Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rest-hooks/normalizr

Package Overview
Dependencies
Maintainers
2
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rest-hooks/normalizr - npm Package Compare versions

Comparing version 7.5.0 to 7.5.1

dist/normalizr.es.min.js

9

CHANGELOG.md

@@ -6,2 +6,11 @@ # Change Log

### [7.5.1](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@7.5.0...@rest-hooks/normalizr@7.5.1) (2021-09-08)
### 🐛 Bug Fix
* Updating nesting under arrays ([#1047](https://github.com/coinbase/rest-hooks/issues/1047)) ([e7addd2](https://github.com/coinbase/rest-hooks/commit/e7addd287bda4c73c93abd38880902d00c28f76d))
## [7.5.0](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@7.4.0...@rest-hooks/normalizr@7.5.0) (2021-07-06)

@@ -8,0 +17,0 @@

96

dist/normalizr.amd.js

@@ -16,4 +16,3 @@ define(['exports'], function (exports) { 'use strict';

function isImmutable(object) {
return !!(object && typeof object.hasOwnProperty === 'function' && (Object.hasOwnProperty.call(object, '__ownerID') || // Immutable.Map
object._map && Object.hasOwnProperty.call(object._map, '__ownerID'))); // Immutable.Record
return !!(object && typeof object.hasOwnProperty === 'function' && (Object.hasOwnProperty.call(object, '__ownerID') || object._map && Object.hasOwnProperty.call(object._map, '__ownerID'))); // Immutable.Record
}

@@ -989,3 +988,5 @@ /**

var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache) {
var DRAFT = Symbol('draft');
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache, dependencies, cycleIndex) {
var entity = getEntity(id, schema);

@@ -1009,12 +1010,13 @@

if (!localCache[schema.key][id]) {
var globalKey = [entity];
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
var trackingIndex = dependencies.length;
dependencies.push(entity);
var wrappedUnvisit = withTrackedEntities(unvisit); // { [DRAFT] } means we are still processing - which if found indicates a cycle
wrappedUnvisit.setLocal = function (entityCopy) {
return localCache[schema.key][id] = entityCopy;
var _localCache$schema$ke;
return localCache[schema.key][id] = (_localCache$schema$ke = {}, _localCache$schema$ke[DRAFT] = entityCopy, _localCache$schema$ke.i = trackingIndex, _localCache$schema$ke);
};
if (!entityCache[schema.key]) entityCache[schema.key] = {};
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap();
var globalCacheEntry = entityCache[schema.key][id];
var globalCacheEntry = getGlobalCacheEntry(entityCache, schema, id);

@@ -1026,11 +1028,25 @@ var _schema$denormalize = schema.denormalize(entity, wrappedUnvisit);

deleted = _schema$denormalize[2];
// if in cycle, use the start of the cycle to track all deps
// otherwise, we use our own trackingIndex
var localKey = dependencies.slice(cycleIndex.i === -1 ? trackingIndex : cycleIndex.i);
if (!globalCacheEntry.has(globalKey)) {
globalCacheEntry.set(globalKey, localCache[schema.key][id]);
if (!globalCacheEntry.has(localKey)) {
globalCacheEntry.set(localKey, localCache[schema.key][id]);
} else {
// localCache is only used before this point for recursive relationships
// since recursive relationships must all referentially change if *any* do, we either
// get the correct one here, or will never find the same version in the cache
localCache[schema.key][id] = globalCacheEntry.get(globalKey);
localCache[schema.key][id] = globalCacheEntry.get(localKey);
} // start of cycle - reset cycle detection
if (cycleIndex.i === trackingIndex) {
cycleIndex.i = -1;
}
} else {
// cycle detected
if (Object.prototype.hasOwnProperty.call(localCache[schema.key][id], DRAFT)) {
cycleIndex.i = localCache[schema.key][id].i;
return [localCache[schema.key][id][DRAFT], found, deleted];
} else {
// with no cycle, globalCacheEntry will have already been set
dependencies.push(entity);
}
}

@@ -1043,2 +1059,6 @@

var getEntity = getEntities(entities);
var dependencies = [];
var cycleIndex = {
i: -1
};

@@ -1054,3 +1074,3 @@ function unvisit(input, schema) {

var method = Array.isArray(schema) ? denormalize$1 : _denormalize;
return method(schema, input, wrappedUnvisit);
return method(schema, input, unvisit);
}

@@ -1070,16 +1090,14 @@ } // null is considered intentional, thus always 'found' as true

return unvisitEntity(input, schema, wrappedUnvisit, getEntity, localCache, entityCache);
return unvisitEntity(input, schema, unvisit, getEntity, localCache, entityCache, dependencies, cycleIndex);
}
if (typeof schema.denormalize === 'function') {
return schema.denormalize(input, wrappedUnvisit);
return schema.denormalize(input, unvisit);
}
return [input, true, false];
}
} //const wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
var globalKey = [];
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
return function (input, schema) {
globalKey.push(input);
var ret = unvisit(input, schema); // in the case where WeakMap cannot be used

@@ -1089,8 +1107,9 @@ // this test ensures null is properly excluded from WeakMap

if (Object(input) !== input) return ret;
dependencies.push(input);
if (!resultCache.has(globalKey)) {
resultCache.set(globalKey, ret[0]);
if (!resultCache.has(dependencies)) {
resultCache.set(dependencies, ret[0]);
return ret;
} else {
return [resultCache.get(globalKey), ret[1], ret[2]];
return [resultCache.get(dependencies), ret[1], ret[2]];
}

@@ -1141,3 +1160,9 @@ };

function withTrackedEntities(unvisit, globalKey) {
function getGlobalCacheEntry(entityCache, schema, id) {
if (!entityCache[schema.key]) entityCache[schema.key] = {};
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap();
return entityCache[schema.key][id];
}
function withTrackedEntities(unvisit) {
// every time we nest, we want to unwrap back to the top.

@@ -1148,14 +1173,3 @@ // this is due to only needed the next level of nested entities for lookup

var wrappedUnvisit = function wrappedUnvisit(input, schema) {
var ret = originalUnvisit(input, schema); // pass over undefined in key
if (ret[0] && schema && isEntity(schema)) {
/* istanbul ignore else */
if (Object(ret[0]) === ret[0]) {
globalKey.push(ret[0]);
} else if (process.env.NODE_ENV !== 'production') {
throw new Error("Unexpected primitive found during denormalization\nFound: " + ret[0] + "\nExpected entity: " + schema);
}
}
return ret;
return originalUnvisit(input, schema);
};

@@ -1267,5 +1281,5 @@

else if ( // eslint-disable-next-line no-undef
process.env.NODE_ENV !== 'production') {
console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: " + index + "\nEntity: " + JSON.stringify(entity, undefined, 2));
}
process.env.NODE_ENV !== 'production') {
console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: " + index + "\nEntity: " + JSON.stringify(entity, undefined, 2));
}
}

@@ -1272,0 +1286,0 @@ } // set this after index updates so we know what indexes to remove from

@@ -1,1 +0,1 @@

define(["exports"],(function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function n(e,t,n){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var s=""+o,a=n(t.get(s),e[s]),u=a[0],c=a[1],f=a[2];return c||(r=!1),f&&(i=!0),t.has(s)?t.set(s,u):t}),t),r,i]}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r(e,t)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}var a=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var s=this.inferSchema(e,t,n);if(!s){if("production"!==process.env.NODE_ENV){var a=this.getSchemaAttribute(e,t,n);console.warn("Schema attribute "+JSON.stringify(a,void 0,2)+" is not expected.\nExpected one of: "+Object.keys(this.schema).map((function(e){return'"'+e+'"'})).join(", ")+"\n\nValue: "+JSON.stringify(e,void 0,2))}return e}var u=r(e,t,n,s,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,n){if(void 0===e)return[e,!1,!1];var r=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0,!1]},s(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),u=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},f=function(e){var t=e[0],n=e[2];return void 0!==t&&!n},l=function(e,t,n,r,i,o,s){return e=u(e),c(t).map((function(t,a){return i(t,n,r,e,o,s)}))},h=function(e,t,n){e=u(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(f).map((function(e){return e[0]})):t,i,r]};function p(e,t,n,r){}var d=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return c(e).map((function(e,a){return s.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(f).map((function(e){return e[0]})):e,i,r]},n.infer=function(e,t,n){this.schema},t}(a),y=function(e,t,n,r,i,o,s){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],u=i(t[n],t,n,r,o,s);null==u?delete a[n]:a[n]=u})),a},m=function(e,r,i){if(t(r))return n(e,r,i);var o=Object.assign({},r),s=!0,a=!1;return Object.keys(e).forEach((function(t){var n=i(o[t],e[t]),r=n[0],u=n[1],c=n[2];void 0!==o[t]&&(o[t]=r),c&&(a=!0),u||(s=!1)})),[o,s,a]};function v(e,t,n,r){for(var i={},o=0,s=Object.keys(e);o<s.length;o++){var a=s[o];i[a]=r(e[a],t,n)}return i}var g=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.apply(void 0,[this.schema].concat(t))},t.infer=function(e,t,n){return v(this.schema,e,t,n)},e}();function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function O(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var k=Symbol("Defined Members"),w=Symbol("unq"),j=function(){function e(){}return e.prototype.toString=function(){return this[w]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,k,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,w,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[k].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=O(e[k]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[k]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},e.infer=function(e,t,n){return v(this.schema,e,t,n)},e.denormalize=function(e,t){var n=this,r=Object.assign({},e),i=!1,o=!0;return Object.keys(this.schema).forEach((function(e){var s=t(r[e],n.schema[e]),a=s[0],u=s[1],c=s[2];void 0!==r[e]&&(r[e]=a),u||e in n.defaults&&!n.defaults[e]||(o=!1),!c||e in n.defaults&&!n.defaults[e]||(i=!0)})),[this.fromJS(r),o,i]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},s(e,null,[{key:"defaults",get:function(){return Object.prototype.hasOwnProperty.call(this,"__defaults")||(this.__defaults=new this),this.__defaults}}]),e}();j.schema={};var E=function(e){function r(){return e.apply(this,arguments)||this}return i(r,e),r.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},r.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},r.normalize=function(e,t,n,r,i,o){var s=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);this.validate(a,e);var u=a.pk(t,n);if(void 0!==u&&""!==u){var c=this.key;return c in o||(o[c]={}),u in o[c]||(o[c][u]=[]),o[c][u].some((function(t){return t===e}))?u:(o[c][u].push(e),Object.keys(this.schema).forEach((function(e){if(Object.prototype.hasOwnProperty.call(a,e)){var t=s.schema[e];a[e]=r(a[e],a,e,t,i,o)}else if("production"!==process.env.NODE_ENV){var n=new Error("Schema key is missing in Entity\n\n Be sure all schema members are also part of the entity\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about nesting schemas: https://resthooks.io/docs/guides/nested-response\n\n Entity keys: "+Object.keys(a)+"\n Schema key(missing): "+e+"\n ");throw n.status=400,n}})),i(this,a,u),u)}if("production"!==process.env.NODE_ENV){var f=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Entity: "+this.name+"\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw f.status=400,f}},r.validate=function(e,t){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation){for(var n,r=new Set(Object.keys(this.defaults)),i=this.keysDefined(e),o=[[],[],[]],s=o[0],a=o[1],u=o[2],c=O(i);!(n=c()).done;){var f=n.value;r.has(f)?s.push(f):u.push(f)}for(var l,h=O(r);!(l=h()).done;){var p=l.value;s.includes(p)||a.push(p)}if(r.size){if(Array.isArray(t)&&u.length){var d="Attempted to initialize "+this.name+" with an array, but named members were expected\n\nThis is likely due to a malformed response.\nTry inspecting the network response or fetch() return value.\nOr use debugging tools: https://resthooks.io/docs/guides/debugging\nLearn more about schemas: https://resthooks.io/docs/api/schema\nIf this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\nMissing: "+a+"\nFirst three members: "+JSON.stringify(t.slice(0,3),null,2);if("warn"!==this.automaticValidation){var y=new Error(d);throw y.status=400,y}console.warn(d)}var m=Math.max(i.length/2,1)<=u.length&&r.size>Math.max(u.length,2)&&Math.pow(s.length,1.5)/2<=u.length,v=s.length<Math.min(1,r.size/2);if(m||v){var g="",b="substantially different than expected keys";v&&(g+="\n Missing: "+a,b="no matching keys found"),m&&(g+="\n Unexpected keys: "+u,b="a large number of unexpected keys found");var k="Attempted to initialize "+this.name+" with "+b+"\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n If this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\n Expected keys:\n Found: "+s+g+"\n Value: "+JSON.stringify(this.toObjectDefined(e),null,2);if(!(s.length>=4&&m||"warn"===this.automaticValidation)){var w=new Error(k);throw w.status=400,w}console.warn(k)}}}},r.expiresAt=function(e,t){return e.expiresAt},r.infer=function(e,t,n){if(e[0]){var r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;var i=function(e,t){return t?t.find((function(t){return Object.prototype.hasOwnProperty.call(e,t)})):void 0}(e[0],this.indexes);return i&&t[this.key]?t[this.key][i][e[0][i]]:void 0}},r.denormalize=function(e,r){var i=this,o=t(e)?e:this.fromJS(e instanceof j?this.toObjectDefined(e):e);if(null==r.setLocal||r.setLocal(o),t(e)){var s=n(this.schema,e,r),a=s[0],u=s[1],c=s[2];return[this.fromJS(a.toObject()),u,c]}var f=!1;return Object.keys(this.schema).forEach((function(t){var n=i.schema[t],s=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,a=r(s,n),u=a[0];!a[2]||Object.prototype.hasOwnProperty.call(e,t)&&!i.defaults[t]||(f=!0),Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==u&&(o[t]=u)})),[o,!0,f]},s(r,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name||"_temp"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),r}(j);function S(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(E.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return j.fromJS.call(this,e)});var _=Symbol("ENTITY WAS DELETED");function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function A(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function N(e,t,n){return(N=A()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&r(o,n.prototype),o}).apply(null,arguments)}function x(e){var t="function"==typeof Map?new Map:void 0;return(x=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return N(e,arguments,z(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,e)})(e)}var D=function(){this.children=new WeakMap},V=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return i(t,e),t}(x(Error)),J=function(){function e(){this.first=new WeakMap}var t=e.prototype;return t.delete=function(e){var t=this.traverse(e);return null==t||delete t.value,!!t},t.get=function(e){var t=this.traverse(e);return null==t?void 0:t.value},t.has=function(e){var t=this.traverse(e);return!!t&&Object.prototype.hasOwnProperty.call(t,"value")},t.set=function(e,t){if(e.length<1)throw new V;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new D,r.set(e[i],n)),r=n.children,i===e.length-1&&(n.value=t);return this},t.traverse=function(e){for(var t,n=this.first,r=0;r<e.length;r++){if(!(t=n.get(e[r])))return;n=t.children}return t},e}(),P=function(e,t,n,r){var i=M(e);function o(e,n){if(!n)return[e,!0,!1];if(!n.denormalize||"function"!=typeof n.denormalize){if("function"==typeof n)return e instanceof n?[e,!0,!1]:[new n(e),!0,!1];if("object"==typeof n)return(Array.isArray(n)?h:m)(n,e,a)}return null===e?[e,!0,!1]:S(n)?void 0===e?[e,!1,!1]:function(e,t,n,r,i,o){var s=r(e,t);if(s===_)return[void 0,!0,!0];if("object"!=typeof s||null===s)return[s,!1,!1];void 0===i[t.key]&&(i[t.key]={});var a=!0,u=!1;if(!i[t.key][e]){var c=[s],f=T(n,c);f.setLocal=function(n){return i[t.key][e]=n},o[t.key]||(o[t.key]={}),o[t.key][e]||(o[t.key][e]=new J);var l=o[t.key][e],h=t.denormalize(s,f);i[t.key][e]=h[0],a=h[1],u=h[2],l.has(c)?i[t.key][e]=l.get(c):l.set(c,i[t.key][e])}return[i[t.key][e],a,u]}(e,n,a,i,r,t):"function"==typeof n.denormalize?n.denormalize(e,a):[e,!0,!1]}var s=[],a=T(o,s);return function(e,t){s.push(e);var r=o(e,t);return Object(e)!==e?r:n.has(s)?[n.get(s),r[1],r[2]]:(n.set(s,r[0]),r)}},M=function(e){var n=t(e);return function(t,r){var i=r.key;return"object"==typeof t?t:n?e.getIn([i,t]):e[i]&&e[i][t]}};function T(e,t){var n=e.og||e,r=function(e,r){var i=n(e,r);if(i[0]&&r&&S(r))if(Object(i[0])===i[0])t.push(i[0]);else if("production"!==process.env.NODE_ENV)throw new Error("Unexpected primitive found during denormalization\nFound: "+i[0]+"\nExpected entity: "+r);return i};return r.og=e,r}var I=function e(t,n,r,i,o,s){return t&&i?i.normalize&&"function"==typeof i.normalize?"object"!=typeof t?t:i.normalize(t,n,r,e,o,s):"function"==typeof i?new i(t):"object"!=typeof t||"object"!=typeof i?t:(Array.isArray(i)?l:y)(i,t,n,r,e,o,s):t};var L=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},n.infer=function(e,t,n){var r=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[r];if(void 0!==i)return{id:n(i,e,t),schema:r}},t}(a),R=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return Object.keys(e).reduce((function(t,n,a){var u,c=e[n];return null!=c?Object.assign({},t,((u={})[n]=s.normalizeValue(c,e,n,r,i,o),u)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,s){var a,u=e[s],c=n.denormalizeValue(u,t),f=c[0],l=c[1],h=c[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[s]=f,a))}),{}),r,i]},n.infer=function(e,t,n){},t}(a),U=function(){function e(e){if("production"!==process.env.NODE_ENV&&!e)throw new Error('Expected option "entity" not found on DeleteSchema.');this._entity=e}var t=e.prototype;return t.normalize=function(e,t,n,r,i,o){if("string"==typeof e)return e;var s=this._entity.fromJS(e,t,n).pk(t,n);if("production"!==process.env.NODE_ENV&&(void 0===s||""===s)){var a,u=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Delete(Entity): Delete("+(null!=(a=this._entity.name)?a:this._entity)+")\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw u.status=400,u}return i(this,_,s),s},t.infer=function(e,t,n){},t.denormalize=function(e,t){return t(e,this._entity)},t._denormalizeNullable=function(){return[]},t._normalizeNullable=function(){return[]},t.merge=function(e,t){return t},s(e,[{key:"key",get:function(){return this._entity.key}}]),e}(),F=Object.freeze({__proto__:null,Union:L,Values:R,Array:d,Object:g,Delete:U}),B=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(E);e.DELETED=_,e.Entity=E,e.FlatEntity=B,e.SimpleRecord=j,e.WeakListMap=J,e.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new J),void 0===t)return[e,!0,!1,{}];if(void 0===e)return[void 0,!1,!1,{}];var o={},s=P(n,r,i,o);return[].concat(s(e,t),[o])},e.inferResults=function e(t,n,r){return function(e){return!!e&&"function"==typeof e.infer}(t)?t.infer(n,r,e):"object"==typeof t&&t?(Array.isArray(t)?p:v)(t,n,r,e):t},e.isEntity=S,e.normalize=function(e,t,n,r,i,o){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i={}),void 0===o&&(o={date:Date.now(),expiresAt:1/0}),void 0===t)return{entities:n,indexes:r,result:e,entityMeta:i};var s=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==s){if("production"!==process.env.NODE_ENV){throw"string"==typeof e&&function(e){try{return"string"!=typeof JSON.parse(e)}catch(e){return!1}}(e)?new Error('Normalizing a string, but this does match schema.\n\nParsing this input string as JSON worked. This likely indicates fetch function did not parse\nthe JSON. By default, this only happens if "content-type" header includes "json".\nSee https://resthooks.io/docs/guides/custom-networking for more information\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".')}var a=Object.assign({},n),u=Object.assign({},r),c=Object.assign({},i),f=function(e,t,n,r,i,o){return function(s,a,u){var c=s.key;c in e||(e[c]={},n[c]=Object.assign({},n[c]),i[c]=Object.assign({},i[c]));var f=e[c][u];if(f)e[c][u]=s.merge(f,a);else{var l=s.expiresAt?s.expiresAt(o,a):o.expiresAt,h=n[c][u];if(h){var p,d,y=(null==(p=i[c][u])?void 0:p.date)>o.date;e[c][u]=typeof a!=typeof h?y?h:a:y?s.merge(a,h):s.merge(h,a),i[c][u]=(null==(d=i[c][u])?void 0:d.expiresAt)>=l?i[c][u]:{expiresAt:l,date:o.date}}else e[c][u]=a,i[c][u]={expiresAt:l,date:o.date}}if(Array.isArray(s.indexes)){var m=e[c][u];c in t||(t[c]={},r[c]=Object.assign({},r[c]));for(var v,g=O(s.indexes);!(v=g()).done;){var b=v.value;b in t[c]||(r[c][b]=t[c][b]={});var k=t[c][b];f&&delete k[f[b]],n[c]&&n[c][u]&&n[c][u][b]!==m[b]&&(k[n[c][u][b]]=_),b in m?k[m[b]]=u:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+b+"\nEntity: "+JSON.stringify(m,void 0,2))}}n[c][u]=e[c][u]}}({},{},a,u,c,o);return{entities:a,indexes:u,result:I(e,e,void 0,t,f,{}),entityMeta:c}},e.schema=F,Object.defineProperty(e,"__esModule",{value:!0})}));
define(["exports"],(function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function n(e,t,n){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var s=""+o,a=n(t.get(s),e[s]),u=a[0],c=a[1],f=a[2];return c||(r=!1),f&&(i=!0),t.has(s)?t.set(s,u):t}),t),r,i]}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r(e,t)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}var a=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var s=this.inferSchema(e,t,n);if(!s){if("production"!==process.env.NODE_ENV){var a=this.getSchemaAttribute(e,t,n);console.warn("Schema attribute "+JSON.stringify(a,void 0,2)+" is not expected.\nExpected one of: "+Object.keys(this.schema).map((function(e){return'"'+e+'"'})).join(", ")+"\n\nValue: "+JSON.stringify(e,void 0,2))}return e}var u=r(e,t,n,s,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,n){if(void 0===e)return[e,!1,!1];var r=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0,!1]},s(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),u=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},f=function(e){var t=e[0],n=e[2];return void 0!==t&&!n},l=function(e,t,n,r,i,o,s){return e=u(e),c(t).map((function(t,a){return i(t,n,r,e,o,s)}))},h=function(e,t,n){e=u(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(f).map((function(e){return e[0]})):t,i,r]};function p(e,t,n,r){}var d=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return c(e).map((function(e,a){return s.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(f).map((function(e){return e[0]})):e,i,r]},n.infer=function(e,t,n){this.schema},t}(a),y=function(e,t,n,r,i,o,s){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],u=i(t[n],t,n,r,o,s);null==u?delete a[n]:a[n]=u})),a},m=function(e,r,i){if(t(r))return n(e,r,i);var o=Object.assign({},r),s=!0,a=!1;return Object.keys(e).forEach((function(t){var n=i(o[t],e[t]),r=n[0],u=n[1],c=n[2];void 0!==o[t]&&(o[t]=r),c&&(a=!0),u||(s=!1)})),[o,s,a]};function v(e,t,n,r){for(var i={},o=0,s=Object.keys(e);o<s.length;o++){var a=s[o];i[a]=r(e[a],t,n)}return i}var g=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.apply(void 0,[this.schema].concat(t))},t.infer=function(e,t,n){return v(this.schema,e,t,n)},e}();function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function O(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var k=Symbol("Defined Members"),w=Symbol("unq"),j=function(){function e(){}return e.prototype.toString=function(){return this[w]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,k,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,w,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[k].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=O(e[k]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[k]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},e.infer=function(e,t,n){return v(this.schema,e,t,n)},e.denormalize=function(e,t){var n=this,r=Object.assign({},e),i=!1,o=!0;return Object.keys(this.schema).forEach((function(e){var s=t(r[e],n.schema[e]),a=s[0],u=s[1],c=s[2];void 0!==r[e]&&(r[e]=a),u||e in n.defaults&&!n.defaults[e]||(o=!1),!c||e in n.defaults&&!n.defaults[e]||(i=!0)})),[this.fromJS(r),o,i]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},s(e,null,[{key:"defaults",get:function(){return Object.prototype.hasOwnProperty.call(this,"__defaults")||(this.__defaults=new this),this.__defaults}}]),e}();j.schema={};var S=function(e){function r(){return e.apply(this,arguments)||this}return i(r,e),r.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},r.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},r.normalize=function(e,t,n,r,i,o){var s=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);this.validate(a,e);var u=a.pk(t,n);if(void 0!==u&&""!==u){var c=this.key;return c in o||(o[c]={}),u in o[c]||(o[c][u]=[]),o[c][u].some((function(t){return t===e}))?u:(o[c][u].push(e),Object.keys(this.schema).forEach((function(e){if(Object.prototype.hasOwnProperty.call(a,e)){var t=s.schema[e];a[e]=r(a[e],a,e,t,i,o)}else if("production"!==process.env.NODE_ENV){var n=new Error("Schema key is missing in Entity\n\n Be sure all schema members are also part of the entity\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about nesting schemas: https://resthooks.io/docs/guides/nested-response\n\n Entity keys: "+Object.keys(a)+"\n Schema key(missing): "+e+"\n ");throw n.status=400,n}})),i(this,a,u),u)}if("production"!==process.env.NODE_ENV){var f=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Entity: "+this.name+"\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw f.status=400,f}},r.validate=function(e,t){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation){for(var n,r=new Set(Object.keys(this.defaults)),i=this.keysDefined(e),o=[[],[],[]],s=o[0],a=o[1],u=o[2],c=O(i);!(n=c()).done;){var f=n.value;r.has(f)?s.push(f):u.push(f)}for(var l,h=O(r);!(l=h()).done;){var p=l.value;s.includes(p)||a.push(p)}if(r.size){if(Array.isArray(t)&&u.length){var d="Attempted to initialize "+this.name+" with an array, but named members were expected\n\nThis is likely due to a malformed response.\nTry inspecting the network response or fetch() return value.\nOr use debugging tools: https://resthooks.io/docs/guides/debugging\nLearn more about schemas: https://resthooks.io/docs/api/schema\nIf this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\nMissing: "+a+"\nFirst three members: "+JSON.stringify(t.slice(0,3),null,2);if("warn"!==this.automaticValidation){var y=new Error(d);throw y.status=400,y}console.warn(d)}var m=Math.max(i.length/2,1)<=u.length&&r.size>Math.max(u.length,2)&&Math.pow(s.length,1.5)/2<=u.length,v=s.length<Math.min(1,r.size/2);if(m||v){var g="",b="substantially different than expected keys";v&&(g+="\n Missing: "+a,b="no matching keys found"),m&&(g+="\n Unexpected keys: "+u,b="a large number of unexpected keys found");var k="Attempted to initialize "+this.name+" with "+b+"\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n If this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\n Expected keys:\n Found: "+s+g+"\n Value: "+JSON.stringify(this.toObjectDefined(e),null,2);if(!(s.length>=4&&m||"warn"===this.automaticValidation)){var w=new Error(k);throw w.status=400,w}console.warn(k)}}}},r.expiresAt=function(e,t){return e.expiresAt},r.infer=function(e,t,n){if(e[0]){var r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;var i=function(e,t){return t?t.find((function(t){return Object.prototype.hasOwnProperty.call(e,t)})):void 0}(e[0],this.indexes);return i&&t[this.key]?t[this.key][i][e[0][i]]:void 0}},r.denormalize=function(e,r){var i=this,o=t(e)?e:this.fromJS(e instanceof j?this.toObjectDefined(e):e);if(null==r.setLocal||r.setLocal(o),t(e)){var s=n(this.schema,e,r),a=s[0],u=s[1],c=s[2];return[this.fromJS(a.toObject()),u,c]}var f=!1;return Object.keys(this.schema).forEach((function(t){var n=i.schema[t],s=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,a=r(s,n),u=a[0];!a[2]||Object.prototype.hasOwnProperty.call(e,t)&&!i.defaults[t]||(f=!0),Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==u&&(o[t]=u)})),[o,!0,f]},s(r,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name||"_temp"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),r}(j);function E(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(S.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return j.fromJS.call(this,e)});var _=Symbol("ENTITY WAS DELETED");function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function A(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function N(e,t,n){return(N=A()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&r(o,n.prototype),o}).apply(null,arguments)}function x(e){var t="function"==typeof Map?new Map:void 0;return(x=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return N(e,arguments,z(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,e)})(e)}var D=function(){this.children=new WeakMap},V=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return i(t,e),t}(x(Error)),J=function(){function e(){this.first=new WeakMap}var t=e.prototype;return t.delete=function(e){var t=this.traverse(e);return null==t||delete t.value,!!t},t.get=function(e){var t=this.traverse(e);return null==t?void 0:t.value},t.has=function(e){var t=this.traverse(e);return!!t&&Object.prototype.hasOwnProperty.call(t,"value")},t.set=function(e,t){if(e.length<1)throw new V;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new D,r.set(e[i],n)),r=n.children,i===e.length-1&&(n.value=t);return this},t.traverse=function(e){for(var t,n=this.first,r=0;r<e.length;r++){if(!(t=n.get(e[r])))return;n=t.children}return t},e}(),P=Symbol("draft"),M=function(e,t,n,r,i,o,s,a){var u=r(e,t);if(u===_)return[void 0,!0,!0];if("object"!=typeof u||null===u)return[u,!1,!1];void 0===i[t.key]&&(i[t.key]={});var c=!0,f=!1;if(i[t.key][e]){if(Object.prototype.hasOwnProperty.call(i[t.key][e],P))return a.i=i[t.key][e].i,[i[t.key][e][P],c,f];s.push(u)}else{var l=s.length;s.push(u);var h=function(e){var t=e.og||e,n=function(e,n){return t(e,n)};return n.og=e,n}(n);h.setLocal=function(n){var r;return i[t.key][e]=((r={})[P]=n,r.i=l,r)};var p=function(e,t,n){e[t.key]||(e[t.key]={});e[t.key][n]||(e[t.key][n]=new J);return e[t.key][n]}(o,t,e),d=t.denormalize(u,h);i[t.key][e]=d[0],c=d[1],f=d[2];var y=s.slice(-1===a.i?l:a.i);p.has(y)?i[t.key][e]=p.get(y):p.set(y,i[t.key][e]),a.i===l&&(a.i=-1)}return[i[t.key][e],c,f]},T=function(e){var n=t(e);return function(t,r){var i=r.key;return"object"==typeof t?t:n?e.getIn([i,t]):e[i]&&e[i][t]}};var I=function e(t,n,r,i,o,s){return t&&i?i.normalize&&"function"==typeof i.normalize?"object"!=typeof t?t:i.normalize(t,n,r,e,o,s):"function"==typeof i?new i(t):"object"!=typeof t||"object"!=typeof i?t:(Array.isArray(i)?l:y)(i,t,n,r,e,o,s):t};var L=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},n.infer=function(e,t,n){var r=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[r];if(void 0!==i)return{id:n(i,e,t),schema:r}},t}(a),R=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return Object.keys(e).reduce((function(t,n,a){var u,c=e[n];return null!=c?Object.assign({},t,((u={})[n]=s.normalizeValue(c,e,n,r,i,o),u)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,s){var a,u=e[s],c=n.denormalizeValue(u,t),f=c[0],l=c[1],h=c[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[s]=f,a))}),{}),r,i]},n.infer=function(e,t,n){},t}(a),U=function(){function e(e){if("production"!==process.env.NODE_ENV&&!e)throw new Error('Expected option "entity" not found on DeleteSchema.');this._entity=e}var t=e.prototype;return t.normalize=function(e,t,n,r,i,o){if("string"==typeof e)return e;var s=this._entity.fromJS(e,t,n).pk(t,n);if("production"!==process.env.NODE_ENV&&(void 0===s||""===s)){var a,u=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Delete(Entity): Delete("+(null!=(a=this._entity.name)?a:this._entity)+")\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw u.status=400,u}return i(this,_,s),s},t.infer=function(e,t,n){},t.denormalize=function(e,t){return t(e,this._entity)},t._denormalizeNullable=function(){return[]},t._normalizeNullable=function(){return[]},t.merge=function(e,t){return t},s(e,[{key:"key",get:function(){return this._entity.key}}]),e}(),F=Object.freeze({__proto__:null,Union:L,Values:R,Array:d,Object:g,Delete:U}),B=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(S);e.DELETED=_,e.Entity=S,e.FlatEntity=B,e.SimpleRecord=j,e.WeakListMap=J,e.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new J),void 0===t)return[e,!0,!1,{}];if(void 0===e)return[void 0,!1,!1,{}];var o={},s=function(e,t,n,r){var i=T(e),o=[],s={i:-1};function a(e,n){if(!n)return[e,!0,!1];if(!n.denormalize||"function"!=typeof n.denormalize){if("function"==typeof n)return e instanceof n?[e,!0,!1]:[new n(e),!0,!1];if("object"==typeof n)return(Array.isArray(n)?h:m)(n,e,a)}return null===e?[e,!0,!1]:E(n)?void 0===e?[e,!1,!1]:M(e,n,a,i,r,t,o,s):"function"==typeof n.denormalize?n.denormalize(e,a):[e,!0,!1]}return function(e,t){var r=a(e,t);return Object(e)!==e?r:(o.push(e),n.has(o)?[n.get(o),r[1],r[2]]:(n.set(o,r[0]),r))}}(n,r,i,o);return[].concat(s(e,t),[o])},e.inferResults=function e(t,n,r){return function(e){return!!e&&"function"==typeof e.infer}(t)?t.infer(n,r,e):"object"==typeof t&&t?(Array.isArray(t)?p:v)(t,n,r,e):t},e.isEntity=E,e.normalize=function(e,t,n,r,i,o){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i={}),void 0===o&&(o={date:Date.now(),expiresAt:1/0}),void 0===t)return{entities:n,indexes:r,result:e,entityMeta:i};var s=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==s){if("production"!==process.env.NODE_ENV){throw"string"==typeof e&&function(e){try{return"string"!=typeof JSON.parse(e)}catch(e){return!1}}(e)?new Error('Normalizing a string, but this does match schema.\n\nParsing this input string as JSON worked. This likely indicates fetch function did not parse\nthe JSON. By default, this only happens if "content-type" header includes "json".\nSee https://resthooks.io/docs/guides/custom-networking for more information\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".')}var a=Object.assign({},n),u=Object.assign({},r),c=Object.assign({},i),f=function(e,t,n,r,i,o){return function(s,a,u){var c=s.key;c in e||(e[c]={},n[c]=Object.assign({},n[c]),i[c]=Object.assign({},i[c]));var f=e[c][u];if(f)e[c][u]=s.merge(f,a);else{var l=s.expiresAt?s.expiresAt(o,a):o.expiresAt,h=n[c][u];if(h){var p,d,y=(null==(p=i[c][u])?void 0:p.date)>o.date;e[c][u]=typeof a!=typeof h?y?h:a:y?s.merge(a,h):s.merge(h,a),i[c][u]=(null==(d=i[c][u])?void 0:d.expiresAt)>=l?i[c][u]:{expiresAt:l,date:o.date}}else e[c][u]=a,i[c][u]={expiresAt:l,date:o.date}}if(Array.isArray(s.indexes)){var m=e[c][u];c in t||(t[c]={},r[c]=Object.assign({},r[c]));for(var v,g=O(s.indexes);!(v=g()).done;){var b=v.value;b in t[c]||(r[c][b]=t[c][b]={});var k=t[c][b];f&&delete k[f[b]],n[c]&&n[c][u]&&n[c][u][b]!==m[b]&&(k[n[c][u][b]]=_),b in m?k[m[b]]=u:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+b+"\nEntity: "+JSON.stringify(m,void 0,2))}}n[c][u]=e[c][u]}}({},{},a,u,c,o);return{entities:a,indexes:u,result:I(e,e,void 0,t,f,{}),entityMeta:c}},e.schema=F,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -17,4 +17,3 @@ var rest_hooks_normalizr = (function (exports) {

function isImmutable(object) {
return !!(object && typeof object.hasOwnProperty === 'function' && (Object.hasOwnProperty.call(object, '__ownerID') || // Immutable.Map
object._map && Object.hasOwnProperty.call(object._map, '__ownerID'))); // Immutable.Record
return !!(object && typeof object.hasOwnProperty === 'function' && (Object.hasOwnProperty.call(object, '__ownerID') || object._map && Object.hasOwnProperty.call(object._map, '__ownerID'))); // Immutable.Record
}

@@ -990,3 +989,5 @@ /**

var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache) {
var DRAFT = Symbol('draft');
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache, dependencies, cycleIndex) {
var entity = getEntity(id, schema);

@@ -1010,12 +1011,13 @@

if (!localCache[schema.key][id]) {
var globalKey = [entity];
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
var trackingIndex = dependencies.length;
dependencies.push(entity);
var wrappedUnvisit = withTrackedEntities(unvisit); // { [DRAFT] } means we are still processing - which if found indicates a cycle
wrappedUnvisit.setLocal = function (entityCopy) {
return localCache[schema.key][id] = entityCopy;
var _localCache$schema$ke;
return localCache[schema.key][id] = (_localCache$schema$ke = {}, _localCache$schema$ke[DRAFT] = entityCopy, _localCache$schema$ke.i = trackingIndex, _localCache$schema$ke);
};
if (!entityCache[schema.key]) entityCache[schema.key] = {};
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap();
var globalCacheEntry = entityCache[schema.key][id];
var globalCacheEntry = getGlobalCacheEntry(entityCache, schema, id);

@@ -1027,11 +1029,25 @@ var _schema$denormalize = schema.denormalize(entity, wrappedUnvisit);

deleted = _schema$denormalize[2];
// if in cycle, use the start of the cycle to track all deps
// otherwise, we use our own trackingIndex
var localKey = dependencies.slice(cycleIndex.i === -1 ? trackingIndex : cycleIndex.i);
if (!globalCacheEntry.has(globalKey)) {
globalCacheEntry.set(globalKey, localCache[schema.key][id]);
if (!globalCacheEntry.has(localKey)) {
globalCacheEntry.set(localKey, localCache[schema.key][id]);
} else {
// localCache is only used before this point for recursive relationships
// since recursive relationships must all referentially change if *any* do, we either
// get the correct one here, or will never find the same version in the cache
localCache[schema.key][id] = globalCacheEntry.get(globalKey);
localCache[schema.key][id] = globalCacheEntry.get(localKey);
} // start of cycle - reset cycle detection
if (cycleIndex.i === trackingIndex) {
cycleIndex.i = -1;
}
} else {
// cycle detected
if (Object.prototype.hasOwnProperty.call(localCache[schema.key][id], DRAFT)) {
cycleIndex.i = localCache[schema.key][id].i;
return [localCache[schema.key][id][DRAFT], found, deleted];
} else {
// with no cycle, globalCacheEntry will have already been set
dependencies.push(entity);
}
}

@@ -1044,2 +1060,6 @@

var getEntity = getEntities(entities);
var dependencies = [];
var cycleIndex = {
i: -1
};

@@ -1055,3 +1075,3 @@ function unvisit(input, schema) {

var method = Array.isArray(schema) ? denormalize$1 : _denormalize;
return method(schema, input, wrappedUnvisit);
return method(schema, input, unvisit);
}

@@ -1071,16 +1091,14 @@ } // null is considered intentional, thus always 'found' as true

return unvisitEntity(input, schema, wrappedUnvisit, getEntity, localCache, entityCache);
return unvisitEntity(input, schema, unvisit, getEntity, localCache, entityCache, dependencies, cycleIndex);
}
if (typeof schema.denormalize === 'function') {
return schema.denormalize(input, wrappedUnvisit);
return schema.denormalize(input, unvisit);
}
return [input, true, false];
}
} //const wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
var globalKey = [];
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
return function (input, schema) {
globalKey.push(input);
var ret = unvisit(input, schema); // in the case where WeakMap cannot be used

@@ -1090,8 +1108,9 @@ // this test ensures null is properly excluded from WeakMap

if (Object(input) !== input) return ret;
dependencies.push(input);
if (!resultCache.has(globalKey)) {
resultCache.set(globalKey, ret[0]);
if (!resultCache.has(dependencies)) {
resultCache.set(dependencies, ret[0]);
return ret;
} else {
return [resultCache.get(globalKey), ret[1], ret[2]];
return [resultCache.get(dependencies), ret[1], ret[2]];
}

@@ -1142,3 +1161,9 @@ };

function withTrackedEntities(unvisit, globalKey) {
function getGlobalCacheEntry(entityCache, schema, id) {
if (!entityCache[schema.key]) entityCache[schema.key] = {};
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap();
return entityCache[schema.key][id];
}
function withTrackedEntities(unvisit) {
// every time we nest, we want to unwrap back to the top.

@@ -1149,14 +1174,3 @@ // this is due to only needed the next level of nested entities for lookup

var wrappedUnvisit = function wrappedUnvisit(input, schema) {
var ret = originalUnvisit(input, schema); // pass over undefined in key
if (ret[0] && schema && isEntity(schema)) {
/* istanbul ignore else */
if (Object(ret[0]) === ret[0]) {
globalKey.push(ret[0]);
} else if (process.env.NODE_ENV !== 'production') {
throw new Error("Unexpected primitive found during denormalization\nFound: " + ret[0] + "\nExpected entity: " + schema);
}
}
return ret;
return originalUnvisit(input, schema);
};

@@ -1268,5 +1282,5 @@

else if ( // eslint-disable-next-line no-undef
process.env.NODE_ENV !== 'production') {
console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: " + index + "\nEntity: " + JSON.stringify(entity, undefined, 2));
}
process.env.NODE_ENV !== 'production') {
console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: " + index + "\nEntity: " + JSON.stringify(entity, undefined, 2));
}
}

@@ -1273,0 +1287,0 @@ } // set this after index updates so we know what indexes to remove from

@@ -1,1 +0,1 @@

var rest_hooks_normalizr=function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function n(e,t,n){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var s=""+o,a=n(t.get(s),e[s]),u=a[0],c=a[1],f=a[2];return c||(r=!1),f&&(i=!0),t.has(s)?t.set(s,u):t}),t),r,i]}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r(e,t)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}var a=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var s=this.inferSchema(e,t,n);if(!s){if("production"!==process.env.NODE_ENV){var a=this.getSchemaAttribute(e,t,n);console.warn("Schema attribute "+JSON.stringify(a,void 0,2)+" is not expected.\nExpected one of: "+Object.keys(this.schema).map((function(e){return'"'+e+'"'})).join(", ")+"\n\nValue: "+JSON.stringify(e,void 0,2))}return e}var u=r(e,t,n,s,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,n){if(void 0===e)return[e,!1,!1];var r=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0,!1]},s(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),u=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},f=function(e){var t=e[0],n=e[2];return void 0!==t&&!n},l=function(e,t,n,r,i,o,s){return e=u(e),c(t).map((function(t,a){return i(t,n,r,e,o,s)}))},h=function(e,t,n){e=u(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(f).map((function(e){return e[0]})):t,i,r]};function p(e,t,n,r){}var d=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return c(e).map((function(e,a){return s.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(f).map((function(e){return e[0]})):e,i,r]},n.infer=function(e,t,n){this.schema},t}(a),y=function(e,t,n,r,i,o,s){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],u=i(t[n],t,n,r,o,s);null==u?delete a[n]:a[n]=u})),a},m=function(e,r,i){if(t(r))return n(e,r,i);var o=Object.assign({},r),s=!0,a=!1;return Object.keys(e).forEach((function(t){var n=i(o[t],e[t]),r=n[0],u=n[1],c=n[2];void 0!==o[t]&&(o[t]=r),c&&(a=!0),u||(s=!1)})),[o,s,a]};function v(e,t,n,r){for(var i={},o=0,s=Object.keys(e);o<s.length;o++){var a=s[o];i[a]=r(e[a],t,n)}return i}var g=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.apply(void 0,[this.schema].concat(t))},t.infer=function(e,t,n){return v(this.schema,e,t,n)},e}();function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function O(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var k=Symbol("Defined Members"),w=Symbol("unq"),j=function(){function e(){}return e.prototype.toString=function(){return this[w]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,k,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,w,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[k].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=O(e[k]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[k]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},e.infer=function(e,t,n){return v(this.schema,e,t,n)},e.denormalize=function(e,t){var n=this,r=Object.assign({},e),i=!1,o=!0;return Object.keys(this.schema).forEach((function(e){var s=t(r[e],n.schema[e]),a=s[0],u=s[1],c=s[2];void 0!==r[e]&&(r[e]=a),u||e in n.defaults&&!n.defaults[e]||(o=!1),!c||e in n.defaults&&!n.defaults[e]||(i=!0)})),[this.fromJS(r),o,i]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},s(e,null,[{key:"defaults",get:function(){return Object.prototype.hasOwnProperty.call(this,"__defaults")||(this.__defaults=new this),this.__defaults}}]),e}();j.schema={};var E=function(e){function r(){return e.apply(this,arguments)||this}return i(r,e),r.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},r.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},r.normalize=function(e,t,n,r,i,o){var s=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);this.validate(a,e);var u=a.pk(t,n);if(void 0!==u&&""!==u){var c=this.key;return c in o||(o[c]={}),u in o[c]||(o[c][u]=[]),o[c][u].some((function(t){return t===e}))?u:(o[c][u].push(e),Object.keys(this.schema).forEach((function(e){if(Object.prototype.hasOwnProperty.call(a,e)){var t=s.schema[e];a[e]=r(a[e],a,e,t,i,o)}else if("production"!==process.env.NODE_ENV){var n=new Error("Schema key is missing in Entity\n\n Be sure all schema members are also part of the entity\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about nesting schemas: https://resthooks.io/docs/guides/nested-response\n\n Entity keys: "+Object.keys(a)+"\n Schema key(missing): "+e+"\n ");throw n.status=400,n}})),i(this,a,u),u)}if("production"!==process.env.NODE_ENV){var f=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Entity: "+this.name+"\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw f.status=400,f}},r.validate=function(e,t){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation){for(var n,r=new Set(Object.keys(this.defaults)),i=this.keysDefined(e),o=[[],[],[]],s=o[0],a=o[1],u=o[2],c=O(i);!(n=c()).done;){var f=n.value;r.has(f)?s.push(f):u.push(f)}for(var l,h=O(r);!(l=h()).done;){var p=l.value;s.includes(p)||a.push(p)}if(r.size){if(Array.isArray(t)&&u.length){var d="Attempted to initialize "+this.name+" with an array, but named members were expected\n\nThis is likely due to a malformed response.\nTry inspecting the network response or fetch() return value.\nOr use debugging tools: https://resthooks.io/docs/guides/debugging\nLearn more about schemas: https://resthooks.io/docs/api/schema\nIf this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\nMissing: "+a+"\nFirst three members: "+JSON.stringify(t.slice(0,3),null,2);if("warn"!==this.automaticValidation){var y=new Error(d);throw y.status=400,y}console.warn(d)}var m=Math.max(i.length/2,1)<=u.length&&r.size>Math.max(u.length,2)&&Math.pow(s.length,1.5)/2<=u.length,v=s.length<Math.min(1,r.size/2);if(m||v){var g="",b="substantially different than expected keys";v&&(g+="\n Missing: "+a,b="no matching keys found"),m&&(g+="\n Unexpected keys: "+u,b="a large number of unexpected keys found");var k="Attempted to initialize "+this.name+" with "+b+"\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n If this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\n Expected keys:\n Found: "+s+g+"\n Value: "+JSON.stringify(this.toObjectDefined(e),null,2);if(!(s.length>=4&&m||"warn"===this.automaticValidation)){var w=new Error(k);throw w.status=400,w}console.warn(k)}}}},r.expiresAt=function(e,t){return e.expiresAt},r.infer=function(e,t,n){if(e[0]){var r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;var i=function(e,t){return t?t.find((function(t){return Object.prototype.hasOwnProperty.call(e,t)})):void 0}(e[0],this.indexes);return i&&t[this.key]?t[this.key][i][e[0][i]]:void 0}},r.denormalize=function(e,r){var i=this,o=t(e)?e:this.fromJS(e instanceof j?this.toObjectDefined(e):e);if(null==r.setLocal||r.setLocal(o),t(e)){var s=n(this.schema,e,r),a=s[0],u=s[1],c=s[2];return[this.fromJS(a.toObject()),u,c]}var f=!1;return Object.keys(this.schema).forEach((function(t){var n=i.schema[t],s=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,a=r(s,n),u=a[0];!a[2]||Object.prototype.hasOwnProperty.call(e,t)&&!i.defaults[t]||(f=!0),Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==u&&(o[t]=u)})),[o,!0,f]},s(r,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name||"_temp"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),r}(j);function S(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(E.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return j.fromJS.call(this,e)});var _=Symbol("ENTITY WAS DELETED");function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function A(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function N(e,t,n){return(N=A()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&r(o,n.prototype),o}).apply(null,arguments)}function x(e){var t="function"==typeof Map?new Map:void 0;return(x=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return N(e,arguments,z(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,e)})(e)}var D=function(){this.children=new WeakMap},V=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return i(t,e),t}(x(Error)),J=function(){function e(){this.first=new WeakMap}var t=e.prototype;return t.delete=function(e){var t=this.traverse(e);return null==t||delete t.value,!!t},t.get=function(e){var t=this.traverse(e);return null==t?void 0:t.value},t.has=function(e){var t=this.traverse(e);return!!t&&Object.prototype.hasOwnProperty.call(t,"value")},t.set=function(e,t){if(e.length<1)throw new V;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new D,r.set(e[i],n)),r=n.children,i===e.length-1&&(n.value=t);return this},t.traverse=function(e){for(var t,n=this.first,r=0;r<e.length;r++){if(!(t=n.get(e[r])))return;n=t.children}return t},e}(),P=function(e,t,n,r){var i=M(e);function o(e,n){if(!n)return[e,!0,!1];if(!n.denormalize||"function"!=typeof n.denormalize){if("function"==typeof n)return e instanceof n?[e,!0,!1]:[new n(e),!0,!1];if("object"==typeof n)return(Array.isArray(n)?h:m)(n,e,a)}return null===e?[e,!0,!1]:S(n)?void 0===e?[e,!1,!1]:function(e,t,n,r,i,o){var s=r(e,t);if(s===_)return[void 0,!0,!0];if("object"!=typeof s||null===s)return[s,!1,!1];void 0===i[t.key]&&(i[t.key]={});var a=!0,u=!1;if(!i[t.key][e]){var c=[s],f=T(n,c);f.setLocal=function(n){return i[t.key][e]=n},o[t.key]||(o[t.key]={}),o[t.key][e]||(o[t.key][e]=new J);var l=o[t.key][e],h=t.denormalize(s,f);i[t.key][e]=h[0],a=h[1],u=h[2],l.has(c)?i[t.key][e]=l.get(c):l.set(c,i[t.key][e])}return[i[t.key][e],a,u]}(e,n,a,i,r,t):"function"==typeof n.denormalize?n.denormalize(e,a):[e,!0,!1]}var s=[],a=T(o,s);return function(e,t){s.push(e);var r=o(e,t);return Object(e)!==e?r:n.has(s)?[n.get(s),r[1],r[2]]:(n.set(s,r[0]),r)}},M=function(e){var n=t(e);return function(t,r){var i=r.key;return"object"==typeof t?t:n?e.getIn([i,t]):e[i]&&e[i][t]}};function T(e,t){var n=e.og||e,r=function(e,r){var i=n(e,r);if(i[0]&&r&&S(r))if(Object(i[0])===i[0])t.push(i[0]);else if("production"!==process.env.NODE_ENV)throw new Error("Unexpected primitive found during denormalization\nFound: "+i[0]+"\nExpected entity: "+r);return i};return r.og=e,r}var I=function e(t,n,r,i,o,s){return t&&i?i.normalize&&"function"==typeof i.normalize?"object"!=typeof t?t:i.normalize(t,n,r,e,o,s):"function"==typeof i?new i(t):"object"!=typeof t||"object"!=typeof i?t:(Array.isArray(i)?l:y)(i,t,n,r,e,o,s):t};var L=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},n.infer=function(e,t,n){var r=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[r];if(void 0!==i)return{id:n(i,e,t),schema:r}},t}(a),R=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return Object.keys(e).reduce((function(t,n,a){var u,c=e[n];return null!=c?Object.assign({},t,((u={})[n]=s.normalizeValue(c,e,n,r,i,o),u)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,s){var a,u=e[s],c=n.denormalizeValue(u,t),f=c[0],l=c[1],h=c[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[s]=f,a))}),{}),r,i]},n.infer=function(e,t,n){},t}(a),U=function(){function e(e){if("production"!==process.env.NODE_ENV&&!e)throw new Error('Expected option "entity" not found on DeleteSchema.');this._entity=e}var t=e.prototype;return t.normalize=function(e,t,n,r,i,o){if("string"==typeof e)return e;var s=this._entity.fromJS(e,t,n).pk(t,n);if("production"!==process.env.NODE_ENV&&(void 0===s||""===s)){var a,u=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Delete(Entity): Delete("+(null!=(a=this._entity.name)?a:this._entity)+")\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw u.status=400,u}return i(this,_,s),s},t.infer=function(e,t,n){},t.denormalize=function(e,t){return t(e,this._entity)},t._denormalizeNullable=function(){return[]},t._normalizeNullable=function(){return[]},t.merge=function(e,t){return t},s(e,[{key:"key",get:function(){return this._entity.key}}]),e}(),F=Object.freeze({__proto__:null,Union:L,Values:R,Array:d,Object:g,Delete:U}),B=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(E);return e.DELETED=_,e.Entity=E,e.FlatEntity=B,e.SimpleRecord=j,e.WeakListMap=J,e.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new J),void 0===t)return[e,!0,!1,{}];if(void 0===e)return[void 0,!1,!1,{}];var o={},s=P(n,r,i,o);return[].concat(s(e,t),[o])},e.inferResults=function e(t,n,r){return function(e){return!!e&&"function"==typeof e.infer}(t)?t.infer(n,r,e):"object"==typeof t&&t?(Array.isArray(t)?p:v)(t,n,r,e):t},e.isEntity=S,e.normalize=function(e,t,n,r,i,o){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i={}),void 0===o&&(o={date:Date.now(),expiresAt:1/0}),void 0===t)return{entities:n,indexes:r,result:e,entityMeta:i};var s=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==s){if("production"!==process.env.NODE_ENV){throw"string"==typeof e&&function(e){try{return"string"!=typeof JSON.parse(e)}catch(e){return!1}}(e)?new Error('Normalizing a string, but this does match schema.\n\nParsing this input string as JSON worked. This likely indicates fetch function did not parse\nthe JSON. By default, this only happens if "content-type" header includes "json".\nSee https://resthooks.io/docs/guides/custom-networking for more information\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".')}var a=Object.assign({},n),u=Object.assign({},r),c=Object.assign({},i),f=function(e,t,n,r,i,o){return function(s,a,u){var c=s.key;c in e||(e[c]={},n[c]=Object.assign({},n[c]),i[c]=Object.assign({},i[c]));var f=e[c][u];if(f)e[c][u]=s.merge(f,a);else{var l=s.expiresAt?s.expiresAt(o,a):o.expiresAt,h=n[c][u];if(h){var p,d,y=(null==(p=i[c][u])?void 0:p.date)>o.date;e[c][u]=typeof a!=typeof h?y?h:a:y?s.merge(a,h):s.merge(h,a),i[c][u]=(null==(d=i[c][u])?void 0:d.expiresAt)>=l?i[c][u]:{expiresAt:l,date:o.date}}else e[c][u]=a,i[c][u]={expiresAt:l,date:o.date}}if(Array.isArray(s.indexes)){var m=e[c][u];c in t||(t[c]={},r[c]=Object.assign({},r[c]));for(var v,g=O(s.indexes);!(v=g()).done;){var b=v.value;b in t[c]||(r[c][b]=t[c][b]={});var k=t[c][b];f&&delete k[f[b]],n[c]&&n[c][u]&&n[c][u][b]!==m[b]&&(k[n[c][u][b]]=_),b in m?k[m[b]]=u:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+b+"\nEntity: "+JSON.stringify(m,void 0,2))}}n[c][u]=e[c][u]}}({},{},a,u,c,o);return{entities:a,indexes:u,result:I(e,e,void 0,t,f,{}),entityMeta:c}},e.schema=F,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
var rest_hooks_normalizr=function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function n(e,t,n){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var s=""+o,a=n(t.get(s),e[s]),u=a[0],c=a[1],f=a[2];return c||(r=!1),f&&(i=!0),t.has(s)?t.set(s,u):t}),t),r,i]}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r(e,t)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}var a=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var s=this.inferSchema(e,t,n);if(!s){if("production"!==process.env.NODE_ENV){var a=this.getSchemaAttribute(e,t,n);console.warn("Schema attribute "+JSON.stringify(a,void 0,2)+" is not expected.\nExpected one of: "+Object.keys(this.schema).map((function(e){return'"'+e+'"'})).join(", ")+"\n\nValue: "+JSON.stringify(e,void 0,2))}return e}var u=r(e,t,n,s,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,n){if(void 0===e)return[e,!1,!1];var r=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0,!1]},s(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),u=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},f=function(e){var t=e[0],n=e[2];return void 0!==t&&!n},l=function(e,t,n,r,i,o,s){return e=u(e),c(t).map((function(t,a){return i(t,n,r,e,o,s)}))},h=function(e,t,n){e=u(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(f).map((function(e){return e[0]})):t,i,r]};function p(e,t,n,r){}var d=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return c(e).map((function(e,a){return s.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(f).map((function(e){return e[0]})):e,i,r]},n.infer=function(e,t,n){this.schema},t}(a),y=function(e,t,n,r,i,o,s){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],u=i(t[n],t,n,r,o,s);null==u?delete a[n]:a[n]=u})),a},m=function(e,r,i){if(t(r))return n(e,r,i);var o=Object.assign({},r),s=!0,a=!1;return Object.keys(e).forEach((function(t){var n=i(o[t],e[t]),r=n[0],u=n[1],c=n[2];void 0!==o[t]&&(o[t]=r),c&&(a=!0),u||(s=!1)})),[o,s,a]};function v(e,t,n,r){for(var i={},o=0,s=Object.keys(e);o<s.length;o++){var a=s[o];i[a]=r(e[a],t,n)}return i}var g=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.apply(void 0,[this.schema].concat(t))},t.infer=function(e,t,n){return v(this.schema,e,t,n)},e}();function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function O(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var k=Symbol("Defined Members"),w=Symbol("unq"),j=function(){function e(){}return e.prototype.toString=function(){return this[w]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,k,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,w,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[k].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=O(e[k]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[k]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},e.infer=function(e,t,n){return v(this.schema,e,t,n)},e.denormalize=function(e,t){var n=this,r=Object.assign({},e),i=!1,o=!0;return Object.keys(this.schema).forEach((function(e){var s=t(r[e],n.schema[e]),a=s[0],u=s[1],c=s[2];void 0!==r[e]&&(r[e]=a),u||e in n.defaults&&!n.defaults[e]||(o=!1),!c||e in n.defaults&&!n.defaults[e]||(i=!0)})),[this.fromJS(r),o,i]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},s(e,null,[{key:"defaults",get:function(){return Object.prototype.hasOwnProperty.call(this,"__defaults")||(this.__defaults=new this),this.__defaults}}]),e}();j.schema={};var S=function(e){function r(){return e.apply(this,arguments)||this}return i(r,e),r.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},r.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},r.normalize=function(e,t,n,r,i,o){var s=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);this.validate(a,e);var u=a.pk(t,n);if(void 0!==u&&""!==u){var c=this.key;return c in o||(o[c]={}),u in o[c]||(o[c][u]=[]),o[c][u].some((function(t){return t===e}))?u:(o[c][u].push(e),Object.keys(this.schema).forEach((function(e){if(Object.prototype.hasOwnProperty.call(a,e)){var t=s.schema[e];a[e]=r(a[e],a,e,t,i,o)}else if("production"!==process.env.NODE_ENV){var n=new Error("Schema key is missing in Entity\n\n Be sure all schema members are also part of the entity\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about nesting schemas: https://resthooks.io/docs/guides/nested-response\n\n Entity keys: "+Object.keys(a)+"\n Schema key(missing): "+e+"\n ");throw n.status=400,n}})),i(this,a,u),u)}if("production"!==process.env.NODE_ENV){var f=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Entity: "+this.name+"\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw f.status=400,f}},r.validate=function(e,t){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation){for(var n,r=new Set(Object.keys(this.defaults)),i=this.keysDefined(e),o=[[],[],[]],s=o[0],a=o[1],u=o[2],c=O(i);!(n=c()).done;){var f=n.value;r.has(f)?s.push(f):u.push(f)}for(var l,h=O(r);!(l=h()).done;){var p=l.value;s.includes(p)||a.push(p)}if(r.size){if(Array.isArray(t)&&u.length){var d="Attempted to initialize "+this.name+" with an array, but named members were expected\n\nThis is likely due to a malformed response.\nTry inspecting the network response or fetch() return value.\nOr use debugging tools: https://resthooks.io/docs/guides/debugging\nLearn more about schemas: https://resthooks.io/docs/api/schema\nIf this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\nMissing: "+a+"\nFirst three members: "+JSON.stringify(t.slice(0,3),null,2);if("warn"!==this.automaticValidation){var y=new Error(d);throw y.status=400,y}console.warn(d)}var m=Math.max(i.length/2,1)<=u.length&&r.size>Math.max(u.length,2)&&Math.pow(s.length,1.5)/2<=u.length,v=s.length<Math.min(1,r.size/2);if(m||v){var g="",b="substantially different than expected keys";v&&(g+="\n Missing: "+a,b="no matching keys found"),m&&(g+="\n Unexpected keys: "+u,b="a large number of unexpected keys found");var k="Attempted to initialize "+this.name+" with "+b+"\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n If this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\n Expected keys:\n Found: "+s+g+"\n Value: "+JSON.stringify(this.toObjectDefined(e),null,2);if(!(s.length>=4&&m||"warn"===this.automaticValidation)){var w=new Error(k);throw w.status=400,w}console.warn(k)}}}},r.expiresAt=function(e,t){return e.expiresAt},r.infer=function(e,t,n){if(e[0]){var r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;var i=function(e,t){return t?t.find((function(t){return Object.prototype.hasOwnProperty.call(e,t)})):void 0}(e[0],this.indexes);return i&&t[this.key]?t[this.key][i][e[0][i]]:void 0}},r.denormalize=function(e,r){var i=this,o=t(e)?e:this.fromJS(e instanceof j?this.toObjectDefined(e):e);if(null==r.setLocal||r.setLocal(o),t(e)){var s=n(this.schema,e,r),a=s[0],u=s[1],c=s[2];return[this.fromJS(a.toObject()),u,c]}var f=!1;return Object.keys(this.schema).forEach((function(t){var n=i.schema[t],s=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,a=r(s,n),u=a[0];!a[2]||Object.prototype.hasOwnProperty.call(e,t)&&!i.defaults[t]||(f=!0),Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==u&&(o[t]=u)})),[o,!0,f]},s(r,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name||"_temp"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),r}(j);function E(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(S.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return j.fromJS.call(this,e)});var _=Symbol("ENTITY WAS DELETED");function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function A(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function N(e,t,n){return(N=A()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&r(o,n.prototype),o}).apply(null,arguments)}function x(e){var t="function"==typeof Map?new Map:void 0;return(x=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return N(e,arguments,z(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,e)})(e)}var D=function(){this.children=new WeakMap},V=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return i(t,e),t}(x(Error)),J=function(){function e(){this.first=new WeakMap}var t=e.prototype;return t.delete=function(e){var t=this.traverse(e);return null==t||delete t.value,!!t},t.get=function(e){var t=this.traverse(e);return null==t?void 0:t.value},t.has=function(e){var t=this.traverse(e);return!!t&&Object.prototype.hasOwnProperty.call(t,"value")},t.set=function(e,t){if(e.length<1)throw new V;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new D,r.set(e[i],n)),r=n.children,i===e.length-1&&(n.value=t);return this},t.traverse=function(e){for(var t,n=this.first,r=0;r<e.length;r++){if(!(t=n.get(e[r])))return;n=t.children}return t},e}(),P=Symbol("draft"),M=function(e,t,n,r,i,o,s,a){var u=r(e,t);if(u===_)return[void 0,!0,!0];if("object"!=typeof u||null===u)return[u,!1,!1];void 0===i[t.key]&&(i[t.key]={});var c=!0,f=!1;if(i[t.key][e]){if(Object.prototype.hasOwnProperty.call(i[t.key][e],P))return a.i=i[t.key][e].i,[i[t.key][e][P],c,f];s.push(u)}else{var l=s.length;s.push(u);var h=function(e){var t=e.og||e,n=function(e,n){return t(e,n)};return n.og=e,n}(n);h.setLocal=function(n){var r;return i[t.key][e]=((r={})[P]=n,r.i=l,r)};var p=function(e,t,n){e[t.key]||(e[t.key]={});e[t.key][n]||(e[t.key][n]=new J);return e[t.key][n]}(o,t,e),d=t.denormalize(u,h);i[t.key][e]=d[0],c=d[1],f=d[2];var y=s.slice(-1===a.i?l:a.i);p.has(y)?i[t.key][e]=p.get(y):p.set(y,i[t.key][e]),a.i===l&&(a.i=-1)}return[i[t.key][e],c,f]},T=function(e){var n=t(e);return function(t,r){var i=r.key;return"object"==typeof t?t:n?e.getIn([i,t]):e[i]&&e[i][t]}};var I=function e(t,n,r,i,o,s){return t&&i?i.normalize&&"function"==typeof i.normalize?"object"!=typeof t?t:i.normalize(t,n,r,e,o,s):"function"==typeof i?new i(t):"object"!=typeof t||"object"!=typeof i?t:(Array.isArray(i)?l:y)(i,t,n,r,e,o,s):t};var L=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},n.infer=function(e,t,n){var r=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[r];if(void 0!==i)return{id:n(i,e,t),schema:r}},t}(a),R=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return Object.keys(e).reduce((function(t,n,a){var u,c=e[n];return null!=c?Object.assign({},t,((u={})[n]=s.normalizeValue(c,e,n,r,i,o),u)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,s){var a,u=e[s],c=n.denormalizeValue(u,t),f=c[0],l=c[1],h=c[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[s]=f,a))}),{}),r,i]},n.infer=function(e,t,n){},t}(a),U=function(){function e(e){if("production"!==process.env.NODE_ENV&&!e)throw new Error('Expected option "entity" not found on DeleteSchema.');this._entity=e}var t=e.prototype;return t.normalize=function(e,t,n,r,i,o){if("string"==typeof e)return e;var s=this._entity.fromJS(e,t,n).pk(t,n);if("production"!==process.env.NODE_ENV&&(void 0===s||""===s)){var a,u=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Delete(Entity): Delete("+(null!=(a=this._entity.name)?a:this._entity)+")\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw u.status=400,u}return i(this,_,s),s},t.infer=function(e,t,n){},t.denormalize=function(e,t){return t(e,this._entity)},t._denormalizeNullable=function(){return[]},t._normalizeNullable=function(){return[]},t.merge=function(e,t){return t},s(e,[{key:"key",get:function(){return this._entity.key}}]),e}(),F=Object.freeze({__proto__:null,Union:L,Values:R,Array:d,Object:g,Delete:U}),B=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(S);return e.DELETED=_,e.Entity=S,e.FlatEntity=B,e.SimpleRecord=j,e.WeakListMap=J,e.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new J),void 0===t)return[e,!0,!1,{}];if(void 0===e)return[void 0,!1,!1,{}];var o={},s=function(e,t,n,r){var i=T(e),o=[],s={i:-1};function a(e,n){if(!n)return[e,!0,!1];if(!n.denormalize||"function"!=typeof n.denormalize){if("function"==typeof n)return e instanceof n?[e,!0,!1]:[new n(e),!0,!1];if("object"==typeof n)return(Array.isArray(n)?h:m)(n,e,a)}return null===e?[e,!0,!1]:E(n)?void 0===e?[e,!1,!1]:M(e,n,a,i,r,t,o,s):"function"==typeof n.denormalize?n.denormalize(e,a):[e,!0,!1]}return function(e,t){var r=a(e,t);return Object(e)!==e?r:(o.push(e),n.has(o)?[n.get(o),r[1],r[2]]:(n.set(o,r[0]),r))}}(n,r,i,o);return[].concat(s(e,t),[o])},e.inferResults=function e(t,n,r){return function(e){return!!e&&"function"==typeof e.infer}(t)?t.infer(n,r,e):"object"==typeof t&&t?(Array.isArray(t)?p:v)(t,n,r,e):t},e.isEntity=E,e.normalize=function(e,t,n,r,i,o){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i={}),void 0===o&&(o={date:Date.now(),expiresAt:1/0}),void 0===t)return{entities:n,indexes:r,result:e,entityMeta:i};var s=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==s){if("production"!==process.env.NODE_ENV){throw"string"==typeof e&&function(e){try{return"string"!=typeof JSON.parse(e)}catch(e){return!1}}(e)?new Error('Normalizing a string, but this does match schema.\n\nParsing this input string as JSON worked. This likely indicates fetch function did not parse\nthe JSON. By default, this only happens if "content-type" header includes "json".\nSee https://resthooks.io/docs/guides/custom-networking for more information\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".')}var a=Object.assign({},n),u=Object.assign({},r),c=Object.assign({},i),f=function(e,t,n,r,i,o){return function(s,a,u){var c=s.key;c in e||(e[c]={},n[c]=Object.assign({},n[c]),i[c]=Object.assign({},i[c]));var f=e[c][u];if(f)e[c][u]=s.merge(f,a);else{var l=s.expiresAt?s.expiresAt(o,a):o.expiresAt,h=n[c][u];if(h){var p,d,y=(null==(p=i[c][u])?void 0:p.date)>o.date;e[c][u]=typeof a!=typeof h?y?h:a:y?s.merge(a,h):s.merge(h,a),i[c][u]=(null==(d=i[c][u])?void 0:d.expiresAt)>=l?i[c][u]:{expiresAt:l,date:o.date}}else e[c][u]=a,i[c][u]={expiresAt:l,date:o.date}}if(Array.isArray(s.indexes)){var m=e[c][u];c in t||(t[c]={},r[c]=Object.assign({},r[c]));for(var v,g=O(s.indexes);!(v=g()).done;){var b=v.value;b in t[c]||(r[c][b]=t[c][b]={});var k=t[c][b];f&&delete k[f[b]],n[c]&&n[c][u]&&n[c][u][b]!==m[b]&&(k[n[c][u][b]]=_),b in m?k[m[b]]=u:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+b+"\nEntity: "+JSON.stringify(m,void 0,2))}}n[c][u]=e[c][u]}}({},{},a,u,c,o);return{entities:a,indexes:u,result:I(e,e,void 0,t,f,{}),entityMeta:c}},e.schema=F,Object.defineProperty(e,"__esModule",{value:!0}),e}({});

@@ -18,4 +18,3 @@ 'use strict';

function isImmutable(object) {
return !!(object && typeof object.hasOwnProperty === 'function' && (Object.hasOwnProperty.call(object, '__ownerID') || // Immutable.Map
object._map && Object.hasOwnProperty.call(object._map, '__ownerID'))); // Immutable.Record
return !!(object && typeof object.hasOwnProperty === 'function' && (Object.hasOwnProperty.call(object, '__ownerID') || object._map && Object.hasOwnProperty.call(object._map, '__ownerID'))); // Immutable.Record
}

@@ -991,3 +990,5 @@ /**

var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache) {
var DRAFT = Symbol('draft');
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache, dependencies, cycleIndex) {
var entity = getEntity(id, schema);

@@ -1011,12 +1012,13 @@

if (!localCache[schema.key][id]) {
var globalKey = [entity];
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
var trackingIndex = dependencies.length;
dependencies.push(entity);
var wrappedUnvisit = withTrackedEntities(unvisit); // { [DRAFT] } means we are still processing - which if found indicates a cycle
wrappedUnvisit.setLocal = function (entityCopy) {
return localCache[schema.key][id] = entityCopy;
var _localCache$schema$ke;
return localCache[schema.key][id] = (_localCache$schema$ke = {}, _localCache$schema$ke[DRAFT] = entityCopy, _localCache$schema$ke.i = trackingIndex, _localCache$schema$ke);
};
if (!entityCache[schema.key]) entityCache[schema.key] = {};
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap();
var globalCacheEntry = entityCache[schema.key][id];
var globalCacheEntry = getGlobalCacheEntry(entityCache, schema, id);

@@ -1028,11 +1030,25 @@ var _schema$denormalize = schema.denormalize(entity, wrappedUnvisit);

deleted = _schema$denormalize[2];
// if in cycle, use the start of the cycle to track all deps
// otherwise, we use our own trackingIndex
var localKey = dependencies.slice(cycleIndex.i === -1 ? trackingIndex : cycleIndex.i);
if (!globalCacheEntry.has(globalKey)) {
globalCacheEntry.set(globalKey, localCache[schema.key][id]);
if (!globalCacheEntry.has(localKey)) {
globalCacheEntry.set(localKey, localCache[schema.key][id]);
} else {
// localCache is only used before this point for recursive relationships
// since recursive relationships must all referentially change if *any* do, we either
// get the correct one here, or will never find the same version in the cache
localCache[schema.key][id] = globalCacheEntry.get(globalKey);
localCache[schema.key][id] = globalCacheEntry.get(localKey);
} // start of cycle - reset cycle detection
if (cycleIndex.i === trackingIndex) {
cycleIndex.i = -1;
}
} else {
// cycle detected
if (Object.prototype.hasOwnProperty.call(localCache[schema.key][id], DRAFT)) {
cycleIndex.i = localCache[schema.key][id].i;
return [localCache[schema.key][id][DRAFT], found, deleted];
} else {
// with no cycle, globalCacheEntry will have already been set
dependencies.push(entity);
}
}

@@ -1045,2 +1061,6 @@

var getEntity = getEntities(entities);
var dependencies = [];
var cycleIndex = {
i: -1
};

@@ -1056,3 +1076,3 @@ function unvisit(input, schema) {

var method = Array.isArray(schema) ? denormalize$1 : _denormalize;
return method(schema, input, wrappedUnvisit);
return method(schema, input, unvisit);
}

@@ -1072,16 +1092,14 @@ } // null is considered intentional, thus always 'found' as true

return unvisitEntity(input, schema, wrappedUnvisit, getEntity, localCache, entityCache);
return unvisitEntity(input, schema, unvisit, getEntity, localCache, entityCache, dependencies, cycleIndex);
}
if (typeof schema.denormalize === 'function') {
return schema.denormalize(input, wrappedUnvisit);
return schema.denormalize(input, unvisit);
}
return [input, true, false];
}
} //const wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
var globalKey = [];
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
return function (input, schema) {
globalKey.push(input);
var ret = unvisit(input, schema); // in the case where WeakMap cannot be used

@@ -1091,8 +1109,9 @@ // this test ensures null is properly excluded from WeakMap

if (Object(input) !== input) return ret;
dependencies.push(input);
if (!resultCache.has(globalKey)) {
resultCache.set(globalKey, ret[0]);
if (!resultCache.has(dependencies)) {
resultCache.set(dependencies, ret[0]);
return ret;
} else {
return [resultCache.get(globalKey), ret[1], ret[2]];
return [resultCache.get(dependencies), ret[1], ret[2]];
}

@@ -1143,3 +1162,9 @@ };

function withTrackedEntities(unvisit, globalKey) {
function getGlobalCacheEntry(entityCache, schema, id) {
if (!entityCache[schema.key]) entityCache[schema.key] = {};
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap();
return entityCache[schema.key][id];
}
function withTrackedEntities(unvisit) {
// every time we nest, we want to unwrap back to the top.

@@ -1150,14 +1175,3 @@ // this is due to only needed the next level of nested entities for lookup

var wrappedUnvisit = function wrappedUnvisit(input, schema) {
var ret = originalUnvisit(input, schema); // pass over undefined in key
if (ret[0] && schema && isEntity(schema)) {
/* istanbul ignore else */
if (Object(ret[0]) === ret[0]) {
globalKey.push(ret[0]);
} else if (process.env.NODE_ENV !== 'production') {
throw new Error("Unexpected primitive found during denormalization\nFound: " + ret[0] + "\nExpected entity: " + schema);
}
}
return ret;
return originalUnvisit(input, schema);
};

@@ -1269,5 +1283,5 @@

else if ( // eslint-disable-next-line no-undef
process.env.NODE_ENV !== 'production') {
console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: " + index + "\nEntity: " + JSON.stringify(entity, undefined, 2));
}
process.env.NODE_ENV !== 'production') {
console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: " + index + "\nEntity: " + JSON.stringify(entity, undefined, 2));
}
}

@@ -1274,0 +1288,0 @@ } // set this after index updates so we know what indexes to remove from

@@ -1,1 +0,1 @@

"use strict";function e(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function t(e,t,n){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var s=""+o,a=n(t.get(s),e[s]),u=a[0],c=a[1],f=a[2];return c||(r=!1),f&&(i=!0),t.has(s)?t.set(s,u):t}),t),r,i]}function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,n(e,t)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}Object.defineProperty(exports,"__esModule",{value:!0});var s=function(){function t(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=t.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var s=this.inferSchema(e,t,n);if(!s){if("production"!==process.env.NODE_ENV){var a=this.getSchemaAttribute(e,t,n);console.warn("Schema attribute "+JSON.stringify(a,void 0,2)+" is not expected.\nExpected one of: "+Object.keys(this.schema).map((function(e){return'"'+e+'"'})).join(", ")+"\n\nValue: "+JSON.stringify(e,void 0,2))}return e}var u=r(e,t,n,s,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(t,n){if(void 0===t)return[t,!1,!1];var r=e(t)?t.get("schema"):t.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:e(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[r]):[t,!0,!1]},o(t,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),t}(),a=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},u=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},c=function(e){var t=e[0],n=e[2];return void 0!==t&&!n},f=function(e,t,n,r,i,o,s){return e=a(e),u(t).map((function(t,a){return i(t,n,r,e,o,s)}))},l=function(e,t,n){e=a(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(c).map((function(e){return e[0]})):t,i,r]};function h(e,t,n,r){}var p=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return u(e).map((function(e,a){return s.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(c).map((function(e){return e[0]})):e,i,r]},n.infer=function(e,t,n){this.schema},t}(s),d=function(e,t,n,r,i,o,s){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],u=i(t[n],t,n,r,o,s);null==u?delete a[n]:a[n]=u})),a},y=function(n,r,i){if(e(r))return t(n,r,i);var o=Object.assign({},r),s=!0,a=!1;return Object.keys(n).forEach((function(e){var t=i(o[e],n[e]),r=t[0],u=t[1],c=t[2];void 0!==o[e]&&(o[e]=r),c&&(a=!0),u||(s=!1)})),[o,s,a]};function m(e,t,n,r){for(var i={},o=0,s=Object.keys(e);o<s.length;o++){var a=s[o];i[a]=r(e[a],t,n)}return i}var v=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},t.infer=function(e,t,n){return m(this.schema,e,t,n)},e}();function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var O=Symbol("Defined Members"),k=Symbol("unq"),w=function(){function e(){}return e.prototype.toString=function(){return this[k]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,O,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,k,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[O].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=b(e[O]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[O]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.apply(void 0,[this.schema].concat(t))},e.infer=function(e,t,n){return m(this.schema,e,t,n)},e.denormalize=function(e,t){var n=this,r=Object.assign({},e),i=!1,o=!0;return Object.keys(this.schema).forEach((function(e){var s=t(r[e],n.schema[e]),a=s[0],u=s[1],c=s[2];void 0!==r[e]&&(r[e]=a),u||e in n.defaults&&!n.defaults[e]||(o=!1),!c||e in n.defaults&&!n.defaults[e]||(i=!0)})),[this.fromJS(r),o,i]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},o(e,null,[{key:"defaults",get:function(){return Object.prototype.hasOwnProperty.call(this,"__defaults")||(this.__defaults=new this),this.__defaults}}]),e}();w.schema={};var j=function(n){function i(){return n.apply(this,arguments)||this}return r(i,n),i.toJSON=function(){return Object.assign({},n.toJSON.call(this),{key:this.key})},i.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},i.normalize=function(e,t,n,r,i,o){var s=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);this.validate(a,e);var u=a.pk(t,n);if(void 0!==u&&""!==u){var c=this.key;return c in o||(o[c]={}),u in o[c]||(o[c][u]=[]),o[c][u].some((function(t){return t===e}))?u:(o[c][u].push(e),Object.keys(this.schema).forEach((function(e){if(Object.prototype.hasOwnProperty.call(a,e)){var t=s.schema[e];a[e]=r(a[e],a,e,t,i,o)}else if("production"!==process.env.NODE_ENV){var n=new Error("Schema key is missing in Entity\n\n Be sure all schema members are also part of the entity\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about nesting schemas: https://resthooks.io/docs/guides/nested-response\n\n Entity keys: "+Object.keys(a)+"\n Schema key(missing): "+e+"\n ");throw n.status=400,n}})),i(this,a,u),u)}if("production"!==process.env.NODE_ENV){var f=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Entity: "+this.name+"\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw f.status=400,f}},i.validate=function(e,t){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation){for(var n,r=new Set(Object.keys(this.defaults)),i=this.keysDefined(e),o=[[],[],[]],s=o[0],a=o[1],u=o[2],c=b(i);!(n=c()).done;){var f=n.value;r.has(f)?s.push(f):u.push(f)}for(var l,h=b(r);!(l=h()).done;){var p=l.value;s.includes(p)||a.push(p)}if(r.size){if(Array.isArray(t)&&u.length){var d="Attempted to initialize "+this.name+" with an array, but named members were expected\n\nThis is likely due to a malformed response.\nTry inspecting the network response or fetch() return value.\nOr use debugging tools: https://resthooks.io/docs/guides/debugging\nLearn more about schemas: https://resthooks.io/docs/api/schema\nIf this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\nMissing: "+a+"\nFirst three members: "+JSON.stringify(t.slice(0,3),null,2);if("warn"!==this.automaticValidation){var y=new Error(d);throw y.status=400,y}console.warn(d)}var m=Math.max(i.length/2,1)<=u.length&&r.size>Math.max(u.length,2)&&Math.pow(s.length,1.5)/2<=u.length,v=s.length<Math.min(1,r.size/2);if(m||v){var g="",O="substantially different than expected keys";v&&(g+="\n Missing: "+a,O="no matching keys found"),m&&(g+="\n Unexpected keys: "+u,O="a large number of unexpected keys found");var k="Attempted to initialize "+this.name+" with "+O+"\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n If this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\n Expected keys:\n Found: "+s+g+"\n Value: "+JSON.stringify(this.toObjectDefined(e),null,2);if(!(s.length>=4&&m||"warn"===this.automaticValidation)){var w=new Error(k);throw w.status=400,w}console.warn(k)}}}},i.expiresAt=function(e,t){return e.expiresAt},i.infer=function(e,t,n){if(e[0]){var r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;var i=function(e,t){return t?t.find((function(t){return Object.prototype.hasOwnProperty.call(e,t)})):void 0}(e[0],this.indexes);return i&&t[this.key]?t[this.key][i][e[0][i]]:void 0}},i.denormalize=function(n,r){var i=this,o=e(n)?n:this.fromJS(n instanceof w?this.toObjectDefined(n):n);if(null==r.setLocal||r.setLocal(o),e(n)){var s=t(this.schema,n,r),a=s[0],u=s[1],c=s[2];return[this.fromJS(a.toObject()),u,c]}var f=!1;return Object.keys(this.schema).forEach((function(e){var t=i.schema[e],s=Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0,a=r(s,t),u=a[0];!a[2]||Object.prototype.hasOwnProperty.call(n,e)&&!i.defaults[e]||(f=!0),Object.prototype.hasOwnProperty.call(n,e)&&n[e]!==u&&(o[e]=u)})),[o,!0,f]},o(i,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name||"_temp"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),i}(w);function E(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(j.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return w.fromJS.call(this,e)});var S=Symbol("ENTITY WAS DELETED");function x(e){return(x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function z(e,t,r){return(z=_()?Reflect.construct:function(e,t,r){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return r&&n(o,r.prototype),o}).apply(null,arguments)}function A(e){var t="function"==typeof Map?new Map:void 0;return(A=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return z(e,arguments,x(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),n(i,e)})(e)}var N=function(){this.children=new WeakMap},D=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return r(t,e),t}(A(Error)),V=function(){function e(){this.first=new WeakMap}var t=e.prototype;return t.delete=function(e){var t=this.traverse(e);return null==t||delete t.value,!!t},t.get=function(e){var t=this.traverse(e);return null==t?void 0:t.value},t.has=function(e){var t=this.traverse(e);return!!t&&Object.prototype.hasOwnProperty.call(t,"value")},t.set=function(e,t){if(e.length<1)throw new D;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new N,r.set(e[i],n)),r=n.children,i===e.length-1&&(n.value=t);return this},t.traverse=function(e){for(var t,n=this.first,r=0;r<e.length;r++){if(!(t=n.get(e[r])))return;n=t.children}return t},e}(),J=function(e,t,n,r){var i=P(e);function o(e,n){if(!n)return[e,!0,!1];if(!n.denormalize||"function"!=typeof n.denormalize){if("function"==typeof n)return e instanceof n?[e,!0,!1]:[new n(e),!0,!1];if("object"==typeof n)return(Array.isArray(n)?l:y)(n,e,a)}return null===e?[e,!0,!1]:E(n)?void 0===e?[e,!1,!1]:function(e,t,n,r,i,o){var s=r(e,t);if(s===S)return[void 0,!0,!0];if("object"!=typeof s||null===s)return[s,!1,!1];void 0===i[t.key]&&(i[t.key]={});var a=!0,u=!1;if(!i[t.key][e]){var c=[s],f=M(n,c);f.setLocal=function(n){return i[t.key][e]=n},o[t.key]||(o[t.key]={}),o[t.key][e]||(o[t.key][e]=new V);var l=o[t.key][e],h=t.denormalize(s,f);i[t.key][e]=h[0],a=h[1],u=h[2],l.has(c)?i[t.key][e]=l.get(c):l.set(c,i[t.key][e])}return[i[t.key][e],a,u]}(e,n,a,i,r,t):"function"==typeof n.denormalize?n.denormalize(e,a):[e,!0,!1]}var s=[],a=M(o,s);return function(e,t){s.push(e);var r=o(e,t);return Object(e)!==e?r:n.has(s)?[n.get(s),r[1],r[2]]:(n.set(s,r[0]),r)}},P=function(t){var n=e(t);return function(e,r){var i=r.key;return"object"==typeof e?e:n?t.getIn([i,e]):t[i]&&t[i][e]}};function M(e,t){var n=e.og||e,r=function(e,r){var i=n(e,r);if(i[0]&&r&&E(r))if(Object(i[0])===i[0])t.push(i[0]);else if("production"!==process.env.NODE_ENV)throw new Error("Unexpected primitive found during denormalization\nFound: "+i[0]+"\nExpected entity: "+r);return i};return r.og=e,r}var T=function e(t,n,r,i,o,s){return t&&i?i.normalize&&"function"==typeof i.normalize?"object"!=typeof t?t:i.normalize(t,n,r,e,o,s):"function"==typeof i?new i(t):"object"!=typeof t||"object"!=typeof i?t:(Array.isArray(i)?f:d)(i,t,n,r,e,o,s):t};var I=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},n.infer=function(e,t,n){var r=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[r];if(void 0!==i)return{id:n(i,e,t),schema:r}},t}(s),L=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return Object.keys(e).reduce((function(t,n,a){var u,c=e[n];return null!=c?Object.assign({},t,((u={})[n]=s.normalizeValue(c,e,n,r,i,o),u)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,s){var a,u=e[s],c=n.denormalizeValue(u,t),f=c[0],l=c[1],h=c[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[s]=f,a))}),{}),r,i]},n.infer=function(e,t,n){},t}(s),R=function(){function e(e){if("production"!==process.env.NODE_ENV&&!e)throw new Error('Expected option "entity" not found on DeleteSchema.');this._entity=e}var t=e.prototype;return t.normalize=function(e,t,n,r,i,o){if("string"==typeof e)return e;var s=this._entity.fromJS(e,t,n).pk(t,n);if("production"!==process.env.NODE_ENV&&(void 0===s||""===s)){var a,u=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Delete(Entity): Delete("+(null!=(a=this._entity.name)?a:this._entity)+")\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw u.status=400,u}return i(this,S,s),s},t.infer=function(e,t,n){},t.denormalize=function(e,t){return t(e,this._entity)},t._denormalizeNullable=function(){return[]},t._normalizeNullable=function(){return[]},t.merge=function(e,t){return t},o(e,[{key:"key",get:function(){return this._entity.key}}]),e}(),U=Object.freeze({__proto__:null,Union:I,Values:L,Array:p,Object:v,Delete:R}),F=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(j);exports.DELETED=S,exports.Entity=j,exports.FlatEntity=F,exports.SimpleRecord=w,exports.WeakListMap=V,exports.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new V),void 0===t)return[e,!0,!1,{}];if(void 0===e)return[void 0,!1,!1,{}];var o={},s=J(n,r,i,o);return[].concat(s(e,t),[o])},exports.inferResults=function e(t,n,r){return function(e){return!!e&&"function"==typeof e.infer}(t)?t.infer(n,r,e):"object"==typeof t&&t?(Array.isArray(t)?h:m)(t,n,r,e):t},exports.isEntity=E,exports.normalize=function(e,t,n,r,i,o){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i={}),void 0===o&&(o={date:Date.now(),expiresAt:1/0}),void 0===t)return{entities:n,indexes:r,result:e,entityMeta:i};var s=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==s){if("production"!==process.env.NODE_ENV){throw"string"==typeof e&&function(e){try{return"string"!=typeof JSON.parse(e)}catch(e){return!1}}(e)?new Error('Normalizing a string, but this does match schema.\n\nParsing this input string as JSON worked. This likely indicates fetch function did not parse\nthe JSON. By default, this only happens if "content-type" header includes "json".\nSee https://resthooks.io/docs/guides/custom-networking for more information\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".')}var a=Object.assign({},n),u=Object.assign({},r),c=Object.assign({},i),f=function(e,t,n,r,i,o){return function(s,a,u){var c=s.key;c in e||(e[c]={},n[c]=Object.assign({},n[c]),i[c]=Object.assign({},i[c]));var f=e[c][u];if(f)e[c][u]=s.merge(f,a);else{var l=s.expiresAt?s.expiresAt(o,a):o.expiresAt,h=n[c][u];if(h){var p,d,y=(null==(p=i[c][u])?void 0:p.date)>o.date;e[c][u]=typeof a!=typeof h?y?h:a:y?s.merge(a,h):s.merge(h,a),i[c][u]=(null==(d=i[c][u])?void 0:d.expiresAt)>=l?i[c][u]:{expiresAt:l,date:o.date}}else e[c][u]=a,i[c][u]={expiresAt:l,date:o.date}}if(Array.isArray(s.indexes)){var m=e[c][u];c in t||(t[c]={},r[c]=Object.assign({},r[c]));for(var v,g=b(s.indexes);!(v=g()).done;){var O=v.value;O in t[c]||(r[c][O]=t[c][O]={});var k=t[c][O];f&&delete k[f[O]],n[c]&&n[c][u]&&n[c][u][O]!==m[O]&&(k[n[c][u][O]]=S),O in m?k[m[O]]=u:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+O+"\nEntity: "+JSON.stringify(m,void 0,2))}}n[c][u]=e[c][u]}}({},{},a,u,c,o);return{entities:a,indexes:u,result:T(e,e,void 0,t,f,{}),entityMeta:c}},exports.schema=U;
"use strict";function e(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function t(e,t,n){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var s=""+o,a=n(t.get(s),e[s]),u=a[0],c=a[1],f=a[2];return c||(r=!1),f&&(i=!0),t.has(s)?t.set(s,u):t}),t),r,i]}function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,n(e,t)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}Object.defineProperty(exports,"__esModule",{value:!0});var s=function(){function t(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=t.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var s=this.inferSchema(e,t,n);if(!s){if("production"!==process.env.NODE_ENV){var a=this.getSchemaAttribute(e,t,n);console.warn("Schema attribute "+JSON.stringify(a,void 0,2)+" is not expected.\nExpected one of: "+Object.keys(this.schema).map((function(e){return'"'+e+'"'})).join(", ")+"\n\nValue: "+JSON.stringify(e,void 0,2))}return e}var u=r(e,t,n,s,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(t,n){if(void 0===t)return[t,!1,!1];var r=e(t)?t.get("schema"):t.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:e(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[r]):[t,!0,!1]},o(t,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),t}(),a=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},u=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},c=function(e){var t=e[0],n=e[2];return void 0!==t&&!n},f=function(e,t,n,r,i,o,s){return e=a(e),u(t).map((function(t,a){return i(t,n,r,e,o,s)}))},l=function(e,t,n){e=a(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(c).map((function(e){return e[0]})):t,i,r]};function h(e,t,n,r){}var p=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return u(e).map((function(e,a){return s.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(c).map((function(e){return e[0]})):e,i,r]},n.infer=function(e,t,n){this.schema},t}(s),d=function(e,t,n,r,i,o,s){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],u=i(t[n],t,n,r,o,s);null==u?delete a[n]:a[n]=u})),a},y=function(n,r,i){if(e(r))return t(n,r,i);var o=Object.assign({},r),s=!0,a=!1;return Object.keys(n).forEach((function(e){var t=i(o[e],n[e]),r=t[0],u=t[1],c=t[2];void 0!==o[e]&&(o[e]=r),c&&(a=!0),u||(s=!1)})),[o,s,a]};function m(e,t,n,r){for(var i={},o=0,s=Object.keys(e);o<s.length;o++){var a=s[o];i[a]=r(e[a],t,n)}return i}var v=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},t.infer=function(e,t,n){return m(this.schema,e,t,n)},e}();function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var O=Symbol("Defined Members"),k=Symbol("unq"),w=function(){function e(){}return e.prototype.toString=function(){return this[k]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,O,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,k,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[O].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=b(e[O]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[O]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.apply(void 0,[this.schema].concat(t))},e.infer=function(e,t,n){return m(this.schema,e,t,n)},e.denormalize=function(e,t){var n=this,r=Object.assign({},e),i=!1,o=!0;return Object.keys(this.schema).forEach((function(e){var s=t(r[e],n.schema[e]),a=s[0],u=s[1],c=s[2];void 0!==r[e]&&(r[e]=a),u||e in n.defaults&&!n.defaults[e]||(o=!1),!c||e in n.defaults&&!n.defaults[e]||(i=!0)})),[this.fromJS(r),o,i]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},o(e,null,[{key:"defaults",get:function(){return Object.prototype.hasOwnProperty.call(this,"__defaults")||(this.__defaults=new this),this.__defaults}}]),e}();w.schema={};var j=function(n){function i(){return n.apply(this,arguments)||this}return r(i,n),i.toJSON=function(){return Object.assign({},n.toJSON.call(this),{key:this.key})},i.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},i.normalize=function(e,t,n,r,i,o){var s=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);this.validate(a,e);var u=a.pk(t,n);if(void 0!==u&&""!==u){var c=this.key;return c in o||(o[c]={}),u in o[c]||(o[c][u]=[]),o[c][u].some((function(t){return t===e}))?u:(o[c][u].push(e),Object.keys(this.schema).forEach((function(e){if(Object.prototype.hasOwnProperty.call(a,e)){var t=s.schema[e];a[e]=r(a[e],a,e,t,i,o)}else if("production"!==process.env.NODE_ENV){var n=new Error("Schema key is missing in Entity\n\n Be sure all schema members are also part of the entity\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about nesting schemas: https://resthooks.io/docs/guides/nested-response\n\n Entity keys: "+Object.keys(a)+"\n Schema key(missing): "+e+"\n ");throw n.status=400,n}})),i(this,a,u),u)}if("production"!==process.env.NODE_ENV){var f=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Entity: "+this.name+"\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw f.status=400,f}},i.validate=function(e,t){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation){for(var n,r=new Set(Object.keys(this.defaults)),i=this.keysDefined(e),o=[[],[],[]],s=o[0],a=o[1],u=o[2],c=b(i);!(n=c()).done;){var f=n.value;r.has(f)?s.push(f):u.push(f)}for(var l,h=b(r);!(l=h()).done;){var p=l.value;s.includes(p)||a.push(p)}if(r.size){if(Array.isArray(t)&&u.length){var d="Attempted to initialize "+this.name+" with an array, but named members were expected\n\nThis is likely due to a malformed response.\nTry inspecting the network response or fetch() return value.\nOr use debugging tools: https://resthooks.io/docs/guides/debugging\nLearn more about schemas: https://resthooks.io/docs/api/schema\nIf this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\nMissing: "+a+"\nFirst three members: "+JSON.stringify(t.slice(0,3),null,2);if("warn"!==this.automaticValidation){var y=new Error(d);throw y.status=400,y}console.warn(d)}var m=Math.max(i.length/2,1)<=u.length&&r.size>Math.max(u.length,2)&&Math.pow(s.length,1.5)/2<=u.length,v=s.length<Math.min(1,r.size/2);if(m||v){var g="",O="substantially different than expected keys";v&&(g+="\n Missing: "+a,O="no matching keys found"),m&&(g+="\n Unexpected keys: "+u,O="a large number of unexpected keys found");var k="Attempted to initialize "+this.name+" with "+O+"\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n If this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\n Expected keys:\n Found: "+s+g+"\n Value: "+JSON.stringify(this.toObjectDefined(e),null,2);if(!(s.length>=4&&m||"warn"===this.automaticValidation)){var w=new Error(k);throw w.status=400,w}console.warn(k)}}}},i.expiresAt=function(e,t){return e.expiresAt},i.infer=function(e,t,n){if(e[0]){var r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;var i=function(e,t){return t?t.find((function(t){return Object.prototype.hasOwnProperty.call(e,t)})):void 0}(e[0],this.indexes);return i&&t[this.key]?t[this.key][i][e[0][i]]:void 0}},i.denormalize=function(n,r){var i=this,o=e(n)?n:this.fromJS(n instanceof w?this.toObjectDefined(n):n);if(null==r.setLocal||r.setLocal(o),e(n)){var s=t(this.schema,n,r),a=s[0],u=s[1],c=s[2];return[this.fromJS(a.toObject()),u,c]}var f=!1;return Object.keys(this.schema).forEach((function(e){var t=i.schema[e],s=Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0,a=r(s,t),u=a[0];!a[2]||Object.prototype.hasOwnProperty.call(n,e)&&!i.defaults[e]||(f=!0),Object.prototype.hasOwnProperty.call(n,e)&&n[e]!==u&&(o[e]=u)})),[o,!0,f]},o(i,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name||"_temp"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),i}(w);function S(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(j.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return w.fromJS.call(this,e)});var E=Symbol("ENTITY WAS DELETED");function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function z(e,t,r){return(z=x()?Reflect.construct:function(e,t,r){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return r&&n(o,r.prototype),o}).apply(null,arguments)}function A(e){var t="function"==typeof Map?new Map:void 0;return(A=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return z(e,arguments,_(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),n(i,e)})(e)}var N=function(){this.children=new WeakMap},D=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return r(t,e),t}(A(Error)),V=function(){function e(){this.first=new WeakMap}var t=e.prototype;return t.delete=function(e){var t=this.traverse(e);return null==t||delete t.value,!!t},t.get=function(e){var t=this.traverse(e);return null==t?void 0:t.value},t.has=function(e){var t=this.traverse(e);return!!t&&Object.prototype.hasOwnProperty.call(t,"value")},t.set=function(e,t){if(e.length<1)throw new D;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new N,r.set(e[i],n)),r=n.children,i===e.length-1&&(n.value=t);return this},t.traverse=function(e){for(var t,n=this.first,r=0;r<e.length;r++){if(!(t=n.get(e[r])))return;n=t.children}return t},e}(),J=Symbol("draft"),P=function(e,t,n,r,i,o,s,a){var u=r(e,t);if(u===E)return[void 0,!0,!0];if("object"!=typeof u||null===u)return[u,!1,!1];void 0===i[t.key]&&(i[t.key]={});var c=!0,f=!1;if(i[t.key][e]){if(Object.prototype.hasOwnProperty.call(i[t.key][e],J))return a.i=i[t.key][e].i,[i[t.key][e][J],c,f];s.push(u)}else{var l=s.length;s.push(u);var h=function(e){var t=e.og||e,n=function(e,n){return t(e,n)};return n.og=e,n}(n);h.setLocal=function(n){var r;return i[t.key][e]=((r={})[J]=n,r.i=l,r)};var p=function(e,t,n){e[t.key]||(e[t.key]={});e[t.key][n]||(e[t.key][n]=new V);return e[t.key][n]}(o,t,e),d=t.denormalize(u,h);i[t.key][e]=d[0],c=d[1],f=d[2];var y=s.slice(-1===a.i?l:a.i);p.has(y)?i[t.key][e]=p.get(y):p.set(y,i[t.key][e]),a.i===l&&(a.i=-1)}return[i[t.key][e],c,f]},M=function(t){var n=e(t);return function(e,r){var i=r.key;return"object"==typeof e?e:n?t.getIn([i,e]):t[i]&&t[i][e]}};var T=function e(t,n,r,i,o,s){return t&&i?i.normalize&&"function"==typeof i.normalize?"object"!=typeof t?t:i.normalize(t,n,r,e,o,s):"function"==typeof i?new i(t):"object"!=typeof t||"object"!=typeof i?t:(Array.isArray(i)?f:d)(i,t,n,r,e,o,s):t};var I=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},n.infer=function(e,t,n){var r=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[r];if(void 0!==i)return{id:n(i,e,t),schema:r}},t}(s),L=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return Object.keys(e).reduce((function(t,n,a){var u,c=e[n];return null!=c?Object.assign({},t,((u={})[n]=s.normalizeValue(c,e,n,r,i,o),u)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,s){var a,u=e[s],c=n.denormalizeValue(u,t),f=c[0],l=c[1],h=c[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[s]=f,a))}),{}),r,i]},n.infer=function(e,t,n){},t}(s),R=function(){function e(e){if("production"!==process.env.NODE_ENV&&!e)throw new Error('Expected option "entity" not found on DeleteSchema.');this._entity=e}var t=e.prototype;return t.normalize=function(e,t,n,r,i,o){if("string"==typeof e)return e;var s=this._entity.fromJS(e,t,n).pk(t,n);if("production"!==process.env.NODE_ENV&&(void 0===s||""===s)){var a,u=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Delete(Entity): Delete("+(null!=(a=this._entity.name)?a:this._entity)+")\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw u.status=400,u}return i(this,E,s),s},t.infer=function(e,t,n){},t.denormalize=function(e,t){return t(e,this._entity)},t._denormalizeNullable=function(){return[]},t._normalizeNullable=function(){return[]},t.merge=function(e,t){return t},o(e,[{key:"key",get:function(){return this._entity.key}}]),e}(),U=Object.freeze({__proto__:null,Union:I,Values:L,Array:p,Object:v,Delete:R}),F=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(j);exports.DELETED=E,exports.Entity=j,exports.FlatEntity=F,exports.SimpleRecord=w,exports.WeakListMap=V,exports.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new V),void 0===t)return[e,!0,!1,{}];if(void 0===e)return[void 0,!1,!1,{}];var o={},s=function(e,t,n,r){var i=M(e),o=[],s={i:-1};function a(e,n){if(!n)return[e,!0,!1];if(!n.denormalize||"function"!=typeof n.denormalize){if("function"==typeof n)return e instanceof n?[e,!0,!1]:[new n(e),!0,!1];if("object"==typeof n)return(Array.isArray(n)?l:y)(n,e,a)}return null===e?[e,!0,!1]:S(n)?void 0===e?[e,!1,!1]:P(e,n,a,i,r,t,o,s):"function"==typeof n.denormalize?n.denormalize(e,a):[e,!0,!1]}return function(e,t){var r=a(e,t);return Object(e)!==e?r:(o.push(e),n.has(o)?[n.get(o),r[1],r[2]]:(n.set(o,r[0]),r))}}(n,r,i,o);return[].concat(s(e,t),[o])},exports.inferResults=function e(t,n,r){return function(e){return!!e&&"function"==typeof e.infer}(t)?t.infer(n,r,e):"object"==typeof t&&t?(Array.isArray(t)?h:m)(t,n,r,e):t},exports.isEntity=S,exports.normalize=function(e,t,n,r,i,o){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i={}),void 0===o&&(o={date:Date.now(),expiresAt:1/0}),void 0===t)return{entities:n,indexes:r,result:e,entityMeta:i};var s=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==s){if("production"!==process.env.NODE_ENV){throw"string"==typeof e&&function(e){try{return"string"!=typeof JSON.parse(e)}catch(e){return!1}}(e)?new Error('Normalizing a string, but this does match schema.\n\nParsing this input string as JSON worked. This likely indicates fetch function did not parse\nthe JSON. By default, this only happens if "content-type" header includes "json".\nSee https://resthooks.io/docs/guides/custom-networking for more information\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".')}var a=Object.assign({},n),u=Object.assign({},r),c=Object.assign({},i),f=function(e,t,n,r,i,o){return function(s,a,u){var c=s.key;c in e||(e[c]={},n[c]=Object.assign({},n[c]),i[c]=Object.assign({},i[c]));var f=e[c][u];if(f)e[c][u]=s.merge(f,a);else{var l=s.expiresAt?s.expiresAt(o,a):o.expiresAt,h=n[c][u];if(h){var p,d,y=(null==(p=i[c][u])?void 0:p.date)>o.date;e[c][u]=typeof a!=typeof h?y?h:a:y?s.merge(a,h):s.merge(h,a),i[c][u]=(null==(d=i[c][u])?void 0:d.expiresAt)>=l?i[c][u]:{expiresAt:l,date:o.date}}else e[c][u]=a,i[c][u]={expiresAt:l,date:o.date}}if(Array.isArray(s.indexes)){var m=e[c][u];c in t||(t[c]={},r[c]=Object.assign({},r[c]));for(var v,g=b(s.indexes);!(v=g()).done;){var O=v.value;O in t[c]||(r[c][O]=t[c][O]={});var k=t[c][O];f&&delete k[f[O]],n[c]&&n[c][u]&&n[c][u][O]!==m[O]&&(k[n[c][u][O]]=E),O in m?k[m[O]]=u:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+O+"\nEntity: "+JSON.stringify(m,void 0,2))}}n[c][u]=e[c][u]}}({},{},a,u,c,o);return{entities:a,indexes:u,result:T(e,e,void 0,t,f,{}),entityMeta:c}},exports.schema=U;

@@ -20,4 +20,3 @@ (function (global, factory) {

function isImmutable(object) {
return !!(object && typeof object.hasOwnProperty === 'function' && (Object.hasOwnProperty.call(object, '__ownerID') || // Immutable.Map
object._map && Object.hasOwnProperty.call(object._map, '__ownerID'))); // Immutable.Record
return !!(object && typeof object.hasOwnProperty === 'function' && (Object.hasOwnProperty.call(object, '__ownerID') || object._map && Object.hasOwnProperty.call(object._map, '__ownerID'))); // Immutable.Record
}

@@ -993,3 +992,5 @@ /**

var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache) {
var DRAFT = Symbol('draft');
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache, dependencies, cycleIndex) {
var entity = getEntity(id, schema);

@@ -1013,12 +1014,13 @@

if (!localCache[schema.key][id]) {
var globalKey = [entity];
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
var trackingIndex = dependencies.length;
dependencies.push(entity);
var wrappedUnvisit = withTrackedEntities(unvisit); // { [DRAFT] } means we are still processing - which if found indicates a cycle
wrappedUnvisit.setLocal = function (entityCopy) {
return localCache[schema.key][id] = entityCopy;
var _localCache$schema$ke;
return localCache[schema.key][id] = (_localCache$schema$ke = {}, _localCache$schema$ke[DRAFT] = entityCopy, _localCache$schema$ke.i = trackingIndex, _localCache$schema$ke);
};
if (!entityCache[schema.key]) entityCache[schema.key] = {};
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap();
var globalCacheEntry = entityCache[schema.key][id];
var globalCacheEntry = getGlobalCacheEntry(entityCache, schema, id);

@@ -1030,11 +1032,25 @@ var _schema$denormalize = schema.denormalize(entity, wrappedUnvisit);

deleted = _schema$denormalize[2];
// if in cycle, use the start of the cycle to track all deps
// otherwise, we use our own trackingIndex
var localKey = dependencies.slice(cycleIndex.i === -1 ? trackingIndex : cycleIndex.i);
if (!globalCacheEntry.has(globalKey)) {
globalCacheEntry.set(globalKey, localCache[schema.key][id]);
if (!globalCacheEntry.has(localKey)) {
globalCacheEntry.set(localKey, localCache[schema.key][id]);
} else {
// localCache is only used before this point for recursive relationships
// since recursive relationships must all referentially change if *any* do, we either
// get the correct one here, or will never find the same version in the cache
localCache[schema.key][id] = globalCacheEntry.get(globalKey);
localCache[schema.key][id] = globalCacheEntry.get(localKey);
} // start of cycle - reset cycle detection
if (cycleIndex.i === trackingIndex) {
cycleIndex.i = -1;
}
} else {
// cycle detected
if (Object.prototype.hasOwnProperty.call(localCache[schema.key][id], DRAFT)) {
cycleIndex.i = localCache[schema.key][id].i;
return [localCache[schema.key][id][DRAFT], found, deleted];
} else {
// with no cycle, globalCacheEntry will have already been set
dependencies.push(entity);
}
}

@@ -1047,2 +1063,6 @@

var getEntity = getEntities(entities);
var dependencies = [];
var cycleIndex = {
i: -1
};

@@ -1058,3 +1078,3 @@ function unvisit(input, schema) {

var method = Array.isArray(schema) ? denormalize$1 : _denormalize;
return method(schema, input, wrappedUnvisit);
return method(schema, input, unvisit);
}

@@ -1074,16 +1094,14 @@ } // null is considered intentional, thus always 'found' as true

return unvisitEntity(input, schema, wrappedUnvisit, getEntity, localCache, entityCache);
return unvisitEntity(input, schema, unvisit, getEntity, localCache, entityCache, dependencies, cycleIndex);
}
if (typeof schema.denormalize === 'function') {
return schema.denormalize(input, wrappedUnvisit);
return schema.denormalize(input, unvisit);
}
return [input, true, false];
}
} //const wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
var globalKey = [];
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
return function (input, schema) {
globalKey.push(input);
var ret = unvisit(input, schema); // in the case where WeakMap cannot be used

@@ -1093,8 +1111,9 @@ // this test ensures null is properly excluded from WeakMap

if (Object(input) !== input) return ret;
dependencies.push(input);
if (!resultCache.has(globalKey)) {
resultCache.set(globalKey, ret[0]);
if (!resultCache.has(dependencies)) {
resultCache.set(dependencies, ret[0]);
return ret;
} else {
return [resultCache.get(globalKey), ret[1], ret[2]];
return [resultCache.get(dependencies), ret[1], ret[2]];
}

@@ -1145,3 +1164,9 @@ };

function withTrackedEntities(unvisit, globalKey) {
function getGlobalCacheEntry(entityCache, schema, id) {
if (!entityCache[schema.key]) entityCache[schema.key] = {};
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap();
return entityCache[schema.key][id];
}
function withTrackedEntities(unvisit) {
// every time we nest, we want to unwrap back to the top.

@@ -1152,14 +1177,3 @@ // this is due to only needed the next level of nested entities for lookup

var wrappedUnvisit = function wrappedUnvisit(input, schema) {
var ret = originalUnvisit(input, schema); // pass over undefined in key
if (ret[0] && schema && isEntity(schema)) {
/* istanbul ignore else */
if (Object(ret[0]) === ret[0]) {
globalKey.push(ret[0]);
} else if (process.env.NODE_ENV !== 'production') {
throw new Error("Unexpected primitive found during denormalization\nFound: " + ret[0] + "\nExpected entity: " + schema);
}
}
return ret;
return originalUnvisit(input, schema);
};

@@ -1271,5 +1285,5 @@

else if ( // eslint-disable-next-line no-undef
process.env.NODE_ENV !== 'production') {
console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: " + index + "\nEntity: " + JSON.stringify(entity, undefined, 2));
}
process.env.NODE_ENV !== 'production') {
console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: " + index + "\nEntity: " + JSON.stringify(entity, undefined, 2));
}
}

@@ -1276,0 +1290,0 @@ } // set this after index updates so we know what indexes to remove from

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).rest_hooks_normalizr={})}(this,(function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function n(e,t,n){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var s=""+o,a=n(t.get(s),e[s]),u=a[0],c=a[1],f=a[2];return c||(r=!1),f&&(i=!0),t.has(s)?t.set(s,u):t}),t),r,i]}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r(e,t)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}var a=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var s=this.inferSchema(e,t,n);if(!s){if("production"!==process.env.NODE_ENV){var a=this.getSchemaAttribute(e,t,n);console.warn("Schema attribute "+JSON.stringify(a,void 0,2)+" is not expected.\nExpected one of: "+Object.keys(this.schema).map((function(e){return'"'+e+'"'})).join(", ")+"\n\nValue: "+JSON.stringify(e,void 0,2))}return e}var u=r(e,t,n,s,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,n){if(void 0===e)return[e,!1,!1];var r=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0,!1]},s(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),u=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},f=function(e){var t=e[0],n=e[2];return void 0!==t&&!n},l=function(e,t,n,r,i,o,s){return e=u(e),c(t).map((function(t,a){return i(t,n,r,e,o,s)}))},h=function(e,t,n){e=u(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(f).map((function(e){return e[0]})):t,i,r]};function p(e,t,n,r){}var d=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return c(e).map((function(e,a){return s.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(f).map((function(e){return e[0]})):e,i,r]},n.infer=function(e,t,n){this.schema},t}(a),y=function(e,t,n,r,i,o,s){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],u=i(t[n],t,n,r,o,s);null==u?delete a[n]:a[n]=u})),a},m=function(e,r,i){if(t(r))return n(e,r,i);var o=Object.assign({},r),s=!0,a=!1;return Object.keys(e).forEach((function(t){var n=i(o[t],e[t]),r=n[0],u=n[1],c=n[2];void 0!==o[t]&&(o[t]=r),c&&(a=!0),u||(s=!1)})),[o,s,a]};function v(e,t,n,r){for(var i={},o=0,s=Object.keys(e);o<s.length;o++){var a=s[o];i[a]=r(e[a],t,n)}return i}var g=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.apply(void 0,[this.schema].concat(t))},t.infer=function(e,t,n){return v(this.schema,e,t,n)},e}();function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function O(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var k=Symbol("Defined Members"),w=Symbol("unq"),j=function(){function e(){}return e.prototype.toString=function(){return this[w]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,k,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,w,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[k].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=O(e[k]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[k]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},e.infer=function(e,t,n){return v(this.schema,e,t,n)},e.denormalize=function(e,t){var n=this,r=Object.assign({},e),i=!1,o=!0;return Object.keys(this.schema).forEach((function(e){var s=t(r[e],n.schema[e]),a=s[0],u=s[1],c=s[2];void 0!==r[e]&&(r[e]=a),u||e in n.defaults&&!n.defaults[e]||(o=!1),!c||e in n.defaults&&!n.defaults[e]||(i=!0)})),[this.fromJS(r),o,i]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},s(e,null,[{key:"defaults",get:function(){return Object.prototype.hasOwnProperty.call(this,"__defaults")||(this.__defaults=new this),this.__defaults}}]),e}();j.schema={};var E=function(e){function r(){return e.apply(this,arguments)||this}return i(r,e),r.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},r.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},r.normalize=function(e,t,n,r,i,o){var s=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);this.validate(a,e);var u=a.pk(t,n);if(void 0!==u&&""!==u){var c=this.key;return c in o||(o[c]={}),u in o[c]||(o[c][u]=[]),o[c][u].some((function(t){return t===e}))?u:(o[c][u].push(e),Object.keys(this.schema).forEach((function(e){if(Object.prototype.hasOwnProperty.call(a,e)){var t=s.schema[e];a[e]=r(a[e],a,e,t,i,o)}else if("production"!==process.env.NODE_ENV){var n=new Error("Schema key is missing in Entity\n\n Be sure all schema members are also part of the entity\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about nesting schemas: https://resthooks.io/docs/guides/nested-response\n\n Entity keys: "+Object.keys(a)+"\n Schema key(missing): "+e+"\n ");throw n.status=400,n}})),i(this,a,u),u)}if("production"!==process.env.NODE_ENV){var f=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Entity: "+this.name+"\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw f.status=400,f}},r.validate=function(e,t){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation){for(var n,r=new Set(Object.keys(this.defaults)),i=this.keysDefined(e),o=[[],[],[]],s=o[0],a=o[1],u=o[2],c=O(i);!(n=c()).done;){var f=n.value;r.has(f)?s.push(f):u.push(f)}for(var l,h=O(r);!(l=h()).done;){var p=l.value;s.includes(p)||a.push(p)}if(r.size){if(Array.isArray(t)&&u.length){var d="Attempted to initialize "+this.name+" with an array, but named members were expected\n\nThis is likely due to a malformed response.\nTry inspecting the network response or fetch() return value.\nOr use debugging tools: https://resthooks.io/docs/guides/debugging\nLearn more about schemas: https://resthooks.io/docs/api/schema\nIf this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\nMissing: "+a+"\nFirst three members: "+JSON.stringify(t.slice(0,3),null,2);if("warn"!==this.automaticValidation){var y=new Error(d);throw y.status=400,y}console.warn(d)}var m=Math.max(i.length/2,1)<=u.length&&r.size>Math.max(u.length,2)&&Math.pow(s.length,1.5)/2<=u.length,v=s.length<Math.min(1,r.size/2);if(m||v){var g="",b="substantially different than expected keys";v&&(g+="\n Missing: "+a,b="no matching keys found"),m&&(g+="\n Unexpected keys: "+u,b="a large number of unexpected keys found");var k="Attempted to initialize "+this.name+" with "+b+"\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n If this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\n Expected keys:\n Found: "+s+g+"\n Value: "+JSON.stringify(this.toObjectDefined(e),null,2);if(!(s.length>=4&&m||"warn"===this.automaticValidation)){var w=new Error(k);throw w.status=400,w}console.warn(k)}}}},r.expiresAt=function(e,t){return e.expiresAt},r.infer=function(e,t,n){if(e[0]){var r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;var i=function(e,t){return t?t.find((function(t){return Object.prototype.hasOwnProperty.call(e,t)})):void 0}(e[0],this.indexes);return i&&t[this.key]?t[this.key][i][e[0][i]]:void 0}},r.denormalize=function(e,r){var i=this,o=t(e)?e:this.fromJS(e instanceof j?this.toObjectDefined(e):e);if(null==r.setLocal||r.setLocal(o),t(e)){var s=n(this.schema,e,r),a=s[0],u=s[1],c=s[2];return[this.fromJS(a.toObject()),u,c]}var f=!1;return Object.keys(this.schema).forEach((function(t){var n=i.schema[t],s=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,a=r(s,n),u=a[0];!a[2]||Object.prototype.hasOwnProperty.call(e,t)&&!i.defaults[t]||(f=!0),Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==u&&(o[t]=u)})),[o,!0,f]},s(r,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name||"_temp"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),r}(j);function S(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(E.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return j.fromJS.call(this,e)});var _=Symbol("ENTITY WAS DELETED");function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function A(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function N(e,t,n){return(N=A()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&r(o,n.prototype),o}).apply(null,arguments)}function x(e){var t="function"==typeof Map?new Map:void 0;return(x=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return N(e,arguments,z(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,e)})(e)}var D=function(){this.children=new WeakMap},V=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return i(t,e),t}(x(Error)),J=function(){function e(){this.first=new WeakMap}var t=e.prototype;return t.delete=function(e){var t=this.traverse(e);return null==t||delete t.value,!!t},t.get=function(e){var t=this.traverse(e);return null==t?void 0:t.value},t.has=function(e){var t=this.traverse(e);return!!t&&Object.prototype.hasOwnProperty.call(t,"value")},t.set=function(e,t){if(e.length<1)throw new V;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new D,r.set(e[i],n)),r=n.children,i===e.length-1&&(n.value=t);return this},t.traverse=function(e){for(var t,n=this.first,r=0;r<e.length;r++){if(!(t=n.get(e[r])))return;n=t.children}return t},e}(),P=function(e,t,n,r){var i=M(e);function o(e,n){if(!n)return[e,!0,!1];if(!n.denormalize||"function"!=typeof n.denormalize){if("function"==typeof n)return e instanceof n?[e,!0,!1]:[new n(e),!0,!1];if("object"==typeof n)return(Array.isArray(n)?h:m)(n,e,a)}return null===e?[e,!0,!1]:S(n)?void 0===e?[e,!1,!1]:function(e,t,n,r,i,o){var s=r(e,t);if(s===_)return[void 0,!0,!0];if("object"!=typeof s||null===s)return[s,!1,!1];void 0===i[t.key]&&(i[t.key]={});var a=!0,u=!1;if(!i[t.key][e]){var c=[s],f=T(n,c);f.setLocal=function(n){return i[t.key][e]=n},o[t.key]||(o[t.key]={}),o[t.key][e]||(o[t.key][e]=new J);var l=o[t.key][e],h=t.denormalize(s,f);i[t.key][e]=h[0],a=h[1],u=h[2],l.has(c)?i[t.key][e]=l.get(c):l.set(c,i[t.key][e])}return[i[t.key][e],a,u]}(e,n,a,i,r,t):"function"==typeof n.denormalize?n.denormalize(e,a):[e,!0,!1]}var s=[],a=T(o,s);return function(e,t){s.push(e);var r=o(e,t);return Object(e)!==e?r:n.has(s)?[n.get(s),r[1],r[2]]:(n.set(s,r[0]),r)}},M=function(e){var n=t(e);return function(t,r){var i=r.key;return"object"==typeof t?t:n?e.getIn([i,t]):e[i]&&e[i][t]}};function T(e,t){var n=e.og||e,r=function(e,r){var i=n(e,r);if(i[0]&&r&&S(r))if(Object(i[0])===i[0])t.push(i[0]);else if("production"!==process.env.NODE_ENV)throw new Error("Unexpected primitive found during denormalization\nFound: "+i[0]+"\nExpected entity: "+r);return i};return r.og=e,r}var I=function e(t,n,r,i,o,s){return t&&i?i.normalize&&"function"==typeof i.normalize?"object"!=typeof t?t:i.normalize(t,n,r,e,o,s):"function"==typeof i?new i(t):"object"!=typeof t||"object"!=typeof i?t:(Array.isArray(i)?l:y)(i,t,n,r,e,o,s):t};var L=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},n.infer=function(e,t,n){var r=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[r];if(void 0!==i)return{id:n(i,e,t),schema:r}},t}(a),R=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return Object.keys(e).reduce((function(t,n,a){var u,c=e[n];return null!=c?Object.assign({},t,((u={})[n]=s.normalizeValue(c,e,n,r,i,o),u)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,s){var a,u=e[s],c=n.denormalizeValue(u,t),f=c[0],l=c[1],h=c[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[s]=f,a))}),{}),r,i]},n.infer=function(e,t,n){},t}(a),U=function(){function e(e){if("production"!==process.env.NODE_ENV&&!e)throw new Error('Expected option "entity" not found on DeleteSchema.');this._entity=e}var t=e.prototype;return t.normalize=function(e,t,n,r,i,o){if("string"==typeof e)return e;var s=this._entity.fromJS(e,t,n).pk(t,n);if("production"!==process.env.NODE_ENV&&(void 0===s||""===s)){var a,u=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Delete(Entity): Delete("+(null!=(a=this._entity.name)?a:this._entity)+")\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw u.status=400,u}return i(this,_,s),s},t.infer=function(e,t,n){},t.denormalize=function(e,t){return t(e,this._entity)},t._denormalizeNullable=function(){return[]},t._normalizeNullable=function(){return[]},t.merge=function(e,t){return t},s(e,[{key:"key",get:function(){return this._entity.key}}]),e}(),F=Object.freeze({__proto__:null,Union:L,Values:R,Array:d,Object:g,Delete:U}),B=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(E);e.DELETED=_,e.Entity=E,e.FlatEntity=B,e.SimpleRecord=j,e.WeakListMap=J,e.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new J),void 0===t)return[e,!0,!1,{}];if(void 0===e)return[void 0,!1,!1,{}];var o={},s=P(n,r,i,o);return[].concat(s(e,t),[o])},e.inferResults=function e(t,n,r){return function(e){return!!e&&"function"==typeof e.infer}(t)?t.infer(n,r,e):"object"==typeof t&&t?(Array.isArray(t)?p:v)(t,n,r,e):t},e.isEntity=S,e.normalize=function(e,t,n,r,i,o){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i={}),void 0===o&&(o={date:Date.now(),expiresAt:1/0}),void 0===t)return{entities:n,indexes:r,result:e,entityMeta:i};var s=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==s){if("production"!==process.env.NODE_ENV){throw"string"==typeof e&&function(e){try{return"string"!=typeof JSON.parse(e)}catch(e){return!1}}(e)?new Error('Normalizing a string, but this does match schema.\n\nParsing this input string as JSON worked. This likely indicates fetch function did not parse\nthe JSON. By default, this only happens if "content-type" header includes "json".\nSee https://resthooks.io/docs/guides/custom-networking for more information\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".')}var a=Object.assign({},n),u=Object.assign({},r),c=Object.assign({},i),f=function(e,t,n,r,i,o){return function(s,a,u){var c=s.key;c in e||(e[c]={},n[c]=Object.assign({},n[c]),i[c]=Object.assign({},i[c]));var f=e[c][u];if(f)e[c][u]=s.merge(f,a);else{var l=s.expiresAt?s.expiresAt(o,a):o.expiresAt,h=n[c][u];if(h){var p,d,y=(null==(p=i[c][u])?void 0:p.date)>o.date;e[c][u]=typeof a!=typeof h?y?h:a:y?s.merge(a,h):s.merge(h,a),i[c][u]=(null==(d=i[c][u])?void 0:d.expiresAt)>=l?i[c][u]:{expiresAt:l,date:o.date}}else e[c][u]=a,i[c][u]={expiresAt:l,date:o.date}}if(Array.isArray(s.indexes)){var m=e[c][u];c in t||(t[c]={},r[c]=Object.assign({},r[c]));for(var v,g=O(s.indexes);!(v=g()).done;){var b=v.value;b in t[c]||(r[c][b]=t[c][b]={});var k=t[c][b];f&&delete k[f[b]],n[c]&&n[c][u]&&n[c][u][b]!==m[b]&&(k[n[c][u][b]]=_),b in m?k[m[b]]=u:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+b+"\nEntity: "+JSON.stringify(m,void 0,2))}}n[c][u]=e[c][u]}}({},{},a,u,c,o);return{entities:a,indexes:u,result:I(e,e,void 0,t,f,{}),entityMeta:c}},e.schema=F,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).rest_hooks_normalizr={})}(this,(function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function n(e,t,n){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var s=""+o,a=n(t.get(s),e[s]),u=a[0],c=a[1],f=a[2];return c||(r=!1),f&&(i=!0),t.has(s)?t.set(s,u):t}),t),r,i]}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r(e,t)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}var a=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var s=this.inferSchema(e,t,n);if(!s){if("production"!==process.env.NODE_ENV){var a=this.getSchemaAttribute(e,t,n);console.warn("Schema attribute "+JSON.stringify(a,void 0,2)+" is not expected.\nExpected one of: "+Object.keys(this.schema).map((function(e){return'"'+e+'"'})).join(", ")+"\n\nValue: "+JSON.stringify(e,void 0,2))}return e}var u=r(e,t,n,s,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,n){if(void 0===e)return[e,!1,!1];var r=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0,!1]},s(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),u=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},f=function(e){var t=e[0],n=e[2];return void 0!==t&&!n},l=function(e,t,n,r,i,o,s){return e=u(e),c(t).map((function(t,a){return i(t,n,r,e,o,s)}))},h=function(e,t,n){e=u(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(f).map((function(e){return e[0]})):t,i,r]};function p(e,t,n,r){}var d=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return c(e).map((function(e,a){return s.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(f).map((function(e){return e[0]})):e,i,r]},n.infer=function(e,t,n){this.schema},t}(a),y=function(e,t,n,r,i,o,s){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],u=i(t[n],t,n,r,o,s);null==u?delete a[n]:a[n]=u})),a},m=function(e,r,i){if(t(r))return n(e,r,i);var o=Object.assign({},r),s=!0,a=!1;return Object.keys(e).forEach((function(t){var n=i(o[t],e[t]),r=n[0],u=n[1],c=n[2];void 0!==o[t]&&(o[t]=r),c&&(a=!0),u||(s=!1)})),[o,s,a]};function v(e,t,n,r){for(var i={},o=0,s=Object.keys(e);o<s.length;o++){var a=s[o];i[a]=r(e[a],t,n)}return i}var g=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.apply(void 0,[this.schema].concat(t))},t.infer=function(e,t,n){return v(this.schema,e,t,n)},e}();function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function O(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var k=Symbol("Defined Members"),w=Symbol("unq"),j=function(){function e(){}return e.prototype.toString=function(){return this[w]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,k,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,w,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[k].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=O(e[k]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[k]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.apply(void 0,[this.schema].concat(t))},e.infer=function(e,t,n){return v(this.schema,e,t,n)},e.denormalize=function(e,t){var n=this,r=Object.assign({},e),i=!1,o=!0;return Object.keys(this.schema).forEach((function(e){var s=t(r[e],n.schema[e]),a=s[0],u=s[1],c=s[2];void 0!==r[e]&&(r[e]=a),u||e in n.defaults&&!n.defaults[e]||(o=!1),!c||e in n.defaults&&!n.defaults[e]||(i=!0)})),[this.fromJS(r),o,i]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},s(e,null,[{key:"defaults",get:function(){return Object.prototype.hasOwnProperty.call(this,"__defaults")||(this.__defaults=new this),this.__defaults}}]),e}();j.schema={};var S=function(e){function r(){return e.apply(this,arguments)||this}return i(r,e),r.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},r.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},r.normalize=function(e,t,n,r,i,o){var s=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);this.validate(a,e);var u=a.pk(t,n);if(void 0!==u&&""!==u){var c=this.key;return c in o||(o[c]={}),u in o[c]||(o[c][u]=[]),o[c][u].some((function(t){return t===e}))?u:(o[c][u].push(e),Object.keys(this.schema).forEach((function(e){if(Object.prototype.hasOwnProperty.call(a,e)){var t=s.schema[e];a[e]=r(a[e],a,e,t,i,o)}else if("production"!==process.env.NODE_ENV){var n=new Error("Schema key is missing in Entity\n\n Be sure all schema members are also part of the entity\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about nesting schemas: https://resthooks.io/docs/guides/nested-response\n\n Entity keys: "+Object.keys(a)+"\n Schema key(missing): "+e+"\n ");throw n.status=400,n}})),i(this,a,u),u)}if("production"!==process.env.NODE_ENV){var f=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Entity: "+this.name+"\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw f.status=400,f}},r.validate=function(e,t){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation){for(var n,r=new Set(Object.keys(this.defaults)),i=this.keysDefined(e),o=[[],[],[]],s=o[0],a=o[1],u=o[2],c=O(i);!(n=c()).done;){var f=n.value;r.has(f)?s.push(f):u.push(f)}for(var l,h=O(r);!(l=h()).done;){var p=l.value;s.includes(p)||a.push(p)}if(r.size){if(Array.isArray(t)&&u.length){var d="Attempted to initialize "+this.name+" with an array, but named members were expected\n\nThis is likely due to a malformed response.\nTry inspecting the network response or fetch() return value.\nOr use debugging tools: https://resthooks.io/docs/guides/debugging\nLearn more about schemas: https://resthooks.io/docs/api/schema\nIf this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\nMissing: "+a+"\nFirst three members: "+JSON.stringify(t.slice(0,3),null,2);if("warn"!==this.automaticValidation){var y=new Error(d);throw y.status=400,y}console.warn(d)}var m=Math.max(i.length/2,1)<=u.length&&r.size>Math.max(u.length,2)&&Math.pow(s.length,1.5)/2<=u.length,v=s.length<Math.min(1,r.size/2);if(m||v){var g="",b="substantially different than expected keys";v&&(g+="\n Missing: "+a,b="no matching keys found"),m&&(g+="\n Unexpected keys: "+u,b="a large number of unexpected keys found");var k="Attempted to initialize "+this.name+" with "+b+"\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n If this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\n Expected keys:\n Found: "+s+g+"\n Value: "+JSON.stringify(this.toObjectDefined(e),null,2);if(!(s.length>=4&&m||"warn"===this.automaticValidation)){var w=new Error(k);throw w.status=400,w}console.warn(k)}}}},r.expiresAt=function(e,t){return e.expiresAt},r.infer=function(e,t,n){if(e[0]){var r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;var i=function(e,t){return t?t.find((function(t){return Object.prototype.hasOwnProperty.call(e,t)})):void 0}(e[0],this.indexes);return i&&t[this.key]?t[this.key][i][e[0][i]]:void 0}},r.denormalize=function(e,r){var i=this,o=t(e)?e:this.fromJS(e instanceof j?this.toObjectDefined(e):e);if(null==r.setLocal||r.setLocal(o),t(e)){var s=n(this.schema,e,r),a=s[0],u=s[1],c=s[2];return[this.fromJS(a.toObject()),u,c]}var f=!1;return Object.keys(this.schema).forEach((function(t){var n=i.schema[t],s=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,a=r(s,n),u=a[0];!a[2]||Object.prototype.hasOwnProperty.call(e,t)&&!i.defaults[t]||(f=!0),Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==u&&(o[t]=u)})),[o,!0,f]},s(r,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name||"_temp"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),r}(j);function E(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(S.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return j.fromJS.call(this,e)});var _=Symbol("ENTITY WAS DELETED");function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function A(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function N(e,t,n){return(N=A()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&r(o,n.prototype),o}).apply(null,arguments)}function x(e){var t="function"==typeof Map?new Map:void 0;return(x=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return N(e,arguments,z(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,e)})(e)}var D=function(){this.children=new WeakMap},V=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return i(t,e),t}(x(Error)),J=function(){function e(){this.first=new WeakMap}var t=e.prototype;return t.delete=function(e){var t=this.traverse(e);return null==t||delete t.value,!!t},t.get=function(e){var t=this.traverse(e);return null==t?void 0:t.value},t.has=function(e){var t=this.traverse(e);return!!t&&Object.prototype.hasOwnProperty.call(t,"value")},t.set=function(e,t){if(e.length<1)throw new V;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new D,r.set(e[i],n)),r=n.children,i===e.length-1&&(n.value=t);return this},t.traverse=function(e){for(var t,n=this.first,r=0;r<e.length;r++){if(!(t=n.get(e[r])))return;n=t.children}return t},e}(),P=Symbol("draft"),M=function(e,t,n,r,i,o,s,a){var u=r(e,t);if(u===_)return[void 0,!0,!0];if("object"!=typeof u||null===u)return[u,!1,!1];void 0===i[t.key]&&(i[t.key]={});var c=!0,f=!1;if(i[t.key][e]){if(Object.prototype.hasOwnProperty.call(i[t.key][e],P))return a.i=i[t.key][e].i,[i[t.key][e][P],c,f];s.push(u)}else{var l=s.length;s.push(u);var h=function(e){var t=e.og||e,n=function(e,n){return t(e,n)};return n.og=e,n}(n);h.setLocal=function(n){var r;return i[t.key][e]=((r={})[P]=n,r.i=l,r)};var p=function(e,t,n){e[t.key]||(e[t.key]={});e[t.key][n]||(e[t.key][n]=new J);return e[t.key][n]}(o,t,e),d=t.denormalize(u,h);i[t.key][e]=d[0],c=d[1],f=d[2];var y=s.slice(-1===a.i?l:a.i);p.has(y)?i[t.key][e]=p.get(y):p.set(y,i[t.key][e]),a.i===l&&(a.i=-1)}return[i[t.key][e],c,f]},T=function(e){var n=t(e);return function(t,r){var i=r.key;return"object"==typeof t?t:n?e.getIn([i,t]):e[i]&&e[i][t]}};var I=function e(t,n,r,i,o,s){return t&&i?i.normalize&&"function"==typeof i.normalize?"object"!=typeof t?t:i.normalize(t,n,r,e,o,s):"function"==typeof i?new i(t):"object"!=typeof t||"object"!=typeof i?t:(Array.isArray(i)?l:y)(i,t,n,r,e,o,s):t};var L=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},n.infer=function(e,t,n){var r=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[r];if(void 0!==i)return{id:n(i,e,t),schema:r}},t}(a),R=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var s=this;return Object.keys(e).reduce((function(t,n,a){var u,c=e[n];return null!=c?Object.assign({},t,((u={})[n]=s.normalizeValue(c,e,n,r,i,o),u)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,s){var a,u=e[s],c=n.denormalizeValue(u,t),f=c[0],l=c[1],h=c[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[s]=f,a))}),{}),r,i]},n.infer=function(e,t,n){},t}(a),U=function(){function e(e){if("production"!==process.env.NODE_ENV&&!e)throw new Error('Expected option "entity" not found on DeleteSchema.');this._entity=e}var t=e.prototype;return t.normalize=function(e,t,n,r,i,o){if("string"==typeof e)return e;var s=this._entity.fromJS(e,t,n).pk(t,n);if("production"!==process.env.NODE_ENV&&(void 0===s||""===s)){var a,u=new Error("Missing usable primary key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Delete(Entity): Delete("+(null!=(a=this._entity.name)?a:this._entity)+")\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw u.status=400,u}return i(this,_,s),s},t.infer=function(e,t,n){},t.denormalize=function(e,t){return t(e,this._entity)},t._denormalizeNullable=function(){return[]},t._normalizeNullable=function(){return[]},t.merge=function(e,t){return t},s(e,[{key:"key",get:function(){return this._entity.key}}]),e}(),F=Object.freeze({__proto__:null,Union:L,Values:R,Array:d,Object:g,Delete:U}),B=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(S);e.DELETED=_,e.Entity=S,e.FlatEntity=B,e.SimpleRecord=j,e.WeakListMap=J,e.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new J),void 0===t)return[e,!0,!1,{}];if(void 0===e)return[void 0,!1,!1,{}];var o={},s=function(e,t,n,r){var i=T(e),o=[],s={i:-1};function a(e,n){if(!n)return[e,!0,!1];if(!n.denormalize||"function"!=typeof n.denormalize){if("function"==typeof n)return e instanceof n?[e,!0,!1]:[new n(e),!0,!1];if("object"==typeof n)return(Array.isArray(n)?h:m)(n,e,a)}return null===e?[e,!0,!1]:E(n)?void 0===e?[e,!1,!1]:M(e,n,a,i,r,t,o,s):"function"==typeof n.denormalize?n.denormalize(e,a):[e,!0,!1]}return function(e,t){var r=a(e,t);return Object(e)!==e?r:(o.push(e),n.has(o)?[n.get(o),r[1],r[2]]:(n.set(o,r[0]),r))}}(n,r,i,o);return[].concat(s(e,t),[o])},e.inferResults=function e(t,n,r){return function(e){return!!e&&"function"==typeof e.infer}(t)?t.infer(n,r,e):"object"==typeof t&&t?(Array.isArray(t)?p:v)(t,n,r,e):t},e.isEntity=E,e.normalize=function(e,t,n,r,i,o){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i={}),void 0===o&&(o={date:Date.now(),expiresAt:1/0}),void 0===t)return{entities:n,indexes:r,result:e,entityMeta:i};var s=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==s){if("production"!==process.env.NODE_ENV){throw"string"==typeof e&&function(e){try{return"string"!=typeof JSON.parse(e)}catch(e){return!1}}(e)?new Error('Normalizing a string, but this does match schema.\n\nParsing this input string as JSON worked. This likely indicates fetch function did not parse\nthe JSON. By default, this only happens if "content-type" header includes "json".\nSee https://resthooks.io/docs/guides/custom-networking for more information\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+s+'", found "'+(null===e?"null":typeof e)+'".')}var a=Object.assign({},n),u=Object.assign({},r),c=Object.assign({},i),f=function(e,t,n,r,i,o){return function(s,a,u){var c=s.key;c in e||(e[c]={},n[c]=Object.assign({},n[c]),i[c]=Object.assign({},i[c]));var f=e[c][u];if(f)e[c][u]=s.merge(f,a);else{var l=s.expiresAt?s.expiresAt(o,a):o.expiresAt,h=n[c][u];if(h){var p,d,y=(null==(p=i[c][u])?void 0:p.date)>o.date;e[c][u]=typeof a!=typeof h?y?h:a:y?s.merge(a,h):s.merge(h,a),i[c][u]=(null==(d=i[c][u])?void 0:d.expiresAt)>=l?i[c][u]:{expiresAt:l,date:o.date}}else e[c][u]=a,i[c][u]={expiresAt:l,date:o.date}}if(Array.isArray(s.indexes)){var m=e[c][u];c in t||(t[c]={},r[c]=Object.assign({},r[c]));for(var v,g=O(s.indexes);!(v=g()).done;){var b=v.value;b in t[c]||(r[c][b]=t[c][b]={});var k=t[c][b];f&&delete k[f[b]],n[c]&&n[c][u]&&n[c][u][b]!==m[b]&&(k[n[c][u][b]]=_),b in m?k[m[b]]=u:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+b+"\nEntity: "+JSON.stringify(m,void 0,2))}}n[c][u]=e[c][u]}}({},{},a,u,c,o);return{entities:a,indexes:u,result:I(e,e,void 0,t,f,{}),entityMeta:c}},e.schema=F,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,3 +0,3 @@

import { Denormalize, DenormalizeNullable, Schema, DenormalizeCache } from './types';
import WeakListMap from './WeakListMap';
import { Denormalize, DenormalizeNullable, Schema, DenormalizeCache } from "./types";
import WeakListMap from "./WeakListMap";
declare type DenormalizeReturn<S extends Schema> = [

@@ -4,0 +4,0 @@ denormalized: Denormalize<S>,

@@ -7,4 +7,5 @@ import { isImmutable } from './schemas/ImmutableUtils';

import WeakListMap from './WeakListMap';
const DRAFT = Symbol('draft');
const unvisitEntity = (id, schema, unvisit, getEntity, localCache, entityCache) => {
const unvisitEntity = (id, schema, unvisit, getEntity, localCache, entityCache, dependencies, cycleIndex) => {
const entity = getEntity(id, schema);

@@ -28,20 +29,36 @@

if (!localCache[schema.key][id]) {
const globalKey = [entity];
const wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
const trackingIndex = dependencies.length;
dependencies.push(entity);
const wrappedUnvisit = withTrackedEntities(unvisit); // { [DRAFT] } means we are still processing - which if found indicates a cycle
wrappedUnvisit.setLocal = entityCopy => localCache[schema.key][id] = entityCopy;
wrappedUnvisit.setLocal = entityCopy => localCache[schema.key][id] = {
[DRAFT]: entityCopy,
i: trackingIndex
};
if (!entityCache[schema.key]) entityCache[schema.key] = {};
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap();
const globalCacheEntry = entityCache[schema.key][id];
[localCache[schema.key][id], found, deleted] = schema.denormalize(entity, wrappedUnvisit);
const globalCacheEntry = getGlobalCacheEntry(entityCache, schema, id);
[localCache[schema.key][id], found, deleted] = schema.denormalize(entity, wrappedUnvisit); // if in cycle, use the start of the cycle to track all deps
// otherwise, we use our own trackingIndex
if (!globalCacheEntry.has(globalKey)) {
globalCacheEntry.set(globalKey, localCache[schema.key][id]);
const localKey = dependencies.slice(cycleIndex.i === -1 ? trackingIndex : cycleIndex.i);
if (!globalCacheEntry.has(localKey)) {
globalCacheEntry.set(localKey, localCache[schema.key][id]);
} else {
// localCache is only used before this point for recursive relationships
// since recursive relationships must all referentially change if *any* do, we either
// get the correct one here, or will never find the same version in the cache
localCache[schema.key][id] = globalCacheEntry.get(globalKey);
localCache[schema.key][id] = globalCacheEntry.get(localKey);
} // start of cycle - reset cycle detection
if (cycleIndex.i === trackingIndex) {
cycleIndex.i = -1;
}
} else {
// cycle detected
if (Object.prototype.hasOwnProperty.call(localCache[schema.key][id], DRAFT)) {
cycleIndex.i = localCache[schema.key][id].i;
return [localCache[schema.key][id][DRAFT], found, deleted];
} else {
// with no cycle, globalCacheEntry will have already been set
dependencies.push(entity);
}
}

@@ -54,2 +71,6 @@

const getEntity = getEntities(entities);
const dependencies = [];
const cycleIndex = {
i: -1
};

@@ -65,3 +86,3 @@ function unvisit(input, schema) {

const method = Array.isArray(schema) ? arrayDenormalize : objectDenormalize;
return method(schema, input, wrappedUnvisit);
return method(schema, input, unvisit);
}

@@ -81,16 +102,14 @@ } // null is considered intentional, thus always 'found' as true

return unvisitEntity(input, schema, wrappedUnvisit, getEntity, localCache, entityCache);
return unvisitEntity(input, schema, unvisit, getEntity, localCache, entityCache, dependencies, cycleIndex);
}
if (typeof schema.denormalize === 'function') {
return schema.denormalize(input, wrappedUnvisit);
return schema.denormalize(input, unvisit);
}
return [input, true, false];
}
} //const wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
const globalKey = [];
const wrappedUnvisit = withTrackedEntities(unvisit, globalKey);
return (input, schema) => {
globalKey.push(input);
const ret = unvisit(input, schema); // in the case where WeakMap cannot be used

@@ -100,8 +119,9 @@ // this test ensures null is properly excluded from WeakMap

if (Object(input) !== input) return ret;
dependencies.push(input);
if (!resultCache.has(globalKey)) {
resultCache.set(globalKey, ret[0]);
if (!resultCache.has(dependencies)) {
resultCache.set(dependencies, ret[0]);
return ret;
} else {
return [resultCache.get(globalKey), ret[1], ret[2]];
return [resultCache.get(dependencies), ret[1], ret[2]];
}

@@ -145,3 +165,9 @@ };

function withTrackedEntities(unvisit, globalKey) {
function getGlobalCacheEntry(entityCache, schema, id) {
if (!entityCache[schema.key]) entityCache[schema.key] = {};
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap();
return entityCache[schema.key][id];
}
function withTrackedEntities(unvisit) {
// every time we nest, we want to unwrap back to the top.

@@ -151,20 +177,7 @@ // this is due to only needed the next level of nested entities for lookup

const wrappedUnvisit = (input, schema) => {
const ret = originalUnvisit(input, schema); // pass over undefined in key
const wrappedUnvisit = (input, schema) => originalUnvisit(input, schema);
if (ret[0] && schema && isEntity(schema)) {
/* istanbul ignore else */
if (Object(ret[0]) === ret[0]) {
globalKey.push(ret[0]);
} else if (process.env.NODE_ENV !== 'production') {
throw new Error(`Unexpected primitive found during denormalization\nFound: ${ret[0]}\nExpected entity: ${schema}`);
}
}
return ret;
};
wrappedUnvisit.og = unvisit;
return wrappedUnvisit;
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9kZW5vcm1hbGl6ZS50cyJdLCJuYW1lcyI6WyJpc0ltbXV0YWJsZSIsImRlbm9ybWFsaXplIiwiYXJyYXlEZW5vcm1hbGl6ZSIsIm9iamVjdERlbm9ybWFsaXplIiwiaXNFbnRpdHkiLCJERUxFVEVEIiwiV2Vha0xpc3RNYXAiLCJ1bnZpc2l0RW50aXR5IiwiaWQiLCJzY2hlbWEiLCJ1bnZpc2l0IiwiZ2V0RW50aXR5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ecord from './SimpleRecord';
import * as schema from '../schema';
import { AbstractInstanceType, Schema } from '../types';
/** Represents data that should be deduped by specifying a primary key. */
export default abstract class Entity extends SimpleRecord {
import * as schema from "../schema";
import { AbstractInstanceType, Schema, NormalizedIndex } from "../types";
/**
* Represents data that should be deduped by specifying a primary key.
* @see https://resthooks.io/docs/api/Entity
*/
export default abstract class Entity {
static toJSON(): {
key: string;
name: string;

@@ -12,3 +13,8 @@ schema: {

};
key: string;
};
/** Defines nested entities */
static schema: {
[k: string]: Schema;
};
/**

@@ -42,4 +48,16 @@ * A unique identifier for each Entity

static pk<T extends typeof Entity>(this: T, value: Partial<AbstractInstanceType<T>>, parent?: any, key?: string): string | undefined;
/** Creates new instance copying over defined values of arguments */
static merge<T extends typeof Entity>(this: T, existing: Partial<AbstractInstanceType<T>>, incoming: Partial<AbstractInstanceType<T>>): Partial<AbstractInstanceType<T>>;
/** Factory method to convert from Plain JS Objects.
*
* @param [props] Plain Object of properties to assign.
* @param [parent] When normalizing, the object which included the record
* @param [key] When normalizing, the key where this record was found
*/
static fromJS<T extends typeof Entity>(this: T, props?: Partial<AbstractInstanceType<T>>): AbstractInstanceType<T>;
/** Do any transformations when first receiving input */
static process(input: any, parent: any, key: string | undefined): any;
static normalize(input: any, parent: any, key: string | undefined, visit: (...args: any) => any, addEntity: (...args: any) => any, visitedEntities: Record<string, any>): any;
protected static validate(processedEntity: Entity, input: any): void;
protected static validate(processedEntity: any): string | undefined;
static infer(args: any[], indexes: NormalizedIndex, recurse: any): any;
static expiresAt(meta: {

@@ -49,6 +67,10 @@ expiresAt: number;

}, input: any): number;
static infer(args: any, indexes: any, infer: any): any;
static denormalize<T extends typeof SimpleRecord>(this: T, input: Readonly<Partial<AbstractInstanceType<T>>>, unvisit: schema.UnvisitFunction): [AbstractInstanceType<T>, boolean, boolean];
static denormalize<T extends typeof Entity>(this: T, input: Readonly<Partial<AbstractInstanceType<T>>>, unvisit: schema.UnvisitFunction): [denormalized: AbstractInstanceType<T>, found: boolean, suspend: boolean];
private static __defaults;
/** All instance defaults set */
protected static get defaults(): any;
/** Used by denormalize to set nested members */
protected static set(entity: any, key: string, value: any): void;
}
export declare function isEntity(schema: Schema): schema is typeof Entity;
//# sourceMappingURL=Entity.d.ts.map

@@ -1,2 +0,2 @@

import Entity from './Entity';
import Entity from "./Entity";
/** Represents data with primary key being from 'id' field. */

@@ -3,0 +3,0 @@ export default class IDEntity extends Entity {

@@ -1,12 +0,10 @@

import { denormalize } from './denormalize';
import { normalize } from './normalize';
import WeakListMap from './WeakListMap';
import * as schema from './schema';
import Entity, { isEntity } from './entities/Entity';
import SimpleRecord from './entities/SimpleRecord';
export { default as FlatEntity } from './entities/FlatEntity';
export { default as inferResults } from './inferResults';
export { DELETED } from './special';
export type { AbstractInstanceType, Schema, Normalize, NormalizeNullable, NormalizedIndex, NormalizeReturnType, NormalizedSchema, Denormalize, DenormalizeNullable, DenormalizeReturnType, DenormalizeCache, } from './types';
export { denormalize, schema, normalize, SimpleRecord, Entity, isEntity, WeakListMap, };
import { denormalize } from "./denormalize";
import { normalize } from "./normalize";
import WeakListMap from "./WeakListMap";
import * as schema from "./schema";
import Entity, { isEntity } from "./entities/Entity";
export { default as inferResults } from "./inferResults";
export { DELETED } from "./special";
export { AbstractInstanceType, Schema, Normalize, NormalizeNullable, NormalizedIndex, NormalizeReturnType, NormalizedSchema, Denormalize, DenormalizeNullable, DenormalizeReturnType, DenormalizeCache, } from "./types";
export { denormalize, schema, normalize, Entity, isEntity, WeakListMap };
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import { NormalizedIndex, NormalizeNullable, Schema } from './types';
import { NormalizedIndex, NormalizeNullable, Schema } from "./types";
/**

@@ -3,0 +3,0 @@ * Build the result parameter to denormalize from schema alone.

@@ -1,2 +0,2 @@

import type { NormalizeNullable, NormalizedSchema, Schema, NormalizedIndex } from './types';
import type { NormalizeNullable, NormalizedSchema, Schema, NormalizedIndex } from "./types";
export declare const normalize: <S extends Schema = Schema, E extends Record<string, Record<string, any> | undefined> = Record<string, Record<string, any>>, R = NormalizeNullable<S>>(input: any, schema?: S | undefined, existingEntities?: Readonly<E>, existingIndexes?: Readonly<NormalizedIndex>, existingEntityMeta?: {

@@ -3,0 +3,0 @@ readonly [entityKey: string]: {

@@ -105,7 +105,7 @@ import { normalize as arrayNormalize } from './schemas/Array';

else if ( // eslint-disable-next-line no-undef
process.env.NODE_ENV !== 'production') {
console.warn(`Index not found in entity. Indexes must be top-level members of your entity.
process.env.NODE_ENV !== 'production') {
console.warn(`Index not found in entity. Indexes must be top-level members of your entity.
Index: ${index}
Entity: ${JSON.stringify(entity, undefined, 2)}`);
}
}
}

@@ -185,2 +185,2 @@ } // set this after index updates so we know what indexes to remove from

};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9ub3JtYWxpemUudHMiXSwibmFtZXMiOlsibm9ybWFsaXplIiwiYXJyYXlOb3JtYWxpemUiLCJvYmplY3ROb3JtYWxpemUiLCJERUxFVEVEIiwidmlzaXQiLCJ2YWx1ZSIsInBhcmVudCIsImtleSIsInNjaGVtYSIsImFkZEVudGl0eSIsInZpc2l0ZWRFbnRpdGllcyIsIm1ldGhvZCIsIkFycmF5IiwiaXNBcnJheSIsImFkZEVudGl0aWVzIiwiZW50aXRpZXMiLCJpbmRleGVzIiwiZXhpc3RpbmdFbnRpdGllcyIsImV4aXN0aW5nSW5kZXhlcyIsImVudGl0eU1ldGEiLCJtZXRhIiwicHJvY2Vzc2VkRW50aXR5IiwiaWQiLCJzY2hlbWFLZXkiLCJleGlzdGluZ0VudGl0eSIsIm1lcmdlIiwiZW50aXR5RXhwaXJlc0F0IiwiZXhwaXJlc0F0IiwiaW5TdG9yZUVudGl0eSIsInByZWZlckV4aXN0aW5nIiwiZGF0ZSIsImVudGl0eSIsImluZGV4IiwiaW5kZXhNYXAiLCJwcm9jZXNzIiwiZW52IiwiTk9ERV9FTlYiL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lwZW9mIGlucHV0XG4gICAgICAgIH1cIi5gLFxuICAgICAgKTtcbiAgICB9XG4gIH1cblxuICBjb25zdCBuZXdFbnRpdGllczogRSA9IHt9IGFzIGFueTtcbiAgY29uc3QgbmV3SW5kZXhlczogTm9ybWFsaXplZEluZGV4ID0ge30gYXMgYW55O1xuICBjb25zdCBlbnRpdGllczogRSA9IHsgLi4uZXhpc3RpbmdFbnRpdGllcyB9IGFzIGFueTtcbiAgY29uc3QgaW5kZXhlczogTm9ybWFsaXplZEluZGV4ID0geyAuLi5leGlzdGluZ0luZGV4ZXMgfTtcbiAgY29uc3QgZW50aXR5TWV0YTogYW55ID0geyAuLi5leGlzdGluZ0VudGl0eU1ldGEgfTtcbiAgY29uc3QgYWRkRW50aXR5ID0gYWRkRW50aXRpZXMoXG4gICAgbmV3RW50aXRpZXMsXG4gICAgbmV3SW5kZXhlcyxcbiAgICBlbnRpdGllcyxcbiAgICBpbmRleGVzLFxuICAgIGVudGl0eU1ldGEsXG4gICAgbWV0YSxcbiAgKTtcbiAgY29uc3QgdmlzaXRlZEVudGl0aWVzID0ge307XG5cbiAgY29uc3QgcmVzdWx0ID0gdmlzaXQoXG4gICAgaW5wdXQsXG4gICAgaW5wdXQsXG4gICAgdW5kZWZpbmVkLFxuICAgIHNjaGVtYSxcbiAgICBhZGRFbnRpdHksXG4gICAgdmlzaXRlZEVudGl0aWVzLFxuICApO1xuICByZXR1cm4geyBlbnRpdGllcywgaW5kZXhlcywgcmVzdWx0LCBlbnRpdHlNZXRhIH07XG59O1xuIl19
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9ub3JtYWxpemUudHMiXSwibmFtZXMiOlsibm9ybWFsaXplIiwiYXJyYXlOb3JtYWxpemUiLCJvYmplY3ROb3JtYWxpemUiLCJERUxFVEVEIiwidmlzaXQiLCJ2YWx1ZSIsInBhcmVudCIsImtleSIsInNjaGVtYSIsImFkZEVudG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ghKGluZGV4IGluIGluZGV4ZXNbc2NoZW1hS2V5XSkpIHtcbiAgICAgICAgICBleGlzdGluZ0luZGV4ZXNbc2NoZW1hS2V5XVtpbmRleF0gPSBpbmRleGVzW3NjaGVtYUtleV1baW5kZXhdID0ge307XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgaW5kZXhNYXAgPSBpbmRleGVzW3NjaGVtYUtleV1baW5kZXhdO1xuICAgICAgICBpZiAoZXhpc3RpbmdFbnRpdHkpIHtcbiAgICAgICAgICBkZWxldGUgaW5kZXhNYXBbZXhpc3RpbmdFbnRpdHlbaW5kZXhdXTtcbiAgICAgICAgfVxuICAgICAgICAvLyBlbnRpdHkgYWxyZWFkeSBpbiBjYWNoZSBidXQgdGhlIGluZGV4IGNoYW5nZWRcbiAgICAgICAgaWYgKFxuICAgICAgICAgIGV4aXN0aW5nRW50aXRpZXNbc2NoZW1hS2V5XSAmJlxuICAgICAgICAgIGV4aXN0aW5nRW50aXRpZXNbc2NoZW1hS2V5XVtpZF0gJiZcbiAgICAgICAgICBleGlzdGluZ0VudGl0aWVzW3NjaGVtYUtleV1baWRdW2luZGV4XSAhPT0gZW50aXR5W2luZGV4XVxuICAgICAgICApIHtcbiAgICAgICAgICBpbmRleE1hcFtleGlzdGluZ0VudGl0aWVzW3NjaGVtYUtleV1baWRdW2luZGV4XV0gPSBERUxFVEVEO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpbmRleCBpbiBlbnRpdHkpIHtcbiAgICAgICAgICBpbmRleE1hcFtlbnRpdHlbaW5kZXhdXSA9IGlkO1xuICAgICAgICB9IC8qIGlzdGFuYnVsIGlnbm9yZSBuZXh0ICovIGVsc2UgaWYgKFxuICAgICAgICAgIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBuby11bmRlZlxuICAgICAgICAgIHByb2Nlc3MuZW52Lk5PREVfRU5WICE9PSAncHJvZHVjdGlvbidcbiAgICAgICAgKSB7XG4gICAgICAgICAgY29uc29sZS53YXJuKGB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wdXQsXG4gICAgaW5wdXQsXG4gICAgdW5kZWZpbmVkLFxuICAgIHNjaGVtYSxcbiAgICBhZGRFbnRpdHksXG4gICAgdmlzaXRlZEVudGl0aWVzLFxuICApO1xuICByZXR1cm4geyBlbnRpdGllcywgaW5kZXhlcywgcmVzdWx0LCBlbnRpdHlNZXRhIH07XG59O1xuIl19

@@ -57,3 +57,3 @@ import {

unvisit: UnvisitFunction,
): [T, boolean, boolean];
): [denormalized: T, found: boolean, suspend: boolean];
infer(

@@ -101,3 +101,3 @@ args: any[],

unvisit: UnvisitFunction,
): [Denormalize<S>[], boolean, boolean];
): [denormalized: Denormalize<S>[], found: boolean, suspend: boolean];

@@ -134,3 +134,3 @@ _denormalizeNullable(): [Denormalize<S>[] | undefined, false, boolean];

unvisit: UnvisitFunction,
): [DenormalizeObject<O>, boolean, boolean];
): [denormalized: DenormalizeObject<O>, found: boolean, suspend: boolean];

@@ -173,3 +173,7 @@ _denormalizeNullable(): [DenormalizeNullableObject<O>, false, boolean];

unvisit: UnvisitFunction,
): [AbstractInstanceType<Choices[keyof Choices]>, boolean, boolean];
): [
denormalized: AbstractInstanceType<Choices[keyof Choices]>,
found: boolean,
suspend: boolean,
];

@@ -234,8 +238,8 @@ _denormalizeNullable(): [

): [
Record<
denormalized: Record<
string,
Choices extends EntityMap<infer T> ? T : Denormalize<Choices>
>,
boolean,
boolean,
found: boolean,
suspend: boolean,
];

@@ -242,0 +246,0 @@

@@ -1,5 +0,9 @@

import { SchemaClass, UnvisitFunction, EntityInterface } from '../schema';
import type { AbstractInstanceType } from '..';
import { SchemaClass, UnvisitFunction, EntityInterface } from "../schema";
import type { AbstractInstanceType } from "../types";
/**
* Marks entity as deleted.
* @see https://resthooks.io/docs/api/Delete
*/
export default class Delete<E extends EntityInterface & {
fromJS: any;
process: any;
}> implements SchemaClass {

@@ -11,3 +15,3 @@ private _entity;

infer(args: any, indexes: any, recurse: any): any;
denormalize(id: string, unvisit: UnvisitFunction): [AbstractInstanceType<E>, boolean, boolean];
denormalize(id: string, unvisit: UnvisitFunction): [denormalized: AbstractInstanceType<E>, found: boolean, suspend: boolean];
_denormalizeNullable(): [

@@ -14,0 +18,0 @@ AbstractInstanceType<E> | undefined,

@@ -14,4 +14,3 @@ /**

export function isImmutable(object) {
return !!(object && typeof object.hasOwnProperty === 'function' && (Object.hasOwnProperty.call(object, '__ownerID') || // Immutable.Map
object._map && Object.hasOwnProperty.call(object._map, '__ownerID'))); // Immutable.Record
return !!(object && typeof object.hasOwnProperty === 'function' && (Object.hasOwnProperty.call(object, '__ownerID') || object._map && Object.hasOwnProperty.call(object._map, '__ownerID'))); // Immutable.Record
}

@@ -52,2 +51,2 @@ /**

}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zY2hlbWFzL0ltbXV0YWJsZVV0aWxzLmpzIl0sIm5hbWVzIjpbImlzSW1tdXRhYmxlIiwib2JqZWN0IiwiaGFzT3duUHJvcGVydHkiLCJPYmplY3QiLCJjYWxsIiwiX21hcCIsImRlbm9ybWFsaXplSW1tdXRhYmxlIiwic2NoZW1hIiwiaW5wdXQiLCJ1bnZpc2l0IiwiZm91bmQiLCJkZWxldGVkIiwia2V5cyIsInJlZHVjZSIsImtleSIsInN0cmluZ0tleSIsIml0ZW0iLCJmb3VuZEl0ZW0iLCJkZWxldGVkSXRlbSIsImdldCIsImhhcyIsInNldCJdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSxPQUFPLFNBQVNBLFdBQVQsQ0FBcUJDLE1BQXJCLEVBQTZCO0FBQ2xDLFNBQU8sQ0FBQyxFQUNOQSxNQUFNLElBQ04sT0FBT0EsTUFBTSxDQUFDQyxjQUFkLEtBQWlDLFVBRGpDLEtBRUNDLE1BQU0sQ0FBQ0QsY0FBUCxDQUF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@

import type { default as schema, EntityInterface } from './schema';
import WeakListMap from './WeakListMap';
import type { default as schema, EntityInterface } from "./schema";
import WeakListMap from "./WeakListMap";
export declare type AbstractInstanceType<T> = T extends {

@@ -4,0 +4,0 @@ prototype: infer U;

{
"name": "@rest-hooks/normalizr",
"version": "7.5.0",
"version": "7.5.1",
"description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications",

@@ -89,3 +89,3 @@ "homepage": "https://github.com/coinbase/rest-hooks/tree/master/packages/normalizr#readme",

},
"gitHead": "3381921609330c7fcd311e4543f3e1e45b40bf69"
"gitHead": "0a735a3a198039145cfd5244319c0e228610100b"
}

@@ -1,3 +0,3 @@

import { Denormalize, DenormalizeNullable, Schema, DenormalizeCache } from './types';
import WeakListMap from './WeakListMap';
import { Denormalize, DenormalizeNullable, Schema, DenormalizeCache } from "./types";
import WeakListMap from "./WeakListMap";
declare type DenormalizeReturn<S extends Schema> = [

@@ -4,0 +4,0 @@ /*denormalized*/ Denormalize<S>,

@@ -1,8 +0,9 @@

import SimpleRecord from './SimpleRecord';
import * as schema from '../schema';
import { AbstractInstanceType, Schema } from '../types';
/** Represents data that should be deduped by specifying a primary key. */
export default abstract class Entity extends SimpleRecord {
import * as schema from "../schema";
import { AbstractInstanceType, Schema, NormalizedIndex } from "../types";
/**
* Represents data that should be deduped by specifying a primary key.
* @see https://resthooks.io/docs/api/Entity
*/
export default abstract class Entity {
static toJSON(): {
key: string;
name: string;

@@ -12,3 +13,8 @@ schema: {

};
key: string;
};
/** Defines nested entities */
static schema: {
[k: string]: Schema;
};
/**

@@ -42,4 +48,16 @@ * A unique identifier for each Entity

static pk<T extends typeof Entity>(this: T, value: Partial<AbstractInstanceType<T>>, parent?: any, key?: string): string | undefined;
/** Creates new instance copying over defined values of arguments */
static merge<T extends typeof Entity>(this: T, existing: Partial<AbstractInstanceType<T>>, incoming: Partial<AbstractInstanceType<T>>): Partial<AbstractInstanceType<T>>;
/** Factory method to convert from Plain JS Objects.
*
* @param [props] Plain Object of properties to assign.
* @param [parent] When normalizing, the object which included the record
* @param [key] When normalizing, the key where this record was found
*/
static fromJS<T extends typeof Entity>(this: T, props?: Partial<AbstractInstanceType<T>>): AbstractInstanceType<T>;
/** Do any transformations when first receiving input */
static process(input: any, parent: any, key: string | undefined): any;
static normalize(input: any, parent: any, key: string | undefined, visit: (...args: any) => any, addEntity: (...args: any) => any, visitedEntities: Record<string, any>): any;
protected static validate(processedEntity: Entity, input: any): void;
protected static validate(processedEntity: any): string | undefined;
static infer(args: any[], indexes: NormalizedIndex, recurse: any): any;
static expiresAt(meta: {

@@ -49,10 +67,14 @@ expiresAt: number;

}, input: any): number;
static infer(args: any, indexes: any, infer: any): any;
static denormalize<T extends typeof SimpleRecord>(this: T, input: Readonly<Partial<AbstractInstanceType<T>>>, unvisit: schema.UnvisitFunction): [
AbstractInstanceType<T>,
boolean,
boolean
static denormalize<T extends typeof Entity>(this: T, input: Readonly<Partial<AbstractInstanceType<T>>>, unvisit: schema.UnvisitFunction): [
/*denormalized*/ AbstractInstanceType<T>,
/*found*/ boolean,
/*suspend*/ boolean
];
private static __defaults;
/*All instance defaults set */
protected static readonly defaults: any;
/** Used by denormalize to set nested members */
protected static set(entity: any, key: string, value: any): void;
}
export declare function isEntity(schema: Schema): schema is typeof Entity;
//# sourceMappingURL=Entity.d.ts.map

@@ -1,2 +0,2 @@

import Entity from './Entity';
import Entity from "./Entity";
/** Represents data with primary key being from 'id' field. */

@@ -3,0 +3,0 @@ export default class IDEntity extends Entity {

@@ -1,12 +0,10 @@

import { denormalize } from './denormalize';
import { normalize } from './normalize';
import WeakListMap from './WeakListMap';
import * as schema from './schema';
import Entity, { isEntity } from './entities/Entity';
import SimpleRecord from './entities/SimpleRecord';
export { default as FlatEntity } from './entities/FlatEntity';
export { default as inferResults } from './inferResults';
export { DELETED } from './special';
export { AbstractInstanceType, Schema, Normalize, NormalizeNullable, NormalizedIndex, NormalizeReturnType, NormalizedSchema, Denormalize, DenormalizeNullable, DenormalizeReturnType, DenormalizeCache, } from './types';
export { denormalize, schema, normalize, SimpleRecord, Entity, isEntity, WeakListMap, };
import { denormalize } from "./denormalize";
import { normalize } from "./normalize";
import WeakListMap from "./WeakListMap";
import * as schema from "./schema";
import Entity, { isEntity } from "./entities/Entity";
export { default as inferResults } from "./inferResults";
export { DELETED } from "./special";
export { AbstractInstanceType, Schema, Normalize, NormalizeNullable, NormalizedIndex, NormalizeReturnType, NormalizedSchema, Denormalize, DenormalizeNullable, DenormalizeReturnType, DenormalizeCache, } from "./types";
export { denormalize, schema, normalize, Entity, isEntity, WeakListMap };
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import { NormalizedIndex, NormalizeNullable, Schema } from './types';
import { NormalizedIndex, NormalizeNullable, Schema } from "./types";
/**

@@ -3,0 +3,0 @@ * Build the result parameter to denormalize from schema alone.

@@ -1,2 +0,2 @@

import { NormalizeNullable, NormalizedSchema, Schema, NormalizedIndex } from './types';
import { NormalizeNullable, NormalizedSchema, Schema, NormalizedIndex } from "./types";
export declare const normalize: <S extends Schema = Schema, E extends Record<string, Record<string, any> | undefined> = Record<string, Record<string, any>>, R = NormalizeNullable<S>>(input: any, schema?: S | undefined, existingEntities?: Readonly<E>, existingIndexes?: Readonly<NormalizedIndex>, existingEntityMeta?: {

@@ -3,0 +3,0 @@ readonly [entityKey: string]: {

@@ -25,5 +25,5 @@ import { Schema, AbstractInstanceType, Normalize, NormalizeNullable, Denormalize, DenormalizeNullable, DenormalizeObject, DenormalizeNullableObject, NormalizeObject, NormalizedNullableObject, UnvisitFunction, EntityMap, NormalizedIndex, } from './types';

input: {} | undefined, unvisit: UnvisitFunction): [
T,
boolean,
boolean
/*denormalized*/ T,
/*found*/ boolean,
/*suspend*/ boolean
];

@@ -58,5 +58,5 @@ infer(args: any[], indexes: NormalizedIndex, recurse: (...args: any) => any): any;

input: {} | undefined, unvisit: UnvisitFunction): [
Denormalize<S>[],
boolean,
boolean
/*denormalized*/ Denormalize<S>[],
/*found*/ boolean,
/*suspend*/ boolean
];

@@ -79,5 +79,5 @@ _denormalizeNullable(): [

input: {} | undefined, unvisit: UnvisitFunction): [
DenormalizeObject<O>,
boolean,
boolean
/*denormalized*/ DenormalizeObject<O>,
/*found*/ boolean,
/*suspend*/ boolean
];

@@ -102,5 +102,5 @@ _denormalizeNullable(): [

input: {} | undefined, unvisit: UnvisitFunction): [
AbstractInstanceType<Choices[keyof Choices]>,
boolean,
boolean
/*denormalized*/ AbstractInstanceType<Choices[keyof Choices]>,
/*found*/ boolean,
/*suspend*/ boolean
];

@@ -126,5 +126,5 @@ _denormalizeNullable(): [

input: {} | undefined, unvisit: UnvisitFunction): [
Record<string, Choices extends EntityMap<infer T> ? T : Denormalize<Choices>>,
boolean,
boolean
/*denormalized*/ Record<string, Choices extends EntityMap<infer T> ? T : Denormalize<Choices>>,
/*found*/ boolean,
/*suspend*/ boolean
];

@@ -131,0 +131,0 @@ _denormalizeNullable(): [

@@ -1,5 +0,9 @@

import { SchemaClass, UnvisitFunction, EntityInterface } from '../schema';
import { AbstractInstanceType } from '..';
import { SchemaClass, UnvisitFunction, EntityInterface } from "../schema";
import { AbstractInstanceType } from "../types";
/**
* Marks entity as deleted.
* @see https://resthooks.io/docs/api/Delete
*/
export default class Delete<E extends EntityInterface & {
fromJS: any;
process: any;
}> implements SchemaClass {

@@ -12,5 +16,5 @@ private _entity;

denormalize(id: string, unvisit: UnvisitFunction): [
AbstractInstanceType<E>,
boolean,
boolean
/*denormalized*/ AbstractInstanceType<E>,
/*found*/ boolean,
/*suspend*/ boolean
];

@@ -17,0 +21,0 @@ _denormalizeNullable(): [

@@ -1,3 +0,3 @@

import { default as schema, EntityInterface } from './schema';
import WeakListMap from './WeakListMap';
import { default as schema, EntityInterface } from "./schema";
import WeakListMap from "./WeakListMap";
export declare type AbstractInstanceType<T> = T extends {

@@ -4,0 +4,0 @@ prototype: infer U;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc