@data-client/core 0.18.1 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/dist/index.js +18 -10
  3. package/dist/index.umd.min.js +1 -1
  4. package/dist/mock.js +18 -10
  5. package/legacy/actions.js +1 -1
  6. package/legacy/controller/Controller.js +10 -3
  7. package/legacy/controller/setManyTypes.js +2 -0
  8. package/legacy/manager/DevtoolsManager.js +9 -9
  9. package/legacy/mock/MockController.js +1 -1
  10. package/legacy/mock/fixtureTypes.js +1 -1
  11. package/legacy/mock/mockState.js +1 -1
  12. package/lib/actionTypes.d.ts +11 -11
  13. package/lib/actions.d.ts +1 -1
  14. package/lib/actions.d.ts.map +1 -1
  15. package/lib/actions.js +1 -1
  16. package/lib/controller/Controller.d.ts +13 -4
  17. package/lib/controller/Controller.d.ts.map +1 -1
  18. package/lib/controller/Controller.js +10 -3
  19. package/lib/controller/ensurePojo.d.ts.map +1 -1
  20. package/lib/controller/setManyTypes.d.ts +69 -0
  21. package/lib/controller/setManyTypes.d.ts.map +1 -0
  22. package/lib/controller/setManyTypes.js +2 -0
  23. package/lib/manager/DefaultConnectionListener.d.ts.map +1 -1
  24. package/lib/manager/DevtoolsManager.d.ts.map +1 -1
  25. package/lib/manager/DevtoolsManager.js +9 -9
  26. package/lib/manager/LogoutManager.d.ts.map +1 -1
  27. package/lib/manager/NetworkManager.d.ts.map +1 -1
  28. package/lib/manager/PollingSubscription.d.ts.map +1 -1
  29. package/lib/manager/SubscriptionManager.d.ts.map +1 -1
  30. package/lib/mock/MockController.d.ts +1 -1
  31. package/lib/mock/MockController.d.ts.map +1 -1
  32. package/lib/mock/MockController.js +1 -1
  33. package/lib/mock/fixtureTypes.d.ts +2 -2
  34. package/lib/mock/fixtureTypes.d.ts.map +1 -1
  35. package/lib/mock/fixtureTypes.js +1 -1
  36. package/lib/mock/mockState.js +1 -1
  37. package/lib/state/GCPolicy.d.ts.map +1 -1
  38. package/lib/state/reducer/expireReducer.d.ts +11 -11
  39. package/lib/state/reducer/invalidateReducer.d.ts +14 -14
  40. package/package.json +5 -4
  41. package/src/actions.ts +1 -1
  42. package/src/controller/Controller.ts +25 -5
  43. package/src/controller/__tests__/getResponse.ts +58 -0
  44. package/src/controller/setManyTypes.ts +114 -0
  45. package/src/manager/DevtoolsManager.ts +11 -8
  46. package/src/manager/__tests__/networkManager.ts +8 -1
  47. package/src/mock/MockController.ts +5 -2
  48. package/src/mock/__tests__/MockController.ts +15 -0
  49. package/src/mock/fixtureTypes.ts +3 -4
  50. package/src/mock/mockState.ts +1 -1
  51. package/ts3.4/actionTypes.d.ts +11 -11
  52. package/ts3.4/actions.d.ts +1 -1
  53. package/ts3.4/controller/Controller.d.ts +10 -7
  54. package/ts3.4/controller/setManyTypes.d.ts +75 -0
  55. package/ts3.4/mock/MockController.d.ts +1 -1
  56. package/ts3.4/mock/fixtureTypes.d.ts +2 -2
  57. package/ts3.4/state/reducer/expireReducer.d.ts +11 -11
  58. package/ts3.4/state/reducer/invalidateReducer.d.ts +14 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,142 @@
1
1
  # @data-client/core
2
2
 
3
+ ## 0.18.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4230](https://github.com/reactive/data-client/pull/4230) [`46f1f24`](https://github.com/reactive/data-client/commit/46f1f24bcb04824805747ed2a1effe7baece337c) - Fix `controller.set()` types for a single [Invalidate](https://dataclient.io/rest/api/Invalidate)
8
+
9
+ Deleting one entity with `set()` worked at runtime but failed to typecheck, since `Invalidate` isn't
10
+ [Queryable](https://dataclient.io/rest/api/schema#queryable). Pass the schema and the row to delete; the row is typed
11
+ by the Entity's fields.
12
+
13
+ ```ts
14
+ // Before: TypeScript error
15
+ // After: no error
16
+ ctrl.set(new Invalidate(Post), { id: '5' });
17
+ ```
18
+
19
+ It takes no `args` and no updater function.
20
+
21
+ - [#4133](https://github.com/reactive/data-client/pull/4133) [`a82758c`](https://github.com/reactive/data-client/commit/a82758cd1998e58d7ad280407db28bd84f5d7b18) - Fix `controller.set()` accepting any value
22
+
23
+ Values are now typed by the schema: Entities take their fields, while [Collection](https://dataclient.io/rest/api/Collection)
24
+ and [All](https://dataclient.io/rest/api/All) take a list of rows. [Query](https://dataclient.io/rest/api/Query) takes
25
+ the input of the schema it wraps, not what its `process()` returns. Updater functions must return the same.
26
+
27
+ ```ts
28
+ // Before: these all typechecked, then failed or wrote nothing at runtime
29
+ ctrl.set(new schema.All(Todo), 42);
30
+ ctrl.set(TodoResource.getList.schema, 'anything');
31
+ ctrl.set(Todo, { id: '5' }, { id: '5', completed: 'yes' });
32
+
33
+ // After: TypeScript errors on the above; these typecheck
34
+ ctrl.set(TodoResource.getList.schema, [{ id: '5', completed: true }]);
35
+ ctrl.set(new schema.All(Todo), [{ id: '5', completed: true }]);
36
+ ```
37
+
38
+ When each member declares its discriminator as a literal (like `readonly type = 'post'`), a
39
+ [Union](https://dataclient.io/rest/api/Union) row is checked against the member it selects. Only
40
+ declared fields are accepted, so a key read by a `schemaAttribute` function must be declared on each member.
41
+
42
+ ```ts
43
+ const Feed = new schema.Union({ post: Post, comment: Comment }, 'type');
44
+ // TypeScript error: commentBody is a Comment field, not a Post field
45
+ ctrl.set(
46
+ Feed,
47
+ { id: '1', type: 'post' },
48
+ { type: 'post', commentBody: 'hi' },
49
+ );
50
+ ```
51
+
52
+ - [#4228](https://github.com/reactive/data-client/pull/4228) [`b55696c`](https://github.com/reactive/data-client/commit/b55696c72ad3e73e0a2f50d3751c7104cd4ad9ee) - Fix TypeScript error passing a `Controller` subclass to `DataProvider` or `DataClientPlugin`
53
+
54
+ A plain `class MyController extends Controller` failed to typecheck as the `Controller` option of [DataProvider](https://dataclient.io/docs/api/DataProvider#Controller), Vue's [DataClientPlugin](https://dataclient.io/vue/api/DataClientPlugin#Controller), and the `@data-client/react/redux` `DataProvider`, so the documented example needed a cast. `MockController()` from `@data-client/core/mock` had the same error when wrapping your subclass. These now typecheck, and you can drop the casts.
55
+
56
+ ```tsx
57
+ class MyController extends Controller {
58
+ doSomething = () => console.log('hi');
59
+ }
60
+
61
+ // Before: TypeScript error, so you had to cast
62
+ <DataProvider Controller={MyController as typeof Controller}>
63
+ app.use(DataClientPlugin, { Controller: MyController as typeof Controller });
64
+
65
+ // After
66
+ <DataProvider Controller={MyController}>
67
+ app.use(DataClientPlugin, { Controller: MyController });
68
+ ```
69
+
70
+ - [#4150](https://github.com/reactive/data-client/pull/4150) [`74e67fa`](https://github.com/reactive/data-client/commit/74e67fa2c4f9f104f5b7a49e877a48e5963e4bd2) - Fix `useCache()` and `useDLE()` returning a truthy `Symbol` for deleted entities
71
+
72
+ After an entity was deleted and its refetch failed, `useCache()` and `useDLE()` (React and Vue) returned an internal
73
+ `Symbol` instead of `undefined`. Since a `Symbol` is truthy, "not loaded" checks passed, and code went on to use it as
74
+ the entity:
75
+
76
+ ```tsx
77
+ const todo = useCache(TodoResource.get, { id });
78
+ if (!todo) return <TodoPlaceholder />;
79
+ // Before: reached here with a Symbol; todo.title was undefined and todo.title.trim() threw
80
+ // After: the placeholder renders
81
+ return <TodoItem title={todo.title.trim()} />;
82
+ ```
83
+
84
+ [Controller.getResponse()](https://dataclient.io/docs/api/Controller#getResponse) and
85
+ [Controller.fetchIfStale()](https://dataclient.io/docs/api/Controller#fetchIfStale) now also give `undefined` there,
86
+ like [Controller.get()](https://dataclient.io/docs/api/Controller#get) already did.
87
+
88
+ - [#4163](https://github.com/reactive/data-client/pull/4163) [`159c963`](https://github.com/reactive/data-client/commit/159c9633679d95427fe4f626aec341c76e4578f8) - Fix slow updates in development while Redux DevTools is open
89
+
90
+ With the [Redux DevTools](https://dataclient.io/docs/getting-started/debugging) extension open, every store update
91
+ stalled the page while DevTools serialized the store: about 20ms with 50 entities, and 200ms with 500. Apps doing
92
+ many `controller.set()` calls, polling, or live updates would stutter in development. Each update now serializes
93
+ 40-60x faster, and timestamps still show as readable times like `10:42:07.123 AM`.
94
+
95
+ - [#4227](https://github.com/reactive/data-client/pull/4227) [`47502c6`](https://github.com/reactive/data-client/commit/47502c664df913297fba3e5011a975dfd01c0d8d) - Type FETCH `action.meta.promise` as `Promise`
96
+
97
+ Managers can now call `.finally()` and `.catch()` on a FETCH action's `meta.promise` without a TypeScript error. It was always a real `Promise` at runtime, but was typed `PromiseLike`, which only has `.then()`.
98
+
99
+ ```ts
100
+ // Before: TypeScript error on .finally(), so both callbacks went to .then()
101
+ const track = () =>
102
+ trackTiming(action.endpoint.name, performance.now() - start);
103
+ action.meta.promise.then(track, track);
104
+
105
+ // After
106
+ action.meta.promise
107
+ .finally(() => {
108
+ trackTiming(action.endpoint.name, performance.now() - start);
109
+ })
110
+ // the fetch's caller handles errors; this only observes timing
111
+ .catch(() => {});
112
+ ```
113
+
114
+ - [#4250](https://github.com/reactive/data-client/pull/4250) [`fc4b015`](https://github.com/reactive/data-client/commit/fc4b015ca0899a2685af881d17f765dce27ffc1a) - Fixture `args` accept readonly tuples
115
+
116
+ Fixtures written with `args: [...] as const` now type-check when passed to [MockResolver](https://dataclient.io/docs/api/MockResolver), `renderDataHook()`, Vue's `renderDataCompose()` or `mockInitialState()`. Before, TypeScript rejected them with "The type 'readonly [...]' is 'readonly' and cannot be assigned to the mutable type", so you had to drop `as const` or cast.
117
+
118
+ ```ts
119
+ const fixtures = [
120
+ {
121
+ endpoint: TodoResource.getList,
122
+ args: [{ userId: 1 }] as const,
123
+ response: [{ id: 1, title: 'Write tests', userId: 1 }],
124
+ },
125
+ ];
126
+
127
+ // Before: type error on `fixtures`. After: works as written
128
+ <MockResolver fixtures={fixtures}>
129
+ <TodoList />
130
+ </MockResolver>;
131
+ ```
132
+
133
+ - [#4019](https://github.com/reactive/data-client/pull/4019) [`aa15f29`](https://github.com/reactive/data-client/commit/aa15f29f6b0a3b4ae655e2d114a419a3fc94ac7e) Thanks [@renovate](https://github.com/apps/renovate)! - Fix TypeScript 7 module resolution for package exports
134
+
135
+ TypeScript 7 requires a `types` condition in `package.json` `exports`. Without it, imports resolved to runtime entrypoints like `node.mjs` and lost declaration files.
136
+
137
+ - Updated dependencies [[`b4b502d`](https://github.com/reactive/data-client/commit/b4b502d545aab0cf75bf030f3de4607a2e3ab7dc), [`aa15f29`](https://github.com/reactive/data-client/commit/aa15f29f6b0a3b4ae655e2d114a419a3fc94ac7e)]:
138
+ - @data-client/normalizr@0.18.2
139
+
3
140
  ## 0.18.1
4
141
 
5
142
  ### Patch Changes
package/dist/index.js CHANGED
@@ -776,6 +776,12 @@ class Controller {
776
776
  * @see https://dataclient.io/docs/api/Controller#set
777
777
  */
778
778
 
779
+ /**
780
+ * Sets every row of an Array or Values of one Entity (or Union) in one normalize,
781
+ * or invalidates the one Entity an Invalidate schema's value identifies.
782
+ * @see https://dataclient.io/docs/api/Controller#set
783
+ */
784
+
779
785
  set(schema, ...rest) {
780
786
  const value = rest[rest.length - 1];
781
787
  const action = createSet(schema, {
@@ -932,9 +938,11 @@ class Controller {
932
938
  // fallback to entity expiry time
933
939
  else expiresAt = entityExpiresAt(paths, state.entitiesMeta);
934
940
  }
941
+ const invalidData = typeof data === 'symbol';
935
942
  return {
936
- data,
937
- expiryStatus: this.getExpiryStatus(typeof data === 'symbol', !!endpoint.invalidIfStale || isInvalid, meta),
943
+ // INVALID symbol (e.g. deleted entity) is an internal marker; expose it as missing data
944
+ data: invalidData ? undefined : data,
945
+ expiryStatus: this.getExpiryStatus(invalidData, !!endpoint.invalidIfStale || isInvalid, meta),
938
946
  expiresAt,
939
947
  countRef: this.gcPolicy.createCountRef({
940
948
  key,
@@ -1662,7 +1670,12 @@ if (process.env.NODE_ENV !== 'production') {
1662
1670
  });
1663
1671
  return serial;
1664
1672
  }
1665
- const HASINTL = typeof Intl !== 'undefined';
1673
+ const dateFormat = typeof Intl !== 'undefined' ? new Intl.DateTimeFormat('en-US', {
1674
+ hour: 'numeric',
1675
+ minute: 'numeric',
1676
+ second: 'numeric',
1677
+ fractionalSecondDigits: 3
1678
+ }) : undefined;
1666
1679
  DEFAULT_CONFIG = {
1667
1680
  name: `Data Client: ${(_globalThis$document = globalThis.document) == null ? void 0 : _globalThis$document.title}`,
1668
1681
  autoPause: true,
@@ -1697,14 +1710,9 @@ if (process.env.NODE_ENV !== 'production') {
1697
1710
  serialize: {
1698
1711
  options: undefined,
1699
1712
  /* istanbul ignore next */
1700
- replacer: HASINTL ? (key, value) => {
1713
+ replacer: dateFormat ? (key, value) => {
1701
1714
  if (typeof value === 'number' && typeof key === 'string' && isFinite(value) && (key === 'date' || key.endsWith('At'))) {
1702
- return Intl.DateTimeFormat('en-US', {
1703
- hour: 'numeric',
1704
- minute: 'numeric',
1705
- second: 'numeric',
1706
- fractionalSecondDigits: 3
1707
- }).format(value);
1715
+ return dateFormat.format(value);
1708
1716
  }
1709
1717
  return value;
1710
1718
  } : undefined
@@ -1 +1 @@
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).RDC=e.RDC||{},e.RDC.Core={}))}(this,(function(e){"use strict";class t{constructor(e=[]){this.localCache=new Map,this._args=e}getEntity(e,t,n,i){const s=t.key;this.localCache.has(s)||this.localCache.set(s,new Map);const r=this.localCache.get(s);return r.get(e)||i(r),r.get(e)}getResults(e,t,n){return{data:n(),paths:[]}}argsKey(e){return e(this._args)}}const n=Symbol("INVALID"),i={};const s=e=>e[0],r=e=>void 0!==e&&"symbol"!=typeof e,o=(e,t,n,i,r)=>{e=s(e);const o=(e=>Array.isArray(e)?e:Object.keys(e).map((t=>e[t])))(t);return o.map((t=>r.visit(e,t,n,i)))},a=(e,t,n)=>(e=s(e),t.map?t.map((t=>n.unvisit(e,t))).filter(r):t);function c(){}function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},h.apply(null,arguments)}const l=(e,t,n,i,s)=>{const r=h({},t),o=Object.keys(e);for(let n=0;n<o.length;n++){const i=o[n],a=e[i],c=s.visit(a,t[i],t,i);void 0===c?delete r[i]:r[i]=c}return r},u=(e,t,i)=>{if(function(e){return!("function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}(t))return function(e,t,i){let s=!1;const r=Object.keys(e).reduce(((t,n)=>{const r=`${n}`,o=i.unvisit(e[r],t.get(r));return"symbol"==typeof o&&(s=!0),t.has(r)?t.set(r,o):t}),t);return s?n:r}(e,t,i);const s=h({},t);let r=!1;const o=Object.keys(e);for(let t=0;t<o.length;t++){const n=o[t],a=i.unvisit(e[n],s[n]);void 0!==s[n]&&(s[n]=a),"symbol"==typeof a&&(r=!0)}return r?n:s};function d(e,t,n,i){const s={};for(const r of Object.keys(e))s[r]=n(e[r],t,i);return s}const p=(e,t,n)=>function(s,r){const o="object"!=typeof r,a=o?e({key:s.key,pk:r}):r;if("symbol"==typeof a)return s.denormalize(a,n);if(void 0===a&&o&&""!==r&&"undefined"!==r)return t.getEntity(r,s,i,(e=>{e.set(r,void 0)}));if("object"!=typeof a||null===a)return a;let c=o?r:s.pk(a,void 0,void 0,n.args);return void 0===c||""===c||"undefined"===c?function(e){const t=new Map;return e(t),t.get("")}((e=>f(s,a,"",e,n))):("string"!=typeof c&&(c=`${c}`),t.getEntity(c,s,a,(e=>f(s,a,c,e,n))))};function f(e,t,i,s,r){const o=e.createIfValid(t);void 0===o?s.set(i,n):(s.set(i,o),s.set(i,e.denormalize(o,r)))}const y=(e,t,i)=>{let s=0;const r={args:i,unvisit:c,argsKey:e=>t.argsKey(e)},o=p(e,t,r);function c(t,i){if(!t)return i;if(null==i)return i;if("function"==typeof t.denormalize){if(function(e){return null!==e&&void 0!==e.pk}(t)){var c;if(s>=(null!=(c=t.maxEntityDepth)?c:64))return function(e,t,i){var s;const r="object"!=typeof i?e({key:t.key,pk:i}):i;return"object"!=typeof r||null===r?r:null!=(s=t.createIfValid(r))?s:n}(e,t,i);s++;const r=o(t,i);return s--,r}return"function"==typeof t.createIfValid&&"string"==typeof i?o(t,i):t.denormalize(i,r)}if("function"==typeof t)return t(i);if("object"==typeof t){return(Array.isArray(t)?a:u)(t,i,r)}return i}return(e,n)=>{const i=Object(n)===n&&Object(e)===e;return t.getResults(n,i,(()=>c(e,n)))}};class g{constructor({entities:e,indexes:t}){this.entities=e,this.indexes=t}tracked(e){const t=this,i=[{path:[""],entity:e}];return[{INVALID:n,getIndex(...e){const n=t.getIndex(...e);return i.push({path:e,entity:n}),t.getIndexEnd(n,e[2])},getEntity(...e){const n=t.getEntity(...e);return i.push({path:e,entity:n}),n},getEntities(e){const n=t.getEntitiesObject(e);return i.push({path:[e],entity:n}),t.getEntities(e)}},i]}}class v extends g{constructor(e){super(e)}getEntitiesObject(e){return this.entities[e]}getEntities(e){const t=this.entities[e];if(void 0!==t)return{keys:()=>Object.keys(t),entries:()=>Object.entries(t)}}getEntity(e,t){var n;return null==(n=this.entities[e])?void 0:n[t]}getIndex(e,t){var n;return null==(n=this.indexes[e])?void 0:n[t]}getIndexEnd(e,t){return null==e?void 0:e[t]}}const m={QueryDelegate:v,getEntities:e=>({key:t,pk:n})=>{var i;return null==(i=e[t])?void 0:i[n]}};class E{constructor(){this.next=new WeakMap,this.nextPath=void 0,this.hasStr=!1}get(e,t,n=[]){let s=this.next.get(e);if(!s)return x;if(this.hasStr)return this._getMixed(s,t,n);for(;s.nextPath;){var r;const e=null!=(r=t(s.nextPath))?r:i,n=s.next.get(e);if(!n)return x;s=n}return[s.value,s.journey]}_getMixed(e,t,n){for(;e.nextPath;){let a;if("function"==typeof e.nextPath){var s,r;const t=null!=(s=e.nextPath(n))?s:"\0";a=null==(r=e.nextStr)?void 0:r.get(t)}else{var o;const n=null!=(o=t(e.nextPath))?o:i;a=e.next.get(n)}if(!a)return x;e=a}return[e.value,e.journey]}set(e,t,n=[],s){if(e.length<1)throw new k;let r=this;for(const t of e){let e;if("function"==typeof t.path){var o;this.hasStr=!0,r.nextStr||(r.nextStr=new Map);const i=null!=(o=t.path(n))?o:"\0";e=r.nextStr.get(i),e||(e=new w,r.nextStr.set(i,e))}else{var a;if(e=r.next.get(t.entity),!e)e=new w,r.next.set(null!=(a=t.entity)?a:i,e)}r.nextPath=t.path,r=e}r.nextPath=void 0,r.value=t,r.journey=null!=s?s:e.map((e=>e.path))}get hasStringDeps(){return this.hasStr}}const x=[void 0,void 0];class w{constructor(){this.next=new WeakMap,this.nextStr=void 0,this.nextPath=void 0,this.value=void 0,this.journey=[]}}class k extends Error{constructor(...e){super(...e),this.message="Keys must include at least one member"}}class b extends v{constructor(e,t,n){super(e),this.newEntities=new Map,this.newIndexes=new Map,this.entitiesMeta=e.entitiesMeta,this.args=t,this.meta=n,this.checkLoop=function(){const e=new Map;return function(t,n,i){let s=e.get(t);s||(s=new Map,e.set(t,s));let r=s.get(n);return r||(r=new Set,s.set(n,r)),!!r.has(i)||(r.add(i),!1)}}()}getNewEntity(e,t){return this.getNewEntities(e).get(t)}getNewEntities(e){let t=this.newEntities.get(e);return void 0===t&&(t=new Map,this.newEntities.set(e,t)),t}getNewIndexes(e){return this.newIndexes.has(e)||(this.newIndexes.set(e,new Map),this.indexes[e]=h({},this.indexes[e])),this.newIndexes.get(e)}mergeEntity(e,t,n){const i=e.key;let s=n,r=this.meta,o=this.getNewEntity(i,t);if(o)s=e.merge(o,n);else if(o=this.getEntity(i,t),o){const a=this.getMeta(i,t);s=e.mergeWithStore(a,r,o,n),r=e.mergeMetaWithStore(a,r,o,n)}this.setEntity(e,t,s,r)}setEntity(e,t,i,s=this.meta){const r=e.key,o=this.getNewEntities(r),a=!o.has(t);a&&0===o.size&&(this.entities[r]=h({},this.entities[r]),this.entitiesMeta[r]=h({},this.entitiesMeta[r])),o.set(t,i),e.indexes&&function(e,t,i,s,r,o){for(const a of t){i.has(a)||i.set(a,s[a]={});const t=i.get(a);o[e]&&delete t[o[e][a]],o&&o[e]&&o[e][a]!==r[a]&&(t[o[e][a]]=n),a in r&&(t[r[a]]=e)}}(t,e.indexes,this.getNewIndexes(r),this.indexes[r],i,this.entities[r]),this._setEntity(r,t,i),a&&this._setMeta(r,t,s)}invalidate({key:e},t){this.setEntity({key:e},t,n)}_setEntity(e,t,n){this.entities[e][t]=n}_setMeta(e,t,n){this.entitiesMeta[e][t]=n}getMeta(e,t){return this.entitiesMeta[e][t]}}const I=(e,t,n=[],{entities:i,indexes:s,entitiesMeta:r}=A,a={fetchedAt:0,date:Date.now(),expiresAt:1/0})=>{if(null==e)return{result:t,entities:i,indexes:s,entitiesMeta:r};const c=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(e);if(null===t||typeof t!==c&&(void 0===e.key||void 0!==e.pk||"string"!=typeof t))throw new Error(`Unexpected input given to normalize. Expected type to be "${c}", found "${null===t?"null":typeof t}".`);const u={entities:h({},i),indexes:h({},s),entitiesMeta:h({},r)},d=(e=>{let t;const n=(n,i,s,r)=>{if(null==i||!n)return i;if("object"!=typeof i){if("function"!=typeof n.normalize)return i;if(!n.acceptsPrimitives)return i&&n.pk?`${i}`:i}if("function"==typeof n.normalize){const o=t;n.pk&&(t=n);const a=n.normalize(i,s,r,e,o);return t=o,a}return"object"!=typeof n?i:(Array.isArray(n)?o:l)(n,i,s,r,e)};return e.visit=n,n})(new b(u,n,a));return{result:d(e,t,t,void 0),entities:u.entities,indexes:u.indexes,entitiesMeta:u.entitiesMeta}};const A={entities:{},indexes:{},entitiesMeta:{}},S={path:{key:"",pk:""},entity:void 0};class L{constructor(e,t,n,i=[]){this.dependencies=[S],this.cycleCache=new Map,this.cycleIndex=-1,this.localCache=new Map,this._hasArgsKey=!1,this._getEntity=e,this._getCache=t,this._resultCache=n,this._args=i}argsKey(e){return this._hasArgsKey=!0,this.dependencies.push({path:e,entity:void 0}),e(this._args)}getEntity(e,t,n,i){const s=t.key,r=this.getOrCreateLocalCache(s);if(r.get(e)){const t=this.cycleCache.get(s);null!=t&&t.has(e)?this.cycleIndex=t.get(e):this.dependencies.push({path:{key:s,pk:e},entity:n})}else{const o=this._getCache(e,t),[a,c]=o.get(n,this._getEntity,this._args);if(c){r.set(e,a.value);const t=a.dependencies;for(let e=0;e<t.length;e++)this.dependencies.push(t[e]);return o.hasStringDeps&&(this._hasArgsKey=!0),a.value}{const t=this.dependencies.length,a=this.getOrCreateCycleCache(s);a.set(e,t),this.dependencies.push({path:{key:s,pk:e},entity:n}),i(r),a.delete(e);const c=this.dependencies.slice(-1===this.cycleIndex?t:this.cycleIndex),h={dependencies:c,value:r.get(e)};o.set(c,h,this._args),this.cycleIndex===t&&(this.cycleIndex=-1)}}return r.get(e)}getOrCreateLocalCache(e){let t=this.localCache.get(e);return t||(t=new Map,this.localCache.set(e,t)),t}getOrCreateCycleCache(e){let t=this.cycleCache.get(e);return t||(t=new Map,this.cycleCache.set(e,t)),t}getResults(e,t,n){if(!t)return{data:n(),paths:this.paths()};let[i,s]=this._resultCache.get(e,this._getEntity,this._args);return void 0===s&&(i=n(),s=this.paths(),this.dependencies[0]={path:{key:"",pk:""},entity:e},this._resultCache.set(this.dependencies,i,this._args,s)),{data:i,paths:s}}paths(){const e=this.dependencies;if(!this._hasArgsKey){const t=new Array(e.length-1);for(let n=1;n<e.length;n++)t[n-1]=e[n].path;return t}const t=[];for(let n=1;n<e.length;n++){const i=e[n].path;"function"!=typeof i&&t.push(i)}return t}}function M(e){return void 0!==e&&(!(e&&"object"==typeof e&&!Array.isArray(e))||Object.values(e).every(M))}class _{constructor(e=m){var t;this.endpoints=new E,this.queryKeys=new Map,this.policy=e,this._getCache=(t=new Map,(e,n)=>{var i;const s=n.key,r=null!=(i=n.cacheWith)?i:n;t.has(s)||t.set(s,new Map);const o=t.get(s);o.has(e)||o.set(e,new WeakMap);const a=o.get(e);let c=a.get(r);return c||(c=new E,a.set(r,c)),c})}denormalize(e,t,n,i=[]){if(void 0===e)return{data:t,paths:[]};if(void 0===t)return{data:void 0,paths:[]};const s=this.policy.getEntities(n);return y(s,new L(s,this._getCache,this.endpoints,i),i)(e,t)}query(e,t,n,i=JSON.stringify(t)){const s=this.buildQueryKey(e,t,n,i);return s?this.denormalize(e,s,n.entities,t):{data:void 0,paths:[]}}buildQueryKey(e,t,n,i=JSON.stringify(t)){if("object"!=typeof e&&"function"!=typeof e.queryKey||!e)return e;let s=this.queryKeys.get(i);s||(s=new E,this.queryKeys.set(i,s));const r=new this.policy.QueryDelegate(n);let[o,a]=s.get(e,(h=r,e=>{switch(e.length){case 1:return h.getEntitiesObject(e[0]);case 2:return h.getEntity(e[0],e[1]);case 3:return h.getIndex(e[0],e[1],e[2])}}));var h;if(!a){const[n,i]=r.tracked(e);o=function(e){return function t(n,i){if(function(e){return!!e&&"function"==typeof e.queryKey}(n)){if(1===i.length&&null===i[0])return;return n.queryKey(i,t,e)}return"object"==typeof n&&n?(Array.isArray(n)?c:d)(n,i,t,e):n}}(n)(e,t),s.set(i,o)}return o}}var C={Invalid:1,InvalidIfStale:2,Valid:3};function O(e,t){const n=Date.now();return{fetchedAt:null!=t?t:n,date:n,expiresAt:n+e}}const R="rdc/fetch",P="rdc/set",j="rdc/setresponse",T="rdc/optimistic",q="rdc/reset",D="rdc/subscribe",N="rdc/unsubscribe",K="rdc/invalidate",z="rdc/invalidateall",Q="rdc/expireall",H="rdc/gc",V=R,F=P,B=j,U=T,Y=q,$=D,W=N,X=K,G=z,J=Q,Z=H;var ee=Object.freeze({__proto__:null,EXPIREALL:Q,EXPIREALL_TYPE:J,FETCH:R,FETCH_TYPE:V,GC:H,GC_TYPE:Z,INVALIDATE:K,INVALIDATEALL:z,INVALIDATEALL_TYPE:G,INVALIDATE_TYPE:X,OPTIMISTIC:T,OPTIMISTIC_TYPE:U,RESET:q,RESET_TYPE:Y,SET:P,SET_RESPONSE:j,SET_RESPONSE_TYPE:B,SET_TYPE:F,SUBSCRIBE:D,SUBSCRIBE_TYPE:$,UNSUBSCRIBE:N,UNSUBSCRIBE_TYPE:W});const te="undefined"!=typeof FormData?e=>e instanceof FormData?Object.fromEntries(e.entries()):e:e=>e;function ne(e,t,n){var i;return{type:T,key:e.key(...t),args:t.map(te),endpoint:e,meta:O(null!=(i=e.dataExpiryLength)?i:6e4,n)}}class ie extends Error{}function se(e,t,n){return"AbortError"===n.name?h({},e,{optimistic:re(e,t)}):h({},e,{meta:h({},e.meta,{[t.key]:{date:t.meta.date,fetchedAt:t.meta.fetchedAt,expiresAt:t.meta.expiresAt,error:n,errorPolicy:null==t.endpoint.errorPolicy?void 0:t.endpoint.errorPolicy(n)}}),optimistic:re(e,t)})}function re(e,t){return e.optimistic.filter((e=>e.key!==t.key||(e.type===T?e.meta.fetchedAt!==t.meta.fetchedAt:e.meta.date>t.meta.date)))}const oe={entities:{},endpoints:{},indexes:{},meta:{},entitiesMeta:{},optimistic:[],lastReset:0};var ae=Object.freeze({__proto__:null,INVALID:n,MemoCache:_,initialState:oe});function ce(e,{args:t}){return{type:D,key:e.key(...t),args:t,endpoint:e}}function he(e,{args:t}){return{type:N,key:e.key(...t),args:t,endpoint:e}}function le(e,{args:t,fetchedAt:n,response:i,error:s=!1}){var r,o;const a=s?null!=(r=e.errorExpiryLength)?r:1e3:null!=(o=e.dataExpiryLength)?o:6e4;return{type:j,key:e.key(...t),response:i,args:t.map(te),endpoint:e,meta:O(a,n),error:s}}function ue(e,{args:t,fetchedAt:n,value:i}){return{type:P,value:i,args:t.map(te),schema:e,meta:O(6e4,n)}}function de(){return{type:q,date:Date.now()}}function pe(e){return{type:z,testKey:e}}function fe(e,{args:t}){return{type:K,key:e.key(...t)}}function ye(e,{args:t}){let n=0,i=0;const s=new Promise(((e,t)=>{[n,i]=[e,t]})),r={fetchedAt:Date.now(),resolve:n,reject:i,promise:s};return{type:R,key:e.key(...t),args:t,endpoint:e,meta:r}}function ge(e){return{type:Q,testKey:e}}var ve=Object.freeze({__proto__:null,createExpireAll:ge,createFetch:ye,createInvalidate:fe,createInvalidateAll:pe,createMeta:O,createOptimistic:ne,createReset:de,createSet:ue,createSetResponse:le,createSubscription:ce,createUnsubscription:he});class me{init(){}cleanup(){}createCountRef(){return()=>()=>{}}}function Ee(e,t){return e.meta[t]}const xe=e=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},we=()=>oe;class ke{constructor({dispatch:e=xe,getState:n=we,memo:i=new _,gcPolicy:s=new me}={}){this.fetch=(e,...n)=>{const i=ye(e,{args:n});return this.dispatch(i),e.schema?i.meta.promise.then((i=>function(e,n,i,s=[]){return void 0===e||void 0===n?n:y(m.getEntities(i),new t(s),s)(e,n).data}(e.schema,i,{},n))):i.meta.promise},this.fetchIfStale=(e,...t)=>{const{data:n,expiresAt:i,expiryStatus:s}=this.getResponseMeta(e,...t,this.getState());return s!==C.Invalid&&Date.now()<=i?n:this.fetch(e,...t)},this.invalidate=(e,...t)=>null!==t[0]?this.dispatch(fe(e,{args:t})):Promise.resolve(),this.invalidateAll=e=>this.dispatch(pe((t=>e.testKey(t)))),this.expireAll=e=>this.dispatch(ge((t=>e.testKey(t)))),this.resetEntireStore=()=>this.dispatch(de()),this.setResponse=(e,...t)=>{const n=t[t.length-1],i=le(e,{args:t.slice(0,t.length-1),response:n});return this.dispatch(i)},this.setError=(e,...t)=>{const n=t[t.length-1],i=le(e,{args:t.slice(0,t.length-1),response:n,error:!0});return this.dispatch(i)},this.resolve=(e,t)=>this.dispatch(le(e,t)),this.subscribe=(e,...t)=>null!==t[0]?this.dispatch(ce(e,{args:t})):Promise.resolve(),this.unsubscribe=(e,...t)=>null!==t[0]?this.dispatch(he(e,{args:t})):Promise.resolve(),this.snapshot=(e,t)=>new Ie(this,e,t),this._dispatch=e,this.getState=n,this.memo=i,this.gcPolicy=s}set dispatch(e){this._dispatch=e}get dispatch(){return this._dispatch}bindMiddleware({dispatch:e,getState:t}){this._dispatch=e,this.getState=t}set(e,...t){const n=t[t.length-1],i=ue(e,{args:t.slice(0,t.length-1),value:n});return this.dispatch(i)}getError(e,...t){if(null===t[0])return;const n=t[t.length-1],i=t.slice(0,t.length-1),s=e.key(...i),r=Ee(n,s);return void 0===n.endpoints[s]||"soft"!==(null==r?void 0:r.errorPolicy)?null==r?void 0:r.error:void 0}getResponse(e,...t){return this.getResponseMeta(e,...t)}getResponseMeta(e,...t){const[n,i]=Ae(t),s=1!==i.length||null!==i[0],r=s?e.key(...i):"",o=s?n.endpoints[r]:void 0,a=e.schema,c=Ee(n,r);let h=null==c?void 0:c.expiresAt;const l=void 0===o&&void 0!==a,u=l?this.memo.buildQueryKey(a,i,n,r):o;if(!s)return{data:u,expiryStatus:C.Valid,expiresAt:1/0,countRef:()=>()=>{}};let d=!1;if(l)d=!M(u);else if(!a||!be(a))return{data:o,expiryStatus:this.getExpiryStatus(void 0===o,!!e.invalidIfStale,c),expiresAt:h||0,countRef:this.gcPolicy.createCountRef({key:r})};const{data:p,paths:f}=this.memo.denormalize(a,u,n.entities,i);return h||(h=d?1:function(e,t){let n=1/0;for(const{key:s,pk:r}of e){var i;const e=null==(i=t[s])||null==(i=i[r])?void 0:i.expiresAt;e<n&&(n=e)}return n}(f,n.entitiesMeta)),{data:p,expiryStatus:this.getExpiryStatus("symbol"==typeof p,!!e.invalidIfStale||d,c),expiresAt:h,countRef:this.gcPolicy.createCountRef({key:r,paths:f})}}get(e,...t){const[n,i]=Ae(t),{data:s}=this.memo.query(e,i,n);return"symbol"==typeof s?void 0:s}getQueryMeta(e,...t){const[n,i]=Ae(t),{data:s,paths:r}=this.memo.query(e,i,n);return{data:"symbol"==typeof s?void 0:s,countRef:this.gcPolicy.createCountRef({paths:r})}}getExpiryStatus(e,t,n={}){return n.invalidated||e&&!n.error?C.Invalid:e||t?C.InvalidIfStale:C.Valid}}function be(e){if(!e)return!1;if(Array.isArray(e))return 0!==e.length&&be(e[0]);const t=typeof e;return("object"===t||"function"===t)&&("function"==typeof e.normalize||Object.values(e).some((e=>be(e))))}class Ie{constructor(e,t,n=0){this.state=void 0,this.controller=void 0,this.fetchedAt=void 0,this.abort=Ie.abort,this.state=t,this.controller=e,this.fetchedAt=n}getResponse(e,...t){return this.controller.getResponse(e,...t,this.state)}getResponseMeta(e,...t){return this.controller.getResponseMeta(e,...t,this.state)}getError(e,...t){return this.controller.getError(e,...t,this.state)}get(e,...t){return this.controller.get(e,...t,this.state)}getQueryMeta(e,...t){return this.controller.getQueryMeta(e,...t,this.state)}}function Ae(e){const t=e.length,n=new Array(t-1);for(let i=0;i<t-1;i++)n[i]=te(e[i]);return[e[t-1],n]}Ie.abort=new ie;class Se extends Error{constructor(){super("Aborted due to RESET"),this.name="ResetError"}}class Le{isOnline(){return void 0===navigator.onLine||navigator.onLine}addOnlineListener(e){addEventListener("online",e)}removeOnlineListener(e){removeEventListener("online",e)}addOfflineListener(e){addEventListener("offline",e)}removeOfflineListener(e){removeEventListener("offline",e)}}class Me{isOnline(){return!0}addOnlineListener(){}removeOnlineListener(){}addOfflineListener(){}removeOfflineListener(){}}let _e;_e="undefined"!=typeof navigator&&"function"==typeof addEventListener?Le:Me;var Ce=_e;let Oe={};class Re{constructor(e,t){var n,i;this.started=!1,this.actions=[],this.maxBufferLength=100;const s=h({},Oe,e);this.devtoolsName=null!=(n=s.name)?n:`Data Client: ${null==(i=globalThis.document)?void 0:i.title}`,this.devTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__.connect(s),null!=e&&e.maxAge&&(this.maxBufferLength=2*e.maxAge),t&&(this.skipLogging=t)}handleAction(e,t){this.started?this.devTools.send(e,t):(this.actions.length>this.maxBufferLength&&(this.actions=this.actions.slice(this.maxBufferLength/2)),this.actions.push([e,t]))}init(e){}cleanup(){}}Re.prototype.middleware=()=>e=>t=>e(t);e.Controller=ke,e.DefaultConnectionListener=Ce,e.DevToolsManager=Re,e.ExpiryStatus=C,e.GCPolicy=class{constructor({intervalMS:e=3e5,expiryMultiplier:t=2,expiresAt:n}={}){this.endpointCount=new Map,this.entityCount=new Map,this.endpointsQ=new Set,this.entitiesQ=[],n&&(this.expiresAt=n.bind(this)),this.options={intervalMS:e,expiryMultiplier:t}}init(e){this.controller=e,this.intervalId=setInterval((()=>{this.idleCallback((()=>this.runSweep()),{timeout:1e3})}),this.options.intervalMS),"object"==typeof this.intervalId&&"unref"in this.intervalId&&this.intervalId.unref()}cleanup(){clearInterval(this.intervalId)}createCountRef({key:e,paths:t=[]}){return()=>{var n;return e&&this.endpointCount.set(e,(null!=(n=this.endpointCount.get(e))?n:0)+1),t.forEach((e=>{var t;const{key:n,pk:i}=e;this.entityCount.has(n)||this.entityCount.set(n,new Map);const s=this.entityCount.get(n);s.set(i,(null!=(t=s.get(i))?t:0)+1)})),()=>{if(e){const t=this.endpointCount.get(e);void 0!==t&&(t<=1?(this.endpointCount.delete(e),this.endpointsQ.add(e)):this.endpointCount.set(e,t-1))}t.forEach((e=>{const{key:t,pk:n}=e;if(!this.entityCount.has(t))return;const i=this.entityCount.get(t),s=i.get(n);void 0!==s&&(s<=1?(i.delete(n),this.entitiesQ.push(e)):i.set(n,s-1))}))}}}expiresAt({fetchedAt:e,expiresAt:t}){return Math.max((t-e)*this.options.expiryMultiplier,12e4)+e}runSweep(){const e=this.controller.getState(),t=[],n=[],i=Date.now(),s=new Set;for(const t of this.endpointsQ){var r;!this.endpointCount.has(t)&&this.expiresAt(null!=(r=e.meta[t])?r:{fetchedAt:0,date:0,expiresAt:0})<i?n.push(t):s.add(t)}this.endpointsQ=s;const o=[];for(const n of this.entitiesQ){var a,c,h;(null==(a=this.entityCount.get(n.key))||!a.has(n.pk))&&this.expiresAt(null!=(c=null==(h=e.entitiesMeta[n.key])?void 0:h[n.pk])?c:{fetchedAt:0,date:0,expiresAt:0})<i?t.push(n):o.push(n)}this.entitiesQ=o,(t.length||n.length)&&this.controller.dispatch({type:H,entities:t,endpoints:n})}idleCallback(e,t){"function"==typeof requestIdleCallback?requestIdleCallback(e,t):e()}},e.ImmortalGCPolicy=me,e.LogoutManager=class{constructor({handleLogout:e,shouldLogout:t}={}){this.middleware=e=>t=>async n=>{await t(n),n.type===j&&n.error&&this.shouldLogout(n.response)&&this.handleLogout(e)},e&&(this.handleLogout=e),t&&(this.shouldLogout=t)}cleanup(){}shouldLogout(e){return 401===e.status}handleLogout(e){e.resetEntireStore()}},e.NetworkManager=class{constructor({dataExpiryLength:e=6e4,errorExpiryLength:t=1e3}={}){this.fetching=new Map,this.controller=new ke,this.middleware=e=>(this.controller=e,t=>n=>{switch(n.type){case R:return this.handleFetch(n),void 0!==n.endpoint.getOptimisticResponse&&n.endpoint.sideEffect?t(n):Promise.resolve();case j:return t(n).then((()=>{if(this.fetching.has(n.key)){var t;const i=null==(t=e.getState().meta[n.key])?void 0:t.error;i?this.handleSet(le(n.endpoint,{args:n.args,response:i,fetchedAt:n.meta.fetchedAt,error:!0})):this.handleSet(n)}}));case q:{const e=Array.from(this.fetching.values());return this.clearAll(),t(n).then((()=>{for(const{reject:t}of e)t(new Se)}))}default:return t(n)}}),this.dataExpiryLength=e,this.errorExpiryLength=t}init(){delete this.cleanupDate}cleanup(){this.cleanupDate=Date.now()}skipLogging(e){return e.type===R&&this.fetching.has(e.key)}allSettled(){if(this.fetching.size)return Promise.allSettled(this.fetching.values().map((({promise:e})=>e)))}clearAll(){for(const e of this.fetching.keys())this.clear(e)}clear(e){this.fetching.has(e)&&(this.fetching.get(e).promise.catch((()=>{})),this.fetching.delete(e))}getLastReset(){return this.cleanupDate?this.cleanupDate:this.controller.getState().lastReset}handleFetch(e){const{resolve:t,reject:n,fetchedAt:i}=e.meta,s=!e.endpoint.sideEffect,r=()=>{let r=e.endpoint(...e.args);return s||(r=(e=>e.then((e=>(t(e),e))).catch((e=>{throw n(e),e})))(r)),r=r.then((t=>{let n=this.getLastReset();return i>=n&&this.controller.resolve(e.endpoint,{args:e.args,response:t,fetchedAt:i}),t})).catch((t=>{const n=this.getLastReset();throw i>=n&&this.controller.resolve(e.endpoint,{args:e.args,response:t,fetchedAt:i,error:!0}),t})),r};return s?this.throttle(e.key,r,i).then((e=>t(e))).catch((e=>n(e))):r().catch((()=>{}))}handleSet(e){if(this.fetching.has(e.key)){const{reject:t,resolve:n}=this.fetching.get(e.key);e.error?t(e.response):n(e.response),this.clear(e.key)}}throttle(e,t,n){const i=this.getLastReset();let s=this.fetching.get(e);return s&&s.fetchedAt>i||(s=function(e){const t={fetchedAt:e};return t.promise=new Promise(((e,n)=>{t.resolve=e,t.reject=n})),t}(n),this.fetching.set(e,s),this.idleCallback((()=>{t().catch((()=>null))}),{timeout:500})),s.promise}idleCallback(e,t){e()}},e.PollingSubscription=class{constructor(e,t,n){if(this.frequencyHistogram=new Map,this.offlineListener=()=>{this.cleanup(),this.connectionListener.addOnlineListener(this.onlineListener)},this.onlineListener=()=>{this.connectionListener.removeOnlineListener(this.onlineListener);const e=Date.now();this.startId=setTimeout((()=>{this.startId&&(delete this.startId,this.update(),this.run())}),Math.max(0,this.lastFetchTime()-e+this.frequency)),this.connectionListener.addOfflineListener(this.offlineListener)},void 0===e.endpoint.pollFrequency)throw new Error("frequency needed for polling subscription");this.endpoint=e.endpoint,this.frequency=e.endpoint.pollFrequency,this.args=e.args,this.key=e.key,this.frequencyHistogram.set(this.frequency,1),this.controller=t,this.connectionListener=n||new Ce,this.connectionListener.isOnline()?this.onlineListener():this.offlineListener()}add(e){void 0!==e&&(this.frequencyHistogram.has(e)?this.frequencyHistogram.set(e,this.frequencyHistogram.get(e)+1):(this.frequencyHistogram.set(e,1),e<this.frequency&&(this.frequency=e,this.run())))}remove(e){if(void 0===e)return!1;if(this.frequencyHistogram.has(e)&&(this.frequencyHistogram.set(e,this.frequencyHistogram.get(e)-1),this.frequencyHistogram.get(e)<1)){if(this.frequencyHistogram.delete(e),0===this.frequencyHistogram.size)return this.cleanup(),!0;e<=this.frequency&&(this.frequency=Math.min(...this.frequencyHistogram.keys()),this.run())}return!1}cleanup(){this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId),this.lastIntervalId&&(clearInterval(this.lastIntervalId),delete this.lastIntervalId),this.startId&&(clearTimeout(this.startId),delete this.startId),this.connectionListener.removeOnlineListener(this.onlineListener),this.connectionListener.removeOfflineListener(this.offlineListener)}update(){const e=this.endpoint,t=function(...t){return e.call(this,...t)};Object.assign(t,this.endpoint),t.dataExpiryLength=this.frequency/2,t.errorExpiryLength=this.frequency/10,t.errorPolicy=()=>"soft",t.key=()=>this.key,this.controller.fetch(t,...this.args).catch((()=>null))}run(){this.startId||(this.intervalId&&(this.lastIntervalId=this.intervalId),this.intervalId=setInterval((()=>{this.lastIntervalId&&(clearInterval(this.lastIntervalId),delete this.lastIntervalId),this.intervalId&&this.update()}),this.frequency))}lastFetchTime(){var e,t;return null!=(e=null==(t=this.controller.getState().meta[this.key])?void 0:t.date)?e:0}},e.ResetError=Se,e.SubscriptionManager=class{constructor(e){this.subscriptions={},this.controller=new ke,this.middleware=e=>(this.controller=e,e=>t=>{switch(t.type){case D:try{this.handleSubscribe(t)}catch(e){console.error(e)}return Promise.resolve();case N:return this.handleUnsubscribe(t),Promise.resolve();default:return e(t)}}),this.Subscription=e}cleanup(){for(const e in this.subscriptions)this.subscriptions[e].cleanup()}handleSubscribe(e){const t=e.key;if(t in this.subscriptions){const n=e.endpoint.pollFrequency;this.subscriptions[t].add(n)}else this.subscriptions[t]=new this.Subscription(e,this.controller)}handleUnsubscribe(e){const t=e.key;if(t in this.subscriptions){const n=e.endpoint.pollFrequency;this.subscriptions[t].remove(n)&&delete this.subscriptions[t]}}},e.__INTERNAL__=ae,e.actionTypes=ee,e.actions=ve,e.applyManager=function(e,t){return e.map(((e,n)=>(e.middleware||(e.middleware=null==e.getMiddleware?void 0:e.getMiddleware()),i=>(0===n&&t.bindMiddleware(i),e.middleware(t)))))},e.createReducer=function(e){return function(t,n){switch(t||(t=oe),n.type){case H:return n.entities.forEach((({key:e,pk:n})=>{var i,s;null==(i=t.entities[e])||delete i[n],null==(s=t.entitiesMeta[e])||delete s[n]})),n.endpoints.forEach((e=>{delete t.endpoints[e],delete t.meta[e]})),t;case R:return function(e,t){if(t.endpoint.getOptimisticResponse&&t.endpoint.sideEffect){const n=ne(t.endpoint,t.args,t.meta.fetchedAt);return h({},e,{optimistic:[...e.optimistic,n]})}return e}(t,n);case T:case j:return function(e,t,n){if(t.error)return se(e,t,t.response);try{var i;let s;if(t.type===T){if(!t.endpoint.getOptimisticResponse)return e;try{s=t.endpoint.getOptimisticResponse.call(t.endpoint,n.snapshot(e,t.meta.fetchedAt),...t.args)}catch(t){if(t.constructor===ie)return e;throw t}}else s=t.response;const{result:r,entities:o,indexes:a,entitiesMeta:c}=I(t.endpoint.schema,s,t.args,e,t.meta),l=h({},e.endpoints,{[t.key]:r});try{if(t.endpoint.update){const e=t.endpoint.update(r,...t.args);Object.keys(e).forEach((t=>{l[t]=e[t](l[t])}))}}catch(e){console.error(`Endpoint.update() error: ${t.key}`),console.error(e)}return{entities:o,endpoints:l,indexes:a,meta:h({},e.meta,{[t.key]:{date:t.meta.date,fetchedAt:t.meta.fetchedAt,expiresAt:t.meta.expiresAt,prevExpiresAt:null==(i=e.meta[t.key])?void 0:i.expiresAt}}),entitiesMeta:c,optimistic:re(e,t),lastReset:e.lastReset}}catch(n){return"object"==typeof n&&(n.message=`Error processing ${t.key}\n\nFull Schema: ${JSON.stringify(t.endpoint.schema,void 0,2)}\n\nError:\n${n.message}`,"response"in t&&(n.response=t.response),n.status=400),se(e,t,n)}}(t,n,e);case P:return function(e,t,n){let i;if("function"==typeof t.value){const s=n.get(t.schema,...t.args,e);if(void 0===s)return e;i=t.value(s)}else i=t.value;try{const{entities:n,indexes:s,entitiesMeta:r}=I(t.schema,i,t.args,e,t.meta);return{entities:n,endpoints:e.endpoints,indexes:s,meta:e.meta,entitiesMeta:r,optimistic:e.optimistic,lastReset:e.lastReset}}catch(t){return e}}(t,n,e);case z:case K:return function(e,t){const n=h({},e.endpoints),i=h({},e.meta),s=e=>{delete n[e];const t=h({},i[e],{expiresAt:0,invalidated:!0});delete t.error,i[e]=t};return t.type===K?s(t.key):Object.keys(n).forEach((e=>{t.testKey(e)&&s(e)})),h({},e,{endpoints:n,meta:i})}(t,n);case Q:return function(e,t){const n=h({},e.meta);return Object.keys(n).forEach((e=>{t.testKey(e)&&(n[e]=h({},n[e],{expiresAt:1}))})),h({},e,{meta:n})}(t,n);case q:return h({},oe,{lastReset:n.date});default:return t}}},e.initManager=function(e,t,n){return()=>(e.forEach((e=>{null==e.init||e.init(n)})),t.gcPolicy.init(t),()=>{e.forEach((e=>{e.cleanup()})),t.gcPolicy.cleanup()})},e.initialState=oe}));
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).RDC=e.RDC||{},e.RDC.Core={}))}(this,(function(e){"use strict";class t{constructor(e=[]){this.localCache=new Map,this._args=e}getEntity(e,t,n,i){const s=t.key;this.localCache.has(s)||this.localCache.set(s,new Map);const r=this.localCache.get(s);return r.get(e)||i(r),r.get(e)}getResults(e,t,n){return{data:n(),paths:[]}}argsKey(e){return e(this._args)}}const n=Symbol("INVALID"),i={};const s=e=>e[0],r=e=>void 0!==e&&"symbol"!=typeof e,o=(e,t,n,i,r)=>{e=s(e);const o=(e=>Array.isArray(e)?e:Object.keys(e).map((t=>e[t])))(t);return o.map((t=>r.visit(e,t,n,i)))},a=(e,t,n)=>(e=s(e),t.map?t.map((t=>n.unvisit(e,t))).filter(r):t);function c(){}function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},h.apply(null,arguments)}const l=(e,t,n,i,s)=>{const r=h({},t),o=Object.keys(e);for(let n=0;n<o.length;n++){const i=o[n],a=e[i],c=s.visit(a,t[i],t,i);void 0===c?delete r[i]:r[i]=c}return r},u=(e,t,i)=>{if(function(e){return!("function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}(t))return function(e,t,i){let s=!1;const r=Object.keys(e).reduce(((t,n)=>{const r=`${n}`,o=i.unvisit(e[r],t.get(r));return"symbol"==typeof o&&(s=!0),t.has(r)?t.set(r,o):t}),t);return s?n:r}(e,t,i);const s=h({},t);let r=!1;const o=Object.keys(e);for(let t=0;t<o.length;t++){const n=o[t],a=i.unvisit(e[n],s[n]);void 0!==s[n]&&(s[n]=a),"symbol"==typeof a&&(r=!0)}return r?n:s};function d(e,t,n,i){const s={};for(const r of Object.keys(e))s[r]=n(e[r],t,i);return s}const p=(e,t,n)=>function(s,r){const o="object"!=typeof r,a=o?e({key:s.key,pk:r}):r;if("symbol"==typeof a)return s.denormalize(a,n);if(void 0===a&&o&&""!==r&&"undefined"!==r)return t.getEntity(r,s,i,(e=>{e.set(r,void 0)}));if("object"!=typeof a||null===a)return a;let c=o?r:s.pk(a,void 0,void 0,n.args);return void 0===c||""===c||"undefined"===c?function(e){const t=new Map;return e(t),t.get("")}((e=>f(s,a,"",e,n))):("string"!=typeof c&&(c=`${c}`),t.getEntity(c,s,a,(e=>f(s,a,c,e,n))))};function f(e,t,i,s,r){const o=e.createIfValid(t);void 0===o?s.set(i,n):(s.set(i,o),s.set(i,e.denormalize(o,r)))}const y=(e,t,i)=>{let s=0;const r={args:i,unvisit:c,argsKey:e=>t.argsKey(e)},o=p(e,t,r);function c(t,i){if(!t)return i;if(null==i)return i;if("function"==typeof t.denormalize){if(function(e){return null!==e&&void 0!==e.pk}(t)){var c;if(s>=(null!=(c=t.maxEntityDepth)?c:64))return function(e,t,i){var s;const r="object"!=typeof i?e({key:t.key,pk:i}):i;return"object"!=typeof r||null===r?r:null!=(s=t.createIfValid(r))?s:n}(e,t,i);s++;const r=o(t,i);return s--,r}return"function"==typeof t.createIfValid&&"string"==typeof i?o(t,i):t.denormalize(i,r)}if("function"==typeof t)return t(i);if("object"==typeof t){return(Array.isArray(t)?a:u)(t,i,r)}return i}return(e,n)=>{const i=Object(n)===n&&Object(e)===e;return t.getResults(n,i,(()=>c(e,n)))}};class g{constructor({entities:e,indexes:t}){this.entities=e,this.indexes=t}tracked(e){const t=this,i=[{path:[""],entity:e}];return[{INVALID:n,getIndex(...e){const n=t.getIndex(...e);return i.push({path:e,entity:n}),t.getIndexEnd(n,e[2])},getEntity(...e){const n=t.getEntity(...e);return i.push({path:e,entity:n}),n},getEntities(e){const n=t.getEntitiesObject(e);return i.push({path:[e],entity:n}),t.getEntities(e)}},i]}}class v extends g{constructor(e){super(e)}getEntitiesObject(e){return this.entities[e]}getEntities(e){const t=this.entities[e];if(void 0!==t)return{keys:()=>Object.keys(t),entries:()=>Object.entries(t)}}getEntity(e,t){var n;return null==(n=this.entities[e])?void 0:n[t]}getIndex(e,t){var n;return null==(n=this.indexes[e])?void 0:n[t]}getIndexEnd(e,t){return null==e?void 0:e[t]}}const m={QueryDelegate:v,getEntities:e=>({key:t,pk:n})=>{var i;return null==(i=e[t])?void 0:i[n]}};class E{constructor(){this.next=new WeakMap,this.nextPath=void 0,this.hasStr=!1}get(e,t,n=[]){let s=this.next.get(e);if(!s)return x;if(this.hasStr)return this._getMixed(s,t,n);for(;s.nextPath;){var r;const e=null!=(r=t(s.nextPath))?r:i,n=s.next.get(e);if(!n)return x;s=n}return[s.value,s.journey]}_getMixed(e,t,n){for(;e.nextPath;){let a;if("function"==typeof e.nextPath){var s,r;const t=null!=(s=e.nextPath(n))?s:"\0";a=null==(r=e.nextStr)?void 0:r.get(t)}else{var o;const n=null!=(o=t(e.nextPath))?o:i;a=e.next.get(n)}if(!a)return x;e=a}return[e.value,e.journey]}set(e,t,n=[],s){if(e.length<1)throw new k;let r=this;for(const t of e){let e;if("function"==typeof t.path){var o;this.hasStr=!0,r.nextStr||(r.nextStr=new Map);const i=null!=(o=t.path(n))?o:"\0";e=r.nextStr.get(i),e||(e=new w,r.nextStr.set(i,e))}else{var a;if(e=r.next.get(t.entity),!e)e=new w,r.next.set(null!=(a=t.entity)?a:i,e)}r.nextPath=t.path,r=e}r.nextPath=void 0,r.value=t,r.journey=null!=s?s:e.map((e=>e.path))}get hasStringDeps(){return this.hasStr}}const x=[void 0,void 0];class w{constructor(){this.next=new WeakMap,this.nextStr=void 0,this.nextPath=void 0,this.value=void 0,this.journey=[]}}class k extends Error{constructor(...e){super(...e),this.message="Keys must include at least one member"}}class b extends v{constructor(e,t,n){super(e),this.newEntities=new Map,this.newIndexes=new Map,this.entitiesMeta=e.entitiesMeta,this.args=t,this.meta=n,this.checkLoop=function(){const e=new Map;return function(t,n,i){let s=e.get(t);s||(s=new Map,e.set(t,s));let r=s.get(n);return r||(r=new Set,s.set(n,r)),!!r.has(i)||(r.add(i),!1)}}()}getNewEntity(e,t){return this.getNewEntities(e).get(t)}getNewEntities(e){let t=this.newEntities.get(e);return void 0===t&&(t=new Map,this.newEntities.set(e,t)),t}getNewIndexes(e){return this.newIndexes.has(e)||(this.newIndexes.set(e,new Map),this.indexes[e]=h({},this.indexes[e])),this.newIndexes.get(e)}mergeEntity(e,t,n){const i=e.key;let s=n,r=this.meta,o=this.getNewEntity(i,t);if(o)s=e.merge(o,n);else if(o=this.getEntity(i,t),o){const a=this.getMeta(i,t);s=e.mergeWithStore(a,r,o,n),r=e.mergeMetaWithStore(a,r,o,n)}this.setEntity(e,t,s,r)}setEntity(e,t,i,s=this.meta){const r=e.key,o=this.getNewEntities(r),a=!o.has(t);a&&0===o.size&&(this.entities[r]=h({},this.entities[r]),this.entitiesMeta[r]=h({},this.entitiesMeta[r])),o.set(t,i),e.indexes&&function(e,t,i,s,r,o){for(const a of t){i.has(a)||i.set(a,s[a]={});const t=i.get(a);o[e]&&delete t[o[e][a]],o&&o[e]&&o[e][a]!==r[a]&&(t[o[e][a]]=n),a in r&&(t[r[a]]=e)}}(t,e.indexes,this.getNewIndexes(r),this.indexes[r],i,this.entities[r]),this._setEntity(r,t,i),a&&this._setMeta(r,t,s)}invalidate({key:e},t){this.setEntity({key:e},t,n)}_setEntity(e,t,n){this.entities[e][t]=n}_setMeta(e,t,n){this.entitiesMeta[e][t]=n}getMeta(e,t){return this.entitiesMeta[e][t]}}const I=(e,t,n=[],{entities:i,indexes:s,entitiesMeta:r}=A,a={fetchedAt:0,date:Date.now(),expiresAt:1/0})=>{if(null==e)return{result:t,entities:i,indexes:s,entitiesMeta:r};const c=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(e);if(null===t||typeof t!==c&&(void 0===e.key||void 0!==e.pk||"string"!=typeof t))throw new Error(`Unexpected input given to normalize. Expected type to be "${c}", found "${null===t?"null":typeof t}".`);const u={entities:h({},i),indexes:h({},s),entitiesMeta:h({},r)},d=(e=>{let t;const n=(n,i,s,r)=>{if(null==i||!n)return i;if("object"!=typeof i){if("function"!=typeof n.normalize)return i;if(!n.acceptsPrimitives)return i&&n.pk?`${i}`:i}if("function"==typeof n.normalize){const o=t;n.pk&&(t=n);const a=n.normalize(i,s,r,e,o);return t=o,a}return"object"!=typeof n?i:(Array.isArray(n)?o:l)(n,i,s,r,e)};return e.visit=n,n})(new b(u,n,a));return{result:d(e,t,t,void 0),entities:u.entities,indexes:u.indexes,entitiesMeta:u.entitiesMeta}};const A={entities:{},indexes:{},entitiesMeta:{}},S={path:{key:"",pk:""},entity:void 0};class L{constructor(e,t,n,i=[]){this.dependencies=[S],this.cycleCache=new Map,this.cycleIndex=-1,this.localCache=new Map,this._hasArgsKey=!1,this._getEntity=e,this._getCache=t,this._resultCache=n,this._args=i}argsKey(e){return this._hasArgsKey=!0,this.dependencies.push({path:e,entity:void 0}),e(this._args)}getEntity(e,t,n,i){const s=t.key,r=this.getOrCreateLocalCache(s);if(r.get(e)){const t=this.cycleCache.get(s);null!=t&&t.has(e)?this.cycleIndex=t.get(e):this.dependencies.push({path:{key:s,pk:e},entity:n})}else{const o=this._getCache(e,t),[a,c]=o.get(n,this._getEntity,this._args);if(c){r.set(e,a.value);const t=a.dependencies;for(let e=0;e<t.length;e++)this.dependencies.push(t[e]);return o.hasStringDeps&&(this._hasArgsKey=!0),a.value}{const t=this.dependencies.length,a=this.getOrCreateCycleCache(s);a.set(e,t),this.dependencies.push({path:{key:s,pk:e},entity:n}),i(r),a.delete(e);const c=this.dependencies.slice(-1===this.cycleIndex?t:this.cycleIndex),h={dependencies:c,value:r.get(e)};o.set(c,h,this._args),this.cycleIndex===t&&(this.cycleIndex=-1)}}return r.get(e)}getOrCreateLocalCache(e){let t=this.localCache.get(e);return t||(t=new Map,this.localCache.set(e,t)),t}getOrCreateCycleCache(e){let t=this.cycleCache.get(e);return t||(t=new Map,this.cycleCache.set(e,t)),t}getResults(e,t,n){if(!t)return{data:n(),paths:this.paths()};let[i,s]=this._resultCache.get(e,this._getEntity,this._args);return void 0===s&&(i=n(),s=this.paths(),this.dependencies[0]={path:{key:"",pk:""},entity:e},this._resultCache.set(this.dependencies,i,this._args,s)),{data:i,paths:s}}paths(){const e=this.dependencies;if(!this._hasArgsKey){const t=new Array(e.length-1);for(let n=1;n<e.length;n++)t[n-1]=e[n].path;return t}const t=[];for(let n=1;n<e.length;n++){const i=e[n].path;"function"!=typeof i&&t.push(i)}return t}}function M(e){return void 0!==e&&(!(e&&"object"==typeof e&&!Array.isArray(e))||Object.values(e).every(M))}class _{constructor(e=m){var t;this.endpoints=new E,this.queryKeys=new Map,this.policy=e,this._getCache=(t=new Map,(e,n)=>{var i;const s=n.key,r=null!=(i=n.cacheWith)?i:n;t.has(s)||t.set(s,new Map);const o=t.get(s);o.has(e)||o.set(e,new WeakMap);const a=o.get(e);let c=a.get(r);return c||(c=new E,a.set(r,c)),c})}denormalize(e,t,n,i=[]){if(void 0===e)return{data:t,paths:[]};if(void 0===t)return{data:void 0,paths:[]};const s=this.policy.getEntities(n);return y(s,new L(s,this._getCache,this.endpoints,i),i)(e,t)}query(e,t,n,i=JSON.stringify(t)){const s=this.buildQueryKey(e,t,n,i);return s?this.denormalize(e,s,n.entities,t):{data:void 0,paths:[]}}buildQueryKey(e,t,n,i=JSON.stringify(t)){if("object"!=typeof e&&"function"!=typeof e.queryKey||!e)return e;let s=this.queryKeys.get(i);s||(s=new E,this.queryKeys.set(i,s));const r=new this.policy.QueryDelegate(n);let[o,a]=s.get(e,(h=r,e=>{switch(e.length){case 1:return h.getEntitiesObject(e[0]);case 2:return h.getEntity(e[0],e[1]);case 3:return h.getIndex(e[0],e[1],e[2])}}));var h;if(!a){const[n,i]=r.tracked(e);o=function(e){return function t(n,i){if(function(e){return!!e&&"function"==typeof e.queryKey}(n)){if(1===i.length&&null===i[0])return;return n.queryKey(i,t,e)}return"object"==typeof n&&n?(Array.isArray(n)?c:d)(n,i,t,e):n}}(n)(e,t),s.set(i,o)}return o}}var C={Invalid:1,InvalidIfStale:2,Valid:3};function O(e,t){const n=Date.now();return{fetchedAt:null!=t?t:n,date:n,expiresAt:n+e}}const R="rdc/fetch",P="rdc/set",j="rdc/setresponse",T="rdc/optimistic",q="rdc/reset",D="rdc/subscribe",N="rdc/unsubscribe",K="rdc/invalidate",z="rdc/invalidateall",Q="rdc/expireall",H="rdc/gc",V=R,F=P,B=j,U=T,Y=q,$=D,W=N,X=K,G=z,J=Q,Z=H;var ee=Object.freeze({__proto__:null,EXPIREALL:Q,EXPIREALL_TYPE:J,FETCH:R,FETCH_TYPE:V,GC:H,GC_TYPE:Z,INVALIDATE:K,INVALIDATEALL:z,INVALIDATEALL_TYPE:G,INVALIDATE_TYPE:X,OPTIMISTIC:T,OPTIMISTIC_TYPE:U,RESET:q,RESET_TYPE:Y,SET:P,SET_RESPONSE:j,SET_RESPONSE_TYPE:B,SET_TYPE:F,SUBSCRIBE:D,SUBSCRIBE_TYPE:$,UNSUBSCRIBE:N,UNSUBSCRIBE_TYPE:W});const te="undefined"!=typeof FormData?e=>e instanceof FormData?Object.fromEntries(e.entries()):e:e=>e;function ne(e,t,n){var i;return{type:T,key:e.key(...t),args:t.map(te),endpoint:e,meta:O(null!=(i=e.dataExpiryLength)?i:6e4,n)}}class ie extends Error{}function se(e,t,n){return"AbortError"===n.name?h({},e,{optimistic:re(e,t)}):h({},e,{meta:h({},e.meta,{[t.key]:{date:t.meta.date,fetchedAt:t.meta.fetchedAt,expiresAt:t.meta.expiresAt,error:n,errorPolicy:null==t.endpoint.errorPolicy?void 0:t.endpoint.errorPolicy(n)}}),optimistic:re(e,t)})}function re(e,t){return e.optimistic.filter((e=>e.key!==t.key||(e.type===T?e.meta.fetchedAt!==t.meta.fetchedAt:e.meta.date>t.meta.date)))}const oe={entities:{},endpoints:{},indexes:{},meta:{},entitiesMeta:{},optimistic:[],lastReset:0};var ae=Object.freeze({__proto__:null,INVALID:n,MemoCache:_,initialState:oe});function ce(e,{args:t}){return{type:D,key:e.key(...t),args:t,endpoint:e}}function he(e,{args:t}){return{type:N,key:e.key(...t),args:t,endpoint:e}}function le(e,{args:t,fetchedAt:n,response:i,error:s=!1}){var r,o;const a=s?null!=(r=e.errorExpiryLength)?r:1e3:null!=(o=e.dataExpiryLength)?o:6e4;return{type:j,key:e.key(...t),response:i,args:t.map(te),endpoint:e,meta:O(a,n),error:s}}function ue(e,{args:t,fetchedAt:n,value:i}){return{type:P,value:i,args:t.map(te),schema:e,meta:O(6e4,n)}}function de(){return{type:q,date:Date.now()}}function pe(e){return{type:z,testKey:e}}function fe(e,{args:t}){return{type:K,key:e.key(...t)}}function ye(e,{args:t}){let n=0,i=0;const s=new Promise(((e,t)=>{[n,i]=[e,t]})),r={fetchedAt:Date.now(),resolve:n,reject:i,promise:s};return{type:R,key:e.key(...t),args:t,endpoint:e,meta:r}}function ge(e){return{type:Q,testKey:e}}var ve=Object.freeze({__proto__:null,createExpireAll:ge,createFetch:ye,createInvalidate:fe,createInvalidateAll:pe,createMeta:O,createOptimistic:ne,createReset:de,createSet:ue,createSetResponse:le,createSubscription:ce,createUnsubscription:he});class me{init(){}cleanup(){}createCountRef(){return()=>()=>{}}}function Ee(e,t){return e.meta[t]}const xe=e=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},we=()=>oe;class ke{constructor({dispatch:e=xe,getState:n=we,memo:i=new _,gcPolicy:s=new me}={}){this.fetch=(e,...n)=>{const i=ye(e,{args:n});return this.dispatch(i),e.schema?i.meta.promise.then((i=>function(e,n,i,s=[]){return void 0===e||void 0===n?n:y(m.getEntities(i),new t(s),s)(e,n).data}(e.schema,i,{},n))):i.meta.promise},this.fetchIfStale=(e,...t)=>{const{data:n,expiresAt:i,expiryStatus:s}=this.getResponseMeta(e,...t,this.getState());return s!==C.Invalid&&Date.now()<=i?n:this.fetch(e,...t)},this.invalidate=(e,...t)=>null!==t[0]?this.dispatch(fe(e,{args:t})):Promise.resolve(),this.invalidateAll=e=>this.dispatch(pe((t=>e.testKey(t)))),this.expireAll=e=>this.dispatch(ge((t=>e.testKey(t)))),this.resetEntireStore=()=>this.dispatch(de()),this.setResponse=(e,...t)=>{const n=t[t.length-1],i=le(e,{args:t.slice(0,t.length-1),response:n});return this.dispatch(i)},this.setError=(e,...t)=>{const n=t[t.length-1],i=le(e,{args:t.slice(0,t.length-1),response:n,error:!0});return this.dispatch(i)},this.resolve=(e,t)=>this.dispatch(le(e,t)),this.subscribe=(e,...t)=>null!==t[0]?this.dispatch(ce(e,{args:t})):Promise.resolve(),this.unsubscribe=(e,...t)=>null!==t[0]?this.dispatch(he(e,{args:t})):Promise.resolve(),this.snapshot=(e,t)=>new Ie(this,e,t),this._dispatch=e,this.getState=n,this.memo=i,this.gcPolicy=s}set dispatch(e){this._dispatch=e}get dispatch(){return this._dispatch}bindMiddleware({dispatch:e,getState:t}){this._dispatch=e,this.getState=t}set(e,...t){const n=t[t.length-1],i=ue(e,{args:t.slice(0,t.length-1),value:n});return this.dispatch(i)}getError(e,...t){if(null===t[0])return;const n=t[t.length-1],i=t.slice(0,t.length-1),s=e.key(...i),r=Ee(n,s);return void 0===n.endpoints[s]||"soft"!==(null==r?void 0:r.errorPolicy)?null==r?void 0:r.error:void 0}getResponse(e,...t){return this.getResponseMeta(e,...t)}getResponseMeta(e,...t){const[n,i]=Ae(t),s=1!==i.length||null!==i[0],r=s?e.key(...i):"",o=s?n.endpoints[r]:void 0,a=e.schema,c=Ee(n,r);let h=null==c?void 0:c.expiresAt;const l=void 0===o&&void 0!==a,u=l?this.memo.buildQueryKey(a,i,n,r):o;if(!s)return{data:u,expiryStatus:C.Valid,expiresAt:1/0,countRef:()=>()=>{}};let d=!1;if(l)d=!M(u);else if(!a||!be(a))return{data:o,expiryStatus:this.getExpiryStatus(void 0===o,!!e.invalidIfStale,c),expiresAt:h||0,countRef:this.gcPolicy.createCountRef({key:r})};const{data:p,paths:f}=this.memo.denormalize(a,u,n.entities,i);h||(h=d?1:function(e,t){let n=1/0;for(const{key:s,pk:r}of e){var i;const e=null==(i=t[s])||null==(i=i[r])?void 0:i.expiresAt;e<n&&(n=e)}return n}(f,n.entitiesMeta));const y="symbol"==typeof p;return{data:y?void 0:p,expiryStatus:this.getExpiryStatus(y,!!e.invalidIfStale||d,c),expiresAt:h,countRef:this.gcPolicy.createCountRef({key:r,paths:f})}}get(e,...t){const[n,i]=Ae(t),{data:s}=this.memo.query(e,i,n);return"symbol"==typeof s?void 0:s}getQueryMeta(e,...t){const[n,i]=Ae(t),{data:s,paths:r}=this.memo.query(e,i,n);return{data:"symbol"==typeof s?void 0:s,countRef:this.gcPolicy.createCountRef({paths:r})}}getExpiryStatus(e,t,n={}){return n.invalidated||e&&!n.error?C.Invalid:e||t?C.InvalidIfStale:C.Valid}}function be(e){if(!e)return!1;if(Array.isArray(e))return 0!==e.length&&be(e[0]);const t=typeof e;return("object"===t||"function"===t)&&("function"==typeof e.normalize||Object.values(e).some((e=>be(e))))}class Ie{constructor(e,t,n=0){this.state=void 0,this.controller=void 0,this.fetchedAt=void 0,this.abort=Ie.abort,this.state=t,this.controller=e,this.fetchedAt=n}getResponse(e,...t){return this.controller.getResponse(e,...t,this.state)}getResponseMeta(e,...t){return this.controller.getResponseMeta(e,...t,this.state)}getError(e,...t){return this.controller.getError(e,...t,this.state)}get(e,...t){return this.controller.get(e,...t,this.state)}getQueryMeta(e,...t){return this.controller.getQueryMeta(e,...t,this.state)}}function Ae(e){const t=e.length,n=new Array(t-1);for(let i=0;i<t-1;i++)n[i]=te(e[i]);return[e[t-1],n]}Ie.abort=new ie;class Se extends Error{constructor(){super("Aborted due to RESET"),this.name="ResetError"}}class Le{isOnline(){return void 0===navigator.onLine||navigator.onLine}addOnlineListener(e){addEventListener("online",e)}removeOnlineListener(e){removeEventListener("online",e)}addOfflineListener(e){addEventListener("offline",e)}removeOfflineListener(e){removeEventListener("offline",e)}}class Me{isOnline(){return!0}addOnlineListener(){}removeOnlineListener(){}addOfflineListener(){}removeOfflineListener(){}}let _e;_e="undefined"!=typeof navigator&&"function"==typeof addEventListener?Le:Me;var Ce=_e;let Oe={};class Re{constructor(e,t){var n,i;this.started=!1,this.actions=[],this.maxBufferLength=100;const s=h({},Oe,e);this.devtoolsName=null!=(n=s.name)?n:`Data Client: ${null==(i=globalThis.document)?void 0:i.title}`,this.devTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__.connect(s),null!=e&&e.maxAge&&(this.maxBufferLength=2*e.maxAge),t&&(this.skipLogging=t)}handleAction(e,t){this.started?this.devTools.send(e,t):(this.actions.length>this.maxBufferLength&&(this.actions=this.actions.slice(this.maxBufferLength/2)),this.actions.push([e,t]))}init(e){}cleanup(){}}Re.prototype.middleware=()=>e=>t=>e(t);e.Controller=ke,e.DefaultConnectionListener=Ce,e.DevToolsManager=Re,e.ExpiryStatus=C,e.GCPolicy=class{constructor({intervalMS:e=3e5,expiryMultiplier:t=2,expiresAt:n}={}){this.endpointCount=new Map,this.entityCount=new Map,this.endpointsQ=new Set,this.entitiesQ=[],n&&(this.expiresAt=n.bind(this)),this.options={intervalMS:e,expiryMultiplier:t}}init(e){this.controller=e,this.intervalId=setInterval((()=>{this.idleCallback((()=>this.runSweep()),{timeout:1e3})}),this.options.intervalMS),"object"==typeof this.intervalId&&"unref"in this.intervalId&&this.intervalId.unref()}cleanup(){clearInterval(this.intervalId)}createCountRef({key:e,paths:t=[]}){return()=>{var n;return e&&this.endpointCount.set(e,(null!=(n=this.endpointCount.get(e))?n:0)+1),t.forEach((e=>{var t;const{key:n,pk:i}=e;this.entityCount.has(n)||this.entityCount.set(n,new Map);const s=this.entityCount.get(n);s.set(i,(null!=(t=s.get(i))?t:0)+1)})),()=>{if(e){const t=this.endpointCount.get(e);void 0!==t&&(t<=1?(this.endpointCount.delete(e),this.endpointsQ.add(e)):this.endpointCount.set(e,t-1))}t.forEach((e=>{const{key:t,pk:n}=e;if(!this.entityCount.has(t))return;const i=this.entityCount.get(t),s=i.get(n);void 0!==s&&(s<=1?(i.delete(n),this.entitiesQ.push(e)):i.set(n,s-1))}))}}}expiresAt({fetchedAt:e,expiresAt:t}){return Math.max((t-e)*this.options.expiryMultiplier,12e4)+e}runSweep(){const e=this.controller.getState(),t=[],n=[],i=Date.now(),s=new Set;for(const t of this.endpointsQ){var r;!this.endpointCount.has(t)&&this.expiresAt(null!=(r=e.meta[t])?r:{fetchedAt:0,date:0,expiresAt:0})<i?n.push(t):s.add(t)}this.endpointsQ=s;const o=[];for(const n of this.entitiesQ){var a,c,h;(null==(a=this.entityCount.get(n.key))||!a.has(n.pk))&&this.expiresAt(null!=(c=null==(h=e.entitiesMeta[n.key])?void 0:h[n.pk])?c:{fetchedAt:0,date:0,expiresAt:0})<i?t.push(n):o.push(n)}this.entitiesQ=o,(t.length||n.length)&&this.controller.dispatch({type:H,entities:t,endpoints:n})}idleCallback(e,t){"function"==typeof requestIdleCallback?requestIdleCallback(e,t):e()}},e.ImmortalGCPolicy=me,e.LogoutManager=class{constructor({handleLogout:e,shouldLogout:t}={}){this.middleware=e=>t=>async n=>{await t(n),n.type===j&&n.error&&this.shouldLogout(n.response)&&this.handleLogout(e)},e&&(this.handleLogout=e),t&&(this.shouldLogout=t)}cleanup(){}shouldLogout(e){return 401===e.status}handleLogout(e){e.resetEntireStore()}},e.NetworkManager=class{constructor({dataExpiryLength:e=6e4,errorExpiryLength:t=1e3}={}){this.fetching=new Map,this.controller=new ke,this.middleware=e=>(this.controller=e,t=>n=>{switch(n.type){case R:return this.handleFetch(n),void 0!==n.endpoint.getOptimisticResponse&&n.endpoint.sideEffect?t(n):Promise.resolve();case j:return t(n).then((()=>{if(this.fetching.has(n.key)){var t;const i=null==(t=e.getState().meta[n.key])?void 0:t.error;i?this.handleSet(le(n.endpoint,{args:n.args,response:i,fetchedAt:n.meta.fetchedAt,error:!0})):this.handleSet(n)}}));case q:{const e=Array.from(this.fetching.values());return this.clearAll(),t(n).then((()=>{for(const{reject:t}of e)t(new Se)}))}default:return t(n)}}),this.dataExpiryLength=e,this.errorExpiryLength=t}init(){delete this.cleanupDate}cleanup(){this.cleanupDate=Date.now()}skipLogging(e){return e.type===R&&this.fetching.has(e.key)}allSettled(){if(this.fetching.size)return Promise.allSettled(this.fetching.values().map((({promise:e})=>e)))}clearAll(){for(const e of this.fetching.keys())this.clear(e)}clear(e){this.fetching.has(e)&&(this.fetching.get(e).promise.catch((()=>{})),this.fetching.delete(e))}getLastReset(){return this.cleanupDate?this.cleanupDate:this.controller.getState().lastReset}handleFetch(e){const{resolve:t,reject:n,fetchedAt:i}=e.meta,s=!e.endpoint.sideEffect,r=()=>{let r=e.endpoint(...e.args);return s||(r=(e=>e.then((e=>(t(e),e))).catch((e=>{throw n(e),e})))(r)),r=r.then((t=>{let n=this.getLastReset();return i>=n&&this.controller.resolve(e.endpoint,{args:e.args,response:t,fetchedAt:i}),t})).catch((t=>{const n=this.getLastReset();throw i>=n&&this.controller.resolve(e.endpoint,{args:e.args,response:t,fetchedAt:i,error:!0}),t})),r};return s?this.throttle(e.key,r,i).then((e=>t(e))).catch((e=>n(e))):r().catch((()=>{}))}handleSet(e){if(this.fetching.has(e.key)){const{reject:t,resolve:n}=this.fetching.get(e.key);e.error?t(e.response):n(e.response),this.clear(e.key)}}throttle(e,t,n){const i=this.getLastReset();let s=this.fetching.get(e);return s&&s.fetchedAt>i||(s=function(e){const t={fetchedAt:e};return t.promise=new Promise(((e,n)=>{t.resolve=e,t.reject=n})),t}(n),this.fetching.set(e,s),this.idleCallback((()=>{t().catch((()=>null))}),{timeout:500})),s.promise}idleCallback(e,t){e()}},e.PollingSubscription=class{constructor(e,t,n){if(this.frequencyHistogram=new Map,this.offlineListener=()=>{this.cleanup(),this.connectionListener.addOnlineListener(this.onlineListener)},this.onlineListener=()=>{this.connectionListener.removeOnlineListener(this.onlineListener);const e=Date.now();this.startId=setTimeout((()=>{this.startId&&(delete this.startId,this.update(),this.run())}),Math.max(0,this.lastFetchTime()-e+this.frequency)),this.connectionListener.addOfflineListener(this.offlineListener)},void 0===e.endpoint.pollFrequency)throw new Error("frequency needed for polling subscription");this.endpoint=e.endpoint,this.frequency=e.endpoint.pollFrequency,this.args=e.args,this.key=e.key,this.frequencyHistogram.set(this.frequency,1),this.controller=t,this.connectionListener=n||new Ce,this.connectionListener.isOnline()?this.onlineListener():this.offlineListener()}add(e){void 0!==e&&(this.frequencyHistogram.has(e)?this.frequencyHistogram.set(e,this.frequencyHistogram.get(e)+1):(this.frequencyHistogram.set(e,1),e<this.frequency&&(this.frequency=e,this.run())))}remove(e){if(void 0===e)return!1;if(this.frequencyHistogram.has(e)&&(this.frequencyHistogram.set(e,this.frequencyHistogram.get(e)-1),this.frequencyHistogram.get(e)<1)){if(this.frequencyHistogram.delete(e),0===this.frequencyHistogram.size)return this.cleanup(),!0;e<=this.frequency&&(this.frequency=Math.min(...this.frequencyHistogram.keys()),this.run())}return!1}cleanup(){this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId),this.lastIntervalId&&(clearInterval(this.lastIntervalId),delete this.lastIntervalId),this.startId&&(clearTimeout(this.startId),delete this.startId),this.connectionListener.removeOnlineListener(this.onlineListener),this.connectionListener.removeOfflineListener(this.offlineListener)}update(){const e=this.endpoint,t=function(...t){return e.call(this,...t)};Object.assign(t,this.endpoint),t.dataExpiryLength=this.frequency/2,t.errorExpiryLength=this.frequency/10,t.errorPolicy=()=>"soft",t.key=()=>this.key,this.controller.fetch(t,...this.args).catch((()=>null))}run(){this.startId||(this.intervalId&&(this.lastIntervalId=this.intervalId),this.intervalId=setInterval((()=>{this.lastIntervalId&&(clearInterval(this.lastIntervalId),delete this.lastIntervalId),this.intervalId&&this.update()}),this.frequency))}lastFetchTime(){var e,t;return null!=(e=null==(t=this.controller.getState().meta[this.key])?void 0:t.date)?e:0}},e.ResetError=Se,e.SubscriptionManager=class{constructor(e){this.subscriptions={},this.controller=new ke,this.middleware=e=>(this.controller=e,e=>t=>{switch(t.type){case D:try{this.handleSubscribe(t)}catch(e){console.error(e)}return Promise.resolve();case N:return this.handleUnsubscribe(t),Promise.resolve();default:return e(t)}}),this.Subscription=e}cleanup(){for(const e in this.subscriptions)this.subscriptions[e].cleanup()}handleSubscribe(e){const t=e.key;if(t in this.subscriptions){const n=e.endpoint.pollFrequency;this.subscriptions[t].add(n)}else this.subscriptions[t]=new this.Subscription(e,this.controller)}handleUnsubscribe(e){const t=e.key;if(t in this.subscriptions){const n=e.endpoint.pollFrequency;this.subscriptions[t].remove(n)&&delete this.subscriptions[t]}}},e.__INTERNAL__=ae,e.actionTypes=ee,e.actions=ve,e.applyManager=function(e,t){return e.map(((e,n)=>(e.middleware||(e.middleware=null==e.getMiddleware?void 0:e.getMiddleware()),i=>(0===n&&t.bindMiddleware(i),e.middleware(t)))))},e.createReducer=function(e){return function(t,n){switch(t||(t=oe),n.type){case H:return n.entities.forEach((({key:e,pk:n})=>{var i,s;null==(i=t.entities[e])||delete i[n],null==(s=t.entitiesMeta[e])||delete s[n]})),n.endpoints.forEach((e=>{delete t.endpoints[e],delete t.meta[e]})),t;case R:return function(e,t){if(t.endpoint.getOptimisticResponse&&t.endpoint.sideEffect){const n=ne(t.endpoint,t.args,t.meta.fetchedAt);return h({},e,{optimistic:[...e.optimistic,n]})}return e}(t,n);case T:case j:return function(e,t,n){if(t.error)return se(e,t,t.response);try{var i;let s;if(t.type===T){if(!t.endpoint.getOptimisticResponse)return e;try{s=t.endpoint.getOptimisticResponse.call(t.endpoint,n.snapshot(e,t.meta.fetchedAt),...t.args)}catch(t){if(t.constructor===ie)return e;throw t}}else s=t.response;const{result:r,entities:o,indexes:a,entitiesMeta:c}=I(t.endpoint.schema,s,t.args,e,t.meta),l=h({},e.endpoints,{[t.key]:r});try{if(t.endpoint.update){const e=t.endpoint.update(r,...t.args);Object.keys(e).forEach((t=>{l[t]=e[t](l[t])}))}}catch(e){console.error(`Endpoint.update() error: ${t.key}`),console.error(e)}return{entities:o,endpoints:l,indexes:a,meta:h({},e.meta,{[t.key]:{date:t.meta.date,fetchedAt:t.meta.fetchedAt,expiresAt:t.meta.expiresAt,prevExpiresAt:null==(i=e.meta[t.key])?void 0:i.expiresAt}}),entitiesMeta:c,optimistic:re(e,t),lastReset:e.lastReset}}catch(n){return"object"==typeof n&&(n.message=`Error processing ${t.key}\n\nFull Schema: ${JSON.stringify(t.endpoint.schema,void 0,2)}\n\nError:\n${n.message}`,"response"in t&&(n.response=t.response),n.status=400),se(e,t,n)}}(t,n,e);case P:return function(e,t,n){let i;if("function"==typeof t.value){const s=n.get(t.schema,...t.args,e);if(void 0===s)return e;i=t.value(s)}else i=t.value;try{const{entities:n,indexes:s,entitiesMeta:r}=I(t.schema,i,t.args,e,t.meta);return{entities:n,endpoints:e.endpoints,indexes:s,meta:e.meta,entitiesMeta:r,optimistic:e.optimistic,lastReset:e.lastReset}}catch(t){return e}}(t,n,e);case z:case K:return function(e,t){const n=h({},e.endpoints),i=h({},e.meta),s=e=>{delete n[e];const t=h({},i[e],{expiresAt:0,invalidated:!0});delete t.error,i[e]=t};return t.type===K?s(t.key):Object.keys(n).forEach((e=>{t.testKey(e)&&s(e)})),h({},e,{endpoints:n,meta:i})}(t,n);case Q:return function(e,t){const n=h({},e.meta);return Object.keys(n).forEach((e=>{t.testKey(e)&&(n[e]=h({},n[e],{expiresAt:1}))})),h({},e,{meta:n})}(t,n);case q:return h({},oe,{lastReset:n.date});default:return t}}},e.initManager=function(e,t,n){return()=>(e.forEach((e=>{null==e.init||e.init(n)})),t.gcPolicy.init(t),()=>{e.forEach((e=>{e.cleanup()})),t.gcPolicy.cleanup()})},e.initialState=oe}));
package/dist/mock.js CHANGED
@@ -573,6 +573,12 @@ class Controller {
573
573
  * @see https://dataclient.io/docs/api/Controller#set
574
574
  */
575
575
 
576
+ /**
577
+ * Sets every row of an Array or Values of one Entity (or Union) in one normalize,
578
+ * or invalidates the one Entity an Invalidate schema's value identifies.
579
+ * @see https://dataclient.io/docs/api/Controller#set
580
+ */
581
+
576
582
  set(schema, ...rest) {
577
583
  const value = rest[rest.length - 1];
578
584
  const action = createSet(schema, {
@@ -729,9 +735,11 @@ class Controller {
729
735
  // fallback to entity expiry time
730
736
  else expiresAt = entityExpiresAt(paths, state.entitiesMeta);
731
737
  }
738
+ const invalidData = typeof data === 'symbol';
732
739
  return {
733
- data,
734
- expiryStatus: this.getExpiryStatus(typeof data === 'symbol', !!endpoint.invalidIfStale || isInvalid, meta),
740
+ // INVALID symbol (e.g. deleted entity) is an internal marker; expose it as missing data
741
+ data: invalidData ? undefined : data,
742
+ expiryStatus: this.getExpiryStatus(invalidData, !!endpoint.invalidIfStale || isInvalid, meta),
735
743
  expiresAt,
736
744
  countRef: this.gcPolicy.createCountRef({
737
745
  key,
@@ -889,7 +897,12 @@ if (process.env.NODE_ENV !== 'production') {
889
897
  });
890
898
  return serial;
891
899
  }
892
- const HASINTL = typeof Intl !== 'undefined';
900
+ const dateFormat = typeof Intl !== 'undefined' ? new Intl.DateTimeFormat('en-US', {
901
+ hour: 'numeric',
902
+ minute: 'numeric',
903
+ second: 'numeric',
904
+ fractionalSecondDigits: 3
905
+ }) : undefined;
893
906
  DEFAULT_CONFIG = {
894
907
  name: `Data Client: ${(_globalThis$document = globalThis.document) == null ? void 0 : _globalThis$document.title}`,
895
908
  autoPause: true,
@@ -924,14 +937,9 @@ if (process.env.NODE_ENV !== 'production') {
924
937
  serialize: {
925
938
  options: undefined,
926
939
  /* istanbul ignore next */
927
- replacer: HASINTL ? (key, value) => {
940
+ replacer: dateFormat ? (key, value) => {
928
941
  if (typeof value === 'number' && typeof key === 'string' && isFinite(value) && (key === 'date' || key.endsWith('At'))) {
929
- return Intl.DateTimeFormat('en-US', {
930
- hour: 'numeric',
931
- minute: 'numeric',
932
- second: 'numeric',
933
- fractionalSecondDigits: 3
934
- }).format(value);
942
+ return dateFormat.format(value);
935
943
  }
936
944
  return value;
937
945
  } : undefined
package/legacy/actions.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6W10sInNvdXJjZXMiOlsiLi4vc3JjL2FjdGlvbnMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUge1xuICBEZW5vcm1hbGl6ZSxcbiAgRW5kcG9pbnRJbnRlcmZhY2UsXG4gIEVudGl0eVBhdGgsXG4gIFF1ZXJ5YWJsZSxcbiAgUmVzb2x2ZVR5cGUsXG4gIFVua25vd25FcnJvcixcbn0gZnJvbSAnQGRhdGEtY2xpZW50L25vcm1hbGl6cic7XG5cbmltcG9ydCB0eXBlIHtcbiAgU0VULFxuICBSRVNFVCxcbiAgRkVUQ0gsXG4gIFNVQlNDUklCRSxcbiAgVU5TVUJTQ1JJQkUsXG4gIElOVkFMSURBVEUsXG4gIEdDLFxuICBPUFRJTUlTVElDLFxuICBJTlZBTElEQVRFQUxMLFxuICBFWFBJUkVBTEwsXG4gIFNFVF9SRVNQT05TRSxcbn0gZnJvbSAnLi9hY3Rpb25UeXBlcy5qcyc7XG5pbXBvcnQgdHlwZSB7IEVuZHBvaW50VXBkYXRlRnVuY3Rpb24gfSBmcm9tICcuL2NvbnRyb2xsZXIvdHlwZXMuanMnO1xuXG50eXBlIEVuZHBvaW50QW5kVXBkYXRlPEUgZXh0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