tinybase 4.2.1 → 4.2.3

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.
@@ -84,6 +84,7 @@ import {
84
84
  TableListener,
85
85
  Tables,
86
86
  TablesListener,
87
+ TransactionListener,
87
88
  Value,
88
89
  ValueIdsListener,
89
90
  ValueListener,
@@ -4286,6 +4287,210 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
4286
4287
  storeOrStoreId?: StoreOrStoreId<Schemas>,
4287
4288
  ) => void;
4288
4289
 
4290
+ /**
4291
+ * The useStartTransactionListener hook registers a listener function with the
4292
+ * Store that will be called at the start of a transaction.
4293
+ *
4294
+ * This has schema-based typing. The following is a simplified representation:
4295
+ *
4296
+ * ```ts override
4297
+ * useStartTransactionListener(
4298
+ * listener: TransactionListener,
4299
+ * listenerDeps?: React.DependencyList,
4300
+ * storeOrStoreId?: StoreOrStoreId,
4301
+ * ): void;
4302
+ * ```
4303
+ *
4304
+ * Unlike the addStartTransactionListener method, which returns a listener Id
4305
+ * and requires you to remove it manually, the useStartTransactionListener hook
4306
+ * manages this lifecycle for you: when the listener changes (per its
4307
+ * `listenerDeps` dependencies) or the component unmounts, the listener on the
4308
+ * underlying Store will be deleted.
4309
+ * @param listener The function that will be called at the start of a
4310
+ * transaction.
4311
+ * @param listenerDeps An optional array of dependencies for the `listener`
4312
+ * function, which, if any change, result in the re-registration of the
4313
+ * listener. This parameter defaults to an empty array.
4314
+ * @param storeOrStoreId The Store to register the listener with: omit for the
4315
+ * default context Store, provide an Id for a named context Store, or provide an
4316
+ * explicit reference.
4317
+ * @example
4318
+ * This example uses the useStartTransactionListener hook to create a listener
4319
+ * that is scoped to a single component. When the component is unmounted, the
4320
+ * listener is removed from the Store.
4321
+ *
4322
+ * ```jsx
4323
+ * const App = ({store}) => (
4324
+ * <Provider store={store}>
4325
+ * <Pane />
4326
+ * </Provider>
4327
+ * );
4328
+ * const Pane = () => {
4329
+ * useStartTransactionListener(() => console.log('Start transaction'));
4330
+ * return <span>App</span>;
4331
+ * };
4332
+ *
4333
+ * const store = createStore();
4334
+ * const app = document.createElement('div');
4335
+ * const root = ReactDOMClient.createRoot(app);
4336
+ * root.render(<App store={store} />); // !act
4337
+ * console.log(store.getListenerStats().transaction);
4338
+ * // -> 1
4339
+ *
4340
+ * store.setValue('open', false); // !act
4341
+ * // -> 'Start transaction'
4342
+ *
4343
+ * root.unmount(); // !act
4344
+ * console.log(store.getListenerStats().transaction);
4345
+ * // -> 0
4346
+ * ```
4347
+ * @category Store hooks
4348
+ * @since v4.2.2
4349
+ */
4350
+ useStartTransactionListener: (
4351
+ listener: TransactionListener<Schemas>,
4352
+ listenerDeps?: React.DependencyList,
4353
+ storeOrStoreId?: StoreOrStoreId<Schemas>,
4354
+ ) => void;
4355
+
4356
+ /**
4357
+ * The useWillFinishTransactionListener hook registers a listener function with
4358
+ * a Store that will be called just before other non-mutating listeners are
4359
+ * called at the end of the transaction.
4360
+ *
4361
+ * This has schema-based typing. The following is a simplified representation:
4362
+ *
4363
+ * ```ts override
4364
+ * useWillFinishTransactionListener(
4365
+ * listener: TransactionListener,
4366
+ * listenerDeps?: React.DependencyList,
4367
+ * storeOrStoreId?: StoreOrStoreId,
4368
+ * ): void;
4369
+ * ```
4370
+ *
4371
+ * Unlike the addWillFinisTransactionListener method, which returns a listener
4372
+ * Id and requires you to remove it manually, the
4373
+ * useWillFinishTransactionListener hook manages this lifecycle for you: when
4374
+ * the listener changes (per its `listenerDeps` dependencies) or the component
4375
+ * unmounts, the listener on the underlying Store will be deleted.
4376
+ * @param listener The function that will be called before the end of a
4377
+ * transaction.
4378
+ * @param listenerDeps An optional array of dependencies for the `listener`
4379
+ * function, which, if any change, result in the re-registration of the
4380
+ * listener. This parameter defaults to an empty array.
4381
+ * @param storeOrStoreId The Store to register the listener with: omit for the
4382
+ * default context Store, provide an Id for a named context Store, or provide an
4383
+ * explicit reference.
4384
+ * @example
4385
+ * This example uses the useWillFinishTransactionListener hook to create a
4386
+ * listener that is scoped to a single component. When the component is
4387
+ * unmounted, the listener is removed from the Store.
4388
+ *
4389
+ * ```jsx
4390
+ * const App = ({store}) => (
4391
+ * <Provider store={store}>
4392
+ * <Pane />
4393
+ * </Provider>
4394
+ * );
4395
+ * const Pane = () => {
4396
+ * useWillFinishTransactionListener(
4397
+ * () => console.log('Will finish transaction'),
4398
+ * );
4399
+ * return <span>App</span>;
4400
+ * };
4401
+ *
4402
+ * const store = createStore();
4403
+ * const app = document.createElement('div');
4404
+ * const root = ReactDOMClient.createRoot(app);
4405
+ * root.render(<App store={store} />); // !act
4406
+ * console.log(store.getListenerStats().transaction);
4407
+ * // -> 1
4408
+ *
4409
+ * store.setValue('open', false); // !act
4410
+ * // -> 'Will finish transaction'
4411
+ *
4412
+ * root.unmount(); // !act
4413
+ * console.log(store.getListenerStats().transaction);
4414
+ * // -> 0
4415
+ * ```
4416
+ * @category Store hooks
4417
+ * @since v4.2.2
4418
+ */
4419
+ useWillFinishTransactionListener: (
4420
+ listener: TransactionListener<Schemas>,
4421
+ listenerDeps?: React.DependencyList,
4422
+ storeOrStoreId?: StoreOrStoreId<Schemas>,
4423
+ ) => void;
4424
+
4425
+ /**
4426
+ * The useDidFinishTransactionListener hook registers a listener function with a
4427
+ * Store that will be called just after other non-mutating listeners are called
4428
+ * at the end of the transaction.
4429
+ *
4430
+ * This has schema-based typing. The following is a simplified representation:
4431
+ *
4432
+ * ```ts override
4433
+ * useDidFinishTransactionListener(
4434
+ * listener: TransactionListener,
4435
+ * listenerDeps?: React.DependencyList,
4436
+ * storeOrStoreId?: StoreOrStoreId,
4437
+ * ): void;
4438
+ * ```
4439
+ *
4440
+ * Unlike the addDidFinishTransactionListener method, which returns a listener
4441
+ * Id and requires you to remove it manually, the
4442
+ * useDidFinishTransactionListener hook manages this lifecycle for you: when the
4443
+ * listener changes (per its `listenerDeps` dependencies) or the component
4444
+ * unmounts, the listener on the underlying Store will be deleted.
4445
+ * @param listener The function that will be called after the end of a
4446
+ * transaction.
4447
+ * @param listenerDeps An optional array of dependencies for the `listener`
4448
+ * function, which, if any change, result in the re-registration of the
4449
+ * listener. This parameter defaults to an empty array.
4450
+ * @param storeOrStoreId The Store to register the listener with: omit for the
4451
+ * default context Store, provide an Id for a named context Store, or provide an
4452
+ * explicit reference.
4453
+ * @example
4454
+ * This example uses the useDidFinishTransactionListener hook to create a
4455
+ * listener that is scoped to a single component. When the component is
4456
+ * unmounted, the listener is removed from the Store.
4457
+ *
4458
+ * ```jsx
4459
+ * const App = ({store}) => (
4460
+ * <Provider store={store}>
4461
+ * <Pane />
4462
+ * </Provider>
4463
+ * );
4464
+ * const Pane = () => {
4465
+ * useDidFinishTransactionListener(
4466
+ * () => console.log('Did finish transaction'),
4467
+ * );
4468
+ * return <span>App</span>;
4469
+ * };
4470
+ *
4471
+ * const store = createStore();
4472
+ * const app = document.createElement('div');
4473
+ * const root = ReactDOMClient.createRoot(app);
4474
+ * root.render(<App store={store} />); // !act
4475
+ * console.log(store.getListenerStats().transaction);
4476
+ * // -> 1
4477
+ *
4478
+ * store.setValue('open', false); // !act
4479
+ * // -> 'Did finish transaction'
4480
+ *
4481
+ * root.unmount(); // !act
4482
+ * console.log(store.getListenerStats().transaction);
4483
+ * // -> 0
4484
+ * ```
4485
+ * @category Store hooks
4486
+ * @since v4.2.2
4487
+ */
4488
+ useDidFinishTransactionListener: (
4489
+ listener: TransactionListener<Schemas>,
4490
+ listenerDeps?: React.DependencyList,
4491
+ storeOrStoreId?: StoreOrStoreId<Schemas>,
4492
+ ) => void;
4493
+
4289
4494
  /**
4290
4495
  * The useCreateMetrics hook is used to create a Metrics object within a React
4291
4496
  * application with convenient memoization.
package/lib/ui-react.js CHANGED
@@ -1 +1 @@
1
- import e,{useContext as t}from"react";const o=e=>typeof e,s="",r=o(s),d="Result",n="Ids",I="Table",u=I+"s",l=I+n,i="Row",c=i+"Count",a=i+n,p="Sorted"+i+n,g="Cell",b=g+n,C="Value",m=C+"s",k=C+n,y=e=>null==e,w=(e,t,o)=>y(e)?o?.():t(e),h=e=>o(e)==r,R=()=>{},v=(e,t)=>e.map(t),q=Object.keys,{createContext:P,useContext:f}=e,x=P([]),S=(e,t)=>{const o=f(x);return y(e)?o[t]:h(e)?((e,t)=>w(e,(e=>e[t])))(o[t+1]??{},e):e},L=(e,t)=>{const o=S(e,t);return y(e)||h(e)?o:e},B=e=>q(f(x)[e]??{}),T=e=>S(e,0),M=e=>L(e,0),E=e=>S(e,2),V=e=>L(e,2),A=e=>S(e,4),F=e=>L(e,4),j=e=>S(e,6),O=e=>L(e,6),Q=e=>S(e,8),z=e=>L(e,8),D=e=>S(e,10),G=e=>L(e,10),{useCallback:H,useEffect:J,useMemo:K,useRef:N,useState:U}=e,W=(e,t,o=[])=>{const s=K((()=>t(e)),[e,...o]);return J((()=>()=>s.destroy()),[s]),s},X=(e,t,o,s=[],r)=>{const[,d]=U(),n=H((()=>t?.["get"+e]?.(...s)??o),[t,...s]),[I]=U(n),u=N(I);return K((()=>u.current=n()),[n]),Y(e,t,((...e)=>{u.current=y(r)?n():e[r],d([])}),[],s),u.current},Y=(e,t,o,s=[],r=[],...d)=>J((()=>{const s=t?.["add"+e+"Listener"]?.(...r,o,...d);return()=>t?.delListener(s)}),[t,...r,...s,...d]),Z=(e,t,o,s=[],r=R,d=[],...n)=>{const I=M(e);return H((e=>w(I,(s=>w(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[I,t,...s,...d,...n])},$=(e,t,o=R,s=[],...r)=>{const d=M(e);return H((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},_=(e,t,o)=>{const s=G(e);return H((()=>s?.[t](o)),[s,t,o])},ee=(e,t=[])=>K(e,t),te=()=>B(1),oe=e=>X(u,M(e),{}),se=e=>X(l,M(e),[],[]),re=(e,t)=>X(I,M(t),{},[e]),de=(e,t)=>X(I+b,M(t),[],[e]),ne=(e,t)=>X(c,M(t),[],[e]),Ie=(e,t)=>X(a,M(t),[],[e]),ue=(e,t,o,s=0,r,d)=>X(p,M(d),[],[e,t,o,s,r],6),le=(e,t,o)=>X(i,M(o),{},[e,t]),ie=(e,t,o)=>X(b,M(o),[],[e,t]),ce=(e,t,o,s)=>X(g,M(s),void 0,[e,t,o],4),ae=e=>X(m,M(e),{}),pe=e=>X(k,M(e),[],[]),ge=(e,t)=>X(C,M(t),void 0,[e]),be=(e,t,o,s,r)=>Z(o,u,e,t,s,r),Ce=(e,t,o,s,r,d)=>Z(s,I,t,o,r,d,e),me=(e,t,o,s,r,d,n)=>Z(r,i,o,s,d,n,e,t),ke=(e,t,o=[],s,r=R,d=[],n=!0)=>{const I=M(s);return H((o=>w(I,(s=>w(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[I,e,...o,...d,n])},ye=(e,t,o,s,r,d,n)=>Z(r,"PartialRow",o,s,d,n,e,t),we=(e,t,o,s,r,d,n,I)=>Z(d,g,s,r,n,I,e,t,o),he=(e,t,o,s,r)=>Z(o,m,e,t,s,r),Re=(e,t,o,s,r)=>Z(o,"PartialValues",e,t,s,r),ve=(e,t,o,s,r,d)=>Z(s,C,t,o,r,d,e),qe=(e,t,o)=>$(e,u,t,o),Pe=(e,t,o,s)=>$(t,I,o,s,e),fe=(e,t,o,s,r)=>$(o,i,s,r,e,t),xe=(e,t,o,s,r,d,n)=>$(r,g,d,n,e,t,o,s),Se=(e,t,o)=>$(e,m,t,o),Le=(e,t,o,s)=>$(t,C,o,s,e),Be=(e,t,o,s)=>Y(u,M(s),e,t,[],o),Te=(e,t,o,s)=>Y(l,M(s),e,t,[],o),Me=(e,t,o,s,r)=>Y(I,M(r),t,o,[e],s),Ee=(e,t,o,s,r)=>Y(I+b,M(r),t,o,[e],s),Ve=(e,t,o,s,r)=>Y(c,M(r),t,o,[e],s),Ae=(e,t,o,s,r)=>Y(a,M(r),t,o,[e],s),Fe=(e,t,o,s,r,d,n,I,u)=>Y(p,M(u),d,n,[e,t,o,s,r],I),je=(e,t,o,s,r,d)=>Y(i,M(d),o,s,[e,t],r),Oe=(e,t,o,s,r,d)=>Y(b,M(d),o,s,[e,t],r),Qe=(e,t,o,s,r,d,n)=>Y(g,M(n),s,r,[e,t,o],d),ze=(e,t,o,s)=>Y(m,M(s),e,t,[],o),De=(e,t,o,s)=>Y(k,M(s),e,t,[],o),Ge=(e,t,o,s,r)=>Y(C,M(r),t,o,[e],s),He=(e,t,o)=>W(e,t,o),Je=()=>B(3),Ke=e=>X("MetricIds",V(e),[]),Ne=(e,t)=>X("Metric",V(t),void 0,[e]),Ue=(e,t,o,s)=>Y("Metric",V(s),t,o,[e]),We=(e,t,o)=>W(e,t,o),Xe=()=>B(5),Ye=(e,t)=>X("SliceIds",F(t),[],[e]),Ze=e=>X("IndexIds",F(e),[]),$e=(e,t,o)=>X("Slice"+a,F(o),[],[e,t]),_e=(e,t,o,s)=>Y("SliceIds",F(s),t,o,[e]),et=(e,t,o,s,r)=>Y("Slice"+a,F(r),o,s,[e,t]),tt=(e,t,o)=>W(e,t,o),ot=()=>B(7),st=e=>X("RelationshipIds",O(e),[]),rt=(e,t,o)=>X("RemoteRowId",O(o),void 0,[e,t]),dt=(e,t,o)=>X("Local"+a,O(o),[],[e,t]),nt=(e,t,o)=>X("Linked"+a,O(o),[],[e,t]),It=(e,t,o,s,r)=>Y("RemoteRowId",O(r),o,s,[e,t]),ut=(e,t,o,s,r)=>Y("Local"+a,O(r),o,s,[e,t]),lt=(e,t,o,s,r)=>Y("Linked"+a,O(r),o,s,[e,t]),it=(e,t,o)=>W(e,t,o),ct=()=>B(9),at=e=>X("QueryIds",z(e),[]),pt=(e,t)=>X(d+I,z(t),{},[e]),gt=(e,t)=>X(d+I+b,z(t),[],[e]),bt=(e,t)=>X(d+c,z(t),[],[e]),Ct=(e,t)=>X(d+a,z(t),[],[e]),mt=(e,t,o,s=0,r,n)=>X(d+p,z(n),[],[e,t,o,s,r],6),kt=(e,t,o)=>X(d+i,z(o),{},[e,t]),yt=(e,t,o)=>X(d+b,z(o),[],[e,t]),wt=(e,t,o,s)=>X(d+g,z(s),void 0,[e,t,o]),ht=(e,t,o,s)=>Y(d+I,z(s),t,o,[e]),Rt=(e,t,o,s)=>Y(d+I+b,z(s),t,o,[e]),vt=(e,t,o,s)=>Y(d+c,z(s),t,o,[e]),qt=(e,t,o,s)=>Y(d+a,z(s),t,o,[e]),Pt=(e,t,o,s,r,n,I,u)=>Y(d+p,z(u),n,I,[e,t,o,s,r]),ft=(e,t,o,s,r)=>Y(d+i,z(r),o,s,[e,t]),xt=(e,t,o,s,r)=>Y(d+b,z(r),o,s,[e,t]),St=(e,t,o,s,r,n)=>Y(d+g,z(n),s,r,[e,t,o]),Lt=(e,t,o)=>W(e,t,o),Bt=()=>B(11),Tt=e=>X("CheckpointIds",G(e),[[],void 0,[]]),Mt=(e,t)=>X("Checkpoint",G(t),void 0,[e]),Et=(e=R,t=[],o,s=R,r=[])=>{const d=G(o);return H((t=>w(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Vt=e=>_(e,"goBackward"),At=e=>_(e,"goForward"),Ft=(e,t=[],o,s=R,r=[])=>{const d=G(o);return H((t=>w(d,(o=>w(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},jt=e=>{const t=G(e),[o,r]=Tt(t);return[(d=o,!(0==(e=>e.length)(d))),Vt(t),r,w(r,(e=>t?.getCheckpoint(e)))??s];var d},Ot=e=>{const t=G(e),[,,[o]]=Tt(t);return[!y(o),At(t),o,w(o,(e=>t?.getCheckpoint(e)))??s]},Qt=(e,t,o)=>Y("CheckpointIds",G(o),e,t),zt=(e,t,o,s)=>Y("Checkpoint",G(s),t,o,[e]),Dt=(e,t,o=[],s,r=[])=>{const[,d]=U(),n=K((()=>t(e)),[e,...o]);return J((()=>((async()=>{await(s?.(n)),d(1)})(),()=>{n.destroy()})),[n,...r]),n},{PureComponent:Gt,Fragment:Ht,createElement:Jt,useCallback:Kt,useLayoutEffect:Nt,useRef:Ut,useState:Wt}=e,Xt=(e,...t)=>y(e)?{}:e(...t),Yt=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useMemo:Zt}=e,$t=({tableId:e,store:t,rowComponent:o=no,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},I)=>so(v(I,(d=>Jt(o,{...Xt(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),_t=({queryId:e,queries:t,resultRowComponent:o=yo,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>so(v(n,(r=>Jt(o,{...Xt(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),eo=({relationshipId:e,relationships:t,rowComponent:o=no,getRowComponentProps:s,separator:r,debugIds:d},n,I)=>{const[u,l,i]=Yt(O(t),e),c=n(e,I,u);return so(v(c,(e=>Jt(o,{...Xt(s,e),key:e,tableId:i,rowId:e,store:l,debugIds:d}))),r,d,I)},to=e=>({checkpoints:t,checkpointComponent:o=Ro,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=G(t);return so(v(e(Tt(n)),(e=>Jt(o,{...Xt(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},oo=({store:e,storesById:o,metrics:s,metricsById:r,indexes:d,indexesById:n,relationships:I,relationshipsById:u,queries:l,queriesById:i,checkpoints:c,checkpointsById:a,children:p})=>{const g=t(x);return Jt(x.Provider,{value:Zt((()=>[e??g[0],{...g[1],...o},s??g[2],{...g[3],...r},d??g[4],{...g[5],...n},I??g[6],{...g[7],...u},l??g[8],{...g[9],...i},c??g[10],{...g[11],...a}]),[e,o,s,r,d,n,I,u,l,i,c,a,g])},p)},so=(e,t,o,s)=>{const r=y(t)||!Array.isArray(e)?e:v(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},ro=({tableId:e,rowId:t,cellId:o,store:r,debugIds:d})=>so(s+(ce(e,t,o,r)??s),void 0,d,o),no=({tableId:e,rowId:t,store:o,cellComponent:s=ro,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:I})=>so(v(((e,t,o,s)=>{const r=ie(t,o,s);return e??r})(d,e,t,o),(d=>Jt(s,{...Xt(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:I}))),n,I,t),Io=e=>$t(e,Ie(e.tableId,e.store)),uo=({cellId:e,descending:t,offset:o,limit:s,...r})=>$t(r,ue(r.tableId,e,t,o,s,r.store)),lo=({store:e,tableComponent:t=Io,getTableComponentProps:o,separator:s,debugIds:r})=>so(v(se(e),(s=>Jt(t,{...Xt(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),io=({valueId:e,store:t,debugIds:o})=>so(s+(ge(e,t)??s),void 0,o,e),co=({store:e,valueComponent:t=io,getValueComponentProps:o,separator:s,debugIds:r})=>so(v(pe(e),(s=>Jt(t,{...Xt(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),ao=({metricId:e,metrics:t,debugIds:o})=>so(Ne(e,t)??s,void 0,o,e),po=({indexId:e,sliceId:t,indexes:o,rowComponent:s=no,getRowComponentProps:r,separator:d,debugIds:n})=>{const[I,u,l]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(F(o),e),i=$e(e,t,I);return so(v(i,(e=>Jt(s,{...Xt(r,e),key:e,tableId:l,rowId:e,store:u,debugIds:n}))),d,n,t)},go=({indexId:e,indexes:t,sliceComponent:o=po,getSliceComponentProps:s,separator:r,debugIds:d})=>so(v(Ye(e,t),(r=>Jt(o,{...Xt(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),bo=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=no,getRowComponentProps:r,debugIds:d})=>{const[n,I,,u]=Yt(O(o),e),l=rt(e,t,n);return so(y(u)||y(l)?null:Jt(s,{...Xt(r,l),key:l,tableId:u,rowId:l,store:I,debugIds:d}),void 0,d,t)},Co=e=>eo(e,dt,e.remoteRowId),mo=e=>eo(e,nt,e.firstRowId),ko=({queryId:e,rowId:t,cellId:o,queries:r,debugIds:d})=>so(s+(wt(e,t,o,r)??s),void 0,d,o),yo=({queryId:e,rowId:t,queries:o,resultCellComponent:s=ko,getResultCellComponentProps:r,separator:d,debugIds:n})=>so(v(yt(e,t,o),(d=>Jt(s,{...Xt(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),wo=e=>_t(e,Ct(e.queryId,e.queries)),ho=({cellId:e,descending:t,offset:o,limit:s,...r})=>_t(r,mt(r.queryId,e,t,o,s,r.queries)),Ro=({checkpoints:e,checkpointId:t,debugIds:o})=>so(Mt(t,e)??s,void 0,o,t),vo=to((e=>e[0])),qo=to((e=>y(e[1])?[]:[e[1]])),Po=to((e=>e[2]));export{vo as BackwardCheckpointsView,ro as CellView,Ro as CheckpointView,qo as CurrentCheckpointView,Po as ForwardCheckpointsView,go as IndexView,mo as LinkedRowsView,Co as LocalRowsView,ao as MetricView,oo as Provider,bo as RemoteRowView,ko as ResultCellView,yo as ResultRowView,ho as ResultSortedTableView,wo as ResultTableView,no as RowView,po as SliceView,uo as SortedTableView,Io as TableView,lo as TablesView,io as ValueView,co as ValuesView,ke as useAddRowCallback,ce as useCell,ie as useCellIds,Oe as useCellIdsListener,Qe as useCellListener,Mt as useCheckpoint,Tt as useCheckpointIds,Qt as useCheckpointIdsListener,zt as useCheckpointListener,D as useCheckpoints,Bt as useCheckpointsIds,G as useCheckpointsOrCheckpointsById,Lt as useCreateCheckpoints,We as useCreateIndexes,He as useCreateMetrics,Dt as useCreatePersister,it as useCreateQueries,tt as useCreateRelationships,ee as useCreateStore,xe as useDelCellCallback,fe as useDelRowCallback,Pe as useDelTableCallback,qe as useDelTablesCallback,Le as useDelValueCallback,Se as useDelValuesCallback,Vt as useGoBackwardCallback,At as useGoForwardCallback,Ft as useGoToCallback,Ze as useIndexIds,A as useIndexes,Xe as useIndexesIds,F as useIndexesOrIndexesById,nt as useLinkedRowIds,lt as useLinkedRowIdsListener,dt as useLocalRowIds,ut as useLocalRowIdsListener,Ne as useMetric,Ke as useMetricIds,Ue as useMetricListener,E as useMetrics,Je as useMetricsIds,V as useMetricsOrMetricsById,Q as useQueries,ct as useQueriesIds,z as useQueriesOrQueriesById,at as useQueryIds,Ot as useRedoInformation,st as useRelationshipIds,j as useRelationships,ot as useRelationshipsIds,O as useRelationshipsOrRelationshipsById,rt as useRemoteRowId,It as useRemoteRowIdListener,wt as useResultCell,yt as useResultCellIds,xt as useResultCellIdsListener,St as useResultCellListener,kt as useResultRow,bt as useResultRowCount,vt as useResultRowCountListener,Ct as useResultRowIds,qt as useResultRowIdsListener,ft as useResultRowListener,mt as useResultSortedRowIds,Pt as useResultSortedRowIdsListener,pt as useResultTable,gt as useResultTableCellIds,Rt as useResultTableCellIdsListener,ht as useResultTableListener,le as useRow,ne as useRowCount,Ve as useRowCountListener,Ie as useRowIds,Ae as useRowIdsListener,je as useRowListener,we as useSetCellCallback,Et as useSetCheckpointCallback,ye as useSetPartialRowCallback,Re as useSetPartialValuesCallback,me as useSetRowCallback,Ce as useSetTableCallback,be as useSetTablesCallback,ve as useSetValueCallback,he as useSetValuesCallback,Ye as useSliceIds,_e as useSliceIdsListener,$e as useSliceRowIds,et as useSliceRowIdsListener,ue as useSortedRowIds,Fe as useSortedRowIdsListener,T as useStore,te as useStoreIds,M as useStoreOrStoreById,re as useTable,de as useTableCellIds,Ee as useTableCellIdsListener,se as useTableIds,Te as useTableIdsListener,Me as useTableListener,oe as useTables,Be as useTablesListener,jt as useUndoInformation,ge as useValue,pe as useValueIds,De as useValueIdsListener,Ge as useValueListener,ae as useValues,ze as useValuesListener};
1
+ import e,{useContext as t}from"react";const o=e=>typeof e,s="",r=o(s),d="Listener",n="Result",I="Ids",i="Table",u=i+"s",l=i+I,c="Row",a=c+"Count",p=c+I,g="Sorted"+c+I,b="Cell",C=b+I,m="Value",k=m+"s",w=m+I,y=e=>null==e,h=(e,t,o)=>y(e)?o?.():t(e),R=e=>o(e)==r,v=()=>{},q=(e,t)=>e.map(t),P=Object.keys,{createContext:f,useContext:x}=e,S=f([]),L=(e,t)=>{const o=x(S);return y(e)?o[t]:R(e)?((e,t)=>h(e,(e=>e[t])))(o[t+1]??{},e):e},B=(e,t)=>{const o=L(e,t);return y(e)||R(e)?o:e},T=e=>P(x(S)[e]??{}),M=e=>L(e,0),F=e=>B(e,0),E=e=>L(e,2),V=e=>B(e,2),A=e=>L(e,4),j=e=>B(e,4),D=e=>L(e,6),O=e=>B(e,6),Q=e=>L(e,8),W=e=>B(e,8),z=e=>L(e,10),G=e=>B(e,10),H=e=>e.toLowerCase();H(d);const J="Transaction";H(J);const{useCallback:K,useEffect:N,useMemo:U,useRef:X,useState:Y}=e,Z=(e,t,o=[])=>{const s=U((()=>t(e)),[e,...o]);return N((()=>()=>s.destroy()),[s]),s},$=(e,t,o,s=[],r)=>{const[,d]=Y(),n=K((()=>t?.["get"+e]?.(...s)??o),[t,...s]),[I]=Y(n),i=X(I);return U((()=>i.current=n()),[n]),_(e,t,((...e)=>{i.current=y(r)?n():e[r],d([])}),[],s),i.current},_=(e,t,o,s=[],r=[],...n)=>N((()=>{const s=t?.["add"+e+d]?.(...r,o,...n);return()=>t?.delListener(s)}),[t,...r,...s,...n]),ee=(e,t,o,s=[],r=v,d=[],...n)=>{const I=F(e);return K((e=>h(I,(s=>h(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[I,t,...s,...d,...n])},te=(e,t,o=v,s=[],...r)=>{const d=F(e);return K((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},oe=(e,t,o)=>{const s=G(e);return K((()=>s?.[t](o)),[s,t,o])},se=(e,t=[])=>U(e,t),re=()=>T(1),de=e=>$(u,F(e),{}),ne=e=>$(l,F(e),[],[]),Ie=(e,t)=>$(i,F(t),{},[e]),ie=(e,t)=>$(i+C,F(t),[],[e]),ue=(e,t)=>$(a,F(t),[],[e]),le=(e,t)=>$(p,F(t),[],[e]),ce=(e,t,o,s=0,r,d)=>$(g,F(d),[],[e,t,o,s,r],6),ae=(e,t,o)=>$(c,F(o),{},[e,t]),pe=(e,t,o)=>$(C,F(o),[],[e,t]),ge=(e,t,o,s)=>$(b,F(s),void 0,[e,t,o],4),be=e=>$(k,F(e),{}),Ce=e=>$(w,F(e),[],[]),me=(e,t)=>$(m,F(t),void 0,[e]),ke=(e,t,o,s,r)=>ee(o,u,e,t,s,r),we=(e,t,o,s,r,d)=>ee(s,i,t,o,r,d,e),ye=(e,t,o,s,r,d,n)=>ee(r,c,o,s,d,n,e,t),he=(e,t,o=[],s,r=v,d=[],n=!0)=>{const I=F(s);return K((o=>h(I,(s=>h(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[I,e,...o,...d,n])},Re=(e,t,o,s,r,d,n)=>ee(r,"PartialRow",o,s,d,n,e,t),ve=(e,t,o,s,r,d,n,I)=>ee(d,b,s,r,n,I,e,t,o),qe=(e,t,o,s,r)=>ee(o,k,e,t,s,r),Pe=(e,t,o,s,r)=>ee(o,"PartialValues",e,t,s,r),fe=(e,t,o,s,r,d)=>ee(s,m,t,o,r,d,e),xe=(e,t,o)=>te(e,u,t,o),Se=(e,t,o,s)=>te(t,i,o,s,e),Le=(e,t,o,s,r)=>te(o,c,s,r,e,t),Be=(e,t,o,s,r,d,n)=>te(r,b,d,n,e,t,o,s),Te=(e,t,o)=>te(e,k,t,o),Me=(e,t,o,s)=>te(t,m,o,s,e),Fe=(e,t,o,s)=>_(u,F(s),e,t,[],o),Ee=(e,t,o,s)=>_(l,F(s),e,t,[],o),Ve=(e,t,o,s,r)=>_(i,F(r),t,o,[e],s),Ae=(e,t,o,s,r)=>_(i+C,F(r),t,o,[e],s),je=(e,t,o,s,r)=>_(a,F(r),t,o,[e],s),De=(e,t,o,s,r)=>_(p,F(r),t,o,[e],s),Oe=(e,t,o,s,r,d,n,I,i)=>_(g,F(i),d,n,[e,t,o,s,r],I),Qe=(e,t,o,s,r,d)=>_(c,F(d),o,s,[e,t],r),We=(e,t,o,s,r,d)=>_(C,F(d),o,s,[e,t],r),ze=(e,t,o,s,r,d,n)=>_(b,F(n),s,r,[e,t,o],d),Ge=(e,t,o,s)=>_(k,F(s),e,t,[],o),He=(e,t,o,s)=>_(w,F(s),e,t,[],o),Je=(e,t,o,s,r)=>_(m,F(r),t,o,[e],s),Ke=(e,t,o)=>_("Start"+J,F(o),e,t),Ne=(e,t,o)=>_("WillFinish"+J,F(o),e,t),Ue=(e,t,o)=>_("DidFinish"+J,F(o),e,t),Xe=(e,t,o)=>Z(e,t,o),Ye=()=>T(3),Ze=e=>$("MetricIds",V(e),[]),$e=(e,t)=>$("Metric",V(t),void 0,[e]),_e=(e,t,o,s)=>_("Metric",V(s),t,o,[e]),et=(e,t,o)=>Z(e,t,o),tt=()=>T(5),ot=(e,t)=>$("SliceIds",j(t),[],[e]),st=e=>$("IndexIds",j(e),[]),rt=(e,t,o)=>$("Slice"+p,j(o),[],[e,t]),dt=(e,t,o,s)=>_("SliceIds",j(s),t,o,[e]),nt=(e,t,o,s,r)=>_("Slice"+p,j(r),o,s,[e,t]),It=(e,t,o)=>Z(e,t,o),it=()=>T(7),ut=e=>$("RelationshipIds",O(e),[]),lt=(e,t,o)=>$("RemoteRowId",O(o),void 0,[e,t]),ct=(e,t,o)=>$("Local"+p,O(o),[],[e,t]),at=(e,t,o)=>$("Linked"+p,O(o),[],[e,t]),pt=(e,t,o,s,r)=>_("RemoteRowId",O(r),o,s,[e,t]),gt=(e,t,o,s,r)=>_("Local"+p,O(r),o,s,[e,t]),bt=(e,t,o,s,r)=>_("Linked"+p,O(r),o,s,[e,t]),Ct=(e,t,o)=>Z(e,t,o),mt=()=>T(9),kt=e=>$("QueryIds",W(e),[]),wt=(e,t)=>$(n+i,W(t),{},[e]),yt=(e,t)=>$(n+i+C,W(t),[],[e]),ht=(e,t)=>$(n+a,W(t),[],[e]),Rt=(e,t)=>$(n+p,W(t),[],[e]),vt=(e,t,o,s=0,r,d)=>$(n+g,W(d),[],[e,t,o,s,r],6),qt=(e,t,o)=>$(n+c,W(o),{},[e,t]),Pt=(e,t,o)=>$(n+C,W(o),[],[e,t]),ft=(e,t,o,s)=>$(n+b,W(s),void 0,[e,t,o]),xt=(e,t,o,s)=>_(n+i,W(s),t,o,[e]),St=(e,t,o,s)=>_(n+i+C,W(s),t,o,[e]),Lt=(e,t,o,s)=>_(n+a,W(s),t,o,[e]),Bt=(e,t,o,s)=>_(n+p,W(s),t,o,[e]),Tt=(e,t,o,s,r,d,I,i)=>_(n+g,W(i),d,I,[e,t,o,s,r]),Mt=(e,t,o,s,r)=>_(n+c,W(r),o,s,[e,t]),Ft=(e,t,o,s,r)=>_(n+C,W(r),o,s,[e,t]),Et=(e,t,o,s,r,d)=>_(n+b,W(d),s,r,[e,t,o]),Vt=(e,t,o)=>Z(e,t,o),At=()=>T(11),jt=e=>$("CheckpointIds",G(e),[[],void 0,[]]),Dt=(e,t)=>$("Checkpoint",G(t),void 0,[e]),Ot=(e=v,t=[],o,s=v,r=[])=>{const d=G(o);return K((t=>h(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Qt=e=>oe(e,"goBackward"),Wt=e=>oe(e,"goForward"),zt=(e,t=[],o,s=v,r=[])=>{const d=G(o);return K((t=>h(d,(o=>h(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},Gt=e=>{const t=G(e),[o,r]=jt(t);return[(d=o,!(0==(e=>e.length)(d))),Qt(t),r,h(r,(e=>t?.getCheckpoint(e)))??s];var d},Ht=e=>{const t=G(e),[,,[o]]=jt(t);return[!y(o),Wt(t),o,h(o,(e=>t?.getCheckpoint(e)))??s]},Jt=(e,t,o)=>_("CheckpointIds",G(o),e,t),Kt=(e,t,o,s)=>_("Checkpoint",G(s),t,o,[e]),Nt=(e,t,o=[],s,r=[])=>{const[,d]=Y(),n=U((()=>t(e)),[e,...o]);return N((()=>((async()=>{await(s?.(n)),d(1)})(),()=>{n.destroy()})),[n,...r]),n},{PureComponent:Ut,Fragment:Xt,createElement:Yt,useCallback:Zt,useLayoutEffect:$t,useRef:_t,useState:eo}=e,to=(e,...t)=>y(e)?{}:e(...t),oo=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useMemo:so}=e,ro=({tableId:e,store:t,rowComponent:o=ao,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},I)=>lo(q(I,(d=>Yt(o,{...to(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),no=({queryId:e,queries:t,resultRowComponent:o=Po,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>lo(q(n,(r=>Yt(o,{...to(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),Io=({relationshipId:e,relationships:t,rowComponent:o=ao,getRowComponentProps:s,separator:r,debugIds:d},n,I)=>{const[i,u,l]=oo(O(t),e),c=n(e,I,i);return lo(q(c,(e=>Yt(o,{...to(s,e),key:e,tableId:l,rowId:e,store:u,debugIds:d}))),r,d,I)},io=e=>({checkpoints:t,checkpointComponent:o=So,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=G(t);return lo(q(e(jt(n)),(e=>Yt(o,{...to(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},uo=({store:e,storesById:o,metrics:s,metricsById:r,indexes:d,indexesById:n,relationships:I,relationshipsById:i,queries:u,queriesById:l,checkpoints:c,checkpointsById:a,children:p})=>{const g=t(S);return Yt(S.Provider,{value:so((()=>[e??g[0],{...g[1],...o},s??g[2],{...g[3],...r},d??g[4],{...g[5],...n},I??g[6],{...g[7],...i},u??g[8],{...g[9],...l},c??g[10],{...g[11],...a}]),[e,o,s,r,d,n,I,i,u,l,c,a,g])},p)},lo=(e,t,o,s)=>{const r=y(t)||!Array.isArray(e)?e:q(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},co=({tableId:e,rowId:t,cellId:o,store:r,debugIds:d})=>lo(s+(ge(e,t,o,r)??s),void 0,d,o),ao=({tableId:e,rowId:t,store:o,cellComponent:s=co,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:I})=>lo(q(((e,t,o,s)=>{const r=pe(t,o,s);return e??r})(d,e,t,o),(d=>Yt(s,{...to(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:I}))),n,I,t),po=e=>ro(e,le(e.tableId,e.store)),go=({cellId:e,descending:t,offset:o,limit:s,...r})=>ro(r,ce(r.tableId,e,t,o,s,r.store)),bo=({store:e,tableComponent:t=po,getTableComponentProps:o,separator:s,debugIds:r})=>lo(q(ne(e),(s=>Yt(t,{...to(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),Co=({valueId:e,store:t,debugIds:o})=>lo(s+(me(e,t)??s),void 0,o,e),mo=({store:e,valueComponent:t=Co,getValueComponentProps:o,separator:s,debugIds:r})=>lo(q(Ce(e),(s=>Yt(t,{...to(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),ko=({metricId:e,metrics:t,debugIds:o})=>lo($e(e,t)??s,void 0,o,e),wo=({indexId:e,sliceId:t,indexes:o,rowComponent:s=ao,getRowComponentProps:r,separator:d,debugIds:n})=>{const[I,i,u]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(j(o),e),l=rt(e,t,I);return lo(q(l,(e=>Yt(s,{...to(r,e),key:e,tableId:u,rowId:e,store:i,debugIds:n}))),d,n,t)},yo=({indexId:e,indexes:t,sliceComponent:o=wo,getSliceComponentProps:s,separator:r,debugIds:d})=>lo(q(ot(e,t),(r=>Yt(o,{...to(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),ho=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=ao,getRowComponentProps:r,debugIds:d})=>{const[n,I,,i]=oo(O(o),e),u=lt(e,t,n);return lo(y(i)||y(u)?null:Yt(s,{...to(r,u),key:u,tableId:i,rowId:u,store:I,debugIds:d}),void 0,d,t)},Ro=e=>Io(e,ct,e.remoteRowId),vo=e=>Io(e,at,e.firstRowId),qo=({queryId:e,rowId:t,cellId:o,queries:r,debugIds:d})=>lo(s+(ft(e,t,o,r)??s),void 0,d,o),Po=({queryId:e,rowId:t,queries:o,resultCellComponent:s=qo,getResultCellComponentProps:r,separator:d,debugIds:n})=>lo(q(Pt(e,t,o),(d=>Yt(s,{...to(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),fo=e=>no(e,Rt(e.queryId,e.queries)),xo=({cellId:e,descending:t,offset:o,limit:s,...r})=>no(r,vt(r.queryId,e,t,o,s,r.queries)),So=({checkpoints:e,checkpointId:t,debugIds:o})=>lo(Dt(t,e)??s,void 0,o,t),Lo=io((e=>e[0])),Bo=io((e=>y(e[1])?[]:[e[1]])),To=io((e=>e[2]));export{Lo as BackwardCheckpointsView,co as CellView,So as CheckpointView,Bo as CurrentCheckpointView,To as ForwardCheckpointsView,yo as IndexView,vo as LinkedRowsView,Ro as LocalRowsView,ko as MetricView,uo as Provider,ho as RemoteRowView,qo as ResultCellView,Po as ResultRowView,xo as ResultSortedTableView,fo as ResultTableView,ao as RowView,wo as SliceView,go as SortedTableView,po as TableView,bo as TablesView,Co as ValueView,mo as ValuesView,he as useAddRowCallback,ge as useCell,pe as useCellIds,We as useCellIdsListener,ze as useCellListener,Dt as useCheckpoint,jt as useCheckpointIds,Jt as useCheckpointIdsListener,Kt as useCheckpointListener,z as useCheckpoints,At as useCheckpointsIds,G as useCheckpointsOrCheckpointsById,Vt as useCreateCheckpoints,et as useCreateIndexes,Xe as useCreateMetrics,Nt as useCreatePersister,Ct as useCreateQueries,It as useCreateRelationships,se as useCreateStore,Be as useDelCellCallback,Le as useDelRowCallback,Se as useDelTableCallback,xe as useDelTablesCallback,Me as useDelValueCallback,Te as useDelValuesCallback,Ue as useDidFinishTransactionListener,Qt as useGoBackwardCallback,Wt as useGoForwardCallback,zt as useGoToCallback,st as useIndexIds,A as useIndexes,tt as useIndexesIds,j as useIndexesOrIndexesById,at as useLinkedRowIds,bt as useLinkedRowIdsListener,ct as useLocalRowIds,gt as useLocalRowIdsListener,$e as useMetric,Ze as useMetricIds,_e as useMetricListener,E as useMetrics,Ye as useMetricsIds,V as useMetricsOrMetricsById,Q as useQueries,mt as useQueriesIds,W as useQueriesOrQueriesById,kt as useQueryIds,Ht as useRedoInformation,ut as useRelationshipIds,D as useRelationships,it as useRelationshipsIds,O as useRelationshipsOrRelationshipsById,lt as useRemoteRowId,pt as useRemoteRowIdListener,ft as useResultCell,Pt as useResultCellIds,Ft as useResultCellIdsListener,Et as useResultCellListener,qt as useResultRow,ht as useResultRowCount,Lt as useResultRowCountListener,Rt as useResultRowIds,Bt as useResultRowIdsListener,Mt as useResultRowListener,vt as useResultSortedRowIds,Tt as useResultSortedRowIdsListener,wt as useResultTable,yt as useResultTableCellIds,St as useResultTableCellIdsListener,xt as useResultTableListener,ae as useRow,ue as useRowCount,je as useRowCountListener,le as useRowIds,De as useRowIdsListener,Qe as useRowListener,ve as useSetCellCallback,Ot as useSetCheckpointCallback,Re as useSetPartialRowCallback,Pe as useSetPartialValuesCallback,ye as useSetRowCallback,we as useSetTableCallback,ke as useSetTablesCallback,fe as useSetValueCallback,qe as useSetValuesCallback,ot as useSliceIds,dt as useSliceIdsListener,rt as useSliceRowIds,nt as useSliceRowIdsListener,ce as useSortedRowIds,Oe as useSortedRowIdsListener,Ke as useStartTransactionListener,M as useStore,re as useStoreIds,F as useStoreOrStoreById,Ie as useTable,ie as useTableCellIds,Ae as useTableCellIdsListener,ne as useTableIds,Ee as useTableIdsListener,Ve as useTableListener,de as useTables,Fe as useTablesListener,Gt as useUndoInformation,me as useValue,Ce as useValueIds,He as useValueIdsListener,Je as useValueListener,be as useValues,Ge as useValuesListener,Ne as useWillFinishTransactionListener};
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,a="",n=l(a),r=l(!0),o=l(0),i=l(l),d="type",u="default",c="Ids",h="Table",m=h+"s",b=h+c,g="Row",I=g+"Count",p=g+c,f="Cell",w=f+c,y="Value",C=y+"s",v=y+c,T="currentTarget",k="value",S=e=>a+e,x=Math.floor,V=isFinite,R=(e,t)=>e instanceof t,q=e=>null==e,N=(e,t,s)=>q(e)?s?.():t(e),L=e=>e==n||e==r,M=e=>l(e)==i,E=e=>Array.isArray(e),{PureComponent:z,Fragment:$,createElement:O,useCallback:A,useLayoutEffect:F,useRef:J,useState:P}=t,B=(e,...t)=>q(e)?{}:e(...t),H=(e,t)=>e.forEach(t),D=(e,t)=>e.map(t),Q=e=>e.length,j=e=>0==Q(e),W=(e,t,s)=>e.slice(t,s),U=(e,...t)=>e.push(...t),G=e=>e.shift(),K=Object,X=K.keys,Y=K.isFrozen,Z=K.freeze,_=e=>R(e,K)&&e.constructor==K,ee=(e=[])=>K.fromEntries(e),te=(e,t)=>!q(((e,t)=>N(e,(e=>e[t])))(e,t)),se=(e,t)=>(delete e[t],e),le=(e,t)=>D(K.entries(e),(([e,s])=>t(s,e))),ae=e=>_(e)&&0==(e=>Q(X(e)))(e),ne=e=>JSON.stringify(e,((e,t)=>R(t,Map)?K.fromEntries([...t]):t)),re=JSON.parse,oe="tinybaseStoreInspector",ie="TinyBase Store Inspector",de=["left","top","bottom","right","full"],ue="state",ce="sort",he="open",me="position",be=he,ge="editable",Ie=(...e)=>ne(e),pe=(e,t)=>D(e.sort(),t),fe=(e,t)=>[!!s.useCell(ue,e,ge,t),A((s=>{t.setCell(ue,e,ge,(e=>!e)),s.preventDefault()}),[t,e])],we="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',Ce=ye+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ve='</svg>")',Te=ye+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",ke=D([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Ce+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+ve)),Se=Ce+"<path d='M20 20l60 60M20 80l60-60' />"+ve,xe=Ce+`<path d='${we}' />`+ve,Ve=Ce+`<path d='${we}M20 20l60 60' />`+ve,Re="*::-webkit-scrollbar",qe=`#${oe}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,t="")=>e.join(t))(le({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Re]:"width:0.5rem;height:0.5rem;",[Re+"-track"]:"background:#111",[Re+"-thumb"]:"background:#999;border:1px solid #111",[Re+"-thumb:hover"]:"background:#fff",[Re+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Te,...ee(D(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...ee(D(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Te,"header>img:nth-of-type(6)":Se,...ee(D(ke,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":xe,"details[open]>summary img.done":Ve,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem","th,td":"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`& ${t}{${e}}`:"")))}`,Ne=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!0),[],e);return s.useValue(be,e)?null:O("img",{onClick:l,title:ie,"data-position":t})},Le=({uniqueId:e,summary:t,editable:l,handleEditable:a,children:n,s:r})=>{const o=!!s.useCell(ue,e,he,r),i=s.useSetCellCallback(ue,e,he,(e=>e[T].open),[],r);return O("details",{open:o,onToggle:i},O("summary",null,t,a?O("img",{onClick:a,className:l?"done":"edit"}):null),n)},Me=e=>{const t=l(e);return L(t)||t==o&&V(e)?t:void 0},Ee=(e,t,s,l,a)=>q(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),ze=(e,t,s)=>q(s)?e.delValue(t):e.setValue(t,s),$e=(e,t,s,l)=>e==n?t:e==o?s:l,{useCallback:Oe,useMemo:Ae,useState:Fe}=t,Je="editable",Pe=(e,t)=>D(s.useTableCellIds(e,t),(t=>e+"."+t)),Be=(e,t,s)=>{const l=Oe(e,t);return s?l:void 0},He=(...e)=>Ae((()=>e),e),De=(e,t)=>Ae((()=>({store:e,tableId:t})),[e,t]),Qe=(e,t)=>Ae((()=>({queries:e,queryId:t})),[e,t]),je=(e,t=!1,s,l=0,a,n,r,o)=>{const[[i,d,u],c]=Fe([e,t,l]),h=Oe((e=>{c(e),o?.(e)}),[o]),m=Be((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),b=Oe((e=>h([i,d,e])),[h,i,d]),g=!0===r?at:r;return[[i,d,u],m,Ae((()=>!1===r?null:O(g,{offset:u,limit:a,total:n,onChange:b})),[r,g,u,a,n,b])]},We=(e,t,s)=>Ae((()=>{const a=t??e;return ee(le(E(a)?ee(D(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:s,...(a=e,l(a)==n?{label:e}:e)}];var a})))}),[t,s,e]),Ue=({className:e,headerRow:t,idColumn:s,params:[l,a,n,r,o,i]})=>O("table",{className:e},i?O("caption",null,i):null,!1===t?null:O("thead",null,O("tr",null,!1===s?null:O(Ge,{sort:r??[],label:"Id",onClick:o}),le(l,(({label:e},t)=>O(Ge,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),O("tbody",null,D(n,(e=>O("tr",{key:e},!1===s?null:O("th",null,e),le(l,(({component:t,getComponentProps:s},l)=>O("td",{key:l},O(t,{...B(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:l=e??a,onClick:n})=>O("th",{onClick:Be((()=>n?.(e)),[n,e],n),className:q(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},q(s)||t!=e?null:(s?"↓":"↑")+" ",l),Ke=({localRowId:e,params:[l,a,n,r,o,i,d]})=>{const u=s.useRemoteRowId(o,e,i);return O("tr",null,!1===l?null:O(t.Fragment,null,O("th",null,e),O("th",null,u)),le(a,(({component:t,getComponentProps:s},l)=>{const[a,o]=l.split(".",2),i=a===n?e:a===r?u:null;return q(i)?null:O("td",{key:l},O(t,{...B(s,i,o),store:d,tableId:a,rowId:i,cellId:o}))})))},Xe=({thing:e,onThingChange:t,className:s,hasSchema:l})=>{const[a,i]=Fe(),[d,u]=Fe(),[c,h]=Fe(),[m,b]=Fe(),[g,I]=Fe();d!==e&&(i(Me(e)),u(e),h(e+""),b(Number(e)||0),I(!!e));const p=Oe(((e,s)=>{s(e),u(e),t(e)}),[t]);return O("div",{className:s},O("button",{className:a,onClick:Oe((()=>{if(!l?.()){const e=$e(a,o,r,n),s=$e(e,c,m,g);i(e),u(s),t(s)}}),[l,t,c,m,g,a])},a),$e(a,O("input",{key:a,value:c,onChange:Oe((e=>p(e[T][k]+"",h)),[p])}),O("input",{key:a,type:"number",value:m,onChange:Oe((e=>p(Number(e[T][k]||0),b)),[p])}),O("input",{key:a,type:"checkbox",checked:g,onChange:Oe((e=>p(!!e[T].checked,I)),[p])})))},Ye=({tableId:e,cellId:t,descending:l,offset:a,limit:n,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,b,g]=je(t,l,i,a,n,s.useRowCount(e,r),d,u);return O(Ue,{...h,params:He(We(s.useTableCellIds(e,r),c,o?st:s.CellView),De(r,e),s.useSortedRowIds(e,...m,n,r),m,b,g)})},Ze=({store:e,editable:t=!1,valueComponent:l=(t?lt:s.ValueView),getValueComponentProps:a,className:n,headerRow:r,idColumn:o})=>O("table",{className:n},!1===r?null:O("thead",null,O("tr",null,!1===o?null:O("th",null,"Id"),O("th",null,y))),O("tbody",null,D(s.useValueIds(e),(t=>O("tr",{key:t},!1===o?null:O("th",null,t),O("td",null,O(l,{...B(a,t),valueId:t,store:e}))))))),_e=({indexId:e,sliceId:t,indexes:l,editable:a,customCells:n,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return O(Ue,{...r,params:He(We(s.useTableCellIds(d,i),n,a?st:s.CellView),De(i,d),s.useSliceRowIds(e,t,o))})},et=({relationshipId:e,relationships:l,editable:a,customCells:n,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=We([...Pe(c,u),...Pe(h,u)],n,a?st:s.CellView),b=He(i,m,c,h,e,d,u);return O("table",{className:r},!1===o?null:O("thead",null,O("tr",null,!1===i?null:O(t.Fragment,null,O("th",null,c,".Id"),O("th",null,h,".Id")),le(m,(({label:e},t)=>O("th",{key:t},e))))),O("tbody",null,D(s.useRowIds(c,u),(e=>O(Ke,{key:e,localRowId:e,params:b})))))},tt=({queryId:e,cellId:t,descending:l,offset:a,limit:n,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,b]=je(t,l,o,a,n,s.useResultRowCount(e,r),i,u);return O(Ue,{...c,params:He(We(s.useResultTableCellIds(e,r),d,s.ResultCellView),Qe(r,e),s.useResultSortedRowIds(e,...h,n,r),h,m,b)})},st=({tableId:e,rowId:t,cellId:l,store:a,className:n})=>O(Xe,{thing:s.useCell(e,t,l,a),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],a),className:n??Je+f,hasSchema:s.useStoreOrStoreById(a)?.hasTablesSchema}),lt=({valueId:e,store:t,className:l})=>O(Xe,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Je+y,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),at=({onChange:e,total:s,offset:l=0,limit:a=s,singular:n="row",plural:r=n+"s"})=>{(l>s||l<0)&&(l=0,e(0));const o=Be((()=>e(l-a)),[e,l,a],l>0),i=Be((()=>e(l+a)),[e,l,a],l+a<s);return O(t.Fragment,null,s>a&&O(t.Fragment,null,O("button",{className:"previous",disabled:0==l,onClick:o},"←"),O("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",Math.min(s,l+a)," of "),s," ",1!=s?r:n)},nt=({indexes:e,indexesId:t,indexId:l,s:a})=>O(Le,{uniqueId:Ie("i",t,l),summary:"Index: "+l,s:a},D(s.useSliceIds(l,e),(s=>O(rt,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:a})))),rt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=Ie("i",t,s,l),[r,o]=fe(n,a);return O(Le,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},O(_e,{sliceId:l,indexId:s,indexes:e,editable:r}))},ot=({indexesId:e,s:t})=>{const l=s.useIndexes(e),a=s.useIndexIds(l);return q(l)?null:O(Le,{uniqueId:Ie("i",e),summary:"Indexes: "+(e??u),s:t},j(a)?"No indexes defined":pe(a,(s=>O(nt,{indexes:l,indexesId:e,indexId:s,s:t}))))},it=({metrics:e,metricId:t})=>O("tr",null,O("th",null,t),O("td",null,e?.getTableId(t)),O("td",null,s.useMetric(t,e))),dt=({metricsId:e,s:t})=>{const l=s.useMetrics(e),a=s.useMetricIds(l);return q(l)?null:O(Le,{uniqueId:Ie("m",e),summary:"Metrics: "+(e??u),s:t},j(a)?"No metrics defined":O("table",null,O("thead",null,O("th",null,"Metric Id"),O("th",null,"Table Id"),O("th",null,"Metric")),O("tbody",null,D(a,(e=>O(it,{metrics:l,metricId:e}))))))},ut=({queries:e,queriesId:t,queryId:l,s:a})=>{const n=Ie("q",t,l),[r,o,i]=re(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a);return O(Le,{uniqueId:n,summary:"Query: "+l,s:a},O(tt,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ct=({queriesId:e,s:t})=>{const l=s.useQueries(e),a=s.useQueryIds(l);return q(l)?null:O(Le,{uniqueId:Ie("q",e),summary:"Queries: "+(e??u),s:t},j(a)?"No queries defined":pe(a,(s=>O(ut,{queries:l,queriesId:e,queryId:s,s:t}))))},ht=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=Ie("r",t,s),[n,r]=fe(a,l);return O(Le,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},O(et,{relationshipId:s,relationships:e,editable:n}))},mt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),a=s.useRelationshipIds(l);return q(l)?null:O(Le,{uniqueId:Ie("r",e),summary:"Relationships: "+(e??u),s:t},j(a)?"No relationships defined":pe(a,(s=>O(ht,{relationships:l,relationshipsId:e,relationshipId:s,s:t}))))},bt=({tableId:e,store:t,storeId:l,s:a})=>{const n=Ie("t",l,e),[r,o,i]=re(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a),[u,c]=fe(n,a);return O(Le,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},O(Ye,{tableId:e,store:t,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},gt=({store:e,storeId:t,s:l})=>{const a=Ie("v",t),[n,r]=fe(a,l);return j(s.useValueIds(e))?null:O(Le,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},O(Ze,{store:e,editable:n}))},It=({storeId:e,s:t})=>{const l=s.useStore(e),a=s.useTableIds(l);return q(l)?null:O(Le,{uniqueId:Ie("s",e),summary:"Store: "+(e??u),s:t},O(gt,{storeId:e,store:l,s:t}),pe(a,(s=>O(bt,{store:l,storeId:e,tableId:s,s:t}))))},pt=({s:e})=>{const t=J(null),l=J(0),[a,n]=P(!1),{scrollLeft:r,scrollTop:o}=s.useValues(e);F((()=>{const e=t.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=x(r)+e.clientWidth&&e.scrollHeight>=x(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,r,o]);const i=A((t=>{const{scrollLeft:s,scrollTop:a}=t[T];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),b=s.useIndexesIds(),g=s.useRelationships(),I=s.useRelationshipsIds(),p=s.useQueries(),f=s.useQueriesIds();return q(d)&&j(u)&&q(c)&&j(h)&&q(m)&&j(b)&&q(g)&&j(I)&&q(p)&&j(f)?O("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):O("article",{ref:t,onScroll:i},O(It,{s:e}),D(u,(t=>O(It,{storeId:t,key:t,s:e}))),O(dt,{s:e}),D(h,(t=>O(dt,{metricsId:t,key:t,s:e}))),O(ot,{s:e}),D(b,(t=>O(ot,{indexesId:t,key:t,s:e}))),O(mt,{s:e}),D(I,(t=>O(mt,{relationshipsId:t,key:t,s:e}))),O(ct,{s:e}),D(f,(t=>O(ct,{queriesId:t,key:t,s:e}))))};class ft extends z{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError=()=>({e:1});componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?O("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const wt=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!1),[],e),a=s.useSetValueCallback(me,(e=>Number(e[T].dataset.id)),[],e);return O("header",null,O("img",{title:ie}),O("span",null,ie),D(de,((e,s)=>s==t?null:O("img",{onClick:a,"data-id":s,title:"Dock to "+e,key:s}))),O("img",{onClick:l,title:"Close"}))},yt=({s:e})=>{const t=s.useValue(me,e)??1;return s.useValue(be,e)?O("main",{"data-position":t},O(wt,{s:e}),O(ft,null,O(pt,{s:e}))):null},Ct=e=>t=>{return s=(t,s)=>t+e(s),Rt(t).reduce(s,0);var s},vt=e=>e?.size??0,Tt=Ct(vt),kt=Ct(Tt),St=Ct(kt),xt=(e,t)=>e?.has(t)??!1,Vt=e=>q(e)||0==vt(e),Rt=e=>[...e?.values()??[]],qt=e=>e.clear(),Nt=(e,t)=>e?.forEach(t),Lt=(e,t)=>e?.delete(t),Mt=e=>new Map(e),Et=e=>[...e?.keys()??[]],zt=(e,t)=>e?.get(t),$t=(e,t)=>Nt(e,((e,s)=>t(s,e))),Ot=(e,t,s)=>q(s)?(Lt(e,t),e):e?.set(t,s),At=(e,t,s)=>(xt(e,t)||Ot(e,t,s()),zt(e,t)),Ft=(e,t,s,l=Ot)=>(le(t,((t,l)=>s(e,l,t))),$t(e,(s=>te(t,s)?0:l(e,s))),e),Jt=(e,t,s)=>{const l={};return Nt(e,((e,a)=>{const n=t?t(e,a):e;!s?.(n,e)&&(l[a]=n)})),l},Pt=(e,t,s)=>Jt(e,(e=>Jt(e,t,s)),ae),Bt=(e,t,s)=>Jt(e,(e=>Pt(e,t,s)),ae),Ht=(e,t)=>{const s=Mt();return Nt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Dt=e=>Ht(e,Ht),Qt=e=>Ht(e,Dt),jt=(e,t,s,l,a=0)=>N((s?At:zt)(e,t[a],a>Q(t)-2?s:Mt),(n=>{if(a>Q(t)-2)return l?.(n)&&Ot(e,t[a]),n;const r=jt(n,t,s,l,a+1);return Vt(n)&&Ot(e,t[a]),r})),Wt=Mt(),Ut=Mt(),Gt="storage",Kt=globalThis.window,Xt=e=>new Set(E(e)||q(e)?e:[e]),Yt=(e,t)=>e?.add(t),Zt=/^\d+$/,_t=()=>{const e=[];let t=0;return[s=>(s?G(e):null)??a+t++,t=>{Zt.test(t)&&Q(e)<1e3&&U(e,t)}]},es=e=>[e,e],ts=(e,t=Tt)=>t(e[0])+t(e[1]),ss=()=>[Mt(),Mt()],ls=e=>[...e],as=([e,t])=>e===t,ns=(e,t,s)=>q(e)||!_(e)||ae(e)||Y(e)?(s?.(),!1):(le(e,((s,l)=>{t(s,l)||se(e,l)})),!ae(e)),rs=(e,t,s)=>Ot(e,t,zt(e,t)==-s?void 0:s),os=()=>{let e,t,s=!1,l=!1,n=0;const r=Mt(),i=Mt(),c=Mt(),T=Mt(),k=Mt(),x=Mt(),V=Mt(),R=Mt(),E=Mt(),z=Mt(),$=Mt(),O=Mt(),A=Mt(),F=Mt(),J=Xt(),P=Mt(),B=Mt(),j=Mt(),G=Mt(),K=ss(),X=ss(),Y=ss(),_=ss(),ee=ss(),oe=ss(),ie=ss(),de=ss(),ue=ss(),ce=ss(),he=ss(),me=ss(),be=ss(),ge=ss(),Ie=ss(),pe=Mt(),fe=ss(),[we,ye,Ce,ve]=(e=>{let t;const[s,l]=_t(),n=Mt();return[(e,l,r,o=[],i=(()=>[]))=>{t??=ws;const d=s(1);return Ot(n,d,[e,l,r,o,i]),Yt(jt(l,r??[a],Xt),d),d},(e,s,...l)=>H(((e,t=[a])=>{const s=[],l=(e,a)=>a==Q(t)?U(s,e):null===t[a]?Nt(e,(e=>l(e,a+1))):H([t[a],null],(t=>l(zt(e,t),a+1)));return l(e,0),s})(e,s),(e=>Nt(e,(e=>zt(n,e)[0](t,...s??[],...l))))),e=>N(zt(n,e),(([,t,s])=>(jt(t,s??[a],void 0,(t=>(Lt(t,e),Vt(t)?1:0))),Ot(n,e),l(e),s))),e=>N(zt(n,e),(([e,,s=[],l,a])=>{const n=(...r)=>{const o=Q(r);o==Q(s)?e(t,...r,...a(r)):q(s[o])?H(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),Te=e=>{if(!ns(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!L(t)&&t!=o||(Me(e[u])!=t&&se(e,u),0))},ke=(t,s)=>(!e||xt($,s)||lt(s))&&ns(t,((e,t)=>Se(s,t,e)),(()=>lt(s))),Se=(e,t,s,l)=>ns(l?s:qe(s,e,t),((l,a)=>N(xe(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>lt(e,t))),xe=(t,s,l,a)=>e?N(zt(zt($,t),l),(e=>Me(a)!=e[d]?lt(t,s,l,a,e[u]):a),(()=>lt(t,s,l,a))):q(Me(a))?lt(t,s,l,a):a,Ve=(e,t)=>ns(t?e:Ne(e),((t,s)=>N(Re(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>at())),Re=(e,s)=>t?N(zt(A,e),(t=>Me(s)!=t[d]?at(e,s,t[u]):s),(()=>at(e,s))):q(Me(s))?at(e,s):s,qe=(e,t,s)=>(N(zt(O,t),(([l,a])=>{Nt(l,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(a,(l=>{te(e,l)||lt(t,s,l)}))})),e),Ne=e=>(t&&(Nt(F,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(J,(t=>{te(e,t)||at(t)}))),e),Le=e=>Ft($,e,((e,t,s)=>{const l=Mt(),a=Xt();Ft(At($,t,Mt),s,((e,t,s)=>{Ot(e,t,s),N(s[u],(e=>Ot(l,t,e)),(()=>Yt(a,t)))})),Ot(O,t,[l,a])}),((e,t)=>{Ot($,t),Ot(O,t)})),$e=e=>Ft(A,e,((e,t,s)=>{Ot(A,t,s),N(s[u],(e=>Ot(F,t,e)),(()=>Yt(J,t)))}),((e,t)=>{Ot(A,t),Ot(F,t),Lt(J,t)})),Oe=e=>ae(e)?us():Gt(e),Ae=e=>Ft(j,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ue(t))),Fe=(e,t)=>Ft(At(j,e,(()=>(Ye(e,1),Ot(P,e,_t()),Ot(B,e,Mt()),Mt()))),t,((t,s,l)=>Je(e,t,s,l)),((t,s)=>Ge(e,t,s))),Je=(e,t,s,l,a)=>Ft(At(t,s,(()=>(Ze(e,s,1),Mt()))),l,((t,l,a)=>Pe(e,s,t,l,a)),((l,n)=>Ke(e,t,s,l,n,a))),Pe=(e,t,s,l,a)=>{xt(s,l)||_e(e,t,l,1);const n=zt(s,l);a!==n&&(et(e,t,l,n,a),Ot(s,l,a))},Be=(e,t,s,l,a)=>N(zt(t,s),(t=>Pe(e,s,t,l,a)),(()=>Je(e,t,s,qe({[l]:a},e,s)))),He=e=>ae(e)?ms():Kt(e),De=e=>Ft(G,e,((e,t,s)=>Qe(t,s)),((e,t)=>Xe(t))),Qe=(e,t)=>{xt(G,e)||tt(e,1);const s=zt(G,e);t!==s&&(st(e,s,t),Ot(G,e,t))},je=(e,t)=>{const[s]=zt(P,e),l=s(t);return xt(zt(j,e),l)?je(e,t):l},We=e=>zt(j,e)??Fe(e,{}),Ue=e=>Fe(e,{}),Ge=(e,t,s)=>{const[,l]=zt(P,e);l(s),Je(e,t,s,{},!0)},Ke=(e,t,s,l,a,n)=>{const r=zt(zt(O,e)?.[0],a);if(!q(r)&&!n)return Pe(e,s,l,a,r);const o=t=>{et(e,s,t,zt(l,t)),_e(e,s,t,-1),Ot(l,t)};q(r)?o(a):$t(l,o),Vt(l)&&(Ze(e,s,-1),Vt(Ot(t,s))&&(Ye(e,-1),Ot(j,e),Ot(P,e),Ot(B,e)))},Xe=e=>{const t=zt(F,e);if(!q(t))return Qe(e,t);st(e,zt(G,e)),tt(e,-1),Ot(G,e)},Ye=(e,t)=>rs(r,e,t),Ze=(e,t,s)=>rs(At(T,e,Mt),t,s)&&Ot(c,e,At(c,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=zt(B,e),n=zt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&rs(At(i,e,Mt),s,l),Ot(a,s,n!=-l?n+l:null),rs(At(At(k,e,Mt),t,Mt),s,l)},et=(e,t,s,l,a)=>At(At(At(x,e,Mt),t,Mt),s,(()=>[l,0]))[1]=a,tt=(e,t)=>rs(V,e,t),st=(e,t,s)=>At(R,e,(()=>[t,0]))[1]=s,lt=(e,t,s,l,a)=>(U(At(At(At(E,e,Mt),t,Mt),s,(()=>[])),l),a),at=(e,t,s)=>(U(At(z,e,(()=>[])),t),s),nt=(e,t,s)=>N(zt(zt(zt(x,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ct(e,t,s))])),rt=e=>N(zt(R,e),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ut(e))])),ot=e=>Vt(E)||Vt(he[e])?0:Nt(e?Qt(E):E,((t,s)=>Nt(t,((t,l)=>Nt(t,((t,a)=>ye(he[e],[s,l,a],t))))))),it=e=>Vt(z)||Vt(me[e])?0:Nt(e?Ht(z):z,((t,s)=>ye(me[e],[s],t))),dt=(e,t,s)=>{if(!Vt(t))return ye(e,s,(()=>Jt(t))),1},ut=e=>{const t=Vt(ie[e]),s=Vt(ue[e])&&Vt(_[e])&&Vt(ee[e])&&Vt(oe[e])&&t&&Vt(X[e]),l=Vt(ce[e])&&Vt(de[e])&&Vt(Y[e])&&Vt(K[e]);if(!s||!l){const a=e?[Ht(r),Dt(i),Ht(c),Dt(T),Qt(k),Qt(x)]:[r,i,c,T,k,x];if(!s){dt(X[e],a[0]),Nt(a[1],((t,s)=>dt(_[e],t,[s]))),Nt(a[2],((t,s)=>{0!=t&&ye(ee[e],[s],pt(s))}));const s=Xt();Nt(a[3],((l,a)=>{dt(oe[e],l,[a])&&!t&&(ye(ie[e],[a,null]),Yt(s,a))})),t||Nt(a[5],((t,l)=>{if(!xt(s,l)){const s=Xt();Nt(t,(e=>Nt(e,(([t,l],a)=>l!==t?Yt(s,a):Lt(e,a))))),Nt(s,(t=>ye(ie[e],[l,t])))}})),Nt(a[4],((t,s)=>Nt(t,((t,l)=>dt(ue[e],t,[s,l])))))}if(!l){let t;Nt(a[5],((s,l)=>{let a;Nt(s,((s,n)=>{let r;Nt(s,(([s,o],i)=>{o!==s&&(ye(ce[e],[l,n,i],o,s,nt),t=a=r=1)})),r&&ye(de[e],[l,n],nt)})),a&&ye(Y[e],[l],nt)})),t&&ye(K[e],void 0,nt)}}},ct=e=>{const t=Vt(ge[e]),s=Vt(Ie[e])&&Vt(be[e]);if(!t||!s){const l=e?[Ht(V),Ht(R)]:[V,R];if(t||dt(ge[e],l[0]),!s){let t;Nt(l[1],(([s,l],a)=>{l!==s&&(ye(Ie[e],[a],l,s,rt),t=1)})),t&&ye(be[e],void 0,rt)}}},ht=(e,...t)=>(Is((()=>e(...D(t,S)))),ws),mt=()=>[Jt(x,((e,t)=>-1===zt(r,t)?null:Jt(e,((e,s)=>-1===zt(zt(T,t),s)?null:Jt(e,(([,e])=>e??null),((e,t)=>as(t)))),ae)),ae),Jt(R,(([,e])=>e??null),((e,t)=>as(t)))],bt=()=>({cellsTouched:s,valuesTouched:l,changedCells:Bt(x,ls,as),invalidCells:Bt(E),changedValues:Jt(R,ls,as),invalidValues:Jt(z),changedTableIds:Jt(r),changedRowIds:Pt(T),changedCellIds:Bt(k),changedValueIds:Jt(V)}),gt=()=>Bt(j),It=()=>Et(j),pt=e=>vt(zt(j,S(e))),ft=e=>Et(zt(j,S(e))),wt=(e,t,s,l=0,a)=>{return D(W((r=zt(j,S(e)),o=(e,s)=>[q(t)?s:zt(e,S(t)),s],n=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),D([...r?.entries()??[]],(([e,t])=>o(t,e))).sort(n)),l,q(a)?a:l+a),(([,e])=>e));var n,r,o},yt=(e,t)=>Et(zt(zt(j,S(e)),S(t))),Ct=(e,t,s)=>zt(zt(zt(j,S(e)),S(t)),S(s)),Rt=()=>Jt(G),Wt=()=>Et(G),Ut=e=>zt(G,S(e)),Gt=e=>ht((()=>(e=>ns(e,ke,lt))(e)?Ae(e):0)),Kt=e=>ht((()=>Ve(e)?De(e):0)),Zt=e=>{try{Oe(re(e))}catch{}return ws},is=t=>ht((()=>{if((e=ns(t,(e=>ns(e,Te))))&&(Le(t),!Vt(j))){const e=gt();us(),Gt(e)}})),ds=e=>ht((()=>{if(t=(e=>ns(e,Te))(e)){const s=Rt();gs(),ms(),t=!0,$e(e),Kt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>xt(j,e)?Ue(e):0),e),hs=(e,t)=>ht(((e,t)=>N(zt(j,e),(s=>xt(s,t)?Ge(e,s,t):0))),e,t),ms=()=>ht((()=>De({}))),bs=()=>ht((()=>{Le({}),e=!1})),gs=()=>ht((()=>{$e({}),t=!1})),Is=(e,t)=>{if(-1!=n){ps();const s=e();return fs(t),s}},ps=()=>(-1!=n&&n++,1==n&&ye(pe,void 0,mt,bt),ws),fs=e=>(n>0&&(n--,0==n&&(s=!Vt(x),l=!Vt(R),n=1,ot(1),s&&ut(1),it(1),l&&ct(1),e?.(mt,bt)&&(Nt(x,((e,t)=>Nt(e,((e,s)=>Nt(e,(([e],l)=>Ee(ws,t,s,l,e))))))),Nt(R,(([e],t)=>ze(ws,t,e))),s=l=!1),ye(fe[0],void 0,mt,bt),n=-1,ot(0),s&&ut(0),it(0),l&&ct(0),ye(fe[1],void 0,mt,bt),n=0,s=l=!1,H([r,i,c,T,k,x,E,V,R,z],qt))),ws),ws={getContent:()=>[gt(),Rt()],getTables:gt,getTableIds:It,getTable:e=>Pt(zt(j,S(e))),getTableCellIds:e=>Et(zt(B,S(e))),getRowCount:pt,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Jt(zt(zt(j,S(e)),S(t))),getCellIds:yt,getCell:Ct,getValues:Rt,getValueIds:Wt,getValue:Ut,hasTables:()=>!Vt(j),hasTable:e=>xt(j,S(e)),hasTableCell:(e,t)=>xt(zt(B,S(e)),S(t)),hasRow:(e,t)=>xt(zt(j,S(e)),S(t)),hasCell:(e,t,s)=>xt(zt(zt(j,S(e)),S(t)),S(s)),hasValues:()=>!Vt(G),hasValue:e=>xt(G,S(e)),getTablesJson:()=>ne(j),getValuesJson:()=>ne(G),getJson:()=>ne([j,G]),getTablesSchemaJson:()=>ne($),getValuesSchemaJson:()=>ne(A),getSchemaJson:()=>ne([$,A]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ht((()=>{(ae(e)?us:Gt)(e),(ae(t)?ms:Kt)(t)})),setTables:Gt,setTable:(e,t)=>ht((e=>ke(t,e)?Fe(e,t):0),e),setRow:(e,t,s)=>ht(((e,t)=>Se(e,t,s)?Je(e,We(e),t,s):0),e,t),addRow:(e,t,s=!0)=>Is((()=>{let l;return Se(e,l,t)&&(e=S(e),Je(e,We(e),l=je(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>ht(((e,t)=>{if(Se(e,t,s,1)){const l=We(e);le(s,((s,a)=>Be(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>ht(((e,t,s)=>N(xe(e,t,s,M(l)?l(Ct(e,t,s)):l),(l=>Be(e,We(e),t,s,l)))),e,t,s),setValues:Kt,setPartialValues:e=>ht((()=>Ve(e,1)?le(e,((e,t)=>Qe(t,e))):0)),setValue:(e,t)=>ht((e=>N(Re(e,M(t)?t(Ut(e)):t),(t=>Qe(e,t)))),e),setTransactionChanges:e=>ht((()=>{le(e[0],((e,t)=>q(e)?cs(t):le(e,((e,s)=>q(e)?hs(t,s):le(e,((e,l)=>Ee(ws,t,s,l,e))))))),le(e[1],((e,t)=>ze(ws,t,e)))})),setTablesJson:Zt,setValuesJson:e=>{try{He(re(e))}catch{}return ws},setJson:e=>ht((()=>{try{const[t,s]=re(e);Oe(t),He(s)}catch{Zt(e)}})),setTablesSchema:is,setValuesSchema:ds,setSchema:(e,t)=>ht((()=>{is(e),ds(t)})),delTables:us,delTable:cs,delRow:hs,delCell:(e,t,s,l)=>ht(((e,t,s)=>N(zt(j,e),(a=>N(zt(a,t),(n=>xt(n,s)?Ke(e,a,t,n,s,l):0))))),e,t,s),delValues:ms,delValue:e=>ht((e=>xt(G,e)?Xe(e):0),e),delTablesSchema:bs,delValuesSchema:gs,delSchema:()=>ht((()=>{bs(),gs()})),transaction:Is,startTransaction:ps,finishTransaction:fs,forEachTable:e=>Nt(j,((t,s)=>e(s,(e=>Nt(t,((t,s)=>e(s,(e=>$t(t,e))))))))),forEachTableCell:(e,t)=>$t(zt(B,S(e)),t),forEachRow:(e,t)=>Nt(zt(j,S(e)),((e,s)=>t(s,(t=>$t(e,t))))),forEachCell:(e,t,s)=>$t(zt(zt(j,S(e)),S(t)),s),forEachValue:e=>$t(G,e),addSortedRowIdsListener:(e,t,s,l,a,n,r)=>{let o=wt(e,t,s,l,a);return we((()=>{const r=wt(e,t,s,l,a);var i,d,u;d=o,Q(i=r)===Q(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,n(ws,e,t,s,l,a,o))}),ie[r?1:0],[e,t],[It])},addStartTransactionListener:e=>we(e,pe),addWillFinishTransactionListener:e=>we(e,fe[0]),addDidFinishTransactionListener:e=>we(e,fe[1]),callListener:e=>(ve(e),ws),delListener:e=>(Ce(e),ws),getListenerStats:()=>({tables:ts(K),tableIds:ts(X),tableCellIds:ts(_),table:ts(Y),rowCount:ts(ee),rowIds:ts(oe),sortedRowIds:ts(ie),row:ts(de,kt),cellIds:ts(ue,kt),cell:ts(ce,St),invalidCell:ts(he,St),values:ts(be),valueIds:ts(ge),value:ts(Ie),invalidValue:ts(me),transaction:Tt(pe)+ts(fe)}),createStore:os,addListener:we,callListeners:ye};return le({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[It]],[h+w]:[1,_,[It]],[I]:[1,ee,[It]],[p]:[1,oe,[It]],[g]:[2,de,[It,ft]],[w]:[2,ue,[It,ft]],[f]:[3,ce,[It,ft,yt],e=>es(Ct(...e))],InvalidCell:[3,he],[C]:[0,be],[v]:[0,ge],[y]:[1,Ie,[Wt],e=>es(Ut(e[0]))],InvalidValue:[1,me]},(([e,t,s,l],a)=>{ws["add"+a+"Listener"]=(...a)=>we(a[e],t[a[e+1]?1:0],e>0?W(a,0,e):void 0,s,l)})),Z(ws)},is=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(os),a=de.indexOf(e);return s.useCreatePersister(l,(e=>{return((e,t,s,l)=>((e,t,s,l,a,n,r=[])=>{let o,i,d,u=0,c=0,h=0,m=0;At(Wt,r,(()=>0)),At(Ut,r,(()=>[]));const b=async e=>(2!=u&&(u=1,c++,await g.schedule((async()=>{await e(),u=0}))),g),g={load:async(s,l)=>await b((async()=>{try{e.setContent(await t())}catch{e.setContent([s,l])}})),startAutoLoad:async(s={},a={})=>(g.stopAutoLoad(),await g.load(s,a),m=1,d=l((async(s,l)=>{if(l){const t=l();await b((async()=>e.setTransactionChanges(t)))}else await b((async()=>{try{e.setContent(s?.()??await t())}catch(e){n?.(e)}}))})),g),stopAutoLoad:()=>(m&&(a(d),d=void 0,m=0),g),save:async t=>(1!=u&&(u=2,h++,await g.schedule((async()=>{try{await s(e.getContent,t)}catch(e){n?.(e)}u=0}))),g),startAutoSave:async()=>(await g.stopAutoSave().save(),o=e.addDidFinishTransactionListener(((e,t)=>{const[s,l]=t();ae(s)&&ae(l)||g.save((()=>[s,l]))})),g),stopAutoSave:()=>(N(o,e.delListener),g),schedule:async(...e)=>(U(zt(Ut,r),...e),await(async()=>{if(!zt(Wt,r)){for(Ot(Wt,r,1);!q(i=G(zt(Ut,r)));)try{await i()}catch(e){n?.(e)}Ot(Wt,r,0)}})(),g),getStore:()=>e,destroy:()=>g.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(g)})(e,(async()=>re(s.getItem(t))),(async e=>s.setItem(t,ne(e()))),(e=>{const l=l=>{l.storageArea===s&&l.key===t&&e((()=>re(l.newValue)))};return Kt.addEventListener(Gt,l),l}),(e=>Kt.removeEventListener(Gt,e)),l))(e,oe,sessionStorage,t);var t}),void 0,(async e=>{await e.load(void 0,{position:-1==a?1:a,open:!!t}),await e.startAutoSave()})),O($,null,O("aside",{id:oe},O(Ne,{s:l}),O(yt,{s:l})),O("style",null,qe))};e.EditableCellView=st,e.EditableValueView=lt,e.RelationshipInHtmlTable=et,e.ResultSortedTableInHtmlTable=tt,e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:l,...a})=>O(Ue,{...a,params:He(We(s.useResultTableCellIds(e,t),l,s.ResultCellView),Qe(t,e),s.useResultRowIds(e,t))}),e.SliceInHtmlTable=_e,e.SortedTableInHtmlTable=Ye,e.SortedTablePaginator=at,e.StoreInspector=e=>O(is,{...e}),e.TableInHtmlTable=({tableId:e,store:t,editable:l,customCells:a,...n})=>O(Ue,{...n,params:He(We(s.useTableCellIds(e,t),a,l?st:s.CellView),De(t,e),s.useRowIds(e,t))}),e.ValuesInHtmlTable=Ze},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
1
+ var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,a="",n=l(a),r=l(!0),o=l(0),i=l(l),d="type",u="default",c="Ids",h="Table",m=h+"s",b=h+c,g="Row",I=g+"Count",p=g+c,f="Cell",w=f+c,y="Value",C=y+"s",v=y+c,k="currentTarget",T="value",S=e=>a+e,x=Math.floor,V=isFinite,R=(e,t)=>e instanceof t,q=e=>null==e,N=(e,t,s)=>q(e)?s?.():t(e),L=e=>e==n||e==r,M=e=>l(e)==i,E=e=>Array.isArray(e),{PureComponent:z,Fragment:$,createElement:O,useCallback:A,useLayoutEffect:F,useRef:J,useState:P}=t,B=(e,...t)=>q(e)?{}:e(...t),H=(e,t)=>e.forEach(t),D=(e,t)=>e.map(t),Q=e=>e.length,j=e=>0==Q(e),W=(e,t,s)=>e.slice(t,s),U=(e,...t)=>e.push(...t),G=e=>e.shift(),K=Object,X=K.keys,Y=K.isFrozen,Z=K.freeze,_=e=>R(e,K)&&e.constructor==K,ee=(e=[])=>K.fromEntries(e),te=(e,t)=>!q(((e,t)=>N(e,(e=>e[t])))(e,t)),se=(e,t)=>(delete e[t],e),le=(e,t)=>D(K.entries(e),(([e,s])=>t(s,e))),ae=e=>_(e)&&0==(e=>Q(X(e)))(e),ne=e=>JSON.stringify(e,((e,t)=>R(t,Map)?K.fromEntries([...t]):t)),re=JSON.parse,oe="tinybaseStoreInspector",ie="TinyBase Store Inspector",de=["left","top","bottom","right","full"],ue="state",ce="sort",he="open",me="position",be=he,ge="editable",Ie=(...e)=>ne(e),pe=(e,t)=>D(e.sort(),t),fe=(e,t)=>[!!s.useCell(ue,e,ge,t),A((s=>{t.setCell(ue,e,ge,(e=>!e)),s.preventDefault()}),[t,e])],we="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',Ce=ye+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ve='</svg>")',ke=ye+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Te=D([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Ce+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+ve)),Se=Ce+"<path d='M20 20l60 60M20 80l60-60' />"+ve,xe=Ce+`<path d='${we}' />`+ve,Ve=Ce+`<path d='${we}M20 20l60 60' />`+ve,Re="*::-webkit-scrollbar",qe=`#${oe}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,t="")=>e.join(t))(le({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Re]:"width:0.5rem;height:0.5rem;",[Re+"-track"]:"background:#111",[Re+"-thumb"]:"background:#999;border:1px solid #111",[Re+"-thumb:hover"]:"background:#fff",[Re+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+ke,...ee(D(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...ee(D(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":ke,"header>img:nth-of-type(6)":Se,...ee(D(Te,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":xe,"details[open]>summary img.done":Ve,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem","th,td":"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`& ${t}{${e}}`:"")))}`,Ne=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!0),[],e);return s.useValue(be,e)?null:O("img",{onClick:l,title:ie,"data-position":t})},Le=({uniqueId:e,summary:t,editable:l,handleEditable:a,children:n,s:r})=>{const o=!!s.useCell(ue,e,he,r),i=s.useSetCellCallback(ue,e,he,(e=>e[k].open),[],r);return O("details",{open:o,onToggle:i},O("summary",null,t,a?O("img",{onClick:a,className:l?"done":"edit"}):null),n)},Me=e=>{const t=l(e);return L(t)||t==o&&V(e)?t:void 0},Ee=(e,t,s,l,a)=>q(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),ze=(e,t,s)=>q(s)?e.delValue(t):e.setValue(t,s),$e=(e,t,s,l)=>e==n?t:e==o?s:l,{useCallback:Oe,useMemo:Ae,useState:Fe}=t,Je="editable",Pe=(e,t)=>D(s.useTableCellIds(e,t),(t=>e+"."+t)),Be=(e,t,s)=>{const l=Oe(e,t);return s?l:void 0},He=(...e)=>Ae((()=>e),e),De=(e,t)=>Ae((()=>({store:e,tableId:t})),[e,t]),Qe=(e,t)=>Ae((()=>({queries:e,queryId:t})),[e,t]),je=(e,t=!1,s,l=0,a,n,r,o)=>{const[[i,d,u],c]=Fe([e,t,l]),h=Oe((e=>{c(e),o?.(e)}),[o]),m=Be((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),b=Oe((e=>h([i,d,e])),[h,i,d]),g=!0===r?at:r;return[[i,d,u],m,Ae((()=>!1===r?null:O(g,{offset:u,limit:a,total:n,onChange:b})),[r,g,u,a,n,b])]},We=(e,t,s)=>Ae((()=>{const a=t??e;return ee(le(E(a)?ee(D(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:s,...(a=e,l(a)==n?{label:e}:e)}];var a})))}),[t,s,e]),Ue=({className:e,headerRow:t,idColumn:s,params:[l,a,n,r,o,i]})=>O("table",{className:e},i?O("caption",null,i):null,!1===t?null:O("thead",null,O("tr",null,!1===s?null:O(Ge,{sort:r??[],label:"Id",onClick:o}),le(l,(({label:e},t)=>O(Ge,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),O("tbody",null,D(n,(e=>O("tr",{key:e},!1===s?null:O("th",null,e),le(l,(({component:t,getComponentProps:s},l)=>O("td",{key:l},O(t,{...B(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:l=e??a,onClick:n})=>O("th",{onClick:Be((()=>n?.(e)),[n,e],n),className:q(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},q(s)||t!=e?null:(s?"↓":"↑")+" ",l),Ke=({localRowId:e,params:[l,a,n,r,o,i,d]})=>{const u=s.useRemoteRowId(o,e,i);return O("tr",null,!1===l?null:O(t.Fragment,null,O("th",null,e),O("th",null,u)),le(a,(({component:t,getComponentProps:s},l)=>{const[a,o]=l.split(".",2),i=a===n?e:a===r?u:null;return q(i)?null:O("td",{key:l},O(t,{...B(s,i,o),store:d,tableId:a,rowId:i,cellId:o}))})))},Xe=({thing:e,onThingChange:t,className:s,hasSchema:l})=>{const[a,i]=Fe(),[d,u]=Fe(),[c,h]=Fe(),[m,b]=Fe(),[g,I]=Fe();d!==e&&(i(Me(e)),u(e),h(e+""),b(Number(e)||0),I(!!e));const p=Oe(((e,s)=>{s(e),u(e),t(e)}),[t]);return O("div",{className:s},O("button",{className:a,onClick:Oe((()=>{if(!l?.()){const e=$e(a,o,r,n),s=$e(e,c,m,g);i(e),u(s),t(s)}}),[l,t,c,m,g,a])},a),$e(a,O("input",{key:a,value:c,onChange:Oe((e=>p(e[k][T]+"",h)),[p])}),O("input",{key:a,type:"number",value:m,onChange:Oe((e=>p(Number(e[k][T]||0),b)),[p])}),O("input",{key:a,type:"checkbox",checked:g,onChange:Oe((e=>p(!!e[k].checked,I)),[p])})))},Ye=({tableId:e,cellId:t,descending:l,offset:a,limit:n,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,b,g]=je(t,l,i,a,n,s.useRowCount(e,r),d,u);return O(Ue,{...h,params:He(We(s.useTableCellIds(e,r),c,o?st:s.CellView),De(r,e),s.useSortedRowIds(e,...m,n,r),m,b,g)})},Ze=({store:e,editable:t=!1,valueComponent:l=(t?lt:s.ValueView),getValueComponentProps:a,className:n,headerRow:r,idColumn:o})=>O("table",{className:n},!1===r?null:O("thead",null,O("tr",null,!1===o?null:O("th",null,"Id"),O("th",null,y))),O("tbody",null,D(s.useValueIds(e),(t=>O("tr",{key:t},!1===o?null:O("th",null,t),O("td",null,O(l,{...B(a,t),valueId:t,store:e}))))))),_e=({indexId:e,sliceId:t,indexes:l,editable:a,customCells:n,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return O(Ue,{...r,params:He(We(s.useTableCellIds(d,i),n,a?st:s.CellView),De(i,d),s.useSliceRowIds(e,t,o))})},et=({relationshipId:e,relationships:l,editable:a,customCells:n,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=We([...Pe(c,u),...Pe(h,u)],n,a?st:s.CellView),b=He(i,m,c,h,e,d,u);return O("table",{className:r},!1===o?null:O("thead",null,O("tr",null,!1===i?null:O(t.Fragment,null,O("th",null,c,".Id"),O("th",null,h,".Id")),le(m,(({label:e},t)=>O("th",{key:t},e))))),O("tbody",null,D(s.useRowIds(c,u),(e=>O(Ke,{key:e,localRowId:e,params:b})))))},tt=({queryId:e,cellId:t,descending:l,offset:a,limit:n,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,b]=je(t,l,o,a,n,s.useResultRowCount(e,r),i,u);return O(Ue,{...c,params:He(We(s.useResultTableCellIds(e,r),d,s.ResultCellView),Qe(r,e),s.useResultSortedRowIds(e,...h,n,r),h,m,b)})},st=({tableId:e,rowId:t,cellId:l,store:a,className:n})=>O(Xe,{thing:s.useCell(e,t,l,a),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],a),className:n??Je+f,hasSchema:s.useStoreOrStoreById(a)?.hasTablesSchema}),lt=({valueId:e,store:t,className:l})=>O(Xe,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Je+y,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),at=({onChange:e,total:s,offset:l=0,limit:a=s,singular:n="row",plural:r=n+"s"})=>{(l>s||l<0)&&(l=0,e(0));const o=Be((()=>e(l-a)),[e,l,a],l>0),i=Be((()=>e(l+a)),[e,l,a],l+a<s);return O(t.Fragment,null,s>a&&O(t.Fragment,null,O("button",{className:"previous",disabled:0==l,onClick:o},"←"),O("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",Math.min(s,l+a)," of "),s," ",1!=s?r:n)},nt=({indexes:e,indexesId:t,indexId:l,s:a})=>O(Le,{uniqueId:Ie("i",t,l),summary:"Index: "+l,s:a},D(s.useSliceIds(l,e),(s=>O(rt,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:a,key:s})))),rt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=Ie("i",t,s,l),[r,o]=fe(n,a);return O(Le,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},O(_e,{sliceId:l,indexId:s,indexes:e,editable:r}))},ot=({indexesId:e,s:t})=>{const l=s.useIndexes(e),a=s.useIndexIds(l);return q(l)?null:O(Le,{uniqueId:Ie("i",e),summary:"Indexes: "+(e??u),s:t},j(a)?"No indexes defined":pe(a,(s=>O(nt,{indexes:l,indexesId:e,indexId:s,s:t,key:s}))))},it=({metrics:e,metricId:t})=>O("tr",null,O("th",null,t),O("td",null,e?.getTableId(t)),O("td",null,s.useMetric(t,e))),dt=({metricsId:e,s:t})=>{const l=s.useMetrics(e),a=s.useMetricIds(l);return q(l)?null:O(Le,{uniqueId:Ie("m",e),summary:"Metrics: "+(e??u),s:t},j(a)?"No metrics defined":O("table",null,O("thead",null,O("th",null,"Metric Id"),O("th",null,"Table Id"),O("th",null,"Metric")),O("tbody",null,D(a,(e=>O(it,{metrics:l,metricId:e,key:e}))))))},ut=({queries:e,queriesId:t,queryId:l,s:a})=>{const n=Ie("q",t,l),[r,o,i]=re(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a);return O(Le,{uniqueId:n,summary:"Query: "+l,s:a},O(tt,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ct=({queriesId:e,s:t})=>{const l=s.useQueries(e),a=s.useQueryIds(l);return q(l)?null:O(Le,{uniqueId:Ie("q",e),summary:"Queries: "+(e??u),s:t},j(a)?"No queries defined":pe(a,(s=>O(ut,{queries:l,queriesId:e,queryId:s,s:t,key:s}))))},ht=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=Ie("r",t,s),[n,r]=fe(a,l);return O(Le,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},O(et,{relationshipId:s,relationships:e,editable:n}))},mt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),a=s.useRelationshipIds(l);return q(l)?null:O(Le,{uniqueId:Ie("r",e),summary:"Relationships: "+(e??u),s:t},j(a)?"No relationships defined":pe(a,(s=>O(ht,{relationships:l,relationshipsId:e,relationshipId:s,s:t,key:s}))))},bt=({tableId:e,store:t,storeId:l,s:a})=>{const n=Ie("t",l,e),[r,o,i]=re(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a),[u,c]=fe(n,a);return O(Le,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},O(Ye,{tableId:e,store:t,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},gt=({store:e,storeId:t,s:l})=>{const a=Ie("v",t),[n,r]=fe(a,l);return j(s.useValueIds(e))?null:O(Le,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},O(Ze,{store:e,editable:n}))},It=({storeId:e,s:t})=>{const l=s.useStore(e),a=s.useTableIds(l);return q(l)?null:O(Le,{uniqueId:Ie("s",e),summary:"Store: "+(e??u),s:t},O(gt,{storeId:e,store:l,s:t}),pe(a,(s=>O(bt,{store:l,storeId:e,tableId:s,s:t,key:s}))))},pt=({s:e})=>{const t=J(null),l=J(0),[a,n]=P(!1),{scrollLeft:r,scrollTop:o}=s.useValues(e);F((()=>{const e=t.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=x(r)+e.clientWidth&&e.scrollHeight>=x(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,r,o]);const i=A((t=>{const{scrollLeft:s,scrollTop:a}=t[k];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),b=s.useIndexesIds(),g=s.useRelationships(),I=s.useRelationshipsIds(),p=s.useQueries(),f=s.useQueriesIds();return q(d)&&j(u)&&q(c)&&j(h)&&q(m)&&j(b)&&q(g)&&j(I)&&q(p)&&j(f)?O("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):O("article",{ref:t,onScroll:i},O(It,{s:e}),D(u,(t=>O(It,{storeId:t,s:e,key:t}))),O(dt,{s:e}),D(h,(t=>O(dt,{metricsId:t,s:e,key:t}))),O(ot,{s:e}),D(b,(t=>O(ot,{indexesId:t,s:e,key:t}))),O(mt,{s:e}),D(I,(t=>O(mt,{relationshipsId:t,s:e,key:t}))),O(ct,{s:e}),D(f,(t=>O(ct,{queriesId:t,s:e,key:t}))))};class ft extends z{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError=()=>({e:1});componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?O("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const wt=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!1),[],e),a=s.useSetValueCallback(me,(e=>Number(e[k].dataset.id)),[],e);return O("header",null,O("img",{title:ie}),O("span",null,ie),D(de,((e,s)=>s==t?null:O("img",{onClick:a,"data-id":s,title:"Dock to "+e,key:s}))),O("img",{onClick:l,title:"Close"}))},yt=({s:e})=>{const t=s.useValue(me,e)??1;return s.useValue(be,e)?O("main",{"data-position":t},O(wt,{s:e}),O(ft,null,O(pt,{s:e}))):null},Ct=e=>t=>{return s=(t,s)=>t+e(s),Rt(t).reduce(s,0);var s},vt=e=>e?.size??0,kt=Ct(vt),Tt=Ct(kt),St=Ct(Tt),xt=(e,t)=>e?.has(t)??!1,Vt=e=>q(e)||0==vt(e),Rt=e=>[...e?.values()??[]],qt=e=>e.clear(),Nt=(e,t)=>e?.forEach(t),Lt=(e,t)=>e?.delete(t),Mt=e=>new Map(e),Et=e=>[...e?.keys()??[]],zt=(e,t)=>e?.get(t),$t=(e,t)=>Nt(e,((e,s)=>t(s,e))),Ot=(e,t,s)=>q(s)?(Lt(e,t),e):e?.set(t,s),At=(e,t,s)=>(xt(e,t)||Ot(e,t,s()),zt(e,t)),Ft=(e,t,s,l=Ot)=>(le(t,((t,l)=>s(e,l,t))),$t(e,(s=>te(t,s)?0:l(e,s))),e),Jt=(e,t,s)=>{const l={};return Nt(e,((e,a)=>{const n=t?t(e,a):e;!s?.(n,e)&&(l[a]=n)})),l},Pt=(e,t,s)=>Jt(e,(e=>Jt(e,t,s)),ae),Bt=(e,t,s)=>Jt(e,(e=>Pt(e,t,s)),ae),Ht=(e,t)=>{const s=Mt();return Nt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Dt=e=>Ht(e,Ht),Qt=e=>Ht(e,Dt),jt=(e,t,s,l,a=0)=>N((s?At:zt)(e,t[a],a>Q(t)-2?s:Mt),(n=>{if(a>Q(t)-2)return l?.(n)&&Ot(e,t[a]),n;const r=jt(n,t,s,l,a+1);return Vt(n)&&Ot(e,t[a]),r})),Wt=Mt(),Ut=Mt(),Gt="storage",Kt=globalThis.window,Xt=e=>new Set(E(e)||q(e)?e:[e]),Yt=(e,t)=>e?.add(t),Zt=/^\d+$/,_t=()=>{const e=[];let t=0;return[s=>(s?G(e):null)??a+t++,t=>{Zt.test(t)&&Q(e)<1e3&&U(e,t)}]},es=e=>[e,e],ts=(e,t=kt)=>t(e[0])+t(e[1]),ss=()=>[Mt(),Mt()],ls=e=>[...e],as=([e,t])=>e===t,ns=(e,t,s)=>q(e)||!_(e)||ae(e)||Y(e)?(s?.(),!1):(le(e,((s,l)=>{t(s,l)||se(e,l)})),!ae(e)),rs=(e,t,s)=>Ot(e,t,zt(e,t)==-s?void 0:s),os=()=>{let e,t,s=!1,l=!1,n=0;const r=Mt(),i=Mt(),c=Mt(),k=Mt(),T=Mt(),x=Mt(),V=Mt(),R=Mt(),E=Mt(),z=Mt(),$=Mt(),O=Mt(),A=Mt(),F=Mt(),J=Xt(),P=Mt(),B=Mt(),j=Mt(),G=Mt(),K=ss(),X=ss(),Y=ss(),_=ss(),ee=ss(),oe=ss(),ie=ss(),de=ss(),ue=ss(),ce=ss(),he=ss(),me=ss(),be=ss(),ge=ss(),Ie=ss(),pe=Mt(),fe=ss(),[we,ye,Ce,ve]=(e=>{let t;const[s,l]=_t(),n=Mt();return[(e,l,r,o=[],i=(()=>[]))=>{t??=ws;const d=s(1);return Ot(n,d,[e,l,r,o,i]),Yt(jt(l,r??[a],Xt),d),d},(e,s,...l)=>H(((e,t=[a])=>{const s=[],l=(e,a)=>a==Q(t)?U(s,e):null===t[a]?Nt(e,(e=>l(e,a+1))):H([t[a],null],(t=>l(zt(e,t),a+1)));return l(e,0),s})(e,s),(e=>Nt(e,(e=>zt(n,e)[0](t,...s??[],...l))))),e=>N(zt(n,e),(([,t,s])=>(jt(t,s??[a],void 0,(t=>(Lt(t,e),Vt(t)?1:0))),Ot(n,e),l(e),s))),e=>N(zt(n,e),(([e,,s=[],l,a])=>{const n=(...r)=>{const o=Q(r);o==Q(s)?e(t,...r,...a(r)):q(s[o])?H(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),ke=e=>{if(!ns(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!L(t)&&t!=o||(Me(e[u])!=t&&se(e,u),0))},Te=(t,s)=>(!e||xt($,s)||lt(s))&&ns(t,((e,t)=>Se(s,t,e)),(()=>lt(s))),Se=(e,t,s,l)=>ns(l?s:qe(s,e,t),((l,a)=>N(xe(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>lt(e,t))),xe=(t,s,l,a)=>e?N(zt(zt($,t),l),(e=>Me(a)!=e[d]?lt(t,s,l,a,e[u]):a),(()=>lt(t,s,l,a))):q(Me(a))?lt(t,s,l,a):a,Ve=(e,t)=>ns(t?e:Ne(e),((t,s)=>N(Re(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>at())),Re=(e,s)=>t?N(zt(A,e),(t=>Me(s)!=t[d]?at(e,s,t[u]):s),(()=>at(e,s))):q(Me(s))?at(e,s):s,qe=(e,t,s)=>(N(zt(O,t),(([l,a])=>{Nt(l,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(a,(l=>{te(e,l)||lt(t,s,l)}))})),e),Ne=e=>(t&&(Nt(F,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(J,(t=>{te(e,t)||at(t)}))),e),Le=e=>Ft($,e,((e,t,s)=>{const l=Mt(),a=Xt();Ft(At($,t,Mt),s,((e,t,s)=>{Ot(e,t,s),N(s[u],(e=>Ot(l,t,e)),(()=>Yt(a,t)))})),Ot(O,t,[l,a])}),((e,t)=>{Ot($,t),Ot(O,t)})),$e=e=>Ft(A,e,((e,t,s)=>{Ot(A,t,s),N(s[u],(e=>Ot(F,t,e)),(()=>Yt(J,t)))}),((e,t)=>{Ot(A,t),Ot(F,t),Lt(J,t)})),Oe=e=>ae(e)?us():Gt(e),Ae=e=>Ft(j,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ue(t))),Fe=(e,t)=>Ft(At(j,e,(()=>(Ye(e,1),Ot(P,e,_t()),Ot(B,e,Mt()),Mt()))),t,((t,s,l)=>Je(e,t,s,l)),((t,s)=>Ge(e,t,s))),Je=(e,t,s,l,a)=>Ft(At(t,s,(()=>(Ze(e,s,1),Mt()))),l,((t,l,a)=>Pe(e,s,t,l,a)),((l,n)=>Ke(e,t,s,l,n,a))),Pe=(e,t,s,l,a)=>{xt(s,l)||_e(e,t,l,1);const n=zt(s,l);a!==n&&(et(e,t,l,n,a),Ot(s,l,a))},Be=(e,t,s,l,a)=>N(zt(t,s),(t=>Pe(e,s,t,l,a)),(()=>Je(e,t,s,qe({[l]:a},e,s)))),He=e=>ae(e)?ms():Kt(e),De=e=>Ft(G,e,((e,t,s)=>Qe(t,s)),((e,t)=>Xe(t))),Qe=(e,t)=>{xt(G,e)||tt(e,1);const s=zt(G,e);t!==s&&(st(e,s,t),Ot(G,e,t))},je=(e,t)=>{const[s]=zt(P,e),l=s(t);return xt(zt(j,e),l)?je(e,t):l},We=e=>zt(j,e)??Fe(e,{}),Ue=e=>Fe(e,{}),Ge=(e,t,s)=>{const[,l]=zt(P,e);l(s),Je(e,t,s,{},!0)},Ke=(e,t,s,l,a,n)=>{const r=zt(zt(O,e)?.[0],a);if(!q(r)&&!n)return Pe(e,s,l,a,r);const o=t=>{et(e,s,t,zt(l,t)),_e(e,s,t,-1),Ot(l,t)};q(r)?o(a):$t(l,o),Vt(l)&&(Ze(e,s,-1),Vt(Ot(t,s))&&(Ye(e,-1),Ot(j,e),Ot(P,e),Ot(B,e)))},Xe=e=>{const t=zt(F,e);if(!q(t))return Qe(e,t);st(e,zt(G,e)),tt(e,-1),Ot(G,e)},Ye=(e,t)=>rs(r,e,t),Ze=(e,t,s)=>rs(At(k,e,Mt),t,s)&&Ot(c,e,At(c,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=zt(B,e),n=zt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&rs(At(i,e,Mt),s,l),Ot(a,s,n!=-l?n+l:null),rs(At(At(T,e,Mt),t,Mt),s,l)},et=(e,t,s,l,a)=>At(At(At(x,e,Mt),t,Mt),s,(()=>[l,0]))[1]=a,tt=(e,t)=>rs(V,e,t),st=(e,t,s)=>At(R,e,(()=>[t,0]))[1]=s,lt=(e,t,s,l,a)=>(U(At(At(At(E,e,Mt),t,Mt),s,(()=>[])),l),a),at=(e,t,s)=>(U(At(z,e,(()=>[])),t),s),nt=(e,t,s)=>N(zt(zt(zt(x,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ct(e,t,s))])),rt=e=>N(zt(R,e),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ut(e))])),ot=e=>Vt(E)||Vt(he[e])?0:Nt(e?Qt(E):E,((t,s)=>Nt(t,((t,l)=>Nt(t,((t,a)=>ye(he[e],[s,l,a],t))))))),it=e=>Vt(z)||Vt(me[e])?0:Nt(e?Ht(z):z,((t,s)=>ye(me[e],[s],t))),dt=(e,t,s)=>{if(!Vt(t))return ye(e,s,(()=>Jt(t))),1},ut=e=>{const t=Vt(ie[e]),s=Vt(ue[e])&&Vt(_[e])&&Vt(ee[e])&&Vt(oe[e])&&t&&Vt(X[e]),l=Vt(ce[e])&&Vt(de[e])&&Vt(Y[e])&&Vt(K[e]);if(!s||!l){const a=e?[Ht(r),Dt(i),Ht(c),Dt(k),Qt(T),Qt(x)]:[r,i,c,k,T,x];if(!s){dt(X[e],a[0]),Nt(a[1],((t,s)=>dt(_[e],t,[s]))),Nt(a[2],((t,s)=>{0!=t&&ye(ee[e],[s],pt(s))}));const s=Xt();Nt(a[3],((l,a)=>{dt(oe[e],l,[a])&&!t&&(ye(ie[e],[a,null]),Yt(s,a))})),t||Nt(a[5],((t,l)=>{if(!xt(s,l)){const s=Xt();Nt(t,(e=>Nt(e,(([t,l],a)=>l!==t?Yt(s,a):Lt(e,a))))),Nt(s,(t=>ye(ie[e],[l,t])))}})),Nt(a[4],((t,s)=>Nt(t,((t,l)=>dt(ue[e],t,[s,l])))))}if(!l){let t;Nt(a[5],((s,l)=>{let a;Nt(s,((s,n)=>{let r;Nt(s,(([s,o],i)=>{o!==s&&(ye(ce[e],[l,n,i],o,s,nt),t=a=r=1)})),r&&ye(de[e],[l,n],nt)})),a&&ye(Y[e],[l],nt)})),t&&ye(K[e],void 0,nt)}}},ct=e=>{const t=Vt(ge[e]),s=Vt(Ie[e])&&Vt(be[e]);if(!t||!s){const l=e?[Ht(V),Ht(R)]:[V,R];if(t||dt(ge[e],l[0]),!s){let t;Nt(l[1],(([s,l],a)=>{l!==s&&(ye(Ie[e],[a],l,s,rt),t=1)})),t&&ye(be[e],void 0,rt)}}},ht=(e,...t)=>(Is((()=>e(...D(t,S)))),ws),mt=()=>[Jt(x,((e,t)=>-1===zt(r,t)?null:Jt(e,((e,s)=>-1===zt(zt(k,t),s)?null:Jt(e,(([,e])=>e??null),((e,t)=>as(t)))),ae)),ae),Jt(R,(([,e])=>e??null),((e,t)=>as(t)))],bt=()=>({cellsTouched:s,valuesTouched:l,changedCells:Bt(x,ls,as),invalidCells:Bt(E),changedValues:Jt(R,ls,as),invalidValues:Jt(z),changedTableIds:Jt(r),changedRowIds:Pt(k),changedCellIds:Bt(T),changedValueIds:Jt(V)}),gt=()=>Bt(j),It=()=>Et(j),pt=e=>vt(zt(j,S(e))),ft=e=>Et(zt(j,S(e))),wt=(e,t,s,l=0,a)=>{return D(W((r=zt(j,S(e)),o=(e,s)=>[q(t)?s:zt(e,S(t)),s],n=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),D([...r?.entries()??[]],(([e,t])=>o(t,e))).sort(n)),l,q(a)?a:l+a),(([,e])=>e));var n,r,o},yt=(e,t)=>Et(zt(zt(j,S(e)),S(t))),Ct=(e,t,s)=>zt(zt(zt(j,S(e)),S(t)),S(s)),Rt=()=>Jt(G),Wt=()=>Et(G),Ut=e=>zt(G,S(e)),Gt=e=>ht((()=>(e=>ns(e,Te,lt))(e)?Ae(e):0)),Kt=e=>ht((()=>Ve(e)?De(e):0)),Zt=e=>{try{Oe(re(e))}catch{}return ws},is=t=>ht((()=>{if((e=ns(t,(e=>ns(e,ke))))&&(Le(t),!Vt(j))){const e=gt();us(),Gt(e)}})),ds=e=>ht((()=>{if(t=(e=>ns(e,ke))(e)){const s=Rt();gs(),ms(),t=!0,$e(e),Kt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>xt(j,e)?Ue(e):0),e),hs=(e,t)=>ht(((e,t)=>N(zt(j,e),(s=>xt(s,t)?Ge(e,s,t):0))),e,t),ms=()=>ht((()=>De({}))),bs=()=>ht((()=>{Le({}),e=!1})),gs=()=>ht((()=>{$e({}),t=!1})),Is=(e,t)=>{if(-1!=n){ps();const s=e();return fs(t),s}},ps=()=>(-1!=n&&n++,1==n&&ye(pe,void 0,mt,bt),ws),fs=e=>(n>0&&(n--,0==n&&(s=!Vt(x),l=!Vt(R),n=1,ot(1),s&&ut(1),it(1),l&&ct(1),e?.(mt,bt)&&(Nt(x,((e,t)=>Nt(e,((e,s)=>Nt(e,(([e],l)=>Ee(ws,t,s,l,e))))))),Nt(R,(([e],t)=>ze(ws,t,e))),s=l=!1),ye(fe[0],void 0,mt,bt),n=-1,ot(0),s&&ut(0),it(0),l&&ct(0),ye(fe[1],void 0,mt,bt),n=0,s=l=!1,H([r,i,c,k,T,x,E,V,R,z],qt))),ws),ws={getContent:()=>[gt(),Rt()],getTables:gt,getTableIds:It,getTable:e=>Pt(zt(j,S(e))),getTableCellIds:e=>Et(zt(B,S(e))),getRowCount:pt,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Jt(zt(zt(j,S(e)),S(t))),getCellIds:yt,getCell:Ct,getValues:Rt,getValueIds:Wt,getValue:Ut,hasTables:()=>!Vt(j),hasTable:e=>xt(j,S(e)),hasTableCell:(e,t)=>xt(zt(B,S(e)),S(t)),hasRow:(e,t)=>xt(zt(j,S(e)),S(t)),hasCell:(e,t,s)=>xt(zt(zt(j,S(e)),S(t)),S(s)),hasValues:()=>!Vt(G),hasValue:e=>xt(G,S(e)),getTablesJson:()=>ne(j),getValuesJson:()=>ne(G),getJson:()=>ne([j,G]),getTablesSchemaJson:()=>ne($),getValuesSchemaJson:()=>ne(A),getSchemaJson:()=>ne([$,A]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ht((()=>{(ae(e)?us:Gt)(e),(ae(t)?ms:Kt)(t)})),setTables:Gt,setTable:(e,t)=>ht((e=>Te(t,e)?Fe(e,t):0),e),setRow:(e,t,s)=>ht(((e,t)=>Se(e,t,s)?Je(e,We(e),t,s):0),e,t),addRow:(e,t,s=!0)=>Is((()=>{let l;return Se(e,l,t)&&(e=S(e),Je(e,We(e),l=je(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>ht(((e,t)=>{if(Se(e,t,s,1)){const l=We(e);le(s,((s,a)=>Be(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>ht(((e,t,s)=>N(xe(e,t,s,M(l)?l(Ct(e,t,s)):l),(l=>Be(e,We(e),t,s,l)))),e,t,s),setValues:Kt,setPartialValues:e=>ht((()=>Ve(e,1)?le(e,((e,t)=>Qe(t,e))):0)),setValue:(e,t)=>ht((e=>N(Re(e,M(t)?t(Ut(e)):t),(t=>Qe(e,t)))),e),setTransactionChanges:e=>ht((()=>{le(e[0],((e,t)=>q(e)?cs(t):le(e,((e,s)=>q(e)?hs(t,s):le(e,((e,l)=>Ee(ws,t,s,l,e))))))),le(e[1],((e,t)=>ze(ws,t,e)))})),setTablesJson:Zt,setValuesJson:e=>{try{He(re(e))}catch{}return ws},setJson:e=>ht((()=>{try{const[t,s]=re(e);Oe(t),He(s)}catch{Zt(e)}})),setTablesSchema:is,setValuesSchema:ds,setSchema:(e,t)=>ht((()=>{is(e),ds(t)})),delTables:us,delTable:cs,delRow:hs,delCell:(e,t,s,l)=>ht(((e,t,s)=>N(zt(j,e),(a=>N(zt(a,t),(n=>xt(n,s)?Ke(e,a,t,n,s,l):0))))),e,t,s),delValues:ms,delValue:e=>ht((e=>xt(G,e)?Xe(e):0),e),delTablesSchema:bs,delValuesSchema:gs,delSchema:()=>ht((()=>{bs(),gs()})),transaction:Is,startTransaction:ps,finishTransaction:fs,forEachTable:e=>Nt(j,((t,s)=>e(s,(e=>Nt(t,((t,s)=>e(s,(e=>$t(t,e))))))))),forEachTableCell:(e,t)=>$t(zt(B,S(e)),t),forEachRow:(e,t)=>Nt(zt(j,S(e)),((e,s)=>t(s,(t=>$t(e,t))))),forEachCell:(e,t,s)=>$t(zt(zt(j,S(e)),S(t)),s),forEachValue:e=>$t(G,e),addSortedRowIdsListener:(e,t,s,l,a,n,r)=>{let o=wt(e,t,s,l,a);return we((()=>{const r=wt(e,t,s,l,a);var i,d,u;d=o,Q(i=r)===Q(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,n(ws,e,t,s,l,a,o))}),ie[r?1:0],[e,t],[It])},addStartTransactionListener:e=>we(e,pe),addWillFinishTransactionListener:e=>we(e,fe[0]),addDidFinishTransactionListener:e=>we(e,fe[1]),callListener:e=>(ve(e),ws),delListener:e=>(Ce(e),ws),getListenerStats:()=>({tables:ts(K),tableIds:ts(X),tableCellIds:ts(_),table:ts(Y),rowCount:ts(ee),rowIds:ts(oe),sortedRowIds:ts(ie),row:ts(de,Tt),cellIds:ts(ue,Tt),cell:ts(ce,St),invalidCell:ts(he,St),values:ts(be),valueIds:ts(ge),value:ts(Ie),invalidValue:ts(me),transaction:kt(pe)+ts(fe)}),createStore:os,addListener:we,callListeners:ye};return le({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[It]],[h+w]:[1,_,[It]],[I]:[1,ee,[It]],[p]:[1,oe,[It]],[g]:[2,de,[It,ft]],[w]:[2,ue,[It,ft]],[f]:[3,ce,[It,ft,yt],e=>es(Ct(...e))],InvalidCell:[3,he],[C]:[0,be],[v]:[0,ge],[y]:[1,Ie,[Wt],e=>es(Ut(e[0]))],InvalidValue:[1,me]},(([e,t,s,l],a)=>{ws["add"+a+"Listener"]=(...a)=>we(a[e],t[a[e+1]?1:0],e>0?W(a,0,e):void 0,s,l)})),Z(ws)},is=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(os),a=de.indexOf(e);return s.useCreatePersister(l,(e=>{return((e,t,s,l)=>((e,t,s,l,a,n,r=[])=>{let o,i,d,u=0,c=0,h=0,m=0;At(Wt,r,(()=>0)),At(Ut,r,(()=>[]));const b=async e=>(2!=u&&(u=1,c++,await g.schedule((async()=>{await e(),u=0}))),g),g={load:async(s,l)=>await b((async()=>{try{e.setContent(await t())}catch{e.setContent([s,l])}})),startAutoLoad:async(s={},a={})=>(g.stopAutoLoad(),await g.load(s,a),m=1,d=l((async(s,l)=>{if(l){const t=l();await b((async()=>e.setTransactionChanges(t)))}else await b((async()=>{try{e.setContent(s?.()??await t())}catch(e){n?.(e)}}))})),g),stopAutoLoad:()=>(m&&(a(d),d=void 0,m=0),g),save:async t=>(1!=u&&(u=2,h++,await g.schedule((async()=>{try{await s(e.getContent,t)}catch(e){n?.(e)}u=0}))),g),startAutoSave:async()=>(await g.stopAutoSave().save(),o=e.addDidFinishTransactionListener(((e,t)=>{const[s,l]=t();ae(s)&&ae(l)||g.save((()=>[s,l]))})),g),stopAutoSave:()=>(N(o,e.delListener),g),schedule:async(...e)=>(U(zt(Ut,r),...e),await(async()=>{if(!zt(Wt,r)){for(Ot(Wt,r,1);!q(i=G(zt(Ut,r)));)try{await i()}catch(e){n?.(e)}Ot(Wt,r,0)}})(),g),getStore:()=>e,destroy:()=>g.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(g)})(e,(async()=>re(s.getItem(t))),(async e=>s.setItem(t,ne(e()))),(e=>{const l=l=>{l.storageArea===s&&l.key===t&&e((()=>re(l.newValue)))};return Kt.addEventListener(Gt,l),l}),(e=>Kt.removeEventListener(Gt,e)),l))(e,oe,sessionStorage,t);var t}),void 0,(async e=>{await e.load(void 0,{position:-1==a?1:a,open:!!t}),await e.startAutoSave()})),O($,null,O("aside",{id:oe},O(Ne,{s:l}),O(yt,{s:l})),O("style",null,qe))};e.EditableCellView=st,e.EditableValueView=lt,e.RelationshipInHtmlTable=et,e.ResultSortedTableInHtmlTable=tt,e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:l,...a})=>O(Ue,{...a,params:He(We(s.useResultTableCellIds(e,t),l,s.ResultCellView),Qe(t,e),s.useResultRowIds(e,t))}),e.SliceInHtmlTable=_e,e.SortedTableInHtmlTable=Ye,e.SortedTablePaginator=at,e.StoreInspector=e=>O(is,{...e}),e.TableInHtmlTable=({tableId:e,store:t,editable:l,customCells:a,...n})=>O(Ue,{...n,params:He(We(s.useTableCellIds(e,t),a,l?st:s.CellView),De(t,e),s.useRowIds(e,t))}),e.ValuesInHtmlTable=Ze},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
Binary file
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u="Result",d="Ids",l="Table",n=l+"s",i=l+d,a="Row",I=a+"Count",c=a+d,C="Sorted"+a+d,p="Cell",b=p+d,w="Value",R=w+"s",k=w+d,g=e=>null==e,h=(e,s,t)=>g(e)?t?.():s(e),m=e=>t(e)==r,y=()=>{},L=(e,s)=>e.map(s),V=Object.keys,{createContext:S,useContext:T}=s,f=S([]),x=(e,s)=>{const t=T(f);return g(e)?t[s]:m(e)?((e,s)=>h(e,(e=>e[s])))(t[s+1]??{},e):e},v=(e,s)=>{const t=x(e,s);return g(e)||m(e)?t:e},P=e=>V(T(f)[e]??{}),q=e=>v(e,0),B=e=>v(e,2),M=e=>v(e,4),O=e=>v(e,6),Q=e=>v(e,8),D=e=>v(e,10),{useCallback:F,useEffect:A,useMemo:E,useRef:G,useState:j}=s,U=(e,s,t=[])=>{const o=E((()=>s(e)),[e,...t]);return A((()=>()=>o.destroy()),[o]),o},z=(e,s,t,o=[],r)=>{const[,u]=j(),d=F((()=>s?.["get"+e]?.(...o)??t),[s,...o]),[l]=j(d),n=G(l);return E((()=>n.current=d()),[d]),H(e,s,((...e)=>{n.current=g(r)?d():e[r],u([])}),[],o),n.current},H=(e,s,t,o=[],r=[],...u)=>A((()=>{const o=s?.["add"+e+"Listener"]?.(...r,t,...u);return()=>s?.delListener(o)}),[s,...r,...o,...u]),J=(e,s,t,o=[],r=y,u=[],...d)=>{const l=q(e);return F((e=>h(l,(o=>h(t(e,o),(e=>r(o["set"+s](...d,e),e)))))),[l,s,...o,...u,...d])},K=(e,s,t=y,o=[],...r)=>{const u=q(e);return F((()=>t(u?.["del"+s](...r))),[u,s,...o,...r])},N=(e,s,t)=>{const o=D(e);return F((()=>o?.[s](t)),[o,s,t])},W=e=>z(i,q(e),[],[]),X=(e,s)=>z(c,q(s),[],[e]),Y=(e,s,t,o=0,r,u)=>z(C,q(u),[],[e,s,t,o,r],6),Z=(e,s,t)=>z(b,q(t),[],[e,s]),$=(e,s,t,o)=>z(p,q(o),void 0,[e,s,t],4),_=e=>z(k,q(e),[],[]),ee=(e,s)=>z(w,q(s),void 0,[e]),se=(e,s)=>z("Metric",B(s),void 0,[e]),te=(e,s)=>z("SliceIds",M(s),[],[e]),oe=(e,s,t)=>z("Slice"+c,M(t),[],[e,s]),re=(e,s,t)=>z("RemoteRowId",O(t),void 0,[e,s]),ue=(e,s,t)=>z("Local"+c,O(t),[],[e,s]),de=(e,s,t)=>z("Linked"+c,O(t),[],[e,s]),le=(e,s)=>z(u+c,Q(s),[],[e]),ne=(e,s,t,o=0,r,d)=>z(u+C,Q(d),[],[e,s,t,o,r],6),ie=(e,s,t)=>z(u+b,Q(t),[],[e,s]),ae=(e,s,t,o)=>z(u+p,Q(o),void 0,[e,s,t]),Ie=e=>z("CheckpointIds",D(e),[[],void 0,[]]),ce=(e,s)=>z("Checkpoint",D(s),void 0,[e]),Ce=e=>N(e,"goBackward"),pe=e=>N(e,"goForward"),{PureComponent:be,Fragment:we,createElement:Re,useCallback:ke,useLayoutEffect:ge,useRef:he,useState:me}=s,ye=(e,...s)=>g(e)?{}:e(...s),Le=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useMemo:Ve}=s,Se=({tableId:e,store:s,rowComponent:t=qe,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:d},l)=>ve(L(l,(u=>Re(t,{...ye(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:d}))),u,d,e),Te=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:o,separator:r,debugIds:u},d)=>ve(L(d,(r=>Re(t,{...ye(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),fe=({relationshipId:e,relationships:s,rowComponent:t=qe,getRowComponentProps:o,separator:r,debugIds:u},d,l)=>{const[n,i,a]=Le(O(s),e),I=d(e,l,n);return ve(L(I,(e=>Re(t,{...ye(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:u}))),r,u,l)},xe=e=>({checkpoints:s,checkpointComponent:t=Fe,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const d=D(s);return ve(L(e(Ie(d)),(e=>Re(t,{...ye(o,e),key:e,checkpoints:d,checkpointId:e,debugIds:u}))),r)},ve=(e,s,t,o)=>{const r=g(s)||!Array.isArray(e)?e:L(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},Pe=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>ve(o+($(e,s,t,r)??o),void 0,u,t),qe=({tableId:e,rowId:s,store:t,cellComponent:o=Pe,getCellComponentProps:r,customCellIds:u,separator:d,debugIds:l})=>ve(L(((e,s,t,o)=>{const r=Z(s,t,o);return e??r})(u,e,s,t),(u=>Re(o,{...ye(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:l}))),d,l,s),Be=e=>Se(e,X(e.tableId,e.store)),Me=({valueId:e,store:s,debugIds:t})=>ve(o+(ee(e,s)??o),void 0,t,e),Oe=({indexId:e,sliceId:s,indexes:t,rowComponent:o=qe,getRowComponentProps:r,separator:u,debugIds:d})=>{const[l,n,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(M(t),e),a=oe(e,s,l);return ve(L(a,(e=>Re(o,{...ye(r,e),key:e,tableId:i,rowId:e,store:n,debugIds:d}))),u,d,s)},Qe=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>ve(o+(ae(e,s,t,r)??o),void 0,u,t),De=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Qe,getResultCellComponentProps:r,separator:u,debugIds:d})=>ve(L(ie(e,s,t),(u=>Re(o,{...ye(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:d}))),u,d,s),Fe=({checkpoints:e,checkpointId:s,debugIds:t})=>ve(ce(s,e)??o,void 0,t,s),Ae=xe((e=>e[0])),Ee=xe((e=>g(e[1])?[]:[e[1]])),Ge=xe((e=>e[2]));e.BackwardCheckpointsView=Ae,e.CellView=Pe,e.CheckpointView=Fe,e.CurrentCheckpointView=Ee,e.ForwardCheckpointsView=Ge,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Oe,getSliceComponentProps:o,separator:r,debugIds:u})=>ve(L(te(e,s),(r=>Re(t,{...ye(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>fe(e,de,e.firstRowId),e.LocalRowsView=e=>fe(e,ue,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>ve(se(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:t,metrics:o,metricsById:r,indexes:u,indexesById:d,relationships:l,relationshipsById:n,queries:i,queriesById:a,checkpoints:I,checkpointsById:c,children:C})=>{const p=s.useContext(f);return Re(f.Provider,{value:Ve((()=>[e??p[0],{...p[1],...t},o??p[2],{...p[3],...r},u??p[4],{...p[5],...d},l??p[6],{...p[7],...n},i??p[8],{...p[9],...a},I??p[10],{...p[11],...c}]),[e,t,o,r,u,d,l,n,i,a,I,c,p])},C)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=qe,getRowComponentProps:r,debugIds:u})=>{const[d,l,,n]=Le(O(t),e),i=re(e,s,d);return ve(g(n)||g(i)?null:Re(o,{...ye(r,i),key:i,tableId:n,rowId:i,store:l,debugIds:u}),void 0,u,s)},e.ResultCellView=Qe,e.ResultRowView=De,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>Te(r,ne(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>Te(e,le(e.queryId,e.queries)),e.RowView=qe,e.SliceView=Oe,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>Se(r,Y(r.tableId,e,s,t,o,r.store)),e.TableView=Be,e.TablesView=({store:e,tableComponent:s=Be,getTableComponentProps:t,separator:o,debugIds:r})=>ve(L(W(e),(o=>Re(s,{...ye(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=Me,e.ValuesView=({store:e,valueComponent:s=Me,getValueComponentProps:t,separator:o,debugIds:r})=>ve(L(_(e),(o=>Re(s,{...ye(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=[],o,r=y,u=[],d=!0)=>{const l=q(o);return F((t=>h(l,(o=>h(s(t,o),(s=>r(o.addRow(e,s,d),o,s)))))),[l,e,...t,...u,d])},e.useCell=$,e.useCellIds=Z,e.useCellIdsListener=(e,s,t,o,r,u)=>H(b,q(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,d)=>H(p,q(d),o,r,[e,s,t],u),e.useCheckpoint=ce,e.useCheckpointIds=Ie,e.useCheckpointIdsListener=(e,s,t)=>H("CheckpointIds",D(t),e,s),e.useCheckpointListener=(e,s,t,o)=>H("Checkpoint",D(o),s,t,[e]),e.useCheckpoints=e=>x(e,10),e.useCheckpointsIds=()=>P(11),e.useCheckpointsOrCheckpointsById=D,e.useCreateCheckpoints=(e,s,t)=>U(e,s,t),e.useCreateIndexes=(e,s,t)=>U(e,s,t),e.useCreateMetrics=(e,s,t)=>U(e,s,t),e.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,u]=j(),d=E((()=>s(e)),[e,...t]);return A((()=>((async()=>{await(o?.(d)),u(1)})(),()=>{d.destroy()})),[d,...r]),d},e.useCreateQueries=(e,s,t)=>U(e,s,t),e.useCreateRelationships=(e,s,t)=>U(e,s,t),e.useCreateStore=(e,s=[])=>E(e,s),e.useDelCellCallback=(e,s,t,o,r,u,d)=>K(r,p,u,d,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>K(t,a,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>K(s,l,t,o,e),e.useDelTablesCallback=(e,s,t)=>K(e,n,s,t),e.useDelValueCallback=(e,s,t,o)=>K(s,w,t,o,e),e.useDelValuesCallback=(e,s,t)=>K(e,R,s,t),e.useGoBackwardCallback=Ce,e.useGoForwardCallback=pe,e.useGoToCallback=(e,s=[],t,o=y,r=[])=>{const u=D(t);return F((s=>h(u,(t=>h(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useIndexIds=e=>z("IndexIds",M(e),[]),e.useIndexes=e=>x(e,4),e.useIndexesIds=()=>P(5),e.useIndexesOrIndexesById=M,e.useLinkedRowIds=de,e.useLinkedRowIdsListener=(e,s,t,o,r)=>H("Linked"+c,O(r),t,o,[e,s]),e.useLocalRowIds=ue,e.useLocalRowIdsListener=(e,s,t,o,r)=>H("Local"+c,O(r),t,o,[e,s]),e.useMetric=se,e.useMetricIds=e=>z("MetricIds",B(e),[]),e.useMetricListener=(e,s,t,o)=>H("Metric",B(o),s,t,[e]),e.useMetrics=e=>x(e,2),e.useMetricsIds=()=>P(3),e.useMetricsOrMetricsById=B,e.useQueries=e=>x(e,8),e.useQueriesIds=()=>P(9),e.useQueriesOrQueriesById=Q,e.useQueryIds=e=>z("QueryIds",Q(e),[]),e.useRedoInformation=e=>{const s=D(e),[,,[t]]=Ie(s);return[!g(t),pe(s),t,h(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>z("RelationshipIds",O(e),[]),e.useRelationships=e=>x(e,6),e.useRelationshipsIds=()=>P(7),e.useRelationshipsOrRelationshipsById=O,e.useRemoteRowId=re,e.useRemoteRowIdListener=(e,s,t,o,r)=>H("RemoteRowId",O(r),t,o,[e,s]),e.useResultCell=ae,e.useResultCellIds=ie,e.useResultCellIdsListener=(e,s,t,o,r)=>H(u+b,Q(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,d)=>H(u+p,Q(d),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>z(u+a,Q(t),{},[e,s]),e.useResultRowCount=(e,s)=>z(u+I,Q(s),[],[e]),e.useResultRowCountListener=(e,s,t,o)=>H(u+I,Q(o),s,t,[e]),e.useResultRowIds=le,e.useResultRowIdsListener=(e,s,t,o)=>H(u+c,Q(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>H(u+a,Q(r),t,o,[e,s]),e.useResultSortedRowIds=ne,e.useResultSortedRowIdsListener=(e,s,t,o,r,d,l,n)=>H(u+C,Q(n),d,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>z(u+l,Q(s),{},[e]),e.useResultTableCellIds=(e,s)=>z(u+l+b,Q(s),[],[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>H(u+l+b,Q(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>H(u+l,Q(o),s,t,[e]),e.useRow=(e,s,t)=>z(a,q(t),{},[e,s]),e.useRowCount=(e,s)=>z(I,q(s),[],[e]),e.useRowCountListener=(e,s,t,o,r)=>H(I,q(r),s,t,[e],o),e.useRowIds=X,e.useRowIdsListener=(e,s,t,o,r)=>H(c,q(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>H(a,q(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,d,l)=>J(u,p,o,r,d,l,e,s,t),e.useSetCheckpointCallback=(e=y,s=[],t,o=y,r=[])=>{const u=D(t);return F((s=>h(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,d)=>J(r,"PartialRow",t,o,u,d,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>J(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,d)=>J(r,a,t,o,u,d,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>J(o,l,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>J(t,n,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>J(o,w,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>J(t,R,e,s,o,r),e.useSliceIds=te,e.useSliceIdsListener=(e,s,t,o)=>H("SliceIds",M(o),s,t,[e]),e.useSliceRowIds=oe,e.useSliceRowIdsListener=(e,s,t,o,r)=>H("Slice"+c,M(r),t,o,[e,s]),e.useSortedRowIds=Y,e.useSortedRowIdsListener=(e,s,t,o,r,u,d,l,n)=>H(C,q(n),u,d,[e,s,t,o,r],l),e.useStore=e=>x(e,0),e.useStoreIds=()=>P(1),e.useStoreOrStoreById=q,e.useTable=(e,s)=>z(l,q(s),{},[e]),e.useTableCellIds=(e,s)=>z(l+b,q(s),[],[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>H(l+b,q(r),s,t,[e],o),e.useTableIds=W,e.useTableIdsListener=(e,s,t,o)=>H(i,q(o),e,s,[],t),e.useTableListener=(e,s,t,o,r)=>H(l,q(r),s,t,[e],o),e.useTables=e=>z(n,q(e),{}),e.useTablesListener=(e,s,t,o)=>H(n,q(o),e,s,[],t),e.useUndoInformation=e=>{const s=D(e),[t,r]=Ie(s);return[(u=t,!(0==(e=>e.length)(u))),Ce(s),r,h(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=ee,e.useValueIds=_,e.useValueIdsListener=(e,s,t,o)=>H(k,q(o),e,s,[],t),e.useValueListener=(e,s,t,o,r)=>H(w,q(r),s,t,[e],o),e.useValues=e=>z(R,q(e),{}),e.useValuesListener=(e,s,t,o)=>H(R,q(o),e,s,[],t)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u="Listener",d="Result",l="Ids",n="Table",i=n+"s",a=n+l,I="Row",c=I+"Count",C=I+l,p="Sorted"+I+l,w="Cell",b=w+l,R="Value",k=R+"s",g=R+l,h=e=>null==e,m=(e,s,t)=>h(e)?t?.():s(e),L=e=>t(e)==r,y=()=>{},S=(e,s)=>e.map(s),V=Object.keys,{createContext:T,useContext:f}=s,x=T([]),v=(e,s)=>{const t=f(x);return h(e)?t[s]:L(e)?((e,s)=>m(e,(e=>e[s])))(t[s+1]??{},e):e},P=(e,s)=>{const t=v(e,s);return h(e)||L(e)?t:e},q=e=>V(f(x)[e]??{}),B=e=>P(e,0),M=e=>P(e,2),D=e=>P(e,4),F=e=>P(e,6),O=e=>P(e,8),Q=e=>P(e,10),A=e=>e.toLowerCase();A(u);const E="Transaction";A(E);const{useCallback:G,useEffect:j,useMemo:U,useRef:W,useState:z}=s,H=(e,s,t=[])=>{const o=U((()=>s(e)),[e,...t]);return j((()=>()=>o.destroy()),[o]),o},J=(e,s,t,o=[],r)=>{const[,u]=z(),d=G((()=>s?.["get"+e]?.(...o)??t),[s,...o]),[l]=z(d),n=W(l);return U((()=>n.current=d()),[d]),K(e,s,((...e)=>{n.current=h(r)?d():e[r],u([])}),[],o),n.current},K=(e,s,t,o=[],r=[],...d)=>j((()=>{const o=s?.["add"+e+u]?.(...r,t,...d);return()=>s?.delListener(o)}),[s,...r,...o,...d]),N=(e,s,t,o=[],r=y,u=[],...d)=>{const l=B(e);return G((e=>m(l,(o=>m(t(e,o),(e=>r(o["set"+s](...d,e),e)))))),[l,s,...o,...u,...d])},X=(e,s,t=y,o=[],...r)=>{const u=B(e);return G((()=>t(u?.["del"+s](...r))),[u,s,...o,...r])},Y=(e,s,t)=>{const o=Q(e);return G((()=>o?.[s](t)),[o,s,t])},Z=e=>J(a,B(e),[],[]),$=(e,s)=>J(C,B(s),[],[e]),_=(e,s,t,o=0,r,u)=>J(p,B(u),[],[e,s,t,o,r],6),ee=(e,s,t)=>J(b,B(t),[],[e,s]),se=(e,s,t,o)=>J(w,B(o),void 0,[e,s,t],4),te=e=>J(g,B(e),[],[]),oe=(e,s)=>J(R,B(s),void 0,[e]),re=(e,s)=>J("Metric",M(s),void 0,[e]),ue=(e,s)=>J("SliceIds",D(s),[],[e]),de=(e,s,t)=>J("Slice"+C,D(t),[],[e,s]),le=(e,s,t)=>J("RemoteRowId",F(t),void 0,[e,s]),ne=(e,s,t)=>J("Local"+C,F(t),[],[e,s]),ie=(e,s,t)=>J("Linked"+C,F(t),[],[e,s]),ae=(e,s)=>J(d+C,O(s),[],[e]),Ie=(e,s,t,o=0,r,u)=>J(d+p,O(u),[],[e,s,t,o,r],6),ce=(e,s,t)=>J(d+b,O(t),[],[e,s]),Ce=(e,s,t,o)=>J(d+w,O(o),void 0,[e,s,t]),pe=e=>J("CheckpointIds",Q(e),[[],void 0,[]]),we=(e,s)=>J("Checkpoint",Q(s),void 0,[e]),be=e=>Y(e,"goBackward"),Re=e=>Y(e,"goForward"),{PureComponent:ke,Fragment:ge,createElement:he,useCallback:me,useLayoutEffect:Le,useRef:ye,useState:Se}=s,Ve=(e,...s)=>h(e)?{}:e(...s),Te=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useMemo:fe}=s,xe=({tableId:e,store:s,rowComponent:t=De,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:d},l)=>Be(S(l,(u=>he(t,{...Ve(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:d}))),u,d,e),ve=({queryId:e,queries:s,resultRowComponent:t=Ee,getResultRowComponentProps:o,separator:r,debugIds:u},d)=>Be(S(d,(r=>he(t,{...Ve(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),Pe=({relationshipId:e,relationships:s,rowComponent:t=De,getRowComponentProps:o,separator:r,debugIds:u},d,l)=>{const[n,i,a]=Te(F(s),e),I=d(e,l,n);return Be(S(I,(e=>he(t,{...Ve(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:u}))),r,u,l)},qe=e=>({checkpoints:s,checkpointComponent:t=Ge,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const d=Q(s);return Be(S(e(pe(d)),(e=>he(t,{...Ve(o,e),key:e,checkpoints:d,checkpointId:e,debugIds:u}))),r)},Be=(e,s,t,o)=>{const r=h(s)||!Array.isArray(e)?e:S(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},Me=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>Be(o+(se(e,s,t,r)??o),void 0,u,t),De=({tableId:e,rowId:s,store:t,cellComponent:o=Me,getCellComponentProps:r,customCellIds:u,separator:d,debugIds:l})=>Be(S(((e,s,t,o)=>{const r=ee(s,t,o);return e??r})(u,e,s,t),(u=>he(o,{...Ve(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:l}))),d,l,s),Fe=e=>xe(e,$(e.tableId,e.store)),Oe=({valueId:e,store:s,debugIds:t})=>Be(o+(oe(e,s)??o),void 0,t,e),Qe=({indexId:e,sliceId:s,indexes:t,rowComponent:o=De,getRowComponentProps:r,separator:u,debugIds:d})=>{const[l,n,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(D(t),e),a=de(e,s,l);return Be(S(a,(e=>he(o,{...Ve(r,e),key:e,tableId:i,rowId:e,store:n,debugIds:d}))),u,d,s)},Ae=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>Be(o+(Ce(e,s,t,r)??o),void 0,u,t),Ee=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Ae,getResultCellComponentProps:r,separator:u,debugIds:d})=>Be(S(ce(e,s,t),(u=>he(o,{...Ve(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:d}))),u,d,s),Ge=({checkpoints:e,checkpointId:s,debugIds:t})=>Be(we(s,e)??o,void 0,t,s),je=qe((e=>e[0])),Ue=qe((e=>h(e[1])?[]:[e[1]])),We=qe((e=>e[2]));e.BackwardCheckpointsView=je,e.CellView=Me,e.CheckpointView=Ge,e.CurrentCheckpointView=Ue,e.ForwardCheckpointsView=We,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Qe,getSliceComponentProps:o,separator:r,debugIds:u})=>Be(S(ue(e,s),(r=>he(t,{...Ve(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>Pe(e,ie,e.firstRowId),e.LocalRowsView=e=>Pe(e,ne,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>Be(re(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:t,metrics:o,metricsById:r,indexes:u,indexesById:d,relationships:l,relationshipsById:n,queries:i,queriesById:a,checkpoints:I,checkpointsById:c,children:C})=>{const p=s.useContext(x);return he(x.Provider,{value:fe((()=>[e??p[0],{...p[1],...t},o??p[2],{...p[3],...r},u??p[4],{...p[5],...d},l??p[6],{...p[7],...n},i??p[8],{...p[9],...a},I??p[10],{...p[11],...c}]),[e,t,o,r,u,d,l,n,i,a,I,c,p])},C)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=De,getRowComponentProps:r,debugIds:u})=>{const[d,l,,n]=Te(F(t),e),i=le(e,s,d);return Be(h(n)||h(i)?null:he(o,{...Ve(r,i),key:i,tableId:n,rowId:i,store:l,debugIds:u}),void 0,u,s)},e.ResultCellView=Ae,e.ResultRowView=Ee,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ve(r,Ie(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>ve(e,ae(e.queryId,e.queries)),e.RowView=De,e.SliceView=Qe,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>xe(r,_(r.tableId,e,s,t,o,r.store)),e.TableView=Fe,e.TablesView=({store:e,tableComponent:s=Fe,getTableComponentProps:t,separator:o,debugIds:r})=>Be(S(Z(e),(o=>he(s,{...Ve(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=Oe,e.ValuesView=({store:e,valueComponent:s=Oe,getValueComponentProps:t,separator:o,debugIds:r})=>Be(S(te(e),(o=>he(s,{...Ve(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=[],o,r=y,u=[],d=!0)=>{const l=B(o);return G((t=>m(l,(o=>m(s(t,o),(s=>r(o.addRow(e,s,d),o,s)))))),[l,e,...t,...u,d])},e.useCell=se,e.useCellIds=ee,e.useCellIdsListener=(e,s,t,o,r,u)=>K(b,B(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,d)=>K(w,B(d),o,r,[e,s,t],u),e.useCheckpoint=we,e.useCheckpointIds=pe,e.useCheckpointIdsListener=(e,s,t)=>K("CheckpointIds",Q(t),e,s),e.useCheckpointListener=(e,s,t,o)=>K("Checkpoint",Q(o),s,t,[e]),e.useCheckpoints=e=>v(e,10),e.useCheckpointsIds=()=>q(11),e.useCheckpointsOrCheckpointsById=Q,e.useCreateCheckpoints=(e,s,t)=>H(e,s,t),e.useCreateIndexes=(e,s,t)=>H(e,s,t),e.useCreateMetrics=(e,s,t)=>H(e,s,t),e.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,u]=z(),d=U((()=>s(e)),[e,...t]);return j((()=>((async()=>{await(o?.(d)),u(1)})(),()=>{d.destroy()})),[d,...r]),d},e.useCreateQueries=(e,s,t)=>H(e,s,t),e.useCreateRelationships=(e,s,t)=>H(e,s,t),e.useCreateStore=(e,s=[])=>U(e,s),e.useDelCellCallback=(e,s,t,o,r,u,d)=>X(r,w,u,d,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>X(t,I,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>X(s,n,t,o,e),e.useDelTablesCallback=(e,s,t)=>X(e,i,s,t),e.useDelValueCallback=(e,s,t,o)=>X(s,R,t,o,e),e.useDelValuesCallback=(e,s,t)=>X(e,k,s,t),e.useDidFinishTransactionListener=(e,s,t)=>K("DidFinish"+E,B(t),e,s),e.useGoBackwardCallback=be,e.useGoForwardCallback=Re,e.useGoToCallback=(e,s=[],t,o=y,r=[])=>{const u=Q(t);return G((s=>m(u,(t=>m(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useIndexIds=e=>J("IndexIds",D(e),[]),e.useIndexes=e=>v(e,4),e.useIndexesIds=()=>q(5),e.useIndexesOrIndexesById=D,e.useLinkedRowIds=ie,e.useLinkedRowIdsListener=(e,s,t,o,r)=>K("Linked"+C,F(r),t,o,[e,s]),e.useLocalRowIds=ne,e.useLocalRowIdsListener=(e,s,t,o,r)=>K("Local"+C,F(r),t,o,[e,s]),e.useMetric=re,e.useMetricIds=e=>J("MetricIds",M(e),[]),e.useMetricListener=(e,s,t,o)=>K("Metric",M(o),s,t,[e]),e.useMetrics=e=>v(e,2),e.useMetricsIds=()=>q(3),e.useMetricsOrMetricsById=M,e.useQueries=e=>v(e,8),e.useQueriesIds=()=>q(9),e.useQueriesOrQueriesById=O,e.useQueryIds=e=>J("QueryIds",O(e),[]),e.useRedoInformation=e=>{const s=Q(e),[,,[t]]=pe(s);return[!h(t),Re(s),t,m(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>J("RelationshipIds",F(e),[]),e.useRelationships=e=>v(e,6),e.useRelationshipsIds=()=>q(7),e.useRelationshipsOrRelationshipsById=F,e.useRemoteRowId=le,e.useRemoteRowIdListener=(e,s,t,o,r)=>K("RemoteRowId",F(r),t,o,[e,s]),e.useResultCell=Ce,e.useResultCellIds=ce,e.useResultCellIdsListener=(e,s,t,o,r)=>K(d+b,O(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>K(d+w,O(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>J(d+I,O(t),{},[e,s]),e.useResultRowCount=(e,s)=>J(d+c,O(s),[],[e]),e.useResultRowCountListener=(e,s,t,o)=>K(d+c,O(o),s,t,[e]),e.useResultRowIds=ae,e.useResultRowIdsListener=(e,s,t,o)=>K(d+C,O(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>K(d+I,O(r),t,o,[e,s]),e.useResultSortedRowIds=Ie,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,n)=>K(d+p,O(n),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>J(d+n,O(s),{},[e]),e.useResultTableCellIds=(e,s)=>J(d+n+b,O(s),[],[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>K(d+n+b,O(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>K(d+n,O(o),s,t,[e]),e.useRow=(e,s,t)=>J(I,B(t),{},[e,s]),e.useRowCount=(e,s)=>J(c,B(s),[],[e]),e.useRowCountListener=(e,s,t,o,r)=>K(c,B(r),s,t,[e],o),e.useRowIds=$,e.useRowIdsListener=(e,s,t,o,r)=>K(C,B(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>K(I,B(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,d,l)=>N(u,w,o,r,d,l,e,s,t),e.useSetCheckpointCallback=(e=y,s=[],t,o=y,r=[])=>{const u=Q(t);return G((s=>m(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,d)=>N(r,"PartialRow",t,o,u,d,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>N(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,d)=>N(r,I,t,o,u,d,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>N(o,n,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>N(t,i,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>N(o,R,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>N(t,k,e,s,o,r),e.useSliceIds=ue,e.useSliceIdsListener=(e,s,t,o)=>K("SliceIds",D(o),s,t,[e]),e.useSliceRowIds=de,e.useSliceRowIdsListener=(e,s,t,o,r)=>K("Slice"+C,D(r),t,o,[e,s]),e.useSortedRowIds=_,e.useSortedRowIdsListener=(e,s,t,o,r,u,d,l,n)=>K(p,B(n),u,d,[e,s,t,o,r],l),e.useStartTransactionListener=(e,s,t)=>K("Start"+E,B(t),e,s),e.useStore=e=>v(e,0),e.useStoreIds=()=>q(1),e.useStoreOrStoreById=B,e.useTable=(e,s)=>J(n,B(s),{},[e]),e.useTableCellIds=(e,s)=>J(n+b,B(s),[],[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>K(n+b,B(r),s,t,[e],o),e.useTableIds=Z,e.useTableIdsListener=(e,s,t,o)=>K(a,B(o),e,s,[],t),e.useTableListener=(e,s,t,o,r)=>K(n,B(r),s,t,[e],o),e.useTables=e=>J(i,B(e),{}),e.useTablesListener=(e,s,t,o)=>K(i,B(o),e,s,[],t),e.useUndoInformation=e=>{const s=Q(e),[t,r]=pe(s);return[(u=t,!(0==(e=>e.length)(u))),be(s),r,m(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=oe,e.useValueIds=te,e.useValueIdsListener=(e,s,t,o)=>K(g,B(o),e,s,[],t),e.useValueListener=(e,s,t,o,r)=>K(R,B(r),s,t,[e],o),e.useValues=e=>J(k,B(e),{}),e.useValuesListener=(e,s,t,o)=>K(k,B(o),e,s,[],t),e.useWillFinishTransactionListener=(e,s,t)=>K("WillFinish"+E,B(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
Binary file