tinybase 5.2.2 → 5.3.0-beta.1

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 (43) hide show
  1. package/@types/ui-react/index.d.cts +159 -0
  2. package/@types/ui-react/index.d.ts +159 -0
  3. package/@types/ui-react/with-schemas/index.d.cts +92 -0
  4. package/@types/ui-react/with-schemas/index.d.ts +92 -0
  5. package/cjs/es6/min/ui-react/index.cjs +1 -1
  6. package/cjs/es6/min/ui-react/index.cjs.gz +0 -0
  7. package/cjs/es6/min/ui-react/with-schemas/index.cjs +1 -1
  8. package/cjs/es6/min/ui-react/with-schemas/index.cjs.gz +0 -0
  9. package/cjs/es6/ui-react/index.cjs +89 -29
  10. package/cjs/es6/ui-react/with-schemas/index.cjs +89 -29
  11. package/cjs/min/ui-react/index.cjs +1 -1
  12. package/cjs/min/ui-react/index.cjs.gz +0 -0
  13. package/cjs/min/ui-react/with-schemas/index.cjs +1 -1
  14. package/cjs/min/ui-react/with-schemas/index.cjs.gz +0 -0
  15. package/cjs/ui-react/index.cjs +63 -30
  16. package/cjs/ui-react/with-schemas/index.cjs +63 -30
  17. package/es6/min/ui-react/index.js +1 -1
  18. package/es6/min/ui-react/index.js.gz +0 -0
  19. package/es6/min/ui-react/with-schemas/index.js +1 -1
  20. package/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  21. package/es6/ui-react/index.js +89 -29
  22. package/es6/ui-react/with-schemas/index.js +89 -29
  23. package/min/ui-react/index.js +1 -1
  24. package/min/ui-react/index.js.gz +0 -0
  25. package/min/ui-react/with-schemas/index.js +1 -1
  26. package/min/ui-react/with-schemas/index.js.gz +0 -0
  27. package/package.json +1 -1
  28. package/readme.md +14 -14
  29. package/releases.md +24 -24
  30. package/ui-react/index.js +63 -30
  31. package/ui-react/with-schemas/index.js +63 -30
  32. package/umd/es6/min/ui-react/index.js +1 -1
  33. package/umd/es6/min/ui-react/index.js.gz +0 -0
  34. package/umd/es6/min/ui-react/with-schemas/index.js +1 -1
  35. package/umd/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  36. package/umd/es6/ui-react/index.js +90 -33
  37. package/umd/es6/ui-react/with-schemas/index.js +90 -33
  38. package/umd/min/ui-react/index.js +1 -1
  39. package/umd/min/ui-react/index.js.gz +0 -0
  40. package/umd/min/ui-react/with-schemas/index.js +1 -1
  41. package/umd/min/ui-react/with-schemas/index.js.gz +0 -0
  42. package/umd/ui-react/index.js +65 -30
  43. package/umd/ui-react/with-schemas/index.js +65 -30
@@ -55,6 +55,7 @@
55
55
  const arrayMap = (array, cb) => array.map(cb);
56
56
  const arrayIsEmpty = (array) => size(array) == 0;
57
57
  const arrayFilter = (array, cb) => array.filter(cb);
58
+ const arrayWith = (array, index, value) => array.with(index, value);
58
59
 
59
60
  const object = Object;
60
61
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -121,6 +122,17 @@
121
122
  ? thing
122
123
  : thingOrThingId;
123
124
  };
125
+ const useProvideThing = (thingId, thing, offset) => {
126
+ const {12: addExtraThingById, 13: delExtraThingById} =
127
+ useContext$1(Context);
128
+ useEffect$1(() => {
129
+ addExtraThingById == null
130
+ ? void 0
131
+ : addExtraThingById(offset, thingId, thing);
132
+ return () =>
133
+ delExtraThingById == null ? void 0 : delExtraThingById(offset, thingId);
134
+ }, [addExtraThingById, thingId, thing, offset, delExtraThingById]);
135
+ };
124
136
  const useThingIds = (offset) => {
125
137
  var _a;
126
138
  return objIds((_a = useContext$1(Context)[offset]) != null ? _a : {});
@@ -128,29 +140,34 @@
128
140
  const useStore = (id) => useThing(id, 0);
129
141
  const useStoreOrStoreById = (storeOrStoreId) =>
130
142
  useThingOrThingById(storeOrStoreId, 0);
131
- const useProvideStore = (storeId, store) => {
132
- const {12: addExtraStore, 13: delExtraStore} = useContext$1(Context);
133
- useEffect$1(() => {
134
- addExtraStore == null ? void 0 : addExtraStore(storeId, store);
135
- return () => (delExtraStore == null ? void 0 : delExtraStore(storeId));
136
- }, [addExtraStore, storeId, store, delExtraStore]);
137
- };
143
+ const useProvideStore = (storeId, store) =>
144
+ useProvideThing(storeId, store, 0);
138
145
  const useMetrics = (id) => useThing(id, 2);
139
146
  const useMetricsOrMetricsById = (metricsOrMetricsId) =>
140
147
  useThingOrThingById(metricsOrMetricsId, 2);
148
+ const useProvideMetrics = (metricsId, metrics) =>
149
+ useProvideThing(metricsId, metrics, 1);
141
150
  const useIndexes = (id) => useThing(id, 4);
142
151
  const useIndexesOrIndexesById = (indexesOrIndexesId) =>
143
152
  useThingOrThingById(indexesOrIndexesId, 4);
153
+ const useProvideIndexes = (indexesId, indexes) =>
154
+ useProvideThing(indexesId, indexes, 2);
144
155
  const useRelationships = (id) => useThing(id, 6);
145
156
  const useRelationshipsOrRelationshipsById = (
146
157
  relationshipsOrRelationshipsId,
147
158
  ) => useThingOrThingById(relationshipsOrRelationshipsId, 6);
159
+ const useProvideRelationships = (relationshipsId, relationships) =>
160
+ useProvideThing(relationshipsId, relationships, 3);
148
161
  const useQueries = (id) => useThing(id, 8);
149
162
  const useQueriesOrQueriesById = (queriesOrQueriesId) =>
150
163
  useThingOrThingById(queriesOrQueriesId, 8);
164
+ const useProvideQueries = (queriesId, queries) =>
165
+ useProvideThing(queriesId, queries, 4);
151
166
  const useCheckpoints = (id) => useThing(id, 10);
152
167
  const useCheckpointsOrCheckpointsById = (checkpointsOrCheckpointsId) =>
153
168
  useThingOrThingById(checkpointsOrCheckpointsId, 10);
169
+ const useProvideCheckpoints = (checkpointsId, checkpoints) =>
170
+ useProvideThing(checkpointsId, checkpoints, 5);
154
171
 
155
172
  const lower = (str) => str.toLowerCase();
156
173
  lower(LISTENER);
@@ -1753,22 +1770,42 @@
1753
1770
  children,
1754
1771
  }) => {
1755
1772
  const parentValue = useContext(Context);
1756
- const [extraStoresById, setExtraStoresById] = useState({});
1757
- const addExtraStore = useCallback(
1758
- (id, store2) =>
1759
- setExtraStoresById((extraStoresById2) =>
1760
- objGet(extraStoresById2, id) == store2
1761
- ? extraStoresById2
1762
- : __spreadProps(__spreadValues({}, extraStoresById2), {
1763
- [id]: store2,
1764
- }),
1773
+ const [extraThingsById, setExtraThingsById] = useState([
1774
+ {},
1775
+ {},
1776
+ {},
1777
+ {},
1778
+ {},
1779
+ {},
1780
+ ]);
1781
+ const addExtraThingById = useCallback(
1782
+ (thingOffset, id, thing) =>
1783
+ setExtraThingsById((extraThingsById2) =>
1784
+ objGet(extraThingsById2[thingOffset], id) == thing
1785
+ ? extraThingsById2
1786
+ : arrayWith(
1787
+ extraThingsById2,
1788
+ thingOffset,
1789
+ __spreadProps(
1790
+ __spreadValues({}, extraThingsById2[thingOffset]),
1791
+ {
1792
+ [id]: thing,
1793
+ },
1794
+ ),
1795
+ ),
1765
1796
  ),
1766
1797
  [],
1767
1798
  );
1768
- const delExtraStore = useCallback(
1769
- (id) =>
1770
- setExtraStoresById((extraStoresById2) =>
1771
- __spreadValues({}, objDel(extraStoresById2, id)),
1799
+ const delExtraThingById = useCallback(
1800
+ (thingOffset, id) =>
1801
+ setExtraThingsById((extraThingsById2) =>
1802
+ !objHas(extraThingsById2[thingOffset], id)
1803
+ ? extraThingsById2
1804
+ : arrayWith(
1805
+ extraThingsById2,
1806
+ thingOffset,
1807
+ objDel(extraThingsById2[thingOffset], id),
1808
+ ),
1772
1809
  ),
1773
1810
  [],
1774
1811
  );
@@ -1780,31 +1817,46 @@
1780
1817
  store != null ? store : parentValue[0],
1781
1818
  __spreadValues(
1782
1819
  __spreadValues(__spreadValues({}, parentValue[1]), storesById),
1783
- extraStoresById,
1820
+ extraThingsById[0],
1784
1821
  ),
1785
1822
  metrics != null ? metrics : parentValue[2],
1786
- __spreadValues(__spreadValues({}, parentValue[3]), metricsById),
1823
+ __spreadValues(
1824
+ __spreadValues(__spreadValues({}, parentValue[3]), metricsById),
1825
+ extraThingsById[1],
1826
+ ),
1787
1827
  indexes != null ? indexes : parentValue[4],
1788
- __spreadValues(__spreadValues({}, parentValue[5]), indexesById),
1828
+ __spreadValues(
1829
+ __spreadValues(__spreadValues({}, parentValue[5]), indexesById),
1830
+ extraThingsById[2],
1831
+ ),
1789
1832
  relationships != null ? relationships : parentValue[6],
1790
1833
  __spreadValues(
1791
- __spreadValues({}, parentValue[7]),
1792
- relationshipsById,
1834
+ __spreadValues(
1835
+ __spreadValues({}, parentValue[7]),
1836
+ relationshipsById,
1837
+ ),
1838
+ extraThingsById[3],
1793
1839
  ),
1794
1840
  queries != null ? queries : parentValue[8],
1795
- __spreadValues(__spreadValues({}, parentValue[9]), queriesById),
1841
+ __spreadValues(
1842
+ __spreadValues(__spreadValues({}, parentValue[9]), queriesById),
1843
+ extraThingsById[4],
1844
+ ),
1796
1845
  checkpoints != null ? checkpoints : parentValue[10],
1797
1846
  __spreadValues(
1798
- __spreadValues({}, parentValue[11]),
1799
- checkpointsById,
1847
+ __spreadValues(
1848
+ __spreadValues({}, parentValue[11]),
1849
+ checkpointsById,
1850
+ ),
1851
+ extraThingsById[5],
1800
1852
  ),
1801
- addExtraStore,
1802
- delExtraStore,
1853
+ addExtraThingById,
1854
+ delExtraThingById,
1803
1855
  ],
1804
1856
  [
1805
1857
  store,
1806
1858
  storesById,
1807
- extraStoresById,
1859
+ extraThingsById,
1808
1860
  metrics,
1809
1861
  metricsById,
1810
1862
  indexes,
@@ -1816,8 +1868,8 @@
1816
1868
  checkpoints,
1817
1869
  checkpointsById,
1818
1870
  parentValue,
1819
- addExtraStore,
1820
- delExtraStore,
1871
+ addExtraThingById,
1872
+ delExtraThingById,
1821
1873
  ],
1822
1874
  ),
1823
1875
  },
@@ -2235,6 +2287,11 @@
2235
2287
  exports.useMetrics = useMetrics;
2236
2288
  exports.useMetricsIds = useMetricsIds;
2237
2289
  exports.useMetricsOrMetricsById = useMetricsOrMetricsById;
2290
+ exports.useProvideCheckpoints = useProvideCheckpoints;
2291
+ exports.useProvideIndexes = useProvideIndexes;
2292
+ exports.useProvideMetrics = useProvideMetrics;
2293
+ exports.useProvideQueries = useProvideQueries;
2294
+ exports.useProvideRelationships = useProvideRelationships;
2238
2295
  exports.useProvideStore = useProvideStore;
2239
2296
  exports.useQueries = useQueries;
2240
2297
  exports.useQueriesIds = useQueriesIds;
@@ -55,6 +55,7 @@
55
55
  const arrayMap = (array, cb) => array.map(cb);
56
56
  const arrayIsEmpty = (array) => size(array) == 0;
57
57
  const arrayFilter = (array, cb) => array.filter(cb);
58
+ const arrayWith = (array, index, value) => array.with(index, value);
58
59
 
59
60
  const object = Object;
60
61
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -121,6 +122,17 @@
121
122
  ? thing
122
123
  : thingOrThingId;
123
124
  };
125
+ const useProvideThing = (thingId, thing, offset) => {
126
+ const {12: addExtraThingById, 13: delExtraThingById} =
127
+ useContext$1(Context);
128
+ useEffect$1(() => {
129
+ addExtraThingById == null
130
+ ? void 0
131
+ : addExtraThingById(offset, thingId, thing);
132
+ return () =>
133
+ delExtraThingById == null ? void 0 : delExtraThingById(offset, thingId);
134
+ }, [addExtraThingById, thingId, thing, offset, delExtraThingById]);
135
+ };
124
136
  const useThingIds = (offset) => {
125
137
  var _a;
126
138
  return objIds((_a = useContext$1(Context)[offset]) != null ? _a : {});
@@ -128,29 +140,34 @@
128
140
  const useStore = (id) => useThing(id, 0);
129
141
  const useStoreOrStoreById = (storeOrStoreId) =>
130
142
  useThingOrThingById(storeOrStoreId, 0);
131
- const useProvideStore = (storeId, store) => {
132
- const {12: addExtraStore, 13: delExtraStore} = useContext$1(Context);
133
- useEffect$1(() => {
134
- addExtraStore == null ? void 0 : addExtraStore(storeId, store);
135
- return () => (delExtraStore == null ? void 0 : delExtraStore(storeId));
136
- }, [addExtraStore, storeId, store, delExtraStore]);
137
- };
143
+ const useProvideStore = (storeId, store) =>
144
+ useProvideThing(storeId, store, 0);
138
145
  const useMetrics = (id) => useThing(id, 2);
139
146
  const useMetricsOrMetricsById = (metricsOrMetricsId) =>
140
147
  useThingOrThingById(metricsOrMetricsId, 2);
148
+ const useProvideMetrics = (metricsId, metrics) =>
149
+ useProvideThing(metricsId, metrics, 1);
141
150
  const useIndexes = (id) => useThing(id, 4);
142
151
  const useIndexesOrIndexesById = (indexesOrIndexesId) =>
143
152
  useThingOrThingById(indexesOrIndexesId, 4);
153
+ const useProvideIndexes = (indexesId, indexes) =>
154
+ useProvideThing(indexesId, indexes, 2);
144
155
  const useRelationships = (id) => useThing(id, 6);
145
156
  const useRelationshipsOrRelationshipsById = (
146
157
  relationshipsOrRelationshipsId,
147
158
  ) => useThingOrThingById(relationshipsOrRelationshipsId, 6);
159
+ const useProvideRelationships = (relationshipsId, relationships) =>
160
+ useProvideThing(relationshipsId, relationships, 3);
148
161
  const useQueries = (id) => useThing(id, 8);
149
162
  const useQueriesOrQueriesById = (queriesOrQueriesId) =>
150
163
  useThingOrThingById(queriesOrQueriesId, 8);
164
+ const useProvideQueries = (queriesId, queries) =>
165
+ useProvideThing(queriesId, queries, 4);
151
166
  const useCheckpoints = (id) => useThing(id, 10);
152
167
  const useCheckpointsOrCheckpointsById = (checkpointsOrCheckpointsId) =>
153
168
  useThingOrThingById(checkpointsOrCheckpointsId, 10);
169
+ const useProvideCheckpoints = (checkpointsId, checkpoints) =>
170
+ useProvideThing(checkpointsId, checkpoints, 5);
154
171
 
155
172
  const lower = (str) => str.toLowerCase();
156
173
  lower(LISTENER);
@@ -1753,22 +1770,42 @@
1753
1770
  children,
1754
1771
  }) => {
1755
1772
  const parentValue = useContext(Context);
1756
- const [extraStoresById, setExtraStoresById] = useState({});
1757
- const addExtraStore = useCallback(
1758
- (id, store2) =>
1759
- setExtraStoresById((extraStoresById2) =>
1760
- objGet(extraStoresById2, id) == store2
1761
- ? extraStoresById2
1762
- : __spreadProps(__spreadValues({}, extraStoresById2), {
1763
- [id]: store2,
1764
- }),
1773
+ const [extraThingsById, setExtraThingsById] = useState([
1774
+ {},
1775
+ {},
1776
+ {},
1777
+ {},
1778
+ {},
1779
+ {},
1780
+ ]);
1781
+ const addExtraThingById = useCallback(
1782
+ (thingOffset, id, thing) =>
1783
+ setExtraThingsById((extraThingsById2) =>
1784
+ objGet(extraThingsById2[thingOffset], id) == thing
1785
+ ? extraThingsById2
1786
+ : arrayWith(
1787
+ extraThingsById2,
1788
+ thingOffset,
1789
+ __spreadProps(
1790
+ __spreadValues({}, extraThingsById2[thingOffset]),
1791
+ {
1792
+ [id]: thing,
1793
+ },
1794
+ ),
1795
+ ),
1765
1796
  ),
1766
1797
  [],
1767
1798
  );
1768
- const delExtraStore = useCallback(
1769
- (id) =>
1770
- setExtraStoresById((extraStoresById2) =>
1771
- __spreadValues({}, objDel(extraStoresById2, id)),
1799
+ const delExtraThingById = useCallback(
1800
+ (thingOffset, id) =>
1801
+ setExtraThingsById((extraThingsById2) =>
1802
+ !objHas(extraThingsById2[thingOffset], id)
1803
+ ? extraThingsById2
1804
+ : arrayWith(
1805
+ extraThingsById2,
1806
+ thingOffset,
1807
+ objDel(extraThingsById2[thingOffset], id),
1808
+ ),
1772
1809
  ),
1773
1810
  [],
1774
1811
  );
@@ -1780,31 +1817,46 @@
1780
1817
  store != null ? store : parentValue[0],
1781
1818
  __spreadValues(
1782
1819
  __spreadValues(__spreadValues({}, parentValue[1]), storesById),
1783
- extraStoresById,
1820
+ extraThingsById[0],
1784
1821
  ),
1785
1822
  metrics != null ? metrics : parentValue[2],
1786
- __spreadValues(__spreadValues({}, parentValue[3]), metricsById),
1823
+ __spreadValues(
1824
+ __spreadValues(__spreadValues({}, parentValue[3]), metricsById),
1825
+ extraThingsById[1],
1826
+ ),
1787
1827
  indexes != null ? indexes : parentValue[4],
1788
- __spreadValues(__spreadValues({}, parentValue[5]), indexesById),
1828
+ __spreadValues(
1829
+ __spreadValues(__spreadValues({}, parentValue[5]), indexesById),
1830
+ extraThingsById[2],
1831
+ ),
1789
1832
  relationships != null ? relationships : parentValue[6],
1790
1833
  __spreadValues(
1791
- __spreadValues({}, parentValue[7]),
1792
- relationshipsById,
1834
+ __spreadValues(
1835
+ __spreadValues({}, parentValue[7]),
1836
+ relationshipsById,
1837
+ ),
1838
+ extraThingsById[3],
1793
1839
  ),
1794
1840
  queries != null ? queries : parentValue[8],
1795
- __spreadValues(__spreadValues({}, parentValue[9]), queriesById),
1841
+ __spreadValues(
1842
+ __spreadValues(__spreadValues({}, parentValue[9]), queriesById),
1843
+ extraThingsById[4],
1844
+ ),
1796
1845
  checkpoints != null ? checkpoints : parentValue[10],
1797
1846
  __spreadValues(
1798
- __spreadValues({}, parentValue[11]),
1799
- checkpointsById,
1847
+ __spreadValues(
1848
+ __spreadValues({}, parentValue[11]),
1849
+ checkpointsById,
1850
+ ),
1851
+ extraThingsById[5],
1800
1852
  ),
1801
- addExtraStore,
1802
- delExtraStore,
1853
+ addExtraThingById,
1854
+ delExtraThingById,
1803
1855
  ],
1804
1856
  [
1805
1857
  store,
1806
1858
  storesById,
1807
- extraStoresById,
1859
+ extraThingsById,
1808
1860
  metrics,
1809
1861
  metricsById,
1810
1862
  indexes,
@@ -1816,8 +1868,8 @@
1816
1868
  checkpoints,
1817
1869
  checkpointsById,
1818
1870
  parentValue,
1819
- addExtraStore,
1820
- delExtraStore,
1871
+ addExtraThingById,
1872
+ delExtraThingById,
1821
1873
  ],
1822
1874
  ),
1823
1875
  },
@@ -2235,6 +2287,11 @@
2235
2287
  exports.useMetrics = useMetrics;
2236
2288
  exports.useMetricsIds = useMetricsIds;
2237
2289
  exports.useMetricsOrMetricsById = useMetricsOrMetricsById;
2290
+ exports.useProvideCheckpoints = useProvideCheckpoints;
2291
+ exports.useProvideIndexes = useProvideIndexes;
2292
+ exports.useProvideMetrics = useProvideMetrics;
2293
+ exports.useProvideQueries = useProvideQueries;
2294
+ exports.useProvideRelationships = useProvideRelationships;
2238
2295
  exports.useProvideStore = useProvideStore;
2239
2296
  exports.useQueries = useQueries;
2240
2297
  exports.useQueriesIds = useQueriesIds;
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",a="Ids",i="Table",c=i+"s",I=i+a,C="Row",b=C+"Count",p=C+a,w="Sorted"+C+a,R="Cell",k=R+a,g="Value",h=g+"s",y=g+a,L=globalThis,m=e=>null==e,S=(e,s,t)=>m(e)?t?.():s(e),T=e=>t(e)==r,V=e=>t(e)==u,f=e=>e.length,v=()=>{},x=(e,s)=>e.every(s),P=(e,s)=>f(e)===f(s)&&x(e,((e,t)=>s[t]===e)),q=(e,s)=>e.map(s),B=Object,H=e=>B.getPrototypeOf(e),M=B.entries,D=e=>!m(e)&&S(H(e),(e=>e==B.prototype||m(H(e))),(()=>!0)),F=B.keys,O=(e,s)=>S(e,(e=>e[s])),Q=(e,s)=>(delete e[s],e),E=(e,s)=>{const t=M(e);return f(t)===f(F(s))&&x(t,(([e,t])=>D(t)?!!D(s[e])&&E(s[e],t):s[e]===t))},{createContext:A,useContext:G,useEffect:j}=s,U=(_=()=>A([]),((e,s)=>s in e)(W=L,z="tinybase_uirc")||(W[z]=_()),W[z]);var W,z,_;const J=(e,s)=>{const t=G(U);return m(e)?t[s]:T(e)?O(t[s+1]??{},e):e},K=(e,s)=>{const t=J(e,s);return m(e)||T(e)?t:e},N=e=>F(G(U)[e]??{}),X=e=>K(e,0),Y=e=>K(e,2),Z=e=>K(e,4),$=e=>K(e,6),ee=e=>K(e,8),se=e=>K(e,10),te=e=>e.toLowerCase();te(l);const oe="Transaction";te(oe);const{useCallback:re,useEffect:ue,useMemo:le,useLayoutEffect:ne,useRef:de,useState:ae,useSyncExternalStore:ie}=s,ce=[],Ie=[{},[],[ce,void 0,ce],void 0,!1,0],Ce=[E,P,([e,s,t],[o,r,u])=>s===r&&P(e,o)&&P(t,u)],be=(e,s)=>e===s,pe=(e,s,t=ce)=>{const[,o]=ae(),[r,u]=ae();return ue((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},we=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},Re=(e,s,t,r=ce)=>{const u=de(Ie[t]),l=re((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??Ie[t];return(Ce[t]??be)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=re((u=>we(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return ie(n,l)},ke=(e,s,t,o=ce,r=ce,...u)=>ne((()=>we(s,e,...r,t,...u)),[s,e,...r,...o,...u]),ge=(e,s,t,o=ce,r=v,u=ce,...l)=>{const n=X(e);return re((e=>S(n,(o=>S(t(e,o),(t=>r(o["set"+s](...he(l,o,e),t),t)))))),[n,s,...o,...u,...ye(l)])},he=(e,s,t)=>q(e,(e=>V(e)?e(t,s):e)),ye=e=>{return s=e=>!V(e),e.filter(s);var s},Le=(e,s,t=v,o=ce,...r)=>{const u=X(e);return re((e=>t(u?.["del"+s](...he(r,u,e)))),[u,s,...o,...ye(r)])},me=(e,s,t)=>{const o=se(e);return re((()=>o?.[s](t)),[o,s,t])},Se=e=>Re(I,X(e),1),Te=(e,s)=>Re(p,X(s),1,[e]),Ve=(e,s,t,o=0,r,u)=>Re(w,X(u),1,[e,s,t,o,r]),fe=(e,s,t)=>Re(k,X(t),1,[e,s]),ve=(e,s,t,o)=>Re(R,X(o),3,[e,s,t]),xe=e=>Re(y,X(e),1),Pe=(e,s)=>Re(g,X(s),3,[e]),qe=(e,s)=>Re("Metric",Y(s),3,[e]),Be=(e,s)=>Re("SliceIds",Z(s),1,[e]),He=(e,s,t)=>Re("Slice"+p,Z(t),1,[e,s]),Me=(e,s,t)=>Re("RemoteRowId",$(t),3,[e,s]),De=(e,s,t)=>Re("Local"+p,$(t),1,[e,s]),Fe=(e,s,t)=>Re("Linked"+p,$(t),1,[e,s]),Oe=(e,s)=>Re(n+p,ee(s),1,[e]),Qe=(e,s,t,o=0,r,u)=>Re(n+w,ee(u),1,[e,s,t,o,r]),Ee=(e,s,t)=>Re(n+k,ee(t),1,[e,s]),Ae=(e,s,t,o)=>Re(n+R,ee(o),3,[e,s,t]),Ge=e=>Re("CheckpointIds",se(e),2),je=(e,s)=>Re("Checkpoint",se(s),3,[e]),Ue=e=>me(e,"goBackward"),We=e=>me(e,"goForward"),{PureComponent:ze,Fragment:_e,createElement:Je,useCallback:Ke,useLayoutEffect:Ne,useRef:Xe,useState:Ye}=s,Ze=(e,...s)=>m(e)?{}:e(...s),$e=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:es,useContext:ss,useMemo:ts,useState:os}=s,rs=({tableId:e,store:s,rowComponent:t=is,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>ds(q(n,(u=>Je(t,{...Ze(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),us=({queryId:e,queries:s,resultRowComponent:t=ps,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>ds(q(l,(r=>Je(t,{...Ze(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ls=({relationshipId:e,relationships:s,rowComponent:t=is,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=$e($(s),e),c=l(e,n,d);return ds(q(c,(e=>Je(t,{...Ze(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},ns=e=>({checkpoints:s,checkpointComponent:t=ws,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=se(s);return ds(q(e(Ge(l)),(e=>Je(t,{...Ze(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},ds=(e,s,t,o)=>{const r=m(s)||!Array.isArray(e)?e:q(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},as=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>ds(o+(ve(e,s,t,r)??o),void 0,u,t),is=({tableId:e,rowId:s,store:t,cellComponent:o=as,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>ds(q(((e,s,t,o)=>{const r=fe(s,t,o);return e??r})(u,e,s,t),(u=>Je(o,{...Ze(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),cs=e=>rs(e,Te(e.tableId,e.store)),Is=({valueId:e,store:s,debugIds:t})=>ds(o+(Pe(e,s)??o),void 0,t,e),Cs=({indexId:e,sliceId:s,indexes:t,rowComponent:o=is,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(Z(t),e),i=He(e,s,n);return ds(q(i,(e=>Je(o,{...Ze(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},bs=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>ds(o+(Ae(e,s,t,r)??o),void 0,u,t),ps=({queryId:e,rowId:s,queries:t,resultCellComponent:o=bs,getResultCellComponentProps:r,separator:u,debugIds:l})=>ds(q(Ee(e,s,t),(u=>Je(o,{...Ze(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),ws=({checkpoints:e,checkpointId:s,debugIds:t})=>ds(je(s,e)??o,void 0,t,s),Rs=ns((e=>e[0])),ks=ns((e=>m(e[1])?[]:[e[1]])),gs=ns((e=>e[2]));e.BackwardCheckpointsView=Rs,e.CellView=as,e.CheckpointView=ws,e.CurrentCheckpointView=ks,e.ForwardCheckpointsView=gs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Cs,getSliceComponentProps:o,separator:r,debugIds:u})=>ds(q(Be(e,s),(r=>Je(t,{...Ze(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>ls(e,Fe,e.firstRowId),e.LocalRowsView=e=>ls(e,De,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>ds(qe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:a,checkpoints:i,checkpointsById:c,children:I})=>{const C=ss(U),[b,p]=os({}),w=es(((e,s)=>p((t=>O(t,e)==s?t:{...t,[e]:s}))),[]),R=es((e=>p((s=>({...Q(s,e)})))),[]);return Je(U.Provider,{value:ts((()=>[e??C[0],{...C[1],...s,...b},t??C[2],{...C[3],...o},r??C[4],{...C[5],...u},l??C[6],{...C[7],...n},d??C[8],{...C[9],...a},i??C[10],{...C[11],...c},w,R]),[e,s,b,t,o,r,u,l,n,d,a,i,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=is,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=$e($(t),e),a=Me(e,s,l);return ds(m(d)||m(a)?null:Je(o,{...Ze(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=bs,e.ResultRowView=ps,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>us(r,Qe(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>us(e,Oe(e.queryId,e.queries)),e.RowView=is,e.SliceView=Cs,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>rs(r,Ve(r.tableId,e,s,t,o,r.store)),e.TableView=cs,e.TablesView=({store:e,tableComponent:s=cs,getTableComponentProps:t,separator:o,debugIds:r})=>ds(q(Se(e),(o=>Je(s,{...Ze(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=Is,e.ValuesView=({store:e,valueComponent:s=Is,getValueComponentProps:t,separator:o,debugIds:r})=>ds(q(xe(e),(o=>Je(s,{...Ze(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=ce,o,r=v,u=ce,l=!0)=>{const n=X(o);return re((t=>S(n,(o=>S(s(t,o),(s=>r(o.addRow(V(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=ve,e.useCellIds=fe,e.useCellIdsListener=(e,s,t,o,r,u)=>ke(k,X(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>ke(R,X(l),o,r,[e,s,t],u),e.useCheckpoint=je,e.useCheckpointIds=Ge,e.useCheckpointIdsListener=(e,s,t)=>ke("CheckpointIds",se(t),e,s),e.useCheckpointListener=(e,s,t,o)=>ke("Checkpoint",se(o),s,t,[e]),e.useCheckpoints=e=>J(e,10),e.useCheckpointsIds=()=>N(11),e.useCheckpointsOrCheckpointsById=se,e.useCreateCheckpoints=(e,s,t)=>pe(e,s,t),e.useCreateIndexes=(e,s,t)=>pe(e,s,t),e.useCreateMergeableStore=(e,s=ce)=>le(e,s),e.useCreateMetrics=(e,s,t)=>pe(e,s,t),e.useCreatePersister=(e,s,t=ce,o,r=ce,u,l=ce)=>{const[,n]=ae(),[d,a]=ae();return ue((()=>{(async()=>{const t=e?await s(e):void 0;a(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),ue((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>pe(e,s,t),e.useCreateRelationships=(e,s,t)=>pe(e,s,t),e.useCreateStore=(e,s=ce)=>le(e,s),e.useCreateSynchronizer=(e,s,t=ce,o,r=ce)=>{const[u,l]=ae();return ue((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),ue((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>Le(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>Le(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>Le(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>Le(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>Le(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>Le(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>ke("DidFinish"+oe,X(t),e,s),e.useGoBackwardCallback=Ue,e.useGoForwardCallback=We,e.useGoToCallback=(e,s=ce,t,o=v,r=ce)=>{const u=se(t);return re((s=>S(u,(t=>S(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>Re(R,X(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>ke(d+R,X(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>Re(C,X(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>ke(d+C,X(u),t,o,[e,s],r),e.useHasTable=(e,s)=>Re(i,X(s),4,[e]),e.useHasTableCell=(e,s,t)=>Re(i+R,X(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>ke(d+i+R,X(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>ke(d+i,X(r),s,t,[e],o),e.useHasTables=e=>Re(c,X(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>ke(d+c,X(o),e,s,[],t),e.useHasValue=(e,s)=>Re(g,X(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>ke(d+g,X(r),s,t,[e],o),e.useHasValues=e=>Re(h,X(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>ke(d+h,X(o),e,s,[],t),e.useIndexIds=e=>Re("IndexIds",Z(e),1),e.useIndexes=e=>J(e,4),e.useIndexesIds=()=>N(5),e.useIndexesOrIndexesById=Z,e.useLinkedRowIds=Fe,e.useLinkedRowIdsListener=(e,s,t,o,r)=>ke("Linked"+p,$(r),t,o,[e,s]),e.useLocalRowIds=De,e.useLocalRowIdsListener=(e,s,t,o,r)=>ke("Local"+p,$(r),t,o,[e,s]),e.useMetric=qe,e.useMetricIds=e=>Re("MetricIds",Y(e),1),e.useMetricListener=(e,s,t,o)=>ke("Metric",Y(o),s,t,[e]),e.useMetrics=e=>J(e,2),e.useMetricsIds=()=>N(3),e.useMetricsOrMetricsById=Y,e.useProvideStore=(e,s)=>{const{12:t,13:o}=G(U);j((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>J(e,8),e.useQueriesIds=()=>N(9),e.useQueriesOrQueriesById=ee,e.useQueryIds=e=>Re("QueryIds",ee(e),1),e.useRedoInformation=e=>{const s=se(e),[,,[t]]=Ge(s);return[!m(t),We(s),t,S(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>Re("RelationshipIds",$(e),1),e.useRelationships=e=>J(e,6),e.useRelationshipsIds=()=>N(7),e.useRelationshipsOrRelationshipsById=$,e.useRemoteRowId=Me,e.useRemoteRowIdListener=(e,s,t,o,r)=>ke("RemoteRowId",$(r),t,o,[e,s]),e.useResultCell=Ae,e.useResultCellIds=Ee,e.useResultCellIdsListener=(e,s,t,o,r)=>ke(n+k,ee(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>ke(n+R,ee(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>Re(n+C,ee(t),0,[e,s]),e.useResultRowCount=(e,s)=>Re(n+b,ee(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>ke(n+b,ee(o),s,t,[e]),e.useResultRowIds=Oe,e.useResultRowIdsListener=(e,s,t,o)=>ke(n+p,ee(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>ke(n+C,ee(r),t,o,[e,s]),e.useResultSortedRowIds=Qe,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>ke(n+w,ee(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>Re(n+i,ee(s),0,[e]),e.useResultTableCellIds=(e,s)=>Re(n+i+k,ee(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>ke(n+i+k,ee(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>ke(n+i,ee(o),s,t,[e]),e.useRow=(e,s,t)=>Re(C,X(t),0,[e,s]),e.useRowCount=(e,s)=>Re(b,X(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>ke(b,X(r),s,t,[e],o),e.useRowIds=Te,e.useRowIdsListener=(e,s,t,o,r)=>ke(p,X(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>ke(C,X(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>ge(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=v,s=ce,t,o=v,r=ce)=>{const u=se(t);return re((s=>S(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>ge(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>ge(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>ge(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>ge(o,i,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>ge(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>ge(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>ge(t,h,e,s,o,r),e.useSliceIds=Be,e.useSliceIdsListener=(e,s,t,o)=>ke("SliceIds",Z(o),s,t,[e]),e.useSliceRowIds=He,e.useSliceRowIdsListener=(e,s,t,o,r)=>ke("Slice"+p,Z(r),t,o,[e,s]),e.useSortedRowIds=Ve,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>ke(w,X(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>ke("Start"+oe,X(t),e,s),e.useStore=e=>J(e,0),e.useStoreIds=()=>N(1),e.useStoreOrStoreById=X,e.useTable=(e,s)=>Re(i,X(s),0,[e]),e.useTableCellIds=(e,s)=>Re(i+k,X(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>ke(i+k,X(r),s,t,[e],o),e.useTableIds=Se,e.useTableIdsListener=(e,s,t,o)=>ke(I,X(o),e,s,ce,t),e.useTableListener=(e,s,t,o,r)=>ke(i,X(r),s,t,[e],o),e.useTables=e=>Re(c,X(e),0),e.useTablesListener=(e,s,t,o)=>ke(c,X(o),e,s,ce,t),e.useUndoInformation=e=>{const s=se(e),[t,r]=Ge(s);return[(u=t,!(0==f(u))),Ue(s),r,S(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Pe,e.useValueIds=xe,e.useValueIdsListener=(e,s,t,o)=>ke(y,X(o),e,s,ce,t),e.useValueListener=(e,s,t,o,r)=>ke(g,X(r),s,t,[e],o),e.useValues=e=>Re(h,X(e),0),e.useValuesListener=(e,s,t,o)=>ke(h,X(o),e,s,ce,t),e.useWillFinishTransactionListener=(e,s,t)=>ke("WillFinish"+oe,X(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",i="Ids",a="Table",c=a+"s",I=a+i,C="Row",p=C+"Count",b=C+i,w="Sorted"+C+i,R="Cell",k=R+i,g="Value",h=g+"s",y=g+i,L=globalThis,m=e=>null==e,S=(e,s,t)=>m(e)?t?.():s(e),T=e=>t(e)==r,V=e=>t(e)==u,f=e=>e.length,v=()=>{},P=(e,s)=>e.every(s),x=(e,s)=>f(e)===f(s)&&P(e,((e,t)=>s[t]===e)),q=(e,s)=>e.map(s),B=(e,s,t)=>e.with(s,t),M=Object,H=e=>M.getPrototypeOf(e),D=M.entries,F=e=>!m(e)&&S(H(e),(e=>e==M.prototype||m(H(e))),(()=>!0)),O=M.keys,Q=(e,s)=>S(e,(e=>e[s])),E=(e,s)=>s in e,A=(e,s)=>{const t=D(e);return f(t)===f(O(s))&&P(t,(([e,t])=>F(t)?!!F(s[e])&&A(s[e],t):s[e]===t))},{createContext:G,useContext:j,useEffect:U}=s,W=(J=()=>G([]),E(z=L,_="tinybase_uirc")||(z[_]=J()),z[_]);var z,_,J;const K=(e,s)=>{const t=j(W);return m(e)?t[s]:T(e)?Q(t[s+1]??{},e):e},N=(e,s)=>{const t=K(e,s);return m(e)||T(e)?t:e},X=(e,s,t)=>{const{12:o,13:r}=j(W);U((()=>(o?.(t,e,s),()=>r?.(t,e))),[o,e,s,t,r])},Y=e=>O(j(W)[e]??{}),Z=e=>N(e,0),$=e=>N(e,2),ee=e=>N(e,4),se=e=>N(e,6),te=e=>N(e,8),oe=e=>N(e,10),re=e=>e.toLowerCase();re(l);const ue="Transaction";re(ue);const{useCallback:le,useEffect:ne,useMemo:de,useLayoutEffect:ie,useRef:ae,useState:ce,useSyncExternalStore:Ie}=s,Ce=[],pe=[{},[],[Ce,void 0,Ce],void 0,!1,0],be=[A,x,([e,s,t],[o,r,u])=>s===r&&x(e,o)&&x(t,u)],we=(e,s)=>e===s,Re=(e,s,t=Ce)=>{const[,o]=ce(),[r,u]=ce();return ne((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},ke=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},ge=(e,s,t,r=Ce)=>{const u=ae(pe[t]),l=le((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??pe[t];return(be[t]??we)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=le((u=>ke(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return Ie(n,l)},he=(e,s,t,o=Ce,r=Ce,...u)=>ie((()=>ke(s,e,...r,t,...u)),[s,e,...r,...o,...u]),ye=(e,s,t,o=Ce,r=v,u=Ce,...l)=>{const n=Z(e);return le((e=>S(n,(o=>S(t(e,o),(t=>r(o["set"+s](...Le(l,o,e),t),t)))))),[n,s,...o,...u,...me(l)])},Le=(e,s,t)=>q(e,(e=>V(e)?e(t,s):e)),me=e=>{return s=e=>!V(e),e.filter(s);var s},Se=(e,s,t=v,o=Ce,...r)=>{const u=Z(e);return le((e=>t(u?.["del"+s](...Le(r,u,e)))),[u,s,...o,...me(r)])},Te=(e,s,t)=>{const o=oe(e);return le((()=>o?.[s](t)),[o,s,t])},Ve=e=>ge(I,Z(e),1),fe=(e,s)=>ge(b,Z(s),1,[e]),ve=(e,s,t,o=0,r,u)=>ge(w,Z(u),1,[e,s,t,o,r]),Pe=(e,s,t)=>ge(k,Z(t),1,[e,s]),xe=(e,s,t,o)=>ge(R,Z(o),3,[e,s,t]),qe=e=>ge(y,Z(e),1),Be=(e,s)=>ge(g,Z(s),3,[e]),Me=(e,s)=>ge("Metric",$(s),3,[e]),He=(e,s)=>ge("SliceIds",ee(s),1,[e]),De=(e,s,t)=>ge("Slice"+b,ee(t),1,[e,s]),Fe=(e,s,t)=>ge("RemoteRowId",se(t),3,[e,s]),Oe=(e,s,t)=>ge("Local"+b,se(t),1,[e,s]),Qe=(e,s,t)=>ge("Linked"+b,se(t),1,[e,s]),Ee=(e,s)=>ge(n+b,te(s),1,[e]),Ae=(e,s,t,o=0,r,u)=>ge(n+w,te(u),1,[e,s,t,o,r]),Ge=(e,s,t)=>ge(n+k,te(t),1,[e,s]),je=(e,s,t,o)=>ge(n+R,te(o),3,[e,s,t]),Ue=e=>ge("CheckpointIds",oe(e),2),We=(e,s)=>ge("Checkpoint",oe(s),3,[e]),ze=e=>Te(e,"goBackward"),_e=e=>Te(e,"goForward"),{PureComponent:Je,Fragment:Ke,createElement:Ne,useCallback:Xe,useLayoutEffect:Ye,useRef:Ze,useState:$e}=s,es=(e,...s)=>m(e)?{}:e(...s),ss=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:ts,useContext:os,useMemo:rs,useState:us}=s,ls=({tableId:e,store:s,rowComponent:t=Is,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>as(q(n,(u=>Ne(t,{...es(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),ns=({queryId:e,queries:s,resultRowComponent:t=Rs,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>as(q(l,(r=>Ne(t,{...es(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ds=({relationshipId:e,relationships:s,rowComponent:t=Is,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,i,a]=ss(se(s),e),c=l(e,n,d);return as(q(c,(e=>Ne(t,{...es(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:u}))),r,u,n)},is=e=>({checkpoints:s,checkpointComponent:t=ks,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=oe(s);return as(q(e(Ue(l)),(e=>Ne(t,{...es(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},as=(e,s,t,o)=>{const r=m(s)||!Array.isArray(e)?e:q(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},cs=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>as(o+(xe(e,s,t,r)??o),void 0,u,t),Is=({tableId:e,rowId:s,store:t,cellComponent:o=cs,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>as(q(((e,s,t,o)=>{const r=Pe(s,t,o);return e??r})(u,e,s,t),(u=>Ne(o,{...es(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),Cs=e=>ls(e,fe(e.tableId,e.store)),ps=({valueId:e,store:s,debugIds:t})=>as(o+(Be(e,s)??o),void 0,t,e),bs=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Is,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(ee(t),e),a=De(e,s,n);return as(q(a,(e=>Ne(o,{...es(r,e),key:e,tableId:i,rowId:e,store:d,debugIds:l}))),u,l,s)},ws=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>as(o+(je(e,s,t,r)??o),void 0,u,t),Rs=({queryId:e,rowId:s,queries:t,resultCellComponent:o=ws,getResultCellComponentProps:r,separator:u,debugIds:l})=>as(q(Ge(e,s,t),(u=>Ne(o,{...es(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),ks=({checkpoints:e,checkpointId:s,debugIds:t})=>as(We(s,e)??o,void 0,t,s),gs=is((e=>e[0])),hs=is((e=>m(e[1])?[]:[e[1]])),ys=is((e=>e[2]));e.BackwardCheckpointsView=gs,e.CellView=cs,e.CheckpointView=ks,e.CurrentCheckpointView=hs,e.ForwardCheckpointsView=ys,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=bs,getSliceComponentProps:o,separator:r,debugIds:u})=>as(q(He(e,s),(r=>Ne(t,{...es(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>ds(e,Qe,e.firstRowId),e.LocalRowsView=e=>ds(e,Oe,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>as(Me(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const C=os(W),[p,b]=us([{},{},{},{},{},{}]),w=ts(((e,s,t)=>b((o=>Q(o[e],s)==t?o:B(o,e,{...o[e],[s]:t})))),[]),R=ts(((e,s)=>b((t=>E(t[e],s)?B(t,e,((e,s)=>(delete e[s],e))(t[e],s)):t))),[]);return Ne(W.Provider,{value:rs((()=>[e??C[0],{...C[1],...s,...p[0]},t??C[2],{...C[3],...o,...p[1]},r??C[4],{...C[5],...u,...p[2]},l??C[6],{...C[7],...n,...p[3]},d??C[8],{...C[9],...i,...p[4]},a??C[10],{...C[11],...c,...p[5]},w,R]),[e,s,p,t,o,r,u,l,n,d,i,a,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Is,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=ss(se(t),e),i=Fe(e,s,l);return as(m(d)||m(i)?null:Ne(o,{...es(r,i),key:i,tableId:d,rowId:i,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=ws,e.ResultRowView=Rs,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ns(r,Ae(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>ns(e,Ee(e.queryId,e.queries)),e.RowView=Is,e.SliceView=bs,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ls(r,ve(r.tableId,e,s,t,o,r.store)),e.TableView=Cs,e.TablesView=({store:e,tableComponent:s=Cs,getTableComponentProps:t,separator:o,debugIds:r})=>as(q(Ve(e),(o=>Ne(s,{...es(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=ps,e.ValuesView=({store:e,valueComponent:s=ps,getValueComponentProps:t,separator:o,debugIds:r})=>as(q(qe(e),(o=>Ne(s,{...es(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=Ce,o,r=v,u=Ce,l=!0)=>{const n=Z(o);return le((t=>S(n,(o=>S(s(t,o),(s=>r(o.addRow(V(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=xe,e.useCellIds=Pe,e.useCellIdsListener=(e,s,t,o,r,u)=>he(k,Z(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>he(R,Z(l),o,r,[e,s,t],u),e.useCheckpoint=We,e.useCheckpointIds=Ue,e.useCheckpointIdsListener=(e,s,t)=>he("CheckpointIds",oe(t),e,s),e.useCheckpointListener=(e,s,t,o)=>he("Checkpoint",oe(o),s,t,[e]),e.useCheckpoints=e=>K(e,10),e.useCheckpointsIds=()=>Y(11),e.useCheckpointsOrCheckpointsById=oe,e.useCreateCheckpoints=(e,s,t)=>Re(e,s,t),e.useCreateIndexes=(e,s,t)=>Re(e,s,t),e.useCreateMergeableStore=(e,s=Ce)=>de(e,s),e.useCreateMetrics=(e,s,t)=>Re(e,s,t),e.useCreatePersister=(e,s,t=Ce,o,r=Ce,u,l=Ce)=>{const[,n]=ce(),[d,i]=ce();return ne((()=>{(async()=>{const t=e?await s(e):void 0;i(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),ne((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>Re(e,s,t),e.useCreateRelationships=(e,s,t)=>Re(e,s,t),e.useCreateStore=(e,s=Ce)=>de(e,s),e.useCreateSynchronizer=(e,s,t=Ce,o,r=Ce)=>{const[u,l]=ce();return ne((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),ne((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>Se(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>Se(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>Se(s,a,t,o,e),e.useDelTablesCallback=(e,s,t)=>Se(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>Se(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>Se(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>he("DidFinish"+ue,Z(t),e,s),e.useGoBackwardCallback=ze,e.useGoForwardCallback=_e,e.useGoToCallback=(e,s=Ce,t,o=v,r=Ce)=>{const u=oe(t);return le((s=>S(u,(t=>S(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>ge(R,Z(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>he(d+R,Z(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>ge(C,Z(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>he(d+C,Z(u),t,o,[e,s],r),e.useHasTable=(e,s)=>ge(a,Z(s),4,[e]),e.useHasTableCell=(e,s,t)=>ge(a+R,Z(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>he(d+a+R,Z(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>he(d+a,Z(r),s,t,[e],o),e.useHasTables=e=>ge(c,Z(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>he(d+c,Z(o),e,s,[],t),e.useHasValue=(e,s)=>ge(g,Z(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>he(d+g,Z(r),s,t,[e],o),e.useHasValues=e=>ge(h,Z(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>he(d+h,Z(o),e,s,[],t),e.useIndexIds=e=>ge("IndexIds",ee(e),1),e.useIndexes=e=>K(e,4),e.useIndexesIds=()=>Y(5),e.useIndexesOrIndexesById=ee,e.useLinkedRowIds=Qe,e.useLinkedRowIdsListener=(e,s,t,o,r)=>he("Linked"+b,se(r),t,o,[e,s]),e.useLocalRowIds=Oe,e.useLocalRowIdsListener=(e,s,t,o,r)=>he("Local"+b,se(r),t,o,[e,s]),e.useMetric=Me,e.useMetricIds=e=>ge("MetricIds",$(e),1),e.useMetricListener=(e,s,t,o)=>he("Metric",$(o),s,t,[e]),e.useMetrics=e=>K(e,2),e.useMetricsIds=()=>Y(3),e.useMetricsOrMetricsById=$,e.useProvideCheckpoints=(e,s)=>X(e,s,5),e.useProvideIndexes=(e,s)=>X(e,s,2),e.useProvideMetrics=(e,s)=>X(e,s,1),e.useProvideQueries=(e,s)=>X(e,s,4),e.useProvideRelationships=(e,s)=>X(e,s,3),e.useProvideStore=(e,s)=>X(e,s,0),e.useQueries=e=>K(e,8),e.useQueriesIds=()=>Y(9),e.useQueriesOrQueriesById=te,e.useQueryIds=e=>ge("QueryIds",te(e),1),e.useRedoInformation=e=>{const s=oe(e),[,,[t]]=Ue(s);return[!m(t),_e(s),t,S(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>ge("RelationshipIds",se(e),1),e.useRelationships=e=>K(e,6),e.useRelationshipsIds=()=>Y(7),e.useRelationshipsOrRelationshipsById=se,e.useRemoteRowId=Fe,e.useRemoteRowIdListener=(e,s,t,o,r)=>he("RemoteRowId",se(r),t,o,[e,s]),e.useResultCell=je,e.useResultCellIds=Ge,e.useResultCellIdsListener=(e,s,t,o,r)=>he(n+k,te(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>he(n+R,te(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>ge(n+C,te(t),0,[e,s]),e.useResultRowCount=(e,s)=>ge(n+p,te(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>he(n+p,te(o),s,t,[e]),e.useResultRowIds=Ee,e.useResultRowIdsListener=(e,s,t,o)=>he(n+b,te(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>he(n+C,te(r),t,o,[e,s]),e.useResultSortedRowIds=Ae,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>he(n+w,te(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>ge(n+a,te(s),0,[e]),e.useResultTableCellIds=(e,s)=>ge(n+a+k,te(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>he(n+a+k,te(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>he(n+a,te(o),s,t,[e]),e.useRow=(e,s,t)=>ge(C,Z(t),0,[e,s]),e.useRowCount=(e,s)=>ge(p,Z(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>he(p,Z(r),s,t,[e],o),e.useRowIds=fe,e.useRowIdsListener=(e,s,t,o,r)=>he(b,Z(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>he(C,Z(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>ye(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=v,s=Ce,t,o=v,r=Ce)=>{const u=oe(t);return le((s=>S(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>ye(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>ye(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>ye(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>ye(o,a,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>ye(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>ye(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>ye(t,h,e,s,o,r),e.useSliceIds=He,e.useSliceIdsListener=(e,s,t,o)=>he("SliceIds",ee(o),s,t,[e]),e.useSliceRowIds=De,e.useSliceRowIdsListener=(e,s,t,o,r)=>he("Slice"+b,ee(r),t,o,[e,s]),e.useSortedRowIds=ve,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>he(w,Z(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>he("Start"+ue,Z(t),e,s),e.useStore=e=>K(e,0),e.useStoreIds=()=>Y(1),e.useStoreOrStoreById=Z,e.useTable=(e,s)=>ge(a,Z(s),0,[e]),e.useTableCellIds=(e,s)=>ge(a+k,Z(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>he(a+k,Z(r),s,t,[e],o),e.useTableIds=Ve,e.useTableIdsListener=(e,s,t,o)=>he(I,Z(o),e,s,Ce,t),e.useTableListener=(e,s,t,o,r)=>he(a,Z(r),s,t,[e],o),e.useTables=e=>ge(c,Z(e),0),e.useTablesListener=(e,s,t,o)=>he(c,Z(o),e,s,Ce,t),e.useUndoInformation=e=>{const s=oe(e),[t,r]=Ue(s);return[(u=t,!(0==f(u))),ze(s),r,S(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Be,e.useValueIds=qe,e.useValueIdsListener=(e,s,t,o)=>he(y,Z(o),e,s,Ce,t),e.useValueListener=(e,s,t,o,r)=>he(g,Z(r),s,t,[e],o),e.useValues=e=>ge(h,Z(e),0),e.useValuesListener=(e,s,t,o)=>he(h,Z(o),e,s,Ce,t),e.useWillFinishTransactionListener=(e,s,t)=>he("WillFinish"+ue,Z(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
Binary file
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",a="Ids",i="Table",c=i+"s",I=i+a,C="Row",b=C+"Count",p=C+a,w="Sorted"+C+a,R="Cell",k=R+a,g="Value",h=g+"s",y=g+a,L=globalThis,m=e=>null==e,S=(e,s,t)=>m(e)?t?.():s(e),T=e=>t(e)==r,V=e=>t(e)==u,f=e=>e.length,v=()=>{},x=(e,s)=>e.every(s),P=(e,s)=>f(e)===f(s)&&x(e,((e,t)=>s[t]===e)),q=(e,s)=>e.map(s),B=Object,H=e=>B.getPrototypeOf(e),M=B.entries,D=e=>!m(e)&&S(H(e),(e=>e==B.prototype||m(H(e))),(()=>!0)),F=B.keys,O=(e,s)=>S(e,(e=>e[s])),Q=(e,s)=>(delete e[s],e),E=(e,s)=>{const t=M(e);return f(t)===f(F(s))&&x(t,(([e,t])=>D(t)?!!D(s[e])&&E(s[e],t):s[e]===t))},{createContext:A,useContext:G,useEffect:j}=s,U=(_=()=>A([]),((e,s)=>s in e)(W=L,z="tinybase_uirc")||(W[z]=_()),W[z]);var W,z,_;const J=(e,s)=>{const t=G(U);return m(e)?t[s]:T(e)?O(t[s+1]??{},e):e},K=(e,s)=>{const t=J(e,s);return m(e)||T(e)?t:e},N=e=>F(G(U)[e]??{}),X=e=>K(e,0),Y=e=>K(e,2),Z=e=>K(e,4),$=e=>K(e,6),ee=e=>K(e,8),se=e=>K(e,10),te=e=>e.toLowerCase();te(l);const oe="Transaction";te(oe);const{useCallback:re,useEffect:ue,useMemo:le,useLayoutEffect:ne,useRef:de,useState:ae,useSyncExternalStore:ie}=s,ce=[],Ie=[{},[],[ce,void 0,ce],void 0,!1,0],Ce=[E,P,([e,s,t],[o,r,u])=>s===r&&P(e,o)&&P(t,u)],be=(e,s)=>e===s,pe=(e,s,t=ce)=>{const[,o]=ae(),[r,u]=ae();return ue((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},we=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},Re=(e,s,t,r=ce)=>{const u=de(Ie[t]),l=re((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??Ie[t];return(Ce[t]??be)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=re((u=>we(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return ie(n,l)},ke=(e,s,t,o=ce,r=ce,...u)=>ne((()=>we(s,e,...r,t,...u)),[s,e,...r,...o,...u]),ge=(e,s,t,o=ce,r=v,u=ce,...l)=>{const n=X(e);return re((e=>S(n,(o=>S(t(e,o),(t=>r(o["set"+s](...he(l,o,e),t),t)))))),[n,s,...o,...u,...ye(l)])},he=(e,s,t)=>q(e,(e=>V(e)?e(t,s):e)),ye=e=>{return s=e=>!V(e),e.filter(s);var s},Le=(e,s,t=v,o=ce,...r)=>{const u=X(e);return re((e=>t(u?.["del"+s](...he(r,u,e)))),[u,s,...o,...ye(r)])},me=(e,s,t)=>{const o=se(e);return re((()=>o?.[s](t)),[o,s,t])},Se=e=>Re(I,X(e),1),Te=(e,s)=>Re(p,X(s),1,[e]),Ve=(e,s,t,o=0,r,u)=>Re(w,X(u),1,[e,s,t,o,r]),fe=(e,s,t)=>Re(k,X(t),1,[e,s]),ve=(e,s,t,o)=>Re(R,X(o),3,[e,s,t]),xe=e=>Re(y,X(e),1),Pe=(e,s)=>Re(g,X(s),3,[e]),qe=(e,s)=>Re("Metric",Y(s),3,[e]),Be=(e,s)=>Re("SliceIds",Z(s),1,[e]),He=(e,s,t)=>Re("Slice"+p,Z(t),1,[e,s]),Me=(e,s,t)=>Re("RemoteRowId",$(t),3,[e,s]),De=(e,s,t)=>Re("Local"+p,$(t),1,[e,s]),Fe=(e,s,t)=>Re("Linked"+p,$(t),1,[e,s]),Oe=(e,s)=>Re(n+p,ee(s),1,[e]),Qe=(e,s,t,o=0,r,u)=>Re(n+w,ee(u),1,[e,s,t,o,r]),Ee=(e,s,t)=>Re(n+k,ee(t),1,[e,s]),Ae=(e,s,t,o)=>Re(n+R,ee(o),3,[e,s,t]),Ge=e=>Re("CheckpointIds",se(e),2),je=(e,s)=>Re("Checkpoint",se(s),3,[e]),Ue=e=>me(e,"goBackward"),We=e=>me(e,"goForward"),{PureComponent:ze,Fragment:_e,createElement:Je,useCallback:Ke,useLayoutEffect:Ne,useRef:Xe,useState:Ye}=s,Ze=(e,...s)=>m(e)?{}:e(...s),$e=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:es,useContext:ss,useMemo:ts,useState:os}=s,rs=({tableId:e,store:s,rowComponent:t=is,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>ds(q(n,(u=>Je(t,{...Ze(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),us=({queryId:e,queries:s,resultRowComponent:t=ps,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>ds(q(l,(r=>Je(t,{...Ze(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ls=({relationshipId:e,relationships:s,rowComponent:t=is,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=$e($(s),e),c=l(e,n,d);return ds(q(c,(e=>Je(t,{...Ze(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},ns=e=>({checkpoints:s,checkpointComponent:t=ws,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=se(s);return ds(q(e(Ge(l)),(e=>Je(t,{...Ze(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},ds=(e,s,t,o)=>{const r=m(s)||!Array.isArray(e)?e:q(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},as=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>ds(o+(ve(e,s,t,r)??o),void 0,u,t),is=({tableId:e,rowId:s,store:t,cellComponent:o=as,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>ds(q(((e,s,t,o)=>{const r=fe(s,t,o);return e??r})(u,e,s,t),(u=>Je(o,{...Ze(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),cs=e=>rs(e,Te(e.tableId,e.store)),Is=({valueId:e,store:s,debugIds:t})=>ds(o+(Pe(e,s)??o),void 0,t,e),Cs=({indexId:e,sliceId:s,indexes:t,rowComponent:o=is,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(Z(t),e),i=He(e,s,n);return ds(q(i,(e=>Je(o,{...Ze(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},bs=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>ds(o+(Ae(e,s,t,r)??o),void 0,u,t),ps=({queryId:e,rowId:s,queries:t,resultCellComponent:o=bs,getResultCellComponentProps:r,separator:u,debugIds:l})=>ds(q(Ee(e,s,t),(u=>Je(o,{...Ze(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),ws=({checkpoints:e,checkpointId:s,debugIds:t})=>ds(je(s,e)??o,void 0,t,s),Rs=ns((e=>e[0])),ks=ns((e=>m(e[1])?[]:[e[1]])),gs=ns((e=>e[2]));e.BackwardCheckpointsView=Rs,e.CellView=as,e.CheckpointView=ws,e.CurrentCheckpointView=ks,e.ForwardCheckpointsView=gs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Cs,getSliceComponentProps:o,separator:r,debugIds:u})=>ds(q(Be(e,s),(r=>Je(t,{...Ze(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>ls(e,Fe,e.firstRowId),e.LocalRowsView=e=>ls(e,De,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>ds(qe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:a,checkpoints:i,checkpointsById:c,children:I})=>{const C=ss(U),[b,p]=os({}),w=es(((e,s)=>p((t=>O(t,e)==s?t:{...t,[e]:s}))),[]),R=es((e=>p((s=>({...Q(s,e)})))),[]);return Je(U.Provider,{value:ts((()=>[e??C[0],{...C[1],...s,...b},t??C[2],{...C[3],...o},r??C[4],{...C[5],...u},l??C[6],{...C[7],...n},d??C[8],{...C[9],...a},i??C[10],{...C[11],...c},w,R]),[e,s,b,t,o,r,u,l,n,d,a,i,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=is,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=$e($(t),e),a=Me(e,s,l);return ds(m(d)||m(a)?null:Je(o,{...Ze(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=bs,e.ResultRowView=ps,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>us(r,Qe(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>us(e,Oe(e.queryId,e.queries)),e.RowView=is,e.SliceView=Cs,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>rs(r,Ve(r.tableId,e,s,t,o,r.store)),e.TableView=cs,e.TablesView=({store:e,tableComponent:s=cs,getTableComponentProps:t,separator:o,debugIds:r})=>ds(q(Se(e),(o=>Je(s,{...Ze(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=Is,e.ValuesView=({store:e,valueComponent:s=Is,getValueComponentProps:t,separator:o,debugIds:r})=>ds(q(xe(e),(o=>Je(s,{...Ze(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=ce,o,r=v,u=ce,l=!0)=>{const n=X(o);return re((t=>S(n,(o=>S(s(t,o),(s=>r(o.addRow(V(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=ve,e.useCellIds=fe,e.useCellIdsListener=(e,s,t,o,r,u)=>ke(k,X(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>ke(R,X(l),o,r,[e,s,t],u),e.useCheckpoint=je,e.useCheckpointIds=Ge,e.useCheckpointIdsListener=(e,s,t)=>ke("CheckpointIds",se(t),e,s),e.useCheckpointListener=(e,s,t,o)=>ke("Checkpoint",se(o),s,t,[e]),e.useCheckpoints=e=>J(e,10),e.useCheckpointsIds=()=>N(11),e.useCheckpointsOrCheckpointsById=se,e.useCreateCheckpoints=(e,s,t)=>pe(e,s,t),e.useCreateIndexes=(e,s,t)=>pe(e,s,t),e.useCreateMergeableStore=(e,s=ce)=>le(e,s),e.useCreateMetrics=(e,s,t)=>pe(e,s,t),e.useCreatePersister=(e,s,t=ce,o,r=ce,u,l=ce)=>{const[,n]=ae(),[d,a]=ae();return ue((()=>{(async()=>{const t=e?await s(e):void 0;a(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),ue((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>pe(e,s,t),e.useCreateRelationships=(e,s,t)=>pe(e,s,t),e.useCreateStore=(e,s=ce)=>le(e,s),e.useCreateSynchronizer=(e,s,t=ce,o,r=ce)=>{const[u,l]=ae();return ue((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),ue((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>Le(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>Le(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>Le(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>Le(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>Le(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>Le(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>ke("DidFinish"+oe,X(t),e,s),e.useGoBackwardCallback=Ue,e.useGoForwardCallback=We,e.useGoToCallback=(e,s=ce,t,o=v,r=ce)=>{const u=se(t);return re((s=>S(u,(t=>S(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>Re(R,X(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>ke(d+R,X(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>Re(C,X(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>ke(d+C,X(u),t,o,[e,s],r),e.useHasTable=(e,s)=>Re(i,X(s),4,[e]),e.useHasTableCell=(e,s,t)=>Re(i+R,X(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>ke(d+i+R,X(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>ke(d+i,X(r),s,t,[e],o),e.useHasTables=e=>Re(c,X(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>ke(d+c,X(o),e,s,[],t),e.useHasValue=(e,s)=>Re(g,X(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>ke(d+g,X(r),s,t,[e],o),e.useHasValues=e=>Re(h,X(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>ke(d+h,X(o),e,s,[],t),e.useIndexIds=e=>Re("IndexIds",Z(e),1),e.useIndexes=e=>J(e,4),e.useIndexesIds=()=>N(5),e.useIndexesOrIndexesById=Z,e.useLinkedRowIds=Fe,e.useLinkedRowIdsListener=(e,s,t,o,r)=>ke("Linked"+p,$(r),t,o,[e,s]),e.useLocalRowIds=De,e.useLocalRowIdsListener=(e,s,t,o,r)=>ke("Local"+p,$(r),t,o,[e,s]),e.useMetric=qe,e.useMetricIds=e=>Re("MetricIds",Y(e),1),e.useMetricListener=(e,s,t,o)=>ke("Metric",Y(o),s,t,[e]),e.useMetrics=e=>J(e,2),e.useMetricsIds=()=>N(3),e.useMetricsOrMetricsById=Y,e.useProvideStore=(e,s)=>{const{12:t,13:o}=G(U);j((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>J(e,8),e.useQueriesIds=()=>N(9),e.useQueriesOrQueriesById=ee,e.useQueryIds=e=>Re("QueryIds",ee(e),1),e.useRedoInformation=e=>{const s=se(e),[,,[t]]=Ge(s);return[!m(t),We(s),t,S(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>Re("RelationshipIds",$(e),1),e.useRelationships=e=>J(e,6),e.useRelationshipsIds=()=>N(7),e.useRelationshipsOrRelationshipsById=$,e.useRemoteRowId=Me,e.useRemoteRowIdListener=(e,s,t,o,r)=>ke("RemoteRowId",$(r),t,o,[e,s]),e.useResultCell=Ae,e.useResultCellIds=Ee,e.useResultCellIdsListener=(e,s,t,o,r)=>ke(n+k,ee(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>ke(n+R,ee(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>Re(n+C,ee(t),0,[e,s]),e.useResultRowCount=(e,s)=>Re(n+b,ee(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>ke(n+b,ee(o),s,t,[e]),e.useResultRowIds=Oe,e.useResultRowIdsListener=(e,s,t,o)=>ke(n+p,ee(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>ke(n+C,ee(r),t,o,[e,s]),e.useResultSortedRowIds=Qe,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>ke(n+w,ee(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>Re(n+i,ee(s),0,[e]),e.useResultTableCellIds=(e,s)=>Re(n+i+k,ee(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>ke(n+i+k,ee(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>ke(n+i,ee(o),s,t,[e]),e.useRow=(e,s,t)=>Re(C,X(t),0,[e,s]),e.useRowCount=(e,s)=>Re(b,X(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>ke(b,X(r),s,t,[e],o),e.useRowIds=Te,e.useRowIdsListener=(e,s,t,o,r)=>ke(p,X(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>ke(C,X(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>ge(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=v,s=ce,t,o=v,r=ce)=>{const u=se(t);return re((s=>S(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>ge(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>ge(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>ge(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>ge(o,i,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>ge(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>ge(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>ge(t,h,e,s,o,r),e.useSliceIds=Be,e.useSliceIdsListener=(e,s,t,o)=>ke("SliceIds",Z(o),s,t,[e]),e.useSliceRowIds=He,e.useSliceRowIdsListener=(e,s,t,o,r)=>ke("Slice"+p,Z(r),t,o,[e,s]),e.useSortedRowIds=Ve,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>ke(w,X(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>ke("Start"+oe,X(t),e,s),e.useStore=e=>J(e,0),e.useStoreIds=()=>N(1),e.useStoreOrStoreById=X,e.useTable=(e,s)=>Re(i,X(s),0,[e]),e.useTableCellIds=(e,s)=>Re(i+k,X(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>ke(i+k,X(r),s,t,[e],o),e.useTableIds=Se,e.useTableIdsListener=(e,s,t,o)=>ke(I,X(o),e,s,ce,t),e.useTableListener=(e,s,t,o,r)=>ke(i,X(r),s,t,[e],o),e.useTables=e=>Re(c,X(e),0),e.useTablesListener=(e,s,t,o)=>ke(c,X(o),e,s,ce,t),e.useUndoInformation=e=>{const s=se(e),[t,r]=Ge(s);return[(u=t,!(0==f(u))),Ue(s),r,S(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Pe,e.useValueIds=xe,e.useValueIdsListener=(e,s,t,o)=>ke(y,X(o),e,s,ce,t),e.useValueListener=(e,s,t,o,r)=>ke(g,X(r),s,t,[e],o),e.useValues=e=>Re(h,X(e),0),e.useValuesListener=(e,s,t,o)=>ke(h,X(o),e,s,ce,t),e.useWillFinishTransactionListener=(e,s,t)=>ke("WillFinish"+oe,X(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",i="Ids",a="Table",c=a+"s",I=a+i,C="Row",p=C+"Count",b=C+i,w="Sorted"+C+i,R="Cell",k=R+i,g="Value",h=g+"s",y=g+i,L=globalThis,m=e=>null==e,S=(e,s,t)=>m(e)?t?.():s(e),T=e=>t(e)==r,V=e=>t(e)==u,f=e=>e.length,v=()=>{},P=(e,s)=>e.every(s),x=(e,s)=>f(e)===f(s)&&P(e,((e,t)=>s[t]===e)),q=(e,s)=>e.map(s),B=(e,s,t)=>e.with(s,t),M=Object,H=e=>M.getPrototypeOf(e),D=M.entries,F=e=>!m(e)&&S(H(e),(e=>e==M.prototype||m(H(e))),(()=>!0)),O=M.keys,Q=(e,s)=>S(e,(e=>e[s])),E=(e,s)=>s in e,A=(e,s)=>{const t=D(e);return f(t)===f(O(s))&&P(t,(([e,t])=>F(t)?!!F(s[e])&&A(s[e],t):s[e]===t))},{createContext:G,useContext:j,useEffect:U}=s,W=(J=()=>G([]),E(z=L,_="tinybase_uirc")||(z[_]=J()),z[_]);var z,_,J;const K=(e,s)=>{const t=j(W);return m(e)?t[s]:T(e)?Q(t[s+1]??{},e):e},N=(e,s)=>{const t=K(e,s);return m(e)||T(e)?t:e},X=(e,s,t)=>{const{12:o,13:r}=j(W);U((()=>(o?.(t,e,s),()=>r?.(t,e))),[o,e,s,t,r])},Y=e=>O(j(W)[e]??{}),Z=e=>N(e,0),$=e=>N(e,2),ee=e=>N(e,4),se=e=>N(e,6),te=e=>N(e,8),oe=e=>N(e,10),re=e=>e.toLowerCase();re(l);const ue="Transaction";re(ue);const{useCallback:le,useEffect:ne,useMemo:de,useLayoutEffect:ie,useRef:ae,useState:ce,useSyncExternalStore:Ie}=s,Ce=[],pe=[{},[],[Ce,void 0,Ce],void 0,!1,0],be=[A,x,([e,s,t],[o,r,u])=>s===r&&x(e,o)&&x(t,u)],we=(e,s)=>e===s,Re=(e,s,t=Ce)=>{const[,o]=ce(),[r,u]=ce();return ne((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},ke=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},ge=(e,s,t,r=Ce)=>{const u=ae(pe[t]),l=le((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??pe[t];return(be[t]??we)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=le((u=>ke(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return Ie(n,l)},he=(e,s,t,o=Ce,r=Ce,...u)=>ie((()=>ke(s,e,...r,t,...u)),[s,e,...r,...o,...u]),ye=(e,s,t,o=Ce,r=v,u=Ce,...l)=>{const n=Z(e);return le((e=>S(n,(o=>S(t(e,o),(t=>r(o["set"+s](...Le(l,o,e),t),t)))))),[n,s,...o,...u,...me(l)])},Le=(e,s,t)=>q(e,(e=>V(e)?e(t,s):e)),me=e=>{return s=e=>!V(e),e.filter(s);var s},Se=(e,s,t=v,o=Ce,...r)=>{const u=Z(e);return le((e=>t(u?.["del"+s](...Le(r,u,e)))),[u,s,...o,...me(r)])},Te=(e,s,t)=>{const o=oe(e);return le((()=>o?.[s](t)),[o,s,t])},Ve=e=>ge(I,Z(e),1),fe=(e,s)=>ge(b,Z(s),1,[e]),ve=(e,s,t,o=0,r,u)=>ge(w,Z(u),1,[e,s,t,o,r]),Pe=(e,s,t)=>ge(k,Z(t),1,[e,s]),xe=(e,s,t,o)=>ge(R,Z(o),3,[e,s,t]),qe=e=>ge(y,Z(e),1),Be=(e,s)=>ge(g,Z(s),3,[e]),Me=(e,s)=>ge("Metric",$(s),3,[e]),He=(e,s)=>ge("SliceIds",ee(s),1,[e]),De=(e,s,t)=>ge("Slice"+b,ee(t),1,[e,s]),Fe=(e,s,t)=>ge("RemoteRowId",se(t),3,[e,s]),Oe=(e,s,t)=>ge("Local"+b,se(t),1,[e,s]),Qe=(e,s,t)=>ge("Linked"+b,se(t),1,[e,s]),Ee=(e,s)=>ge(n+b,te(s),1,[e]),Ae=(e,s,t,o=0,r,u)=>ge(n+w,te(u),1,[e,s,t,o,r]),Ge=(e,s,t)=>ge(n+k,te(t),1,[e,s]),je=(e,s,t,o)=>ge(n+R,te(o),3,[e,s,t]),Ue=e=>ge("CheckpointIds",oe(e),2),We=(e,s)=>ge("Checkpoint",oe(s),3,[e]),ze=e=>Te(e,"goBackward"),_e=e=>Te(e,"goForward"),{PureComponent:Je,Fragment:Ke,createElement:Ne,useCallback:Xe,useLayoutEffect:Ye,useRef:Ze,useState:$e}=s,es=(e,...s)=>m(e)?{}:e(...s),ss=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:ts,useContext:os,useMemo:rs,useState:us}=s,ls=({tableId:e,store:s,rowComponent:t=Is,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>as(q(n,(u=>Ne(t,{...es(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),ns=({queryId:e,queries:s,resultRowComponent:t=Rs,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>as(q(l,(r=>Ne(t,{...es(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ds=({relationshipId:e,relationships:s,rowComponent:t=Is,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,i,a]=ss(se(s),e),c=l(e,n,d);return as(q(c,(e=>Ne(t,{...es(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:u}))),r,u,n)},is=e=>({checkpoints:s,checkpointComponent:t=ks,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=oe(s);return as(q(e(Ue(l)),(e=>Ne(t,{...es(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},as=(e,s,t,o)=>{const r=m(s)||!Array.isArray(e)?e:q(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},cs=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>as(o+(xe(e,s,t,r)??o),void 0,u,t),Is=({tableId:e,rowId:s,store:t,cellComponent:o=cs,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>as(q(((e,s,t,o)=>{const r=Pe(s,t,o);return e??r})(u,e,s,t),(u=>Ne(o,{...es(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),Cs=e=>ls(e,fe(e.tableId,e.store)),ps=({valueId:e,store:s,debugIds:t})=>as(o+(Be(e,s)??o),void 0,t,e),bs=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Is,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(ee(t),e),a=De(e,s,n);return as(q(a,(e=>Ne(o,{...es(r,e),key:e,tableId:i,rowId:e,store:d,debugIds:l}))),u,l,s)},ws=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>as(o+(je(e,s,t,r)??o),void 0,u,t),Rs=({queryId:e,rowId:s,queries:t,resultCellComponent:o=ws,getResultCellComponentProps:r,separator:u,debugIds:l})=>as(q(Ge(e,s,t),(u=>Ne(o,{...es(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),ks=({checkpoints:e,checkpointId:s,debugIds:t})=>as(We(s,e)??o,void 0,t,s),gs=is((e=>e[0])),hs=is((e=>m(e[1])?[]:[e[1]])),ys=is((e=>e[2]));e.BackwardCheckpointsView=gs,e.CellView=cs,e.CheckpointView=ks,e.CurrentCheckpointView=hs,e.ForwardCheckpointsView=ys,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=bs,getSliceComponentProps:o,separator:r,debugIds:u})=>as(q(He(e,s),(r=>Ne(t,{...es(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>ds(e,Qe,e.firstRowId),e.LocalRowsView=e=>ds(e,Oe,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>as(Me(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const C=os(W),[p,b]=us([{},{},{},{},{},{}]),w=ts(((e,s,t)=>b((o=>Q(o[e],s)==t?o:B(o,e,{...o[e],[s]:t})))),[]),R=ts(((e,s)=>b((t=>E(t[e],s)?B(t,e,((e,s)=>(delete e[s],e))(t[e],s)):t))),[]);return Ne(W.Provider,{value:rs((()=>[e??C[0],{...C[1],...s,...p[0]},t??C[2],{...C[3],...o,...p[1]},r??C[4],{...C[5],...u,...p[2]},l??C[6],{...C[7],...n,...p[3]},d??C[8],{...C[9],...i,...p[4]},a??C[10],{...C[11],...c,...p[5]},w,R]),[e,s,p,t,o,r,u,l,n,d,i,a,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Is,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=ss(se(t),e),i=Fe(e,s,l);return as(m(d)||m(i)?null:Ne(o,{...es(r,i),key:i,tableId:d,rowId:i,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=ws,e.ResultRowView=Rs,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ns(r,Ae(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>ns(e,Ee(e.queryId,e.queries)),e.RowView=Is,e.SliceView=bs,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ls(r,ve(r.tableId,e,s,t,o,r.store)),e.TableView=Cs,e.TablesView=({store:e,tableComponent:s=Cs,getTableComponentProps:t,separator:o,debugIds:r})=>as(q(Ve(e),(o=>Ne(s,{...es(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=ps,e.ValuesView=({store:e,valueComponent:s=ps,getValueComponentProps:t,separator:o,debugIds:r})=>as(q(qe(e),(o=>Ne(s,{...es(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=Ce,o,r=v,u=Ce,l=!0)=>{const n=Z(o);return le((t=>S(n,(o=>S(s(t,o),(s=>r(o.addRow(V(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=xe,e.useCellIds=Pe,e.useCellIdsListener=(e,s,t,o,r,u)=>he(k,Z(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>he(R,Z(l),o,r,[e,s,t],u),e.useCheckpoint=We,e.useCheckpointIds=Ue,e.useCheckpointIdsListener=(e,s,t)=>he("CheckpointIds",oe(t),e,s),e.useCheckpointListener=(e,s,t,o)=>he("Checkpoint",oe(o),s,t,[e]),e.useCheckpoints=e=>K(e,10),e.useCheckpointsIds=()=>Y(11),e.useCheckpointsOrCheckpointsById=oe,e.useCreateCheckpoints=(e,s,t)=>Re(e,s,t),e.useCreateIndexes=(e,s,t)=>Re(e,s,t),e.useCreateMergeableStore=(e,s=Ce)=>de(e,s),e.useCreateMetrics=(e,s,t)=>Re(e,s,t),e.useCreatePersister=(e,s,t=Ce,o,r=Ce,u,l=Ce)=>{const[,n]=ce(),[d,i]=ce();return ne((()=>{(async()=>{const t=e?await s(e):void 0;i(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),ne((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>Re(e,s,t),e.useCreateRelationships=(e,s,t)=>Re(e,s,t),e.useCreateStore=(e,s=Ce)=>de(e,s),e.useCreateSynchronizer=(e,s,t=Ce,o,r=Ce)=>{const[u,l]=ce();return ne((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),ne((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>Se(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>Se(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>Se(s,a,t,o,e),e.useDelTablesCallback=(e,s,t)=>Se(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>Se(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>Se(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>he("DidFinish"+ue,Z(t),e,s),e.useGoBackwardCallback=ze,e.useGoForwardCallback=_e,e.useGoToCallback=(e,s=Ce,t,o=v,r=Ce)=>{const u=oe(t);return le((s=>S(u,(t=>S(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>ge(R,Z(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>he(d+R,Z(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>ge(C,Z(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>he(d+C,Z(u),t,o,[e,s],r),e.useHasTable=(e,s)=>ge(a,Z(s),4,[e]),e.useHasTableCell=(e,s,t)=>ge(a+R,Z(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>he(d+a+R,Z(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>he(d+a,Z(r),s,t,[e],o),e.useHasTables=e=>ge(c,Z(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>he(d+c,Z(o),e,s,[],t),e.useHasValue=(e,s)=>ge(g,Z(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>he(d+g,Z(r),s,t,[e],o),e.useHasValues=e=>ge(h,Z(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>he(d+h,Z(o),e,s,[],t),e.useIndexIds=e=>ge("IndexIds",ee(e),1),e.useIndexes=e=>K(e,4),e.useIndexesIds=()=>Y(5),e.useIndexesOrIndexesById=ee,e.useLinkedRowIds=Qe,e.useLinkedRowIdsListener=(e,s,t,o,r)=>he("Linked"+b,se(r),t,o,[e,s]),e.useLocalRowIds=Oe,e.useLocalRowIdsListener=(e,s,t,o,r)=>he("Local"+b,se(r),t,o,[e,s]),e.useMetric=Me,e.useMetricIds=e=>ge("MetricIds",$(e),1),e.useMetricListener=(e,s,t,o)=>he("Metric",$(o),s,t,[e]),e.useMetrics=e=>K(e,2),e.useMetricsIds=()=>Y(3),e.useMetricsOrMetricsById=$,e.useProvideCheckpoints=(e,s)=>X(e,s,5),e.useProvideIndexes=(e,s)=>X(e,s,2),e.useProvideMetrics=(e,s)=>X(e,s,1),e.useProvideQueries=(e,s)=>X(e,s,4),e.useProvideRelationships=(e,s)=>X(e,s,3),e.useProvideStore=(e,s)=>X(e,s,0),e.useQueries=e=>K(e,8),e.useQueriesIds=()=>Y(9),e.useQueriesOrQueriesById=te,e.useQueryIds=e=>ge("QueryIds",te(e),1),e.useRedoInformation=e=>{const s=oe(e),[,,[t]]=Ue(s);return[!m(t),_e(s),t,S(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>ge("RelationshipIds",se(e),1),e.useRelationships=e=>K(e,6),e.useRelationshipsIds=()=>Y(7),e.useRelationshipsOrRelationshipsById=se,e.useRemoteRowId=Fe,e.useRemoteRowIdListener=(e,s,t,o,r)=>he("RemoteRowId",se(r),t,o,[e,s]),e.useResultCell=je,e.useResultCellIds=Ge,e.useResultCellIdsListener=(e,s,t,o,r)=>he(n+k,te(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>he(n+R,te(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>ge(n+C,te(t),0,[e,s]),e.useResultRowCount=(e,s)=>ge(n+p,te(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>he(n+p,te(o),s,t,[e]),e.useResultRowIds=Ee,e.useResultRowIdsListener=(e,s,t,o)=>he(n+b,te(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>he(n+C,te(r),t,o,[e,s]),e.useResultSortedRowIds=Ae,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>he(n+w,te(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>ge(n+a,te(s),0,[e]),e.useResultTableCellIds=(e,s)=>ge(n+a+k,te(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>he(n+a+k,te(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>he(n+a,te(o),s,t,[e]),e.useRow=(e,s,t)=>ge(C,Z(t),0,[e,s]),e.useRowCount=(e,s)=>ge(p,Z(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>he(p,Z(r),s,t,[e],o),e.useRowIds=fe,e.useRowIdsListener=(e,s,t,o,r)=>he(b,Z(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>he(C,Z(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>ye(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=v,s=Ce,t,o=v,r=Ce)=>{const u=oe(t);return le((s=>S(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>ye(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>ye(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>ye(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>ye(o,a,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>ye(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>ye(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>ye(t,h,e,s,o,r),e.useSliceIds=He,e.useSliceIdsListener=(e,s,t,o)=>he("SliceIds",ee(o),s,t,[e]),e.useSliceRowIds=De,e.useSliceRowIdsListener=(e,s,t,o,r)=>he("Slice"+b,ee(r),t,o,[e,s]),e.useSortedRowIds=ve,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>he(w,Z(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>he("Start"+ue,Z(t),e,s),e.useStore=e=>K(e,0),e.useStoreIds=()=>Y(1),e.useStoreOrStoreById=Z,e.useTable=(e,s)=>ge(a,Z(s),0,[e]),e.useTableCellIds=(e,s)=>ge(a+k,Z(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>he(a+k,Z(r),s,t,[e],o),e.useTableIds=Ve,e.useTableIdsListener=(e,s,t,o)=>he(I,Z(o),e,s,Ce,t),e.useTableListener=(e,s,t,o,r)=>he(a,Z(r),s,t,[e],o),e.useTables=e=>ge(c,Z(e),0),e.useTablesListener=(e,s,t,o)=>he(c,Z(o),e,s,Ce,t),e.useUndoInformation=e=>{const s=oe(e),[t,r]=Ue(s);return[(u=t,!(0==f(u))),ze(s),r,S(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Be,e.useValueIds=qe,e.useValueIdsListener=(e,s,t,o)=>he(y,Z(o),e,s,Ce,t),e.useValueListener=(e,s,t,o,r)=>he(g,Z(r),s,t,[e],o),e.useValues=e=>ge(h,Z(e),0),e.useValuesListener=(e,s,t,o)=>he(h,Z(o),e,s,Ce,t),e.useWillFinishTransactionListener=(e,s,t)=>he("WillFinish"+ue,Z(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);