tinybase 4.6.0-beta.0 → 4.6.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/lib/checkpoints.js +1 -1
  2. package/lib/checkpoints.js.gz +0 -0
  3. package/lib/cjs/checkpoints.cjs +1 -1
  4. package/lib/cjs/checkpoints.cjs.gz +0 -0
  5. package/lib/cjs/persisters/persister-electric-sql.cjs +1 -0
  6. package/lib/cjs/persisters/persister-electric-sql.cjs.gz +0 -0
  7. package/lib/cjs/persisters/persister-partykit-server.cjs +1 -1
  8. package/lib/cjs/persisters/persister-partykit-server.cjs.gz +0 -0
  9. package/lib/cjs/tinybase.cjs +1 -1
  10. package/lib/cjs/tinybase.cjs.gz +0 -0
  11. package/lib/cjs/ui-react.cjs +1 -1
  12. package/lib/cjs/ui-react.cjs.gz +0 -0
  13. package/lib/cjs-es6/checkpoints.cjs +1 -1
  14. package/lib/cjs-es6/checkpoints.cjs.gz +0 -0
  15. package/lib/cjs-es6/persisters/persister-electric-sql.cjs +1 -0
  16. package/lib/cjs-es6/persisters/persister-electric-sql.cjs.gz +0 -0
  17. package/lib/cjs-es6/persisters/persister-partykit-server.cjs +1 -1
  18. package/lib/cjs-es6/persisters/persister-partykit-server.cjs.gz +0 -0
  19. package/lib/cjs-es6/tinybase.cjs +1 -1
  20. package/lib/cjs-es6/tinybase.cjs.gz +0 -0
  21. package/lib/cjs-es6/ui-react.cjs +1 -1
  22. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  23. package/lib/debug/checkpoints.js +8 -0
  24. package/lib/debug/persisters/persister-electric-sql.js +839 -0
  25. package/lib/debug/persisters/persister-partykit-server.js +45 -25
  26. package/lib/debug/tinybase.js +8 -0
  27. package/lib/debug/ui-react.js +20 -2
  28. package/lib/es6/checkpoints.js +1 -1
  29. package/lib/es6/checkpoints.js.gz +0 -0
  30. package/lib/es6/persisters/persister-electric-sql.js +1 -0
  31. package/lib/es6/persisters/persister-electric-sql.js.gz +0 -0
  32. package/lib/es6/persisters/persister-partykit-server.js +1 -1
  33. package/lib/es6/persisters/persister-partykit-server.js.gz +0 -0
  34. package/lib/es6/tinybase.js +1 -1
  35. package/lib/es6/tinybase.js.gz +0 -0
  36. package/lib/es6/ui-react.js +1 -1
  37. package/lib/es6/ui-react.js.gz +0 -0
  38. package/lib/persisters/persister-electric-sql.js +1 -0
  39. package/lib/persisters/persister-electric-sql.js.gz +0 -0
  40. package/lib/persisters/persister-partykit-server.js +1 -1
  41. package/lib/persisters/persister-partykit-server.js.gz +0 -0
  42. package/lib/tinybase.js +1 -1
  43. package/lib/tinybase.js.gz +0 -0
  44. package/lib/types/checkpoints.d.ts +58 -6
  45. package/lib/types/persisters/persister-automerge.d.ts +1 -1
  46. package/lib/types/persisters/persister-browser.d.ts +2 -2
  47. package/lib/types/persisters/persister-cr-sqlite-wasm.d.ts +1 -1
  48. package/lib/types/persisters/persister-electric-sql.d.ts +164 -0
  49. package/lib/types/persisters/persister-expo-sqlite-next.d.ts +3 -3
  50. package/lib/types/persisters/persister-expo-sqlite.d.ts +1 -1
  51. package/lib/types/persisters/persister-file.d.ts +1 -1
  52. package/lib/types/persisters/persister-indexed-db.d.ts +1 -1
  53. package/lib/types/persisters/persister-partykit-client.d.ts +1 -1
  54. package/lib/types/persisters/persister-partykit-server.d.ts +32 -8
  55. package/lib/types/persisters/persister-remote.d.ts +1 -1
  56. package/lib/types/persisters/persister-sqlite-wasm.d.ts +1 -1
  57. package/lib/types/persisters/persister-sqlite3.d.ts +1 -1
  58. package/lib/types/persisters/persister-yjs.d.ts +1 -1
  59. package/lib/types/persisters.d.ts +2 -0
  60. package/lib/types/ui-react.d.ts +56 -26
  61. package/lib/types/with-schemas/checkpoints.d.ts +64 -6
  62. package/lib/types/with-schemas/internal/ui-react.d.ts +5 -0
  63. package/lib/types/with-schemas/persisters/persister-electric-sql.d.ts +177 -0
  64. package/lib/types/with-schemas/persisters/persister-expo-sqlite-next.d.ts +2 -2
  65. package/lib/types/with-schemas/persisters/persister-partykit-server.d.ts +44 -10
  66. package/lib/types/with-schemas/persisters/persister-sqlite3.d.ts +1 -1
  67. package/lib/types/with-schemas/persisters.d.ts +2 -0
  68. package/lib/types/with-schemas/ui-react.d.ts +56 -36
  69. package/lib/ui-react.js +1 -1
  70. package/lib/ui-react.js.gz +0 -0
  71. package/lib/umd/checkpoints.js +1 -1
  72. package/lib/umd/checkpoints.js.gz +0 -0
  73. package/lib/umd/persisters/persister-electric-sql.js +1 -0
  74. package/lib/umd/persisters/persister-electric-sql.js.gz +0 -0
  75. package/lib/umd/persisters/persister-partykit-server.js +1 -1
  76. package/lib/umd/persisters/persister-partykit-server.js.gz +0 -0
  77. package/lib/umd/tinybase.js +1 -1
  78. package/lib/umd/tinybase.js.gz +0 -0
  79. package/lib/umd/ui-react.js +1 -1
  80. package/lib/umd/ui-react.js.gz +0 -0
  81. package/lib/umd-es6/checkpoints.js +1 -1
  82. package/lib/umd-es6/checkpoints.js.gz +0 -0
  83. package/lib/umd-es6/persisters/persister-electric-sql.js +1 -0
  84. package/lib/umd-es6/persisters/persister-electric-sql.js.gz +0 -0
  85. package/lib/umd-es6/persisters/persister-partykit-server.js +1 -1
  86. package/lib/umd-es6/persisters/persister-partykit-server.js.gz +0 -0
  87. package/lib/umd-es6/tinybase.js +1 -1
  88. package/lib/umd-es6/tinybase.js.gz +0 -0
  89. package/lib/umd-es6/ui-react.js +1 -1
  90. package/lib/umd-es6/ui-react.js.gz +0 -0
  91. package/package.json +48 -43
  92. package/readme.md +2 -2
@@ -39,6 +39,7 @@ import {
39
39
  CurrentCheckpointProps,
40
40
  ExtraProps,
41
41
  ForwardCheckpointsProps,
42
+ GetId,
42
43
  IndexProps,
43
44
  IndexesOrIndexesId,
44
45
  LinkedRowsProps,
@@ -2575,7 +2576,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2575
2576
  *
2576
2577
  * ```ts override
2577
2578
  * useSetTableCallback<Parameter>(
2578
- * tableId: Id,
2579
+ * tableId: Id | GetId<Parameter>,
2579
2580
  * getTable: (parameter: Parameter, store: Store) => Table,
2580
2581
  * getTableDeps?: React.DependencyList,
2581
2582
  * storeOrStoreId?: StoreOrStoreId,
@@ -2604,13 +2605,15 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2604
2605
  * The Store to which the callback will make the mutation (indicated by the
2605
2606
  * hook's `storeOrStoreId` parameter) is always automatically used as a hook
2606
2607
  * dependency for the callback.
2607
- * @param tableId The Id of the Table in the Store to set.
2608
+ * @param tableId The Id of the Table in the Store to set, or a GetId function
2609
+ * that will return it.
2608
2610
  * @param getTable A function which returns the Table object that will be used
2609
2611
  * to update the Store, based on the parameter the callback will receive (and
2610
2612
  * which is most likely a DOM event).
2611
2613
  * @param getTableDeps An optional array of dependencies for the `getTable`
2612
2614
  * function, which, if any change, result in the regeneration of the callback.
2613
- * This parameter defaults to an empty array.
2615
+ * This parameter defaults to an empty array. Also use this to indicate the
2616
+ * dependencies of a GetId functions if used as the tableId argument.
2614
2617
  * @param storeOrStoreId The Store to be updated: omit for the default context
2615
2618
  * Store, provide an Id for a named context Store, or provide an explicit
2616
2619
  * reference.
@@ -2661,7 +2664,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2661
2664
  TableId extends TableIdFromSchema<Schemas[0]>,
2662
2665
  SetTable = Table<Schemas[0], TableId, true>,
2663
2666
  >(
2664
- tableId: TableId,
2667
+ tableId: TableId | GetId<Schemas, Parameter, TableId>,
2665
2668
  getTable: (
2666
2669
  parameter: Parameter,
2667
2670
  store: Store<Schemas>,
@@ -2680,8 +2683,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2680
2683
  *
2681
2684
  * ```ts override
2682
2685
  * useSetRowCallback<Parameter>(
2683
- * tableId: Id,
2684
- * rowId: Id,
2686
+ * tableId: Id | GetId<Parameter>,
2687
+ * rowId: Id | GetId<Parameter>,
2685
2688
  * getRow: (parameter: Parameter, store: Store) => Row,
2686
2689
  * getRowDeps?: React.DependencyList,
2687
2690
  * storeOrStoreId?: StoreOrStoreId,
@@ -2710,14 +2713,18 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2710
2713
  * The Store to which the callback will make the mutation (indicated by the
2711
2714
  * hook's `storeOrStoreId` parameter) is always automatically used as a hook
2712
2715
  * dependency for the callback.
2713
- * @param tableId The Id of the Table in the Store.
2714
- * @param rowId The Id of the Row in the Table to set.
2716
+ * @param tableId The Id of the Table in the Store, or a GetId function that
2717
+ * will return it.
2718
+ * @param rowId The Id of the Row in the Table to set, or a GetId function that
2719
+ * will return it.
2715
2720
  * @param getRow A function which returns the Row object that will be used to
2716
2721
  * update the Store, based on the parameter the callback will receive (and which
2717
2722
  * is most likely a DOM event).
2718
2723
  * @param getRowDeps An optional array of dependencies for the `getRow`
2719
2724
  * function, which, if any change, result in the regeneration of the callback.
2720
- * This parameter defaults to an empty array.
2725
+ * This parameter defaults to an empty array. Also use this to indicate the
2726
+ * dependencies of any GetId functions if used as the tableId or rowId
2727
+ * arguments.
2721
2728
  * @param storeOrStoreId The Store to be updated: omit for the default context
2722
2729
  * Store, provide an Id for a named context Store, or provide an explicit
2723
2730
  * reference.
@@ -2769,8 +2776,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2769
2776
  TableId extends TableIdFromSchema<Schemas[0]>,
2770
2777
  SetRow = Row<Schemas[0], TableId, true>,
2771
2778
  >(
2772
- tableId: TableId,
2773
- rowId: Id,
2779
+ tableId: TableId | GetId<Schemas, Parameter, TableId>,
2780
+ rowId: Id | GetId<Schemas, Parameter, Id>,
2774
2781
  getRow: (parameter: Parameter, store: Store<Schemas>) => NoInfer<SetRow>,
2775
2782
  getRowDeps?: React.DependencyList,
2776
2783
  storeOrStoreId?: StoreOrStoreId<Schemas>,
@@ -2786,7 +2793,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2786
2793
  *
2787
2794
  * ```ts override
2788
2795
  * useAddRowCallback<Parameter>(
2789
- * tableId: Id,
2796
+ * tableId: Id | GetId<Parameter>,
2790
2797
  * getRow: (parameter: Parameter, store: Store) => Row,
2791
2798
  * getRowDeps?: React.DependencyList,
2792
2799
  * storeOrStoreId?: StoreOrStoreId,
@@ -2823,13 +2830,15 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2823
2830
  * specify `reuseRowIds` to be `false`, then the Id will be a monotonically
2824
2831
  * increasing string representation of an increasing integer, regardless of any
2825
2832
  * you may have previously deleted.
2826
- * @param tableId The Id of the Table in the Store.
2833
+ * @param tableId The Id of the Table in the Store, or a GetId function
2834
+ * that will return it.
2827
2835
  * @param getRow A function which returns the Row object that will be used to
2828
2836
  * update the Store, based on the parameter the callback will receive (and which
2829
2837
  * is most likely a DOM event).
2830
2838
  * @param getRowDeps An optional array of dependencies for the `getRow`
2831
2839
  * function, which, if any change, result in the regeneration of the callback.
2832
- * This parameter defaults to an empty array.
2840
+ * This parameter defaults to an empty array. Also use this to indicate the
2841
+ * dependencies of a GetId functions if used as the tableId argument.
2833
2842
  * @param storeOrStoreId The Store to be updated: omit for the default context
2834
2843
  * Store, provide an Id for a named context Store, or provide an explicit
2835
2844
  * reference.
@@ -2882,7 +2891,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2882
2891
  TableId extends TableIdFromSchema<Schemas[0]>,
2883
2892
  AddRow = Row<Schemas[0], TableId, true>,
2884
2893
  >(
2885
- tableId: TableId,
2894
+ tableId: TableId | GetId<Schemas, Parameter, TableId>,
2886
2895
  getRow: (parameter: Parameter, store: Store<Schemas>) => NoInfer<AddRow>,
2887
2896
  getRowDeps?: React.DependencyList,
2888
2897
  storeOrStoreId?: StoreOrStoreId<Schemas>,
@@ -2900,8 +2909,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2900
2909
  *
2901
2910
  * ```ts override
2902
2911
  * useSetPartialRowCallback<Parameter>(
2903
- * tableId: Id,
2904
- * rowId: Id,
2912
+ * tableId: Id | GetId<Parameter>,
2913
+ * rowId: Id | GetId<Parameter>,
2905
2914
  * getPartialRow: (parameter: Parameter, store: Store) => Row,
2906
2915
  * getPartialRowDeps?: React.DependencyList,
2907
2916
  * storeOrStoreId?: StoreOrStoreId,
@@ -2930,14 +2939,18 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2930
2939
  * The Store to which the callback will make the mutation (indicated by the
2931
2940
  * hook's `storeOrStoreId` parameter) is always automatically used as a hook
2932
2941
  * dependency for the callback.
2933
- * @param tableId The Id of the Table in the Store.
2934
- * @param rowId The Id of the Row in the Table to set.
2942
+ * @param tableId The Id of the Table in the Store, or a GetId function that
2943
+ * will return it.
2944
+ * @param rowId The Id of the Row in the Table to set, or a GetId function that
2945
+ * will return it.
2935
2946
  * @param getPartialRow A function which returns the partial Row object that
2936
2947
  * will be used to update the Store, based on the parameter the callback will
2937
2948
  * receive (and which is most likely a DOM event).
2938
2949
  * @param getPartialRowDeps An optional array of dependencies for the `getRow`
2939
2950
  * function, which, if any change, result in the regeneration of the callback.
2940
- * This parameter defaults to an empty array.
2951
+ * This parameter defaults to an empty array. Also use this to indicate the
2952
+ * dependencies of any GetId functions if used as the tableId, rowId, or cellId
2953
+ * arguments.
2941
2954
  * @param storeOrStoreId The Store to be updated: omit for the default context
2942
2955
  * Store, provide an Id for a named context Store, or provide an explicit
2943
2956
  * reference.
@@ -2990,8 +3003,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
2990
3003
  TableId extends TableIdFromSchema<Schemas[0]>,
2991
3004
  SetPartialRow = Row<Schemas[0], TableId, true>,
2992
3005
  >(
2993
- tableId: TableId,
2994
- rowId: Id,
3006
+ tableId: TableId | GetId<Schemas, Parameter, TableId>,
3007
+ rowId: Id | GetId<Schemas, Parameter, Id>,
2995
3008
  getPartialRow: (
2996
3009
  parameter: Parameter,
2997
3010
  store: Store<Schemas>,
@@ -3010,9 +3023,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
3010
3023
  *
3011
3024
  * ```ts override
3012
3025
  * useSetCellCallback<Parameter>(
3013
- * tableId: Id,
3014
- * rowId: Id,
3015
- * cellId: Id,
3026
+ * tableId: Id | GetId<Parameter>,
3027
+ * rowId: Id | GetId<Parameter>,
3028
+ * cellId: Id | GetId<Parameter>,
3016
3029
  * getCell: (parameter: Parameter, store: Store) => Cell | MapCell,
3017
3030
  * getCellDeps?: React.DependencyList,
3018
3031
  * storeOrStoreId?: StoreOrStoreId,
@@ -3041,15 +3054,20 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
3041
3054
  * The Store to which the callback will make the mutation (indicated by the
3042
3055
  * hook's `storeOrStoreId` parameter) is always automatically used as a hook
3043
3056
  * dependency for the callback.
3044
- * @param tableId The Id of the Table in the Store.
3045
- * @param rowId The Id of the Row in the Table.
3046
- * @param cellId The Id of the Cell in the Row to set.
3057
+ * @param tableId The Id of the Table in the Store, or a GetId function that
3058
+ * will return it.
3059
+ * @param rowId The Id of the Row in the Table, or a GetId function that will
3060
+ * return it.
3061
+ * @param cellId The Id of the Cell in the Row to set, or a GetId function that
3062
+ * will return it.
3047
3063
  * @param getCell A function which returns the Cell value that will be used to
3048
3064
  * update the Store, or a MapCell function to update it, based on the parameter
3049
3065
  * the callback will receive (and which is most likely a DOM event).
3050
3066
  * @param getCellDeps An optional array of dependencies for the `getCell`
3051
3067
  * function, which, if any change, result in the regeneration of the callback.
3052
- * This parameter defaults to an empty array.
3068
+ * This parameter defaults to an empty array. Also use this to indicate the
3069
+ * dependencies of any GetId functions if used as the tableId, rowId, or cellId
3070
+ * arguments.
3053
3071
  * @param storeOrStoreId The Store to be updated: omit for the default context
3054
3072
  * Store, provide an Id for a named context Store, or provide an explicit
3055
3073
  * reference.
@@ -3142,9 +3160,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
3142
3160
  | Cell<Schemas[0], TableId, CellId>
3143
3161
  | MapCell<Schemas[0], TableId, CellId>,
3144
3162
  >(
3145
- tableId: TableId,
3146
- rowId: Id,
3147
- cellId: CellId,
3163
+ tableId: TableId | GetId<Schemas, Parameter, TableId>,
3164
+ rowId: Id | GetId<Schemas, Parameter, Id>,
3165
+ cellId: CellId | GetId<Schemas, Parameter, CellId>,
3148
3166
  getCell: (
3149
3167
  parameter: Parameter,
3150
3168
  store: Store<Schemas>,
@@ -3364,7 +3382,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
3364
3382
  *
3365
3383
  * ```ts override
3366
3384
  * useSetValueCallback<Parameter>(
3367
- * valueId: Id,
3385
+ * valueId: Id | GetId<Parameter>,
3368
3386
  * getValue: (parameter: Parameter, store: Store) => Value | MapValue,
3369
3387
  * getValueDeps?: React.DependencyList,
3370
3388
  * storeOrStoreId?: StoreOrStoreId,
@@ -3393,13 +3411,15 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
3393
3411
  * The Store to which the callback will make the mutation (indicated by the
3394
3412
  * hook's `storeOrStoreId` parameter) is always automatically used as a hook
3395
3413
  * dependency for the callback.
3396
- * @param valueId The Id of the Value in the Store to set.
3414
+ * @param valueId The Id of the Value in the Store to set, or a GetId function
3415
+ * that will return it.
3397
3416
  * @param getValue A function which returns the Value object that will be used
3398
3417
  * to update the Store, based on the parameter the callback will receive (and
3399
3418
  * which is most likely a DOM event).
3400
3419
  * @param getValueDeps An optional array of dependencies for the `getValue`
3401
3420
  * function, which, if any change, result in the regeneration of the callback.
3402
- * This parameter defaults to an empty array.
3421
+ * This parameter defaults to an empty array. Also use this to indicate the
3422
+ * dependencies of a GetId function if used as the valueId argument.
3403
3423
  * @param storeOrStoreId The Store to be updated: omit for the default context
3404
3424
  * Store, provide an Id for a named context Store, or provide an explicit
3405
3425
  * reference.
@@ -3451,7 +3471,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
3451
3471
  ValueId extends ValueIdFromSchema<Schemas[1]>,
3452
3472
  SetOrMapValue = Value<Schemas[1], ValueId> | MapValue<Schemas[1], ValueId>,
3453
3473
  >(
3454
- valueId: ValueId,
3474
+ valueId: ValueId | GetId<Schemas, Parameter, ValueId>,
3455
3475
  getValue: (
3456
3476
  parameter: Parameter,
3457
3477
  store: Store<Schemas>,
package/lib/ui-react.js CHANGED
@@ -1 +1 @@
1
- import e from"react";const t=e=>typeof e,o="",s=t(o),r="Listener",d="Result",n="Has",u="has",I="Ids",i="Table",c=i+"s",l=i+I,a="Row",p=a+"Count",g=a+I,b="Sorted"+a+I,C="Cell",m=C+I,k="Value",y=k+"s",w=k+I,h=e=>null==e,R=(e,t,o)=>h(e)?o?.():t(e),v=e=>t(e)==s,f=()=>{},q=(e,t)=>e.map(t),P=Object.keys,x=(e,t)=>R(e,(e=>e[t])),S=(e,t)=>(delete e[t],e),{createContext:L,useContext:B,useEffect:T}=e,E=L([]),M=(e,t)=>{const o=B(E);return h(e)?o[t]:v(e)?x(o[t+1]??{},e):e},F=(e,t)=>{const o=M(e,t);return h(e)||v(e)?o:e},V=e=>P(B(E)[e]??{}),A=e=>M(e,0),j=e=>F(e,0),D=(e,t)=>{const{12:o,13:s}=B(E);T((()=>(o?.(e,t),()=>s?.(e))),[o,e,t,s])},H=e=>M(e,2),O=e=>F(e,2),Q=e=>M(e,4),W=e=>F(e,4),z=e=>M(e,6),G=e=>F(e,6),J=e=>M(e,8),K=e=>F(e,8),N=e=>M(e,10),U=e=>F(e,10),X=e=>e.toLowerCase();X(r);const Y="Transaction";X(Y);const{useCallback:Z,useEffect:$,useMemo:_,useLayoutEffect:ee,useRef:te,useState:oe}=e,se=[],re={},de=[[],void 0,[]],ne=(e,t,o=se)=>{const s=_((()=>t(e)),[e,...o]);return $((()=>()=>s.destroy()),[s]),s},ue=(e,t,o,s=se,r,d="get",n="")=>{const[,u]=oe(),I=Z((()=>t?.[d+e]?.(...s)??o),[t,e,...s,o]),i=te();return _((()=>i.current=I()),[I]),Ie(n+e,t,((...e)=>{i.current=h(r)?I():e[r],u([])}),[I,r],s),i.current},Ie=(e,t,o,s=se,d=se,...n)=>ee((()=>{const s=t?.["add"+e+r]?.(...d,o,...n);return()=>t?.delListener(s)}),[t,e,...d,...s,...n]),ie=(e,t,o,s=se,r=f,d=se,...n)=>{const u=j(e);return Z((e=>R(u,(s=>R(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[u,t,...s,...d,...n])},ce=(e,t,o=f,s=se,...r)=>{const d=j(e);return Z((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},le=(e,t,o)=>{const s=U(e);return Z((()=>s?.[t](o)),[s,t,o])},ae=(e,t=se)=>_(e,t),pe=()=>V(1),ge=e=>ue(c,j(e),!1,[],1,u,n),be=e=>ue(c,j(e),re),Ce=e=>ue(l,j(e),se),me=(e,t)=>ue(i,j(t),!1,[e],2,u,n),ke=(e,t)=>ue(i,j(t),re,[e]),ye=(e,t)=>ue(i+m,j(t),se,[e]),we=(e,t,o)=>ue(i+C,j(o),!1,[e,t],3,u,n),he=(e,t)=>ue(p,j(t),0,[e]),Re=(e,t)=>ue(g,j(t),se,[e]),ve=(e,t,o,s=0,r,d)=>ue(b,j(d),se,[e,t,o,s,r],6),fe=(e,t,o)=>ue(a,j(o),!1,[e,t],3,u,n),qe=(e,t,o)=>ue(a,j(o),re,[e,t]),Pe=(e,t,o)=>ue(m,j(o),se,[e,t]),xe=(e,t,o,s)=>ue(C,j(s),!1,[e,t,o],4,u,n),Se=(e,t,o,s)=>ue(C,j(s),void 0,[e,t,o],4),Le=e=>ue(y,j(e),!1,[],1,u,n),Be=e=>ue(y,j(e),re),Te=e=>ue(w,j(e),se),Ee=(e,t)=>ue(k,j(t),!1,[e],2,u,n),Me=(e,t)=>ue(k,j(t),void 0,[e]),Fe=(e,t,o,s,r)=>ie(o,c,e,t,s,r),Ve=(e,t,o,s,r,d)=>ie(s,i,t,o,r,d,e),Ae=(e,t,o,s,r,d,n)=>ie(r,a,o,s,d,n,e,t),je=(e,t,o=se,s,r=f,d=se,n=!0)=>{const u=j(s);return Z((o=>R(u,(s=>R(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[u,e,...o,...d,n])},De=(e,t,o,s,r,d,n)=>ie(r,"PartialRow",o,s,d,n,e,t),He=(e,t,o,s,r,d,n,u)=>ie(d,C,s,r,n,u,e,t,o),Oe=(e,t,o,s,r)=>ie(o,y,e,t,s,r),Qe=(e,t,o,s,r)=>ie(o,"PartialValues",e,t,s,r),We=(e,t,o,s,r,d)=>ie(s,k,t,o,r,d,e),ze=(e,t,o)=>ce(e,c,t,o),Ge=(e,t,o,s)=>ce(t,i,o,s,e),Je=(e,t,o,s,r)=>ce(o,a,s,r,e,t),Ke=(e,t,o,s,r,d,n)=>ce(r,C,d,n,e,t,o,s),Ne=(e,t,o)=>ce(e,y,t,o),Ue=(e,t,o,s)=>ce(t,k,o,s,e),Xe=(e,t,o,s)=>Ie(n+c,j(s),e,t,[],o),Ye=(e,t,o,s)=>Ie(c,j(s),e,t,se,o),Ze=(e,t,o,s)=>Ie(l,j(s),e,t,se,o),$e=(e,t,o,s,r)=>Ie(n+i,j(r),t,o,[e],s),_e=(e,t,o,s,r)=>Ie(i,j(r),t,o,[e],s),et=(e,t,o,s,r)=>Ie(i+m,j(r),t,o,[e],s),tt=(e,t,o,s,r,d)=>Ie(n+i+C,j(d),o,s,[e,t],r),ot=(e,t,o,s,r)=>Ie(p,j(r),t,o,[e],s),st=(e,t,o,s,r)=>Ie(g,j(r),t,o,[e],s),rt=(e,t,o,s,r,d,n,u,I)=>Ie(b,j(I),d,n,[e,t,o,s,r],u),dt=(e,t,o,s,r,d)=>Ie(n+a,j(d),o,s,[e,t],r),nt=(e,t,o,s,r,d)=>Ie(a,j(d),o,s,[e,t],r),ut=(e,t,o,s,r,d)=>Ie(m,j(d),o,s,[e,t],r),It=(e,t,o,s,r,d,u)=>Ie(n+C,j(u),s,r,[e,t,o],d),it=(e,t,o,s,r,d,n)=>Ie(C,j(n),s,r,[e,t,o],d),ct=(e,t,o,s)=>Ie(n+y,j(s),e,t,[],o),lt=(e,t,o,s)=>Ie(y,j(s),e,t,se,o),at=(e,t,o,s)=>Ie(w,j(s),e,t,se,o),pt=(e,t,o,s,r)=>Ie(n+k,j(r),t,o,[e],s),gt=(e,t,o,s,r)=>Ie(k,j(r),t,o,[e],s),bt=(e,t,o)=>Ie("Start"+Y,j(o),e,t),Ct=(e,t,o)=>Ie("WillFinish"+Y,j(o),e,t),mt=(e,t,o)=>Ie("DidFinish"+Y,j(o),e,t),kt=(e,t,o)=>ne(e,t,o),yt=()=>V(3),wt=e=>ue("MetricIds",O(e),se),ht=(e,t)=>ue("Metric",O(t),void 0,[e]),Rt=(e,t,o,s)=>Ie("Metric",O(s),t,o,[e]),vt=(e,t,o)=>ne(e,t,o),ft=()=>V(5),qt=(e,t)=>ue("SliceIds",W(t),se,[e]),Pt=e=>ue("IndexIds",W(e),se),xt=(e,t,o)=>ue("Slice"+g,W(o),se,[e,t]),St=(e,t,o,s)=>Ie("SliceIds",W(s),t,o,[e]),Lt=(e,t,o,s,r)=>Ie("Slice"+g,W(r),o,s,[e,t]),Bt=(e,t,o)=>ne(e,t,o),Tt=()=>V(7),Et=e=>ue("RelationshipIds",G(e),se),Mt=(e,t,o)=>ue("RemoteRowId",G(o),void 0,[e,t]),Ft=(e,t,o)=>ue("Local"+g,G(o),se,[e,t]),Vt=(e,t,o)=>ue("Linked"+g,G(o),se,[e,t]),At=(e,t,o,s,r)=>Ie("RemoteRowId",G(r),o,s,[e,t]),jt=(e,t,o,s,r)=>Ie("Local"+g,G(r),o,s,[e,t]),Dt=(e,t,o,s,r)=>Ie("Linked"+g,G(r),o,s,[e,t]),Ht=(e,t,o)=>ne(e,t,o),Ot=()=>V(9),Qt=e=>ue("QueryIds",K(e),se),Wt=(e,t)=>ue(d+i,K(t),re,[e]),zt=(e,t)=>ue(d+i+m,K(t),se,[e]),Gt=(e,t)=>ue(d+p,K(t),0,[e]),Jt=(e,t)=>ue(d+g,K(t),se,[e]),Kt=(e,t,o,s=0,r,n)=>ue(d+b,K(n),se,[e,t,o,s,r],6),Nt=(e,t,o)=>ue(d+a,K(o),re,[e,t]),Ut=(e,t,o)=>ue(d+m,K(o),se,[e,t]),Xt=(e,t,o,s)=>ue(d+C,K(s),void 0,[e,t,o]),Yt=(e,t,o,s)=>Ie(d+i,K(s),t,o,[e]),Zt=(e,t,o,s)=>Ie(d+i+m,K(s),t,o,[e]),$t=(e,t,o,s)=>Ie(d+p,K(s),t,o,[e]),_t=(e,t,o,s)=>Ie(d+g,K(s),t,o,[e]),eo=(e,t,o,s,r,n,u,I)=>Ie(d+b,K(I),n,u,[e,t,o,s,r]),to=(e,t,o,s,r)=>Ie(d+a,K(r),o,s,[e,t]),oo=(e,t,o,s,r)=>Ie(d+m,K(r),o,s,[e,t]),so=(e,t,o,s,r,n)=>Ie(d+C,K(n),s,r,[e,t,o]),ro=(e,t,o)=>ne(e,t,o),no=()=>V(11),uo=e=>ue("CheckpointIds",U(e),de),Io=(e,t)=>ue("Checkpoint",U(t),void 0,[e]),io=(e=f,t=se,o,s=f,r=se)=>{const d=U(o);return Z((t=>R(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},co=e=>le(e,"goBackward"),lo=e=>le(e,"goForward"),ao=(e,t=se,o,s=f,r=se)=>{const d=U(o);return Z((t=>R(d,(o=>R(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},po=e=>{const t=U(e),[s,r]=uo(t);return[(d=s,!(0==d.length)),co(t),r,R(r,(e=>t?.getCheckpoint(e)))??o];var d},go=e=>{const t=U(e),[,,[s]]=uo(t);return[!h(s),lo(t),s,R(s,(e=>t?.getCheckpoint(e)))??o]},bo=(e,t,o)=>Ie("CheckpointIds",U(o),e,t),Co=(e,t,o,s)=>Ie("Checkpoint",U(s),t,o,[e]),mo=(e,t,o=se,s,r=se,d,n=se)=>{const[,u]=oe(),I=_((()=>t(e)),[e,...o]);return $((()=>((async()=>{s&&(await s(I),u([]))})(),()=>{I?.destroy(),d?.(I)})),[I,...r,...n]),I},{PureComponent:ko,Fragment:yo,createElement:wo,useCallback:ho,useLayoutEffect:Ro,useRef:vo,useState:fo}=e,qo=(e,...t)=>h(e)?{}:e(...t),Po=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useCallback:xo,useContext:So,useMemo:Lo,useState:Bo}=e,To=({tableId:e,store:t,rowComponent:o=Do,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},u)=>Ao(q(u,(d=>wo(o,{...qo(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),Eo=({queryId:e,queries:t,resultRowComponent:o=Zo,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>Ao(q(n,(r=>wo(o,{...qo(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),Mo=({relationshipId:e,relationships:t,rowComponent:o=Do,getRowComponentProps:s,separator:r,debugIds:d},n,u)=>{const[I,i,c]=Po(G(t),e),l=n(e,u,I);return Ao(q(l,(e=>wo(o,{...qo(s,e),key:e,tableId:c,rowId:e,store:i,debugIds:d}))),r,d,u)},Fo=e=>({checkpoints:t,checkpointComponent:o=es,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=U(t);return Ao(q(e(uo(n)),(e=>wo(o,{...qo(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},Vo=({store:e,storesById:t,metrics:o,metricsById:s,indexes:r,indexesById:d,relationships:n,relationshipsById:u,queries:I,queriesById:i,checkpoints:c,checkpointsById:l,children:a})=>{const p=So(E),[g,b]=Bo({}),C=xo(((e,t)=>b((o=>x(o,e)==t?o:{...o,[e]:t}))),[]),m=xo((e=>b((t=>({...S(t,e)})))),[]);return wo(E.Provider,{value:Lo((()=>[e??p[0],{...p[1],...t,...g},o??p[2],{...p[3],...s},r??p[4],{...p[5],...d},n??p[6],{...p[7],...u},I??p[8],{...p[9],...i},c??p[10],{...p[11],...l},C,m]),[e,t,g,o,s,r,d,n,u,I,i,c,l,p,C,m])},a)},Ao=(e,t,o,s)=>{const r=h(t)||!Array.isArray(e)?e:q(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},jo=({tableId:e,rowId:t,cellId:s,store:r,debugIds:d})=>Ao(o+(Se(e,t,s,r)??o),void 0,d,s),Do=({tableId:e,rowId:t,store:o,cellComponent:s=jo,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:u})=>Ao(q(((e,t,o,s)=>{const r=Pe(t,o,s);return e??r})(d,e,t,o),(d=>wo(s,{...qo(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:u}))),n,u,t),Ho=e=>To(e,Re(e.tableId,e.store)),Oo=({cellId:e,descending:t,offset:o,limit:s,...r})=>To(r,ve(r.tableId,e,t,o,s,r.store)),Qo=({store:e,tableComponent:t=Ho,getTableComponentProps:o,separator:s,debugIds:r})=>Ao(q(Ce(e),(s=>wo(t,{...qo(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),Wo=({valueId:e,store:t,debugIds:s})=>Ao(o+(Me(e,t)??o),void 0,s,e),zo=({store:e,valueComponent:t=Wo,getValueComponentProps:o,separator:s,debugIds:r})=>Ao(q(Te(e),(s=>wo(t,{...qo(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),Go=({metricId:e,metrics:t,debugIds:s})=>Ao(ht(e,t)??o,void 0,s,e),Jo=({indexId:e,sliceId:t,indexes:o,rowComponent:s=Do,getRowComponentProps:r,separator:d,debugIds:n})=>{const[u,I,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(W(o),e),c=xt(e,t,u);return Ao(q(c,(e=>wo(s,{...qo(r,e),key:e,tableId:i,rowId:e,store:I,debugIds:n}))),d,n,t)},Ko=({indexId:e,indexes:t,sliceComponent:o=Jo,getSliceComponentProps:s,separator:r,debugIds:d})=>Ao(q(qt(e,t),(r=>wo(o,{...qo(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),No=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=Do,getRowComponentProps:r,debugIds:d})=>{const[n,u,,I]=Po(G(o),e),i=Mt(e,t,n);return Ao(h(I)||h(i)?null:wo(s,{...qo(r,i),key:i,tableId:I,rowId:i,store:u,debugIds:d}),void 0,d,t)},Uo=e=>Mo(e,Ft,e.remoteRowId),Xo=e=>Mo(e,Vt,e.firstRowId),Yo=({queryId:e,rowId:t,cellId:s,queries:r,debugIds:d})=>Ao(o+(Xt(e,t,s,r)??o),void 0,d,s),Zo=({queryId:e,rowId:t,queries:o,resultCellComponent:s=Yo,getResultCellComponentProps:r,separator:d,debugIds:n})=>Ao(q(Ut(e,t,o),(d=>wo(s,{...qo(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),$o=e=>Eo(e,Jt(e.queryId,e.queries)),_o=({cellId:e,descending:t,offset:o,limit:s,...r})=>Eo(r,Kt(r.queryId,e,t,o,s,r.queries)),es=({checkpoints:e,checkpointId:t,debugIds:s})=>Ao(Io(t,e)??o,void 0,s,t),ts=Fo((e=>e[0])),os=Fo((e=>h(e[1])?[]:[e[1]])),ss=Fo((e=>e[2]));export{ts as BackwardCheckpointsView,jo as CellView,es as CheckpointView,os as CurrentCheckpointView,ss as ForwardCheckpointsView,Ko as IndexView,Xo as LinkedRowsView,Uo as LocalRowsView,Go as MetricView,Vo as Provider,No as RemoteRowView,Yo as ResultCellView,Zo as ResultRowView,_o as ResultSortedTableView,$o as ResultTableView,Do as RowView,Jo as SliceView,Oo as SortedTableView,Ho as TableView,Qo as TablesView,Wo as ValueView,zo as ValuesView,je as useAddRowCallback,Se as useCell,Pe as useCellIds,ut as useCellIdsListener,it as useCellListener,Io as useCheckpoint,uo as useCheckpointIds,bo as useCheckpointIdsListener,Co as useCheckpointListener,N as useCheckpoints,no as useCheckpointsIds,U as useCheckpointsOrCheckpointsById,ro as useCreateCheckpoints,vt as useCreateIndexes,kt as useCreateMetrics,mo as useCreatePersister,Ht as useCreateQueries,Bt as useCreateRelationships,ae as useCreateStore,Ke as useDelCellCallback,Je as useDelRowCallback,Ge as useDelTableCallback,ze as useDelTablesCallback,Ue as useDelValueCallback,Ne as useDelValuesCallback,mt as useDidFinishTransactionListener,co as useGoBackwardCallback,lo as useGoForwardCallback,ao as useGoToCallback,xe as useHasCell,It as useHasCellListener,fe as useHasRow,dt as useHasRowListener,me as useHasTable,we as useHasTableCell,tt as useHasTableCellListener,$e as useHasTableListener,ge as useHasTables,Xe as useHasTablesListener,Ee as useHasValue,pt as useHasValueListener,Le as useHasValues,ct as useHasValuesListener,Pt as useIndexIds,Q as useIndexes,ft as useIndexesIds,W as useIndexesOrIndexesById,Vt as useLinkedRowIds,Dt as useLinkedRowIdsListener,Ft as useLocalRowIds,jt as useLocalRowIdsListener,ht as useMetric,wt as useMetricIds,Rt as useMetricListener,H as useMetrics,yt as useMetricsIds,O as useMetricsOrMetricsById,D as useProvideStore,J as useQueries,Ot as useQueriesIds,K as useQueriesOrQueriesById,Qt as useQueryIds,go as useRedoInformation,Et as useRelationshipIds,z as useRelationships,Tt as useRelationshipsIds,G as useRelationshipsOrRelationshipsById,Mt as useRemoteRowId,At as useRemoteRowIdListener,Xt as useResultCell,Ut as useResultCellIds,oo as useResultCellIdsListener,so as useResultCellListener,Nt as useResultRow,Gt as useResultRowCount,$t as useResultRowCountListener,Jt as useResultRowIds,_t as useResultRowIdsListener,to as useResultRowListener,Kt as useResultSortedRowIds,eo as useResultSortedRowIdsListener,Wt as useResultTable,zt as useResultTableCellIds,Zt as useResultTableCellIdsListener,Yt as useResultTableListener,qe as useRow,he as useRowCount,ot as useRowCountListener,Re as useRowIds,st as useRowIdsListener,nt as useRowListener,He as useSetCellCallback,io as useSetCheckpointCallback,De as useSetPartialRowCallback,Qe as useSetPartialValuesCallback,Ae as useSetRowCallback,Ve as useSetTableCallback,Fe as useSetTablesCallback,We as useSetValueCallback,Oe as useSetValuesCallback,qt as useSliceIds,St as useSliceIdsListener,xt as useSliceRowIds,Lt as useSliceRowIdsListener,ve as useSortedRowIds,rt as useSortedRowIdsListener,bt as useStartTransactionListener,A as useStore,pe as useStoreIds,j as useStoreOrStoreById,ke as useTable,ye as useTableCellIds,et as useTableCellIdsListener,Ce as useTableIds,Ze as useTableIdsListener,_e as useTableListener,be as useTables,Ye as useTablesListener,po as useUndoInformation,Me as useValue,Te as useValueIds,at as useValueIdsListener,gt as useValueListener,Be as useValues,lt as useValuesListener,Ct as useWillFinishTransactionListener};
1
+ import e from"react";const t=e=>typeof e,o="",s=t(o),r=t(t),d="Listener",n="Result",u="Has",I="has",i="Ids",c="Table",l=c+"s",a=c+i,p="Row",g=p+"Count",b=p+i,C="Sorted"+p+i,m="Cell",k=m+i,y="Value",w=y+"s",h=y+i,R=e=>null==e,v=(e,t,o)=>R(e)?o?.():t(e),f=e=>t(e)==s,q=e=>t(e)==r,P=()=>{},x=(e,t)=>e.map(t),S=Object.keys,L=(e,t)=>v(e,(e=>e[t])),B=(e,t)=>(delete e[t],e),{createContext:T,useContext:E,useEffect:M}=e,F=T([]),V=(e,t)=>{const o=E(F);return R(e)?o[t]:f(e)?L(o[t+1]??{},e):e},A=(e,t)=>{const o=V(e,t);return R(e)||f(e)?o:e},j=e=>S(E(F)[e]??{}),D=e=>V(e,0),H=e=>A(e,0),O=(e,t)=>{const{12:o,13:s}=E(F);M((()=>(o?.(e,t),()=>s?.(e))),[o,e,t,s])},Q=e=>V(e,2),W=e=>A(e,2),z=e=>V(e,4),G=e=>A(e,4),J=e=>V(e,6),K=e=>A(e,6),N=e=>V(e,8),U=e=>A(e,8),X=e=>V(e,10),Y=e=>A(e,10),Z=e=>e.toLowerCase();Z(d);const $="Transaction";Z($);const{useCallback:_,useEffect:ee,useMemo:te,useLayoutEffect:oe,useRef:se,useState:re}=e,de=[],ne={},ue=[[],void 0,[]],Ie=(e,t,o=de)=>{const s=te((()=>t(e)),[e,...o]);return ee((()=>()=>s.destroy()),[s]),s},ie=(e,t,o,s=de,r,d="get",n="")=>{const[,u]=re(),I=_((()=>t?.[d+e]?.(...s)??o),[t,e,...s,o]),i=se();return te((()=>i.current=I()),[I]),ce(n+e,t,((...e)=>{i.current=R(r)?I():e[r],u([])}),[I,r],s),i.current},ce=(e,t,o,s=de,r=de,...n)=>oe((()=>{const s=t?.["add"+e+d]?.(...r,o,...n);return()=>t?.delListener(s)}),[t,e,...r,...s,...n]),le=(e,t,o,s=de,r=P,d=de,...n)=>{const u=H(e);return _((e=>v(u,(s=>v(o(e,s),(o=>r(s["set"+t](...x(n,(t=>q(t)?t(e,s):t)),o),o)))))),[u,t,...s,...d,...n])},ae=(e,t,o=P,s=de,...r)=>{const d=H(e);return _((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},pe=(e,t,o)=>{const s=Y(e);return _((()=>s?.[t](o)),[s,t,o])},ge=(e,t=de)=>te(e,t),be=()=>j(1),Ce=e=>ie(l,H(e),!1,[],1,I,u),me=e=>ie(l,H(e),ne),ke=e=>ie(a,H(e),de),ye=(e,t)=>ie(c,H(t),!1,[e],2,I,u),we=(e,t)=>ie(c,H(t),ne,[e]),he=(e,t)=>ie(c+k,H(t),de,[e]),Re=(e,t,o)=>ie(c+m,H(o),!1,[e,t],3,I,u),ve=(e,t)=>ie(g,H(t),0,[e]),fe=(e,t)=>ie(b,H(t),de,[e]),qe=(e,t,o,s=0,r,d)=>ie(C,H(d),de,[e,t,o,s,r],6),Pe=(e,t,o)=>ie(p,H(o),!1,[e,t],3,I,u),xe=(e,t,o)=>ie(p,H(o),ne,[e,t]),Se=(e,t,o)=>ie(k,H(o),de,[e,t]),Le=(e,t,o,s)=>ie(m,H(s),!1,[e,t,o],4,I,u),Be=(e,t,o,s)=>ie(m,H(s),void 0,[e,t,o],4),Te=e=>ie(w,H(e),!1,[],1,I,u),Ee=e=>ie(w,H(e),ne),Me=e=>ie(h,H(e),de),Fe=(e,t)=>ie(y,H(t),!1,[e],2,I,u),Ve=(e,t)=>ie(y,H(t),void 0,[e]),Ae=(e,t,o,s,r)=>le(o,l,e,t,s,r),je=(e,t,o,s,r,d)=>le(s,c,t,o,r,d,e),De=(e,t,o,s,r,d,n)=>le(r,p,o,s,d,n,e,t),He=(e,t,o=de,s,r=P,d=de,n=!0)=>{const u=H(s);return _((o=>v(u,(s=>v(t(o,s),(t=>r(s.addRow(q(e)?e(o,s):e,t,n),s,t)))))),[u,e,...o,...d,n])},Oe=(e,t,o,s,r,d,n)=>le(r,"PartialRow",o,s,d,n,e,t),Qe=(e,t,o,s,r,d,n,u)=>le(d,m,s,r,n,u,e,t,o),We=(e,t,o,s,r)=>le(o,w,e,t,s,r),ze=(e,t,o,s,r)=>le(o,"PartialValues",e,t,s,r),Ge=(e,t,o,s,r,d)=>le(s,y,t,o,r,d,e),Je=(e,t,o)=>ae(e,l,t,o),Ke=(e,t,o,s)=>ae(t,c,o,s,e),Ne=(e,t,o,s,r)=>ae(o,p,s,r,e,t),Ue=(e,t,o,s,r,d,n)=>ae(r,m,d,n,e,t,o,s),Xe=(e,t,o)=>ae(e,w,t,o),Ye=(e,t,o,s)=>ae(t,y,o,s,e),Ze=(e,t,o,s)=>ce(u+l,H(s),e,t,[],o),$e=(e,t,o,s)=>ce(l,H(s),e,t,de,o),_e=(e,t,o,s)=>ce(a,H(s),e,t,de,o),et=(e,t,o,s,r)=>ce(u+c,H(r),t,o,[e],s),tt=(e,t,o,s,r)=>ce(c,H(r),t,o,[e],s),ot=(e,t,o,s,r)=>ce(c+k,H(r),t,o,[e],s),st=(e,t,o,s,r,d)=>ce(u+c+m,H(d),o,s,[e,t],r),rt=(e,t,o,s,r)=>ce(g,H(r),t,o,[e],s),dt=(e,t,o,s,r)=>ce(b,H(r),t,o,[e],s),nt=(e,t,o,s,r,d,n,u,I)=>ce(C,H(I),d,n,[e,t,o,s,r],u),ut=(e,t,o,s,r,d)=>ce(u+p,H(d),o,s,[e,t],r),It=(e,t,o,s,r,d)=>ce(p,H(d),o,s,[e,t],r),it=(e,t,o,s,r,d)=>ce(k,H(d),o,s,[e,t],r),ct=(e,t,o,s,r,d,n)=>ce(u+m,H(n),s,r,[e,t,o],d),lt=(e,t,o,s,r,d,n)=>ce(m,H(n),s,r,[e,t,o],d),at=(e,t,o,s)=>ce(u+w,H(s),e,t,[],o),pt=(e,t,o,s)=>ce(w,H(s),e,t,de,o),gt=(e,t,o,s)=>ce(h,H(s),e,t,de,o),bt=(e,t,o,s,r)=>ce(u+y,H(r),t,o,[e],s),Ct=(e,t,o,s,r)=>ce(y,H(r),t,o,[e],s),mt=(e,t,o)=>ce("Start"+$,H(o),e,t),kt=(e,t,o)=>ce("WillFinish"+$,H(o),e,t),yt=(e,t,o)=>ce("DidFinish"+$,H(o),e,t),wt=(e,t,o)=>Ie(e,t,o),ht=()=>j(3),Rt=e=>ie("MetricIds",W(e),de),vt=(e,t)=>ie("Metric",W(t),void 0,[e]),ft=(e,t,o,s)=>ce("Metric",W(s),t,o,[e]),qt=(e,t,o)=>Ie(e,t,o),Pt=()=>j(5),xt=(e,t)=>ie("SliceIds",G(t),de,[e]),St=e=>ie("IndexIds",G(e),de),Lt=(e,t,o)=>ie("Slice"+b,G(o),de,[e,t]),Bt=(e,t,o,s)=>ce("SliceIds",G(s),t,o,[e]),Tt=(e,t,o,s,r)=>ce("Slice"+b,G(r),o,s,[e,t]),Et=(e,t,o)=>Ie(e,t,o),Mt=()=>j(7),Ft=e=>ie("RelationshipIds",K(e),de),Vt=(e,t,o)=>ie("RemoteRowId",K(o),void 0,[e,t]),At=(e,t,o)=>ie("Local"+b,K(o),de,[e,t]),jt=(e,t,o)=>ie("Linked"+b,K(o),de,[e,t]),Dt=(e,t,o,s,r)=>ce("RemoteRowId",K(r),o,s,[e,t]),Ht=(e,t,o,s,r)=>ce("Local"+b,K(r),o,s,[e,t]),Ot=(e,t,o,s,r)=>ce("Linked"+b,K(r),o,s,[e,t]),Qt=(e,t,o)=>Ie(e,t,o),Wt=()=>j(9),zt=e=>ie("QueryIds",U(e),de),Gt=(e,t)=>ie(n+c,U(t),ne,[e]),Jt=(e,t)=>ie(n+c+k,U(t),de,[e]),Kt=(e,t)=>ie(n+g,U(t),0,[e]),Nt=(e,t)=>ie(n+b,U(t),de,[e]),Ut=(e,t,o,s=0,r,d)=>ie(n+C,U(d),de,[e,t,o,s,r],6),Xt=(e,t,o)=>ie(n+p,U(o),ne,[e,t]),Yt=(e,t,o)=>ie(n+k,U(o),de,[e,t]),Zt=(e,t,o,s)=>ie(n+m,U(s),void 0,[e,t,o]),$t=(e,t,o,s)=>ce(n+c,U(s),t,o,[e]),_t=(e,t,o,s)=>ce(n+c+k,U(s),t,o,[e]),eo=(e,t,o,s)=>ce(n+g,U(s),t,o,[e]),to=(e,t,o,s)=>ce(n+b,U(s),t,o,[e]),oo=(e,t,o,s,r,d,u,I)=>ce(n+C,U(I),d,u,[e,t,o,s,r]),so=(e,t,o,s,r)=>ce(n+p,U(r),o,s,[e,t]),ro=(e,t,o,s,r)=>ce(n+k,U(r),o,s,[e,t]),no=(e,t,o,s,r,d)=>ce(n+m,U(d),s,r,[e,t,o]),uo=(e,t,o)=>Ie(e,t,o),Io=()=>j(11),io=e=>ie("CheckpointIds",Y(e),ue),co=(e,t)=>ie("Checkpoint",Y(t),void 0,[e]),lo=(e=P,t=de,o,s=P,r=de)=>{const d=Y(o);return _((t=>v(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},ao=e=>pe(e,"goBackward"),po=e=>pe(e,"goForward"),go=(e,t=de,o,s=P,r=de)=>{const d=Y(o);return _((t=>v(d,(o=>v(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},bo=e=>{const t=Y(e),[s,r]=io(t);return[(d=s,!(0==d.length)),ao(t),r,v(r,(e=>t?.getCheckpoint(e)))??o];var d},Co=e=>{const t=Y(e),[,,[s]]=io(t);return[!R(s),po(t),s,v(s,(e=>t?.getCheckpoint(e)))??o]},mo=(e,t,o)=>ce("CheckpointIds",Y(o),e,t),ko=(e,t,o,s)=>ce("Checkpoint",Y(s),t,o,[e]),yo=(e,t,o=de,s,r=de,d,n=de)=>{const[,u]=re(),I=te((()=>t(e)),[e,...o]);return ee((()=>((async()=>{s&&(await s(I),u([]))})(),()=>{I?.destroy(),d?.(I)})),[I,...r,...n]),I},{PureComponent:wo,Fragment:ho,createElement:Ro,useCallback:vo,useLayoutEffect:fo,useRef:qo,useState:Po}=e,xo=(e,...t)=>R(e)?{}:e(...t),So=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useCallback:Lo,useContext:Bo,useMemo:To,useState:Eo}=e,Mo=({tableId:e,store:t,rowComponent:o=Oo,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},u)=>Do(x(u,(d=>Ro(o,{...xo(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),Fo=({queryId:e,queries:t,resultRowComponent:o=_o,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>Do(x(n,(r=>Ro(o,{...xo(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),Vo=({relationshipId:e,relationships:t,rowComponent:o=Oo,getRowComponentProps:s,separator:r,debugIds:d},n,u)=>{const[I,i,c]=So(K(t),e),l=n(e,u,I);return Do(x(l,(e=>Ro(o,{...xo(s,e),key:e,tableId:c,rowId:e,store:i,debugIds:d}))),r,d,u)},Ao=e=>({checkpoints:t,checkpointComponent:o=os,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=Y(t);return Do(x(e(io(n)),(e=>Ro(o,{...xo(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},jo=({store:e,storesById:t,metrics:o,metricsById:s,indexes:r,indexesById:d,relationships:n,relationshipsById:u,queries:I,queriesById:i,checkpoints:c,checkpointsById:l,children:a})=>{const p=Bo(F),[g,b]=Eo({}),C=Lo(((e,t)=>b((o=>L(o,e)==t?o:{...o,[e]:t}))),[]),m=Lo((e=>b((t=>({...B(t,e)})))),[]);return Ro(F.Provider,{value:To((()=>[e??p[0],{...p[1],...t,...g},o??p[2],{...p[3],...s},r??p[4],{...p[5],...d},n??p[6],{...p[7],...u},I??p[8],{...p[9],...i},c??p[10],{...p[11],...l},C,m]),[e,t,g,o,s,r,d,n,u,I,i,c,l,p,C,m])},a)},Do=(e,t,o,s)=>{const r=R(t)||!Array.isArray(e)?e:x(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},Ho=({tableId:e,rowId:t,cellId:s,store:r,debugIds:d})=>Do(o+(Be(e,t,s,r)??o),void 0,d,s),Oo=({tableId:e,rowId:t,store:o,cellComponent:s=Ho,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:u})=>Do(x(((e,t,o,s)=>{const r=Se(t,o,s);return e??r})(d,e,t,o),(d=>Ro(s,{...xo(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:u}))),n,u,t),Qo=e=>Mo(e,fe(e.tableId,e.store)),Wo=({cellId:e,descending:t,offset:o,limit:s,...r})=>Mo(r,qe(r.tableId,e,t,o,s,r.store)),zo=({store:e,tableComponent:t=Qo,getTableComponentProps:o,separator:s,debugIds:r})=>Do(x(ke(e),(s=>Ro(t,{...xo(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),Go=({valueId:e,store:t,debugIds:s})=>Do(o+(Ve(e,t)??o),void 0,s,e),Jo=({store:e,valueComponent:t=Go,getValueComponentProps:o,separator:s,debugIds:r})=>Do(x(Me(e),(s=>Ro(t,{...xo(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),Ko=({metricId:e,metrics:t,debugIds:s})=>Do(vt(e,t)??o,void 0,s,e),No=({indexId:e,sliceId:t,indexes:o,rowComponent:s=Oo,getRowComponentProps:r,separator:d,debugIds:n})=>{const[u,I,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(G(o),e),c=Lt(e,t,u);return Do(x(c,(e=>Ro(s,{...xo(r,e),key:e,tableId:i,rowId:e,store:I,debugIds:n}))),d,n,t)},Uo=({indexId:e,indexes:t,sliceComponent:o=No,getSliceComponentProps:s,separator:r,debugIds:d})=>Do(x(xt(e,t),(r=>Ro(o,{...xo(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),Xo=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=Oo,getRowComponentProps:r,debugIds:d})=>{const[n,u,,I]=So(K(o),e),i=Vt(e,t,n);return Do(R(I)||R(i)?null:Ro(s,{...xo(r,i),key:i,tableId:I,rowId:i,store:u,debugIds:d}),void 0,d,t)},Yo=e=>Vo(e,At,e.remoteRowId),Zo=e=>Vo(e,jt,e.firstRowId),$o=({queryId:e,rowId:t,cellId:s,queries:r,debugIds:d})=>Do(o+(Zt(e,t,s,r)??o),void 0,d,s),_o=({queryId:e,rowId:t,queries:o,resultCellComponent:s=$o,getResultCellComponentProps:r,separator:d,debugIds:n})=>Do(x(Yt(e,t,o),(d=>Ro(s,{...xo(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),es=e=>Fo(e,Nt(e.queryId,e.queries)),ts=({cellId:e,descending:t,offset:o,limit:s,...r})=>Fo(r,Ut(r.queryId,e,t,o,s,r.queries)),os=({checkpoints:e,checkpointId:t,debugIds:s})=>Do(co(t,e)??o,void 0,s,t),ss=Ao((e=>e[0])),rs=Ao((e=>R(e[1])?[]:[e[1]])),ds=Ao((e=>e[2]));export{ss as BackwardCheckpointsView,Ho as CellView,os as CheckpointView,rs as CurrentCheckpointView,ds as ForwardCheckpointsView,Uo as IndexView,Zo as LinkedRowsView,Yo as LocalRowsView,Ko as MetricView,jo as Provider,Xo as RemoteRowView,$o as ResultCellView,_o as ResultRowView,ts as ResultSortedTableView,es as ResultTableView,Oo as RowView,No as SliceView,Wo as SortedTableView,Qo as TableView,zo as TablesView,Go as ValueView,Jo as ValuesView,He as useAddRowCallback,Be as useCell,Se as useCellIds,it as useCellIdsListener,lt as useCellListener,co as useCheckpoint,io as useCheckpointIds,mo as useCheckpointIdsListener,ko as useCheckpointListener,X as useCheckpoints,Io as useCheckpointsIds,Y as useCheckpointsOrCheckpointsById,uo as useCreateCheckpoints,qt as useCreateIndexes,wt as useCreateMetrics,yo as useCreatePersister,Qt as useCreateQueries,Et as useCreateRelationships,ge as useCreateStore,Ue as useDelCellCallback,Ne as useDelRowCallback,Ke as useDelTableCallback,Je as useDelTablesCallback,Ye as useDelValueCallback,Xe as useDelValuesCallback,yt as useDidFinishTransactionListener,ao as useGoBackwardCallback,po as useGoForwardCallback,go as useGoToCallback,Le as useHasCell,ct as useHasCellListener,Pe as useHasRow,ut as useHasRowListener,ye as useHasTable,Re as useHasTableCell,st as useHasTableCellListener,et as useHasTableListener,Ce as useHasTables,Ze as useHasTablesListener,Fe as useHasValue,bt as useHasValueListener,Te as useHasValues,at as useHasValuesListener,St as useIndexIds,z as useIndexes,Pt as useIndexesIds,G as useIndexesOrIndexesById,jt as useLinkedRowIds,Ot as useLinkedRowIdsListener,At as useLocalRowIds,Ht as useLocalRowIdsListener,vt as useMetric,Rt as useMetricIds,ft as useMetricListener,Q as useMetrics,ht as useMetricsIds,W as useMetricsOrMetricsById,O as useProvideStore,N as useQueries,Wt as useQueriesIds,U as useQueriesOrQueriesById,zt as useQueryIds,Co as useRedoInformation,Ft as useRelationshipIds,J as useRelationships,Mt as useRelationshipsIds,K as useRelationshipsOrRelationshipsById,Vt as useRemoteRowId,Dt as useRemoteRowIdListener,Zt as useResultCell,Yt as useResultCellIds,ro as useResultCellIdsListener,no as useResultCellListener,Xt as useResultRow,Kt as useResultRowCount,eo as useResultRowCountListener,Nt as useResultRowIds,to as useResultRowIdsListener,so as useResultRowListener,Ut as useResultSortedRowIds,oo as useResultSortedRowIdsListener,Gt as useResultTable,Jt as useResultTableCellIds,_t as useResultTableCellIdsListener,$t as useResultTableListener,xe as useRow,ve as useRowCount,rt as useRowCountListener,fe as useRowIds,dt as useRowIdsListener,It as useRowListener,Qe as useSetCellCallback,lo as useSetCheckpointCallback,Oe as useSetPartialRowCallback,ze as useSetPartialValuesCallback,De as useSetRowCallback,je as useSetTableCallback,Ae as useSetTablesCallback,Ge as useSetValueCallback,We as useSetValuesCallback,xt as useSliceIds,Bt as useSliceIdsListener,Lt as useSliceRowIds,Tt as useSliceRowIdsListener,qe as useSortedRowIds,nt as useSortedRowIdsListener,mt as useStartTransactionListener,D as useStore,be as useStoreIds,H as useStoreOrStoreById,we as useTable,he as useTableCellIds,ot as useTableCellIdsListener,ke as useTableIds,_e as useTableIdsListener,tt as useTableListener,me as useTables,$e as useTablesListener,bo as useUndoInformation,Ve as useValue,Me as useValueIds,gt as useValueIdsListener,Ct as useValueListener,Ee as useValues,pt as useValuesListener,kt as useWillFinishTransactionListener};
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>null==e,n=(e,n,s)=>t(e)?s?.():n(e),s=e=>e.length,o=(e,t)=>e.includes(t),r=(e,t)=>e.forEach(t),l=e=>0==s(e),i=(e,...t)=>e.push(...t),c=e=>e.pop(),d=e=>e.shift(),a=Object.freeze,u=(e,t)=>e?.has(t)??!1,h=e=>t(e)||0==(e=>e?.size??0)(e),p=(e,t)=>e?.forEach(t),f=(e,t)=>e?.delete(t),C=e=>new Map(e),g=(e,t)=>e?.get(t),k=(e,n,s)=>t(s)?(f(e,n),e):e?.set(n,s),v=(e,t,n)=>(u(e,t)||k(e,t,n()),g(e,t)),y=(e,t,o,r,l=0)=>n((o?v:g)(e,t[l],l>s(t)-2?o:C),(n=>{if(l>s(t)-2)return r?.(n)&&k(e,t[l]),n;const i=y(n,t,o,r,l+1);return h(n)&&k(e,t[l]),i})),L=e=>new Set(Array.isArray(e)||t(e)?e:[e]),w=/^\d+$/,b=(e=>{const b=new WeakMap;return e=>(b.has(e)||b.set(e,(e=>{let b,S,T,x=100,z=C(),E=C(),V=1;const j=C(),m=C(),[A,B,I]=(e=>{let o;const[l,c]=(()=>{const e=[];let t=0;return[n=>(n?d(e):null)??""+t++,t=>{w.test(t)&&s(e)<1e3&&i(e,t)}]})(),a=C();return[(e,t,n,s=[],r=(()=>[]))=>{o??=_;const i=l(1);var c,d;return k(a,i,[e,t,n,s,r]),c=y(t,n??[""],L),d=i,c?.add(d),i},(e,t,...n)=>r(((e,t=[""])=>{const n=[],o=(e,l)=>l==s(t)?i(n,e):null===t[l]?p(e,(e=>o(e,l+1))):r([t[l],null],(t=>o(g(e,t),l+1)));return o(e,0),n})(e,t),(e=>p(e,(e=>g(a,e)[0](o,...t??[],...n))))),e=>n(g(a,e),(([,t,n])=>(y(t,n??[""],void 0,(t=>(f(t,e),h(t)?1:0))),k(a,e),c(e),n))),e=>n(g(a,e),(([e,,n=[],l,i])=>{const c=(...d)=>{const a=s(d);a==s(n)?e(o,...d,...i(d)):t(n[a])?r(l[a]?.(...d)??[],(e=>c(...d,e))):c(...d,n[a])};c()}))]})(),M=C(),F=C(),O=[],W=[],$=(n,s)=>{V=0,e.transaction((()=>{const[o,r]=g(M,s);p(o,((s,o)=>p(s,((s,r)=>p(s,((s,l)=>((e,n,s,o,r)=>t(r)?e.delCell(n,s,o,!0):e.setCell(n,s,o,r))(e,o,r,l,s[n]))))))),p(r,((s,o)=>((e,n,s)=>t(s)?e.delValue(n):e.setValue(n,s))(e,o,s[n])))})),V=1},q=e=>{k(M,e),k(F,e),B(m,[e])},D=(e,t)=>r(((e,t)=>e.splice(0,t))(e,t??s(e)),q),G=()=>D(O,s(O)-x),H=()=>n(b,(()=>{i(O,b),G(),D(W),b=void 0,T=1})),J=()=>{b=c(O),T=1},K=e.addCellListener(null,null,null,((e,t,n,s,o,r)=>{if(V){H();const e=v(z,t,C),l=v(e,n,C),i=v(l,s,(()=>[r,void 0]));i[1]=o,i[0]===o&&h(k(l,s))&&h(k(e,n))&&h(k(z,t))&&J(),U()}})),N=e.addValueListener(null,((e,t,n,s)=>{if(V){H();const e=v(E,t,(()=>[s,void 0]));e[1]=n,e[0]===n&&h(k(E,t))&&J(),U()}})),P=(e="")=>(t(b)&&(b=""+S++,k(M,b,[z,E]),Y(b,e),z=C(),E=C(),T=1),b),Q=()=>{l(O)||(((e,...t)=>{e.unshift(...t)})(W,P()),$(0,b),b=c(O),T=1)},R=()=>{l(W)||(i(O,b),b=d(W),$(1,b),T=1)},U=()=>{T&&(B(j),T=0)},X=e=>{const t=P(e);return U(),t},Y=(e,t)=>(Z(e)&&g(F,e)!==t&&(k(F,e,t),B(m,[e])),_),Z=e=>u(M,e),_={setSize:e=>(x=e,G(),_),addCheckpoint:X,setCheckpoint:Y,getStore:()=>e,getCheckpointIds:()=>[[...O],b,[...W]],forEachCheckpoint:e=>{return t=e,p(F,((e,n)=>t(n,e)));var t},hasCheckpoint:Z,getCheckpoint:e=>g(F,e),goBackward:()=>(Q(),U(),_),goForward:()=>(R(),U(),_),goTo:e=>{const n=o(O,e)?Q:o(W,e)?R:null;for(;!t(n)&&e!=b;)n();return U(),_},addCheckpointIdsListener:e=>A(e,j),addCheckpointListener:(e,t)=>A(t,m,[e]),delListener:e=>(I(e),_),clear:()=>(D(O),D(W),t(b)||q(b),b=void 0,S=0,X(),_),destroy:()=>{e.delListener(K),e.delListener(N)},getListenerStats:()=>({})};return a(_.clear())})(e)),b.get(e))})();e.createCheckpoints=b},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseCheckpoints={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>null==e,n=(e,n,r)=>t(e)?r?.():n(e),r=e=>e.length,o=(e,t)=>e.includes(t),s=(e,t)=>e.forEach(t),l=e=>0==r(e),i=(e,...t)=>e.push(...t),c=e=>e.pop(),d=e=>e.shift(),a=Object.freeze,u=(e,t)=>e?.has(t)??!1,h=e=>t(e)||0==(e=>e?.size??0)(e),p=(e,t)=>e?.forEach(t),f=(e,t)=>e?.delete(t),C=e=>new Map(e),g=(e,t)=>e?.get(t),k=(e,n,r)=>t(r)?(f(e,n),e):e?.set(n,r),v=(e,t,n)=>(u(e,t)||k(e,t,n()),g(e,t)),y=(e,t,o,s,l=0)=>n((o?v:g)(e,t[l],l>r(t)-2?o:C),(n=>{if(l>r(t)-2)return s?.(n)&&k(e,t[l]),n;const i=y(n,t,o,s,l+1);return h(n)&&k(e,t[l]),i})),L=e=>new Set(Array.isArray(e)||t(e)?e:[e]),w=/^\d+$/,b=(e=>{const b=new WeakMap;return e=>(b.has(e)||b.set(e,(e=>{let b,S,T,x=100,z=C(),E=C(),V=1;const j=C(),m=C(),[A,B,F]=(e=>{let o;const[l,c]=(()=>{const e=[];let t=0;return[n=>(n?d(e):null)??""+t++,t=>{w.test(t)&&r(e)<1e3&&i(e,t)}]})(),a=C();return[(e,t,n,r=[],s=(()=>[]))=>{o??=_;const i=l(1);var c,d;return k(a,i,[e,t,n,r,s]),c=y(t,n??[""],L),d=i,c?.add(d),i},(e,t,...n)=>s(((e,t=[""])=>{const n=[],o=(e,l)=>l==r(t)?i(n,e):null===t[l]?p(e,(e=>o(e,l+1))):s([t[l],null],(t=>o(g(e,t),l+1)));return o(e,0),n})(e,t),(e=>p(e,(e=>g(a,e)[0](o,...t??[],...n))))),e=>n(g(a,e),(([,t,n])=>(y(t,n??[""],void 0,(t=>(f(t,e),h(t)?1:0))),k(a,e),c(e),n))),e=>n(g(a,e),(([e,,n=[],l,i])=>{const c=(...d)=>{const a=r(d);a==r(n)?e(o,...d,...i(d)):t(n[a])?s(l[a]?.(...d)??[],(e=>c(...d,e))):c(...d,n[a])};c()}))]})(),I=C(),M=C(),O=[],W=[],$=(n,r)=>{V=0,e.transaction((()=>{const[o,s]=g(I,r);p(o,((r,o)=>p(r,((r,s)=>p(r,((r,l)=>((e,n,r,o,s)=>t(s)?e.delCell(n,r,o,!0):e.setCell(n,r,o,s))(e,o,s,l,r[n]))))))),p(s,((r,o)=>((e,n,r)=>t(r)?e.delValue(n):e.setValue(n,r))(e,o,r[n])))})),V=1},q=e=>{k(I,e),k(M,e),B(m,[e])},D=(e,t)=>s(((e,t)=>e.splice(0,t))(e,t??r(e)),q),G=()=>D(O,r(O)-x),H=()=>n(b,(()=>{i(O,b),G(),D(W),b=void 0,T=1})),J=()=>{b=c(O),T=1},K=e.addCellListener(null,null,null,((e,t,n,r,o,s)=>{if(V){H();const e=v(z,t,C),l=v(e,n,C),i=v(l,r,(()=>[s,void 0]));i[1]=o,i[0]===o&&h(k(l,r))&&h(k(e,n))&&h(k(z,t))&&J(),U()}})),N=e.addValueListener(null,((e,t,n,r)=>{if(V){H();const e=v(E,t,(()=>[r,void 0]));e[1]=n,e[0]===n&&h(k(E,t))&&J(),U()}})),P=(e="")=>(t(b)&&(b=""+S++,k(I,b,[z,E]),Y(b,e),z=C(),E=C(),T=1),b),Q=()=>{l(O)||(((e,...t)=>{e.unshift(...t)})(W,P()),$(0,b),b=c(O),T=1)},R=()=>{l(W)||(i(O,b),b=d(W),$(1,b),T=1)},U=()=>{T&&(B(j),T=0)},X=e=>{const t=P(e);return U(),t},Y=(e,t)=>(Z(e)&&g(M,e)!==t&&(k(M,e,t),B(m,[e])),_),Z=e=>u(I,e),_={setSize:e=>(x=e,G(),_),addCheckpoint:X,setCheckpoint:Y,getStore:()=>e,getCheckpointIds:()=>[[...O],b,[...W]],forEachCheckpoint:e=>{return t=e,p(M,((e,n)=>t(n,e)));var t},hasCheckpoint:Z,getCheckpoint:e=>g(M,e),goBackward:()=>(Q(),U(),_),goForward:()=>(R(),U(),_),goTo:e=>{const n=o(O,e)?Q:o(W,e)?R:null;for(;!t(n)&&e!=b;)n();return U(),_},addCheckpointIdsListener:e=>A(e,j),addCheckpointListener:(e,t)=>A(t,m,[e]),delListener:e=>(F(e),_),clear:()=>(D(O),D(W),t(b)||q(b),b=void 0,S=0,X(),_),clearForward:()=>(l(W)||(D(W),B(j)),_),destroy:()=>{e.delListener(K),e.delListener(N)},getListenerStats:()=>({})};return a(_.clear())})(e)),b.get(e))})();e.createCheckpoints=b},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseCheckpoints={});
Binary file
@@ -0,0 +1 @@
1
+ var a,t;a=this,t=function(a){"use strict";const t=a=>typeof a,e="tinybase",s=",",n=t(""),i=(a,t)=>a.repeat(t),o=Promise,c=setInterval,r=clearInterval,l=a=>null==a,y=(a,t,e)=>l(a)?e?.():t(a),w=a=>t(a)==n,E=(a,t,e)=>a.slice(t,e),d=a=>a.length,u=async a=>o.all(a),f=(a,t="")=>a.join(t),p=(a,t)=>a.map(t),T=a=>0==d(a),v=(a,t)=>a.filter(t),m=(a,...t)=>a.push(...t),h=(a,t)=>a?.has(t)??!1,A=a=>[...a?.values()??[]],L=(a,t)=>a?.delete(t),b=Object,N=a=>b.getPrototypeOf(a),O=b.keys,R=b.freeze,g=(a=[])=>b.fromEntries(a),S=(...a)=>b.assign({},...a),C=(a,t)=>p(b.entries(a),(([a,e])=>t(e,a))),D=a=>b.values(a),I=a=>d(O(a)),F=a=>(a=>!l(a)&&y(N(a),(a=>a==b.prototype||l(N(a))),(()=>!0)))(a)&&0==I(a),M=a=>new Map(a),P=a=>[...a?.keys()??[]],$=(a,t)=>a?.get(t),_=(a,t)=>p([...a?.entries()??[]],(([a,e])=>t(e,a))),B=(a,t,e)=>l(e)?(L(a,t),a):a?.set(t,e),j=(a,t,e)=>(h(a,t)||B(a,t,e()),$(a,t)),x=(a,t,e,s=B)=>(C(t,((t,s)=>e(a,s,t))),((a,t)=>{((a,t)=>{a?.forEach(t)})(a,((a,e)=>t(e)))})(a,(e=>((a,t)=>!l(((a,t)=>y(a,(a=>a[t])))(a,t)))(t,e)?0:s(a,e))),a),H=a=>new Set(Array.isArray(a)||l(a)?a:[a]),W=(a,t)=>a?.add(t),q="_",k="_id",J=a=>`"${a.replace(/"/g,'""')}"`,U="FROM pragma_table_",Y="WHERE",z=(a,t,e)=>{const n=M();return[async()=>x(n,g(await u(p(await a("SELECT name "+U+"list WHERE schema='main'AND type='table'AND name IN("+K(t)+")",t),(async({name:t})=>[t,g(p(await a("SELECT name,type "+U+"info(?)",[t]),(({name:a,type:t})=>[a,t])))])))),((a,t,e)=>B(n,t,x(j(n,t,M),e,((a,t,e)=>{e!=$(a,t)&&B(a,t,e)}),((a,t)=>B(a,t))))),((a,t)=>B(n,t))),async(t,e)=>((a,t)=>!l($($(n,a),t)))(t,e)?g(v(p(await a("SELECT*FROM"+J(t)),(a=>{return[a[e],(t={...a},s=e,delete t[s],t)];var t,s})),(([a,t])=>!l(a)&&!F(t)))):{},async(t,e,i,o,c,r=!1)=>{const y=H();C(i??{},(a=>p(O(a??{}),(a=>W(y,a)))));const w=A(y);if(!r&&c&&T(w)&&h(n,t))return await a("DROP TABLE"+J(t)),void B(n,t);if(T(w)||h(n,t)){const s=$(n,t),i=H(P(s));await u([...p(w,(async e=>{L(i,e)||(await a(`ALTER TABLE${J(t)}ADD${J(e)}`),B(s,e,""))})),...!r&&o?p(A(i),(async n=>{n!=e&&(await a(`ALTER TABLE${J(t)}DROP${J(n)}`),B(s,n))})):[]])}else await a(`CREATE TABLE${J(t)}(${J(e)} PRIMARY KEY ON CONFLICT REPLACE${f(p(w,(a=>s+J(a))))});`),B(n,t,M([[e,""],...p(w,(a=>[a,""]))]));if(r)l(i)?await a("DELETE FROM"+J(t)+"WHERE 1"):await u(C(i,(async(s,n)=>{l(s)?await a("DELETE FROM"+J(t)+Y+J(e)+"=?",[n]):T(w)||await G(a,t,e,O(s),[n,...D(s)])})));else if(T(w))h(n,t)&&await a("DELETE FROM"+J(t)+"WHERE 1");else{const s=v(P($(n,t)),(a=>a!=e)),o=[],c=[];C(i??{},((a,t)=>{m(o,t,...p(s,(t=>a?.[t]))),m(c,t)})),await G(a,t,e,s,o),await a("DELETE FROM"+J(t)+Y+J(e)+"NOT IN("+K(c)+")",c)}},async t=>{let s;await a("BEGIN");try{s=await t()}catch(a){e?.(a)}return await a("END"),s}]},G=async(a,t,e,n,o)=>await a("INSERT INTO"+J(t)+"("+J(e)+f(p(n,(a=>s+J(a))))+")VALUES"+E(i(`,(?${i(",?",d(n))})`,d(o)/(d(n)+1)),1)+"ON CONFLICT("+J(e)+")DO UPDATE SET"+f(p(n,(a=>J(a)+"=excluded."+J(a))),s),o),K=a=>f(p(a,(()=>"?")),s),V=JSON.parse,Q=M(),X=M(),Z=(a,t,e,s,n,i,[o,c]=[],r=[])=>{let w,E,d,u=0,f=0;j(Q,r,(()=>0)),j(X,r,(()=>[]));const p=async a=>(2!=u&&(u=1,await T.schedule((async()=>{await a(),u=0}))),T),T={load:async(e,s)=>await p((async()=>{try{a.setContent(await t())}catch{a.setContent([e,s])}})),startAutoLoad:async(e={},n={})=>(T.stopAutoLoad(),await T.load(e,n),f=1,d=s((async(e,s)=>{if(s){const t=s();await p((async()=>a.setTransactionChanges(t)))}else await p((async()=>{try{a.setContent(e?.()??await t())}catch(a){i?.(a)}}))})),T),stopAutoLoad:()=>(f&&(n(d),d=void 0,f=0),T),save:async t=>(1!=u&&(u=2,await T.schedule((async()=>{try{await e(a.getContent,t)}catch(a){i?.(a)}u=0}))),T),startAutoSave:async()=>(await T.stopAutoSave().save(),w=a.addDidFinishTransactionListener(((a,t)=>{const[e,s]=t();F(e)&&F(s)||T.save((()=>[e,s]))})),T),stopAutoSave:()=>(y(w,a.delListener),w=void 0,T),schedule:async(...a)=>(m($(X,r),...a),await(async()=>{if(!$(Q,r)){for(B(Q,r,1);!l((a=$(X,r),E=a.shift()));)try{await E()}catch(a){i?.(a)}B(Q,r,0)}var a})(),T),getStore:()=>a,destroy:()=>T.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return o&&(T[o]=()=>c),R(T)},aa="store",ta=(a,t,e,s,n,[i],o,c)=>{const[r,l,y,w]=z(t,o,n);return Z(a,(async()=>await w((async()=>(await r(),V((await l(i,k))[q]?.[aa]??"null"))))),(async a=>await w((async()=>{var t;await r(),await y(i,k,{[q]:{[aa]:(t=a()??null,JSON.stringify(t,((a,t)=>t instanceof Map?b.fromEntries([...t]):t)))}},!0,!0)}))),e,s,n,["getDb",c],c)},ea=(a,t,e,s,n,[i,o,[c,r,y]],w,E)=>{const[d,f,p,T]=z(t,w,n),m=async(a,t)=>await u(_(o,(async([e,s,n,i],o)=>{const c=a[o];t&&void 0===c||await p(e,s,c,n,i,t)}))),h=async(a,t)=>r?await p(y,k,{[q]:a},!0,!0,t):null;return Z(a,(async()=>await T((async()=>{await d();const a=await(async()=>g(v(await u(_(i,(async([a,t],e)=>[a,await f(e,t)]))),(a=>!F(a[1])))))(),t=await(async()=>c?(await f(y,k))[q]:{})();return F(a)&&l(t)?void 0:[a,t]}))),(async(a,t)=>await T((async()=>{if(await d(),l(t)){const[t,e]=a();await m(t),await h(e)}else{const[a,e]=t();await m(a,!0),await h(e,!0)}}))),e,s,n,["getDb",E],E)},sa="json",na="autoLoadIntervalSeconds",ia="rowIdColumnName",oa="tableId",ca="tableName",ra={mode:sa,[na]:1},la={load:0,save:0,[ca]:e+"_values"},ya=(a,t,e,s)=>{const n=M();return C(a,((a,i)=>{const o=E(D(S(t,w(a)?{[e]:a}:a)),0,I(t));l(o[0])||s(i,o[0])||B(n,i,o)})),n},wa="pragma ",Ea="data_version",da="schema_version",ua=(a,t,s,n,i,o,l,y)=>{let d,u;const[f,p,T,v]=(a=>{const t=(a=>S(ra,w(a)?{storeTableName:a}:a??{}))(a),s=t[na];if(t.mode==sa){const{storeTableName:a=e}=t;return[1,s,[a],H(a)]}const{tables:{load:n={},save:i={}}={},values:o={}}=t,c=E(D(S(la,o)),0,I(la)),r=c[2],l=H(r);return[0,s,[ya(n,{[oa]:null,[ia]:k},oa,(a=>W(l,a)&&a==r)),ya(i,{[ca]:null,[ia]:k,deleteEmptyColumns:0,deleteEmptyTable:0},ca,((a,t)=>W(l,t)&&t==r)),c],l]})(t);return(f?ta:ea)(a,o?async(a,t)=>(o(a,t),await s(a,t)):s,(a=>[c((async()=>{try{const t=(await s(wa+Ea))[0][Ea],e=(await s(wa+da))[0][da];t==(d??=t)&&e==(u??=e)||(a(),d=t,u=e)}catch{}}),1e3*p),n((t=>v.has(t)?a():0))]),(([a,t])=>{r(a),d=u=null,i(t)}),l,T,A(v),y)};a.createElectricSqlPersister=(a,t,e,s,n)=>ua(a,e,(async(a,e=[])=>await t.db.raw({sql:a,args:e})),(a=>t.notifier.subscribeToDataChanges((e=>{return s=({tablename:t})=>a(t),t.notifier.alias(e).forEach(s);var s}))),(a=>a()),s,n,t)},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((a="undefined"!=typeof globalThis?globalThis:a||self).TinyBasePersisterElectricSql={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,a=t(""),s="t",n=(e,t)=>e.startsWith(t),r=Promise,i=e=>null==e,o=(e,t,a)=>i(e)?a?.():t(e),c=(e,t,a)=>e.slice(t,a),l=e=>e.length,f=async e=>r.all(e),h=(e,t)=>e.map(t),u=(e,...t)=>e.push(...t),g=Object,y=(e=[])=>g.fromEntries(e),w=(e,t)=>h(g.entries(e),(([e,a])=>t(a,e))),d=(e,t,a)=>(((e,t)=>!i(((e,t)=>o(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=a()),e[t]),p=e=>JSON.stringify(e,((e,t)=>t instanceof Map?g.fromEntries([...t]):t)),S=JSON.parse,P=(e,s,n)=>e+s+(t(n)==a?n:p(n)),m=(e,t,a)=>{const s=l(e);return n(t,e)?[t[s],(a?S:String)(c(t,s+1))]:void 0},x=(e,t)=>((e,t)=>e?.forEach(t))(e,((e,a)=>t(a,e))),b="hasStore",T=y(h(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),D=async(e,t="")=>!!await e.get(t+b),v=async(e,t="")=>{const a={},n={};return x(await e.list(),((e,r)=>o(m(t,e),(([e,t])=>{if(e==s){const[e,s,n]=S("["+t+"]");d(d(a,e,y),s,y)[n]=r}else"v"==e&&(n[t]=r)})))),[a,n]},R=async(e,t,a,r)=>{const o=e.party.storage,c=e.config.storagePrefix,h={[c+b]:1},g=[],y=[];await f(w(t[0],(async(t,n)=>i(t)?!a&&e.canDelTable(n,r)&&((e,...t)=>e.unshift(...t))(y,C(c,s,n)):e.canSetTable(n,a,r)&&await f(w(t,(async(t,l)=>i(t)?!a&&e.canDelRow(n,l,r)&&u(y,C(c,s,n,l)):e.canSetRow(n,l,a,r)&&await f(w(t,(async(t,f)=>{const y=[n,l,f],w=C(c,s,...y);i(t)?!a&&e.canDelCell(...y,r)&&u(g,w):e.canSetCell(...y,t,a,r,await o.get(w))&&(h[w]=t)}))))))))),await f(w(t[1],(async(t,s)=>{const n=c+"v"+s;i(t)?!a&&e.canDelValue(s,r)&&u(g,n):e.canSetValue(s,t,a,r,await o.get(n))&&(h[n]=t)}))),0!=l(y)&&x(await o.list(),(e=>y.every((t=>!n(e,t)||u(g,e)&&0)))),await o.delete(g),await o.put(h)},C=(e,t,...a)=>P(e,t,c(p(a),1,-1)),O=async(e,t,a=null)=>new Response(a,{status:t,headers:e.config.responseHeaders});e.TinyBasePartyKitServer=class{constructor(e){this.party=e,this.config={},this.config.storePath??="/store",this.config.messagePrefix??="",this.config.storagePrefix??="",this.config.responseHeaders??=T}async onRequest(e){const{party:{storage:t},config:{storePath:a,storagePrefix:s}}=this;if(new URL(e.url).pathname.endsWith(a)){const a=await D(t,s),n=await e.text();return"PUT"==e.method?a?O(this,205):(await R(this,S(n),!0,e),O(this,201)):O(this,200,a?p(await v(t,s)):"")}return O(this,404)}async onMessage(e,t){const{party:{storage:a,broadcast:s},config:{messagePrefix:n,storagePrefix:r}}=this;await o(m(n,e,1),(async([e,i])=>{"s"==e&&await D(a,r)&&(await R(this,i,!1,t),s(P(n,"s",i),[t.id]))}))}canSetTable(e,t,a){return!0}canDelTable(e,t){return!0}canSetRow(e,t,a,s){return!0}canDelRow(e,t,a){return!0}canSetCell(e,t,a,s,n,r,i){return!0}canDelCell(e,t,a,s){return!0}canSetValue(e,t,a,s,n){return!0}canDelValue(e,t){return!0}},e.hasStoreInStorage=D,e.loadStoreFromStorage=v},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
1
+ var a,t;a=this,t=function(a){"use strict";const t=a=>typeof a,e=t(""),s="t",n=(a,t)=>a.startsWith(t),i=Promise,r=a=>null==a,o=(a,t,e)=>r(a)?e?.():t(a),c=(a,t,e)=>a.slice(t,e),l=a=>a.length,f=async a=>i.all(a),y=(a,t)=>a.map(t),h=(a,...t)=>a.push(...t),g=Object,w=(a=[])=>g.fromEntries(a),u=(a,t)=>y(g.entries(a),(([a,e])=>t(e,a))),d=(a,t,e)=>(((a,t)=>!r(((a,t)=>o(a,(a=>a[t])))(a,t)))(a,t)||(a[t]=e()),a[t]),p=a=>JSON.stringify(a,((a,t)=>t instanceof Map?g.fromEntries([...t]):t)),S=JSON.parse,P=(a,s,n)=>a+s+(t(n)==e?n:p(n)),m=(a,t,e)=>{const s=l(a);return n(t,a)?[t[s],(e?S:String)(c(t,s+1))]:void 0},x=(a,t)=>((a,t)=>a?.forEach(t))(a,((a,e)=>t(e,a))),b="hasStore",T=w(y(["Origin","Methods","Headers"],(a=>["Access-Control-Allow-"+a,"*"]))),D=async(a,t="")=>!!await a.get(t+b),v=async(a,t="")=>{const e={},n={};return x(await a.list(),((a,i)=>o(m(t,a),(([a,t])=>{if(a==s){const[a,s,n]=S("["+t+"]");d(d(e,a,w),s,w)[n]=i}else"v"==a&&(n[t]=i)})))),[e,n]},R=async(a,t,e)=>a.party.broadcast(P(a.config.messagePrefix,"s",t),e),C=async(a,t,e,i)=>{const o=a.party.storage,c=a.config.storagePrefix,y={[c+b]:1},g=[],w=[];await f(u(t[0],(async(t,n)=>r(t)?!e&&await a.canDelTable(n,i)&&((a,...t)=>a.unshift(...t))(w,O(c,s,n)):await a.canSetTable(n,e,i)&&await f(u(t,(async(t,l)=>r(t)?!e&&await a.canDelRow(n,l,i)&&h(w,O(c,s,n,l)):await a.canSetRow(n,l,e,i)&&await f(u(t,(async(t,f)=>{const w=[n,l,f],u=O(c,s,...w);r(t)?!e&&await a.canDelCell(...w,i)&&h(g,u):await a.canSetCell(...w,t,e,i,await o.get(u))&&(y[u]=t)}))))))))),await f(u(t[1],(async(t,s)=>{const n=c+"v"+s;r(t)?!e&&await a.canDelValue(s,i)&&h(g,n):await a.canSetValue(s,t,e,i,await o.get(n))&&(y[n]=t)}))),0!=l(w)&&x(await o.list(),(a=>w.every((t=>!n(a,t)||h(g,a)&&0)))),await o.delete(g),await o.put(y)},O=(a,t,...e)=>P(a,t,c(p(e),1,-1)),V=async(a,t,e=null)=>new Response(e,{status:t,headers:a.config.responseHeaders});a.TinyBasePartyKitServer=class{constructor(a){this.party=a,this.config={},this.config.storePath??="/store",this.config.messagePrefix??="",this.config.storagePrefix??="",this.config.responseHeaders??=T}async onRequest(a){const{party:{storage:t},config:{storePath:e,storagePrefix:s}}=this;if(new URL(a.url).pathname.endsWith(e)){const e=await D(t,s),n=await a.text();return"PUT"==a.method?e?V(this,205):(await C(this,S(n),!0,a),V(this,201)):V(this,200,e?p(await v(t,s)):"")}return V(this,404)}async onMessage(a,t){const{config:{messagePrefix:e,storagePrefix:s}}=this;await o(m(e,a,1),(async([a,e])=>{"s"==a&&await D(this.party.storage,s)&&(await C(this,e,!1,t),R(this,e,[t.id]))}))}async canSetTable(a,t,e){return!0}async canDelTable(a,t){return!0}async canSetRow(a,t,e,s){return!0}async canDelRow(a,t,e){return!0}async canSetCell(a,t,e,s,n,i,r){return!0}async canDelCell(a,t,e,s){return!0}async canSetValue(a,t,e,s,n){return!0}async canDelValue(a,t){return!0}},a.broadcastTransactionChanges=R,a.hasStoreInStorage=D,a.loadStoreFromStorage=v},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((a="undefined"!=typeof globalThis?globalThis:a||self).TinyBasePersisterPartyKitServer={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,s="",n=t(s),a=t(!0),o=t(0),r=t(t),i="type",l="default",c="Listener",d="Result",u="add",h="Has",g="Ids",f="Table",L=f+"s",w=f+g,v="Row",I=v+"Count",S=v+g,y="Sorted"+v+g,T="Cell",R=T+g,p="Value",C=p+"s",b=p+g,m=e=>s+e,V=Math.max,E=Math.min,k=isFinite,M=e=>null==e,x=(e,t,s)=>M(e)?s?.():t(e),D=e=>e==n||e==a,J=e=>t(e)==r,A=e=>Array.isArray(e),F=(e,t,s)=>e.slice(t,s),Q=e=>e.length,z=()=>{},N=(e,t)=>e.includes(t),O=(e,t)=>e.every(t),P=(e,t)=>Q(e)===Q(t)&&O(e,((e,s)=>t[s]===e)),j=(e,t)=>O(e,((s,n)=>0==n||t(e[n-1],s)<=0)),B=(e,t)=>e.sort(t),W=(e,t)=>e.forEach(t),H=(e,t)=>e.map(t),$=e=>G(e,((e,t)=>e+t),0),q=e=>0==Q(e),G=(e,t,s)=>e.reduce(t,s),K=(e,...t)=>e.push(...t),U=e=>e.pop(),X=e=>e.shift(),Y=Object,Z=e=>Y.getPrototypeOf(e),_=Y.keys,ee=Y.isFrozen,te=Y.freeze,se=e=>!M(e)&&x(Z(e),(e=>e==Y.prototype||M(Z(e))),(()=>!0)),ne=(e,t)=>!M(((e,t)=>x(e,(e=>e[t])))(e,t)),ae=(e,t)=>(delete e[t],e),oe=(e,t)=>H(Y.entries(e),(([e,s])=>t(s,e))),re=e=>se(e)&&0==(e=>Q(_(e)))(e),ie=e=>e?.size??0,le=(e,t)=>e?.has(t)??!1,ce=e=>M(e)||0==ie(e),de=e=>[...e?.values()??[]],ue=e=>e.clear(),he=(e,t)=>e?.forEach(t),ge=(e,t)=>e?.delete(t),fe=e=>new Map(e),Le=e=>[...e?.keys()??[]],we=(e,t)=>e?.get(t),ve=(e,t)=>he(e,((e,s)=>t(s,e))),Ie=(e,t,s)=>M(s)?(ge(e,t),e):e?.set(t,s),Se=(e,t,s)=>(le(e,t)||Ie(e,t,s()),we(e,t)),ye=(e,t,s,n=Ie)=>(oe(t,((t,n)=>s(e,n,t))),ve(e,(s=>ne(t,s)?0:n(e,s))),e),Te=(e,t,s)=>{const n={};return he(e,((e,a)=>{const o=t?t(e,a):e;!s?.(o,e)&&(n[a]=o)})),n},Re=(e,t,s)=>Te(e,(e=>Te(e,t,s)),re),pe=(e,t,s)=>Te(e,(e=>Re(e,t,s)),re),Ce=(e,t)=>{const s=fe();return he(e,((e,n)=>s.set(n,t?.(e)??e))),s},be=e=>Ce(e,Ce),me=e=>Ce(e,be),Ve=(e,t,s,n,a=0)=>x((s?Se:we)(e,t[a],a>Q(t)-2?s:fe),(o=>{if(a>Q(t)-2)return n?.(o)&&Ie(e,t[a]),o;const r=Ve(o,t,s,n,a+1);return ce(o)&&Ie(e,t[a]),r})),Ee=e=>{const s=t(e);return D(s)||s==o&&k(e)?s:void 0},ke=(e,t,s,n,a)=>M(a)?e.delCell(t,s,n,!0):e.setCell(t,s,n,a),Me=(e,t,s)=>M(s)?e.delValue(t):e.setValue(t,s),xe=e=>new Set(A(e)||M(e)?e:[e]),De=(e,t)=>e?.add(t),Je=(e,t,s,n,a)=>{const o=e.hasRow,r=fe(),i=fe(),l=fe(),c=fe(),d=fe(),u=fe(),h=(t,s,...n)=>{const a=Se(u,t,xe);return W(n,(t=>De(a,t)&&s&&e.callListener(t))),n},g=(t,...s)=>x(we(u,t),(n=>{W(q(s)?de(n):s,(t=>{e.delListener(t),ge(n,t)})),ce(n)&&Ie(u,t)})),f=(e,s)=>{Ie(r,e,s),le(i,e)||(Ie(i,e,t()),Ie(c,e,fe()),Ie(d,e,fe()),a(l))},L=e=>{Ie(r,e),Ie(i,e),Ie(c,e),Ie(d,e),g(e),a(l)};return[()=>e,()=>Le(r),e=>ve(i,e),e=>le(i,e),e=>we(r,e),e=>we(i,e),(e,t)=>Ie(i,e,t),f,(t,n,a,r,i)=>{f(t,n);const l=fe(),u=fe(),L=we(c,t),w=we(d,t),v=t=>{const a=s=>e.getCell(n,t,s),c=we(L,t),d=o(n,t)?s(r(a,t)):void 0;if(c===d||A(c)&&A(d)&&P(c,d)||Ie(l,t,[c,d]),!M(i)){const e=we(w,t),s=o(n,t)?i(a,t):void 0;e!=s&&Ie(u,t,s)}},I=e=>{a((()=>{he(l,(([,e],t)=>Ie(L,t,e))),he(u,((e,t)=>Ie(w,t,e)))}),l,u,L,w,e),ue(l),ue(u)};ve(L,v),e.hasTable(n)&&W(e.getRowIds(n),(e=>{le(L,e)||v(e)})),I(!0),g(t),h(t,0,e.addRowListener(n,null,((e,t,s)=>v(s))),e.addTableListener(n,(()=>I())))},L,e=>n(e,l),()=>ve(u,L),h,g]},Ae=(e,a)=>t(e)==n?t=>t(e):e??(()=>a??s),Fe=e=>{const t=new WeakMap;return s=>(t.has(s)||t.set(s,e(s)),t.get(s))},Qe=/^\d+$/,ze=()=>{const e=[];let t=0;return[n=>(n?X(e):null)??s+t++,t=>{Qe.test(t)&&Q(e)<1e3&&K(e,t)}]},Ne=e=>{let t;const[n,a]=ze(),o=fe();return[(a,r,i,l=[],c=(()=>[]))=>{t??=e();const d=n(1);return Ie(o,d,[a,r,i,l,c]),De(Ve(r,i??[s],xe),d),d},(e,n,...a)=>W(((e,t=[s])=>{const n=[],a=(e,s)=>s==Q(t)?K(n,e):null===t[s]?he(e,(e=>a(e,s+1))):W([t[s],null],(t=>a(we(e,t),s+1)));return a(e,0),n})(e,n),(e=>he(e,(e=>we(o,e)[0](t,...n??[],...a))))),e=>x(we(o,e),(([,t,n])=>(Ve(t,n??[s],void 0,(t=>(ge(t,e),ce(t)?1:0))),Ie(o,e),a(e),n))),e=>x(we(o,e),(([e,,s=[],n,a])=>{const o=(...r)=>{const i=Q(r);i==Q(s)?e(t,...r,...a(r)):M(s[i])?W(n[i]?.(...r)??[],(e=>o(...r,e))):o(...r,s[i])};o()}))]},Oe=Fe((e=>{let t,n,a,o=100,r=fe(),i=fe(),l=1;const c=fe(),d=fe(),[u,h,g]=Ne((()=>F)),f=fe(),L=fe(),w=[],v=[],I=(t,s)=>{l=0,e.transaction((()=>{const[n,a]=we(f,s);he(n,((s,n)=>he(s,((s,a)=>he(s,((s,o)=>ke(e,n,a,o,s[t]))))))),he(a,((s,n)=>Me(e,n,s[t])))})),l=1},S=e=>{Ie(f,e),Ie(L,e),h(d,[e])},y=(e,t)=>W(((e,t)=>e.splice(0,t))(e,t??Q(e)),S),T=()=>y(w,Q(w)-o),R=()=>x(t,(()=>{K(w,t),T(),y(v),t=void 0,a=1})),p=()=>{t=U(w),a=1},C=e.addCellListener(null,null,null,((e,t,s,n,a,o)=>{if(l){R();const e=Se(r,t,fe),i=Se(e,s,fe),l=Se(i,n,(()=>[o,void 0]));l[1]=a,l[0]===a&&ce(Ie(i,n))&&ce(Ie(e,s))&&ce(Ie(r,t))&&p(),k()}})),b=e.addValueListener(null,((e,t,s,n)=>{if(l){R();const e=Se(i,t,(()=>[n,void 0]));e[1]=s,e[0]===s&&ce(Ie(i,t))&&p(),k()}})),m=(e="")=>(M(t)&&(t=s+n++,Ie(f,t,[r,i]),J(t,e),r=fe(),i=fe(),a=1),t),V=()=>{q(w)||(((e,...t)=>{e.unshift(...t)})(v,m()),I(0,t),t=U(w),a=1)},E=()=>{q(v)||(K(w,t),t=X(v),I(1,t),a=1)},k=()=>{a&&(h(c),a=0)},D=e=>{const t=m(e);return k(),t},J=(e,t)=>(A(e)&&we(L,e)!==t&&(Ie(L,e,t),h(d,[e])),F),A=e=>le(f,e),F={setSize:e=>(o=e,T(),F),addCheckpoint:D,setCheckpoint:J,getStore:()=>e,getCheckpointIds:()=>[[...w],t,[...v]],forEachCheckpoint:e=>ve(L,e),hasCheckpoint:A,getCheckpoint:e=>we(L,e),goBackward:()=>(V(),k(),F),goForward:()=>(E(),k(),F),goTo:e=>{const s=N(w,e)?V:N(v,e)?E:null;for(;!M(s)&&e!=t;)s();return k(),F},addCheckpointIdsListener:e=>u(e,c),addCheckpointListener:(e,t)=>u(t,d,[e]),delListener:e=>(g(e),F),clear:()=>(y(w),y(v),M(t)||S(t),t=void 0,n=0,D(),F),destroy:()=>{e.delListener(C),e.delListener(b)},getListenerStats:()=>({})};return te(F.clear())})),Pe=(e,t)=>(e??0)<(t??0)?-1:1,je=Fe((e=>{const t=fe(),n=fe(),[a,o,r]=Ne((()=>S)),[i,l,c,d,u,h,g,,f,L,w,v]=Je(e,fe,(e=>M(e)?s:A(e)?H(e,m):m(e)),a,o),I=(t,s,n)=>{const a=u(t);he(n,((t,n)=>s(n,(s=>he(t,(t=>s(t,(s=>e.forEachCell(a,t,s)))))))))},S={setIndexDefinition:(e,s,a,r,i,l=Pe)=>{const c=M(i)?void 0:([e],[t])=>i(e,t);return f(e,s,((s,a,i,d,u,f)=>{let L=0;const w=xe(),v=xe(),I=h(e);if(he(a,(([e,t],s)=>{const n=xe(e),a=xe(t);he(n,(e=>ge(a,e)?ge(n,e):0)),he(n,(e=>{De(w,e),x(we(I,e),(t=>{ge(t,s),ce(t)&&(Ie(I,e),L=1)}))})),he(a,(e=>{De(w,e),le(I,e)||(Ie(I,e,xe()),L=1),De(we(I,e),s),M(r)||De(v,e)}))})),s(),ce(u)||(f?ve(I,(e=>De(v,e))):ve(i,(e=>x(we(d,e),(e=>De(v,e))))),he(v,(e=>{const t=(t,s)=>l(we(u,t),we(u,s),e),s=[...we(I,e)];j(s,t)||(Ie(I,e,xe(B(s,t))),De(w,e))}))),(L||f)&&!M(c)){const t=[...I];j(t,c)||(g(e,fe(B(t,c))),L=1)}L&&o(t,[e]),he(w,(t=>o(n,[e,t])))}),Ae(a),x(r,Ae)),S},delIndexDefinition:e=>(L(e),S),getStore:i,getIndexIds:l,forEachIndex:e=>c(((t,s)=>e(t,(e=>I(t,e,s))))),forEachSlice:(e,t)=>I(e,t,h(e)),hasIndex:d,hasSlice:(e,t)=>le(h(e),t),getTableId:u,getSliceIds:e=>Le(h(e)),getSliceRowIds:(e,t)=>de(we(h(e),t)),addIndexIdsListener:w,addSliceIdsListener:(e,s)=>a(s,t,[e]),addSliceRowIdsListener:(e,t,s)=>a(s,n,[e,t]),delListener:e=>(r(e),S),destroy:v,getListenerStats:()=>({})};return te(S)})),Be=fe([["avg",[(e,t)=>$(e)/t,(e,t,s)=>e+(t-e)/(s+1),(e,t,s)=>e+(e-t)/(s-1),(e,t,s,n)=>e+(t-s)/n]],["max",[e=>V(...e),(e,t)=>V(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:V(t,e)]],["min",[e=>E(...e),(e,t)=>E(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:E(t,e)]],["sum",[e=>$(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,s)=>e-s+t]]]),We=(e,t,s,n,a,o=!1)=>{if(ce(s))return;const[r,i,l,c]=a;return o||=M(e),he(n,(([s,n])=>{o||(e=M(s)?i?.(e,n,t++):M(n)?l?.(e,s,t--):c?.(e,n,s,t),o||=M(e))})),o?r(de(s),ie(s)):e},He=Fe((e=>{const t=fe(),[n,a,o]=Ne((()=>v)),[r,i,l,c,d,u,h,,g,f,L,w]=Je(e,z,(e=>isNaN(e)||M(e)||!0===e||!1===e||e===s?void 0:1*e),n,a),v={setMetricDefinition:(e,s,n,o,r,i,l)=>{const c=J(n)?[n,r,i,l]:we(Be,n)??we(Be,"sum");return g(e,s,((s,n,o,r,i,l)=>{const d=u(e),g=ie(r);l||=M(d),s();let f=We(d,g,r,n,c,l);k(f)||(f=void 0),f!=d&&(h(e,f),a(t,[e],f,d))}),Ae(o,1)),v},delMetricDefinition:e=>(f(e),v),getStore:r,getMetricIds:i,forEachMetric:l,hasMetric:c,getTableId:d,getMetric:u,addMetricIdsListener:L,addMetricListener:(e,s)=>n(s,t,[e]),delListener:e=>(o(e),v),destroy:w,getListenerStats:()=>({})};return te(v)})),$e=fe(),qe=fe(),Ge=Fe((e=>{const t=e.createStore,n=t(),a=t(),o=fe(),{addListener:r,callListeners:i,delListener:l}=a,[h,g,L,w,p,,,C,,b,m,V,E,k]=Je(e,(()=>!0),z,r,i),D=(e,t,...s)=>W(s,(s=>De(Se(Se(o,t,fe),e,xe),s))),A=e=>{x(we(o,e),(e=>{ve(e,((e,t)=>he(t,(t=>e.delListener(t))))),ue(e)})),W([a,n],(t=>t.delTable(e)))},N=(e,t,s)=>D(t,e,t.addStartTransactionListener(s.startTransaction),t.addDidFinishTransactionListener((()=>s.finishTransaction()))),P={setQueryDefinition:(t,o,r)=>{C(t,o),A(t);const i=[],l=[[null,[o,null,null,[],fe()]]],c=[],d=[],u=[];r({select:(e,t)=>{const n=J(e)?[Q(i)+s,e]:[M(t)?e:t,s=>s(e,t)];return K(i,n),{as:e=>n[0]=e}},join:(e,t,s)=>{const n=M(s)||J(t)?null:t,a=M(n)?t:s,o=[e,[e,n,J(a)?a:e=>e(a),[],fe()]];return K(l,o),{as:e=>o[0]=e}},where:(e,t,s)=>K(c,J(e)?e:M(s)?s=>s(e)===t:n=>n(e,t)===s),group:(e,t,s,n,a)=>{const o=[e,[e,J(t)?[t,s,n,a]:we(Be,t)??[(e,t)=>t]]];return K(d,o),{as:e=>o[0]=e}},having:(e,t)=>K(u,J(e)?e:s=>s(e)===t)});const h=fe(i);if(ce(h))return P;const g=fe(l);ve(g,((e,[,t])=>x(we(g,t),(({3:t})=>M(e)?0:K(t,e)))));const f=fe(d);let L=n;if(ce(f)&&q(u))L=a;else{N(t,L,a);const e=fe();ve(f,((t,[s,n])=>De(Se(e,s,xe),[t,n])));const s=xe();ve(h,(t=>le(e,t)?0:De(s,t)));const n=fe(),o=(s,n,o,r)=>x(s,(([i,l,c,d])=>{ve(n,((t,[s])=>{const n=Se(i,t,fe),a=we(n,o),l=r?void 0:s;if(a!==l){const s=xe([[a,l]]),r=ie(n);Ie(n,o,l),he(we(e,t),(([e,t])=>{const a=We(d[e],r,n,s,t);d[e]=M(Ee(a))?null:a}))}})),ce(l)||!O(u,(e=>e((e=>d[e]))))?a.delRow(t,c):M(c)?s[2]=a.addRow(t,d):a.setRow(t,c,d)}));D(L,t,L.addRowListener(t,null,((a,r,i,l)=>{const c=[],d=[],u=fe(),h=L.hasRow(t,i);let g=!h;he(s,(e=>{const[s,n,a]=l(t,i,e);K(c,n),K(d,a),g||=s})),ve(e,(e=>{const[s,,n]=l(t,i,e);(g||s)&&Ie(u,e,[n])})),g&&o(Ve(n,c,void 0,(([,e])=>(ge(e,i),ce(e)))),u,i,1),h&&o(Ve(n,d,(()=>{const e={};return he(s,(s=>e[s]=L.getCell(t,i,s))),[fe(),xe(),void 0,e]}),(([,e])=>{De(e,i)})),u,i)})))}N(t,e,L);const w=(s,n,a,r)=>{const i=t=>e.getCell(n,a,t);W(r,(n=>{const[a,,o,r,l]=we(g,n),c=o?.(i,s),[d,u]=we(l,s)??[];c!=d&&(M(u)||k(t,u),Ie(l,s,M(c)?null:[c,...E(t,1,e.addRowListener(a,c,(()=>w(s,a,c,r))))]))})),(s=>{const n=(t,n)=>e.getCell(...M(n)?[o,s,t]:t===o?[o,s,n]:[we(g,t)?.[0],we(we(g,t)?.[4],s)?.[0],n]);L.transaction((()=>O(c,(e=>e(n)))?ve(h,((e,a)=>ke(L,t,s,e,a(n,s)))):L.delRow(t,s)))})(s)},{3:v}=we(g,null);return L.transaction((()=>E(t,1,e.addRowListener(o,null,((s,n,a)=>{e.hasRow(o,a)?w(a,o,a,v):(L.delRow(t,a),he(g,(({4:e})=>x(we(e,a),(([,s])=>{k(t,s),Ie(e,a)})))))}))))),P},delQueryDefinition:e=>(A(e),b(e),P),getStore:h,getQueryIds:g,forEachQuery:L,hasQuery:w,getTableId:p,addQueryIdsListener:e=>m((()=>e(P))),delListener:e=>(l(e),P),destroy:V,getListenerStats:()=>{const{tables:e,tableIds:t,transaction:s,...n}=a.getListenerStats();return n}};return oe({[f]:[1,1],[f+R]:[0,1],[I]:[0,1],[S]:[0,1],[y]:[0,5],[v]:[1,2],[R]:[0,2],[T]:[1,3]},(([e,t],s)=>{W(e?["get","has","forEach"]:["get"],(e=>P[e+d+s]=(...t)=>a[e+s](...t))),P[u+d+s+c]=(...e)=>a[u+s+c](...F(e,0,t),((s,...n)=>e[t](P,...n)),!0)})),te(P)})),Ke=Fe((e=>{const t=fe(),n=fe(),a=fe(),o=fe(),[r,i,l]=Ne((()=>R)),[c,d,u,h,g,f,,,L,w,v,I]=Je(e,(()=>[fe(),fe(),fe(),fe()]),(e=>M(e)?void 0:e+s),r,i),S=(e,t,s)=>x(f(e),(([n,,a])=>{if(!le(a,t)){const o=xe();if(g(e)!=T(e))De(o,t);else{let e=t;for(;!M(e)&&!le(o,e);)De(o,e),e=we(n,e)}if(s)return o;Ie(a,t,o)}return we(a,t)})),y=(e,t)=>x(f(e),(([,,e])=>Ie(e,t))),T=e=>we(t,e),R={setRelationshipDefinition:(e,s,r,l)=>(Ie(t,e,r),L(e,s,((t,s)=>{const r=xe(),l=xe(),c=xe(),[d,u]=f(e);he(s,(([t,s],n)=>{M(t)||(De(l,t),x(we(u,t),(e=>{ge(e,n),ce(e)&&Ie(u,t)}))),M(s)||(De(l,s),le(u,s)||Ie(u,s,xe()),De(we(u,s),n)),De(r,n),Ie(d,n,s),ve(we(o,e),(t=>{le(S(e,t),n)&&De(c,t)}))})),t(),he(r,(t=>i(n,[e,t]))),he(l,(t=>i(a,[e,t]))),he(c,(t=>{y(e,t),i(o,[e,t])}))}),Ae(l)),R),delRelationshipDefinition:e=>(Ie(t,e),w(e),R),getStore:c,getRelationshipIds:d,forEachRelationship:t=>u((s=>t(s,(t=>e.forEachRow(g(s),t))))),hasRelationship:h,getLocalTableId:g,getRemoteTableId:T,getRemoteRowId:(e,t)=>we(f(e)?.[0],t),getLocalRowIds:(e,t)=>de(we(f(e)?.[1],t)),getLinkedRowIds:(e,t)=>M(f(e))?[t]:de(S(e,t,!0)),addRelationshipIdsListener:v,addRemoteRowIdListener:(e,t,s)=>r(s,n,[e,t]),addLocalRowIdsListener:(e,t,s)=>r(s,a,[e,t]),addLinkedRowIdsListener:(e,t,s)=>(S(e,t),r(s,o,[e,t])),delListener:e=>(y(...l(e)??[]),R),destroy:I,getListenerStats:()=>({})};return te(R)})),Ue=e=>[e,e],Xe=()=>[fe(),fe()],Ye=e=>[...e],Ze=([e,t])=>e===t,_e=e=>JSON.stringify(e,((e,t)=>t instanceof Map?Y.fromEntries([...t]):t)),et=JSON.parse,tt=(e,t,s)=>M(e)||!se(e)||re(e)||ee(e)?(s?.(),!1):(oe(e,((s,n)=>{t(s,n)||ae(e,n)})),!re(e)),st=(e,t,s)=>Ie(e,t,we(e,t)==-s?void 0:s),nt=()=>{let e,t,s=!1,n=!1,a=!1,r=!1,d=0;const g=fe(),y=fe(),V=fe(),E=fe(),k=fe(),A=fe(),Q=fe(),z=fe(),O=fe(),j=fe(),$=fe(),q=fe(),G=fe(),U=fe(),X=xe(),Y=fe(),Z=fe(),_=fe(),ee=fe(),se=Xe(),de=Xe(),Ve=Xe(),Je=Xe(),Ae=Xe(),Fe=Xe(),Qe=Xe(),Oe=Xe(),je=Xe(),Be=Xe(),We=Xe(),He=Xe(),$e=Xe(),qe=Xe(),Ge=Xe(),Ke=Xe(),at=Xe(),ot=Xe(),rt=Xe(),it=Xe(),lt=Xe(),ct=Xe(),dt=fe(),ut=Xe(),[ht,gt,ft,Lt]=Ne((()=>zs)),wt=e=>{if(!tt(e,((e,t)=>N([i,l],t))))return!1;const t=e[i];return!(!D(t)&&t!=o||(Ee(e[l])!=t&&ae(e,l),0))},vt=(t,s)=>(!e||le($,s)||Gt(s))&&tt(t,((e,t)=>It(s,t,e)),(()=>Gt(s))),It=(e,t,s,n)=>tt(n?s:Rt(s,e,t),((n,a)=>x(St(e,t,a,n),(e=>(s[a]=e,!0)),(()=>!1))),(()=>Gt(e,t))),St=(t,s,n,a)=>e?x(we(we($,t),n),(e=>Ee(a)!=e[i]?Gt(t,s,n,a,e[l]):a),(()=>Gt(t,s,n,a))):M(Ee(a))?Gt(t,s,n,a):a,yt=(e,t)=>tt(t?e:pt(e),((t,s)=>x(Tt(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>Kt())),Tt=(e,s)=>t?x(we(G,e),(t=>Ee(s)!=t[i]?Kt(e,s,t[l]):s),(()=>Kt(e,s))):M(Ee(s))?Kt(e,s):s,Rt=(e,t,s)=>(x(we(q,t),(([n,a])=>{he(n,((t,s)=>{ne(e,s)||(e[s]=t)})),he(a,(n=>{ne(e,n)||Gt(t,s,n)}))})),e),pt=e=>(t&&(he(U,((t,s)=>{ne(e,s)||(e[s]=t)})),he(X,(t=>{ne(e,t)||Kt(t)}))),e),Ct=e=>ye($,e,((e,t,s)=>{const n=fe(),a=xe();ye(Se($,t,fe),s,((e,t,s)=>{Ie(e,t,s),x(s[l],(e=>Ie(n,t,e)),(()=>De(a,t)))})),Ie(q,t,[n,a])}),((e,t)=>{Ie($,t),Ie(q,t)})),bt=e=>ye(G,e,((e,t,s)=>{Ie(G,t,s),x(s[l],(e=>Ie(U,t,e)),(()=>De(X,t)))}),((e,t)=>{Ie(G,t),Ie(U,t),ge(X,t)})),mt=e=>re(e)?Es():ps(e),Vt=e=>ye(_,e,((e,t,s)=>Et(t,s)),((e,t)=>zt(t))),Et=(e,t)=>ye(Se(_,e,(()=>(jt(e,1),Ie(Y,e,ze()),Ie(Z,e,fe()),fe()))),t,((t,s,n)=>kt(e,t,s,n)),((t,s)=>Nt(e,t,s))),kt=(e,t,s,n,a)=>ye(Se(t,s,(()=>(Bt(e,s,1),fe()))),n,((t,n,a)=>Mt(e,s,t,n,a)),((n,o)=>Ot(e,t,s,n,o,a))),Mt=(e,t,s,n,a)=>{le(s,n)||Wt(e,t,n,1);const o=we(s,n);a!==o&&(Ht(e,t,n,o,a),Ie(s,n,a))},xt=(e,t,s,n,a)=>x(we(t,s),(t=>Mt(e,s,t,n,a)),(()=>kt(e,t,s,Rt({[n]:a},e,s)))),Dt=e=>re(e)?xs():Cs(e),Jt=e=>ye(ee,e,((e,t,s)=>At(t,s)),((e,t)=>Pt(t))),At=(e,t)=>{le(ee,e)||$t(e,1);const s=we(ee,e);t!==s&&(qt(e,s,t),Ie(ee,e,t))},Ft=(e,t)=>{const[s]=we(Y,e),n=s(t);return le(we(_,e),n)?Ft(e,t):n},Qt=e=>we(_,e)??Et(e,{}),zt=e=>Et(e,{}),Nt=(e,t,s)=>{const[,n]=we(Y,e);n(s),kt(e,t,s,{},!0)},Ot=(e,t,s,n,a,o)=>{const r=we(we(q,e)?.[0],a);if(!M(r)&&!o)return Mt(e,s,n,a,r);const i=t=>{Ht(e,s,t,we(n,t)),Wt(e,s,t,-1),Ie(n,t)};M(r)?i(a):ve(n,i),ce(n)&&(Bt(e,s,-1),ce(Ie(t,s))&&(jt(e,-1),Ie(_,e),Ie(Y,e),Ie(Z,e)))},Pt=e=>{const t=we(U,e);if(!M(t))return At(e,t);qt(e,we(ee,e)),$t(e,-1),Ie(ee,e)},jt=(e,t)=>st(g,e,t),Bt=(e,t,s)=>st(Se(E,e,fe),t,s)&&Ie(V,e,Se(V,e,(()=>0))+s),Wt=(e,t,s,n)=>{const a=we(Z,e),o=we(a,s)??0;(0==o&&1==n||1==o&&-1==n)&&st(Se(y,e,fe),s,n),Ie(a,s,o!=-n?o+n:null),st(Se(Se(k,e,fe),t,fe),s,n)},Ht=(e,t,s,n,a)=>Se(Se(Se(A,e,fe),t,fe),s,(()=>[n,0]))[1]=a,$t=(e,t)=>st(Q,e,t),qt=(e,t,s)=>Se(z,e,(()=>[t,0]))[1]=s,Gt=(e,t,s,n,a)=>(K(Se(Se(Se(O,e,fe),t,fe),s,(()=>[])),n),a),Kt=(e,t,s)=>(K(Se(j,e,(()=>[])),t),s),Ut=(e,t,s)=>x(we(we(we(A,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...Ue(hs(e,t,s))])),Xt=e=>x(we(z,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Ue(Ls(e))])),Yt=e=>ce(O)||ce(Ke[e])?0:he(e?me(O):O,((t,s)=>he(t,((t,n)=>he(t,((t,a)=>gt(Ke[e],[s,n,a],t))))))),Zt=e=>ce(j)||ce(at[e])?0:he(e?Ce(j):j,((t,s)=>gt(at[e],[s],t))),_t=(e,t,s,n)=>{if(!ce(e))return gt(t,n,(()=>Te(e))),ve(e,((e,t)=>gt(s,[...n??[],e],1==t))),1},es=e=>{const t=ws();t!=a&&gt(se[e],void 0,t);const s=ce(Be[e]),n=ce($e[e])&&ce(qe[e])&&ce(je[e])&&ce(We[e])&&ce(Fe[e])&&ce(Qe[e])&&ce(Oe[e])&&s&&ce(Ve[e])&&ce(Je[e]),o=ce(Ge[e])&&ce(He[e])&&ce(Ae[e])&&ce(de[e]);if(!n||!o){const t=e?[Ce(g),be(y),Ce(V),be(E),me(k),me(A)]:[g,y,V,E,k,A];if(!n){_t(t[0],Ve[e],Je[e]),he(t[1],((t,s)=>_t(t,Fe[e],Qe[e],[s]))),he(t[2],((t,s)=>{0!=t&&gt(Oe[e],[s],ls(s))}));const n=xe();he(t[3],((t,a)=>{_t(t,je[e],We[e],[a])&&!s&&(gt(Be[e],[a,null]),De(n,a))})),s||he(t[5],((t,s)=>{if(!le(n,s)){const n=xe();he(t,(e=>he(e,(([t,s],a)=>s!==t?De(n,a):ge(e,a))))),he(n,(t=>gt(Be[e],[s,t])))}})),he(t[4],((t,s)=>he(t,((t,n)=>_t(t,$e[e],qe[e],[s,n])))))}if(!o){let s;he(t[5],((t,n)=>{let a;he(t,((t,o)=>{let r;he(t,(([t,i],l)=>{i!==t&&(gt(Ge[e],[n,o,l],i,t,Ut),s=a=r=1)})),r&&gt(He[e],[n,o],Ut)})),a&&gt(Ae[e],[n],Ut)})),s&&gt(de[e],void 0,Ut)}}},ts=e=>{const t=Ts();t!=r&&gt(ot[e],void 0,t);const s=ce(it[e])&&ce(lt[e]),n=ce(ct[e])&&ce(rt[e]);if(!s||!n){const t=e?[Ce(Q),Ce(z)]:[Q,z];if(s||_t(t[0],it[e],lt[e]),!n){let s;he(t[1],(([t,n],a)=>{n!==t&&(gt(ct[e],[a],n,t,Xt),s=1)})),s&&gt(rt[e],void 0,Xt)}}},ss=(e,...t)=>(As((()=>e(...H(t,m)))),zs),ns=()=>[Te(A,((e,t)=>-1===we(g,t)?null:Te(e,((e,s)=>-1===we(we(E,t),s)?null:Te(e,(([,e])=>e??null),((e,t)=>Ze(t)))),re)),re),Te(z,(([,e])=>e??null),((e,t)=>Ze(t)))],as=()=>({cellsTouched:s,valuesTouched:n,changedCells:pe(A,Ye,Ze),invalidCells:pe(O),changedValues:Te(z,Ye,Ze),invalidValues:Te(j),changedTableIds:Te(g),changedRowIds:Re(E),changedCellIds:pe(k),changedValueIds:Te(Q)}),os=()=>pe(_),rs=()=>Le(_),is=e=>Le(we(Z,m(e))),ls=e=>ie(we(_,m(e))),cs=e=>Le(we(_,m(e))),ds=(e,t,s,n=0,a)=>{return H(F(B((o=we(_,m(e)),r=(e,s)=>[M(t)?s:we(e,m(t)),s],H([...o?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>Pe(e,t)*(s?-1:1))),n,M(a)?a:n+a),(([,e])=>e));var o,r},us=(e,t)=>Le(we(we(_,m(e)),m(t))),hs=(e,t,s)=>we(we(we(_,m(e)),m(t)),m(s)),gs=()=>Te(ee),fs=()=>Le(ee),Ls=e=>we(ee,m(e)),ws=()=>!ce(_),vs=e=>le(_,m(e)),Is=(e,t)=>le(we(Z,m(e)),m(t)),Ss=(e,t)=>le(we(_,m(e)),m(t)),ys=(e,t,s)=>le(we(we(_,m(e)),m(t)),m(s)),Ts=()=>!ce(ee),Rs=e=>le(ee,m(e)),ps=e=>ss((()=>(e=>tt(e,vt,Gt))(e)?Vt(e):0)),Cs=e=>ss((()=>yt(e)?Jt(e):0)),bs=e=>{try{mt(et(e))}catch{}return zs},ms=t=>ss((()=>{if((e=tt(t,(e=>tt(e,wt))))&&(Ct(t),!ce(_))){const e=os();Es(),ps(e)}})),Vs=e=>ss((()=>{if(t=(e=>tt(e,wt))(e)){const s=gs();Js(),xs(),t=!0,bt(e),Cs(s)}})),Es=()=>ss((()=>Vt({}))),ks=e=>ss((e=>le(_,e)?zt(e):0),e),Ms=(e,t)=>ss(((e,t)=>x(we(_,e),(s=>le(s,t)?Nt(e,s,t):0))),e,t),xs=()=>ss((()=>Jt({}))),Ds=()=>ss((()=>{Ct({}),e=!1})),Js=()=>ss((()=>{bt({}),t=!1})),As=(e,t)=>{if(-1!=d){Fs();const s=e();return Qs(t),s}},Fs=()=>(-1!=d&&d++,1==d&&gt(dt,void 0,ns,as),zs),Qs=e=>(d>0&&(d--,0==d&&(s=!ce(A),n=!ce(z),d=1,Yt(1),s&&es(1),Zt(1),n&&ts(1),e?.(ns,as)&&(he(A,((e,t)=>he(e,((e,s)=>he(e,(([e],n)=>ke(zs,t,s,n,e))))))),he(z,(([e],t)=>Me(zs,t,e))),s=n=!1),gt(ut[0],void 0,ns,as),d=-1,Yt(0),s&&es(0),Zt(0),n&&ts(0),gt(ut[1],void 0,ns,as),d=0,s=n=!1,a=ws(),r=Ts(),W([g,y,V,E,k,A,O,Q,z,j],ue))),zs),zs={getContent:()=>[os(),gs()],getTables:os,getTableIds:rs,getTable:e=>Re(we(_,m(e))),getTableCellIds:is,getRowCount:ls,getRowIds:cs,getSortedRowIds:ds,getRow:(e,t)=>Te(we(we(_,m(e)),m(t))),getCellIds:us,getCell:hs,getValues:gs,getValueIds:fs,getValue:Ls,hasTables:ws,hasTable:vs,hasTableCell:Is,hasRow:Ss,hasCell:ys,hasValues:Ts,hasValue:Rs,getTablesJson:()=>_e(_),getValuesJson:()=>_e(ee),getJson:()=>_e([_,ee]),getTablesSchemaJson:()=>_e($),getValuesSchemaJson:()=>_e(G),getSchemaJson:()=>_e([$,G]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ss((()=>{(re(e)?Es:ps)(e),(re(t)?xs:Cs)(t)})),setTables:ps,setTable:(e,t)=>ss((e=>vt(t,e)?Et(e,t):0),e),setRow:(e,t,s)=>ss(((e,t)=>It(e,t,s)?kt(e,Qt(e),t,s):0),e,t),addRow:(e,t,s=!0)=>As((()=>{let n;return It(e,n,t)&&(e=m(e),kt(e,Qt(e),n=Ft(e,s?1:0),t)),n})),setPartialRow:(e,t,s)=>ss(((e,t)=>{if(It(e,t,s,1)){const n=Qt(e);oe(s,((s,a)=>xt(e,n,t,a,s)))}}),e,t),setCell:(e,t,s,n)=>ss(((e,t,s)=>x(St(e,t,s,J(n)?n(hs(e,t,s)):n),(n=>xt(e,Qt(e),t,s,n)))),e,t,s),setValues:Cs,setPartialValues:e=>ss((()=>yt(e,1)?oe(e,((e,t)=>At(t,e))):0)),setValue:(e,t)=>ss((e=>x(Tt(e,J(t)?t(Ls(e)):t),(t=>At(e,t)))),e),setTransactionChanges:e=>ss((()=>{oe(e[0],((e,t)=>M(e)?ks(t):oe(e,((e,s)=>M(e)?Ms(t,s):oe(e,((e,n)=>ke(zs,t,s,n,e))))))),oe(e[1],((e,t)=>Me(zs,t,e)))})),setTablesJson:bs,setValuesJson:e=>{try{Dt(et(e))}catch{}return zs},setJson:e=>ss((()=>{try{const[t,s]=et(e);mt(t),Dt(s)}catch{bs(e)}})),setTablesSchema:ms,setValuesSchema:Vs,setSchema:(e,t)=>ss((()=>{ms(e),Vs(t)})),delTables:Es,delTable:ks,delRow:Ms,delCell:(e,t,s,n)=>ss(((e,t,s)=>x(we(_,e),(a=>x(we(a,t),(o=>le(o,s)?Ot(e,a,t,o,s,n):0))))),e,t,s),delValues:xs,delValue:e=>ss((e=>le(ee,e)?Pt(e):0),e),delTablesSchema:Ds,delValuesSchema:Js,delSchema:()=>ss((()=>{Ds(),Js()})),transaction:As,startTransaction:Fs,finishTransaction:Qs,forEachTable:e=>he(_,((t,s)=>e(s,(e=>he(t,((t,s)=>e(s,(e=>ve(t,e))))))))),forEachTableCell:(e,t)=>ve(we(Z,m(e)),t),forEachRow:(e,t)=>he(we(_,m(e)),((e,s)=>t(s,(t=>ve(e,t))))),forEachCell:(e,t,s)=>ve(we(we(_,m(e)),m(t)),s),forEachValue:e=>ve(ee,e),addSortedRowIdsListener:(e,t,s,n,a,o,r)=>{let i=ds(e,t,s,n,a);return ht((()=>{const r=ds(e,t,s,n,a);P(r,i)||(i=r,o(zs,e,t,s,n,a,i))}),Be[r?1:0],[e,t],[rs])},addStartTransactionListener:e=>ht(e,dt),addWillFinishTransactionListener:e=>ht(e,ut[0]),addDidFinishTransactionListener:e=>ht(e,ut[1]),callListener:e=>(Lt(e),zs),delListener:e=>(ft(e),zs),getListenerStats:()=>({}),createStore:nt,addListener:ht,callListeners:gt};return oe({[h+L]:[0,se,[],()=>[ws()]],[L]:[0,de],[w]:[0,Ve],[h+f]:[1,Je,[rs],e=>[vs(...e)]],[f]:[1,Ae,[rs]],[f+R]:[1,Fe,[rs]],[h+f+T]:[2,Qe,[rs,is],e=>[Is(...e)]],[I]:[1,Oe,[rs]],[S]:[1,je,[rs]],[h+v]:[2,We,[rs,cs],e=>[Ss(...e)]],[v]:[2,He,[rs,cs]],[R]:[2,$e,[rs,cs]],[h+T]:[3,qe,[rs,cs,us],e=>[ys(...e)]],[T]:[3,Ge,[rs,cs,us],e=>Ue(hs(...e))],InvalidCell:[3,Ke],[h+C]:[0,ot,[],()=>[Ts()]],[C]:[0,rt],[b]:[0,it],[h+p]:[1,lt,[fs],e=>[Rs(...e)]],[p]:[1,ct,[fs],e=>Ue(Ls(e[0]))],InvalidValue:[1,at]},(([e,t,s,n],a)=>{zs[u+a+c]=(...a)=>ht(a[e],t[a[e+1]?1:0],e>0?F(a,0,e):void 0,s,n)})),te(zs)};e.createCheckpoints=Oe,e.createCustomPersister=(e,t,s,n,a,o,[r,i]=[],l=[])=>{let c,d,u,h=0,g=0;Se($e,l,(()=>0)),Se(qe,l,(()=>[]));const f=async e=>(2!=h&&(h=1,await L.schedule((async()=>{await e(),h=0}))),L),L={load:async(s,n)=>await f((async()=>{try{e.setContent(await t())}catch{e.setContent([s,n])}})),startAutoLoad:async(s={},a={})=>(L.stopAutoLoad(),await L.load(s,a),g=1,u=n((async(s,n)=>{if(n){const t=n();await f((async()=>e.setTransactionChanges(t)))}else await f((async()=>{try{e.setContent(s?.()??await t())}catch(e){o?.(e)}}))})),L),stopAutoLoad:()=>(g&&(a(u),u=void 0,g=0),L),save:async t=>(1!=h&&(h=2,await L.schedule((async()=>{try{await s(e.getContent,t)}catch(e){o?.(e)}h=0}))),L),startAutoSave:async()=>(await L.stopAutoSave().save(),c=e.addDidFinishTransactionListener(((e,t)=>{const[s,n]=t();re(s)&&re(n)||L.save((()=>[s,n]))})),L),stopAutoSave:()=>(x(c,e.delListener),c=void 0,L),schedule:async(...e)=>(K(we(qe,l),...e),await(async()=>{if(!we($e,l)){for(Ie($e,l,1);!M(d=X(we(qe,l)));)try{await d()}catch(e){o?.(e)}Ie($e,l,0)}})(),L),getStore:()=>e,destroy:()=>L.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return r&&(L[r]=()=>i),te(L)},e.createIndexes=je,e.createMetrics=He,e.createQueries=Ge,e.createRelationships=Ke,e.createStore=nt,e.defaultSorter=Pe},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBase={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,s="",n=t(s),a=t(!0),o=t(0),r=t(t),i="type",l="default",c="Listener",d="Result",u="add",h="Has",g="Ids",f="Table",L=f+"s",w=f+g,v="Row",I=v+"Count",S=v+g,y="Sorted"+v+g,T="Cell",R=T+g,p="Value",C=p+"s",b=p+g,m=e=>s+e,V=Math.max,E=Math.min,k=isFinite,M=e=>null==e,x=(e,t,s)=>M(e)?s?.():t(e),D=e=>e==n||e==a,J=e=>t(e)==r,A=e=>Array.isArray(e),F=(e,t,s)=>e.slice(t,s),Q=e=>e.length,z=()=>{},N=(e,t)=>e.includes(t),O=(e,t)=>e.every(t),P=(e,t)=>Q(e)===Q(t)&&O(e,((e,s)=>t[s]===e)),j=(e,t)=>O(e,((s,n)=>0==n||t(e[n-1],s)<=0)),B=(e,t)=>e.sort(t),W=(e,t)=>e.forEach(t),H=(e,t)=>e.map(t),$=e=>G(e,((e,t)=>e+t),0),q=e=>0==Q(e),G=(e,t,s)=>e.reduce(t,s),K=(e,...t)=>e.push(...t),U=e=>e.pop(),X=e=>e.shift(),Y=Object,Z=e=>Y.getPrototypeOf(e),_=Y.keys,ee=Y.isFrozen,te=Y.freeze,se=e=>!M(e)&&x(Z(e),(e=>e==Y.prototype||M(Z(e))),(()=>!0)),ne=(e,t)=>!M(((e,t)=>x(e,(e=>e[t])))(e,t)),ae=(e,t)=>(delete e[t],e),oe=(e,t)=>H(Y.entries(e),(([e,s])=>t(s,e))),re=e=>se(e)&&0==(e=>Q(_(e)))(e),ie=e=>e?.size??0,le=(e,t)=>e?.has(t)??!1,ce=e=>M(e)||0==ie(e),de=e=>[...e?.values()??[]],ue=e=>e.clear(),he=(e,t)=>e?.forEach(t),ge=(e,t)=>e?.delete(t),fe=e=>new Map(e),Le=e=>[...e?.keys()??[]],we=(e,t)=>e?.get(t),ve=(e,t)=>he(e,((e,s)=>t(s,e))),Ie=(e,t,s)=>M(s)?(ge(e,t),e):e?.set(t,s),Se=(e,t,s)=>(le(e,t)||Ie(e,t,s()),we(e,t)),ye=(e,t,s,n=Ie)=>(oe(t,((t,n)=>s(e,n,t))),ve(e,(s=>ne(t,s)?0:n(e,s))),e),Te=(e,t,s)=>{const n={};return he(e,((e,a)=>{const o=t?t(e,a):e;!s?.(o,e)&&(n[a]=o)})),n},Re=(e,t,s)=>Te(e,(e=>Te(e,t,s)),re),pe=(e,t,s)=>Te(e,(e=>Re(e,t,s)),re),Ce=(e,t)=>{const s=fe();return he(e,((e,n)=>s.set(n,t?.(e)??e))),s},be=e=>Ce(e,Ce),me=e=>Ce(e,be),Ve=(e,t,s,n,a=0)=>x((s?Se:we)(e,t[a],a>Q(t)-2?s:fe),(o=>{if(a>Q(t)-2)return n?.(o)&&Ie(e,t[a]),o;const r=Ve(o,t,s,n,a+1);return ce(o)&&Ie(e,t[a]),r})),Ee=e=>{const s=t(e);return D(s)||s==o&&k(e)?s:void 0},ke=(e,t,s,n,a)=>M(a)?e.delCell(t,s,n,!0):e.setCell(t,s,n,a),Me=(e,t,s)=>M(s)?e.delValue(t):e.setValue(t,s),xe=e=>new Set(A(e)||M(e)?e:[e]),De=(e,t)=>e?.add(t),Je=(e,t,s,n,a)=>{const o=e.hasRow,r=fe(),i=fe(),l=fe(),c=fe(),d=fe(),u=fe(),h=(t,s,...n)=>{const a=Se(u,t,xe);return W(n,(t=>De(a,t)&&s&&e.callListener(t))),n},g=(t,...s)=>x(we(u,t),(n=>{W(q(s)?de(n):s,(t=>{e.delListener(t),ge(n,t)})),ce(n)&&Ie(u,t)})),f=(e,s)=>{Ie(r,e,s),le(i,e)||(Ie(i,e,t()),Ie(c,e,fe()),Ie(d,e,fe()),a(l))},L=e=>{Ie(r,e),Ie(i,e),Ie(c,e),Ie(d,e),g(e),a(l)};return[()=>e,()=>Le(r),e=>ve(i,e),e=>le(i,e),e=>we(r,e),e=>we(i,e),(e,t)=>Ie(i,e,t),f,(t,n,a,r,i)=>{f(t,n);const l=fe(),u=fe(),L=we(c,t),w=we(d,t),v=t=>{const a=s=>e.getCell(n,t,s),c=we(L,t),d=o(n,t)?s(r(a,t)):void 0;if(c===d||A(c)&&A(d)&&P(c,d)||Ie(l,t,[c,d]),!M(i)){const e=we(w,t),s=o(n,t)?i(a,t):void 0;e!=s&&Ie(u,t,s)}},I=e=>{a((()=>{he(l,(([,e],t)=>Ie(L,t,e))),he(u,((e,t)=>Ie(w,t,e)))}),l,u,L,w,e),ue(l),ue(u)};ve(L,v),e.hasTable(n)&&W(e.getRowIds(n),(e=>{le(L,e)||v(e)})),I(!0),g(t),h(t,0,e.addRowListener(n,null,((e,t,s)=>v(s))),e.addTableListener(n,(()=>I())))},L,e=>n(e,l),()=>ve(u,L),h,g]},Ae=(e,a)=>t(e)==n?t=>t(e):e??(()=>a??s),Fe=e=>{const t=new WeakMap;return s=>(t.has(s)||t.set(s,e(s)),t.get(s))},Qe=/^\d+$/,ze=()=>{const e=[];let t=0;return[n=>(n?X(e):null)??s+t++,t=>{Qe.test(t)&&Q(e)<1e3&&K(e,t)}]},Ne=e=>{let t;const[n,a]=ze(),o=fe();return[(a,r,i,l=[],c=(()=>[]))=>{t??=e();const d=n(1);return Ie(o,d,[a,r,i,l,c]),De(Ve(r,i??[s],xe),d),d},(e,n,...a)=>W(((e,t=[s])=>{const n=[],a=(e,s)=>s==Q(t)?K(n,e):null===t[s]?he(e,(e=>a(e,s+1))):W([t[s],null],(t=>a(we(e,t),s+1)));return a(e,0),n})(e,n),(e=>he(e,(e=>we(o,e)[0](t,...n??[],...a))))),e=>x(we(o,e),(([,t,n])=>(Ve(t,n??[s],void 0,(t=>(ge(t,e),ce(t)?1:0))),Ie(o,e),a(e),n))),e=>x(we(o,e),(([e,,s=[],n,a])=>{const o=(...r)=>{const i=Q(r);i==Q(s)?e(t,...r,...a(r)):M(s[i])?W(n[i]?.(...r)??[],(e=>o(...r,e))):o(...r,s[i])};o()}))]},Oe=Fe((e=>{let t,n,a,o=100,r=fe(),i=fe(),l=1;const c=fe(),d=fe(),[u,h,g]=Ne((()=>F)),f=fe(),L=fe(),w=[],v=[],I=(t,s)=>{l=0,e.transaction((()=>{const[n,a]=we(f,s);he(n,((s,n)=>he(s,((s,a)=>he(s,((s,o)=>ke(e,n,a,o,s[t]))))))),he(a,((s,n)=>Me(e,n,s[t])))})),l=1},S=e=>{Ie(f,e),Ie(L,e),h(d,[e])},y=(e,t)=>W(((e,t)=>e.splice(0,t))(e,t??Q(e)),S),T=()=>y(w,Q(w)-o),R=()=>x(t,(()=>{K(w,t),T(),y(v),t=void 0,a=1})),p=()=>{t=U(w),a=1},C=e.addCellListener(null,null,null,((e,t,s,n,a,o)=>{if(l){R();const e=Se(r,t,fe),i=Se(e,s,fe),l=Se(i,n,(()=>[o,void 0]));l[1]=a,l[0]===a&&ce(Ie(i,n))&&ce(Ie(e,s))&&ce(Ie(r,t))&&p(),k()}})),b=e.addValueListener(null,((e,t,s,n)=>{if(l){R();const e=Se(i,t,(()=>[n,void 0]));e[1]=s,e[0]===s&&ce(Ie(i,t))&&p(),k()}})),m=(e="")=>(M(t)&&(t=s+n++,Ie(f,t,[r,i]),J(t,e),r=fe(),i=fe(),a=1),t),V=()=>{q(w)||(((e,...t)=>{e.unshift(...t)})(v,m()),I(0,t),t=U(w),a=1)},E=()=>{q(v)||(K(w,t),t=X(v),I(1,t),a=1)},k=()=>{a&&(h(c),a=0)},D=e=>{const t=m(e);return k(),t},J=(e,t)=>(A(e)&&we(L,e)!==t&&(Ie(L,e,t),h(d,[e])),F),A=e=>le(f,e),F={setSize:e=>(o=e,T(),F),addCheckpoint:D,setCheckpoint:J,getStore:()=>e,getCheckpointIds:()=>[[...w],t,[...v]],forEachCheckpoint:e=>ve(L,e),hasCheckpoint:A,getCheckpoint:e=>we(L,e),goBackward:()=>(V(),k(),F),goForward:()=>(E(),k(),F),goTo:e=>{const s=N(w,e)?V:N(v,e)?E:null;for(;!M(s)&&e!=t;)s();return k(),F},addCheckpointIdsListener:e=>u(e,c),addCheckpointListener:(e,t)=>u(t,d,[e]),delListener:e=>(g(e),F),clear:()=>(y(w),y(v),M(t)||S(t),t=void 0,n=0,D(),F),clearForward:()=>(q(v)||(y(v),h(c)),F),destroy:()=>{e.delListener(C),e.delListener(b)},getListenerStats:()=>({})};return te(F.clear())})),Pe=(e,t)=>(e??0)<(t??0)?-1:1,je=Fe((e=>{const t=fe(),n=fe(),[a,o,r]=Ne((()=>S)),[i,l,c,d,u,h,g,,f,L,w,v]=Je(e,fe,(e=>M(e)?s:A(e)?H(e,m):m(e)),a,o),I=(t,s,n)=>{const a=u(t);he(n,((t,n)=>s(n,(s=>he(t,(t=>s(t,(s=>e.forEachCell(a,t,s)))))))))},S={setIndexDefinition:(e,s,a,r,i,l=Pe)=>{const c=M(i)?void 0:([e],[t])=>i(e,t);return f(e,s,((s,a,i,d,u,f)=>{let L=0;const w=xe(),v=xe(),I=h(e);if(he(a,(([e,t],s)=>{const n=xe(e),a=xe(t);he(n,(e=>ge(a,e)?ge(n,e):0)),he(n,(e=>{De(w,e),x(we(I,e),(t=>{ge(t,s),ce(t)&&(Ie(I,e),L=1)}))})),he(a,(e=>{De(w,e),le(I,e)||(Ie(I,e,xe()),L=1),De(we(I,e),s),M(r)||De(v,e)}))})),s(),ce(u)||(f?ve(I,(e=>De(v,e))):ve(i,(e=>x(we(d,e),(e=>De(v,e))))),he(v,(e=>{const t=(t,s)=>l(we(u,t),we(u,s),e),s=[...we(I,e)];j(s,t)||(Ie(I,e,xe(B(s,t))),De(w,e))}))),(L||f)&&!M(c)){const t=[...I];j(t,c)||(g(e,fe(B(t,c))),L=1)}L&&o(t,[e]),he(w,(t=>o(n,[e,t])))}),Ae(a),x(r,Ae)),S},delIndexDefinition:e=>(L(e),S),getStore:i,getIndexIds:l,forEachIndex:e=>c(((t,s)=>e(t,(e=>I(t,e,s))))),forEachSlice:(e,t)=>I(e,t,h(e)),hasIndex:d,hasSlice:(e,t)=>le(h(e),t),getTableId:u,getSliceIds:e=>Le(h(e)),getSliceRowIds:(e,t)=>de(we(h(e),t)),addIndexIdsListener:w,addSliceIdsListener:(e,s)=>a(s,t,[e]),addSliceRowIdsListener:(e,t,s)=>a(s,n,[e,t]),delListener:e=>(r(e),S),destroy:v,getListenerStats:()=>({})};return te(S)})),Be=fe([["avg",[(e,t)=>$(e)/t,(e,t,s)=>e+(t-e)/(s+1),(e,t,s)=>e+(e-t)/(s-1),(e,t,s,n)=>e+(t-s)/n]],["max",[e=>V(...e),(e,t)=>V(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:V(t,e)]],["min",[e=>E(...e),(e,t)=>E(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:E(t,e)]],["sum",[e=>$(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,s)=>e-s+t]]]),We=(e,t,s,n,a,o=!1)=>{if(ce(s))return;const[r,i,l,c]=a;return o||=M(e),he(n,(([s,n])=>{o||(e=M(s)?i?.(e,n,t++):M(n)?l?.(e,s,t--):c?.(e,n,s,t),o||=M(e))})),o?r(de(s),ie(s)):e},He=Fe((e=>{const t=fe(),[n,a,o]=Ne((()=>v)),[r,i,l,c,d,u,h,,g,f,L,w]=Je(e,z,(e=>isNaN(e)||M(e)||!0===e||!1===e||e===s?void 0:1*e),n,a),v={setMetricDefinition:(e,s,n,o,r,i,l)=>{const c=J(n)?[n,r,i,l]:we(Be,n)??we(Be,"sum");return g(e,s,((s,n,o,r,i,l)=>{const d=u(e),g=ie(r);l||=M(d),s();let f=We(d,g,r,n,c,l);k(f)||(f=void 0),f!=d&&(h(e,f),a(t,[e],f,d))}),Ae(o,1)),v},delMetricDefinition:e=>(f(e),v),getStore:r,getMetricIds:i,forEachMetric:l,hasMetric:c,getTableId:d,getMetric:u,addMetricIdsListener:L,addMetricListener:(e,s)=>n(s,t,[e]),delListener:e=>(o(e),v),destroy:w,getListenerStats:()=>({})};return te(v)})),$e=fe(),qe=fe(),Ge=Fe((e=>{const t=e.createStore,n=t(),a=t(),o=fe(),{addListener:r,callListeners:i,delListener:l}=a,[h,g,L,w,p,,,C,,b,m,V,E,k]=Je(e,(()=>!0),z,r,i),D=(e,t,...s)=>W(s,(s=>De(Se(Se(o,t,fe),e,xe),s))),A=e=>{x(we(o,e),(e=>{ve(e,((e,t)=>he(t,(t=>e.delListener(t))))),ue(e)})),W([a,n],(t=>t.delTable(e)))},N=(e,t,s)=>D(t,e,t.addStartTransactionListener(s.startTransaction),t.addDidFinishTransactionListener((()=>s.finishTransaction()))),P={setQueryDefinition:(t,o,r)=>{C(t,o),A(t);const i=[],l=[[null,[o,null,null,[],fe()]]],c=[],d=[],u=[];r({select:(e,t)=>{const n=J(e)?[Q(i)+s,e]:[M(t)?e:t,s=>s(e,t)];return K(i,n),{as:e=>n[0]=e}},join:(e,t,s)=>{const n=M(s)||J(t)?null:t,a=M(n)?t:s,o=[e,[e,n,J(a)?a:e=>e(a),[],fe()]];return K(l,o),{as:e=>o[0]=e}},where:(e,t,s)=>K(c,J(e)?e:M(s)?s=>s(e)===t:n=>n(e,t)===s),group:(e,t,s,n,a)=>{const o=[e,[e,J(t)?[t,s,n,a]:we(Be,t)??[(e,t)=>t]]];return K(d,o),{as:e=>o[0]=e}},having:(e,t)=>K(u,J(e)?e:s=>s(e)===t)});const h=fe(i);if(ce(h))return P;const g=fe(l);ve(g,((e,[,t])=>x(we(g,t),(({3:t})=>M(e)?0:K(t,e)))));const f=fe(d);let L=n;if(ce(f)&&q(u))L=a;else{N(t,L,a);const e=fe();ve(f,((t,[s,n])=>De(Se(e,s,xe),[t,n])));const s=xe();ve(h,(t=>le(e,t)?0:De(s,t)));const n=fe(),o=(s,n,o,r)=>x(s,(([i,l,c,d])=>{ve(n,((t,[s])=>{const n=Se(i,t,fe),a=we(n,o),l=r?void 0:s;if(a!==l){const s=xe([[a,l]]),r=ie(n);Ie(n,o,l),he(we(e,t),(([e,t])=>{const a=We(d[e],r,n,s,t);d[e]=M(Ee(a))?null:a}))}})),ce(l)||!O(u,(e=>e((e=>d[e]))))?a.delRow(t,c):M(c)?s[2]=a.addRow(t,d):a.setRow(t,c,d)}));D(L,t,L.addRowListener(t,null,((a,r,i,l)=>{const c=[],d=[],u=fe(),h=L.hasRow(t,i);let g=!h;he(s,(e=>{const[s,n,a]=l(t,i,e);K(c,n),K(d,a),g||=s})),ve(e,(e=>{const[s,,n]=l(t,i,e);(g||s)&&Ie(u,e,[n])})),g&&o(Ve(n,c,void 0,(([,e])=>(ge(e,i),ce(e)))),u,i,1),h&&o(Ve(n,d,(()=>{const e={};return he(s,(s=>e[s]=L.getCell(t,i,s))),[fe(),xe(),void 0,e]}),(([,e])=>{De(e,i)})),u,i)})))}N(t,e,L);const w=(s,n,a,r)=>{const i=t=>e.getCell(n,a,t);W(r,(n=>{const[a,,o,r,l]=we(g,n),c=o?.(i,s),[d,u]=we(l,s)??[];c!=d&&(M(u)||k(t,u),Ie(l,s,M(c)?null:[c,...E(t,1,e.addRowListener(a,c,(()=>w(s,a,c,r))))]))})),(s=>{const n=(t,n)=>e.getCell(...M(n)?[o,s,t]:t===o?[o,s,n]:[we(g,t)?.[0],we(we(g,t)?.[4],s)?.[0],n]);L.transaction((()=>O(c,(e=>e(n)))?ve(h,((e,a)=>ke(L,t,s,e,a(n,s)))):L.delRow(t,s)))})(s)},{3:v}=we(g,null);return L.transaction((()=>E(t,1,e.addRowListener(o,null,((s,n,a)=>{e.hasRow(o,a)?w(a,o,a,v):(L.delRow(t,a),he(g,(({4:e})=>x(we(e,a),(([,s])=>{k(t,s),Ie(e,a)})))))}))))),P},delQueryDefinition:e=>(A(e),b(e),P),getStore:h,getQueryIds:g,forEachQuery:L,hasQuery:w,getTableId:p,addQueryIdsListener:e=>m((()=>e(P))),delListener:e=>(l(e),P),destroy:V,getListenerStats:()=>{const{tables:e,tableIds:t,transaction:s,...n}=a.getListenerStats();return n}};return oe({[f]:[1,1],[f+R]:[0,1],[I]:[0,1],[S]:[0,1],[y]:[0,5],[v]:[1,2],[R]:[0,2],[T]:[1,3]},(([e,t],s)=>{W(e?["get","has","forEach"]:["get"],(e=>P[e+d+s]=(...t)=>a[e+s](...t))),P[u+d+s+c]=(...e)=>a[u+s+c](...F(e,0,t),((s,...n)=>e[t](P,...n)),!0)})),te(P)})),Ke=Fe((e=>{const t=fe(),n=fe(),a=fe(),o=fe(),[r,i,l]=Ne((()=>R)),[c,d,u,h,g,f,,,L,w,v,I]=Je(e,(()=>[fe(),fe(),fe(),fe()]),(e=>M(e)?void 0:e+s),r,i),S=(e,t,s)=>x(f(e),(([n,,a])=>{if(!le(a,t)){const o=xe();if(g(e)!=T(e))De(o,t);else{let e=t;for(;!M(e)&&!le(o,e);)De(o,e),e=we(n,e)}if(s)return o;Ie(a,t,o)}return we(a,t)})),y=(e,t)=>x(f(e),(([,,e])=>Ie(e,t))),T=e=>we(t,e),R={setRelationshipDefinition:(e,s,r,l)=>(Ie(t,e,r),L(e,s,((t,s)=>{const r=xe(),l=xe(),c=xe(),[d,u]=f(e);he(s,(([t,s],n)=>{M(t)||(De(l,t),x(we(u,t),(e=>{ge(e,n),ce(e)&&Ie(u,t)}))),M(s)||(De(l,s),le(u,s)||Ie(u,s,xe()),De(we(u,s),n)),De(r,n),Ie(d,n,s),ve(we(o,e),(t=>{le(S(e,t),n)&&De(c,t)}))})),t(),he(r,(t=>i(n,[e,t]))),he(l,(t=>i(a,[e,t]))),he(c,(t=>{y(e,t),i(o,[e,t])}))}),Ae(l)),R),delRelationshipDefinition:e=>(Ie(t,e),w(e),R),getStore:c,getRelationshipIds:d,forEachRelationship:t=>u((s=>t(s,(t=>e.forEachRow(g(s),t))))),hasRelationship:h,getLocalTableId:g,getRemoteTableId:T,getRemoteRowId:(e,t)=>we(f(e)?.[0],t),getLocalRowIds:(e,t)=>de(we(f(e)?.[1],t)),getLinkedRowIds:(e,t)=>M(f(e))?[t]:de(S(e,t,!0)),addRelationshipIdsListener:v,addRemoteRowIdListener:(e,t,s)=>r(s,n,[e,t]),addLocalRowIdsListener:(e,t,s)=>r(s,a,[e,t]),addLinkedRowIdsListener:(e,t,s)=>(S(e,t),r(s,o,[e,t])),delListener:e=>(y(...l(e)??[]),R),destroy:I,getListenerStats:()=>({})};return te(R)})),Ue=e=>[e,e],Xe=()=>[fe(),fe()],Ye=e=>[...e],Ze=([e,t])=>e===t,_e=e=>JSON.stringify(e,((e,t)=>t instanceof Map?Y.fromEntries([...t]):t)),et=JSON.parse,tt=(e,t,s)=>M(e)||!se(e)||re(e)||ee(e)?(s?.(),!1):(oe(e,((s,n)=>{t(s,n)||ae(e,n)})),!re(e)),st=(e,t,s)=>Ie(e,t,we(e,t)==-s?void 0:s),nt=()=>{let e,t,s=!1,n=!1,a=!1,r=!1,d=0;const g=fe(),y=fe(),V=fe(),E=fe(),k=fe(),A=fe(),Q=fe(),z=fe(),O=fe(),j=fe(),$=fe(),q=fe(),G=fe(),U=fe(),X=xe(),Y=fe(),Z=fe(),_=fe(),ee=fe(),se=Xe(),de=Xe(),Ve=Xe(),Je=Xe(),Ae=Xe(),Fe=Xe(),Qe=Xe(),Oe=Xe(),je=Xe(),Be=Xe(),We=Xe(),He=Xe(),$e=Xe(),qe=Xe(),Ge=Xe(),Ke=Xe(),at=Xe(),ot=Xe(),rt=Xe(),it=Xe(),lt=Xe(),ct=Xe(),dt=fe(),ut=Xe(),[ht,gt,ft,Lt]=Ne((()=>zs)),wt=e=>{if(!tt(e,((e,t)=>N([i,l],t))))return!1;const t=e[i];return!(!D(t)&&t!=o||(Ee(e[l])!=t&&ae(e,l),0))},vt=(t,s)=>(!e||le($,s)||Gt(s))&&tt(t,((e,t)=>It(s,t,e)),(()=>Gt(s))),It=(e,t,s,n)=>tt(n?s:Rt(s,e,t),((n,a)=>x(St(e,t,a,n),(e=>(s[a]=e,!0)),(()=>!1))),(()=>Gt(e,t))),St=(t,s,n,a)=>e?x(we(we($,t),n),(e=>Ee(a)!=e[i]?Gt(t,s,n,a,e[l]):a),(()=>Gt(t,s,n,a))):M(Ee(a))?Gt(t,s,n,a):a,yt=(e,t)=>tt(t?e:pt(e),((t,s)=>x(Tt(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>Kt())),Tt=(e,s)=>t?x(we(G,e),(t=>Ee(s)!=t[i]?Kt(e,s,t[l]):s),(()=>Kt(e,s))):M(Ee(s))?Kt(e,s):s,Rt=(e,t,s)=>(x(we(q,t),(([n,a])=>{he(n,((t,s)=>{ne(e,s)||(e[s]=t)})),he(a,(n=>{ne(e,n)||Gt(t,s,n)}))})),e),pt=e=>(t&&(he(U,((t,s)=>{ne(e,s)||(e[s]=t)})),he(X,(t=>{ne(e,t)||Kt(t)}))),e),Ct=e=>ye($,e,((e,t,s)=>{const n=fe(),a=xe();ye(Se($,t,fe),s,((e,t,s)=>{Ie(e,t,s),x(s[l],(e=>Ie(n,t,e)),(()=>De(a,t)))})),Ie(q,t,[n,a])}),((e,t)=>{Ie($,t),Ie(q,t)})),bt=e=>ye(G,e,((e,t,s)=>{Ie(G,t,s),x(s[l],(e=>Ie(U,t,e)),(()=>De(X,t)))}),((e,t)=>{Ie(G,t),Ie(U,t),ge(X,t)})),mt=e=>re(e)?Es():ps(e),Vt=e=>ye(_,e,((e,t,s)=>Et(t,s)),((e,t)=>zt(t))),Et=(e,t)=>ye(Se(_,e,(()=>(jt(e,1),Ie(Y,e,ze()),Ie(Z,e,fe()),fe()))),t,((t,s,n)=>kt(e,t,s,n)),((t,s)=>Nt(e,t,s))),kt=(e,t,s,n,a)=>ye(Se(t,s,(()=>(Bt(e,s,1),fe()))),n,((t,n,a)=>Mt(e,s,t,n,a)),((n,o)=>Ot(e,t,s,n,o,a))),Mt=(e,t,s,n,a)=>{le(s,n)||Wt(e,t,n,1);const o=we(s,n);a!==o&&(Ht(e,t,n,o,a),Ie(s,n,a))},xt=(e,t,s,n,a)=>x(we(t,s),(t=>Mt(e,s,t,n,a)),(()=>kt(e,t,s,Rt({[n]:a},e,s)))),Dt=e=>re(e)?xs():Cs(e),Jt=e=>ye(ee,e,((e,t,s)=>At(t,s)),((e,t)=>Pt(t))),At=(e,t)=>{le(ee,e)||$t(e,1);const s=we(ee,e);t!==s&&(qt(e,s,t),Ie(ee,e,t))},Ft=(e,t)=>{const[s]=we(Y,e),n=s(t);return le(we(_,e),n)?Ft(e,t):n},Qt=e=>we(_,e)??Et(e,{}),zt=e=>Et(e,{}),Nt=(e,t,s)=>{const[,n]=we(Y,e);n(s),kt(e,t,s,{},!0)},Ot=(e,t,s,n,a,o)=>{const r=we(we(q,e)?.[0],a);if(!M(r)&&!o)return Mt(e,s,n,a,r);const i=t=>{Ht(e,s,t,we(n,t)),Wt(e,s,t,-1),Ie(n,t)};M(r)?i(a):ve(n,i),ce(n)&&(Bt(e,s,-1),ce(Ie(t,s))&&(jt(e,-1),Ie(_,e),Ie(Y,e),Ie(Z,e)))},Pt=e=>{const t=we(U,e);if(!M(t))return At(e,t);qt(e,we(ee,e)),$t(e,-1),Ie(ee,e)},jt=(e,t)=>st(g,e,t),Bt=(e,t,s)=>st(Se(E,e,fe),t,s)&&Ie(V,e,Se(V,e,(()=>0))+s),Wt=(e,t,s,n)=>{const a=we(Z,e),o=we(a,s)??0;(0==o&&1==n||1==o&&-1==n)&&st(Se(y,e,fe),s,n),Ie(a,s,o!=-n?o+n:null),st(Se(Se(k,e,fe),t,fe),s,n)},Ht=(e,t,s,n,a)=>Se(Se(Se(A,e,fe),t,fe),s,(()=>[n,0]))[1]=a,$t=(e,t)=>st(Q,e,t),qt=(e,t,s)=>Se(z,e,(()=>[t,0]))[1]=s,Gt=(e,t,s,n,a)=>(K(Se(Se(Se(O,e,fe),t,fe),s,(()=>[])),n),a),Kt=(e,t,s)=>(K(Se(j,e,(()=>[])),t),s),Ut=(e,t,s)=>x(we(we(we(A,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...Ue(hs(e,t,s))])),Xt=e=>x(we(z,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Ue(Ls(e))])),Yt=e=>ce(O)||ce(Ke[e])?0:he(e?me(O):O,((t,s)=>he(t,((t,n)=>he(t,((t,a)=>gt(Ke[e],[s,n,a],t))))))),Zt=e=>ce(j)||ce(at[e])?0:he(e?Ce(j):j,((t,s)=>gt(at[e],[s],t))),_t=(e,t,s,n)=>{if(!ce(e))return gt(t,n,(()=>Te(e))),ve(e,((e,t)=>gt(s,[...n??[],e],1==t))),1},es=e=>{const t=ws();t!=a&&gt(se[e],void 0,t);const s=ce(Be[e]),n=ce($e[e])&&ce(qe[e])&&ce(je[e])&&ce(We[e])&&ce(Fe[e])&&ce(Qe[e])&&ce(Oe[e])&&s&&ce(Ve[e])&&ce(Je[e]),o=ce(Ge[e])&&ce(He[e])&&ce(Ae[e])&&ce(de[e]);if(!n||!o){const t=e?[Ce(g),be(y),Ce(V),be(E),me(k),me(A)]:[g,y,V,E,k,A];if(!n){_t(t[0],Ve[e],Je[e]),he(t[1],((t,s)=>_t(t,Fe[e],Qe[e],[s]))),he(t[2],((t,s)=>{0!=t&&gt(Oe[e],[s],ls(s))}));const n=xe();he(t[3],((t,a)=>{_t(t,je[e],We[e],[a])&&!s&&(gt(Be[e],[a,null]),De(n,a))})),s||he(t[5],((t,s)=>{if(!le(n,s)){const n=xe();he(t,(e=>he(e,(([t,s],a)=>s!==t?De(n,a):ge(e,a))))),he(n,(t=>gt(Be[e],[s,t])))}})),he(t[4],((t,s)=>he(t,((t,n)=>_t(t,$e[e],qe[e],[s,n])))))}if(!o){let s;he(t[5],((t,n)=>{let a;he(t,((t,o)=>{let r;he(t,(([t,i],l)=>{i!==t&&(gt(Ge[e],[n,o,l],i,t,Ut),s=a=r=1)})),r&&gt(He[e],[n,o],Ut)})),a&&gt(Ae[e],[n],Ut)})),s&&gt(de[e],void 0,Ut)}}},ts=e=>{const t=Ts();t!=r&&gt(ot[e],void 0,t);const s=ce(it[e])&&ce(lt[e]),n=ce(ct[e])&&ce(rt[e]);if(!s||!n){const t=e?[Ce(Q),Ce(z)]:[Q,z];if(s||_t(t[0],it[e],lt[e]),!n){let s;he(t[1],(([t,n],a)=>{n!==t&&(gt(ct[e],[a],n,t,Xt),s=1)})),s&&gt(rt[e],void 0,Xt)}}},ss=(e,...t)=>(As((()=>e(...H(t,m)))),zs),ns=()=>[Te(A,((e,t)=>-1===we(g,t)?null:Te(e,((e,s)=>-1===we(we(E,t),s)?null:Te(e,(([,e])=>e??null),((e,t)=>Ze(t)))),re)),re),Te(z,(([,e])=>e??null),((e,t)=>Ze(t)))],as=()=>({cellsTouched:s,valuesTouched:n,changedCells:pe(A,Ye,Ze),invalidCells:pe(O),changedValues:Te(z,Ye,Ze),invalidValues:Te(j),changedTableIds:Te(g),changedRowIds:Re(E),changedCellIds:pe(k),changedValueIds:Te(Q)}),os=()=>pe(_),rs=()=>Le(_),is=e=>Le(we(Z,m(e))),ls=e=>ie(we(_,m(e))),cs=e=>Le(we(_,m(e))),ds=(e,t,s,n=0,a)=>{return H(F(B((o=we(_,m(e)),r=(e,s)=>[M(t)?s:we(e,m(t)),s],H([...o?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>Pe(e,t)*(s?-1:1))),n,M(a)?a:n+a),(([,e])=>e));var o,r},us=(e,t)=>Le(we(we(_,m(e)),m(t))),hs=(e,t,s)=>we(we(we(_,m(e)),m(t)),m(s)),gs=()=>Te(ee),fs=()=>Le(ee),Ls=e=>we(ee,m(e)),ws=()=>!ce(_),vs=e=>le(_,m(e)),Is=(e,t)=>le(we(Z,m(e)),m(t)),Ss=(e,t)=>le(we(_,m(e)),m(t)),ys=(e,t,s)=>le(we(we(_,m(e)),m(t)),m(s)),Ts=()=>!ce(ee),Rs=e=>le(ee,m(e)),ps=e=>ss((()=>(e=>tt(e,vt,Gt))(e)?Vt(e):0)),Cs=e=>ss((()=>yt(e)?Jt(e):0)),bs=e=>{try{mt(et(e))}catch{}return zs},ms=t=>ss((()=>{if((e=tt(t,(e=>tt(e,wt))))&&(Ct(t),!ce(_))){const e=os();Es(),ps(e)}})),Vs=e=>ss((()=>{if(t=(e=>tt(e,wt))(e)){const s=gs();Js(),xs(),t=!0,bt(e),Cs(s)}})),Es=()=>ss((()=>Vt({}))),ks=e=>ss((e=>le(_,e)?zt(e):0),e),Ms=(e,t)=>ss(((e,t)=>x(we(_,e),(s=>le(s,t)?Nt(e,s,t):0))),e,t),xs=()=>ss((()=>Jt({}))),Ds=()=>ss((()=>{Ct({}),e=!1})),Js=()=>ss((()=>{bt({}),t=!1})),As=(e,t)=>{if(-1!=d){Fs();const s=e();return Qs(t),s}},Fs=()=>(-1!=d&&d++,1==d&&gt(dt,void 0,ns,as),zs),Qs=e=>(d>0&&(d--,0==d&&(s=!ce(A),n=!ce(z),d=1,Yt(1),s&&es(1),Zt(1),n&&ts(1),e?.(ns,as)&&(he(A,((e,t)=>he(e,((e,s)=>he(e,(([e],n)=>ke(zs,t,s,n,e))))))),he(z,(([e],t)=>Me(zs,t,e))),s=n=!1),gt(ut[0],void 0,ns,as),d=-1,Yt(0),s&&es(0),Zt(0),n&&ts(0),gt(ut[1],void 0,ns,as),d=0,s=n=!1,a=ws(),r=Ts(),W([g,y,V,E,k,A,O,Q,z,j],ue))),zs),zs={getContent:()=>[os(),gs()],getTables:os,getTableIds:rs,getTable:e=>Re(we(_,m(e))),getTableCellIds:is,getRowCount:ls,getRowIds:cs,getSortedRowIds:ds,getRow:(e,t)=>Te(we(we(_,m(e)),m(t))),getCellIds:us,getCell:hs,getValues:gs,getValueIds:fs,getValue:Ls,hasTables:ws,hasTable:vs,hasTableCell:Is,hasRow:Ss,hasCell:ys,hasValues:Ts,hasValue:Rs,getTablesJson:()=>_e(_),getValuesJson:()=>_e(ee),getJson:()=>_e([_,ee]),getTablesSchemaJson:()=>_e($),getValuesSchemaJson:()=>_e(G),getSchemaJson:()=>_e([$,G]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ss((()=>{(re(e)?Es:ps)(e),(re(t)?xs:Cs)(t)})),setTables:ps,setTable:(e,t)=>ss((e=>vt(t,e)?Et(e,t):0),e),setRow:(e,t,s)=>ss(((e,t)=>It(e,t,s)?kt(e,Qt(e),t,s):0),e,t),addRow:(e,t,s=!0)=>As((()=>{let n;return It(e,n,t)&&(e=m(e),kt(e,Qt(e),n=Ft(e,s?1:0),t)),n})),setPartialRow:(e,t,s)=>ss(((e,t)=>{if(It(e,t,s,1)){const n=Qt(e);oe(s,((s,a)=>xt(e,n,t,a,s)))}}),e,t),setCell:(e,t,s,n)=>ss(((e,t,s)=>x(St(e,t,s,J(n)?n(hs(e,t,s)):n),(n=>xt(e,Qt(e),t,s,n)))),e,t,s),setValues:Cs,setPartialValues:e=>ss((()=>yt(e,1)?oe(e,((e,t)=>At(t,e))):0)),setValue:(e,t)=>ss((e=>x(Tt(e,J(t)?t(Ls(e)):t),(t=>At(e,t)))),e),setTransactionChanges:e=>ss((()=>{oe(e[0],((e,t)=>M(e)?ks(t):oe(e,((e,s)=>M(e)?Ms(t,s):oe(e,((e,n)=>ke(zs,t,s,n,e))))))),oe(e[1],((e,t)=>Me(zs,t,e)))})),setTablesJson:bs,setValuesJson:e=>{try{Dt(et(e))}catch{}return zs},setJson:e=>ss((()=>{try{const[t,s]=et(e);mt(t),Dt(s)}catch{bs(e)}})),setTablesSchema:ms,setValuesSchema:Vs,setSchema:(e,t)=>ss((()=>{ms(e),Vs(t)})),delTables:Es,delTable:ks,delRow:Ms,delCell:(e,t,s,n)=>ss(((e,t,s)=>x(we(_,e),(a=>x(we(a,t),(o=>le(o,s)?Ot(e,a,t,o,s,n):0))))),e,t,s),delValues:xs,delValue:e=>ss((e=>le(ee,e)?Pt(e):0),e),delTablesSchema:Ds,delValuesSchema:Js,delSchema:()=>ss((()=>{Ds(),Js()})),transaction:As,startTransaction:Fs,finishTransaction:Qs,forEachTable:e=>he(_,((t,s)=>e(s,(e=>he(t,((t,s)=>e(s,(e=>ve(t,e))))))))),forEachTableCell:(e,t)=>ve(we(Z,m(e)),t),forEachRow:(e,t)=>he(we(_,m(e)),((e,s)=>t(s,(t=>ve(e,t))))),forEachCell:(e,t,s)=>ve(we(we(_,m(e)),m(t)),s),forEachValue:e=>ve(ee,e),addSortedRowIdsListener:(e,t,s,n,a,o,r)=>{let i=ds(e,t,s,n,a);return ht((()=>{const r=ds(e,t,s,n,a);P(r,i)||(i=r,o(zs,e,t,s,n,a,i))}),Be[r?1:0],[e,t],[rs])},addStartTransactionListener:e=>ht(e,dt),addWillFinishTransactionListener:e=>ht(e,ut[0]),addDidFinishTransactionListener:e=>ht(e,ut[1]),callListener:e=>(Lt(e),zs),delListener:e=>(ft(e),zs),getListenerStats:()=>({}),createStore:nt,addListener:ht,callListeners:gt};return oe({[h+L]:[0,se,[],()=>[ws()]],[L]:[0,de],[w]:[0,Ve],[h+f]:[1,Je,[rs],e=>[vs(...e)]],[f]:[1,Ae,[rs]],[f+R]:[1,Fe,[rs]],[h+f+T]:[2,Qe,[rs,is],e=>[Is(...e)]],[I]:[1,Oe,[rs]],[S]:[1,je,[rs]],[h+v]:[2,We,[rs,cs],e=>[Ss(...e)]],[v]:[2,He,[rs,cs]],[R]:[2,$e,[rs,cs]],[h+T]:[3,qe,[rs,cs,us],e=>[ys(...e)]],[T]:[3,Ge,[rs,cs,us],e=>Ue(hs(...e))],InvalidCell:[3,Ke],[h+C]:[0,ot,[],()=>[Ts()]],[C]:[0,rt],[b]:[0,it],[h+p]:[1,lt,[fs],e=>[Rs(...e)]],[p]:[1,ct,[fs],e=>Ue(Ls(e[0]))],InvalidValue:[1,at]},(([e,t,s,n],a)=>{zs[u+a+c]=(...a)=>ht(a[e],t[a[e+1]?1:0],e>0?F(a,0,e):void 0,s,n)})),te(zs)};e.createCheckpoints=Oe,e.createCustomPersister=(e,t,s,n,a,o,[r,i]=[],l=[])=>{let c,d,u,h=0,g=0;Se($e,l,(()=>0)),Se(qe,l,(()=>[]));const f=async e=>(2!=h&&(h=1,await L.schedule((async()=>{await e(),h=0}))),L),L={load:async(s,n)=>await f((async()=>{try{e.setContent(await t())}catch{e.setContent([s,n])}})),startAutoLoad:async(s={},a={})=>(L.stopAutoLoad(),await L.load(s,a),g=1,u=n((async(s,n)=>{if(n){const t=n();await f((async()=>e.setTransactionChanges(t)))}else await f((async()=>{try{e.setContent(s?.()??await t())}catch(e){o?.(e)}}))})),L),stopAutoLoad:()=>(g&&(a(u),u=void 0,g=0),L),save:async t=>(1!=h&&(h=2,await L.schedule((async()=>{try{await s(e.getContent,t)}catch(e){o?.(e)}h=0}))),L),startAutoSave:async()=>(await L.stopAutoSave().save(),c=e.addDidFinishTransactionListener(((e,t)=>{const[s,n]=t();re(s)&&re(n)||L.save((()=>[s,n]))})),L),stopAutoSave:()=>(x(c,e.delListener),c=void 0,L),schedule:async(...e)=>(K(we(qe,l),...e),await(async()=>{if(!we($e,l)){for(Ie($e,l,1);!M(d=X(we(qe,l)));)try{await d()}catch(e){o?.(e)}Ie($e,l,0)}})(),L),getStore:()=>e,destroy:()=>L.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return r&&(L[r]=()=>i),te(L)},e.createIndexes=je,e.createMetrics=He,e.createQueries=Ge,e.createRelationships=Ke,e.createStore=nt,e.defaultSorter=Pe},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBase={});
Binary file
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",u=t(o),r="Listener",l="Result",d="Has",n="has",i="Ids",a="Table",c=a+"s",I=a+i,C="Row",b=C+"Count",p=C+i,w="Sorted"+C+i,R="Cell",k=R+i,g="Value",L=g+"s",h=g+i,m=e=>null==e,y=(e,s,t)=>m(e)?t?.():s(e),T=e=>t(e)==u,V=()=>{},S=(e,s)=>e.map(s),f=Object.keys,v=(e,s)=>y(e,(e=>e[s])),x=(e,s)=>(delete e[s],e),{createContext:P,useContext:q,useEffect:B}=s,H=P([]),M=(e,s)=>{const t=q(H);return m(e)?t[s]:T(e)?v(t[s+1]??{},e):e},D=(e,s)=>{const t=M(e,s);return m(e)||T(e)?t:e},F=e=>f(q(H)[e]??{}),O=e=>D(e,0),Q=e=>D(e,2),E=e=>D(e,4),A=e=>D(e,6),G=e=>D(e,8),j=e=>D(e,10),U=e=>e.toLowerCase();U(r);const W="Transaction";U(W);const{useCallback:z,useEffect:J,useMemo:K,useLayoutEffect:N,useRef:X,useState:Y}=s,Z=[],$={},_=[[],void 0,[]],ee=(e,s,t=Z)=>{const o=K((()=>s(e)),[e,...t]);return J((()=>()=>o.destroy()),[o]),o},se=(e,s,t,o=Z,u,r="get",l="")=>{const[,d]=Y(),n=z((()=>s?.[r+e]?.(...o)??t),[s,e,...o,t]),i=X();return K((()=>i.current=n()),[n]),te(l+e,s,((...e)=>{i.current=m(u)?n():e[u],d([])}),[n,u],o),i.current},te=(e,s,t,o=Z,u=Z,...l)=>N((()=>{const o=s?.["add"+e+r]?.(...u,t,...l);return()=>s?.delListener(o)}),[s,e,...u,...o,...l]),oe=(e,s,t,o=Z,u=V,r=Z,...l)=>{const d=O(e);return z((e=>y(d,(o=>y(t(e,o),(e=>u(o["set"+s](...l,e),e)))))),[d,s,...o,...r,...l])},ue=(e,s,t=V,o=Z,...u)=>{const r=O(e);return z((()=>t(r?.["del"+s](...u))),[r,s,...o,...u])},re=(e,s,t)=>{const o=j(e);return z((()=>o?.[s](t)),[o,s,t])},le=e=>se(I,O(e),Z),de=(e,s)=>se(p,O(s),Z,[e]),ne=(e,s,t,o=0,u,r)=>se(w,O(r),Z,[e,s,t,o,u],6),ie=(e,s,t)=>se(k,O(t),Z,[e,s]),ae=(e,s,t,o)=>se(R,O(o),void 0,[e,s,t],4),ce=e=>se(h,O(e),Z),Ie=(e,s)=>se(g,O(s),void 0,[e]),Ce=(e,s)=>se("Metric",Q(s),void 0,[e]),be=(e,s)=>se("SliceIds",E(s),Z,[e]),pe=(e,s,t)=>se("Slice"+p,E(t),Z,[e,s]),we=(e,s,t)=>se("RemoteRowId",A(t),void 0,[e,s]),Re=(e,s,t)=>se("Local"+p,A(t),Z,[e,s]),ke=(e,s,t)=>se("Linked"+p,A(t),Z,[e,s]),ge=(e,s)=>se(l+p,G(s),Z,[e]),Le=(e,s,t,o=0,u,r)=>se(l+w,G(r),Z,[e,s,t,o,u],6),he=(e,s,t)=>se(l+k,G(t),Z,[e,s]),me=(e,s,t,o)=>se(l+R,G(o),void 0,[e,s,t]),ye=e=>se("CheckpointIds",j(e),_),Te=(e,s)=>se("Checkpoint",j(s),void 0,[e]),Ve=e=>re(e,"goBackward"),Se=e=>re(e,"goForward"),{PureComponent:fe,Fragment:ve,createElement:xe,useCallback:Pe,useLayoutEffect:qe,useRef:Be,useState:He}=s,Me=(e,...s)=>m(e)?{}:e(...s),De=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Fe,useContext:Oe,useMemo:Qe,useState:Ee}=s,Ae=({tableId:e,store:s,rowComponent:t=Je,getRowComponentProps:o,customCellIds:u,separator:r,debugIds:l},d)=>We(S(d,(r=>xe(t,{...Me(o,r),key:r,tableId:e,rowId:r,customCellIds:u,store:s,debugIds:l}))),r,l,e),Ge=({queryId:e,queries:s,resultRowComponent:t=Ze,getResultRowComponentProps:o,separator:u,debugIds:r},l)=>We(S(l,(u=>xe(t,{...Me(o,u),key:u,queryId:e,rowId:u,queries:s,debugIds:r}))),u,r,e),je=({relationshipId:e,relationships:s,rowComponent:t=Je,getRowComponentProps:o,separator:u,debugIds:r},l,d)=>{const[n,i,a]=De(A(s),e),c=l(e,d,n);return We(S(c,(e=>xe(t,{...Me(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:r}))),u,r,d)},Ue=e=>({checkpoints:s,checkpointComponent:t=$e,getCheckpointComponentProps:o,separator:u,debugIds:r})=>{const l=j(s);return We(S(e(ye(l)),(e=>xe(t,{...Me(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:r}))),u)},We=(e,s,t,o)=>{const u=m(s)||!Array.isArray(e)?e:S(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",u,"}"]:u},ze=({tableId:e,rowId:s,cellId:t,store:u,debugIds:r})=>We(o+(ae(e,s,t,u)??o),void 0,r,t),Je=({tableId:e,rowId:s,store:t,cellComponent:o=ze,getCellComponentProps:u,customCellIds:r,separator:l,debugIds:d})=>We(S(((e,s,t,o)=>{const u=ie(s,t,o);return e??u})(r,e,s,t),(r=>xe(o,{...Me(u,r),key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:d}))),l,d,s),Ke=e=>Ae(e,de(e.tableId,e.store)),Ne=({valueId:e,store:s,debugIds:t})=>We(o+(Ie(e,s)??o),void 0,t,e),Xe=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Je,getRowComponentProps:u,separator:r,debugIds:l})=>{const[d,n,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(E(t),e),a=pe(e,s,d);return We(S(a,(e=>xe(o,{...Me(u,e),key:e,tableId:i,rowId:e,store:n,debugIds:l}))),r,l,s)},Ye=({queryId:e,rowId:s,cellId:t,queries:u,debugIds:r})=>We(o+(me(e,s,t,u)??o),void 0,r,t),Ze=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Ye,getResultCellComponentProps:u,separator:r,debugIds:l})=>We(S(he(e,s,t),(r=>xe(o,{...Me(u,r),key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:l}))),r,l,s),$e=({checkpoints:e,checkpointId:s,debugIds:t})=>We(Te(s,e)??o,void 0,t,s),_e=Ue((e=>e[0])),es=Ue((e=>m(e[1])?[]:[e[1]])),ss=Ue((e=>e[2]));e.BackwardCheckpointsView=_e,e.CellView=ze,e.CheckpointView=$e,e.CurrentCheckpointView=es,e.ForwardCheckpointsView=ss,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Xe,getSliceComponentProps:o,separator:u,debugIds:r})=>We(S(be(e,s),(u=>xe(t,{...Me(o,u),key:u,indexId:e,sliceId:u,indexes:s,debugIds:r}))),u,r,e),e.LinkedRowsView=e=>je(e,ke,e.firstRowId),e.LocalRowsView=e=>je(e,Re,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>We(Ce(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:u,indexesById:r,relationships:l,relationshipsById:d,queries:n,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const C=Oe(H),[b,p]=Ee({}),w=Fe(((e,s)=>p((t=>v(t,e)==s?t:{...t,[e]:s}))),[]),R=Fe((e=>p((s=>({...x(s,e)})))),[]);return xe(H.Provider,{value:Qe((()=>[e??C[0],{...C[1],...s,...b},t??C[2],{...C[3],...o},u??C[4],{...C[5],...r},l??C[6],{...C[7],...d},n??C[8],{...C[9],...i},a??C[10],{...C[11],...c},w,R]),[e,s,b,t,o,u,r,l,d,n,i,a,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Je,getRowComponentProps:u,debugIds:r})=>{const[l,d,,n]=De(A(t),e),i=we(e,s,l);return We(m(n)||m(i)?null:xe(o,{...Me(u,i),key:i,tableId:n,rowId:i,store:d,debugIds:r}),void 0,r,s)},e.ResultCellView=Ye,e.ResultRowView=Ze,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>Ge(u,Le(u.queryId,e,s,t,o,u.queries)),e.ResultTableView=e=>Ge(e,ge(e.queryId,e.queries)),e.RowView=Je,e.SliceView=Xe,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>Ae(u,ne(u.tableId,e,s,t,o,u.store)),e.TableView=Ke,e.TablesView=({store:e,tableComponent:s=Ke,getTableComponentProps:t,separator:o,debugIds:u})=>We(S(le(e),(o=>xe(s,{...Me(t,o),key:o,tableId:o,store:e,debugIds:u}))),o),e.ValueView=Ne,e.ValuesView=({store:e,valueComponent:s=Ne,getValueComponentProps:t,separator:o,debugIds:u})=>We(S(ce(e),(o=>xe(s,{...Me(t,o),key:o,valueId:o,store:e,debugIds:u}))),o),e.useAddRowCallback=(e,s,t=Z,o,u=V,r=Z,l=!0)=>{const d=O(o);return z((t=>y(d,(o=>y(s(t,o),(s=>u(o.addRow(e,s,l),o,s)))))),[d,e,...t,...r,l])},e.useCell=ae,e.useCellIds=ie,e.useCellIdsListener=(e,s,t,o,u,r)=>te(k,O(r),t,o,[e,s],u),e.useCellListener=(e,s,t,o,u,r,l)=>te(R,O(l),o,u,[e,s,t],r),e.useCheckpoint=Te,e.useCheckpointIds=ye,e.useCheckpointIdsListener=(e,s,t)=>te("CheckpointIds",j(t),e,s),e.useCheckpointListener=(e,s,t,o)=>te("Checkpoint",j(o),s,t,[e]),e.useCheckpoints=e=>M(e,10),e.useCheckpointsIds=()=>F(11),e.useCheckpointsOrCheckpointsById=j,e.useCreateCheckpoints=(e,s,t)=>ee(e,s,t),e.useCreateIndexes=(e,s,t)=>ee(e,s,t),e.useCreateMetrics=(e,s,t)=>ee(e,s,t),e.useCreatePersister=(e,s,t=Z,o,u=Z,r,l=Z)=>{const[,d]=Y(),n=K((()=>s(e)),[e,...t]);return J((()=>((async()=>{o&&(await o(n),d([]))})(),()=>{n?.destroy(),r?.(n)})),[n,...u,...l]),n},e.useCreateQueries=(e,s,t)=>ee(e,s,t),e.useCreateRelationships=(e,s,t)=>ee(e,s,t),e.useCreateStore=(e,s=Z)=>K(e,s),e.useDelCellCallback=(e,s,t,o,u,r,l)=>ue(u,R,r,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,u)=>ue(t,C,o,u,e,s),e.useDelTableCallback=(e,s,t,o)=>ue(s,a,t,o,e),e.useDelTablesCallback=(e,s,t)=>ue(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>ue(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>ue(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>te("DidFinish"+W,O(t),e,s),e.useGoBackwardCallback=Ve,e.useGoForwardCallback=Se,e.useGoToCallback=(e,s=Z,t,o=V,u=Z)=>{const r=j(t);return z((s=>y(r,(t=>y(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...u])},e.useHasCell=(e,s,t,o)=>se(R,O(o),!1,[e,s,t],4,n,d),e.useHasCellListener=(e,s,t,o,u,r,l)=>te(d+R,O(l),o,u,[e,s,t],r),e.useHasRow=(e,s,t)=>se(C,O(t),!1,[e,s],3,n,d),e.useHasRowListener=(e,s,t,o,u,r)=>te(d+C,O(r),t,o,[e,s],u),e.useHasTable=(e,s)=>se(a,O(s),!1,[e],2,n,d),e.useHasTableCell=(e,s,t)=>se(a+R,O(t),!1,[e,s],3,n,d),e.useHasTableCellListener=(e,s,t,o,u,r)=>te(d+a+R,O(r),t,o,[e,s],u),e.useHasTableListener=(e,s,t,o,u)=>te(d+a,O(u),s,t,[e],o),e.useHasTables=e=>se(c,O(e),!1,[],1,n,d),e.useHasTablesListener=(e,s,t,o)=>te(d+c,O(o),e,s,[],t),e.useHasValue=(e,s)=>se(g,O(s),!1,[e],2,n,d),e.useHasValueListener=(e,s,t,o,u)=>te(d+g,O(u),s,t,[e],o),e.useHasValues=e=>se(L,O(e),!1,[],1,n,d),e.useHasValuesListener=(e,s,t,o)=>te(d+L,O(o),e,s,[],t),e.useIndexIds=e=>se("IndexIds",E(e),Z),e.useIndexes=e=>M(e,4),e.useIndexesIds=()=>F(5),e.useIndexesOrIndexesById=E,e.useLinkedRowIds=ke,e.useLinkedRowIdsListener=(e,s,t,o,u)=>te("Linked"+p,A(u),t,o,[e,s]),e.useLocalRowIds=Re,e.useLocalRowIdsListener=(e,s,t,o,u)=>te("Local"+p,A(u),t,o,[e,s]),e.useMetric=Ce,e.useMetricIds=e=>se("MetricIds",Q(e),Z),e.useMetricListener=(e,s,t,o)=>te("Metric",Q(o),s,t,[e]),e.useMetrics=e=>M(e,2),e.useMetricsIds=()=>F(3),e.useMetricsOrMetricsById=Q,e.useProvideStore=(e,s)=>{const{12:t,13:o}=q(H);B((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>M(e,8),e.useQueriesIds=()=>F(9),e.useQueriesOrQueriesById=G,e.useQueryIds=e=>se("QueryIds",G(e),Z),e.useRedoInformation=e=>{const s=j(e),[,,[t]]=ye(s);return[!m(t),Se(s),t,y(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>se("RelationshipIds",A(e),Z),e.useRelationships=e=>M(e,6),e.useRelationshipsIds=()=>F(7),e.useRelationshipsOrRelationshipsById=A,e.useRemoteRowId=we,e.useRemoteRowIdListener=(e,s,t,o,u)=>te("RemoteRowId",A(u),t,o,[e,s]),e.useResultCell=me,e.useResultCellIds=he,e.useResultCellIdsListener=(e,s,t,o,u)=>te(l+k,G(u),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,u,r)=>te(l+R,G(r),o,u,[e,s,t]),e.useResultRow=(e,s,t)=>se(l+C,G(t),$,[e,s]),e.useResultRowCount=(e,s)=>se(l+b,G(s),0,[e]),e.useResultRowCountListener=(e,s,t,o)=>te(l+b,G(o),s,t,[e]),e.useResultRowIds=ge,e.useResultRowIdsListener=(e,s,t,o)=>te(l+p,G(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,u)=>te(l+C,G(u),t,o,[e,s]),e.useResultSortedRowIds=Le,e.useResultSortedRowIdsListener=(e,s,t,o,u,r,d,n)=>te(l+w,G(n),r,d,[e,s,t,o,u]),e.useResultTable=(e,s)=>se(l+a,G(s),$,[e]),e.useResultTableCellIds=(e,s)=>se(l+a+k,G(s),Z,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>te(l+a+k,G(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>te(l+a,G(o),s,t,[e]),e.useRow=(e,s,t)=>se(C,O(t),$,[e,s]),e.useRowCount=(e,s)=>se(b,O(s),0,[e]),e.useRowCountListener=(e,s,t,o,u)=>te(b,O(u),s,t,[e],o),e.useRowIds=de,e.useRowIdsListener=(e,s,t,o,u)=>te(p,O(u),s,t,[e],o),e.useRowListener=(e,s,t,o,u,r)=>te(C,O(r),t,o,[e,s],u),e.useSetCellCallback=(e,s,t,o,u,r,l,d)=>oe(r,R,o,u,l,d,e,s,t),e.useSetCheckpointCallback=(e=V,s=Z,t,o=V,u=Z)=>{const r=j(t);return z((s=>y(r,(t=>{const u=e(s);o(t.addCheckpoint(u),t,u)}))),[r,...s,...u])},e.useSetPartialRowCallback=(e,s,t,o,u,r,l)=>oe(u,"PartialRow",t,o,r,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,u)=>oe(t,"PartialValues",e,s,o,u),e.useSetRowCallback=(e,s,t,o,u,r,l)=>oe(u,C,t,o,r,l,e,s),e.useSetTableCallback=(e,s,t,o,u,r)=>oe(o,a,s,t,u,r,e),e.useSetTablesCallback=(e,s,t,o,u)=>oe(t,c,e,s,o,u),e.useSetValueCallback=(e,s,t,o,u,r)=>oe(o,g,s,t,u,r,e),e.useSetValuesCallback=(e,s,t,o,u)=>oe(t,L,e,s,o,u),e.useSliceIds=be,e.useSliceIdsListener=(e,s,t,o)=>te("SliceIds",E(o),s,t,[e]),e.useSliceRowIds=pe,e.useSliceRowIdsListener=(e,s,t,o,u)=>te("Slice"+p,E(u),t,o,[e,s]),e.useSortedRowIds=ne,e.useSortedRowIdsListener=(e,s,t,o,u,r,l,d,n)=>te(w,O(n),r,l,[e,s,t,o,u],d),e.useStartTransactionListener=(e,s,t)=>te("Start"+W,O(t),e,s),e.useStore=e=>M(e,0),e.useStoreIds=()=>F(1),e.useStoreOrStoreById=O,e.useTable=(e,s)=>se(a,O(s),$,[e]),e.useTableCellIds=(e,s)=>se(a+k,O(s),Z,[e]),e.useTableCellIdsListener=(e,s,t,o,u)=>te(a+k,O(u),s,t,[e],o),e.useTableIds=le,e.useTableIdsListener=(e,s,t,o)=>te(I,O(o),e,s,Z,t),e.useTableListener=(e,s,t,o,u)=>te(a,O(u),s,t,[e],o),e.useTables=e=>se(c,O(e),$),e.useTablesListener=(e,s,t,o)=>te(c,O(o),e,s,Z,t),e.useUndoInformation=e=>{const s=j(e),[t,u]=ye(s);return[(r=t,!(0==r.length)),Ve(s),u,y(u,(e=>s?.getCheckpoint(e)))??o];var r},e.useValue=Ie,e.useValueIds=ce,e.useValueIdsListener=(e,s,t,o)=>te(h,O(o),e,s,Z,t),e.useValueListener=(e,s,t,o,u)=>te(g,O(u),s,t,[e],o),e.useValues=e=>se(L,O(e),$),e.useValuesListener=(e,s,t,o)=>te(L,O(o),e,s,Z,t),e.useWillFinishTransactionListener=(e,s,t)=>te("WillFinish"+W,O(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",u=t(o),r=t(t),l="Listener",d="Result",n="Has",i="has",a="Ids",c="Table",I=c+"s",C=c+a,b="Row",p=b+"Count",w=b+a,R="Sorted"+b+a,k="Cell",g=k+a,L="Value",h=L+"s",m=L+a,y=e=>null==e,T=(e,s,t)=>y(e)?t?.():s(e),V=e=>t(e)==u,S=e=>t(e)==r,f=()=>{},v=(e,s)=>e.map(s),x=Object.keys,P=(e,s)=>T(e,(e=>e[s])),q=(e,s)=>(delete e[s],e),{createContext:B,useContext:H,useEffect:M}=s,D=B([]),F=(e,s)=>{const t=H(D);return y(e)?t[s]:V(e)?P(t[s+1]??{},e):e},O=(e,s)=>{const t=F(e,s);return y(e)||V(e)?t:e},Q=e=>x(H(D)[e]??{}),E=e=>O(e,0),A=e=>O(e,2),G=e=>O(e,4),j=e=>O(e,6),U=e=>O(e,8),W=e=>O(e,10),z=e=>e.toLowerCase();z(l);const J="Transaction";z(J);const{useCallback:K,useEffect:N,useMemo:X,useLayoutEffect:Y,useRef:Z,useState:$}=s,_=[],ee={},se=[[],void 0,[]],te=(e,s,t=_)=>{const o=X((()=>s(e)),[e,...t]);return N((()=>()=>o.destroy()),[o]),o},oe=(e,s,t,o=_,u,r="get",l="")=>{const[,d]=$(),n=K((()=>s?.[r+e]?.(...o)??t),[s,e,...o,t]),i=Z();return X((()=>i.current=n()),[n]),ue(l+e,s,((...e)=>{i.current=y(u)?n():e[u],d([])}),[n,u],o),i.current},ue=(e,s,t,o=_,u=_,...r)=>Y((()=>{const o=s?.["add"+e+l]?.(...u,t,...r);return()=>s?.delListener(o)}),[s,e,...u,...o,...r]),re=(e,s,t,o=_,u=f,r=_,...l)=>{const d=E(e);return K((e=>T(d,(o=>T(t(e,o),(t=>u(o["set"+s](...v(l,(s=>S(s)?s(e,o):s)),t),t)))))),[d,s,...o,...r,...l])},le=(e,s,t=f,o=_,...u)=>{const r=E(e);return K((()=>t(r?.["del"+s](...u))),[r,s,...o,...u])},de=(e,s,t)=>{const o=W(e);return K((()=>o?.[s](t)),[o,s,t])},ne=e=>oe(C,E(e),_),ie=(e,s)=>oe(w,E(s),_,[e]),ae=(e,s,t,o=0,u,r)=>oe(R,E(r),_,[e,s,t,o,u],6),ce=(e,s,t)=>oe(g,E(t),_,[e,s]),Ie=(e,s,t,o)=>oe(k,E(o),void 0,[e,s,t],4),Ce=e=>oe(m,E(e),_),be=(e,s)=>oe(L,E(s),void 0,[e]),pe=(e,s)=>oe("Metric",A(s),void 0,[e]),we=(e,s)=>oe("SliceIds",G(s),_,[e]),Re=(e,s,t)=>oe("Slice"+w,G(t),_,[e,s]),ke=(e,s,t)=>oe("RemoteRowId",j(t),void 0,[e,s]),ge=(e,s,t)=>oe("Local"+w,j(t),_,[e,s]),Le=(e,s,t)=>oe("Linked"+w,j(t),_,[e,s]),he=(e,s)=>oe(d+w,U(s),_,[e]),me=(e,s,t,o=0,u,r)=>oe(d+R,U(r),_,[e,s,t,o,u],6),ye=(e,s,t)=>oe(d+g,U(t),_,[e,s]),Te=(e,s,t,o)=>oe(d+k,U(o),void 0,[e,s,t]),Ve=e=>oe("CheckpointIds",W(e),se),Se=(e,s)=>oe("Checkpoint",W(s),void 0,[e]),fe=e=>de(e,"goBackward"),ve=e=>de(e,"goForward"),{PureComponent:xe,Fragment:Pe,createElement:qe,useCallback:Be,useLayoutEffect:He,useRef:Me,useState:De}=s,Fe=(e,...s)=>y(e)?{}:e(...s),Oe=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Qe,useContext:Ee,useMemo:Ae,useState:Ge}=s,je=({tableId:e,store:s,rowComponent:t=Ne,getRowComponentProps:o,customCellIds:u,separator:r,debugIds:l},d)=>Je(v(d,(r=>qe(t,{...Fe(o,r),key:r,tableId:e,rowId:r,customCellIds:u,store:s,debugIds:l}))),r,l,e),Ue=({queryId:e,queries:s,resultRowComponent:t=_e,getResultRowComponentProps:o,separator:u,debugIds:r},l)=>Je(v(l,(u=>qe(t,{...Fe(o,u),key:u,queryId:e,rowId:u,queries:s,debugIds:r}))),u,r,e),We=({relationshipId:e,relationships:s,rowComponent:t=Ne,getRowComponentProps:o,separator:u,debugIds:r},l,d)=>{const[n,i,a]=Oe(j(s),e),c=l(e,d,n);return Je(v(c,(e=>qe(t,{...Fe(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:r}))),u,r,d)},ze=e=>({checkpoints:s,checkpointComponent:t=es,getCheckpointComponentProps:o,separator:u,debugIds:r})=>{const l=W(s);return Je(v(e(Ve(l)),(e=>qe(t,{...Fe(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:r}))),u)},Je=(e,s,t,o)=>{const u=y(s)||!Array.isArray(e)?e:v(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",u,"}"]:u},Ke=({tableId:e,rowId:s,cellId:t,store:u,debugIds:r})=>Je(o+(Ie(e,s,t,u)??o),void 0,r,t),Ne=({tableId:e,rowId:s,store:t,cellComponent:o=Ke,getCellComponentProps:u,customCellIds:r,separator:l,debugIds:d})=>Je(v(((e,s,t,o)=>{const u=ce(s,t,o);return e??u})(r,e,s,t),(r=>qe(o,{...Fe(u,r),key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:d}))),l,d,s),Xe=e=>je(e,ie(e.tableId,e.store)),Ye=({valueId:e,store:s,debugIds:t})=>Je(o+(be(e,s)??o),void 0,t,e),Ze=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Ne,getRowComponentProps:u,separator:r,debugIds:l})=>{const[d,n,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(G(t),e),a=Re(e,s,d);return Je(v(a,(e=>qe(o,{...Fe(u,e),key:e,tableId:i,rowId:e,store:n,debugIds:l}))),r,l,s)},$e=({queryId:e,rowId:s,cellId:t,queries:u,debugIds:r})=>Je(o+(Te(e,s,t,u)??o),void 0,r,t),_e=({queryId:e,rowId:s,queries:t,resultCellComponent:o=$e,getResultCellComponentProps:u,separator:r,debugIds:l})=>Je(v(ye(e,s,t),(r=>qe(o,{...Fe(u,r),key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:l}))),r,l,s),es=({checkpoints:e,checkpointId:s,debugIds:t})=>Je(Se(s,e)??o,void 0,t,s),ss=ze((e=>e[0])),ts=ze((e=>y(e[1])?[]:[e[1]])),os=ze((e=>e[2]));e.BackwardCheckpointsView=ss,e.CellView=Ke,e.CheckpointView=es,e.CurrentCheckpointView=ts,e.ForwardCheckpointsView=os,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Ze,getSliceComponentProps:o,separator:u,debugIds:r})=>Je(v(we(e,s),(u=>qe(t,{...Fe(o,u),key:u,indexId:e,sliceId:u,indexes:s,debugIds:r}))),u,r,e),e.LinkedRowsView=e=>We(e,Le,e.firstRowId),e.LocalRowsView=e=>We(e,ge,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>Je(pe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:u,indexesById:r,relationships:l,relationshipsById:d,queries:n,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const C=Ee(D),[b,p]=Ge({}),w=Qe(((e,s)=>p((t=>P(t,e)==s?t:{...t,[e]:s}))),[]),R=Qe((e=>p((s=>({...q(s,e)})))),[]);return qe(D.Provider,{value:Ae((()=>[e??C[0],{...C[1],...s,...b},t??C[2],{...C[3],...o},u??C[4],{...C[5],...r},l??C[6],{...C[7],...d},n??C[8],{...C[9],...i},a??C[10],{...C[11],...c},w,R]),[e,s,b,t,o,u,r,l,d,n,i,a,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Ne,getRowComponentProps:u,debugIds:r})=>{const[l,d,,n]=Oe(j(t),e),i=ke(e,s,l);return Je(y(n)||y(i)?null:qe(o,{...Fe(u,i),key:i,tableId:n,rowId:i,store:d,debugIds:r}),void 0,r,s)},e.ResultCellView=$e,e.ResultRowView=_e,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>Ue(u,me(u.queryId,e,s,t,o,u.queries)),e.ResultTableView=e=>Ue(e,he(e.queryId,e.queries)),e.RowView=Ne,e.SliceView=Ze,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>je(u,ae(u.tableId,e,s,t,o,u.store)),e.TableView=Xe,e.TablesView=({store:e,tableComponent:s=Xe,getTableComponentProps:t,separator:o,debugIds:u})=>Je(v(ne(e),(o=>qe(s,{...Fe(t,o),key:o,tableId:o,store:e,debugIds:u}))),o),e.ValueView=Ye,e.ValuesView=({store:e,valueComponent:s=Ye,getValueComponentProps:t,separator:o,debugIds:u})=>Je(v(Ce(e),(o=>qe(s,{...Fe(t,o),key:o,valueId:o,store:e,debugIds:u}))),o),e.useAddRowCallback=(e,s,t=_,o,u=f,r=_,l=!0)=>{const d=E(o);return K((t=>T(d,(o=>T(s(t,o),(s=>u(o.addRow(S(e)?e(t,o):e,s,l),o,s)))))),[d,e,...t,...r,l])},e.useCell=Ie,e.useCellIds=ce,e.useCellIdsListener=(e,s,t,o,u,r)=>ue(g,E(r),t,o,[e,s],u),e.useCellListener=(e,s,t,o,u,r,l)=>ue(k,E(l),o,u,[e,s,t],r),e.useCheckpoint=Se,e.useCheckpointIds=Ve,e.useCheckpointIdsListener=(e,s,t)=>ue("CheckpointIds",W(t),e,s),e.useCheckpointListener=(e,s,t,o)=>ue("Checkpoint",W(o),s,t,[e]),e.useCheckpoints=e=>F(e,10),e.useCheckpointsIds=()=>Q(11),e.useCheckpointsOrCheckpointsById=W,e.useCreateCheckpoints=(e,s,t)=>te(e,s,t),e.useCreateIndexes=(e,s,t)=>te(e,s,t),e.useCreateMetrics=(e,s,t)=>te(e,s,t),e.useCreatePersister=(e,s,t=_,o,u=_,r,l=_)=>{const[,d]=$(),n=X((()=>s(e)),[e,...t]);return N((()=>((async()=>{o&&(await o(n),d([]))})(),()=>{n?.destroy(),r?.(n)})),[n,...u,...l]),n},e.useCreateQueries=(e,s,t)=>te(e,s,t),e.useCreateRelationships=(e,s,t)=>te(e,s,t),e.useCreateStore=(e,s=_)=>X(e,s),e.useDelCellCallback=(e,s,t,o,u,r,l)=>le(u,k,r,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,u)=>le(t,b,o,u,e,s),e.useDelTableCallback=(e,s,t,o)=>le(s,c,t,o,e),e.useDelTablesCallback=(e,s,t)=>le(e,I,s,t),e.useDelValueCallback=(e,s,t,o)=>le(s,L,t,o,e),e.useDelValuesCallback=(e,s,t)=>le(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>ue("DidFinish"+J,E(t),e,s),e.useGoBackwardCallback=fe,e.useGoForwardCallback=ve,e.useGoToCallback=(e,s=_,t,o=f,u=_)=>{const r=W(t);return K((s=>T(r,(t=>T(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...u])},e.useHasCell=(e,s,t,o)=>oe(k,E(o),!1,[e,s,t],4,i,n),e.useHasCellListener=(e,s,t,o,u,r,l)=>ue(n+k,E(l),o,u,[e,s,t],r),e.useHasRow=(e,s,t)=>oe(b,E(t),!1,[e,s],3,i,n),e.useHasRowListener=(e,s,t,o,u,r)=>ue(n+b,E(r),t,o,[e,s],u),e.useHasTable=(e,s)=>oe(c,E(s),!1,[e],2,i,n),e.useHasTableCell=(e,s,t)=>oe(c+k,E(t),!1,[e,s],3,i,n),e.useHasTableCellListener=(e,s,t,o,u,r)=>ue(n+c+k,E(r),t,o,[e,s],u),e.useHasTableListener=(e,s,t,o,u)=>ue(n+c,E(u),s,t,[e],o),e.useHasTables=e=>oe(I,E(e),!1,[],1,i,n),e.useHasTablesListener=(e,s,t,o)=>ue(n+I,E(o),e,s,[],t),e.useHasValue=(e,s)=>oe(L,E(s),!1,[e],2,i,n),e.useHasValueListener=(e,s,t,o,u)=>ue(n+L,E(u),s,t,[e],o),e.useHasValues=e=>oe(h,E(e),!1,[],1,i,n),e.useHasValuesListener=(e,s,t,o)=>ue(n+h,E(o),e,s,[],t),e.useIndexIds=e=>oe("IndexIds",G(e),_),e.useIndexes=e=>F(e,4),e.useIndexesIds=()=>Q(5),e.useIndexesOrIndexesById=G,e.useLinkedRowIds=Le,e.useLinkedRowIdsListener=(e,s,t,o,u)=>ue("Linked"+w,j(u),t,o,[e,s]),e.useLocalRowIds=ge,e.useLocalRowIdsListener=(e,s,t,o,u)=>ue("Local"+w,j(u),t,o,[e,s]),e.useMetric=pe,e.useMetricIds=e=>oe("MetricIds",A(e),_),e.useMetricListener=(e,s,t,o)=>ue("Metric",A(o),s,t,[e]),e.useMetrics=e=>F(e,2),e.useMetricsIds=()=>Q(3),e.useMetricsOrMetricsById=A,e.useProvideStore=(e,s)=>{const{12:t,13:o}=H(D);M((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>F(e,8),e.useQueriesIds=()=>Q(9),e.useQueriesOrQueriesById=U,e.useQueryIds=e=>oe("QueryIds",U(e),_),e.useRedoInformation=e=>{const s=W(e),[,,[t]]=Ve(s);return[!y(t),ve(s),t,T(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>oe("RelationshipIds",j(e),_),e.useRelationships=e=>F(e,6),e.useRelationshipsIds=()=>Q(7),e.useRelationshipsOrRelationshipsById=j,e.useRemoteRowId=ke,e.useRemoteRowIdListener=(e,s,t,o,u)=>ue("RemoteRowId",j(u),t,o,[e,s]),e.useResultCell=Te,e.useResultCellIds=ye,e.useResultCellIdsListener=(e,s,t,o,u)=>ue(d+g,U(u),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,u,r)=>ue(d+k,U(r),o,u,[e,s,t]),e.useResultRow=(e,s,t)=>oe(d+b,U(t),ee,[e,s]),e.useResultRowCount=(e,s)=>oe(d+p,U(s),0,[e]),e.useResultRowCountListener=(e,s,t,o)=>ue(d+p,U(o),s,t,[e]),e.useResultRowIds=he,e.useResultRowIdsListener=(e,s,t,o)=>ue(d+w,U(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,u)=>ue(d+b,U(u),t,o,[e,s]),e.useResultSortedRowIds=me,e.useResultSortedRowIdsListener=(e,s,t,o,u,r,l,n)=>ue(d+R,U(n),r,l,[e,s,t,o,u]),e.useResultTable=(e,s)=>oe(d+c,U(s),ee,[e]),e.useResultTableCellIds=(e,s)=>oe(d+c+g,U(s),_,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>ue(d+c+g,U(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>ue(d+c,U(o),s,t,[e]),e.useRow=(e,s,t)=>oe(b,E(t),ee,[e,s]),e.useRowCount=(e,s)=>oe(p,E(s),0,[e]),e.useRowCountListener=(e,s,t,o,u)=>ue(p,E(u),s,t,[e],o),e.useRowIds=ie,e.useRowIdsListener=(e,s,t,o,u)=>ue(w,E(u),s,t,[e],o),e.useRowListener=(e,s,t,o,u,r)=>ue(b,E(r),t,o,[e,s],u),e.useSetCellCallback=(e,s,t,o,u,r,l,d)=>re(r,k,o,u,l,d,e,s,t),e.useSetCheckpointCallback=(e=f,s=_,t,o=f,u=_)=>{const r=W(t);return K((s=>T(r,(t=>{const u=e(s);o(t.addCheckpoint(u),t,u)}))),[r,...s,...u])},e.useSetPartialRowCallback=(e,s,t,o,u,r,l)=>re(u,"PartialRow",t,o,r,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,u)=>re(t,"PartialValues",e,s,o,u),e.useSetRowCallback=(e,s,t,o,u,r,l)=>re(u,b,t,o,r,l,e,s),e.useSetTableCallback=(e,s,t,o,u,r)=>re(o,c,s,t,u,r,e),e.useSetTablesCallback=(e,s,t,o,u)=>re(t,I,e,s,o,u),e.useSetValueCallback=(e,s,t,o,u,r)=>re(o,L,s,t,u,r,e),e.useSetValuesCallback=(e,s,t,o,u)=>re(t,h,e,s,o,u),e.useSliceIds=we,e.useSliceIdsListener=(e,s,t,o)=>ue("SliceIds",G(o),s,t,[e]),e.useSliceRowIds=Re,e.useSliceRowIdsListener=(e,s,t,o,u)=>ue("Slice"+w,G(u),t,o,[e,s]),e.useSortedRowIds=ae,e.useSortedRowIdsListener=(e,s,t,o,u,r,l,d,n)=>ue(R,E(n),r,l,[e,s,t,o,u],d),e.useStartTransactionListener=(e,s,t)=>ue("Start"+J,E(t),e,s),e.useStore=e=>F(e,0),e.useStoreIds=()=>Q(1),e.useStoreOrStoreById=E,e.useTable=(e,s)=>oe(c,E(s),ee,[e]),e.useTableCellIds=(e,s)=>oe(c+g,E(s),_,[e]),e.useTableCellIdsListener=(e,s,t,o,u)=>ue(c+g,E(u),s,t,[e],o),e.useTableIds=ne,e.useTableIdsListener=(e,s,t,o)=>ue(C,E(o),e,s,_,t),e.useTableListener=(e,s,t,o,u)=>ue(c,E(u),s,t,[e],o),e.useTables=e=>oe(I,E(e),ee),e.useTablesListener=(e,s,t,o)=>ue(I,E(o),e,s,_,t),e.useUndoInformation=e=>{const s=W(e),[t,u]=Ve(s);return[(r=t,!(0==r.length)),fe(s),u,T(u,(e=>s?.getCheckpoint(e)))??o];var r},e.useValue=be,e.useValueIds=Ce,e.useValueIdsListener=(e,s,t,o)=>ue(m,E(o),e,s,_,t),e.useValueListener=(e,s,t,o,u)=>ue(L,E(u),s,t,[e],o),e.useValues=e=>oe(h,E(e),ee),e.useValuesListener=(e,s,t,o)=>ue(h,E(o),e,s,_,t),e.useWillFinishTransactionListener=(e,s,t)=>ue("WillFinish"+J,E(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