tinybase 4.1.0-beta.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 +41 -24
package/lib/cjs/tools.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const e=e=>typeof e,t="tinybase",l="",a=",",n=e(l),o=e(!0),d=e(0),r="type",s="default",I="Listener",$="get",c="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",T=w+i,v=(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),S=e=>e.length,A=(e,t)=>e.filter(t),P=(e,...t)=>e.push(...t),E=e=>e.pop(),D=(e,...t)=>e.unshift(...t),O=e=>e.shift(),N=JSON.parse,L=isFinite,G=(e,t)=>e instanceof t,j=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&&L(t)?l:void 0},B=Object,F=B.keys,U=B.freeze,_=e=>G(e,B)&&e.constructor==B,Z=(e,t)=>k(B.entries(e),(([e,l])=>t(l,e))),H=e=>S(F(e)),Q=e=>_(e)&&0==H(e),q=(e,t)=>e?.has(t)??!1,K=e=>[...e?.values()??[]],X=(e,t)=>e?.forEach(t),Y=(e,t)=>e?.delete(t),ee=e=>new Map(e),te=(e,t)=>e?.get(t),le=(e,t)=>X(e,((e,l)=>t(l,e))),ae=(e,t)=>k([...e?.entries()??[]],(([e,l])=>t(l,e))),ne=(e,t,l)=>j(l)?(Y(e,t),e):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",$e=", and registers a listener so that any changes to that result will cause a re-render",ce="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="?: ",Te=" | undefined",ve="NonNullable",Ve="Partial",xe="Props",Re="Provider",ke=`Registers a ${we} that will be called`,Se="Represents",Ae="rowId: "+ge,Pe="Schema",Ee="Set",De=", descending?: boolean, offset?: number, limit?: number",Oe="[]",Ne="the Store",Le="Transaction",Ge=Le+"Changes",je=re(Le),Me="Execute a "+je+" to make multiple mutations",Je="Explicitly starts a "+je,ze="Explicitly finishes a "+je,We="the end of the "+je,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+Ne:l),Ye=(e=0,t,a=0)=>ut[t]+He+Xe(e,1)+(a?" when setting it":l),et=(e,t=0)=>Se+` 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),$t=(e,t=0)=>ut[t]+` ${Xe()} `+st(e),ct=(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",Se,"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=[$,"has","set","del","set","forEach",c,l],bt=[Ne,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)||j(e)?e:[e]),gt=(e,t)=>e?.add(t),mt=/[^A-Za-z]+/,ft=/[^A-Za-z0-9]+/,wt=/^( *)\/\*\* *(.*?) *\*\/$/gm,yt=(e,t,l)=>e.substring(t,l),Tt=e=>e.includes(a),vt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return q(e,n)?vt(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)))),St=e=>de(R((e&&!mt.test(e[0])?e:" "+e).split(ft),"_")),At=e=>`/** ${e}. */`,Pt=(...e)=>R(A(e,(e=>e)),", "),Et=(...e)=>"{"+R(e,"; ")+"}",Dt=(...e)=>Et(...k(e,(e=>"readonly "+e))),Ot=()=>{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=>(t??n)==n?gt(oe(e[n],l,ht),a):0)))),(e,a,n,o=l,d=1)=>vt(t,e,[a,n,o,d]),(e,t,l)=>vt(a,e,z(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>te(a,e)===t?e:vt(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)=>Tt(e)!=Tt(t)?Tt(e)?-1:1:e>t?1:-1)),l],(e=>e.replace("{React}","React"))),()=>ae(t,(([e,t,a,n],o)=>[At(t),`${n?he+" ":l}type ${o}${a} = ${e};`,l])),()=>ae(a,((e,t)=>(e=z(e)?e:[e],P(e,E(e)+";"),[`const ${t} = ${O(e)}`,e,l])))]},Nt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Lt=(e,t,l)=>[t=>Z(e,((e,a)=>t(a,kt(a,1),l(St(a),`'${a}'`)))),(t,a)=>Z(e[t],((e,t)=>a(t,e[r],e[s],l(St(t),`'${t}'`),kt(t,1)))),e=>Z(t,((t,a)=>e(a,t[r],t[s],l(St(a),`'${a}'`),kt(a,1))))],Gt=(e,t,a,n)=>[(n,o)=>{const d=n+": "+o,r=e(p,Et(...t((e=>`'${e}'?: {[rowId: Id]: `+Et(...a(e,((e,t,a)=>`'${e}'${j(a)?"?":l}: ${t}`)))+"}"))),Ye(1,5)),s=e(p+Ue,Et(...t((e=>`'${e}'?: {[rowId: Id]: `+Et(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Ye(1,5,1)),$=e(u+ge,"keyof "+r,"A "+u+" Id in "+Ne),c=`<TId extends ${$}>`,i=e(u,ve+`<${r}[TId]>`,"A "+u+" in "+Ne,c),w=e(u+Ue,ve+`<${s}[TId]>`,"A "+u+" in "+Ne+_e,c),y=e(C,i+"<TId>[Id]","A "+C+" in a "+u,c),T=e(C+Ue,w+"<TId>[Id]","A "+C+" in a "+u+_e,c),v=e(m+ge,`Extract<keyof ${y}<TId>, Id>`,"A "+m+" Id in a "+C,c),V=e(m,ve+`<${r}[TId]>[Id][CId]`,"A "+m+" in a "+C,`<TId extends ${$}, CId extends ${v}<TId>>`),x=e("CellIdCellArray",`CId extends ${v}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,m+" Ids and types in a "+C,`<TId extends ${$}, CId = ${v}<TId>>`,0),R=e(m+ce,`(...[cellId, cell]: ${x}<TId>)`+Fe,nt(se+m+" Id, and "+m),c),k=e(C+ce,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Fe+") "+Fe,nt(se+C+" Id, and a "+m+" iterator"),c),S=e(u+m+ce,`(cellId: ${v}<TId>, count: number) `+Fe,nt(se+m+" Id, and count of how many times it appears"),c),A=e("TableIdForEachRowArray",`TId extends ${$} ? [tableId: TId, forEachRow: (rowCallback: ${k}<TId>)${Fe}] : never`,u+" Ids and callback types",`<TId = ${$}>`,0),P=e(u+ce,`(...[tableId, forEachRow]: ${A})`+Fe,nt(se+u+" Id, and a "+C+" iterator"),l),E=e("TableIdRowIdCellIdArray",`TId extends ${$} ? [tableId: TId, rowId: Id, cellId: ${v}<TId>] : never`,"Ids for GetCellChange",`<TId = ${$}>`,0),D=e("GetCellChange",`(...[tableId, rowId, cellId]: ${E}) => CellChange`,Ie+" returning information about any Cell's changes during a "+je),O=e(p+I,`(${d}, getCellChange: ${D}${Te})`+Fe,ot(1)),N=e(b+I,`(${d})`+Fe,ot(2)),L=e(u+I,`(${d}, tableId: ${$}, getCellChange: ${D}${Te})`+Fe,ot(3)),G=e(u+f+I,`(${d}, tableId: ${$})`+Fe,ot(14,3)),M=e(h+I,`(${d}, tableId: ${$})`+Fe,ot(4,3)),J=e(g+I,"("+Pt(d,"tableId: "+$,"cellId: Id"+Te,"descending: boolean","offset: number","limit: number"+Te,"sortedRowIds: Ids")+")"+Fe,ot(13,3)),z=e(C+I,"("+Pt(""+d,"tableId: "+$,Ae,`getCellChange: ${D}${Te}`)+")"+Fe,ot(5,3)),W=e(f+I,"("+Pt(""+d,"tableId: "+$,Ae)+")"+Fe,ot(6,5)),B=e("CellListenerArgsArrayInner",`CId extends ${v}<TId> ? [${d}, tableId: TId, ${Ae}, cellId: CId, newCell: ${V}<TId, CId> ${Te}, oldCell: ${V}<TId, CId> ${Te}, getCellChange: ${D} ${Te}] : never`,"Cell args for CellListener",`<TId extends ${$}, CId = ${v}<TId>>`,0),F=e("CellListenerArgsArrayOuter",`TId extends ${$} ? `+B+"<TId> : never","Table args for CellListener",`<TId = ${$}>`,0);return[r,s,$,i,w,y,T,v,V,R,k,S,P,O,N,L,G,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, ${Ae}, cellId: Id, invalidCells: any[])`+Fe,ot(8))]},(t,a)=>{const o=t+": "+a,d=e(y,Et(...n(((e,t,a)=>`'${e}'${j(a)?"?":l}: ${t}`))),Ye(2,5)),r=e(y+Ue,Et(...n(((e,t)=>`'${e}'?: ${t}`))),Ye(2,5,1)),s=e(w+ge,"keyof "+d,"A "+w+" Id in "+Ne),$=e(w,ve+`<${d}[VId]>`,"A "+w+" Id in "+Ne,`<VId extends ${s}>`),c=e("ValueIdValueArray",`VId extends ${s} ? [valueId: VId, value: ${$}<VId>] : never`,w+" Ids and types in "+Ne,`<VId = ${s}>`,0),i=e(w+ce,`(...[valueId, value]: ${c})`+Fe,nt(se+w+" Id, and "+w)),u=e("GetValueChange",`(valueId: ${s}) => ValueChange`,Ie+" returning information about any Value's changes during a "+je),p=e(y+I,`(${o}, getValueChange: ${u}${Te})`+Fe,ot(9)),b=e(T+I,`(${o})`+Fe,ot(10)),C=e("ValueListenerArgsArray",`VId extends ${s} ? [${o}, valueId: VId, newValue: ${$}<VId> ${Te}, oldValue: ${$}<VId> ${Te}, getValueChange: ${u} ${Te}] : never`,"Value args for ValueListener",`<VId = ${s}>`,0);return[d,r,s,$,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(Le+I,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Fe,Ie+" listening to the completion of a "+je)],jt=(e,t=l,a=l)=>`store.${e}(${t})`+(a?" as "+a:l),Mt=(e,t=l)=>`fluent(() => ${jt(e,t)})`,Jt=(e,t=l,a=l)=>`store.${e}(${t?t+", ":l}proxy(listener)${a?", "+a:l})`,zt=(e,a,n)=>{const[d,$,v,V,k,S,A,E]=Ot(),[O,N,L]=Lt(e,a,k),[G,M,z]=Gt(v,O,N,L),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||D(s,At(o)),P(s,l),s})),F=(e,t,a,n,o,d=l)=>vt(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:jt)(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(c+e+I,(n?n+", ":l)+we+": "+t+(d?", mutator?: boolean":l),ge,Jt(c+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($(1,Z,H,`create${H} as create${H}Decl`),Q(e))$(null,t,p);else{$(0,t,"CellChange"),$(null,t,i);const[e,a,n,d,I,c,w,y,T,V,S,A,E,D,L,M,z,W,B,F,Q,le,ae]=G(q,H),de=ee();O(((e,t)=>{const l=`<'${e}'>`,a=[v(t+u,d+l,Se+` the '${e}' `+u),v(t+u+Ue,I+l,Se+` the '${e}' `+u+_e),v(t+C,c+l,et(e)),v(t+C+Ue,w+l,et(e,1)),v(t+m+ge,y+l,`A Cell Id for the '${e}' `+u),v(t+m+ce,V+l,nt(`a Cell Id and value from a Row in the '${e}' `+u)),v(t+C+ce,S+l,nt(`a Row Id from the '${e}' Table, and a Cell iterator`)),v(t+u+m+ce,A+l,nt(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];ne(de,e,a),$(1,Z,...a)})),$(1,Z,e,a,n,y,E,D,L,M,z,W,B,F,Q,le,ae),oe=[e,a,n,y,D,L,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+Oe,tt(u,Ne)),U(5,l,u,Be,lt(u,Ne),"tableCallback: "+E,"tableCallback as any"),O(((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+De,a+", cellId, descending, offset, limit"),U(5,t,C,Be,lt(C,rt(e)),"rowCallback: "+c,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,$t(e,r),Ae+o,a+", rowId"+d))),U(6,t,C,ge+Te,"Add a new Row to "+rt(e),"row: "+s+", reuseIds?: boolean",a+", row, reuseIds"),U(0,t,f,I+Oe,tt(m,st(e)),Ae,a+", rowId"),U(5,t,m,Be,lt(m,st(e)),Ae+", cellCallback: "+$,a+", rowId, cellCallback as any"),N(e,((n,d,r,s,I)=>{const $="Map"+kt(d,1);ne(Y,d,$);const c=d+(j(r)?Te:l);x([[c],[o],[H,`, cell: ${d} | `+$,", cell as any"],[H]],(([o,d=l,r=l],$)=>U($,t+I,m,o,ct(e,n,$),Ae+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,D,Ye(1,8)+" changes"),_(b,L,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),Pt("tableId: TId",`cellId: ${y}<TId>`+Te,"descending: boolean","offset: number","limit: number"+Te),Pt("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(O((e=>te(de,e)?.[4]??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"),$(1,Z,...K(Y)),P(X,".set"+p+Pe+"({",Rt(O(((e,t,a)=>[`[${a}]: {`,...N(e,((e,t,a,n)=>`[${n}]: {[${k(St(r),`'${r}'`)}]: ${k(St(t),`'${t}'`)}${j(a)?l:`, [${k(St(s),`'${s}'`)}]: `+(J(a)?k(St(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(Q(a))$(null,t,y);else{const[e,a,n,d,I,c,i,u,p]=M(q,H);$(1,Z,e,a,n,I,c,i,u,p),de=[e,a,n,c,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,T,n+Oe,tt(w,Ne)),U(5,l,w,"void",lt(w,Ne),"valueCallback: "+I,"valueCallback as any"),L(((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,c,Ye(2,8)+" changes"),_(T,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"),$(1,Z,...K(Y)),$(0,t,"ValueChange"),P(X,".set"+y+Pe+"({",L(((e,t,a,n)=>[`[${n}]: {[${k(St(r),`'${r}'`)}]: ${k(St(t),`'${t}'`)}${j(a)?l:`, [${k(St(s),`'${s}'`)}]: `+(J(a)?k(St(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,Ge,H,`Applies a set of ${Ge} to the Store`,"transactionChanges: "+Ge,"transactionChanges"),le(Y,((e,t)=>v(t,`(cell: ${e}${Te}) => `+e,`Takes a ${e} Cell value and returns another`))),$(null,t,"DoRollback",ge,"IdOrNull",fe,"Store",Ge),$(0,t,"Get"+Ge,"GetTransactionLog"),U(0,l,fe,fe,Ye(0,6)),U(2,l,fe,H,Ye(0,7),"tablesAndValuesJson: "+fe,"tablesAndValuesJson"),U(7,l,je,"Return",Me,Ce,"actions, doRollback","<Return>"),U(7,l,"start"+Le,H,Je),U(7,l,"finish"+Le,H,ze,be,"doRollback");const re=z(q,H);return _("Start"+Le,re,ke+" just before the start of the "+je,l,l,0),_("WillFinish"+Le,re,ke+" just before "+We,l,l,0),_("DidFinish"+Le,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 "+Ne,"listenerId: Id","listenerId"),F("getStore",l,"Store","store",ut[0]+" the underlying Store object"),$(1,t,"createStore"),$(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(...S(0),...A(),he+" interface "+H+" {",...B(0),"}",l,At(`Creates a ${H} object`),he+" function create"+H+"(): "+H+";"),d(...S(1),he+" const create"+H+": typeof create"+H+"Decl = () => {",...E(),`return Object.freeze(${q});`,"};"),oe,de]},Wt=e=>$+e,Bt=e=>Pt(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"+ce+"<"+Zt+">",el="rowId",tl="rowId={rowId}",ll=", separator, debugIds",al="separator?: ReactElement | string",nl="then?: (store: Store",ol=Pt(nl+")"+Fe,_t),dl="then, then"+ue,rl=el+Kt+ge,sl="View",Il=(e,...t)=>Pt(...t,we+": "+e,we+pe,"mutator?: boolean"),$l=(...e)=>Pt(...e,we,we+ue,"mutator"),cl=(e,a,n,o,d)=>{const[r,s,$,c,v,V,x,k]=Ot(),[S,A,E]=Lt(e,a,v),O=`./${kt(n)}.d`,N=`./${kt(n)}-ui-react.d`,L="tinybase/ui-react",G=kt(n,1),M=kt(G),J=G+"Or"+G+ge,z=M+"Or"+G+ge,W=M+`={${M}}`,B=ee(),F=(e,t,a,n,o,d=l)=>(s(1,N,e+" as "+e+"Decl"),vt(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,$=l)=>(s(1,L,`use${t} as use${t}Core`),U(e,Pt(o,X,I),a,le+`(${z}, use${t}Core, [`+(d||l)+($?"], ["+$: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||D(s,At(o)),P(s,l),s}));s(null,t,ge,"Store",ce,Zt+"ized"+ce),s(0,L,"ComponentReturnType"),s(null,L,"ExtraProps"),s(0,O,G);const q=$(J,G+" | "+ge,`Used when you need to refer to a ${G} in a React hook or component`),K=$(Re+xe,Dt(M+ye+G,M+`ById?: {[${M}Id: Id]: ${G}}`),`Used with the ${Re} component, so that a `+G+" can be passed into the context of an application");s(0,"react","ReactElement","ComponentType"),s(1,"react","React"),s(1,N,q,K);const X=z+ye+q;v("{createContext, useContext, useMemo}","React"),v("Context",`createContext<[${G}?, {[${M}Id: Id]: ${G}}?]>([])`),U("Create"+G,`create: () => ${G}, create`+pe,G,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${G} within a React application with convenient memoization`);const Y=U(G,"id?: Id",G+Te,["{",Qt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${G} from within a ${Re} component context`),le=c("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=c("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),oe=c("wrap",Pt("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=v("NullComponent","() => null");if(!Q(e)){const[e,a,n,d,r,w,y,T,v,V,x,k,P,E]=o;s(null,O,e,a,n,r,w,y,T,v,V,x,k,P),s(0,O,d),s(1,O,G),s(null,t,i,"IdOrNull");const D=c("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,",");"]),L=c("getDefaultTableComponent","tableId: Id",R(S(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+de),J=c("getDefaultCellComponent","tableId: Id, cellId: Id",R(S(((e,t,l)=>`tableId == ${l} ? ${R(A(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+de} : `)))+de);_(p,p,e,Ye(1,0)+$e);const z=_(b,b,n+Oe,tt(u,Ne)+$e);_(Ee+p+ce,Ee+p+ce,Yt,Ye(1,9)+qt,Pt(Wt(p)+Ht+a,Wt(p)+pe),Bt(p),Xt,Pt(nl,`tables: ${a})`+Fe,_t),dl),_(ie+p+ce,ie+p+ce,ce,Ye(1,12),l,l,l,ol,dl);const B=$(m+xe,Dt("tableId?: TId","rowId: Id","cellId?: CId",M+ye+G,Ft),at(se+m),`<TId extends ${n}, CId extends ${d}<TId>>`),F=$(C+xe,Dt("tableId?: TId","rowId: Id",M+ye+G,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${B}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,al,Ft),at(se+C),`<TId extends ${n}>`),U=$(u+xe,Dt("tableId?: TId",M+ye+G,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",al,Ft),at(se+u),`<TId extends ${n}>`),H=$("Sorted"+u+xe,Dt("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",M+ye+G,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",al,Ft),at(se+"sorted "+u),`<TId extends ${n}>`),Q=$(p+xe,Dt(M+ye+G,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${U}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,al,Ft),at(Xe(1,1)));s(1,N,Q,U,H,F,B),Z(p+sl,"{"+M+", tableComponents, getTableComponentProps"+ll+"}: "+Q,[oe+`(${z}(${M}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+L+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ne}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",W,Ut,"/>;","}), separator)"],Ye(1,13)+$e),S(((e,t,a)=>{const[n,o,d,r,I]=te(E,e);s(null,O,n,o,d,r,I),_(t+u,u,n,It(e)+$e,l,a),_(t+u+f,u+f,i,tt(m,"the whole of "+rt(e))+$e,l,a);const $=_(t+h,h,i,tt(C,rt(e))+$e,l,a),c=_(t+g,g,i,tt(C,rt(e),1)+$e,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");_(t+C,C,d,$t(e)+$e,rl,Pt(a,el));const p=_(t+f,f,I+Oe,tt(m,st(e))+$e,rl,Pt(a,el));_(Ee+t+u+ce,Ee+u+ce,Yt,It(e,9)+qt,Pt(Wt(u)+Ht+o,Wt(u)+pe),Pt(a,Bt(u)),Xt,Pt(nl,`table: ${o})`+Fe,_t),dl),_(ie+t+u+ce,ie+u+ce,ce,It(e,12),l,a,l,ol,dl),_(Ee+t+C+ce,Ee+C+ce,Yt,$t(e,9)+qt,Pt(rl,Wt(C)+Ht+r,Wt(C)+pe),Pt(a,el,Bt(C)),Xt,Pt(nl,`row: ${r})`+Fe,_t),dl),_("Add"+t+C+ce,"Add"+C+ce,Yt,$t(e,10)+qt,Pt(Wt(C)+Ht+r,Wt(C)+pe),Pt(a,Bt(C)),Xt,"then?: ("+Pt(rl+Te,"store: Store","row: "+r+")"+Fe,"then"+pe)+", reuseRowIds?: boolean",dl+", reuseRowIds"),_(Ee+t+Ve+C+ce,Ee+Ve+C+ce,Yt,$t(e,11)+qt,Pt(rl,Wt(Ve+C)+Ht+r,Wt(Ve+C)+pe),Pt(a,el,Bt(Ve+C)),Xt,Pt(nl,`partialRow: ${r})`+Fe,_t),dl),_(ie+t+C+ce,ie+C+ce,ce,$t(e,12),rl,Pt(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)"],$t(e,13)+$e);Z(t+"Sorted"+u+sl,"{cellId, descending, offset, limit, ...props}: "+H+`<'${e}'>`,D+"(props, "+c+`(cellId, descending, offset, limit, props.${M}), ${a}, ${b});`,It(e,13)+", sorted"+$e),Z(t+u+sl,`props: ${U}<'${e}'>`,D+"(props, "+$+`(props.${M}), ${a}, ${b});`,It(e,13)+$e),A(e,((n,o,d,r,I)=>{const $="Map"+kt(o,1);s(0,O,$),s(1,O,$);const c=_(t+I+m,m,o+(j(d)?Te:l),ct(e,n)+$e,rl,Pt(a,el,r));_(Ee+t+I+m+ce,Ee+m+ce,Yt,ct(e,n,9)+qt,Pt(rl,Wt(m)+Ht+o+" | "+$,Wt(m)+pe),Pt(a,el,r,Bt(m)),Xt,Pt(nl,`cell: ${o} | ${$})`+Fe,_t),dl),_(ie+t+I+m+ce,ie+m+ce,ce,ct(e,n,12),Pt(rl,"forceDel?: boolean"),Pt(a,el,r,"forceDel"),l,ol,dl),Z(t+I+m+sl,`{rowId, ${M}, debugIds}: `+B+`<'${e}', '${n}'>`,[oe+`('' + ${c}(rowId, `+M+`) ?? '', undefined, debugIds, ${r})`],ct(e,n,13)+$e)}))}));const q=R(S((e=>te(E,e)?.[4]??l))," | ");_(p+I,p+I,Be,Ye(1,8)+" changes",Il(r),$l()),_(b+I,b+I,Be,dt(2,0,1),Il(w),$l()),_(u+I,u+I,Be,dt(3,0),Il(y,`tableId: ${n} | null`),$l("tableId")),_(u+f+I,u+f+I,Be,dt(14,3,1),Il(T,`tableId: ${n} | null`),$l("tableId")),_(h+I,h+I,Be,dt(4,3,1),Il(v,`tableId: ${n} | null`),$l("tableId")),_(g+I,g+I,Be,dt(13,3,1),Il(V,`tableId: ${n} | null`,"cellId: "+q+Te,"descending: boolean","offset: number","limit: number"+Te),$l("tableId","cellId","descending","offset","limit")),_(C+I,C+I,Be,dt(5,3),Il(x,`tableId: ${n} | null`,el+": IdOrNull"),$l("tableId",el)),_(f+I,f+I,Be,dt(6,5,1),Il(k,`tableId: ${n} | null`,el+": IdOrNull"),$l("tableId",el)),_(m+I,m+I,Be,dt(7,5),Il(P,`tableId: ${n} | null`,el+": IdOrNull",`cellId: ${q} | null`),$l("tableId",el,"cellId"))}if(!Q(a)){const[e,t,a,n,o,r]=d;s(null,O,...d),s(1,O,G);const i=c("getDefaultValueComponent","valueId: Id",R(E(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+de);_(y,y,e,Ye(2,0)+$e);const u=_(T,T,a+Oe,tt(w,Ne)+$e);_(Ee+y+ce,Ee+y+ce,Yt,Ye(2,9)+qt,Pt(Wt(y)+Ht+t,Wt(y)+pe),Bt(y),Xt,Pt(nl,`values: ${t})`+Fe,_t),dl),_(Ee+Ve+y+ce,Ee+Ve+y+ce,Yt,Ye(2,11)+qt,Pt(Wt(Ve+y)+Ht+t,Wt(Ve+y)+pe),Bt(Ve+y),Xt,Pt(nl,`partialValues: ${t})`+Fe,_t),dl),_(ie+y+ce,ie+y+ce,ce,Ye(2,12),l,l,l,ol,dl);const p=$(w+xe,Dt("valueId?: VId",M+ye+G,Ft),at("a Value"),`<VId extends ${a}>`),b=$(y+xe,Dt(M+ye+G,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,al,Ft),at(Xe(2,1)));s(1,N,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)+$e),E(((e,t,a,n,o)=>{const d="Map"+kt(t,1);s(0,O,d),s(1,O,d);const r=_(o+w,w,t,it(e)+$e,l,n);_(Ee+o+w+ce,Ee+w+ce,Yt,it(e,9)+qt,Pt(Wt(w)+Ht+t+" | "+d,Wt(w)+pe),Pt(n,Bt(w)),Xt,Pt(nl,`value: ${t} | ${d})`+Fe,_t),dl),_(ie+o+w+ce,ie+w+ce,ce,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)+$e)})),_(y+I,y+I,Be,Ye(2,8)+" changes",Il(n),$l()),_(T+I,T+I,Be,dt(10,0,1),Il(o),$l()),_(w+I,w+I,Be,dt(11,0),Il(r,`valueId: ${a} | null`),$l("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,...cl(e,t,a,d,r)]},ul={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},pl=Nt((e=>{const t=()=>{const t=N(e.getTablesSchemaJson());return!Q(t)||v(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=ee();if(v(a,(t=>v(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,$=oe(s,o,(()=>0))+1;return $>I&&(d[2]=[$,o]),ne(s,o,$),d[3]++,r==W(o)})))))return t[l]={},X(n,(([e,,[,n],o],d)=>{t[l][d]={[r]:e,...o==S(a)?{[s]:n}:{}}})),1}))?t:{}},l=()=>{const t=N(e.getValuesSchemaJson());return Q(t)&&e.forEachValue(((e,l)=>{t[e]={[r]:W(l)}})),t},a=e=>il(t(),l(),e),n=async e=>{const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(await import("prettier")).format}catch(e){l=e=>e}return k(a(e),((e,a)=>Vt(l(e,{...ul,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})})),{totalTables:l,totalRows:a,totalCells:n,totalValues:S(e.getValueIds()),jsonLength:xt(e.getJson()),...t?{detail:{tables:o}}:{}}},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));exports.createTools=pl;
1
+ "use strict";const e=e=>typeof e,t="tinybase",l="",a=",",n=e(l),o=e(!0),d=e(0),s="type",r="default",I="Listener",c="get",$="add",u="Ids",i="Table",p=i+"s",b=i+u,C="Row",h=C+u,m="Sorted"+C+u,g="Cell",f=g+u,w="Value",y=w+"s",T=w+u,v=(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),S=e=>e.length,A=(e,t)=>e.filter(t),P=(e,...t)=>e.push(...t),E=e=>e.pop(),D=(e,...t)=>e.unshift(...t),O=e=>e.shift(),N=JSON.parse,L=isFinite,G=(e,t)=>e instanceof t,j=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&&L(t)?l:void 0},B=Object,F=B.keys,U=B.freeze,_=e=>G(e,B)&&e.constructor==B,Z=(e,t)=>k(B.entries(e),(([e,l])=>t(l,e))),H=e=>S(F(e)),Q=e=>_(e)&&0==H(e),q=(e,t)=>e?.has(t)??!1,K=e=>[...e?.values()??[]],X=(e,t)=>e?.forEach(t),Y=(e,t)=>e?.delete(t),ee=e=>new Map(e),te=(e,t)=>e?.get(t),le=(e,t)=>X(e,((e,l)=>t(l,e))),ae=(e,t)=>k([...e?.entries()??[]],(([e,l])=>t(l,e))),ne=(e,t,l)=>j(l)?(Y(e,t),e):e?.set(t,l),oe=(e,t,l)=>(q(e,t)||ne(e,t,l()),te(e,t)),de=e=>e.toUpperCase(),se=e=>e.toLowerCase(),re="a ",Ie="A function for",ce=", and registers a listener so that any changes to that result will cause a re-render",$e="Callback",ue="Del",ie="Deps",pe=ie+"?: React.DependencyList",be="doRollback?: DoRollback",Ce="actions: () => Return, "+be,he="export",me="Id",ge="Invalid",fe="Json",we=se(I),ye="?: ",Te=" | undefined",ve="NonNullable",Ve="Partial",xe="Props",Re="Provider",ke=`Registers a ${we} that will be called`,Se="Represents",Ae="rowId: "+me,Pe="Schema",Ee="Set",De=", descending?: boolean, offset?: number, limit?: number",Oe="[]",Ne="the Store",Le="Transaction",Ge=Le+"Changes",je=se(Le),Me="Execute a "+je+" to make multiple mutations",Je="Explicitly starts a "+je,ze="Explicitly finishes a "+je,We="the end of the "+je,Be="void",Fe=" => "+Be,Ue="WhenSet",_e=" when setting it",Ze=re+"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+Ne:l),Ye=(e=0,t,a=0)=>it[t]+He+Xe(e,1)+(a?" when setting it":l),et=(e,t=0)=>Se+` 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"),st=e=>`the '${e}' `+i,rt=e=>"the specified Row in "+st(e),It=(e,t=0)=>it[t]+` ${Xe()} `+st(e),ct=(e,t=0)=>it[t]+` ${Xe()} `+rt(e),$t=(e,t,l=0)=>it[l]+` the '${t}' Cell for `+rt(e),ut=(e,t=0)=>it[t]+` the '${e}' Value`,it=["Gets","Checks existence of","Sets","Deletes","Sets part of",Se,"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=[Ne,p,qe+i+He+u,re+i,qe+C+He+u,re+C,qe+g+He+u,re+g,"invalid Cell changes",y,qe+w+He+u,re+w,"invalid Value changes",qe+"sorted "+C+He+u,qe+g+He+u+" anywhere"],Ct=[l,"tabular ","keyed value "],ht=e=>new Set(z(e)||j(e)?e:[e]),mt=(e,t)=>e?.add(t),gt=/[^A-Za-z]+/,ft=/[^A-Za-z0-9]+/,wt=/^( *)\/\*\* *(.*?) *\*\/$/gm,yt=(e,t,l)=>e.substring(t,l),Tt=e=>e.includes(a),vt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return q(e,n)?vt(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:se)(yt(e,0,1))+yt(e,1)))),St=e=>de(R((e&&!gt.test(e[0])?e:" "+e).split(ft),"_")),At=e=>`/** ${e}. */`,Pt=(...e)=>R(A(e,(e=>e)),", "),Et=(...e)=>"{"+R(e,"; ")+"}",Dt=(...e)=>Et(...k(e,(e=>"readonly "+e))),Ot=()=>{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=>(t??n)==n?mt(oe(e[n],l,ht),a):0)))),(e,a,n,o=l,d=1)=>vt(t,e,[a,n,o,d]),(e,t,l)=>vt(a,e,z(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>te(a,e)===t?e:vt(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)=>Tt(e)!=Tt(t)?Tt(e)?-1:1:e>t?1:-1)),l],(e=>e.replace("{React}","React"))),()=>ae(t,(([e,t,a,n],o)=>[At(t),`${n?he+" ":l}type ${o}${a} = ${e};`,l])),()=>ae(a,((e,t)=>(e=z(e)?e:[e],P(e,E(e)+";"),[`const ${t} = ${O(e)}`,e,l])))]},Nt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Lt=(e,t,l)=>[t=>Z(e,((e,a)=>t(a,kt(a,1),l(St(a),`'${a}'`)))),(t,a)=>Z(e[t],((e,t)=>a(t,e[s],e[r],l(St(t),`'${t}'`),kt(t,1)))),e=>Z(t,((t,a)=>e(a,t[s],t[r],l(St(a),`'${a}'`),kt(a,1))))],Gt=(e,t,a,n)=>[(n,o)=>{const d=n+": "+o,s=e(p,Et(...t((e=>`'${e}'?: {[rowId: Id]: `+Et(...a(e,((e,t,a)=>`'${e}'${j(a)?"?":l}: ${t}`)))+"}"))),Ye(1,5)),r=e(p+Ue,Et(...t((e=>`'${e}'?: {[rowId: Id]: `+Et(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Ye(1,5,1)),c=e(i+me,"keyof "+s,"A "+i+" Id in "+Ne),$=`<TId extends ${c}>`,u=e(i,ve+`<${s}[TId]>`,"A "+i+" in "+Ne,$),w=e(i+Ue,ve+`<${r}[TId]>`,"A "+i+" in "+Ne+_e,$),y=e(C,u+"<TId>[Id]","A "+C+" in a "+i,$),T=e(C+Ue,w+"<TId>[Id]","A "+C+" in a "+i+_e,$),v=e(g+me,`Extract<keyof ${y}<TId>, Id>`,"A "+g+" Id in a "+C,$),V=e(g,ve+`<${s}[TId]>[Id][CId]`,"A "+g+" in a "+C,`<TId extends ${c}, CId extends ${v}<TId>>`),x=e("CellIdCellArray",`CId extends ${v}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,g+" Ids and types in a "+C,`<TId extends ${c}, CId = ${v}<TId>>`,0),R=e(g+$e,`(...[cellId, cell]: ${x}<TId>)`+Fe,nt(re+g+" Id, and "+g),$),k=e(C+$e,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Fe+") "+Fe,nt(re+C+" Id, and a "+g+" iterator"),$),S=e(i+g+$e,`(cellId: ${v}<TId>, count: number) `+Fe,nt(re+g+" Id, and count of how many times it appears"),$),A=e("TableIdForEachRowArray",`TId extends ${c} ? [tableId: TId, forEachRow: (rowCallback: ${k}<TId>)${Fe}] : never`,i+" Ids and callback types",`<TId = ${c}>`,0),P=e(i+$e,`(...[tableId, forEachRow]: ${A})`+Fe,nt(re+i+" Id, and a "+C+" iterator"),l),E=e("TableIdRowIdCellIdArray",`TId extends ${c} ? [tableId: TId, rowId: Id, cellId: ${v}<TId>] : never`,"Ids for GetCellChange",`<TId = ${c}>`,0),D=e("GetCellChange",`(...[tableId, rowId, cellId]: ${E}) => CellChange`,Ie+" returning information about any Cell's changes during a "+je),O=e(p+I,`(${d}, getCellChange: ${D}${Te})`+Fe,ot(1)),N=e(b+I,`(${d})`+Fe,ot(2)),L=e(i+I,`(${d}, tableId: ${c}, getCellChange: ${D}${Te})`+Fe,ot(3)),G=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,"("+Pt(d,"tableId: "+c,"cellId: Id"+Te,"descending: boolean","offset: number","limit: number"+Te,"sortedRowIds: Ids")+")"+Fe,ot(13,3)),z=e(C+I,"("+Pt(""+d,"tableId: "+c,Ae,`getCellChange: ${D}${Te}`)+")"+Fe,ot(5,3)),W=e(f+I,"("+Pt(""+d,"tableId: "+c,Ae)+")"+Fe,ot(6,5)),B=e("CellListenerArgsArrayInner",`CId extends ${v}<TId> ? [${d}, tableId: TId, ${Ae}, cellId: CId, newCell: ${V}<TId, CId> ${Te}, oldCell: ${V}<TId, CId> ${Te}, getCellChange: ${D} ${Te}] : never`,"Cell args for CellListener",`<TId extends ${c}, CId = ${v}<TId>>`,0),F=e("CellListenerArgsArrayOuter",`TId extends ${c} ? `+B+"<TId> : never","Table args for CellListener",`<TId = ${c}>`,0);return[s,r,c,u,w,y,T,v,V,R,k,S,P,O,N,L,G,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, ${Ae}, cellId: Id, invalidCells: any[])`+Fe,ot(8))]},(t,a)=>{const o=t+": "+a,d=e(y,Et(...n(((e,t,a)=>`'${e}'${j(a)?"?":l}: ${t}`))),Ye(2,5)),s=e(y+Ue,Et(...n(((e,t)=>`'${e}'?: ${t}`))),Ye(2,5,1)),r=e(w+me,"keyof "+d,"A "+w+" Id in "+Ne),c=e(w,ve+`<${d}[VId]>`,"A "+w+" Id in "+Ne,`<VId extends ${r}>`),$=e("ValueIdValueArray",`VId extends ${r} ? [valueId: VId, value: ${c}<VId>] : never`,w+" Ids and types in "+Ne,`<VId = ${r}>`,0),u=e(w+$e,`(...[valueId, value]: ${$})`+Fe,nt(re+w+" Id, and "+w)),i=e("GetValueChange",`(valueId: ${r}) => ValueChange`,Ie+" returning information about any Value's changes during a "+je),p=e(y+I,`(${o}, getValueChange: ${i}${Te})`+Fe,ot(9)),b=e(T+I,`(${o})`+Fe,ot(10)),C=e("ValueListenerArgsArray",`VId extends ${r} ? [${o}, valueId: VId, newValue: ${c}<VId> ${Te}, oldValue: ${c}<VId> ${Te}, getValueChange: ${i} ${Te}] : never`,"Value args for ValueListener",`<VId = ${r}>`,0);return[d,s,r,c,u,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(Le+I,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Fe,Ie+" listening to the completion of a "+je)],jt=(e,t=l,a=l)=>`store.${e}(${t})`+(a?" as "+a:l),Mt=(e,t=l)=>`fluent(() => ${jt(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,v,V,k,S,A,E]=Ot(),[O,N,L]=Lt(e,a,k),[G,M,z]=Gt(v,O,N,L),W=ee(),B=(e=0)=>ae(W,(([t,a,n,o,d],s)=>{const r=e?[s+`: ${d}(${t}): ${a} => ${n},`]:[s+d+`(${t}): ${a};`];return e||D(r,At(o)),P(r,l),r})),F=(e,t,a,n,o,d=l)=>vt(W,e,[t,a,n,o,d]),U=(e,t,a,n,o,d=l,s=l,r=l)=>F(pt[e]+t+(4==e?Ve:l)+a,d,n,(n==H?Mt:jt)(pt[e]+(4==e?Ve:l)+a,s,e?void 0:n),o,r),_=(e,t,a,n=l,o=l,d=1,s=l)=>F($+e+I,(n?n+", ":l)+we+": "+t+(d?", mutator?: boolean":l),me,Jt($+e+I,o,d?"mutator":l),a,s),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,u);const[e,a,n,d,I,$,w,y,T,V,S,A,E,D,L,M,z,W,B,F,Q,le,ae]=G(q,H),de=ee();O(((e,t)=>{const l=`<'${e}'>`,a=[v(t+i,d+l,Se+` the '${e}' `+i),v(t+i+Ue,I+l,Se+` the '${e}' `+i+_e),v(t+C,$+l,et(e)),v(t+C+Ue,w+l,et(e,1)),v(t+g+me,y+l,`A Cell Id for the '${e}' `+i),v(t+g+$e,V+l,nt(`a Cell Id and value from a Row in the '${e}' `+i)),v(t+C+$e,S+l,nt(`a Row Id from the '${e}' Table, and a Cell iterator`)),v(t+i+g+$e,A+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,E,D,L,M,z,W,B,F,Q,le,ae),oe=[e,a,n,y,D,L,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+Oe,tt(i,Ne)),U(5,l,i,Be,lt(i,Ne),"tableCallback: "+E,"tableCallback as any"),O(((e,t,a)=>{const[n,d,s,r,I,c,$,p]=te(de,e);x([[n],[o],[H,"table: "+d,", table"],[H]],(([n,o,d=l],s)=>U(s,t,i,n,It(e,s),o,a+d))),U(0,t,i+f,u,tt(g,"the whole of "+st(e)),l,a),U(5,t,i+g,Be,lt(i+g,"the whole of "+st(e)),"tableCellCallback: "+p,a+", tableCellCallback as any"),U(0,t,h,u,tt(C,st(e)),l,a),U(0,t,m,u,tt(C,st(e),1),"cellId?: "+I+De,a+", cellId, descending, offset, limit"),U(5,t,C,Be,lt(C,st(e)),"rowCallback: "+$,a+", rowCallback as any"),x([[s],[o],[H,", row: "+r,", row"],[H],[H,", partialRow: "+r,", partialRow"]],(([n,o=l,d=l],s)=>U(s,t,C,n,ct(e,s),Ae+o,a+", rowId"+d))),U(6,t,C,me+Te,"Add a new Row to "+st(e),"row: "+r+", reuseIds?: boolean",a+", row, reuseIds"),U(0,t,f,I+Oe,tt(g,rt(e)),Ae,a+", rowId"),U(5,t,g,Be,lt(g,rt(e)),Ae+", cellCallback: "+c,a+", rowId, cellCallback as any"),N(e,((n,d,s,r,I)=>{const c="Map"+kt(d,1);ne(Y,d,c);const $=d+(j(s)?Te:l);x([[$],[o],[H,`, cell: ${d} | `+c,", cell as any"],[H]],(([o,d=l,s=l],c)=>U(c,t+I,g,o,$t(e,n,c),Ae+d,a+", rowId, "+r+s))),U(1,t+I,i+g,o,it[1]+` the '${n}' Cell anywhere in `+st(e),l,a+", "+r)}))})),U(0,l,p+fe,fe,Ye(1,6)),U(2,l,p+fe,H,Ye(1,7),"tablesJson: "+fe,"tables"+fe),_(p,D,Ye(1,8)+" changes"),_(b,L,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),Pt("tableId: TId",`cellId: ${y}<TId>`+Te,"descending: boolean","offset: number","limit: number"+Te),Pt("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(O((e=>te(de,e)?.[4]??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)),P(X,".set"+p+Pe+"({",Rt(O(((e,t,a)=>[`[${a}]: {`,...N(e,((e,t,a,n)=>`[${n}]: {[${k(St(s),`'${s}'`)}]: ${k(St(t),`'${t}'`)}${j(a)?l:`, [${k(St(r),`'${r}'`)}]: `+(J(a)?k(St(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,T,n+Oe,tt(w,Ne)),U(5,l,w,"void",lt(w,Ne),"valueCallback: "+I,"valueCallback as any"),L(((e,t,a,n,d)=>{const s="Map"+kt(t,1);ne(Y,t,s),x([[t],[o],[H,`value: ${t} | `+s,", value as any"],[H]],(([t,a,o=l],s)=>U(s,d,w,t,ut(e,s),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"),_(T,u,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"),P(X,".set"+y+Pe+"({",L(((e,t,a,n)=>[`[${n}]: {[${k(St(s),`'${s}'`)}]: ${k(St(t),`'${t}'`)}${j(a)?l:`, [${k(St(r),`'${r}'`)}]: `+(J(a)?k(St(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,Ge,H,`Applies a set of ${Ge} to the Store`,"transactionChanges: "+Ge,"transactionChanges"),le(Y,((e,t)=>v(t,`(cell: ${e}${Te}) => `+e,`Takes a ${e} Cell value and returns another`))),c(null,t,"DoRollback",me,"IdOrNull",fe,"Store",Ge),c(0,t,"Get"+Ge,"GetTransactionLog"),U(0,l,fe,fe,Ye(0,6)),U(2,l,fe,H,Ye(0,7),"tablesAndValuesJson: "+fe,"tablesAndValuesJson"),U(7,l,je,"Return",Me,Ce,"actions, doRollback","<Return>"),U(7,l,"start"+Le,H,Je),U(7,l,"finish"+Le,H,ze,be,"doRollback");const se=z(q,H);return _("Start"+Le,se,ke+" just before the start of the "+je,l,l,0),_("WillFinish"+Le,se,ke+" just before "+We,l,l,0),_("DidFinish"+Le,se,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 "+Ne,"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`,se),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(...S(0),...A(),he+" interface "+H+" {",...B(0),"}",l,At(`Creates a ${H} object`),he+" function create"+H+"(): "+H+";"),d(...S(1),he+" const create"+H+": typeof create"+H+"Decl = () => {",...E(),`return Object.freeze(${q});`,"};"),oe,de]},Wt=e=>c+e,Bt=e=>Pt(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"+$e+"<"+Zt+">",el="rowId",tl="rowId={rowId}",ll=", separator, debugIds",al="separator?: ReactElement | string",nl="then?: (store: Store",ol=Pt(nl+")"+Fe,_t),dl="then, then"+ie,sl=el+Kt+me,rl="View",Il=(e,...t)=>Pt(...t,we+": "+e,we+pe,"mutator?: boolean"),cl=(...e)=>Pt(...e,we,we+ie,"mutator"),$l=(e,a,n,o,d)=>{const[s,r,c,$,v,V,x,k]=Ot(),[S,A,E]=Lt(e,a,v),O=`./${kt(n)}.d`,N=`./${kt(n)}-ui-react.d`,L="tinybase/ui-react",G=kt(n,1),M=kt(G),J=G+"Or"+G+me,z=M+"Or"+G+me,W=M+`={${M}}`,B=ee(),F=(e,t,a,n,o,d=l)=>(r(1,N,e+" as "+e+"Decl"),vt(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,s=l,I=l,c=l)=>(r(1,L,`use${t} as use${t}Core`),U(e,Pt(o,X,I),a,le+`(${z}, use${t}Core, [`+(d||l)+(c?"], ["+c:l)+"]);",n,s)),Z=(e,t,l,a)=>F(e,t,1,l,a),H=(e=0)=>ae(B,(([t,a,n,o,d],s)=>{const r=e?[he+` const ${s}: typeof ${s}Decl = ${d}(${t}): ${1==a?"any":a} =>`,n]:[he+` function ${s}${d}(${t}): ${1==a?"ComponentReturnType":a};`];return e||D(r,At(o)),P(r,l),r}));r(null,t,me,"Store",$e,Zt+"ized"+$e),r(0,L,"ComponentReturnType"),r(1,L,"useCellIds"),r(null,L,"ExtraProps"),r(0,O,G);const q=c(J,G+" | "+me,`Used when you need to refer to a ${G} in a React hook or component`),K=c(Re+xe,Dt(M+ye+G,M+`ById?: {[${M}Id: Id]: ${G}}`),`Used with the ${Re} component, so that a `+G+" can be passed into the context of an application");r(0,"react","ReactElement","ComponentType"),r(1,"react","React"),r(1,N,q,K);const X=z+ye+q;v("{createContext, useContext, useMemo}","React"),v("Context",`createContext<[${G}?, {[${M}Id: Id]: ${G}}?]>([])`),U("Create"+G,`create: () => ${G}, create`+pe,G,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${G} within a React application with convenient memoization`);const Y=U(G,"id?: Id",G+Te,["{",Qt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${G} 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",Pt("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=$("useCustomOrDefaultCellIds",Pt("customCellIds: Ids | undefined","tableId: Id","rowId: Id",`${z}?: ${q} | undefined`),[`const defaultCellIds = ${le}(${z}, useCellIds, [tableId, rowId]);`,"return customCellIds ?? defaultCellIds;"]),se=v("NullComponent","() => null");if(!Q(e)){const[e,a,n,d,s,w,y,T,v,V,x,k,P,E]=o;r(null,O,e,a,n,s,w,y,T,v,V,x,k,P),r(0,O,d),r(1,O,G),r(null,t,u,"IdOrNull");const D=$("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,",");"]),L=$("getDefaultTableComponent","tableId: Id",R(S(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+se),J=$("getDefaultCellComponent","tableId: Id, cellId: Id",R(S(((e,t,l)=>`tableId == ${l} ? ${R(A(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+se} : `)))+se);_(p,p,e,Ye(1,0)+ce);const z=_(b,b,n+Oe,tt(i,Ne)+ce);_(Ee+p+$e,Ee+p+$e,Yt,Ye(1,9)+qt,Pt(Wt(p)+Ht+a,Wt(p)+pe),Bt(p),Xt,Pt(nl,`tables: ${a})`+Fe,_t),dl),_(ue+p+$e,ue+p+$e,$e,Ye(1,12),l,l,l,ol,dl);const B=c(g+xe,Dt("tableId?: TId","rowId: Id","cellId?: CId",M+ye+G,Ft),at(re+g),`<TId extends ${n}, CId extends ${d}<TId>>`),F=c(C+xe,Dt("tableId?: TId","rowId: Id",M+ye+G,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${B}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,`customCellIds?: ${d}<TId>[]`,al,Ft),at(re+C),`<TId extends ${n}>`),U=c(i+xe,Dt("tableId?: TId",M+ye+G,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",al,Ft),at(re+i),`<TId extends ${n}>`),H=c("Sorted"+i+xe,Dt("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",M+ye+G,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",al,Ft),at(re+"sorted "+i),`<TId extends ${n}>`),Q=c(p+xe,Dt(M+ye+G,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${U}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,al,Ft),at(Xe(1,1)));r(1,N,Q,U,H,F,B),Z(p+rl,"{"+M+", tableComponents, getTableComponentProps"+ll+"}: "+Q,[oe+`(${z}(${M}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+L+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ne}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",W,Ut,"/>;","}), separator)"],Ye(1,13)+ce),S(((e,t,a)=>{const[n,o,d,s,I]=te(E,e);r(null,O,n,o,d,s,I),_(t+i,i,n,It(e)+ce,l,a),_(t+i+f,i+f,u,tt(g,"the whole of "+st(e))+ce,l,a);const c=_(t+h,h,u,tt(C,st(e))+ce,l,a),$=_(t+m,m,u,tt(C,st(e),1)+ce,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");_(t+C,C,d,ct(e)+ce,sl,Pt(a,el)),_(t+f,f,I+Oe,tt(g,rt(e))+ce,sl,Pt(a,el)),_(Ee+t+i+$e,Ee+i+$e,Yt,It(e,9)+qt,Pt(Wt(i)+Ht+o,Wt(i)+pe),Pt(a,Bt(i)),Xt,Pt(nl,`table: ${o})`+Fe,_t),dl),_(ue+t+i+$e,ue+i+$e,$e,It(e,12),l,a,l,ol,dl),_(Ee+t+C+$e,Ee+C+$e,Yt,ct(e,9)+qt,Pt(sl,Wt(C)+Ht+s,Wt(C)+pe),Pt(a,el,Bt(C)),Xt,Pt(nl,`row: ${s})`+Fe,_t),dl),_("Add"+t+C+$e,"Add"+C+$e,Yt,ct(e,10)+qt,Pt(Wt(C)+Ht+s,Wt(C)+pe),Pt(a,Bt(C)),Xt,"then?: ("+Pt(sl+Te,"store: Store","row: "+s+")"+Fe,"then"+pe)+", reuseRowIds?: boolean",dl+", reuseRowIds"),_(Ee+t+Ve+C+$e,Ee+Ve+C+$e,Yt,ct(e,11)+qt,Pt(sl,Wt(Ve+C)+Ht+s,Wt(Ve+C)+pe),Pt(a,el,Bt(Ve+C)),Xt,Pt(nl,`partialRow: ${s})`+Fe,_t),dl),_(ue+t+C+$e,ue+C+$e,$e,ct(e,12),sl,Pt(a,el),l,ol,dl);const p=Z(t+C+rl,"{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+rl,"{cellId, descending, offset, limit, ...props}: "+H+`<'${e}'>`,D+"(props, "+$+`(cellId, descending, offset, limit, props.${M}), ${a}, ${p});`,It(e,13)+", sorted"+ce),Z(t+i+rl,`props: ${U}<'${e}'>`,D+"(props, "+c+`(props.${M}), ${a}, ${p});`,It(e,13)+ce),A(e,((n,o,d,s,I)=>{const c="Map"+kt(o,1);r(0,O,c),r(1,O,c);const $=_(t+I+g,g,o+(j(d)?Te:l),$t(e,n)+ce,sl,Pt(a,el,s));_(Ee+t+I+g+$e,Ee+g+$e,Yt,$t(e,n,9)+qt,Pt(sl,Wt(g)+Ht+o+" | "+c,Wt(g)+pe),Pt(a,el,s,Bt(g)),Xt,Pt(nl,`cell: ${o} | ${c})`+Fe,_t),dl),_(ue+t+I+g+$e,ue+g+$e,$e,$t(e,n,12),Pt(sl,"forceDel?: boolean"),Pt(a,el,s,"forceDel"),l,ol,dl),Z(t+I+g+rl,`{rowId, ${M}, debugIds}: `+B+`<'${e}', '${n}'>`,[oe+`('' + ${$}(rowId, `+M+`) ?? '', undefined, debugIds, ${s})`],$t(e,n,13)+ce)}))}));const q=R(S((e=>te(E,e)?.[4]??l))," | ");_(p+I,p+I,Be,Ye(1,8)+" changes",Il(s),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(T,`tableId: ${n} | null`),cl("tableId")),_(h+I,h+I,Be,dt(4,3,1),Il(v,`tableId: ${n} | null`),cl("tableId")),_(m+I,m+I,Be,dt(13,3,1),Il(V,`tableId: ${n} | null`,"cellId: "+q+Te,"descending: boolean","offset: number","limit: number"+Te),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(P,`tableId: ${n} | null`,el+": IdOrNull",`cellId: ${q} | null`),cl("tableId",el,"cellId"))}if(!Q(a)){const[e,t,a,n,o,s]=d;r(null,O,...d),r(1,O,G);const u=$("getDefaultValueComponent","valueId: Id",R(E(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+se);_(y,y,e,Ye(2,0)+ce);const i=_(T,T,a+Oe,tt(w,Ne)+ce);_(Ee+y+$e,Ee+y+$e,Yt,Ye(2,9)+qt,Pt(Wt(y)+Ht+t,Wt(y)+pe),Bt(y),Xt,Pt(nl,`values: ${t})`+Fe,_t),dl),_(Ee+Ve+y+$e,Ee+Ve+y+$e,Yt,Ye(2,11)+qt,Pt(Wt(Ve+y)+Ht+t,Wt(Ve+y)+pe),Bt(Ve+y),Xt,Pt(nl,`partialValues: ${t})`+Fe,_t),dl),_(ue+y+$e,ue+y+$e,$e,Ye(2,12),l,l,l,ol,dl);const p=c(w+xe,Dt("valueId?: VId",M+ye+G,Ft),at("a Value"),`<VId extends ${a}>`),b=c(y+xe,Dt(M+ye+G,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,al,Ft),at(Xe(2,1)));r(1,N,b,p),Z(y+rl,"{"+M+", valueComponents, getValueComponentProps"+ll+"}: "+b,[oe+`(${i}(${M}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+u+"(valueId);","return <Value",`{...${ne}(getValueComponentProps, valueId)}`,"key={valueId}",W,Ut,"/>;","}), separator)"],Ye(2,13)+ce),E(((e,t,a,n,o)=>{const d="Map"+kt(t,1);r(0,O,d),r(1,O,d);const s=_(o+w,w,t,ut(e)+ce,l,n);_(Ee+o+w+$e,Ee+w+$e,Yt,ut(e,9)+qt,Pt(Wt(w)+Ht+t+" | "+d,Wt(w)+pe),Pt(n,Bt(w)),Xt,Pt(nl,`value: ${t} | ${d})`+Fe,_t),dl),_(ue+o+w+$e,ue+w+$e,$e,ut(e,12),l,n,l,ol,dl),Z(o+w+rl,`{${M}, debugIds}: ${p}<'${e}'>`,[oe+`('' + ${s}(`+M+`) ?? '', undefined, debugIds, ${n})`],ut(e,13)+ce)})),_(y+I,y+I,Be,Ye(2,8)+" changes",Il(n),cl()),_(T+I,T+I,Be,dt(10,0,1),Il(o),cl()),_(w+I,w+I,Be,dt(11,0),Il(s,`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"),[s(...V(0),...x(),...H(0)),s(...V(1),...k(),...H(1))]},ul=(e,t,a)=>{if(Q(e)&&Q(t))return[l,l,l,l];const[n,o,d,s]=zt(e,t,a);return[n,o,...$l(e,t,a,d,s)]},il={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},pl=Nt((e=>{const t=()=>{const t=N(e.getTablesSchemaJson());return!Q(t)||v(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=ee();if(v(a,(t=>v(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=oe(n,a,(()=>[W(o),ee(),[0],0])),[s,r,[I]]=d,c=oe(r,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),ne(r,o,c),d[3]++,s==W(o)})))))return t[l]={},X(n,(([e,,[,n],o],d)=>{t[l][d]={[s]:e,...o==S(a)?{[r]:n}:{}}})),1}))?t:{}},l=()=>{const t=N(e.getValuesSchemaJson());return Q(t)&&e.forEachValue(((e,l)=>{t[e]={[s]:W(l)}})),t},a=e=>ul(t(),l(),e),n=async e=>{const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(await import("prettier")).format}catch(e){l=e=>e}return k(a(e),((e,a)=>Vt(l(e,{...il,filepath:"_."+t[a]}))))};return U({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,d)=>{l++;let s=0,r=0;const I={};d(((e,l)=>{s++;let a=0;l((()=>a++)),r+=a,t&&(I[e]={rowCells:a})})),a+=s,n+=r,t&&(o[e]={tableRows:s,tableCells:r,rows:I})})),{totalTables:l,totalRows:a,totalCells:n,totalValues:S(e.getValueIds()),jsonLength:xt(e.getJson()),...t?{detail:{tables:o}}:{}}},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));exports.createTools=pl;
Binary file
@@ -0,0 +1 @@
1
+ "use strict";var e=require("./ui-react"),l=require("react");const t=(e,l)=>e.map(l),o=e=>null==e,{createContext:n,useContext:s}=l;n([]);const r=(e,...l)=>o(e)?{}:e(...l),{createElement:a,useCallback:d,useState:u}=l,c=(e,l,t)=>{const o=d(e,l);return t?o:void 0},i=(e,l)=>o(e)||e[0]!=l?void 0:`sorted ${e[1]?"de":"a"}scending`,I=({cellId:e,sorting:l,label:t=e??"",onClick:n})=>a("th",{onClick:c((()=>n?.(e)),[n,e],!o(n)),className:i(l,e)},t),C=({tableId:l,rowIds:o,store:n,cellComponent:s=e.CellView,getCellComponentProps:d,className:u,headerRow:c,idColumn:i,customCellIds:C,sorting:b,onHeaderThClick:m})=>{const k=e.useTableCellIds(l,n),h=C??k;return a("table",{className:u},!1===c?null:a("thead",null,a("tr",null,!1===i?null:a(I,{sorting:b,label:"Id",onClick:m}),t(h,(e=>a(I,{key:e,cellId:e,sorting:b,onClick:m}))))),a("tbody",null,t(o,(e=>a("tr",{key:e},!1===i?null:a("th",null,e),t(h,(t=>a("td",{key:t},a(s,{...r(d,e,t),tableId:l,rowId:e,cellId:t,store:n})))))))))};exports.SortedTableInHtmlTable=({tableId:l,cellId:t,descending:o,offset:n,limit:s,store:r,sortOnClick:d,...i})=>{const[I,b]=u([t,!!o]),m=c((e=>b([e,e==I[0]&&!I[1]])),[I],d);return a(C,{...i,tableId:l,store:r,rowIds:e.useSortedRowIds(l,...I,n,s,r),sorting:I,onHeaderThClick:m})},exports.TableInHtmlTable=({tableId:l,store:t,...o})=>a(C,{...o,tableId:l,store:t,rowIds:e.useRowIds(l,t)}),exports.ValuesInHtmlTable=({store:l,valueComponent:o=e.ValueView,getValueComponentProps:n,className:s,headerRow:d,idColumn:u})=>a("table",{className:s},!1===d?null:a("thead",null,a("tr",null,!1===u?null:a("th",null,"Id"),a("th",null,"Value"))),a("tbody",null,t(e.useValueIds(l),(e=>a("tr",{key:e},!1===u?null:a("th",null,e),a("td",null,a(o,{...r(n,e),valueId:e,store:l})))))));
Binary file
@@ -1 +1 @@
1
- "use strict";var e=require("react");const s=e=>typeof e,t="",o=s(t),r="Ids",l="Table",d=l+"s",u=l+r,n="Row",p=n+r,a="Sorted"+n+r,i="Cell",I=i+r,c="Value",x=c+"s",w=c+r,R=(e,s)=>e.map(s),C=e=>null==e,b=(e,s,t)=>C(e)?t?.():s(e),k=e=>s(e)==o,g=()=>{},{createContext:m,useContext:L}=e,V=m([]),h=(e,s)=>{const t=L(V);return C(e)?t[s]:k(e)?((e,s)=>b(e,(e=>e[s])))(t[s+1],e):e},S=(e,s)=>{const t=h(e,s);return C(e)||k(e)?t:e},y=e=>S(e,0),T=e=>S(e,2),v=e=>S(e,4),P=e=>S(e,6),q=e=>S(e,8),f=e=>S(e,10),{useCallback:B,useEffect:M,useMemo:D,useRef:A,useState:F}=e,G=(e,s,t=[])=>{const o=D((()=>s(e)),[e,...t]);return M((()=>()=>o.destroy()),[o]),o},E=(e,s,t,o=[],r)=>{const[,l]=F(),d=B((()=>s?.["get"+e]?.(...o)??t),[s,...o]),[u]=F(d),n=A(u);return D((()=>n.current=d()),[d]),Q(e,s,((...e)=>{n.current=C(r)?d():e[r],l([])}),[],o),n.current},Q=(e,s,t,o=[],r=[],...l)=>M((()=>{const o=s?.["add"+e+"Listener"]?.(...r,t,...l);return()=>s?.delListener(o)}),[s,...r,...o,...l]),U=(e,s,t,o=[],r=g,l=[],...d)=>{const u=y(e);return B((e=>b(u,(o=>b(t(e,o),(e=>r(o["set"+s](...d,e),e)))))),[u,s,...o,...l,...d])},j=(e,s,t=g,o=[],...r)=>{const l=y(e);return B((()=>t(l?.["del"+s](...r))),[l,s,...o,...r])},z=(e,s,t)=>{const o=f(e);return B((()=>o?.[s](t)),[o,s,t])},H=e=>E(u,y(e),[],[]),J=(e,s)=>E(p,y(s),[],[e]),K=(e,s,t,o=0,r,l)=>E(a,y(l),[],[e,s,t,o,r],6),N=(e,s,t)=>E(I,y(t),[],[e,s]),O=(e,s,t,o)=>E(i,y(o),void 0,[e,s,t],4),W=e=>E(w,y(e),[],[]),X=(e,s)=>E(c,y(s),void 0,[e]),Y=(e,s)=>E("Metric",T(s),void 0,[e]),Z=(e,s)=>E("SliceIds",v(s),[],[e]),$=(e,s,t)=>E("SliceRowIds",v(t),[],[e,s]),_=(e,s,t)=>E("RemoteRowId",P(t),void 0,[e,s]),ee=(e,s,t)=>E("LocalRowIds",P(t),[],[e,s]),se=(e,s,t)=>E("LinkedRowIds",P(t),[],[e,s]),te=(e,s)=>E("ResultRowIds",q(s),[],[e]),oe=(e,s,t,o=0,r,l)=>E("ResultSortedRowIds",q(l),[],[e,s,t,o,r],6),re=(e,s,t)=>E("ResultCellIds",q(t),[],[e,s]),le=(e,s,t,o)=>E("ResultCell",q(o),void 0,[e,s,t]),de=e=>E("CheckpointIds",f(e),[[],void 0,[]]),ue=(e,s)=>E("Checkpoint",f(s),void 0,[e]),ne=e=>z(e,"goBackward"),pe=e=>z(e,"goForward"),{createElement:ae,useMemo:ie}=e,Ie=({tableId:e,store:s,rowComponent:t=ge,getRowComponentProps:o,separator:r,debugIds:l},d)=>be(R(d,(r=>ae(t,{...Ce(o,r),key:r,tableId:e,rowId:r,store:s,debugIds:l}))),r,l,e),ce=({queryId:e,queries:s,resultRowComponent:t=Se,getResultRowComponentProps:o,separator:r,debugIds:l},d)=>be(R(d,(r=>ae(t,{...Ce(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:l}))),r,l,e),xe=e=>{const s=P(e);return[s,s?.getStore()]},we=({relationshipId:e,relationships:s,rowComponent:t=ge,getRowComponentProps:o,separator:r,debugIds:l},d,u)=>{const[n,p]=xe(s),a=n?.getLocalTableId(e),i=d(e,u,n);return be(R(i,(e=>ae(t,{...Ce(o,e),key:e,tableId:a,rowId:e,store:p,debugIds:l}))),r,l,u)},Re=e=>({checkpoints:s,checkpointComponent:t=ye,getCheckpointComponentProps:o,separator:r,debugIds:l})=>{const d=f(s);return be(R(e(de(d)),(e=>ae(t,{...Ce(o,e),key:e,checkpoints:d,checkpointId:e,debugIds:l}))),r)},Ce=(e,s)=>C(e)?{}:e(s),be=(e,s,t,o)=>{const r=C(s)||!Array.isArray(e)?e:R(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},ke=({tableId:e,rowId:s,cellId:o,store:r,debugIds:l})=>be(t+(O(e,s,o,r)??t),void 0,l,o),ge=({tableId:e,rowId:s,store:t,cellComponent:o=ke,getCellComponentProps:r,separator:l,debugIds:d})=>be(R(N(e,s,t),(l=>ae(o,{...Ce(r,l),key:l,tableId:e,rowId:s,cellId:l,store:t,debugIds:d}))),l,d,s),me=e=>Ie(e,J(e.tableId,e.store)),Le=({valueId:e,store:s,debugIds:o})=>be(t+(X(e,s)??t),void 0,o,e),Ve=({indexId:e,sliceId:s,indexes:t,rowComponent:o=ge,getRowComponentProps:r,separator:l,debugIds:d})=>{const u=v(t),n=u?.getStore(),p=u?.getTableId(e),a=$(e,s,u);return be(R(a,(e=>ae(o,{...Ce(r,e),key:e,tableId:p,rowId:e,store:n,debugIds:d}))),l,d,s)},he=({queryId:e,rowId:s,cellId:o,queries:r,debugIds:l})=>be(t+(le(e,s,o,r)??t),void 0,l,o),Se=({queryId:e,rowId:s,queries:t,resultCellComponent:o=he,getResultCellComponentProps:r,separator:l,debugIds:d})=>be(R(re(e,s,t),(l=>ae(o,{...Ce(r,l),key:l,queryId:e,rowId:s,cellId:l,queries:t,debugIds:d}))),l,d,s),ye=({checkpoints:e,checkpointId:s,debugIds:o})=>be(ue(s,e)??t,void 0,o,s),Te=Re((e=>e[0])),ve=Re((e=>C(e[1])?[]:[e[1]])),Pe=Re((e=>e[2]));exports.BackwardCheckpointsView=Te,exports.CellView=ke,exports.CheckpointView=ye,exports.CurrentCheckpointView=ve,exports.ForwardCheckpointsView=Pe,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=Ve,getSliceComponentProps:o,separator:r,debugIds:l})=>be(R(Z(e,s),(r=>ae(t,{...Ce(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:l}))),r,l,e),exports.LinkedRowsView=e=>we(e,se,e.firstRowId),exports.LocalRowsView=e=>we(e,ee,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:o})=>be(Y(e,s)??t,void 0,o,e),exports.Provider=({store:s,storesById:t,metrics:o,metricsById:r,indexes:l,indexesById:d,relationships:u,relationshipsById:n,queries:p,queriesById:a,checkpoints:i,checkpointsById:I,children:c})=>{const x=e.useContext(V);return ae(V.Provider,{value:ie((()=>[s??x[0],{...x[1],...t},o??x[2],{...x[3],...r},l??x[4],{...x[5],...d},u??x[6],{...x[7],...n},p??x[8],{...x[9],...a},i??x[10],{...x[11],...I}]),[s,t,o,r,l,d,u,n,p,a,i,I,x])},c)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=ge,getRowComponentProps:r,debugIds:l})=>{const[d,u]=xe(t),n=d?.getRemoteTableId(e),p=_(e,s,d);return be(C(n)||C(p)?null:ae(o,{...Ce(r,p),key:p,tableId:n,rowId:p,store:u,debugIds:l}),void 0,l,s)},exports.ResultCellView=he,exports.ResultRowView=Se,exports.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ce(r,oe(r.queryId,e,s,t,o,r.queries)),exports.ResultTableView=e=>ce(e,te(e.queryId,e.queries)),exports.RowView=ge,exports.SliceView=Ve,exports.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>Ie(r,K(r.tableId,e,s,t,o,r.store)),exports.TableView=me,exports.TablesView=({store:e,tableComponent:s=me,getTableComponentProps:t,separator:o,debugIds:r})=>be(R(H(e),(o=>ae(s,{...Ce(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),exports.ValueView=Le,exports.ValuesView=({store:e,valueComponent:s=Le,getValueComponentProps:t,separator:o,debugIds:r})=>be(R(W(e),(o=>ae(s,{...Ce(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),exports.tableView=Ie,exports.useAddRowCallback=(e,s,t=[],o,r=g,l=[],d=!0)=>{const u=y(o);return B((t=>b(u,(o=>b(s(t,o),(s=>r(o.addRow(e,s,d),o,s)))))),[u,e,...t,...l,d])},exports.useCell=O,exports.useCellIds=N,exports.useCellIdsListener=(e,s,t,o,r,l)=>Q(I,y(l),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,l,d)=>Q(i,y(d),o,r,[e,s,t],l),exports.useCheckpoint=ue,exports.useCheckpointIds=de,exports.useCheckpointIdsListener=(e,s,t)=>Q("CheckpointIds",f(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>Q("Checkpoint",f(o),s,t,[e]),exports.useCheckpoints=e=>h(e,10),exports.useCreateCheckpoints=(e,s,t)=>G(e,s,t),exports.useCreateIndexes=(e,s,t)=>G(e,s,t),exports.useCreateMetrics=(e,s,t)=>G(e,s,t),exports.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,l]=F(),d=D((()=>s(e)),[e,...t]);return M((()=>((async()=>{await(o?.(d)),l(1)})(),()=>{d.destroy()})),[d,...r]),d},exports.useCreateQueries=(e,s,t)=>G(e,s,t),exports.useCreateRelationships=(e,s,t)=>G(e,s,t),exports.useCreateStore=(e,s=[])=>D(e,s),exports.useDelCellCallback=(e,s,t,o,r,l,d)=>j(r,i,l,d,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>j(t,n,o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>j(s,l,t,o,e),exports.useDelTablesCallback=(e,s,t)=>j(e,d,s,t),exports.useDelValueCallback=(e,s,t,o)=>j(s,c,t,o,e),exports.useDelValuesCallback=(e,s,t)=>j(e,x,s,t),exports.useGoBackwardCallback=ne,exports.useGoForwardCallback=pe,exports.useGoToCallback=(e,s=[],t,o=g,r=[])=>{const l=f(t);return B((s=>b(l,(t=>b(e(s),(e=>o(t.goTo(e),e)))))),[l,...s,...r])},exports.useIndexes=e=>h(e,4),exports.useLinkedRowIds=se,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>Q("LinkedRowIds",P(r),t,o,[e,s]),exports.useLocalRowIds=ee,exports.useLocalRowIdsListener=(e,s,t,o,r)=>Q("LocalRowIds",P(r),t,o,[e,s]),exports.useMetric=Y,exports.useMetricListener=(e,s,t,o)=>Q("Metric",T(o),s,t,[e]),exports.useMetrics=e=>h(e,2),exports.useQueries=e=>h(e,8),exports.useRedoInformation=e=>{const s=f(e),[,,[o]]=de(s);return[!C(o),pe(s),o,b(o,(e=>s?.getCheckpoint(e)))??t]},exports.useRelationships=e=>h(e,6),exports.useRemoteRowId=_,exports.useRemoteRowIdListener=(e,s,t,o,r)=>Q("RemoteRowId",P(r),t,o,[e,s]),exports.useResultCell=le,exports.useResultCellIds=re,exports.useResultCellIdsListener=(e,s,t,o,r)=>Q("ResultCellIds",q(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,l)=>Q("ResultCell",q(l),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>E("ResultRow",q(t),{},[e,s]),exports.useResultRowIds=te,exports.useResultRowIdsListener=(e,s,t,o)=>Q("ResultRowIds",q(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>Q("ResultRow",q(r),t,o,[e,s]),exports.useResultSortedRowIds=oe,exports.useResultSortedRowIdsListener=(e,s,t,o,r,l,d,u)=>Q("ResultSortedRowIds",q(u),l,d,[e,s,t,o,r]),exports.useResultTable=(e,s)=>E("ResultTable",q(s),{},[e]),exports.useResultTableListener=(e,s,t,o)=>Q("ResultTable",q(o),s,t,[e]),exports.useRow=(e,s,t)=>E(n,y(t),{},[e,s]),exports.useRowIds=J,exports.useRowIdsListener=(e,s,t,o,r)=>Q(p,y(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,l)=>Q(n,y(l),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,l,d,u)=>U(l,i,o,r,d,u,e,s,t),exports.useSetCheckpointCallback=(e=g,s=[],t,o=g,r=[])=>{const l=f(t);return B((s=>b(l,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[l,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,l,d)=>U(r,"PartialRow",t,o,l,d,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>U(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,l,d)=>U(r,n,t,o,l,d,e,s),exports.useSetTableCallback=(e,s,t,o,r,d)=>U(o,l,s,t,r,d,e),exports.useSetTablesCallback=(e,s,t,o,r)=>U(t,d,e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,l)=>U(o,c,s,t,r,l,e),exports.useSetValuesCallback=(e,s,t,o,r)=>U(t,x,e,s,o,r),exports.useSliceIds=Z,exports.useSliceIdsListener=(e,s,t,o)=>Q("SliceIds",v(o),s,t,[e]),exports.useSliceRowIds=$,exports.useSliceRowIdsListener=(e,s,t,o,r)=>Q("SliceRowIds",v(r),t,o,[e,s]),exports.useSortedRowIds=K,exports.useSortedRowIdsListener=(e,s,t,o,r,l,d,u,n)=>Q(a,y(n),l,d,[e,s,t,o,r],u),exports.useStore=e=>h(e,0),exports.useTable=(e,s)=>E(l,y(s),{},[e]),exports.useTableCellIds=(e,s)=>E(l+I,y(s),[],[e]),exports.useTableCellIdsListener=(e,s,t,o,r)=>Q(l+I,y(r),s,t,[e],o),exports.useTableIds=H,exports.useTableIdsListener=(e,s,t,o)=>Q(u,y(o),e,s,[],t),exports.useTableListener=(e,s,t,o,r)=>Q(l,y(r),s,t,[e],o),exports.useTables=e=>E(d,y(e),{}),exports.useTablesListener=(e,s,t,o)=>Q(d,y(o),e,s,[],t),exports.useUndoInformation=e=>{const s=f(e),[o,r]=de(s);return[(l=o,!(0==(e=>e.length)(l))),ne(s),r,b(r,(e=>s?.getCheckpoint(e)))??t];var l},exports.useValue=X,exports.useValueIds=W,exports.useValueIdsListener=(e,s,t,o)=>Q(w,y(o),e,s,[],t),exports.useValueListener=(e,s,t,o,r)=>Q(c,y(r),s,t,[e],o),exports.useValues=e=>E(x,y(e),{}),exports.useValuesListener=(e,s,t,o)=>Q(x,y(o),e,s,[],t);
1
+ "use strict";var e=require("react");const s=e=>typeof e,t="",o=s(t),r="Ids",l="Table",d=l+"s",u=l+r,n="Row",p=n+r,a="Sorted"+n+r,i="Cell",I=i+r,c="Value",x=c+"s",w=c+r,C=(e,s)=>e.map(s),R=e=>null==e,b=(e,s,t)=>R(e)?t?.():s(e),k=e=>s(e)==o,g=()=>{},{createContext:m,useContext:L}=e,h=m([]),V=(e,s)=>{const t=L(h);return R(e)?t[s]:k(e)?((e,s)=>b(e,(e=>e[s])))(t[s+1],e):e},S=(e,s)=>{const t=V(e,s);return R(e)||k(e)?t:e},y=(e,...s)=>R(e)?{}:e(...s),T=e=>S(e,0),v=e=>S(e,2),P=e=>S(e,4),q=e=>S(e,6),f=e=>S(e,8),B=e=>S(e,10),{useCallback:M,useEffect:D,useMemo:A,useRef:F,useState:G}=e,E=(e,s,t=[])=>{const o=A((()=>s(e)),[e,...t]);return D((()=>()=>o.destroy()),[o]),o},Q=(e,s,t,o=[],r)=>{const[,l]=G(),d=M((()=>s?.["get"+e]?.(...o)??t),[s,...o]),[u]=G(d),n=F(u);return A((()=>n.current=d()),[d]),U(e,s,((...e)=>{n.current=R(r)?d():e[r],l([])}),[],o),n.current},U=(e,s,t,o=[],r=[],...l)=>D((()=>{const o=s?.["add"+e+"Listener"]?.(...r,t,...l);return()=>s?.delListener(o)}),[s,...r,...o,...l]),j=(e,s,t,o=[],r=g,l=[],...d)=>{const u=T(e);return M((e=>b(u,(o=>b(t(e,o),(e=>r(o["set"+s](...d,e),e)))))),[u,s,...o,...l,...d])},z=(e,s,t=g,o=[],...r)=>{const l=T(e);return M((()=>t(l?.["del"+s](...r))),[l,s,...o,...r])},H=(e,s,t)=>{const o=B(e);return M((()=>o?.[s](t)),[o,s,t])},J=e=>Q(u,T(e),[],[]),K=(e,s)=>Q(p,T(s),[],[e]),N=(e,s,t,o=0,r,l)=>Q(a,T(l),[],[e,s,t,o,r],6),O=(e,s,t)=>Q(I,T(t),[],[e,s]),W=(e,s,t,o)=>Q(i,T(o),void 0,[e,s,t],4),X=e=>Q(w,T(e),[],[]),Y=(e,s)=>Q(c,T(s),void 0,[e]),Z=(e,s)=>Q("Metric",v(s),void 0,[e]),$=(e,s)=>Q("SliceIds",P(s),[],[e]),_=(e,s,t)=>Q("SliceRowIds",P(t),[],[e,s]),ee=(e,s,t)=>Q("RemoteRowId",q(t),void 0,[e,s]),se=(e,s,t)=>Q("LocalRowIds",q(t),[],[e,s]),te=(e,s,t)=>Q("LinkedRowIds",q(t),[],[e,s]),oe=(e,s)=>Q("ResultRowIds",f(s),[],[e]),re=(e,s,t,o=0,r,l)=>Q("ResultSortedRowIds",f(l),[],[e,s,t,o,r],6),le=(e,s,t)=>Q("ResultCellIds",f(t),[],[e,s]),de=(e,s,t,o)=>Q("ResultCell",f(o),void 0,[e,s,t]),ue=e=>Q("CheckpointIds",B(e),[[],void 0,[]]),ne=(e,s)=>Q("Checkpoint",B(s),void 0,[e]),pe=e=>H(e,"goBackward"),ae=e=>H(e,"goForward"),{createElement:ie,useMemo:Ie}=e,ce=({tableId:e,store:s,rowComponent:t=ge,getRowComponentProps:o,customCellIds:r,separator:l,debugIds:d},u)=>be(C(u,(l=>ie(t,{...y(o,l),key:l,tableId:e,rowId:l,customCellIds:r,store:s,debugIds:d}))),l,d,e),xe=({queryId:e,queries:s,resultRowComponent:t=Se,getResultRowComponentProps:o,separator:r,debugIds:l},d)=>be(C(d,(r=>ie(t,{...y(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:l}))),r,l,e),we=e=>{const s=q(e);return[s,s?.getStore()]},Ce=({relationshipId:e,relationships:s,rowComponent:t=ge,getRowComponentProps:o,separator:r,debugIds:l},d,u)=>{const[n,p]=we(s),a=n?.getLocalTableId(e),i=d(e,u,n);return be(C(i,(e=>ie(t,{...y(o,e),key:e,tableId:a,rowId:e,store:p,debugIds:l}))),r,l,u)},Re=e=>({checkpoints:s,checkpointComponent:t=ye,getCheckpointComponentProps:o,separator:r,debugIds:l})=>{const d=B(s);return be(C(e(ue(d)),(e=>ie(t,{...y(o,e),key:e,checkpoints:d,checkpointId:e,debugIds:l}))),r)},be=(e,s,t,o)=>{const r=R(s)||!Array.isArray(e)?e:C(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},ke=({tableId:e,rowId:s,cellId:o,store:r,debugIds:l})=>be(t+(W(e,s,o,r)??t),void 0,l,o),ge=({tableId:e,rowId:s,store:t,cellComponent:o=ke,getCellComponentProps:r,customCellIds:l,separator:d,debugIds:u})=>be(C(((e,s,t,o)=>{const r=O(s,t,o);return e??r})(l,e,s,t),(l=>ie(o,{...y(r,l),key:l,tableId:e,rowId:s,cellId:l,store:t,debugIds:u}))),d,u,s),me=e=>ce(e,K(e.tableId,e.store)),Le=({valueId:e,store:s,debugIds:o})=>be(t+(Y(e,s)??t),void 0,o,e),he=({indexId:e,sliceId:s,indexes:t,rowComponent:o=ge,getRowComponentProps:r,separator:l,debugIds:d})=>{const u=P(t),n=u?.getStore(),p=u?.getTableId(e),a=_(e,s,u);return be(C(a,(e=>ie(o,{...y(r,e),key:e,tableId:p,rowId:e,store:n,debugIds:d}))),l,d,s)},Ve=({queryId:e,rowId:s,cellId:o,queries:r,debugIds:l})=>be(t+(de(e,s,o,r)??t),void 0,l,o),Se=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Ve,getResultCellComponentProps:r,separator:l,debugIds:d})=>be(C(le(e,s,t),(l=>ie(o,{...y(r,l),key:l,queryId:e,rowId:s,cellId:l,queries:t,debugIds:d}))),l,d,s),ye=({checkpoints:e,checkpointId:s,debugIds:o})=>be(ne(s,e)??t,void 0,o,s),Te=Re((e=>e[0])),ve=Re((e=>R(e[1])?[]:[e[1]])),Pe=Re((e=>e[2]));exports.BackwardCheckpointsView=Te,exports.CellView=ke,exports.CheckpointView=ye,exports.CurrentCheckpointView=ve,exports.ForwardCheckpointsView=Pe,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=he,getSliceComponentProps:o,separator:r,debugIds:l})=>be(C($(e,s),(r=>ie(t,{...y(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:l}))),r,l,e),exports.LinkedRowsView=e=>Ce(e,te,e.firstRowId),exports.LocalRowsView=e=>Ce(e,se,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:o})=>be(Z(e,s)??t,void 0,o,e),exports.Provider=({store:s,storesById:t,metrics:o,metricsById:r,indexes:l,indexesById:d,relationships:u,relationshipsById:n,queries:p,queriesById:a,checkpoints:i,checkpointsById:I,children:c})=>{const x=e.useContext(h);return ie(h.Provider,{value:Ie((()=>[s??x[0],{...x[1],...t},o??x[2],{...x[3],...r},l??x[4],{...x[5],...d},u??x[6],{...x[7],...n},p??x[8],{...x[9],...a},i??x[10],{...x[11],...I}]),[s,t,o,r,l,d,u,n,p,a,i,I,x])},c)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=ge,getRowComponentProps:r,debugIds:l})=>{const[d,u]=we(t),n=d?.getRemoteTableId(e),p=ee(e,s,d);return be(R(n)||R(p)?null:ie(o,{...y(r,p),key:p,tableId:n,rowId:p,store:u,debugIds:l}),void 0,l,s)},exports.ResultCellView=Ve,exports.ResultRowView=Se,exports.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>xe(r,re(r.queryId,e,s,t,o,r.queries)),exports.ResultTableView=e=>xe(e,oe(e.queryId,e.queries)),exports.RowView=ge,exports.SliceView=he,exports.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ce(r,N(r.tableId,e,s,t,o,r.store)),exports.TableView=me,exports.TablesView=({store:e,tableComponent:s=me,getTableComponentProps:t,separator:o,debugIds:r})=>be(C(J(e),(o=>ie(s,{...y(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),exports.ValueView=Le,exports.ValuesView=({store:e,valueComponent:s=Le,getValueComponentProps:t,separator:o,debugIds:r})=>be(C(X(e),(o=>ie(s,{...y(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),exports.useAddRowCallback=(e,s,t=[],o,r=g,l=[],d=!0)=>{const u=T(o);return M((t=>b(u,(o=>b(s(t,o),(s=>r(o.addRow(e,s,d),o,s)))))),[u,e,...t,...l,d])},exports.useCell=W,exports.useCellIds=O,exports.useCellIdsListener=(e,s,t,o,r,l)=>U(I,T(l),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,l,d)=>U(i,T(d),o,r,[e,s,t],l),exports.useCheckpoint=ne,exports.useCheckpointIds=ue,exports.useCheckpointIdsListener=(e,s,t)=>U("CheckpointIds",B(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>U("Checkpoint",B(o),s,t,[e]),exports.useCheckpoints=e=>V(e,10),exports.useCreateCheckpoints=(e,s,t)=>E(e,s,t),exports.useCreateIndexes=(e,s,t)=>E(e,s,t),exports.useCreateMetrics=(e,s,t)=>E(e,s,t),exports.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,l]=G(),d=A((()=>s(e)),[e,...t]);return D((()=>((async()=>{await(o?.(d)),l(1)})(),()=>{d.destroy()})),[d,...r]),d},exports.useCreateQueries=(e,s,t)=>E(e,s,t),exports.useCreateRelationships=(e,s,t)=>E(e,s,t),exports.useCreateStore=(e,s=[])=>A(e,s),exports.useDelCellCallback=(e,s,t,o,r,l,d)=>z(r,i,l,d,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>z(t,n,o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>z(s,l,t,o,e),exports.useDelTablesCallback=(e,s,t)=>z(e,d,s,t),exports.useDelValueCallback=(e,s,t,o)=>z(s,c,t,o,e),exports.useDelValuesCallback=(e,s,t)=>z(e,x,s,t),exports.useGoBackwardCallback=pe,exports.useGoForwardCallback=ae,exports.useGoToCallback=(e,s=[],t,o=g,r=[])=>{const l=B(t);return M((s=>b(l,(t=>b(e(s),(e=>o(t.goTo(e),e)))))),[l,...s,...r])},exports.useIndexes=e=>V(e,4),exports.useLinkedRowIds=te,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>U("LinkedRowIds",q(r),t,o,[e,s]),exports.useLocalRowIds=se,exports.useLocalRowIdsListener=(e,s,t,o,r)=>U("LocalRowIds",q(r),t,o,[e,s]),exports.useMetric=Z,exports.useMetricListener=(e,s,t,o)=>U("Metric",v(o),s,t,[e]),exports.useMetrics=e=>V(e,2),exports.useQueries=e=>V(e,8),exports.useRedoInformation=e=>{const s=B(e),[,,[o]]=ue(s);return[!R(o),ae(s),o,b(o,(e=>s?.getCheckpoint(e)))??t]},exports.useRelationships=e=>V(e,6),exports.useRemoteRowId=ee,exports.useRemoteRowIdListener=(e,s,t,o,r)=>U("RemoteRowId",q(r),t,o,[e,s]),exports.useResultCell=de,exports.useResultCellIds=le,exports.useResultCellIdsListener=(e,s,t,o,r)=>U("ResultCellIds",f(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,l)=>U("ResultCell",f(l),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>Q("ResultRow",f(t),{},[e,s]),exports.useResultRowIds=oe,exports.useResultRowIdsListener=(e,s,t,o)=>U("ResultRowIds",f(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>U("ResultRow",f(r),t,o,[e,s]),exports.useResultSortedRowIds=re,exports.useResultSortedRowIdsListener=(e,s,t,o,r,l,d,u)=>U("ResultSortedRowIds",f(u),l,d,[e,s,t,o,r]),exports.useResultTable=(e,s)=>Q("ResultTable",f(s),{},[e]),exports.useResultTableListener=(e,s,t,o)=>U("ResultTable",f(o),s,t,[e]),exports.useRow=(e,s,t)=>Q(n,T(t),{},[e,s]),exports.useRowIds=K,exports.useRowIdsListener=(e,s,t,o,r)=>U(p,T(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,l)=>U(n,T(l),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,l,d,u)=>j(l,i,o,r,d,u,e,s,t),exports.useSetCheckpointCallback=(e=g,s=[],t,o=g,r=[])=>{const l=B(t);return M((s=>b(l,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[l,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,l,d)=>j(r,"PartialRow",t,o,l,d,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>j(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,l,d)=>j(r,n,t,o,l,d,e,s),exports.useSetTableCallback=(e,s,t,o,r,d)=>j(o,l,s,t,r,d,e),exports.useSetTablesCallback=(e,s,t,o,r)=>j(t,d,e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,l)=>j(o,c,s,t,r,l,e),exports.useSetValuesCallback=(e,s,t,o,r)=>j(t,x,e,s,o,r),exports.useSliceIds=$,exports.useSliceIdsListener=(e,s,t,o)=>U("SliceIds",P(o),s,t,[e]),exports.useSliceRowIds=_,exports.useSliceRowIdsListener=(e,s,t,o,r)=>U("SliceRowIds",P(r),t,o,[e,s]),exports.useSortedRowIds=N,exports.useSortedRowIdsListener=(e,s,t,o,r,l,d,u,n)=>U(a,T(n),l,d,[e,s,t,o,r],u),exports.useStore=e=>V(e,0),exports.useTable=(e,s)=>Q(l,T(s),{},[e]),exports.useTableCellIds=(e,s)=>Q(l+I,T(s),[],[e]),exports.useTableCellIdsListener=(e,s,t,o,r)=>U(l+I,T(r),s,t,[e],o),exports.useTableIds=J,exports.useTableIdsListener=(e,s,t,o)=>U(u,T(o),e,s,[],t),exports.useTableListener=(e,s,t,o,r)=>U(l,T(r),s,t,[e],o),exports.useTables=e=>Q(d,T(e),{}),exports.useTablesListener=(e,s,t,o)=>U(d,T(o),e,s,[],t),exports.useUndoInformation=e=>{const s=B(e),[o,r]=ue(s);return[(l=o,!(0==(e=>e.length)(l))),pe(s),r,b(r,(e=>s?.getCheckpoint(e)))??t];var l},exports.useValue=Y,exports.useValueIds=X,exports.useValueIdsListener=(e,s,t,o)=>U(w,T(o),e,s,[],t),exports.useValueListener=(e,s,t,o,r)=>U(c,T(r),s,t,[e],o),exports.useValues=e=>Q(x,T(e),{}),exports.useValuesListener=(e,s,t,o)=>U(x,T(o),e,s,[],t);
Binary file
@@ -1 +1 @@
1
- "use strict";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})}));exports.createTools=Tl;
1
+ "use strict";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})}));exports.createTools=Tl;
Binary file
@@ -0,0 +1 @@
1
+ "use strict";var e=require("./ui-react"),l=require("react");const t=(e,l)=>e.map(l),r=e=>null==e,{createContext:o,useContext:n}=l;o([]);const a=(e,...l)=>r(e)?{}:e(...l);var s=Object.defineProperty,d=Object.defineProperties,u=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,I=(e,l,t)=>l in e?s(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,m=(e,l)=>{for(var t in l||(l={}))i.call(l,t)&&I(e,t,l[t]);if(c)for(var t of c(l))b.call(l,t)&&I(e,t,l[t]);return e},p=(e,l)=>d(e,u(l)),C=(e,l)=>{var t={};for(var r in e)i.call(e,r)&&l.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&c)for(var r of c(e))l.indexOf(r)<0&&b.call(e,r)&&(t[r]=e[r]);return t};const{createElement:f,useCallback:v,useState:w}=l,y=(e,l,t)=>{const r=v(e,l);return t?r:void 0},g=(e,l)=>r(e)||e[0]!=l?void 0:`sorted ${e[1]?"de":"a"}scending`,k=({cellId:e,sorting:l,label:t=(null!=e?e:""),onClick:o})=>f("th",{onClick:y((()=>null==o?void 0:o(e)),[o,e],!r(o)),className:g(l,e)},t),O=({tableId:l,rowIds:r,store:o,cellComponent:n=e.CellView,getCellComponentProps:s,className:d,headerRow:u,idColumn:c,customCellIds:i,sorting:b,onHeaderThClick:I})=>{const C=e.useTableCellIds(l,o),v=null!=i?i:C;return f("table",{className:d},!1===u?null:f("thead",null,f("tr",null,!1===c?null:f(k,{sorting:b,label:"Id",onClick:I}),t(v,(e=>f(k,{key:e,cellId:e,sorting:b,onClick:I}))))),f("tbody",null,t(r,(e=>f("tr",{key:e},!1===c?null:f("th",null,e),t(v,(t=>f("td",{key:t},f(n,p(m({},a(s,e,t)),{tableId:l,rowId:e,cellId:t,store:o}))))))))))};exports.SortedTableInHtmlTable=l=>{var t=l,{tableId:r,cellId:o,descending:n,offset:a,limit:s,store:d,sortOnClick:u}=t,c=C(t,["tableId","cellId","descending","offset","limit","store","sortOnClick"]);const[i,b]=w([o,!!n]),I=y((e=>b([e,e==i[0]&&!i[1]])),[i],u);return f(O,p(m({},c),{tableId:r,store:d,rowIds:e.useSortedRowIds(r,...i,a,s,d),sorting:i,onHeaderThClick:I}))},exports.TableInHtmlTable=l=>{var t=l,{tableId:r,store:o}=t,n=C(t,["tableId","store"]);return f(O,p(m({},n),{tableId:r,store:o,rowIds:e.useRowIds(r,o)}))},exports.ValuesInHtmlTable=({store:l,valueComponent:r=e.ValueView,getValueComponentProps:o,className:n,headerRow:s,idColumn:d})=>f("table",{className:n},!1===s?null:f("thead",null,f("tr",null,!1===d?null:f("th",null,"Id"),f("th",null,"Value"))),f("tbody",null,t(e.useValueIds(l),(e=>f("tr",{key:e},!1===d?null:f("th",null,e),f("td",null,f(r,p(m({},a(o,e)),{valueId:e,store:l}))))))));
Binary file
@@ -1 +1 @@
1
- "use strict";var e=require("react");const s=e=>typeof e,t="",o=s(t),r="Ids",l="Table",u=l+"s",d=l+r,n="Row",i=n+r,a="Sorted"+n+r,p="Cell",c=p+r,I="Value",x=I+"s",w=I+r,b=(e,s)=>e.map(s),R=e=>null==e,C=(e,s,t)=>R(e)?null==t?void 0:t():s(e),k=e=>s(e)==o,v=()=>{},{createContext:g,useContext:m}=e,h=g([]),y=(e,s)=>{const t=m(h);return R(e)?t[s]:k(e)?((e,s)=>C(e,(e=>e[s])))(t[s+1],e):e},L=(e,s)=>{const t=y(e,s);return R(e)||k(e)?t:e},V=e=>L(e,0),S=e=>L(e,2),f=e=>L(e,4),T=e=>L(e,6),P=e=>L(e,8),q=e=>L(e,10),{useCallback:O,useEffect:B,useMemo:M,useRef:D,useState:j}=e,A=(e,s,t=[])=>{const o=M((()=>s(e)),[e,...t]);return B((()=>()=>o.destroy()),[o]),o},E=(e,s,t,o=[],r)=>{const[,l]=j(),u=O((()=>{var r,l;return null!=(l=null==(r=null==s?void 0:s["get"+e])?void 0:r.call(s,...o))?l:t}),[s,...o]),[d]=j(u),n=D(d);return M((()=>n.current=u()),[u]),F(e,s,((...e)=>{n.current=R(r)?u():e[r],l([])}),[],o),n.current},F=(e,s,t,o=[],r=[],...l)=>B((()=>{var o;const u=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...r,t,...l);return()=>null==s?void 0:s.delListener(u)}),[s,...r,...o,...l]),G=(e,s,t,o=[],r=v,l=[],...u)=>{const d=V(e);return O((e=>C(d,(o=>C(t(e,o),(e=>r(o["set"+s](...u,e),e)))))),[d,s,...o,...l,...u])},Q=(e,s,t=v,o=[],...r)=>{const l=V(e);return O((()=>t(null==l?void 0:l["del"+s](...r))),[l,s,...o,...r])},U=(e,s,t)=>{const o=q(e);return O((()=>null==o?void 0:o[s](t)),[o,s,t])},z=e=>E(d,V(e),[],[]),H=(e,s)=>E(i,V(s),[],[e]),J=(e,s,t,o=0,r,l)=>E(a,V(l),[],[e,s,t,o,r],6),K=(e,s,t)=>E(c,V(t),[],[e,s]),N=(e,s,t,o)=>E(p,V(o),void 0,[e,s,t],4),W=e=>E(w,V(e),[],[]),X=(e,s)=>E(I,V(s),void 0,[e]),Y=(e,s)=>E("Metric",S(s),void 0,[e]),Z=(e,s)=>E("SliceIds",f(s),[],[e]),$=(e,s,t)=>E("SliceRowIds",f(t),[],[e,s]),_=(e,s,t)=>E("RemoteRowId",T(t),void 0,[e,s]),ee=(e,s,t)=>E("LocalRowIds",T(t),[],[e,s]),se=(e,s,t)=>E("LinkedRowIds",T(t),[],[e,s]),te=(e,s)=>E("ResultRowIds",P(s),[],[e]),oe=(e,s,t,o=0,r,l)=>E("ResultSortedRowIds",P(l),[],[e,s,t,o,r],6),re=(e,s,t)=>E("ResultCellIds",P(t),[],[e,s]),le=(e,s,t,o)=>E("ResultCell",P(o),void 0,[e,s,t]),ue=e=>E("CheckpointIds",q(e),[[],void 0,[]]),de=(e,s)=>E("Checkpoint",q(s),void 0,[e]),ne=e=>U(e,"goBackward"),ie=e=>U(e,"goForward");var ae=Object.defineProperty,pe=Object.defineProperties,ce=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,xe=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable,be=(e,s,t)=>s in e?ae(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,Re=(e,s)=>{for(var t in s||(s={}))xe.call(s,t)&&be(e,t,s[t]);if(Ie)for(var t of Ie(s))we.call(s,t)&&be(e,t,s[t]);return e},Ce=(e,s)=>pe(e,ce(s)),ke=(e,s)=>{var t={};for(var o in e)xe.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&Ie)for(var o of Ie(e))s.indexOf(o)<0&&we.call(e,o)&&(t[o]=e[o]);return t};const{createElement:ve,useMemo:ge}=e,me=({tableId:e,store:s,rowComponent:t=Pe,getRowComponentProps:o,separator:r,debugIds:l},u)=>fe(b(u,(r=>ve(t,Ce(Re({},Se(o,r)),{key:r,tableId:e,rowId:r,store:s,debugIds:l})))),r,l,e),he=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:o,separator:r,debugIds:l},u)=>fe(b(u,(r=>ve(t,Ce(Re({},Se(o,r)),{key:r,queryId:e,rowId:r,queries:s,debugIds:l})))),r,l,e),ye=e=>{const s=T(e);return[s,null==s?void 0:s.getStore()]},Le=({relationshipId:e,relationships:s,rowComponent:t=Pe,getRowComponentProps:o,separator:r,debugIds:l},u,d)=>{const[n,i]=ye(s),a=null==n?void 0:n.getLocalTableId(e),p=u(e,d,n);return fe(b(p,(e=>ve(t,Ce(Re({},Se(o,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:l})))),r,l,d)},Ve=e=>({checkpoints:s,checkpointComponent:t=je,getCheckpointComponentProps:o,separator:r,debugIds:l})=>{const u=q(s);return fe(b(e(ue(u)),(e=>ve(t,Ce(Re({},Se(o,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:l})))),r)},Se=(e,s)=>R(e)?{}:e(s),fe=(e,s,t,o)=>{const r=R(s)||!Array.isArray(e)?e:b(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},Te=({tableId:e,rowId:s,cellId:o,store:r,debugIds:l})=>{var u;return fe(t+(null!=(u=N(e,s,o,r))?u:t),void 0,l,o)},Pe=({tableId:e,rowId:s,store:t,cellComponent:o=Te,getCellComponentProps:r,separator:l,debugIds:u})=>fe(b(K(e,s,t),(l=>ve(o,Ce(Re({},Se(r,l)),{key:l,tableId:e,rowId:s,cellId:l,store:t,debugIds:u})))),l,u,s),qe=e=>me(e,H(e.tableId,e.store)),Oe=({valueId:e,store:s,debugIds:o})=>{var r;return fe(t+(null!=(r=X(e,s))?r:t),void 0,o,e)},Be=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Pe,getRowComponentProps:r,separator:l,debugIds:u})=>{const d=f(t),n=null==d?void 0:d.getStore(),i=null==d?void 0:d.getTableId(e),a=$(e,s,d);return fe(b(a,(e=>ve(o,Ce(Re({},Se(r,e)),{key:e,tableId:i,rowId:e,store:n,debugIds:u})))),l,u,s)},Me=({queryId:e,rowId:s,cellId:o,queries:r,debugIds:l})=>{var u;return fe(t+(null!=(u=le(e,s,o,r))?u:t),void 0,l,o)},De=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Me,getResultCellComponentProps:r,separator:l,debugIds:u})=>fe(b(re(e,s,t),(l=>ve(o,Ce(Re({},Se(r,l)),{key:l,queryId:e,rowId:s,cellId:l,queries:t,debugIds:u})))),l,u,s),je=({checkpoints:e,checkpointId:s,debugIds:o})=>{var r;return fe(null!=(r=de(s,e))?r:t,void 0,o,s)},Ae=Ve((e=>e[0])),Ee=Ve((e=>R(e[1])?[]:[e[1]])),Fe=Ve((e=>e[2]));exports.BackwardCheckpointsView=Ae,exports.CellView=Te,exports.CheckpointView=je,exports.CurrentCheckpointView=Ee,exports.ForwardCheckpointsView=Fe,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=Be,getSliceComponentProps:o,separator:r,debugIds:l})=>fe(b(Z(e,s),(r=>ve(t,Ce(Re({},Se(o,r)),{key:r,indexId:e,sliceId:r,indexes:s,debugIds:l})))),r,l,e),exports.LinkedRowsView=e=>Le(e,se,e.firstRowId),exports.LocalRowsView=e=>Le(e,ee,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:o})=>{var r;return fe(null!=(r=Y(e,s))?r:t,void 0,o,e)},exports.Provider=({store:s,storesById:t,metrics:o,metricsById:r,indexes:l,indexesById:u,relationships:d,relationshipsById:n,queries:i,queriesById:a,checkpoints:p,checkpointsById:c,children:I})=>{const x=e.useContext(h);return ve(h.Provider,{value:ge((()=>[null!=s?s:x[0],Re(Re({},x[1]),t),null!=o?o:x[2],Re(Re({},x[3]),r),null!=l?l:x[4],Re(Re({},x[5]),u),null!=d?d:x[6],Re(Re({},x[7]),n),null!=i?i:x[8],Re(Re({},x[9]),a),null!=p?p:x[10],Re(Re({},x[11]),c)]),[s,t,o,r,l,u,d,n,i,a,p,c,x])},I)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Pe,getRowComponentProps:r,debugIds:l})=>{const[u,d]=ye(t),n=null==u?void 0:u.getRemoteTableId(e),i=_(e,s,u);return fe(R(n)||R(i)?null:ve(o,Ce(Re({},Se(r,i)),{key:i,tableId:n,rowId:i,store:d,debugIds:l})),void 0,l,s)},exports.ResultCellView=Me,exports.ResultRowView=De,exports.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=ke(s,["cellId","descending","offset","limit"]);return he(u,oe(u.queryId,t,o,r,l,u.queries))},exports.ResultTableView=e=>he(e,te(e.queryId,e.queries)),exports.RowView=Pe,exports.SliceView=Be,exports.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=ke(s,["cellId","descending","offset","limit"]);return me(u,J(u.tableId,t,o,r,l,u.store))},exports.TableView=qe,exports.TablesView=({store:e,tableComponent:s=qe,getTableComponentProps:t,separator:o,debugIds:r})=>fe(b(z(e),(o=>ve(s,Ce(Re({},Se(t,o)),{key:o,tableId:o,store:e,debugIds:r})))),o),exports.ValueView=Oe,exports.ValuesView=({store:e,valueComponent:s=Oe,getValueComponentProps:t,separator:o,debugIds:r})=>fe(b(W(e),(o=>ve(s,Ce(Re({},Se(t,o)),{key:o,valueId:o,store:e,debugIds:r})))),o),exports.tableView=me,exports.useAddRowCallback=(e,s,t=[],o,r=v,l=[],u=!0)=>{const d=V(o);return O((t=>C(d,(o=>C(s(t,o),(s=>r(o.addRow(e,s,u),o,s)))))),[d,e,...t,...l,u])},exports.useCell=N,exports.useCellIds=K,exports.useCellIdsListener=(e,s,t,o,r,l)=>F(c,V(l),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,l,u)=>F(p,V(u),o,r,[e,s,t],l),exports.useCheckpoint=de,exports.useCheckpointIds=ue,exports.useCheckpointIdsListener=(e,s,t)=>F("CheckpointIds",q(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>F("Checkpoint",q(o),s,t,[e]),exports.useCheckpoints=e=>y(e,10),exports.useCreateCheckpoints=(e,s,t)=>A(e,s,t),exports.useCreateIndexes=(e,s,t)=>A(e,s,t),exports.useCreateMetrics=(e,s,t)=>A(e,s,t),exports.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,l]=j(),u=M((()=>s(e)),[e,...t]);return B((()=>{var e;return e=function*(){yield null==o?void 0:o(u),l(1)},new Promise(((s,t)=>{var o=s=>{try{l(e.next(s))}catch(e){t(e)}},r=s=>{try{l(e.throw(s))}catch(e){t(e)}},l=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,r);l((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...r]),u},exports.useCreateQueries=(e,s,t)=>A(e,s,t),exports.useCreateRelationships=(e,s,t)=>A(e,s,t),exports.useCreateStore=(e,s=[])=>M(e,s),exports.useDelCellCallback=(e,s,t,o,r,l,u)=>Q(r,p,l,u,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>Q(t,n,o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>Q(s,l,t,o,e),exports.useDelTablesCallback=(e,s,t)=>Q(e,u,s,t),exports.useDelValueCallback=(e,s,t,o)=>Q(s,I,t,o,e),exports.useDelValuesCallback=(e,s,t)=>Q(e,x,s,t),exports.useGoBackwardCallback=ne,exports.useGoForwardCallback=ie,exports.useGoToCallback=(e,s=[],t,o=v,r=[])=>{const l=q(t);return O((s=>C(l,(t=>C(e(s),(e=>o(t.goTo(e),e)))))),[l,...s,...r])},exports.useIndexes=e=>y(e,4),exports.useLinkedRowIds=se,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>F("LinkedRowIds",T(r),t,o,[e,s]),exports.useLocalRowIds=ee,exports.useLocalRowIdsListener=(e,s,t,o,r)=>F("LocalRowIds",T(r),t,o,[e,s]),exports.useMetric=Y,exports.useMetricListener=(e,s,t,o)=>F("Metric",S(o),s,t,[e]),exports.useMetrics=e=>y(e,2),exports.useQueries=e=>y(e,8),exports.useRedoInformation=e=>{var s;const o=q(e),[,,[r]]=ue(o);return[!R(r),ie(o),r,null!=(s=C(r,(e=>null==o?void 0:o.getCheckpoint(e))))?s:t]},exports.useRelationships=e=>y(e,6),exports.useRemoteRowId=_,exports.useRemoteRowIdListener=(e,s,t,o,r)=>F("RemoteRowId",T(r),t,o,[e,s]),exports.useResultCell=le,exports.useResultCellIds=re,exports.useResultCellIdsListener=(e,s,t,o,r)=>F("ResultCellIds",P(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,l)=>F("ResultCell",P(l),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>E("ResultRow",P(t),{},[e,s]),exports.useResultRowIds=te,exports.useResultRowIdsListener=(e,s,t,o)=>F("ResultRowIds",P(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>F("ResultRow",P(r),t,o,[e,s]),exports.useResultSortedRowIds=oe,exports.useResultSortedRowIdsListener=(e,s,t,o,r,l,u,d)=>F("ResultSortedRowIds",P(d),l,u,[e,s,t,o,r]),exports.useResultTable=(e,s)=>E("ResultTable",P(s),{},[e]),exports.useResultTableListener=(e,s,t,o)=>F("ResultTable",P(o),s,t,[e]),exports.useRow=(e,s,t)=>E(n,V(t),{},[e,s]),exports.useRowIds=H,exports.useRowIdsListener=(e,s,t,o,r)=>F(i,V(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,l)=>F(n,V(l),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,l,u,d)=>G(l,p,o,r,u,d,e,s,t),exports.useSetCheckpointCallback=(e=v,s=[],t,o=v,r=[])=>{const l=q(t);return O((s=>C(l,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[l,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,l,u)=>G(r,"PartialRow",t,o,l,u,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>G(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,l,u)=>G(r,n,t,o,l,u,e,s),exports.useSetTableCallback=(e,s,t,o,r,u)=>G(o,l,s,t,r,u,e),exports.useSetTablesCallback=(e,s,t,o,r)=>G(t,u,e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,l)=>G(o,I,s,t,r,l,e),exports.useSetValuesCallback=(e,s,t,o,r)=>G(t,x,e,s,o,r),exports.useSliceIds=Z,exports.useSliceIdsListener=(e,s,t,o)=>F("SliceIds",f(o),s,t,[e]),exports.useSliceRowIds=$,exports.useSliceRowIdsListener=(e,s,t,o,r)=>F("SliceRowIds",f(r),t,o,[e,s]),exports.useSortedRowIds=J,exports.useSortedRowIdsListener=(e,s,t,o,r,l,u,d,n)=>F(a,V(n),l,u,[e,s,t,o,r],d),exports.useStore=e=>y(e,0),exports.useTable=(e,s)=>E(l,V(s),{},[e]),exports.useTableCellIds=(e,s)=>E(l+c,V(s),[],[e]),exports.useTableCellIdsListener=(e,s,t,o,r)=>F(l+c,V(r),s,t,[e],o),exports.useTableIds=z,exports.useTableIdsListener=(e,s,t,o)=>F(d,V(o),e,s,[],t),exports.useTableListener=(e,s,t,o,r)=>F(l,V(r),s,t,[e],o),exports.useTables=e=>E(u,V(e),{}),exports.useTablesListener=(e,s,t,o)=>F(u,V(o),e,s,[],t),exports.useUndoInformation=e=>{var s;const o=q(e),[r,l]=ue(o);return[(u=r,!(0==(e=>e.length)(u))),ne(o),l,null!=(s=C(l,(e=>null==o?void 0:o.getCheckpoint(e))))?s:t];var u},exports.useValue=X,exports.useValueIds=W,exports.useValueIdsListener=(e,s,t,o)=>F(w,V(o),e,s,[],t),exports.useValueListener=(e,s,t,o,r)=>F(I,V(r),s,t,[e],o),exports.useValues=e=>E(x,V(e),{}),exports.useValuesListener=(e,s,t,o)=>F(x,V(o),e,s,[],t);
1
+ "use strict";var e=require("react");const s=e=>typeof e,t="",o=s(t),r="Ids",l="Table",u=l+"s",d=l+r,n="Row",i=n+r,a="Sorted"+n+r,p="Cell",c=p+r,I="Value",x=I+"s",w=I+r,C=(e,s)=>e.map(s),b=e=>null==e,R=(e,s,t)=>b(e)?null==t?void 0:t():s(e),k=e=>s(e)==o,v=()=>{},{createContext:g,useContext:m}=e,h=g([]),y=(e,s)=>{const t=m(h);return b(e)?t[s]:k(e)?((e,s)=>R(e,(e=>e[s])))(t[s+1],e):e},L=(e,s)=>{const t=y(e,s);return b(e)||k(e)?t:e},V=(e,...s)=>b(e)?{}:e(...s),S=e=>L(e,0),f=e=>L(e,2),T=e=>L(e,4),P=e=>L(e,6),q=e=>L(e,8),O=e=>L(e,10),{useCallback:B,useEffect:M,useMemo:D,useRef:j,useState:A}=e,E=(e,s,t=[])=>{const o=D((()=>s(e)),[e,...t]);return M((()=>()=>o.destroy()),[o]),o},F=(e,s,t,o=[],r)=>{const[,l]=A(),u=B((()=>{var r,l;return null!=(l=null==(r=null==s?void 0:s["get"+e])?void 0:r.call(s,...o))?l:t}),[s,...o]),[d]=A(u),n=j(d);return D((()=>n.current=u()),[u]),G(e,s,((...e)=>{n.current=b(r)?u():e[r],l([])}),[],o),n.current},G=(e,s,t,o=[],r=[],...l)=>M((()=>{var o;const u=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...r,t,...l);return()=>null==s?void 0:s.delListener(u)}),[s,...r,...o,...l]),Q=(e,s,t,o=[],r=v,l=[],...u)=>{const d=S(e);return B((e=>R(d,(o=>R(t(e,o),(e=>r(o["set"+s](...u,e),e)))))),[d,s,...o,...l,...u])},U=(e,s,t=v,o=[],...r)=>{const l=S(e);return B((()=>t(null==l?void 0:l["del"+s](...r))),[l,s,...o,...r])},z=(e,s,t)=>{const o=O(e);return B((()=>null==o?void 0:o[s](t)),[o,s,t])},H=e=>F(d,S(e),[],[]),J=(e,s)=>F(i,S(s),[],[e]),K=(e,s,t,o=0,r,l)=>F(a,S(l),[],[e,s,t,o,r],6),N=(e,s,t)=>F(c,S(t),[],[e,s]),W=(e,s,t,o)=>F(p,S(o),void 0,[e,s,t],4),X=e=>F(w,S(e),[],[]),Y=(e,s)=>F(I,S(s),void 0,[e]),Z=(e,s)=>F("Metric",f(s),void 0,[e]),$=(e,s)=>F("SliceIds",T(s),[],[e]),_=(e,s,t)=>F("SliceRowIds",T(t),[],[e,s]),ee=(e,s,t)=>F("RemoteRowId",P(t),void 0,[e,s]),se=(e,s,t)=>F("LocalRowIds",P(t),[],[e,s]),te=(e,s,t)=>F("LinkedRowIds",P(t),[],[e,s]),oe=(e,s)=>F("ResultRowIds",q(s),[],[e]),re=(e,s,t,o=0,r,l)=>F("ResultSortedRowIds",q(l),[],[e,s,t,o,r],6),le=(e,s,t)=>F("ResultCellIds",q(t),[],[e,s]),ue=(e,s,t,o)=>F("ResultCell",q(o),void 0,[e,s,t]),de=e=>F("CheckpointIds",O(e),[[],void 0,[]]),ne=(e,s)=>F("Checkpoint",O(s),void 0,[e]),ie=e=>z(e,"goBackward"),ae=e=>z(e,"goForward");var pe=Object.defineProperty,ce=Object.defineProperties,Ie=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,we=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,be=(e,s,t)=>s in e?pe(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,Re=(e,s)=>{for(var t in s||(s={}))we.call(s,t)&&be(e,t,s[t]);if(xe)for(var t of xe(s))Ce.call(s,t)&&be(e,t,s[t]);return e},ke=(e,s)=>ce(e,Ie(s)),ve=(e,s)=>{var t={};for(var o in e)we.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&xe)for(var o of xe(e))s.indexOf(o)<0&&Ce.call(e,o)&&(t[o]=e[o]);return t};const{createElement:ge,useMemo:me}=e,he=({tableId:e,store:s,rowComponent:t=Pe,getRowComponentProps:o,customCellIds:r,separator:l,debugIds:u},d)=>fe(C(d,(l=>ge(t,ke(Re({},V(o,l)),{key:l,tableId:e,rowId:l,customCellIds:r,store:s,debugIds:u})))),l,u,e),ye=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:o,separator:r,debugIds:l},u)=>fe(C(u,(r=>ge(t,ke(Re({},V(o,r)),{key:r,queryId:e,rowId:r,queries:s,debugIds:l})))),r,l,e),Le=e=>{const s=P(e);return[s,null==s?void 0:s.getStore()]},Ve=({relationshipId:e,relationships:s,rowComponent:t=Pe,getRowComponentProps:o,separator:r,debugIds:l},u,d)=>{const[n,i]=Le(s),a=null==n?void 0:n.getLocalTableId(e),p=u(e,d,n);return fe(C(p,(e=>ge(t,ke(Re({},V(o,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:l})))),r,l,d)},Se=e=>({checkpoints:s,checkpointComponent:t=je,getCheckpointComponentProps:o,separator:r,debugIds:l})=>{const u=O(s);return fe(C(e(de(u)),(e=>ge(t,ke(Re({},V(o,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:l})))),r)},fe=(e,s,t,o)=>{const r=b(s)||!Array.isArray(e)?e:C(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},Te=({tableId:e,rowId:s,cellId:o,store:r,debugIds:l})=>{var u;return fe(t+(null!=(u=W(e,s,o,r))?u:t),void 0,l,o)},Pe=({tableId:e,rowId:s,store:t,cellComponent:o=Te,getCellComponentProps:r,customCellIds:l,separator:u,debugIds:d})=>fe(C(((e,s,t,o)=>{const r=N(s,t,o);return null!=e?e:r})(l,e,s,t),(l=>ge(o,ke(Re({},V(r,l)),{key:l,tableId:e,rowId:s,cellId:l,store:t,debugIds:d})))),u,d,s),qe=e=>he(e,J(e.tableId,e.store)),Oe=({valueId:e,store:s,debugIds:o})=>{var r;return fe(t+(null!=(r=Y(e,s))?r:t),void 0,o,e)},Be=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Pe,getRowComponentProps:r,separator:l,debugIds:u})=>{const d=T(t),n=null==d?void 0:d.getStore(),i=null==d?void 0:d.getTableId(e),a=_(e,s,d);return fe(C(a,(e=>ge(o,ke(Re({},V(r,e)),{key:e,tableId:i,rowId:e,store:n,debugIds:u})))),l,u,s)},Me=({queryId:e,rowId:s,cellId:o,queries:r,debugIds:l})=>{var u;return fe(t+(null!=(u=ue(e,s,o,r))?u:t),void 0,l,o)},De=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Me,getResultCellComponentProps:r,separator:l,debugIds:u})=>fe(C(le(e,s,t),(l=>ge(o,ke(Re({},V(r,l)),{key:l,queryId:e,rowId:s,cellId:l,queries:t,debugIds:u})))),l,u,s),je=({checkpoints:e,checkpointId:s,debugIds:o})=>{var r;return fe(null!=(r=ne(s,e))?r:t,void 0,o,s)},Ae=Se((e=>e[0])),Ee=Se((e=>b(e[1])?[]:[e[1]])),Fe=Se((e=>e[2]));exports.BackwardCheckpointsView=Ae,exports.CellView=Te,exports.CheckpointView=je,exports.CurrentCheckpointView=Ee,exports.ForwardCheckpointsView=Fe,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=Be,getSliceComponentProps:o,separator:r,debugIds:l})=>fe(C($(e,s),(r=>ge(t,ke(Re({},V(o,r)),{key:r,indexId:e,sliceId:r,indexes:s,debugIds:l})))),r,l,e),exports.LinkedRowsView=e=>Ve(e,te,e.firstRowId),exports.LocalRowsView=e=>Ve(e,se,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:o})=>{var r;return fe(null!=(r=Z(e,s))?r:t,void 0,o,e)},exports.Provider=({store:s,storesById:t,metrics:o,metricsById:r,indexes:l,indexesById:u,relationships:d,relationshipsById:n,queries:i,queriesById:a,checkpoints:p,checkpointsById:c,children:I})=>{const x=e.useContext(h);return ge(h.Provider,{value:me((()=>[null!=s?s:x[0],Re(Re({},x[1]),t),null!=o?o:x[2],Re(Re({},x[3]),r),null!=l?l:x[4],Re(Re({},x[5]),u),null!=d?d:x[6],Re(Re({},x[7]),n),null!=i?i:x[8],Re(Re({},x[9]),a),null!=p?p:x[10],Re(Re({},x[11]),c)]),[s,t,o,r,l,u,d,n,i,a,p,c,x])},I)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Pe,getRowComponentProps:r,debugIds:l})=>{const[u,d]=Le(t),n=null==u?void 0:u.getRemoteTableId(e),i=ee(e,s,u);return fe(b(n)||b(i)?null:ge(o,ke(Re({},V(r,i)),{key:i,tableId:n,rowId:i,store:d,debugIds:l})),void 0,l,s)},exports.ResultCellView=Me,exports.ResultRowView=De,exports.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=ve(s,["cellId","descending","offset","limit"]);return ye(u,re(u.queryId,t,o,r,l,u.queries))},exports.ResultTableView=e=>ye(e,oe(e.queryId,e.queries)),exports.RowView=Pe,exports.SliceView=Be,exports.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=ve(s,["cellId","descending","offset","limit"]);return he(u,K(u.tableId,t,o,r,l,u.store))},exports.TableView=qe,exports.TablesView=({store:e,tableComponent:s=qe,getTableComponentProps:t,separator:o,debugIds:r})=>fe(C(H(e),(o=>ge(s,ke(Re({},V(t,o)),{key:o,tableId:o,store:e,debugIds:r})))),o),exports.ValueView=Oe,exports.ValuesView=({store:e,valueComponent:s=Oe,getValueComponentProps:t,separator:o,debugIds:r})=>fe(C(X(e),(o=>ge(s,ke(Re({},V(t,o)),{key:o,valueId:o,store:e,debugIds:r})))),o),exports.useAddRowCallback=(e,s,t=[],o,r=v,l=[],u=!0)=>{const d=S(o);return B((t=>R(d,(o=>R(s(t,o),(s=>r(o.addRow(e,s,u),o,s)))))),[d,e,...t,...l,u])},exports.useCell=W,exports.useCellIds=N,exports.useCellIdsListener=(e,s,t,o,r,l)=>G(c,S(l),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,l,u)=>G(p,S(u),o,r,[e,s,t],l),exports.useCheckpoint=ne,exports.useCheckpointIds=de,exports.useCheckpointIdsListener=(e,s,t)=>G("CheckpointIds",O(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>G("Checkpoint",O(o),s,t,[e]),exports.useCheckpoints=e=>y(e,10),exports.useCreateCheckpoints=(e,s,t)=>E(e,s,t),exports.useCreateIndexes=(e,s,t)=>E(e,s,t),exports.useCreateMetrics=(e,s,t)=>E(e,s,t),exports.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,l]=A(),u=D((()=>s(e)),[e,...t]);return M((()=>{var e;return e=function*(){yield null==o?void 0:o(u),l(1)},new Promise(((s,t)=>{var o=s=>{try{l(e.next(s))}catch(e){t(e)}},r=s=>{try{l(e.throw(s))}catch(e){t(e)}},l=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,r);l((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...r]),u},exports.useCreateQueries=(e,s,t)=>E(e,s,t),exports.useCreateRelationships=(e,s,t)=>E(e,s,t),exports.useCreateStore=(e,s=[])=>D(e,s),exports.useDelCellCallback=(e,s,t,o,r,l,u)=>U(r,p,l,u,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>U(t,n,o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>U(s,l,t,o,e),exports.useDelTablesCallback=(e,s,t)=>U(e,u,s,t),exports.useDelValueCallback=(e,s,t,o)=>U(s,I,t,o,e),exports.useDelValuesCallback=(e,s,t)=>U(e,x,s,t),exports.useGoBackwardCallback=ie,exports.useGoForwardCallback=ae,exports.useGoToCallback=(e,s=[],t,o=v,r=[])=>{const l=O(t);return B((s=>R(l,(t=>R(e(s),(e=>o(t.goTo(e),e)))))),[l,...s,...r])},exports.useIndexes=e=>y(e,4),exports.useLinkedRowIds=te,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>G("LinkedRowIds",P(r),t,o,[e,s]),exports.useLocalRowIds=se,exports.useLocalRowIdsListener=(e,s,t,o,r)=>G("LocalRowIds",P(r),t,o,[e,s]),exports.useMetric=Z,exports.useMetricListener=(e,s,t,o)=>G("Metric",f(o),s,t,[e]),exports.useMetrics=e=>y(e,2),exports.useQueries=e=>y(e,8),exports.useRedoInformation=e=>{var s;const o=O(e),[,,[r]]=de(o);return[!b(r),ae(o),r,null!=(s=R(r,(e=>null==o?void 0:o.getCheckpoint(e))))?s:t]},exports.useRelationships=e=>y(e,6),exports.useRemoteRowId=ee,exports.useRemoteRowIdListener=(e,s,t,o,r)=>G("RemoteRowId",P(r),t,o,[e,s]),exports.useResultCell=ue,exports.useResultCellIds=le,exports.useResultCellIdsListener=(e,s,t,o,r)=>G("ResultCellIds",q(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,l)=>G("ResultCell",q(l),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>F("ResultRow",q(t),{},[e,s]),exports.useResultRowIds=oe,exports.useResultRowIdsListener=(e,s,t,o)=>G("ResultRowIds",q(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>G("ResultRow",q(r),t,o,[e,s]),exports.useResultSortedRowIds=re,exports.useResultSortedRowIdsListener=(e,s,t,o,r,l,u,d)=>G("ResultSortedRowIds",q(d),l,u,[e,s,t,o,r]),exports.useResultTable=(e,s)=>F("ResultTable",q(s),{},[e]),exports.useResultTableListener=(e,s,t,o)=>G("ResultTable",q(o),s,t,[e]),exports.useRow=(e,s,t)=>F(n,S(t),{},[e,s]),exports.useRowIds=J,exports.useRowIdsListener=(e,s,t,o,r)=>G(i,S(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,l)=>G(n,S(l),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,l,u,d)=>Q(l,p,o,r,u,d,e,s,t),exports.useSetCheckpointCallback=(e=v,s=[],t,o=v,r=[])=>{const l=O(t);return B((s=>R(l,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[l,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,l,u)=>Q(r,"PartialRow",t,o,l,u,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>Q(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,l,u)=>Q(r,n,t,o,l,u,e,s),exports.useSetTableCallback=(e,s,t,o,r,u)=>Q(o,l,s,t,r,u,e),exports.useSetTablesCallback=(e,s,t,o,r)=>Q(t,u,e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,l)=>Q(o,I,s,t,r,l,e),exports.useSetValuesCallback=(e,s,t,o,r)=>Q(t,x,e,s,o,r),exports.useSliceIds=$,exports.useSliceIdsListener=(e,s,t,o)=>G("SliceIds",T(o),s,t,[e]),exports.useSliceRowIds=_,exports.useSliceRowIdsListener=(e,s,t,o,r)=>G("SliceRowIds",T(r),t,o,[e,s]),exports.useSortedRowIds=K,exports.useSortedRowIdsListener=(e,s,t,o,r,l,u,d,n)=>G(a,S(n),l,u,[e,s,t,o,r],d),exports.useStore=e=>y(e,0),exports.useTable=(e,s)=>F(l,S(s),{},[e]),exports.useTableCellIds=(e,s)=>F(l+c,S(s),[],[e]),exports.useTableCellIdsListener=(e,s,t,o,r)=>G(l+c,S(r),s,t,[e],o),exports.useTableIds=H,exports.useTableIdsListener=(e,s,t,o)=>G(d,S(o),e,s,[],t),exports.useTableListener=(e,s,t,o,r)=>G(l,S(r),s,t,[e],o),exports.useTables=e=>F(u,S(e),{}),exports.useTablesListener=(e,s,t,o)=>G(u,S(o),e,s,[],t),exports.useUndoInformation=e=>{var s;const o=O(e),[r,l]=de(o);return[(u=r,!(0==(e=>e.length)(u))),ie(o),l,null!=(s=R(l,(e=>null==o?void 0:o.getCheckpoint(e))))?s:t];var u},exports.useValue=Y,exports.useValueIds=X,exports.useValueIdsListener=(e,s,t,o)=>G(w,S(o),e,s,[],t),exports.useValueListener=(e,s,t,o,r)=>G(I,S(r),s,t,[e],o),exports.useValues=e=>F(x,S(e),{}),exports.useValuesListener=(e,s,t,o)=>G(x,S(o),e,s,[],t);
Binary file
@@ -1827,6 +1827,7 @@ const getStoreUiReactApi = (
1827
1827
  PARAMETER + 'ized' + CALLBACK,
1828
1828
  );
1829
1829
  addImport(0, tinyBaseUiReact, 'ComponentReturnType');
1830
+ addImport(1, tinyBaseUiReact, 'useCellIds');
1830
1831
  addImport(null, tinyBaseUiReact, 'ExtraProps');
1831
1832
  addImport(0, moduleDefinition, storeType);
1832
1833
  const storeOrStoreIdType = addType(
@@ -1903,6 +1904,19 @@ const getStoreUiReactApi = (
1903
1904
  `return encloseWithId ? [id, ':{', separated, '}'] : separated;`,
1904
1905
  ],
1905
1906
  );
1907
+ const useCustomOrDefaultCellIds = addInternalFunction(
1908
+ 'useCustomOrDefaultCellIds',
1909
+ getParameterList(
1910
+ 'customCellIds: Ids | undefined',
1911
+ 'tableId: Id',
1912
+ 'rowId: Id',
1913
+ `${storeOrStoreId}?: ${storeOrStoreIdType} | undefined`,
1914
+ ),
1915
+ [
1916
+ `const defaultCellIds = ${useHook}(${storeOrStoreId}, useCellIds, [tableId, rowId]);`,
1917
+ 'return customCellIds ?? defaultCellIds;',
1918
+ ],
1919
+ );
1906
1920
  const NullComponent = addConstant('NullComponent', `() => null`);
1907
1921
  if (!objIsEmpty(tablesSchema)) {
1908
1922
  const [
@@ -1942,7 +1956,7 @@ const getStoreUiReactApi = (
1942
1956
  addImport(null, TINYBASE, IDS, 'IdOrNull');
1943
1957
  const tableView = addInternalFunction(
1944
1958
  'tableView',
1945
- `{${storeInstance}, rowComponent, getRowComponentProps` +
1959
+ `{${storeInstance}, rowComponent, getRowComponentProps, customCellIds` +
1946
1960
  SEPARATOR_AND_DEBUG_IDS +
1947
1961
  '}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>',
1948
1962
  [
@@ -1953,6 +1967,7 @@ const getStoreUiReactApi = (
1953
1967
  'key={rowId}',
1954
1968
  'tableId={tableId}',
1955
1969
  ROW_ID_PROP,
1970
+ 'customCellIds={customCellIds}',
1956
1971
  storeProp,
1957
1972
  DEBUG_IDS_PROP,
1958
1973
  '/>',
@@ -2056,6 +2071,7 @@ const getStoreUiReactApi = (
2056
2071
  cellIdType +
2057
2072
  `<TId>]?: ComponentType<${cellPropsType}<TId, CId>>;}`,
2058
2073
  `getCellComponentProps?: (cellId: ${cellIdType}<TId>) => ExtraProps`,
2074
+ `customCellIds?: ${cellIdType}<TId>[]`,
2059
2075
  SEPARATOR_PROP_TYPE,
2060
2076
  DEBUG_IDS_PROP_TYPE,
2061
2077
  ),
@@ -2069,6 +2085,7 @@ const getStoreUiReactApi = (
2069
2085
  storeInstance + OPTIONAL_COLON + storeType,
2070
2086
  `rowComponent?: ComponentType<${rowPropsType}<TId>>`,
2071
2087
  `getRowComponentProps?: (rowId: Id) => ExtraProps`,
2088
+ `customCellIds?: CellId<TId>[]`,
2072
2089
  SEPARATOR_PROP_TYPE,
2073
2090
  DEBUG_IDS_PROP_TYPE,
2074
2091
  ),
@@ -2086,6 +2103,7 @@ const getStoreUiReactApi = (
2086
2103
  storeInstance + OPTIONAL_COLON + storeType,
2087
2104
  `rowComponent?: ComponentType<${rowPropsType}<TId>>`,
2088
2105
  `getRowComponentProps?: (rowId: Id) => ExtraProps`,
2106
+ `customCellIds?: CellId<TId>[]`,
2089
2107
  SEPARATOR_PROP_TYPE,
2090
2108
  DEBUG_IDS_PROP_TYPE,
2091
2109
  ),
@@ -2197,7 +2215,7 @@ const getStoreUiReactApi = (
2197
2215
  TYPED_ROW_ID,
2198
2216
  getParameterList(TABLE_ID, ROW_ID),
2199
2217
  );
2200
- const useCellIds = addProxyHook(
2218
+ addProxyHook(
2201
2219
  tableName + CELL_IDS,
2202
2220
  CELL_IDS,
2203
2221
  cellIdType2 + SQUARE_BRACKETS,
@@ -2308,11 +2326,14 @@ const getStoreUiReactApi = (
2308
2326
  tableName + ROW + VIEW,
2309
2327
  '{rowId, ' +
2310
2328
  storeInstance +
2311
- ', cellComponents, getCellComponentProps' +
2329
+ ', cellComponents, getCellComponentProps, customCellIds' +
2312
2330
  SEPARATOR_AND_DEBUG_IDS +
2313
2331
  `}: ${rowPropsType}<'${tableId}'>`,
2314
2332
  [
2315
- wrap + `(${useCellIds}(rowId, ${storeInstance}).map((cellId) => {`,
2333
+ wrap +
2334
+ `(${useCustomOrDefaultCellIds}(customCellIds, ` +
2335
+ TABLE_ID +
2336
+ `, rowId, ${storeInstance}).map((cellId: ${cellIdType2}) => {`,
2316
2337
  'const Cell = (cellComponents?.[cellId] ?? ' +
2317
2338
  getDefaultCellComponent +
2318
2339
  `(${TABLE_ID}, cellId)) as React.ComponentType<CellProps<typeof ` +