spacetimedb 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/dist/browser/react/index.mjs.map +1 -1
  2. package/dist/index.browser.mjs +18 -4
  3. package/dist/index.browser.mjs.map +1 -1
  4. package/dist/index.cjs +18 -16
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.ts +13 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.mjs +18 -16
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/lib/algebraic_type.d.ts +115 -0
  11. package/dist/lib/algebraic_type.d.ts.map +1 -0
  12. package/dist/lib/algebraic_value.d.ts +6 -0
  13. package/dist/lib/algebraic_value.d.ts.map +1 -0
  14. package/dist/lib/autogen/algebraic_type_type.d.ts +64 -0
  15. package/dist/lib/autogen/algebraic_type_type.d.ts.map +1 -0
  16. package/dist/lib/autogen/algebraic_type_variants.d.ts +68 -0
  17. package/dist/lib/autogen/algebraic_type_variants.d.ts.map +1 -0
  18. package/dist/lib/autogen/index_type_type.d.ts +16 -0
  19. package/dist/lib/autogen/index_type_type.d.ts.map +1 -0
  20. package/dist/lib/autogen/index_type_variants.d.ts +7 -0
  21. package/dist/lib/autogen/index_type_variants.d.ts.map +1 -0
  22. package/dist/lib/autogen/lifecycle_type.d.ts +19 -0
  23. package/dist/lib/autogen/lifecycle_type.d.ts.map +1 -0
  24. package/dist/lib/autogen/lifecycle_variants.d.ts +10 -0
  25. package/dist/lib/autogen/lifecycle_variants.d.ts.map +1 -0
  26. package/dist/lib/autogen/misc_module_export_type.d.ts +12 -0
  27. package/dist/lib/autogen/misc_module_export_type.d.ts.map +1 -0
  28. package/dist/lib/autogen/misc_module_export_variants.d.ts +6 -0
  29. package/dist/lib/autogen/misc_module_export_variants.d.ts.map +1 -0
  30. package/dist/lib/autogen/product_type_element_type.d.ts +20 -0
  31. package/dist/lib/autogen/product_type_element_type.d.ts.map +1 -0
  32. package/dist/lib/autogen/product_type_type.d.ts +19 -0
  33. package/dist/lib/autogen/product_type_type.d.ts.map +1 -0
  34. package/dist/lib/autogen/raw_column_def_v_8_type.d.ts +20 -0
  35. package/dist/lib/autogen/raw_column_def_v_8_type.d.ts.map +1 -0
  36. package/dist/lib/autogen/raw_column_default_value_v_9_type.d.ts +20 -0
  37. package/dist/lib/autogen/raw_column_default_value_v_9_type.d.ts.map +1 -0
  38. package/dist/lib/autogen/raw_constraint_data_v_9_type.d.ts +12 -0
  39. package/dist/lib/autogen/raw_constraint_data_v_9_type.d.ts.map +1 -0
  40. package/dist/lib/autogen/raw_constraint_data_v_9_variants.d.ts +6 -0
  41. package/dist/lib/autogen/raw_constraint_data_v_9_variants.d.ts.map +1 -0
  42. package/dist/lib/autogen/raw_constraint_def_v_8_type.d.ts +20 -0
  43. package/dist/lib/autogen/raw_constraint_def_v_8_type.d.ts.map +1 -0
  44. package/dist/lib/autogen/raw_constraint_def_v_9_type.d.ts +20 -0
  45. package/dist/lib/autogen/raw_constraint_def_v_9_type.d.ts.map +1 -0
  46. package/dist/lib/autogen/raw_index_algorithm_type.d.ts +13 -0
  47. package/dist/lib/autogen/raw_index_algorithm_type.d.ts.map +1 -0
  48. package/dist/lib/autogen/raw_index_algorithm_variants.d.ts +13 -0
  49. package/dist/lib/autogen/raw_index_algorithm_variants.d.ts.map +1 -0
  50. package/dist/lib/autogen/raw_index_def_v_8_type.d.ts +22 -0
  51. package/dist/lib/autogen/raw_index_def_v_8_type.d.ts.map +1 -0
  52. package/dist/lib/autogen/raw_index_def_v_9_type.d.ts +21 -0
  53. package/dist/lib/autogen/raw_index_def_v_9_type.d.ts.map +1 -0
  54. package/dist/lib/autogen/raw_misc_module_export_v_9_type.d.ts +12 -0
  55. package/dist/lib/autogen/raw_misc_module_export_v_9_type.d.ts.map +1 -0
  56. package/dist/lib/autogen/raw_misc_module_export_v_9_variants.d.ts +6 -0
  57. package/dist/lib/autogen/raw_misc_module_export_v_9_variants.d.ts.map +1 -0
  58. package/dist/lib/autogen/raw_module_def_type.d.ts +14 -0
  59. package/dist/lib/autogen/raw_module_def_type.d.ts.map +1 -0
  60. package/dist/lib/autogen/raw_module_def_v_8_type.d.ts +25 -0
  61. package/dist/lib/autogen/raw_module_def_v_8_type.d.ts.map +1 -0
  62. package/dist/lib/autogen/raw_module_def_v_9_type.d.ts +29 -0
  63. package/dist/lib/autogen/raw_module_def_v_9_type.d.ts.map +1 -0
  64. package/dist/lib/autogen/raw_module_def_variants.d.ts +11 -0
  65. package/dist/lib/autogen/raw_module_def_variants.d.ts.map +1 -0
  66. package/dist/lib/autogen/raw_reducer_def_v_9_type.d.ts +22 -0
  67. package/dist/lib/autogen/raw_reducer_def_v_9_type.d.ts.map +1 -0
  68. package/dist/lib/autogen/raw_row_level_security_def_v_9_type.d.ts +18 -0
  69. package/dist/lib/autogen/raw_row_level_security_def_v_9_type.d.ts.map +1 -0
  70. package/dist/lib/autogen/raw_schedule_def_v_9_type.d.ts +20 -0
  71. package/dist/lib/autogen/raw_schedule_def_v_9_type.d.ts.map +1 -0
  72. package/dist/lib/autogen/raw_scoped_type_name_v_9_type.d.ts +19 -0
  73. package/dist/lib/autogen/raw_scoped_type_name_v_9_type.d.ts.map +1 -0
  74. package/dist/lib/autogen/raw_sequence_def_v_8_type.d.ts +24 -0
  75. package/dist/lib/autogen/raw_sequence_def_v_8_type.d.ts.map +1 -0
  76. package/dist/lib/autogen/raw_sequence_def_v_9_type.d.ts +23 -0
  77. package/dist/lib/autogen/raw_sequence_def_v_9_type.d.ts.map +1 -0
  78. package/dist/lib/autogen/raw_table_def_v_8_type.d.ts +29 -0
  79. package/dist/lib/autogen/raw_table_def_v_8_type.d.ts.map +1 -0
  80. package/dist/lib/autogen/raw_table_def_v_9_type.d.ts +32 -0
  81. package/dist/lib/autogen/raw_table_def_v_9_type.d.ts.map +1 -0
  82. package/dist/lib/autogen/raw_type_def_v_9_type.d.ts +21 -0
  83. package/dist/lib/autogen/raw_type_def_v_9_type.d.ts.map +1 -0
  84. package/dist/lib/autogen/raw_unique_constraint_data_v_9_type.d.ts +18 -0
  85. package/dist/lib/autogen/raw_unique_constraint_data_v_9_type.d.ts.map +1 -0
  86. package/dist/lib/autogen/reducer_def_type.d.ts +20 -0
  87. package/dist/lib/autogen/reducer_def_type.d.ts.map +1 -0
  88. package/dist/lib/autogen/sum_type_type.d.ts +19 -0
  89. package/dist/lib/autogen/sum_type_type.d.ts.map +1 -0
  90. package/dist/lib/autogen/sum_type_variant_type.d.ts +20 -0
  91. package/dist/lib/autogen/sum_type_variant_type.d.ts.map +1 -0
  92. package/dist/lib/autogen/table_access_type.d.ts +16 -0
  93. package/dist/lib/autogen/table_access_type.d.ts.map +1 -0
  94. package/dist/lib/autogen/table_access_variants.d.ts +7 -0
  95. package/dist/lib/autogen/table_access_variants.d.ts.map +1 -0
  96. package/dist/lib/autogen/table_desc_type.d.ts +20 -0
  97. package/dist/lib/autogen/table_desc_type.d.ts.map +1 -0
  98. package/dist/lib/autogen/table_type_type.d.ts +16 -0
  99. package/dist/lib/autogen/table_type_type.d.ts.map +1 -0
  100. package/dist/lib/autogen/table_type_variants.d.ts +7 -0
  101. package/dist/lib/autogen/table_type_variants.d.ts.map +1 -0
  102. package/dist/lib/autogen/type_alias_type.d.ts +19 -0
  103. package/dist/lib/autogen/type_alias_type.d.ts.map +1 -0
  104. package/dist/lib/autogen/typespace_type.d.ts +19 -0
  105. package/dist/lib/autogen/typespace_type.d.ts.map +1 -0
  106. package/dist/lib/binary_reader.d.ts +25 -0
  107. package/dist/lib/binary_reader.d.ts.map +1 -0
  108. package/dist/lib/binary_writer.d.ts +25 -0
  109. package/dist/lib/binary_writer.d.ts.map +1 -0
  110. package/dist/lib/connection_id.d.ts +37 -0
  111. package/dist/lib/connection_id.d.ts.map +1 -0
  112. package/dist/lib/identity.d.ts +39 -0
  113. package/dist/lib/identity.d.ts.map +1 -0
  114. package/dist/lib/schedule_at.d.ts +23 -0
  115. package/dist/lib/schedule_at.d.ts.map +1 -0
  116. package/dist/lib/time_duration.d.ts +18 -0
  117. package/dist/lib/time_duration.d.ts.map +1 -0
  118. package/dist/lib/timestamp.d.ts +35 -0
  119. package/dist/lib/timestamp.d.ts.map +1 -0
  120. package/dist/lib/utils.d.ts +13 -0
  121. package/dist/lib/utils.d.ts.map +1 -0
  122. package/dist/min/index.browser.mjs +1 -1
  123. package/dist/min/index.browser.mjs.map +1 -1
  124. package/dist/min/react/index.mjs.map +1 -1
  125. package/dist/min/sdk/index.browser.mjs +1 -1
  126. package/dist/min/sdk/index.browser.mjs.map +1 -1
  127. package/dist/react/SpacetimeDBProvider.d.ts +8 -0
  128. package/dist/react/SpacetimeDBProvider.d.ts.map +1 -0
  129. package/dist/react/index.cjs.map +1 -1
  130. package/dist/react/index.d.ts +4 -0
  131. package/dist/react/index.d.ts.map +1 -0
  132. package/dist/react/index.mjs.map +1 -1
  133. package/dist/react/useSpacetimeDB.d.ts +5 -0
  134. package/dist/react/useSpacetimeDB.d.ts.map +1 -0
  135. package/dist/react/useTable.d.ts +120 -0
  136. package/dist/react/useTable.d.ts.map +1 -0
  137. package/dist/sdk/client_api/bsatn_row_list_type.d.ts +20 -0
  138. package/dist/sdk/client_api/bsatn_row_list_type.d.ts.map +1 -0
  139. package/dist/sdk/client_api/call_reducer_type.d.ts +21 -0
  140. package/dist/sdk/client_api/call_reducer_type.d.ts.map +1 -0
  141. package/dist/sdk/client_api/client_message_type.d.ts +24 -0
  142. package/dist/sdk/client_api/client_message_type.d.ts.map +1 -0
  143. package/dist/sdk/client_api/client_message_variants.d.ts +36 -0
  144. package/dist/sdk/client_api/client_message_variants.d.ts.map +1 -0
  145. package/dist/sdk/client_api/compressable_query_update_type.d.ts +14 -0
  146. package/dist/sdk/client_api/compressable_query_update_type.d.ts.map +1 -0
  147. package/dist/sdk/client_api/compressable_query_update_variants.d.ts +14 -0
  148. package/dist/sdk/client_api/compressable_query_update_variants.d.ts.map +1 -0
  149. package/dist/sdk/client_api/database_update_type.d.ts +19 -0
  150. package/dist/sdk/client_api/database_update_type.d.ts.map +1 -0
  151. package/dist/sdk/client_api/energy_quanta_type.d.ts +18 -0
  152. package/dist/sdk/client_api/energy_quanta_type.d.ts.map +1 -0
  153. package/dist/sdk/client_api/identity_token_type.d.ts +20 -0
  154. package/dist/sdk/client_api/identity_token_type.d.ts.map +1 -0
  155. package/dist/sdk/client_api/index.d.ts +86 -0
  156. package/dist/sdk/client_api/index.d.ts.map +1 -0
  157. package/dist/sdk/client_api/initial_subscription_type.d.ts +21 -0
  158. package/dist/sdk/client_api/initial_subscription_type.d.ts.map +1 -0
  159. package/dist/sdk/client_api/one_off_query_response_type.d.ts +22 -0
  160. package/dist/sdk/client_api/one_off_query_response_type.d.ts.map +1 -0
  161. package/dist/sdk/client_api/one_off_query_type.d.ts +19 -0
  162. package/dist/sdk/client_api/one_off_query_type.d.ts.map +1 -0
  163. package/dist/sdk/client_api/one_off_table_type.d.ts +20 -0
  164. package/dist/sdk/client_api/one_off_table_type.d.ts.map +1 -0
  165. package/dist/sdk/client_api/query_id_type.d.ts +18 -0
  166. package/dist/sdk/client_api/query_id_type.d.ts.map +1 -0
  167. package/dist/sdk/client_api/query_update_type.d.ts +20 -0
  168. package/dist/sdk/client_api/query_update_type.d.ts.map +1 -0
  169. package/dist/sdk/client_api/reducer_call_info_type.d.ts +21 -0
  170. package/dist/sdk/client_api/reducer_call_info_type.d.ts.map +1 -0
  171. package/dist/sdk/client_api/row_size_hint_type.d.ts +12 -0
  172. package/dist/sdk/client_api/row_size_hint_type.d.ts.map +1 -0
  173. package/dist/sdk/client_api/row_size_hint_variants.d.ts +9 -0
  174. package/dist/sdk/client_api/row_size_hint_variants.d.ts.map +1 -0
  175. package/dist/sdk/client_api/server_message_type.d.ts +30 -0
  176. package/dist/sdk/client_api/server_message_type.d.ts.map +1 -0
  177. package/dist/sdk/client_api/server_message_variants.d.ts +51 -0
  178. package/dist/sdk/client_api/server_message_variants.d.ts.map +1 -0
  179. package/dist/sdk/client_api/subscribe_applied_type.d.ts +23 -0
  180. package/dist/sdk/client_api/subscribe_applied_type.d.ts.map +1 -0
  181. package/dist/sdk/client_api/subscribe_multi_applied_type.d.ts +23 -0
  182. package/dist/sdk/client_api/subscribe_multi_applied_type.d.ts.map +1 -0
  183. package/dist/sdk/client_api/subscribe_multi_type.d.ts +21 -0
  184. package/dist/sdk/client_api/subscribe_multi_type.d.ts.map +1 -0
  185. package/dist/sdk/client_api/subscribe_rows_type.d.ts +21 -0
  186. package/dist/sdk/client_api/subscribe_rows_type.d.ts.map +1 -0
  187. package/dist/sdk/client_api/subscribe_single_type.d.ts +21 -0
  188. package/dist/sdk/client_api/subscribe_single_type.d.ts.map +1 -0
  189. package/dist/sdk/client_api/subscribe_type.d.ts +19 -0
  190. package/dist/sdk/client_api/subscribe_type.d.ts.map +1 -0
  191. package/dist/sdk/client_api/subscription_error_type.d.ts +22 -0
  192. package/dist/sdk/client_api/subscription_error_type.d.ts.map +1 -0
  193. package/dist/sdk/client_api/table_update_type.d.ts +22 -0
  194. package/dist/sdk/client_api/table_update_type.d.ts.map +1 -0
  195. package/dist/sdk/client_api/transaction_update_light_type.d.ts +20 -0
  196. package/dist/sdk/client_api/transaction_update_light_type.d.ts.map +1 -0
  197. package/dist/sdk/client_api/transaction_update_type.d.ts +27 -0
  198. package/dist/sdk/client_api/transaction_update_type.d.ts.map +1 -0
  199. package/dist/sdk/client_api/unsubscribe_applied_type.d.ts +23 -0
  200. package/dist/sdk/client_api/unsubscribe_applied_type.d.ts.map +1 -0
  201. package/dist/sdk/client_api/unsubscribe_multi_applied_type.d.ts +23 -0
  202. package/dist/sdk/client_api/unsubscribe_multi_applied_type.d.ts.map +1 -0
  203. package/dist/sdk/client_api/unsubscribe_multi_type.d.ts +20 -0
  204. package/dist/sdk/client_api/unsubscribe_multi_type.d.ts.map +1 -0
  205. package/dist/sdk/client_api/unsubscribe_type.d.ts +20 -0
  206. package/dist/sdk/client_api/unsubscribe_type.d.ts.map +1 -0
  207. package/dist/sdk/client_api/update_status_type.d.ts +16 -0
  208. package/dist/sdk/client_api/update_status_type.d.ts.map +1 -0
  209. package/dist/sdk/client_api/update_status_variants.d.ts +13 -0
  210. package/dist/sdk/client_api/update_status_variants.d.ts.map +1 -0
  211. package/dist/sdk/client_cache.d.ts +17 -0
  212. package/dist/sdk/client_cache.d.ts.map +1 -0
  213. package/dist/sdk/db_connection_builder.d.ts +145 -0
  214. package/dist/sdk/db_connection_builder.d.ts.map +1 -0
  215. package/dist/sdk/db_connection_impl.d.ts +102 -0
  216. package/dist/sdk/db_connection_impl.d.ts.map +1 -0
  217. package/dist/sdk/db_context.d.ts +25 -0
  218. package/dist/sdk/db_context.d.ts.map +1 -0
  219. package/dist/sdk/decompress.d.ts +2 -0
  220. package/dist/sdk/decompress.d.ts.map +1 -0
  221. package/dist/sdk/event.d.ts +15 -0
  222. package/dist/sdk/event.d.ts.map +1 -0
  223. package/dist/sdk/event_context.d.ts +18 -0
  224. package/dist/sdk/event_context.d.ts.map +1 -0
  225. package/dist/sdk/event_emitter.d.ts +7 -0
  226. package/dist/sdk/event_emitter.d.ts.map +1 -0
  227. package/dist/sdk/index.browser.mjs +18 -4
  228. package/dist/sdk/index.browser.mjs.map +1 -1
  229. package/dist/sdk/index.cjs +18 -16
  230. package/dist/sdk/index.cjs.map +1 -1
  231. package/dist/sdk/index.d.ts +4 -0
  232. package/dist/sdk/index.d.ts.map +1 -0
  233. package/dist/sdk/index.mjs +18 -16
  234. package/dist/sdk/index.mjs.map +1 -1
  235. package/dist/sdk/json_api.d.ts +40 -0
  236. package/dist/sdk/json_api.d.ts.map +1 -0
  237. package/dist/sdk/logger.d.ts +4 -0
  238. package/dist/sdk/logger.d.ts.map +1 -0
  239. package/dist/sdk/message_types.d.ts +50 -0
  240. package/dist/sdk/message_types.d.ts.map +1 -0
  241. package/dist/sdk/reducer_event.d.ts +42 -0
  242. package/dist/sdk/reducer_event.d.ts.map +1 -0
  243. package/dist/sdk/spacetime_module.d.ts +31 -0
  244. package/dist/sdk/spacetime_module.d.ts.map +1 -0
  245. package/dist/sdk/subscription_builder_impl.d.ts +126 -0
  246. package/dist/sdk/subscription_builder_impl.d.ts.map +1 -0
  247. package/dist/sdk/table_cache.d.ts +111 -0
  248. package/dist/sdk/table_cache.d.ts.map +1 -0
  249. package/dist/sdk/version.d.ts +18 -0
  250. package/dist/sdk/version.d.ts.map +1 -0
  251. package/dist/sdk/websocket_decompress_adapter.d.ts +21 -0
  252. package/dist/sdk/websocket_decompress_adapter.d.ts.map +1 -0
  253. package/dist/sdk/websocket_test_adapter.d.ts +22 -0
  254. package/dist/sdk/websocket_test_adapter.d.ts.map +1 -0
  255. package/dist/sdk/ws.d.ts +2 -0
  256. package/dist/sdk/ws.d.ts.map +1 -0
  257. package/dist/server/index.d.ts +3 -0
  258. package/dist/server/index.d.ts.map +1 -0
  259. package/dist/server/type_builders.d.ts +656 -0
  260. package/dist/server/type_builders.d.ts.map +1 -0
  261. package/dist/server/type_builders.test-d.d.ts +2 -0
  262. package/dist/server/type_builders.test-d.d.ts.map +1 -0
  263. package/dist/server/type_util.d.ts +18 -0
  264. package/dist/server/type_util.d.ts.map +1 -0
  265. package/package.json +30 -27
  266. package/src/react/SpacetimeDBProvider.ts +4 -1
  267. package/src/react/useSpacetimeDB.ts +1 -1
  268. package/src/react/useTable.ts +1 -1
  269. package/src/sdk/db_connection_builder.ts +1 -1
  270. package/src/sdk/db_connection_impl.ts +6 -6
  271. package/src/sdk/message_types.ts +3 -3
  272. package/src/sdk/reducer_event.ts +3 -3
  273. package/src/sdk/spacetime_module.ts +1 -1
  274. package/src/sdk/table_cache.ts +1 -1
  275. package/src/sdk/websocket_decompress_adapter.ts +2 -30
  276. package/src/sdk/websocket_test_adapter.ts +1 -1
  277. package/src/sdk/ws.ts +24 -0
  278. package/LICENSE.txt +0 -759
@@ -0,0 +1,19 @@
1
+ import { BinaryReader as __BinaryReader, BinaryWriter as __BinaryWriter, type AlgebraicType as __AlgebraicTypeType } from '../../index';
2
+ export type TypeAlias = {
3
+ name: string;
4
+ ty: number;
5
+ };
6
+ /**
7
+ * An object for generated helper functions.
8
+ */
9
+ export declare const TypeAlias: {
10
+ /**
11
+ * A function which returns this type represented as an AlgebraicType.
12
+ * This function is derived from the AlgebraicType used to generate this type.
13
+ */
14
+ getTypeScriptAlgebraicType(): __AlgebraicTypeType;
15
+ serialize(writer: __BinaryWriter, value: TypeAlias): void;
16
+ deserialize(reader: __BinaryReader): TypeAlias;
17
+ };
18
+ export default TypeAlias;
19
+ //# sourceMappingURL=type_alias_type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type_alias_type.d.ts","sourceRoot":"","sources":["../../../src/lib/autogen/type_alias_type.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,YAAY,IAAI,cAAc,EAC9B,YAAY,IAAI,cAAc,EAM9B,KAAK,aAAa,IAAI,mBAAmB,EAE1C,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB;;;OAGG;kCAC2B,mBAAmB;sBAS/B,cAAc,SAAS,SAAS,GAAG,IAAI;wBAQrC,cAAc,GAAG,SAAS;CAM/C,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { BinaryReader as __BinaryReader, BinaryWriter as __BinaryWriter, type AlgebraicType as __AlgebraicTypeType } from '../../index';
2
+ import { AlgebraicType } from './algebraic_type_type';
3
+ export type Typespace = {
4
+ types: AlgebraicType[];
5
+ };
6
+ /**
7
+ * An object for generated helper functions.
8
+ */
9
+ export declare const Typespace: {
10
+ /**
11
+ * A function which returns this type represented as an AlgebraicType.
12
+ * This function is derived from the AlgebraicType used to generate this type.
13
+ */
14
+ getTypeScriptAlgebraicType(): __AlgebraicTypeType;
15
+ serialize(writer: __BinaryWriter, value: Typespace): void;
16
+ deserialize(reader: __BinaryReader): Typespace;
17
+ };
18
+ export default Typespace;
19
+ //# sourceMappingURL=typespace_type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typespace_type.d.ts","sourceRoot":"","sources":["../../../src/lib/autogen/typespace_type.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,YAAY,IAAI,cAAc,EAC9B,YAAY,IAAI,cAAc,EAM9B,KAAK,aAAa,IAAI,mBAAmB,EAE1C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAItD,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB;;;OAGG;kCAC2B,mBAAmB;sBAa/B,cAAc,SAAS,SAAS,GAAG,IAAI;wBAQrC,cAAc,GAAG,SAAS;CAM/C,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,25 @@
1
+ export default class BinaryReader {
2
+ #private;
3
+ constructor(input: Uint8Array);
4
+ get offset(): number;
5
+ readUInt8Array(): Uint8Array;
6
+ readBool(): boolean;
7
+ readByte(): number;
8
+ readBytes(length: number): Uint8Array;
9
+ readI8(): number;
10
+ readU8(): number;
11
+ readI16(): number;
12
+ readU16(): number;
13
+ readI32(): number;
14
+ readU32(): number;
15
+ readI64(): bigint;
16
+ readU64(): bigint;
17
+ readU128(): bigint;
18
+ readI128(): bigint;
19
+ readU256(): bigint;
20
+ readI256(): bigint;
21
+ readF32(): number;
22
+ readF64(): number;
23
+ readString(): string;
24
+ }
25
+ //# sourceMappingURL=binary_reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary_reader.d.ts","sourceRoot":"","sources":["../../src/lib/binary_reader.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,YAAY;;gBAInB,KAAK,EAAE,UAAU;IAK7B,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,cAAc,IAAI,UAAU;IAW5B,QAAQ,IAAI,OAAO;IAMnB,QAAQ,IAAI,MAAM;IAMlB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;IAUrC,MAAM,IAAI,MAAM;IAMhB,MAAM,IAAI,MAAM;IAMhB,OAAO,IAAI,MAAM;IAMjB,OAAO,IAAI,MAAM;IAMjB,OAAO,IAAI,MAAM;IAMjB,OAAO,IAAI,MAAM;IAMjB,OAAO,IAAI,MAAM;IAMjB,OAAO,IAAI,MAAM;IAMjB,QAAQ,IAAI,MAAM;IAQlB,QAAQ,IAAI,MAAM;IAQlB,QAAQ,IAAI,MAAM;IAelB,QAAQ,IAAI,MAAM;IAelB,OAAO,IAAI,MAAM;IAMjB,OAAO,IAAI,MAAM;IAMjB,UAAU,IAAI,MAAM;CAYrB"}
@@ -0,0 +1,25 @@
1
+ export default class BinaryWriter {
2
+ #private;
3
+ constructor(size: number);
4
+ toBase64(): string;
5
+ getBuffer(): Uint8Array;
6
+ writeUInt8Array(value: Uint8Array): void;
7
+ writeBool(value: boolean): void;
8
+ writeByte(value: number): void;
9
+ writeI8(value: number): void;
10
+ writeU8(value: number): void;
11
+ writeI16(value: number): void;
12
+ writeU16(value: number): void;
13
+ writeI32(value: number): void;
14
+ writeU32(value: number): void;
15
+ writeI64(value: bigint): void;
16
+ writeU64(value: bigint): void;
17
+ writeU128(value: bigint): void;
18
+ writeI128(value: bigint): void;
19
+ writeU256(value: bigint): void;
20
+ writeI256(value: bigint): void;
21
+ writeF32(value: number): void;
22
+ writeF64(value: number): void;
23
+ writeString(value: string): void;
24
+ }
25
+ //# sourceMappingURL=binary_writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary_writer.d.ts","sourceRoot":"","sources":["../../src/lib/binary_writer.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,OAAO,YAAY;;gBAKnB,IAAI,EAAE,MAAM;IAgBxB,QAAQ,IAAI,MAAM;IAIlB,SAAS,IAAI,UAAU;IAIvB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAUxC,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAM/B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM9B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM5B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM5B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAS9B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAS9B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAc9B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAc9B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAQjC"}
@@ -0,0 +1,37 @@
1
+ import { AlgebraicType } from './algebraic_type';
2
+ /**
3
+ * A unique identifier for a client connected to a database.
4
+ */
5
+ export declare class ConnectionId {
6
+ __connection_id__: bigint;
7
+ /**
8
+ * Creates a new `ConnectionId`.
9
+ */
10
+ constructor(data: bigint);
11
+ /**
12
+ * Get the algebraic type representation of the {@link ConnectionId} type.
13
+ * @returns The algebraic type representation of the type.
14
+ */
15
+ static getAlgebraicType(): AlgebraicType;
16
+ isZero(): boolean;
17
+ static nullIfZero(addr: ConnectionId): ConnectionId | null;
18
+ static random(): ConnectionId;
19
+ /**
20
+ * Compare two connection IDs for equality.
21
+ */
22
+ isEqual(other: ConnectionId): boolean;
23
+ /**
24
+ * Print the connection ID as a hexadecimal string.
25
+ */
26
+ toHexString(): string;
27
+ /**
28
+ * Convert the connection ID to a Uint8Array.
29
+ */
30
+ toUint8Array(): Uint8Array;
31
+ /**
32
+ * Parse a connection ID from a hexadecimal string.
33
+ */
34
+ static fromString(str: string): ConnectionId;
35
+ static fromStringOrNull(str: string): ConnectionId | null;
36
+ }
37
+ //# sourceMappingURL=connection_id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection_id.d.ts","sourceRoot":"","sources":["../../src/lib/connection_id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD;;GAEG;AACH,qBAAa,YAAY;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;OAEG;gBACS,IAAI,EAAE,MAAM;IAIxB;;;OAGG;IACH,MAAM,CAAC,gBAAgB,IAAI,aAAa;IAQxC,MAAM,IAAI,OAAO;IAIjB,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,GAAG,IAAI;IAQ1D,MAAM,CAAC,MAAM,IAAI,YAAY;IAW7B;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAIrC;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,YAAY,IAAI,UAAU;IAI1B;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;IAI5C,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;CAQ1D"}
@@ -0,0 +1,39 @@
1
+ import { AlgebraicType } from './algebraic_type';
2
+ /**
3
+ * A unique identifier for a user connected to a database.
4
+ */
5
+ export declare class Identity {
6
+ __identity__: bigint;
7
+ /**
8
+ * Creates a new `Identity`.
9
+ *
10
+ * `data` can be a hexadecimal string or a `bigint`.
11
+ */
12
+ constructor(data: string | bigint);
13
+ /**
14
+ * Get the algebraic type representation of the {@link Identity} type.
15
+ * @returns The algebraic type representation of the type.
16
+ */
17
+ static getAlgebraicType(): AlgebraicType;
18
+ /**
19
+ * Compare two identities for equality.
20
+ */
21
+ isEqual(other: Identity): boolean;
22
+ /**
23
+ * Print the identity as a hexadecimal string.
24
+ */
25
+ toHexString(): string;
26
+ /**
27
+ * Convert the address to a Uint8Array.
28
+ */
29
+ toUint8Array(): Uint8Array;
30
+ /**
31
+ * Parse an Identity from a hexadecimal string.
32
+ */
33
+ static fromString(str: string): Identity;
34
+ /**
35
+ * Zero identity (0x0000000000000000000000000000000000000000000000000000000000000000)
36
+ */
37
+ static zero(): Identity;
38
+ }
39
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/lib/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD;;GAEG;AACH,qBAAa,QAAQ;IACnB,YAAY,EAAE,MAAM,CAAC;IAErB;;;;OAIG;gBACS,IAAI,EAAE,MAAM,GAAG,MAAM;IAMjC;;;OAGG;IACH,MAAM,CAAC,gBAAgB,IAAI,aAAa;IAMxC;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAIjC;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,YAAY,IAAI,UAAU;IAI1B;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;IAIxC;;OAEG;IACH,MAAM,CAAC,IAAI,IAAI,QAAQ;CAGxB"}
@@ -0,0 +1,23 @@
1
+ import { AlgebraicType } from './algebraic_type';
2
+ import { TimeDuration } from './time_duration';
3
+ import { Timestamp } from './timestamp';
4
+ export declare const ScheduleAt: {
5
+ /**
6
+ * Get the algebraic type representation of the {@link ScheduleAt} type.
7
+ * @returns The algebraic type representation of the type.
8
+ */
9
+ getAlgebraicType(): AlgebraicType;
10
+ };
11
+ export type Interval = {
12
+ tag: 'Interval';
13
+ value: TimeDuration;
14
+ };
15
+ export declare const Interval: (value: bigint) => Interval;
16
+ export type Time = {
17
+ tag: 'Time';
18
+ value: Timestamp;
19
+ };
20
+ export declare const Time: (value: bigint) => Time;
21
+ export type ScheduleAt = Interval | Time;
22
+ export default ScheduleAt;
23
+ //# sourceMappingURL=schedule_at.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule_at.d.ts","sourceRoot":"","sources":["../../src/lib/schedule_at.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAO,MAAM,UAAU,EAAE;IACvB;;;OAGG;IACH,gBAAgB,IAAI,aAAa,CAAC;CAanC,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,QAGvC,CAAC;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AACF,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,KAAG,IAGnC,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC;AACzC,eAAe,UAAU,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { AlgebraicType } from './algebraic_type';
2
+ /**
3
+ * A difference between two points in time, represented as a number of microseconds.
4
+ */
5
+ export declare class TimeDuration {
6
+ __time_duration_micros__: bigint;
7
+ private static MICROS_PER_MILLIS;
8
+ /**
9
+ * Get the algebraic type representation of the {@link TimeDuration} type.
10
+ * @returns The algebraic type representation of the type.
11
+ */
12
+ static getAlgebraicType(): AlgebraicType;
13
+ get micros(): bigint;
14
+ get millis(): number;
15
+ constructor(micros: bigint);
16
+ static fromMillis(millis: number): TimeDuration;
17
+ }
18
+ //# sourceMappingURL=time_duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time_duration.d.ts","sourceRoot":"","sources":["../../src/lib/time_duration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;GAEG;AACH,qBAAa,YAAY;IACvB,wBAAwB,EAAE,MAAM,CAAC;IAEjC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAiB;IAEjD;;;OAGG;IACH,MAAM,CAAC,gBAAgB,IAAI,aAAa;IAWxC,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;gBAEW,MAAM,EAAE,MAAM;IAI1B,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;CAGhD"}
@@ -0,0 +1,35 @@
1
+ import { AlgebraicType } from './algebraic_type';
2
+ /**
3
+ * A point in time, represented as a number of microseconds since the Unix epoch.
4
+ */
5
+ export declare class Timestamp {
6
+ __timestamp_micros_since_unix_epoch__: bigint;
7
+ private static MICROS_PER_MILLIS;
8
+ get microsSinceUnixEpoch(): bigint;
9
+ constructor(micros: bigint);
10
+ /**
11
+ * Get the algebraic type representation of the {@link Timestamp} type.
12
+ * @returns The algebraic type representation of the type.
13
+ */
14
+ static getAlgebraicType(): AlgebraicType;
15
+ /**
16
+ * The Unix epoch, the midnight at the beginning of January 1, 1970, UTC.
17
+ */
18
+ static UNIX_EPOCH: Timestamp;
19
+ /**
20
+ * Get a `Timestamp` representing the execution environment's belief of the current moment in time.
21
+ */
22
+ static now(): Timestamp;
23
+ /**
24
+ * Get a `Timestamp` representing the same point in time as `date`.
25
+ */
26
+ static fromDate(date: Date): Timestamp;
27
+ /**
28
+ * Get a `Date` representing approximately the same point in time as `this`.
29
+ *
30
+ * This method truncates to millisecond precision,
31
+ * and throws `RangeError` if the `Timestamp` is outside the range representable as a `Date`.
32
+ */
33
+ toDate(): Date;
34
+ }
35
+ //# sourceMappingURL=timestamp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timestamp.d.ts","sourceRoot":"","sources":["../../src/lib/timestamp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;GAEG;AACH,qBAAa,SAAS;IACpB,qCAAqC,EAAE,MAAM,CAAC;IAE9C,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAiB;IAEjD,IAAI,oBAAoB,IAAI,MAAM,CAEjC;gBAEW,MAAM,EAAE,MAAM;IAI1B;;;OAGG;IACH,MAAM,CAAC,gBAAgB,IAAI,aAAa;IAWxC;;OAEG;IACH,MAAM,CAAC,UAAU,EAAE,SAAS,CAAqB;IAEjD;;OAEG;IACH,MAAM,CAAC,GAAG,IAAI,SAAS;IAIvB;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS;IAMtC;;;;;OAKG;IACH,MAAM,IAAI,IAAI;CAaf"}
@@ -0,0 +1,13 @@
1
+ export declare function toPascalCase(s: string): string;
2
+ export declare function deepEqual(obj1: any, obj2: any): boolean;
3
+ export declare function uint8ArrayToHexString(array: Uint8Array): string;
4
+ export declare function uint8ArrayToU128(array: Uint8Array): bigint;
5
+ export declare function uint8ArrayToU256(array: Uint8Array): bigint;
6
+ export declare function hexStringToUint8Array(str: string): Uint8Array;
7
+ export declare function hexStringToU128(str: string): bigint;
8
+ export declare function hexStringToU256(str: string): bigint;
9
+ export declare function u128ToUint8Array(data: bigint): Uint8Array;
10
+ export declare function u128ToHexString(data: bigint): string;
11
+ export declare function u256ToUint8Array(data: bigint): Uint8Array;
12
+ export declare function u256ToHexString(data: bigint): string;
13
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CA6BvD;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAI/D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAK1D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAK1D;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAS7D;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAIzD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAIzD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -1 +1 @@
1
- import{fromByteArray as e}from"base64-js";var t=class e{__time_duration_micros__;static MICROS_PER_MILLIS=1000n;static getAlgebraicType(){return v.Product({elements:[{name:"__time_duration_micros__",algebraicType:v.I64}]})}get micros(){return this.__time_duration_micros__}get millis(){return Number(this.micros/e.MICROS_PER_MILLIS)}constructor(e){this.__time_duration_micros__=e}static fromMillis(t){return new e(BigInt(t)*e.MICROS_PER_MILLIS)}},r=class e{__timestamp_micros_since_unix_epoch__;static MICROS_PER_MILLIS=1000n;get microsSinceUnixEpoch(){return this.__timestamp_micros_since_unix_epoch__}constructor(e){this.__timestamp_micros_since_unix_epoch__=e}static getAlgebraicType(){return v.Product({elements:[{name:"__timestamp_micros_since_unix_epoch__",algebraicType:v.I64}]})}static UNIX_EPOCH=new e(0n);static now(){return e.fromDate(new Date)}static fromDate(t){const r=t.getTime(),i=BigInt(r)*e.MICROS_PER_MILLIS;return new e(i)}toDate(){const t=this.__timestamp_micros_since_unix_epoch__/e.MICROS_PER_MILLIS;if(t>BigInt(Number.MAX_SAFE_INTEGER)||t<BigInt(Number.MIN_SAFE_INTEGER))throw new RangeError("Timestamp is outside of the representable range of JS's Date");return new Date(Number(t))}},i=class{#e;#t;#r=0;constructor(e){this.#e=new Uint8Array(e),this.#t=new DataView(this.#e.buffer)}#i(e){const t=this.#r+e+1;if(t<=this.#e.length)return;let r=2*this.#e.length;r<t&&(r=t);const i=new Uint8Array(r);i.set(this.#e),this.#e=i,this.#t=new DataView(this.#e.buffer)}toBase64(){return e(this.#e.subarray(0,this.#r))}getBuffer(){return this.#e.slice(0,this.#r)}writeUInt8Array(e){const t=e.length;this.#i(4+t),this.writeU32(t),this.#e.set(e,this.#r),this.#r+=e.length}writeBool(e){this.#i(1),this.#t.setUint8(this.#r,e?1:0),this.#r+=1}writeByte(e){this.#i(1),this.#t.setUint8(this.#r,e),this.#r+=1}writeI8(e){this.#i(1),this.#t.setInt8(this.#r,e),this.#r+=1}writeU8(e){this.#i(1),this.#t.setUint8(this.#r,e),this.#r+=1}writeI16(e){this.#i(2),this.#t.setInt16(this.#r,e,!0),this.#r+=2}writeU16(e){this.#i(2),this.#t.setUint16(this.#r,e,!0),this.#r+=2}writeI32(e){this.#i(4),this.#t.setInt32(this.#r,e,!0),this.#r+=4}writeU32(e){this.#i(4),this.#t.setUint32(this.#r,e,!0),this.#r+=4}writeI64(e){this.#i(8),this.#t.setBigInt64(this.#r,e,!0),this.#r+=8}writeU64(e){this.#i(8),this.#t.setBigUint64(this.#r,e,!0),this.#r+=8}writeU128(e){this.#i(16);const t=e&BigInt("0xFFFFFFFFFFFFFFFF"),r=e>>BigInt(64);this.#t.setBigUint64(this.#r,t,!0),this.#t.setBigUint64(this.#r+8,r,!0),this.#r+=16}writeI128(e){this.#i(16);const t=e&BigInt("0xFFFFFFFFFFFFFFFF"),r=e>>BigInt(64);this.#t.setBigInt64(this.#r,t,!0),this.#t.setBigInt64(this.#r+8,r,!0),this.#r+=16}writeU256(e){this.#i(32);const t=BigInt("0xFFFFFFFFFFFFFFFF"),r=e&t,i=e>>BigInt(64)&t,a=e>>BigInt(128)&t,s=e>>BigInt(192);this.#t.setBigUint64(this.#r+0,r,!0),this.#t.setBigUint64(this.#r+8,i,!0),this.#t.setBigUint64(this.#r+16,a,!0),this.#t.setBigUint64(this.#r+24,s,!0),this.#r+=32}writeI256(e){this.#i(32);const t=BigInt("0xFFFFFFFFFFFFFFFF"),r=e&t,i=e>>BigInt(64)&t,a=e>>BigInt(128)&t,s=e>>BigInt(192);this.#t.setBigUint64(this.#r+0,r,!0),this.#t.setBigUint64(this.#r+8,i,!0),this.#t.setBigUint64(this.#r+16,a,!0),this.#t.setBigInt64(this.#r+24,s,!0),this.#r+=32}writeF32(e){this.#i(4),this.#t.setFloat32(this.#r,e,!0),this.#r+=4}writeF64(e){this.#i(8),this.#t.setFloat64(this.#r,e,!0),this.#r+=8}writeString(e){const t=(new TextEncoder).encode(e);this.writeU32(t.length),this.#i(t.length),this.#e.set(t,this.#r),this.#r+=t.length}},a=class{#e;#r=0;constructor(e){this.#e=new DataView(e.buffer),this.#r=e.byteOffset}get offset(){return this.#r}readUInt8Array(){const e=this.readU32(),t=new Uint8Array(this.#e.buffer,this.#r,e);return this.#r+=e,t}readBool(){const e=this.#e.getUint8(this.#r);return this.#r+=1,0!==e}readByte(){const e=this.#e.getUint8(this.#r);return this.#r+=1,e}readBytes(e){const t=new DataView(this.#e.buffer,this.#r,e);return this.#r+=e,new Uint8Array(t.buffer)}readI8(){const e=this.#e.getInt8(this.#r);return this.#r+=1,e}readU8(){const e=this.#e.getUint8(this.#r);return this.#r+=1,e}readI16(){const e=this.#e.getInt16(this.#r,!0);return this.#r+=2,e}readU16(){const e=this.#e.getUint16(this.#r,!0);return this.#r+=2,e}readI32(){const e=this.#e.getInt32(this.#r,!0);return this.#r+=4,e}readU32(){const e=this.#e.getUint32(this.#r,!0);return this.#r+=4,e}readI64(){const e=this.#e.getBigInt64(this.#r,!0);return this.#r+=8,e}readU64(){const e=this.#e.getBigUint64(this.#r,!0);return this.#r+=8,e}readU128(){const e=this.#e.getBigUint64(this.#r,!0),t=this.#e.getBigUint64(this.#r+8,!0);return this.#r+=16,(t<<BigInt(64))+e}readI128(){const e=this.#e.getBigUint64(this.#r,!0),t=this.#e.getBigInt64(this.#r+8,!0);return this.#r+=16,(t<<BigInt(64))+e}readU256(){const e=this.#e.getBigUint64(this.#r,!0),t=this.#e.getBigUint64(this.#r+8,!0),r=this.#e.getBigUint64(this.#r+16,!0),i=this.#e.getBigUint64(this.#r+24,!0);return this.#r+=32,(i<<BigInt(192))+(r<<BigInt(128))+(t<<BigInt(64))+e}readI256(){const e=this.#e.getBigUint64(this.#r,!0),t=this.#e.getBigUint64(this.#r+8,!0),r=this.#e.getBigUint64(this.#r+16,!0),i=this.#e.getBigInt64(this.#r+24,!0);return this.#r+=32,(i<<BigInt(192))+(r<<BigInt(128))+(t<<BigInt(64))+e}readF32(){const e=this.#e.getFloat32(this.#r,!0);return this.#r+=4,e}readF64(){const e=this.#e.getFloat64(this.#r,!0);return this.#r+=8,e}readString(){const e=this.readU32(),t=new Uint8Array(this.#e.buffer,this.#r,e),r=new TextDecoder("utf-8").decode(t);return this.#r+=e,r}};function s(e){const t=e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace("-","").replace("_",""));return t.charAt(0).toUpperCase()+t.slice(1)}function n(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(const a of r)if(!i.includes(a)||!n(e[a],t[a]))return!1;return!0}function c(e){return Array.prototype.map.call(e.reverse(),e=>("00"+e.toString(16)).slice(-2)).join("")}function o(e){if(16!=e.length)throw new Error(`Uint8Array is not 16 bytes long: ${e}`);return new a(e).readU128()}function l(e){if(32!=e.length)throw new Error(`Uint8Array is not 32 bytes long: [${e}]`);return new a(e).readU256()}function u(e){e.startsWith("0x")&&(e=e.slice(2));const t=e.match(/.{1,2}/g)||[];return Uint8Array.from(t.map(e=>parseInt(e,16))).reverse()}function p(e){return o(u(e))}function d(e){return l(u(e))}function y(e){const t=new i(16);return t.writeU128(e),t.getBuffer()}function g(e){return c(y(e))}function h(e){const t=new i(32);return t.writeU256(e),t.getBuffer()}function b(e){return c(h(e))}var m=class e{__identity__;constructor(e){this.__identity__="string"==typeof e?d(e):e}static getAlgebraicType(){return v.Product({elements:[{name:"__identity__",algebraicType:v.U256}]})}isEqual(e){return this.toHexString()===e.toHexString()}toHexString(){return b(this.__identity__)}toUint8Array(){return h(this.__identity__)}static fromString(t){return new e(t)}static zero(){return new e(0n)}},f={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"name",algebraicType:v.createOptionType(v.String)},{name:"algebraicType",algebraicType:S.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,f.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,f.getTypeScriptAlgebraicType())},T={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"variants",algebraicType:v.Array(f.getTypeScriptAlgebraicType())}]}),serialize(e,t){v.serializeValue(e,T.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,T.getTypeScriptAlgebraicType())},w={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"name",algebraicType:v.createOptionType(v.String)},{name:"algebraicType",algebraicType:S.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,w.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,w.getTypeScriptAlgebraicType())},I={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"elements",algebraicType:v.Array(w.getTypeScriptAlgebraicType())}]}),serialize(e,t){v.serializeValue(e,I.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,I.getTypeScriptAlgebraicType())},S={Ref:e=>({tag:"Ref",value:e}),Sum:e=>({tag:"Sum",value:e}),Product:e=>({tag:"Product",value:e}),Array:e=>({tag:"Array",value:e}),String:{tag:"String"},Bool:{tag:"Bool"},I8:{tag:"I8"},U8:{tag:"U8"},I16:{tag:"I16"},U16:{tag:"U16"},I32:{tag:"I32"},U32:{tag:"U32"},I64:{tag:"I64"},U64:{tag:"U64"},I128:{tag:"I128"},U128:{tag:"U128"},I256:{tag:"I256"},U256:{tag:"U256"},F32:{tag:"F32"},F64:{tag:"F64"},getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"Ref",algebraicType:v.U32},{name:"Sum",algebraicType:T.getTypeScriptAlgebraicType()},{name:"Product",algebraicType:I.getTypeScriptAlgebraicType()},{name:"Array",algebraicType:S.getTypeScriptAlgebraicType()},{name:"String",algebraicType:v.Product({elements:[]})},{name:"Bool",algebraicType:v.Product({elements:[]})},{name:"I8",algebraicType:v.Product({elements:[]})},{name:"U8",algebraicType:v.Product({elements:[]})},{name:"I16",algebraicType:v.Product({elements:[]})},{name:"U16",algebraicType:v.Product({elements:[]})},{name:"I32",algebraicType:v.Product({elements:[]})},{name:"U32",algebraicType:v.Product({elements:[]})},{name:"I64",algebraicType:v.Product({elements:[]})},{name:"U64",algebraicType:v.Product({elements:[]})},{name:"I128",algebraicType:v.Product({elements:[]})},{name:"U128",algebraicType:v.Product({elements:[]})},{name:"I256",algebraicType:v.Product({elements:[]})},{name:"U256",algebraicType:v.Product({elements:[]})},{name:"F32",algebraicType:v.Product({elements:[]})},{name:"F64",algebraicType:v.Product({elements:[]})}]}),serialize(e,t){v.serializeValue(e,S.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,S.getTypeScriptAlgebraicType())},A={getAlgebraicType:()=>v.Sum({variants:[{name:"Interval",algebraicType:v.createTimeDurationType()},{name:"Time",algebraicType:v.createTimestampType()}]})},U=e=>({tag:"Interval",value:new t(e)}),_=e=>({tag:"Time",value:new r(e)}),z=A,v={...S,createOptionType:function(e){return S.Sum({variants:[{name:"some",algebraicType:e},{name:"none",algebraicType:S.Product({elements:[]})}]})},createIdentityType:function(){return m.getAlgebraicType()},createConnectionIdType:function(){return M.getAlgebraicType()},createScheduleAtType:function(){return z.getAlgebraicType()},createTimestampType:function(){return r.getAlgebraicType()},createTimeDurationType:function(){return t.getAlgebraicType()},serializeValue:function(e,t,r){switch(t.tag){case"Product":x.serializeValue(e,t.value,r);break;case"Sum":B.serializeValue(e,t.value,r);break;case"Array":if("U8"===t.value.tag)e.writeUInt8Array(r);else{const i=t.value;e.writeU32(r.length);for(const t of r)v.serializeValue(e,i,t)}break;case"Bool":e.writeBool(r);break;case"I8":e.writeI8(r);break;case"U8":e.writeU8(r);break;case"I16":e.writeI16(r);break;case"U16":e.writeU16(r);break;case"I32":e.writeI32(r);break;case"U32":e.writeU32(r);break;case"I64":e.writeI64(r);break;case"U64":e.writeU64(r);break;case"I128":e.writeI128(r);break;case"U128":e.writeU128(r);break;case"I256":e.writeI256(r);break;case"U256":e.writeU256(r);break;case"F32":e.writeF32(r);break;case"F64":e.writeF64(r);break;case"String":e.writeString(r);break;default:throw new Error(`not implemented, ${t.tag}`)}},deserializeValue:function(e,t){switch(t.tag){case"Product":return x.deserializeValue(e,t.value);case"Sum":return B.deserializeValue(e,t.value);case"Array":if("U8"===t.value.tag)return e.readUInt8Array();{const r=t.value,i=e.readU32(),a=[];for(let t=0;t<i;t++)a.push(v.deserializeValue(e,r));return a}case"Bool":return e.readBool();case"I8":return e.readI8();case"U8":return e.readU8();case"I16":return e.readI16();case"U16":return e.readU16();case"I32":return e.readI32();case"U32":return e.readU32();case"I64":return e.readI64();case"U64":return e.readU64();case"I128":return e.readI128();case"U128":return e.readU128();case"I256":return e.readI256();case"U256":return e.readU256();case"F32":return e.readF32();case"F64":return e.readF64();case"String":return e.readString();default:throw new Error(`not implemented, ${t.tag}`)}},intoMapKey:function(e,t){switch(e.tag){case"U8":case"U16":case"U32":case"U64":case"U128":case"U256":case"I8":case"I16":case"I64":case"I128":case"F32":case"F64":case"String":case"Bool":return t;case"Product":return x.intoMapKey(e.value,t);default:{const e=new i(10);return this.serialize(e,t),e.toBase64()}}}},x={...I,serializeValue(e,t,r){for(const i of t.elements)v.serializeValue(e,i.algebraicType,r[i.name])},deserializeValue(e,i){const a={};if(1===i.elements.length){if("__time_duration_micros__"===i.elements[0].name)return new t(e.readI64());if("__timestamp_micros_since_unix_epoch__"===i.elements[0].name)return new r(e.readI64());if("__identity__"===i.elements[0].name)return new m(e.readU256());if("__connection_id__"===i.elements[0].name)return new M(e.readU128())}for(const t of i.elements)a[t.name]=v.deserializeValue(e,t.algebraicType);return a},intoMapKey(e,t){if(1===e.elements.length){if("__time_duration_micros__"===e.elements[0].name)return t.__time_duration_micros__;if("__timestamp_micros_since_unix_epoch__"===e.elements[0].name)return t.__timestamp_micros_since_unix_epoch__;if("__identity__"===e.elements[0].name)return t.__identity__;if("__connection_id__"===e.elements[0].name)return t.__connection_id__}const r=new i(10);return v.serializeValue(r,v.Product(e),t),r.toBase64()}},B={...T,serializeValue:function(e,t,r){if(2==t.variants.length&&"some"===t.variants[0].name&&"none"===t.variants[1].name)null!=r?(e.writeByte(0),v.serializeValue(e,t.variants[0].algebraicType,r)):e.writeByte(1);else{const i=r.tag,a=t.variants.findIndex(e=>e.name===i);if(a<0)throw`Can't serialize a sum type, couldn't find ${r.tag} tag`;e.writeU8(a),v.serializeValue(e,t.variants[a].algebraicType,r.value)}},deserializeValue:function(e,t){const r=e.readU8();if(2==t.variants.length&&"some"===t.variants[0].name&&"none"===t.variants[1].name){if(0===r)return v.deserializeValue(e,t.variants[0].algebraicType);if(1===r)return;throw`Can't deserialize an option type, couldn't find ${r} tag`}{const i=t.variants[r],a=v.deserializeValue(e,i.algebraicType);return{tag:i.name,value:a}}}},M=class e{__connection_id__;constructor(e){this.__connection_id__=e}static getAlgebraicType(){return v.Product({elements:[{name:"__connection_id__",algebraicType:v.U128}]})}isZero(){return this.__connection_id__===BigInt(0)}static nullIfZero(e){return e.isZero()?null:e}static random(){function t(){return Math.floor(255*Math.random())}let r=BigInt(0);for(let e=0;e<16;e++)r=r<<BigInt(8)|BigInt(t());return new e(r)}isEqual(e){return this.__connection_id__==e.__connection_id__}toHexString(){return g(this.__connection_id__)}toUint8Array(){return y(this.__connection_id__)}static fromString(t){return new e(p(t))}static fromStringOrNull(t){const r=e.fromString(t);return r.isZero()?null:r}};function q(e,t){const r=new a(t);return e.deserialize(r)}var F={FixedSize:e=>({tag:"FixedSize",value:e}),RowOffsets:e=>({tag:"RowOffsets",value:e}),getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"FixedSize",algebraicType:v.U16},{name:"RowOffsets",algebraicType:v.Array(v.U64)}]}),serialize(e,t){v.serializeValue(e,F.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,F.getTypeScriptAlgebraicType())},P={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"sizeHint",algebraicType:F.getTypeScriptAlgebraicType()},{name:"rowsData",algebraicType:v.Array(v.U8)}]}),serialize(e,t){v.serializeValue(e,P.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,P.getTypeScriptAlgebraicType())},V={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"reducer",algebraicType:v.String},{name:"args",algebraicType:v.Array(v.U8)},{name:"requestId",algebraicType:v.U32},{name:"flags",algebraicType:v.U8}]}),serialize(e,t){v.serializeValue(e,V.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,V.getTypeScriptAlgebraicType())},O={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"queryStrings",algebraicType:v.Array(v.String)},{name:"requestId",algebraicType:v.U32}]}),serialize(e,t){v.serializeValue(e,O.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,O.getTypeScriptAlgebraicType())},C={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"messageId",algebraicType:v.Array(v.U8)},{name:"queryString",algebraicType:v.String}]}),serialize(e,t){v.serializeValue(e,C.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,C.getTypeScriptAlgebraicType())},E={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"id",algebraicType:v.U32}]}),serialize(e,t){v.serializeValue(e,E.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,E.getTypeScriptAlgebraicType())},k={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"query",algebraicType:v.String},{name:"requestId",algebraicType:v.U32},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,k.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,k.getTypeScriptAlgebraicType())},R={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"queryStrings",algebraicType:v.Array(v.String)},{name:"requestId",algebraicType:v.U32},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,R.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,R.getTypeScriptAlgebraicType())},K={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,K.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,K.getTypeScriptAlgebraicType())},D={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,D.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,D.getTypeScriptAlgebraicType())},N={CallReducer:e=>({tag:"CallReducer",value:e}),Subscribe:e=>({tag:"Subscribe",value:e}),OneOffQuery:e=>({tag:"OneOffQuery",value:e}),SubscribeSingle:e=>({tag:"SubscribeSingle",value:e}),SubscribeMulti:e=>({tag:"SubscribeMulti",value:e}),Unsubscribe:e=>({tag:"Unsubscribe",value:e}),UnsubscribeMulti:e=>({tag:"UnsubscribeMulti",value:e}),getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"CallReducer",algebraicType:V.getTypeScriptAlgebraicType()},{name:"Subscribe",algebraicType:O.getTypeScriptAlgebraicType()},{name:"OneOffQuery",algebraicType:C.getTypeScriptAlgebraicType()},{name:"SubscribeSingle",algebraicType:k.getTypeScriptAlgebraicType()},{name:"SubscribeMulti",algebraicType:R.getTypeScriptAlgebraicType()},{name:"Unsubscribe",algebraicType:K.getTypeScriptAlgebraicType()},{name:"UnsubscribeMulti",algebraicType:D.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,N.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,N.getTypeScriptAlgebraicType())},$={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"deletes",algebraicType:P.getTypeScriptAlgebraicType()},{name:"inserts",algebraicType:P.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,$.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,$.getTypeScriptAlgebraicType())},L={Uncompressed:e=>({tag:"Uncompressed",value:e}),Brotli:e=>({tag:"Brotli",value:e}),Gzip:e=>({tag:"Gzip",value:e}),getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"Uncompressed",algebraicType:$.getTypeScriptAlgebraicType()},{name:"Brotli",algebraicType:v.Array(v.U8)},{name:"Gzip",algebraicType:v.Array(v.U8)}]}),serialize(e,t){v.serializeValue(e,L.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,L.getTypeScriptAlgebraicType())},j={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"tableId",algebraicType:v.U32},{name:"tableName",algebraicType:v.String},{name:"numRows",algebraicType:v.U64},{name:"updates",algebraicType:v.Array(L.getTypeScriptAlgebraicType())}]}),serialize(e,t){v.serializeValue(e,j.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,j.getTypeScriptAlgebraicType())},H={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"tables",algebraicType:v.Array(j.getTypeScriptAlgebraicType())}]}),serialize(e,t){v.serializeValue(e,H.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,H.getTypeScriptAlgebraicType())},Q={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"databaseUpdate",algebraicType:H.getTypeScriptAlgebraicType()},{name:"requestId",algebraicType:v.U32},{name:"totalHostExecutionDuration",algebraicType:v.createTimeDurationType()}]}),serialize(e,t){v.serializeValue(e,Q.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,Q.getTypeScriptAlgebraicType())},W={Committed:e=>({tag:"Committed",value:e}),Failed:e=>({tag:"Failed",value:e}),OutOfEnergy:{tag:"OutOfEnergy"},getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"Committed",algebraicType:H.getTypeScriptAlgebraicType()},{name:"Failed",algebraicType:v.String},{name:"OutOfEnergy",algebraicType:v.Product({elements:[]})}]}),serialize(e,t){v.serializeValue(e,W.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,W.getTypeScriptAlgebraicType())},Z={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"reducerName",algebraicType:v.String},{name:"reducerId",algebraicType:v.U32},{name:"args",algebraicType:v.Array(v.U8)},{name:"requestId",algebraicType:v.U32}]}),serialize(e,t){v.serializeValue(e,Z.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,Z.getTypeScriptAlgebraicType())},G={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"quanta",algebraicType:v.U128}]}),serialize(e,t){v.serializeValue(e,G.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,G.getTypeScriptAlgebraicType())},X={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"status",algebraicType:W.getTypeScriptAlgebraicType()},{name:"timestamp",algebraicType:v.createTimestampType()},{name:"callerIdentity",algebraicType:v.createIdentityType()},{name:"callerConnectionId",algebraicType:v.createConnectionIdType()},{name:"reducerCall",algebraicType:Z.getTypeScriptAlgebraicType()},{name:"energyQuantaUsed",algebraicType:G.getTypeScriptAlgebraicType()},{name:"totalHostExecutionDuration",algebraicType:v.createTimeDurationType()}]}),serialize(e,t){v.serializeValue(e,X.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,X.getTypeScriptAlgebraicType())},J={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"update",algebraicType:H.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,J.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,J.getTypeScriptAlgebraicType())},Y={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"identity",algebraicType:v.createIdentityType()},{name:"token",algebraicType:v.String},{name:"connectionId",algebraicType:v.createConnectionIdType()}]}),serialize(e,t){v.serializeValue(e,Y.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,Y.getTypeScriptAlgebraicType())},ee={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"tableName",algebraicType:v.String},{name:"rows",algebraicType:P.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,ee.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,ee.getTypeScriptAlgebraicType())},te={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"messageId",algebraicType:v.Array(v.U8)},{name:"error",algebraicType:v.createOptionType(v.String)},{name:"tables",algebraicType:v.Array(ee.getTypeScriptAlgebraicType())},{name:"totalHostExecutionDuration",algebraicType:v.createTimeDurationType()}]}),serialize(e,t){v.serializeValue(e,te.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,te.getTypeScriptAlgebraicType())},re={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"tableId",algebraicType:v.U32},{name:"tableName",algebraicType:v.String},{name:"tableRows",algebraicType:j.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,re.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,re.getTypeScriptAlgebraicType())},ie={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"totalHostExecutionDurationMicros",algebraicType:v.U64},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()},{name:"rows",algebraicType:re.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,ie.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,ie.getTypeScriptAlgebraicType())},ae={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"totalHostExecutionDurationMicros",algebraicType:v.U64},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()},{name:"rows",algebraicType:re.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,ae.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,ae.getTypeScriptAlgebraicType())},se={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"totalHostExecutionDurationMicros",algebraicType:v.U64},{name:"requestId",algebraicType:v.createOptionType(v.U32)},{name:"queryId",algebraicType:v.createOptionType(v.U32)},{name:"tableId",algebraicType:v.createOptionType(v.U32)},{name:"error",algebraicType:v.String}]}),serialize(e,t){v.serializeValue(e,se.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,se.getTypeScriptAlgebraicType())},ne={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"totalHostExecutionDurationMicros",algebraicType:v.U64},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()},{name:"update",algebraicType:H.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,ne.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,ne.getTypeScriptAlgebraicType())},ce={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"totalHostExecutionDurationMicros",algebraicType:v.U64},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()},{name:"update",algebraicType:H.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,ce.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,ce.getTypeScriptAlgebraicType())},oe={InitialSubscription:e=>({tag:"InitialSubscription",value:e}),TransactionUpdate:e=>({tag:"TransactionUpdate",value:e}),TransactionUpdateLight:e=>({tag:"TransactionUpdateLight",value:e}),IdentityToken:e=>({tag:"IdentityToken",value:e}),OneOffQueryResponse:e=>({tag:"OneOffQueryResponse",value:e}),SubscribeApplied:e=>({tag:"SubscribeApplied",value:e}),UnsubscribeApplied:e=>({tag:"UnsubscribeApplied",value:e}),SubscriptionError:e=>({tag:"SubscriptionError",value:e}),SubscribeMultiApplied:e=>({tag:"SubscribeMultiApplied",value:e}),UnsubscribeMultiApplied:e=>({tag:"UnsubscribeMultiApplied",value:e}),getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"InitialSubscription",algebraicType:Q.getTypeScriptAlgebraicType()},{name:"TransactionUpdate",algebraicType:X.getTypeScriptAlgebraicType()},{name:"TransactionUpdateLight",algebraicType:J.getTypeScriptAlgebraicType()},{name:"IdentityToken",algebraicType:Y.getTypeScriptAlgebraicType()},{name:"OneOffQueryResponse",algebraicType:te.getTypeScriptAlgebraicType()},{name:"SubscribeApplied",algebraicType:ie.getTypeScriptAlgebraicType()},{name:"UnsubscribeApplied",algebraicType:ae.getTypeScriptAlgebraicType()},{name:"SubscriptionError",algebraicType:se.getTypeScriptAlgebraicType()},{name:"SubscribeMultiApplied",algebraicType:ne.getTypeScriptAlgebraicType()},{name:"UnsubscribeMultiApplied",algebraicType:ce.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,oe.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,oe.getTypeScriptAlgebraicType())},le=class{#a=new Map;on(e,t){let r=this.#a.get(e);r||(r=new Set,this.#a.set(e,r)),r.add(t)}off(e,t){const r=this.#a.get(e);r&&r.delete(t)}emit(e,...t){const r=this.#a.get(e);if(r)for(const e of r)e(...t)}},ue={component:"đŸ“Ļ",info:"â„šī¸",warn:"âš ī¸",error:"❌",debug:"🐛"},pe={component:"color: #fff; background-color: #8D6FDD; padding: 2px 5px; border-radius: 3px;",info:"color: #fff; background-color: #007bff; padding: 2px 5px; border-radius: 3px;",warn:"color: #fff; background-color: #ffc107; padding: 2px 5px; border-radius: 3px;",error:"color: #fff; background-color: #dc3545; padding: 2px 5px; border-radius: 3px;",debug:"color: #fff; background-color: #28a745; padding: 2px 5px; border-radius: 3px;"},de={component:"color: #8D6FDD;",info:"color: #007bff;",warn:"color: #ffc107;",error:"color: #dc3545;",debug:"color: #28a745;"},ye=(e,t)=>{console.log(`%c${ue[e]} ${e.toUpperCase()}%c ${t}`,pe[e],de[e])},ge=class{rows;tableTypeInfo;emitter;constructor(e){this.tableTypeInfo=e,this.rows=new Map,this.emitter=new le}count(){return this.rows.size}iter(){return Array.from(this.rows.values()).map(([e])=>e)}applyOperations=(e,t)=>{const r=[];if(void 0!==this.tableTypeInfo.primaryKeyInfo){const i=new Map,a=new Map;for(const t of e)if("insert"===t.type){const[e,r]=i.get(t.rowId)||[t,0];i.set(t.rowId,[t,r+1])}else{const[e,r]=a.get(t.rowId)||[t,0];a.set(t.rowId,[t,r+1])}for(const[e,[s,n]]of i){const i=a.get(e);if(i){const[c,o]=i,l=n-o,u=this.update(t,e,s.row,l);u&&r.push(u),a.delete(e)}else{const e=this.insert(t,s,n);e&&r.push(e)}}for(const[e,i]of a.values()){const a=this.delete(t,e,i);a&&r.push(a)}}else for(const i of e)if("insert"===i.type){const e=this.insert(t,i);e&&r.push(e)}else{const e=this.delete(t,i);e&&r.push(e)}return r};update=(e,t,r,i=0)=>{const a=this.rows.get(t);if(!a)return void ye("error",`Updating a row that was not present in the cache. Table: ${this.tableTypeInfo.tableName}, RowId: ${t}`);const[s,n]=a,c=Math.max(1,n+i);if(!(n+i<=0))return this.rows.set(t,[r,c]),0===n?(ye("error",`Updating a row id in table ${this.tableTypeInfo.tableName} which was not present in the cache (rowId: ${t})`),{type:"insert",table:this.tableTypeInfo.tableName,cb:()=>{this.emitter.emit("insert",e,r)}}):{type:"update",table:this.tableTypeInfo.tableName,cb:()=>{this.emitter.emit("update",e,s,r)}};ye("error",`Negative reference count for in table ${this.tableTypeInfo.tableName} row ${t} (${n} + ${i})`)};insert=(e,t,r=1)=>{const[i,a]=this.rows.get(t.rowId)||[t.row,0];if(this.rows.set(t.rowId,[t.row,a+r]),0===a)return{type:"insert",table:this.tableTypeInfo.tableName,cb:()=>{this.emitter.emit("insert",e,t.row)}}};delete=(e,t,r=1)=>{const[i,a]=this.rows.get(t.rowId)||[t.row,0];if(0!==a)return a<=r?(this.rows.delete(t.rowId),{type:"delete",table:this.tableTypeInfo.tableName,cb:()=>{this.emitter.emit("delete",e,t.row)}}):void this.rows.set(t.rowId,[t.row,a-r]);ye("warn","Deleting a row that was not present in the cache")};onInsert=e=>{this.emitter.on("insert",e)};onDelete=e=>{this.emitter.on("delete",e)};onUpdate=e=>{this.emitter.on("update",e)};removeOnInsert=e=>{this.emitter.off("insert",e)};removeOnDelete=e=>{this.emitter.off("delete",e)};removeOnUpdate=e=>{this.emitter.off("update",e)}},he=class{tables;constructor(){this.tables=new Map}getTable(e){const t=this.tables.get(e);if(!t)throw console.error("The table has not been registered for this client. Please register the table before using it. If you have registered global tables using the SpacetimeDBClient.registerTables() or `registerTable()` method, please make sure that is executed first!"),new Error(`Table ${e} does not exist`);return t}getOrCreateTable(e){let t;return this.tables.has(e.tableName)?t=this.tables.get(e.tableName):(t=new ge(e),this.tables.set(e.tableName,t)),t}};var be=class e{major;minor;patch;preRelease;buildInfo;constructor(e,t,r,i=null,a=null){this.major=e,this.minor=t,this.patch=r,this.preRelease=i,this.buildInfo=a}toString(){let e=`${this.major}.${this.minor}.${this.patch}`;return this.preRelease&&(e+=`-${this.preRelease.join(".")}`),this.buildInfo&&(e+=`+${this.buildInfo}`),e}compare(e){return this.major!==e.major?this.major-e.major:this.minor!==e.minor?this.minor-e.minor:this.patch!==e.patch?this.patch-e.patch:this.preRelease&&e.preRelease?function(e,t){const r=Math.min(e.length,t.length);for(let i=0;i<r;i++){const r=e[i],a=t[i];if(r!==a)return"number"==typeof r&&"number"==typeof a?r-a:"string"==typeof r&&"string"==typeof a?r.localeCompare(a):"string"==typeof r?1:-1}return e.length-t.length}(this.preRelease,e.preRelease):this.preRelease||e.preRelease?-1:0}clone(){return new e(this.major,this.minor,this.patch,this.preRelease?[...this.preRelease]:null,this.buildInfo)}static parseVersionString(t){const r=t.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*))?(?:\+([\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*))?$/);if(!r)throw new Error(`Invalid version string: ${t}`);const i=parseInt(r[1],10),a=parseInt(r[2],10),s=parseInt(r[3],10),n=r[4]?r[4].split(".").map(e=>isNaN(Number(e))?e:Number(e)):null,c=r[5]||null;return new e(i,a,s,n,c)}},me=new be(1,4,0);function fe(e){return`Module code was generated with an incompatible version of the spacetimedb cli (${e}). Update the cli version to at least ${me.toString()} and regenerate the bindings. You can upgrade to the latest cli version by running: spacetime version upgrade`}async function Te(e,t,r=131072){let i=0;const a=new ReadableStream({pull(t){if(i<e.length){const a=e.subarray(i,Math.min(i+r,e.length));t.enqueue(a),i+=r}else t.close()}}),s=new DecompressionStream(t),n=a.pipeThrough(s).getReader(),c=[];let o,l=0;for(;!(o=await n.read()).done;)c.push(o.value),l+=o.value.length;const u=new Uint8Array(l);let p=0;for(const e of c)u.set(e,p),p+=e.length;return u}var we=class e{onclose;onopen;onmessage;onerror;#s;async#n(e){const t=new Uint8Array(e.data);let r;if(0===t[0])r=t.slice(1);else{if(1===t[0])throw new Error("Brotli Compression not supported. Please use gzip or none compression in withCompression method on DbConnection.");if(2!==t[0])throw new Error("Unexpected Compression Algorithm. Please use `gzip` or `none`");r=await Te(t.slice(1),"gzip")}this.onmessage?.({data:r})}#c(e){this.onopen?.(e)}#o(e){this.onerror?.(e)}#l(e){this.onclose?.(e)}send(e){this.#s.send(e)}close(){this.#s.close()}constructor(e){this.onmessage=void 0,this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,e.onmessage=this.#n.bind(this),e.onerror=this.#o.bind(this),e.onclose=this.#l.bind(this),e.onopen=this.#c.bind(this),e.binaryType="arraybuffer",this.#s=e}static async createWebSocketFn({url:t,nameOrAddress:r,wsProtocol:i,authToken:a,compression:s,lightMode:n}){const c=new Headers;let o,l;if(o=WebSocket,a){c.set("Authorization",`Bearer ${a}`);const e=new URL("v1/identity/websocket-token",t);e.protocol="wss:"===t.protocol?"https:":"http:";const r=await fetch(e,{method:"POST",headers:c});if(!r.ok)return Promise.reject(new Error(`Failed to verify token: ${r.statusText}`));{const{token:e}=await r.json();l=e}}const u=new URL(`v1/database/${r}/subscribe`,t);l&&u.searchParams.set("token",l),u.searchParams.set("compression","gzip"===s?"Gzip":"None"),n&&u.searchParams.set("light","true");const p=new o(u.toString(),i);return new e(p)}},Ie=class{constructor(e,t){this.remoteModule=e,this.dbConnectionConstructor=t,this.#u=we.createWebSocketFn}#p;#d;#y;#g;#h=new le;#b="gzip";#m=!1;#u;withUri(e){return this.#p=new URL(e),this}withModuleName(e){return this.#d=e,this}withToken(e){return this.#g=e,this}withWSFn(e){return this.#u=e,this}withCompression(e){return this.#b=e,this}withLightMode(e){return this.#m=e,this}onConnect(e){return this.#h.on("connect",e),this}onConnectError(e){return this.#h.on("connectError",e),this}onDisconnect(e){return this.#h.on("disconnect",e),this}build(){if(!this.#p)throw new Error("URI is required to connect to SpacetimeDB");if(!this.#d)throw new Error("Database name or address is required to connect to SpacetimeDB");return function(e){if(void 0===e)throw new Error(fe(e));if(be.parseVersionString(e).compare(me)<0)throw new Error(fe(e))}(this.remoteModule.versionInfo?.cliVersion),this.dbConnectionConstructor(new ze({uri:this.#p,nameOrAddress:this.#d,identity:this.#y,token:this.#g,emitter:this.#h,compression:this.#b,lightMode:this.#m,createWSFn:this.#u,remoteModule:this.remoteModule}))}},Se=class{constructor(e){this.db=e}#f=void 0;#T=void 0;onApplied(e){return this.#f=e,this}onError(e){return this.#T=e,this}subscribe(e){const t=Array.isArray(e)?e:[e];if(0===t.length)throw new Error("Subscriptions must have at least one query");return new Ue(this.db,t,this.#f,this.#T)}subscribeToAllTables(){this.subscribe("SELECT * FROM *")}},Ae=class{subscriptions=new Map},Ue=class{constructor(e,t,r,i){this.db=e,this.#h.on("applied",e=>{this.#w=!0,r&&r(e)}),this.#h.on("error",(e,t)=>{this.#w=!1,this.#I=!0,i&&i(e,t)}),this.#S=this.db.registerSubscription(this,this.#h,t)}#S;#A=!1;#I=!1;#w=!1;#h=new le;unsubscribe(){if(this.#A)throw new Error("Unsubscribe has already been called");this.#A=!0,this.db.unregisterSubscription(this.#S),this.#h.on("end",e=>{this.#I=!0,this.#w=!1})}unsubscribeThen(e){if(this.#I)throw new Error("Subscription has already ended");if(this.#A)throw new Error("Unsubscribe has already been called");this.#A=!0,this.db.unregisterSubscription(this.#S),this.#h.on("end",t=>{this.#I=!0,this.#w=!1,e(t)})}isEnded(){return this.#I}isActive(){return this.#w}};function _e(e){switch(e){case"FullUpdate":return 0;case"NoSuccessNotify":return 1}}var ze=class{isActive=!1;identity=void 0;token=void 0;db;reducers;setReducerFlags;connectionId=M.random();#S=0;#h;#U=new le;#f;#_;#z=Promise.resolve();#v=new Ae;clientCache;ws;wsPromise;constructor({uri:e,nameOrAddress:t,identity:r,token:i,emitter:a,remoteModule:s,createWSFn:n,compression:c,lightMode:o}){ye("info","Connecting to SpacetimeDB WS...");const l=new URL(e.toString());/^wss?:/.test(e.protocol)||(l.protocol="https:"===l.protocol?"wss:":"ws:"),this.identity=r,this.token=i,this.#_=s,this.#h=a;const u=this.connectionId.toHexString();l.searchParams.set("connection_id",u),this.clientCache=new he,this.db=this.#_.dbViewConstructor(this),this.setReducerFlags=this.#_.setReducerFlagsConstructor(),this.reducers=this.#_.reducersConstructor(this,this.setReducerFlags),this.wsPromise=n({url:l,nameOrAddress:t,wsProtocol:"v1.bsatn.spacetimedb",authToken:i,compression:c,lightMode:o}).then(e=>(this.ws=e,this.ws.onclose=()=>{this.#h.emit("disconnect",this)},this.ws.onerror=e=>{this.#h.emit("connectError",this,e)},this.ws.onopen=this.#c.bind(this),this.ws.onmessage=this.#n.bind(this),e)).catch(e=>{ye("error","Error connecting to SpacetimeDB WS"),this.#h.emit("connectError",this,e)})}#x=()=>{const e=this.#S;return this.#S+=1,e};subscriptionBuilder=()=>new Se(this);registerSubscription(e,t,r){const i=this.#x();return this.#v.subscriptions.set(i,{handle:e,emitter:t}),this.#B(N.SubscribeMulti({queryStrings:r,queryId:{id:i},requestId:0})),i}unregisterSubscription(e){this.#B(N.UnsubscribeMulti({queryId:{id:e},requestId:0}))}async#M(t){const r=(t,r,i)=>{const s=i.rowsData,n=new a(s),c=[],o=this.#_.tables[r].rowType,l=this.#_.tables[r].primaryKeyInfo;for(;n.offset<s.length+s.byteOffset;){const r=n.offset,i=v.deserializeValue(n,o);let a;if(void 0!==l)a=v.intoMapKey(l.colType,i[l.colName]);else{const t=s.subarray(r-s.byteOffset,n.offset-s.byteOffset);a=e(t)}c.push({type:t,rowId:a,row:i})}return c},i=async e=>{const t=e.tableName;let i=[];for(const s of e.updates){let e;if("Gzip"===s.tag){const t=await Te(s.value,"gzip");e=$.deserialize(new a(t))}else{if("Brotli"===s.tag)throw new Error("Brotli compression not supported. Please use gzip or none compression in withCompression method on DbConnection.");e=s.value}i=i.concat(r("insert",t,e.inserts)),i=i.concat(r("delete",t,e.deletes))}return{tableName:t,operations:i}},s=async e=>{const t=[];for(const r of e.tables)t.push(await i(r));return t};switch(t.tag){case"InitialSubscription":{const e=t.value.databaseUpdate;return{tag:"InitialSubscription",tableUpdates:await s(e)}}case"TransactionUpdateLight":{const e=t.value.update;return{tag:"TransactionUpdateLight",tableUpdates:await s(e)}}case"TransactionUpdate":{const e=t.value,r=e.callerIdentity,i=M.nullIfZero(e.callerConnectionId),a=e.reducerCall.reducerName,n=e.reducerCall.args,c=e.energyQuantaUsed;let o,l=[],u="";switch(e.status.tag){case"Committed":l=await s(e.status.value);break;case"Failed":l=[],u=e.status.value;break;case"OutOfEnergy":l=[]}if("<none>"===a){const e=u;return void console.error(`Received an error from the database: ${e}`)}""!==a&&(o={reducerName:a,args:n});return{tag:"TransactionUpdate",tableUpdates:l,identity:r,connectionId:i,reducerInfo:o,status:e.status,energyConsumed:c.quanta,message:u,timestamp:e.timestamp}}case"IdentityToken":return{tag:"IdentityToken",identity:t.value.identity,token:t.value.token,connectionId:t.value.connectionId};case"OneOffQueryResponse":throw new Error(`TypeScript SDK never sends one-off queries, but got OneOffQueryResponse ${t}`);case"SubscribeMultiApplied":{const e=await s(t.value.update);return{tag:"SubscribeApplied",queryId:t.value.queryId.id,tableUpdates:e}}case"UnsubscribeMultiApplied":{const e=await s(t.value.update);return{tag:"UnsubscribeApplied",queryId:t.value.queryId.id,tableUpdates:e}}case"SubscriptionError":return{tag:"SubscriptionError",queryId:t.value.queryId,error:t.value.error}}}#B(e){this.wsPromise.then(t=>{if(t){const r=new i(1024);N.serialize(r,e);const a=r.getBuffer();t.send(a)}})}#c(){this.isActive=!0}#q(e,t){const r=[];for(const i of e){const e=i.tableName,a=this.#_.tables[e],s=this.clientCache.getOrCreateTable(a).applyOperations(i.operations,t);for(const e of s)r.push(e)}return r}async#F(e){const t=q(oe,e),r=await this.#M(t);if(r)switch(r.tag){case"InitialSubscription":{const e={tag:"SubscribeApplied"},t=this.#_.eventContextConstructor(this,e),{event:i,...a}=t,s=this.#q(r.tableUpdates,t);this.#h&&this.#f?.(a);for(const e of s)e.cb();break}case"TransactionUpdateLight":{const e={tag:"UnknownTransaction"},t=this.#_.eventContextConstructor(this,e),i=this.#q(r.tableUpdates,t);for(const e of i)e.cb();break}case"TransactionUpdate":{let e,t,i=r.reducerInfo,s=!1;if(i){t=this.#_.reducers[i.reducerName];try{const r=new a(i.args);e=v.deserializeValue(r,t.argsType)}catch{console.debug("Failed to deserialize reducer arguments"),s=!0}}else s=!0;if(s){const e={tag:"UnknownTransaction"},t=this.#_.eventContextConstructor(this,e),i=this.#q(r.tableUpdates,t);for(const e of i)e.cb();return}const n={callerIdentity:r.identity,status:r.status,callerConnectionId:r.connectionId,timestamp:r.timestamp,energyConsumed:r.energyConsumed,reducer:{name:i.reducerName,args:e}},c={tag:"Reducer",value:n},o=this.#_.eventContextConstructor(this,c),l={...o,event:n},u=this.#q(r.tableUpdates,o),p=[];t.argsType.value.elements.forEach(t=>{p.push(e[t.name])}),this.#U.emit(i.reducerName,l,...p);for(const e of u)e.cb();break}case"IdentityToken":this.identity=r.identity,!this.token&&r.token&&(this.token=r.token),this.connectionId=r.connectionId,this.#h.emit("connect",this,this.identity,this.token);break;case"SubscribeApplied":{const e=this.#v.subscriptions.get(r.queryId);if(void 0===e){ye("error",`Received SubscribeApplied for unknown queryId ${r.queryId}.`);break}const t={tag:"SubscribeApplied"},i=this.#_.eventContextConstructor(this,t),{event:a,...s}=i,n=this.#q(r.tableUpdates,i);e?.emitter.emit("applied",s);for(const e of n)e.cb();break}case"UnsubscribeApplied":{const e=this.#v.subscriptions.get(r.queryId);if(void 0===e){ye("error",`Received UnsubscribeApplied for unknown queryId ${r.queryId}.`);break}const t={tag:"UnsubscribeApplied"},i=this.#_.eventContextConstructor(this,t),{event:a,...s}=i,n=this.#q(r.tableUpdates,i);e?.emitter.emit("end",s),this.#v.subscriptions.delete(r.queryId);for(const e of n)e.cb();break}case"SubscriptionError":{const e=Error(r.error),t={tag:"Error",value:e},i={...this.#_.eventContextConstructor(this,t),event:e};void 0!==r.queryId?(this.#v.subscriptions.get(r.queryId)?.emitter.emit("error",i,e),this.#v.subscriptions.delete(r.queryId)):(console.error("Received an error message without a queryId: ",e),this.#v.subscriptions.forEach(({emitter:t})=>{t.emit("error",i,e)}))}}}#n(e){this.#z=this.#z.then(()=>this.#F(e.data))}callReducer(e,t,r){const i=N.CallReducer({reducer:e,args:t,requestId:0,flags:_e(r)});this.#B(i)}disconnect(){this.wsPromise.then(e=>{e&&e.close()})}on(e,t){this.#h.on(e,t)}off(e,t){this.#h.off(e,t)}onConnect(e){this.#h.on("connect",e)}onDisconnect(e){this.#h.on("disconnect",e)}onConnectError(e){this.#h.on("connectError",e)}removeOnConnect(e){this.#h.off("connect",e)}removeOnDisconnect(e){this.#h.off("disconnect",e)}removeOnConnectError(e){this.#h.off("connectError",e)}onReducer(e,t){this.#U.on(e,t)}offReducer(e,t){this.#U.off(e,t)}},ve=class{type;spacetimeType;algebraicType;constructor(e){this.algebraicType=e}},xe=class extends ve{constructor(){super(v.U8)}index(e){return new Ze(this,{...Qe,indexType:e})}unique(){return new Ze(this,{...Qe,isUnique:!0})}primaryKey(){return new Ze(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new Ze(this,{...Qe,isAutoIncrement:!0})}},Be=class extends ve{constructor(){super(v.U16)}index(e){return new Ge(this,{...Qe,indexType:e})}unique(){return new Ge(this,{...Qe,isUnique:!0})}primaryKey(){return new Ge(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new Ge(this,{...Qe,isAutoIncrement:!0})}},Me=class extends ve{constructor(){super(v.U32)}index(e){return new Xe(this,{...Qe,indexType:e})}unique(){return new Xe(this,{...Qe,isUnique:!0})}primaryKey(){return new Xe(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new Xe(this,{...Qe,isAutoIncrement:!0})}},qe=class extends ve{constructor(){super(v.U64)}index(e){return new Je(this,{...Qe,indexType:e})}unique(){return new Je(this,{...Qe,isUnique:!0})}primaryKey(){return new Je(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new Je(this,{...Qe,isAutoIncrement:!0})}},Fe=class extends ve{constructor(){super(v.U128)}index(e){return new Ye(this,{...Qe,indexType:e})}unique(){return new Ye(this,{...Qe,isUnique:!0})}primaryKey(){return new Ye(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new Ye(this,{...Qe,isAutoIncrement:!0})}},Pe=class extends ve{constructor(){super(v.U256)}index(e){return new et(this,{...Qe,indexType:e})}unique(){return new et(this,{...Qe,isUnique:!0})}primaryKey(){return new et(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new et(this,{...Qe,isAutoIncrement:!0})}},Ve=class extends ve{constructor(){super(v.I8)}index(e){return new tt(this,{...Qe,indexType:e})}unique(){return new tt(this,{...Qe,isUnique:!0})}primaryKey(){return new tt(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new tt(this,{...Qe,isAutoIncrement:!0})}},Oe=class extends ve{constructor(){super(v.I16)}index(e){return new rt(this,{...Qe,indexType:e})}unique(){return new rt(this,{...Qe,isUnique:!0})}primaryKey(){return new rt(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new rt(this,{...Qe,isAutoIncrement:!0})}},Ce=class extends ve{constructor(){super(v.I32)}index(e){return new it(this,{...Qe,indexType:e})}unique(){return new it(this,{...Qe,isUnique:!0})}primaryKey(){return new it(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new it(this,{...Qe,isAutoIncrement:!0})}},Ee=class extends ve{constructor(){super(v.I64)}index(e){return new at(this,{...Qe,indexType:e})}unique(){return new at(this,{...Qe,isUnique:!0})}primaryKey(){return new at(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new at(this,{...Qe,isAutoIncrement:!0})}},ke=class extends ve{constructor(){super(v.I128)}index(e){return new st(this,{...Qe,indexType:e})}unique(){return new st(this,{...Qe,isUnique:!0})}primaryKey(){return new st(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new st(this,{...Qe,isAutoIncrement:!0})}},Re=class extends ve{constructor(){super(v.I256)}index(e){return new nt(this,{...Qe,indexType:e})}unique(){return new nt(this,{...Qe,isUnique:!0})}primaryKey(){return new nt(this,{...Qe,isPrimaryKey:!0})}autoInc(){return new nt(this,{...Qe,isAutoIncrement:!0})}},Ke=class extends ve{constructor(){super(v.F32)}},De=class extends ve{constructor(){super(v.F64)}},Ne=class extends ve{constructor(){super(v.Bool)}index(e){return new ct(this,{...Qe,indexType:e})}unique(){return new ct(this,{...Qe,isUnique:!0})}primaryKey(){return new ct(this,{...Qe,isPrimaryKey:!0})}},$e=class extends ve{constructor(){super(v.String)}index(e){return new ot(this,{...Qe,indexType:e})}unique(){return new ot(this,{...Qe,isUnique:!0})}primaryKey(){return new ot(this,{...Qe,isPrimaryKey:!0})}},Le=class extends ve{element;constructor(e){super(v.Array(e.algebraicType))}},je=class extends ve{elements;constructor(e){var t;super(v.Product({elements:(t=e,Object.entries(t).map(([e,{algebraicType:t}])=>({name:e,algebraicType:t})))}))}},He=class extends ve{variants;constructor(e){var t;super(v.Sum({variants:(t=e,Object.entries(t).map(([e,{algebraicType:t}])=>({name:e,algebraicType:t})))}))}},Qe={},We=class{columnMetadataType;typeBuilder;columnMetadata;constructor(e,t){this.typeBuilder=e,this.columnMetadata=t??Qe}},Ze=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},Ge=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},Xe=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},Je=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},Ye=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},et=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},tt=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},rt=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},it=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},at=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},st=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},nt=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},ct=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}},ot=class e extends We{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}},lt={bool:()=>new Ne,string:()=>new $e,number:()=>new De,i8:()=>new Ve,u8:()=>new xe,i16:()=>new Oe,u16:()=>new Be,i32:()=>new Ce,u32:()=>new Me,i64:()=>new Ee,u64:()=>new qe,i128:()=>new ke,u128:()=>new Fe,i256:()=>new Re,u256:()=>new Pe,f32:()=>new Ke,f64:()=>new De,object:e=>new je(e),array:e=>new Le(e),enum:e=>new He(e),scheduleAt:()=>new We(new ve(A.getAlgebraicType()),{...Qe,isScheduleAt:!0}),identity:()=>new ve(m.getAlgebraicType()),connectionId:()=>new ve(M.getAlgebraicType()),timestamp:()=>new ve(r.getAlgebraicType()),timeDuration:()=>new ve(t.getAlgebraicType())};export{v as AlgebraicType,a as BinaryReader,i as BinaryWriter,he as ClientCache,M as ConnectionId,Ie as DbConnectionBuilder,ze as DbConnectionImpl,m as Identity,U as Interval,x as ProductType,w as ProductTypeElement,A as ScheduleAt,Se as SubscriptionBuilderImpl,B as SumType,f as SumTypeVariant,ge as TableCache,_ as Time,t as TimeDuration,r as Timestamp,n as deepEqual,p as hexStringToU128,d as hexStringToU256,u as hexStringToUint8Array,q as parseValue,lt as t,s as toPascalCase,g as u128ToHexString,y as u128ToUint8Array,b as u256ToHexString,h as u256ToUint8Array,c as uint8ArrayToHexString,o as uint8ArrayToU128,l as uint8ArrayToU256};//# sourceMappingURL=index.browser.mjs.map
1
+ import{fromByteArray as e}from"base64-js";var t=class e{__time_duration_micros__;static MICROS_PER_MILLIS=1000n;static getAlgebraicType(){return v.Product({elements:[{name:"__time_duration_micros__",algebraicType:v.I64}]})}get micros(){return this.__time_duration_micros__}get millis(){return Number(this.micros/e.MICROS_PER_MILLIS)}constructor(e){this.__time_duration_micros__=e}static fromMillis(t){return new e(BigInt(t)*e.MICROS_PER_MILLIS)}},r=class e{__timestamp_micros_since_unix_epoch__;static MICROS_PER_MILLIS=1000n;get microsSinceUnixEpoch(){return this.__timestamp_micros_since_unix_epoch__}constructor(e){this.__timestamp_micros_since_unix_epoch__=e}static getAlgebraicType(){return v.Product({elements:[{name:"__timestamp_micros_since_unix_epoch__",algebraicType:v.I64}]})}static UNIX_EPOCH=new e(0n);static now(){return e.fromDate(new Date)}static fromDate(t){const r=t.getTime(),i=BigInt(r)*e.MICROS_PER_MILLIS;return new e(i)}toDate(){const t=this.__timestamp_micros_since_unix_epoch__/e.MICROS_PER_MILLIS;if(t>BigInt(Number.MAX_SAFE_INTEGER)||t<BigInt(Number.MIN_SAFE_INTEGER))throw new RangeError("Timestamp is outside of the representable range of JS's Date");return new Date(Number(t))}},i=class{#e;#t;#r=0;constructor(e){this.#e=new Uint8Array(e),this.#t=new DataView(this.#e.buffer)}#i(e){const t=this.#r+e+1;if(t<=this.#e.length)return;let r=2*this.#e.length;r<t&&(r=t);const i=new Uint8Array(r);i.set(this.#e),this.#e=i,this.#t=new DataView(this.#e.buffer)}toBase64(){return e(this.#e.subarray(0,this.#r))}getBuffer(){return this.#e.slice(0,this.#r)}writeUInt8Array(e){const t=e.length;this.#i(4+t),this.writeU32(t),this.#e.set(e,this.#r),this.#r+=e.length}writeBool(e){this.#i(1),this.#t.setUint8(this.#r,e?1:0),this.#r+=1}writeByte(e){this.#i(1),this.#t.setUint8(this.#r,e),this.#r+=1}writeI8(e){this.#i(1),this.#t.setInt8(this.#r,e),this.#r+=1}writeU8(e){this.#i(1),this.#t.setUint8(this.#r,e),this.#r+=1}writeI16(e){this.#i(2),this.#t.setInt16(this.#r,e,!0),this.#r+=2}writeU16(e){this.#i(2),this.#t.setUint16(this.#r,e,!0),this.#r+=2}writeI32(e){this.#i(4),this.#t.setInt32(this.#r,e,!0),this.#r+=4}writeU32(e){this.#i(4),this.#t.setUint32(this.#r,e,!0),this.#r+=4}writeI64(e){this.#i(8),this.#t.setBigInt64(this.#r,e,!0),this.#r+=8}writeU64(e){this.#i(8),this.#t.setBigUint64(this.#r,e,!0),this.#r+=8}writeU128(e){this.#i(16);const t=e&BigInt("0xFFFFFFFFFFFFFFFF"),r=e>>BigInt(64);this.#t.setBigUint64(this.#r,t,!0),this.#t.setBigUint64(this.#r+8,r,!0),this.#r+=16}writeI128(e){this.#i(16);const t=e&BigInt("0xFFFFFFFFFFFFFFFF"),r=e>>BigInt(64);this.#t.setBigInt64(this.#r,t,!0),this.#t.setBigInt64(this.#r+8,r,!0),this.#r+=16}writeU256(e){this.#i(32);const t=BigInt("0xFFFFFFFFFFFFFFFF"),r=e&t,i=e>>BigInt(64)&t,a=e>>BigInt(128)&t,s=e>>BigInt(192);this.#t.setBigUint64(this.#r+0,r,!0),this.#t.setBigUint64(this.#r+8,i,!0),this.#t.setBigUint64(this.#r+16,a,!0),this.#t.setBigUint64(this.#r+24,s,!0),this.#r+=32}writeI256(e){this.#i(32);const t=BigInt("0xFFFFFFFFFFFFFFFF"),r=e&t,i=e>>BigInt(64)&t,a=e>>BigInt(128)&t,s=e>>BigInt(192);this.#t.setBigUint64(this.#r+0,r,!0),this.#t.setBigUint64(this.#r+8,i,!0),this.#t.setBigUint64(this.#r+16,a,!0),this.#t.setBigInt64(this.#r+24,s,!0),this.#r+=32}writeF32(e){this.#i(4),this.#t.setFloat32(this.#r,e,!0),this.#r+=4}writeF64(e){this.#i(8),this.#t.setFloat64(this.#r,e,!0),this.#r+=8}writeString(e){const t=(new TextEncoder).encode(e);this.writeU32(t.length),this.#i(t.length),this.#e.set(t,this.#r),this.#r+=t.length}},a=class{#e;#r=0;constructor(e){this.#e=new DataView(e.buffer),this.#r=e.byteOffset}get offset(){return this.#r}readUInt8Array(){const e=this.readU32(),t=new Uint8Array(this.#e.buffer,this.#r,e);return this.#r+=e,t}readBool(){const e=this.#e.getUint8(this.#r);return this.#r+=1,0!==e}readByte(){const e=this.#e.getUint8(this.#r);return this.#r+=1,e}readBytes(e){const t=new DataView(this.#e.buffer,this.#r,e);return this.#r+=e,new Uint8Array(t.buffer)}readI8(){const e=this.#e.getInt8(this.#r);return this.#r+=1,e}readU8(){const e=this.#e.getUint8(this.#r);return this.#r+=1,e}readI16(){const e=this.#e.getInt16(this.#r,!0);return this.#r+=2,e}readU16(){const e=this.#e.getUint16(this.#r,!0);return this.#r+=2,e}readI32(){const e=this.#e.getInt32(this.#r,!0);return this.#r+=4,e}readU32(){const e=this.#e.getUint32(this.#r,!0);return this.#r+=4,e}readI64(){const e=this.#e.getBigInt64(this.#r,!0);return this.#r+=8,e}readU64(){const e=this.#e.getBigUint64(this.#r,!0);return this.#r+=8,e}readU128(){const e=this.#e.getBigUint64(this.#r,!0),t=this.#e.getBigUint64(this.#r+8,!0);return this.#r+=16,(t<<BigInt(64))+e}readI128(){const e=this.#e.getBigUint64(this.#r,!0),t=this.#e.getBigInt64(this.#r+8,!0);return this.#r+=16,(t<<BigInt(64))+e}readU256(){const e=this.#e.getBigUint64(this.#r,!0),t=this.#e.getBigUint64(this.#r+8,!0),r=this.#e.getBigUint64(this.#r+16,!0),i=this.#e.getBigUint64(this.#r+24,!0);return this.#r+=32,(i<<BigInt(192))+(r<<BigInt(128))+(t<<BigInt(64))+e}readI256(){const e=this.#e.getBigUint64(this.#r,!0),t=this.#e.getBigUint64(this.#r+8,!0),r=this.#e.getBigUint64(this.#r+16,!0),i=this.#e.getBigInt64(this.#r+24,!0);return this.#r+=32,(i<<BigInt(192))+(r<<BigInt(128))+(t<<BigInt(64))+e}readF32(){const e=this.#e.getFloat32(this.#r,!0);return this.#r+=4,e}readF64(){const e=this.#e.getFloat64(this.#r,!0);return this.#r+=8,e}readString(){const e=this.readU32(),t=new Uint8Array(this.#e.buffer,this.#r,e),r=new TextDecoder("utf-8").decode(t);return this.#r+=e,r}};function s(e){const t=e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace("-","").replace("_",""));return t.charAt(0).toUpperCase()+t.slice(1)}function n(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(const a of r)if(!i.includes(a)||!n(e[a],t[a]))return!1;return!0}function c(e){return Array.prototype.map.call(e.reverse(),e=>("00"+e.toString(16)).slice(-2)).join("")}function o(e){if(16!=e.length)throw new Error(`Uint8Array is not 16 bytes long: ${e}`);return new a(e).readU128()}function l(e){if(32!=e.length)throw new Error(`Uint8Array is not 32 bytes long: [${e}]`);return new a(e).readU256()}function u(e){e.startsWith("0x")&&(e=e.slice(2));const t=e.match(/.{1,2}/g)||[];return Uint8Array.from(t.map(e=>parseInt(e,16))).reverse()}function p(e){return o(u(e))}function d(e){return l(u(e))}function y(e){const t=new i(16);return t.writeU128(e),t.getBuffer()}function g(e){return c(y(e))}function h(e){const t=new i(32);return t.writeU256(e),t.getBuffer()}function b(e){return c(h(e))}var m=class e{__identity__;constructor(e){this.__identity__="string"==typeof e?d(e):e}static getAlgebraicType(){return v.Product({elements:[{name:"__identity__",algebraicType:v.U256}]})}isEqual(e){return this.toHexString()===e.toHexString()}toHexString(){return b(this.__identity__)}toUint8Array(){return h(this.__identity__)}static fromString(t){return new e(t)}static zero(){return new e(0n)}},f={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"name",algebraicType:v.createOptionType(v.String)},{name:"algebraicType",algebraicType:I.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,f.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,f.getTypeScriptAlgebraicType())},T={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"variants",algebraicType:v.Array(f.getTypeScriptAlgebraicType())}]}),serialize(e,t){v.serializeValue(e,T.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,T.getTypeScriptAlgebraicType())},w={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"name",algebraicType:v.createOptionType(v.String)},{name:"algebraicType",algebraicType:I.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,w.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,w.getTypeScriptAlgebraicType())},S={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"elements",algebraicType:v.Array(w.getTypeScriptAlgebraicType())}]}),serialize(e,t){v.serializeValue(e,S.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,S.getTypeScriptAlgebraicType())},I={Ref:e=>({tag:"Ref",value:e}),Sum:e=>({tag:"Sum",value:e}),Product:e=>({tag:"Product",value:e}),Array:e=>({tag:"Array",value:e}),String:{tag:"String"},Bool:{tag:"Bool"},I8:{tag:"I8"},U8:{tag:"U8"},I16:{tag:"I16"},U16:{tag:"U16"},I32:{tag:"I32"},U32:{tag:"U32"},I64:{tag:"I64"},U64:{tag:"U64"},I128:{tag:"I128"},U128:{tag:"U128"},I256:{tag:"I256"},U256:{tag:"U256"},F32:{tag:"F32"},F64:{tag:"F64"},getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"Ref",algebraicType:v.U32},{name:"Sum",algebraicType:T.getTypeScriptAlgebraicType()},{name:"Product",algebraicType:S.getTypeScriptAlgebraicType()},{name:"Array",algebraicType:I.getTypeScriptAlgebraicType()},{name:"String",algebraicType:v.Product({elements:[]})},{name:"Bool",algebraicType:v.Product({elements:[]})},{name:"I8",algebraicType:v.Product({elements:[]})},{name:"U8",algebraicType:v.Product({elements:[]})},{name:"I16",algebraicType:v.Product({elements:[]})},{name:"U16",algebraicType:v.Product({elements:[]})},{name:"I32",algebraicType:v.Product({elements:[]})},{name:"U32",algebraicType:v.Product({elements:[]})},{name:"I64",algebraicType:v.Product({elements:[]})},{name:"U64",algebraicType:v.Product({elements:[]})},{name:"I128",algebraicType:v.Product({elements:[]})},{name:"U128",algebraicType:v.Product({elements:[]})},{name:"I256",algebraicType:v.Product({elements:[]})},{name:"U256",algebraicType:v.Product({elements:[]})},{name:"F32",algebraicType:v.Product({elements:[]})},{name:"F64",algebraicType:v.Product({elements:[]})}]}),serialize(e,t){v.serializeValue(e,I.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,I.getTypeScriptAlgebraicType())},A={getAlgebraicType:()=>v.Sum({variants:[{name:"Interval",algebraicType:v.createTimeDurationType()},{name:"Time",algebraicType:v.createTimestampType()}]})},U=e=>({tag:"Interval",value:new t(e)}),_=e=>({tag:"Time",value:new r(e)}),z=A,v={...I,createOptionType:function(e){return I.Sum({variants:[{name:"some",algebraicType:e},{name:"none",algebraicType:I.Product({elements:[]})}]})},createIdentityType:function(){return m.getAlgebraicType()},createConnectionIdType:function(){return M.getAlgebraicType()},createScheduleAtType:function(){return z.getAlgebraicType()},createTimestampType:function(){return r.getAlgebraicType()},createTimeDurationType:function(){return t.getAlgebraicType()},serializeValue:function(e,t,r){switch(t.tag){case"Product":x.serializeValue(e,t.value,r);break;case"Sum":B.serializeValue(e,t.value,r);break;case"Array":if("U8"===t.value.tag)e.writeUInt8Array(r);else{const i=t.value;e.writeU32(r.length);for(const t of r)v.serializeValue(e,i,t)}break;case"Bool":e.writeBool(r);break;case"I8":e.writeI8(r);break;case"U8":e.writeU8(r);break;case"I16":e.writeI16(r);break;case"U16":e.writeU16(r);break;case"I32":e.writeI32(r);break;case"U32":e.writeU32(r);break;case"I64":e.writeI64(r);break;case"U64":e.writeU64(r);break;case"I128":e.writeI128(r);break;case"U128":e.writeU128(r);break;case"I256":e.writeI256(r);break;case"U256":e.writeU256(r);break;case"F32":e.writeF32(r);break;case"F64":e.writeF64(r);break;case"String":e.writeString(r);break;default:throw new Error(`not implemented, ${t.tag}`)}},deserializeValue:function(e,t){switch(t.tag){case"Product":return x.deserializeValue(e,t.value);case"Sum":return B.deserializeValue(e,t.value);case"Array":if("U8"===t.value.tag)return e.readUInt8Array();{const r=t.value,i=e.readU32(),a=[];for(let t=0;t<i;t++)a.push(v.deserializeValue(e,r));return a}case"Bool":return e.readBool();case"I8":return e.readI8();case"U8":return e.readU8();case"I16":return e.readI16();case"U16":return e.readU16();case"I32":return e.readI32();case"U32":return e.readU32();case"I64":return e.readI64();case"U64":return e.readU64();case"I128":return e.readI128();case"U128":return e.readU128();case"I256":return e.readI256();case"U256":return e.readU256();case"F32":return e.readF32();case"F64":return e.readF64();case"String":return e.readString();default:throw new Error(`not implemented, ${t.tag}`)}},intoMapKey:function(e,t){switch(e.tag){case"U8":case"U16":case"U32":case"U64":case"U128":case"U256":case"I8":case"I16":case"I64":case"I128":case"F32":case"F64":case"String":case"Bool":return t;case"Product":return x.intoMapKey(e.value,t);default:{const e=new i(10);return this.serialize(e,t),e.toBase64()}}}},x={...S,serializeValue(e,t,r){for(const i of t.elements)v.serializeValue(e,i.algebraicType,r[i.name])},deserializeValue(e,i){const a={};if(1===i.elements.length){if("__time_duration_micros__"===i.elements[0].name)return new t(e.readI64());if("__timestamp_micros_since_unix_epoch__"===i.elements[0].name)return new r(e.readI64());if("__identity__"===i.elements[0].name)return new m(e.readU256());if("__connection_id__"===i.elements[0].name)return new M(e.readU128())}for(const t of i.elements)a[t.name]=v.deserializeValue(e,t.algebraicType);return a},intoMapKey(e,t){if(1===e.elements.length){if("__time_duration_micros__"===e.elements[0].name)return t.__time_duration_micros__;if("__timestamp_micros_since_unix_epoch__"===e.elements[0].name)return t.__timestamp_micros_since_unix_epoch__;if("__identity__"===e.elements[0].name)return t.__identity__;if("__connection_id__"===e.elements[0].name)return t.__connection_id__}const r=new i(10);return v.serializeValue(r,v.Product(e),t),r.toBase64()}},B={...T,serializeValue:function(e,t,r){if(2==t.variants.length&&"some"===t.variants[0].name&&"none"===t.variants[1].name)null!=r?(e.writeByte(0),v.serializeValue(e,t.variants[0].algebraicType,r)):e.writeByte(1);else{const i=r.tag,a=t.variants.findIndex(e=>e.name===i);if(a<0)throw`Can't serialize a sum type, couldn't find ${r.tag} tag`;e.writeU8(a),v.serializeValue(e,t.variants[a].algebraicType,r.value)}},deserializeValue:function(e,t){const r=e.readU8();if(2==t.variants.length&&"some"===t.variants[0].name&&"none"===t.variants[1].name){if(0===r)return v.deserializeValue(e,t.variants[0].algebraicType);if(1===r)return;throw`Can't deserialize an option type, couldn't find ${r} tag`}{const i=t.variants[r],a=v.deserializeValue(e,i.algebraicType);return{tag:i.name,value:a}}}},M=class e{__connection_id__;constructor(e){this.__connection_id__=e}static getAlgebraicType(){return v.Product({elements:[{name:"__connection_id__",algebraicType:v.U128}]})}isZero(){return this.__connection_id__===BigInt(0)}static nullIfZero(e){return e.isZero()?null:e}static random(){function t(){return Math.floor(255*Math.random())}let r=BigInt(0);for(let e=0;e<16;e++)r=r<<BigInt(8)|BigInt(t());return new e(r)}isEqual(e){return this.__connection_id__==e.__connection_id__}toHexString(){return g(this.__connection_id__)}toUint8Array(){return y(this.__connection_id__)}static fromString(t){return new e(p(t))}static fromStringOrNull(t){const r=e.fromString(t);return r.isZero()?null:r}};function q(e,t){const r=new a(t);return e.deserialize(r)}var F={FixedSize:e=>({tag:"FixedSize",value:e}),RowOffsets:e=>({tag:"RowOffsets",value:e}),getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"FixedSize",algebraicType:v.U16},{name:"RowOffsets",algebraicType:v.Array(v.U64)}]}),serialize(e,t){v.serializeValue(e,F.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,F.getTypeScriptAlgebraicType())},P={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"sizeHint",algebraicType:F.getTypeScriptAlgebraicType()},{name:"rowsData",algebraicType:v.Array(v.U8)}]}),serialize(e,t){v.serializeValue(e,P.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,P.getTypeScriptAlgebraicType())},V={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"reducer",algebraicType:v.String},{name:"args",algebraicType:v.Array(v.U8)},{name:"requestId",algebraicType:v.U32},{name:"flags",algebraicType:v.U8}]}),serialize(e,t){v.serializeValue(e,V.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,V.getTypeScriptAlgebraicType())},O={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"queryStrings",algebraicType:v.Array(v.String)},{name:"requestId",algebraicType:v.U32}]}),serialize(e,t){v.serializeValue(e,O.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,O.getTypeScriptAlgebraicType())},C={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"messageId",algebraicType:v.Array(v.U8)},{name:"queryString",algebraicType:v.String}]}),serialize(e,t){v.serializeValue(e,C.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,C.getTypeScriptAlgebraicType())},E={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"id",algebraicType:v.U32}]}),serialize(e,t){v.serializeValue(e,E.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,E.getTypeScriptAlgebraicType())},k={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"query",algebraicType:v.String},{name:"requestId",algebraicType:v.U32},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,k.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,k.getTypeScriptAlgebraicType())},R={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"queryStrings",algebraicType:v.Array(v.String)},{name:"requestId",algebraicType:v.U32},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,R.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,R.getTypeScriptAlgebraicType())},K={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,K.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,K.getTypeScriptAlgebraicType())},D={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,D.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,D.getTypeScriptAlgebraicType())},N={CallReducer:e=>({tag:"CallReducer",value:e}),Subscribe:e=>({tag:"Subscribe",value:e}),OneOffQuery:e=>({tag:"OneOffQuery",value:e}),SubscribeSingle:e=>({tag:"SubscribeSingle",value:e}),SubscribeMulti:e=>({tag:"SubscribeMulti",value:e}),Unsubscribe:e=>({tag:"Unsubscribe",value:e}),UnsubscribeMulti:e=>({tag:"UnsubscribeMulti",value:e}),getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"CallReducer",algebraicType:V.getTypeScriptAlgebraicType()},{name:"Subscribe",algebraicType:O.getTypeScriptAlgebraicType()},{name:"OneOffQuery",algebraicType:C.getTypeScriptAlgebraicType()},{name:"SubscribeSingle",algebraicType:k.getTypeScriptAlgebraicType()},{name:"SubscribeMulti",algebraicType:R.getTypeScriptAlgebraicType()},{name:"Unsubscribe",algebraicType:K.getTypeScriptAlgebraicType()},{name:"UnsubscribeMulti",algebraicType:D.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,N.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,N.getTypeScriptAlgebraicType())},$={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"deletes",algebraicType:P.getTypeScriptAlgebraicType()},{name:"inserts",algebraicType:P.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,$.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,$.getTypeScriptAlgebraicType())},L={Uncompressed:e=>({tag:"Uncompressed",value:e}),Brotli:e=>({tag:"Brotli",value:e}),Gzip:e=>({tag:"Gzip",value:e}),getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"Uncompressed",algebraicType:$.getTypeScriptAlgebraicType()},{name:"Brotli",algebraicType:v.Array(v.U8)},{name:"Gzip",algebraicType:v.Array(v.U8)}]}),serialize(e,t){v.serializeValue(e,L.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,L.getTypeScriptAlgebraicType())},j={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"tableId",algebraicType:v.U32},{name:"tableName",algebraicType:v.String},{name:"numRows",algebraicType:v.U64},{name:"updates",algebraicType:v.Array(L.getTypeScriptAlgebraicType())}]}),serialize(e,t){v.serializeValue(e,j.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,j.getTypeScriptAlgebraicType())},W={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"tables",algebraicType:v.Array(j.getTypeScriptAlgebraicType())}]}),serialize(e,t){v.serializeValue(e,W.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,W.getTypeScriptAlgebraicType())},H={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"databaseUpdate",algebraicType:W.getTypeScriptAlgebraicType()},{name:"requestId",algebraicType:v.U32},{name:"totalHostExecutionDuration",algebraicType:v.createTimeDurationType()}]}),serialize(e,t){v.serializeValue(e,H.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,H.getTypeScriptAlgebraicType())},Q={Committed:e=>({tag:"Committed",value:e}),Failed:e=>({tag:"Failed",value:e}),OutOfEnergy:{tag:"OutOfEnergy"},getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"Committed",algebraicType:W.getTypeScriptAlgebraicType()},{name:"Failed",algebraicType:v.String},{name:"OutOfEnergy",algebraicType:v.Product({elements:[]})}]}),serialize(e,t){v.serializeValue(e,Q.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,Q.getTypeScriptAlgebraicType())},Z={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"reducerName",algebraicType:v.String},{name:"reducerId",algebraicType:v.U32},{name:"args",algebraicType:v.Array(v.U8)},{name:"requestId",algebraicType:v.U32}]}),serialize(e,t){v.serializeValue(e,Z.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,Z.getTypeScriptAlgebraicType())},G={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"quanta",algebraicType:v.U128}]}),serialize(e,t){v.serializeValue(e,G.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,G.getTypeScriptAlgebraicType())},X={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"status",algebraicType:Q.getTypeScriptAlgebraicType()},{name:"timestamp",algebraicType:v.createTimestampType()},{name:"callerIdentity",algebraicType:v.createIdentityType()},{name:"callerConnectionId",algebraicType:v.createConnectionIdType()},{name:"reducerCall",algebraicType:Z.getTypeScriptAlgebraicType()},{name:"energyQuantaUsed",algebraicType:G.getTypeScriptAlgebraicType()},{name:"totalHostExecutionDuration",algebraicType:v.createTimeDurationType()}]}),serialize(e,t){v.serializeValue(e,X.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,X.getTypeScriptAlgebraicType())},J={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"update",algebraicType:W.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,J.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,J.getTypeScriptAlgebraicType())},Y={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"identity",algebraicType:v.createIdentityType()},{name:"token",algebraicType:v.String},{name:"connectionId",algebraicType:v.createConnectionIdType()}]}),serialize(e,t){v.serializeValue(e,Y.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,Y.getTypeScriptAlgebraicType())},ee={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"tableName",algebraicType:v.String},{name:"rows",algebraicType:P.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,ee.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,ee.getTypeScriptAlgebraicType())},te={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"messageId",algebraicType:v.Array(v.U8)},{name:"error",algebraicType:v.createOptionType(v.String)},{name:"tables",algebraicType:v.Array(ee.getTypeScriptAlgebraicType())},{name:"totalHostExecutionDuration",algebraicType:v.createTimeDurationType()}]}),serialize(e,t){v.serializeValue(e,te.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,te.getTypeScriptAlgebraicType())},re={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"tableId",algebraicType:v.U32},{name:"tableName",algebraicType:v.String},{name:"tableRows",algebraicType:j.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,re.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,re.getTypeScriptAlgebraicType())},ie={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"totalHostExecutionDurationMicros",algebraicType:v.U64},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()},{name:"rows",algebraicType:re.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,ie.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,ie.getTypeScriptAlgebraicType())},ae={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"totalHostExecutionDurationMicros",algebraicType:v.U64},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()},{name:"rows",algebraicType:re.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,ae.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,ae.getTypeScriptAlgebraicType())},se={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"totalHostExecutionDurationMicros",algebraicType:v.U64},{name:"requestId",algebraicType:v.createOptionType(v.U32)},{name:"queryId",algebraicType:v.createOptionType(v.U32)},{name:"tableId",algebraicType:v.createOptionType(v.U32)},{name:"error",algebraicType:v.String}]}),serialize(e,t){v.serializeValue(e,se.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,se.getTypeScriptAlgebraicType())},ne={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"totalHostExecutionDurationMicros",algebraicType:v.U64},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()},{name:"update",algebraicType:W.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,ne.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,ne.getTypeScriptAlgebraicType())},ce={getTypeScriptAlgebraicType:()=>v.Product({elements:[{name:"requestId",algebraicType:v.U32},{name:"totalHostExecutionDurationMicros",algebraicType:v.U64},{name:"queryId",algebraicType:E.getTypeScriptAlgebraicType()},{name:"update",algebraicType:W.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,ce.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,ce.getTypeScriptAlgebraicType())},oe={InitialSubscription:e=>({tag:"InitialSubscription",value:e}),TransactionUpdate:e=>({tag:"TransactionUpdate",value:e}),TransactionUpdateLight:e=>({tag:"TransactionUpdateLight",value:e}),IdentityToken:e=>({tag:"IdentityToken",value:e}),OneOffQueryResponse:e=>({tag:"OneOffQueryResponse",value:e}),SubscribeApplied:e=>({tag:"SubscribeApplied",value:e}),UnsubscribeApplied:e=>({tag:"UnsubscribeApplied",value:e}),SubscriptionError:e=>({tag:"SubscriptionError",value:e}),SubscribeMultiApplied:e=>({tag:"SubscribeMultiApplied",value:e}),UnsubscribeMultiApplied:e=>({tag:"UnsubscribeMultiApplied",value:e}),getTypeScriptAlgebraicType:()=>v.Sum({variants:[{name:"InitialSubscription",algebraicType:H.getTypeScriptAlgebraicType()},{name:"TransactionUpdate",algebraicType:X.getTypeScriptAlgebraicType()},{name:"TransactionUpdateLight",algebraicType:J.getTypeScriptAlgebraicType()},{name:"IdentityToken",algebraicType:Y.getTypeScriptAlgebraicType()},{name:"OneOffQueryResponse",algebraicType:te.getTypeScriptAlgebraicType()},{name:"SubscribeApplied",algebraicType:ie.getTypeScriptAlgebraicType()},{name:"UnsubscribeApplied",algebraicType:ae.getTypeScriptAlgebraicType()},{name:"SubscriptionError",algebraicType:se.getTypeScriptAlgebraicType()},{name:"SubscribeMultiApplied",algebraicType:ne.getTypeScriptAlgebraicType()},{name:"UnsubscribeMultiApplied",algebraicType:ce.getTypeScriptAlgebraicType()}]}),serialize(e,t){v.serializeValue(e,oe.getTypeScriptAlgebraicType(),t)},deserialize:e=>v.deserializeValue(e,oe.getTypeScriptAlgebraicType())},le=class{#a=new Map;on(e,t){let r=this.#a.get(e);r||(r=new Set,this.#a.set(e,r)),r.add(t)}off(e,t){const r=this.#a.get(e);r&&r.delete(t)}emit(e,...t){const r=this.#a.get(e);if(r)for(const e of r)e(...t)}},ue={component:"đŸ“Ļ",info:"â„šī¸",warn:"âš ī¸",error:"❌",debug:"🐛"},pe={component:"color: #fff; background-color: #8D6FDD; padding: 2px 5px; border-radius: 3px;",info:"color: #fff; background-color: #007bff; padding: 2px 5px; border-radius: 3px;",warn:"color: #fff; background-color: #ffc107; padding: 2px 5px; border-radius: 3px;",error:"color: #fff; background-color: #dc3545; padding: 2px 5px; border-radius: 3px;",debug:"color: #fff; background-color: #28a745; padding: 2px 5px; border-radius: 3px;"},de={component:"color: #8D6FDD;",info:"color: #007bff;",warn:"color: #ffc107;",error:"color: #dc3545;",debug:"color: #28a745;"},ye=(e,t)=>{console.log(`%c${ue[e]} ${e.toUpperCase()}%c ${t}`,pe[e],de[e])},ge=class{rows;tableTypeInfo;emitter;constructor(e){this.tableTypeInfo=e,this.rows=new Map,this.emitter=new le}count(){return this.rows.size}iter(){return Array.from(this.rows.values()).map(([e])=>e)}applyOperations=(e,t)=>{const r=[];if(void 0!==this.tableTypeInfo.primaryKeyInfo){const i=new Map,a=new Map;for(const t of e)if("insert"===t.type){const[e,r]=i.get(t.rowId)||[t,0];i.set(t.rowId,[t,r+1])}else{const[e,r]=a.get(t.rowId)||[t,0];a.set(t.rowId,[t,r+1])}for(const[e,[s,n]]of i){const i=a.get(e);if(i){const[c,o]=i,l=n-o,u=this.update(t,e,s.row,l);u&&r.push(u),a.delete(e)}else{const e=this.insert(t,s,n);e&&r.push(e)}}for(const[e,i]of a.values()){const a=this.delete(t,e,i);a&&r.push(a)}}else for(const i of e)if("insert"===i.type){const e=this.insert(t,i);e&&r.push(e)}else{const e=this.delete(t,i);e&&r.push(e)}return r};update=(e,t,r,i=0)=>{const a=this.rows.get(t);if(!a)return void ye("error",`Updating a row that was not present in the cache. Table: ${this.tableTypeInfo.tableName}, RowId: ${t}`);const[s,n]=a,c=Math.max(1,n+i);if(!(n+i<=0))return this.rows.set(t,[r,c]),0===n?(ye("error",`Updating a row id in table ${this.tableTypeInfo.tableName} which was not present in the cache (rowId: ${t})`),{type:"insert",table:this.tableTypeInfo.tableName,cb:()=>{this.emitter.emit("insert",e,r)}}):{type:"update",table:this.tableTypeInfo.tableName,cb:()=>{this.emitter.emit("update",e,s,r)}};ye("error",`Negative reference count for in table ${this.tableTypeInfo.tableName} row ${t} (${n} + ${i})`)};insert=(e,t,r=1)=>{const[i,a]=this.rows.get(t.rowId)||[t.row,0];if(this.rows.set(t.rowId,[t.row,a+r]),0===a)return{type:"insert",table:this.tableTypeInfo.tableName,cb:()=>{this.emitter.emit("insert",e,t.row)}}};delete=(e,t,r=1)=>{const[i,a]=this.rows.get(t.rowId)||[t.row,0];if(0!==a)return a<=r?(this.rows.delete(t.rowId),{type:"delete",table:this.tableTypeInfo.tableName,cb:()=>{this.emitter.emit("delete",e,t.row)}}):void this.rows.set(t.rowId,[t.row,a-r]);ye("warn","Deleting a row that was not present in the cache")};onInsert=e=>{this.emitter.on("insert",e)};onDelete=e=>{this.emitter.on("delete",e)};onUpdate=e=>{this.emitter.on("update",e)};removeOnInsert=e=>{this.emitter.off("insert",e)};removeOnDelete=e=>{this.emitter.off("delete",e)};removeOnUpdate=e=>{this.emitter.off("update",e)}},he=class{tables;constructor(){this.tables=new Map}getTable(e){const t=this.tables.get(e);if(!t)throw console.error("The table has not been registered for this client. Please register the table before using it. If you have registered global tables using the SpacetimeDBClient.registerTables() or `registerTable()` method, please make sure that is executed first!"),new Error(`Table ${e} does not exist`);return t}getOrCreateTable(e){let t;return this.tables.has(e.tableName)?t=this.tables.get(e.tableName):(t=new ge(e),this.tables.set(e.tableName,t)),t}};var be=class e{major;minor;patch;preRelease;buildInfo;constructor(e,t,r,i=null,a=null){this.major=e,this.minor=t,this.patch=r,this.preRelease=i,this.buildInfo=a}toString(){let e=`${this.major}.${this.minor}.${this.patch}`;return this.preRelease&&(e+=`-${this.preRelease.join(".")}`),this.buildInfo&&(e+=`+${this.buildInfo}`),e}compare(e){return this.major!==e.major?this.major-e.major:this.minor!==e.minor?this.minor-e.minor:this.patch!==e.patch?this.patch-e.patch:this.preRelease&&e.preRelease?function(e,t){const r=Math.min(e.length,t.length);for(let i=0;i<r;i++){const r=e[i],a=t[i];if(r!==a)return"number"==typeof r&&"number"==typeof a?r-a:"string"==typeof r&&"string"==typeof a?r.localeCompare(a):"string"==typeof r?1:-1}return e.length-t.length}(this.preRelease,e.preRelease):this.preRelease||e.preRelease?-1:0}clone(){return new e(this.major,this.minor,this.patch,this.preRelease?[...this.preRelease]:null,this.buildInfo)}static parseVersionString(t){const r=t.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*))?(?:\+([\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*))?$/);if(!r)throw new Error(`Invalid version string: ${t}`);const i=parseInt(r[1],10),a=parseInt(r[2],10),s=parseInt(r[3],10),n=r[4]?r[4].split(".").map(e=>isNaN(Number(e))?e:Number(e)):null,c=r[5]||null;return new e(i,a,s,n,c)}},me=new be(1,4,0);function fe(e){return`Module code was generated with an incompatible version of the spacetimedb cli (${e}). Update the cli version to at least ${me.toString()} and regenerate the bindings. You can upgrade to the latest cli version by running: spacetime version upgrade`}async function Te(e,t,r=131072){let i=0;const a=new ReadableStream({pull(t){if(i<e.length){const a=e.subarray(i,Math.min(i+r,e.length));t.enqueue(a),i+=r}else t.close()}}),s=new DecompressionStream(t),n=a.pipeThrough(s).getReader(),c=[];let o,l=0;for(;!(o=await n.read()).done;)c.push(o.value),l+=o.value.length;const u=new Uint8Array(l);let p=0;for(const e of c)u.set(e,p),p+=e.length;return u}var we=class e{onclose;onopen;onmessage;onerror;#s;async#n(e){const t=new Uint8Array(e.data);let r;if(0===t[0])r=t.slice(1);else{if(1===t[0])throw new Error("Brotli Compression not supported. Please use gzip or none compression in withCompression method on DbConnection.");if(2!==t[0])throw new Error("Unexpected Compression Algorithm. Please use `gzip` or `none`");r=await Te(t.slice(1),"gzip")}this.onmessage?.({data:r})}#c(e){this.onopen?.(e)}#o(e){this.onerror?.(e)}#l(e){this.onclose?.(e)}send(e){this.#s.send(e)}close(){this.#s.close()}constructor(e){this.onmessage=void 0,this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,e.onmessage=this.#n.bind(this),e.onerror=this.#o.bind(this),e.onclose=this.#l.bind(this),e.onopen=this.#c.bind(this),e.binaryType="arraybuffer",this.#s=e}static async createWebSocketFn({url:t,nameOrAddress:r,wsProtocol:i,authToken:a,compression:s,lightMode:n}){const c=new Headers,o=await async function(){if(void 0!==globalThis.WebSocket)return globalThis.WebSocket;const e=new Function("m","return import(m)");try{const{WebSocket:t}=await e("undici");return t}catch(e){throw console.warn("[spacetimedb-sdk] No global WebSocket found. On Node 18–21, please install `undici` (npm install undici) to enable WebSocket support."),e}}();let l;if(a){c.set("Authorization",`Bearer ${a}`);const e=new URL("v1/identity/websocket-token",t);e.protocol="wss:"===t.protocol?"https:":"http:";const r=await fetch(e,{method:"POST",headers:c});if(!r.ok)return Promise.reject(new Error(`Failed to verify token: ${r.statusText}`));{const{token:e}=await r.json();l=e}}const u=new URL(`v1/database/${r}/subscribe`,t);l&&u.searchParams.set("token",l),u.searchParams.set("compression","gzip"===s?"Gzip":"None"),n&&u.searchParams.set("light","true");const p=new o(u.toString(),i);return new e(p)}},Se=class{constructor(e,t){this.remoteModule=e,this.dbConnectionConstructor=t,this.#u=we.createWebSocketFn}#p;#d;#y;#g;#h=new le;#b="gzip";#m=!1;#u;withUri(e){return this.#p=new URL(e),this}withModuleName(e){return this.#d=e,this}withToken(e){return this.#g=e,this}withWSFn(e){return this.#u=e,this}withCompression(e){return this.#b=e,this}withLightMode(e){return this.#m=e,this}onConnect(e){return this.#h.on("connect",e),this}onConnectError(e){return this.#h.on("connectError",e),this}onDisconnect(e){return this.#h.on("disconnect",e),this}build(){if(!this.#p)throw new Error("URI is required to connect to SpacetimeDB");if(!this.#d)throw new Error("Database name or address is required to connect to SpacetimeDB");return function(e){if(void 0===e)throw new Error(fe(e));if(be.parseVersionString(e).compare(me)<0)throw new Error(fe(e))}(this.remoteModule.versionInfo?.cliVersion),this.dbConnectionConstructor(new ze({uri:this.#p,nameOrAddress:this.#d,identity:this.#y,token:this.#g,emitter:this.#h,compression:this.#b,lightMode:this.#m,createWSFn:this.#u,remoteModule:this.remoteModule}))}},Ie=class{constructor(e){this.db=e}#f=void 0;#T=void 0;onApplied(e){return this.#f=e,this}onError(e){return this.#T=e,this}subscribe(e){const t=Array.isArray(e)?e:[e];if(0===t.length)throw new Error("Subscriptions must have at least one query");return new Ue(this.db,t,this.#f,this.#T)}subscribeToAllTables(){this.subscribe("SELECT * FROM *")}},Ae=class{subscriptions=new Map},Ue=class{constructor(e,t,r,i){this.db=e,this.#h.on("applied",e=>{this.#w=!0,r&&r(e)}),this.#h.on("error",(e,t)=>{this.#w=!1,this.#S=!0,i&&i(e,t)}),this.#I=this.db.registerSubscription(this,this.#h,t)}#I;#A=!1;#S=!1;#w=!1;#h=new le;unsubscribe(){if(this.#A)throw new Error("Unsubscribe has already been called");this.#A=!0,this.db.unregisterSubscription(this.#I),this.#h.on("end",e=>{this.#S=!0,this.#w=!1})}unsubscribeThen(e){if(this.#S)throw new Error("Subscription has already ended");if(this.#A)throw new Error("Unsubscribe has already been called");this.#A=!0,this.db.unregisterSubscription(this.#I),this.#h.on("end",t=>{this.#S=!0,this.#w=!1,e(t)})}isEnded(){return this.#S}isActive(){return this.#w}};function _e(e){switch(e){case"FullUpdate":return 0;case"NoSuccessNotify":return 1}}var ze=class{isActive=!1;identity=void 0;token=void 0;db;reducers;setReducerFlags;connectionId=M.random();#I=0;#h;#U=new le;#f;#_;#z=Promise.resolve();#v=new Ae;clientCache;ws;wsPromise;constructor({uri:e,nameOrAddress:t,identity:r,token:i,emitter:a,remoteModule:s,createWSFn:n,compression:c,lightMode:o}){ye("info","Connecting to SpacetimeDB WS...");const l=new URL(e.toString());/^wss?:/.test(e.protocol)||(l.protocol="https:"===l.protocol?"wss:":"ws:"),this.identity=r,this.token=i,this.#_=s,this.#h=a;const u=this.connectionId.toHexString();l.searchParams.set("connection_id",u),this.clientCache=new he,this.db=this.#_.dbViewConstructor(this),this.setReducerFlags=this.#_.setReducerFlagsConstructor(),this.reducers=this.#_.reducersConstructor(this,this.setReducerFlags),this.wsPromise=n({url:l,nameOrAddress:t,wsProtocol:"v1.bsatn.spacetimedb",authToken:i,compression:c,lightMode:o}).then(e=>(this.ws=e,this.ws.onclose=()=>{this.#h.emit("disconnect",this)},this.ws.onerror=e=>{this.#h.emit("connectError",this,e)},this.ws.onopen=this.#c.bind(this),this.ws.onmessage=this.#n.bind(this),e)).catch(e=>{ye("error","Error connecting to SpacetimeDB WS"),this.#h.emit("connectError",this,e)})}#x=()=>{const e=this.#I;return this.#I+=1,e};subscriptionBuilder=()=>new Ie(this);registerSubscription(e,t,r){const i=this.#x();return this.#v.subscriptions.set(i,{handle:e,emitter:t}),this.#B(N.SubscribeMulti({queryStrings:r,queryId:{id:i},requestId:0})),i}unregisterSubscription(e){this.#B(N.UnsubscribeMulti({queryId:{id:e},requestId:0}))}async#M(t){const r=(t,r,i)=>{const s=i.rowsData,n=new a(s),c=[],o=this.#_.tables[r].rowType,l=this.#_.tables[r].primaryKeyInfo;for(;n.offset<s.length+s.byteOffset;){const r=n.offset,i=v.deserializeValue(n,o);let a;if(void 0!==l)a=v.intoMapKey(l.colType,i[l.colName]);else{const t=s.subarray(r-s.byteOffset,n.offset-s.byteOffset);a=e(t)}c.push({type:t,rowId:a,row:i})}return c},i=async e=>{const t=e.tableName;let i=[];for(const s of e.updates){let e;if("Gzip"===s.tag){const t=await Te(s.value,"gzip");e=$.deserialize(new a(t))}else{if("Brotli"===s.tag)throw new Error("Brotli compression not supported. Please use gzip or none compression in withCompression method on DbConnection.");e=s.value}i=i.concat(r("insert",t,e.inserts)),i=i.concat(r("delete",t,e.deletes))}return{tableName:t,operations:i}},s=async e=>{const t=[];for(const r of e.tables)t.push(await i(r));return t};switch(t.tag){case"InitialSubscription":{const e=t.value.databaseUpdate;return{tag:"InitialSubscription",tableUpdates:await s(e)}}case"TransactionUpdateLight":{const e=t.value.update;return{tag:"TransactionUpdateLight",tableUpdates:await s(e)}}case"TransactionUpdate":{const e=t.value,r=e.callerIdentity,i=M.nullIfZero(e.callerConnectionId),a=e.reducerCall.reducerName,n=e.reducerCall.args,c=e.energyQuantaUsed;let o,l=[],u="";switch(e.status.tag){case"Committed":l=await s(e.status.value);break;case"Failed":l=[],u=e.status.value;break;case"OutOfEnergy":l=[]}if("<none>"===a){const e=u;return void console.error(`Received an error from the database: ${e}`)}""!==a&&(o={reducerName:a,args:n});return{tag:"TransactionUpdate",tableUpdates:l,identity:r,connectionId:i,reducerInfo:o,status:e.status,energyConsumed:c.quanta,message:u,timestamp:e.timestamp}}case"IdentityToken":return{tag:"IdentityToken",identity:t.value.identity,token:t.value.token,connectionId:t.value.connectionId};case"OneOffQueryResponse":throw new Error(`TypeScript SDK never sends one-off queries, but got OneOffQueryResponse ${t}`);case"SubscribeMultiApplied":{const e=await s(t.value.update);return{tag:"SubscribeApplied",queryId:t.value.queryId.id,tableUpdates:e}}case"UnsubscribeMultiApplied":{const e=await s(t.value.update);return{tag:"UnsubscribeApplied",queryId:t.value.queryId.id,tableUpdates:e}}case"SubscriptionError":return{tag:"SubscriptionError",queryId:t.value.queryId,error:t.value.error}}}#B(e){this.wsPromise.then(t=>{if(t){const r=new i(1024);N.serialize(r,e);const a=r.getBuffer();t.send(a)}})}#c(){this.isActive=!0}#q(e,t){const r=[];for(const i of e){const e=i.tableName,a=this.#_.tables[e],s=this.clientCache.getOrCreateTable(a).applyOperations(i.operations,t);for(const e of s)r.push(e)}return r}async#F(e){const t=q(oe,e),r=await this.#M(t);if(r)switch(r.tag){case"InitialSubscription":{const e={tag:"SubscribeApplied"},t=this.#_.eventContextConstructor(this,e),{event:i,...a}=t,s=this.#q(r.tableUpdates,t);this.#h&&this.#f?.(a);for(const e of s)e.cb();break}case"TransactionUpdateLight":{const e={tag:"UnknownTransaction"},t=this.#_.eventContextConstructor(this,e),i=this.#q(r.tableUpdates,t);for(const e of i)e.cb();break}case"TransactionUpdate":{let e,t,i=r.reducerInfo,s=!1;if(i){t=this.#_.reducers[i.reducerName];try{const r=new a(i.args);e=v.deserializeValue(r,t.argsType)}catch{console.debug("Failed to deserialize reducer arguments"),s=!0}}else s=!0;if(s){const e={tag:"UnknownTransaction"},t=this.#_.eventContextConstructor(this,e),i=this.#q(r.tableUpdates,t);for(const e of i)e.cb();return}const n={callerIdentity:r.identity,status:r.status,callerConnectionId:r.connectionId,timestamp:r.timestamp,energyConsumed:r.energyConsumed,reducer:{name:i.reducerName,args:e}},c={tag:"Reducer",value:n},o=this.#_.eventContextConstructor(this,c),l={...o,event:n},u=this.#q(r.tableUpdates,o),p=[];t.argsType.value.elements.forEach(t=>{p.push(e[t.name])}),this.#U.emit(i.reducerName,l,...p);for(const e of u)e.cb();break}case"IdentityToken":this.identity=r.identity,!this.token&&r.token&&(this.token=r.token),this.connectionId=r.connectionId,this.#h.emit("connect",this,this.identity,this.token);break;case"SubscribeApplied":{const e=this.#v.subscriptions.get(r.queryId);if(void 0===e){ye("error",`Received SubscribeApplied for unknown queryId ${r.queryId}.`);break}const t={tag:"SubscribeApplied"},i=this.#_.eventContextConstructor(this,t),{event:a,...s}=i,n=this.#q(r.tableUpdates,i);e?.emitter.emit("applied",s);for(const e of n)e.cb();break}case"UnsubscribeApplied":{const e=this.#v.subscriptions.get(r.queryId);if(void 0===e){ye("error",`Received UnsubscribeApplied for unknown queryId ${r.queryId}.`);break}const t={tag:"UnsubscribeApplied"},i=this.#_.eventContextConstructor(this,t),{event:a,...s}=i,n=this.#q(r.tableUpdates,i);e?.emitter.emit("end",s),this.#v.subscriptions.delete(r.queryId);for(const e of n)e.cb();break}case"SubscriptionError":{const e=Error(r.error),t={tag:"Error",value:e},i={...this.#_.eventContextConstructor(this,t),event:e};void 0!==r.queryId?(this.#v.subscriptions.get(r.queryId)?.emitter.emit("error",i,e),this.#v.subscriptions.delete(r.queryId)):(console.error("Received an error message without a queryId: ",e),this.#v.subscriptions.forEach(({emitter:t})=>{t.emit("error",i,e)}))}}}#n(e){this.#z=this.#z.then(()=>this.#F(e.data))}callReducer(e,t,r){const i=N.CallReducer({reducer:e,args:t,requestId:0,flags:_e(r)});this.#B(i)}disconnect(){this.wsPromise.then(e=>{e&&e.close()})}on(e,t){this.#h.on(e,t)}off(e,t){this.#h.off(e,t)}onConnect(e){this.#h.on("connect",e)}onDisconnect(e){this.#h.on("disconnect",e)}onConnectError(e){this.#h.on("connectError",e)}removeOnConnect(e){this.#h.off("connect",e)}removeOnDisconnect(e){this.#h.off("disconnect",e)}removeOnConnectError(e){this.#h.off("connectError",e)}onReducer(e,t){this.#U.on(e,t)}offReducer(e,t){this.#U.off(e,t)}},ve=class{type;spacetimeType;algebraicType;constructor(e){this.algebraicType=e}},xe=class extends ve{constructor(){super(v.U8)}index(e){return new Ze(this,{...He,indexType:e})}unique(){return new Ze(this,{...He,isUnique:!0})}primaryKey(){return new Ze(this,{...He,isPrimaryKey:!0})}autoInc(){return new Ze(this,{...He,isAutoIncrement:!0})}},Be=class extends ve{constructor(){super(v.U16)}index(e){return new Ge(this,{...He,indexType:e})}unique(){return new Ge(this,{...He,isUnique:!0})}primaryKey(){return new Ge(this,{...He,isPrimaryKey:!0})}autoInc(){return new Ge(this,{...He,isAutoIncrement:!0})}},Me=class extends ve{constructor(){super(v.U32)}index(e){return new Xe(this,{...He,indexType:e})}unique(){return new Xe(this,{...He,isUnique:!0})}primaryKey(){return new Xe(this,{...He,isPrimaryKey:!0})}autoInc(){return new Xe(this,{...He,isAutoIncrement:!0})}},qe=class extends ve{constructor(){super(v.U64)}index(e){return new Je(this,{...He,indexType:e})}unique(){return new Je(this,{...He,isUnique:!0})}primaryKey(){return new Je(this,{...He,isPrimaryKey:!0})}autoInc(){return new Je(this,{...He,isAutoIncrement:!0})}},Fe=class extends ve{constructor(){super(v.U128)}index(e){return new Ye(this,{...He,indexType:e})}unique(){return new Ye(this,{...He,isUnique:!0})}primaryKey(){return new Ye(this,{...He,isPrimaryKey:!0})}autoInc(){return new Ye(this,{...He,isAutoIncrement:!0})}},Pe=class extends ve{constructor(){super(v.U256)}index(e){return new et(this,{...He,indexType:e})}unique(){return new et(this,{...He,isUnique:!0})}primaryKey(){return new et(this,{...He,isPrimaryKey:!0})}autoInc(){return new et(this,{...He,isAutoIncrement:!0})}},Ve=class extends ve{constructor(){super(v.I8)}index(e){return new tt(this,{...He,indexType:e})}unique(){return new tt(this,{...He,isUnique:!0})}primaryKey(){return new tt(this,{...He,isPrimaryKey:!0})}autoInc(){return new tt(this,{...He,isAutoIncrement:!0})}},Oe=class extends ve{constructor(){super(v.I16)}index(e){return new rt(this,{...He,indexType:e})}unique(){return new rt(this,{...He,isUnique:!0})}primaryKey(){return new rt(this,{...He,isPrimaryKey:!0})}autoInc(){return new rt(this,{...He,isAutoIncrement:!0})}},Ce=class extends ve{constructor(){super(v.I32)}index(e){return new it(this,{...He,indexType:e})}unique(){return new it(this,{...He,isUnique:!0})}primaryKey(){return new it(this,{...He,isPrimaryKey:!0})}autoInc(){return new it(this,{...He,isAutoIncrement:!0})}},Ee=class extends ve{constructor(){super(v.I64)}index(e){return new at(this,{...He,indexType:e})}unique(){return new at(this,{...He,isUnique:!0})}primaryKey(){return new at(this,{...He,isPrimaryKey:!0})}autoInc(){return new at(this,{...He,isAutoIncrement:!0})}},ke=class extends ve{constructor(){super(v.I128)}index(e){return new st(this,{...He,indexType:e})}unique(){return new st(this,{...He,isUnique:!0})}primaryKey(){return new st(this,{...He,isPrimaryKey:!0})}autoInc(){return new st(this,{...He,isAutoIncrement:!0})}},Re=class extends ve{constructor(){super(v.I256)}index(e){return new nt(this,{...He,indexType:e})}unique(){return new nt(this,{...He,isUnique:!0})}primaryKey(){return new nt(this,{...He,isPrimaryKey:!0})}autoInc(){return new nt(this,{...He,isAutoIncrement:!0})}},Ke=class extends ve{constructor(){super(v.F32)}},De=class extends ve{constructor(){super(v.F64)}},Ne=class extends ve{constructor(){super(v.Bool)}index(e){return new ct(this,{...He,indexType:e})}unique(){return new ct(this,{...He,isUnique:!0})}primaryKey(){return new ct(this,{...He,isPrimaryKey:!0})}},$e=class extends ve{constructor(){super(v.String)}index(e){return new ot(this,{...He,indexType:e})}unique(){return new ot(this,{...He,isUnique:!0})}primaryKey(){return new ot(this,{...He,isPrimaryKey:!0})}},Le=class extends ve{element;constructor(e){super(v.Array(e.algebraicType))}},je=class extends ve{elements;constructor(e){var t;super(v.Product({elements:(t=e,Object.entries(t).map(([e,{algebraicType:t}])=>({name:e,algebraicType:t})))}))}},We=class extends ve{variants;constructor(e){var t;super(v.Sum({variants:(t=e,Object.entries(t).map(([e,{algebraicType:t}])=>({name:e,algebraicType:t})))}))}},He={},Qe=class{columnMetadataType;typeBuilder;columnMetadata;constructor(e,t){this.typeBuilder=e,this.columnMetadata=t??He}},Ze=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},Ge=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},Xe=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},Je=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},Ye=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},et=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},tt=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},rt=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},it=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},at=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},st=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},nt=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}autoInc(){return new e(this.typeBuilder,{...this.columnMetadata,isAutoIncrement:!0})}},ct=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}},ot=class e extends Qe{index(t){return new e(this.typeBuilder,{...this.columnMetadata,indexType:t})}unique(){return new e(this.typeBuilder,{...this.columnMetadata,isUnique:!0})}primaryKey(){return new e(this.typeBuilder,{...this.columnMetadata,isPrimaryKey:!0})}},lt={bool:()=>new Ne,string:()=>new $e,number:()=>new De,i8:()=>new Ve,u8:()=>new xe,i16:()=>new Oe,u16:()=>new Be,i32:()=>new Ce,u32:()=>new Me,i64:()=>new Ee,u64:()=>new qe,i128:()=>new ke,u128:()=>new Fe,i256:()=>new Re,u256:()=>new Pe,f32:()=>new Ke,f64:()=>new De,object:e=>new je(e),array:e=>new Le(e),enum:e=>new We(e),scheduleAt:()=>new Qe(new ve(A.getAlgebraicType()),{...He,isScheduleAt:!0}),identity:()=>new ve(m.getAlgebraicType()),connectionId:()=>new ve(M.getAlgebraicType()),timestamp:()=>new ve(r.getAlgebraicType()),timeDuration:()=>new ve(t.getAlgebraicType())};export{v as AlgebraicType,a as BinaryReader,i as BinaryWriter,he as ClientCache,M as ConnectionId,Se as DbConnectionBuilder,ze as DbConnectionImpl,m as Identity,U as Interval,x as ProductType,w as ProductTypeElement,A as ScheduleAt,Ie as SubscriptionBuilderImpl,B as SumType,f as SumTypeVariant,ge as TableCache,_ as Time,t as TimeDuration,r as Timestamp,n as deepEqual,p as hexStringToU128,d as hexStringToU256,u as hexStringToUint8Array,q as parseValue,lt as t,s as toPascalCase,g as u128ToHexString,y as u128ToUint8Array,b as u256ToHexString,h as u256ToUint8Array,c as uint8ArrayToHexString,o as uint8ArrayToU128,l as uint8ArrayToU256};//# sourceMappingURL=index.browser.mjs.map