holosphere 2.0.0-alpha1 → 2.0.0-alpha10

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 (418) hide show
  1. package/CHANGELOG.md +473 -0
  2. package/FEATURES.md +431 -0
  3. package/LICENSE +29 -166
  4. package/LICENSE-AGPL.md +180 -0
  5. package/README.md +97 -16
  6. package/dist/2019-D2OG2idw.js +6680 -0
  7. package/dist/2019-D2OG2idw.js.map +1 -0
  8. package/dist/2019-EION3wKo.cjs +8 -0
  9. package/dist/2019-EION3wKo.cjs.map +1 -0
  10. package/dist/_commonjsHelpers-C37NGDzP.cjs +2 -0
  11. package/dist/_commonjsHelpers-C37NGDzP.cjs.map +1 -0
  12. package/dist/_commonjsHelpers-CUmg6egw.js +7 -0
  13. package/dist/_commonjsHelpers-CUmg6egw.js.map +1 -0
  14. package/dist/browser-BSniCNqO.js +3058 -0
  15. package/dist/browser-BSniCNqO.js.map +1 -0
  16. package/dist/browser-Cq59Ij19.cjs +2 -0
  17. package/dist/browser-Cq59Ij19.cjs.map +1 -0
  18. package/dist/cdn/holosphere.min.js +55 -0
  19. package/dist/cdn/holosphere.min.js.map +1 -0
  20. package/dist/cjs/holosphere.cjs +2 -0
  21. package/dist/cjs/holosphere.cjs.map +1 -0
  22. package/dist/esm/holosphere.js +53 -0
  23. package/dist/esm/holosphere.js.map +1 -0
  24. package/dist/index-DDGt_V9o.cjs +12 -0
  25. package/dist/index-DDGt_V9o.cjs.map +1 -0
  26. package/dist/index-DJXftyvB.js +39841 -0
  27. package/dist/index-DJXftyvB.js.map +1 -0
  28. package/dist/index-DMbdcMtK.cjs +18 -0
  29. package/dist/index-DMbdcMtK.cjs.map +1 -0
  30. package/dist/index-DeZ1xz_s.js +15104 -0
  31. package/dist/index-DeZ1xz_s.js.map +1 -0
  32. package/dist/indexeddb-storage-BFt6hMeF.js +176 -0
  33. package/dist/indexeddb-storage-BFt6hMeF.js.map +1 -0
  34. package/dist/indexeddb-storage-BK5tv4Sh.cjs +2 -0
  35. package/dist/indexeddb-storage-BK5tv4Sh.cjs.map +1 -0
  36. package/dist/memory-storage-C9HuoL2E.js +91 -0
  37. package/dist/memory-storage-C9HuoL2E.js.map +1 -0
  38. package/dist/memory-storage-Dao7jfYG.cjs +2 -0
  39. package/dist/memory-storage-Dao7jfYG.cjs.map +1 -0
  40. package/dist/secp256k1-BbKzbLtD.cjs +12 -0
  41. package/dist/secp256k1-BbKzbLtD.cjs.map +1 -0
  42. package/dist/secp256k1-CreY7Pcl.js +1890 -0
  43. package/dist/secp256k1-CreY7Pcl.js.map +1 -0
  44. package/docs/CONTRACTS.md +797 -0
  45. package/docs/FOSDEM_PROPOSAL.md +388 -0
  46. package/docs/LOCALFIRST.md +266 -0
  47. package/docs/api/ai_aggregation.js.html +333 -0
  48. package/docs/api/ai_breakdown.js.html +524 -0
  49. package/docs/api/ai_classifier.js.html +231 -0
  50. package/docs/api/ai_council.js.html +246 -0
  51. package/docs/api/ai_embeddings.js.html +304 -0
  52. package/docs/api/ai_federation-ai.js.html +338 -0
  53. package/docs/api/ai_h3-ai.js.html +970 -0
  54. package/docs/api/ai_index.js.html +124 -0
  55. package/docs/api/ai_json-ops.js.html +241 -0
  56. package/docs/api/ai_llm-service.js.html +239 -0
  57. package/docs/api/ai_nl-query.js.html +236 -0
  58. package/docs/api/ai_relationships.js.html +367 -0
  59. package/docs/api/ai_schema-extractor.js.html +235 -0
  60. package/docs/api/ai_spatial.js.html +307 -0
  61. package/docs/api/ai_tts.js.html +214 -0
  62. package/docs/api/content_social-protocols.js.html +180 -0
  63. package/docs/api/core_holosphere.js.html +757 -0
  64. package/docs/api/crypto_nostr-utils.js.html +306 -0
  65. package/docs/api/crypto_secp256k1.js.html +267 -0
  66. package/docs/api/data/search.json +1 -0
  67. package/docs/api/federation_discovery.js.html +337 -0
  68. package/docs/api/federation_handshake.js.html +478 -0
  69. package/docs/api/federation_hologram.js.html +1053 -0
  70. package/docs/api/federation_registry.js.html +389 -0
  71. package/docs/api/fonts/Inconsolata-Regular.ttf +0 -0
  72. package/docs/api/fonts/OpenSans-Regular.ttf +0 -0
  73. package/docs/api/fonts/WorkSans-Bold.ttf +0 -0
  74. package/docs/api/global.html +3 -0
  75. package/docs/api/hierarchical_upcast.js.html +128 -0
  76. package/docs/api/index.html +265 -0
  77. package/docs/api/index.js.html +1868 -0
  78. package/docs/api/lib_ai-methods.js.html +660 -0
  79. package/docs/api/lib_contract-methods.js.html +445 -0
  80. package/docs/api/lib_errors.js.html +56 -0
  81. package/docs/api/lib_federation-methods.js.html +348 -0
  82. package/docs/api/lib_index.js.html +33 -0
  83. package/docs/api/module-ai.html +5 -0
  84. package/docs/api/module-ai_aggregation-SmartAggregation.html +6 -0
  85. package/docs/api/module-ai_aggregation.SmartAggregation.html +3 -0
  86. package/docs/api/module-ai_aggregation.html +3 -0
  87. package/docs/api/module-ai_breakdown-TaskBreakdown.html +5 -0
  88. package/docs/api/module-ai_breakdown.TaskBreakdown.html +3 -0
  89. package/docs/api/module-ai_breakdown.html +3 -0
  90. package/docs/api/module-ai_classifier-Classifier.html +6 -0
  91. package/docs/api/module-ai_classifier.Classifier.html +3 -0
  92. package/docs/api/module-ai_classifier.html +3 -0
  93. package/docs/api/module-ai_council-Council.html +6 -0
  94. package/docs/api/module-ai_council.Council.html +3 -0
  95. package/docs/api/module-ai_council.html +3 -0
  96. package/docs/api/module-ai_embeddings-Embeddings.html +5 -0
  97. package/docs/api/module-ai_embeddings.Embeddings.html +3 -0
  98. package/docs/api/module-ai_embeddings.html +3 -0
  99. package/docs/api/module-ai_federation-ai-FederationAdvisor.html +6 -0
  100. package/docs/api/module-ai_federation-ai.FederationAdvisor.html +3 -0
  101. package/docs/api/module-ai_federation-ai.html +3 -0
  102. package/docs/api/module-ai_h3-ai-H3AI.html +6 -0
  103. package/docs/api/module-ai_h3-ai.H3AI.html +3 -0
  104. package/docs/api/module-ai_h3-ai.html +3 -0
  105. package/docs/api/module-ai_json-ops-JSONOps.html +5 -0
  106. package/docs/api/module-ai_json-ops.JSONOps.html +3 -0
  107. package/docs/api/module-ai_json-ops.html +3 -0
  108. package/docs/api/module-ai_llm-service-LLMService.html +5 -0
  109. package/docs/api/module-ai_llm-service.LLMService.html +3 -0
  110. package/docs/api/module-ai_llm-service.html +3 -0
  111. package/docs/api/module-ai_nl-query-NLQuery.html +5 -0
  112. package/docs/api/module-ai_nl-query.NLQuery.html +3 -0
  113. package/docs/api/module-ai_nl-query.html +3 -0
  114. package/docs/api/module-ai_relationships-RelationshipDiscovery.html +6 -0
  115. package/docs/api/module-ai_relationships.RelationshipDiscovery.html +3 -0
  116. package/docs/api/module-ai_relationships.html +3 -0
  117. package/docs/api/module-ai_schema-extractor-SchemaExtractor.html +5 -0
  118. package/docs/api/module-ai_schema-extractor.SchemaExtractor.html +3 -0
  119. package/docs/api/module-ai_schema-extractor.html +3 -0
  120. package/docs/api/module-ai_spatial-SpatialAnalysis.html +6 -0
  121. package/docs/api/module-ai_spatial.SpatialAnalysis.html +3 -0
  122. package/docs/api/module-ai_spatial.html +3 -0
  123. package/docs/api/module-ai_tts-TTS.html +5 -0
  124. package/docs/api/module-ai_tts.TTS.html +3 -0
  125. package/docs/api/module-ai_tts.html +3 -0
  126. package/docs/api/module-content_social-protocols.html +3 -0
  127. package/docs/api/module-core_holosphere-HoloSphere.html +6 -0
  128. package/docs/api/module-core_holosphere.HoloSphere.html +3 -0
  129. package/docs/api/module-core_holosphere.html +3 -0
  130. package/docs/api/module-crypto_nostr-utils.html +3 -0
  131. package/docs/api/module-crypto_secp256k1.html +3 -0
  132. package/docs/api/module-federation_hologram.html +3 -0
  133. package/docs/api/module-hierarchical_upcast.html +3 -0
  134. package/docs/api/module-holosphere-HoloSphereBase.html +3 -0
  135. package/docs/api/module-holosphere.html +3 -0
  136. package/docs/api/module-lib_ai-methods.html +3 -0
  137. package/docs/api/module-lib_contract-methods.html +3 -0
  138. package/docs/api/module-lib_errors-AuthorizationError.html +3 -0
  139. package/docs/api/module-lib_errors-ValidationError.html +3 -0
  140. package/docs/api/module-lib_errors.AuthorizationError.html +3 -0
  141. package/docs/api/module-lib_errors.ValidationError.html +3 -0
  142. package/docs/api/module-lib_errors.html +3 -0
  143. package/docs/api/module-lib_federation-methods.html +3 -0
  144. package/docs/api/module-lib_index.html +3 -0
  145. package/docs/api/module-schema_validator-ValidationError.html +3 -0
  146. package/docs/api/module-schema_validator.ValidationError.html +3 -0
  147. package/docs/api/module-schema_validator.html +3 -0
  148. package/docs/api/module-spatial_h3-operations.html +4 -0
  149. package/docs/api/module-storage_backend-factory.BackendFactory.html +3 -0
  150. package/docs/api/module-storage_backend-factory.html +3 -0
  151. package/docs/api/module-storage_backend-interface-StorageBackend.html +3 -0
  152. package/docs/api/module-storage_backend-interface.StorageBackend.html +3 -0
  153. package/docs/api/module-storage_backend-interface.html +3 -0
  154. package/docs/api/module-storage_backends_activitypub-backend-ActivityPubBackend.html +7 -0
  155. package/docs/api/module-storage_backends_activitypub-backend.ActivityPubBackend.html +3 -0
  156. package/docs/api/module-storage_backends_activitypub-backend.html +3 -0
  157. package/docs/api/module-storage_backends_activitypub_server-ActivityPubServer.html +8 -0
  158. package/docs/api/module-storage_backends_activitypub_server.ActivityPubServer.html +3 -0
  159. package/docs/api/module-storage_backends_activitypub_server.html +3 -0
  160. package/docs/api/module-storage_backends_gundb-backend-GunDBBackend.html +7 -0
  161. package/docs/api/module-storage_backends_gundb-backend.GunDBBackend.html +3 -0
  162. package/docs/api/module-storage_backends_gundb-backend.html +3 -0
  163. package/docs/api/module-storage_backends_nostr-backend-NostrBackend.html +8 -0
  164. package/docs/api/module-storage_backends_nostr-backend.NostrBackend.html +3 -0
  165. package/docs/api/module-storage_backends_nostr-backend.html +3 -0
  166. package/docs/api/module-storage_filesystem-storage-FileSystemStorage.html +5 -0
  167. package/docs/api/module-storage_filesystem-storage-browser-FileSystemStorage.html +3 -0
  168. package/docs/api/module-storage_filesystem-storage-browser.FileSystemStorage.html +3 -0
  169. package/docs/api/module-storage_filesystem-storage-browser.html +3 -0
  170. package/docs/api/module-storage_filesystem-storage.FileSystemStorage.html +3 -0
  171. package/docs/api/module-storage_filesystem-storage.html +3 -0
  172. package/docs/api/module-storage_global-tables.html +3 -0
  173. package/docs/api/module-storage_gun-async.html +3 -0
  174. package/docs/api/module-storage_gun-auth-GunAuth.html +5 -0
  175. package/docs/api/module-storage_gun-auth.GunAuth.html +3 -0
  176. package/docs/api/module-storage_gun-auth.html +3 -0
  177. package/docs/api/module-storage_gun-federation.html +3 -0
  178. package/docs/api/module-storage_gun-references-GunReferenceHandler.html +5 -0
  179. package/docs/api/module-storage_gun-references.GunReferenceHandler.html +3 -0
  180. package/docs/api/module-storage_gun-references.html +3 -0
  181. package/docs/api/module-storage_gun-schema-GunSchemaValidator.html +5 -0
  182. package/docs/api/module-storage_gun-schema.GunSchemaValidator.html +3 -0
  183. package/docs/api/module-storage_gun-schema.html +3 -0
  184. package/docs/api/module-storage_gun-wrapper.html +11 -0
  185. package/docs/api/module-storage_indexeddb-storage-IndexedDBStorage.html +5 -0
  186. package/docs/api/module-storage_indexeddb-storage.IndexedDBStorage.html +3 -0
  187. package/docs/api/module-storage_indexeddb-storage.html +3 -0
  188. package/docs/api/module-storage_key-storage-simple.html +3 -0
  189. package/docs/api/module-storage_key-storage.html +4 -0
  190. package/docs/api/module-storage_memory-storage-MemoryStorage.html +5 -0
  191. package/docs/api/module-storage_memory-storage.MemoryStorage.html +3 -0
  192. package/docs/api/module-storage_memory-storage.html +3 -0
  193. package/docs/api/module-storage_migration-MigrationTool.html +6 -0
  194. package/docs/api/module-storage_migration.MigrationTool.html +3 -0
  195. package/docs/api/module-storage_migration.html +3 -0
  196. package/docs/api/module-storage_nostr-async.html +18 -0
  197. package/docs/api/module-storage_nostr-client-LRUCache.html +3 -0
  198. package/docs/api/module-storage_nostr-client-NostrClient.html +7 -0
  199. package/docs/api/module-storage_nostr-client.NostrClient.html +15 -0
  200. package/docs/api/module-storage_nostr-client.html +6 -0
  201. package/docs/api/module-storage_nostr-wrapper.html +3 -0
  202. package/docs/api/module-storage_outbox-queue-OutboxQueue.html +4 -0
  203. package/docs/api/module-storage_outbox-queue.OutboxQueue.html +3 -0
  204. package/docs/api/module-storage_outbox-queue.html +3 -0
  205. package/docs/api/module-storage_persistent-storage-PersistentStorage.html +3 -0
  206. package/docs/api/module-storage_persistent-storage.html +4 -0
  207. package/docs/api/module-storage_sync-service-SyncService.html +5 -0
  208. package/docs/api/module-storage_sync-service.SyncService.html +3 -0
  209. package/docs/api/module-storage_sync-service.html +3 -0
  210. package/docs/api/module-storage_unified-storage.html +3 -0
  211. package/docs/api/module-subscriptions_manager.SubscriptionRegistry.html +3 -0
  212. package/docs/api/module-subscriptions_manager.html +3 -0
  213. package/docs/api/schema_validator.js.html +113 -0
  214. package/docs/api/scripts/core.js +726 -0
  215. package/docs/api/scripts/core.min.js +23 -0
  216. package/docs/api/scripts/resize.js +90 -0
  217. package/docs/api/scripts/search.js +265 -0
  218. package/docs/api/scripts/search.min.js +6 -0
  219. package/docs/api/scripts/third-party/Apache-License-2.0.txt +202 -0
  220. package/docs/api/scripts/third-party/fuse.js +9 -0
  221. package/docs/api/scripts/third-party/hljs-line-num-original.js +369 -0
  222. package/docs/api/scripts/third-party/hljs-line-num.js +1 -0
  223. package/docs/api/scripts/third-party/hljs-original.js +5171 -0
  224. package/docs/api/scripts/third-party/hljs.js +1 -0
  225. package/docs/api/scripts/third-party/popper.js +5 -0
  226. package/docs/api/scripts/third-party/tippy.js +1 -0
  227. package/docs/api/scripts/third-party/tocbot.js +672 -0
  228. package/docs/api/scripts/third-party/tocbot.min.js +1 -0
  229. package/docs/api/spatial_h3-operations.js.html +129 -0
  230. package/docs/api/storage_backend-factory.js.html +133 -0
  231. package/docs/api/storage_backend-interface.js.html +164 -0
  232. package/docs/api/storage_backends_activitypub-backend.js.html +298 -0
  233. package/docs/api/storage_backends_activitypub_server.js.html +678 -0
  234. package/docs/api/storage_backends_gundb-backend.js.html +878 -0
  235. package/docs/api/storage_backends_nostr-backend.js.html +254 -0
  236. package/docs/api/storage_filesystem-storage-browser.js.html +83 -0
  237. package/docs/api/storage_filesystem-storage.js.html +207 -0
  238. package/docs/api/storage_global-tables.js.html +116 -0
  239. package/docs/api/storage_gun-async.js.html +344 -0
  240. package/docs/api/storage_gun-auth.js.html +376 -0
  241. package/docs/api/storage_gun-federation.js.html +788 -0
  242. package/docs/api/storage_gun-references.js.html +212 -0
  243. package/docs/api/storage_gun-schema.js.html +309 -0
  244. package/docs/api/storage_gun-wrapper.js.html +645 -0
  245. package/docs/api/storage_indexeddb-storage.js.html +224 -0
  246. package/docs/api/storage_key-storage-simple.js.html +102 -0
  247. package/docs/api/storage_key-storage.js.html +171 -0
  248. package/docs/api/storage_memory-storage.js.html +128 -0
  249. package/docs/api/storage_migration.js.html +354 -0
  250. package/docs/api/storage_nostr-async.js.html +1076 -0
  251. package/docs/api/storage_nostr-client.js.html +1598 -0
  252. package/docs/api/storage_nostr-wrapper.js.html +218 -0
  253. package/docs/api/storage_outbox-queue.js.html +248 -0
  254. package/docs/api/storage_persistent-storage.js.html +160 -0
  255. package/docs/api/storage_sync-service.js.html +201 -0
  256. package/docs/api/storage_unified-storage.js.html +157 -0
  257. package/docs/api/styles/clean-jsdoc-theme-base.css +1159 -0
  258. package/docs/api/styles/clean-jsdoc-theme-dark.css +412 -0
  259. package/docs/api/styles/clean-jsdoc-theme-light.css +482 -0
  260. package/docs/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  261. package/docs/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  262. package/docs/api/styles/clean-jsdoc-theme.min.css +1 -0
  263. package/docs/api/subscriptions_manager.js.html +162 -0
  264. package/docs/contracts/api-interface.md +793 -0
  265. package/docs/data-model.md +476 -0
  266. package/docs/gun-async-usage.md +338 -0
  267. package/docs/plan.md +349 -0
  268. package/docs/quickstart.md +674 -0
  269. package/docs/research.md +362 -0
  270. package/docs/spec.md +244 -0
  271. package/docs/storage-backends.md +326 -0
  272. package/docs/tasks.md +947 -0
  273. package/examples/demo.html +47 -0
  274. package/examples/holosphere-widget.js +1242 -0
  275. package/examples/widget-demo.html +274 -0
  276. package/examples/widget.html +703 -0
  277. package/jsdoc.json +26 -0
  278. package/package.json +25 -7
  279. package/src/ai/aggregation.js +13 -2
  280. package/src/ai/breakdown.js +12 -2
  281. package/src/ai/classifier.js +14 -3
  282. package/src/ai/council.js +22 -7
  283. package/src/ai/embeddings.js +37 -15
  284. package/src/ai/federation-ai.js +13 -2
  285. package/src/ai/h3-ai.js +14 -2
  286. package/src/ai/index.js +16 -7
  287. package/src/ai/json-ops.js +18 -5
  288. package/src/ai/llm-service.js +62 -31
  289. package/src/ai/nl-query.js +12 -2
  290. package/src/ai/relationships.js +13 -2
  291. package/src/ai/schema-extractor.js +24 -10
  292. package/src/ai/spatial.js +13 -2
  293. package/src/ai/tts.js +25 -8
  294. package/src/cdn-entry.js +22 -0
  295. package/src/content/social-protocols.js +34 -25
  296. package/src/contracts/abis/Appreciative.json +1280 -0
  297. package/src/contracts/abis/AppreciativeFactory.json +101 -0
  298. package/src/contracts/abis/Bundle.json +1438 -0
  299. package/src/contracts/abis/BundleFactory.json +106 -0
  300. package/src/contracts/abis/Holon.json +881 -0
  301. package/src/contracts/abis/Holons.json +330 -0
  302. package/src/contracts/abis/Managed.json +1262 -0
  303. package/src/contracts/abis/ManagedFactory.json +149 -0
  304. package/src/contracts/abis/Membrane.json +261 -0
  305. package/src/contracts/abis/Splitter.json +1624 -0
  306. package/src/contracts/abis/SplitterFactory.json +220 -0
  307. package/src/contracts/abis/TestToken.json +321 -0
  308. package/src/contracts/abis/Zoned.json +1461 -0
  309. package/src/contracts/abis/ZonedFactory.json +154 -0
  310. package/src/contracts/chain-manager.js +403 -0
  311. package/src/contracts/deployer.js +500 -0
  312. package/src/contracts/event-listener.js +539 -0
  313. package/src/contracts/holon-contracts.js +359 -0
  314. package/src/contracts/index.js +82 -0
  315. package/src/contracts/networks.js +229 -0
  316. package/src/contracts/operations.js +687 -0
  317. package/src/contracts/queries.js +638 -0
  318. package/src/core/holosphere.js +487 -6
  319. package/src/crypto/nostr-utils.js +303 -0
  320. package/src/crypto/secp256k1.js +7 -2
  321. package/src/federation/handshake.js +475 -0
  322. package/src/federation/hologram.js +117 -3
  323. package/src/hierarchical/upcast.js +40 -25
  324. package/src/index.js +1501 -1909
  325. package/src/lib/ai-methods.js +657 -0
  326. package/src/lib/contract-methods.js +442 -0
  327. package/src/lib/errors.js +53 -0
  328. package/src/lib/federation-methods.js +345 -0
  329. package/src/lib/index.js +30 -0
  330. package/src/schema/validator.js +22 -3
  331. package/src/spatial/h3-operations.js +19 -3
  332. package/src/storage/backend-factory.js +7 -2
  333. package/src/storage/backend-interface.js +21 -2
  334. package/src/storage/backends/activitypub/server.js +25 -3
  335. package/src/storage/backends/activitypub-backend.js +25 -2
  336. package/src/storage/backends/gundb-backend.js +692 -50
  337. package/src/storage/backends/nostr-backend.js +116 -1
  338. package/src/storage/filesystem-storage-browser.js +42 -2
  339. package/src/storage/filesystem-storage.js +72 -5
  340. package/src/storage/global-tables.js +35 -3
  341. package/src/storage/gun-async.js +75 -15
  342. package/src/storage/gun-auth.js +373 -0
  343. package/src/storage/gun-federation.js +785 -0
  344. package/src/storage/gun-references.js +209 -0
  345. package/src/storage/gun-schema.js +306 -0
  346. package/src/storage/gun-wrapper.js +475 -54
  347. package/src/storage/indexeddb-storage.js +112 -13
  348. package/src/storage/key-storage-simple.js +32 -9
  349. package/src/storage/key-storage.js +45 -13
  350. package/src/storage/memory-storage.js +68 -2
  351. package/src/storage/migration.js +20 -7
  352. package/src/storage/nostr-async.js +412 -122
  353. package/src/storage/nostr-client.js +749 -76
  354. package/src/storage/nostr-wrapper.js +6 -2
  355. package/src/storage/outbox-queue.js +55 -18
  356. package/src/storage/persistent-storage.js +62 -14
  357. package/src/storage/sync-service.js +51 -17
  358. package/src/storage/unified-storage.js +154 -0
  359. package/src/subscriptions/manager.js +34 -17
  360. package/types/index.d.ts +133 -0
  361. package/vite.config.cdn.js +60 -0
  362. package/tests/unit/ai/aggregation.test.js +0 -295
  363. package/tests/unit/ai/breakdown.test.js +0 -446
  364. package/tests/unit/ai/classifier.test.js +0 -294
  365. package/tests/unit/ai/council.test.js +0 -262
  366. package/tests/unit/ai/embeddings.test.js +0 -384
  367. package/tests/unit/ai/federation-ai.test.js +0 -344
  368. package/tests/unit/ai/h3-ai.test.js +0 -458
  369. package/tests/unit/ai/index.test.js +0 -304
  370. package/tests/unit/ai/json-ops.test.js +0 -307
  371. package/tests/unit/ai/llm-service.test.js +0 -390
  372. package/tests/unit/ai/nl-query.test.js +0 -383
  373. package/tests/unit/ai/relationships.test.js +0 -311
  374. package/tests/unit/ai/schema-extractor.test.js +0 -384
  375. package/tests/unit/ai/spatial.test.js +0 -279
  376. package/tests/unit/ai/tts.test.js +0 -279
  377. package/tests/unit/content.test.js +0 -332
  378. package/tests/unit/contract/core.test.js +0 -88
  379. package/tests/unit/contract/crypto.test.js +0 -198
  380. package/tests/unit/contract/data.test.js +0 -223
  381. package/tests/unit/contract/federation.test.js +0 -181
  382. package/tests/unit/contract/hierarchical.test.js +0 -113
  383. package/tests/unit/contract/schema.test.js +0 -114
  384. package/tests/unit/contract/social.test.js +0 -217
  385. package/tests/unit/contract/spatial.test.js +0 -110
  386. package/tests/unit/contract/subscriptions.test.js +0 -128
  387. package/tests/unit/contract/utils.test.js +0 -159
  388. package/tests/unit/core.test.js +0 -152
  389. package/tests/unit/crypto.test.js +0 -328
  390. package/tests/unit/federation.test.js +0 -234
  391. package/tests/unit/gun-async.test.js +0 -252
  392. package/tests/unit/hierarchical.test.js +0 -399
  393. package/tests/unit/integration/scenario-01-geographic-storage.test.js +0 -74
  394. package/tests/unit/integration/scenario-02-federation.test.js +0 -76
  395. package/tests/unit/integration/scenario-03-subscriptions.test.js +0 -102
  396. package/tests/unit/integration/scenario-04-validation.test.js +0 -129
  397. package/tests/unit/integration/scenario-05-hierarchy.test.js +0 -125
  398. package/tests/unit/integration/scenario-06-social.test.js +0 -135
  399. package/tests/unit/integration/scenario-07-persistence.test.js +0 -130
  400. package/tests/unit/integration/scenario-08-authorization.test.js +0 -161
  401. package/tests/unit/integration/scenario-09-cross-dimensional.test.js +0 -139
  402. package/tests/unit/integration/scenario-10-cross-holosphere-capabilities.test.js +0 -357
  403. package/tests/unit/integration/scenario-11-cross-holosphere-federation.test.js +0 -410
  404. package/tests/unit/integration/scenario-12-capability-federated-read.test.js +0 -719
  405. package/tests/unit/performance/benchmark.test.js +0 -85
  406. package/tests/unit/schema.test.js +0 -213
  407. package/tests/unit/spatial.test.js +0 -158
  408. package/tests/unit/storage.test.js +0 -195
  409. package/tests/unit/subscriptions.test.js +0 -328
  410. package/tests/unit/test-data-permanence-debug.js +0 -197
  411. package/tests/unit/test-data-permanence.js +0 -340
  412. package/tests/unit/test-key-persistence-fixed.js +0 -148
  413. package/tests/unit/test-key-persistence.js +0 -172
  414. package/tests/unit/test-relay-permanence.js +0 -376
  415. package/tests/unit/test-second-node.js +0 -95
  416. package/tests/unit/test-simple-write.js +0 -89
  417. /package/{cleanup-test-data.js → scripts/cleanup-test-data.js} +0 -0
  418. /package/{test-ai-real-api.js → scripts/test-ai-real-api.js} +0 -0
@@ -0,0 +1,176 @@
1
+ import { aZ as PersistentStorage } from "./index-DJXftyvB.js";
2
+ class IndexedDBStorage extends PersistentStorage {
3
+ /**
4
+ * Create a new IndexedDBStorage instance.
5
+ */
6
+ constructor() {
7
+ super();
8
+ this.db = null;
9
+ this.dbName = "";
10
+ this.storeName = "events";
11
+ }
12
+ /**
13
+ * Initialize storage with namespace.
14
+ *
15
+ * Creates or opens the IndexedDB database and object store.
16
+ *
17
+ * @param {string} namespace - Storage namespace
18
+ * @returns {Promise<void>}
19
+ */
20
+ async init(namespace) {
21
+ this.dbName = `holosphere_${namespace}`;
22
+ return new Promise((resolve, reject) => {
23
+ const request = indexedDB.open(this.dbName, 1);
24
+ request.onerror = () => reject(request.error);
25
+ request.onsuccess = () => {
26
+ this.db = request.result;
27
+ resolve(void 0);
28
+ };
29
+ request.onupgradeneeded = (event) => {
30
+ const target = (
31
+ /** @type {IDBOpenDBRequest} */
32
+ event.target
33
+ );
34
+ const db = target.result;
35
+ if (!db.objectStoreNames.contains(this.storeName)) {
36
+ const objectStore = db.createObjectStore(this.storeName, { keyPath: "key" });
37
+ objectStore.createIndex("key", "key", { unique: false });
38
+ }
39
+ };
40
+ });
41
+ }
42
+ /**
43
+ * Store an event.
44
+ *
45
+ * @param {string} key - Storage key
46
+ * @param {Object} event - Event data
47
+ * @returns {Promise<void>}
48
+ */
49
+ async put(key, event) {
50
+ return new Promise((resolve, reject) => {
51
+ if (!this.db) {
52
+ reject(new Error("Database not initialized"));
53
+ return;
54
+ }
55
+ const transaction = this.db.transaction([this.storeName], "readwrite");
56
+ const objectStore = transaction.objectStore(this.storeName);
57
+ const request = objectStore.put({ key, event, timestamp: Date.now() });
58
+ request.onsuccess = () => resolve(void 0);
59
+ request.onerror = () => reject(request.error);
60
+ });
61
+ }
62
+ /**
63
+ * Retrieve an event.
64
+ *
65
+ * @param {string} key - Storage key
66
+ * @returns {Promise<Object|null>} Event data or null
67
+ */
68
+ async get(key) {
69
+ return new Promise((resolve, reject) => {
70
+ if (!this.db) {
71
+ reject(new Error("Database not initialized"));
72
+ return;
73
+ }
74
+ const transaction = this.db.transaction([this.storeName], "readonly");
75
+ const objectStore = transaction.objectStore(this.storeName);
76
+ const request = objectStore.get(key);
77
+ request.onsuccess = () => {
78
+ const result = request.result;
79
+ resolve(result ? result.event : null);
80
+ };
81
+ request.onerror = () => reject(request.error);
82
+ });
83
+ }
84
+ /**
85
+ * Retrieve all events matching a prefix.
86
+ *
87
+ * Uses IDBKeyRange for efficient B-tree index queries.
88
+ *
89
+ * @param {string} prefix - Key prefix to match
90
+ * @returns {Promise<any[]>} Array of matching events
91
+ */
92
+ async getAll(prefix) {
93
+ return new Promise((resolve, reject) => {
94
+ if (!this.db) {
95
+ reject(new Error("Database not initialized"));
96
+ return;
97
+ }
98
+ const transaction = this.db.transaction([this.storeName], "readonly");
99
+ const objectStore = transaction.objectStore(this.storeName);
100
+ const results = [];
101
+ let request;
102
+ if (prefix) {
103
+ const range = IDBKeyRange.bound(prefix, prefix + "￿", false, false);
104
+ request = objectStore.openCursor(range);
105
+ } else {
106
+ request = objectStore.openCursor();
107
+ }
108
+ request.onsuccess = (event) => {
109
+ const target = (
110
+ /** @type {IDBRequest} */
111
+ event.target
112
+ );
113
+ const cursor = target.result;
114
+ if (cursor) {
115
+ results.push(cursor.value.event);
116
+ cursor.continue();
117
+ } else {
118
+ resolve(results);
119
+ }
120
+ };
121
+ request.onerror = () => reject(request.error);
122
+ });
123
+ }
124
+ /**
125
+ * Delete an event.
126
+ *
127
+ * @param {string} key - Storage key
128
+ * @returns {Promise<void>}
129
+ */
130
+ async delete(key) {
131
+ return new Promise((resolve, reject) => {
132
+ if (!this.db) {
133
+ reject(new Error("Database not initialized"));
134
+ return;
135
+ }
136
+ const transaction = this.db.transaction([this.storeName], "readwrite");
137
+ const objectStore = transaction.objectStore(this.storeName);
138
+ const request = objectStore.delete(key);
139
+ request.onsuccess = () => resolve(void 0);
140
+ request.onerror = () => reject(request.error);
141
+ });
142
+ }
143
+ /**
144
+ * Clear all stored events.
145
+ *
146
+ * @returns {Promise<void>}
147
+ */
148
+ async clear() {
149
+ return new Promise((resolve, reject) => {
150
+ if (!this.db) {
151
+ reject(new Error("Database not initialized"));
152
+ return;
153
+ }
154
+ const transaction = this.db.transaction([this.storeName], "readwrite");
155
+ const objectStore = transaction.objectStore(this.storeName);
156
+ const request = objectStore.clear();
157
+ request.onsuccess = () => resolve(void 0);
158
+ request.onerror = () => reject(request.error);
159
+ });
160
+ }
161
+ /**
162
+ * Close the database connection.
163
+ *
164
+ * @returns {Promise<void>}
165
+ */
166
+ async close() {
167
+ if (this.db) {
168
+ this.db.close();
169
+ this.db = null;
170
+ }
171
+ }
172
+ }
173
+ export {
174
+ IndexedDBStorage
175
+ };
176
+ //# sourceMappingURL=indexeddb-storage-BFt6hMeF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexeddb-storage-BFt6hMeF.js","sources":["../src/storage/indexeddb-storage.js"],"sourcesContent":["/**\n * @fileoverview IndexedDB storage adapter for browsers.\n *\n * Provides persistent storage with good performance using browser IndexedDB.\n * Uses B-tree indexes for efficient prefix queries.\n *\n * @module storage/indexeddb-storage\n */\n\nimport { PersistentStorage } from './persistent-storage.js';\n\n/**\n * IndexedDB storage adapter for browsers.\n *\n * Provides high-performance persistent storage using IndexedDB with efficient prefix queries.\n *\n * @class IndexedDBStorage\n * @extends PersistentStorage\n * @example\n * const storage = new IndexedDBStorage();\n * await storage.init('myapp');\n * await storage.put('key1', { id: 'event1', content: 'test' });\n */\nexport class IndexedDBStorage extends PersistentStorage {\n /**\n * Create a new IndexedDBStorage instance.\n */\n constructor() {\n super();\n /** @type {IDBDatabase|null} */\n this.db = null;\n /** @type {string} */\n this.dbName = '';\n /** @type {string} */\n this.storeName = 'events';\n }\n\n /**\n * Initialize storage with namespace.\n *\n * Creates or opens the IndexedDB database and object store.\n *\n * @param {string} namespace - Storage namespace\n * @returns {Promise<void>}\n */\n async init(namespace) {\n this.dbName = `holosphere_${namespace}`;\n\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.dbName, 1);\n\n request.onerror = () => reject(request.error);\n request.onsuccess = () => {\n this.db = request.result;\n resolve(undefined);\n };\n\n request.onupgradeneeded = (event) => {\n const target = /** @type {IDBOpenDBRequest} */ (event.target);\n const db = target.result;\n\n // Create object store if it doesn't exist\n if (!db.objectStoreNames.contains(this.storeName)) {\n const objectStore = db.createObjectStore(this.storeName, { keyPath: 'key' });\n // Create index for prefix queries\n objectStore.createIndex('key', 'key', { unique: false });\n }\n };\n });\n }\n\n /**\n * Store an event.\n *\n * @param {string} key - Storage key\n * @param {Object} event - Event data\n * @returns {Promise<void>}\n */\n async put(key, event) {\n return new Promise((resolve, reject) => {\n if (!this.db) {\n reject(new Error('Database not initialized'));\n return;\n }\n const transaction = this.db.transaction([this.storeName], 'readwrite');\n const objectStore = transaction.objectStore(this.storeName);\n\n const request = objectStore.put({ key, event, timestamp: Date.now() });\n\n request.onsuccess = () => resolve(undefined);\n request.onerror = () => reject(request.error);\n });\n }\n\n /**\n * Retrieve an event.\n *\n * @param {string} key - Storage key\n * @returns {Promise<Object|null>} Event data or null\n */\n async get(key) {\n return new Promise((resolve, reject) => {\n if (!this.db) {\n reject(new Error('Database not initialized'));\n return;\n }\n const transaction = this.db.transaction([this.storeName], 'readonly');\n const objectStore = transaction.objectStore(this.storeName);\n\n const request = objectStore.get(key);\n\n request.onsuccess = () => {\n const result = request.result;\n resolve(result ? result.event : null);\n };\n request.onerror = () => reject(request.error);\n });\n }\n\n /**\n * Retrieve all events matching a prefix.\n *\n * Uses IDBKeyRange for efficient B-tree index queries.\n *\n * @param {string} prefix - Key prefix to match\n * @returns {Promise<any[]>} Array of matching events\n */\n async getAll(prefix) {\n return new Promise((resolve, reject) => {\n if (!this.db) {\n reject(new Error('Database not initialized'));\n return;\n }\n const transaction = this.db.transaction([this.storeName], 'readonly');\n const objectStore = transaction.objectStore(this.storeName);\n\n /** @type {any[]} */\n const results = [];\n\n // Use IDBKeyRange for efficient prefix query instead of full table scan\n // This creates a range from \"prefix\" to \"prefix\\uffff\" (highest unicode char)\n // which efficiently uses the B-tree index\n let request;\n if (prefix) {\n const range = IDBKeyRange.bound(prefix, prefix + '\\uffff', false, false);\n request = objectStore.openCursor(range);\n } else {\n // No prefix = get all\n request = objectStore.openCursor();\n }\n\n request.onsuccess = (event) => {\n const target = /** @type {IDBRequest} */ (event.target);\n const cursor = target.result;\n if (cursor) {\n results.push(cursor.value.event);\n cursor.continue();\n } else {\n resolve(results);\n }\n };\n\n request.onerror = () => reject(request.error);\n });\n }\n\n /**\n * Delete an event.\n *\n * @param {string} key - Storage key\n * @returns {Promise<void>}\n */\n async delete(key) {\n return new Promise((resolve, reject) => {\n if (!this.db) {\n reject(new Error('Database not initialized'));\n return;\n }\n const transaction = this.db.transaction([this.storeName], 'readwrite');\n const objectStore = transaction.objectStore(this.storeName);\n\n const request = objectStore.delete(key);\n\n request.onsuccess = () => resolve(undefined);\n request.onerror = () => reject(request.error);\n });\n }\n\n /**\n * Clear all stored events.\n *\n * @returns {Promise<void>}\n */\n async clear() {\n return new Promise((resolve, reject) => {\n if (!this.db) {\n reject(new Error('Database not initialized'));\n return;\n }\n const transaction = this.db.transaction([this.storeName], 'readwrite');\n const objectStore = transaction.objectStore(this.storeName);\n\n const request = objectStore.clear();\n\n request.onsuccess = () => resolve(undefined);\n request.onerror = () => reject(request.error);\n });\n }\n\n /**\n * Close the database connection.\n *\n * @returns {Promise<void>}\n */\n async close() {\n if (this.db) {\n this.db.close();\n this.db = null;\n }\n }\n}\n"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DMbdcMtK.cjs");class t extends e.PersistentStorage{constructor(){super(),this.db=null,this.dbName="",this.storeName="events"}async init(e){return this.dbName=`holosphere_${e}`,new Promise((e,t)=>{const r=indexedDB.open(this.dbName,1);r.onerror=()=>t(r.error),r.onsuccess=()=>{this.db=r.result,e(void 0)},r.onupgradeneeded=e=>{const t=e.target.result;if(!t.objectStoreNames.contains(this.storeName)){t.createObjectStore(this.storeName,{keyPath:"key"}).createIndex("key","key",{unique:!1})}}})}async put(e,t){return new Promise((r,s)=>{if(!this.db)return void s(new Error("Database not initialized"));const o=this.db.transaction([this.storeName],"readwrite").objectStore(this.storeName).put({key:e,event:t,timestamp:Date.now()});o.onsuccess=()=>r(void 0),o.onerror=()=>s(o.error)})}async get(e){return new Promise((t,r)=>{if(!this.db)return void r(new Error("Database not initialized"));const s=this.db.transaction([this.storeName],"readonly").objectStore(this.storeName).get(e);s.onsuccess=()=>{const e=s.result;t(e?e.event:null)},s.onerror=()=>r(s.error)})}async getAll(e){return new Promise((t,r)=>{if(!this.db)return void r(new Error("Database not initialized"));const s=this.db.transaction([this.storeName],"readonly").objectStore(this.storeName),o=[];let n;if(e){const t=IDBKeyRange.bound(e,e+"￿",!1,!1);n=s.openCursor(t)}else n=s.openCursor();n.onsuccess=e=>{const r=e.target.result;r?(o.push(r.value.event),r.continue()):t(o)},n.onerror=()=>r(n.error)})}async delete(e){return new Promise((t,r)=>{if(!this.db)return void r(new Error("Database not initialized"));const s=this.db.transaction([this.storeName],"readwrite").objectStore(this.storeName).delete(e);s.onsuccess=()=>t(void 0),s.onerror=()=>r(s.error)})}async clear(){return new Promise((e,t)=>{if(!this.db)return void t(new Error("Database not initialized"));const r=this.db.transaction([this.storeName],"readwrite").objectStore(this.storeName).clear();r.onsuccess=()=>e(void 0),r.onerror=()=>t(r.error)})}async close(){this.db&&(this.db.close(),this.db=null)}}exports.IndexedDBStorage=t;
2
+ //# sourceMappingURL=indexeddb-storage-BK5tv4Sh.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexeddb-storage-BK5tv4Sh.cjs","sources":["../src/storage/indexeddb-storage.js"],"sourcesContent":["/**\n * @fileoverview IndexedDB storage adapter for browsers.\n *\n * Provides persistent storage with good performance using browser IndexedDB.\n * Uses B-tree indexes for efficient prefix queries.\n *\n * @module storage/indexeddb-storage\n */\n\nimport { PersistentStorage } from './persistent-storage.js';\n\n/**\n * IndexedDB storage adapter for browsers.\n *\n * Provides high-performance persistent storage using IndexedDB with efficient prefix queries.\n *\n * @class IndexedDBStorage\n * @extends PersistentStorage\n * @example\n * const storage = new IndexedDBStorage();\n * await storage.init('myapp');\n * await storage.put('key1', { id: 'event1', content: 'test' });\n */\nexport class IndexedDBStorage extends PersistentStorage {\n /**\n * Create a new IndexedDBStorage instance.\n */\n constructor() {\n super();\n /** @type {IDBDatabase|null} */\n this.db = null;\n /** @type {string} */\n this.dbName = '';\n /** @type {string} */\n this.storeName = 'events';\n }\n\n /**\n * Initialize storage with namespace.\n *\n * Creates or opens the IndexedDB database and object store.\n *\n * @param {string} namespace - Storage namespace\n * @returns {Promise<void>}\n */\n async init(namespace) {\n this.dbName = `holosphere_${namespace}`;\n\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.dbName, 1);\n\n request.onerror = () => reject(request.error);\n request.onsuccess = () => {\n this.db = request.result;\n resolve(undefined);\n };\n\n request.onupgradeneeded = (event) => {\n const target = /** @type {IDBOpenDBRequest} */ (event.target);\n const db = target.result;\n\n // Create object store if it doesn't exist\n if (!db.objectStoreNames.contains(this.storeName)) {\n const objectStore = db.createObjectStore(this.storeName, { keyPath: 'key' });\n // Create index for prefix queries\n objectStore.createIndex('key', 'key', { unique: false });\n }\n };\n });\n }\n\n /**\n * Store an event.\n *\n * @param {string} key - Storage key\n * @param {Object} event - Event data\n * @returns {Promise<void>}\n */\n async put(key, event) {\n return new Promise((resolve, reject) => {\n if (!this.db) {\n reject(new Error('Database not initialized'));\n return;\n }\n const transaction = this.db.transaction([this.storeName], 'readwrite');\n const objectStore = transaction.objectStore(this.storeName);\n\n const request = objectStore.put({ key, event, timestamp: Date.now() });\n\n request.onsuccess = () => resolve(undefined);\n request.onerror = () => reject(request.error);\n });\n }\n\n /**\n * Retrieve an event.\n *\n * @param {string} key - Storage key\n * @returns {Promise<Object|null>} Event data or null\n */\n async get(key) {\n return new Promise((resolve, reject) => {\n if (!this.db) {\n reject(new Error('Database not initialized'));\n return;\n }\n const transaction = this.db.transaction([this.storeName], 'readonly');\n const objectStore = transaction.objectStore(this.storeName);\n\n const request = objectStore.get(key);\n\n request.onsuccess = () => {\n const result = request.result;\n resolve(result ? result.event : null);\n };\n request.onerror = () => reject(request.error);\n });\n }\n\n /**\n * Retrieve all events matching a prefix.\n *\n * Uses IDBKeyRange for efficient B-tree index queries.\n *\n * @param {string} prefix - Key prefix to match\n * @returns {Promise<any[]>} Array of matching events\n */\n async getAll(prefix) {\n return new Promise((resolve, reject) => {\n if (!this.db) {\n reject(new Error('Database not initialized'));\n return;\n }\n const transaction = this.db.transaction([this.storeName], 'readonly');\n const objectStore = transaction.objectStore(this.storeName);\n\n /** @type {any[]} */\n const results = [];\n\n // Use IDBKeyRange for efficient prefix query instead of full table scan\n // This creates a range from \"prefix\" to \"prefix\\uffff\" (highest unicode char)\n // which efficiently uses the B-tree index\n let request;\n if (prefix) {\n const range = IDBKeyRange.bound(prefix, prefix + '\\uffff', false, false);\n request = objectStore.openCursor(range);\n } else {\n // No prefix = get all\n request = objectStore.openCursor();\n }\n\n request.onsuccess = (event) => {\n const target = /** @type {IDBRequest} */ (event.target);\n const cursor = target.result;\n if (cursor) {\n results.push(cursor.value.event);\n cursor.continue();\n } else {\n resolve(results);\n }\n };\n\n request.onerror = () => reject(request.error);\n });\n }\n\n /**\n * Delete an event.\n *\n * @param {string} key - Storage key\n * @returns {Promise<void>}\n */\n async delete(key) {\n return new Promise((resolve, reject) => {\n if (!this.db) {\n reject(new Error('Database not initialized'));\n return;\n }\n const transaction = this.db.transaction([this.storeName], 'readwrite');\n const objectStore = transaction.objectStore(this.storeName);\n\n const request = objectStore.delete(key);\n\n request.onsuccess = () => resolve(undefined);\n request.onerror = () => reject(request.error);\n });\n }\n\n /**\n * Clear all stored events.\n *\n * @returns {Promise<void>}\n */\n async clear() {\n return new Promise((resolve, reject) => {\n if (!this.db) {\n reject(new Error('Database not initialized'));\n return;\n }\n const transaction = this.db.transaction([this.storeName], 'readwrite');\n const objectStore = transaction.objectStore(this.storeName);\n\n const request = objectStore.clear();\n\n request.onsuccess = () => resolve(undefined);\n request.onerror = () => reject(request.error);\n });\n }\n\n /**\n * Close the database connection.\n *\n * @returns {Promise<void>}\n */\n async close() {\n if (this.db) {\n this.db.close();\n this.db = null;\n }\n }\n}\n"],"names":["IndexedDBStorage","PersistentStorage","constructor","super","this","db","dbName","storeName","init","namespace","Promise","resolve","reject","request","indexedDB","open","onerror","error","onsuccess","result","onupgradeneeded","event","objectStoreNames","contains","createObjectStore","keyPath","createIndex","unique","put","key","Error","transaction","objectStore","timestamp","Date","now","get","getAll","prefix","results","range","IDBKeyRange","bound","openCursor","cursor","push","value","continue","delete","clear","close"],"mappings":"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"}
@@ -0,0 +1,91 @@
1
+ import { aZ as PersistentStorage } from "./index-DJXftyvB.js";
2
+ class MemoryStorage extends PersistentStorage {
3
+ /**
4
+ * Create a new MemoryStorage instance.
5
+ */
6
+ constructor() {
7
+ super();
8
+ this.data = /* @__PURE__ */ new Map();
9
+ this.namespace = null;
10
+ }
11
+ /**
12
+ * Initialize storage with namespace.
13
+ *
14
+ * @param {string} namespace - Storage namespace
15
+ * @returns {Promise<void>}
16
+ */
17
+ async init(namespace) {
18
+ this.namespace = namespace;
19
+ if (!MemoryStorage._globalStore) {
20
+ MemoryStorage._globalStore = /* @__PURE__ */ new Map();
21
+ }
22
+ if (!MemoryStorage._globalStore.has(namespace)) {
23
+ MemoryStorage._globalStore.set(namespace, /* @__PURE__ */ new Map());
24
+ }
25
+ this.data = MemoryStorage._globalStore.get(namespace);
26
+ }
27
+ /**
28
+ * Store an event.
29
+ *
30
+ * @param {string} key - Storage key
31
+ * @param {Object} event - Event data
32
+ * @returns {Promise<void>}
33
+ */
34
+ async put(key, event) {
35
+ this.data.set(key, JSON.parse(JSON.stringify(event)));
36
+ }
37
+ /**
38
+ * Retrieve an event.
39
+ *
40
+ * @param {string} key - Storage key
41
+ * @returns {Promise<Object|null>} Event data or null
42
+ */
43
+ async get(key) {
44
+ const data = this.data.get(key);
45
+ return data ? JSON.parse(JSON.stringify(data)) : null;
46
+ }
47
+ /**
48
+ * Retrieve all events matching a prefix.
49
+ *
50
+ * @param {string} prefix - Key prefix to match
51
+ * @returns {Promise<any[]>} Array of matching events
52
+ */
53
+ async getAll(prefix) {
54
+ const results = [];
55
+ for (const [key, value] of this.data.entries()) {
56
+ if (key.startsWith(prefix)) {
57
+ results.push(JSON.parse(JSON.stringify(value)));
58
+ }
59
+ }
60
+ return results;
61
+ }
62
+ /**
63
+ * Delete an event.
64
+ *
65
+ * @param {string} key - Storage key
66
+ * @returns {Promise<void>}
67
+ */
68
+ async delete(key) {
69
+ this.data.delete(key);
70
+ }
71
+ /**
72
+ * Clear all stored events.
73
+ *
74
+ * @returns {Promise<void>}
75
+ */
76
+ async clear() {
77
+ this.data.clear();
78
+ }
79
+ /**
80
+ * Close storage (no-op for memory storage).
81
+ *
82
+ * @returns {Promise<void>}
83
+ */
84
+ async close() {
85
+ }
86
+ }
87
+ MemoryStorage._globalStore = null;
88
+ export {
89
+ MemoryStorage
90
+ };
91
+ //# sourceMappingURL=memory-storage-C9HuoL2E.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-storage-C9HuoL2E.js","sources":["../src/storage/memory-storage.js"],"sourcesContent":["/**\n * @fileoverview Memory-only storage adapter (fallback, no actual persistence).\n *\n * Provides in-memory storage for testing or when persistent storage is unavailable.\n * Data is shared across instances with the same namespace but lost on process restart.\n *\n * @module storage/memory-storage\n */\n\nimport { PersistentStorage } from './persistent-storage.js';\n\n/**\n * Memory-only storage adapter.\n *\n * Stores data in memory with no persistence across restarts.\n * Uses a global store to share data across instances with same namespace.\n *\n * @class MemoryStorage\n * @extends PersistentStorage\n * @example\n * const storage = new MemoryStorage();\n * await storage.init('myapp');\n * await storage.put('key1', { id: 'event1' });\n */\nexport class MemoryStorage extends PersistentStorage {\n /**\n * Create a new MemoryStorage instance.\n */\n constructor() {\n super();\n this.data = new Map();\n this.namespace = null;\n }\n\n /**\n * Initialize storage with namespace.\n *\n * @param {string} namespace - Storage namespace\n * @returns {Promise<void>}\n */\n async init(namespace) {\n this.namespace = namespace;\n // Check if there's existing data for this namespace\n if (!MemoryStorage._globalStore) {\n MemoryStorage._globalStore = new Map();\n }\n if (!MemoryStorage._globalStore.has(namespace)) {\n MemoryStorage._globalStore.set(namespace, new Map());\n }\n this.data = MemoryStorage._globalStore.get(namespace);\n }\n\n /**\n * Store an event.\n *\n * @param {string} key - Storage key\n * @param {Object} event - Event data\n * @returns {Promise<void>}\n */\n async put(key, event) {\n this.data.set(key, JSON.parse(JSON.stringify(event))); // Deep clone\n }\n\n /**\n * Retrieve an event.\n *\n * @param {string} key - Storage key\n * @returns {Promise<Object|null>} Event data or null\n */\n async get(key) {\n const data = this.data.get(key);\n return data ? JSON.parse(JSON.stringify(data)) : null; // Deep clone\n }\n\n /**\n * Retrieve all events matching a prefix.\n *\n * @param {string} prefix - Key prefix to match\n * @returns {Promise<any[]>} Array of matching events\n */\n async getAll(prefix) {\n /** @type {any[]} */\n const results = [];\n for (const [key, value] of this.data.entries()) {\n if (key.startsWith(prefix)) {\n results.push(JSON.parse(JSON.stringify(value)));\n }\n }\n return results;\n }\n\n /**\n * Delete an event.\n *\n * @param {string} key - Storage key\n * @returns {Promise<void>}\n */\n async delete(key) {\n this.data.delete(key);\n }\n\n /**\n * Clear all stored events.\n *\n * @returns {Promise<void>}\n */\n async clear() {\n this.data.clear();\n }\n\n /**\n * Close storage (no-op for memory storage).\n *\n * @returns {Promise<void>}\n */\n async close() {\n // Nothing to close for memory storage\n }\n}\n\n/**\n * Global store shared across instances with same namespace.\n * @private\n */\nMemoryStorage._globalStore = null;\n"],"names":[],"mappings":";AAwBO,MAAM,sBAAsB,kBAAkB;AAAA;AAAA;AAAA;AAAA,EAInD,cAAc;AACZ,UAAK;AACL,SAAK,OAAO,oBAAI,IAAG;AACnB,SAAK,YAAY;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,KAAK,WAAW;AACpB,SAAK,YAAY;AAEjB,QAAI,CAAC,cAAc,cAAc;AAC/B,oBAAc,eAAe,oBAAI,IAAG;AAAA,IACtC;AACA,QAAI,CAAC,cAAc,aAAa,IAAI,SAAS,GAAG;AAC9C,oBAAc,aAAa,IAAI,WAAW,oBAAI,IAAG,CAAE;AAAA,IACrD;AACA,SAAK,OAAO,cAAc,aAAa,IAAI,SAAS;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,IAAI,KAAK,OAAO;AACpB,SAAK,KAAK,IAAI,KAAK,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAAC;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,KAAK;AACb,UAAM,OAAO,KAAK,KAAK,IAAI,GAAG;AAC9B,WAAO,OAAO,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC,IAAI;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAAQ;AAEnB,UAAM,UAAU,CAAA;AAChB,eAAW,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,WAAW;AAC9C,UAAI,IAAI,WAAW,MAAM,GAAG;AAC1B,gBAAQ,KAAK,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAAC;AAAA,MAChD;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,KAAK;AAChB,SAAK,KAAK,OAAO,GAAG;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,QAAQ;AACZ,SAAK,KAAK,MAAK;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,QAAQ;AAAA,EAEd;AACF;AAMA,cAAc,eAAe;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-DMbdcMtK.cjs");class e extends t.PersistentStorage{constructor(){super(),this.data=new Map,this.namespace=null}async init(t){this.namespace=t,e._globalStore||(e._globalStore=new Map),e._globalStore.has(t)||e._globalStore.set(t,new Map),this.data=e._globalStore.get(t)}async put(t,e){this.data.set(t,JSON.parse(JSON.stringify(e)))}async get(t){const e=this.data.get(t);return e?JSON.parse(JSON.stringify(e)):null}async getAll(t){const e=[];for(const[s,a]of this.data.entries())s.startsWith(t)&&e.push(JSON.parse(JSON.stringify(a)));return e}async delete(t){this.data.delete(t)}async clear(){this.data.clear()}async close(){}}e._globalStore=null,exports.MemoryStorage=e;
2
+ //# sourceMappingURL=memory-storage-Dao7jfYG.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-storage-Dao7jfYG.cjs","sources":["../src/storage/memory-storage.js"],"sourcesContent":["/**\n * @fileoverview Memory-only storage adapter (fallback, no actual persistence).\n *\n * Provides in-memory storage for testing or when persistent storage is unavailable.\n * Data is shared across instances with the same namespace but lost on process restart.\n *\n * @module storage/memory-storage\n */\n\nimport { PersistentStorage } from './persistent-storage.js';\n\n/**\n * Memory-only storage adapter.\n *\n * Stores data in memory with no persistence across restarts.\n * Uses a global store to share data across instances with same namespace.\n *\n * @class MemoryStorage\n * @extends PersistentStorage\n * @example\n * const storage = new MemoryStorage();\n * await storage.init('myapp');\n * await storage.put('key1', { id: 'event1' });\n */\nexport class MemoryStorage extends PersistentStorage {\n /**\n * Create a new MemoryStorage instance.\n */\n constructor() {\n super();\n this.data = new Map();\n this.namespace = null;\n }\n\n /**\n * Initialize storage with namespace.\n *\n * @param {string} namespace - Storage namespace\n * @returns {Promise<void>}\n */\n async init(namespace) {\n this.namespace = namespace;\n // Check if there's existing data for this namespace\n if (!MemoryStorage._globalStore) {\n MemoryStorage._globalStore = new Map();\n }\n if (!MemoryStorage._globalStore.has(namespace)) {\n MemoryStorage._globalStore.set(namespace, new Map());\n }\n this.data = MemoryStorage._globalStore.get(namespace);\n }\n\n /**\n * Store an event.\n *\n * @param {string} key - Storage key\n * @param {Object} event - Event data\n * @returns {Promise<void>}\n */\n async put(key, event) {\n this.data.set(key, JSON.parse(JSON.stringify(event))); // Deep clone\n }\n\n /**\n * Retrieve an event.\n *\n * @param {string} key - Storage key\n * @returns {Promise<Object|null>} Event data or null\n */\n async get(key) {\n const data = this.data.get(key);\n return data ? JSON.parse(JSON.stringify(data)) : null; // Deep clone\n }\n\n /**\n * Retrieve all events matching a prefix.\n *\n * @param {string} prefix - Key prefix to match\n * @returns {Promise<any[]>} Array of matching events\n */\n async getAll(prefix) {\n /** @type {any[]} */\n const results = [];\n for (const [key, value] of this.data.entries()) {\n if (key.startsWith(prefix)) {\n results.push(JSON.parse(JSON.stringify(value)));\n }\n }\n return results;\n }\n\n /**\n * Delete an event.\n *\n * @param {string} key - Storage key\n * @returns {Promise<void>}\n */\n async delete(key) {\n this.data.delete(key);\n }\n\n /**\n * Clear all stored events.\n *\n * @returns {Promise<void>}\n */\n async clear() {\n this.data.clear();\n }\n\n /**\n * Close storage (no-op for memory storage).\n *\n * @returns {Promise<void>}\n */\n async close() {\n // Nothing to close for memory storage\n }\n}\n\n/**\n * Global store shared across instances with same namespace.\n * @private\n */\nMemoryStorage._globalStore = null;\n"],"names":["MemoryStorage","PersistentStorage","constructor","super","this","data","Map","namespace","init","_globalStore","has","set","get","put","key","event","JSON","parse","stringify","getAll","prefix","results","value","entries","startsWith","push","delete","clear","close"],"mappings":"wHAwBO,MAAMA,UAAsBC,EAAAA,kBAIjC,WAAAC,GACEC,QACAC,KAAKC,SAAWC,IAChBF,KAAKG,UAAY,IACnB,CAQA,UAAMC,CAAKD,GACTH,KAAKG,UAAYA,EAEZP,EAAcS,eACjBT,EAAcS,iBAAmBH,KAE9BN,EAAcS,aAAaC,IAAIH,IAClCP,EAAcS,aAAaE,IAAIJ,EAAW,IAAID,KAEhDF,KAAKC,KAAOL,EAAcS,aAAaG,IAAIL,EAC7C,CASA,SAAMM,CAAIC,EAAKC,GACbX,KAAKC,KAAKM,IAAIG,EAAKE,KAAKC,MAAMD,KAAKE,UAAUH,IAC/C,CAQA,SAAMH,CAAIE,GACR,MAAMT,EAAOD,KAAKC,KAAKO,IAAIE,GAC3B,OAAOT,EAAOW,KAAKC,MAAMD,KAAKE,UAAUb,IAAS,IACnD,CAQA,YAAMc,CAAOC,GAEX,MAAMC,EAAU,GAChB,IAAA,MAAYP,EAAKQ,KAAUlB,KAAKC,KAAKkB,UAC/BT,EAAIU,WAAWJ,IACjBC,EAAQI,KAAKT,KAAKC,MAAMD,KAAKE,UAAUI,KAG3C,OAAOD,CACT,CAQA,YAAM,CAAOP,GACXV,KAAKC,KAAKqB,OAAOZ,EACnB,CAOA,WAAMa,GACJvB,KAAKC,KAAKsB,OACZ,CAOA,WAAMC,GAEN,EAOF5B,EAAcS,aAAe"}
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-DMbdcMtK.cjs");class e extends t.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,t.ahash(e);const n=t.toBytes(r);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=e.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),t.clean(i)}update(e){return t.aexists(this),this.iHash.update(e),this}digestInto(e){t.aexists(this),t.abytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:o,blockLen:i,outputLen:s}=this;return t.finished=n,t.destroyed=o,t.blockLen=i,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const r=(t,r,n)=>new e(t,r).update(n).digest();r.create=(t,r)=>new e(t,r);
2
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
+ const n=BigInt(0),o=BigInt(1);function i(t,e=""){if("boolean"!=typeof t){throw new Error((e&&`"${e}"`)+"expected boolean, got type="+typeof t)}return t}function s(e,r,n=""){const o=t.isBytes(e),i=e?.length,s=void 0!==r;if(!o||s&&i!==r){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${r}`:"")+", got "+(o?`length=${i}`:"type="+typeof e))}return e}function c(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function a(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?n:BigInt("0x"+t)}function f(e){return a(t.bytesToHex(e))}function u(e){return t.abytes(e),a(t.bytesToHex(Uint8Array.from(e).reverse()))}function d(e,r){return t.hexToBytes(e.toString(16).padStart(2*r,"0"))}function l(t,e){return d(t,e).reverse()}function h(e,r,n){let o;if("string"==typeof r)try{o=t.hexToBytes(r)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else{if(!t.isBytes(r))throw new Error(e+" must be hex string or Uint8Array");o=Uint8Array.from(r)}return o.length,o}const w=t=>"bigint"==typeof t&&n<=t;function y(t,e,r,n){if(!function(t,e,r){return w(t)&&w(e)&&w(r)&&e<=t&&t<r}(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function g(t){let e;for(e=0;t>n;t>>=o,e+=1);return e}const p=t=>(o<<BigInt(t))-o;function m(t,e,r={}){if(!t||"object"!=typeof t)throw new Error("expected valid options object");function n(e,r,n){const o=t[e];if(n&&void 0===o)return;const i=typeof o;if(i!==r||null===o)throw new Error(`param "${e}" is invalid: expected ${r}, got ${i}`)}Object.entries(e).forEach(([t,e])=>n(t,e,!1)),Object.entries(r).forEach(([t,e])=>n(t,e,!0))}function b(t){const e=new WeakMap;return(r,...n)=>{const o=e.get(r);if(void 0!==o)return o;const i=t(r,...n);return e.set(r,i),i}}
4
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const E=BigInt(0),B=BigInt(1),v=BigInt(2),x=BigInt(3),O=BigInt(4),R=BigInt(5),S=BigInt(7),I=BigInt(8),N=BigInt(9),q=BigInt(16);function A(t,e){const r=t%e;return r>=E?r:e+r}function F(t,e,r){let n=t;for(;e-- >E;)n*=n,n%=r;return n}function Z(t,e){if(t===E)throw new Error("invert: expected non-zero number");if(e<=E)throw new Error("invert: expected positive modulus, got "+e);let r=A(t,e),n=e,o=E,i=B;for(;r!==E;){const t=n%r,e=o-i*(n/r);n=r,r=t,o=i,i=e}if(n!==B)throw new Error("invert: does not exist");return A(o,e)}function H(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function U(t,e){const r=(t.ORDER+B)/O,n=t.pow(e,r);return H(t,n,e),n}function V(t,e){const r=(t.ORDER-R)/I,n=t.mul(e,v),o=t.pow(n,r),i=t.mul(e,o),s=t.mul(t.mul(i,v),o),c=t.mul(i,t.sub(s,t.ONE));return H(t,c,e),c}function T(t){if(t<x)throw new Error("sqrt is not defined for small field");let e=t-B,r=0;for(;e%v===E;)e/=v,r++;let n=v;const o=j(t);for(;1===L(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return U;let i=o.pow(n,e);const s=(e+B)/v;return function(t,n){if(t.is0(n))return n;if(1!==L(t,n))throw new Error("Cannot find square root");let o=r,c=t.mul(t.ONE,i),a=t.pow(n,e),f=t.pow(n,s);for(;!t.eql(a,t.ONE);){if(t.is0(a))return t.ZERO;let e=1,r=t.sqr(a);for(;!t.eql(r,t.ONE);)if(e++,r=t.sqr(r),e===o)throw new Error("Cannot find square root");const n=B<<BigInt(o-e-1),i=t.pow(c,n);o=e,c=t.sqr(i),a=t.mul(a,c),f=t.mul(f,i)}return f}}function k(t){return t%O===x?U:t%I===R?V:t%q===N?function(t){const e=j(t),r=T(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+S)/q;return(t,e)=>{let r=t.pow(e,s),c=t.mul(r,n);const a=t.mul(r,o),f=t.mul(r,i),u=t.eql(t.sqr(c),e),d=t.eql(t.sqr(a),e);r=t.cmov(r,c,u),c=t.cmov(f,a,d);const l=t.eql(t.sqr(c),e),h=t.cmov(r,c,l);return H(t,h,e),h}}(t):T(t)}const P=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function K(t,e,r=!1){const n=new Array(e.length).fill(r?t.ZERO:void 0),o=e.reduce((e,r,o)=>t.is0(r)?e:(n[o]=e,t.mul(e,r)),t.ONE),i=t.inv(o);return e.reduceRight((e,r,o)=>t.is0(r)?e:(n[o]=t.mul(e,n[o]),t.mul(e,r)),i),n}function L(t,e){const r=(t.ORDER-B)/v,n=t.pow(e,r),o=t.eql(n,t.ONE),i=t.eql(n,t.ZERO),s=t.eql(n,t.neg(t.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function C(e,r){void 0!==r&&t.anumber(r);const n=void 0!==r?r:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function j(t,e,r=!1,n={}){if(t<=E)throw new Error("invalid field: expected ORDER > 0, got "+t);let o,i,s,c=!1;if("object"==typeof e&&null!=e){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");const t=e;t.BITS&&(o=t.BITS),t.sqrt&&(i=t.sqrt),"boolean"==typeof t.isLE&&(r=t.isLE),"boolean"==typeof t.modFromBytes&&(c=t.modFromBytes),s=t.allowedLengths}else"number"==typeof e&&(o=e),n.sqrt&&(i=n.sqrt);const{nBitLength:a,nByteLength:h}=C(t,o);if(h>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let w;const y=Object.freeze({ORDER:t,isLE:r,BITS:a,BYTES:h,MASK:p(a),ZERO:E,ONE:B,allowedLengths:s,create:e=>A(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return E<=e&&e<t},is0:t=>t===E,isValidNot0:t=>!y.is0(t)&&y.isValid(t),isOdd:t=>(t&B)===B,neg:e=>A(-e,t),eql:(t,e)=>t===e,sqr:e=>A(e*e,t),add:(e,r)=>A(e+r,t),sub:(e,r)=>A(e-r,t),mul:(e,r)=>A(e*r,t),pow:(t,e)=>function(t,e,r){if(r<E)throw new Error("invalid exponent, negatives unsupported");if(r===E)return t.ONE;if(r===B)return e;let n=t.ONE,o=e;for(;r>E;)r&B&&(n=t.mul(n,o)),o=t.sqr(o),r>>=B;return n}(y,t,e),div:(e,r)=>A(e*Z(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>Z(e,t),sqrt:i||(e=>(w||(w=k(t)),w(y,e))),toBytes:t=>r?l(t,h):d(t,h),fromBytes:(e,n=!0)=>{if(s){if(!s.includes(e.length)||e.length>h)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+e.length);const t=new Uint8Array(h);t.set(e,r?0:t.length-e.length),e=t}if(e.length!==h)throw new Error("Field.fromBytes: expected "+h+" bytes, got "+e.length);let o=r?u(e):f(e);if(c&&(o=A(o,t)),!n&&!y.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:t=>K(y,t),cmov:(t,e,r)=>r?e:t});return Object.freeze(y)}function D(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Y(t){const e=D(t);return e+Math.ceil(e/2)}
5
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6
+ const z=BigInt(0),$=BigInt(1);function _(t,e){const r=e.negate();return t?r:e}function M(t,e){const r=K(t.Fp,e.map(t=>t.Z));return e.map((e,n)=>t.fromAffine(e.toAffine(r[n])))}function G(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function X(t,e){G(t,e);const r=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:p(t),maxNumber:r,shiftBy:BigInt(t)}}function W(t,e,r){const{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r;let c=Number(t&o),a=t>>s;c>n&&(c-=i,a+=$);const f=e*n;return{nextN:a,offset:f+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:e%2!=0,offsetF:f}}const J=new WeakMap,Q=new WeakMap;function tt(t){return Q.get(t)||1}function et(t){if(t!==z)throw new Error("invalid wNAF")}class rt{constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,r=this.ZERO){let n=t;for(;e>z;)e&$&&(r=r.add(n)),n=n.double(),e>>=$;return r}precomputeWindow(t,e){const{windows:r,windowSize:n}=X(e,this.bits),o=[];let i=t,s=i;for(let c=0;c<r;c++){s=i,o.push(s);for(let t=1;t<n;t++)s=s.add(i),o.push(s);i=s.double()}return o}wNAF(t,e,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let n=this.ZERO,o=this.BASE;const i=X(t,this.bits);for(let s=0;s<i.windows;s++){const{nextN:t,offset:c,isZero:a,isNeg:f,isNegF:u,offsetF:d}=W(r,s,i);r=t,a?o=o.add(_(u,e[d])):n=n.add(_(f,e[c]))}return et(r),{p:n,f:o}}wNAFUnsafe(t,e,r,n=this.ZERO){const o=X(t,this.bits);for(let i=0;i<o.windows&&r!==z;i++){const{nextN:t,offset:s,isZero:c,isNeg:a}=W(r,i,o);if(r=t,!c){const t=e[s];n=n.add(a?t.negate():t)}}return et(r),n}getPrecomputes(t,e,r){let n=J.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&("function"==typeof r&&(n=r(n)),J.set(e,n))),n}cached(t,e,r){const n=tt(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)}unsafe(t,e,r,n){const o=tt(t);return 1===o?this._unsafeLadder(t,e,n):this.wNAFUnsafe(o,this.getPrecomputes(o,t,r),e,n)}createCache(t,e){G(e,this.bits),Q.set(t,e),J.delete(t)}hasCache(t){return 1!==tt(t)}}function nt(t,e,r,n){!function(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})}(r,t),function(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}(n,e);const o=r.length,i=n.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,c=g(BigInt(o));let a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);const f=p(a),u=new Array(Number(f)+1).fill(s);let d=s;for(let l=Math.floor((e.BITS-1)/a)*a;l>=0;l-=a){u.fill(s);for(let e=0;e<i;e++){const t=n[e],o=Number(t>>BigInt(l)&f);u[o]=u[o].add(r[e])}let t=s;for(let e=u.length-1,r=s;e>0;e--)r=r.add(u[e]),t=t.add(r);if(d=d.add(t),0!==l)for(let e=0;e<a;e++)d=d.double()}return d}function ot(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(t){m(t,P.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(e),e}return j(t,{isLE:r})}
7
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
8
+ const it=(t,e)=>(t+(t>=0?e:-e)/lt)/e;function st(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function ct(t,e){const r={};for(let n of Object.keys(e))r[n]=void 0===t[n]?e[n]:t[n];return i(r.lowS,"lowS"),i(r.prehash,"prehash"),void 0!==r.format&&st(r.format),r}class at extends Error{constructor(t=""){super(t)}}const ft={Err:at,_tlv:{encode:(t,e)=>{const{Err:r}=ft;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(1&e.length)throw new r("tlv.encode: unpadded data");const n=e.length/2,o=c(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");const i=n>127?c(o.length/2|128):"";return c(t)+i+o+e},decode(t,e){const{Err:r}=ft;let n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const o=e[n++];let i=0;if(!!(128&o)){const t=127&o;if(!t)throw new r("tlv.decode(long): indefinite length not supported");if(t>4)throw new r("tlv.decode(long): byte length is too big");const s=e.subarray(n,n+t);if(s.length!==t)throw new r("tlv.decode: length bytes not complete");if(0===s[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of s)i=i<<8|e;if(n+=t,i<128)throw new r("tlv.decode(long): not minimal encoding")}else i=o;const s=e.subarray(n,n+i);if(s.length!==i)throw new r("tlv.decode: wrong value length");return{v:s,l:e.subarray(n+i)}}},_int:{encode(t){const{Err:e}=ft;if(t<ut)throw new e("integer: negative integers are not allowed");let r=c(t);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=ft;if(128&t[0])throw new e("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new e("invalid signature integer: unnecessary leading zero");return f(t)}},toSig(t){const{Err:e,_int:r,_tlv:n}=ft,o=h("signature",t),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");const{v:c,l:a}=n.decode(2,i),{v:f,l:u}=n.decode(2,a);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(f)}},hexFromSig(t){const{_tlv:e,_int:r}=ft,n=e.encode(2,r.encode(t.r))+e.encode(2,r.encode(t.s));return e.encode(48,n)}},ut=BigInt(0),dt=BigInt(1),lt=BigInt(2),ht=BigInt(3),wt=BigInt(4);function yt(t,e){const{BYTES:r}=t;let n;if("bigint"==typeof e)n=e;else{let i=h("private key",e);try{n=t.fromBytes(i)}catch(o){throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function gt(e,r={}){const n=function(t,e,r={},n){if(void 0===n&&(n="edwards"===t),!e||"object"!=typeof e)throw new Error(`expected valid ${t} CURVE object`);for(const c of["p","n","h"]){const t=e[c];if(!("bigint"==typeof t&&t>z))throw new Error(`CURVE.${c} must be positive bigint`)}const o=ot(e.p,r.Fp,n),i=ot(e.n,r.Fn,n),s=["Gx","Gy","a","b"];for(const c of s)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return{CURVE:e=Object.freeze(Object.assign({},e)),Fp:o,Fn:i}}("weierstrass",e,r),{Fp:o,Fn:c}=n;let a=n.CURVE;const{h:f,n:u}=a;m(r,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:d}=r;if(d&&(!o.is0(a.a)||"bigint"!=typeof d.beta||!Array.isArray(d.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const l=mt(o,c);function w(){if(!o.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const y=r.toBytes||function(e,r,n){const{x:s,y:c}=r.toAffine(),a=o.toBytes(s);if(i(n,"isCompressed"),n){w();const e=!o.isOdd(c);return t.concatBytes(pt(e),a)}return t.concatBytes(Uint8Array.of(4),a,o.toBytes(c))},E=r.fromBytes||function(t){s(t,void 0,"Point");const{publicKey:e,publicKeyUncompressed:r}=l,n=t.length,i=t[0],c=t.subarray(1);if(n!==e||2!==i&&3!==i){if(n===r&&4===i){const t=o.BYTES,e=o.fromBytes(c.subarray(0,t)),r=o.fromBytes(c.subarray(t,2*t));if(!v(e,r))throw new Error("bad point: is not on curve");return{x:e,y:r}}throw new Error(`bad point: got length ${n}, expected compressed=${e} or uncompressed=${r}`)}{const t=o.fromBytes(c);if(!o.isValid(t))throw new Error("bad point: is not on curve, wrong x");const e=B(t);let r;try{r=o.sqrt(e)}catch(a){const t=a instanceof Error?": "+a.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}w();return!(1&~i)!==o.isOdd(r)&&(r=o.neg(r)),{x:t,y:r}}};function B(t){const e=o.sqr(t),r=o.mul(e,t);return o.add(o.add(r,o.mul(t,a.a)),a.b)}function v(t,e){const r=o.sqr(e),n=B(t);return o.eql(r,n)}if(!v(a.Gx,a.Gy))throw new Error("bad curve params: generator point");const x=o.mul(o.pow(a.a,ht),wt),O=o.mul(o.sqr(a.b),BigInt(27));if(o.is0(o.add(x,O)))throw new Error("bad curve params: a or b");function R(t,e,r=!1){if(!o.isValid(e)||r&&o.is0(e))throw new Error(`bad point coordinate ${t}`);return e}function S(t){if(!(t instanceof F))throw new Error("ProjectivePoint expected")}function I(t){if(!d||!d.basises)throw new Error("no endo");return function(t,e,r){const[[n,o],[i,s]]=e,c=it(s*t,r),a=it(-o*t,r);let f=t-c*n-a*i,u=-c*o-a*s;const d=f<ut,l=u<ut;d&&(f=-f),l&&(u=-u);const h=p(Math.ceil(g(r)/2))+dt;if(f<ut||f>=h||u<ut||u>=h)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:d,k1:f,k2neg:l,k2:u}}(t,d.basises,c.ORDER)}const N=b((t,e)=>{const{X:r,Y:n,Z:i}=t;if(o.eql(i,o.ONE))return{x:r,y:n};const s=t.is0();null==e&&(e=s?o.ONE:o.inv(i));const c=o.mul(r,e),a=o.mul(n,e),f=o.mul(i,e);if(s)return{x:o.ZERO,y:o.ZERO};if(!o.eql(f,o.ONE))throw new Error("invZ was invalid");return{x:c,y:a}}),q=b(t=>{if(t.is0()){if(r.allowInfinityPoint&&!o.is0(t.Y))return;throw new Error("bad point: ZERO")}const{x:e,y:n}=t.toAffine();if(!o.isValid(e)||!o.isValid(n))throw new Error("bad point: x or y not field elements");if(!v(e,n))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function A(t,e,r,n,i){return r=new F(o.mul(r.X,t),r.Y,r.Z),e=_(n,e),r=_(i,r),e.add(r)}class F{constructor(t,e,r){this.X=R("x",t),this.Y=R("y",e,!0),this.Z=R("z",r),Object.freeze(this)}static CURVE(){return a}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!o.isValid(e)||!o.isValid(r))throw new Error("invalid affine point");if(t instanceof F)throw new Error("projective point not allowed");return o.is0(e)&&o.is0(r)?F.ZERO:new F(e,r,o.ONE)}static fromBytes(t){const e=F.fromAffine(E(s(t,void 0,"point")));return e.assertValidity(),e}static fromHex(t){return F.fromBytes(h("pointHex",t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return H.createCache(this,t),e||this.multiply(ht),this}assertValidity(){q(this)}hasEvenY(){const{y:t}=this.toAffine();if(!o.isOdd)throw new Error("Field doesn't support isOdd");return!o.isOdd(t)}equals(t){S(t);const{X:e,Y:r,Z:n}=this,{X:i,Y:s,Z:c}=t,a=o.eql(o.mul(e,c),o.mul(i,n)),f=o.eql(o.mul(r,c),o.mul(s,n));return a&&f}negate(){return new F(this.X,o.neg(this.Y),this.Z)}double(){const{a:t,b:e}=a,r=o.mul(e,ht),{X:n,Y:i,Z:s}=this;let c=o.ZERO,f=o.ZERO,u=o.ZERO,d=o.mul(n,n),l=o.mul(i,i),h=o.mul(s,s),w=o.mul(n,i);return w=o.add(w,w),u=o.mul(n,s),u=o.add(u,u),c=o.mul(t,u),f=o.mul(r,h),f=o.add(c,f),c=o.sub(l,f),f=o.add(l,f),f=o.mul(c,f),c=o.mul(w,c),u=o.mul(r,u),h=o.mul(t,h),w=o.sub(d,h),w=o.mul(t,w),w=o.add(w,u),u=o.add(d,d),d=o.add(u,d),d=o.add(d,h),d=o.mul(d,w),f=o.add(f,d),h=o.mul(i,s),h=o.add(h,h),d=o.mul(h,w),c=o.sub(c,d),u=o.mul(h,l),u=o.add(u,u),u=o.add(u,u),new F(c,f,u)}add(t){S(t);const{X:e,Y:r,Z:n}=this,{X:i,Y:s,Z:c}=t;let f=o.ZERO,u=o.ZERO,d=o.ZERO;const l=a.a,h=o.mul(a.b,ht);let w=o.mul(e,i),y=o.mul(r,s),g=o.mul(n,c),p=o.add(e,r),m=o.add(i,s);p=o.mul(p,m),m=o.add(w,y),p=o.sub(p,m),m=o.add(e,n);let b=o.add(i,c);return m=o.mul(m,b),b=o.add(w,g),m=o.sub(m,b),b=o.add(r,n),f=o.add(s,c),b=o.mul(b,f),f=o.add(y,g),b=o.sub(b,f),d=o.mul(l,m),f=o.mul(h,g),d=o.add(f,d),f=o.sub(y,d),d=o.add(y,d),u=o.mul(f,d),y=o.add(w,w),y=o.add(y,w),g=o.mul(l,g),m=o.mul(h,m),y=o.add(y,g),g=o.sub(w,g),g=o.mul(l,g),m=o.add(m,g),w=o.mul(y,m),u=o.add(u,w),w=o.mul(b,m),f=o.mul(p,f),f=o.sub(f,w),w=o.mul(p,y),d=o.mul(b,d),d=o.add(d,w),new F(f,u,d)}subtract(t){return this.add(t.negate())}is0(){return this.equals(F.ZERO)}multiply(t){const{endo:e}=r;if(!c.isValidNot0(t))throw new Error("invalid scalar: out of range");let n,o;const i=t=>H.cached(this,t,t=>M(F,t));if(e){const{k1neg:r,k1:s,k2neg:c,k2:a}=I(t),{p:f,f:u}=i(s),{p:d,f:l}=i(a);o=u.add(l),n=A(e.beta,f,d,r,c)}else{const{p:e,f:r}=i(t);n=e,o=r}return M(F,[n,o])[0]}multiplyUnsafe(t){const{endo:e}=r,n=this;if(!c.isValid(t))throw new Error("invalid scalar: out of range");if(t===ut||n.is0())return F.ZERO;if(t===dt)return n;if(H.hasCache(this))return this.multiply(t);if(e){const{k1neg:r,k1:o,k2neg:i,k2:s}=I(t),{p1:c,p2:a}=function(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>z||n>z;)r&$&&(i=i.add(o)),n&$&&(s=s.add(o)),o=o.double(),r>>=$,n>>=$;return{p1:i,p2:s}}(F,n,o,s);return A(e.beta,c,a,r,i)}return H.unsafe(n,t)}multiplyAndAddUnsafe(t,e,r){const n=this.multiplyUnsafe(e).add(t.multiplyUnsafe(r));return n.is0()?void 0:n}toAffine(t){return N(this,t)}isTorsionFree(){const{isTorsionFree:t}=r;return f===dt||(t?t(F,this):H.unsafe(this,u).is0())}clearCofactor(){const{clearCofactor:t}=r;return f===dt?this:t?t(F,this):this.multiplyUnsafe(f)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}toBytes(t=!0){return i(t,"isCompressed"),this.assertValidity(),y(F,this,t)}toHex(e=!0){return t.bytesToHex(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(t=!0){return this.toBytes(t)}_setWindowSize(t){this.precompute(t)}static normalizeZ(t){return M(F,t)}static msm(t,e){return nt(F,c,t,e)}static fromPrivateKey(t){return F.BASE.multiply(yt(c,t))}}F.BASE=new F(a.Gx,a.Gy,o.ONE),F.ZERO=new F(o.ZERO,o.ONE,o.ZERO),F.Fp=o,F.Fn=c;const Z=c.BITS,H=new rt(F,r.endo?Math.ceil(Z/2):Z);return F.BASE.precompute(8),F}function pt(t){return Uint8Array.of(t?2:3)}function mt(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function bt(e,r={}){const{Fn:n}=e,o=r.randomBytes||t.randomBytes,i=Object.assign(mt(e.Fp,n),{seed:Y(n.ORDER)});function c(t){try{return!!yt(n,t)}catch(e){return!1}}function a(t=o(i.seed)){return function(t,e,r=!1){const n=t.length,o=D(e),i=Y(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);const s=A(r?u(t):f(t),e-B)+B;return r?l(s,o):d(s,o)}(s(t,i.seed,"seed"),n.ORDER)}function w(t,r=!0){return e.BASE.multiply(yt(n,t)).toBytes(r)}function y(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:o,publicKeyUncompressed:s}=i;if(n.allowedLengths||r===o)return;const c=h("key",t).length;return c===o||c===s}const g={isValidSecretKey:c,isValidPublicKey:function(t,r){const{publicKey:n,publicKeyUncompressed:o}=i;try{const i=t.length;return(!0!==r||i===n)&&((!1!==r||i===o)&&!!e.fromBytes(t))}catch(s){return!1}},randomSecretKey:a,isValidPrivateKey:c,randomPrivateKey:a,normPrivateKeyToScalar:t=>yt(n,t),precompute:(t=8,r=e.BASE)=>r.precompute(t,!1)};return Object.freeze({getPublicKey:w,getSharedSecret:function(t,r,o=!0){if(!0===y(t))throw new Error("first arg must be private key");if(!1===y(r))throw new Error("second arg must be public key");const i=yt(n,t);return e.fromHex(r).multiply(i).toBytes(o)},keygen:function(t){const e=a(t);return{secretKey:e,publicKey:w(e)}},Point:e,utils:g,lengths:i})}function Et(e,n,o={}){t.ahash(n),m(o,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const i=o.randomBytes||t.randomBytes,c=o.hmac||((e,...o)=>r(n,e,t.concatBytes(...o))),{Fp:a,Fn:u}=e,{ORDER:d,BITS:l}=u,{keygen:w,getPublicKey:g,getSharedSecret:b,utils:E,lengths:B}=bt(e,o),v={prehash:!1,lowS:"boolean"==typeof o.lowS&&o.lowS,format:void 0,extraEntropy:!1},x="compact";function O(t){return t>d>>dt}function R(t,e){if(!u.isValidNot0(e))throw new Error(`invalid signature ${t}: out of range 1..Point.Fn.ORDER`);return e}class S{constructor(t,e,r){this.r=R("r",t),this.s=R("s",e),null!=r&&(this.recovery=r),Object.freeze(this)}static fromBytes(t,e=x){let r;if(function(t,e){st(e);const r=B.signature;s(t,"compact"===e?r:"recovered"===e?r+1:void 0,`${e} signature`)}(t,e),"der"===e){const{r:e,s:r}=ft.toSig(s(t));return new S(e,r)}"recovered"===e&&(r=t[0],e="compact",t=t.subarray(1));const n=u.BYTES,o=t.subarray(0,n),i=t.subarray(n,2*n);return new S(u.fromBytes(o),u.fromBytes(i),r)}static fromHex(e,r){return this.fromBytes(t.hexToBytes(e),r)}addRecoveryBit(t){return new S(this.r,this.s,t)}recoverPublicKey(r){const n=a.ORDER,{r:o,s:i,recovery:s}=this;if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");if(d*lt<n&&s>1)throw new Error("recovery id is ambiguous for h>1 curve");const c=2===s||3===s?o+d:o;if(!a.isValid(c))throw new Error("recovery id 2 or 3 invalid");const f=a.toBytes(c),l=e.fromBytes(t.concatBytes(pt(!(1&s)),f)),w=u.inv(c),y=N(h("msgHash",r)),g=u.create(-y*w),p=u.create(i*w),m=e.BASE.multiplyUnsafe(g).add(l.multiplyUnsafe(p));if(m.is0())throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return O(this.s)}toBytes(e=x){if(st(e),"der"===e)return t.hexToBytes(ft.hexFromSig(this));const r=u.toBytes(this.r),n=u.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return t.concatBytes(Uint8Array.of(this.recovery),r,n)}return t.concatBytes(r,n)}toHex(e){return t.bytesToHex(this.toBytes(e))}assertValidity(){}static fromCompact(t){return S.fromBytes(h("sig",t),"compact")}static fromDER(t){return S.fromBytes(h("sig",t),"der")}normalizeS(){return this.hasHighS()?new S(this.r,u.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return t.bytesToHex(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return t.bytesToHex(this.toBytes("compact"))}}const I=o.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=f(t),r=8*t.length-l;return r>0?e>>BigInt(r):e},N=o.bits2int_modN||function(t){return u.create(I(t))},q=p(l);function A(t){return y("num < 2^"+l,t,ut,q),u.toBytes(t)}function F(t,e){return s(t,void 0,"message"),e?s(n(t),void 0,"prehashed message"):t}return Object.freeze({keygen:w,getPublicKey:g,getSharedSecret:b,utils:E,lengths:B,Point:e,sign:function(r,o,s={}){r=h("message",r);const{seed:a,k2sig:f}=function(r,n,o){if(["recovered","canonical"].some(t=>t in o))throw new Error("sign() legacy options not supported");const{lowS:s,prehash:c,extraEntropy:a}=ct(o,v);r=F(r,c);const f=N(r),d=yt(u,n),l=[A(d),A(f)];if(null!=a&&!1!==a){const t=!0===a?i(B.secretKey):a;l.push(h("extraEntropy",t))}const w=t.concatBytes(...l),y=f;return{seed:w,k2sig:function(t){const r=I(t);if(!u.isValidNot0(r))return;const n=u.inv(r),o=e.BASE.multiply(r).toAffine(),i=u.create(o.x);if(i===ut)return;const c=u.create(n*u.create(y+i*d));if(c===ut)return;let a=(o.x===i?0:2)|Number(o.y&dt),f=c;return s&&O(c)&&(f=u.neg(c),a^=1),new S(i,f,a)}}}(r,o,s);return function(e,r,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof r||r<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const o=t=>new Uint8Array(t),i=t=>Uint8Array.of(t);let s=o(e),c=o(e),a=0;const f=()=>{s.fill(1),c.fill(0),a=0},u=(...t)=>n(c,s,...t),d=(t=o(0))=>{c=u(i(0),t),s=u(),0!==t.length&&(c=u(i(1),t),s=u())},l=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<r;){s=u();const t=s.slice();n.push(t),e+=s.length}return t.concatBytes(...n)};return(t,e)=>{let r;for(f(),d(t);!(r=e(l()));)d();return f(),r}}(n.outputLen,u.BYTES,c)(a,f)},verify:function(r,n,o,i={}){const{lowS:s,prehash:c,format:a}=ct(i,v);if(o=h("publicKey",o),n=F(h("message",n),c),"strict"in i)throw new Error("options.strict was renamed to lowS");const f=void 0===a?function(e){let r;const n="string"==typeof e||t.isBytes(e),o=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!o)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(o)r=new S(e.r,e.s);else if(n){try{r=S.fromBytes(h("sig",e),"der")}catch(i){if(!(i instanceof ft.Err))throw i}if(!r)try{r=S.fromBytes(h("sig",e),"compact")}catch(s){return!1}}return r||!1}(r):S.fromBytes(h("sig",r),a);if(!1===f)return!1;try{const t=e.fromBytes(o);if(s&&f.hasHighS())return!1;const{r:r,s:i}=f,c=N(n),a=u.inv(i),d=u.create(c*a),l=u.create(r*a),h=e.BASE.multiplyUnsafe(d).add(t.multiplyUnsafe(l));if(h.is0())return!1;return u.create(h.x)===r}catch(d){return!1}},recoverPublicKey:function(t,e,r={}){const{prehash:n}=ct(r,v);return e=F(e,n),S.fromBytes(t,"recovered").recoverPublicKey(e).toBytes()},Signature:S,hash:n})}function Bt(t){const{CURVE:e,curveOpts:r}=function(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp;let n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(t=>Math.ceil(t/2)))):void 0;return{CURVE:e,curveOpts:{Fp:r,Fn:j(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes}}}(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}function vt(t){const{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:o}=Bt(t);return function(t,e){const r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,C(r.Fn.ORDER,r.Fn.BITS))})}(t,Et(gt(e,r),n,o))}
9
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
10
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
11
+ const xt={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Ot={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Rt=BigInt(2);const St=j(xt.p,{sqrt:function(t){const e=xt.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),f=t*t*t%e,u=f*f*t%e,d=F(u,r,e)*u%e,l=F(d,r,e)*u%e,h=F(l,Rt,e)*f%e,w=F(h,o,e)*h%e,y=F(w,i,e)*w%e,g=F(y,c,e)*y%e,p=F(g,a,e)*g%e,m=F(p,c,e)*y%e,b=F(m,r,e)*u%e,E=F(b,s,e)*w%e,B=F(E,n,e)*f%e,v=F(B,Rt,e);if(!St.eql(St.sqr(v),t))throw new Error("Cannot find square root");return v}}),It=function(t,e){const r=e=>vt({...t,hash:e});return{...r(e),create:r}}({...xt,Fp:St,lowS:!0,endo:Ot},t.sha256);exports.secp256k1=It;
12
+ //# sourceMappingURL=secp256k1-BbKzbLtD.cjs.map