tinybase 4.0.0 → 4.1.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 (46) hide show
  1. package/lib/cjs/tools.cjs +1 -1
  2. package/lib/cjs/tools.cjs.gz +0 -0
  3. package/lib/cjs/ui-react-dom.cjs +1 -0
  4. package/lib/cjs/ui-react-dom.cjs.gz +0 -0
  5. package/lib/cjs/ui-react.cjs +1 -1
  6. package/lib/cjs/ui-react.cjs.gz +0 -0
  7. package/lib/cjs-es6/tools.cjs +1 -1
  8. package/lib/cjs-es6/tools.cjs.gz +0 -0
  9. package/lib/cjs-es6/ui-react-dom.cjs +1 -0
  10. package/lib/cjs-es6/ui-react-dom.cjs.gz +0 -0
  11. package/lib/cjs-es6/ui-react.cjs +1 -1
  12. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  13. package/lib/debug/tools.js +25 -4
  14. package/lib/debug/ui-react-dom.js +205 -0
  15. package/lib/debug/ui-react.js +21 -13
  16. package/lib/es6/tools.js +1 -1
  17. package/lib/es6/tools.js.gz +0 -0
  18. package/lib/es6/ui-react-dom.js +1 -0
  19. package/lib/es6/ui-react-dom.js.gz +0 -0
  20. package/lib/es6/ui-react.js +1 -1
  21. package/lib/es6/ui-react.js.gz +0 -0
  22. package/lib/tools.js +1 -1
  23. package/lib/tools.js.gz +0 -0
  24. package/lib/types/ui-react-dom.d.ts +544 -0
  25. package/lib/types/ui-react.d.ts +59 -18
  26. package/lib/types/with-schemas/internal/ui-react.d.ts +15 -0
  27. package/lib/types/with-schemas/ui-react-dom.d.ts +590 -0
  28. package/lib/types/with-schemas/ui-react.d.ts +44 -18
  29. package/lib/ui-react-dom.js +1 -0
  30. package/lib/ui-react-dom.js.gz +0 -0
  31. package/lib/ui-react.js +1 -1
  32. package/lib/ui-react.js.gz +0 -0
  33. package/lib/umd/tools.js +1 -1
  34. package/lib/umd/tools.js.gz +0 -0
  35. package/lib/umd/ui-react-dom.js +1 -0
  36. package/lib/umd/ui-react-dom.js.gz +0 -0
  37. package/lib/umd/ui-react.js +1 -1
  38. package/lib/umd/ui-react.js.gz +0 -0
  39. package/lib/umd-es6/tools.js +1 -1
  40. package/lib/umd-es6/tools.js.gz +0 -0
  41. package/lib/umd-es6/ui-react-dom.js +1 -0
  42. package/lib/umd-es6/ui-react-dom.js.gz +0 -0
  43. package/lib/umd-es6/ui-react.js +1 -1
  44. package/lib/umd-es6/ui-react.js.gz +0 -0
  45. package/package.json +32 -28
  46. package/readme.md +50 -33
@@ -0,0 +1,205 @@
1
+ import {
2
+ useRowIds,
3
+ useSortedRowIds,
4
+ useValueIds,
5
+ ValueView,
6
+ useTableCellIds,
7
+ CellView,
8
+ } from './ui-react';
9
+ import React from 'react';
10
+
11
+ const EMPTY_STRING = '';
12
+ const VALUE = 'Value';
13
+
14
+ const arrayMap = (array, cb) => array.map(cb);
15
+
16
+ const isUndefined = (thing) => thing == void 0;
17
+
18
+ const {createContext, useContext} = React;
19
+ createContext([]);
20
+ const getProps = (getProps2, ...ids) =>
21
+ isUndefined(getProps2) ? {} : getProps2(...ids);
22
+
23
+ const {createElement, useCallback, useState} = React;
24
+ const useCallbackOrUndefined = (callback, deps, test) => {
25
+ const returnCallback = useCallback(callback, deps);
26
+ return test ? returnCallback : void 0;
27
+ };
28
+ const sortedClassName = (sorting, cellId) =>
29
+ isUndefined(sorting)
30
+ ? void 0
31
+ : sorting[0] != cellId
32
+ ? void 0
33
+ : `sorted ${sorting[1] ? 'de' : 'a'}scending`;
34
+ const HtmlHeaderTh = ({
35
+ cellId,
36
+ sorting,
37
+ label = cellId ?? EMPTY_STRING,
38
+ onClick,
39
+ }) =>
40
+ /* @__PURE__ */ createElement(
41
+ 'th',
42
+ {
43
+ onClick: useCallbackOrUndefined(
44
+ () => onClick?.(cellId),
45
+ [onClick, cellId],
46
+ !isUndefined(onClick),
47
+ ),
48
+ className: sortedClassName(sorting, cellId),
49
+ },
50
+ label,
51
+ );
52
+ const HtmlTable = ({
53
+ tableId,
54
+ rowIds,
55
+ store,
56
+ cellComponent: Cell = CellView,
57
+ getCellComponentProps,
58
+ className,
59
+ headerRow,
60
+ idColumn,
61
+ customCellIds,
62
+ sorting,
63
+ onHeaderThClick,
64
+ }) => {
65
+ const defaultCellIds = useTableCellIds(tableId, store);
66
+ const cellIds = customCellIds ?? defaultCellIds;
67
+ return /* @__PURE__ */ createElement(
68
+ 'table',
69
+ {className},
70
+ headerRow === false
71
+ ? null
72
+ : /* @__PURE__ */ createElement(
73
+ 'thead',
74
+ null,
75
+ /* @__PURE__ */ createElement(
76
+ 'tr',
77
+ null,
78
+ idColumn === false
79
+ ? null
80
+ : /* @__PURE__ */ createElement(HtmlHeaderTh, {
81
+ sorting,
82
+ label: 'Id',
83
+ onClick: onHeaderThClick,
84
+ }),
85
+ arrayMap(cellIds, (cellId) =>
86
+ /* @__PURE__ */ createElement(HtmlHeaderTh, {
87
+ key: cellId,
88
+ cellId,
89
+ sorting,
90
+ onClick: onHeaderThClick,
91
+ }),
92
+ ),
93
+ ),
94
+ ),
95
+ /* @__PURE__ */ createElement(
96
+ 'tbody',
97
+ null,
98
+ arrayMap(rowIds, (rowId) =>
99
+ /* @__PURE__ */ createElement(
100
+ 'tr',
101
+ {key: rowId},
102
+ idColumn === false
103
+ ? null
104
+ : /* @__PURE__ */ createElement('th', null, rowId),
105
+ arrayMap(cellIds, (cellId) =>
106
+ /* @__PURE__ */ createElement(
107
+ 'td',
108
+ {key: cellId},
109
+ /* @__PURE__ */ createElement(Cell, {
110
+ ...getProps(getCellComponentProps, rowId, cellId),
111
+ tableId,
112
+ rowId,
113
+ cellId,
114
+ store,
115
+ }),
116
+ ),
117
+ ),
118
+ ),
119
+ ),
120
+ ),
121
+ );
122
+ };
123
+ const TableInHtmlTable = ({tableId, store, ...props}) =>
124
+ /* @__PURE__ */ createElement(HtmlTable, {
125
+ ...props,
126
+ tableId,
127
+ store,
128
+ rowIds: useRowIds(tableId, store),
129
+ });
130
+ const SortedTableInHtmlTable = ({
131
+ tableId,
132
+ cellId,
133
+ descending,
134
+ offset,
135
+ limit,
136
+ store,
137
+ sortOnClick,
138
+ ...props
139
+ }) => {
140
+ const [sorting, setSorting] = useState([cellId, descending ? true : false]);
141
+ const handleHeaderThClick = useCallbackOrUndefined(
142
+ (cellId2) =>
143
+ setSorting([cellId2, cellId2 == sorting[0] ? !sorting[1] : false]),
144
+ [sorting],
145
+ sortOnClick,
146
+ );
147
+ return /* @__PURE__ */ createElement(HtmlTable, {
148
+ ...props,
149
+ tableId,
150
+ store,
151
+ rowIds: useSortedRowIds(tableId, ...sorting, offset, limit, store),
152
+ sorting,
153
+ onHeaderThClick: handleHeaderThClick,
154
+ });
155
+ };
156
+ const ValuesInHtmlTable = ({
157
+ store,
158
+ valueComponent: Value = ValueView,
159
+ getValueComponentProps,
160
+ className,
161
+ headerRow,
162
+ idColumn,
163
+ }) =>
164
+ /* @__PURE__ */ createElement(
165
+ 'table',
166
+ {className},
167
+ headerRow === false
168
+ ? null
169
+ : /* @__PURE__ */ createElement(
170
+ 'thead',
171
+ null,
172
+ /* @__PURE__ */ createElement(
173
+ 'tr',
174
+ null,
175
+ idColumn === false
176
+ ? null
177
+ : /* @__PURE__ */ createElement('th', null, 'Id'),
178
+ /* @__PURE__ */ createElement('th', null, VALUE),
179
+ ),
180
+ ),
181
+ /* @__PURE__ */ createElement(
182
+ 'tbody',
183
+ null,
184
+ arrayMap(useValueIds(store), (valueId) =>
185
+ /* @__PURE__ */ createElement(
186
+ 'tr',
187
+ {key: valueId},
188
+ idColumn === false
189
+ ? null
190
+ : /* @__PURE__ */ createElement('th', null, valueId),
191
+ /* @__PURE__ */ createElement(
192
+ 'td',
193
+ null,
194
+ /* @__PURE__ */ createElement(Value, {
195
+ ...getProps(getValueComponentProps, valueId),
196
+ valueId,
197
+ store,
198
+ }),
199
+ ),
200
+ ),
201
+ ),
202
+ ),
203
+ );
204
+
205
+ export {SortedTableInHtmlTable, TableInHtmlTable, ValuesInHtmlTable};
@@ -48,6 +48,8 @@ const useThingOrThingId = (thingOrThingId, offset) => {
48
48
  ? thing
49
49
  : thingOrThingId;
50
50
  };
51
+ const getProps = (getProps2, ...ids) =>
52
+ isUndefined(getProps2) ? {} : getProps2(...ids);
51
53
  const useStore = (id) => useThing(id, 0);
52
54
  const useMetrics = (id) => useThing(id, 2);
53
55
  const useIndexes = (id) => useThing(id, 4);
@@ -984,6 +986,7 @@ const tableView = (
984
986
  store,
985
987
  rowComponent: Row = RowView,
986
988
  getRowComponentProps,
989
+ customCellIds,
987
990
  separator,
988
991
  debugIds,
989
992
  },
@@ -996,6 +999,7 @@ const tableView = (
996
999
  key: rowId,
997
1000
  tableId,
998
1001
  rowId,
1002
+ customCellIds,
999
1003
  store,
1000
1004
  debugIds,
1001
1005
  }),
@@ -1092,8 +1096,6 @@ const getUseCheckpointView =
1092
1096
  separator,
1093
1097
  );
1094
1098
  };
1095
- const getProps = (getProps2, id) =>
1096
- isUndefined(getProps2) ? {} : getProps2(id);
1097
1099
  const Provider = ({
1098
1100
  store,
1099
1101
  storesById,
@@ -1155,6 +1157,10 @@ const wrap = (children, separator, encloseWithId, id) => {
1155
1157
  : arrayMap(children, (child, c) => (c > 0 ? [separator, child] : child));
1156
1158
  return encloseWithId ? [id, ':{', separated, '}'] : separated;
1157
1159
  };
1160
+ const useCustomOrDefaultCellIds = (customCellIds, tableId, rowId, store) => {
1161
+ const defaultCellIds = useCellIds(tableId, rowId, store);
1162
+ return customCellIds ?? defaultCellIds;
1163
+ };
1158
1164
  const CellView = ({tableId, rowId, cellId, store, debugIds}) =>
1159
1165
  wrap(
1160
1166
  EMPTY_STRING + (useCell(tableId, rowId, cellId, store) ?? EMPTY_STRING),
@@ -1168,20 +1174,23 @@ const RowView = ({
1168
1174
  store,
1169
1175
  cellComponent: Cell = CellView,
1170
1176
  getCellComponentProps,
1177
+ customCellIds,
1171
1178
  separator,
1172
1179
  debugIds,
1173
1180
  }) =>
1174
1181
  wrap(
1175
- arrayMap(useCellIds(tableId, rowId, store), (cellId) =>
1176
- /* @__PURE__ */ createElement(Cell, {
1177
- ...getProps(getCellComponentProps, cellId),
1178
- key: cellId,
1179
- tableId,
1180
- rowId,
1181
- cellId,
1182
- store,
1183
- debugIds,
1184
- }),
1182
+ arrayMap(
1183
+ useCustomOrDefaultCellIds(customCellIds, tableId, rowId, store),
1184
+ (cellId) =>
1185
+ /* @__PURE__ */ createElement(Cell, {
1186
+ ...getProps(getCellComponentProps, cellId),
1187
+ key: cellId,
1188
+ tableId,
1189
+ rowId,
1190
+ cellId,
1191
+ store,
1192
+ debugIds,
1193
+ }),
1185
1194
  ),
1186
1195
  separator,
1187
1196
  debugIds,
@@ -1428,7 +1437,6 @@ export {
1428
1437
  TablesView,
1429
1438
  ValueView,
1430
1439
  ValuesView,
1431
- tableView,
1432
1440
  useAddRowCallback,
1433
1441
  useCell,
1434
1442
  useCellIds,
package/lib/es6/tools.js CHANGED
@@ -1 +1 @@
1
- const e=e=>typeof e,t="tinybase",l="",a=",",n=e(l),o=e(!0),d=e(0),r="type",s="default",I="Listener",c="get",$="add",i="Ids",u="Table",p=u+"s",b=u+i,C="Row",h=C+i,g="Sorted"+C+i,m="Cell",f=m+i,w="Value",y=w+"s",v=w+i,T=(e,t)=>e.every(t),V=(e,t)=>e.sort(t),x=(e,t)=>e.forEach(t),R=(e,t=l)=>e.join(t),k=(e,t)=>e.map(t),P=e=>e.length,S=(e,t)=>e.filter(t),A=(e,...t)=>e.push(...t),O=e=>e.pop(),E=(e,...t)=>e.unshift(...t),D=e=>e.shift(),j=JSON.parse,N=isFinite,L=(e,t)=>e instanceof t,G=e=>null==e,M=e=>e==n||e==o,J=t=>e(t)==n,z=e=>Array.isArray(e),W=t=>{const l=e(t);return M(l)||l==d&&N(t)?l:void 0},B=Object,F=B.keys,U=B.freeze,_=e=>L(e,B)&&e.constructor==B,Z=(e,t)=>k(B.entries(e),(([e,l])=>t(l,e))),H=e=>P(F(e)),Q=e=>_(e)&&0==H(e),q=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},K=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},X=(e,t)=>null==e?void 0:e.forEach(t),Y=(e,t)=>null==e?void 0:e.delete(t),ee=e=>new Map(e),te=(e,t)=>null==e?void 0:e.get(t),le=(e,t)=>X(e,((e,l)=>t(l,e))),ae=(e,t)=>{var l;return k([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},ne=(e,t,l)=>G(l)?(Y(e,t),e):null==e?void 0:e.set(t,l),oe=(e,t,l)=>(q(e,t)||ne(e,t,l()),te(e,t)),de=e=>e.toUpperCase(),re=e=>e.toLowerCase(),se="a ",Ie="A function for",ce=", and registers a listener so that any changes to that result will cause a re-render",$e="Callback",ie="Del",ue="Deps",pe=ue+"?: React.DependencyList",be="doRollback?: DoRollback",Ce="actions: () => Return, "+be,he="export",ge="Id",me="Invalid",fe="Json",we=re(I),ye="?: ",ve=" | undefined",Te="NonNullable",Ve="Partial",xe="Props",Re="Provider",ke=`Registers a ${we} that will be called`,Pe="Represents",Se="rowId: "+ge,Ae="Schema",Oe="Set",Ee=", descending?: boolean, offset?: number, limit?: number",De="[]",je="the Store",Ne="Transaction",Le=Ne+"Changes",Ge=re(Ne),Me="Execute a "+Ge+" to make multiple mutations",Je="Explicitly starts a "+Ge,ze="Explicitly finishes a "+Ge,We="the end of the "+Ge,Be="void",Fe=" => "+Be,Ue="WhenSet",_e=" when setting it",Ze=se+"string serialization of",He=" ",Qe="Gets a callback that can ",qe="the ",Ke=" the schema for",Xe=(e=0,t=0)=>`the ${Ct[e]}content of`+(t?He+je:l),Ye=(e=0,t,a=0)=>ut[t]+He+Xe(e,1)+(a?" when setting it":l),et=(e,t=0)=>Pe+` a Row when ${t?"s":"g"}etting ${Xe()} the '${e}' `+u,tt=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,lt=(e,t)=>`Calls a function for each ${e} in `+t,at=e=>"The props passed to a component that renders "+e,nt=e=>"A function that takes "+e,ot=(e,t=0)=>Ie+" listening to changes to "+bt[e]+" in "+bt[t],dt=(e,t,a=0)=>ke+" whenever "+bt[e]+" in "+bt[t]+" change"+(a?l:"s"),rt=e=>`the '${e}' `+u,st=e=>"the specified Row in "+rt(e),It=(e,t=0)=>ut[t]+` ${Xe()} `+rt(e),ct=(e,t=0)=>ut[t]+` ${Xe()} `+st(e),$t=(e,t,l=0)=>ut[l]+` the '${t}' Cell for `+st(e),it=(e,t=0)=>ut[t]+` the '${e}' Value`,ut=["Gets","Checks existence of","Sets","Deletes","Sets part of",Pe,"Gets "+Ze,"Sets "+Ze,ke+" whenever",Qe+"set",Qe+"add",Qe+"set part of",Qe+"delete","Renders","Gets "+Ze+Ke,"Sets"+Ke,"Deletes"+Ke],pt=[c,"has","set","del","set","forEach",$,l],bt=[je,p,qe+u+He+i,se+u,qe+C+He+i,se+C,qe+m+He+i,se+m,"invalid Cell changes",y,qe+w+He+i,se+w,"invalid Value changes",qe+"sorted "+C+He+i,qe+m+He+i+" anywhere"],Ct=[l,"tabular ","keyed value "],ht=e=>new Set(z(e)||G(e)?e:[e]),gt=(e,t)=>null==e?void 0:e.add(t),mt=/[^A-Za-z]+/,ft=/[^A-Za-z0-9]+/,wt=/^( *)\/\*\* *(.*?) *\*\/$/gm,yt=(e,t,l)=>e.substring(t,l),vt=e=>e.includes(a),Tt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return q(e,n)?Tt(e,t,l,a+1):(ne(e,n,l),n)},Vt=e=>e.replace(wt,((e,t,l)=>{const a=77-xt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),xt=e=>e.length,Rt=e=>e.flat(1e3),kt=(e,t=0)=>R(k(e.split(ft),((e,l)=>(l>0||t?de:re)(yt(e,0,1))+yt(e,1)))),Pt=e=>de(R((e&&!mt.test(e[0])?e:" "+e).split(ft),"_")),St=e=>`/** ${e}. */`,At=(...e)=>R(S(e,(e=>e)),", "),Ot=(...e)=>"{"+R(e,"; ")+"}",Et=(...e)=>Ot(...k(e,(e=>"readonly "+e))),Dt=()=>{const e=[ee(),ee(),ee(),ee()],t=ee(),a=ee(),n=e=>{const t=e.indexOf(" as ");return-1!=t?e.substring(t+4):e};return[(...e)=>R(Rt(e),"\n"),(t,l,...a)=>x(a,(a=>x([0,1],(n=>(null!=t?t:n)==n?gt(oe(e[n],l,ht),a):0)))),(e,a,n,o=l,d=1)=>Tt(t,e,[a,n,o,d]),(e,t,l)=>Tt(a,e,z(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>te(a,e)===t?e:Tt(a,e,t),(t=0)=>k([...V(ae(e[t],((e,t)=>`import {${R(V(K(e),((e,t)=>n(e)>n(t)?1:-1)),", ")}} from '${t}';`)),((e,t)=>vt(e)!=vt(t)?vt(e)?-1:1:e>t?1:-1)),l],(e=>e.replace("{React}","React"))),()=>ae(t,(([e,t,a,n],o)=>[St(t),`${n?he+" ":l}type ${o}${a} = ${e};`,l])),()=>ae(a,((e,t)=>(e=z(e)?e:[e],A(e,O(e)+";"),[`const ${t} = ${D(e)}`,e,l])))]},jt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Nt=(e,t,l)=>[t=>Z(e,((e,a)=>t(a,kt(a,1),l(Pt(a),`'${a}'`)))),(t,a)=>Z(e[t],((e,t)=>a(t,e[r],e[s],l(Pt(t),`'${t}'`),kt(t,1)))),e=>Z(t,((t,a)=>e(a,t[r],t[s],l(Pt(a),`'${a}'`),kt(a,1))))],Lt=(e,t,a,n)=>[(n,o)=>{const d=n+": "+o,r=e(p,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...a(e,((e,t,a)=>`'${e}'${G(a)?"?":l}: ${t}`)))+"}"))),Ye(1,5)),s=e(p+Ue,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Ye(1,5,1)),c=e(u+ge,"keyof "+r,"A "+u+" Id in "+je),$=`<TId extends ${c}>`,i=e(u,Te+`<${r}[TId]>`,"A "+u+" in "+je,$),w=e(u+Ue,Te+`<${s}[TId]>`,"A "+u+" in "+je+_e,$),y=e(C,i+"<TId>[Id]","A "+C+" in a "+u,$),v=e(C+Ue,w+"<TId>[Id]","A "+C+" in a "+u+_e,$),T=e(m+ge,`Extract<keyof ${y}<TId>, Id>`,"A "+m+" Id in a "+C,$),V=e(m,Te+`<${r}[TId]>[Id][CId]`,"A "+m+" in a "+C,`<TId extends ${c}, CId extends ${T}<TId>>`),x=e("CellIdCellArray",`CId extends ${T}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,m+" Ids and types in a "+C,`<TId extends ${c}, CId = ${T}<TId>>`,0),R=e(m+$e,`(...[cellId, cell]: ${x}<TId>)`+Fe,nt(se+m+" Id, and "+m),$),k=e(C+$e,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Fe+") "+Fe,nt(se+C+" Id, and a "+m+" iterator"),$),P=e(u+m+$e,`(cellId: ${T}<TId>, count: number) `+Fe,nt(se+m+" Id, and count of how many times it appears"),$),S=e("TableIdForEachRowArray",`TId extends ${c} ? [tableId: TId, forEachRow: (rowCallback: ${k}<TId>)${Fe}] : never`,u+" Ids and callback types",`<TId = ${c}>`,0),A=e(u+$e,`(...[tableId, forEachRow]: ${S})`+Fe,nt(se+u+" Id, and a "+C+" iterator"),l),O=e("TableIdRowIdCellIdArray",`TId extends ${c} ? [tableId: TId, rowId: Id, cellId: ${T}<TId>] : never`,"Ids for GetCellChange",`<TId = ${c}>`,0),E=e("GetCellChange",`(...[tableId, rowId, cellId]: ${O}) => CellChange`,Ie+" returning information about any Cell's changes during a "+Ge),D=e(p+I,`(${d}, getCellChange: ${E}${ve})`+Fe,ot(1)),j=e(b+I,`(${d})`+Fe,ot(2)),N=e(u+I,`(${d}, tableId: ${c}, getCellChange: ${E}${ve})`+Fe,ot(3)),L=e(u+f+I,`(${d}, tableId: ${c})`+Fe,ot(14,3)),M=e(h+I,`(${d}, tableId: ${c})`+Fe,ot(4,3)),J=e(g+I,"("+At(d,"tableId: "+c,"cellId: Id"+ve,"descending: boolean","offset: number","limit: number"+ve,"sortedRowIds: Ids")+")"+Fe,ot(13,3)),z=e(C+I,"("+At(""+d,"tableId: "+c,Se,`getCellChange: ${E}${ve}`)+")"+Fe,ot(5,3)),W=e(f+I,"("+At(""+d,"tableId: "+c,Se)+")"+Fe,ot(6,5)),B=e("CellListenerArgsArrayInner",`CId extends ${T}<TId> ? [${d}, tableId: TId, ${Se}, cellId: CId, newCell: ${V}<TId, CId> ${ve}, oldCell: ${V}<TId, CId> ${ve}, getCellChange: ${E} ${ve}] : never`,"Cell args for CellListener",`<TId extends ${c}, CId = ${T}<TId>>`,0),F=e("CellListenerArgsArrayOuter",`TId extends ${c} ? `+B+"<TId> : never","Table args for CellListener",`<TId = ${c}>`,0);return[r,s,c,i,w,y,v,T,V,R,k,P,A,D,j,N,L,M,J,z,W,e(m+I,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${F})`+Fe,ot(7,5)),e(me+m+I,`(${d}, tableId: Id, ${Se}, cellId: Id, invalidCells: any[])`+Fe,ot(8))]},(t,a)=>{const o=t+": "+a,d=e(y,Ot(...n(((e,t,a)=>`'${e}'${G(a)?"?":l}: ${t}`))),Ye(2,5)),r=e(y+Ue,Ot(...n(((e,t)=>`'${e}'?: ${t}`))),Ye(2,5,1)),s=e(w+ge,"keyof "+d,"A "+w+" Id in "+je),c=e(w,Te+`<${d}[VId]>`,"A "+w+" Id in "+je,`<VId extends ${s}>`),$=e("ValueIdValueArray",`VId extends ${s} ? [valueId: VId, value: ${c}<VId>] : never`,w+" Ids and types in "+je,`<VId = ${s}>`,0),i=e(w+$e,`(...[valueId, value]: ${$})`+Fe,nt(se+w+" Id, and "+w)),u=e("GetValueChange",`(valueId: ${s}) => ValueChange`,Ie+" returning information about any Value's changes during a "+Ge),p=e(y+I,`(${o}, getValueChange: ${u}${ve})`+Fe,ot(9)),b=e(v+I,`(${o})`+Fe,ot(10)),C=e("ValueListenerArgsArray",`VId extends ${s} ? [${o}, valueId: VId, newValue: ${c}<VId> ${ve}, oldValue: ${c}<VId> ${ve}, getValueChange: ${u} ${ve}] : never`,"Value args for ValueListener",`<VId = ${s}>`,0);return[d,r,s,c,i,p,b,e(w+I,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Fe,ot(11)),e(me+w+I,`(${o}, valueId: Id, invalidValues: any[])`+Fe,ot(12))]},(t,l)=>e(Ne+I,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Fe,Ie+" listening to the completion of a "+Ge)],Gt=(e,t=l,a=l)=>`store.${e}(${t})`+(a?" as "+a:l),Mt=(e,t=l)=>`fluent(() => ${Gt(e,t)})`,Jt=(e,t=l,a=l)=>`store.${e}(${t?t+", ":l}proxy(listener)${a?", "+a:l})`,zt=(e,a,n)=>{const[d,c,T,V,k,P,S,O]=Dt(),[D,j,N]=Nt(e,a,k),[L,M,z]=Lt(T,D,j,N),W=ee(),B=(e=0)=>ae(W,(([t,a,n,o,d],r)=>{const s=e?[r+`: ${d}(${t}): ${a} => ${n},`]:[r+d+`(${t}): ${a};`];return e||E(s,St(o)),A(s,l),s})),F=(e,t,a,n,o,d=l)=>Tt(W,e,[t,a,n,o,d]),U=(e,t,a,n,o,d=l,r=l,s=l)=>F(pt[e]+t+(4==e?Ve:l)+a,d,n,(n==H?Mt:Gt)(pt[e]+(4==e?Ve:l)+a,r,e?void 0:n),o,s),_=(e,t,a,n=l,o=l,d=1,r=l)=>F($+e+I,(n?n+", ":l)+we+": "+t+(d?", mutator?: boolean":l),ge,Jt($+e+I,o,d?"mutator":l),a,r),Z=`./${kt(n)}.d`,H=kt(n,1),q=kt(H),X=[],Y=ee();let oe=[],de=[];if(c(1,Z,H,`create${H} as create${H}Decl`),Q(e))c(null,t,p);else{c(0,t,"CellChange"),c(null,t,i);const[e,a,n,d,I,$,w,y,v,V,P,S,O,E,N,M,z,W,B,F,Q,le,ae]=L(q,H),de=ee();D(((e,t)=>{const l=`<'${e}'>`,a=[T(t+u,d+l,Pe+` the '${e}' `+u),T(t+u+Ue,I+l,Pe+` the '${e}' `+u+_e),T(t+C,$+l,et(e)),T(t+C+Ue,w+l,et(e,1)),T(t+m+ge,y+l,`A Cell Id for the '${e}' `+u),T(t+m+$e,V+l,nt(`a Cell Id and value from a Row in the '${e}' `+u)),T(t+C+$e,P+l,nt(`a Row Id from the '${e}' Table, and a Cell iterator`)),T(t+u+m+$e,S+l,nt(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];ne(de,e,a),c(1,Z,...a)})),c(1,Z,e,a,n,y,O,E,N,M,z,W,B,F,Q,le,ae),oe=[e,a,n,y,E,N,M,z,W,B,F,Q,le,de],x([[e],[o],[H,"tables: "+a,"tables"],[H]],(([e,t,a],n)=>U(n,l,p,e,Ye(1,n),t,a))),U(0,l,b,n+De,tt(u,je)),U(5,l,u,Be,lt(u,je),"tableCallback: "+O,"tableCallback as any"),D(((e,t,a)=>{const[n,d,r,s,I,c,$,p]=te(de,e);x([[n],[o],[H,"table: "+d,", table"],[H]],(([n,o,d=l],r)=>U(r,t,u,n,It(e,r),o,a+d))),U(0,t,u+f,i,tt(m,"the whole of "+rt(e)),l,a),U(5,t,u+m,Be,lt(u+m,"the whole of "+rt(e)),"tableCellCallback: "+p,a+", tableCellCallback as any"),U(0,t,h,i,tt(C,rt(e)),l,a),U(0,t,g,i,tt(C,rt(e),1),"cellId?: "+I+Ee,a+", cellId, descending, offset, limit"),U(5,t,C,Be,lt(C,rt(e)),"rowCallback: "+$,a+", rowCallback as any"),x([[r],[o],[H,", row: "+s,", row"],[H],[H,", partialRow: "+s,", partialRow"]],(([n,o=l,d=l],r)=>U(r,t,C,n,ct(e,r),Se+o,a+", rowId"+d))),U(6,t,C,ge+ve,"Add a new Row to "+rt(e),"row: "+s+", reuseIds?: boolean",a+", row, reuseIds"),U(0,t,f,I+De,tt(m,st(e)),Se,a+", rowId"),U(5,t,m,Be,lt(m,st(e)),Se+", cellCallback: "+c,a+", rowId, cellCallback as any"),j(e,((n,d,r,s,I)=>{const c="Map"+kt(d,1);ne(Y,d,c);const $=d+(G(r)?ve:l);x([[$],[o],[H,`, cell: ${d} | `+c,", cell as any"],[H]],(([o,d=l,r=l],c)=>U(c,t+I,m,o,$t(e,n,c),Se+d,a+", rowId, "+s+r))),U(1,t+I,u+m,o,ut[1]+` the '${n}' Cell anywhere in `+rt(e),l,a+", "+s)}))})),U(0,l,p+fe,fe,Ye(1,6)),U(2,l,p+fe,H,Ye(1,7),"tablesJson: "+fe,"tables"+fe),_(p,E,Ye(1,8)+" changes"),_(b,N,dt(2,0,1)),_(u,M,dt(3,0),`tableId: ${n} | null`,"tableId"),_(u+f,z,dt(14,3,1),`tableId: ${n} | null`,"tableId"),_(h,W,dt(4,3,1),`tableId: ${n} | null`,"tableId"),_(g,B,dt(13,3,1),At("tableId: TId",`cellId: ${y}<TId>`+ve,"descending: boolean","offset: number","limit: number"+ve),At("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),_(C,F,dt(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(f,Q,dt(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(m,le,dt(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${R(D((e=>{var t,a;return null!=(a=null==(t=te(de,e))?void 0:t[4])?a:l}))," | ")} | null`,"tableId, rowId, cellId"),_(me+m,ae,ke+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),c(1,Z,...K(Y)),A(X,".set"+p+Ae+"({",Rt(D(((e,t,a)=>[`[${a}]: {`,...j(e,((e,t,a,n)=>`[${n}]: {[${k(Pt(r),`'${r}'`)}]: ${k(Pt(t),`'${t}'`)}${G(a)?l:`, [${k(Pt(s),`'${s}'`)}]: `+(J(a)?k(Pt(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(Q(a))c(null,t,y);else{const[e,a,n,d,I,$,i,u,p]=M(q,H);c(1,Z,e,a,n,I,$,i,u,p),de=[e,a,n,$,i,u],x([[e],[o],[H,"values: "+a,"values"],[H],[H,"partialValues: "+a,"partialValues"]],(([e,t,a],n)=>U(n,l,y,e,Ye(2,n),t,a))),U(0,l,v,n+De,tt(w,je)),U(5,l,w,"void",lt(w,je),"valueCallback: "+I,"valueCallback as any"),N(((e,t,a,n,d)=>{const r="Map"+kt(t,1);ne(Y,t,r),x([[t],[o],[H,`value: ${t} | `+r,", value as any"],[H]],(([t,a,o=l],r)=>U(r,d,w,t,it(e,r),a,n+o)))})),U(0,l,y+fe,fe,Ye(2,6)),U(2,l,y+fe,H,Ye(2,7),"valuesJson: "+fe,"values"+fe),_(y,$,Ye(2,8)+" changes"),_(v,i,dt(10,0,1)),_(w,u,dt(11,0),`valueId: ${n} | null`,"valueId"),_(me+w,p,ke+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),c(1,Z,...K(Y)),c(0,t,"ValueChange"),A(X,".set"+y+Ae+"({",N(((e,t,a,n)=>[`[${n}]: {[${k(Pt(r),`'${r}'`)}]: ${k(Pt(t),`'${t}'`)}${G(a)?l:`, [${k(Pt(s),`'${s}'`)}]: `+(J(a)?k(Pt(a),`'${a}'`):a)}},`])),"})")}U(0,l,"Content",`[${p}, ${y}]`,Ye(0,0)),U(2,l,"Content",H,Ye(0,2),`[tables, values]: [${p}, ${y}]`,"[tables, values]"),U(2,l,Le,H,`Applies a set of ${Le} to the Store`,"transactionChanges: "+Le,"transactionChanges"),le(Y,((e,t)=>T(t,`(cell: ${e}${ve}) => `+e,`Takes a ${e} Cell value and returns another`))),c(null,t,"DoRollback",ge,"IdOrNull",fe,"Store",Le),c(0,t,"Get"+Le,"GetTransactionLog"),U(0,l,fe,fe,Ye(0,6)),U(2,l,fe,H,Ye(0,7),"tablesAndValuesJson: "+fe,"tablesAndValuesJson"),U(7,l,Ge,"Return",Me,Ce,"actions, doRollback","<Return>"),U(7,l,"start"+Ne,H,Je),U(7,l,"finish"+Ne,H,ze,be,"doRollback");const re=z(q,H);return _("Start"+Ne,re,ke+" just before the start of the "+Ge,l,l,0),_("WillFinish"+Ne,re,ke+" just before "+We,l,l,0),_("DidFinish"+Ne,re,ke+" just after "+We,l,l,0),U(7,l,"call"+I,H,"Manually provoke a listener to be called","listenerId: Id","listenerId"),U(3,l,I,H,"Remove a listener that was previously added to "+je,"listenerId: Id","listenerId"),F("getStore",l,"Store","store",ut[0]+" the underlying Store object"),c(1,t,"createStore"),c(1,Z,H,`create${H} as create${H}Decl`,re),k("store",["createStore()",...X]),V("fluent","actions: () => Store",["actions();",`return ${q};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${q}, ...params)`),k(q,["{",...B(1),"}"]),[d(...P(0),...S(),he+" interface "+H+" {",...B(0),"}",l,St(`Creates a ${H} object`),he+" function create"+H+"(): "+H+";"),d(...P(1),he+" const create"+H+": typeof create"+H+"Decl = () => {",...O(),`return Object.freeze(${q});`,"};"),oe,de]},Wt=e=>c+e,Bt=e=>At(Wt(e),Wt(e)+ue),Ft="debugIds?: boolean",Ut="debugIds={debugIds}",_t="then"+pe,Zt="Parameter",Ht=": (parameter: "+Zt+", store: Store) => ",Qt="const contextValue = useContext(Context);",qt=", based on a parameter",Kt=": ",Xt="<"+Zt+",>",Yt=Zt+"ized"+$e+"<"+Zt+">",el="rowId",tl="rowId={rowId}",ll=", separator, debugIds",al="separator?: ReactElement | string",nl="then?: (store: Store",ol=At(nl+")"+Fe,_t),dl="then, then"+ue,rl=el+Kt+ge,sl="View",Il=(e,...t)=>At(...t,we+": "+e,we+pe,"mutator?: boolean"),cl=(...e)=>At(...e,we,we+ue,"mutator"),$l=(e,a,n,o,d)=>{const[r,s,c,$,T,V,x,k]=Dt(),[P,S,O]=Nt(e,a,T),D=`./${kt(n)}.d`,j=`./${kt(n)}-ui-react.d`,N="tinybase/ui-react",L=kt(n,1),M=kt(L),J=L+"Or"+L+ge,z=M+"Or"+L+ge,W=M+`={${M}}`,B=ee(),F=(e,t,a,n,o,d=l)=>(s(1,j,e+" as "+e+"Decl"),Tt(B,e,[t,a,n,o,d])),U=(e,t,a,n,o,d=l)=>F("use"+e,t,a,n,o,d),_=(e,t,a,n,o=l,d=l,r=l,I=l,c=l)=>(s(1,N,`use${t} as use${t}Core`),U(e,At(o,X,I),a,le+`(${z}, use${t}Core, [`+(d||l)+(c?"], ["+c:l)+"]);",n,r)),Z=(e,t,l,a)=>F(e,t,1,l,a),H=(e=0)=>ae(B,(([t,a,n,o,d],r)=>{const s=e?[he+` const ${r}: typeof ${r}Decl = ${d}(${t}): ${1==a?"any":a} =>`,n]:[he+` function ${r}${d}(${t}): ${1==a?"ComponentReturnType":a};`];return e||E(s,St(o)),A(s,l),s}));s(null,t,ge,"Store",$e,Zt+"ized"+$e),s(0,N,"ComponentReturnType"),s(null,N,"ExtraProps"),s(0,D,L);const q=c(J,L+" | "+ge,`Used when you need to refer to a ${L} in a React hook or component`),K=c(Re+xe,Et(M+ye+L,M+`ById?: {[${M}Id: Id]: ${L}}`),`Used with the ${Re} component, so that a `+L+" can be passed into the context of an application");s(0,"react","ReactElement","ComponentType"),s(1,"react","React"),s(1,j,q,K);const X=z+ye+q;T("{createContext, useContext, useMemo}","React"),T("Context",`createContext<[${L}?, {[${M}Id: Id]: ${L}}?]>([])`),U("Create"+L,`create: () => ${L}, create`+pe,L,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${L} within a React application with convenient memoization`);const Y=U(L,"id?: Id",L+ve,["{",Qt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${L} from within a ${Re} component context`),le=$("useHook",z+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${M} = ${Y}(${z} as Id);`,`return hook(...preParams, ((${z} == null || typeof ${z} == 'string')`,`? ${M} : ${z})?.getStore(), ...postParams)`]),ne=$("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),oe=$("wrap",At("children: any","separator?: any","encloseWithId?: boolean","id?: Id"),["const separated = separator==null || !Array.isArray(children)"," ? children"," : children.map((child, c) => (c > 0 ? [separator, child] : child));","return encloseWithId ? [id, ':{', separated, '}'] : separated;"]),de=T("NullComponent","() => null");if(!Q(e)){const[e,a,n,d,r,w,y,v,T,V,x,k,A,O]=o;s(null,D,e,a,n,r,w,y,v,T,V,x,k,A),s(0,D,d),s(1,D,L),s(null,t,i,"IdOrNull");const E=$("tableView",`{${M}, rowComponent, getRowComponentProps`+ll+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${oe}(rowIds.map((rowId) => (`,"<Row","{..."+ne+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",tl,W,Ut,"/>","))",ll,", tableId,",");"]),N=$("getDefaultTableComponent","tableId: Id",R(P(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+de),J=$("getDefaultCellComponent","tableId: Id, cellId: Id",R(P(((e,t,l)=>`tableId == ${l} ? ${R(S(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+de} : `)))+de);_(p,p,e,Ye(1,0)+ce);const z=_(b,b,n+De,tt(u,je)+ce);_(Oe+p+$e,Oe+p+$e,Yt,Ye(1,9)+qt,At(Wt(p)+Ht+a,Wt(p)+pe),Bt(p),Xt,At(nl,`tables: ${a})`+Fe,_t),dl),_(ie+p+$e,ie+p+$e,$e,Ye(1,12),l,l,l,ol,dl);const B=c(m+xe,Et("tableId?: TId","rowId: Id","cellId?: CId",M+ye+L,Ft),at(se+m),`<TId extends ${n}, CId extends ${d}<TId>>`),F=c(C+xe,Et("tableId?: TId","rowId: Id",M+ye+L,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${B}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,al,Ft),at(se+C),`<TId extends ${n}>`),U=c(u+xe,Et("tableId?: TId",M+ye+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",al,Ft),at(se+u),`<TId extends ${n}>`),H=c("Sorted"+u+xe,Et("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",M+ye+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",al,Ft),at(se+"sorted "+u),`<TId extends ${n}>`),Q=c(p+xe,Et(M+ye+L,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${U}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,al,Ft),at(Xe(1,1)));s(1,j,Q,U,H,F,B),Z(p+sl,"{"+M+", tableComponents, getTableComponentProps"+ll+"}: "+Q,[oe+`(${z}(${M}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+N+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ne}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",W,Ut,"/>;","}), separator)"],Ye(1,13)+ce),P(((e,t,a)=>{const[n,o,d,r,I]=te(O,e);s(null,D,n,o,d,r,I),_(t+u,u,n,It(e)+ce,l,a),_(t+u+f,u+f,i,tt(m,"the whole of "+rt(e))+ce,l,a);const c=_(t+h,h,i,tt(C,rt(e))+ce,l,a),$=_(t+g,g,i,tt(C,rt(e),1)+ce,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");_(t+C,C,d,ct(e)+ce,rl,At(a,el));const p=_(t+f,f,I+De,tt(m,st(e))+ce,rl,At(a,el));_(Oe+t+u+$e,Oe+u+$e,Yt,It(e,9)+qt,At(Wt(u)+Ht+o,Wt(u)+pe),At(a,Bt(u)),Xt,At(nl,`table: ${o})`+Fe,_t),dl),_(ie+t+u+$e,ie+u+$e,$e,It(e,12),l,a,l,ol,dl),_(Oe+t+C+$e,Oe+C+$e,Yt,ct(e,9)+qt,At(rl,Wt(C)+Ht+r,Wt(C)+pe),At(a,el,Bt(C)),Xt,At(nl,`row: ${r})`+Fe,_t),dl),_("Add"+t+C+$e,"Add"+C+$e,Yt,ct(e,10)+qt,At(Wt(C)+Ht+r,Wt(C)+pe),At(a,Bt(C)),Xt,"then?: ("+At(rl+ve,"store: Store","row: "+r+")"+Fe,"then"+pe)+", reuseRowIds?: boolean",dl+", reuseRowIds"),_(Oe+t+Ve+C+$e,Oe+Ve+C+$e,Yt,ct(e,11)+qt,At(rl,Wt(Ve+C)+Ht+r,Wt(Ve+C)+pe),At(a,el,Bt(Ve+C)),Xt,At(nl,`partialRow: ${r})`+Fe,_t),dl),_(ie+t+C+$e,ie+C+$e,$e,ct(e,12),rl,At(a,el),l,ol,dl);const b=Z(t+C+sl,"{rowId, "+M+", cellComponents, getCellComponentProps"+ll+`}: ${F}<'${e}'>`,[oe+`(${p}(rowId, ${M}).map((cellId) => {`,"const Cell = (cellComponents?.[cellId] ?? "+J+`(${a}, cellId)) as React.ComponentType<CellProps<typeof `+a+", typeof cellId>>;","return <Cell",`{...${ne}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${a}}`,tl,"cellId={cellId}",W,Ut,"/>;","})"+ll+", rowId)"],ct(e,13)+ce);Z(t+"Sorted"+u+sl,"{cellId, descending, offset, limit, ...props}: "+H+`<'${e}'>`,E+"(props, "+$+`(cellId, descending, offset, limit, props.${M}), ${a}, ${b});`,It(e,13)+", sorted"+ce),Z(t+u+sl,`props: ${U}<'${e}'>`,E+"(props, "+c+`(props.${M}), ${a}, ${b});`,It(e,13)+ce),S(e,((n,o,d,r,I)=>{const c="Map"+kt(o,1);s(0,D,c),s(1,D,c);const $=_(t+I+m,m,o+(G(d)?ve:l),$t(e,n)+ce,rl,At(a,el,r));_(Oe+t+I+m+$e,Oe+m+$e,Yt,$t(e,n,9)+qt,At(rl,Wt(m)+Ht+o+" | "+c,Wt(m)+pe),At(a,el,r,Bt(m)),Xt,At(nl,`cell: ${o} | ${c})`+Fe,_t),dl),_(ie+t+I+m+$e,ie+m+$e,$e,$t(e,n,12),At(rl,"forceDel?: boolean"),At(a,el,r,"forceDel"),l,ol,dl),Z(t+I+m+sl,`{rowId, ${M}, debugIds}: `+B+`<'${e}', '${n}'>`,[oe+`('' + ${$}(rowId, `+M+`) ?? '', undefined, debugIds, ${r})`],$t(e,n,13)+ce)}))}));const q=R(P((e=>{var t,a;return null!=(a=null==(t=te(O,e))?void 0:t[4])?a:l}))," | ");_(p+I,p+I,Be,Ye(1,8)+" changes",Il(r),cl()),_(b+I,b+I,Be,dt(2,0,1),Il(w),cl()),_(u+I,u+I,Be,dt(3,0),Il(y,`tableId: ${n} | null`),cl("tableId")),_(u+f+I,u+f+I,Be,dt(14,3,1),Il(v,`tableId: ${n} | null`),cl("tableId")),_(h+I,h+I,Be,dt(4,3,1),Il(T,`tableId: ${n} | null`),cl("tableId")),_(g+I,g+I,Be,dt(13,3,1),Il(V,`tableId: ${n} | null`,"cellId: "+q+ve,"descending: boolean","offset: number","limit: number"+ve),cl("tableId","cellId","descending","offset","limit")),_(C+I,C+I,Be,dt(5,3),Il(x,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(f+I,f+I,Be,dt(6,5,1),Il(k,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(m+I,m+I,Be,dt(7,5),Il(A,`tableId: ${n} | null`,el+": IdOrNull",`cellId: ${q} | null`),cl("tableId",el,"cellId"))}if(!Q(a)){const[e,t,a,n,o,r]=d;s(null,D,...d),s(1,D,L);const i=$("getDefaultValueComponent","valueId: Id",R(O(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+de);_(y,y,e,Ye(2,0)+ce);const u=_(v,v,a+De,tt(w,je)+ce);_(Oe+y+$e,Oe+y+$e,Yt,Ye(2,9)+qt,At(Wt(y)+Ht+t,Wt(y)+pe),Bt(y),Xt,At(nl,`values: ${t})`+Fe,_t),dl),_(Oe+Ve+y+$e,Oe+Ve+y+$e,Yt,Ye(2,11)+qt,At(Wt(Ve+y)+Ht+t,Wt(Ve+y)+pe),Bt(Ve+y),Xt,At(nl,`partialValues: ${t})`+Fe,_t),dl),_(ie+y+$e,ie+y+$e,$e,Ye(2,12),l,l,l,ol,dl);const p=c(w+xe,Et("valueId?: VId",M+ye+L,Ft),at("a Value"),`<VId extends ${a}>`),b=c(y+xe,Et(M+ye+L,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,al,Ft),at(Xe(2,1)));s(1,j,b,p),Z(y+sl,"{"+M+", valueComponents, getValueComponentProps"+ll+"}: "+b,[oe+`(${u}(${M}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+i+"(valueId);","return <Value",`{...${ne}(getValueComponentProps, valueId)}`,"key={valueId}",W,Ut,"/>;","}), separator)"],Ye(2,13)+ce),O(((e,t,a,n,o)=>{const d="Map"+kt(t,1);s(0,D,d),s(1,D,d);const r=_(o+w,w,t,it(e)+ce,l,n);_(Oe+o+w+$e,Oe+w+$e,Yt,it(e,9)+qt,At(Wt(w)+Ht+t+" | "+d,Wt(w)+pe),At(n,Bt(w)),Xt,At(nl,`value: ${t} | ${d})`+Fe,_t),dl),_(ie+o+w+$e,ie+w+$e,$e,it(e,12),l,n,l,ol,dl),Z(o+w+sl,`{${M}, debugIds}: ${p}<'${e}'>`,[oe+`('' + ${r}(`+M+`) ?? '', undefined, debugIds, ${n})`],it(e,13)+ce)})),_(y+I,y+I,Be,Ye(2,8)+" changes",Il(n),cl()),_(v+I,v+I,Be,dt(10,0,1),Il(o),cl()),_(w+I,w+I,Be,dt(11,0),Il(r,`valueId: ${a} | null`),cl("valueId"))}return Z(Re,`{${M}, ${M}ById, children}: `+K+" & {children: React.ReactNode}",["{",Qt,"return (","<Context."+Re,"value={useMemo(",`() => [${M} ?? contextValue[0], {...contextValue[1], ...${M}ById}],`,`[${M}, ${M}ById, contextValue],`,")}>","{children}",`</Context.${Re}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[r(...V(0),...x(),...H(0)),r(...V(1),...k(),...H(1))]},il=(e,t,a)=>{if(Q(e)&&Q(t))return[l,l,l,l];const[n,o,d,r]=zt(e,t,a);return[n,o,...$l(e,t,a,d,r)]};var ul=Object.defineProperty,pl=Object.defineProperties,bl=Object.getOwnPropertyDescriptors,Cl=Object.getOwnPropertySymbols,hl=Object.prototype.hasOwnProperty,gl=Object.prototype.propertyIsEnumerable,ml=(e,t,l)=>t in e?ul(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,fl=(e,t)=>{for(var l in t||(t={}))hl.call(t,l)&&ml(e,l,t[l]);if(Cl)for(var l of Cl(t))gl.call(t,l)&&ml(e,l,t[l]);return e},wl=(e,t)=>pl(e,bl(t)),yl=(e,t,l)=>new Promise(((a,n)=>{var o=e=>{try{r(l.next(e))}catch(e){n(e)}},d=e=>{try{r(l.throw(e))}catch(e){n(e)}},r=e=>e.done?a(e.value):Promise.resolve(e.value).then(o,d);r((l=l.apply(e,t)).next())}));const vl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},Tl=jt((e=>{const t=()=>{const t=j(e.getTablesSchemaJson());return!Q(t)||T(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=ee();if(T(a,(t=>T(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=oe(n,a,(()=>[W(o),ee(),[0],0])),[r,s,[I]]=d,c=oe(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),ne(s,o,c),d[3]++,r==W(o)})))))return t[l]={},X(n,(([e,,[,n],o],d)=>{t[l][d]=fl({[r]:e},o==P(a)?{[s]:n}:{})})),1}))?t:{}},l=()=>{const t=j(e.getValuesSchemaJson());return Q(t)&&e.forEachValue(((e,l)=>{t[e]={[r]:W(l)}})),t},a=e=>il(t(),l(),e),n=e=>yl(void 0,null,(function*(){const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(yield import("prettier")).format}catch(e){l=e=>e}return k(a(e),((e,a)=>Vt(l(e,wl(fl({},vl),{filepath:"_."+t[a]})))))}));return U({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,d)=>{l++;let r=0,s=0;const I={};d(((e,l)=>{r++;let a=0;l((()=>a++)),s+=a,t&&(I[e]={rowCells:a})})),a+=r,n+=s,t&&(o[e]={tableRows:r,tableCells:s,rows:I})})),fl({totalTables:l,totalRows:a,totalCells:n,totalValues:P(e.getValueIds()),jsonLength:xt(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));export{Tl as createTools};
1
+ const e=e=>typeof e,t="tinybase",l="",a=",",n=e(l),o=e(!0),d=e(0),r="type",s="default",I="Listener",c="get",u="add",$="Ids",i="Table",p=i+"s",b=i+$,C="Row",h=C+$,m="Sorted"+C+$,g="Cell",f=g+$,w="Value",y=w+"s",v=w+$,T=(e,t)=>e.every(t),V=(e,t)=>e.sort(t),x=(e,t)=>e.forEach(t),R=(e,t=l)=>e.join(t),k=(e,t)=>e.map(t),P=e=>e.length,S=(e,t)=>e.filter(t),A=(e,...t)=>e.push(...t),O=e=>e.pop(),E=(e,...t)=>e.unshift(...t),D=e=>e.shift(),j=JSON.parse,N=isFinite,L=(e,t)=>e instanceof t,G=e=>null==e,M=e=>e==n||e==o,J=t=>e(t)==n,z=e=>Array.isArray(e),W=t=>{const l=e(t);return M(l)||l==d&&N(t)?l:void 0},B=Object,F=B.keys,U=B.freeze,_=e=>L(e,B)&&e.constructor==B,Z=(e,t)=>k(B.entries(e),(([e,l])=>t(l,e))),H=e=>P(F(e)),Q=e=>_(e)&&0==H(e),q=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},K=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},X=(e,t)=>null==e?void 0:e.forEach(t),Y=(e,t)=>null==e?void 0:e.delete(t),ee=e=>new Map(e),te=(e,t)=>null==e?void 0:e.get(t),le=(e,t)=>X(e,((e,l)=>t(l,e))),ae=(e,t)=>{var l;return k([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},ne=(e,t,l)=>G(l)?(Y(e,t),e):null==e?void 0:e.set(t,l),oe=(e,t,l)=>(q(e,t)||ne(e,t,l()),te(e,t)),de=e=>e.toUpperCase(),re=e=>e.toLowerCase(),se="a ",Ie="A function for",ce=", and registers a listener so that any changes to that result will cause a re-render",ue="Callback",$e="Del",ie="Deps",pe=ie+"?: React.DependencyList",be="doRollback?: DoRollback",Ce="actions: () => Return, "+be,he="export",me="Id",ge="Invalid",fe="Json",we=re(I),ye="?: ",ve=" | undefined",Te="NonNullable",Ve="Partial",xe="Props",Re="Provider",ke=`Registers a ${we} that will be called`,Pe="Represents",Se="rowId: "+me,Ae="Schema",Oe="Set",Ee=", descending?: boolean, offset?: number, limit?: number",De="[]",je="the Store",Ne="Transaction",Le=Ne+"Changes",Ge=re(Ne),Me="Execute a "+Ge+" to make multiple mutations",Je="Explicitly starts a "+Ge,ze="Explicitly finishes a "+Ge,We="the end of the "+Ge,Be="void",Fe=" => "+Be,Ue="WhenSet",_e=" when setting it",Ze=se+"string serialization of",He=" ",Qe="Gets a callback that can ",qe="the ",Ke=" the schema for",Xe=(e=0,t=0)=>`the ${Ct[e]}content of`+(t?He+je:l),Ye=(e=0,t,a=0)=>it[t]+He+Xe(e,1)+(a?" when setting it":l),et=(e,t=0)=>Pe+` a Row when ${t?"s":"g"}etting ${Xe()} the '${e}' `+i,tt=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,lt=(e,t)=>`Calls a function for each ${e} in `+t,at=e=>"The props passed to a component that renders "+e,nt=e=>"A function that takes "+e,ot=(e,t=0)=>Ie+" listening to changes to "+bt[e]+" in "+bt[t],dt=(e,t,a=0)=>ke+" whenever "+bt[e]+" in "+bt[t]+" change"+(a?l:"s"),rt=e=>`the '${e}' `+i,st=e=>"the specified Row in "+rt(e),It=(e,t=0)=>it[t]+` ${Xe()} `+rt(e),ct=(e,t=0)=>it[t]+` ${Xe()} `+st(e),ut=(e,t,l=0)=>it[l]+` the '${t}' Cell for `+st(e),$t=(e,t=0)=>it[t]+` the '${e}' Value`,it=["Gets","Checks existence of","Sets","Deletes","Sets part of",Pe,"Gets "+Ze,"Sets "+Ze,ke+" whenever",Qe+"set",Qe+"add",Qe+"set part of",Qe+"delete","Renders","Gets "+Ze+Ke,"Sets"+Ke,"Deletes"+Ke],pt=[c,"has","set","del","set","forEach",u,l],bt=[je,p,qe+i+He+$,se+i,qe+C+He+$,se+C,qe+g+He+$,se+g,"invalid Cell changes",y,qe+w+He+$,se+w,"invalid Value changes",qe+"sorted "+C+He+$,qe+g+He+$+" anywhere"],Ct=[l,"tabular ","keyed value "],ht=e=>new Set(z(e)||G(e)?e:[e]),mt=(e,t)=>null==e?void 0:e.add(t),gt=/[^A-Za-z]+/,ft=/[^A-Za-z0-9]+/,wt=/^( *)\/\*\* *(.*?) *\*\/$/gm,yt=(e,t,l)=>e.substring(t,l),vt=e=>e.includes(a),Tt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return q(e,n)?Tt(e,t,l,a+1):(ne(e,n,l),n)},Vt=e=>e.replace(wt,((e,t,l)=>{const a=77-xt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),xt=e=>e.length,Rt=e=>e.flat(1e3),kt=(e,t=0)=>R(k(e.split(ft),((e,l)=>(l>0||t?de:re)(yt(e,0,1))+yt(e,1)))),Pt=e=>de(R((e&&!gt.test(e[0])?e:" "+e).split(ft),"_")),St=e=>`/** ${e}. */`,At=(...e)=>R(S(e,(e=>e)),", "),Ot=(...e)=>"{"+R(e,"; ")+"}",Et=(...e)=>Ot(...k(e,(e=>"readonly "+e))),Dt=()=>{const e=[ee(),ee(),ee(),ee()],t=ee(),a=ee(),n=e=>{const t=e.indexOf(" as ");return-1!=t?e.substring(t+4):e};return[(...e)=>R(Rt(e),"\n"),(t,l,...a)=>x(a,(a=>x([0,1],(n=>(null!=t?t:n)==n?mt(oe(e[n],l,ht),a):0)))),(e,a,n,o=l,d=1)=>Tt(t,e,[a,n,o,d]),(e,t,l)=>Tt(a,e,z(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>te(a,e)===t?e:Tt(a,e,t),(t=0)=>k([...V(ae(e[t],((e,t)=>`import {${R(V(K(e),((e,t)=>n(e)>n(t)?1:-1)),", ")}} from '${t}';`)),((e,t)=>vt(e)!=vt(t)?vt(e)?-1:1:e>t?1:-1)),l],(e=>e.replace("{React}","React"))),()=>ae(t,(([e,t,a,n],o)=>[St(t),`${n?he+" ":l}type ${o}${a} = ${e};`,l])),()=>ae(a,((e,t)=>(e=z(e)?e:[e],A(e,O(e)+";"),[`const ${t} = ${D(e)}`,e,l])))]},jt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Nt=(e,t,l)=>[t=>Z(e,((e,a)=>t(a,kt(a,1),l(Pt(a),`'${a}'`)))),(t,a)=>Z(e[t],((e,t)=>a(t,e[r],e[s],l(Pt(t),`'${t}'`),kt(t,1)))),e=>Z(t,((t,a)=>e(a,t[r],t[s],l(Pt(a),`'${a}'`),kt(a,1))))],Lt=(e,t,a,n)=>[(n,o)=>{const d=n+": "+o,r=e(p,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...a(e,((e,t,a)=>`'${e}'${G(a)?"?":l}: ${t}`)))+"}"))),Ye(1,5)),s=e(p+Ue,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Ye(1,5,1)),c=e(i+me,"keyof "+r,"A "+i+" Id in "+je),u=`<TId extends ${c}>`,$=e(i,Te+`<${r}[TId]>`,"A "+i+" in "+je,u),w=e(i+Ue,Te+`<${s}[TId]>`,"A "+i+" in "+je+_e,u),y=e(C,$+"<TId>[Id]","A "+C+" in a "+i,u),v=e(C+Ue,w+"<TId>[Id]","A "+C+" in a "+i+_e,u),T=e(g+me,`Extract<keyof ${y}<TId>, Id>`,"A "+g+" Id in a "+C,u),V=e(g,Te+`<${r}[TId]>[Id][CId]`,"A "+g+" in a "+C,`<TId extends ${c}, CId extends ${T}<TId>>`),x=e("CellIdCellArray",`CId extends ${T}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,g+" Ids and types in a "+C,`<TId extends ${c}, CId = ${T}<TId>>`,0),R=e(g+ue,`(...[cellId, cell]: ${x}<TId>)`+Fe,nt(se+g+" Id, and "+g),u),k=e(C+ue,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Fe+") "+Fe,nt(se+C+" Id, and a "+g+" iterator"),u),P=e(i+g+ue,`(cellId: ${T}<TId>, count: number) `+Fe,nt(se+g+" Id, and count of how many times it appears"),u),S=e("TableIdForEachRowArray",`TId extends ${c} ? [tableId: TId, forEachRow: (rowCallback: ${k}<TId>)${Fe}] : never`,i+" Ids and callback types",`<TId = ${c}>`,0),A=e(i+ue,`(...[tableId, forEachRow]: ${S})`+Fe,nt(se+i+" Id, and a "+C+" iterator"),l),O=e("TableIdRowIdCellIdArray",`TId extends ${c} ? [tableId: TId, rowId: Id, cellId: ${T}<TId>] : never`,"Ids for GetCellChange",`<TId = ${c}>`,0),E=e("GetCellChange",`(...[tableId, rowId, cellId]: ${O}) => CellChange`,Ie+" returning information about any Cell's changes during a "+Ge),D=e(p+I,`(${d}, getCellChange: ${E}${ve})`+Fe,ot(1)),j=e(b+I,`(${d})`+Fe,ot(2)),N=e(i+I,`(${d}, tableId: ${c}, getCellChange: ${E}${ve})`+Fe,ot(3)),L=e(i+f+I,`(${d}, tableId: ${c})`+Fe,ot(14,3)),M=e(h+I,`(${d}, tableId: ${c})`+Fe,ot(4,3)),J=e(m+I,"("+At(d,"tableId: "+c,"cellId: Id"+ve,"descending: boolean","offset: number","limit: number"+ve,"sortedRowIds: Ids")+")"+Fe,ot(13,3)),z=e(C+I,"("+At(""+d,"tableId: "+c,Se,`getCellChange: ${E}${ve}`)+")"+Fe,ot(5,3)),W=e(f+I,"("+At(""+d,"tableId: "+c,Se)+")"+Fe,ot(6,5)),B=e("CellListenerArgsArrayInner",`CId extends ${T}<TId> ? [${d}, tableId: TId, ${Se}, cellId: CId, newCell: ${V}<TId, CId> ${ve}, oldCell: ${V}<TId, CId> ${ve}, getCellChange: ${E} ${ve}] : never`,"Cell args for CellListener",`<TId extends ${c}, CId = ${T}<TId>>`,0),F=e("CellListenerArgsArrayOuter",`TId extends ${c} ? `+B+"<TId> : never","Table args for CellListener",`<TId = ${c}>`,0);return[r,s,c,$,w,y,v,T,V,R,k,P,A,D,j,N,L,M,J,z,W,e(g+I,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${F})`+Fe,ot(7,5)),e(ge+g+I,`(${d}, tableId: Id, ${Se}, cellId: Id, invalidCells: any[])`+Fe,ot(8))]},(t,a)=>{const o=t+": "+a,d=e(y,Ot(...n(((e,t,a)=>`'${e}'${G(a)?"?":l}: ${t}`))),Ye(2,5)),r=e(y+Ue,Ot(...n(((e,t)=>`'${e}'?: ${t}`))),Ye(2,5,1)),s=e(w+me,"keyof "+d,"A "+w+" Id in "+je),c=e(w,Te+`<${d}[VId]>`,"A "+w+" Id in "+je,`<VId extends ${s}>`),u=e("ValueIdValueArray",`VId extends ${s} ? [valueId: VId, value: ${c}<VId>] : never`,w+" Ids and types in "+je,`<VId = ${s}>`,0),$=e(w+ue,`(...[valueId, value]: ${u})`+Fe,nt(se+w+" Id, and "+w)),i=e("GetValueChange",`(valueId: ${s}) => ValueChange`,Ie+" returning information about any Value's changes during a "+Ge),p=e(y+I,`(${o}, getValueChange: ${i}${ve})`+Fe,ot(9)),b=e(v+I,`(${o})`+Fe,ot(10)),C=e("ValueListenerArgsArray",`VId extends ${s} ? [${o}, valueId: VId, newValue: ${c}<VId> ${ve}, oldValue: ${c}<VId> ${ve}, getValueChange: ${i} ${ve}] : never`,"Value args for ValueListener",`<VId = ${s}>`,0);return[d,r,s,c,$,p,b,e(w+I,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Fe,ot(11)),e(ge+w+I,`(${o}, valueId: Id, invalidValues: any[])`+Fe,ot(12))]},(t,l)=>e(Ne+I,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Fe,Ie+" listening to the completion of a "+Ge)],Gt=(e,t=l,a=l)=>`store.${e}(${t})`+(a?" as "+a:l),Mt=(e,t=l)=>`fluent(() => ${Gt(e,t)})`,Jt=(e,t=l,a=l)=>`store.${e}(${t?t+", ":l}proxy(listener)${a?", "+a:l})`,zt=(e,a,n)=>{const[d,c,T,V,k,P,S,O]=Dt(),[D,j,N]=Nt(e,a,k),[L,M,z]=Lt(T,D,j,N),W=ee(),B=(e=0)=>ae(W,(([t,a,n,o,d],r)=>{const s=e?[r+`: ${d}(${t}): ${a} => ${n},`]:[r+d+`(${t}): ${a};`];return e||E(s,St(o)),A(s,l),s})),F=(e,t,a,n,o,d=l)=>Tt(W,e,[t,a,n,o,d]),U=(e,t,a,n,o,d=l,r=l,s=l)=>F(pt[e]+t+(4==e?Ve:l)+a,d,n,(n==H?Mt:Gt)(pt[e]+(4==e?Ve:l)+a,r,e?void 0:n),o,s),_=(e,t,a,n=l,o=l,d=1,r=l)=>F(u+e+I,(n?n+", ":l)+we+": "+t+(d?", mutator?: boolean":l),me,Jt(u+e+I,o,d?"mutator":l),a,r),Z=`./${kt(n)}.d`,H=kt(n,1),q=kt(H),X=[],Y=ee();let oe=[],de=[];if(c(1,Z,H,`create${H} as create${H}Decl`),Q(e))c(null,t,p);else{c(0,t,"CellChange"),c(null,t,$);const[e,a,n,d,I,u,w,y,v,V,P,S,O,E,N,M,z,W,B,F,Q,le,ae]=L(q,H),de=ee();D(((e,t)=>{const l=`<'${e}'>`,a=[T(t+i,d+l,Pe+` the '${e}' `+i),T(t+i+Ue,I+l,Pe+` the '${e}' `+i+_e),T(t+C,u+l,et(e)),T(t+C+Ue,w+l,et(e,1)),T(t+g+me,y+l,`A Cell Id for the '${e}' `+i),T(t+g+ue,V+l,nt(`a Cell Id and value from a Row in the '${e}' `+i)),T(t+C+ue,P+l,nt(`a Row Id from the '${e}' Table, and a Cell iterator`)),T(t+i+g+ue,S+l,nt(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];ne(de,e,a),c(1,Z,...a)})),c(1,Z,e,a,n,y,O,E,N,M,z,W,B,F,Q,le,ae),oe=[e,a,n,y,E,N,M,z,W,B,F,Q,le,de],x([[e],[o],[H,"tables: "+a,"tables"],[H]],(([e,t,a],n)=>U(n,l,p,e,Ye(1,n),t,a))),U(0,l,b,n+De,tt(i,je)),U(5,l,i,Be,lt(i,je),"tableCallback: "+O,"tableCallback as any"),D(((e,t,a)=>{const[n,d,r,s,I,c,u,p]=te(de,e);x([[n],[o],[H,"table: "+d,", table"],[H]],(([n,o,d=l],r)=>U(r,t,i,n,It(e,r),o,a+d))),U(0,t,i+f,$,tt(g,"the whole of "+rt(e)),l,a),U(5,t,i+g,Be,lt(i+g,"the whole of "+rt(e)),"tableCellCallback: "+p,a+", tableCellCallback as any"),U(0,t,h,$,tt(C,rt(e)),l,a),U(0,t,m,$,tt(C,rt(e),1),"cellId?: "+I+Ee,a+", cellId, descending, offset, limit"),U(5,t,C,Be,lt(C,rt(e)),"rowCallback: "+u,a+", rowCallback as any"),x([[r],[o],[H,", row: "+s,", row"],[H],[H,", partialRow: "+s,", partialRow"]],(([n,o=l,d=l],r)=>U(r,t,C,n,ct(e,r),Se+o,a+", rowId"+d))),U(6,t,C,me+ve,"Add a new Row to "+rt(e),"row: "+s+", reuseIds?: boolean",a+", row, reuseIds"),U(0,t,f,I+De,tt(g,st(e)),Se,a+", rowId"),U(5,t,g,Be,lt(g,st(e)),Se+", cellCallback: "+c,a+", rowId, cellCallback as any"),j(e,((n,d,r,s,I)=>{const c="Map"+kt(d,1);ne(Y,d,c);const u=d+(G(r)?ve:l);x([[u],[o],[H,`, cell: ${d} | `+c,", cell as any"],[H]],(([o,d=l,r=l],c)=>U(c,t+I,g,o,ut(e,n,c),Se+d,a+", rowId, "+s+r))),U(1,t+I,i+g,o,it[1]+` the '${n}' Cell anywhere in `+rt(e),l,a+", "+s)}))})),U(0,l,p+fe,fe,Ye(1,6)),U(2,l,p+fe,H,Ye(1,7),"tablesJson: "+fe,"tables"+fe),_(p,E,Ye(1,8)+" changes"),_(b,N,dt(2,0,1)),_(i,M,dt(3,0),`tableId: ${n} | null`,"tableId"),_(i+f,z,dt(14,3,1),`tableId: ${n} | null`,"tableId"),_(h,W,dt(4,3,1),`tableId: ${n} | null`,"tableId"),_(m,B,dt(13,3,1),At("tableId: TId",`cellId: ${y}<TId>`+ve,"descending: boolean","offset: number","limit: number"+ve),At("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),_(C,F,dt(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(f,Q,dt(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(g,le,dt(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${R(D((e=>{var t,a;return null!=(a=null==(t=te(de,e))?void 0:t[4])?a:l}))," | ")} | null`,"tableId, rowId, cellId"),_(ge+g,ae,ke+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),c(1,Z,...K(Y)),A(X,".set"+p+Ae+"({",Rt(D(((e,t,a)=>[`[${a}]: {`,...j(e,((e,t,a,n)=>`[${n}]: {[${k(Pt(r),`'${r}'`)}]: ${k(Pt(t),`'${t}'`)}${G(a)?l:`, [${k(Pt(s),`'${s}'`)}]: `+(J(a)?k(Pt(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(Q(a))c(null,t,y);else{const[e,a,n,d,I,u,$,i,p]=M(q,H);c(1,Z,e,a,n,I,u,$,i,p),de=[e,a,n,u,$,i],x([[e],[o],[H,"values: "+a,"values"],[H],[H,"partialValues: "+a,"partialValues"]],(([e,t,a],n)=>U(n,l,y,e,Ye(2,n),t,a))),U(0,l,v,n+De,tt(w,je)),U(5,l,w,"void",lt(w,je),"valueCallback: "+I,"valueCallback as any"),N(((e,t,a,n,d)=>{const r="Map"+kt(t,1);ne(Y,t,r),x([[t],[o],[H,`value: ${t} | `+r,", value as any"],[H]],(([t,a,o=l],r)=>U(r,d,w,t,$t(e,r),a,n+o)))})),U(0,l,y+fe,fe,Ye(2,6)),U(2,l,y+fe,H,Ye(2,7),"valuesJson: "+fe,"values"+fe),_(y,u,Ye(2,8)+" changes"),_(v,$,dt(10,0,1)),_(w,i,dt(11,0),`valueId: ${n} | null`,"valueId"),_(ge+w,p,ke+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),c(1,Z,...K(Y)),c(0,t,"ValueChange"),A(X,".set"+y+Ae+"({",N(((e,t,a,n)=>[`[${n}]: {[${k(Pt(r),`'${r}'`)}]: ${k(Pt(t),`'${t}'`)}${G(a)?l:`, [${k(Pt(s),`'${s}'`)}]: `+(J(a)?k(Pt(a),`'${a}'`):a)}},`])),"})")}U(0,l,"Content",`[${p}, ${y}]`,Ye(0,0)),U(2,l,"Content",H,Ye(0,2),`[tables, values]: [${p}, ${y}]`,"[tables, values]"),U(2,l,Le,H,`Applies a set of ${Le} to the Store`,"transactionChanges: "+Le,"transactionChanges"),le(Y,((e,t)=>T(t,`(cell: ${e}${ve}) => `+e,`Takes a ${e} Cell value and returns another`))),c(null,t,"DoRollback",me,"IdOrNull",fe,"Store",Le),c(0,t,"Get"+Le,"GetTransactionLog"),U(0,l,fe,fe,Ye(0,6)),U(2,l,fe,H,Ye(0,7),"tablesAndValuesJson: "+fe,"tablesAndValuesJson"),U(7,l,Ge,"Return",Me,Ce,"actions, doRollback","<Return>"),U(7,l,"start"+Ne,H,Je),U(7,l,"finish"+Ne,H,ze,be,"doRollback");const re=z(q,H);return _("Start"+Ne,re,ke+" just before the start of the "+Ge,l,l,0),_("WillFinish"+Ne,re,ke+" just before "+We,l,l,0),_("DidFinish"+Ne,re,ke+" just after "+We,l,l,0),U(7,l,"call"+I,H,"Manually provoke a listener to be called","listenerId: Id","listenerId"),U(3,l,I,H,"Remove a listener that was previously added to "+je,"listenerId: Id","listenerId"),F("getStore",l,"Store","store",it[0]+" the underlying Store object"),c(1,t,"createStore"),c(1,Z,H,`create${H} as create${H}Decl`,re),k("store",["createStore()",...X]),V("fluent","actions: () => Store",["actions();",`return ${q};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${q}, ...params)`),k(q,["{",...B(1),"}"]),[d(...P(0),...S(),he+" interface "+H+" {",...B(0),"}",l,St(`Creates a ${H} object`),he+" function create"+H+"(): "+H+";"),d(...P(1),he+" const create"+H+": typeof create"+H+"Decl = () => {",...O(),`return Object.freeze(${q});`,"};"),oe,de]},Wt=e=>c+e,Bt=e=>At(Wt(e),Wt(e)+ie),Ft="debugIds?: boolean",Ut="debugIds={debugIds}",_t="then"+pe,Zt="Parameter",Ht=": (parameter: "+Zt+", store: Store) => ",Qt="const contextValue = useContext(Context);",qt=", based on a parameter",Kt=": ",Xt="<"+Zt+",>",Yt=Zt+"ized"+ue+"<"+Zt+">",el="rowId",tl="rowId={rowId}",ll=", separator, debugIds",al="separator?: ReactElement | string",nl="then?: (store: Store",ol=At(nl+")"+Fe,_t),dl="then, then"+ie,rl=el+Kt+me,sl="View",Il=(e,...t)=>At(...t,we+": "+e,we+pe,"mutator?: boolean"),cl=(...e)=>At(...e,we,we+ie,"mutator"),ul=(e,a,n,o,d)=>{const[r,s,c,u,T,V,x,k]=Dt(),[P,S,O]=Nt(e,a,T),D=`./${kt(n)}.d`,j=`./${kt(n)}-ui-react.d`,N="tinybase/ui-react",L=kt(n,1),M=kt(L),J=L+"Or"+L+me,z=M+"Or"+L+me,W=M+`={${M}}`,B=ee(),F=(e,t,a,n,o,d=l)=>(s(1,j,e+" as "+e+"Decl"),Tt(B,e,[t,a,n,o,d])),U=(e,t,a,n,o,d=l)=>F("use"+e,t,a,n,o,d),_=(e,t,a,n,o=l,d=l,r=l,I=l,c=l)=>(s(1,N,`use${t} as use${t}Core`),U(e,At(o,X,I),a,le+`(${z}, use${t}Core, [`+(d||l)+(c?"], ["+c:l)+"]);",n,r)),Z=(e,t,l,a)=>F(e,t,1,l,a),H=(e=0)=>ae(B,(([t,a,n,o,d],r)=>{const s=e?[he+` const ${r}: typeof ${r}Decl = ${d}(${t}): ${1==a?"any":a} =>`,n]:[he+` function ${r}${d}(${t}): ${1==a?"ComponentReturnType":a};`];return e||E(s,St(o)),A(s,l),s}));s(null,t,me,"Store",ue,Zt+"ized"+ue),s(0,N,"ComponentReturnType"),s(1,N,"useCellIds"),s(null,N,"ExtraProps"),s(0,D,L);const q=c(J,L+" | "+me,`Used when you need to refer to a ${L} in a React hook or component`),K=c(Re+xe,Et(M+ye+L,M+`ById?: {[${M}Id: Id]: ${L}}`),`Used with the ${Re} component, so that a `+L+" can be passed into the context of an application");s(0,"react","ReactElement","ComponentType"),s(1,"react","React"),s(1,j,q,K);const X=z+ye+q;T("{createContext, useContext, useMemo}","React"),T("Context",`createContext<[${L}?, {[${M}Id: Id]: ${L}}?]>([])`),U("Create"+L,`create: () => ${L}, create`+pe,L,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${L} within a React application with convenient memoization`);const Y=U(L,"id?: Id",L+ve,["{",Qt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${L} from within a ${Re} component context`),le=u("useHook",z+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${M} = ${Y}(${z} as Id);`,`return hook(...preParams, ((${z} == null || typeof ${z} == 'string')`,`? ${M} : ${z})?.getStore(), ...postParams)`]),ne=u("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),oe=u("wrap",At("children: any","separator?: any","encloseWithId?: boolean","id?: Id"),["const separated = separator==null || !Array.isArray(children)"," ? children"," : children.map((child, c) => (c > 0 ? [separator, child] : child));","return encloseWithId ? [id, ':{', separated, '}'] : separated;"]),de=u("useCustomOrDefaultCellIds",At("customCellIds: Ids | undefined","tableId: Id","rowId: Id",`${z}?: ${q} | undefined`),[`const defaultCellIds = ${le}(${z}, useCellIds, [tableId, rowId]);`,"return customCellIds ?? defaultCellIds;"]),re=T("NullComponent","() => null");if(!Q(e)){const[e,a,n,d,r,w,y,v,T,V,x,k,A,O]=o;s(null,D,e,a,n,r,w,y,v,T,V,x,k,A),s(0,D,d),s(1,D,L),s(null,t,$,"IdOrNull");const E=u("tableView",`{${M}, rowComponent, getRowComponentProps, customCellIds`+ll+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${oe}(rowIds.map((rowId) => (`,"<Row","{..."+ne+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",tl,"customCellIds={customCellIds}",W,Ut,"/>","))",ll,", tableId,",");"]),N=u("getDefaultTableComponent","tableId: Id",R(P(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+re),J=u("getDefaultCellComponent","tableId: Id, cellId: Id",R(P(((e,t,l)=>`tableId == ${l} ? ${R(S(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+re} : `)))+re);_(p,p,e,Ye(1,0)+ce);const z=_(b,b,n+De,tt(i,je)+ce);_(Oe+p+ue,Oe+p+ue,Yt,Ye(1,9)+qt,At(Wt(p)+Ht+a,Wt(p)+pe),Bt(p),Xt,At(nl,`tables: ${a})`+Fe,_t),dl),_($e+p+ue,$e+p+ue,ue,Ye(1,12),l,l,l,ol,dl);const B=c(g+xe,Et("tableId?: TId","rowId: Id","cellId?: CId",M+ye+L,Ft),at(se+g),`<TId extends ${n}, CId extends ${d}<TId>>`),F=c(C+xe,Et("tableId?: TId","rowId: Id",M+ye+L,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${B}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,`customCellIds?: ${d}<TId>[]`,al,Ft),at(se+C),`<TId extends ${n}>`),U=c(i+xe,Et("tableId?: TId",M+ye+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",al,Ft),at(se+i),`<TId extends ${n}>`),H=c("Sorted"+i+xe,Et("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",M+ye+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",al,Ft),at(se+"sorted "+i),`<TId extends ${n}>`),Q=c(p+xe,Et(M+ye+L,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${U}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,al,Ft),at(Xe(1,1)));s(1,j,Q,U,H,F,B),Z(p+sl,"{"+M+", tableComponents, getTableComponentProps"+ll+"}: "+Q,[oe+`(${z}(${M}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+N+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ne}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",W,Ut,"/>;","}), separator)"],Ye(1,13)+ce),P(((e,t,a)=>{const[n,o,d,r,I]=te(O,e);s(null,D,n,o,d,r,I),_(t+i,i,n,It(e)+ce,l,a),_(t+i+f,i+f,$,tt(g,"the whole of "+rt(e))+ce,l,a);const c=_(t+h,h,$,tt(C,rt(e))+ce,l,a),u=_(t+m,m,$,tt(C,rt(e),1)+ce,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");_(t+C,C,d,ct(e)+ce,rl,At(a,el)),_(t+f,f,I+De,tt(g,st(e))+ce,rl,At(a,el)),_(Oe+t+i+ue,Oe+i+ue,Yt,It(e,9)+qt,At(Wt(i)+Ht+o,Wt(i)+pe),At(a,Bt(i)),Xt,At(nl,`table: ${o})`+Fe,_t),dl),_($e+t+i+ue,$e+i+ue,ue,It(e,12),l,a,l,ol,dl),_(Oe+t+C+ue,Oe+C+ue,Yt,ct(e,9)+qt,At(rl,Wt(C)+Ht+r,Wt(C)+pe),At(a,el,Bt(C)),Xt,At(nl,`row: ${r})`+Fe,_t),dl),_("Add"+t+C+ue,"Add"+C+ue,Yt,ct(e,10)+qt,At(Wt(C)+Ht+r,Wt(C)+pe),At(a,Bt(C)),Xt,"then?: ("+At(rl+ve,"store: Store","row: "+r+")"+Fe,"then"+pe)+", reuseRowIds?: boolean",dl+", reuseRowIds"),_(Oe+t+Ve+C+ue,Oe+Ve+C+ue,Yt,ct(e,11)+qt,At(rl,Wt(Ve+C)+Ht+r,Wt(Ve+C)+pe),At(a,el,Bt(Ve+C)),Xt,At(nl,`partialRow: ${r})`+Fe,_t),dl),_($e+t+C+ue,$e+C+ue,ue,ct(e,12),rl,At(a,el),l,ol,dl);const p=Z(t+C+sl,"{rowId, "+M+", cellComponents, getCellComponentProps, customCellIds"+ll+`}: ${F}<'${e}'>`,[oe+`(${de}(customCellIds, `+a+`, rowId, ${M}).map((cellId: ${I}) => {`,"const Cell = (cellComponents?.[cellId] ?? "+J+`(${a}, cellId)) as React.ComponentType<CellProps<typeof `+a+", typeof cellId>>;","return <Cell",`{...${ne}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${a}}`,tl,"cellId={cellId}",W,Ut,"/>;","})"+ll+", rowId)"],ct(e,13)+ce);Z(t+"Sorted"+i+sl,"{cellId, descending, offset, limit, ...props}: "+H+`<'${e}'>`,E+"(props, "+u+`(cellId, descending, offset, limit, props.${M}), ${a}, ${p});`,It(e,13)+", sorted"+ce),Z(t+i+sl,`props: ${U}<'${e}'>`,E+"(props, "+c+`(props.${M}), ${a}, ${p});`,It(e,13)+ce),S(e,((n,o,d,r,I)=>{const c="Map"+kt(o,1);s(0,D,c),s(1,D,c);const u=_(t+I+g,g,o+(G(d)?ve:l),ut(e,n)+ce,rl,At(a,el,r));_(Oe+t+I+g+ue,Oe+g+ue,Yt,ut(e,n,9)+qt,At(rl,Wt(g)+Ht+o+" | "+c,Wt(g)+pe),At(a,el,r,Bt(g)),Xt,At(nl,`cell: ${o} | ${c})`+Fe,_t),dl),_($e+t+I+g+ue,$e+g+ue,ue,ut(e,n,12),At(rl,"forceDel?: boolean"),At(a,el,r,"forceDel"),l,ol,dl),Z(t+I+g+sl,`{rowId, ${M}, debugIds}: `+B+`<'${e}', '${n}'>`,[oe+`('' + ${u}(rowId, `+M+`) ?? '', undefined, debugIds, ${r})`],ut(e,n,13)+ce)}))}));const q=R(P((e=>{var t,a;return null!=(a=null==(t=te(O,e))?void 0:t[4])?a:l}))," | ");_(p+I,p+I,Be,Ye(1,8)+" changes",Il(r),cl()),_(b+I,b+I,Be,dt(2,0,1),Il(w),cl()),_(i+I,i+I,Be,dt(3,0),Il(y,`tableId: ${n} | null`),cl("tableId")),_(i+f+I,i+f+I,Be,dt(14,3,1),Il(v,`tableId: ${n} | null`),cl("tableId")),_(h+I,h+I,Be,dt(4,3,1),Il(T,`tableId: ${n} | null`),cl("tableId")),_(m+I,m+I,Be,dt(13,3,1),Il(V,`tableId: ${n} | null`,"cellId: "+q+ve,"descending: boolean","offset: number","limit: number"+ve),cl("tableId","cellId","descending","offset","limit")),_(C+I,C+I,Be,dt(5,3),Il(x,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(f+I,f+I,Be,dt(6,5,1),Il(k,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(g+I,g+I,Be,dt(7,5),Il(A,`tableId: ${n} | null`,el+": IdOrNull",`cellId: ${q} | null`),cl("tableId",el,"cellId"))}if(!Q(a)){const[e,t,a,n,o,r]=d;s(null,D,...d),s(1,D,L);const $=u("getDefaultValueComponent","valueId: Id",R(O(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+re);_(y,y,e,Ye(2,0)+ce);const i=_(v,v,a+De,tt(w,je)+ce);_(Oe+y+ue,Oe+y+ue,Yt,Ye(2,9)+qt,At(Wt(y)+Ht+t,Wt(y)+pe),Bt(y),Xt,At(nl,`values: ${t})`+Fe,_t),dl),_(Oe+Ve+y+ue,Oe+Ve+y+ue,Yt,Ye(2,11)+qt,At(Wt(Ve+y)+Ht+t,Wt(Ve+y)+pe),Bt(Ve+y),Xt,At(nl,`partialValues: ${t})`+Fe,_t),dl),_($e+y+ue,$e+y+ue,ue,Ye(2,12),l,l,l,ol,dl);const p=c(w+xe,Et("valueId?: VId",M+ye+L,Ft),at("a Value"),`<VId extends ${a}>`),b=c(y+xe,Et(M+ye+L,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,al,Ft),at(Xe(2,1)));s(1,j,b,p),Z(y+sl,"{"+M+", valueComponents, getValueComponentProps"+ll+"}: "+b,[oe+`(${i}(${M}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+$+"(valueId);","return <Value",`{...${ne}(getValueComponentProps, valueId)}`,"key={valueId}",W,Ut,"/>;","}), separator)"],Ye(2,13)+ce),O(((e,t,a,n,o)=>{const d="Map"+kt(t,1);s(0,D,d),s(1,D,d);const r=_(o+w,w,t,$t(e)+ce,l,n);_(Oe+o+w+ue,Oe+w+ue,Yt,$t(e,9)+qt,At(Wt(w)+Ht+t+" | "+d,Wt(w)+pe),At(n,Bt(w)),Xt,At(nl,`value: ${t} | ${d})`+Fe,_t),dl),_($e+o+w+ue,$e+w+ue,ue,$t(e,12),l,n,l,ol,dl),Z(o+w+sl,`{${M}, debugIds}: ${p}<'${e}'>`,[oe+`('' + ${r}(`+M+`) ?? '', undefined, debugIds, ${n})`],$t(e,13)+ce)})),_(y+I,y+I,Be,Ye(2,8)+" changes",Il(n),cl()),_(v+I,v+I,Be,dt(10,0,1),Il(o),cl()),_(w+I,w+I,Be,dt(11,0),Il(r,`valueId: ${a} | null`),cl("valueId"))}return Z(Re,`{${M}, ${M}ById, children}: `+K+" & {children: React.ReactNode}",["{",Qt,"return (","<Context."+Re,"value={useMemo(",`() => [${M} ?? contextValue[0], {...contextValue[1], ...${M}ById}],`,`[${M}, ${M}ById, contextValue],`,")}>","{children}",`</Context.${Re}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[r(...V(0),...x(),...H(0)),r(...V(1),...k(),...H(1))]},$l=(e,t,a)=>{if(Q(e)&&Q(t))return[l,l,l,l];const[n,o,d,r]=zt(e,t,a);return[n,o,...ul(e,t,a,d,r)]};var il=Object.defineProperty,pl=Object.defineProperties,bl=Object.getOwnPropertyDescriptors,Cl=Object.getOwnPropertySymbols,hl=Object.prototype.hasOwnProperty,ml=Object.prototype.propertyIsEnumerable,gl=(e,t,l)=>t in e?il(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,fl=(e,t)=>{for(var l in t||(t={}))hl.call(t,l)&&gl(e,l,t[l]);if(Cl)for(var l of Cl(t))ml.call(t,l)&&gl(e,l,t[l]);return e},wl=(e,t)=>pl(e,bl(t)),yl=(e,t,l)=>new Promise(((a,n)=>{var o=e=>{try{r(l.next(e))}catch(e){n(e)}},d=e=>{try{r(l.throw(e))}catch(e){n(e)}},r=e=>e.done?a(e.value):Promise.resolve(e.value).then(o,d);r((l=l.apply(e,t)).next())}));const vl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},Tl=jt((e=>{const t=()=>{const t=j(e.getTablesSchemaJson());return!Q(t)||T(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=ee();if(T(a,(t=>T(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=oe(n,a,(()=>[W(o),ee(),[0],0])),[r,s,[I]]=d,c=oe(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),ne(s,o,c),d[3]++,r==W(o)})))))return t[l]={},X(n,(([e,,[,n],o],d)=>{t[l][d]=fl({[r]:e},o==P(a)?{[s]:n}:{})})),1}))?t:{}},l=()=>{const t=j(e.getValuesSchemaJson());return Q(t)&&e.forEachValue(((e,l)=>{t[e]={[r]:W(l)}})),t},a=e=>$l(t(),l(),e),n=e=>yl(void 0,null,(function*(){const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(yield import("prettier")).format}catch(e){l=e=>e}return k(a(e),((e,a)=>Vt(l(e,wl(fl({},vl),{filepath:"_."+t[a]})))))}));return U({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,d)=>{l++;let r=0,s=0;const I={};d(((e,l)=>{r++;let a=0;l((()=>a++)),s+=a,t&&(I[e]={rowCells:a})})),a+=r,n+=s,t&&(o[e]={tableRows:r,tableCells:s,rows:I})})),fl({totalTables:l,totalRows:a,totalCells:n,totalValues:P(e.getValueIds()),jsonLength:xt(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));export{Tl as createTools};
Binary file
@@ -0,0 +1 @@
1
+ import{useRowIds as e,useSortedRowIds as l,useValueIds as t,ValueView as r,useTableCellIds as o,CellView as n}from"./ui-react";import a from"react";const s=(e,l)=>e.map(l),d=e=>null==e,{createContext:c,useContext:u}=a;c([]);const i=(e,...l)=>d(e)?{}:e(...l);var b=Object.defineProperty,m=Object.defineProperties,p=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,v=(e,l,t)=>l in e?b(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,y=(e,l)=>{for(var t in l||(l={}))f.call(l,t)&&v(e,t,l[t]);if(I)for(var t of I(l))C.call(l,t)&&v(e,t,l[t]);return e},g=(e,l)=>m(e,p(l)),k=(e,l)=>{var t={};for(var r in e)f.call(e,r)&&l.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&I)for(var r of I(e))l.indexOf(r)<0&&C.call(e,r)&&(t[r]=e[r]);return t};const{createElement:O,useCallback:h,useState:w}=a,P=(e,l,t)=>{const r=h(e,l);return t?r:void 0},j=(e,l)=>d(e)||e[0]!=l?void 0:`sorted ${e[1]?"de":"a"}scending`,x=({cellId:e,sorting:l,label:t=(null!=e?e:""),onClick:r})=>O("th",{onClick:P((()=>null==r?void 0:r(e)),[r,e],!d(r)),className:j(l,e)},t),N=({tableId:e,rowIds:l,store:t,cellComponent:r=n,getCellComponentProps:a,className:d,headerRow:c,idColumn:u,customCellIds:b,sorting:m,onHeaderThClick:p})=>{const I=o(e,t),f=null!=b?b:I;return O("table",{className:d},!1===c?null:O("thead",null,O("tr",null,!1===u?null:O(x,{sorting:m,label:"Id",onClick:p}),s(f,(e=>O(x,{key:e,cellId:e,sorting:m,onClick:p}))))),O("tbody",null,s(l,(l=>O("tr",{key:l},!1===u?null:O("th",null,l),s(f,(o=>O("td",{key:o},O(r,g(y({},i(a,l,o)),{tableId:e,rowId:l,cellId:o,store:t}))))))))))},E=l=>{var t=l,{tableId:r,store:o}=t,n=k(t,["tableId","store"]);return O(N,g(y({},n),{tableId:r,store:o,rowIds:e(r,o)}))},H=e=>{var t=e,{tableId:r,cellId:o,descending:n,offset:a,limit:s,store:d,sortOnClick:c}=t,u=k(t,["tableId","cellId","descending","offset","limit","store","sortOnClick"]);const[i,b]=w([o,!!n]),m=P((e=>b([e,e==i[0]&&!i[1]])),[i],c);return O(N,g(y({},u),{tableId:r,store:d,rowIds:l(r,...i,a,s,d),sorting:i,onHeaderThClick:m}))},R=({store:e,valueComponent:l=r,getValueComponentProps:o,className:n,headerRow:a,idColumn:d})=>O("table",{className:n},!1===a?null:O("thead",null,O("tr",null,!1===d?null:O("th",null,"Id"),O("th",null,"Value"))),O("tbody",null,s(t(e),(t=>O("tr",{key:t},!1===d?null:O("th",null,t),O("td",null,O(l,g(y({},i(o,t)),{valueId:t,store:e}))))))));export{H as SortedTableInHtmlTable,E as TableInHtmlTable,R as ValuesInHtmlTable};
Binary file
@@ -1 +1 @@
1
- import e,{useContext as o}from"react";const t=e=>typeof e,r="",d=t(r),n="Ids",l="Table",s=l+"s",u=l+n,i="Row",a=i+n,c="Sorted"+i+n,I="Cell",p=I+n,v="Value",b=v+"s",g=v+n,w=(e,o)=>e.map(o),m=e=>null==e,R=(e,o,t)=>m(e)?null==t?void 0:t():o(e),C=e=>t(e)==d,y=()=>{},{createContext:k,useContext:h}=e,f=k([]),P=(e,o)=>{const t=h(f);return m(e)?t[o]:C(e)?((e,o)=>R(e,(e=>e[o])))(t[o+1],e):e},q=(e,o)=>{const t=P(e,o);return m(e)||C(e)?t:e},x=e=>P(e,0),S=e=>P(e,2),O=e=>P(e,4),T=e=>P(e,6),B=e=>P(e,8),L=e=>P(e,10),j=e=>q(e,0),M=e=>q(e,2),E=e=>q(e,4),V=e=>q(e,6),A=e=>q(e,8),D=e=>q(e,10),{useCallback:F,useEffect:z,useMemo:G,useRef:H,useState:J}=e,K=(e,o,t=[])=>{const r=G((()=>o(e)),[e,...t]);return z((()=>()=>r.destroy()),[r]),r},N=(e,o,t,r=[],d)=>{const[,n]=J(),l=F((()=>{var d,n;return null!=(n=null==(d=null==o?void 0:o["get"+e])?void 0:d.call(o,...r))?n:t}),[o,...r]),[s]=J(l),u=H(s);return G((()=>u.current=l()),[l]),Q(e,o,((...e)=>{u.current=m(d)?l():e[d],n([])}),[],r),u.current},Q=(e,o,t,r=[],d=[],...n)=>z((()=>{var r;const l=null==(r=null==o?void 0:o["add"+e+"Listener"])?void 0:r.call(o,...d,t,...n);return()=>null==o?void 0:o.delListener(l)}),[o,...d,...r,...n]),U=(e,o,t,r=[],d=y,n=[],...l)=>{const s=j(e);return F((e=>R(s,(r=>R(t(e,r),(e=>d(r["set"+o](...l,e),e)))))),[s,o,...r,...n,...l])},W=(e,o,t=y,r=[],...d)=>{const n=j(e);return F((()=>t(null==n?void 0:n["del"+o](...d))),[n,o,...r,...d])},X=(e,o,t)=>{const r=D(e);return F((()=>null==r?void 0:r[o](t)),[r,o,t])},Y=(e,o=[])=>G(e,o),Z=e=>N(s,j(e),{}),$=e=>N(u,j(e),[],[]),_=(e,o)=>N(l,j(o),{},[e]),ee=(e,o)=>N(l+p,j(o),[],[e]),oe=(e,o)=>N(a,j(o),[],[e]),te=(e,o,t,r=0,d,n)=>N(c,j(n),[],[e,o,t,r,d],6),re=(e,o,t)=>N(i,j(t),{},[e,o]),de=(e,o,t)=>N(p,j(t),[],[e,o]),ne=(e,o,t,r)=>N(I,j(r),void 0,[e,o,t],4),le=e=>N(b,j(e),{}),se=e=>N(g,j(e),[],[]),ue=(e,o)=>N(v,j(o),void 0,[e]),ie=(e,o,t,r,d)=>U(t,s,e,o,r,d),ae=(e,o,t,r,d,n)=>U(r,l,o,t,d,n,e),ce=(e,o,t,r,d,n,l)=>U(d,i,t,r,n,l,e,o),Ie=(e,o,t=[],r,d=y,n=[],l=!0)=>{const s=j(r);return F((t=>R(s,(r=>R(o(t,r),(o=>d(r.addRow(e,o,l),r,o)))))),[s,e,...t,...n,l])},pe=(e,o,t,r,d,n,l)=>U(d,"PartialRow",t,r,n,l,e,o),ve=(e,o,t,r,d,n,l,s)=>U(n,I,r,d,l,s,e,o,t),be=(e,o,t,r,d)=>U(t,b,e,o,r,d),ge=(e,o,t,r,d)=>U(t,"PartialValues",e,o,r,d),we=(e,o,t,r,d,n)=>U(r,v,o,t,d,n,e),me=(e,o,t)=>W(e,s,o,t),Re=(e,o,t,r)=>W(o,l,t,r,e),Ce=(e,o,t,r,d)=>W(t,i,r,d,e,o),ye=(e,o,t,r,d,n,l)=>W(d,I,n,l,e,o,t,r),ke=(e,o,t)=>W(e,b,o,t),he=(e,o,t,r)=>W(o,v,t,r,e),fe=(e,o,t,r)=>Q(s,j(r),e,o,[],t),Pe=(e,o,t,r)=>Q(u,j(r),e,o,[],t),qe=(e,o,t,r,d)=>Q(l,j(d),o,t,[e],r),xe=(e,o,t,r,d)=>Q(l+p,j(d),o,t,[e],r),Se=(e,o,t,r,d)=>Q(a,j(d),o,t,[e],r),Oe=(e,o,t,r,d,n,l,s,u)=>Q(c,j(u),n,l,[e,o,t,r,d],s),Te=(e,o,t,r,d,n)=>Q(i,j(n),t,r,[e,o],d),Be=(e,o,t,r,d,n)=>Q(p,j(n),t,r,[e,o],d),Le=(e,o,t,r,d,n,l)=>Q(I,j(l),r,d,[e,o,t],n),je=(e,o,t,r)=>Q(b,j(r),e,o,[],t),Me=(e,o,t,r)=>Q(g,j(r),e,o,[],t),Ee=(e,o,t,r,d)=>Q(v,j(d),o,t,[e],r),Ve=(e,o,t)=>K(e,o,t),Ae=(e,o)=>N("Metric",M(o),void 0,[e]),De=(e,o,t,r)=>Q("Metric",M(r),o,t,[e]),Fe=(e,o,t)=>K(e,o,t),ze=(e,o)=>N("SliceIds",E(o),[],[e]),Ge=(e,o,t)=>N("SliceRowIds",E(t),[],[e,o]),He=(e,o,t,r)=>Q("SliceIds",E(r),o,t,[e]),Je=(e,o,t,r,d)=>Q("SliceRowIds",E(d),t,r,[e,o]),Ke=(e,o,t)=>K(e,o,t),Ne=(e,o,t)=>N("RemoteRowId",V(t),void 0,[e,o]),Qe=(e,o,t)=>N("LocalRowIds",V(t),[],[e,o]),Ue=(e,o,t)=>N("LinkedRowIds",V(t),[],[e,o]),We=(e,o,t,r,d)=>Q("RemoteRowId",V(d),t,r,[e,o]),Xe=(e,o,t,r,d)=>Q("LocalRowIds",V(d),t,r,[e,o]),Ye=(e,o,t,r,d)=>Q("LinkedRowIds",V(d),t,r,[e,o]),Ze=(e,o,t)=>K(e,o,t),$e=(e,o)=>N("ResultTable",A(o),{},[e]),_e=(e,o)=>N("ResultRowIds",A(o),[],[e]),eo=(e,o,t,r=0,d,n)=>N("ResultSortedRowIds",A(n),[],[e,o,t,r,d],6),oo=(e,o,t)=>N("ResultRow",A(t),{},[e,o]),to=(e,o,t)=>N("ResultCellIds",A(t),[],[e,o]),ro=(e,o,t,r)=>N("ResultCell",A(r),void 0,[e,o,t]),no=(e,o,t,r)=>Q("ResultTable",A(r),o,t,[e]),lo=(e,o,t,r)=>Q("ResultRowIds",A(r),o,t,[e]),so=(e,o,t,r,d,n,l,s)=>Q("ResultSortedRowIds",A(s),n,l,[e,o,t,r,d]),uo=(e,o,t,r,d)=>Q("ResultRow",A(d),t,r,[e,o]),io=(e,o,t,r,d)=>Q("ResultCellIds",A(d),t,r,[e,o]),ao=(e,o,t,r,d,n)=>Q("ResultCell",A(n),r,d,[e,o,t]),co=(e,o,t)=>K(e,o,t),Io=e=>N("CheckpointIds",D(e),[[],void 0,[]]),po=(e,o)=>N("Checkpoint",D(o),void 0,[e]),vo=(e=y,o=[],t,r=y,d=[])=>{const n=D(t);return F((o=>R(n,(t=>{const d=e(o);r(t.addCheckpoint(d),t,d)}))),[n,...o,...d])},bo=e=>X(e,"goBackward"),go=e=>X(e,"goForward"),wo=(e,o=[],t,r=y,d=[])=>{const n=D(t);return F((o=>R(n,(t=>R(e(o),(e=>r(t.goTo(e),e)))))),[n,...o,...d])},mo=e=>{var o;const t=D(e),[d,n]=Io(t);return[(l=d,!(0==(e=>e.length)(l))),bo(t),n,null!=(o=R(n,(e=>null==t?void 0:t.getCheckpoint(e))))?o:r];var l},Ro=e=>{var o;const t=D(e),[,,[d]]=Io(t);return[!m(d),go(t),d,null!=(o=R(d,(e=>null==t?void 0:t.getCheckpoint(e))))?o:r]},Co=(e,o,t)=>Q("CheckpointIds",D(t),e,o),yo=(e,o,t,r)=>Q("Checkpoint",D(r),o,t,[e]),ko=(e,o,t=[],r,d=[])=>{const[,n]=J(),l=G((()=>o(e)),[e,...t]);return z((()=>{var e;return e=function*(){yield null==r?void 0:r(l),n(1)},new Promise(((o,t)=>{var r=o=>{try{n(e.next(o))}catch(e){t(e)}},d=o=>{try{n(e.throw(o))}catch(e){t(e)}},n=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,d);n((e=e.apply(void 0,null)).next())})),()=>{l.destroy()}}),[l,...d]),l};var ho=Object.defineProperty,fo=Object.defineProperties,Po=Object.getOwnPropertyDescriptors,qo=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,So=Object.prototype.propertyIsEnumerable,Oo=(e,o,t)=>o in e?ho(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,To=(e,o)=>{for(var t in o||(o={}))xo.call(o,t)&&Oo(e,t,o[t]);if(qo)for(var t of qo(o))So.call(o,t)&&Oo(e,t,o[t]);return e},Bo=(e,o)=>fo(e,Po(o)),Lo=(e,o)=>{var t={};for(var r in e)xo.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&qo)for(var r of qo(e))o.indexOf(r)<0&&So.call(e,r)&&(t[r]=e[r]);return t};const{createElement:jo,useMemo:Mo}=e,Eo=({tableId:e,store:o,rowComponent:t=Ko,getRowComponentProps:r,separator:d,debugIds:n},l)=>Ho(w(l,(d=>jo(t,Bo(To({},zo(r,d)),{key:d,tableId:e,rowId:d,store:o,debugIds:n})))),d,n,e),Vo=({queryId:e,queries:o,resultRowComponent:t=rt,getResultRowComponentProps:r,separator:d,debugIds:n},l)=>Ho(w(l,(d=>jo(t,Bo(To({},zo(r,d)),{key:d,queryId:e,rowId:d,queries:o,debugIds:n})))),d,n,e),Ao=e=>{const o=V(e);return[o,null==o?void 0:o.getStore()]},Do=({relationshipId:e,relationships:o,rowComponent:t=Ko,getRowComponentProps:r,separator:d,debugIds:n},l,s)=>{const[u,i]=Ao(o),a=null==u?void 0:u.getLocalTableId(e),c=l(e,s,u);return Ho(w(c,(e=>jo(t,Bo(To({},zo(r,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:n})))),d,n,s)},Fo=e=>({checkpoints:o,checkpointComponent:t=lt,getCheckpointComponentProps:r,separator:d,debugIds:n})=>{const l=D(o);return Ho(w(e(Io(l)),(e=>jo(t,Bo(To({},zo(r,e)),{key:e,checkpoints:l,checkpointId:e,debugIds:n})))),d)},zo=(e,o)=>m(e)?{}:e(o),Go=({store:e,storesById:t,metrics:r,metricsById:d,indexes:n,indexesById:l,relationships:s,relationshipsById:u,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:p})=>{const v=o(f);return jo(f.Provider,{value:Mo((()=>[null!=e?e:v[0],To(To({},v[1]),t),null!=r?r:v[2],To(To({},v[3]),d),null!=n?n:v[4],To(To({},v[5]),l),null!=s?s:v[6],To(To({},v[7]),u),null!=i?i:v[8],To(To({},v[9]),a),null!=c?c:v[10],To(To({},v[11]),I)]),[e,t,r,d,n,l,s,u,i,a,c,I,v])},p)},Ho=(e,o,t,r)=>{const d=m(o)||!Array.isArray(e)?e:w(e,((e,t)=>t>0?[o,e]:e));return t?[r,":{",d,"}"]:d},Jo=({tableId:e,rowId:o,cellId:t,store:d,debugIds:n})=>{var l;return Ho(r+(null!=(l=ne(e,o,t,d))?l:r),void 0,n,t)},Ko=({tableId:e,rowId:o,store:t,cellComponent:r=Jo,getCellComponentProps:d,separator:n,debugIds:l})=>Ho(w(de(e,o,t),(n=>jo(r,Bo(To({},zo(d,n)),{key:n,tableId:e,rowId:o,cellId:n,store:t,debugIds:l})))),n,l,o),No=e=>Eo(e,oe(e.tableId,e.store)),Qo=e=>{var o=e,{cellId:t,descending:r,offset:d,limit:n}=o,l=Lo(o,["cellId","descending","offset","limit"]);return Eo(l,te(l.tableId,t,r,d,n,l.store))},Uo=({store:e,tableComponent:o=No,getTableComponentProps:t,separator:r,debugIds:d})=>Ho(w($(e),(r=>jo(o,Bo(To({},zo(t,r)),{key:r,tableId:r,store:e,debugIds:d})))),r),Wo=({valueId:e,store:o,debugIds:t})=>{var d;return Ho(r+(null!=(d=ue(e,o))?d:r),void 0,t,e)},Xo=({store:e,valueComponent:o=Wo,getValueComponentProps:t,separator:r,debugIds:d})=>Ho(w(se(e),(r=>jo(o,Bo(To({},zo(t,r)),{key:r,valueId:r,store:e,debugIds:d})))),r),Yo=({metricId:e,metrics:o,debugIds:t})=>{var d;return Ho(null!=(d=Ae(e,o))?d:r,void 0,t,e)},Zo=({indexId:e,sliceId:o,indexes:t,rowComponent:r=Ko,getRowComponentProps:d,separator:n,debugIds:l})=>{const s=E(t),u=null==s?void 0:s.getStore(),i=null==s?void 0:s.getTableId(e),a=Ge(e,o,s);return Ho(w(a,(e=>jo(r,Bo(To({},zo(d,e)),{key:e,tableId:i,rowId:e,store:u,debugIds:l})))),n,l,o)},$o=({indexId:e,indexes:o,sliceComponent:t=Zo,getSliceComponentProps:r,separator:d,debugIds:n})=>Ho(w(ze(e,o),(d=>jo(t,Bo(To({},zo(r,d)),{key:d,indexId:e,sliceId:d,indexes:o,debugIds:n})))),d,n,e),_o=({relationshipId:e,localRowId:o,relationships:t,rowComponent:r=Ko,getRowComponentProps:d,debugIds:n})=>{const[l,s]=Ao(t),u=null==l?void 0:l.getRemoteTableId(e),i=Ne(e,o,l);return Ho(m(u)||m(i)?null:jo(r,Bo(To({},zo(d,i)),{key:i,tableId:u,rowId:i,store:s,debugIds:n})),void 0,n,o)},et=e=>Do(e,Qe,e.remoteRowId),ot=e=>Do(e,Ue,e.firstRowId),tt=({queryId:e,rowId:o,cellId:t,queries:d,debugIds:n})=>{var l;return Ho(r+(null!=(l=ro(e,o,t,d))?l:r),void 0,n,t)},rt=({queryId:e,rowId:o,queries:t,resultCellComponent:r=tt,getResultCellComponentProps:d,separator:n,debugIds:l})=>Ho(w(to(e,o,t),(n=>jo(r,Bo(To({},zo(d,n)),{key:n,queryId:e,rowId:o,cellId:n,queries:t,debugIds:l})))),n,l,o),dt=e=>Vo(e,_e(e.queryId,e.queries)),nt=e=>{var o=e,{cellId:t,descending:r,offset:d,limit:n}=o,l=Lo(o,["cellId","descending","offset","limit"]);return Vo(l,eo(l.queryId,t,r,d,n,l.queries))},lt=({checkpoints:e,checkpointId:o,debugIds:t})=>{var d;return Ho(null!=(d=po(o,e))?d:r,void 0,t,o)},st=Fo((e=>e[0])),ut=Fo((e=>m(e[1])?[]:[e[1]])),it=Fo((e=>e[2]));export{st as BackwardCheckpointsView,Jo as CellView,lt as CheckpointView,ut as CurrentCheckpointView,it as ForwardCheckpointsView,$o as IndexView,ot as LinkedRowsView,et as LocalRowsView,Yo as MetricView,Go as Provider,_o as RemoteRowView,tt as ResultCellView,rt as ResultRowView,nt as ResultSortedTableView,dt as ResultTableView,Ko as RowView,Zo as SliceView,Qo as SortedTableView,No as TableView,Uo as TablesView,Wo as ValueView,Xo as ValuesView,Eo as tableView,Ie as useAddRowCallback,ne as useCell,de as useCellIds,Be as useCellIdsListener,Le as useCellListener,po as useCheckpoint,Io as useCheckpointIds,Co as useCheckpointIdsListener,yo as useCheckpointListener,L as useCheckpoints,co as useCreateCheckpoints,Fe as useCreateIndexes,Ve as useCreateMetrics,ko as useCreatePersister,Ze as useCreateQueries,Ke as useCreateRelationships,Y as useCreateStore,ye as useDelCellCallback,Ce as useDelRowCallback,Re as useDelTableCallback,me as useDelTablesCallback,he as useDelValueCallback,ke as useDelValuesCallback,bo as useGoBackwardCallback,go as useGoForwardCallback,wo as useGoToCallback,O as useIndexes,Ue as useLinkedRowIds,Ye as useLinkedRowIdsListener,Qe as useLocalRowIds,Xe as useLocalRowIdsListener,Ae as useMetric,De as useMetricListener,S as useMetrics,B as useQueries,Ro as useRedoInformation,T as useRelationships,Ne as useRemoteRowId,We as useRemoteRowIdListener,ro as useResultCell,to as useResultCellIds,io as useResultCellIdsListener,ao as useResultCellListener,oo as useResultRow,_e as useResultRowIds,lo as useResultRowIdsListener,uo as useResultRowListener,eo as useResultSortedRowIds,so as useResultSortedRowIdsListener,$e as useResultTable,no as useResultTableListener,re as useRow,oe as useRowIds,Se as useRowIdsListener,Te as useRowListener,ve as useSetCellCallback,vo as useSetCheckpointCallback,pe as useSetPartialRowCallback,ge as useSetPartialValuesCallback,ce as useSetRowCallback,ae as useSetTableCallback,ie as useSetTablesCallback,we as useSetValueCallback,be as useSetValuesCallback,ze as useSliceIds,He as useSliceIdsListener,Ge as useSliceRowIds,Je as useSliceRowIdsListener,te as useSortedRowIds,Oe as useSortedRowIdsListener,x as useStore,_ as useTable,ee as useTableCellIds,xe as useTableCellIdsListener,$ as useTableIds,Pe as useTableIdsListener,qe as useTableListener,Z as useTables,fe as useTablesListener,mo as useUndoInformation,ue as useValue,se as useValueIds,Me as useValueIdsListener,Ee as useValueListener,le as useValues,je as useValuesListener};
1
+ import e,{useContext as o}from"react";const t=e=>typeof e,r="",d=t(r),n="Ids",l="Table",s=l+"s",u=l+n,i="Row",a=i+n,c="Sorted"+i+n,I="Cell",p=I+n,v="Value",b=v+"s",g=v+n,w=(e,o)=>e.map(o),m=e=>null==e,C=(e,o,t)=>m(e)?null==t?void 0:t():o(e),R=e=>t(e)==d,y=()=>{},{createContext:k,useContext:h}=e,f=k([]),P=(e,o)=>{const t=h(f);return m(e)?t[o]:R(e)?((e,o)=>C(e,(e=>e[o])))(t[o+1],e):e},q=(e,o)=>{const t=P(e,o);return m(e)||R(e)?t:e},x=(e,...o)=>m(e)?{}:e(...o),S=e=>P(e,0),O=e=>P(e,2),T=e=>P(e,4),B=e=>P(e,6),L=e=>P(e,8),j=e=>P(e,10),M=e=>q(e,0),E=e=>q(e,2),V=e=>q(e,4),A=e=>q(e,6),D=e=>q(e,8),F=e=>q(e,10),{useCallback:z,useEffect:G,useMemo:H,useRef:J,useState:K}=e,N=(e,o,t=[])=>{const r=H((()=>o(e)),[e,...t]);return G((()=>()=>r.destroy()),[r]),r},Q=(e,o,t,r=[],d)=>{const[,n]=K(),l=z((()=>{var d,n;return null!=(n=null==(d=null==o?void 0:o["get"+e])?void 0:d.call(o,...r))?n:t}),[o,...r]),[s]=K(l),u=J(s);return H((()=>u.current=l()),[l]),U(e,o,((...e)=>{u.current=m(d)?l():e[d],n([])}),[],r),u.current},U=(e,o,t,r=[],d=[],...n)=>G((()=>{var r;const l=null==(r=null==o?void 0:o["add"+e+"Listener"])?void 0:r.call(o,...d,t,...n);return()=>null==o?void 0:o.delListener(l)}),[o,...d,...r,...n]),W=(e,o,t,r=[],d=y,n=[],...l)=>{const s=M(e);return z((e=>C(s,(r=>C(t(e,r),(e=>d(r["set"+o](...l,e),e)))))),[s,o,...r,...n,...l])},X=(e,o,t=y,r=[],...d)=>{const n=M(e);return z((()=>t(null==n?void 0:n["del"+o](...d))),[n,o,...r,...d])},Y=(e,o,t)=>{const r=F(e);return z((()=>null==r?void 0:r[o](t)),[r,o,t])},Z=(e,o=[])=>H(e,o),$=e=>Q(s,M(e),{}),_=e=>Q(u,M(e),[],[]),ee=(e,o)=>Q(l,M(o),{},[e]),oe=(e,o)=>Q(l+p,M(o),[],[e]),te=(e,o)=>Q(a,M(o),[],[e]),re=(e,o,t,r=0,d,n)=>Q(c,M(n),[],[e,o,t,r,d],6),de=(e,o,t)=>Q(i,M(t),{},[e,o]),ne=(e,o,t)=>Q(p,M(t),[],[e,o]),le=(e,o,t,r)=>Q(I,M(r),void 0,[e,o,t],4),se=e=>Q(b,M(e),{}),ue=e=>Q(g,M(e),[],[]),ie=(e,o)=>Q(v,M(o),void 0,[e]),ae=(e,o,t,r,d)=>W(t,s,e,o,r,d),ce=(e,o,t,r,d,n)=>W(r,l,o,t,d,n,e),Ie=(e,o,t,r,d,n,l)=>W(d,i,t,r,n,l,e,o),pe=(e,o,t=[],r,d=y,n=[],l=!0)=>{const s=M(r);return z((t=>C(s,(r=>C(o(t,r),(o=>d(r.addRow(e,o,l),r,o)))))),[s,e,...t,...n,l])},ve=(e,o,t,r,d,n,l)=>W(d,"PartialRow",t,r,n,l,e,o),be=(e,o,t,r,d,n,l,s)=>W(n,I,r,d,l,s,e,o,t),ge=(e,o,t,r,d)=>W(t,b,e,o,r,d),we=(e,o,t,r,d)=>W(t,"PartialValues",e,o,r,d),me=(e,o,t,r,d,n)=>W(r,v,o,t,d,n,e),Ce=(e,o,t)=>X(e,s,o,t),Re=(e,o,t,r)=>X(o,l,t,r,e),ye=(e,o,t,r,d)=>X(t,i,r,d,e,o),ke=(e,o,t,r,d,n,l)=>X(d,I,n,l,e,o,t,r),he=(e,o,t)=>X(e,b,o,t),fe=(e,o,t,r)=>X(o,v,t,r,e),Pe=(e,o,t,r)=>U(s,M(r),e,o,[],t),qe=(e,o,t,r)=>U(u,M(r),e,o,[],t),xe=(e,o,t,r,d)=>U(l,M(d),o,t,[e],r),Se=(e,o,t,r,d)=>U(l+p,M(d),o,t,[e],r),Oe=(e,o,t,r,d)=>U(a,M(d),o,t,[e],r),Te=(e,o,t,r,d,n,l,s,u)=>U(c,M(u),n,l,[e,o,t,r,d],s),Be=(e,o,t,r,d,n)=>U(i,M(n),t,r,[e,o],d),Le=(e,o,t,r,d,n)=>U(p,M(n),t,r,[e,o],d),je=(e,o,t,r,d,n,l)=>U(I,M(l),r,d,[e,o,t],n),Me=(e,o,t,r)=>U(b,M(r),e,o,[],t),Ee=(e,o,t,r)=>U(g,M(r),e,o,[],t),Ve=(e,o,t,r,d)=>U(v,M(d),o,t,[e],r),Ae=(e,o,t)=>N(e,o,t),De=(e,o)=>Q("Metric",E(o),void 0,[e]),Fe=(e,o,t,r)=>U("Metric",E(r),o,t,[e]),ze=(e,o,t)=>N(e,o,t),Ge=(e,o)=>Q("SliceIds",V(o),[],[e]),He=(e,o,t)=>Q("SliceRowIds",V(t),[],[e,o]),Je=(e,o,t,r)=>U("SliceIds",V(r),o,t,[e]),Ke=(e,o,t,r,d)=>U("SliceRowIds",V(d),t,r,[e,o]),Ne=(e,o,t)=>N(e,o,t),Qe=(e,o,t)=>Q("RemoteRowId",A(t),void 0,[e,o]),Ue=(e,o,t)=>Q("LocalRowIds",A(t),[],[e,o]),We=(e,o,t)=>Q("LinkedRowIds",A(t),[],[e,o]),Xe=(e,o,t,r,d)=>U("RemoteRowId",A(d),t,r,[e,o]),Ye=(e,o,t,r,d)=>U("LocalRowIds",A(d),t,r,[e,o]),Ze=(e,o,t,r,d)=>U("LinkedRowIds",A(d),t,r,[e,o]),$e=(e,o,t)=>N(e,o,t),_e=(e,o)=>Q("ResultTable",D(o),{},[e]),eo=(e,o)=>Q("ResultRowIds",D(o),[],[e]),oo=(e,o,t,r=0,d,n)=>Q("ResultSortedRowIds",D(n),[],[e,o,t,r,d],6),to=(e,o,t)=>Q("ResultRow",D(t),{},[e,o]),ro=(e,o,t)=>Q("ResultCellIds",D(t),[],[e,o]),no=(e,o,t,r)=>Q("ResultCell",D(r),void 0,[e,o,t]),lo=(e,o,t,r)=>U("ResultTable",D(r),o,t,[e]),so=(e,o,t,r)=>U("ResultRowIds",D(r),o,t,[e]),uo=(e,o,t,r,d,n,l,s)=>U("ResultSortedRowIds",D(s),n,l,[e,o,t,r,d]),io=(e,o,t,r,d)=>U("ResultRow",D(d),t,r,[e,o]),ao=(e,o,t,r,d)=>U("ResultCellIds",D(d),t,r,[e,o]),co=(e,o,t,r,d,n)=>U("ResultCell",D(n),r,d,[e,o,t]),Io=(e,o,t)=>N(e,o,t),po=e=>Q("CheckpointIds",F(e),[[],void 0,[]]),vo=(e,o)=>Q("Checkpoint",F(o),void 0,[e]),bo=(e=y,o=[],t,r=y,d=[])=>{const n=F(t);return z((o=>C(n,(t=>{const d=e(o);r(t.addCheckpoint(d),t,d)}))),[n,...o,...d])},go=e=>Y(e,"goBackward"),wo=e=>Y(e,"goForward"),mo=(e,o=[],t,r=y,d=[])=>{const n=F(t);return z((o=>C(n,(t=>C(e(o),(e=>r(t.goTo(e),e)))))),[n,...o,...d])},Co=e=>{var o;const t=F(e),[d,n]=po(t);return[(l=d,!(0==(e=>e.length)(l))),go(t),n,null!=(o=C(n,(e=>null==t?void 0:t.getCheckpoint(e))))?o:r];var l},Ro=e=>{var o;const t=F(e),[,,[d]]=po(t);return[!m(d),wo(t),d,null!=(o=C(d,(e=>null==t?void 0:t.getCheckpoint(e))))?o:r]},yo=(e,o,t)=>U("CheckpointIds",F(t),e,o),ko=(e,o,t,r)=>U("Checkpoint",F(r),o,t,[e]),ho=(e,o,t=[],r,d=[])=>{const[,n]=K(),l=H((()=>o(e)),[e,...t]);return G((()=>{var e;return e=function*(){yield null==r?void 0:r(l),n(1)},new Promise(((o,t)=>{var r=o=>{try{n(e.next(o))}catch(e){t(e)}},d=o=>{try{n(e.throw(o))}catch(e){t(e)}},n=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,d);n((e=e.apply(void 0,null)).next())})),()=>{l.destroy()}}),[l,...d]),l};var fo=Object.defineProperty,Po=Object.defineProperties,qo=Object.getOwnPropertyDescriptors,xo=Object.getOwnPropertySymbols,So=Object.prototype.hasOwnProperty,Oo=Object.prototype.propertyIsEnumerable,To=(e,o,t)=>o in e?fo(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,Bo=(e,o)=>{for(var t in o||(o={}))So.call(o,t)&&To(e,t,o[t]);if(xo)for(var t of xo(o))Oo.call(o,t)&&To(e,t,o[t]);return e},Lo=(e,o)=>Po(e,qo(o)),jo=(e,o)=>{var t={};for(var r in e)So.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&xo)for(var r of xo(e))o.indexOf(r)<0&&Oo.call(e,r)&&(t[r]=e[r]);return t};const{createElement:Mo,useMemo:Eo}=e,Vo=({tableId:e,store:o,rowComponent:t=Ko,getRowComponentProps:r,customCellIds:d,separator:n,debugIds:l},s)=>Ho(w(s,(n=>Mo(t,Lo(Bo({},x(r,n)),{key:n,tableId:e,rowId:n,customCellIds:d,store:o,debugIds:l})))),n,l,e),Ao=({queryId:e,queries:o,resultRowComponent:t=rt,getResultRowComponentProps:r,separator:d,debugIds:n},l)=>Ho(w(l,(d=>Mo(t,Lo(Bo({},x(r,d)),{key:d,queryId:e,rowId:d,queries:o,debugIds:n})))),d,n,e),Do=e=>{const o=A(e);return[o,null==o?void 0:o.getStore()]},Fo=({relationshipId:e,relationships:o,rowComponent:t=Ko,getRowComponentProps:r,separator:d,debugIds:n},l,s)=>{const[u,i]=Do(o),a=null==u?void 0:u.getLocalTableId(e),c=l(e,s,u);return Ho(w(c,(e=>Mo(t,Lo(Bo({},x(r,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:n})))),d,n,s)},zo=e=>({checkpoints:o,checkpointComponent:t=lt,getCheckpointComponentProps:r,separator:d,debugIds:n})=>{const l=F(o);return Ho(w(e(po(l)),(e=>Mo(t,Lo(Bo({},x(r,e)),{key:e,checkpoints:l,checkpointId:e,debugIds:n})))),d)},Go=({store:e,storesById:t,metrics:r,metricsById:d,indexes:n,indexesById:l,relationships:s,relationshipsById:u,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:p})=>{const v=o(f);return Mo(f.Provider,{value:Eo((()=>[null!=e?e:v[0],Bo(Bo({},v[1]),t),null!=r?r:v[2],Bo(Bo({},v[3]),d),null!=n?n:v[4],Bo(Bo({},v[5]),l),null!=s?s:v[6],Bo(Bo({},v[7]),u),null!=i?i:v[8],Bo(Bo({},v[9]),a),null!=c?c:v[10],Bo(Bo({},v[11]),I)]),[e,t,r,d,n,l,s,u,i,a,c,I,v])},p)},Ho=(e,o,t,r)=>{const d=m(o)||!Array.isArray(e)?e:w(e,((e,t)=>t>0?[o,e]:e));return t?[r,":{",d,"}"]:d},Jo=({tableId:e,rowId:o,cellId:t,store:d,debugIds:n})=>{var l;return Ho(r+(null!=(l=le(e,o,t,d))?l:r),void 0,n,t)},Ko=({tableId:e,rowId:o,store:t,cellComponent:r=Jo,getCellComponentProps:d,customCellIds:n,separator:l,debugIds:s})=>Ho(w(((e,o,t,r)=>{const d=ne(o,t,r);return null!=e?e:d})(n,e,o,t),(n=>Mo(r,Lo(Bo({},x(d,n)),{key:n,tableId:e,rowId:o,cellId:n,store:t,debugIds:s})))),l,s,o),No=e=>Vo(e,te(e.tableId,e.store)),Qo=e=>{var o=e,{cellId:t,descending:r,offset:d,limit:n}=o,l=jo(o,["cellId","descending","offset","limit"]);return Vo(l,re(l.tableId,t,r,d,n,l.store))},Uo=({store:e,tableComponent:o=No,getTableComponentProps:t,separator:r,debugIds:d})=>Ho(w(_(e),(r=>Mo(o,Lo(Bo({},x(t,r)),{key:r,tableId:r,store:e,debugIds:d})))),r),Wo=({valueId:e,store:o,debugIds:t})=>{var d;return Ho(r+(null!=(d=ie(e,o))?d:r),void 0,t,e)},Xo=({store:e,valueComponent:o=Wo,getValueComponentProps:t,separator:r,debugIds:d})=>Ho(w(ue(e),(r=>Mo(o,Lo(Bo({},x(t,r)),{key:r,valueId:r,store:e,debugIds:d})))),r),Yo=({metricId:e,metrics:o,debugIds:t})=>{var d;return Ho(null!=(d=De(e,o))?d:r,void 0,t,e)},Zo=({indexId:e,sliceId:o,indexes:t,rowComponent:r=Ko,getRowComponentProps:d,separator:n,debugIds:l})=>{const s=V(t),u=null==s?void 0:s.getStore(),i=null==s?void 0:s.getTableId(e),a=He(e,o,s);return Ho(w(a,(e=>Mo(r,Lo(Bo({},x(d,e)),{key:e,tableId:i,rowId:e,store:u,debugIds:l})))),n,l,o)},$o=({indexId:e,indexes:o,sliceComponent:t=Zo,getSliceComponentProps:r,separator:d,debugIds:n})=>Ho(w(Ge(e,o),(d=>Mo(t,Lo(Bo({},x(r,d)),{key:d,indexId:e,sliceId:d,indexes:o,debugIds:n})))),d,n,e),_o=({relationshipId:e,localRowId:o,relationships:t,rowComponent:r=Ko,getRowComponentProps:d,debugIds:n})=>{const[l,s]=Do(t),u=null==l?void 0:l.getRemoteTableId(e),i=Qe(e,o,l);return Ho(m(u)||m(i)?null:Mo(r,Lo(Bo({},x(d,i)),{key:i,tableId:u,rowId:i,store:s,debugIds:n})),void 0,n,o)},et=e=>Fo(e,Ue,e.remoteRowId),ot=e=>Fo(e,We,e.firstRowId),tt=({queryId:e,rowId:o,cellId:t,queries:d,debugIds:n})=>{var l;return Ho(r+(null!=(l=no(e,o,t,d))?l:r),void 0,n,t)},rt=({queryId:e,rowId:o,queries:t,resultCellComponent:r=tt,getResultCellComponentProps:d,separator:n,debugIds:l})=>Ho(w(ro(e,o,t),(n=>Mo(r,Lo(Bo({},x(d,n)),{key:n,queryId:e,rowId:o,cellId:n,queries:t,debugIds:l})))),n,l,o),dt=e=>Ao(e,eo(e.queryId,e.queries)),nt=e=>{var o=e,{cellId:t,descending:r,offset:d,limit:n}=o,l=jo(o,["cellId","descending","offset","limit"]);return Ao(l,oo(l.queryId,t,r,d,n,l.queries))},lt=({checkpoints:e,checkpointId:o,debugIds:t})=>{var d;return Ho(null!=(d=vo(o,e))?d:r,void 0,t,o)},st=zo((e=>e[0])),ut=zo((e=>m(e[1])?[]:[e[1]])),it=zo((e=>e[2]));export{st as BackwardCheckpointsView,Jo as CellView,lt as CheckpointView,ut as CurrentCheckpointView,it as ForwardCheckpointsView,$o as IndexView,ot as LinkedRowsView,et as LocalRowsView,Yo as MetricView,Go as Provider,_o as RemoteRowView,tt as ResultCellView,rt as ResultRowView,nt as ResultSortedTableView,dt as ResultTableView,Ko as RowView,Zo as SliceView,Qo as SortedTableView,No as TableView,Uo as TablesView,Wo as ValueView,Xo as ValuesView,pe as useAddRowCallback,le as useCell,ne as useCellIds,Le as useCellIdsListener,je as useCellListener,vo as useCheckpoint,po as useCheckpointIds,yo as useCheckpointIdsListener,ko as useCheckpointListener,j as useCheckpoints,Io as useCreateCheckpoints,ze as useCreateIndexes,Ae as useCreateMetrics,ho as useCreatePersister,$e as useCreateQueries,Ne as useCreateRelationships,Z as useCreateStore,ke as useDelCellCallback,ye as useDelRowCallback,Re as useDelTableCallback,Ce as useDelTablesCallback,fe as useDelValueCallback,he as useDelValuesCallback,go as useGoBackwardCallback,wo as useGoForwardCallback,mo as useGoToCallback,T as useIndexes,We as useLinkedRowIds,Ze as useLinkedRowIdsListener,Ue as useLocalRowIds,Ye as useLocalRowIdsListener,De as useMetric,Fe as useMetricListener,O as useMetrics,L as useQueries,Ro as useRedoInformation,B as useRelationships,Qe as useRemoteRowId,Xe as useRemoteRowIdListener,no as useResultCell,ro as useResultCellIds,ao as useResultCellIdsListener,co as useResultCellListener,to as useResultRow,eo as useResultRowIds,so as useResultRowIdsListener,io as useResultRowListener,oo as useResultSortedRowIds,uo as useResultSortedRowIdsListener,_e as useResultTable,lo as useResultTableListener,de as useRow,te as useRowIds,Oe as useRowIdsListener,Be as useRowListener,be as useSetCellCallback,bo as useSetCheckpointCallback,ve as useSetPartialRowCallback,we as useSetPartialValuesCallback,Ie as useSetRowCallback,ce as useSetTableCallback,ae as useSetTablesCallback,me as useSetValueCallback,ge as useSetValuesCallback,Ge as useSliceIds,Je as useSliceIdsListener,He as useSliceRowIds,Ke as useSliceRowIdsListener,re as useSortedRowIds,Te as useSortedRowIdsListener,S as useStore,ee as useTable,oe as useTableCellIds,Se as useTableCellIdsListener,_ as useTableIds,qe as useTableIdsListener,xe as useTableListener,$ as useTables,Pe as useTablesListener,Co as useUndoInformation,ie as useValue,ue as useValueIds,Ee as useValueIdsListener,Ve as useValueListener,se as useValues,Me as useValuesListener};
Binary file