@undefineds.co/xpod 0.3.57 → 0.3.61

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 (779) hide show
  1. package/README.md +3 -0
  2. package/config/cli.json +88 -0
  3. package/config/cloud.json +32 -1
  4. package/config/components-ignore.json +3 -0
  5. package/config/extensions.local.initializer.json +44 -0
  6. package/config/resolver.json +86 -0
  7. package/config/xpod.base.json +4 -0
  8. package/dist/agents/AgentExecutorFactory.d.ts +3 -3
  9. package/dist/agents/AgentExecutorFactory.js +28 -15
  10. package/dist/agents/AgentExecutorFactory.js.map +1 -1
  11. package/dist/agents/BaseAgentExecutor.d.ts +2 -1
  12. package/dist/agents/BaseAgentExecutor.js +1 -0
  13. package/dist/agents/BaseAgentExecutor.js.map +1 -1
  14. package/dist/agents/ClaudeExecutor.d.ts +3 -1
  15. package/dist/agents/ClaudeExecutor.js +18 -12
  16. package/dist/agents/ClaudeExecutor.js.map +1 -1
  17. package/dist/agents/config/resolve.js +0 -21
  18. package/dist/agents/config/resolve.js.map +1 -1
  19. package/dist/agents/config/types.d.ts +2 -7
  20. package/dist/agents/config/types.js +2 -1
  21. package/dist/agents/config/types.js.map +1 -1
  22. package/dist/agents/types.d.ts +18 -0
  23. package/dist/agents/types.js.map +1 -1
  24. package/dist/ai/schema/types.d.ts +2 -1
  25. package/dist/ai/schema/types.js +1 -0
  26. package/dist/ai/schema/types.js.map +1 -1
  27. package/dist/ai/service/CredentialReader.d.ts +3 -1
  28. package/dist/ai/service/CredentialReader.js.map +1 -1
  29. package/dist/ai/service/CredentialReaderImpl.d.ts +3 -1
  30. package/dist/ai/service/CredentialReaderImpl.js +24 -2
  31. package/dist/ai/service/CredentialReaderImpl.js.map +1 -1
  32. package/dist/ai/service/EmbeddingServiceImpl.js +13 -2
  33. package/dist/ai/service/EmbeddingServiceImpl.js.map +1 -1
  34. package/dist/ai/service/ProviderRegistry.d.ts +4 -0
  35. package/dist/ai/service/ProviderRegistry.js.map +1 -1
  36. package/dist/ai/service/ProviderRegistry.jsonld +4 -0
  37. package/dist/ai/service/ProviderRegistryImpl.d.ts +4 -1
  38. package/dist/ai/service/ProviderRegistryImpl.js +26 -4
  39. package/dist/ai/service/ProviderRegistryImpl.js.map +1 -1
  40. package/dist/ai/service/ProviderRegistryImpl.jsonld +12 -0
  41. package/dist/ai/service/defaultEmbeddingProfile.d.ts +5 -0
  42. package/dist/ai/service/defaultEmbeddingProfile.js +31 -0
  43. package/dist/ai/service/defaultEmbeddingProfile.js.map +1 -0
  44. package/dist/ai/service/index.d.ts +1 -0
  45. package/dist/ai/service/index.js +1 -0
  46. package/dist/ai/service/index.js.map +1 -1
  47. package/dist/ai/service/types.d.ts +1 -0
  48. package/dist/ai/service/types.js.map +1 -1
  49. package/dist/api/ApiServer.js +17 -2
  50. package/dist/api/ApiServer.js.map +1 -1
  51. package/dist/api/ai-gateway/AiGatewayService.d.ts +106 -0
  52. package/dist/api/ai-gateway/AiGatewayService.js +527 -0
  53. package/dist/api/ai-gateway/AiGatewayService.js.map +1 -0
  54. package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.d.ts +38 -0
  55. package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js +128 -0
  56. package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js.map +1 -0
  57. package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.d.ts +25 -0
  58. package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js +91 -0
  59. package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js.map +1 -0
  60. package/dist/api/ai-gateway/auth/GatewayApiKey.d.ts +28 -0
  61. package/dist/api/ai-gateway/auth/GatewayApiKey.js +162 -0
  62. package/dist/api/ai-gateway/auth/GatewayApiKey.js.map +1 -0
  63. package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.d.ts +56 -0
  64. package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js +143 -0
  65. package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js.map +1 -0
  66. package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.d.ts +26 -0
  67. package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js +97 -0
  68. package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js.map +1 -0
  69. package/dist/api/ai-gateway/auth/GatewayPrincipal.d.ts +20 -0
  70. package/dist/api/ai-gateway/auth/GatewayPrincipal.js +37 -0
  71. package/dist/api/ai-gateway/auth/GatewayPrincipal.js.map +1 -0
  72. package/dist/api/ai-gateway/auth/InvocationTokenCodec.d.ts +41 -0
  73. package/dist/api/ai-gateway/auth/InvocationTokenCodec.js +221 -0
  74. package/dist/api/ai-gateway/auth/InvocationTokenCodec.js.map +1 -0
  75. package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.d.ts +54 -0
  76. package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js +152 -0
  77. package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js.map +1 -0
  78. package/dist/api/ai-gateway/connect/index.d.ts +367 -0
  79. package/dist/api/ai-gateway/connect/index.js +1061 -0
  80. package/dist/api/ai-gateway/connect/index.js.map +1 -0
  81. package/dist/api/ai-gateway/credentials/CloudKmsWrapper.d.ts +40 -0
  82. package/dist/api/ai-gateway/credentials/CloudKmsWrapper.js +59 -0
  83. package/dist/api/ai-gateway/credentials/CloudKmsWrapper.js.map +1 -0
  84. package/dist/api/ai-gateway/credentials/CredentialVault.d.ts +14 -0
  85. package/dist/api/ai-gateway/credentials/CredentialVault.js +11 -0
  86. package/dist/api/ai-gateway/credentials/CredentialVault.js.map +1 -0
  87. package/dist/api/ai-gateway/credentials/KeyWrapper.d.ts +27 -0
  88. package/dist/api/ai-gateway/credentials/KeyWrapper.js +3 -0
  89. package/dist/api/ai-gateway/credentials/KeyWrapper.js.map +1 -0
  90. package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.d.ts +27 -0
  91. package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.js +145 -0
  92. package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.js.map +1 -0
  93. package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.d.ts +13 -0
  94. package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.js +133 -0
  95. package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.js.map +1 -0
  96. package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.d.ts +23 -0
  97. package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.js +62 -0
  98. package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.js.map +1 -0
  99. package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.d.ts +23 -0
  100. package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.js +173 -0
  101. package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.js.map +1 -0
  102. package/dist/api/ai-gateway/errors.d.ts +21 -0
  103. package/dist/api/ai-gateway/errors.js +50 -0
  104. package/dist/api/ai-gateway/errors.js.map +1 -0
  105. package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.d.ts +6 -0
  106. package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.js +111 -0
  107. package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.js.map +1 -0
  108. package/dist/api/ai-gateway/protocol/MessagesFrontend.d.ts +6 -0
  109. package/dist/api/ai-gateway/protocol/MessagesFrontend.js +99 -0
  110. package/dist/api/ai-gateway/protocol/MessagesFrontend.js.map +1 -0
  111. package/dist/api/ai-gateway/protocol/ResponsesFrontend.d.ts +6 -0
  112. package/dist/api/ai-gateway/protocol/ResponsesFrontend.js +232 -0
  113. package/dist/api/ai-gateway/protocol/ResponsesFrontend.js.map +1 -0
  114. package/dist/api/ai-gateway/protocol/index.d.ts +3 -0
  115. package/dist/api/ai-gateway/protocol/index.js +10 -0
  116. package/dist/api/ai-gateway/protocol/index.js.map +1 -0
  117. package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.d.ts +7 -0
  118. package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.js +37 -0
  119. package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.js.map +1 -0
  120. package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.d.ts +9 -0
  121. package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.js +127 -0
  122. package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.js.map +1 -0
  123. package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.d.ts +8 -0
  124. package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js +47 -0
  125. package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js.map +1 -0
  126. package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.d.ts +8 -0
  127. package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.js +57 -0
  128. package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.js.map +1 -0
  129. package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.d.ts +1 -0
  130. package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.js +6 -0
  131. package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.js.map +1 -0
  132. package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.d.ts +13 -0
  133. package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js +34 -0
  134. package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js.map +1 -0
  135. package/dist/api/ai-gateway/providers/ProviderRegistry.d.ts +68 -0
  136. package/dist/api/ai-gateway/providers/ProviderRegistry.js +288 -0
  137. package/dist/api/ai-gateway/providers/ProviderRegistry.js.map +1 -0
  138. package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.d.ts +88 -0
  139. package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js +645 -0
  140. package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js.map +1 -0
  141. package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.d.ts +13 -0
  142. package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js +48 -0
  143. package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js.map +1 -0
  144. package/dist/api/ai-gateway/providers/index.d.ts +9 -0
  145. package/dist/api/ai-gateway/providers/index.js +26 -0
  146. package/dist/api/ai-gateway/providers/index.js.map +1 -0
  147. package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.d.ts +5 -0
  148. package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.js +21 -0
  149. package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.js.map +1 -0
  150. package/dist/api/ai-gateway/quota/BailianQuotaAdapter.d.ts +5 -0
  151. package/dist/api/ai-gateway/quota/BailianQuotaAdapter.js +21 -0
  152. package/dist/api/ai-gateway/quota/BailianQuotaAdapter.js.map +1 -0
  153. package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.d.ts +10 -0
  154. package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.js +83 -0
  155. package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.js.map +1 -0
  156. package/dist/api/ai-gateway/quota/KimiQuotaAdapter.d.ts +10 -0
  157. package/dist/api/ai-gateway/quota/KimiQuotaAdapter.js +70 -0
  158. package/dist/api/ai-gateway/quota/KimiQuotaAdapter.js.map +1 -0
  159. package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.d.ts +5 -0
  160. package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.js +21 -0
  161. package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.js.map +1 -0
  162. package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.d.ts +214 -0
  163. package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js +511 -0
  164. package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js.map +1 -0
  165. package/dist/api/ai-gateway/quota/index.d.ts +6 -0
  166. package/dist/api/ai-gateway/quota/index.js +23 -0
  167. package/dist/api/ai-gateway/quota/index.js.map +1 -0
  168. package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.d.ts +26 -0
  169. package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.js +67 -0
  170. package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.js.map +1 -0
  171. package/dist/api/ai-gateway/routing/ModelRouter.d.ts +84 -0
  172. package/dist/api/ai-gateway/routing/ModelRouter.js +274 -0
  173. package/dist/api/ai-gateway/routing/ModelRouter.js.map +1 -0
  174. package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.d.ts +39 -0
  175. package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.js +122 -0
  176. package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.js.map +1 -0
  177. package/dist/api/ai-gateway/routing/SessionAffinityStore.d.ts +49 -0
  178. package/dist/api/ai-gateway/routing/SessionAffinityStore.js +66 -0
  179. package/dist/api/ai-gateway/routing/SessionAffinityStore.js.map +1 -0
  180. package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.d.ts +25 -0
  181. package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js +50 -0
  182. package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js.map +1 -0
  183. package/dist/api/ai-gateway/types.d.ts +112 -0
  184. package/dist/api/ai-gateway/types.js +305 -0
  185. package/dist/api/ai-gateway/types.js.map +1 -0
  186. package/dist/api/auth/AuthContext.d.ts +18 -3
  187. package/dist/api/auth/AuthContext.js +13 -2
  188. package/dist/api/auth/AuthContext.js.map +1 -1
  189. package/dist/api/auth/Authenticator.d.ts +3 -0
  190. package/dist/api/auth/Authenticator.js.map +1 -1
  191. package/dist/api/auth/ClientCredentialsAuthenticator.d.ts +2 -6
  192. package/dist/api/auth/ClientCredentialsAuthenticator.js +12 -30
  193. package/dist/api/auth/ClientCredentialsAuthenticator.js.map +1 -1
  194. package/dist/api/auth/SolidTokenAuthenticator.d.ts +2 -0
  195. package/dist/api/auth/SolidTokenAuthenticator.js +88 -2
  196. package/dist/api/auth/SolidTokenAuthenticator.js.map +1 -1
  197. package/dist/api/auth/TokenIdentity.d.ts +6 -0
  198. package/dist/api/auth/TokenIdentity.js +31 -0
  199. package/dist/api/auth/TokenIdentity.js.map +1 -0
  200. package/dist/api/chatkit/ai-provider.d.ts +9 -23
  201. package/dist/api/chatkit/ai-provider.js +30 -153
  202. package/dist/api/chatkit/ai-provider.js.map +1 -1
  203. package/dist/api/chatkit/default-agent.d.ts +24 -15
  204. package/dist/api/chatkit/default-agent.js +24 -83
  205. package/dist/api/chatkit/default-agent.js.map +1 -1
  206. package/dist/api/chatkit/index.d.ts +2 -1
  207. package/dist/api/chatkit/index.js +3 -1
  208. package/dist/api/chatkit/index.js.map +1 -1
  209. package/dist/api/chatkit/pod-store.d.ts +13 -1
  210. package/dist/api/chatkit/pod-store.js +127 -7
  211. package/dist/api/chatkit/pod-store.js.map +1 -1
  212. package/dist/api/chatkit/runtime/AcpAgentRuntime.d.ts +0 -1
  213. package/dist/api/chatkit/runtime/AcpAgentRuntime.js +14 -51
  214. package/dist/api/chatkit/runtime/AcpAgentRuntime.js.map +1 -1
  215. package/dist/api/chatkit/runtime/AcpRunner.js +2 -1
  216. package/dist/api/chatkit/runtime/AcpRunner.js.map +1 -1
  217. package/dist/api/chatkit/runtime/CodexRuntimeProjector.d.ts +15 -1
  218. package/dist/api/chatkit/runtime/CodexRuntimeProjector.js +52 -34
  219. package/dist/api/chatkit/runtime/CodexRuntimeProjector.js.map +1 -1
  220. package/dist/api/chatkit/service.d.ts +8 -1
  221. package/dist/api/chatkit/service.js +46 -5
  222. package/dist/api/chatkit/service.js.map +1 -1
  223. package/dist/api/chatkit/store.d.ts +23 -1
  224. package/dist/api/chatkit/store.js +56 -0
  225. package/dist/api/chatkit/store.js.map +1 -1
  226. package/dist/api/chatkit/types.d.ts +1 -0
  227. package/dist/api/chatkit/types.js.map +1 -1
  228. package/dist/api/container/common.js +286 -13
  229. package/dist/api/container/common.js.map +1 -1
  230. package/dist/api/container/index.js +126 -6
  231. package/dist/api/container/index.js.map +1 -1
  232. package/dist/api/container/local.js +50 -6
  233. package/dist/api/container/local.js.map +1 -1
  234. package/dist/api/container/rdf.d.ts +15 -0
  235. package/dist/api/container/rdf.js +90 -0
  236. package/dist/api/container/rdf.js.map +1 -0
  237. package/dist/api/container/routes.js +151 -11
  238. package/dist/api/container/routes.js.map +1 -1
  239. package/dist/api/container/types.d.ts +96 -0
  240. package/dist/api/container/types.js.map +1 -1
  241. package/dist/api/handlers/AdminHandler.d.ts +25 -2
  242. package/dist/api/handlers/AdminHandler.js +60 -10
  243. package/dist/api/handlers/AdminHandler.js.map +1 -1
  244. package/dist/api/handlers/AiClientConfigurationHandler.d.ts +7 -0
  245. package/dist/api/handlers/AiClientConfigurationHandler.js +202 -0
  246. package/dist/api/handlers/AiClientConfigurationHandler.js.map +1 -0
  247. package/dist/api/handlers/AiGatewayHandler.d.ts +23 -0
  248. package/dist/api/handlers/AiGatewayHandler.js +231 -0
  249. package/dist/api/handlers/AiGatewayHandler.js.map +1 -0
  250. package/dist/api/handlers/AiGatewayManagementHandler.d.ts +24 -0
  251. package/dist/api/handlers/AiGatewayManagementHandler.js +503 -0
  252. package/dist/api/handlers/AiGatewayManagementHandler.js.map +1 -0
  253. package/dist/api/handlers/ChatHandler.d.ts +11 -12
  254. package/dist/api/handlers/ChatHandler.js +12 -219
  255. package/dist/api/handlers/ChatHandler.js.map +1 -1
  256. package/dist/api/handlers/DashboardHandler.js +22 -116
  257. package/dist/api/handlers/DashboardHandler.js.map +1 -1
  258. package/dist/api/handlers/NetworkSettingsHandler.d.ts +97 -0
  259. package/dist/api/handlers/NetworkSettingsHandler.js +511 -0
  260. package/dist/api/handlers/NetworkSettingsHandler.js.map +1 -0
  261. package/dist/api/handlers/PodSettingsHandler.d.ts +79 -0
  262. package/dist/api/handlers/PodSettingsHandler.js +162 -0
  263. package/dist/api/handlers/PodSettingsHandler.js.map +1 -0
  264. package/dist/api/handlers/ProvisionHandler.d.ts +3 -1
  265. package/dist/api/handlers/ProvisionHandler.js +22 -87
  266. package/dist/api/handlers/ProvisionHandler.js.map +1 -1
  267. package/dist/api/handlers/RdfStatsHandler.d.ts +6 -0
  268. package/dist/api/handlers/RdfStatsHandler.js +85 -0
  269. package/dist/api/handlers/RdfStatsHandler.js.map +1 -0
  270. package/dist/api/handlers/SettingsHandler.d.ts +5 -0
  271. package/dist/api/handlers/SettingsHandler.js +13 -0
  272. package/dist/api/handlers/SettingsHandler.js.map +1 -0
  273. package/dist/api/handlers/StaticSpaHandler.d.ts +8 -0
  274. package/dist/api/handlers/StaticSpaHandler.js +102 -0
  275. package/dist/api/handlers/StaticSpaHandler.js.map +1 -0
  276. package/dist/api/handlers/index.d.ts +1 -0
  277. package/dist/api/handlers/index.js +1 -0
  278. package/dist/api/handlers/index.js.map +1 -1
  279. package/dist/api/http/readBoundedJsonBody.d.ts +14 -0
  280. package/dist/api/http/readBoundedJsonBody.js +58 -0
  281. package/dist/api/http/readBoundedJsonBody.js.map +1 -0
  282. package/dist/api/middleware/AuthMiddleware.d.ts +1 -0
  283. package/dist/api/middleware/AuthMiddleware.js +33 -4
  284. package/dist/api/middleware/AuthMiddleware.js.map +1 -1
  285. package/dist/api/runs/AgentRuntimeTypes.d.ts +18 -3
  286. package/dist/api/runs/AgentRuntimeTypes.js +61 -0
  287. package/dist/api/runs/AgentRuntimeTypes.js.map +1 -1
  288. package/dist/api/runs/InngestRunExecutionBackend.d.ts +28 -3
  289. package/dist/api/runs/InngestRunExecutionBackend.js +26 -3
  290. package/dist/api/runs/InngestRunExecutionBackend.js.map +1 -1
  291. package/dist/api/runs/ManagedRunWorker.d.ts +4 -1
  292. package/dist/api/runs/ManagedRunWorker.js +39 -8
  293. package/dist/api/runs/ManagedRunWorker.js.map +1 -1
  294. package/dist/api/runs/PiAgentRuntimeDriver.d.ts +5 -1
  295. package/dist/api/runs/PiAgentRuntimeDriver.js +94 -57
  296. package/dist/api/runs/PiAgentRuntimeDriver.js.map +1 -1
  297. package/dist/api/runs/RdfRunContextRetriever.d.ts +46 -0
  298. package/dist/api/runs/RdfRunContextRetriever.js +277 -0
  299. package/dist/api/runs/RdfRunContextRetriever.js.map +1 -0
  300. package/dist/api/runs/RunExecutionBackend.d.ts +38 -0
  301. package/dist/api/runs/RunExecutionBackend.js.map +1 -1
  302. package/dist/api/runs/RunStateCenter.d.ts +18 -3
  303. package/dist/api/runs/RunStateCenter.js +85 -24
  304. package/dist/api/runs/RunStateCenter.js.map +1 -1
  305. package/dist/api/runtime.js +163 -3
  306. package/dist/api/runtime.js.map +1 -1
  307. package/dist/api/service/AiClientConfigurationService.d.ts +97 -0
  308. package/dist/api/service/AiClientConfigurationService.js +379 -0
  309. package/dist/api/service/AiClientConfigurationService.js.map +1 -0
  310. package/dist/api/service/RdfBenchmarkReportCatalog.d.ts +86 -0
  311. package/dist/api/service/RdfBenchmarkReportCatalog.js +349 -0
  312. package/dist/api/service/RdfBenchmarkReportCatalog.js.map +1 -0
  313. package/dist/api/service/RdfBenchmarkReportGate.d.ts +78 -0
  314. package/dist/api/service/RdfBenchmarkReportGate.js +197 -0
  315. package/dist/api/service/RdfBenchmarkReportGate.js.map +1 -0
  316. package/dist/api/service/RdfSearchIndexingService.d.ts +113 -0
  317. package/dist/api/service/RdfSearchIndexingService.js +272 -0
  318. package/dist/api/service/RdfSearchIndexingService.js.map +1 -0
  319. package/dist/api/service/RdfSearchIndexingSolidFsSyncer.d.ts +27 -0
  320. package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js +90 -0
  321. package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js.map +1 -0
  322. package/dist/api/service/RdfStorageStatsService.d.ts +31 -0
  323. package/dist/api/service/RdfStorageStatsService.js +97 -0
  324. package/dist/api/service/RdfStorageStatsService.js.map +1 -0
  325. package/dist/api/service/VectorStoreService.d.ts +2 -0
  326. package/dist/api/service/VectorStoreService.js +70 -2
  327. package/dist/api/service/VectorStoreService.js.map +1 -1
  328. package/dist/api/service/VercelChatService.d.ts +27 -38
  329. package/dist/api/service/VercelChatService.js +153 -505
  330. package/dist/api/service/VercelChatService.js.map +1 -1
  331. package/dist/api/service/provider-http-transport.d.ts +21 -0
  332. package/dist/api/service/provider-http-transport.js +108 -2
  333. package/dist/api/service/provider-http-transport.js.map +1 -1
  334. package/dist/api/service/provider-registry.d.ts +5 -7
  335. package/dist/api/service/provider-registry.js +81 -64
  336. package/dist/api/service/provider-registry.js.map +1 -1
  337. package/dist/api/tasks/InngestTaskScheduler.d.ts +44 -4
  338. package/dist/api/tasks/TaskMaterializer.d.ts +10 -1
  339. package/dist/api/tasks/TaskMaterializer.js +39 -4
  340. package/dist/api/tasks/TaskMaterializer.js.map +1 -1
  341. package/dist/api/tasks/TaskService.d.ts +5 -1
  342. package/dist/api/tasks/TaskService.js +3 -0
  343. package/dist/api/tasks/TaskService.js.map +1 -1
  344. package/dist/cli/commands/obj.d.ts +9 -0
  345. package/dist/cli/commands/obj.js +74 -3
  346. package/dist/cli/commands/obj.js.map +1 -1
  347. package/dist/cli/commands/rdf.d.ts +9 -0
  348. package/dist/cli/commands/rdf.js +66 -1
  349. package/dist/cli/commands/rdf.js.map +1 -1
  350. package/dist/cli/commands/start.js +3 -0
  351. package/dist/cli/commands/start.js.map +1 -1
  352. package/dist/cli/lib/solid-auth.d.ts +3 -3
  353. package/dist/cli/lib/solid-auth.js +4 -4
  354. package/dist/cli/lib/solid-auth.js.map +1 -1
  355. package/dist/components/components.jsonld +16 -0
  356. package/dist/components/context.jsonld +815 -28
  357. package/dist/document/Chunker.jsonld +110 -0
  358. package/dist/document/{DocumentParser.d.ts → DocumentReader.d.ts} +23 -11
  359. package/dist/document/{DocumentParser.js → DocumentReader.js} +2 -2
  360. package/dist/document/DocumentReader.js.map +1 -0
  361. package/dist/document/DocumentReader.jsonld +82 -0
  362. package/dist/document/HeadingChunker.jsonld +41 -0
  363. package/dist/document/{JinaDocumentParser.d.ts → JinaReader.d.ts} +7 -7
  364. package/dist/document/{JinaDocumentParser.js → JinaReader.js} +12 -12
  365. package/dist/document/JinaReader.js.map +1 -0
  366. package/dist/document/JinaReader.jsonld +133 -0
  367. package/dist/document/L0SourceSummary.d.ts +103 -0
  368. package/dist/document/L0SourceSummary.js +157 -0
  369. package/dist/document/L0SourceSummary.js.map +1 -0
  370. package/dist/document/L0SourceSummary.jsonld +326 -0
  371. package/dist/document/PaddleOcrReader.d.ts +40 -0
  372. package/dist/document/PaddleOcrReader.js +53 -0
  373. package/dist/document/PaddleOcrReader.js.map +1 -0
  374. package/dist/document/PaddleOcrReader.jsonld +234 -0
  375. package/dist/document/ReaderAiConfig.d.ts +50 -0
  376. package/dist/document/ReaderAiConfig.js +109 -0
  377. package/dist/document/ReaderAiConfig.js.map +1 -0
  378. package/dist/document/ReaderAiConfig.jsonld +185 -0
  379. package/dist/document/ReaderPolicy.d.ts +89 -0
  380. package/dist/document/ReaderPolicy.js +158 -0
  381. package/dist/document/ReaderPolicy.js.map +1 -0
  382. package/dist/document/ReaderPolicy.jsonld +218 -0
  383. package/dist/document/index.d.ts +6 -2
  384. package/dist/document/index.js +6 -2
  385. package/dist/document/index.js.map +1 -1
  386. package/dist/edge/DdnsManager.d.ts +1 -1
  387. package/dist/edge/DdnsManager.js.map +1 -1
  388. package/dist/edge/EdgeNodeAgent.d.ts +4 -0
  389. package/dist/edge/EdgeNodeAgent.js +6 -0
  390. package/dist/edge/EdgeNodeAgent.js.map +1 -1
  391. package/dist/edge/EdgeNodeAgent.jsonld +8 -0
  392. package/dist/edge/EdgeNodeAgentInitializer.d.ts +16 -0
  393. package/dist/edge/EdgeNodeAgentInitializer.js +51 -0
  394. package/dist/edge/EdgeNodeAgentInitializer.js.map +1 -1
  395. package/dist/edge/EdgeNodeAgentInitializer.jsonld +250 -0
  396. package/dist/edge/EdgeNodeCertificateCapabilityBridge.d.ts +34 -0
  397. package/dist/edge/EdgeNodeCertificateCapabilityBridge.js +111 -0
  398. package/dist/edge/EdgeNodeCertificateCapabilityBridge.js.map +1 -0
  399. package/dist/edge/acme/AcmeCertificateManager.d.ts +14 -1
  400. package/dist/edge/acme/AcmeCertificateManager.js +67 -7
  401. package/dist/edge/acme/AcmeCertificateManager.js.map +1 -1
  402. package/dist/edge/acme/AcmeCertificateManager.jsonld +22 -2
  403. package/dist/edge/acme/ClusterCertificateManager.d.ts +12 -0
  404. package/dist/edge/acme/ClusterCertificateManager.js +38 -0
  405. package/dist/edge/acme/ClusterCertificateManager.js.map +1 -1
  406. package/dist/extensions/ExtensionRuntime.d.ts +17 -0
  407. package/dist/extensions/ExtensionRuntime.js +171 -0
  408. package/dist/extensions/ExtensionRuntime.js.map +1 -0
  409. package/dist/extensions/PodCredentialResolver.d.ts +23 -0
  410. package/dist/extensions/PodCredentialResolver.js +139 -0
  411. package/dist/extensions/PodCredentialResolver.js.map +1 -0
  412. package/dist/extensions/index.d.ts +3 -0
  413. package/dist/extensions/index.js +20 -0
  414. package/dist/extensions/index.js.map +1 -0
  415. package/dist/extensions/types.d.ts +73 -0
  416. package/dist/extensions/types.js +3 -0
  417. package/dist/extensions/types.js.map +1 -0
  418. package/dist/http/SubgraphSparqlHttpHandler.d.ts +20 -1
  419. package/dist/http/SubgraphSparqlHttpHandler.js +324 -43
  420. package/dist/http/SubgraphSparqlHttpHandler.js.map +1 -1
  421. package/dist/http/SubgraphSparqlHttpHandler.jsonld +87 -0
  422. package/dist/identity/drizzle/EdgeNodeRepository.js +3 -2
  423. package/dist/identity/drizzle/EdgeNodeRepository.js.map +1 -1
  424. package/dist/identity/drizzle/schema.pg.js +1 -1
  425. package/dist/identity/drizzle/schema.pg.js.map +1 -1
  426. package/dist/identity/drizzle/schema.sqlite.js +1 -1
  427. package/dist/identity/drizzle/schema.sqlite.js.map +1 -1
  428. package/dist/identity/oidc/ScopedPickWebIdHandler.js +5 -5
  429. package/dist/identity/oidc/ScopedPickWebIdHandler.js.map +1 -1
  430. package/dist/index.d.ts +12 -2
  431. package/dist/index.js +13 -1
  432. package/dist/index.js.map +1 -1
  433. package/dist/main.js +3 -0
  434. package/dist/main.js.map +1 -1
  435. package/dist/provision/LocalProvisionState.d.ts +28 -0
  436. package/dist/provision/LocalProvisionState.js +124 -0
  437. package/dist/provision/LocalProvisionState.js.map +1 -0
  438. package/dist/provision/ProvisionCodeCodec.d.ts +7 -3
  439. package/dist/provision/ProvisionCodeCodec.js +10 -3
  440. package/dist/provision/ProvisionCodeCodec.js.map +1 -1
  441. package/dist/provision/ProvisionPodCreator.d.ts +15 -1
  442. package/dist/provision/ProvisionPodCreator.js +68 -1
  443. package/dist/provision/ProvisionPodCreator.js.map +1 -1
  444. package/dist/provision/ProvisionPodCreator.jsonld +31 -0
  445. package/dist/provision/ServiceAccessTokenCodec.d.ts +45 -0
  446. package/dist/provision/ServiceAccessTokenCodec.js +86 -0
  447. package/dist/provision/ServiceAccessTokenCodec.js.map +1 -0
  448. package/dist/runtime/GatewayAdminProxyAuth.d.ts +29 -0
  449. package/dist/runtime/GatewayAdminProxyAuth.js +108 -0
  450. package/dist/runtime/GatewayAdminProxyAuth.js.map +1 -0
  451. package/dist/runtime/Proxy.d.ts +10 -0
  452. package/dist/runtime/Proxy.js +64 -6
  453. package/dist/runtime/Proxy.js.map +1 -1
  454. package/dist/runtime/XpodRuntime.js +1 -0
  455. package/dist/runtime/XpodRuntime.js.map +1 -1
  456. package/dist/runtime/bootstrap.d.ts +1 -0
  457. package/dist/runtime/bootstrap.js +29 -0
  458. package/dist/runtime/bootstrap.js.map +1 -1
  459. package/dist/runtime/css-process.d.ts +1 -0
  460. package/dist/runtime/css-process.js +1 -0
  461. package/dist/runtime/css-process.js.map +1 -1
  462. package/dist/runtime/index.d.ts +1 -0
  463. package/dist/runtime/index.js +3 -1
  464. package/dist/runtime/index.js.map +1 -1
  465. package/dist/runtime/lifecycle.d.ts +3 -1
  466. package/dist/runtime/lifecycle.js +3 -1
  467. package/dist/runtime/lifecycle.js.map +1 -1
  468. package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js +2 -0
  469. package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js.map +1 -1
  470. package/dist/runtime/runner/types.d.ts +3 -0
  471. package/dist/runtime/runner/types.js.map +1 -1
  472. package/dist/runtime/runtime-types.d.ts +2 -0
  473. package/dist/runtime/runtime-types.js.map +1 -1
  474. package/dist/runtime/safe-env.d.ts +15 -0
  475. package/dist/runtime/safe-env.js +109 -0
  476. package/dist/runtime/safe-env.js.map +1 -0
  477. package/dist/security/index.d.ts +1 -0
  478. package/dist/security/index.js +18 -0
  479. package/dist/security/index.js.map +1 -0
  480. package/dist/security/secret-cell/DeploymentRootKeyProvider.d.ts +17 -0
  481. package/dist/security/secret-cell/DeploymentRootKeyProvider.js +61 -0
  482. package/dist/security/secret-cell/DeploymentRootKeyProvider.js.map +1 -0
  483. package/dist/security/secret-cell/DeploymentRootKeyProvider.jsonld +124 -0
  484. package/dist/security/secret-cell/SecretCellVault.d.ts +55 -0
  485. package/dist/security/secret-cell/SecretCellVault.js +242 -0
  486. package/dist/security/secret-cell/SecretCellVault.js.map +1 -0
  487. package/dist/security/secret-cell/SecretCellVault.jsonld +207 -0
  488. package/dist/security/secret-cell/index.d.ts +2 -0
  489. package/dist/security/secret-cell/index.js +11 -0
  490. package/dist/security/secret-cell/index.js.map +1 -0
  491. package/dist/solidfs/CompositeSolidFsSyncer.d.ts +18 -0
  492. package/dist/solidfs/CompositeSolidFsSyncer.js +32 -0
  493. package/dist/solidfs/CompositeSolidFsSyncer.js.map +1 -0
  494. package/dist/solidfs/LocalSolidFS.js +25 -1
  495. package/dist/solidfs/LocalSolidFS.js.map +1 -1
  496. package/dist/solidfs/RdfIndexSolidFsSyncer.d.ts +41 -2
  497. package/dist/solidfs/RdfIndexSolidFsSyncer.js +331 -21
  498. package/dist/solidfs/RdfIndexSolidFsSyncer.js.map +1 -1
  499. package/dist/solidfs/SolidFsMetaNotes.d.ts +25 -0
  500. package/dist/solidfs/SolidFsMetaNotes.js +103 -0
  501. package/dist/solidfs/SolidFsMetaNotes.js.map +1 -0
  502. package/dist/solidfs/SolidFsSyncJournal.d.ts +2 -2
  503. package/dist/solidfs/SolidFsSyncJournal.js +9 -4
  504. package/dist/solidfs/SolidFsSyncJournal.js.map +1 -1
  505. package/dist/solidfs/SolidFsSyncJournal.jsonld +119 -0
  506. package/dist/solidfs/WorkspacePrompt.d.ts +13 -0
  507. package/dist/solidfs/WorkspacePrompt.js +42 -0
  508. package/dist/solidfs/WorkspacePrompt.js.map +1 -0
  509. package/dist/solidfs/index.d.ts +3 -0
  510. package/dist/solidfs/index.js +3 -0
  511. package/dist/solidfs/index.js.map +1 -1
  512. package/dist/solidfs/types.d.ts +12 -2
  513. package/dist/solidfs/types.js.map +1 -1
  514. package/dist/storage/accessors/MixDataAccessor.d.ts +36 -4
  515. package/dist/storage/accessors/MixDataAccessor.js +222 -23
  516. package/dist/storage/accessors/MixDataAccessor.js.map +1 -1
  517. package/dist/storage/accessors/MixDataAccessor.jsonld +89 -0
  518. package/dist/storage/accessors/SolidRdfDataAccessor.d.ts +6 -1
  519. package/dist/storage/accessors/SolidRdfDataAccessor.js +35 -0
  520. package/dist/storage/accessors/SolidRdfDataAccessor.js.map +1 -1
  521. package/dist/storage/accessors/SolidRdfDataAccessor.jsonld +20 -0
  522. package/dist/storage/database/PostgresPoolManager.d.ts +1 -0
  523. package/dist/storage/database/PostgresPoolManager.js +2 -2
  524. package/dist/storage/database/PostgresPoolManager.js.map +1 -1
  525. package/dist/storage/locking/UrlAwareRedisLocker.d.ts +2 -0
  526. package/dist/storage/locking/UrlAwareRedisLocker.js +65 -0
  527. package/dist/storage/locking/UrlAwareRedisLocker.js.map +1 -1
  528. package/dist/storage/locking/UrlAwareRedisLocker.jsonld +19 -0
  529. package/dist/storage/rdf/PostgresRdfEngine.d.ts +286 -9
  530. package/dist/storage/rdf/PostgresRdfEngine.js +10773 -2084
  531. package/dist/storage/rdf/PostgresRdfEngine.js.map +1 -1
  532. package/dist/storage/rdf/PostgresRdfEngine.jsonld +1693 -89
  533. package/dist/storage/rdf/PostgresRdfSqlExecutor.d.ts +24 -0
  534. package/dist/storage/rdf/PostgresRdfSqlExecutor.js +131 -0
  535. package/dist/storage/rdf/PostgresRdfSqlExecutor.js.map +1 -0
  536. package/dist/storage/rdf/PostgresRdfTextIndex.d.ts +54 -0
  537. package/dist/storage/rdf/PostgresRdfTextIndex.js +1255 -0
  538. package/dist/storage/rdf/PostgresRdfTextIndex.js.map +1 -0
  539. package/dist/storage/rdf/PostgresRdfTextIndex.jsonld +487 -0
  540. package/dist/storage/rdf/PostgresRdfVectorIndex.d.ts +46 -0
  541. package/dist/storage/rdf/PostgresRdfVectorIndex.js +1165 -0
  542. package/dist/storage/rdf/PostgresRdfVectorIndex.js.map +1 -0
  543. package/dist/storage/rdf/PostgresRdfVectorIndex.jsonld +423 -0
  544. package/dist/storage/rdf/Rdf3xIndex.d.ts +14 -1
  545. package/dist/storage/rdf/Rdf3xIndex.js +286 -2
  546. package/dist/storage/rdf/Rdf3xIndex.js.map +1 -1
  547. package/dist/storage/rdf/Rdf3xIndex.jsonld +36 -0
  548. package/dist/storage/rdf/Rdf3xSchema.d.ts +5 -1
  549. package/dist/storage/rdf/Rdf3xSchema.js +17 -3
  550. package/dist/storage/rdf/Rdf3xSchema.js.map +1 -1
  551. package/dist/storage/rdf/RdfAccessScope.d.ts +22 -0
  552. package/dist/storage/rdf/RdfAccessScope.js +345 -0
  553. package/dist/storage/rdf/RdfAccessScope.js.map +1 -0
  554. package/dist/storage/rdf/RdfAccessScope.jsonld +45 -0
  555. package/dist/storage/rdf/RdfFusionRankPlan.d.ts +2 -0
  556. package/dist/storage/rdf/RdfFusionRankPlan.js +186 -0
  557. package/dist/storage/rdf/RdfFusionRankPlan.js.map +1 -0
  558. package/dist/storage/rdf/RdfJoinShape.d.ts +8 -0
  559. package/dist/storage/rdf/RdfJoinShape.js +31 -0
  560. package/dist/storage/rdf/RdfJoinShape.js.map +1 -0
  561. package/dist/storage/rdf/RdfQuadIndex.d.ts +5 -2
  562. package/dist/storage/rdf/RdfQuadIndex.js +94 -6
  563. package/dist/storage/rdf/RdfQuadIndex.js.map +1 -1
  564. package/dist/storage/rdf/RdfQuadIndex.jsonld +12 -0
  565. package/dist/storage/rdf/RdfQueryExecutor.d.ts +3 -4
  566. package/dist/storage/rdf/RdfQueryExecutor.js +235 -8
  567. package/dist/storage/rdf/RdfQueryExecutor.js.map +1 -1
  568. package/dist/storage/rdf/RdfSearchSourceFilter.d.ts +10 -0
  569. package/dist/storage/rdf/RdfSearchSourceFilter.js +83 -0
  570. package/dist/storage/rdf/RdfSearchSourceFilter.js.map +1 -0
  571. package/dist/storage/rdf/RdfSparqlAdapter.d.ts +27 -1
  572. package/dist/storage/rdf/RdfSparqlAdapter.js +265 -3
  573. package/dist/storage/rdf/RdfSparqlAdapter.js.map +1 -1
  574. package/dist/storage/rdf/RdfSparqlAdapter.jsonld +8 -0
  575. package/dist/storage/rdf/RdfTermDictionary.d.ts +7 -1
  576. package/dist/storage/rdf/RdfTermDictionary.js +139 -0
  577. package/dist/storage/rdf/RdfTermDictionary.js.map +1 -1
  578. package/dist/storage/rdf/RdfTermDictionary.jsonld +4 -0
  579. package/dist/storage/rdf/RdfTextIndex.d.ts +45 -2
  580. package/dist/storage/rdf/RdfTextIndex.js +810 -114
  581. package/dist/storage/rdf/RdfTextIndex.js.map +1 -1
  582. package/dist/storage/rdf/RdfTextIndex.jsonld +193 -0
  583. package/dist/storage/rdf/RdfTextProjection.d.ts +10 -0
  584. package/dist/storage/rdf/RdfTextProjection.js +258 -0
  585. package/dist/storage/rdf/RdfTextProjection.js.map +1 -0
  586. package/dist/storage/rdf/RdfVectorIndex.d.ts +30 -2
  587. package/dist/storage/rdf/RdfVectorIndex.js +461 -38
  588. package/dist/storage/rdf/RdfVectorIndex.js.map +1 -1
  589. package/dist/storage/rdf/RdfVectorIndex.jsonld +163 -0
  590. package/dist/storage/rdf/SolidRdfEngine.d.ts +12 -9
  591. package/dist/storage/rdf/SolidRdfEngine.js +48 -22
  592. package/dist/storage/rdf/SolidRdfEngine.js.map +1 -1
  593. package/dist/storage/rdf/SolidRdfEngine.jsonld +33 -43
  594. package/dist/storage/rdf/SolidRdfSparqlEngine.d.ts +19 -8
  595. package/dist/storage/rdf/SolidRdfSparqlEngine.js +674 -44
  596. package/dist/storage/rdf/SolidRdfSparqlEngine.js.map +1 -1
  597. package/dist/storage/rdf/SolidRdfSparqlEngine.jsonld +51 -0
  598. package/dist/storage/rdf/index.d.ts +9 -5
  599. package/dist/storage/rdf/index.js +42 -1
  600. package/dist/storage/rdf/index.js.map +1 -1
  601. package/dist/storage/rdf/models-benchmark.d.ts +264 -2
  602. package/dist/storage/rdf/models-benchmark.js +4207 -155
  603. package/dist/storage/rdf/models-benchmark.js.map +1 -1
  604. package/dist/storage/rdf/types.d.ts +833 -4
  605. package/dist/storage/rdf/types.js.map +1 -1
  606. package/dist/storage/rdf/types.jsonld +348 -0
  607. package/dist/storage/sparql/CompatibilitySparqlEngine.d.ts +14 -13
  608. package/dist/storage/sparql/CompatibilitySparqlEngine.js +24 -24
  609. package/dist/storage/sparql/CompatibilitySparqlEngine.js.map +1 -1
  610. package/dist/storage/sparql/CompatibilitySparqlEngineImpl.d.ts +14 -13
  611. package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js +30 -18
  612. package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js.map +1 -1
  613. package/dist/storage/sparql/SubgraphQueryEngine.d.ts +21 -12
  614. package/dist/storage/sparql/SubgraphQueryEngine.js +12 -12
  615. package/dist/storage/sparql/SubgraphQueryEngine.js.map +1 -1
  616. package/dist/terminal/sandbox/MacOSSandbox.js +2 -1
  617. package/dist/terminal/sandbox/MacOSSandbox.js.map +1 -1
  618. package/dist/terminal/sandbox/index.js +2 -1
  619. package/dist/terminal/sandbox/index.js.map +1 -1
  620. package/dist/test-utils/no-auth-xpod.js +3 -0
  621. package/dist/test-utils/no-auth-xpod.js.map +1 -1
  622. package/dist/tunnel/LocalTunnelProvider.d.ts +3 -0
  623. package/dist/tunnel/LocalTunnelProvider.js +17 -1
  624. package/dist/tunnel/LocalTunnelProvider.js.map +1 -1
  625. package/dist/tunnel/LocalTunnelProvider.jsonld +23 -0
  626. package/dist/tunnel/SakuraFrpTunnelProvider.d.ts +3 -0
  627. package/dist/tunnel/SakuraFrpTunnelProvider.js +18 -2
  628. package/dist/tunnel/SakuraFrpTunnelProvider.js.map +1 -1
  629. package/dist/tunnel/TunnelProfiles.d.ts +22 -0
  630. package/dist/tunnel/TunnelProfiles.js +208 -0
  631. package/dist/tunnel/TunnelProfiles.js.map +1 -0
  632. package/dist/tunnel/index.d.ts +2 -0
  633. package/dist/tunnel/index.js +4 -1
  634. package/dist/tunnel/index.js.map +1 -1
  635. package/dist/util/identifiers/ClusterIdentifierStrategy.d.ts +3 -0
  636. package/dist/util/identifiers/ClusterIdentifierStrategy.js +18 -2
  637. package/dist/util/identifiers/ClusterIdentifierStrategy.js.map +1 -1
  638. package/dist/util/identifiers/ClusterIdentifierStrategy.jsonld +5 -1
  639. package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.d.ts +55 -0
  640. package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.js +167 -0
  641. package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionHeader.d.ts +3 -0
  642. package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionHeader.js +8 -0
  643. package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionList.d.ts +4 -0
  644. package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionList.js +36 -0
  645. package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.d.ts +4 -0
  646. package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.js +37 -0
  647. package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMainHeader.d.ts +3 -0
  648. package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMainHeader.js +7 -0
  649. package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.d.ts +14 -0
  650. package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.js +333 -0
  651. package/node_modules/@undefineds.co/ai-connection/dist/AiProviderCard.d.ts +22 -0
  652. package/node_modules/@undefineds.co/ai-connection/dist/AiProviderCard.js +43 -0
  653. package/node_modules/@undefineds.co/ai-connection/dist/AiQuotaCard.d.ts +8 -0
  654. package/node_modules/@undefineds.co/ai-connection/dist/AiQuotaCard.js +6 -0
  655. package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.d.ts +120 -0
  656. package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.js +414 -0
  657. package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.d.ts +32 -0
  658. package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.js +212 -0
  659. package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.d.ts +14 -0
  660. package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.js +90 -0
  661. package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.cjs +668 -0
  662. package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.d.ts +6 -0
  663. package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.js +6 -0
  664. package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.d.ts +21 -0
  665. package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.js +82 -0
  666. package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.d.ts +13 -0
  667. package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.js +83 -0
  668. package/node_modules/@undefineds.co/ai-connection/dist/client-config/transaction.d.ts +17 -0
  669. package/node_modules/@undefineds.co/ai-connection/dist/client-config/transaction.js +153 -0
  670. package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.d.ts +40 -0
  671. package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.js +1 -0
  672. package/node_modules/@undefineds.co/ai-connection/dist/controller.d.ts +42 -0
  673. package/node_modules/@undefineds.co/ai-connection/dist/controller.js +289 -0
  674. package/node_modules/@undefineds.co/ai-connection/dist/index.d.ts +16 -0
  675. package/node_modules/@undefineds.co/ai-connection/dist/index.js +41 -0
  676. package/node_modules/@undefineds.co/ai-connection/dist/manifest.d.ts +1 -0
  677. package/node_modules/@undefineds.co/ai-connection/dist/manifest.js +18 -0
  678. package/node_modules/@undefineds.co/ai-connection/dist/service-access.d.ts +3 -0
  679. package/node_modules/@undefineds.co/ai-connection/dist/service-access.js +133 -0
  680. package/node_modules/@undefineds.co/ai-connection/package.json +50 -0
  681. package/node_modules/@undefineds.co/extension-sdk/README.md +299 -0
  682. package/node_modules/@undefineds.co/extension-sdk/dist/index.d.ts +5 -0
  683. package/node_modules/@undefineds.co/extension-sdk/dist/index.js +5 -0
  684. package/node_modules/@undefineds.co/extension-sdk/dist/layout.d.ts +16 -0
  685. package/node_modules/@undefineds.co/extension-sdk/dist/layout.js +36 -0
  686. package/node_modules/@undefineds.co/extension-sdk/dist/manifest.d.ts +27 -0
  687. package/node_modules/@undefineds.co/extension-sdk/dist/manifest.js +79 -0
  688. package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.d.ts +7 -0
  689. package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.js +8 -0
  690. package/node_modules/@undefineds.co/extension-sdk/dist/react/auth-boundary.d.ts +27 -0
  691. package/node_modules/@undefineds.co/extension-sdk/dist/react/auth-boundary.js +49 -0
  692. package/node_modules/@undefineds.co/extension-sdk/dist/react/layout-context.d.ts +11 -0
  693. package/node_modules/@undefineds.co/extension-sdk/dist/react/layout-context.js +9 -0
  694. package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.d.ts +38 -0
  695. package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.js +132 -0
  696. package/node_modules/@undefineds.co/extension-sdk/dist/react.d.ts +12 -0
  697. package/node_modules/@undefineds.co/extension-sdk/dist/react.js +19 -0
  698. package/node_modules/@undefineds.co/extension-sdk/dist/testing.d.ts +7 -0
  699. package/node_modules/@undefineds.co/extension-sdk/dist/testing.js +27 -0
  700. package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +225 -0
  701. package/node_modules/@undefineds.co/extension-sdk/dist/web.js +142 -0
  702. package/node_modules/@undefineds.co/extension-sdk/package.json +49 -0
  703. package/node_modules/@undefineds.co/shared-ui/dist/badge.d.ts +8 -0
  704. package/node_modules/@undefineds.co/shared-ui/dist/badge.js +17 -0
  705. package/node_modules/@undefineds.co/shared-ui/dist/button.d.ts +10 -0
  706. package/node_modules/@undefineds.co/shared-ui/dist/button.js +30 -0
  707. package/node_modules/@undefineds.co/shared-ui/dist/card.d.ts +7 -0
  708. package/node_modules/@undefineds.co/shared-ui/dist/card.js +15 -0
  709. package/node_modules/@undefineds.co/shared-ui/dist/index.d.ts +6 -0
  710. package/node_modules/@undefineds.co/shared-ui/dist/index.js +6 -0
  711. package/node_modules/@undefineds.co/shared-ui/dist/input.d.ts +4 -0
  712. package/node_modules/@undefineds.co/shared-ui/dist/input.js +5 -0
  713. package/node_modules/@undefineds.co/shared-ui/dist/theme.css +121 -0
  714. package/node_modules/@undefineds.co/shared-ui/dist/utils.d.ts +2 -0
  715. package/node_modules/@undefineds.co/shared-ui/dist/utils.js +5 -0
  716. package/node_modules/@undefineds.co/shared-ui/dist/workspace.d.ts +23 -0
  717. package/node_modules/@undefineds.co/shared-ui/dist/workspace.js +38 -0
  718. package/node_modules/@undefineds.co/shared-ui/package.json +39 -0
  719. package/node_modules/@undefineds.co/solid-sdk/dist/index.d.ts +3 -0
  720. package/node_modules/@undefineds.co/solid-sdk/dist/index.js +3 -0
  721. package/node_modules/@undefineds.co/solid-sdk/dist/pod-runtime.d.ts +45 -0
  722. package/node_modules/@undefineds.co/solid-sdk/dist/pod-runtime.js +147 -0
  723. package/node_modules/@undefineds.co/solid-sdk/dist/react.d.ts +15 -0
  724. package/node_modules/@undefineds.co/solid-sdk/dist/react.js +15 -0
  725. package/node_modules/@undefineds.co/solid-sdk/dist/session.d.ts +42 -0
  726. package/node_modules/@undefineds.co/solid-sdk/dist/session.js +127 -0
  727. package/node_modules/@undefineds.co/solid-sdk/package.json +45 -0
  728. package/package.json +32 -12
  729. package/static/app/assets/index-BoYHJ6si.js +230 -0
  730. package/static/app/assets/inrupt-smoke.js +2 -2
  731. package/static/app/assets/main.css +1 -1
  732. package/static/app/assets/main.js +9 -9
  733. package/static/dashboard/assets/NetworkPage-Brt79fuQ.js +2 -0
  734. package/static/dashboard/assets/PaneListHeader-57nvMwH6.js +1 -0
  735. package/static/dashboard/assets/PodPage-CM6do1vB.js +2 -0
  736. package/static/dashboard/assets/ServicesPage-BUNxGJRz.js +1 -0
  737. package/static/dashboard/assets/card-B9Zjf_2p.js +1 -0
  738. package/static/dashboard/assets/dashboard-8C6o666W.js +305 -0
  739. package/static/dashboard/assets/dashboard-CSdewNeA.css +1 -0
  740. package/static/dashboard/assets/database-DPh9wDY9.js +1 -0
  741. package/static/dashboard/assets/external-link-VbMQvVMz.js +1 -0
  742. package/static/dashboard/assets/index-RfiFckzb.js +51 -0
  743. package/static/dashboard/assets/refresh-cw-BxVxNxNr.js +1 -0
  744. package/static/dashboard/assets/services-status-context-DKmJ7ISr.js +1 -0
  745. package/static/dashboard/dashboard.html +2 -2
  746. package/static/settings/assets/ModelsPage-D_IH7AH3.js +1 -0
  747. package/static/settings/assets/PaneListHeader-Bgaze006.js +1 -0
  748. package/static/settings/assets/PodPage-Cy1VNObw.js +2 -0
  749. package/static/settings/assets/ServicesPage-BsFaxVWC.js +1 -0
  750. package/static/settings/assets/SettingsPage-UafNWE_p.js +48 -0
  751. package/static/settings/assets/card-B_bXSIn-.js +1 -0
  752. package/static/settings/assets/services-status-context-DiX-AbrP.js +1 -0
  753. package/static/settings/assets/settings-B30oMfZq.js +305 -0
  754. package/static/settings/assets/settings-CSdewNeA.css +1 -0
  755. package/static/settings/assets/workspace-layout-Dv1Yn9Ci.js +1 -0
  756. package/static/settings/auth.html +21 -0
  757. package/static/settings/reachability.html +221 -0
  758. package/static/settings/reachability.svg +7 -0
  759. package/static/settings/reachability.webmanifest +18 -0
  760. package/static/settings/settings.html +13 -0
  761. package/static/settings/signal-pod.html +293 -0
  762. package/static/settings/vite.svg +1 -0
  763. package/dist/api/service/ai-gateway-transport.d.ts +0 -25
  764. package/dist/api/service/ai-gateway-transport.js +0 -136
  765. package/dist/api/service/ai-gateway-transport.js.map +0 -1
  766. package/dist/api/service/chat-protocol-adapters.d.ts +0 -5
  767. package/dist/api/service/chat-protocol-adapters.js +0 -146
  768. package/dist/api/service/chat-protocol-adapters.js.map +0 -1
  769. package/dist/api/service/chat-routing.d.ts +0 -8
  770. package/dist/api/service/chat-routing.js +0 -16
  771. package/dist/api/service/chat-routing.js.map +0 -1
  772. package/dist/api/service/platform-ai-config.d.ts +0 -10
  773. package/dist/api/service/platform-ai-config.js +0 -76
  774. package/dist/api/service/platform-ai-config.js.map +0 -1
  775. package/dist/document/DocumentParser.js.map +0 -1
  776. package/dist/document/JinaDocumentParser.js.map +0 -1
  777. package/static/app/assets/index-C1yksyT4.js +0 -171
  778. package/static/dashboard/assets/dashboard-BssaVKTn.css +0 -1
  779. package/static/dashboard/assets/dashboard-Ckuadl3C.js +0 -54
@@ -0,0 +1,305 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelsPage-D_IH7AH3.js","assets/card-B_bXSIn-.js","assets/workspace-layout-Dv1Yn9Ci.js","assets/PodPage-Cy1VNObw.js","assets/PaneListHeader-Bgaze006.js","assets/ServicesPage-BsFaxVWC.js","assets/services-status-context-DiX-AbrP.js","assets/SettingsPage-UafNWE_p.js"])))=>i.map(i=>d[i]);
2
+ function _mergeNamespaces(i,e){for(var t=0;t<e.length;t++){const n=e[t];if(typeof n!="string"&&!Array.isArray(n)){for(const s in n)if(s!=="default"&&!(s in i)){const a=Object.getOwnPropertyDescriptor(n,s);a&&Object.defineProperty(i,s,a.get?a:{enumerable:!0,get:()=>n[s]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const u of a.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&n(u)}).observe(document,{childList:!0,subtree:!0});function t(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(s){if(s.ep)return;s.ep=!0;const a=t(s);fetch(s.href,a)}})();function getDefaultExportFromCjs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var jsxRuntime={exports:{}},reactJsxRuntime_production={};var hasRequiredReactJsxRuntime_production;function requireReactJsxRuntime_production(){if(hasRequiredReactJsxRuntime_production)return reactJsxRuntime_production;hasRequiredReactJsxRuntime_production=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,s,a){var u=null;if(a!==void 0&&(u=""+a),s.key!==void 0&&(u=""+s.key),"key"in s){a={};for(var c in s)c!=="key"&&(a[c]=s[c])}else a=s;return s=a.ref,{$$typeof:i,type:n,key:u,ref:s!==void 0?s:null,props:a}}return reactJsxRuntime_production.Fragment=e,reactJsxRuntime_production.jsx=t,reactJsxRuntime_production.jsxs=t,reactJsxRuntime_production}var hasRequiredJsxRuntime;function requireJsxRuntime(){return hasRequiredJsxRuntime||(hasRequiredJsxRuntime=1,jsxRuntime.exports=requireReactJsxRuntime_production()),jsxRuntime.exports}var jsxRuntimeExports=requireJsxRuntime(),react={exports:{}},react_production={};var hasRequiredReact_production;function requireReact_production(){if(hasRequiredReact_production)return react_production;hasRequiredReact_production=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),y=Symbol.iterator;function S(G){return G===null||typeof G!="object"?null:(G=y&&G[y]||G["@@iterator"],typeof G=="function"?G:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,T={};function A(G,ce,oe){this.props=G,this.context=ce,this.refs=T,this.updater=oe||w}A.prototype.isReactComponent={},A.prototype.setState=function(G,ce){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,ce,"setState")},A.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function F(){}F.prototype=A.prototype;function x(G,ce,oe){this.props=G,this.context=ce,this.refs=T,this.updater=oe||w}var D=x.prototype=new F;D.constructor=x,R(D,A.prototype),D.isPureReactComponent=!0;var O=Array.isArray;function K(){}var z={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function Ee(G,ce,oe){var Fe=oe.ref;return{$$typeof:i,type:G,key:ce,ref:Fe!==void 0?Fe:null,props:oe}}function q(G,ce){return Ee(G.type,ce,G.props)}function Y(G){return typeof G=="object"&&G!==null&&G.$$typeof===i}function Te(G){var ce={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(oe){return ce[oe]})}var re=/\/+/g;function $e(G,ce){return typeof G=="object"&&G!==null&&G.key!=null?Te(""+G.key):ce.toString(36)}function ze(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(K,K):(G.status="pending",G.then(function(ce){G.status==="pending"&&(G.status="fulfilled",G.value=ce)},function(ce){G.status==="pending"&&(G.status="rejected",G.reason=ce)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function ye(G,ce,oe,Fe,Ue){var Je=typeof G;(Je==="undefined"||Je==="boolean")&&(G=null);var He=!1;if(G===null)He=!0;else switch(Je){case"bigint":case"string":case"number":He=!0;break;case"object":switch(G.$$typeof){case i:case e:He=!0;break;case p:return He=G._init,ye(He(G._payload),ce,oe,Fe,Ue)}}if(He)return Ue=Ue(G),He=Fe===""?"."+$e(G,0):Fe,O(Ue)?(oe="",He!=null&&(oe=He.replace(re,"$&/")+"/"),ye(Ue,ce,oe,"",function(Oe){return Oe})):Ue!=null&&(Y(Ue)&&(Ue=q(Ue,oe+(Ue.key==null||G&&G.key===Ue.key?"":(""+Ue.key).replace(re,"$&/")+"/")+He)),ce.push(Ue)),1;He=0;var he=Fe===""?".":Fe+":";if(O(G))for(var fe=0;fe<G.length;fe++)Fe=G[fe],Je=he+$e(Fe,fe),He+=ye(Fe,ce,oe,Je,Ue);else if(fe=S(G),typeof fe=="function")for(G=fe.call(G),fe=0;!(Fe=G.next()).done;)Fe=Fe.value,Je=he+$e(Fe,fe++),He+=ye(Fe,ce,oe,Je,Ue);else if(Je==="object"){if(typeof G.then=="function")return ye(ze(G),ce,oe,Fe,Ue);throw ce=String(G),Error("Objects are not valid as a React child (found: "+(ce==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":ce)+"). If you meant to render a collection of children, use an array instead.")}return He}function Ve(G,ce,oe){if(G==null)return G;var Fe=[],Ue=0;return ye(G,Fe,"","",function(Je){return ce.call(oe,Je,Ue++)}),Fe}function pe(G){if(G._status===-1){var ce=G._result;ce=ce(),ce.then(function(oe){(G._status===0||G._status===-1)&&(G._status=1,G._result=oe)},function(oe){(G._status===0||G._status===-1)&&(G._status=2,G._result=oe)}),G._status===-1&&(G._status=0,G._result=ce)}if(G._status===1)return G._result.default;throw G._result}var De=typeof reportError=="function"?reportError:function(G){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var ce=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof G=="object"&&G!==null&&typeof G.message=="string"?String(G.message):String(G),error:G});if(!window.dispatchEvent(ce))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",G);return}console.error(G)},$={map:Ve,forEach:function(G,ce,oe){Ve(G,function(){ce.apply(this,arguments)},oe)},count:function(G){var ce=0;return Ve(G,function(){ce++}),ce},toArray:function(G){return Ve(G,function(ce){return ce})||[]},only:function(G){if(!Y(G))throw Error("React.Children.only expected to receive a single React element child.");return G}};return react_production.Activity=g,react_production.Children=$,react_production.Component=A,react_production.Fragment=t,react_production.Profiler=s,react_production.PureComponent=x,react_production.StrictMode=n,react_production.Suspense=h,react_production.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=z,react_production.__COMPILER_RUNTIME={__proto__:null,c:function(G){return z.H.useMemoCache(G)}},react_production.cache=function(G){return function(){return G.apply(null,arguments)}},react_production.cacheSignal=function(){return null},react_production.cloneElement=function(G,ce,oe){if(G==null)throw Error("The argument must be a React element, but you passed "+G+".");var Fe=R({},G.props),Ue=G.key;if(ce!=null)for(Je in ce.key!==void 0&&(Ue=""+ce.key),ce)!X.call(ce,Je)||Je==="key"||Je==="__self"||Je==="__source"||Je==="ref"&&ce.ref===void 0||(Fe[Je]=ce[Je]);var Je=arguments.length-2;if(Je===1)Fe.children=oe;else if(1<Je){for(var He=Array(Je),he=0;he<Je;he++)He[he]=arguments[he+2];Fe.children=He}return Ee(G.type,Ue,Fe)},react_production.createContext=function(G){return G={$$typeof:u,_currentValue:G,_currentValue2:G,_threadCount:0,Provider:null,Consumer:null},G.Provider=G,G.Consumer={$$typeof:a,_context:G},G},react_production.createElement=function(G,ce,oe){var Fe,Ue={},Je=null;if(ce!=null)for(Fe in ce.key!==void 0&&(Je=""+ce.key),ce)X.call(ce,Fe)&&Fe!=="key"&&Fe!=="__self"&&Fe!=="__source"&&(Ue[Fe]=ce[Fe]);var He=arguments.length-2;if(He===1)Ue.children=oe;else if(1<He){for(var he=Array(He),fe=0;fe<He;fe++)he[fe]=arguments[fe+2];Ue.children=he}if(G&&G.defaultProps)for(Fe in He=G.defaultProps,He)Ue[Fe]===void 0&&(Ue[Fe]=He[Fe]);return Ee(G,Je,Ue)},react_production.createRef=function(){return{current:null}},react_production.forwardRef=function(G){return{$$typeof:c,render:G}},react_production.isValidElement=Y,react_production.lazy=function(G){return{$$typeof:p,_payload:{_status:-1,_result:G},_init:pe}},react_production.memo=function(G,ce){return{$$typeof:f,type:G,compare:ce===void 0?null:ce}},react_production.startTransition=function(G){var ce=z.T,oe={};z.T=oe;try{var Fe=G(),Ue=z.S;Ue!==null&&Ue(oe,Fe),typeof Fe=="object"&&Fe!==null&&typeof Fe.then=="function"&&Fe.then(K,De)}catch(Je){De(Je)}finally{ce!==null&&oe.types!==null&&(ce.types=oe.types),z.T=ce}},react_production.unstable_useCacheRefresh=function(){return z.H.useCacheRefresh()},react_production.use=function(G){return z.H.use(G)},react_production.useActionState=function(G,ce,oe){return z.H.useActionState(G,ce,oe)},react_production.useCallback=function(G,ce){return z.H.useCallback(G,ce)},react_production.useContext=function(G){return z.H.useContext(G)},react_production.useDebugValue=function(){},react_production.useDeferredValue=function(G,ce){return z.H.useDeferredValue(G,ce)},react_production.useEffect=function(G,ce){return z.H.useEffect(G,ce)},react_production.useEffectEvent=function(G){return z.H.useEffectEvent(G)},react_production.useId=function(){return z.H.useId()},react_production.useImperativeHandle=function(G,ce,oe){return z.H.useImperativeHandle(G,ce,oe)},react_production.useInsertionEffect=function(G,ce){return z.H.useInsertionEffect(G,ce)},react_production.useLayoutEffect=function(G,ce){return z.H.useLayoutEffect(G,ce)},react_production.useMemo=function(G,ce){return z.H.useMemo(G,ce)},react_production.useOptimistic=function(G,ce){return z.H.useOptimistic(G,ce)},react_production.useReducer=function(G,ce,oe){return z.H.useReducer(G,ce,oe)},react_production.useRef=function(G){return z.H.useRef(G)},react_production.useState=function(G){return z.H.useState(G)},react_production.useSyncExternalStore=function(G,ce,oe){return z.H.useSyncExternalStore(G,ce,oe)},react_production.useTransition=function(){return z.H.useTransition()},react_production.version="19.2.8",react_production}var hasRequiredReact;function requireReact(){return hasRequiredReact||(hasRequiredReact=1,react.exports=requireReact_production()),react.exports}var reactExports=requireReact();const React3=getDefaultExportFromCjs(reactExports),React=_mergeNamespaces({__proto__:null,default:React3},[reactExports]);var client={exports:{}},reactDomClient_production={},scheduler={exports:{}},scheduler_production={};var hasRequiredScheduler_production;function requireScheduler_production(){return hasRequiredScheduler_production||(hasRequiredScheduler_production=1,(function(i){function e(ye,Ve){var pe=ye.length;ye.push(Ve);e:for(;0<pe;){var De=pe-1>>>1,$=ye[De];if(0<s($,Ve))ye[De]=Ve,ye[pe]=$,pe=De;else break e}}function t(ye){return ye.length===0?null:ye[0]}function n(ye){if(ye.length===0)return null;var Ve=ye[0],pe=ye.pop();if(pe!==Ve){ye[0]=pe;e:for(var De=0,$=ye.length,G=$>>>1;De<G;){var ce=2*(De+1)-1,oe=ye[ce],Fe=ce+1,Ue=ye[Fe];if(0>s(oe,pe))Fe<$&&0>s(Ue,oe)?(ye[De]=Ue,ye[Fe]=pe,De=Fe):(ye[De]=oe,ye[ce]=pe,De=ce);else if(Fe<$&&0>s(Ue,pe))ye[De]=Ue,ye[Fe]=pe,De=Fe;else break e}}return Ve}function s(ye,Ve){var pe=ye.sortIndex-Ve.sortIndex;return pe!==0?pe:ye.id-Ve.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;i.unstable_now=function(){return a.now()}}else{var u=Date,c=u.now();i.unstable_now=function(){return u.now()-c}}var h=[],f=[],p=1,g=null,y=3,S=!1,w=!1,R=!1,T=!1,A=typeof setTimeout=="function"?setTimeout:null,F=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;function D(ye){for(var Ve=t(f);Ve!==null;){if(Ve.callback===null)n(f);else if(Ve.startTime<=ye)n(f),Ve.sortIndex=Ve.expirationTime,e(h,Ve);else break;Ve=t(f)}}function O(ye){if(R=!1,D(ye),!w)if(t(h)!==null)w=!0,K||(K=!0,Te());else{var Ve=t(f);Ve!==null&&ze(O,Ve.startTime-ye)}}var K=!1,z=-1,X=5,Ee=-1;function q(){return T?!0:!(i.unstable_now()-Ee<X)}function Y(){if(T=!1,K){var ye=i.unstable_now();Ee=ye;var Ve=!0;try{e:{w=!1,R&&(R=!1,F(z),z=-1),S=!0;var pe=y;try{t:{for(D(ye),g=t(h);g!==null&&!(g.expirationTime>ye&&q());){var De=g.callback;if(typeof De=="function"){g.callback=null,y=g.priorityLevel;var $=De(g.expirationTime<=ye);if(ye=i.unstable_now(),typeof $=="function"){g.callback=$,D(ye),Ve=!0;break t}g===t(h)&&n(h),D(ye)}else n(h);g=t(h)}if(g!==null)Ve=!0;else{var G=t(f);G!==null&&ze(O,G.startTime-ye),Ve=!1}}break e}finally{g=null,y=pe,S=!1}Ve=void 0}}finally{Ve?Te():K=!1}}}var Te;if(typeof x=="function")Te=function(){x(Y)};else if(typeof MessageChannel<"u"){var re=new MessageChannel,$e=re.port2;re.port1.onmessage=Y,Te=function(){$e.postMessage(null)}}else Te=function(){A(Y,0)};function ze(ye,Ve){z=A(function(){ye(i.unstable_now())},Ve)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(ye){ye.callback=null},i.unstable_forceFrameRate=function(ye){0>ye||125<ye?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<ye?Math.floor(1e3/ye):5},i.unstable_getCurrentPriorityLevel=function(){return y},i.unstable_next=function(ye){switch(y){case 1:case 2:case 3:var Ve=3;break;default:Ve=y}var pe=y;y=Ve;try{return ye()}finally{y=pe}},i.unstable_requestPaint=function(){T=!0},i.unstable_runWithPriority=function(ye,Ve){switch(ye){case 1:case 2:case 3:case 4:case 5:break;default:ye=3}var pe=y;y=ye;try{return Ve()}finally{y=pe}},i.unstable_scheduleCallback=function(ye,Ve,pe){var De=i.unstable_now();switch(typeof pe=="object"&&pe!==null?(pe=pe.delay,pe=typeof pe=="number"&&0<pe?De+pe:De):pe=De,ye){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=pe+$,ye={id:p++,callback:Ve,priorityLevel:ye,startTime:pe,expirationTime:$,sortIndex:-1},pe>De?(ye.sortIndex=pe,e(f,ye),t(h)===null&&ye===t(f)&&(R?(F(z),z=-1):R=!0,ze(O,pe-De))):(ye.sortIndex=$,e(h,ye),w||S||(w=!0,K||(K=!0,Te()))),ye},i.unstable_shouldYield=q,i.unstable_wrapCallback=function(ye){var Ve=y;return function(){var pe=y;y=Ve;try{return ye.apply(this,arguments)}finally{y=pe}}}})(scheduler_production)),scheduler_production}var hasRequiredScheduler;function requireScheduler(){return hasRequiredScheduler||(hasRequiredScheduler=1,scheduler.exports=requireScheduler_production()),scheduler.exports}var reactDom={exports:{}},reactDom_production={};var hasRequiredReactDom_production;function requireReactDom_production(){if(hasRequiredReactDom_production)return reactDom_production;hasRequiredReactDom_production=1;var i=requireReact();function e(h){var f="https://react.dev/errors/"+h;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)f+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+h+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(){}var n={d:{f:t,r:function(){throw Error(e(522))},D:t,C:t,L:t,m:t,X:t,S:t,M:t},p:0,findDOMNode:null},s=Symbol.for("react.portal");function a(h,f,p){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:g==null?null:""+g,children:h,containerInfo:f,implementation:p}}var u=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(h,f){if(h==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return reactDom_production.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,reactDom_production.createPortal=function(h,f){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(e(299));return a(h,f,null,p)},reactDom_production.flushSync=function(h){var f=u.T,p=n.p;try{if(u.T=null,n.p=2,h)return h()}finally{u.T=f,n.p=p,n.d.f()}},reactDom_production.preconnect=function(h,f){typeof h=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,n.d.C(h,f))},reactDom_production.prefetchDNS=function(h){typeof h=="string"&&n.d.D(h)},reactDom_production.preinit=function(h,f){if(typeof h=="string"&&f&&typeof f.as=="string"){var p=f.as,g=c(p,f.crossOrigin),y=typeof f.integrity=="string"?f.integrity:void 0,S=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;p==="style"?n.d.S(h,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:g,integrity:y,fetchPriority:S}):p==="script"&&n.d.X(h,{crossOrigin:g,integrity:y,fetchPriority:S,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},reactDom_production.preinitModule=function(h,f){if(typeof h=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var p=c(f.as,f.crossOrigin);n.d.M(h,{crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&n.d.M(h)},reactDom_production.preload=function(h,f){if(typeof h=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var p=f.as,g=c(p,f.crossOrigin);n.d.L(h,p,{crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},reactDom_production.preloadModule=function(h,f){if(typeof h=="string")if(f){var p=c(f.as,f.crossOrigin);n.d.m(h,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else n.d.m(h)},reactDom_production.requestFormReset=function(h){n.d.r(h)},reactDom_production.unstable_batchedUpdates=function(h,f){return h(f)},reactDom_production.useFormState=function(h,f,p){return u.H.useFormState(h,f,p)},reactDom_production.useFormStatus=function(){return u.H.useHostTransitionStatus()},reactDom_production.version="19.2.8",reactDom_production}var hasRequiredReactDom;function requireReactDom(){if(hasRequiredReactDom)return reactDom.exports;hasRequiredReactDom=1;function i(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),reactDom.exports=requireReactDom_production(),reactDom.exports}var hasRequiredReactDomClient_production;function requireReactDomClient_production(){if(hasRequiredReactDomClient_production)return reactDomClient_production;hasRequiredReactDomClient_production=1;var i=requireScheduler(),e=requireReact(),t=requireReactDom();function n(o){var l="https://react.dev/errors/"+o;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)l+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+o+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function a(o){var l=o,d=o;if(o.alternate)for(;l.return;)l=l.return;else{o=l;do l=o,(l.flags&4098)!==0&&(d=l.return),o=l.return;while(o)}return l.tag===3?d:null}function u(o){if(o.tag===13){var l=o.memoizedState;if(l===null&&(o=o.alternate,o!==null&&(l=o.memoizedState)),l!==null)return l.dehydrated}return null}function c(o){if(o.tag===31){var l=o.memoizedState;if(l===null&&(o=o.alternate,o!==null&&(l=o.memoizedState)),l!==null)return l.dehydrated}return null}function h(o){if(a(o)!==o)throw Error(n(188))}function f(o){var l=o.alternate;if(!l){if(l=a(o),l===null)throw Error(n(188));return l!==o?null:o}for(var d=o,m=l;;){var E=d.return;if(E===null)break;var C=E.alternate;if(C===null){if(m=E.return,m!==null){d=m;continue}break}if(E.child===C.child){for(C=E.child;C;){if(C===d)return h(E),o;if(C===m)return h(E),l;C=C.sibling}throw Error(n(188))}if(d.return!==m.return)d=E,m=C;else{for(var W=!1,le=E.child;le;){if(le===d){W=!0,d=E,m=C;break}if(le===m){W=!0,m=E,d=C;break}le=le.sibling}if(!W){for(le=C.child;le;){if(le===d){W=!0,d=C,m=E;break}if(le===m){W=!0,m=C,d=E;break}le=le.sibling}if(!W)throw Error(n(189))}}if(d.alternate!==m)throw Error(n(190))}if(d.tag!==3)throw Error(n(188));return d.stateNode.current===d?o:l}function p(o){var l=o.tag;if(l===5||l===26||l===27||l===6)return o;for(o=o.child;o!==null;){if(l=p(o),l!==null)return l;o=o.sibling}return null}var g=Object.assign,y=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),F=Symbol.for("react.consumer"),x=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),Ee=Symbol.for("react.activity"),q=Symbol.for("react.memo_cache_sentinel"),Y=Symbol.iterator;function Te(o){return o===null||typeof o!="object"?null:(o=Y&&o[Y]||o["@@iterator"],typeof o=="function"?o:null)}var re=Symbol.for("react.client.reference");function $e(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===re?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case R:return"Fragment";case A:return"Profiler";case T:return"StrictMode";case O:return"Suspense";case K:return"SuspenseList";case Ee:return"Activity"}if(typeof o=="object")switch(o.$$typeof){case w:return"Portal";case x:return o.displayName||"Context";case F:return(o._context.displayName||"Context")+".Consumer";case D:var l=o.render;return o=o.displayName,o||(o=l.displayName||l.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case z:return l=o.displayName||null,l!==null?l:$e(o.type)||"Memo";case X:l=o._payload,o=o._init;try{return $e(o(l))}catch{}}return null}var ze=Array.isArray,ye=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ve=t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,pe={pending:!1,data:null,method:null,action:null},De=[],$=-1;function G(o){return{current:o}}function ce(o){0>$||(o.current=De[$],De[$]=null,$--)}function oe(o,l){$++,De[$]=o.current,o.current=l}var Fe=G(null),Ue=G(null),Je=G(null),He=G(null);function he(o,l){switch(oe(Je,l),oe(Ue,o),oe(Fe,null),l.nodeType){case 9:case 11:o=(o=l.documentElement)&&(o=o.namespaceURI)?Of(o):0;break;default:if(o=l.tagName,l=l.namespaceURI)l=Of(l),o=$f(l,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}ce(Fe),oe(Fe,o)}function fe(){ce(Fe),ce(Ue),ce(Je)}function Oe(o){o.memoizedState!==null&&oe(He,o);var l=Fe.current,d=$f(l,o.type);l!==d&&(oe(Ue,o),oe(Fe,d))}function ie(o){Ue.current===o&&(ce(Fe),ce(Ue)),He.current===o&&(ce(He),ia._currentValue=pe)}var j,N;function L(o){if(j===void 0)try{throw Error()}catch(d){var l=d.stack.trim().match(/\n( *(at )?)/);j=l&&l[1]||"",N=-1<d.stack.indexOf(`
3
+ at`)?" (<anonymous>)":-1<d.stack.indexOf("@")?"@unknown:0:0":""}return`
4
+ `+j+o+N}var V=!1;function ee(o,l){if(!o||V)return"";V=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var m={DetermineComponentFrameRoot:function(){try{if(l){var dt=function(){throw Error()};if(Object.defineProperty(dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(dt,[])}catch(it){var tt=it}Reflect.construct(o,[],dt)}else{try{dt.call()}catch(it){tt=it}o.call(dt.prototype)}}else{try{throw Error()}catch(it){tt=it}(dt=o())&&typeof dt.catch=="function"&&dt.catch(function(){})}}catch(it){if(it&&tt&&typeof it.stack=="string")return[it.stack,tt.stack]}return[null,null]}};m.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var E=Object.getOwnPropertyDescriptor(m.DetermineComponentFrameRoot,"name");E&&E.configurable&&Object.defineProperty(m.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var C=m.DetermineComponentFrameRoot(),W=C[0],le=C[1];if(W&&le){var ke=W.split(`
5
+ `),Ye=le.split(`
6
+ `);for(E=m=0;m<ke.length&&!ke[m].includes("DetermineComponentFrameRoot");)m++;for(;E<Ye.length&&!Ye[E].includes("DetermineComponentFrameRoot");)E++;if(m===ke.length||E===Ye.length)for(m=ke.length-1,E=Ye.length-1;1<=m&&0<=E&&ke[m]!==Ye[E];)E--;for(;1<=m&&0<=E;m--,E--)if(ke[m]!==Ye[E]){if(m!==1||E!==1)do if(m--,E--,0>E||ke[m]!==Ye[E]){var lt=`
7
+ `+ke[m].replace(" at new "," at ");return o.displayName&&lt.includes("<anonymous>")&&(lt=lt.replace("<anonymous>",o.displayName)),lt}while(1<=m&&0<=E);break}}}finally{V=!1,Error.prepareStackTrace=d}return(d=o?o.displayName||o.name:"")?L(d):""}function ae(o,l){switch(o.tag){case 26:case 27:case 5:return L(o.type);case 16:return L("Lazy");case 13:return o.child!==l&&l!==null?L("Suspense Fallback"):L("Suspense");case 19:return L("SuspenseList");case 0:case 15:return ee(o.type,!1);case 11:return ee(o.type.render,!1);case 1:return ee(o.type,!0);case 31:return L("Activity");default:return""}}function ve(o){try{var l="",d=null;do l+=ae(o,d),d=o,o=o.return;while(o);return l}catch(m){return`
8
+ Error generating stack: `+m.message+`
9
+ `+m.stack}}var J=Object.prototype.hasOwnProperty,me=i.unstable_scheduleCallback,xe=i.unstable_cancelCallback,de=i.unstable_shouldYield,st=i.unstable_requestPaint,ft=i.unstable_now,Ge=i.unstable_getCurrentPriorityLevel,pt=i.unstable_ImmediatePriority,Z=i.unstable_UserBlockingPriority,P=i.unstable_NormalPriority,B=i.unstable_LowPriority,U=i.unstable_IdlePriority,Ie=i.log,Me=i.unstable_setDisableYieldValue,Pe=null,gt=null;function _t(o){if(typeof Ie=="function"&&Me(o),gt&&typeof gt.setStrictMode=="function")try{gt.setStrictMode(Pe,o)}catch{}}var Tt=Math.clz32?Math.clz32:sn,kt=Math.log,Ft=Math.LN2;function sn(o){return o>>>=0,o===0?32:31-(kt(o)/Ft|0)|0}var Yt=256,Dt=262144,vr=4194304;function Bt(o){var l=o&42;if(l!==0)return l;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function dr(o,l,d){var m=o.pendingLanes;if(m===0)return 0;var E=0,C=o.suspendedLanes,W=o.pingedLanes;o=o.warmLanes;var le=m&134217727;return le!==0?(m=le&~C,m!==0?E=Bt(m):(W&=le,W!==0?E=Bt(W):d||(d=le&~o,d!==0&&(E=Bt(d))))):(le=m&~C,le!==0?E=Bt(le):W!==0?E=Bt(W):d||(d=m&~o,d!==0&&(E=Bt(d)))),E===0?0:l!==0&&l!==E&&(l&C)===0&&(C=E&-E,d=l&-l,C>=d||C===32&&(d&4194048)!==0)?l:E}function nr(o,l){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&l)===0}function Vr(o,l){switch(o){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function M(){var o=vr;return vr<<=1,(vr&62914560)===0&&(vr=4194304),o}function H(o){for(var l=[],d=0;31>d;d++)l.push(o);return l}function Be(o,l){o.pendingLanes|=l,l!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function qe(o,l,d,m,E,C){var W=o.pendingLanes;o.pendingLanes=d,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=d,o.entangledLanes&=d,o.errorRecoveryDisabledLanes&=d,o.shellSuspendCounter=0;var le=o.entanglements,ke=o.expirationTimes,Ye=o.hiddenUpdates;for(d=W&~d;0<d;){var lt=31-Tt(d),dt=1<<lt;le[lt]=0,ke[lt]=-1;var tt=Ye[lt];if(tt!==null)for(Ye[lt]=null,lt=0;lt<tt.length;lt++){var it=tt[lt];it!==null&&(it.lane&=-536870913)}d&=~dt}m!==0&&at(o,m,0),C!==0&&E===0&&o.tag!==0&&(o.suspendedLanes|=C&~(W&~l))}function at(o,l,d){o.pendingLanes|=l,o.suspendedLanes&=~l;var m=31-Tt(l);o.entangledLanes|=l,o.entanglements[m]=o.entanglements[m]|1073741824|d&261930}function Ut(o,l){var d=o.entangledLanes|=l;for(o=o.entanglements;d;){var m=31-Tt(d),E=1<<m;E&l|o[m]&l&&(o[m]|=l),d&=~E}}function Ht(o,l){var d=l&-l;return d=(d&42)!==0?1:on(d),(d&(o.suspendedLanes|l))!==0?0:d}function on(o){switch(o){case 2:o=1;break;case 8:o=4;break;case 32:o=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:o=128;break;case 268435456:o=134217728;break;default:o=0}return o}function Sr(o){return o&=-o,2<o?8<o?(o&134217727)!==0?32:268435456:8:2}function sr(){var o=Ve.p;return o!==0?o:(o=window.event,o===void 0?32:ah(o.type))}function bn(o,l){var d=Ve.p;try{return Ve.p=o,l()}finally{Ve.p=d}}var Hr=Math.random().toString(36).slice(2),qt="__reactFiber$"+Hr,fr="__reactProps$"+Hr,Dr="__reactContainer$"+Hr,Mr="__reactEvents$"+Hr,Lt="__reactListeners$"+Hr,Rt="__reactHandles$"+Hr,hr="__reactResources$"+Hr,oi="__reactMarker$"+Hr;function br(o){delete o[qt],delete o[fr],delete o[Mr],delete o[Lt],delete o[Rt]}function or(o){var l=o[qt];if(l)return l;for(var d=o.parentNode;d;){if(l=d[Dr]||d[qt]){if(d=l.alternate,l.child!==null||d!==null&&d.child!==null)for(o=Hf(o);o!==null;){if(d=o[qt])return d;o=Hf(o)}return l}o=d,d=o.parentNode}return null}function ai(o){if(o=o[qt]||o[Dr]){var l=o.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return o}return null}function Pr(o){var l=o.tag;if(l===5||l===26||l===27||l===6)return o.stateNode;throw Error(n(33))}function vn(o){var l=o[hr];return l||(l=o[hr]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function Er(o){o[oi]=!0}var _i=new Set,wi={};function Sn(o,l){hn(o,l),hn(o+"Capture",l)}function hn(o,l){for(wi[o]=l,o=0;o<l.length;o++)_i.add(l[o])}var En=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),ws={},_={};function b(o){return J.call(_,o)?!0:J.call(ws,o)?!1:En.test(o)?_[o]=!0:(ws[o]=!0,!1)}function v(o,l,d){if(b(l))if(d===null)o.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":o.removeAttribute(l);return;case"boolean":var m=l.toLowerCase().slice(0,5);if(m!=="data-"&&m!=="aria-"){o.removeAttribute(l);return}}o.setAttribute(l,""+d)}}function I(o,l,d){if(d===null)o.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":o.removeAttribute(l);return}o.setAttribute(l,""+d)}}function k(o,l,d,m){if(m===null)o.removeAttribute(d);else{switch(typeof m){case"undefined":case"function":case"symbol":case"boolean":o.removeAttribute(d);return}o.setAttributeNS(l,d,""+m)}}function Q(o){switch(typeof o){case"bigint":case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function te(o){var l=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function we(o,l,d){var m=Object.getOwnPropertyDescriptor(o.constructor.prototype,l);if(!o.hasOwnProperty(l)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var E=m.get,C=m.set;return Object.defineProperty(o,l,{configurable:!0,get:function(){return E.call(this)},set:function(W){d=""+W,C.call(this,W)}}),Object.defineProperty(o,l,{enumerable:m.enumerable}),{getValue:function(){return d},setValue:function(W){d=""+W},stopTracking:function(){o._valueTracker=null,delete o[l]}}}}function ge(o){if(!o._valueTracker){var l=te(o)?"checked":"value";o._valueTracker=we(o,l,""+o[l])}}function be(o){if(!o)return!1;var l=o._valueTracker;if(!l)return!0;var d=l.getValue(),m="";return o&&(m=te(o)?o.checked?"true":"false":o.value),o=m,o!==d?(l.setValue(o),!0):!1}function _e(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}var Re=/[\n"\\]/g;function Ce(o){return o.replace(Re,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function Le(o,l,d,m,E,C,W,le){o.name="",W!=null&&typeof W!="function"&&typeof W!="symbol"&&typeof W!="boolean"?o.type=W:o.removeAttribute("type"),l!=null?W==="number"?(l===0&&o.value===""||o.value!=l)&&(o.value=""+Q(l)):o.value!==""+Q(l)&&(o.value=""+Q(l)):W!=="submit"&&W!=="reset"||o.removeAttribute("value"),l!=null?Xe(o,W,Q(l)):d!=null?Xe(o,W,Q(d)):m!=null&&o.removeAttribute("value"),E==null&&C!=null&&(o.defaultChecked=!!C),E!=null&&(o.checked=E&&typeof E!="function"&&typeof E!="symbol"),le!=null&&typeof le!="function"&&typeof le!="symbol"&&typeof le!="boolean"?o.name=""+Q(le):o.removeAttribute("name")}function We(o,l,d,m,E,C,W,le){if(C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"&&(o.type=C),l!=null||d!=null){if(!(C!=="submit"&&C!=="reset"||l!=null)){ge(o);return}d=d!=null?""+Q(d):"",l=l!=null?""+Q(l):d,le||l===o.value||(o.value=l),o.defaultValue=l}m=m??E,m=typeof m!="function"&&typeof m!="symbol"&&!!m,o.checked=le?o.checked:!!m,o.defaultChecked=!!m,W!=null&&typeof W!="function"&&typeof W!="symbol"&&typeof W!="boolean"&&(o.name=W),ge(o)}function Xe(o,l,d){l==="number"&&_e(o.ownerDocument)===o||o.defaultValue===""+d||(o.defaultValue=""+d)}function et(o,l,d,m){if(o=o.options,l){l={};for(var E=0;E<d.length;E++)l["$"+d[E]]=!0;for(d=0;d<o.length;d++)E=l.hasOwnProperty("$"+o[d].value),o[d].selected!==E&&(o[d].selected=E),E&&m&&(o[d].defaultSelected=!0)}else{for(d=""+Q(d),l=null,E=0;E<o.length;E++){if(o[E].value===d){o[E].selected=!0,m&&(o[E].defaultSelected=!0);return}l!==null||o[E].disabled||(l=o[E])}l!==null&&(l.selected=!0)}}function ne(o,l,d){if(l!=null&&(l=""+Q(l),l!==o.value&&(o.value=l),d==null)){o.defaultValue!==l&&(o.defaultValue=l);return}o.defaultValue=d!=null?""+Q(d):""}function Se(o,l,d,m){if(l==null){if(m!=null){if(d!=null)throw Error(n(92));if(ze(m)){if(1<m.length)throw Error(n(93));m=m[0]}d=m}d==null&&(d=""),l=d}d=Q(l),o.defaultValue=d,m=o.textContent,m===d&&m!==""&&m!==null&&(o.value=m),ge(o)}function Ae(o,l){if(l){var d=o.firstChild;if(d&&d===o.lastChild&&d.nodeType===3){d.nodeValue=l;return}}o.textContent=l}var Ne=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Qe(o,l,d){var m=l.indexOf("--")===0;d==null||typeof d=="boolean"||d===""?m?o.setProperty(l,""):l==="float"?o.cssFloat="":o[l]="":m?o.setProperty(l,d):typeof d!="number"||d===0||Ne.has(l)?l==="float"?o.cssFloat=d:o[l]=(""+d).trim():o[l]=d+"px"}function nt(o,l,d){if(l!=null&&typeof l!="object")throw Error(n(62));if(o=o.style,d!=null){for(var m in d)!d.hasOwnProperty(m)||l!=null&&l.hasOwnProperty(m)||(m.indexOf("--")===0?o.setProperty(m,""):m==="float"?o.cssFloat="":o[m]="");for(var E in l)m=l[E],l.hasOwnProperty(E)&&d[E]!==m&&Qe(o,E,m)}else for(var C in l)l.hasOwnProperty(C)&&Qe(o,C,l[C])}function bt(o){if(o.indexOf("-")===-1)return!1;switch(o){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ht=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Ct=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function yt(o){return Ct.test(""+o)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":o}function wt(){}var Jt=null;function Qt(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var Mt=null,Ir=null;function Lr(o){var l=ai(o);if(l&&(o=l.stateNode)){var d=o[fr]||null;e:switch(o=l.stateNode,l.type){case"input":if(Le(o,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name),l=d.name,d.type==="radio"&&l!=null){for(d=o;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll('input[name="'+Ce(""+l)+'"][type="radio"]'),l=0;l<d.length;l++){var m=d[l];if(m!==o&&m.form===o.form){var E=m[fr]||null;if(!E)throw Error(n(90));Le(m,E.value,E.defaultValue,E.defaultValue,E.checked,E.defaultChecked,E.type,E.name)}}for(l=0;l<d.length;l++)m=d[l],m.form===o.form&&be(m)}break e;case"textarea":ne(o,d.value,d.defaultValue);break e;case"select":l=d.value,l!=null&&et(o,!!d.multiple,l,!1)}}}var Ur=!1;function ar(o,l,d){if(Ur)return o(l,d);Ur=!0;try{var m=o(l);return m}finally{if(Ur=!1,(Mt!==null||Ir!==null)&&(Xa(),Mt&&(l=Mt,o=Ir,Ir=Mt=null,Lr(l),o)))for(l=0;l<o.length;l++)Lr(o[l])}}function Xt(o,l){var d=o.stateNode;if(d===null)return null;var m=d[fr]||null;if(m===null)return null;d=m[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(o=o.type,m=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!m;break e;default:o=!1}if(o)return null;if(d&&typeof d!="function")throw Error(n(231,l,typeof d));return d}var ir=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Or=!1;if(ir)try{var _n={};Object.defineProperty(_n,"passive",{get:function(){Or=!0}}),window.addEventListener("test",_n,_n),window.removeEventListener("test",_n,_n)}catch{Or=!1}var tn=null,pn=null,Tn=null;function gn(){if(Tn)return Tn;var o,l=pn,d=l.length,m,E="value"in tn?tn.value:tn.textContent,C=E.length;for(o=0;o<d&&l[o]===E[o];o++);var W=d-o;for(m=1;m<=W&&l[d-m]===E[C-m];m++);return Tn=E.slice(o,1<m?1-m:void 0)}function Fn(o){var l=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&l===13&&(o=13)):o=l,o===10&&(o=13),32<=o||o===13?o:0}function wr(){return!0}function $r(){return!1}function Cr(o){function l(d,m,E,C,W){this._reactName=d,this._targetInst=E,this.type=m,this.nativeEvent=C,this.target=W,this.currentTarget=null;for(var le in o)o.hasOwnProperty(le)&&(d=o[le],this[le]=d?d(C):C[le]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?wr:$r,this.isPropagationStopped=$r,this}return g(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=wr)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=wr)},persist:function(){},isPersistent:wr}),l}var kr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Mn=Cr(kr),mn=g({},kr,{view:0,detail:0}),Mi=Cr(mn),qn,Xr,rn,Yr=g({},mn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Tr,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==rn&&(rn&&o.type==="mousemove"?(qn=o.screenX-rn.screenX,Xr=o.screenY-rn.screenY):Xr=qn=0,rn=o),qn)},movementY:function(o){return"movementY"in o?o.movementY:Xr}}),lr=Cr(Yr),Dn=g({},Yr,{dataTransfer:0}),hi=Cr(Dn),Nr=g({},mn,{relatedTarget:0}),zn=Cr(Nr),Vn=g({},kr,{animationName:0,elapsedTime:0,pseudoElement:0}),Hn=Cr(Vn),$s=g({},kr,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),wo=Cr($s),Wn=g({},kr,{data:0}),vo=Cr(Wn),la={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},an={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},vi={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function qi(o){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(o):(o=vi[o])?!!l[o]:!1}function Tr(){return qi}var Kn=g({},mn,{key:function(o){if(o.key){var l=la[o.key]||o.key;if(l!=="Unidentified")return l}return o.type==="keypress"?(o=Fn(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?an[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Tr,charCode:function(o){return o.type==="keypress"?Fn(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?Fn(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),vs=Cr(Kn),So=g({},Yr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wr=Cr(So),zi=g({},mn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Tr}),Vi=Cr(zi),Eo=g({},kr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Si=Cr(Eo),Hi=g({},Yr,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),To=Cr(Hi),Gn=g({},kr,{newState:0,oldState:0}),wl=Cr(Gn),Ro=[9,13,27,32],Pn=ir&&"CompositionEvent"in window,li=null;ir&&"documentMode"in document&&(li=document.documentMode);var ua=ir&&"TextEvent"in window&&!li,ca=ir&&(!Pn||li&&8<li&&11>=li),da=" ",fa=!1;function js(o,l){switch(o){case"keyup":return Ro.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xo(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Wi=!1;function vl(o,l){switch(o){case"compositionend":return xo(l);case"keypress":return l.which!==32?null:(fa=!0,da);case"textInput":return o=l.data,o===da&&fa?null:o;default:return null}}function Ao(o,l){if(Wi)return o==="compositionend"||!Pn&&js(o,l)?(o=gn(),Tn=pn=tn=null,Wi=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return ca&&l.locale!=="ko"?null:l.data;default:return null}}var Ki={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Bs(o){var l=o&&o.nodeName&&o.nodeName.toLowerCase();return l==="input"?!!Ki[o.type]:l==="textarea"}function ha(o,l,d,m){Mt?Ir?Ir.push(m):Ir=[m]:Mt=m,l=sl(l,"onChange"),0<l.length&&(d=new Mn("onChange","change",null,d,m),o.push({event:d,listeners:l}))}var Ei=null,Ti=null;function pa(o){Ff(o,0)}function Ms(o){var l=Pr(o);if(be(l))return o}function Gi(o,l){if(o==="change")return l}var Io=!1;if(ir){var Ss;if(ir){var qs="oninput"in document;if(!qs){var zs=document.createElement("div");zs.setAttribute("oninput","return;"),qs=typeof zs.oninput=="function"}Ss=qs}else Ss=!1;Io=Ss&&(!document.documentMode||9<document.documentMode)}function ga(){Ei&&(Ei.detachEvent("onpropertychange",Ot),Ti=Ei=null)}function Ot(o){if(o.propertyName==="value"&&Ms(Ti)){var l=[];ha(l,Ti,o,Qt(o)),ar(pa,l)}}function ot(o,l,d){o==="focusin"?(ga(),Ei=l,Ti=d,Ei.attachEvent("onpropertychange",Ot)):o==="focusout"&&ga()}function rt(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return Ms(Ti)}function ut(o,l){if(o==="click")return Ms(l)}function mt(o,l){if(o==="input"||o==="change")return Ms(l)}function xt(o,l){return o===l&&(o!==0||1/o===1/l)||o!==o&&l!==l}var vt=typeof Object.is=="function"?Object.is:xt;function se(o,l){if(vt(o,l))return!0;if(typeof o!="object"||o===null||typeof l!="object"||l===null)return!1;var d=Object.keys(o),m=Object.keys(l);if(d.length!==m.length)return!1;for(m=0;m<d.length;m++){var E=d[m];if(!J.call(l,E)||!vt(o[E],l[E]))return!1}return!0}function yn(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function ue(o,l){var d=yn(o);o=0;for(var m;d;){if(d.nodeType===3){if(m=o+d.textContent.length,o<=l&&m>=l)return{node:d,offset:l-o};o=m}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=yn(d)}}function ui(o,l){return o&&l?o===l?!0:o&&o.nodeType===3?!1:l&&l.nodeType===3?ui(o,l.parentNode):"contains"in o?o.contains(l):o.compareDocumentPosition?!!(o.compareDocumentPosition(l)&16):!1:!1}function Es(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var l=_e(o.document);l instanceof o.HTMLIFrameElement;){try{var d=typeof l.contentWindow.location.href=="string"}catch{d=!1}if(d)o=l.contentWindow;else break;l=_e(o.document)}return l}function Ji(o){var l=o&&o.nodeName&&o.nodeName.toLowerCase();return l&&(l==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||l==="textarea"||o.contentEditable==="true")}var Vs=ir&&"documentMode"in document&&11>=document.documentMode,pr=null,Rn=null,kn=null,pi=!1;function Hs(o,l,d){var m=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;pi||pr==null||pr!==_e(m)||(m=pr,"selectionStart"in m&&Ji(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),kn&&se(kn,m)||(kn=m,m=sl(Rn,"onSelect"),0<m.length&&(l=new Mn("onSelect","select",null,l,d),o.push({event:l,listeners:m}),l.target=pr)))}function Jn(o,l){var d={};return d[o.toLowerCase()]=l.toLowerCase(),d["Webkit"+o]="webkit"+l,d["Moz"+o]="moz"+l,d}var Nt={animationend:Jn("Animation","AnimationEnd"),animationiteration:Jn("Animation","AnimationIteration"),animationstart:Jn("Animation","AnimationStart"),transitionrun:Jn("Transition","TransitionRun"),transitionstart:Jn("Transition","TransitionStart"),transitioncancel:Jn("Transition","TransitionCancel"),transitionend:Jn("Transition","TransitionEnd")},Zt={},Pt={};ir&&(Pt=document.createElement("div").style,"AnimationEvent"in window||(delete Nt.animationend.animation,delete Nt.animationiteration.animation,delete Nt.animationstart.animation),"TransitionEvent"in window||delete Nt.transitionend.transition);function Rr(o){if(Zt[o])return Zt[o];if(!Nt[o])return o;var l=Nt[o],d;for(d in l)if(l.hasOwnProperty(d)&&d in Pt)return Zt[o]=l[d];return o}var Kr=Rr("animationend"),Ts=Rr("animationiteration"),Qn=Rr("animationstart"),ma=Rr("transitionrun"),Ws=Rr("transitionstart"),Co=Rr("transitioncancel"),Ri=Rr("transitionend"),uc=new Map,Sl="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Sl.push("scrollEnd");function ci(o,l){uc.set(o,l),Sn(l,[o])}var ya=typeof reportError=="function"?reportError:function(o){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof o=="object"&&o!==null&&typeof o.message=="string"?String(o.message):String(o),error:o});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",o);return}console.error(o)},Zn=[],Ks=0,El=0;function ba(){for(var o=Ks,l=El=Ks=0;l<o;){var d=Zn[l];Zn[l++]=null;var m=Zn[l];Zn[l++]=null;var E=Zn[l];Zn[l++]=null;var C=Zn[l];if(Zn[l++]=null,m!==null&&E!==null){var W=m.pending;W===null?E.next=E:(E.next=W.next,W.next=E),m.pending=E}C!==0&&cc(d,E,C)}}function wa(o,l,d,m){Zn[Ks++]=o,Zn[Ks++]=l,Zn[Ks++]=d,Zn[Ks++]=m,El|=m,o.lanes|=m,o=o.alternate,o!==null&&(o.lanes|=m)}function Tl(o,l,d,m){return wa(o,l,d,m),va(o)}function Rs(o,l){return wa(o,null,null,l),va(o)}function cc(o,l,d){o.lanes|=d;var m=o.alternate;m!==null&&(m.lanes|=d);for(var E=!1,C=o.return;C!==null;)C.childLanes|=d,m=C.alternate,m!==null&&(m.childLanes|=d),C.tag===22&&(o=C.stateNode,o===null||o._visibility&1||(E=!0)),o=C,C=C.return;return o.tag===3?(C=o.stateNode,E&&l!==null&&(E=31-Tt(d),o=C.hiddenUpdates,m=o[E],m===null?o[E]=[l]:m.push(l),l.lane=d|536870912),C):null}function va(o){if(50<Zo)throw Zo=0,Pu=null,Error(n(185));for(var l=o.return;l!==null;)o=l,l=o.return;return o.tag===3?o.stateNode:null}var Gs={};function bh(o,l,d,m){this.tag=o,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ln(o,l,d,m){return new bh(o,l,d,m)}function Rl(o){return o=o.prototype,!(!o||!o.isReactComponent)}function xi(o,l){var d=o.alternate;return d===null?(d=Ln(o.tag,l,o.key,o.mode),d.elementType=o.elementType,d.type=o.type,d.stateNode=o.stateNode,d.alternate=o,o.alternate=d):(d.pendingProps=l,d.type=o.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=o.flags&65011712,d.childLanes=o.childLanes,d.lanes=o.lanes,d.child=o.child,d.memoizedProps=o.memoizedProps,d.memoizedState=o.memoizedState,d.updateQueue=o.updateQueue,l=o.dependencies,d.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},d.sibling=o.sibling,d.index=o.index,d.ref=o.ref,d.refCleanup=o.refCleanup,d}function dc(o,l){o.flags&=65011714;var d=o.alternate;return d===null?(o.childLanes=0,o.lanes=l,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=d.childLanes,o.lanes=d.lanes,o.child=d.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=d.memoizedProps,o.memoizedState=d.memoizedState,o.updateQueue=d.updateQueue,o.type=d.type,l=d.dependencies,o.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),o}function Sa(o,l,d,m,E,C){var W=0;if(m=o,typeof o=="function")Rl(o)&&(W=1);else if(typeof o=="string")W=Ep(o,d,Fe.current)?26:o==="html"||o==="head"||o==="body"?27:5;else e:switch(o){case Ee:return o=Ln(31,d,l,E),o.elementType=Ee,o.lanes=C,o;case R:return xs(d.children,E,C,l);case T:W=8,E|=24;break;case A:return o=Ln(12,d,l,E|2),o.elementType=A,o.lanes=C,o;case O:return o=Ln(13,d,l,E),o.elementType=O,o.lanes=C,o;case K:return o=Ln(19,d,l,E),o.elementType=K,o.lanes=C,o;default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case x:W=10;break e;case F:W=9;break e;case D:W=11;break e;case z:W=14;break e;case X:W=16,m=null;break e}W=29,d=Error(n(130,o===null?"null":typeof o,"")),m=null}return l=Ln(W,d,l,E),l.elementType=o,l.type=m,l.lanes=C,l}function xs(o,l,d,m){return o=Ln(7,o,m,l),o.lanes=d,o}function xl(o,l,d){return o=Ln(6,o,null,l),o.lanes=d,o}function fc(o){var l=Ln(18,null,null,0);return l.stateNode=o,l}function Al(o,l,d){return l=Ln(4,o.children!==null?o.children:[],o.key,l),l.lanes=d,l.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},l}var hc=new WeakMap;function Xn(o,l){if(typeof o=="object"&&o!==null){var d=hc.get(o);return d!==void 0?d:(l={value:o,source:l,stack:ve(l)},hc.set(o,l),l)}return{value:o,source:l,stack:ve(l)}}var Js=[],Qs=0,Ea=null,No=0,Yn=[],ei=0,Qi=null,gi=1,mi="";function Ai(o,l){Js[Qs++]=No,Js[Qs++]=Ea,Ea=o,No=l}function pc(o,l,d){Yn[ei++]=gi,Yn[ei++]=mi,Yn[ei++]=Qi,Qi=o;var m=gi;o=mi;var E=32-Tt(m)-1;m&=~(1<<E),d+=1;var C=32-Tt(l)+E;if(30<C){var W=E-E%5;C=(m&(1<<W)-1).toString(32),m>>=W,E-=W,gi=1<<32-Tt(l)+E|d<<E|m,mi=C+o}else gi=1<<C|d<<E|m,mi=o}function Il(o){o.return!==null&&(Ai(o,1),pc(o,1,0))}function Cl(o){for(;o===Ea;)Ea=Js[--Qs],Js[Qs]=null,No=Js[--Qs],Js[Qs]=null;for(;o===Qi;)Qi=Yn[--ei],Yn[ei]=null,mi=Yn[--ei],Yn[ei]=null,gi=Yn[--ei],Yn[ei]=null}function gc(o,l){Yn[ei++]=gi,Yn[ei++]=mi,Yn[ei++]=Qi,gi=l.id,mi=l.overflow,Qi=o}var ln=null,xr=null,Gt=!1,Zi=null,ti=!1,Nl=Error(n(519));function Xi(o){var l=Error(n(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Fo(Xn(l,o)),Nl}function mc(o){var l=o.stateNode,d=o.type,m=o.memoizedProps;switch(l[qt]=o,l[fr]=m,d){case"dialog":Vt("cancel",l),Vt("close",l);break;case"iframe":case"object":case"embed":Vt("load",l);break;case"video":case"audio":for(d=0;d<Yo.length;d++)Vt(Yo[d],l);break;case"source":Vt("error",l);break;case"img":case"image":case"link":Vt("error",l),Vt("load",l);break;case"details":Vt("toggle",l);break;case"input":Vt("invalid",l),We(l,m.value,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name,!0);break;case"select":Vt("invalid",l);break;case"textarea":Vt("invalid",l),Se(l,m.value,m.defaultValue,m.children)}d=m.children,typeof d!="string"&&typeof d!="number"&&typeof d!="bigint"||l.textContent===""+d||m.suppressHydrationWarning===!0||Lf(l.textContent,d)?(m.popover!=null&&(Vt("beforetoggle",l),Vt("toggle",l)),m.onScroll!=null&&Vt("scroll",l),m.onScrollEnd!=null&&Vt("scrollend",l),m.onClick!=null&&(l.onclick=wt),l=!0):l=!1,l||Xi(o,!0)}function yc(o){for(ln=o.return;ln;)switch(ln.tag){case 5:case 31:case 13:ti=!1;return;case 27:case 3:ti=!0;return;default:ln=ln.return}}function Zs(o){if(o!==ln)return!1;if(!Gt)return yc(o),Gt=!0,!1;var l=o.tag,d;if((d=l!==3&&l!==27)&&((d=l===5)&&(d=o.type,d=!(d!=="form"&&d!=="button")||Gu(o.type,o.memoizedProps)),d=!d),d&&xr&&Xi(o),yc(o),l===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(317));xr=Vf(o)}else if(l===31){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(317));xr=Vf(o)}else l===27?(l=xr,ps(o.type)?(o=Yu,Yu=null,xr=o):xr=l):xr=ln?ni(o.stateNode.nextSibling):null;return!0}function As(){xr=ln=null,Gt=!1}function Fl(){var o=Zi;return o!==null&&(Cn===null?Cn=o:Cn.push.apply(Cn,o),Zi=null),o}function Fo(o){Zi===null?Zi=[o]:Zi.push(o)}var Dl=G(null),Is=null,Ii=null;function Yi(o,l,d){oe(Dl,l._currentValue),l._currentValue=d}function Ci(o){o._currentValue=Dl.current,ce(Dl)}function Pl(o,l,d){for(;o!==null;){var m=o.alternate;if((o.childLanes&l)!==l?(o.childLanes|=l,m!==null&&(m.childLanes|=l)):m!==null&&(m.childLanes&l)!==l&&(m.childLanes|=l),o===d)break;o=o.return}}function kl(o,l,d,m){var E=o.child;for(E!==null&&(E.return=o);E!==null;){var C=E.dependencies;if(C!==null){var W=E.child;C=C.firstContext;e:for(;C!==null;){var le=C;C=E;for(var ke=0;ke<l.length;ke++)if(le.context===l[ke]){C.lanes|=d,le=C.alternate,le!==null&&(le.lanes|=d),Pl(C.return,d,o),m||(W=null);break e}C=le.next}}else if(E.tag===18){if(W=E.return,W===null)throw Error(n(341));W.lanes|=d,C=W.alternate,C!==null&&(C.lanes|=d),Pl(W,d,o),W=null}else W=E.child;if(W!==null)W.return=E;else for(W=E;W!==null;){if(W===o){W=null;break}if(E=W.sibling,E!==null){E.return=W.return,W=E;break}W=W.return}E=W}}function Xs(o,l,d,m){o=null;for(var E=l,C=!1;E!==null;){if(!C){if((E.flags&524288)!==0)C=!0;else if((E.flags&262144)!==0)break}if(E.tag===10){var W=E.alternate;if(W===null)throw Error(n(387));if(W=W.memoizedProps,W!==null){var le=E.type;vt(E.pendingProps.value,W.value)||(o!==null?o.push(le):o=[le])}}else if(E===He.current){if(W=E.alternate,W===null)throw Error(n(387));W.memoizedState.memoizedState!==E.memoizedState.memoizedState&&(o!==null?o.push(ia):o=[ia])}E=E.return}o!==null&&kl(l,o,d,m),l.flags|=262144}function Ta(o){for(o=o.firstContext;o!==null;){if(!vt(o.context._currentValue,o.memoizedValue))return!0;o=o.next}return!1}function Cs(o){Is=o,Ii=null,o=o.dependencies,o!==null&&(o.firstContext=null)}function un(o){return bc(Is,o)}function Ra(o,l){return Is===null&&Cs(o),bc(o,l)}function bc(o,l){var d=l._currentValue;if(l={context:l,memoizedValue:d,next:null},Ii===null){if(o===null)throw Error(n(308));Ii=l,o.dependencies={lanes:0,firstContext:l},o.flags|=524288}else Ii=Ii.next=l;return d}var _h=typeof AbortController<"u"?AbortController:function(){var o=[],l=this.signal={aborted:!1,addEventListener:function(d,m){o.push(m)}};this.abort=function(){l.aborted=!0,o.forEach(function(d){return d()})}},wh=i.unstable_scheduleCallback,vh=i.unstable_NormalPriority,Gr={$$typeof:x,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ll(){return{controller:new _h,data:new Map,refCount:0}}function Do(o){o.refCount--,o.refCount===0&&wh(vh,function(){o.controller.abort()})}var Po=null,Ul=0,Ys=0,eo=null;function Sh(o,l){if(Po===null){var d=Po=[];Ul=0,Ys=ju(),eo={status:"pending",value:void 0,then:function(m){d.push(m)}}}return Ul++,l.then(_c,_c),l}function _c(){if(--Ul===0&&Po!==null){eo!==null&&(eo.status="fulfilled");var o=Po;Po=null,Ys=0,eo=null;for(var l=0;l<o.length;l++)(0,o[l])()}}function Eh(o,l){var d=[],m={status:"pending",value:null,reason:null,then:function(E){d.push(E)}};return o.then(function(){m.status="fulfilled",m.value=l;for(var E=0;E<d.length;E++)(0,d[E])(l)},function(E){for(m.status="rejected",m.reason=E,E=0;E<d.length;E++)(0,d[E])(void 0)}),m}var wc=ye.S;ye.S=function(o,l){sf=ft(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&Sh(o,l),wc!==null&&wc(o,l)};var Ns=G(null);function Ol(){var o=Ns.current;return o!==null?o:_r.pooledCache}function xa(o,l){l===null?oe(Ns,Ns.current):oe(Ns,l.pool)}function vc(){var o=Ol();return o===null?null:{parent:Gr._currentValue,pool:o}}var to=Error(n(460)),$l=Error(n(474)),Aa=Error(n(542)),Ia={then:function(){}};function Sc(o){return o=o.status,o==="fulfilled"||o==="rejected"}function Ec(o,l,d){switch(d=o[d],d===void 0?o.push(l):d!==l&&(l.then(wt,wt),l=d),l.status){case"fulfilled":return l.value;case"rejected":throw o=l.reason,Rc(o),o;default:if(typeof l.status=="string")l.then(wt,wt);else{if(o=_r,o!==null&&100<o.shellSuspendCounter)throw Error(n(482));o=l,o.status="pending",o.then(function(m){if(l.status==="pending"){var E=l;E.status="fulfilled",E.value=m}},function(m){if(l.status==="pending"){var E=l;E.status="rejected",E.reason=m}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw o=l.reason,Rc(o),o}throw Ds=l,to}}function Fs(o){try{var l=o._init;return l(o._payload)}catch(d){throw d!==null&&typeof d=="object"&&typeof d.then=="function"?(Ds=d,to):d}}var Ds=null;function Tc(){if(Ds===null)throw Error(n(459));var o=Ds;return Ds=null,o}function Rc(o){if(o===to||o===Aa)throw Error(n(483))}var ro=null,ko=0;function Ca(o){var l=ko;return ko+=1,ro===null&&(ro=[]),Ec(ro,o,l)}function Lo(o,l){l=l.props.ref,o.ref=l!==void 0?l:null}function Na(o,l){throw l.$$typeof===y?Error(n(525)):(o=Object.prototype.toString.call(l),Error(n(31,o==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":o)))}function xc(o){function l(Ke,je){if(o){var Ze=Ke.deletions;Ze===null?(Ke.deletions=[je],Ke.flags|=16):Ze.push(je)}}function d(Ke,je){if(!o)return null;for(;je!==null;)l(Ke,je),je=je.sibling;return null}function m(Ke){for(var je=new Map;Ke!==null;)Ke.key!==null?je.set(Ke.key,Ke):je.set(Ke.index,Ke),Ke=Ke.sibling;return je}function E(Ke,je){return Ke=xi(Ke,je),Ke.index=0,Ke.sibling=null,Ke}function C(Ke,je,Ze){return Ke.index=Ze,o?(Ze=Ke.alternate,Ze!==null?(Ze=Ze.index,Ze<je?(Ke.flags|=67108866,je):Ze):(Ke.flags|=67108866,je)):(Ke.flags|=1048576,je)}function W(Ke){return o&&Ke.alternate===null&&(Ke.flags|=67108866),Ke}function le(Ke,je,Ze,ct){return je===null||je.tag!==6?(je=xl(Ze,Ke.mode,ct),je.return=Ke,je):(je=E(je,Ze),je.return=Ke,je)}function ke(Ke,je,Ze,ct){var At=Ze.type;return At===R?lt(Ke,je,Ze.props.children,ct,Ze.key):je!==null&&(je.elementType===At||typeof At=="object"&&At!==null&&At.$$typeof===X&&Fs(At)===je.type)?(je=E(je,Ze.props),Lo(je,Ze),je.return=Ke,je):(je=Sa(Ze.type,Ze.key,Ze.props,null,Ke.mode,ct),Lo(je,Ze),je.return=Ke,je)}function Ye(Ke,je,Ze,ct){return je===null||je.tag!==4||je.stateNode.containerInfo!==Ze.containerInfo||je.stateNode.implementation!==Ze.implementation?(je=Al(Ze,Ke.mode,ct),je.return=Ke,je):(je=E(je,Ze.children||[]),je.return=Ke,je)}function lt(Ke,je,Ze,ct,At){return je===null||je.tag!==7?(je=xs(Ze,Ke.mode,ct,At),je.return=Ke,je):(je=E(je,Ze),je.return=Ke,je)}function dt(Ke,je,Ze){if(typeof je=="string"&&je!==""||typeof je=="number"||typeof je=="bigint")return je=xl(""+je,Ke.mode,Ze),je.return=Ke,je;if(typeof je=="object"&&je!==null){switch(je.$$typeof){case S:return Ze=Sa(je.type,je.key,je.props,null,Ke.mode,Ze),Lo(Ze,je),Ze.return=Ke,Ze;case w:return je=Al(je,Ke.mode,Ze),je.return=Ke,je;case X:return je=Fs(je),dt(Ke,je,Ze)}if(ze(je)||Te(je))return je=xs(je,Ke.mode,Ze,null),je.return=Ke,je;if(typeof je.then=="function")return dt(Ke,Ca(je),Ze);if(je.$$typeof===x)return dt(Ke,Ra(Ke,je),Ze);Na(Ke,je)}return null}function tt(Ke,je,Ze,ct){var At=je!==null?je.key:null;if(typeof Ze=="string"&&Ze!==""||typeof Ze=="number"||typeof Ze=="bigint")return At!==null?null:le(Ke,je,""+Ze,ct);if(typeof Ze=="object"&&Ze!==null){switch(Ze.$$typeof){case S:return Ze.key===At?ke(Ke,je,Ze,ct):null;case w:return Ze.key===At?Ye(Ke,je,Ze,ct):null;case X:return Ze=Fs(Ze),tt(Ke,je,Ze,ct)}if(ze(Ze)||Te(Ze))return At!==null?null:lt(Ke,je,Ze,ct,null);if(typeof Ze.then=="function")return tt(Ke,je,Ca(Ze),ct);if(Ze.$$typeof===x)return tt(Ke,je,Ra(Ke,Ze),ct);Na(Ke,Ze)}return null}function it(Ke,je,Ze,ct,At){if(typeof ct=="string"&&ct!==""||typeof ct=="number"||typeof ct=="bigint")return Ke=Ke.get(Ze)||null,le(je,Ke,""+ct,At);if(typeof ct=="object"&&ct!==null){switch(ct.$$typeof){case S:return Ke=Ke.get(ct.key===null?Ze:ct.key)||null,ke(je,Ke,ct,At);case w:return Ke=Ke.get(ct.key===null?Ze:ct.key)||null,Ye(je,Ke,ct,At);case X:return ct=Fs(ct),it(Ke,je,Ze,ct,At)}if(ze(ct)||Te(ct))return Ke=Ke.get(Ze)||null,lt(je,Ke,ct,At,null);if(typeof ct.then=="function")return it(Ke,je,Ze,Ca(ct),At);if(ct.$$typeof===x)return it(Ke,je,Ze,Ra(je,ct),At);Na(je,ct)}return null}function St(Ke,je,Ze,ct){for(var At=null,er=null,Et=je,jt=je=0,Kt=null;Et!==null&&jt<Ze.length;jt++){Et.index>jt?(Kt=Et,Et=null):Kt=Et.sibling;var tr=tt(Ke,Et,Ze[jt],ct);if(tr===null){Et===null&&(Et=Kt);break}o&&Et&&tr.alternate===null&&l(Ke,Et),je=C(tr,je,jt),er===null?At=tr:er.sibling=tr,er=tr,Et=Kt}if(jt===Ze.length)return d(Ke,Et),Gt&&Ai(Ke,jt),At;if(Et===null){for(;jt<Ze.length;jt++)Et=dt(Ke,Ze[jt],ct),Et!==null&&(je=C(Et,je,jt),er===null?At=Et:er.sibling=Et,er=Et);return Gt&&Ai(Ke,jt),At}for(Et=m(Et);jt<Ze.length;jt++)Kt=it(Et,Ke,jt,Ze[jt],ct),Kt!==null&&(o&&Kt.alternate!==null&&Et.delete(Kt.key===null?jt:Kt.key),je=C(Kt,je,jt),er===null?At=Kt:er.sibling=Kt,er=Kt);return o&&Et.forEach(function(_s){return l(Ke,_s)}),Gt&&Ai(Ke,jt),At}function It(Ke,je,Ze,ct){if(Ze==null)throw Error(n(151));for(var At=null,er=null,Et=je,jt=je=0,Kt=null,tr=Ze.next();Et!==null&&!tr.done;jt++,tr=Ze.next()){Et.index>jt?(Kt=Et,Et=null):Kt=Et.sibling;var _s=tt(Ke,Et,tr.value,ct);if(_s===null){Et===null&&(Et=Kt);break}o&&Et&&_s.alternate===null&&l(Ke,Et),je=C(_s,je,jt),er===null?At=_s:er.sibling=_s,er=_s,Et=Kt}if(tr.done)return d(Ke,Et),Gt&&Ai(Ke,jt),At;if(Et===null){for(;!tr.done;jt++,tr=Ze.next())tr=dt(Ke,tr.value,ct),tr!==null&&(je=C(tr,je,jt),er===null?At=tr:er.sibling=tr,er=tr);return Gt&&Ai(Ke,jt),At}for(Et=m(Et);!tr.done;jt++,tr=Ze.next())tr=it(Et,Ke,jt,tr.value,ct),tr!==null&&(o&&tr.alternate!==null&&Et.delete(tr.key===null?jt:tr.key),je=C(tr,je,jt),er===null?At=tr:er.sibling=tr,er=tr);return o&&Et.forEach(function(kp){return l(Ke,kp)}),Gt&&Ai(Ke,jt),At}function yr(Ke,je,Ze,ct){if(typeof Ze=="object"&&Ze!==null&&Ze.type===R&&Ze.key===null&&(Ze=Ze.props.children),typeof Ze=="object"&&Ze!==null){switch(Ze.$$typeof){case S:e:{for(var At=Ze.key;je!==null;){if(je.key===At){if(At=Ze.type,At===R){if(je.tag===7){d(Ke,je.sibling),ct=E(je,Ze.props.children),ct.return=Ke,Ke=ct;break e}}else if(je.elementType===At||typeof At=="object"&&At!==null&&At.$$typeof===X&&Fs(At)===je.type){d(Ke,je.sibling),ct=E(je,Ze.props),Lo(ct,Ze),ct.return=Ke,Ke=ct;break e}d(Ke,je);break}else l(Ke,je);je=je.sibling}Ze.type===R?(ct=xs(Ze.props.children,Ke.mode,ct,Ze.key),ct.return=Ke,Ke=ct):(ct=Sa(Ze.type,Ze.key,Ze.props,null,Ke.mode,ct),Lo(ct,Ze),ct.return=Ke,Ke=ct)}return W(Ke);case w:e:{for(At=Ze.key;je!==null;){if(je.key===At)if(je.tag===4&&je.stateNode.containerInfo===Ze.containerInfo&&je.stateNode.implementation===Ze.implementation){d(Ke,je.sibling),ct=E(je,Ze.children||[]),ct.return=Ke,Ke=ct;break e}else{d(Ke,je);break}else l(Ke,je);je=je.sibling}ct=Al(Ze,Ke.mode,ct),ct.return=Ke,Ke=ct}return W(Ke);case X:return Ze=Fs(Ze),yr(Ke,je,Ze,ct)}if(ze(Ze))return St(Ke,je,Ze,ct);if(Te(Ze)){if(At=Te(Ze),typeof At!="function")throw Error(n(150));return Ze=At.call(Ze),It(Ke,je,Ze,ct)}if(typeof Ze.then=="function")return yr(Ke,je,Ca(Ze),ct);if(Ze.$$typeof===x)return yr(Ke,je,Ra(Ke,Ze),ct);Na(Ke,Ze)}return typeof Ze=="string"&&Ze!==""||typeof Ze=="number"||typeof Ze=="bigint"?(Ze=""+Ze,je!==null&&je.tag===6?(d(Ke,je.sibling),ct=E(je,Ze),ct.return=Ke,Ke=ct):(d(Ke,je),ct=xl(Ze,Ke.mode,ct),ct.return=Ke,Ke=ct),W(Ke)):d(Ke,je)}return function(Ke,je,Ze,ct){try{ko=0;var At=yr(Ke,je,Ze,ct);return ro=null,At}catch(Et){if(Et===to||Et===Aa)throw Et;var er=Ln(29,Et,null,Ke.mode);return er.lanes=ct,er.return=Ke,er}}}var Ps=xc(!0),Ac=xc(!1),es=!1;function jl(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Bl(o,l){o=o.updateQueue,l.updateQueue===o&&(l.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function ts(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function rs(o,l,d){var m=o.updateQueue;if(m===null)return null;if(m=m.shared,(rr&2)!==0){var E=m.pending;return E===null?l.next=l:(l.next=E.next,E.next=l),m.pending=l,l=va(o),cc(o,null,d),l}return wa(o,m,l,d),va(o)}function Uo(o,l,d){if(l=l.updateQueue,l!==null&&(l=l.shared,(d&4194048)!==0)){var m=l.lanes;m&=o.pendingLanes,d|=m,l.lanes=d,Ut(o,d)}}function Ml(o,l){var d=o.updateQueue,m=o.alternate;if(m!==null&&(m=m.updateQueue,d===m)){var E=null,C=null;if(d=d.firstBaseUpdate,d!==null){do{var W={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};C===null?E=C=W:C=C.next=W,d=d.next}while(d!==null);C===null?E=C=l:C=C.next=l}else E=C=l;d={baseState:m.baseState,firstBaseUpdate:E,lastBaseUpdate:C,shared:m.shared,callbacks:m.callbacks},o.updateQueue=d;return}o=d.lastBaseUpdate,o===null?d.firstBaseUpdate=l:o.next=l,d.lastBaseUpdate=l}var ql=!1;function Oo(){if(ql){var o=eo;if(o!==null)throw o}}function $o(o,l,d,m){ql=!1;var E=o.updateQueue;es=!1;var C=E.firstBaseUpdate,W=E.lastBaseUpdate,le=E.shared.pending;if(le!==null){E.shared.pending=null;var ke=le,Ye=ke.next;ke.next=null,W===null?C=Ye:W.next=Ye,W=ke;var lt=o.alternate;lt!==null&&(lt=lt.updateQueue,le=lt.lastBaseUpdate,le!==W&&(le===null?lt.firstBaseUpdate=Ye:le.next=Ye,lt.lastBaseUpdate=ke))}if(C!==null){var dt=E.baseState;W=0,lt=Ye=ke=null,le=C;do{var tt=le.lane&-536870913,it=tt!==le.lane;if(it?(Wt&tt)===tt:(m&tt)===tt){tt!==0&&tt===Ys&&(ql=!0),lt!==null&&(lt=lt.next={lane:0,tag:le.tag,payload:le.payload,callback:null,next:null});e:{var St=o,It=le;tt=l;var yr=d;switch(It.tag){case 1:if(St=It.payload,typeof St=="function"){dt=St.call(yr,dt,tt);break e}dt=St;break e;case 3:St.flags=St.flags&-65537|128;case 0:if(St=It.payload,tt=typeof St=="function"?St.call(yr,dt,tt):St,tt==null)break e;dt=g({},dt,tt);break e;case 2:es=!0}}tt=le.callback,tt!==null&&(o.flags|=64,it&&(o.flags|=8192),it=E.callbacks,it===null?E.callbacks=[tt]:it.push(tt))}else it={lane:tt,tag:le.tag,payload:le.payload,callback:le.callback,next:null},lt===null?(Ye=lt=it,ke=dt):lt=lt.next=it,W|=tt;if(le=le.next,le===null){if(le=E.shared.pending,le===null)break;it=le,le=it.next,it.next=null,E.lastBaseUpdate=it,E.shared.pending=null}}while(!0);lt===null&&(ke=dt),E.baseState=ke,E.firstBaseUpdate=Ye,E.lastBaseUpdate=lt,C===null&&(E.shared.lanes=0),us|=W,o.lanes=W,o.memoizedState=dt}}function Ic(o,l){if(typeof o!="function")throw Error(n(191,o));o.call(l)}function Cc(o,l){var d=o.callbacks;if(d!==null)for(o.callbacks=null,o=0;o<d.length;o++)Ic(d[o],l)}var no=G(null),Fa=G(0);function Nc(o,l){o=$i,oe(Fa,o),oe(no,l),$i=o|l.baseLanes}function zl(){oe(Fa,$i),oe(no,no.current)}function Vl(){$i=Fa.current,ce(no),ce(Fa)}var Un=G(null),ri=null;function ss(o){var l=o.alternate;oe(qr,qr.current&1),oe(Un,o),ri===null&&(l===null||no.current!==null||l.memoizedState!==null)&&(ri=o)}function Hl(o){oe(qr,qr.current),oe(Un,o),ri===null&&(ri=o)}function Fc(o){o.tag===22?(oe(qr,qr.current),oe(Un,o),ri===null&&(ri=o)):os()}function os(){oe(qr,qr.current),oe(Un,Un.current)}function On(o){ce(Un),ri===o&&(ri=null),ce(qr)}var qr=G(0);function Da(o){for(var l=o;l!==null;){if(l.tag===13){var d=l.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||Zu(d)||Xu(d)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Ni=0,$t=null,gr=null,Jr=null,Pa=!1,io=!1,ks=!1,ka=0,jo=0,so=null,Th=0;function jr(){throw Error(n(321))}function Wl(o,l){if(l===null)return!1;for(var d=0;d<l.length&&d<o.length;d++)if(!vt(o[d],l[d]))return!1;return!0}function Kl(o,l,d,m,E,C){return Ni=C,$t=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,ye.H=o===null||o.memoizedState===null?gd:lu,ks=!1,C=d(m,E),ks=!1,io&&(C=Pc(l,d,m,E)),Dc(o),C}function Dc(o){ye.H=qo;var l=gr!==null&&gr.next!==null;if(Ni=0,Jr=gr=$t=null,Pa=!1,jo=0,so=null,l)throw Error(n(300));o===null||Qr||(o=o.dependencies,o!==null&&Ta(o)&&(Qr=!0))}function Pc(o,l,d,m){$t=o;var E=0;do{if(io&&(so=null),jo=0,io=!1,25<=E)throw Error(n(301));if(E+=1,Jr=gr=null,o.updateQueue!=null){var C=o.updateQueue;C.lastEffect=null,C.events=null,C.stores=null,C.memoCache!=null&&(C.memoCache.index=0)}ye.H=md,C=l(d,m)}while(io);return C}function Rh(){var o=ye.H,l=o.useState()[0];return l=typeof l.then=="function"?Bo(l):l,o=o.useState()[0],(gr!==null?gr.memoizedState:null)!==o&&($t.flags|=1024),l}function Gl(){var o=ka!==0;return ka=0,o}function Jl(o,l,d){l.updateQueue=o.updateQueue,l.flags&=-2053,o.lanes&=~d}function Ql(o){if(Pa){for(o=o.memoizedState;o!==null;){var l=o.queue;l!==null&&(l.pending=null),o=o.next}Pa=!1}Ni=0,Jr=gr=$t=null,io=!1,jo=ka=0,so=null}function wn(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Jr===null?$t.memoizedState=Jr=o:Jr=Jr.next=o,Jr}function zr(){if(gr===null){var o=$t.alternate;o=o!==null?o.memoizedState:null}else o=gr.next;var l=Jr===null?$t.memoizedState:Jr.next;if(l!==null)Jr=l,gr=o;else{if(o===null)throw $t.alternate===null?Error(n(467)):Error(n(310));gr=o,o={memoizedState:gr.memoizedState,baseState:gr.baseState,baseQueue:gr.baseQueue,queue:gr.queue,next:null},Jr===null?$t.memoizedState=Jr=o:Jr=Jr.next=o}return Jr}function La(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Bo(o){var l=jo;return jo+=1,so===null&&(so=[]),o=Ec(so,o,l),l=$t,(Jr===null?l.memoizedState:Jr.next)===null&&(l=l.alternate,ye.H=l===null||l.memoizedState===null?gd:lu),o}function Ua(o){if(o!==null&&typeof o=="object"){if(typeof o.then=="function")return Bo(o);if(o.$$typeof===x)return un(o)}throw Error(n(438,String(o)))}function Zl(o){var l=null,d=$t.updateQueue;if(d!==null&&(l=d.memoCache),l==null){var m=$t.alternate;m!==null&&(m=m.updateQueue,m!==null&&(m=m.memoCache,m!=null&&(l={data:m.data.map(function(E){return E.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),d===null&&(d=La(),$t.updateQueue=d),d.memoCache=l,d=l.data[l.index],d===void 0)for(d=l.data[l.index]=Array(o),m=0;m<o;m++)d[m]=q;return l.index++,d}function Fi(o,l){return typeof l=="function"?l(o):l}function Oa(o){var l=zr();return Xl(l,gr,o)}function Xl(o,l,d){var m=o.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=d;var E=o.baseQueue,C=m.pending;if(C!==null){if(E!==null){var W=E.next;E.next=C.next,C.next=W}l.baseQueue=E=C,m.pending=null}if(C=o.baseState,E===null)o.memoizedState=C;else{l=E.next;var le=W=null,ke=null,Ye=l,lt=!1;do{var dt=Ye.lane&-536870913;if(dt!==Ye.lane?(Wt&dt)===dt:(Ni&dt)===dt){var tt=Ye.revertLane;if(tt===0)ke!==null&&(ke=ke.next={lane:0,revertLane:0,gesture:null,action:Ye.action,hasEagerState:Ye.hasEagerState,eagerState:Ye.eagerState,next:null}),dt===Ys&&(lt=!0);else if((Ni&tt)===tt){Ye=Ye.next,tt===Ys&&(lt=!0);continue}else dt={lane:0,revertLane:Ye.revertLane,gesture:null,action:Ye.action,hasEagerState:Ye.hasEagerState,eagerState:Ye.eagerState,next:null},ke===null?(le=ke=dt,W=C):ke=ke.next=dt,$t.lanes|=tt,us|=tt;dt=Ye.action,ks&&d(C,dt),C=Ye.hasEagerState?Ye.eagerState:d(C,dt)}else tt={lane:dt,revertLane:Ye.revertLane,gesture:Ye.gesture,action:Ye.action,hasEagerState:Ye.hasEagerState,eagerState:Ye.eagerState,next:null},ke===null?(le=ke=tt,W=C):ke=ke.next=tt,$t.lanes|=dt,us|=dt;Ye=Ye.next}while(Ye!==null&&Ye!==l);if(ke===null?W=C:ke.next=le,!vt(C,o.memoizedState)&&(Qr=!0,lt&&(d=eo,d!==null)))throw d;o.memoizedState=C,o.baseState=W,o.baseQueue=ke,m.lastRenderedState=C}return E===null&&(m.lanes=0),[o.memoizedState,m.dispatch]}function Yl(o){var l=zr(),d=l.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=o;var m=d.dispatch,E=d.pending,C=l.memoizedState;if(E!==null){d.pending=null;var W=E=E.next;do C=o(C,W.action),W=W.next;while(W!==E);vt(C,l.memoizedState)||(Qr=!0),l.memoizedState=C,l.baseQueue===null&&(l.baseState=C),d.lastRenderedState=C}return[C,m]}function kc(o,l,d){var m=$t,E=zr(),C=Gt;if(C){if(d===void 0)throw Error(n(407));d=d()}else d=l();var W=!vt((gr||E).memoizedState,d);if(W&&(E.memoizedState=d,Qr=!0),E=E.queue,ru(Oc.bind(null,m,E,o),[o]),E.getSnapshot!==l||W||Jr!==null&&Jr.memoizedState.tag&1){if(m.flags|=2048,oo(9,{destroy:void 0},Uc.bind(null,m,E,d,l),null),_r===null)throw Error(n(349));C||(Ni&127)!==0||Lc(m,l,d)}return d}function Lc(o,l,d){o.flags|=16384,o={getSnapshot:l,value:d},l=$t.updateQueue,l===null?(l=La(),$t.updateQueue=l,l.stores=[o]):(d=l.stores,d===null?l.stores=[o]:d.push(o))}function Uc(o,l,d,m){l.value=d,l.getSnapshot=m,$c(l)&&jc(o)}function Oc(o,l,d){return d(function(){$c(l)&&jc(o)})}function $c(o){var l=o.getSnapshot;o=o.value;try{var d=l();return!vt(o,d)}catch{return!0}}function jc(o){var l=Rs(o,2);l!==null&&Nn(l,o,2)}function eu(o){var l=wn();if(typeof o=="function"){var d=o;if(o=d(),ks){_t(!0);try{d()}finally{_t(!1)}}}return l.memoizedState=l.baseState=o,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fi,lastRenderedState:o},l}function Bc(o,l,d,m){return o.baseState=d,Xl(o,gr,typeof m=="function"?m:Fi)}function xh(o,l,d,m,E){if(Ba(o))throw Error(n(485));if(o=l.action,o!==null){var C={payload:E,action:o,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(W){C.listeners.push(W)}};ye.T!==null?d(!0):C.isTransition=!1,m(C),d=l.pending,d===null?(C.next=l.pending=C,Mc(l,C)):(C.next=d.next,l.pending=d.next=C)}}function Mc(o,l){var d=l.action,m=l.payload,E=o.state;if(l.isTransition){var C=ye.T,W={};ye.T=W;try{var le=d(E,m),ke=ye.S;ke!==null&&ke(W,le),qc(o,l,le)}catch(Ye){tu(o,l,Ye)}finally{C!==null&&W.types!==null&&(C.types=W.types),ye.T=C}}else try{C=d(E,m),qc(o,l,C)}catch(Ye){tu(o,l,Ye)}}function qc(o,l,d){d!==null&&typeof d=="object"&&typeof d.then=="function"?d.then(function(m){zc(o,l,m)},function(m){return tu(o,l,m)}):zc(o,l,d)}function zc(o,l,d){l.status="fulfilled",l.value=d,Vc(l),o.state=d,l=o.pending,l!==null&&(d=l.next,d===l?o.pending=null:(d=d.next,l.next=d,Mc(o,d)))}function tu(o,l,d){var m=o.pending;if(o.pending=null,m!==null){m=m.next;do l.status="rejected",l.reason=d,Vc(l),l=l.next;while(l!==m)}o.action=null}function Vc(o){o=o.listeners;for(var l=0;l<o.length;l++)(0,o[l])()}function Hc(o,l){return l}function Wc(o,l){if(Gt){var d=_r.formState;if(d!==null){e:{var m=$t;if(Gt){if(xr){t:{for(var E=xr,C=ti;E.nodeType!==8;){if(!C){E=null;break t}if(E=ni(E.nextSibling),E===null){E=null;break t}}C=E.data,E=C==="F!"||C==="F"?E:null}if(E){xr=ni(E.nextSibling),m=E.data==="F!";break e}}Xi(m)}m=!1}m&&(l=d[0])}}return d=wn(),d.memoizedState=d.baseState=l,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hc,lastRenderedState:l},d.queue=m,d=fd.bind(null,$t,m),m.dispatch=d,m=eu(!1),C=au.bind(null,$t,!1,m.queue),m=wn(),E={state:l,dispatch:null,action:o,pending:null},m.queue=E,d=xh.bind(null,$t,E,C,d),E.dispatch=d,m.memoizedState=o,[l,d,!1]}function Kc(o){var l=zr();return Gc(l,gr,o)}function Gc(o,l,d){if(l=Xl(o,l,Hc)[0],o=Oa(Fi)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var m=Bo(l)}catch(W){throw W===to?Aa:W}else m=l;l=zr();var E=l.queue,C=E.dispatch;return d!==l.memoizedState&&($t.flags|=2048,oo(9,{destroy:void 0},Ah.bind(null,E,d),null)),[m,C,o]}function Ah(o,l){o.action=l}function Jc(o){var l=zr(),d=gr;if(d!==null)return Gc(l,d,o);zr(),l=l.memoizedState,d=zr();var m=d.queue.dispatch;return d.memoizedState=o,[l,m,!1]}function oo(o,l,d,m){return o={tag:o,create:d,deps:m,inst:l,next:null},l=$t.updateQueue,l===null&&(l=La(),$t.updateQueue=l),d=l.lastEffect,d===null?l.lastEffect=o.next=o:(m=d.next,d.next=o,o.next=m,l.lastEffect=o),o}function Qc(){return zr().memoizedState}function $a(o,l,d,m){var E=wn();$t.flags|=o,E.memoizedState=oo(1|l,{destroy:void 0},d,m===void 0?null:m)}function ja(o,l,d,m){var E=zr();m=m===void 0?null:m;var C=E.memoizedState.inst;gr!==null&&m!==null&&Wl(m,gr.memoizedState.deps)?E.memoizedState=oo(l,C,d,m):($t.flags|=o,E.memoizedState=oo(1|l,C,d,m))}function Zc(o,l){$a(8390656,8,o,l)}function ru(o,l){ja(2048,8,o,l)}function Ih(o){$t.flags|=4;var l=$t.updateQueue;if(l===null)l=La(),$t.updateQueue=l,l.events=[o];else{var d=l.events;d===null?l.events=[o]:d.push(o)}}function Xc(o){var l=zr().memoizedState;return Ih({ref:l,nextImpl:o}),function(){if((rr&2)!==0)throw Error(n(440));return l.impl.apply(void 0,arguments)}}function Yc(o,l){return ja(4,2,o,l)}function ed(o,l){return ja(4,4,o,l)}function td(o,l){if(typeof l=="function"){o=o();var d=l(o);return function(){typeof d=="function"?d():l(null)}}if(l!=null)return o=o(),l.current=o,function(){l.current=null}}function rd(o,l,d){d=d!=null?d.concat([o]):null,ja(4,4,td.bind(null,l,o),d)}function nu(){}function nd(o,l){var d=zr();l=l===void 0?null:l;var m=d.memoizedState;return l!==null&&Wl(l,m[1])?m[0]:(d.memoizedState=[o,l],o)}function sd(o,l){var d=zr();l=l===void 0?null:l;var m=d.memoizedState;if(l!==null&&Wl(l,m[1]))return m[0];if(m=o(),ks){_t(!0);try{o()}finally{_t(!1)}}return d.memoizedState=[m,l],m}function iu(o,l,d){return d===void 0||(Ni&1073741824)!==0&&(Wt&261930)===0?o.memoizedState=l:(o.memoizedState=d,o=af(),$t.lanes|=o,us|=o,d)}function od(o,l,d,m){return vt(d,l)?d:no.current!==null?(o=iu(o,d,m),vt(o,l)||(Qr=!0),o):(Ni&42)===0||(Ni&1073741824)!==0&&(Wt&261930)===0?(Qr=!0,o.memoizedState=d):(o=af(),$t.lanes|=o,us|=o,l)}function ad(o,l,d,m,E){var C=Ve.p;Ve.p=C!==0&&8>C?C:8;var W=ye.T,le={};ye.T=le,au(o,!1,l,d);try{var ke=E(),Ye=ye.S;if(Ye!==null&&Ye(le,ke),ke!==null&&typeof ke=="object"&&typeof ke.then=="function"){var lt=Eh(ke,m);Mo(o,l,lt,Bn(o))}else Mo(o,l,m,Bn(o))}catch(dt){Mo(o,l,{then:function(){},status:"rejected",reason:dt},Bn())}finally{Ve.p=C,W!==null&&le.types!==null&&(W.types=le.types),ye.T=W}}function Ch(){}function su(o,l,d,m){if(o.tag!==5)throw Error(n(476));var E=ld(o).queue;ad(o,E,l,pe,d===null?Ch:function(){return ud(o),d(m)})}function ld(o){var l=o.memoizedState;if(l!==null)return l;l={memoizedState:pe,baseState:pe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fi,lastRenderedState:pe},next:null};var d={};return l.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fi,lastRenderedState:d},next:null},o.memoizedState=l,o=o.alternate,o!==null&&(o.memoizedState=l),l}function ud(o){var l=ld(o);l.next===null&&(l=o.alternate.memoizedState),Mo(o,l.next.queue,{},Bn())}function ou(){return un(ia)}function cd(){return zr().memoizedState}function dd(){return zr().memoizedState}function Nh(o){for(var l=o.return;l!==null;){switch(l.tag){case 24:case 3:var d=Bn();o=ts(d);var m=rs(l,o,d);m!==null&&(Nn(m,l,d),Uo(m,l,d)),l={cache:Ll()},o.payload=l;return}l=l.return}}function Fh(o,l,d){var m=Bn();d={lane:m,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Ba(o)?hd(l,d):(d=Tl(o,l,d,m),d!==null&&(Nn(d,o,m),pd(d,l,m)))}function fd(o,l,d){var m=Bn();Mo(o,l,d,m)}function Mo(o,l,d,m){var E={lane:m,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(Ba(o))hd(l,E);else{var C=o.alternate;if(o.lanes===0&&(C===null||C.lanes===0)&&(C=l.lastRenderedReducer,C!==null))try{var W=l.lastRenderedState,le=C(W,d);if(E.hasEagerState=!0,E.eagerState=le,vt(le,W))return wa(o,l,E,0),_r===null&&ba(),!1}catch{}if(d=Tl(o,l,E,m),d!==null)return Nn(d,o,m),pd(d,l,m),!0}return!1}function au(o,l,d,m){if(m={lane:2,revertLane:ju(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},Ba(o)){if(l)throw Error(n(479))}else l=Tl(o,d,m,2),l!==null&&Nn(l,o,2)}function Ba(o){var l=o.alternate;return o===$t||l!==null&&l===$t}function hd(o,l){io=Pa=!0;var d=o.pending;d===null?l.next=l:(l.next=d.next,d.next=l),o.pending=l}function pd(o,l,d){if((d&4194048)!==0){var m=l.lanes;m&=o.pendingLanes,d|=m,l.lanes=d,Ut(o,d)}}var qo={readContext:un,use:Ua,useCallback:jr,useContext:jr,useEffect:jr,useImperativeHandle:jr,useLayoutEffect:jr,useInsertionEffect:jr,useMemo:jr,useReducer:jr,useRef:jr,useState:jr,useDebugValue:jr,useDeferredValue:jr,useTransition:jr,useSyncExternalStore:jr,useId:jr,useHostTransitionStatus:jr,useFormState:jr,useActionState:jr,useOptimistic:jr,useMemoCache:jr,useCacheRefresh:jr};qo.useEffectEvent=jr;var gd={readContext:un,use:Ua,useCallback:function(o,l){return wn().memoizedState=[o,l===void 0?null:l],o},useContext:un,useEffect:Zc,useImperativeHandle:function(o,l,d){d=d!=null?d.concat([o]):null,$a(4194308,4,td.bind(null,l,o),d)},useLayoutEffect:function(o,l){return $a(4194308,4,o,l)},useInsertionEffect:function(o,l){$a(4,2,o,l)},useMemo:function(o,l){var d=wn();l=l===void 0?null:l;var m=o();if(ks){_t(!0);try{o()}finally{_t(!1)}}return d.memoizedState=[m,l],m},useReducer:function(o,l,d){var m=wn();if(d!==void 0){var E=d(l);if(ks){_t(!0);try{d(l)}finally{_t(!1)}}}else E=l;return m.memoizedState=m.baseState=E,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:E},m.queue=o,o=o.dispatch=Fh.bind(null,$t,o),[m.memoizedState,o]},useRef:function(o){var l=wn();return o={current:o},l.memoizedState=o},useState:function(o){o=eu(o);var l=o.queue,d=fd.bind(null,$t,l);return l.dispatch=d,[o.memoizedState,d]},useDebugValue:nu,useDeferredValue:function(o,l){var d=wn();return iu(d,o,l)},useTransition:function(){var o=eu(!1);return o=ad.bind(null,$t,o.queue,!0,!1),wn().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,l,d){var m=$t,E=wn();if(Gt){if(d===void 0)throw Error(n(407));d=d()}else{if(d=l(),_r===null)throw Error(n(349));(Wt&127)!==0||Lc(m,l,d)}E.memoizedState=d;var C={value:d,getSnapshot:l};return E.queue=C,Zc(Oc.bind(null,m,C,o),[o]),m.flags|=2048,oo(9,{destroy:void 0},Uc.bind(null,m,C,d,l),null),d},useId:function(){var o=wn(),l=_r.identifierPrefix;if(Gt){var d=mi,m=gi;d=(m&~(1<<32-Tt(m)-1)).toString(32)+d,l="_"+l+"R_"+d,d=ka++,0<d&&(l+="H"+d.toString(32)),l+="_"}else d=Th++,l="_"+l+"r_"+d.toString(32)+"_";return o.memoizedState=l},useHostTransitionStatus:ou,useFormState:Wc,useActionState:Wc,useOptimistic:function(o){var l=wn();l.memoizedState=l.baseState=o;var d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=d,l=au.bind(null,$t,!0,d),d.dispatch=l,[o,l]},useMemoCache:Zl,useCacheRefresh:function(){return wn().memoizedState=Nh.bind(null,$t)},useEffectEvent:function(o){var l=wn(),d={impl:o};return l.memoizedState=d,function(){if((rr&2)!==0)throw Error(n(440));return d.impl.apply(void 0,arguments)}}},lu={readContext:un,use:Ua,useCallback:nd,useContext:un,useEffect:ru,useImperativeHandle:rd,useInsertionEffect:Yc,useLayoutEffect:ed,useMemo:sd,useReducer:Oa,useRef:Qc,useState:function(){return Oa(Fi)},useDebugValue:nu,useDeferredValue:function(o,l){var d=zr();return od(d,gr.memoizedState,o,l)},useTransition:function(){var o=Oa(Fi)[0],l=zr().memoizedState;return[typeof o=="boolean"?o:Bo(o),l]},useSyncExternalStore:kc,useId:cd,useHostTransitionStatus:ou,useFormState:Kc,useActionState:Kc,useOptimistic:function(o,l){var d=zr();return Bc(d,gr,o,l)},useMemoCache:Zl,useCacheRefresh:dd};lu.useEffectEvent=Xc;var md={readContext:un,use:Ua,useCallback:nd,useContext:un,useEffect:ru,useImperativeHandle:rd,useInsertionEffect:Yc,useLayoutEffect:ed,useMemo:sd,useReducer:Yl,useRef:Qc,useState:function(){return Yl(Fi)},useDebugValue:nu,useDeferredValue:function(o,l){var d=zr();return gr===null?iu(d,o,l):od(d,gr.memoizedState,o,l)},useTransition:function(){var o=Yl(Fi)[0],l=zr().memoizedState;return[typeof o=="boolean"?o:Bo(o),l]},useSyncExternalStore:kc,useId:cd,useHostTransitionStatus:ou,useFormState:Jc,useActionState:Jc,useOptimistic:function(o,l){var d=zr();return gr!==null?Bc(d,gr,o,l):(d.baseState=o,[o,d.queue.dispatch])},useMemoCache:Zl,useCacheRefresh:dd};md.useEffectEvent=Xc;function uu(o,l,d,m){l=o.memoizedState,d=d(m,l),d=d==null?l:g({},l,d),o.memoizedState=d,o.lanes===0&&(o.updateQueue.baseState=d)}var cu={enqueueSetState:function(o,l,d){o=o._reactInternals;var m=Bn(),E=ts(m);E.payload=l,d!=null&&(E.callback=d),l=rs(o,E,m),l!==null&&(Nn(l,o,m),Uo(l,o,m))},enqueueReplaceState:function(o,l,d){o=o._reactInternals;var m=Bn(),E=ts(m);E.tag=1,E.payload=l,d!=null&&(E.callback=d),l=rs(o,E,m),l!==null&&(Nn(l,o,m),Uo(l,o,m))},enqueueForceUpdate:function(o,l){o=o._reactInternals;var d=Bn(),m=ts(d);m.tag=2,l!=null&&(m.callback=l),l=rs(o,m,d),l!==null&&(Nn(l,o,d),Uo(l,o,d))}};function yd(o,l,d,m,E,C,W){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(m,C,W):l.prototype&&l.prototype.isPureReactComponent?!se(d,m)||!se(E,C):!0}function bd(o,l,d,m){o=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(d,m),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(d,m),l.state!==o&&cu.enqueueReplaceState(l,l.state,null)}function Ls(o,l){var d=l;if("ref"in l){d={};for(var m in l)m!=="ref"&&(d[m]=l[m])}if(o=o.defaultProps){d===l&&(d=g({},d));for(var E in o)d[E]===void 0&&(d[E]=o[E])}return d}function _d(o){ya(o)}function wd(o){console.error(o)}function vd(o){ya(o)}function Ma(o,l){try{var d=o.onUncaughtError;d(l.value,{componentStack:l.stack})}catch(m){setTimeout(function(){throw m})}}function Sd(o,l,d){try{var m=o.onCaughtError;m(d.value,{componentStack:d.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(E){setTimeout(function(){throw E})}}function du(o,l,d){return d=ts(d),d.tag=3,d.payload={element:null},d.callback=function(){Ma(o,l)},d}function Ed(o){return o=ts(o),o.tag=3,o}function Td(o,l,d,m){var E=d.type.getDerivedStateFromError;if(typeof E=="function"){var C=m.value;o.payload=function(){return E(C)},o.callback=function(){Sd(l,d,m)}}var W=d.stateNode;W!==null&&typeof W.componentDidCatch=="function"&&(o.callback=function(){Sd(l,d,m),typeof E!="function"&&(cs===null?cs=new Set([this]):cs.add(this));var le=m.stack;this.componentDidCatch(m.value,{componentStack:le!==null?le:""})})}function Dh(o,l,d,m,E){if(d.flags|=32768,m!==null&&typeof m=="object"&&typeof m.then=="function"){if(l=d.alternate,l!==null&&Xs(l,d,E,!0),d=Un.current,d!==null){switch(d.tag){case 31:case 13:return ri===null?Ya():d.alternate===null&&Br===0&&(Br=3),d.flags&=-257,d.flags|=65536,d.lanes=E,m===Ia?d.flags|=16384:(l=d.updateQueue,l===null?d.updateQueue=new Set([m]):l.add(m),Uu(o,m,E)),!1;case 22:return d.flags|=65536,m===Ia?d.flags|=16384:(l=d.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([m])},d.updateQueue=l):(d=l.retryQueue,d===null?l.retryQueue=new Set([m]):d.add(m)),Uu(o,m,E)),!1}throw Error(n(435,d.tag))}return Uu(o,m,E),Ya(),!1}if(Gt)return l=Un.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=E,m!==Nl&&(o=Error(n(422),{cause:m}),Fo(Xn(o,d)))):(m!==Nl&&(l=Error(n(423),{cause:m}),Fo(Xn(l,d))),o=o.current.alternate,o.flags|=65536,E&=-E,o.lanes|=E,m=Xn(m,d),E=du(o.stateNode,m,E),Ml(o,E),Br!==4&&(Br=2)),!1;var C=Error(n(520),{cause:m});if(C=Xn(C,d),Qo===null?Qo=[C]:Qo.push(C),Br!==4&&(Br=2),l===null)return!0;m=Xn(m,d),d=l;do{switch(d.tag){case 3:return d.flags|=65536,o=E&-E,d.lanes|=o,o=du(d.stateNode,m,o),Ml(d,o),!1;case 1:if(l=d.type,C=d.stateNode,(d.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||C!==null&&typeof C.componentDidCatch=="function"&&(cs===null||!cs.has(C))))return d.flags|=65536,E&=-E,d.lanes|=E,E=Ed(E),Td(E,o,d,m),Ml(d,E),!1}d=d.return}while(d!==null);return!1}var fu=Error(n(461)),Qr=!1;function dn(o,l,d,m){l.child=o===null?Ac(l,null,d,m):Ps(l,o.child,d,m)}function Rd(o,l,d,m,E){d=d.render;var C=l.ref;if("ref"in m){var W={};for(var le in m)le!=="ref"&&(W[le]=m[le])}else W=m;return Cs(l),m=Kl(o,l,d,W,C,E),le=Gl(),o!==null&&!Qr?(Jl(o,l,E),Di(o,l,E)):(Gt&&le&&Il(l),l.flags|=1,dn(o,l,m,E),l.child)}function xd(o,l,d,m,E){if(o===null){var C=d.type;return typeof C=="function"&&!Rl(C)&&C.defaultProps===void 0&&d.compare===null?(l.tag=15,l.type=C,Ad(o,l,C,m,E)):(o=Sa(d.type,null,m,l,l.mode,E),o.ref=l.ref,o.return=l,l.child=o)}if(C=o.child,!wu(o,E)){var W=C.memoizedProps;if(d=d.compare,d=d!==null?d:se,d(W,m)&&o.ref===l.ref)return Di(o,l,E)}return l.flags|=1,o=xi(C,m),o.ref=l.ref,o.return=l,l.child=o}function Ad(o,l,d,m,E){if(o!==null){var C=o.memoizedProps;if(se(C,m)&&o.ref===l.ref)if(Qr=!1,l.pendingProps=m=C,wu(o,E))(o.flags&131072)!==0&&(Qr=!0);else return l.lanes=o.lanes,Di(o,l,E)}return hu(o,l,d,m,E)}function Id(o,l,d,m){var E=m.children,C=o!==null?o.memoizedState:null;if(o===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.mode==="hidden"){if((l.flags&128)!==0){if(C=C!==null?C.baseLanes|d:d,o!==null){for(m=l.child=o.child,E=0;m!==null;)E=E|m.lanes|m.childLanes,m=m.sibling;m=E&~C}else m=0,l.child=null;return Cd(o,l,C,d,m)}if((d&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},o!==null&&xa(l,C!==null?C.cachePool:null),C!==null?Nc(l,C):zl(),Fc(l);else return m=l.lanes=536870912,Cd(o,l,C!==null?C.baseLanes|d:d,d,m)}else C!==null?(xa(l,C.cachePool),Nc(l,C),os(),l.memoizedState=null):(o!==null&&xa(l,null),zl(),os());return dn(o,l,E,d),l.child}function zo(o,l){return o!==null&&o.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function Cd(o,l,d,m,E){var C=Ol();return C=C===null?null:{parent:Gr._currentValue,pool:C},l.memoizedState={baseLanes:d,cachePool:C},o!==null&&xa(l,null),zl(),Fc(l),o!==null&&Xs(o,l,m,!0),l.childLanes=E,null}function qa(o,l){return l=Va({mode:l.mode,children:l.children},o.mode),l.ref=o.ref,o.child=l,l.return=o,l}function Nd(o,l,d){return Ps(l,o.child,null,d),o=qa(l,l.pendingProps),o.flags|=2,On(l),l.memoizedState=null,o}function Ph(o,l,d){var m=l.pendingProps,E=(l.flags&128)!==0;if(l.flags&=-129,o===null){if(Gt){if(m.mode==="hidden")return o=qa(l,m),l.lanes=536870912,zo(null,o);if(Hl(l),(o=xr)?(o=zf(o,ti),o=o!==null&&o.data==="&"?o:null,o!==null&&(l.memoizedState={dehydrated:o,treeContext:Qi!==null?{id:gi,overflow:mi}:null,retryLane:536870912,hydrationErrors:null},d=fc(o),d.return=l,l.child=d,ln=l,xr=null)):o=null,o===null)throw Xi(l);return l.lanes=536870912,null}return qa(l,m)}var C=o.memoizedState;if(C!==null){var W=C.dehydrated;if(Hl(l),E)if(l.flags&256)l.flags&=-257,l=Nd(o,l,d);else if(l.memoizedState!==null)l.child=o.child,l.flags|=128,l=null;else throw Error(n(558));else if(Qr||Xs(o,l,d,!1),E=(d&o.childLanes)!==0,Qr||E){if(m=_r,m!==null&&(W=Ht(m,d),W!==0&&W!==C.retryLane))throw C.retryLane=W,Rs(o,W),Nn(m,o,W),fu;Ya(),l=Nd(o,l,d)}else o=C.treeContext,xr=ni(W.nextSibling),ln=l,Gt=!0,Zi=null,ti=!1,o!==null&&gc(l,o),l=qa(l,m),l.flags|=4096;return l}return o=xi(o.child,{mode:m.mode,children:m.children}),o.ref=l.ref,l.child=o,o.return=l,o}function za(o,l){var d=l.ref;if(d===null)o!==null&&o.ref!==null&&(l.flags|=4194816);else{if(typeof d!="function"&&typeof d!="object")throw Error(n(284));(o===null||o.ref!==d)&&(l.flags|=4194816)}}function hu(o,l,d,m,E){return Cs(l),d=Kl(o,l,d,m,void 0,E),m=Gl(),o!==null&&!Qr?(Jl(o,l,E),Di(o,l,E)):(Gt&&m&&Il(l),l.flags|=1,dn(o,l,d,E),l.child)}function Fd(o,l,d,m,E,C){return Cs(l),l.updateQueue=null,d=Pc(l,m,d,E),Dc(o),m=Gl(),o!==null&&!Qr?(Jl(o,l,C),Di(o,l,C)):(Gt&&m&&Il(l),l.flags|=1,dn(o,l,d,C),l.child)}function Dd(o,l,d,m,E){if(Cs(l),l.stateNode===null){var C=Gs,W=d.contextType;typeof W=="object"&&W!==null&&(C=un(W)),C=new d(m,C),l.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,C.updater=cu,l.stateNode=C,C._reactInternals=l,C=l.stateNode,C.props=m,C.state=l.memoizedState,C.refs={},jl(l),W=d.contextType,C.context=typeof W=="object"&&W!==null?un(W):Gs,C.state=l.memoizedState,W=d.getDerivedStateFromProps,typeof W=="function"&&(uu(l,d,W,m),C.state=l.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(W=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),W!==C.state&&cu.enqueueReplaceState(C,C.state,null),$o(l,m,C,E),Oo(),C.state=l.memoizedState),typeof C.componentDidMount=="function"&&(l.flags|=4194308),m=!0}else if(o===null){C=l.stateNode;var le=l.memoizedProps,ke=Ls(d,le);C.props=ke;var Ye=C.context,lt=d.contextType;W=Gs,typeof lt=="object"&&lt!==null&&(W=un(lt));var dt=d.getDerivedStateFromProps;lt=typeof dt=="function"||typeof C.getSnapshotBeforeUpdate=="function",le=l.pendingProps!==le,lt||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(le||Ye!==W)&&bd(l,C,m,W),es=!1;var tt=l.memoizedState;C.state=tt,$o(l,m,C,E),Oo(),Ye=l.memoizedState,le||tt!==Ye||es?(typeof dt=="function"&&(uu(l,d,dt,m),Ye=l.memoizedState),(ke=es||yd(l,d,ke,m,tt,Ye,W))?(lt||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(l.flags|=4194308)):(typeof C.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=m,l.memoizedState=Ye),C.props=m,C.state=Ye,C.context=W,m=ke):(typeof C.componentDidMount=="function"&&(l.flags|=4194308),m=!1)}else{C=l.stateNode,Bl(o,l),W=l.memoizedProps,lt=Ls(d,W),C.props=lt,dt=l.pendingProps,tt=C.context,Ye=d.contextType,ke=Gs,typeof Ye=="object"&&Ye!==null&&(ke=un(Ye)),le=d.getDerivedStateFromProps,(Ye=typeof le=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(W!==dt||tt!==ke)&&bd(l,C,m,ke),es=!1,tt=l.memoizedState,C.state=tt,$o(l,m,C,E),Oo();var it=l.memoizedState;W!==dt||tt!==it||es||o!==null&&o.dependencies!==null&&Ta(o.dependencies)?(typeof le=="function"&&(uu(l,d,le,m),it=l.memoizedState),(lt=es||yd(l,d,lt,m,tt,it,ke)||o!==null&&o.dependencies!==null&&Ta(o.dependencies))?(Ye||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(m,it,ke),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(m,it,ke)),typeof C.componentDidUpdate=="function"&&(l.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof C.componentDidUpdate!="function"||W===o.memoizedProps&&tt===o.memoizedState||(l.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||W===o.memoizedProps&&tt===o.memoizedState||(l.flags|=1024),l.memoizedProps=m,l.memoizedState=it),C.props=m,C.state=it,C.context=ke,m=lt):(typeof C.componentDidUpdate!="function"||W===o.memoizedProps&&tt===o.memoizedState||(l.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||W===o.memoizedProps&&tt===o.memoizedState||(l.flags|=1024),m=!1)}return C=m,za(o,l),m=(l.flags&128)!==0,C||m?(C=l.stateNode,d=m&&typeof d.getDerivedStateFromError!="function"?null:C.render(),l.flags|=1,o!==null&&m?(l.child=Ps(l,o.child,null,E),l.child=Ps(l,null,d,E)):dn(o,l,d,E),l.memoizedState=C.state,o=l.child):o=Di(o,l,E),o}function Pd(o,l,d,m){return As(),l.flags|=256,dn(o,l,d,m),l.child}var pu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function gu(o){return{baseLanes:o,cachePool:vc()}}function mu(o,l,d){return o=o!==null?o.childLanes&~d:0,l&&(o|=jn),o}function kd(o,l,d){var m=l.pendingProps,E=!1,C=(l.flags&128)!==0,W;if((W=C)||(W=o!==null&&o.memoizedState===null?!1:(qr.current&2)!==0),W&&(E=!0,l.flags&=-129),W=(l.flags&32)!==0,l.flags&=-33,o===null){if(Gt){if(E?ss(l):os(),(o=xr)?(o=zf(o,ti),o=o!==null&&o.data!=="&"?o:null,o!==null&&(l.memoizedState={dehydrated:o,treeContext:Qi!==null?{id:gi,overflow:mi}:null,retryLane:536870912,hydrationErrors:null},d=fc(o),d.return=l,l.child=d,ln=l,xr=null)):o=null,o===null)throw Xi(l);return Xu(o)?l.lanes=32:l.lanes=536870912,null}var le=m.children;return m=m.fallback,E?(os(),E=l.mode,le=Va({mode:"hidden",children:le},E),m=xs(m,E,d,null),le.return=l,m.return=l,le.sibling=m,l.child=le,m=l.child,m.memoizedState=gu(d),m.childLanes=mu(o,W,d),l.memoizedState=pu,zo(null,m)):(ss(l),yu(l,le))}var ke=o.memoizedState;if(ke!==null&&(le=ke.dehydrated,le!==null)){if(C)l.flags&256?(ss(l),l.flags&=-257,l=bu(o,l,d)):l.memoizedState!==null?(os(),l.child=o.child,l.flags|=128,l=null):(os(),le=m.fallback,E=l.mode,m=Va({mode:"visible",children:m.children},E),le=xs(le,E,d,null),le.flags|=2,m.return=l,le.return=l,m.sibling=le,l.child=m,Ps(l,o.child,null,d),m=l.child,m.memoizedState=gu(d),m.childLanes=mu(o,W,d),l.memoizedState=pu,l=zo(null,m));else if(ss(l),Xu(le)){if(W=le.nextSibling&&le.nextSibling.dataset,W)var Ye=W.dgst;W=Ye,m=Error(n(419)),m.stack="",m.digest=W,Fo({value:m,source:null,stack:null}),l=bu(o,l,d)}else if(Qr||Xs(o,l,d,!1),W=(d&o.childLanes)!==0,Qr||W){if(W=_r,W!==null&&(m=Ht(W,d),m!==0&&m!==ke.retryLane))throw ke.retryLane=m,Rs(o,m),Nn(W,o,m),fu;Zu(le)||Ya(),l=bu(o,l,d)}else Zu(le)?(l.flags|=192,l.child=o.child,l=null):(o=ke.treeContext,xr=ni(le.nextSibling),ln=l,Gt=!0,Zi=null,ti=!1,o!==null&&gc(l,o),l=yu(l,m.children),l.flags|=4096);return l}return E?(os(),le=m.fallback,E=l.mode,ke=o.child,Ye=ke.sibling,m=xi(ke,{mode:"hidden",children:m.children}),m.subtreeFlags=ke.subtreeFlags&65011712,Ye!==null?le=xi(Ye,le):(le=xs(le,E,d,null),le.flags|=2),le.return=l,m.return=l,m.sibling=le,l.child=m,zo(null,m),m=l.child,le=o.child.memoizedState,le===null?le=gu(d):(E=le.cachePool,E!==null?(ke=Gr._currentValue,E=E.parent!==ke?{parent:ke,pool:ke}:E):E=vc(),le={baseLanes:le.baseLanes|d,cachePool:E}),m.memoizedState=le,m.childLanes=mu(o,W,d),l.memoizedState=pu,zo(o.child,m)):(ss(l),d=o.child,o=d.sibling,d=xi(d,{mode:"visible",children:m.children}),d.return=l,d.sibling=null,o!==null&&(W=l.deletions,W===null?(l.deletions=[o],l.flags|=16):W.push(o)),l.child=d,l.memoizedState=null,d)}function yu(o,l){return l=Va({mode:"visible",children:l},o.mode),l.return=o,o.child=l}function Va(o,l){return o=Ln(22,o,null,l),o.lanes=0,o}function bu(o,l,d){return Ps(l,o.child,null,d),o=yu(l,l.pendingProps.children),o.flags|=2,l.memoizedState=null,o}function Ld(o,l,d){o.lanes|=l;var m=o.alternate;m!==null&&(m.lanes|=l),Pl(o.return,l,d)}function _u(o,l,d,m,E,C){var W=o.memoizedState;W===null?o.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:m,tail:d,tailMode:E,treeForkCount:C}:(W.isBackwards=l,W.rendering=null,W.renderingStartTime=0,W.last=m,W.tail=d,W.tailMode=E,W.treeForkCount=C)}function Ud(o,l,d){var m=l.pendingProps,E=m.revealOrder,C=m.tail;m=m.children;var W=qr.current,le=(W&2)!==0;if(le?(W=W&1|2,l.flags|=128):W&=1,oe(qr,W),dn(o,l,m,d),m=Gt?No:0,!le&&o!==null&&(o.flags&128)!==0)e:for(o=l.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&Ld(o,d,l);else if(o.tag===19)Ld(o,d,l);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===l)break e;for(;o.sibling===null;){if(o.return===null||o.return===l)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}switch(E){case"forwards":for(d=l.child,E=null;d!==null;)o=d.alternate,o!==null&&Da(o)===null&&(E=d),d=d.sibling;d=E,d===null?(E=l.child,l.child=null):(E=d.sibling,d.sibling=null),_u(l,!1,E,d,C,m);break;case"backwards":case"unstable_legacy-backwards":for(d=null,E=l.child,l.child=null;E!==null;){if(o=E.alternate,o!==null&&Da(o)===null){l.child=E;break}o=E.sibling,E.sibling=d,d=E,E=o}_u(l,!0,d,null,C,m);break;case"together":_u(l,!1,null,null,void 0,m);break;default:l.memoizedState=null}return l.child}function Di(o,l,d){if(o!==null&&(l.dependencies=o.dependencies),us|=l.lanes,(d&l.childLanes)===0)if(o!==null){if(Xs(o,l,d,!1),(d&l.childLanes)===0)return null}else return null;if(o!==null&&l.child!==o.child)throw Error(n(153));if(l.child!==null){for(o=l.child,d=xi(o,o.pendingProps),l.child=d,d.return=l;o.sibling!==null;)o=o.sibling,d=d.sibling=xi(o,o.pendingProps),d.return=l;d.sibling=null}return l.child}function wu(o,l){return(o.lanes&l)!==0?!0:(o=o.dependencies,!!(o!==null&&Ta(o)))}function kh(o,l,d){switch(l.tag){case 3:he(l,l.stateNode.containerInfo),Yi(l,Gr,o.memoizedState.cache),As();break;case 27:case 5:Oe(l);break;case 4:he(l,l.stateNode.containerInfo);break;case 10:Yi(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,Hl(l),null;break;case 13:var m=l.memoizedState;if(m!==null)return m.dehydrated!==null?(ss(l),l.flags|=128,null):(d&l.child.childLanes)!==0?kd(o,l,d):(ss(l),o=Di(o,l,d),o!==null?o.sibling:null);ss(l);break;case 19:var E=(o.flags&128)!==0;if(m=(d&l.childLanes)!==0,m||(Xs(o,l,d,!1),m=(d&l.childLanes)!==0),E){if(m)return Ud(o,l,d);l.flags|=128}if(E=l.memoizedState,E!==null&&(E.rendering=null,E.tail=null,E.lastEffect=null),oe(qr,qr.current),m)break;return null;case 22:return l.lanes=0,Id(o,l,d,l.pendingProps);case 24:Yi(l,Gr,o.memoizedState.cache)}return Di(o,l,d)}function Od(o,l,d){if(o!==null)if(o.memoizedProps!==l.pendingProps)Qr=!0;else{if(!wu(o,d)&&(l.flags&128)===0)return Qr=!1,kh(o,l,d);Qr=(o.flags&131072)!==0}else Qr=!1,Gt&&(l.flags&1048576)!==0&&pc(l,No,l.index);switch(l.lanes=0,l.tag){case 16:e:{var m=l.pendingProps;if(o=Fs(l.elementType),l.type=o,typeof o=="function")Rl(o)?(m=Ls(o,m),l.tag=1,l=Dd(null,l,o,m,d)):(l.tag=0,l=hu(null,l,o,m,d));else{if(o!=null){var E=o.$$typeof;if(E===D){l.tag=11,l=Rd(null,l,o,m,d);break e}else if(E===z){l.tag=14,l=xd(null,l,o,m,d);break e}}throw l=$e(o)||o,Error(n(306,l,""))}}return l;case 0:return hu(o,l,l.type,l.pendingProps,d);case 1:return m=l.type,E=Ls(m,l.pendingProps),Dd(o,l,m,E,d);case 3:e:{if(he(l,l.stateNode.containerInfo),o===null)throw Error(n(387));m=l.pendingProps;var C=l.memoizedState;E=C.element,Bl(o,l),$o(l,m,null,d);var W=l.memoizedState;if(m=W.cache,Yi(l,Gr,m),m!==C.cache&&kl(l,[Gr],d,!0),Oo(),m=W.element,C.isDehydrated)if(C={element:m,isDehydrated:!1,cache:W.cache},l.updateQueue.baseState=C,l.memoizedState=C,l.flags&256){l=Pd(o,l,m,d);break e}else if(m!==E){E=Xn(Error(n(424)),l),Fo(E),l=Pd(o,l,m,d);break e}else for(o=l.stateNode.containerInfo,o.nodeType===9?o=o.body:o=o.nodeName==="HTML"?o.ownerDocument.body:o,xr=ni(o.firstChild),ln=l,Gt=!0,Zi=null,ti=!0,d=Ac(l,null,m,d),l.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(As(),m===E){l=Di(o,l,d);break e}dn(o,l,m,d)}l=l.child}return l;case 26:return za(o,l),o===null?(d=Jf(l.type,null,l.pendingProps,null))?l.memoizedState=d:Gt||(d=l.type,o=l.pendingProps,m=ol(Je.current).createElement(d),m[qt]=l,m[fr]=o,fn(m,d,o),Er(m),l.stateNode=m):l.memoizedState=Jf(l.type,o.memoizedProps,l.pendingProps,o.memoizedState),null;case 27:return Oe(l),o===null&&Gt&&(m=l.stateNode=Wf(l.type,l.pendingProps,Je.current),ln=l,ti=!0,E=xr,ps(l.type)?(Yu=E,xr=ni(m.firstChild)):xr=E),dn(o,l,l.pendingProps.children,d),za(o,l),o===null&&(l.flags|=4194304),l.child;case 5:return o===null&&Gt&&((E=m=xr)&&(m=cp(m,l.type,l.pendingProps,ti),m!==null?(l.stateNode=m,ln=l,xr=ni(m.firstChild),ti=!1,E=!0):E=!1),E||Xi(l)),Oe(l),E=l.type,C=l.pendingProps,W=o!==null?o.memoizedProps:null,m=C.children,Gu(E,C)?m=null:W!==null&&Gu(E,W)&&(l.flags|=32),l.memoizedState!==null&&(E=Kl(o,l,Rh,null,null,d),ia._currentValue=E),za(o,l),dn(o,l,m,d),l.child;case 6:return o===null&&Gt&&((o=d=xr)&&(d=dp(d,l.pendingProps,ti),d!==null?(l.stateNode=d,ln=l,xr=null,o=!0):o=!1),o||Xi(l)),null;case 13:return kd(o,l,d);case 4:return he(l,l.stateNode.containerInfo),m=l.pendingProps,o===null?l.child=Ps(l,null,m,d):dn(o,l,m,d),l.child;case 11:return Rd(o,l,l.type,l.pendingProps,d);case 7:return dn(o,l,l.pendingProps,d),l.child;case 8:return dn(o,l,l.pendingProps.children,d),l.child;case 12:return dn(o,l,l.pendingProps.children,d),l.child;case 10:return m=l.pendingProps,Yi(l,l.type,m.value),dn(o,l,m.children,d),l.child;case 9:return E=l.type._context,m=l.pendingProps.children,Cs(l),E=un(E),m=m(E),l.flags|=1,dn(o,l,m,d),l.child;case 14:return xd(o,l,l.type,l.pendingProps,d);case 15:return Ad(o,l,l.type,l.pendingProps,d);case 19:return Ud(o,l,d);case 31:return Ph(o,l,d);case 22:return Id(o,l,d,l.pendingProps);case 24:return Cs(l),m=un(Gr),o===null?(E=Ol(),E===null&&(E=_r,C=Ll(),E.pooledCache=C,C.refCount++,C!==null&&(E.pooledCacheLanes|=d),E=C),l.memoizedState={parent:m,cache:E},jl(l),Yi(l,Gr,E)):((o.lanes&d)!==0&&(Bl(o,l),$o(l,null,null,d),Oo()),E=o.memoizedState,C=l.memoizedState,E.parent!==m?(E={parent:m,cache:m},l.memoizedState=E,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=E),Yi(l,Gr,m)):(m=C.cache,Yi(l,Gr,m),m!==E.cache&&kl(l,[Gr],d,!0))),dn(o,l,l.pendingProps.children,d),l.child;case 29:throw l.pendingProps}throw Error(n(156,l.tag))}function Pi(o){o.flags|=4}function vu(o,l,d,m,E){if((l=(o.mode&32)!==0)&&(l=!1),l){if(o.flags|=16777216,(E&335544128)===E)if(o.stateNode.complete)o.flags|=8192;else if(df())o.flags|=8192;else throw Ds=Ia,$l}else o.flags&=-16777217}function $d(o,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)o.flags&=-16777217;else if(o.flags|=16777216,!eh(l))if(df())o.flags|=8192;else throw Ds=Ia,$l}function Ha(o,l){l!==null&&(o.flags|=4),o.flags&16384&&(l=o.tag!==22?M():536870912,o.lanes|=l,co|=l)}function Vo(o,l){if(!Gt)switch(o.tailMode){case"hidden":l=o.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?o.tail=null:d.sibling=null;break;case"collapsed":d=o.tail;for(var m=null;d!==null;)d.alternate!==null&&(m=d),d=d.sibling;m===null?l||o.tail===null?o.tail=null:o.tail.sibling=null:m.sibling=null}}function Ar(o){var l=o.alternate!==null&&o.alternate.child===o.child,d=0,m=0;if(l)for(var E=o.child;E!==null;)d|=E.lanes|E.childLanes,m|=E.subtreeFlags&65011712,m|=E.flags&65011712,E.return=o,E=E.sibling;else for(E=o.child;E!==null;)d|=E.lanes|E.childLanes,m|=E.subtreeFlags,m|=E.flags,E.return=o,E=E.sibling;return o.subtreeFlags|=m,o.childLanes=d,l}function Lh(o,l,d){var m=l.pendingProps;switch(Cl(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ar(l),null;case 1:return Ar(l),null;case 3:return d=l.stateNode,m=null,o!==null&&(m=o.memoizedState.cache),l.memoizedState.cache!==m&&(l.flags|=2048),Ci(Gr),fe(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(o===null||o.child===null)&&(Zs(l)?Pi(l):o===null||o.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Fl())),Ar(l),null;case 26:var E=l.type,C=l.memoizedState;return o===null?(Pi(l),C!==null?(Ar(l),$d(l,C)):(Ar(l),vu(l,E,null,m,d))):C?C!==o.memoizedState?(Pi(l),Ar(l),$d(l,C)):(Ar(l),l.flags&=-16777217):(o=o.memoizedProps,o!==m&&Pi(l),Ar(l),vu(l,E,o,m,d)),null;case 27:if(ie(l),d=Je.current,E=l.type,o!==null&&l.stateNode!=null)o.memoizedProps!==m&&Pi(l);else{if(!m){if(l.stateNode===null)throw Error(n(166));return Ar(l),null}o=Fe.current,Zs(l)?mc(l):(o=Wf(E,m,d),l.stateNode=o,Pi(l))}return Ar(l),null;case 5:if(ie(l),E=l.type,o!==null&&l.stateNode!=null)o.memoizedProps!==m&&Pi(l);else{if(!m){if(l.stateNode===null)throw Error(n(166));return Ar(l),null}if(C=Fe.current,Zs(l))mc(l);else{var W=ol(Je.current);switch(C){case 1:C=W.createElementNS("http://www.w3.org/2000/svg",E);break;case 2:C=W.createElementNS("http://www.w3.org/1998/Math/MathML",E);break;default:switch(E){case"svg":C=W.createElementNS("http://www.w3.org/2000/svg",E);break;case"math":C=W.createElementNS("http://www.w3.org/1998/Math/MathML",E);break;case"script":C=W.createElement("div"),C.innerHTML="<script><\/script>",C=C.removeChild(C.firstChild);break;case"select":C=typeof m.is=="string"?W.createElement("select",{is:m.is}):W.createElement("select"),m.multiple?C.multiple=!0:m.size&&(C.size=m.size);break;default:C=typeof m.is=="string"?W.createElement(E,{is:m.is}):W.createElement(E)}}C[qt]=l,C[fr]=m;e:for(W=l.child;W!==null;){if(W.tag===5||W.tag===6)C.appendChild(W.stateNode);else if(W.tag!==4&&W.tag!==27&&W.child!==null){W.child.return=W,W=W.child;continue}if(W===l)break e;for(;W.sibling===null;){if(W.return===null||W.return===l)break e;W=W.return}W.sibling.return=W.return,W=W.sibling}l.stateNode=C;e:switch(fn(C,E,m),E){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}m&&Pi(l)}}return Ar(l),vu(l,l.type,o===null?null:o.memoizedProps,l.pendingProps,d),null;case 6:if(o&&l.stateNode!=null)o.memoizedProps!==m&&Pi(l);else{if(typeof m!="string"&&l.stateNode===null)throw Error(n(166));if(o=Je.current,Zs(l)){if(o=l.stateNode,d=l.memoizedProps,m=null,E=ln,E!==null)switch(E.tag){case 27:case 5:m=E.memoizedProps}o[qt]=l,o=!!(o.nodeValue===d||m!==null&&m.suppressHydrationWarning===!0||Lf(o.nodeValue,d)),o||Xi(l,!0)}else o=ol(o).createTextNode(m),o[qt]=l,l.stateNode=o}return Ar(l),null;case 31:if(d=l.memoizedState,o===null||o.memoizedState!==null){if(m=Zs(l),d!==null){if(o===null){if(!m)throw Error(n(318));if(o=l.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(557));o[qt]=l}else As(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Ar(l),o=!1}else d=Fl(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=d),o=!0;if(!o)return l.flags&256?(On(l),l):(On(l),null);if((l.flags&128)!==0)throw Error(n(558))}return Ar(l),null;case 13:if(m=l.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(E=Zs(l),m!==null&&m.dehydrated!==null){if(o===null){if(!E)throw Error(n(318));if(E=l.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(n(317));E[qt]=l}else As(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Ar(l),E=!1}else E=Fl(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=E),E=!0;if(!E)return l.flags&256?(On(l),l):(On(l),null)}return On(l),(l.flags&128)!==0?(l.lanes=d,l):(d=m!==null,o=o!==null&&o.memoizedState!==null,d&&(m=l.child,E=null,m.alternate!==null&&m.alternate.memoizedState!==null&&m.alternate.memoizedState.cachePool!==null&&(E=m.alternate.memoizedState.cachePool.pool),C=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(C=m.memoizedState.cachePool.pool),C!==E&&(m.flags|=2048)),d!==o&&d&&(l.child.flags|=8192),Ha(l,l.updateQueue),Ar(l),null);case 4:return fe(),o===null&&zu(l.stateNode.containerInfo),Ar(l),null;case 10:return Ci(l.type),Ar(l),null;case 19:if(ce(qr),m=l.memoizedState,m===null)return Ar(l),null;if(E=(l.flags&128)!==0,C=m.rendering,C===null)if(E)Vo(m,!1);else{if(Br!==0||o!==null&&(o.flags&128)!==0)for(o=l.child;o!==null;){if(C=Da(o),C!==null){for(l.flags|=128,Vo(m,!1),o=C.updateQueue,l.updateQueue=o,Ha(l,o),l.subtreeFlags=0,o=d,d=l.child;d!==null;)dc(d,o),d=d.sibling;return oe(qr,qr.current&1|2),Gt&&Ai(l,m.treeForkCount),l.child}o=o.sibling}m.tail!==null&&ft()>Qa&&(l.flags|=128,E=!0,Vo(m,!1),l.lanes=4194304)}else{if(!E)if(o=Da(C),o!==null){if(l.flags|=128,E=!0,o=o.updateQueue,l.updateQueue=o,Ha(l,o),Vo(m,!0),m.tail===null&&m.tailMode==="hidden"&&!C.alternate&&!Gt)return Ar(l),null}else 2*ft()-m.renderingStartTime>Qa&&d!==536870912&&(l.flags|=128,E=!0,Vo(m,!1),l.lanes=4194304);m.isBackwards?(C.sibling=l.child,l.child=C):(o=m.last,o!==null?o.sibling=C:l.child=C,m.last=C)}return m.tail!==null?(o=m.tail,m.rendering=o,m.tail=o.sibling,m.renderingStartTime=ft(),o.sibling=null,d=qr.current,oe(qr,E?d&1|2:d&1),Gt&&Ai(l,m.treeForkCount),o):(Ar(l),null);case 22:case 23:return On(l),Vl(),m=l.memoizedState!==null,o!==null?o.memoizedState!==null!==m&&(l.flags|=8192):m&&(l.flags|=8192),m?(d&536870912)!==0&&(l.flags&128)===0&&(Ar(l),l.subtreeFlags&6&&(l.flags|=8192)):Ar(l),d=l.updateQueue,d!==null&&Ha(l,d.retryQueue),d=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(d=o.memoizedState.cachePool.pool),m=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(m=l.memoizedState.cachePool.pool),m!==d&&(l.flags|=2048),o!==null&&ce(Ns),null;case 24:return d=null,o!==null&&(d=o.memoizedState.cache),l.memoizedState.cache!==d&&(l.flags|=2048),Ci(Gr),Ar(l),null;case 25:return null;case 30:return null}throw Error(n(156,l.tag))}function Uh(o,l){switch(Cl(l),l.tag){case 1:return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 3:return Ci(Gr),fe(),o=l.flags,(o&65536)!==0&&(o&128)===0?(l.flags=o&-65537|128,l):null;case 26:case 27:case 5:return ie(l),null;case 31:if(l.memoizedState!==null){if(On(l),l.alternate===null)throw Error(n(340));As()}return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 13:if(On(l),o=l.memoizedState,o!==null&&o.dehydrated!==null){if(l.alternate===null)throw Error(n(340));As()}return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 19:return ce(qr),null;case 4:return fe(),null;case 10:return Ci(l.type),null;case 22:case 23:return On(l),Vl(),o!==null&&ce(Ns),o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 24:return Ci(Gr),null;case 25:return null;default:return null}}function jd(o,l){switch(Cl(l),l.tag){case 3:Ci(Gr),fe();break;case 26:case 27:case 5:ie(l);break;case 4:fe();break;case 31:l.memoizedState!==null&&On(l);break;case 13:On(l);break;case 19:ce(qr);break;case 10:Ci(l.type);break;case 22:case 23:On(l),Vl(),o!==null&&ce(Ns);break;case 24:Ci(Gr)}}function Ho(o,l){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var E=m.next;d=E;do{if((d.tag&o)===o){m=void 0;var C=d.create,W=d.inst;m=C(),W.destroy=m}d=d.next}while(d!==E)}}catch(le){cr(l,l.return,le)}}function as(o,l,d){try{var m=l.updateQueue,E=m!==null?m.lastEffect:null;if(E!==null){var C=E.next;m=C;do{if((m.tag&o)===o){var W=m.inst,le=W.destroy;if(le!==void 0){W.destroy=void 0,E=l;var ke=d,Ye=le;try{Ye()}catch(lt){cr(E,ke,lt)}}}m=m.next}while(m!==C)}}catch(lt){cr(l,l.return,lt)}}function Bd(o){var l=o.updateQueue;if(l!==null){var d=o.stateNode;try{Cc(l,d)}catch(m){cr(o,o.return,m)}}}function Md(o,l,d){d.props=Ls(o.type,o.memoizedProps),d.state=o.memoizedState;try{d.componentWillUnmount()}catch(m){cr(o,l,m)}}function Wo(o,l){try{var d=o.ref;if(d!==null){switch(o.tag){case 26:case 27:case 5:var m=o.stateNode;break;case 30:m=o.stateNode;break;default:m=o.stateNode}typeof d=="function"?o.refCleanup=d(m):d.current=m}}catch(E){cr(o,l,E)}}function yi(o,l){var d=o.ref,m=o.refCleanup;if(d!==null)if(typeof m=="function")try{m()}catch(E){cr(o,l,E)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(E){cr(o,l,E)}else d.current=null}function qd(o){var l=o.type,d=o.memoizedProps,m=o.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":d.autoFocus&&m.focus();break e;case"img":d.src?m.src=d.src:d.srcSet&&(m.srcset=d.srcSet)}}catch(E){cr(o,o.return,E)}}function Su(o,l,d){try{var m=o.stateNode;ip(m,o.type,d,l),m[fr]=l}catch(E){cr(o,o.return,E)}}function zd(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&ps(o.type)||o.tag===4}function Eu(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||zd(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&ps(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Tu(o,l,d){var m=o.tag;if(m===5||m===6)o=o.stateNode,l?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(o,l):(l=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,l.appendChild(o),d=d._reactRootContainer,d!=null||l.onclick!==null||(l.onclick=wt));else if(m!==4&&(m===27&&ps(o.type)&&(d=o.stateNode,l=null),o=o.child,o!==null))for(Tu(o,l,d),o=o.sibling;o!==null;)Tu(o,l,d),o=o.sibling}function Wa(o,l,d){var m=o.tag;if(m===5||m===6)o=o.stateNode,l?d.insertBefore(o,l):d.appendChild(o);else if(m!==4&&(m===27&&ps(o.type)&&(d=o.stateNode),o=o.child,o!==null))for(Wa(o,l,d),o=o.sibling;o!==null;)Wa(o,l,d),o=o.sibling}function Vd(o){var l=o.stateNode,d=o.memoizedProps;try{for(var m=o.type,E=l.attributes;E.length;)l.removeAttributeNode(E[0]);fn(l,m,d),l[qt]=o,l[fr]=d}catch(C){cr(o,o.return,C)}}var ki=!1,Zr=!1,Ru=!1,Hd=typeof WeakSet=="function"?WeakSet:Set,nn=null;function Oh(o,l){if(o=o.containerInfo,Wu=hl,o=Es(o),Ji(o)){if("selectionStart"in o)var d={start:o.selectionStart,end:o.selectionEnd};else e:{d=(d=o.ownerDocument)&&d.defaultView||window;var m=d.getSelection&&d.getSelection();if(m&&m.rangeCount!==0){d=m.anchorNode;var E=m.anchorOffset,C=m.focusNode;m=m.focusOffset;try{d.nodeType,C.nodeType}catch{d=null;break e}var W=0,le=-1,ke=-1,Ye=0,lt=0,dt=o,tt=null;t:for(;;){for(var it;dt!==d||E!==0&&dt.nodeType!==3||(le=W+E),dt!==C||m!==0&&dt.nodeType!==3||(ke=W+m),dt.nodeType===3&&(W+=dt.nodeValue.length),(it=dt.firstChild)!==null;)tt=dt,dt=it;for(;;){if(dt===o)break t;if(tt===d&&++Ye===E&&(le=W),tt===C&&++lt===m&&(ke=W),(it=dt.nextSibling)!==null)break;dt=tt,tt=dt.parentNode}dt=it}d=le===-1||ke===-1?null:{start:le,end:ke}}else d=null}d=d||{start:0,end:0}}else d=null;for(Ku={focusedElem:o,selectionRange:d},hl=!1,nn=l;nn!==null;)if(l=nn,o=l.child,(l.subtreeFlags&1028)!==0&&o!==null)o.return=l,nn=o;else for(;nn!==null;){switch(l=nn,C=l.alternate,o=l.flags,l.tag){case 0:if((o&4)!==0&&(o=l.updateQueue,o=o!==null?o.events:null,o!==null))for(d=0;d<o.length;d++)E=o[d],E.ref.impl=E.nextImpl;break;case 11:case 15:break;case 1:if((o&1024)!==0&&C!==null){o=void 0,d=l,E=C.memoizedProps,C=C.memoizedState,m=d.stateNode;try{var St=Ls(d.type,E);o=m.getSnapshotBeforeUpdate(St,C),m.__reactInternalSnapshotBeforeUpdate=o}catch(It){cr(d,d.return,It)}}break;case 3:if((o&1024)!==0){if(o=l.stateNode.containerInfo,d=o.nodeType,d===9)Qu(o);else if(d===1)switch(o.nodeName){case"HEAD":case"HTML":case"BODY":Qu(o);break;default:o.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((o&1024)!==0)throw Error(n(163))}if(o=l.sibling,o!==null){o.return=l.return,nn=o;break}nn=l.return}}function Wd(o,l,d){var m=d.flags;switch(d.tag){case 0:case 11:case 15:Ui(o,d),m&4&&Ho(5,d);break;case 1:if(Ui(o,d),m&4)if(o=d.stateNode,l===null)try{o.componentDidMount()}catch(W){cr(d,d.return,W)}else{var E=Ls(d.type,l.memoizedProps);l=l.memoizedState;try{o.componentDidUpdate(E,l,o.__reactInternalSnapshotBeforeUpdate)}catch(W){cr(d,d.return,W)}}m&64&&Bd(d),m&512&&Wo(d,d.return);break;case 3:if(Ui(o,d),m&64&&(o=d.updateQueue,o!==null)){if(l=null,d.child!==null)switch(d.child.tag){case 27:case 5:l=d.child.stateNode;break;case 1:l=d.child.stateNode}try{Cc(o,l)}catch(W){cr(d,d.return,W)}}break;case 27:l===null&&m&4&&Vd(d);case 26:case 5:Ui(o,d),l===null&&m&4&&qd(d),m&512&&Wo(d,d.return);break;case 12:Ui(o,d);break;case 31:Ui(o,d),m&4&&Jd(o,d);break;case 13:Ui(o,d),m&4&&Qd(o,d),m&64&&(o=d.memoizedState,o!==null&&(o=o.dehydrated,o!==null&&(d=Wh.bind(null,d),fp(o,d))));break;case 22:if(m=d.memoizedState!==null||ki,!m){l=l!==null&&l.memoizedState!==null||Zr,E=ki;var C=Zr;ki=m,(Zr=l)&&!C?Oi(o,d,(d.subtreeFlags&8772)!==0):Ui(o,d),ki=E,Zr=C}break;case 30:break;default:Ui(o,d)}}function Kd(o){var l=o.alternate;l!==null&&(o.alternate=null,Kd(l)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(l=o.stateNode,l!==null&&br(l)),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}var Fr=null,xn=!1;function Li(o,l,d){for(d=d.child;d!==null;)Gd(o,l,d),d=d.sibling}function Gd(o,l,d){if(gt&&typeof gt.onCommitFiberUnmount=="function")try{gt.onCommitFiberUnmount(Pe,d)}catch{}switch(d.tag){case 26:Zr||yi(d,l),Li(o,l,d),d.memoizedState?d.memoizedState.count--:d.stateNode&&(d=d.stateNode,d.parentNode.removeChild(d));break;case 27:Zr||yi(d,l);var m=Fr,E=xn;ps(d.type)&&(Fr=d.stateNode,xn=!1),Li(o,l,d),ta(d.stateNode),Fr=m,xn=E;break;case 5:Zr||yi(d,l);case 6:if(m=Fr,E=xn,Fr=null,Li(o,l,d),Fr=m,xn=E,Fr!==null)if(xn)try{(Fr.nodeType===9?Fr.body:Fr.nodeName==="HTML"?Fr.ownerDocument.body:Fr).removeChild(d.stateNode)}catch(C){cr(d,l,C)}else try{Fr.removeChild(d.stateNode)}catch(C){cr(d,l,C)}break;case 18:Fr!==null&&(xn?(o=Fr,Mf(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,d.stateNode),_o(o)):Mf(Fr,d.stateNode));break;case 4:m=Fr,E=xn,Fr=d.stateNode.containerInfo,xn=!0,Li(o,l,d),Fr=m,xn=E;break;case 0:case 11:case 14:case 15:as(2,d,l),Zr||as(4,d,l),Li(o,l,d);break;case 1:Zr||(yi(d,l),m=d.stateNode,typeof m.componentWillUnmount=="function"&&Md(d,l,m)),Li(o,l,d);break;case 21:Li(o,l,d);break;case 22:Zr=(m=Zr)||d.memoizedState!==null,Li(o,l,d),Zr=m;break;default:Li(o,l,d)}}function Jd(o,l){if(l.memoizedState===null&&(o=l.alternate,o!==null&&(o=o.memoizedState,o!==null))){o=o.dehydrated;try{_o(o)}catch(d){cr(l,l.return,d)}}}function Qd(o,l){if(l.memoizedState===null&&(o=l.alternate,o!==null&&(o=o.memoizedState,o!==null&&(o=o.dehydrated,o!==null))))try{_o(o)}catch(d){cr(l,l.return,d)}}function $h(o){switch(o.tag){case 31:case 13:case 19:var l=o.stateNode;return l===null&&(l=o.stateNode=new Hd),l;case 22:return o=o.stateNode,l=o._retryCache,l===null&&(l=o._retryCache=new Hd),l;default:throw Error(n(435,o.tag))}}function Ka(o,l){var d=$h(o);l.forEach(function(m){if(!d.has(m)){d.add(m);var E=Kh.bind(null,o,m);m.then(E,E)}})}function An(o,l){var d=l.deletions;if(d!==null)for(var m=0;m<d.length;m++){var E=d[m],C=o,W=l,le=W;e:for(;le!==null;){switch(le.tag){case 27:if(ps(le.type)){Fr=le.stateNode,xn=!1;break e}break;case 5:Fr=le.stateNode,xn=!1;break e;case 3:case 4:Fr=le.stateNode.containerInfo,xn=!0;break e}le=le.return}if(Fr===null)throw Error(n(160));Gd(C,W,E),Fr=null,xn=!1,C=E.alternate,C!==null&&(C.return=null),E.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)Zd(l,o),l=l.sibling}var di=null;function Zd(o,l){var d=o.alternate,m=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:An(l,o),In(o),m&4&&(as(3,o,o.return),Ho(3,o),as(5,o,o.return));break;case 1:An(l,o),In(o),m&512&&(Zr||d===null||yi(d,d.return)),m&64&&ki&&(o=o.updateQueue,o!==null&&(m=o.callbacks,m!==null&&(d=o.shared.hiddenCallbacks,o.shared.hiddenCallbacks=d===null?m:d.concat(m))));break;case 26:var E=di;if(An(l,o),In(o),m&512&&(Zr||d===null||yi(d,d.return)),m&4){var C=d!==null?d.memoizedState:null;if(m=o.memoizedState,d===null)if(m===null)if(o.stateNode===null){e:{m=o.type,d=o.memoizedProps,E=E.ownerDocument||E;t:switch(m){case"title":C=E.getElementsByTagName("title")[0],(!C||C[oi]||C[qt]||C.namespaceURI==="http://www.w3.org/2000/svg"||C.hasAttribute("itemprop"))&&(C=E.createElement(m),E.head.insertBefore(C,E.querySelector("head > title"))),fn(C,m,d),C[qt]=o,Er(C),m=C;break e;case"link":var W=Xf("link","href",E).get(m+(d.href||""));if(W){for(var le=0;le<W.length;le++)if(C=W[le],C.getAttribute("href")===(d.href==null||d.href===""?null:d.href)&&C.getAttribute("rel")===(d.rel==null?null:d.rel)&&C.getAttribute("title")===(d.title==null?null:d.title)&&C.getAttribute("crossorigin")===(d.crossOrigin==null?null:d.crossOrigin)){W.splice(le,1);break t}}C=E.createElement(m),fn(C,m,d),E.head.appendChild(C);break;case"meta":if(W=Xf("meta","content",E).get(m+(d.content||""))){for(le=0;le<W.length;le++)if(C=W[le],C.getAttribute("content")===(d.content==null?null:""+d.content)&&C.getAttribute("name")===(d.name==null?null:d.name)&&C.getAttribute("property")===(d.property==null?null:d.property)&&C.getAttribute("http-equiv")===(d.httpEquiv==null?null:d.httpEquiv)&&C.getAttribute("charset")===(d.charSet==null?null:d.charSet)){W.splice(le,1);break t}}C=E.createElement(m),fn(C,m,d),E.head.appendChild(C);break;default:throw Error(n(468,m))}C[qt]=o,Er(C),m=C}o.stateNode=m}else Yf(E,o.type,o.stateNode);else o.stateNode=Zf(E,m,o.memoizedProps);else C!==m?(C===null?d.stateNode!==null&&(d=d.stateNode,d.parentNode.removeChild(d)):C.count--,m===null?Yf(E,o.type,o.stateNode):Zf(E,m,o.memoizedProps)):m===null&&o.stateNode!==null&&Su(o,o.memoizedProps,d.memoizedProps)}break;case 27:An(l,o),In(o),m&512&&(Zr||d===null||yi(d,d.return)),d!==null&&m&4&&Su(o,o.memoizedProps,d.memoizedProps);break;case 5:if(An(l,o),In(o),m&512&&(Zr||d===null||yi(d,d.return)),o.flags&32){E=o.stateNode;try{Ae(E,"")}catch(St){cr(o,o.return,St)}}m&4&&o.stateNode!=null&&(E=o.memoizedProps,Su(o,E,d!==null?d.memoizedProps:E)),m&1024&&(Ru=!0);break;case 6:if(An(l,o),In(o),m&4){if(o.stateNode===null)throw Error(n(162));m=o.memoizedProps,d=o.stateNode;try{d.nodeValue=m}catch(St){cr(o,o.return,St)}}break;case 3:if(ul=null,E=di,di=al(l.containerInfo),An(l,o),di=E,In(o),m&4&&d!==null&&d.memoizedState.isDehydrated)try{_o(l.containerInfo)}catch(St){cr(o,o.return,St)}Ru&&(Ru=!1,Xd(o));break;case 4:m=di,di=al(o.stateNode.containerInfo),An(l,o),In(o),di=m;break;case 12:An(l,o),In(o);break;case 31:An(l,o),In(o),m&4&&(m=o.updateQueue,m!==null&&(o.updateQueue=null,Ka(o,m)));break;case 13:An(l,o),In(o),o.child.flags&8192&&o.memoizedState!==null!=(d!==null&&d.memoizedState!==null)&&(Ja=ft()),m&4&&(m=o.updateQueue,m!==null&&(o.updateQueue=null,Ka(o,m)));break;case 22:E=o.memoizedState!==null;var ke=d!==null&&d.memoizedState!==null,Ye=ki,lt=Zr;if(ki=Ye||E,Zr=lt||ke,An(l,o),Zr=lt,ki=Ye,In(o),m&8192)e:for(l=o.stateNode,l._visibility=E?l._visibility&-2:l._visibility|1,E&&(d===null||ke||ki||Zr||Us(o)),d=null,l=o;;){if(l.tag===5||l.tag===26){if(d===null){ke=d=l;try{if(C=ke.stateNode,E)W=C.style,typeof W.setProperty=="function"?W.setProperty("display","none","important"):W.display="none";else{le=ke.stateNode;var dt=ke.memoizedProps.style,tt=dt!=null&&dt.hasOwnProperty("display")?dt.display:null;le.style.display=tt==null||typeof tt=="boolean"?"":(""+tt).trim()}}catch(St){cr(ke,ke.return,St)}}}else if(l.tag===6){if(d===null){ke=l;try{ke.stateNode.nodeValue=E?"":ke.memoizedProps}catch(St){cr(ke,ke.return,St)}}}else if(l.tag===18){if(d===null){ke=l;try{var it=ke.stateNode;E?qf(it,!0):qf(ke.stateNode,!1)}catch(St){cr(ke,ke.return,St)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===o)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===o)break e;for(;l.sibling===null;){if(l.return===null||l.return===o)break e;d===l&&(d=null),l=l.return}d===l&&(d=null),l.sibling.return=l.return,l=l.sibling}m&4&&(m=o.updateQueue,m!==null&&(d=m.retryQueue,d!==null&&(m.retryQueue=null,Ka(o,d))));break;case 19:An(l,o),In(o),m&4&&(m=o.updateQueue,m!==null&&(o.updateQueue=null,Ka(o,m)));break;case 30:break;case 21:break;default:An(l,o),In(o)}}function In(o){var l=o.flags;if(l&2){try{for(var d,m=o.return;m!==null;){if(zd(m)){d=m;break}m=m.return}if(d==null)throw Error(n(160));switch(d.tag){case 27:var E=d.stateNode,C=Eu(o);Wa(o,C,E);break;case 5:var W=d.stateNode;d.flags&32&&(Ae(W,""),d.flags&=-33);var le=Eu(o);Wa(o,le,W);break;case 3:case 4:var ke=d.stateNode.containerInfo,Ye=Eu(o);Tu(o,Ye,ke);break;default:throw Error(n(161))}}catch(lt){cr(o,o.return,lt)}o.flags&=-3}l&4096&&(o.flags&=-4097)}function Xd(o){if(o.subtreeFlags&1024)for(o=o.child;o!==null;){var l=o;Xd(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),o=o.sibling}}function Ui(o,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)Wd(o,l.alternate,l),l=l.sibling}function Us(o){for(o=o.child;o!==null;){var l=o;switch(l.tag){case 0:case 11:case 14:case 15:as(4,l,l.return),Us(l);break;case 1:yi(l,l.return);var d=l.stateNode;typeof d.componentWillUnmount=="function"&&Md(l,l.return,d),Us(l);break;case 27:ta(l.stateNode);case 26:case 5:yi(l,l.return),Us(l);break;case 22:l.memoizedState===null&&Us(l);break;case 30:Us(l);break;default:Us(l)}o=o.sibling}}function Oi(o,l,d){for(d=d&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var m=l.alternate,E=o,C=l,W=C.flags;switch(C.tag){case 0:case 11:case 15:Oi(E,C,d),Ho(4,C);break;case 1:if(Oi(E,C,d),m=C,E=m.stateNode,typeof E.componentDidMount=="function")try{E.componentDidMount()}catch(Ye){cr(m,m.return,Ye)}if(m=C,E=m.updateQueue,E!==null){var le=m.stateNode;try{var ke=E.shared.hiddenCallbacks;if(ke!==null)for(E.shared.hiddenCallbacks=null,E=0;E<ke.length;E++)Ic(ke[E],le)}catch(Ye){cr(m,m.return,Ye)}}d&&W&64&&Bd(C),Wo(C,C.return);break;case 27:Vd(C);case 26:case 5:Oi(E,C,d),d&&m===null&&W&4&&qd(C),Wo(C,C.return);break;case 12:Oi(E,C,d);break;case 31:Oi(E,C,d),d&&W&4&&Jd(E,C);break;case 13:Oi(E,C,d),d&&W&4&&Qd(E,C);break;case 22:C.memoizedState===null&&Oi(E,C,d),Wo(C,C.return);break;case 30:break;default:Oi(E,C,d)}l=l.sibling}}function xu(o,l){var d=null;o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(d=o.memoizedState.cachePool.pool),o=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(o=l.memoizedState.cachePool.pool),o!==d&&(o!=null&&o.refCount++,d!=null&&Do(d))}function Au(o,l){o=null,l.alternate!==null&&(o=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==o&&(l.refCount++,o!=null&&Do(o))}function fi(o,l,d,m){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)Yd(o,l,d,m),l=l.sibling}function Yd(o,l,d,m){var E=l.flags;switch(l.tag){case 0:case 11:case 15:fi(o,l,d,m),E&2048&&Ho(9,l);break;case 1:fi(o,l,d,m);break;case 3:fi(o,l,d,m),E&2048&&(o=null,l.alternate!==null&&(o=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==o&&(l.refCount++,o!=null&&Do(o)));break;case 12:if(E&2048){fi(o,l,d,m),o=l.stateNode;try{var C=l.memoizedProps,W=C.id,le=C.onPostCommit;typeof le=="function"&&le(W,l.alternate===null?"mount":"update",o.passiveEffectDuration,-0)}catch(ke){cr(l,l.return,ke)}}else fi(o,l,d,m);break;case 31:fi(o,l,d,m);break;case 13:fi(o,l,d,m);break;case 23:break;case 22:C=l.stateNode,W=l.alternate,l.memoizedState!==null?C._visibility&2?fi(o,l,d,m):Ko(o,l):C._visibility&2?fi(o,l,d,m):(C._visibility|=2,ao(o,l,d,m,(l.subtreeFlags&10256)!==0||!1)),E&2048&&xu(W,l);break;case 24:fi(o,l,d,m),E&2048&&Au(l.alternate,l);break;default:fi(o,l,d,m)}}function ao(o,l,d,m,E){for(E=E&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var C=o,W=l,le=d,ke=m,Ye=W.flags;switch(W.tag){case 0:case 11:case 15:ao(C,W,le,ke,E),Ho(8,W);break;case 23:break;case 22:var lt=W.stateNode;W.memoizedState!==null?lt._visibility&2?ao(C,W,le,ke,E):Ko(C,W):(lt._visibility|=2,ao(C,W,le,ke,E)),E&&Ye&2048&&xu(W.alternate,W);break;case 24:ao(C,W,le,ke,E),E&&Ye&2048&&Au(W.alternate,W);break;default:ao(C,W,le,ke,E)}l=l.sibling}}function Ko(o,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var d=o,m=l,E=m.flags;switch(m.tag){case 22:Ko(d,m),E&2048&&xu(m.alternate,m);break;case 24:Ko(d,m),E&2048&&Au(m.alternate,m);break;default:Ko(d,m)}l=l.sibling}}var Go=8192;function lo(o,l,d){if(o.subtreeFlags&Go)for(o=o.child;o!==null;)ef(o,l,d),o=o.sibling}function ef(o,l,d){switch(o.tag){case 26:lo(o,l,d),o.flags&Go&&o.memoizedState!==null&&Tp(d,di,o.memoizedState,o.memoizedProps);break;case 5:lo(o,l,d);break;case 3:case 4:var m=di;di=al(o.stateNode.containerInfo),lo(o,l,d),di=m;break;case 22:o.memoizedState===null&&(m=o.alternate,m!==null&&m.memoizedState!==null?(m=Go,Go=16777216,lo(o,l,d),Go=m):lo(o,l,d));break;default:lo(o,l,d)}}function tf(o){var l=o.alternate;if(l!==null&&(o=l.child,o!==null)){l.child=null;do l=o.sibling,o.sibling=null,o=l;while(o!==null)}}function Jo(o){var l=o.deletions;if((o.flags&16)!==0){if(l!==null)for(var d=0;d<l.length;d++){var m=l[d];nn=m,nf(m,o)}tf(o)}if(o.subtreeFlags&10256)for(o=o.child;o!==null;)rf(o),o=o.sibling}function rf(o){switch(o.tag){case 0:case 11:case 15:Jo(o),o.flags&2048&&as(9,o,o.return);break;case 3:Jo(o);break;case 12:Jo(o);break;case 22:var l=o.stateNode;o.memoizedState!==null&&l._visibility&2&&(o.return===null||o.return.tag!==13)?(l._visibility&=-3,Ga(o)):Jo(o);break;default:Jo(o)}}function Ga(o){var l=o.deletions;if((o.flags&16)!==0){if(l!==null)for(var d=0;d<l.length;d++){var m=l[d];nn=m,nf(m,o)}tf(o)}for(o=o.child;o!==null;){switch(l=o,l.tag){case 0:case 11:case 15:as(8,l,l.return),Ga(l);break;case 22:d=l.stateNode,d._visibility&2&&(d._visibility&=-3,Ga(l));break;default:Ga(l)}o=o.sibling}}function nf(o,l){for(;nn!==null;){var d=nn;switch(d.tag){case 0:case 11:case 15:as(8,d,l);break;case 23:case 22:if(d.memoizedState!==null&&d.memoizedState.cachePool!==null){var m=d.memoizedState.cachePool.pool;m!=null&&m.refCount++}break;case 24:Do(d.memoizedState.cache)}if(m=d.child,m!==null)m.return=d,nn=m;else e:for(d=o;nn!==null;){m=nn;var E=m.sibling,C=m.return;if(Kd(m),m===d){nn=null;break e}if(E!==null){E.return=C,nn=E;break e}nn=C}}}var jh={getCacheForType:function(o){var l=un(Gr),d=l.data.get(o);return d===void 0&&(d=o(),l.data.set(o,d)),d},cacheSignal:function(){return un(Gr).controller.signal}},Bh=typeof WeakMap=="function"?WeakMap:Map,rr=0,_r=null,zt=null,Wt=0,ur=0,$n=null,ls=!1,uo=!1,Iu=!1,$i=0,Br=0,us=0,Os=0,Cu=0,jn=0,co=0,Qo=null,Cn=null,Nu=!1,Ja=0,sf=0,Qa=1/0,Za=null,cs=null,en=0,ds=null,fo=null,ji=0,Fu=0,Du=null,of=null,Zo=0,Pu=null;function Bn(){return(rr&2)!==0&&Wt!==0?Wt&-Wt:ye.T!==null?ju():sr()}function af(){if(jn===0)if((Wt&536870912)===0||Gt){var o=Dt;Dt<<=1,(Dt&3932160)===0&&(Dt=262144),jn=o}else jn=536870912;return o=Un.current,o!==null&&(o.flags|=32),jn}function Nn(o,l,d){(o===_r&&(ur===2||ur===9)||o.cancelPendingCommit!==null)&&(ho(o,0),fs(o,Wt,jn,!1)),Be(o,d),((rr&2)===0||o!==_r)&&(o===_r&&((rr&2)===0&&(Os|=d),Br===4&&fs(o,Wt,jn,!1)),bi(o))}function lf(o,l,d){if((rr&6)!==0)throw Error(n(327));var m=!d&&(l&127)===0&&(l&o.expiredLanes)===0||nr(o,l),E=m?zh(o,l):Lu(o,l,!0),C=m;do{if(E===0){uo&&!m&&fs(o,l,0,!1);break}else{if(d=o.current.alternate,C&&!Mh(d)){E=Lu(o,l,!1),C=!1;continue}if(E===2){if(C=l,o.errorRecoveryDisabledLanes&C)var W=0;else W=o.pendingLanes&-536870913,W=W!==0?W:W&536870912?536870912:0;if(W!==0){l=W;e:{var le=o;E=Qo;var ke=le.current.memoizedState.isDehydrated;if(ke&&(ho(le,W).flags|=256),W=Lu(le,W,!1),W!==2){if(Iu&&!ke){le.errorRecoveryDisabledLanes|=C,Os|=C,E=4;break e}C=Cn,Cn=E,C!==null&&(Cn===null?Cn=C:Cn.push.apply(Cn,C))}E=W}if(C=!1,E!==2)continue}}if(E===1){ho(o,0),fs(o,l,0,!0);break}e:{switch(m=o,C=E,C){case 0:case 1:throw Error(n(345));case 4:if((l&4194048)!==l)break;case 6:fs(m,l,jn,!ls);break e;case 2:Cn=null;break;case 3:case 5:break;default:throw Error(n(329))}if((l&62914560)===l&&(E=Ja+300-ft(),10<E)){if(fs(m,l,jn,!ls),dr(m,0,!0)!==0)break e;ji=l,m.timeoutHandle=jf(uf.bind(null,m,d,Cn,Za,Nu,l,jn,Os,co,ls,C,"Throttled",-0,0),E);break e}uf(m,d,Cn,Za,Nu,l,jn,Os,co,ls,C,null,-0,0)}}break}while(!0);bi(o)}function uf(o,l,d,m,E,C,W,le,ke,Ye,lt,dt,tt,it){if(o.timeoutHandle=-1,dt=l.subtreeFlags,dt&8192||(dt&16785408)===16785408){dt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:wt},ef(l,C,dt);var St=(C&62914560)===C?Ja-ft():(C&4194048)===C?sf-ft():0;if(St=Rp(dt,St),St!==null){ji=C,o.cancelPendingCommit=St(yf.bind(null,o,l,C,d,m,E,W,le,ke,lt,dt,null,tt,it)),fs(o,C,W,!Ye);return}}yf(o,l,C,d,m,E,W,le,ke)}function Mh(o){for(var l=o;;){var d=l.tag;if((d===0||d===11||d===15)&&l.flags&16384&&(d=l.updateQueue,d!==null&&(d=d.stores,d!==null)))for(var m=0;m<d.length;m++){var E=d[m],C=E.getSnapshot;E=E.value;try{if(!vt(C(),E))return!1}catch{return!1}}if(d=l.child,l.subtreeFlags&16384&&d!==null)d.return=l,l=d;else{if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function fs(o,l,d,m){l&=~Cu,l&=~Os,o.suspendedLanes|=l,o.pingedLanes&=~l,m&&(o.warmLanes|=l),m=o.expirationTimes;for(var E=l;0<E;){var C=31-Tt(E),W=1<<C;m[C]=-1,E&=~W}d!==0&&at(o,d,l)}function Xa(){return(rr&6)===0?(Xo(0),!1):!0}function ku(){if(zt!==null){if(ur===0)var o=zt.return;else o=zt,Ii=Is=null,Ql(o),ro=null,ko=0,o=zt;for(;o!==null;)jd(o.alternate,o),o=o.return;zt=null}}function ho(o,l){var d=o.timeoutHandle;d!==-1&&(o.timeoutHandle=-1,ap(d)),d=o.cancelPendingCommit,d!==null&&(o.cancelPendingCommit=null,d()),ji=0,ku(),_r=o,zt=d=xi(o.current,null),Wt=l,ur=0,$n=null,ls=!1,uo=nr(o,l),Iu=!1,co=jn=Cu=Os=us=Br=0,Cn=Qo=null,Nu=!1,(l&8)!==0&&(l|=l&32);var m=o.entangledLanes;if(m!==0)for(o=o.entanglements,m&=l;0<m;){var E=31-Tt(m),C=1<<E;l|=o[E],m&=~C}return $i=l,ba(),d}function cf(o,l){$t=null,ye.H=qo,l===to||l===Aa?(l=Tc(),ur=3):l===$l?(l=Tc(),ur=4):ur=l===fu?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,$n=l,zt===null&&(Br=1,Ma(o,Xn(l,o.current)))}function df(){var o=Un.current;return o===null?!0:(Wt&4194048)===Wt?ri===null:(Wt&62914560)===Wt||(Wt&536870912)!==0?o===ri:!1}function ff(){var o=ye.H;return ye.H=qo,o===null?qo:o}function hf(){var o=ye.A;return ye.A=jh,o}function Ya(){Br=4,ls||(Wt&4194048)!==Wt&&Un.current!==null||(uo=!0),(us&134217727)===0&&(Os&134217727)===0||_r===null||fs(_r,Wt,jn,!1)}function Lu(o,l,d){var m=rr;rr|=2;var E=ff(),C=hf();(_r!==o||Wt!==l)&&(Za=null,ho(o,l)),l=!1;var W=Br;e:do try{if(ur!==0&&zt!==null){var le=zt,ke=$n;switch(ur){case 8:ku(),W=6;break e;case 3:case 2:case 9:case 6:Un.current===null&&(l=!0);var Ye=ur;if(ur=0,$n=null,po(o,le,ke,Ye),d&&uo){W=0;break e}break;default:Ye=ur,ur=0,$n=null,po(o,le,ke,Ye)}}qh(),W=Br;break}catch(lt){cf(o,lt)}while(!0);return l&&o.shellSuspendCounter++,Ii=Is=null,rr=m,ye.H=E,ye.A=C,zt===null&&(_r=null,Wt=0,ba()),W}function qh(){for(;zt!==null;)pf(zt)}function zh(o,l){var d=rr;rr|=2;var m=ff(),E=hf();_r!==o||Wt!==l?(Za=null,Qa=ft()+500,ho(o,l)):uo=nr(o,l);e:do try{if(ur!==0&&zt!==null){l=zt;var C=$n;t:switch(ur){case 1:ur=0,$n=null,po(o,l,C,1);break;case 2:case 9:if(Sc(C)){ur=0,$n=null,gf(l);break}l=function(){ur!==2&&ur!==9||_r!==o||(ur=7),bi(o)},C.then(l,l);break e;case 3:ur=7;break e;case 4:ur=5;break e;case 7:Sc(C)?(ur=0,$n=null,gf(l)):(ur=0,$n=null,po(o,l,C,7));break;case 5:var W=null;switch(zt.tag){case 26:W=zt.memoizedState;case 5:case 27:var le=zt;if(W?eh(W):le.stateNode.complete){ur=0,$n=null;var ke=le.sibling;if(ke!==null)zt=ke;else{var Ye=le.return;Ye!==null?(zt=Ye,el(Ye)):zt=null}break t}}ur=0,$n=null,po(o,l,C,5);break;case 6:ur=0,$n=null,po(o,l,C,6);break;case 8:ku(),Br=6;break e;default:throw Error(n(462))}}Vh();break}catch(lt){cf(o,lt)}while(!0);return Ii=Is=null,ye.H=m,ye.A=E,rr=d,zt!==null?0:(_r=null,Wt=0,ba(),Br)}function Vh(){for(;zt!==null&&!de();)pf(zt)}function pf(o){var l=Od(o.alternate,o,$i);o.memoizedProps=o.pendingProps,l===null?el(o):zt=l}function gf(o){var l=o,d=l.alternate;switch(l.tag){case 15:case 0:l=Fd(d,l,l.pendingProps,l.type,void 0,Wt);break;case 11:l=Fd(d,l,l.pendingProps,l.type.render,l.ref,Wt);break;case 5:Ql(l);default:jd(d,l),l=zt=dc(l,$i),l=Od(d,l,$i)}o.memoizedProps=o.pendingProps,l===null?el(o):zt=l}function po(o,l,d,m){Ii=Is=null,Ql(l),ro=null,ko=0;var E=l.return;try{if(Dh(o,E,l,d,Wt)){Br=1,Ma(o,Xn(d,o.current)),zt=null;return}}catch(C){if(E!==null)throw zt=E,C;Br=1,Ma(o,Xn(d,o.current)),zt=null;return}l.flags&32768?(Gt||m===1?o=!0:uo||(Wt&536870912)!==0?o=!1:(ls=o=!0,(m===2||m===9||m===3||m===6)&&(m=Un.current,m!==null&&m.tag===13&&(m.flags|=16384))),mf(l,o)):el(l)}function el(o){var l=o;do{if((l.flags&32768)!==0){mf(l,ls);return}o=l.return;var d=Lh(l.alternate,l,$i);if(d!==null){zt=d;return}if(l=l.sibling,l!==null){zt=l;return}zt=l=o}while(l!==null);Br===0&&(Br=5)}function mf(o,l){do{var d=Uh(o.alternate,o);if(d!==null){d.flags&=32767,zt=d;return}if(d=o.return,d!==null&&(d.flags|=32768,d.subtreeFlags=0,d.deletions=null),!l&&(o=o.sibling,o!==null)){zt=o;return}zt=o=d}while(o!==null);Br=6,zt=null}function yf(o,l,d,m,E,C,W,le,ke){o.cancelPendingCommit=null;do tl();while(en!==0);if((rr&6)!==0)throw Error(n(327));if(l!==null){if(l===o.current)throw Error(n(177));if(C=l.lanes|l.childLanes,C|=El,qe(o,d,C,W,le,ke),o===_r&&(zt=_r=null,Wt=0),fo=l,ds=o,ji=d,Fu=C,Du=E,of=m,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(o.callbackNode=null,o.callbackPriority=0,Gh(P,function(){return Sf(),null})):(o.callbackNode=null,o.callbackPriority=0),m=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||m){m=ye.T,ye.T=null,E=Ve.p,Ve.p=2,W=rr,rr|=4;try{Oh(o,l,d)}finally{rr=W,Ve.p=E,ye.T=m}}en=1,bf(),_f(),wf()}}function bf(){if(en===1){en=0;var o=ds,l=fo,d=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||d){d=ye.T,ye.T=null;var m=Ve.p;Ve.p=2;var E=rr;rr|=4;try{Zd(l,o);var C=Ku,W=Es(o.containerInfo),le=C.focusedElem,ke=C.selectionRange;if(W!==le&&le&&le.ownerDocument&&ui(le.ownerDocument.documentElement,le)){if(ke!==null&&Ji(le)){var Ye=ke.start,lt=ke.end;if(lt===void 0&&(lt=Ye),"selectionStart"in le)le.selectionStart=Ye,le.selectionEnd=Math.min(lt,le.value.length);else{var dt=le.ownerDocument||document,tt=dt&&dt.defaultView||window;if(tt.getSelection){var it=tt.getSelection(),St=le.textContent.length,It=Math.min(ke.start,St),yr=ke.end===void 0?It:Math.min(ke.end,St);!it.extend&&It>yr&&(W=yr,yr=It,It=W);var Ke=ue(le,It),je=ue(le,yr);if(Ke&&je&&(it.rangeCount!==1||it.anchorNode!==Ke.node||it.anchorOffset!==Ke.offset||it.focusNode!==je.node||it.focusOffset!==je.offset)){var Ze=dt.createRange();Ze.setStart(Ke.node,Ke.offset),it.removeAllRanges(),It>yr?(it.addRange(Ze),it.extend(je.node,je.offset)):(Ze.setEnd(je.node,je.offset),it.addRange(Ze))}}}}for(dt=[],it=le;it=it.parentNode;)it.nodeType===1&&dt.push({element:it,left:it.scrollLeft,top:it.scrollTop});for(typeof le.focus=="function"&&le.focus(),le=0;le<dt.length;le++){var ct=dt[le];ct.element.scrollLeft=ct.left,ct.element.scrollTop=ct.top}}hl=!!Wu,Ku=Wu=null}finally{rr=E,Ve.p=m,ye.T=d}}o.current=l,en=2}}function _f(){if(en===2){en=0;var o=ds,l=fo,d=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||d){d=ye.T,ye.T=null;var m=Ve.p;Ve.p=2;var E=rr;rr|=4;try{Wd(o,l.alternate,l)}finally{rr=E,Ve.p=m,ye.T=d}}en=3}}function wf(){if(en===4||en===3){en=0,st();var o=ds,l=fo,d=ji,m=of;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?en=5:(en=0,fo=ds=null,vf(o,o.pendingLanes));var E=o.pendingLanes;if(E===0&&(cs=null),Sr(d),l=l.stateNode,gt&&typeof gt.onCommitFiberRoot=="function")try{gt.onCommitFiberRoot(Pe,l,void 0,(l.current.flags&128)===128)}catch{}if(m!==null){l=ye.T,E=Ve.p,Ve.p=2,ye.T=null;try{for(var C=o.onRecoverableError,W=0;W<m.length;W++){var le=m[W];C(le.value,{componentStack:le.stack})}}finally{ye.T=l,Ve.p=E}}(ji&3)!==0&&tl(),bi(o),E=o.pendingLanes,(d&261930)!==0&&(E&42)!==0?o===Pu?Zo++:(Zo=0,Pu=o):Zo=0,Xo(0)}}function vf(o,l){(o.pooledCacheLanes&=l)===0&&(l=o.pooledCache,l!=null&&(o.pooledCache=null,Do(l)))}function tl(){return bf(),_f(),wf(),Sf()}function Sf(){if(en!==5)return!1;var o=ds,l=Fu;Fu=0;var d=Sr(ji),m=ye.T,E=Ve.p;try{Ve.p=32>d?32:d,ye.T=null,d=Du,Du=null;var C=ds,W=ji;if(en=0,fo=ds=null,ji=0,(rr&6)!==0)throw Error(n(331));var le=rr;if(rr|=4,rf(C.current),Yd(C,C.current,W,d),rr=le,Xo(0,!1),gt&&typeof gt.onPostCommitFiberRoot=="function")try{gt.onPostCommitFiberRoot(Pe,C)}catch{}return!0}finally{Ve.p=E,ye.T=m,vf(o,l)}}function Ef(o,l,d){l=Xn(d,l),l=du(o.stateNode,l,2),o=rs(o,l,2),o!==null&&(Be(o,2),bi(o))}function cr(o,l,d){if(o.tag===3)Ef(o,o,d);else for(;l!==null;){if(l.tag===3){Ef(l,o,d);break}else if(l.tag===1){var m=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(cs===null||!cs.has(m))){o=Xn(d,o),d=Ed(2),m=rs(l,d,2),m!==null&&(Td(d,m,l,o),Be(m,2),bi(m));break}}l=l.return}}function Uu(o,l,d){var m=o.pingCache;if(m===null){m=o.pingCache=new Bh;var E=new Set;m.set(l,E)}else E=m.get(l),E===void 0&&(E=new Set,m.set(l,E));E.has(d)||(Iu=!0,E.add(d),o=Hh.bind(null,o,l,d),l.then(o,o))}function Hh(o,l,d){var m=o.pingCache;m!==null&&m.delete(l),o.pingedLanes|=o.suspendedLanes&d,o.warmLanes&=~d,_r===o&&(Wt&d)===d&&(Br===4||Br===3&&(Wt&62914560)===Wt&&300>ft()-Ja?(rr&2)===0&&ho(o,0):Cu|=d,co===Wt&&(co=0)),bi(o)}function Tf(o,l){l===0&&(l=M()),o=Rs(o,l),o!==null&&(Be(o,l),bi(o))}function Wh(o){var l=o.memoizedState,d=0;l!==null&&(d=l.retryLane),Tf(o,d)}function Kh(o,l){var d=0;switch(o.tag){case 31:case 13:var m=o.stateNode,E=o.memoizedState;E!==null&&(d=E.retryLane);break;case 19:m=o.stateNode;break;case 22:m=o.stateNode._retryCache;break;default:throw Error(n(314))}m!==null&&m.delete(l),Tf(o,d)}function Gh(o,l){return me(o,l)}var rl=null,go=null,Ou=!1,nl=!1,$u=!1,hs=0;function bi(o){o!==go&&o.next===null&&(go===null?rl=go=o:go=go.next=o),nl=!0,Ou||(Ou=!0,Qh())}function Xo(o,l){if(!$u&&nl){$u=!0;do for(var d=!1,m=rl;m!==null;){if(o!==0){var E=m.pendingLanes;if(E===0)var C=0;else{var W=m.suspendedLanes,le=m.pingedLanes;C=(1<<31-Tt(42|o)+1)-1,C&=E&~(W&~le),C=C&201326741?C&201326741|1:C?C|2:0}C!==0&&(d=!0,If(m,C))}else C=Wt,C=dr(m,m===_r?C:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(C&3)===0||nr(m,C)||(d=!0,If(m,C));m=m.next}while(d);$u=!1}}function Jh(){Rf()}function Rf(){nl=Ou=!1;var o=0;hs!==0&&op()&&(o=hs);for(var l=ft(),d=null,m=rl;m!==null;){var E=m.next,C=xf(m,l);C===0?(m.next=null,d===null?rl=E:d.next=E,E===null&&(go=d)):(d=m,(o!==0||(C&3)!==0)&&(nl=!0)),m=E}en!==0&&en!==5||Xo(o),hs!==0&&(hs=0)}function xf(o,l){for(var d=o.suspendedLanes,m=o.pingedLanes,E=o.expirationTimes,C=o.pendingLanes&-62914561;0<C;){var W=31-Tt(C),le=1<<W,ke=E[W];ke===-1?((le&d)===0||(le&m)!==0)&&(E[W]=Vr(le,l)):ke<=l&&(o.expiredLanes|=le),C&=~le}if(l=_r,d=Wt,d=dr(o,o===l?d:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),m=o.callbackNode,d===0||o===l&&(ur===2||ur===9)||o.cancelPendingCommit!==null)return m!==null&&m!==null&&xe(m),o.callbackNode=null,o.callbackPriority=0;if((d&3)===0||nr(o,d)){if(l=d&-d,l===o.callbackPriority)return l;switch(m!==null&&xe(m),Sr(d)){case 2:case 8:d=Z;break;case 32:d=P;break;case 268435456:d=U;break;default:d=P}return m=Af.bind(null,o),d=me(d,m),o.callbackPriority=l,o.callbackNode=d,l}return m!==null&&m!==null&&xe(m),o.callbackPriority=2,o.callbackNode=null,2}function Af(o,l){if(en!==0&&en!==5)return o.callbackNode=null,o.callbackPriority=0,null;var d=o.callbackNode;if(tl()&&o.callbackNode!==d)return null;var m=Wt;return m=dr(o,o===_r?m:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),m===0?null:(lf(o,m,l),xf(o,ft()),o.callbackNode!=null&&o.callbackNode===d?Af.bind(null,o):null)}function If(o,l){if(tl())return null;lf(o,l,!0)}function Qh(){lp(function(){(rr&6)!==0?me(pt,Jh):Rf()})}function ju(){if(hs===0){var o=Ys;o===0&&(o=Yt,Yt<<=1,(Yt&261888)===0&&(Yt=256)),hs=o}return hs}function Cf(o){return o==null||typeof o=="symbol"||typeof o=="boolean"?null:typeof o=="function"?o:yt(""+o)}function Nf(o,l){var d=l.ownerDocument.createElement("input");return d.name=l.name,d.value=l.value,o.id&&d.setAttribute("form",o.id),l.parentNode.insertBefore(d,l),o=new FormData(o),d.parentNode.removeChild(d),o}function Zh(o,l,d,m,E){if(l==="submit"&&d&&d.stateNode===E){var C=Cf((E[fr]||null).action),W=m.submitter;W&&(l=(l=W[fr]||null)?Cf(l.formAction):W.getAttribute("formAction"),l!==null&&(C=l,W=null));var le=new Mn("action","action",null,m,E);o.push({event:le,listeners:[{instance:null,listener:function(){if(m.defaultPrevented){if(hs!==0){var ke=W?Nf(E,W):new FormData(E);su(d,{pending:!0,data:ke,method:E.method,action:C},null,ke)}}else typeof C=="function"&&(le.preventDefault(),ke=W?Nf(E,W):new FormData(E),su(d,{pending:!0,data:ke,method:E.method,action:C},C,ke))},currentTarget:E}]})}}for(var Bu=0;Bu<Sl.length;Bu++){var Mu=Sl[Bu],Xh=Mu.toLowerCase(),Yh=Mu[0].toUpperCase()+Mu.slice(1);ci(Xh,"on"+Yh)}ci(Kr,"onAnimationEnd"),ci(Ts,"onAnimationIteration"),ci(Qn,"onAnimationStart"),ci("dblclick","onDoubleClick"),ci("focusin","onFocus"),ci("focusout","onBlur"),ci(ma,"onTransitionRun"),ci(Ws,"onTransitionStart"),ci(Co,"onTransitionCancel"),ci(Ri,"onTransitionEnd"),hn("onMouseEnter",["mouseout","mouseover"]),hn("onMouseLeave",["mouseout","mouseover"]),hn("onPointerEnter",["pointerout","pointerover"]),hn("onPointerLeave",["pointerout","pointerover"]),Sn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Sn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Sn("onBeforeInput",["compositionend","keypress","textInput","paste"]),Sn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Sn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Sn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Yo="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),ep=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Yo));function Ff(o,l){l=(l&4)!==0;for(var d=0;d<o.length;d++){var m=o[d],E=m.event;m=m.listeners;e:{var C=void 0;if(l)for(var W=m.length-1;0<=W;W--){var le=m[W],ke=le.instance,Ye=le.currentTarget;if(le=le.listener,ke!==C&&E.isPropagationStopped())break e;C=le,E.currentTarget=Ye;try{C(E)}catch(lt){ya(lt)}E.currentTarget=null,C=ke}else for(W=0;W<m.length;W++){if(le=m[W],ke=le.instance,Ye=le.currentTarget,le=le.listener,ke!==C&&E.isPropagationStopped())break e;C=le,E.currentTarget=Ye;try{C(E)}catch(lt){ya(lt)}E.currentTarget=null,C=ke}}}}function Vt(o,l){var d=l[Mr];d===void 0&&(d=l[Mr]=new Set);var m=o+"__bubble";d.has(m)||(Df(l,o,2,!1),d.add(m))}function qu(o,l,d){var m=0;l&&(m|=4),Df(d,o,m,l)}var il="_reactListening"+Math.random().toString(36).slice(2);function zu(o){if(!o[il]){o[il]=!0,_i.forEach(function(d){d!=="selectionchange"&&(ep.has(d)||qu(d,!1,o),qu(d,!0,o))});var l=o.nodeType===9?o:o.ownerDocument;l===null||l[il]||(l[il]=!0,qu("selectionchange",!1,l))}}function Df(o,l,d,m){switch(ah(l)){case 2:var E=Ip;break;case 8:E=Cp;break;default:E=ic}d=E.bind(null,l,d,o),E=void 0,!Or||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(E=!0),m?E!==void 0?o.addEventListener(l,d,{capture:!0,passive:E}):o.addEventListener(l,d,!0):E!==void 0?o.addEventListener(l,d,{passive:E}):o.addEventListener(l,d,!1)}function Vu(o,l,d,m,E){var C=m;if((l&1)===0&&(l&2)===0&&m!==null)e:for(;;){if(m===null)return;var W=m.tag;if(W===3||W===4){var le=m.stateNode.containerInfo;if(le===E)break;if(W===4)for(W=m.return;W!==null;){var ke=W.tag;if((ke===3||ke===4)&&W.stateNode.containerInfo===E)return;W=W.return}for(;le!==null;){if(W=or(le),W===null)return;if(ke=W.tag,ke===5||ke===6||ke===26||ke===27){m=C=W;continue e}le=le.parentNode}}m=m.return}ar(function(){var Ye=C,lt=Qt(d),dt=[];e:{var tt=uc.get(o);if(tt!==void 0){var it=Mn,St=o;switch(o){case"keypress":if(Fn(d)===0)break e;case"keydown":case"keyup":it=vs;break;case"focusin":St="focus",it=zn;break;case"focusout":St="blur",it=zn;break;case"beforeblur":case"afterblur":it=zn;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":it=lr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":it=hi;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":it=Vi;break;case Kr:case Ts:case Qn:it=Hn;break;case Ri:it=Si;break;case"scroll":case"scrollend":it=Mi;break;case"wheel":it=To;break;case"copy":case"cut":case"paste":it=wo;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":it=Wr;break;case"toggle":case"beforetoggle":it=wl}var It=(l&4)!==0,yr=!It&&(o==="scroll"||o==="scrollend"),Ke=It?tt!==null?tt+"Capture":null:tt;It=[];for(var je=Ye,Ze;je!==null;){var ct=je;if(Ze=ct.stateNode,ct=ct.tag,ct!==5&&ct!==26&&ct!==27||Ze===null||Ke===null||(ct=Xt(je,Ke),ct!=null&&It.push(ea(je,ct,Ze))),yr)break;je=je.return}0<It.length&&(tt=new it(tt,St,null,d,lt),dt.push({event:tt,listeners:It}))}}if((l&7)===0){e:{if(tt=o==="mouseover"||o==="pointerover",it=o==="mouseout"||o==="pointerout",tt&&d!==Jt&&(St=d.relatedTarget||d.fromElement)&&(or(St)||St[Dr]))break e;if((it||tt)&&(tt=lt.window===lt?lt:(tt=lt.ownerDocument)?tt.defaultView||tt.parentWindow:window,it?(St=d.relatedTarget||d.toElement,it=Ye,St=St?or(St):null,St!==null&&(yr=a(St),It=St.tag,St!==yr||It!==5&&It!==27&&It!==6)&&(St=null)):(it=null,St=Ye),it!==St)){if(It=lr,ct="onMouseLeave",Ke="onMouseEnter",je="mouse",(o==="pointerout"||o==="pointerover")&&(It=Wr,ct="onPointerLeave",Ke="onPointerEnter",je="pointer"),yr=it==null?tt:Pr(it),Ze=St==null?tt:Pr(St),tt=new It(ct,je+"leave",it,d,lt),tt.target=yr,tt.relatedTarget=Ze,ct=null,or(lt)===Ye&&(It=new It(Ke,je+"enter",St,d,lt),It.target=Ze,It.relatedTarget=yr,ct=It),yr=ct,it&&St)t:{for(It=tp,Ke=it,je=St,Ze=0,ct=Ke;ct;ct=It(ct))Ze++;ct=0;for(var At=je;At;At=It(At))ct++;for(;0<Ze-ct;)Ke=It(Ke),Ze--;for(;0<ct-Ze;)je=It(je),ct--;for(;Ze--;){if(Ke===je||je!==null&&Ke===je.alternate){It=Ke;break t}Ke=It(Ke),je=It(je)}It=null}else It=null;it!==null&&Pf(dt,tt,it,It,!1),St!==null&&yr!==null&&Pf(dt,yr,St,It,!0)}}e:{if(tt=Ye?Pr(Ye):window,it=tt.nodeName&&tt.nodeName.toLowerCase(),it==="select"||it==="input"&&tt.type==="file")var er=Gi;else if(Bs(tt))if(Io)er=mt;else{er=rt;var Et=ot}else it=tt.nodeName,!it||it.toLowerCase()!=="input"||tt.type!=="checkbox"&&tt.type!=="radio"?Ye&&bt(Ye.elementType)&&(er=Gi):er=ut;if(er&&(er=er(o,Ye))){ha(dt,er,d,lt);break e}Et&&Et(o,tt,Ye),o==="focusout"&&Ye&&tt.type==="number"&&Ye.memoizedProps.value!=null&&Xe(tt,"number",tt.value)}switch(Et=Ye?Pr(Ye):window,o){case"focusin":(Bs(Et)||Et.contentEditable==="true")&&(pr=Et,Rn=Ye,kn=null);break;case"focusout":kn=Rn=pr=null;break;case"mousedown":pi=!0;break;case"contextmenu":case"mouseup":case"dragend":pi=!1,Hs(dt,d,lt);break;case"selectionchange":if(Vs)break;case"keydown":case"keyup":Hs(dt,d,lt)}var jt;if(Pn)e:{switch(o){case"compositionstart":var Kt="onCompositionStart";break e;case"compositionend":Kt="onCompositionEnd";break e;case"compositionupdate":Kt="onCompositionUpdate";break e}Kt=void 0}else Wi?js(o,d)&&(Kt="onCompositionEnd"):o==="keydown"&&d.keyCode===229&&(Kt="onCompositionStart");Kt&&(ca&&d.locale!=="ko"&&(Wi||Kt!=="onCompositionStart"?Kt==="onCompositionEnd"&&Wi&&(jt=gn()):(tn=lt,pn="value"in tn?tn.value:tn.textContent,Wi=!0)),Et=sl(Ye,Kt),0<Et.length&&(Kt=new vo(Kt,o,null,d,lt),dt.push({event:Kt,listeners:Et}),jt?Kt.data=jt:(jt=xo(d),jt!==null&&(Kt.data=jt)))),(jt=ua?vl(o,d):Ao(o,d))&&(Kt=sl(Ye,"onBeforeInput"),0<Kt.length&&(Et=new vo("onBeforeInput","beforeinput",null,d,lt),dt.push({event:Et,listeners:Kt}),Et.data=jt)),Zh(dt,o,Ye,d,lt)}Ff(dt,l)})}function ea(o,l,d){return{instance:o,listener:l,currentTarget:d}}function sl(o,l){for(var d=l+"Capture",m=[];o!==null;){var E=o,C=E.stateNode;if(E=E.tag,E!==5&&E!==26&&E!==27||C===null||(E=Xt(o,d),E!=null&&m.unshift(ea(o,E,C)),E=Xt(o,l),E!=null&&m.push(ea(o,E,C))),o.tag===3)return m;o=o.return}return[]}function tp(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5&&o.tag!==27);return o||null}function Pf(o,l,d,m,E){for(var C=l._reactName,W=[];d!==null&&d!==m;){var le=d,ke=le.alternate,Ye=le.stateNode;if(le=le.tag,ke!==null&&ke===m)break;le!==5&&le!==26&&le!==27||Ye===null||(ke=Ye,E?(Ye=Xt(d,C),Ye!=null&&W.unshift(ea(d,Ye,ke))):E||(Ye=Xt(d,C),Ye!=null&&W.push(ea(d,Ye,ke)))),d=d.return}W.length!==0&&o.push({event:l,listeners:W})}var rp=/\r\n?/g,np=/\u0000|\uFFFD/g;function kf(o){return(typeof o=="string"?o:""+o).replace(rp,`
10
+ `).replace(np,"")}function Lf(o,l){return l=kf(l),kf(o)===l}function mr(o,l,d,m,E,C){switch(d){case"children":typeof m=="string"?l==="body"||l==="textarea"&&m===""||Ae(o,m):(typeof m=="number"||typeof m=="bigint")&&l!=="body"&&Ae(o,""+m);break;case"className":I(o,"class",m);break;case"tabIndex":I(o,"tabindex",m);break;case"dir":case"role":case"viewBox":case"width":case"height":I(o,d,m);break;case"style":nt(o,m,C);break;case"data":if(l!=="object"){I(o,"data",m);break}case"src":case"href":if(m===""&&(l!=="a"||d!=="href")){o.removeAttribute(d);break}if(m==null||typeof m=="function"||typeof m=="symbol"||typeof m=="boolean"){o.removeAttribute(d);break}m=yt(""+m),o.setAttribute(d,m);break;case"action":case"formAction":if(typeof m=="function"){o.setAttribute(d,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof C=="function"&&(d==="formAction"?(l!=="input"&&mr(o,l,"name",E.name,E,null),mr(o,l,"formEncType",E.formEncType,E,null),mr(o,l,"formMethod",E.formMethod,E,null),mr(o,l,"formTarget",E.formTarget,E,null)):(mr(o,l,"encType",E.encType,E,null),mr(o,l,"method",E.method,E,null),mr(o,l,"target",E.target,E,null)));if(m==null||typeof m=="symbol"||typeof m=="boolean"){o.removeAttribute(d);break}m=yt(""+m),o.setAttribute(d,m);break;case"onClick":m!=null&&(o.onclick=wt);break;case"onScroll":m!=null&&Vt("scroll",o);break;case"onScrollEnd":m!=null&&Vt("scrollend",o);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(n(61));if(d=m.__html,d!=null){if(E.children!=null)throw Error(n(60));o.innerHTML=d}}break;case"multiple":o.multiple=m&&typeof m!="function"&&typeof m!="symbol";break;case"muted":o.muted=m&&typeof m!="function"&&typeof m!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(m==null||typeof m=="function"||typeof m=="boolean"||typeof m=="symbol"){o.removeAttribute("xlink:href");break}d=yt(""+m),o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",d);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":m!=null&&typeof m!="function"&&typeof m!="symbol"?o.setAttribute(d,""+m):o.removeAttribute(d);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":m&&typeof m!="function"&&typeof m!="symbol"?o.setAttribute(d,""):o.removeAttribute(d);break;case"capture":case"download":m===!0?o.setAttribute(d,""):m!==!1&&m!=null&&typeof m!="function"&&typeof m!="symbol"?o.setAttribute(d,m):o.removeAttribute(d);break;case"cols":case"rows":case"size":case"span":m!=null&&typeof m!="function"&&typeof m!="symbol"&&!isNaN(m)&&1<=m?o.setAttribute(d,m):o.removeAttribute(d);break;case"rowSpan":case"start":m==null||typeof m=="function"||typeof m=="symbol"||isNaN(m)?o.removeAttribute(d):o.setAttribute(d,m);break;case"popover":Vt("beforetoggle",o),Vt("toggle",o),v(o,"popover",m);break;case"xlinkActuate":k(o,"http://www.w3.org/1999/xlink","xlink:actuate",m);break;case"xlinkArcrole":k(o,"http://www.w3.org/1999/xlink","xlink:arcrole",m);break;case"xlinkRole":k(o,"http://www.w3.org/1999/xlink","xlink:role",m);break;case"xlinkShow":k(o,"http://www.w3.org/1999/xlink","xlink:show",m);break;case"xlinkTitle":k(o,"http://www.w3.org/1999/xlink","xlink:title",m);break;case"xlinkType":k(o,"http://www.w3.org/1999/xlink","xlink:type",m);break;case"xmlBase":k(o,"http://www.w3.org/XML/1998/namespace","xml:base",m);break;case"xmlLang":k(o,"http://www.w3.org/XML/1998/namespace","xml:lang",m);break;case"xmlSpace":k(o,"http://www.w3.org/XML/1998/namespace","xml:space",m);break;case"is":v(o,"is",m);break;case"innerText":case"textContent":break;default:(!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(d=ht.get(d)||d,v(o,d,m))}}function Hu(o,l,d,m,E,C){switch(d){case"style":nt(o,m,C);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(n(61));if(d=m.__html,d!=null){if(E.children!=null)throw Error(n(60));o.innerHTML=d}}break;case"children":typeof m=="string"?Ae(o,m):(typeof m=="number"||typeof m=="bigint")&&Ae(o,""+m);break;case"onScroll":m!=null&&Vt("scroll",o);break;case"onScrollEnd":m!=null&&Vt("scrollend",o);break;case"onClick":m!=null&&(o.onclick=wt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!wi.hasOwnProperty(d))e:{if(d[0]==="o"&&d[1]==="n"&&(E=d.endsWith("Capture"),l=d.slice(2,E?d.length-7:void 0),C=o[fr]||null,C=C!=null?C[d]:null,typeof C=="function"&&o.removeEventListener(l,C,E),typeof m=="function")){typeof C!="function"&&C!==null&&(d in o?o[d]=null:o.hasAttribute(d)&&o.removeAttribute(d)),o.addEventListener(l,m,E);break e}d in o?o[d]=m:m===!0?o.setAttribute(d,""):v(o,d,m)}}}function fn(o,l,d){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Vt("error",o),Vt("load",o);var m=!1,E=!1,C;for(C in d)if(d.hasOwnProperty(C)){var W=d[C];if(W!=null)switch(C){case"src":m=!0;break;case"srcSet":E=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(n(137,l));default:mr(o,l,C,W,d,null)}}E&&mr(o,l,"srcSet",d.srcSet,d,null),m&&mr(o,l,"src",d.src,d,null);return;case"input":Vt("invalid",o);var le=C=W=E=null,ke=null,Ye=null;for(m in d)if(d.hasOwnProperty(m)){var lt=d[m];if(lt!=null)switch(m){case"name":E=lt;break;case"type":W=lt;break;case"checked":ke=lt;break;case"defaultChecked":Ye=lt;break;case"value":C=lt;break;case"defaultValue":le=lt;break;case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(n(137,l));break;default:mr(o,l,m,lt,d,null)}}We(o,C,le,ke,Ye,W,E,!1);return;case"select":Vt("invalid",o),m=W=C=null;for(E in d)if(d.hasOwnProperty(E)&&(le=d[E],le!=null))switch(E){case"value":C=le;break;case"defaultValue":W=le;break;case"multiple":m=le;default:mr(o,l,E,le,d,null)}l=C,d=W,o.multiple=!!m,l!=null?et(o,!!m,l,!1):d!=null&&et(o,!!m,d,!0);return;case"textarea":Vt("invalid",o),C=E=m=null;for(W in d)if(d.hasOwnProperty(W)&&(le=d[W],le!=null))switch(W){case"value":m=le;break;case"defaultValue":E=le;break;case"children":C=le;break;case"dangerouslySetInnerHTML":if(le!=null)throw Error(n(91));break;default:mr(o,l,W,le,d,null)}Se(o,m,E,C);return;case"option":for(ke in d)d.hasOwnProperty(ke)&&(m=d[ke],m!=null)&&(ke==="selected"?o.selected=m&&typeof m!="function"&&typeof m!="symbol":mr(o,l,ke,m,d,null));return;case"dialog":Vt("beforetoggle",o),Vt("toggle",o),Vt("cancel",o),Vt("close",o);break;case"iframe":case"object":Vt("load",o);break;case"video":case"audio":for(m=0;m<Yo.length;m++)Vt(Yo[m],o);break;case"image":Vt("error",o),Vt("load",o);break;case"details":Vt("toggle",o);break;case"embed":case"source":case"link":Vt("error",o),Vt("load",o);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Ye in d)if(d.hasOwnProperty(Ye)&&(m=d[Ye],m!=null))switch(Ye){case"children":case"dangerouslySetInnerHTML":throw Error(n(137,l));default:mr(o,l,Ye,m,d,null)}return;default:if(bt(l)){for(lt in d)d.hasOwnProperty(lt)&&(m=d[lt],m!==void 0&&Hu(o,l,lt,m,d,void 0));return}}for(le in d)d.hasOwnProperty(le)&&(m=d[le],m!=null&&mr(o,l,le,m,d,null))}function ip(o,l,d,m){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var E=null,C=null,W=null,le=null,ke=null,Ye=null,lt=null;for(it in d){var dt=d[it];if(d.hasOwnProperty(it)&&dt!=null)switch(it){case"checked":break;case"value":break;case"defaultValue":ke=dt;default:m.hasOwnProperty(it)||mr(o,l,it,null,m,dt)}}for(var tt in m){var it=m[tt];if(dt=d[tt],m.hasOwnProperty(tt)&&(it!=null||dt!=null))switch(tt){case"type":C=it;break;case"name":E=it;break;case"checked":Ye=it;break;case"defaultChecked":lt=it;break;case"value":W=it;break;case"defaultValue":le=it;break;case"children":case"dangerouslySetInnerHTML":if(it!=null)throw Error(n(137,l));break;default:it!==dt&&mr(o,l,tt,it,m,dt)}}Le(o,W,le,ke,Ye,lt,C,E);return;case"select":it=W=le=tt=null;for(C in d)if(ke=d[C],d.hasOwnProperty(C)&&ke!=null)switch(C){case"value":break;case"multiple":it=ke;default:m.hasOwnProperty(C)||mr(o,l,C,null,m,ke)}for(E in m)if(C=m[E],ke=d[E],m.hasOwnProperty(E)&&(C!=null||ke!=null))switch(E){case"value":tt=C;break;case"defaultValue":le=C;break;case"multiple":W=C;default:C!==ke&&mr(o,l,E,C,m,ke)}l=le,d=W,m=it,tt!=null?et(o,!!d,tt,!1):!!m!=!!d&&(l!=null?et(o,!!d,l,!0):et(o,!!d,d?[]:"",!1));return;case"textarea":it=tt=null;for(le in d)if(E=d[le],d.hasOwnProperty(le)&&E!=null&&!m.hasOwnProperty(le))switch(le){case"value":break;case"children":break;default:mr(o,l,le,null,m,E)}for(W in m)if(E=m[W],C=d[W],m.hasOwnProperty(W)&&(E!=null||C!=null))switch(W){case"value":tt=E;break;case"defaultValue":it=E;break;case"children":break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(n(91));break;default:E!==C&&mr(o,l,W,E,m,C)}ne(o,tt,it);return;case"option":for(var St in d)tt=d[St],d.hasOwnProperty(St)&&tt!=null&&!m.hasOwnProperty(St)&&(St==="selected"?o.selected=!1:mr(o,l,St,null,m,tt));for(ke in m)tt=m[ke],it=d[ke],m.hasOwnProperty(ke)&&tt!==it&&(tt!=null||it!=null)&&(ke==="selected"?o.selected=tt&&typeof tt!="function"&&typeof tt!="symbol":mr(o,l,ke,tt,m,it));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var It in d)tt=d[It],d.hasOwnProperty(It)&&tt!=null&&!m.hasOwnProperty(It)&&mr(o,l,It,null,m,tt);for(Ye in m)if(tt=m[Ye],it=d[Ye],m.hasOwnProperty(Ye)&&tt!==it&&(tt!=null||it!=null))switch(Ye){case"children":case"dangerouslySetInnerHTML":if(tt!=null)throw Error(n(137,l));break;default:mr(o,l,Ye,tt,m,it)}return;default:if(bt(l)){for(var yr in d)tt=d[yr],d.hasOwnProperty(yr)&&tt!==void 0&&!m.hasOwnProperty(yr)&&Hu(o,l,yr,void 0,m,tt);for(lt in m)tt=m[lt],it=d[lt],!m.hasOwnProperty(lt)||tt===it||tt===void 0&&it===void 0||Hu(o,l,lt,tt,m,it);return}}for(var Ke in d)tt=d[Ke],d.hasOwnProperty(Ke)&&tt!=null&&!m.hasOwnProperty(Ke)&&mr(o,l,Ke,null,m,tt);for(dt in m)tt=m[dt],it=d[dt],!m.hasOwnProperty(dt)||tt===it||tt==null&&it==null||mr(o,l,dt,tt,m,it)}function Uf(o){switch(o){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function sp(){if(typeof performance.getEntriesByType=="function"){for(var o=0,l=0,d=performance.getEntriesByType("resource"),m=0;m<d.length;m++){var E=d[m],C=E.transferSize,W=E.initiatorType,le=E.duration;if(C&&le&&Uf(W)){for(W=0,le=E.responseEnd,m+=1;m<d.length;m++){var ke=d[m],Ye=ke.startTime;if(Ye>le)break;var lt=ke.transferSize,dt=ke.initiatorType;lt&&Uf(dt)&&(ke=ke.responseEnd,W+=lt*(ke<le?1:(le-Ye)/(ke-Ye)))}if(--m,l+=8*(C+W)/(E.duration/1e3),o++,10<o)break}}if(0<o)return l/o/1e6}return navigator.connection&&(o=navigator.connection.downlink,typeof o=="number")?o:5}var Wu=null,Ku=null;function ol(o){return o.nodeType===9?o:o.ownerDocument}function Of(o){switch(o){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function $f(o,l){if(o===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return o===1&&l==="foreignObject"?0:o}function Gu(o,l){return o==="textarea"||o==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var Ju=null;function op(){var o=window.event;return o&&o.type==="popstate"?o===Ju?!1:(Ju=o,!0):(Ju=null,!1)}var jf=typeof setTimeout=="function"?setTimeout:void 0,ap=typeof clearTimeout=="function"?clearTimeout:void 0,Bf=typeof Promise=="function"?Promise:void 0,lp=typeof queueMicrotask=="function"?queueMicrotask:typeof Bf<"u"?function(o){return Bf.resolve(null).then(o).catch(up)}:jf;function up(o){setTimeout(function(){throw o})}function ps(o){return o==="head"}function Mf(o,l){var d=l,m=0;do{var E=d.nextSibling;if(o.removeChild(d),E&&E.nodeType===8)if(d=E.data,d==="/$"||d==="/&"){if(m===0){o.removeChild(E),_o(l);return}m--}else if(d==="$"||d==="$?"||d==="$~"||d==="$!"||d==="&")m++;else if(d==="html")ta(o.ownerDocument.documentElement);else if(d==="head"){d=o.ownerDocument.head,ta(d);for(var C=d.firstChild;C;){var W=C.nextSibling,le=C.nodeName;C[oi]||le==="SCRIPT"||le==="STYLE"||le==="LINK"&&C.rel.toLowerCase()==="stylesheet"||d.removeChild(C),C=W}}else d==="body"&&ta(o.ownerDocument.body);d=E}while(d);_o(l)}function qf(o,l){var d=o;o=0;do{var m=d.nextSibling;if(d.nodeType===1?l?(d._stashedDisplay=d.style.display,d.style.display="none"):(d.style.display=d._stashedDisplay||"",d.getAttribute("style")===""&&d.removeAttribute("style")):d.nodeType===3&&(l?(d._stashedText=d.nodeValue,d.nodeValue=""):d.nodeValue=d._stashedText||""),m&&m.nodeType===8)if(d=m.data,d==="/$"){if(o===0)break;o--}else d!=="$"&&d!=="$?"&&d!=="$~"&&d!=="$!"||o++;d=m}while(d)}function Qu(o){var l=o.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var d=l;switch(l=l.nextSibling,d.nodeName){case"HTML":case"HEAD":case"BODY":Qu(d),br(d);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(d.rel.toLowerCase()==="stylesheet")continue}o.removeChild(d)}}function cp(o,l,d,m){for(;o.nodeType===1;){var E=d;if(o.nodeName.toLowerCase()!==l.toLowerCase()){if(!m&&(o.nodeName!=="INPUT"||o.type!=="hidden"))break}else if(m){if(!o[oi])switch(l){case"meta":if(!o.hasAttribute("itemprop"))break;return o;case"link":if(C=o.getAttribute("rel"),C==="stylesheet"&&o.hasAttribute("data-precedence"))break;if(C!==E.rel||o.getAttribute("href")!==(E.href==null||E.href===""?null:E.href)||o.getAttribute("crossorigin")!==(E.crossOrigin==null?null:E.crossOrigin)||o.getAttribute("title")!==(E.title==null?null:E.title))break;return o;case"style":if(o.hasAttribute("data-precedence"))break;return o;case"script":if(C=o.getAttribute("src"),(C!==(E.src==null?null:E.src)||o.getAttribute("type")!==(E.type==null?null:E.type)||o.getAttribute("crossorigin")!==(E.crossOrigin==null?null:E.crossOrigin))&&C&&o.hasAttribute("async")&&!o.hasAttribute("itemprop"))break;return o;default:return o}}else if(l==="input"&&o.type==="hidden"){var C=E.name==null?null:""+E.name;if(E.type==="hidden"&&o.getAttribute("name")===C)return o}else return o;if(o=ni(o.nextSibling),o===null)break}return null}function dp(o,l,d){if(l==="")return null;for(;o.nodeType!==3;)if((o.nodeType!==1||o.nodeName!=="INPUT"||o.type!=="hidden")&&!d||(o=ni(o.nextSibling),o===null))return null;return o}function zf(o,l){for(;o.nodeType!==8;)if((o.nodeType!==1||o.nodeName!=="INPUT"||o.type!=="hidden")&&!l||(o=ni(o.nextSibling),o===null))return null;return o}function Zu(o){return o.data==="$?"||o.data==="$~"}function Xu(o){return o.data==="$!"||o.data==="$?"&&o.ownerDocument.readyState!=="loading"}function fp(o,l){var d=o.ownerDocument;if(o.data==="$~")o._reactRetry=l;else if(o.data!=="$?"||d.readyState!=="loading")l();else{var m=function(){l(),d.removeEventListener("DOMContentLoaded",m)};d.addEventListener("DOMContentLoaded",m),o._reactRetry=m}}function ni(o){for(;o!=null;o=o.nextSibling){var l=o.nodeType;if(l===1||l===3)break;if(l===8){if(l=o.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return o}var Yu=null;function Vf(o){o=o.nextSibling;for(var l=0;o;){if(o.nodeType===8){var d=o.data;if(d==="/$"||d==="/&"){if(l===0)return ni(o.nextSibling);l--}else d!=="$"&&d!=="$!"&&d!=="$?"&&d!=="$~"&&d!=="&"||l++}o=o.nextSibling}return null}function Hf(o){o=o.previousSibling;for(var l=0;o;){if(o.nodeType===8){var d=o.data;if(d==="$"||d==="$!"||d==="$?"||d==="$~"||d==="&"){if(l===0)return o;l--}else d!=="/$"&&d!=="/&"||l++}o=o.previousSibling}return null}function Wf(o,l,d){switch(l=ol(d),o){case"html":if(o=l.documentElement,!o)throw Error(n(452));return o;case"head":if(o=l.head,!o)throw Error(n(453));return o;case"body":if(o=l.body,!o)throw Error(n(454));return o;default:throw Error(n(451))}}function ta(o){for(var l=o.attributes;l.length;)o.removeAttributeNode(l[0]);br(o)}var ii=new Map,Kf=new Set;function al(o){return typeof o.getRootNode=="function"?o.getRootNode():o.nodeType===9?o:o.ownerDocument}var Bi=Ve.d;Ve.d={f:hp,r:pp,D:gp,C:mp,L:yp,m:bp,X:wp,S:_p,M:vp};function hp(){var o=Bi.f(),l=Xa();return o||l}function pp(o){var l=ai(o);l!==null&&l.tag===5&&l.type==="form"?ud(l):Bi.r(o)}var mo=typeof document>"u"?null:document;function Gf(o,l,d){var m=mo;if(m&&typeof l=="string"&&l){var E=Ce(l);E='link[rel="'+o+'"][href="'+E+'"]',typeof d=="string"&&(E+='[crossorigin="'+d+'"]'),Kf.has(E)||(Kf.add(E),o={rel:o,crossOrigin:d,href:l},m.querySelector(E)===null&&(l=m.createElement("link"),fn(l,"link",o),Er(l),m.head.appendChild(l)))}}function gp(o){Bi.D(o),Gf("dns-prefetch",o,null)}function mp(o,l){Bi.C(o,l),Gf("preconnect",o,l)}function yp(o,l,d){Bi.L(o,l,d);var m=mo;if(m&&o&&l){var E='link[rel="preload"][as="'+Ce(l)+'"]';l==="image"&&d&&d.imageSrcSet?(E+='[imagesrcset="'+Ce(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(E+='[imagesizes="'+Ce(d.imageSizes)+'"]')):E+='[href="'+Ce(o)+'"]';var C=E;switch(l){case"style":C=yo(o);break;case"script":C=bo(o)}ii.has(C)||(o=g({rel:"preload",href:l==="image"&&d&&d.imageSrcSet?void 0:o,as:l},d),ii.set(C,o),m.querySelector(E)!==null||l==="style"&&m.querySelector(ra(C))||l==="script"&&m.querySelector(na(C))||(l=m.createElement("link"),fn(l,"link",o),Er(l),m.head.appendChild(l)))}}function bp(o,l){Bi.m(o,l);var d=mo;if(d&&o){var m=l&&typeof l.as=="string"?l.as:"script",E='link[rel="modulepreload"][as="'+Ce(m)+'"][href="'+Ce(o)+'"]',C=E;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":C=bo(o)}if(!ii.has(C)&&(o=g({rel:"modulepreload",href:o},l),ii.set(C,o),d.querySelector(E)===null)){switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(na(C)))return}m=d.createElement("link"),fn(m,"link",o),Er(m),d.head.appendChild(m)}}}function _p(o,l,d){Bi.S(o,l,d);var m=mo;if(m&&o){var E=vn(m).hoistableStyles,C=yo(o);l=l||"default";var W=E.get(C);if(!W){var le={loading:0,preload:null};if(W=m.querySelector(ra(C)))le.loading=5;else{o=g({rel:"stylesheet",href:o,"data-precedence":l},d),(d=ii.get(C))&&ec(o,d);var ke=W=m.createElement("link");Er(ke),fn(ke,"link",o),ke._p=new Promise(function(Ye,lt){ke.onload=Ye,ke.onerror=lt}),ke.addEventListener("load",function(){le.loading|=1}),ke.addEventListener("error",function(){le.loading|=2}),le.loading|=4,ll(W,l,m)}W={type:"stylesheet",instance:W,count:1,state:le},E.set(C,W)}}}function wp(o,l){Bi.X(o,l);var d=mo;if(d&&o){var m=vn(d).hoistableScripts,E=bo(o),C=m.get(E);C||(C=d.querySelector(na(E)),C||(o=g({src:o,async:!0},l),(l=ii.get(E))&&tc(o,l),C=d.createElement("script"),Er(C),fn(C,"link",o),d.head.appendChild(C)),C={type:"script",instance:C,count:1,state:null},m.set(E,C))}}function vp(o,l){Bi.M(o,l);var d=mo;if(d&&o){var m=vn(d).hoistableScripts,E=bo(o),C=m.get(E);C||(C=d.querySelector(na(E)),C||(o=g({src:o,async:!0,type:"module"},l),(l=ii.get(E))&&tc(o,l),C=d.createElement("script"),Er(C),fn(C,"link",o),d.head.appendChild(C)),C={type:"script",instance:C,count:1,state:null},m.set(E,C))}}function Jf(o,l,d,m){var E=(E=Je.current)?al(E):null;if(!E)throw Error(n(446));switch(o){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(l=yo(d.href),d=vn(E).hoistableStyles,m=d.get(l),m||(m={type:"style",instance:null,count:0,state:null},d.set(l,m)),m):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){o=yo(d.href);var C=vn(E).hoistableStyles,W=C.get(o);if(W||(E=E.ownerDocument||E,W={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},C.set(o,W),(C=E.querySelector(ra(o)))&&!C._p&&(W.instance=C,W.state.loading=5),ii.has(o)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},ii.set(o,d),C||Sp(E,o,d,W.state))),l&&m===null)throw Error(n(528,""));return W}if(l&&m!==null)throw Error(n(529,""));return null;case"script":return l=d.async,d=d.src,typeof d=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=bo(d),d=vn(E).hoistableScripts,m=d.get(l),m||(m={type:"script",instance:null,count:0,state:null},d.set(l,m)),m):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,o))}}function yo(o){return'href="'+Ce(o)+'"'}function ra(o){return'link[rel="stylesheet"]['+o+"]"}function Qf(o){return g({},o,{"data-precedence":o.precedence,precedence:null})}function Sp(o,l,d,m){o.querySelector('link[rel="preload"][as="style"]['+l+"]")?m.loading=1:(l=o.createElement("link"),m.preload=l,l.addEventListener("load",function(){return m.loading|=1}),l.addEventListener("error",function(){return m.loading|=2}),fn(l,"link",d),Er(l),o.head.appendChild(l))}function bo(o){return'[src="'+Ce(o)+'"]'}function na(o){return"script[async]"+o}function Zf(o,l,d){if(l.count++,l.instance===null)switch(l.type){case"style":var m=o.querySelector('style[data-href~="'+Ce(d.href)+'"]');if(m)return l.instance=m,Er(m),m;var E=g({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return m=(o.ownerDocument||o).createElement("style"),Er(m),fn(m,"style",E),ll(m,d.precedence,o),l.instance=m;case"stylesheet":E=yo(d.href);var C=o.querySelector(ra(E));if(C)return l.state.loading|=4,l.instance=C,Er(C),C;m=Qf(d),(E=ii.get(E))&&ec(m,E),C=(o.ownerDocument||o).createElement("link"),Er(C);var W=C;return W._p=new Promise(function(le,ke){W.onload=le,W.onerror=ke}),fn(C,"link",m),l.state.loading|=4,ll(C,d.precedence,o),l.instance=C;case"script":return C=bo(d.src),(E=o.querySelector(na(C)))?(l.instance=E,Er(E),E):(m=d,(E=ii.get(C))&&(m=g({},d),tc(m,E)),o=o.ownerDocument||o,E=o.createElement("script"),Er(E),fn(E,"link",m),o.head.appendChild(E),l.instance=E);case"void":return null;default:throw Error(n(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(m=l.instance,l.state.loading|=4,ll(m,d.precedence,o));return l.instance}function ll(o,l,d){for(var m=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),E=m.length?m[m.length-1]:null,C=E,W=0;W<m.length;W++){var le=m[W];if(le.dataset.precedence===l)C=le;else if(C!==E)break}C?C.parentNode.insertBefore(o,C.nextSibling):(l=d.nodeType===9?d.head:d,l.insertBefore(o,l.firstChild))}function ec(o,l){o.crossOrigin==null&&(o.crossOrigin=l.crossOrigin),o.referrerPolicy==null&&(o.referrerPolicy=l.referrerPolicy),o.title==null&&(o.title=l.title)}function tc(o,l){o.crossOrigin==null&&(o.crossOrigin=l.crossOrigin),o.referrerPolicy==null&&(o.referrerPolicy=l.referrerPolicy),o.integrity==null&&(o.integrity=l.integrity)}var ul=null;function Xf(o,l,d){if(ul===null){var m=new Map,E=ul=new Map;E.set(d,m)}else E=ul,m=E.get(d),m||(m=new Map,E.set(d,m));if(m.has(o))return m;for(m.set(o,null),d=d.getElementsByTagName(o),E=0;E<d.length;E++){var C=d[E];if(!(C[oi]||C[qt]||o==="link"&&C.getAttribute("rel")==="stylesheet")&&C.namespaceURI!=="http://www.w3.org/2000/svg"){var W=C.getAttribute(l)||"";W=o+W;var le=m.get(W);le?le.push(C):m.set(W,[C])}}return m}function Yf(o,l,d){o=o.ownerDocument||o,o.head.insertBefore(d,l==="title"?o.querySelector("head > title"):null)}function Ep(o,l,d){if(d===1||l.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(o=l.disabled,typeof l.precedence=="string"&&o==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function eh(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function Tp(o,l,d,m){if(d.type==="stylesheet"&&(typeof m.media!="string"||matchMedia(m.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var E=yo(m.href),C=l.querySelector(ra(E));if(C){l=C._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(o.count++,o=cl.bind(o),l.then(o,o)),d.state.loading|=4,d.instance=C,Er(C);return}C=l.ownerDocument||l,m=Qf(m),(E=ii.get(E))&&ec(m,E),C=C.createElement("link"),Er(C);var W=C;W._p=new Promise(function(le,ke){W.onload=le,W.onerror=ke}),fn(C,"link",m),d.instance=C}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(d,l),(l=d.state.preload)&&(d.state.loading&3)===0&&(o.count++,d=cl.bind(o),l.addEventListener("load",d),l.addEventListener("error",d))}}var rc=0;function Rp(o,l){return o.stylesheets&&o.count===0&&fl(o,o.stylesheets),0<o.count||0<o.imgCount?function(d){var m=setTimeout(function(){if(o.stylesheets&&fl(o,o.stylesheets),o.unsuspend){var C=o.unsuspend;o.unsuspend=null,C()}},6e4+l);0<o.imgBytes&&rc===0&&(rc=62500*sp());var E=setTimeout(function(){if(o.waitingForImages=!1,o.count===0&&(o.stylesheets&&fl(o,o.stylesheets),o.unsuspend)){var C=o.unsuspend;o.unsuspend=null,C()}},(o.imgBytes>rc?50:800)+l);return o.unsuspend=d,function(){o.unsuspend=null,clearTimeout(m),clearTimeout(E)}}:null}function cl(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)fl(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var dl=null;function fl(o,l){o.stylesheets=null,o.unsuspend!==null&&(o.count++,dl=new Map,l.forEach(xp,o),dl=null,cl.call(o))}function xp(o,l){if(!(l.state.loading&4)){var d=dl.get(o);if(d)var m=d.get(null);else{d=new Map,dl.set(o,d);for(var E=o.querySelectorAll("link[data-precedence],style[data-precedence]"),C=0;C<E.length;C++){var W=E[C];(W.nodeName==="LINK"||W.getAttribute("media")!=="not all")&&(d.set(W.dataset.precedence,W),m=W)}m&&d.set(null,m)}E=l.instance,W=E.getAttribute("data-precedence"),C=d.get(W)||m,C===m&&d.set(null,E),d.set(W,E),this.count++,m=cl.bind(this),E.addEventListener("load",m),E.addEventListener("error",m),C?C.parentNode.insertBefore(E,C.nextSibling):(o=o.nodeType===9?o.head:o,o.insertBefore(E,o.firstChild)),l.state.loading|=4}}var ia={$$typeof:x,Provider:null,Consumer:null,_currentValue:pe,_currentValue2:pe,_threadCount:0};function Ap(o,l,d,m,E,C,W,le,ke){this.tag=1,this.containerInfo=o,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=H(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=H(0),this.hiddenUpdates=H(null),this.identifierPrefix=m,this.onUncaughtError=E,this.onCaughtError=C,this.onRecoverableError=W,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ke,this.incompleteTransitions=new Map}function th(o,l,d,m,E,C,W,le,ke,Ye,lt,dt){return o=new Ap(o,l,d,W,ke,Ye,lt,dt,le),l=1,C===!0&&(l|=24),C=Ln(3,null,null,l),o.current=C,C.stateNode=o,l=Ll(),l.refCount++,o.pooledCache=l,l.refCount++,C.memoizedState={element:m,isDehydrated:d,cache:l},jl(C),o}function rh(o){return o?(o=Gs,o):Gs}function nh(o,l,d,m,E,C){E=rh(E),m.context===null?m.context=E:m.pendingContext=E,m=ts(l),m.payload={element:d},C=C===void 0?null:C,C!==null&&(m.callback=C),d=rs(o,m,l),d!==null&&(Nn(d,o,l),Uo(d,o,l))}function ih(o,l){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var d=o.retryLane;o.retryLane=d!==0&&d<l?d:l}}function nc(o,l){ih(o,l),(o=o.alternate)&&ih(o,l)}function sh(o){if(o.tag===13||o.tag===31){var l=Rs(o,67108864);l!==null&&Nn(l,o,67108864),nc(o,67108864)}}function oh(o){if(o.tag===13||o.tag===31){var l=Bn();l=on(l);var d=Rs(o,l);d!==null&&Nn(d,o,l),nc(o,l)}}var hl=!0;function Ip(o,l,d,m){var E=ye.T;ye.T=null;var C=Ve.p;try{Ve.p=2,ic(o,l,d,m)}finally{Ve.p=C,ye.T=E}}function Cp(o,l,d,m){var E=ye.T;ye.T=null;var C=Ve.p;try{Ve.p=8,ic(o,l,d,m)}finally{Ve.p=C,ye.T=E}}function ic(o,l,d,m){if(hl){var E=sc(m);if(E===null)Vu(o,l,m,pl,d),lh(o,m);else if(Fp(E,o,l,d,m))m.stopPropagation();else if(lh(o,m),l&4&&-1<Np.indexOf(o)){for(;E!==null;){var C=ai(E);if(C!==null)switch(C.tag){case 3:if(C=C.stateNode,C.current.memoizedState.isDehydrated){var W=Bt(C.pendingLanes);if(W!==0){var le=C;for(le.pendingLanes|=2,le.entangledLanes|=2;W;){var ke=1<<31-Tt(W);le.entanglements[1]|=ke,W&=~ke}bi(C),(rr&6)===0&&(Qa=ft()+500,Xo(0))}}break;case 31:case 13:le=Rs(C,2),le!==null&&Nn(le,C,2),Xa(),nc(C,2)}if(C=sc(m),C===null&&Vu(o,l,m,pl,d),C===E)break;E=C}E!==null&&m.stopPropagation()}else Vu(o,l,m,null,d)}}function sc(o){return o=Qt(o),oc(o)}var pl=null;function oc(o){if(pl=null,o=or(o),o!==null){var l=a(o);if(l===null)o=null;else{var d=l.tag;if(d===13){if(o=u(l),o!==null)return o;o=null}else if(d===31){if(o=c(l),o!==null)return o;o=null}else if(d===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;o=null}else l!==o&&(o=null)}}return pl=o,null}function ah(o){switch(o){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ge()){case pt:return 2;case Z:return 8;case P:case B:return 32;case U:return 268435456;default:return 32}default:return 32}}var ac=!1,gs=null,ms=null,ys=null,sa=new Map,oa=new Map,bs=[],Np="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function lh(o,l){switch(o){case"focusin":case"focusout":gs=null;break;case"dragenter":case"dragleave":ms=null;break;case"mouseover":case"mouseout":ys=null;break;case"pointerover":case"pointerout":sa.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":oa.delete(l.pointerId)}}function aa(o,l,d,m,E,C){return o===null||o.nativeEvent!==C?(o={blockedOn:l,domEventName:d,eventSystemFlags:m,nativeEvent:C,targetContainers:[E]},l!==null&&(l=ai(l),l!==null&&sh(l)),o):(o.eventSystemFlags|=m,l=o.targetContainers,E!==null&&l.indexOf(E)===-1&&l.push(E),o)}function Fp(o,l,d,m,E){switch(l){case"focusin":return gs=aa(gs,o,l,d,m,E),!0;case"dragenter":return ms=aa(ms,o,l,d,m,E),!0;case"mouseover":return ys=aa(ys,o,l,d,m,E),!0;case"pointerover":var C=E.pointerId;return sa.set(C,aa(sa.get(C)||null,o,l,d,m,E)),!0;case"gotpointercapture":return C=E.pointerId,oa.set(C,aa(oa.get(C)||null,o,l,d,m,E)),!0}return!1}function uh(o){var l=or(o.target);if(l!==null){var d=a(l);if(d!==null){if(l=d.tag,l===13){if(l=u(d),l!==null){o.blockedOn=l,bn(o.priority,function(){oh(d)});return}}else if(l===31){if(l=c(d),l!==null){o.blockedOn=l,bn(o.priority,function(){oh(d)});return}}else if(l===3&&d.stateNode.current.memoizedState.isDehydrated){o.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}o.blockedOn=null}function gl(o){if(o.blockedOn!==null)return!1;for(var l=o.targetContainers;0<l.length;){var d=sc(o.nativeEvent);if(d===null){d=o.nativeEvent;var m=new d.constructor(d.type,d);Jt=m,d.target.dispatchEvent(m),Jt=null}else return l=ai(d),l!==null&&sh(l),o.blockedOn=d,!1;l.shift()}return!0}function ch(o,l,d){gl(o)&&d.delete(l)}function Dp(){ac=!1,gs!==null&&gl(gs)&&(gs=null),ms!==null&&gl(ms)&&(ms=null),ys!==null&&gl(ys)&&(ys=null),sa.forEach(ch),oa.forEach(ch)}function ml(o,l){o.blockedOn===l&&(o.blockedOn=null,ac||(ac=!0,i.unstable_scheduleCallback(i.unstable_NormalPriority,Dp)))}var yl=null;function dh(o){yl!==o&&(yl=o,i.unstable_scheduleCallback(i.unstable_NormalPriority,function(){yl===o&&(yl=null);for(var l=0;l<o.length;l+=3){var d=o[l],m=o[l+1],E=o[l+2];if(typeof m!="function"){if(oc(m||d)===null)continue;break}var C=ai(d);C!==null&&(o.splice(l,3),l-=3,su(C,{pending:!0,data:E,method:d.method,action:m},m,E))}}))}function _o(o){function l(ke){return ml(ke,o)}gs!==null&&ml(gs,o),ms!==null&&ml(ms,o),ys!==null&&ml(ys,o),sa.forEach(l),oa.forEach(l);for(var d=0;d<bs.length;d++){var m=bs[d];m.blockedOn===o&&(m.blockedOn=null)}for(;0<bs.length&&(d=bs[0],d.blockedOn===null);)uh(d),d.blockedOn===null&&bs.shift();if(d=(o.ownerDocument||o).$$reactFormReplay,d!=null)for(m=0;m<d.length;m+=3){var E=d[m],C=d[m+1],W=E[fr]||null;if(typeof C=="function")W||dh(d);else if(W){var le=null;if(C&&C.hasAttribute("formAction")){if(E=C,W=C[fr]||null)le=W.formAction;else if(oc(E)!==null)continue}else le=W.action;typeof le=="function"?d[m+1]=le:(d.splice(m,3),m-=3),dh(d)}}}function fh(){function o(C){C.canIntercept&&C.info==="react-transition"&&C.intercept({handler:function(){return new Promise(function(W){return E=W})},focusReset:"manual",scroll:"manual"})}function l(){E!==null&&(E(),E=null),m||setTimeout(d,20)}function d(){if(!m&&!navigation.transition){var C=navigation.currentEntry;C&&C.url!=null&&navigation.navigate(C.url,{state:C.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var m=!1,E=null;return navigation.addEventListener("navigate",o),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(d,100),function(){m=!0,navigation.removeEventListener("navigate",o),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),E!==null&&(E(),E=null)}}}function lc(o){this._internalRoot=o}bl.prototype.render=lc.prototype.render=function(o){var l=this._internalRoot;if(l===null)throw Error(n(409));var d=l.current,m=Bn();nh(d,m,o,l,null,null)},bl.prototype.unmount=lc.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var l=o.containerInfo;nh(o.current,2,null,o,null,null),Xa(),l[Dr]=null}};function bl(o){this._internalRoot=o}bl.prototype.unstable_scheduleHydration=function(o){if(o){var l=sr();o={blockedOn:null,target:o,priority:l};for(var d=0;d<bs.length&&l!==0&&l<bs[d].priority;d++);bs.splice(d,0,o),d===0&&uh(o)}};var hh=e.version;if(hh!=="19.2.8")throw Error(n(527,hh,"19.2.8"));Ve.findDOMNode=function(o){var l=o._reactInternals;if(l===void 0)throw typeof o.render=="function"?Error(n(188)):(o=Object.keys(o).join(","),Error(n(268,o)));return o=f(l),o=o!==null?p(o):null,o=o===null?null:o.stateNode,o};var Pp={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:ye,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var _l=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!_l.isDisabled&&_l.supportsFiber)try{Pe=_l.inject(Pp),gt=_l}catch{}}return reactDomClient_production.createRoot=function(o,l){if(!s(o))throw Error(n(299));var d=!1,m="",E=_d,C=wd,W=vd;return l!=null&&(l.unstable_strictMode===!0&&(d=!0),l.identifierPrefix!==void 0&&(m=l.identifierPrefix),l.onUncaughtError!==void 0&&(E=l.onUncaughtError),l.onCaughtError!==void 0&&(C=l.onCaughtError),l.onRecoverableError!==void 0&&(W=l.onRecoverableError)),l=th(o,1,!1,null,null,d,m,null,E,C,W,fh),o[Dr]=l.current,zu(o),new lc(l)},reactDomClient_production.hydrateRoot=function(o,l,d){if(!s(o))throw Error(n(299));var m=!1,E="",C=_d,W=wd,le=vd,ke=null;return d!=null&&(d.unstable_strictMode===!0&&(m=!0),d.identifierPrefix!==void 0&&(E=d.identifierPrefix),d.onUncaughtError!==void 0&&(C=d.onUncaughtError),d.onCaughtError!==void 0&&(W=d.onCaughtError),d.onRecoverableError!==void 0&&(le=d.onRecoverableError),d.formState!==void 0&&(ke=d.formState)),l=th(o,1,!0,l,d??null,m,E,ke,C,W,le,fh),l.context=rh(null),d=l.current,m=Bn(),m=on(m),E=ts(m),E.callback=null,rs(d,E,m),d=m,l.current.lanes=d,Be(l,d),bi(l),o[Dr]=l.current,zu(o),new bl(l)},reactDomClient_production.version="19.2.8",reactDomClient_production}var hasRequiredClient;function requireClient(){if(hasRequiredClient)return client.exports;hasRequiredClient=1;function i(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),client.exports=requireReactDomClient_production(),client.exports}var clientExports=requireClient();var ABSOLUTE_URL_REGEX=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,PROTOCOL_RELATIVE_URL_REGEX=/^[\\/]{2}/;function normalizeProtocolRelativeUrl(i,e){return e+i.replace(/\\/g,"/")}var PopStateEventType="popstate";function isLocation(i){return typeof i=="object"&&i!=null&&"pathname"in i&&"search"in i&&"hash"in i&&"state"in i&&"key"in i}function createBrowserHistory(i={}){function e(n,s){let a=s.state?.masked,{pathname:u,search:c,hash:h}=a||n.location;return createLocation("",{pathname:u,search:c,hash:h},s.state&&s.state.usr||null,s.state&&s.state.key||"default",a?{pathname:n.location.pathname,search:n.location.search,hash:n.location.hash}:void 0)}function t(n,s){return typeof s=="string"?s:createPath(s)}return getUrlBasedHistory(e,t,null,i)}function invariant(i,e){if(i===!1||i===null||typeof i>"u")throw new Error(e)}function warning(i,e){if(!i){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function createKey(){return Math.random().toString(36).substring(2,10)}function getHistoryState(i,e){return{usr:i.state,key:i.key,idx:e,masked:i.mask?{pathname:i.pathname,search:i.search,hash:i.hash}:void 0}}function createLocation(i,e,t=null,n,s){return{pathname:typeof i=="string"?i:i.pathname,search:"",hash:"",...typeof e=="string"?parsePath(e):e,state:t,key:e&&e.key||n||createKey(),mask:s}}function createPath({pathname:i="/",search:e="",hash:t=""}){return e&&e!=="?"&&(i+=e.charAt(0)==="?"?e:"?"+e),t&&t!=="#"&&(i+=t.charAt(0)==="#"?t:"#"+t),i}function parsePath(i){let e={};if(i){let t=i.indexOf("#");t>=0&&(e.hash=i.substring(t),i=i.substring(0,t));let n=i.indexOf("?");n>=0&&(e.search=i.substring(n),i=i.substring(0,n)),i&&(e.pathname=i)}return e}function getUrlBasedHistory(i,e,t,n={}){let{window:s=document.defaultView,v5Compat:a=!1}=n,u=s.history,c="POP",h=null,f=p();f==null&&(f=0,u.replaceState({...u.state,idx:f},""));function p(){return(u.state||{idx:null}).idx}function g(){c="POP";let T=p(),A=T==null?null:T-f;f=T,h&&h({action:c,location:R.location,delta:A})}function y(T,A){c="PUSH";let F=isLocation(T)?T:createLocation(R.location,T,A);f=p()+1;let x=getHistoryState(F,f),D=R.createHref(F.mask||F);try{u.pushState(x,"",D)}catch(O){if(O instanceof DOMException&&O.name==="DataCloneError")throw O;s.location.assign(D)}a&&h&&h({action:c,location:R.location,delta:1})}function S(T,A){c="REPLACE";let F=isLocation(T)?T:createLocation(R.location,T,A);f=p();let x=getHistoryState(F,f),D=R.createHref(F.mask||F);u.replaceState(x,"",D),a&&h&&h({action:c,location:R.location,delta:0})}function w(T){return createBrowserURLImpl(s,T)}let R={get action(){return c},get location(){return i(s,u)},listen(T){if(h)throw new Error("A history only accepts one active listener");return s.addEventListener(PopStateEventType,g),h=T,()=>{s.removeEventListener(PopStateEventType,g),h=null}},createHref(T){return e(s,T)},createURL:w,encodeLocation(T){let A=w(T);return{pathname:A.pathname,search:A.search,hash:A.hash}},push:y,replace:S,go(T){return u.go(T)}};return R}function createBrowserURLImpl(i,e,t=!1){let n="http://localhost";i&&(n=i.location.origin!=="null"?i.location.origin:i.location.href),invariant(n,"No window.location.(origin|href) available to create URL");let s=typeof e=="string"?e:createPath(e);return s=s.replace(/ $/,"%20"),!t&&PROTOCOL_RELATIVE_URL_REGEX.test(s)&&(s=n+s),new URL(s,n)}function matchRoutes(i,e,t="/"){return matchRoutesImpl(i,e,t,!1)}function matchRoutesImpl(i,e,t,n,s){let a=typeof e=="string"?parsePath(e):e,u=stripBasename(a.pathname||"/",t);if(u==null)return null;let c=flattenAndRankRoutes(i),h=null,f=decodePath(u);for(let p=0;h==null&&p<c.length;++p)h=matchRouteBranch(c[p],f,n);return h}function flattenAndRankRoutes(i){let e=flattenRoutes(i);return rankRouteBranches(e),e}function flattenRoutes(i,e=[],t=[],n="",s=!1){let a=(u,c,h=s,f)=>{let p={relativePath:f===void 0?u.path||"":f,caseSensitive:u.caseSensitive===!0,childrenIndex:c,route:u};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(n)&&h)return;invariant(p.relativePath.startsWith(n),`Absolute route path "${p.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(n.length)}let g=joinPaths([n,p.relativePath]),y=t.concat(p);u.children&&u.children.length>0&&(invariant(u.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${g}".`),flattenRoutes(u.children,e,y,g,h)),!(u.path==null&&!u.index)&&e.push({path:g,score:computeScore(g,u.index),routesMeta:y.map((S,w)=>{let[R,T]=compilePath(S.relativePath,S.caseSensitive,w===y.length-1);return{...S,matcher:R,compiledParams:T}})})};return i.forEach((u,c)=>{if(u.path===""||!u.path?.includes("?"))a(u,c);else for(let h of explodeOptionalSegments(u.path))a(u,c,!0,h)}),e}function explodeOptionalSegments(i){let e=i.split("/");if(e.length===0)return[];let[t,...n]=e,s=t.endsWith("?"),a=t.replace(/\?$/,"");if(n.length===0)return s?[a,""]:[a];let u=explodeOptionalSegments(n.join("/")),c=[];return c.push(...u.map(h=>h===""?a:[a,h].join("/"))),s&&c.push(...u),c.map(h=>i.startsWith("/")&&h===""?"/":h)}function rankRouteBranches(i){i.sort((e,t)=>e.score!==t.score?t.score-e.score:compareIndexes(e.routesMeta.map(n=>n.childrenIndex),t.routesMeta.map(n=>n.childrenIndex)))}var paramRe=/^:[\w-]+$/,dynamicSegmentValue=3,indexRouteValue=2,emptySegmentValue=1,staticSegmentValue=10,splatPenalty=-2,isSplat=i=>i==="*";function computeScore(i,e){let t=i.split("/"),n=t.length;return t.some(isSplat)&&(n+=splatPenalty),e&&(n+=indexRouteValue),t.filter(s=>!isSplat(s)).reduce((s,a)=>s+(paramRe.test(a)?dynamicSegmentValue:a===""?emptySegmentValue:staticSegmentValue),n)}function compareIndexes(i,e){return i.length===e.length&&i.slice(0,-1).every((n,s)=>n===e[s])?i[i.length-1]-e[e.length-1]:0}function matchRouteBranch(i,e,t=!1){let{routesMeta:n}=i,s={},a="/",u=[];for(let c=0;c<n.length;++c){let h=n[c],f=c===n.length-1,p=a==="/"?e:e.slice(a.length)||"/",g={path:h.relativePath,caseSensitive:h.caseSensitive,end:f},y=h.matcher&&h.compiledParams?matchPathImpl(g,p,h.matcher,h.compiledParams):matchPath(g,p),S=h.route;if(!y&&f&&t&&!n[n.length-1].route.index&&(y=matchPath({path:h.relativePath,caseSensitive:h.caseSensitive,end:!1},p)),!y)return null;Object.assign(s,y.params),u.push({params:s,pathname:joinPaths([a,y.pathname]),pathnameBase:normalizePathname(joinPaths([a,y.pathnameBase])),route:S}),y.pathnameBase!=="/"&&(a=joinPaths([a,y.pathnameBase]))}return u}function matchPath(i,e){typeof i=="string"&&(i={path:i,caseSensitive:!1,end:!0});let[t,n]=compilePath(i.path,i.caseSensitive,i.end);return matchPathImpl(i,e,t,n)}function matchPathImpl(i,e,t,n){let s=e.match(t);if(!s)return null;let a=s[0],u=a.replace(/(.)\/+$/,"$1"),c=s.slice(1);return{params:n.reduce((f,{paramName:p,isOptional:g},y)=>{if(p==="*"){let w=c[y]||"";u=a.slice(0,a.length-w.length).replace(/(.)\/+$/,"$1")}const S=c[y];return g&&!S?f[p]=void 0:f[p]=(S||"").replace(/%2F/g,"/"),f},{}),pathname:a,pathnameBase:u,pattern:i}}function compilePath(i,e=!1,t=!0){warning(i==="*"||!i.endsWith("*")||i.endsWith("/*"),`Route path "${i}" will be treated as if it were "${i.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${i.replace(/\*$/,"/*")}".`);let n=[],s="^"+i.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(u,c,h,f,p)=>{if(n.push({paramName:c,isOptional:h!=null}),h){let g=p.charAt(f+u.length);return g&&g!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return i.endsWith("*")?(n.push({paramName:"*"}),s+=i==="*"||i==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?s+="\\/*$":i!==""&&i!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,e?void 0:"i"),n]}function decodePath(i){try{return i.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return warning(!1,`The URL path "${i}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),i}}function stripBasename(i,e){if(e==="/")return i;if(!i.toLowerCase().startsWith(e.toLowerCase()))return null;let t=e.endsWith("/")?e.length-1:e.length,n=i.charAt(t);return n&&n!=="/"?null:i.slice(t)||"/"}function resolvePath(i,e="/"){let{pathname:t,search:n="",hash:s=""}=typeof i=="string"?parsePath(i):i,a;return t?(t=removeDoubleSlashes(t),t.startsWith("/")?a=resolvePathname(t.substring(1),"/"):a=resolvePathname(t,e)):a=e,{pathname:a,search:normalizeSearch(n),hash:normalizeHash(s)}}function resolvePathname(i,e){let t=removeTrailingSlash(e).split("/");return i.split("/").forEach(s=>{s===".."?t.length>1&&t.pop():s!=="."&&t.push(s)}),t.length>1?t.join("/"):"/"}function getInvalidPathError(i,e,t,n){return`Cannot include a '${i}' character in a manually specified \`to.${e}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${t}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function getPathContributingMatches(i){return i.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function getResolveToMatches(i){let e=getPathContributingMatches(i);return e.map((t,n)=>n===e.length-1?t.pathname:t.pathnameBase)}function resolveTo(i,e,t,n=!1){let s;typeof i=="string"?s=parsePath(i):(s={...i},invariant(!s.pathname||!s.pathname.includes("?"),getInvalidPathError("?","pathname","search",s)),invariant(!s.pathname||!s.pathname.includes("#"),getInvalidPathError("#","pathname","hash",s)),invariant(!s.search||!s.search.includes("#"),getInvalidPathError("#","search","hash",s)));let a=i===""||s.pathname==="",u=a?"/":s.pathname,c;if(u==null)c=t;else{let g=e.length-1;if(!n&&u.startsWith("..")){let y=u.split("/");for(;y[0]==="..";)y.shift(),g-=1;s.pathname=y.join("/")}c=g>=0?e[g]:"/"}let h=resolvePath(s,c),f=u&&u!=="/"&&u.endsWith("/"),p=(a||u===".")&&t.endsWith("/");return!h.pathname.endsWith("/")&&(f||p)&&(h.pathname+="/"),h}var removeDoubleSlashes=i=>i.replace(/[\\/]{2,}/g,"/"),joinPaths=i=>removeDoubleSlashes(i.join("/")),removeTrailingSlash=i=>i.replace(/\/+$/,""),normalizePathname=i=>removeTrailingSlash(i).replace(/^\/*/,"/"),normalizeSearch=i=>!i||i==="?"?"":i.startsWith("?")?i:"?"+i,normalizeHash=i=>!i||i==="#"?"":i.startsWith("#")?i:"#"+i,ErrorResponseImpl=class{constructor(i,e,t,n=!1){this.status=i,this.statusText=e||"",this.internal=n,t instanceof Error?(this.data=t.toString(),this.error=t):this.data=t}};function isRouteErrorResponse(i){return i!=null&&typeof i.status=="number"&&typeof i.statusText=="string"&&typeof i.internal=="boolean"&&"data"in i}function getRoutePattern(i){let e=i.map(t=>t.route.path).filter(Boolean);return joinPaths(e)||"/"}var isBrowser=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function parseToInfo(i,e){let t=i;if(typeof t!="string"||!ABSOLUTE_URL_REGEX.test(t))return{absoluteURL:void 0,isExternal:!1,to:t};let n=t,s=!1;if(isBrowser)try{let a=new URL(window.location.href),u=PROTOCOL_RELATIVE_URL_REGEX.test(t)?new URL(normalizeProtocolRelativeUrl(t,a.protocol)):new URL(t),c=stripBasename(u.pathname,e);u.origin===a.origin&&c!=null?t=c+u.search+u.hash:s=!0}catch{warning(!1,`<Link to="${t}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:n,isExternal:s,to:t}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var validMutationMethodsArr=["POST","PUT","PATCH","DELETE"];new Set(validMutationMethodsArr);var validRequestMethodsArr=["GET",...validMutationMethodsArr];new Set(validRequestMethodsArr);var invalidProtocols=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function hasInvalidProtocol(i){try{return invalidProtocols.includes(new URL(i).protocol)}catch{return!1}}var DataRouterContext=reactExports.createContext(null);DataRouterContext.displayName="DataRouter";var DataRouterStateContext=reactExports.createContext(null);DataRouterStateContext.displayName="DataRouterState";var RSCRouterContext=reactExports.createContext(!1);function useIsRSCRouterContext(){return reactExports.useContext(RSCRouterContext)}var ViewTransitionContext=reactExports.createContext({isTransitioning:!1});ViewTransitionContext.displayName="ViewTransition";var FetchersContext=reactExports.createContext(new Map);FetchersContext.displayName="Fetchers";var AwaitContext=reactExports.createContext(null);AwaitContext.displayName="Await";var NavigationContext=reactExports.createContext(null);NavigationContext.displayName="Navigation";var LocationContext=reactExports.createContext(null);LocationContext.displayName="Location";var RouteContext=reactExports.createContext({outlet:null,matches:[],isDataRoute:!1});RouteContext.displayName="Route";var RouteErrorContext=reactExports.createContext(null);RouteErrorContext.displayName="RouteError";var ERROR_DIGEST_BASE="REACT_ROUTER_ERROR",ERROR_DIGEST_REDIRECT="REDIRECT",ERROR_DIGEST_ROUTE_ERROR_RESPONSE="ROUTE_ERROR_RESPONSE";function decodeRedirectErrorDigest(i){if(i.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:{`))try{let e=JSON.parse(i.slice(28));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.location=="string"&&typeof e.reloadDocument=="boolean"&&typeof e.replace=="boolean")return e}catch{}}function decodeRouteErrorResponseDigest(i){if(i.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:{`))try{let e=JSON.parse(i.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new ErrorResponseImpl(e.status,e.statusText,e.data)}catch{}}function useHref(i,{relative:e}={}){invariant(useInRouterContext(),"useHref() may be used only in the context of a <Router> component.");let{basename:t,navigator:n}=reactExports.useContext(NavigationContext),{hash:s,pathname:a,search:u}=useResolvedPath(i,{relative:e}),c=a;return t!=="/"&&(c=a==="/"?t:joinPaths([t,a])),n.createHref({pathname:c,search:u,hash:s})}function useInRouterContext(){return reactExports.useContext(LocationContext)!=null}function useLocation(){return invariant(useInRouterContext(),"useLocation() may be used only in the context of a <Router> component."),reactExports.useContext(LocationContext).location}var navigateEffectWarning="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function useIsomorphicLayoutEffect(i){reactExports.useContext(NavigationContext).static||reactExports.useLayoutEffect(i)}function useNavigate(){let{isDataRoute:i}=reactExports.useContext(RouteContext);return i?useNavigateStable():useNavigateUnstable()}function useNavigateUnstable(){invariant(useInRouterContext(),"useNavigate() may be used only in the context of a <Router> component.");let i=reactExports.useContext(DataRouterContext),{basename:e,navigator:t}=reactExports.useContext(NavigationContext),{matches:n}=reactExports.useContext(RouteContext),{pathname:s}=useLocation(),a=JSON.stringify(getResolveToMatches(n)),u=reactExports.useRef(!1);return useIsomorphicLayoutEffect(()=>{u.current=!0}),reactExports.useCallback((h,f={})=>{if(warning(u.current,navigateEffectWarning),!u.current)return;if(typeof h=="number"){t.go(h);return}let p=resolveTo(h,JSON.parse(a),s,f.relative==="path");i==null&&e!=="/"&&(p.pathname=p.pathname==="/"?e:joinPaths([e,p.pathname])),(f.replace?t.replace:t.push)(p,f.state,f)},[e,t,a,s,i])}var OutletContext=reactExports.createContext(null);function useOutlet(i){let e=reactExports.useContext(RouteContext).outlet;return reactExports.useMemo(()=>e&&reactExports.createElement(OutletContext.Provider,{value:i},e),[e,i])}function useResolvedPath(i,{relative:e}={}){let{matches:t}=reactExports.useContext(RouteContext),{pathname:n}=useLocation(),s=JSON.stringify(getResolveToMatches(t));return reactExports.useMemo(()=>resolveTo(i,JSON.parse(s),n,e==="path"),[i,s,n,e])}function useRoutes(i,e){return useRoutesImpl(i)}function useRoutesImpl(i,e,t){invariant(useInRouterContext(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:n}=reactExports.useContext(NavigationContext),{matches:s}=reactExports.useContext(RouteContext),a=s[s.length-1],u=a?a.params:{},c=a?a.pathname:"/",h=a?a.pathnameBase:"/",f=a&&a.route;{let T=f&&f.path||"";warningOnce(c,!f||T.endsWith("*")||T.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${T}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
11
+
12
+ Please change the parent <Route path="${T}"> to <Route path="${T==="/"?"*":`${T}/*`}">.`)}let p=useLocation(),g;g=p;let y=g.pathname||"/",S=y;if(h!=="/"){let T=h.replace(/^\//,"").split("/");S="/"+y.replace(/^\//,"").split("/").slice(T.length).join("/")}let w=t&&t.state.matches.length?t.state.matches.map(T=>Object.assign(T,{route:t.manifest[T.route.id]||T.route})):matchRoutes(i,{pathname:S});return warning(f||w!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),warning(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),_renderMatches(w&&w.map(T=>Object.assign({},T,{params:Object.assign({},u,T.params),pathname:joinPaths([h,n.encodeLocation?n.encodeLocation(T.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?h:joinPaths([h,n.encodeLocation?n.encodeLocation(T.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),s,t)}function DefaultErrorComponent(){let i=useRouteError(),e=isRouteErrorResponse(i)?`${i.status} ${i.statusText}`:i instanceof Error?i.message:JSON.stringify(i),t=i instanceof Error?i.stack:null,n="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:n},a={padding:"2px 4px",backgroundColor:n},u=null;return console.error("Error handled by React Router default ErrorBoundary:",i),u=reactExports.createElement(reactExports.Fragment,null,reactExports.createElement("p",null,"💿 Hey developer 👋"),reactExports.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",reactExports.createElement("code",{style:a},"ErrorBoundary")," or"," ",reactExports.createElement("code",{style:a},"errorElement")," prop on your route.")),reactExports.createElement(reactExports.Fragment,null,reactExports.createElement("h2",null,"Unexpected Application Error!"),reactExports.createElement("h3",{style:{fontStyle:"italic"}},e),t?reactExports.createElement("pre",{style:s},t):null,u)}var defaultErrorElement=reactExports.createElement(DefaultErrorComponent,null),RenderErrorBoundary=class extends reactExports.Component{constructor(i){super(i),this.state={location:i.location,revalidation:i.revalidation,error:i.error}}static getDerivedStateFromError(i){return{error:i}}static getDerivedStateFromProps(i,e){return e.location!==i.location||e.revalidation!=="idle"&&i.revalidation==="idle"?{error:i.error,location:i.location,revalidation:i.revalidation}:{error:i.error!==void 0?i.error:e.error,location:e.location,revalidation:i.revalidation||e.revalidation}}componentDidCatch(i,e){this.props.onError?this.props.onError(i,e):console.error("React Router caught the following error during render",i)}render(){let i=this.state.error;if(this.context&&typeof i=="object"&&i&&"digest"in i&&typeof i.digest=="string"){const t=decodeRouteErrorResponseDigest(i.digest);t&&(i=t)}let e=i!==void 0?reactExports.createElement(RouteContext.Provider,{value:this.props.routeContext},reactExports.createElement(RouteErrorContext.Provider,{value:i,children:this.props.component})):this.props.children;return this.context?reactExports.createElement(RSCErrorHandler,{error:i},e):e}};RenderErrorBoundary.contextType=RSCRouterContext;var errorRedirectHandledMap=new WeakMap;function RSCErrorHandler({children:i,error:e}){let{basename:t}=reactExports.useContext(NavigationContext);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let n=decodeRedirectErrorDigest(e.digest);if(n){let s=errorRedirectHandledMap.get(e);if(s)throw s;let a=parseToInfo(n.location,t),u=a.absoluteURL||a.to;if(hasInvalidProtocol(u))throw new Error("Invalid redirect location");if(isBrowser&&!errorRedirectHandledMap.get(e))if(a.isExternal||n.reloadDocument)window.location.href=u;else{const c=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:n.replace}));throw errorRedirectHandledMap.set(e,c),c}return reactExports.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u}`})}}return i}function RenderedRoute({routeContext:i,match:e,children:t}){let n=reactExports.useContext(DataRouterContext);return n&&n.static&&n.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=e.route.id),reactExports.createElement(RouteContext.Provider,{value:i},t)}function _renderMatches(i,e=[],t){let n=t?.state;if(i==null){if(!n)return null;if(n.errors)i=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)i=n.matches;else return null}let s=i,a=n?.errors;if(a!=null){let p=s.findIndex(g=>g.route.id&&a?.[g.route.id]!==void 0);invariant(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,p+1))}let u=!1,c=-1;if(t&&n){u=n.renderFallback;for(let p=0;p<s.length;p++){let g=s[p];if((g.route.HydrateFallback||g.route.hydrateFallbackElement)&&(c=p),g.route.id){let{loaderData:y,errors:S}=n,w=g.route.loader&&!y.hasOwnProperty(g.route.id)&&(!S||S[g.route.id]===void 0);if(g.route.lazy||w){t.isStatic&&(u=!0),c>=0?s=s.slice(0,c+1):s=[s[0]];break}}}}let h=t?.onError,f=n&&h?(p,g)=>{h(p,{location:n.location,params:n.matches?.[0]?.params??{},pattern:getRoutePattern(n.matches),errorInfo:g})}:void 0;return s.reduceRight((p,g,y)=>{let S,w=!1,R=null,T=null;n&&(S=a&&g.route.id?a[g.route.id]:void 0,R=g.route.errorElement||defaultErrorElement,u&&(c<0&&y===0?(warningOnce("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),w=!0,T=null):c===y&&(w=!0,T=g.route.hydrateFallbackElement||null)));let A=e.concat(s.slice(0,y+1)),F=()=>{let x;return S?x=R:w?x=T:g.route.Component?x=reactExports.createElement(g.route.Component,null):g.route.element?x=g.route.element:x=p,reactExports.createElement(RenderedRoute,{match:g,routeContext:{outlet:p,matches:A,isDataRoute:n!=null},children:x})};return n&&(g.route.ErrorBoundary||g.route.errorElement||y===0)?reactExports.createElement(RenderErrorBoundary,{location:n.location,revalidation:n.revalidation,component:R,error:S,children:F(),routeContext:{outlet:null,matches:A,isDataRoute:!0},onError:f}):F()},null)}function getDataRouterConsoleError(i){return`${i} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function useDataRouterContext(i){let e=reactExports.useContext(DataRouterContext);return invariant(e,getDataRouterConsoleError(i)),e}function useDataRouterState(i){let e=reactExports.useContext(DataRouterStateContext);return invariant(e,getDataRouterConsoleError(i)),e}function useRouteContext(i){let e=reactExports.useContext(RouteContext);return invariant(e,getDataRouterConsoleError(i)),e}function useCurrentRouteId(i){let e=useRouteContext(i),t=e.matches[e.matches.length-1];return invariant(t.route.id,`${i} can only be used on routes that contain a unique "id"`),t.route.id}function useRouteId(){return useCurrentRouteId("useRouteId")}function useRouteError(){let i=reactExports.useContext(RouteErrorContext),e=useDataRouterState("useRouteError"),t=useCurrentRouteId("useRouteError");return i!==void 0?i:e.errors?.[t]}function useNavigateStable(){let{router:i}=useDataRouterContext("useNavigate"),e=useCurrentRouteId("useNavigate"),t=reactExports.useRef(!1);return useIsomorphicLayoutEffect(()=>{t.current=!0}),reactExports.useCallback(async(s,a={})=>{warning(t.current,navigateEffectWarning),t.current&&(typeof s=="number"?await i.navigate(s):await i.navigate(s,{fromRouteId:e,...a}))},[i,e])}var alreadyWarned={};function warningOnce(i,e,t){!e&&!alreadyWarned[i]&&(alreadyWarned[i]=!0,warning(!1,t))}reactExports.memo(DataRoutes2);function DataRoutes2({routes:i,manifest:e,future:t,state:n,isStatic:s,onError:a}){return useRoutesImpl(i,void 0,{manifest:e,state:n,isStatic:s,onError:a})}function Navigate({to:i,replace:e,state:t,relative:n}){invariant(useInRouterContext(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=reactExports.useContext(NavigationContext);warning(!s,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=reactExports.useContext(RouteContext),{pathname:u}=useLocation(),c=useNavigate(),h=resolveTo(i,getResolveToMatches(a),u,n==="path"),f=JSON.stringify(h);return reactExports.useEffect(()=>{c(JSON.parse(f),{replace:e,state:t,relative:n})},[c,f,n,e,t]),null}function Outlet(i){return useOutlet(i.context)}function Router({basename:i="/",children:e=null,location:t,navigationType:n="POP",navigator:s,static:a=!1,useTransitions:u}){invariant(!useInRouterContext(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=i.replace(/^\/*/,"/"),h=reactExports.useMemo(()=>({basename:c,navigator:s,static:a,useTransitions:u,future:{}}),[c,s,a,u]);typeof t=="string"&&(t=parsePath(t));let{pathname:f="/",search:p="",hash:g="",state:y=null,key:S="default",mask:w}=t,R=reactExports.useMemo(()=>{let T=stripBasename(f,c);return T==null?null:{location:{pathname:T,search:p,hash:g,state:y,key:S,mask:w},navigationType:n}},[c,f,p,g,y,S,n,w]);return warning(R!=null,`<Router basename="${c}"> is not able to match the URL "${f}${p}${g}" because it does not start with the basename, so the <Router> won't render anything.`),R==null?null:reactExports.createElement(NavigationContext.Provider,{value:h},reactExports.createElement(LocationContext.Provider,{children:e,value:R}))}var defaultMethod="get",defaultEncType="application/x-www-form-urlencoded";function isHtmlElement(i){return typeof HTMLElement<"u"&&i instanceof HTMLElement}function isButtonElement(i){return isHtmlElement(i)&&i.tagName.toLowerCase()==="button"}function isFormElement(i){return isHtmlElement(i)&&i.tagName.toLowerCase()==="form"}function isInputElement(i){return isHtmlElement(i)&&i.tagName.toLowerCase()==="input"}function isModifiedEvent(i){return!!(i.metaKey||i.altKey||i.ctrlKey||i.shiftKey)}function shouldProcessLinkClick(i,e){return i.button===0&&(!e||e==="_self")&&!isModifiedEvent(i)}var _formDataSupportsSubmitter=null;function isFormDataSubmitterSupported(){if(_formDataSupportsSubmitter===null)try{new FormData(document.createElement("form"),0),_formDataSupportsSubmitter=!1}catch{_formDataSupportsSubmitter=!0}return _formDataSupportsSubmitter}var supportedFormEncTypes=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function getFormEncType(i){return i!=null&&!supportedFormEncTypes.has(i)?(warning(!1,`"${i}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`),null):i}function getFormSubmissionInfo(i,e){let t,n,s,a,u;if(isFormElement(i)){let c=i.getAttribute("action");n=c?stripBasename(c,e):null,t=i.getAttribute("method")||defaultMethod,s=getFormEncType(i.getAttribute("enctype"))||defaultEncType,a=new FormData(i)}else if(isButtonElement(i)||isInputElement(i)&&(i.type==="submit"||i.type==="image")){let c=i.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let h=i.getAttribute("formaction")||c.getAttribute("action");if(n=h?stripBasename(h,e):null,t=i.getAttribute("formmethod")||c.getAttribute("method")||defaultMethod,s=getFormEncType(i.getAttribute("formenctype"))||getFormEncType(c.getAttribute("enctype"))||defaultEncType,a=new FormData(c,i),!isFormDataSubmitterSupported()){let{name:f,type:p,value:g}=i;if(p==="image"){let y=f?`${f}.`:"";a.append(`${y}x`,"0"),a.append(`${y}y`,"0")}else f&&a.append(f,g)}}else{if(isHtmlElement(i))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=defaultMethod,n=null,s=defaultEncType,u=i}return a&&s==="text/plain"&&(u=a,a=void 0),{action:n,method:t.toLowerCase(),encType:s,formData:a,body:u}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function invariant2(i,e){if(i===!1||i===null||typeof i>"u")throw new Error(e)}function singleFetchUrl(i,e,t,n){let s=typeof i=="string"?new URL(i,typeof window>"u"?"server://singlefetch/":window.location.origin):i;return t?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${n}`:s.pathname=`${s.pathname}.${n}`:s.pathname==="/"?s.pathname=`_root.${n}`:e&&stripBasename(s.pathname,e)==="/"?s.pathname=`${removeTrailingSlash(e)}/_root.${n}`:s.pathname=`${removeTrailingSlash(s.pathname)}.${n}`,s}async function loadRouteModule(i,e){if(i.id in e)return e[i.id];try{let t=await import(i.module);return e[i.id]=t,t}catch(t){return console.error(`Error loading route module \`${i.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function isHtmlLinkDescriptor(i){return i==null?!1:i.href==null?i.rel==="preload"&&typeof i.imageSrcSet=="string"&&typeof i.imageSizes=="string":typeof i.rel=="string"&&typeof i.href=="string"}async function getKeyedPrefetchLinks(i,e,t){let n=await Promise.all(i.map(async s=>{let a=e.routes[s.route.id];if(a){let u=await loadRouteModule(a,t);return u.links?u.links():[]}return[]}));return dedupeLinkDescriptors(n.flat(1).filter(isHtmlLinkDescriptor).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function getNewMatchesForLinks(i,e,t,n,s,a){let u=(h,f)=>t[f]?h.route.id!==t[f].route.id:!0,c=(h,f)=>t[f].pathname!==h.pathname||t[f].route.path?.endsWith("*")&&t[f].params["*"]!==h.params["*"];return a==="assets"?e.filter((h,f)=>u(h,f)||c(h,f)):a==="data"?e.filter((h,f)=>{let p=n.routes[h.route.id];if(!p||!p.hasLoader)return!1;if(u(h,f)||c(h,f))return!0;if(h.route.shouldRevalidate){let g=h.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:t[0]?.params||{},nextUrl:new URL(i,window.origin),nextParams:h.params,defaultShouldRevalidate:!0});if(typeof g=="boolean")return g}return!0}):[]}function getModuleLinkHrefs(i,e,{includeHydrateFallback:t}={}){return dedupeHrefs(i.map(n=>{let s=e.routes[n.route.id];if(!s)return[];let a=[s.module];return s.clientActionModule&&(a=a.concat(s.clientActionModule)),s.clientLoaderModule&&(a=a.concat(s.clientLoaderModule)),t&&s.hydrateFallbackModule&&(a=a.concat(s.hydrateFallbackModule)),s.imports&&(a=a.concat(s.imports)),a}).flat(1))}function dedupeHrefs(i){return[...new Set(i)]}function sortKeys(i){let e={},t=Object.keys(i).sort();for(let n of t)e[n]=i[n];return e}function dedupeLinkDescriptors(i,e){let t=new Set;return new Set(e),i.reduce((n,s)=>{let a=JSON.stringify(sortKeys(s));return t.has(a)||(t.add(a),n.push({key:a,link:s})),n},[])}function useDataRouterContext2(){let i=reactExports.useContext(DataRouterContext);return invariant2(i,"You must render this element inside a <DataRouterContext.Provider> element"),i}function useDataRouterStateContext(){let i=reactExports.useContext(DataRouterStateContext);return invariant2(i,"You must render this element inside a <DataRouterStateContext.Provider> element"),i}var FrameworkContext=reactExports.createContext(void 0);FrameworkContext.displayName="FrameworkContext";function useFrameworkContext(){let i=reactExports.useContext(FrameworkContext);return invariant2(i,"You must render this element inside a <HydratedRouter> element"),i}function usePrefetchBehavior(i,e){let t=reactExports.useContext(FrameworkContext),[n,s]=reactExports.useState(!1),[a,u]=reactExports.useState(!1),{onFocus:c,onBlur:h,onMouseEnter:f,onMouseLeave:p,onTouchStart:g}=e,y=reactExports.useRef(null);reactExports.useEffect(()=>{if(i==="render"&&u(!0),i==="viewport"){let R=A=>{A.forEach(F=>{u(F.isIntersecting)})},T=new IntersectionObserver(R,{threshold:.5});return y.current&&T.observe(y.current),()=>{T.disconnect()}}},[i]),reactExports.useEffect(()=>{if(n){let R=setTimeout(()=>{u(!0)},100);return()=>{clearTimeout(R)}}},[n]);let S=()=>{s(!0)},w=()=>{s(!1),u(!1)};return t?i!=="intent"?[a,y,{}]:[a,y,{onFocus:composeEventHandlers(c,S),onBlur:composeEventHandlers(h,w),onMouseEnter:composeEventHandlers(f,S),onMouseLeave:composeEventHandlers(p,w),onTouchStart:composeEventHandlers(g,S)}]:[!1,y,{}]}function composeEventHandlers(i,e){return t=>{i&&i(t),t.defaultPrevented||e(t)}}function PrefetchPageLinks({page:i,...e}){let t=useIsRSCRouterContext(),{nonce:n}=useFrameworkContext(),{router:s}=useDataRouterContext2(),a=reactExports.useMemo(()=>matchRoutes(s.routes,i,s.basename),[s.routes,i,s.basename]);return a?(e.nonce==null&&n&&(e={...e,nonce:n}),t?reactExports.createElement(RSCPrefetchPageLinksImpl,{page:i,matches:a,...e}):reactExports.createElement(PrefetchPageLinksImpl,{page:i,matches:a,...e})):null}function useKeyedPrefetchLinks(i){let{manifest:e,routeModules:t}=useFrameworkContext(),[n,s]=reactExports.useState([]);return reactExports.useEffect(()=>{let a=!1;return getKeyedPrefetchLinks(i,e,t).then(u=>{a||s(u)}),()=>{a=!0}},[i,e,t]),n}function RSCPrefetchPageLinksImpl({page:i,matches:e,...t}){let n=useLocation(),{future:s}=useFrameworkContext(),{basename:a}=useDataRouterContext2(),u=reactExports.useMemo(()=>{if(i===n.pathname+n.search+n.hash)return[];let c=singleFetchUrl(i,a,s.v8_trailingSlashAwareDataRequests,"rsc"),h=!1,f=[];for(let p of e)typeof p.route.shouldRevalidate=="function"?h=!0:f.push(p.route.id);return h&&f.length>0&&c.searchParams.set("_routes",f.join(",")),[c.pathname+c.search]},[a,s.v8_trailingSlashAwareDataRequests,i,n,e]);return reactExports.createElement(reactExports.Fragment,null,u.map(c=>reactExports.createElement("link",{key:c,rel:"prefetch",as:"fetch",href:c,...t})))}function PrefetchPageLinksImpl({page:i,matches:e,...t}){let n=useLocation(),{future:s,manifest:a,routeModules:u}=useFrameworkContext(),{basename:c}=useDataRouterContext2(),{loaderData:h,matches:f}=useDataRouterStateContext(),p=reactExports.useMemo(()=>getNewMatchesForLinks(i,e,f,a,n,"data"),[i,e,f,a,n]),g=reactExports.useMemo(()=>getNewMatchesForLinks(i,e,f,a,n,"assets"),[i,e,f,a,n]),y=reactExports.useMemo(()=>{if(i===n.pathname+n.search+n.hash)return[];let R=new Set,T=!1;if(e.forEach(F=>{let x=a.routes[F.route.id];!x||!x.hasLoader||(!p.some(D=>D.route.id===F.route.id)&&F.route.id in h&&u[F.route.id]?.shouldRevalidate||x.hasClientLoader?T=!0:R.add(F.route.id))}),R.size===0)return[];let A=singleFetchUrl(i,c,s.v8_trailingSlashAwareDataRequests,"data");return T&&R.size>0&&A.searchParams.set("_routes",e.filter(F=>R.has(F.route.id)).map(F=>F.route.id).join(",")),[A.pathname+A.search]},[c,s.v8_trailingSlashAwareDataRequests,h,n,a,p,e,i,u]),S=reactExports.useMemo(()=>getModuleLinkHrefs(g,a),[g,a]),w=useKeyedPrefetchLinks(g);return reactExports.createElement(reactExports.Fragment,null,y.map(R=>reactExports.createElement("link",{key:R,rel:"prefetch",as:"fetch",href:R,...t})),S.map(R=>reactExports.createElement("link",{key:R,rel:"modulepreload",href:R,...t})),w.map(({key:R,link:T})=>reactExports.createElement("link",{key:R,nonce:t.nonce,...T,crossOrigin:T.crossOrigin??t.crossOrigin})))}function mergeRefs(...i){return e=>{i.forEach(t=>{typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var isBrowser2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{isBrowser2&&(window.__reactRouterVersion="7.18.2")}catch{}function BrowserRouter({basename:i,children:e,useTransitions:t,window:n}){let s=reactExports.useRef();s.current==null&&(s.current=createBrowserHistory({window:n,v5Compat:!0}));let a=s.current,[u,c]=reactExports.useState({action:a.action,location:a.location}),h=reactExports.useCallback(f=>{t===!1?c(f):reactExports.startTransition(()=>c(f))},[t]);return reactExports.useLayoutEffect(()=>a.listen(h),[a,h]),reactExports.createElement(Router,{basename:i,children:e,location:u.location,navigationType:u.action,navigator:a,useTransitions:t})}var Link=reactExports.forwardRef(function({onClick:e,discover:t="render",prefetch:n="none",relative:s,reloadDocument:a,replace:u,mask:c,state:h,target:f,to:p,preventScrollReset:g,viewTransition:y,defaultShouldRevalidate:S,...w},R){let{basename:T,navigator:A,useTransitions:F}=reactExports.useContext(NavigationContext),x=typeof p=="string"&&ABSOLUTE_URL_REGEX.test(p),D=parseToInfo(p,T);p=D.to;let O=useHref(p,{relative:s}),K=useLocation(),z=null;if(c){let ze=resolveTo(c,[],K.mask?K.mask.pathname:"/",!0);T!=="/"&&(ze.pathname=ze.pathname==="/"?T:joinPaths([T,ze.pathname])),z=A.createHref(ze)}let[X,Ee,q]=usePrefetchBehavior(n,w),Y=useLinkClickHandler(p,{replace:u,mask:c,state:h,target:f,preventScrollReset:g,relative:s,viewTransition:y,defaultShouldRevalidate:S,useTransitions:F});function Te(ze){e&&e(ze),ze.defaultPrevented||Y(ze)}let re=!(D.isExternal||a),$e=reactExports.createElement("a",{...w,...q,href:(re?z:void 0)||D.absoluteURL||O,onClick:re?Te:e,ref:mergeRefs(R,Ee),target:f,"data-discover":!x&&t==="render"?"true":void 0});return X&&!x?reactExports.createElement(reactExports.Fragment,null,$e,reactExports.createElement(PrefetchPageLinks,{page:O})):$e});Link.displayName="Link";var NavLink=reactExports.forwardRef(function({"aria-current":e="page",caseSensitive:t=!1,className:n="",end:s=!1,style:a,to:u,viewTransition:c,children:h,...f},p){let g=useResolvedPath(u,{relative:f.relative}),y=useLocation(),S=reactExports.useContext(DataRouterStateContext),{navigator:w,basename:R}=reactExports.useContext(NavigationContext),T=S!=null&&useViewTransitionState(g)&&c===!0,A=w.encodeLocation?w.encodeLocation(g).pathname:g.pathname,F=y.pathname,x=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;t||(F=F.toLowerCase(),x=x?x.toLowerCase():null,A=A.toLowerCase()),x&&R&&(x=stripBasename(x,R)||x);const D=A!=="/"&&A.endsWith("/")?A.length-1:A.length;let O=F===A||!s&&F.startsWith(A)&&F.charAt(D)==="/",K=x!=null&&(x===A||!s&&x.startsWith(A)&&x.charAt(A.length)==="/"),z={isActive:O,isPending:K,isTransitioning:T},X=O?e:void 0,Ee;typeof n=="function"?Ee=n(z):Ee=[n,O?"active":null,K?"pending":null,T?"transitioning":null].filter(Boolean).join(" ");let q=typeof a=="function"?a(z):a;return reactExports.createElement(Link,{...f,"aria-current":X,className:Ee,ref:p,style:q,to:u,viewTransition:c},typeof h=="function"?h(z):h)});NavLink.displayName="NavLink";var Form=reactExports.forwardRef(({discover:i="render",fetcherKey:e,navigate:t,reloadDocument:n,replace:s,state:a,method:u=defaultMethod,action:c,onSubmit:h,relative:f,preventScrollReset:p,viewTransition:g,defaultShouldRevalidate:y,...S},w)=>{let{useTransitions:R}=reactExports.useContext(NavigationContext),T=useSubmit(),A=useFormAction(c,{relative:f}),F=u.toLowerCase()==="get"?"get":"post",x=typeof c=="string"&&ABSOLUTE_URL_REGEX.test(c),D=O=>{if(h&&h(O),O.defaultPrevented)return;O.preventDefault();let K=O.nativeEvent.submitter,z=K?.getAttribute("formmethod")||u,X=()=>T(K||O.currentTarget,{fetcherKey:e,method:z,navigate:t,replace:s,state:a,relative:f,preventScrollReset:p,viewTransition:g,defaultShouldRevalidate:y});R&&t!==!1?reactExports.startTransition(()=>X()):X()};return reactExports.createElement("form",{ref:w,method:F,action:A,onSubmit:n?h:D,...S,"data-discover":!x&&i==="render"?"true":void 0})});Form.displayName="Form";function getDataRouterConsoleError2(i){return`${i} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function useDataRouterContext3(i){let e=reactExports.useContext(DataRouterContext);return invariant(e,getDataRouterConsoleError2(i)),e}function useLinkClickHandler(i,{target:e,replace:t,mask:n,state:s,preventScrollReset:a,relative:u,viewTransition:c,defaultShouldRevalidate:h,useTransitions:f}={}){let p=useNavigate(),g=useLocation(),y=useResolvedPath(i,{relative:u});return reactExports.useCallback(S=>{if(shouldProcessLinkClick(S,e)){S.preventDefault();let w=t!==void 0?t:createPath(g)===createPath(y),R=()=>p(i,{replace:w,mask:n,state:s,preventScrollReset:a,relative:u,viewTransition:c,defaultShouldRevalidate:h});f?reactExports.startTransition(()=>R()):R()}},[g,p,y,t,n,s,e,i,a,u,c,h,f])}var fetcherId=0,getUniqueFetcherId=()=>`__${String(++fetcherId)}__`;function useSubmit(){let{router:i}=useDataRouterContext3("useSubmit"),{basename:e}=reactExports.useContext(NavigationContext),t=useRouteId(),n=i.fetch,s=i.navigate;return reactExports.useCallback(async(a,u={})=>{let{action:c,method:h,encType:f,formData:p,body:g}=getFormSubmissionInfo(a,e);if(u.navigate===!1){let y=u.fetcherKey||getUniqueFetcherId();await n(y,t,u.action||c,{defaultShouldRevalidate:u.defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:p,body:g,formMethod:u.method||h,formEncType:u.encType||f,flushSync:u.flushSync})}else await s(u.action||c,{defaultShouldRevalidate:u.defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:p,body:g,formMethod:u.method||h,formEncType:u.encType||f,replace:u.replace,state:u.state,fromRouteId:t,flushSync:u.flushSync,viewTransition:u.viewTransition})},[n,s,e,t])}function useFormAction(i,{relative:e}={}){let{basename:t}=reactExports.useContext(NavigationContext),n=reactExports.useContext(RouteContext);invariant(n,"useFormAction must be used inside a RouteContext");let[s]=n.matches.slice(-1),a={...useResolvedPath(i||".",{relative:e})},u=useLocation();if(i==null){a.search=u.search;let c=new URLSearchParams(a.search),h=c.getAll("index");if(h.some(p=>p==="")){c.delete("index"),h.filter(g=>g).forEach(g=>c.append("index",g));let p=c.toString();a.search=p?`?${p}`:""}}return(!i||i===".")&&s.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(a.pathname=a.pathname==="/"?t:joinPaths([t,a.pathname])),createPath(a)}function useViewTransitionState(i,{relative:e}={}){let t=reactExports.useContext(ViewTransitionContext);invariant(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=useDataRouterContext3("useViewTransitionState"),s=useResolvedPath(i,{relative:e});if(!t.isTransitioning)return!1;let a=stripBasename(t.currentLocation.pathname,n)||t.currentLocation.pathname,u=stripBasename(t.nextLocation.pathname,n)||t.nextLocation.pathname;return matchPath(s.pathname,u)!=null||matchPath(s.pathname,a)!=null}const scriptRel="modulepreload",assetsURL=function(i){return"/settings/"+i},seen={},__vitePreload=function(e,t,n){let s=Promise.resolve();if(t&&t.length>0){let h=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),c=u?.nonce||u?.getAttribute("nonce");s=h(t.map(f=>{if(f=assetsURL(f),f in seen)return;seen[f]=!0;const p=f.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${g}`))return;const y=document.createElement("link");if(y.rel=p?"stylesheet":scriptRel,p||(y.as="script"),y.crossOrigin="",y.href=f,c&&y.setAttribute("nonce",c),document.head.appendChild(y),p)return new Promise((S,w)=>{y.addEventListener("load",S),y.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function a(u){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=u,window.dispatchEvent(c),!c.defaultPrevented)throw u}return s.then(u=>{for(const c of u||[])c.status==="rejected"&&a(c.reason);return e().catch(a)})};const mergeClasses=(...i)=>i.filter((e,t,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===t).join(" ").trim();const toKebabCase=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const toCamelCase=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase());const toPascalCase=i=>{const e=toCamelCase(i);return e.charAt(0).toUpperCase()+e.slice(1)};var defaultAttributes={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const hasA11yProp=i=>{for(const e in i)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Icon=reactExports.forwardRef(({color:i="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:u,...c},h)=>reactExports.createElement("svg",{ref:h,...defaultAttributes,width:e,height:e,stroke:i,strokeWidth:n?Number(t)*24/Number(e):t,className:mergeClasses("lucide",s),...!a&&!hasA11yProp(c)&&{"aria-hidden":"true"},...c},[...u.map(([f,p])=>reactExports.createElement(f,p)),...Array.isArray(a)?a:[a]]));const createLucideIcon=(i,e)=>{const t=reactExports.forwardRef(({className:n,...s},a)=>reactExports.createElement(Icon,{ref:a,iconNode:e,className:mergeClasses(`lucide-${toKebabCase(toPascalCase(i))}`,`lucide-${i}`,n),...s}));return t.displayName=toPascalCase(i),t};const __iconNode$3=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Bot=createLucideIcon("bot",__iconNode$3);const __iconNode$2=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Box=createLucideIcon("box",__iconNode$2);const __iconNode$1=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Network=createLucideIcon("network",__iconNode$1);const __iconNode=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Server=createLucideIcon("server",__iconNode),settingsNavigationItems=[{id:"models",label:"Models",path:"/models",description:"Model providers, default models, API keys, and inference preferences.",keywords:["ai","llm","provider","model","api key"],icon:Bot},{id:"pod",label:"Pod",path:"/pod",description:"Pod storage, profile, identity, and data access settings.",keywords:["solid","storage","profile","webid","data"],icon:Box},{id:"network",label:"Network",path:"/network",description:"Network endpoints, DNS, domains, tunnels, and connectivity.",keywords:["dns","domain","tunnel","endpoint","connection"],icon:Network},{id:"services",label:"Services",path:"/services",description:"Runtime services, logs, RDF indexing, diagnostics, and restart controls.",keywords:["runtime","logs","rdf","diagnostics","status"],icon:Server}];function r(i){var e,t,n="";if(typeof i=="string"||typeof i=="number")n+=i;else if(typeof i=="object")if(Array.isArray(i)){var s=i.length;for(e=0;e<s;e++)i[e]&&(t=r(i[e]))&&(n&&(n+=" "),n+=t)}else for(t in i)i[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var i,e,t=0,n="",s=arguments.length;t<s;t++)(i=arguments[t])&&(e=r(i))&&(n&&(n+=" "),n+=e);return n}const falsyToString=i=>typeof i=="boolean"?`${i}`:i===0?"0":i,cx=clsx,cva=(i,e)=>t=>{var n;if(e?.variants==null)return cx(i,t?.class,t?.className);const{variants:s,defaultVariants:a}=e,u=Object.keys(s).map(f=>{const p=t?.[f],g=a?.[f];if(p===null)return null;const y=falsyToString(p)||falsyToString(g);return s[f][y]}),c=t&&Object.entries(t).reduce((f,p)=>{let[g,y]=p;return y===void 0||(f[g]=y),f},{}),h=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((f,p)=>{let{class:g,className:y,...S}=p;return Object.entries(S).every(w=>{let[R,T]=w;return Array.isArray(T)?T.includes({...a,...c}[R]):{...a,...c}[R]===T})?[...f,g,y]:f},[]);return cx(i,u,h,t?.class,t?.className)},concatArrays=(i,e)=>{const t=new Array(i.length+e.length);for(let n=0;n<i.length;n++)t[n]=i[n];for(let n=0;n<e.length;n++)t[i.length+n]=e[n];return t},createClassValidatorObject=(i,e)=>({classGroupId:i,validator:e}),createClassPartObject=(i=new Map,e=null,t)=>({nextPart:i,validators:e,classGroupId:t}),CLASS_PART_SEPARATOR="-",EMPTY_CONFLICTS=[],ARBITRARY_PROPERTY_PREFIX="arbitrary..",createClassGroupUtils=i=>{const e=createClassMap(i),{conflictingClassGroups:t,conflictingClassGroupModifiers:n}=i;return{getClassGroupId:u=>{if(u.startsWith("[")&&u.endsWith("]"))return getGroupIdForArbitraryProperty(u);const c=u.split(CLASS_PART_SEPARATOR),h=c[0]===""&&c.length>1?1:0;return getGroupRecursive(c,h,e)},getConflictingClassGroupIds:(u,c)=>{if(c){const h=n[u],f=t[u];return h?f?concatArrays(f,h):h:f||EMPTY_CONFLICTS}return t[u]||EMPTY_CONFLICTS}}},getGroupRecursive=(i,e,t)=>{if(i.length-e===0)return t.classGroupId;const s=i[e],a=t.nextPart.get(s);if(a){const f=getGroupRecursive(i,e+1,a);if(f)return f}const u=t.validators;if(u===null)return;const c=e===0?i.join(CLASS_PART_SEPARATOR):i.slice(e).join(CLASS_PART_SEPARATOR),h=u.length;for(let f=0;f<h;f++){const p=u[f];if(p.validator(c))return p.classGroupId}},getGroupIdForArbitraryProperty=i=>i.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=i.slice(1,-1),t=e.indexOf(":"),n=e.slice(0,t);return n?ARBITRARY_PROPERTY_PREFIX+n:void 0})(),createClassMap=i=>{const{theme:e,classGroups:t}=i;return processClassGroups(t,e)},processClassGroups=(i,e)=>{const t=createClassPartObject();for(const n in i){const s=i[n];processClassesRecursively(s,t,n,e)}return t},processClassesRecursively=(i,e,t,n)=>{const s=i.length;for(let a=0;a<s;a++){const u=i[a];processClassDefinition(u,e,t,n)}},processClassDefinition=(i,e,t,n)=>{if(typeof i=="string"){processStringDefinition(i,e,t);return}if(typeof i=="function"){processFunctionDefinition(i,e,t,n);return}processObjectDefinition(i,e,t,n)},processStringDefinition=(i,e,t)=>{const n=i===""?e:getPart(e,i);n.classGroupId=t},processFunctionDefinition=(i,e,t,n)=>{if(isThemeGetter(i)){processClassesRecursively(i(n),e,t,n);return}e.validators===null&&(e.validators=[]),e.validators.push(createClassValidatorObject(t,i))},processObjectDefinition=(i,e,t,n)=>{const s=Object.entries(i),a=s.length;for(let u=0;u<a;u++){const[c,h]=s[u];processClassesRecursively(h,getPart(e,c),t,n)}},getPart=(i,e)=>{let t=i;const n=e.split(CLASS_PART_SEPARATOR),s=n.length;for(let a=0;a<s;a++){const u=n[a];let c=t.nextPart.get(u);c||(c=createClassPartObject(),t.nextPart.set(u,c)),t=c}return t},isThemeGetter=i=>"isThemeGetter"in i&&i.isThemeGetter===!0,createLruCache=i=>{if(i<1)return{get:()=>{},set:()=>{}};let e=0,t=Object.create(null),n=Object.create(null);const s=(a,u)=>{t[a]=u,e++,e>i&&(e=0,n=t,t=Object.create(null))};return{get(a){let u=t[a];if(u!==void 0)return u;if((u=n[a])!==void 0)return s(a,u),u},set(a,u){a in t?t[a]=u:s(a,u)}}},IMPORTANT_MODIFIER="!",MODIFIER_SEPARATOR=":",EMPTY_MODIFIERS=[],createResultObject=(i,e,t,n,s)=>({modifiers:i,hasImportantModifier:e,baseClassName:t,maybePostfixModifierPosition:n,isExternal:s}),createParseClassName=i=>{const{prefix:e,experimentalParseClassName:t}=i;let n=s=>{const a=[];let u=0,c=0,h=0,f;const p=s.length;for(let R=0;R<p;R++){const T=s[R];if(u===0&&c===0){if(T===MODIFIER_SEPARATOR){a.push(s.slice(h,R)),h=R+1;continue}if(T==="/"){f=R;continue}}T==="["?u++:T==="]"?u--:T==="("?c++:T===")"&&c--}const g=a.length===0?s:s.slice(h);let y=g,S=!1;g.endsWith(IMPORTANT_MODIFIER)?(y=g.slice(0,-1),S=!0):g.startsWith(IMPORTANT_MODIFIER)&&(y=g.slice(1),S=!0);const w=f&&f>h?f-h:void 0;return createResultObject(a,S,y,w)};if(e){const s=e+MODIFIER_SEPARATOR,a=n;n=u=>u.startsWith(s)?a(u.slice(s.length)):createResultObject(EMPTY_MODIFIERS,!1,u,void 0,!0)}if(t){const s=n;n=a=>t({className:a,parseClassName:s})}return n},createSortModifiers=i=>{const e=new Map;return i.orderSensitiveModifiers.forEach((t,n)=>{e.set(t,1e6+n)}),t=>{const n=[];let s=[];for(let a=0;a<t.length;a++){const u=t[a],c=u[0]==="[",h=e.has(u);c||h?(s.length>0&&(s.sort(),n.push(...s),s=[]),n.push(u)):s.push(u)}return s.length>0&&(s.sort(),n.push(...s)),n}},createConfigUtils=i=>({cache:createLruCache(i.cacheSize),parseClassName:createParseClassName(i),sortModifiers:createSortModifiers(i),postfixLookupClassGroupIds:createPostfixLookupClassGroupIds(i),...createClassGroupUtils(i)}),createPostfixLookupClassGroupIds=i=>{const e=Object.create(null),t=i.postfixLookupClassGroups;if(t)for(let n=0;n<t.length;n++)e[t[n]]=!0;return e},SPLIT_CLASSES_REGEX=/\s+/,mergeClassList=(i,e)=>{const{parseClassName:t,getClassGroupId:n,getConflictingClassGroupIds:s,sortModifiers:a,postfixLookupClassGroupIds:u}=e,c=[],h=i.trim().split(SPLIT_CLASSES_REGEX);let f="";for(let p=h.length-1;p>=0;p-=1){const g=h[p],{isExternal:y,modifiers:S,hasImportantModifier:w,baseClassName:R,maybePostfixModifierPosition:T}=t(g);if(y){f=g+(f.length>0?" "+f:f);continue}let A=!!T,F;if(A){const z=R.substring(0,T);F=n(z);const X=F&&u[F]?n(R):void 0;X&&X!==F&&(F=X,A=!1)}else F=n(R);if(!F){if(!A){f=g+(f.length>0?" "+f:f);continue}if(F=n(R),!F){f=g+(f.length>0?" "+f:f);continue}A=!1}const x=S.length===0?"":S.length===1?S[0]:a(S).join(":"),D=w?x+IMPORTANT_MODIFIER:x,O=D+F;if(c.indexOf(O)>-1)continue;c.push(O);const K=s(F,A);for(let z=0;z<K.length;++z){const X=K[z];c.push(D+X)}f=g+(f.length>0?" "+f:f)}return f},twJoin=(...i)=>{let e=0,t,n,s="";for(;e<i.length;)(t=i[e++])&&(n=toValue(t))&&(s&&(s+=" "),s+=n);return s},toValue=i=>{if(typeof i=="string")return i;let e,t="";for(let n=0;n<i.length;n++)i[n]&&(e=toValue(i[n]))&&(t&&(t+=" "),t+=e);return t},createTailwindMerge=(i,...e)=>{let t,n,s,a;const u=h=>{const f=e.reduce((p,g)=>g(p),i());return t=createConfigUtils(f),n=t.cache.get,s=t.cache.set,a=c,c(h)},c=h=>{const f=n(h);if(f)return f;const p=mergeClassList(h,t);return s(h,p),p};return a=u,(...h)=>a(twJoin(...h))},fallbackThemeArr=[],fromTheme=i=>{const e=t=>t[i]||fallbackThemeArr;return e.isThemeGetter=!0,e},arbitraryValueRegex=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,arbitraryVariableRegex=/^\((?:(\w[\w-]*):)?(.+)\)$/i,fractionRegex=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,tshirtUnitRegex=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lengthUnitRegex=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,colorFunctionRegex=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,shadowRegex=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,imageRegex=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,isFraction=i=>fractionRegex.test(i),isNumber=i=>!!i&&!Number.isNaN(Number(i)),isInteger=i=>!!i&&Number.isInteger(Number(i)),isPercent=i=>i.endsWith("%")&&isNumber(i.slice(0,-1)),isTshirtSize=i=>tshirtUnitRegex.test(i),isAny=()=>!0,isLengthOnly=i=>lengthUnitRegex.test(i)&&!colorFunctionRegex.test(i),isNever=()=>!1,isShadow=i=>shadowRegex.test(i),isImage=i=>imageRegex.test(i),isAnyNonArbitrary=i=>!isArbitraryValue(i)&&!isArbitraryVariable(i),isNamedContainerQuery=i=>i.startsWith("@container")&&(i[10]==="/"&&i[11]!==void 0||i[11]==="s"&&i[16]!==void 0&&i.startsWith("-size/",10)||i[11]==="n"&&i[18]!==void 0&&i.startsWith("-normal/",10)),isArbitrarySize=i=>getIsArbitraryValue(i,isLabelSize,isNever),isArbitraryValue=i=>arbitraryValueRegex.test(i),isArbitraryLength=i=>getIsArbitraryValue(i,isLabelLength,isLengthOnly),isArbitraryNumber=i=>getIsArbitraryValue(i,isLabelNumber,isNumber),isArbitraryWeight=i=>getIsArbitraryValue(i,isLabelWeight,isAny),isArbitraryFamilyName=i=>getIsArbitraryValue(i,isLabelFamilyName,isNever),isArbitraryPosition=i=>getIsArbitraryValue(i,isLabelPosition,isNever),isArbitraryImage=i=>getIsArbitraryValue(i,isLabelImage,isImage),isArbitraryShadow=i=>getIsArbitraryValue(i,isLabelShadow,isShadow),isArbitraryVariable=i=>arbitraryVariableRegex.test(i),isArbitraryVariableLength=i=>getIsArbitraryVariable(i,isLabelLength),isArbitraryVariableFamilyName=i=>getIsArbitraryVariable(i,isLabelFamilyName),isArbitraryVariablePosition=i=>getIsArbitraryVariable(i,isLabelPosition),isArbitraryVariableSize=i=>getIsArbitraryVariable(i,isLabelSize),isArbitraryVariableImage=i=>getIsArbitraryVariable(i,isLabelImage),isArbitraryVariableShadow=i=>getIsArbitraryVariable(i,isLabelShadow,!0),isArbitraryVariableWeight=i=>getIsArbitraryVariable(i,isLabelWeight,!0),getIsArbitraryValue=(i,e,t)=>{const n=arbitraryValueRegex.exec(i);return n?n[1]?e(n[1]):t(n[2]):!1},getIsArbitraryVariable=(i,e,t=!1)=>{const n=arbitraryVariableRegex.exec(i);return n?n[1]?e(n[1]):t:!1},isLabelPosition=i=>i==="position"||i==="percentage",isLabelImage=i=>i==="image"||i==="url",isLabelSize=i=>i==="length"||i==="size"||i==="bg-size",isLabelLength=i=>i==="length",isLabelNumber=i=>i==="number",isLabelFamilyName=i=>i==="family-name",isLabelWeight=i=>i==="number"||i==="weight",isLabelShadow=i=>i==="shadow",getDefaultConfig=()=>{const i=fromTheme("color"),e=fromTheme("font"),t=fromTheme("text"),n=fromTheme("font-weight"),s=fromTheme("tracking"),a=fromTheme("leading"),u=fromTheme("breakpoint"),c=fromTheme("container"),h=fromTheme("spacing"),f=fromTheme("radius"),p=fromTheme("shadow"),g=fromTheme("inset-shadow"),y=fromTheme("text-shadow"),S=fromTheme("drop-shadow"),w=fromTheme("blur"),R=fromTheme("perspective"),T=fromTheme("aspect"),A=fromTheme("ease"),F=fromTheme("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],D=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...D(),isArbitraryVariable,isArbitraryValue],K=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto","contain","none"],X=()=>[isArbitraryVariable,isArbitraryValue,h],Ee=()=>[isFraction,"full","auto",...X()],q=()=>[isInteger,"none","subgrid",isArbitraryVariable,isArbitraryValue],Y=()=>["auto",{span:["full",isInteger,isArbitraryVariable,isArbitraryValue]},isInteger,isArbitraryVariable,isArbitraryValue],Te=()=>[isInteger,"auto",isArbitraryVariable,isArbitraryValue],re=()=>["auto","min","max","fr",isArbitraryVariable,isArbitraryValue],$e=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ze=()=>["start","end","center","stretch","center-safe","end-safe"],ye=()=>["auto",...X()],Ve=()=>[isFraction,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...X()],pe=()=>[isFraction,"screen","full","dvw","lvw","svw","min","max","fit",...X()],De=()=>[isFraction,"screen","full","lh","dvh","lvh","svh","min","max","fit",...X()],$=()=>[i,isArbitraryVariable,isArbitraryValue],G=()=>[...D(),isArbitraryVariablePosition,isArbitraryPosition,{position:[isArbitraryVariable,isArbitraryValue]}],ce=()=>["no-repeat",{repeat:["","x","y","space","round"]}],oe=()=>["auto","cover","contain",isArbitraryVariableSize,isArbitrarySize,{size:[isArbitraryVariable,isArbitraryValue]}],Fe=()=>[isPercent,isArbitraryVariableLength,isArbitraryLength],Ue=()=>["","none","full",f,isArbitraryVariable,isArbitraryValue],Je=()=>["",isNumber,isArbitraryVariableLength,isArbitraryLength],He=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],fe=()=>[isNumber,isPercent,isArbitraryVariablePosition,isArbitraryPosition],Oe=()=>["","none",w,isArbitraryVariable,isArbitraryValue],ie=()=>["none",isNumber,isArbitraryVariable,isArbitraryValue],j=()=>["none",isNumber,isArbitraryVariable,isArbitraryValue],N=()=>[isNumber,isArbitraryVariable,isArbitraryValue],L=()=>[isFraction,"full",...X()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[isTshirtSize],breakpoint:[isTshirtSize],color:[isAny],container:[isTshirtSize],"drop-shadow":[isTshirtSize],ease:["in","out","in-out"],font:[isAnyNonArbitrary],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[isTshirtSize],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[isTshirtSize],shadow:[isTshirtSize],spacing:["px",isNumber],text:[isTshirtSize],"text-shadow":[isTshirtSize],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",isFraction,isArbitraryValue,isArbitraryVariable,T]}],container:["container"],"container-type":[{"@container":["","normal","size",isArbitraryVariable,isArbitraryValue]}],"container-named":[isNamedContainerQuery],columns:[{columns:[isNumber,isArbitraryValue,isArbitraryVariable,c]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:O()}],overflow:[{overflow:K()}],"overflow-x":[{"overflow-x":K()}],"overflow-y":[{"overflow-y":K()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:Ee()}],"inset-x":[{"inset-x":Ee()}],"inset-y":[{"inset-y":Ee()}],start:[{"inset-s":Ee(),start:Ee()}],end:[{"inset-e":Ee(),end:Ee()}],"inset-bs":[{"inset-bs":Ee()}],"inset-be":[{"inset-be":Ee()}],top:[{top:Ee()}],right:[{right:Ee()}],bottom:[{bottom:Ee()}],left:[{left:Ee()}],visibility:["visible","invisible","collapse"],z:[{z:[isInteger,"auto",isArbitraryVariable,isArbitraryValue]}],basis:[{basis:[isFraction,"full","auto",c,...X()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[isNumber,isFraction,"auto","initial","none",isArbitraryValue]}],grow:[{grow:["",isNumber,isArbitraryVariable,isArbitraryValue]}],shrink:[{shrink:["",isNumber,isArbitraryVariable,isArbitraryValue]}],order:[{order:[isInteger,"first","last","none",isArbitraryVariable,isArbitraryValue]}],"grid-cols":[{"grid-cols":q()}],"col-start-end":[{col:Y()}],"col-start":[{"col-start":Te()}],"col-end":[{"col-end":Te()}],"grid-rows":[{"grid-rows":q()}],"row-start-end":[{row:Y()}],"row-start":[{"row-start":Te()}],"row-end":[{"row-end":Te()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:X()}],"gap-x":[{"gap-x":X()}],"gap-y":[{"gap-y":X()}],"justify-content":[{justify:[...$e(),"normal"]}],"justify-items":[{"justify-items":[...ze(),"normal"]}],"justify-self":[{"justify-self":["auto",...ze()]}],"align-content":[{content:["normal",...$e()]}],"align-items":[{items:[...ze(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ze(),{baseline:["","last"]}]}],"place-content":[{"place-content":$e()}],"place-items":[{"place-items":[...ze(),"baseline"]}],"place-self":[{"place-self":["auto",...ze()]}],p:[{p:X()}],px:[{px:X()}],py:[{py:X()}],ps:[{ps:X()}],pe:[{pe:X()}],pbs:[{pbs:X()}],pbe:[{pbe:X()}],pt:[{pt:X()}],pr:[{pr:X()}],pb:[{pb:X()}],pl:[{pl:X()}],m:[{m:ye()}],mx:[{mx:ye()}],my:[{my:ye()}],ms:[{ms:ye()}],me:[{me:ye()}],mbs:[{mbs:ye()}],mbe:[{mbe:ye()}],mt:[{mt:ye()}],mr:[{mr:ye()}],mb:[{mb:ye()}],ml:[{ml:ye()}],"space-x":[{"space-x":X()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":X()}],"space-y-reverse":["space-y-reverse"],size:[{size:Ve()}],"inline-size":[{inline:["auto",...pe()]}],"min-inline-size":[{"min-inline":["auto",...pe()]}],"max-inline-size":[{"max-inline":["none",...pe()]}],"block-size":[{block:["auto",...De()]}],"min-block-size":[{"min-block":["auto",...De()]}],"max-block-size":[{"max-block":["none",...De()]}],w:[{w:[c,"screen",...Ve()]}],"min-w":[{"min-w":[c,"screen","none",...Ve()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[u]},...Ve()]}],h:[{h:["screen","lh",...Ve()]}],"min-h":[{"min-h":["screen","lh","none",...Ve()]}],"max-h":[{"max-h":["screen","lh",...Ve()]}],"font-size":[{text:["base",t,isArbitraryVariableLength,isArbitraryLength]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,isArbitraryVariableWeight,isArbitraryWeight]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",isPercent,isArbitraryValue]}],"font-family":[{font:[isArbitraryVariableFamilyName,isArbitraryFamilyName,e]}],"font-features":[{"font-features":[isArbitraryValue]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,isArbitraryVariable,isArbitraryValue]}],"line-clamp":[{"line-clamp":[isNumber,"none",isArbitraryVariable,isArbitraryNumber]}],leading:[{leading:[a,...X()]}],"list-image":[{"list-image":["none",isArbitraryVariable,isArbitraryValue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",isArbitraryVariable,isArbitraryValue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...He(),"wavy"]}],"text-decoration-thickness":[{decoration:[isNumber,"from-font","auto",isArbitraryVariable,isArbitraryLength]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[isNumber,"auto",isArbitraryVariable,isArbitraryValue]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:X()}],"tab-size":[{tab:[isInteger,isArbitraryVariable,isArbitraryValue]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",isArbitraryVariable,isArbitraryValue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",isArbitraryVariable,isArbitraryValue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:G()}],"bg-repeat":[{bg:ce()}],"bg-size":[{bg:oe()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},isInteger,isArbitraryVariable,isArbitraryValue],radial:["",isArbitraryVariable,isArbitraryValue],conic:[isInteger,isArbitraryVariable,isArbitraryValue]},isArbitraryVariableImage,isArbitraryImage]}],"bg-color":[{bg:$()}],"gradient-from-pos":[{from:Fe()}],"gradient-via-pos":[{via:Fe()}],"gradient-to-pos":[{to:Fe()}],"gradient-from":[{from:$()}],"gradient-via":[{via:$()}],"gradient-to":[{to:$()}],rounded:[{rounded:Ue()}],"rounded-s":[{"rounded-s":Ue()}],"rounded-e":[{"rounded-e":Ue()}],"rounded-t":[{"rounded-t":Ue()}],"rounded-r":[{"rounded-r":Ue()}],"rounded-b":[{"rounded-b":Ue()}],"rounded-l":[{"rounded-l":Ue()}],"rounded-ss":[{"rounded-ss":Ue()}],"rounded-se":[{"rounded-se":Ue()}],"rounded-ee":[{"rounded-ee":Ue()}],"rounded-es":[{"rounded-es":Ue()}],"rounded-tl":[{"rounded-tl":Ue()}],"rounded-tr":[{"rounded-tr":Ue()}],"rounded-br":[{"rounded-br":Ue()}],"rounded-bl":[{"rounded-bl":Ue()}],"border-w":[{border:Je()}],"border-w-x":[{"border-x":Je()}],"border-w-y":[{"border-y":Je()}],"border-w-s":[{"border-s":Je()}],"border-w-e":[{"border-e":Je()}],"border-w-bs":[{"border-bs":Je()}],"border-w-be":[{"border-be":Je()}],"border-w-t":[{"border-t":Je()}],"border-w-r":[{"border-r":Je()}],"border-w-b":[{"border-b":Je()}],"border-w-l":[{"border-l":Je()}],"divide-x":[{"divide-x":Je()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Je()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...He(),"hidden","none"]}],"divide-style":[{divide:[...He(),"hidden","none"]}],"border-color":[{border:$()}],"border-color-x":[{"border-x":$()}],"border-color-y":[{"border-y":$()}],"border-color-s":[{"border-s":$()}],"border-color-e":[{"border-e":$()}],"border-color-bs":[{"border-bs":$()}],"border-color-be":[{"border-be":$()}],"border-color-t":[{"border-t":$()}],"border-color-r":[{"border-r":$()}],"border-color-b":[{"border-b":$()}],"border-color-l":[{"border-l":$()}],"divide-color":[{divide:$()}],"outline-style":[{outline:[...He(),"none","hidden"]}],"outline-offset":[{"outline-offset":[isNumber,isArbitraryVariable,isArbitraryValue]}],"outline-w":[{outline:["",isNumber,isArbitraryVariableLength,isArbitraryLength]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",p,isArbitraryVariableShadow,isArbitraryShadow]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",g,isArbitraryVariableShadow,isArbitraryShadow]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:Je()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[isNumber,isArbitraryLength]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":Je()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",y,isArbitraryVariableShadow,isArbitraryShadow]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[isNumber,isArbitraryVariable,isArbitraryValue]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[isNumber]}],"mask-image-linear-from-pos":[{"mask-linear-from":fe()}],"mask-image-linear-to-pos":[{"mask-linear-to":fe()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":fe()}],"mask-image-t-to-pos":[{"mask-t-to":fe()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":fe()}],"mask-image-r-to-pos":[{"mask-r-to":fe()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":fe()}],"mask-image-b-to-pos":[{"mask-b-to":fe()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":fe()}],"mask-image-l-to-pos":[{"mask-l-to":fe()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":fe()}],"mask-image-x-to-pos":[{"mask-x-to":fe()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":fe()}],"mask-image-y-to-pos":[{"mask-y-to":fe()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[isArbitraryVariable,isArbitraryValue]}],"mask-image-radial-from-pos":[{"mask-radial-from":fe()}],"mask-image-radial-to-pos":[{"mask-radial-to":fe()}],"mask-image-radial-from-color":[{"mask-radial-from":$()}],"mask-image-radial-to-color":[{"mask-radial-to":$()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":D()}],"mask-image-conic-pos":[{"mask-conic":[isNumber]}],"mask-image-conic-from-pos":[{"mask-conic-from":fe()}],"mask-image-conic-to-pos":[{"mask-conic-to":fe()}],"mask-image-conic-from-color":[{"mask-conic-from":$()}],"mask-image-conic-to-color":[{"mask-conic-to":$()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:G()}],"mask-repeat":[{mask:ce()}],"mask-size":[{mask:oe()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",isArbitraryVariable,isArbitraryValue]}],filter:[{filter:["","none",isArbitraryVariable,isArbitraryValue]}],blur:[{blur:Oe()}],brightness:[{brightness:[isNumber,isArbitraryVariable,isArbitraryValue]}],contrast:[{contrast:[isNumber,isArbitraryVariable,isArbitraryValue]}],"drop-shadow":[{"drop-shadow":["","none",S,isArbitraryVariableShadow,isArbitraryShadow]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",isNumber,isArbitraryVariable,isArbitraryValue]}],"hue-rotate":[{"hue-rotate":[isNumber,isArbitraryVariable,isArbitraryValue]}],invert:[{invert:["",isNumber,isArbitraryVariable,isArbitraryValue]}],saturate:[{saturate:[isNumber,isArbitraryVariable,isArbitraryValue]}],sepia:[{sepia:["",isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-filter":[{"backdrop-filter":["","none",isArbitraryVariable,isArbitraryValue]}],"backdrop-blur":[{"backdrop-blur":Oe()}],"backdrop-brightness":[{"backdrop-brightness":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-contrast":[{"backdrop-contrast":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-invert":[{"backdrop-invert":["",isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-opacity":[{"backdrop-opacity":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-saturate":[{"backdrop-saturate":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-sepia":[{"backdrop-sepia":["",isNumber,isArbitraryVariable,isArbitraryValue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":X()}],"border-spacing-x":[{"border-spacing-x":X()}],"border-spacing-y":[{"border-spacing-y":X()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",isArbitraryVariable,isArbitraryValue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[isNumber,"initial",isArbitraryVariable,isArbitraryValue]}],ease:[{ease:["linear","initial",A,isArbitraryVariable,isArbitraryValue]}],delay:[{delay:[isNumber,isArbitraryVariable,isArbitraryValue]}],animate:[{animate:["none",F,isArbitraryVariable,isArbitraryValue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[R,isArbitraryVariable,isArbitraryValue]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:ie()}],"rotate-x":[{"rotate-x":ie()}],"rotate-y":[{"rotate-y":ie()}],"rotate-z":[{"rotate-z":ie()}],scale:[{scale:j()}],"scale-x":[{"scale-x":j()}],"scale-y":[{"scale-y":j()}],"scale-z":[{"scale-z":j()}],"scale-3d":["scale-3d"],skew:[{skew:N()}],"skew-x":[{"skew-x":N()}],"skew-y":[{"skew-y":N()}],transform:[{transform:[isArbitraryVariable,isArbitraryValue,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:L()}],"translate-x":[{"translate-x":L()}],"translate-y":[{"translate-y":L()}],"translate-z":[{"translate-z":L()}],"translate-none":["translate-none"],zoom:[{zoom:[isInteger,isArbitraryVariable,isArbitraryValue]}],accent:[{accent:$()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:$()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",isArbitraryVariable,isArbitraryValue]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":$()}],"scrollbar-track-color":[{"scrollbar-track":$()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":X()}],"scroll-mx":[{"scroll-mx":X()}],"scroll-my":[{"scroll-my":X()}],"scroll-ms":[{"scroll-ms":X()}],"scroll-me":[{"scroll-me":X()}],"scroll-mbs":[{"scroll-mbs":X()}],"scroll-mbe":[{"scroll-mbe":X()}],"scroll-mt":[{"scroll-mt":X()}],"scroll-mr":[{"scroll-mr":X()}],"scroll-mb":[{"scroll-mb":X()}],"scroll-ml":[{"scroll-ml":X()}],"scroll-p":[{"scroll-p":X()}],"scroll-px":[{"scroll-px":X()}],"scroll-py":[{"scroll-py":X()}],"scroll-ps":[{"scroll-ps":X()}],"scroll-pe":[{"scroll-pe":X()}],"scroll-pbs":[{"scroll-pbs":X()}],"scroll-pbe":[{"scroll-pbe":X()}],"scroll-pt":[{"scroll-pt":X()}],"scroll-pr":[{"scroll-pr":X()}],"scroll-pb":[{"scroll-pb":X()}],"scroll-pl":[{"scroll-pl":X()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",isArbitraryVariable,isArbitraryValue]}],fill:[{fill:["none",...$()]}],"stroke-w":[{stroke:[isNumber,isArbitraryVariableLength,isArbitraryLength,isArbitraryNumber]}],stroke:[{stroke:["none",...$()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},twMerge=createTailwindMerge(getDefaultConfig);function cn(...i){return twMerge(clsx(i))}var __defProp$1=Object.defineProperty,__name$1=(i,e)=>__defProp$1(i,"name",{value:e,configurable:!0});function setRef(i,e){if(typeof i=="function")return i(e);i!=null&&(i.current=e)}__name$1(setRef,"setRef");function composeRefs(...i){return e=>{let t=!1;const n=i.map(s=>{const a=setRef(s,e);return!t&&typeof a=="function"&&(t=!0),a});if(t)return()=>{for(let s=0;s<n.length;s++){const a=n[s];typeof a=="function"?a():setRef(i[s],null)}}}}__name$1(composeRefs,"composeRefs");function useComposedRefs(...i){return reactExports.useCallback(composeRefs(...i),i)}__name$1(useComposedRefs,"useComposedRefs");var __defProp=Object.defineProperty,__name=(i,e)=>__defProp(i,"name",{value:e,configurable:!0});function createSlot(i){const e=reactExports.forwardRef((t,n)=>{let{children:s,...a}=t,u=null,c=!1;const h=[];isLazyComponent(s)&&typeof use=="function"&&(s=use(s._payload)),reactExports.Children.forEach(s,y=>{if(isSlottable(y)){c=!0;const S=y;let w="child"in S.props?S.props.child:S.props.children;isLazyComponent(w)&&typeof use=="function"&&(w=use(w._payload)),u=getSlottableElementFromSlottable(S,w),h.push(u?.props?.children)}else h.push(y)}),u?u=reactExports.cloneElement(u,void 0,h):!c&&reactExports.Children.count(s)===1&&reactExports.isValidElement(s)&&(u=s);const f=u?getElementRef(u):void 0,p=useComposedRefs(n,f);if(!u){if(s||s===0)throw new Error(c?createSlottableError(i):createSlotError(i));return s}const g=mergeProps(a,u.props??{});return u.type!==reactExports.Fragment&&(g.ref=n?p:f),reactExports.cloneElement(u,g)});return e.displayName=`${i}.Slot`,e}__name(createSlot,"createSlot");var Slot=createSlot("Slot"),SLOTTABLE_IDENTIFIER=Symbol.for("radix.slottable");function createSlottable(i){const e=__name(t=>"child"in t?t.children(t.child):t.children,"Slottable");return e.displayName=`${i}.Slottable`,e.__radixId=SLOTTABLE_IDENTIFIER,e}__name(createSlottable,"createSlottable");var getSlottableElementFromSlottable=__name((i,e)=>{if("child"in i.props){const t=i.props.child;return reactExports.isValidElement(t)?reactExports.cloneElement(t,void 0,i.props.children(t.props.children)):null}return reactExports.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function mergeProps(i,e){const t={...e};for(const n in e){const s=i[n],a=e[n];/^on[A-Z]/.test(n)?s&&a?t[n]=(...c)=>{const h=a(...c);return s(...c),h}:s&&(t[n]=s):n==="style"?t[n]={...s,...a}:n==="className"&&(t[n]=[s,a].filter(Boolean).join(" "))}return{...i,...t}}__name(mergeProps,"mergeProps");function getElementRef(i){let e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?i.ref:(e=Object.getOwnPropertyDescriptor(i,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?i.props.ref:i.props.ref||i.ref)}__name(getElementRef,"getElementRef");function isSlottable(i){return reactExports.isValidElement(i)&&typeof i.type=="function"&&"__radixId"in i.type&&i.type.__radixId===SLOTTABLE_IDENTIFIER}__name(isSlottable,"isSlottable");var REACT_LAZY_TYPE=Symbol.for("react.lazy");function isLazyComponent(i){return i!=null&&typeof i=="object"&&"$$typeof"in i&&i.$$typeof===REACT_LAZY_TYPE&&"_payload"in i&&isPromiseLike(i._payload)}__name(isLazyComponent,"isLazyComponent");function isPromiseLike(i){return typeof i=="object"&&i!==null&&"then"in i}__name(isPromiseLike,"isPromiseLike");var createSlotError=__name(i=>`${i} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),createSlottableError=__name(i=>`${i} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),use=React[" use ".trim().toString()];const buttonVariants=cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",subtle:"bg-muted text-muted-foreground hover:bg-muted/80"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Button=reactExports.forwardRef(({className:i,variant:e,size:t,asChild:n=!1,...s},a)=>{const u=n?Slot:"button";return jsxRuntimeExports.jsx(u,{className:cn(buttonVariants({variant:e,size:t,className:i})),ref:a,...s})});Button.displayName="Button";const Input=reactExports.forwardRef(({className:i,type:e="text",...t},n)=>jsxRuntimeExports.jsx("input",{ref:n,type:e,className:cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",i),...t}));Input.displayName="Input";const appLayoutGridStyle={gridTemplateColumns:"60px minmax(0, 1fr)"};function AppLayout({navigation:i,children:e,className:t}){return jsxRuntimeExports.jsxs("section",{className:cn("grid h-screen min-h-0 bg-background",t),style:appLayoutGridStyle,"data-app-layout":"workspace",children:[jsxRuntimeExports.jsx("aside",{className:"min-h-0 overflow-hidden border-r border-border/50 bg-layout-sidebar",children:i}),jsxRuntimeExports.jsx("div",{className:"min-h-0 min-w-0 overflow-hidden bg-layout-content",children:e})]})}const defaultLoginTitle="Connect Solid Pod",safeLoginErrorMessage="登录失败,请重试。";function normalizeLoginError(){return safeLoginErrorMessage}function AuthSurface({children:i,labelledBy:e}){return jsxRuntimeExports.jsx("section",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-10 text-foreground","aria-labelledby":e,"data-auth-boundary":"surface",children:jsxRuntimeExports.jsx("div",{className:"w-full max-w-md rounded-lg border border-border bg-layout-content px-8 py-7 shadow-sm",children:i})})}function LoginView({title:i,description:e,defaultIssuer:t="",logo:n,error:s,onLogin:a}){const u=reactExports.useId(),c=reactExports.useId(),h=reactExports.useId(),[f,p]=reactExports.useState(t),[g,y]=reactExports.useState(!1),[S,w]=reactExports.useState(),R=f.trim(),T=S??s,A=reactExports.useMemo(()=>T?h:void 0,[h,T]);async function F(x){if(x.preventDefault(),!(!R||g)){y(!0),w(void 0);try{await a(R)}catch{w(normalizeLoginError())}finally{y(!1)}}}return jsxRuntimeExports.jsx(AuthSurface,{labelledBy:u,children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-6",children:[jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[n?jsxRuntimeExports.jsx("div",{className:"flex justify-center","aria-hidden":"true",children:n}):null,jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntimeExports.jsx("h1",{id:u,className:"text-2xl font-semibold leading-8 tracking-normal",children:i}),e?jsxRuntimeExports.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:e}):null]})]}),jsxRuntimeExports.jsxs("form",{className:"flex flex-col gap-4",onSubmit:x=>{F(x)},children:[jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2 text-left",children:[jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-5 text-foreground",htmlFor:c,children:"Solid issuer"}),jsxRuntimeExports.jsx(Input,{id:c,value:f,disabled:g,"aria-describedby":A,placeholder:"https://solidcommunity.net",onChange:x=>p(x.currentTarget.value)})]}),T?jsxRuntimeExports.jsx("p",{id:h,className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm leading-5 text-destructive",role:"alert",children:T}):null,jsxRuntimeExports.jsx(Button,{type:"submit",className:"w-full",disabled:!R||g,children:g?"登录中...":"登录"})]})]})})}function AuthBoundary({state:i,login:e,children:t,loginView:n}){return i.status==="authenticated"?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:t}):i.status==="loading"?jsxRuntimeExports.jsx(AuthSurface,{children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center gap-3 text-center text-sm leading-6 text-muted-foreground",role:"status","aria-label":"认证状态",children:[jsxRuntimeExports.jsx("span",{className:"h-8 w-8 rounded-full border-2 border-border border-t-primary","aria-hidden":"true"}),jsxRuntimeExports.jsx("span",{children:"正在检查登录状态"})]})}):jsxRuntimeExports.jsx(LoginView,{title:n?.title??defaultLoginTitle,description:n?.description,defaultIssuer:n?.defaultIssuer,logo:n?.logo,error:i.status==="error"?i.message:void 0,onLogin:e})}function ProductNavLinks({items:i,label:e}){return jsxRuntimeExports.jsx("nav",{"aria-label":e,className:"flex flex-1 flex-col items-center gap-4 py-4",children:i.map(t=>{const n=t.icon;return jsxRuntimeExports.jsxs(NavLink,{to:t.path,"aria-label":t.label,title:t.label,className:({isActive:s})=>clsx("flex h-9 w-9 items-center justify-center rounded-md transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s?"text-primary":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[jsxRuntimeExports.jsx(n,{className:"h-6 w-6","aria-hidden":"true"}),jsxRuntimeExports.jsx("span",{className:"sr-only",children:t.label})]},t.id)})})}function XpodProductLayout({product:i,items:e,switchHref:t}){const n=i==="dashboard"?"Open Settings":"Open Dashboard";return jsxRuntimeExports.jsx(AppLayout,{className:`xpod-${i}-shell`,navigation:jsxRuntimeExports.jsxs("div",{className:"flex min-h-full flex-col items-center",children:[jsxRuntimeExports.jsx("div",{className:"flex shrink-0 flex-col items-center pt-12",children:jsxRuntimeExports.jsx("a",{"aria-label":n,className:"flex h-9 w-9 items-center justify-center rounded-md bg-primary text-sm font-semibold text-primary-foreground shadow-sm",href:t,title:n,children:"X"})}),jsxRuntimeExports.jsx(ProductNavLinks,{items:e,label:`Primary ${i} sections`})]}),children:jsxRuntimeExports.jsx("div",{className:"min-h-full bg-background",children:jsxRuntimeExports.jsx(Outlet,{})})})}function XpodSettingsLayout(){return jsxRuntimeExports.jsx(XpodProductLayout,{product:"settings",items:settingsNavigationItems,switchHref:"/dashboard/overview"})}const crypto$1=crypto,isCryptoKey=i=>i instanceof CryptoKey,encoder=new TextEncoder,decoder=new TextDecoder;function concat(...i){const e=i.reduce((s,{length:a})=>s+a,0),t=new Uint8Array(e);let n=0;for(const s of i)t.set(s,n),n+=s.length;return t}const encodeBase64=i=>{let e=i;typeof e=="string"&&(e=encoder.encode(e));const t=32768,n=[];for(let s=0;s<e.length;s+=t)n.push(String.fromCharCode.apply(null,e.subarray(s,s+t)));return btoa(n.join(""))},encode$1=i=>encodeBase64(i).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),decodeBase64=i=>{const e=atob(i),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t},decode$1=i=>{let e=i;e instanceof Uint8Array&&(e=decoder.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return decodeBase64(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class JOSEError extends Error{constructor(e,t){super(e,t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}JOSEError.code="ERR_JOSE_GENERIC";class JWTClaimValidationFailed extends JOSEError{constructor(e,t,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:t}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=n,this.reason=s,this.payload=t}}JWTClaimValidationFailed.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class JWTExpired extends JOSEError{constructor(e,t,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:t}}),this.code="ERR_JWT_EXPIRED",this.claim=n,this.reason=s,this.payload=t}}JWTExpired.code="ERR_JWT_EXPIRED";class JOSEAlgNotAllowed extends JOSEError{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}JOSEAlgNotAllowed.code="ERR_JOSE_ALG_NOT_ALLOWED";class JOSENotSupported extends JOSEError{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}JOSENotSupported.code="ERR_JOSE_NOT_SUPPORTED";class JWEDecryptionFailed extends JOSEError{constructor(e="decryption operation failed",t){super(e,t),this.code="ERR_JWE_DECRYPTION_FAILED"}}JWEDecryptionFailed.code="ERR_JWE_DECRYPTION_FAILED";class JWEInvalid extends JOSEError{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}JWEInvalid.code="ERR_JWE_INVALID";class JWSInvalid extends JOSEError{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}JWSInvalid.code="ERR_JWS_INVALID";class JWTInvalid extends JOSEError{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}JWTInvalid.code="ERR_JWT_INVALID";class JWKInvalid extends JOSEError{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}JWKInvalid.code="ERR_JWK_INVALID";class JWKSInvalid extends JOSEError{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}JWKSInvalid.code="ERR_JWKS_INVALID";class JWKSNoMatchingKey extends JOSEError{constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_NO_MATCHING_KEY"}}JWKSNoMatchingKey.code="ERR_JWKS_NO_MATCHING_KEY";class JWKSMultipleMatchingKeys extends JOSEError{constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}JWKSMultipleMatchingKeys.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class JWKSTimeout extends JOSEError{constructor(e="request timed out",t){super(e,t),this.code="ERR_JWKS_TIMEOUT"}}JWKSTimeout.code="ERR_JWKS_TIMEOUT";class JWSSignatureVerificationFailed extends JOSEError{constructor(e="signature verification failed",t){super(e,t),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}JWSSignatureVerificationFailed.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function unusable(i,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${i}`)}function isAlgorithm(i,e){return i.name===e}function getHashLength(i){return parseInt(i.name.slice(4),10)}function getNamedCurve(i){switch(i){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function checkUsage(i,e){if(e.length&&!e.some(t=>i.usages.includes(t))){let t="CryptoKey does not support this operation, its usages must include ";if(e.length>2){const n=e.pop();t+=`one of ${e.join(", ")}, or ${n}.`}else e.length===2?t+=`one of ${e[0]} or ${e[1]}.`:t+=`${e[0]}.`;throw new TypeError(t)}}function checkSigCryptoKey(i,e,...t){switch(e){case"HS256":case"HS384":case"HS512":{if(!isAlgorithm(i.algorithm,"HMAC"))throw unusable("HMAC");const n=parseInt(e.slice(2),10);if(getHashLength(i.algorithm.hash)!==n)throw unusable(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!isAlgorithm(i.algorithm,"RSASSA-PKCS1-v1_5"))throw unusable("RSASSA-PKCS1-v1_5");const n=parseInt(e.slice(2),10);if(getHashLength(i.algorithm.hash)!==n)throw unusable(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!isAlgorithm(i.algorithm,"RSA-PSS"))throw unusable("RSA-PSS");const n=parseInt(e.slice(2),10);if(getHashLength(i.algorithm.hash)!==n)throw unusable(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(i.algorithm.name!=="Ed25519"&&i.algorithm.name!=="Ed448")throw unusable("Ed25519 or Ed448");break}case"Ed25519":{if(!isAlgorithm(i.algorithm,"Ed25519"))throw unusable("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!isAlgorithm(i.algorithm,"ECDSA"))throw unusable("ECDSA");const n=getNamedCurve(e);if(i.algorithm.namedCurve!==n)throw unusable(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}checkUsage(i,t)}function message(i,e,...t){if(t=t.filter(Boolean),t.length>2){const n=t.pop();i+=`one of type ${t.join(", ")}, or ${n}.`}else t.length===2?i+=`one of type ${t[0]} or ${t[1]}.`:i+=`of type ${t[0]}.`;return e==null?i+=` Received ${e}`:typeof e=="function"&&e.name?i+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&e.constructor?.name&&(i+=` Received an instance of ${e.constructor.name}`),i}const invalidKeyInput=(i,...e)=>message("Key must be ",i,...e);function withAlg(i,e,...t){return message(`Key for the ${i} algorithm must be `,e,...t)}const isKeyLike=i=>isCryptoKey(i)?!0:i?.[Symbol.toStringTag]==="KeyObject",types=["CryptoKey"],isDisjoint=(...i)=>{const e=i.filter(Boolean);if(e.length===0||e.length===1)return!0;let t;for(const n of e){const s=Object.keys(n);if(!t||t.size===0){t=new Set(s);continue}for(const a of s){if(t.has(a))return!1;t.add(a)}}return!0};function isObjectLike(i){return typeof i=="object"&&i!==null}function isObject$1(i){if(!isObjectLike(i)||Object.prototype.toString.call(i)!=="[object Object]")return!1;if(Object.getPrototypeOf(i)===null)return!0;let e=i;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(i)===e}const checkKeyLength=(i,e)=>{if(i.startsWith("RS")||i.startsWith("PS")){const{modulusLength:t}=e.algorithm;if(typeof t!="number"||t<2048)throw new TypeError(`${i} requires key modulusLength to be 2048 bits or larger`)}};function isJWK(i){return isObject$1(i)&&typeof i.kty=="string"}function isPrivateJWK(i){return i.kty!=="oct"&&typeof i.d=="string"}function isPublicJWK(i){return i.kty!=="oct"&&typeof i.d>"u"}function isSecretJWK(i){return isJWK(i)&&i.kty==="oct"&&typeof i.k=="string"}function subtleMapping(i){let e,t;switch(i.kty){case"RSA":{switch(i.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${i.alg.slice(-3)}`},t=i.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${i.alg.slice(-3)}`},t=i.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(i.alg.slice(-3),10)||1}`},t=i.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(i.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},t=i.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},t=i.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},t=i.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:i.crv},t=i.d?["deriveBits"]:[];break;default:throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(i.alg){case"Ed25519":e={name:"Ed25519"},t=i.d?["sign"]:["verify"];break;case"EdDSA":e={name:i.crv},t=i.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:i.crv},t=i.d?["deriveBits"]:[];break;default:throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:t}}const parse$1=async i=>{if(!i.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:e,keyUsages:t}=subtleMapping(i),n=[e,i.ext??!1,i.key_ops??t],s={...i};return delete s.alg,delete s.use,crypto$1.subtle.importKey("jwk",s,...n)},exportKeyValue=i=>decode$1(i);let privCache,pubCache;const isKeyObject=i=>i?.[Symbol.toStringTag]==="KeyObject",importAndCache=async(i,e,t,n,s=!1)=>{let a=i.get(e);if(a?.[n])return a[n];const u=await parse$1({...t,alg:n});return s&&Object.freeze(e),a?a[n]=u:i.set(e,{[n]:u}),u},normalizePublicKey=(i,e)=>{if(isKeyObject(i)){let t=i.export({format:"jwk"});return delete t.d,delete t.dp,delete t.dq,delete t.p,delete t.q,delete t.qi,t.k?exportKeyValue(t.k):(pubCache||(pubCache=new WeakMap),importAndCache(pubCache,i,t,e))}return isJWK(i)?i.k?decode$1(i.k):(pubCache||(pubCache=new WeakMap),importAndCache(pubCache,i,i,e,!0)):i},normalizePrivateKey=(i,e)=>{if(isKeyObject(i)){let t=i.export({format:"jwk"});return t.k?exportKeyValue(t.k):(privCache||(privCache=new WeakMap),importAndCache(privCache,i,t,e))}return isJWK(i)?i.k?decode$1(i.k):(privCache||(privCache=new WeakMap),importAndCache(privCache,i,i,e,!0)):i},normalize$1={normalizePublicKey,normalizePrivateKey};async function importJWK(i,e){if(!isObject$1(i))throw new TypeError("JWK must be an object");switch(e||(e=i.alg),i.kty){case"oct":if(typeof i.k!="string"||!i.k)throw new TypeError('missing "k" (Key Value) Parameter value');return decode$1(i.k);case"RSA":if("oth"in i&&i.oth!==void 0)throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return parse$1({...i,alg:e});default:throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value')}}const tag=i=>i?.[Symbol.toStringTag],jwkMatchesOp=(i,e,t)=>{if(e.use!==void 0&&e.use!=="sig")throw new TypeError("Invalid key for this operation, when present its use must be sig");if(e.key_ops!==void 0&&e.key_ops.includes?.(t)!==!0)throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${t}`);if(e.alg!==void 0&&e.alg!==i)throw new TypeError(`Invalid key for this operation, when present its alg must be ${i}`);return!0},symmetricTypeCheck=(i,e,t,n)=>{if(!(e instanceof Uint8Array)){if(n&&isJWK(e)){if(isSecretJWK(e)&&jwkMatchesOp(i,e,t))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!isKeyLike(e))throw new TypeError(withAlg(i,e,...types,"Uint8Array",n?"JSON Web Key":null));if(e.type!=="secret")throw new TypeError(`${tag(e)} instances for symmetric algorithms must be of type "secret"`)}},asymmetricTypeCheck=(i,e,t,n)=>{if(n&&isJWK(e))switch(t){case"sign":if(isPrivateJWK(e)&&jwkMatchesOp(i,e,t))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(isPublicJWK(e)&&jwkMatchesOp(i,e,t))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!isKeyLike(e))throw new TypeError(withAlg(i,e,...types,n?"JSON Web Key":null));if(e.type==="secret")throw new TypeError(`${tag(e)} instances for asymmetric algorithms must not be of type "secret"`);if(t==="sign"&&e.type==="public")throw new TypeError(`${tag(e)} instances for asymmetric algorithm signing must be of type "private"`);if(t==="decrypt"&&e.type==="public")throw new TypeError(`${tag(e)} instances for asymmetric algorithm decryption must be of type "private"`);if(e.algorithm&&t==="verify"&&e.type==="private")throw new TypeError(`${tag(e)} instances for asymmetric algorithm verifying must be of type "public"`);if(e.algorithm&&t==="encrypt"&&e.type==="private")throw new TypeError(`${tag(e)} instances for asymmetric algorithm encryption must be of type "public"`)};function checkKeyType(i,e,t,n){e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?symmetricTypeCheck(e,t,n,i):asymmetricTypeCheck(e,t,n,i)}checkKeyType.bind(void 0,!1);const checkKeyTypeWithJwk=checkKeyType.bind(void 0,!0);function validateCrit(i,e,t,n,s){if(s.crit!==void 0&&n?.crit===void 0)throw new i('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(u=>typeof u!="string"||u.length===0))throw new i('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;t!==void 0?a=new Map([...Object.entries(t),...e.entries()]):a=e;for(const u of n.crit){if(!a.has(u))throw new JOSENotSupported(`Extension Header Parameter "${u}" is not recognized`);if(s[u]===void 0)throw new i(`Extension Header Parameter "${u}" is missing`);if(a.get(u)&&n[u]===void 0)throw new i(`Extension Header Parameter "${u}" MUST be integrity protected`)}return new Set(n.crit)}const validateAlgorithms=(i,e)=>{if(e!==void 0&&(!Array.isArray(e)||e.some(t=>typeof t!="string")))throw new TypeError(`"${i}" option must be an array of strings`);if(e)return new Set(e)},keyToJWK=async i=>{if(i instanceof Uint8Array)return{kty:"oct",k:encode$1(i)};if(!isCryptoKey(i))throw new TypeError(invalidKeyInput(i,...types,"Uint8Array"));if(!i.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:e,key_ops:t,alg:n,use:s,...a}=await crypto$1.subtle.exportKey("jwk",i);return a};async function exportJWK(i){return keyToJWK(i)}function subtleDsa(i,e){const t=`SHA-${i.slice(-3)}`;switch(i){case"HS256":case"HS384":case"HS512":return{hash:t,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:t,name:"RSA-PSS",saltLength:i.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:t,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:t,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:e.name};default:throw new JOSENotSupported(`alg ${i} is not supported either by JOSE or your javascript runtime`)}}async function getCryptoKey(i,e,t){if(t==="sign"&&(e=await normalize$1.normalizePrivateKey(e,i)),t==="verify"&&(e=await normalize$1.normalizePublicKey(e,i)),isCryptoKey(e))return checkSigCryptoKey(e,i,t),e;if(e instanceof Uint8Array){if(!i.startsWith("HS"))throw new TypeError(invalidKeyInput(e,...types));return crypto$1.subtle.importKey("raw",e,{hash:`SHA-${i.slice(-3)}`,name:"HMAC"},!1,[t])}throw new TypeError(invalidKeyInput(e,...types,"Uint8Array","JSON Web Key"))}const verify=async(i,e,t,n)=>{const s=await getCryptoKey(i,e,"verify");checkKeyLength(i,s);const a=subtleDsa(i,s.algorithm);try{return await crypto$1.subtle.verify(a,s,t,n)}catch{return!1}};async function flattenedVerify(i,e,t){if(!isObject$1(i))throw new JWSInvalid("Flattened JWS must be an object");if(i.protected===void 0&&i.header===void 0)throw new JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');if(i.protected!==void 0&&typeof i.protected!="string")throw new JWSInvalid("JWS Protected Header incorrect type");if(i.payload===void 0)throw new JWSInvalid("JWS Payload missing");if(typeof i.signature!="string")throw new JWSInvalid("JWS Signature missing or incorrect type");if(i.header!==void 0&&!isObject$1(i.header))throw new JWSInvalid("JWS Unprotected Header incorrect type");let n={};if(i.protected)try{const R=decode$1(i.protected);n=JSON.parse(decoder.decode(R))}catch{throw new JWSInvalid("JWS Protected Header is invalid")}if(!isDisjoint(n,i.header))throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const s={...n,...i.header},a=validateCrit(JWSInvalid,new Map([["b64",!0]]),t?.crit,n,s);let u=!0;if(a.has("b64")&&(u=n.b64,typeof u!="boolean"))throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:c}=s;if(typeof c!="string"||!c)throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');const h=t&&validateAlgorithms("algorithms",t.algorithms);if(h&&!h.has(c))throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');if(u){if(typeof i.payload!="string")throw new JWSInvalid("JWS Payload must be a string")}else if(typeof i.payload!="string"&&!(i.payload instanceof Uint8Array))throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");let f=!1;typeof e=="function"?(e=await e(n,i),f=!0,checkKeyTypeWithJwk(c,e,"verify"),isJWK(e)&&(e=await importJWK(e,c))):checkKeyTypeWithJwk(c,e,"verify");const p=concat(encoder.encode(i.protected??""),encoder.encode("."),typeof i.payload=="string"?encoder.encode(i.payload):i.payload);let g;try{g=decode$1(i.signature)}catch{throw new JWSInvalid("Failed to base64url decode the signature")}if(!await verify(c,e,g,p))throw new JWSSignatureVerificationFailed;let S;if(u)try{S=decode$1(i.payload)}catch{throw new JWSInvalid("Failed to base64url decode the payload")}else typeof i.payload=="string"?S=encoder.encode(i.payload):S=i.payload;const w={payload:S};return i.protected!==void 0&&(w.protectedHeader=n),i.header!==void 0&&(w.unprotectedHeader=i.header),f?{...w,key:e}:w}async function compactVerify(i,e,t){if(i instanceof Uint8Array&&(i=decoder.decode(i)),typeof i!="string")throw new JWSInvalid("Compact JWS must be a string or Uint8Array");const{0:n,1:s,2:a,length:u}=i.split(".");if(u!==3)throw new JWSInvalid("Invalid Compact JWS");const c=await flattenedVerify({payload:s,protected:n,signature:a},e,t),h={payload:c.payload,protectedHeader:c.protectedHeader};return typeof e=="function"?{...h,key:c.key}:h}const epoch=i=>Math.floor(i.getTime()/1e3),minute=60,hour=minute*60,day=hour*24,week=day*7,year=day*365.25,REGEX=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,secs=i=>{const e=REGEX.exec(i);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");const t=parseFloat(e[2]),n=e[3].toLowerCase();let s;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":s=Math.round(t);break;case"minute":case"minutes":case"min":case"mins":case"m":s=Math.round(t*minute);break;case"hour":case"hours":case"hr":case"hrs":case"h":s=Math.round(t*hour);break;case"day":case"days":case"d":s=Math.round(t*day);break;case"week":case"weeks":case"w":s=Math.round(t*week);break;default:s=Math.round(t*year);break}return e[1]==="-"||e[4]==="ago"?-s:s},normalizeTyp=i=>i.toLowerCase().replace(/^application\//,""),checkAudiencePresence=(i,e)=>typeof i=="string"?e.includes(i):Array.isArray(i)?e.some(Set.prototype.has.bind(new Set(i))):!1,jwtPayload=(i,e,t={})=>{let n;try{n=JSON.parse(decoder.decode(e))}catch{}if(!isObject$1(n))throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");const{typ:s}=t;if(s&&(typeof i.typ!="string"||normalizeTyp(i.typ)!==normalizeTyp(s)))throw new JWTClaimValidationFailed('unexpected "typ" JWT header value',n,"typ","check_failed");const{requiredClaims:a=[],issuer:u,subject:c,audience:h,maxTokenAge:f}=t,p=[...a];f!==void 0&&p.push("iat"),h!==void 0&&p.push("aud"),c!==void 0&&p.push("sub"),u!==void 0&&p.push("iss");for(const w of new Set(p.reverse()))if(!(w in n))throw new JWTClaimValidationFailed(`missing required "${w}" claim`,n,w,"missing");if(u&&!(Array.isArray(u)?u:[u]).includes(n.iss))throw new JWTClaimValidationFailed('unexpected "iss" claim value',n,"iss","check_failed");if(c&&n.sub!==c)throw new JWTClaimValidationFailed('unexpected "sub" claim value',n,"sub","check_failed");if(h&&!checkAudiencePresence(n.aud,typeof h=="string"?[h]:h))throw new JWTClaimValidationFailed('unexpected "aud" claim value',n,"aud","check_failed");let g;switch(typeof t.clockTolerance){case"string":g=secs(t.clockTolerance);break;case"number":g=t.clockTolerance;break;case"undefined":g=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:y}=t,S=epoch(y||new Date);if((n.iat!==void 0||f)&&typeof n.iat!="number")throw new JWTClaimValidationFailed('"iat" claim must be a number',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!="number")throw new JWTClaimValidationFailed('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>S+g)throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!="number")throw new JWTClaimValidationFailed('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=S-g)throw new JWTExpired('"exp" claim timestamp check failed',n,"exp","check_failed")}if(f){const w=S-n.iat,R=typeof f=="number"?f:secs(f);if(w-g>R)throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(w<0-g)throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n};async function jwtVerify(i,e,t){const n=await compactVerify(i,e,t);if(n.protectedHeader.crit?.includes("b64")&&n.protectedHeader.b64===!1)throw new JWTInvalid("JWTs MUST NOT use unencoded payload");const a={payload:jwtPayload(n.protectedHeader,n.payload,t),protectedHeader:n.protectedHeader};return typeof e=="function"?{...a,key:n.key}:a}const sign=async(i,e,t)=>{const n=await getCryptoKey(i,e,"sign");checkKeyLength(i,n);const s=await crypto$1.subtle.sign(subtleDsa(i,n.algorithm),n,t);return new Uint8Array(s)};class FlattenedSign{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,t){if(!this._protectedHeader&&!this._unprotectedHeader)throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!isDisjoint(this._protectedHeader,this._unprotectedHeader))throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader},s=validateCrit(JWSInvalid,new Map([["b64",!0]]),t?.crit,this._protectedHeader,n);let a=!0;if(s.has("b64")&&(a=this._protectedHeader.b64,typeof a!="boolean"))throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:u}=n;if(typeof u!="string"||!u)throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');checkKeyTypeWithJwk(u,e,"sign");let c=this._payload;a&&(c=encoder.encode(encode$1(c)));let h;this._protectedHeader?h=encoder.encode(encode$1(JSON.stringify(this._protectedHeader))):h=encoder.encode("");const f=concat(h,encoder.encode("."),c),p=await sign(u,e,f),g={signature:encode$1(p),payload:""};return a&&(g.payload=decoder.decode(c)),this._unprotectedHeader&&(g.header=this._unprotectedHeader),this._protectedHeader&&(g.protected=decoder.decode(h)),g}}class CompactSign{constructor(e){this._flattened=new FlattenedSign(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,t){const n=await this._flattened.sign(e,t);if(n.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`}}function validateInput(i,e){if(!Number.isFinite(e))throw new TypeError(`Invalid ${i} input`);return e}class ProduceJWT{constructor(e={}){if(!isObject$1(e))throw new TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload={...this._payload,iss:e},this}setSubject(e){return this._payload={...this._payload,sub:e},this}setAudience(e){return this._payload={...this._payload,aud:e},this}setJti(e){return this._payload={...this._payload,jti:e},this}setNotBefore(e){return typeof e=="number"?this._payload={...this._payload,nbf:validateInput("setNotBefore",e)}:e instanceof Date?this._payload={...this._payload,nbf:validateInput("setNotBefore",epoch(e))}:this._payload={...this._payload,nbf:epoch(new Date)+secs(e)},this}setExpirationTime(e){return typeof e=="number"?this._payload={...this._payload,exp:validateInput("setExpirationTime",e)}:e instanceof Date?this._payload={...this._payload,exp:validateInput("setExpirationTime",epoch(e))}:this._payload={...this._payload,exp:epoch(new Date)+secs(e)},this}setIssuedAt(e){return typeof e>"u"?this._payload={...this._payload,iat:epoch(new Date)}:e instanceof Date?this._payload={...this._payload,iat:validateInput("setIssuedAt",epoch(e))}:typeof e=="string"?this._payload={...this._payload,iat:validateInput("setIssuedAt",epoch(new Date)+secs(e))}:this._payload={...this._payload,iat:validateInput("setIssuedAt",e)},this}}class SignJWT extends ProduceJWT{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,t){const n=new CompactSign(encoder.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new JWTInvalid("JWTs MUST NOT use unencoded payload");return n.sign(e,t)}}function getKtyFromAlg(i){switch(typeof i=="string"&&i.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set')}}function isJWKSLike(i){return i&&typeof i=="object"&&Array.isArray(i.keys)&&i.keys.every(isJWKLike)}function isJWKLike(i){return isObject$1(i)}function clone$1(i){return typeof structuredClone=="function"?structuredClone(i):JSON.parse(JSON.stringify(i))}class LocalJWKSet{constructor(e){if(this._cached=new WeakMap,!isJWKSLike(e))throw new JWKSInvalid("JSON Web Key Set malformed");this._jwks=clone$1(e)}async getKey(e,t){const{alg:n,kid:s}={...e,...t?.header},a=getKtyFromAlg(n),u=this._jwks.keys.filter(f=>{let p=a===f.kty;if(p&&typeof s=="string"&&(p=s===f.kid),p&&typeof f.alg=="string"&&(p=n===f.alg),p&&typeof f.use=="string"&&(p=f.use==="sig"),p&&Array.isArray(f.key_ops)&&(p=f.key_ops.includes("verify")),p)switch(n){case"ES256":p=f.crv==="P-256";break;case"ES256K":p=f.crv==="secp256k1";break;case"ES384":p=f.crv==="P-384";break;case"ES512":p=f.crv==="P-521";break;case"Ed25519":p=f.crv==="Ed25519";break;case"EdDSA":p=f.crv==="Ed25519"||f.crv==="Ed448";break}return p}),{0:c,length:h}=u;if(h===0)throw new JWKSNoMatchingKey;if(h!==1){const f=new JWKSMultipleMatchingKeys,{_cached:p}=this;throw f[Symbol.asyncIterator]=async function*(){for(const g of u)try{yield await importWithAlgCache(p,g,n)}catch{}},f}return importWithAlgCache(this._cached,c,n)}}async function importWithAlgCache(i,e,t){const n=i.get(e)||i.set(e,{}).get(e);if(n[t]===void 0){const s=await importJWK({...e,ext:!0},t);if(s instanceof Uint8Array||s.type!=="public")throw new JWKSInvalid("JSON Web Key Set members must be public keys");n[t]=s}return n[t]}function createLocalJWKSet(i){const e=new LocalJWKSet(i),t=async(n,s)=>e.getKey(n,s);return Object.defineProperties(t,{jwks:{value:()=>clone$1(e._jwks),enumerable:!0,configurable:!1,writable:!1}}),t}const fetchJwks=async(i,e,t)=>{let n,s,a=!1;typeof AbortController=="function"&&(n=new AbortController,s=setTimeout(()=>{a=!0,n.abort()},e));const u=await fetch(i.href,{signal:n?n.signal:void 0,redirect:"manual",headers:t.headers}).catch(c=>{throw a?new JWKSTimeout:c});if(s!==void 0&&clearTimeout(s),u.status!==200)throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await u.json()}catch{throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON")}};function isCloudflareWorkers(){return typeof WebSocketPair<"u"||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime<"u"&&EdgeRuntime==="vercel"}let USER_AGENT;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(USER_AGENT="jose/v5.10.0");const jwksCache=Symbol();function isFreshJwksCache(i,e){return!(typeof i!="object"||i===null||!("uat"in i)||typeof i.uat!="number"||Date.now()-i.uat>=e||!("jwks"in i)||!isObject$1(i.jwks)||!Array.isArray(i.jwks.keys)||!Array.prototype.every.call(i.jwks.keys,isObject$1))}class RemoteJWKSet{constructor(e,t){if(!(e instanceof URL))throw new TypeError("url must be an instance of URL");this._url=new URL(e.href),this._options={agent:t?.agent,headers:t?.headers},this._timeoutDuration=typeof t?.timeoutDuration=="number"?t?.timeoutDuration:5e3,this._cooldownDuration=typeof t?.cooldownDuration=="number"?t?.cooldownDuration:3e4,this._cacheMaxAge=typeof t?.cacheMaxAge=="number"?t?.cacheMaxAge:6e5,t?.[jwksCache]!==void 0&&(this._cache=t?.[jwksCache],isFreshJwksCache(t?.[jwksCache],this._cacheMaxAge)&&(this._jwksTimestamp=this._cache.uat,this._local=createLocalJWKSet(this._cache.jwks)))}coolingDown(){return typeof this._jwksTimestamp=="number"?Date.now()<this._jwksTimestamp+this._cooldownDuration:!1}fresh(){return typeof this._jwksTimestamp=="number"?Date.now()<this._jwksTimestamp+this._cacheMaxAge:!1}async getKey(e,t){(!this._local||!this.fresh())&&await this.reload();try{return await this._local(e,t)}catch(n){if(n instanceof JWKSNoMatchingKey&&this.coolingDown()===!1)return await this.reload(),this._local(e,t);throw n}}async reload(){this._pendingFetch&&isCloudflareWorkers()&&(this._pendingFetch=void 0);const e=new Headers(this._options.headers);USER_AGENT&&!e.has("User-Agent")&&(e.set("User-Agent",USER_AGENT),this._options.headers=Object.fromEntries(e.entries())),this._pendingFetch||(this._pendingFetch=fetchJwks(this._url,this._timeoutDuration,this._options).then(t=>{this._local=createLocalJWKSet(t),this._cache&&(this._cache.uat=Date.now(),this._cache.jwks=t),this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(t=>{throw this._pendingFetch=void 0,t})),await this._pendingFetch}}function createRemoteJWKSet(i,e){const t=new RemoteJWKSet(i,e),n=async(s,a)=>t.getKey(s,a);return Object.defineProperties(n,{coolingDown:{get:()=>t.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>t.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>t.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>!!t._pendingFetch,enumerable:!0,configurable:!1},jwks:{value:()=>t._local?.jwks(),enumerable:!0,configurable:!1,writable:!1}}),n}function getModulusLengthOption(i){const e=i?.modulusLength??2048;if(typeof e!="number"||e<2048)throw new JOSENotSupported("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return e}async function generateKeyPair$1(i,e){let t,n;switch(i){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${i.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:getModulusLengthOption(e)},n=["sign","verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${i.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:getModulusLengthOption(e)},n=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(i.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:getModulusLengthOption(e)},n=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":t={name:"ECDSA",namedCurve:"P-256"},n=["sign","verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},n=["sign","verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},n=["sign","verify"];break;case"Ed25519":t={name:"Ed25519"},n=["sign","verify"];break;case"EdDSA":{n=["sign","verify"];const s="Ed25519";switch(s){case"Ed25519":case"Ed448":t={name:s};break;default:throw new JOSENotSupported("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{n=["deriveKey","deriveBits"];const s="P-256";switch(s){case"P-256":case"P-384":case"P-521":{t={name:"ECDH",namedCurve:s};break}case"X25519":case"X448":t={name:s};break;default:throw new JOSENotSupported("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto$1.subtle.generateKey(t,!1,n)}async function generateKeyPair(i,e){return generateKeyPair$1(i,e)}const byteToHex=[];for(let i=0;i<256;++i)byteToHex.push((i+256).toString(16).slice(1));function unsafeStringify(i,e=0){return(byteToHex[i[e+0]]+byteToHex[i[e+1]]+byteToHex[i[e+2]]+byteToHex[i[e+3]]+"-"+byteToHex[i[e+4]]+byteToHex[i[e+5]]+"-"+byteToHex[i[e+6]]+byteToHex[i[e+7]]+"-"+byteToHex[i[e+8]]+byteToHex[i[e+9]]+"-"+byteToHex[i[e+10]]+byteToHex[i[e+11]]+byteToHex[i[e+12]]+byteToHex[i[e+13]]+byteToHex[i[e+14]]+byteToHex[i[e+15]]).toLowerCase()}let getRandomValues;const rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");getRandomValues=crypto.getRandomValues.bind(crypto)}return getRandomValues(rnds8)}const randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),native={randomUUID};function v4(i,e,t){if(native.randomUUID&&!i)return native.randomUUID();i=i||{};const n=i.random??i.rng?.()??rng();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,unsafeStringify(n)}const SOLID_CLIENT_AUTHN_KEY_PREFIX="solidClientAuthn:",PREFERRED_SIGNING_ALG=["ES256","RS256"],EVENTS={ERROR:"error",LOGIN:"login",LOGOUT:"logout",NEW_REFRESH_TOKEN:"newRefreshToken",NEW_TOKENS:"newTokens",AUTHORIZATION_REQUEST:"authorizationRequest",SESSION_EXPIRED:"sessionExpired",SESSION_EXTENDED:"sessionExtended",SESSION_RESTORED:"sessionRestore",TIMEOUT_SET:"timeoutSet"},REFRESH_BEFORE_EXPIRATION_SECONDS=5,SCOPE_OPENID="openid",SCOPE_OFFLINE="offline_access",SCOPE_WEBID="webid",DEFAULT_SCOPES=[SCOPE_OPENID,SCOPE_OFFLINE,SCOPE_WEBID];class AggregateHandler{handleables;constructor(e){this.handleables=e,this.handleables=e}async getProperHandler(e){const t=await Promise.all(this.handleables.map(n=>n.canHandle(...e)));for(let n=0;n<t.length;n+=1)if(t[n])return this.handleables[n];return null}async canHandle(...e){return await this.getProperHandler(e)!==null}async handle(...e){const t=await this.getProperHandler(e);if(t)return t.handle(...e);throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${e.map(n=>{try{return JSON.stringify(n)}catch{return n.toString()}}).join(", ")}`)}}async function getWebidFromTokenPayload(i,e,t,n){let s,a;try{const{payload:u}=await jwtVerify(i,createRemoteJWKSet(new URL(e)),{issuer:t,audience:n});s=u}catch(u){throw new Error(`Token verification failed: ${u.stack}`)}if(typeof s.azp=="string"&&(a=s.azp),typeof s.webid=="string")return{webId:s.webid,clientId:a};if(typeof s.sub!="string")throw new Error(`The token ${JSON.stringify(s)} is invalid: it has no 'webid' claim and no 'sub' claim.`);try{return new URL(s.sub),{webId:s.sub,clientId:a}}catch(u){throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${s.sub}] is invalid as a URL - error [${u}].`)}}function normalizeScopes(i){return Array.isArray(i)?Array.from(new Set([...DEFAULT_SCOPES,...i.filter(e=>typeof e=="string"&&!e.includes(" "))])):DEFAULT_SCOPES}function isValidRedirectUrl(i){try{const e=new URL(i),t=!e.searchParams.has("code")&&!e.searchParams.has("state"),n=e.hash==="";return t&&n}catch{return!1}}function removeOpenIdParams(i){const e=new URL(i);return e.searchParams.delete("state"),e.searchParams.delete("code"),e.searchParams.delete("error"),e.searchParams.delete("error_description"),e.searchParams.delete("iss"),e}function booleanWithFallback(i,e){return typeof i=="boolean"?!!i:!!e}class AuthorizationCodeWithPkceOidcHandlerBase{storageUtility;redirector;constructor(e,t){this.storageUtility=e,this.redirector=t,this.storageUtility=e,this.redirector=t}parametersGuard=e=>e.issuerConfiguration.grantTypesSupported!==void 0&&e.issuerConfiguration.grantTypesSupported.indexOf("authorization_code")>-1&&e.redirectUrl!==void 0;async canHandle(e){return this.parametersGuard(e)}async setupRedirectHandler({oidcLoginOptions:e,state:t,codeVerifier:n,targetUrl:s}){if(!this.parametersGuard(e))throw new Error("The authorization code grant requires a redirectUrl.");await Promise.all([this.storageUtility.setForUser(t,{sessionId:e.sessionId}),this.storageUtility.setForUser(e.sessionId,{codeVerifier:n,issuer:e.issuer.toString(),redirectUrl:e.redirectUrl,dpop:(!!e.dpop).toString(),keepAlive:booleanWithFallback(e.keepAlive,!0).toString()})]),this.redirector.redirect(s,{handleRedirect:e.handleRedirect})}}class GeneralLogoutHandler{sessionInfoManager;constructor(e){this.sessionInfoManager=e,this.sessionInfoManager=e}async canHandle(){return!0}async handle(e){await this.sessionInfoManager.clear(e)}}class IRpLogoutHandler{redirector;constructor(e){this.redirector=e,this.redirector=e}async canHandle(e,t){return t?.logoutType==="idp"}async handle(e,t){if(t?.logoutType!=="idp")throw new Error("Attempting to call idp logout handler to perform app logout");if(t.toLogoutUrl===void 0)throw new Error("Cannot perform IDP logout. Did you log in using the OIDC authentication flow?");this.redirector.redirect(t.toLogoutUrl(t),{handleRedirect:t.handleRedirect})}}class IWaterfallLogoutHandler{handlers;constructor(e,t){this.handlers=[new GeneralLogoutHandler(e),new IRpLogoutHandler(t)]}async canHandle(){return!0}async handle(e,t){for(const n of this.handlers)await n.canHandle(e,t)&&await n.handle(e,t)}}function getUnauthenticatedSession(){return{isLoggedIn:!1,sessionId:v4(),fetch:(...i)=>fetch(...i)}}async function clear$1(i,e){await Promise.all([e.deleteAllUserData(i,{secure:!1}),e.deleteAllUserData(i,{secure:!0})])}class SessionInfoManagerBase{storageUtility;constructor(e){this.storageUtility=e,this.storageUtility=e}update(e,t){throw new Error("Not Implemented")}set(e,t){throw new Error("Not Implemented")}get(e){throw new Error("Not implemented")}async getAll(){throw new Error("Not implemented")}async clear(e){return clear$1(e,this.storageUtility)}async register(e){throw new Error("Not implemented")}async getRegisteredSessionIdAll(){throw new Error("Not implemented")}async clearAll(){throw new Error("Not implemented")}async setOidcContext(e,t){throw new Error("Not implemented")}}function getEndSessionUrl({endSessionEndpoint:i,idTokenHint:e,postLogoutRedirectUri:t,state:n}){const s=new URL(i);return e!==void 0&&s.searchParams.append("id_token_hint",e),t!==void 0&&(s.searchParams.append("post_logout_redirect_uri",t),n!==void 0&&s.searchParams.append("state",n)),s.toString()}function maybeBuildRpInitiatedLogout({endSessionEndpoint:i,idTokenHint:e}){if(i!==void 0)return function({state:n,postLogoutUrl:s}){return getEndSessionUrl({endSessionEndpoint:i,idTokenHint:e,state:n,postLogoutRedirectUri:s})}}function isSupportedTokenType(i){return typeof i=="string"&&["DPoP","Bearer"].includes(i)}function isValidUrl$1(i){try{return new URL(i),!0}catch{return!1}}function determineSigningAlg(i,e){return e.find(t=>i.includes(t))??null}function isStaticClient(i){return i.clientId!==void 0&&!isValidUrl$1(i.clientId)}function isSolidOidcClient(i,e){return e.scopesSupported.includes("webid")&&i.clientId!==void 0&&isValidUrl$1(i.clientId)}function isKnownClientType(i){return typeof i=="string"&&["dynamic","static","solid-oidc"].includes(i)}async function handleRegistration(i,e,t,n){let s;if(isSolidOidcClient(i,e))s={clientId:i.clientId,clientName:i.clientName,clientType:"solid-oidc"};else if(isStaticClient(i))s={clientId:i.clientId,clientSecret:i.clientSecret,clientName:i.clientName,clientType:"static"};else return n.getClient({sessionId:i.sessionId,clientName:i.clientName,redirectUrl:i.redirectUrl},e);const a={clientId:s.clientId,clientType:s.clientType};return s.clientType==="static"&&(a.clientSecret=s.clientSecret),s.clientName&&(a.clientName=s.clientName),await t.setForUser(i.sessionId,a),s}const boundFetch=(i,e)=>fetch(i,e);let ClientAuthentication$1=class{loginHandler;redirectHandler;logoutHandler;sessionInfoManager;issuerConfigFetcher;boundLogout;constructor(e,t,n,s,a){this.loginHandler=e,this.redirectHandler=t,this.logoutHandler=n,this.sessionInfoManager=s,this.issuerConfigFetcher=a,this.loginHandler=e,this.redirectHandler=t,this.logoutHandler=n,this.sessionInfoManager=s,this.issuerConfigFetcher=a}fetch=boundFetch;logout=async(e,t)=>{await this.logoutHandler.handle(e,t?.logoutType==="idp"?{...t,toLogoutUrl:this.boundLogout}:t),this.fetch=boundFetch,delete this.boundLogout};getSessionInfo=async e=>this.sessionInfoManager.get(e);getAllSessionInfo=async()=>this.sessionInfoManager.getAll()};async function loadOidcContextFromStorage(i,e,t){try{const[n,s,a,u,c]=await Promise.all([e.getForUser(i,"issuer",{errorIfNull:!0}),e.getForUser(i,"codeVerifier"),e.getForUser(i,"redirectUrl"),e.getForUser(i,"dpop",{errorIfNull:!0}),e.getForUser(i,"keepAlive")]);await e.deleteForUser(i,"codeVerifier");const h=await t.fetchConfig(n);return{codeVerifier:s,redirectUrl:a,issuerConfig:h,dpop:u==="true",keepAlive:typeof c=="string"?c==="true":!0}}catch(n){throw new Error(`Failed to retrieve OIDC context from storage associated with session [${i}]: ${n}`)}}async function saveSessionInfoToStorage(i,e,t,n,s,a,u,c){t!==void 0&&await i.setForUser(e,{webId:t},{secure:u}),n!==void 0&&await i.setForUser(e,{clientId:n},{secure:u}),await i.setForUser(e,{isLoggedIn:s},{secure:u})}class StorageUtility{secureStorage;insecureStorage;constructor(e,t){this.secureStorage=e,this.insecureStorage=t,this.secureStorage=e,this.insecureStorage=t}getKey(e){return`solidClientAuthenticationUser:${e}`}async getUserData(e,t){const n=await(t?this.secureStorage:this.insecureStorage).get(this.getKey(e));if(n===void 0)return{};try{return JSON.parse(n)}catch{throw new Error(`Data for user [${e}] in [${t?"secure":"unsecure"}] storage is corrupted - expected valid JSON, but got: ${n}`)}}async setUserData(e,t,n){await(n?this.secureStorage:this.insecureStorage).set(this.getKey(e),JSON.stringify(t))}async get(e,t){const n=await(t?.secure?this.secureStorage:this.insecureStorage).get(e);if(n===void 0&&t?.errorIfNull)throw new Error(`[${e}] is not stored`);return n}async set(e,t,n){return(n?.secure?this.secureStorage:this.insecureStorage).set(e,t)}async delete(e,t){return(t?.secure?this.secureStorage:this.insecureStorage).delete(e)}async getForUser(e,t,n){const s=await this.getUserData(e,n?.secure);let a;if((!s||!s[t])&&(a=void 0),a=s[t],a===void 0&&n?.errorIfNull)throw new Error(`Field [${t}] for user [${e}] is not stored`);return a||void 0}async setForUser(e,t,n){let s;try{s=await this.getUserData(e,n?.secure)}catch{s={}}await this.setUserData(e,{...s,...t},n?.secure)}async deleteForUser(e,t,n){const s=await this.getUserData(e,n?.secure);delete s[t],await this.setUserData(e,s,n?.secure)}async deleteAllUserData(e,t){await(t?.secure?this.secureStorage:this.insecureStorage).delete(this.getKey(e))}}class InMemoryStorage{map={};async get(e){return this.map[e]||void 0}async set(e,t){this.map[e]=t}async delete(e){delete this.map[e]}}class ConfigurationError extends Error{constructor(e){super(e)}}class InvalidResponseError extends Error{missingFields;constructor(e){super(`Invalid response from OIDC provider: missing fields ${e}`),this.missingFields=e}}class OidcProviderError extends Error{error;errorDescription;constructor(e,t,n){super(e),this.error=t,this.errorDescription=n}}function normalizeHTU(i){const e=new URL(i);return new URL(e.pathname,e.origin).toString()}async function createDpopHeader(i,e,t){return new SignJWT({htu:normalizeHTU(i),htm:e.toUpperCase(),jti:v4()}).setProtectedHeader({alg:PREFERRED_SIGNING_ALG[0],jwk:t.publicKey,typ:"dpop+jwt"}).setIssuedAt().sign(t.privateKey,{})}async function generateDpopKeyPair(){const{privateKey:i,publicKey:e}=await generateKeyPair(PREFERRED_SIGNING_ALG[0]),t={privateKey:i,publicKey:await exportJWK(e)};return[t.publicKey.alg]=PREFERRED_SIGNING_ALG,t}const DEFAULT_EXPIRATION_TIME_SECONDS=600;function isExpectedAuthError(i){return[401,403].includes(i)}async function buildDpopFetchOptions(i,e,t,n){const s=new Headers(n?.headers);return s.set("Authorization",`DPoP ${e}`),s.set("DPoP",await createDpopHeader(i,n?.method??"get",t)),{...n,headers:s}}async function buildAuthenticatedHeaders(i,e,t,n){if(t!==void 0)return buildDpopFetchOptions(i,e,t,n);const s=new Headers(n?.headers);return s.set("Authorization",`Bearer ${e}`),{...n,headers:s}}async function makeAuthenticatedRequest(i,e,t,n,s=fetch){return s(e,await buildAuthenticatedHeaders(e.toString(),i,n,t))}async function refreshAccessToken(i,e,t){const n=await i.tokenRefresher.refresh(i.sessionId,i.refreshToken,e);return t?.emit(EVENTS.SESSION_EXTENDED,n.expiresIn??DEFAULT_EXPIRATION_TIME_SECONDS),{accessToken:n.accessToken,refreshToken:n.refreshToken,expiresIn:n.expiresIn}}const computeRefreshDelay=i=>i!==void 0?i-REFRESH_BEFORE_EXPIRATION_SECONDS>0?i-REFRESH_BEFORE_EXPIRATION_SECONDS:i:DEFAULT_EXPIRATION_TIME_SECONDS;function buildAuthenticatedFetch(i,e){let t=i,n;const s=e?.refreshOptions;if(s!==void 0){const a=async()=>{try{const{accessToken:u,refreshToken:c,expiresIn:h}=await refreshAccessToken(s,e.dpopKey,e.eventEmitter);t=u,c!==void 0&&(s.refreshToken=c),clearTimeout(n),n=setTimeout(a,computeRefreshDelay(h)*1e3),e.eventEmitter?.emit(EVENTS.TIMEOUT_SET,n)}catch(u){u instanceof OidcProviderError&&(e?.eventEmitter?.emit(EVENTS.ERROR,u.error,u.errorDescription),e?.eventEmitter?.emit(EVENTS.SESSION_EXPIRED)),u instanceof InvalidResponseError&&u.missingFields.includes("access_token")&&e?.eventEmitter?.emit(EVENTS.SESSION_EXPIRED)}};n=setTimeout(a,computeRefreshDelay(e.expiresIn)*1e3),e.eventEmitter?.emit(EVENTS.TIMEOUT_SET,n)}else if(e!==void 0&&e.eventEmitter!==void 0){const a=setTimeout(()=>{e.eventEmitter.emit(EVENTS.SESSION_EXPIRED)},computeRefreshDelay(e.expiresIn)*1e3);e.eventEmitter.emit(EVENTS.TIMEOUT_SET,a)}return async(a,u)=>{let c=await makeAuthenticatedRequest(t,a,u,e?.dpopKey,e?.fetch);const h=!c.ok&&!isExpectedAuthError(c.status);return c.ok||h||c.url!==a&&e?.dpopKey!==void 0&&(c=await makeAuthenticatedRequest(t,c.url,u,e.dpopKey,e.fetch)),c}}var events={exports:{}},hasRequiredEvents;function requireEvents(){if(hasRequiredEvents)return events.exports;hasRequiredEvents=1;var i=typeof Reflect=="object"?Reflect:null,e=i&&typeof i.apply=="function"?i.apply:function(O,K,z){return Function.prototype.apply.call(O,K,z)},t;i&&typeof i.ownKeys=="function"?t=i.ownKeys:Object.getOwnPropertySymbols?t=function(O){return Object.getOwnPropertyNames(O).concat(Object.getOwnPropertySymbols(O))}:t=function(O){return Object.getOwnPropertyNames(O)};function n(D){console&&console.warn&&console.warn(D)}var s=Number.isNaN||function(O){return O!==O};function a(){a.init.call(this)}events.exports=a,events.exports.once=A,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(D){if(typeof D!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof D)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(D){if(typeof D!="number"||D<0||s(D))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+D+".");u=D}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(O){if(typeof O!="number"||O<0||s(O))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+O+".");return this._maxListeners=O,this};function h(D){return D._maxListeners===void 0?a.defaultMaxListeners:D._maxListeners}a.prototype.getMaxListeners=function(){return h(this)},a.prototype.emit=function(O){for(var K=[],z=1;z<arguments.length;z++)K.push(arguments[z]);var X=O==="error",Ee=this._events;if(Ee!==void 0)X=X&&Ee.error===void 0;else if(!X)return!1;if(X){var q;if(K.length>0&&(q=K[0]),q instanceof Error)throw q;var Y=new Error("Unhandled error."+(q?" ("+q.message+")":""));throw Y.context=q,Y}var Te=Ee[O];if(Te===void 0)return!1;if(typeof Te=="function")e(Te,this,K);else for(var re=Te.length,$e=w(Te,re),z=0;z<re;++z)e($e[z],this,K);return!0};function f(D,O,K,z){var X,Ee,q;if(c(K),Ee=D._events,Ee===void 0?(Ee=D._events=Object.create(null),D._eventsCount=0):(Ee.newListener!==void 0&&(D.emit("newListener",O,K.listener?K.listener:K),Ee=D._events),q=Ee[O]),q===void 0)q=Ee[O]=K,++D._eventsCount;else if(typeof q=="function"?q=Ee[O]=z?[K,q]:[q,K]:z?q.unshift(K):q.push(K),X=h(D),X>0&&q.length>X&&!q.warned){q.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+q.length+" "+String(O)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=D,Y.type=O,Y.count=q.length,n(Y)}return D}a.prototype.addListener=function(O,K){return f(this,O,K,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(O,K){return f(this,O,K,!0)};function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function g(D,O,K){var z={fired:!1,wrapFn:void 0,target:D,type:O,listener:K},X=p.bind(z);return X.listener=K,z.wrapFn=X,X}a.prototype.once=function(O,K){return c(K),this.on(O,g(this,O,K)),this},a.prototype.prependOnceListener=function(O,K){return c(K),this.prependListener(O,g(this,O,K)),this},a.prototype.removeListener=function(O,K){var z,X,Ee,q,Y;if(c(K),X=this._events,X===void 0)return this;if(z=X[O],z===void 0)return this;if(z===K||z.listener===K)--this._eventsCount===0?this._events=Object.create(null):(delete X[O],X.removeListener&&this.emit("removeListener",O,z.listener||K));else if(typeof z!="function"){for(Ee=-1,q=z.length-1;q>=0;q--)if(z[q]===K||z[q].listener===K){Y=z[q].listener,Ee=q;break}if(Ee<0)return this;Ee===0?z.shift():R(z,Ee),z.length===1&&(X[O]=z[0]),X.removeListener!==void 0&&this.emit("removeListener",O,Y||K)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(O){var K,z,X;if(z=this._events,z===void 0)return this;if(z.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):z[O]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete z[O]),this;if(arguments.length===0){var Ee=Object.keys(z),q;for(X=0;X<Ee.length;++X)q=Ee[X],q!=="removeListener"&&this.removeAllListeners(q);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(K=z[O],typeof K=="function")this.removeListener(O,K);else if(K!==void 0)for(X=K.length-1;X>=0;X--)this.removeListener(O,K[X]);return this};function y(D,O,K){var z=D._events;if(z===void 0)return[];var X=z[O];return X===void 0?[]:typeof X=="function"?K?[X.listener||X]:[X]:K?T(X):w(X,X.length)}a.prototype.listeners=function(O){return y(this,O,!0)},a.prototype.rawListeners=function(O){return y(this,O,!1)},a.listenerCount=function(D,O){return typeof D.listenerCount=="function"?D.listenerCount(O):S.call(D,O)},a.prototype.listenerCount=S;function S(D){var O=this._events;if(O!==void 0){var K=O[D];if(typeof K=="function")return 1;if(K!==void 0)return K.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function w(D,O){for(var K=new Array(O),z=0;z<O;++z)K[z]=D[z];return K}function R(D,O){for(;O+1<D.length;O++)D[O]=D[O+1];D.pop()}function T(D){for(var O=new Array(D.length),K=0;K<O.length;++K)O[K]=D[K].listener||D[K];return O}function A(D,O){return new Promise(function(K,z){function X(q){D.removeListener(O,Ee),z(q)}function Ee(){typeof D.removeListener=="function"&&D.removeListener("error",X),K([].slice.call(arguments))}x(D,O,Ee,{once:!0}),O!=="error"&&F(D,X,{once:!0})})}function F(D,O,K){typeof D.on=="function"&&x(D,"error",O,K)}function x(D,O,K,z){if(typeof D.on=="function")z.once?D.once(O,K):D.on(O,K);else if(typeof D.addEventListener=="function")D.addEventListener(O,function X(Ee){z.once&&D.removeEventListener(O,X),K(Ee)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof D)}return events.exports}var eventsExports=requireEvents();const EventEmitter=getDefaultExportFromCjs(eventsExports);var oidcClient_min$1={exports:{}},oidcClient_min=oidcClient_min$1.exports,hasRequiredOidcClient_min;function requireOidcClient_min(){return hasRequiredOidcClient_min||(hasRequiredOidcClient_min=1,(function(i,e){(function(n,s){i.exports=s()})(oidcClient_min,(function(){return(function(t){var n={};function s(a){if(n[a])return n[a].exports;var u=n[a]={i:a,l:!1,exports:{}};return t[a].call(u.exports,u,u.exports,s),u.l=!0,u.exports}return s.m=t,s.c=n,s.d=function(a,u,c){s.o(a,u)||Object.defineProperty(a,u,{enumerable:!0,get:c})},s.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},s.t=function(a,u){if(1&u&&(a=s(a)),8&u||4&u&&typeof a=="object"&&a&&a.__esModule)return a;var c=Object.create(null);if(s.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:a}),2&u&&typeof a!="string")for(var h in a)s.d(c,h,(function(f){return a[f]}).bind(null,h));return c},s.n=function(a){var u=a&&a.__esModule?function(){return a.default}:function(){return a};return s.d(u,"a",u),u},s.o=function(a,u){return Object.prototype.hasOwnProperty.call(a,u)},s.p="",s(s.s=22)})([function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0});var a=(function(){function f(p,g){for(var y=0;y<g.length;y++){var S=g[y];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(p,S.key,S)}}return function(p,g,y){return g&&f(p.prototype,g),y&&f(p,y),p}})(),u={debug:function(){},info:function(){},warn:function(){},error:function(){}},c=void 0,h=void 0;(n.Log=(function(){function f(){(function(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")})(this,f)}return f.reset=function(){h=3,c=u},f.debug=function(){if(h>=4){for(var g=arguments.length,y=Array(g),S=0;S<g;S++)y[S]=arguments[S];c.debug.apply(c,Array.from(y))}},f.info=function(){if(h>=3){for(var g=arguments.length,y=Array(g),S=0;S<g;S++)y[S]=arguments[S];c.info.apply(c,Array.from(y))}},f.warn=function(){if(h>=2){for(var g=arguments.length,y=Array(g),S=0;S<g;S++)y[S]=arguments[S];c.warn.apply(c,Array.from(y))}},f.error=function(){if(h>=1){for(var g=arguments.length,y=Array(g),S=0;S<g;S++)y[S]=arguments[S];c.error.apply(c,Array.from(y))}},a(f,null,[{key:"NONE",get:function(){return 0}},{key:"ERROR",get:function(){return 1}},{key:"WARN",get:function(){return 2}},{key:"INFO",get:function(){return 3}},{key:"DEBUG",get:function(){return 4}},{key:"level",get:function(){return h},set:function(g){if(!(0<=g&&g<=4))throw new Error("Invalid log level");h=g}},{key:"logger",get:function(){return c},set:function(g){if(!g.debug&&g.info&&(g.debug=g.info),!(g.debug&&g.info&&g.warn&&g.error))throw new Error("Invalid logger");c=g}}]),f})()).reset()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0});var a=(function(){function f(p,g){for(var y=0;y<g.length;y++){var S=g[y];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(p,S.key,S)}}return function(p,g,y){return g&&f(p.prototype,g),y&&f(p,y),p}})(),u={setInterval:(function(f){function p(g,y){return f.apply(this,arguments)}return p.toString=function(){return f.toString()},p})((function(f,p){return setInterval(f,p)})),clearInterval:(function(f){function p(g){return f.apply(this,arguments)}return p.toString=function(){return f.toString()},p})((function(f){return clearInterval(f)}))},c=!1,h=null;n.Global=(function(){function f(){(function(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")})(this,f)}return f._testing=function(){c=!0},f.setXMLHttpRequest=function(g){h=g},a(f,null,[{key:"location",get:function(){if(!c)return location}},{key:"localStorage",get:function(){if(!c&&typeof window<"u")return localStorage}},{key:"sessionStorage",get:function(){if(!c&&typeof window<"u")return sessionStorage}},{key:"XMLHttpRequest",get:function(){if(!c&&typeof window<"u")return h||XMLHttpRequest}},{key:"timer",get:function(){if(!c)return u}}]),f})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.MetadataService=void 0;var a=(function(){function p(g,y){for(var S=0;S<y.length;S++){var w=y[S];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(g,w.key,w)}}return function(g,y,S){return y&&p(g.prototype,y),S&&p(g,S),g}})(),u=s(0),c=s(7);function h(p,g){if(!(p instanceof g))throw new TypeError("Cannot call a class as a function")}var f=".well-known/openid-configuration";n.MetadataService=(function(){function p(g){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c.JsonService;if(h(this,p),!g)throw u.Log.error("MetadataService: No settings passed to MetadataService"),new Error("settings");this._settings=g,this._jsonService=new y(["application/jwk-set+json"])}return p.prototype.resetSigningKeys=function(){this._settings=this._settings||{},this._settings.signingKeys=void 0},p.prototype.getMetadata=function(){var y=this;return this._settings.metadata?(u.Log.debug("MetadataService.getMetadata: Returning metadata from settings"),Promise.resolve(this._settings.metadata)):this.metadataUrl?(u.Log.debug("MetadataService.getMetadata: getting metadata from",this.metadataUrl),this._jsonService.getJson(this.metadataUrl).then((function(S){u.Log.debug("MetadataService.getMetadata: json received");var w=y._settings.metadataSeed||{};return y._settings.metadata=Object.assign({},w,S),y._settings.metadata}))):(u.Log.error("MetadataService.getMetadata: No authority or metadataUrl configured on settings"),Promise.reject(new Error("No authority or metadataUrl configured on settings")))},p.prototype.getIssuer=function(){return this._getMetadataProperty("issuer")},p.prototype.getAuthorizationEndpoint=function(){return this._getMetadataProperty("authorization_endpoint")},p.prototype.getUserInfoEndpoint=function(){return this._getMetadataProperty("userinfo_endpoint")},p.prototype.getTokenEndpoint=function(){var y=!(arguments.length>0&&arguments[0]!==void 0)||arguments[0];return this._getMetadataProperty("token_endpoint",y)},p.prototype.getCheckSessionIframe=function(){return this._getMetadataProperty("check_session_iframe",!0)},p.prototype.getEndSessionEndpoint=function(){return this._getMetadataProperty("end_session_endpoint",!0)},p.prototype.getRevocationEndpoint=function(){return this._getMetadataProperty("revocation_endpoint",!0)},p.prototype.getKeysEndpoint=function(){return this._getMetadataProperty("jwks_uri",!0)},p.prototype._getMetadataProperty=function(y){var S=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return u.Log.debug("MetadataService.getMetadataProperty for: "+y),this.getMetadata().then((function(w){if(u.Log.debug("MetadataService.getMetadataProperty: metadata recieved"),w[y]===void 0){if(S===!0)return void u.Log.warn("MetadataService.getMetadataProperty: Metadata does not contain optional property "+y);throw u.Log.error("MetadataService.getMetadataProperty: Metadata does not contain property "+y),new Error("Metadata does not contain property "+y)}return w[y]}))},p.prototype.getSigningKeys=function(){var y=this;return this._settings.signingKeys?(u.Log.debug("MetadataService.getSigningKeys: Returning signingKeys from settings"),Promise.resolve(this._settings.signingKeys)):this._getMetadataProperty("jwks_uri").then((function(S){return u.Log.debug("MetadataService.getSigningKeys: jwks_uri received",S),y._jsonService.getJson(S).then((function(w){if(u.Log.debug("MetadataService.getSigningKeys: key set received",w),!w.keys)throw u.Log.error("MetadataService.getSigningKeys: Missing keys on keyset"),new Error("Missing keys on keyset");return y._settings.signingKeys=w.keys,y._settings.signingKeys}))}))},a(p,[{key:"metadataUrl",get:function(){return this._metadataUrl||(this._settings.metadataUrl?this._metadataUrl=this._settings.metadataUrl:(this._metadataUrl=this._settings.authority,this._metadataUrl&&this._metadataUrl.indexOf(f)<0&&(this._metadataUrl[this._metadataUrl.length-1]!=="/"&&(this._metadataUrl+="/"),this._metadataUrl+=f))),this._metadataUrl}}]),p})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.UrlUtility=void 0;var a=s(0),u=s(1);n.UrlUtility=(function(){function c(){(function(f,p){if(!(f instanceof p))throw new TypeError("Cannot call a class as a function")})(this,c)}return c.addQueryParam=function(f,p,g){return f.indexOf("?")<0&&(f+="?"),f[f.length-1]!=="?"&&(f+="&"),f+=encodeURIComponent(p),f+="=",f+=encodeURIComponent(g)},c.parseUrlFragment=function(f){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"#",g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.Global;typeof f!="string"&&(f=g.location.href);var y=f.lastIndexOf(p);y>=0&&(f=f.substr(y+1)),p==="?"&&(y=f.indexOf("#"))>=0&&(f=f.substr(0,y));for(var S,w={},R=/([^&=]+)=([^&]*)/g,T=0;S=R.exec(f);)if(w[decodeURIComponent(S[1])]=decodeURIComponent(S[2].replace(/\+/g," ")),T++>50)return a.Log.error("UrlUtility.parseUrlFragment: response exceeded expected number of parameters",f),{error:"Response exceeded expected number of parameters"};for(var A in w)return w;return{}},c})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.JoseUtil=void 0;var a=s(26),u=(function(h){return h&&h.__esModule?h:{default:h}})(s(33));n.JoseUtil=(0,u.default)({jws:a.jws,KeyUtil:a.KeyUtil,X509:a.X509,crypto:a.crypto,hextob64u:a.hextob64u,b64tohex:a.b64tohex,AllowedSigningAlgs:a.AllowedSigningAlgs})},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.OidcClientSettings=void 0;var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},u=(function(){function A(F,x){for(var D=0;D<x.length;D++){var O=x[D];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(F,O.key,O)}}return function(F,x,D){return x&&A(F.prototype,x),D&&A(F,D),F}})(),c=s(0),h=s(23),f=s(6),p=s(24),g=s(2);function y(A,F){if(!(A instanceof F))throw new TypeError("Cannot call a class as a function")}var S=".well-known/openid-configuration",w="id_token",R="openid",T="client_secret_post";n.OidcClientSettings=(function(){function A(){var F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},x=F.authority,D=F.metadataUrl,O=F.metadata,K=F.signingKeys,z=F.metadataSeed,X=F.client_id,Ee=F.client_secret,q=F.response_type,Y=q===void 0?w:q,Te=F.scope,re=Te===void 0?R:Te,$e=F.redirect_uri,ze=F.post_logout_redirect_uri,ye=F.client_authentication,Ve=ye===void 0?T:ye,pe=F.prompt,De=F.display,$=F.max_age,G=F.ui_locales,ce=F.acr_values,oe=F.resource,Fe=F.response_mode,Ue=F.filterProtocolClaims,Je=Ue===void 0||Ue,He=F.loadUserInfo,he=He===void 0||He,fe=F.staleStateAge,Oe=fe===void 0?900:fe,ie=F.clockSkew,j=ie===void 0?300:ie,N=F.clockService,L=N===void 0?new h.ClockService:N,V=F.userInfoJwtIssuer,ee=V===void 0?"OP":V,ae=F.mergeClaims,ve=ae!==void 0&&ae,J=F.stateStore,me=J===void 0?new f.WebStorageStateStore:J,xe=F.ResponseValidatorCtor,de=xe===void 0?p.ResponseValidator:xe,st=F.MetadataServiceCtor,ft=st===void 0?g.MetadataService:st,Ge=F.extraQueryParams,pt=Ge===void 0?{}:Ge,Z=F.extraTokenParams,P=Z===void 0?{}:Z;y(this,A),this._authority=x,this._metadataUrl=D,this._metadata=O,this._metadataSeed=z,this._signingKeys=K,this._client_id=X,this._client_secret=Ee,this._response_type=Y,this._scope=re,this._redirect_uri=$e,this._post_logout_redirect_uri=ze,this._client_authentication=Ve,this._prompt=pe,this._display=De,this._max_age=$,this._ui_locales=G,this._acr_values=ce,this._resource=oe,this._response_mode=Fe,this._filterProtocolClaims=!!Je,this._loadUserInfo=!!he,this._staleStateAge=Oe,this._clockSkew=j,this._clockService=L,this._userInfoJwtIssuer=ee,this._mergeClaims=!!ve,this._stateStore=me,this._validator=new de(this),this._metadataService=new ft(this),this._extraQueryParams=(pt===void 0?"undefined":a(pt))==="object"?pt:{},this._extraTokenParams=(P===void 0?"undefined":a(P))==="object"?P:{}}return A.prototype.getEpochTime=function(){return this._clockService.getEpochTime()},u(A,[{key:"client_id",get:function(){return this._client_id},set:function(x){if(this._client_id)throw c.Log.error("OidcClientSettings.set_client_id: client_id has already been assigned."),new Error("client_id has already been assigned.");this._client_id=x}},{key:"client_secret",get:function(){return this._client_secret}},{key:"response_type",get:function(){return this._response_type}},{key:"scope",get:function(){return this._scope}},{key:"redirect_uri",get:function(){return this._redirect_uri}},{key:"post_logout_redirect_uri",get:function(){return this._post_logout_redirect_uri}},{key:"client_authentication",get:function(){return this._client_authentication}},{key:"prompt",get:function(){return this._prompt}},{key:"display",get:function(){return this._display}},{key:"max_age",get:function(){return this._max_age}},{key:"ui_locales",get:function(){return this._ui_locales}},{key:"acr_values",get:function(){return this._acr_values}},{key:"resource",get:function(){return this._resource}},{key:"response_mode",get:function(){return this._response_mode}},{key:"authority",get:function(){return this._authority},set:function(x){if(this._authority)throw c.Log.error("OidcClientSettings.set_authority: authority has already been assigned."),new Error("authority has already been assigned.");this._authority=x}},{key:"metadataUrl",get:function(){return this._metadataUrl||(this._metadataUrl=this.authority,this._metadataUrl&&this._metadataUrl.indexOf(S)<0&&(this._metadataUrl[this._metadataUrl.length-1]!=="/"&&(this._metadataUrl+="/"),this._metadataUrl+=S)),this._metadataUrl}},{key:"metadata",get:function(){return this._metadata},set:function(x){this._metadata=x}},{key:"metadataSeed",get:function(){return this._metadataSeed},set:function(x){this._metadataSeed=x}},{key:"signingKeys",get:function(){return this._signingKeys},set:function(x){this._signingKeys=x}},{key:"filterProtocolClaims",get:function(){return this._filterProtocolClaims}},{key:"loadUserInfo",get:function(){return this._loadUserInfo}},{key:"staleStateAge",get:function(){return this._staleStateAge}},{key:"clockSkew",get:function(){return this._clockSkew}},{key:"userInfoJwtIssuer",get:function(){return this._userInfoJwtIssuer}},{key:"mergeClaims",get:function(){return this._mergeClaims}},{key:"stateStore",get:function(){return this._stateStore}},{key:"validator",get:function(){return this._validator}},{key:"metadataService",get:function(){return this._metadataService}},{key:"extraQueryParams",get:function(){return this._extraQueryParams},set:function(x){(x===void 0?"undefined":a(x))==="object"?this._extraQueryParams=x:this._extraQueryParams={}}},{key:"extraTokenParams",get:function(){return this._extraTokenParams},set:function(x){(x===void 0?"undefined":a(x))==="object"?this._extraTokenParams=x:this._extraTokenParams={}}}]),A})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.WebStorageStateStore=void 0;var a=s(0),u=s(1);function c(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")}n.WebStorageStateStore=(function(){function h(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=f.prefix,g=p===void 0?"oidc.":p,y=f.store,S=y===void 0?u.Global.localStorage:y;c(this,h),this._store=S,this._prefix=g}return h.prototype.set=function(p,g){return a.Log.debug("WebStorageStateStore.set",p),p=this._prefix+p,this._store.setItem(p,g),Promise.resolve()},h.prototype.get=function(p){a.Log.debug("WebStorageStateStore.get",p),p=this._prefix+p;var g=this._store.getItem(p);return Promise.resolve(g)},h.prototype.remove=function(p){a.Log.debug("WebStorageStateStore.remove",p),p=this._prefix+p;var g=this._store.getItem(p);return this._store.removeItem(p),Promise.resolve(g)},h.prototype.getAllKeys=function(){a.Log.debug("WebStorageStateStore.getAllKeys");for(var p=[],g=0;g<this._store.length;g++){var y=this._store.key(g);y.indexOf(this._prefix)===0&&p.push(y.substr(this._prefix.length))}return Promise.resolve(p)},h})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.JsonService=void 0;var a=s(0),u=s(1);function c(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")}n.JsonService=(function(){function h(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.Global.XMLHttpRequest,g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;c(this,h),f&&Array.isArray(f)?this._contentTypes=f.slice():this._contentTypes=[],this._contentTypes.push("application/json"),g&&this._contentTypes.push("application/jwt"),this._XMLHttpRequest=p,this._jwtHandler=g}return h.prototype.getJson=function(p,g){var y=this;if(!p)throw a.Log.error("JsonService.getJson: No url passed"),new Error("url");return a.Log.debug("JsonService.getJson, url: ",p),new Promise((function(S,w){var R=new y._XMLHttpRequest;R.open("GET",p);var T=y._contentTypes,A=y._jwtHandler;R.onload=function(){if(a.Log.debug("JsonService.getJson: HTTP response received, status",R.status),R.status===200){var F=R.getResponseHeader("Content-Type");if(F){var x=T.find((function(D){if(F.startsWith(D))return!0}));if(x=="application/jwt")return void A(R).then(S,w);if(x)try{return void S(JSON.parse(R.responseText))}catch(D){return a.Log.error("JsonService.getJson: Error parsing JSON response",D.message),void w(D)}}w(Error("Invalid response Content-Type: "+F+", from URL: "+p))}else w(Error(R.statusText+" ("+R.status+")"))},R.onerror=function(){a.Log.error("JsonService.getJson: network error"),w(Error("Network Error"))},g&&(a.Log.debug("JsonService.getJson: token passed, setting Authorization header"),R.setRequestHeader("Authorization","Bearer "+g)),R.send()}))},h.prototype.postForm=function(p,g,y){var S=this;if(!p)throw a.Log.error("JsonService.postForm: No url passed"),new Error("url");return a.Log.debug("JsonService.postForm, url: ",p),new Promise((function(w,R){var T=new S._XMLHttpRequest;T.open("POST",p);var A=S._contentTypes;T.onload=function(){if(a.Log.debug("JsonService.postForm: HTTP response received, status",T.status),T.status!==200){if(T.status===400&&(K=T.getResponseHeader("Content-Type"))&&A.find((function(z){if(K.startsWith(z))return!0})))try{var O=JSON.parse(T.responseText);if(O&&O.error)return a.Log.error("JsonService.postForm: Error from server: ",O.error),void R(new Error(O.error))}catch(z){return a.Log.error("JsonService.postForm: Error parsing JSON response",z.message),void R(z)}R(Error(T.statusText+" ("+T.status+")"))}else{var K;if((K=T.getResponseHeader("Content-Type"))&&A.find((function(z){if(K.startsWith(z))return!0})))try{return void w(JSON.parse(T.responseText))}catch(z){return a.Log.error("JsonService.postForm: Error parsing JSON response",z.message),void R(z)}R(Error("Invalid response Content-Type: "+K+", from URL: "+p))}},T.onerror=function(){a.Log.error("JsonService.postForm: network error"),R(Error("Network Error"))};var F="";for(var x in g){var D=g[x];D&&(F.length>0&&(F+="&"),F+=encodeURIComponent(x),F+="=",F+=encodeURIComponent(D))}T.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),y!==void 0&&T.setRequestHeader("Authorization","Basic "+btoa(y)),T.send(F)}))},h})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.SigninRequest=void 0;var a=s(0),u=s(3),c=s(13);n.SigninRequest=(function(){function h(f){var p=f.url,g=f.client_id,y=f.redirect_uri,S=f.response_type,w=f.scope,R=f.authority,T=f.data,A=f.prompt,F=f.display,x=f.max_age,D=f.ui_locales,O=f.id_token_hint,K=f.login_hint,z=f.acr_values,X=f.resource,Ee=f.response_mode,q=f.request,Y=f.request_uri,Te=f.extraQueryParams,re=f.request_type,$e=f.client_secret,ze=f.extraTokenParams,ye=f.skipUserInfo;if((function(oe,Fe){if(!(oe instanceof Fe))throw new TypeError("Cannot call a class as a function")})(this,h),!p)throw a.Log.error("SigninRequest.ctor: No url passed"),new Error("url");if(!g)throw a.Log.error("SigninRequest.ctor: No client_id passed"),new Error("client_id");if(!y)throw a.Log.error("SigninRequest.ctor: No redirect_uri passed"),new Error("redirect_uri");if(!S)throw a.Log.error("SigninRequest.ctor: No response_type passed"),new Error("response_type");if(!w)throw a.Log.error("SigninRequest.ctor: No scope passed"),new Error("scope");if(!R)throw a.Log.error("SigninRequest.ctor: No authority passed"),new Error("authority");var Ve=h.isOidc(S),pe=h.isCode(S);Ee||(Ee=h.isCode(S)?"query":null),this.state=new c.SigninState({nonce:Ve,data:T,client_id:g,authority:R,redirect_uri:y,code_verifier:pe,request_type:re,response_mode:Ee,client_secret:$e,scope:w,extraTokenParams:ze,skipUserInfo:ye}),p=u.UrlUtility.addQueryParam(p,"client_id",g),p=u.UrlUtility.addQueryParam(p,"redirect_uri",y),p=u.UrlUtility.addQueryParam(p,"response_type",S),p=u.UrlUtility.addQueryParam(p,"scope",w),p=u.UrlUtility.addQueryParam(p,"state",this.state.id),Ve&&(p=u.UrlUtility.addQueryParam(p,"nonce",this.state.nonce)),pe&&(p=u.UrlUtility.addQueryParam(p,"code_challenge",this.state.code_challenge),p=u.UrlUtility.addQueryParam(p,"code_challenge_method","S256"));var De={prompt:A,display:F,max_age:x,ui_locales:D,id_token_hint:O,login_hint:K,acr_values:z,resource:X,request:q,request_uri:Y,response_mode:Ee};for(var $ in De)De[$]&&(p=u.UrlUtility.addQueryParam(p,$,De[$]));for(var G in Te)p=u.UrlUtility.addQueryParam(p,G,Te[G]);this.url=p}return h.isOidc=function(p){return!!p.split(/\s+/g).filter((function(g){return g==="id_token"}))[0]},h.isOAuth=function(p){return!!p.split(/\s+/g).filter((function(g){return g==="token"}))[0]},h.isCode=function(p){return!!p.split(/\s+/g).filter((function(g){return g==="code"}))[0]},h})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.State=void 0;var a=(function(){function f(p,g){for(var y=0;y<g.length;y++){var S=g[y];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(p,S.key,S)}}return function(p,g,y){return g&&f(p.prototype,g),y&&f(p,y),p}})(),u=s(0),c=(function(p){return p&&p.__esModule?p:{default:p}})(s(14));function h(f,p){if(!(f instanceof p))throw new TypeError("Cannot call a class as a function")}n.State=(function(){function f(){var p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},g=p.id,y=p.data,S=p.created,w=p.request_type;h(this,f),this._id=g||(0,c.default)(),this._data=y,this._created=typeof S=="number"&&S>0?S:parseInt(Date.now()/1e3),this._request_type=w}return f.prototype.toStorageString=function(){return u.Log.debug("State.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type})},f.fromStorageString=function(g){return u.Log.debug("State.fromStorageString"),new f(JSON.parse(g))},f.clearStaleState=function(g,y){var S=Date.now()/1e3-y;return g.getAllKeys().then((function(w){u.Log.debug("State.clearStaleState: got keys",w);for(var R=[],T=function(D){var O=w[D];F=g.get(O).then((function(K){var z=!1;if(K)try{var X=f.fromStorageString(K);u.Log.debug("State.clearStaleState: got item from key: ",O,X.created),X.created<=S&&(z=!0)}catch(Ee){u.Log.error("State.clearStaleState: Error parsing state for key",O,Ee.message),z=!0}else u.Log.debug("State.clearStaleState: no item in storage for key: ",O),z=!0;if(z)return u.Log.debug("State.clearStaleState: removed item for key: ",O),g.remove(O)})),R.push(F)},A=0;A<w.length;A++){var F;T(A)}return u.Log.debug("State.clearStaleState: waiting on promise count:",R.length),Promise.all(R)}))},a(f,[{key:"id",get:function(){return this._id}},{key:"data",get:function(){return this._data}},{key:"created",get:function(){return this._created}},{key:"request_type",get:function(){return this._request_type}}]),f})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.OidcClient=void 0;var a=(function(){function T(A,F){for(var x=0;x<F.length;x++){var D=F[x];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(A,D.key,D)}}return function(A,F,x){return F&&T(A.prototype,F),x&&T(A,x),A}})(),u=s(0),c=s(5),h=s(12),f=s(8),p=s(34),g=s(35),y=s(36),S=s(13),w=s(9);function R(T,A){if(!(T instanceof A))throw new TypeError("Cannot call a class as a function")}n.OidcClient=(function(){function T(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};R(this,T),A instanceof c.OidcClientSettings?this._settings=A:this._settings=new c.OidcClientSettings(A)}return T.prototype.createSigninRequest=function(){var F=this,x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},D=x.response_type,O=x.scope,K=x.redirect_uri,z=x.data,X=x.state,Ee=x.prompt,q=x.display,Y=x.max_age,Te=x.ui_locales,re=x.id_token_hint,$e=x.login_hint,ze=x.acr_values,ye=x.resource,Ve=x.request,pe=x.request_uri,De=x.response_mode,$=x.extraQueryParams,G=x.extraTokenParams,ce=x.request_type,oe=x.skipUserInfo,Fe=arguments[1];u.Log.debug("OidcClient.createSigninRequest");var Ue=this._settings.client_id;D=D||this._settings.response_type,O=O||this._settings.scope,K=K||this._settings.redirect_uri,Ee=Ee||this._settings.prompt,q=q||this._settings.display,Y=Y||this._settings.max_age,Te=Te||this._settings.ui_locales,ze=ze||this._settings.acr_values,ye=ye||this._settings.resource,De=De||this._settings.response_mode,$=$||this._settings.extraQueryParams,G=G||this._settings.extraTokenParams;var Je=this._settings.authority;return f.SigninRequest.isCode(D)&&D!=="code"?Promise.reject(new Error("OpenID Connect hybrid flow is not supported")):this._metadataService.getAuthorizationEndpoint().then((function(He){u.Log.debug("OidcClient.createSigninRequest: Received authorization endpoint",He);var he=new f.SigninRequest({url:He,client_id:Ue,redirect_uri:K,response_type:D,scope:O,data:z||X,authority:Je,prompt:Ee,display:q,max_age:Y,ui_locales:Te,id_token_hint:re,login_hint:$e,acr_values:ze,resource:ye,request:Ve,request_uri:pe,extraQueryParams:$,extraTokenParams:G,request_type:ce,response_mode:De,client_secret:F._settings.client_secret,skipUserInfo:oe}),fe=he.state;return(Fe=Fe||F._stateStore).set(fe.id,fe.toStorageString()).then((function(){return he}))}))},T.prototype.readSigninResponseState=function(F,x){var D=arguments.length>2&&arguments[2]!==void 0&&arguments[2];u.Log.debug("OidcClient.readSigninResponseState");var O=this._settings.response_mode==="query"||!this._settings.response_mode&&f.SigninRequest.isCode(this._settings.response_type),K=O?"?":"#",z=new p.SigninResponse(F,K);if(!z.state)return u.Log.error("OidcClient.readSigninResponseState: No state in response"),Promise.reject(new Error("No state in response"));x=x||this._stateStore;var X=D?x.remove.bind(x):x.get.bind(x);return X(z.state).then((function(Ee){if(!Ee)throw u.Log.error("OidcClient.readSigninResponseState: No matching state found in storage"),new Error("No matching state found in storage");return{state:S.SigninState.fromStorageString(Ee),response:z}}))},T.prototype.processSigninResponse=function(F,x){var D=this;return u.Log.debug("OidcClient.processSigninResponse"),this.readSigninResponseState(F,x,!0).then((function(O){var K=O.state,z=O.response;return u.Log.debug("OidcClient.processSigninResponse: Received state from storage; validating response"),D._validator.validateSigninResponse(K,z)}))},T.prototype.createSignoutRequest=function(){var F=this,x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},D=x.id_token_hint,O=x.data,K=x.state,z=x.post_logout_redirect_uri,X=x.extraQueryParams,Ee=x.request_type,q=arguments[1];return u.Log.debug("OidcClient.createSignoutRequest"),z=z||this._settings.post_logout_redirect_uri,X=X||this._settings.extraQueryParams,this._metadataService.getEndSessionEndpoint().then((function(Y){if(!Y)throw u.Log.error("OidcClient.createSignoutRequest: No end session endpoint url returned"),new Error("no end session endpoint");u.Log.debug("OidcClient.createSignoutRequest: Received end session endpoint",Y);var Te=new g.SignoutRequest({url:Y,id_token_hint:D,post_logout_redirect_uri:z,data:O||K,extraQueryParams:X,request_type:Ee}),re=Te.state;return re&&(u.Log.debug("OidcClient.createSignoutRequest: Signout request has state to persist"),(q=q||F._stateStore).set(re.id,re.toStorageString())),Te}))},T.prototype.readSignoutResponseState=function(F,x){var D=arguments.length>2&&arguments[2]!==void 0&&arguments[2];u.Log.debug("OidcClient.readSignoutResponseState");var O=new y.SignoutResponse(F);if(!O.state)return u.Log.debug("OidcClient.readSignoutResponseState: No state in response"),O.error?(u.Log.warn("OidcClient.readSignoutResponseState: Response was error: ",O.error),Promise.reject(new h.ErrorResponse(O))):Promise.resolve({state:void 0,response:O});var K=O.state;x=x||this._stateStore;var z=D?x.remove.bind(x):x.get.bind(x);return z(K).then((function(X){if(!X)throw u.Log.error("OidcClient.readSignoutResponseState: No matching state found in storage"),new Error("No matching state found in storage");return{state:w.State.fromStorageString(X),response:O}}))},T.prototype.processSignoutResponse=function(F,x){var D=this;return u.Log.debug("OidcClient.processSignoutResponse"),this.readSignoutResponseState(F,x,!0).then((function(O){var K=O.state,z=O.response;return K?(u.Log.debug("OidcClient.processSignoutResponse: Received state from storage; validating response"),D._validator.validateSignoutResponse(K,z)):(u.Log.debug("OidcClient.processSignoutResponse: No state from storage; skipping validating response"),z)}))},T.prototype.clearStaleState=function(F){return u.Log.debug("OidcClient.clearStaleState"),F=F||this._stateStore,w.State.clearStaleState(F,this.settings.staleStateAge)},a(T,[{key:"_stateStore",get:function(){return this.settings.stateStore}},{key:"_validator",get:function(){return this.settings.validator}},{key:"_metadataService",get:function(){return this.settings.metadataService}},{key:"settings",get:function(){return this._settings}},{key:"metadataService",get:function(){return this._metadataService}}]),T})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.TokenClient=void 0;var a=s(7),u=s(2),c=s(0);function h(f,p){if(!(f instanceof p))throw new TypeError("Cannot call a class as a function")}n.TokenClient=(function(){function f(p){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:a.JsonService,y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.MetadataService;if(h(this,f),!p)throw c.Log.error("TokenClient.ctor: No settings passed"),new Error("settings");this._settings=p,this._jsonService=new g,this._metadataService=new y(this._settings)}return f.prototype.exchangeCode=function(){var g=this,y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(y=Object.assign({},y)).grant_type=y.grant_type||"authorization_code",y.client_id=y.client_id||this._settings.client_id,y.client_secret=y.client_secret||this._settings.client_secret,y.redirect_uri=y.redirect_uri||this._settings.redirect_uri;var S=void 0,w=y._client_authentication||this._settings._client_authentication;return delete y._client_authentication,y.code?y.redirect_uri?y.code_verifier?y.client_id?y.client_secret||w!="client_secret_basic"?(w=="client_secret_basic"&&(S=y.client_id+":"+y.client_secret,delete y.client_id,delete y.client_secret),this._metadataService.getTokenEndpoint(!1).then((function(R){return c.Log.debug("TokenClient.exchangeCode: Received token endpoint"),g._jsonService.postForm(R,y,S).then((function(T){return c.Log.debug("TokenClient.exchangeCode: response received"),T}))}))):(c.Log.error("TokenClient.exchangeCode: No client_secret passed"),Promise.reject(new Error("A client_secret is required"))):(c.Log.error("TokenClient.exchangeCode: No client_id passed"),Promise.reject(new Error("A client_id is required"))):(c.Log.error("TokenClient.exchangeCode: No code_verifier passed"),Promise.reject(new Error("A code_verifier is required"))):(c.Log.error("TokenClient.exchangeCode: No redirect_uri passed"),Promise.reject(new Error("A redirect_uri is required"))):(c.Log.error("TokenClient.exchangeCode: No code passed"),Promise.reject(new Error("A code is required")))},f.prototype.exchangeRefreshToken=function(){var g=this,y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(y=Object.assign({},y)).grant_type=y.grant_type||"refresh_token",y.client_id=y.client_id||this._settings.client_id,y.client_secret=y.client_secret||this._settings.client_secret;var S=void 0,w=y._client_authentication||this._settings._client_authentication;return delete y._client_authentication,y.refresh_token?y.client_id?(w=="client_secret_basic"&&(S=y.client_id+":"+y.client_secret,delete y.client_id,delete y.client_secret),this._metadataService.getTokenEndpoint(!1).then((function(R){return c.Log.debug("TokenClient.exchangeRefreshToken: Received token endpoint"),g._jsonService.postForm(R,y,S).then((function(T){return c.Log.debug("TokenClient.exchangeRefreshToken: response received"),T}))}))):(c.Log.error("TokenClient.exchangeRefreshToken: No client_id passed"),Promise.reject(new Error("A client_id is required"))):(c.Log.error("TokenClient.exchangeRefreshToken: No refresh_token passed"),Promise.reject(new Error("A refresh_token is required")))},f})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.ErrorResponse=void 0;var a=s(0);function u(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")}function c(h,f){if(!h)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!f||typeof f!="object"&&typeof f!="function"?h:f}n.ErrorResponse=(function(h){function f(){var p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},g=p.error,y=p.error_description,S=p.error_uri,w=p.state,R=p.session_state;if(u(this,f),!g)throw a.Log.error("No error passed to ErrorResponse"),new Error("error");var T=c(this,h.call(this,y||g));return T.name="ErrorResponse",T.error=g,T.error_description=y,T.error_uri=S,T.state=w,T.session_state=R,T}return(function(g,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);g.prototype=Object.create(y&&y.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(g,y):g.__proto__=y)})(f,h),f})(Error)},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.SigninState=void 0;var a=(function(){function y(S,w){for(var R=0;R<w.length;R++){var T=w[R];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(S,T.key,T)}}return function(S,w,R){return w&&y(S.prototype,w),R&&y(S,R),S}})(),u=s(0),c=s(9),h=s(4),f=(function(S){return S&&S.__esModule?S:{default:S}})(s(14));function p(y,S){if(!(y instanceof S))throw new TypeError("Cannot call a class as a function")}function g(y,S){if(!y)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!S||typeof S!="object"&&typeof S!="function"?y:S}n.SigninState=(function(y){function S(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},R=w.nonce,T=w.authority,A=w.client_id,F=w.redirect_uri,x=w.code_verifier,D=w.response_mode,O=w.client_secret,K=w.scope,z=w.extraTokenParams,X=w.skipUserInfo;p(this,S);var Ee=g(this,y.call(this,arguments[0]));if(R===!0?Ee._nonce=(0,f.default)():R&&(Ee._nonce=R),x===!0?Ee._code_verifier=(0,f.default)()+(0,f.default)()+(0,f.default)():x&&(Ee._code_verifier=x),Ee.code_verifier){var q=h.JoseUtil.hashString(Ee.code_verifier,"SHA256");Ee._code_challenge=h.JoseUtil.hexToBase64Url(q)}return Ee._redirect_uri=F,Ee._authority=T,Ee._client_id=A,Ee._response_mode=D,Ee._client_secret=O,Ee._scope=K,Ee._extraTokenParams=z,Ee._skipUserInfo=X,Ee}return(function(R,T){if(typeof T!="function"&&T!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof T);R.prototype=Object.create(T&&T.prototype,{constructor:{value:R,enumerable:!1,writable:!0,configurable:!0}}),T&&(Object.setPrototypeOf?Object.setPrototypeOf(R,T):R.__proto__=T)})(S,y),S.prototype.toStorageString=function(){return u.Log.debug("SigninState.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,nonce:this.nonce,code_verifier:this.code_verifier,redirect_uri:this.redirect_uri,authority:this.authority,client_id:this.client_id,response_mode:this.response_mode,client_secret:this.client_secret,scope:this.scope,extraTokenParams:this.extraTokenParams,skipUserInfo:this.skipUserInfo})},S.fromStorageString=function(R){return u.Log.debug("SigninState.fromStorageString"),new S(JSON.parse(R))},a(S,[{key:"nonce",get:function(){return this._nonce}},{key:"authority",get:function(){return this._authority}},{key:"client_id",get:function(){return this._client_id}},{key:"redirect_uri",get:function(){return this._redirect_uri}},{key:"code_verifier",get:function(){return this._code_verifier}},{key:"code_challenge",get:function(){return this._code_challenge}},{key:"response_mode",get:function(){return this._response_mode}},{key:"client_secret",get:function(){return this._client_secret}},{key:"scope",get:function(){return this._scope}},{key:"extraTokenParams",get:function(){return this._extraTokenParams}},{key:"skipUserInfo",get:function(){return this._skipUserInfo}}]),S})(c.State)},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(){return(a!="undefined"&&a!==null&&a.getRandomValues!==void 0?u:c)().replace(/-/g,"")};var a=typeof window<"u"?window.crypto||window.msCrypto:null;function u(){return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,(function(h){return(h^a.getRandomValues(new Uint8Array(1))[0]&15>>h/4).toString(16)}))}function c(){return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,(function(h){return(h^16*Math.random()>>h/4).toString(16)}))}t.exports=n.default},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.User=void 0;var a=(function(){function c(h,f){for(var p=0;p<f.length;p++){var g=f[p];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(h,g.key,g)}}return function(h,f,p){return f&&c(h.prototype,f),p&&c(h,p),h}})(),u=s(0);n.User=(function(){function c(h){var f=h.id_token,p=h.session_state,g=h.access_token,y=h.refresh_token,S=h.token_type,w=h.scope,R=h.profile,T=h.expires_at,A=h.state;(function(x,D){if(!(x instanceof D))throw new TypeError("Cannot call a class as a function")})(this,c),this.id_token=f,this.session_state=p,this.access_token=g,this.refresh_token=y,this.token_type=S,this.scope=w,this.profile=R,this.expires_at=T,this.state=A}return c.prototype.toStorageString=function(){return u.Log.debug("User.toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})},c.fromStorageString=function(f){return u.Log.debug("User.fromStorageString"),new c(JSON.parse(f))},a(c,[{key:"expires_in",get:function(){if(this.expires_at){var f=parseInt(Date.now()/1e3);return this.expires_at-f}},set:function(f){var p=parseInt(f);if(typeof p=="number"&&p>0){var g=parseInt(Date.now()/1e3);this.expires_at=g+p}}},{key:"expired",get:function(){var f=this.expires_in;if(f!==void 0)return f<=0}},{key:"scopes",get:function(){return(this.scope||"").split(" ")}}]),c})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.AccessTokenEvents=void 0;var a=s(0),u=s(46);function c(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")}n.AccessTokenEvents=(function(){function h(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=f.accessTokenExpiringNotificationTime,g=p===void 0?60:p,y=f.accessTokenExpiringTimer,S=y===void 0?new u.Timer("Access token expiring"):y,w=f.accessTokenExpiredTimer,R=w===void 0?new u.Timer("Access token expired"):w;c(this,h),this._accessTokenExpiringNotificationTime=g,this._accessTokenExpiring=S,this._accessTokenExpired=R}return h.prototype.load=function(p){if(p.access_token&&p.expires_in!==void 0){var g=p.expires_in;if(a.Log.debug("AccessTokenEvents.load: access token present, remaining duration:",g),g>0){var y=g-this._accessTokenExpiringNotificationTime;y<=0&&(y=1),a.Log.debug("AccessTokenEvents.load: registering expiring timer in:",y),this._accessTokenExpiring.init(y)}else a.Log.debug("AccessTokenEvents.load: canceling existing expiring timer becase we're past expiration."),this._accessTokenExpiring.cancel();var S=g+1;a.Log.debug("AccessTokenEvents.load: registering expired timer in:",S),this._accessTokenExpired.init(S)}else this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},h.prototype.unload=function(){a.Log.debug("AccessTokenEvents.unload: canceling existing access token timers"),this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},h.prototype.addAccessTokenExpiring=function(p){this._accessTokenExpiring.addHandler(p)},h.prototype.removeAccessTokenExpiring=function(p){this._accessTokenExpiring.removeHandler(p)},h.prototype.addAccessTokenExpired=function(p){this._accessTokenExpired.addHandler(p)},h.prototype.removeAccessTokenExpired=function(p){this._accessTokenExpired.removeHandler(p)},h})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.Event=void 0;var a=s(0);n.Event=(function(){function u(c){(function(f,p){if(!(f instanceof p))throw new TypeError("Cannot call a class as a function")})(this,u),this._name=c,this._callbacks=[]}return u.prototype.addHandler=function(h){this._callbacks.push(h)},u.prototype.removeHandler=function(h){var f=this._callbacks.findIndex((function(p){return p===h}));f>=0&&this._callbacks.splice(f,1)},u.prototype.raise=function(){a.Log.debug("Event: Raising event: "+this._name);for(var h=0;h<this._callbacks.length;h++){var f;(f=this._callbacks)[h].apply(f,arguments)}},u})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.SessionMonitor=void 0;var a=(function(){function p(g,y){for(var S=0;S<y.length;S++){var w=y[S];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(g,w.key,w)}}return function(g,y,S){return y&&p(g.prototype,y),S&&p(g,S),g}})(),u=s(0),c=s(19),h=s(1);function f(p,g){if(!(p instanceof g))throw new TypeError("Cannot call a class as a function")}n.SessionMonitor=(function(){function p(g){var y=this,S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c.CheckSessionIFrame,w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:h.Global.timer;if(f(this,p),!g)throw u.Log.error("SessionMonitor.ctor: No user manager passed to SessionMonitor"),new Error("userManager");this._userManager=g,this._CheckSessionIFrameCtor=S,this._timer=w,this._userManager.events.addUserLoaded(this._start.bind(this)),this._userManager.events.addUserUnloaded(this._stop.bind(this)),Promise.resolve(this._userManager.getUser().then((function(R){R?y._start(R):y._settings.monitorAnonymousSession&&y._userManager.querySessionStatus().then((function(T){var A={session_state:T.session_state};T.sub&&T.sid&&(A.profile={sub:T.sub,sid:T.sid}),y._start(A)})).catch((function(T){u.Log.error("SessionMonitor ctor: error from querySessionStatus:",T.message)}))})).catch((function(R){u.Log.error("SessionMonitor ctor: error from getUser:",R.message)})))}return p.prototype._start=function(y){var S=this,w=y.session_state;w&&(y.profile?(this._sub=y.profile.sub,this._sid=y.profile.sid,u.Log.debug("SessionMonitor._start: session_state:",w,", sub:",this._sub)):(this._sub=void 0,this._sid=void 0,u.Log.debug("SessionMonitor._start: session_state:",w,", anonymous user")),this._checkSessionIFrame?this._checkSessionIFrame.start(w):this._metadataService.getCheckSessionIframe().then((function(R){if(R){u.Log.debug("SessionMonitor._start: Initializing check session iframe");var T=S._client_id,A=S._checkSessionInterval,F=S._stopCheckSessionOnError;S._checkSessionIFrame=new S._CheckSessionIFrameCtor(S._callback.bind(S),T,R,A,F),S._checkSessionIFrame.load().then((function(){S._checkSessionIFrame.start(w)}))}else u.Log.warn("SessionMonitor._start: No check session iframe found in the metadata")})).catch((function(R){u.Log.error("SessionMonitor._start: Error from getCheckSessionIframe:",R.message)})))},p.prototype._stop=function(){var y=this;if(this._sub=void 0,this._sid=void 0,this._checkSessionIFrame&&(u.Log.debug("SessionMonitor._stop"),this._checkSessionIFrame.stop()),this._settings.monitorAnonymousSession)var S=this._timer.setInterval((function(){y._timer.clearInterval(S),y._userManager.querySessionStatus().then((function(w){var R={session_state:w.session_state};w.sub&&w.sid&&(R.profile={sub:w.sub,sid:w.sid}),y._start(R)})).catch((function(w){u.Log.error("SessionMonitor: error from querySessionStatus:",w.message)}))}),1e3)},p.prototype._callback=function(){var y=this;this._userManager.querySessionStatus().then((function(S){var w=!0;S?S.sub===y._sub?(w=!1,y._checkSessionIFrame.start(S.session_state),S.sid===y._sid?u.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",S.session_state):(u.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:",S.session_state),y._userManager.events._raiseUserSessionChanged())):u.Log.debug("SessionMonitor._callback: Different subject signed into OP:",S.sub):u.Log.debug("SessionMonitor._callback: Subject no longer signed into OP"),w&&(y._sub?(u.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed out event"),y._userManager.events._raiseUserSignedOut()):(u.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed in event"),y._userManager.events._raiseUserSignedIn()))})).catch((function(S){y._sub&&(u.Log.debug("SessionMonitor._callback: Error calling queryCurrentSigninSession; raising signed out event",S.message),y._userManager.events._raiseUserSignedOut())}))},a(p,[{key:"_settings",get:function(){return this._userManager.settings}},{key:"_metadataService",get:function(){return this._userManager.metadataService}},{key:"_client_id",get:function(){return this._settings.client_id}},{key:"_checkSessionInterval",get:function(){return this._settings.checkSessionInterval}},{key:"_stopCheckSessionOnError",get:function(){return this._settings.stopCheckSessionOnError}}]),p})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.CheckSessionIFrame=void 0;var a=s(0);function u(c,h){if(!(c instanceof h))throw new TypeError("Cannot call a class as a function")}n.CheckSessionIFrame=(function(){function c(h,f,p,g){var y=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4];u(this,c),this._callback=h,this._client_id=f,this._url=p,this._interval=g||2e3,this._stopOnError=y;var S=p.indexOf("/",p.indexOf("//")+2);this._frame_origin=p.substr(0,S),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.width=0,this._frame.height=0,this._frame.src=p}return c.prototype.load=function(){var f=this;return new Promise((function(p){f._frame.onload=function(){p()},window.document.body.appendChild(f._frame),f._boundMessageEvent=f._message.bind(f),window.addEventListener("message",f._boundMessageEvent,!1)}))},c.prototype._message=function(f){f.origin===this._frame_origin&&f.source===this._frame.contentWindow&&(f.data==="error"?(a.Log.error("CheckSessionIFrame: error message from check session op iframe"),this._stopOnError&&this.stop()):f.data==="changed"?(a.Log.debug("CheckSessionIFrame: changed message from check session op iframe"),this.stop(),this._callback()):a.Log.debug("CheckSessionIFrame: "+f.data+" message from check session op iframe"))},c.prototype.start=function(f){var p=this;if(this._session_state!==f){a.Log.debug("CheckSessionIFrame.start"),this.stop(),this._session_state=f;var g=function(){p._frame.contentWindow.postMessage(p._client_id+" "+p._session_state,p._frame_origin)};g(),this._timer=window.setInterval(g,this._interval)}},c.prototype.stop=function(){this._session_state=null,this._timer&&(a.Log.debug("CheckSessionIFrame.stop"),window.clearInterval(this._timer),this._timer=null)},c})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.TokenRevocationClient=void 0;var a=s(0),u=s(2),c=s(1);function h(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")}var f="access_token",p="refresh_token";n.TokenRevocationClient=(function(){function g(y){var S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c.Global.XMLHttpRequest,w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.MetadataService;if(h(this,g),!y)throw a.Log.error("TokenRevocationClient.ctor: No settings provided"),new Error("No settings provided.");this._settings=y,this._XMLHttpRequestCtor=S,this._metadataService=new w(this._settings)}return g.prototype.revoke=function(S,w){var R=this,T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"access_token";if(!S)throw a.Log.error("TokenRevocationClient.revoke: No token provided"),new Error("No token provided.");if(T!==f&&T!=p)throw a.Log.error("TokenRevocationClient.revoke: Invalid token type"),new Error("Invalid token type.");return this._metadataService.getRevocationEndpoint().then((function(A){if(A){a.Log.debug("TokenRevocationClient.revoke: Revoking "+T);var F=R._settings.client_id,x=R._settings.client_secret;return R._revoke(A,F,x,S,T)}if(w)throw a.Log.error("TokenRevocationClient.revoke: Revocation not supported"),new Error("Revocation not supported")}))},g.prototype._revoke=function(S,w,R,T,A){var F=this;return new Promise((function(x,D){var O=new F._XMLHttpRequestCtor;O.open("POST",S),O.onload=function(){a.Log.debug("TokenRevocationClient.revoke: HTTP response received, status",O.status),O.status===200?x():D(Error(O.statusText+" ("+O.status+")"))},O.onerror=function(){a.Log.debug("TokenRevocationClient.revoke: Network Error."),D("Network Error")};var K="client_id="+encodeURIComponent(w);R&&(K+="&client_secret="+encodeURIComponent(R)),K+="&token_type_hint="+encodeURIComponent(A),K+="&token="+encodeURIComponent(T),O.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),O.send(K)}))},g})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.CordovaPopupWindow=void 0;var a=(function(){function c(h,f){for(var p=0;p<f.length;p++){var g=f[p];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(h,g.key,g)}}return function(h,f,p){return f&&c(h.prototype,f),p&&c(h,p),h}})(),u=s(0);n.CordovaPopupWindow=(function(){function c(h){var f=this;(function(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")})(this,c),this._promise=new Promise((function(p,g){f._resolve=p,f._reject=g})),this.features=h.popupWindowFeatures||"location=no,toolbar=no,zoom=no",this.target=h.popupWindowTarget||"_blank",this.redirect_uri=h.startUrl,u.Log.debug("CordovaPopupWindow.ctor: redirect_uri: "+this.redirect_uri)}return c.prototype._isInAppBrowserInstalled=function(f){return["cordova-plugin-inappbrowser","cordova-plugin-inappbrowser.inappbrowser","org.apache.cordova.inappbrowser"].some((function(p){return f.hasOwnProperty(p)}))},c.prototype.navigate=function(f){if(f&&f.url){if(!window.cordova)return this._error("cordova is undefined");var p=window.cordova.require("cordova/plugin_list").metadata;if(this._isInAppBrowserInstalled(p)===!1)return this._error("InAppBrowser plugin not found");this._popup=cordova.InAppBrowser.open(f.url,this.target,this.features),this._popup?(u.Log.debug("CordovaPopupWindow.navigate: popup successfully created"),this._exitCallbackEvent=this._exitCallback.bind(this),this._loadStartCallbackEvent=this._loadStartCallback.bind(this),this._popup.addEventListener("exit",this._exitCallbackEvent,!1),this._popup.addEventListener("loadstart",this._loadStartCallbackEvent,!1)):this._error("Error opening popup window")}else this._error("No url provided");return this.promise},c.prototype._loadStartCallback=function(f){f.url.indexOf(this.redirect_uri)===0&&this._success({url:f.url})},c.prototype._exitCallback=function(f){this._error(f)},c.prototype._success=function(f){this._cleanup(),u.Log.debug("CordovaPopupWindow: Successful response from cordova popup window"),this._resolve(f)},c.prototype._error=function(f){this._cleanup(),u.Log.error(f),this._reject(new Error(f))},c.prototype.close=function(){this._cleanup()},c.prototype._cleanup=function(){this._popup&&(u.Log.debug("CordovaPopupWindow: cleaning up popup"),this._popup.removeEventListener("exit",this._exitCallbackEvent,!1),this._popup.removeEventListener("loadstart",this._loadStartCallbackEvent,!1),this._popup.close()),this._popup=null},a(c,[{key:"promise",get:function(){return this._promise}}]),c})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0});var a=s(0),u=s(10),c=s(5),h=s(6),f=s(37),p=s(38),g=s(16),y=s(2),S=s(48),w=s(49),R=s(19),T=s(20),A=s(18),F=s(1),x=s(15),D=s(50);n.default={Version:D.Version,Log:a.Log,OidcClient:u.OidcClient,OidcClientSettings:c.OidcClientSettings,WebStorageStateStore:h.WebStorageStateStore,InMemoryWebStorage:f.InMemoryWebStorage,UserManager:p.UserManager,AccessTokenEvents:g.AccessTokenEvents,MetadataService:y.MetadataService,CordovaPopupNavigator:S.CordovaPopupNavigator,CordovaIFrameNavigator:w.CordovaIFrameNavigator,CheckSessionIFrame:R.CheckSessionIFrame,TokenRevocationClient:T.TokenRevocationClient,SessionMonitor:A.SessionMonitor,Global:F.Global,User:x.User},t.exports=n.default},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.ClockService=(function(){function a(){(function(c,h){if(!(c instanceof h))throw new TypeError("Cannot call a class as a function")})(this,a)}return a.prototype.getEpochTime=function(){return Promise.resolve(Date.now()/1e3|0)},a})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.ResponseValidator=void 0;var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},u=s(0),c=s(2),h=s(25),f=s(11),p=s(12),g=s(4);function y(w,R){if(!(w instanceof R))throw new TypeError("Cannot call a class as a function")}var S=["nonce","at_hash","iat","nbf","exp","aud","iss","c_hash"];n.ResponseValidator=(function(){function w(R){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c.MetadataService,A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:h.UserInfoService,F=arguments.length>3&&arguments[3]!==void 0?arguments[3]:g.JoseUtil,x=arguments.length>4&&arguments[4]!==void 0?arguments[4]:f.TokenClient;if(y(this,w),!R)throw u.Log.error("ResponseValidator.ctor: No settings passed to ResponseValidator"),new Error("settings");this._settings=R,this._metadataService=new T(this._settings),this._userInfoService=new A(this._settings),this._joseUtil=F,this._tokenClient=new x(this._settings)}return w.prototype.validateSigninResponse=function(T,A){var F=this;return u.Log.debug("ResponseValidator.validateSigninResponse"),this._processSigninParams(T,A).then((function(x){return u.Log.debug("ResponseValidator.validateSigninResponse: state processed"),F._validateTokens(T,x).then((function(D){return u.Log.debug("ResponseValidator.validateSigninResponse: tokens validated"),F._processClaims(T,D).then((function(O){return u.Log.debug("ResponseValidator.validateSigninResponse: claims processed"),O}))}))}))},w.prototype.validateSignoutResponse=function(T,A){return T.id!==A.state?(u.Log.error("ResponseValidator.validateSignoutResponse: State does not match"),Promise.reject(new Error("State does not match"))):(u.Log.debug("ResponseValidator.validateSignoutResponse: state validated"),A.state=T.data,A.error?(u.Log.warn("ResponseValidator.validateSignoutResponse: Response was error",A.error),Promise.reject(new p.ErrorResponse(A))):Promise.resolve(A))},w.prototype._processSigninParams=function(T,A){if(T.id!==A.state)return u.Log.error("ResponseValidator._processSigninParams: State does not match"),Promise.reject(new Error("State does not match"));if(!T.client_id)return u.Log.error("ResponseValidator._processSigninParams: No client_id on state"),Promise.reject(new Error("No client_id on state"));if(!T.authority)return u.Log.error("ResponseValidator._processSigninParams: No authority on state"),Promise.reject(new Error("No authority on state"));if(this._settings.authority){if(this._settings.authority&&this._settings.authority!==T.authority)return u.Log.error("ResponseValidator._processSigninParams: authority mismatch on settings vs. signin state"),Promise.reject(new Error("authority mismatch on settings vs. signin state"))}else this._settings.authority=T.authority;if(this._settings.client_id){if(this._settings.client_id&&this._settings.client_id!==T.client_id)return u.Log.error("ResponseValidator._processSigninParams: client_id mismatch on settings vs. signin state"),Promise.reject(new Error("client_id mismatch on settings vs. signin state"))}else this._settings.client_id=T.client_id;return u.Log.debug("ResponseValidator._processSigninParams: state validated"),A.state=T.data,A.error?(u.Log.warn("ResponseValidator._processSigninParams: Response was error",A.error),Promise.reject(new p.ErrorResponse(A))):T.nonce&&!A.id_token?(u.Log.error("ResponseValidator._processSigninParams: Expecting id_token in response"),Promise.reject(new Error("No id_token in response"))):!T.nonce&&A.id_token?(u.Log.error("ResponseValidator._processSigninParams: Not expecting id_token in response"),Promise.reject(new Error("Unexpected id_token in response"))):T.code_verifier&&!A.code?(u.Log.error("ResponseValidator._processSigninParams: Expecting code in response"),Promise.reject(new Error("No code in response"))):!T.code_verifier&&A.code?(u.Log.error("ResponseValidator._processSigninParams: Not expecting code in response"),Promise.reject(new Error("Unexpected code in response"))):(A.scope||(A.scope=T.scope),Promise.resolve(A))},w.prototype._processClaims=function(T,A){var F=this;if(A.isOpenIdConnect){if(u.Log.debug("ResponseValidator._processClaims: response is OIDC, processing claims"),A.profile=this._filterProtocolClaims(A.profile),T.skipUserInfo!==!0&&this._settings.loadUserInfo&&A.access_token)return u.Log.debug("ResponseValidator._processClaims: loading user info"),this._userInfoService.getClaims(A.access_token).then((function(x){return u.Log.debug("ResponseValidator._processClaims: user info claims received from user info endpoint"),x.sub!==A.profile.sub?(u.Log.error("ResponseValidator._processClaims: sub from user info endpoint does not match sub in id_token"),Promise.reject(new Error("sub from user info endpoint does not match sub in id_token"))):(A.profile=F._mergeClaims(A.profile,x),u.Log.debug("ResponseValidator._processClaims: user info claims received, updated profile:",A.profile),A)}));u.Log.debug("ResponseValidator._processClaims: not loading user info")}else u.Log.debug("ResponseValidator._processClaims: response is not OIDC, not processing claims");return Promise.resolve(A)},w.prototype._mergeClaims=function(T,A){var F=Object.assign({},T);for(var x in A){var D=A[x];Array.isArray(D)||(D=[D]);for(var O=0;O<D.length;O++){var K=D[O];F[x]?Array.isArray(F[x])?F[x].indexOf(K)<0&&F[x].push(K):F[x]!==K&&((K===void 0?"undefined":a(K))==="object"&&this._settings.mergeClaims?F[x]=this._mergeClaims(F[x],K):F[x]=[F[x],K]):F[x]=K}}return F},w.prototype._filterProtocolClaims=function(T){u.Log.debug("ResponseValidator._filterProtocolClaims, incoming claims:",T);var A=Object.assign({},T);return this._settings._filterProtocolClaims?(S.forEach((function(F){delete A[F]})),u.Log.debug("ResponseValidator._filterProtocolClaims: protocol claims filtered",A)):u.Log.debug("ResponseValidator._filterProtocolClaims: protocol claims not filtered"),A},w.prototype._validateTokens=function(T,A){return A.code?(u.Log.debug("ResponseValidator._validateTokens: Validating code"),this._processCode(T,A)):A.id_token?A.access_token?(u.Log.debug("ResponseValidator._validateTokens: Validating id_token and access_token"),this._validateIdTokenAndAccessToken(T,A)):(u.Log.debug("ResponseValidator._validateTokens: Validating id_token"),this._validateIdToken(T,A)):(u.Log.debug("ResponseValidator._validateTokens: No code to process or id_token to validate"),Promise.resolve(A))},w.prototype._processCode=function(T,A){var F=this,x={client_id:T.client_id,client_secret:T.client_secret,code:A.code,redirect_uri:T.redirect_uri,code_verifier:T.code_verifier};return T.extraTokenParams&&a(T.extraTokenParams)==="object"&&Object.assign(x,T.extraTokenParams),this._tokenClient.exchangeCode(x).then((function(D){for(var O in D)A[O]=D[O];return A.id_token?(u.Log.debug("ResponseValidator._processCode: token response successful, processing id_token"),F._validateIdTokenAttributes(T,A)):(u.Log.debug("ResponseValidator._processCode: token response successful, returning response"),A)}))},w.prototype._validateIdTokenAttributes=function(T,A){var F=this;return this._metadataService.getIssuer().then((function(x){var D=T.client_id,O=F._settings.clockSkew;return u.Log.debug("ResponseValidator._validateIdTokenAttributes: Validaing JWT attributes; using clock skew (in seconds) of: ",O),F._settings.getEpochTime().then((function(K){return F._joseUtil.validateJwtAttributes(A.id_token,x,D,O,K).then((function(z){return T.nonce&&T.nonce!==z.nonce?(u.Log.error("ResponseValidator._validateIdTokenAttributes: Invalid nonce in id_token"),Promise.reject(new Error("Invalid nonce in id_token"))):z.sub?(A.profile=z,A):(u.Log.error("ResponseValidator._validateIdTokenAttributes: No sub present in id_token"),Promise.reject(new Error("No sub present in id_token")))}))}))}))},w.prototype._validateIdTokenAndAccessToken=function(T,A){var F=this;return this._validateIdToken(T,A).then((function(x){return F._validateAccessToken(x)}))},w.prototype._getSigningKeyForJwt=function(T){var A=this;return this._metadataService.getSigningKeys().then((function(F){var x=T.header.kid;if(!F)return u.Log.error("ResponseValidator._validateIdToken: No signing keys from metadata"),Promise.reject(new Error("No signing keys from metadata"));u.Log.debug("ResponseValidator._validateIdToken: Received signing keys");var D=void 0;if(x)D=F.filter((function(O){return O.kid===x}))[0];else{if((F=A._filterByAlg(F,T.header.alg)).length>1)return u.Log.error("ResponseValidator._validateIdToken: No kid found in id_token and more than one key found in metadata"),Promise.reject(new Error("No kid found in id_token and more than one key found in metadata"));D=F[0]}return Promise.resolve(D)}))},w.prototype._getSigningKeyForJwtWithSingleRetry=function(T){var A=this;return this._getSigningKeyForJwt(T).then((function(F){return F?Promise.resolve(F):(A._metadataService.resetSigningKeys(),A._getSigningKeyForJwt(T))}))},w.prototype._validateIdToken=function(T,A){var F=this;if(!T.nonce)return u.Log.error("ResponseValidator._validateIdToken: No nonce on state"),Promise.reject(new Error("No nonce on state"));var x=this._joseUtil.parseJwt(A.id_token);return x&&x.header&&x.payload?T.nonce!==x.payload.nonce?(u.Log.error("ResponseValidator._validateIdToken: Invalid nonce in id_token"),Promise.reject(new Error("Invalid nonce in id_token"))):this._metadataService.getIssuer().then((function(D){return u.Log.debug("ResponseValidator._validateIdToken: Received issuer"),F._getSigningKeyForJwtWithSingleRetry(x).then((function(O){if(!O)return u.Log.error("ResponseValidator._validateIdToken: No key matching kid or alg found in signing keys"),Promise.reject(new Error("No key matching kid or alg found in signing keys"));var K=T.client_id,z=F._settings.clockSkew;return u.Log.debug("ResponseValidator._validateIdToken: Validaing JWT; using clock skew (in seconds) of: ",z),F._joseUtil.validateJwt(A.id_token,O,D,K,z).then((function(){return u.Log.debug("ResponseValidator._validateIdToken: JWT validation successful"),x.payload.sub?(A.profile=x.payload,A):(u.Log.error("ResponseValidator._validateIdToken: No sub present in id_token"),Promise.reject(new Error("No sub present in id_token")))}))}))})):(u.Log.error("ResponseValidator._validateIdToken: Failed to parse id_token",x),Promise.reject(new Error("Failed to parse id_token")))},w.prototype._filterByAlg=function(T,A){var F=null;if(A.startsWith("RS"))F="RSA";else if(A.startsWith("PS"))F="PS";else{if(!A.startsWith("ES"))return u.Log.debug("ResponseValidator._filterByAlg: alg not supported: ",A),[];F="EC"}return u.Log.debug("ResponseValidator._filterByAlg: Looking for keys that match kty: ",F),T=T.filter((function(x){return x.kty===F})),u.Log.debug("ResponseValidator._filterByAlg: Number of keys that match kty: ",F,T.length),T},w.prototype._validateAccessToken=function(T){if(!T.profile)return u.Log.error("ResponseValidator._validateAccessToken: No profile loaded from id_token"),Promise.reject(new Error("No profile loaded from id_token"));if(!T.profile.at_hash)return u.Log.error("ResponseValidator._validateAccessToken: No at_hash in id_token"),Promise.reject(new Error("No at_hash in id_token"));if(!T.id_token)return u.Log.error("ResponseValidator._validateAccessToken: No id_token"),Promise.reject(new Error("No id_token"));var A=this._joseUtil.parseJwt(T.id_token);if(!A||!A.header)return u.Log.error("ResponseValidator._validateAccessToken: Failed to parse id_token",A),Promise.reject(new Error("Failed to parse id_token"));var F=A.header.alg;if(!F||F.length!==5)return u.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",F),Promise.reject(new Error("Unsupported alg: "+F));var x=F.substr(2,3);if(!x)return u.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",F,x),Promise.reject(new Error("Unsupported alg: "+F));if((x=parseInt(x))!==256&&x!==384&&x!==512)return u.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",F,x),Promise.reject(new Error("Unsupported alg: "+F));var D="sha"+x,O=this._joseUtil.hashString(T.access_token,D);if(!O)return u.Log.error("ResponseValidator._validateAccessToken: access_token hash failed:",D),Promise.reject(new Error("Failed to validate at_hash"));var K=O.substr(0,O.length/2),z=this._joseUtil.hexToBase64Url(K);return z!==T.profile.at_hash?(u.Log.error("ResponseValidator._validateAccessToken: Failed to validate at_hash",z,T.profile.at_hash),Promise.reject(new Error("Failed to validate at_hash"))):(u.Log.debug("ResponseValidator._validateAccessToken: success"),Promise.resolve(T))},w})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.UserInfoService=void 0;var a=s(7),u=s(2),c=s(0),h=s(4);function f(p,g){if(!(p instanceof g))throw new TypeError("Cannot call a class as a function")}n.UserInfoService=(function(){function p(g){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:a.JsonService,S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.MetadataService,w=arguments.length>3&&arguments[3]!==void 0?arguments[3]:h.JoseUtil;if(f(this,p),!g)throw c.Log.error("UserInfoService.ctor: No settings passed"),new Error("settings");this._settings=g,this._jsonService=new y(void 0,void 0,this._getClaimsFromJwt.bind(this)),this._metadataService=new S(this._settings),this._joseUtil=w}return p.prototype.getClaims=function(y){var S=this;return y?this._metadataService.getUserInfoEndpoint().then((function(w){return c.Log.debug("UserInfoService.getClaims: received userinfo url",w),S._jsonService.getJson(w,y).then((function(R){return c.Log.debug("UserInfoService.getClaims: claims received",R),R}))})):(c.Log.error("UserInfoService.getClaims: No token passed"),Promise.reject(new Error("A token is required")))},p.prototype._getClaimsFromJwt=function(y){var S=this;try{var w=this._joseUtil.parseJwt(y.responseText);if(!w||!w.header||!w.payload)return c.Log.error("UserInfoService._getClaimsFromJwt: Failed to parse JWT",w),Promise.reject(new Error("Failed to parse id_token"));var R=w.header.kid,T=void 0;switch(this._settings.userInfoJwtIssuer){case"OP":T=this._metadataService.getIssuer();break;case"ANY":T=Promise.resolve(w.payload.iss);break;default:T=Promise.resolve(this._settings.userInfoJwtIssuer)}return T.then((function(A){return c.Log.debug("UserInfoService._getClaimsFromJwt: Received issuer:"+A),S._metadataService.getSigningKeys().then((function(F){if(!F)return c.Log.error("UserInfoService._getClaimsFromJwt: No signing keys from metadata"),Promise.reject(new Error("No signing keys from metadata"));c.Log.debug("UserInfoService._getClaimsFromJwt: Received signing keys");var x=void 0;if(R)x=F.filter((function(K){return K.kid===R}))[0];else{if((F=S._filterByAlg(F,w.header.alg)).length>1)return c.Log.error("UserInfoService._getClaimsFromJwt: No kid found in id_token and more than one key found in metadata"),Promise.reject(new Error("No kid found in id_token and more than one key found in metadata"));x=F[0]}if(!x)return c.Log.error("UserInfoService._getClaimsFromJwt: No key matching kid or alg found in signing keys"),Promise.reject(new Error("No key matching kid or alg found in signing keys"));var D=S._settings.client_id,O=S._settings.clockSkew;return c.Log.debug("UserInfoService._getClaimsFromJwt: Validaing JWT; using clock skew (in seconds) of: ",O),S._joseUtil.validateJwt(y.responseText,x,A,D,O,void 0,!0).then((function(){return c.Log.debug("UserInfoService._getClaimsFromJwt: JWT validation successful"),w.payload}))}))}))}catch(A){return c.Log.error("UserInfoService._getClaimsFromJwt: Error parsing JWT response",A.message),void reject(A)}},p.prototype._filterByAlg=function(y,S){var w=null;if(S.startsWith("RS"))w="RSA";else if(S.startsWith("PS"))w="PS";else{if(!S.startsWith("ES"))return c.Log.debug("UserInfoService._filterByAlg: alg not supported: ",S),[];w="EC"}return c.Log.debug("UserInfoService._filterByAlg: Looking for keys that match kty: ",w),y=y.filter((function(R){return R.kty===w})),c.Log.debug("UserInfoService._filterByAlg: Number of keys that match kty: ",w,y.length),y},p})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.AllowedSigningAlgs=n.b64tohex=n.hextob64u=n.crypto=n.X509=n.KeyUtil=n.jws=void 0;var a=s(27);n.jws=a.jws,n.KeyUtil=a.KEYUTIL,n.X509=a.X509,n.crypto=a.crypto,n.hextob64u=a.hextob64u,n.b64tohex=a.b64tohex,n.AllowedSigningAlgs=["RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"]},function(t,n,s){(function(a){Object.defineProperty(n,"__esModule",{value:!0});var u,c,h,f,p,g,y,S,w,R,T,A=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},F={},x={},D=D||(u=Math,h=(c={}).lib={},f=h.Base=(function(){function _(){}return{extend:function(v){_.prototype=this;var I=new _;return v&&I.mixIn(v),I.hasOwnProperty("init")||(I.init=function(){I.$super.init.apply(this,arguments)}),I.init.prototype=I,I.$super=this,I},create:function(){var v=this.extend();return v.init.apply(v,arguments),v},init:function(){},mixIn:function(v){for(var I in v)v.hasOwnProperty(I)&&(this[I]=v[I]);v.hasOwnProperty("toString")&&(this.toString=v.toString)},clone:function(){return this.init.prototype.extend(this)}}})(),p=h.WordArray=f.extend({init:function(b,v){b=this.words=b||[],this.sigBytes=v??4*b.length},toString:function(b){return(b||y).stringify(this)},concat:function(b){var v=this.words,I=b.words,k=this.sigBytes,Q=b.sigBytes;if(this.clamp(),k%4)for(var te=0;te<Q;te++){var we=I[te>>>2]>>>24-te%4*8&255;v[k+te>>>2]|=we<<24-(k+te)%4*8}else for(te=0;te<Q;te+=4)v[k+te>>>2]=I[te>>>2];return this.sigBytes+=Q,this},clamp:function(){var b=this.words,v=this.sigBytes;b[v>>>2]&=4294967295<<32-v%4*8,b.length=u.ceil(v/4)},clone:function(){var b=f.clone.call(this);return b.words=this.words.slice(0),b},random:function(b){for(var v=[],I=0;I<b;I+=4)v.push(4294967296*u.random()|0);return new p.init(v,b)}}),g=c.enc={},y=g.Hex={stringify:function(b){for(var v=b.words,I=b.sigBytes,k=[],Q=0;Q<I;Q++){var te=v[Q>>>2]>>>24-Q%4*8&255;k.push((te>>>4).toString(16)),k.push((15&te).toString(16))}return k.join("")},parse:function(b){for(var v=b.length,I=[],k=0;k<v;k+=2)I[k>>>3]|=parseInt(b.substr(k,2),16)<<24-k%8*4;return new p.init(I,v/2)}},S=g.Latin1={stringify:function(b){for(var v=b.words,I=b.sigBytes,k=[],Q=0;Q<I;Q++){var te=v[Q>>>2]>>>24-Q%4*8&255;k.push(String.fromCharCode(te))}return k.join("")},parse:function(b){for(var v=b.length,I=[],k=0;k<v;k++)I[k>>>2]|=(255&b.charCodeAt(k))<<24-k%4*8;return new p.init(I,v)}},w=g.Utf8={stringify:function(b){try{return decodeURIComponent(escape(S.stringify(b)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(b){return S.parse(unescape(encodeURIComponent(b)))}},R=h.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new p.init,this._nDataBytes=0},_append:function(b){typeof b=="string"&&(b=w.parse(b)),this._data.concat(b),this._nDataBytes+=b.sigBytes},_process:function(b){var v=this._data,I=v.words,k=v.sigBytes,Q=this.blockSize,te=k/(4*Q),we=(te=b?u.ceil(te):u.max((0|te)-this._minBufferSize,0))*Q,ge=u.min(4*we,k);if(we){for(var be=0;be<we;be+=Q)this._doProcessBlock(I,be);var _e=I.splice(0,we);v.sigBytes-=ge}return new p.init(_e,ge)},clone:function(){var b=f.clone.call(this);return b._data=this._data.clone(),b},_minBufferSize:0}),h.Hasher=R.extend({cfg:f.extend(),init:function(b){this.cfg=this.cfg.extend(b),this.reset()},reset:function(){R.reset.call(this),this._doReset()},update:function(b){return this._append(b),this._process(),this},finalize:function(b){return b&&this._append(b),this._doFinalize()},blockSize:16,_createHelper:function(b){return function(v,I){return new b.init(I).finalize(v)}},_createHmacHelper:function(b){return function(v,I){return new T.HMAC.init(b,I).finalize(v)}}}),T=c.algo={},c);(function(_){var b,v=(b=D).lib,I=v.Base,k=v.WordArray;(b=b.x64={}).Word=I.extend({init:function(te,we){this.high=te,this.low=we}}),b.WordArray=I.extend({init:function(te,we){te=this.words=te||[],this.sigBytes=we??8*te.length},toX32:function(){for(var te=this.words,we=te.length,ge=[],be=0;be<we;be++){var _e=te[be];ge.push(_e.high),ge.push(_e.low)}return k.create(ge,this.sigBytes)},clone:function(){for(var te=I.clone.call(this),we=te.words=this.words.slice(0),ge=we.length,be=0;be<ge;be++)we[be]=we[be].clone();return te}})})(),(function(){var _=D,b=_.lib.WordArray;_.enc.Base64={stringify:function(I){var k=I.words,Q=I.sigBytes,te=this._map;I.clamp(),I=[];for(var we=0;we<Q;we+=3)for(var ge=(k[we>>>2]>>>24-we%4*8&255)<<16|(k[we+1>>>2]>>>24-(we+1)%4*8&255)<<8|k[we+2>>>2]>>>24-(we+2)%4*8&255,be=0;4>be&&we+.75*be<Q;be++)I.push(te.charAt(ge>>>6*(3-be)&63));if(k=te.charAt(64))for(;I.length%4;)I.push(k);return I.join("")},parse:function(I){var k=I.length,Q=this._map;(te=Q.charAt(64))&&(te=I.indexOf(te))!=-1&&(k=te);for(var te=[],we=0,ge=0;ge<k;ge++)if(ge%4){var be=Q.indexOf(I.charAt(ge-1))<<ge%4*2,_e=Q.indexOf(I.charAt(ge))>>>6-ge%4*2;te[we>>>2]|=(be|_e)<<24-we%4*8,we++}return b.create(te,we)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})(),(function(_){for(var b=D,v=(k=b.lib).WordArray,I=k.Hasher,k=b.algo,Q=[],te=[],we=function(Xe){return 4294967296*(Xe-(0|Xe))|0},ge=2,be=0;64>be;){var _e;e:{_e=ge;for(var Re=_.sqrt(_e),Ce=2;Ce<=Re;Ce++)if(!(_e%Ce)){_e=!1;break e}_e=!0}_e&&(8>be&&(Q[be]=we(_.pow(ge,.5))),te[be]=we(_.pow(ge,1/3)),be++),ge++}var Le=[];k=k.SHA256=I.extend({_doReset:function(){this._hash=new v.init(Q.slice(0))},_doProcessBlock:function(Xe,et){for(var ne=this._hash.words,Se=ne[0],Ae=ne[1],Ne=ne[2],Qe=ne[3],nt=ne[4],bt=ne[5],ht=ne[6],Ct=ne[7],yt=0;64>yt;yt++){if(16>yt)Le[yt]=0|Xe[et+yt];else{var wt=Le[yt-15],Jt=Le[yt-2];Le[yt]=((wt<<25|wt>>>7)^(wt<<14|wt>>>18)^wt>>>3)+Le[yt-7]+((Jt<<15|Jt>>>17)^(Jt<<13|Jt>>>19)^Jt>>>10)+Le[yt-16]}wt=Ct+((nt<<26|nt>>>6)^(nt<<21|nt>>>11)^(nt<<7|nt>>>25))+(nt&bt^~nt&ht)+te[yt]+Le[yt],Jt=((Se<<30|Se>>>2)^(Se<<19|Se>>>13)^(Se<<10|Se>>>22))+(Se&Ae^Se&Ne^Ae&Ne),Ct=ht,ht=bt,bt=nt,nt=Qe+wt|0,Qe=Ne,Ne=Ae,Ae=Se,Se=wt+Jt|0}ne[0]=ne[0]+Se|0,ne[1]=ne[1]+Ae|0,ne[2]=ne[2]+Ne|0,ne[3]=ne[3]+Qe|0,ne[4]=ne[4]+nt|0,ne[5]=ne[5]+bt|0,ne[6]=ne[6]+ht|0,ne[7]=ne[7]+Ct|0},_doFinalize:function(){var Xe=this._data,et=Xe.words,ne=8*this._nDataBytes,Se=8*Xe.sigBytes;return et[Se>>>5]|=128<<24-Se%32,et[14+(Se+64>>>9<<4)]=_.floor(ne/4294967296),et[15+(Se+64>>>9<<4)]=ne,Xe.sigBytes=4*et.length,this._process(),this._hash},clone:function(){var Xe=I.clone.call(this);return Xe._hash=this._hash.clone(),Xe}}),b.SHA256=I._createHelper(k),b.HmacSHA256=I._createHmacHelper(k)})(Math),(function(){function _(){return I.create.apply(I,arguments)}for(var b=D,v=b.lib.Hasher,I=(Q=b.x64).Word,k=Q.WordArray,Q=b.algo,te=[_(1116352408,3609767458),_(1899447441,602891725),_(3049323471,3964484399),_(3921009573,2173295548),_(961987163,4081628472),_(1508970993,3053834265),_(2453635748,2937671579),_(2870763221,3664609560),_(3624381080,2734883394),_(310598401,1164996542),_(607225278,1323610764),_(1426881987,3590304994),_(1925078388,4068182383),_(2162078206,991336113),_(2614888103,633803317),_(3248222580,3479774868),_(3835390401,2666613458),_(4022224774,944711139),_(264347078,2341262773),_(604807628,2007800933),_(770255983,1495990901),_(1249150122,1856431235),_(1555081692,3175218132),_(1996064986,2198950837),_(2554220882,3999719339),_(2821834349,766784016),_(2952996808,2566594879),_(3210313671,3203337956),_(3336571891,1034457026),_(3584528711,2466948901),_(113926993,3758326383),_(338241895,168717936),_(666307205,1188179964),_(773529912,1546045734),_(1294757372,1522805485),_(1396182291,2643833823),_(1695183700,2343527390),_(1986661051,1014477480),_(2177026350,1206759142),_(2456956037,344077627),_(2730485921,1290863460),_(2820302411,3158454273),_(3259730800,3505952657),_(3345764771,106217008),_(3516065817,3606008344),_(3600352804,1432725776),_(4094571909,1467031594),_(275423344,851169720),_(430227734,3100823752),_(506948616,1363258195),_(659060556,3750685593),_(883997877,3785050280),_(958139571,3318307427),_(1322822218,3812723403),_(1537002063,2003034995),_(1747873779,3602036899),_(1955562222,1575990012),_(2024104815,1125592928),_(2227730452,2716904306),_(2361852424,442776044),_(2428436474,593698344),_(2756734187,3733110249),_(3204031479,2999351573),_(3329325298,3815920427),_(3391569614,3928383900),_(3515267271,566280711),_(3940187606,3454069534),_(4118630271,4000239992),_(116418474,1914138554),_(174292421,2731055270),_(289380356,3203993006),_(460393269,320620315),_(685471733,587496836),_(852142971,1086792851),_(1017036298,365543100),_(1126000580,2618297676),_(1288033470,3409855158),_(1501505948,4234509866),_(1607167915,987167468),_(1816402316,1246189591)],we=[],ge=0;80>ge;ge++)we[ge]=_();Q=Q.SHA512=v.extend({_doReset:function(){this._hash=new k.init([new I.init(1779033703,4089235720),new I.init(3144134277,2227873595),new I.init(1013904242,4271175723),new I.init(2773480762,1595750129),new I.init(1359893119,2917565137),new I.init(2600822924,725511199),new I.init(528734635,4215389547),new I.init(1541459225,327033209)])},_doProcessBlock:function(_e,Re){for(var Ce=(Ae=this._hash.words)[0],Le=Ae[1],We=Ae[2],Xe=Ae[3],et=Ae[4],ne=Ae[5],Se=Ae[6],Ae=Ae[7],Ne=Ce.high,Qe=Ce.low,nt=Le.high,bt=Le.low,ht=We.high,Ct=We.low,yt=Xe.high,wt=Xe.low,Jt=et.high,Qt=et.low,Mt=ne.high,Ir=ne.low,Lr=Se.high,Ur=Se.low,ar=Ae.high,Xt=Ae.low,ir=Ne,Or=Qe,_n=nt,tn=bt,pn=ht,Tn=Ct,gn=yt,Fn=wt,wr=Jt,$r=Qt,Cr=Mt,kr=Ir,Mn=Lr,mn=Ur,Mi=ar,qn=Xt,Xr=0;80>Xr;Xr++){var rn=we[Xr];if(16>Xr)var Yr=rn.high=0|_e[Re+2*Xr],lr=rn.low=0|_e[Re+2*Xr+1];else{Yr=((lr=(Yr=we[Xr-15]).high)>>>1|(Dn=Yr.low)<<31)^(lr>>>8|Dn<<24)^lr>>>7;var Dn=(Dn>>>1|lr<<31)^(Dn>>>8|lr<<24)^(Dn>>>7|lr<<25),hi=((lr=(hi=we[Xr-2]).high)>>>19|(Nr=hi.low)<<13)^(lr<<3|Nr>>>29)^lr>>>6,Nr=(Nr>>>19|lr<<13)^(Nr<<3|lr>>>29)^(Nr>>>6|lr<<26),zn=(lr=we[Xr-7]).high,Vn=(Hn=we[Xr-16]).high,Hn=Hn.low;Yr=(Yr=(Yr=Yr+zn+((lr=Dn+lr.low)>>>0<Dn>>>0?1:0))+hi+((lr=lr+Nr)>>>0<Nr>>>0?1:0))+Vn+((lr=lr+Hn)>>>0<Hn>>>0?1:0),rn.high=Yr,rn.low=lr}zn=wr&Cr^~wr&Mn,Hn=$r&kr^~$r&mn,rn=ir&_n^ir&pn^_n&pn;var $s=Or&tn^Or&Tn^tn&Tn,wo=(Dn=(ir>>>28|Or<<4)^(ir<<30|Or>>>2)^(ir<<25|Or>>>7),hi=(Or>>>28|ir<<4)^(Or<<30|ir>>>2)^(Or<<25|ir>>>7),(Nr=te[Xr]).high),Wn=Nr.low;Vn=Mi+((wr>>>14|$r<<18)^(wr>>>18|$r<<14)^(wr<<23|$r>>>9))+((Nr=qn+(($r>>>14|wr<<18)^($r>>>18|wr<<14)^($r<<23|wr>>>9)))>>>0<qn>>>0?1:0),Mi=Mn,qn=mn,Mn=Cr,mn=kr,Cr=wr,kr=$r,wr=gn+(Vn=(Vn=(Vn=Vn+zn+((Nr=Nr+Hn)>>>0<Hn>>>0?1:0))+wo+((Nr=Nr+Wn)>>>0<Wn>>>0?1:0))+Yr+((Nr=Nr+lr)>>>0<lr>>>0?1:0))+(($r=Fn+Nr|0)>>>0<Fn>>>0?1:0)|0,gn=pn,Fn=Tn,pn=_n,Tn=tn,_n=ir,tn=Or,ir=Vn+(rn=Dn+rn+((lr=hi+$s)>>>0<hi>>>0?1:0))+((Or=Nr+lr|0)>>>0<Nr>>>0?1:0)|0}Qe=Ce.low=Qe+Or,Ce.high=Ne+ir+(Qe>>>0<Or>>>0?1:0),bt=Le.low=bt+tn,Le.high=nt+_n+(bt>>>0<tn>>>0?1:0),Ct=We.low=Ct+Tn,We.high=ht+pn+(Ct>>>0<Tn>>>0?1:0),wt=Xe.low=wt+Fn,Xe.high=yt+gn+(wt>>>0<Fn>>>0?1:0),Qt=et.low=Qt+$r,et.high=Jt+wr+(Qt>>>0<$r>>>0?1:0),Ir=ne.low=Ir+kr,ne.high=Mt+Cr+(Ir>>>0<kr>>>0?1:0),Ur=Se.low=Ur+mn,Se.high=Lr+Mn+(Ur>>>0<mn>>>0?1:0),Xt=Ae.low=Xt+qn,Ae.high=ar+Mi+(Xt>>>0<qn>>>0?1:0)},_doFinalize:function(){var _e=this._data,Re=_e.words,Ce=8*this._nDataBytes,Le=8*_e.sigBytes;return Re[Le>>>5]|=128<<24-Le%32,Re[30+(Le+128>>>10<<5)]=Math.floor(Ce/4294967296),Re[31+(Le+128>>>10<<5)]=Ce,_e.sigBytes=4*Re.length,this._process(),this._hash.toX32()},clone:function(){var _e=v.clone.call(this);return _e._hash=this._hash.clone(),_e},blockSize:32}),b.SHA512=v._createHelper(Q),b.HmacSHA512=v._createHmacHelper(Q)})(),(function(){var _=D,b=(k=_.x64).Word,v=k.WordArray,I=(k=_.algo).SHA512,k=k.SHA384=I.extend({_doReset:function(){this._hash=new v.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var te=I._doFinalize.call(this);return te.sigBytes-=16,te}});_.SHA384=I._createHelper(k),_.HmacSHA384=I._createHmacHelper(k)})();var O,K="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function z(_){var b,v,I="";for(b=0;b+3<=_.length;b+=3)v=parseInt(_.substring(b,b+3),16),I+=K.charAt(v>>6)+K.charAt(63&v);for(b+1==_.length?(v=parseInt(_.substring(b,b+1),16),I+=K.charAt(v<<2)):b+2==_.length&&(v=parseInt(_.substring(b,b+2),16),I+=K.charAt(v>>2)+K.charAt((3&v)<<4)),"=";(3&I.length)>0;)I+="=";return I}function X(_){var b,v,I,k="",Q=0;for(b=0;b<_.length&&_.charAt(b)!="=";++b)(I=K.indexOf(_.charAt(b)))<0||(Q==0?(k+=ze(I>>2),v=3&I,Q=1):Q==1?(k+=ze(v<<2|I>>4),v=15&I,Q=2):Q==2?(k+=ze(v),k+=ze(I>>2),v=3&I,Q=3):(k+=ze(v<<2|I>>4),k+=ze(15&I),Q=0));return Q==1&&(k+=ze(v<<2)),k}function Ee(_){var b,v=X(_),I=new Array;for(b=0;2*b<v.length;++b)I[b]=parseInt(v.substring(2*b,2*b+2),16);return I}function q(_,b,v){_!=null&&(typeof _=="number"?this.fromNumber(_,b,v):b==null&&typeof _!="string"?this.fromString(_,256):this.fromString(_,b))}function Y(){return new q(null)}F.appName=="Microsoft Internet Explorer"?(q.prototype.am=function(b,v,I,k,Q,te){for(var we=32767&v,ge=v>>15;--te>=0;){var be=32767&this[b],_e=this[b++]>>15,Re=ge*be+_e*we;Q=((be=we*be+((32767&Re)<<15)+I[k]+(1073741823&Q))>>>30)+(Re>>>15)+ge*_e+(Q>>>30),I[k++]=1073741823&be}return Q},O=30):F.appName!="Netscape"?(q.prototype.am=function(b,v,I,k,Q,te){for(;--te>=0;){var we=v*this[b++]+I[k]+Q;Q=Math.floor(we/67108864),I[k++]=67108863&we}return Q},O=26):(q.prototype.am=function(b,v,I,k,Q,te){for(var we=16383&v,ge=v>>14;--te>=0;){var be=16383&this[b],_e=this[b++]>>14,Re=ge*be+_e*we;Q=((be=we*be+((16383&Re)<<14)+I[k]+Q)>>28)+(Re>>14)+ge*_e,I[k++]=268435455&be}return Q},O=28),q.prototype.DB=O,q.prototype.DM=(1<<O)-1,q.prototype.DV=1<<O,q.prototype.FV=Math.pow(2,52),q.prototype.F1=52-O,q.prototype.F2=2*O-52;var Te,re,$e=new Array;for(Te=48,re=0;re<=9;++re)$e[Te++]=re;for(Te=97,re=10;re<36;++re)$e[Te++]=re;for(Te=65,re=10;re<36;++re)$e[Te++]=re;function ze(_){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(_)}function ye(_,b){var v=$e[_.charCodeAt(b)];return v??-1}function Ve(_){var b=Y();return b.fromInt(_),b}function pe(_){var b,v=1;return(b=_>>>16)!=0&&(_=b,v+=16),(b=_>>8)!=0&&(_=b,v+=8),(b=_>>4)!=0&&(_=b,v+=4),(b=_>>2)!=0&&(_=b,v+=2),(b=_>>1)!=0&&(_=b,v+=1),v}function De(_){this.m=_}function $(_){this.m=_,this.mp=_.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<_.DB-15)-1,this.mt2=2*_.t}function G(_,b){return _&b}function ce(_,b){return _|b}function oe(_,b){return _^b}function Fe(_,b){return _&~b}function Ue(_){if(_==0)return-1;var b=0;return(65535&_)==0&&(_>>=16,b+=16),(255&_)==0&&(_>>=8,b+=8),(15&_)==0&&(_>>=4,b+=4),(3&_)==0&&(_>>=2,b+=2),(1&_)==0&&++b,b}function Je(_){for(var b=0;_!=0;)_&=_-1,++b;return b}function He(){}function he(_){return _}function fe(_){this.r2=Y(),this.q3=Y(),q.ONE.dlShiftTo(2*_.t,this.r2),this.mu=this.r2.divide(_),this.m=_}De.prototype.convert=function(b){return b.s<0||b.compareTo(this.m)>=0?b.mod(this.m):b},De.prototype.revert=function(b){return b},De.prototype.reduce=function(b){b.divRemTo(this.m,null,b)},De.prototype.mulTo=function(b,v,I){b.multiplyTo(v,I),this.reduce(I)},De.prototype.sqrTo=function(b,v){b.squareTo(v),this.reduce(v)},$.prototype.convert=function(b){var v=Y();return b.abs().dlShiftTo(this.m.t,v),v.divRemTo(this.m,null,v),b.s<0&&v.compareTo(q.ZERO)>0&&this.m.subTo(v,v),v},$.prototype.revert=function(b){var v=Y();return b.copyTo(v),this.reduce(v),v},$.prototype.reduce=function(b){for(;b.t<=this.mt2;)b[b.t++]=0;for(var v=0;v<this.m.t;++v){var I=32767&b[v],k=I*this.mpl+((I*this.mph+(b[v]>>15)*this.mpl&this.um)<<15)&b.DM;for(b[I=v+this.m.t]+=this.m.am(0,k,b,v,0,this.m.t);b[I]>=b.DV;)b[I]-=b.DV,b[++I]++}b.clamp(),b.drShiftTo(this.m.t,b),b.compareTo(this.m)>=0&&b.subTo(this.m,b)},$.prototype.mulTo=function(b,v,I){b.multiplyTo(v,I),this.reduce(I)},$.prototype.sqrTo=function(b,v){b.squareTo(v),this.reduce(v)},q.prototype.copyTo=function(b){for(var v=this.t-1;v>=0;--v)b[v]=this[v];b.t=this.t,b.s=this.s},q.prototype.fromInt=function(b){this.t=1,this.s=b<0?-1:0,b>0?this[0]=b:b<-1?this[0]=b+this.DV:this.t=0},q.prototype.fromString=function(b,v){var I;if(v==16)I=4;else if(v==8)I=3;else if(v==256)I=8;else if(v==2)I=1;else if(v==32)I=5;else{if(v!=4)return void this.fromRadix(b,v);I=2}this.t=0,this.s=0;for(var k=b.length,Q=!1,te=0;--k>=0;){var we=I==8?255&b[k]:ye(b,k);we<0?b.charAt(k)=="-"&&(Q=!0):(Q=!1,te==0?this[this.t++]=we:te+I>this.DB?(this[this.t-1]|=(we&(1<<this.DB-te)-1)<<te,this[this.t++]=we>>this.DB-te):this[this.t-1]|=we<<te,(te+=I)>=this.DB&&(te-=this.DB))}I==8&&(128&b[0])!=0&&(this.s=-1,te>0&&(this[this.t-1]|=(1<<this.DB-te)-1<<te)),this.clamp(),Q&&q.ZERO.subTo(this,this)},q.prototype.clamp=function(){for(var b=this.s&this.DM;this.t>0&&this[this.t-1]==b;)--this.t},q.prototype.dlShiftTo=function(b,v){var I;for(I=this.t-1;I>=0;--I)v[I+b]=this[I];for(I=b-1;I>=0;--I)v[I]=0;v.t=this.t+b,v.s=this.s},q.prototype.drShiftTo=function(b,v){for(var I=b;I<this.t;++I)v[I-b]=this[I];v.t=Math.max(this.t-b,0),v.s=this.s},q.prototype.lShiftTo=function(b,v){var I,k=b%this.DB,Q=this.DB-k,te=(1<<Q)-1,we=Math.floor(b/this.DB),ge=this.s<<k&this.DM;for(I=this.t-1;I>=0;--I)v[I+we+1]=this[I]>>Q|ge,ge=(this[I]&te)<<k;for(I=we-1;I>=0;--I)v[I]=0;v[we]=ge,v.t=this.t+we+1,v.s=this.s,v.clamp()},q.prototype.rShiftTo=function(b,v){v.s=this.s;var I=Math.floor(b/this.DB);if(I>=this.t)v.t=0;else{var k=b%this.DB,Q=this.DB-k,te=(1<<k)-1;v[0]=this[I]>>k;for(var we=I+1;we<this.t;++we)v[we-I-1]|=(this[we]&te)<<Q,v[we-I]=this[we]>>k;k>0&&(v[this.t-I-1]|=(this.s&te)<<Q),v.t=this.t-I,v.clamp()}},q.prototype.subTo=function(b,v){for(var I=0,k=0,Q=Math.min(b.t,this.t);I<Q;)k+=this[I]-b[I],v[I++]=k&this.DM,k>>=this.DB;if(b.t<this.t){for(k-=b.s;I<this.t;)k+=this[I],v[I++]=k&this.DM,k>>=this.DB;k+=this.s}else{for(k+=this.s;I<b.t;)k-=b[I],v[I++]=k&this.DM,k>>=this.DB;k-=b.s}v.s=k<0?-1:0,k<-1?v[I++]=this.DV+k:k>0&&(v[I++]=k),v.t=I,v.clamp()},q.prototype.multiplyTo=function(b,v){var I=this.abs(),k=b.abs(),Q=I.t;for(v.t=Q+k.t;--Q>=0;)v[Q]=0;for(Q=0;Q<k.t;++Q)v[Q+I.t]=I.am(0,k[Q],v,Q,0,I.t);v.s=0,v.clamp(),this.s!=b.s&&q.ZERO.subTo(v,v)},q.prototype.squareTo=function(b){for(var v=this.abs(),I=b.t=2*v.t;--I>=0;)b[I]=0;for(I=0;I<v.t-1;++I){var k=v.am(I,v[I],b,2*I,0,1);(b[I+v.t]+=v.am(I+1,2*v[I],b,2*I+1,k,v.t-I-1))>=v.DV&&(b[I+v.t]-=v.DV,b[I+v.t+1]=1)}b.t>0&&(b[b.t-1]+=v.am(I,v[I],b,2*I,0,1)),b.s=0,b.clamp()},q.prototype.divRemTo=function(b,v,I){var k=b.abs();if(!(k.t<=0)){var Q=this.abs();if(Q.t<k.t)return v?.fromInt(0),void(I!=null&&this.copyTo(I));I==null&&(I=Y());var te=Y(),we=this.s,ge=b.s,be=this.DB-pe(k[k.t-1]);be>0?(k.lShiftTo(be,te),Q.lShiftTo(be,I)):(k.copyTo(te),Q.copyTo(I));var _e=te.t,Re=te[_e-1];if(Re!=0){var Ce=Re*(1<<this.F1)+(_e>1?te[_e-2]>>this.F2:0),Le=this.FV/Ce,We=(1<<this.F1)/Ce,Xe=1<<this.F2,et=I.t,ne=et-_e,Se=v??Y();for(te.dlShiftTo(ne,Se),I.compareTo(Se)>=0&&(I[I.t++]=1,I.subTo(Se,I)),q.ONE.dlShiftTo(_e,Se),Se.subTo(te,te);te.t<_e;)te[te.t++]=0;for(;--ne>=0;){var Ae=I[--et]==Re?this.DM:Math.floor(I[et]*Le+(I[et-1]+Xe)*We);if((I[et]+=te.am(0,Ae,I,ne,0,_e))<Ae)for(te.dlShiftTo(ne,Se),I.subTo(Se,I);I[et]<--Ae;)I.subTo(Se,I)}v!=null&&(I.drShiftTo(_e,v),we!=ge&&q.ZERO.subTo(v,v)),I.t=_e,I.clamp(),be>0&&I.rShiftTo(be,I),we<0&&q.ZERO.subTo(I,I)}}},q.prototype.invDigit=function(){if(this.t<1)return 0;var b=this[0];if((1&b)==0)return 0;var v=3&b;return(v=(v=(v=(v=v*(2-(15&b)*v)&15)*(2-(255&b)*v)&255)*(2-((65535&b)*v&65535))&65535)*(2-b*v%this.DV)%this.DV)>0?this.DV-v:-v},q.prototype.isEven=function(){return(this.t>0?1&this[0]:this.s)==0},q.prototype.exp=function(b,v){if(b>4294967295||b<1)return q.ONE;var I=Y(),k=Y(),Q=v.convert(this),te=pe(b)-1;for(Q.copyTo(I);--te>=0;)if(v.sqrTo(I,k),(b&1<<te)>0)v.mulTo(k,Q,I);else{var we=I;I=k,k=we}return v.revert(I)},q.prototype.toString=function(b){if(this.s<0)return"-"+this.negate().toString(b);var v;if(b==16)v=4;else if(b==8)v=3;else if(b==2)v=1;else if(b==32)v=5;else{if(b!=4)return this.toRadix(b);v=2}var I,k=(1<<v)-1,Q=!1,te="",we=this.t,ge=this.DB-we*this.DB%v;if(we-- >0)for(ge<this.DB&&(I=this[we]>>ge)>0&&(Q=!0,te=ze(I));we>=0;)ge<v?(I=(this[we]&(1<<ge)-1)<<v-ge,I|=this[--we]>>(ge+=this.DB-v)):(I=this[we]>>(ge-=v)&k,ge<=0&&(ge+=this.DB,--we)),I>0&&(Q=!0),Q&&(te+=ze(I));return Q?te:"0"},q.prototype.negate=function(){var b=Y();return q.ZERO.subTo(this,b),b},q.prototype.abs=function(){return this.s<0?this.negate():this},q.prototype.compareTo=function(b){var v=this.s-b.s;if(v!=0)return v;var I=this.t;if((v=I-b.t)!=0)return this.s<0?-v:v;for(;--I>=0;)if((v=this[I]-b[I])!=0)return v;return 0},q.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+pe(this[this.t-1]^this.s&this.DM)},q.prototype.mod=function(b){var v=Y();return this.abs().divRemTo(b,null,v),this.s<0&&v.compareTo(q.ZERO)>0&&b.subTo(v,v),v},q.prototype.modPowInt=function(b,v){var I;return I=b<256||v.isEven()?new De(v):new $(v),this.exp(b,I)},q.ZERO=Ve(0),q.ONE=Ve(1),He.prototype.convert=he,He.prototype.revert=he,He.prototype.mulTo=function(b,v,I){b.multiplyTo(v,I)},He.prototype.sqrTo=function(b,v){b.squareTo(v)},fe.prototype.convert=function(b){if(b.s<0||b.t>2*this.m.t)return b.mod(this.m);if(b.compareTo(this.m)<0)return b;var v=Y();return b.copyTo(v),this.reduce(v),v},fe.prototype.revert=function(b){return b},fe.prototype.reduce=function(b){for(b.drShiftTo(this.m.t-1,this.r2),b.t>this.m.t+1&&(b.t=this.m.t+1,b.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);b.compareTo(this.r2)<0;)b.dAddOffset(1,this.m.t+1);for(b.subTo(this.r2,b);b.compareTo(this.m)>=0;)b.subTo(this.m,b)},fe.prototype.mulTo=function(b,v,I){b.multiplyTo(v,I),this.reduce(I)},fe.prototype.sqrTo=function(b,v){b.squareTo(v),this.reduce(v)};var Oe=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],ie=(1<<26)/Oe[Oe.length-1];function j(){this.i=0,this.j=0,this.S=new Array}q.prototype.chunkSize=function(b){return Math.floor(Math.LN2*this.DB/Math.log(b))},q.prototype.toRadix=function(b){if(b==null&&(b=10),this.signum()==0||b<2||b>36)return"0";var v=this.chunkSize(b),I=Math.pow(b,v),k=Ve(I),Q=Y(),te=Y(),we="";for(this.divRemTo(k,Q,te);Q.signum()>0;)we=(I+te.intValue()).toString(b).substr(1)+we,Q.divRemTo(k,Q,te);return te.intValue().toString(b)+we},q.prototype.fromRadix=function(b,v){this.fromInt(0),v==null&&(v=10);for(var I=this.chunkSize(v),k=Math.pow(v,I),Q=!1,te=0,we=0,ge=0;ge<b.length;++ge){var be=ye(b,ge);be<0?b.charAt(ge)=="-"&&this.signum()==0&&(Q=!0):(we=v*we+be,++te>=I&&(this.dMultiply(k),this.dAddOffset(we,0),te=0,we=0))}te>0&&(this.dMultiply(Math.pow(v,te)),this.dAddOffset(we,0)),Q&&q.ZERO.subTo(this,this)},q.prototype.fromNumber=function(b,v,I){if(typeof v=="number")if(b<2)this.fromInt(1);else for(this.fromNumber(b,I),this.testBit(b-1)||this.bitwiseTo(q.ONE.shiftLeft(b-1),ce,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(v);)this.dAddOffset(2,0),this.bitLength()>b&&this.subTo(q.ONE.shiftLeft(b-1),this);else{var k=new Array,Q=7&b;k.length=1+(b>>3),v.nextBytes(k),Q>0?k[0]&=(1<<Q)-1:k[0]=0,this.fromString(k,256)}},q.prototype.bitwiseTo=function(b,v,I){var k,Q,te=Math.min(b.t,this.t);for(k=0;k<te;++k)I[k]=v(this[k],b[k]);if(b.t<this.t){for(Q=b.s&this.DM,k=te;k<this.t;++k)I[k]=v(this[k],Q);I.t=this.t}else{for(Q=this.s&this.DM,k=te;k<b.t;++k)I[k]=v(Q,b[k]);I.t=b.t}I.s=v(this.s,b.s),I.clamp()},q.prototype.changeBit=function(b,v){var I=q.ONE.shiftLeft(b);return this.bitwiseTo(I,v,I),I},q.prototype.addTo=function(b,v){for(var I=0,k=0,Q=Math.min(b.t,this.t);I<Q;)k+=this[I]+b[I],v[I++]=k&this.DM,k>>=this.DB;if(b.t<this.t){for(k+=b.s;I<this.t;)k+=this[I],v[I++]=k&this.DM,k>>=this.DB;k+=this.s}else{for(k+=this.s;I<b.t;)k+=b[I],v[I++]=k&this.DM,k>>=this.DB;k+=b.s}v.s=k<0?-1:0,k>0?v[I++]=k:k<-1&&(v[I++]=this.DV+k),v.t=I,v.clamp()},q.prototype.dMultiply=function(b){this[this.t]=this.am(0,b-1,this,0,0,this.t),++this.t,this.clamp()},q.prototype.dAddOffset=function(b,v){if(b!=0){for(;this.t<=v;)this[this.t++]=0;for(this[v]+=b;this[v]>=this.DV;)this[v]-=this.DV,++v>=this.t&&(this[this.t++]=0),++this[v]}},q.prototype.multiplyLowerTo=function(b,v,I){var k,Q=Math.min(this.t+b.t,v);for(I.s=0,I.t=Q;Q>0;)I[--Q]=0;for(k=I.t-this.t;Q<k;++Q)I[Q+this.t]=this.am(0,b[Q],I,Q,0,this.t);for(k=Math.min(b.t,v);Q<k;++Q)this.am(0,b[Q],I,Q,0,v-Q);I.clamp()},q.prototype.multiplyUpperTo=function(b,v,I){--v;var k=I.t=this.t+b.t-v;for(I.s=0;--k>=0;)I[k]=0;for(k=Math.max(v-this.t,0);k<b.t;++k)I[this.t+k-v]=this.am(v-k,b[k],I,0,0,this.t+k-v);I.clamp(),I.drShiftTo(1,I)},q.prototype.modInt=function(b){if(b<=0)return 0;var v=this.DV%b,I=this.s<0?b-1:0;if(this.t>0)if(v==0)I=this[0]%b;else for(var k=this.t-1;k>=0;--k)I=(v*I+this[k])%b;return I},q.prototype.millerRabin=function(b){var v=this.subtract(q.ONE),I=v.getLowestSetBit();if(I<=0)return!1;var k=v.shiftRight(I);(b=b+1>>1)>Oe.length&&(b=Oe.length);for(var Q=Y(),te=0;te<b;++te){Q.fromInt(Oe[Math.floor(Math.random()*Oe.length)]);var we=Q.modPow(k,this);if(we.compareTo(q.ONE)!=0&&we.compareTo(v)!=0){for(var ge=1;ge++<I&&we.compareTo(v)!=0;)if((we=we.modPowInt(2,this)).compareTo(q.ONE)==0)return!1;if(we.compareTo(v)!=0)return!1}}return!0},q.prototype.clone=function(){var b=Y();return this.copyTo(b),b},q.prototype.intValue=function(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},q.prototype.byteValue=function(){return this.t==0?this.s:this[0]<<24>>24},q.prototype.shortValue=function(){return this.t==0?this.s:this[0]<<16>>16},q.prototype.signum=function(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1},q.prototype.toByteArray=function(){var b=this.t,v=new Array;v[0]=this.s;var I,k=this.DB-b*this.DB%8,Q=0;if(b-- >0)for(k<this.DB&&(I=this[b]>>k)!=(this.s&this.DM)>>k&&(v[Q++]=I|this.s<<this.DB-k);b>=0;)k<8?(I=(this[b]&(1<<k)-1)<<8-k,I|=this[--b]>>(k+=this.DB-8)):(I=this[b]>>(k-=8)&255,k<=0&&(k+=this.DB,--b)),(128&I)!=0&&(I|=-256),Q==0&&(128&this.s)!=(128&I)&&++Q,(Q>0||I!=this.s)&&(v[Q++]=I);return v},q.prototype.equals=function(b){return this.compareTo(b)==0},q.prototype.min=function(b){return this.compareTo(b)<0?this:b},q.prototype.max=function(b){return this.compareTo(b)>0?this:b},q.prototype.and=function(b){var v=Y();return this.bitwiseTo(b,G,v),v},q.prototype.or=function(b){var v=Y();return this.bitwiseTo(b,ce,v),v},q.prototype.xor=function(b){var v=Y();return this.bitwiseTo(b,oe,v),v},q.prototype.andNot=function(b){var v=Y();return this.bitwiseTo(b,Fe,v),v},q.prototype.not=function(){for(var b=Y(),v=0;v<this.t;++v)b[v]=this.DM&~this[v];return b.t=this.t,b.s=~this.s,b},q.prototype.shiftLeft=function(b){var v=Y();return b<0?this.rShiftTo(-b,v):this.lShiftTo(b,v),v},q.prototype.shiftRight=function(b){var v=Y();return b<0?this.lShiftTo(-b,v):this.rShiftTo(b,v),v},q.prototype.getLowestSetBit=function(){for(var b=0;b<this.t;++b)if(this[b]!=0)return b*this.DB+Ue(this[b]);return this.s<0?this.t*this.DB:-1},q.prototype.bitCount=function(){for(var b=0,v=this.s&this.DM,I=0;I<this.t;++I)b+=Je(this[I]^v);return b},q.prototype.testBit=function(b){var v=Math.floor(b/this.DB);return v>=this.t?this.s!=0:(this[v]&1<<b%this.DB)!=0},q.prototype.setBit=function(b){return this.changeBit(b,ce)},q.prototype.clearBit=function(b){return this.changeBit(b,Fe)},q.prototype.flipBit=function(b){return this.changeBit(b,oe)},q.prototype.add=function(b){var v=Y();return this.addTo(b,v),v},q.prototype.subtract=function(b){var v=Y();return this.subTo(b,v),v},q.prototype.multiply=function(b){var v=Y();return this.multiplyTo(b,v),v},q.prototype.divide=function(b){var v=Y();return this.divRemTo(b,v,null),v},q.prototype.remainder=function(b){var v=Y();return this.divRemTo(b,null,v),v},q.prototype.divideAndRemainder=function(b){var v=Y(),I=Y();return this.divRemTo(b,v,I),new Array(v,I)},q.prototype.modPow=function(b,v){var I,k,Q=b.bitLength(),te=Ve(1);if(Q<=0)return te;I=Q<18?1:Q<48?3:Q<144?4:Q<768?5:6,k=Q<8?new De(v):v.isEven()?new fe(v):new $(v);var we=new Array,ge=3,be=I-1,_e=(1<<I)-1;if(we[1]=k.convert(this),I>1){var Re=Y();for(k.sqrTo(we[1],Re);ge<=_e;)we[ge]=Y(),k.mulTo(Re,we[ge-2],we[ge]),ge+=2}var Ce,Le,We=b.t-1,Xe=!0,et=Y();for(Q=pe(b[We])-1;We>=0;){for(Q>=be?Ce=b[We]>>Q-be&_e:(Ce=(b[We]&(1<<Q+1)-1)<<be-Q,We>0&&(Ce|=b[We-1]>>this.DB+Q-be)),ge=I;(1&Ce)==0;)Ce>>=1,--ge;if((Q-=ge)<0&&(Q+=this.DB,--We),Xe)we[Ce].copyTo(te),Xe=!1;else{for(;ge>1;)k.sqrTo(te,et),k.sqrTo(et,te),ge-=2;ge>0?k.sqrTo(te,et):(Le=te,te=et,et=Le),k.mulTo(et,we[Ce],te)}for(;We>=0&&(b[We]&1<<Q)==0;)k.sqrTo(te,et),Le=te,te=et,et=Le,--Q<0&&(Q=this.DB-1,--We)}return k.revert(te)},q.prototype.modInverse=function(b){var v=b.isEven();if(this.isEven()&&v||b.signum()==0)return q.ZERO;for(var I=b.clone(),k=this.clone(),Q=Ve(1),te=Ve(0),we=Ve(0),ge=Ve(1);I.signum()!=0;){for(;I.isEven();)I.rShiftTo(1,I),v?(Q.isEven()&&te.isEven()||(Q.addTo(this,Q),te.subTo(b,te)),Q.rShiftTo(1,Q)):te.isEven()||te.subTo(b,te),te.rShiftTo(1,te);for(;k.isEven();)k.rShiftTo(1,k),v?(we.isEven()&&ge.isEven()||(we.addTo(this,we),ge.subTo(b,ge)),we.rShiftTo(1,we)):ge.isEven()||ge.subTo(b,ge),ge.rShiftTo(1,ge);I.compareTo(k)>=0?(I.subTo(k,I),v&&Q.subTo(we,Q),te.subTo(ge,te)):(k.subTo(I,k),v&&we.subTo(Q,we),ge.subTo(te,ge))}return k.compareTo(q.ONE)!=0?q.ZERO:ge.compareTo(b)>=0?ge.subtract(b):ge.signum()<0?(ge.addTo(b,ge),ge.signum()<0?ge.add(b):ge):ge},q.prototype.pow=function(b){return this.exp(b,new He)},q.prototype.gcd=function(b){var v=this.s<0?this.negate():this.clone(),I=b.s<0?b.negate():b.clone();if(v.compareTo(I)<0){var k=v;v=I,I=k}var Q=v.getLowestSetBit(),te=I.getLowestSetBit();if(te<0)return v;for(Q<te&&(te=Q),te>0&&(v.rShiftTo(te,v),I.rShiftTo(te,I));v.signum()>0;)(Q=v.getLowestSetBit())>0&&v.rShiftTo(Q,v),(Q=I.getLowestSetBit())>0&&I.rShiftTo(Q,I),v.compareTo(I)>=0?(v.subTo(I,v),v.rShiftTo(1,v)):(I.subTo(v,I),I.rShiftTo(1,I));return te>0&&I.lShiftTo(te,I),I},q.prototype.isProbablePrime=function(b){var v,I=this.abs();if(I.t==1&&I[0]<=Oe[Oe.length-1]){for(v=0;v<Oe.length;++v)if(I[0]==Oe[v])return!0;return!1}if(I.isEven())return!1;for(v=1;v<Oe.length;){for(var k=Oe[v],Q=v+1;Q<Oe.length&&k<ie;)k*=Oe[Q++];for(k=I.modInt(k);v<Q;)if(k%Oe[v++]==0)return!1}return I.millerRabin(b)},q.prototype.square=function(){var b=Y();return this.squareTo(b),b},j.prototype.init=function(b){var v,I,k;for(v=0;v<256;++v)this.S[v]=v;for(I=0,v=0;v<256;++v)I=I+this.S[v]+b[v%b.length]&255,k=this.S[v],this.S[v]=this.S[I],this.S[I]=k;this.i=0,this.j=0},j.prototype.next=function(){var b;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,b=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=b,this.S[b+this.S[this.i]&255]};var N,L,V;function ee(){(function(b){L[V++]^=255&b,L[V++]^=b>>8&255,L[V++]^=b>>16&255,L[V++]^=b>>24&255,V>=256&&(V-=256)})(new Date().getTime())}if(L==null){var ae;if(L=new Array,V=0,x!==void 0&&(x.crypto!==void 0||x.msCrypto!==void 0)){var ve=x.crypto||x.msCrypto;if(ve.getRandomValues){var J=new Uint8Array(32);for(ve.getRandomValues(J),ae=0;ae<32;++ae)L[V++]=J[ae]}else if(F.appName=="Netscape"&&F.appVersion<"5"){var me=x.crypto.random(32);for(ae=0;ae<me.length;++ae)L[V++]=255&me.charCodeAt(ae)}}for(;V<256;)ae=Math.floor(65536*Math.random()),L[V++]=ae>>>8,L[V++]=255&ae;V=0,ee()}function xe(){if(N==null){for(ee(),(N=(function(){return new j})()).init(L),V=0;V<L.length;++V)L[V]=0;V=0}return N.next()}function de(){}function st(_,b){return new q(_,b)}function ft(_,b,v){for(var I="",k=0;I.length<b;)I+=v(String.fromCharCode.apply(String,_.concat([(4278190080&k)>>24,(16711680&k)>>16,(65280&k)>>8,255&k]))),k+=1;return I}function Ge(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function pt(_,b){this.x=b,this.q=_}function Z(_,b,v,I){this.curve=_,this.x=b,this.y=v,this.z=I??q.ONE,this.zinv=null}function P(_,b,v){this.q=_,this.a=this.fromBigInteger(b),this.b=this.fromBigInteger(v),this.infinity=new Z(this,null,null)}de.prototype.nextBytes=function(b){var v;for(v=0;v<b.length;++v)b[v]=xe()},Ge.prototype.doPublic=function(b){return b.modPowInt(this.e,this.n)},Ge.prototype.setPublic=function(b,v){if(this.isPublic=!0,this.isPrivate=!1,typeof b!="string")this.n=b,this.e=v;else{if(!(b!=null&&v!=null&&b.length>0&&v.length>0))throw"Invalid RSA public key";this.n=st(b,16),this.e=parseInt(v,16)}},Ge.prototype.encrypt=function(b){var v=(function(te,we){if(we<te.length+11)throw"Message too long for RSA";for(var ge=new Array,be=te.length-1;be>=0&&we>0;){var _e=te.charCodeAt(be--);_e<128?ge[--we]=_e:_e>127&&_e<2048?(ge[--we]=63&_e|128,ge[--we]=_e>>6|192):(ge[--we]=63&_e|128,ge[--we]=_e>>6&63|128,ge[--we]=_e>>12|224)}ge[--we]=0;for(var Re=new de,Ce=new Array;we>2;){for(Ce[0]=0;Ce[0]==0;)Re.nextBytes(Ce);ge[--we]=Ce[0]}return ge[--we]=2,ge[--we]=0,new q(ge)})(b,this.n.bitLength()+7>>3);if(v==null)return null;var I=this.doPublic(v);if(I==null)return null;var k=I.toString(16);return(1&k.length)==0?k:"0"+k},Ge.prototype.encryptOAEP=function(b,v,I){var k=(function(ge,be,_e,Re){var Ce=U.crypto.MessageDigest,Le=U.crypto.Util,We=null;if(_e||(_e="sha1"),typeof _e=="string"&&(We=Ce.getCanonicalAlgName(_e),Re=Ce.getHashLength(We),_e=function(ht){return dr(Le.hashHex(nr(ht),We))}),ge.length+2*Re+2>be)throw"Message too long for RSA";var Xe,et="";for(Xe=0;Xe<be-ge.length-2*Re-2;Xe+=1)et+="\0";var ne=_e("")+et+""+ge,Se=new Array(Re);new de().nextBytes(Se);var Ae=ft(Se,ne.length,_e),Ne=[];for(Xe=0;Xe<ne.length;Xe+=1)Ne[Xe]=ne.charCodeAt(Xe)^Ae.charCodeAt(Xe);var Qe=ft(Ne,Se.length,_e),nt=[0];for(Xe=0;Xe<Se.length;Xe+=1)nt[Xe+1]=Se[Xe]^Qe.charCodeAt(Xe);return new q(nt.concat(Ne))})(b,this.n.bitLength()+7>>3,v,I);if(k==null)return null;var Q=this.doPublic(k);if(Q==null)return null;var te=Q.toString(16);return(1&te.length)==0?te:"0"+te},Ge.prototype.type="RSA",pt.prototype.equals=function(b){return b==this||this.q.equals(b.q)&&this.x.equals(b.x)},pt.prototype.toBigInteger=function(){return this.x},pt.prototype.negate=function(){return new pt(this.q,this.x.negate().mod(this.q))},pt.prototype.add=function(b){return new pt(this.q,this.x.add(b.toBigInteger()).mod(this.q))},pt.prototype.subtract=function(b){return new pt(this.q,this.x.subtract(b.toBigInteger()).mod(this.q))},pt.prototype.multiply=function(b){return new pt(this.q,this.x.multiply(b.toBigInteger()).mod(this.q))},pt.prototype.square=function(){return new pt(this.q,this.x.square().mod(this.q))},pt.prototype.divide=function(b){return new pt(this.q,this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q))},Z.prototype.getX=function(){return this.zinv==null&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},Z.prototype.getY=function(){return this.zinv==null&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},Z.prototype.equals=function(b){return b==this||(this.isInfinity()?b.isInfinity():b.isInfinity()?this.isInfinity():!!b.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(b.z)).mod(this.curve.q).equals(q.ZERO)&&b.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(b.z)).mod(this.curve.q).equals(q.ZERO))},Z.prototype.isInfinity=function(){return this.x==null&&this.y==null||this.z.equals(q.ZERO)&&!this.y.toBigInteger().equals(q.ZERO)},Z.prototype.negate=function(){return new Z(this.curve,this.x,this.y.negate(),this.z)},Z.prototype.add=function(b){if(this.isInfinity())return b;if(b.isInfinity())return this;var v=b.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(b.z)).mod(this.curve.q),I=b.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(b.z)).mod(this.curve.q);if(q.ZERO.equals(I))return q.ZERO.equals(v)?this.twice():this.curve.getInfinity();var k=new q("3"),Q=this.x.toBigInteger(),te=this.y.toBigInteger(),we=(b.x.toBigInteger(),b.y.toBigInteger(),I.square()),ge=we.multiply(I),be=Q.multiply(we),_e=v.square().multiply(this.z),Re=_e.subtract(be.shiftLeft(1)).multiply(b.z).subtract(ge).multiply(I).mod(this.curve.q),Ce=be.multiply(k).multiply(v).subtract(te.multiply(ge)).subtract(_e.multiply(v)).multiply(b.z).add(v.multiply(ge)).mod(this.curve.q),Le=ge.multiply(this.z).multiply(b.z).mod(this.curve.q);return new Z(this.curve,this.curve.fromBigInteger(Re),this.curve.fromBigInteger(Ce),Le)},Z.prototype.twice=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var b=new q("3"),v=this.x.toBigInteger(),I=this.y.toBigInteger(),k=I.multiply(this.z),Q=k.multiply(I).mod(this.curve.q),te=this.curve.a.toBigInteger(),we=v.square().multiply(b);q.ZERO.equals(te)||(we=we.add(this.z.square().multiply(te)));var ge=(we=we.mod(this.curve.q)).square().subtract(v.shiftLeft(3).multiply(Q)).shiftLeft(1).multiply(k).mod(this.curve.q),be=we.multiply(b).multiply(v).subtract(Q.shiftLeft(1)).shiftLeft(2).multiply(Q).subtract(we.square().multiply(we)).mod(this.curve.q),_e=k.square().multiply(k).shiftLeft(3).mod(this.curve.q);return new Z(this.curve,this.curve.fromBigInteger(ge),this.curve.fromBigInteger(be),_e)},Z.prototype.multiply=function(b){if(this.isInfinity())return this;if(b.signum()==0)return this.curve.getInfinity();var v,I=b,k=I.multiply(new q("3")),Q=this.negate(),te=this,we=this.curve.q.subtract(b),ge=we.multiply(new q("3")),be=new Z(this.curve,this.x,this.y),_e=be.negate();for(v=k.bitLength()-2;v>0;--v){te=te.twice();var Re=k.testBit(v);Re!=I.testBit(v)&&(te=te.add(Re?this:Q))}for(v=ge.bitLength()-2;v>0;--v){be=be.twice();var Ce=ge.testBit(v);Ce!=we.testBit(v)&&(be=be.add(Ce?be:_e))}return te},Z.prototype.multiplyTwo=function(b,v,I){var k;k=b.bitLength()>I.bitLength()?b.bitLength()-1:I.bitLength()-1;for(var Q=this.curve.getInfinity(),te=this.add(v);k>=0;)Q=Q.twice(),b.testBit(k)?Q=I.testBit(k)?Q.add(te):Q.add(this):I.testBit(k)&&(Q=Q.add(v)),--k;return Q},P.prototype.getQ=function(){return this.q},P.prototype.getA=function(){return this.a},P.prototype.getB=function(){return this.b},P.prototype.equals=function(b){return b==this||this.q.equals(b.q)&&this.a.equals(b.a)&&this.b.equals(b.b)},P.prototype.getInfinity=function(){return this.infinity},P.prototype.fromBigInteger=function(b){return new pt(this.q,b)},P.prototype.decodePointHex=function(b){switch(parseInt(b.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var v=(b.length-2)/2,I=b.substr(2,v),k=b.substr(v+2,v);return new Z(this,this.fromBigInteger(new q(I,16)),this.fromBigInteger(new q(k,16)));default:return null}},pt.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},Z.prototype.getEncoded=function(_){var b=function(te,we){var ge=te.toByteArrayUnsigned();if(we<ge.length)ge=ge.slice(ge.length-we);else for(;we>ge.length;)ge.unshift(0);return ge},v=this.getX().toBigInteger(),I=this.getY().toBigInteger(),k=b(v,32);return _?I.isEven()?k.unshift(2):k.unshift(3):(k.unshift(4),k=k.concat(b(I,32))),k},Z.decodeFrom=function(_,b){b[0];var v=b.length-1,I=b.slice(1,1+v/2),k=b.slice(1+v/2,1+v);I.unshift(0),k.unshift(0);var Q=new q(I),te=new q(k);return new Z(_,_.fromBigInteger(Q),_.fromBigInteger(te))},Z.decodeFromHex=function(_,b){b.substr(0,2);var v=b.length-2,I=b.substr(2,v/2),k=b.substr(2+v/2,v/2),Q=new q(I,16),te=new q(k,16);return new Z(_,_.fromBigInteger(Q),_.fromBigInteger(te))},Z.prototype.add2D=function(_){if(this.isInfinity())return _;if(_.isInfinity())return this;if(this.x.equals(_.x))return this.y.equals(_.y)?this.twice():this.curve.getInfinity();var b=_.x.subtract(this.x),v=_.y.subtract(this.y).divide(b),I=v.square().subtract(this.x).subtract(_.x),k=v.multiply(this.x.subtract(I)).subtract(this.y);return new Z(this.curve,I,k)},Z.prototype.twice2D=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var _=this.curve.fromBigInteger(q.valueOf(2)),b=this.curve.fromBigInteger(q.valueOf(3)),v=this.x.square().multiply(b).add(this.curve.a).divide(this.y.multiply(_)),I=v.square().subtract(this.x.multiply(_)),k=v.multiply(this.x.subtract(I)).subtract(this.y);return new Z(this.curve,I,k)},Z.prototype.multiply2D=function(_){if(this.isInfinity())return this;if(_.signum()==0)return this.curve.getInfinity();var b,v=_,I=v.multiply(new q("3")),k=this.negate(),Q=this;for(b=I.bitLength()-2;b>0;--b){Q=Q.twice();var te=I.testBit(b);te!=v.testBit(b)&&(Q=Q.add2D(te?this:k))}return Q},Z.prototype.isOnCurve=function(){var _=this.getX().toBigInteger(),b=this.getY().toBigInteger(),v=this.curve.getA().toBigInteger(),I=this.curve.getB().toBigInteger(),k=this.curve.getQ(),Q=b.multiply(b).mod(k),te=_.multiply(_).multiply(_).add(v.multiply(_)).add(I).mod(k);return Q.equals(te)},Z.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},Z.prototype.validate=function(){var _=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var b=this.getX().toBigInteger(),v=this.getY().toBigInteger();if(b.compareTo(q.ONE)<0||b.compareTo(_.subtract(q.ONE))>0)throw new Error("x coordinate out of bounds");if(v.compareTo(q.ONE)<0||v.compareTo(_.subtract(q.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(_).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var B=(function(){var _=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),b=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),v={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:`
13
+ `,r:"\r",t:" "};function I(te,we,ge){return we?v[we]:String.fromCharCode(parseInt(ge,16))}var k=new String(""),Q=Object.hasOwnProperty;return function(te,we){var ge,be,_e=te.match(_),Re=_e[0],Ce=!1;Re==="{"?ge={}:Re==="["?ge=[]:(ge=[],Ce=!0);for(var Le=[ge],We=1-Ce,Xe=_e.length;We<Xe;++We){var et;switch((Re=_e[We]).charCodeAt(0)){default:(et=Le[0])[be||et.length]=+Re,be=void 0;break;case 34:if((Re=Re.substring(1,Re.length-1)).indexOf("\\")!==-1&&(Re=Re.replace(b,I)),et=Le[0],!be){if(!(et instanceof Array)){be=Re||k;break}be=et.length}et[be]=Re,be=void 0;break;case 91:et=Le[0],Le.unshift(et[be||et.length]=[]),be=void 0;break;case 93:Le.shift();break;case 102:(et=Le[0])[be||et.length]=!1,be=void 0;break;case 110:(et=Le[0])[be||et.length]=null,be=void 0;break;case 116:(et=Le[0])[be||et.length]=!0,be=void 0;break;case 123:et=Le[0],Le.unshift(et[be||et.length]={}),be=void 0;break;case 125:Le.shift()}}if(Ce){if(Le.length!==1)throw new Error;ge=ge[0]}else if(Le.length)throw new Error;return we&&(ge=(function ne(Se,Ae){var Ne=Se[Ae];if(Ne&&(Ne===void 0?"undefined":A(Ne))==="object"){var Qe=null;for(var nt in Ne)if(Q.call(Ne,nt)&&Ne!==Se){var bt=ne(Ne,nt);bt!==void 0?Ne[nt]=bt:(Qe||(Qe=[]),Qe.push(nt))}if(Qe)for(var ht=Qe.length;--ht>=0;)delete Ne[Qe[ht]]}return we.call(Se,Ae,Ne)})({"":ge},"")),ge}})();U!==void 0&&U||(n.KJUR=U={}),U.asn1!==void 0&&U.asn1||(U.asn1={}),U.asn1.ASN1Util=new function(){this.integerToByteHex=function(_){var b=_.toString(16);return b.length%2==1&&(b="0"+b),b},this.bigIntToMinTwosComplementsHex=function(_){var b=_.toString(16);if(b.substr(0,1)!="-")b.length%2==1?b="0"+b:b.match(/^[0-7]/)||(b="00"+b);else{var v=b.substr(1).length;v%2==1?v+=1:b.match(/^[0-7]/)||(v+=2);for(var I="",k=0;k<v;k++)I+="f";b=new q(I,16).xor(_).add(q.ONE).toString(16).replace(/^-/,"")}return b},this.getPEMStringFromHex=function(_,b){return Be(_,b)},this.newObject=function(_){var b=U.asn1,v=b.ASN1Object,I=b.DERBoolean,k=b.DERInteger,Q=b.DERBitString,te=b.DEROctetString,we=b.DERNull,ge=b.DERObjectIdentifier,be=b.DEREnumerated,_e=b.DERUTF8String,Re=b.DERNumericString,Ce=b.DERPrintableString,Le=b.DERTeletexString,We=b.DERIA5String,Xe=b.DERUTCTime,et=b.DERGeneralizedTime,ne=b.DERVisibleString,Se=b.DERBMPString,Ae=b.DERSequence,Ne=b.DERSet,Qe=b.DERTaggedObject,nt=b.ASN1Util.newObject;if(_ instanceof b.ASN1Object)return _;var bt=Object.keys(_);if(bt.length!=1)throw new Error("key of param shall be only one.");var ht=bt[0];if(":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+ht+":")==-1)throw new Error("undefined key: "+ht);if(ht=="bool")return new I(_[ht]);if(ht=="int")return new k(_[ht]);if(ht=="bitstr")return new Q(_[ht]);if(ht=="octstr")return new te(_[ht]);if(ht=="null")return new we(_[ht]);if(ht=="oid")return new ge(_[ht]);if(ht=="enum")return new be(_[ht]);if(ht=="utf8str")return new _e(_[ht]);if(ht=="numstr")return new Re(_[ht]);if(ht=="prnstr")return new Ce(_[ht]);if(ht=="telstr")return new Le(_[ht]);if(ht=="ia5str")return new We(_[ht]);if(ht=="utctime")return new Xe(_[ht]);if(ht=="gentime")return new et(_[ht]);if(ht=="visstr")return new ne(_[ht]);if(ht=="bmpstr")return new Se(_[ht]);if(ht=="asn1")return new v(_[ht]);if(ht=="seq"){for(var Ct=_[ht],yt=[],wt=0;wt<Ct.length;wt++){var Jt=nt(Ct[wt]);yt.push(Jt)}return new Ae({array:yt})}if(ht=="set"){for(Ct=_[ht],yt=[],wt=0;wt<Ct.length;wt++)Jt=nt(Ct[wt]),yt.push(Jt);return new Ne({array:yt})}if(ht=="tag"){var Qt=_[ht];if(Object.prototype.toString.call(Qt)==="[object Array]"&&Qt.length==3){var Mt=nt(Qt[2]);return new Qe({tag:Qt[0],explicit:Qt[1],obj:Mt})}return new Qe(Qt)}},this.jsonToASN1HEX=function(_){return this.newObject(_).getEncodedHex()}},U.asn1.ASN1Util.oidHexToInt=function(_){for(var b="",v=parseInt(_.substr(0,2),16),I=(b=Math.floor(v/40)+"."+v%40,""),k=2;k<_.length;k+=2){var Q=("00000000"+parseInt(_.substr(k,2),16).toString(2)).slice(-8);I+=Q.substr(1,7),Q.substr(0,1)=="0"&&(b=b+"."+new q(I,2).toString(10),I="")}return b},U.asn1.ASN1Util.oidIntToHex=function(_){var b=function(ge){var be=ge.toString(16);return be.length==1&&(be="0"+be),be},v=function(ge){var be="",_e=new q(ge,10).toString(2),Re=7-_e.length%7;Re==7&&(Re=0);for(var Ce="",Le=0;Le<Re;Le++)Ce+="0";for(_e=Ce+_e,Le=0;Le<_e.length-1;Le+=7){var We=_e.substr(Le,7);Le!=_e.length-7&&(We="1"+We),be+=b(parseInt(We,2))}return be};if(!_.match(/^[0-9.]+$/))throw"malformed oid string: "+_;var I="",k=_.split("."),Q=40*parseInt(k[0])+parseInt(k[1]);I+=b(Q),k.splice(0,2);for(var te=0;te<k.length;te++)I+=v(k[te]);return I},U.asn1.ASN1Object=function(_){this.params=null,this.getLengthHexFromValue=function(){if(this.hV===void 0||this.hV==null)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n=0,v="+this.hV);var b=this.hV.length/2,v=b.toString(16);if(v.length%2==1&&(v="0"+v),b<128)return v;var I=v.length/2;if(I>15)throw"ASN.1 length too long to represent by 8x: n = "+b.toString(16);return(128+I).toString(16)+v},this.getEncodedHex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(b){this.params=b},_!=null&&_.tlv!=null&&(this.hTLV=_.tlv,this.isModified=!1)},U.asn1.DERAbstractString=function(_){U.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(b){this.hTLV=null,this.isModified=!0,this.s=b,this.hV=vr(this.s).toLowerCase()},this.setStringHex=function(b){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=b},this.getFreshValueHex=function(){return this.hV},_!==void 0&&(typeof _=="string"?this.setString(_):_.str!==void 0?this.setString(_.str):_.hex!==void 0&&this.setStringHex(_.hex))},Lt(U.asn1.DERAbstractString,U.asn1.ASN1Object),U.asn1.DERAbstractTime=function(_){U.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(b){var v=b.getTime()+6e4*b.getTimezoneOffset();return new Date(v)},this.formatDate=function(b,v,I){var k=this.zeroPadding,Q=this.localDateToUTC(b),te=String(Q.getFullYear());v=="utc"&&(te=te.substr(2,2));var we=te+k(String(Q.getMonth()+1),2)+k(String(Q.getDate()),2)+k(String(Q.getHours()),2)+k(String(Q.getMinutes()),2)+k(String(Q.getSeconds()),2);if(I===!0){var ge=Q.getMilliseconds();if(ge!=0){var be=k(String(ge),3);we=we+"."+(be=be.replace(/[0]+$/,""))}}return we+"Z"},this.zeroPadding=function(b,v){return b.length>=v?b:new Array(v-b.length+1).join("0")+b},this.getString=function(){return this.s},this.setString=function(b){this.hTLV=null,this.isModified=!0,this.s=b,this.hV=kt(b)},this.setByDateValue=function(b,v,I,k,Q,te){var we=new Date(Date.UTC(b,v-1,I,k,Q,te,0));this.setByDate(we)},this.getFreshValueHex=function(){return this.hV}},Lt(U.asn1.DERAbstractTime,U.asn1.ASN1Object),U.asn1.DERAbstractStructured=function(_){U.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(b){this.hTLV=null,this.isModified=!0,this.asn1Array=b},this.appendASN1Object=function(b){this.hTLV=null,this.isModified=!0,this.asn1Array.push(b)},this.asn1Array=new Array,_!==void 0&&_.array!==void 0&&(this.asn1Array=_.array)},Lt(U.asn1.DERAbstractStructured,U.asn1.ASN1Object),U.asn1.DERBoolean=function(_){U.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=_==0?"010100":"0101ff"},Lt(U.asn1.DERBoolean,U.asn1.ASN1Object),U.asn1.DERInteger=function(_){U.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(b){this.hTLV=null,this.isModified=!0,this.hV=U.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)},this.setByInteger=function(b){var v=new q(String(b),10);this.setByBigInteger(v)},this.setValueHex=function(b){this.hV=b},this.getFreshValueHex=function(){return this.hV},_!==void 0&&(_.bigint!==void 0?this.setByBigInteger(_.bigint):_.int!==void 0?this.setByInteger(_.int):typeof _=="number"?this.setByInteger(_):_.hex!==void 0&&this.setValueHex(_.hex))},Lt(U.asn1.DERInteger,U.asn1.ASN1Object),U.asn1.DERBitString=function(_){if(_!==void 0&&_.obj!==void 0){var b=U.asn1.ASN1Util.newObject(_.obj);_.hex="00"+b.getEncodedHex()}U.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(v){this.hTLV=null,this.isModified=!0,this.hV=v},this.setUnusedBitsAndHexValue=function(v,I){if(v<0||7<v)throw"unused bits shall be from 0 to 7: u = "+v;var k="0"+v;this.hTLV=null,this.isModified=!0,this.hV=k+I},this.setByBinaryString=function(v){var I=8-(v=v.replace(/0+$/,"")).length%8;I==8&&(I=0);for(var k=0;k<=I;k++)v+="0";var Q="";for(k=0;k<v.length-1;k+=8){var te=v.substr(k,8),we=parseInt(te,2).toString(16);we.length==1&&(we="0"+we),Q+=we}this.hTLV=null,this.isModified=!0,this.hV="0"+I+Q},this.setByBooleanArray=function(v){for(var I="",k=0;k<v.length;k++)v[k]==1?I+="1":I+="0";this.setByBinaryString(I)},this.newFalseArray=function(v){for(var I=new Array(v),k=0;k<v;k++)I[k]=!1;return I},this.getFreshValueHex=function(){return this.hV},_!==void 0&&(typeof _=="string"&&_.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(_):_.hex!==void 0?this.setHexValueIncludingUnusedBits(_.hex):_.bin!==void 0?this.setByBinaryString(_.bin):_.array!==void 0&&this.setByBooleanArray(_.array))},Lt(U.asn1.DERBitString,U.asn1.ASN1Object),U.asn1.DEROctetString=function(_){if(_!==void 0&&_.obj!==void 0){var b=U.asn1.ASN1Util.newObject(_.obj);_.hex=b.getEncodedHex()}U.asn1.DEROctetString.superclass.constructor.call(this,_),this.hT="04"},Lt(U.asn1.DEROctetString,U.asn1.DERAbstractString),U.asn1.DERNull=function(){U.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Lt(U.asn1.DERNull,U.asn1.ASN1Object),U.asn1.DERObjectIdentifier=function(_){U.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(b){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=b},this.setValueOidString=function(b){var v=(function(k){var Q=function(Ce){var Le=Ce.toString(16);return Le.length==1&&(Le="0"+Le),Le},te=function(Ce){var Le="",We=parseInt(Ce,10).toString(2),Xe=7-We.length%7;Xe==7&&(Xe=0);for(var et="",ne=0;ne<Xe;ne++)et+="0";for(We=et+We,ne=0;ne<We.length-1;ne+=7){var Se=We.substr(ne,7);ne!=We.length-7&&(Se="1"+Se),Le+=Q(parseInt(Se,2))}return Le};try{if(!k.match(/^[0-9.]+$/))return null;var we="",ge=k.split("."),be=40*parseInt(ge[0],10)+parseInt(ge[1],10);we+=Q(be),ge.splice(0,2);for(var _e=0;_e<ge.length;_e++)we+=te(ge[_e]);return we}catch{return null}})(b);if(v==null)throw new Error("malformed oid string: "+b);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=v},this.setValueName=function(b){var v=U.asn1.x509.OID.name2oid(b);if(v==="")throw new Error("DERObjectIdentifier oidName undefined: "+b);this.setValueOidString(v)},this.setValueNameOrOid=function(b){b.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(b):this.setValueName(b)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(b){typeof b=="string"?this.setValueNameOrOid(b):b.oid!==void 0?this.setValueNameOrOid(b.oid):b.name!==void 0?this.setValueNameOrOid(b.name):b.hex!==void 0&&this.setValueHex(b.hex)},_!==void 0&&this.setByParam(_)},Lt(U.asn1.DERObjectIdentifier,U.asn1.ASN1Object),U.asn1.DEREnumerated=function(_){U.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(b){this.hTLV=null,this.isModified=!0,this.hV=U.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)},this.setByInteger=function(b){var v=new q(String(b),10);this.setByBigInteger(v)},this.setValueHex=function(b){this.hV=b},this.getFreshValueHex=function(){return this.hV},_!==void 0&&(_.int!==void 0?this.setByInteger(_.int):typeof _=="number"?this.setByInteger(_):_.hex!==void 0&&this.setValueHex(_.hex))},Lt(U.asn1.DEREnumerated,U.asn1.ASN1Object),U.asn1.DERUTF8String=function(_){U.asn1.DERUTF8String.superclass.constructor.call(this,_),this.hT="0c"},Lt(U.asn1.DERUTF8String,U.asn1.DERAbstractString),U.asn1.DERNumericString=function(_){U.asn1.DERNumericString.superclass.constructor.call(this,_),this.hT="12"},Lt(U.asn1.DERNumericString,U.asn1.DERAbstractString),U.asn1.DERPrintableString=function(_){U.asn1.DERPrintableString.superclass.constructor.call(this,_),this.hT="13"},Lt(U.asn1.DERPrintableString,U.asn1.DERAbstractString),U.asn1.DERTeletexString=function(_){U.asn1.DERTeletexString.superclass.constructor.call(this,_),this.hT="14"},Lt(U.asn1.DERTeletexString,U.asn1.DERAbstractString),U.asn1.DERIA5String=function(_){U.asn1.DERIA5String.superclass.constructor.call(this,_),this.hT="16"},Lt(U.asn1.DERIA5String,U.asn1.DERAbstractString),U.asn1.DERVisibleString=function(_){U.asn1.DERIA5String.superclass.constructor.call(this,_),this.hT="1a"},Lt(U.asn1.DERVisibleString,U.asn1.DERAbstractString),U.asn1.DERBMPString=function(_){U.asn1.DERBMPString.superclass.constructor.call(this,_),this.hT="1e"},Lt(U.asn1.DERBMPString,U.asn1.DERAbstractString),U.asn1.DERUTCTime=function(_){U.asn1.DERUTCTime.superclass.constructor.call(this,_),this.hT="17",this.setByDate=function(b){this.hTLV=null,this.isModified=!0,this.date=b,this.s=this.formatDate(this.date,"utc"),this.hV=kt(this.s)},this.getFreshValueHex=function(){return this.date===void 0&&this.s===void 0&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=kt(this.s)),this.hV},_!==void 0&&(_.str!==void 0?this.setString(_.str):typeof _=="string"&&_.match(/^[0-9]{12}Z$/)?this.setString(_):_.hex!==void 0?this.setStringHex(_.hex):_.date!==void 0&&this.setByDate(_.date))},Lt(U.asn1.DERUTCTime,U.asn1.DERAbstractTime),U.asn1.DERGeneralizedTime=function(_){U.asn1.DERGeneralizedTime.superclass.constructor.call(this,_),this.hT="18",this.withMillis=!1,this.setByDate=function(b){this.hTLV=null,this.isModified=!0,this.date=b,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=kt(this.s)},this.getFreshValueHex=function(){return this.date===void 0&&this.s===void 0&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=kt(this.s)),this.hV},_!==void 0&&(_.str!==void 0?this.setString(_.str):typeof _=="string"&&_.match(/^[0-9]{14}Z$/)?this.setString(_):_.hex!==void 0?this.setStringHex(_.hex):_.date!==void 0&&this.setByDate(_.date),_.millis===!0&&(this.withMillis=!0))},Lt(U.asn1.DERGeneralizedTime,U.asn1.DERAbstractTime),U.asn1.DERSequence=function(_){U.asn1.DERSequence.superclass.constructor.call(this,_),this.hT="30",this.getFreshValueHex=function(){for(var b="",v=0;v<this.asn1Array.length;v++)b+=this.asn1Array[v].getEncodedHex();return this.hV=b,this.hV}},Lt(U.asn1.DERSequence,U.asn1.DERAbstractStructured),U.asn1.DERSet=function(_){U.asn1.DERSet.superclass.constructor.call(this,_),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var b=new Array,v=0;v<this.asn1Array.length;v++){var I=this.asn1Array[v];b.push(I.getEncodedHex())}return this.sortFlag==1&&b.sort(),this.hV=b.join(""),this.hV},_!==void 0&&_.sortflag!==void 0&&_.sortflag==0&&(this.sortFlag=!1)},Lt(U.asn1.DERSet,U.asn1.DERAbstractStructured),U.asn1.DERTaggedObject=function(_){U.asn1.DERTaggedObject.superclass.constructor.call(this);var b=U.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(v,I,k){this.hT=I,this.isExplicit=v,this.asn1Object=k,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=k.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,I),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(v){v.tag!=null&&(this.hT=v.tag),v.explicit!=null&&(this.isExplicit=v.explicit),v.tage!=null&&(this.hT=v.tage,this.isExplicit=!0),v.tagi!=null&&(this.hT=v.tagi,this.isExplicit=!1),v.obj!=null&&(v.obj instanceof b.ASN1Object?(this.asn1Object=v.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):A(v.obj)=="object"&&(this.asn1Object=b.ASN1Util.newObject(v.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},_!=null&&this.setByParam(_)},Lt(U.asn1.DERTaggedObject,U.asn1.ASN1Object);var U,Ie,Me,Pe=new function(){};function gt(_){for(var b=new Array,v=0;v<_.length;v++)b[v]=_.charCodeAt(v);return b}function _t(_){for(var b="",v=0;v<_.length;v++)b+=String.fromCharCode(_[v]);return b}function Tt(_){for(var b="",v=0;v<_.length;v++){var I=_[v].toString(16);I.length==1&&(I="0"+I),b+=I}return b}function kt(_){return Tt(gt(_))}function Ft(_){return _=(_=(_=_.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function sn(_){return _.length%4==2?_+="==":_.length%4==3&&(_+="="),_=(_=_.replace(/-/g,"+")).replace(/_/g,"/")}function Yt(_){return _.length%2==1&&(_="0"+_),Ft(z(_))}function Dt(_){return X(sn(_))}function vr(_){return Ht(qt(_))}function Bt(_){return decodeURIComponent(on(_))}function dr(_){for(var b="",v=0;v<_.length-1;v+=2)b+=String.fromCharCode(parseInt(_.substr(v,2),16));return b}function nr(_){for(var b="",v=0;v<_.length;v++)b+=("0"+_.charCodeAt(v).toString(16)).slice(-2);return b}function Vr(_){return z(_)}function M(_){var b=Vr(_).replace(/(.{64})/g,`$1\r
14
+ `);return b=b.replace(/\r\n$/,"")}function H(_){return X(_.replace(/[^0-9A-Za-z\/+=]*/g,""))}function Be(_,b){return"-----BEGIN "+b+`-----\r
15
+ `+M(_)+`\r
16
+ -----END `+b+`-----\r
17
+ `}function qe(_,b){if(_.indexOf("-----BEGIN ")==-1)throw"can't find PEM header: "+b;return H(_=b!==void 0?(_=_.replace(new RegExp("^[^]*-----BEGIN "+b+"-----"),"")).replace(new RegExp("-----END "+b+"-----[^]*$"),""):(_=_.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function at(_){var b,v,I,k,Q,te,we,ge,be,_e,Re;if(Re=_.match(/^(\d{2}|\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return ge=Re[1],b=parseInt(ge),ge.length===2&&(50<=b&&b<100?b=1900+b:0<=b&&b<50&&(b=2e3+b)),v=parseInt(Re[2])-1,I=parseInt(Re[3]),k=parseInt(Re[4]),Q=parseInt(Re[5]),te=parseInt(Re[6]),we=0,(be=Re[7])!==""&&(_e=(be.substr(1)+"00").substr(0,3),we=parseInt(_e)),Date.UTC(b,v,I,k,Q,te,we);throw"unsupported zulu format: "+_}function Ut(_){return~~(at(_)/1e3)}function Ht(_){return _.replace(/%/g,"")}function on(_){return _.replace(/(..)/g,"%$1")}function Sr(_){var b="malformed IPv6 address";if(!_.match(/^[0-9A-Fa-f:]+$/))throw b;var v=(_=_.toLowerCase()).split(":").length-1;if(v<2)throw b;var I=":".repeat(7-v+2),k=(_=_.replace("::",I)).split(":");if(k.length!=8)throw b;for(var Q=0;Q<8;Q++)k[Q]=("0000"+k[Q]).slice(-4);return k.join("")}function sr(_){if(!_.match(/^[0-9A-Fa-f]{32}$/))throw"malformed IPv6 address octet";for(var b=(_=_.toLowerCase()).match(/.{1,4}/g),v=0;v<8;v++)b[v]=b[v].replace(/^0+/,""),b[v]==""&&(b[v]="0");var I=(_=":"+b.join(":")+":").match(/:(0:){2,}/g);if(I===null)return _.slice(1,-1);var k="";for(v=0;v<I.length;v++)I[v].length>k.length&&(k=I[v]);return(_=_.replace(k,"::")).slice(1,-1)}function bn(_){var b="malformed hex value";if(!_.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw b;if(_.length!=8)return _.length==32?sr(_):_;try{return parseInt(_.substr(0,2),16)+"."+parseInt(_.substr(2,2),16)+"."+parseInt(_.substr(4,2),16)+"."+parseInt(_.substr(6,2),16)}catch{throw b}}function Hr(_){return _.match(/.{4}/g).map((function(v){var I=parseInt(v.substr(0,2),16),k=parseInt(v.substr(2),16);if(I==0&k<128)return String.fromCharCode(k);if(I<8){var Q=128|63&k;return Bt((192|(7&I)<<3|(192&k)>>6).toString(16)+Q.toString(16))}Q=128|(15&I)<<2|(192&k)>>6;var te=128|63&k;return Bt((224|(240&I)>>4).toString(16)+Q.toString(16)+te.toString(16))})).join("")}function qt(_){for(var b=encodeURIComponent(_),v="",I=0;I<b.length;I++)b[I]=="%"?(v+=b.substr(I,3),I+=2):v=v+"%"+kt(b[I]);return v}function fr(_){return!(_.length%2!=0||!_.match(/^[0-9a-f]+$/)&&!_.match(/^[0-9A-F]+$/))}function Dr(_){return _.length%2==1?"0"+_:_.substr(0,1)>"7"?"00"+_:_}Pe.getLblen=function(_,b){if(_.substr(b+2,1)!="8")return 1;var v=parseInt(_.substr(b+3,1));return v==0?-1:0<v&&v<10?v+1:-2},Pe.getL=function(_,b){var v=Pe.getLblen(_,b);return v<1?"":_.substr(b+2,2*v)},Pe.getVblen=function(_,b){var v;return(v=Pe.getL(_,b))==""?-1:(v.substr(0,1)==="8"?new q(v.substr(2),16):new q(v,16)).intValue()},Pe.getVidx=function(_,b){var v=Pe.getLblen(_,b);return v<0?v:b+2*(v+1)},Pe.getV=function(_,b){var v=Pe.getVidx(_,b),I=Pe.getVblen(_,b);return _.substr(v,2*I)},Pe.getTLV=function(_,b){return _.substr(b,2)+Pe.getL(_,b)+Pe.getV(_,b)},Pe.getTLVblen=function(_,b){return 2+2*Pe.getLblen(_,b)+2*Pe.getVblen(_,b)},Pe.getNextSiblingIdx=function(_,b){return Pe.getVidx(_,b)+2*Pe.getVblen(_,b)},Pe.getChildIdx=function(_,b){var v,I,k,Q=Pe,te=[];v=Q.getVidx(_,b),I=2*Q.getVblen(_,b),_.substr(b,2)=="03"&&(v+=2,I-=2),k=0;for(var we=v;k<=I;){var ge=Q.getTLVblen(_,we);if((k+=ge)<=I&&te.push(we),we+=ge,k>=I)break}return te},Pe.getNthChildIdx=function(_,b,v){return Pe.getChildIdx(_,b)[v]},Pe.getIdxbyList=function(_,b,v,I){var k,Q,te=Pe;return v.length==0?I!==void 0&&_.substr(b,2)!==I?-1:b:(k=v.shift())>=(Q=te.getChildIdx(_,b)).length?-1:te.getIdxbyList(_,Q[k],v,I)},Pe.getIdxbyListEx=function(_,b,v,I){var k,Q,te=Pe;if(v.length==0)return I!==void 0&&_.substr(b,2)!==I?-1:b;k=v.shift(),Q=te.getChildIdx(_,b);for(var we=0,ge=0;ge<Q.length;ge++){var be=_.substr(Q[ge],2);if(typeof k=="number"&&!te.isContextTag(be)&&we==k||typeof k=="string"&&te.isContextTag(be,k))return te.getIdxbyListEx(_,Q[ge],v,I);te.isContextTag(be)||we++}return-1},Pe.getTLVbyList=function(_,b,v,I){var k=Pe,Q=k.getIdxbyList(_,b,v,I);return Q==-1||Q>=_.length?null:k.getTLV(_,Q)},Pe.getTLVbyListEx=function(_,b,v,I){var k=Pe,Q=k.getIdxbyListEx(_,b,v,I);return Q==-1?null:k.getTLV(_,Q)},Pe.getVbyList=function(_,b,v,I,k){var Q,te,we=Pe;return(Q=we.getIdxbyList(_,b,v,I))==-1||Q>=_.length?null:(te=we.getV(_,Q),k===!0&&(te=te.substr(2)),te)},Pe.getVbyListEx=function(_,b,v,I,k){var Q,te,we=Pe;return(Q=we.getIdxbyListEx(_,b,v,I))==-1?null:(te=we.getV(_,Q),_.substr(Q,2)=="03"&&k!==!1&&(te=te.substr(2)),te)},Pe.getInt=function(_,b,v){v==null&&(v=-1);try{var I=_.substr(b,2);if(I!="02"&&I!="03")return v;var k=Pe.getV(_,b);return I=="02"?parseInt(k,16):(function(te){try{var we=te.substr(0,2);if(we=="00")return parseInt(te.substr(2),16);var ge=parseInt(we,16),be=te.substr(2),_e=parseInt(be,16).toString(2);return _e=="0"&&(_e="00000000"),_e=_e.slice(0,0-ge),parseInt(_e,2)}catch{return-1}})(k)}catch{return v}},Pe.getOID=function(_,b,v){v==null&&(v=null);try{return _.substr(b,2)!="06"?v:(function(k){if(!fr(k))return null;try{var Q=[],te=k.substr(0,2),we=parseInt(te,16);Q[0]=new String(Math.floor(we/40)),Q[1]=new String(we%40);for(var ge=k.substr(2),be=[],_e=0;_e<ge.length/2;_e++)be.push(parseInt(ge.substr(2*_e,2),16));var Re=[],Ce="";for(_e=0;_e<be.length;_e++)128&be[_e]?Ce+=Mr((127&be[_e]).toString(2),7):(Ce+=Mr((127&be[_e]).toString(2),7),Re.push(new String(parseInt(Ce,2))),Ce="");var Le=Q.join(".");return Re.length>0&&(Le=Le+"."+Re.join(".")),Le}catch{return null}})(Pe.getV(_,b))}catch{return v}},Pe.getOIDName=function(_,b,v){v==null&&(v=null);try{var I=Pe.getOID(_,b,v);if(I==v)return v;var k=U.asn1.x509.OID.oid2name(I);return k==""?I:k}catch{return v}},Pe.getString=function(_,b,v){v==null&&(v=null);try{return dr(Pe.getV(_,b))}catch{return v}},Pe.hextooidstr=function(_){var b=function(Ce,Le){return Ce.length>=Le?Ce:new Array(Le-Ce.length+1).join("0")+Ce},v=[],I=_.substr(0,2),k=parseInt(I,16);v[0]=new String(Math.floor(k/40)),v[1]=new String(k%40);for(var Q=_.substr(2),te=[],we=0;we<Q.length/2;we++)te.push(parseInt(Q.substr(2*we,2),16));var ge=[],be="";for(we=0;we<te.length;we++)128&te[we]?be+=b((127&te[we]).toString(2),7):(be+=b((127&te[we]).toString(2),7),ge.push(new String(parseInt(be,2))),be="");var _e=v.join(".");return ge.length>0&&(_e=_e+"."+ge.join(".")),_e},Pe.dump=function(_,b,v,I){var k=Pe,Q=k.getV,te=k.dump,we=k.getChildIdx,ge=_;_ instanceof U.asn1.ASN1Object&&(ge=_.getEncodedHex());var be=function(ht,Ct){return ht.length<=2*Ct?ht:ht.substr(0,Ct)+"..(total "+ht.length/2+"bytes).."+ht.substr(ht.length-Ct,Ct)};b===void 0&&(b={ommit_long_octet:32}),v===void 0&&(v=0),I===void 0&&(I="");var _e,Re=b.ommit_long_octet;if((_e=ge.substr(v,2))=="01")return(Ce=Q(ge,v))=="00"?I+`BOOLEAN FALSE
18
+ `:I+`BOOLEAN TRUE
19
+ `;if(_e=="02")return I+"INTEGER "+be(Ce=Q(ge,v),Re)+`
20
+ `;if(_e=="03"){var Ce=Q(ge,v);if(k.isASN1HEX(Ce.substr(2))){var Le=I+`BITSTRING, encapsulates
21
+ `;return Le+=te(Ce.substr(2),b,0,I+" ")}return I+"BITSTRING "+be(Ce,Re)+`
22
+ `}if(_e=="04")return Ce=Q(ge,v),k.isASN1HEX(Ce)?(Le=I+`OCTETSTRING, encapsulates
23
+ `,Le+=te(Ce,b,0,I+" ")):I+"OCTETSTRING "+be(Ce,Re)+`
24
+ `;if(_e=="05")return I+`NULL
25
+ `;if(_e=="06"){var We=Q(ge,v),Xe=U.asn1.ASN1Util.oidHexToInt(We),et=U.asn1.x509.OID.oid2name(Xe),ne=Xe.replace(/\./g," ");return et!=""?I+"ObjectIdentifier "+et+" ("+ne+`)
26
+ `:I+"ObjectIdentifier ("+ne+`)
27
+ `}if(_e=="0a")return I+"ENUMERATED "+parseInt(Q(ge,v))+`
28
+ `;if(_e=="0c")return I+"UTF8String '"+Bt(Q(ge,v))+`'
29
+ `;if(_e=="13")return I+"PrintableString '"+Bt(Q(ge,v))+`'
30
+ `;if(_e=="14")return I+"TeletexString '"+Bt(Q(ge,v))+`'
31
+ `;if(_e=="16")return I+"IA5String '"+Bt(Q(ge,v))+`'
32
+ `;if(_e=="17")return I+"UTCTime "+Bt(Q(ge,v))+`
33
+ `;if(_e=="18")return I+"GeneralizedTime "+Bt(Q(ge,v))+`
34
+ `;if(_e=="1a")return I+"VisualString '"+Bt(Q(ge,v))+`'
35
+ `;if(_e=="1e")return I+"BMPString '"+Hr(Q(ge,v))+`'
36
+ `;if(_e=="30"){if(ge.substr(v,4)=="3000")return I+`SEQUENCE {}
37
+ `;Le=I+`SEQUENCE
38
+ `;var Se=b;if(((Qe=we(ge,v)).length==2||Qe.length==3)&&ge.substr(Qe[0],2)=="06"&&ge.substr(Qe[Qe.length-1],2)=="04"){et=k.oidname(Q(ge,Qe[0]));var Ae=JSON.parse(JSON.stringify(b));Ae.x509ExtName=et,Se=Ae}for(var Ne=0;Ne<Qe.length;Ne++)Le+=te(ge,Se,Qe[Ne],I+" ");return Le}if(_e=="31"){Le=I+`SET
39
+ `;var Qe=we(ge,v);for(Ne=0;Ne<Qe.length;Ne++)Le+=te(ge,b,Qe[Ne],I+" ");return Le}if((128&(_e=parseInt(_e,16)))!=0){var nt=31&_e;if((32&_e)!=0){for(Le=I+"["+nt+`]
40
+ `,Qe=we(ge,v),Ne=0;Ne<Qe.length;Ne++)Le+=te(ge,b,Qe[Ne],I+" ");return Le}if(Ce=Q(ge,v),Pe.isASN1HEX(Ce)){var Le=I+"["+nt+`]
41
+ `;return Le+=te(Ce,b,0,I+" ")}return(Ce.substr(0,8)=="68747470"||b.x509ExtName==="subjectAltName"&&nt==2)&&(Ce=Bt(Ce)),Le=I+"["+nt+"] "+Ce+`
42
+ `}return I+"UNKNOWN("+_e+") "+Q(ge,v)+`
43
+ `},Pe.isContextTag=function(_,b){var v,I;_=_.toLowerCase();try{v=parseInt(_,16)}catch{return-1}if(b===void 0)return(192&v)==128;try{return b.match(/^\[[0-9]+\]$/)!=null&&!((I=parseInt(b.substr(1,b.length-1),10))>31)&&(192&v)==128&&(31&v)==I}catch{return!1}},Pe.isASN1HEX=function(_){var b=Pe;if(_.length%2==1)return!1;var v=b.getVblen(_,0),I=_.substr(0,2),k=b.getL(_,0);return _.length-I.length-k.length==2*v},Pe.checkStrictDER=function(_,b,v,I,k){var Q=Pe;if(v===void 0){if(typeof _!="string")throw new Error("not hex string");if(_=_.toLowerCase(),!U.lang.String.isHex(_))throw new Error("not hex string");v=_.length,k=(I=_.length/2)<128?1:Math.ceil(I.toString(16))+1}if(Q.getL(_,b).length>2*k)throw new Error("L of TLV too long: idx="+b);var te=Q.getVblen(_,b);if(te>I)throw new Error("value of L too long than hex: idx="+b);var we=Q.getTLV(_,b),ge=we.length-2-Q.getL(_,b).length;if(ge!==2*te)throw new Error("V string length and L's value not the same:"+ge+"/"+2*te);if(b===0&&_.length!=we.length)throw new Error("total length and TLV length unmatch:"+_.length+"!="+we.length);var be=_.substr(b,2);if(be==="02"){var _e=Q.getVidx(_,b);if(_.substr(_e,2)=="00"&&_.charCodeAt(_e+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(be,16)){for(var Re=Q.getVblen(_,b),Ce=0,Le=Q.getChildIdx(_,b),We=0;We<Le.length;We++)Ce+=Q.getTLV(_,Le[We]).length,Q.checkStrictDER(_,Le[We],v,I,k);if(2*Re!=Ce)throw new Error("sum of children's TLV length and L unmatch: "+2*Re+"!="+Ce)}},Pe.oidname=function(_){var b=U.asn1;U.lang.String.isHex(_)&&(_=b.ASN1Util.oidHexToInt(_));var v=b.x509.OID.oid2name(_);return v===""&&(v=_),v},U!==void 0&&U||(n.KJUR=U={}),U.lang!==void 0&&U.lang||(U.lang={}),U.lang.String=function(){},typeof a=="function"?(n.utf8tob64u=Ie=function(b){return Ft(a.from(b,"utf8").toString("base64"))},n.b64utoutf8=Me=function(b){return a.from(sn(b),"base64").toString("utf8")}):(n.utf8tob64u=Ie=function(b){return Yt(Ht(qt(b)))},n.b64utoutf8=Me=function(b){return decodeURIComponent(on(Dt(b)))}),U.lang.String.isInteger=function(_){return!!_.match(/^[0-9]+$/)||!!_.match(/^-[0-9]+$/)},U.lang.String.isHex=function(_){return fr(_)},U.lang.String.isBase64=function(_){return!(!(_=_.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||_.length%4!=0)},U.lang.String.isBase64URL=function(_){return!_.match(/[+/=]/)&&(_=sn(_),U.lang.String.isBase64(_))},U.lang.String.isIntegerArray=function(_){return!!(_=_.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},U.lang.String.isPrintable=function(_){return _.match(/^[0-9A-Za-z '()+,-./:=?]*$/)!==null},U.lang.String.isIA5=function(_){return _.match(/^[\x20-\x21\x23-\x7f]*$/)!==null},U.lang.String.isMail=function(_){return _.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)!==null};var Mr=function(b,v,I){return I==null&&(I="0"),b.length>=v?b:new Array(v-b.length+1).join(I)+b};function Lt(_,b){var v=function(){};v.prototype=b.prototype,_.prototype=new v,_.prototype.constructor=_,_.superclass=b.prototype,b.prototype.constructor==Object.prototype.constructor&&(b.prototype.constructor=b)}U!==void 0&&U||(n.KJUR=U={}),U.crypto!==void 0&&U.crypto||(U.crypto={}),U.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:D.algo.MD5,sha1:D.algo.SHA1,sha224:D.algo.SHA224,sha256:D.algo.SHA256,sha384:D.algo.SHA384,sha512:D.algo.SHA512,ripemd160:D.algo.RIPEMD160},this.getDigestInfoHex=function(_,b){if(this.DIGESTINFOHEAD[b]===void 0)throw"alg not supported in Util.DIGESTINFOHEAD: "+b;return this.DIGESTINFOHEAD[b]+_},this.getPaddedDigestInfoHex=function(_,b,v){var I=this.getDigestInfoHex(_,b),k=v/4;if(I.length+22>k)throw"key is too short for SigAlg: keylen="+v+","+b;for(var Q="0001",te="00"+I,we="",ge=k-Q.length-te.length,be=0;be<ge;be+=2)we+="ff";return Q+we+te},this.hashString=function(_,b){return new U.crypto.MessageDigest({alg:b}).digestString(_)},this.hashHex=function(_,b){return new U.crypto.MessageDigest({alg:b}).digestHex(_)},this.sha1=function(_){return this.hashString(_,"sha1")},this.sha256=function(_){return this.hashString(_,"sha256")},this.sha256Hex=function(_){return this.hashHex(_,"sha256")},this.sha512=function(_){return this.hashString(_,"sha512")},this.sha512Hex=function(_){return this.hashHex(_,"sha512")},this.isKey=function(_){return _ instanceof Ge||_ instanceof U.crypto.DSA||_ instanceof U.crypto.ECDSA}},U.crypto.Util.md5=function(_){return new U.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(_)},U.crypto.Util.ripemd160=function(_){return new U.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(_)},U.crypto.Util.SECURERANDOMGEN=new de,U.crypto.Util.getRandomHexOfNbytes=function(_){var b=new Array(_);return U.crypto.Util.SECURERANDOMGEN.nextBytes(b),Tt(b)},U.crypto.Util.getRandomBigIntegerOfNbytes=function(_){return new q(U.crypto.Util.getRandomHexOfNbytes(_),16)},U.crypto.Util.getRandomHexOfNbits=function(_){var b=_%8,v=new Array((_-b)/8+1);return U.crypto.Util.SECURERANDOMGEN.nextBytes(v),v[0]=(255<<b&255^255)&v[0],Tt(v)},U.crypto.Util.getRandomBigIntegerOfNbits=function(_){return new q(U.crypto.Util.getRandomHexOfNbits(_),16)},U.crypto.Util.getRandomBigIntegerZeroToMax=function(_){for(var b=_.bitLength();;){var v=U.crypto.Util.getRandomBigIntegerOfNbits(b);if(_.compareTo(v)!=-1)return v}},U.crypto.Util.getRandomBigIntegerMinToMax=function(_,b){var v=_.compareTo(b);if(v==1)throw"biMin is greater than biMax";if(v==0)return _;var I=b.subtract(_);return U.crypto.Util.getRandomBigIntegerZeroToMax(I).add(_)},U.crypto.MessageDigest=function(_){this.setAlgAndProvider=function(b,v){if((b=U.crypto.MessageDigest.getCanonicalAlgName(b))!==null&&v===void 0&&(v=U.crypto.Util.DEFAULTPROVIDER[b]),":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(b)!=-1&&v=="cryptojs"){try{this.md=U.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[b].create()}catch(I){throw"setAlgAndProvider hash alg set fail alg="+b+"/"+I}this.updateString=function(I){this.md.update(I)},this.updateHex=function(I){var k=D.enc.Hex.parse(I);this.md.update(k)},this.digest=function(){return this.md.finalize().toString(D.enc.Hex)},this.digestString=function(I){return this.updateString(I),this.digest()},this.digestHex=function(I){return this.updateHex(I),this.digest()}}if(":sha256:".indexOf(b)!=-1&&v=="sjcl"){try{this.md=new sjcl.hash.sha256}catch(I){throw"setAlgAndProvider hash alg set fail alg="+b+"/"+I}this.updateString=function(I){this.md.update(I)},this.updateHex=function(I){var k=sjcl.codec.hex.toBits(I);this.md.update(k)},this.digest=function(){var I=this.md.finalize();return sjcl.codec.hex.fromBits(I)},this.digestString=function(I){return this.updateString(I),this.digest()},this.digestHex=function(I){return this.updateHex(I),this.digest()}}},this.updateString=function(b){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(b){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(b){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(b){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},_!==void 0&&_.alg!==void 0&&(this.algName=_.alg,_.prov===void 0&&(this.provName=U.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},U.crypto.MessageDigest.getCanonicalAlgName=function(_){return typeof _=="string"&&(_=(_=_.toLowerCase()).replace(/-/,"")),_},U.crypto.MessageDigest.getHashLength=function(_){var b=U.crypto.MessageDigest,v=b.getCanonicalAlgName(_);if(b.HASHLENGTH[v]===void 0)throw"not supported algorithm: "+_;return b.HASHLENGTH[v]},U.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},U.crypto.Mac=function(_){this.setAlgAndProvider=function(b,v){if((b=b.toLowerCase())==null&&(b="hmacsha1"),(b=b.toLowerCase()).substr(0,4)!="hmac")throw"setAlgAndProvider unsupported HMAC alg: "+b;v===void 0&&(v=U.crypto.Util.DEFAULTPROVIDER[b]),this.algProv=b+"/"+v;var I=b.substr(4);if(":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(I)!=-1&&v=="cryptojs"){try{var k=U.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[I];this.mac=D.algo.HMAC.create(k,this.pass)}catch(Q){throw"setAlgAndProvider hash alg set fail hashAlg="+I+"/"+Q}this.updateString=function(Q){this.mac.update(Q)},this.updateHex=function(Q){var te=D.enc.Hex.parse(Q);this.mac.update(te)},this.doFinal=function(){return this.mac.finalize().toString(D.enc.Hex)},this.doFinalString=function(Q){return this.updateString(Q),this.doFinal()},this.doFinalHex=function(Q){return this.updateHex(Q),this.doFinal()}}},this.updateString=function(b){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(b){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(b){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(b){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(b){if(typeof b=="string"){var v=b;return b.length%2!=1&&b.match(/^[0-9A-Fa-f]+$/)||(v=nr(b)),void(this.pass=D.enc.Hex.parse(v))}if((b===void 0?"undefined":A(b))!="object")throw"KJUR.crypto.Mac unsupported password type: "+b;if(v=null,b.hex!==void 0){if(b.hex.length%2!=0||!b.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+b.hex;v=b.hex}if(b.utf8!==void 0&&(v=vr(b.utf8)),b.rstr!==void 0&&(v=nr(b.rstr)),b.b64!==void 0&&(v=X(b.b64)),b.b64u!==void 0&&(v=Dt(b.b64u)),v==null)throw"KJUR.crypto.Mac unsupported password type: "+b;this.pass=D.enc.Hex.parse(v)},_!==void 0&&(_.pass!==void 0&&this.setPassword(_.pass),_.alg!==void 0&&(this.algName=_.alg,_.prov===void 0&&(this.provName=U.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},U.crypto.Signature=function(_){var b=null;if(this._setAlgNames=function(){var v=this.algName.match(/^(.+)with(.+)$/);v&&(this.mdAlgName=v[1].toLowerCase(),this.pubkeyAlgName=v[2].toLowerCase(),this.pubkeyAlgName=="rsaandmgf1"&&this.mdAlgName=="sha"&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(v,I){for(var k="",Q=I/4-v.length,te=0;te<Q;te++)k+="0";return k+v},this.setAlgAndProvider=function(v,I){if(this._setAlgNames(),I!="cryptojs/jsrsa")throw new Error("provider not supported: "+I);if(":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)!=-1){try{this.md=new U.crypto.MessageDigest({alg:this.mdAlgName})}catch(k){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+k)}this.init=function(k,Q){var te=null;try{te=Q===void 0?Rt.getKey(k):Rt.getKey(k,Q)}catch(we){throw"init failed:"+we}if(te.isPrivate===!0)this.prvKey=te,this.state="SIGN";else{if(te.isPublic!==!0)throw"init failed.:"+te;this.pubKey=te,this.state="VERIFY"}},this.updateString=function(k){this.md.updateString(k)},this.updateHex=function(k){this.md.updateHex(k)},this.sign=function(){if(this.sHashHex=this.md.digest(),this.prvKey===void 0&&this.ecprvhex!==void 0&&this.eccurvename!==void 0&&U.crypto.ECDSA!==void 0&&(this.prvKey=new U.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof Ge&&this.pubkeyAlgName==="rsaandmgf1")this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof Ge&&this.pubkeyAlgName==="rsa")this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof U.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof U.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(k){return this.updateString(k),this.sign()},this.signHex=function(k){return this.updateHex(k),this.sign()},this.verify=function(k){if(this.sHashHex=this.md.digest(),this.pubKey===void 0&&this.ecpubhex!==void 0&&this.eccurvename!==void 0&&U.crypto.ECDSA!==void 0&&(this.pubKey=new U.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof Ge&&this.pubkeyAlgName==="rsaandmgf1")return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,k,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof Ge&&this.pubkeyAlgName==="rsa")return this.pubKey.verifyWithMessageHash(this.sHashHex,k);if(U.crypto.ECDSA!==void 0&&this.pubKey instanceof U.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,k);if(U.crypto.DSA!==void 0&&this.pubKey instanceof U.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,k);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(v,I){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(v){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(v){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(v){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(v){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(v){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=_,_!==void 0&&(_.alg!==void 0&&(this.algName=_.alg,_.prov===void 0?this.provName=U.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=_.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),_.psssaltlen!==void 0&&(this.pssSaltLen=_.psssaltlen),_.prvkeypem!==void 0)){if(_.prvkeypas!==void 0)throw"both prvkeypem and prvkeypas parameters not supported";try{b=Rt.getKey(_.prvkeypem),this.init(b)}catch(v){throw"fatal error to load pem private key: "+v}}},U.crypto.Cipher=function(_){},U.crypto.Cipher.encrypt=function(_,b,v){if(b instanceof Ge&&b.isPublic){var I=U.crypto.Cipher.getAlgByKeyAndName(b,v);if(I==="RSA")return b.encrypt(_);if(I==="RSAOAEP")return b.encryptOAEP(_,"sha1");var k=I.match(/^RSAOAEP(\d+)$/);if(k!==null)return b.encryptOAEP(_,"sha"+k[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+v}throw"Cipher.encrypt: unsupported key or algorithm"},U.crypto.Cipher.decrypt=function(_,b,v){if(b instanceof Ge&&b.isPrivate){var I=U.crypto.Cipher.getAlgByKeyAndName(b,v);if(I==="RSA")return b.decrypt(_);if(I==="RSAOAEP")return b.decryptOAEP(_,"sha1");var k=I.match(/^RSAOAEP(\d+)$/);if(k!==null)return b.decryptOAEP(_,"sha"+k[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+v}throw"Cipher.decrypt: unsupported key or algorithm"},U.crypto.Cipher.getAlgByKeyAndName=function(_,b){if(_ instanceof Ge){if(":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(b)!=-1)return b;if(b==null)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+b}throw"getAlgByKeyAndName: not supported algorithm name: "+b},U.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040023":"secp521r1","2b81040022":"secp384r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},U!==void 0&&U||(n.KJUR=U={}),U.crypto!==void 0&&U.crypto||(U.crypto={}),U.crypto.ECDSA=function(_){var b=Error,v=q,I=Z,k=U.crypto.ECDSA,Q=U.crypto.ECParameterDB,te=k.getName,we=Pe,ge=we.getVbyListEx,be=we.isASN1HEX,_e=new de;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(Re){return new v(Re.bitLength(),_e).mod(Re.subtract(v.ONE)).add(v.ONE)},this.setNamedCurve=function(Re){this.ecparams=Q.getByName(Re),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=Re},this.setPrivateKeyHex=function(Re){this.isPrivate=!0,this.prvKeyHex=Re},this.setPublicKeyHex=function(Re){this.isPublic=!0,this.pubKeyHex=Re},this.getPublicKeyXYHex=function(){var Re=this.pubKeyHex;if(Re.substr(0,2)!=="04")throw"this method supports uncompressed format(04) only";var Ce=this.ecparams.keylen/4;if(Re.length!==2+2*Ce)throw"malformed public key hex length";var Le={};return Le.x=Re.substr(2,Ce),Le.y=Re.substr(2+Ce),Le},this.getShortNISTPCurveName=function(){var Re=this.curveName;return Re==="secp256r1"||Re==="NIST P-256"||Re==="P-256"||Re==="prime256v1"?"P-256":Re==="secp384r1"||Re==="NIST P-384"||Re==="P-384"?"P-384":null},this.generateKeyPairHex=function(){var Re=this.ecparams.n,Ce=this.getBigRandom(Re),Le=this.ecparams.G.multiply(Ce),We=Le.getX().toBigInteger(),Xe=Le.getY().toBigInteger(),et=this.ecparams.keylen/4,ne=("0000000000"+Ce.toString(16)).slice(-et),Se="04"+("0000000000"+We.toString(16)).slice(-et)+("0000000000"+Xe.toString(16)).slice(-et);return this.setPrivateKeyHex(ne),this.setPublicKeyHex(Se),{ecprvhex:ne,ecpubhex:Se}},this.signWithMessageHash=function(Re){return this.signHex(Re,this.prvKeyHex)},this.signHex=function(Re,Ce){var Le=new v(Ce,16),We=this.ecparams.n,Xe=new v(Re.substring(0,this.ecparams.keylen/4),16);do var et=this.getBigRandom(We),ne=this.ecparams.G.multiply(et).getX().toBigInteger().mod(We);while(ne.compareTo(v.ZERO)<=0);var Se=et.modInverse(We).multiply(Xe.add(Le.multiply(ne))).mod(We);return k.biRSSigToASN1Sig(ne,Se)},this.sign=function(Re,Ce){var Le=Ce,We=this.ecparams.n,Xe=v.fromByteArrayUnsigned(Re);do var et=this.getBigRandom(We),ne=this.ecparams.G.multiply(et).getX().toBigInteger().mod(We);while(ne.compareTo(q.ZERO)<=0);var Se=et.modInverse(We).multiply(Xe.add(Le.multiply(ne))).mod(We);return this.serializeSig(ne,Se)},this.verifyWithMessageHash=function(Re,Ce){return this.verifyHex(Re,Ce,this.pubKeyHex)},this.verifyHex=function(Re,Ce,Le){try{var We,Xe,et=k.parseSigHex(Ce);We=et.r,Xe=et.s;var ne=I.decodeFromHex(this.ecparams.curve,Le),Se=new v(Re.substring(0,this.ecparams.keylen/4),16);return this.verifyRaw(Se,We,Xe,ne)}catch{return!1}},this.verify=function(Re,Ce,Le){var We,Xe,et;if(Bitcoin.Util.isArray(Ce)){var ne=this.parseSig(Ce);We=ne.r,Xe=ne.s}else{if((Ce===void 0?"undefined":A(Ce))!=="object"||!Ce.r||!Ce.s)throw"Invalid value for signature";We=Ce.r,Xe=Ce.s}if(Le instanceof Z)et=Le;else{if(!Bitcoin.Util.isArray(Le))throw"Invalid format for pubkey value, must be byte array or ECPointFp";et=I.decodeFrom(this.ecparams.curve,Le)}var Se=v.fromByteArrayUnsigned(Re);return this.verifyRaw(Se,We,Xe,et)},this.verifyRaw=function(Re,Ce,Le,We){var Xe=this.ecparams.n,et=this.ecparams.G;if(Ce.compareTo(v.ONE)<0||Ce.compareTo(Xe)>=0||Le.compareTo(v.ONE)<0||Le.compareTo(Xe)>=0)return!1;var ne=Le.modInverse(Xe),Se=Re.multiply(ne).mod(Xe),Ae=Ce.multiply(ne).mod(Xe);return et.multiply(Se).add(We.multiply(Ae)).getX().toBigInteger().mod(Xe).equals(Ce)},this.serializeSig=function(Re,Ce){var Le=Re.toByteArraySigned(),We=Ce.toByteArraySigned(),Xe=[];return Xe.push(2),Xe.push(Le.length),(Xe=Xe.concat(Le)).push(2),Xe.push(We.length),(Xe=Xe.concat(We)).unshift(Xe.length),Xe.unshift(48),Xe},this.parseSig=function(Re){var Ce;if(Re[0]!=48)throw new Error("Signature not a valid DERSequence");if(Re[Ce=2]!=2)throw new Error("First element in signature must be a DERInteger");var Le=Re.slice(Ce+2,Ce+2+Re[Ce+1]);if(Re[Ce+=2+Re[Ce+1]]!=2)throw new Error("Second element in signature must be a DERInteger");var We=Re.slice(Ce+2,Ce+2+Re[Ce+1]);return Ce+=2+Re[Ce+1],{r:v.fromByteArrayUnsigned(Le),s:v.fromByteArrayUnsigned(We)}},this.parseSigCompact=function(Re){if(Re.length!==65)throw"Signature has the wrong length";var Ce=Re[0]-27;if(Ce<0||Ce>7)throw"Invalid signature type";var Le=this.ecparams.n;return{r:v.fromByteArrayUnsigned(Re.slice(1,33)).mod(Le),s:v.fromByteArrayUnsigned(Re.slice(33,65)).mod(Le),i:Ce}},this.readPKCS5PrvKeyHex=function(Re){if(be(Re)===!1)throw new Error("not ASN.1 hex string");var Ce,Le,We;try{Ce=ge(Re,0,["[0]",0],"06"),Le=ge(Re,0,[1],"04");try{We=ge(Re,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=te(Ce),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(We),this.setPrivateKeyHex(Le),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(Re){if(be(Re)===!1)throw new b("not ASN.1 hex string");var Ce,Le,We;try{ge(Re,0,[1,0],"06"),Ce=ge(Re,0,[1,1],"06"),Le=ge(Re,0,[2,0,1],"04");try{We=ge(Re,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new b("malformed PKCS#8 plain ECC private key")}if(this.curveName=te(Ce),this.curveName===void 0)throw new b("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(We),this.setPrivateKeyHex(Le),this.isPublic=!1},this.readPKCS8PubKeyHex=function(Re){if(be(Re)===!1)throw new b("not ASN.1 hex string");var Ce,Le;try{ge(Re,0,[0,0],"06"),Ce=ge(Re,0,[0,1],"06"),Le=ge(Re,0,[1],"03")}catch{throw new b("malformed PKCS#8 ECC public key")}if(this.curveName=te(Ce),this.curveName===null)throw new b("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(Le)},this.readCertPubKeyHex=function(Re,Ce){if(be(Re)===!1)throw new b("not ASN.1 hex string");var Le,We;try{Le=ge(Re,0,[0,5,0,1],"06"),We=ge(Re,0,[0,5,1],"03")}catch{throw new b("malformed X.509 certificate ECC public key")}if(this.curveName=te(Le),this.curveName===null)throw new b("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(We)},_!==void 0&&_.curve!==void 0&&(this.curveName=_.curve),this.curveName===void 0&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),_!==void 0&&(_.prv!==void 0&&this.setPrivateKeyHex(_.prv),_.pub!==void 0&&this.setPublicKeyHex(_.pub))},U.crypto.ECDSA.parseSigHex=function(_){var b=U.crypto.ECDSA.parseSigHexInHexRS(_);return{r:new q(b.r,16),s:new q(b.s,16)}},U.crypto.ECDSA.parseSigHexInHexRS=function(_){var b=Pe,v=b.getChildIdx,I=b.getV;if(b.checkStrictDER(_,0),_.substr(0,2)!="30")throw new Error("signature is not a ASN.1 sequence");var k=v(_,0);if(k.length!=2)throw new Error("signature shall have two elements");var Q=k[0],te=k[1];if(_.substr(Q,2)!="02")throw new Error("1st item not ASN.1 integer");if(_.substr(te,2)!="02")throw new Error("2nd item not ASN.1 integer");return{r:I(_,Q),s:I(_,te)}},U.crypto.ECDSA.asn1SigToConcatSig=function(_){var b=U.crypto.ECDSA.parseSigHexInHexRS(_),v=b.r,I=b.s;if(v.substr(0,2)=="00"&&v.length%32==2&&(v=v.substr(2)),I.substr(0,2)=="00"&&I.length%32==2&&(I=I.substr(2)),v.length%32==30&&(v="00"+v),I.length%32==30&&(I="00"+I),v.length%32!=0)throw"unknown ECDSA sig r length error";if(I.length%32!=0)throw"unknown ECDSA sig s length error";return v+I},U.crypto.ECDSA.concatSigToASN1Sig=function(_){if(_.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var b=_.substr(0,_.length/2),v=_.substr(_.length/2);return U.crypto.ECDSA.hexRSSigToASN1Sig(b,v)},U.crypto.ECDSA.hexRSSigToASN1Sig=function(_,b){var v=new q(_,16),I=new q(b,16);return U.crypto.ECDSA.biRSSigToASN1Sig(v,I)},U.crypto.ECDSA.biRSSigToASN1Sig=function(_,b){var v=U.asn1,I=new v.DERInteger({bigint:_}),k=new v.DERInteger({bigint:b});return new v.DERSequence({array:[I,k]}).getEncodedHex()},U.crypto.ECDSA.getName=function(_){return _==="2b8104001f"?"secp192k1":_==="2a8648ce3d030107"?"secp256r1":_==="2b8104000a"?"secp256k1":_==="2b81040021"?"secp224r1":_==="2b81040022"?"secp384r1":"|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(_)!==-1?"secp256r1":"|secp256k1|".indexOf(_)!==-1?"secp256k1":"|secp224r1|NIST P-224|P-224|".indexOf(_)!==-1?"secp224r1":"|secp384r1|NIST P-384|P-384|".indexOf(_)!==-1?"secp384r1":null},U!==void 0&&U||(n.KJUR=U={}),U.crypto!==void 0&&U.crypto||(U.crypto={}),U.crypto.ECParameterDB=new function(){var _={},b={};function v(I){return new q(I,16)}this.getByName=function(I){var k=I;if(b[k]!==void 0&&(k=b[I]),_[k]!==void 0)return _[k];throw"unregistered EC curve name: "+k},this.regist=function(I,k,Q,te,we,ge,be,_e,Re,Ce,Le,We){_[I]={};var Xe=v(Q),et=v(te),ne=v(we),Se=v(ge),Ae=v(be),Ne=new P(Xe,et,ne),Qe=Ne.decodePointHex("04"+_e+Re);_[I].name=I,_[I].keylen=k,_[I].curve=Ne,_[I].G=Qe,_[I].n=Se,_[I].h=Ae,_[I].oid=Le,_[I].info=We;for(var nt=0;nt<Ce.length;nt++)b[Ce[nt]]=I}},U.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),U.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),U.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),U.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),U.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),U.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),U.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),U.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),U.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),U.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]);var Rt=(function(){var _=function(be,_e,Re){return b(D.AES,be,_e,Re)},b=function(be,_e,Re,Ce){var Le=D.enc.Hex.parse(_e),We=D.enc.Hex.parse(Re),Xe=D.enc.Hex.parse(Ce),et={};et.key=We,et.iv=Xe,et.ciphertext=Le;var ne=be.decrypt(et,We,{iv:Xe});return D.enc.Hex.stringify(ne)},v=function(be,_e,Re){return I(D.AES,be,_e,Re)},I=function(be,_e,Re,Ce){var Le=D.enc.Hex.parse(_e),We=D.enc.Hex.parse(Re),Xe=D.enc.Hex.parse(Ce),et=be.encrypt(Le,We,{iv:Xe}),ne=D.enc.Hex.parse(et.toString());return D.enc.Base64.stringify(ne)},k={"AES-256-CBC":{proc:_,eproc:v,keylen:32,ivlen:16},"AES-192-CBC":{proc:_,eproc:v,keylen:24,ivlen:16},"AES-128-CBC":{proc:_,eproc:v,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(be,_e,Re){return b(D.TripleDES,be,_e,Re)},eproc:function(be,_e,Re){return I(D.TripleDES,be,_e,Re)},keylen:24,ivlen:8},"DES-CBC":{proc:function(be,_e,Re){return b(D.DES,be,_e,Re)},eproc:function(be,_e,Re){return I(D.DES,be,_e,Re)},keylen:8,ivlen:8}},Q=function(be){var _e={},Re=be.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));Re&&(_e.cipher=Re[1],_e.ivsalt=Re[2]);var Ce=be.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));Ce&&(_e.type=Ce[1]);var Le=-1,We=0;be.indexOf(`\r
44
+ \r
45
+ `)!=-1&&(Le=be.indexOf(`\r
46
+ \r
47
+ `),We=2),be.indexOf(`
48
+
49
+ `)!=-1&&(Le=be.indexOf(`
50
+
51
+ `),We=1);var Xe=be.indexOf("-----END");if(Le!=-1&&Xe!=-1){var et=be.substring(Le+2*We,Xe-We);et=et.replace(/\s+/g,""),_e.data=et}return _e},te=function(be,_e,Re){for(var Ce=Re.substring(0,16),Le=D.enc.Hex.parse(Ce),We=D.enc.Utf8.parse(_e),Xe=k[be].keylen+k[be].ivlen,et="",ne=null;;){var Se=D.algo.MD5.create();if(ne!=null&&Se.update(ne),Se.update(We),Se.update(Le),ne=Se.finalize(),(et+=D.enc.Hex.stringify(ne)).length>=2*Xe)break}var Ae={};return Ae.keyhex=et.substr(0,2*k[be].keylen),Ae.ivhex=et.substr(2*k[be].keylen,2*k[be].ivlen),Ae},we=function(be,_e,Re,Ce){var Le=D.enc.Base64.parse(be),We=D.enc.Hex.stringify(Le);return(0,k[_e].proc)(We,Re,Ce)};return{version:"1.0.0",parsePKCS5PEM:function(be){return Q(be)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(be,_e,Re){return te(be,_e,Re)},decryptKeyB64:function(be,_e,Re,Ce){return we(be,_e,Re,Ce)},getDecryptedKeyHex:function(be,_e){var Re=Q(be),Ce=(Re.type,Re.cipher),Le=Re.ivsalt,We=Re.data,Xe=te(Ce,_e,Le).keyhex;return we(We,Ce,Xe,Le)},getEncryptedPKCS5PEMFromPrvKeyHex:function(be,_e,Re,Ce,Le){var We="";if(Ce!==void 0&&Ce!=null||(Ce="AES-256-CBC"),k[Ce]===void 0)throw new Error("KEYUTIL unsupported algorithm: "+Ce);Le!==void 0&&Le!=null||(Le=(function(ne){var Se=D.lib.WordArray.random(ne);return D.enc.Hex.stringify(Se)})(k[Ce].ivlen).toUpperCase());var Xe=(function(ne,Se,Ae,Ne){return(0,k[Se].eproc)(ne,Ae,Ne)})(_e,Ce,te(Ce,Re,Le).keyhex,Le);return We="-----BEGIN "+be+` PRIVATE KEY-----\r
52
+ `,We+=`Proc-Type: 4,ENCRYPTED\r
53
+ `,We+="DEK-Info: "+Ce+","+Le+`\r
54
+ `,We+=`\r
55
+ `,We+=Xe.replace(/(.{64})/g,`$1\r
56
+ `),We+=`\r
57
+ -----END `+be+` PRIVATE KEY-----\r
58
+ `},parseHexOfEncryptedPKCS8:function(be){var _e=Pe,Re=_e.getChildIdx,Ce=_e.getV,Le={},We=Re(be,0);if(We.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+We.length);Le.ciphertext=Ce(be,We[1]);var Xe=Re(be,We[0]);if(Xe.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+Xe.length);if(Ce(be,Xe[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var et=Re(be,Xe[1]);if(Xe.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+et.length);var ne=Re(be,et[1]);if(ne.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+ne.length);if(Ce(be,ne[0])!="2a864886f70d0307")throw"this only supports TripleDES";Le.encryptionSchemeAlg="TripleDES",Le.encryptionSchemeIV=Ce(be,ne[1]);var Se=Re(be,et[0]);if(Se.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+Se.length);if(Ce(be,Se[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var Ae=Re(be,Se[1]);if(Ae.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+Ae.length);Le.pbkdf2Salt=Ce(be,Ae[0]);var Ne=Ce(be,Ae[1]);try{Le.pbkdf2Iter=parseInt(Ne,16)}catch{throw new Error("malformed format pbkdf2Iter: "+Ne)}return Le},getPBKDF2KeyHexFromParam:function(be,_e){var Re=D.enc.Hex.parse(be.pbkdf2Salt),Ce=be.pbkdf2Iter,Le=D.PBKDF2(_e,Re,{keySize:6,iterations:Ce});return D.enc.Hex.stringify(Le)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(be,_e){var Re=qe(be,"ENCRYPTED PRIVATE KEY"),Ce=this.parseHexOfEncryptedPKCS8(Re),Le=Rt.getPBKDF2KeyHexFromParam(Ce,_e),We={};We.ciphertext=D.enc.Hex.parse(Ce.ciphertext);var Xe=D.enc.Hex.parse(Le),et=D.enc.Hex.parse(Ce.encryptionSchemeIV),ne=D.TripleDES.decrypt(We,Xe,{iv:et});return D.enc.Hex.stringify(ne)},getKeyFromEncryptedPKCS8PEM:function(be,_e){var Re=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(be,_e);return this.getKeyFromPlainPrivatePKCS8Hex(Re)},parsePlainPrivatePKCS8Hex:function(be){var _e=Pe,Re=_e.getChildIdx,Ce=_e.getV,Le={algparam:null};if(be.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var We=Re(be,0);if(We.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(be.substr(We[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var Xe=Re(be,We[1]);if(Xe.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(be.substr(Xe[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(Le.algoid=Ce(be,Xe[0]),be.substr(Xe[1],2)=="06"&&(Le.algparam=Ce(be,Xe[1])),be.substr(We[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return Le.keyidx=_e.getVidx(be,We[2]),Le},getKeyFromPlainPrivatePKCS8PEM:function(be){var _e=qe(be,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(_e)},getKeyFromPlainPrivatePKCS8Hex:function(be){var _e,Re=this.parsePlainPrivatePKCS8Hex(be);if(Re.algoid=="2a864886f70d010101")_e=new Ge;else if(Re.algoid=="2a8648ce380401")_e=new U.crypto.DSA;else{if(Re.algoid!="2a8648ce3d0201")throw new Error("unsupported private key algorithm");_e=new U.crypto.ECDSA}return _e.readPKCS8PrvKeyHex(be),_e},_getKeyFromPublicPKCS8Hex:function(be){var _e,Re=Pe.getVbyList(be,0,[0,0],"06");if(Re==="2a864886f70d010101")_e=new Ge;else if(Re==="2a8648ce380401")_e=new U.crypto.DSA;else{if(Re!=="2a8648ce3d0201")throw new Error("unsupported PKCS#8 public key hex");_e=new U.crypto.ECDSA}return _e.readPKCS8PubKeyHex(be),_e},parsePublicRawRSAKeyHex:function(be){var _e=Pe,Re=_e.getChildIdx,Ce=_e.getV,Le={};if(be.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var We=Re(be,0);if(We.length!=2)throw new Error("malformed RSA key(code:002)");if(be.substr(We[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(Le.n=Ce(be,We[0]),be.substr(We[1],2)!="02")throw new Error("malformed RSA key(code:004)");return Le.e=Ce(be,We[1]),Le},parsePublicPKCS8Hex:function(be){var _e=Pe,Re=_e.getChildIdx,Ce=_e.getV,Le={algparam:null},We=Re(be,0);if(We.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+We.length);var Xe=We[0];if(be.substr(Xe,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var et=Re(be,Xe);if(et.length!=2)throw new Error("malformed PKCS8 public key(code:002)");if(be.substr(et[0],2)!="06")throw new Error("malformed PKCS8 public key(code:003)");if(Le.algoid=Ce(be,et[0]),be.substr(et[1],2)=="06"?Le.algparam=Ce(be,et[1]):be.substr(et[1],2)=="30"&&(Le.algparam={},Le.algparam.p=_e.getVbyList(be,et[1],[0],"02"),Le.algparam.q=_e.getVbyList(be,et[1],[1],"02"),Le.algparam.g=_e.getVbyList(be,et[1],[2],"02")),be.substr(We[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return Le.key=Ce(be,We[1]).substr(2),Le}}})();Rt.getKey=function(_,b,v){var I=(et=Pe).getChildIdx,k=(et.getV,et.getVbyList),Q=U.crypto,te=Q.ECDSA,we=Q.DSA,ge=Ge,be=qe,_e=Rt;if(ge!==void 0&&_ instanceof ge||te!==void 0&&_ instanceof te||we!==void 0&&_ instanceof we)return _;if(_.curve!==void 0&&_.xy!==void 0&&_.d===void 0)return new te({pub:_.xy,curve:_.curve});if(_.curve!==void 0&&_.d!==void 0)return new te({prv:_.d,curve:_.curve});if(_.kty===void 0&&_.n!==void 0&&_.e!==void 0&&_.d===void 0)return(wt=new ge).setPublic(_.n,_.e),wt;if(_.kty===void 0&&_.n!==void 0&&_.e!==void 0&&_.d!==void 0&&_.p!==void 0&&_.q!==void 0&&_.dp!==void 0&&_.dq!==void 0&&_.co!==void 0&&_.qi===void 0)return(wt=new ge).setPrivateEx(_.n,_.e,_.d,_.p,_.q,_.dp,_.dq,_.co),wt;if(_.kty===void 0&&_.n!==void 0&&_.e!==void 0&&_.d!==void 0&&_.p===void 0)return(wt=new ge).setPrivate(_.n,_.e,_.d),wt;if(_.p!==void 0&&_.q!==void 0&&_.g!==void 0&&_.y!==void 0&&_.x===void 0)return(wt=new we).setPublic(_.p,_.q,_.g,_.y),wt;if(_.p!==void 0&&_.q!==void 0&&_.g!==void 0&&_.y!==void 0&&_.x!==void 0)return(wt=new we).setPrivate(_.p,_.q,_.g,_.y,_.x),wt;if(_.kty==="RSA"&&_.n!==void 0&&_.e!==void 0&&_.d===void 0)return(wt=new ge).setPublic(Dt(_.n),Dt(_.e)),wt;if(_.kty==="RSA"&&_.n!==void 0&&_.e!==void 0&&_.d!==void 0&&_.p!==void 0&&_.q!==void 0&&_.dp!==void 0&&_.dq!==void 0&&_.qi!==void 0)return(wt=new ge).setPrivateEx(Dt(_.n),Dt(_.e),Dt(_.d),Dt(_.p),Dt(_.q),Dt(_.dp),Dt(_.dq),Dt(_.qi)),wt;if(_.kty==="RSA"&&_.n!==void 0&&_.e!==void 0&&_.d!==void 0)return(wt=new ge).setPrivate(Dt(_.n),Dt(_.e),Dt(_.d)),wt;if(_.kty==="EC"&&_.crv!==void 0&&_.x!==void 0&&_.y!==void 0&&_.d===void 0){var Re=(yt=new te({curve:_.crv})).ecparams.keylen/4,Ce="04"+("0000000000"+Dt(_.x)).slice(-Re)+("0000000000"+Dt(_.y)).slice(-Re);return yt.setPublicKeyHex(Ce),yt}if(_.kty==="EC"&&_.crv!==void 0&&_.x!==void 0&&_.y!==void 0&&_.d!==void 0){Re=(yt=new te({curve:_.crv})).ecparams.keylen/4,Ce="04"+("0000000000"+Dt(_.x)).slice(-Re)+("0000000000"+Dt(_.y)).slice(-Re);var Le=("0000000000"+Dt(_.d)).slice(-Re);return yt.setPublicKeyHex(Ce),yt.setPrivateKeyHex(Le),yt}if(v==="pkcs5prv"){var We,Xe=_,et=Pe;if((We=I(Xe,0)).length===9)(wt=new ge).readPKCS5PrvKeyHex(Xe);else if(We.length===6)(wt=new we).readPKCS5PrvKeyHex(Xe);else{if(!(We.length>2&&Xe.substr(We[1],2)==="04"))throw new Error("unsupported PKCS#1/5 hexadecimal key");(wt=new te).readPKCS5PrvKeyHex(Xe)}return wt}if(v==="pkcs8prv")return wt=_e.getKeyFromPlainPrivatePKCS8Hex(_);if(v==="pkcs8pub")return _e._getKeyFromPublicPKCS8Hex(_);if(v==="x509pub")return or.getPublicKeyFromCertHex(_);if(_.indexOf("-END CERTIFICATE-",0)!=-1||_.indexOf("-END X509 CERTIFICATE-",0)!=-1||_.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return or.getPublicKeyFromCertPEM(_);if(_.indexOf("-END PUBLIC KEY-")!=-1){var ne=qe(_,"PUBLIC KEY");return _e._getKeyFromPublicPKCS8Hex(ne)}if(_.indexOf("-END RSA PRIVATE KEY-")!=-1&&_.indexOf("4,ENCRYPTED")==-1){var Se=be(_,"RSA PRIVATE KEY");return _e.getKey(Se,null,"pkcs5prv")}if(_.indexOf("-END DSA PRIVATE KEY-")!=-1&&_.indexOf("4,ENCRYPTED")==-1){var Ae=k(Mt=be(_,"DSA PRIVATE KEY"),0,[1],"02"),Ne=k(Mt,0,[2],"02"),Qe=k(Mt,0,[3],"02"),nt=k(Mt,0,[4],"02"),bt=k(Mt,0,[5],"02");return(wt=new we).setPrivate(new q(Ae,16),new q(Ne,16),new q(Qe,16),new q(nt,16),new q(bt,16)),wt}if(_.indexOf("-END EC PRIVATE KEY-")!=-1&&_.indexOf("4,ENCRYPTED")==-1)return Se=be(_,"EC PRIVATE KEY"),_e.getKey(Se,null,"pkcs5prv");if(_.indexOf("-END PRIVATE KEY-")!=-1)return _e.getKeyFromPlainPrivatePKCS8PEM(_);if(_.indexOf("-END RSA PRIVATE KEY-")!=-1&&_.indexOf("4,ENCRYPTED")!=-1){var ht=_e.getDecryptedKeyHex(_,b),Ct=new Ge;return Ct.readPKCS5PrvKeyHex(ht),Ct}if(_.indexOf("-END EC PRIVATE KEY-")!=-1&&_.indexOf("4,ENCRYPTED")!=-1){var yt,wt=k(Mt=_e.getDecryptedKeyHex(_,b),0,[1],"04"),Jt=k(Mt,0,[2,0],"06"),Qt=k(Mt,0,[3,0],"03").substr(2);if(U.crypto.OID.oidhex2name[Jt]===void 0)throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+Jt);return(yt=new te({curve:U.crypto.OID.oidhex2name[Jt]})).setPublicKeyHex(Qt),yt.setPrivateKeyHex(wt),yt.isPublic=!1,yt}if(_.indexOf("-END DSA PRIVATE KEY-")!=-1&&_.indexOf("4,ENCRYPTED")!=-1){var Mt;return Ae=k(Mt=_e.getDecryptedKeyHex(_,b),0,[1],"02"),Ne=k(Mt,0,[2],"02"),Qe=k(Mt,0,[3],"02"),nt=k(Mt,0,[4],"02"),bt=k(Mt,0,[5],"02"),(wt=new we).setPrivate(new q(Ae,16),new q(Ne,16),new q(Qe,16),new q(nt,16),new q(bt,16)),wt}if(_.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return _e.getKeyFromEncryptedPKCS8PEM(_,b);throw new Error("not supported argument")},Rt.generateKeypair=function(_,b){if(_=="RSA"){var v=b;(te=new Ge).generate(v,"10001"),te.isPrivate=!0,te.isPublic=!0;var I=new Ge,k=te.n.toString(16),Q=te.e.toString(16);return I.setPublic(k,Q),I.isPrivate=!1,I.isPublic=!0,(we={}).prvKeyObj=te,we.pubKeyObj=I,we}if(_=="EC"){var te,we,ge=b,be=new U.crypto.ECDSA({curve:ge}).generateKeyPairHex();return(te=new U.crypto.ECDSA({curve:ge})).setPublicKeyHex(be.ecpubhex),te.setPrivateKeyHex(be.ecprvhex),te.isPrivate=!0,te.isPublic=!1,(I=new U.crypto.ECDSA({curve:ge})).setPublicKeyHex(be.ecpubhex),I.isPrivate=!1,I.isPublic=!0,(we={}).prvKeyObj=te,we.pubKeyObj=I,we}throw new Error("unknown algorithm: "+_)},Rt.getPEM=function(_,b,v,I,k,Q){var te=U,we=te.asn1,ge=we.DERObjectIdentifier,be=we.DERInteger,_e=we.ASN1Util.newObject,Re=we.x509.SubjectPublicKeyInfo,Ce=te.crypto,Le=Ce.DSA,We=Ce.ECDSA,Xe=Ge;function et(yt){return _e({seq:[{int:0},{int:{bigint:yt.n}},{int:yt.e},{int:{bigint:yt.d}},{int:{bigint:yt.p}},{int:{bigint:yt.q}},{int:{bigint:yt.dmp1}},{int:{bigint:yt.dmq1}},{int:{bigint:yt.coeff}}]})}function ne(yt){return _e({seq:[{int:1},{octstr:{hex:yt.prvKeyHex}},{tag:["a0",!0,{oid:{name:yt.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+yt.pubKeyHex}}]}]})}function Se(yt){return _e({seq:[{int:0},{int:{bigint:yt.p}},{int:{bigint:yt.q}},{int:{bigint:yt.g}},{int:{bigint:yt.y}},{int:{bigint:yt.x}}]})}if((Xe!==void 0&&_ instanceof Xe||Le!==void 0&&_ instanceof Le||We!==void 0&&_ instanceof We)&&_.isPublic==1&&(b===void 0||b=="PKCS8PUB"))return Be(nt=new Re(_).getEncodedHex(),"PUBLIC KEY");if(b=="PKCS1PRV"&&Xe!==void 0&&_ instanceof Xe&&(v===void 0||v==null)&&_.isPrivate==1)return Be(nt=et(_).getEncodedHex(),"RSA PRIVATE KEY");if(b=="PKCS1PRV"&&We!==void 0&&_ instanceof We&&(v===void 0||v==null)&&_.isPrivate==1){var Ae=new ge({name:_.curveName}).getEncodedHex(),Ne=ne(_).getEncodedHex(),Qe="";return Qe+=Be(Ae,"EC PARAMETERS"),Qe+=Be(Ne,"EC PRIVATE KEY")}if(b=="PKCS1PRV"&&Le!==void 0&&_ instanceof Le&&(v===void 0||v==null)&&_.isPrivate==1)return Be(nt=Se(_).getEncodedHex(),"DSA PRIVATE KEY");if(b=="PKCS5PRV"&&Xe!==void 0&&_ instanceof Xe&&v!==void 0&&v!=null&&_.isPrivate==1){var nt=et(_).getEncodedHex();return I===void 0&&(I="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",nt,v,I,Q)}if(b=="PKCS5PRV"&&We!==void 0&&_ instanceof We&&v!==void 0&&v!=null&&_.isPrivate==1)return nt=ne(_).getEncodedHex(),I===void 0&&(I="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",nt,v,I,Q);if(b=="PKCS5PRV"&&Le!==void 0&&_ instanceof Le&&v!==void 0&&v!=null&&_.isPrivate==1)return nt=Se(_).getEncodedHex(),I===void 0&&(I="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",nt,v,I,Q);var bt=function(wt,Jt){var Qt=ht(wt,Jt);return new _e({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:Qt.pbkdf2Salt}},{int:Qt.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:Qt.encryptionSchemeIV}}]}]}]},{octstr:{hex:Qt.ciphertext}}]}).getEncodedHex()},ht=function(wt,Jt){var Qt=D.lib.WordArray.random(8),Mt=D.lib.WordArray.random(8),Ir=D.PBKDF2(Jt,Qt,{keySize:6,iterations:100}),Lr=D.enc.Hex.parse(wt),Ur=D.TripleDES.encrypt(Lr,Ir,{iv:Mt})+"",ar={};return ar.ciphertext=Ur,ar.pbkdf2Salt=D.enc.Hex.stringify(Qt),ar.pbkdf2Iter=100,ar.encryptionSchemeAlg="DES-EDE3-CBC",ar.encryptionSchemeIV=D.enc.Hex.stringify(Mt),ar};if(b=="PKCS8PRV"&&Xe!=null&&_ instanceof Xe&&_.isPrivate==1){var Ct=et(_).getEncodedHex();return nt=_e({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:Ct}}]}).getEncodedHex(),v===void 0||v==null?Be(nt,"PRIVATE KEY"):Be(Ne=bt(nt,v),"ENCRYPTED PRIVATE KEY")}if(b=="PKCS8PRV"&&We!==void 0&&_ instanceof We&&_.isPrivate==1)return Ct=new _e({seq:[{int:1},{octstr:{hex:_.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+_.pubKeyHex}}]}]}).getEncodedHex(),nt=_e({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:_.curveName}}]},{octstr:{hex:Ct}}]}).getEncodedHex(),v===void 0||v==null?Be(nt,"PRIVATE KEY"):Be(Ne=bt(nt,v),"ENCRYPTED PRIVATE KEY");if(b=="PKCS8PRV"&&Le!==void 0&&_ instanceof Le&&_.isPrivate==1)return Ct=new be({bigint:_.x}).getEncodedHex(),nt=_e({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:_.p}},{int:{bigint:_.q}},{int:{bigint:_.g}}]}]},{octstr:{hex:Ct}}]}).getEncodedHex(),v===void 0||v==null?Be(nt,"PRIVATE KEY"):Be(Ne=bt(nt,v),"ENCRYPTED PRIVATE KEY");throw new Error("unsupported object nor format")},Rt.getKeyFromCSRPEM=function(_){var b=qe(_,"CERTIFICATE REQUEST");return Rt.getKeyFromCSRHex(b)},Rt.getKeyFromCSRHex=function(_){var b=Rt.parseCSRHex(_);return Rt.getKey(b.p8pubkeyhex,null,"pkcs8pub")},Rt.parseCSRHex=function(_){var b=Pe,v=b.getChildIdx,I=b.getTLV,k={},Q=_;if(Q.substr(0,2)!="30")throw new Error("malformed CSR(code:001)");var te=v(Q,0);if(te.length<1)throw new Error("malformed CSR(code:002)");if(Q.substr(te[0],2)!="30")throw new Error("malformed CSR(code:003)");var we=v(Q,te[0]);if(we.length<3)throw new Error("malformed CSR(code:004)");return k.p8pubkeyhex=I(Q,we[2]),k},Rt.getKeyID=function(_){var b=Rt,v=Pe;typeof _=="string"&&_.indexOf("BEGIN ")!=-1&&(_=b.getKey(_));var I=qe(b.getPEM(_)),k=v.getIdxbyList(I,0,[1]),Q=v.getV(I,k).substring(2);return U.crypto.Util.hashHex(Q,"sha1")},Rt.getJWKFromKey=function(_){var b={};if(_ instanceof Ge&&_.isPrivate)return b.kty="RSA",b.n=Yt(_.n.toString(16)),b.e=Yt(_.e.toString(16)),b.d=Yt(_.d.toString(16)),b.p=Yt(_.p.toString(16)),b.q=Yt(_.q.toString(16)),b.dp=Yt(_.dmp1.toString(16)),b.dq=Yt(_.dmq1.toString(16)),b.qi=Yt(_.coeff.toString(16)),b;if(_ instanceof Ge&&_.isPublic)return b.kty="RSA",b.n=Yt(_.n.toString(16)),b.e=Yt(_.e.toString(16)),b;if(_ instanceof U.crypto.ECDSA&&_.isPrivate){if((I=_.getShortNISTPCurveName())!=="P-256"&&I!=="P-384")throw new Error("unsupported curve name for JWT: "+I);var v=_.getPublicKeyXYHex();return b.kty="EC",b.crv=I,b.x=Yt(v.x),b.y=Yt(v.y),b.d=Yt(_.prvKeyHex),b}if(_ instanceof U.crypto.ECDSA&&_.isPublic){var I;if((I=_.getShortNISTPCurveName())!=="P-256"&&I!=="P-384")throw new Error("unsupported curve name for JWT: "+I);return v=_.getPublicKeyXYHex(),b.kty="EC",b.crv=I,b.x=Yt(v.x),b.y=Yt(v.y),b}throw new Error("not supported key object")},Ge.getPosArrayOfChildrenFromHex=function(_){return Pe.getChildIdx(_,0)},Ge.getHexValueArrayOfChildrenFromHex=function(_){var b,v=Pe.getV,I=v(_,(b=Ge.getPosArrayOfChildrenFromHex(_))[0]),k=v(_,b[1]),Q=v(_,b[2]),te=v(_,b[3]),we=v(_,b[4]),ge=v(_,b[5]),be=v(_,b[6]),_e=v(_,b[7]),Re=v(_,b[8]);return(b=new Array).push(I,k,Q,te,we,ge,be,_e,Re),b},Ge.prototype.readPrivateKeyFromPEMString=function(_){var b=qe(_),v=Ge.getHexValueArrayOfChildrenFromHex(b);this.setPrivateEx(v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8])},Ge.prototype.readPKCS5PrvKeyHex=function(_){var b=Ge.getHexValueArrayOfChildrenFromHex(_);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])},Ge.prototype.readPKCS8PrvKeyHex=function(_){var b,v,I,k,Q,te,we,ge,be=Pe,_e=be.getVbyListEx;if(be.isASN1HEX(_)===!1)throw new Error("not ASN.1 hex string");try{b=_e(_,0,[2,0,1],"02"),v=_e(_,0,[2,0,2],"02"),I=_e(_,0,[2,0,3],"02"),k=_e(_,0,[2,0,4],"02"),Q=_e(_,0,[2,0,5],"02"),te=_e(_,0,[2,0,6],"02"),we=_e(_,0,[2,0,7],"02"),ge=_e(_,0,[2,0,8],"02")}catch{throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(b,v,I,k,Q,te,we,ge)},Ge.prototype.readPKCS5PubKeyHex=function(_){var b=Pe,v=b.getV;if(b.isASN1HEX(_)===!1)throw new Error("keyHex is not ASN.1 hex string");var I=b.getChildIdx(_,0);if(I.length!==2||_.substr(I[0],2)!=="02"||_.substr(I[1],2)!=="02")throw new Error("wrong hex for PKCS#5 public key");var k=v(_,I[0]),Q=v(_,I[1]);this.setPublic(k,Q)},Ge.prototype.readPKCS8PubKeyHex=function(_){var b=Pe;if(b.isASN1HEX(_)===!1)throw new Error("not ASN.1 hex string");if(b.getTLVbyListEx(_,0,[0,0])!=="06092a864886f70d010101")throw new Error("not PKCS8 RSA public key");var v=b.getTLVbyListEx(_,0,[1,0]);this.readPKCS5PubKeyHex(v)},Ge.prototype.readCertPubKeyHex=function(_,b){var v,I;(v=new or).readCertHex(_),I=v.getPublicKeyHex(),this.readPKCS8PubKeyHex(I)};function hr(_,b){for(var v="",I=b/4-_.length,k=0;k<I;k++)v+="0";return v+_}function oi(_,b,v){for(var I="",k=0;I.length<b;)I+=dr(v(nr(_+String.fromCharCode.apply(String,[(4278190080&k)>>24,(16711680&k)>>16,(65280&k)>>8,255&k])))),k+=1;return I}function br(_){for(var b in U.crypto.Util.DIGESTINFOHEAD){var v=U.crypto.Util.DIGESTINFOHEAD[b],I=v.length;if(_.substring(0,I)==v)return[b,_.substring(I)]}return[]}function or(_){var b,v=Pe,I=v.getChildIdx,k=v.getV,Q=v.getTLV,te=v.getVbyList,we=v.getVbyListEx,ge=v.getTLVbyList,be=v.getTLVbyListEx,_e=v.getIdxbyList,Re=v.getIdxbyListEx,Ce=v.getVidx,Le=v.getInt,We=v.oidname,Xe=v.hextooidstr,et=qe;try{b=U.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch{}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(this.hex===null||this.version!==0)return this.version;var ne=ge(this.hex,0,[0,0]);if(ne.substr(0,2)=="a0"){var Se=ge(ne,0,[0]),Ae=Le(Se,0);if(Ae<0||2<Ae)throw new Error("malformed version field");return this.version=Ae+1,this.version}return this.version=1,this.foffset=-1,1},this.getSerialNumberHex=function(){return we(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var ne=be(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(ne)},this.getAlgorithmIdentifierName=function(ne){for(var Se in b)if(ne===b[Se])return Se;return We(we(ne,0,[0],"06"))},this.getIssuer=function(){return this.getX500Name(this.getIssuerHex())},this.getIssuerHex=function(){return ge(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(){return this.getX500Name(this.getSubjectHex())},this.getSubjectHex=function(){return ge(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var ne=te(this.hex,0,[0,4+this.foffset,0]);return ne=ne.replace(/(..)/g,"%$1"),ne=decodeURIComponent(ne)},this.getNotAfter=function(){var ne=te(this.hex,0,[0,4+this.foffset,1]);return ne=ne.replace(/(..)/g,"%$1"),ne=decodeURIComponent(ne)},this.getPublicKeyHex=function(){return v.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return _e(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var ne=this.getPublicKeyIdx();return _e(this.hex,ne,[1,0],"30")},this.getPublicKey=function(){return Rt.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var ne=ge(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(ne)},this.getSignatureValueHex=function(){return te(this.hex,0,[2],"03",!0)},this.verifySignature=function(ne){var Se=this.getSignatureAlgorithmField(),Ae=this.getSignatureValueHex(),Ne=ge(this.hex,0,[0],"30"),Qe=new U.crypto.Signature({alg:Se});return Qe.init(ne),Qe.updateHex(Ne),Qe.verify(Ae)},this.parseExt=function(ne){var Se,Ae,Ne;if(ne===void 0){if(Ne=this.hex,this.version!==3)return-1;Se=_e(Ne,0,[0,7,0],"30"),Ae=I(Ne,Se)}else{Ne=qe(ne);var Qe=_e(Ne,0,[0,3,0,0],"06");if(k(Ne,Qe)!="2a864886f70d01090e")return void(this.aExtInfo=new Array);Se=_e(Ne,0,[0,3,0,1,0],"30"),Ae=I(Ne,Se),this.hex=Ne}this.aExtInfo=new Array;for(var nt=0;nt<Ae.length;nt++){var bt={critical:!1},ht=0;I(Ne,Ae[nt]).length===3&&(bt.critical=!0,ht=1),bt.oid=v.hextooidstr(te(Ne,Ae[nt],[0],"06"));var Ct=_e(Ne,Ae[nt],[1+ht]);bt.vidx=Ce(Ne,Ct),this.aExtInfo.push(bt)}},this.getExtInfo=function(ne){var Se=this.aExtInfo,Ae=ne;if(ne.match(/^[0-9.]+$/)||(Ae=U.asn1.x509.OID.name2oid(ne)),Ae!==""){for(var Ne=0;Ne<Se.length;Ne++)if(Se[Ne].oid===Ae)return Se[Ne]}},this.getExtBasicConstraints=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("basicConstraints");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"basicConstraints"};if(Se&&(Ne.critical=!0),ne==="3000")return Ne;if(ne==="30030101ff")return Ne.cA=!0,Ne;if(ne.substr(0,12)==="30060101ff02"){var Qe=k(ne,10),nt=parseInt(Qe,16);return Ne.cA=!0,Ne.pathLen=nt,Ne}throw new Error("hExtV parse error: "+ne)},this.getExtKeyUsage=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("keyUsage");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"keyUsage"};return Se&&(Ne.critical=!0),Ne.names=this.getExtKeyUsageString(ne).split(","),Ne},this.getExtKeyUsageBin=function(ne){if(ne===void 0){var Se=this.getExtInfo("keyUsage");if(Se===void 0)return"";ne=Q(this.hex,Se.vidx)}if(ne.length!=8&&ne.length!=10)throw new Error("malformed key usage value: "+ne);var Ae="000000000000000"+parseInt(ne.substr(6),16).toString(2);return ne.length==8&&(Ae=Ae.slice(-8)),ne.length==10&&(Ae=Ae.slice(-16)),(Ae=Ae.replace(/0+$/,""))==""&&(Ae="0"),Ae},this.getExtKeyUsageString=function(ne){for(var Se=this.getExtKeyUsageBin(ne),Ae=new Array,Ne=0;Ne<Se.length;Ne++)Se.substr(Ne,1)=="1"&&Ae.push(or.KEYUSAGE_NAME[Ne]);return Ae.join(",")},this.getExtSubjectKeyIdentifier=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("subjectKeyIdentifier");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"subjectKeyIdentifier"};Se&&(Ne.critical=!0);var Qe=k(ne,0);return Ne.kid={hex:Qe},Ne},this.getExtAuthorityKeyIdentifier=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("authorityKeyIdentifier");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"authorityKeyIdentifier"};Se&&(Ne.critical=!0);for(var Qe=I(ne,0),nt=0;nt<Qe.length;nt++){var bt=ne.substr(Qe[nt],2);if(bt==="80"&&(Ne.kid={hex:k(ne,Qe[nt])}),bt==="a1"){var ht=Q(ne,Qe[nt]),Ct=this.getGeneralNames(ht);Ne.issuer=Ct[0].dn}bt==="82"&&(Ne.sn={hex:k(ne,Qe[nt])})}return Ne},this.getExtExtKeyUsage=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("extKeyUsage");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"extKeyUsage",array:[]};Se&&(Ne.critical=!0);for(var Qe=I(ne,0),nt=0;nt<Qe.length;nt++)Ne.array.push(We(k(ne,Qe[nt])));return Ne},this.getExtExtKeyUsageName=function(){var ne=this.getExtInfo("extKeyUsage");if(ne===void 0)return ne;var Se=new Array,Ae=Q(this.hex,ne.vidx);if(Ae==="")return Se;for(var Ne=I(Ae,0),Qe=0;Qe<Ne.length;Qe++)Se.push(We(k(Ae,Ne[Qe])));return Se},this.getExtSubjectAltName=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("subjectAltName");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"subjectAltName",array:[]};return Se&&(Ne.critical=!0),Ne.array=this.getGeneralNames(ne),Ne},this.getExtIssuerAltName=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("issuerAltName");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"issuerAltName",array:[]};return Se&&(Ne.critical=!0),Ne.array=this.getGeneralNames(ne),Ne},this.getGeneralNames=function(ne){for(var Se=I(ne,0),Ae=[],Ne=0;Ne<Se.length;Ne++){var Qe=this.getGeneralName(Q(ne,Se[Ne]));Qe!==void 0&&Ae.push(Qe)}return Ae},this.getGeneralName=function(ne){var Se=ne.substr(0,2),Ae=k(ne,0),Ne=dr(Ae);return Se=="81"?{rfc822:Ne}:Se=="82"?{dns:Ne}:Se=="86"?{uri:Ne}:Se=="87"?{ip:bn(Ae)}:Se=="a4"?{dn:this.getX500Name(Ae)}:void 0},this.getExtSubjectAltName2=function(){var ne,Se,Ae,Ne=this.getExtInfo("subjectAltName");if(Ne===void 0)return Ne;for(var Qe=new Array,nt=Q(this.hex,Ne.vidx),bt=I(nt,0),ht=0;ht<bt.length;ht++)Ae=nt.substr(bt[ht],2),ne=k(nt,bt[ht]),Ae==="81"&&(Se=Bt(ne),Qe.push(["MAIL",Se])),Ae==="82"&&(Se=Bt(ne),Qe.push(["DNS",Se])),Ae==="84"&&(Se=or.hex2dn(ne,0),Qe.push(["DN",Se])),Ae==="86"&&(Se=Bt(ne),Qe.push(["URI",Se])),Ae==="87"&&(Se=bn(ne),Qe.push(["IP",Se]));return Qe},this.getExtCRLDistributionPoints=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("cRLDistributionPoints");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"cRLDistributionPoints",array:[]};Se&&(Ne.critical=!0);for(var Qe=I(ne,0),nt=0;nt<Qe.length;nt++){var bt=Q(ne,Qe[nt]);Ne.array.push(this.getDistributionPoint(bt))}return Ne},this.getDistributionPoint=function(ne){for(var Se={},Ae=I(ne,0),Ne=0;Ne<Ae.length;Ne++){var Qe=ne.substr(Ae[Ne],2),nt=Q(ne,Ae[Ne]);Qe=="a0"&&(Se.dpname=this.getDistributionPointName(nt))}return Se},this.getDistributionPointName=function(ne){for(var Se={},Ae=I(ne,0),Ne=0;Ne<Ae.length;Ne++){var Qe=ne.substr(Ae[Ne],2),nt=Q(ne,Ae[Ne]);Qe=="a0"&&(Se.full=this.getGeneralNames(nt))}return Se},this.getExtCRLDistributionPointsURI=function(){var ne=this.getExtInfo("cRLDistributionPoints");if(ne===void 0)return ne;for(var Se=new Array,Ae=I(this.hex,ne.vidx),Ne=0;Ne<Ae.length;Ne++)try{var Qe=Bt(te(this.hex,Ae[Ne],[0,0,0],"86"));Se.push(Qe)}catch{}return Se},this.getExtAIAInfo=function(){var ne=this.getExtInfo("authorityInfoAccess");if(ne===void 0)return ne;for(var Se={ocsp:[],caissuer:[]},Ae=I(this.hex,ne.vidx),Ne=0;Ne<Ae.length;Ne++){var Qe=te(this.hex,Ae[Ne],[0],"06"),nt=te(this.hex,Ae[Ne],[1],"86");Qe==="2b06010505073001"&&Se.ocsp.push(Bt(nt)),Qe==="2b06010505073002"&&Se.caissuer.push(Bt(nt))}return Se},this.getExtAuthorityInfoAccess=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("authorityInfoAccess");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"authorityInfoAccess",array:[]};Se&&(Ne.critical=!0);for(var Qe=I(ne,0),nt=0;nt<Qe.length;nt++){var bt=we(ne,Qe[nt],[0],"06"),ht=Bt(te(ne,Qe[nt],[1],"86"));if(bt=="2b06010505073001")Ne.array.push({ocsp:ht});else{if(bt!="2b06010505073002")throw new Error("unknown method: "+bt);Ne.array.push({caissuer:ht})}}return Ne},this.getExtCertificatePolicies=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("certificatePolicies");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"certificatePolicies",array:[]};Se&&(Ne.critical=!0);for(var Qe=I(ne,0),nt=0;nt<Qe.length;nt++){var bt=Q(ne,Qe[nt]),ht=this.getPolicyInformation(bt);Ne.array.push(ht)}return Ne},this.getPolicyInformation=function(ne){var Se={},Ae=te(ne,0,[0],"06");Se.policyoid=We(Ae);var Ne=Re(ne,0,[1],"30");if(Ne!=-1){Se.array=[];for(var Qe=I(ne,Ne),nt=0;nt<Qe.length;nt++){var bt=Q(ne,Qe[nt]),ht=this.getPolicyQualifierInfo(bt);Se.array.push(ht)}}return Se},this.getPolicyQualifierInfo=function(ne){var Se={},Ae=te(ne,0,[0],"06");if(Ae==="2b06010505070201"){var Ne=we(ne,0,[1],"16");Se.cps=dr(Ne)}else if(Ae==="2b06010505070202"){var Qe=ge(ne,0,[1],"30");Se.unotice=this.getUserNotice(Qe)}return Se},this.getUserNotice=function(ne){for(var Se={},Ae=I(ne,0),Ne=0;Ne<Ae.length;Ne++){var Qe=Q(ne,Ae[Ne]);Qe.substr(0,2)!="30"&&(Se.exptext=this.getDisplayText(Qe))}return Se},this.getDisplayText=function(ne){var Se={};return Se.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[ne.substr(0,2)],Se.str=dr(k(ne,0)),Se},this.getExtCRLNumber=function(ne,Se){var Ae={extname:"cRLNumber"};if(Se&&(Ae.critical=!0),ne.substr(0,2)=="02")return Ae.num={hex:k(ne,0)},Ae;throw new Error("hExtV parse error: "+ne)},this.getExtCRLReason=function(ne,Se){var Ae={extname:"cRLReason"};if(Se&&(Ae.critical=!0),ne.substr(0,2)=="0a")return Ae.code=parseInt(k(ne,0),16),Ae;throw new Error("hExtV parse error: "+ne)},this.getExtOcspNonce=function(ne,Se){var Ae={extname:"ocspNonce"};Se&&(Ae.critical=!0);var Ne=k(ne,0);return Ae.hex=Ne,Ae},this.getExtOcspNoCheck=function(ne,Se){var Ae={extname:"ocspNoCheck"};return Se&&(Ae.critical=!0),Ae},this.getExtAdobeTimeStamp=function(ne,Se){if(ne===void 0&&Se===void 0){var Ae=this.getExtInfo("adobeTimeStamp");if(Ae===void 0)return;ne=Q(this.hex,Ae.vidx),Se=Ae.critical}var Ne={extname:"adobeTimeStamp"};Se&&(Ne.critical=!0);var Qe=I(ne,0);if(Qe.length>1){var nt=Q(ne,Qe[1]),bt=this.getGeneralName(nt);bt.uri!=null&&(Ne.uri=bt.uri)}if(Qe.length>2){var ht=Q(ne,Qe[2]);ht=="0101ff"&&(Ne.reqauth=!0),ht=="010100"&&(Ne.reqauth=!1)}return Ne},this.getX500NameRule=function(ne){for(var Se=null,Ae=[],Ne=0;Ne<ne.length;Ne++)for(var Qe=ne[Ne],nt=0;nt<Qe.length;nt++)Ae.push(Qe[nt]);for(Ne=0;Ne<Ae.length;Ne++){var bt=Ae[Ne],ht=bt.ds,Ct=bt.value,yt=bt.type;if(ht!="prn"&&ht!="utf8"&&ht!="ia5")return"mixed";if(ht=="ia5"){if(yt!="CN")return"mixed";if(U.lang.String.isMail(Ct))continue;return"mixed"}if(yt=="C"){if(ht=="prn")continue;return"mixed"}if(Se==null)Se=ht;else if(Se!==ht)return"mixed"}return Se??"prn"},this.getX500Name=function(ne){var Se=this.getX500NameArray(ne);return{array:Se,str:this.dnarraytostr(Se)}},this.getX500NameArray=function(ne){for(var Se=[],Ae=I(ne,0),Ne=0;Ne<Ae.length;Ne++)Se.push(this.getRDN(Q(ne,Ae[Ne])));return Se},this.getRDN=function(ne){for(var Se=[],Ae=I(ne,0),Ne=0;Ne<Ae.length;Ne++)Se.push(this.getAttrTypeAndValue(Q(ne,Ae[Ne])));return Se},this.getAttrTypeAndValue=function(ne){var Se={type:null,value:null,ds:null},Ae=I(ne,0),Ne=te(ne,Ae[0],[],"06"),Qe=te(ne,Ae[1],[]),nt=U.asn1.ASN1Util.oidHexToInt(Ne);return Se.type=U.asn1.x509.OID.oid2atype(nt),Se.ds=this.HEX2STAG[ne.substr(Ae[1],2)],Se.ds!="bmp"?Se.value=Bt(Qe):Se.value=Hr(Qe),Se},this.readCertPEM=function(ne){this.readCertHex(et(ne))},this.readCertHex=function(ne){this.hex=ne,this.getVersion();try{_e(this.hex,0,[0,7],"a3"),this.parseExt()}catch{}},this.getParam=function(){var ne={};return ne.version=this.getVersion(),ne.serial={hex:this.getSerialNumberHex()},ne.sigalg=this.getSignatureAlgorithmField(),ne.issuer=this.getIssuer(),ne.notbefore=this.getNotBefore(),ne.notafter=this.getNotAfter(),ne.subject=this.getSubject(),ne.sbjpubkey=Be(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(ne.ext=this.getExtParamArray()),ne.sighex=this.getSignatureValueHex(),ne},this.getExtParamArray=function(ne){ne==null&&Re(this.hex,0,[0,"[3]"])!=-1&&(ne=be(this.hex,0,[0,"[3]",0],"30"));for(var Se=[],Ae=I(ne,0),Ne=0;Ne<Ae.length;Ne++){var Qe=Q(ne,Ae[Ne]),nt=this.getExtParam(Qe);nt!=null&&Se.push(nt)}return Se},this.getExtParam=function(ne){var Se=I(ne,0).length;if(Se!=2&&Se!=3)throw new Error("wrong number elements in Extension: "+Se+" "+ne);var Ae=Xe(te(ne,0,[0],"06")),Ne=!1;Se==3&&ge(ne,0,[1])=="0101ff"&&(Ne=!0);var Qe=ge(ne,0,[Se-1,0]),nt=void 0;if(Ae=="2.5.29.14"?nt=this.getExtSubjectKeyIdentifier(Qe,Ne):Ae=="2.5.29.15"?nt=this.getExtKeyUsage(Qe,Ne):Ae=="2.5.29.17"?nt=this.getExtSubjectAltName(Qe,Ne):Ae=="2.5.29.18"?nt=this.getExtIssuerAltName(Qe,Ne):Ae=="2.5.29.19"?nt=this.getExtBasicConstraints(Qe,Ne):Ae=="2.5.29.31"?nt=this.getExtCRLDistributionPoints(Qe,Ne):Ae=="2.5.29.32"?nt=this.getExtCertificatePolicies(Qe,Ne):Ae=="2.5.29.35"?nt=this.getExtAuthorityKeyIdentifier(Qe,Ne):Ae=="2.5.29.37"?nt=this.getExtExtKeyUsage(Qe,Ne):Ae=="1.3.6.1.5.5.7.1.1"?nt=this.getExtAuthorityInfoAccess(Qe,Ne):Ae=="2.5.29.20"?nt=this.getExtCRLNumber(Qe,Ne):Ae=="2.5.29.21"?nt=this.getExtCRLReason(Qe,Ne):Ae=="1.3.6.1.5.5.7.48.1.2"?nt=this.getExtOcspNonce(Qe,Ne):Ae=="1.3.6.1.5.5.7.48.1.5"?nt=this.getExtOcspNoCheck(Qe,Ne):Ae=="1.2.840.113583.1.1.9.1"&&(nt=this.getExtAdobeTimeStamp(Qe,Ne)),nt!=null)return nt;var bt={extname:Ae,extn:Qe};return Ne&&(bt.critical=!0),bt},this.findExt=function(ne,Se){for(var Ae=0;Ae<ne.length;Ae++)if(ne[Ae].extname==Se)return ne[Ae];return null},this.updateExtCDPFullURI=function(ne,Se){var Ae=this.findExt(ne,"cRLDistributionPoints");if(Ae!=null&&Ae.array!=null){for(var Ne=Ae.array,Qe=0;Qe<Ne.length;Qe++)if(Ne[Qe].dpname!=null&&Ne[Qe].dpname.full!=null)for(var nt=Ne[Qe].dpname.full,bt=0;bt<nt.length;bt++){var ht=nt[Qe];ht.uri!=null&&(ht.uri=Se)}}},this.updateExtAIAOCSP=function(ne,Se){var Ae=this.findExt(ne,"authorityInfoAccess");if(Ae!=null&&Ae.array!=null)for(var Ne=Ae.array,Qe=0;Qe<Ne.length;Qe++)Ne[Qe].ocsp!=null&&(Ne[Qe].ocsp=Se)},this.updateExtAIACAIssuer=function(ne,Se){var Ae=this.findExt(ne,"authorityInfoAccess");if(Ae!=null&&Ae.array!=null)for(var Ne=Ae.array,Qe=0;Qe<Ne.length;Qe++)Ne[Qe].caissuer!=null&&(Ne[Qe].caissuer=Se)},this.dnarraytostr=function(ne){return"/"+ne.map((function(Se){return(function(Ne){return Ne.map((function(Qe){return(function(bt){return bt.type+"="+bt.value})(Qe).replace(/\+/,"\\+")})).join("+")})(Se).replace(/\//,"\\/")})).join("/")},this.getInfo=function(){var ne,Se,Ae,Ne=function(Ir){return JSON.stringify(Ir.array).replace(/[\[\]\{\}\"]/g,"")},Qe=function(Ir){for(var Lr="",Ur=Ir.array,ar=0;ar<Ur.length;ar++){var Xt=Ur[ar];if(Lr+=" policy oid: "+Xt.policyoid+`
59
+ `,Xt.array!==void 0)for(var ir=0;ir<Xt.array.length;ir++){var Or=Xt.array[ir];Or.cps!==void 0&&(Lr+=" cps: "+Or.cps+`
60
+ `)}}return Lr},nt=function(Ir){for(var Lr="",Ur=Ir.array,ar=0;ar<Ur.length;ar++){var Xt=Ur[ar];try{Xt.dpname.full[0].uri!==void 0&&(Lr+=" "+Xt.dpname.full[0].uri+`
61
+ `)}catch{}try{Xt.dname.full[0].dn.hex!==void 0&&(Lr+=" "+or.hex2dn(Xt.dpname.full[0].dn.hex)+`
62
+ `)}catch{}}return Lr},bt=function(Ir){for(var Lr="",Ur=Ir.array,ar=0;ar<Ur.length;ar++){var Xt=Ur[ar];Xt.caissuer!==void 0&&(Lr+=" caissuer: "+Xt.caissuer+`
63
+ `),Xt.ocsp!==void 0&&(Lr+=" ocsp: "+Xt.ocsp+`
64
+ `)}return Lr};if(ne=`Basic Fields
65
+ `,ne+=" serial number: "+this.getSerialNumberHex()+`
66
+ `,ne+=" signature algorithm: "+this.getSignatureAlgorithmField()+`
67
+ `,ne+=" issuer: "+this.getIssuerString()+`
68
+ `,ne+=" notBefore: "+this.getNotBefore()+`
69
+ `,ne+=" notAfter: "+this.getNotAfter()+`
70
+ `,ne+=" subject: "+this.getSubjectString()+`
71
+ `,ne+=` subject public key info:
72
+ `,ne+=" key algorithm: "+(Se=this.getPublicKey()).type+`
73
+ `,Se.type==="RSA"&&(ne+=" n="+Dr(Se.n.toString(16)).substr(0,16)+`...
74
+ `,ne+=" e="+Dr(Se.e.toString(16))+`
75
+ `),(Ae=this.aExtInfo)!=null){ne+=`X509v3 Extensions:
76
+ `;for(var ht=0;ht<Ae.length;ht++){var Ct=Ae[ht],yt=U.asn1.x509.OID.oid2name(Ct.oid);yt===""&&(yt=Ct.oid);var wt="";if(Ct.critical===!0&&(wt="CRITICAL"),ne+=" "+yt+" "+wt+`:
77
+ `,yt==="basicConstraints"){var Jt=this.getExtBasicConstraints();Jt.cA===void 0?ne+=` {}
78
+ `:(ne+=" cA=true",Jt.pathLen!==void 0&&(ne+=", pathLen="+Jt.pathLen),ne+=`
79
+ `)}else if(yt==="keyUsage")ne+=" "+this.getExtKeyUsageString()+`
80
+ `;else if(yt==="subjectKeyIdentifier")ne+=" "+this.getExtSubjectKeyIdentifier().kid.hex+`
81
+ `;else if(yt==="authorityKeyIdentifier"){var Qt=this.getExtAuthorityKeyIdentifier();Qt.kid!==void 0&&(ne+=" kid="+Qt.kid.hex+`
82
+ `)}else yt==="extKeyUsage"?ne+=" "+this.getExtExtKeyUsage().array.join(", ")+`
83
+ `:yt==="subjectAltName"?ne+=" "+Ne(this.getExtSubjectAltName())+`
84
+ `:yt==="cRLDistributionPoints"?ne+=nt(this.getExtCRLDistributionPoints()):yt==="authorityInfoAccess"?ne+=bt(this.getExtAuthorityInfoAccess()):yt==="certificatePolicies"&&(ne+=Qe(this.getExtCertificatePolicies()))}}return ne+="signature algorithm: "+this.getSignatureAlgorithmName()+`
85
+ `,ne+="signature: "+this.getSignatureValueHex().substr(0,16)+`...
86
+ `},typeof _=="string"&&(_.indexOf("-----BEGIN")!=-1?this.readCertPEM(_):U.lang.String.isHex(_)&&this.readCertHex(_))}Ge.prototype.sign=function(_,b){var v=(function(k){return U.crypto.Util.hashString(k,b)})(_);return this.signWithMessageHash(v,b)},Ge.prototype.signWithMessageHash=function(_,b){var v=st(U.crypto.Util.getPaddedDigestInfoHex(_,b,this.n.bitLength()),16);return hr(this.doPrivate(v).toString(16),this.n.bitLength())},Ge.prototype.signPSS=function(_,b,v){var I=(function(Q){return U.crypto.Util.hashHex(Q,b)})(nr(_));return v===void 0&&(v=-1),this.signWithMessageHashPSS(I,b,v)},Ge.prototype.signWithMessageHashPSS=function(_,b,v){var I,k=dr(_),Q=k.length,te=this.n.bitLength()-1,we=Math.ceil(te/8),ge=function(ne){return U.crypto.Util.hashHex(ne,b)};if(v===-1||v===void 0)v=Q;else if(v===-2)v=we-Q-2;else if(v<-2)throw new Error("invalid salt length");if(we<Q+v+2)throw new Error("data too long");var be="";v>0&&(be=new Array(v),new de().nextBytes(be),be=String.fromCharCode.apply(String,be));var _e=dr(ge(nr("\0\0\0\0\0\0\0\0"+k+be))),Re=[];for(I=0;I<we-v-Q-2;I+=1)Re[I]=0;var Ce=String.fromCharCode.apply(String,Re)+""+be,Le=oi(_e,Ce.length,ge),We=[];for(I=0;I<Ce.length;I+=1)We[I]=Ce.charCodeAt(I)^Le.charCodeAt(I);var Xe=65280>>8*we-te&255;for(We[0]&=~Xe,I=0;I<Q;I++)We.push(_e.charCodeAt(I));return We.push(188),hr(this.doPrivate(new q(We)).toString(16),this.n.bitLength())},Ge.prototype.verify=function(_,b){if((b=b.toLowerCase()).match(/^[0-9a-f]+$/)==null)return!1;var v=st(b,16),I=this.n.bitLength();if(v.bitLength()>I)return!1;var k=this.doPublic(v).toString(16);if(k.length+3!=I/4)return!1;var Q=br(k.replace(/^1f+00/,""));if(Q.length==0)return!1;var te=Q[0];return Q[1]==(function(ge){return U.crypto.Util.hashString(ge,te)})(_)},Ge.prototype.verifyWithMessageHash=function(_,b){if(b.length!=Math.ceil(this.n.bitLength()/4))return!1;var v=st(b,16);if(v.bitLength()>this.n.bitLength())return 0;var I=br(this.doPublic(v).toString(16).replace(/^1f+00/,""));return I.length==0?!1:(I[0],I[1]==_)},Ge.prototype.verifyPSS=function(_,b,v,I){var k=(function(te){return U.crypto.Util.hashHex(te,v)})(nr(_));return I===void 0&&(I=-1),this.verifyWithMessageHashPSS(k,b,v,I)},Ge.prototype.verifyWithMessageHashPSS=function(_,b,v,I){if(b.length!=Math.ceil(this.n.bitLength()/4))return!1;var k,Q=new q(b,16),te=function(Ae){return U.crypto.Util.hashHex(Ae,v)},we=dr(_),ge=we.length,be=this.n.bitLength()-1,_e=Math.ceil(be/8);if(I===-1||I===void 0)I=ge;else if(I===-2)I=_e-ge-2;else if(I<-2)throw new Error("invalid salt length");if(_e<ge+I+2)throw new Error("data too long");var Re=this.doPublic(Q).toByteArray();for(k=0;k<Re.length;k+=1)Re[k]&=255;for(;Re.length<_e;)Re.unshift(0);if(Re[_e-1]!==188)throw new Error("encoded message does not end in 0xbc");var Ce=(Re=String.fromCharCode.apply(String,Re)).substr(0,_e-ge-1),Le=Re.substr(Ce.length,ge),We=65280>>8*_e-be&255;if((Ce.charCodeAt(0)&We)!=0)throw new Error("bits beyond keysize not zero");var Xe=oi(Le,Ce.length,te),et=[];for(k=0;k<Ce.length;k+=1)et[k]=Ce.charCodeAt(k)^Xe.charCodeAt(k);et[0]&=~We;var ne=_e-ge-I-2;for(k=0;k<ne;k+=1)if(et[k]!==0)throw new Error("leftmost octets not zero");if(et[ne]!==1)throw new Error("0x01 marker not found");return Le===dr(te(nr("\0\0\0\0\0\0\0\0"+we+String.fromCharCode.apply(String,et.slice(-I)))))},Ge.SALT_LEN_HLEN=-1,Ge.SALT_LEN_MAX=-2,Ge.SALT_LEN_RECOVER=-2,or.hex2dn=function(_,b){b===void 0&&(b=0);var v=new or;return Pe.getTLV(_,b),v.getX500Name(_).str},or.hex2rdn=function(_,b){if(b===void 0&&(b=0),_.substr(b,2)!=="31")throw new Error("malformed RDN");for(var v=new Array,I=Pe.getChildIdx(_,b),k=0;k<I.length;k++)v.push(or.hex2attrTypeValue(_,I[k]));return(v=v.map((function(Q){return Q.replace("+","\\+")}))).join("+")},or.hex2attrTypeValue=function(_,b){var v=Pe,I=v.getV;if(b===void 0&&(b=0),_.substr(b,2)!=="30")throw new Error("malformed attribute type and value");var k=v.getChildIdx(_,b);k.length!==2||_.substr(k[0],2);var Q=I(_,k[0]),te=U.asn1.ASN1Util.oidHexToInt(Q);return U.asn1.x509.OID.oid2atype(te)+"="+dr(I(_,k[1]))},or.getPublicKeyFromCertHex=function(_){var b=new or;return b.readCertHex(_),b.getPublicKey()},or.getPublicKeyFromCertPEM=function(_){var b=new or;return b.readCertPEM(_),b.getPublicKey()},or.getPublicKeyInfoPropOfCertPEM=function(_){var b,v,I=Pe.getVbyList,k={};return k.algparam=null,(b=new or).readCertPEM(_),v=b.getPublicKeyHex(),k.keyhex=I(v,0,[1],"03").substr(2),k.algoid=I(v,0,[0,0],"06"),k.algoid==="2a8648ce3d0201"&&(k.algparam=I(v,0,[0,1],"06")),k},or.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],U!==void 0&&U||(n.KJUR=U={}),U.jws!==void 0&&U.jws||(U.jws={}),U.jws.JWS=function(){var _=U.jws.JWS.isSafeJSONString;this.parseJWS=function(b,v){if(this.parsedJWS===void 0||!v&&this.parsedJWS.sigvalH===void 0){var I=b.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(I==null)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var k=I[1],Q=I[2],te=I[3],we=k+"."+Q;if(this.parsedJWS={},this.parsedJWS.headB64U=k,this.parsedJWS.payloadB64U=Q,this.parsedJWS.sigvalB64U=te,this.parsedJWS.si=we,!v){var ge=Dt(te),be=st(ge,16);this.parsedJWS.sigvalH=ge,this.parsedJWS.sigvalBI=be}var _e=Me(k),Re=Me(Q);if(this.parsedJWS.headS=_e,this.parsedJWS.payloadS=Re,!_(_e,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+_e}}},U.jws.JWS.sign=function(_,b,v,I,k){var Q,te,we,ge=U,be=ge.jws.JWS,_e=be.readSafeJSONString,Re=be.isSafeJSONString,Ce=ge.crypto,Le=(Ce.ECDSA,Ce.Mac),We=Ce.Signature,Xe=JSON;if(typeof b!="string"&&(b===void 0?"undefined":A(b))!="object")throw"spHeader must be JSON string or object: "+b;if((b===void 0?"undefined":A(b))=="object"&&(te=b,Q=Xe.stringify(te)),typeof b=="string"){if(!Re(Q=b))throw"JWS Head is not safe JSON string: "+Q;te=_e(Q)}if(we=v,(v===void 0?"undefined":A(v))=="object"&&(we=Xe.stringify(v)),_!=""&&_!=null||te.alg===void 0||(_=te.alg),_!=""&&_!=null&&te.alg===void 0&&(te.alg=_,Q=Xe.stringify(te)),_!==te.alg)throw"alg and sHeader.alg doesn't match: "+_+"!="+te.alg;var et=null;if(be.jwsalg2sigalg[_]===void 0)throw"unsupported alg name: "+_;et=be.jwsalg2sigalg[_];var ne=Ie(Q)+"."+Ie(we),Se="";if(et.substr(0,4)=="Hmac"){if(I===void 0)throw"mac key shall be specified for HS* alg";var Ae=new Le({alg:et,prov:"cryptojs",pass:I});Ae.updateString(ne),Se=Ae.doFinal()}else if(et.indexOf("withECDSA")!=-1){(Qe=new We({alg:et})).init(I,k),Qe.updateString(ne);var Ne=Qe.sign();Se=U.crypto.ECDSA.asn1SigToConcatSig(Ne)}else{var Qe;et!="none"&&((Qe=new We({alg:et})).init(I,k),Qe.updateString(ne),Se=Qe.sign())}return ne+"."+Yt(Se)},U.jws.JWS.verify=function(_,b,v){var I,k=U,Q=k.jws.JWS,te=Q.readSafeJSONString,we=k.crypto,ge=we.ECDSA,be=we.Mac,_e=we.Signature;A(Ge)!==void 0&&(I=Ge);var Re=_.split(".");if(Re.length!==3)return!1;var Ce=Re[0]+"."+Re[1],Le=Dt(Re[2]),We=te(Me(Re[0])),Xe=null,et=null;if(We.alg===void 0)throw"algorithm not specified in header";if(et=(Xe=We.alg).substr(0,2),v!=null&&Object.prototype.toString.call(v)==="[object Array]"&&v.length>0&&(":"+v.join(":")+":").indexOf(":"+Xe+":")==-1)throw"algorithm '"+Xe+"' not accepted in the list";if(Xe!="none"&&b===null)throw"key shall be specified to verify.";if(typeof b=="string"&&b.indexOf("-----BEGIN ")!=-1&&(b=Rt.getKey(b)),!(et!="RS"&&et!="PS"||b instanceof I))throw"key shall be a RSAKey obj for RS* and PS* algs";if(et=="ES"&&!(b instanceof ge))throw"key shall be a ECDSA obj for ES* algs";var ne=null;if(Q.jwsalg2sigalg[We.alg]===void 0)throw"unsupported alg name: "+Xe;if((ne=Q.jwsalg2sigalg[Xe])=="none")throw"not supported";if(ne.substr(0,4)=="Hmac"){if(b===void 0)throw"hexadecimal key shall be specified for HMAC";var Se=new be({alg:ne,pass:b});return Se.updateString(Ce),Le==Se.doFinal()}if(ne.indexOf("withECDSA")!=-1){var Ae,Ne=null;try{Ne=ge.concatSigToASN1Sig(Le)}catch{return!1}return(Ae=new _e({alg:ne})).init(b),Ae.updateString(Ce),Ae.verify(Ne)}return(Ae=new _e({alg:ne})).init(b),Ae.updateString(Ce),Ae.verify(Le)},U.jws.JWS.parse=function(_){var b,v,I,k=_.split("."),Q={};if(k.length!=2&&k.length!=3)throw"malformed sJWS: wrong number of '.' splitted elements";return b=k[0],v=k[1],k.length==3&&(I=k[2]),Q.headerObj=U.jws.JWS.readSafeJSONString(Me(b)),Q.payloadObj=U.jws.JWS.readSafeJSONString(Me(v)),Q.headerPP=JSON.stringify(Q.headerObj,null," "),Q.payloadObj==null?Q.payloadPP=Me(v):Q.payloadPP=JSON.stringify(Q.payloadObj,null," "),I!==void 0&&(Q.sigHex=Dt(I)),Q},U.jws.JWS.verifyJWT=function(_,b,v){var I=U.jws,k=I.JWS,Q=k.readSafeJSONString,te=k.inArray,we=k.includedArray,ge=_.split("."),be=ge[0],_e=ge[1],Re=(Dt(ge[2]),Q(Me(be))),Ce=Q(Me(_e));if(Re.alg===void 0)return!1;if(v.alg===void 0)throw"acceptField.alg shall be specified";if(!te(Re.alg,v.alg)||Ce.iss!==void 0&&A(v.iss)==="object"&&!te(Ce.iss,v.iss)||Ce.sub!==void 0&&A(v.sub)==="object"&&!te(Ce.sub,v.sub))return!1;if(Ce.aud!==void 0&&A(v.aud)==="object"){if(typeof Ce.aud=="string"){if(!te(Ce.aud,v.aud))return!1}else if(A(Ce.aud)=="object"&&!we(Ce.aud,v.aud))return!1}var Le=I.IntDate.getNow();return v.verifyAt!==void 0&&typeof v.verifyAt=="number"&&(Le=v.verifyAt),v.gracePeriod!==void 0&&typeof v.gracePeriod=="number"||(v.gracePeriod=0),!(Ce.exp!==void 0&&typeof Ce.exp=="number"&&Ce.exp+v.gracePeriod<Le)&&!(Ce.nbf!==void 0&&typeof Ce.nbf=="number"&&Le<Ce.nbf-v.gracePeriod)&&!(Ce.iat!==void 0&&typeof Ce.iat=="number"&&Le<Ce.iat-v.gracePeriod)&&(Ce.jti===void 0||v.jti===void 0||Ce.jti===v.jti)&&!!k.verify(_,b,v.alg)},U.jws.JWS.includedArray=function(_,b){var v=U.jws.JWS.inArray;if(_===null||(_===void 0?"undefined":A(_))!=="object"||typeof _.length!="number")return!1;for(var I=0;I<_.length;I++)if(!v(_[I],b))return!1;return!0},U.jws.JWS.inArray=function(_,b){if(b===null||(b===void 0?"undefined":A(b))!=="object"||typeof b.length!="number")return!1;for(var v=0;v<b.length;v++)if(b[v]==_)return!0;return!1},U.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},U.jws.JWS.isSafeJSONString=function(_,b,v){var I=null;try{return((I=B(_))===void 0?"undefined":A(I))!="object"||I.constructor===Array?0:(b&&(b[v]=I),1)}catch{return 0}},U.jws.JWS.readSafeJSONString=function(_){var b=null;try{return((b=B(_))===void 0?"undefined":A(b))!="object"||b.constructor===Array?null:b}catch{return null}},U.jws.JWS.getEncodedSignatureValueFromJWS=function(_){var b=_.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(b==null)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return b[1]},U.jws.JWS.getJWKthumbprint=function(_){if(_.kty!=="RSA"&&_.kty!=="EC"&&_.kty!=="oct")throw"unsupported algorithm for JWK Thumprint";var b="{";if(_.kty==="RSA"){if(typeof _.n!="string"||typeof _.e!="string")throw"wrong n and e value for RSA key";b+='"e":"'+_.e+'",',b+='"kty":"'+_.kty+'",',b+='"n":"'+_.n+'"}'}else if(_.kty==="EC"){if(typeof _.crv!="string"||typeof _.x!="string"||typeof _.y!="string")throw"wrong crv, x and y value for EC key";b+='"crv":"'+_.crv+'",',b+='"kty":"'+_.kty+'",',b+='"x":"'+_.x+'",',b+='"y":"'+_.y+'"}'}else if(_.kty==="oct"){if(typeof _.k!="string")throw"wrong k value for oct(symmetric) key";b+='"kty":"'+_.kty+'",',b+='"k":"'+_.k+'"}'}var v=nr(b);return Yt(U.crypto.Util.hashHex(v,"sha256"))},U.jws.IntDate={},U.jws.IntDate.get=function(_){var b=U.jws.IntDate,v=b.getNow,I=b.getZulu;if(_=="now")return v();if(_=="now + 1hour")return v()+3600;if(_=="now + 1day")return v()+86400;if(_=="now + 1month")return v()+2592e3;if(_=="now + 1year")return v()+31536e3;if(_.match(/Z$/))return I(_);if(_.match(/^[0-9]+$/))return parseInt(_);throw"unsupported format: "+_},U.jws.IntDate.getZulu=function(_){return Ut(_)},U.jws.IntDate.getNow=function(){return~~(new Date/1e3)},U.jws.IntDate.intDate2UTCString=function(_){return new Date(1e3*_).toUTCString()},U.jws.IntDate.intDate2Zulu=function(_){var b=new Date(1e3*_);return("0000"+b.getUTCFullYear()).slice(-4)+("00"+(b.getUTCMonth()+1)).slice(-2)+("00"+b.getUTCDate()).slice(-2)+("00"+b.getUTCHours()).slice(-2)+("00"+b.getUTCMinutes()).slice(-2)+("00"+b.getUTCSeconds()).slice(-2)+"Z"},n.SecureRandom=de,n.rng_seed_time=ee,n.BigInteger=q,n.RSAKey=Ge;var ai=U.crypto.EDSA;n.EDSA=ai;var Pr=U.crypto.DSA;n.DSA=Pr;var vn=U.crypto.Signature;n.Signature=vn;var Er=U.crypto.MessageDigest;n.MessageDigest=Er;var _i=U.crypto.Mac;n.Mac=_i;var wi=U.crypto.Cipher;n.Cipher=wi,n.KEYUTIL=Rt,n.ASN1HEX=Pe,n.X509=or,n.CryptoJS=D,n.b64tohex=X,n.b64toBA=Ee,n.stoBA=gt,n.BAtos=_t,n.BAtohex=Tt,n.stohex=kt,n.stob64=function(b){return z(kt(b))},n.stob64u=function(b){return Ft(z(kt(b)))},n.b64utos=function(b){return _t(Ee(sn(b)))},n.b64tob64u=Ft,n.b64utob64=sn,n.hex2b64=z,n.hextob64u=Yt,n.b64utohex=Dt,n.utf8tob64u=Ie,n.b64utoutf8=Me,n.utf8tob64=function(b){return z(Ht(qt(b)))},n.b64toutf8=function(b){return decodeURIComponent(on(X(b)))},n.utf8tohex=vr,n.hextoutf8=Bt,n.hextorstr=dr,n.rstrtohex=nr,n.hextob64=Vr,n.hextob64nl=M,n.b64nltohex=H,n.hextopem=Be,n.pemtohex=qe,n.hextoArrayBuffer=function(b){if(b.length%2!=0)throw"input is not even length";if(b.match(/^[0-9A-Fa-f]+$/)==null)throw"input is not hexadecimal";for(var v=new ArrayBuffer(b.length/2),I=new DataView(v),k=0;k<b.length/2;k++)I.setUint8(k,parseInt(b.substr(2*k,2),16));return v},n.ArrayBuffertohex=function(b){for(var v="",I=new DataView(b),k=0;k<b.byteLength;k++)v+=("00"+I.getUint8(k).toString(16)).slice(-2);return v},n.zulutomsec=at,n.zulutosec=Ut,n.zulutodate=function(b){return new Date(at(b))},n.datetozulu=function(b,v,I){var k,Q=b.getUTCFullYear();if(v){if(Q<1950||2049<Q)throw"not proper year for UTCTime: "+Q;k=(""+Q).slice(-2)}else k=("000"+Q).slice(-4);if(k+=("0"+(b.getUTCMonth()+1)).slice(-2),k+=("0"+b.getUTCDate()).slice(-2),k+=("0"+b.getUTCHours()).slice(-2),k+=("0"+b.getUTCMinutes()).slice(-2),k+=("0"+b.getUTCSeconds()).slice(-2),I){var te=b.getUTCMilliseconds();te!==0&&(k+="."+(te=(te=("00"+te).slice(-3)).replace(/0+$/g,"")))}return k+="Z"},n.uricmptohex=Ht,n.hextouricmp=on,n.ipv6tohex=Sr,n.hextoipv6=sr,n.hextoip=bn,n.iptohex=function(b){var v="malformed IP address";if(!(b=b.toLowerCase(b)).match(/^[0-9.]+$/)){if(b.match(/^[0-9a-f:]+$/)&&b.indexOf(":")!==-1)return Sr(b);throw v}var I=b.split(".");if(I.length!==4)throw v;var k="";try{for(var Q=0;Q<4;Q++)k+=("0"+parseInt(I[Q]).toString(16)).slice(-2);return k}catch{throw v}},n.encodeURIComponentAll=qt,n.newline_toUnix=function(b){return b=b.replace(/\r\n/gm,`
87
+ `)},n.newline_toDos=function(b){return b=(b=b.replace(/\r\n/gm,`
88
+ `)).replace(/\n/gm,`\r
89
+ `)},n.hextoposhex=Dr,n.intarystrtohex=function(b){b=(b=(b=b.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return b.split(/,/).map((function(v,I,k){var Q=parseInt(v);if(Q<0||255<Q)throw"integer not in range 0-255";return("00"+Q.toString(16)).slice(-2)})).join("")}catch(v){throw"malformed integer array string: "+v}},n.strdiffidx=function(b,v){var I=b.length;b.length>v.length&&(I=v.length);for(var k=0;k<I;k++)if(b.charCodeAt(k)!=v.charCodeAt(k))return k;return b.length!=v.length?I:-1},n.KJUR=U;var Sn=U.crypto;n.crypto=Sn;var hn=U.asn1;n.asn1=hn;var En=U.jws;n.jws=En;var ws=U.lang;n.lang=ws}).call(this,s(28).Buffer)},function(t,n,s){(function(a){var u=s(30),c=s(31),h=s(32);function f(){return g.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function p(ie,j){if(f()<j)throw new RangeError("Invalid typed array length");return g.TYPED_ARRAY_SUPPORT?(ie=new Uint8Array(j)).__proto__=g.prototype:(ie===null&&(ie=new g(j)),ie.length=j),ie}function g(ie,j,N){if(!(g.TYPED_ARRAY_SUPPORT||this instanceof g))return new g(ie,j,N);if(typeof ie=="number"){if(typeof j=="string")throw new Error("If encoding is specified then the first argument must be a string");return w(this,ie)}return y(this,ie,j,N)}function y(ie,j,N,L){if(typeof j=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&j instanceof ArrayBuffer?(function(ee,ae,ve,J){if(ae.byteLength,ve<0||ae.byteLength<ve)throw new RangeError("'offset' is out of bounds");if(ae.byteLength<ve+(J||0))throw new RangeError("'length' is out of bounds");return ae=ve===void 0&&J===void 0?new Uint8Array(ae):J===void 0?new Uint8Array(ae,ve):new Uint8Array(ae,ve,J),g.TYPED_ARRAY_SUPPORT?(ee=ae).__proto__=g.prototype:ee=R(ee,ae),ee})(ie,j,N,L):typeof j=="string"?(function(ee,ae,ve){if(typeof ve=="string"&&ve!==""||(ve="utf8"),!g.isEncoding(ve))throw new TypeError('"encoding" must be a valid string encoding');var J=0|A(ae,ve),me=(ee=p(ee,J)).write(ae,ve);return me!==J&&(ee=ee.slice(0,me)),ee})(ie,j,N):(function(ee,ae){if(g.isBuffer(ae)){var ve=0|T(ae.length);return(ee=p(ee,ve)).length===0||ae.copy(ee,0,0,ve),ee}if(ae){if(typeof ArrayBuffer<"u"&&ae.buffer instanceof ArrayBuffer||"length"in ae)return typeof ae.length!="number"||(function(me){return me!=me})(ae.length)?p(ee,0):R(ee,ae);if(ae.type==="Buffer"&&h(ae.data))return R(ee,ae.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")})(ie,j)}function S(ie){if(typeof ie!="number")throw new TypeError('"size" argument must be a number');if(ie<0)throw new RangeError('"size" argument must not be negative')}function w(ie,j){if(S(j),ie=p(ie,j<0?0:0|T(j)),!g.TYPED_ARRAY_SUPPORT)for(var N=0;N<j;++N)ie[N]=0;return ie}function R(ie,j){var N=j.length<0?0:0|T(j.length);ie=p(ie,N);for(var L=0;L<N;L+=1)ie[L]=255&j[L];return ie}function T(ie){if(ie>=f())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f().toString(16)+" bytes");return 0|ie}function A(ie,j){if(g.isBuffer(ie))return ie.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(ie)||ie instanceof ArrayBuffer))return ie.byteLength;typeof ie!="string"&&(ie=""+ie);var N=ie.length;if(N===0)return 0;for(var L=!1;;)switch(j){case"ascii":case"latin1":case"binary":return N;case"utf8":case"utf-8":case void 0:return he(ie).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*N;case"hex":return N>>>1;case"base64":return fe(ie).length;default:if(L)return he(ie).length;j=(""+j).toLowerCase(),L=!0}}function F(ie,j,N){var L=!1;if((j===void 0||j<0)&&(j=0),j>this.length||((N===void 0||N>this.length)&&(N=this.length),N<=0)||(N>>>=0)<=(j>>>=0))return"";for(ie||(ie="utf8");;)switch(ie){case"hex":return Ve(this,j,N);case"utf8":case"utf-8":return re(this,j,N);case"ascii":return ze(this,j,N);case"latin1":case"binary":return ye(this,j,N);case"base64":return Te(this,j,N);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,j,N);default:if(L)throw new TypeError("Unknown encoding: "+ie);ie=(ie+"").toLowerCase(),L=!0}}function x(ie,j,N){var L=ie[j];ie[j]=ie[N],ie[N]=L}function D(ie,j,N,L,V){if(ie.length===0)return-1;if(typeof N=="string"?(L=N,N=0):N>2147483647?N=2147483647:N<-2147483648&&(N=-2147483648),N=+N,isNaN(N)&&(N=V?0:ie.length-1),N<0&&(N=ie.length+N),N>=ie.length){if(V)return-1;N=ie.length-1}else if(N<0){if(!V)return-1;N=0}if(typeof j=="string"&&(j=g.from(j,L)),g.isBuffer(j))return j.length===0?-1:O(ie,j,N,L,V);if(typeof j=="number")return j&=255,g.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?V?Uint8Array.prototype.indexOf.call(ie,j,N):Uint8Array.prototype.lastIndexOf.call(ie,j,N):O(ie,[j],N,L,V);throw new TypeError("val must be string, number or Buffer")}function O(ie,j,N,L,V){var ee,ae=1,ve=ie.length,J=j.length;if(L!==void 0&&((L=String(L).toLowerCase())==="ucs2"||L==="ucs-2"||L==="utf16le"||L==="utf-16le")){if(ie.length<2||j.length<2)return-1;ae=2,ve/=2,J/=2,N/=2}function me(ft,Ge){return ae===1?ft[Ge]:ft.readUInt16BE(Ge*ae)}if(V){var xe=-1;for(ee=N;ee<ve;ee++)if(me(ie,ee)===me(j,xe===-1?0:ee-xe)){if(xe===-1&&(xe=ee),ee-xe+1===J)return xe*ae}else xe!==-1&&(ee-=ee-xe),xe=-1}else for(N+J>ve&&(N=ve-J),ee=N;ee>=0;ee--){for(var de=!0,st=0;st<J;st++)if(me(ie,ee+st)!==me(j,st)){de=!1;break}if(de)return ee}return-1}function K(ie,j,N,L){N=Number(N)||0;var V=ie.length-N;L?(L=Number(L))>V&&(L=V):L=V;var ee=j.length;if(ee%2!=0)throw new TypeError("Invalid hex string");L>ee/2&&(L=ee/2);for(var ae=0;ae<L;++ae){var ve=parseInt(j.substr(2*ae,2),16);if(isNaN(ve))return ae;ie[N+ae]=ve}return ae}function z(ie,j,N,L){return Oe(he(j,ie.length-N),ie,N,L)}function X(ie,j,N,L){return Oe((function(ee){for(var ae=[],ve=0;ve<ee.length;++ve)ae.push(255&ee.charCodeAt(ve));return ae})(j),ie,N,L)}function Ee(ie,j,N,L){return X(ie,j,N,L)}function q(ie,j,N,L){return Oe(fe(j),ie,N,L)}function Y(ie,j,N,L){return Oe((function(ee,ae){for(var ve,J,me,xe=[],de=0;de<ee.length&&!((ae-=2)<0);++de)J=(ve=ee.charCodeAt(de))>>8,me=ve%256,xe.push(me),xe.push(J);return xe})(j,ie.length-N),ie,N,L)}function Te(ie,j,N){return j===0&&N===ie.length?u.fromByteArray(ie):u.fromByteArray(ie.slice(j,N))}function re(ie,j,N){N=Math.min(ie.length,N);for(var L=[],V=j;V<N;){var ee,ae,ve,J,me=ie[V],xe=null,de=me>239?4:me>223?3:me>191?2:1;if(V+de<=N)switch(de){case 1:me<128&&(xe=me);break;case 2:(192&(ee=ie[V+1]))==128&&(J=(31&me)<<6|63&ee)>127&&(xe=J);break;case 3:ee=ie[V+1],ae=ie[V+2],(192&ee)==128&&(192&ae)==128&&(J=(15&me)<<12|(63&ee)<<6|63&ae)>2047&&(J<55296||J>57343)&&(xe=J);break;case 4:ee=ie[V+1],ae=ie[V+2],ve=ie[V+3],(192&ee)==128&&(192&ae)==128&&(192&ve)==128&&(J=(15&me)<<18|(63&ee)<<12|(63&ae)<<6|63&ve)>65535&&J<1114112&&(xe=J)}xe===null?(xe=65533,de=1):xe>65535&&(xe-=65536,L.push(xe>>>10&1023|55296),xe=56320|1023&xe),L.push(xe),V+=de}return(function(ft){var Ge=ft.length;if(Ge<=$e)return String.fromCharCode.apply(String,ft);for(var pt="",Z=0;Z<Ge;)pt+=String.fromCharCode.apply(String,ft.slice(Z,Z+=$e));return pt})(L)}n.Buffer=g,n.SlowBuffer=function(j){return+j!=j&&(j=0),g.alloc(+j)},n.INSPECT_MAX_BYTES=50,g.TYPED_ARRAY_SUPPORT=a.TYPED_ARRAY_SUPPORT!==void 0?a.TYPED_ARRAY_SUPPORT:(function(){try{var j=new Uint8Array(1);return j.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},j.foo()===42&&typeof j.subarray=="function"&&j.subarray(1,1).byteLength===0}catch{return!1}})(),n.kMaxLength=f(),g.poolSize=8192,g._augment=function(ie){return ie.__proto__=g.prototype,ie},g.from=function(ie,j,N){return y(null,ie,j,N)},g.TYPED_ARRAY_SUPPORT&&(g.prototype.__proto__=Uint8Array.prototype,g.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&g[Symbol.species]===g&&Object.defineProperty(g,Symbol.species,{value:null,configurable:!0})),g.alloc=function(ie,j,N){return(function(V,ee,ae,ve){return S(ee),ee<=0?p(V,ee):ae!==void 0?typeof ve=="string"?p(V,ee).fill(ae,ve):p(V,ee).fill(ae):p(V,ee)})(null,ie,j,N)},g.allocUnsafe=function(ie){return w(null,ie)},g.allocUnsafeSlow=function(ie){return w(null,ie)},g.isBuffer=function(j){return!(j==null||!j._isBuffer)},g.compare=function(j,N){if(!g.isBuffer(j)||!g.isBuffer(N))throw new TypeError("Arguments must be Buffers");if(j===N)return 0;for(var L=j.length,V=N.length,ee=0,ae=Math.min(L,V);ee<ae;++ee)if(j[ee]!==N[ee]){L=j[ee],V=N[ee];break}return L<V?-1:V<L?1:0},g.isEncoding=function(j){switch(String(j).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},g.concat=function(j,N){if(!h(j))throw new TypeError('"list" argument must be an Array of Buffers');if(j.length===0)return g.alloc(0);var L;if(N===void 0)for(N=0,L=0;L<j.length;++L)N+=j[L].length;var V=g.allocUnsafe(N),ee=0;for(L=0;L<j.length;++L){var ae=j[L];if(!g.isBuffer(ae))throw new TypeError('"list" argument must be an Array of Buffers');ae.copy(V,ee),ee+=ae.length}return V},g.byteLength=A,g.prototype._isBuffer=!0,g.prototype.swap16=function(){var j=this.length;if(j%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var N=0;N<j;N+=2)x(this,N,N+1);return this},g.prototype.swap32=function(){var j=this.length;if(j%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var N=0;N<j;N+=4)x(this,N,N+3),x(this,N+1,N+2);return this},g.prototype.swap64=function(){var j=this.length;if(j%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var N=0;N<j;N+=8)x(this,N,N+7),x(this,N+1,N+6),x(this,N+2,N+5),x(this,N+3,N+4);return this},g.prototype.toString=function(){var j=0|this.length;return j===0?"":arguments.length===0?re(this,0,j):F.apply(this,arguments)},g.prototype.equals=function(j){if(!g.isBuffer(j))throw new TypeError("Argument must be a Buffer");return this===j||g.compare(this,j)===0},g.prototype.inspect=function(){var j="",N=n.INSPECT_MAX_BYTES;return this.length>0&&(j=this.toString("hex",0,N).match(/.{2}/g).join(" "),this.length>N&&(j+=" ... ")),"<Buffer "+j+">"},g.prototype.compare=function(j,N,L,V,ee){if(!g.isBuffer(j))throw new TypeError("Argument must be a Buffer");if(N===void 0&&(N=0),L===void 0&&(L=j?j.length:0),V===void 0&&(V=0),ee===void 0&&(ee=this.length),N<0||L>j.length||V<0||ee>this.length)throw new RangeError("out of range index");if(V>=ee&&N>=L)return 0;if(V>=ee)return-1;if(N>=L)return 1;if(this===j)return 0;for(var ae=(ee>>>=0)-(V>>>=0),ve=(L>>>=0)-(N>>>=0),J=Math.min(ae,ve),me=this.slice(V,ee),xe=j.slice(N,L),de=0;de<J;++de)if(me[de]!==xe[de]){ae=me[de],ve=xe[de];break}return ae<ve?-1:ve<ae?1:0},g.prototype.includes=function(j,N,L){return this.indexOf(j,N,L)!==-1},g.prototype.indexOf=function(j,N,L){return D(this,j,N,L,!0)},g.prototype.lastIndexOf=function(j,N,L){return D(this,j,N,L,!1)},g.prototype.write=function(j,N,L,V){if(N===void 0)V="utf8",L=this.length,N=0;else if(L===void 0&&typeof N=="string")V=N,L=this.length,N=0;else{if(!isFinite(N))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");N|=0,isFinite(L)?(L|=0,V===void 0&&(V="utf8")):(V=L,L=void 0)}var ee=this.length-N;if((L===void 0||L>ee)&&(L=ee),j.length>0&&(L<0||N<0)||N>this.length)throw new RangeError("Attempt to write outside buffer bounds");V||(V="utf8");for(var ae=!1;;)switch(V){case"hex":return K(this,j,N,L);case"utf8":case"utf-8":return z(this,j,N,L);case"ascii":return X(this,j,N,L);case"latin1":case"binary":return Ee(this,j,N,L);case"base64":return q(this,j,N,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,j,N,L);default:if(ae)throw new TypeError("Unknown encoding: "+V);V=(""+V).toLowerCase(),ae=!0}},g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $e=4096;function ze(ie,j,N){var L="";N=Math.min(ie.length,N);for(var V=j;V<N;++V)L+=String.fromCharCode(127&ie[V]);return L}function ye(ie,j,N){var L="";N=Math.min(ie.length,N);for(var V=j;V<N;++V)L+=String.fromCharCode(ie[V]);return L}function Ve(ie,j,N){var L=ie.length;(!j||j<0)&&(j=0),(!N||N<0||N>L)&&(N=L);for(var V="",ee=j;ee<N;++ee)V+=He(ie[ee]);return V}function pe(ie,j,N){for(var L=ie.slice(j,N),V="",ee=0;ee<L.length;ee+=2)V+=String.fromCharCode(L[ee]+256*L[ee+1]);return V}function De(ie,j,N){if(ie%1!=0||ie<0)throw new RangeError("offset is not uint");if(ie+j>N)throw new RangeError("Trying to access beyond buffer length")}function $(ie,j,N,L,V,ee){if(!g.isBuffer(ie))throw new TypeError('"buffer" argument must be a Buffer instance');if(j>V||j<ee)throw new RangeError('"value" argument is out of bounds');if(N+L>ie.length)throw new RangeError("Index out of range")}function G(ie,j,N,L){j<0&&(j=65535+j+1);for(var V=0,ee=Math.min(ie.length-N,2);V<ee;++V)ie[N+V]=(j&255<<8*(L?V:1-V))>>>8*(L?V:1-V)}function ce(ie,j,N,L){j<0&&(j=4294967295+j+1);for(var V=0,ee=Math.min(ie.length-N,4);V<ee;++V)ie[N+V]=j>>>8*(L?V:3-V)&255}function oe(ie,j,N,L,V,ee){if(N+L>ie.length)throw new RangeError("Index out of range");if(N<0)throw new RangeError("Index out of range")}function Fe(ie,j,N,L,V){return V||oe(ie,0,N,4),c.write(ie,j,N,L,23,4),N+4}function Ue(ie,j,N,L,V){return V||oe(ie,0,N,8),c.write(ie,j,N,L,52,8),N+8}g.prototype.slice=function(j,N){var L,V=this.length;if((j=~~j)<0?(j+=V)<0&&(j=0):j>V&&(j=V),(N=N===void 0?V:~~N)<0?(N+=V)<0&&(N=0):N>V&&(N=V),N<j&&(N=j),g.TYPED_ARRAY_SUPPORT)(L=this.subarray(j,N)).__proto__=g.prototype;else{var ee=N-j;L=new g(ee,void 0);for(var ae=0;ae<ee;++ae)L[ae]=this[ae+j]}return L},g.prototype.readUIntLE=function(j,N,L){j|=0,N|=0,L||De(j,N,this.length);for(var V=this[j],ee=1,ae=0;++ae<N&&(ee*=256);)V+=this[j+ae]*ee;return V},g.prototype.readUIntBE=function(j,N,L){j|=0,N|=0,L||De(j,N,this.length);for(var V=this[j+--N],ee=1;N>0&&(ee*=256);)V+=this[j+--N]*ee;return V},g.prototype.readUInt8=function(j,N){return N||De(j,1,this.length),this[j]},g.prototype.readUInt16LE=function(j,N){return N||De(j,2,this.length),this[j]|this[j+1]<<8},g.prototype.readUInt16BE=function(j,N){return N||De(j,2,this.length),this[j]<<8|this[j+1]},g.prototype.readUInt32LE=function(j,N){return N||De(j,4,this.length),(this[j]|this[j+1]<<8|this[j+2]<<16)+16777216*this[j+3]},g.prototype.readUInt32BE=function(j,N){return N||De(j,4,this.length),16777216*this[j]+(this[j+1]<<16|this[j+2]<<8|this[j+3])},g.prototype.readIntLE=function(j,N,L){j|=0,N|=0,L||De(j,N,this.length);for(var V=this[j],ee=1,ae=0;++ae<N&&(ee*=256);)V+=this[j+ae]*ee;return V>=(ee*=128)&&(V-=Math.pow(2,8*N)),V},g.prototype.readIntBE=function(j,N,L){j|=0,N|=0,L||De(j,N,this.length);for(var V=N,ee=1,ae=this[j+--V];V>0&&(ee*=256);)ae+=this[j+--V]*ee;return ae>=(ee*=128)&&(ae-=Math.pow(2,8*N)),ae},g.prototype.readInt8=function(j,N){return N||De(j,1,this.length),128&this[j]?-1*(255-this[j]+1):this[j]},g.prototype.readInt16LE=function(j,N){N||De(j,2,this.length);var L=this[j]|this[j+1]<<8;return 32768&L?4294901760|L:L},g.prototype.readInt16BE=function(j,N){N||De(j,2,this.length);var L=this[j+1]|this[j]<<8;return 32768&L?4294901760|L:L},g.prototype.readInt32LE=function(j,N){return N||De(j,4,this.length),this[j]|this[j+1]<<8|this[j+2]<<16|this[j+3]<<24},g.prototype.readInt32BE=function(j,N){return N||De(j,4,this.length),this[j]<<24|this[j+1]<<16|this[j+2]<<8|this[j+3]},g.prototype.readFloatLE=function(j,N){return N||De(j,4,this.length),c.read(this,j,!0,23,4)},g.prototype.readFloatBE=function(j,N){return N||De(j,4,this.length),c.read(this,j,!1,23,4)},g.prototype.readDoubleLE=function(j,N){return N||De(j,8,this.length),c.read(this,j,!0,52,8)},g.prototype.readDoubleBE=function(j,N){return N||De(j,8,this.length),c.read(this,j,!1,52,8)},g.prototype.writeUIntLE=function(j,N,L,V){j=+j,N|=0,L|=0,V||$(this,j,N,L,Math.pow(2,8*L)-1,0);var ee=1,ae=0;for(this[N]=255&j;++ae<L&&(ee*=256);)this[N+ae]=j/ee&255;return N+L},g.prototype.writeUIntBE=function(j,N,L,V){j=+j,N|=0,L|=0,V||$(this,j,N,L,Math.pow(2,8*L)-1,0);var ee=L-1,ae=1;for(this[N+ee]=255&j;--ee>=0&&(ae*=256);)this[N+ee]=j/ae&255;return N+L},g.prototype.writeUInt8=function(j,N,L){return j=+j,N|=0,L||$(this,j,N,1,255,0),g.TYPED_ARRAY_SUPPORT||(j=Math.floor(j)),this[N]=255&j,N+1},g.prototype.writeUInt16LE=function(j,N,L){return j=+j,N|=0,L||$(this,j,N,2,65535,0),g.TYPED_ARRAY_SUPPORT?(this[N]=255&j,this[N+1]=j>>>8):G(this,j,N,!0),N+2},g.prototype.writeUInt16BE=function(j,N,L){return j=+j,N|=0,L||$(this,j,N,2,65535,0),g.TYPED_ARRAY_SUPPORT?(this[N]=j>>>8,this[N+1]=255&j):G(this,j,N,!1),N+2},g.prototype.writeUInt32LE=function(j,N,L){return j=+j,N|=0,L||$(this,j,N,4,4294967295,0),g.TYPED_ARRAY_SUPPORT?(this[N+3]=j>>>24,this[N+2]=j>>>16,this[N+1]=j>>>8,this[N]=255&j):ce(this,j,N,!0),N+4},g.prototype.writeUInt32BE=function(j,N,L){return j=+j,N|=0,L||$(this,j,N,4,4294967295,0),g.TYPED_ARRAY_SUPPORT?(this[N]=j>>>24,this[N+1]=j>>>16,this[N+2]=j>>>8,this[N+3]=255&j):ce(this,j,N,!1),N+4},g.prototype.writeIntLE=function(j,N,L,V){if(j=+j,N|=0,!V){var ee=Math.pow(2,8*L-1);$(this,j,N,L,ee-1,-ee)}var ae=0,ve=1,J=0;for(this[N]=255&j;++ae<L&&(ve*=256);)j<0&&J===0&&this[N+ae-1]!==0&&(J=1),this[N+ae]=(j/ve>>0)-J&255;return N+L},g.prototype.writeIntBE=function(j,N,L,V){if(j=+j,N|=0,!V){var ee=Math.pow(2,8*L-1);$(this,j,N,L,ee-1,-ee)}var ae=L-1,ve=1,J=0;for(this[N+ae]=255&j;--ae>=0&&(ve*=256);)j<0&&J===0&&this[N+ae+1]!==0&&(J=1),this[N+ae]=(j/ve>>0)-J&255;return N+L},g.prototype.writeInt8=function(j,N,L){return j=+j,N|=0,L||$(this,j,N,1,127,-128),g.TYPED_ARRAY_SUPPORT||(j=Math.floor(j)),j<0&&(j=255+j+1),this[N]=255&j,N+1},g.prototype.writeInt16LE=function(j,N,L){return j=+j,N|=0,L||$(this,j,N,2,32767,-32768),g.TYPED_ARRAY_SUPPORT?(this[N]=255&j,this[N+1]=j>>>8):G(this,j,N,!0),N+2},g.prototype.writeInt16BE=function(j,N,L){return j=+j,N|=0,L||$(this,j,N,2,32767,-32768),g.TYPED_ARRAY_SUPPORT?(this[N]=j>>>8,this[N+1]=255&j):G(this,j,N,!1),N+2},g.prototype.writeInt32LE=function(j,N,L){return j=+j,N|=0,L||$(this,j,N,4,2147483647,-2147483648),g.TYPED_ARRAY_SUPPORT?(this[N]=255&j,this[N+1]=j>>>8,this[N+2]=j>>>16,this[N+3]=j>>>24):ce(this,j,N,!0),N+4},g.prototype.writeInt32BE=function(j,N,L){return j=+j,N|=0,L||$(this,j,N,4,2147483647,-2147483648),j<0&&(j=4294967295+j+1),g.TYPED_ARRAY_SUPPORT?(this[N]=j>>>24,this[N+1]=j>>>16,this[N+2]=j>>>8,this[N+3]=255&j):ce(this,j,N,!1),N+4},g.prototype.writeFloatLE=function(j,N,L){return Fe(this,j,N,!0,L)},g.prototype.writeFloatBE=function(j,N,L){return Fe(this,j,N,!1,L)},g.prototype.writeDoubleLE=function(j,N,L){return Ue(this,j,N,!0,L)},g.prototype.writeDoubleBE=function(j,N,L){return Ue(this,j,N,!1,L)},g.prototype.copy=function(j,N,L,V){if(L||(L=0),V||V===0||(V=this.length),N>=j.length&&(N=j.length),N||(N=0),V>0&&V<L&&(V=L),V===L||j.length===0||this.length===0)return 0;if(N<0)throw new RangeError("targetStart out of bounds");if(L<0||L>=this.length)throw new RangeError("sourceStart out of bounds");if(V<0)throw new RangeError("sourceEnd out of bounds");V>this.length&&(V=this.length),j.length-N<V-L&&(V=j.length-N+L);var ee,ae=V-L;if(this===j&&L<N&&N<V)for(ee=ae-1;ee>=0;--ee)j[ee+N]=this[ee+L];else if(ae<1e3||!g.TYPED_ARRAY_SUPPORT)for(ee=0;ee<ae;++ee)j[ee+N]=this[ee+L];else Uint8Array.prototype.set.call(j,this.subarray(L,L+ae),N);return ae},g.prototype.fill=function(j,N,L,V){if(typeof j=="string"){if(typeof N=="string"?(V=N,N=0,L=this.length):typeof L=="string"&&(V=L,L=this.length),j.length===1){var ee=j.charCodeAt(0);ee<256&&(j=ee)}if(V!==void 0&&typeof V!="string")throw new TypeError("encoding must be a string");if(typeof V=="string"&&!g.isEncoding(V))throw new TypeError("Unknown encoding: "+V)}else typeof j=="number"&&(j&=255);if(N<0||this.length<N||this.length<L)throw new RangeError("Out of range index");if(L<=N)return this;var ae;if(N>>>=0,L=L===void 0?this.length:L>>>0,j||(j=0),typeof j=="number")for(ae=N;ae<L;++ae)this[ae]=j;else{var ve=g.isBuffer(j)?j:he(new g(j,V).toString()),J=ve.length;for(ae=0;ae<L-N;++ae)this[ae+N]=ve[ae%J]}return this};var Je=/[^+\/0-9A-Za-z-_]/g;function He(ie){return ie<16?"0"+ie.toString(16):ie.toString(16)}function he(ie,j){var N;j=j||1/0;for(var L=ie.length,V=null,ee=[],ae=0;ae<L;++ae){if((N=ie.charCodeAt(ae))>55295&&N<57344){if(!V){if(N>56319){(j-=3)>-1&&ee.push(239,191,189);continue}if(ae+1===L){(j-=3)>-1&&ee.push(239,191,189);continue}V=N;continue}if(N<56320){(j-=3)>-1&&ee.push(239,191,189),V=N;continue}N=65536+(V-55296<<10|N-56320)}else V&&(j-=3)>-1&&ee.push(239,191,189);if(V=null,N<128){if((j-=1)<0)break;ee.push(N)}else if(N<2048){if((j-=2)<0)break;ee.push(N>>6|192,63&N|128)}else if(N<65536){if((j-=3)<0)break;ee.push(N>>12|224,N>>6&63|128,63&N|128)}else{if(!(N<1114112))throw new Error("Invalid code point");if((j-=4)<0)break;ee.push(N>>18|240,N>>12&63|128,N>>6&63|128,63&N|128)}}return ee}function fe(ie){return u.toByteArray((function(N){if((N=(function(V){return V.trim?V.trim():V.replace(/^\s+|\s+$/g,"")})(N).replace(Je,"")).length<2)return"";for(;N.length%4!=0;)N+="=";return N})(ie))}function Oe(ie,j,N,L){for(var V=0;V<L&&!(V+N>=j.length||V>=ie.length);++V)j[V+N]=ie[V];return V}}).call(this,s(29))},function(t,n){var s;s=(function(){return this})();try{s=s||new Function("return this")()}catch{typeof window=="object"&&(s=window)}t.exports=s},function(t,n,s){n.byteLength=function(w){var R=g(w),T=R[0],A=R[1];return 3*(T+A)/4-A},n.toByteArray=function(w){var R,T,A=g(w),F=A[0],x=A[1],D=new c((function(X,Ee,q){return 3*(Ee+q)/4-q})(0,F,x)),O=0,K=x>0?F-4:F;for(T=0;T<K;T+=4)R=u[w.charCodeAt(T)]<<18|u[w.charCodeAt(T+1)]<<12|u[w.charCodeAt(T+2)]<<6|u[w.charCodeAt(T+3)],D[O++]=R>>16&255,D[O++]=R>>8&255,D[O++]=255&R;return x===2&&(R=u[w.charCodeAt(T)]<<2|u[w.charCodeAt(T+1)]>>4,D[O++]=255&R),x===1&&(R=u[w.charCodeAt(T)]<<10|u[w.charCodeAt(T+1)]<<4|u[w.charCodeAt(T+2)]>>2,D[O++]=R>>8&255,D[O++]=255&R),D},n.fromByteArray=function(w){for(var R,T=w.length,A=T%3,F=[],x=16383,D=0,O=T-A;D<O;D+=x)F.push(y(w,D,D+x>O?O:D+x));return A===1?(R=w[T-1],F.push(a[R>>2]+a[R<<4&63]+"==")):A===2&&(R=(w[T-2]<<8)+w[T-1],F.push(a[R>>10]+a[R>>4&63]+a[R<<2&63]+"=")),F.join("")};for(var a=[],u=[],c=typeof Uint8Array<"u"?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,p=h.length;f<p;++f)a[f]=h[f],u[h.charCodeAt(f)]=f;function g(S){var w=S.length;if(w%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var R=S.indexOf("=");return R===-1&&(R=w),[R,R===w?0:4-R%4]}function y(S,w,R){for(var T,A,F=[],x=w;x<R;x+=3)T=(S[x]<<16&16711680)+(S[x+1]<<8&65280)+(255&S[x+2]),F.push(a[(A=T)>>18&63]+a[A>>12&63]+a[A>>6&63]+a[63&A]);return F.join("")}u[45]=62,u[95]=63},function(t,n){n.read=function(s,a,u,c,h){var f,p,g=8*h-c-1,y=(1<<g)-1,S=y>>1,w=-7,R=u?h-1:0,T=u?-1:1,A=s[a+R];for(R+=T,f=A&(1<<-w)-1,A>>=-w,w+=g;w>0;f=256*f+s[a+R],R+=T,w-=8);for(p=f&(1<<-w)-1,f>>=-w,w+=c;w>0;p=256*p+s[a+R],R+=T,w-=8);if(f===0)f=1-S;else{if(f===y)return p?NaN:1/0*(A?-1:1);p+=Math.pow(2,c),f-=S}return(A?-1:1)*p*Math.pow(2,f-c)},n.write=function(s,a,u,c,h,f){var p,g,y,S=8*f-h-1,w=(1<<S)-1,R=w>>1,T=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=c?0:f-1,F=c?1:-1,x=a<0||a===0&&1/a<0?1:0;for(a=Math.abs(a),isNaN(a)||a===1/0?(g=isNaN(a)?1:0,p=w):(p=Math.floor(Math.log(a)/Math.LN2),a*(y=Math.pow(2,-p))<1&&(p--,y*=2),(a+=p+R>=1?T/y:T*Math.pow(2,1-R))*y>=2&&(p++,y/=2),p+R>=w?(g=0,p=w):p+R>=1?(g=(a*y-1)*Math.pow(2,h),p+=R):(g=a*Math.pow(2,R-1)*Math.pow(2,h),p=0));h>=8;s[u+A]=255&g,A+=F,g/=256,h-=8);for(p=p<<h|g,S+=h;S>0;s[u+A]=255&p,A+=F,p/=256,S-=8);s[u+A-F]|=128*x}},function(t,n){var s={}.toString;t.exports=Array.isArray||function(a){return s.call(a)=="[object Array]"}},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(c){var h=c.jws,f=c.KeyUtil,p=c.X509,g=c.crypto,y=c.hextob64u,S=c.b64tohex,w=c.AllowedSigningAlgs;return(function(){function R(){(function(A,F){if(!(A instanceof F))throw new TypeError("Cannot call a class as a function")})(this,R)}return R.parseJwt=function(A){a.Log.debug("JoseUtil.parseJwt");try{var F=h.JWS.parse(A);return{header:F.headerObj,payload:F.payloadObj}}catch(x){a.Log.error(x)}},R.validateJwt=function(A,F,x,D,O,K,z){a.Log.debug("JoseUtil.validateJwt");try{if(F.kty==="RSA")if(F.e&&F.n)F=f.getKey(F);else{if(!F.x5c||!F.x5c.length)return a.Log.error("JoseUtil.validateJwt: RSA key missing key material",F),Promise.reject(new Error("RSA key missing key material"));var X=S(F.x5c[0]);F=p.getPublicKeyFromCertHex(X)}else{if(F.kty!=="EC")return a.Log.error("JoseUtil.validateJwt: Unsupported key type",F&&F.kty),Promise.reject(new Error(F.kty));if(!(F.crv&&F.x&&F.y))return a.Log.error("JoseUtil.validateJwt: EC key missing key material",F),Promise.reject(new Error("EC key missing key material"));F=f.getKey(F)}return R._validateJwt(A,F,x,D,O,K,z)}catch(Ee){return a.Log.error(Ee&&Ee.message||Ee),Promise.reject("JWT validation failed")}},R.validateJwtAttributes=function(A,F,x,D,O,K){D||(D=0),O||(O=parseInt(Date.now()/1e3));var z=R.parseJwt(A).payload;if(!z.iss)return a.Log.error("JoseUtil._validateJwt: issuer was not provided"),Promise.reject(new Error("issuer was not provided"));if(z.iss!==F)return a.Log.error("JoseUtil._validateJwt: Invalid issuer in token",z.iss),Promise.reject(new Error("Invalid issuer in token: "+z.iss));if(!z.aud)return a.Log.error("JoseUtil._validateJwt: aud was not provided"),Promise.reject(new Error("aud was not provided"));if(!(z.aud===x||Array.isArray(z.aud)&&z.aud.indexOf(x)>=0))return a.Log.error("JoseUtil._validateJwt: Invalid audience in token",z.aud),Promise.reject(new Error("Invalid audience in token: "+z.aud));if(z.azp&&z.azp!==x)return a.Log.error("JoseUtil._validateJwt: Invalid azp in token",z.azp),Promise.reject(new Error("Invalid azp in token: "+z.azp));if(!K){var X=O+D,Ee=O-D;if(!z.iat)return a.Log.error("JoseUtil._validateJwt: iat was not provided"),Promise.reject(new Error("iat was not provided"));if(X<z.iat)return a.Log.error("JoseUtil._validateJwt: iat is in the future",z.iat),Promise.reject(new Error("iat is in the future: "+z.iat));if(z.nbf&&X<z.nbf)return a.Log.error("JoseUtil._validateJwt: nbf is in the future",z.nbf),Promise.reject(new Error("nbf is in the future: "+z.nbf));if(!z.exp)return a.Log.error("JoseUtil._validateJwt: exp was not provided"),Promise.reject(new Error("exp was not provided"));if(z.exp<Ee)return a.Log.error("JoseUtil._validateJwt: exp is in the past",z.exp),Promise.reject(new Error("exp is in the past:"+z.exp))}return Promise.resolve(z)},R._validateJwt=function(A,F,x,D,O,K,z){return R.validateJwtAttributes(A,x,D,O,K,z).then((function(X){try{return h.JWS.verify(A,F,w)?X:(a.Log.error("JoseUtil._validateJwt: signature validation failed"),Promise.reject(new Error("signature validation failed")))}catch(Ee){return a.Log.error(Ee&&Ee.message||Ee),Promise.reject(new Error("signature validation failed"))}}))},R.hashString=function(A,F){try{return g.Util.hashString(A,F)}catch(x){a.Log.error(x)}},R.hexToBase64Url=function(A){try{return y(A)}catch(F){a.Log.error(F)}},R})()};var a=s(0);t.exports=n.default},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.SigninResponse=void 0;var a=(function(){function h(f,p){for(var g=0;g<p.length;g++){var y=p[g];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(f,y.key,y)}}return function(f,p,g){return p&&h(f.prototype,p),g&&h(f,g),f}})(),u=s(3);function c(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")}n.SigninResponse=(function(){function h(f){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"#";c(this,h);var g=u.UrlUtility.parseUrlFragment(f,p);this.error=g.error,this.error_description=g.error_description,this.error_uri=g.error_uri,this.code=g.code,this.state=g.state,this.id_token=g.id_token,this.session_state=g.session_state,this.access_token=g.access_token,this.token_type=g.token_type,this.scope=g.scope,this.profile=void 0,this.expires_in=g.expires_in}return a(h,[{key:"expires_in",get:function(){if(this.expires_at){var p=parseInt(Date.now()/1e3);return this.expires_at-p}},set:function(p){var g=parseInt(p);if(typeof g=="number"&&g>0){var y=parseInt(Date.now()/1e3);this.expires_at=y+g}}},{key:"expired",get:function(){var p=this.expires_in;if(p!==void 0)return p<=0}},{key:"scopes",get:function(){return(this.scope||"").split(" ")}},{key:"isOpenIdConnect",get:function(){return this.scopes.indexOf("openid")>=0||!!this.id_token}}]),h})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.SignoutRequest=void 0;var a=s(0),u=s(3),c=s(9);n.SignoutRequest=function h(f){var p=f.url,g=f.id_token_hint,y=f.post_logout_redirect_uri,S=f.data,w=f.extraQueryParams,R=f.request_type;if((function(F,x){if(!(F instanceof x))throw new TypeError("Cannot call a class as a function")})(this,h),!p)throw a.Log.error("SignoutRequest.ctor: No url passed"),new Error("url");for(var T in g&&(p=u.UrlUtility.addQueryParam(p,"id_token_hint",g)),y&&(p=u.UrlUtility.addQueryParam(p,"post_logout_redirect_uri",y),S&&(this.state=new c.State({data:S,request_type:R}),p=u.UrlUtility.addQueryParam(p,"state",this.state.id))),w)p=u.UrlUtility.addQueryParam(p,T,w[T]);this.url=p}},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.SignoutResponse=void 0;var a=s(3);n.SignoutResponse=function u(c){(function(p,g){if(!(p instanceof g))throw new TypeError("Cannot call a class as a function")})(this,u);var h=a.UrlUtility.parseUrlFragment(c,"?");this.error=h.error,this.error_description=h.error_description,this.error_uri=h.error_uri,this.state=h.state}},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.InMemoryWebStorage=void 0;var a=(function(){function c(h,f){for(var p=0;p<f.length;p++){var g=f[p];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(h,g.key,g)}}return function(h,f,p){return f&&c(h.prototype,f),p&&c(h,p),h}})(),u=s(0);n.InMemoryWebStorage=(function(){function c(){(function(f,p){if(!(f instanceof p))throw new TypeError("Cannot call a class as a function")})(this,c),this._data={}}return c.prototype.getItem=function(f){return u.Log.debug("InMemoryWebStorage.getItem",f),this._data[f]},c.prototype.setItem=function(f,p){u.Log.debug("InMemoryWebStorage.setItem",f),this._data[f]=p},c.prototype.removeItem=function(f){u.Log.debug("InMemoryWebStorage.removeItem",f),delete this._data[f]},c.prototype.key=function(f){return Object.getOwnPropertyNames(this._data)[f]},a(c,[{key:"length",get:function(){return Object.getOwnPropertyNames(this._data).length}}]),c})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.UserManager=void 0;var a=(function(){function x(D,O){for(var K=0;K<O.length;K++){var z=O[K];z.enumerable=z.enumerable||!1,z.configurable=!0,"value"in z&&(z.writable=!0),Object.defineProperty(D,z.key,z)}}return function(D,O,K){return O&&x(D.prototype,O),K&&x(D,K),D}})(),u=s(0),c=s(10),h=s(39),f=s(15),p=s(45),g=s(47),y=s(18),S=s(8),w=s(20),R=s(11),T=s(4);function A(x,D){if(!(x instanceof D))throw new TypeError("Cannot call a class as a function")}function F(x,D){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!D||typeof D!="object"&&typeof D!="function"?x:D}n.UserManager=(function(x){function D(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:g.SilentRenewService,z=arguments.length>2&&arguments[2]!==void 0?arguments[2]:y.SessionMonitor,X=arguments.length>3&&arguments[3]!==void 0?arguments[3]:w.TokenRevocationClient,Ee=arguments.length>4&&arguments[4]!==void 0?arguments[4]:R.TokenClient,q=arguments.length>5&&arguments[5]!==void 0?arguments[5]:T.JoseUtil;A(this,D),O instanceof h.UserManagerSettings||(O=new h.UserManagerSettings(O));var Y=F(this,x.call(this,O));return Y._events=new p.UserManagerEvents(O),Y._silentRenewService=new K(Y),Y.settings.automaticSilentRenew&&(u.Log.debug("UserManager.ctor: automaticSilentRenew is configured, setting up silent renew"),Y.startSilentRenew()),Y.settings.monitorSession&&(u.Log.debug("UserManager.ctor: monitorSession is configured, setting up session monitor"),Y._sessionMonitor=new z(Y)),Y._tokenRevocationClient=new X(Y._settings),Y._tokenClient=new Ee(Y._settings),Y._joseUtil=q,Y}return(function(K,z){if(typeof z!="function"&&z!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof z);K.prototype=Object.create(z&&z.prototype,{constructor:{value:K,enumerable:!1,writable:!0,configurable:!0}}),z&&(Object.setPrototypeOf?Object.setPrototypeOf(K,z):K.__proto__=z)})(D,x),D.prototype.getUser=function(){var K=this;return this._loadUser().then((function(z){return z?(u.Log.info("UserManager.getUser: user loaded"),K._events.load(z,!1),z):(u.Log.info("UserManager.getUser: user not found in storage"),null)}))},D.prototype.removeUser=function(){var K=this;return this.storeUser(null).then((function(){u.Log.info("UserManager.removeUser: user removed from storage"),K._events.unload()}))},D.prototype.signinRedirect=function(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(K=Object.assign({},K)).request_type="si:r";var z={useReplaceToNavigate:K.useReplaceToNavigate};return this._signinStart(K,this._redirectNavigator,z).then((function(){u.Log.info("UserManager.signinRedirect: successful")}))},D.prototype.signinRedirectCallback=function(K){return this._signinEnd(K||this._redirectNavigator.url).then((function(z){return z.profile&&z.profile.sub?u.Log.info("UserManager.signinRedirectCallback: successful, signed in sub: ",z.profile.sub):u.Log.info("UserManager.signinRedirectCallback: no sub"),z}))},D.prototype.signinPopup=function(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(K=Object.assign({},K)).request_type="si:p";var z=K.redirect_uri||this.settings.popup_redirect_uri||this.settings.redirect_uri;return z?(K.redirect_uri=z,K.display="popup",this._signin(K,this._popupNavigator,{startUrl:z,popupWindowFeatures:K.popupWindowFeatures||this.settings.popupWindowFeatures,popupWindowTarget:K.popupWindowTarget||this.settings.popupWindowTarget}).then((function(X){return X&&(X.profile&&X.profile.sub?u.Log.info("UserManager.signinPopup: signinPopup successful, signed in sub: ",X.profile.sub):u.Log.info("UserManager.signinPopup: no sub")),X}))):(u.Log.error("UserManager.signinPopup: No popup_redirect_uri or redirect_uri configured"),Promise.reject(new Error("No popup_redirect_uri or redirect_uri configured")))},D.prototype.signinPopupCallback=function(K){return this._signinCallback(K,this._popupNavigator).then((function(z){return z&&(z.profile&&z.profile.sub?u.Log.info("UserManager.signinPopupCallback: successful, signed in sub: ",z.profile.sub):u.Log.info("UserManager.signinPopupCallback: no sub")),z})).catch((function(z){u.Log.error(z.message)}))},D.prototype.signinSilent=function(){var K=this,z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return z=Object.assign({},z),this._loadUser().then((function(X){return X&&X.refresh_token?(z.refresh_token=X.refresh_token,K._useRefreshToken(z)):(z.request_type="si:s",z.id_token_hint=z.id_token_hint||K.settings.includeIdTokenInSilentRenew&&X&&X.id_token,X&&K._settings.validateSubOnSilentRenew&&(u.Log.debug("UserManager.signinSilent, subject prior to silent renew: ",X.profile.sub),z.current_sub=X.profile.sub),K._signinSilentIframe(z))}))},D.prototype._useRefreshToken=function(){var K=this,z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this._tokenClient.exchangeRefreshToken(z).then((function(X){return X?X.access_token?K._loadUser().then((function(Ee){if(Ee){var q=Promise.resolve();return X.id_token&&(q=K._validateIdTokenFromTokenRefreshToken(Ee.profile,X.id_token)),q.then((function(){return u.Log.debug("UserManager._useRefreshToken: refresh token response success"),Ee.id_token=X.id_token||Ee.id_token,Ee.access_token=X.access_token,Ee.refresh_token=X.refresh_token||Ee.refresh_token,Ee.expires_in=X.expires_in,K.storeUser(Ee).then((function(){return K._events.load(Ee),Ee}))}))}return null})):(u.Log.error("UserManager._useRefreshToken: No access token returned from token endpoint"),Promise.reject("No access token returned from token endpoint")):(u.Log.error("UserManager._useRefreshToken: No response returned from token endpoint"),Promise.reject("No response returned from token endpoint"))}))},D.prototype._validateIdTokenFromTokenRefreshToken=function(K,z){var X=this;return this._metadataService.getIssuer().then((function(Ee){return X.settings.getEpochTime().then((function(q){return X._joseUtil.validateJwtAttributes(z,Ee,X._settings.client_id,X._settings.clockSkew,q).then((function(Y){return Y?Y.sub!==K.sub?(u.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: sub in id_token does not match current sub"),Promise.reject(new Error("sub in id_token does not match current sub"))):Y.auth_time&&Y.auth_time!==K.auth_time?(u.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: auth_time in id_token does not match original auth_time"),Promise.reject(new Error("auth_time in id_token does not match original auth_time"))):Y.azp&&Y.azp!==K.azp?(u.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: azp in id_token does not match original azp"),Promise.reject(new Error("azp in id_token does not match original azp"))):!Y.azp&&K.azp?(u.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: azp not in id_token, but present in original id_token"),Promise.reject(new Error("azp not in id_token, but present in original id_token"))):void 0:(u.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: Failed to validate id_token"),Promise.reject(new Error("Failed to validate id_token")))}))}))}))},D.prototype._signinSilentIframe=function(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},z=K.redirect_uri||this.settings.silent_redirect_uri||this.settings.redirect_uri;return z?(K.redirect_uri=z,K.prompt=K.prompt||"none",this._signin(K,this._iframeNavigator,{startUrl:z,silentRequestTimeout:K.silentRequestTimeout||this.settings.silentRequestTimeout}).then((function(X){return X&&(X.profile&&X.profile.sub?u.Log.info("UserManager.signinSilent: successful, signed in sub: ",X.profile.sub):u.Log.info("UserManager.signinSilent: no sub")),X}))):(u.Log.error("UserManager.signinSilent: No silent_redirect_uri configured"),Promise.reject(new Error("No silent_redirect_uri configured")))},D.prototype.signinSilentCallback=function(K){return this._signinCallback(K,this._iframeNavigator).then((function(z){return z&&(z.profile&&z.profile.sub?u.Log.info("UserManager.signinSilentCallback: successful, signed in sub: ",z.profile.sub):u.Log.info("UserManager.signinSilentCallback: no sub")),z}))},D.prototype.signinCallback=function(K){var z=this;return this.readSigninResponseState(K).then((function(X){var Ee=X.state;return X.response,Ee.request_type==="si:r"?z.signinRedirectCallback(K):Ee.request_type==="si:p"?z.signinPopupCallback(K):Ee.request_type==="si:s"?z.signinSilentCallback(K):Promise.reject(new Error("invalid response_type in state"))}))},D.prototype.signoutCallback=function(K,z){var X=this;return this.readSignoutResponseState(K).then((function(Ee){var q=Ee.state,Y=Ee.response;return q?q.request_type==="so:r"?X.signoutRedirectCallback(K):q.request_type==="so:p"?X.signoutPopupCallback(K,z):Promise.reject(new Error("invalid response_type in state")):Y}))},D.prototype.querySessionStatus=function(){var K=this,z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(z=Object.assign({},z)).request_type="si:s";var X=z.redirect_uri||this.settings.silent_redirect_uri||this.settings.redirect_uri;return X?(z.redirect_uri=X,z.prompt="none",z.response_type=z.response_type||this.settings.query_status_response_type,z.scope=z.scope||"openid",z.skipUserInfo=!0,this._signinStart(z,this._iframeNavigator,{startUrl:X,silentRequestTimeout:z.silentRequestTimeout||this.settings.silentRequestTimeout}).then((function(Ee){return K.processSigninResponse(Ee.url).then((function(q){if(u.Log.debug("UserManager.querySessionStatus: got signin response"),q.session_state&&q.profile.sub)return u.Log.info("UserManager.querySessionStatus: querySessionStatus success for sub: ",q.profile.sub),{session_state:q.session_state,sub:q.profile.sub,sid:q.profile.sid};u.Log.info("querySessionStatus successful, user not authenticated")})).catch((function(q){if(q.session_state&&K.settings.monitorAnonymousSession&&(q.message=="login_required"||q.message=="consent_required"||q.message=="interaction_required"||q.message=="account_selection_required"))return u.Log.info("UserManager.querySessionStatus: querySessionStatus success for anonymous user"),{session_state:q.session_state};throw q}))}))):(u.Log.error("UserManager.querySessionStatus: No silent_redirect_uri configured"),Promise.reject(new Error("No silent_redirect_uri configured")))},D.prototype._signin=function(K,z){var X=this,Ee=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this._signinStart(K,z,Ee).then((function(q){return X._signinEnd(q.url,K)}))},D.prototype._signinStart=function(K,z){var X=this,Ee=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return z.prepare(Ee).then((function(q){return u.Log.debug("UserManager._signinStart: got navigator window handle"),X.createSigninRequest(K).then((function(Y){return u.Log.debug("UserManager._signinStart: got signin request"),Ee.url=Y.url,Ee.id=Y.state.id,q.navigate(Ee)})).catch((function(Y){throw q.close&&(u.Log.debug("UserManager._signinStart: Error after preparing navigator, closing navigator window"),q.close()),Y}))}))},D.prototype._signinEnd=function(K){var z=this,X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.processSigninResponse(K).then((function(Ee){u.Log.debug("UserManager._signinEnd: got signin response");var q=new f.User(Ee);if(X.current_sub){if(X.current_sub!==q.profile.sub)return u.Log.debug("UserManager._signinEnd: current user does not match user returned from signin. sub from signin: ",q.profile.sub),Promise.reject(new Error("login_required"));u.Log.debug("UserManager._signinEnd: current user matches user returned from signin")}return z.storeUser(q).then((function(){return u.Log.debug("UserManager._signinEnd: user stored"),z._events.load(q),q}))}))},D.prototype._signinCallback=function(K,z){u.Log.debug("UserManager._signinCallback");var X=this._settings.response_mode==="query"||!this._settings.response_mode&&S.SigninRequest.isCode(this._settings.response_type)?"?":"#";return z.callback(K,void 0,X)},D.prototype.signoutRedirect=function(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(K=Object.assign({},K)).request_type="so:r";var z=K.post_logout_redirect_uri||this.settings.post_logout_redirect_uri;z&&(K.post_logout_redirect_uri=z);var X={useReplaceToNavigate:K.useReplaceToNavigate};return this._signoutStart(K,this._redirectNavigator,X).then((function(){u.Log.info("UserManager.signoutRedirect: successful")}))},D.prototype.signoutRedirectCallback=function(K){return this._signoutEnd(K||this._redirectNavigator.url).then((function(z){return u.Log.info("UserManager.signoutRedirectCallback: successful"),z}))},D.prototype.signoutPopup=function(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(K=Object.assign({},K)).request_type="so:p";var z=K.post_logout_redirect_uri||this.settings.popup_post_logout_redirect_uri||this.settings.post_logout_redirect_uri;return K.post_logout_redirect_uri=z,K.display="popup",K.post_logout_redirect_uri&&(K.state=K.state||{}),this._signout(K,this._popupNavigator,{startUrl:z,popupWindowFeatures:K.popupWindowFeatures||this.settings.popupWindowFeatures,popupWindowTarget:K.popupWindowTarget||this.settings.popupWindowTarget}).then((function(){u.Log.info("UserManager.signoutPopup: successful")}))},D.prototype.signoutPopupCallback=function(K,z){return z===void 0&&typeof K=="boolean"&&(z=K,K=null),this._popupNavigator.callback(K,z,"?").then((function(){u.Log.info("UserManager.signoutPopupCallback: successful")}))},D.prototype._signout=function(K,z){var X=this,Ee=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this._signoutStart(K,z,Ee).then((function(q){return X._signoutEnd(q.url)}))},D.prototype._signoutStart=function(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},z=this,X=arguments[1],Ee=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return X.prepare(Ee).then((function(q){return u.Log.debug("UserManager._signoutStart: got navigator window handle"),z._loadUser().then((function(Y){return u.Log.debug("UserManager._signoutStart: loaded current user from storage"),(z._settings.revokeAccessTokenOnSignout?z._revokeInternal(Y):Promise.resolve()).then((function(){var Te=K.id_token_hint||Y&&Y.id_token;return Te&&(u.Log.debug("UserManager._signoutStart: Setting id_token into signout request"),K.id_token_hint=Te),z.removeUser().then((function(){return u.Log.debug("UserManager._signoutStart: user removed, creating signout request"),z.createSignoutRequest(K).then((function(re){return u.Log.debug("UserManager._signoutStart: got signout request"),Ee.url=re.url,re.state&&(Ee.id=re.state.id),q.navigate(Ee)}))}))}))})).catch((function(Y){throw q.close&&(u.Log.debug("UserManager._signoutStart: Error after preparing navigator, closing navigator window"),q.close()),Y}))}))},D.prototype._signoutEnd=function(K){return this.processSignoutResponse(K).then((function(z){return u.Log.debug("UserManager._signoutEnd: got signout response"),z}))},D.prototype.revokeAccessToken=function(){var K=this;return this._loadUser().then((function(z){return K._revokeInternal(z,!0).then((function(X){if(X)return u.Log.debug("UserManager.revokeAccessToken: removing token properties from user and re-storing"),z.access_token=null,z.refresh_token=null,z.expires_at=null,z.token_type=null,K.storeUser(z).then((function(){u.Log.debug("UserManager.revokeAccessToken: user stored"),K._events.load(z)}))}))})).then((function(){u.Log.info("UserManager.revokeAccessToken: access token revoked successfully")}))},D.prototype._revokeInternal=function(K,z){var X=this;if(K){var Ee=K.access_token,q=K.refresh_token;return this._revokeAccessTokenInternal(Ee,z).then((function(Y){return X._revokeRefreshTokenInternal(q,z).then((function(Te){return Y||Te||u.Log.debug("UserManager.revokeAccessToken: no need to revoke due to no token(s), or JWT format"),Y||Te}))}))}return Promise.resolve(!1)},D.prototype._revokeAccessTokenInternal=function(K,z){return!K||K.indexOf(".")>=0?Promise.resolve(!1):this._tokenRevocationClient.revoke(K,z).then((function(){return!0}))},D.prototype._revokeRefreshTokenInternal=function(K,z){return K?this._tokenRevocationClient.revoke(K,z,"refresh_token").then((function(){return!0})):Promise.resolve(!1)},D.prototype.startSilentRenew=function(){this._silentRenewService.start()},D.prototype.stopSilentRenew=function(){this._silentRenewService.stop()},D.prototype._loadUser=function(){return this._userStore.get(this._userStoreKey).then((function(K){return K?(u.Log.debug("UserManager._loadUser: user storageString loaded"),f.User.fromStorageString(K)):(u.Log.debug("UserManager._loadUser: no user storageString"),null)}))},D.prototype.storeUser=function(K){if(K){u.Log.debug("UserManager.storeUser: storing user");var z=K.toStorageString();return this._userStore.set(this._userStoreKey,z)}return u.Log.debug("storeUser.storeUser: removing user"),this._userStore.remove(this._userStoreKey)},a(D,[{key:"_redirectNavigator",get:function(){return this.settings.redirectNavigator}},{key:"_popupNavigator",get:function(){return this.settings.popupNavigator}},{key:"_iframeNavigator",get:function(){return this.settings.iframeNavigator}},{key:"_userStore",get:function(){return this.settings.userStore}},{key:"events",get:function(){return this._events}},{key:"_userStoreKey",get:function(){return"user:"+this.settings.authority+":"+this.settings.client_id}}]),D})(c.OidcClient)},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.UserManagerSettings=void 0;var a=(function(){function R(T,A){for(var F=0;F<A.length;F++){var x=A[F];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(T,x.key,x)}}return function(T,A,F){return A&&R(T.prototype,A),F&&R(T,F),T}})(),u=(s(0),s(5)),c=s(40),h=s(41),f=s(43),p=s(6),g=s(1),y=s(8);function S(R,T){if(!(R instanceof T))throw new TypeError("Cannot call a class as a function")}function w(R,T){if(!R)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!T||typeof T!="object"&&typeof T!="function"?R:T}n.UserManagerSettings=(function(R){function T(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},F=A.popup_redirect_uri,x=A.popup_post_logout_redirect_uri,D=A.popupWindowFeatures,O=A.popupWindowTarget,K=A.silent_redirect_uri,z=A.silentRequestTimeout,X=A.automaticSilentRenew,Ee=X!==void 0&&X,q=A.validateSubOnSilentRenew,Y=q!==void 0&&q,Te=A.includeIdTokenInSilentRenew,re=Te===void 0||Te,$e=A.monitorSession,ze=$e===void 0||$e,ye=A.monitorAnonymousSession,Ve=ye!==void 0&&ye,pe=A.checkSessionInterval,De=pe===void 0?2e3:pe,$=A.stopCheckSessionOnError,G=$===void 0||$,ce=A.query_status_response_type,oe=A.revokeAccessTokenOnSignout,Fe=oe!==void 0&&oe,Ue=A.accessTokenExpiringNotificationTime,Je=Ue===void 0?60:Ue,He=A.redirectNavigator,he=He===void 0?new c.RedirectNavigator:He,fe=A.popupNavigator,Oe=fe===void 0?new h.PopupNavigator:fe,ie=A.iframeNavigator,j=ie===void 0?new f.IFrameNavigator:ie,N=A.userStore,L=N===void 0?new p.WebStorageStateStore({store:g.Global.sessionStorage}):N;S(this,T);var V=w(this,R.call(this,arguments[0]));return V._popup_redirect_uri=F,V._popup_post_logout_redirect_uri=x,V._popupWindowFeatures=D,V._popupWindowTarget=O,V._silent_redirect_uri=K,V._silentRequestTimeout=z,V._automaticSilentRenew=Ee,V._validateSubOnSilentRenew=Y,V._includeIdTokenInSilentRenew=re,V._accessTokenExpiringNotificationTime=Je,V._monitorSession=ze,V._monitorAnonymousSession=Ve,V._checkSessionInterval=De,V._stopCheckSessionOnError=G,ce?V._query_status_response_type=ce:arguments[0]&&arguments[0].response_type?V._query_status_response_type=y.SigninRequest.isOidc(arguments[0].response_type)?"id_token":"code":V._query_status_response_type="id_token",V._revokeAccessTokenOnSignout=Fe,V._redirectNavigator=he,V._popupNavigator=Oe,V._iframeNavigator=j,V._userStore=L,V}return(function(F,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);F.prototype=Object.create(x&&x.prototype,{constructor:{value:F,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(F,x):F.__proto__=x)})(T,R),a(T,[{key:"popup_redirect_uri",get:function(){return this._popup_redirect_uri}},{key:"popup_post_logout_redirect_uri",get:function(){return this._popup_post_logout_redirect_uri}},{key:"popupWindowFeatures",get:function(){return this._popupWindowFeatures}},{key:"popupWindowTarget",get:function(){return this._popupWindowTarget}},{key:"silent_redirect_uri",get:function(){return this._silent_redirect_uri}},{key:"silentRequestTimeout",get:function(){return this._silentRequestTimeout}},{key:"automaticSilentRenew",get:function(){return this._automaticSilentRenew}},{key:"validateSubOnSilentRenew",get:function(){return this._validateSubOnSilentRenew}},{key:"includeIdTokenInSilentRenew",get:function(){return this._includeIdTokenInSilentRenew}},{key:"accessTokenExpiringNotificationTime",get:function(){return this._accessTokenExpiringNotificationTime}},{key:"monitorSession",get:function(){return this._monitorSession}},{key:"monitorAnonymousSession",get:function(){return this._monitorAnonymousSession}},{key:"checkSessionInterval",get:function(){return this._checkSessionInterval}},{key:"stopCheckSessionOnError",get:function(){return this._stopCheckSessionOnError}},{key:"query_status_response_type",get:function(){return this._query_status_response_type}},{key:"revokeAccessTokenOnSignout",get:function(){return this._revokeAccessTokenOnSignout}},{key:"redirectNavigator",get:function(){return this._redirectNavigator}},{key:"popupNavigator",get:function(){return this._popupNavigator}},{key:"iframeNavigator",get:function(){return this._iframeNavigator}},{key:"userStore",get:function(){return this._userStore}}]),T})(u.OidcClientSettings)},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.RedirectNavigator=void 0;var a=(function(){function c(h,f){for(var p=0;p<f.length;p++){var g=f[p];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(h,g.key,g)}}return function(h,f,p){return f&&c(h.prototype,f),p&&c(h,p),h}})(),u=s(0);n.RedirectNavigator=(function(){function c(){(function(f,p){if(!(f instanceof p))throw new TypeError("Cannot call a class as a function")})(this,c)}return c.prototype.prepare=function(){return Promise.resolve(this)},c.prototype.navigate=function(f){return f&&f.url?(f.useReplaceToNavigate?window.location.replace(f.url):window.location=f.url,Promise.resolve()):(u.Log.error("RedirectNavigator.navigate: No url provided"),Promise.reject(new Error("No url provided")))},a(c,[{key:"url",get:function(){return window.location.href}}]),c})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.PopupNavigator=void 0;var a=s(0),u=s(42);n.PopupNavigator=(function(){function c(){(function(f,p){if(!(f instanceof p))throw new TypeError("Cannot call a class as a function")})(this,c)}return c.prototype.prepare=function(f){var p=new u.PopupWindow(f);return Promise.resolve(p)},c.prototype.callback=function(f,p,g){a.Log.debug("PopupNavigator.callback");try{return u.PopupWindow.notifyOpener(f,p,g),Promise.resolve()}catch(y){return Promise.reject(y)}},c})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.PopupWindow=void 0;var a=(function(){function h(f,p){for(var g=0;g<p.length;g++){var y=p[g];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(f,y.key,y)}}return function(f,p,g){return p&&h(f.prototype,p),g&&h(f,g),f}})(),u=s(0),c=s(3);n.PopupWindow=(function(){function h(f){var p=this;(function(w,R){if(!(w instanceof R))throw new TypeError("Cannot call a class as a function")})(this,h),this._promise=new Promise((function(S,w){p._resolve=S,p._reject=w}));var g=f.popupWindowTarget||"_blank",y=f.popupWindowFeatures||"location=no,toolbar=no,width=500,height=500,left=100,top=100;";this._popup=window.open("",g,y),this._popup&&(u.Log.debug("PopupWindow.ctor: popup successfully created"),this._checkForPopupClosedTimer=window.setInterval(this._checkForPopupClosed.bind(this),500))}return h.prototype.navigate=function(p){return this._popup?p&&p.url?(u.Log.debug("PopupWindow.navigate: Setting URL in popup"),this._id=p.id,this._id&&(window["popupCallback_"+p.id]=this._callback.bind(this)),this._popup.focus(),this._popup.window.location=p.url):(this._error("PopupWindow.navigate: no url provided"),this._error("No url provided")):this._error("PopupWindow.navigate: Error opening popup window"),this.promise},h.prototype._success=function(p){u.Log.debug("PopupWindow.callback: Successful response from popup window"),this._cleanup(),this._resolve(p)},h.prototype._error=function(p){u.Log.error("PopupWindow.error: ",p),this._cleanup(),this._reject(new Error(p))},h.prototype.close=function(){this._cleanup(!1)},h.prototype._cleanup=function(p){u.Log.debug("PopupWindow.cleanup"),window.clearInterval(this._checkForPopupClosedTimer),this._checkForPopupClosedTimer=null,delete window["popupCallback_"+this._id],this._popup&&!p&&this._popup.close(),this._popup=null},h.prototype._checkForPopupClosed=function(){this._popup&&!this._popup.closed||this._error("Popup window closed")},h.prototype._callback=function(p,g){this._cleanup(g),p?(u.Log.debug("PopupWindow.callback success"),this._success({url:p})):(u.Log.debug("PopupWindow.callback: Invalid response from popup"),this._error("Invalid response from popup"))},h.notifyOpener=function(p,g,y){if(window.opener){if(p=p||window.location.href){var S=c.UrlUtility.parseUrlFragment(p,y);if(S.state){var w="popupCallback_"+S.state,R=window.opener[w];R?(u.Log.debug("PopupWindow.notifyOpener: passing url message to opener"),R(p,g)):u.Log.warn("PopupWindow.notifyOpener: no matching callback found on opener")}else u.Log.warn("PopupWindow.notifyOpener: no state found in response url")}}else u.Log.warn("PopupWindow.notifyOpener: no window.opener. Can't complete notification.")},a(h,[{key:"promise",get:function(){return this._promise}}]),h})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.IFrameNavigator=void 0;var a=s(0),u=s(44);n.IFrameNavigator=(function(){function c(){(function(f,p){if(!(f instanceof p))throw new TypeError("Cannot call a class as a function")})(this,c)}return c.prototype.prepare=function(f){var p=new u.IFrameWindow(f);return Promise.resolve(p)},c.prototype.callback=function(f){a.Log.debug("IFrameNavigator.callback");try{return u.IFrameWindow.notifyParent(f),Promise.resolve()}catch(p){return Promise.reject(p)}},c})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.IFrameWindow=void 0;var a=(function(){function c(h,f){for(var p=0;p<f.length;p++){var g=f[p];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(h,g.key,g)}}return function(h,f,p){return f&&c(h.prototype,f),p&&c(h,p),h}})(),u=s(0);n.IFrameWindow=(function(){function c(h){var f=this;(function(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")})(this,c),this._promise=new Promise((function(p,g){f._resolve=p,f._reject=g})),this._boundMessageEvent=this._message.bind(this),window.addEventListener("message",this._boundMessageEvent,!1),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.width=0,this._frame.height=0,window.document.body.appendChild(this._frame)}return c.prototype.navigate=function(f){if(f&&f.url){var p=f.silentRequestTimeout||1e4;u.Log.debug("IFrameWindow.navigate: Using timeout of:",p),this._timer=window.setTimeout(this._timeout.bind(this),p),this._frame.src=f.url}else this._error("No url provided");return this.promise},c.prototype._success=function(f){this._cleanup(),u.Log.debug("IFrameWindow: Successful response from frame window"),this._resolve(f)},c.prototype._error=function(f){this._cleanup(),u.Log.error(f),this._reject(new Error(f))},c.prototype.close=function(){this._cleanup()},c.prototype._cleanup=function(){this._frame&&(u.Log.debug("IFrameWindow: cleanup"),window.removeEventListener("message",this._boundMessageEvent,!1),window.clearTimeout(this._timer),window.document.body.removeChild(this._frame),this._timer=null,this._frame=null,this._boundMessageEvent=null)},c.prototype._timeout=function(){u.Log.debug("IFrameWindow.timeout"),this._error("Frame window timed out")},c.prototype._message=function(f){if(u.Log.debug("IFrameWindow.message"),this._timer&&f.origin===this._origin&&f.source===this._frame.contentWindow&&typeof f.data=="string"&&(f.data.startsWith("http://")||f.data.startsWith("https://"))){var p=f.data;p?this._success({url:p}):this._error("Invalid response from frame")}},c.notifyParent=function(f){u.Log.debug("IFrameWindow.notifyParent"),(f=f||window.location.href)&&(u.Log.debug("IFrameWindow.notifyParent: posting url message to parent"),window.parent.postMessage(f,location.protocol+"//"+location.host))},a(c,[{key:"promise",get:function(){return this._promise}},{key:"_origin",get:function(){return location.protocol+"//"+location.host}}]),c})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.UserManagerEvents=void 0;var a=s(0),u=s(16),c=s(17);n.UserManagerEvents=(function(h){function f(p){(function(S,w){if(!(S instanceof w))throw new TypeError("Cannot call a class as a function")})(this,f);var g=(function(S,w){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!w||typeof w!="object"&&typeof w!="function"?S:w})(this,h.call(this,p));return g._userLoaded=new c.Event("User loaded"),g._userUnloaded=new c.Event("User unloaded"),g._silentRenewError=new c.Event("Silent renew error"),g._userSignedIn=new c.Event("User signed in"),g._userSignedOut=new c.Event("User signed out"),g._userSessionChanged=new c.Event("User session changed"),g}return(function(g,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);g.prototype=Object.create(y&&y.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(g,y):g.__proto__=y)})(f,h),f.prototype.load=function(g){var y=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];a.Log.debug("UserManagerEvents.load"),h.prototype.load.call(this,g),y&&this._userLoaded.raise(g)},f.prototype.unload=function(){a.Log.debug("UserManagerEvents.unload"),h.prototype.unload.call(this),this._userUnloaded.raise()},f.prototype.addUserLoaded=function(g){this._userLoaded.addHandler(g)},f.prototype.removeUserLoaded=function(g){this._userLoaded.removeHandler(g)},f.prototype.addUserUnloaded=function(g){this._userUnloaded.addHandler(g)},f.prototype.removeUserUnloaded=function(g){this._userUnloaded.removeHandler(g)},f.prototype.addSilentRenewError=function(g){this._silentRenewError.addHandler(g)},f.prototype.removeSilentRenewError=function(g){this._silentRenewError.removeHandler(g)},f.prototype._raiseSilentRenewError=function(g){a.Log.debug("UserManagerEvents._raiseSilentRenewError",g.message),this._silentRenewError.raise(g)},f.prototype.addUserSignedIn=function(g){this._userSignedIn.addHandler(g)},f.prototype.removeUserSignedIn=function(g){this._userSignedIn.removeHandler(g)},f.prototype._raiseUserSignedIn=function(){a.Log.debug("UserManagerEvents._raiseUserSignedIn"),this._userSignedIn.raise()},f.prototype.addUserSignedOut=function(g){this._userSignedOut.addHandler(g)},f.prototype.removeUserSignedOut=function(g){this._userSignedOut.removeHandler(g)},f.prototype._raiseUserSignedOut=function(){a.Log.debug("UserManagerEvents._raiseUserSignedOut"),this._userSignedOut.raise()},f.prototype.addUserSessionChanged=function(g){this._userSessionChanged.addHandler(g)},f.prototype.removeUserSessionChanged=function(g){this._userSessionChanged.removeHandler(g)},f.prototype._raiseUserSessionChanged=function(){a.Log.debug("UserManagerEvents._raiseUserSessionChanged"),this._userSessionChanged.raise()},f})(u.AccessTokenEvents)},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.Timer=void 0;var a=(function(){function g(y,S){for(var w=0;w<S.length;w++){var R=S[w];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(y,R.key,R)}}return function(y,S,w){return S&&g(y.prototype,S),w&&g(y,w),y}})(),u=s(0),c=s(1),h=s(17);function f(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")}function p(g,y){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!y||typeof y!="object"&&typeof y!="function"?g:y}n.Timer=(function(g){function y(S){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c.Global.timer,R=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;f(this,y);var T=p(this,g.call(this,S));return T._timer=w,T._nowFunc=R||function(){return Date.now()/1e3},T}return(function(w,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof R);w.prototype=Object.create(R&&R.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),R&&(Object.setPrototypeOf?Object.setPrototypeOf(w,R):w.__proto__=R)})(y,g),y.prototype.init=function(w){w<=0&&(w=1),w=parseInt(w);var R=this.now+w;if(this.expiration===R&&this._timerHandle)u.Log.debug("Timer.init timer "+this._name+" skipping initialization since already initialized for expiration:",this.expiration);else{this.cancel(),u.Log.debug("Timer.init timer "+this._name+" for duration:",w),this._expiration=R;var T=5;w<T&&(T=w),this._timerHandle=this._timer.setInterval(this._callback.bind(this),1e3*T)}},y.prototype.cancel=function(){this._timerHandle&&(u.Log.debug("Timer.cancel: ",this._name),this._timer.clearInterval(this._timerHandle),this._timerHandle=null)},y.prototype._callback=function(){var w=this._expiration-this.now;u.Log.debug("Timer.callback; "+this._name+" timer expires in:",w),this._expiration<=this.now&&(this.cancel(),g.prototype.raise.call(this))},a(y,[{key:"now",get:function(){return parseInt(this._nowFunc())}},{key:"expiration",get:function(){return this._expiration}}]),y})(h.Event)},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.SilentRenewService=void 0;var a=s(0);n.SilentRenewService=(function(){function u(c){(function(f,p){if(!(f instanceof p))throw new TypeError("Cannot call a class as a function")})(this,u),this._userManager=c}return u.prototype.start=function(){this._callback||(this._callback=this._tokenExpiring.bind(this),this._userManager.events.addAccessTokenExpiring(this._callback),this._userManager.getUser().then((function(h){})).catch((function(h){a.Log.error("SilentRenewService.start: Error from getUser:",h.message)})))},u.prototype.stop=function(){this._callback&&(this._userManager.events.removeAccessTokenExpiring(this._callback),delete this._callback)},u.prototype._tokenExpiring=function(){var h=this;this._userManager.signinSilent().then((function(f){a.Log.debug("SilentRenewService._tokenExpiring: Silent token renewal successful")}),(function(f){a.Log.error("SilentRenewService._tokenExpiring: Error from signinSilent:",f.message),h._userManager.events._raiseSilentRenewError(f)}))},u})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.CordovaPopupNavigator=void 0;var a=s(21);n.CordovaPopupNavigator=(function(){function u(){(function(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")})(this,u)}return u.prototype.prepare=function(h){var f=new a.CordovaPopupWindow(h);return Promise.resolve(f)},u})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.CordovaIFrameNavigator=void 0;var a=s(21);n.CordovaIFrameNavigator=(function(){function u(){(function(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")})(this,u)}return u.prototype.prepare=function(h){h.popupWindowFeatures="hidden=yes";var f=new a.CordovaPopupWindow(h);return Promise.resolve(f)},u})()},function(t,n,s){Object.defineProperty(n,"__esModule",{value:!0}),n.Version="1.11.6"}])}))})(oidcClient_min$1)),oidcClient_min$1.exports}var oidcClient_minExports=requireOidcClient_min();function processErrorResponse(i,e){throw i.error==="invalid_redirect_uri"?new Error(`Dynamic client registration failed: the provided redirect uri [${e.redirectUrl?.toString()}] is invalid - ${i.error_description??""}`):i.error==="invalid_client_metadata"?new Error(`Dynamic client registration failed: the provided client metadata ${JSON.stringify(e)} is invalid - ${i.error_description??""}`):new Error(`Dynamic client registration failed: ${i.error} - ${i.error_description??""}`)}function hasClientId(i){return typeof i.client_id=="string"}function hasRedirectUri(i){return Array.isArray(i.redirect_uris)&&i.redirect_uris.every(e=>typeof e=="string")}function validateRegistrationResponse(i,e){if(!hasClientId(i))throw new Error(`Dynamic client registration failed: no client_id has been found on ${JSON.stringify(i)}`);if(e.redirectUrl&&hasRedirectUri(i)&&i.redirect_uris[0]!==e.redirectUrl.toString())throw new Error(`Dynamic client registration failed: the returned redirect URIs ${JSON.stringify(i.redirect_uris)} don't match the provided ${JSON.stringify([e.redirectUrl.toString()])}`);return!0}async function registerClient(i,e){if(!e.registrationEndpoint)throw new Error("Dynamic Registration could not be completed because the issuer has no registration endpoint.");if(!Array.isArray(e.idTokenSigningAlgValuesSupported))throw new Error("The OIDC issuer discovery profile is missing the 'id_token_signing_alg_values_supported' value, which is mandatory.");const t=determineSigningAlg(e.idTokenSigningAlgValuesSupported,PREFERRED_SIGNING_ALG),n={client_name:i.clientName,application_type:"web",redirect_uris:[i.redirectUrl?.toString()],subject_type:"public",token_endpoint_auth_method:"client_secret_basic",id_token_signed_response_alg:t,grant_types:["authorization_code","refresh_token"]},s={"Content-Type":"application/json"},a=await fetch(e.registrationEndpoint.toString(),{method:"POST",headers:s,body:JSON.stringify(n)});if(a.ok){const u=await a.json();return validateRegistrationResponse(u,i),{clientId:u.client_id,clientSecret:u.client_secret,expiresAt:u.client_secret_expires_at,idTokenSignedResponseAlg:u.id_token_signed_response_alg,clientType:"dynamic"}}throw a.status===400&&processErrorResponse(await a.json(),i),new Error(`Dynamic client registration failed: the server returned ${a.status} ${a.statusText} - ${await a.text()}`)}function hasError(i){return i.error!==void 0&&typeof i.error=="string"}function hasErrorDescription(i){return i.error_description!==void 0&&typeof i.error_description=="string"}function hasErrorUri(i){return i.error_uri!==void 0&&typeof i.error_uri=="string"}function hasAccessToken(i){return i.access_token!==void 0&&typeof i.access_token=="string"}function hasIdToken(i){return i.id_token!==void 0&&typeof i.id_token=="string"}function hasRefreshToken(i){return i.refresh_token!==void 0&&typeof i.refresh_token=="string"}function hasTokenType(i){return i.token_type!==void 0&&typeof i.token_type=="string"}function hasExpiresIn(i){return i.expires_in===void 0||typeof i.expires_in=="number"}function validatePreconditions(i,e){if(e.grantType&&(!i.grantTypesSupported||!i.grantTypesSupported.includes(e.grantType)))throw new Error(`The issuer [${i.issuer}] does not support the [${e.grantType}] grant`);if(!i.tokenEndpoint)throw new Error(`This issuer [${i.issuer}] does not have a token endpoint`)}function validateTokenEndpointResponse(i,e){if(hasError(i))throw new OidcProviderError(`Token endpoint returned error [${i.error}]${hasErrorDescription(i)?`: ${i.error_description}`:""}${hasErrorUri(i)?` (see ${i.error_uri})`:""}`,i.error,hasErrorDescription(i)?i.error_description:void 0);if(!hasAccessToken(i))throw new InvalidResponseError(["access_token"]);if(!hasIdToken(i))throw new InvalidResponseError(["id_token"]);if(!hasTokenType(i))throw new InvalidResponseError(["token_type"]);if(!hasExpiresIn(i))throw new InvalidResponseError(["expires_in"]);if(!e&&i.token_type.toLowerCase()!=="bearer")throw new Error(`Invalid token endpoint response: requested a [Bearer] token, but got a 'token_type' value of [${i.token_type}].`);return i}async function getTokens(i,e,t,n){validatePreconditions(i,t);const s={"content-type":"application/x-www-form-urlencoded"};let a;n&&(a=await generateDpopKeyPair(),s.DPoP=await createDpopHeader(i.tokenEndpoint,"POST",a)),e.clientSecret&&(s.Authorization=`Basic ${btoa(`${e.clientId}:${e.clientSecret}`)}`);const u={grant_type:t.grantType,redirect_uri:t.redirectUrl,code:t.code,code_verifier:t.codeVerifier,client_id:e.clientId},c={method:"POST",headers:s,body:new URLSearchParams(u).toString()},f=await(await fetch(i.tokenEndpoint,c)).json(),p=validateTokenEndpointResponse(f,n),{webId:g,clientId:y}=await getWebidFromTokenPayload(p.id_token,i.jwksUri,i.issuer,e.clientId);return{accessToken:p.access_token,idToken:p.id_token,refreshToken:hasRefreshToken(p)?p.refresh_token:void 0,webId:g,clientId:y,dpopKey:a,expiresIn:p.expires_in}}const isValidUrl=i=>{try{return new URL(i),!0}catch{return!1}};async function refresh(i,e,t,n){if(t.clientId===void 0)throw new Error("No client ID available when trying to refresh the access token.");const s={grant_type:"refresh_token",refresh_token:i};let a={};n!==void 0&&(a={DPoP:await createDpopHeader(e.tokenEndpoint,"POST",n)});let u={};t.clientSecret!==void 0?u={Authorization:`Basic ${btoa(`${t.clientId}:${t.clientSecret}`)}`}:isValidUrl(t.clientId)&&(s.client_id=t.clientId);const c=await fetch(e.tokenEndpoint,{method:"POST",body:new URLSearchParams(s).toString(),headers:{...a,...u,"Content-Type":"application/x-www-form-urlencoded"}});let h;try{h=await c.json()}catch{throw new Error(`The token endpoint of issuer ${e.issuer} returned a malformed response.`)}const f=validateTokenEndpointResponse(h,n!==void 0),{webId:p}=await getWebidFromTokenPayload(f.id_token,e.jwksUri,e.issuer,t.clientId);return{accessToken:f.access_token,idToken:f.id_token,refreshToken:typeof f.refresh_token=="string"?f.refresh_token:void 0,webId:p,dpopKey:n,expiresIn:f.expires_in}}function normalizeCallbackUrl(i){const e=removeOpenIdParams(i);return e.hash="",i.includes(`${e.origin}/`)?e.href:`${e.origin}${e.href.substring(e.origin.length+1)}`}async function clearOidcPersistentStorage(){await new oidcClient_minExports.OidcClient({response_mode:"query"}).clearStaleState(new oidcClient_minExports.WebStorageStateStore({}));const e=window.localStorage,t=[];for(let n=0;n<=e.length;n+=1){const s=e.key(n);s&&(s.match(/^oidc\..+$/)||s.match(/^solidClientAuthenticationUser:.+$/))&&t.push(s)}t.forEach(n=>e.removeItem(n))}class StorageUtilityBrowser extends StorageUtility{constructor(e,t){super(e,t)}}class ClientAuthentication extends ClientAuthentication$1{login=async(e,t)=>{e.prompt!=="none"&&await this.sessionInfoManager.clear(e.sessionId);const n=e.redirectUrl??normalizeCallbackUrl(window.location.href);if(!isValidRedirectUrl(n))throw new Error(`${n} is not a valid redirect URL, it is either a malformed IRI, includes a hash fragment, or reserved query parameters ('code' or 'state').`);await this.loginHandler.handle({...e,redirectUrl:n,clientName:e.clientName??e.clientId,eventEmitter:t})};validateCurrentSession=async e=>{const t=await this.sessionInfoManager.get(e);return t===void 0||t.clientAppId===void 0||t.issuer===void 0?null:t};handleIncomingRedirect=async(e,t)=>{try{const n=await this.redirectHandler.handle(e,t,void 0);return this.fetch=n.fetch.bind(window),this.boundLogout=n.getLogoutUrl,await this.cleanUrlAfterRedirect(e),{isLoggedIn:n.isLoggedIn,webId:n.webId,sessionId:n.sessionId,expirationDate:n.expirationDate,clientAppId:n.clientAppId}}catch(n){await this.cleanUrlAfterRedirect(e),t.emit(EVENTS.ERROR,"redirect",n);return}};async cleanUrlAfterRedirect(e){const t=removeOpenIdParams(e).href;for(window.history.replaceState(null,"",t);window.location.href!==t;)await new Promise(n=>{setTimeout(()=>n(),1)})}}function hasIssuer(i){return typeof i.oidcIssuer=="string"}function hasRedirectUrl(i){return typeof i.redirectUrl=="string"}class OidcLoginHandler{storageUtility;oidcHandler;issuerConfigFetcher;clientRegistrar;constructor(e,t,n,s){this.storageUtility=e,this.oidcHandler=t,this.issuerConfigFetcher=n,this.clientRegistrar=s,this.storageUtility=e,this.oidcHandler=t,this.issuerConfigFetcher=n,this.clientRegistrar=s}async canHandle(e){return hasIssuer(e)&&hasRedirectUrl(e)}async handle(e){if(!hasIssuer(e))throw new ConfigurationError(`OidcLoginHandler requires an OIDC issuer: missing property 'oidcIssuer' in ${JSON.stringify(e)}`);if(!hasRedirectUrl(e))throw new ConfigurationError(`OidcLoginHandler requires a redirect URL: missing property 'redirectUrl' in ${JSON.stringify(e)}`);const t=await this.issuerConfigFetcher.fetchConfig(e.oidcIssuer),n=await handleRegistration(e,t,this.storageUtility,this.clientRegistrar),s={issuer:t.issuer,dpop:e.tokenType.toLowerCase()==="dpop",...e,issuerConfiguration:t,client:n,scopes:normalizeScopes(e.customScopes)};return this.oidcHandler.handle(s)}}class AuthorizationCodeWithPkceOidcHandler extends AuthorizationCodeWithPkceOidcHandlerBase{async handle(e){const t={authority:e.issuer.toString(),client_id:e.client.clientId,client_secret:e.client.clientSecret,redirect_uri:e.redirectUrl,response_type:"code",scope:e.scopes.join(" "),filterProtocolClaims:!0,loadUserInfo:!1,code_verifier:!0,prompt:e.prompt??"consent"},n=new oidcClient_minExports.OidcClient(t);try{const s=await n.createSigninRequest();return await this.setupRedirectHandler({oidcLoginOptions:e,state:s.state._id,codeVerifier:s.state._code_verifier,targetUrl:s.url.toString()})}catch(s){console.error(s)}}}const WELL_KNOWN_OPENID_CONFIG=".well-known/openid-configuration",issuerConfigKeyMap={issuer:{toKey:"issuer",convertToUrl:!0},authorization_endpoint:{toKey:"authorizationEndpoint",convertToUrl:!0},token_endpoint:{toKey:"tokenEndpoint",convertToUrl:!0},userinfo_endpoint:{toKey:"userinfoEndpoint",convertToUrl:!0},jwks_uri:{toKey:"jwksUri",convertToUrl:!0},registration_endpoint:{toKey:"registrationEndpoint",convertToUrl:!0},end_session_endpoint:{toKey:"endSessionEndpoint",convertToUrl:!0},scopes_supported:{toKey:"scopesSupported"},response_types_supported:{toKey:"responseTypesSupported"},response_modes_supported:{toKey:"responseModesSupported"},grant_types_supported:{toKey:"grantTypesSupported"},acr_values_supported:{toKey:"acrValuesSupported"},subject_types_supported:{toKey:"subjectTypesSupported"},id_token_signing_alg_values_supported:{toKey:"idTokenSigningAlgValuesSupported"},id_token_encryption_alg_values_supported:{toKey:"idTokenEncryptionAlgValuesSupported"},id_token_encryption_enc_values_supported:{toKey:"idTokenEncryptionEncValuesSupported"},userinfo_signing_alg_values_supported:{toKey:"userinfoSigningAlgValuesSupported"},userinfo_encryption_alg_values_supported:{toKey:"userinfoEncryptionAlgValuesSupported"},userinfo_encryption_enc_values_supported:{toKey:"userinfoEncryptionEncValuesSupported"},request_object_signing_alg_values_supported:{toKey:"requestObjectSigningAlgValuesSupported"},request_object_encryption_alg_values_supported:{toKey:"requestObjectEncryptionAlgValuesSupported"},request_object_encryption_enc_values_supported:{toKey:"requestObjectEncryptionEncValuesSupported"},token_endpoint_auth_methods_supported:{toKey:"tokenEndpointAuthMethodsSupported"},token_endpoint_auth_signing_alg_values_supported:{toKey:"tokenEndpointAuthSigningAlgValuesSupported"},display_values_supported:{toKey:"displayValuesSupported"},claim_types_supported:{toKey:"claimTypesSupported"},claims_supported:{toKey:"claimsSupported"},service_documentation:{toKey:"serviceDocumentation"},claims_locales_supported:{toKey:"claimsLocalesSupported"},ui_locales_supported:{toKey:"uiLocalesSupported"},claims_parameter_supported:{toKey:"claimsParameterSupported"},request_parameter_supported:{toKey:"requestParameterSupported"},request_uri_parameter_supported:{toKey:"requestUriParameterSupported"},require_request_uri_registration:{toKey:"requireRequestUriRegistration"},op_policy_uri:{toKey:"opPolicyUri",convertToUrl:!0},op_tos_uri:{toKey:"opTosUri",convertToUrl:!0}};function processConfig(i){const e={};return Object.keys(i).forEach(t=>{issuerConfigKeyMap[t]&&(e[issuerConfigKeyMap[t].toKey]=i[t])}),Array.isArray(e.scopesSupported)||(e.scopesSupported=["openid"]),e}class IssuerConfigFetcher{storageUtility;constructor(e){this.storageUtility=e,this.storageUtility=e}static getLocalStorageKey(e){return`issuerConfig:${e}`}async fetchConfig(e){let t;const n=new URL(WELL_KNOWN_OPENID_CONFIG,e.endsWith("/")?e:`${e}/`).href,s=await fetch(n);try{t=processConfig(await s.json())}catch(a){throw new ConfigurationError(`[${e.toString()}] has an invalid configuration: ${a.message}`)}return await this.storageUtility.set(IssuerConfigFetcher.getLocalStorageKey(e),JSON.stringify(t)),t}}async function clear(i,e){await clear$1(i,e),await clearOidcPersistentStorage()}class SessionInfoManager extends SessionInfoManagerBase{async get(e){const[t,n,s,a,u,c,h,f]=await Promise.all([this.storageUtility.getForUser(e,"isLoggedIn",{secure:!0}),this.storageUtility.getForUser(e,"webId",{secure:!0}),this.storageUtility.getForUser(e,"clientId",{secure:!1}),this.storageUtility.getForUser(e,"clientSecret",{secure:!1}),this.storageUtility.getForUser(e,"redirectUrl",{secure:!1}),this.storageUtility.getForUser(e,"refreshToken",{secure:!0}),this.storageUtility.getForUser(e,"issuer",{secure:!1}),this.storageUtility.getForUser(e,"tokenType",{secure:!1})]);if(typeof u=="string"&&!isValidRedirectUrl(u)){await Promise.all([this.storageUtility.deleteAllUserData(e,{secure:!1}),this.storageUtility.deleteAllUserData(e,{secure:!0})]);return}if(f!==void 0&&!isSupportedTokenType(f))throw new Error(`Tokens of type [${f}] are not supported.`);if(!(s===void 0&&t===void 0&&n===void 0&&c===void 0))return{sessionId:e,webId:n,isLoggedIn:t==="true",redirectUrl:u,refreshToken:c,issuer:h,clientAppId:s,clientAppSecret:a,tokenType:f??"DPoP"}}async clear(e){return clear(e,this.storageUtility)}}class FallbackRedirectHandler{async canHandle(e){try{return new URL(e),!0}catch(t){throw new Error(`[${e}] is not a valid URL, and cannot be used as a redirect URL: ${t}`)}}async handle(e){return getUnauthenticatedSession()}}class AuthCodeRedirectHandler{storageUtility;sessionInfoManager;issuerConfigFetcher;clientRegistrar;tokerRefresher;constructor(e,t,n,s,a){this.storageUtility=e,this.sessionInfoManager=t,this.issuerConfigFetcher=n,this.clientRegistrar=s,this.tokerRefresher=a,this.storageUtility=e,this.sessionInfoManager=t,this.issuerConfigFetcher=n,this.clientRegistrar=s,this.tokerRefresher=a}async canHandle(e){try{const t=new URL(e);return t.searchParams.get("code")!==null&&t.searchParams.get("state")!==null}catch(t){throw new Error(`[${e}] is not a valid URL, and cannot be used as a redirect URL: ${t}`)}}async handle(e,t){if(!await this.canHandle(e))throw new Error(`AuthCodeRedirectHandler cannot handle [${e}]: it is missing one of [code, state].`);const n=new URL(e),s=n.searchParams.get("state"),a=await this.storageUtility.getForUser(s,"sessionId",{errorIfNull:!0}),{issuerConfig:u,codeVerifier:c,redirectUrl:h,dpop:f}=await loadOidcContextFromStorage(a,this.storageUtility,this.issuerConfigFetcher),p=n.searchParams.get("iss");if(typeof p=="string"&&p!==u.issuer)throw new Error(`The value of the iss parameter (${p}) does not match the issuer identifier of the authorization server (${u.issuer}). See [rfc9207](https://www.rfc-editor.org/rfc/rfc9207.html#section-2.3-3.1.1)`);if(c===void 0)throw new Error(`The code verifier for session ${a} is missing from storage.`);if(h===void 0)throw new Error(`The redirect URL for session ${a} is missing from storage.`);const g=await this.clientRegistrar.getClient({sessionId:a},u),y=Date.now(),S=await getTokens(u,g,{grantType:"authorization_code",code:n.searchParams.get("code"),codeVerifier:c,redirectUrl:h},f);window.localStorage.removeItem(`oidc.${s}`);let w;S.refreshToken!==void 0&&(w={sessionId:a,refreshToken:S.refreshToken,tokenRefresher:this.tokerRefresher});const R=buildAuthenticatedFetch(S.accessToken,{dpopKey:S.dpopKey,refreshOptions:w,eventEmitter:t,expiresIn:S.expiresIn});await saveSessionInfoToStorage(this.storageUtility,a,S.webId,S.clientId,"true",void 0,!0);const T=await this.sessionInfoManager.get(a);if(!T)throw new Error(`Could not retrieve session: [${a}].`);return Object.assign(T,{fetch:R,getLogoutUrl:maybeBuildRpInitiatedLogout({idTokenHint:S.idToken,endSessionEndpoint:u.endSessionEndpoint}),expirationDate:typeof S.expiresIn=="number"?y+S.expiresIn*1e3:void 0})}}class AggregateRedirectHandler extends AggregateHandler{constructor(e){super(e)}}class BrowserStorage{get storage(){return window.localStorage}async get(e){return this.storage.getItem(e)||void 0}async set(e,t){this.storage.setItem(e,t)}async delete(e){this.storage.removeItem(e)}}class Redirector{redirect(e,t){t&&t.handleRedirect?t.handleRedirect(e):t&&t.redirectByReplacingState?window.history.replaceState({},"",e):window.location.href=e}}class ClientRegistrar{storageUtility;constructor(e){this.storageUtility=e,this.storageUtility=e}async getClient(e,t){const[n,s,a,u,c]=await Promise.all([this.storageUtility.getForUser(e.sessionId,"clientId",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"clientSecret",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"expiresAt",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"clientName",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"clientType",{secure:!1})]),h=a!==void 0?Number.parseInt(a,10):-1,f=s!==void 0&&h!==0&&Math.floor(Date.now()/1e3)>h;if(n&&isKnownClientType(c)&&!f)return s!==void 0?{clientId:n,clientSecret:s,clientName:u,clientType:"dynamic",expiresAt:h}:{clientId:n,clientName:u,clientType:c};try{const p=await registerClient(e,t),g={clientId:p.clientId,clientType:"dynamic"};return p.clientSecret!==void 0&&(g.clientSecret=p.clientSecret,g.expiresAt=String(p.expiresAt)),p.idTokenSignedResponseAlg&&(g.idTokenSignedResponseAlg=p.idTokenSignedResponseAlg),await this.storageUtility.setForUser(e.sessionId,g,{secure:!1}),p}catch(p){throw new Error("Client registration failed.",{cause:p})}}}class ErrorOidcHandler{async canHandle(e){try{return new URL(e).searchParams.has("error")}catch(t){throw new Error(`[${e}] is not a valid URL, and cannot be used as a redirect URL: ${t}`)}}async handle(e,t){if(t!==void 0){const n=new URL(e),s=n.searchParams.get("error"),a=n.searchParams.get("error_description");t.emit(EVENTS.ERROR,s,a)}return getUnauthenticatedSession()}}class TokenRefresher{storageUtility;issuerConfigFetcher;clientRegistrar;constructor(e,t,n){this.storageUtility=e,this.issuerConfigFetcher=t,this.clientRegistrar=n,this.storageUtility=e,this.issuerConfigFetcher=t,this.clientRegistrar=n}async refresh(e,t,n,s){const a=await loadOidcContextFromStorage(e,this.storageUtility,this.issuerConfigFetcher),u=await this.clientRegistrar.getClient({sessionId:e},a.issuerConfig);if(t===void 0)throw new Error(`Session [${e}] has no refresh token to allow it to refresh its access token.`);if(a.dpop&&n===void 0)throw new Error(`For session [${e}], the key bound to the DPoP access token must be provided to refresh said access token.`);const c=await refresh(t,a.issuerConfig,u,n);return c.refreshToken!==void 0&&s?.emit(EVENTS.NEW_REFRESH_TOKEN,c.refreshToken),c}}function getClientAuthenticationWithDependencies(i){const e=new InMemoryStorage,t=i.secureStorage||e,n=i.insecureStorage||new BrowserStorage,s=new StorageUtilityBrowser(t,n),a=new IssuerConfigFetcher(s),u=new ClientRegistrar(s),c=new SessionInfoManager(s),h=new TokenRefresher(s,a,u),f=new Redirector,p=new OidcLoginHandler(s,new AuthorizationCodeWithPkceOidcHandler(s,f),a,u),g=new AggregateRedirectHandler([new ErrorOidcHandler,new AuthCodeRedirectHandler(s,c,a,u,h),new FallbackRedirectHandler]);return new ClientAuthentication(p,g,new IWaterfallLogoutHandler(c,f),c,a)}const KEY_CURRENT_SESSION=`${SOLID_CLIENT_AUTHN_KEY_PREFIX}currentSession`,KEY_CURRENT_URL=`${SOLID_CLIENT_AUTHN_KEY_PREFIX}currentUrl`;async function silentlyAuthenticate(i,e,t){const n=await e.validateCurrentSession(i);return n!==null?(window.localStorage.setItem(KEY_CURRENT_URL,window.location.href),await e.login({sessionId:i,prompt:"none",oidcIssuer:n.issuer,redirectUrl:n.redirectUrl,clientId:n.clientAppId,clientSecret:n.clientAppSecret,tokenType:n.tokenType??"DPoP"},t.events),!0):!1}function isLoggedIn(i){return!!i?.isLoggedIn}class Session{info;events;clientAuthentication;tokenRequestInProgress=!1;constructor(e={},t=void 0){this.events=new EventEmitter,e.clientAuthentication?this.clientAuthentication=e.clientAuthentication:e.secureStorage&&e.insecureStorage?this.clientAuthentication=getClientAuthenticationWithDependencies({secureStorage:e.secureStorage,insecureStorage:e.insecureStorage}):this.clientAuthentication=getClientAuthenticationWithDependencies({}),e.sessionInfo?this.info={sessionId:e.sessionInfo.sessionId,isLoggedIn:!1,webId:e.sessionInfo.webId,clientAppId:e.sessionInfo.clientAppId}:this.info={sessionId:t??v4(),isLoggedIn:!1},this.events.on(EVENTS.LOGIN,()=>window.localStorage.setItem(KEY_CURRENT_SESSION,this.info.sessionId)),this.events.on(EVENTS.SESSION_EXPIRED,()=>this.internalLogout(!1)),this.events.on(EVENTS.ERROR,()=>this.internalLogout(!1))}login=async e=>(await this.clientAuthentication.login({sessionId:this.info.sessionId,...e,tokenType:e.tokenType??"DPoP"},this.events),new Promise(()=>{}));fetch=(e,t)=>this.clientAuthentication.fetch(e,t);internalLogout=async(e,t)=>{window.localStorage.removeItem(KEY_CURRENT_SESSION),await this.clientAuthentication.logout(this.info.sessionId,t),this.info.isLoggedIn=!1,e&&this.events.emit(EVENTS.LOGOUT)};logout=async e=>this.internalLogout(!0,e);handleIncomingRedirect=async(e={})=>{if(this.info.isLoggedIn)return this.info;if(this.tokenRequestInProgress)return;const t=typeof e=="string"?{url:e}:e,n=t.url??window.location.href;this.tokenRequestInProgress=!0;const s=await this.clientAuthentication.handleIncomingRedirect(n,this.events);if(isLoggedIn(s)){this.setSessionInfo(s);const a=window.localStorage.getItem(KEY_CURRENT_URL);a===null?this.events.emit(EVENTS.LOGIN):(window.localStorage.removeItem(KEY_CURRENT_URL),this.events.emit(EVENTS.SESSION_RESTORED,a))}else if(t.restorePreviousSession===!0){const a=window.localStorage.getItem(KEY_CURRENT_SESSION);if(a!==null&&await silentlyAuthenticate(a,this.clientAuthentication,this))return new Promise(()=>{})}return this.tokenRequestInProgress=!1,s};setSessionInfo(e){this.info.isLoggedIn=e.isLoggedIn,this.info.webId=e.webId,this.info.sessionId=e.sessionId,this.info.clientAppId=e.clientAppId,this.info.expirationDate=e.expirationDate,this.events.on(EVENTS.SESSION_EXTENDED,t=>{this.info.expirationDate=Date.now()+t*1e3})}}function snapshotFromSessionInfo(i){return i?.isLoggedIn&&i.webId?{status:"authenticated",webId:i.webId}:{status:"anonymous"}}function normalizeError(i){return i instanceof Error?i:new Error(String(i))}function snapshotFromSessionError(i,e){return{status:"error",webId:e.webId,error:normalizeError(i)}}function areSnapshotsEqual(i,e){return!i||i.status!==e.status||i.webId!==e.webId?!1:i.status==="error"&&e.status==="error"?i.error===e.error:!0}function createSolidSessionRuntime(i={}){const e=i.session??new Session,t=new Set;let n={status:"initializing"},s,a,u=!1,c,h=!1;const f=R=>{if(n=R,h||areSnapshotsEqual(s,n))return n;s=n;for(const T of t)T(n);return n},p=()=>f(snapshotFromSessionInfo(e.info)),g=()=>f({status:"anonymous"}),y=()=>f(snapshotFromSessionError("Solid session expired",e.info)),S=(R,T)=>{const A=snapshotFromSessionError(T??R??"Solid session error",e.info);u&&(c=A),f(A)};e.events.on(EVENTS.LOGIN,p),e.events.on(EVENTS.SESSION_RESTORED,p),e.events.on(EVENTS.LOGOUT,g),e.events.on(EVENTS.SESSION_EXPIRED,y);const w=e.events;return w.on(EVENTS.ERROR,S),{fetch:e.fetch,getSnapshot(){return n},initialize(R={}){if(a)return a;u=!0,c=void 0,f({status:"initializing"});const T=e.handleIncomingRedirect({restorePreviousSession:R.restorePreviousSession??!0}).then(A=>{const F=snapshotFromSessionInfo(A??e.info);return F.status==="anonymous"&&c?.status==="error"?c:f(F)}).catch(A=>f(snapshotFromSessionError(A,e.info))).finally(()=>{a===T&&(a=void 0,u=!1,c=void 0)});return a=T,a},login(R){return e.login(R)},async logout(R){await e.logout(R),f({status:"anonymous"})},subscribe(R){return t.add(R),()=>{t.delete(R)}},dispose(){h=!0,t.clear(),e.events.off(EVENTS.LOGIN,p),e.events.off(EVENTS.SESSION_RESTORED,p),e.events.off(EVENTS.LOGOUT,g),e.events.off(EVENTS.SESSION_EXPIRED,y),w.off(EVENTS.ERROR,S)}}}const KEY_SEPARATOR="\0";function normalizeIdentityPart(i){const e=i.trim();try{return new URL(e).href}catch{return e}}function compositeKey(i,e){return`${normalizeIdentityPart(i)}${KEY_SEPARATOR}${normalizeIdentityPart(e)}`}function nextGeneration(i,e){const t=(i.get(e)??0)+1;return i.set(e,t),t}function createAbortedOpenError(){const i=new Error("Pod open aborted because the runtime identity changed");return i.name="AbortError",i}function createPodRuntime(i){const{adapter:e}=i,t=new Map,n=new Map,s=new Map,a=new Map,u=h=>{if(!h){t.clear(),n.clear();for(const f of s.values())f.controller.abort();s.clear();for(const f of a.keys())nextGeneration(a,f);return}if(typeof h=="string"){c(h);return}c(h.webId,h.podUrl)},c=(h,f)=>{const p=normalizeIdentityPart(h);if(nextGeneration(a,p),s.get(p)?.controller.abort(),s.delete(p),f){const y=compositeKey(h,f);n.delete(y),normalizeIdentityPart(t.get(p)?.podUrl??"")===normalizeIdentityPart(f)&&t.delete(p);return}const g=t.get(p);g&&n.delete(compositeKey(g.webId,g.podUrl)),t.delete(p)};return{open(h){const f=normalizeIdentityPart(h.webId),p=t.get(f);if(p)return Promise.resolve(p);const g=s.get(f);if(g)return g.promise;const y=a.get(f)??0;a.set(f,y);const S=new AbortController,w=()=>!S.signal.aborted&&(a.get(f)??0)===y,R=()=>{if(!w())throw createAbortedOpenError()},T=(async()=>{const F=await e.discoverPod({webId:h.webId,fetch:h.fetch,signal:S.signal,isCurrent:w});R();const x=compositeKey(h.webId,F),D=n.get(x);if(D)return w()&&t.set(f,D),D;const O=await e.openDatabase({webId:h.webId,podUrl:F,fetch:h.fetch,signal:S.signal,isCurrent:w});R(),await e.hydrateCollections({webId:h.webId,podUrl:F,database:O,signal:S.signal,isCurrent:w}),R();const K={webId:h.webId,podUrl:F,database:O,collections:"ready"};return w()&&(t.set(f,K),n.set(x,K)),K})();s.set(f,{generation:y,promise:T,controller:S});const A=()=>{const F=s.get(f);F?.generation===y&&F.promise===T&&s.delete(f)};return T.then(A,A),T},clear:u,dispose(){u()}}}const SolidRuntimeContext=reactExports.createContext(null);function SolidRuntimeProvider({value:i,children:e}){return reactExports.createElement(SolidRuntimeContext.Provider,{value:i},e)}const urlAlphabet="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",generateNanoId=(i=21)=>{let e="";if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.getRandomValues=="function"){const t=globalThis.crypto.getRandomValues(new Uint8Array(i));for(let n=0;n<i;n++)e+=urlAlphabet[t[n]%urlAlphabet.length]}else{console.warn("Using Math.random fallback for NanoID generation.");for(let t=0;t<i;t++)e+=urlAlphabet[Math.floor(Math.random()*256)%urlAlphabet.length]}return e},hasStringValue$2=i=>typeof i=="object"&&i!==null&&typeof i.value=="string",hasTermValue=i=>typeof i=="object"&&i!==null&&typeof i.term=="object"&&i.term!==null&&typeof i.term?.value=="string",resolveTermIri=i=>{if(typeof i=="string")return i;if(hasStringValue$2(i))return i.value;if(hasTermValue(i))return i.term.value;throw new Error("Term must be a string or VocabTerm with a string value")},entityKind=Symbol.for("drizzle:entityKind");function is(i,e){if(!i||typeof i!="object")return!1;if(i instanceof e)return!0;if(!Object.prototype.hasOwnProperty.call(e,entityKind))throw new Error(`Class "${e.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let t=i.constructor;if(t)for(;t;){if(entityKind in t&&t[entityKind]===e[entityKind])return!0;t=Object.getPrototypeOf(t)}return!1}class Column{table;static[entityKind]="Column";name;primary;notNull;default;defaultFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;config;constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType}mapFromDriverValue(e){return e}mapToDriverValue(e){return e}}const ViewBaseConfig=Symbol.for("drizzle:ViewBaseConfig");class View{static[entityKind]="View";[ViewBaseConfig];constructor({name:e,schema:t,selectedFields:n,query:s}){this[ViewBaseConfig]={name:e,originalName:e,schema:t,selectedFields:n,query:s,isExisting:!s,isAlias:!1}}getSQL(){return new SQL([this])}}const SubqueryConfig=Symbol.for("drizzle:SubqueryConfig");class Subquery{static[entityKind]="Subquery";[SubqueryConfig];constructor(e,t,n,s=!1){this[SubqueryConfig]={sql:e,selection:t,alias:n,isWith:s}}getSQL(){return new SQL([this])}}class SelectionProxyHandler{static[entityKind]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if(t===SubqueryConfig)return{...e[SubqueryConfig],selection:new Proxy(e[SubqueryConfig].selection,this)};if(t===ViewBaseConfig)return{...e[ViewBaseConfig],selectedFields:new Proxy(e[ViewBaseConfig].selectedFields,this)};if(typeof t=="symbol")return e[t];const s=(is(e,Subquery)?e[SubqueryConfig].selection:is(e,View)?e[ViewBaseConfig].selectedFields:e)[t];if(is(s,SQL.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!s.isSelectionField)return s.sql;const a=s.clone();return a.isSelectionField=!0,a}if(is(s,SQL)){if(this.config.sqlBehavior==="sql")return s;throw new Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return is(s,Column)?this.config.alias?new Proxy(s,new ColumnAliasProxyHandler(new Proxy(s.table,new TableAliasProxyHandler(this.config.alias,this.config.replaceOriginalName??!1)))):s:typeof s!="object"||s===null?s:new Proxy(s,new SelectionProxyHandler(this.config))}}function orderSelectedFields(i,e){return Object.entries(i).reduce((t,[n,s])=>{if(typeof n!="string")return t;const a=e?[...e,n]:[n];return is(s,Column)||is(s,SQL)||is(s,SQL.Aliased)?t.push({path:a,field:s}):is(s,Table)?t.push(...orderSelectedFields(s[Table.Symbol.Columns],a)):t.push(...orderSelectedFields(s,a)),t},[])}function applyMixins(i,e){for(const t of e)for(const n of Object.getOwnPropertyNames(t.prototype))Object.defineProperty(i.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n)||Object.create(null))}function getTableLikeName(i){return is(i,Subquery)?i[SubqueryConfig].alias:is(i,View)?i[ViewBaseConfig].name:is(i,SQL)?void 0:i[Table.Symbol.IsAlias]?i[Table.Symbol.Name]:i[Table.Symbol.BaseName]}const TableName=Symbol.for("drizzle:Name"),Schema=Symbol.for("drizzle:Schema"),Columns=Symbol.for("drizzle:Columns"),OriginalName=Symbol.for("drizzle:OriginalName"),BaseName=Symbol.for("drizzle:BaseName"),IsAlias=Symbol.for("drizzle:IsAlias"),ExtraConfigBuilder=Symbol.for("drizzle:ExtraConfigBuilder"),IsDrizzleTable=Symbol.for("drizzle:IsDrizzleTable");class Table{static[entityKind]="Table";static Symbol={Name:TableName,Schema,OriginalName,Columns,BaseName,IsAlias,ExtraConfigBuilder};[TableName];[OriginalName];[Schema];[Columns];[BaseName];[IsAlias]=!1;[ExtraConfigBuilder]=void 0;[IsDrizzleTable]=!0;constructor(e,t,n){this[TableName]=this[OriginalName]=e,this[Schema]=t,this[BaseName]=n}getSQL(){return new SQL([this])}}class QueryPromise{static[entityKind]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}const tracer={startActiveSpan(i,e){return e()}},InlineForeignKeys=Symbol.for("drizzle:PgInlineForeignKeys");class PgTable extends Table{static[entityKind]="PgTable";static Symbol=Object.assign({},Table.Symbol,{InlineForeignKeys});[InlineForeignKeys]=[];[Table.Symbol.ExtraConfigBuilder]=void 0}class TypedQueryBuilder{static[entityKind]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class PgSelectQueryBuilder extends TypedQueryBuilder{static[entityKind]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:e,fields:t,isPartialSelect:n,session:s,dialect:a,withList:u,distinct:c}){super(),this.config={withList:u,table:e,fields:{...t},distinct:c},this.isPartialSelect=n,this.session=s,this.dialect=a,this._={selectedFields:t},this.tableName=getTableLikeName(e),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:!0}:{}}createJoin(e){return(t,n)=>{const s=this.tableName,a=getTableLikeName(t);if(typeof a=="string"&&this.config.joins?.some(u=>u.alias===a))throw new Error(`Alias "${a}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof s=="string"&&(this.config.fields={[s]:this.config.fields}),typeof a=="string"&&!is(t,SQL))){const u=is(t,Subquery)?t[SubqueryConfig].selection:is(t,View)?t[ViewBaseConfig].selectedFields:t[Table.Symbol.Columns];this.config.fields[a]=u}if(typeof n=="function"&&(n=n(new Proxy(this.config.fields,new SelectionProxyHandler({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:n,table:t,joinType:e,alias:a}),typeof a=="string")switch(e){case"left":{this.joinsNotNullableMap[a]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([u])=>[u,!1])),this.joinsNotNullableMap[a]=!0;break}case"inner":{this.joinsNotNullableMap[a]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([u])=>[u,!1])),this.joinsNotNullableMap[a]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new SelectionProxyHandler({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new SelectionProxyHandler({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if(typeof e[0]=="function"){const t=e[0](new Proxy(this.config.fields,new SelectionProxyHandler({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]=="function"){const t=e[0](new Proxy(this.config.fields,new SelectionProxyHandler({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.orderBy=Array.isArray(t)?t:[t]}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}offset(e){return this.config.offset=e,this}for(e,t={}){return this.config.lockingClauses||(this.config.lockingClauses=[]),this.config.lockingClauses.push({strength:e,config:t}),this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){const{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){return new Proxy(new Subquery(this.getSQL(),this.config.fields,e),new SelectionProxyHandler({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}class PgSelect extends PgSelectQueryBuilder{static[entityKind]="PgSelect";_prepare(e){const{session:t,config:n,dialect:s,joinsNotNullableMap:a}=this;if(!t)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return tracer.startActiveSpan("drizzle.prepareQuery",()=>{const u=orderSelectedFields(n.fields),c=t.prepareQuery(s.sqlToQuery(this.getSQL()),u,e);return c.joinsNotNullableMap=a,c})}prepare(e){return this._prepare(e)}execute=e=>tracer.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e))}applyMixins(PgSelect,[QueryPromise]);class Relation{sourceTable;referencedTable;relationName;static[entityKind]="Relation";referencedTableName;fieldName;constructor(e,t,n){this.sourceTable=e,this.referencedTable=t,this.relationName=n,this.referencedTableName=t[Table.Symbol.Name]}}function isSQLWrapper(i){return typeof i=="object"&&i!==null&&"getSQL"in i&&typeof i.getSQL=="function"}function mergeQueries(i){const e={sql:"",params:[]};for(const t of i)e.sql+=t.sql,e.params.push(...t.params),t.typings?.length&&(e.typings||(e.typings=[]),e.typings.push(...t.typings));return e}class StringChunk{static[entityKind]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new SQL([this])}}class SQL{queryChunks;static[entityKind]="SQL";decoder=noopDecoder;shouldInlineParams=!1;constructor(e){this.queryChunks=e}append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return tracer.startActiveSpan("drizzle.buildSQL",t=>{const n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(e,t){const n=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{escapeName:s,escapeParam:a,prepareTyping:u,inlineParams:c,paramStartIndex:h}=n;return mergeQueries(e.map(f=>{if(is(f,StringChunk))return{sql:f.value.join(""),params:[]};if(is(f,Name))return{sql:s(f.value),params:[]};if(f===void 0)return{sql:"",params:[]};if(Array.isArray(f)){const p=[new StringChunk("(")];for(const[g,y]of f.entries())p.push(y),g<f.length-1&&p.push(new StringChunk(", "));return p.push(new StringChunk(")")),this.buildQueryFromSourceParams(p,n)}if(is(f,SQL))return this.buildQueryFromSourceParams(f.queryChunks,{...n,inlineParams:c||f.shouldInlineParams});if(is(f,Table)){const p=f[Table.Symbol.Schema],g=f[Table.Symbol.Name];return{sql:p===void 0?s(g):s(p)+"."+s(g),params:[]}}if(is(f,Column))return{sql:s(f.table[Table.Symbol.Name])+"."+s(f.name),params:[]};if(is(f,View)){const p=f[ViewBaseConfig].schema,g=f[ViewBaseConfig].name;return{sql:p===void 0?s(g):s(p)+"."+s(g),params:[]}}if(is(f,Param)){const p=f.value===null?null:f.encoder.mapToDriverValue(f.value);if(is(p,SQL))return this.buildQueryFromSourceParams([p],n);if(c)return{sql:this.mapInlineParam(p,n),params:[]};let g;return u!==void 0&&(g=[u(f.encoder)]),{sql:a(h.value++,p),params:[p],typings:g}}return is(f,Placeholder)?{sql:a(h.value++,f),params:[f]}:is(f,SQL.Aliased)&&f.fieldAlias!==void 0?{sql:s(f.fieldAlias),params:[]}:is(f,Subquery)?f[SubqueryConfig].isWith?{sql:s(f[SubqueryConfig].alias),params:[]}:this.buildQueryFromSourceParams([new StringChunk("("),f[SubqueryConfig].sql,new StringChunk(") "),new Name(f[SubqueryConfig].alias)],n):isSQLWrapper(f)?this.buildQueryFromSourceParams([new StringChunk("("),f.getSQL(),new StringChunk(")")],n):is(f,Relation)?this.buildQueryFromSourceParams([f.sourceTable,new StringChunk("."),sql.identifier(f.fieldName)],n):c?{sql:this.mapInlineParam(f,n),params:[]}:{sql:a(h.value++,f),params:[f]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return"null";if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="string")return t(e);if(typeof e=="object"){const n=e.toString();return t(n==="[object Object]"?JSON.stringify(e):n)}throw new Error("Unexpected param value: "+e)}getSQL(){return this}as(e){return e===void 0?this:new SQL.Aliased(this,e)}mapWith(e){return this.decoder=typeof e=="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}}class Name{value;static[entityKind]="Name";brand;constructor(e){this.value=e}getSQL(){return new SQL([this])}}const noopDecoder={mapFromDriverValue:i=>i},noopEncoder={mapToDriverValue:i=>i};({...noopDecoder,...noopEncoder});class Param{value;encoder;static[entityKind]="Param";brand;constructor(e,t=noopEncoder){this.value=e,this.encoder=t}getSQL(){return new SQL([this])}}function sql(i,...e){const t=[];(e.length>0||i.length>0&&i[0]!=="")&&t.push(new StringChunk(i[0]));for(const[n,s]of e.entries())t.push(s,new StringChunk(i[n+1]));return new SQL(t)}(function(i){function e(){return new SQL([])}i.empty=e;function t(h){return new SQL(h)}i.fromList=t;function n(h){return new SQL([new StringChunk(h)])}i.raw=n;function s(h,f){const p=[];for(const[g,y]of h.entries())g>0&&f!==void 0&&p.push(f),p.push(y);return new SQL(p)}i.join=s;function a(h){return new Name(h)}i.identifier=a;function u(h){return new Placeholder(h)}i.placeholder=u;function c(h,f){return new Param(h,f)}i.param=c})(sql||(sql={}));(function(i){class e{sql;fieldAlias;static[entityKind]="SQL.Aliased";isSelectionField=!1;constructor(n,s){this.sql=n,this.fieldAlias=s}getSQL(){return this.sql}clone(){return new e(this.sql,this.fieldAlias)}}i.Aliased=e})(SQL||(SQL={}));class Placeholder{name;static[entityKind]="Placeholder";constructor(e){this.name=e}getSQL(){return new SQL([this])}}Column.prototype.getSQL=function(){return new SQL([this])};class ColumnAliasProxyHandler{table;static[entityKind]="ColumnAliasProxyHandler";constructor(e){this.table=e}get(e,t){return t==="table"?this.table:e[t]}}class TableAliasProxyHandler{alias;replaceOriginalName;static[entityKind]="TableAliasProxyHandler";constructor(e,t){this.alias=e,this.replaceOriginalName=t}get(e,t){if(t===Table.Symbol.IsAlias)return!0;if(t===Table.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===Table.Symbol.OriginalName)return this.alias;if(t===ViewBaseConfig)return{...e[ViewBaseConfig],name:this.alias,isAlias:!0};if(t===Table.Symbol.Columns){const s=e[Table.Symbol.Columns];if(!s)return s;const a={};return Object.keys(s).map(u=>{a[u]=new Proxy(s[u],new ColumnAliasProxyHandler(new Proxy(e,this)))}),a}const n=e[t];return is(n,Column)?new Proxy(n,new ColumnAliasProxyHandler(new Proxy(e,this))):n}}var _a$b;class ColumnBuilder{constructor(e,t,n={},s,a){this.name=e,this.dataType=t,this.options={...n},this._predicateUri=s,this.elementType=a??null}formatValue(e){if(e==null)throw new Error("Cannot format null or undefined value");if(this.options.isArray){if(!Array.isArray(e))throw new Error("Array column requires array value");return e.map(t=>this.formatSingleValue(t))}return this.formatSingleValue(e)}formatSingleValue(e){const t=this.options.isArray&&this.elementType?this.elementType:this.dataType;if(this.options.linkTarget&&typeof e=="string")return`<${e}>`;switch(t){case"string":return`"${String(e).replace(/"/g,'"')}"`;case"integer":return String(Number(e));case"boolean":return`"${e}"^^<http://www.w3.org/2001/XMLSchema#boolean>`;case"datetime":return`"${(e instanceof Date?e:new Date(e)).toISOString()}"^^<http://www.w3.org/2001/XMLSchema#dateTime>`;case"json":case"object":return`"${JSON.stringify(e).replace(/"/g,'"')}"^^<http://www.w3.org/2001/XMLSchema#json>`;case"uri":if(typeof e!="string"||!e.includes(":"))throw new Error(`URI column requires valid IRI, got: ${e}`);return`<${e}>`;default:return`"${String(e).replace(/"/g,'"')}"`}}parseValue(e,t){return this.parseSingleValue(e,t)}parseSingleValue(e,t){if(!t)return e;if(t.includes("#integer")||t.includes("#int"))return parseInt(e,10);if(t.includes("#decimal")||t.includes("#double"))return parseFloat(e);if(t.includes("#boolean"))return e==="true";if(t.includes("#dateTime"))return new Date(e);if(t.includes("#json"))try{return JSON.parse(e)}catch{return console.warn("Failed to parse JSON value:",e),e}return e.startsWith("http://")||e.startsWith("https://"),e}primaryKey(){return this._predicateUri="@id",this.options={...this.options,primaryKey:!0,required:!0,predicate:"@id"},this}notNull(){return this.options={...this.options,required:!0,notNull:!0},this}predicate(e){const t=resolveTermIri(e);return this._predicateUri=t,this.options={...this.options,predicate:t},this}default(e){return this.options={...this.options,defaultValue:e},this}defaultNow(){return this.options={...this.options,defaultValue:()=>new Date},this}inverse(e=!0){return this.options={...this.options,inverse:e},this}link(e){return typeof e=="string"?e.startsWith("http://")||e.startsWith("https://")?this.options={...this.options,linkTarget:e}:this.options={...this.options,linkTableName:e}:this.options={...this.options,linkTable:e},this}array(){return new ColumnBuilder(this.name,"array",{...this.options,baseType:this.dataType,isArray:!0},this._predicateUri,this.dataType)}getPredicateUri(){return this._predicateUri}}class PodColumnBase{constructor(e,t,n={},s){this.name=e,this.dataType=t,this.options=n,this.tableName=s}getPredicate(e){if(this.options.predicate)return this.options.predicate;if(e)return`${e.uri}${this.name}`;throw new Error(`Missing predicate for column "${this.name}"; please set namespace or predicate explicitly.`)}isLink(){return!!(this.options.linkTarget||this.options.linkTableName||this.options.linkTable)}getLinkTarget(){return this.options.linkTarget}getLinkTableName(){return this.options.linkTableName}getLinkTable(){return this.options.linkTable}primaryKey(){return this.options.primaryKey=!0,this.options.required=!0,this.options.predicate="@id",this}notNull(){return this.options.required=!0,this}default(e){return this.options.defaultValue=e,this}predicate(e){return this.options.predicate=resolveTermIri(e),this}link(e){return typeof e=="string"?e.startsWith("http://")||e.startsWith("https://")?this.options.linkTarget=e:this.options.linkTableName=e:this.options.linkTable=e,this}inverse(e=!0){return this.options.inverse=e,this}isInverse(){return this.options.inverse===!0}formatValue(e){if(e==null)throw new Error("Cannot format null or undefined value");if(this.options.isArray){if(!Array.isArray(e))throw new Error("Array column requires array value");return e.map(t=>this.formatSingleValue(t))}return this.formatSingleValue(e)}formatSingleValue(e){if(this.options.linkTarget&&typeof e=="string")return`<${e}>`;switch(this.dataType){case"string":return`"${String(e).replace(/"/g,'"')}"`;case"integer":return`"${Number(e)}"^^<http://www.w3.org/2001/XMLSchema#integer>`;case"boolean":return`"${e}"^^<http://www.w3.org/2001/XMLSchema#boolean>`;case"datetime":return`"${(e instanceof Date?e:new Date(e)).toISOString()}"^^<http://www.w3.org/2001/XMLSchema#dateTime>`;case"json":case"object":return`"${JSON.stringify(e).replace(/"/g,'"')}"^^<http://www.w3.org/2001/XMLSchema#json>`;case"uri":if(typeof e!="string"||!e.includes(":"))throw new Error(`URI column requires valid IRI, got: ${e}`);return`<${e}>`;default:return`"${String(e).replace(/"/g,'"')}"`}}}_a$b=entityKind;PodColumnBase[_a$b]="PodColumn";class PodStringColumn extends PodColumnBase{constructor(e,t={}){super(e,"string",t)}}class PodIntegerColumn extends PodColumnBase{constructor(e,t={}){super(e,"integer",t)}}class PodBooleanColumn extends PodColumnBase{constructor(e,t={}){super(e,"boolean",t)}}class PodDateTimeColumn extends PodColumnBase{constructor(e,t={}){super(e,"datetime",t)}}class PodJsonColumn extends PodColumnBase{constructor(e,t={}){super(e,"json",t)}}class PodObjectColumn extends PodColumnBase{constructor(e,t={}){super(e,"object",t)}}class PodUriColumn extends PodColumnBase{constructor(e,t={}){super(e,"uri",t)}}class PodArrayColumn extends PodColumnBase{constructor(e,t,n={}){super(e,"array",n),this.elementType=t}}function boolean$2(i,e={}){return new ColumnBuilder(i,"boolean",e)}function object$1(i,e={}){return new ColumnBuilder(i,"object",e)}function uri(i,e={}){return new ColumnBuilder(i,"uri",e)}function id(i="id",e={}){const t=new PodStringColumn(i,{...e,predicate:"@id",primaryKey:!0,required:!0,...e.defaultValue!==void 0?{defaultValue:e.defaultValue}:{}});return t._virtualId=!0,t}function string$2(i,e={}){return new ColumnBuilder(i,"string",e)}function integer$1(i,e={}){return new ColumnBuilder(i,"integer",e)}function date$3(i,e={}){return new ColumnBuilder(i,"datetime",e)}function validateColumnOverride(i,e,t){const n=i.getPredicateUri?.()??i.options?.predicate,s=e.options?.predicate;if(n&&s&&n!==s)throw new Error(`Schema 继承错误: 不能修改 "${t}" 列的 predicate。父 schema 定义为 "${s}",子 schema 尝试改为 "${n}"。子类只能添加约束(notNull, default),不能更改 predicate。`)}function mergeSchemaColumns(i,e){const t={};for(const[n,s]of Object.entries(i.columns))t[n]=s;for(const[n,s]of Object.entries(e)){const a=i.columns[n];if(a&&!(s instanceof PodColumnBase)){validateColumnOverride(s,a,n);const u=s;!u.getPredicateUri?.()&&!u.options?.predicate&&(u.options={...u.options,predicate:a.options?.predicate})}t[n]=s}return t}function renderDefaultIdTemplate(i,e){if(!/\{[^{}]+\}/.test(i))return i;if(/\{\s*id\s*\}/.test(i))throw new Error("id default template uses {key} for the generated local key; {id} is the final resource id");const t=e.row??{},n=resolveDate(t,e.now),s={yyyy:String(n.getUTCFullYear()),MM:String(n.getUTCMonth()+1).padStart(2,"0"),dd:String(n.getUTCDate()).padStart(2,"0")};return i.replace(/\{([^{}]+)\}/g,(a,u)=>{const c=u.trim();if(c==="key")return e.key;if(c==="yyyy")return s.yyyy;if(c==="MM")return s.MM;if(c==="dd")return s.dd;const h=resolveExpression(c,t,e);return h==null?"":String(h)})}function resolveDate(i,e=new Date){const t=i.createdAt??i.favoredAt??i.indexedAt??e,n=t instanceof Date?t:new Date(typeof t=="number"&&Math.abs(t)<1e11?t*1e3:t);return Number.isFinite(n.getTime())?n:e}function resolveExpression(i,e,t){const n=parseExpression(i);let s=resolveTemplatePath(n.path,e,t);for(const a of n.transforms)s=applyTransform(s,a,n.path,t);return n.selector?applyPathSelector(s,n.selector):s}function parseExpression(i){const e=i.match(/^(.+?)\[(.*)\]$/),t=e?e[1].trim():i,[n,...s]=t.split("|").map(a=>a.trim()).filter(Boolean);return{path:n??i,transforms:s,selector:e?.[2]?.trim()}}function resolveTemplatePath(i,e,t){const n=i.split("."),s=n[0];return n.reduce((a,u,c)=>{if(typeof a=="string")return s?resolveResourceProperty(a,s,u,t):void 0;if(!(!a||typeof a!="object"))return s&&isResourceProperty(u)&&!((u==="id"||u==="key")&&u in a)?resolveResourceProperty(a,s,u,t):c>0&&u==="id"&&readRef(a)?extractResourceId(a,s??"",t):a[u]},e)}function isResourceProperty(i){return i==="id"||i==="key"||i==="doc"||i==="document"||i==="dir"||i==="owner"}function resolveResourceProperty(i,e,t,n){if(t==="id")return extractResourceId(i,e,n);const s=extractResourceId(i,e,n);if(s){if(t==="key"){const a=extractTemplateValuesForField(i,e,n);return a?.key??a?.id??deriveResourceKey(s)}if(t==="doc"||t==="document")return resourceDocument(s);if(t==="dir"||t==="owner")return deriveOwnerDir(s)}}function applyTransform(i,e,t,n){if(e==="slug")return slugifyValue(String(i??""));const s=extractResourceId(i,t,n);if(e==="resource")return s;if(e==="document")return s?resourceDocument(s):"";if(e==="owner")return s?deriveOwnerDir(s):"";const a=extractTemplateValuesForField(i,t,n);return e==="id"?a?.id??a?.key??s??"":a?.[e]??""}function extractResourceId(i,e,t){const n=readRef(i);if(!n)return null;const s=resolveLinkedResource(e,t);if(!s)return normalizePodDataResourceId$1(n);if(!isCompleteResourceId$1(n))return renderLinkedResourceId(s,n);const a=relativeSubjectFromRef$1(s,n);return normalizePodDataResourceId$1(a??n)}function extractTemplateValuesForField(i,e,t){const n=readRef(i);if(!n)return null;const s=resolveLinkedResource(e,t);if(!s)return null;const a=relativeSubjectFromRef$1(s,n)??(isCompleteResourceId$1(n)?null:renderLinkedResourceId(s,n));if(!a)return null;const u=resourceTemplate(s);return u?extractVarsFromTemplate(normalizePodDataResourceId$1(a),u):{id:normalizePodDataResourceId$1(a)}}function resolveLinkedResource(i,e){const t=e.links?.[i];if(t)return t;const n=e.resource?.columns?.[i];return n?.getLinkTable?.()??n?.options?.linkTable??null}function resourceTemplate(i){const e=i.getSubjectTemplate?.()??i.config?.subjectTemplate;if(e)return e;const t=i.columns?.id?.options?.defaultValue;return typeof t=="string"?t:null}function renderLinkedResourceId(i,e){const t=resourceTemplate(i);if(!t)return e;const n=i.columns?.id?.options?.defaultValue;return typeof n=="function"?String(n(e,{})):t.replace(/\{([^}]+)\}/g,(s,a)=>{const u=parseTemplateField(a);return u==="id"||u==="key"?e:""})}function readRef(i){if(typeof i=="string"&&i.length>0)return i;if(!i||typeof i!="object")return null;const e=i,t=e["@id"]??e.subject??e.id;return typeof t=="string"&&t.length>0?t:null}function resourcePath(i){return normalizeResourcePath$1(i.getResourcePath?.()??i.config?.base??"")}function relativeSubjectFromRef$1(i,e){const t=resourcePath(i);if(!t)return normalizePodDataResourceId$1(e);const n=Array.from(new Set([t,t.replace(/^\/+/,""),t.endsWith("/")?t.slice(0,-1):t].filter(Boolean)));for(const s of n){const a=e.indexOf(s);if(a<0)continue;let u=e.slice(a+s.length);return u.startsWith("/")&&(u=u.slice(1)),u.length>0?u:null}return normalizePodDataResourceId$1(e)}function extractVarsFromTemplate(i,e){let t=0;const n=new Map,s=[];let a=0;for(const c of e.matchAll(/\{([^}]+)\}/g)){s.push(escapeRegExp$1(e.slice(a,c.index)));const h=`var${t++}`;n.set(h,parseTemplateField(c[1]??"")),s.push(`(?<${h}>.+?)`),a=c.index+c[0].length}s.push(escapeRegExp$1(e.slice(a)));const u=s.join("");try{const c=i.match(new RegExp(`^${u}$`));if(!c?.groups)return null;const h={};for(const[f,p]of Object.entries(c.groups)){const g=n.get(f);!g||p===void 0||(h[g]=decodeURIComponent(p))}return h}catch{return null}}function parseTemplateField(i){const e=i.split("|").map(n=>n.trim()).filter(Boolean)[0]??i,t=e.replace(/\[[^\]]*\]$/u,"").trim();return t.split(".")[0]?.trim()||t||e}function escapeRegExp$1(i){return i.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}function applyPathSelector(i,e){const t=splitResourcePath(i);if(!t)return;if(/^-?\d+$/.test(e))return t[normalizeIndex(Number(e),t.length)];const n=e.match(/^(-?\d*)\s*:\s*(-?\d*)$/);if(!n)throw new Error(`Invalid id default path selector [${e}]`);const s=n[1]===""?0:normalizeSliceIndex(Number(n[1]),t.length),a=n[2]===""?t.length:normalizeSliceIndex(Number(n[2]),t.length);return t.slice(s,a).join("/")}function splitResourcePath(i){const e=readRef(i);if(!e)return null;const t=normalizePodDataResourceId$1(e),[n,s]=t.split("#"),a=(n??t).split("/").filter(Boolean);return s&&a.push(s),a}function normalizePodDataResourceId$1(i){const e=i.indexOf("#"),[t,n=""]=e>=0?[i.slice(0,e),i.slice(e)]:[i,""],s=t.indexOf("/.data/");return`${s>=0?t.slice(s+7):t.replace(/^\/?\.data\//u,"").replace(/^\/+/u,"")}${n}`}function normalizeResourcePath$1(i){return i.trim().replace(/^(\.\/)+/,"")}function isCompleteResourceId$1(i){return/^https?:\/\//u.test(i)||i.startsWith("/")||i.startsWith("#")||i.includes("#")||/\.(ttl|jsonld|json)(?:$|[?#])/iu.test(i)}function deriveOwnerDir(i){const e=normalizePodDataResourceId$1(i),t=e.indexOf("#"),n=t>=0?e.slice(0,t):e,s=t>=0?e.slice(t+1):"",a=n.match(/^(.+)\/\d{4}\/\d{2}\/\d{2}\/[^/]+\.(?:ttl|jsonld|json)$/i);if(a?.[1])return a[1];if(n==="task/index.ttl"&&s&&s!=="this")return`task/${s}`;const u=n.match(/^(.+)\/index\.(?:ttl|jsonld|json)$/i);if(u?.[1])return u[1];const c=n.match(/^(.+)\.(?:ttl|jsonld|json)$/i);if(c?.[1])return c[1];const h=n.split("/").filter(Boolean);return h.length>1?h.slice(0,-1).join("/"):n}function resourceDocument(i){const e=normalizePodDataResourceId$1(i),t=e.indexOf("#");return t>=0?e.slice(0,t):e}function deriveResourceKey(i){const e=normalizePodDataResourceId$1(i),t=e.indexOf("#");if(t>=0){const c=e.slice(t+1);if(c&&c!=="this"&&c!=="me"&&c!=="it")return c}const n=resourceDocument(e).replace(/\/+$/u,""),s=n.match(/(?:^|\/)([^/]+)\/index\.(?:ttl|jsonld|json)$/iu);if(s?.[1])return s[1];const a=n.match(/(?:^|\/)([^/]+)\.(?:ttl|jsonld|json)$/iu);if(a?.[1])return a[1];const u=n.split("/").filter(Boolean);return u.length>0?u[u.length-1]:e}function slugifyValue(i){return i.normalize("NFKC").toLowerCase().trim().replace(/[\s_]+/g,"-").replace(/[^\p{Letter}\p{Number}.-]+/gu,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function normalizeIndex(i,e){return i<0?e+i:i}function normalizeSliceIndex(i,e){const t=i<0?e+i:i;return Math.max(0,Math.min(e,t))}function parseTemplateVariableField$1(i){const e=i.split("|").map(n=>n.trim()).filter(Boolean)[0]??i,t=e.replace(/\[[^\]]*\]$/u,"").trim();return t.split(".")[0]?.trim()||t||e}function normalizeResourcePath(i){return i.trim().replace(/^(\.\/)+/,"")}function podResourcePath(i){return normalizeResourcePath(i.getResourcePath?.()??i.config?.base??"")}function podResourceSubjectTemplate(i){return i.getSubjectTemplate?.()??i.config?.subjectTemplate}function podResourceIdDefaultTemplate(i){const e=i.columns?.id?.options?.defaultValue;return typeof e=="string"?e:void 0}function resourceRelativePrefix(i){const e=podResourcePath(i),t=normalizeResourcePath(i.getContainerPath?.()??i.config?.containerPath??"");return e?t&&e.startsWith(t)?normalizeResourcePath(e.slice(t.length)):e.split("/").pop()??e:""}function qualifyFragmentResourceId(i,e){if(!e.startsWith("#"))return e;const t=resourceRelativePrefix(i);return t?`${t}${e}`:e}function templateRelativeSubject(i,e){if((podResourceSubjectTemplate(i)??podResourceIdDefaultTemplate(i))?.startsWith("#")&&!e.startsWith("#")){const n=e.indexOf("#");if(n>=0)return e.slice(n)}return e}function isBaseRelativeSubjectId$1(i){return!i||/^https?:\/\//.test(i)||i.startsWith("/")?!1:i.startsWith("#")||i.includes("#")||/\.(ttl|jsonld|json)(?:#|$)/i.test(i)}function isTemplateCompleteResourceId(i,e){if(!e||/^https?:\/\//.test(e)||e.startsWith("/"))return!1;const t=podResourceSubjectTemplate(i)??podResourceIdDefaultTemplate(i);return t?extractTemplateValues(templateRelativeSubject(i,e),t)!==null:!1}function isResourceRelativeSubjectId(i,e){return isBaseRelativeSubjectId$1(e)||isTemplateCompleteResourceId(i,e)}function relativeSubjectFromRef(i,e){const t=podResourcePath(i);if(!t)return null;const n=Array.from(new Set([t,t.replace(/^\/+/,""),t.endsWith("/")?t.slice(0,-1):t].filter(Boolean)));for(const s of n){const a=e.indexOf(s);if(a<0)continue;let u=e.slice(a+s.length);if(u.startsWith("/")&&(u=u.slice(1)),u.length>0)return u}return isBaseRelativeSubjectId$1(e)||isTemplateCompleteResourceId(i,e)?normalizeResourcePath(e):null}function extractTemplateValues(i,e){if(!e.includes("{"))return i===e?{}:null;let t=0;const n=new Map,s=[];let a=0;for(const c of e.matchAll(/\{([^}]+)\}/g)){s.push(escapeRegExp(e.slice(a,c.index)));const h=`var${t++}`;n.set(h,parseTemplateVariableField$1(c[1]??"")),s.push(`(?<${h}>.+?)`),a=c.index+c[0].length}s.push(escapeRegExp(e.slice(a)));const u=`^${s.join("")}$`;try{const c=i.match(new RegExp(u));if(!c?.groups)return null;const h={};for(const[f,p]of Object.entries(c.groups)){const g=n.get(f);if(!g||p===void 0)continue;const y=decodeURIComponent(p);if(g in h&&h[g]!==y)return null;h[g]=y}return h}catch{return null}}function escapeRegExp(i){return i.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}function parsePodResourceRef(i,e){if(!e)return null;const t=relativeSubjectFromRef(i,e);if(!t)return null;const n=qualifyFragmentResourceId(i,t),s=podResourceSubjectTemplate(i)??podResourceIdDefaultTemplate(i),a=s?extractTemplateValues(templateRelativeSubject(i,n),s):{id:decodeURIComponent(n)};return a?{resourceId:decodeURIComponent(n),templateValues:a}:null}function extractPodResourceTemplateValue(i,e,t="id"){return parsePodResourceRef(i,e)?.templateValues[t]??null}function resolvePodBaseUrl(i){const e=i.trim();return e?e.includes("/profile/card#me")?e.replace("/profile/card#me","").replace(/\/+$/u,""):e.replace(/\/+$/u,""):""}function resolvePodBaseUrlFromDatabase(i){if(!i||typeof i!="object")return null;const e=i,t=typeof e.getDialect=="function"?e.getDialect():null,n=readPodUrl(t);if(n)return resolvePodBaseUrl(n);const s=typeof e.getSession=="function"?e.getSession():e.session,a=readPodUrl(s);if(a)return resolvePodBaseUrl(a);const u=readWebId(s);return u&&u.includes("/profile/card#me")?resolvePodBaseUrl(u):null}function normalizePodDataResourceId(i){const e=i.indexOf("#"),[t,n=""]=e>=0?[i.slice(0,e),i.slice(e)]:[i,""],s=t.indexOf("/.data/");return`${s>=0?t.slice(s+7):t.replace(/^\/?\.data\//u,"").replace(/^\/+/u,"")}${n}`}function resolvePodResourceId(i,e){const t=resolveKnownTargetIri(e);if(t)return parsePodResourceRef(i,t)?.resourceId??normalizePodDataResourceId(t);if(typeof e=="string")return assertCompleteStringResourceId(i,e),normalizePodDataResourceId(e);const n=typeof e.id=="string"&&e.id.trim().length>0?e.id.trim():void 0;if(!n)throw new Error("resolvePodResourceId requires a resource id on target.id or a full target IRI");if(isCompleteResourceId(n)||isTemplateCompleteResourceId(i,n))return normalizePodDataResourceId(n);const s=resolveDefaultResourceId(i,n,e);if(s)return normalizePodDataResourceId(s);const a=podResourceSubjectTemplate(i);return normalizePodDataResourceId(a?renderSubjectTemplateResourceId(a,n,e):n)}function buildPodResourceIri(i,e){const t=resolvePodBaseUrl(i);if(!t||/^https?:\/\//u.test(e))return e;const n=e.startsWith("/")?e:`/.data/${normalizePodDataResourceId(e)}`;return new URL(n.replace(/^\/+/u,""),`${t}/`).toString()}function buildPodResourceIriForResource(i,e,t){const n=resolveKnownTargetIri(t);if(n)return n;const s=resolvePodRootTargetPath(t);if(s)return buildPodResourceIri(i,s);const a=resolvePodResourceId(e,t),u=isResourceRelativeSubjectId(e,a)?`${podResourcePath(e).replace(/\/+$/u,"")}/${normalizeResourcePath(a)}`:e.resolveUri?.(a)??`/.data/${normalizePodDataResourceId(a)}`;return buildPodResourceIri(i,u)}function buildPodResourceIriForDatabase(i,e,t){const n=resolvePodBaseUrlFromDatabase(i);if(!n)throw new Error("buildPodResourceIriForDatabase requires a database with a Pod URL or WebID");return buildPodResourceIriForResource(n,e,t)}function resolvePodResourceIriForDatabase(i,e,t){if(!t)return null;try{return buildPodResourceIriForDatabase(i,e,t)}catch{return null}}function resolveKnownTargetIri(i){if(typeof i=="string")return/^https?:\/\//u.test(i)?i:null;const e=i["@id"]??i.subject;return typeof e=="string"&&/^https?:\/\//u.test(e)?e:null}function resolvePodRootTargetPath(i){if(typeof i=="string")return i.startsWith("/")?i:null;const e=typeof i.id=="string"?i.id.trim():"";return e.startsWith("/")?e:null}function isCompleteResourceId(i){return/^https?:\/\//u.test(i)||i.startsWith("/")||i.startsWith("#")||i.includes("#")||/\.(ttl|jsonld|json)(?:$|[?#])/iu.test(i)}function assertCompleteStringResourceId(i,e){if(isCompleteResourceId(e)||isTemplateCompleteResourceId(i,e))return;const t=i.columns?.id?.options?.defaultValue!==void 0,n=podResourceSubjectTemplate(i);if(t||n)throw new Error("resolvePodResourceId does not accept local keys as string targets. Pass a structured row object with id and required fields, or pass a complete resource id/IRI.")}function resolveDefaultResourceId(i,e,t){const n=i.columns?.id?.options?.defaultValue;if(n===void 0)return null;if(typeof n=="string")return renderDefaultIdTemplate(n,{key:e,row:t,resource:i});if(typeof n!="function")return String(n);const s=n;return s.length===0?String(s()):String(s(e,t))}function renderSubjectTemplateResourceId(i,e,t){const n=i.replace(/\{\s*id\s*\}/gu,"{key}");return renderDefaultIdTemplate(n,{key:encodeURIComponent(e),row:t})}function readPodUrl(i){if(!i||typeof i!="object")return null;const e=i,t=typeof e.getPodUrl=="function"?e.getPodUrl():e.info?.podUrl??e.podUrl;return typeof t=="string"&&t.trim().length>0?t:null}function readWebId(i){if(!i||typeof i!="object")return null;const e=i,t=e.info?.webId??e.webId;return typeof t=="string"&&t.trim().length>0?t:null}var _a$a;class PodTable{constructor(e,t,n){this.initialized=!1;const s=n.type;if(!s)throw new Error("podTable requires a type (RDF class) via options.type");const a=n.typeIndex,u=a==="private"||a==="public",c=this.resolveBase(n.base,e);this.resourcePath=c.resourcePath,this.containerPath=c.containerPath;const h=this.resolveSubjectTemplate(n.subjectTemplate,c.resourcePath,c.containerPath,e);this.subjectTemplate=h.template,this.hasCustomSubjectTemplate=h.isCustom,this.resourceMode=n.resourceMode??(n.sparqlEndpoint?"sparql":void 0),this.sparqlEndpoint=n.sparqlEndpoint,this.registerTypeIndexEnabled=u&&n.autoRegister!==!1,this.config={name:e,base:c.resourcePath,type:resolveTermIri(s),namespace:n.namespace,typeIndex:u?a:void 0,saiRegistryPath:n.saiRegistryPath,autoRegister:n.autoRegister,containerPath:c.containerPath,hooks:n.hooks},this.subjectTemplate&&(this.config.subjectTemplate=this.subjectTemplate),this.parentClasses=this.normalizeParents(n.subClassOf??[]),this.parentClasses.length>0&&(this.config.subClassOf=[...this.parentClasses]),this.columns=t,Object.assign(this,t);let f=0;for(const p of Object.values(t))if(p.options.primaryKey&&f++,p.table=this,p.tableName=e,!p.options.predicate&&!p._virtualId&&!n.namespace)throw new Error(`Column "${p.name}" in table "${e}" is missing a predicate.`);if(f!==1)throw new Error(`PodTable "${e}" must have exactly one primary key column. Found ${f}.`);this.$inferSelect={},this.$inferInsert={},this.$inferUpdate={},this._={brand:"Table",config:this.config,name:e,schema:void 0,columns:t,inferSelect:{},inferInsert:{},inferUpdate:{}},this.mapping=this.buildTableMapping()}getContainerPath(){return this.containerPath}getType(){return this.config.type}getRdfClass(){return this.getType()}getNamespace(){return this.config.namespace}getSubjectTemplate(){return this.subjectTemplate}buildId(e){return resolvePodResourceId(this,e)}buildIri(e,t){return buildPodResourceIriForResource(e,this,t)}buildIriForDatabase(e,t){return buildPodResourceIriForDatabase(e,this,t)}resolveIriForDatabase(e,t){return resolvePodResourceIriForDatabase(e,this,t)}parseRef(e){return parsePodResourceRef(this,e)}extractTemplateValue(e,t="id"){return extractPodResourceTemplateValue(this,e,t)}hasCustomTemplate(){return this.hasCustomSubjectTemplate}getSubClassOf(){return[...this.parentClasses]}getMapping(){return this.mapping}get $schema(){return new SolidSchema(this.columns,{type:this.config.type,namespace:this.config.namespace,subjectTemplate:this.subjectTemplate,subClassOf:this.parentClasses.length>0?[...this.parentClasses]:void 0})}resolveUri(e){const t=this.subjectTemplate;if(!t)return/^https?:\/\//.test(e)||e.startsWith("/")?e:`${this.config.base.endsWith("/")?this.config.base:`${this.config.base}/`}${e}`;const n=t.replace(/\{id\}/g,e);return n.startsWith("#")?`${this.resourcePath}${n}`:`${this.containerPath.endsWith("/")?this.containerPath:`${this.containerPath}/`}${n}`}resolveBase(e,t){if(!e||e.trim().length===0)throw new Error(`podTable '${t}' requires a 'base' option.`);const n=this.normalizeBaseInput(e),s=this.normalizeResourcePath(n);if(s.endsWith("/")){const u=this.ensureTrailingSlash(s);return{resourcePath:u,containerPath:u}}const a=this.ensureTrailingSlash(this.deriveContainerPath(s));return{resourcePath:s,containerPath:a}}normalizeBaseInput(e){const t=e.trim(),n=t.match(/^([a-zA-Z][\w+.-]*):\/\/(.*)$/);if(n){const[,s,a]=n,u=s.toLowerCase(),c=a.trim();return u==="http"||u==="https"?`${u}://${c}`:c.startsWith("/")?c:`/${c}`}return t}normalizeResourcePath(e){if(/^[a-zA-Z][\w+.-]*:\/\//.test(e))return e;const n=e.trim().replace(/^(\.\/)+/,"").replace(/\/+/g,"/");return n.startsWith("/")?n:`/${n}`}deriveContainerPath(e){const t=e.endsWith("/")?e.slice(0,-1):e,n=t.lastIndexOf("/");return n===-1?"/":t.slice(0,n+1)}ensureTrailingSlash(e){return e.endsWith("/")?e:`${e}/`}getResourcePath(){return this.resourcePath}getResourceMode(){return this.resourceMode}getSparqlEndpoint(){return this.sparqlEndpoint}shouldRegisterTypeIndex(){return this.registerTypeIndexEnabled}async init(e){await e.registerTable(this)}isInitialized(){return this.initialized}markInitialized(e=!0){this.initialized=e}setBase(e){const t=this.resolveBase(e,this.config.name);this.resourcePath=t.resourcePath,this.containerPath=t.containerPath,this.config.base=t.resourcePath,this.config.containerPath=t.containerPath,this._?.config&&(this._.config.base=this.config.base,this._.config.containerPath=this.config.containerPath),this.hasCustomSubjectTemplate||(this.subjectTemplate=void 0,delete this.config.subjectTemplate,this._?.config&&delete this._.config.subjectTemplate),this.mapping=this.buildTableMapping()}setSubjectTemplate(e){this.subjectTemplate=e,this.hasCustomSubjectTemplate=!0,this.config.subjectTemplate=e,this._?.config&&(this._.config.subjectTemplate=e),this.mapping=this.buildTableMapping()}setSparqlEndpoint(e){this.sparqlEndpoint=e,this.resourceMode||(this.resourceMode="sparql")}getColumns(){return this.columns}getColumn(e){return this.columns[e]}hasColumn(e){return e in this.columns}resolveSubjectTemplate(e,t,n,s){return e&&e.trim().length>0?{template:e.trim(),isCustom:!0}:{template:void 0,isCustom:!1}}buildTableMapping(){const e={};for(const t of Object.values(this.columns))e[t.name]=this.buildColumnMapping(t);return{name:this.config.name,type:this.config.type,subjectTemplate:this.subjectTemplate,namespace:this.config.namespace,subClassOf:this.parentClasses.length>0?[...this.parentClasses]:void 0,columns:e,relations:this.relations}}buildColumnMapping(e){const t=e._virtualId?"@id":e.getPredicate(this.config.namespace);return{column:e.name,predicate:t,kind:e.isLink()?"object":"datatype",datatype:this.inferColumnDatatype(e),linkTarget:e.getLinkTarget(),isArray:e.options.isArray??!1,inverse:e.isInverse()}}inferColumnDatatype(e){switch(e.dataType){case"string":return"http://www.w3.org/2001/XMLSchema#string";case"integer":return"http://www.w3.org/2001/XMLSchema#integer";case"boolean":return"http://www.w3.org/2001/XMLSchema#boolean";case"datetime":return"http://www.w3.org/2001/XMLSchema#dateTime";case"json":case"object":return"http://www.w3.org/2001/XMLSchema#json";default:return}}normalizeParents(e){if(!e)return[];const n=(Array.isArray(e)?e:[e]).map(s=>resolveTermIri(s)).filter(s=>s&&s.length>0);return Array.from(new Set(n))}}_a$a=entityKind;PodTable[_a$a]="PodTable";function podTable(i,e,t){const n={};for(const[s,a]of Object.entries(e)){if(a instanceof PodColumnBase){n[s]=a;continue}let u;switch(a.dataType){case"integer":u=new PodIntegerColumn(a.name,a.options);break;case"datetime":u=new PodDateTimeColumn(a.name,a.options);break;case"boolean":u=new PodBooleanColumn(a.name,a.options);break;case"json":u=new PodJsonColumn(a.name,a.options);break;case"object":u=new PodObjectColumn(a.name,a.options);break;case"array":{const h=a.elementType??a.options.baseType??"string";u=new PodArrayColumn(a.name,h,a.options);break}case"uri":u=new PodUriColumn(a.name,a.options);break;default:u=new PodStringColumn(a.name,a.options);break}const c=a.getPredicateUri?.();c&&u.predicate(c),n[s]=u}return new PodTable(i,n,t)}class SolidSchema{constructor(e,t){this.columns=e,this.options=t,this.$kind="SolidSchema",this.namespace=t.namespace,this.subjectTemplate=t.subjectTemplate,this.subClassOf=t.subClassOf?Array.isArray(t.subClassOf)?t.subClassOf.map(resolveTermIri):[resolveTermIri(t.subClassOf)]:void 0}table(e,t){return new PodTable(e,this.columns,{...this.options,...t})}extend(e,t){const n=mergeSchemaColumns(this,e),s=[this.type];return this.subClassOf&&s.push(...this.subClassOf),solidSchema(n,{...t,subClassOf:s})}get type(){return resolveTermIri(this.options.type)}}function solidSchema(i,e){const t={};for(const[n,s]of Object.entries(i)){if(s instanceof PodColumnBase){t[n]=s;continue}let a;switch(s.dataType){case"integer":a=new PodIntegerColumn(s.name,s.options);break;case"datetime":a=new PodDateTimeColumn(s.name,s.options);break;case"boolean":a=new PodBooleanColumn(s.name,s.options);break;case"json":a=new PodJsonColumn(s.name,s.options);break;case"object":a=new PodObjectColumn(s.name,s.options);break;case"array":{const c=s.elementType??s.options.baseType??"string";a=new PodArrayColumn(s.name,c,s.options);break}case"uri":a=new PodUriColumn(s.name,s.options);break;default:a=new PodStringColumn(s.name,s.options);break}const u=s.getPredicateUri?.();u&&a.predicate(u),t[n]=a}return new SolidSchema(t,e)}function isSolidSchema(i){return i instanceof SolidSchema||i?.$kind==="SolidSchema"}const index=Object.freeze(Object.defineProperty({__proto__:null,ColumnBuilder,PodArrayColumn,PodBooleanColumn,PodColumnBase,PodDateTimeColumn,PodIntegerColumn,PodJsonColumn,PodObjectColumn,PodStringColumn,PodTable,PodUriColumn,SolidSchema,boolean:boolean$2,date:date$3,generateNanoId,hasStringValue:hasStringValue$2,hasTermValue,id,integer:integer$1,isSolidSchema,mergeSchemaColumns,object:object$1,podTable,resolveTermIri,solidSchema,string:string$2,uri,validateColumnOverride},Symbol.toStringTag,{value:"Module"})),XSD$8="http://www.w3.org/2001/XMLSchema#";function getPredicateForColumn(i,e){if(!i)return"http://example.org/unknown";if(typeof e.getMapping=="function"){const s=e.getMapping()?.columns?.[i.name];if(s?.predicate)return s.predicate}if(typeof i.getPredicateUri=="function")return i.getPredicateUri();if(i._predicateUri)return i._predicateUri;if(i.predicate&&typeof i.predicate=="string")return i.predicate;const t=e instanceof SolidSchema?e.options.namespace:e.config.namespace;if(typeof i.getPredicate=="function")try{return i.getPredicate(t)}catch{}return i.options?.predicate?i.options.predicate:t?`${typeof t=="string"?t:t.uri}${i.name}`:(i.name==="id"&&console.log("[DEBUG] getPredicateForColumn 'id' fallback to example.org. Column:",i),`http://example.org/${i.name}`)}function formatValue(i,e,t,n){return Array.isArray(i)?i.map(s=>formatSingleValue(s,e,t,n)):formatSingleValue(i,e,t,n)}function formatSingleValue(i,e,t,n){if(i==null)return'""';if(e?.dataType==="uri"||e?.options?.linkTarget){const s=String(i);if(s.startsWith("<")&&s.endsWith(">")){const a=s.slice(1,-1);return t&&!t.isAbsoluteUri(a)?`<${t.resolveLink(a,e,n)}>`:s}return t?`<${t.resolveLink(s,e,n)}>`:s.startsWith("<")?s:`<${s}>`}return typeof i=="string"?!e&&(i.startsWith("http://")||i.startsWith("https://"))?`<${i}>`:`"${i.replace(/\\/g,"\\\\").replace(/"/g,'"')}"`:typeof i=="number"?Number.isInteger(i)?String(i):`"${i}"^^<${XSD$8}decimal>`:typeof i=="boolean"?`"${i}"^^<${XSD$8}boolean>`:i instanceof Date?`"${i.toISOString()}"^^<${XSD$8}dateTime>`:`"${String(i)}"`}function resolveColumn(i,e){if(i&&typeof i=="object"&&i instanceof PodColumnBase)return i;if(i&&typeof i=="object"&&"name"in i){const t=i.name;if(typeof t=="string"&&e.columns[t])return e.columns[t]}if(typeof i=="string"){const t=e.columns[i];if(t)return t}throw new Error(`Unable to resolve column reference for select field: ${String(i)}`)}function generateSubjectUri(i,e,t){const n=t.resolveSubject(e,i);if(!n)throw new Error("Failed to generate subject URI");return n}var _a$9;class SPARQLExpression{constructor(){this[_a$9]="SPARQLExpression"}}_a$9=Symbol.toStringTag;class BinaryExpression extends SPARQLExpression{constructor(e,t,n){super(),this.left=e,this.operator=t,this.right=n,this.type="binary_expr"}}class LogicalExpression extends SPARQLExpression{constructor(e,t){super(),this.operator=e,this.expressions=t,this.type="logical_expr"}}class UnaryExpression extends SPARQLExpression{constructor(e,t){super(),this.operator=e,this.value=t,this.type="unary_expr"}}class SelectionAliasExpression extends SPARQLExpression{constructor(e){super(),this.alias=e}}function eq(i,e){return new BinaryExpression(i,"=",e)}function inArray(i,e){return new BinaryExpression(i,"IN",e)}function and(...i){return new LogicalExpression("AND",i.filter(Boolean))}function parseActivityStreamsMessage(i){const e=JSON.parse(i);return{id:e.id||e["@id"]||"",type:e.type,object:typeof e.object=="string"?e.object:e.object?.id||e.object?.["@id"]||"",published:e.published||new Date().toISOString(),state:e.state}}class BaseChannel{constructor(e){this._connected=!1,this.config=e}get connected(){return this._connected}handleMessage(e){try{const t=parseActivityStreamsMessage(e);this.config.onNotification(t)}catch(t){this.handleError(new Error(`Failed to parse notification: ${t}`))}}handleError(e){this.config.onError?this.config.onError(e):console.error("[NotificationChannel] Error:",e)}handleClose(){this._connected=!1,this.config.onClose&&this.config.onClose()}}class SSEChannel extends BaseChannel{constructor(e){super(e),this.abortController=null,this.reader=null,this.contentType=""}async connect(){if(this._connected)return;this.abortController=new AbortController;const e=this.config.fetch||fetch;try{const t=`notify-sse-${Date.now()}`,n=await e(this.config.receiveFrom,{method:"GET",headers:{Accept:"text/turtle, text/event-stream","X-Request-ID":t},signal:this.abortController.signal});if(!n.ok)throw new Error(`SSE connection failed: ${n.status} ${n.statusText}`);if(!n.body)throw new Error("SSE response has no body");this.contentType=n.headers.get("content-type")||"",this._connected=!0,this.reader=n.body.getReader(),this.readStream()}catch(t){throw t.name!=="AbortError"&&this.handleError(t),t}}disconnect(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.reader&&(this.reader.cancel().catch(()=>{}),this.reader=null),this._connected=!1,this.handleClose()}async readStream(){if(!this.reader)return;const e=new TextDecoder;let t="";try{for(;this._connected;){const{done:n,value:s}=await this.reader.read();if(n){t.trim()&&this.parseNotification(t.trim()),this.handleClose();break}const a=e.decode(s,{stream:!0});t+=a,this.contentType.includes("text/turtle")?t=this.processTurtleBuffer(t):t=this.processSSEBuffer(t)}}catch(n){n.name!=="AbortError"&&this.handleError(n)}}processTurtleBuffer(e){const t=e.split(`
90
+ `);let n="";for(let s=0;s<t.length;s++){const a=t[s];n+=a+`
91
+ `,a.trim().endsWith(".")&&(this.parseTurtleNotification(n.trim()),n="")}return n}processSSEBuffer(e){const t=e.split(`
92
+
93
+ `),n=t.pop()||"";for(const s of t)s.trim()&&this.parseSSEMessage(s);return n}parseTurtleNotification(e){try{const t=e.match(/<https:\/\/www\.w3\.org\/ns\/activitystreams#object>\s*<([^>]+)>/),n=e.match(/a\s*<https:\/\/www\.w3\.org\/ns\/activitystreams#(\w+)>/),s=e.match(/<https:\/\/www\.w3\.org\/ns\/activitystreams#published>\s*"([^"]+)"/),a=e.match(/<http:\/\/www\.w3\.org\/ns\/solid\/notifications#state>\s*"([^"]+)"/),u=e.match(/^<([^>]+)>/);if(!t||!n)return;const c={id:u?.[1]||`urn:notification:${Date.now()}`,type:n[1],object:t[1],published:s?.[1]||new Date().toISOString(),state:a?.[1]};this.handleMessage(JSON.stringify(c))}catch(t){console.warn("[SSE] Failed to parse Turtle notification:",t)}}parseNotification(e){e.startsWith("{")?this.handleMessage(e):e.includes("activitystreams")&&this.parseTurtleNotification(e)}parseSSEMessage(e){const t=e.split(`
94
+ `);let n="",s="message";for(const a of t)a.startsWith("data:")?n+=a.slice(5).trim():a.startsWith("event:")&&(s=a.slice(6).trim());n&&s==="message"&&this.handleMessage(n)}}const getWebSocket=()=>{if(typeof WebSocket<"u")return WebSocket;try{return require("ws")}catch{throw new Error('WebSocket is not available. Install "ws" package for Node.js support.')}};class WebSocketChannel extends BaseChannel{constructor(e){super(e),this.ws=null,this.reconnectAttempts=0,this.maxReconnectAttempts=3,this.reconnectDelay=1e3}async connect(){if(!this._connected)return new Promise((e,t)=>{try{const n=getWebSocket();this.ws=new n(this.config.receiveFrom),this.ws.onopen=()=>{this._connected=!0,this.reconnectAttempts=0,e()},this.ws.onmessage=s=>{const a=typeof s.data=="string"?s.data:s.data?.toString?.()||"";this.handleMessage(a)},this.ws.onerror=()=>{const s=new Error("WebSocket error");this.handleError(s),this._connected||t(s)},this.ws.onclose=s=>{this._connected=!1,!s.wasClean&&this.reconnectAttempts<this.maxReconnectAttempts?(this.reconnectAttempts++,setTimeout(()=>{this.connect().catch(()=>{})},this.reconnectDelay*this.reconnectAttempts)):this.handleClose()}}catch(n){t(n)}})}disconnect(){this.reconnectAttempts=this.maxReconnectAttempts,this.ws&&(this.ws.close(1e3,"Client disconnect"),this.ws=null),this._connected=!1}}const CHANNEL_TYPE_URI={"streaming-http":"http://www.w3.org/ns/solid/notifications#StreamingHTTPChannel2023",websocket:"http://www.w3.org/ns/solid/notifications#WebSocketChannel2023"},CHANNEL_NAMES={"streaming-http":"StreamingHTTPChannel2023",websocket:"WebSocketChannel2023"};class NotificationsClient{constructor(e,t){this.subscriptions=new Map,this.fetch=e,this.preferredChannels=t?.preferredChannels??["streaming-http","websocket"]}async subscribe(e,t){const n=await this.discoverNotificationService(e),a=(t.channel?[t.channel,...this.preferredChannels.filter(c=>c!==t.channel)]:this.preferredChannels).filter(c=>n.supportedChannels.includes(c));if(a.length===0)throw new Error(`No supported notification channels found for ${e}. Server supports: ${n.supportedChannels.join(", ")}`);let u=null;for(const c of a)try{return await this.connectChannel(c,e,n,t)}catch(h){console.log(`[Notifications] Channel "${c}" failed, trying next...`),u=h}throw u??new Error(`Failed to connect to any notification channel for ${e}`)}async resubscribe(e,t,n,s){let a;if(t==="streaming-http")a=this.buildSSEDirectUrl(n.baseEndpoint,e),console.log(`[Notifications] SSE reconnect to: ${a}`);else{const h=`${n.baseEndpoint}${CHANNEL_NAMES[t]}/`;a=(await this.createSubscription(h,e,t,s.features)).receiveFrom,console.log(`[Notifications] WebSocket resubscription created, receiveFrom: ${a}`)}const u=this.subscriptions.get(e),c=this.createChannelWithReconnect(t,a,s,u);return await c.connect(),c}async connectChannel(e,t,n,s){let a;if(e==="streaming-http")a=this.buildSSEDirectUrl(n.baseEndpoint,t),console.log(`[Notifications] SSE direct connect to: ${a}`);else{const h=`${n.baseEndpoint}${CHANNEL_NAMES[e]}/`;a=(await this.createSubscription(h,t,e,s.features)).receiveFrom,console.log(`[Notifications] WebSocket subscription created, receiveFrom: ${a}`)}const u=new SubscriptionImpl(t,e,null,()=>this.subscriptions.delete(t),this,s,n),c=this.createChannelWithReconnect(e,a,s,u);return await c.connect(),u.setChannel(c),this.subscriptions.set(t,u),u}buildSSEDirectUrl(e,t){return`${e.endsWith("/")?e:`${e}/`}StreamingHTTPChannel2023/${encodeURIComponent(t)}`}unsubscribeAll(){for(const e of this.subscriptions.values())e.unsubscribe();this.subscriptions.clear()}async discoverNotificationService(e){const t=await this.discoverFromLinkHeader(e);if(t)return t;const n=new URL(e),s=`${n.origin}/.well-known/solid`;try{return await this.fetchStorageDescription(s,n.origin)}catch{return{baseEndpoint:`${n.origin}/.notifications/`,supportedChannels:["websocket","streaming-http"]}}}async discoverFromLinkHeader(e){try{const n=(await this.fetch(e,{method:"HEAD"})).headers.get("Link");if(!n)return null;const s=new URL(e),a=[],u=n.match(/<([^>]+)>;\s*rel="?http:\/\/www\.w3\.org\/ns\/solid\/terms#updatesViaStreamingHttp2023"?/);u&&a.push("streaming-http");const c=n.match(/<([^>]+)>;\s*rel="?http:\/\/www\.w3\.org\/ns\/solid\/terms#updatesViaWebSocketChannel2023"?/);if(c&&a.push("websocket"),u){const h=u[1],f=new URL(h),p=f.pathname.split("/"),g=p.findIndex(y=>y===".notifications");if(g!==-1){const y=p.slice(0,g+1).join("/")+"/";return a.includes("websocket")||a.push("websocket"),{baseEndpoint:`${f.origin}${y}`,supportedChannels:a}}}return c&&a.length>0?{baseEndpoint:`${s.origin}/.notifications/`,supportedChannels:a}:null}catch{return null}}async findStorageRoot(e){try{const a=(await this.fetch(e,{method:"HEAD"})).headers.get("Link");if(a){const u=a.match(/<([^>]+)>;\s*rel="?http:\/\/www\.w3\.org\/ns\/pim\/space#storage"?/);if(u)return u[1]}}catch{}const t=new URL(e),n=t.pathname.split("/").filter(Boolean);return n.length>0?`${t.origin}/${n[0]}/`:`${t.origin}/`}async fetchStorageDescription(e,t){const n=await this.fetch(e,{headers:{Accept:"text/turtle, application/ld+json"}});if(!n.ok)throw new Error(`Failed to fetch storage description: ${n.status}`);const s=await n.text(),a=[],u=/<http:\/\/www\.w3\.org\/ns\/solid\/notifications#subscription>\s+<([^>]+)>/g,c=/notify:subscription[>\s]+<([^>]+)>/g;let h;const f=[];for(;(h=u.exec(s))!==null;)f.push(h[1]);for(;(h=c.exec(s))!==null;)f.push(h[1]);for(const g of f)g.includes("WebSocketChannel2023")&&!a.includes("websocket")&&a.push("websocket"),g.includes("StreamingHTTPChannel2023")&&!a.includes("streaming-http")&&a.push("streaming-http");return a.length===0&&(s.includes("WebSocketChannel2023")&&a.push("websocket"),s.includes("StreamingHTTPChannel2023")&&a.push("streaming-http")),{baseEndpoint:`${new URL(t).origin}/.notifications/`,supportedChannels:a.length>0?a:["websocket"]}}async createSubscription(e,t,n,s){const a={"@context":["https://www.w3.org/ns/solid/notification/v1"],type:CHANNEL_TYPE_URI[n],topic:t,...s&&s.length>0?{features:s}:{}},u=`notify-sub-${Date.now()}`,c=await this.fetch(e,{method:"POST",headers:{"Content-Type":"application/ld+json",Accept:"application/ld+json","X-Request-ID":u},body:JSON.stringify(a)});if(!c.ok){const h=await c.text();throw new Error(`Failed to create subscription: ${c.status} ${c.statusText} - ${h}`)}return c.json()}createChannel(e,t,n){const s={receiveFrom:t,onNotification:n.onNotification,onError:n.onError,onClose:n.onClose,fetch:this.fetch};switch(e){case"streaming-http":return new SSEChannel(s);case"websocket":return new WebSocketChannel(s);default:throw new Error(`Unsupported channel type: ${e}`)}}createChannelWithReconnect(e,t,n,s){const a={receiveFrom:t,onNotification:n.onNotification,onError:n.onError,onClose:()=>{s?s.handleDisconnect():n.onClose?.()},fetch:this.fetch};switch(e){case"streaming-http":return new SSEChannel(a);case"websocket":return new WebSocketChannel(a);default:throw new Error(`Unsupported channel type: ${e}`)}}}class SubscriptionImpl{constructor(e,t,n,s,a,u,c){this._active=!0,this.reconnectAttempts=0,this.reconnectTimer=null,this.isReconnecting=!1,this._topic=e,this._channel=t,this.notificationChannel=n,this.onUnsubscribe=s,this.client=a,this.options=u,this.discovery=c}setChannel(e){this.notificationChannel=e}get active(){return this._active&&(this.notificationChannel?.connected||this.isReconnecting)}get channel(){return this._channel}get topic(){return this._topic}handleDisconnect(){if(!this._active)return;const e=this.options.autoReconnect!==!1,t=this.options.maxReconnectAttempts??5;if(!e){this.options.onClose?.();return}if(t>0&&this.reconnectAttempts>=t){console.log(`[Notifications] Max reconnect attempts (${t}) reached for ${this._topic}`),this.options.onClose?.();return}this.isReconnecting=!0,this.reconnectAttempts++;const n=this.options.reconnectDelayMs??1e3,s=Math.min(n*Math.pow(2,this.reconnectAttempts-1),3e4);console.log(`[Notifications] Connection lost for ${this._topic}, reconnecting in ${s}ms (attempt ${this.reconnectAttempts})`),this.options.onReconnect?.(this.reconnectAttempts),this.reconnectTimer=setTimeout(async()=>{try{const a=await this.client.resubscribe(this._topic,this._channel,this.discovery,this.options);this.notificationChannel=a,this.reconnectAttempts=0,this.isReconnecting=!1,console.log(`[Notifications] Reconnected successfully for ${this._topic}`)}catch(a){console.error(`[Notifications] Reconnect failed for ${this._topic}:`,a),this.isReconnecting=!1,this.handleDisconnect()}},s)}unsubscribe(){this._active&&(this._active=!1,this.isReconnecting=!1,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.notificationChannel?.disconnect(),this.onUnsubscribe())}}const SOLID={typeIndex:"http://www.w3.org/ns/solid/terms#publicTypeIndex",privateTypeIndex:"http://www.w3.org/ns/solid/terms#privateTypeIndex",oidcIssuer:"http://www.w3.org/ns/solid/terms#oidcIssuer"},INTEROP$1={hasRegistrySet:"http://www.w3.org/ns/solid/interop#hasRegistrySet"};class ProviderCache{constructor(e){this.cache=new Map,this.ttl=e?.ttl??1440*60*1e3,this.fetchFn=e?.fetch??fetch}async getWellKnown(e){const t=this.extractProvider(e),n=this.cache.get(t);if(n&&Date.now()<n.expiresAt)return this.applyToPod(n.paths,e);const s=await this.fetchWellKnown(e),a=this.extractPaths(s,e);return this.cache.set(t,{paths:a,expiresAt:Date.now()+this.ttl}),s}async discover(e,t,n,s){const a=await this.getWellKnown(e);if(a.registrySet){const u=await n(a.registrySet,t);if(u)return u}return a.typeIndex?s(a.typeIndex,t):null}setTTL(e){this.ttl=e}clear(){this.cache.clear()}clearProvider(e){this.cache.delete(e)}extractProvider(e){const t=new URL(e).host,n=t.split(".");return n.length>=2?n.slice(-2).join("."):t}async fetchWellKnown(e){const t=e.endsWith("/")?e:`${e}/`,n=`${t}.well-known/solid`;try{const s=await this.fetchFn(n,{headers:{Accept:"text/turtle, application/ld+json"}});if(!s.ok)return{};const a=s.headers.get("content-type")||"",u=await s.text();return a.includes("turtle")||a.includes("n3")?this.parseTurtle(u,t):a.includes("json")?this.parseJsonLd(u):this.parseTurtle(u,t)}catch{return{}}}parseTurtle(e,t){const n={raw:{}},s=e.split(/\s*;\s*|\s*\.\s*(?=\n|$)|\n/).map(a=>a.trim()).filter(Boolean);for(const a of s){if(a.includes("publicTypeIndex")||a.includes(SOLID.typeIndex)){const u=this.extractUrl(a);u&&(n.typeIndex=this.resolveUrl(u,t))}if(a.includes("privateTypeIndex")||a.includes(SOLID.privateTypeIndex)){const u=this.extractUrl(a);u&&(n.privateTypeIndex=this.resolveUrl(u,t))}if(a.includes("hasRegistrySet")||a.includes(INTEROP$1.hasRegistrySet)){const u=this.extractUrl(a);u&&(n.registrySet=this.resolveUrl(u,t))}if(a.includes("oidcIssuer")||a.includes(SOLID.oidcIssuer)){const u=this.extractUrl(a);u&&(n.oidcIssuer=this.resolveUrl(u,t))}}return n}extractUrl(e){const t=e.match(/<([^>]+)>/g);return t&&t.length>0?t[t.length-1].slice(1,-1):null}parseJsonLd(e){try{const t=JSON.parse(e),n={raw:{}},s=t["@graph"]||[t];for(const a of s)(a[SOLID.typeIndex]||a["solid:publicTypeIndex"])&&(n.typeIndex=this.extractJsonLdValue(a[SOLID.typeIndex]||a["solid:publicTypeIndex"])),(a[SOLID.privateTypeIndex]||a["solid:privateTypeIndex"])&&(n.privateTypeIndex=this.extractJsonLdValue(a[SOLID.privateTypeIndex]||a["solid:privateTypeIndex"])),(a[INTEROP$1.hasRegistrySet]||a["interop:hasRegistrySet"])&&(n.registrySet=this.extractJsonLdValue(a[INTEROP$1.hasRegistrySet]||a["interop:hasRegistrySet"])),(a[SOLID.oidcIssuer]||a["solid:oidcIssuer"])&&(n.oidcIssuer=this.extractJsonLdValue(a[SOLID.oidcIssuer]||a["solid:oidcIssuer"]));return n}catch{return{}}}extractJsonLdValue(e){if(typeof e=="string")return e;if(typeof e=="object"&&e!==null)return e["@id"]}resolveUrl(e,t){return e.startsWith("http://")||e.startsWith("https://")?e:new URL(e,t).toString()}extractPaths(e,t){const n=t.endsWith("/")?t:`${t}/`,s={};return e.typeIndex&&(s.typeIndex=this.toRelativePath(e.typeIndex,n)),e.privateTypeIndex&&(s.privateTypeIndex=this.toRelativePath(e.privateTypeIndex,n)),e.registrySet&&(s.registrySet=this.toRelativePath(e.registrySet,n)),e.oidcIssuer&&(s.oidcIssuer=e.oidcIssuer),s}toRelativePath(e,t){return e.startsWith(t)?e.slice(t.length-1):e}applyToPod(e,t){const n=t.endsWith("/")?t:`${t}/`,s={};return e.typeIndex&&(s.typeIndex=this.toAbsoluteUrl(e.typeIndex,n)),e.privateTypeIndex&&(s.privateTypeIndex=this.toAbsoluteUrl(e.privateTypeIndex,n)),e.registrySet&&(s.registrySet=this.toAbsoluteUrl(e.registrySet,n)),e.oidcIssuer&&(s.oidcIssuer=e.oidcIssuer),s}toAbsoluteUrl(e,t){return e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/")?`${t.slice(0,-1)}${e}`:`${t}${e}`}}class FederatedQueryExecutor{constructor(e){this.providerCache=e?.providerCache??new ProviderCache,this.fetchFn=e?.fetch??fetch,this.defaultTimeout=e?.timeout??3e4}async execute(e,t,n){const s=[],a=[...e];if(!t.isFederated||!t.discover)return{data:a};const u=t.table,c=t.discover,h=t.relationName??"items",f=u.type,p=[];for(let S=0;S<e.length;S++){const w=e[S],R=c(w);if(!R){a[S][h]=[];continue}const A=(Array.isArray(R)?R:[R]).filter(F=>typeof F=="string"&&F.length>0);if(A.length===0){a[S][h]=[];continue}p.push({index:S,webIds:A})}const g=n?.parallel??!0,y=n?.maxConcurrency??5;return g?await this.executeParallel(a,p,f,h,s,y,n?.timeout??this.defaultTimeout):await this.executeSequential(a,p,f,h,s,n?.timeout??this.defaultTimeout),{data:a,errors:s.length>0?s:void 0}}async executeParallel(e,t,n,s,a,u,c){for(let h=0;h<t.length;h+=u){const f=t.slice(h,h+u);await Promise.all(f.map(async p=>{try{const g=await this.discoverAndQuery(p.webIds,n,c);e[p.index][s]=g}catch(g){e[p.index][s]=[],a.push(this.createError([p.index,s],g,p.webIds[0]))}}))}}async executeSequential(e,t,n,s,a,u){for(const c of t)try{const h=await this.discoverAndQuery(c.webIds,n,u);e[c.index][s]=h}catch(h){e[c.index][s]=[],a.push(this.createError([c.index,s],h,c.webIds[0]))}}async discoverAndQuery(e,t,n){const s=[];for(const a of e){const u=this.extractPodUrl(a);if(!u)continue;const c=await this.providerCache.getWellKnown(u),h=await this.discoverContainer(u,c,t);if(!h)continue;const f=await this.queryContainer(h,t,n);s.push(...f)}return s}extractPodUrl(e){try{const t=new URL(e);return`${t.protocol}//${t.host}/`}catch{return null}}async discoverContainer(e,t,n){if(t.registrySet){const s=await this.discoverFromSAI(t.registrySet,n);if(s)return s}if(t.typeIndex){const s=await this.discoverFromTypeIndex(t.typeIndex,n);if(s)return s}return null}async discoverFromSAI(e,t){try{const n=await this.fetchFn(e,{headers:{Accept:"text/turtle"}});if(!n.ok)return null;const a=(await n.text()).match(/hasDataRegistry>\s*<([^>]+)>/);if(!a)return null;const u=this.resolveUrl(a[1],e),c=await this.fetchFn(u,{headers:{Accept:"text/turtle"}});if(!c.ok)return null;const f=(await c.text()).matchAll(/hasDataRegistration>\s*<([^>]+)>/g);for(const p of f){const g=this.resolveUrl(p[1],u),y=await this.fetchFn(g,{headers:{Accept:"text/turtle"}});if(!y.ok)continue;const w=(await y.text()).match(/registeredShapeTree>\s*<([^>]+)>/);if(!w)continue;const R=this.resolveUrl(w[1],g),T=await this.fetchFn(R,{headers:{Accept:"text/turtle"}});if(!T.ok)continue;if((await T.text()).includes(t))return g.endsWith("/")?g:g+"/"}return null}catch{return null}}resolveUrl(e,t){return e.startsWith("http://")||e.startsWith("https://")?e:new URL(e,t).toString()}async discoverFromTypeIndex(e,t){try{const n=await this.fetchFn(e,{headers:{Accept:"text/turtle"}});if(!n.ok)return null;const a=(await n.text()).split(/\s*[;.]\s*|\n/).map(h=>h.trim()).filter(Boolean);let u=!1,c=null;for(const h of a)if(h.includes("forClass")&&h.includes(t)&&(u=!0),u){if(h.includes("instance")&&!h.includes("instanceContainer")){const f=h.match(/<([^>]+)>/);if(f){c=f[1];break}}if(h.includes("instanceContainer")){const f=h.match(/<([^>]+)>/);if(f){c=f[1];break}}}return c}catch{return null}}async queryContainer(e,t,n){try{const s=new AbortController,a=setTimeout(()=>s.abort(),n),u=await this.fetchFn(e,{headers:{Accept:"text/turtle"},signal:s.signal});if(clearTimeout(a),!u.ok){if(u.status===403)throw new Error(`403 Forbidden: ${e}`);if(u.status===404)throw new Error(`404 Not Found: ${e}`);return[]}const c=await u.text();return this.parseTurtleResources(c,e,t)}catch(s){throw s instanceof Error&&s.name==="AbortError"?new Error(`Timeout: ${e}`):s}}parseTurtleResources(e,t,n){const s=[],a={},u=/@prefix\s+(\w+):\s*<([^>]+)>\s*\./g;let c;for(;(c=u.exec(e))!==null;)a[c[1]]=c[2];const h=new RegExp(`<([^>]+)>\\s+(?:a|rdf:type|<http://www\\.w3\\.org/1999/02/22-rdf-syntax-ns#type>)\\s+<${this.escapeRegex(n)}>`,"g"),f=[];for(;(c=h.exec(e))!==null;)f.push(c[1]);for(const p of f){const g=this.extractResourceProperties(e,p,a,t);g&&s.push(g)}return s}extractResourceProperties(e,t,n,s){const a={"@id":t,id:this.extractIdFromUri(t)},u=this.escapeRegex(t),c=new RegExp(`<${u}>\\s+<([^>]+)>\\s+<([^>]+)>`,"g");let h;for(;(h=c.exec(e))!==null;){const p=h[1],g=h[2],y=this.extractLocalName(p);p.includes("22-rdf-syntax-ns#type")||(a[y]=g)}const f=new RegExp(`<${u}>\\s+<([^>]+)>\\s+"([^"]*)"`,"g");for(;(h=f.exec(e))!==null;){const p=h[1],g=h[2],y=this.extractLocalName(p);a[y]=g}return a}extractIdFromUri(e){const t=e.indexOf("#");if(t!==-1)return e.slice(t);const n=e.lastIndexOf("/");return n!==-1?e.slice(n+1):e}extractLocalName(e){return e.includes("#")?e.split("#").pop()??e:e.split("/").pop()??e}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}createError(e,t,n){const s=t instanceof Error?t.message:String(t);let a="NETWORK_ERROR";return s.includes("403")||s.includes("Forbidden")?a="FORBIDDEN":s.includes("404")||s.includes("Not Found")?a="NOT_FOUND":s.includes("timeout")||s.includes("Timeout")?a="TIMEOUT":s.includes("discover")&&(a="DISCOVERY_FAILED"),{path:e,code:a,message:s,url:n}}}new FederatedQueryExecutor;var buffer={},base64Js={},hasRequiredBase64Js;function requireBase64Js(){if(hasRequiredBase64Js)return base64Js;hasRequiredBase64Js=1,base64Js.byteLength=c,base64Js.toByteArray=f,base64Js.fromByteArray=y;for(var i=[],e=[],t=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=n.length;s<a;++s)i[s]=n[s],e[n.charCodeAt(s)]=s;e[45]=62,e[95]=63;function u(S){var w=S.length;if(w%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var R=S.indexOf("=");R===-1&&(R=w);var T=R===w?0:4-R%4;return[R,T]}function c(S){var w=u(S),R=w[0],T=w[1];return(R+T)*3/4-T}function h(S,w,R){return(w+R)*3/4-R}function f(S){var w,R=u(S),T=R[0],A=R[1],F=new t(h(S,T,A)),x=0,D=A>0?T-4:T,O;for(O=0;O<D;O+=4)w=e[S.charCodeAt(O)]<<18|e[S.charCodeAt(O+1)]<<12|e[S.charCodeAt(O+2)]<<6|e[S.charCodeAt(O+3)],F[x++]=w>>16&255,F[x++]=w>>8&255,F[x++]=w&255;return A===2&&(w=e[S.charCodeAt(O)]<<2|e[S.charCodeAt(O+1)]>>4,F[x++]=w&255),A===1&&(w=e[S.charCodeAt(O)]<<10|e[S.charCodeAt(O+1)]<<4|e[S.charCodeAt(O+2)]>>2,F[x++]=w>>8&255,F[x++]=w&255),F}function p(S){return i[S>>18&63]+i[S>>12&63]+i[S>>6&63]+i[S&63]}function g(S,w,R){for(var T,A=[],F=w;F<R;F+=3)T=(S[F]<<16&16711680)+(S[F+1]<<8&65280)+(S[F+2]&255),A.push(p(T));return A.join("")}function y(S){for(var w,R=S.length,T=R%3,A=[],F=16383,x=0,D=R-T;x<D;x+=F)A.push(g(S,x,x+F>D?D:x+F));return T===1?(w=S[R-1],A.push(i[w>>2]+i[w<<4&63]+"==")):T===2&&(w=(S[R-2]<<8)+S[R-1],A.push(i[w>>10]+i[w>>4&63]+i[w<<2&63]+"=")),A.join("")}return base64Js}var ieee754={};var hasRequiredIeee754;function requireIeee754(){return hasRequiredIeee754||(hasRequiredIeee754=1,ieee754.read=function(i,e,t,n,s){var a,u,c=s*8-n-1,h=(1<<c)-1,f=h>>1,p=-7,g=t?s-1:0,y=t?-1:1,S=i[e+g];for(g+=y,a=S&(1<<-p)-1,S>>=-p,p+=c;p>0;a=a*256+i[e+g],g+=y,p-=8);for(u=a&(1<<-p)-1,a>>=-p,p+=n;p>0;u=u*256+i[e+g],g+=y,p-=8);if(a===0)a=1-f;else{if(a===h)return u?NaN:(S?-1:1)*(1/0);u=u+Math.pow(2,n),a=a-f}return(S?-1:1)*u*Math.pow(2,a-n)},ieee754.write=function(i,e,t,n,s,a){var u,c,h,f=a*8-s-1,p=(1<<f)-1,g=p>>1,y=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=n?0:a-1,w=n?1:-1,R=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,u=p):(u=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-u))<1&&(u--,h*=2),u+g>=1?e+=y/h:e+=y*Math.pow(2,1-g),e*h>=2&&(u++,h/=2),u+g>=p?(c=0,u=p):u+g>=1?(c=(e*h-1)*Math.pow(2,s),u=u+g):(c=e*Math.pow(2,g-1)*Math.pow(2,s),u=0));s>=8;i[t+S]=c&255,S+=w,c/=256,s-=8);for(u=u<<s|c,f+=s;f>0;i[t+S]=u&255,S+=w,u/=256,f-=8);i[t+S-w]|=R*128}),ieee754}var hasRequiredBuffer;function requireBuffer(){return hasRequiredBuffer||(hasRequiredBuffer=1,(function(i){const e=requireBase64Js(),t=requireIeee754(),n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=c,i.SlowBuffer=F,i.INSPECT_MAX_BYTES=50;const s=2147483647;i.kMaxLength=s,c.TYPED_ARRAY_SUPPORT=a(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{const Z=new Uint8Array(1),P={foo:function(){return 42}};return Object.setPrototypeOf(P,Uint8Array.prototype),Object.setPrototypeOf(Z,P),Z.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function u(Z){if(Z>s)throw new RangeError('The value "'+Z+'" is invalid for option "size"');const P=new Uint8Array(Z);return Object.setPrototypeOf(P,c.prototype),P}function c(Z,P,B){if(typeof Z=="number"){if(typeof P=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(Z)}return h(Z,P,B)}c.poolSize=8192;function h(Z,P,B){if(typeof Z=="string")return y(Z,P);if(ArrayBuffer.isView(Z))return w(Z);if(Z==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Z);if(de(Z,ArrayBuffer)||Z&&de(Z.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(de(Z,SharedArrayBuffer)||Z&&de(Z.buffer,SharedArrayBuffer)))return R(Z,P,B);if(typeof Z=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const U=Z.valueOf&&Z.valueOf();if(U!=null&&U!==Z)return c.from(U,P,B);const Ie=T(Z);if(Ie)return Ie;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof Z[Symbol.toPrimitive]=="function")return c.from(Z[Symbol.toPrimitive]("string"),P,B);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Z)}c.from=function(Z,P,B){return h(Z,P,B)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function f(Z){if(typeof Z!="number")throw new TypeError('"size" argument must be of type number');if(Z<0)throw new RangeError('The value "'+Z+'" is invalid for option "size"')}function p(Z,P,B){return f(Z),Z<=0?u(Z):P!==void 0?typeof B=="string"?u(Z).fill(P,B):u(Z).fill(P):u(Z)}c.alloc=function(Z,P,B){return p(Z,P,B)};function g(Z){return f(Z),u(Z<0?0:A(Z)|0)}c.allocUnsafe=function(Z){return g(Z)},c.allocUnsafeSlow=function(Z){return g(Z)};function y(Z,P){if((typeof P!="string"||P==="")&&(P="utf8"),!c.isEncoding(P))throw new TypeError("Unknown encoding: "+P);const B=x(Z,P)|0;let U=u(B);const Ie=U.write(Z,P);return Ie!==B&&(U=U.slice(0,Ie)),U}function S(Z){const P=Z.length<0?0:A(Z.length)|0,B=u(P);for(let U=0;U<P;U+=1)B[U]=Z[U]&255;return B}function w(Z){if(de(Z,Uint8Array)){const P=new Uint8Array(Z);return R(P.buffer,P.byteOffset,P.byteLength)}return S(Z)}function R(Z,P,B){if(P<0||Z.byteLength<P)throw new RangeError('"offset" is outside of buffer bounds');if(Z.byteLength<P+(B||0))throw new RangeError('"length" is outside of buffer bounds');let U;return P===void 0&&B===void 0?U=new Uint8Array(Z):B===void 0?U=new Uint8Array(Z,P):U=new Uint8Array(Z,P,B),Object.setPrototypeOf(U,c.prototype),U}function T(Z){if(c.isBuffer(Z)){const P=A(Z.length)|0,B=u(P);return B.length===0||Z.copy(B,0,0,P),B}if(Z.length!==void 0)return typeof Z.length!="number"||st(Z.length)?u(0):S(Z);if(Z.type==="Buffer"&&Array.isArray(Z.data))return S(Z.data)}function A(Z){if(Z>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return Z|0}function F(Z){return+Z!=Z&&(Z=0),c.alloc(+Z)}c.isBuffer=function(P){return P!=null&&P._isBuffer===!0&&P!==c.prototype},c.compare=function(P,B){if(de(P,Uint8Array)&&(P=c.from(P,P.offset,P.byteLength)),de(B,Uint8Array)&&(B=c.from(B,B.offset,B.byteLength)),!c.isBuffer(P)||!c.isBuffer(B))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(P===B)return 0;let U=P.length,Ie=B.length;for(let Me=0,Pe=Math.min(U,Ie);Me<Pe;++Me)if(P[Me]!==B[Me]){U=P[Me],Ie=B[Me];break}return U<Ie?-1:Ie<U?1:0},c.isEncoding=function(P){switch(String(P).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(P,B){if(!Array.isArray(P))throw new TypeError('"list" argument must be an Array of Buffers');if(P.length===0)return c.alloc(0);let U;if(B===void 0)for(B=0,U=0;U<P.length;++U)B+=P[U].length;const Ie=c.allocUnsafe(B);let Me=0;for(U=0;U<P.length;++U){let Pe=P[U];if(de(Pe,Uint8Array))Me+Pe.length>Ie.length?(c.isBuffer(Pe)||(Pe=c.from(Pe)),Pe.copy(Ie,Me)):Uint8Array.prototype.set.call(Ie,Pe,Me);else if(c.isBuffer(Pe))Pe.copy(Ie,Me);else throw new TypeError('"list" argument must be an Array of Buffers');Me+=Pe.length}return Ie};function x(Z,P){if(c.isBuffer(Z))return Z.length;if(ArrayBuffer.isView(Z)||de(Z,ArrayBuffer))return Z.byteLength;if(typeof Z!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof Z);const B=Z.length,U=arguments.length>2&&arguments[2]===!0;if(!U&&B===0)return 0;let Ie=!1;for(;;)switch(P){case"ascii":case"latin1":case"binary":return B;case"utf8":case"utf-8":return ae(Z).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B*2;case"hex":return B>>>1;case"base64":return me(Z).length;default:if(Ie)return U?-1:ae(Z).length;P=(""+P).toLowerCase(),Ie=!0}}c.byteLength=x;function D(Z,P,B){let U=!1;if((P===void 0||P<0)&&(P=0),P>this.length||((B===void 0||B>this.length)&&(B=this.length),B<=0)||(B>>>=0,P>>>=0,B<=P))return"";for(Z||(Z="utf8");;)switch(Z){case"hex":return De(this,P,B);case"utf8":case"utf-8":return $e(this,P,B);case"ascii":return Ve(this,P,B);case"latin1":case"binary":return pe(this,P,B);case"base64":return re(this,P,B);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $(this,P,B);default:if(U)throw new TypeError("Unknown encoding: "+Z);Z=(Z+"").toLowerCase(),U=!0}}c.prototype._isBuffer=!0;function O(Z,P,B){const U=Z[P];Z[P]=Z[B],Z[B]=U}c.prototype.swap16=function(){const P=this.length;if(P%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let B=0;B<P;B+=2)O(this,B,B+1);return this},c.prototype.swap32=function(){const P=this.length;if(P%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let B=0;B<P;B+=4)O(this,B,B+3),O(this,B+1,B+2);return this},c.prototype.swap64=function(){const P=this.length;if(P%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let B=0;B<P;B+=8)O(this,B,B+7),O(this,B+1,B+6),O(this,B+2,B+5),O(this,B+3,B+4);return this},c.prototype.toString=function(){const P=this.length;return P===0?"":arguments.length===0?$e(this,0,P):D.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(P){if(!c.isBuffer(P))throw new TypeError("Argument must be a Buffer");return this===P?!0:c.compare(this,P)===0},c.prototype.inspect=function(){let P="";const B=i.INSPECT_MAX_BYTES;return P=this.toString("hex",0,B).replace(/(.{2})/g,"$1 ").trim(),this.length>B&&(P+=" ... "),"<Buffer "+P+">"},n&&(c.prototype[n]=c.prototype.inspect),c.prototype.compare=function(P,B,U,Ie,Me){if(de(P,Uint8Array)&&(P=c.from(P,P.offset,P.byteLength)),!c.isBuffer(P))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof P);if(B===void 0&&(B=0),U===void 0&&(U=P?P.length:0),Ie===void 0&&(Ie=0),Me===void 0&&(Me=this.length),B<0||U>P.length||Ie<0||Me>this.length)throw new RangeError("out of range index");if(Ie>=Me&&B>=U)return 0;if(Ie>=Me)return-1;if(B>=U)return 1;if(B>>>=0,U>>>=0,Ie>>>=0,Me>>>=0,this===P)return 0;let Pe=Me-Ie,gt=U-B;const _t=Math.min(Pe,gt),Tt=this.slice(Ie,Me),kt=P.slice(B,U);for(let Ft=0;Ft<_t;++Ft)if(Tt[Ft]!==kt[Ft]){Pe=Tt[Ft],gt=kt[Ft];break}return Pe<gt?-1:gt<Pe?1:0};function K(Z,P,B,U,Ie){if(Z.length===0)return-1;if(typeof B=="string"?(U=B,B=0):B>2147483647?B=2147483647:B<-2147483648&&(B=-2147483648),B=+B,st(B)&&(B=Ie?0:Z.length-1),B<0&&(B=Z.length+B),B>=Z.length){if(Ie)return-1;B=Z.length-1}else if(B<0)if(Ie)B=0;else return-1;if(typeof P=="string"&&(P=c.from(P,U)),c.isBuffer(P))return P.length===0?-1:z(Z,P,B,U,Ie);if(typeof P=="number")return P=P&255,typeof Uint8Array.prototype.indexOf=="function"?Ie?Uint8Array.prototype.indexOf.call(Z,P,B):Uint8Array.prototype.lastIndexOf.call(Z,P,B):z(Z,[P],B,U,Ie);throw new TypeError("val must be string, number or Buffer")}function z(Z,P,B,U,Ie){let Me=1,Pe=Z.length,gt=P.length;if(U!==void 0&&(U=String(U).toLowerCase(),U==="ucs2"||U==="ucs-2"||U==="utf16le"||U==="utf-16le")){if(Z.length<2||P.length<2)return-1;Me=2,Pe/=2,gt/=2,B/=2}function _t(kt,Ft){return Me===1?kt[Ft]:kt.readUInt16BE(Ft*Me)}let Tt;if(Ie){let kt=-1;for(Tt=B;Tt<Pe;Tt++)if(_t(Z,Tt)===_t(P,kt===-1?0:Tt-kt)){if(kt===-1&&(kt=Tt),Tt-kt+1===gt)return kt*Me}else kt!==-1&&(Tt-=Tt-kt),kt=-1}else for(B+gt>Pe&&(B=Pe-gt),Tt=B;Tt>=0;Tt--){let kt=!0;for(let Ft=0;Ft<gt;Ft++)if(_t(Z,Tt+Ft)!==_t(P,Ft)){kt=!1;break}if(kt)return Tt}return-1}c.prototype.includes=function(P,B,U){return this.indexOf(P,B,U)!==-1},c.prototype.indexOf=function(P,B,U){return K(this,P,B,U,!0)},c.prototype.lastIndexOf=function(P,B,U){return K(this,P,B,U,!1)};function X(Z,P,B,U){B=Number(B)||0;const Ie=Z.length-B;U?(U=Number(U),U>Ie&&(U=Ie)):U=Ie;const Me=P.length;U>Me/2&&(U=Me/2);let Pe;for(Pe=0;Pe<U;++Pe){const gt=parseInt(P.substr(Pe*2,2),16);if(st(gt))return Pe;Z[B+Pe]=gt}return Pe}function Ee(Z,P,B,U){return xe(ae(P,Z.length-B),Z,B,U)}function q(Z,P,B,U){return xe(ve(P),Z,B,U)}function Y(Z,P,B,U){return xe(me(P),Z,B,U)}function Te(Z,P,B,U){return xe(J(P,Z.length-B),Z,B,U)}c.prototype.write=function(P,B,U,Ie){if(B===void 0)Ie="utf8",U=this.length,B=0;else if(U===void 0&&typeof B=="string")Ie=B,U=this.length,B=0;else if(isFinite(B))B=B>>>0,isFinite(U)?(U=U>>>0,Ie===void 0&&(Ie="utf8")):(Ie=U,U=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Me=this.length-B;if((U===void 0||U>Me)&&(U=Me),P.length>0&&(U<0||B<0)||B>this.length)throw new RangeError("Attempt to write outside buffer bounds");Ie||(Ie="utf8");let Pe=!1;for(;;)switch(Ie){case"hex":return X(this,P,B,U);case"utf8":case"utf-8":return Ee(this,P,B,U);case"ascii":case"latin1":case"binary":return q(this,P,B,U);case"base64":return Y(this,P,B,U);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Te(this,P,B,U);default:if(Pe)throw new TypeError("Unknown encoding: "+Ie);Ie=(""+Ie).toLowerCase(),Pe=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function re(Z,P,B){return P===0&&B===Z.length?e.fromByteArray(Z):e.fromByteArray(Z.slice(P,B))}function $e(Z,P,B){B=Math.min(Z.length,B);const U=[];let Ie=P;for(;Ie<B;){const Me=Z[Ie];let Pe=null,gt=Me>239?4:Me>223?3:Me>191?2:1;if(Ie+gt<=B){let _t,Tt,kt,Ft;switch(gt){case 1:Me<128&&(Pe=Me);break;case 2:_t=Z[Ie+1],(_t&192)===128&&(Ft=(Me&31)<<6|_t&63,Ft>127&&(Pe=Ft));break;case 3:_t=Z[Ie+1],Tt=Z[Ie+2],(_t&192)===128&&(Tt&192)===128&&(Ft=(Me&15)<<12|(_t&63)<<6|Tt&63,Ft>2047&&(Ft<55296||Ft>57343)&&(Pe=Ft));break;case 4:_t=Z[Ie+1],Tt=Z[Ie+2],kt=Z[Ie+3],(_t&192)===128&&(Tt&192)===128&&(kt&192)===128&&(Ft=(Me&15)<<18|(_t&63)<<12|(Tt&63)<<6|kt&63,Ft>65535&&Ft<1114112&&(Pe=Ft))}}Pe===null?(Pe=65533,gt=1):Pe>65535&&(Pe-=65536,U.push(Pe>>>10&1023|55296),Pe=56320|Pe&1023),U.push(Pe),Ie+=gt}return ye(U)}const ze=4096;function ye(Z){const P=Z.length;if(P<=ze)return String.fromCharCode.apply(String,Z);let B="",U=0;for(;U<P;)B+=String.fromCharCode.apply(String,Z.slice(U,U+=ze));return B}function Ve(Z,P,B){let U="";B=Math.min(Z.length,B);for(let Ie=P;Ie<B;++Ie)U+=String.fromCharCode(Z[Ie]&127);return U}function pe(Z,P,B){let U="";B=Math.min(Z.length,B);for(let Ie=P;Ie<B;++Ie)U+=String.fromCharCode(Z[Ie]);return U}function De(Z,P,B){const U=Z.length;(!P||P<0)&&(P=0),(!B||B<0||B>U)&&(B=U);let Ie="";for(let Me=P;Me<B;++Me)Ie+=ft[Z[Me]];return Ie}function $(Z,P,B){const U=Z.slice(P,B);let Ie="";for(let Me=0;Me<U.length-1;Me+=2)Ie+=String.fromCharCode(U[Me]+U[Me+1]*256);return Ie}c.prototype.slice=function(P,B){const U=this.length;P=~~P,B=B===void 0?U:~~B,P<0?(P+=U,P<0&&(P=0)):P>U&&(P=U),B<0?(B+=U,B<0&&(B=0)):B>U&&(B=U),B<P&&(B=P);const Ie=this.subarray(P,B);return Object.setPrototypeOf(Ie,c.prototype),Ie};function G(Z,P,B){if(Z%1!==0||Z<0)throw new RangeError("offset is not uint");if(Z+P>B)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(P,B,U){P=P>>>0,B=B>>>0,U||G(P,B,this.length);let Ie=this[P],Me=1,Pe=0;for(;++Pe<B&&(Me*=256);)Ie+=this[P+Pe]*Me;return Ie},c.prototype.readUintBE=c.prototype.readUIntBE=function(P,B,U){P=P>>>0,B=B>>>0,U||G(P,B,this.length);let Ie=this[P+--B],Me=1;for(;B>0&&(Me*=256);)Ie+=this[P+--B]*Me;return Ie},c.prototype.readUint8=c.prototype.readUInt8=function(P,B){return P=P>>>0,B||G(P,1,this.length),this[P]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(P,B){return P=P>>>0,B||G(P,2,this.length),this[P]|this[P+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(P,B){return P=P>>>0,B||G(P,2,this.length),this[P]<<8|this[P+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(P,B){return P=P>>>0,B||G(P,4,this.length),(this[P]|this[P+1]<<8|this[P+2]<<16)+this[P+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(P,B){return P=P>>>0,B||G(P,4,this.length),this[P]*16777216+(this[P+1]<<16|this[P+2]<<8|this[P+3])},c.prototype.readBigUInt64LE=Ge(function(P){P=P>>>0,N(P,"offset");const B=this[P],U=this[P+7];(B===void 0||U===void 0)&&L(P,this.length-8);const Ie=B+this[++P]*2**8+this[++P]*2**16+this[++P]*2**24,Me=this[++P]+this[++P]*2**8+this[++P]*2**16+U*2**24;return BigInt(Ie)+(BigInt(Me)<<BigInt(32))}),c.prototype.readBigUInt64BE=Ge(function(P){P=P>>>0,N(P,"offset");const B=this[P],U=this[P+7];(B===void 0||U===void 0)&&L(P,this.length-8);const Ie=B*2**24+this[++P]*2**16+this[++P]*2**8+this[++P],Me=this[++P]*2**24+this[++P]*2**16+this[++P]*2**8+U;return(BigInt(Ie)<<BigInt(32))+BigInt(Me)}),c.prototype.readIntLE=function(P,B,U){P=P>>>0,B=B>>>0,U||G(P,B,this.length);let Ie=this[P],Me=1,Pe=0;for(;++Pe<B&&(Me*=256);)Ie+=this[P+Pe]*Me;return Me*=128,Ie>=Me&&(Ie-=Math.pow(2,8*B)),Ie},c.prototype.readIntBE=function(P,B,U){P=P>>>0,B=B>>>0,U||G(P,B,this.length);let Ie=B,Me=1,Pe=this[P+--Ie];for(;Ie>0&&(Me*=256);)Pe+=this[P+--Ie]*Me;return Me*=128,Pe>=Me&&(Pe-=Math.pow(2,8*B)),Pe},c.prototype.readInt8=function(P,B){return P=P>>>0,B||G(P,1,this.length),this[P]&128?(255-this[P]+1)*-1:this[P]},c.prototype.readInt16LE=function(P,B){P=P>>>0,B||G(P,2,this.length);const U=this[P]|this[P+1]<<8;return U&32768?U|4294901760:U},c.prototype.readInt16BE=function(P,B){P=P>>>0,B||G(P,2,this.length);const U=this[P+1]|this[P]<<8;return U&32768?U|4294901760:U},c.prototype.readInt32LE=function(P,B){return P=P>>>0,B||G(P,4,this.length),this[P]|this[P+1]<<8|this[P+2]<<16|this[P+3]<<24},c.prototype.readInt32BE=function(P,B){return P=P>>>0,B||G(P,4,this.length),this[P]<<24|this[P+1]<<16|this[P+2]<<8|this[P+3]},c.prototype.readBigInt64LE=Ge(function(P){P=P>>>0,N(P,"offset");const B=this[P],U=this[P+7];(B===void 0||U===void 0)&&L(P,this.length-8);const Ie=this[P+4]+this[P+5]*2**8+this[P+6]*2**16+(U<<24);return(BigInt(Ie)<<BigInt(32))+BigInt(B+this[++P]*2**8+this[++P]*2**16+this[++P]*2**24)}),c.prototype.readBigInt64BE=Ge(function(P){P=P>>>0,N(P,"offset");const B=this[P],U=this[P+7];(B===void 0||U===void 0)&&L(P,this.length-8);const Ie=(B<<24)+this[++P]*2**16+this[++P]*2**8+this[++P];return(BigInt(Ie)<<BigInt(32))+BigInt(this[++P]*2**24+this[++P]*2**16+this[++P]*2**8+U)}),c.prototype.readFloatLE=function(P,B){return P=P>>>0,B||G(P,4,this.length),t.read(this,P,!0,23,4)},c.prototype.readFloatBE=function(P,B){return P=P>>>0,B||G(P,4,this.length),t.read(this,P,!1,23,4)},c.prototype.readDoubleLE=function(P,B){return P=P>>>0,B||G(P,8,this.length),t.read(this,P,!0,52,8)},c.prototype.readDoubleBE=function(P,B){return P=P>>>0,B||G(P,8,this.length),t.read(this,P,!1,52,8)};function ce(Z,P,B,U,Ie,Me){if(!c.isBuffer(Z))throw new TypeError('"buffer" argument must be a Buffer instance');if(P>Ie||P<Me)throw new RangeError('"value" argument is out of bounds');if(B+U>Z.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(P,B,U,Ie){if(P=+P,B=B>>>0,U=U>>>0,!Ie){const gt=Math.pow(2,8*U)-1;ce(this,P,B,U,gt,0)}let Me=1,Pe=0;for(this[B]=P&255;++Pe<U&&(Me*=256);)this[B+Pe]=P/Me&255;return B+U},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(P,B,U,Ie){if(P=+P,B=B>>>0,U=U>>>0,!Ie){const gt=Math.pow(2,8*U)-1;ce(this,P,B,U,gt,0)}let Me=U-1,Pe=1;for(this[B+Me]=P&255;--Me>=0&&(Pe*=256);)this[B+Me]=P/Pe&255;return B+U},c.prototype.writeUint8=c.prototype.writeUInt8=function(P,B,U){return P=+P,B=B>>>0,U||ce(this,P,B,1,255,0),this[B]=P&255,B+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(P,B,U){return P=+P,B=B>>>0,U||ce(this,P,B,2,65535,0),this[B]=P&255,this[B+1]=P>>>8,B+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(P,B,U){return P=+P,B=B>>>0,U||ce(this,P,B,2,65535,0),this[B]=P>>>8,this[B+1]=P&255,B+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(P,B,U){return P=+P,B=B>>>0,U||ce(this,P,B,4,4294967295,0),this[B+3]=P>>>24,this[B+2]=P>>>16,this[B+1]=P>>>8,this[B]=P&255,B+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(P,B,U){return P=+P,B=B>>>0,U||ce(this,P,B,4,4294967295,0),this[B]=P>>>24,this[B+1]=P>>>16,this[B+2]=P>>>8,this[B+3]=P&255,B+4};function oe(Z,P,B,U,Ie){j(P,U,Ie,Z,B,7);let Me=Number(P&BigInt(4294967295));Z[B++]=Me,Me=Me>>8,Z[B++]=Me,Me=Me>>8,Z[B++]=Me,Me=Me>>8,Z[B++]=Me;let Pe=Number(P>>BigInt(32)&BigInt(4294967295));return Z[B++]=Pe,Pe=Pe>>8,Z[B++]=Pe,Pe=Pe>>8,Z[B++]=Pe,Pe=Pe>>8,Z[B++]=Pe,B}function Fe(Z,P,B,U,Ie){j(P,U,Ie,Z,B,7);let Me=Number(P&BigInt(4294967295));Z[B+7]=Me,Me=Me>>8,Z[B+6]=Me,Me=Me>>8,Z[B+5]=Me,Me=Me>>8,Z[B+4]=Me;let Pe=Number(P>>BigInt(32)&BigInt(4294967295));return Z[B+3]=Pe,Pe=Pe>>8,Z[B+2]=Pe,Pe=Pe>>8,Z[B+1]=Pe,Pe=Pe>>8,Z[B]=Pe,B+8}c.prototype.writeBigUInt64LE=Ge(function(P,B=0){return oe(this,P,B,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=Ge(function(P,B=0){return Fe(this,P,B,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(P,B,U,Ie){if(P=+P,B=B>>>0,!Ie){const _t=Math.pow(2,8*U-1);ce(this,P,B,U,_t-1,-_t)}let Me=0,Pe=1,gt=0;for(this[B]=P&255;++Me<U&&(Pe*=256);)P<0&&gt===0&&this[B+Me-1]!==0&&(gt=1),this[B+Me]=(P/Pe>>0)-gt&255;return B+U},c.prototype.writeIntBE=function(P,B,U,Ie){if(P=+P,B=B>>>0,!Ie){const _t=Math.pow(2,8*U-1);ce(this,P,B,U,_t-1,-_t)}let Me=U-1,Pe=1,gt=0;for(this[B+Me]=P&255;--Me>=0&&(Pe*=256);)P<0&&gt===0&&this[B+Me+1]!==0&&(gt=1),this[B+Me]=(P/Pe>>0)-gt&255;return B+U},c.prototype.writeInt8=function(P,B,U){return P=+P,B=B>>>0,U||ce(this,P,B,1,127,-128),P<0&&(P=255+P+1),this[B]=P&255,B+1},c.prototype.writeInt16LE=function(P,B,U){return P=+P,B=B>>>0,U||ce(this,P,B,2,32767,-32768),this[B]=P&255,this[B+1]=P>>>8,B+2},c.prototype.writeInt16BE=function(P,B,U){return P=+P,B=B>>>0,U||ce(this,P,B,2,32767,-32768),this[B]=P>>>8,this[B+1]=P&255,B+2},c.prototype.writeInt32LE=function(P,B,U){return P=+P,B=B>>>0,U||ce(this,P,B,4,2147483647,-2147483648),this[B]=P&255,this[B+1]=P>>>8,this[B+2]=P>>>16,this[B+3]=P>>>24,B+4},c.prototype.writeInt32BE=function(P,B,U){return P=+P,B=B>>>0,U||ce(this,P,B,4,2147483647,-2147483648),P<0&&(P=4294967295+P+1),this[B]=P>>>24,this[B+1]=P>>>16,this[B+2]=P>>>8,this[B+3]=P&255,B+4},c.prototype.writeBigInt64LE=Ge(function(P,B=0){return oe(this,P,B,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=Ge(function(P,B=0){return Fe(this,P,B,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ue(Z,P,B,U,Ie,Me){if(B+U>Z.length)throw new RangeError("Index out of range");if(B<0)throw new RangeError("Index out of range")}function Je(Z,P,B,U,Ie){return P=+P,B=B>>>0,Ie||Ue(Z,P,B,4),t.write(Z,P,B,U,23,4),B+4}c.prototype.writeFloatLE=function(P,B,U){return Je(this,P,B,!0,U)},c.prototype.writeFloatBE=function(P,B,U){return Je(this,P,B,!1,U)};function He(Z,P,B,U,Ie){return P=+P,B=B>>>0,Ie||Ue(Z,P,B,8),t.write(Z,P,B,U,52,8),B+8}c.prototype.writeDoubleLE=function(P,B,U){return He(this,P,B,!0,U)},c.prototype.writeDoubleBE=function(P,B,U){return He(this,P,B,!1,U)},c.prototype.copy=function(P,B,U,Ie){if(!c.isBuffer(P))throw new TypeError("argument should be a Buffer");if(U||(U=0),!Ie&&Ie!==0&&(Ie=this.length),B>=P.length&&(B=P.length),B||(B=0),Ie>0&&Ie<U&&(Ie=U),Ie===U||P.length===0||this.length===0)return 0;if(B<0)throw new RangeError("targetStart out of bounds");if(U<0||U>=this.length)throw new RangeError("Index out of range");if(Ie<0)throw new RangeError("sourceEnd out of bounds");Ie>this.length&&(Ie=this.length),P.length-B<Ie-U&&(Ie=P.length-B+U);const Me=Ie-U;return this===P&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(B,U,Ie):Uint8Array.prototype.set.call(P,this.subarray(U,Ie),B),Me},c.prototype.fill=function(P,B,U,Ie){if(typeof P=="string"){if(typeof B=="string"?(Ie=B,B=0,U=this.length):typeof U=="string"&&(Ie=U,U=this.length),Ie!==void 0&&typeof Ie!="string")throw new TypeError("encoding must be a string");if(typeof Ie=="string"&&!c.isEncoding(Ie))throw new TypeError("Unknown encoding: "+Ie);if(P.length===1){const Pe=P.charCodeAt(0);(Ie==="utf8"&&Pe<128||Ie==="latin1")&&(P=Pe)}}else typeof P=="number"?P=P&255:typeof P=="boolean"&&(P=Number(P));if(B<0||this.length<B||this.length<U)throw new RangeError("Out of range index");if(U<=B)return this;B=B>>>0,U=U===void 0?this.length:U>>>0,P||(P=0);let Me;if(typeof P=="number")for(Me=B;Me<U;++Me)this[Me]=P;else{const Pe=c.isBuffer(P)?P:c.from(P,Ie),gt=Pe.length;if(gt===0)throw new TypeError('The value "'+P+'" is invalid for argument "value"');for(Me=0;Me<U-B;++Me)this[Me+B]=Pe[Me%gt]}return this};const he={};function fe(Z,P,B){he[Z]=class extends B{constructor(){super(),Object.defineProperty(this,"message",{value:P.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${Z}]`,this.stack,delete this.name}get code(){return Z}set code(Ie){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:Ie,writable:!0})}toString(){return`${this.name} [${Z}]: ${this.message}`}}}fe("ERR_BUFFER_OUT_OF_BOUNDS",function(Z){return Z?`${Z} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),fe("ERR_INVALID_ARG_TYPE",function(Z,P){return`The "${Z}" argument must be of type number. Received type ${typeof P}`},TypeError),fe("ERR_OUT_OF_RANGE",function(Z,P,B){let U=`The value of "${Z}" is out of range.`,Ie=B;return Number.isInteger(B)&&Math.abs(B)>2**32?Ie=Oe(String(B)):typeof B=="bigint"&&(Ie=String(B),(B>BigInt(2)**BigInt(32)||B<-(BigInt(2)**BigInt(32)))&&(Ie=Oe(Ie)),Ie+="n"),U+=` It must be ${P}. Received ${Ie}`,U},RangeError);function Oe(Z){let P="",B=Z.length;const U=Z[0]==="-"?1:0;for(;B>=U+4;B-=3)P=`_${Z.slice(B-3,B)}${P}`;return`${Z.slice(0,B)}${P}`}function ie(Z,P,B){N(P,"offset"),(Z[P]===void 0||Z[P+B]===void 0)&&L(P,Z.length-(B+1))}function j(Z,P,B,U,Ie,Me){if(Z>B||Z<P){const Pe=typeof P=="bigint"?"n":"";let gt;throw P===0||P===BigInt(0)?gt=`>= 0${Pe} and < 2${Pe} ** ${(Me+1)*8}${Pe}`:gt=`>= -(2${Pe} ** ${(Me+1)*8-1}${Pe}) and < 2 ** ${(Me+1)*8-1}${Pe}`,new he.ERR_OUT_OF_RANGE("value",gt,Z)}ie(U,Ie,Me)}function N(Z,P){if(typeof Z!="number")throw new he.ERR_INVALID_ARG_TYPE(P,"number",Z)}function L(Z,P,B){throw Math.floor(Z)!==Z?(N(Z,B),new he.ERR_OUT_OF_RANGE("offset","an integer",Z)):P<0?new he.ERR_BUFFER_OUT_OF_BOUNDS:new he.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${P}`,Z)}const V=/[^+/0-9A-Za-z-_]/g;function ee(Z){if(Z=Z.split("=")[0],Z=Z.trim().replace(V,""),Z.length<2)return"";for(;Z.length%4!==0;)Z=Z+"=";return Z}function ae(Z,P){P=P||1/0;let B;const U=Z.length;let Ie=null;const Me=[];for(let Pe=0;Pe<U;++Pe){if(B=Z.charCodeAt(Pe),B>55295&&B<57344){if(!Ie){if(B>56319){(P-=3)>-1&&Me.push(239,191,189);continue}else if(Pe+1===U){(P-=3)>-1&&Me.push(239,191,189);continue}Ie=B;continue}if(B<56320){(P-=3)>-1&&Me.push(239,191,189),Ie=B;continue}B=(Ie-55296<<10|B-56320)+65536}else Ie&&(P-=3)>-1&&Me.push(239,191,189);if(Ie=null,B<128){if((P-=1)<0)break;Me.push(B)}else if(B<2048){if((P-=2)<0)break;Me.push(B>>6|192,B&63|128)}else if(B<65536){if((P-=3)<0)break;Me.push(B>>12|224,B>>6&63|128,B&63|128)}else if(B<1114112){if((P-=4)<0)break;Me.push(B>>18|240,B>>12&63|128,B>>6&63|128,B&63|128)}else throw new Error("Invalid code point")}return Me}function ve(Z){const P=[];for(let B=0;B<Z.length;++B)P.push(Z.charCodeAt(B)&255);return P}function J(Z,P){let B,U,Ie;const Me=[];for(let Pe=0;Pe<Z.length&&!((P-=2)<0);++Pe)B=Z.charCodeAt(Pe),U=B>>8,Ie=B%256,Me.push(Ie),Me.push(U);return Me}function me(Z){return e.toByteArray(ee(Z))}function xe(Z,P,B,U){let Ie;for(Ie=0;Ie<U&&!(Ie+B>=P.length||Ie>=Z.length);++Ie)P[Ie+B]=Z[Ie];return Ie}function de(Z,P){return Z instanceof P||Z!=null&&Z.constructor!=null&&Z.constructor.name!=null&&Z.constructor.name===P.name}function st(Z){return Z!==Z}const ft=(function(){const Z="0123456789abcdef",P=new Array(256);for(let B=0;B<16;++B){const U=B*16;for(let Ie=0;Ie<16;++Ie)P[U+Ie]=Z[B]+Z[Ie]}return P})();function Ge(Z){return typeof BigInt>"u"?pt:Z}function pt(){throw new Error("BigInt not supported")}})(buffer)),buffer}var bufferExports=requireBuffer();const RDF$1="http://www.w3.org/1999/02/22-rdf-syntax-ns#",XSD$7="http://www.w3.org/2001/XMLSchema#",SWAP$1="http://www.w3.org/2000/10/swap/",namespaces$1={xsd:{decimal:`${XSD$7}decimal`,boolean:`${XSD$7}boolean`,double:`${XSD$7}double`,integer:`${XSD$7}integer`,string:`${XSD$7}string`},rdf:{type:`${RDF$1}type`,nil:`${RDF$1}nil`,first:`${RDF$1}first`,rest:`${RDF$1}rest`,langString:`${RDF$1}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${SWAP$1}reify#forSome`,forAll:`${SWAP$1}reify#forAll`},log:{implies:`${SWAP$1}log#implies`,isImpliedBy:`${SWAP$1}log#isImpliedBy`}},{xsd:xsd$5}=namespaces$1,escapeSequence$1=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,escapeReplacements$1={"\\":"\\","'":"'",'"':'"',n:`
95
+ `,r:"\r",t:" ",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},illegalIriChars$1=/[\x00-\x20<>\\"\{\}\|\^\`]/,lineModeRegExps$1={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},invalidRegExp$1=/$0^/;let N3Lexer$1=class{constructor(e){if(this._iri=/^<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/,this._unescapedIri=/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/,this._simpleQuotedString=/^"([^"\\\r\n]*)"(?=[^"])/,this._simpleApostropheString=/^'([^'\\\r\n]*)'(?=[^'])/,this._langcode=/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,this._prefix=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,this._prefixed=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<>]))/,this._variable=/^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<>])/,this._blank=/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<>]))/,this._number=/^[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?|\d*(\.)?)\d+(?=\.?[,;:\s#()\[\]\{\}"'<>])/,this._boolean=/^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<>])/,this._keyword=/^@[a-z]+(?=[\s#<:])/i,this._sparqlKeyword=/^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i,this._shortPredicates=/^a(?=[\s#()\[\]\{\}"'<>])/,this._newline=/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,this._comment=/#([^\n\r]*)/,this._whitespace=/^[ \t]+/,this._endOfFile=/^(?:#[^\n\r]*)?$/,e=e||{},this._isImpliedBy=e.isImpliedBy,this._lineMode=!!e.lineMode){this._n3Mode=!1;for(const t in this)!(t in lineModeRegExps$1)&&this[t]instanceof RegExp&&(this[t]=invalidRegExp$1)}else this._n3Mode=e.n3!==!1;this.comments=!!e.comments,this._literalClosingPos=0}_tokenizeToEnd(e,t){let n=this._input,s=n.length;for(;;){let c,h;for(;c=this._newline.exec(n);)this.comments&&(h=this._comment.exec(c[0]))&&a("comment",h[1],"",this._line,c[0].length),n=n.substr(c[0].length,n.length),s=n.length,this._line++;if(!c&&(c=this._whitespace.exec(n))&&(n=n.substr(c[0].length,n.length)),this._endOfFile.test(n))return t&&(this.comments&&(h=this._comment.exec(n))&&a("comment",h[1],"",this._line,n.length),n=null,a("eof","","",this._line,0)),this._input=n;const f=this._line,p=n[0];let g="",y="",S="",w=null,R=0,T=!1;switch(p){case"^":if(n.length<3)break;if(n[1]==="^"){if(this._previousMarker="^^",n=n.substr(2),n[0]!=="<"){T=!0;break}}else{this._n3Mode&&(R=1,g="^");break}case"<":if(w=this._unescapedIri.exec(n))g="IRI",y=w[1];else if(w=this._iri.exec(n)){if(y=this._unescape(w[1]),y===null||illegalIriChars$1.test(y))return u(this);g="IRI"}else n.length>1&&n[1]==="<"?(g="<<",R=2):this._n3Mode&&n.length>1&&n[1]==="="&&(R=2,this._isImpliedBy?(g="abbreviation",y="<"):(g="inverse",y=">"));break;case">":n.length>1&&n[1]===">"&&(g=">>",R=2);break;case"_":((w=this._blank.exec(n))||t&&(w=this._blank.exec(`${n} `)))&&(g="blank",S="_",y=w[1]);break;case'"':if(w=this._simpleQuotedString.exec(n))y=w[1];else if({value:y,matchLength:R}=this._parseLiteral(n),y===null)return u(this);(w!==null||R!==0)&&(g="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(w=this._simpleApostropheString.exec(n))y=w[1];else if({value:y,matchLength:R}=this._parseLiteral(n),y===null)return u(this);(w!==null||R!==0)&&(g="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(w=this._variable.exec(n))&&(g="var",y=w[0]);break;case"@":this._previousMarker==="literal"&&(w=this._langcode.exec(n))?(g="langcode",y=w[1]):(w=this._keyword.exec(n))&&(g=w[0]);break;case".":if(n.length===1?t:n[1]<"0"||n[1]>"9"){g=".",R=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(w=this._number.exec(n)||t&&(w=this._number.exec(`${n} `)))&&(g="literal",y=w[0],S=typeof w[1]=="string"?xsd$5.double:typeof w[2]=="string"?xsd$5.decimal:xsd$5.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(w=this._sparqlKeyword.exec(n))?g=w[0].toUpperCase():T=!0;break;case"f":case"t":(w=this._boolean.exec(n))?(g="literal",y=w[0],S=xsd$5.boolean):T=!0;break;case"a":(w=this._shortPredicates.exec(n))?(g="abbreviation",y="a"):T=!0;break;case"=":this._n3Mode&&n.length>1&&(g="abbreviation",n[1]!==">"?(R=1,y="="):(R=2,y=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(R=1,g=p);break;case"{":!this._lineMode&&n.length>=2&&(n[1]==="|"?(g="{|",R=2):(g=p,R=1));break;case"|":n.length>=2&&n[1]==="}"&&(g="|}",R=2);break;default:T=!0}if(T&&((this._previousMarker==="@prefix"||this._previousMarker==="PREFIX")&&(w=this._prefix.exec(n))?(g="prefix",y=w[1]||""):((w=this._prefixed.exec(n))||t&&(w=this._prefixed.exec(`${n} `)))&&(g="prefixed",S=w[1]||"",y=this._unescape(w[2]))),this._previousMarker==="^^")switch(g){case"prefixed":g="type";break;case"IRI":g="typeIRI";break;default:g=""}if(!g)return t||!/^'''|^"""/.test(n)&&/\n|\r/.test(n)?u(this):this._input=n;const A=R||w[0].length,F=a(g,y,S,f,A);this.previousToken=F,this._previousMarker=g,n=n.substr(A,n.length)}function a(c,h,f,p,g){const y=n?s-n.length:s,S=y+g,w={type:c,value:h,prefix:f,line:p,start:y,end:S};return e(null,w),w}function u(c){e(c._syntaxError(/^\S*/.exec(n)[0]))}}_unescape(e){let t=!1;const n=e.replace(escapeSequence$1,(s,a,u,c)=>{if(typeof a=="string")return String.fromCharCode(Number.parseInt(a,16));if(typeof u=="string"){let h=Number.parseInt(u,16);return h<=65535?String.fromCharCode(Number.parseInt(u,16)):String.fromCharCode(55296+((h-=65536)>>10),56320+(h&1023))}return c in escapeReplacements$1?escapeReplacements$1[c]:(t=!0,"")});return t?null:n}_parseLiteral(e){if(e.length>=3){const t=e.match(/^(?:"""|"|'''|'|)/)[0],n=t.length;let s=Math.max(this._literalClosingPos,n);for(;(s=e.indexOf(t,s))>0;){let a=0;for(;e[s-a-1]==="\\";)a++;if(a%2===0){const u=e.substring(n,s),c=u.split(/\r\n|\r|\n/).length-1,h=s+n;if(n===1&&c!==0||n===3&&this._lineMode)break;return this._line+=c,{value:this._unescape(u),matchLength:h}}s++}this._literalClosingPos=e.length-n+1}return{value:"",matchLength:0}}_syntaxError(e){this._input=null;const t=new Error(`Unexpected "${e}" on line ${this._line}.`);return t.context={token:void 0,line:this._line,previousToken:this.previousToken},t}_readStartingBom(e){return e.startsWith("\uFEFF")?e.substr(1):e}tokenize(e,t){if(this._line=1,typeof e=="string")if(this._input=this._readStartingBom(e),typeof t=="function")queueMicrotask(()=>this._tokenizeToEnd(t,!0));else{const n=[];let s;if(this._tokenizeToEnd((a,u)=>a?s=a:n.push(u),!0),s)throw s;return n}else this._pendingBuffer=null,typeof e.setEncoding=="function"&&e.setEncoding("utf8"),e.on("data",n=>{this._input!==null&&n.length!==0&&(this._pendingBuffer&&(n=bufferExports.Buffer.concat([this._pendingBuffer,n]),this._pendingBuffer=null),n[n.length-1]&128?this._pendingBuffer=n:(typeof this._input>"u"?this._input=this._readStartingBom(typeof n=="string"?n:n.toString()):this._input+=n,this._tokenizeToEnd(t,!1)))}),e.on("end",()=>{typeof this._input=="string"&&this._tokenizeToEnd(t,!0)}),e.on("error",t)}};const{rdf:rdf$3,xsd:xsd$4}=namespaces$1;let DEFAULTGRAPH$3,_blankNodeCounter$1=0;const DataFactory$2={namedNode:namedNode$1,blankNode:blankNode$1,variable:variable$1,literal:literal$1,defaultGraph:defaultGraph$1,quad:quad$1,triple:quad$1,fromTerm:fromTerm$1,fromQuad:fromQuad$1};let Term$1=class ph{constructor(e){this.id=e}get value(){return this.id}equals(e){return e instanceof ph?this.id===e.id:!!e&&this.termType===e.termType&&this.value===e.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}},NamedNode$2=class extends Term$1{get termType(){return"NamedNode"}},Literal$2=class gh extends Term$1{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){const e=this.id;let t=e.lastIndexOf('"')+1;return t<e.length&&e[t++]==="@"?e.substr(t).toLowerCase():""}get datatype(){return new NamedNode$2(this.datatypeString)}get datatypeString(){const e=this.id,t=e.lastIndexOf('"')+1,n=t<e.length?e[t]:"";return n==="^"?e.substr(t+2):n!=="@"?xsd$4.string:rdf$3.langString}equals(e){return e instanceof gh?this.id===e.id:!!e&&!!e.datatype&&this.termType===e.termType&&this.value===e.value&&this.language===e.language&&this.datatype.value===e.datatype.value}toJSON(){return{termType:this.termType,value:this.value,language:this.language,datatype:{termType:"NamedNode",value:this.datatypeString}}}},BlankNode$2=class extends Term$1{constructor(e){super(`_:${e}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}},Variable$2=class extends Term$1{constructor(e){super(`?${e}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}},DefaultGraph$2=class extends Term$1{constructor(){return super(""),DEFAULTGRAPH$3||this}get termType(){return"DefaultGraph"}equals(e){return this===e||!!e&&this.termType===e.termType}};DEFAULTGRAPH$3=new DefaultGraph$2;function termFromId$1(i,e,t){if(e=e||DataFactory$2,!i)return e.defaultGraph();switch(i[0]){case"?":return e.variable(i.substr(1));case"_":return e.blankNode(i.substr(2));case'"':if(e===DataFactory$2)return new Literal$2(i);if(i[i.length-1]==='"')return e.literal(i.substr(1,i.length-2));const n=i.lastIndexOf('"',i.length-1);return e.literal(i.substr(1,n-1),i[n+1]==="@"?i.substr(n+2):e.namedNode(i.substr(n+3)));case"[":i=JSON.parse(i);break;default:if(!t||!Array.isArray(i))return e.namedNode(i)}return e.quad(termFromId$1(i[0],e,!0),termFromId$1(i[1],e,!0),termFromId$1(i[2],e,!0),i[3]&&termFromId$1(i[3],e,!0))}function termToId$1(i,e){if(typeof i=="string")return i;if(i instanceof Term$1&&i.termType!=="Quad")return i.id;if(!i)return DEFAULTGRAPH$3.id;switch(i.termType){case"NamedNode":return i.value;case"BlankNode":return`_:${i.value}`;case"Variable":return`?${i.value}`;case"DefaultGraph":return"";case"Literal":return`"${i.value}"${i.language?`@${i.language}`:i.datatype&&i.datatype.value!==xsd$4.string?`^^${i.datatype.value}`:""}`;case"Quad":const t=[termToId$1(i.subject,!0),termToId$1(i.predicate,!0),termToId$1(i.object,!0)];return i.graph&&i.graph.termType!=="DefaultGraph"&&t.push(termToId$1(i.graph,!0)),e?t:JSON.stringify(t);default:throw new Error(`Unexpected termType: ${i.termType}`)}}let Quad$2=class extends Term$1{constructor(e,t,n,s){super(""),this._subject=e,this._predicate=t,this._object=n,this._graph=s||DEFAULTGRAPH$3}get termType(){return"Quad"}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}get graph(){return this._graph}toJSON(){return{termType:this.termType,subject:this._subject.toJSON(),predicate:this._predicate.toJSON(),object:this._object.toJSON(),graph:this._graph.toJSON()}}equals(e){return!!e&&this._subject.equals(e.subject)&&this._predicate.equals(e.predicate)&&this._object.equals(e.object)&&this._graph.equals(e.graph)}};function namedNode$1(i){return new NamedNode$2(i)}function blankNode$1(i){return new BlankNode$2(i||`n3-${_blankNodeCounter$1++}`)}function literal$1(i,e){if(typeof e=="string")return new Literal$2(`"${i}"@${e.toLowerCase()}`);let t=e?e.value:"";return t===""&&(typeof i=="boolean"?t=xsd$4.boolean:typeof i=="number"&&(Number.isFinite(i)?t=Number.isInteger(i)?xsd$4.integer:xsd$4.double:(t=xsd$4.double,Number.isNaN(i)||(i=i>0?"INF":"-INF")))),t===""||t===xsd$4.string?new Literal$2(`"${i}"`):new Literal$2(`"${i}"^^${t}`)}function variable$1(i){return new Variable$2(i)}function defaultGraph$1(){return DEFAULTGRAPH$3}function quad$1(i,e,t,n){return new Quad$2(i,e,t,n)}function fromTerm$1(i){if(i instanceof Term$1)return i;switch(i.termType){case"NamedNode":return namedNode$1(i.value);case"BlankNode":return blankNode$1(i.value);case"Variable":return variable$1(i.value);case"DefaultGraph":return DEFAULTGRAPH$3;case"Literal":return literal$1(i.value,i.language||i.datatype);case"Quad":return fromQuad$1(i);default:throw new Error(`Unexpected termType: ${i.termType}`)}}function fromQuad$1(i){if(i instanceof Quad$2)return i;if(i.termType!=="Quad")throw new Error(`Unexpected termType: ${i.termType}`);return quad$1(fromTerm$1(i.subject),fromTerm$1(i.predicate),fromTerm$1(i.object),fromTerm$1(i.graph))}let blankNodePrefix$1=0,N3Parser$1=class{constructor(e){this._contextStack=[],this._graph=null,e=e||{},this._setBase(e.baseIRI),e.factory&&initDataFactory$1(this,e.factory);const t=typeof e.format=="string"?e.format.match(/\w*$/)[0].toLowerCase():"",n=/turtle/.test(t),s=/trig/.test(t),a=/triple/.test(t),u=/quad/.test(t),c=this._n3Mode=/n3/.test(t),h=a||u;(this._supportsNamedGraphs=!(n||c))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(n||s||a||c),this._isImpliedBy=e.isImpliedBy,this._supportsRDFStar=t===""||/star|\*$/.test(t),h&&(this._resolveRelativeIRI=f=>null),this._blankNodePrefix=typeof e.blankNodePrefix!="string"?"":e.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=e.lexer||new N3Lexer$1({lineMode:h,n3:c,isImpliedBy:this._isImpliedBy}),this._explicitQuantifiers=!!e.explicitQuantifiers}static _resetBlankNodePrefix(){blankNodePrefix$1=0}_setBase(e){if(!e)this._base="",this._basePath="";else{const t=e.indexOf("#");t>=0&&(e=e.substr(0,t)),this._base=e,this._basePath=e.indexOf("/")<0?e:e.replace(/[^\/?]*(?:\?.*)?$/,""),e=e.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i),this._baseRoot=e[0],this._baseScheme=e[1]}}_saveContext(e,t,n,s,a){const u=this._n3Mode;this._contextStack.push({type:e,subject:n,predicate:s,object:a,graph:t,inverse:u?this._inversePredicate:!1,blankPrefix:u?this._prefixes._:"",quantified:u?this._quantified:null}),u&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(e,t){const n=this._contextStack.pop();if(!n||n.type!==e)return this._error(`Unexpected ${t.type}`,t);this._subject=n.subject,this._predicate=n.predicate,this._object=n.object,this._graph=n.graph,this._n3Mode&&(this._inversePredicate=n.inverse,this._prefixes._=n.blankPrefix,this._quantified=n.quantified)}_readInTopContext(e){switch(e.type){case"eof":return this._graph!==null?this._error("Unclosed graph",e):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"PREFIX":this._sparqlStyle=!0;case"@prefix":return this._readPrefix;case"BASE":this._sparqlStyle=!0;case"@base":return this._readBaseIRI;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(e)}}_readEntity(e,t){let n;switch(e.type){case"IRI":case"typeIRI":const s=this._resolveIRI(e.value);if(s===null)return this._error("Invalid IRI",e);n=this._factory.namedNode(s);break;case"type":case"prefixed":const a=this._prefixes[e.prefix];if(a===void 0)return this._error(`Undefined prefix "${e.prefix}:"`,e);n=this._factory.namedNode(a+e.value);break;case"blank":n=this._factory.blankNode(this._prefixes[e.prefix]+e.value);break;case"var":n=this._factory.variable(e.value.substr(1));break;default:return this._error(`Expected entity but got ${e.type}`,e)}return!t&&this._n3Mode&&n.id in this._quantified&&(n=this._quantified[n.id]),n}_readSubject(e){switch(this._predicate=null,e.type){case"[":return this._saveContext("blank",this._graph,this._subject=this._factory.blankNode(),null,null),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this.RDF_NIL,null,null),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._graph=this._factory.blankNode(),null,null),this._readSubject):this._error("Unexpected graph",e);case"}":return this._readPunctuation(e);case"@forSome":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORSOME,this._quantifier="blankNode",this._readQuantifierList):this._error('Unexpected "@forSome"',e);case"@forAll":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORALL,this._quantifier="variable",this._readQuantifierList):this._error('Unexpected "@forAll"',e);case"literal":if(!this._n3Mode)return this._error("Unexpected literal",e);if(e.prefix.length===0)return this._literalValue=e.value,this._completeSubjectLiteral;this._subject=this._factory.literal(e.value,this._factory.namedNode(e.prefix));break;case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,null,null,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",e);default:if((this._subject=this._readEntity(e))===void 0)return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph}_readPredicate(e){const t=e.type;switch(t){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=this.ABBREVIATIONS[e.value];break;case".":case"]":case"}":return this._predicate===null?this._error(`Unexpected ${t}`,e):(this._subject=null,t==="]"?this._readBlankNodeTail(e):this._readPunctuation(e));case";":return this._predicate!==null?this._readPredicate:this._error("Expected predicate but got ;",e);case"[":if(this._n3Mode)return this._saveContext("blank",this._graph,this._subject,this._subject=this._factory.blankNode(),null),this._readBlankNodeHead;case"blank":if(!this._n3Mode)return this._error("Disallowed blank node as predicate",e);default:if((this._predicate=this._readEntity(e))===void 0)return}return this._readObject}_readObject(e){switch(e.type){case"literal":if(e.prefix.length===0)return this._literalValue=e.value,this._readDataTypeOrLang;this._object=this._factory.literal(e.value,this._factory.namedNode(e.prefix));break;case"[":return this._saveContext("blank",this._graph,this._subject,this._predicate,this._subject=this._factory.blankNode()),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this._subject,this._predicate,this.RDF_NIL),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",e);case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,this._subject,this._predicate,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",e);default:if((this._object=this._readEntity(e))===void 0)return;if(this._n3Mode)return this._getPathReader(this._getContextEndReader())}return this._getContextEndReader()}_readPredicateOrNamedGraph(e){return e.type==="{"?this._readGraph(e):this._readPredicate(e)}_readGraph(e){return e.type!=="{"?this._error(`Expected graph but got ${e.type}`,e):(this._graph=this._subject,this._subject=null,this._readSubject)}_readBlankNodeHead(e){return e.type==="]"?(this._subject=null,this._readBlankNodeTail(e)):(this._predicate=null,this._readPredicate(e))}_readBlankNodeTail(e){if(e.type!=="]")return this._readBlankNodePunctuation(e);this._subject!==null&&this._emit(this._subject,this._predicate,this._object,this._graph);const t=this._predicate===null;return this._restoreContext("blank",e),this._object!==null?this._getContextEndReader():this._predicate!==null?this._readObject:t?this._readPredicateOrNamedGraph:this._readPredicateAfterBlank}_readPredicateAfterBlank(e){switch(e.type){case".":case"}":return this._subject=null,this._readPunctuation(e);default:return this._readPredicate(e)}}_readListItem(e){let t=null,n=null,s=this._readListItem;const a=this._subject,u=this._contextStack,c=u[u.length-1];switch(e.type){case"[":this._saveContext("blank",this._graph,n=this._factory.blankNode(),this.RDF_FIRST,this._subject=t=this._factory.blankNode()),s=this._readBlankNodeHead;break;case"(":this._saveContext("list",this._graph,n=this._factory.blankNode(),this.RDF_FIRST,this.RDF_NIL),this._subject=null;break;case")":if(this._restoreContext("list",e),u.length!==0&&u[u.length-1].type==="list"&&this._emit(this._subject,this._predicate,this._object,this._graph),this._predicate===null){if(s=this._readPredicate,this._subject===this.RDF_NIL)return s}else if(s=this._getContextEndReader(),this._object===this.RDF_NIL)return s;n=this.RDF_NIL;break;case"literal":e.prefix.length===0?(this._literalValue=e.value,s=this._readListItemDataTypeOrLang):(t=this._factory.literal(e.value,this._factory.namedNode(e.prefix)),s=this._getContextEndReader());break;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",e);default:if((t=this._readEntity(e))===void 0)return}if(n===null&&(this._subject=n=this._factory.blankNode()),a===null?c.predicate===null?c.subject=n:c.object=n:this._emit(a,this.RDF_REST,n,this._graph),t!==null){if(this._n3Mode&&(e.type==="IRI"||e.type==="prefixed"))return this._saveContext("item",this._graph,n,this.RDF_FIRST,t),this._subject=t,this._predicate=null,this._getPathReader(this._readListItem);this._emit(n,this.RDF_FIRST,t,this._graph)}return s}_readDataTypeOrLang(e){return this._completeObjectLiteral(e,!1)}_readListItemDataTypeOrLang(e){return this._completeObjectLiteral(e,!0)}_completeLiteral(e){let t=this._factory.literal(this._literalValue);switch(e.type){case"type":case"typeIRI":const n=this._readEntity(e);if(n===void 0)return;t=this._factory.literal(this._literalValue,n),e=null;break;case"langcode":t=this._factory.literal(this._literalValue,e.value),e=null;break}return{token:e,literal:t}}_completeSubjectLiteral(e){return this._subject=this._completeLiteral(e).literal,this._readPredicateOrNamedGraph}_completeObjectLiteral(e,t){const n=this._completeLiteral(e);if(n)return this._object=n.literal,t&&this._emit(this._subject,this.RDF_FIRST,this._object,this._graph),n.token===null?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(n.token))}_readFormulaTail(e){return e.type!=="}"?this._readPunctuation(e):(this._subject!==null&&this._emit(this._subject,this._predicate,this._object,this._graph),this._restoreContext("formula",e),this._object===null?this._readPredicate:this._getContextEndReader())}_readPunctuation(e){let t,n=this._graph;const s=this._subject,a=this._inversePredicate;switch(e.type){case"}":if(this._graph===null)return this._error("Unexpected graph closing",e);if(this._n3Mode)return this._readFormulaTail(e);this._graph=null;case".":this._subject=null,t=this._contextStack.length?this._readSubject:this._readInTopContext,a&&(this._inversePredicate=!1);break;case";":t=this._readPredicate;break;case",":t=this._readObject;break;case"{|":if(!this._supportsRDFStar)return this._error("Unexpected RDF-star syntax",e);const u=this._predicate,c=this._object;this._subject=this._factory.quad(s,u,c,this.DEFAULTGRAPH),t=this._readPredicate;break;case"|}":if(this._subject.termType!=="Quad")return this._error("Unexpected asserted triple closing",e);this._subject=null,t=this._readPunctuation;break;default:if(this._supportsQuads&&this._graph===null&&(n=this._readEntity(e))!==void 0){t=this._readQuadPunctuation;break}return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}if(s!==null){const u=this._predicate,c=this._object;a?this._emit(c,u,s,n):this._emit(s,u,c,n)}return t}_readBlankNodePunctuation(e){let t;switch(e.type){case";":t=this._readPredicate;break;case",":t=this._readObject;break;default:return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}return this._emit(this._subject,this._predicate,this._object,this._graph),t}_readQuadPunctuation(e){return e.type!=="."?this._error("Expected dot to follow quad",e):this._readInTopContext}_readPrefix(e){return e.type!=="prefix"?this._error("Expected prefix to follow @prefix",e):(this._prefix=e.value,this._readPrefixIRI)}_readPrefixIRI(e){if(e.type!=="IRI")return this._error(`Expected IRI to follow prefix "${this._prefix}:"`,e);const t=this._readEntity(e);return this._prefixes[this._prefix]=t.value,this._prefixCallback(this._prefix,t),this._readDeclarationPunctuation}_readBaseIRI(e){const t=e.type==="IRI"&&this._resolveIRI(e.value);return t?(this._setBase(t),this._readDeclarationPunctuation):this._error("Expected valid IRI to follow base declaration",e)}_readNamedGraphLabel(e){switch(e.type){case"IRI":case"blank":case"prefixed":return this._readSubject(e),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",e)}}_readNamedGraphBlankLabel(e){return e.type!=="]"?this._error("Invalid graph label",e):(this._subject=this._factory.blankNode(),this._readGraph)}_readDeclarationPunctuation(e){return this._sparqlStyle?(this._sparqlStyle=!1,this._readInTopContext(e)):e.type!=="."?this._error("Expected declaration to end with a dot",e):this._readInTopContext}_readQuantifierList(e){let t;switch(e.type){case"IRI":case"prefixed":if((t=this._readEntity(e,!0))!==void 0)break;default:return this._error(`Unexpected ${e.type}`,e)}return this._explicitQuantifiers?(this._subject===null?this._emit(this._graph||this.DEFAULTGRAPH,this._predicate,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH):this._emit(this._subject,this.RDF_REST,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH),this._emit(this._subject,this.RDF_FIRST,t,this.QUANTIFIERS_GRAPH)):this._quantified[t.id]=this._factory[this._quantifier](this._factory.blankNode().value),this._readQuantifierPunctuation}_readQuantifierPunctuation(e){return e.type===","?this._readQuantifierList:(this._explicitQuantifiers&&(this._emit(this._subject,this.RDF_REST,this.RDF_NIL,this.QUANTIFIERS_GRAPH),this._subject=null),this._readCallback=this._getContextEndReader(),this._readCallback(e))}_getPathReader(e){return this._afterPath=e,this._readPath}_readPath(e){switch(e.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:const t=this._contextStack,n=t.length&&t[t.length-1];if(n&&n.type==="item"){const s=this._subject;this._restoreContext("item",e),this._emit(this._subject,this.RDF_FIRST,s,this._graph)}return this._afterPath(e)}}_readForwardPath(e){let t,n;const s=this._factory.blankNode();if((n=this._readEntity(e))!==void 0)return this._predicate===null?(t=this._subject,this._subject=s):(t=this._object,this._object=s),this._emit(t,n,s,this._graph),this._readPath}_readBackwardPath(e){const t=this._factory.blankNode();let n,s;if((n=this._readEntity(e))!==void 0)return this._predicate===null?(s=this._subject,this._subject=t):(s=this._object,this._object=t),this._emit(t,n,s,this._graph),this._readPath}_readRDFStarTailOrGraph(e){return e.type!==">>"?this._supportsQuads&&this._graph===null&&(this._graph=this._readEntity(e))!==void 0?this._readRDFStarTail:this._error(`Expected >> to follow "${this._object.id}"`,e):this._readRDFStarTail(e)}_readRDFStarTail(e){if(e.type!==">>")return this._error(`Expected >> but got ${e.type}`,e);const t=this._factory.quad(this._subject,this._predicate,this._object,this._graph||this.DEFAULTGRAPH);return this._restoreContext("<<",e),this._subject===null?(this._subject=t,this._readPredicate):(this._object=t,this._getContextEndReader())}_getContextEndReader(){const e=this._contextStack;if(!e.length)return this._readPunctuation;switch(e[e.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail;case"<<":return this._readRDFStarTailOrGraph}}_emit(e,t,n,s){this._callback(null,this._factory.quad(e,t,n,s||this.DEFAULTGRAPH))}_error(e,t){const n=new Error(`${e} on line ${t.line}.`);n.context={token:t,line:t.line,previousToken:this._lexer.previousToken},this._callback(n),this._callback=noop$1}_resolveIRI(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)?e:this._resolveRelativeIRI(e)}_resolveRelativeIRI(e){if(!e.length)return this._base;switch(e[0]){case"#":return this._base+e;case"?":return this._base.replace(/(?:\?.*)?$/,e);case"/":return(e[1]==="/"?this._baseScheme:this._baseRoot)+this._removeDotSegments(e);default:return/^[^/:]*:/.test(e)?null:this._removeDotSegments(this._basePath+e)}}_removeDotSegments(e){if(!/(^|\/)\.\.?($|[/#?])/.test(e))return e;const t=e.length;let n="",s=-1,a=-1,u=0,c="/";for(;s<t;){switch(c){case":":if(a<0&&e[++s]==="/"&&e[++s]==="/")for(;(a=s+1)<t&&e[a]!=="/";)s=a;break;case"?":case"#":s=t;break;case"/":if(e[s+1]===".")switch(c=e[++s+1],c){case"/":n+=e.substring(u,s-1),u=s+1;break;case void 0:case"?":case"#":return n+e.substring(u,s)+e.substr(s+1);case".":if(c=e[++s+1],c===void 0||c==="/"||c==="?"||c==="#"){if(n+=e.substring(u,s-2),(u=n.lastIndexOf("/"))>=a&&(n=n.substr(0,u)),c!=="/")return`${n}/${e.substr(s+1)}`;u=s+1}}}c=e[++s]}return n+e.substring(u)}parse(e,t,n){let s,a,u;if(t&&(t.onQuad||t.onPrefix||t.onComment)?(s=t.onQuad,a=t.onPrefix,u=t.onComment):(s=t,a=n),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${blankNodePrefix$1++}_`,this._prefixCallback=a||noop$1,this._inversePredicate=!1,this._quantified=Object.create(null),!s){const h=[];let f;if(this._callback=(p,g)=>{p?f=p:g&&h.push(g)},this._lexer.tokenize(e).every(p=>this._readCallback=this._readCallback(p)),f)throw f;return h}let c=(h,f)=>{h!==null?(this._callback(h),this._callback=noop$1):this._readCallback&&(this._readCallback=this._readCallback(f))};u&&(this._lexer.comments=!0,c=(h,f)=>{h!==null?(this._callback(h),this._callback=noop$1):this._readCallback&&(f.type==="comment"?u(f.value):this._readCallback=this._readCallback(f))}),this._callback=s,this._lexer.tokenize(e,c)}};function noop$1(){}function initDataFactory$1(i,e){i._factory=e,i.DEFAULTGRAPH=e.defaultGraph(),i.RDF_FIRST=e.namedNode(namespaces$1.rdf.first),i.RDF_REST=e.namedNode(namespaces$1.rdf.rest),i.RDF_NIL=e.namedNode(namespaces$1.rdf.nil),i.N3_FORALL=e.namedNode(namespaces$1.r.forAll),i.N3_FORSOME=e.namedNode(namespaces$1.r.forSome),i.ABBREVIATIONS={a:e.namedNode(namespaces$1.rdf.type),"=":e.namedNode(namespaces$1.owl.sameAs),">":e.namedNode(namespaces$1.log.implies),"<":e.namedNode(namespaces$1.log.isImpliedBy)},i.QUANTIFIERS_GRAPH=e.namedNode("urn:n3:quantifiers")}initDataFactory$1(N3Parser$1.prototype,DataFactory$2);function isDefaultGraph$1(i){return!!i&&i.termType==="DefaultGraph"}function escapeRegex$2(i){return i.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&")}const BASE_UNSUPPORTED$1=/^:?[^:?#]*(?:[?#]|$)|^file:|^[^:]*:\/*[^?#]+?\/(?:\.\.?(?:\/|$)|\/)/i,SUFFIX_SUPPORTED$1=/^(?:(?:[^/?#]{3,}|\.?[^/?#.]\.?)(?:\/[^/?#]{3,}|\.?[^/?#.]\.?)*\/?)?(?:[?#]|$)/,CURRENT$1="./",PARENT$1="../",QUERY$1="?",FRAGMENT$1="#";let BaseIRI$1=class mh{constructor(e){this.base=e,this._baseLength=0,this._baseMatcher=null,this._pathReplacements=new Array(e.length+1)}static supports(e){return!BASE_UNSUPPORTED$1.test(e)}_getBaseMatcher(){if(this._baseMatcher)return this._baseMatcher;if(!mh.supports(this.base))return this._baseMatcher=/.^/;const e=/^[^:]*:\/*/.exec(this.base)[0],t=["^",escapeRegex$2(e)],n=[],s=[],a=/[^/?#]*([/?#])/y;let u,c=0,h=0,f=a.lastIndex=e.length;for(;!c&&!h&&(u=a.exec(this.base));)u[1]===FRAGMENT$1?h=a.lastIndex-1:(t.push(escapeRegex$2(u[0]),"(?:"),n.push(")?"),u[1]!==QUERY$1?s.push(f=a.lastIndex):(c=f=a.lastIndex,h=this.base.indexOf(FRAGMENT$1,c),this._pathReplacements[c]=QUERY$1));for(let p=0;p<s.length;p++)this._pathReplacements[s[p]]=PARENT$1.repeat(s.length-p-1);return this._pathReplacements[s[s.length-1]]=CURRENT$1,this._baseLength=h>0?h:this.base.length,t.push(escapeRegex$2(this.base.substring(f,this._baseLength)),c?"(?:#|$)":"(?:[?#]|$)"),this._baseMatcher=new RegExp([...t,...n].join(""))}toRelative(e){const t=this._getBaseMatcher().exec(e);if(!t)return e;const n=t[0].length;if(n===this._baseLength&&n===e.length)return"";const s=this._pathReplacements[n];if(s){const a=e.substring(n);return s!==QUERY$1&&!SUFFIX_SUPPORTED$1.test(a)?e:s===CURRENT$1&&/^[^?#]/.test(a)?a:s+a}return e.substring(n-1)}};const DEFAULTGRAPH$2=DataFactory$2.defaultGraph(),{rdf:rdf$2,xsd:xsd$3}=namespaces$1,escape$2=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,escapeAll$1=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,escapedCharacters$1={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};let SerializedTerm$1=class extends Term$1{equals(e){return e===this}},N3Writer$1=class{constructor(e,t){if(this._prefixRegex=/$0^/,e&&typeof e.write!="function"&&(t=e,e=null),t=t||{},this._lists=t.lists,e)this._outputStream=e,this._endStream=t.end===void 0?!0:!!t.end;else{let n="";this._outputStream={write(s,a,u){n+=s,u&&u()},end:s=>{s&&s(null,n)}},this._endStream=!0}this._subject=null,/triple|quad/i.test(t.format)?(this._lineMode=!0,this._writeQuad=this._writeQuadLine):(this._lineMode=!1,this._graph=DEFAULTGRAPH$2,this._prefixIRIs=Object.create(null),t.prefixes&&this.addPrefixes(t.prefixes),t.baseIRI&&(this._baseIri=new BaseIRI$1(t.baseIRI)))}get _inDefaultGraph(){return DEFAULTGRAPH$2.equals(this._graph)}_write(e,t){this._outputStream.write(e,"utf8",t)}_writeQuad(e,t,n,s,a){try{s.equals(this._graph)||(this._write((this._subject===null?"":this._inDefaultGraph?`.
96
+ `:`
97
+ }
98
+ `)+(DEFAULTGRAPH$2.equals(s)?"":`${this._encodeIriOrBlank(s)} {
99
+ `)),this._graph=s,this._subject=null),e.equals(this._subject)?t.equals(this._predicate)?this._write(`, ${this._encodeObject(n)}`,a):this._write(`;
100
+ ${this._encodePredicate(this._predicate=t)} ${this._encodeObject(n)}`,a):this._write(`${(this._subject===null?"":`.
101
+ `)+this._encodeSubject(this._subject=e)} ${this._encodePredicate(this._predicate=t)} ${this._encodeObject(n)}`,a)}catch(u){a&&a(u)}}_writeQuadLine(e,t,n,s,a){delete this._prefixMatch,this._write(this.quadToString(e,t,n,s),a)}quadToString(e,t,n,s){return`${this._encodeSubject(e)} ${this._encodeIriOrBlank(t)} ${this._encodeObject(n)}${s&&s.value?` ${this._encodeIriOrBlank(s)} .
102
+ `:` .
103
+ `}`}quadsToString(e){let t="";for(const n of e)t+=this.quadToString(n.subject,n.predicate,n.object,n.graph);return t}_encodeSubject(e){return e.termType==="Quad"?this._encodeQuad(e):this._encodeIriOrBlank(e)}_encodeIriOrBlank(e){if(e.termType!=="NamedNode")return this._lists&&e.value in this._lists&&(e=this.list(this._lists[e.value])),"id"in e?e.id:`_:${e.value}`;let t=e.value;this._baseIri&&(t=this._baseIri.toRelative(t)),escape$2.test(t)&&(t=t.replace(escapeAll$1,characterReplacer$1));const n=this._prefixRegex.exec(t);return n?n[1]?this._prefixIRIs[n[1]]+n[2]:t:`<${t}>`}_encodeLiteral(e){let t=e.value;if(escape$2.test(t)&&(t=t.replace(escapeAll$1,characterReplacer$1)),e.language)return`"${t}"@${e.language}`;if(this._lineMode){if(e.datatype.value===xsd$3.string)return`"${t}"`}else switch(e.datatype.value){case xsd$3.string:return`"${t}"`;case xsd$3.boolean:if(t==="true"||t==="false")return t;break;case xsd$3.integer:if(/^[+-]?\d+$/.test(t))return t;break;case xsd$3.decimal:if(/^[+-]?\d*\.\d+$/.test(t))return t;break;case xsd$3.double:if(/^[+-]?(?:\d+\.\d*|\.?\d+)[eE][+-]?\d+$/.test(t))return t;break}return`"${t}"^^${this._encodeIriOrBlank(e.datatype)}`}_encodePredicate(e){return e.value===rdf$2.type?"a":this._encodeIriOrBlank(e)}_encodeObject(e){switch(e.termType){case"Quad":return this._encodeQuad(e);case"Literal":return this._encodeLiteral(e);default:return this._encodeIriOrBlank(e)}}_encodeQuad({subject:e,predicate:t,object:n,graph:s}){return`<<${this._encodeSubject(e)} ${this._encodePredicate(t)} ${this._encodeObject(n)}${isDefaultGraph$1(s)?"":` ${this._encodeIriOrBlank(s)}`}>>`}_blockedWrite(){throw new Error("Cannot write because the writer has been closed.")}addQuad(e,t,n,s,a){n===void 0?this._writeQuad(e.subject,e.predicate,e.object,e.graph,t):typeof s=="function"?this._writeQuad(e,t,n,DEFAULTGRAPH$2,s):this._writeQuad(e,t,n,s||DEFAULTGRAPH$2,a)}addQuads(e){for(let t=0;t<e.length;t++)this.addQuad(e[t])}addPrefix(e,t,n){const s={};s[e]=t,this.addPrefixes(s,n)}addPrefixes(e,t){if(!this._prefixIRIs)return t&&t();let n=!1;for(let s in e){let a=e[s];typeof a!="string"&&(a=a.value),n=!0,this._subject!==null&&(this._write(this._inDefaultGraph?`.
104
+ `:`
105
+ }
106
+ `),this._subject=null,this._graph=""),this._prefixIRIs[a]=s+=":",this._write(`@prefix ${s} <${a}>.
107
+ `)}if(n){let s="",a="";for(const u in this._prefixIRIs)s+=s?`|${u}`:u,a+=(a?"|":"")+this._prefixIRIs[u];s=escapeRegex$2(s),this._prefixRegex=new RegExp(`^(?:${a})[^/]*$|^(${s})([_a-zA-Z0-9][\\-_a-zA-Z0-9]*)$`)}this._write(n?`
108
+ `:"",t)}blank(e,t){let n=e,s,a;switch(e===void 0?n=[]:e.termType?n=[{predicate:e,object:t}]:"length"in e||(n=[e]),a=n.length){case 0:return new SerializedTerm$1("[]");case 1:if(s=n[0],!(s.object instanceof SerializedTerm$1))return new SerializedTerm$1(`[ ${this._encodePredicate(s.predicate)} ${this._encodeObject(s.object)} ]`);default:let u="[";for(let c=0;c<a;c++)s=n[c],s.predicate.equals(e)?u+=`, ${this._encodeObject(s.object)}`:(u+=`${(c?`;
109
+ `:`
110
+ `)+this._encodePredicate(s.predicate)} ${this._encodeObject(s.object)}`,e=s.predicate);return new SerializedTerm$1(`${u}
111
+ ]`)}}list(e){const t=e&&e.length||0,n=new Array(t);for(let s=0;s<t;s++)n[s]=this._encodeObject(e[s]);return new SerializedTerm$1(`(${n.join(" ")})`)}end(e){this._subject!==null&&(this._write(this._inDefaultGraph?`.
112
+ `:`
113
+ }
114
+ `),this._subject=null),this._write=this._blockedWrite;let t=e&&((n,s)=>{t=null,e(n,s)});if(this._endStream)try{return this._outputStream.end(t)}catch{}t&&t()}};function characterReplacer$1(i){let e=escapedCharacters$1[i];return e===void 0&&(i.length===1?(e=i.charCodeAt(0).toString(16),e="\\u0000".substr(0,6-e.length)+e):(e=((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)+9216).toString(16),e="\\U00000000".substr(0,10-e.length)+e)),e}var browser$3={exports:{}},stream$1={exports:{}},primordials$1,hasRequiredPrimordials$1;function requirePrimordials$1(){if(hasRequiredPrimordials$1)return primordials$1;hasRequiredPrimordials$1=1;class i extends Error{constructor(t){if(!Array.isArray(t))throw new TypeError(`Expected input to be an Array, got ${typeof t}`);let n="";for(let s=0;s<t.length;s++)n+=` ${t[s].stack}
115
+ `;super(n),this.name="AggregateError",this.errors=t}}return primordials$1={AggregateError:i,ArrayIsArray(e){return Array.isArray(e)},ArrayPrototypeIncludes(e,t){return e.includes(t)},ArrayPrototypeIndexOf(e,t){return e.indexOf(t)},ArrayPrototypeJoin(e,t){return e.join(t)},ArrayPrototypeMap(e,t){return e.map(t)},ArrayPrototypePop(e,t){return e.pop(t)},ArrayPrototypePush(e,t){return e.push(t)},ArrayPrototypeSlice(e,t,n){return e.slice(t,n)},Error,FunctionPrototypeCall(e,t,...n){return e.call(t,...n)},FunctionPrototypeSymbolHasInstance(e,t){return Function.prototype[Symbol.hasInstance].call(e,t)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(e,t){return Object.defineProperties(e,t)},ObjectDefineProperty(e,t,n){return Object.defineProperty(e,t,n)},ObjectGetOwnPropertyDescriptor(e,t){return Object.getOwnPropertyDescriptor(e,t)},ObjectKeys(e){return Object.keys(e)},ObjectSetPrototypeOf(e,t){return Object.setPrototypeOf(e,t)},Promise,PromisePrototypeCatch(e,t){return e.catch(t)},PromisePrototypeThen(e,t,n){return e.then(t,n)},PromiseReject(e){return Promise.reject(e)},PromiseResolve(e){return Promise.resolve(e)},ReflectApply:Reflect.apply,RegExpPrototypeTest(e,t){return e.test(t)},SafeSet:Set,String,StringPrototypeSlice(e,t,n){return e.slice(t,n)},StringPrototypeToLowerCase(e){return e.toLowerCase()},StringPrototypeToUpperCase(e){return e.toUpperCase()},StringPrototypeTrim(e){return e.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(e,t,n){return e.set(t,n)},Boolean,Uint8Array},primordials$1}var util$1={exports:{}},inspect$1,hasRequiredInspect$1;function requireInspect$1(){return hasRequiredInspect$1||(hasRequiredInspect$1=1,inspect$1={format(i,...e){return i.replace(/%([sdifj])/g,function(...[t,n]){const s=e.shift();return n==="f"?s.toFixed(6):n==="j"?JSON.stringify(s):n==="s"&&typeof s=="object"?`${s.constructor!==Object?s.constructor.name:""} {}`.trim():s.toString()})},inspect(i){switch(typeof i){case"string":if(i.includes("'"))if(i.includes('"')){if(!i.includes("`")&&!i.includes("${"))return`\`${i}\``}else return`"${i}"`;return`'${i}'`;case"number":return isNaN(i)?"NaN":Object.is(i,-0)?String(i):i;case"bigint":return`${String(i)}n`;case"boolean":case"undefined":return String(i);case"object":return"{}"}}}),inspect$1}var errors$1,hasRequiredErrors$1;function requireErrors$1(){if(hasRequiredErrors$1)return errors$1;hasRequiredErrors$1=1;const{format:i,inspect:e}=requireInspect$1(),{AggregateError:t}=requirePrimordials$1(),n=globalThis.AggregateError||t,s=Symbol("kIsNodeError"),a=["string","function","number","object","Function","Object","boolean","bigint","symbol"],u=/^([A-Z][a-z0-9]*)+$/,c="__node_internal_",h={};function f(T,A){if(!T)throw new h.ERR_INTERNAL_ASSERTION(A)}function p(T){let A="",F=T.length;const x=T[0]==="-"?1:0;for(;F>=x+4;F-=3)A=`_${T.slice(F-3,F)}${A}`;return`${T.slice(0,F)}${A}`}function g(T,A,F){if(typeof A=="function")return f(A.length<=F.length,`Code: ${T}; The provided arguments length (${F.length}) does not match the required ones (${A.length}).`),A(...F);const x=(A.match(/%[dfijoOs]/g)||[]).length;return f(x===F.length,`Code: ${T}; The provided arguments length (${F.length}) does not match the required ones (${x}).`),F.length===0?A:i(A,...F)}function y(T,A,F){F||(F=Error);class x extends F{constructor(...O){super(g(T,A,O))}toString(){return`${this.name} [${T}]: ${this.message}`}}Object.defineProperties(x.prototype,{name:{value:F.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${T}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),x.prototype.code=T,x.prototype[s]=!0,h[T]=x}function S(T){const A=c+T.name;return Object.defineProperty(T,"name",{value:A}),T}function w(T,A){if(T&&A&&T!==A){if(Array.isArray(A.errors))return A.errors.push(T),A;const F=new n([A,T],A.message);return F.code=A.code,F}return T||A}class R extends Error{constructor(A="The operation was aborted",F=void 0){if(F!==void 0&&typeof F!="object")throw new h.ERR_INVALID_ARG_TYPE("options","Object",F);super(A,F),this.code="ABORT_ERR",this.name="AbortError"}}return y("ERR_ASSERTION","%s",Error),y("ERR_INVALID_ARG_TYPE",(T,A,F)=>{f(typeof T=="string","'name' must be a string"),Array.isArray(A)||(A=[A]);let x="The ";T.endsWith(" argument")?x+=`${T} `:x+=`"${T}" ${T.includes(".")?"property":"argument"} `,x+="must be ";const D=[],O=[],K=[];for(const X of A)f(typeof X=="string","All expected entries have to be of type string"),a.includes(X)?D.push(X.toLowerCase()):u.test(X)?O.push(X):(f(X!=="object",'The value "object" should be written as "Object"'),K.push(X));if(O.length>0){const X=D.indexOf("object");X!==-1&&(D.splice(D,X,1),O.push("Object"))}if(D.length>0){switch(D.length){case 1:x+=`of type ${D[0]}`;break;case 2:x+=`one of type ${D[0]} or ${D[1]}`;break;default:{const X=D.pop();x+=`one of type ${D.join(", ")}, or ${X}`}}(O.length>0||K.length>0)&&(x+=" or ")}if(O.length>0){switch(O.length){case 1:x+=`an instance of ${O[0]}`;break;case 2:x+=`an instance of ${O[0]} or ${O[1]}`;break;default:{const X=O.pop();x+=`an instance of ${O.join(", ")}, or ${X}`}}K.length>0&&(x+=" or ")}switch(K.length){case 0:break;case 1:K[0].toLowerCase()!==K[0]&&(x+="an "),x+=`${K[0]}`;break;case 2:x+=`one of ${K[0]} or ${K[1]}`;break;default:{const X=K.pop();x+=`one of ${K.join(", ")}, or ${X}`}}if(F==null)x+=`. Received ${F}`;else if(typeof F=="function"&&F.name)x+=`. Received function ${F.name}`;else if(typeof F=="object"){var z;if((z=F.constructor)!==null&&z!==void 0&&z.name)x+=`. Received an instance of ${F.constructor.name}`;else{const X=e(F,{depth:-1});x+=`. Received ${X}`}}else{let X=e(F,{colors:!1});X.length>25&&(X=`${X.slice(0,25)}...`),x+=`. Received type ${typeof F} (${X})`}return x},TypeError),y("ERR_INVALID_ARG_VALUE",(T,A,F="is invalid")=>{let x=e(A);return x.length>128&&(x=x.slice(0,128)+"..."),`The ${T.includes(".")?"property":"argument"} '${T}' ${F}. Received ${x}`},TypeError),y("ERR_INVALID_RETURN_VALUE",(T,A,F)=>{var x;const D=F!=null&&(x=F.constructor)!==null&&x!==void 0&&x.name?`instance of ${F.constructor.name}`:`type ${typeof F}`;return`Expected ${T} to be returned from the "${A}" function but got ${D}.`},TypeError),y("ERR_MISSING_ARGS",(...T)=>{f(T.length>0,"At least one arg needs to be specified");let A;const F=T.length;switch(T=(Array.isArray(T)?T:[T]).map(x=>`"${x}"`).join(" or "),F){case 1:A+=`The ${T[0]} argument`;break;case 2:A+=`The ${T[0]} and ${T[1]} arguments`;break;default:{const x=T.pop();A+=`The ${T.join(", ")}, and ${x} arguments`}break}return`${A} must be specified`},TypeError),y("ERR_OUT_OF_RANGE",(T,A,F)=>{f(A,'Missing "range" argument');let x;if(Number.isInteger(F)&&Math.abs(F)>2**32)x=p(String(F));else if(typeof F=="bigint"){x=String(F);const D=BigInt(2)**BigInt(32);(F>D||F<-D)&&(x=p(x)),x+="n"}else x=e(F);return`The value of "${T}" is out of range. It must be ${A}. Received ${x}`},RangeError),y("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),y("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),y("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),y("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),y("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),y("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),y("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),y("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),y("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),y("ERR_STREAM_WRITE_AFTER_END","write after end",Error),y("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),errors$1={AbortError:R,aggregateTwoErrors:S(w),hideStackFrames:S,codes:h},errors$1}var browser$2={exports:{}},hasRequiredBrowser$3;function requireBrowser$3(){if(hasRequiredBrowser$3)return browser$2.exports;hasRequiredBrowser$3=1;const{AbortController:i,AbortSignal:e}=typeof self<"u"?self:typeof window<"u"?window:void 0;return browser$2.exports=i,browser$2.exports.AbortSignal=e,browser$2.exports.default=i,browser$2.exports}var hasRequiredUtil$1;function requireUtil$1(){return hasRequiredUtil$1||(hasRequiredUtil$1=1,(function(i){const e=requireBuffer(),{format:t,inspect:n}=requireInspect$1(),{codes:{ERR_INVALID_ARG_TYPE:s}}=requireErrors$1(),{kResistStopPropagation:a,AggregateError:u,SymbolDispose:c}=requirePrimordials$1(),h=globalThis.AbortSignal||requireBrowser$3().AbortSignal,f=globalThis.AbortController||requireBrowser$3().AbortController,p=Object.getPrototypeOf(async function(){}).constructor,g=globalThis.Blob||e.Blob,y=typeof g<"u"?function(T){return T instanceof g}:function(T){return!1},S=(R,T)=>{if(R!==void 0&&(R===null||typeof R!="object"||!("aborted"in R)))throw new s(T,"AbortSignal",R)},w=(R,T)=>{if(typeof R!="function")throw new s(T,"Function",R)};i.exports={AggregateError:u,kEmptyObject:Object.freeze({}),once(R){let T=!1;return function(...A){T||(T=!0,R.apply(this,A))}},createDeferredPromise:function(){let R,T;return{promise:new Promise((F,x)=>{R=F,T=x}),resolve:R,reject:T}},promisify(R){return new Promise((T,A)=>{R((F,...x)=>F?A(F):T(...x))})},debuglog(){return function(){}},format:t,inspect:n,types:{isAsyncFunction(R){return R instanceof p},isArrayBufferView(R){return ArrayBuffer.isView(R)}},isBlob:y,deprecate(R,T){return R},addAbortListener:requireEvents().addAbortListener||function(T,A){if(T===void 0)throw new s("signal","AbortSignal",T);S(T,"signal"),w(A,"listener");let F;return T.aborted?queueMicrotask(()=>A()):(T.addEventListener("abort",A,{__proto__:null,once:!0,[a]:!0}),F=()=>{T.removeEventListener("abort",A)}),{__proto__:null,[c](){var x;(x=F)===null||x===void 0||x()}}},AbortSignalAny:h.any||function(T){if(T.length===1)return T[0];const A=new f,F=()=>A.abort();return T.forEach(x=>{S(x,"signals"),x.addEventListener("abort",F,{once:!0})}),A.signal.addEventListener("abort",()=>{T.forEach(x=>x.removeEventListener("abort",F))},{once:!0}),A.signal}},i.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")})(util$1)),util$1.exports}var operators$1={},validators$1,hasRequiredValidators$1;function requireValidators$1(){if(hasRequiredValidators$1)return validators$1;hasRequiredValidators$1=1;const{ArrayIsArray:i,ArrayPrototypeIncludes:e,ArrayPrototypeJoin:t,ArrayPrototypeMap:n,NumberIsInteger:s,NumberIsNaN:a,NumberMAX_SAFE_INTEGER:u,NumberMIN_SAFE_INTEGER:c,NumberParseInt:h,ObjectPrototypeHasOwnProperty:f,RegExpPrototypeExec:p,String:g,StringPrototypeToUpperCase:y,StringPrototypeTrim:S}=requirePrimordials$1(),{hideStackFrames:w,codes:{ERR_SOCKET_BAD_PORT:R,ERR_INVALID_ARG_TYPE:T,ERR_INVALID_ARG_VALUE:A,ERR_OUT_OF_RANGE:F,ERR_UNKNOWN_SIGNAL:x}}=requireErrors$1(),{normalizeEncoding:D}=requireUtil$1(),{isAsyncFunction:O,isArrayBufferView:K}=requireUtil$1().types,z={};function X(J){return J===(J|0)}function Ee(J){return J===J>>>0}const q=/^[0-7]+$/,Y="must be a 32-bit unsigned integer or an octal string";function Te(J,me,xe){if(typeof J>"u"&&(J=xe),typeof J=="string"){if(p(q,J)===null)throw new A(me,J,Y);J=h(J,8)}return ze(J,me),J}const re=w((J,me,xe=c,de=u)=>{if(typeof J!="number")throw new T(me,"number",J);if(!s(J))throw new F(me,"an integer",J);if(J<xe||J>de)throw new F(me,`>= ${xe} && <= ${de}`,J)}),$e=w((J,me,xe=-2147483648,de=2147483647)=>{if(typeof J!="number")throw new T(me,"number",J);if(!s(J))throw new F(me,"an integer",J);if(J<xe||J>de)throw new F(me,`>= ${xe} && <= ${de}`,J)}),ze=w((J,me,xe=!1)=>{if(typeof J!="number")throw new T(me,"number",J);if(!s(J))throw new F(me,"an integer",J);const de=xe?1:0,st=4294967295;if(J<de||J>st)throw new F(me,`>= ${de} && <= ${st}`,J)});function ye(J,me){if(typeof J!="string")throw new T(me,"string",J)}function Ve(J,me,xe=void 0,de){if(typeof J!="number")throw new T(me,"number",J);if(xe!=null&&J<xe||de!=null&&J>de||(xe!=null||de!=null)&&a(J))throw new F(me,`${xe!=null?`>= ${xe}`:""}${xe!=null&&de!=null?" && ":""}${de!=null?`<= ${de}`:""}`,J)}const pe=w((J,me,xe)=>{if(!e(xe,J)){const st="must be one of: "+t(n(xe,ft=>typeof ft=="string"?`'${ft}'`:g(ft)),", ");throw new A(me,J,st)}});function De(J,me){if(typeof J!="boolean")throw new T(me,"boolean",J)}function $(J,me,xe){return J==null||!f(J,me)?xe:J[me]}const G=w((J,me,xe=null)=>{const de=$(xe,"allowArray",!1),st=$(xe,"allowFunction",!1);if(!$(xe,"nullable",!1)&&J===null||!de&&i(J)||typeof J!="object"&&(!st||typeof J!="function"))throw new T(me,"Object",J)}),ce=w((J,me)=>{if(J!=null&&typeof J!="object"&&typeof J!="function")throw new T(me,"a dictionary",J)}),oe=w((J,me,xe=0)=>{if(!i(J))throw new T(me,"Array",J);if(J.length<xe){const de=`must be longer than ${xe}`;throw new A(me,J,de)}});function Fe(J,me){oe(J,me);for(let xe=0;xe<J.length;xe++)ye(J[xe],`${me}[${xe}]`)}function Ue(J,me){oe(J,me);for(let xe=0;xe<J.length;xe++)De(J[xe],`${me}[${xe}]`)}function Je(J,me){oe(J,me);for(let xe=0;xe<J.length;xe++){const de=J[xe],st=`${me}[${xe}]`;if(de==null)throw new T(st,"AbortSignal",de);ie(de,st)}}function He(J,me="signal"){if(ye(J,me),z[J]===void 0)throw z[y(J)]!==void 0?new x(J+" (signals must use all capital letters)"):new x(J)}const he=w((J,me="buffer")=>{if(!K(J))throw new T(me,["Buffer","TypedArray","DataView"],J)});function fe(J,me){const xe=D(me),de=J.length;if(xe==="hex"&&de%2!==0)throw new A("encoding",me,`is invalid for data of length ${de}`)}function Oe(J,me="Port",xe=!0){if(typeof J!="number"&&typeof J!="string"||typeof J=="string"&&S(J).length===0||+J!==+J>>>0||J>65535||J===0&&!xe)throw new R(me,J,xe);return J|0}const ie=w((J,me)=>{if(J!==void 0&&(J===null||typeof J!="object"||!("aborted"in J)))throw new T(me,"AbortSignal",J)}),j=w((J,me)=>{if(typeof J!="function")throw new T(me,"Function",J)}),N=w((J,me)=>{if(typeof J!="function"||O(J))throw new T(me,"Function",J)}),L=w((J,me)=>{if(J!==void 0)throw new T(me,"undefined",J)});function V(J,me,xe){if(!e(xe,J))throw new T(me,`('${t(xe,"|")}')`,J)}const ee=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function ae(J,me){if(typeof J>"u"||!p(ee,J))throw new A(me,J,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function ve(J){if(typeof J=="string")return ae(J,"hints"),J;if(i(J)){const me=J.length;let xe="";if(me===0)return xe;for(let de=0;de<me;de++){const st=J[de];ae(st,"hints"),xe+=st,de!==me-1&&(xe+=", ")}return xe}throw new A("hints",J,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}return validators$1={isInt32:X,isUint32:Ee,parseFileMode:Te,validateArray:oe,validateStringArray:Fe,validateBooleanArray:Ue,validateAbortSignalArray:Je,validateBoolean:De,validateBuffer:he,validateDictionary:ce,validateEncoding:fe,validateFunction:j,validateInt32:$e,validateInteger:re,validateNumber:Ve,validateObject:G,validateOneOf:pe,validatePlainFunction:N,validatePort:Oe,validateSignalName:He,validateString:ye,validateUint32:ze,validateUndefined:L,validateUnion:V,validateAbortSignal:ie,validateLinkHeaderValue:ve},validators$1}var endOfStream$1={exports:{}},browser$1={exports:{}},hasRequiredBrowser$2;function requireBrowser$2(){if(hasRequiredBrowser$2)return browser$1.exports;hasRequiredBrowser$2=1;var i=browser$1.exports={},e,t;function n(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?e=setTimeout:e=n}catch{e=n}try{typeof clearTimeout=="function"?t=clearTimeout:t=s}catch{t=s}})();function a(R){if(e===setTimeout)return setTimeout(R,0);if((e===n||!e)&&setTimeout)return e=setTimeout,setTimeout(R,0);try{return e(R,0)}catch{try{return e.call(null,R,0)}catch{return e.call(this,R,0)}}}function u(R){if(t===clearTimeout)return clearTimeout(R);if((t===s||!t)&&clearTimeout)return t=clearTimeout,clearTimeout(R);try{return t(R)}catch{try{return t.call(null,R)}catch{return t.call(this,R)}}}var c=[],h=!1,f,p=-1;function g(){!h||!f||(h=!1,f.length?c=f.concat(c):p=-1,c.length&&y())}function y(){if(!h){var R=a(g);h=!0;for(var T=c.length;T;){for(f=c,c=[];++p<T;)f&&f[p].run();p=-1,T=c.length}f=null,h=!1,u(R)}}i.nextTick=function(R){var T=new Array(arguments.length-1);if(arguments.length>1)for(var A=1;A<arguments.length;A++)T[A-1]=arguments[A];c.push(new S(R,T)),c.length===1&&!h&&a(y)};function S(R,T){this.fun=R,this.array=T}S.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={};function w(){}return i.on=w,i.addListener=w,i.once=w,i.off=w,i.removeListener=w,i.removeAllListeners=w,i.emit=w,i.prependListener=w,i.prependOnceListener=w,i.listeners=function(R){return[]},i.binding=function(R){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(R){throw new Error("process.chdir is not supported")},i.umask=function(){return 0},browser$1.exports}var utils$1,hasRequiredUtils$1;function requireUtils$1(){if(hasRequiredUtils$1)return utils$1;hasRequiredUtils$1=1;const{SymbolAsyncIterator:i,SymbolIterator:e,SymbolFor:t}=requirePrimordials$1(),n=t("nodejs.stream.destroyed"),s=t("nodejs.stream.errored"),a=t("nodejs.stream.readable"),u=t("nodejs.stream.writable"),c=t("nodejs.stream.disturbed"),h=t("nodejs.webstream.isClosedPromise"),f=t("nodejs.webstream.controllerErrorFunction");function p($,G=!1){var ce;return!!($&&typeof $.pipe=="function"&&typeof $.on=="function"&&(!G||typeof $.pause=="function"&&typeof $.resume=="function")&&(!$._writableState||((ce=$._readableState)===null||ce===void 0?void 0:ce.readable)!==!1)&&(!$._writableState||$._readableState))}function g($){var G;return!!($&&typeof $.write=="function"&&typeof $.on=="function"&&(!$._readableState||((G=$._writableState)===null||G===void 0?void 0:G.writable)!==!1))}function y($){return!!($&&typeof $.pipe=="function"&&$._readableState&&typeof $.on=="function"&&typeof $.write=="function")}function S($){return $&&($._readableState||$._writableState||typeof $.write=="function"&&typeof $.on=="function"||typeof $.pipe=="function"&&typeof $.on=="function")}function w($){return!!($&&!S($)&&typeof $.pipeThrough=="function"&&typeof $.getReader=="function"&&typeof $.cancel=="function")}function R($){return!!($&&!S($)&&typeof $.getWriter=="function"&&typeof $.abort=="function")}function T($){return!!($&&!S($)&&typeof $.readable=="object"&&typeof $.writable=="object")}function A($){return w($)||R($)||T($)}function F($,G){return $==null?!1:G===!0?typeof $[i]=="function":G===!1?typeof $[e]=="function":typeof $[i]=="function"||typeof $[e]=="function"}function x($){if(!S($))return null;const G=$._writableState,ce=$._readableState,oe=G||ce;return!!($.destroyed||$[n]||oe!=null&&oe.destroyed)}function D($){if(!g($))return null;if($.writableEnded===!0)return!0;const G=$._writableState;return G!=null&&G.errored?!1:typeof G?.ended!="boolean"?null:G.ended}function O($,G){if(!g($))return null;if($.writableFinished===!0)return!0;const ce=$._writableState;return ce!=null&&ce.errored?!1:typeof ce?.finished!="boolean"?null:!!(ce.finished||G===!1&&ce.ended===!0&&ce.length===0)}function K($){if(!p($))return null;if($.readableEnded===!0)return!0;const G=$._readableState;return!G||G.errored?!1:typeof G?.ended!="boolean"?null:G.ended}function z($,G){if(!p($))return null;const ce=$._readableState;return ce!=null&&ce.errored?!1:typeof ce?.endEmitted!="boolean"?null:!!(ce.endEmitted||G===!1&&ce.ended===!0&&ce.length===0)}function X($){return $&&$[a]!=null?$[a]:typeof $?.readable!="boolean"?null:x($)?!1:p($)&&$.readable&&!z($)}function Ee($){return $&&$[u]!=null?$[u]:typeof $?.writable!="boolean"?null:x($)?!1:g($)&&$.writable&&!D($)}function q($,G){return S($)?x($)?!0:!(G?.readable!==!1&&X($)||G?.writable!==!1&&Ee($)):null}function Y($){var G,ce;return S($)?$.writableErrored?$.writableErrored:(G=(ce=$._writableState)===null||ce===void 0?void 0:ce.errored)!==null&&G!==void 0?G:null:null}function Te($){var G,ce;return S($)?$.readableErrored?$.readableErrored:(G=(ce=$._readableState)===null||ce===void 0?void 0:ce.errored)!==null&&G!==void 0?G:null:null}function re($){if(!S($))return null;if(typeof $.closed=="boolean")return $.closed;const G=$._writableState,ce=$._readableState;return typeof G?.closed=="boolean"||typeof ce?.closed=="boolean"?G?.closed||ce?.closed:typeof $._closed=="boolean"&&$e($)?$._closed:null}function $e($){return typeof $._closed=="boolean"&&typeof $._defaultKeepAlive=="boolean"&&typeof $._removedConnection=="boolean"&&typeof $._removedContLen=="boolean"}function ze($){return typeof $._sent100=="boolean"&&$e($)}function ye($){var G;return typeof $._consuming=="boolean"&&typeof $._dumped=="boolean"&&((G=$.req)===null||G===void 0?void 0:G.upgradeOrConnect)===void 0}function Ve($){if(!S($))return null;const G=$._writableState,ce=$._readableState,oe=G||ce;return!oe&&ze($)||!!(oe&&oe.autoDestroy&&oe.emitClose&&oe.closed===!1)}function pe($){var G;return!!($&&((G=$[c])!==null&&G!==void 0?G:$.readableDidRead||$.readableAborted))}function De($){var G,ce,oe,Fe,Ue,Je,He,he,fe,Oe;return!!($&&((G=(ce=(oe=(Fe=(Ue=(Je=$[s])!==null&&Je!==void 0?Je:$.readableErrored)!==null&&Ue!==void 0?Ue:$.writableErrored)!==null&&Fe!==void 0?Fe:(He=$._readableState)===null||He===void 0?void 0:He.errorEmitted)!==null&&oe!==void 0?oe:(he=$._writableState)===null||he===void 0?void 0:he.errorEmitted)!==null&&ce!==void 0?ce:(fe=$._readableState)===null||fe===void 0?void 0:fe.errored)!==null&&G!==void 0?G:!((Oe=$._writableState)===null||Oe===void 0)&&Oe.errored))}return utils$1={isDestroyed:x,kIsDestroyed:n,isDisturbed:pe,kIsDisturbed:c,isErrored:De,kIsErrored:s,isReadable:X,kIsReadable:a,kIsClosedPromise:h,kControllerErrorFunction:f,kIsWritable:u,isClosed:re,isDuplexNodeStream:y,isFinished:q,isIterable:F,isReadableNodeStream:p,isReadableStream:w,isReadableEnded:K,isReadableFinished:z,isReadableErrored:Te,isNodeStream:S,isWebStream:A,isWritable:Ee,isWritableNodeStream:g,isWritableStream:R,isWritableEnded:D,isWritableFinished:O,isWritableErrored:Y,isServerRequest:ye,isServerResponse:ze,willEmitClose:Ve,isTransformStream:T},utils$1}var hasRequiredEndOfStream$1;function requireEndOfStream$1(){if(hasRequiredEndOfStream$1)return endOfStream$1.exports;hasRequiredEndOfStream$1=1;const i=requireBrowser$2(),{AbortError:e,codes:t}=requireErrors$1(),{ERR_INVALID_ARG_TYPE:n,ERR_STREAM_PREMATURE_CLOSE:s}=t,{kEmptyObject:a,once:u}=requireUtil$1(),{validateAbortSignal:c,validateFunction:h,validateObject:f,validateBoolean:p}=requireValidators$1(),{Promise:g,PromisePrototypeThen:y,SymbolDispose:S}=requirePrimordials$1(),{isClosed:w,isReadable:R,isReadableNodeStream:T,isReadableStream:A,isReadableFinished:F,isReadableErrored:x,isWritable:D,isWritableNodeStream:O,isWritableStream:K,isWritableFinished:z,isWritableErrored:X,isNodeStream:Ee,willEmitClose:q,kIsClosedPromise:Y}=requireUtils$1();let Te;function re(pe){return pe.setHeader&&typeof pe.abort=="function"}const $e=()=>{};function ze(pe,De,$){var G,ce;if(arguments.length===2?($=De,De=a):De==null?De=a:f(De,"options"),h($,"callback"),c(De.signal,"options.signal"),$=u($),A(pe)||K(pe))return ye(pe,De,$);if(!Ee(pe))throw new n("stream",["ReadableStream","WritableStream","Stream"],pe);const oe=(G=De.readable)!==null&&G!==void 0?G:T(pe),Fe=(ce=De.writable)!==null&&ce!==void 0?ce:O(pe),Ue=pe._writableState,Je=pe._readableState,He=()=>{pe.writable||Oe()};let he=q(pe)&&T(pe)===oe&&O(pe)===Fe,fe=z(pe,!1);const Oe=()=>{fe=!0,pe.destroyed&&(he=!1),!(he&&(!pe.readable||oe))&&(!oe||ie)&&$.call(pe)};let ie=F(pe,!1);const j=()=>{ie=!0,pe.destroyed&&(he=!1),!(he&&(!pe.writable||Fe))&&(!Fe||fe)&&$.call(pe)},N=J=>{$.call(pe,J)};let L=w(pe);const V=()=>{L=!0;const J=X(pe)||x(pe);if(J&&typeof J!="boolean")return $.call(pe,J);if(oe&&!ie&&T(pe,!0)&&!F(pe,!1))return $.call(pe,new s);if(Fe&&!fe&&!z(pe,!1))return $.call(pe,new s);$.call(pe)},ee=()=>{L=!0;const J=X(pe)||x(pe);if(J&&typeof J!="boolean")return $.call(pe,J);$.call(pe)},ae=()=>{pe.req.on("finish",Oe)};re(pe)?(pe.on("complete",Oe),he||pe.on("abort",V),pe.req?ae():pe.on("request",ae)):Fe&&!Ue&&(pe.on("end",He),pe.on("close",He)),!he&&typeof pe.aborted=="boolean"&&pe.on("aborted",V),pe.on("end",j),pe.on("finish",Oe),De.error!==!1&&pe.on("error",N),pe.on("close",V),L?i.nextTick(V):Ue!=null&&Ue.errorEmitted||Je!=null&&Je.errorEmitted?he||i.nextTick(ee):(!oe&&(!he||R(pe))&&(fe||D(pe)===!1)||!Fe&&(!he||D(pe))&&(ie||R(pe)===!1)||Je&&pe.req&&pe.aborted)&&i.nextTick(ee);const ve=()=>{$=$e,pe.removeListener("aborted",V),pe.removeListener("complete",Oe),pe.removeListener("abort",V),pe.removeListener("request",ae),pe.req&&pe.req.removeListener("finish",Oe),pe.removeListener("end",He),pe.removeListener("close",He),pe.removeListener("finish",Oe),pe.removeListener("end",j),pe.removeListener("error",N),pe.removeListener("close",V)};if(De.signal&&!L){const J=()=>{const me=$;ve(),me.call(pe,new e(void 0,{cause:De.signal.reason}))};if(De.signal.aborted)i.nextTick(J);else{Te=Te||requireUtil$1().addAbortListener;const me=Te(De.signal,J),xe=$;$=u((...de)=>{me[S](),xe.apply(pe,de)})}}return ve}function ye(pe,De,$){let G=!1,ce=$e;if(De.signal)if(ce=()=>{G=!0,$.call(pe,new e(void 0,{cause:De.signal.reason}))},De.signal.aborted)i.nextTick(ce);else{Te=Te||requireUtil$1().addAbortListener;const Fe=Te(De.signal,ce),Ue=$;$=u((...Je)=>{Fe[S](),Ue.apply(pe,Je)})}const oe=(...Fe)=>{G||i.nextTick(()=>$.apply(pe,Fe))};return y(pe[Y].promise,oe,oe),$e}function Ve(pe,De){var $;let G=!1;return De===null&&(De=a),($=De)!==null&&$!==void 0&&$.cleanup&&(p(De.cleanup,"cleanup"),G=De.cleanup),new g((ce,oe)=>{const Fe=ze(pe,De,Ue=>{G&&Fe(),Ue?oe(Ue):ce()})})}return endOfStream$1.exports=ze,endOfStream$1.exports.finished=Ve,endOfStream$1.exports}var destroy_1$1,hasRequiredDestroy$1;function requireDestroy$1(){if(hasRequiredDestroy$1)return destroy_1$1;hasRequiredDestroy$1=1;const i=requireBrowser$2(),{aggregateTwoErrors:e,codes:{ERR_MULTIPLE_CALLBACK:t},AbortError:n}=requireErrors$1(),{Symbol:s}=requirePrimordials$1(),{kIsDestroyed:a,isDestroyed:u,isFinished:c,isServerRequest:h}=requireUtils$1(),f=s("kDestroy"),p=s("kConstruct");function g(q,Y,Te){q&&(q.stack,Y&&!Y.errored&&(Y.errored=q),Te&&!Te.errored&&(Te.errored=q))}function y(q,Y){const Te=this._readableState,re=this._writableState,$e=re||Te;return re!=null&&re.destroyed||Te!=null&&Te.destroyed?(typeof Y=="function"&&Y(),this):(g(q,re,Te),re&&(re.destroyed=!0),Te&&(Te.destroyed=!0),$e.constructed?S(this,q,Y):this.once(f,function(ze){S(this,e(ze,q),Y)}),this)}function S(q,Y,Te){let re=!1;function $e(ze){if(re)return;re=!0;const ye=q._readableState,Ve=q._writableState;g(ze,Ve,ye),Ve&&(Ve.closed=!0),ye&&(ye.closed=!0),typeof Te=="function"&&Te(ze),ze?i.nextTick(w,q,ze):i.nextTick(R,q)}try{q._destroy(Y||null,$e)}catch(ze){$e(ze)}}function w(q,Y){T(q,Y),R(q)}function R(q){const Y=q._readableState,Te=q._writableState;Te&&(Te.closeEmitted=!0),Y&&(Y.closeEmitted=!0),(Te!=null&&Te.emitClose||Y!=null&&Y.emitClose)&&q.emit("close")}function T(q,Y){const Te=q._readableState,re=q._writableState;re!=null&&re.errorEmitted||Te!=null&&Te.errorEmitted||(re&&(re.errorEmitted=!0),Te&&(Te.errorEmitted=!0),q.emit("error",Y))}function A(){const q=this._readableState,Y=this._writableState;q&&(q.constructed=!0,q.closed=!1,q.closeEmitted=!1,q.destroyed=!1,q.errored=null,q.errorEmitted=!1,q.reading=!1,q.ended=q.readable===!1,q.endEmitted=q.readable===!1),Y&&(Y.constructed=!0,Y.destroyed=!1,Y.closed=!1,Y.closeEmitted=!1,Y.errored=null,Y.errorEmitted=!1,Y.finalCalled=!1,Y.prefinished=!1,Y.ended=Y.writable===!1,Y.ending=Y.writable===!1,Y.finished=Y.writable===!1)}function F(q,Y,Te){const re=q._readableState,$e=q._writableState;if($e!=null&&$e.destroyed||re!=null&&re.destroyed)return this;re!=null&&re.autoDestroy||$e!=null&&$e.autoDestroy?q.destroy(Y):Y&&(Y.stack,$e&&!$e.errored&&($e.errored=Y),re&&!re.errored&&(re.errored=Y),Te?i.nextTick(T,q,Y):T(q,Y))}function x(q,Y){if(typeof q._construct!="function")return;const Te=q._readableState,re=q._writableState;Te&&(Te.constructed=!1),re&&(re.constructed=!1),q.once(p,Y),!(q.listenerCount(p)>1)&&i.nextTick(D,q)}function D(q){let Y=!1;function Te(re){if(Y){F(q,re??new t);return}Y=!0;const $e=q._readableState,ze=q._writableState,ye=ze||$e;$e&&($e.constructed=!0),ze&&(ze.constructed=!0),ye.destroyed?q.emit(f,re):re?F(q,re,!0):i.nextTick(O,q)}try{q._construct(re=>{i.nextTick(Te,re)})}catch(re){i.nextTick(Te,re)}}function O(q){q.emit(p)}function K(q){return q?.setHeader&&typeof q.abort=="function"}function z(q){q.emit("close")}function X(q,Y){q.emit("error",Y),i.nextTick(z,q)}function Ee(q,Y){!q||u(q)||(!Y&&!c(q)&&(Y=new n),h(q)?(q.socket=null,q.destroy(Y)):K(q)?q.abort():K(q.req)?q.req.abort():typeof q.destroy=="function"?q.destroy(Y):typeof q.close=="function"?q.close():Y?i.nextTick(X,q,Y):i.nextTick(z,q),q.destroyed||(q[a]=!0))}return destroy_1$1={construct:x,destroyer:Ee,destroy:y,undestroy:A,errorOrDestroy:F},destroy_1$1}var legacy$1,hasRequiredLegacy$1;function requireLegacy$1(){if(hasRequiredLegacy$1)return legacy$1;hasRequiredLegacy$1=1;const{ArrayIsArray:i,ObjectSetPrototypeOf:e}=requirePrimordials$1(),{EventEmitter:t}=requireEvents();function n(a){t.call(this,a)}e(n.prototype,t.prototype),e(n,t),n.prototype.pipe=function(a,u){const c=this;function h(R){a.writable&&a.write(R)===!1&&c.pause&&c.pause()}c.on("data",h);function f(){c.readable&&c.resume&&c.resume()}a.on("drain",f),!a._isStdio&&(!u||u.end!==!1)&&(c.on("end",g),c.on("close",y));let p=!1;function g(){p||(p=!0,a.end())}function y(){p||(p=!0,typeof a.destroy=="function"&&a.destroy())}function S(R){w(),t.listenerCount(this,"error")===0&&this.emit("error",R)}s(c,"error",S),s(a,"error",S);function w(){c.removeListener("data",h),a.removeListener("drain",f),c.removeListener("end",g),c.removeListener("close",y),c.removeListener("error",S),a.removeListener("error",S),c.removeListener("end",w),c.removeListener("close",w),a.removeListener("close",w)}return c.on("end",w),c.on("close",w),a.on("close",w),a.emit("pipe",c),a};function s(a,u,c){if(typeof a.prependListener=="function")return a.prependListener(u,c);!a._events||!a._events[u]?a.on(u,c):i(a._events[u])?a._events[u].unshift(c):a._events[u]=[c,a._events[u]]}return legacy$1={Stream:n,prependListener:s},legacy$1}var addAbortSignal$1={exports:{}},hasRequiredAddAbortSignal$1;function requireAddAbortSignal$1(){return hasRequiredAddAbortSignal$1||(hasRequiredAddAbortSignal$1=1,(function(i){const{SymbolDispose:e}=requirePrimordials$1(),{AbortError:t,codes:n}=requireErrors$1(),{isNodeStream:s,isWebStream:a,kControllerErrorFunction:u}=requireUtils$1(),c=requireEndOfStream$1(),{ERR_INVALID_ARG_TYPE:h}=n;let f;const p=(g,y)=>{if(typeof g!="object"||!("aborted"in g))throw new h(y,"AbortSignal",g)};i.exports.addAbortSignal=function(y,S){if(p(y,"signal"),!s(S)&&!a(S))throw new h("stream",["ReadableStream","WritableStream","Stream"],S);return i.exports.addAbortSignalNoValidate(y,S)},i.exports.addAbortSignalNoValidate=function(g,y){if(typeof g!="object"||!("aborted"in g))return y;const S=s(y)?()=>{y.destroy(new t(void 0,{cause:g.reason}))}:()=>{y[u](new t(void 0,{cause:g.reason}))};if(g.aborted)S();else{f=f||requireUtil$1().addAbortListener;const w=f(g,S);c(y,w[e])}return y}})(addAbortSignal$1)),addAbortSignal$1.exports}var buffer_list$1,hasRequiredBuffer_list$1;function requireBuffer_list$1(){if(hasRequiredBuffer_list$1)return buffer_list$1;hasRequiredBuffer_list$1=1;const{StringPrototypeSlice:i,SymbolIterator:e,TypedArrayPrototypeSet:t,Uint8Array:n}=requirePrimordials$1(),{Buffer:s}=requireBuffer(),{inspect:a}=requireUtil$1();return buffer_list$1=class{constructor(){this.head=null,this.tail=null,this.length=0}push(c){const h={data:c,next:null};this.length>0?this.tail.next=h:this.head=h,this.tail=h,++this.length}unshift(c){const h={data:c,next:this.head};this.length===0&&(this.tail=h),this.head=h,++this.length}shift(){if(this.length===0)return;const c=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,c}clear(){this.head=this.tail=null,this.length=0}join(c){if(this.length===0)return"";let h=this.head,f=""+h.data;for(;(h=h.next)!==null;)f+=c+h.data;return f}concat(c){if(this.length===0)return s.alloc(0);const h=s.allocUnsafe(c>>>0);let f=this.head,p=0;for(;f;)t(h,f.data,p),p+=f.data.length,f=f.next;return h}consume(c,h){const f=this.head.data;if(c<f.length){const p=f.slice(0,c);return this.head.data=f.slice(c),p}return c===f.length?this.shift():h?this._getString(c):this._getBuffer(c)}first(){return this.head.data}*[e](){for(let c=this.head;c;c=c.next)yield c.data}_getString(c){let h="",f=this.head,p=0;do{const g=f.data;if(c>g.length)h+=g,c-=g.length;else{c===g.length?(h+=g,++p,f.next?this.head=f.next:this.head=this.tail=null):(h+=i(g,0,c),this.head=f,f.data=i(g,c));break}++p}while((f=f.next)!==null);return this.length-=p,h}_getBuffer(c){const h=s.allocUnsafe(c),f=c;let p=this.head,g=0;do{const y=p.data;if(c>y.length)t(h,y,f-c),c-=y.length;else{c===y.length?(t(h,y,f-c),++g,p.next?this.head=p.next:this.head=this.tail=null):(t(h,new n(y.buffer,y.byteOffset,c),f-c),this.head=p,p.data=y.slice(c));break}++g}while((p=p.next)!==null);return this.length-=g,h}[Symbol.for("nodejs.util.inspect.custom")](c,h){return a(this,{...h,depth:0,customInspect:!1})}},buffer_list$1}var state$1,hasRequiredState$1;function requireState$1(){if(hasRequiredState$1)return state$1;hasRequiredState$1=1;const{MathFloor:i,NumberIsInteger:e}=requirePrimordials$1(),{validateInteger:t}=requireValidators$1(),{ERR_INVALID_ARG_VALUE:n}=requireErrors$1().codes;let s=16*1024,a=16;function u(p,g,y){return p.highWaterMark!=null?p.highWaterMark:g?p[y]:null}function c(p){return p?a:s}function h(p,g){t(g,"value",0),p?a=g:s=g}function f(p,g,y,S){const w=u(g,S,y);if(w!=null){if(!e(w)||w<0){const R=S?`options.${y}`:"options.highWaterMark";throw new n(R,w)}return i(w)}return c(p.objectMode)}return state$1={getHighWaterMark:f,getDefaultHighWaterMark:c,setDefaultHighWaterMark:h},state$1}var string_decoder={},safeBuffer={exports:{}};var hasRequiredSafeBuffer;function requireSafeBuffer(){return hasRequiredSafeBuffer||(hasRequiredSafeBuffer=1,(function(i,e){var t=requireBuffer(),n=t.Buffer;function s(u,c){for(var h in u)c[h]=u[h]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?i.exports=t:(s(t,e),e.Buffer=a);function a(u,c,h){return n(u,c,h)}a.prototype=Object.create(n.prototype),s(n,a),a.from=function(u,c,h){if(typeof u=="number")throw new TypeError("Argument must not be a number");return n(u,c,h)},a.alloc=function(u,c,h){if(typeof u!="number")throw new TypeError("Argument must be a number");var f=n(u);return c!==void 0?typeof h=="string"?f.fill(c,h):f.fill(c):f.fill(0),f},a.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return n(u)},a.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(u)}})(safeBuffer,safeBuffer.exports)),safeBuffer.exports}var hasRequiredString_decoder;function requireString_decoder(){if(hasRequiredString_decoder)return string_decoder;hasRequiredString_decoder=1;var i=requireSafeBuffer().Buffer,e=i.isEncoding||function(A){switch(A=""+A,A&&A.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function t(A){if(!A)return"utf8";for(var F;;)switch(A){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return A;default:if(F)return;A=(""+A).toLowerCase(),F=!0}}function n(A){var F=t(A);if(typeof F!="string"&&(i.isEncoding===e||!e(A)))throw new Error("Unknown encoding: "+A);return F||A}string_decoder.StringDecoder=s;function s(A){this.encoding=n(A);var F;switch(this.encoding){case"utf16le":this.text=g,this.end=y,F=4;break;case"utf8":this.fillLast=h,F=4;break;case"base64":this.text=S,this.end=w,F=3;break;default:this.write=R,this.end=T;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(F)}s.prototype.write=function(A){if(A.length===0)return"";var F,x;if(this.lastNeed){if(F=this.fillLast(A),F===void 0)return"";x=this.lastNeed,this.lastNeed=0}else x=0;return x<A.length?F?F+this.text(A,x):this.text(A,x):F||""},s.prototype.end=p,s.prototype.text=f,s.prototype.fillLast=function(A){if(this.lastNeed<=A.length)return A.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);A.copy(this.lastChar,this.lastTotal-this.lastNeed,0,A.length),this.lastNeed-=A.length};function a(A){return A<=127?0:A>>5===6?2:A>>4===14?3:A>>3===30?4:A>>6===2?-1:-2}function u(A,F,x){var D=F.length-1;if(D<x)return 0;var O=a(F[D]);return O>=0?(O>0&&(A.lastNeed=O-1),O):--D<x||O===-2?0:(O=a(F[D]),O>=0?(O>0&&(A.lastNeed=O-2),O):--D<x||O===-2?0:(O=a(F[D]),O>=0?(O>0&&(O===2?O=0:A.lastNeed=O-3),O):0))}function c(A,F,x){if((F[0]&192)!==128)return A.lastNeed=0,"�";if(A.lastNeed>1&&F.length>1){if((F[1]&192)!==128)return A.lastNeed=1,"�";if(A.lastNeed>2&&F.length>2&&(F[2]&192)!==128)return A.lastNeed=2,"�"}}function h(A){var F=this.lastTotal-this.lastNeed,x=c(this,A);if(x!==void 0)return x;if(this.lastNeed<=A.length)return A.copy(this.lastChar,F,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);A.copy(this.lastChar,F,0,A.length),this.lastNeed-=A.length}function f(A,F){var x=u(this,A,F);if(!this.lastNeed)return A.toString("utf8",F);this.lastTotal=x;var D=A.length-(x-this.lastNeed);return A.copy(this.lastChar,0,D),A.toString("utf8",F,D)}function p(A){var F=A&&A.length?this.write(A):"";return this.lastNeed?F+"�":F}function g(A,F){if((A.length-F)%2===0){var x=A.toString("utf16le",F);if(x){var D=x.charCodeAt(x.length-1);if(D>=55296&&D<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=A[A.length-2],this.lastChar[1]=A[A.length-1],x.slice(0,-1)}return x}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=A[A.length-1],A.toString("utf16le",F,A.length-1)}function y(A){var F=A&&A.length?this.write(A):"";if(this.lastNeed){var x=this.lastTotal-this.lastNeed;return F+this.lastChar.toString("utf16le",0,x)}return F}function S(A,F){var x=(A.length-F)%3;return x===0?A.toString("base64",F):(this.lastNeed=3-x,this.lastTotal=3,x===1?this.lastChar[0]=A[A.length-1]:(this.lastChar[0]=A[A.length-2],this.lastChar[1]=A[A.length-1]),A.toString("base64",F,A.length-x))}function w(A){var F=A&&A.length?this.write(A):"";return this.lastNeed?F+this.lastChar.toString("base64",0,3-this.lastNeed):F}function R(A){return A.toString(this.encoding)}function T(A){return A&&A.length?this.write(A):""}return string_decoder}var from_1$1,hasRequiredFrom$1;function requireFrom$1(){if(hasRequiredFrom$1)return from_1$1;hasRequiredFrom$1=1;const i=requireBrowser$2(),{PromisePrototypeThen:e,SymbolAsyncIterator:t,SymbolIterator:n}=requirePrimordials$1(),{Buffer:s}=requireBuffer(),{ERR_INVALID_ARG_TYPE:a,ERR_STREAM_NULL_VALUES:u}=requireErrors$1().codes;function c(h,f,p){let g;if(typeof f=="string"||f instanceof s)return new h({objectMode:!0,...p,read(){this.push(f),this.push(null)}});let y;if(f&&f[t])y=!0,g=f[t]();else if(f&&f[n])y=!1,g=f[n]();else throw new a("iterable",["Iterable"],f);const S=new h({objectMode:!0,highWaterMark:1,...p});let w=!1;S._read=function(){w||(w=!0,T())},S._destroy=function(A,F){e(R(A),()=>i.nextTick(F,A),x=>i.nextTick(F,x||A))};async function R(A){const F=A!=null,x=typeof g.throw=="function";if(F&&x){const{value:D,done:O}=await g.throw(A);if(await D,O)return}if(typeof g.return=="function"){const{value:D}=await g.return();await D}}async function T(){for(;;){try{const{value:A,done:F}=y?await g.next():g.next();if(F)S.push(null);else{const x=A&&typeof A.then=="function"?await A:A;if(x===null)throw w=!1,new u;if(S.push(x))continue;w=!1}}catch(A){S.destroy(A)}break}}return S}return from_1$1=c,from_1$1}var readable$1,hasRequiredReadable$1;function requireReadable$1(){if(hasRequiredReadable$1)return readable$1;hasRequiredReadable$1=1;const i=requireBrowser$2(),{ArrayPrototypeIndexOf:e,NumberIsInteger:t,NumberIsNaN:n,NumberParseInt:s,ObjectDefineProperties:a,ObjectKeys:u,ObjectSetPrototypeOf:c,Promise:h,SafeSet:f,SymbolAsyncDispose:p,SymbolAsyncIterator:g,Symbol:y}=requirePrimordials$1();readable$1=de,de.ReadableState=xe;const{EventEmitter:S}=requireEvents(),{Stream:w,prependListener:R}=requireLegacy$1(),{Buffer:T}=requireBuffer(),{addAbortSignal:A}=requireAddAbortSignal$1(),F=requireEndOfStream$1();let x=requireUtil$1().debuglog("stream",M=>{x=M});const D=requireBuffer_list$1(),O=requireDestroy$1(),{getHighWaterMark:K,getDefaultHighWaterMark:z}=requireState$1(),{aggregateTwoErrors:X,codes:{ERR_INVALID_ARG_TYPE:Ee,ERR_METHOD_NOT_IMPLEMENTED:q,ERR_OUT_OF_RANGE:Y,ERR_STREAM_PUSH_AFTER_EOF:Te,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:re},AbortError:$e}=requireErrors$1(),{validateObject:ze}=requireValidators$1(),ye=y("kPaused"),{StringDecoder:Ve}=requireString_decoder(),pe=requireFrom$1();c(de.prototype,w.prototype),c(de,w);const De=()=>{},{errorOrDestroy:$}=O,G=1,ce=2,oe=4,Fe=8,Ue=16,Je=32,He=64,he=128,fe=256,Oe=512,ie=1024,j=2048,N=4096,L=8192,V=16384,ee=32768,ae=65536,ve=1<<17,J=1<<18;function me(M){return{enumerable:!1,get(){return(this.state&M)!==0},set(H){H?this.state|=M:this.state&=~M}}}a(xe.prototype,{objectMode:me(G),ended:me(ce),endEmitted:me(oe),reading:me(Fe),constructed:me(Ue),sync:me(Je),needReadable:me(He),emittedReadable:me(he),readableListening:me(fe),resumeScheduled:me(Oe),errorEmitted:me(ie),emitClose:me(j),autoDestroy:me(N),destroyed:me(L),closed:me(V),closeEmitted:me(ee),multiAwaitDrain:me(ae),readingMore:me(ve),dataEmitted:me(J)});function xe(M,H,Be){typeof Be!="boolean"&&(Be=H instanceof requireDuplex$1()),this.state=j|N|Ue|Je,M&&M.objectMode&&(this.state|=G),Be&&M&&M.readableObjectMode&&(this.state|=G),this.highWaterMark=M?K(this,M,"readableHighWaterMark",Be):z(!1),this.buffer=new D,this.length=0,this.pipes=[],this.flowing=null,this[ye]=null,M&&M.emitClose===!1&&(this.state&=~j),M&&M.autoDestroy===!1&&(this.state&=~N),this.errored=null,this.defaultEncoding=M&&M.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,M&&M.encoding&&(this.decoder=new Ve(M.encoding),this.encoding=M.encoding)}function de(M){if(!(this instanceof de))return new de(M);const H=this instanceof requireDuplex$1();this._readableState=new xe(M,this,H),M&&(typeof M.read=="function"&&(this._read=M.read),typeof M.destroy=="function"&&(this._destroy=M.destroy),typeof M.construct=="function"&&(this._construct=M.construct),M.signal&&!H&&A(M.signal,this)),w.call(this,M),O.construct(this,()=>{this._readableState.needReadable&&Ie(this,this._readableState)})}de.prototype.destroy=O.destroy,de.prototype._undestroy=O.undestroy,de.prototype._destroy=function(M,H){H(M)},de.prototype[S.captureRejectionSymbol]=function(M){this.destroy(M)},de.prototype[p]=function(){let M;return this.destroyed||(M=this.readableEnded?null:new $e,this.destroy(M)),new h((H,Be)=>F(this,qe=>qe&&qe!==M?Be(qe):H(null)))},de.prototype.push=function(M,H){return st(this,M,H,!1)},de.prototype.unshift=function(M,H){return st(this,M,H,!0)};function st(M,H,Be,qe){x("readableAddChunk",H);const at=M._readableState;let Ut;if((at.state&G)===0&&(typeof H=="string"?(Be=Be||at.defaultEncoding,at.encoding!==Be&&(qe&&at.encoding?H=T.from(H,Be).toString(at.encoding):(H=T.from(H,Be),Be=""))):H instanceof T?Be="":w._isUint8Array(H)?(H=w._uint8ArrayToBuffer(H),Be=""):H!=null&&(Ut=new Ee("chunk",["string","Buffer","Uint8Array"],H))),Ut)$(M,Ut);else if(H===null)at.state&=~Fe,P(M,at);else if((at.state&G)!==0||H&&H.length>0)if(qe)if((at.state&oe)!==0)$(M,new re);else{if(at.destroyed||at.errored)return!1;ft(M,at,H,!0)}else if(at.ended)$(M,new Te);else{if(at.destroyed||at.errored)return!1;at.state&=~Fe,at.decoder&&!Be?(H=at.decoder.write(H),at.objectMode||H.length!==0?ft(M,at,H,!1):Ie(M,at)):ft(M,at,H,!1)}else qe||(at.state&=~Fe,Ie(M,at));return!at.ended&&(at.length<at.highWaterMark||at.length===0)}function ft(M,H,Be,qe){H.flowing&&H.length===0&&!H.sync&&M.listenerCount("data")>0?((H.state&ae)!==0?H.awaitDrainWriters.clear():H.awaitDrainWriters=null,H.dataEmitted=!0,M.emit("data",Be)):(H.length+=H.objectMode?1:Be.length,qe?H.buffer.unshift(Be):H.buffer.push(Be),(H.state&He)!==0&&B(M)),Ie(M,H)}de.prototype.isPaused=function(){const M=this._readableState;return M[ye]===!0||M.flowing===!1},de.prototype.setEncoding=function(M){const H=new Ve(M);this._readableState.decoder=H,this._readableState.encoding=this._readableState.decoder.encoding;const Be=this._readableState.buffer;let qe="";for(const at of Be)qe+=H.write(at);return Be.clear(),qe!==""&&Be.push(qe),this._readableState.length=qe.length,this};const Ge=1073741824;function pt(M){if(M>Ge)throw new Y("size","<= 1GiB",M);return M--,M|=M>>>1,M|=M>>>2,M|=M>>>4,M|=M>>>8,M|=M>>>16,M++,M}function Z(M,H){return M<=0||H.length===0&&H.ended?0:(H.state&G)!==0?1:n(M)?H.flowing&&H.length?H.buffer.first().length:H.length:M<=H.length?M:H.ended?H.length:0}de.prototype.read=function(M){x("read",M),M===void 0?M=NaN:t(M)||(M=s(M,10));const H=this._readableState,Be=M;if(M>H.highWaterMark&&(H.highWaterMark=pt(M)),M!==0&&(H.state&=~he),M===0&&H.needReadable&&((H.highWaterMark!==0?H.length>=H.highWaterMark:H.length>0)||H.ended))return x("read: emitReadable",H.length,H.ended),H.length===0&&H.ended?vr(this):B(this),null;if(M=Z(M,H),M===0&&H.ended)return H.length===0&&vr(this),null;let qe=(H.state&He)!==0;if(x("need readable",qe),(H.length===0||H.length-M<H.highWaterMark)&&(qe=!0,x("length less than watermark",qe)),H.ended||H.reading||H.destroyed||H.errored||!H.constructed)qe=!1,x("reading, ended or constructing",qe);else if(qe){x("do read"),H.state|=Fe|Je,H.length===0&&(H.state|=He);try{this._read(H.highWaterMark)}catch(Ut){$(this,Ut)}H.state&=~Je,H.reading||(M=Z(Be,H))}let at;return M>0?at=Dt(M,H):at=null,at===null?(H.needReadable=H.length<=H.highWaterMark,M=0):(H.length-=M,H.multiAwaitDrain?H.awaitDrainWriters.clear():H.awaitDrainWriters=null),H.length===0&&(H.ended||(H.needReadable=!0),Be!==M&&H.ended&&vr(this)),at!==null&&!H.errorEmitted&&!H.closeEmitted&&(H.dataEmitted=!0,this.emit("data",at)),at};function P(M,H){if(x("onEofChunk"),!H.ended){if(H.decoder){const Be=H.decoder.end();Be&&Be.length&&(H.buffer.push(Be),H.length+=H.objectMode?1:Be.length)}H.ended=!0,H.sync?B(M):(H.needReadable=!1,H.emittedReadable=!0,U(M))}}function B(M){const H=M._readableState;x("emitReadable",H.needReadable,H.emittedReadable),H.needReadable=!1,H.emittedReadable||(x("emitReadable",H.flowing),H.emittedReadable=!0,i.nextTick(U,M))}function U(M){const H=M._readableState;x("emitReadable_",H.destroyed,H.length,H.ended),!H.destroyed&&!H.errored&&(H.length||H.ended)&&(M.emit("readable"),H.emittedReadable=!1),H.needReadable=!H.flowing&&!H.ended&&H.length<=H.highWaterMark,Ft(M)}function Ie(M,H){!H.readingMore&&H.constructed&&(H.readingMore=!0,i.nextTick(Me,M,H))}function Me(M,H){for(;!H.reading&&!H.ended&&(H.length<H.highWaterMark||H.flowing&&H.length===0);){const Be=H.length;if(x("maybeReadMore read 0"),M.read(0),Be===H.length)break}H.readingMore=!1}de.prototype._read=function(M){throw new q("_read()")},de.prototype.pipe=function(M,H){const Be=this,qe=this._readableState;qe.pipes.length===1&&(qe.multiAwaitDrain||(qe.multiAwaitDrain=!0,qe.awaitDrainWriters=new f(qe.awaitDrainWriters?[qe.awaitDrainWriters]:[]))),qe.pipes.push(M),x("pipe count=%d opts=%j",qe.pipes.length,H);const Ut=(!H||H.end!==!1)&&M!==i.stdout&&M!==i.stderr?on:Lt;qe.endEmitted?i.nextTick(Ut):Be.once("end",Ut),M.on("unpipe",Ht);function Ht(Rt,hr){x("onunpipe"),Rt===Be&&hr&&hr.hasUnpiped===!1&&(hr.hasUnpiped=!0,bn())}function on(){x("onend"),M.end()}let Sr,sr=!1;function bn(){x("cleanup"),M.removeListener("close",Dr),M.removeListener("finish",Mr),Sr&&M.removeListener("drain",Sr),M.removeListener("error",fr),M.removeListener("unpipe",Ht),Be.removeListener("end",on),Be.removeListener("end",Lt),Be.removeListener("data",qt),sr=!0,Sr&&qe.awaitDrainWriters&&(!M._writableState||M._writableState.needDrain)&&Sr()}function Hr(){sr||(qe.pipes.length===1&&qe.pipes[0]===M?(x("false write response, pause",0),qe.awaitDrainWriters=M,qe.multiAwaitDrain=!1):qe.pipes.length>1&&qe.pipes.includes(M)&&(x("false write response, pause",qe.awaitDrainWriters.size),qe.awaitDrainWriters.add(M)),Be.pause()),Sr||(Sr=Pe(Be,M),M.on("drain",Sr))}Be.on("data",qt);function qt(Rt){x("ondata");const hr=M.write(Rt);x("dest.write",hr),hr===!1&&Hr()}function fr(Rt){if(x("onerror",Rt),Lt(),M.removeListener("error",fr),M.listenerCount("error")===0){const hr=M._writableState||M._readableState;hr&&!hr.errorEmitted?$(M,Rt):M.emit("error",Rt)}}R(M,"error",fr);function Dr(){M.removeListener("finish",Mr),Lt()}M.once("close",Dr);function Mr(){x("onfinish"),M.removeListener("close",Dr),Lt()}M.once("finish",Mr);function Lt(){x("unpipe"),Be.unpipe(M)}return M.emit("pipe",Be),M.writableNeedDrain===!0?Hr():qe.flowing||(x("pipe resume"),Be.resume()),M};function Pe(M,H){return function(){const qe=M._readableState;qe.awaitDrainWriters===H?(x("pipeOnDrain",1),qe.awaitDrainWriters=null):qe.multiAwaitDrain&&(x("pipeOnDrain",qe.awaitDrainWriters.size),qe.awaitDrainWriters.delete(H)),(!qe.awaitDrainWriters||qe.awaitDrainWriters.size===0)&&M.listenerCount("data")&&M.resume()}}de.prototype.unpipe=function(M){const H=this._readableState,Be={hasUnpiped:!1};if(H.pipes.length===0)return this;if(!M){const at=H.pipes;H.pipes=[],this.pause();for(let Ut=0;Ut<at.length;Ut++)at[Ut].emit("unpipe",this,{hasUnpiped:!1});return this}const qe=e(H.pipes,M);return qe===-1?this:(H.pipes.splice(qe,1),H.pipes.length===0&&this.pause(),M.emit("unpipe",this,Be),this)},de.prototype.on=function(M,H){const Be=w.prototype.on.call(this,M,H),qe=this._readableState;return M==="data"?(qe.readableListening=this.listenerCount("readable")>0,qe.flowing!==!1&&this.resume()):M==="readable"&&!qe.endEmitted&&!qe.readableListening&&(qe.readableListening=qe.needReadable=!0,qe.flowing=!1,qe.emittedReadable=!1,x("on readable",qe.length,qe.reading),qe.length?B(this):qe.reading||i.nextTick(_t,this)),Be},de.prototype.addListener=de.prototype.on,de.prototype.removeListener=function(M,H){const Be=w.prototype.removeListener.call(this,M,H);return M==="readable"&&i.nextTick(gt,this),Be},de.prototype.off=de.prototype.removeListener,de.prototype.removeAllListeners=function(M){const H=w.prototype.removeAllListeners.apply(this,arguments);return(M==="readable"||M===void 0)&&i.nextTick(gt,this),H};function gt(M){const H=M._readableState;H.readableListening=M.listenerCount("readable")>0,H.resumeScheduled&&H[ye]===!1?H.flowing=!0:M.listenerCount("data")>0?M.resume():H.readableListening||(H.flowing=null)}function _t(M){x("readable nexttick read 0"),M.read(0)}de.prototype.resume=function(){const M=this._readableState;return M.flowing||(x("resume"),M.flowing=!M.readableListening,Tt(this,M)),M[ye]=!1,this};function Tt(M,H){H.resumeScheduled||(H.resumeScheduled=!0,i.nextTick(kt,M,H))}function kt(M,H){x("resume",H.reading),H.reading||M.read(0),H.resumeScheduled=!1,M.emit("resume"),Ft(M),H.flowing&&!H.reading&&M.read(0)}de.prototype.pause=function(){return x("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(x("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[ye]=!0,this};function Ft(M){const H=M._readableState;for(x("flow",H.flowing);H.flowing&&M.read()!==null;);}de.prototype.wrap=function(M){let H=!1;M.on("data",qe=>{!this.push(qe)&&M.pause&&(H=!0,M.pause())}),M.on("end",()=>{this.push(null)}),M.on("error",qe=>{$(this,qe)}),M.on("close",()=>{this.destroy()}),M.on("destroy",()=>{this.destroy()}),this._read=()=>{H&&M.resume&&(H=!1,M.resume())};const Be=u(M);for(let qe=1;qe<Be.length;qe++){const at=Be[qe];this[at]===void 0&&typeof M[at]=="function"&&(this[at]=M[at].bind(M))}return this},de.prototype[g]=function(){return sn(this)},de.prototype.iterator=function(M){return M!==void 0&&ze(M,"options"),sn(this,M)};function sn(M,H){typeof M.read!="function"&&(M=de.wrap(M,{objectMode:!0}));const Be=Yt(M,H);return Be.stream=M,Be}async function*Yt(M,H){let Be=De;function qe(Ht){this===M?(Be(),Be=De):Be=Ht}M.on("readable",qe);let at;const Ut=F(M,{writable:!1},Ht=>{at=Ht?X(at,Ht):null,Be(),Be=De});try{for(;;){const Ht=M.destroyed?null:M.read();if(Ht!==null)yield Ht;else{if(at)throw at;if(at===null)return;await new h(qe)}}}catch(Ht){throw at=X(at,Ht),at}finally{(at||H?.destroyOnReturn!==!1)&&(at===void 0||M._readableState.autoDestroy)?O.destroyer(M,null):(M.off("readable",qe),Ut())}}a(de.prototype,{readable:{__proto__:null,get(){const M=this._readableState;return!!M&&M.readable!==!1&&!M.destroyed&&!M.errorEmitted&&!M.endEmitted},set(M){this._readableState&&(this._readableState.readable=!!M)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(M){this._readableState&&(this._readableState.flowing=M)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(M){this._readableState&&(this._readableState.destroyed=M)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),a(xe.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[ye]!==!1},set(M){this[ye]=!!M}}}),de._fromList=Dt;function Dt(M,H){if(H.length===0)return null;let Be;return H.objectMode?Be=H.buffer.shift():!M||M>=H.length?(H.decoder?Be=H.buffer.join(""):H.buffer.length===1?Be=H.buffer.first():Be=H.buffer.concat(H.length),H.buffer.clear()):Be=H.buffer.consume(M,H.decoder),Be}function vr(M){const H=M._readableState;x("endReadable",H.endEmitted),H.endEmitted||(H.ended=!0,i.nextTick(Bt,H,M))}function Bt(M,H){if(x("endReadableNT",M.endEmitted,M.length),!M.errored&&!M.closeEmitted&&!M.endEmitted&&M.length===0){if(M.endEmitted=!0,H.emit("end"),H.writable&&H.allowHalfOpen===!1)i.nextTick(dr,H);else if(M.autoDestroy){const Be=H._writableState;(!Be||Be.autoDestroy&&(Be.finished||Be.writable===!1))&&H.destroy()}}}function dr(M){M.writable&&!M.writableEnded&&!M.destroyed&&M.end()}de.from=function(M,H){return pe(de,M,H)};let nr;function Vr(){return nr===void 0&&(nr={}),nr}return de.fromWeb=function(M,H){return Vr().newStreamReadableFromReadableStream(M,H)},de.toWeb=function(M,H){return Vr().newReadableStreamFromStreamReadable(M,H)},de.wrap=function(M,H){var Be,qe;return new de({objectMode:(Be=(qe=M.readableObjectMode)!==null&&qe!==void 0?qe:M.objectMode)!==null&&Be!==void 0?Be:!0,...H,destroy(at,Ut){O.destroyer(M,at),Ut(at)}}).wrap(M)},readable$1}var writable$1,hasRequiredWritable$1;function requireWritable$1(){if(hasRequiredWritable$1)return writable$1;hasRequiredWritable$1=1;const i=requireBrowser$2(),{ArrayPrototypeSlice:e,Error:t,FunctionPrototypeSymbolHasInstance:n,ObjectDefineProperty:s,ObjectDefineProperties:a,ObjectSetPrototypeOf:u,StringPrototypeToLowerCase:c,Symbol:h,SymbolHasInstance:f}=requirePrimordials$1();writable$1=ze,ze.WritableState=re;const{EventEmitter:p}=requireEvents(),g=requireLegacy$1().Stream,{Buffer:y}=requireBuffer(),S=requireDestroy$1(),{addAbortSignal:w}=requireAddAbortSignal$1(),{getHighWaterMark:R,getDefaultHighWaterMark:T}=requireState$1(),{ERR_INVALID_ARG_TYPE:A,ERR_METHOD_NOT_IMPLEMENTED:F,ERR_MULTIPLE_CALLBACK:x,ERR_STREAM_CANNOT_PIPE:D,ERR_STREAM_DESTROYED:O,ERR_STREAM_ALREADY_FINISHED:K,ERR_STREAM_NULL_VALUES:z,ERR_STREAM_WRITE_AFTER_END:X,ERR_UNKNOWN_ENCODING:Ee}=requireErrors$1().codes,{errorOrDestroy:q}=S;u(ze.prototype,g.prototype),u(ze,g);function Y(){}const Te=h("kOnFinished");function re(N,L,V){typeof V!="boolean"&&(V=L instanceof requireDuplex$1()),this.objectMode=!!(N&&N.objectMode),V&&(this.objectMode=this.objectMode||!!(N&&N.writableObjectMode)),this.highWaterMark=N?R(this,N,"writableHighWaterMark",V):T(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const ee=!!(N&&N.decodeStrings===!1);this.decodeStrings=!ee,this.defaultEncoding=N&&N.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=$.bind(void 0,L),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,$e(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!N||N.emitClose!==!1,this.autoDestroy=!N||N.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[Te]=[]}function $e(N){N.buffered=[],N.bufferedIndex=0,N.allBuffers=!0,N.allNoop=!0}re.prototype.getBuffer=function(){return e(this.buffered,this.bufferedIndex)},s(re.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function ze(N){const L=this instanceof requireDuplex$1();if(!L&&!n(ze,this))return new ze(N);this._writableState=new re(N,this,L),N&&(typeof N.write=="function"&&(this._write=N.write),typeof N.writev=="function"&&(this._writev=N.writev),typeof N.destroy=="function"&&(this._destroy=N.destroy),typeof N.final=="function"&&(this._final=N.final),typeof N.construct=="function"&&(this._construct=N.construct),N.signal&&w(N.signal,this)),g.call(this,N),S.construct(this,()=>{const V=this._writableState;V.writing||Fe(this,V),he(this,V)})}s(ze,f,{__proto__:null,value:function(N){return n(this,N)?!0:this!==ze?!1:N&&N._writableState instanceof re}}),ze.prototype.pipe=function(){q(this,new D)};function ye(N,L,V,ee){const ae=N._writableState;if(typeof V=="function")ee=V,V=ae.defaultEncoding;else{if(!V)V=ae.defaultEncoding;else if(V!=="buffer"&&!y.isEncoding(V))throw new Ee(V);typeof ee!="function"&&(ee=Y)}if(L===null)throw new z;if(!ae.objectMode)if(typeof L=="string")ae.decodeStrings!==!1&&(L=y.from(L,V),V="buffer");else if(L instanceof y)V="buffer";else if(g._isUint8Array(L))L=g._uint8ArrayToBuffer(L),V="buffer";else throw new A("chunk",["string","Buffer","Uint8Array"],L);let ve;return ae.ending?ve=new X:ae.destroyed&&(ve=new O("write")),ve?(i.nextTick(ee,ve),q(N,ve,!0),ve):(ae.pendingcb++,Ve(N,ae,L,V,ee))}ze.prototype.write=function(N,L,V){return ye(this,N,L,V)===!0},ze.prototype.cork=function(){this._writableState.corked++},ze.prototype.uncork=function(){const N=this._writableState;N.corked&&(N.corked--,N.writing||Fe(this,N))},ze.prototype.setDefaultEncoding=function(L){if(typeof L=="string"&&(L=c(L)),!y.isEncoding(L))throw new Ee(L);return this._writableState.defaultEncoding=L,this};function Ve(N,L,V,ee,ae){const ve=L.objectMode?1:V.length;L.length+=ve;const J=L.length<L.highWaterMark;return J||(L.needDrain=!0),L.writing||L.corked||L.errored||!L.constructed?(L.buffered.push({chunk:V,encoding:ee,callback:ae}),L.allBuffers&&ee!=="buffer"&&(L.allBuffers=!1),L.allNoop&&ae!==Y&&(L.allNoop=!1)):(L.writelen=ve,L.writecb=ae,L.writing=!0,L.sync=!0,N._write(V,ee,L.onwrite),L.sync=!1),J&&!L.errored&&!L.destroyed}function pe(N,L,V,ee,ae,ve,J){L.writelen=ee,L.writecb=J,L.writing=!0,L.sync=!0,L.destroyed?L.onwrite(new O("write")):V?N._writev(ae,L.onwrite):N._write(ae,ve,L.onwrite),L.sync=!1}function De(N,L,V,ee){--L.pendingcb,ee(V),oe(L),q(N,V)}function $(N,L){const V=N._writableState,ee=V.sync,ae=V.writecb;if(typeof ae!="function"){q(N,new x);return}V.writing=!1,V.writecb=null,V.length-=V.writelen,V.writelen=0,L?(L.stack,V.errored||(V.errored=L),N._readableState&&!N._readableState.errored&&(N._readableState.errored=L),ee?i.nextTick(De,N,V,L,ae):De(N,V,L,ae)):(V.buffered.length>V.bufferedIndex&&Fe(N,V),ee?V.afterWriteTickInfo!==null&&V.afterWriteTickInfo.cb===ae?V.afterWriteTickInfo.count++:(V.afterWriteTickInfo={count:1,cb:ae,stream:N,state:V},i.nextTick(G,V.afterWriteTickInfo)):ce(N,V,1,ae))}function G({stream:N,state:L,count:V,cb:ee}){return L.afterWriteTickInfo=null,ce(N,L,V,ee)}function ce(N,L,V,ee){for(!L.ending&&!N.destroyed&&L.length===0&&L.needDrain&&(L.needDrain=!1,N.emit("drain"));V-- >0;)L.pendingcb--,ee();L.destroyed&&oe(L),he(N,L)}function oe(N){if(N.writing)return;for(let ae=N.bufferedIndex;ae<N.buffered.length;++ae){var L;const{chunk:ve,callback:J}=N.buffered[ae],me=N.objectMode?1:ve.length;N.length-=me,J((L=N.errored)!==null&&L!==void 0?L:new O("write"))}const V=N[Te].splice(0);for(let ae=0;ae<V.length;ae++){var ee;V[ae]((ee=N.errored)!==null&&ee!==void 0?ee:new O("end"))}$e(N)}function Fe(N,L){if(L.corked||L.bufferProcessing||L.destroyed||!L.constructed)return;const{buffered:V,bufferedIndex:ee,objectMode:ae}=L,ve=V.length-ee;if(!ve)return;let J=ee;if(L.bufferProcessing=!0,ve>1&&N._writev){L.pendingcb-=ve-1;const me=L.allNoop?Y:de=>{for(let st=J;st<V.length;++st)V[st].callback(de)},xe=L.allNoop&&J===0?V:e(V,J);xe.allBuffers=L.allBuffers,pe(N,L,!0,L.length,xe,"",me),$e(L)}else{do{const{chunk:me,encoding:xe,callback:de}=V[J];V[J++]=null;const st=ae?1:me.length;pe(N,L,!1,st,me,xe,de)}while(J<V.length&&!L.writing);J===V.length?$e(L):J>256?(V.splice(0,J),L.bufferedIndex=0):L.bufferedIndex=J}L.bufferProcessing=!1}ze.prototype._write=function(N,L,V){if(this._writev)this._writev([{chunk:N,encoding:L}],V);else throw new F("_write()")},ze.prototype._writev=null,ze.prototype.end=function(N,L,V){const ee=this._writableState;typeof N=="function"?(V=N,N=null,L=null):typeof L=="function"&&(V=L,L=null);let ae;if(N!=null){const ve=ye(this,N,L);ve instanceof t&&(ae=ve)}return ee.corked&&(ee.corked=1,this.uncork()),ae||(!ee.errored&&!ee.ending?(ee.ending=!0,he(this,ee,!0),ee.ended=!0):ee.finished?ae=new K("end"):ee.destroyed&&(ae=new O("end"))),typeof V=="function"&&(ae||ee.finished?i.nextTick(V,ae):ee[Te].push(V)),this};function Ue(N){return N.ending&&!N.destroyed&&N.constructed&&N.length===0&&!N.errored&&N.buffered.length===0&&!N.finished&&!N.writing&&!N.errorEmitted&&!N.closeEmitted}function Je(N,L){let V=!1;function ee(ae){if(V){q(N,ae??x());return}if(V=!0,L.pendingcb--,ae){const ve=L[Te].splice(0);for(let J=0;J<ve.length;J++)ve[J](ae);q(N,ae,L.sync)}else Ue(L)&&(L.prefinished=!0,N.emit("prefinish"),L.pendingcb++,i.nextTick(fe,N,L))}L.sync=!0,L.pendingcb++;try{N._final(ee)}catch(ae){ee(ae)}L.sync=!1}function He(N,L){!L.prefinished&&!L.finalCalled&&(typeof N._final=="function"&&!L.destroyed?(L.finalCalled=!0,Je(N,L)):(L.prefinished=!0,N.emit("prefinish")))}function he(N,L,V){Ue(L)&&(He(N,L),L.pendingcb===0&&(V?(L.pendingcb++,i.nextTick((ee,ae)=>{Ue(ae)?fe(ee,ae):ae.pendingcb--},N,L)):Ue(L)&&(L.pendingcb++,fe(N,L))))}function fe(N,L){L.pendingcb--,L.finished=!0;const V=L[Te].splice(0);for(let ee=0;ee<V.length;ee++)V[ee]();if(N.emit("finish"),L.autoDestroy){const ee=N._readableState;(!ee||ee.autoDestroy&&(ee.endEmitted||ee.readable===!1))&&N.destroy()}}a(ze.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(N){this._writableState&&(this._writableState.destroyed=N)}},writable:{__proto__:null,get(){const N=this._writableState;return!!N&&N.writable!==!1&&!N.destroyed&&!N.errored&&!N.ending&&!N.ended},set(N){this._writableState&&(this._writableState.writable=!!N)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){const N=this._writableState;return N?!N.destroyed&&!N.ending&&N.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});const Oe=S.destroy;ze.prototype.destroy=function(N,L){const V=this._writableState;return!V.destroyed&&(V.bufferedIndex<V.buffered.length||V[Te].length)&&i.nextTick(oe,V),Oe.call(this,N,L),this},ze.prototype._undestroy=S.undestroy,ze.prototype._destroy=function(N,L){L(N)},ze.prototype[p.captureRejectionSymbol]=function(N){this.destroy(N)};let ie;function j(){return ie===void 0&&(ie={}),ie}return ze.fromWeb=function(N,L){return j().newStreamWritableFromWritableStream(N,L)},ze.toWeb=function(N){return j().newWritableStreamFromStreamWritable(N)},writable$1}var duplexify$1,hasRequiredDuplexify$1;function requireDuplexify$1(){if(hasRequiredDuplexify$1)return duplexify$1;hasRequiredDuplexify$1=1;const i=requireBrowser$2(),e=requireBuffer(),{isReadable:t,isWritable:n,isIterable:s,isNodeStream:a,isReadableNodeStream:u,isWritableNodeStream:c,isDuplexNodeStream:h,isReadableStream:f,isWritableStream:p}=requireUtils$1(),g=requireEndOfStream$1(),{AbortError:y,codes:{ERR_INVALID_ARG_TYPE:S,ERR_INVALID_RETURN_VALUE:w}}=requireErrors$1(),{destroyer:R}=requireDestroy$1(),T=requireDuplex$1(),A=requireReadable$1(),F=requireWritable$1(),{createDeferredPromise:x}=requireUtil$1(),D=requireFrom$1(),O=globalThis.Blob||e.Blob,K=typeof O<"u"?function(re){return re instanceof O}:function(re){return!1},z=globalThis.AbortController||requireBrowser$3().AbortController,{FunctionPrototypeCall:X}=requirePrimordials$1();class Ee extends T{constructor(re){super(re),re?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),re?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}duplexify$1=function Te(re,$e){if(h(re))return re;if(u(re))return Y({readable:re});if(c(re))return Y({writable:re});if(a(re))return Y({writable:!1,readable:!1});if(f(re))return Y({readable:A.fromWeb(re)});if(p(re))return Y({writable:F.fromWeb(re)});if(typeof re=="function"){const{value:ye,write:Ve,final:pe,destroy:De}=q(re);if(s(ye))return D(Ee,ye,{objectMode:!0,write:Ve,final:pe,destroy:De});const $=ye?.then;if(typeof $=="function"){let G;const ce=X($,ye,oe=>{if(oe!=null)throw new w("nully","body",oe)},oe=>{R(G,oe)});return G=new Ee({objectMode:!0,readable:!1,write:Ve,final(oe){pe(async()=>{try{await ce,i.nextTick(oe,null)}catch(Fe){i.nextTick(oe,Fe)}})},destroy:De})}throw new w("Iterable, AsyncIterable or AsyncFunction",$e,ye)}if(K(re))return Te(re.arrayBuffer());if(s(re))return D(Ee,re,{objectMode:!0,writable:!1});if(f(re?.readable)&&p(re?.writable))return Ee.fromWeb(re);if(typeof re?.writable=="object"||typeof re?.readable=="object"){const ye=re!=null&&re.readable?u(re?.readable)?re?.readable:Te(re.readable):void 0,Ve=re!=null&&re.writable?c(re?.writable)?re?.writable:Te(re.writable):void 0;return Y({readable:ye,writable:Ve})}const ze=re?.then;if(typeof ze=="function"){let ye;return X(ze,re,Ve=>{Ve!=null&&ye.push(Ve),ye.push(null)},Ve=>{R(ye,Ve)}),ye=new Ee({objectMode:!0,writable:!1,read(){}})}throw new S($e,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],re)};function q(Te){let{promise:re,resolve:$e}=x();const ze=new z,ye=ze.signal;return{value:Te((async function*(){for(;;){const pe=re;re=null;const{chunk:De,done:$,cb:G}=await pe;if(i.nextTick(G),$)return;if(ye.aborted)throw new y(void 0,{cause:ye.reason});({promise:re,resolve:$e}=x()),yield De}})(),{signal:ye}),write(pe,De,$){const G=$e;$e=null,G({chunk:pe,done:!1,cb:$})},final(pe){const De=$e;$e=null,De({done:!0,cb:pe})},destroy(pe,De){ze.abort(),De(pe)}}}function Y(Te){const re=Te.readable&&typeof Te.readable.read!="function"?A.wrap(Te.readable):Te.readable,$e=Te.writable;let ze=!!t(re),ye=!!n($e),Ve,pe,De,$,G;function ce(oe){const Fe=$;$=null,Fe?Fe(oe):oe&&G.destroy(oe)}return G=new Ee({readableObjectMode:!!(re!=null&&re.readableObjectMode),writableObjectMode:!!($e!=null&&$e.writableObjectMode),readable:ze,writable:ye}),ye&&(g($e,oe=>{ye=!1,oe&&R(re,oe),ce(oe)}),G._write=function(oe,Fe,Ue){$e.write(oe,Fe)?Ue():Ve=Ue},G._final=function(oe){$e.end(),pe=oe},$e.on("drain",function(){if(Ve){const oe=Ve;Ve=null,oe()}}),$e.on("finish",function(){if(pe){const oe=pe;pe=null,oe()}})),ze&&(g(re,oe=>{ze=!1,oe&&R(re,oe),ce(oe)}),re.on("readable",function(){if(De){const oe=De;De=null,oe()}}),re.on("end",function(){G.push(null)}),G._read=function(){for(;;){const oe=re.read();if(oe===null){De=G._read;return}if(!G.push(oe))return}}),G._destroy=function(oe,Fe){!oe&&$!==null&&(oe=new y),De=null,Ve=null,pe=null,$===null?Fe(oe):($=Fe,R($e,oe),R(re,oe))},G}return duplexify$1}var duplex$1,hasRequiredDuplex$1;function requireDuplex$1(){if(hasRequiredDuplex$1)return duplex$1;hasRequiredDuplex$1=1;const{ObjectDefineProperties:i,ObjectGetOwnPropertyDescriptor:e,ObjectKeys:t,ObjectSetPrototypeOf:n}=requirePrimordials$1();duplex$1=u;const s=requireReadable$1(),a=requireWritable$1();n(u.prototype,s.prototype),n(u,s);{const p=t(a.prototype);for(let g=0;g<p.length;g++){const y=p[g];u.prototype[y]||(u.prototype[y]=a.prototype[y])}}function u(p){if(!(this instanceof u))return new u(p);s.call(this,p),a.call(this,p),p?(this.allowHalfOpen=p.allowHalfOpen!==!1,p.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),p.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}i(u.prototype,{writable:{__proto__:null,...e(a.prototype,"writable")},writableHighWaterMark:{__proto__:null,...e(a.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...e(a.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...e(a.prototype,"writableBuffer")},writableLength:{__proto__:null,...e(a.prototype,"writableLength")},writableFinished:{__proto__:null,...e(a.prototype,"writableFinished")},writableCorked:{__proto__:null,...e(a.prototype,"writableCorked")},writableEnded:{__proto__:null,...e(a.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...e(a.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(p){this._readableState&&this._writableState&&(this._readableState.destroyed=p,this._writableState.destroyed=p)}}});let c;function h(){return c===void 0&&(c={}),c}u.fromWeb=function(p,g){return h().newStreamDuplexFromReadableWritablePair(p,g)},u.toWeb=function(p){return h().newReadableWritablePairFromDuplex(p)};let f;return u.from=function(p){return f||(f=requireDuplexify$1()),f(p,"body")},duplex$1}var transform$2,hasRequiredTransform$1;function requireTransform$1(){if(hasRequiredTransform$1)return transform$2;hasRequiredTransform$1=1;const{ObjectSetPrototypeOf:i,Symbol:e}=requirePrimordials$1();transform$2=u;const{ERR_METHOD_NOT_IMPLEMENTED:t}=requireErrors$1().codes,n=requireDuplex$1(),{getHighWaterMark:s}=requireState$1();i(u.prototype,n.prototype),i(u,n);const a=e("kCallback");function u(f){if(!(this instanceof u))return new u(f);const p=f?s(this,f,"readableHighWaterMark",!0):null;p===0&&(f={...f,highWaterMark:null,readableHighWaterMark:p,writableHighWaterMark:f.writableHighWaterMark||0}),n.call(this,f),this._readableState.sync=!1,this[a]=null,f&&(typeof f.transform=="function"&&(this._transform=f.transform),typeof f.flush=="function"&&(this._flush=f.flush)),this.on("prefinish",h)}function c(f){typeof this._flush=="function"&&!this.destroyed?this._flush((p,g)=>{if(p){f?f(p):this.destroy(p);return}g!=null&&this.push(g),this.push(null),f&&f()}):(this.push(null),f&&f())}function h(){this._final!==c&&c.call(this)}return u.prototype._final=c,u.prototype._transform=function(f,p,g){throw new t("_transform()")},u.prototype._write=function(f,p,g){const y=this._readableState,S=this._writableState,w=y.length;this._transform(f,p,(R,T)=>{if(R){g(R);return}T!=null&&this.push(T),S.ended||w===y.length||y.length<y.highWaterMark?g():this[a]=g})},u.prototype._read=function(){if(this[a]){const f=this[a];this[a]=null,f()}},transform$2}var passthrough$1,hasRequiredPassthrough$1;function requirePassthrough$1(){if(hasRequiredPassthrough$1)return passthrough$1;hasRequiredPassthrough$1=1;const{ObjectSetPrototypeOf:i}=requirePrimordials$1();passthrough$1=t;const e=requireTransform$1();i(t.prototype,e.prototype),i(t,e);function t(n){if(!(this instanceof t))return new t(n);e.call(this,n)}return t.prototype._transform=function(n,s,a){a(null,n)},passthrough$1}var pipeline_1$1,hasRequiredPipeline$1;function requirePipeline$1(){if(hasRequiredPipeline$1)return pipeline_1$1;hasRequiredPipeline$1=1;const i=requireBrowser$2(),{ArrayIsArray:e,Promise:t,SymbolAsyncIterator:n,SymbolDispose:s}=requirePrimordials$1(),a=requireEndOfStream$1(),{once:u}=requireUtil$1(),c=requireDestroy$1(),h=requireDuplex$1(),{aggregateTwoErrors:f,codes:{ERR_INVALID_ARG_TYPE:p,ERR_INVALID_RETURN_VALUE:g,ERR_MISSING_ARGS:y,ERR_STREAM_DESTROYED:S,ERR_STREAM_PREMATURE_CLOSE:w},AbortError:R}=requireErrors$1(),{validateFunction:T,validateAbortSignal:A}=requireValidators$1(),{isIterable:F,isReadable:x,isReadableNodeStream:D,isNodeStream:O,isTransformStream:K,isWebStream:z,isReadableStream:X,isReadableFinished:Ee}=requireUtils$1(),q=globalThis.AbortController||requireBrowser$3().AbortController;let Y,Te,re;function $e(oe,Fe,Ue){let Je=!1;oe.on("close",()=>{Je=!0});const He=a(oe,{readable:Fe,writable:Ue},he=>{Je=!he});return{destroy:he=>{Je||(Je=!0,c.destroyer(oe,he||new S("pipe")))},cleanup:He}}function ze(oe){return T(oe[oe.length-1],"streams[stream.length - 1]"),oe.pop()}function ye(oe){if(F(oe))return oe;if(D(oe))return Ve(oe);throw new p("val",["Readable","Iterable","AsyncIterable"],oe)}async function*Ve(oe){Te||(Te=requireReadable$1()),yield*Te.prototype[n].call(oe)}async function pe(oe,Fe,Ue,{end:Je}){let He,he=null;const fe=j=>{if(j&&(He=j),he){const N=he;he=null,N()}},Oe=()=>new t((j,N)=>{He?N(He):he=()=>{He?N(He):j()}});Fe.on("drain",fe);const ie=a(Fe,{readable:!1},fe);try{Fe.writableNeedDrain&&await Oe();for await(const j of oe)Fe.write(j)||await Oe();Je&&(Fe.end(),await Oe()),Ue()}catch(j){Ue(He!==j?f(He,j):j)}finally{ie(),Fe.off("drain",fe)}}async function De(oe,Fe,Ue,{end:Je}){K(Fe)&&(Fe=Fe.writable);const He=Fe.getWriter();try{for await(const he of oe)await He.ready,He.write(he).catch(()=>{});await He.ready,Je&&await He.close(),Ue()}catch(he){try{await He.abort(he),Ue(he)}catch(fe){Ue(fe)}}}function $(...oe){return G(oe,u(ze(oe)))}function G(oe,Fe,Ue){if(oe.length===1&&e(oe[0])&&(oe=oe[0]),oe.length<2)throw new y("streams");const Je=new q,He=Je.signal,he=Ue?.signal,fe=[];A(he,"options.signal");function Oe(){ae(new R)}re=re||requireUtil$1().addAbortListener;let ie;he&&(ie=re(he,Oe));let j,N;const L=[];let V=0;function ee(xe){ae(xe,--V===0)}function ae(xe,de){var st;if(xe&&(!j||j.code==="ERR_STREAM_PREMATURE_CLOSE")&&(j=xe),!(!j&&!de)){for(;L.length;)L.shift()(j);(st=ie)===null||st===void 0||st[s](),Je.abort(),de&&(j||fe.forEach(ft=>ft()),i.nextTick(Fe,j,N))}}let ve;for(let xe=0;xe<oe.length;xe++){const de=oe[xe],st=xe<oe.length-1,ft=xe>0,Ge=st||Ue?.end!==!1,pt=xe===oe.length-1;if(O(de)){let Z=function(P){P&&P.name!=="AbortError"&&P.code!=="ERR_STREAM_PREMATURE_CLOSE"&&ee(P)};if(Ge){const{destroy:P,cleanup:B}=$e(de,st,ft);L.push(P),x(de)&&pt&&fe.push(B)}de.on("error",Z),x(de)&&pt&&fe.push(()=>{de.removeListener("error",Z)})}if(xe===0)if(typeof de=="function"){if(ve=de({signal:He}),!F(ve))throw new g("Iterable, AsyncIterable or Stream","source",ve)}else F(de)||D(de)||K(de)?ve=de:ve=h.from(de);else if(typeof de=="function"){if(K(ve)){var J;ve=ye((J=ve)===null||J===void 0?void 0:J.readable)}else ve=ye(ve);if(ve=de(ve,{signal:He}),st){if(!F(ve,!0))throw new g("AsyncIterable",`transform[${xe-1}]`,ve)}else{var me;Y||(Y=requirePassthrough$1());const Z=new Y({objectMode:!0}),P=(me=ve)===null||me===void 0?void 0:me.then;if(typeof P=="function")V++,P.call(ve,Ie=>{N=Ie,Ie!=null&&Z.write(Ie),Ge&&Z.end(),i.nextTick(ee)},Ie=>{Z.destroy(Ie),i.nextTick(ee,Ie)});else if(F(ve,!0))V++,pe(ve,Z,ee,{end:Ge});else if(X(ve)||K(ve)){const Ie=ve.readable||ve;V++,pe(Ie,Z,ee,{end:Ge})}else throw new g("AsyncIterable or Promise","destination",ve);ve=Z;const{destroy:B,cleanup:U}=$e(ve,!1,!0);L.push(B),pt&&fe.push(U)}}else if(O(de)){if(D(ve)){V+=2;const Z=ce(ve,de,ee,{end:Ge});x(de)&&pt&&fe.push(Z)}else if(K(ve)||X(ve)){const Z=ve.readable||ve;V++,pe(Z,de,ee,{end:Ge})}else if(F(ve))V++,pe(ve,de,ee,{end:Ge});else throw new p("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],ve);ve=de}else if(z(de)){if(D(ve))V++,De(ye(ve),de,ee,{end:Ge});else if(X(ve)||F(ve))V++,De(ve,de,ee,{end:Ge});else if(K(ve))V++,De(ve.readable,de,ee,{end:Ge});else throw new p("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],ve);ve=de}else ve=h.from(de)}return(He!=null&&He.aborted||he!=null&&he.aborted)&&i.nextTick(Oe),ve}function ce(oe,Fe,Ue,{end:Je}){let He=!1;if(Fe.on("close",()=>{He||Ue(new w)}),oe.pipe(Fe,{end:!1}),Je){let he=function(){He=!0,Fe.end()};Ee(oe)?i.nextTick(he):oe.once("end",he)}else Ue();return a(oe,{readable:!0,writable:!1},he=>{const fe=oe._readableState;he&&he.code==="ERR_STREAM_PREMATURE_CLOSE"&&fe&&fe.ended&&!fe.errored&&!fe.errorEmitted?oe.once("end",Ue).once("error",Ue):Ue(he)}),a(Fe,{readable:!1,writable:!0},Ue)}return pipeline_1$1={pipelineImpl:G,pipeline:$},pipeline_1$1}var compose$1,hasRequiredCompose$1;function requireCompose$1(){if(hasRequiredCompose$1)return compose$1;hasRequiredCompose$1=1;const{pipeline:i}=requirePipeline$1(),e=requireDuplex$1(),{destroyer:t}=requireDestroy$1(),{isNodeStream:n,isReadable:s,isWritable:a,isWebStream:u,isTransformStream:c,isWritableStream:h,isReadableStream:f}=requireUtils$1(),{AbortError:p,codes:{ERR_INVALID_ARG_VALUE:g,ERR_MISSING_ARGS:y}}=requireErrors$1(),S=requireEndOfStream$1();return compose$1=function(...R){if(R.length===0)throw new y("streams");if(R.length===1)return e.from(R[0]);const T=[...R];if(typeof R[0]=="function"&&(R[0]=e.from(R[0])),typeof R[R.length-1]=="function"){const Y=R.length-1;R[Y]=e.from(R[Y])}for(let Y=0;Y<R.length;++Y)if(!(!n(R[Y])&&!u(R[Y]))){if(Y<R.length-1&&!(s(R[Y])||f(R[Y])||c(R[Y])))throw new g(`streams[${Y}]`,T[Y],"must be readable");if(Y>0&&!(a(R[Y])||h(R[Y])||c(R[Y])))throw new g(`streams[${Y}]`,T[Y],"must be writable")}let A,F,x,D,O;function K(Y){const Te=D;D=null,Te?Te(Y):Y?O.destroy(Y):!q&&!Ee&&O.destroy()}const z=R[0],X=i(R,K),Ee=!!(a(z)||h(z)||c(z)),q=!!(s(X)||f(X)||c(X));if(O=new e({writableObjectMode:!!(z!=null&&z.writableObjectMode),readableObjectMode:!!(X!=null&&X.readableObjectMode),writable:Ee,readable:q}),Ee){if(n(z))O._write=function(Te,re,$e){z.write(Te,re)?$e():A=$e},O._final=function(Te){z.end(),F=Te},z.on("drain",function(){if(A){const Te=A;A=null,Te()}});else if(u(z)){const re=(c(z)?z.writable:z).getWriter();O._write=async function($e,ze,ye){try{await re.ready,re.write($e).catch(()=>{}),ye()}catch(Ve){ye(Ve)}},O._final=async function($e){try{await re.ready,re.close().catch(()=>{}),F=$e}catch(ze){$e(ze)}}}const Y=c(X)?X.readable:X;S(Y,()=>{if(F){const Te=F;F=null,Te()}})}if(q){if(n(X))X.on("readable",function(){if(x){const Y=x;x=null,Y()}}),X.on("end",function(){O.push(null)}),O._read=function(){for(;;){const Y=X.read();if(Y===null){x=O._read;return}if(!O.push(Y))return}};else if(u(X)){const Te=(c(X)?X.readable:X).getReader();O._read=async function(){for(;;)try{const{value:re,done:$e}=await Te.read();if(!O.push(re))return;if($e){O.push(null);return}}catch{return}}}}return O._destroy=function(Y,Te){!Y&&D!==null&&(Y=new p),x=null,A=null,F=null,D===null?Te(Y):(D=Te,n(X)&&t(X,Y))},O},compose$1}var hasRequiredOperators$1;function requireOperators$1(){if(hasRequiredOperators$1)return operators$1;hasRequiredOperators$1=1;const i=globalThis.AbortController||requireBrowser$3().AbortController,{codes:{ERR_INVALID_ARG_VALUE:e,ERR_INVALID_ARG_TYPE:t,ERR_MISSING_ARGS:n,ERR_OUT_OF_RANGE:s},AbortError:a}=requireErrors$1(),{validateAbortSignal:u,validateInteger:c,validateObject:h}=requireValidators$1(),f=requirePrimordials$1().Symbol("kWeak"),p=requirePrimordials$1().Symbol("kResistStopPropagation"),{finished:g}=requireEndOfStream$1(),y=requireCompose$1(),{addAbortSignalNoValidate:S}=requireAddAbortSignal$1(),{isWritable:w,isNodeStream:R}=requireUtils$1(),{deprecate:T}=requireUtil$1(),{ArrayPrototypePush:A,Boolean:F,MathFloor:x,Number:D,NumberIsNaN:O,Promise:K,PromiseReject:z,PromiseResolve:X,PromisePrototypeThen:Ee,Symbol:q}=requirePrimordials$1(),Y=q("kEmpty"),Te=q("kEof");function re(he,fe){if(fe!=null&&h(fe,"options"),fe?.signal!=null&&u(fe.signal,"options.signal"),R(he)&&!w(he))throw new e("stream",he,"must be writable");const Oe=y(this,he);return fe!=null&&fe.signal&&S(fe.signal,Oe),Oe}function $e(he,fe){if(typeof he!="function")throw new t("fn",["Function","AsyncFunction"],he);fe!=null&&h(fe,"options"),fe?.signal!=null&&u(fe.signal,"options.signal");let Oe=1;fe?.concurrency!=null&&(Oe=x(fe.concurrency));let ie=Oe-1;return fe?.highWaterMark!=null&&(ie=x(fe.highWaterMark)),c(Oe,"options.concurrency",1),c(ie,"options.highWaterMark",0),ie+=Oe,(async function*(){const N=requireUtil$1().AbortSignalAny([fe?.signal].filter(F)),L=this,V=[],ee={signal:N};let ae,ve,J=!1,me=0;function xe(){J=!0,de()}function de(){me-=1,st()}function st(){ve&&!J&&me<Oe&&V.length<ie&&(ve(),ve=null)}async function ft(){try{for await(let Ge of L){if(J)return;if(N.aborted)throw new a;try{if(Ge=he(Ge,ee),Ge===Y)continue;Ge=X(Ge)}catch(pt){Ge=z(pt)}me+=1,Ee(Ge,de,xe),V.push(Ge),ae&&(ae(),ae=null),!J&&(V.length>=ie||me>=Oe)&&await new K(pt=>{ve=pt})}V.push(Te)}catch(Ge){const pt=z(Ge);Ee(pt,de,xe),V.push(pt)}finally{J=!0,ae&&(ae(),ae=null)}}ft();try{for(;;){for(;V.length>0;){const Ge=await V[0];if(Ge===Te)return;if(N.aborted)throw new a;Ge!==Y&&(yield Ge),V.shift(),st()}await new K(Ge=>{ae=Ge})}}finally{J=!0,ve&&(ve(),ve=null)}}).call(this)}function ze(he=void 0){return he!=null&&h(he,"options"),he?.signal!=null&&u(he.signal,"options.signal"),(async function*(){let Oe=0;for await(const j of this){var ie;if(he!=null&&(ie=he.signal)!==null&&ie!==void 0&&ie.aborted)throw new a({cause:he.signal.reason});yield[Oe++,j]}}).call(this)}async function ye(he,fe=void 0){for await(const Oe of $.call(this,he,fe))return!0;return!1}async function Ve(he,fe=void 0){if(typeof he!="function")throw new t("fn",["Function","AsyncFunction"],he);return!await ye.call(this,async(...Oe)=>!await he(...Oe),fe)}async function pe(he,fe){for await(const Oe of $.call(this,he,fe))return Oe}async function De(he,fe){if(typeof he!="function")throw new t("fn",["Function","AsyncFunction"],he);async function Oe(ie,j){return await he(ie,j),Y}for await(const ie of $e.call(this,Oe,fe));}function $(he,fe){if(typeof he!="function")throw new t("fn",["Function","AsyncFunction"],he);async function Oe(ie,j){return await he(ie,j)?ie:Y}return $e.call(this,Oe,fe)}class G extends n{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}async function ce(he,fe,Oe){var ie;if(typeof he!="function")throw new t("reducer",["Function","AsyncFunction"],he);Oe!=null&&h(Oe,"options"),Oe?.signal!=null&&u(Oe.signal,"options.signal");let j=arguments.length>1;if(Oe!=null&&(ie=Oe.signal)!==null&&ie!==void 0&&ie.aborted){const ae=new a(void 0,{cause:Oe.signal.reason});throw this.once("error",()=>{}),await g(this.destroy(ae)),ae}const N=new i,L=N.signal;if(Oe!=null&&Oe.signal){const ae={once:!0,[f]:this,[p]:!0};Oe.signal.addEventListener("abort",()=>N.abort(),ae)}let V=!1;try{for await(const ae of this){var ee;if(V=!0,Oe!=null&&(ee=Oe.signal)!==null&&ee!==void 0&&ee.aborted)throw new a;j?fe=await he(fe,ae,{signal:L}):(fe=ae,j=!0)}if(!V&&!j)throw new G}finally{N.abort()}return fe}async function oe(he){he!=null&&h(he,"options"),he?.signal!=null&&u(he.signal,"options.signal");const fe=[];for await(const ie of this){var Oe;if(he!=null&&(Oe=he.signal)!==null&&Oe!==void 0&&Oe.aborted)throw new a(void 0,{cause:he.signal.reason});A(fe,ie)}return fe}function Fe(he,fe){const Oe=$e.call(this,he,fe);return(async function*(){for await(const j of Oe)yield*j}).call(this)}function Ue(he){if(he=D(he),O(he))return 0;if(he<0)throw new s("number",">= 0",he);return he}function Je(he,fe=void 0){return fe!=null&&h(fe,"options"),fe?.signal!=null&&u(fe.signal,"options.signal"),he=Ue(he),(async function*(){var ie;if(fe!=null&&(ie=fe.signal)!==null&&ie!==void 0&&ie.aborted)throw new a;for await(const N of this){var j;if(fe!=null&&(j=fe.signal)!==null&&j!==void 0&&j.aborted)throw new a;he--<=0&&(yield N)}}).call(this)}function He(he,fe=void 0){return fe!=null&&h(fe,"options"),fe?.signal!=null&&u(fe.signal,"options.signal"),he=Ue(he),(async function*(){var ie;if(fe!=null&&(ie=fe.signal)!==null&&ie!==void 0&&ie.aborted)throw new a;for await(const N of this){var j;if(fe!=null&&(j=fe.signal)!==null&&j!==void 0&&j.aborted)throw new a;if(he-- >0&&(yield N),he<=0)return}}).call(this)}return operators$1.streamReturningOperators={asIndexedPairs:T(ze,"readable.asIndexedPairs will be removed in a future version."),drop:Je,filter:$,flatMap:Fe,map:$e,take:He,compose:re},operators$1.promiseReturningOperators={every:Ve,forEach:De,reduce:ce,toArray:oe,some:ye,find:pe},operators$1}var promises$1,hasRequiredPromises$1;function requirePromises$1(){if(hasRequiredPromises$1)return promises$1;hasRequiredPromises$1=1;const{ArrayPrototypePop:i,Promise:e}=requirePrimordials$1(),{isIterable:t,isNodeStream:n,isWebStream:s}=requireUtils$1(),{pipelineImpl:a}=requirePipeline$1(),{finished:u}=requireEndOfStream$1();requireStream$1();function c(...h){return new e((f,p)=>{let g,y;const S=h[h.length-1];if(S&&typeof S=="object"&&!n(S)&&!t(S)&&!s(S)){const w=i(h);g=w.signal,y=w.end}a(h,(w,R)=>{w?p(w):f(R)},{signal:g,end:y})})}return promises$1={finished:u,pipeline:c},promises$1}var hasRequiredStream$1;function requireStream$1(){if(hasRequiredStream$1)return stream$1.exports;hasRequiredStream$1=1;const{Buffer:i}=requireBuffer(),{ObjectDefineProperty:e,ObjectKeys:t,ReflectApply:n}=requirePrimordials$1(),{promisify:{custom:s}}=requireUtil$1(),{streamReturningOperators:a,promiseReturningOperators:u}=requireOperators$1(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:c}}=requireErrors$1(),h=requireCompose$1(),{setDefaultHighWaterMark:f,getDefaultHighWaterMark:p}=requireState$1(),{pipeline:g}=requirePipeline$1(),{destroyer:y}=requireDestroy$1(),S=requireEndOfStream$1(),w=requirePromises$1(),R=requireUtils$1(),T=stream$1.exports=requireLegacy$1().Stream;T.isDestroyed=R.isDestroyed,T.isDisturbed=R.isDisturbed,T.isErrored=R.isErrored,T.isReadable=R.isReadable,T.isWritable=R.isWritable,T.Readable=requireReadable$1();for(const F of t(a)){let D=function(...O){if(new.target)throw c();return T.Readable.from(n(x,this,O))};const x=a[F];e(D,"name",{__proto__:null,value:x.name}),e(D,"length",{__proto__:null,value:x.length}),e(T.Readable.prototype,F,{__proto__:null,value:D,enumerable:!1,configurable:!0,writable:!0})}for(const F of t(u)){let D=function(...O){if(new.target)throw c();return n(x,this,O)};const x=u[F];e(D,"name",{__proto__:null,value:x.name}),e(D,"length",{__proto__:null,value:x.length}),e(T.Readable.prototype,F,{__proto__:null,value:D,enumerable:!1,configurable:!0,writable:!0})}T.Writable=requireWritable$1(),T.Duplex=requireDuplex$1(),T.Transform=requireTransform$1(),T.PassThrough=requirePassthrough$1(),T.pipeline=g;const{addAbortSignal:A}=requireAddAbortSignal$1();return T.addAbortSignal=A,T.finished=S,T.destroy=y,T.compose=h,T.setDefaultHighWaterMark=f,T.getDefaultHighWaterMark=p,e(T,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return w}}),e(g,s,{__proto__:null,enumerable:!0,get(){return w.pipeline}}),e(S,s,{__proto__:null,enumerable:!0,get(){return w.finished}}),T.Stream=T,T._isUint8Array=function(x){return x instanceof Uint8Array},T._uint8ArrayToBuffer=function(x){return i.from(x.buffer,x.byteOffset,x.byteLength)},stream$1.exports}var hasRequiredBrowser$1;function requireBrowser$1(){return hasRequiredBrowser$1||(hasRequiredBrowser$1=1,(function(i){const e=requireStream$1(),t=requirePromises$1(),n=e.Readable.destroy;i.exports=e.Readable,i.exports._uint8ArrayToBuffer=e._uint8ArrayToBuffer,i.exports._isUint8Array=e._isUint8Array,i.exports.isDisturbed=e.isDisturbed,i.exports.isErrored=e.isErrored,i.exports.isReadable=e.isReadable,i.exports.Readable=e.Readable,i.exports.Writable=e.Writable,i.exports.Duplex=e.Duplex,i.exports.Transform=e.Transform,i.exports.PassThrough=e.PassThrough,i.exports.addAbortSignal=e.addAbortSignal,i.exports.finished=e.finished,i.exports.destroy=e.destroy,i.exports.destroy=n,i.exports.pipeline=e.pipeline,i.exports.compose=e.compose,Object.defineProperty(e,"promises",{configurable:!0,enumerable:!0,get(){return t}}),i.exports.Stream=e.Stream,i.exports.default=i.exports})(browser$3)),browser$3.exports}var browserExports$1=requireBrowser$1();const ITERATOR$1=Symbol("iter");function merge$2(i,e,t=4){if(t===0)return Object.assign(i,e);for(const n in e)i[n]=merge$2(i[n]||Object.create(null),e[n],t-1);return i}function intersect$1(i,e,t=4){let n=!1;for(const s in i)if(s in e){const a=t===0?null:intersect$1(i[s],e[s],t-1);if(a!==!1)n=n||Object.create(null),n[s]=a;else if(t===3)return!1}return n}function difference$1(i,e,t=4){let n=!1;for(const s in i)if(!(s in e))n=n||Object.create(null),n[s]=t===0?null:merge$2({},i[s],t-1);else if(t!==0){const a=difference$1(i[s],e[s],t-1);if(a!==!1)n=n||Object.create(null),n[s]=a;else if(t===3)return!1}return n}let N3EntityIndex$1=class{constructor(e={}){this._id=1,this._ids=Object.create(null),this._ids[""]=1,this._entities=Object.create(null),this._entities[1]="",this._blankNodeIndex=0,this._factory=e.factory||DataFactory$2}_termFromId(e){if(e[0]==="."){const t=this._entities,n=e.split(".");return this._factory.quad(this._termFromId(t[n[1]]),this._termFromId(t[n[2]]),this._termFromId(t[n[3]]),n[4]&&this._termFromId(t[n[4]]))}return termFromId$1(e,this._factory)}_termToNumericId(e){if(e.termType==="Quad"){const t=this._termToNumericId(e.subject),n=this._termToNumericId(e.predicate),s=this._termToNumericId(e.object);let a;return t&&n&&s&&(isDefaultGraph$1(e.graph)||(a=this._termToNumericId(e.graph)))&&this._ids[a?`.${t}.${n}.${s}.${a}`:`.${t}.${n}.${s}`]}return this._ids[termToId$1(e)]}_termToNewNumericId(e){const t=e&&e.termType==="Quad"?`.${this._termToNewNumericId(e.subject)}.${this._termToNewNumericId(e.predicate)}.${this._termToNewNumericId(e.object)}${isDefaultGraph$1(e.graph)?"":`.${this._termToNewNumericId(e.graph)}`}`:termToId$1(e);return this._ids[t]||(this._ids[this._entities[++this._id]=t]=this._id)}createBlankNode(e){let t,n;if(e)for(t=e=`_:${e}`,n=1;this._ids[t];)t=e+n++;else do t=`_:b${this._blankNodeIndex++}`;while(this._ids[t]);return this._ids[t]=++this._id,this._entities[this._id]=t,this._factory.blankNode(t.substr(2))}},N3Store$1=class si{constructor(e,t){this._size=0,this._graphs=Object.create(null),!t&&e&&!e[0]&&typeof e.match!="function"&&(t=e,e=null),t=t||{},this._factory=t.factory||DataFactory$2,this._entityIndex=t.entityIndex||new N3EntityIndex$1({factory:this._factory}),this._entities=this._entityIndex._entities,this._termFromId=this._entityIndex._termFromId.bind(this._entityIndex),this._termToNumericId=this._entityIndex._termToNumericId.bind(this._entityIndex),this._termToNewNumericId=this._entityIndex._termToNewNumericId.bind(this._entityIndex),e&&this.addAll(e)}get size(){let e=this._size;if(e!==null)return e;e=0;const t=this._graphs;let n,s;for(const a in t)for(const u in n=t[a].subjects)for(const c in s=n[u])e+=Object.keys(s[c]).length;return this._size=e}_addToIndex(e,t,n,s){const a=e[t]||(e[t]={}),u=a[n]||(a[n]={}),c=s in u;return c||(u[s]=null),!c}_removeFromIndex(e,t,n,s){const a=e[t],u=a[n];delete u[s];for(const c in u)return;delete a[n];for(const c in a)return;delete e[t]}*_findInIndex(e,t,n,s,a,u,c,h){let f,p,g;const y=this._entities,S=this._termFromId(y[h]),w={subject:null,predicate:null,object:null};t&&((f=e,e={})[t]=f[t]);for(const R in e)if(p=e[R]){w[a]=this._termFromId(y[R]),n&&((f=p,p={})[n]=f[n]);for(const T in p)if(g=p[T]){w[u]=this._termFromId(y[T]);const A=s?s in g?[s]:[]:Object.keys(g);for(let F=0;F<A.length;F++)w[c]=this._termFromId(y[A[F]]),yield this._factory.quad(w.subject,w.predicate,w.object,S)}}}_loop(e,t){for(const n in e)t(n)}_loopByKey0(e,t,n){let s,a;if(s=e[t])for(a in s)n(a)}_loopByKey1(e,t,n){let s,a;for(s in e)a=e[s],a[t]&&n(s)}_loopBy2Keys(e,t,n,s){let a,u,c;if((a=e[t])&&(u=a[n]))for(c in u)s(c)}_countInIndex(e,t,n,s){let a=0,u,c,h;t&&((u=e,e={})[t]=u[t]);for(const f in e)if(c=e[f]){n&&((u=c,c={})[n]=u[n]);for(const p in c)(h=c[p])&&(s?s in h&&a++:a+=Object.keys(h).length)}return a}_getGraphs(e){return e=e===""?1:e&&(this._termToNumericId(e)||-1),typeof e!="number"?this._graphs:{[e]:this._graphs[e]}}_uniqueEntities(e){const t=Object.create(null);return n=>{n in t||(t[n]=!0,e(this._termFromId(this._entities[n],this._factory)))}}add(e){return this.addQuad(e),this}addQuad(e,t,n,s){t||(s=e.graph,n=e.object,t=e.predicate,e=e.subject),s=s?this._termToNewNumericId(s):1;let a=this._graphs[s];return a||(a=this._graphs[s]={subjects:{},predicates:{},objects:{}},Object.freeze(a)),e=this._termToNewNumericId(e),t=this._termToNewNumericId(t),n=this._termToNewNumericId(n),this._addToIndex(a.subjects,e,t,n)?(this._addToIndex(a.predicates,t,n,e),this._addToIndex(a.objects,n,e,t),this._size=null,!0):!1}addQuads(e){for(let t=0;t<e.length;t++)this.addQuad(e[t])}delete(e){return this.removeQuad(e),this}has(e,t,n,s){return e&&e.subject&&({subject:e,predicate:t,object:n,graph:s}=e),!this.readQuads(e,t,n,s).next().done}import(e){return e.on("data",t=>{this.addQuad(t)}),e}removeQuad(e,t,n,s){t||({subject:e,predicate:t,object:n,graph:s}=e),s=s?this._termToNumericId(s):1;const a=this._graphs;let u,c,h;if(!(e=e&&this._termToNumericId(e))||!(t=t&&this._termToNumericId(t))||!(n=n&&this._termToNumericId(n))||!(u=a[s])||!(c=u.subjects[e])||!(h=c[t])||!(n in h))return!1;this._removeFromIndex(u.subjects,e,t,n),this._removeFromIndex(u.predicates,t,n,e),this._removeFromIndex(u.objects,n,e,t),this._size!==null&&this._size--;for(e in u.subjects)return!0;return delete a[s],!0}removeQuads(e){for(let t=0;t<e.length;t++)this.removeQuad(e[t])}remove(e){return e.on("data",t=>{this.removeQuad(t)}),e}removeMatches(e,t,n,s){const a=new browserExports$1.Readable({objectMode:!0}),u=this.readQuads(e,t,n,s);return a._read=c=>{for(;--c>=0;){const{done:h,value:f}=u.next();if(h){a.push(null);return}a.push(f)}},this.remove(a)}deleteGraph(e){return this.removeMatches(null,null,null,e)}getQuads(e,t,n,s){return[...this.readQuads(e,t,n,s)]}*readQuads(e,t,n,s){const a=this._getGraphs(s);let u,c,h,f;if(!(e&&!(c=this._termToNumericId(e))||t&&!(h=this._termToNumericId(t))||n&&!(f=this._termToNumericId(n))))for(const p in a)(u=a[p])&&(c?f?yield*this._findInIndex(u.objects,f,c,h,"object","subject","predicate",p):yield*this._findInIndex(u.subjects,c,h,null,"subject","predicate","object",p):h?yield*this._findInIndex(u.predicates,h,f,null,"predicate","object","subject",p):f?yield*this._findInIndex(u.objects,f,null,null,"object","subject","predicate",p):yield*this._findInIndex(u.subjects,null,null,null,"subject","predicate","object",p))}match(e,t,n,s){return new DatasetCoreAndReadableStream$1(this,e,t,n,s,{entityIndex:this._entityIndex})}countQuads(e,t,n,s){const a=this._getGraphs(s);let u=0,c,h,f,p;if(e&&!(h=this._termToNumericId(e))||t&&!(f=this._termToNumericId(t))||n&&!(p=this._termToNumericId(n)))return 0;for(const g in a)(c=a[g])&&(e?n?u+=this._countInIndex(c.objects,p,h,f):u+=this._countInIndex(c.subjects,h,f,p):t?u+=this._countInIndex(c.predicates,f,p,h):u+=this._countInIndex(c.objects,p,h,f));return u}forEach(e,t,n,s,a){this.some(u=>(e(u,this),!1),t,n,s,a)}every(e,t,n,s,a){return!this.some(u=>!e(u,this),t,n,s,a)}some(e,t,n,s,a){for(const u of this.readQuads(t,n,s,a))if(e(u,this))return!0;return!1}getSubjects(e,t,n){const s=[];return this.forSubjects(a=>{s.push(a)},e,t,n),s}forSubjects(e,t,n,s){const a=this._getGraphs(s);let u,c,h;if(e=this._uniqueEntities(e),!(t&&!(c=this._termToNumericId(t))||n&&!(h=this._termToNumericId(n))))for(s in a)(u=a[s])&&(c?h?this._loopBy2Keys(u.predicates,c,h,e):this._loopByKey1(u.subjects,c,e):h?this._loopByKey0(u.objects,h,e):this._loop(u.subjects,e))}getPredicates(e,t,n){const s=[];return this.forPredicates(a=>{s.push(a)},e,t,n),s}forPredicates(e,t,n,s){const a=this._getGraphs(s);let u,c,h;if(e=this._uniqueEntities(e),!(t&&!(c=this._termToNumericId(t))||n&&!(h=this._termToNumericId(n))))for(s in a)(u=a[s])&&(c?h?this._loopBy2Keys(u.objects,h,c,e):this._loopByKey0(u.subjects,c,e):h?this._loopByKey1(u.predicates,h,e):this._loop(u.predicates,e))}getObjects(e,t,n){const s=[];return this.forObjects(a=>{s.push(a)},e,t,n),s}forObjects(e,t,n,s){const a=this._getGraphs(s);let u,c,h;if(e=this._uniqueEntities(e),!(t&&!(c=this._termToNumericId(t))||n&&!(h=this._termToNumericId(n))))for(s in a)(u=a[s])&&(c?h?this._loopBy2Keys(u.subjects,c,h,e):this._loopByKey1(u.objects,c,e):h?this._loopByKey0(u.predicates,h,e):this._loop(u.objects,e))}getGraphs(e,t,n){const s=[];return this.forGraphs(a=>{s.push(a)},e,t,n),s}forGraphs(e,t,n,s){for(const a in this._graphs)this.some(u=>(e(u.graph),!0),t,n,s,this._termFromId(this._entities[a]))}createBlankNode(e){return this._entityIndex.createBlankNode(e)}extractLists({remove:e=!1,ignoreErrors:t=!1}={}){const n={},s=t?(()=>!0):((c,h)=>{throw new Error(`${c.value} ${h}`)}),a=this.getQuads(null,namespaces$1.rdf.rest,namespaces$1.rdf.nil,null),u=e?[...a]:[];return a.forEach(c=>{const h=[];let f=!1,p,g;const y=c.graph;let S=c.subject;for(;S&&!f;){const w=this.getQuads(null,null,S,null),R=this.getQuads(S,null,null,null);let T,A=null,F=null,x=null;for(let D=0;D<R.length&&!f;D++)T=R[D],T.graph.equals(y)?p?f=s(S,"has non-list arcs out"):T.predicate.value===namespaces$1.rdf.first?A?f=s(S,"has multiple rdf:first arcs"):u.push(A=T):T.predicate.value===namespaces$1.rdf.rest?F?f=s(S,"has multiple rdf:rest arcs"):u.push(F=T):w.length?f=s(S,"can't be subject and object"):(p=T,g="subject"):f=s(S,"not confined to single graph");for(let D=0;D<w.length&&!f;++D)T=w[D],p?f=s(S,"can't have coreferences"):T.predicate.value===namespaces$1.rdf.rest?x?f=s(S,"has incoming rdf:rest arcs"):x=T:(p=T,g="object");A?h.unshift(A.object):f=s(S,"has no list head"),S=x&&x.subject}f?e=!1:p&&(n[p[g].value]=h)}),e&&this.removeQuads(u),n}addAll(e){if(e instanceof DatasetCoreAndReadableStream$1&&(e=e.filtered),Array.isArray(e))this.addQuads(e);else if(e instanceof si&&e._entityIndex===this._entityIndex)e._size!==0&&(this._graphs=merge$2(this._graphs,e._graphs),this._size=null);else for(const t of e)this.add(t);return this}contains(e){if(e instanceof DatasetCoreAndReadableStream$1&&(e=e.filtered),e===this)return!0;if(!(e instanceof si)||this._entityIndex!==e._entityIndex)return e.every(f=>this.has(f));const t=this._graphs,n=e._graphs;let s,a,u,c,h;for(const f in n){if(!(s=t[f]))return!1;s=s.subjects;for(const p in a=n[f].subjects){if(!(u=s[p]))return!1;for(const g in c=a[p]){if(!(h=u[g]))return!1;for(const y in c[g])if(!(y in h))return!1}}}return!0}deleteMatches(e,t,n,s){for(const a of this.match(e,t,n,s))this.removeQuad(a);return this}difference(e){if(e&&e instanceof DatasetCoreAndReadableStream$1&&(e=e.filtered),e===this)return new si({entityIndex:this._entityIndex});if(e instanceof si&&e._entityIndex===this._entityIndex){const t=new si({entityIndex:this._entityIndex}),n=difference$1(this._graphs,e._graphs);return n&&(t._graphs=n,t._size=null),t}return this.filter(t=>!e.has(t))}equals(e){return e instanceof DatasetCoreAndReadableStream$1&&(e=e.filtered),e===this||this.size===e.size&&this.contains(e)}filter(e){const t=new si({entityIndex:this._entityIndex});for(const n of this)e(n,this)&&t.add(n);return t}intersection(e){if(e instanceof DatasetCoreAndReadableStream$1&&(e=e.filtered),e===this){const t=new si({entityIndex:this._entityIndex});return t._graphs=merge$2(Object.create(null),this._graphs),t._size=this._size,t}else if(e instanceof si&&this._entityIndex===e._entityIndex){const t=new si({entityIndex:this._entityIndex}),n=intersect$1(e._graphs,this._graphs);return n&&(t._graphs=n,t._size=null),t}return this.filter(t=>e.has(t))}map(e){const t=new si({entityIndex:this._entityIndex});for(const n of this)t.add(e(n,this));return t}reduce(e,t){const n=this.readQuads();let s=t===void 0?n.next().value:t;for(const a of n)s=e(s,a,this);return s}toArray(){return this.getQuads()}toCanonical(){throw new Error("not implemented")}toStream(){return this.match()}toString(){return new N3Writer$1().quadsToString(this)}union(e){const t=new si({entityIndex:this._entityIndex});return t._graphs=merge$2(Object.create(null),this._graphs),t._size=this._size,t.addAll(e),t}*[Symbol.iterator](){yield*this.readQuads()}};function indexMatch$1(i,e,t=0){const n=e[t];if(n&&!(n in i))return!1;let s=!1;for(const a in n?{[n]:i[n]}:i){const u=t===2?null:indexMatch$1(i[a],e,t+1);u!==!1&&(s=s||Object.create(null),s[a]=u)}return s}let DatasetCoreAndReadableStream$1=class yh extends browserExports$1.Readable{constructor(e,t,n,s,a,u){super({objectMode:!0}),Object.assign(this,{n3Store:e,subject:t,predicate:n,object:s,graph:a,options:u})}get filtered(){if(!this._filtered){const{n3Store:e,graph:t,object:n,predicate:s,subject:a}=this,u=this._filtered=new N3Store$1({factory:e._factory,entityIndex:this.options.entityIndex});let c,h,f;if(a&&!(c=u._termToNumericId(a))||s&&!(h=u._termToNumericId(s))||n&&!(f=u._termToNumericId(n)))return u;const p=e._getGraphs(t);for(const g in p){let y,S,w,R;(R=p[g])&&(!c&&h?(S=indexMatch$1(R.predicates,[h,f,c]))&&(y=indexMatch$1(R.subjects,[c,h,f]),w=indexMatch$1(R.objects,[f,c,h])):f?(w=indexMatch$1(R.objects,[f,c,h]))&&(y=indexMatch$1(R.subjects,[c,h,f]),S=indexMatch$1(R.predicates,[h,f,c])):(y=indexMatch$1(R.subjects,[c,h,f]))&&(S=indexMatch$1(R.predicates,[h,f,c]),w=indexMatch$1(R.objects,[f,c,h])),y&&(u._graphs[g]={subjects:y,predicates:S,objects:w}))}u._size=null}return this._filtered}get size(){return this.filtered.size}_read(e){e>0&&!this[ITERATOR$1]&&(this[ITERATOR$1]=this[Symbol.iterator]());const t=this[ITERATOR$1];for(;--e>=0;){const{done:n,value:s}=t.next();if(n){this.push(null);return}this.push(s)}}addAll(e){return this.filtered.addAll(e)}contains(e){return this.filtered.contains(e)}deleteMatches(e,t,n,s){return this.filtered.deleteMatches(e,t,n,s)}difference(e){return this.filtered.difference(e)}equals(e){return this.filtered.equals(e)}every(e,t,n,s,a){return this.filtered.every(e,t,n,s,a)}filter(e){return this.filtered.filter(e)}forEach(e,t,n,s,a){return this.filtered.forEach(e,t,n,s,a)}import(e){return this.filtered.import(e)}intersection(e){return this.filtered.intersection(e)}map(e){return this.filtered.map(e)}some(e,t,n,s,a){return this.filtered.some(e,t,n,s,a)}toCanonical(){return this.filtered.toCanonical()}toStream(){return this._filtered?this._filtered.toStream():this.n3Store.match(this.subject,this.predicate,this.object,this.graph)}union(e){return this._filtered?this._filtered.union(e):this.n3Store.match(this.subject,this.predicate,this.object,this.graph).addAll(e)}toArray(){return this._filtered?this._filtered.toArray():this.n3Store.getQuads(this.subject,this.predicate,this.object,this.graph)}reduce(e,t){return this.filtered.reduce(e,t)}toString(){return new N3Writer$1().quadsToString(this)}add(e){return this.filtered.add(e)}delete(e){return this.filtered.delete(e)}has(e){return this.filtered.has(e)}match(e,t,n,s){return new yh(this.filtered,e,t,n,s,this.options)}*[Symbol.iterator](){yield*this._filtered||this.n3Store.readQuads(this.subject,this.predicate,this.object,this.graph)}};var _a$8;function isRecord$2(i){return typeof i=="object"&&i!==null}function isPodTable(i){return isRecord$2(i)&&"columns"in i&&"config"in i}function hasStringValue$1(i){return isRecord$2(i)&&typeof i.value=="string"}function isAbsoluteIri(i){return i.startsWith("http://")||i.startsWith("https://")}function normalizePodBase(i){return i.endsWith("/")?i:`${i}/`}function normalizeBaseRelativePath(i){return i.replace(/^\/+/u,"")}function hasDuplicatePathComposition(i){const t=i.split("#")[0].replace(/^https?:\/\/[^/]+/u,"").split("/").filter(Boolean);for(let n=0;n<t.length;n++)for(let s=2;n+s*2<=t.length;s++){const a=t.slice(n,n+s).join("/"),u=t.slice(n+s,n+s*2).join("/");if(a===u)return!0}return!1}function isBaseRelativeSubjectId(i){return!i||isAbsoluteIri(i)||i.startsWith("/")?!1:i.startsWith("#")||i.includes("#")||/\.(ttl|jsonld|json)(?:#|$)/i.test(i)}function isTimeLocatorKey(i){return["yyyy","MM","dd","HH","mm","ss","timestamp"].includes(i)}function parseTemplateVariableField(i){return i.split("|").map(e=>e.trim()).filter(Boolean)[0]??i}function escapeSparqlString(i){return i.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")}function hasTimeLocatorContext(i){return i.createdAt!==void 0||i.created_at!==void 0||i.dateCreated!==void 0}function getKnownRowIri(i){for(const e of["@id","subject","uri","source"]){const t=i[e];if(typeof t=="string"&&isAbsoluteIri(t))return t}}class PodDatabase{constructor(e,t,n){this.dialect=e,this.session=t,this.schema=n,this.notificationsClient=null,this.federatedExecutor=null,this.lastFederatedErrors=[]}getLastFederatedErrors(){return this.lastFederatedErrors}clearFederatedErrors(){this.lastFederatedErrors=[]}getFederatedExecutor(){return this.federatedExecutor||(this.federatedExecutor=new FederatedQueryExecutor({fetch:this.dialect.getAuthenticatedFetch()})),this.federatedExecutor}createTable(e,t){const n=e.table("default",t);return t.hooks&&(n.config.hooks=t.hooks),Reflect.set(n,"_db",this),n}select(e){return this.session.select(e)}insert(e){return this.session.insert(e)}update(e){return this.session.update(e)}delete(e){return this.session.delete(e)}resolvePodFileUrl(e){if(!e||typeof e!="string")throw new Error("resource file path must be a non-empty string");if(isAbsoluteIri(e))return e;const t=this.dialect.getPodUrl;if(typeof t!="function")throw new Error("Cannot resolve Pod file path because dialect.getPodUrl is not available");return new URL(normalizeBaseRelativePath(e),normalizePodBase(t.call(this.dialect))).toString()}getResourceFileInputs(e){const t=[];e.document&&t.push({...e.document,relationField:e.document.relationField??"document"}),e.source&&t.push({...e.source,relationField:e.source.relationField??"source"});for(const n of e.files??[])t.push({...n,relationField:n.relationField??"document"});return t}validateNoDuplicatePathComposition(e){const t=e.find(hasDuplicatePathComposition);if(t)throw new Error(`duplicate path composition detected: ${t}`)}async dryRunResourceWithDocument(e,t){if(!isRecord$2(t.row)||Array.isArray(t.row))throw new Error("dryRunResourceWithDocument requires a row object");const n=this.resolveRowIri(e,t.row),s=t.row.id,a=typeof s=="string"&&!isAbsoluteIri(s)?s:this.resolveRowId(e,t.row),u={...t.row},c=[],h=[a];for(const f of this.getResourceFileInputs(t)){const p=f.url??f.path;if(!p)throw new Error(`resource file '${f.relationField}' requires path or url`);h.push(p);const g=this.resolvePodFileUrl(p);u[f.relationField]=g,c.push({relationField:f.relationField,url:g,...f.contentType?{contentType:f.contentType}:{}})}return this.validateNoDuplicatePathComposition(h),{ok:!0,resourceId:a,resourceIri:n,row:u,rdfMutations:[{type:"upsert",subject:n,fields:Object.keys(u)}],fileWrites:c,warnings:[],errors:[]}}async upsertResourceWithDocument(e,t){const n=await this.dryRunResourceWithDocument(e,t),s=this.dialect.getAuthenticatedFetch(),a=[];try{for(const u of this.getResourceFileInputs(t)){const c=u.url??u.path;if(!c)throw new Error(`resource file '${u.relationField}' requires path or url`);const h=this.resolvePodFileUrl(c),f={};u.contentType&&(f["content-type"]=u.contentType);const p=await s(h,{method:"PUT",headers:f,body:u.content??""});if(!p.ok)throw new Error(`Failed to write resource file ${h}: HTTP ${p.status}`);a.push(h)}return await this.insert(e).values(n.row).execute(),n}catch(u){for(const c of a.reverse())try{await s(c,{method:"DELETE"})}catch{}throw u}}async moveDocumentAndRelink(e,t){const n=t.relationField??"document",s=t.fromUrl??(t.fromPath?this.resolvePodFileUrl(t.fromPath):void 0),a=t.toUrl??t.toPath;if(!a)throw new Error("moveDocumentAndRelink requires toPath or toUrl");const u=this.resolvePodFileUrl(a);this.validateNoDuplicatePathComposition([t.id,a]);const c=this.dialect.getAuthenticatedFetch();let h=t.content??null,f=t.contentType;if(h===null&&s){const y=await c(s,{method:"GET"});if(!y.ok)throw new Error(`Failed to read source document ${s}: HTTP ${y.status}`);h=await y.blob(),f=f??y.headers.get("content-type")??void 0}if(h===null)throw new Error("moveDocumentAndRelink requires content when fromPath/fromUrl is not provided");const p={};f&&(p["content-type"]=f);const g=await c(u,{method:"PUT",headers:p,body:h});if(!g.ok)throw new Error(`Failed to write destination document ${u}: HTTP ${g.status}`);try{const y=await this.updateById(e,t.id,{[n]:u});return s&&s!==u&&await c(s,{method:"DELETE"}),{fromUrl:s,toUrl:u,resource:y}}catch(y){try{await c(u,{method:"DELETE"})}catch{}throw y}}async deleteResourceWithDocument(e,t){const n=t.relationField??"document",s=await this.findById(e,t.id),a=t.url??(t.path?this.resolvePodFileUrl(t.path):void 0)??(typeof s?.[n]=="string"?s[n]:void 0),u=await this.deleteById(e,t.id);if(u&&a){const c=await this.dialect.getAuthenticatedFetch()(a,{method:"DELETE"});if(!c.ok&&c.status!==404)throw new Error(`Failed to delete resource file ${a}: HTTP ${c.status}`)}return{deleted:u,fileUrl:a}}async execute(e){return await this.executeSPARQL(e)}async executeSPARQL(e){if(typeof e!="string"||e.trim().length===0)throw new Error("executeSPARQL requires a non-empty SPARQL query string");return await this.dialect.executeSPARQL(e)}async batch(e){const t=[];for(const n of e)t.push(await n);return t}async findFirst(e,t){const n=this.select().from(e).limit(1);t&&Object.keys(t).length>0&&n.where(t);const s=await n;return s.length>0?s[0]:null}getLocatorTemplate(e){return e.getSubjectTemplate?.()??e.config?.subjectTemplate}getRequiredLocatorKeys(e){const t=this.getLocatorTemplate(e);if(!t)return["id"];const n=Array.from(t.matchAll(/\{([^}]+)\}/g)).map(s=>parseTemplateVariableField(s[1])).filter(s=>s!=="index");return Array.from(new Set(n))}resolveResourceTargetIri(e,t,n){if(typeof t=="string")return isAbsoluteIri(t)?t:this.resolveLocatorSubject(e,{id:t},n);if(!isRecord$2(t)||Array.isArray(t))throw new Error(`${n} requires a resource IRI, base-relative id, row, or locator object`);const s=getKnownRowIri(t);return s||this.resolveLocatorSubject(e,t,n)}resolveLocatorSubject(e,t,n){if(!isRecord$2(t)||Array.isArray(t))throw new Error(`${n} requires a locator object`);if("@id"in t)throw new Error(`${n} does not accept '@id'. Use ${this.getIriAlternative(n)} instead.`);const s=t.id;if(typeof s=="string"&&isAbsoluteIri(s))throw new Error(`${n} does not accept a full IRI in locator.id. Use ${this.getIriAlternative(n)} instead.`);const a=this.getRequiredLocatorKeys(e),u=this.dialect.getResolver(e),c=hasTimeLocatorContext(t),h=a.filter(f=>t[f]!==void 0&&t[f]!==null?!1:!(c&&isTimeLocatorKey(f)));if(typeof s=="string"&&isBaseRelativeSubjectId(s)){const f=a.filter(p=>p!=="id");if(s.startsWith("#")&&f.length>0){const p=this.getLocatorTemplate(e)??"<exact-id>";throw new Error(`${n} requires a complete locator for subjectTemplate '${p}'. Missing [${f.join(", ")}]. Use a base-relative resource id that includes every storage slot.`)}return u.resolveSubject(e,t)}if(h.length>0){const f=this.getLocatorTemplate(e)??"<exact-id>";throw new Error(`${n} requires a complete locator for subjectTemplate '${f}'. Missing [${h.join(", ")}]. Use ${this.getIriAlternative(n)} when you already have a full IRI.`)}return u.resolveSubject(e,t)}resolveIdSubject(e,t,n){if(!t||typeof t!="string")throw new Error(`${n} requires a valid base-relative resource id string`);if(isAbsoluteIri(t))throw new Error(`${n} requires a base-relative resource id. Use ${this.getIriAlternative(n)} for full IRIs.`);const s=this.getLocatorTemplate(e)??"<exact-id>",a=this.getRequiredLocatorKeys(e).filter(c=>c!=="id"),u=this.dialect.getResolver(e);if(isBaseRelativeSubjectId(t)){if(t.startsWith("#")&&a.length>0)throw new Error(`${n} requires a base-relative resource id for subjectTemplate '${s}', got local fragment id '${t}'. Missing [${a.join(", ")}]. Use a base-relative id that includes every storage slot.`);return u.resolveSubject(e,{id:t.startsWith("#")?t.slice(1):t})}if(a.length>0)throw new Error(`${n} requires a base-relative resource id for subjectTemplate '${s}', got local id '${t}'. Missing [${a.join(", ")}]. Use a base-relative id that includes every storage slot.`);return u.resolveSubject(e,{id:t})}warnFindByLocatorDeprecation(){PodDatabase.findByLocatorDeprecationWarned||(PodDatabase.findByLocatorDeprecationWarned=!0,console.warn("[drizzle-solid] findByLocator(resource, locator) is deprecated and will be removed in a future release. Use findById(resource, id) for base-relative resource ids, findByResource(resource, target) for generic exact targets, or findByIri(resource, iri) for full IRIs."))}getIriAlternative(e){return e==="resolveLocatorIri"||e==="resolveLocatorId"?"the full IRI directly":e==="findById"||e==="findByResource"?"findByIri(resource, iri)":e==="updateById"||e==="updateByResource"?"updateByIri(resource, iri, data)":e==="deleteById"||e==="deleteByResource"?"deleteByIri(resource, iri)":`${e.replace("Locator","Iri")}(resource, iri)`}resolveLocatorIri(e,t){return this.resolveLocatorSubject(e,t,"resolveLocatorIri")}resolveLocatorId(e,t){const n=this.resolveLocatorSubject(e,t,"resolveLocatorId");return this.resolveBaseRelativeResourceId(e,n)}resolveResourceIri(e,t){return this.resolveResourceTargetIri(e,t,"resolveResourceIri")}resolveResourceId(e,t){const n=this.resolveResourceTargetIri(e,t,"resolveResourceId");return this.resolveBaseRelativeResourceId(e,n)}resolveRelationIri(e,t){return this.resolveResourceTargetIri(e,t,"resolveRelationIri")}resolveRowIri(e,t){if(!isRecord$2(t)||Array.isArray(t))throw new Error("resolveRowIri requires a row object");return getKnownRowIri(t)??this.resolveLocatorSubject(e,t,"resolveRowIri")}resolveRowId(e,t){if(!isRecord$2(t)||Array.isArray(t))throw new Error("resolveRowId requires a row object");const n=getKnownRowIri(t)??this.resolveLocatorSubject(e,t,"resolveRowId");return this.resolveBaseRelativeResourceId(e,n)}resolveBaseRelativeResourceId(e,t){return parsePodResourceRef(e,t)?.resourceId??this.dialect.getResolver(e).parseId(e,t)}needsShortIdSubjectLookup(e,t){return!t||typeof t!="string"||isAbsoluteIri(t)||isBaseRelativeSubjectId(t)?!1:this.getRequiredLocatorKeys(e).some(n=>n!=="id")}buildShortIdSubjectSuffix(e,t){const n=this.getLocatorTemplate(e)??"<exact-id>",s=Array.from(n.matchAll(/\{([^}]+)\}/g));let a=-1;for(let g=s.length-1;g>=0;g--)if(parseTemplateVariableField(s[g][1])==="id"){a=g;break}if(a<0)return t;const u=s[a],c=s[a-1],h=c?.index===void 0?0:c.index+c[0].length,f=u.index??0,p=f+u[0].length;return`${n.slice(h,f)}${t}${n.slice(p)}`}resolveShortIdLookupSource(e){const t=this.dialect;if(typeof t.resolveTableResource=="function"){const n=t.resolveTableResource(e);if(n.mode==="sparql"&&n.endpoint)return{kind:"sparql",resourceUrl:n.endpoint,descriptor:n}}return null}extractSubjectFromLookupRow(e){if(!isRecord$2(e))return null;const t=e.subject??e.s??e["?subject"]??e["?s"];return typeof t=="string"?t:hasStringValue$1(t)?t.value:null}subjectMatchesShortId(e,t,n,s){const a=parsePodResourceRef(e,t);return a?a.templateValues.id===n:t.endsWith(s)}getIndexedSubject(e,t){const n=this.dialect;return typeof n.lookupIndexedResourceSubject!="function"?null:n.lookupIndexedResourceSubject(e,t)}async lookupSubjectIriByShortId(e,t,n){const s=this.resolveShortIdLookupSource(e);if(!s){const g=this.getLocatorTemplate(e)??"<exact-id>";throw new Error(`${n} cannot resolve short id '${t}' for subjectTemplate '${g}' because no resource query source is available.`)}const a=this.buildShortIdSubjectSuffix(e,t),u=t,h={type:"SELECT",query:`SELECT DISTINCT ?subject WHERE {
116
+ ${e.config?.type?`?subject ?typePredicate ?typeObject .
117
+ FILTER(?typePredicate = <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> && ?typeObject = <${e.config.type}> && CONTAINS(STR(?subject), "${escapeSparqlString(u)}"))`:`?subject ?predicate ?object .
118
+ FILTER(CONTAINS(STR(?subject), "${escapeSparqlString(u)}"))`}
119
+ }
120
+ LIMIT 50`,prefixes:{}},f=s.kind==="sparql"?await this.dialect.executeOnResource(s.resourceUrl,h,s.descriptor):await this.dialect.getSPARQLExecutor().queryContainer(s.resourceUrl,h),p=Array.from(new Set(f.map(g=>this.extractSubjectFromLookupRow(g)).filter(g=>!!g).filter(g=>this.subjectMatchesShortId(e,g,t,a))));if(p.length>1)throw new Error(`${n} found multiple resources for short id '${t}' in '${e.config?.name??"resource"}'. Use a base-relative resource id or full IRI to disambiguate.`);return p[0]??this.getIndexedSubject(e,t)}async resolveIdSubjectForExactOperation(e,t,n){return this.needsShortIdSubjectLookup(e,t)?await this.lookupSubjectIriByShortId(e,t,n):this.resolveIdSubject(e,t,n)}async findById(e,t){const n=await this.resolveIdSubjectForExactOperation(e,t,"findById");return n?await this.findByIri(e,n):null}async findByLocator(e,t){this.warnFindByLocatorDeprecation();const n=this.resolveLocatorSubject(e,t,"findByLocator");return await this.findByIri(e,n)}async findByResource(e,t){if(typeof t=="string"&&this.needsShortIdSubjectLookup(e,t))return await this.findById(e,t);const n=this.resolveResourceTargetIri(e,t,"findByResource");return await this.findByIri(e,n)}async findByIri(e,t){if(!t||typeof t!="string")throw new Error("findByIri requires a valid IRI string");const n=await this.findByIriViaExactResource(e,t);return n!==void 0?n:(await this.session.select().from(e).whereByIri(t).limit(1))[0]??null}getColumnPredicate(e,t){return t.options?.predicate??t.getPredicate?.(e.config.namespace)}async findByIriViaExactResource(e,t){if(!isPodTable(e))return;const n=this.parseIri(t).documentUrl,s=await this.readPredicateObjectRowsFromDocument(n,t);if(s===null)return null;if(s!==void 0){const h=this.mapPredicateObjectRows(e,t,s);if(h!==void 0)return h}if(typeof this.dialect.executeOnResource!="function")return;const a={type:"SELECT",query:`SELECT ?p ?o WHERE { <${t}> ?p ?o . }`,prefixes:{}};let u;try{u=await this.dialect.executeOnResource(n,a)}catch(h){if(this.isMissingExactResourceError(h))return;throw h}const c=this.mapPredicateObjectRows(e,t,u);if(c!==void 0)return c}async readPredicateObjectRowsFromDocument(e,t){const n=this.dialect.getAuthenticatedFetch;if(typeof n!="function")return;let s;try{s=await n.call(this.dialect)(e,{method:"GET",headers:{Accept:"text/turtle, application/ld+json;q=0.8, */*;q=0.1"}})}catch(c){return this.isMissingExactResourceError(c)?null:void 0}if(s.status===404)return null;if(!s.ok)return;const a=s.headers.get("content-type")??"";if(a&&!a.includes("text/turtle")&&!a.includes("application/n-triples")&&!a.includes("application/trig")&&!a.includes("application/ld+json"))return;const u=await s.text();if(!u.trim())return null;try{return new N3Parser$1({baseIRI:e,format:a.includes("application/n-triples")?"N-Triples":"text/turtle"}).parse(u).filter(f=>f.subject.termType==="NamedNode"&&f.subject.value===t).map(f=>({p:f.predicate.value,o:this.convertRdfTermToValue(f.object)}))}catch{return}}convertRdfTermToValue(e){if(e.termType==="NamedNode")return e.value;if(e.termType==="BlankNode")return`_:${e.value}`;if(e.termType!=="Literal")return e.value;const t=e.datatype?.value??"";if(t.includes("#integer")||t.includes("#int"))return parseInt(e.value,10);if(t.includes("#decimal")||t.includes("#double"))return parseFloat(e.value);if(t.includes("#boolean"))return e.value==="true";if(t.includes("#dateTime"))return new Date(e.value);if(t.includes("#json"))try{return JSON.parse(e.value)}catch{return e.value}return e.value}isMissingExactResourceError(e){if(!isRecord$2(e))return!1;if((e.status??e.statusCode)===404)return!0;const n=e.message;return typeof n=="string"&&/\b(?:HTTP status )?404\b/.test(n)}mapPredicateObjectRows(e,t,n){if(!Array.isArray(n)||n.length===0)return null;const s={subject:t,"@id":t,uri:t},a=this.extractIdFromIri(e,t);a!==void 0&&(s.id=a);let u=!1,c=!1,h=!1;for(const f of n){if(!isRecord$2(f))continue;const p=f.p??f.predicate??f["?p"],g=f.o??f.object??f["?o"];if(typeof p=="string"){p==="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"&&g===e.config.type&&(u=!0);for(const[y,S]of Object.entries(e.columns??{})){if(S._virtualId)continue;const w=this.getColumnPredicate(e,S);if(!w||w==="@id"||w!==p)continue;if(S.options?.isArray||S.dataType==="array"){const T=Array.isArray(s[y])?s[y]:s[y]===void 0?[]:[s[y]];s[y]=[...T,g]}else s[y]===void 0&&(s[y]=g);(S.dataType==="object"||S.dataType==="json")&&typeof g=="string"&&isAbsoluteIri(g)&&(h=!0),c=!0}}}if(!u&&!c)return null;if(!h)return s}extractIdFromIri(e,t){const n=parsePodResourceRef(e,t)?.resourceId;if(n)return n;try{const c=this.dialect.getResolver(e).parseId(e,t);if(c)return c}catch{}const s=e.getSubjectTemplate?.()??e.config?.subjectTemplate;if(!s)return;if(s==="{id}.ttl"){const c=t.split("/").pop()??"";return c.endsWith(".ttl")?c.slice(0,-4):c||void 0}if(s==="{id}.ttl#it"){const h=t.split("#")[0].split("/").pop()??"";return h.endsWith(".ttl")?h.slice(0,-4):h||void 0}const a=t.indexOf("#");if(a>=0&&s.includes("{id}")&&s.startsWith("#"))return decodeURIComponent(t.slice(a+1));const u=t.split("#")[0].split("/").pop()??"";return u.endsWith(".ttl")?u.slice(0,-4):void 0}parseIri(e){const t=e.indexOf("#");return t>=0?{documentUrl:e.substring(0,t),fragment:e.substring(t+1)}:{documentUrl:e,fragment:null}}async subscribeByIri(e,t,n){if(!t||typeof t!="string")throw new Error("subscribeByIri requires a valid IRI string");if(!t.startsWith("http://")&&!t.startsWith("https://"))throw new Error(`subscribeByIri requires an absolute IRI, got: ${t}`);if(!this.notificationsClient){const u=this.dialect.getAuthenticatedFetch(),c={preferredChannels:this.dialect.config.preferredChannels??["streaming-http","websocket"]};this.notificationsClient=new NotificationsClient(u,c)}const{documentUrl:s}=this.parseIri(t),a=await this.notificationsClient.subscribe(s,{channel:n.channel,features:n.features,onNotification:async u=>{try{if(u.type==="Update"){const c=await this.findByIri(e,t);c&&await n.onUpdate(c)}else u.type==="Delete"&&await n.onDelete?.()}catch(c){n.onError?.(c)}},onError:n.onError});return()=>a.unsubscribe()}async updateByIri(e,t,n){if(!t||typeof t!="string")throw new Error("updateByIri requires a valid IRI string");if(!t.startsWith("http://")&&!t.startsWith("https://"))throw new Error(`updateByIri requires an absolute IRI, got: ${t}`);const s=n;return await this.session.update(e).set(s).whereByIri(t),await this.findByIri(e,t)}async updateById(e,t,n){const s=await this.resolveIdSubjectForExactOperation(e,t,"updateById");return s?await this.updateByIri(e,s,n):null}async updateByLocator(e,t,n){const s=this.resolveLocatorSubject(e,t,"updateByLocator");return await this.updateByIri(e,s,n)}async updateByResource(e,t,n){if(typeof t=="string"&&this.needsShortIdSubjectLookup(e,t))return await this.updateById(e,t,n);const s=this.resolveResourceTargetIri(e,t,"updateByResource");return await this.updateByIri(e,s,n)}async deleteByIri(e,t){if(!t||typeof t!="string")throw new Error("deleteByIri requires a valid IRI string");if(!t.startsWith("http://")&&!t.startsWith("https://"))throw new Error(`deleteByIri requires an absolute IRI, got: ${t}`);return await this.findByIri(e,t)?(await this.session.delete(e).whereByIri(t),!0):!1}async deleteById(e,t){const n=await this.resolveIdSubjectForExactOperation(e,t,"deleteById");return n?await this.deleteByIri(e,n):!1}async deleteByLocator(e,t){const n=this.resolveLocatorSubject(e,t,"deleteByLocator");return await this.deleteByIri(e,n)}async deleteByResource(e,t){if(typeof t=="string"&&this.needsShortIdSubjectLookup(e,t))return await this.deleteById(e,t);const n=this.resolveResourceTargetIri(e,t,"deleteByResource");return await this.deleteByIri(e,n)}async transaction(e){return await this.session.transaction(async t=>{const n=new PodDatabase(this.dialect,t,this.schema);return await e(n)})}getDialect(){return this.dialect}getSession(){return this.session}getSchema(){return this.schema}get discovery(){return this.dialect.getDiscovery()}async connect(){return await this.dialect.connect()}async disconnect(){return this.notificationsClient&&this.notificationsClient.unsubscribeAll(),await this.dialect.disconnect()}async subscribe(e,t){if(!this.notificationsClient){const a=this.dialect.getAuthenticatedFetch(),u={preferredChannels:this.dialect.config.preferredChannels??["streaming-http","websocket"]};this.notificationsClient=new NotificationsClient(a,u)}const n=this.resolveResourceTopic(e,t.iri),s={channel:t.channel,features:t.features,onNotification:a=>{if(t.onNotification?.(a),!!(t.onCreate||t.onUpdate||t.onDelete||t.onAdd||t.onRemove)){const c={id:a.id,type:a.type,object:a.object,published:a.published,state:a.state};switch(a.type){case"Create":t.onCreate?.(c);break;case"Update":t.onUpdate?.(c);break;case"Delete":t.onDelete?.(c);break;case"Add":t.onAdd?.(c);break;case"Remove":t.onRemove?.(c);break}}},onError:t.onError,onClose:t.onClose};return this.notificationsClient.subscribe(n,s)}resolveResourceTopic(e,t){if(t){if(!t.startsWith("http://")&&!t.startsWith("https://"))throw new Error(`iri must be an absolute URL, got: ${t}`);return t}const n=e.config.base||"";if(n.startsWith("http://")||n.startsWith("https://"))return n;const s=this.dialect.getPodUrl(),a=s.endsWith("/")?s:`${s}/`,u=n.startsWith("/")?n.slice(1):n;return`${a}${u}`}getConfig(){return this.dialect.getConfig()}async discoverTable(e){const t=await this.dialect.discoverDataLocations(e);if(t.length===0)return console.log(`[discoverTable] No data locations found for ${e}`),null;const n=t[0],s=n.shapes[0]?.url;if(console.log(`[discoverTable] Found location: ${n.container}, shape: ${s||"none"}`),s){const f=this.dialect.getShapeManager(),p=await f.loadShape(s,this.dialect.getAuthenticatedFetch());if(p){console.log(`[discoverTable] Loaded shape with ${p.properties.length} properties`);const g=f.shapeToTable(p,n.container);return await this.init(g.table),g.table}}console.log("[discoverTable] No shape available, creating basic table");const{podTable:a,string:u}=await __vitePreload(async()=>{const{podTable:f,string:p}=await Promise.resolve().then(()=>index);return{podTable:f,string:p}},[]),c=this.extractClassName(e),h=a(c,{id:u("id").primaryKey()},{type:e,base:n.container});return await this.init(h),h}async discoverTables(e){const t=[];for(const n of e){const s=await this.discoverTable(n);s&&t.push(s)}return t}async discover(e,t){return this.dialect.discoverDataLocations(e,t)}async discoverAll(){return this.dialect.discoverAll()}async discoverByApp(e){return this.dialect.discoverByApp(e)}async locationToTable(e,t){const n=t??{};let s;if(n.shape)typeof n.shape=="string"?(s=e.shapes.find(f=>f.url===n.shape),s||(s={url:n.shape,source:"config"})):s=n.shape;else if(n.appId){if(s=e.shapes.find(f=>f.registeredBy===n.appId),!s)throw new Error(`[locationToTable] No shape found for appId: ${n.appId}`)}else s=e.shapes[0];if(s?.url){const f=this.dialect.getShapeManager(),p=await f.loadShape(s.url,this.dialect.getAuthenticatedFetch());if(p){console.log(`[locationToTable] Loaded shape: ${s.url} (${p.properties.length} properties)`),s.registeredBy&&console.log(`[locationToTable] -> registeredBy: ${s.registeredBy}`);const g=f.shapeToTable(p,e.container);return await this.init(g.table),g.table}}console.log(`[locationToTable] No shape available, creating basic table for container: ${e.container}`);const{podTable:a,string:u}=await __vitePreload(async()=>{const{podTable:f,string:p}=await Promise.resolve().then(()=>index);return{podTable:f,string:p}},void 0),c=this.extractContainerName(e.container),h=a(c,{id:u("id").primaryKey()},{type:"http://www.w3.org/2000/01/rdf-schema#Resource",base:e.container});return await this.init(h),h}extractContainerName(e){const t=e.replace(/\/$/,""),n=t.lastIndexOf("/");return n>=0&&t.substring(n+1).toLowerCase()||"data"}async discoverTablesFor(e,t,n){const s=await this.discover(e,t),a=[];for(const u of s){const c=await this.locationToTable(u,n);a.push(c)}return a}extractClassName(e){const t=e.lastIndexOf("#");if(t>=0)return e.substring(t+1).toLowerCase();const n=e.lastIndexOf("/");return n>=0?e.substring(n+1).toLowerCase():e.toLowerCase()}addSource(e){this.dialect.addSource(e)}removeSource(e){this.dialect.removeSource(e)}getSources(){return this.dialect.getSources()}async addSourcesFromTypeIndex(){return await this.dialect.addSourcesFromTypeIndex()}async init(...e){let t,n;const s=e[e.length-1];s&&typeof s=="object"&&!Array.isArray(s)&&!("columns"in s)?(t=s,n=e.slice(0,-1)):n=e;const a=[];for(const u of n)if(u)if(Array.isArray(u))for(const c of u)c&&a.push(c);else a.push(u);for(const u of a)if(typeof u.init=="function"?await u.init(this.dialect):await this.dialect.registerTable(u),t?.generateShape||t?.saveShape){const c=this.dialect.getShapeManager(),h=c.generateShape(u);if(t?.saveShape){const f=this.dialect.getPodUrl();let p=t.shapeLocation;p?p.startsWith("http")||(p=`${f}${p.replace(/^\//,"")}`):p=`${f}shapes/`,p.endsWith("/")||(p+="/");const g=`${p}${u.config.name}Shape.ttl`;try{await c.saveShape(h,g),console.log(`[init] Shape saved to: ${g}`)}catch(y){console.warn(`[init] Failed to save Shape to ${g}:`,y)}}}}get query(){return this.queryProxy||(this.queryProxy=this.buildQueryProxy()),this.queryProxy}buildQueryProxy(){const e=this.schema&&typeof this.schema=="object"?Object.entries(this.schema):[],t=new Map;for(const[a,u]of e)isPodTable(u)&&t.set(a,u);const n=(a,u)=>{const c=x=>{let D=null;const O=()=>(D||(D=x()),D);return{then:(K,z)=>O().then(K,z),catch:K=>O().catch(K),finally:K=>O().finally(K),[Symbol.toStringTag]:"Promise"}},h=(x,D,O)=>{const K={};for(const[z,X]of Object.entries(D)){if(X instanceof PodColumnBase){K[z]=x[X.name];continue}if(typeof X=="string"){K[z]=x[X]??x[X.split(".").pop()??X];continue}const Ee=X?.name;if(typeof Ee=="string"){K[z]=x[Ee];continue}K[z]=x[z]}if(O)for(const z of Object.keys(O))K[z]=x[z]??[];return K},f=async x=>{this.clearFederatedErrors();let D=this.session.select().from(u);x?.where&&(D=D.where(x.where)),x?.orderBy&&(Array.isArray(x.orderBy)?x.orderBy:[x.orderBy]).forEach(X=>{D=D.orderBy(X.column,X.direction??"asc")}),typeof x?.limit=="number"&&(D=D.limit(x.limit)),typeof x?.offset=="number"&&(D=D.offset(x.offset));let O=await D;x?.with&&Object.keys(x.with).length>0&&(O=await this.eagerLoadWith(O,u,x.with,t));const K=x?.columns;return K&&(O=O.map(z=>h(z,K,x.with))),O},p=x=>c(()=>f(x)),g=async(x,D)=>{if(!x)return null;let O=[x];D?.with&&Object.keys(D.with).length>0&&(O=await this.eagerLoadWith(O,u,D.with,t));const K=D?.columns;return K&&(O=O.map(z=>h(z,K,D.with))),O[0]??null},y=x=>c(async()=>(await f({...x,limit:1}))[0]??null),S=x=>c(async()=>(await f({where:x?.where,columns:void 0,limit:void 0,offset:void 0})).length),w=()=>(x,D)=>c(async()=>await g(await this.findByLocator(u,x),D)),R=()=>(x,D)=>c(async()=>await g(await this.findById(u,x),D)),T=()=>(x,D)=>c(async()=>await g(await this.findByIri(u,x),D)),A=()=>(x,D)=>c(async()=>await g(await this.findByResource(u,x),D));return{findMany:p,findFirst:y,find:(x,D)=>A()(x,D),findById:R(),findByLocator:w(),findByIri:T(),findByResource:A(),count:S}},s={};return new Proxy(s,{get:(a,u)=>{if(typeof u!="string")return;const c=t.get(u);if(c)return n(u,c)}})}async eagerLoadWith(e,t,n,s){if(!e||e.length===0)return e;const a=this.dedupeBySubject(e);for(const[u,c]of Object.entries(n)){if(!c)continue;const h=t.relations?.[u],f=typeof c=="object"&&c.table?c.table:h?.table??s.get(u);if(!f)continue;if(isSolidSchema(f)||h?.isFederated){if(h&&h.discover)try{const X=await this.getFederatedExecutor().execute(a,{...h,relationName:u});X.errors&&X.errors.length>0&&this.lastFederatedErrors.push(...X.errors)}catch(z){console.warn(`Federated relation "${u}" failed:`,z),a.forEach(X=>{X[u]=[]})}else console.warn(`Federated relation "${u}" missing discover function, skipping.`),a.forEach(z=>{z[u]=[]});continue}const p=f,g=p.config.type,y=h?.fields&&h.fields.length>0?h.fields:Object.values(p.columns??{}),S=z=>!!(z&&(z.options?.linkTarget===t.config.type||z.options?.linkTable===t||z.getLinkTable?.()===t)),w=z=>!!(z&&(z.options?.linkTarget===g||z.options?.linkTable===p||z.getLinkTable?.()===p)),R=h?.fields&&h.fields.length>0?y:y.filter(z=>S(z)&&!z.isInverse?.());if(R.length===0){const X=(h?.references??[]).filter(ye=>!!(ye&&typeof ye.isInverse=="function"&&ye.isInverse()&&w(ye))),Ee=Object.values(t.columns??{}),q=(X.length>0?X:Ee).filter(ye=>typeof ye.isInverse=="function"&&ye.isInverse()&&w(ye));if(q.length===0)continue;const Y=a.map(ye=>this.collectInverseLinkValues(ye,q)),Te=Array.from(new Set(Y.flat().filter(ye=>typeof ye=="string"&&ye.length>0)));if(Te.length===0){e.forEach(ye=>{ye[u]=[]});continue}let re=this.session.select().from(p);re=re.whereByIri(Te);const $e=await re,ze=this.groupRowsByIri($e);a.forEach((ye,Ve)=>{const pe=Y[Ve],De=[];pe.forEach($=>{const G=ze.get($);G&&G.length>0&&De.push(...G)}),ye[u]=De});continue}const T=R[0],A=h?.references&&h.references[0],F=T.isLink(),x=a.map(z=>this.resolveParentKey(z,A,F)).filter(z=>typeof z=="string"&&z.length>0);if(x.length===0)continue;let D=this.session.select().from(p);F?D=D.where(inArray(T,x)):D=D.where({[T.name]:x});const O=await D,K=new Map;for(const z of O){const X=z[T.name],Ee=this.normalizeLiteralValue(X),q=F?this.collectLinkLookupKeys(X):Ee?[Ee]:[];for(const Y of q){const Te=K.get(Y)??[];Te.push(z),K.set(Y,Te)}}a.forEach(z=>{const X=F?Array.from(new Set([this.resolveParentKey(z,A,!0),this.resolveIdFromRow(z)].filter(q=>typeof q=="string"&&q.length>0))):[this.resolveParentKey(z,A,!1)].filter(q=>typeof q=="string"&&q.length>0),Ee=[];for(const q of X){const Y=K.get(q)??[];for(const Te of Y)Ee.includes(Te)||Ee.push(Te)}z[u]=Ee})}return a}dedupeBySubject(e){const t=new Map,n=[];for(const s of e){const a=this.resolveIriFromRow(s)??this.resolveIdFromRow(s);if(!a){n.push(`__anon_${n.length}`),t.set(n[n.length-1],{...s});continue}if(!t.has(a)){t.set(a,{...s}),n.push(a);continue}const u=t.get(a);if(u)for(const[c,h]of Object.entries(s)){if(h===void 0)continue;const f=u[c];if(f===void 0){u[c]=h;continue}const p=Array.isArray(f)?f:[f],g=Array.isArray(h)?h:[h],y=[...p];for(const S of g)y.some(w=>w===S)||y.push(S);u[c]=y.length===1?y[0]:y}}return n.map(s=>t.get(s)).filter(s=>s!==void 0)}resolveIdFromRow(e){if(!e)return;if(typeof e.id=="string"&&e.id.length>0)return e.id;const t=typeof e["@id"]=="string"?e["@id"]:void 0;if(t)return this.extractFragment(t)}resolveParentKey(e,t,n){if(t){const s=e[t.name];return n?this.normalizeLinkValue(s):this.normalizeLiteralValue(s)}return n?this.resolveIriFromRow(e):this.resolveIdFromRow(e)}resolveIriFromRow(e){if(e){if(typeof e["@id"]=="string"&&e["@id"].length>0)return e["@id"];if(typeof e.subject=="string"&&e.subject.length>0)return e.subject}}collectLinkLookupKeys(e){const t=[],n=this.normalizeLinkValue(e)??this.normalizeLiteralValue(e);if(n){t.push(n);const s=this.extractFragment(n);s&&!t.includes(s)&&t.push(s)}return t}normalizeLinkValue(e){if(e){if(typeof e=="string")return e;if(hasStringValue$1(e))return e.value}}normalizeLiteralValue(e){if(e!=null){if(typeof e=="string")return e;if(hasStringValue$1(e))return e.value}}collectInverseLinkValues(e,t){if(!t.length)return[];const n=[];for(const s of t){const a=e[s.name];if(a==null)continue;const u=c=>{const h=this.normalizeLinkValue(c)??(typeof c=="string"?c:void 0);h&&n.push(h)};Array.isArray(a)?a.forEach(u):u(a)}return n}groupRowsByIri(e){const t=new Map;for(const n of e){const s=this.normalizeLinkValue(n["@id"])??this.normalizeLinkValue(n.uri)??(typeof n["@id"]=="string"?n["@id"]:void 0);if(!s)continue;const a=t.get(s)??[];a.push(n),t.set(s,a)}return t}extractFragment(e){const t=e.includes("#")?e.split("#").pop():void 0;return t&&t.length>0?t:e.split("/").pop()??e}}_a$8=entityKind;PodDatabase[_a$8]="PodDatabase";PodDatabase.findByLocatorDeprecationWarned=!1;function isAggregateExpression(i){return!!i&&typeof i=="object"&&i.kind==="aggregate"}function inferSPARQLQueryType(i){const n=i.replace(/^\s*#.*$/gm,"").trim().replace(/^(?:\s*(?:PREFIX|BASE)\s+[^\n]+\n)*/i,"").trim().match(/^(SELECT|ASK|INSERT|DELETE|UPDATE|WITH|LOAD|CLEAR|CREATE|DROP|COPY|MOVE|ADD|CONSTRUCT|DESCRIBE)\b/i)?.[1]?.toUpperCase();switch(n){case"SELECT":case"ASK":case"INSERT":case"DELETE":case"UPDATE":return n;case"WITH":case"LOAD":case"CLEAR":case"CREATE":case"DROP":case"COPY":case"MOVE":case"ADD":return"UPDATE";default:return}}function createLiteralCondition(i,e,t){const n=i?`${i}.${e}`:e;return t==null?new UnaryExpression("IS NULL",n):Array.isArray(t)?new BinaryExpression(n,"IN",t):new BinaryExpression(n,"=",t)}function buildConditionTreeFromObject(i,e){if(!i)return;const t=Object.entries(i);if(t.length===0)return;const n=t.map(([s,a])=>createLiteralCondition(e,s,a));return n.length===1?n[0]:new LogicalExpression("AND",n)}function resolveRowSubject(i){if(!(!i||typeof i!="object")){if(typeof i["@id"]=="string"&&i["@id"].length>0)return i["@id"];if(typeof i.subject=="string"&&i.subject.length>0)return i.subject;if(typeof i.uri=="string"&&i.uri.length>0)return i.uri;if(typeof i.source=="string"&&i.source.length>0)return i.source;if(typeof i.id=="string"&&i.id.length>0)return i.id}}function orderRowsBySubjects(i,e){if(!i.length||!e.length)return i;const t=new Map,n=[];for(const a of i){const u=resolveRowSubject(a);if(!u){n.push(a);continue}const c=t.get(u)??[];c.push(a),t.set(u,c)}const s=[];for(const a of e){const u=t.get(a);u?.length&&(s.push(...u),t.delete(a))}for(const a of t.values())s.push(...a);return s.push(...n),s}function isSelectFieldMap(i){return!!i&&typeof i=="object"&&!(i instanceof PodColumnBase)&&!(i instanceof PodTable)&&!("aggregateType"in i)}function resolveFieldBindingCandidates(i,e){const t=new Set;if(typeof e=="string"){if(t.add(e),e.includes(".")){const[n,s]=e.split(".",2);s&&(t.add(`${n}.${s}`),t.add(s))}}else e instanceof PodColumnBase&&(e.table?.config?.name&&t.add(`${e.table.config.name}.${e.name}`),t.add(e.name));return Array.from(t)}function isEmptyProjectedValue(i){if(i==null)return!0;if(Array.isArray(i))return i.length===0;if(typeof i=="object"){const e=Object.values(i);return e.length>0&&e.every(t=>isEmptyProjectedValue(t))}return!1}function projectTableRow(i,e){const t=e.config.name,n={};let s=!1;for(const a of Object.keys(e.columns)){const c=(t?[`${t}.${a}`,a]:[a]).find(h=>i[h]!==void 0);n[a]=c?i[c]:void 0,n[a]!==void 0&&(s=!0)}return s?n:null}function projectFieldValue(i,e,t){if(t instanceof PodTable)return projectTableRow(i,t);if(isSelectFieldMap(t)){const n={};for(const[s,a]of Object.entries(t))n[s]=projectFieldValue(i,s,a);return isEmptyProjectedValue(n)?null:n}for(const n of resolveFieldBindingCandidates(e,t))if(i[n]!==void 0)return i[n];return i[e]}function projectReturningRow(i,e){if(!e||e===!0)return i;const t={};for(const[n,s]of Object.entries(e))t[n]=projectFieldValue(i,n,s);return t}function projectReturningRows(i,e){return!e||e===!0?i:i.map(t=>projectReturningRow(t,e))}const UUID_REGEX=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,SINGLETON_FRAGMENTS=new Set(["#me","#this","#profile","#card"]);class UriResolverImpl{constructor(e=""){this.podUrl=e.replace(/\/$/,"")}setPodUrl(e){this.podUrl=e.replace(/\/$/,"")}resolveSubject(e,t,n,s){const a=s?.strict??!0,u=t["@id"]??t.id??t.uri;if(typeof u=="string"){if(this.isAbsoluteUri(u))return u;const p=this.resolveBaseRelativeSubjectId(e,u);if(p)return p;u.startsWith("#")&&this.acceptsFragmentOnlyResourceId(e)&&(t={...t,id:u.slice(1)})}const c=this.getEffectivePattern(e),h=this.getSubjectBaseUrl(e);if(this.isSingleton(e))return this.combineBaseAndPattern(h,c);const f=this.applyTemplate(c,t,n,e,a);return f===null?this.generateFallbackUri(h,c,n):this.isAbsoluteUri(f)?f:this.combineBaseAndPattern(h,f)}parseSubject(e,t){if(!e)return null;const n=e.indexOf("#"),s=n!==-1,a=s?e.slice(0,n):e,u=s?e.slice(n+1):void 0,c=this.extractPublicId(e,t),h=this.getResourceMode(t);return{uri:e,resourceUrl:a,fragment:u,id:c,mode:h}}getResourceUrl(e){const t=e.indexOf("#");return t!==-1?e.slice(0,t):e}getResourceMode(e){if(!(e.hasCustomTemplate?.()??!1)){const s=e.config?.base??"";return/\.(ttl|jsonld|json)$/i.test(s)?"fragment":"document"}return(e.config?.subjectTemplate??this.getDefaultPattern(e)).startsWith("#")?"fragment":"document"}getDefaultPattern(e){return"{id}"}resolveInlineChild(e,t,n,s){const a=n["@id"]??n.id;return typeof a=="string"?a:`${this.getResourceUrl(e)}#${t}-${s+1}`}isSingleton(e){const t=e.config?.subjectTemplate;return t?!!(SINGLETON_FRAGMENTS.has(t)||!t.includes("{")):!1}resolveLink(e,t,n){const s=String(e??""),a=n?.record&&typeof n.record=="object"?n.record:void 0;if(this.isAbsoluteUri(s))return s;if(s.startsWith("/")||s.startsWith("#")){const p=n?.baseUri||this.podUrl;if(p)try{return new URL(s,p).toString()}catch{}throw new Error(`Cannot resolve relative URI "${s}": no baseUri configured`)}const u=t.getLinkTable?.();if(u){const p=this.getTableUriInfo(u);if(p)return this.buildFullUri(s,p.baseUrl,p.subjectTemplate,u,n,a);throw new Error(`Cannot resolve URI "${s}": linked table "${u.config?.name}" has no base configured.`)}const c=t.getLinkTableName?.();if(c){if(n?.tableNameRegistry){const g=n.tableNameRegistry.get(c);if(g){const y=this.getTableUriInfo(g);if(y)return this.buildFullUri(s,y.baseUrl,y.subjectTemplate,g,n,a)}}const p=n?.tableNameRegistry?Array.from(n.tableNameRegistry.keys()).join(", "):"(no tables registered)";throw new Error(`Cannot resolve URI "${s}": table "${c}" not found in schema. Available tables: ${p}`)}const h=t.getLinkTarget?.();if(h){if(!n?.tableRegistry)throw new Error(`Cannot resolve URI "${s}" (links to ${h}): tableRegistry not configured. Ensure the schema is properly registered.`);const p=n.tableRegistry.get(h);if(p&&p.length>0){if(p.length>1){const S=p.map(w=>w.config?.name||"unknown").join(", ");throw new Error(`Ambiguous link target: class "${h}" has multiple tables [${S}]. Use .link('tableName') or .link(tableObject) to specify which table to use.`)}const g=p[0],y=this.getTableUriInfo(g);if(y)return this.buildFullUri(s,y.baseUrl,y.subjectTemplate,g,n,a)}throw new Error(`Cannot resolve URI "${s}": class "${h}" not found in tableRegistry. Available classes: ${Array.from(n.tableRegistry.keys()).join(", ")||"(none)"}`)}const f=n?.baseUri||this.podUrl;if(f&&this.isAbsoluteUri(f)){const p=f.endsWith("/")?f:`${f}/`;return this.buildFullUri(s,p)}throw new Error(`Cannot resolve URI "${s}". Either provide a full URI (https://...), or configure baseUri.`)}isAbsoluteUri(e){return!e||typeof e!="string"?!1:e.includes(":")&&(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("urn:")||e.startsWith("did:")||e.startsWith("mailto:")||e.startsWith("tel:")||e.startsWith("file://")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e))}isLinkColumn(e){return e?e.dataType==="uri"||e.isLink?.()||!!e.options?.linkTarget||!!e.options?.linkTableName||!!e.options?.linkTable:!1}findTargetTable(e,t){const n=e.getLinkTable?.()||e.options?.linkTable;if(n)return n;const s=e.getLinkTableName?.()||e.options?.linkTableName;if(s&&t?.tableNameRegistry){const u=t.tableNameRegistry.get(s);if(u)return u}const a=e.getLinkTarget?.()||e.options?.linkTarget;if(a&&t?.tableRegistry){const u=t.tableRegistry.get(a);if(u&&u.length===1)return u[0]}}extractLinkId(e,t,n){if(e?.startsWith("/")){const u=n?.baseUri||this.podUrl;if(u){const c=u.endsWith("/")?u:`${u}/`;e=new URL(e.replace(/^\/+/,""),c).toString()}}if(!e||!this.isAbsoluteUri(e))return e;const s=this.findTargetTable(t,n);if(!s)return e;const a=this.extractTemplateIdFromSubject(e,s);return a||e}getTableUriInfo(e){const t=e.config?.base;if(!t)return;const n=e.config?.subjectTemplate;return{baseUrl:this.toAbsoluteUrl(t),subjectTemplate:n}}buildFullUri(e,t,n,s,a,u){const c=String(e??"");if(!n){const y=this.combineBaseAndResourceId(t,c);return this.assertNoUnresolvedTemplate(y,void 0,s),y}if(!UUID_REGEX.test(c)&&c.includes("/")&&!c.includes("{")){const y=`${t}${c}`;return this.assertNoUnresolvedTemplate(y,n,s),y}const h=this.buildTemplateRecord(c,n,s,a,u),f=this.applyTemplate(n,h,void 0,s,!0,a);if(f===null)throw new Error(`[UriResolver] Failed to resolve URI template "${n}" for table "${s?.config?.name??"unknown"}"`);if(this.isAbsoluteUri(f))return this.assertNoUnresolvedTemplate(f,n,s),f;if(f.startsWith("#")){const S=`${t.endsWith("/")?t.slice(0,-1):t}${f}`;return this.assertNoUnresolvedTemplate(S,n,s),S}const g=`${t.endsWith("/")?t:`${t}/`}${f}`;return this.assertNoUnresolvedTemplate(g,n,s),g}buildTemplateRecord(e,t,n,s,a){const u={...a??{}};u.id=e;for(const c of t.matchAll(/\{([^}]+)\}/g)){const f=this.parseTemplateVariable(c[1]).field;if(f==="id"||f==="index"||f in u)continue;const p=this.resolveTemplateVariable(f,n,s,a);p!=null&&p!==""&&(u[f]=p)}return u}resolveTemplateVariable(e,t,n,s){if(!s||typeof s!="object")return;if(e in s){const h=t?.columns?.[e];return this.normalizeValue(s[e],h,n)}const a=`${e}Id`;if(a in s)return String(s[a]);const u=t?.columns?.[e],c=u?this.findTargetTable(u,n):void 0;if(c)for(const[h,f]of Object.entries(s)){const p=n?.currentTable?.columns?.[h];if((p?this.findTargetTable(p,n):void 0)===c)return this.normalizeValue(f,u,n)}}assertNoUnresolvedTemplate(e,t,n){if(/\{[^}]+\}/.test(e)){const s=n?.config?.name||"unknown";throw new Error(`[UriResolver] Unresolved URI template variable while resolving table "${s}" with template "${t??"<exact-id>"}": ${e}`)}}getEffectivePattern(e){if(e.hasCustomTemplate?.()??!1){const n=e.config?.subjectTemplate;if(n&&n.trim().length>0)return n}return this.getDefaultPattern(e)}getSubjectBaseUrl(e){const t=e.config?.base??"";return this.toAbsoluteUrl(t)}isBaseRelativeSubjectId(e){return!e||this.isAbsoluteUri(e)||e.startsWith("/")?!1:e.startsWith("#")||e.includes("#")||/\.(ttl|jsonld|json)(?:#|$)/i.test(e)}acceptsFragmentOnlyResourceId(e){const t=e.config?.subjectTemplate;if(!t)return!1;const n=Array.from(t.matchAll(/\{([^}]+)\}/g)).map(s=>this.parseTemplateVariable(s[1]).field);return t==="#{id}"||t.startsWith("#")&&n.length===1&&n[0]==="id"}resolveBaseRelativeSubjectId(e,t){if(!this.isBaseRelativeSubjectId(t))return null;const n=this.getSubjectBaseUrl(e);if(t.startsWith("#"))return this.acceptsFragmentOnlyResourceId(e)?`${n}${t}`:null;if(n.endsWith("/"))return`${n}${t}`;const s=n.lastIndexOf("/");return`${s>=0?n.slice(0,s+1):`${n}/`}${t}`}toAbsoluteUrl(e){if(!e)return this.podUrl;if(this.isAbsoluteUri(e))return e;const t=e.startsWith("/")?e:`/${e}`;return`${this.podUrl}${t}`}combineBaseAndPattern(e,t){return t.startsWith("#")?`${e.endsWith("/")?e.slice(0,-1):e}${t}`:e.endsWith("/")?`${e}${t}`:(e.endsWith(".ttl")||e.endsWith(".jsonld"))&&t.startsWith("#")?`${e}${t}`:`${e}/${t}`}combineBaseAndResourceId(e,t){return t.startsWith("#")?`${e.endsWith("/")?e.slice(0,-1):e}${t}`:`${e.endsWith("/")?e:`${e}/`}${t}`}normalizeValue(e,t,n){return e==null?"":typeof e=="string"&&this.isAbsoluteUri(e)&&t&&this.isLinkColumn(t)?this.extractLinkId(e,t,n):String(e)}parseTemplateVariable(e){const[t,...n]=e.split("|").map(s=>s.trim()).filter(Boolean);return{raw:e,field:t||e,transforms:n}}slugifyValue(e){return e.normalize("NFKC").toLowerCase().replace(/[^\p{Letter}\p{Number}]+/gu,"-").replace(/^-+|-+$/g,"")}applyTransforms(e,t,n,s){let a=this.normalizeValue(e,n,s);for(const u of t.transforms){if(u==="id"){a=n&&this.isLinkColumn(n)?this.extractLinkId(a,n,s):a;continue}u==="slug"&&(a=this.slugifyValue(a))}return a}applyTemplate(e,t,n,s,a=!0,u){if(!e.includes("{"))return e;const c=this.createTimeContext(t),h=[],f=e.replace(/(#?)\{([^}]+)\}/g,(p,g,y)=>{const S=this.parseTemplateVariable(y),w=S.field;if(w in c)return g+c[w];if(w==="index"&&n!==void 0)return g+String(n+1);let R=t[w];if(w==="id"&&R==null&&(R=t["@id"]??t.uri),R==null)return h.push(y),p;const T=s?.columns?.[w],A=u??(s?{tableRegistry:s[Symbol.for("drizzle:tableRegistry")],tableNameRegistry:s[Symbol.for("drizzle:tableNameRegistry")]}:void 0),F=this.applyTransforms(R,S,T,A);return g==="#"&&F.startsWith("#")?g+F.slice(1):g+F});if(h.length>0){if(a){const p=s?.config?.name||"unknown";throw new Error(`[UriResolver] Missing required fields for template "${e}" in table "${p}": [${h.join(", ")}]. Record keys: [${Object.keys(t).join(", ")}]. Record: ${JSON.stringify(t)}`)}return null}return f}createTimeContext(e){let t;const n=e.createdAt??e.created_at??e.dateCreated;n instanceof Date?t=n:typeof n=="string"||typeof n=="number"?t=new Date(n):t=new Date;const s=t.getUTCFullYear().toString(),a=(t.getUTCMonth()+1).toString().padStart(2,"0"),u=t.getUTCDate().toString().padStart(2,"0"),c=Math.floor(t.getTime()/1e3).toString();return{date:t,yyyy:s,MM:a,dd:u,timestamp:c}}generateFallbackUri(e,t,n){const s=n!==void 0?`row-${n+1}`:`row-${Date.now()}`;return t.startsWith("#")?`${e.endsWith("/")?e.slice(0,-1):e}#${s}`:`${e.endsWith("/")?e:`${e}/`}${s}.ttl`}extractRelativeSubjectId(e,t){const n=t.config?.base??"";let s="";if(n&&e.includes(n)){const a=e.indexOf(n);s=e.substring(a+n.length),s.startsWith("#")&&!(t.hasCustomTemplate?.()??!1)&&(s=`${n.split("/").filter(Boolean).pop()??""}${s}`),s.startsWith("/")&&(s=s.substring(1))}else if(!n)s=e;else return console.warn(`[UriResolver] Cannot extract ID: base "${n}" not found in URI "${e}"`),"";return s}extractPublicId(e,t){return this.extractTemplateIdFromSubject(e,t)??this.extractRelativeSubjectId(e,t)}extractTemplateIdFromSubject(e,t){const n=this.extractRelativeSubjectId(e,t),s=t.config?.subjectTemplate;return s?this.extractIdFromTemplate(n,s):n}extractIdFromTemplate(e,t){let n=t.replace(/[.+?^$[\]\\()]/g,"\\$&").replace(/\{id\}/g,"(?<id>.+?)").replace(/\{[^}]+\}/g,"(?:.+?)");n=`^${n}$`;try{const s=new RegExp(n),a=e.match(s);if(a&&a.groups?.id)return a.groups.id;if(a&&a[1])return a[1]}catch{}return null}}function isOrderByExpression(i){if(!i||typeof i!="object")return!1;const e=i;return"column"in e&&(e.direction==="asc"||e.direction==="desc")}function isReservedIdentifierKey(i){return i==="id"||i==="@id"||i.endsWith(".id")||i.endsWith(".@id")}function isReservedIdentifierOperand(i){if(i instanceof PodColumnBase){const e=i;return i.name==="id"||i.options?.predicate==="@id"||e._virtualId===!0}return typeof i=="string"?isReservedIdentifierKey(i):!1}function conditionTargetsReservedIdentifier(i){return i.type==="binary_expr"?!!(isReservedIdentifierOperand(i.left)||isReservedIdentifierOperand(i.right)):i.type==="logical_expr"?i.expressions.some(e=>e!=null&&typeof e=="object"&&"type"in e&&conditionTargetsReservedIdentifier(e)):i.type==="unary_expr"?i.value!=null&&typeof i.value=="object"&&"type"in i.value&&conditionTargetsReservedIdentifier(i.value):!1}function createWhereIdentifierError(i){switch(i){case"select":return["Using 'id' or '@id' in where() is not supported.","Use findById(id) for base-relative resource ids,","or findByIri(iri) for full IRI exact lookups."].join(" ");case"update":return["Using 'id' or '@id' in where() is not supported.","Use updateById(id, data) for base-relative resource ids,","or updateByIri(iri, data) for full IRI exact updates."].join(" ");case"delete":return["Using 'id' or '@id' in where() is not supported.","Use deleteById(id) for base-relative resource ids,","or deleteByIri(iri) for full IRI exact deletes."].join(" ")}}function assertPublicWhereObject(i,e){if(e){for(const t of Object.keys(e))if(isReservedIdentifierKey(t))throw new Error(createWhereIdentifierError(i))}}function assertPublicWhereCondition(i,e){if(conditionTargetsReservedIdentifier(e))throw new Error(createWhereIdentifierError(i))}var define_process_env_default$2={},_a$7;class SelectQueryBuilder{constructor(e,t){this.session=e,this.joins=[],this.orderByClauses=[],this.isDistinct=!1,this.tableAliases=new Map,this.aliasToTable=new Map,this.aliasUsage=new Map,this.joinFilters=[],this.groupByColumns=[],t&&this.setSelectedFields(t)}from(e){return this.selectedTable=e,this.primaryAlias=this.ensureAliasForTable(e),this}columns(e){return this.setSelectedFields(e),this}setSelectedFields(e){this.selectedFields={...e}}where(e){return e instanceof SQL?this.sql=e:this.isQueryCondition(e)?(assertPublicWhereCondition("select",e),this.processQueryCondition(e)):(assertPublicWhereObject("select",e),this.processWhereObject(e)),this}whereByIri(e){return this.processWhereObject({"@id":e}),this}isQueryCondition(e){return e&&typeof e=="object"&&"type"in e&&"operator"in e}convertQueryConditionToSimple(e){if(e.type==="binary_expr"){const t=e.left,n=e.right,s=e.operator,a=typeof t=="string"?t:t?.name;if(s==="="&&a&&n!==void 0)return{[a]:n}}if(e.type==="logical_expr"){const t=e.operator,n=e.expressions;if(t==="AND"&&n){const s={};for(const a of n){const u=this.convertQueryConditionToSimple(a);if(!u||Object.keys(u).length===0)return{};for(const[c,h]of Object.entries(u))s[c]=h}return s}}return{}}extractTableFromCondition(e){if(e.type==="binary_expr"){const t=e.left;if(t&&typeof t=="object"&&"table"in t){const n=t.table;if(n)return this.tableAliases.get(n)}if(typeof t=="string"&&t.includes("."))return t.split(".")[0]}}leftJoin(e,t){return this.addJoin("leftJoin",e,t)}rightJoin(e,t){return this.addJoin("rightJoin",e,t)}innerJoin(e,t){return this.addJoin("innerJoin",e,t)}fullJoin(e,t){return this.addJoin("fullJoin",e,t)}crossJoin(e){return this.addJoin("crossJoin",e)}groupBy(...e){const t=e.map(n=>this.resolveColumnReference(n));return this.groupByColumns.push(...t),this}having(e){return this.havingCondition=typeof e=="function"?e(this.createSelectedFieldAliases()):e,this}createSelectedFieldAliases(){const e={};for(const t of Object.keys(this.selectedFields??{}))e[t]=new SelectionAliasExpression(t);return e}addJoin(e,t,n){if(e==="rightJoin"||e==="fullJoin")throw new Error(`${e} is not yet supported in Solid dialect`);const s=this.ensureAliasForTable(t),a=e==="crossJoin"?void 0:this.resolveJoinConditions(n,s);return this.joins.push({type:e,table:t,alias:s,rawCondition:n,resolvedConditions:a}),this}ensureAliasForTable(e){const t=this.tableAliases.get(e);if(t)return t;const n=e.config.name||"table",s=this.aliasUsage.get(n)??0,a=s+1;this.aliasUsage.set(n,a);const u=s===0?n:`${n}_${a}`;return this.tableAliases.set(e,u),this.aliasToTable.set(u,e),u}resolveJoinConditions(e,t){if(this.isQueryCondition(e))return this.resolveJoinConditionExpression(e,t);if(!e||typeof e!="object")throw new Error("JOIN condition must be an equality expression or column mapping");const n=Object.entries(e);if(n.length===0)throw new Error("JOIN condition cannot be empty");return n.map(([s,a])=>{const u=this.resolveColumnReference(s),c=this.resolveColumnReference(a);if(u.alias!==t&&c.alias!==t)throw new Error("JOIN condition must reference the joined table in at least one side");return{left:u,right:c}})}resolveJoinConditionExpression(e,t){if(e.type==="logical_expr"){const a=(e.operator??"").toUpperCase(),u=e.expressions??[];if(a!=="AND"||u.length===0)throw new Error("JOIN condition only supports equality expressions combined with AND");return u.flatMap(c=>this.resolveJoinConditionExpression(c,t))}if(e.type!=="binary_expr"||e.operator!=="=")throw new Error("JOIN condition only supports equality expressions");const n=this.getConditionColumnReference(e.left),s=this.getConditionColumnReference(e.right);if(!n||!s)throw new Error("JOIN equality must compare two table columns");if(n.alias!==t&&s.alias!==t)throw new Error("JOIN condition must reference the joined table in at least one side");return[{left:n,right:s}]}getConditionColumnReference(e,t){if(e instanceof PodColumnBase)return this.resolveColumnReference(e,t);if(typeof e=="string"){if(e.includes("."))return this.resolveColumnReference(e,t);const n=t??this.primaryAlias,s=n?this.aliasToTable.get(n):void 0;if(s&&e in(s.columns??{}))return this.resolveColumnReference(e,t)}}resolveColumnReference(e,t){if(e instanceof PodColumnBase){const n=e.table;if(!n)throw new Error(`Column ${e.name} is not associated with a table`);const s=this.ensureAliasForTable(n);return{table:n,alias:s,column:e.name}}if(typeof e=="string"){const{alias:n,column:s}=this.parseColumnReferenceString(e),a=n??t??this.primaryAlias;if(!a)throw new Error(`Unable to resolve table alias for column reference "${e}"`);const u=this.aliasToTable.get(a);if(!u)throw new Error(`Unknown table alias "${a}" in column reference "${e}"`);return{table:u,alias:a,column:s}}throw new Error("Unsupported column link type")}parseColumnReferenceString(e){const t=e.trim();if(!t.includes("."))return{column:t};const[n,s]=t.split(".",2);return{alias:n,column:s}}processWhereObject(e){if(!e)return;const t={...this.whereConditions??{}};for(const[n,s]of Object.entries(e)){const{alias:a,column:u}=this.parseColumnReferenceString(n),c=a??this.primaryAlias;if(!c||c===this.primaryAlias||!this.aliasToTable.has(c)){t[u]=s;continue}this.joinFilters.push(createLiteralCondition(c,u,s))}this.whereConditions=Object.keys(t).length>0?t:void 0}processQueryCondition(e){const t=this.extractTableFromCondition(e);if(t&&t!==this.primaryAlias){this.joinFilters.push(e);return}this.conditionTree=e;const n=this.convertQueryConditionToSimple(e);Object.keys(n).length>0&&(this.whereConditions=n)}applyInternalQueryCondition(e){return this.processQueryCondition(e),this}normalizeWhereConditions(){if(this.conditionTree)return this.conditionTree;const e=this.primaryAlias??this.selectedTable?.config.name;return buildConditionTreeFromObject(this.whereConditions,e)}toIR(){const e=this.normalizeWhereConditions();return this.buildQueryPlan(e)}buildQueryPlan(e){if(!this.selectedTable)throw new Error("No table specified for SELECT query");const t=this.joins.map(n=>({type:n.type,table:n.table,alias:n.alias,conditions:(n.resolvedConditions??[]).map(({left:s,right:a})=>({left:s,right:a}))}));return{baseTable:this.selectedTable,baseAlias:this.primaryAlias??this.selectedTable.config.name,select:this.selectedFields,selectAll:!this.selectedFields,where:this.whereConditions,conditionTree:e,joins:t.length>0?t:void 0,joinFilters:this.joinFilters.length>0?[...this.joinFilters]:void 0,groupBy:this.groupByColumns.length>0?[...this.groupByColumns]:void 0,having:this.havingCondition,orderBy:this.orderByClauses.length>0?this.orderByClauses.map(n=>({rawColumn:n.column,direction:n.direction})):void 0,distinct:this.isDistinct||void 0,limit:this.limitCount,offset:this.offsetCount,aliasToTable:new Map(this.aliasToTable),tableToAlias:new Map(this.tableAliases)}}limit(e){if(!Number.isInteger(e)||e<0)throw new Error("LIMIT must be a non-negative integer");return this.limitCount=e,this}offset(e){if(!Number.isInteger(e)||e<0)throw new Error("OFFSET must be a non-negative integer");return this.offsetCount=e,this}addOrderByClause(e,t="asc"){const n=typeof e=="string"?e:e.name;if(!n)throw new Error("ORDER BY requires a valid column name");this.orderByClauses.push({column:n,direction:t})}orderBy(...e){if(e.length===0)throw new Error("ORDER BY requires at least one column or expression");if(e.length===2&&(e[0]instanceof PodColumnBase||typeof e[0]=="string")&&(e[1]==="asc"||e[1]==="desc"))return this.addOrderByClause(e[0],e[1]),this;for(const t of e){if(isOrderByExpression(t)){this.addOrderByClause(t.column,t.direction);continue}if(t instanceof PodColumnBase||typeof t=="string"){this.addOrderByClause(t,"asc");continue}throw new Error("ORDER BY received an unsupported argument")}return this}distinct(e=!0){return this.isDistinct=e,this}buildSPARQLQuery(e="toSPARQL()"){if(this.sql){const n=this.sql.queryChunks.join(""),s=inferSPARQLQueryType(n);if(!s)throw new Error(`${e} could not infer SPARQL query type from raw AST input`);return{type:s,query:n,prefixes:{}}}if(!this.selectedTable)throw new Error("No table specified for SELECT query");if(this.joins.length>0)throw new Error(`${e} is not yet supported for JOIN queries in Solid dialect`);if(this.shouldUseProjectionFallback())throw new Error(`${e} does not support structured selections in Solid dialect`);const t=this.session.getDialect().getSPARQLConverter?.();if(!t)throw new Error(`${e} requires dialect SPARQL converter support`);return t.convertSelectPlan(this.toIR())}toSPARQL(){return this.buildSPARQLQuery("toSPARQL()")}toSparql(){return this.toSPARQL()}async execute(){if(!this.selectedTable)throw new Error("No table specified for SELECT query");if(this.limitCount===0)return[];if(this.sql)return await this.session.executeSql(this.sql,this.selectedTable);{const e=this.toIR(),t=e.conditionTree,n=this.joins.length>0,s=this.shouldUseAggregateFallback(),a=this.shouldUseProjectionFallback(),u=n||s;(n||s||a)&&(e.select=void 0,e.selectAll=!0);const c=u?{...e,limit:void 0,offset:void 0,orderBy:void 0,...n?{joins:void 0,joinFilters:void 0}:{},...s?{groupBy:void 0,having:void 0}:{}}:n?{...e,joins:void 0,joinFilters:void 0}:e,h={type:"select",table:this.selectedTable,where:t,limit:u?void 0:this.limitCount,offset:u?void 0:this.offsetCount,orderBy:u||this.orderByClauses.length===0?void 0:this.orderByClauses,distinct:this.isDistinct||void 0};if(h.plan=c,this.groupByColumns.length===0&&this.hasMixedAggregateSelection())throw new Error("Mixed aggregate and non-aggregate selections require groupBy columns");let f;if(!n&&!s&&!a?(this.selectedFields&&(h.select=this.selectedFields),f=await this.session.execute(h),f=this.applySubjectMetadata(f)):(n?h.select=void 0:!s&&!a?h.select=this.selectedFields:h.select=void 0,f=await this.session.execute(h),n||(f=this.applySubjectMetadata(f)),n&&(f=this.normalizeBaseRows(f),f=this.mergeRowsBySubject(f),f=await this.applyJoinFallback(f),f=this.applyJoinFilters(f))),s){let g=this.handleAggregateFallback(f);return g=this.applyHavingFilter(g),u&&(g=this.applyDeferredOrderBy(g),g=this.applyDeferredOffsetAndLimit(g)),g}let p=f;return n||(p=this.mergeRowsBySubject(p)),this.selectedTable&&(p=await this.hydrateInlineColumns(p,this.selectedTable,!n)),n&&(p=this.applyDeferredOrderBy(p)),this.selectedFields&&(p=p.map(g=>this.projectSelectedRow(g))),p=this.applyDistinctRows(p),n||(p=this.mergeRowsBySubject(p)),n&&(p=this.applyDeferredOffsetAndLimit(p)),p}}projectSelectedRow(e){return this.selectedFields?this.projectFieldMap(e,this.selectedFields):e}projectFieldMap(e,t,n=!0){const s={};for(const[a,u]of Object.entries(t))s[a]=this.projectFieldValue(e,a,u,n);return s}projectFieldValue(e,t,n,s=!0){if(isAggregateExpression(n))return s?e[t]:void 0;if(n instanceof PodTable)return this.projectTableValue(e,n);if(this.isSelectFieldMap(n)){const a=this.collectSelectionAliases(n),u=a.size===1&&!a.has(this.primaryAlias??""),c=this.projectFieldMap(e,n,!u);if(a.size===1){const[h]=Array.from(a);if(h&&h!==this.primaryAlias&&this.isProjectedValueEmpty(c))return null}return c}for(const a of this.resolveFieldBindingCandidates(t,n))if(e[a]!==void 0)return e[a];return s?e[t]:void 0}projectTableValue(e,t){const n=this.tableAliases.get(t)??t.config.name,s={};let a=!1;for(const u of Object.keys(t.columns)){const h=(n===this.primaryAlias?[u,`${n}.${u}`]:[`${n}.${u}`]).find(f=>e[f]!==void 0);s[u]=h?e[h]:void 0,s[u]!==void 0&&(a=!0)}return n!==this.primaryAlias&&!a?null:s}isSelectFieldMap(e){return!!e&&typeof e=="object"&&!(e instanceof PodColumnBase)&&!(e instanceof PodTable)&&!isAggregateExpression(e)}collectSelectionAliases(e){if(typeof e=="string"){const{alias:n}=this.parseColumnReferenceString(e);return new Set(n?[n]:this.primaryAlias?[this.primaryAlias]:[])}if(e instanceof PodColumnBase)return new Set([this.resolveColumnReference(e).alias]);if(e instanceof PodTable)return new Set([this.tableAliases.get(e)??e.config.name]);if(!this.isSelectFieldMap(e))return new Set;const t=new Set;for(const n of Object.values(e))for(const s of this.collectSelectionAliases(n))t.add(s);return t}isProjectedValueEmpty(e){if(e==null)return!0;if(Array.isArray(e))return e.length===0;if(typeof e=="object"){const t=Object.values(e);return t.length>0&&t.every(n=>this.isProjectedValueEmpty(n))}return!1}resolveFieldBindingCandidates(e,t){const n=new Set;if(typeof t=="string"){const{alias:s,column:a}=this.parseColumnReferenceString(t);n.add(t),n.add(a),s&&n.add(`${s}.${a}`)}else if(t instanceof PodColumnBase){const s=this.resolveColumnReference(t);n.add(`${s.alias}.${s.column}`),(!s.alias||s.alias===this.primaryAlias)&&n.add(t.name)}else if(t&&typeof t=="object"){const s=t.name;typeof s=="string"&&n.add(s)}return Array.from(n)}shouldUseProjectionFallback(){if(!this.selectedFields)return!1;const e=t=>!!(t instanceof PodTable||this.isSelectFieldMap(t));return Object.values(this.selectedFields).some(t=>e(t))}shouldUseAggregateFallback(){if(this.havingCondition)return!0;if(this.joins.length>0)return this.groupByColumns.length>0||this.hasAggregateSelection();if(this.groupByColumns.length>0||!this.selectedFields)return!1;const e=Object.values(this.selectedFields);return e.length>0&&e.every(t=>isAggregateExpression(t))}buildAggregateRow(e){const t={};if(!this.selectedFields)return t;for(const[n,s]of Object.entries(this.selectedFields))isAggregateExpression(s)&&(t[n]=this.computeAggregateValue(s,e));return t}computeAggregateValue(e,t){const n=this.resolveAggregateColumnRef(e);if(!n)return e.func==="count"?e.distinct?this.countDistinctRows(t):t.length:null;switch(e.func){case"count":return this.collectValuesForCount(n,t,!!e.distinct).length;case"sum":{const s=this.collectNumericValues(n,t,!!e.distinct);return s.length===0?null:s.reduce((a,u)=>a+u,0)}case"avg":{const s=this.collectNumericValues(n,t,!!e.distinct);return s.length===0?null:s.reduce((u,c)=>u+c,0)/s.length}case"min":{const s=this.collectNumericValues(n,t,!!e.distinct);return s.length===0?null:Math.min(...s)}case"max":{const s=this.collectNumericValues(n,t,!!e.distinct);return s.length===0?null:Math.max(...s)}default:return null}}resolveAggregateColumnRef(e){const t=e.column;if(t){if(typeof t=="string")return this.resolveColumnReference(t);if(t instanceof PodColumnBase)return this.resolveColumnReference(t);if(typeof t=="object"&&"name"in t){const n=t.name;if(typeof n=="string")return this.resolveColumnReference(n)}}}collectValuesForCount(e,t,n){const s=t.map(c=>this.getRowValueForColumn(c,e)).filter(c=>c!=null);if(!n)return s;const a=new Set,u=[];for(const c of s){const h=this.serializeValueForKey(c);a.has(h)||(a.add(h),u.push(c))}return u}collectNumericValues(e,t,n){const s=[],a=new Set;for(const u of t){const c=this.getRowValueForColumn(u,e);if(c==null)continue;const h=Number(c);if(!Number.isNaN(h))if(n){const f=this.serializeValueForKey(h);a.has(f)||(a.add(f),s.push(h))}else s.push(h)}return s}countDistinctRows(e){const t=new Set;for(const n of e){const s=this.serializeValueForKey(n);t.add(s)}return t.size}handleAggregateFallback(e){if(!this.selectedFields){if(this.groupByColumns.length===0)return e;const t=new Map;for(const n of e){const s=this.groupByColumns.map(u=>this.serializeValueForKey(this.getRowValueForColumn(n,u))),a=JSON.stringify(s);t.has(a)||t.set(a,n)}return Array.from(t.values())}return this.groupByColumns.length===0?[this.buildAggregateRow(e)]:this.buildGroupedAggregateRows(e)}buildGroupedAggregateRows(e){if(!this.selectedFields)return e;this.ensureGroupByValidity();const t=new Map;for(const s of e){const a=this.groupByColumns.map(c=>this.serializeValueForKey(this.getRowValueForColumn(s,c))),u=JSON.stringify(a);t.has(u)||t.set(u,{rows:[],first:s}),t.get(u)?.rows.push(s)}const n=[];for(const{rows:s,first:a}of t.values()){const u=this.buildAggregateRow(s),c={};for(const[h,f]of Object.entries(this.selectedFields))if(isAggregateExpression(f))c[h]=u[h];else{const p=this.resolveSelectFieldColumn(f);c[h]=p?this.getRowValueForColumn(a,p):void 0}n.push(c)}return n}ensureGroupByValidity(){if(!this.selectedFields)return;const e=this.groupByColumns.map(t=>`${t.alias}.${t.column}`);for(const t of Object.values(this.selectedFields)){if(isAggregateExpression(t))continue;const n=this.resolveSelectFieldColumn(t);if(!n)continue;const s=`${n.alias}.${n.column}`;if(!e.includes(s))throw new Error(`Column ${s} must appear in GROUP BY clause when mixed with aggregates`)}}resolveSelectFieldColumn(e){if(e instanceof PodColumnBase)return this.resolveColumnReference(e);if(typeof e=="string")return this.resolveColumnReference(e)}hasAggregateSelection(){return this.selectedFields?Object.values(this.selectedFields).some(e=>isAggregateExpression(e)):!1}hasMixedAggregateSelection(){if(!this.selectedFields)return!1;const e=Object.values(this.selectedFields),t=e.some(s=>isAggregateExpression(s)),n=e.some(s=>!isAggregateExpression(s));return t&&n}applySubjectMetadata(e){return e.map(t=>this.attachSubjectMetadata(t))}extractSubjectValue(e){const t=e.subject??e["@id"]??e.uri;if(typeof t=="object"&&t&&"value"in t){const n=t.value;return typeof n=="string"&&n.length>0?n:void 0}if(typeof t=="string"&&t.length>0)return t}attachSubjectMetadata(e){const t=this.extractSubjectValue(e);if(typeof t=="string"&&t.length>0&&(e["@id"]===void 0&&(e["@id"]=t),e.uri===void 0&&(e.uri=t),e.id===void 0)){const n=this.extractIdFromSubject(t,this.selectedTable);n!==void 0&&(e.id=n)}return e}normalizeBaseRows(e){if(!e.length)return e;const t=this.primaryAlias||this.ensureAliasForTable(this.selectedTable);return e.map(n=>{const s={...n};for(const[u,c]of Object.entries(n))u!==`${t}.${u}`&&(s[`${t}.${u}`]=c);const a=this.extractSubjectValue(n);if(a){s.subject=a,s["@id"]=a,s.uri=a,s[`${t}.subject`]=a,s[`${t}.@id`]=a,s[`${t}.uri`]=a;const u=this.extractIdFromSubject(a,this.selectedTable);u!==void 0&&(s.id===void 0&&(s.id=u),(this.shouldUseSubjectIdentityColumn(this.selectedTable,"id")||s[`${t}.id`]===void 0)&&(s[`${t}.id`]=u))}return s})}async hydrateInlineColumns(e,t,n=!0){if(!e.length)return e;const s=Object.values(t.columns??{}).filter(T=>this.isInlineObjectColumn(T));if(s.length===0)return e;n&&(e=this.mergeRowsBySubject(e));const a=new Map;s.forEach(T=>{const A=T.getPredicate(t.config.namespace);a.set(A,T)});const u=Array.from(new Set(e.map(T=>this.normalizeInlineIri(T["@id"]??T.subject??T.uri??T.id)).filter(T=>!!T)));if(u.length===0||a.size===0)return e;const c=Array.from(a.keys()).map(T=>`<${T}>`).join(" "),h=this.session.getDialect().getSPARQLExecutor(),f=[],p=new Map;for(const T of u){const A=this.inferSourceFromChild(T,t),F=p.get(A)??[];F.push(T),p.set(A,F)}for(const[T,A]of p.entries()){const x={type:"SELECT",query:`SELECT ?parent ?linkPred ?child ?pred ?obj WHERE {
121
+ VALUES ?parent { ${A.map(O=>`<${O}>`).join(" ")} }
122
+ VALUES ?linkPred { ${c} }
123
+ ?parent ?linkPred ?child .
124
+ OPTIONAL { ?child ?pred ?obj . }
125
+ }`,prefixes:{}},D=await h.executeQueryWithSource(x,T);f.push(...D)}const g=t.config.namespace?.uri??t.config.namespace,y=new Map,S=new Map;f.forEach(T=>{const A=this.normalizeInlineIri(T.parent),F=this.normalizeInlineIri(T.linkPred),x=this.normalizeInlineIri(T.child),D=this.normalizeInlineIri(T.pred),O=this.normalizeInlineObjectValue(T.obj);if(!A||!F)return;const K=a.get(F);if(K){const q=y.get(A)??new Map,Y=q.get(K.name)??[];x&&!Y.includes(x)&&Y.push(x),q.set(K.name,Y),y.set(A,q)}if(!x||!D)return;const z=S.get(x)??{"@id":x,id:this.extractIdFromSubject(x,t)},X=this.normalizeInlinePredicateKey(D,g);if(O===void 0){S.set(x,z);return}const Ee=z[X];Ee===void 0?z[X]=O:Array.isArray(Ee)?z[X]=[...Ee,O]:z[X]=[Ee,O],S.set(x,z)});const w=T=>{if(Array.isArray(T))return T.map(F=>this.normalizeInlineIri(F)).filter(F=>!!F);const A=this.normalizeInlineIri(T);return A?[A]:[]},R=(T,A,F)=>{const x=T?y.get(T)?.get(F.name)??[]:[],O=(x.length>0?x:w(A)).map(K=>S.get(K)??{"@id":K,id:this.extractIdFromSubject(K,t)});return F.dataType==="array"?O:O[0]??null};return e.forEach(T=>{const A=this.normalizeInlineIri(T["@id"]??T.subject??T.uri??T.id);s.forEach(F=>{T[F.name]=R(A,T[F.name],F)})}),e}normalizeInlinePredicateKey(e,t){if(t&&e.startsWith(t))return e.slice(t.length);const n=e.lastIndexOf("#");if(n!==-1&&n<e.length-1)return e.slice(n+1);const s=e.lastIndexOf("/");return s!==-1&&s<e.length-1?e.slice(s+1):e}normalizeInlineObjectValue(e){if(e!=null)return typeof e=="object"&&"value"in e?e.value??void 0:e}normalizeInlineIri(e){if(e){if(typeof e=="string")return e;if(typeof e=="object"&&typeof e["@id"]=="string")return e["@id"];if(typeof e=="object"&&typeof e.id=="string"&&e.id.includes("http"))return e.id;if(typeof e=="object"&&typeof e.value=="string")return e.value}}applyDeferredOrderBy(e){if(this.orderByClauses.length===0||e.length<2)return e;const t=[...e];return t.sort((n,s)=>{for(const a of this.orderByClauses){const u=this.getOrderByValue(n,a.column),c=this.getOrderByValue(s,a.column),h=this.compareOrderByValues(u,c);if(h!==0)return a.direction==="desc"?-h:h}return 0}),t}applyDistinctRows(e){if(!this.isDistinct||e.length<2)return e;const t=new Set,n=[];for(const s of e){const a=this.serializeValueForKey(s);t.has(a)||(t.add(a),n.push(s))}return n}applyDeferredOffsetAndLimit(e){const t=this.offsetCount??0,n=t>0?e.slice(t):e;return this.limitCount===void 0?n:n.slice(0,this.limitCount)}getOrderByValue(e,t){if(t in e)return e[t];const n=Object.keys(e).find(s=>s.endsWith(`.${t}`));if(n)return e[n]}compareOrderByValues(e,t){return e===t?0:e==null?1:t==null?-1:typeof e=="number"&&typeof t=="number"?e-t:String(e).localeCompare(String(t))}mergeRowsBySubject(e){const t=new Map,n=[];return e.forEach(a=>{const u=this.normalizeInlineIri(a["@id"])??this.normalizeInlineIri(a.subject)??this.normalizeInlineIri(a.uri)??(typeof a.id=="string"?a.id:void 0);if(define_process_env_default$2.DEBUG_INLINE_MERGE==="1"&&console.log("mergeRowsBySubject key",u),!u){n.push(`__anon_${n.length}`),t.set(n[n.length-1],{...a});return}if(!t.has(u)){const f={...a};Object.entries(f).forEach(([p,g])=>{if(g===void 0)return;const y=this.getColumnDefinitionForRowKey(p);(y?.options?.isArray||y?.dataType==="array")&&!Array.isArray(g)&&(f[p]=[g])}),t.set(u,f),n.push(u);return}const c=t.get(u),h=f=>{if(f instanceof Date)return`date:${f.toISOString()}`;if(typeof f=="string")return`str:${f}`;if(typeof f=="number")return`num:${f}`;if(typeof f=="boolean")return`bool:${f}`;if(f==null)return"nil";try{return`obj:${JSON.stringify(f)}`}catch{return`obj:${String(f)}`}};Object.entries(a).forEach(([f,p])=>{if(p===void 0)return;const g=c[f];if(g===void 0){c[f]=p;return}const y=Array.isArray(g)?g:[g],S=Array.isArray(p)?p:[p],w=[...y];S.forEach(A=>{const F=h(A);w.some(x=>h(x)===F)||w.push(A)});const R=this.getColumnDefinitionForRowKey(f),T=R?.options?.isArray||R?.dataType==="array";!T&&w.length>1?(console.warn(`[Data Integrity] Multiple values found for single-value column '${f}' on subject '${u}'. Using first value.`),c[f]=w[0]):T?c[f]=w:c[f]=w.length===1?w[0]:w})}),n.map(a=>t.get(a))}getColumnDefinitionForRowKey(e){if(!e)return;if(!e.includes("."))return this.selectedTable?.columns[e];const[t,n]=e.split(".",2);if(!(!t||!n))return t===this.primaryAlias?this.selectedTable?.columns[n]:this.aliasToTable.get(t)?.columns?.[n]}inferSourceFromChild(e,t){if(!e)return this.session.getDialect().getPodUrl();const n=e.indexOf("#");if(n>0)return e.slice(0,n);const s=t.getResourcePath?.()||t.config.base||t.getContainerPath?.();return s?s.startsWith("http")?s:`${this.session.getDialect().getPodUrl()}${s.replace(/^\//,"")}`:this.session.getDialect().getPodUrl()}isInlineObjectColumn(e){if(!e)return!1;if(e.dataType==="object"||e.dataType==="json")return!0;if(e.dataType==="array"){const t=e.elementType??e.options?.baseType;return t==="object"||t==="json"}return!1}async applyJoinFallback(e){let t=e;for(const n of this.joins){const s=await this.fetchJoinRows(n,t);t=this.mergeRowsWithJoin(t,n,s)}return t}async fetchJoinRows(e,t){if(e.type==="crossJoin"){const w=await this.session.select().from(e.table);return this.normalizeJoinRows(e,w)}const n=e.resolvedConditions??[];if(n.length===0)return[];const[s]=n,a=s.left.alias===e.alias?s.left:s.right,u=a===s.left?s.right:s.left,c=new Map;for(const w of t){const R=this.getRowValueForColumn(w,u);if(R==null)continue;const T=this.serializeValueForKey(R);c.has(T)||c.set(T,R)}if(c.size===0)return[];const h=Array.from(c.values()),f=()=>this.session.select().from(e.table),p=e.table.getColumn(a.column),g=this.buildExactJoinLookupConditions(e,t);if(g&&g.length>0){const w=[];for(const R of g){const T=f(),F=await(conditionTargetsReservedIdentifier(R)?T.applyInternalQueryCondition(R):T.where(R));w.push(...F)}return this.mergeRowsBySubject(this.normalizeJoinRows(e,w))}const y=this.buildJoinLookupCondition(p,h);if(y){const w=f(),T=await(conditionTargetsReservedIdentifier(y)?w.applyInternalQueryCondition(y):w.where(y));return this.normalizeJoinRows(e,T)}const S=await f();return this.normalizeJoinRows(e,S)}buildExactJoinLookupConditions(e,t){const n=e.resolvedConditions??[];if(n.length===0)return;const[s]=n,a=s.left.alias===e.alias?s.left:s.right,u=a===s.left?s.right:s.left,c=this.getRequiredSubjectTemplateVariables(e.table),h=a.column==="id"&&c.length>0;if(!h&&n.length===1)return;const f=new Map;for(const y of n){const S=y.left.alias===e.alias?y.left:y.right;f.set(S.column,y)}const p=[],g=new Set;for(const y of t){const S=this.getRowValueForColumn(y,u);if(S==null)continue;const w=typeof S=="string"&&this.isAbsoluteIri(S),R=[],T=[];let A=!1;for(const x of n){const D=x.left.alias===e.alias?x.left:x.right,O=D===x.left?x.right:x.left,K=this.getRowValueForColumn(y,O);if(K==null){if(h&&!w&&c.includes(D.column))throw new Error(this.buildMissingJoinLocatorError(e,c.filter(X=>{const Ee=f.get(X);if(!Ee)return!0;const Y=(Ee.left.alias===e.alias?Ee.left:Ee.right)===Ee.left?Ee.right:Ee.left,Te=this.getRowValueForColumn(y,Y);return Te==null})));A=!0;break}const z=e.table.getColumn(D.column);if(!z){A=!0;break}R.push(eq(z,K)),T.push(`${D.column}:${this.serializeValueForKey(K)}`)}if(A)continue;if(h&&!w){const x=c.filter(D=>{const O=f.get(D);if(!O)return!0;const z=(O.left.alias===e.alias?O.left:O.right)===O.left?O.right:O.left,X=this.getRowValueForColumn(y,z);return X==null});if(x.length>0)throw new Error(this.buildMissingJoinLocatorError(e,x))}if(R.length===0)continue;const F=T.join("|");g.has(F)||(g.add(F),p.push(R.length===1?R[0]:and(...R)))}return p.length>0?p:void 0}buildJoinLookupCondition(e,t){if(!(!e||t.length===0))return t.length===1?eq(e,t[0]):inArray(e,t)}getRequiredSubjectTemplateVariables(e){const t=e.getSubjectTemplate?.()??e.config?.subjectTemplate??"";return Array.from(new Set(Array.from(t.matchAll(/\{([^}]+)\}/g)).map(n=>n[1].split("|")[0]?.trim()||n[1]).filter(Boolean))).filter(n=>n!=="id"&&n!=="index"&&n!=="yyyy"&&n!=="MM"&&n!=="dd"&&n!=="HH"&&n!=="mm"&&n!=="ss"&&n!=="timestamp"&&n!=="date")}isAbsoluteIri(e){return/^[a-zA-Z][\w+.-]*:\/\//.test(e)}buildMissingJoinLocatorError(e,t){const n=e.table.getSubjectTemplate?.()??e.table.config?.subjectTemplate??"<exact-id>",s=Array.from(new Set(t)),a=s[0]??"...";return`Cannot join table "${e.table.config.name??"unknown"}" by id with subjectTemplate "${n}" because locator variable(s) [${s.join(", ")}] are missing. Add join conditions for all required template variables (for example eq(base.${a}, join.${a})) or join via full IRI values.`}normalizeJoinRows(e,t){return t.map(n=>{const s={};for(const[u,c]of Object.entries(n))s[`${e.alias}.${u}`]=c;const a=this.extractSubjectValue(n);if(a){s.subject=a,s["@id"]=a,s.uri=a,s[`${e.alias}.subject`]=a,s[`${e.alias}.@id`]=a,s[`${e.alias}.uri`]=a;const u=this.extractIdFromSubject(a,e.table);u!==void 0&&(this.shouldUseSubjectIdentityColumn(e.table,"id")||s[`${e.alias}.id`]===void 0)&&(s[`${e.alias}.id`]=u)}return s})}mergeRowsWithJoin(e,t,n){if(t.type==="crossJoin"){if(e.length===0||n.length===0)return[];const p=[];for(const g of e)for(const y of n)p.push({...g,...y});return p}const s=t.resolvedConditions??[];if(s.length===0)return e;const[a]=s,u=a.left.alias===t.alias?a.left:a.right,c=u===a.left?a.right:a.left,h=new Map;for(const p of n){const g=this.getRowValueForColumn(p,u);if(g==null)continue;const y=this.serializeValueForKey(g);h.has(y)||h.set(y,[]),h.get(y).push(p)}const f=[];for(const p of e){const g=this.getRowValueForColumn(p,c),y=this.serializeValueForKey(g),w=(g!=null?h.get(y)??[]:[]).filter(R=>this.joinRowMatchesAllConditions(p,R,t.alias,s));if(w.length===0){if(t.type==="innerJoin")continue;f.push({...p,...this.createEmptyJoinRow(t)});continue}for(const R of w)f.push({...p,...R})}return f}joinRowMatchesAllConditions(e,t,n,s){return s.every(a=>{const u=a.left.alias===n?a.left:a.right,c=u===a.left?a.right:a.left,h=this.getRowValueForColumn(e,c),f=this.getRowValueForColumn(t,u);return h==null||f===void 0||f===null?!1:this.serializeValueForKey(h)===this.serializeValueForKey(f)})}createEmptyJoinRow(e){const t={};for(const n of Object.keys(e.table.columns))t[`${e.alias}.${n}`]=void 0;return t[`${e.alias}.subject`]=void 0,t[`${e.alias}.id`]=void 0,t}applyJoinFilters(e){return this.joinFilters.length===0?e:e.filter(t=>this.joinFilters.every(n=>this.evaluateCondition(t,n)))}applyHavingFilter(e){return this.havingCondition?e.filter(t=>this.evaluateCondition(t,this.havingCondition)):e}evaluateCondition(e,t){switch(t.type){case"binary_expr":return this.evaluateBinaryCondition(e,t);case"unary_expr":return this.evaluateUnaryCondition(e,t);case"logical_expr":return this.evaluateLogicalCondition(e,t);default:return!0}}evaluateBinaryCondition(e,t){const n=t.left,s=t.right,a=t.operator;if(!n)return!0;const u=this.resolveConditionOperandValue(e,n,this.primaryAlias),c=this.resolveConditionOperandValue(e,s);switch(a.toUpperCase()){case"=":return u===c;case"!=":case"<>":return u!==c;case">":return Number(u)>Number(c);case">=":return Number(u)>=Number(c);case"<":return Number(u)<Number(c);case"<=":return Number(u)<=Number(c);case"IN":return Array.isArray(c)&&c.includes(u);case"NOT IN":return Array.isArray(c)&&!c.includes(u);case"LIKE":return typeof u=="string"&&typeof c=="string"&&this.computeLikeMatch(u,c);default:return!0}}evaluateUnaryCondition(e,t){const n=t.operator,s=t.value;if(n.toUpperCase()==="NOT")return!this.evaluateCondition(e,s);if(!s)return!0;const a=this.resolveConditionOperandValue(e,s,this.primaryAlias);switch(n.toUpperCase()){case"IS NULL":return a==null;case"IS NOT NULL":return a!=null;default:return!0}}evaluateLogicalCondition(e,t){const n=t.operator,s=t.expressions??[];return n.toUpperCase()==="AND"?s.every(a=>this.evaluateCondition(e,a)):n.toUpperCase()==="OR"?s.some(a=>this.evaluateCondition(e,a)):!0}resolveConditionOperandValue(e,t,n){if(t instanceof SelectionAliasExpression)return e[t.alias];const s=this.getConditionColumnReference(t,n);return s?this.getRowValueForColumn(e,s):t}getColumnKeyCandidates(e){const t=[],n=this.primaryAlias;return e.alias===n&&t.push(e.column),t.push(`${e.alias}.${e.column}`),t}getRowValueForColumn(e,t){const n=this.getColumnKeyCandidates(t);for(const s of n)if(s in e)return e[s]}shouldUseSubjectIdentityColumn(e,t){const n=e?.columns?.[t];return!!(n?._virtualId||n?.options?.predicate==="@id")}serializeValueForKey(e){return e===null?"null":typeof e=="object"?JSON.stringify(e):String(e)}extractIdFromSubject(e,t){if(!e)return;if(t){const a=parsePodResourceRef(t,e)?.resourceId;if(a)return a}if(t){const a=this.session.getDialect?.(),c=(a?.getUriResolver?.()??new UriResolverImpl(a?.getPodUrl?.()??"")).parseSubject(e,t);if(c&&c.id)return c.id}const n=e.indexOf("#");if(n!==-1)return e.slice(n);const s=e.lastIndexOf("/");if(s!==-1){const a=e.slice(s+1);if(a.length>0)return a}}computeLikeMatch(e,t){const n=t.replace(/[.+^${}()|[\]\\]/g,"\\$&");return new RegExp(`^${n.replace(/%/g,".*").replace(/_/g,".")}$`,"i").test(e)}async selectIdsByCondition(e,t){return(await this.session.select({id:e.getColumn("id")??e.columns.id}).from(e).where(t).columns({"@id":e.columns.id})).map(a=>a.id||a["@id"]).filter(a=>typeof a=="string"&&a.length>0)}then(e,t){return this.execute().then(e,t)}}_a$7=entityKind;SelectQueryBuilder[_a$7]="SelectQueryBuilder";var _a$6;class InsertQueryBuilder{constructor(e,t){this.session=e,this.table=t,this.toIR=()=>{const n=this.getRowsWithDefaults();return{table:this.table,rows:n}}}values(e){return e instanceof SQL?this.sql=e:this.insertValues=e,this}returning(e){return this.returningFields=e??!0,this}buildSPARQLQuery(e="toSPARQL()"){if(this.sql){const n=this.sql.queryChunks.join(""),s=inferSPARQLQueryType(n);if(!s)throw new Error(`${e} could not infer SPARQL query type from raw AST input`);return{type:s,query:n,prefixes:{}}}const t=this.session.getDialect().getSPARQLConverter?.();if(!t)throw new Error(`${e} requires dialect SPARQL converter support`);return t.convertInsert(this.toIR())}toSPARQL(){return this.buildSPARQLQuery("toSPARQL()")}toSparql(){return this.toSPARQL()}async execute(){if(this.sql){if(this.returningFields)throw new Error("returning() is not supported for raw SQL insert in Solid dialect");return await this.session.executeSql(this.sql,this.table)}else if(this.insertValues){const e=this.getRowsWithDefaults(),t=this.returningFields?this.getSubjectUris(e):[],n={type:"insert",table:this.table,values:Array.isArray(this.insertValues)?e:e[0],plan:{table:this.table,rows:e}},s=await this.session.execute(n),a=this.returningFields?await this.fetchReturningRowsBySubjects(t):s;return await this.runAfterInsertHooks(a),a}else throw new Error("No values specified for INSERT query")}then(e,t){return this.execute().then(e,t)}async fetchReturningRowsBySubjects(e){if(e.length===0)return[];const t=await this.session.select().from(this.table).whereByIri(e);return projectReturningRows(orderRowsBySubjects(t,e),this.returningFields)}getSubjectUris(e){const t=this.session.getDialect().getUriResolver?.();if(!t)throw new Error("returning() requires dialect URI resolver support");return e.map(n=>generateSubjectUri(n,this.table,t))}async runAfterInsertHooks(e){const t=this.table.config.hooks;if(!t?.afterInsert)return;const n=this.buildHookContext();if(!n){console.warn("[InsertQueryBuilder] Cannot run hooks: missing session info");return}for(const s of e)try{await t.afterInsert(n,s)}catch(a){console.error("[InsertQueryBuilder] afterInsert hook failed:",a)}}buildHookContext(){const e=this.session.getDialect(),t=e.getWebId(),n=e.getAuthenticatedFetch();return!t||!n?null:{session:{info:{isLoggedIn:!0,webId:t},fetch:n},table:this.table,db:this.table._db??null}}getRowsWithDefaults(){const e=this.insertValues;if(!e)throw new Error("No values specified for INSERT query");return(Array.isArray(e)?e:[e]).map(n=>this.applyDefaultValues(n))}applyDefaultValues(e){const t={...e},n=this.table?.columns??{},s=Object.entries(n);for(const[a,u]of s.filter(([,c])=>!this.isPrimaryKeyColumn(c)))this.applyDefaultValue(t,a,u);for(const[a,u]of s.filter(([,c])=>this.isPrimaryKeyColumn(c)))this.applyDefaultValue(t,a,u);return t}applyDefaultValue(e,t,n){if(e[t]===void 0){const s=n.options?.defaultValue;s!==void 0&&(e[t]=this.resolveDefaultValue(s,n,e))}}resolveDefaultValue(e,t,n){const s=this.isPrimaryKeyColumn(t)?generateNanoId():void 0;if(typeof e=="string"&&s)return renderDefaultIdTemplate(e,{key:s,row:n,resource:this.table});if(typeof e!="function")return e;const a=e;return a.length===0?a():a(s,n)}isPrimaryKeyColumn(e){return e.options?.primaryKey===!0||e.options?.predicate==="@id"}}_a$6=entityKind;InsertQueryBuilder[_a$6]="InsertQueryBuilder";var _a$5;class UpdateQueryBuilder{constructor(e,t){this.session=e,this.table=t,this.toIR=()=>{if(!this.updateData)throw new Error("No data specified for UPDATE query");const n=this.normalizeWhereConditionsForUpdate();if(!n)throw new Error("UPDATE operation requires where conditions to locate target resources");return{table:this.table,data:this.updateData,where:n}}}set(e){return e instanceof SQL?this.sql=e:this.updateData=e,this}returning(e){return this.returningFields=e??!0,this}where(e){if(e instanceof SQL)this.sql||(this.sql=e);else if(this.isQueryCondition(e)){assertPublicWhereCondition("update",e),this.conditionTree=e;const t=this.convertQueryConditionToSimple(e);this.whereConditions=Object.keys(t).length>0?t:void 0}else assertPublicWhereObject("update",e),this.whereConditions=e,this.conditionTree=void 0;return this}whereByIri(e){return this.whereConditions={"@id":e},this.conditionTree=void 0,this}isQueryCondition(e){return e&&typeof e=="object"&&"type"in e&&"operator"in e}convertQueryConditionToSimple(e){if(e.type==="binary_expr"){const t=e.left,n=e.right,s=typeof t=="string"?t:t?.name;if(s&&n!==void 0)return{[s]:n}}return{}}normalizeWhereConditionsForUpdate(){return this.conditionTree?this.conditionTree:buildConditionTreeFromObject(this.whereConditions)}buildSPARQLQuery(e="toSPARQL()"){if(this.sql){const s=this.sql.queryChunks.join(""),a=inferSPARQLQueryType(s);if(!a)throw new Error(`${e} could not infer SPARQL query type from raw AST input`);return{type:a,query:s,prefixes:{}}}const t=this.session.getDialect().getSPARQLConverter?.();if(!t)throw new Error(`${e} requires dialect SPARQL converter support`);const n=this.toIR();return t.convertUpdate(n.data,n.where,n.table)}toSPARQL(){return this.buildSPARQLQuery("toSPARQL()")}toSparql(){return this.toSPARQL()}async execute(){if(this.sql){if(this.returningFields)throw new Error("returning() is not supported for raw SQL update in Solid dialect");return await this.session.executeSql(this.sql,this.table)}else if(this.updateData){const e=this.toIR(),n=(this.returningFields?await this.fetchMatchedRows(e.where):[]).map(c=>resolveRowSubject(c)).filter(c=>typeof c=="string"&&c.length>0),s={type:"update",table:this.table,data:e.data,where:e.where,plan:e},a=await this.session.execute(s),u=this.returningFields?await this.fetchReturningRowsBySubjects(n):a;return await this.runAfterUpdateHooks(u),u}else throw new Error("No data specified for UPDATE query")}async fetchMatchedRows(e){const t=this.whereConditions?.["@id"];return!this.conditionTree&&typeof t=="string"?await this.session.select().from(this.table).whereByIri(t):await this.session.select().from(this.table).where(e)}async fetchReturningRowsBySubjects(e){if(e.length===0)return[];const t=await this.session.select().from(this.table).whereByIri(e),n=projectReturningRows(orderRowsBySubjects(t,e),this.returningFields),s=Object.entries(this.updateData??{}).filter(([,a])=>Array.isArray(a));return s.length===0?n:n.map(a=>{const u={...a};for(const[c,h]of s)c in u&&(u[c]=[...h]);return u})}async runAfterUpdateHooks(e){const t=this.table.config.hooks;if(!t?.afterUpdate)return;const n=this.buildHookContext();if(!n){console.warn("[UpdateQueryBuilder] Cannot run hooks: missing session info");return}const s=this.updateData??{};for(const a of e)try{await t.afterUpdate(n,a,s)}catch(u){console.error("[UpdateQueryBuilder] afterUpdate hook failed:",u)}}buildHookContext(){const e=this.session.getDialect(),t=e.getWebId(),n=e.getAuthenticatedFetch();return!t||!n?null:{session:{info:{isLoggedIn:!0,webId:t},fetch:n},table:this.table,db:this.table._db??null}}then(e,t){return this.execute().then(e,t)}}_a$5=entityKind;UpdateQueryBuilder[_a$5]="UpdateQueryBuilder";var _a$4;class DeleteQueryBuilder{constructor(e,t){this.session=e,this.table=t,this.toIR=()=>{const n=this.normalizeWhereConditionsForDelete();return{table:this.table,where:n}}}where(e){if(e instanceof SQL)this.sql=e;else if(this.isQueryCondition(e)){assertPublicWhereCondition("delete",e),this.conditionTree=e;const t=this.convertQueryConditionToSimple(e);this.whereConditions=Object.keys(t).length>0?t:void 0}else assertPublicWhereObject("delete",e),this.whereConditions=e,this.conditionTree=void 0;return this}returning(e){return this.returningFields=e??!0,this}whereByIri(e){return this.whereConditions={"@id":e},this.conditionTree=void 0,this}isQueryCondition(e){return e&&typeof e=="object"&&"type"in e&&"operator"in e}convertQueryConditionToSimple(e){if(e.type==="binary_expr"){const t=e.left,n=e.right,s=typeof t=="string"?t:t?.name;if(s&&n!==void 0)return{[s]:n}}return{}}normalizeWhereConditionsForDelete(){return this.conditionTree?this.conditionTree:buildConditionTreeFromObject(this.whereConditions)}buildSPARQLQuery(e="toSPARQL()"){if(this.sql){const s=this.sql.queryChunks.join(""),a=inferSPARQLQueryType(s);if(!a)throw new Error(`${e} could not infer SPARQL query type from raw AST input`);return{type:a,query:s,prefixes:{}}}const t=this.session.getDialect().getSPARQLConverter?.();if(!t)throw new Error(`${e} requires dialect SPARQL converter support`);const n=this.toIR();return t.convertDelete(n.where??{},n.table)}toSPARQL(){return this.buildSPARQLQuery("toSPARQL()")}toSparql(){return this.toSPARQL()}async execute(){if(this.sql){if(this.returningFields)throw new Error("returning() is not supported for raw SQL delete in Solid dialect");return await this.session.executeSql(this.sql,this.table)}else{const e=this.toIR(),t=this.returningFields?await this.fetchMatchedRows(e.where):[],n=t.map(c=>resolveRowSubject(c)).filter(c=>typeof c=="string"&&c.length>0),s={type:"delete",table:this.table,where:e.where,plan:e},a=await this.session.execute(s),u=this.returningFields?projectReturningRows(orderRowsBySubjects(t,n),this.returningFields):a;return await this.runAfterDeleteHooks(u),u}}async fetchMatchedRows(e){const t=this.whereConditions?.["@id"];if(!this.conditionTree&&typeof t=="string")return await this.session.select().from(this.table).whereByIri(t);let n=this.session.select().from(this.table);return e&&(n=n.where(e)),await n}async runAfterDeleteHooks(e){const t=this.table.config.hooks;if(!t?.afterDelete)return;const n=this.buildHookContext();if(!n){console.warn("[DeleteQueryBuilder] Cannot run hooks: missing session info");return}for(const s of e)try{await t.afterDelete(n,s)}catch(a){console.error("[DeleteQueryBuilder] afterDelete hook failed:",a)}}buildHookContext(){const e=this.session.getDialect(),t=e.getWebId(),n=e.getAuthenticatedFetch();return!t||!n?null:{session:{info:{isLoggedIn:!0,webId:t},fetch:n},table:this.table,db:this.table._db??null}}then(e,t){return this.execute().then(e,t)}}_a$4=entityKind;DeleteQueryBuilder[_a$4]="DeleteQueryBuilder";var _a$3;class PodAsyncSession{constructor(e,t,n={}){this.dialect=e,this._schema=t,this.options=n}getSchema(){return this._schema}isConnected(){return this.dialect.isConnected()}getDialect(){return this.dialect}getOptions(){return this.options}async ensureInitialized(e){const t=typeof this.dialect.getResourcePreparationMode=="function"?this.dialect.getResourcePreparationMode():"best-effort";if(t==="off"){e&&typeof e.markInitialized=="function"&&e.markInitialized(!0);return}if(e&&typeof e.isInitialized=="function"){if(!e.isInitialized())try{typeof e.init=="function"?await e.init(this.dialect):await this.dialect.registerTable(e)}catch(n){if(t!=="best-effort")throw n;e.markInitialized?.(!0)}return}if(e)try{await this.dialect.registerTable(e)}catch(n){if(t!=="best-effort")throw n}}async execute(e){if(this.options.logger&&console.log("Executing operation:",e),!e||!e.type)throw new Error("Invalid operation: missing type");if(!e.table)throw new Error("Invalid operation: missing table");if(!["select","insert","update","delete"].includes(e.type))throw new Error(`Unsupported operation type: ${e.type}`);if(await this.ensureInitialized(e.table),Array.isArray(e.joins))for(const s of e.joins)s?.table&&await this.ensureInitialized(s.table);const n=await this.dialect.query(e);return this.updateSubjectIndex(e,n),n}updateSubjectIndex(e,t){if(e.type==="select")return;const n=this.dialect;if(typeof n.registerResourceSubject!="function"&&typeof n.unregisterResourceSubject!="function")return;const s=this.resolveOperationSubjects(e,t);if(e.type==="delete"){s.forEach(a=>n.unregisterResourceSubject?.(e.table,a));return}s.forEach(a=>n.registerResourceSubject?.(e.table,a))}resolveOperationSubjects(e,t){const n=new Set;for(const s of t){const a=this.getKnownRowIri(s);a&&n.add(a)}if(e.type==="insert"){const s=e.plan;(Array.isArray(s?.rows)?s.rows:[]).forEach(u=>{try{n.add(generateSubjectUri(u,e.table,this.dialect.getUriResolver?.()))}catch{}})}return Array.from(n)}getKnownRowIri(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of["@id","subject","uri","source"]){const s=t[n];if(typeof s=="string"&&/^https?:\/\//.test(s))return s}return null}async executeSql(e,t){return this.options.logger&&console.log("Executing SQL AST:",e),await this.ensureInitialized(t),await this.dialect.executeSql(e,t)}select(e){return new SelectQueryBuilder(this,e)}insert(e){return new InsertQueryBuilder(this,e)}update(e){return new UpdateQueryBuilder(this,e)}delete(e){return new DeleteQueryBuilder(this,e)}async transaction(e){return await e(this)}}_a$3=entityKind;PodAsyncSession[_a$3]="PodAsyncSession";const resolveCreateRequire$1=()=>{if(typeof window<"u")return null;try{const nodeRequire=eval("require");if(!nodeRequire)return null;const moduleLib=nodeRequire("module");return!moduleLib||typeof moduleLib.createRequire!="function"?null:moduleLib.createRequire}catch{return null}},createRequireFn=resolveCreateRequire$1(),isAbsoluteModuleFilename=i=>i.startsWith("file:")||i.startsWith("/")||/^[a-zA-Z]:[\\/]/.test(i),moduleFilename=typeof __filename=="string"&&isAbsoluteModuleFilename(__filename)?__filename:typeof process<"u"&&typeof process.cwd=="function"?`${process.cwd().replace(/\/$/,"")}/package.json`:"/package.json",createDefaultRequireModule=()=>{if(!createRequireFn)return null;try{return createRequireFn(moduleFilename)}catch{return null}},defaultRequireModule=createDefaultRequireModule(),patchActionObserverHttp=(i,e)=>{if(!i)return!1;try{const t=i(e);if(t&&t.ActionObserverHttp){if(t.ActionObserverHttp.prototype.__drizzleSolidObservedActorsPatchApplied)return!0;const n=t.ActionObserverHttp.prototype.onRun;return t.ActionObserverHttp.prototype.onRun=function(s,a,u){return(!this.observedActors||!Array.isArray(this.observedActors))&&(this.observedActors=[]),n.call(this,s,a,u)},t.ActionObserverHttp.prototype.__drizzleSolidObservedActorsPatchApplied=!0,!0}return!1}catch{return!1}},applyComunicaPatches=(i=defaultRequireModule)=>i?["@comunica/actor-query-result-serialize-sparql-json","@comunica/actor-query-result-serialize-stats","@comunica/query-sparql-solid/node_modules/@comunica/actor-query-result-serialize-sparql-json","@comunica/query-sparql-solid/node_modules/@comunica/actor-query-result-serialize-stats"].map(t=>patchActionObserverHttp(i,t)).some(Boolean):!1;applyComunicaPatches();let configuredQueryEngineFactory=null;const resolveCreateRequire=async()=>{if(typeof window<"u")return null;try{const nodeRequire=eval("require");if(nodeRequire){const i=nodeRequire("module");if(i&&typeof i.createRequire=="function")return i.createRequire}}catch{}try{const i=await __vitePreload(()=>import("node:module"),[]);if(typeof i.createRequire=="function")return i.createRequire}catch{}return null},buildMissingComunicaError=i=>{const e=i instanceof Error&&i.message?` Original error: ${i.message}`:"";return new Error("A SPARQL query engine is required for this operation. Install `@comunica/query-sparql-solid` in the consuming app, or provide `sparql.createQueryEngine` to `drizzle(...)`, or call `configureSparqlEngine(...)` before executing LDP/SPARQL-client queries."+e)},loadComunicaModuleWithRequire=async i=>{const e=await resolveCreateRequire();if(!e)throw new Error("Node module resolution is not available in this runtime.");const t=e(i);applyComunicaPatches(t);const n=t("@comunica/query-sparql-solid");if(applyComunicaPatches(t),!n||typeof n.QueryEngine!="function")throw new Error("Resolved module does not export QueryEngine.");return n},loadDefaultComunicaModule=async()=>{try{return await loadComunicaModuleWithRequire(typeof __filename=="string"?__filename:typeof process<"u"&&typeof process.cwd=="function"?`${process.cwd().replace(/\/$/,"")}/package.json`:"/package.json")}catch(i){try{applyComunicaPatches();const e=await __vitePreload(()=>import("@comunica/query-sparql-solid"),[]);if(applyComunicaPatches(),e&&typeof e.QueryEngine=="function")return e}catch(e){throw buildMissingComunicaError(e??i)}throw buildMissingComunicaError(i)}},createDefaultQueryEngine=async()=>{const i=await loadDefaultComunicaModule();return new i.QueryEngine},getConfiguredSparqlEngineFactory=i=>i??configuredQueryEngineFactory??createDefaultQueryEngine;class ComunicaSPARQLExecutor{constructor(e){this.engine=null,this.sources=[...e.sources],this.fetchFn=this.createSafeFetch(e.fetch||fetch),this.logging=e.logging||!1,this.createQueryEngine=getConfiguredSparqlEngineFactory(e.createQueryEngine)}formatError(e){return e instanceof Error?e.message:String(e)}createSourceRef(e,t="auto"){return t==="sparql"?{type:"sparql",value:e}:e}createSafeFetch(e){return async(t,n)=>{try{const s=await e(t,n),a=new Map;s.headers&&s.headers.forEach((h,f)=>{a.set(f.toLowerCase(),h||"")});const c={...s,headers:{get:h=>{const f=h.toLowerCase();return a.get(f)||null},has:h=>{const f=h.toLowerCase();return a.has(f)},forEach:h=>{a.forEach((f,p)=>h(f,p))},entries:()=>a.entries(),keys:()=>a.keys(),values:()=>a.values(),[Symbol.iterator]:()=>a.entries(),includes:h=>{if(!h)return!1;for(const[f,p]of Array.from(a.entries()))if(f.toLowerCase().includes(h.toLowerCase())||p.toLowerCase().includes(h.toLowerCase()))return!0;return!1}},status:s.status||200,statusText:s.statusText||"OK",ok:s.ok!==void 0?s.ok:!0,url:s.url||(typeof t=="string"?t:t.toString()),type:s.type||"basic",redirected:s.redirected||!1,body:s.body,bodyUsed:s.bodyUsed||!1,includes:h=>{if(!h)return!1;for(const[f,p]of Array.from(a.entries()))if(f.toLowerCase().includes(h.toLowerCase())||p.toLowerCase().includes(h.toLowerCase()))return!0;return!1},text:async()=>{try{return await s.text()}catch(h){return this.logging&&console.warn("[SafeFetch] Text parsing failed:",this.formatError(h)),""}},json:async()=>{try{return await s.json()}catch(h){return this.logging&&console.warn("[SafeFetch] JSON parsing failed:",this.formatError(h)),{}}},clone:()=>{try{return this.createSafeFetch(e)(t,n)}catch(h){return this.logging&&console.warn("[SafeFetch] Clone failed:",this.formatError(h)),c}}};return c}catch(s){throw this.logging&&console.error("[SafeFetch] Error:",this.formatError(s)),s}}}async initEngine(){return this.engine||(this.engine=await this.createQueryEngine()),this.engine}async executeQuery(e){try{const t=await this.initEngine();if(this.logging&&console.log(`[Comunica] Executing ${e.type} query:`,e.query),e.type==="SELECT")return await this.executeSelectInternal(e,t);if(e.type==="ASK")return await this.executeAskInternal(e,t);if(["INSERT","UPDATE","DELETE"].includes(e.type))return await this.executeUpdate(e,t);throw new Error(`Unsupported query type: ${e.type}`)}catch(t){throw console.error("SPARQL query execution failed:",this.formatError(t)),t}}async executeSelect(e){try{this.logging&&console.log("[SPARQL] Executing SELECT query with full processing");const t={type:"SELECT",query:e.trim()},n=this.sources[0];if(!n)throw new Error("No data sources configured");return this.logging&&(console.log("[SPARQL] Query object:",t),console.log("[SPARQL] Source URL:",n)),await this.executeQueryWithSource(t,n)}catch(t){throw this.logging&&console.error("[Simple] SELECT query execution failed:",this.formatError(t)),t}}async queryBindings(e,t){return await(await(await this.initEngine()).queryBindings(e,{sources:[t],fetch:this.fetchFn})).toArray()}async executeSelectInternal(e,t){try{if(this.sources.length===0)throw new Error("No sources configured for SPARQL query");return(await(await t.queryBindings(e.query,{sources:this.sources,fetch:this.fetchFn,httpTimeout:3e4,httpRetryCount:1,httpRetryDelay:1e3})).toArray()).map(a=>{const u=a,c={},h=(f,p)=>{const g=this.extractBindingKeyName(f);g&&(c[g]=this.convertComunicaTerm(p))};if(u&&typeof u.forEach=="function")u.forEach((f,p)=>h(p,f));else if(u&&typeof u.entries=="function")for(const[f,p]of u.entries())h(f,p);else for(const f in u)Object.prototype.hasOwnProperty.call(u,f)&&h(f,u[f]);return c})}catch(n){throw console.error("SELECT query failed:",this.formatError(n)),n}}async executeAskInternal(e,t){try{if(this.logging&&console.log("[Comunica] Executing ASK query:",e.query),this.sources.length===0)throw new Error("No sources configured for SPARQL query");return[{result:await t.queryBoolean(e.query,{sources:this.sources,fetch:this.fetchFn,httpTimeout:3e4,httpRetryCount:1,httpRetryDelay:1e3})}]}catch(n){throw console.error("ASK query failed:",this.formatError(n)),n}}async executeUpdate(e,t){try{this.logging&&console.log(`[Simple] Executing ${e.type} query:`,e.query);const n=[];for(const s of this.sources)try{this.logging&&console.log(`[Comunica] Executing UPDATE query on ${s}:`,e.query.substring(0,100)+"...");let a=null;try{const f=await this.fetchFn(s,{method:"HEAD",headers:{Accept:"text/turtle"}});f.ok&&(a=f.headers.get("ETag"),this.logging&&a&&console.log(`[UPDATE] Got ETag for ${s}: ${a}`))}catch{this.logging&&console.log(`[UPDATE] HEAD request failed for ${s}, continuing without ETag`)}const u={"Content-Type":"application/sparql-update","If-Match":a??"*"},c=async f=>this.fetchFn(s,{method:"PATCH",headers:f,body:e.query}),h=await c(u);if(h.ok)n.push({success:!0,source:s,status:h.status}),await this.invalidateCache(t,s);else if(h.status===409||h.status===412){this.logging&&console.log(`[UPDATE] ${h.status} conflict for ${s}, trying multiple retry strategies`);let f=!1;if(h.status===412)try{const p=await this.fetchFn(s,{method:"HEAD",headers:{Accept:"text/turtle"}});if(p.ok){const g=p.headers.get("ETag");if(g){const y={...u,"If-Match":g},S=await c(y);S.ok&&(n.push({success:!0,source:s,status:S.status,retried:!0,strategy:"refreshed-etag"}),await this.invalidateCache(t,s),f=!0)}}}catch(p){this.logging&&console.log("[UPDATE] Retry with refreshed ETag failed:",p)}if(!f)try{const p=await c({"Content-Type":"application/sparql-update"});p.ok&&(n.push({success:!0,source:s,status:p.status,retried:!0,strategy:"no-etag"}),await this.invalidateCache(t,s),f=!0)}catch(p){this.logging&&console.log("[UPDATE] Retry strategy 1 failed:",p)}if(!f)try{if((await this.fetchFn(s,{method:"GET",headers:{Accept:"text/turtle"}})).ok){const g=await this.fetchFn(s,{method:"PUT",headers:{"Content-Type":"application/sparql-update"},body:e.query});g.ok&&(n.push({success:!0,source:s,status:g.status,retried:!0,strategy:"put-method"}),await this.invalidateCache(t,s),f=!0)}}catch(p){this.logging&&console.log("[UPDATE] Retry strategy 2 failed:",p)}if(!f){const p=await h.text();n.push({success:!1,source:s,error:`All retry strategies failed: ${h.status} ${h.statusText}`,details:p})}}else{const f=await h.text();n.push({success:!1,source:s,error:`${h.status} ${h.statusText}`,details:f})}}catch(a){n.push({success:!1,source:s,error:this.formatError(a)})}return n}catch(n){throw console.error("UPDATE query failed:",this.formatError(n)),n}}async invalidateHttpCache(e){this.engine&&(await this.invalidateCache(this.engine,e),await this.invalidateCache(this.engine,void 0))}async invalidateCache(e,t){const n=e.invalidateHttpCache;if(typeof n=="function")try{await n.call(e,t)}catch(s){this.logging&&console.warn(`[UPDATE] Failed to invalidate cache for ${t}:`,this.formatError(s))}}extractBindingKeyName(e){if(e==null)return null;if(typeof e=="string")return e;if(typeof e=="object"){const t=e;if(t&&typeof t.value=="string"||t&&t.termType==="Variable"&&typeof t.value=="string")return t.value}return typeof e=="symbol"?e.description??e.toString():String(e)}convertComunicaTerm(e){if(!e)return null;const t=e;switch(t.termType){case"NamedNode":return t.value;case"Literal":if(t.datatype&&t.datatype.value){const n=t.datatype.value;if(typeof n=="string"){if(n.includes("#integer")||n.includes("#int"))return parseInt(String(t.value),10);if(n.includes("#decimal")||n.includes("#double"))return parseFloat(String(t.value));if(n.includes("#boolean"))return t.value==="true";if(n.includes("#dateTime"))return new Date(String(t.value));if(n.includes("#json"))try{return JSON.parse(String(t.value))}catch(s){return console.warn("Failed to parse JSON value:",t.value,this.formatError(s)),t.value}else if(n.includes("#jsonArray")||n.includes("solid/terms#jsonArray"))try{const s=JSON.parse(String(t.value));return Array.isArray(s)?s:(console.warn("Expected array but got:",typeof s,s),[s])}catch(s){return console.warn("Failed to parse JSON Array value:",t.value,this.formatError(s)),[t.value]}}}return t.value;case"BlankNode":return`_:${String(t.value)}`;default:return t.value}}async queryContainer(e,t){const n=e&&e.startsWith("http")?e:`${this.sources[0]}${e||""}`;let s;return t?s=t:s={type:"SELECT",query:`
126
+ SELECT ?subject ?predicate ?object WHERE {
127
+ ?subject ?predicate ?object .
128
+ FILTER(STRSTARTS(STR(?subject), "${n}"))
129
+ }
130
+ `},this.executeQueryWithSource(s,n)}async executeQueryWithSource(e,t,n="auto"){try{const s=await this.initEngine(),a=this.createSourceRef(t,n);if(this.logging&&(console.log(`[Comunica] Executing ${e.type} query on ${t}:`,e.query),console.log("[Debug] sparqlQuery object:",JSON.stringify(e,null,2))),e.type==="SELECT"){const c=await(await s.queryBindings(e.query,{sources:[a],fetch:this.fetchFn})).toArray(),h=c.map(f=>{const p=f,g={};if(this.logging&&c.indexOf(f)===0&&(console.log("[Debug] Binding object:",p),console.log("[Debug] Binding type:",typeof p),console.log("[Debug] Binding constructor:",p.constructor?.name),console.log("[Debug] Binding keys:",Object.keys(p)),console.log("[Debug] Has entries method:",typeof p.entries),console.log("[Debug] Has keys method:",typeof p.keys),console.log("[Debug] Has get method:",typeof p.get)),p.entries&&typeof p.entries=="function")try{for(const[y,S]of p.entries()){const w=this.extractBindingKeyName(y);w&&(g[w]=this.convertComunicaTerm(S))}}catch(y){console.warn("[Warning] binding.entries() failed:",this.formatError(y))}else if(p.keys&&typeof p.keys=="function"&&typeof p.get=="function")try{for(const y of p.keys()){const S=p.get(y);if(S){const w=this.extractBindingKeyName(y);if(!w)continue;const R=this.convertComunicaTerm(S);g[w]=R,this.logging&&c.indexOf(f)===0&&(console.log(`[Debug] Variable: ${w}, Term: ${R}`),console.log("[Debug] Variable object:",y),console.log("[Debug] Term object:",S))}}}catch(y){console.warn("[Warning] binding.keys()/get() failed:",this.formatError(y))}if(Object.keys(g).length===0){for(const y in p)if(Object.prototype.hasOwnProperty.call(p,y)&&y!=="type"&&y!=="size"){const S=p[y];if(S){const w=this.extractBindingKeyName(y);w&&(g[w]=this.convertComunicaTerm(S))}}}return g});return this.logging&&console.log(`[Comunica] ${e.type} query results:`,h),h}else if(e.type==="ASK"){const u=await s.queryBoolean(e.query,{sources:[a],fetch:this.fetchFn});return this.logging&&console.log(`[Comunica] ${e.type} query result:`,u),[{result:u}]}else{const u=this.sources;this.sources=[t];try{const c=await this.executeUpdate(e,s),h=c.filter(f=>!f.success);if(h.length>0){const f=h[0],p=f&&f.error?f.error:"UPDATE operation failed";throw new Error(p)}return this.logging&&console.log(`[Comunica] ${e.type} operation completed successfully`),c}finally{this.sources=u}}}catch(s){throw this.logging&&console.error("[Comunica] Query execution failed:",this.formatError(s)),s}}addSource(e){this.sources.includes(e)||this.sources.push(e)}removeSource(e){const t=this.sources.indexOf(e);t>-1&&this.sources.splice(t,1)}getSources(){return[...this.sources]}}const SolidSPARQLExecutor=ComunicaSPARQLExecutor,sparqlExecutor=Object.freeze(Object.defineProperty({__proto__:null,ComunicaSPARQLExecutor,SolidSPARQLExecutor},Symbol.toStringTag,{value:"Module"}));var define_process_env_default$1={};class PodExecutor{constructor(e){this.deps=e}async query(e){await this.deps.ensureConnected(),await this.deps.ensureTableResourcePath(e.table);const t=this.deps.resolveTableResource(e.table),n=e.type==="select"?this.getSelectStrategy(e,t):this.deps.getLdpStrategy(),{containerUrl:s,resourceUrl:a}=this.deps.resolveTableUrls(e.table),u=this.deps.normalizeResourceUrl(a),h=(e.type==="select"?this.getExactSelectResourceUrl(e):void 0)??(e.type==="select"&&t.mode==="sparql"?t.endpoint:u);try{switch(e.type){case"select":return await this.executeSelect(e,n,s,h);case"insert":return await this.executeInsert(e,n,s,u,t);case"update":return await this.executeUpdate(e,n,s,u,t);case"delete":return await this.executeDelete(e,n,s,u,t);default:throw new Error(`Unsupported operation type: ${e.type}`)}}catch(f){throw typeof process<"u"&&define_process_env_default$1?.LINX_DEBUG==="1"&&console.error(`${e.type.toUpperCase()} operation failed:`,f),f}}shouldSkipResourcePreparation(){return this.deps.shouldSkipResourcePreparation?.()??!1}shouldUseWriteTimeResourcePreparation(){return this.deps.shouldUseWriteTimeResourcePreparation?.()??this.shouldSkipResourcePreparation()}shouldContinueAfterResourcePreparationError(){return this.deps.shouldContinueAfterResourcePreparationError?.()??!1}async prepareResource(e,t){if(!this.shouldSkipResourcePreparation())try{await t()}catch(n){if(!this.shouldContinueAfterResourcePreparationError())throw n;typeof process<"u"&&define_process_env_default$1?.LINX_DEBUG==="1"&&console.warn(`[${e}] Resource preparation failed; continuing in best-effort mode:`,n)}}async executeSelect(e,t,n,s){let a;if(e.plan&&this.deps.isSelectPlan(e.plan))a=e.plan;else{if(e.plan&&!this.deps.isSelectPlan(e.plan))throw new Error("Invalid plan supplied for select operation");{const c=e.table.config.name??"table",h={baseTable:e.table,baseAlias:c,selectAll:!0,conditionTree:e.where,limit:e.limit,offset:e.offset,distinct:e.distinct,aliasToTable:new Map([[c,e.table]]),tableToAlias:new Map([[e.table,c]])};h._simpleSelectOptions=e.sql?void 0:{table:e.table,where:e.where,limit:e.limit,offset:e.offset,orderBy:e.orderBy,distinct:e.distinct},h._sql=e.sql,a=h}}return await t.executeSelect(a,n,s)}getSelectStrategy(e,t){return this.deps.getStrategy(e.table)}isExactIriSelect(e){const t=e.where;if(!t||typeof t!="object"||"type"in t)return!1;const n=t["@id"];return typeof n=="string"&&n.startsWith("http")}getExactSelectResourceUrl(e){if(!this.isExactIriSelect(e))return;const t=e.where["@id"],n=t.indexOf("#");return n>=0?t.slice(0,n):t}async executeInsert(e,t,n,s,a){const u=Array.isArray(e.values)?e.values:[e.values];if(!u||u.length===0)throw new Error("INSERT operation requires at least one value");const c=this.shouldUseWriteTimeResourcePreparation(),h=c&&!this.shouldSkipResourcePreparation();if(!c&&!this.deps.preparedContainers.has(this.deps.normalizeContainerKey(n))&&await this.prepareResource("INSERT",()=>this.deps.ensureContainerExists(n)),a.mode==="ldp"&&!c&&!this.deps.preparedResources.has(this.deps.normalizeResourceKey(s))&&await this.prepareResource("INSERT",()=>this.deps.ensureResourceExists(s,{createIfMissing:!0})),a.mode==="ldp"&&!c)for(const g of u)try{const y=this.deps.sparqlConverter.generateSubjectUri(g,e.table),S={type:"ASK",query:`ASK { <${y}> ?p ?o }`,prefixes:{}};if((await this.deps.sparqlExecutor.executeQueryWithSource(S,s))[0]?.result)throw new Error(`Duplicate primary key: ${y} already exists.`)}catch(y){if(y.message&&y.message.includes("Duplicate primary key"))throw y;await this.deps.sparqlExecutor.invalidateHttpCache(s)}const f={...this.deps.isInsertPlan(e.plan)?e.plan:{table:e.table,rows:u},ensureContainerExists:c?void 0:async g=>{await this.prepareResource("INSERT",()=>this.deps.ensureContainerExists(g))},repairContainerOnWriteFailure:h?async g=>{await this.prepareResource("INSERT",()=>this.deps.ensureContainerExists(g))}:void 0,skipResourceExistenceCheck:c||this.deps.isInsertPlan(e.plan)&&e.plan.skipResourceExistenceCheck===!0,tableRegistry:this.deps.getTableRegistries?.().tableRegistry,tableNameRegistry:this.deps.getTableRegistries?.().tableNameRegistry};if(!t.executeInsert)throw new Error("Strategy does not support INSERT operations");return await t.executeInsert(f,n,s)}async executeUpdate(e,t,n,s,a){if(!e.data)throw new Error("UPDATE operation requires data");if(!e.where||Object.keys(e.where).length===0)throw new Error("UPDATE operation requires where conditions to locate target resources");if(a.mode==="ldp"&&!this.shouldUseWriteTimeResourcePreparation()){if(!this.deps.preparedContainers.has(this.deps.normalizeContainerKey(n)))try{await this.prepareResource("UPDATE",()=>this.deps.ensureContainerExists(n))}catch(h){const f=h instanceof Error?h.message:String(h);if(f.includes("Failed to check container: 401")||f.includes("Failed to check container: 403"))console.warn(`[UPDATE] Skipping container existence check for ${n}: ${f}`);else throw h}this.deps.preparedResources.has(this.deps.normalizeResourceKey(s))||await this.prepareResource("UPDATE",()=>this.deps.ensureResourceExists(s,{createIfMissing:!1}))}const u=this.deps.isUpdatePlan(e.plan)?e.plan:{table:e.table,data:e.data,where:e.where};if(a.mode==="sparql"){const h=await this.deps.ensureIdentifierCondition(u.where,u.table,s);if(!h)return console.warn("[UPDATE] No matching subjects found for provided condition, skipping update."),[];u.where=h}if(!t.executeUpdate)throw new Error("Strategy does not support UPDATE operations");return await t.executeUpdate(u,n,s)}async executeDelete(e,t,n,s,a){if(a.mode==="ldp"&&!this.shouldUseWriteTimeResourcePreparation()&&(this.deps.preparedContainers.has(this.deps.normalizeContainerKey(n))||await this.prepareResource("DELETE",()=>this.deps.ensureContainerExists(n)),!(this.deps.preparedResources.has(this.deps.normalizeResourceKey(s))||this.shouldSkipResourcePreparation()?!0:await this.deps.resourceExists(s))))return console.log("[DELETE] Target resource does not exist, skipping execution"),[{success:!0,source:s,status:404}];const u=this.deps.isDeletePlan(e.plan)?e.plan:{table:e.table,where:e.where};if(a.mode==="sparql"&&u.where){const h=await this.deps.ensureIdentifierCondition(u.where,u.table,s);if(!h)return console.warn("[DELETE] No matching subjects found for provided condition, skipping delete."),[];u.where=h}if(!t.executeDelete)throw new Error("Strategy does not support DELETE operations");return await t.executeDelete(u,n,s)}}function isSameOrigin(i,e){try{const t=new URL(i),n=new URL(e);return t.origin===n.origin}catch{return!1}}function getFetchForOrigin(i,e,t){return isSameOrigin(i,e)?t:fetch}const normalize=i=>i.endsWith("/")?i:`${i}/`,pickSameOrigin=(i,e)=>{try{const t=new URL(i).origin;return e.find(s=>{try{return new URL(s).origin===t}catch{return!1}})||null}catch{return null}},deriveFromUrl=i=>{if(!i||i.trim().length===0)return null;try{const e=new URL(i),n=e.pathname.split("/").filter(Boolean)[0],s=n&&n!=="profile"?`/${n}/`:"/";return normalize(`${e.origin}${s}`)}catch{return null}};function resolvePodBase(i){const{webId:e,podUrl:t,storages:n}=i,s=(n||[]).filter(Boolean);if(s.length>0){const f=pickSameOrigin(e,s)||s[0];return normalize(f)}const a=deriveFromUrl(t),u=deriveFromUrl(e),c=h=>{if(!h)return!1;try{return new URL(h).pathname!=="/"}catch{return!1}};if(c(a))return a;if(c(u))return u;if(a)return a;if(u)return u;try{const h=new URL(e);return normalize(h.origin)}catch{return normalize(e)}}const PIM_STORAGE="http://www.w3.org/ns/pim/space#storage",SOLID_POD="http://www.w3.org/ns/solid/terms#pod";class WebIdResolver{constructor(){this.cache=new Map}extractStorageFromProfile(e,t,n){const s=n?.split(";")[0]?.trim().toLowerCase(),u=new N3Parser$1({baseIRI:e,format:s==="application/n-triples"?"N-Triples":void 0}).parse(t),c=[PIM_STORAGE,SOLID_POD];for(const h of c){const f=u.find(p=>p.subject.value===e&&p.predicate.value===h);if(f?.object?.value)return f.object.value}return null}async resolveStorage(e,t){if(this.cache.has(e))return this.cache.get(e)??null;try{const s=await(t??fetch)(e,{headers:{Accept:"text/turtle, application/n-triples;q=0.9, text/n3;q=0.8, */*;q=0.1"}});if(!s.ok)throw new Error(`Failed to fetch WebID profile: ${s.status} ${s.statusText}`);const a=await s.text(),u=this.extractStorageFromProfile(e,a,s.headers.get("content-type"));if(u){const c=u.endsWith("/")?u:`${u}/`;return console.log(`[WebIdResolver] Resolved storage for ${e} -> ${c}`),this.cache.set(e,c),c}}catch(n){console.warn(`[WebIdResolver] Failed to resolve storage for ${e}`,n)}return null}clearCache(){this.cache.clear()}}const webIdResolver=new WebIdResolver,REQUEST_ID_DETECTION_TIMEOUT_MS=3e3;function generateRequestId(){const i=Date.now().toString(36),e=Math.random().toString(36).substring(2,8);return`${i}-${e}`}class PodRuntime{constructor(e){this.storageUrl=null,this.storageResolvedAt=0,this.connected=!1,this.wrappedFetch=null,this.requestIdSupported=null,this.storageTTL=300*1e3,this.session=e.session,this.webId=e.webId,this.podUrl=resolvePodBase({webId:this.webId,podUrl:e.podUrl}),this.explicitPodUrl=typeof e.podUrl=="string"&&e.podUrl.trim().length>0,e.storageTTL!==void 0&&(this.storageTTL=e.storageTTL)}async detectRequestIdSupport(){const e=new AbortController,t=setTimeout(()=>e.abort(),REQUEST_ID_DETECTION_TIMEOUT_MS);try{return((await globalThis.fetch(this.podUrl,{method:"OPTIONS",signal:e.signal})).headers.get("Access-Control-Allow-Headers")||"").toLowerCase().includes("x-request-id")}catch{return!1}finally{clearTimeout(t)}}createWrappedFetch(){const e=this.session.fetch,t=this;return async(n,s)=>{if(!t.requestIdSupported)return e(n,s);const a=generateRequestId(),u=new Headers(s?.headers);return u.has("X-Request-ID")||u.set("X-Request-ID",a),e(n,{...s,headers:u})}}getSession(){return this.session}getFetch(){return this.wrappedFetch||(this.wrappedFetch=this.createWrappedFetch()),this.wrappedFetch}getWebId(){return this.webId}getPodUrl(){return this.podUrl}getStorageUrl(){return this.storageUrl}isStorageExpired(){return this.storageResolvedAt?Date.now()-this.storageResolvedAt>this.storageTTL:!0}async getPodUrlWithRefresh(){return this.isStorageExpired()&&await this.refreshStorage(),this.podUrl}async refreshStorage(){if(this.explicitPodUrl)return this.storageUrl=this.podUrl,this.storageResolvedAt=Date.now(),this.storageUrl;webIdResolver.clearCache();const e=await webIdResolver.resolveStorage(this.webId,this.getFetch());return e&&(this.storageUrl=e,this.storageResolvedAt=Date.now(),!this.explicitPodUrl&&e!==this.podUrl&&(console.log(`[PodRuntime] Storage refreshed: ${e}`),this.podUrl=e)),this.storageUrl}setPodUrl(e){this.podUrl=e.endsWith("/")?e:`${e}/`}isConnected(){return this.connected}async connect(){if(!this.connected)try{if(console.log(`Connecting to Solid Pod: ${this.podUrl}`),console.log(`Using WebID: ${this.webId}`),this.explicitPodUrl){this.requestIdSupported=!1,this.wrappedFetch=this.createWrappedFetch(),this.storageUrl=this.podUrl,this.storageResolvedAt=Date.now(),this.connected=!0,console.log("Using explicit Pod URL; skipping Pod root probe");return}this.requestIdSupported=await this.detectRequestIdSupport(),this.wrappedFetch=this.createWrappedFetch();const e=await webIdResolver.resolveStorage(this.webId,this.wrappedFetch);e&&(this.storageUrl=e,this.storageResolvedAt=Date.now(),e!==this.podUrl&&(console.log(`[PodRuntime] IdP-SP separation detected: storage at ${e}`),this.podUrl=e));const t=await this.wrappedFetch(this.podUrl,{method:"HEAD"}),n=t.status;if(n===500&&!this.explicitPodUrl){const s=this.requestIdSupported?t.headers.get("X-Request-ID")||"unknown":"disabled";throw console.error(`Pod probe failed, X-Request-ID: ${s}`),new Error(`Failed to connect to Pod: ${n} ${t.statusText}`)}n===500&&this.explicitPodUrl&&console.warn(`Pod root returned ${n} for explicit Pod URL, continuing (child resources may still be writable)`),t.ok?console.log("Successfully connected to Solid Pod"):console.warn(n===401||n===403?`Pod root returned ${n}, continuing (child resources may still be writable)`:`Pod root returned ${n}, continuing (child resources may still be writable)`),this.connected=!0}catch(e){throw console.error("Failed to connect to Pod:",e),e}}async disconnect(){this.connected=!1,console.log("Disconnected from Solid Pod")}}var Wildcard={},hasRequiredWildcard;function requireWildcard(){if(hasRequiredWildcard)return Wildcard;hasRequiredWildcard=1;let i=class{constructor(){return e||this}equals(n){return n&&this.termType===n.termType}};Object.defineProperty(i.prototype,"value",{enumerable:!0,value:"*"}),Object.defineProperty(i.prototype,"termType",{enumerable:!0,value:"Wildcard"});var e=new i;return Wildcard.Wildcard=i,Wildcard}var SparqlParser_1,hasRequiredSparqlParser;function requireSparqlParser(){if(hasRequiredSparqlParser)return SparqlParser_1;hasRequiredSparqlParser=1;var i=(function(){var e=function(ot,rt,ut,mt){for(ut=ut||{},mt=ot.length;mt--;ut[ot[mt]]=rt);return ut},t=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],n=[2,247],s=[100,110,113,115,116,123,126,131,329,330,331,332,333],a=[2,409],u=[1,18],c=[1,27],h=[13,16,45,197,224,229,308],f=[28,29,53],p=[28,53],g=[1,42],y=[1,45],S=[1,41],w=[1,44],R=[123,126],T=[1,67],A=[39,45,87],F=[13,16,45,197,224,308],x=[1,87],D=[2,281],O=[1,86],K=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],z=[6,28,29,53,63,70,73,81,83,85],X=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],Ee=[6,13,16,28,29,45,53,63,70,73,81,82,83,85,87,89,197,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314],q=[6,13,16,28,29,31,39,45,47,48,53,63,70,73,81,82,83,85,87,89,109,112,121,123,126,128,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,337,338,340,341,342,343,344,345,346],Y=[13,16,308],Te=[112,132,327,334],re=[13,16,112,132,308],$e=[1,111],ze=[1,117],ye=[112,132,327,328,334],Ve=[13,16,112,132,308,328],pe=[28,29,45,53,87],De=[1,138],$=[1,151],G=[1,128],ce=[1,127],oe=[1,129],Fe=[1,140],Ue=[1,141],Je=[1,142],He=[1,143],he=[1,144],fe=[1,145],Oe=[1,147],ie=[1,148],j=[2,457],N=[1,158],L=[1,159],V=[1,160],ee=[1,152],ae=[1,153],ve=[1,156],J=[1,171],me=[1,172],xe=[1,173],de=[1,174],st=[1,175],ft=[1,176],Ge=[1,167],pt=[1,168],Z=[1,169],P=[1,170],B=[1,157],U=[1,166],Ie=[1,161],Me=[1,162],Pe=[1,163],gt=[1,164],_t=[1,165],Tt=[6,13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335],kt=[1,195],Ft=[6,31,73,81,83,85],sn=[2,285],Yt=[1,199],Dt=[1,201],vr=[6,31,70,73,81,83,85],Bt=[2,283],dr=[1,207],nr=[1,218],Vr=[1,223],M=[1,219],H=[1,225],Be=[1,226],qe=[1,224],at=[6,63,70,73,81,83,85],Ut=[1,236],Ht=[2,334],on=[1,243],Sr=[1,241],sr=[6,193],bn=[2,349],Hr=[2,339],qt=[28,128],fr=[47,48,193,272],Dr=[47,48,193,242,272],Mr=[47,48,193,242,246,272],Lt=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],Rt=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],hr=[1,271],oi=[1,270],br=[6,13,16,29,31,39,45,47,48,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],or=[1,281],ai=[1,280],Pr=[13,16,29,31,39,45,47,48,82,85,87,89,112,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346],vn=[45,89],Er=[13,16,29,31,39,45,47,48,82,85,87,89,112,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346],_i=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],wi=[31,89],Sn=[48,87],hn=[6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337,338],En=[6,13,16,39,45,48,82,87,89,231,263,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337,338,340],ws=[1,313],_=[6,85],b=[6,31,81,83,85],v=[2,361],I=[2,353],k=[1,343],Q=[31,112,335],te=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],we=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335],ge=[6,109,193],be=[31,112],_e=[13,16,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],Re=[1,390],Ce=[1,391],Le=[13,16,87,197,308,314],We=[13,16,39,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],Xe=[1,417],et=[1,418],ne=[13,16,48,197,229,308],Se=[6,31,85],Ae=[6,13,16,31,45,73,81,83,85,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],Ne=[6,13,16,29,31,45,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,231,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,346,347,348,349,350,351],Qe=[29,31,85,112,159,160,161,163,164],nt=[1,443],bt=[1,444],ht=[1,449],Ct=[31,112,193,232,318,335],yt=[13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],wt=[13,16,31,45,48,82,87,89,112,193,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],Jt=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],Qt=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Mt=[31,45],Ir=[1,507],Lr=[1,508],Ur=[6,13,16,29,31,39,45,47,48,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,336,338,341,342,343,344,345,346,347,348,349,350,351],ar=[29,31,85,112,159,160,161,163,164,335],Xt=[6,13,16,31,45,70,73,81,83,85,87,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],ir=[13,16,31,45,48,82,87,89,112,193,197,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],Or=[2,352],_n=[13,16,197,308,314],tn=[1,565],pn=[6,13,16,31,45,76,78,81,83,85,87,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],Tn=[13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],gn=[13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335],Fn=[13,16,87,308],wr=[2,364],$r=[29,31,85,112,159,160,161,163,164,193,232,318,335],Cr=[31,112,193,232,272,318,335],kr=[2,359],Mn=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],mn=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],Mi=[13,16,31,45,82,87,89,112,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],qn=[2,347],Xr={trace:function(){},yy:{},symbols_:{error:2,QueryOrUpdate:3,Prologue:4,QueryOrUpdate_group0:5,EOF:6,Query:7,Qry:8,Query_option0:9,Prologue_repetition0:10,BaseDecl:11,BASE:12,IRIREF:13,PrefixDecl:14,PREFIX:15,PNAME_NS:16,SelectClauseWildcard:17,Qry_repetition0:18,WhereClause:19,SolutionModifierNoGroup:20,SelectClauseVars:21,Qry_repetition1:22,SolutionModifier:23,CONSTRUCT:24,ConstructTemplate:25,Qry_repetition2:26,Qry_repetition3:27,WHERE:28,"{":29,Qry_option0:30,"}":31,DESCRIBE:32,Qry_group0:33,Qry_repetition4:34,Qry_option1:35,ASK:36,Qry_repetition5:37,SelectClauseBase:38,"*":39,SelectClauseVars_repetition_plus0:40,SELECT:41,SelectClauseBase_option0:42,SelectClauseItem:43,Var:44,"(":45,Expression:46,AS:47,")":48,SubSelect:49,SubSelect_option0:50,SubSelect_option1:51,DatasetClause:52,FROM:53,DatasetClause_option0:54,iri:55,WhereClause_option0:56,GroupGraphPattern:57,SolutionModifier_option0:58,SolutionModifierNoGroup_option0:59,SolutionModifierNoGroup_option1:60,SolutionModifierNoGroup_option2:61,GroupClause:62,GROUP:63,BY:64,GroupClause_repetition_plus0:65,GroupCondition:66,BuiltInCall:67,FunctionCall:68,HavingClause:69,HAVING:70,HavingClause_repetition_plus0:71,OrderClause:72,ORDER:73,OrderClause_repetition_plus0:74,OrderCondition:75,ASC:76,BrackettedExpression:77,DESC:78,Constraint:79,LimitOffsetClauses:80,LIMIT:81,INTEGER:82,OFFSET:83,ValuesClause:84,VALUES:85,InlineData:86,VAR:87,InlineData_repetition0:88,NIL:89,InlineData_repetition1:90,InlineData_repetition_plus2:91,InlineData_repetition3:92,DataBlock:93,DataBlockValueList:94,DataBlockValueList_repetition_plus0:95,Update:96,Update_repetition0:97,Update1:98,Update_option0:99,LOAD:100,Update1_option0:101,Update1_option1:102,Update1_group0:103,Update1_option2:104,GraphRefAll:105,Update1_group1:106,Update1_option3:107,GraphOrDefault:108,TO:109,CREATE:110,Update1_option4:111,GRAPH:112,INSERTDATA:113,QuadPattern:114,DELETEDATA:115,DELETEWHERE:116,Update1_option5:117,InsertDeleteClause:118,Update1_repetition0:119,IntoGraphClause:120,INTO:121,GraphRef:122,DELETE:123,InsertDeleteClause_option0:124,InsertClause:125,INSERT:126,UsingClause:127,USING:128,UsingClause_option0:129,WithClause:130,WITH:131,DEFAULT:132,GraphOrDefault_option0:133,GraphRefAll_group0:134,Quads:135,Quads_option0:136,Quads_repetition0:137,QuadsNotTriples:138,VarOrIri:139,QuadsNotTriples_option0:140,QuadsNotTriples_option1:141,QuadsNotTriples_option2:142,TriplesTemplate:143,TriplesTemplate_repetition0:144,TriplesSameSubject:145,TriplesTemplate_option0:146,GroupGraphPatternSub:147,GroupGraphPatternSub_option0:148,GroupGraphPatternSub_repetition0:149,GroupGraphPatternSubTail:150,GraphPatternNotTriples:151,GroupGraphPatternSubTail_option0:152,GroupGraphPatternSubTail_option1:153,TriplesBlock:154,TriplesBlock_repetition0:155,TriplesSameSubjectPath:156,TriplesBlock_option0:157,GroupOrUnionGraphPattern:158,OPTIONAL:159,MINUS:160,SERVICE:161,GraphPatternNotTriples_option0:162,FILTER:163,BIND:164,InlineDataOneVar:165,InlineDataFull:166,InlineDataOneVar_repetition0:167,InlineDataFull_repetition0:168,InlineDataFull_repetition_plus1:169,InlineDataFull_repetition2:170,DataBlockValue:171,Literal:172,QuotedTriple:173,UNDEF:174,GroupOrUnionGraphPattern_repetition0:175,ArgList:176,ArgList_option0:177,ArgList_repetition0:178,ExpressionList:179,ExpressionList_repetition0:180,ConstructTemplate_option0:181,ConstructTriples:182,ConstructTriples_repetition0:183,ConstructTriples_option0:184,VarOrTermOrQuotedTP:185,PropertyListNotEmpty:186,TriplesNode:187,PropertyList:188,PropertyList_option0:189,VerbObjectList:190,PropertyListNotEmpty_repetition0:191,SemiOptionalVerbObjectList:192,";":193,SemiOptionalVerbObjectList_option0:194,Verb:195,ObjectList:196,a:197,ObjectList_repetition0:198,Object:199,GraphNode:200,Object_option0:201,PropertyListPathNotEmpty:202,TriplesNodePath:203,TriplesSameSubjectPath_option0:204,O:205,PropertyListPathNotEmpty_repetition0:206,PropertyListPathNotEmptyTail:207,O_group0:208,ObjectListPath:209,ObjectListPath_repetition0:210,ObjectPath:211,GraphNodePath:212,ObjectPath_option0:213,Path:214,Path_repetition0:215,PathSequence:216,PathSequence_repetition0:217,PathEltOrInverse:218,PathElt:219,PathPrimary:220,PathElt_option0:221,PathEltOrInverse_option0:222,IriOrA:223,"!":224,PathNegatedPropertySet:225,PathOneInPropertySet:226,PathNegatedPropertySet_repetition0:227,PathNegatedPropertySet_option0:228,"^":229,TriplesNode_repetition_plus0:230,"[":231,"]":232,TriplesNodePath_repetition_plus0:233,VarOrTermOrQuotedTPExpr:234,VarOrTerm:235,GraphTerm:236,BlankNode:237,ConditionalOrExpression:238,ConditionalAndExpression:239,ConditionalOrExpression_repetition0:240,ConditionalOrExpressionTail:241,"||":242,RelationalExpression:243,ConditionalAndExpression_repetition0:244,ConditionalAndExpressionTail:245,"&&":246,NumericExpression:247,RelationalExpression_group0:248,RelationalExpression_option0:249,IN:250,MultiplicativeExpression:251,NumericExpression_repetition0:252,AdditiveExpressionTail:253,AdditiveExpressionTail_group0:254,NumericLiteralPositive:255,AdditiveExpressionTail_repetition0:256,NumericLiteralNegative:257,AdditiveExpressionTail_repetition1:258,UnaryExpression:259,MultiplicativeExpression_repetition0:260,MultiplicativeExpressionTail:261,MultiplicativeExpressionTail_group0:262,"+":263,PrimaryExpression:264,"-":265,ExprQuotedTP:266,Aggregate:267,FUNC_ARITY0:268,FUNC_ARITY1:269,FUNC_ARITY1_SPARQL_STAR:270,FUNC_ARITY2:271,",":272,FUNC_ARITY3:273,FUNC_ARITY3_SPARQL_STAR:274,BuiltInCall_group0:275,BOUND:276,BNODE:277,BuiltInCall_option0:278,EXISTS:279,COUNT:280,Aggregate_option0:281,Aggregate_group0:282,FUNC_AGGREGATE:283,Aggregate_option1:284,GROUP_CONCAT:285,Aggregate_option2:286,Aggregate_option3:287,GroupConcatSeparator:288,SEPARATOR:289,"=":290,String:291,LANGTAG:292,"^^":293,DECIMAL:294,DOUBLE:295,BOOLEAN:296,INTEGER_POSITIVE:297,DECIMAL_POSITIVE:298,DOUBLE_POSITIVE:299,INTEGER_NEGATIVE:300,DECIMAL_NEGATIVE:301,DOUBLE_NEGATIVE:302,STRING_LITERAL1:303,STRING_LITERAL2:304,STRING_LITERAL_LONG1:305,STRING_LITERAL_LONG2:306,PrefixedName:307,PNAME_LN:308,BLANK_NODE_LABEL:309,ANON:310,QuotedTP:311,"<<":312,qtSubjectOrObject:313,">>":314,DataValueTerm:315,AnnotationPattern:316,"{|":317,"|}":318,AnnotationPatternPath:319,ExprVarOrTerm:320,QueryOrUpdate_group0_option0:321,Prologue_repetition0_group0:322,Qry_group0_repetition_plus0:323,SelectClauseBase_option0_group0:324,DISTINCT:325,REDUCED:326,NAMED:327,SILENT:328,CLEAR:329,DROP:330,ADD:331,MOVE:332,COPY:333,ALL:334,".":335,UNION:336,"|":337,"/":338,PathElt_option0_group0:339,"?":340,"!=":341,"<":342,">":343,"<=":344,">=":345,NOT:346,CONCAT:347,COALESCE:348,SUBSTR:349,REGEX:350,REPLACE:351,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",12:"BASE",13:"IRIREF",15:"PREFIX",16:"PNAME_NS",24:"CONSTRUCT",28:"WHERE",29:"{",31:"}",32:"DESCRIBE",36:"ASK",39:"*",41:"SELECT",45:"(",47:"AS",48:")",53:"FROM",63:"GROUP",64:"BY",70:"HAVING",73:"ORDER",76:"ASC",78:"DESC",81:"LIMIT",82:"INTEGER",83:"OFFSET",85:"VALUES",87:"VAR",89:"NIL",100:"LOAD",109:"TO",110:"CREATE",112:"GRAPH",113:"INSERTDATA",115:"DELETEDATA",116:"DELETEWHERE",121:"INTO",123:"DELETE",126:"INSERT",128:"USING",131:"WITH",132:"DEFAULT",159:"OPTIONAL",160:"MINUS",161:"SERVICE",163:"FILTER",164:"BIND",174:"UNDEF",193:";",197:"a",224:"!",229:"^",231:"[",232:"]",242:"||",246:"&&",250:"IN",263:"+",265:"-",268:"FUNC_ARITY0",269:"FUNC_ARITY1",270:"FUNC_ARITY1_SPARQL_STAR",271:"FUNC_ARITY2",272:",",273:"FUNC_ARITY3",274:"FUNC_ARITY3_SPARQL_STAR",276:"BOUND",277:"BNODE",279:"EXISTS",280:"COUNT",283:"FUNC_AGGREGATE",285:"GROUP_CONCAT",289:"SEPARATOR",290:"=",292:"LANGTAG",293:"^^",294:"DECIMAL",295:"DOUBLE",296:"BOOLEAN",297:"INTEGER_POSITIVE",298:"DECIMAL_POSITIVE",299:"DOUBLE_POSITIVE",300:"INTEGER_NEGATIVE",301:"DECIMAL_NEGATIVE",302:"DOUBLE_NEGATIVE",303:"STRING_LITERAL1",304:"STRING_LITERAL2",305:"STRING_LITERAL_LONG1",306:"STRING_LITERAL_LONG2",308:"PNAME_LN",309:"BLANK_NODE_LABEL",310:"ANON",312:"<<",314:">>",317:"{|",318:"|}",325:"DISTINCT",326:"REDUCED",327:"NAMED",328:"SILENT",329:"CLEAR",330:"DROP",331:"ADD",332:"MOVE",333:"COPY",334:"ALL",335:".",336:"UNION",337:"|",338:"/",340:"?",341:"!=",342:"<",343:">",344:"<=",345:">=",346:"NOT",347:"CONCAT",348:"COALESCE",349:"SUBSTR",350:"REGEX",351:"REPLACE"},productions_:[0,[3,3],[7,2],[4,1],[11,2],[14,3],[8,4],[8,4],[8,5],[8,7],[8,5],[8,4],[17,2],[21,2],[38,2],[43,1],[43,5],[49,4],[49,4],[52,3],[19,2],[23,2],[20,3],[62,3],[66,1],[66,1],[66,3],[66,5],[66,1],[69,2],[72,3],[75,2],[75,2],[75,1],[75,1],[80,2],[80,2],[80,4],[80,4],[84,2],[86,4],[86,4],[86,6],[86,2],[94,3],[96,3],[98,4],[98,3],[98,5],[98,4],[98,2],[98,2],[98,2],[98,5],[120,2],[118,3],[118,1],[125,2],[127,3],[130,2],[108,1],[108,2],[122,2],[105,1],[105,1],[114,3],[135,2],[138,7],[143,3],[57,3],[57,3],[147,2],[150,3],[154,3],[151,1],[151,2],[151,2],[151,3],[151,4],[151,2],[151,6],[151,1],[93,1],[93,1],[165,4],[166,4],[166,6],[171,1],[171,1],[171,1],[171,1],[158,2],[79,1],[79,1],[79,1],[68,2],[176,1],[176,5],[179,1],[179,4],[25,3],[182,3],[145,2],[145,2],[188,1],[186,2],[192,2],[190,2],[195,1],[195,1],[196,2],[199,2],[156,2],[156,2],[202,2],[207,1],[207,2],[205,2],[209,2],[211,2],[214,2],[216,2],[219,2],[218,2],[220,1],[220,2],[220,3],[225,1],[225,1],[225,4],[226,1],[226,2],[187,3],[187,3],[203,3],[203,3],[200,1],[200,1],[212,1],[212,1],[234,1],[235,1],[235,1],[139,1],[139,1],[44,1],[236,1],[236,1],[236,1],[236,1],[46,1],[238,2],[241,2],[239,2],[245,2],[243,1],[243,3],[243,4],[247,2],[253,2],[253,2],[253,2],[251,2],[261,2],[259,2],[259,2],[259,2],[259,1],[264,1],[264,1],[264,1],[264,1],[264,1],[264,1],[264,1],[77,3],[67,1],[67,2],[67,4],[67,4],[67,6],[67,8],[67,8],[67,2],[67,4],[67,2],[67,4],[67,3],[267,5],[267,5],[267,6],[288,4],[172,1],[172,2],[172,3],[172,1],[172,1],[172,1],[172,1],[172,1],[172,1],[255,1],[255,1],[255,1],[257,1],[257,1],[257,1],[291,1],[291,1],[291,1],[291,1],[55,1],[55,1],[307,1],[307,1],[237,1],[237,1],[311,5],[173,5],[313,1],[313,1],[313,1],[313,1],[313,1],[315,1],[315,1],[315,1],[185,1],[185,1],[185,1],[316,3],[319,3],[266,5],[320,1],[320,1],[320,1],[223,1],[223,1],[321,0],[321,1],[5,1],[5,1],[5,1],[9,0],[9,1],[322,1],[322,1],[10,0],[10,2],[18,0],[18,2],[22,0],[22,2],[26,0],[26,2],[27,0],[27,2],[30,0],[30,1],[323,1],[323,2],[33,1],[33,1],[34,0],[34,2],[35,0],[35,1],[37,0],[37,2],[40,1],[40,2],[324,1],[324,1],[42,0],[42,1],[50,0],[50,1],[51,0],[51,1],[54,0],[54,1],[56,0],[56,1],[58,0],[58,1],[59,0],[59,1],[60,0],[60,1],[61,0],[61,1],[65,1],[65,2],[71,1],[71,2],[74,1],[74,2],[88,0],[88,2],[90,0],[90,2],[91,1],[91,2],[92,0],[92,2],[95,1],[95,2],[97,0],[97,4],[99,0],[99,2],[101,0],[101,1],[102,0],[102,1],[103,1],[103,1],[104,0],[104,1],[106,1],[106,1],[106,1],[107,0],[107,1],[111,0],[111,1],[117,0],[117,1],[119,0],[119,2],[124,0],[124,1],[129,0],[129,1],[133,0],[133,1],[134,1],[134,1],[134,1],[136,0],[136,1],[137,0],[137,2],[140,0],[140,1],[141,0],[141,1],[142,0],[142,1],[144,0],[144,3],[146,0],[146,1],[148,0],[148,1],[149,0],[149,2],[152,0],[152,1],[153,0],[153,1],[155,0],[155,3],[157,0],[157,1],[162,0],[162,1],[167,0],[167,2],[168,0],[168,2],[169,1],[169,2],[170,0],[170,2],[175,0],[175,3],[177,0],[177,1],[178,0],[178,3],[180,0],[180,3],[181,0],[181,1],[183,0],[183,3],[184,0],[184,1],[189,0],[189,1],[191,0],[191,2],[194,0],[194,1],[198,0],[198,3],[201,0],[201,1],[204,0],[204,1],[206,0],[206,2],[208,1],[208,1],[210,0],[210,3],[213,0],[213,1],[215,0],[215,3],[217,0],[217,3],[339,1],[339,1],[339,1],[221,0],[221,1],[222,0],[222,1],[227,0],[227,3],[228,0],[228,1],[230,1],[230,2],[233,1],[233,2],[240,0],[240,2],[244,0],[244,2],[248,1],[248,1],[248,1],[248,1],[248,1],[248,1],[249,0],[249,1],[252,0],[252,2],[254,1],[254,1],[256,0],[256,2],[258,0],[258,2],[260,0],[260,2],[262,1],[262,1],[275,1],[275,1],[275,1],[275,1],[275,1],[278,0],[278,1],[281,0],[281,1],[282,1],[282,1],[284,0],[284,1],[286,0],[286,1],[287,0],[287,1]],performAction:function(rt,ut,mt,xt,vt,se,yn){var ue=se.length-1;switch(vt){case 1:if(se[ue-1]=se[ue-1]||{},Ot.base&&(se[ue-1].base=Ot.base),Ot.base="",se[ue-1].prefixes=Ot.prefixes,Ot.prefixes=null,Ot.pathOnly){if(se[ue-1].type==="path"||"termType"in se[ue-1])return se[ue-1];throw new Error("Received full SPARQL query in path only mode")}else if(se[ue-1].type==="path"||"termType"in se[ue-1])throw new Error("Received only path in full SPARQL mode");if(se[ue-1].type==="update"){const Nt={};for(const Zt of se[ue-1].updates)if(Zt.updateType==="insert"){const Pt={};for(const Rr of Zt.insert)if(Rr.type==="bgp"||Rr.type==="graph")for(const Kr of Rr.triples)Kr.subject.termType==="BlankNode"&&(Pt[Kr.subject.value]=!0),Kr.predicate.termType==="BlankNode"&&(Pt[Kr.predicate.value]=!0),Kr.object.termType==="BlankNode"&&(Pt[Kr.object.value]=!0);for(const Rr of Object.keys(Pt)){if(Nt[Rr])throw new Error("Detected reuse blank node across different INSERT DATA clauses");Nt[Rr]=!0}}}return se[ue-1];case 2:this.$={...se[ue-1],...se[ue],type:"query"};break;case 4:Ot.base=vs(se[ue]);break;case 5:Ot.prefixes||(Ot.prefixes={}),se[ue-1]=se[ue-1].substr(0,se[ue-1].length-1),se[ue]=vs(se[ue]),Ot.prefixes[se[ue-1]]=se[ue];break;case 6:this.$={...se[ue-3],...Si(se[ue-2]),...se[ue-1],...se[ue]};break;case 7:if(!Ot.skipValidation&&(Ei(se[ue-3].variables.map(Zt=>Bs(Zt.expression))).some(Zt=>Zt.aggregation==="count"&&!(Zt.expression instanceof rn))||se[ue].group)){for(const Zt of se[ue-3].variables)if(Zt.termType==="Variable"){if(!se[ue].group||!se[ue].group.map(Pt=>Ki(Pt)).includes(Ki(Zt)))throw Error("Projection of ungrouped variable (?"+Ki(Zt)+")")}else if(Bs(Zt.expression).length===0){const Pt=ha(Zt.expression);for(const Rr of Pt)if(!se[ue].group||!se[ue].group.map||!se[ue].group.map(Kr=>Ki(Kr)).includes(Ki(Rr)))throw Error("Use of ungrouped variable in projection of operation (?"+Ki(Rr)+")")}}const pi=se[ue-1].where.filter(Nt=>Nt.type==="query");if(pi.length>0){const Nt=se[ue-3].variables.filter(Pt=>Pt.variable&&Pt.variable.value).map(Pt=>Pt.variable.value),Zt=Ei(pi.map(Pt=>Pt.variables)).map(Pt=>Pt.value||Pt.variable.value);for(const Pt of Nt)if(Zt.indexOf(Pt)>=0)throw Error("Target id of 'AS' (?"+Pt+") already used in subquery")}this.$=Tr(se[ue-3],Si(se[ue-2]),se[ue-1],se[ue]);break;case 8:this.$=Tr({queryType:"CONSTRUCT",template:se[ue-3]},Si(se[ue-2]),se[ue-1],se[ue]);break;case 9:this.$=Tr({queryType:"CONSTRUCT",template:se[ue-2]=se[ue-2]?se[ue-2].triples:[]},Si(se[ue-5]),{where:[{type:"bgp",triples:qi([],se[ue-2])}]},se[ue]);break;case 10:this.$=Tr({queryType:"DESCRIBE",variables:se[ue-3]==="*"?[new rn]:se[ue-3]},Si(se[ue-2]),se[ue-1],se[ue]);break;case 11:this.$=Tr({queryType:"ASK"},Si(se[ue-2]),se[ue-1],se[ue]);break;case 12:this.$=Tr(se[ue-1],{variables:[new rn]});break;case 13:const Hs=se[ue].map(Nt=>Nt.value||Nt.variable.value),Jn=Ms(Hs);if(Jn.length>0)throw Error("Two or more of the resulting columns have the same name (?"+Jn[0]+")");this.$=Tr(se[ue-1],{variables:se[ue]});break;case 14:this.$=Tr({queryType:"SELECT"},se[ue]&&(se[ue-1]=an(se[ue]),se[ue]={},se[ue][se[ue-1]]=!0,se[ue]));break;case 16:case 27:this.$=zi(se[ue-3],{variable:se[ue-1]});break;case 17:case 18:this.$=Tr(se[ue-3],se[ue-2],se[ue-1],se[ue],{type:"query"});break;case 19:case 58:this.$={iri:se[ue],named:!!se[ue-1]};break;case 20:this.$={where:se[ue].patterns};break;case 21:this.$=Tr(se[ue-1],se[ue]);break;case 22:this.$=Tr(se[ue-2],se[ue-1],se[ue]);break;case 23:this.$={group:se[ue]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=zi(se[ue]);break;case 26:this.$=zi(se[ue-1]);break;case 29:this.$={having:se[ue]};break;case 30:this.$={order:se[ue]};break;case 32:this.$=zi(se[ue],{descending:!0});break;case 35:this.$={limit:Hi(se[ue])};break;case 36:this.$={offset:Hi(se[ue])};break;case 37:this.$={limit:Hi(se[ue-2]),offset:Hi(se[ue])};break;case 38:this.$={limit:Hi(se[ue]),offset:Hi(se[ue-2])};break;case 39:case 43:this.$={type:"values",values:se[ue]};break;case 40:case 84:this.$=se[ue-1].map(Nt=>({[se[ue-3]]:Nt}));break;case 41:case 85:this.$=se[ue-1].map(()=>({}));break;case 42:case 86:var ui=se[ue-4].length;se[ue-4]=se[ue-4].map(So),this.$=se[ue-1].map(function(Nt){if(Nt.length!==ui)throw Error("Inconsistent VALUES length");for(var Zt={},Pt=0;Pt<ui;Pt++)Zt["?"+se[ue-4][Pt].value]=Nt[Pt];return Zt});break;case 44:case 65:case 100:case 126:case 175:this.$=se[ue-1];break;case 45:this.$={type:"update",updates:vi(se[ue-2],se[ue-1])};break;case 46:this.$=Tr({type:"load",silent:!!se[ue-2],source:se[ue-1]},se[ue]&&{destination:se[ue]});break;case 47:this.$={type:an(se[ue-2]),silent:!!se[ue-1],graph:se[ue]};break;case 48:this.$={type:an(se[ue-4]),silent:!!se[ue-3],source:se[ue-2],destination:se[ue]};break;case 49:this.$={type:"create",silent:!!se[ue-2],graph:{type:"graph",name:se[ue]}};break;case 50:this.$={updateType:"insert",insert:qs(se[ue])};break;case 51:this.$={updateType:"delete",delete:zs(qs(se[ue]))};break;case 52:this.$={updateType:"deletewhere",delete:zs(se[ue])};break;case 53:this.$={updateType:"insertdelete",...se[ue-4],...se[ue-3],...Si(se[ue-2],"using"),where:se[ue].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=se[ue];break;case 55:this.$={delete:zs(se[ue-1]),insert:se[ue]||[]};break;case 56:this.$={delete:[],insert:se[ue]};break;case 59:this.$={graph:se[ue]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:se[ue]};break;case 64:this.$={[an(se[ue])]:!0};break;case 66:this.$=se[ue-1]?Kn(se[ue],[se[ue-1]]):Kn(se[ue]);break;case 67:var Es=Tr(se[ue-3]||{triples:[]},{type:"graph",name:se[ue-5]});this.$=se[ue]?[Es,se[ue]]:[Es];break;case 68:case 73:this.$={type:"bgp",triples:Kn(se[ue-2],[se[ue-1]])};break;case 69:this.$={type:"group",patterns:[se[ue-1]]};break;case 70:for(const Nt of se[ue-1].filter(Zt=>Zt.type==="bind")){const Zt=se[ue-1].indexOf(Nt),Pt=new Set;for(const Rr of se[ue-1].slice(0,Zt))(Rr.type==="group"||Rr.type==="bgp")&&pa(Rr).forEach(Kr=>Pt.add(Kr));if(Pt.has(Nt.variable.value))throw Error("Variable used to bind is already bound (?"+Nt.variable.value+")")}this.$={type:"group",patterns:se[ue-1]};break;case 71:this.$=se[ue-1]?Kn([se[ue-1]],se[ue]):Kn(se[ue]);break;case 72:this.$=se[ue]?[se[ue-2],se[ue]]:se[ue-2];break;case 75:this.$=Tr(se[ue],{type:"optional"});break;case 76:this.$=Tr(se[ue],{type:"minus"});break;case 77:this.$=Tr(se[ue],{type:"graph",name:se[ue-1]});break;case 78:this.$=Tr(se[ue],{type:"service",name:se[ue-1],silent:!!se[ue-2]});break;case 79:this.$={type:"filter",expression:se[ue]};break;case 80:this.$={type:"bind",variable:se[ue-1],expression:se[ue-3]};break;case 89:this.$=Gi(se[ue]);break;case 90:this.$=void 0;break;case 91:this.$=se[ue-1].length?{type:"union",patterns:Kn(se[ue-1].map(To),[To(se[ue])])}:se[ue];break;case 95:this.$={...se[ue],function:se[ue-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:vi(se[ue-2],se[ue-1]),distinct:!!se[ue-3]};break;case 98:case 115:case 128:case 247:case 249:case 251:case 253:case 255:case 263:case 267:case 297:case 299:case 303:case 307:case 328:case 341:case 349:case 355:case 361:case 367:case 369:case 373:case 375:case 379:case 381:case 385:case 391:case 395:case 401:case 405:case 409:case 411:case 420:case 428:case 430:case 440:case 444:case 446:case 448:this.$=[];break;case 99:this.$=vi(se[ue-2],se[ue-1]);break;case 101:this.$=Kn(se[ue-2],[se[ue-1]]);break;case 102:case 112:this.$=Ss(se[ue].map(Nt=>Tr(Pn(se[ue-1]),Nt)));break;case 103:this.$=Ss(qi(se[ue].map(Nt=>Tr(Pn(se[ue-1].entity),Nt)),se[ue-1].triples));break;case 105:this.$=Kn([se[ue-1]],se[ue]);break;case 106:this.$=Kn(se[ue]);break;case 107:this.$=Ao(se[ue-1],se[ue]);break;case 109:case 237:this.$=Ot.factory.namedNode(lr);break;case 110:case 118:this.$=vi(se[ue-1],se[ue]);break;case 111:this.$=se[ue]?{annotation:se[ue],object:se[ue-1]}:se[ue-1];break;case 113:this.$=se[ue]?Ss(qi(se[ue].map(Nt=>Tr(Pn(se[ue-1].entity),Nt)),se[ue-1].triples)):se[ue-1].triples;break;case 114:this.$=Ao(...se[ue-1],se[ue]);break;case 116:this.$=Ao(...se[ue]);break;case 117:case 159:case 163:this.$=[se[ue-1],se[ue]];break;case 119:this.$=se[ue]?{object:se[ue-1],annotation:se[ue]}:se[ue-1];break;case 120:this.$=se[ue-1].length?Vi("|",vi(se[ue-1],se[ue])):se[ue];break;case 121:this.$=se[ue-1].length?Vi("/",vi(se[ue-1],se[ue])):se[ue];break;case 122:this.$=se[ue]?Vi(se[ue],[se[ue-1]]):se[ue-1];break;case 123:this.$=se[ue-1]?Vi(se[ue-1],[se[ue]]):se[ue];break;case 125:case 131:this.$=Vi(se[ue-1],[se[ue]]);break;case 129:this.$=Vi("|",vi(se[ue-2],se[ue-1]));break;case 132:case 134:this.$=Wi(se[ue-1]);break;case 133:case 135:this.$=vl(se[ue-1]);break;case 140:this.$={entity:se[ue],triples:[]};break;case 145:this.$=So(se[ue]);break;case 149:this.$=Ot.factory.namedNode(Nr);break;case 151:case 153:case 158:case 162:this.$=Eo(se[ue-1],se[ue]);break;case 152:this.$=["||",se[ue]];break;case 154:this.$=["&&",se[ue]];break;case 156:this.$=Wr(se[ue-1],[se[ue-2],se[ue]]);break;case 157:this.$=Wr(se[ue-2]?"notin":"in",[se[ue-3],se[ue]]);break;case 160:this.$=["+",Eo(se[ue-1],se[ue])];break;case 161:var Ji=Gn(se[ue-1].value.replace("-",""),se[ue-1].datatype);this.$=["-",Eo(Ji,se[ue])];break;case 164:this.$=Wr("UPLUS",[se[ue]]);break;case 165:this.$=Wr(se[ue-1],[se[ue]]);break;case 166:this.$=Wr("UMINUS",[se[ue]]);break;case 177:this.$=Wr(an(se[ue-1]));break;case 178:this.$=Wr(an(se[ue-3]),[se[ue-1]]);break;case 179:this.$=Gi(Wr(an(se[ue-3]),[se[ue-1]]));break;case 180:this.$=Wr(an(se[ue-5]),[se[ue-3],se[ue-1]]);break;case 181:this.$=Wr(an(se[ue-7]),[se[ue-5],se[ue-3],se[ue-1]]);break;case 182:this.$=Gi(Wr(an(se[ue-7]),[se[ue-5],se[ue-3],se[ue-1]]));break;case 183:this.$=Wr(an(se[ue-1]),se[ue]);break;case 184:this.$=Wr("bound",[So(se[ue-1])]);break;case 185:this.$=Wr(se[ue-1],[]);break;case 186:this.$=Wr(se[ue-3],[se[ue-1]]);break;case 187:this.$=Wr(se[ue-2]?"notexists":"exists",[To(se[ue])]);break;case 188:case 189:this.$=zi(se[ue-1],{type:"aggregate",aggregation:an(se[ue-4]),distinct:!!se[ue-2]});break;case 190:this.$=zi(se[ue-2],{type:"aggregate",aggregation:an(se[ue-5]),distinct:!!se[ue-3],separator:typeof se[ue-1]=="string"?se[ue-1]:" "});break;case 192:this.$=Gn(se[ue]);break;case 193:this.$=wl(se[ue-1],an(se[ue].substr(1)));break;case 194:this.$=Gn(se[ue-2],se[ue]);break;case 195:case 204:this.$=Gn(se[ue],Vn);break;case 196:case 205:this.$=Gn(se[ue],Hn);break;case 197:case 206:this.$=Gn(an(se[ue]),$s);break;case 200:this.$=Gn(se[ue].toLowerCase(),wo);break;case 201:this.$=Gn(se[ue].substr(1),Vn);break;case 202:this.$=Gn(se[ue].substr(1),Hn);break;case 203:this.$=Gn(se[ue].substr(1).toLowerCase(),$s);break;case 207:case 208:this.$=xo(se[ue],1);break;case 209:case 210:this.$=xo(se[ue],3);break;case 211:this.$=Ot.factory.namedNode(vs(se[ue]));break;case 213:var Vs=se[ue].indexOf(":"),pr=se[ue].substr(0,Vs),Rn=Ot.prefixes[pr];if(!Rn)throw new Error("Unknown prefix: "+pr);var kn=vs(Rn+se[ue].substr(Vs+1));this.$=Ot.factory.namedNode(kn);break;case 214:if(se[ue]=se[ue].substr(0,se[ue].length-1),!(se[ue]in Ot.prefixes))throw new Error("Unknown prefix: "+se[ue]);var kn=vs(Ot.prefixes[se[ue]]);this.$=Ot.factory.namedNode(kn);break;case 215:this.$=li(se[ue].replace(/^(_:)/,""));break;case 216:this.$=li();break;case 217:case 218:case 232:this.$=Gi(Ro(se[ue-3],se[ue-2],se[ue-1]));break;case 230:case 231:this.$=Gi(se[ue-1]);break;case 248:case 250:case 252:case 254:case 256:case 260:case 264:case 268:case 270:case 292:case 294:case 296:case 298:case 300:case 302:case 304:case 306:case 329:case 342:case 356:case 368:case 370:case 372:case 374:case 392:case 402:case 425:case 427:case 429:case 431:case 441:case 445:case 447:case 449:se[ue-1].push(se[ue]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[se[ue]];break;case 308:se[ue-3].push(se[ue-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:se[ue-2].push(se[ue-1]);break}},table:[e(t,n,{3:1,4:2,10:3}),{1:[3]},e(s,[2,307],{5:4,7:5,321:6,214:7,8:8,96:9,215:10,17:11,21:12,97:16,38:17,6:[2,238],13:a,16:a,45:a,197:a,224:a,229:a,308:a,24:[1,13],32:[1,14],36:[1,15],41:u}),e([6,13,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],[2,3],{322:19,11:20,14:21,12:[1,22],15:[1,23]}),{6:[1,24]},{6:[2,240]},{6:[2,241]},{6:[2,242]},{6:[2,243],9:25,84:26,85:c},{6:[2,239]},e(h,[2,411],{216:28,217:29}),e(f,[2,249],{18:30}),e(f,[2,251],{22:31}),e(p,[2,255],{25:32,27:33,29:[1,34]}),{13:g,16:y,33:35,39:[1,37],44:39,55:40,87:S,139:38,307:43,308:w,323:36},e(f,[2,267],{37:46}),e(R,[2,326],{98:47,103:49,106:50,117:55,130:61,100:[1,48],110:[1,51],113:[1,52],115:[1,53],116:[1,54],131:[1,62],329:[1,56],330:[1,57],331:[1,58],332:[1,59],333:[1,60]}),{39:[1,63],40:64,43:65,44:66,45:T,87:S},e(A,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),e(t,[2,248]),e(t,[2,245]),e(t,[2,246]),{13:[1,72]},{16:[1,73]},{1:[2,1]},{6:[2,2]},{6:[2,244]},{45:[1,77],85:[1,78],86:74,87:[1,75],89:[1,76]},e([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],[2,120],{337:[1,79]}),e(F,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:x,29:D,52:84,53:O,56:85},{19:88,28:x,29:D,52:89,53:O,56:85},e(f,[2,253],{26:90}),{28:[1,91],52:92,53:O},e(K,[2,385],{181:93,182:94,183:95,31:[2,383]}),e(z,[2,263],{34:96}),e(z,[2,261],{44:39,55:40,307:43,139:97,13:g,16:y,87:S,308:w}),e(z,[2,262]),e(X,[2,259]),e(Ee,[2,143]),e(Ee,[2,144]),e([6,13,16,28,29,31,39,45,47,48,53,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,145]),e(q,[2,211]),e(q,[2,212]),e(q,[2,213]),e(q,[2,214]),{19:98,28:x,29:D,52:99,53:O,56:85},{6:[2,309],99:100,193:[1,101]},e(Y,[2,311],{101:102,328:[1,103]}),e(Te,[2,317],{104:104,328:[1,105]}),e(re,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:$e,114:110},{29:$e,114:112},{29:$e,114:113},{118:114,123:[1,115],125:116,126:ze},e(ye,[2,315]),e(ye,[2,316]),e(Ve,[2,319]),e(Ve,[2,320]),e(Ve,[2,321]),e(R,[2,327]),{13:g,16:y,55:118,307:43,308:w},e(f,[2,12]),e(f,[2,13],{44:66,43:119,45:T,87:S}),e(pe,[2,269]),e(pe,[2,15]),{13:g,16:y,44:136,45:De,46:120,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(A,[2,14]),e(A,[2,274]),e(A,[2,271]),e(A,[2,272]),e(t,[2,4]),{13:[1,177]},e(Tt,[2,39]),{29:[1,178]},{29:[1,179]},{87:[1,181],91:180},{45:[1,187],87:[1,185],89:[1,186],93:182,165:183,166:184},e(h,[2,410]),e([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337],[2,121],{338:[1,188]}),{13:g,16:y,45:[1,193],55:194,197:kt,219:189,220:190,223:191,224:[1,192],307:43,308:w},e(F,[2,419]),e(Ft,sn,{20:196,59:197,69:198,70:Yt}),e(f,[2,250]),{29:Dt,57:200},e(Y,[2,279],{54:202,327:[1,203]}),{29:[2,282]},e(vr,Bt,{23:204,58:205,62:206,63:dr}),e(f,[2,252]),{19:208,28:x,29:D,52:209,53:O,56:85},{29:[1,210]},e(p,[2,256]),{31:[1,211]},{31:[2,384]},{13:g,16:y,44:215,45:nr,55:220,82:$,87:S,89:Vr,145:212,172:221,185:213,187:214,231:M,236:216,237:222,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:217,312:qe},e(at,[2,265],{56:85,35:227,52:228,19:229,28:x,29:D,53:O}),e(X,[2,260]),e(vr,Bt,{58:205,62:206,23:230,63:dr}),e(f,[2,268]),{6:[2,45]},e(t,n,{10:3,4:231}),{13:g,16:y,55:232,307:43,308:w},e(Y,[2,312]),{105:233,112:Ut,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},e(Te,[2,318]),e(Y,Ht,{108:240,133:242,112:on,132:Sr}),e(re,[2,323]),{112:[1,244]},{112:[2,325]},e(sr,[2,50]),e(K,bn,{135:245,136:246,143:247,144:248,31:Hr,112:Hr}),e(sr,[2,51]),e(sr,[2,52]),e(qt,[2,328],{119:249}),{29:$e,114:250},e(qt,[2,56]),{29:$e,114:251},e(R,[2,59]),e(pe,[2,270]),{47:[1,252]},e(fr,[2,150]),e(Dr,[2,428],{240:253}),e(Mr,[2,430],{244:254}),e(Mr,[2,155],{248:255,249:256,250:[2,438],290:[1,257],341:[1,258],342:[1,259],343:[1,260],344:[1,261],345:[1,262],346:[1,263]}),e(Lt,[2,440],{252:264}),e(Rt,[2,448],{260:265}),{13:g,16:y,44:136,45:De,55:133,67:132,68:134,77:131,82:$,87:S,172:135,255:154,257:155,264:266,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{13:g,16:y,44:136,45:De,55:133,67:132,68:134,77:131,82:$,87:S,172:135,255:154,257:155,264:267,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{13:g,16:y,44:136,45:De,55:133,67:132,68:134,77:131,82:$,87:S,172:135,255:154,257:155,264:268,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(Rt,[2,167]),e(Rt,[2,168]),e(Rt,[2,169]),e(Rt,[2,170],{176:269,45:hr,89:oi}),e(Rt,[2,171]),e(Rt,[2,172]),e(Rt,[2,173]),e(Rt,[2,174]),{13:g,16:y,44:136,45:De,46:272,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(br,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:or,89:ai,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},e(Pr,[2,192],{292:[1,286],293:[1,287]}),e(Pr,[2,195]),e(Pr,[2,196]),e(Pr,[2,197]),e(Pr,[2,198]),e(Pr,[2,199]),e(Pr,[2,200]),{13:g,16:y,44:39,55:40,82:$,87:S,139:289,172:291,255:154,257:155,266:290,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},e(vn,[2,452]),e(vn,[2,453]),e(vn,[2,454]),e(vn,[2,455]),e(vn,[2,456]),{279:[2,458]},e(Er,[2,207]),e(Er,[2,208]),e(Er,[2,209]),e(Er,[2,210]),e(Pr,[2,201]),e(Pr,[2,202]),e(Pr,[2,203]),e(Pr,[2,204]),e(Pr,[2,205]),e(Pr,[2,206]),e(t,[2,5]),e(_i,[2,297],{88:295}),e(wi,[2,299],{90:296}),{48:[1,297],87:[1,298]},e(Sn,[2,301]),e(Tt,[2,43]),e(Tt,[2,82]),e(Tt,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},e(h,[2,412]),e(hn,[2,123]),e(hn,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),e(En,[2,124]),{13:g,16:y,45:[1,311],55:194,89:[1,310],197:kt,223:312,225:308,226:309,229:ws,307:43,308:w},e(h,a,{215:10,214:314}),e(En,[2,236]),e(En,[2,237]),e(_,[2,6]),e(b,[2,287],{60:315,72:316,73:[1,317]}),e(Ft,[2,286]),{13:g,16:y,45:De,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,307:43,308:w,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e([6,31,63,70,73,81,83,85],[2,20]),e(K,v,{38:17,49:324,147:325,17:326,21:327,148:328,154:329,155:330,29:I,31:I,85:I,112:I,159:I,160:I,161:I,163:I,164:I,41:u}),{13:g,16:y,55:331,307:43,308:w},e(Y,[2,280]),e(_,[2,7]),e(Ft,sn,{59:197,69:198,20:332,70:Yt}),e(vr,[2,284]),{64:[1,333]},e(vr,Bt,{58:205,62:206,23:334,63:dr}),e(f,[2,254]),e(K,bn,{144:248,30:335,143:336,31:[2,257]}),e(f,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:g,16:y,44:39,55:40,87:S,139:342,186:339,190:340,195:341,197:k,307:43,308:w},e(Q,[2,389],{44:39,55:40,307:43,190:340,195:341,139:342,188:344,189:345,186:346,13:g,16:y,87:S,197:k,308:w}),e(te,[2,227]),e(te,[2,228]),e(te,[2,229]),{13:g,16:y,44:215,45:nr,55:220,82:$,87:S,89:Vr,172:221,185:351,187:350,200:348,230:347,231:M,234:349,236:216,237:222,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:217,312:qe},{13:g,16:y,44:39,55:40,87:S,139:342,186:352,190:340,195:341,197:k,307:43,308:w},e(te,[2,146]),e(te,[2,147]),e(te,[2,148]),e(te,[2,149]),{13:g,16:y,44:354,55:355,82:$,87:S,172:357,237:356,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:358,312:qe,313:353},e(we,[2,215]),e(we,[2,216]),e(vr,Bt,{58:205,62:206,23:359,63:dr}),e(z,[2,264]),e(at,[2,266]),e(_,[2,11]),e(s,[2,308],{6:[2,310]}),e(sr,[2,313],{102:360,120:361,121:[1,362]}),e(sr,[2,47]),e(sr,[2,63]),e(sr,[2,64]),{13:g,16:y,55:363,307:43,308:w},e(sr,[2,336]),e(sr,[2,337]),e(sr,[2,338]),{109:[1,364]},e(ge,[2,60]),{13:g,16:y,55:365,307:43,308:w},e(Y,[2,335]),{13:g,16:y,55:366,307:43,308:w},{31:[1,367]},e(be,[2,341],{137:368}),e(be,[2,340]),{13:g,16:y,44:215,45:nr,55:220,82:$,87:S,89:Vr,145:369,172:221,185:213,187:214,231:M,236:216,237:222,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:217,312:qe},{28:[1,370],127:371,128:[1,372]},e(qt,[2,330],{124:373,125:374,126:ze}),e(qt,[2,57]),{44:375,87:S},e(fr,[2,151],{241:376,242:[1,377]}),e(Dr,[2,153],{245:378,246:[1,379]}),{13:g,16:y,44:136,45:De,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,247:380,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{250:[1,381]},e(_e,[2,432]),e(_e,[2,433]),e(_e,[2,434]),e(_e,[2,435]),e(_e,[2,436]),e(_e,[2,437]),{250:[2,439]},e([47,48,193,242,246,250,272,290,341,342,343,344,345,346],[2,158],{253:382,254:383,255:384,257:385,263:[1,386],265:[1,387],297:J,298:me,299:xe,300:de,301:st,302:ft}),e(Lt,[2,162],{261:388,262:389,39:Re,338:Ce}),e(Rt,[2,164]),e(Rt,[2,165]),e(Rt,[2,166]),e(br,[2,95]),e(br,[2,96]),e(_e,[2,377],{177:392,325:[1,393]}),{48:[1,394]},e(br,[2,177]),{13:g,16:y,44:136,45:De,46:395,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{13:g,16:y,44:136,45:De,46:396,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{13:g,16:y,44:136,45:De,46:397,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{13:g,16:y,44:136,45:De,46:398,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{13:g,16:y,44:136,45:De,46:399,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(br,[2,183]),e(br,[2,98]),e(_e,[2,381],{180:400}),{87:[1,401]},e(br,[2,185]),{13:g,16:y,44:136,45:De,46:402,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{29:Dt,57:403},e(Pr,[2,193]),{13:g,16:y,55:404,307:43,308:w},{13:g,16:y,44:39,55:40,87:S,139:342,195:405,197:k,307:43,308:w},e(Le,[2,233]),e(Le,[2,234]),e(Le,[2,235]),e(We,[2,459],{281:406,325:[1,407]}),e(_e,[2,463],{284:408,325:[1,409]}),e(_e,[2,465],{286:410,325:[1,411]}),{13:g,16:y,31:[1,412],55:414,82:$,171:413,172:415,173:416,174:Xe,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:et},{31:[1,419],89:[1,420]},{29:[1,421]},e(Sn,[2,302]),e(_i,[2,367],{167:422}),e(wi,[2,369],{168:423}),{48:[1,424],87:[1,425]},e(Sn,[2,371]),e(hn,[2,122]),e(hn,[2,417]),e(hn,[2,413]),e(hn,[2,414]),e(hn,[2,415]),e(En,[2,125]),e(En,[2,127]),e(En,[2,128]),e(ne,[2,420],{227:426}),e(En,[2,130]),{13:g,16:y,55:194,197:kt,223:427,307:43,308:w},{48:[1,428]},e(Se,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),e(b,[2,288]),{64:[1,433]},e(Ft,[2,29],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:434,13:g,16:y,45:De,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,276:Oe,277:ie,279:j,280:N,283:L,285:V,308:w,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t}),e(Ae,[2,293]),e(Ne,[2,92]),e(Ne,[2,93]),e(Ne,[2,94]),{45:hr,89:oi,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:x,29:D,56:85},{19:438,28:x,29:D,56:85},e(Qe,[2,355],{149:439}),e(Qe,[2,354]),{13:g,16:y,44:215,45:nt,55:220,82:$,87:S,89:Vr,156:440,172:221,185:441,203:442,231:bt,236:216,237:222,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:217,312:qe},e(z,[2,19]),e(Se,[2,21]),{13:g,16:y,44:450,45:ht,55:323,65:445,66:446,67:447,68:448,87:S,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,307:43,308:w,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(_,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},e(K,[2,386],{31:[2,388]}),e(Q,[2,102]),e(Ct,[2,391],{191:452}),e(K,[2,395],{196:453,198:454}),e(K,[2,108]),e(K,[2,109]),e(Q,[2,103]),e(Q,[2,104]),e(Q,[2,390]),{13:g,16:y,44:215,45:nr,48:[1,455],55:220,82:$,87:S,89:Vr,172:221,185:351,187:350,200:456,231:M,234:349,236:216,237:222,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:217,312:qe},e(yt,[2,424]),e(wt,[2,136]),e(wt,[2,137]),e(Jt,[2,140]),{232:[1,457]},{13:g,16:y,44:39,55:40,87:S,139:342,195:458,197:k,307:43,308:w},e(Le,[2,219]),e(Le,[2,220]),e(Le,[2,221]),e(Le,[2,222]),e(Le,[2,223]),e(_,[2,10]),e(sr,[2,46]),e(sr,[2,314]),{112:Ut,122:459},e(sr,[2,62]),e(Y,Ht,{133:242,108:460,112:on,132:Sr}),e(ge,[2,61]),e(sr,[2,49]),e([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},e(be,[2,351],{146:463,335:[1,464]}),{29:Dt,57:465},e(qt,[2,329]),e(Y,[2,332],{129:466,327:[1,467]}),e(qt,[2,55]),e(qt,[2,331]),{48:[1,468]},e(Dr,[2,429]),{13:g,16:y,44:136,45:De,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(Mr,[2,431]),{13:g,16:y,44:136,45:De,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,243:470,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(Mr,[2,156]),{45:or,89:ai,179:471},e(Lt,[2,441]),{13:g,16:y,44:136,45:De,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,251:472,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(Rt,[2,444],{256:473}),e(Rt,[2,446],{258:474}),e(_e,[2,442]),e(_e,[2,443]),e(Rt,[2,449]),{13:g,16:y,44:136,45:De,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,255:154,257:155,259:475,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(_e,[2,450]),e(_e,[2,451]),e(_e,[2,379],{178:476}),e(_e,[2,378]),e([6,13,16,29,31,39,45,47,48,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,175]),{48:[1,477]},{48:[1,478]},{272:[1,479]},{272:[1,480]},{272:[1,481]},{13:g,16:y,44:136,45:De,46:482,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{48:[1,483]},{48:[1,484]},e(br,[2,187]),e(Pr,[2,194]),{13:g,16:y,44:39,55:40,82:$,87:S,139:289,172:291,255:154,257:155,266:290,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,320:485},{13:g,16:y,39:[1,487],44:136,45:De,46:488,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,282:486,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(We,[2,460]),{13:g,16:y,44:136,45:De,46:489,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(_e,[2,464]),{13:g,16:y,44:136,45:De,46:490,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(_e,[2,466]),e(Tt,[2,40]),e(_i,[2,298]),e(Qt,[2,87]),e(Qt,[2,88]),e(Qt,[2,89]),e(Qt,[2,90]),{13:g,16:y,55:492,82:$,172:493,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,311:494,312:qe,315:491},e(Tt,[2,41]),e(wi,[2,300]),e(Mt,[2,303],{92:495}),{13:g,16:y,31:[1,496],55:414,82:$,171:497,172:415,173:416,174:Xe,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:et},{31:[1,498],89:[1,499]},{29:[1,500]},e(Sn,[2,372]),{13:g,16:y,48:[2,422],55:194,197:kt,223:312,226:502,228:501,229:ws,307:43,308:w},e(En,[2,131]),e(En,[2,126]),e(Se,[2,22]),e(Se,[2,290]),{82:[1,503]},{82:[1,504]},{13:g,16:y,44:510,45:De,55:323,67:321,68:322,74:505,75:506,76:Ir,77:320,78:Lr,79:509,87:S,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,307:43,308:w,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(Ae,[2,294]),e(Ur,[2,69]),e(Ur,[2,70]),e(Ft,sn,{59:197,69:198,20:511,70:Yt}),e(vr,Bt,{58:205,62:206,23:512,63:dr}),{29:[2,375],31:[2,71],84:522,85:c,112:[1,518],150:513,151:514,158:515,159:[1,516],160:[1,517],161:[1,519],163:[1,520],164:[1,521],175:523},e(Qe,[2,363],{157:524,335:[1,525]}),e(h,a,{215:10,202:526,205:527,208:528,214:529,44:530,87:S}),e(ar,[2,399],{215:10,205:527,208:528,214:529,44:530,204:531,202:532,13:a,16:a,45:a,197:a,224:a,229:a,308:a,87:S}),{13:g,16:y,44:215,45:nt,55:220,82:$,87:S,89:Vr,172:221,185:351,203:536,212:534,231:bt,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:217,312:qe},e(h,a,{215:10,205:527,208:528,214:529,44:530,202:537,87:S}),e(vr,[2,23],{307:43,267:139,275:146,278:149,55:323,67:447,68:448,44:450,66:538,13:g,16:y,45:ht,87:S,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,276:Oe,277:ie,279:j,280:N,283:L,285:V,308:w,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t}),e(Xt,[2,291]),e(Xt,[2,24]),e(Xt,[2,25]),{13:g,16:y,44:136,45:De,46:539,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(Xt,[2,28]),e(vr,Bt,{58:205,62:206,23:540,63:dr}),e([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),e(Ct,[2,107]),{13:g,16:y,44:215,45:nr,55:220,82:$,87:S,89:Vr,172:221,185:351,187:350,199:543,200:544,231:M,234:349,236:216,237:222,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:217,312:qe},e(ir,[2,132]),e(yt,[2,425]),e(ir,[2,133]),{13:g,16:y,44:354,55:355,82:$,87:S,172:357,237:356,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:358,312:qe,313:545},e(sr,[2,54]),e(sr,[2,48]),e(be,[2,342]),{13:g,16:y,44:39,55:40,87:S,139:546,307:43,308:w},e(be,[2,68]),e(K,[2,350],{31:Or,112:Or}),e(sr,[2,53]),{13:g,16:y,55:547,307:43,308:w},e(Y,[2,333]),e(pe,[2,16]),e(Dr,[2,152]),e(Mr,[2,154]),e(Mr,[2,157]),e(Lt,[2,159]),e(Lt,[2,160],{262:389,261:548,39:Re,338:Ce}),e(Lt,[2,161],{262:389,261:549,39:Re,338:Ce}),e(Rt,[2,163]),{13:g,16:y,44:136,45:De,46:550,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(br,[2,178]),e(br,[2,179]),{13:g,16:y,44:136,45:De,46:551,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{13:g,16:y,44:136,45:De,46:552,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{13:g,16:y,44:136,45:De,46:553,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{48:[1,554],272:[1,555]},e(br,[2,184]),e(br,[2,186]),{314:[1,556]},{48:[1,557]},{48:[2,461]},{48:[2,462]},{48:[1,558]},{48:[2,467],193:[1,561],287:559,288:560},{13:g,16:y,55:194,197:kt,223:562,307:43,308:w},e(_n,[2,224]),e(_n,[2,225]),e(_n,[2,226]),{31:[1,563],45:tn,94:564},e(Tt,[2,84]),e(_i,[2,368]),e(Tt,[2,85]),e(wi,[2,370]),e(Mt,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},e(Se,[2,35],{83:[1,569]}),e(Se,[2,36],{81:[1,570]}),e(b,[2,30],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:509,44:510,75:571,13:g,16:y,45:De,76:Ir,78:Lr,87:S,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,276:Oe,277:ie,279:j,280:N,283:L,285:V,308:w,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t}),e(pn,[2,295]),{45:De,77:572},{45:De,77:573},e(pn,[2,33]),e(pn,[2,34]),{31:[2,275],50:574,84:575,85:c},{31:[2,277],51:576,84:577,85:c},e(Qe,[2,356]),e(Tn,[2,357],{152:578,335:[1,579]}),e(gn,[2,74]),{29:Dt,57:580},{29:Dt,57:581},{13:g,16:y,44:39,55:40,87:S,139:582,307:43,308:w},e(Fn,[2,365],{162:583,328:[1,584]}),{13:g,16:y,45:De,55:323,67:321,68:322,77:320,79:585,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,307:43,308:w,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{45:[1,586]},e(gn,[2,81]),{29:Dt,57:587},e(Qe,[2,73]),e(K,[2,362],{29:wr,31:wr,85:wr,112:wr,159:wr,160:wr,161:wr,163:wr,164:wr}),e(ar,[2,112]),e($r,[2,401],{206:588}),e(K,[2,405],{209:589,210:590}),e(K,[2,403]),e(K,[2,404]),e(ar,[2,113]),e(ar,[2,400]),{13:g,16:y,44:215,45:nt,48:[1,591],55:220,82:$,87:S,89:Vr,172:221,185:351,203:536,212:592,231:bt,234:535,236:216,237:222,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:217,312:qe},e(yt,[2,426]),e(Jt,[2,138]),e(Jt,[2,139]),{232:[1,593]},e(Xt,[2,292]),{47:[1,595],48:[1,594]},e(_,[2,9]),e(Ct,[2,392]),e(Ct,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:g,16:y,87:S,197:k,308:w}),e(Ct,[2,110],{272:[1,598]}),e(Cr,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},e(qt,[2,58]),e(Rt,[2,445]),e(Rt,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},e(br,[2,99]),e(_e,[2,382]),e([13,16,39,47,48,87,193,197,242,246,250,263,265,272,290,297,298,299,300,301,302,308,314,338,341,342,343,344,345,346],[2,232]),e(br,[2,188]),e(br,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:g,16:y,55:492,82:$,172:493,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,311:494,312:qe,315:611},e(Tt,[2,42]),e(Mt,[2,304]),{13:g,16:y,55:414,82:$,95:612,171:613,172:415,173:416,174:Xe,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:et},{31:[1,614],45:tn,94:615},e(En,[2,129]),e(ne,[2,421]),{82:[1,616]},{82:[1,617]},e(pn,[2,296]),e(pn,[2,31]),e(pn,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},e(K,v,{155:330,153:618,154:619,29:kr,31:kr,85:kr,112:kr,159:kr,160:kr,161:kr,163:kr,164:kr}),e(Tn,[2,358]),e(gn,[2,75]),e(gn,[2,76]),{29:Dt,57:620},{13:g,16:y,44:39,55:40,87:S,139:621,307:43,308:w},e(Fn,[2,366]),e(gn,[2,79]),{13:g,16:y,44:136,45:De,46:622,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(gn,[2,91],{336:[1,623]}),e([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),e($r,[2,117]),{13:g,16:y,44:215,45:nt,55:220,82:$,87:S,89:Vr,172:221,185:351,203:536,211:626,212:627,231:bt,234:535,236:216,237:222,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,309:H,310:Be,311:217,312:qe},e(te,[2,134]),e(yt,[2,427]),e(te,[2,135]),e(Xt,[2,26]),{44:628,87:S},e(Ct,[2,106]),e(Ct,[2,394]),e(K,[2,396]),e(Cr,[2,111]),e(Cr,[2,398]),{13:g,16:y,44:39,55:40,87:S,139:342,186:629,190:340,195:341,197:k,307:43,308:w},e(we,[2,217]),e(K,bn,{144:248,140:630,143:631,31:[2,343]}),e(br,[2,97]),e(_e,[2,380]),e(br,[2,180]),{13:g,16:y,44:136,45:De,46:632,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},{13:g,16:y,44:136,45:De,46:633,55:133,67:132,68:134,77:131,82:$,87:S,172:135,224:G,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:ce,264:130,265:oe,266:137,267:139,268:Fe,269:Ue,270:Je,271:He,273:he,274:fe,275:146,276:Oe,277:ie,278:149,279:j,280:N,283:L,285:V,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:B,346:U,347:Ie,348:Me,349:Pe,350:gt,351:_t},e(br,[2,190]),{290:[1,634]},{314:[1,635]},{13:g,16:y,48:[1,636],55:414,82:$,171:637,172:415,173:416,174:Xe,255:154,257:155,291:150,294:ee,295:ae,296:ve,297:J,298:me,299:xe,300:de,301:st,302:ft,303:Ge,304:pt,305:Z,306:P,307:43,308:w,312:et},e(Mn,[2,305]),e(Tt,[2,86]),e(Mt,[2,374]),e(Se,[2,37]),e(Se,[2,38]),e(Qe,[2,72]),e(Qe,[2,360]),e(gn,[2,77]),{29:Dt,57:638},{47:[1,639]},{29:[2,376]},e($r,[2,402]),e($r,[2,115],{215:10,208:528,214:529,44:530,205:640,13:a,16:a,45:a,197:a,224:a,229:a,308:a,87:S}),e($r,[2,118],{272:[1,641]}),e(mn,[2,407],{213:642,319:643,317:[1,644]}),{48:[1,645]},{318:[1,646]},{31:[1,647]},{31:[2,344]},{48:[1,648]},{48:[1,649]},{291:650,303:Ge,304:pt,305:Z,306:P},e(Qt,[2,218]),e(Mt,[2,44]),e(Mn,[2,306]),e(gn,[2,78]),{44:651,87:S},e($r,[2,116]),e(K,[2,406]),e(mn,[2,119]),e(mn,[2,408]),e(h,a,{215:10,205:527,208:528,214:529,44:530,202:652,87:S}),e(Xt,[2,27]),e(Cr,[2,230]),e(Mi,[2,345],{141:653,335:[1,654]}),e(br,[2,181]),e(br,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},e(K,bn,{144:248,142:657,143:658,31:qn,112:qn}),e(Mi,[2,346]),e(gn,[2,80]),e(mn,[2,231]),e(be,[2,67]),e(be,[2,348])],defaultActions:{5:[2,240],6:[2,241],7:[2,242],9:[2,239],24:[2,1],25:[2,2],26:[2,244],87:[2,282],94:[2,384],100:[2,45],109:[2,325],166:[2,458],263:[2,439],336:[2,258],337:[2,101],487:[2,461],488:[2,462],560:[2,468],574:[2,17],575:[2,276],576:[2,18],577:[2,278],623:[2,376],631:[2,344],650:[2,191]},parseError:function(rt,ut){if(ut.recoverable)this.trace(rt);else{var mt=new Error(rt);throw mt.hash=ut,mt}},parse:function(rt){var ut=this,mt=[0],xt=[null],vt=[],se=this.table,yn="",ue=0,ui=0,Es=2,Ji=1,Vs=vt.slice.call(arguments,1),pr=Object.create(this.lexer),Rn={yy:{}};for(var kn in this.yy)Object.prototype.hasOwnProperty.call(this.yy,kn)&&(Rn.yy[kn]=this.yy[kn]);pr.setInput(rt,Rn.yy),Rn.yy.lexer=pr,Rn.yy.parser=this,typeof pr.yylloc>"u"&&(pr.yylloc={});var pi=pr.yylloc;vt.push(pi);var Hs=pr.options&&pr.options.ranges;typeof Rn.yy.parseError=="function"?this.parseError=Rn.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var Jn=function(){var Ri;return Ri=pr.lex()||Ji,typeof Ri!="number"&&(Ri=ut.symbols_[Ri]||Ri),Ri},Nt,Zt,Pt,Rr,Kr={},Ts,Qn,ma,Ws;;){if(Zt=mt[mt.length-1],this.defaultActions[Zt]?Pt=this.defaultActions[Zt]:((Nt===null||typeof Nt>"u")&&(Nt=Jn()),Pt=se[Zt]&&se[Zt][Nt]),typeof Pt>"u"||!Pt.length||!Pt[0]){var Co="";Ws=[];for(Ts in se[Zt])this.terminals_[Ts]&&Ts>Es&&Ws.push("'"+this.terminals_[Ts]+"'");pr.showPosition?Co="Parse error on line "+(ue+1)+`:
131
+ `+pr.showPosition()+`
132
+ Expecting `+Ws.join(", ")+", got '"+(this.terminals_[Nt]||Nt)+"'":Co="Parse error on line "+(ue+1)+": Unexpected "+(Nt==Ji?"end of input":"'"+(this.terminals_[Nt]||Nt)+"'"),this.parseError(Co,{text:pr.match,token:this.terminals_[Nt]||Nt,line:pr.yylineno,loc:pi,expected:Ws})}if(Pt[0]instanceof Array&&Pt.length>1)throw new Error("Parse Error: multiple actions possible at state: "+Zt+", token: "+Nt);switch(Pt[0]){case 1:mt.push(Nt),xt.push(pr.yytext),vt.push(pr.yylloc),mt.push(Pt[1]),Nt=null,ui=pr.yyleng,yn=pr.yytext,ue=pr.yylineno,pi=pr.yylloc;break;case 2:if(Qn=this.productions_[Pt[1]][1],Kr.$=xt[xt.length-Qn],Kr._$={first_line:vt[vt.length-(Qn||1)].first_line,last_line:vt[vt.length-1].last_line,first_column:vt[vt.length-(Qn||1)].first_column,last_column:vt[vt.length-1].last_column},Hs&&(Kr._$.range=[vt[vt.length-(Qn||1)].range[0],vt[vt.length-1].range[1]]),Rr=this.performAction.apply(Kr,[yn,ui,ue,Rn.yy,Pt[1],xt,vt].concat(Vs)),typeof Rr<"u")return Rr;Qn&&(mt=mt.slice(0,-1*Qn*2),xt=xt.slice(0,-1*Qn),vt=vt.slice(0,-1*Qn)),mt.push(this.productions_[Pt[1]][0]),xt.push(Kr.$),vt.push(Kr._$),ma=se[mt[mt.length-2]][mt[mt.length-1]],mt.push(ma);break;case 3:return!0}}return!0}},rn=requireWildcard().Wildcard,Yr="http://www.w3.org/1999/02/22-rdf-syntax-ns#",lr=Yr+"type",Dn=Yr+"first",hi=Yr+"rest",Nr=Yr+"nil",zn="http://www.w3.org/2001/XMLSchema#",Vn=zn+"integer",Hn=zn+"decimal",$s=zn+"double",wo=zn+"boolean",Wn="",vo="",la="";function an(ot){return ot.toLowerCase()}function vi(ot,rt){return ot.push(rt),ot}function qi(ot,rt){return ot.push.apply(ot,rt),ot}function Tr(ot){ot||(ot={});for(var rt=1,ut=arguments.length,mt;rt<ut&&(mt=arguments[rt]||{});rt++)for(var xt in mt)ot[xt]=mt[xt];return ot}function Kn(){for(var ot=[],rt=0,ut=arguments.length;rt<ut;rt++)ot=ot.concat.apply(ot,arguments[rt]);return ot}function vs(ot){if(ot[0]==="<"&&(ot=ot.substring(1,ot.length-1)),/^[a-z][a-z0-9.+-]*:/i.test(ot))return ot;if(!Ot.base)throw new Error("Cannot resolve relative IRI "+ot+" because no base IRI was set.");switch(Wn!==Ot.base&&(Wn=Ot.base,vo=Wn.replace(/[^\/:]*$/,""),la=Wn.match(/^(?:[a-z]+:\/*)?[^\/]*/)[0]),ot[0]){case void 0:return Wn;case"#":return Wn+ot;case"?":return Wn.replace(/(?:\?.*)?$/,ot);case"/":return la+ot;default:return vo+ot}}function So(ot){if(ot){var rt=ot[0];if(rt==="?"||rt==="$")return Ot.factory.variable(ot.substr(1))}return ot}function Wr(ot,rt){return{type:"operation",operator:ot,args:rt||[]}}function zi(ot,rt){var ut={expression:ot==="*"?new rn:ot};if(rt)for(var mt in rt)ut[mt]=rt[mt];return ut}function Vi(ot,rt){return{type:"path",pathType:ot,items:rt}}function Eo(ot,rt){for(var ut=0,mt=rt.length,xt;ut<mt&&(xt=rt[ut]);ut++)ot=Wr(xt[0],[ot,xt[1]]);return ot}function Si(ot,rt){var ut=[],mt=[],xt=ot.length,vt,se={};if(!xt)return null;for(var yn=0;yn<xt&&(vt=ot[yn]);yn++)(vt.named?mt:ut).push(vt.iri);return se[rt||"from"]={default:ut,named:mt},se}function Hi(ot){return parseInt(ot,10)}function To(ot){return ot.type==="group"&&ot.patterns.length===1?ot.patterns[0]:ot}function Gn(ot,rt){return rt&&rt.termType!=="NamedNode"&&(rt=Ot.factory.namedNode(rt)),Ot.factory.literal(ot,rt)}function wl(ot,rt){return Ot.factory.literal(ot,rt)}function Ro(ot,rt,ut){if(!("termType"in rt))throw new Error("Nested triples cannot contain paths");return Ot.factory.quad(ot,rt,ut)}function Pn(ot,rt,ut,mt){var xt={};return ot!=null&&(xt.subject=ot),rt!=null&&(xt.predicate=rt),ut!=null&&(xt.object=ut),mt!=null&&(xt.annotations=mt),xt}function li(ot){return typeof ot=="string"?ot.startsWith("e_")?Ot.factory.blankNode(ot):Ot.factory.blankNode("e_"+ot):Ot.factory.blankNode("g_"+ua++)}var ua=0;Ot._resetBlanks=function(){ua=0};var ca=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\(.)/g,da={"\\":"\\","'":"'",'"':'"',t:" ",b:"\b",n:`
133
+ `,r:"\r",f:"\f"},fa=/[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/,js=String.fromCharCode;function xo(ot,rt){ot=ot.substring(rt,ot.length-rt);try{ot=ot.replace(ca,function(ut,mt,xt,vt){var se;if(mt){if(se=parseInt(mt,16),isNaN(se))throw new Error;return js(se)}else if(xt){if(se=parseInt(xt,16),isNaN(se))throw new Error;return se<65535?js(se):js(55296+((se-=65536)>>10),56320+(se&1023))}else{var yn=da[vt];if(!yn)throw new Error;return yn}})}catch{return""}if(fa.exec(ot))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+ot);return ot}function Wi(ot){var rt=li(),ut=rt,mt=[],xt,vt=[];ot.forEach(function(ui){mt.push(ui.entity),qi(vt,ui.triples)});for(var se=0,yn=0,ue=mt.length,xt=Array(ue*2);se<ue;)xt[yn++]=Pn(ut,Ot.factory.namedNode(Dn),mt[se]),xt[yn++]=Pn(ut,Ot.factory.namedNode(hi),ut=++se<ue?li():Ot.factory.namedNode(Nr));return{entity:rt,triples:qi(xt,vt)}}function vl(ot){var rt=li();return{entity:rt,triples:ot.map(function(ut){return Tr(Pn(rt),ut)})}}function Ao(ot,rt,ut){var mt=[],xt=[];return rt.forEach(function(vt){let se=null;vt.annotation&&(se=vt.annotation,vt=vt.object),mt.push(Pn(null,ot,vt.entity,se)),qi(xt,vt.triples)}),Kn(mt,ut||[],xt)}function Ki(ot){return ot.variable?ot.variable.value:ot.value||ot.expression.value}function Bs(ot){if(!ot)return[];if(ot.type==="aggregate")return[ot];if(ot.type==="operation"){const rt=[];for(const ut of ot.args)rt.push(...Bs(ut));return rt}return[]}function ha(ot){const rt=new Set,ut=function(mt){mt&&(mt.termType==="Variable"?rt.add(mt):mt.type==="operation"&&mt.args.forEach(ut))};return ut(ot),rt}function Ei(ot,rt=1,ut=[]){for(const mt of ot)rt>0&&mt instanceof Array?Ei(mt,rt-1,ut):ut.push(mt);return ut}function Ti(ot){return ot.termType==="Variable"}function pa(ot){if(ot.triples){const rt=[];for(const ut of ot.triples)Ti(ut.subject)&&rt.push(ut.subject.value),Ti(ut.predicate)&&rt.push(ut.predicate.value),Ti(ut.object)&&rt.push(ut.object.value);return rt}else if(ot.patterns){const rt=[];for(const ut of ot.patterns)rt.push(...pa(ut));return rt}return[]}function Ms(ot){const rt=ot.slice().sort(),ut=[];for(let mt=0;mt<rt.length-1;mt++)rt[mt+1]==rt[mt]&&ut.push(rt[mt]);return ut}function Gi(ot){if(!Ot.sparqlStar)throw new Error("SPARQL-star support is not enabled");return ot}function Io(ot,rt,ut){for(const mt of rt){const xt=Pn("subject"in mt?mt.subject:ot,mt.predicate,mt.object);ut.push(xt),mt.annotations&&Io(Ro(ot,mt.predicate,mt.object),mt.annotations,ut)}}function Ss(ot){if(Ot.sparqlStar){const rt=[];return ot.forEach(ut=>{const mt=Pn(ut.subject,ut.predicate,ut.object);rt.push(mt),ut.annotations&&Io(Ro(ut.subject,ut.predicate,ut.object),ut.annotations,rt)}),rt}return ot}function qs(ot){for(const rt of ot){if(rt.type==="graph"&&rt.name.termType==="Variable")throw new Error("Detected illegal variable in GRAPH");if(rt.type==="bgp"||rt.type==="graph"){for(const ut of rt.triples)if(ut.subject.termType==="Variable"||ut.predicate.termType==="Variable"||ut.object.termType==="Variable")throw new Error("Detected illegal variable in BGP")}}return ot}function zs(ot){for(const rt of ot)if(rt.type==="bgp"){for(const ut of rt.triples)if(ut.subject.termType==="BlankNode"||ut.predicate.termType==="BlankNode"||ut.object.termType==="BlankNode")throw new Error("Detected illegal blank node in BGP")}return ot}var ga=(function(){var ot={EOF:1,parseError:function(ut,mt){if(this.yy.parser)this.yy.parser.parseError(ut,mt);else throw new Error(ut)},setInput:function(rt,ut){return this.yy=ut||this.yy||{},this._input=rt,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var rt=this._input[0];this.yytext+=rt,this.yyleng++,this.offset++,this.match+=rt,this.matched+=rt;var ut=rt.match(/(?:\r\n?|\n).*/g);return ut?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),rt},unput:function(rt){var ut=rt.length,mt=rt.split(/(?:\r\n?|\n)/g);this._input=rt+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-ut),this.offset-=ut;var xt=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),mt.length-1&&(this.yylineno-=mt.length-1);var vt=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:mt?(mt.length===xt.length?this.yylloc.first_column:0)+xt[xt.length-mt.length].length-mt[0].length:this.yylloc.first_column-ut},this.options.ranges&&(this.yylloc.range=[vt[0],vt[0]+this.yyleng-ut]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
134
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(rt){this.unput(this.match.slice(rt))},pastInput:function(){var rt=this.matched.substr(0,this.matched.length-this.match.length);return(rt.length>20?"...":"")+rt.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var rt=this.match;return rt.length<20&&(rt+=this._input.substr(0,20-rt.length)),(rt.substr(0,20)+(rt.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var rt=this.pastInput(),ut=new Array(rt.length+1).join("-");return rt+this.upcomingInput()+`
135
+ `+ut+"^"},test_match:function(rt,ut){var mt,xt,vt;if(this.options.backtrack_lexer&&(vt={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(vt.yylloc.range=this.yylloc.range.slice(0))),xt=rt[0].match(/(?:\r\n?|\n).*/g),xt&&(this.yylineno+=xt.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:xt?xt[xt.length-1].length-xt[xt.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+rt[0].length},this.yytext+=rt[0],this.match+=rt[0],this.matches=rt,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(rt[0].length),this.matched+=rt[0],mt=this.performAction.call(this,this.yy,this,ut,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),mt)return mt;if(this._backtrack){for(var se in vt)this[se]=vt[se];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var rt,ut,mt,xt;this._more||(this.yytext="",this.match="");for(var vt=this._currentRules(),se=0;se<vt.length;se++)if(mt=this._input.match(this.rules[vt[se]]),mt&&(!ut||mt[0].length>ut[0].length)){if(ut=mt,xt=se,this.options.backtrack_lexer){if(rt=this.test_match(mt,vt[se]),rt!==!1)return rt;if(this._backtrack){ut=!1;continue}else return!1}else if(!this.options.flex)break}return ut?(rt=this.test_match(ut,vt[xt]),rt!==!1?rt:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
136
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var ut=this.next();return ut||this.lex()},begin:function(ut){this.conditionStack.push(ut)},popState:function(){var ut=this.conditionStack.length-1;return ut>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(ut){return ut=this.conditionStack.length-1-Math.abs(ut||0),ut>=0?this.conditionStack[ut]:"INITIAL"},pushState:function(ut){this.begin(ut)},stateStackSize:function(){return this.conditionStack.length},options:{flex:!0,"case-insensitive":!0},performAction:function(ut,mt,xt,vt){switch(xt){case 0:break;case 1:return 12;case 2:return 15;case 3:return 41;case 4:return 325;case 5:return 326;case 6:return 45;case 7:return 47;case 8:return 48;case 9:return 39;case 10:return 24;case 11:return 28;case 12:return 29;case 13:return 31;case 14:return 32;case 15:return 36;case 16:return 53;case 17:return 327;case 18:return 63;case 19:return 64;case 20:return 70;case 21:return 73;case 22:return 76;case 23:return 78;case 24:return 81;case 25:return 83;case 26:return 85;case 27:return 193;case 28:return 100;case 29:return 328;case 30:return 121;case 31:return 329;case 32:return 330;case 33:return 110;case 34:return 331;case 35:return 109;case 36:return 332;case 37:return 333;case 38:return 113;case 39:return 115;case 40:return 116;case 41:return 131;case 42:return 123;case 43:return 126;case 44:return 128;case 45:return 132;case 46:return 112;case 47:return 334;case 48:return 335;case 49:return 159;case 50:return 161;case 51:return 164;case 52:return 174;case 53:return 160;case 54:return 336;case 55:return 163;case 56:return 312;case 57:return 314;case 58:return 317;case 59:return 318;case 60:return 272;case 61:return 197;case 62:return 337;case 63:return 338;case 64:return 229;case 65:return 340;case 66:return 263;case 67:return 224;case 68:return 231;case 69:return 232;case 70:return 242;case 71:return 246;case 72:return 290;case 73:return 341;case 74:return 342;case 75:return 343;case 76:return 344;case 77:return 345;case 78:return 250;case 79:return 346;case 80:return 265;case 81:return 276;case 82:return 277;case 83:return 268;case 84:return 269;case 85:return 270;case 86:return 271;case 87:return 347;case 88:return 348;case 89:return 273;case 90:return 274;case 91:return 350;case 92:return 349;case 93:return 351;case 94:return 279;case 95:return 280;case 96:return 283;case 97:return 285;case 98:return 289;case 99:return 293;case 100:return 296;case 101:return 13;case 102:return 16;case 103:return 308;case 104:return 309;case 105:return 87;case 106:return 292;case 107:return 82;case 108:return 294;case 109:return 295;case 110:return 297;case 111:return 298;case 112:return 299;case 113:return 300;case 114:return 301;case 115:return 302;case 116:return"EXPONENT";case 117:return 303;case 118:return 304;case 119:return 305;case 120:return 306;case 121:return 89;case 122:return 310;case 123:return 6;case 124:return"INVALID";case 125:console.log(mt.yytext);break}},rules:[/^(?:\s+|(#[^\n\r]*))/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:\{\|)/i,/^(?:\|\})/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(SUBJECT|PREDICATE|OBJECT|isTRIPLE))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:TRIPLE)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true|false)/i,/^(?:(<(?:[^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:)((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?))/i,/^(?:([\?\$]((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(?:(?:[^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*'))/i,/^(?:("(?:(?:[^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*"))/i,/^(?:('''(?:(?:'|'')?(?:[^'\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*'''))/i,/^(?:("""(?:(?:"|"")?(?:[^\"\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125],inclusive:!0}}};return ot})();Xr.lexer=ga;function Ot(){this.yy={}}return Ot.prototype=Xr,Xr.Parser=Ot,new Ot})();return SparqlParser_1=i,SparqlParser_1}var SparqlGenerator,hasRequiredSparqlGenerator;function requireSparqlGenerator(){if(hasRequiredSparqlGenerator)return SparqlGenerator;hasRequiredSparqlGenerator=1;var i="http://www.w3.org/2001/XMLSchema#integer",e="http://www.w3.org/2001/XMLSchema#string";function t(y){this._options=y=y||{};var S=y.prefixes||{};this._prefixByIri={};var w=[];for(var R in S){var T=S[R];c(T)&&(this._prefixByIri[T]=R,w.push(T))}var A=w.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+A+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._sparqlStar=y.sparqlStar,this._indent=c(y.indent)?y.indent:" ",this._newline=c(y.newline)?y.newline:`
137
+ `,this._explicitDatatype=!!y.explicitDatatype}t.prototype.toQuery=function(y){var S="";return y.queryType&&(S+=y.queryType.toUpperCase()+" "),y.reduced&&(S+="REDUCED "),y.distinct&&(S+="DISTINCT "),y.variables?S+=p(y.variables,void 0,function(w){return/^[?$]/.test(w)?w:h(w)?this.toEntity(w):"("+this.toExpression(w.expression)+" AS "+u(w.variable)+")"},this)+" ":y.template&&(S+=this.group(y.template,!0)+this._newline),y.from&&(S+=this.graphs("FROM ",y.from.default)+this.graphs("FROM NAMED ",y.from.named)),y.where&&(S+="WHERE "+this.group(y.where,!0)+this._newline),y.updates&&(S+=p(y.updates,";"+this._newline,this.toUpdate,this)),y.group&&(S+="GROUP BY "+p(y.group,void 0,function(w){var R=h(w.expression)?this.toEntity(w.expression):"("+this.toExpression(w.expression)+")";return w.variable?"("+R+" AS "+u(w.variable)+")":R},this)+this._newline),y.having&&(S+="HAVING ("+p(y.having,void 0,this.toExpression,this)+")"+this._newline),y.order&&(S+="ORDER BY "+p(y.order,void 0,function(w){var R="("+this.toExpression(w.expression)+")";return w.descending?"DESC "+R:R},this)+this._newline),Number.isInteger(y.offset)&&(S+="OFFSET "+y.offset+this._newline),Number.isInteger(y.limit)&&(S+="LIMIT "+y.limit+this._newline),y.values&&(S+=this.values(y)),S=this.baseAndPrefixes(y)+S,S.trim()},t.prototype.baseAndPrefixes=function(y){var S=y.base?"BASE <"+y.base+">"+this._newline:"",w="";for(var R in y.prefixes)(this._options.allPrefixes||this._usedPrefixes[R])&&(w+="PREFIX "+R+": <"+y.prefixes[R]+">"+this._newline);return S+w},t.prototype.toPattern=function(y){var S=y.type||y instanceof Array&&"array"||(y.subject&&y.predicate&&y.object?"triple":"");if(!(S in this))throw new Error("Unknown entry type: "+S);return this[S](y)},t.prototype.triple=function(y){return this.toEntity(y.subject)+" "+this.toEntity(y.predicate)+" "+this.toEntity(y.object)+"."},t.prototype.array=function(y){return p(y,this._newline,this.toPattern,this)},t.prototype.bgp=function(y){return this.encodeTriples(y.triples)},t.prototype.encodeTriples=function(y){if(!y.length)return"";for(var S=[],w=void 0,R=void 0,T=0;T<y.length;T++){var A=y[T];f(A.subject,w)?f(A.predicate,R)?S.push(","):(R=A.predicate,S.push(";"+this._newline,this._indent,this.toEntity(R))):(w&&S.push("."+this._newline),w=A.subject,R=A.predicate,S.push(this.toEntity(w)," ",this.toEntity(R))),S.push(" ",this.toEntity(A.object))}return S.push("."),S.join("")},t.prototype.graph=function(y){return"GRAPH "+this.toEntity(y.name)+" "+this.group(y)},t.prototype.graphs=function(y,S){return!S||S.length===0?"":p(S,"",function(w){return y+this.toEntity(w)+this._newline},this)},t.prototype.group=function(y,S){return y=S!==!0?this.array(y.patterns||y.triples):this.toPattern(y.type!=="group"?y:y.patterns),y.indexOf(this._newline)===-1?"{ "+y+" }":"{"+this._newline+this.indent(y)+this._newline+"}"},t.prototype.query=function(y){return this.toQuery(y)},t.prototype.filter=function(y){return"FILTER("+this.toExpression(y.expression)+")"},t.prototype.bind=function(y){return"BIND("+this.toExpression(y.expression)+" AS "+u(y.variable)+")"},t.prototype.optional=function(y){return"OPTIONAL "+this.group(y)},t.prototype.union=function(y){return p(y.patterns,this._newline+"UNION"+this._newline,function(S){return this.group(S,!0)},this)},t.prototype.minus=function(y){return"MINUS "+this.group(y)},t.prototype.values=function(y){var S=Object.keys(y.values.reduce(function(T,A){for(var F in A)T[F]=!0;return T},{})),w,R;return S.length===1?w=R="":(w="(",R=")"),"VALUES "+w+S.join(" ")+R+" {"+this._newline+p(y.values,this._newline,function(T){return" "+w+p(S,void 0,function(A){return T[A]?this.toEntity(T[A]):"UNDEF"},this)+R},this)+this._newline+"}"},t.prototype.service=function(y){return"SERVICE "+(y.silent?"SILENT ":"")+this.toEntity(y.name)+" "+this.group(y)},t.prototype.toExpression=function(y){if(h(y))return this.toEntity(y);switch(y.type.toLowerCase()){case"aggregate":return y.aggregation.toUpperCase()+"("+(y.distinct?"DISTINCT ":"")+this.toExpression(y.expression)+(typeof y.separator=="string"?'; SEPARATOR = "'+y.separator.replace(n,s)+'"':"")+")";case"functioncall":return this.toEntity(y.function)+"("+p(y.args,", ",this.toExpression,this)+")";case"operation":var S=y.operator.toUpperCase(),w=y.args||[];switch(y.operator.toLowerCase()){case"<":case">":case">=":case"<=":case"&&":case"||":case"=":case"!=":case"+":case"-":case"*":case"/":return(h(w[0])?this.toEntity(w[0]):"("+this.toExpression(w[0])+")")+" "+S+" "+(h(w[1])?this.toEntity(w[1]):"("+this.toExpression(w[1])+")");case"!":return"!("+this.toExpression(w[0])+")";case"uplus":return"+("+this.toExpression(w[0])+")";case"uminus":return"-("+this.toExpression(w[0])+")";case"notin":S="NOT IN";case"in":return this.toExpression(w[0])+" "+S+"("+(c(w[1])?w[1]:p(w[1],", ",this.toExpression,this))+")";case"notexists":S="NOT EXISTS";case"exists":return S+" "+this.group(w[0],!0);default:return S+"("+p(w,", ",this.toExpression,this)+")"}default:throw new Error("Unknown expression type: "+y.type)}},t.prototype.toEntity=function(y){if(h(y))switch(y.termType){case"Wildcard":return"*";case"Variable":return u(y);case"BlankNode":return"_:"+y.value;case"Literal":var S=y.value||"",w=y.language||"",R=y.datatype;if(y='"'+S.replace(n,s)+'"',w)y+="@"+w;else if(R){if(!this._explicitDatatype)switch(R.value){case e:return y;case i:if(/^\d+$/.test(S))return S+" "}y+="^^"+this.encodeIRI(R.value)}return y;case"Quad":if(!this._sparqlStar)throw new Error("SPARQL* support is not enabled");return y.graph&&y.graph.termType!=="DefaultGraph"?"<< GRAPH "+this.toEntity(y.graph)+" { "+this.toEntity(y.subject)+" "+this.toEntity(y.predicate)+" "+this.toEntity(y.object)+" } >>":"<< "+this.toEntity(y.subject)+" "+this.toEntity(y.predicate)+" "+this.toEntity(y.object)+" >>";default:return this.encodeIRI(y.value)}else{var T=y.items.map(this.toEntity,this),A=y.pathType;switch(A){case"^":case"!":return A+T[0];case"*":case"+":case"?":return"("+T[0]+A+")";default:return"("+T.join(A)+")"}}};var n=/["\\\t\n\r\b\f]/g,s=function(y){return a[y]},a={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};t.prototype.encodeIRI=function(y){var S=this._prefixRegex.exec(y);if(S){var w=this._prefixByIri[S[1]];return this._usedPrefixes[w]=!0,w+":"+S[2]}return"<"+y+">"},t.prototype.toUpdate=function(y){switch(y.type||y.updateType){case"load":return"LOAD"+(y.source?" "+this.toEntity(y.source):"")+(y.destination?" INTO GRAPH "+this.toEntity(y.destination):"");case"insert":return"INSERT DATA "+this.group(y.insert,!0);case"delete":return"DELETE DATA "+this.group(y.delete,!0);case"deletewhere":return"DELETE WHERE "+this.group(y.delete,!0);case"insertdelete":return(y.graph?"WITH "+this.toEntity(y.graph)+this._newline:"")+(y.delete.length?"DELETE "+this.group(y.delete,!0)+this._newline:"")+(y.insert.length?"INSERT "+this.group(y.insert,!0)+this._newline:"")+(y.using?this.graphs("USING ",y.using.default):"")+(y.using?this.graphs("USING NAMED ",y.using.named):"")+"WHERE "+this.group(y.where,!0);case"add":case"copy":case"move":return y.type.toUpperCase()+" "+(y.silent?"SILENT ":"")+(y.source.default?"DEFAULT":this.toEntity(y.source.name))+" TO "+this.toEntity(y.destination.name);case"create":case"clear":case"drop":return y.type.toUpperCase()+(y.silent?" SILENT ":" ")+(y.graph.default?"DEFAULT":y.graph.named?"NAMED":y.graph.all?"ALL":"GRAPH "+this.toEntity(y.graph.name));default:throw new Error("Unknown update query type: "+y.type)}},t.prototype.indent=function(y){return y.replace(/^/gm,this._indent)};function u(y){return"?"+y.value}function c(y){return typeof y=="string"}function h(y){return typeof y.termType=="string"}function f(y,S){if(!y||!h(y)||!S||!h(S)||y.termType!==S.termType)return!1;switch(y.termType){case"Literal":return y.value===S.value&&y.language===S.language&&f(y.datatype,S.datatype);case"Quad":return f(y.subject,S.subject)&&f(y.predicate,S.predicate)&&f(y.object,S.object)&&f(y.graph,S.graph);default:return y.value===S.value}}function p(y,S,w,R){return y.map(w,R).join(c(S)?S:" ")}function g(y={}){return{stringify:function(S){var w=Object.create(y);return w.prefixes=S.prefixes,new t(w).toQuery(S)},createGenerator:function(){return new t(y)}}}return SparqlGenerator={Generator:g},SparqlGenerator}var rdfDataFactory={},BlankNode$1={},hasRequiredBlankNode;function requireBlankNode(){if(hasRequiredBlankNode)return BlankNode$1;hasRequiredBlankNode=1,Object.defineProperty(BlankNode$1,"__esModule",{value:!0}),BlankNode$1.BlankNode=void 0;class i{constructor(t){this.termType="BlankNode",this.value=t}equals(t){return!!t&&t.termType==="BlankNode"&&t.value===this.value}}return BlankNode$1.BlankNode=i,BlankNode$1}var DataFactory$1={},DefaultGraph$1={},hasRequiredDefaultGraph;function requireDefaultGraph(){if(hasRequiredDefaultGraph)return DefaultGraph$1;hasRequiredDefaultGraph=1,Object.defineProperty(DefaultGraph$1,"__esModule",{value:!0}),DefaultGraph$1.DefaultGraph=void 0;class i{constructor(){this.termType="DefaultGraph",this.value=""}equals(t){return!!t&&t.termType==="DefaultGraph"}}return DefaultGraph$1.DefaultGraph=i,i.INSTANCE=new i,DefaultGraph$1}var Literal$1={},NamedNode$1={},hasRequiredNamedNode;function requireNamedNode(){if(hasRequiredNamedNode)return NamedNode$1;hasRequiredNamedNode=1,Object.defineProperty(NamedNode$1,"__esModule",{value:!0}),NamedNode$1.NamedNode=void 0;class i{constructor(t){this.termType="NamedNode",this.value=t}equals(t){return!!t&&t.termType==="NamedNode"&&t.value===this.value}}return NamedNode$1.NamedNode=i,NamedNode$1}var hasRequiredLiteral;function requireLiteral(){if(hasRequiredLiteral)return Literal$1;hasRequiredLiteral=1,Object.defineProperty(Literal$1,"__esModule",{value:!0}),Literal$1.Literal=void 0;const i=requireNamedNode();class e{constructor(n,s){this.termType="Literal",this.value=n,typeof s=="string"?(this.language=s,this.datatype=e.RDF_LANGUAGE_STRING):s?(this.language="",this.datatype=s):(this.language="",this.datatype=e.XSD_STRING)}equals(n){return!!n&&n.termType==="Literal"&&n.value===this.value&&n.language===this.language&&this.datatype.equals(n.datatype)}}return Literal$1.Literal=e,e.RDF_LANGUAGE_STRING=new i.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),e.XSD_STRING=new i.NamedNode("http://www.w3.org/2001/XMLSchema#string"),Literal$1}var Quad$1={},hasRequiredQuad;function requireQuad(){if(hasRequiredQuad)return Quad$1;hasRequiredQuad=1,Object.defineProperty(Quad$1,"__esModule",{value:!0}),Quad$1.Quad=void 0;class i{constructor(t,n,s,a){this.termType="Quad",this.value="",this.subject=t,this.predicate=n,this.object=s,this.graph=a}equals(t){return!!t&&(t.termType==="Quad"||!t.termType)&&this.subject.equals(t.subject)&&this.predicate.equals(t.predicate)&&this.object.equals(t.object)&&this.graph.equals(t.graph)}}return Quad$1.Quad=i,Quad$1}var Variable$1={},hasRequiredVariable;function requireVariable(){if(hasRequiredVariable)return Variable$1;hasRequiredVariable=1,Object.defineProperty(Variable$1,"__esModule",{value:!0}),Variable$1.Variable=void 0;class i{constructor(t){this.termType="Variable",this.value=t}equals(t){return!!t&&t.termType==="Variable"&&t.value===this.value}}return Variable$1.Variable=i,Variable$1}var hasRequiredDataFactory;function requireDataFactory(){if(hasRequiredDataFactory)return DataFactory$1;hasRequiredDataFactory=1,Object.defineProperty(DataFactory$1,"__esModule",{value:!0}),DataFactory$1.DataFactory=void 0;const i=requireBlankNode(),e=requireDefaultGraph(),t=requireLiteral(),n=requireNamedNode(),s=requireQuad(),a=requireVariable();let u=0;class c{constructor(f){this.blankNodeCounter=0,f=f||{},this.blankNodePrefix=f.blankNodePrefix||`df_${u++}_`}namedNode(f){return new n.NamedNode(f)}blankNode(f){return new i.BlankNode(f||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(f,p){return new t.Literal(f,p)}variable(f){return new a.Variable(f)}defaultGraph(){return e.DefaultGraph.INSTANCE}quad(f,p,g,y){return new s.Quad(f,p,g,y||this.defaultGraph())}fromTerm(f){switch(f.termType){case"NamedNode":return this.namedNode(f.value);case"BlankNode":return this.blankNode(f.value);case"Literal":return f.language?this.literal(f.value,f.language):f.datatype.equals(t.Literal.XSD_STRING)?this.literal(f.value):this.literal(f.value,this.fromTerm(f.datatype));case"Variable":return this.variable(f.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(f.subject),this.fromTerm(f.predicate),this.fromTerm(f.object),this.fromTerm(f.graph))}}fromQuad(f){return this.fromTerm(f)}resetBlankNodeCounter(){this.blankNodeCounter=0}}return DataFactory$1.DataFactory=c,DataFactory$1}var hasRequiredRdfDataFactory;function requireRdfDataFactory(){return hasRequiredRdfDataFactory||(hasRequiredRdfDataFactory=1,(function(i){var e=rdfDataFactory&&rdfDataFactory.__createBinding||(Object.create?(function(n,s,a,u){u===void 0&&(u=a);var c=Object.getOwnPropertyDescriptor(s,a);(!c||("get"in c?!s.__esModule:c.writable||c.configurable))&&(c={enumerable:!0,get:function(){return s[a]}}),Object.defineProperty(n,u,c)}):(function(n,s,a,u){u===void 0&&(u=a),n[u]=s[a]})),t=rdfDataFactory&&rdfDataFactory.__exportStar||function(n,s){for(var a in n)a!=="default"&&!Object.prototype.hasOwnProperty.call(s,a)&&e(s,n,a)};Object.defineProperty(i,"__esModule",{value:!0}),t(requireBlankNode(),i),t(requireDataFactory(),i),t(requireDefaultGraph(),i),t(requireLiteral(),i),t(requireNamedNode(),i),t(requireQuad(),i),t(requireVariable(),i)})(rdfDataFactory)),rdfDataFactory}var sparql,hasRequiredSparql;function requireSparql(){if(hasRequiredSparql)return sparql;hasRequiredSparql=1;const{Parser:i}=requireSparqlParser(),{Generator:e}=requireSparqlGenerator(),{Wildcard:t}=requireWildcard(),{DataFactory:n}=requireRdfDataFactory();function s({prefixes:a,baseIRI:u,factory:c,pathOnly:h,sparqlStar:f,skipValidation:p,skipUngroupedVariableCheck:g}={}){const y={};for(const w in a??{})y[w]=a[w];const S=new i;return S.parse=function(){return i.base=u||"",i.prefixes=Object.create(y),i.factory=c||new n,i.sparqlStar=!!f,i.pathOnly=!!h,i.skipValidation=!!p||!!g,i.prototype.parse.apply(S,arguments)},S._resetBlanks=i._resetBlanks,S}return sparql={Parser:s,Generator:e,Wildcard:t},sparql}var sparqlExports=requireSparql();class ExpressionBuilder{constructor(e=new UriResolverImpl){this.uriResolver=e}setTableContext(e){this.tableContext=e}getUriContext(){if(this.tableContext)return{baseUri:this.tableContext.baseUri,tableRegistry:this.tableContext.tableRegistry,tableNameRegistry:this.tableContext.tableNameRegistry}}buildWhereClause(e,t){const n=this.buildExpression(e,t);return n?`FILTER(${n})`:""}extractSubjectConstraint(e,t){const n=this.extractSubjectConstraintInternal(e,t);return n?.values?.length?n:null}isLinkColumn(e){return this.uriResolver.isLinkColumn(e)}formatLinkValue(e,t,n){const s=String(e);if(s.startsWith("<")&&s.endsWith(">")){const a=s.slice(1,-1);if(this.uriResolver.isAbsoluteUri(a))return s;const u=this.getUriContext();try{return`<${this.uriResolver.resolveLink(a,t,u)}>`}catch(c){const h=n.config?.name??"unknown",f=t?.name??"unknown";if(this.isPartialTemplateError(c))return{partial:!0,id:a};throw new Error(`[ExpressionBuilder] Failed to resolve URI for ${h}.${f}: ${c}`)}}if(s.startsWith("<"))return s;try{const a=this.getUriContext();return`<${this.uriResolver.resolveLink(s,t,a)}>`}catch(a){const u=n.config?.name??"unknown",c=t?.name??"unknown";if(this.isPartialTemplateError(a))return{partial:!0,id:s};throw new Error(`[ExpressionBuilder] Failed to resolve URI for ${u}.${c}: ${a}`)}}isPartialTemplateError(e){const t=String(e);return t.includes("Missing required fields for template")||t.includes("Unresolved URI template variable")}isPartialLinkValue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.partial===!0&&typeof e.id=="string"}formatPartialLinkCondition(e,t,n){if(!this.isPartialLinkValue(t))return;const s=t.id.replace(/\\/g,"\\\\").replace(/"/g,'\\"');if(n==="=")return`STRENDS(STR(${e}), "#${s}")`;if(n==="!=")return`!STRENDS(STR(${e}), "#${s}")`}parseTemplateVariable(e){const[t,...n]=e.split("|").map(s=>s.trim()).filter(Boolean);return{field:t||e,transforms:n}}getTemplateVariableFields(e){const t=e.config?.subjectTemplate??"";return t?Array.from(new Set(Array.from(t.matchAll(/\{([^}]+)\}/g)).map(n=>this.parseTemplateVariable(n[1]).field))):[]}getMissingLocatorVariables(e){const t=new Set(["id","index","yyyy","MM","dd","HH","mm","ss","timestamp","date"]);return this.getTemplateVariableFields(e).filter(n=>!t.has(n))}buildMissingLocatorError(e){const t=e.config?.subjectTemplate??"",n=this.getMissingLocatorVariables(e);return new Error(`Cannot resolve subjectTemplate '${t}': missing required variable(s) [${n.join(", ")}] in query condition. Add eq(table.${n[0]}, value) to your where clause.`)}formatSubjectValue(e,t,n){const s=String(e??"");if(s.startsWith("<")&&s.endsWith(">")){const u=s.slice(1,-1);if(this.uriResolver.isAbsoluteUri(u))return s;const c=u.startsWith("#")?u.slice(1):u;try{return`<${this.uriResolver.resolveSubject(t,{id:c})}>`}catch(h){throw this.getMissingLocatorVariables(t).length>0?this.buildMissingLocatorError(t):h}}if(this.uriResolver.isAbsoluteUri(s))return`<${s}>`;const a=s.startsWith("#")?s.slice(1):s;try{return`<${this.uriResolver.resolveSubject(t,{id:a})}>`}catch(u){throw this.getMissingLocatorVariables(t).length>0?this.buildMissingLocatorError(t):u}}isDrizzleSQL(e){return!e||typeof e!="object"?!1:e.constructor?.[Symbol.for("drizzle:entityKind")]==="SQL"||Array.isArray(e.queryChunks)&&typeof e.getSQL=="function"}buildExpression(e,t){if(!e||typeof e!="object")return"";if(this.isDrizzleSQL(e))throw new Error("Drizzle-ORM operators are not supported. Please use the operators provided by drizzle-solid.");switch(e.type){case"logical_expr":return this.buildLogicalExpression(e,t);case"unary_expr":return this.buildUnaryExpression(e,t);case"binary_expr":return this.buildBinaryExpression(e,t);default:return""}}buildLogicalExpression(e,t){if(!e.expressions||e.expressions.length===0)return"";const n=e.expressions.map(a=>this.buildExpression(a,t)).filter(a=>a.length>0);if(n.length===0)return"";const s=e.operator==="OR"?" || ":" && ";return`(${n.join(s)})`}extractSubjectConstraintInternal(e,t){if(!e||typeof e!="object"||this.isDrizzleSQL(e))return null;if(e.type==="binary_expr")return this.extractSubjectConstraintFromBinary(e,t);if(e.type==="logical_expr"&&e.operator==="AND"&&Array.isArray(e.expressions)){const n=this.extractExactSubjectConstraintFromLogical(e,t);if(n)return n;let s=null;const a=[];for(const u of e.expressions){const c=this.extractSubjectConstraintInternal(u,t);if(c?.values?.length){s=s===null?[...c.values]:s.filter(h=>new Set(c.values).has(h)),c.remainingCondition&&a.push(c.remainingCondition);continue}a.push(u)}return s?.length?a.length===0?{values:s}:a.length===1?{values:s,remainingCondition:a[0]}:{values:s,remainingCondition:new LogicalExpression("AND",a)}:null}return null}extractSubjectConstraintFromBinary(e,t){if(e.operator!=="IN"||!Array.isArray(e.right)||e.right.length<=1)return null;const n=this.resolveColumnName(e.left);if(!n)return null;const s=t.columns[n],a=n==="id",u=a&&s?getPredicateForColumn(s,t):null,c=a&&u==="@id";if(!(n==="subject"||n==="@id"||c))return null;const f=[];for(const p of e.right){const g=this.formatSubjectValue(p,t,c);if(typeof g!="string"||!g.startsWith("<")||!g.endsWith(">"))return null;f.push(g.slice(1,-1))}return f.length>1?{values:f}:null}extractExactSubjectConstraintFromLogical(e,t){if(!(t.config?.subjectTemplate??"").includes("{"))return null;const s=new Set(["index","yyyy","MM","dd","HH","mm","ss","timestamp","date"]),a=this.getTemplateVariableFields(t).filter(p=>!s.has(p));if(a.length===0)return null;const u=new Map,c=[];for(const p of e.expressions){const g=p;if(g.type!=="binary_expr"||g.operator!=="="){c.push(p);continue}const y=this.resolveColumnName(g.left);if(!y||!a.includes(y)&&y!=="id"&&y!=="@id"&&y!=="subject"){c.push(p);continue}u.set(y,g.right)}if(!u.has("id")&&!u.has("@id")&&!u.has("subject"))return null;const h={};for(const p of a){if(!u.has(p))return null;h[p]=u.get(p)}u.has("@id")?h["@id"]=u.get("@id"):u.has("subject")?h["@id"]=u.get("subject"):h.id=u.get("id");const f=this.uriResolver.resolveSubject(t,h);return c.length===0?{values:[f]}:c.length===1?{values:[f],remainingCondition:c[0]}:{values:[f],remainingCondition:new LogicalExpression("AND",c)}}buildUnaryExpression(e,t){const n=e.operator;if(n==="NOT")return`!(${this.buildExpression(e.value,t)})`;const s=this.resolveColumnName(e.value);if(!s)return"";const a=t.columns[s],u=s==="id",c=u&&a?getPredicateForColumn(a,t):null,p=s==="subject"||s==="@id"||u&&c==="@id"?"?subject":`?${s}`;if(n==="IS NULL")return`!(BOUND(${p}))`;if(n==="IS NOT NULL")return`BOUND(${p})`;if(n==="EXISTS"||n==="NOT EXISTS"){const y=`EXISTS { ${String(e.value)} }`;return n==="NOT EXISTS"?`!(${y})`:y}return""}buildBinaryExpression(e,t){const n=this.resolveColumnName(e.left);if(!n)return"";const s=t.columns[n],a=n==="id",u=a&&s?getPredicateForColumn(s,t):null,c=a&&u==="@id",h=n==="subject"||n==="@id"||c,f=h?"?subject":`?${n}`,p=this.isLinkColumn(s);let g=e.right;if(e.operator==="IN"||e.operator==="NOT IN"){if(!Array.isArray(g)||g.length===0)return e.operator==="IN"?"false":"true";if(h){const A=g.map(x=>this.formatSubjectValue(x,t,c)).join(", "),F=`${f} IN(${A})`;return e.operator==="NOT IN"?`!(${F})`:F}const S=g.map(A=>p?this.formatLinkValue(A,s,t):formatValue(A,s,this.uriResolver,this.getUriContext()));if(S.some(A=>this.isPartialLinkValue(A))){const F=`(${S.map(x=>{if(this.isPartialLinkValue(x)){const O=x.id.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`STRENDS(STR(${f}), "#${O}")`}const D=Array.isArray(x)?x.join(", "):x;return`(${f} = ${D})`}).join(" || ")})`;return e.operator==="NOT IN"?`!(${F})`:F}const R=S.join(", "),T=`${f} IN(${R})`;return e.operator==="NOT IN"?`!(${T})`:T}if(e.operator==="REGEX"){const S=g.pattern??g,w=g.flags??"";return`REGEX(STR(${f}), "${S}", "${w}")`}if(e.operator==="LIKE"){let S=String(g).replace(/[.+^${}()|[\\]/g,"\\$&").replace(/%/g,".*").replace(/_/g,".");return`REGEX(STR(${f}), "^${S}$", "i")`}if(e.operator==="ILIKE"){let S=String(g).replace(/[.+^${}()|[\\]/g,"\\$&").replace(/%/g,".*").replace(/_/g,".");return`REGEX(STR(${f}), "^${S}$", "i")`}if(e.operator==="BETWEEN"||e.operator==="NOT BETWEEN"){if(!Array.isArray(g)||g.length!==2)return"";const[S,w]=g,R=formatValue(S,s,this.uriResolver,this.getUriContext()),T=formatValue(w,s,this.uriResolver,this.getUriContext()),A=`(${f} >= ${R} && ${f} <= ${T})`;return e.operator==="NOT BETWEEN"?`!${A}`:A}let y;if(h)y=this.formatSubjectValue(g,t,c);else if(p){const S=this.formatLinkValue(g,s,t),w=this.formatPartialLinkCondition(f,S,e.operator);if(w)return w;y=this.isPartialLinkValue(S)?`"${S.id.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:S}else y=formatValue(g,s,this.uriResolver,this.getUriContext());return`(${f} ${e.operator} ${y})`}resolveColumnName(e){return typeof e=="string"?e.includes(".")?e.split(".")[1]:e:e&&typeof e=="object"&&"name"in e?e.name:e&&typeof e=="object"&&"column"in e?e.column:""}}class SelectBuilder{constructor(e,t=new UriResolverImpl){this.generator=new sparqlExports.Generator,this.prefixes=e,this.uriResolver=t,this.expressionBuilder=new ExpressionBuilder(t)}setTableContext(e){this.tableContext=e,this.expressionBuilder.setTableContext(e)}convertSelect(e,t,n,s,a=!0){const u={queryType:"SELECT",variables:this.buildSelectVariables(e,t),where:this.buildWherePatterns(e,t,n,s,a),type:"query",prefixes:this.prefixes};return s&&s.length>0&&!n&&(u.from={default:s.map(h=>({termType:"NamedNode",value:h})),named:[]}),typeof e.limit=="number"&&(u.limit=e.limit),typeof e.offset=="number"&&(u.offset=e.offset),Array.isArray(e.orderBy)&&e.orderBy.length>0&&(u.order=e.orderBy.map(h=>({expression:{termType:"Variable",value:h.column},descending:h.direction==="desc"}))),Array.isArray(e.groupBy)&&e.groupBy.length>0&&(u.group=e.groupBy.map(h=>({expression:{termType:"Variable",value:h}}))),Array.isArray(e.having)&&e.having.length>0&&(u.having=e.having),e.distinct&&(u.distinct=!0),{type:"SELECT",query:this.generator.stringify(u),prefixes:this.prefixes}}convertSelectPlan(e,t,n,s=!0){const a=e.orderBy?.map(h=>{const f=h.reference?.column??h.rawColumn;if(f)return{column:f,direction:h.direction}}).filter(h=>!!h),u=e.groupBy?.map(h=>h.column),c={select:e.select,columns:e.selectAll?"*":void 0,where:e.conditionTree??e.where,limit:e.limit,offset:e.offset,orderBy:a,groupBy:u,having:this.buildHavingExpressions(e),distinct:e.distinct};return this.convertSelect(c,e.baseTable,t,n,s)}buildHavingExpressions(e){if(!e.having)return;const t=this.buildHavingExpression(e.having,e.select,e.baseTable);if(!t)return;const n=Object.entries(this.prefixes).map(([p,g])=>`PREFIX ${p}: <${g}>`).join(`
138
+ `),s=e.groupBy?.map(p=>`?${p.column}`)??[],a=s.length>0?s.join(" "):"?subject",u=s.length>0?` GROUP BY ${s.join(" ")}`:"",c=`${n}
139
+ SELECT ${a} WHERE { ?subject ?predicate ?object . }${u} HAVING (${t})`;return new sparqlExports.Parser({skipUngroupedVariableCheck:!0}).parse(c).having}buildHavingExpression(e,t,n){switch(e.type){case"logical_expr":return this.buildHavingLogicalExpression(e,t,n);case"unary_expr":return this.buildHavingUnaryExpression(e,t,n);case"binary_expr":return this.buildHavingBinaryExpression(e,t,n);default:return""}}buildHavingLogicalExpression(e,t,n){const s=e.operator==="OR"?" || ":" && ",a=(e.expressions??[]).map(u=>this.buildHavingExpression(u,t,n)).filter(u=>u.length>0);return a.length===0?"":`(${a.join(s)})`}buildHavingUnaryExpression(e,t,n){const s=e.operator.toUpperCase();if(s==="NOT"){const u=this.buildHavingExpression(e.value,t,n);return u?`!(${u})`:""}if(s==="EXISTS"||s==="NOT EXISTS"){const u=`EXISTS { ${String(e.value)} }`;return s==="NOT EXISTS"?`!(${u})`:u}const a=this.buildHavingOperand(e.value,t,n);return a?s==="IS NULL"?`!(BOUND(${a}))`:s==="IS NOT NULL"?`BOUND(${a})`:"":""}buildHavingBinaryExpression(e,t,n){const s=this.buildHavingOperand(e.left,t,n);if(!s)return"";const a=e.operator.toUpperCase();if(a==="BETWEEN"||a==="NOT BETWEEN"){const c=Array.isArray(e.right)?e.right:[];if(c.length!==2)return"";const h=this.buildHavingOperand(c[0],t,n),f=this.buildHavingOperand(c[1],t,n),p=`(${s} >= ${h} && ${s} <= ${f})`;return a==="NOT BETWEEN"?`!${p}`:p}if(a==="IN"||a==="NOT IN"){const h=(Array.isArray(e.right)?e.right:[]).map(p=>this.buildHavingOperand(p,t,n)).join(", "),f=`${s} IN (${h})`;return a==="NOT IN"?`!(${f})`:f}const u=this.buildHavingOperand(e.right,t,n);return u?`${s} ${e.operator} ${u}`:""}buildHavingOperand(e,t,n){return e instanceof SelectionAliasExpression?this.buildHavingAliasOperand(e.alias,t,n):typeof e=="string"&&t&&e in t?this.buildHavingAliasOperand(e,t,n):e instanceof PodColumnBase?`?${resolveColumn(e,n).name}`:e&&typeof e=="object"&&"name"in e?`?${resolveColumn(e,n).name}`:typeof e=="string"&&n.columns[e]?`?${resolveColumn(e,n).name}`:String(formatValue(e,void 0,this.uriResolver,this.getUriContext()))}buildHavingAliasOperand(e,t,n){const s=t?.[e];return s?isAggregateExpression(s)?this.buildAggregateOperand(s,n):s instanceof PodColumnBase||typeof s=="string"||s&&typeof s=="object"&&"name"in s?`?${resolveColumn(s,n).name}`:`?${e}`:`?${e}`}buildAggregateOperand(e,t){const n=e.distinct?"DISTINCT ":"";if(!e.column)return`${e.func.toUpperCase()}(*)`;const s=resolveColumn(e.column,t);return`${e.func.toUpperCase()}(${n}?${s.name})`}getUriContext(){if(this.tableContext)return{baseUri:this.tableContext.baseUri,tableRegistry:this.tableContext.tableRegistry,tableNameRegistry:this.tableContext.tableNameRegistry}}convertSimpleSelect(e,t,n,s=!0){const a=e.table;a.config.type;const u={queryType:"SELECT",variables:[{termType:"Variable",value:"subject"}],where:this.buildWherePatterns(e,a,t,n,s),type:"query",prefixes:this.prefixes};return n&&n.length>0&&!t&&(u.from={default:n.map(c=>({termType:"NamedNode",value:c})),named:[]}),Object.keys(a.columns).forEach(c=>{const h=a.columns[c],f=getPredicateForColumn(h,a);f&&f!=="@id"&&u.variables.push({termType:"Variable",value:c})}),typeof e.limit=="number"&&(u.limit=e.limit),typeof e.offset=="number"&&(u.offset=e.offset),e.orderBy&&e.orderBy.length>0&&(u.order=e.orderBy.map(c=>({expression:{termType:"Variable",value:c.column},descending:c.direction==="desc"}))),e.distinct&&(u.distinct=!0),{type:"SELECT",query:this.generator.stringify(u),prefixes:this.prefixes}}buildSelectVariables(e,t){const n=e.select,s=Array.isArray(e.groupBy)&&e.groupBy.length>0;let a=!1;if(n&&typeof n=="object"&&Object.keys(n).length>0){const p=Object.values(n);a=p.length>0&&p.every(g=>isAggregateExpression(g))}const c=!a&&(!s||s&&e.groupBy.includes("subject"))?[{termType:"Variable",value:"subject"}]:[],h=new Set(["subject"]);for(const[p,g]of Object.entries(t.columns))getPredicateForColumn(g,t)==="@id"&&h.add(p);if(n&&typeof n=="object"&&Object.keys(n).length>0){const p=Object.entries(n).filter(([g])=>!h.has(g)).map(([g,y])=>this.buildSelectEntry(g,y,t));return c.concat(p)}if(e.columns==="*"||!e.columns){const p=Object.keys(t.columns).filter(g=>!h.has(g)).map(g=>({termType:"Variable",value:g}));return c.concat(p)}const f=e.columns.filter(p=>{const g=typeof p=="string"?p:p.name;return!h.has(g)}).map(p=>({termType:"Variable",value:typeof p=="string"?p:p.name}));return c.concat(f)}buildSelectEntry(e,t,n){if(isAggregateExpression(t))return this.buildAggregateSelectEntry(e,t,n);const a=resolveColumn(t,n).name;return e===a?{termType:"Variable",value:a}:{expression:{termType:"Variable",value:a},variable:{termType:"Variable",value:e}}}buildAggregateSelectEntry(e,t,n){const s=t.func,a=t.column?{termType:"Variable",value:resolveColumn(t.column,n).name}:new sparqlExports.Wildcard;return{expression:{type:"aggregate",aggregation:s,distinct:!!t.distinct,expression:a},variable:{termType:"Variable",value:e}}}buildWherePatterns(e,t,n,s,a=!0){const u=[],c=e.where?this.expressionBuilder.extractSubjectConstraint(e.where,t):null,h=c?c.remainingCondition:e.where;c?.values?.length&&u.push({type:"values",values:c.values.map(w=>({"?subject":{termType:"NamedNode",value:w}}))}),u.push({type:"bgp",triples:[{subject:{termType:"Variable",value:"subject"},predicate:{termType:"NamedNode",value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"},object:{termType:"NamedNode",value:t.config.type}}]});const f=[],p=[],g=new Set;if(h&&typeof h=="object"){const w=R=>{!R||typeof R!="object"||(R.left&&(typeof R.left=="string"?g.add(R.left):R.left.name&&g.add(R.left.name)),R.value&&(typeof R.value=="string"?g.add(R.value):R.value.name?g.add(R.value.name):typeof R.value=="object"&&w(R.value)),R.expressions&&Array.isArray(R.expressions)&&R.expressions.forEach(w))};w(h)}const y=e.select;let S=null;if(y&&typeof y=="object"&&Object.keys(y).length>0){S=new Set;const w=R=>R?typeof R=="string"?R:R.name?R.name:isAggregateExpression(R)&&R.column?w(R.column):null:null;for(const[R,T]of Object.entries(y)){S.add(R);const A=w(T);A&&S.add(A)}if(g.forEach(R=>S.add(R)),Array.isArray(e.orderBy))for(const R of e.orderBy)R.column&&S.add(R.column);if(Array.isArray(e.groupBy))for(const R of e.groupBy){const T=w(R);T&&S.add(T)}}if(Object.entries(t.columns).forEach(([w,R])=>{if(S&&!S.has(w))return;const T=getPredicateForColumn(R,t);if(T==="@id")return;const A={termType:"Variable",value:"subject"},F={termType:"Variable",value:w},x=R.options?.inverse,D={subject:x?F:A,predicate:{termType:"NamedNode",value:T},object:x?A:F};x?p.push(D):R.options?.required||g.has(w)?f.push(D):p.push(D)}),f.length>0&&u.push({type:"bgp",triples:f}),p.forEach(w=>{u.push({type:"optional",patterns:[{type:"bgp",triples:[w]}]})}),h){const w=this.expressionBuilder.buildWhereClause(h,t);if(w)try{const T=`${Object.entries(this.prefixes).map(([x,D])=>`PREFIX ${x}: <${D}>`).join(`
140
+ `)}
141
+ SELECT * WHERE { ${w} }`,F=new sparqlExports.Parser().parse(T);if(F.where){const x=F.where.find(D=>D.type==="filter");x&&u.push(x)}}catch(R){console.warn("Failed to parse filter string into AST:",w,R)}}return n?[{type:"graph",name:{termType:"NamedNode",value:n},patterns:u}]:a&&this.uriResolver.getResourceMode(t)==="document"&&(!s||s.length===0)?[{type:"graph",name:{termType:"Variable",value:"g"},patterns:u}]:u}}const XSD$6="http://www.w3.org/2001/XMLSchema#";class DefaultHandler{constructor(){this.name="default"}canHandle(e){const t=e.dataType;return t==="string"||t==="integer"||t==="boolean"||t==="datetime"}formatValue(e,t,n){switch(t.dataType){case"string":return{termType:"Literal",value:String(e),datatype:{termType:"NamedNode",value:`${XSD$6}string`}};case"integer":return{termType:"Literal",value:String(Number(e)),datatype:{termType:"NamedNode",value:`${XSD$6}integer`}};case"boolean":return{termType:"Literal",value:String(!!e),datatype:{termType:"NamedNode",value:`${XSD$6}boolean`}};case"datetime":return{termType:"Literal",value:(e instanceof Date?e:new Date(e)).toISOString(),datatype:{termType:"NamedNode",value:`${XSD$6}dateTime`}};default:return{termType:"Literal",value:String(e)}}}parseValue(e,t){const n=e.datatype?.value??"";switch(t.dataType){case"integer":return parseInt(e.value,10);case"boolean":return e.value==="true";case"datetime":return new Date(e.value);default:return n.includes("#integer")||n.includes("#int")?parseInt(e.value,10):n.includes("#boolean")?e.value==="true":n.includes("#dateTime")?new Date(e.value):e.value}}buildTriples(e,t,n,s,a,u){const c=this.formatValue(n,s);return{triples:[{subject:{termType:"NamedNode",value:e},predicate:{termType:"NamedNode",value:t},object:c}]}}}class UriHandler{constructor(){this.name="uri"}canHandle(e){return e.dataType==="uri"||e.isLink()}toUriContext(e){if(e)return{baseUri:e.baseUri,tableRegistry:e.tableRegistry,tableNameRegistry:e.tableNameRegistry,record:e.record,currentTable:e.currentTable}}formatValue(e,t,n){const s=String(e),a=this.toUriContext(n);return{termType:"NamedNode",value:(n?.uriResolver??new UriResolverImpl).resolveLink(s,t,a)}}parseValue(e,t){return e.value}buildTriples(e,t,n,s,a,u){const c=this.formatValue(n,s,u);return{triples:[{subject:{termType:"NamedNode",value:e},predicate:{termType:"NamedNode",value:t},object:c}]}}}const XSD$5="http://www.w3.org/2001/XMLSchema#";class ArrayHandler{constructor(){this.name="array"}canHandle(e){return e.options?.isArray===!0||e.dataType==="array"}formatValue(e,t,n){if(!Array.isArray(e))throw new Error("Array column requires array value");const s=t.options?.baseType??"string";return e.map(a=>this.formatSingleValue(a,s))}formatSingleValue(e,t){switch(t){case"string":return{termType:"Literal",value:String(e),datatype:{termType:"NamedNode",value:`${XSD$5}string`}};case"integer":return{termType:"Literal",value:String(Number(e)),datatype:{termType:"NamedNode",value:`${XSD$5}integer`}};case"boolean":return{termType:"Literal",value:String(!!e),datatype:{termType:"NamedNode",value:`${XSD$5}boolean`}};case"datetime":return{termType:"Literal",value:(e instanceof Date?e:new Date(e)).toISOString(),datatype:{termType:"NamedNode",value:`${XSD$5}dateTime`}};case"uri":return{termType:"NamedNode",value:String(e)};default:return{termType:"Literal",value:String(e)}}}parseValue(e,t){const n=t.options?.baseType??"string",s=e.datatype?.value??"";switch(n){case"integer":return parseInt(e.value,10);case"boolean":return e.value==="true";case"datetime":return new Date(e.value);case"uri":return e.value;default:return s.includes("#integer")?parseInt(e.value,10):s.includes("#boolean")?e.value==="true":s.includes("#dateTime")?new Date(e.value):e.value}}buildTriples(e,t,n,s,a,u){let c;return Array.isArray(n)?c=n:typeof n=="string"&&n.includes(",")?c=n.split(",").map(p=>p.trim()).filter(Boolean):c=[n],{triples:this.formatValue(c,s).map(p=>({subject:{termType:"NamedNode",value:e},predicate:{termType:"NamedNode",value:t},object:p}))}}}const XSD$4="http://www.w3.org/2001/XMLSchema#";class InverseHandler{constructor(){this.name="inverse"}canHandle(e){return e.options?.inverse===!0}toUriContext(e){if(e)return{baseUri:e.baseUri,tableRegistry:e.tableRegistry,tableNameRegistry:e.tableNameRegistry,record:e.record,currentTable:e.currentTable}}formatValue(e,t,n){if(t.options?.linkTarget||t.dataType==="uri"||t.isLink?.()){const s=String(e),a=this.toUriContext(n);return{termType:"NamedNode",value:(n?.uriResolver??new UriResolverImpl).resolveLink(s,t,a)}}return this.isUri(e)?{termType:"NamedNode",value:String(e)}:{termType:"Literal",value:String(e),datatype:{termType:"NamedNode",value:`${XSD$4}string`}}}isUri(e){return typeof e!="string"?!1:e.startsWith("http://")||e.startsWith("https://")}parseValue(e,t){return e.value}buildTriples(e,t,n,s,a,u){return{triples:(Array.isArray(n)?n:typeof n=="string"&&n.includes(",")?n.split(",").map(f=>f.trim()).filter(Boolean):[n]).map(f=>({subject:this.formatValue(f,s,u),predicate:{termType:"NamedNode",value:t},object:{termType:"NamedNode",value:e}}))}}}const XSD$3="http://www.w3.org/2001/XMLSchema#";class InlineObjectHandler{constructor(){this.name="inline"}canHandle(e){if(e.dataType==="object"||e.dataType==="json")return!0;if(e.dataType==="array"){const t=e.elementType||e.options?.baseType;return t==="object"||t==="json"}return!1}formatValue(e,t,n){return typeof e=="string"?{termType:"NamedNode",value:e}:{termType:"Literal",value:JSON.stringify(e),datatype:{termType:"NamedNode",value:`${XSD$3}json`}}}parseValue(e,t){if(e.datatype?.value?.includes("#json"))try{return JSON.parse(e.value)}catch{return e.value}return e.termType==="NamedNode",e.value}buildTriples(e,t,n,s,a,u){const c=[],h=[];return(Array.isArray(n)?n:[n]).forEach((p,g)=>{if(!p||typeof p!="object")return;const y=p,S=u.resolveInlineChildUri(e,s.name,y,g);c.push({subject:{termType:"NamedNode",value:e},predicate:{termType:"NamedNode",value:t},object:{termType:"NamedNode",value:S}});const w=this.buildChildTriples(S,y,a,u);h.push(...w)}),{triples:c,childTriples:h}}buildChildTriples(e,t,n,s){const a=[],u=s.getNamespaceUri(n);return Object.entries(t).forEach(([c,h])=>{if(c==="id"||c==="@id"||h==null)return;const f=this.resolvePredicateUri(c,u);(Array.isArray(h)?[h]:[h]).forEach(g=>{const y=this.formatChildValue(g);a.push({subject:{termType:"NamedNode",value:e},predicate:{termType:"NamedNode",value:f},object:y})})}),a}resolvePredicateUri(e,t){return e.startsWith("http://")||e.startsWith("https://")?e:t?`${t}${e}`:`http://example.org/${e}`}formatChildValue(e){if(e==null)return{termType:"Literal",value:""};if(typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://")))return{termType:"NamedNode",value:e};if(typeof e=="number"){const t=Number.isInteger(e)?`${XSD$3}integer`:`${XSD$3}decimal`;return{termType:"Literal",value:String(e),datatype:{termType:"NamedNode",value:t}}}return typeof e=="boolean"?{termType:"Literal",value:String(e),datatype:{termType:"NamedNode",value:`${XSD$3}boolean`}}:e instanceof Date?{termType:"Literal",value:e.toISOString(),datatype:{termType:"NamedNode",value:`${XSD$3}dateTime`}}:typeof e=="object"?{termType:"Literal",value:JSON.stringify(e),datatype:{termType:"NamedNode",value:`${XSD$3}json`}}:{termType:"Literal",value:String(e),datatype:{termType:"NamedNode",value:`${XSD$3}string`}}}}class HandlerRegistry{constructor(){this.handlers=[],this.register(new InlineObjectHandler),this.register(new InverseHandler),this.register(new ArrayHandler),this.register(new UriHandler),this.register(new DefaultHandler)}register(e){this.handlers.push(e)}getHandler(e){for(const t of this.handlers)if(t.canHandle(e))return t;throw new Error(`No handler found for column: ${e.name} (type: ${e.dataType})`)}getAllHandlers(){return[...this.handlers]}}const handlerRegistry=new HandlerRegistry,RDF_TYPE="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",XSD$2="http://www.w3.org/2001/XMLSchema#";class TripleBuilderImpl{constructor(e){this.uriResolver=e??new UriResolverImpl}setTableRegistry(e,t){this.tableRegistry=e,this.tableNameRegistry=t}setBaseUri(e){this.baseUri=e}createContext(e,t){return{resolveInlineChildUri:this.resolveInlineChildUri.bind(this),getNamespaceUri:this.getNamespaceUri.bind(this),uriResolver:this.uriResolver,baseUri:this.baseUri,tableRegistry:this.tableRegistry,tableNameRegistry:this.tableNameRegistry,record:e,currentTable:t}}buildInsert(e,t,n,s){const a=handlerRegistry.getHandler(t),u=this.getPredicateUri(t,s),c=this.createContext(s?.__currentRecord,s);return a.buildTriples(e,u,n,t,s,c)}buildDelete(e,t,n,s=""){const a=this.getPredicateUri(t,n),u=`old_${t.name}${s}`;return t.dataType==="object"||t.dataType==="json"?this.buildInlineDeleteTriples(e,a,t.name,s):t.options?.inverse?{triples:[{subject:{termType:"Variable",value:u},predicate:{termType:"NamedNode",value:a},object:{termType:"NamedNode",value:e}}]}:{triples:[{subject:{termType:"NamedNode",value:e},predicate:{termType:"NamedNode",value:a},object:{termType:"Variable",value:u}}]}}buildInlineDeleteTriples(e,t,n,s){const a=`old_${n}${s}`,u=`op_${n}${s}`,c=`oo_${n}${s}`;return{triples:[{subject:{termType:"NamedNode",value:e},predicate:{termType:"NamedNode",value:t},object:{termType:"Variable",value:a}}],childTriples:[{subject:{termType:"Variable",value:a},predicate:{termType:"Variable",value:u},object:{termType:"Variable",value:c}}]}}buildTypeTriple(e,t){return{subject:{termType:"NamedNode",value:e},predicate:{termType:"NamedNode",value:RDF_TYPE},object:{termType:"NamedNode",value:t}}}toN3Strings(e){return e.map(t=>{const n=this.termToN3(t.subject),s=this.termToN3(t.predicate),a=this.termToN3(t.object);return`${n} ${s} ${a} .`})}termToN3(e){switch(e.termType){case"NamedNode":return`<${e.value}>`;case"Variable":return`?${e.value}`;case"BlankNode":return`_:${e.value}`;case"Literal":{if(e.value.includes(`
142
+ `)||e.value.includes("\r")){let s=e.value;if(s=s.replace(/"""/g,'"\\"\\""'),s.endsWith('"')){const a=s.match(/"*$/),u=a?a[0].length:0;u>0&&(s=s.slice(0,-u)+'\\"'.repeat(u))}if(e.language)return`"""${s}"""@${e.language}`;if(e.datatype){const a=e.datatype.value;return a===`${XSD$2}string`?`"""${s}"""`:a===`${XSD$2}integer`?e.value:`"""${s}"""^^<${a}>`}return`"""${s}"""`}const n=e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"');if(e.language)return`"${n}"@${e.language}`;if(e.datatype){const s=e.datatype.value;return s===`${XSD$2}string`?`"${n}"`:s===`${XSD$2}integer`?e.value:`"${n}"^^<${s}>`}return`"${n}"`}default:return`"${e.value}"`}}buildN3Patch(e,t,n=[]){const s=w=>w.trim().endsWith(".")?w.trim():`${w.trim()} .`,a=e.map(s),u=t.map(s),c=n.map(s),h=a.length>0,f=c.length>0,p=h?` solid:delete {
143
+ ${a.map(w=>` ${w}`).join(`
144
+ `)}
145
+ };
146
+ `:"",g=u.length>0?` solid:insert {
147
+ ${u.map(w=>` ${w}`).join(`
148
+ `)}
149
+ };
150
+ `:"",y=f?` solid:where {
151
+ ${c.map(w=>` ${w}`).join(`
152
+ `)}
153
+ }.
154
+ `:"",S=`@prefix solid: <http://www.w3.org/ns/solid/terms#>.
155
+ _:patch a solid:InsertDeletePatch;
156
+ `;if(!h&&!f){const w=g.endsWith(`;
157
+ `)?g.replace(/;\n$/,`.
158
+ `):g||` solid:insert { }.
159
+ `;return`${S}${w}`}return`${S}${p}${g}${y}`.replace(/;\n$/,`.
160
+ `)}getPredicateUri(e,t){if(e.options?.predicate==="@id")return"@id";if(e.options?.predicate)return e.options.predicate;const n=t.config?.namespace;return n?`${typeof n=="string"?n:n.uri}${e.name}`:`http://example.org/${e.name}`}formatValue(e,t){if(e==null)return'""';if(!t)return this.formatValueByInference(e);const s=handlerRegistry.getHandler(t).formatValue(e,t);return Array.isArray(s)?s.map(a=>this.termToN3(a)):this.termToN3(s)}formatValueByInference(e){return typeof e=="string"?e.startsWith("http://")||e.startsWith("https://")?`<${e}>`:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e=="number"?Number.isInteger(e)?String(e):`"${e}"^^<${XSD$2}decimal>`:typeof e=="boolean"?`"${e}"^^<${XSD$2}boolean>`:e instanceof Date?`"${e.toISOString()}"^^<${XSD$2}dateTime>`:typeof e=="object"?`"${JSON.stringify(e).replace(/"/g,'\\"')}"^^<${XSD$2}json>`:`"${String(e)}"`}resolveInlineChildUri(e,t,n,s){const a=typeof n["@id"]=="string"?n["@id"]:typeof n.id=="string"?n.id:void 0;if(a)return a;const u=e.indexOf("#"),c=u>=0?e.slice(0,u):e;return`${c.endsWith("#")?c:`${c}#`}${t}-${s+1}`}getNamespaceUri(e){const t=e.config?.namespace;if(t)return typeof t=="string"?t:t.uri}}new TripleBuilderImpl(new UriResolverImpl);function getDocumentUriFromSubjectUri(i){const e=i.indexOf("#");return e!==-1?i.substring(0,e):i}class UpdateBuilder{constructor(e,t=new UriResolverImpl){this.toSparqlJsTriple=n=>n,this.generator=new sparqlExports.Generator,this.prefixes=e,this.uriResolver=t,this.tripleBuilder=new TripleBuilderImpl(t)}setTableContext(e){this.tableContext=e,this.tripleBuilder.setTableRegistry(e.tableRegistry,e.tableNameRegistry),e.baseUri&&this.tripleBuilder.setBaseUri(e.baseUri)}getUriContext(e,t){if(!(!this.tableContext&&!e&&!t))return{baseUri:this.tableContext?.baseUri,tableRegistry:this.tableContext?.tableRegistry,tableNameRegistry:this.tableContext?.tableNameRegistry,record:e,currentTable:t}}resolveLinkTerm(e,t,n,s){const a=String(e??"").replace(/^<|>$/g,"");if(this.uriResolver.isAbsoluteUri(a))return a;try{return this.uriResolver.resolveLink(a,t,this.getUriContext(s,n))}catch(u){const c=n.config?.name??"unknown",h=t?.name??"unknown";throw new Error(`[UpdateBuilder] Failed to resolve URI for ${c}.${h}: ${u}`)}}formatValueOrThrow(e,t,n,s){try{return formatValue(e,t,this.uriResolver,this.getUriContext(s,n))}catch(a){const u=n.config?.name??"unknown",c=t?.name??"unknown";throw new Error(`[UpdateBuilder] Failed to resolve URI for ${u}.${c}: ${a}`)}}convertInsert(e,t,n){if(!t&&!e)throw new Error("INSERT operation requires a target table");let s,a;if(Array.isArray(e)){if(s=e,!t)throw new Error("INSERT operation requires a target table");a=t}else s=e.rows,a=e.table;const u=new Set,c=[];for(const g of s)g.id&&(u.has(g.id)?c.push(g.id):u.add(g.id));if(c.length>0)throw new Error(`Duplicate IDs found in insert data: ${c.join(", ")}`);const h=this.buildInsertTriples(s,a),f=[];if(n){const g={type:"bgp",triples:h};f.push({updateType:"insert",insert:[{type:"graph",name:{termType:"NamedNode",value:n},patterns:[g]}]})}else{const g={};for(const y of h)if(y.subject&&y.subject.termType==="NamedNode"){const S=getDocumentUriFromSubjectUri(y.subject.value);g[S]||(g[S]=[]),g[S].push(y)}else g.__default__||(g.__default__=[]),g.__default__.push(y);for(const y in g){const w={type:"bgp",triples:g[y]};y==="__default__"?f.push({updateType:"insert",insert:[w]}):f.push({updateType:"insert",insert:[{type:"graph",name:{termType:"NamedNode",value:y},patterns:[w]}]})}}if(f.length===0)throw new Error("No valid insert statements generated");const p={type:"update",prefixes:this.prefixes,updates:f};return{type:"INSERT",query:this.generator.stringify(p),prefixes:this.prefixes}}buildInsertTriples(e,t){const n=[],s=t.config.type;for(const a of e){const u=generateSubjectUri(a,t,this.uriResolver),c={termType:"NamedNode",value:u};t.__currentRecord=a;try{n.push({subject:c,predicate:{termType:"NamedNode",value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"},object:{termType:"NamedNode",value:s}}),Object.entries(a).forEach(([h,f])=>{if(h==="id"||f===void 0||f===null)return;const p=t.columns[h];if(!p)return;const g=getPredicateForColumn(p,t);if(p.dataType==="object"||p.dataType==="json"||p.dataType==="array"&&(p.elementType==="object"||p.options?.baseType==="object")){const R=this.tripleBuilder.buildInsert(u,p,f,t);n.push(...R.triples.map(this.toSparqlJsTriple),...R.childTriples?.map(this.toSparqlJsTriple)??[]);return}if(p.options?.inverse){(Array.isArray(f)?f:[f]).forEach(T=>{const A=this.resolveLinkTerm(T,p,t,a);n.push({subject:{termType:"NamedNode",value:A},predicate:{termType:"NamedNode",value:g},object:c})});return}const S=this.formatValueOrThrow(f,p,t,a),w=this.parseTermString(S);n.push({subject:c,predicate:{termType:"NamedNode",value:g},object:w})})}finally{delete t.__currentRecord}}return n}convertUpdate(e,t,n,s){const a=this.extractSubjectRecords(t);if(a.length===0)throw new Error("UPDATE operation requires an id or @id condition to target a specific resource");const u=[];for(const h of a){const f=generateSubjectUri(h,n,this.uriResolver),g={termType:"NamedNode",value:s||getDocumentUriFromSubjectUri(f)},{deleteTriples:y,insertTriples:S,whereTriples:w}=this.buildUpdatePartsForRecord(f,e,n),R={type:"bgp",triples:y},T={type:"bgp",triples:w.length>0?w:y};if(y.length>0&&u.push({updateType:"insertdelete",delete:[{type:"graph",name:g,patterns:[R]}],insert:[],where:[{type:"graph",name:g,patterns:[T]}]}),S.length>0){const A={type:"bgp",triples:S};u.push({updateType:"insert",insert:[{type:"graph",name:g,patterns:[A]}]})}}if(u.length===0)throw new Error("No valid update statements generated for provided data");const c={type:"update",prefixes:this.prefixes,updates:u};return{type:"UPDATE",query:this.generator.stringify(c),prefixes:this.prefixes}}convertDelete(e,t,n){const s=[];let a=[],u=[];const c=this.extractSubjectRecords(e);if(c.length===0)if(n){const f={termType:"NamedNode",value:n};a.push({subject:{termType:"Variable",value:"s"},predicate:{termType:"Variable",value:"p"},object:{termType:"Variable",value:"o"}}),u.push({subject:{termType:"Variable",value:"s"},predicate:{termType:"NamedNode",value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"},object:{termType:"NamedNode",value:t.config.type}});const p={updateType:"insertdelete",delete:[{type:"graph",name:f,patterns:[{type:"bgp",triples:a}]}],insert:[],where:[{type:"graph",name:f,patterns:[{type:"bgp",triples:u}]}]};s.push(p)}else throw new Error("DELETE operation in Document Mode requires specific resource IDs or an explicit target graph.");else for(const f of c){const p=generateSubjectUri(f,t,this.uriResolver),y={termType:"NamedNode",value:n||getDocumentUriFromSubjectUri(p)},A={updateType:"insertdelete",delete:[{type:"graph",name:y,patterns:[{type:"bgp",triples:[{subject:{termType:"NamedNode",value:p},predicate:{termType:"Variable",value:"p"},object:{termType:"Variable",value:"o"}}]}]}],insert:[],where:[{type:"graph",name:y,patterns:[{type:"bgp",triples:[{subject:{termType:"NamedNode",value:p},predicate:{termType:"Variable",value:"p"},object:{termType:"Variable",value:"o"}}]}]}]};s.push(A)}if(s.length===0)throw new Error("No valid delete statements generated");const h={type:"update",prefixes:this.prefixes,updates:s};return{type:"DELETE",query:this.generator.stringify(h),prefixes:this.prefixes}}buildUpdatePartsForRecord(e,t,n){const s=[],a=[],u=[];return Object.entries(t).forEach(([c,h],f)=>{const p=n.columns[c];if(!p)return;const g=getPredicateForColumn(p,n),y=`old_${c}_${f}`,S=p.dataType==="object"||p.dataType==="json"||p.dataType==="array"&&(p.elementType==="object"||p.options?.baseType==="object"),w={termType:"NamedNode",value:e},R={termType:"NamedNode",value:g},T={termType:"Variable",value:y};if(S){const A={termType:"Variable",value:`p_${y}`},F={termType:"Variable",value:`o_${y}`},x={subject:w,predicate:R,object:T},D={subject:T,predicate:A,object:F};if(s.push(x,D),u.push(x,D),h!=null){const O=this.tripleBuilder.buildInsert(e,p,h,n);a.push(...O.triples.map(this.toSparqlJsTriple),...O.childTriples?.map(this.toSparqlJsTriple)??[])}return}if(p.options?.inverse){const A={subject:T,predicate:R,object:w};if(s.push(A),u.push(A),h!=null){const F=this.resolveLinkTerm(h,p,n,t);a.push({subject:{termType:"NamedNode",value:F},predicate:R,object:w})}}else{const A={subject:w,predicate:R,object:T};if(s.push(A),u.push(A),h!=null){const F=this.formatValueOrThrow(h,p,n,t),x=this.parseTermString(F);a.push({subject:w,predicate:R,object:x})}}}),{deleteTriples:s,insertTriples:a,whereTriples:u}}parseTermString(e){if(typeof e!="string")return{termType:"Literal",value:String(e)};if(e.startsWith("<"))return{termType:"NamedNode",value:e.slice(1,-1)};if(e.startsWith("_:"))return{termType:"BlankNode",value:e.slice(2)};if(e.startsWith('"')){const t=e.lastIndexOf('"'),n=e.slice(1,t),s=e.slice(t+1);let a,u;if(s.startsWith("^^")){const c=s.slice(2);a={termType:"NamedNode",value:c.startsWith("<")?c.slice(1,-1):c}}else s.startsWith("@")&&(u=s.slice(1));return{termType:"Literal",value:n,datatype:a,language:u}}return{termType:"Literal",value:e}}extractSubjectRecords(e){if(!e)return[];if(this.isQueryCondition(e)){const t=this.findConditionValue(e,"id"),n=this.findConditionValue(e,"@id"),s={};return n&&(s["@id"]=n),t&&(s.id=t),Object.keys(s).length>0?[s]:[]}return typeof e=="object"&&(e.id||e["@id"])?[e]:[]}isQueryCondition(e){return e&&typeof e=="object"&&"type"in e}findConditionValue(e,t){if(e.type==="binary_expr"&&e.operator==="="){const n=e.left,s=e.right;let a;if(typeof n=="string"?a=n.includes(".")?n.split(".")[1]:n:n&&typeof n=="object"&&"name"in n?a=n.name:n&&typeof n=="object"&&"column"in n&&(a=n.column),a===t&&s!=null)return typeof s=="object"&&"value"in s?s.value:s}if(e.type==="logical_expr"){const n=e.expressions||e.conditions||[];for(const s of n){const a=this.findConditionValue(s,t);if(a!==void 0)return a}}}}class ASTToSPARQLConverter{constructor(e,t,n){this.podUrl=e,this.webId=t,this.prefixes={rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",schema:"https://schema.org/",foaf:"http://xmlns.com/foaf/0.1/",dc:"http://purl.org/dc/terms/",solid:"http://www.w3.org/ns/solid/terms#",ldp:"http://www.w3.org/ns/ldp#",xsd:"http://www.w3.org/2001/XMLSchema#"},this.uriResolver=n??new UriResolverImpl(e),this.selectBuilder=new SelectBuilder(this.prefixes,this.uriResolver),this.updateBuilder=new UpdateBuilder(this.prefixes,this.uriResolver),this.expressionBuilder=new ExpressionBuilder(this.uriResolver)}setTableRegistry(e,t,n){this.tableContext={tableRegistry:e,tableNameRegistry:t,baseUri:n},this.selectBuilder.setTableContext(this.tableContext),this.expressionBuilder.setTableContext(this.tableContext),this.updateBuilder.setTableContext(this.tableContext)}convertSelect(e,t,n,s,a=!0){return this.selectBuilder.convertSelect(e,t,n,s,a)}buildWhereClauseForCondition(e,t){return this.expressionBuilder.buildWhereClause(e,t)}convertSelectPlan(e,t,n,s=!0){return this.selectBuilder.convertSelectPlan(e,t,n,s)}convertSimpleSelect(e,t,n,s=!0){return this.selectBuilder.convertSimpleSelect(e,t,n,s)}convertInsert(e,t,n){return this.updateBuilder.convertInsert(e,t,n)}convertUpdate(e,t,n,s){return this.updateBuilder.convertUpdate(e,t,n,s)}convertDelete(e,t,n){return this.updateBuilder.convertDelete(e,t,n)}getPrefixes(){return this.prefixes}addPrefix(e,t){this.prefixes[e]=t}getPredicateForColumnPublic(e,t){return getPredicateForColumn(e,t)}formatLiteralValue(e,t){return formatValue(e,t)}generateSubjectUri(e,t){return generateSubjectUri(e,t,this.uriResolver)}parseDrizzleAST(e,t){return{type:"select",columns:"*",where:this.parseWhereClause(e)}}parseWhereClause(e){return{}}}class TypeIndexDiscovery{constructor(e,t,n){this.manager=e,this.podUrl=t,this.uriResolver=n??new UriResolverImpl(t)}setPodUrl(e){this.podUrl=e}getPodUrl(){return typeof this.manager.getConfig=="function"?this.manager.getConfig().podUrl||this.podUrl:this.podUrl}async register(e,t){if(!e.shouldRegisterTypeIndex?.())return;e.config.name??JSON.stringify(e.config);const s=this.getRdfClass(e),a=e._.config?.isPublic?"public":"private";this.uriResolver.getResourceMode(e);let u=e.getContainerPath()||"/data/";const c=this.getPodUrl();let h=`${c.replace(/\/$/,"")}${u}`;const f=this.resolveTableResource(e);if(f.mode==="ldp"){const g=f.containerUrl,y=c.replace(/\/$/,"");g.startsWith(y)&&(u=g.substring(y.length),h=g.replace(/\/$/,"")+"/")}const p={rdfClass:s,containerPath:u,forClass:e.config.name,instanceContainer:h,visibility:a};try{const g=await this.manager.discoverSpecificType(s);g&&g.instanceContainer!==h&&console.warn(`[TypeIndexDiscovery] ⚠️ TypeIndex has different path for ${e.config.name}:
161
+ - TypeIndex: ${g.instanceContainer}
162
+ - Configured: ${h}
163
+ Updating TypeIndex to use configured path...`),await this.manager.registerType(p)}catch(g){this.handleRegistrationError(g,p,a)}}async discover(e,t){const n=[],s=await this.manager.discoverSpecificTypes([e]);for(const a of s)n.push({container:a.instanceContainer??a.containerPath,shapes:[],source:"typeindex"});return n}async isRegistered(e){return!!await this.manager.discoverSpecificType(e)}getRdfClass(e){return typeof e.config.type=="string"?e.config.type:e.config.type.value||String(e.config.type)}resolveTableResource(e){const t=e.getResourcePath?.()??e.config.base,n=e.getContainerPath()||"/data/";return{mode:"ldp",containerUrl:this.toAbsolute(n),resourceUrl:this.toAbsolute(t??n)}}toAbsolute(e){if(e.startsWith("http"))return e;const t=this.getPodUrl(),n=t.endsWith("/")?t:`${t}/`,s=e.startsWith("/")?e.slice(1):e;return`${n}${s}`}async handleRegistrationError(e,t,n){if((e instanceof Error?e.message:String(e)).includes("TypeIndex not found")){console.warn("[TypeIndexDiscovery] TypeIndex missing. Attempting to create.");try{const a=await this.manager.createTypeIndex(n==="public");await this.manager.registerType(t,a)}catch(a){console.warn("[TypeIndexDiscovery] Unable to create TypeIndex. Continuing without registration.",a)}}else console.warn("[TypeIndexDiscovery] TypeIndex registration failed. Continuing without registration.",e)}}const INTEROP={NS:"http://www.w3.org/ns/solid/interop#",ApplicationRegistration:"http://www.w3.org/ns/solid/interop#ApplicationRegistration",DataRegistration:"http://www.w3.org/ns/solid/interop#DataRegistration",AccessGrant:"http://www.w3.org/ns/solid/interop#AccessGrant",DataGrant:"http://www.w3.org/ns/solid/interop#DataGrant",RegistrySet:"http://www.w3.org/ns/solid/interop#RegistrySet",DataRegistry:"http://www.w3.org/ns/solid/interop#DataRegistry",hasRegistrySet:"http://www.w3.org/ns/solid/interop#hasRegistrySet",hasDataRegistry:"http://www.w3.org/ns/solid/interop#hasDataRegistry",hasDataRegistration:"http://www.w3.org/ns/solid/interop#hasDataRegistration",registeredShapeTree:"http://www.w3.org/ns/solid/interop#registeredShapeTree",registeredBy:"http://www.w3.org/ns/solid/interop#registeredBy",hasAccessGrant:"http://www.w3.org/ns/solid/interop#hasAccessGrant",hasDataGrant:"http://www.w3.org/ns/solid/interop#hasDataGrant",scopeOfGrant:"http://www.w3.org/ns/solid/interop#scopeOfGrant",dataOwner:"http://www.w3.org/ns/solid/interop#dataOwner",registeredShapeTreeProp:"http://www.w3.org/ns/solid/interop#registeredShapeTree"},SHAPETREES={NS:"http://www.w3.org/ns/shapetrees#",ShapeTree:"http://www.w3.org/ns/shapetrees#ShapeTree",expectsType:"http://www.w3.org/ns/shapetrees#expectsType",shape:"http://www.w3.org/ns/shapetrees#shape"},UDFS={NS:"https://vocab.undefineds.co/",subjectTemplate:"https://vocab.undefineds.co/subjectTemplate"},ns={prefix:"interop",uri:INTEROP.NS},registrySetSchema=solidSchema({id:id(),hasDataRegistry:uri("hasDataRegistry").array().predicate(INTEROP.hasDataRegistry),hasAgentRegistry:uri("hasAgentRegistry").array().predicate("http://www.w3.org/ns/solid/interop#hasAgentRegistry")},{type:INTEROP.RegistrySet,namespace:ns}),dataRegistrySchema=solidSchema({id:id(),hasDataRegistration:uri("hasDataRegistration").array().predicate(INTEROP.hasDataRegistration)},{type:INTEROP.DataRegistry,namespace:ns}),dataRegistrationSchema=solidSchema({id:id(),registeredShapeTree:uri("registeredShapeTree").predicate(INTEROP.registeredShapeTree),registeredBy:uri("registeredBy").predicate(INTEROP.registeredBy),registeredAt:string$2("registeredAt").predicate("http://www.w3.org/ns/solid/interop#registeredAt"),subjectTemplate:string$2("subjectTemplate").predicate(UDFS.subjectTemplate)},{type:INTEROP.DataRegistration,namespace:ns}),applicationRegistrationSchema=solidSchema({id:id(),registeredAgent:uri("registeredAgent").predicate("http://www.w3.org/ns/solid/interop#registeredAgent"),hasAccessGrant:uri("hasAccessGrant").predicate(INTEROP.hasAccessGrant)},{type:INTEROP.ApplicationRegistration,namespace:ns}),accessGrantSchema=solidSchema({id:id(),grantedBy:uri("grantedBy").predicate("http://www.w3.org/ns/solid/interop#grantedBy"),grantedAt:string$2("grantedAt").predicate("http://www.w3.org/ns/solid/interop#grantedAt"),grantee:uri("grantee").predicate("http://www.w3.org/ns/solid/interop#grantee"),hasDataGrant:uri("hasDataGrant").array().predicate(INTEROP.hasDataGrant)},{type:INTEROP.AccessGrant,namespace:ns}),dataGrantSchema=solidSchema({id:id(),registeredShapeTree:uri("registeredShapeTree").predicate(INTEROP.registeredShapeTree),hasDataRegistration:uri("hasDataRegistration").predicate(INTEROP.hasDataRegistration),scopeOfGrant:uri("scopeOfGrant").predicate(INTEROP.scopeOfGrant),accessMode:uri("accessMode").array().predicate("http://www.w3.org/ns/solid/interop#accessMode"),dataOwner:uri("dataOwner").predicate(INTEROP.dataOwner)},{type:INTEROP.DataGrant,namespace:ns});var link,hasRequiredLink;function requireLink(){if(hasRequiredLink)return link;hasRequiredLink=1;var i=/^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i,e=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/\s|\uFEFF|\xA0/,n=/\r?\n[\x20\x09]+/g,s=/[;,"]/,a=/[;,"]|\s/,u=/^[!#$%&'*+\-\.^_`|~\da-zA-Z]+$/,c={IDLE:1,URI:2,ATTR:4};function h(w){return w.replace(e,"")}function f(w){return t.test(w)}function p(w,R){for(;f(w[R]);)R++;return R}function g(w){return a.test(w)||!u.test(w)}function y(w,R){return Object.keys(w).length===Object.keys(R).length&&Object.keys(w).every(T=>T in R&&w[T]===R[T])}class S{constructor(R){this.refs=[],R&&this.parse(R)}rel(R){for(var T=[],A=R.toLowerCase(),F=0;F<this.refs.length;F++)typeof this.refs[F].rel=="string"&&this.refs[F].rel.toLowerCase()===A&&T.push(this.refs[F]);return T}get(R,T){R=R.toLowerCase(),T=T.toLowerCase();for(var A=[],F=0;F<this.refs.length;F++)typeof this.refs[F][R]=="string"&&this.refs[F][R].toLowerCase()===T&&A.push(this.refs[F]);return A}set(R){return this.refs.push(R),this}setUnique(R){return this.refs.some(T=>y(T,R))||this.refs.push(R),this}has(R,T){R=R.toLowerCase(),T=T.toLowerCase();for(var A=0;A<this.refs.length;A++)if(typeof this.refs[A][R]=="string"&&this.refs[A][R].toLowerCase()===T)return!0;return!1}parse(R,x){x=x||0,R=x?R.slice(x):R,R=h(R).replace(n,"");for(var A=c.IDLE,F=R.length,x=0,D=null;x<F;)if(A===c.IDLE){if(f(R[x])){x++;continue}else if(R[x]==="<"){D!=null&&(D.rel!=null?this.refs.push(...S.expandRelations(D)):this.refs.push(D));var O=R.indexOf(">",x);if(O===-1)throw new Error("Expected end of URI delimiter at offset "+x);D={uri:R.slice(x+1,O)},x=O,A=c.URI}else throw new Error('Unexpected character "'+R[x]+'" at offset '+x);x++}else if(A===c.URI)if(f(R[x])){x++;continue}else if(R[x]===";")A=c.ATTR,x++;else if(R[x]===",")A=c.IDLE,x++;else throw new Error('Unexpected character "'+R[x]+'" at offset '+x);else if(A===c.ATTR){if(R[x]===";"||f(R[x])){x++;continue}var O=R.indexOf("=",x);O===-1&&(O=R.indexOf(";",x)),O===-1&&(O=R.length);var K=h(R.slice(x,O)).toLowerCase(),z="";if(x=O+1,x=p(R,x),R[x]==='"')for(x++;x<F;){if(R[x]==='"'){x++;break}R[x]==="\\"&&x++,z+=R[x],x++}else{for(var O=x+1;!s.test(R[O])&&O<F;)O++;z=R.slice(x,O),x=O}switch(D[K]&&S.isSingleOccurenceAttr(K)||(K[K.length-1]==="*"?D[K]=S.parseExtendedValue(z):(z=K==="type"?z.toLowerCase():z,D[K]!=null?Array.isArray(D[K])?D[K].push(z):D[K]=[D[K],z]:D[K]=z)),R[x]){case",":A=c.IDLE;break;case";":A=c.ATTR;break}x++}else throw new Error('Unknown parser state "'+A+'"');return D!=null&&(D.rel!=null?this.refs.push(...S.expandRelations(D)):this.refs.push(D)),D=null,this}toString(){for(var R=[],T="",A=null,F=0;F<this.refs.length;F++)A=this.refs[F],T=Object.keys(this.refs[F]).reduce(function(x,D){return D==="uri"?x:x+"; "+S.formatAttribute(D,A[D])},"<"+A.uri+">"),R.push(T);return R.join(", ")}}return S.isCompatibleEncoding=function(w){return i.test(w)},S.parse=function(w,R){return new S().parse(w,R)},S.isSingleOccurenceAttr=function(w){return w==="rel"||w==="type"||w==="media"||w==="title"||w==="title*"},S.isTokenAttr=function(w){return w==="rel"||w==="type"||w==="anchor"},S.escapeQuotes=function(w){return w.replace(/"/g,'\\"')},S.expandRelations=function(w){var R=w.rel.split(" ");return R.map(function(T){var A=Object.assign({},w);return A.rel=T,A})},S.parseExtendedValue=function(w){var R=/([^']+)?(?:'([^']*)')?(.+)/.exec(w);return{language:R[2].toLowerCase(),encoding:S.isCompatibleEncoding(R[1])?null:R[1].toLowerCase(),value:S.isCompatibleEncoding(R[1])?decodeURIComponent(R[3]):R[3]}},S.formatExtendedAttribute=function(w,R){var T=(R.encoding||"utf-8").toUpperCase(),A=R.language||"en",F="";return typeof Buffer<"u"&&Buffer.isBuffer(R.value)&&S.isCompatibleEncoding(T)?F=R.value.toString(T):typeof Buffer<"u"&&Buffer.isBuffer(R.value)?F=R.value.toString("hex").replace(/[0-9a-f]{2}/gi,"%$1"):F=encodeURIComponent(R.value),w+"="+T+"'"+A+"'"+F},S.formatAttribute=function(w,R){return Array.isArray(R)?R.map(T=>S.formatAttribute(w,T)).join("; "):w[w.length-1]==="*"||typeof R!="string"?S.formatExtendedAttribute(w,R):(S.isTokenAttr(w)?R=g(R)?'"'+S.escapeQuotes(R)+'"':S.escapeQuotes(R):g(R)&&(R=encodeURIComponent(R),R=R.replace(/%20/g," ").replace(/%2C/g,",").replace(/%3B/g,";"),R='"'+R+'"'),w+"="+R)},link=S,link}class InruptClientError extends Error{}const PROBLEM_DETAILS_MIME="application/problem+json",DEFAULT_TYPE=new URL("about:blank");function asUrl$1(i,e){if(i!==void 0)try{return new URL(i,e)}catch{}}function buildProblemDetails(i){let e,t,n,s,a;if(i.headers.get("Content-Type")===PROBLEM_DETAILS_MIME)try{const u=JSON.parse(i.body),c=asUrl$1(u.type,i.url);c!==void 0&&(e=c),typeof u.title=="string"&&(t=u.title),typeof u.status=="number"&&(n=u.status),typeof u.detail=="string"&&(s=u.detail);const h=asUrl$1(u.instance,i.url);h!==void 0&&(a=h)}catch{}return Object.freeze({type:e??DEFAULT_TYPE,title:t??i.statusText,status:n??i.status,detail:s,instance:a})}class ClientHttpError extends InruptClientError{constructor(e,t,n,s){if(super(n,s),e.status>=200&&e.status<400)throw new InruptClientError(`A ClientHttpError cannot be built from a success response, got ${e.status} ${e.statusText}`);this.errorResponse=Object.freeze({status:e.status,statusText:e.statusText,headers:e.headers,url:e.url,body:t,ok:!1}),this.details=buildProblemDetails(this.errorResponse)}get response(){return this.errorResponse}get problemDetails(){return this.details}}function hasResourceInfo(i){const e=i;return typeof e=="object"&&typeof e.internal_resourceInfo=="object"}function hasServerResourceInfo(i){const e=i;return typeof e=="object"&&typeof e.internal_resourceInfo=="object"&&typeof e.internal_resourceInfo.linkedResources=="object"}function hasChangelog(i){const e=i;return typeof e.internal_changeLog=="object"&&Array.isArray(e.internal_changeLog.additions)&&Array.isArray(e.internal_changeLog.deletions)}class SolidClientError extends Error{}function internal_toIriString(i){return typeof i=="string"?i:i.value}function normalizeUrl(i,e={}){const t=new URL(i);return t.pathname=t.pathname.replace(/\/\/+/g,"/"),e.trailingSlash===!1&&t.pathname.slice(-1)==="/"&&(t.pathname=t.pathname.slice(0,t.pathname.length-1)),e.trailingSlash===!0&&t.pathname.slice(-1)!=="/"&&(t.pathname=`${t.pathname}/`),t.href}var linkExports=requireLink();const LinkHeader=getDefaultExportFromCjs(linkExports);function internal_parseResourceInfo(i){var e,t,n,s,a;const u=(t=(e=i.headers.get("Content-Type"))===null||e===void 0?void 0:e.split(";"))!==null&&t!==void 0?t:[],c=u.length>0&&["text/turtle","application/ld+json"].includes(u[0]),h={sourceIri:i.url,isRawData:!c,contentLocation:(n=i.headers.get("Content-Location"))!==null&&n!==void 0?n:void 0,contentType:(s=i.headers.get("Content-Type"))!==null&&s!==void 0?s:void 0,linkedResources:{},location:(a=i.headers.get("Location"))!==null&&a!==void 0?a:void 0},f=i.headers.get("Link");if(f){const g=LinkHeader.parse(f),y=g.get("rel","acl");y.length===1&&(h.aclUrl=new URL(y[0].uri,h.sourceIri).href),h.linkedResources=g.refs.reduce((S,w)=>{var R,T;return(R=S[T=w.rel])!==null&&R!==void 0||(S[T]=[]),S[w.rel].push(new URL(w.uri,h.sourceIri).href),S},h.linkedResources)}const p=i.headers.get("WAC-Allow");return p&&(h.permissions=parseWacAllowHeader(p)),h}function parseWacAllowHeader(i){function e(n){const s=n.split(" ");return s.includes("write")?{read:s.includes("read"),append:!0,write:!0,control:s.includes("control")}:{read:s.includes("read"),append:s.includes("append"),write:!1,control:s.includes("control")}}function t(n,s){const a=n.split(",").map(c=>c.split("=")).filter(c=>c.length===2&&c[0].trim()===s);if(a.length!==1)return"";const u=a[0][1].trim();return u.charAt(0)!=='"'||u.charAt(u.length-1)!=='"'?"":u.substring(1,u.length-1)}return{user:e(t(i,"user")),public:e(t(i,"public"))}}function internal_isUnsuccessfulResponse(i){return!i.ok}function internal_isAuthenticationFailureResponse(i){return i.status===401||i.status===403}const ldp={BasicContainer:"http://www.w3.org/ns/ldp#BasicContainer",Resource:"http://www.w3.org/ns/ldp#Resource"};function responseToResourceInfo(i,e={ignoreAuthenticationErrors:!1}){if(internal_isUnsuccessfulResponse(i)&&(!internal_isAuthenticationFailureResponse(i)||!e.ignoreAuthenticationErrors))throw new FetchError(`Fetching the metadata of the Resource at [${i.url}] failed: [${i.status}] [${i.statusText}].`,i);return{internal_resourceInfo:internal_parseResourceInfo(i)}}function getContentType(i){var e;return(e=i.internal_resourceInfo.contentType)!==null&&e!==void 0?e:null}function getSourceUrl(i){return hasResourceInfo(i)?i.internal_resourceInfo.sourceIri:null}class FetchError extends SolidClientError{constructor(e,t,n){super(e),this.response=t,typeof n=="string"?this.httpError=new ClientHttpError(t,n,e):this.httpError=new ClientHttpError(t,"",e)}get statusCode(){return this.response.status}get statusText(){return this.response.statusText}get problemDetails(){return this.httpError.problemDetails}}const RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#",XSD$1="http://www.w3.org/2001/XMLSchema#",SWAP="http://www.w3.org/2000/10/swap/",namespaces={xsd:{decimal:`${XSD$1}decimal`,boolean:`${XSD$1}boolean`,double:`${XSD$1}double`,integer:`${XSD$1}integer`,string:`${XSD$1}string`},rdf:{type:`${RDF}type`,nil:`${RDF}nil`,first:`${RDF}first`,rest:`${RDF}rest`,langString:`${RDF}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${SWAP}reify#forSome`,forAll:`${SWAP}reify#forAll`},log:{implies:`${SWAP}log#implies`,isImpliedBy:`${SWAP}log#isImpliedBy`}},{xsd:xsd$2}=namespaces,escapeSequence=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,escapeReplacements={"\\":"\\","'":"'",'"':'"',n:`
164
+ `,r:"\r",t:" ",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},illegalIriChars=/[\x00-\x20<>\\"\{\}\|\^\`]/,lineModeRegExps={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},invalidRegExp=/$0^/;class N3Lexer{constructor(e){if(this._iri=/^<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/,this._unescapedIri=/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/,this._simpleQuotedString=/^"([^"\\\r\n]*)"(?=[^"])/,this._simpleApostropheString=/^'([^'\\\r\n]*)'(?=[^'])/,this._langcode=/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,this._prefix=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,this._prefixed=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<>]))/,this._variable=/^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<>])/,this._blank=/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<>]))/,this._number=/^[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?|\d*(\.)?)\d+(?=\.?[,;:\s#()\[\]\{\}"'<>])/,this._boolean=/^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<>])/,this._keyword=/^@[a-z]+(?=[\s#<:])/i,this._sparqlKeyword=/^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i,this._shortPredicates=/^a(?=[\s#()\[\]\{\}"'<>])/,this._newline=/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,this._comment=/#([^\n\r]*)/,this._whitespace=/^[ \t]+/,this._endOfFile=/^(?:#[^\n\r]*)?$/,e=e||{},this._isImpliedBy=e.isImpliedBy,this._lineMode=!!e.lineMode){this._n3Mode=!1;for(const t in this)!(t in lineModeRegExps)&&this[t]instanceof RegExp&&(this[t]=invalidRegExp)}else this._n3Mode=e.n3!==!1;this.comments=!!e.comments,this._literalClosingPos=0}_tokenizeToEnd(e,t){let n=this._input,s=n.length;for(;;){let c,h;for(;c=this._newline.exec(n);)this.comments&&(h=this._comment.exec(c[0]))&&a("comment",h[1],"",this._line,c[0].length),n=n.substr(c[0].length,n.length),s=n.length,this._line++;if(!c&&(c=this._whitespace.exec(n))&&(n=n.substr(c[0].length,n.length)),this._endOfFile.test(n))return t&&(this.comments&&(h=this._comment.exec(n))&&a("comment",h[1],"",this._line,n.length),n=null,a("eof","","",this._line,0)),this._input=n;const f=this._line,p=n[0];let g="",y="",S="",w=null,R=0,T=!1;switch(p){case"^":if(n.length<3)break;if(n[1]==="^"){if(this._previousMarker="^^",n=n.substr(2),n[0]!=="<"){T=!0;break}}else{this._n3Mode&&(R=1,g="^");break}case"<":if(w=this._unescapedIri.exec(n))g="IRI",y=w[1];else if(w=this._iri.exec(n)){if(y=this._unescape(w[1]),y===null||illegalIriChars.test(y))return u(this);g="IRI"}else n.length>1&&n[1]==="<"?(g="<<",R=2):this._n3Mode&&n.length>1&&n[1]==="="&&(R=2,this._isImpliedBy?(g="abbreviation",y="<"):(g="inverse",y=">"));break;case">":n.length>1&&n[1]===">"&&(g=">>",R=2);break;case"_":((w=this._blank.exec(n))||t&&(w=this._blank.exec(`${n} `)))&&(g="blank",S="_",y=w[1]);break;case'"':if(w=this._simpleQuotedString.exec(n))y=w[1];else if({value:y,matchLength:R}=this._parseLiteral(n),y===null)return u(this);(w!==null||R!==0)&&(g="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(w=this._simpleApostropheString.exec(n))y=w[1];else if({value:y,matchLength:R}=this._parseLiteral(n),y===null)return u(this);(w!==null||R!==0)&&(g="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(w=this._variable.exec(n))&&(g="var",y=w[0]);break;case"@":this._previousMarker==="literal"&&(w=this._langcode.exec(n))?(g="langcode",y=w[1]):(w=this._keyword.exec(n))&&(g=w[0]);break;case".":if(n.length===1?t:n[1]<"0"||n[1]>"9"){g=".",R=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(w=this._number.exec(n)||t&&(w=this._number.exec(`${n} `)))&&(g="literal",y=w[0],S=typeof w[1]=="string"?xsd$2.double:typeof w[2]=="string"?xsd$2.decimal:xsd$2.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(w=this._sparqlKeyword.exec(n))?g=w[0].toUpperCase():T=!0;break;case"f":case"t":(w=this._boolean.exec(n))?(g="literal",y=w[0],S=xsd$2.boolean):T=!0;break;case"a":(w=this._shortPredicates.exec(n))?(g="abbreviation",y="a"):T=!0;break;case"=":this._n3Mode&&n.length>1&&(g="abbreviation",n[1]!==">"?(R=1,y="="):(R=2,y=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(R=1,g=p);break;case"{":!this._lineMode&&n.length>=2&&(n[1]==="|"?(g="{|",R=2):(g=p,R=1));break;case"|":n.length>=2&&n[1]==="}"&&(g="|}",R=2);break;default:T=!0}if(T&&((this._previousMarker==="@prefix"||this._previousMarker==="PREFIX")&&(w=this._prefix.exec(n))?(g="prefix",y=w[1]||""):((w=this._prefixed.exec(n))||t&&(w=this._prefixed.exec(`${n} `)))&&(g="prefixed",S=w[1]||"",y=this._unescape(w[2]))),this._previousMarker==="^^")switch(g){case"prefixed":g="type";break;case"IRI":g="typeIRI";break;default:g=""}if(!g)return t||!/^'''|^"""/.test(n)&&/\n|\r/.test(n)?u(this):this._input=n;const A=R||w[0].length,F=a(g,y,S,f,A);this.previousToken=F,this._previousMarker=g,n=n.substr(A,n.length)}function a(c,h,f,p,g){const y=n?s-n.length:s,S=y+g,w={type:c,value:h,prefix:f,line:p,start:y,end:S};return e(null,w),w}function u(c){e(c._syntaxError(/^\S*/.exec(n)[0]))}}_unescape(e){let t=!1;const n=e.replace(escapeSequence,(s,a,u,c)=>{if(typeof a=="string")return String.fromCharCode(Number.parseInt(a,16));if(typeof u=="string"){let h=Number.parseInt(u,16);return h<=65535?String.fromCharCode(Number.parseInt(u,16)):String.fromCharCode(55296+((h-=65536)>>10),56320+(h&1023))}return c in escapeReplacements?escapeReplacements[c]:(t=!0,"")});return t?null:n}_parseLiteral(e){if(e.length>=3){const t=e.match(/^(?:"""|"|'''|'|)/)[0],n=t.length;let s=Math.max(this._literalClosingPos,n);for(;(s=e.indexOf(t,s))>0;){let a=0;for(;e[s-a-1]==="\\";)a++;if(a%2===0){const u=e.substring(n,s),c=u.split(/\r\n|\r|\n/).length-1,h=s+n;if(n===1&&c!==0||n===3&&this._lineMode)break;return this._line+=c,{value:this._unescape(u),matchLength:h}}s++}this._literalClosingPos=e.length-n+1}return{value:"",matchLength:0}}_syntaxError(e){this._input=null;const t=new Error(`Unexpected "${e}" on line ${this._line}.`);return t.context={token:void 0,line:this._line,previousToken:this.previousToken},t}_readStartingBom(e){return e.startsWith("\uFEFF")?e.substr(1):e}tokenize(e,t){if(this._line=1,typeof e=="string")if(this._input=this._readStartingBom(e),typeof t=="function")queueMicrotask(()=>this._tokenizeToEnd(t,!0));else{const n=[];let s;if(this._tokenizeToEnd((a,u)=>a?s=a:n.push(u),!0),s)throw s;return n}else this._pendingBuffer=null,typeof e.setEncoding=="function"&&e.setEncoding("utf8"),e.on("data",n=>{this._input!==null&&n.length!==0&&(this._pendingBuffer&&(n=bufferExports.Buffer.concat([this._pendingBuffer,n]),this._pendingBuffer=null),n[n.length-1]&128?this._pendingBuffer=n:(typeof this._input>"u"?this._input=this._readStartingBom(typeof n=="string"?n:n.toString()):this._input+=n,this._tokenizeToEnd(t,!1)))}),e.on("end",()=>{typeof this._input=="string"&&this._tokenizeToEnd(t,!0)}),e.on("error",t)}}const{rdf:rdf$1,xsd:xsd$1}=namespaces;let DEFAULTGRAPH$1,_blankNodeCounter=0;const DataFactory={namedNode,blankNode,variable,literal,defaultGraph,quad,triple:quad,fromTerm,fromQuad};class Term{constructor(e){this.id=e}get value(){return this.id}equals(e){return e instanceof Term?this.id===e.id:!!e&&this.termType===e.termType&&this.value===e.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}}class NamedNode extends Term{get termType(){return"NamedNode"}}class Literal extends Term{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){const e=this.id;let t=e.lastIndexOf('"')+1;return t<e.length&&e[t++]==="@"?e.substr(t).toLowerCase():""}get datatype(){return new NamedNode(this.datatypeString)}get datatypeString(){const e=this.id,t=e.lastIndexOf('"')+1,n=t<e.length?e[t]:"";return n==="^"?e.substr(t+2):n!=="@"?xsd$1.string:rdf$1.langString}equals(e){return e instanceof Literal?this.id===e.id:!!e&&!!e.datatype&&this.termType===e.termType&&this.value===e.value&&this.language===e.language&&this.datatype.value===e.datatype.value}toJSON(){return{termType:this.termType,value:this.value,language:this.language,datatype:{termType:"NamedNode",value:this.datatypeString}}}}class BlankNode extends Term{constructor(e){super(`_:${e}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}}class Variable extends Term{constructor(e){super(`?${e}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}}class DefaultGraph extends Term{constructor(){return super(""),DEFAULTGRAPH$1||this}get termType(){return"DefaultGraph"}equals(e){return this===e||!!e&&this.termType===e.termType}}DEFAULTGRAPH$1=new DefaultGraph;function termFromId(i,e,t){if(e=e||DataFactory,!i)return e.defaultGraph();switch(i[0]){case"?":return e.variable(i.substr(1));case"_":return e.blankNode(i.substr(2));case'"':if(e===DataFactory)return new Literal(i);if(i[i.length-1]==='"')return e.literal(i.substr(1,i.length-2));const n=i.lastIndexOf('"',i.length-1);return e.literal(i.substr(1,n-1),i[n+1]==="@"?i.substr(n+2):e.namedNode(i.substr(n+3)));case"[":i=JSON.parse(i);break;default:if(!t||!Array.isArray(i))return e.namedNode(i)}return e.quad(termFromId(i[0],e,!0),termFromId(i[1],e,!0),termFromId(i[2],e,!0),i[3]&&termFromId(i[3],e,!0))}function termToId(i,e){if(typeof i=="string")return i;if(i instanceof Term&&i.termType!=="Quad")return i.id;if(!i)return DEFAULTGRAPH$1.id;switch(i.termType){case"NamedNode":return i.value;case"BlankNode":return`_:${i.value}`;case"Variable":return`?${i.value}`;case"DefaultGraph":return"";case"Literal":return`"${i.value}"${i.language?`@${i.language}`:i.datatype&&i.datatype.value!==xsd$1.string?`^^${i.datatype.value}`:""}`;case"Quad":const t=[termToId(i.subject,!0),termToId(i.predicate,!0),termToId(i.object,!0)];return i.graph&&i.graph.termType!=="DefaultGraph"&&t.push(termToId(i.graph,!0)),e?t:JSON.stringify(t);default:throw new Error(`Unexpected termType: ${i.termType}`)}}class Quad extends Term{constructor(e,t,n,s){super(""),this._subject=e,this._predicate=t,this._object=n,this._graph=s||DEFAULTGRAPH$1}get termType(){return"Quad"}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}get graph(){return this._graph}toJSON(){return{termType:this.termType,subject:this._subject.toJSON(),predicate:this._predicate.toJSON(),object:this._object.toJSON(),graph:this._graph.toJSON()}}equals(e){return!!e&&this._subject.equals(e.subject)&&this._predicate.equals(e.predicate)&&this._object.equals(e.object)&&this._graph.equals(e.graph)}}function namedNode(i){return new NamedNode(i)}function blankNode(i){return new BlankNode(i||`n3-${_blankNodeCounter++}`)}function literal(i,e){if(typeof e=="string")return new Literal(`"${i}"@${e.toLowerCase()}`);let t=e?e.value:"";return t===""&&(typeof i=="boolean"?t=xsd$1.boolean:typeof i=="number"&&(Number.isFinite(i)?t=Number.isInteger(i)?xsd$1.integer:xsd$1.double:(t=xsd$1.double,Number.isNaN(i)||(i=i>0?"INF":"-INF")))),t===""||t===xsd$1.string?new Literal(`"${i}"`):new Literal(`"${i}"^^${t}`)}function variable(i){return new Variable(i)}function defaultGraph(){return DEFAULTGRAPH$1}function quad(i,e,t,n){return new Quad(i,e,t,n)}function fromTerm(i){if(i instanceof Term)return i;switch(i.termType){case"NamedNode":return namedNode(i.value);case"BlankNode":return blankNode(i.value);case"Variable":return variable(i.value);case"DefaultGraph":return DEFAULTGRAPH$1;case"Literal":return literal(i.value,i.language||i.datatype);case"Quad":return fromQuad(i);default:throw new Error(`Unexpected termType: ${i.termType}`)}}function fromQuad(i){if(i instanceof Quad)return i;if(i.termType!=="Quad")throw new Error(`Unexpected termType: ${i.termType}`);return quad(fromTerm(i.subject),fromTerm(i.predicate),fromTerm(i.object),fromTerm(i.graph))}let blankNodePrefix=0;class N3Parser{constructor(e){this._contextStack=[],this._graph=null,e=e||{},this._setBase(e.baseIRI),e.factory&&initDataFactory(this,e.factory);const t=typeof e.format=="string"?e.format.match(/\w*$/)[0].toLowerCase():"",n=/turtle/.test(t),s=/trig/.test(t),a=/triple/.test(t),u=/quad/.test(t),c=this._n3Mode=/n3/.test(t),h=a||u;(this._supportsNamedGraphs=!(n||c))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(n||s||a||c),this._isImpliedBy=e.isImpliedBy,this._supportsRDFStar=t===""||/star|\*$/.test(t),h&&(this._resolveRelativeIRI=f=>null),this._blankNodePrefix=typeof e.blankNodePrefix!="string"?"":e.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=e.lexer||new N3Lexer({lineMode:h,n3:c,isImpliedBy:this._isImpliedBy}),this._explicitQuantifiers=!!e.explicitQuantifiers}static _resetBlankNodePrefix(){blankNodePrefix=0}_setBase(e){if(!e)this._base="",this._basePath="";else{const t=e.indexOf("#");t>=0&&(e=e.substr(0,t)),this._base=e,this._basePath=e.indexOf("/")<0?e:e.replace(/[^\/?]*(?:\?.*)?$/,""),e=e.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i),this._baseRoot=e[0],this._baseScheme=e[1]}}_saveContext(e,t,n,s,a){const u=this._n3Mode;this._contextStack.push({type:e,subject:n,predicate:s,object:a,graph:t,inverse:u?this._inversePredicate:!1,blankPrefix:u?this._prefixes._:"",quantified:u?this._quantified:null}),u&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(e,t){const n=this._contextStack.pop();if(!n||n.type!==e)return this._error(`Unexpected ${t.type}`,t);this._subject=n.subject,this._predicate=n.predicate,this._object=n.object,this._graph=n.graph,this._n3Mode&&(this._inversePredicate=n.inverse,this._prefixes._=n.blankPrefix,this._quantified=n.quantified)}_readInTopContext(e){switch(e.type){case"eof":return this._graph!==null?this._error("Unclosed graph",e):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"PREFIX":this._sparqlStyle=!0;case"@prefix":return this._readPrefix;case"BASE":this._sparqlStyle=!0;case"@base":return this._readBaseIRI;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(e)}}_readEntity(e,t){let n;switch(e.type){case"IRI":case"typeIRI":const s=this._resolveIRI(e.value);if(s===null)return this._error("Invalid IRI",e);n=this._factory.namedNode(s);break;case"type":case"prefixed":const a=this._prefixes[e.prefix];if(a===void 0)return this._error(`Undefined prefix "${e.prefix}:"`,e);n=this._factory.namedNode(a+e.value);break;case"blank":n=this._factory.blankNode(this._prefixes[e.prefix]+e.value);break;case"var":n=this._factory.variable(e.value.substr(1));break;default:return this._error(`Expected entity but got ${e.type}`,e)}return!t&&this._n3Mode&&n.id in this._quantified&&(n=this._quantified[n.id]),n}_readSubject(e){switch(this._predicate=null,e.type){case"[":return this._saveContext("blank",this._graph,this._subject=this._factory.blankNode(),null,null),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this.RDF_NIL,null,null),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._graph=this._factory.blankNode(),null,null),this._readSubject):this._error("Unexpected graph",e);case"}":return this._readPunctuation(e);case"@forSome":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORSOME,this._quantifier="blankNode",this._readQuantifierList):this._error('Unexpected "@forSome"',e);case"@forAll":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORALL,this._quantifier="variable",this._readQuantifierList):this._error('Unexpected "@forAll"',e);case"literal":if(!this._n3Mode)return this._error("Unexpected literal",e);if(e.prefix.length===0)return this._literalValue=e.value,this._completeSubjectLiteral;this._subject=this._factory.literal(e.value,this._factory.namedNode(e.prefix));break;case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,null,null,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",e);default:if((this._subject=this._readEntity(e))===void 0)return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph}_readPredicate(e){const t=e.type;switch(t){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=this.ABBREVIATIONS[e.value];break;case".":case"]":case"}":return this._predicate===null?this._error(`Unexpected ${t}`,e):(this._subject=null,t==="]"?this._readBlankNodeTail(e):this._readPunctuation(e));case";":return this._predicate!==null?this._readPredicate:this._error("Expected predicate but got ;",e);case"[":if(this._n3Mode)return this._saveContext("blank",this._graph,this._subject,this._subject=this._factory.blankNode(),null),this._readBlankNodeHead;case"blank":if(!this._n3Mode)return this._error("Disallowed blank node as predicate",e);default:if((this._predicate=this._readEntity(e))===void 0)return}return this._readObject}_readObject(e){switch(e.type){case"literal":if(e.prefix.length===0)return this._literalValue=e.value,this._readDataTypeOrLang;this._object=this._factory.literal(e.value,this._factory.namedNode(e.prefix));break;case"[":return this._saveContext("blank",this._graph,this._subject,this._predicate,this._subject=this._factory.blankNode()),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this._subject,this._predicate,this.RDF_NIL),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",e);case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,this._subject,this._predicate,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",e);default:if((this._object=this._readEntity(e))===void 0)return;if(this._n3Mode)return this._getPathReader(this._getContextEndReader())}return this._getContextEndReader()}_readPredicateOrNamedGraph(e){return e.type==="{"?this._readGraph(e):this._readPredicate(e)}_readGraph(e){return e.type!=="{"?this._error(`Expected graph but got ${e.type}`,e):(this._graph=this._subject,this._subject=null,this._readSubject)}_readBlankNodeHead(e){return e.type==="]"?(this._subject=null,this._readBlankNodeTail(e)):(this._predicate=null,this._readPredicate(e))}_readBlankNodeTail(e){if(e.type!=="]")return this._readBlankNodePunctuation(e);this._subject!==null&&this._emit(this._subject,this._predicate,this._object,this._graph);const t=this._predicate===null;return this._restoreContext("blank",e),this._object!==null?this._getContextEndReader():this._predicate!==null?this._readObject:t?this._readPredicateOrNamedGraph:this._readPredicateAfterBlank}_readPredicateAfterBlank(e){switch(e.type){case".":case"}":return this._subject=null,this._readPunctuation(e);default:return this._readPredicate(e)}}_readListItem(e){let t=null,n=null,s=this._readListItem;const a=this._subject,u=this._contextStack,c=u[u.length-1];switch(e.type){case"[":this._saveContext("blank",this._graph,n=this._factory.blankNode(),this.RDF_FIRST,this._subject=t=this._factory.blankNode()),s=this._readBlankNodeHead;break;case"(":this._saveContext("list",this._graph,n=this._factory.blankNode(),this.RDF_FIRST,this.RDF_NIL),this._subject=null;break;case")":if(this._restoreContext("list",e),u.length!==0&&u[u.length-1].type==="list"&&this._emit(this._subject,this._predicate,this._object,this._graph),this._predicate===null){if(s=this._readPredicate,this._subject===this.RDF_NIL)return s}else if(s=this._getContextEndReader(),this._object===this.RDF_NIL)return s;n=this.RDF_NIL;break;case"literal":e.prefix.length===0?(this._literalValue=e.value,s=this._readListItemDataTypeOrLang):(t=this._factory.literal(e.value,this._factory.namedNode(e.prefix)),s=this._getContextEndReader());break;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",e);default:if((t=this._readEntity(e))===void 0)return}if(n===null&&(this._subject=n=this._factory.blankNode()),a===null?c.predicate===null?c.subject=n:c.object=n:this._emit(a,this.RDF_REST,n,this._graph),t!==null){if(this._n3Mode&&(e.type==="IRI"||e.type==="prefixed"))return this._saveContext("item",this._graph,n,this.RDF_FIRST,t),this._subject=t,this._predicate=null,this._getPathReader(this._readListItem);this._emit(n,this.RDF_FIRST,t,this._graph)}return s}_readDataTypeOrLang(e){return this._completeObjectLiteral(e,!1)}_readListItemDataTypeOrLang(e){return this._completeObjectLiteral(e,!0)}_completeLiteral(e){let t=this._factory.literal(this._literalValue);switch(e.type){case"type":case"typeIRI":const n=this._readEntity(e);if(n===void 0)return;t=this._factory.literal(this._literalValue,n),e=null;break;case"langcode":t=this._factory.literal(this._literalValue,e.value),e=null;break}return{token:e,literal:t}}_completeSubjectLiteral(e){return this._subject=this._completeLiteral(e).literal,this._readPredicateOrNamedGraph}_completeObjectLiteral(e,t){const n=this._completeLiteral(e);if(n)return this._object=n.literal,t&&this._emit(this._subject,this.RDF_FIRST,this._object,this._graph),n.token===null?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(n.token))}_readFormulaTail(e){return e.type!=="}"?this._readPunctuation(e):(this._subject!==null&&this._emit(this._subject,this._predicate,this._object,this._graph),this._restoreContext("formula",e),this._object===null?this._readPredicate:this._getContextEndReader())}_readPunctuation(e){let t,n=this._graph;const s=this._subject,a=this._inversePredicate;switch(e.type){case"}":if(this._graph===null)return this._error("Unexpected graph closing",e);if(this._n3Mode)return this._readFormulaTail(e);this._graph=null;case".":this._subject=null,t=this._contextStack.length?this._readSubject:this._readInTopContext,a&&(this._inversePredicate=!1);break;case";":t=this._readPredicate;break;case",":t=this._readObject;break;case"{|":if(!this._supportsRDFStar)return this._error("Unexpected RDF-star syntax",e);const u=this._predicate,c=this._object;this._subject=this._factory.quad(s,u,c,this.DEFAULTGRAPH),t=this._readPredicate;break;case"|}":if(this._subject.termType!=="Quad")return this._error("Unexpected asserted triple closing",e);this._subject=null,t=this._readPunctuation;break;default:if(this._supportsQuads&&this._graph===null&&(n=this._readEntity(e))!==void 0){t=this._readQuadPunctuation;break}return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}if(s!==null){const u=this._predicate,c=this._object;a?this._emit(c,u,s,n):this._emit(s,u,c,n)}return t}_readBlankNodePunctuation(e){let t;switch(e.type){case";":t=this._readPredicate;break;case",":t=this._readObject;break;default:return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}return this._emit(this._subject,this._predicate,this._object,this._graph),t}_readQuadPunctuation(e){return e.type!=="."?this._error("Expected dot to follow quad",e):this._readInTopContext}_readPrefix(e){return e.type!=="prefix"?this._error("Expected prefix to follow @prefix",e):(this._prefix=e.value,this._readPrefixIRI)}_readPrefixIRI(e){if(e.type!=="IRI")return this._error(`Expected IRI to follow prefix "${this._prefix}:"`,e);const t=this._readEntity(e);return this._prefixes[this._prefix]=t.value,this._prefixCallback(this._prefix,t),this._readDeclarationPunctuation}_readBaseIRI(e){const t=e.type==="IRI"&&this._resolveIRI(e.value);return t?(this._setBase(t),this._readDeclarationPunctuation):this._error("Expected valid IRI to follow base declaration",e)}_readNamedGraphLabel(e){switch(e.type){case"IRI":case"blank":case"prefixed":return this._readSubject(e),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",e)}}_readNamedGraphBlankLabel(e){return e.type!=="]"?this._error("Invalid graph label",e):(this._subject=this._factory.blankNode(),this._readGraph)}_readDeclarationPunctuation(e){return this._sparqlStyle?(this._sparqlStyle=!1,this._readInTopContext(e)):e.type!=="."?this._error("Expected declaration to end with a dot",e):this._readInTopContext}_readQuantifierList(e){let t;switch(e.type){case"IRI":case"prefixed":if((t=this._readEntity(e,!0))!==void 0)break;default:return this._error(`Unexpected ${e.type}`,e)}return this._explicitQuantifiers?(this._subject===null?this._emit(this._graph||this.DEFAULTGRAPH,this._predicate,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH):this._emit(this._subject,this.RDF_REST,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH),this._emit(this._subject,this.RDF_FIRST,t,this.QUANTIFIERS_GRAPH)):this._quantified[t.id]=this._factory[this._quantifier](this._factory.blankNode().value),this._readQuantifierPunctuation}_readQuantifierPunctuation(e){return e.type===","?this._readQuantifierList:(this._explicitQuantifiers&&(this._emit(this._subject,this.RDF_REST,this.RDF_NIL,this.QUANTIFIERS_GRAPH),this._subject=null),this._readCallback=this._getContextEndReader(),this._readCallback(e))}_getPathReader(e){return this._afterPath=e,this._readPath}_readPath(e){switch(e.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:const t=this._contextStack,n=t.length&&t[t.length-1];if(n&&n.type==="item"){const s=this._subject;this._restoreContext("item",e),this._emit(this._subject,this.RDF_FIRST,s,this._graph)}return this._afterPath(e)}}_readForwardPath(e){let t,n;const s=this._factory.blankNode();if((n=this._readEntity(e))!==void 0)return this._predicate===null?(t=this._subject,this._subject=s):(t=this._object,this._object=s),this._emit(t,n,s,this._graph),this._readPath}_readBackwardPath(e){const t=this._factory.blankNode();let n,s;if((n=this._readEntity(e))!==void 0)return this._predicate===null?(s=this._subject,this._subject=t):(s=this._object,this._object=t),this._emit(t,n,s,this._graph),this._readPath}_readRDFStarTailOrGraph(e){return e.type!==">>"?this._supportsQuads&&this._graph===null&&(this._graph=this._readEntity(e))!==void 0?this._readRDFStarTail:this._error(`Expected >> to follow "${this._object.id}"`,e):this._readRDFStarTail(e)}_readRDFStarTail(e){if(e.type!==">>")return this._error(`Expected >> but got ${e.type}`,e);const t=this._factory.quad(this._subject,this._predicate,this._object,this._graph||this.DEFAULTGRAPH);return this._restoreContext("<<",e),this._subject===null?(this._subject=t,this._readPredicate):(this._object=t,this._getContextEndReader())}_getContextEndReader(){const e=this._contextStack;if(!e.length)return this._readPunctuation;switch(e[e.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail;case"<<":return this._readRDFStarTailOrGraph}}_emit(e,t,n,s){this._callback(null,this._factory.quad(e,t,n,s||this.DEFAULTGRAPH))}_error(e,t){const n=new Error(`${e} on line ${t.line}.`);n.context={token:t,line:t.line,previousToken:this._lexer.previousToken},this._callback(n),this._callback=noop}_resolveIRI(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)?e:this._resolveRelativeIRI(e)}_resolveRelativeIRI(e){if(!e.length)return this._base;switch(e[0]){case"#":return this._base+e;case"?":return this._base.replace(/(?:\?.*)?$/,e);case"/":return(e[1]==="/"?this._baseScheme:this._baseRoot)+this._removeDotSegments(e);default:return/^[^/:]*:/.test(e)?null:this._removeDotSegments(this._basePath+e)}}_removeDotSegments(e){if(!/(^|\/)\.\.?($|[/#?])/.test(e))return e;const t=e.length;let n="",s=-1,a=-1,u=0,c="/";for(;s<t;){switch(c){case":":if(a<0&&e[++s]==="/"&&e[++s]==="/")for(;(a=s+1)<t&&e[a]!=="/";)s=a;break;case"?":case"#":s=t;break;case"/":if(e[s+1]===".")switch(c=e[++s+1],c){case"/":n+=e.substring(u,s-1),u=s+1;break;case void 0:case"?":case"#":return n+e.substring(u,s)+e.substr(s+1);case".":if(c=e[++s+1],c===void 0||c==="/"||c==="?"||c==="#"){if(n+=e.substring(u,s-2),(u=n.lastIndexOf("/"))>=a&&(n=n.substr(0,u)),c!=="/")return`${n}/${e.substr(s+1)}`;u=s+1}}}c=e[++s]}return n+e.substring(u)}parse(e,t,n){let s,a,u;if(t&&(t.onQuad||t.onPrefix||t.onComment)?(s=t.onQuad,a=t.onPrefix,u=t.onComment):(s=t,a=n),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${blankNodePrefix++}_`,this._prefixCallback=a||noop,this._inversePredicate=!1,this._quantified=Object.create(null),!s){const h=[];let f;if(this._callback=(p,g)=>{p?f=p:g&&h.push(g)},this._lexer.tokenize(e).every(p=>this._readCallback=this._readCallback(p)),f)throw f;return h}let c=(h,f)=>{h!==null?(this._callback(h),this._callback=noop):this._readCallback&&(this._readCallback=this._readCallback(f))};u&&(this._lexer.comments=!0,c=(h,f)=>{h!==null?(this._callback(h),this._callback=noop):this._readCallback&&(f.type==="comment"?u(f.value):this._readCallback=this._readCallback(f))}),this._callback=s,this._lexer.tokenize(e,c)}}function noop(){}function initDataFactory(i,e){i._factory=e,i.DEFAULTGRAPH=e.defaultGraph(),i.RDF_FIRST=e.namedNode(namespaces.rdf.first),i.RDF_REST=e.namedNode(namespaces.rdf.rest),i.RDF_NIL=e.namedNode(namespaces.rdf.nil),i.N3_FORALL=e.namedNode(namespaces.r.forAll),i.N3_FORSOME=e.namedNode(namespaces.r.forSome),i.ABBREVIATIONS={a:e.namedNode(namespaces.rdf.type),"=":e.namedNode(namespaces.owl.sameAs),">":e.namedNode(namespaces.log.implies),"<":e.namedNode(namespaces.log.isImpliedBy)},i.QUANTIFIERS_GRAPH=e.namedNode("urn:n3:quantifiers")}initDataFactory(N3Parser.prototype,DataFactory);function isDefaultGraph(i){return!!i&&i.termType==="DefaultGraph"}function escapeRegex$1(i){return i.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&")}const BASE_UNSUPPORTED=/^:?[^:?#]*(?:[?#]|$)|^file:|^[^:]*:\/*[^?#]+?\/(?:\.\.?(?:\/|$)|\/)/i,SUFFIX_SUPPORTED=/^(?:(?:[^/?#]{3,}|\.?[^/?#.]\.?)(?:\/[^/?#]{3,}|\.?[^/?#.]\.?)*\/?)?(?:[?#]|$)/,CURRENT="./",PARENT="../",QUERY="?",FRAGMENT="#";class BaseIRI{constructor(e){this.base=e,this._baseLength=0,this._baseMatcher=null,this._pathReplacements=new Array(e.length+1)}static supports(e){return!BASE_UNSUPPORTED.test(e)}_getBaseMatcher(){if(this._baseMatcher)return this._baseMatcher;if(!BaseIRI.supports(this.base))return this._baseMatcher=/.^/;const e=/^[^:]*:\/*/.exec(this.base)[0],t=["^",escapeRegex$1(e)],n=[],s=[],a=/[^/?#]*([/?#])/y;let u,c=0,h=0,f=a.lastIndex=e.length;for(;!c&&!h&&(u=a.exec(this.base));)u[1]===FRAGMENT?h=a.lastIndex-1:(t.push(escapeRegex$1(u[0]),"(?:"),n.push(")?"),u[1]!==QUERY?s.push(f=a.lastIndex):(c=f=a.lastIndex,h=this.base.indexOf(FRAGMENT,c),this._pathReplacements[c]=QUERY));for(let p=0;p<s.length;p++)this._pathReplacements[s[p]]=PARENT.repeat(s.length-p-1);return this._pathReplacements[s[s.length-1]]=CURRENT,this._baseLength=h>0?h:this.base.length,t.push(escapeRegex$1(this.base.substring(f,this._baseLength)),c?"(?:#|$)":"(?:[?#]|$)"),this._baseMatcher=new RegExp([...t,...n].join(""))}toRelative(e){const t=this._getBaseMatcher().exec(e);if(!t)return e;const n=t[0].length;if(n===this._baseLength&&n===e.length)return"";const s=this._pathReplacements[n];if(s){const a=e.substring(n);return s!==QUERY&&!SUFFIX_SUPPORTED.test(a)?e:s===CURRENT&&/^[^?#]/.test(a)?a:s+a}return e.substring(n-1)}}const DEFAULTGRAPH=DataFactory.defaultGraph(),{rdf,xsd}=namespaces,escape$1=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,escapeAll=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,escapedCharacters={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};class SerializedTerm extends Term{equals(e){return e===this}}class N3Writer{constructor(e,t){if(this._prefixRegex=/$0^/,e&&typeof e.write!="function"&&(t=e,e=null),t=t||{},this._lists=t.lists,e)this._outputStream=e,this._endStream=t.end===void 0?!0:!!t.end;else{let n="";this._outputStream={write(s,a,u){n+=s,u&&u()},end:s=>{s&&s(null,n)}},this._endStream=!0}this._subject=null,/triple|quad/i.test(t.format)?(this._lineMode=!0,this._writeQuad=this._writeQuadLine):(this._lineMode=!1,this._graph=DEFAULTGRAPH,this._prefixIRIs=Object.create(null),t.prefixes&&this.addPrefixes(t.prefixes),t.baseIRI&&(this._baseIri=new BaseIRI(t.baseIRI)))}get _inDefaultGraph(){return DEFAULTGRAPH.equals(this._graph)}_write(e,t){this._outputStream.write(e,"utf8",t)}_writeQuad(e,t,n,s,a){try{s.equals(this._graph)||(this._write((this._subject===null?"":this._inDefaultGraph?`.
165
+ `:`
166
+ }
167
+ `)+(DEFAULTGRAPH.equals(s)?"":`${this._encodeIriOrBlank(s)} {
168
+ `)),this._graph=s,this._subject=null),e.equals(this._subject)?t.equals(this._predicate)?this._write(`, ${this._encodeObject(n)}`,a):this._write(`;
169
+ ${this._encodePredicate(this._predicate=t)} ${this._encodeObject(n)}`,a):this._write(`${(this._subject===null?"":`.
170
+ `)+this._encodeSubject(this._subject=e)} ${this._encodePredicate(this._predicate=t)} ${this._encodeObject(n)}`,a)}catch(u){a&&a(u)}}_writeQuadLine(e,t,n,s,a){delete this._prefixMatch,this._write(this.quadToString(e,t,n,s),a)}quadToString(e,t,n,s){return`${this._encodeSubject(e)} ${this._encodeIriOrBlank(t)} ${this._encodeObject(n)}${s&&s.value?` ${this._encodeIriOrBlank(s)} .
171
+ `:` .
172
+ `}`}quadsToString(e){let t="";for(const n of e)t+=this.quadToString(n.subject,n.predicate,n.object,n.graph);return t}_encodeSubject(e){return e.termType==="Quad"?this._encodeQuad(e):this._encodeIriOrBlank(e)}_encodeIriOrBlank(e){if(e.termType!=="NamedNode")return this._lists&&e.value in this._lists&&(e=this.list(this._lists[e.value])),"id"in e?e.id:`_:${e.value}`;let t=e.value;this._baseIri&&(t=this._baseIri.toRelative(t)),escape$1.test(t)&&(t=t.replace(escapeAll,characterReplacer));const n=this._prefixRegex.exec(t);return n?n[1]?this._prefixIRIs[n[1]]+n[2]:t:`<${t}>`}_encodeLiteral(e){let t=e.value;if(escape$1.test(t)&&(t=t.replace(escapeAll,characterReplacer)),e.language)return`"${t}"@${e.language}`;if(this._lineMode){if(e.datatype.value===xsd.string)return`"${t}"`}else switch(e.datatype.value){case xsd.string:return`"${t}"`;case xsd.boolean:if(t==="true"||t==="false")return t;break;case xsd.integer:if(/^[+-]?\d+$/.test(t))return t;break;case xsd.decimal:if(/^[+-]?\d*\.\d+$/.test(t))return t;break;case xsd.double:if(/^[+-]?(?:\d+\.\d*|\.?\d+)[eE][+-]?\d+$/.test(t))return t;break}return`"${t}"^^${this._encodeIriOrBlank(e.datatype)}`}_encodePredicate(e){return e.value===rdf.type?"a":this._encodeIriOrBlank(e)}_encodeObject(e){switch(e.termType){case"Quad":return this._encodeQuad(e);case"Literal":return this._encodeLiteral(e);default:return this._encodeIriOrBlank(e)}}_encodeQuad({subject:e,predicate:t,object:n,graph:s}){return`<<${this._encodeSubject(e)} ${this._encodePredicate(t)} ${this._encodeObject(n)}${isDefaultGraph(s)?"":` ${this._encodeIriOrBlank(s)}`}>>`}_blockedWrite(){throw new Error("Cannot write because the writer has been closed.")}addQuad(e,t,n,s,a){n===void 0?this._writeQuad(e.subject,e.predicate,e.object,e.graph,t):typeof s=="function"?this._writeQuad(e,t,n,DEFAULTGRAPH,s):this._writeQuad(e,t,n,s||DEFAULTGRAPH,a)}addQuads(e){for(let t=0;t<e.length;t++)this.addQuad(e[t])}addPrefix(e,t,n){const s={};s[e]=t,this.addPrefixes(s,n)}addPrefixes(e,t){if(!this._prefixIRIs)return t&&t();let n=!1;for(let s in e){let a=e[s];typeof a!="string"&&(a=a.value),n=!0,this._subject!==null&&(this._write(this._inDefaultGraph?`.
173
+ `:`
174
+ }
175
+ `),this._subject=null,this._graph=""),this._prefixIRIs[a]=s+=":",this._write(`@prefix ${s} <${a}>.
176
+ `)}if(n){let s="",a="";for(const u in this._prefixIRIs)s+=s?`|${u}`:u,a+=(a?"|":"")+this._prefixIRIs[u];s=escapeRegex$1(s),this._prefixRegex=new RegExp(`^(?:${a})[^/]*$|^(${s})([_a-zA-Z0-9][\\-_a-zA-Z0-9]*)$`)}this._write(n?`
177
+ `:"",t)}blank(e,t){let n=e,s,a;switch(e===void 0?n=[]:e.termType?n=[{predicate:e,object:t}]:"length"in e||(n=[e]),a=n.length){case 0:return new SerializedTerm("[]");case 1:if(s=n[0],!(s.object instanceof SerializedTerm))return new SerializedTerm(`[ ${this._encodePredicate(s.predicate)} ${this._encodeObject(s.object)} ]`);default:let u="[";for(let c=0;c<a;c++)s=n[c],s.predicate.equals(e)?u+=`, ${this._encodeObject(s.object)}`:(u+=`${(c?`;
178
+ `:`
179
+ `)+this._encodePredicate(s.predicate)} ${this._encodeObject(s.object)}`,e=s.predicate);return new SerializedTerm(`${u}
180
+ ]`)}}list(e){const t=e&&e.length||0,n=new Array(t);for(let s=0;s<t;s++)n[s]=this._encodeObject(e[s]);return new SerializedTerm(`(${n.join(" ")})`)}end(e){this._subject!==null&&(this._write(this._inDefaultGraph?`.
181
+ `:`
182
+ }
183
+ `),this._subject=null),this._write=this._blockedWrite;let t=e&&((n,s)=>{t=null,e(n,s)});if(this._endStream)try{return this._outputStream.end(t)}catch{}t&&t()}}function characterReplacer(i){let e=escapedCharacters[i];return e===void 0&&(i.length===1?(e=i.charCodeAt(0).toString(16),e="\\u0000".substr(0,6-e.length)+e):(e=((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)+9216).toString(16),e="\\U00000000".substr(0,10-e.length)+e)),e}var browser={exports:{}},stream={exports:{}},primordials,hasRequiredPrimordials;function requirePrimordials(){if(hasRequiredPrimordials)return primordials;hasRequiredPrimordials=1;class i extends Error{constructor(t){if(!Array.isArray(t))throw new TypeError(`Expected input to be an Array, got ${typeof t}`);let n="";for(let s=0;s<t.length;s++)n+=` ${t[s].stack}
184
+ `;super(n),this.name="AggregateError",this.errors=t}}return primordials={AggregateError:i,ArrayIsArray(e){return Array.isArray(e)},ArrayPrototypeIncludes(e,t){return e.includes(t)},ArrayPrototypeIndexOf(e,t){return e.indexOf(t)},ArrayPrototypeJoin(e,t){return e.join(t)},ArrayPrototypeMap(e,t){return e.map(t)},ArrayPrototypePop(e,t){return e.pop(t)},ArrayPrototypePush(e,t){return e.push(t)},ArrayPrototypeSlice(e,t,n){return e.slice(t,n)},Error,FunctionPrototypeCall(e,t,...n){return e.call(t,...n)},FunctionPrototypeSymbolHasInstance(e,t){return Function.prototype[Symbol.hasInstance].call(e,t)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(e,t){return Object.defineProperties(e,t)},ObjectDefineProperty(e,t,n){return Object.defineProperty(e,t,n)},ObjectGetOwnPropertyDescriptor(e,t){return Object.getOwnPropertyDescriptor(e,t)},ObjectKeys(e){return Object.keys(e)},ObjectSetPrototypeOf(e,t){return Object.setPrototypeOf(e,t)},Promise,PromisePrototypeCatch(e,t){return e.catch(t)},PromisePrototypeThen(e,t,n){return e.then(t,n)},PromiseReject(e){return Promise.reject(e)},PromiseResolve(e){return Promise.resolve(e)},ReflectApply:Reflect.apply,RegExpPrototypeTest(e,t){return e.test(t)},SafeSet:Set,String,StringPrototypeSlice(e,t,n){return e.slice(t,n)},StringPrototypeToLowerCase(e){return e.toLowerCase()},StringPrototypeToUpperCase(e){return e.toUpperCase()},StringPrototypeTrim(e){return e.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(e,t,n){return e.set(t,n)},Boolean,Uint8Array},primordials}var util={exports:{}},inspect,hasRequiredInspect;function requireInspect(){return hasRequiredInspect||(hasRequiredInspect=1,inspect={format(i,...e){return i.replace(/%([sdifj])/g,function(...[t,n]){const s=e.shift();return n==="f"?s.toFixed(6):n==="j"?JSON.stringify(s):n==="s"&&typeof s=="object"?`${s.constructor!==Object?s.constructor.name:""} {}`.trim():s.toString()})},inspect(i){switch(typeof i){case"string":if(i.includes("'"))if(i.includes('"')){if(!i.includes("`")&&!i.includes("${"))return`\`${i}\``}else return`"${i}"`;return`'${i}'`;case"number":return isNaN(i)?"NaN":Object.is(i,-0)?String(i):i;case"bigint":return`${String(i)}n`;case"boolean":case"undefined":return String(i);case"object":return"{}"}}}),inspect}var errors,hasRequiredErrors;function requireErrors(){if(hasRequiredErrors)return errors;hasRequiredErrors=1;const{format:i,inspect:e}=requireInspect(),{AggregateError:t}=requirePrimordials(),n=globalThis.AggregateError||t,s=Symbol("kIsNodeError"),a=["string","function","number","object","Function","Object","boolean","bigint","symbol"],u=/^([A-Z][a-z0-9]*)+$/,c="__node_internal_",h={};function f(T,A){if(!T)throw new h.ERR_INTERNAL_ASSERTION(A)}function p(T){let A="",F=T.length;const x=T[0]==="-"?1:0;for(;F>=x+4;F-=3)A=`_${T.slice(F-3,F)}${A}`;return`${T.slice(0,F)}${A}`}function g(T,A,F){if(typeof A=="function")return f(A.length<=F.length,`Code: ${T}; The provided arguments length (${F.length}) does not match the required ones (${A.length}).`),A(...F);const x=(A.match(/%[dfijoOs]/g)||[]).length;return f(x===F.length,`Code: ${T}; The provided arguments length (${F.length}) does not match the required ones (${x}).`),F.length===0?A:i(A,...F)}function y(T,A,F){F||(F=Error);class x extends F{constructor(...O){super(g(T,A,O))}toString(){return`${this.name} [${T}]: ${this.message}`}}Object.defineProperties(x.prototype,{name:{value:F.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${T}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),x.prototype.code=T,x.prototype[s]=!0,h[T]=x}function S(T){const A=c+T.name;return Object.defineProperty(T,"name",{value:A}),T}function w(T,A){if(T&&A&&T!==A){if(Array.isArray(A.errors))return A.errors.push(T),A;const F=new n([A,T],A.message);return F.code=A.code,F}return T||A}class R extends Error{constructor(A="The operation was aborted",F=void 0){if(F!==void 0&&typeof F!="object")throw new h.ERR_INVALID_ARG_TYPE("options","Object",F);super(A,F),this.code="ABORT_ERR",this.name="AbortError"}}return y("ERR_ASSERTION","%s",Error),y("ERR_INVALID_ARG_TYPE",(T,A,F)=>{f(typeof T=="string","'name' must be a string"),Array.isArray(A)||(A=[A]);let x="The ";T.endsWith(" argument")?x+=`${T} `:x+=`"${T}" ${T.includes(".")?"property":"argument"} `,x+="must be ";const D=[],O=[],K=[];for(const X of A)f(typeof X=="string","All expected entries have to be of type string"),a.includes(X)?D.push(X.toLowerCase()):u.test(X)?O.push(X):(f(X!=="object",'The value "object" should be written as "Object"'),K.push(X));if(O.length>0){const X=D.indexOf("object");X!==-1&&(D.splice(D,X,1),O.push("Object"))}if(D.length>0){switch(D.length){case 1:x+=`of type ${D[0]}`;break;case 2:x+=`one of type ${D[0]} or ${D[1]}`;break;default:{const X=D.pop();x+=`one of type ${D.join(", ")}, or ${X}`}}(O.length>0||K.length>0)&&(x+=" or ")}if(O.length>0){switch(O.length){case 1:x+=`an instance of ${O[0]}`;break;case 2:x+=`an instance of ${O[0]} or ${O[1]}`;break;default:{const X=O.pop();x+=`an instance of ${O.join(", ")}, or ${X}`}}K.length>0&&(x+=" or ")}switch(K.length){case 0:break;case 1:K[0].toLowerCase()!==K[0]&&(x+="an "),x+=`${K[0]}`;break;case 2:x+=`one of ${K[0]} or ${K[1]}`;break;default:{const X=K.pop();x+=`one of ${K.join(", ")}, or ${X}`}}if(F==null)x+=`. Received ${F}`;else if(typeof F=="function"&&F.name)x+=`. Received function ${F.name}`;else if(typeof F=="object"){var z;if((z=F.constructor)!==null&&z!==void 0&&z.name)x+=`. Received an instance of ${F.constructor.name}`;else{const X=e(F,{depth:-1});x+=`. Received ${X}`}}else{let X=e(F,{colors:!1});X.length>25&&(X=`${X.slice(0,25)}...`),x+=`. Received type ${typeof F} (${X})`}return x},TypeError),y("ERR_INVALID_ARG_VALUE",(T,A,F="is invalid")=>{let x=e(A);return x.length>128&&(x=x.slice(0,128)+"..."),`The ${T.includes(".")?"property":"argument"} '${T}' ${F}. Received ${x}`},TypeError),y("ERR_INVALID_RETURN_VALUE",(T,A,F)=>{var x;const D=F!=null&&(x=F.constructor)!==null&&x!==void 0&&x.name?`instance of ${F.constructor.name}`:`type ${typeof F}`;return`Expected ${T} to be returned from the "${A}" function but got ${D}.`},TypeError),y("ERR_MISSING_ARGS",(...T)=>{f(T.length>0,"At least one arg needs to be specified");let A;const F=T.length;switch(T=(Array.isArray(T)?T:[T]).map(x=>`"${x}"`).join(" or "),F){case 1:A+=`The ${T[0]} argument`;break;case 2:A+=`The ${T[0]} and ${T[1]} arguments`;break;default:{const x=T.pop();A+=`The ${T.join(", ")}, and ${x} arguments`}break}return`${A} must be specified`},TypeError),y("ERR_OUT_OF_RANGE",(T,A,F)=>{f(A,'Missing "range" argument');let x;if(Number.isInteger(F)&&Math.abs(F)>2**32)x=p(String(F));else if(typeof F=="bigint"){x=String(F);const D=BigInt(2)**BigInt(32);(F>D||F<-D)&&(x=p(x)),x+="n"}else x=e(F);return`The value of "${T}" is out of range. It must be ${A}. Received ${x}`},RangeError),y("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),y("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),y("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),y("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),y("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),y("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),y("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),y("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),y("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),y("ERR_STREAM_WRITE_AFTER_END","write after end",Error),y("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),errors={AbortError:R,aggregateTwoErrors:S(w),hideStackFrames:S,codes:h},errors}var hasRequiredUtil;function requireUtil(){return hasRequiredUtil||(hasRequiredUtil=1,(function(i){const e=requireBuffer(),{format:t,inspect:n}=requireInspect(),{codes:{ERR_INVALID_ARG_TYPE:s}}=requireErrors(),{kResistStopPropagation:a,AggregateError:u,SymbolDispose:c}=requirePrimordials(),h=globalThis.AbortSignal||requireBrowser$3().AbortSignal,f=globalThis.AbortController||requireBrowser$3().AbortController,p=Object.getPrototypeOf(async function(){}).constructor,g=globalThis.Blob||e.Blob,y=typeof g<"u"?function(T){return T instanceof g}:function(T){return!1},S=(R,T)=>{if(R!==void 0&&(R===null||typeof R!="object"||!("aborted"in R)))throw new s(T,"AbortSignal",R)},w=(R,T)=>{if(typeof R!="function")throw new s(T,"Function",R)};i.exports={AggregateError:u,kEmptyObject:Object.freeze({}),once(R){let T=!1;return function(...A){T||(T=!0,R.apply(this,A))}},createDeferredPromise:function(){let R,T;return{promise:new Promise((F,x)=>{R=F,T=x}),resolve:R,reject:T}},promisify(R){return new Promise((T,A)=>{R((F,...x)=>F?A(F):T(...x))})},debuglog(){return function(){}},format:t,inspect:n,types:{isAsyncFunction(R){return R instanceof p},isArrayBufferView(R){return ArrayBuffer.isView(R)}},isBlob:y,deprecate(R,T){return R},addAbortListener:requireEvents().addAbortListener||function(T,A){if(T===void 0)throw new s("signal","AbortSignal",T);S(T,"signal"),w(A,"listener");let F;return T.aborted?queueMicrotask(()=>A()):(T.addEventListener("abort",A,{__proto__:null,once:!0,[a]:!0}),F=()=>{T.removeEventListener("abort",A)}),{__proto__:null,[c](){var x;(x=F)===null||x===void 0||x()}}},AbortSignalAny:h.any||function(T){if(T.length===1)return T[0];const A=new f,F=()=>A.abort();return T.forEach(x=>{S(x,"signals"),x.addEventListener("abort",F,{once:!0})}),A.signal.addEventListener("abort",()=>{T.forEach(x=>x.removeEventListener("abort",F))},{once:!0}),A.signal}},i.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")})(util)),util.exports}var operators={},validators,hasRequiredValidators;function requireValidators(){if(hasRequiredValidators)return validators;hasRequiredValidators=1;const{ArrayIsArray:i,ArrayPrototypeIncludes:e,ArrayPrototypeJoin:t,ArrayPrototypeMap:n,NumberIsInteger:s,NumberIsNaN:a,NumberMAX_SAFE_INTEGER:u,NumberMIN_SAFE_INTEGER:c,NumberParseInt:h,ObjectPrototypeHasOwnProperty:f,RegExpPrototypeExec:p,String:g,StringPrototypeToUpperCase:y,StringPrototypeTrim:S}=requirePrimordials(),{hideStackFrames:w,codes:{ERR_SOCKET_BAD_PORT:R,ERR_INVALID_ARG_TYPE:T,ERR_INVALID_ARG_VALUE:A,ERR_OUT_OF_RANGE:F,ERR_UNKNOWN_SIGNAL:x}}=requireErrors(),{normalizeEncoding:D}=requireUtil(),{isAsyncFunction:O,isArrayBufferView:K}=requireUtil().types,z={};function X(J){return J===(J|0)}function Ee(J){return J===J>>>0}const q=/^[0-7]+$/,Y="must be a 32-bit unsigned integer or an octal string";function Te(J,me,xe){if(typeof J>"u"&&(J=xe),typeof J=="string"){if(p(q,J)===null)throw new A(me,J,Y);J=h(J,8)}return ze(J,me),J}const re=w((J,me,xe=c,de=u)=>{if(typeof J!="number")throw new T(me,"number",J);if(!s(J))throw new F(me,"an integer",J);if(J<xe||J>de)throw new F(me,`>= ${xe} && <= ${de}`,J)}),$e=w((J,me,xe=-2147483648,de=2147483647)=>{if(typeof J!="number")throw new T(me,"number",J);if(!s(J))throw new F(me,"an integer",J);if(J<xe||J>de)throw new F(me,`>= ${xe} && <= ${de}`,J)}),ze=w((J,me,xe=!1)=>{if(typeof J!="number")throw new T(me,"number",J);if(!s(J))throw new F(me,"an integer",J);const de=xe?1:0,st=4294967295;if(J<de||J>st)throw new F(me,`>= ${de} && <= ${st}`,J)});function ye(J,me){if(typeof J!="string")throw new T(me,"string",J)}function Ve(J,me,xe=void 0,de){if(typeof J!="number")throw new T(me,"number",J);if(xe!=null&&J<xe||de!=null&&J>de||(xe!=null||de!=null)&&a(J))throw new F(me,`${xe!=null?`>= ${xe}`:""}${xe!=null&&de!=null?" && ":""}${de!=null?`<= ${de}`:""}`,J)}const pe=w((J,me,xe)=>{if(!e(xe,J)){const st="must be one of: "+t(n(xe,ft=>typeof ft=="string"?`'${ft}'`:g(ft)),", ");throw new A(me,J,st)}});function De(J,me){if(typeof J!="boolean")throw new T(me,"boolean",J)}function $(J,me,xe){return J==null||!f(J,me)?xe:J[me]}const G=w((J,me,xe=null)=>{const de=$(xe,"allowArray",!1),st=$(xe,"allowFunction",!1);if(!$(xe,"nullable",!1)&&J===null||!de&&i(J)||typeof J!="object"&&(!st||typeof J!="function"))throw new T(me,"Object",J)}),ce=w((J,me)=>{if(J!=null&&typeof J!="object"&&typeof J!="function")throw new T(me,"a dictionary",J)}),oe=w((J,me,xe=0)=>{if(!i(J))throw new T(me,"Array",J);if(J.length<xe){const de=`must be longer than ${xe}`;throw new A(me,J,de)}});function Fe(J,me){oe(J,me);for(let xe=0;xe<J.length;xe++)ye(J[xe],`${me}[${xe}]`)}function Ue(J,me){oe(J,me);for(let xe=0;xe<J.length;xe++)De(J[xe],`${me}[${xe}]`)}function Je(J,me){oe(J,me);for(let xe=0;xe<J.length;xe++){const de=J[xe],st=`${me}[${xe}]`;if(de==null)throw new T(st,"AbortSignal",de);ie(de,st)}}function He(J,me="signal"){if(ye(J,me),z[J]===void 0)throw z[y(J)]!==void 0?new x(J+" (signals must use all capital letters)"):new x(J)}const he=w((J,me="buffer")=>{if(!K(J))throw new T(me,["Buffer","TypedArray","DataView"],J)});function fe(J,me){const xe=D(me),de=J.length;if(xe==="hex"&&de%2!==0)throw new A("encoding",me,`is invalid for data of length ${de}`)}function Oe(J,me="Port",xe=!0){if(typeof J!="number"&&typeof J!="string"||typeof J=="string"&&S(J).length===0||+J!==+J>>>0||J>65535||J===0&&!xe)throw new R(me,J,xe);return J|0}const ie=w((J,me)=>{if(J!==void 0&&(J===null||typeof J!="object"||!("aborted"in J)))throw new T(me,"AbortSignal",J)}),j=w((J,me)=>{if(typeof J!="function")throw new T(me,"Function",J)}),N=w((J,me)=>{if(typeof J!="function"||O(J))throw new T(me,"Function",J)}),L=w((J,me)=>{if(J!==void 0)throw new T(me,"undefined",J)});function V(J,me,xe){if(!e(xe,J))throw new T(me,`('${t(xe,"|")}')`,J)}const ee=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function ae(J,me){if(typeof J>"u"||!p(ee,J))throw new A(me,J,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function ve(J){if(typeof J=="string")return ae(J,"hints"),J;if(i(J)){const me=J.length;let xe="";if(me===0)return xe;for(let de=0;de<me;de++){const st=J[de];ae(st,"hints"),xe+=st,de!==me-1&&(xe+=", ")}return xe}throw new A("hints",J,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}return validators={isInt32:X,isUint32:Ee,parseFileMode:Te,validateArray:oe,validateStringArray:Fe,validateBooleanArray:Ue,validateAbortSignalArray:Je,validateBoolean:De,validateBuffer:he,validateDictionary:ce,validateEncoding:fe,validateFunction:j,validateInt32:$e,validateInteger:re,validateNumber:Ve,validateObject:G,validateOneOf:pe,validatePlainFunction:N,validatePort:Oe,validateSignalName:He,validateString:ye,validateUint32:ze,validateUndefined:L,validateUnion:V,validateAbortSignal:ie,validateLinkHeaderValue:ve},validators}var endOfStream={exports:{}},utils,hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils;hasRequiredUtils=1;const{SymbolAsyncIterator:i,SymbolIterator:e,SymbolFor:t}=requirePrimordials(),n=t("nodejs.stream.destroyed"),s=t("nodejs.stream.errored"),a=t("nodejs.stream.readable"),u=t("nodejs.stream.writable"),c=t("nodejs.stream.disturbed"),h=t("nodejs.webstream.isClosedPromise"),f=t("nodejs.webstream.controllerErrorFunction");function p($,G=!1){var ce;return!!($&&typeof $.pipe=="function"&&typeof $.on=="function"&&(!G||typeof $.pause=="function"&&typeof $.resume=="function")&&(!$._writableState||((ce=$._readableState)===null||ce===void 0?void 0:ce.readable)!==!1)&&(!$._writableState||$._readableState))}function g($){var G;return!!($&&typeof $.write=="function"&&typeof $.on=="function"&&(!$._readableState||((G=$._writableState)===null||G===void 0?void 0:G.writable)!==!1))}function y($){return!!($&&typeof $.pipe=="function"&&$._readableState&&typeof $.on=="function"&&typeof $.write=="function")}function S($){return $&&($._readableState||$._writableState||typeof $.write=="function"&&typeof $.on=="function"||typeof $.pipe=="function"&&typeof $.on=="function")}function w($){return!!($&&!S($)&&typeof $.pipeThrough=="function"&&typeof $.getReader=="function"&&typeof $.cancel=="function")}function R($){return!!($&&!S($)&&typeof $.getWriter=="function"&&typeof $.abort=="function")}function T($){return!!($&&!S($)&&typeof $.readable=="object"&&typeof $.writable=="object")}function A($){return w($)||R($)||T($)}function F($,G){return $==null?!1:G===!0?typeof $[i]=="function":G===!1?typeof $[e]=="function":typeof $[i]=="function"||typeof $[e]=="function"}function x($){if(!S($))return null;const G=$._writableState,ce=$._readableState,oe=G||ce;return!!($.destroyed||$[n]||oe!=null&&oe.destroyed)}function D($){if(!g($))return null;if($.writableEnded===!0)return!0;const G=$._writableState;return G!=null&&G.errored?!1:typeof G?.ended!="boolean"?null:G.ended}function O($,G){if(!g($))return null;if($.writableFinished===!0)return!0;const ce=$._writableState;return ce!=null&&ce.errored?!1:typeof ce?.finished!="boolean"?null:!!(ce.finished||G===!1&&ce.ended===!0&&ce.length===0)}function K($){if(!p($))return null;if($.readableEnded===!0)return!0;const G=$._readableState;return!G||G.errored?!1:typeof G?.ended!="boolean"?null:G.ended}function z($,G){if(!p($))return null;const ce=$._readableState;return ce!=null&&ce.errored?!1:typeof ce?.endEmitted!="boolean"?null:!!(ce.endEmitted||G===!1&&ce.ended===!0&&ce.length===0)}function X($){return $&&$[a]!=null?$[a]:typeof $?.readable!="boolean"?null:x($)?!1:p($)&&$.readable&&!z($)}function Ee($){return $&&$[u]!=null?$[u]:typeof $?.writable!="boolean"?null:x($)?!1:g($)&&$.writable&&!D($)}function q($,G){return S($)?x($)?!0:!(G?.readable!==!1&&X($)||G?.writable!==!1&&Ee($)):null}function Y($){var G,ce;return S($)?$.writableErrored?$.writableErrored:(G=(ce=$._writableState)===null||ce===void 0?void 0:ce.errored)!==null&&G!==void 0?G:null:null}function Te($){var G,ce;return S($)?$.readableErrored?$.readableErrored:(G=(ce=$._readableState)===null||ce===void 0?void 0:ce.errored)!==null&&G!==void 0?G:null:null}function re($){if(!S($))return null;if(typeof $.closed=="boolean")return $.closed;const G=$._writableState,ce=$._readableState;return typeof G?.closed=="boolean"||typeof ce?.closed=="boolean"?G?.closed||ce?.closed:typeof $._closed=="boolean"&&$e($)?$._closed:null}function $e($){return typeof $._closed=="boolean"&&typeof $._defaultKeepAlive=="boolean"&&typeof $._removedConnection=="boolean"&&typeof $._removedContLen=="boolean"}function ze($){return typeof $._sent100=="boolean"&&$e($)}function ye($){var G;return typeof $._consuming=="boolean"&&typeof $._dumped=="boolean"&&((G=$.req)===null||G===void 0?void 0:G.upgradeOrConnect)===void 0}function Ve($){if(!S($))return null;const G=$._writableState,ce=$._readableState,oe=G||ce;return!oe&&ze($)||!!(oe&&oe.autoDestroy&&oe.emitClose&&oe.closed===!1)}function pe($){var G;return!!($&&((G=$[c])!==null&&G!==void 0?G:$.readableDidRead||$.readableAborted))}function De($){var G,ce,oe,Fe,Ue,Je,He,he,fe,Oe;return!!($&&((G=(ce=(oe=(Fe=(Ue=(Je=$[s])!==null&&Je!==void 0?Je:$.readableErrored)!==null&&Ue!==void 0?Ue:$.writableErrored)!==null&&Fe!==void 0?Fe:(He=$._readableState)===null||He===void 0?void 0:He.errorEmitted)!==null&&oe!==void 0?oe:(he=$._writableState)===null||he===void 0?void 0:he.errorEmitted)!==null&&ce!==void 0?ce:(fe=$._readableState)===null||fe===void 0?void 0:fe.errored)!==null&&G!==void 0?G:!((Oe=$._writableState)===null||Oe===void 0)&&Oe.errored))}return utils={isDestroyed:x,kIsDestroyed:n,isDisturbed:pe,kIsDisturbed:c,isErrored:De,kIsErrored:s,isReadable:X,kIsReadable:a,kIsClosedPromise:h,kControllerErrorFunction:f,kIsWritable:u,isClosed:re,isDuplexNodeStream:y,isFinished:q,isIterable:F,isReadableNodeStream:p,isReadableStream:w,isReadableEnded:K,isReadableFinished:z,isReadableErrored:Te,isNodeStream:S,isWebStream:A,isWritable:Ee,isWritableNodeStream:g,isWritableStream:R,isWritableEnded:D,isWritableFinished:O,isWritableErrored:Y,isServerRequest:ye,isServerResponse:ze,willEmitClose:Ve,isTransformStream:T},utils}var hasRequiredEndOfStream;function requireEndOfStream(){if(hasRequiredEndOfStream)return endOfStream.exports;hasRequiredEndOfStream=1;const i=requireBrowser$2(),{AbortError:e,codes:t}=requireErrors(),{ERR_INVALID_ARG_TYPE:n,ERR_STREAM_PREMATURE_CLOSE:s}=t,{kEmptyObject:a,once:u}=requireUtil(),{validateAbortSignal:c,validateFunction:h,validateObject:f,validateBoolean:p}=requireValidators(),{Promise:g,PromisePrototypeThen:y,SymbolDispose:S}=requirePrimordials(),{isClosed:w,isReadable:R,isReadableNodeStream:T,isReadableStream:A,isReadableFinished:F,isReadableErrored:x,isWritable:D,isWritableNodeStream:O,isWritableStream:K,isWritableFinished:z,isWritableErrored:X,isNodeStream:Ee,willEmitClose:q,kIsClosedPromise:Y}=requireUtils();let Te;function re(pe){return pe.setHeader&&typeof pe.abort=="function"}const $e=()=>{};function ze(pe,De,$){var G,ce;if(arguments.length===2?($=De,De=a):De==null?De=a:f(De,"options"),h($,"callback"),c(De.signal,"options.signal"),$=u($),A(pe)||K(pe))return ye(pe,De,$);if(!Ee(pe))throw new n("stream",["ReadableStream","WritableStream","Stream"],pe);const oe=(G=De.readable)!==null&&G!==void 0?G:T(pe),Fe=(ce=De.writable)!==null&&ce!==void 0?ce:O(pe),Ue=pe._writableState,Je=pe._readableState,He=()=>{pe.writable||Oe()};let he=q(pe)&&T(pe)===oe&&O(pe)===Fe,fe=z(pe,!1);const Oe=()=>{fe=!0,pe.destroyed&&(he=!1),!(he&&(!pe.readable||oe))&&(!oe||ie)&&$.call(pe)};let ie=F(pe,!1);const j=()=>{ie=!0,pe.destroyed&&(he=!1),!(he&&(!pe.writable||Fe))&&(!Fe||fe)&&$.call(pe)},N=J=>{$.call(pe,J)};let L=w(pe);const V=()=>{L=!0;const J=X(pe)||x(pe);if(J&&typeof J!="boolean")return $.call(pe,J);if(oe&&!ie&&T(pe,!0)&&!F(pe,!1))return $.call(pe,new s);if(Fe&&!fe&&!z(pe,!1))return $.call(pe,new s);$.call(pe)},ee=()=>{L=!0;const J=X(pe)||x(pe);if(J&&typeof J!="boolean")return $.call(pe,J);$.call(pe)},ae=()=>{pe.req.on("finish",Oe)};re(pe)?(pe.on("complete",Oe),he||pe.on("abort",V),pe.req?ae():pe.on("request",ae)):Fe&&!Ue&&(pe.on("end",He),pe.on("close",He)),!he&&typeof pe.aborted=="boolean"&&pe.on("aborted",V),pe.on("end",j),pe.on("finish",Oe),De.error!==!1&&pe.on("error",N),pe.on("close",V),L?i.nextTick(V):Ue!=null&&Ue.errorEmitted||Je!=null&&Je.errorEmitted?he||i.nextTick(ee):(!oe&&(!he||R(pe))&&(fe||D(pe)===!1)||!Fe&&(!he||D(pe))&&(ie||R(pe)===!1)||Je&&pe.req&&pe.aborted)&&i.nextTick(ee);const ve=()=>{$=$e,pe.removeListener("aborted",V),pe.removeListener("complete",Oe),pe.removeListener("abort",V),pe.removeListener("request",ae),pe.req&&pe.req.removeListener("finish",Oe),pe.removeListener("end",He),pe.removeListener("close",He),pe.removeListener("finish",Oe),pe.removeListener("end",j),pe.removeListener("error",N),pe.removeListener("close",V)};if(De.signal&&!L){const J=()=>{const me=$;ve(),me.call(pe,new e(void 0,{cause:De.signal.reason}))};if(De.signal.aborted)i.nextTick(J);else{Te=Te||requireUtil().addAbortListener;const me=Te(De.signal,J),xe=$;$=u((...de)=>{me[S](),xe.apply(pe,de)})}}return ve}function ye(pe,De,$){let G=!1,ce=$e;if(De.signal)if(ce=()=>{G=!0,$.call(pe,new e(void 0,{cause:De.signal.reason}))},De.signal.aborted)i.nextTick(ce);else{Te=Te||requireUtil().addAbortListener;const Fe=Te(De.signal,ce),Ue=$;$=u((...Je)=>{Fe[S](),Ue.apply(pe,Je)})}const oe=(...Fe)=>{G||i.nextTick(()=>$.apply(pe,Fe))};return y(pe[Y].promise,oe,oe),$e}function Ve(pe,De){var $;let G=!1;return De===null&&(De=a),($=De)!==null&&$!==void 0&&$.cleanup&&(p(De.cleanup,"cleanup"),G=De.cleanup),new g((ce,oe)=>{const Fe=ze(pe,De,Ue=>{G&&Fe(),Ue?oe(Ue):ce()})})}return endOfStream.exports=ze,endOfStream.exports.finished=Ve,endOfStream.exports}var destroy_1,hasRequiredDestroy;function requireDestroy(){if(hasRequiredDestroy)return destroy_1;hasRequiredDestroy=1;const i=requireBrowser$2(),{aggregateTwoErrors:e,codes:{ERR_MULTIPLE_CALLBACK:t},AbortError:n}=requireErrors(),{Symbol:s}=requirePrimordials(),{kIsDestroyed:a,isDestroyed:u,isFinished:c,isServerRequest:h}=requireUtils(),f=s("kDestroy"),p=s("kConstruct");function g(q,Y,Te){q&&(q.stack,Y&&!Y.errored&&(Y.errored=q),Te&&!Te.errored&&(Te.errored=q))}function y(q,Y){const Te=this._readableState,re=this._writableState,$e=re||Te;return re!=null&&re.destroyed||Te!=null&&Te.destroyed?(typeof Y=="function"&&Y(),this):(g(q,re,Te),re&&(re.destroyed=!0),Te&&(Te.destroyed=!0),$e.constructed?S(this,q,Y):this.once(f,function(ze){S(this,e(ze,q),Y)}),this)}function S(q,Y,Te){let re=!1;function $e(ze){if(re)return;re=!0;const ye=q._readableState,Ve=q._writableState;g(ze,Ve,ye),Ve&&(Ve.closed=!0),ye&&(ye.closed=!0),typeof Te=="function"&&Te(ze),ze?i.nextTick(w,q,ze):i.nextTick(R,q)}try{q._destroy(Y||null,$e)}catch(ze){$e(ze)}}function w(q,Y){T(q,Y),R(q)}function R(q){const Y=q._readableState,Te=q._writableState;Te&&(Te.closeEmitted=!0),Y&&(Y.closeEmitted=!0),(Te!=null&&Te.emitClose||Y!=null&&Y.emitClose)&&q.emit("close")}function T(q,Y){const Te=q._readableState,re=q._writableState;re!=null&&re.errorEmitted||Te!=null&&Te.errorEmitted||(re&&(re.errorEmitted=!0),Te&&(Te.errorEmitted=!0),q.emit("error",Y))}function A(){const q=this._readableState,Y=this._writableState;q&&(q.constructed=!0,q.closed=!1,q.closeEmitted=!1,q.destroyed=!1,q.errored=null,q.errorEmitted=!1,q.reading=!1,q.ended=q.readable===!1,q.endEmitted=q.readable===!1),Y&&(Y.constructed=!0,Y.destroyed=!1,Y.closed=!1,Y.closeEmitted=!1,Y.errored=null,Y.errorEmitted=!1,Y.finalCalled=!1,Y.prefinished=!1,Y.ended=Y.writable===!1,Y.ending=Y.writable===!1,Y.finished=Y.writable===!1)}function F(q,Y,Te){const re=q._readableState,$e=q._writableState;if($e!=null&&$e.destroyed||re!=null&&re.destroyed)return this;re!=null&&re.autoDestroy||$e!=null&&$e.autoDestroy?q.destroy(Y):Y&&(Y.stack,$e&&!$e.errored&&($e.errored=Y),re&&!re.errored&&(re.errored=Y),Te?i.nextTick(T,q,Y):T(q,Y))}function x(q,Y){if(typeof q._construct!="function")return;const Te=q._readableState,re=q._writableState;Te&&(Te.constructed=!1),re&&(re.constructed=!1),q.once(p,Y),!(q.listenerCount(p)>1)&&i.nextTick(D,q)}function D(q){let Y=!1;function Te(re){if(Y){F(q,re??new t);return}Y=!0;const $e=q._readableState,ze=q._writableState,ye=ze||$e;$e&&($e.constructed=!0),ze&&(ze.constructed=!0),ye.destroyed?q.emit(f,re):re?F(q,re,!0):i.nextTick(O,q)}try{q._construct(re=>{i.nextTick(Te,re)})}catch(re){i.nextTick(Te,re)}}function O(q){q.emit(p)}function K(q){return q?.setHeader&&typeof q.abort=="function"}function z(q){q.emit("close")}function X(q,Y){q.emit("error",Y),i.nextTick(z,q)}function Ee(q,Y){!q||u(q)||(!Y&&!c(q)&&(Y=new n),h(q)?(q.socket=null,q.destroy(Y)):K(q)?q.abort():K(q.req)?q.req.abort():typeof q.destroy=="function"?q.destroy(Y):typeof q.close=="function"?q.close():Y?i.nextTick(X,q,Y):i.nextTick(z,q),q.destroyed||(q[a]=!0))}return destroy_1={construct:x,destroyer:Ee,destroy:y,undestroy:A,errorOrDestroy:F},destroy_1}var legacy,hasRequiredLegacy;function requireLegacy(){if(hasRequiredLegacy)return legacy;hasRequiredLegacy=1;const{ArrayIsArray:i,ObjectSetPrototypeOf:e}=requirePrimordials(),{EventEmitter:t}=requireEvents();function n(a){t.call(this,a)}e(n.prototype,t.prototype),e(n,t),n.prototype.pipe=function(a,u){const c=this;function h(R){a.writable&&a.write(R)===!1&&c.pause&&c.pause()}c.on("data",h);function f(){c.readable&&c.resume&&c.resume()}a.on("drain",f),!a._isStdio&&(!u||u.end!==!1)&&(c.on("end",g),c.on("close",y));let p=!1;function g(){p||(p=!0,a.end())}function y(){p||(p=!0,typeof a.destroy=="function"&&a.destroy())}function S(R){w(),t.listenerCount(this,"error")===0&&this.emit("error",R)}s(c,"error",S),s(a,"error",S);function w(){c.removeListener("data",h),a.removeListener("drain",f),c.removeListener("end",g),c.removeListener("close",y),c.removeListener("error",S),a.removeListener("error",S),c.removeListener("end",w),c.removeListener("close",w),a.removeListener("close",w)}return c.on("end",w),c.on("close",w),a.on("close",w),a.emit("pipe",c),a};function s(a,u,c){if(typeof a.prependListener=="function")return a.prependListener(u,c);!a._events||!a._events[u]?a.on(u,c):i(a._events[u])?a._events[u].unshift(c):a._events[u]=[c,a._events[u]]}return legacy={Stream:n,prependListener:s},legacy}var addAbortSignal={exports:{}},hasRequiredAddAbortSignal;function requireAddAbortSignal(){return hasRequiredAddAbortSignal||(hasRequiredAddAbortSignal=1,(function(i){const{SymbolDispose:e}=requirePrimordials(),{AbortError:t,codes:n}=requireErrors(),{isNodeStream:s,isWebStream:a,kControllerErrorFunction:u}=requireUtils(),c=requireEndOfStream(),{ERR_INVALID_ARG_TYPE:h}=n;let f;const p=(g,y)=>{if(typeof g!="object"||!("aborted"in g))throw new h(y,"AbortSignal",g)};i.exports.addAbortSignal=function(y,S){if(p(y,"signal"),!s(S)&&!a(S))throw new h("stream",["ReadableStream","WritableStream","Stream"],S);return i.exports.addAbortSignalNoValidate(y,S)},i.exports.addAbortSignalNoValidate=function(g,y){if(typeof g!="object"||!("aborted"in g))return y;const S=s(y)?()=>{y.destroy(new t(void 0,{cause:g.reason}))}:()=>{y[u](new t(void 0,{cause:g.reason}))};if(g.aborted)S();else{f=f||requireUtil().addAbortListener;const w=f(g,S);c(y,w[e])}return y}})(addAbortSignal)),addAbortSignal.exports}var buffer_list,hasRequiredBuffer_list;function requireBuffer_list(){if(hasRequiredBuffer_list)return buffer_list;hasRequiredBuffer_list=1;const{StringPrototypeSlice:i,SymbolIterator:e,TypedArrayPrototypeSet:t,Uint8Array:n}=requirePrimordials(),{Buffer:s}=requireBuffer(),{inspect:a}=requireUtil();return buffer_list=class{constructor(){this.head=null,this.tail=null,this.length=0}push(c){const h={data:c,next:null};this.length>0?this.tail.next=h:this.head=h,this.tail=h,++this.length}unshift(c){const h={data:c,next:this.head};this.length===0&&(this.tail=h),this.head=h,++this.length}shift(){if(this.length===0)return;const c=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,c}clear(){this.head=this.tail=null,this.length=0}join(c){if(this.length===0)return"";let h=this.head,f=""+h.data;for(;(h=h.next)!==null;)f+=c+h.data;return f}concat(c){if(this.length===0)return s.alloc(0);const h=s.allocUnsafe(c>>>0);let f=this.head,p=0;for(;f;)t(h,f.data,p),p+=f.data.length,f=f.next;return h}consume(c,h){const f=this.head.data;if(c<f.length){const p=f.slice(0,c);return this.head.data=f.slice(c),p}return c===f.length?this.shift():h?this._getString(c):this._getBuffer(c)}first(){return this.head.data}*[e](){for(let c=this.head;c;c=c.next)yield c.data}_getString(c){let h="",f=this.head,p=0;do{const g=f.data;if(c>g.length)h+=g,c-=g.length;else{c===g.length?(h+=g,++p,f.next?this.head=f.next:this.head=this.tail=null):(h+=i(g,0,c),this.head=f,f.data=i(g,c));break}++p}while((f=f.next)!==null);return this.length-=p,h}_getBuffer(c){const h=s.allocUnsafe(c),f=c;let p=this.head,g=0;do{const y=p.data;if(c>y.length)t(h,y,f-c),c-=y.length;else{c===y.length?(t(h,y,f-c),++g,p.next?this.head=p.next:this.head=this.tail=null):(t(h,new n(y.buffer,y.byteOffset,c),f-c),this.head=p,p.data=y.slice(c));break}++g}while((p=p.next)!==null);return this.length-=g,h}[Symbol.for("nodejs.util.inspect.custom")](c,h){return a(this,{...h,depth:0,customInspect:!1})}},buffer_list}var state,hasRequiredState;function requireState(){if(hasRequiredState)return state;hasRequiredState=1;const{MathFloor:i,NumberIsInteger:e}=requirePrimordials(),{validateInteger:t}=requireValidators(),{ERR_INVALID_ARG_VALUE:n}=requireErrors().codes;let s=16*1024,a=16;function u(p,g,y){return p.highWaterMark!=null?p.highWaterMark:g?p[y]:null}function c(p){return p?a:s}function h(p,g){t(g,"value",0),p?a=g:s=g}function f(p,g,y,S){const w=u(g,S,y);if(w!=null){if(!e(w)||w<0){const R=S?`options.${y}`:"options.highWaterMark";throw new n(R,w)}return i(w)}return c(p.objectMode)}return state={getHighWaterMark:f,getDefaultHighWaterMark:c,setDefaultHighWaterMark:h},state}var from_1,hasRequiredFrom;function requireFrom(){if(hasRequiredFrom)return from_1;hasRequiredFrom=1;const i=requireBrowser$2(),{PromisePrototypeThen:e,SymbolAsyncIterator:t,SymbolIterator:n}=requirePrimordials(),{Buffer:s}=requireBuffer(),{ERR_INVALID_ARG_TYPE:a,ERR_STREAM_NULL_VALUES:u}=requireErrors().codes;function c(h,f,p){let g;if(typeof f=="string"||f instanceof s)return new h({objectMode:!0,...p,read(){this.push(f),this.push(null)}});let y;if(f&&f[t])y=!0,g=f[t]();else if(f&&f[n])y=!1,g=f[n]();else throw new a("iterable",["Iterable"],f);const S=new h({objectMode:!0,highWaterMark:1,...p});let w=!1;S._read=function(){w||(w=!0,T())},S._destroy=function(A,F){e(R(A),()=>i.nextTick(F,A),x=>i.nextTick(F,x||A))};async function R(A){const F=A!=null,x=typeof g.throw=="function";if(F&&x){const{value:D,done:O}=await g.throw(A);if(await D,O)return}if(typeof g.return=="function"){const{value:D}=await g.return();await D}}async function T(){for(;;){try{const{value:A,done:F}=y?await g.next():g.next();if(F)S.push(null);else{const x=A&&typeof A.then=="function"?await A:A;if(x===null)throw w=!1,new u;if(S.push(x))continue;w=!1}}catch(A){S.destroy(A)}break}}return S}return from_1=c,from_1}var readable,hasRequiredReadable;function requireReadable(){if(hasRequiredReadable)return readable;hasRequiredReadable=1;const i=requireBrowser$2(),{ArrayPrototypeIndexOf:e,NumberIsInteger:t,NumberIsNaN:n,NumberParseInt:s,ObjectDefineProperties:a,ObjectKeys:u,ObjectSetPrototypeOf:c,Promise:h,SafeSet:f,SymbolAsyncDispose:p,SymbolAsyncIterator:g,Symbol:y}=requirePrimordials();readable=de,de.ReadableState=xe;const{EventEmitter:S}=requireEvents(),{Stream:w,prependListener:R}=requireLegacy(),{Buffer:T}=requireBuffer(),{addAbortSignal:A}=requireAddAbortSignal(),F=requireEndOfStream();let x=requireUtil().debuglog("stream",M=>{x=M});const D=requireBuffer_list(),O=requireDestroy(),{getHighWaterMark:K,getDefaultHighWaterMark:z}=requireState(),{aggregateTwoErrors:X,codes:{ERR_INVALID_ARG_TYPE:Ee,ERR_METHOD_NOT_IMPLEMENTED:q,ERR_OUT_OF_RANGE:Y,ERR_STREAM_PUSH_AFTER_EOF:Te,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:re},AbortError:$e}=requireErrors(),{validateObject:ze}=requireValidators(),ye=y("kPaused"),{StringDecoder:Ve}=requireString_decoder(),pe=requireFrom();c(de.prototype,w.prototype),c(de,w);const De=()=>{},{errorOrDestroy:$}=O,G=1,ce=2,oe=4,Fe=8,Ue=16,Je=32,He=64,he=128,fe=256,Oe=512,ie=1024,j=2048,N=4096,L=8192,V=16384,ee=32768,ae=65536,ve=1<<17,J=1<<18;function me(M){return{enumerable:!1,get(){return(this.state&M)!==0},set(H){H?this.state|=M:this.state&=~M}}}a(xe.prototype,{objectMode:me(G),ended:me(ce),endEmitted:me(oe),reading:me(Fe),constructed:me(Ue),sync:me(Je),needReadable:me(He),emittedReadable:me(he),readableListening:me(fe),resumeScheduled:me(Oe),errorEmitted:me(ie),emitClose:me(j),autoDestroy:me(N),destroyed:me(L),closed:me(V),closeEmitted:me(ee),multiAwaitDrain:me(ae),readingMore:me(ve),dataEmitted:me(J)});function xe(M,H,Be){typeof Be!="boolean"&&(Be=H instanceof requireDuplex()),this.state=j|N|Ue|Je,M&&M.objectMode&&(this.state|=G),Be&&M&&M.readableObjectMode&&(this.state|=G),this.highWaterMark=M?K(this,M,"readableHighWaterMark",Be):z(!1),this.buffer=new D,this.length=0,this.pipes=[],this.flowing=null,this[ye]=null,M&&M.emitClose===!1&&(this.state&=~j),M&&M.autoDestroy===!1&&(this.state&=~N),this.errored=null,this.defaultEncoding=M&&M.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,M&&M.encoding&&(this.decoder=new Ve(M.encoding),this.encoding=M.encoding)}function de(M){if(!(this instanceof de))return new de(M);const H=this instanceof requireDuplex();this._readableState=new xe(M,this,H),M&&(typeof M.read=="function"&&(this._read=M.read),typeof M.destroy=="function"&&(this._destroy=M.destroy),typeof M.construct=="function"&&(this._construct=M.construct),M.signal&&!H&&A(M.signal,this)),w.call(this,M),O.construct(this,()=>{this._readableState.needReadable&&Ie(this,this._readableState)})}de.prototype.destroy=O.destroy,de.prototype._undestroy=O.undestroy,de.prototype._destroy=function(M,H){H(M)},de.prototype[S.captureRejectionSymbol]=function(M){this.destroy(M)},de.prototype[p]=function(){let M;return this.destroyed||(M=this.readableEnded?null:new $e,this.destroy(M)),new h((H,Be)=>F(this,qe=>qe&&qe!==M?Be(qe):H(null)))},de.prototype.push=function(M,H){return st(this,M,H,!1)},de.prototype.unshift=function(M,H){return st(this,M,H,!0)};function st(M,H,Be,qe){x("readableAddChunk",H);const at=M._readableState;let Ut;if((at.state&G)===0&&(typeof H=="string"?(Be=Be||at.defaultEncoding,at.encoding!==Be&&(qe&&at.encoding?H=T.from(H,Be).toString(at.encoding):(H=T.from(H,Be),Be=""))):H instanceof T?Be="":w._isUint8Array(H)?(H=w._uint8ArrayToBuffer(H),Be=""):H!=null&&(Ut=new Ee("chunk",["string","Buffer","Uint8Array"],H))),Ut)$(M,Ut);else if(H===null)at.state&=~Fe,P(M,at);else if((at.state&G)!==0||H&&H.length>0)if(qe)if((at.state&oe)!==0)$(M,new re);else{if(at.destroyed||at.errored)return!1;ft(M,at,H,!0)}else if(at.ended)$(M,new Te);else{if(at.destroyed||at.errored)return!1;at.state&=~Fe,at.decoder&&!Be?(H=at.decoder.write(H),at.objectMode||H.length!==0?ft(M,at,H,!1):Ie(M,at)):ft(M,at,H,!1)}else qe||(at.state&=~Fe,Ie(M,at));return!at.ended&&(at.length<at.highWaterMark||at.length===0)}function ft(M,H,Be,qe){H.flowing&&H.length===0&&!H.sync&&M.listenerCount("data")>0?((H.state&ae)!==0?H.awaitDrainWriters.clear():H.awaitDrainWriters=null,H.dataEmitted=!0,M.emit("data",Be)):(H.length+=H.objectMode?1:Be.length,qe?H.buffer.unshift(Be):H.buffer.push(Be),(H.state&He)!==0&&B(M)),Ie(M,H)}de.prototype.isPaused=function(){const M=this._readableState;return M[ye]===!0||M.flowing===!1},de.prototype.setEncoding=function(M){const H=new Ve(M);this._readableState.decoder=H,this._readableState.encoding=this._readableState.decoder.encoding;const Be=this._readableState.buffer;let qe="";for(const at of Be)qe+=H.write(at);return Be.clear(),qe!==""&&Be.push(qe),this._readableState.length=qe.length,this};const Ge=1073741824;function pt(M){if(M>Ge)throw new Y("size","<= 1GiB",M);return M--,M|=M>>>1,M|=M>>>2,M|=M>>>4,M|=M>>>8,M|=M>>>16,M++,M}function Z(M,H){return M<=0||H.length===0&&H.ended?0:(H.state&G)!==0?1:n(M)?H.flowing&&H.length?H.buffer.first().length:H.length:M<=H.length?M:H.ended?H.length:0}de.prototype.read=function(M){x("read",M),M===void 0?M=NaN:t(M)||(M=s(M,10));const H=this._readableState,Be=M;if(M>H.highWaterMark&&(H.highWaterMark=pt(M)),M!==0&&(H.state&=~he),M===0&&H.needReadable&&((H.highWaterMark!==0?H.length>=H.highWaterMark:H.length>0)||H.ended))return x("read: emitReadable",H.length,H.ended),H.length===0&&H.ended?vr(this):B(this),null;if(M=Z(M,H),M===0&&H.ended)return H.length===0&&vr(this),null;let qe=(H.state&He)!==0;if(x("need readable",qe),(H.length===0||H.length-M<H.highWaterMark)&&(qe=!0,x("length less than watermark",qe)),H.ended||H.reading||H.destroyed||H.errored||!H.constructed)qe=!1,x("reading, ended or constructing",qe);else if(qe){x("do read"),H.state|=Fe|Je,H.length===0&&(H.state|=He);try{this._read(H.highWaterMark)}catch(Ut){$(this,Ut)}H.state&=~Je,H.reading||(M=Z(Be,H))}let at;return M>0?at=Dt(M,H):at=null,at===null?(H.needReadable=H.length<=H.highWaterMark,M=0):(H.length-=M,H.multiAwaitDrain?H.awaitDrainWriters.clear():H.awaitDrainWriters=null),H.length===0&&(H.ended||(H.needReadable=!0),Be!==M&&H.ended&&vr(this)),at!==null&&!H.errorEmitted&&!H.closeEmitted&&(H.dataEmitted=!0,this.emit("data",at)),at};function P(M,H){if(x("onEofChunk"),!H.ended){if(H.decoder){const Be=H.decoder.end();Be&&Be.length&&(H.buffer.push(Be),H.length+=H.objectMode?1:Be.length)}H.ended=!0,H.sync?B(M):(H.needReadable=!1,H.emittedReadable=!0,U(M))}}function B(M){const H=M._readableState;x("emitReadable",H.needReadable,H.emittedReadable),H.needReadable=!1,H.emittedReadable||(x("emitReadable",H.flowing),H.emittedReadable=!0,i.nextTick(U,M))}function U(M){const H=M._readableState;x("emitReadable_",H.destroyed,H.length,H.ended),!H.destroyed&&!H.errored&&(H.length||H.ended)&&(M.emit("readable"),H.emittedReadable=!1),H.needReadable=!H.flowing&&!H.ended&&H.length<=H.highWaterMark,Ft(M)}function Ie(M,H){!H.readingMore&&H.constructed&&(H.readingMore=!0,i.nextTick(Me,M,H))}function Me(M,H){for(;!H.reading&&!H.ended&&(H.length<H.highWaterMark||H.flowing&&H.length===0);){const Be=H.length;if(x("maybeReadMore read 0"),M.read(0),Be===H.length)break}H.readingMore=!1}de.prototype._read=function(M){throw new q("_read()")},de.prototype.pipe=function(M,H){const Be=this,qe=this._readableState;qe.pipes.length===1&&(qe.multiAwaitDrain||(qe.multiAwaitDrain=!0,qe.awaitDrainWriters=new f(qe.awaitDrainWriters?[qe.awaitDrainWriters]:[]))),qe.pipes.push(M),x("pipe count=%d opts=%j",qe.pipes.length,H);const Ut=(!H||H.end!==!1)&&M!==i.stdout&&M!==i.stderr?on:Lt;qe.endEmitted?i.nextTick(Ut):Be.once("end",Ut),M.on("unpipe",Ht);function Ht(Rt,hr){x("onunpipe"),Rt===Be&&hr&&hr.hasUnpiped===!1&&(hr.hasUnpiped=!0,bn())}function on(){x("onend"),M.end()}let Sr,sr=!1;function bn(){x("cleanup"),M.removeListener("close",Dr),M.removeListener("finish",Mr),Sr&&M.removeListener("drain",Sr),M.removeListener("error",fr),M.removeListener("unpipe",Ht),Be.removeListener("end",on),Be.removeListener("end",Lt),Be.removeListener("data",qt),sr=!0,Sr&&qe.awaitDrainWriters&&(!M._writableState||M._writableState.needDrain)&&Sr()}function Hr(){sr||(qe.pipes.length===1&&qe.pipes[0]===M?(x("false write response, pause",0),qe.awaitDrainWriters=M,qe.multiAwaitDrain=!1):qe.pipes.length>1&&qe.pipes.includes(M)&&(x("false write response, pause",qe.awaitDrainWriters.size),qe.awaitDrainWriters.add(M)),Be.pause()),Sr||(Sr=Pe(Be,M),M.on("drain",Sr))}Be.on("data",qt);function qt(Rt){x("ondata");const hr=M.write(Rt);x("dest.write",hr),hr===!1&&Hr()}function fr(Rt){if(x("onerror",Rt),Lt(),M.removeListener("error",fr),M.listenerCount("error")===0){const hr=M._writableState||M._readableState;hr&&!hr.errorEmitted?$(M,Rt):M.emit("error",Rt)}}R(M,"error",fr);function Dr(){M.removeListener("finish",Mr),Lt()}M.once("close",Dr);function Mr(){x("onfinish"),M.removeListener("close",Dr),Lt()}M.once("finish",Mr);function Lt(){x("unpipe"),Be.unpipe(M)}return M.emit("pipe",Be),M.writableNeedDrain===!0?Hr():qe.flowing||(x("pipe resume"),Be.resume()),M};function Pe(M,H){return function(){const qe=M._readableState;qe.awaitDrainWriters===H?(x("pipeOnDrain",1),qe.awaitDrainWriters=null):qe.multiAwaitDrain&&(x("pipeOnDrain",qe.awaitDrainWriters.size),qe.awaitDrainWriters.delete(H)),(!qe.awaitDrainWriters||qe.awaitDrainWriters.size===0)&&M.listenerCount("data")&&M.resume()}}de.prototype.unpipe=function(M){const H=this._readableState,Be={hasUnpiped:!1};if(H.pipes.length===0)return this;if(!M){const at=H.pipes;H.pipes=[],this.pause();for(let Ut=0;Ut<at.length;Ut++)at[Ut].emit("unpipe",this,{hasUnpiped:!1});return this}const qe=e(H.pipes,M);return qe===-1?this:(H.pipes.splice(qe,1),H.pipes.length===0&&this.pause(),M.emit("unpipe",this,Be),this)},de.prototype.on=function(M,H){const Be=w.prototype.on.call(this,M,H),qe=this._readableState;return M==="data"?(qe.readableListening=this.listenerCount("readable")>0,qe.flowing!==!1&&this.resume()):M==="readable"&&!qe.endEmitted&&!qe.readableListening&&(qe.readableListening=qe.needReadable=!0,qe.flowing=!1,qe.emittedReadable=!1,x("on readable",qe.length,qe.reading),qe.length?B(this):qe.reading||i.nextTick(_t,this)),Be},de.prototype.addListener=de.prototype.on,de.prototype.removeListener=function(M,H){const Be=w.prototype.removeListener.call(this,M,H);return M==="readable"&&i.nextTick(gt,this),Be},de.prototype.off=de.prototype.removeListener,de.prototype.removeAllListeners=function(M){const H=w.prototype.removeAllListeners.apply(this,arguments);return(M==="readable"||M===void 0)&&i.nextTick(gt,this),H};function gt(M){const H=M._readableState;H.readableListening=M.listenerCount("readable")>0,H.resumeScheduled&&H[ye]===!1?H.flowing=!0:M.listenerCount("data")>0?M.resume():H.readableListening||(H.flowing=null)}function _t(M){x("readable nexttick read 0"),M.read(0)}de.prototype.resume=function(){const M=this._readableState;return M.flowing||(x("resume"),M.flowing=!M.readableListening,Tt(this,M)),M[ye]=!1,this};function Tt(M,H){H.resumeScheduled||(H.resumeScheduled=!0,i.nextTick(kt,M,H))}function kt(M,H){x("resume",H.reading),H.reading||M.read(0),H.resumeScheduled=!1,M.emit("resume"),Ft(M),H.flowing&&!H.reading&&M.read(0)}de.prototype.pause=function(){return x("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(x("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[ye]=!0,this};function Ft(M){const H=M._readableState;for(x("flow",H.flowing);H.flowing&&M.read()!==null;);}de.prototype.wrap=function(M){let H=!1;M.on("data",qe=>{!this.push(qe)&&M.pause&&(H=!0,M.pause())}),M.on("end",()=>{this.push(null)}),M.on("error",qe=>{$(this,qe)}),M.on("close",()=>{this.destroy()}),M.on("destroy",()=>{this.destroy()}),this._read=()=>{H&&M.resume&&(H=!1,M.resume())};const Be=u(M);for(let qe=1;qe<Be.length;qe++){const at=Be[qe];this[at]===void 0&&typeof M[at]=="function"&&(this[at]=M[at].bind(M))}return this},de.prototype[g]=function(){return sn(this)},de.prototype.iterator=function(M){return M!==void 0&&ze(M,"options"),sn(this,M)};function sn(M,H){typeof M.read!="function"&&(M=de.wrap(M,{objectMode:!0}));const Be=Yt(M,H);return Be.stream=M,Be}async function*Yt(M,H){let Be=De;function qe(Ht){this===M?(Be(),Be=De):Be=Ht}M.on("readable",qe);let at;const Ut=F(M,{writable:!1},Ht=>{at=Ht?X(at,Ht):null,Be(),Be=De});try{for(;;){const Ht=M.destroyed?null:M.read();if(Ht!==null)yield Ht;else{if(at)throw at;if(at===null)return;await new h(qe)}}}catch(Ht){throw at=X(at,Ht),at}finally{(at||H?.destroyOnReturn!==!1)&&(at===void 0||M._readableState.autoDestroy)?O.destroyer(M,null):(M.off("readable",qe),Ut())}}a(de.prototype,{readable:{__proto__:null,get(){const M=this._readableState;return!!M&&M.readable!==!1&&!M.destroyed&&!M.errorEmitted&&!M.endEmitted},set(M){this._readableState&&(this._readableState.readable=!!M)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(M){this._readableState&&(this._readableState.flowing=M)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(M){this._readableState&&(this._readableState.destroyed=M)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),a(xe.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[ye]!==!1},set(M){this[ye]=!!M}}}),de._fromList=Dt;function Dt(M,H){if(H.length===0)return null;let Be;return H.objectMode?Be=H.buffer.shift():!M||M>=H.length?(H.decoder?Be=H.buffer.join(""):H.buffer.length===1?Be=H.buffer.first():Be=H.buffer.concat(H.length),H.buffer.clear()):Be=H.buffer.consume(M,H.decoder),Be}function vr(M){const H=M._readableState;x("endReadable",H.endEmitted),H.endEmitted||(H.ended=!0,i.nextTick(Bt,H,M))}function Bt(M,H){if(x("endReadableNT",M.endEmitted,M.length),!M.errored&&!M.closeEmitted&&!M.endEmitted&&M.length===0){if(M.endEmitted=!0,H.emit("end"),H.writable&&H.allowHalfOpen===!1)i.nextTick(dr,H);else if(M.autoDestroy){const Be=H._writableState;(!Be||Be.autoDestroy&&(Be.finished||Be.writable===!1))&&H.destroy()}}}function dr(M){M.writable&&!M.writableEnded&&!M.destroyed&&M.end()}de.from=function(M,H){return pe(de,M,H)};let nr;function Vr(){return nr===void 0&&(nr={}),nr}return de.fromWeb=function(M,H){return Vr().newStreamReadableFromReadableStream(M,H)},de.toWeb=function(M,H){return Vr().newReadableStreamFromStreamReadable(M,H)},de.wrap=function(M,H){var Be,qe;return new de({objectMode:(Be=(qe=M.readableObjectMode)!==null&&qe!==void 0?qe:M.objectMode)!==null&&Be!==void 0?Be:!0,...H,destroy(at,Ut){O.destroyer(M,at),Ut(at)}}).wrap(M)},readable}var writable,hasRequiredWritable;function requireWritable(){if(hasRequiredWritable)return writable;hasRequiredWritable=1;const i=requireBrowser$2(),{ArrayPrototypeSlice:e,Error:t,FunctionPrototypeSymbolHasInstance:n,ObjectDefineProperty:s,ObjectDefineProperties:a,ObjectSetPrototypeOf:u,StringPrototypeToLowerCase:c,Symbol:h,SymbolHasInstance:f}=requirePrimordials();writable=ze,ze.WritableState=re;const{EventEmitter:p}=requireEvents(),g=requireLegacy().Stream,{Buffer:y}=requireBuffer(),S=requireDestroy(),{addAbortSignal:w}=requireAddAbortSignal(),{getHighWaterMark:R,getDefaultHighWaterMark:T}=requireState(),{ERR_INVALID_ARG_TYPE:A,ERR_METHOD_NOT_IMPLEMENTED:F,ERR_MULTIPLE_CALLBACK:x,ERR_STREAM_CANNOT_PIPE:D,ERR_STREAM_DESTROYED:O,ERR_STREAM_ALREADY_FINISHED:K,ERR_STREAM_NULL_VALUES:z,ERR_STREAM_WRITE_AFTER_END:X,ERR_UNKNOWN_ENCODING:Ee}=requireErrors().codes,{errorOrDestroy:q}=S;u(ze.prototype,g.prototype),u(ze,g);function Y(){}const Te=h("kOnFinished");function re(N,L,V){typeof V!="boolean"&&(V=L instanceof requireDuplex()),this.objectMode=!!(N&&N.objectMode),V&&(this.objectMode=this.objectMode||!!(N&&N.writableObjectMode)),this.highWaterMark=N?R(this,N,"writableHighWaterMark",V):T(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const ee=!!(N&&N.decodeStrings===!1);this.decodeStrings=!ee,this.defaultEncoding=N&&N.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=$.bind(void 0,L),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,$e(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!N||N.emitClose!==!1,this.autoDestroy=!N||N.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[Te]=[]}function $e(N){N.buffered=[],N.bufferedIndex=0,N.allBuffers=!0,N.allNoop=!0}re.prototype.getBuffer=function(){return e(this.buffered,this.bufferedIndex)},s(re.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function ze(N){const L=this instanceof requireDuplex();if(!L&&!n(ze,this))return new ze(N);this._writableState=new re(N,this,L),N&&(typeof N.write=="function"&&(this._write=N.write),typeof N.writev=="function"&&(this._writev=N.writev),typeof N.destroy=="function"&&(this._destroy=N.destroy),typeof N.final=="function"&&(this._final=N.final),typeof N.construct=="function"&&(this._construct=N.construct),N.signal&&w(N.signal,this)),g.call(this,N),S.construct(this,()=>{const V=this._writableState;V.writing||Fe(this,V),he(this,V)})}s(ze,f,{__proto__:null,value:function(N){return n(this,N)?!0:this!==ze?!1:N&&N._writableState instanceof re}}),ze.prototype.pipe=function(){q(this,new D)};function ye(N,L,V,ee){const ae=N._writableState;if(typeof V=="function")ee=V,V=ae.defaultEncoding;else{if(!V)V=ae.defaultEncoding;else if(V!=="buffer"&&!y.isEncoding(V))throw new Ee(V);typeof ee!="function"&&(ee=Y)}if(L===null)throw new z;if(!ae.objectMode)if(typeof L=="string")ae.decodeStrings!==!1&&(L=y.from(L,V),V="buffer");else if(L instanceof y)V="buffer";else if(g._isUint8Array(L))L=g._uint8ArrayToBuffer(L),V="buffer";else throw new A("chunk",["string","Buffer","Uint8Array"],L);let ve;return ae.ending?ve=new X:ae.destroyed&&(ve=new O("write")),ve?(i.nextTick(ee,ve),q(N,ve,!0),ve):(ae.pendingcb++,Ve(N,ae,L,V,ee))}ze.prototype.write=function(N,L,V){return ye(this,N,L,V)===!0},ze.prototype.cork=function(){this._writableState.corked++},ze.prototype.uncork=function(){const N=this._writableState;N.corked&&(N.corked--,N.writing||Fe(this,N))},ze.prototype.setDefaultEncoding=function(L){if(typeof L=="string"&&(L=c(L)),!y.isEncoding(L))throw new Ee(L);return this._writableState.defaultEncoding=L,this};function Ve(N,L,V,ee,ae){const ve=L.objectMode?1:V.length;L.length+=ve;const J=L.length<L.highWaterMark;return J||(L.needDrain=!0),L.writing||L.corked||L.errored||!L.constructed?(L.buffered.push({chunk:V,encoding:ee,callback:ae}),L.allBuffers&&ee!=="buffer"&&(L.allBuffers=!1),L.allNoop&&ae!==Y&&(L.allNoop=!1)):(L.writelen=ve,L.writecb=ae,L.writing=!0,L.sync=!0,N._write(V,ee,L.onwrite),L.sync=!1),J&&!L.errored&&!L.destroyed}function pe(N,L,V,ee,ae,ve,J){L.writelen=ee,L.writecb=J,L.writing=!0,L.sync=!0,L.destroyed?L.onwrite(new O("write")):V?N._writev(ae,L.onwrite):N._write(ae,ve,L.onwrite),L.sync=!1}function De(N,L,V,ee){--L.pendingcb,ee(V),oe(L),q(N,V)}function $(N,L){const V=N._writableState,ee=V.sync,ae=V.writecb;if(typeof ae!="function"){q(N,new x);return}V.writing=!1,V.writecb=null,V.length-=V.writelen,V.writelen=0,L?(L.stack,V.errored||(V.errored=L),N._readableState&&!N._readableState.errored&&(N._readableState.errored=L),ee?i.nextTick(De,N,V,L,ae):De(N,V,L,ae)):(V.buffered.length>V.bufferedIndex&&Fe(N,V),ee?V.afterWriteTickInfo!==null&&V.afterWriteTickInfo.cb===ae?V.afterWriteTickInfo.count++:(V.afterWriteTickInfo={count:1,cb:ae,stream:N,state:V},i.nextTick(G,V.afterWriteTickInfo)):ce(N,V,1,ae))}function G({stream:N,state:L,count:V,cb:ee}){return L.afterWriteTickInfo=null,ce(N,L,V,ee)}function ce(N,L,V,ee){for(!L.ending&&!N.destroyed&&L.length===0&&L.needDrain&&(L.needDrain=!1,N.emit("drain"));V-- >0;)L.pendingcb--,ee();L.destroyed&&oe(L),he(N,L)}function oe(N){if(N.writing)return;for(let ae=N.bufferedIndex;ae<N.buffered.length;++ae){var L;const{chunk:ve,callback:J}=N.buffered[ae],me=N.objectMode?1:ve.length;N.length-=me,J((L=N.errored)!==null&&L!==void 0?L:new O("write"))}const V=N[Te].splice(0);for(let ae=0;ae<V.length;ae++){var ee;V[ae]((ee=N.errored)!==null&&ee!==void 0?ee:new O("end"))}$e(N)}function Fe(N,L){if(L.corked||L.bufferProcessing||L.destroyed||!L.constructed)return;const{buffered:V,bufferedIndex:ee,objectMode:ae}=L,ve=V.length-ee;if(!ve)return;let J=ee;if(L.bufferProcessing=!0,ve>1&&N._writev){L.pendingcb-=ve-1;const me=L.allNoop?Y:de=>{for(let st=J;st<V.length;++st)V[st].callback(de)},xe=L.allNoop&&J===0?V:e(V,J);xe.allBuffers=L.allBuffers,pe(N,L,!0,L.length,xe,"",me),$e(L)}else{do{const{chunk:me,encoding:xe,callback:de}=V[J];V[J++]=null;const st=ae?1:me.length;pe(N,L,!1,st,me,xe,de)}while(J<V.length&&!L.writing);J===V.length?$e(L):J>256?(V.splice(0,J),L.bufferedIndex=0):L.bufferedIndex=J}L.bufferProcessing=!1}ze.prototype._write=function(N,L,V){if(this._writev)this._writev([{chunk:N,encoding:L}],V);else throw new F("_write()")},ze.prototype._writev=null,ze.prototype.end=function(N,L,V){const ee=this._writableState;typeof N=="function"?(V=N,N=null,L=null):typeof L=="function"&&(V=L,L=null);let ae;if(N!=null){const ve=ye(this,N,L);ve instanceof t&&(ae=ve)}return ee.corked&&(ee.corked=1,this.uncork()),ae||(!ee.errored&&!ee.ending?(ee.ending=!0,he(this,ee,!0),ee.ended=!0):ee.finished?ae=new K("end"):ee.destroyed&&(ae=new O("end"))),typeof V=="function"&&(ae||ee.finished?i.nextTick(V,ae):ee[Te].push(V)),this};function Ue(N){return N.ending&&!N.destroyed&&N.constructed&&N.length===0&&!N.errored&&N.buffered.length===0&&!N.finished&&!N.writing&&!N.errorEmitted&&!N.closeEmitted}function Je(N,L){let V=!1;function ee(ae){if(V){q(N,ae??x());return}if(V=!0,L.pendingcb--,ae){const ve=L[Te].splice(0);for(let J=0;J<ve.length;J++)ve[J](ae);q(N,ae,L.sync)}else Ue(L)&&(L.prefinished=!0,N.emit("prefinish"),L.pendingcb++,i.nextTick(fe,N,L))}L.sync=!0,L.pendingcb++;try{N._final(ee)}catch(ae){ee(ae)}L.sync=!1}function He(N,L){!L.prefinished&&!L.finalCalled&&(typeof N._final=="function"&&!L.destroyed?(L.finalCalled=!0,Je(N,L)):(L.prefinished=!0,N.emit("prefinish")))}function he(N,L,V){Ue(L)&&(He(N,L),L.pendingcb===0&&(V?(L.pendingcb++,i.nextTick((ee,ae)=>{Ue(ae)?fe(ee,ae):ae.pendingcb--},N,L)):Ue(L)&&(L.pendingcb++,fe(N,L))))}function fe(N,L){L.pendingcb--,L.finished=!0;const V=L[Te].splice(0);for(let ee=0;ee<V.length;ee++)V[ee]();if(N.emit("finish"),L.autoDestroy){const ee=N._readableState;(!ee||ee.autoDestroy&&(ee.endEmitted||ee.readable===!1))&&N.destroy()}}a(ze.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(N){this._writableState&&(this._writableState.destroyed=N)}},writable:{__proto__:null,get(){const N=this._writableState;return!!N&&N.writable!==!1&&!N.destroyed&&!N.errored&&!N.ending&&!N.ended},set(N){this._writableState&&(this._writableState.writable=!!N)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){const N=this._writableState;return N?!N.destroyed&&!N.ending&&N.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});const Oe=S.destroy;ze.prototype.destroy=function(N,L){const V=this._writableState;return!V.destroyed&&(V.bufferedIndex<V.buffered.length||V[Te].length)&&i.nextTick(oe,V),Oe.call(this,N,L),this},ze.prototype._undestroy=S.undestroy,ze.prototype._destroy=function(N,L){L(N)},ze.prototype[p.captureRejectionSymbol]=function(N){this.destroy(N)};let ie;function j(){return ie===void 0&&(ie={}),ie}return ze.fromWeb=function(N,L){return j().newStreamWritableFromWritableStream(N,L)},ze.toWeb=function(N){return j().newWritableStreamFromStreamWritable(N)},writable}var duplexify,hasRequiredDuplexify;function requireDuplexify(){if(hasRequiredDuplexify)return duplexify;hasRequiredDuplexify=1;const i=requireBrowser$2(),e=requireBuffer(),{isReadable:t,isWritable:n,isIterable:s,isNodeStream:a,isReadableNodeStream:u,isWritableNodeStream:c,isDuplexNodeStream:h,isReadableStream:f,isWritableStream:p}=requireUtils(),g=requireEndOfStream(),{AbortError:y,codes:{ERR_INVALID_ARG_TYPE:S,ERR_INVALID_RETURN_VALUE:w}}=requireErrors(),{destroyer:R}=requireDestroy(),T=requireDuplex(),A=requireReadable(),F=requireWritable(),{createDeferredPromise:x}=requireUtil(),D=requireFrom(),O=globalThis.Blob||e.Blob,K=typeof O<"u"?function(re){return re instanceof O}:function(re){return!1},z=globalThis.AbortController||requireBrowser$3().AbortController,{FunctionPrototypeCall:X}=requirePrimordials();class Ee extends T{constructor(re){super(re),re?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),re?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}duplexify=function Te(re,$e){if(h(re))return re;if(u(re))return Y({readable:re});if(c(re))return Y({writable:re});if(a(re))return Y({writable:!1,readable:!1});if(f(re))return Y({readable:A.fromWeb(re)});if(p(re))return Y({writable:F.fromWeb(re)});if(typeof re=="function"){const{value:ye,write:Ve,final:pe,destroy:De}=q(re);if(s(ye))return D(Ee,ye,{objectMode:!0,write:Ve,final:pe,destroy:De});const $=ye?.then;if(typeof $=="function"){let G;const ce=X($,ye,oe=>{if(oe!=null)throw new w("nully","body",oe)},oe=>{R(G,oe)});return G=new Ee({objectMode:!0,readable:!1,write:Ve,final(oe){pe(async()=>{try{await ce,i.nextTick(oe,null)}catch(Fe){i.nextTick(oe,Fe)}})},destroy:De})}throw new w("Iterable, AsyncIterable or AsyncFunction",$e,ye)}if(K(re))return Te(re.arrayBuffer());if(s(re))return D(Ee,re,{objectMode:!0,writable:!1});if(f(re?.readable)&&p(re?.writable))return Ee.fromWeb(re);if(typeof re?.writable=="object"||typeof re?.readable=="object"){const ye=re!=null&&re.readable?u(re?.readable)?re?.readable:Te(re.readable):void 0,Ve=re!=null&&re.writable?c(re?.writable)?re?.writable:Te(re.writable):void 0;return Y({readable:ye,writable:Ve})}const ze=re?.then;if(typeof ze=="function"){let ye;return X(ze,re,Ve=>{Ve!=null&&ye.push(Ve),ye.push(null)},Ve=>{R(ye,Ve)}),ye=new Ee({objectMode:!0,writable:!1,read(){}})}throw new S($e,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],re)};function q(Te){let{promise:re,resolve:$e}=x();const ze=new z,ye=ze.signal;return{value:Te((async function*(){for(;;){const pe=re;re=null;const{chunk:De,done:$,cb:G}=await pe;if(i.nextTick(G),$)return;if(ye.aborted)throw new y(void 0,{cause:ye.reason});({promise:re,resolve:$e}=x()),yield De}})(),{signal:ye}),write(pe,De,$){const G=$e;$e=null,G({chunk:pe,done:!1,cb:$})},final(pe){const De=$e;$e=null,De({done:!0,cb:pe})},destroy(pe,De){ze.abort(),De(pe)}}}function Y(Te){const re=Te.readable&&typeof Te.readable.read!="function"?A.wrap(Te.readable):Te.readable,$e=Te.writable;let ze=!!t(re),ye=!!n($e),Ve,pe,De,$,G;function ce(oe){const Fe=$;$=null,Fe?Fe(oe):oe&&G.destroy(oe)}return G=new Ee({readableObjectMode:!!(re!=null&&re.readableObjectMode),writableObjectMode:!!($e!=null&&$e.writableObjectMode),readable:ze,writable:ye}),ye&&(g($e,oe=>{ye=!1,oe&&R(re,oe),ce(oe)}),G._write=function(oe,Fe,Ue){$e.write(oe,Fe)?Ue():Ve=Ue},G._final=function(oe){$e.end(),pe=oe},$e.on("drain",function(){if(Ve){const oe=Ve;Ve=null,oe()}}),$e.on("finish",function(){if(pe){const oe=pe;pe=null,oe()}})),ze&&(g(re,oe=>{ze=!1,oe&&R(re,oe),ce(oe)}),re.on("readable",function(){if(De){const oe=De;De=null,oe()}}),re.on("end",function(){G.push(null)}),G._read=function(){for(;;){const oe=re.read();if(oe===null){De=G._read;return}if(!G.push(oe))return}}),G._destroy=function(oe,Fe){!oe&&$!==null&&(oe=new y),De=null,Ve=null,pe=null,$===null?Fe(oe):($=Fe,R($e,oe),R(re,oe))},G}return duplexify}var duplex,hasRequiredDuplex;function requireDuplex(){if(hasRequiredDuplex)return duplex;hasRequiredDuplex=1;const{ObjectDefineProperties:i,ObjectGetOwnPropertyDescriptor:e,ObjectKeys:t,ObjectSetPrototypeOf:n}=requirePrimordials();duplex=u;const s=requireReadable(),a=requireWritable();n(u.prototype,s.prototype),n(u,s);{const p=t(a.prototype);for(let g=0;g<p.length;g++){const y=p[g];u.prototype[y]||(u.prototype[y]=a.prototype[y])}}function u(p){if(!(this instanceof u))return new u(p);s.call(this,p),a.call(this,p),p?(this.allowHalfOpen=p.allowHalfOpen!==!1,p.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),p.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}i(u.prototype,{writable:{__proto__:null,...e(a.prototype,"writable")},writableHighWaterMark:{__proto__:null,...e(a.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...e(a.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...e(a.prototype,"writableBuffer")},writableLength:{__proto__:null,...e(a.prototype,"writableLength")},writableFinished:{__proto__:null,...e(a.prototype,"writableFinished")},writableCorked:{__proto__:null,...e(a.prototype,"writableCorked")},writableEnded:{__proto__:null,...e(a.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...e(a.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(p){this._readableState&&this._writableState&&(this._readableState.destroyed=p,this._writableState.destroyed=p)}}});let c;function h(){return c===void 0&&(c={}),c}u.fromWeb=function(p,g){return h().newStreamDuplexFromReadableWritablePair(p,g)},u.toWeb=function(p){return h().newReadableWritablePairFromDuplex(p)};let f;return u.from=function(p){return f||(f=requireDuplexify()),f(p,"body")},duplex}var transform$1,hasRequiredTransform;function requireTransform(){if(hasRequiredTransform)return transform$1;hasRequiredTransform=1;const{ObjectSetPrototypeOf:i,Symbol:e}=requirePrimordials();transform$1=u;const{ERR_METHOD_NOT_IMPLEMENTED:t}=requireErrors().codes,n=requireDuplex(),{getHighWaterMark:s}=requireState();i(u.prototype,n.prototype),i(u,n);const a=e("kCallback");function u(f){if(!(this instanceof u))return new u(f);const p=f?s(this,f,"readableHighWaterMark",!0):null;p===0&&(f={...f,highWaterMark:null,readableHighWaterMark:p,writableHighWaterMark:f.writableHighWaterMark||0}),n.call(this,f),this._readableState.sync=!1,this[a]=null,f&&(typeof f.transform=="function"&&(this._transform=f.transform),typeof f.flush=="function"&&(this._flush=f.flush)),this.on("prefinish",h)}function c(f){typeof this._flush=="function"&&!this.destroyed?this._flush((p,g)=>{if(p){f?f(p):this.destroy(p);return}g!=null&&this.push(g),this.push(null),f&&f()}):(this.push(null),f&&f())}function h(){this._final!==c&&c.call(this)}return u.prototype._final=c,u.prototype._transform=function(f,p,g){throw new t("_transform()")},u.prototype._write=function(f,p,g){const y=this._readableState,S=this._writableState,w=y.length;this._transform(f,p,(R,T)=>{if(R){g(R);return}T!=null&&this.push(T),S.ended||w===y.length||y.length<y.highWaterMark?g():this[a]=g})},u.prototype._read=function(){if(this[a]){const f=this[a];this[a]=null,f()}},transform$1}var passthrough,hasRequiredPassthrough;function requirePassthrough(){if(hasRequiredPassthrough)return passthrough;hasRequiredPassthrough=1;const{ObjectSetPrototypeOf:i}=requirePrimordials();passthrough=t;const e=requireTransform();i(t.prototype,e.prototype),i(t,e);function t(n){if(!(this instanceof t))return new t(n);e.call(this,n)}return t.prototype._transform=function(n,s,a){a(null,n)},passthrough}var pipeline_1,hasRequiredPipeline;function requirePipeline(){if(hasRequiredPipeline)return pipeline_1;hasRequiredPipeline=1;const i=requireBrowser$2(),{ArrayIsArray:e,Promise:t,SymbolAsyncIterator:n,SymbolDispose:s}=requirePrimordials(),a=requireEndOfStream(),{once:u}=requireUtil(),c=requireDestroy(),h=requireDuplex(),{aggregateTwoErrors:f,codes:{ERR_INVALID_ARG_TYPE:p,ERR_INVALID_RETURN_VALUE:g,ERR_MISSING_ARGS:y,ERR_STREAM_DESTROYED:S,ERR_STREAM_PREMATURE_CLOSE:w},AbortError:R}=requireErrors(),{validateFunction:T,validateAbortSignal:A}=requireValidators(),{isIterable:F,isReadable:x,isReadableNodeStream:D,isNodeStream:O,isTransformStream:K,isWebStream:z,isReadableStream:X,isReadableFinished:Ee}=requireUtils(),q=globalThis.AbortController||requireBrowser$3().AbortController;let Y,Te,re;function $e(oe,Fe,Ue){let Je=!1;oe.on("close",()=>{Je=!0});const He=a(oe,{readable:Fe,writable:Ue},he=>{Je=!he});return{destroy:he=>{Je||(Je=!0,c.destroyer(oe,he||new S("pipe")))},cleanup:He}}function ze(oe){return T(oe[oe.length-1],"streams[stream.length - 1]"),oe.pop()}function ye(oe){if(F(oe))return oe;if(D(oe))return Ve(oe);throw new p("val",["Readable","Iterable","AsyncIterable"],oe)}async function*Ve(oe){Te||(Te=requireReadable()),yield*Te.prototype[n].call(oe)}async function pe(oe,Fe,Ue,{end:Je}){let He,he=null;const fe=j=>{if(j&&(He=j),he){const N=he;he=null,N()}},Oe=()=>new t((j,N)=>{He?N(He):he=()=>{He?N(He):j()}});Fe.on("drain",fe);const ie=a(Fe,{readable:!1},fe);try{Fe.writableNeedDrain&&await Oe();for await(const j of oe)Fe.write(j)||await Oe();Je&&(Fe.end(),await Oe()),Ue()}catch(j){Ue(He!==j?f(He,j):j)}finally{ie(),Fe.off("drain",fe)}}async function De(oe,Fe,Ue,{end:Je}){K(Fe)&&(Fe=Fe.writable);const He=Fe.getWriter();try{for await(const he of oe)await He.ready,He.write(he).catch(()=>{});await He.ready,Je&&await He.close(),Ue()}catch(he){try{await He.abort(he),Ue(he)}catch(fe){Ue(fe)}}}function $(...oe){return G(oe,u(ze(oe)))}function G(oe,Fe,Ue){if(oe.length===1&&e(oe[0])&&(oe=oe[0]),oe.length<2)throw new y("streams");const Je=new q,He=Je.signal,he=Ue?.signal,fe=[];A(he,"options.signal");function Oe(){ae(new R)}re=re||requireUtil().addAbortListener;let ie;he&&(ie=re(he,Oe));let j,N;const L=[];let V=0;function ee(xe){ae(xe,--V===0)}function ae(xe,de){var st;if(xe&&(!j||j.code==="ERR_STREAM_PREMATURE_CLOSE")&&(j=xe),!(!j&&!de)){for(;L.length;)L.shift()(j);(st=ie)===null||st===void 0||st[s](),Je.abort(),de&&(j||fe.forEach(ft=>ft()),i.nextTick(Fe,j,N))}}let ve;for(let xe=0;xe<oe.length;xe++){const de=oe[xe],st=xe<oe.length-1,ft=xe>0,Ge=st||Ue?.end!==!1,pt=xe===oe.length-1;if(O(de)){let Z=function(P){P&&P.name!=="AbortError"&&P.code!=="ERR_STREAM_PREMATURE_CLOSE"&&ee(P)};if(Ge){const{destroy:P,cleanup:B}=$e(de,st,ft);L.push(P),x(de)&&pt&&fe.push(B)}de.on("error",Z),x(de)&&pt&&fe.push(()=>{de.removeListener("error",Z)})}if(xe===0)if(typeof de=="function"){if(ve=de({signal:He}),!F(ve))throw new g("Iterable, AsyncIterable or Stream","source",ve)}else F(de)||D(de)||K(de)?ve=de:ve=h.from(de);else if(typeof de=="function"){if(K(ve)){var J;ve=ye((J=ve)===null||J===void 0?void 0:J.readable)}else ve=ye(ve);if(ve=de(ve,{signal:He}),st){if(!F(ve,!0))throw new g("AsyncIterable",`transform[${xe-1}]`,ve)}else{var me;Y||(Y=requirePassthrough());const Z=new Y({objectMode:!0}),P=(me=ve)===null||me===void 0?void 0:me.then;if(typeof P=="function")V++,P.call(ve,Ie=>{N=Ie,Ie!=null&&Z.write(Ie),Ge&&Z.end(),i.nextTick(ee)},Ie=>{Z.destroy(Ie),i.nextTick(ee,Ie)});else if(F(ve,!0))V++,pe(ve,Z,ee,{end:Ge});else if(X(ve)||K(ve)){const Ie=ve.readable||ve;V++,pe(Ie,Z,ee,{end:Ge})}else throw new g("AsyncIterable or Promise","destination",ve);ve=Z;const{destroy:B,cleanup:U}=$e(ve,!1,!0);L.push(B),pt&&fe.push(U)}}else if(O(de)){if(D(ve)){V+=2;const Z=ce(ve,de,ee,{end:Ge});x(de)&&pt&&fe.push(Z)}else if(K(ve)||X(ve)){const Z=ve.readable||ve;V++,pe(Z,de,ee,{end:Ge})}else if(F(ve))V++,pe(ve,de,ee,{end:Ge});else throw new p("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],ve);ve=de}else if(z(de)){if(D(ve))V++,De(ye(ve),de,ee,{end:Ge});else if(X(ve)||F(ve))V++,De(ve,de,ee,{end:Ge});else if(K(ve))V++,De(ve.readable,de,ee,{end:Ge});else throw new p("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],ve);ve=de}else ve=h.from(de)}return(He!=null&&He.aborted||he!=null&&he.aborted)&&i.nextTick(Oe),ve}function ce(oe,Fe,Ue,{end:Je}){let He=!1;if(Fe.on("close",()=>{He||Ue(new w)}),oe.pipe(Fe,{end:!1}),Je){let he=function(){He=!0,Fe.end()};Ee(oe)?i.nextTick(he):oe.once("end",he)}else Ue();return a(oe,{readable:!0,writable:!1},he=>{const fe=oe._readableState;he&&he.code==="ERR_STREAM_PREMATURE_CLOSE"&&fe&&fe.ended&&!fe.errored&&!fe.errorEmitted?oe.once("end",Ue).once("error",Ue):Ue(he)}),a(Fe,{readable:!1,writable:!0},Ue)}return pipeline_1={pipelineImpl:G,pipeline:$},pipeline_1}var compose,hasRequiredCompose;function requireCompose(){if(hasRequiredCompose)return compose;hasRequiredCompose=1;const{pipeline:i}=requirePipeline(),e=requireDuplex(),{destroyer:t}=requireDestroy(),{isNodeStream:n,isReadable:s,isWritable:a,isWebStream:u,isTransformStream:c,isWritableStream:h,isReadableStream:f}=requireUtils(),{AbortError:p,codes:{ERR_INVALID_ARG_VALUE:g,ERR_MISSING_ARGS:y}}=requireErrors(),S=requireEndOfStream();return compose=function(...R){if(R.length===0)throw new y("streams");if(R.length===1)return e.from(R[0]);const T=[...R];if(typeof R[0]=="function"&&(R[0]=e.from(R[0])),typeof R[R.length-1]=="function"){const Y=R.length-1;R[Y]=e.from(R[Y])}for(let Y=0;Y<R.length;++Y)if(!(!n(R[Y])&&!u(R[Y]))){if(Y<R.length-1&&!(s(R[Y])||f(R[Y])||c(R[Y])))throw new g(`streams[${Y}]`,T[Y],"must be readable");if(Y>0&&!(a(R[Y])||h(R[Y])||c(R[Y])))throw new g(`streams[${Y}]`,T[Y],"must be writable")}let A,F,x,D,O;function K(Y){const Te=D;D=null,Te?Te(Y):Y?O.destroy(Y):!q&&!Ee&&O.destroy()}const z=R[0],X=i(R,K),Ee=!!(a(z)||h(z)||c(z)),q=!!(s(X)||f(X)||c(X));if(O=new e({writableObjectMode:!!(z!=null&&z.writableObjectMode),readableObjectMode:!!(X!=null&&X.readableObjectMode),writable:Ee,readable:q}),Ee){if(n(z))O._write=function(Te,re,$e){z.write(Te,re)?$e():A=$e},O._final=function(Te){z.end(),F=Te},z.on("drain",function(){if(A){const Te=A;A=null,Te()}});else if(u(z)){const re=(c(z)?z.writable:z).getWriter();O._write=async function($e,ze,ye){try{await re.ready,re.write($e).catch(()=>{}),ye()}catch(Ve){ye(Ve)}},O._final=async function($e){try{await re.ready,re.close().catch(()=>{}),F=$e}catch(ze){$e(ze)}}}const Y=c(X)?X.readable:X;S(Y,()=>{if(F){const Te=F;F=null,Te()}})}if(q){if(n(X))X.on("readable",function(){if(x){const Y=x;x=null,Y()}}),X.on("end",function(){O.push(null)}),O._read=function(){for(;;){const Y=X.read();if(Y===null){x=O._read;return}if(!O.push(Y))return}};else if(u(X)){const Te=(c(X)?X.readable:X).getReader();O._read=async function(){for(;;)try{const{value:re,done:$e}=await Te.read();if(!O.push(re))return;if($e){O.push(null);return}}catch{return}}}}return O._destroy=function(Y,Te){!Y&&D!==null&&(Y=new p),x=null,A=null,F=null,D===null?Te(Y):(D=Te,n(X)&&t(X,Y))},O},compose}var hasRequiredOperators;function requireOperators(){if(hasRequiredOperators)return operators;hasRequiredOperators=1;const i=globalThis.AbortController||requireBrowser$3().AbortController,{codes:{ERR_INVALID_ARG_VALUE:e,ERR_INVALID_ARG_TYPE:t,ERR_MISSING_ARGS:n,ERR_OUT_OF_RANGE:s},AbortError:a}=requireErrors(),{validateAbortSignal:u,validateInteger:c,validateObject:h}=requireValidators(),f=requirePrimordials().Symbol("kWeak"),p=requirePrimordials().Symbol("kResistStopPropagation"),{finished:g}=requireEndOfStream(),y=requireCompose(),{addAbortSignalNoValidate:S}=requireAddAbortSignal(),{isWritable:w,isNodeStream:R}=requireUtils(),{deprecate:T}=requireUtil(),{ArrayPrototypePush:A,Boolean:F,MathFloor:x,Number:D,NumberIsNaN:O,Promise:K,PromiseReject:z,PromiseResolve:X,PromisePrototypeThen:Ee,Symbol:q}=requirePrimordials(),Y=q("kEmpty"),Te=q("kEof");function re(he,fe){if(fe!=null&&h(fe,"options"),fe?.signal!=null&&u(fe.signal,"options.signal"),R(he)&&!w(he))throw new e("stream",he,"must be writable");const Oe=y(this,he);return fe!=null&&fe.signal&&S(fe.signal,Oe),Oe}function $e(he,fe){if(typeof he!="function")throw new t("fn",["Function","AsyncFunction"],he);fe!=null&&h(fe,"options"),fe?.signal!=null&&u(fe.signal,"options.signal");let Oe=1;fe?.concurrency!=null&&(Oe=x(fe.concurrency));let ie=Oe-1;return fe?.highWaterMark!=null&&(ie=x(fe.highWaterMark)),c(Oe,"options.concurrency",1),c(ie,"options.highWaterMark",0),ie+=Oe,(async function*(){const N=requireUtil().AbortSignalAny([fe?.signal].filter(F)),L=this,V=[],ee={signal:N};let ae,ve,J=!1,me=0;function xe(){J=!0,de()}function de(){me-=1,st()}function st(){ve&&!J&&me<Oe&&V.length<ie&&(ve(),ve=null)}async function ft(){try{for await(let Ge of L){if(J)return;if(N.aborted)throw new a;try{if(Ge=he(Ge,ee),Ge===Y)continue;Ge=X(Ge)}catch(pt){Ge=z(pt)}me+=1,Ee(Ge,de,xe),V.push(Ge),ae&&(ae(),ae=null),!J&&(V.length>=ie||me>=Oe)&&await new K(pt=>{ve=pt})}V.push(Te)}catch(Ge){const pt=z(Ge);Ee(pt,de,xe),V.push(pt)}finally{J=!0,ae&&(ae(),ae=null)}}ft();try{for(;;){for(;V.length>0;){const Ge=await V[0];if(Ge===Te)return;if(N.aborted)throw new a;Ge!==Y&&(yield Ge),V.shift(),st()}await new K(Ge=>{ae=Ge})}}finally{J=!0,ve&&(ve(),ve=null)}}).call(this)}function ze(he=void 0){return he!=null&&h(he,"options"),he?.signal!=null&&u(he.signal,"options.signal"),(async function*(){let Oe=0;for await(const j of this){var ie;if(he!=null&&(ie=he.signal)!==null&&ie!==void 0&&ie.aborted)throw new a({cause:he.signal.reason});yield[Oe++,j]}}).call(this)}async function ye(he,fe=void 0){for await(const Oe of $.call(this,he,fe))return!0;return!1}async function Ve(he,fe=void 0){if(typeof he!="function")throw new t("fn",["Function","AsyncFunction"],he);return!await ye.call(this,async(...Oe)=>!await he(...Oe),fe)}async function pe(he,fe){for await(const Oe of $.call(this,he,fe))return Oe}async function De(he,fe){if(typeof he!="function")throw new t("fn",["Function","AsyncFunction"],he);async function Oe(ie,j){return await he(ie,j),Y}for await(const ie of $e.call(this,Oe,fe));}function $(he,fe){if(typeof he!="function")throw new t("fn",["Function","AsyncFunction"],he);async function Oe(ie,j){return await he(ie,j)?ie:Y}return $e.call(this,Oe,fe)}class G extends n{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}async function ce(he,fe,Oe){var ie;if(typeof he!="function")throw new t("reducer",["Function","AsyncFunction"],he);Oe!=null&&h(Oe,"options"),Oe?.signal!=null&&u(Oe.signal,"options.signal");let j=arguments.length>1;if(Oe!=null&&(ie=Oe.signal)!==null&&ie!==void 0&&ie.aborted){const ae=new a(void 0,{cause:Oe.signal.reason});throw this.once("error",()=>{}),await g(this.destroy(ae)),ae}const N=new i,L=N.signal;if(Oe!=null&&Oe.signal){const ae={once:!0,[f]:this,[p]:!0};Oe.signal.addEventListener("abort",()=>N.abort(),ae)}let V=!1;try{for await(const ae of this){var ee;if(V=!0,Oe!=null&&(ee=Oe.signal)!==null&&ee!==void 0&&ee.aborted)throw new a;j?fe=await he(fe,ae,{signal:L}):(fe=ae,j=!0)}if(!V&&!j)throw new G}finally{N.abort()}return fe}async function oe(he){he!=null&&h(he,"options"),he?.signal!=null&&u(he.signal,"options.signal");const fe=[];for await(const ie of this){var Oe;if(he!=null&&(Oe=he.signal)!==null&&Oe!==void 0&&Oe.aborted)throw new a(void 0,{cause:he.signal.reason});A(fe,ie)}return fe}function Fe(he,fe){const Oe=$e.call(this,he,fe);return(async function*(){for await(const j of Oe)yield*j}).call(this)}function Ue(he){if(he=D(he),O(he))return 0;if(he<0)throw new s("number",">= 0",he);return he}function Je(he,fe=void 0){return fe!=null&&h(fe,"options"),fe?.signal!=null&&u(fe.signal,"options.signal"),he=Ue(he),(async function*(){var ie;if(fe!=null&&(ie=fe.signal)!==null&&ie!==void 0&&ie.aborted)throw new a;for await(const N of this){var j;if(fe!=null&&(j=fe.signal)!==null&&j!==void 0&&j.aborted)throw new a;he--<=0&&(yield N)}}).call(this)}function He(he,fe=void 0){return fe!=null&&h(fe,"options"),fe?.signal!=null&&u(fe.signal,"options.signal"),he=Ue(he),(async function*(){var ie;if(fe!=null&&(ie=fe.signal)!==null&&ie!==void 0&&ie.aborted)throw new a;for await(const N of this){var j;if(fe!=null&&(j=fe.signal)!==null&&j!==void 0&&j.aborted)throw new a;if(he-- >0&&(yield N),he<=0)return}}).call(this)}return operators.streamReturningOperators={asIndexedPairs:T(ze,"readable.asIndexedPairs will be removed in a future version."),drop:Je,filter:$,flatMap:Fe,map:$e,take:He,compose:re},operators.promiseReturningOperators={every:Ve,forEach:De,reduce:ce,toArray:oe,some:ye,find:pe},operators}var promises,hasRequiredPromises;function requirePromises(){if(hasRequiredPromises)return promises;hasRequiredPromises=1;const{ArrayPrototypePop:i,Promise:e}=requirePrimordials(),{isIterable:t,isNodeStream:n,isWebStream:s}=requireUtils(),{pipelineImpl:a}=requirePipeline(),{finished:u}=requireEndOfStream();requireStream();function c(...h){return new e((f,p)=>{let g,y;const S=h[h.length-1];if(S&&typeof S=="object"&&!n(S)&&!t(S)&&!s(S)){const w=i(h);g=w.signal,y=w.end}a(h,(w,R)=>{w?p(w):f(R)},{signal:g,end:y})})}return promises={finished:u,pipeline:c},promises}var hasRequiredStream;function requireStream(){if(hasRequiredStream)return stream.exports;hasRequiredStream=1;const{Buffer:i}=requireBuffer(),{ObjectDefineProperty:e,ObjectKeys:t,ReflectApply:n}=requirePrimordials(),{promisify:{custom:s}}=requireUtil(),{streamReturningOperators:a,promiseReturningOperators:u}=requireOperators(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:c}}=requireErrors(),h=requireCompose(),{setDefaultHighWaterMark:f,getDefaultHighWaterMark:p}=requireState(),{pipeline:g}=requirePipeline(),{destroyer:y}=requireDestroy(),S=requireEndOfStream(),w=requirePromises(),R=requireUtils(),T=stream.exports=requireLegacy().Stream;T.isDestroyed=R.isDestroyed,T.isDisturbed=R.isDisturbed,T.isErrored=R.isErrored,T.isReadable=R.isReadable,T.isWritable=R.isWritable,T.Readable=requireReadable();for(const F of t(a)){let D=function(...O){if(new.target)throw c();return T.Readable.from(n(x,this,O))};const x=a[F];e(D,"name",{__proto__:null,value:x.name}),e(D,"length",{__proto__:null,value:x.length}),e(T.Readable.prototype,F,{__proto__:null,value:D,enumerable:!1,configurable:!0,writable:!0})}for(const F of t(u)){let D=function(...O){if(new.target)throw c();return n(x,this,O)};const x=u[F];e(D,"name",{__proto__:null,value:x.name}),e(D,"length",{__proto__:null,value:x.length}),e(T.Readable.prototype,F,{__proto__:null,value:D,enumerable:!1,configurable:!0,writable:!0})}T.Writable=requireWritable(),T.Duplex=requireDuplex(),T.Transform=requireTransform(),T.PassThrough=requirePassthrough(),T.pipeline=g;const{addAbortSignal:A}=requireAddAbortSignal();return T.addAbortSignal=A,T.finished=S,T.destroy=y,T.compose=h,T.setDefaultHighWaterMark=f,T.getDefaultHighWaterMark=p,e(T,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return w}}),e(g,s,{__proto__:null,enumerable:!0,get(){return w.pipeline}}),e(S,s,{__proto__:null,enumerable:!0,get(){return w.finished}}),T.Stream=T,T._isUint8Array=function(x){return x instanceof Uint8Array},T._uint8ArrayToBuffer=function(x){return i.from(x.buffer,x.byteOffset,x.byteLength)},stream.exports}var hasRequiredBrowser;function requireBrowser(){return hasRequiredBrowser||(hasRequiredBrowser=1,(function(i){const e=requireStream(),t=requirePromises(),n=e.Readable.destroy;i.exports=e.Readable,i.exports._uint8ArrayToBuffer=e._uint8ArrayToBuffer,i.exports._isUint8Array=e._isUint8Array,i.exports.isDisturbed=e.isDisturbed,i.exports.isErrored=e.isErrored,i.exports.isReadable=e.isReadable,i.exports.Readable=e.Readable,i.exports.Writable=e.Writable,i.exports.Duplex=e.Duplex,i.exports.Transform=e.Transform,i.exports.PassThrough=e.PassThrough,i.exports.addAbortSignal=e.addAbortSignal,i.exports.finished=e.finished,i.exports.destroy=e.destroy,i.exports.destroy=n,i.exports.pipeline=e.pipeline,i.exports.compose=e.compose,Object.defineProperty(e,"promises",{configurable:!0,enumerable:!0,get(){return t}}),i.exports.Stream=e.Stream,i.exports.default=i.exports})(browser)),browser.exports}var browserExports=requireBrowser();const ITERATOR=Symbol("iter");function merge$1(i,e,t=4){if(t===0)return Object.assign(i,e);for(const n in e)i[n]=merge$1(i[n]||Object.create(null),e[n],t-1);return i}function intersect(i,e,t=4){let n=!1;for(const s in i)if(s in e){const a=t===0?null:intersect(i[s],e[s],t-1);if(a!==!1)n=n||Object.create(null),n[s]=a;else if(t===3)return!1}return n}function difference(i,e,t=4){let n=!1;for(const s in i)if(!(s in e))n=n||Object.create(null),n[s]=t===0?null:merge$1({},i[s],t-1);else if(t!==0){const a=difference(i[s],e[s],t-1);if(a!==!1)n=n||Object.create(null),n[s]=a;else if(t===3)return!1}return n}class N3EntityIndex{constructor(e={}){this._id=1,this._ids=Object.create(null),this._ids[""]=1,this._entities=Object.create(null),this._entities[1]="",this._blankNodeIndex=0,this._factory=e.factory||DataFactory}_termFromId(e){if(e[0]==="."){const t=this._entities,n=e.split(".");return this._factory.quad(this._termFromId(t[n[1]]),this._termFromId(t[n[2]]),this._termFromId(t[n[3]]),n[4]&&this._termFromId(t[n[4]]))}return termFromId(e,this._factory)}_termToNumericId(e){if(e.termType==="Quad"){const t=this._termToNumericId(e.subject),n=this._termToNumericId(e.predicate),s=this._termToNumericId(e.object);let a;return t&&n&&s&&(isDefaultGraph(e.graph)||(a=this._termToNumericId(e.graph)))&&this._ids[a?`.${t}.${n}.${s}.${a}`:`.${t}.${n}.${s}`]}return this._ids[termToId(e)]}_termToNewNumericId(e){const t=e&&e.termType==="Quad"?`.${this._termToNewNumericId(e.subject)}.${this._termToNewNumericId(e.predicate)}.${this._termToNewNumericId(e.object)}${isDefaultGraph(e.graph)?"":`.${this._termToNewNumericId(e.graph)}`}`:termToId(e);return this._ids[t]||(this._ids[this._entities[++this._id]=t]=this._id)}createBlankNode(e){let t,n;if(e)for(t=e=`_:${e}`,n=1;this._ids[t];)t=e+n++;else do t=`_:b${this._blankNodeIndex++}`;while(this._ids[t]);return this._ids[t]=++this._id,this._entities[this._id]=t,this._factory.blankNode(t.substr(2))}}class N3Store{constructor(e,t){this._size=0,this._graphs=Object.create(null),!t&&e&&!e[0]&&typeof e.match!="function"&&(t=e,e=null),t=t||{},this._factory=t.factory||DataFactory,this._entityIndex=t.entityIndex||new N3EntityIndex({factory:this._factory}),this._entities=this._entityIndex._entities,this._termFromId=this._entityIndex._termFromId.bind(this._entityIndex),this._termToNumericId=this._entityIndex._termToNumericId.bind(this._entityIndex),this._termToNewNumericId=this._entityIndex._termToNewNumericId.bind(this._entityIndex),e&&this.addAll(e)}get size(){let e=this._size;if(e!==null)return e;e=0;const t=this._graphs;let n,s;for(const a in t)for(const u in n=t[a].subjects)for(const c in s=n[u])e+=Object.keys(s[c]).length;return this._size=e}_addToIndex(e,t,n,s){const a=e[t]||(e[t]={}),u=a[n]||(a[n]={}),c=s in u;return c||(u[s]=null),!c}_removeFromIndex(e,t,n,s){const a=e[t],u=a[n];delete u[s];for(const c in u)return;delete a[n];for(const c in a)return;delete e[t]}*_findInIndex(e,t,n,s,a,u,c,h){let f,p,g;const y=this._entities,S=this._termFromId(y[h]),w={subject:null,predicate:null,object:null};t&&((f=e,e={})[t]=f[t]);for(const R in e)if(p=e[R]){w[a]=this._termFromId(y[R]),n&&((f=p,p={})[n]=f[n]);for(const T in p)if(g=p[T]){w[u]=this._termFromId(y[T]);const A=s?s in g?[s]:[]:Object.keys(g);for(let F=0;F<A.length;F++)w[c]=this._termFromId(y[A[F]]),yield this._factory.quad(w.subject,w.predicate,w.object,S)}}}_loop(e,t){for(const n in e)t(n)}_loopByKey0(e,t,n){let s,a;if(s=e[t])for(a in s)n(a)}_loopByKey1(e,t,n){let s,a;for(s in e)a=e[s],a[t]&&n(s)}_loopBy2Keys(e,t,n,s){let a,u,c;if((a=e[t])&&(u=a[n]))for(c in u)s(c)}_countInIndex(e,t,n,s){let a=0,u,c,h;t&&((u=e,e={})[t]=u[t]);for(const f in e)if(c=e[f]){n&&((u=c,c={})[n]=u[n]);for(const p in c)(h=c[p])&&(s?s in h&&a++:a+=Object.keys(h).length)}return a}_getGraphs(e){return e=e===""?1:e&&(this._termToNumericId(e)||-1),typeof e!="number"?this._graphs:{[e]:this._graphs[e]}}_uniqueEntities(e){const t=Object.create(null);return n=>{n in t||(t[n]=!0,e(this._termFromId(this._entities[n],this._factory)))}}add(e){return this.addQuad(e),this}addQuad(e,t,n,s){t||(s=e.graph,n=e.object,t=e.predicate,e=e.subject),s=s?this._termToNewNumericId(s):1;let a=this._graphs[s];return a||(a=this._graphs[s]={subjects:{},predicates:{},objects:{}},Object.freeze(a)),e=this._termToNewNumericId(e),t=this._termToNewNumericId(t),n=this._termToNewNumericId(n),this._addToIndex(a.subjects,e,t,n)?(this._addToIndex(a.predicates,t,n,e),this._addToIndex(a.objects,n,e,t),this._size=null,!0):!1}addQuads(e){for(let t=0;t<e.length;t++)this.addQuad(e[t])}delete(e){return this.removeQuad(e),this}has(e,t,n,s){return e&&e.subject&&({subject:e,predicate:t,object:n,graph:s}=e),!this.readQuads(e,t,n,s).next().done}import(e){return e.on("data",t=>{this.addQuad(t)}),e}removeQuad(e,t,n,s){t||({subject:e,predicate:t,object:n,graph:s}=e),s=s?this._termToNumericId(s):1;const a=this._graphs;let u,c,h;if(!(e=e&&this._termToNumericId(e))||!(t=t&&this._termToNumericId(t))||!(n=n&&this._termToNumericId(n))||!(u=a[s])||!(c=u.subjects[e])||!(h=c[t])||!(n in h))return!1;this._removeFromIndex(u.subjects,e,t,n),this._removeFromIndex(u.predicates,t,n,e),this._removeFromIndex(u.objects,n,e,t),this._size!==null&&this._size--;for(e in u.subjects)return!0;return delete a[s],!0}removeQuads(e){for(let t=0;t<e.length;t++)this.removeQuad(e[t])}remove(e){return e.on("data",t=>{this.removeQuad(t)}),e}removeMatches(e,t,n,s){const a=new browserExports.Readable({objectMode:!0}),u=this.readQuads(e,t,n,s);return a._read=c=>{for(;--c>=0;){const{done:h,value:f}=u.next();if(h){a.push(null);return}a.push(f)}},this.remove(a)}deleteGraph(e){return this.removeMatches(null,null,null,e)}getQuads(e,t,n,s){return[...this.readQuads(e,t,n,s)]}*readQuads(e,t,n,s){const a=this._getGraphs(s);let u,c,h,f;if(!(e&&!(c=this._termToNumericId(e))||t&&!(h=this._termToNumericId(t))||n&&!(f=this._termToNumericId(n))))for(const p in a)(u=a[p])&&(c?f?yield*this._findInIndex(u.objects,f,c,h,"object","subject","predicate",p):yield*this._findInIndex(u.subjects,c,h,null,"subject","predicate","object",p):h?yield*this._findInIndex(u.predicates,h,f,null,"predicate","object","subject",p):f?yield*this._findInIndex(u.objects,f,null,null,"object","subject","predicate",p):yield*this._findInIndex(u.subjects,null,null,null,"subject","predicate","object",p))}match(e,t,n,s){return new DatasetCoreAndReadableStream(this,e,t,n,s,{entityIndex:this._entityIndex})}countQuads(e,t,n,s){const a=this._getGraphs(s);let u=0,c,h,f,p;if(e&&!(h=this._termToNumericId(e))||t&&!(f=this._termToNumericId(t))||n&&!(p=this._termToNumericId(n)))return 0;for(const g in a)(c=a[g])&&(e?n?u+=this._countInIndex(c.objects,p,h,f):u+=this._countInIndex(c.subjects,h,f,p):t?u+=this._countInIndex(c.predicates,f,p,h):u+=this._countInIndex(c.objects,p,h,f));return u}forEach(e,t,n,s,a){this.some(u=>(e(u,this),!1),t,n,s,a)}every(e,t,n,s,a){return!this.some(u=>!e(u,this),t,n,s,a)}some(e,t,n,s,a){for(const u of this.readQuads(t,n,s,a))if(e(u,this))return!0;return!1}getSubjects(e,t,n){const s=[];return this.forSubjects(a=>{s.push(a)},e,t,n),s}forSubjects(e,t,n,s){const a=this._getGraphs(s);let u,c,h;if(e=this._uniqueEntities(e),!(t&&!(c=this._termToNumericId(t))||n&&!(h=this._termToNumericId(n))))for(s in a)(u=a[s])&&(c?h?this._loopBy2Keys(u.predicates,c,h,e):this._loopByKey1(u.subjects,c,e):h?this._loopByKey0(u.objects,h,e):this._loop(u.subjects,e))}getPredicates(e,t,n){const s=[];return this.forPredicates(a=>{s.push(a)},e,t,n),s}forPredicates(e,t,n,s){const a=this._getGraphs(s);let u,c,h;if(e=this._uniqueEntities(e),!(t&&!(c=this._termToNumericId(t))||n&&!(h=this._termToNumericId(n))))for(s in a)(u=a[s])&&(c?h?this._loopBy2Keys(u.objects,h,c,e):this._loopByKey0(u.subjects,c,e):h?this._loopByKey1(u.predicates,h,e):this._loop(u.predicates,e))}getObjects(e,t,n){const s=[];return this.forObjects(a=>{s.push(a)},e,t,n),s}forObjects(e,t,n,s){const a=this._getGraphs(s);let u,c,h;if(e=this._uniqueEntities(e),!(t&&!(c=this._termToNumericId(t))||n&&!(h=this._termToNumericId(n))))for(s in a)(u=a[s])&&(c?h?this._loopBy2Keys(u.subjects,c,h,e):this._loopByKey1(u.objects,c,e):h?this._loopByKey0(u.predicates,h,e):this._loop(u.objects,e))}getGraphs(e,t,n){const s=[];return this.forGraphs(a=>{s.push(a)},e,t,n),s}forGraphs(e,t,n,s){for(const a in this._graphs)this.some(u=>(e(u.graph),!0),t,n,s,this._termFromId(this._entities[a]))}createBlankNode(e){return this._entityIndex.createBlankNode(e)}extractLists({remove:e=!1,ignoreErrors:t=!1}={}){const n={},s=t?(()=>!0):((c,h)=>{throw new Error(`${c.value} ${h}`)}),a=this.getQuads(null,namespaces.rdf.rest,namespaces.rdf.nil,null),u=e?[...a]:[];return a.forEach(c=>{const h=[];let f=!1,p,g;const y=c.graph;let S=c.subject;for(;S&&!f;){const w=this.getQuads(null,null,S,null),R=this.getQuads(S,null,null,null);let T,A=null,F=null,x=null;for(let D=0;D<R.length&&!f;D++)T=R[D],T.graph.equals(y)?p?f=s(S,"has non-list arcs out"):T.predicate.value===namespaces.rdf.first?A?f=s(S,"has multiple rdf:first arcs"):u.push(A=T):T.predicate.value===namespaces.rdf.rest?F?f=s(S,"has multiple rdf:rest arcs"):u.push(F=T):w.length?f=s(S,"can't be subject and object"):(p=T,g="subject"):f=s(S,"not confined to single graph");for(let D=0;D<w.length&&!f;++D)T=w[D],p?f=s(S,"can't have coreferences"):T.predicate.value===namespaces.rdf.rest?x?f=s(S,"has incoming rdf:rest arcs"):x=T:(p=T,g="object");A?h.unshift(A.object):f=s(S,"has no list head"),S=x&&x.subject}f?e=!1:p&&(n[p[g].value]=h)}),e&&this.removeQuads(u),n}addAll(e){if(e instanceof DatasetCoreAndReadableStream&&(e=e.filtered),Array.isArray(e))this.addQuads(e);else if(e instanceof N3Store&&e._entityIndex===this._entityIndex)e._size!==0&&(this._graphs=merge$1(this._graphs,e._graphs),this._size=null);else for(const t of e)this.add(t);return this}contains(e){if(e instanceof DatasetCoreAndReadableStream&&(e=e.filtered),e===this)return!0;if(!(e instanceof N3Store)||this._entityIndex!==e._entityIndex)return e.every(f=>this.has(f));const t=this._graphs,n=e._graphs;let s,a,u,c,h;for(const f in n){if(!(s=t[f]))return!1;s=s.subjects;for(const p in a=n[f].subjects){if(!(u=s[p]))return!1;for(const g in c=a[p]){if(!(h=u[g]))return!1;for(const y in c[g])if(!(y in h))return!1}}}return!0}deleteMatches(e,t,n,s){for(const a of this.match(e,t,n,s))this.removeQuad(a);return this}difference(e){if(e&&e instanceof DatasetCoreAndReadableStream&&(e=e.filtered),e===this)return new N3Store({entityIndex:this._entityIndex});if(e instanceof N3Store&&e._entityIndex===this._entityIndex){const t=new N3Store({entityIndex:this._entityIndex}),n=difference(this._graphs,e._graphs);return n&&(t._graphs=n,t._size=null),t}return this.filter(t=>!e.has(t))}equals(e){return e instanceof DatasetCoreAndReadableStream&&(e=e.filtered),e===this||this.size===e.size&&this.contains(e)}filter(e){const t=new N3Store({entityIndex:this._entityIndex});for(const n of this)e(n,this)&&t.add(n);return t}intersection(e){if(e instanceof DatasetCoreAndReadableStream&&(e=e.filtered),e===this){const t=new N3Store({entityIndex:this._entityIndex});return t._graphs=merge$1(Object.create(null),this._graphs),t._size=this._size,t}else if(e instanceof N3Store&&this._entityIndex===e._entityIndex){const t=new N3Store({entityIndex:this._entityIndex}),n=intersect(e._graphs,this._graphs);return n&&(t._graphs=n,t._size=null),t}return this.filter(t=>e.has(t))}map(e){const t=new N3Store({entityIndex:this._entityIndex});for(const n of this)t.add(e(n,this));return t}reduce(e,t){const n=this.readQuads();let s=t===void 0?n.next().value:t;for(const a of n)s=e(s,a,this);return s}toArray(){return this.getQuads()}toCanonical(){throw new Error("not implemented")}toStream(){return this.match()}toString(){return new N3Writer().quadsToString(this)}union(e){const t=new N3Store({entityIndex:this._entityIndex});return t._graphs=merge$1(Object.create(null),this._graphs),t._size=this._size,t.addAll(e),t}*[Symbol.iterator](){yield*this.readQuads()}}function indexMatch(i,e,t=0){const n=e[t];if(n&&!(n in i))return!1;let s=!1;for(const a in n?{[n]:i[n]}:i){const u=t===2?null:indexMatch(i[a],e,t+1);u!==!1&&(s=s||Object.create(null),s[a]=u)}return s}class DatasetCoreAndReadableStream extends browserExports.Readable{constructor(e,t,n,s,a,u){super({objectMode:!0}),Object.assign(this,{n3Store:e,subject:t,predicate:n,object:s,graph:a,options:u})}get filtered(){if(!this._filtered){const{n3Store:e,graph:t,object:n,predicate:s,subject:a}=this,u=this._filtered=new N3Store({factory:e._factory,entityIndex:this.options.entityIndex});let c,h,f;if(a&&!(c=u._termToNumericId(a))||s&&!(h=u._termToNumericId(s))||n&&!(f=u._termToNumericId(n)))return u;const p=e._getGraphs(t);for(const g in p){let y,S,w,R;(R=p[g])&&(!c&&h?(S=indexMatch(R.predicates,[h,f,c]))&&(y=indexMatch(R.subjects,[c,h,f]),w=indexMatch(R.objects,[f,c,h])):f?(w=indexMatch(R.objects,[f,c,h]))&&(y=indexMatch(R.subjects,[c,h,f]),S=indexMatch(R.predicates,[h,f,c])):(y=indexMatch(R.subjects,[c,h,f]))&&(S=indexMatch(R.predicates,[h,f,c]),w=indexMatch(R.objects,[f,c,h])),y&&(u._graphs[g]={subjects:y,predicates:S,objects:w}))}u._size=null}return this._filtered}get size(){return this.filtered.size}_read(e){e>0&&!this[ITERATOR]&&(this[ITERATOR]=this[Symbol.iterator]());const t=this[ITERATOR];for(;--e>=0;){const{done:n,value:s}=t.next();if(n){this.push(null);return}this.push(s)}}addAll(e){return this.filtered.addAll(e)}contains(e){return this.filtered.contains(e)}deleteMatches(e,t,n,s){return this.filtered.deleteMatches(e,t,n,s)}difference(e){return this.filtered.difference(e)}equals(e){return this.filtered.equals(e)}every(e,t,n,s,a){return this.filtered.every(e,t,n,s,a)}filter(e){return this.filtered.filter(e)}forEach(e,t,n,s,a){return this.filtered.forEach(e,t,n,s,a)}import(e){return this.filtered.import(e)}intersection(e){return this.filtered.intersection(e)}map(e){return this.filtered.map(e)}some(e,t,n,s,a){return this.filtered.some(e,t,n,s,a)}toCanonical(){return this.filtered.toCanonical()}toStream(){return this._filtered?this._filtered.toStream():this.n3Store.match(this.subject,this.predicate,this.object,this.graph)}union(e){return this._filtered?this._filtered.union(e):this.n3Store.match(this.subject,this.predicate,this.object,this.graph).addAll(e)}toArray(){return this._filtered?this._filtered.toArray():this.n3Store.getQuads(this.subject,this.predicate,this.object,this.graph)}reduce(e,t){return this.filtered.reduce(e,t)}toString(){return new N3Writer().quadsToString(this)}add(e){return this.filtered.add(e)}delete(e){return this.filtered.delete(e)}has(e){return this.filtered.has(e)}match(e,t,n,s){return new DatasetCoreAndReadableStream(this.filtered,e,t,n,s,this.options)}*[Symbol.iterator](){yield*this._filtered||this.n3Store.readQuads(this.subject,this.predicate,this.object,this.graph)}}const getTurtleParser=()=>{const i=[],e=[],t=[];return{onQuad:n=>{i.push(n)},onError:n=>{t.push(n)},onComplete:n=>{e.push(n)},parse:(n,s)=>{getParser(getSourceUrl(s)).parse(n,(a,u)=>{a?t.forEach(c=>c(a)):u?i.forEach(c=>c(u)):e.forEach(c=>c())})}}};function getParser(i){return new N3Parser({format:"text/turtle",baseIRI:i})}async function triplesToTurtle(i,e){const t="text/turtle",n=new N3Writer({format:t,prefixes:e?.prefixes}),s=i.map(c=>DataFactory.quad(c.subject,c.predicate,c.object,void 0));return n.addQuads(s),await new Promise((c,h)=>{n.end((f,p)=>{f?h(f):c(p)})})}const localNodeSkolemPrefix="https://inrupt.com/.well-known/sdk-local-node/",{freeze}=Object;function isLocalNodeIri(i){return i.substring(0,localNodeSkolemPrefix.length)===localNodeSkolemPrefix}function getLocalNodeName(i){return i.substring(localNodeSkolemPrefix.length)}function getLocalNodeIri(i){return`${localNodeSkolemPrefix}${i}`}function isBlankNodeId(i){return typeof i=="string"&&i.substring(0,2)==="_:"}function getBlankNodeValue(i){return i.substring(2)}function getBlankNodeId(i){return`_:${i.value}`}const xmlSchemaTypes={boolean:"http://www.w3.org/2001/XMLSchema#boolean",dateTime:"http://www.w3.org/2001/XMLSchema#dateTime",date:"http://www.w3.org/2001/XMLSchema#date",time:"http://www.w3.org/2001/XMLSchema#time",decimal:"http://www.w3.org/2001/XMLSchema#decimal",integer:"http://www.w3.org/2001/XMLSchema#integer",string:"http://www.w3.org/2001/XMLSchema#string",langString:"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"};function serializeBoolean(i){return i?"true":"false"}function deserializeBoolean(i){return i==="true"||i==="1"?!0:i==="false"||i==="0"?!1:null}function serializeTime(i){let e,t;if(i.millisecond&&(i.millisecond<10?e=`00${i.millisecond}`:i.millisecond<100?e=`0${i.millisecond}`:e=i.millisecond),typeof i.timezoneHourOffset=="number"){const n=Math.abs(i.timezoneHourOffset)<10?`0${Math.abs(i.timezoneHourOffset)}`:Math.abs(i.timezoneHourOffset);t=i.timezoneHourOffset>=0?`+${n}`:`-${n}`,i.timezoneMinuteOffset?t=`${t}:${i.timezoneMinuteOffset<10?`0${i.timezoneMinuteOffset}`:i.timezoneMinuteOffset}`:t+=":00"}return`${i.hour<10?`0${i.hour}`:i.hour}:${i.minute<10?`0${i.minute}`:i.minute}:${i.second<10?`0${i.second}`:i.second}${i.millisecond?`.${e}`:""}${t||""}`}function deserializeTime(i){if(!/\d\d:\d\d:\d\d(\.\d+)?(Z|(\+|-)\d\d:\d\d)?/.test(i))return null;const[t,n]=splitTimeFromTimezone(i),[s,a,u]=t.split(":");let c=Number.parseInt(s,10),h=Number.parseInt(a,10);const[f,p]=u.split("."),g=Number.parseInt(f,10),y=p?Number.parseInt(p,10):void 0;h>=60&&(c+=1,h-=60);const S={hour:c,minute:h,second:g};if(typeof y=="number"&&(S.millisecond=y),typeof n=="string"){const[w,R]=getTimezoneOffsets(n);if(typeof w!="number"||w>24||typeof R!="number"||R>59)return null;S.timezoneHourOffset=w,S.timezoneMinuteOffset=R}return S}function serializeDatetime(i){return i.toISOString()}function deserializeDatetime(i){if(!/-?\d{4,}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(Z|(\+|-)\d\d:\d\d)?/.test(i))return null;const[t,n]=i.split("T"),[s,a]=t.charAt(0)==="-"?[-1,t.substring(1)]:[1,t],[u,c,h]=a.split("-"),f=Number.parseInt(u,10)*s,p=Number.parseInt(c,10)-1,g=Number.parseInt(h,10),[y,S]=splitTimeFromTimezone(n),[w,R]=typeof S=="string"?getTimezoneOffsets(S):[0,0],[T,A,F]=y.split(":"),x=Number.parseInt(T,10)+w,D=Number.parseInt(A,10)+R,[O,K]=F.split("."),z=Number.parseInt(O,10),X=K?Number.parseInt(K,10):0,Ee=new Date(Date.UTC(f,p,g,x,D,z,X));return f>=0&&f<100&&Ee.setUTCFullYear(Ee.getUTCFullYear()-1900),Ee}function serializeDate(i){const e=i.getFullYear(),t=i.getMonth()+1,n=i.getDate(),[,s]=splitTimeFromTimezone(i.toISOString());return`${e}-${String(t).padStart(2,"0")}-${String(n).padStart(2,"0")}${s}`}function deserializeDate(i){if(!/-?\d{4,}-\d\d-\d\d(Z|(\+|-)\d\d:\d\d)?/.test(i))return null;const t=i,[n,s]=t.charAt(0)==="-"?[-1,t.substring(1)]:[1,t],[a,u,c]=s.split("-"),h=c.length>2?c.substring(0,2):c,f=Number.parseInt(a,10)*n,p=Number.parseInt(u,10)-1,g=Number.parseInt(h,10),y=12,S=new Date(Date.UTC(f,p,g,y));return f>=0&&f<100&&S.setUTCFullYear(S.getUTCFullYear()-1900),S}function splitTimeFromTimezone(i){if(i.endsWith("Z"))return[i.substring(0,i.length-1),"Z"];const e=i.split("+"),t=i.split("-");return e.length===1&&t.length===1?[e[0],void 0]:e.length>t.length?[e[0],`+${e[1]}`]:[t[0],`-${t[1]}`]}function getTimezoneOffsets(i){if(i==="Z")return[0,0];const e=i.charAt(0)==="+"?1:-1,[t,n]=i.substring(1).split(":"),s=Number.parseInt(t,10),a=Number.parseInt(n,10);return[s*e,a*e]}function serializeDecimal(i){return i.toString()}function deserializeDecimal(i){const e=Number.parseFloat(i);return Number.isNaN(e)?null:e}function serializeInteger(i){return i.toString()}function deserializeInteger(i){const e=Number.parseInt(i,10);return Number.isNaN(e)?null:e}function normalizeLocale(i){return i.toLowerCase()}function isNamedNode(i){return isTerm(i)&&i.termType==="NamedNode"}function isLiteral(i){return isTerm(i)&&i.termType==="Literal"}function isTerm(i){return i!==null&&typeof i=="object"&&typeof i.termType=="string"&&typeof i.value=="string"&&typeof i.equals=="function"}function isLocalNode(i){return isNamedNode(i)&&isLocalNodeIri(i.value)}function internal_isValidUrl(i){const e=internal_toIriString(i);if(typeof URL!="function")return!0;try{return new URL(e),!0}catch{return!1}}function resolveIriForLocalNode(i,e){return DataFactory.namedNode(resolveLocalIri(getLocalNodeName(i.value),e))}function resolveLocalIri(i,e){if(typeof URL!="function")throw new Error("The URL interface is not available, so an IRI cannot be determined.");const t=new URL(e);return t.hash=i,t.href}function addRdfJsQuadToDataset(i,e){var t;if(!["NamedNode","DefaultGraph"].includes(e.graph.termType))throw new Error(`Cannot parse Quads with nodes of type [${e.graph.termType}] as their Graph node.`);const s=e.graph.termType==="DefaultGraph"?"default":e.graph.value,a=(t=i.graphs[s])!==null&&t!==void 0?t:{};return freeze({...i,graphs:freeze({...i.graphs,[s]:addRdfJsQuadToGraph(a,e)})})}function addRdfJsQuadToGraph(i,e){var t;if(!["NamedNode","BlankNode"].includes(e.subject.termType))throw new Error(`Cannot parse Quads with nodes of type [${e.subject.termType}] as their Subject node.`);const s=e.subject.termType==="BlankNode"?`_:${e.subject.value}`:e.subject.value,a=(t=i[s])!==null&&t!==void 0?t:{type:"Subject",url:s,predicates:{}};return freeze({...i,[s]:addRdfJsQuadToSubject(a,e)})}function addRdfJsQuadToSubject(i,e){return freeze({...i,predicates:addRdfJsQuadToPredicates(i.predicates,e)})}function addRdfJsQuadToPredicates(i,e){var t;if(!["NamedNode"].includes(e.predicate.termType))throw new Error(`Cannot parse Quads with nodes of type [${e.predicate.termType}] as their Predicate node.`);const s=e.predicate.value,a=(t=i[s])!==null&&t!==void 0?t:{};return freeze({...i,[s]:addRdfJsQuadToObjects(a,e)})}function addRdfJsQuadToObjects(i,e){var t,n,s,a,u,c,h,f;if(e.object.termType==="NamedNode"){const p=freeze([...(t=i.namedNodes)!==null&&t!==void 0?t:[],e.object.value]);return freeze({...i,namedNodes:p})}if(e.object.termType==="Literal"){if(e.object.datatype.value===xmlSchemaTypes.langString){const y=e.object.language.toLowerCase(),S=freeze([...(s=(n=i.langStrings)===null||n===void 0?void 0:n[y])!==null&&s!==void 0?s:[],e.object.value]),w=freeze({...(a=i.langStrings)!==null&&a!==void 0?a:{},[y]:S});return freeze({...i,langStrings:w})}const p=freeze([...(c=(u=i.literals)===null||u===void 0?void 0:u[e.object.datatype.value])!==null&&c!==void 0?c:[],e.object.value]),g=freeze({...(h=i.literals)!==null&&h!==void 0?h:{},[e.object.datatype.value]:p});return freeze({...i,literals:g})}if(e.object.termType==="BlankNode"){const p=freeze([...(f=i.blankNodes)!==null&&f!==void 0?f:[],getBlankNodeId(e.object)]);return freeze({...i,blankNodes:p})}throw new Error(`Objects of type [${e.object.termType}] are not supported.`)}function toRdfJsQuads(i,e={}){var t;const n=[],s=(t=e.dataFactory)!==null&&t!==void 0?t:DataFactory;return Object.keys(i.graphs).forEach(a=>{const u=i.graphs[a],c=a==="default"?s.defaultGraph():s.namedNode(a);Object.keys(u).forEach(h=>{const{predicates:f}=u[h],p=isBlankNodeId(h)?s.blankNode(getBlankNodeValue(h)):s.namedNode(h);n.push(...subjectToRdfJsQuads(f,p,c,e))})}),n}function subjectToRdfJsQuads(i,e,t,n={}){var s;const a=[],u=(s=n.dataFactory)!==null&&s!==void 0?s:DataFactory;return Object.keys(i).forEach(c=>{var h,f,p,g;const y=u.namedNode(c),S=(h=i[c].langStrings)!==null&&h!==void 0?h:{},w=(f=i[c].namedNodes)!==null&&f!==void 0?f:[],R=(p=i[c].literals)!==null&&p!==void 0?p:{},T=(g=i[c].blankNodes)!==null&&g!==void 0?g:[];Object.keys(R).forEach(x=>{const D=u.namedNode(x);R[x].forEach(K=>{const z=u.literal(K,D);a.push(u.quad(e,y,z,t))})}),Object.keys(S).forEach(x=>{S[x].forEach(O=>{const K=u.literal(O,x);a.push(u.quad(e,y,K,t))})}),w.forEach(x=>{const D=u.namedNode(x);a.push(u.quad(e,y,D,t))}),T.forEach(x=>{if(isBlankNodeId(x)){const D=u.blankNode(getBlankNodeValue(x));a.push(u.quad(e,y,D,t))}else{const D=u.blankNode(),O=u.quad(e,y,D,t),K=subjectToRdfJsQuads(x,D,t);a.push(O),a.push(...K)}})}),a}function fromRdfJsDataset(i){const e={graphs:{default:{}},type:"Dataset"};return Array.from(i).reduce((t,n)=>addRdfJsQuadToDataset(t,n),e)}function internal_getReadableValue(i){var e,t,n,s,a,u,c,h;if(isNamedNode(i))return`<${i.value}> (URL)`;if(isLiteral(i)){if(!isNamedNode(i.datatype))return`[${i.value}] (RDF/JS Literal of unknown type)`;let f;switch(i.datatype.value){case xmlSchemaTypes.boolean:return f=(t=(e=deserializeBoolean(i.value))===null||e===void 0?void 0:e.valueOf())!==null&&t!==void 0?t:`Invalid data: \`${i.value}\``,`${f} (boolean)`;case xmlSchemaTypes.dateTime:return f=(s=(n=deserializeDatetime(i.value))===null||n===void 0?void 0:n.toUTCString())!==null&&s!==void 0?s:`Invalid data: \`${i.value}\``,`${f} (datetime)`;case xmlSchemaTypes.decimal:return f=(u=(a=deserializeDecimal(i.value))===null||a===void 0?void 0:a.toString())!==null&&u!==void 0?u:`Invalid data: \`${i.value}\``,`${f} (decimal)`;case xmlSchemaTypes.integer:return f=(h=(c=deserializeInteger(i.value))===null||c===void 0?void 0:c.toString())!==null&&h!==void 0?h:`Invalid data: \`${i.value}\``,`${f} (integer)`;case xmlSchemaTypes.langString:return`"${i.value}" (${i.language} string)`;case xmlSchemaTypes.string:return`"${i.value}" (string)`;default:return`[${i.value}] (RDF/JS Literal of type: \`${i.datatype.value}\`)`}}return i.termType==="BlankNode"?`[${i.value}] (RDF/JS BlankNode)`:i.termType==="Quad"?"??? (nested RDF* Quad)":i.termType==="Variable"?`?${i.value} (RDF/JS Variable)`:i}function internal_throwIfNotThing(i){if(!isThing(i))throw new ThingExpectedError(i)}function internal_addAdditionsToChangeLog(i,e){const t=hasChangelog(i)?i.internal_changeLog:{additions:[],deletions:[]},[n,s]=e.filter(a=>!containsBlankNode(a)).reduce(([a,u],c)=>typeof u.find(f=>f.equals(c))<"u"?[a,u.filter(f=>!f.equals(c))]:[a.concat(c),u],[t.additions,t.deletions]);return freeze({...i,internal_changeLog:{additions:n,deletions:s}})}function internal_addDeletionsToChangeLog(i,e){const t=hasChangelog(i)?i.internal_changeLog:{additions:[],deletions:[]},[n,s]=e.filter(a=>!containsBlankNode(a)).reduce(([a,u],c)=>typeof a.find(f=>f.equals(c))<"u"?[a.filter(f=>!f.equals(c)),u]:[a,u.concat(c)],[t.additions,t.deletions]);return freeze({...i,internal_changeLog:{additions:n,deletions:s}})}function internal_withChangeLog(i){return hasChangelog(i)?i:freeze({...i,internal_changeLog:{additions:[],deletions:[]}})}function containsBlankNode(i){return i.subject.termType==="BlankNode"||i.object.termType==="BlankNode"}function getUrl(i,e){var t,n,s;if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const a=internal_toIriString(e),u=(s=(n=(t=i.predicates[a])===null||t===void 0?void 0:t.namedNodes)===null||n===void 0?void 0:n[0])!==null&&s!==void 0?s:null;return u===null?null:isLocalNodeIri(u)?`#${getLocalNodeName(u)}`:u}function getUrlAll(i,e){var t,n,s;if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const a=internal_toIriString(e);return(s=(n=(t=i.predicates[a])===null||t===void 0?void 0:t.namedNodes)===null||n===void 0?void 0:n.map(u=>isLocalNodeIri(u)?`#${getLocalNodeName(u)}`:u))!==null&&s!==void 0?s:[]}const getIriAll=getUrlAll;function getStringNoLocale(i,e){return internal_throwIfNotThing(i),getLiteralOfType(i,e,xmlSchemaTypes.string)}function getNamedNodeAll(i,e){return getIriAll(i,e).map(n=>DataFactory.namedNode(n))}function getLiteralAll(i,e){var t,n,s,a;if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const u=internal_toIriString(e);let c=[];const h=(n=(t=i.predicates[u])===null||t===void 0?void 0:t.langStrings)!==null&&n!==void 0?n:{},f=Object.keys(h);for(const y of f){const w=h[y].map(R=>DataFactory.literal(R,y));c=c.concat(w)}const p=(a=(s=i.predicates[u])===null||s===void 0?void 0:s.literals)!==null&&a!==void 0?a:{},g=Object.keys(p);for(const y of g){const S=p[y],w=DataFactory.namedNode(y),R=S.map(T=>DataFactory.literal(T,w));c=c.concat(R)}return c}function getTermAll(i,e){var t,n;internal_throwIfNotThing(i);const s=getNamedNodeAll(i,e),a=getLiteralAll(i,e),u=internal_toIriString(e),h=((n=(t=i.predicates[u])===null||t===void 0?void 0:t.blankNodes)!==null&&n!==void 0?n:[]).map(p=>{const g=isBlankNodeId(p)?getBlankNodeValue(p):void 0;return DataFactory.blankNode(g)});return s.concat(a).concat(h)}function getLiteralOfType(i,e,t){var n,s,a,u;if(!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const c=internal_toIriString(e);return(u=(a=(s=(n=i.predicates[c])===null||n===void 0?void 0:n.literals)===null||s===void 0?void 0:s[t])===null||a===void 0?void 0:a[0])!==null&&u!==void 0?u:null}function getThing(i,e,t={}){var n;if(!internal_isValidUrl(e)&&!e.match(/^_:/))throw new ValidThingUrlExpectedError(e);const s=typeof t.scope<"u"?internal_toIriString(t.scope):"default",a=(n=i.graphs[s])!==null&&n!==void 0?n:{},u=internal_toIriString(e),c=isLocalNodeIri(u)&&hasServerResourceInfo(i)?resolveLocalIri(getLocalNodeName(u),getSourceUrl(i)):u,h=a[c];return typeof h>"u"?null:h}function getThingAll(i,e={acceptBlankNodes:!1}){var t;const n=typeof e.scope<"u"?internal_toIriString(e.scope):"default",s=(t=i.graphs[n])!==null&&t!==void 0?t:{};return Object.values(s).filter(a=>!isBlankNodeId(a.url)||e.acceptBlankNodes)}function setThing(i,e){var t;const n=isThingLocal(e)&&hasServerResourceInfo(i)?resolveLocalIri(getLocalNodeName(e.url),getSourceUrl(i)):e.url,s=i.graphs.default,a=freeze({...s,[n]:freeze({...e,url:n})}),u=freeze({...i.graphs,default:a}),c=DataFactory.namedNode(n),h=(t=i.graphs.default[n])===null||t===void 0?void 0:t.predicates,f=typeof h<"u"?subjectToRdfJsQuads(h,c,DataFactory.defaultGraph()):[],p=subjectToRdfJsQuads(e.predicates,c,DataFactory.defaultGraph());return internal_addAdditionsToChangeLog(internal_addDeletionsToChangeLog(freeze({...i,graphs:u}),f),p)}function createThing(i={}){var e;if(typeof i.url<"u"){const{url:a}=i;if(!internal_isValidUrl(a))throw new ValidThingUrlExpectedError(a);return freeze({type:"Subject",predicates:freeze({}),url:a})}const t=(e=i.name)!==null&&e!==void 0?e:generateName(),n=getLocalNodeIri(t);return freeze({type:"Subject",predicates:freeze({}),url:n})}function isThing(i){return typeof i=="object"&&i!==null&&typeof i.type=="string"&&i.type==="Subject"}function asUrl(i,e){if(isThingLocal(i)){if(typeof e>"u")throw new Error("The URL of a Thing that has not been persisted cannot be determined without a base URL.");return resolveLocalIri(getLocalNodeName(i.url),e)}return i.url}const asIri=asUrl;function thingAsMarkdown(i){let e="";isThingLocal(i)?e+=`## Thing (no URL yet — identifier: \`#${getLocalNodeName(i.url)}\`)
185
+ `:e+=`## Thing: ${i.url}
186
+ `;const t=Object.keys(i.predicates);if(t.length===0)e+=`
187
+ <empty>
188
+ `;else for(const n of t){e+=`
189
+ Property: ${n}
190
+ `;const s=getTermAll(i,n);e+=s.reduce((a,u)=>`${a}- ${internal_getReadableValue(u)}
191
+ `,"")}return e}function isThingLocal(i){return isLocalNodeIri(i.url)}class ThingExpectedError extends SolidClientError{constructor(e){const t=`Expected a Thing, but received: [${e}].`;super(t),this.receivedValue=e}}class ValidPropertyUrlExpectedError extends SolidClientError{constructor(e){const t=isNamedNode(e)?e.value:e,n=`Expected a valid URL to identify a property, but received: [${t}].`;super(n),this.receivedProperty=t}}class ValidValueUrlExpectedError extends SolidClientError{constructor(e){const t=isNamedNode(e)?e.value:e,n=`Expected a valid URL value, but received: [${t}].`;super(n),this.receivedValue=t}}class ValidThingUrlExpectedError extends SolidClientError{constructor(e){const t=isNamedNode(e)?e.value:e,n=`Expected a valid URL to identify a Thing, but received: [${t}].`;super(n),this.receivedValue=t}}const generateName=()=>v4();function normalizeServerSideIri(i){const e=new URL(i);return e.hash="",e.href}function createSolidDataset(){return freeze({type:"Dataset",graphs:{default:{}}})}async function responseToSolidDataset(i,e={}){if(internal_isUnsuccessfulResponse(i)){const p=await i.clone().text();throw new FetchError(`Fetching the SolidDataset at [${i.url}] failed: [${i.status}] [${i.statusText}] ${p}.`,i,p)}const t=responseToResourceInfo(i),n={"text/turtle":getTurtleParser(),...e.parsers},s=getContentType(t);if(s===null)throw new Error(`Could not determine the content type of the Resource at [${getSourceUrl(t)}].`);const a=s.split(";")[0],u=n[a];if(typeof u>"u")throw new Error(`The Resource at [${getSourceUrl(t)}] has a MIME type of [${a}], but the only parsers available are for the following MIME types: [${Object.keys(n).join(", ")}].`);const c=await i.text(),h=await new Promise((p,g)=>{const y=new N3Store;u.onError(S=>{g(new Error(`Encountered an error parsing the Resource at [${getSourceUrl(t)}] with content type [${s}]: ${S}`))}),u.onQuad(S=>{y.add(S)}),u.onComplete(()=>{p(y)}),u.parse(c,t)}),f=freeze(fromRdfJsDataset(h));return freeze({...f,...t})}async function getSolidDataset(i,e){var t,n;const s=normalizeUrl(internal_toIriString(i)),a=Object.keys((t=e?.parsers)!==null&&t!==void 0?t:{}),u=a.length>0?a.join(", "):"text/turtle",c=await((n=e?.fetch)!==null&&n!==void 0?n:fetch)(s,{headers:{Accept:u}});if(internal_isUnsuccessfulResponse(c)){const f=await c.clone().text();throw new FetchError(`Fetching the Resource at [${s}] failed: [${c.status}] [${c.statusText}] ${f}.`,c,f)}return await responseToSolidDataset(c,e)}async function prepareSolidDatasetUpdate(i){const e=i.internal_changeLog.deletions.length>0?`DELETE DATA {${(await triplesToTurtle(i.internal_changeLog.deletions.map(getNamedNodesForLocalNodes))).trim()}};`:"",t=i.internal_changeLog.additions.length>0?`INSERT DATA {${(await triplesToTurtle(i.internal_changeLog.additions.map(getNamedNodesForLocalNodes))).trim()}};`:"";return{method:"PATCH",body:`${e} ${t}`,headers:{"Content-Type":"application/sparql-update"}}}async function prepareSolidDatasetCreation(i,e){return{method:"PUT",body:await triplesToTurtle(toRdfJsQuads(i).map(getNamedNodesForLocalNodes),e),headers:{"Content-Type":"text/turtle","If-None-Match":"*",Link:`<${ldp.Resource}>; rel="type"`}}}async function saveSolidDatasetAt(i,e,t){var n;const s=normalizeUrl(internal_toIriString(i)),a=internal_withChangeLog(e),u=isUpdate(a,s)?await prepareSolidDatasetUpdate(a):await prepareSolidDatasetCreation(a,t),c=await((n=t?.fetch)!==null&&n!==void 0?n:fetch)(s,u);if(internal_isUnsuccessfulResponse(c)){const g=isUpdate(a,s)?`The changes that were sent to the Pod are listed below.
192
+
193
+ ${changeLogAsMarkdown(a)}`:`The SolidDataset that was sent to the Pod is listed below.
194
+
195
+ ${solidDatasetAsMarkdown(a)}`,y=await c.clone().text();throw new FetchError(`Storing the Resource at [${s}] failed: [${c.status}] [${c.statusText}] ${y}.
196
+
197
+ ${g}`,c,y)}const h={...internal_parseResourceInfo(c),isRawData:!1},f=freeze({...e,internal_changeLog:{additions:[],deletions:[]},internal_resourceInfo:h});return resolveLocalIrisInSolidDataset(f)}async function createContainerAt(i,e={}){var t,n;const s=normalizeUrl(internal_toIriString(i),{trailingSlash:!0}),a=await((t=e.fetch)!==null&&t!==void 0?t:fetch)(s,{method:"PUT",body:e.initialContent?await triplesToTurtle(toRdfJsQuads(e.initialContent).map(getNamedNodesForLocalNodes)):void 0,headers:{Accept:"text/turtle","Content-Type":"text/turtle","If-None-Match":"*",Link:`<${ldp.BasicContainer}>; rel="type"`}});if(internal_isUnsuccessfulResponse(a)){const h=e.initialContent===void 0?"empty":"non-empty",f=await a.clone().text();throw new FetchError(`Creating the ${h} Container at [${i}] failed: [${a.status}] [${a.statusText}] ${f}.`,a,f)}const u=internal_parseResourceInfo(a);return freeze({...(n=e.initialContent)!==null&&n!==void 0?n:createSolidDataset(),internal_changeLog:{additions:[],deletions:[]},internal_resourceInfo:u})}function isSourceIriEqualTo(i,e){return normalizeServerSideIri(i.internal_resourceInfo.sourceIri)===normalizeServerSideIri(e)}function isUpdate(i,e){return hasChangelog(i)&&hasResourceInfo(i)&&typeof i.internal_resourceInfo.sourceIri=="string"&&isSourceIriEqualTo(i,e)}function solidDatasetAsMarkdown(i){let e="";hasResourceInfo(i)?e+=`# SolidDataset: ${getSourceUrl(i)}
198
+ `:e+=`# SolidDataset (no URL yet)
199
+ `;const t=getThingAll(i);return t.length===0?e+=`
200
+ <empty>
201
+ `:t.forEach(n=>{e+=`
202
+ ${thingAsMarkdown(n)}`,hasChangelog(i)&&(e+=`
203
+ ${getReadableChangeLogSummary(i,n)}
204
+ `)}),e}function changeLogAsMarkdown(i){if(!hasResourceInfo(i))return"This is a newly initialized SolidDataset, so there is no source to compare it to.";if(!hasChangelog(i)||i.internal_changeLog.additions.length===0&&i.internal_changeLog.deletions.length===0)return`## Changes compared to ${getSourceUrl(i)}
205
+
206
+ This SolidDataset has not been modified since it was fetched from ${getSourceUrl(i)}.
207
+ `;let e=`## Changes compared to ${getSourceUrl(i)}
208
+ `;const t=sortChangeLogByThingAndProperty(i);return Object.keys(t).forEach(n=>{e+=`
209
+ ### Thing: ${n}
210
+ `;const s=t[n];Object.keys(s).forEach(a=>{e+=`
211
+ Property: ${a}
212
+ `;const{deleted:u}=s[a],{added:c}=s[a];u.length>0&&(e+=`- Removed:
213
+ `,e+=u.reduce((h,f)=>`${h} - ${internal_getReadableValue(f)}
214
+ `,"")),c.length>0&&(e+=`- Added:
215
+ `,e+=c.reduce((h,f)=>`${h} - ${internal_getReadableValue(f)}
216
+ `,""))})}),e}function sortChangeLogByThingAndProperty(i){const e=Object.create(null);return i.internal_changeLog.deletions.forEach(t=>{var n,s,a;const u=isLocalNode(t.subject)?resolveIriForLocalNode(t.subject,getSourceUrl(i)):t.subject;if(!isNamedNode(u)||!isNamedNode(t.predicate))return;const c=internal_toIriString(u),h=internal_toIriString(t.predicate);(n=e[c])!==null&&n!==void 0||(e[c]=Object.create(null)),(s=(a=e[c])[h])!==null&&s!==void 0||(a[h]={added:[],deleted:[]}),e[c][h].deleted.push(t.object)}),i.internal_changeLog.additions.forEach(t=>{var n,s,a;const u=isLocalNode(t.subject)?resolveIriForLocalNode(t.subject,getSourceUrl(i)):t.subject;if(!isNamedNode(u)||!isNamedNode(t.predicate))return;const c=internal_toIriString(u),h=internal_toIriString(t.predicate);(n=e[c])!==null&&n!==void 0||(e[c]=Object.create(null)),(s=(a=e[c])[h])!==null&&s!==void 0||(a[h]={added:[],deleted:[]}),e[c][h].added.push(t.object)}),e}function getReadableChangeLogSummary(i,e){const t=DataFactory.namedNode(e.url),n=i.internal_changeLog.additions.reduce((c,h)=>h.subject.equals(t)?c+1:c,0),s=i.internal_changeLog.deletions.reduce((c,h)=>h.subject.equals(t)?c+1:c,0),a=n===1?"1 new value added":`${n} new values added`,u=s===1?"1 value removed":`${s} values removed`;return`(${a} / ${u})`}function getNamedNodesForLocalNodes(i){const e=isNamedNode(i.subject)?getNamedNodeFromLocalNode(i.subject):i.subject,t=isNamedNode(i.object)?getNamedNodeFromLocalNode(i.object):i.object;return DataFactory.quad(e,i.predicate,t,i.graph)}function getNamedNodeFromLocalNode(i){return isLocalNodeIri(i.value)?DataFactory.namedNode(`#${getLocalNodeName(i.value)}`):i}function resolveLocalIrisInSolidDataset(i){const e=getSourceUrl(i),t=i.graphs.default,s=Object.keys(t).reduce((u,c)=>{const h=resolveLocalIrisInThing(u[c],e),f=isLocalNodeIri(c)?`${e}#${getLocalNodeName(c)}`:c,p={...u};return delete p[c],p[f]=h,freeze(p)},t),a=freeze({...i.graphs,default:s});return freeze({...i,graphs:a})}function resolveLocalIrisInThing(i,e){const n=Object.keys(i.predicates).reduce((s,a)=>{var u;const c=(u=s[a].namedNodes)!==null&&u!==void 0?u:[];if(c.every(p=>!isLocalNodeIri(p)))return s;const h=freeze(c.map(p=>isLocalNodeIri(p)?`${e}#${getLocalNodeName(p)}`:p)),f=freeze({...s[a],namedNodes:h});return freeze({...s,[a]:f})},i.predicates);return freeze({...i,predicates:n,url:isLocalNodeIri(i.url)?`${e}#${getLocalNodeName(i.url)}`:i.url})}const addUrl=(i,e,t)=>{var n,s;if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);if(!isThing(t)&&!internal_isValidUrl(t))throw new ValidValueUrlExpectedError(t);const a=internal_toIriString(e),u=(n=i.predicates[a])!==null&&n!==void 0?n:{},c=(s=u.namedNodes)!==null&&s!==void 0?s:[];let h;isNamedNode(t)?h=t.value:typeof t=="string"?h=t:isThingLocal(t)?h=t.url:h=asIri(t);const f=freeze(c.concat(internal_toIriString(h))),p=freeze({...u,namedNodes:f}),g=freeze({...i.predicates,[a]:p});return freeze({...i,predicates:g})},addIri=addUrl,addBoolean=(i,e,t)=>(internal_throwIfNotThing(i),addLiteralOfType(i,e,serializeBoolean(t),xmlSchemaTypes.boolean)),addDatetime=(i,e,t)=>(internal_throwIfNotThing(i),addLiteralOfType(i,e,serializeDatetime(t),xmlSchemaTypes.dateTime)),addDate=(i,e,t)=>(internal_throwIfNotThing(i),addLiteralOfType(i,e,serializeDate(t),xmlSchemaTypes.date)),addTime=(i,e,t)=>(internal_throwIfNotThing(i),addLiteralOfType(i,e,serializeTime(t),xmlSchemaTypes.time)),addDecimal=(i,e,t)=>(internal_throwIfNotThing(i),addLiteralOfType(i,e,serializeDecimal(t),xmlSchemaTypes.decimal)),addInteger=(i,e,t)=>(internal_throwIfNotThing(i),addLiteralOfType(i,e,serializeInteger(t),xmlSchemaTypes.integer));function addStringWithLocale(i,e,t,n){var s,a,u;if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const c=internal_toIriString(e),h=normalizeLocale(n),f=(s=i.predicates[c])!==null&&s!==void 0?s:{},p=(a=f.langStrings)!==null&&a!==void 0?a:{},g=(u=p[h])!==null&&u!==void 0?u:[],y=freeze(g.concat(t)),S=freeze({...p,[h]:y}),w=freeze({...f,langStrings:S}),R=freeze({...i.predicates,[c]:w});return freeze({...i,predicates:R})}const addStringNoLocale=(i,e,t)=>(internal_throwIfNotThing(i),addLiteralOfType(i,e,t,xmlSchemaTypes.string));function addNamedNode(i,e,t){return addUrl(i,e,t.value)}function addLiteral(i,e,t){if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);return t.datatype.value===xmlSchemaTypes.langString?addStringWithLocale(i,e,t.value,t.language):addLiteralOfType(i,e,t.value,t.datatype.value)}function addTerm(i,e,t){var n,s;if(t.termType==="NamedNode")return addNamedNode(i,e,t);if(t.termType==="Literal")return addLiteral(i,e,t);if(t.termType==="BlankNode"){if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const a=internal_toIriString(e),u=(n=i.predicates[a])!==null&&n!==void 0?n:{},c=(s=u.blankNodes)!==null&&s!==void 0?s:[],h=freeze(c.concat(getBlankNodeId(t))),f=freeze({...u,blankNodes:h}),p=freeze({...i.predicates,[a]:f});return freeze({...i,predicates:p})}throw new Error(`Term type [${t.termType}] is not supported by @inrupt/solid-client.`)}function addLiteralOfType(i,e,t,n){var s,a,u;if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const c=internal_toIriString(e),h=(s=i.predicates[c])!==null&&s!==void 0?s:{},f=(a=h.literals)!==null&&a!==void 0?a:{},p=(u=f[n])!==null&&u!==void 0?u:[],g=freeze(p.concat(t)),y=freeze({...f,[n]:g}),S=freeze({...h,literals:y}),w=freeze({...i.predicates,[c]:S});return freeze({...i,predicates:w})}function removeAll(i,e){if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const t=internal_toIriString(e),n={...i.predicates};return delete n[t],freeze({...i,predicates:freeze(n)})}const removeUrl=(i,e,t)=>{var n,s,a;if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const u=internal_toIriString(e);if(!isThing(t)&&!internal_isValidUrl(t))throw new ValidValueUrlExpectedError(t);const c=isThing(t)?asIri(t):internal_toIriString(t),h=freeze((a=(s=(n=i.predicates[u])===null||n===void 0?void 0:n.namedNodes)===null||s===void 0?void 0:s.filter(g=>g.toLowerCase()!==c.toLowerCase()))!==null&&a!==void 0?a:[]),f=freeze({...i.predicates[u],namedNodes:h}),p=freeze({...i.predicates,[u]:f});return freeze({...i,predicates:p})},removeIri=removeUrl,removeBoolean=(i,e,t)=>(internal_throwIfNotThing(i),removeLiteralMatching(i,e,xmlSchemaTypes.boolean,n=>deserializeBoolean(n)===t)),removeDatetime=(i,e,t)=>(internal_throwIfNotThing(i),removeLiteralMatching(i,e,xmlSchemaTypes.dateTime,n=>{var s;return((s=deserializeDatetime(n))===null||s===void 0?void 0:s.getTime())===t.getTime()})),removeDate=(i,e,t)=>(internal_throwIfNotThing(i),removeLiteralMatching(i,e,xmlSchemaTypes.date,function(n){const s=deserializeDate(n);return s?s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getUTCDate()===t.getUTCDate():!1})),removeTime=(i,e,t)=>(internal_throwIfNotThing(i),removeLiteralMatching(i,e,xmlSchemaTypes.time,function(n){const s=deserializeTime(n);return s?s.hour===t.hour&&s.minute===t.minute&&s.second===t.second&&s.millisecond===t.millisecond&&s.timezoneHourOffset===t.timezoneHourOffset&&s.timezoneMinuteOffset===t.timezoneMinuteOffset:!1})),removeDecimal=(i,e,t)=>(internal_throwIfNotThing(i),removeLiteralMatching(i,e,xmlSchemaTypes.decimal,n=>deserializeDecimal(n)===t)),removeInteger=(i,e,t)=>(internal_throwIfNotThing(i),removeLiteralMatching(i,e,xmlSchemaTypes.integer,n=>deserializeInteger(n)===t));function removeStringWithLocale(i,e,t,n){var s,a;if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const u=internal_toIriString(e),c=(a=(s=i.predicates[u])===null||s===void 0?void 0:s.langStrings)!==null&&a!==void 0?a:{},h=Object.keys(c).find(w=>normalizeLocale(w)===normalizeLocale(n)&&Array.isArray(c[w])&&c[w].length>0);if(typeof h!="string")return i;const f=c[h],p=freeze(f.filter(w=>w!==t)),g=freeze({...c,[h]:p}),y=freeze({...i.predicates[u],langStrings:g}),S=freeze({...i.predicates,[u]:y});return freeze({...i,predicates:S})}const removeStringNoLocale=(i,e,t)=>(internal_throwIfNotThing(i),removeLiteralMatching(i,e,xmlSchemaTypes.string,n=>n===t));function removeNamedNode(i,e,t){return removeUrl(i,e,t.value)}function removeLiteral(i,e,t){var n,s,a;if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const u=t.datatype.value;if(u===xmlSchemaTypes.langString)return removeStringWithLocale(i,e,t.value,t.language);const c=internal_toIriString(e),h=(n=i.predicates[c])!==null&&n!==void 0?n:{},f=(s=h.literals)!==null&&s!==void 0?s:{},p=(a=f[u])!==null&&a!==void 0?a:[],g=freeze(p.filter(T=>T!==t.value)),y=freeze({...f,[u]:g}),S=freeze({...h,literals:y}),w=freeze({...i.predicates,[c]:S});return freeze({...i,predicates:w})}function removeLiteralMatching(i,e,t,n){var s,a,u;if(!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);const c=internal_toIriString(e),h=(s=i.predicates[c])!==null&&s!==void 0?s:{},f=(a=h.literals)!==null&&a!==void 0?a:{},p=(u=f[t])!==null&&u!==void 0?u:[],g=freeze(p.filter(T=>!n(T))),y=freeze({...f,[t]:g}),S=freeze({...h,literals:y}),w=freeze({...i.predicates,[c]:S});return freeze({...i,predicates:w})}const setUrl=(i,e,t)=>{if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);if(!isThing(t)&&!internal_isValidUrl(t))throw new ValidValueUrlExpectedError(t);return addUrl(removeAll(i,e),e,t)},setIri=setUrl,setBoolean=(i,e,t)=>(internal_throwIfNotThing(i),addBoolean(removeAll(i,e),e,t)),setDatetime=(i,e,t)=>(internal_throwIfNotThing(i),addDatetime(removeAll(i,e),e,t)),setDate=(i,e,t)=>(internal_throwIfNotThing(i),addDate(removeAll(i,e),e,t)),setTime=(i,e,t)=>(internal_throwIfNotThing(i),addTime(removeAll(i,e),e,t)),setDecimal=(i,e,t)=>(internal_throwIfNotThing(i),addDecimal(removeAll(i,e),e,t)),setInteger=(i,e,t)=>(internal_throwIfNotThing(i),addInteger(removeAll(i,e),e,t));function setStringWithLocale(i,e,t,n){return internal_throwIfNotThing(i),addStringWithLocale(removeAll(i,e),e,t,n)}const setStringNoLocale=(i,e,t)=>(internal_throwIfNotThing(i),addStringNoLocale(removeAll(i,e),e,t));function setNamedNode(i,e,t){return internal_throwIfNotThing(i),addNamedNode(removeAll(i,e),e,t)}function setLiteral(i,e,t){return internal_throwIfNotThing(i),addLiteral(removeAll(i,e),e,t)}function setTerm(i,e,t){if(internal_throwIfNotThing(i),!internal_isValidUrl(e))throw new ValidPropertyUrlExpectedError(e);return addTerm(removeAll(i,e),e,t)}function buildThing(i=createThing()){let e=isThing(i)?i:createThing(i);function t(u){return(c,h)=>(e=u(e,c,h),a)}function n(u){return(c,h)=>(e=u(e,c,h),a)}function s(u){return(c,h)=>(e=u(e,c,h),a)}const a={build:()=>e,addUrl:t(addUrl),addIri:t(addIri),addBoolean:t(addBoolean),addDatetime:t(addDatetime),addDate:t(addDate),addTime:t(addTime),addDecimal:t(addDecimal),addInteger:t(addInteger),addStringNoLocale:t(addStringNoLocale),addStringEnglish:(u,c)=>(e=addStringWithLocale(e,u,c,"en"),a),addStringWithLocale:(u,c,h)=>(e=addStringWithLocale(e,u,c,h),a),addNamedNode:t(addNamedNode),addLiteral:t(addLiteral),addTerm:t(addTerm),setUrl:n(setUrl),setIri:n(setIri),setBoolean:n(setBoolean),setDatetime:n(setDatetime),setDate:n(setDate),setTime:n(setTime),setDecimal:n(setDecimal),setInteger:n(setInteger),setStringNoLocale:n(setStringNoLocale),setStringEnglish:(u,c)=>(e=setStringWithLocale(e,u,c,"en"),a),setStringWithLocale:(u,c,h)=>(e=setStringWithLocale(e,u,c,h),a),setNamedNode:n(setNamedNode),setLiteral:n(setLiteral),setTerm:n(setTerm),removeAll:u=>(e=removeAll(e,u),a),removeUrl:s(removeUrl),removeIri:s(removeIri),removeBoolean:s(removeBoolean),removeDatetime:s(removeDatetime),removeDate:s(removeDate),removeTime:s(removeTime),removeDecimal:s(removeDecimal),removeInteger:s(removeInteger),removeStringNoLocale:s(removeStringNoLocale),removeStringEnglish:(u,c)=>buildThing(removeStringWithLocale(e,u,c,"en")),removeStringWithLocale:(u,c,h)=>buildThing(removeStringWithLocale(e,u,c,h)),removeNamedNode:s(removeNamedNode),removeLiteral:s(removeLiteral)};return a}const normalizeRdfClass=i=>i&&(i.startsWith("http://schema.org/")?i.replace("http://schema.org/","https://schema.org/"):i);class InteropDiscovery{constructor(e,t,n){this.webId=e,this.fetchFn=t,this.clientId=n,this.shapeTreeCache=new Map}async ensureRegistrySet(e,t,n){if(!n?.registryPath)throw new Error("Missing registryPath for SAI registry auto-creation.");const s=n.registryPath.endsWith("/")?n.registryPath:`${n.registryPath}/`,a=s.replace(/[^/]+\/$/,""),u=`${s}agents/`,c=`${s}set.ttl`,f=`${c}#set-drizzle-solid`,p=`${s}data-registry.ttl`,y=`${p}#data-registry`;try{a&&a!==s&&await createContainerAt(a,{fetch:this.fetchFn}),await createContainerAt(s,{fetch:this.fetchFn})}catch{}try{await createContainerAt(u,{fetch:this.fetchFn})}catch{}const S=setUrl(createThing({url:y}),"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",INTEROP.DataRegistry);let w;try{w=await getSolidDataset(p,{fetch:this.fetchFn})}catch{w=void 0}if(w){if(!getThing(w,y)){const O=setThing(w,S);await saveSolidDatasetAt(p,O,{fetch:this.fetchFn})}}else{let D=createSolidDataset();D=setThing(D,S),await saveSolidDatasetAt(p,D,{fetch:this.fetchFn})}let R=createThing({url:f});R=setUrl(R,"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",INTEROP.RegistrySet),R=addUrl(R,INTEROP.hasDataRegistry,y),R=addUrl(R,"http://www.w3.org/ns/solid/interop#hasAgentRegistry",u);let T;try{T=await getSolidDataset(c,{fetch:this.fetchFn})}catch{T=void 0}if(T){const D=getThing(T,f);if(D){const O=getPredicateForColumn(registrySetSchema.columns.hasDataRegistry,registrySetSchema),K=getPredicateForColumn(registrySetSchema.columns.hasAgentRegistry,registrySetSchema),z=getUrlAll(D,O),X=getUrlAll(D,K);let Ee=D;if(z.includes(y)||(Ee=addUrl(Ee,O,y)),X.includes(u)||(Ee=addUrl(Ee,K,u)),Ee!==D){const q=setThing(T,Ee);await saveSolidDatasetAt(c,q,{fetch:this.fetchFn})}}else{const O=setThing(T,R);await saveSolidDatasetAt(c,O,{fetch:this.fetchFn})}}else{let D=createSolidDataset();D=setThing(D,R),await saveSolidDatasetAt(c,D,{fetch:this.fetchFn})}const A=setUrl(t,INTEROP.hasRegistrySet,f),F=setThing(e,A),x=this.webId.split("#")[0];return await saveSolidDatasetAt(x,F,{fetch:this.fetchFn}),f}async register(e,t){if(!t?.registryPath)throw new Error("registryPath is required for SAI registration.");const n=typeof e.config.type=="string"?e.config.type:e.config.type.value,s=normalizeRdfClass(n)??n;try{const a=await getSolidDataset(this.webId,{fetch:this.fetchFn}),u=getThing(a,this.webId);if(!u)throw new Error("Profile not found");let c=getUrl(u,INTEROP.hasRegistrySet),h,f;if(c)try{h=await getSolidDataset(c,{fetch:this.fetchFn}),f=getThing(h,c)}catch{h=void 0,f=void 0}if((!c||!f)&&(c=await this.ensureRegistrySet(a,u,t),h=await getSolidDataset(c,{fetch:this.fetchFn}),f=getThing(h,c),!f))throw new Error("RegistrySet not found");if(!t?.force&&(await this.discover(n)).length>0){console.log(`[InteropDiscovery] ${e.config.name} already registered, skipping`);return}const p=getPredicateForColumn(registrySetSchema.columns.hasDataRegistry,registrySetSchema),g=getUrlAll(f,p);if(g.length===0)throw new Error("No DataRegistry found");const y=g[0],S=t?.containerSlug??e.config.name,w=y.endsWith("/")?y:y+"/",R=`${w}${S}/`;try{await getSolidDataset(R,{fetch:this.fetchFn})}catch{await createContainerAt(R,{fetch:this.fetchFn})}const T=`${w}${S}`,A=`${T}#ShapeTree`;let F=createThing({url:A});F=setUrl(F,"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",SHAPETREES.ShapeTree),F=setUrl(F,SHAPETREES.expectsType,s),t?.shapeUrl&&(F=setUrl(F,SHAPETREES.shape,t.shapeUrl));let x=createThing({url:T});x=setUrl(x,"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",INTEROP.DataRegistration);const D=this.clientId&&/^https?:\/\//.test(this.clientId)?this.clientId:this.webId;x=setUrl(x,INTEROP.registeredBy,D),x=setDatetime(x,"http://www.w3.org/ns/solid/interop#registeredAt",new Date),x=setUrl(x,INTEROP.registeredShapeTree,A);const O=e.getSubjectTemplate();O&&(x=setStringNoLocale(x,UDFS.subjectTemplate,O));let K;try{K=await getSolidDataset(T,{fetch:this.fetchFn})}catch{K=null}let z=K??createSolidDataset(),X=!1;const Ee=getThing(z,T);if(!Ee)z=setThing(z,x),X=!0;else{let $e=Ee;const ze=getUrl(Ee,INTEROP.registeredBy),ye=getUrl(Ee,INTEROP.registeredShapeTree),Ve=getStringNoLocale(Ee,UDFS.subjectTemplate);ze||($e=setUrl($e,INTEROP.registeredBy,D)),ye||($e=setUrl($e,INTEROP.registeredShapeTree,A)),!Ve&&O&&($e=setStringNoLocale($e,UDFS.subjectTemplate,O)),$e!==Ee&&(z=setThing(z,$e),X=!0)}getThing(z,A)||(z=setThing(z,F),X=!0),(!K||X)&&await saveSolidDatasetAt(T,z,{fetch:this.fetchFn});let Y=await getSolidDataset(y,{fetch:this.fetchFn}),Te=getThing(Y,y);if(!Te)throw new Error("Registry Thing missing in Dataset");const re=getPredicateForColumn(dataRegistrySchema.columns.hasDataRegistration,dataRegistrySchema);Te=addUrl(Te,re,T),Y=setThing(Y,Te),await saveSolidDatasetAt(y,Y,{fetch:this.fetchFn}),this.shapeTreeCache.set(A,{expectsType:s,shape:t?.shapeUrl}),console.log(`[InteropDiscovery] Registered ${e.config.name} at ${T}`),console.log(`[InteropDiscovery] -> ShapeTree: ${A}`),console.log(`[InteropDiscovery] -> expectsType: ${s}`),t?.shapeUrl&&console.log(`[InteropDiscovery] -> Shape: ${t.shapeUrl}`)}catch(a){throw console.error("[InteropDiscovery] Registration failed:",a),a}}async discover(e,t){try{const n=[],s=await getSolidDataset(this.webId,{fetch:this.fetchFn}),a=getThing(s,this.webId);if(!a)return[];const u=getUrlAll(a,INTEROP.hasRegistrySet);if(u.length===0)return[];for(const c of u){const h=await this.discoverDataRegistrationsRaw(c,e,t);n.push(...h);const f=await this.discoverAccessGrantsRaw(c,e,t);n.push(...f)}return this.mergeByContainer(n)}catch(n){return console.error("[InteropDiscovery] Discovery failed:",n),[]}}mergeByContainer(e){const t=new Map;for(const n of e){const s=t.get(n.container),a=n.shape?{url:n.shape,shapeTree:n.shapeTree,registeredBy:n.registeredBy,source:n.source}:void 0;s?(a&&!s.shapes.some(u=>u.url===a.url)&&s.shapes.push(a),!s.subjectTemplate&&n.subjectTemplate&&(s.subjectTemplate=n.subjectTemplate)):t.set(n.container,{container:n.container,subjectTemplate:n.subjectTemplate,shapes:a?[a]:[],source:n.source})}return Array.from(t.values())}async discoverDataRegistrationsRaw(e,t,n){const s=[],a=normalizeRdfClass(t)??t;try{const u=await getSolidDataset(e,{fetch:this.fetchFn}),c=getThing(u,e);if(!c)return[];const h=getPredicateForColumn(registrySetSchema.columns.hasDataRegistry,registrySetSchema),f=getUrlAll(c,h);for(const p of f)try{const g=await getSolidDataset(p,{fetch:this.fetchFn}),y=getThing(g,p);if(!y)continue;const S=getPredicateForColumn(dataRegistrySchema.columns.hasDataRegistration,dataRegistrySchema),w=getUrlAll(y,S);for(const R of w){const T=await getSolidDataset(R,{fetch:this.fetchFn}),A=getThing(T,R);if(!A)continue;const F=getPredicateForColumn(dataRegistrationSchema.columns.registeredShapeTree,dataRegistrationSchema),x=getUrl(A,F);if(!x)continue;const D=getPredicateForColumn(dataRegistrationSchema.columns.registeredBy,dataRegistrationSchema),O=getUrl(A,D),K=getStringNoLocale(A,UDFS.subjectTemplate)??void 0;if(n?.appId&&O!==n.appId)continue;const z=await this.resolveShapeTree(x);normalizeRdfClass(z?.expectsType)===a&&s.push({container:R,source:"interop",subjectTemplate:K,shapeTree:x,shape:z?.shape,registeredBy:O??void 0})}}catch(g){console.warn(`[InteropDiscovery] Error checking registry ${p}:`,g)}}catch(u){console.warn(`[InteropDiscovery] Error exploring RegistrySet ${e}:`,u)}return s}async discoverAccessGrantsRaw(e,t,n){if(!this.clientId)return console.warn("[InteropDiscovery] No ClientID available, skipping Access Grant discovery"),[];const s=[],a=normalizeRdfClass(t)??t;try{const u=await getSolidDataset(e,{fetch:this.fetchFn}),c=getThing(u,e);if(!c)return console.warn(`[InteropDiscovery] RegistrySet Thing not found at ${e}`),[];const h=getPredicateForColumn(registrySetSchema.columns.hasAgentRegistry,registrySetSchema),f=getUrlAll(c,h);for(const p of f)try{const g=await getSolidDataset(p,{fetch:this.fetchFn}),y=getThing(g,p);if(!y)continue;const w=getUrlAll(y,"http://www.w3.org/ns/solid/interop#hasApplicationRegistration"),R=getUrlAll(y,"http://www.w3.org/ns/ldp#contains"),T=Array.from(new Set([...w,...R]));for(const A of T)try{const F=await getSolidDataset(A,{fetch:this.fetchFn}),x=getThingAll(F);for(const D of x){const O=getPredicateForColumn(applicationRegistrationSchema.columns.registeredAgent,applicationRegistrationSchema);if(getUrl(D,O)===this.clientId){const z=getPredicateForColumn(applicationRegistrationSchema.columns.hasAccessGrant,applicationRegistrationSchema),X=getUrlAll(D,z);for(const Ee of X){let q=getThing(F,Ee);if(!q){const re=await getSolidDataset(Ee,{fetch:this.fetchFn}).catch(()=>null);re&&(q=getThing(re,Ee))}if(!q)continue;const Y=getPredicateForColumn(accessGrantSchema.columns.hasDataGrant,accessGrantSchema),Te=getUrlAll(q,Y);for(const re of Te){let $e=getThing(F,re);if(!$e){const G=await getSolidDataset(re,{fetch:this.fetchFn}).catch(()=>null);G&&($e=getThing(G,re))}if(!$e)continue;const ze=getPredicateForColumn(dataGrantSchema.columns.registeredShapeTree,dataGrantSchema),ye=getUrl($e,ze);if(!ye)continue;const Ve=getPredicateForColumn(dataGrantSchema.columns.dataOwner,dataGrantSchema),pe=getUrl($e,Ve);if(n?.appId&&pe!==n.appId)continue;const De=await this.resolveShapeTree(ye);if(normalizeRdfClass(De?.expectsType)===a){const G=getPredicateForColumn(dataGrantSchema.columns.hasDataRegistration,dataGrantSchema),ce=getUrl($e,G);console.log(`[InteropDiscovery] Found matching Data Grant: ${re}`),console.log(`[InteropDiscovery] -> ShapeTree: ${ye}`),console.log(`[InteropDiscovery] -> Shape: ${De?.shape}`),console.log(`[InteropDiscovery] -> Data Registration: ${ce}`),ce&&s.push({container:ce,source:"interop",shapeTree:ye,shape:De?.shape,registeredBy:pe??void 0})}else console.log(`[InteropDiscovery] ShapeTree mismatch: ${ye} vs ${t}`)}}}}}catch{}}catch(g){console.warn(`[InteropDiscovery] Error checking AgentRegistry ${p}:`,g)}}catch(u){console.warn("[InteropDiscovery] Error in AccessGrant discovery:",u)}return s}async isRegistered(e){return(await this.discover(e)).length>0}async discoverByApp(e){try{const s=(await this.discoverAll()).filter(a=>a.registeredBy===e).map(a=>({container:a.container,source:"interop",shapeTree:a.shapeTree,shape:a.shape,registeredBy:a.registeredBy}));return this.mergeByContainer(s)}catch(t){return console.error("[InteropDiscovery] discoverByApp failed:",t),[]}}async discoverAll(){const e=[];try{const t=await getSolidDataset(this.webId,{fetch:this.fetchFn}),n=getThing(t,this.webId);if(!n)return[];const s=getUrlAll(n,INTEROP.hasRegistrySet);for(const a of s)try{const u=await getSolidDataset(a,{fetch:this.fetchFn}),c=getThing(u,a);if(!c)continue;const h=getPredicateForColumn(registrySetSchema.columns.hasDataRegistry,registrySetSchema),f=getUrlAll(c,h);for(const p of f)try{const g=await getSolidDataset(p,{fetch:this.fetchFn}),y=getThing(g,p);if(!y)continue;const S=getPredicateForColumn(dataRegistrySchema.columns.hasDataRegistration,dataRegistrySchema),w=getUrlAll(y,S);for(const R of w)try{const T=await getSolidDataset(R,{fetch:this.fetchFn}),A=getThing(T,R);if(!A)continue;const F=getPredicateForColumn(dataRegistrationSchema.columns.registeredShapeTree,dataRegistrationSchema),x=getUrl(A,F);if(!x)continue;const D=getPredicateForColumn(dataRegistrationSchema.columns.registeredBy,dataRegistrationSchema),O=getUrl(A,D),K=getPredicateForColumn(dataRegistrationSchema.columns.registeredAt,dataRegistrationSchema),z=getUrl(A,K),X=z?new Date(z):void 0,Ee=getStringNoLocale(A,UDFS.subjectTemplate)??void 0,q=await this.resolveShapeTree(x);e.push({registrationUrl:R,container:R,rdfClass:q?.expectsType??"",shapeTree:x,shape:q?.shape,subjectTemplate:Ee,registeredBy:O??void 0,registeredAt:X})}catch(T){console.warn(`[InteropDiscovery] Error reading registration ${R}:`,T)}}catch(g){console.warn(`[InteropDiscovery] Error reading registry ${p}:`,g)}}catch(u){console.warn(`[InteropDiscovery] Error reading RegistrySet ${a}:`,u)}}catch(t){console.error("[InteropDiscovery] discoverAll failed:",t)}return e}async checkShapeTreeMatchesClass(e,t){const n=await this.resolveShapeTree(e);return normalizeRdfClass(n?.expectsType)===(normalizeRdfClass(t)??t)}async resolveShapeTree(e){if(this.shapeTreeCache.has(e))return this.shapeTreeCache.get(e);try{const t=await getSolidDataset(e,{fetch:this.fetchFn}),n=getThing(t,e);if(!n)return this.shapeTreeCache.set(e,{}),null;const s=getUrl(n,SHAPETREES.expectsType)??void 0,a=getUrl(n,SHAPETREES.shape)??void 0,u={expectsType:s,shape:a};return this.shapeTreeCache.set(e,u),u}catch(t){return console.warn(`[InteropDiscovery] Failed to fetch ShapeTree ${e}:`,t),this.shapeTreeCache.set(e,{}),null}}}function mergeLocationsByContainer(i){const e=new Map;for(const t of i){const n=e.get(t.container);if(n)for(const s of t.shapes)n.shapes.some(a=>a.url===s.url)||n.shapes.push(s);else e.set(t.container,{container:t.container,subjectPattern:t.subjectPattern,shapes:[...t.shapes],source:t.source})}return Array.from(e.values())}class CompositeDiscovery{constructor(e){this.strategies=e}async register(e,t){const n=[];let s=!1;for(const a of this.strategies)if(!(a instanceof InteropDiscovery&&!t?.registryPath))try{await a.register(e,t),s=!0}catch(u){n.push(u),console.warn("Registration failed with strategy, trying next:",u)}if(!s){const a=n.length>0?` Errors: ${n.map(String).join("; ")}`:"";throw new Error(`Failed to register table with any discovery strategy.${a}`)}}async discover(e,t){const n=[];for(const s of this.strategies)try{const a=await s.discover(e,t);n.push(...a)}catch(a){console.warn("Discovery failed with strategy, trying next:",a)}return mergeLocationsByContainer(n)}async isRegistered(e){for(const t of this.strategies)if(await t.isRegistered(e))return!0;return!1}async discoverAll(){const e=[];for(const t of this.strategies)if(t.discoverAll)try{const n=await t.discoverAll();e.push(...n)}catch(n){console.warn("discoverAll failed with strategy:",n)}return e}async discoverByApp(e){const t=[];for(const n of this.strategies)if(n.discoverByApp)try{const s=await n.discoverByApp(e);t.push(...s)}catch(s){console.warn("discoverByApp failed with strategy:",s)}return mergeLocationsByContainer(t)}}function getContainerUrl(i){try{const e=new URL(i),t=e.pathname.lastIndexOf("/");return t<0?null:(e.pathname=e.pathname.slice(0,t+1),e.search="",e.hash="",e.toString())}catch{const e=i.lastIndexOf("/");return e>0?i.slice(0,e+1):null}}class LdpExecutor{constructor(e,t,n){this.sparqlExecutor=e,this.fetchFn=t,this.uriResolver=n,this.tripleBuilder=new TripleBuilderImpl(n)}setTableRegistry(e,t){this.tripleBuilder.setTableRegistry(e,t)}setBaseUri(e){this.tripleBuilder.setBaseUri(e)}async executeInsert(e,t,n,s={}){s.tableRegistry&&s.tableNameRegistry&&this.setTableRegistry(s.tableRegistry,s.tableNameRegistry);const a=[];if(e.forEach((g,y)=>{const S=this.uriResolver.resolveSubject(t,g,y);t.__currentRecord=g;try{const w=this.tripleBuilder.buildTypeTriple(S,t.config.type);a.push(...this.tripleBuilder.toN3Strings([w])),Object.entries(t.columns??{}).forEach(([R,T])=>{if(g[R]===void 0||g[R]===null||T._virtualId||(T.options?.predicate||T._predicateUri)==="@id")return;const F=this.tripleBuilder.buildInsert(S,T,g[R],t);a.push(...this.tripleBuilder.toN3Strings(F.triples)),F.childTriples&&F.childTriples.length>0&&a.push(...this.tripleBuilder.toN3Strings(F.childTriples))})}finally{delete t.__currentRecord}}),a.length===0)return[];if(this.uriResolver.getResourceMode(t)==="document"){const g=new Map;for(let S=0;S<e.length;S++){const w=e[S],R=this.uriResolver.resolveSubject(t,w,S);t.__currentRecord=w;try{const T=this.uriResolver.getResourceUrl(R),A=[],F=this.tripleBuilder.buildTypeTriple(R,t.config.type);if(A.push(...this.tripleBuilder.toN3Strings([F])),Object.entries(t.columns??{}).forEach(([D,O])=>{if(w[D]===void 0||w[D]===null||O._virtualId||(O.options?.predicate||O._predicateUri)==="@id")return;const z=this.tripleBuilder.buildInsert(R,O,w[D],t);A.push(...this.tripleBuilder.toN3Strings(z.triples)),z.childTriples&&z.childTriples.length>0&&A.push(...this.tripleBuilder.toN3Strings(z.childTriples))}),A.length===0)continue;const x=g.get(T)||{triples:[],hasFragmentSubject:!1};x.triples.push(...A),x.hasFragmentSubject=x.hasFragmentSubject||R.includes("#"),g.set(T,x)}finally{delete t.__currentRecord}}const y=[];for(const[S,w]of g.entries()){const R=w.triples,T=getContainerUrl(S);T&&s.ensureContainerExists&&await s.ensureContainerExists(T);let A=!1;if(!s.skipResourceExistenceCheck){const O=await this.fetchFn(S,{method:"HEAD"});A=O.ok||O.status===405}let F,x;if(s.skipResourceExistenceCheck){const O=`INSERT DATA {
217
+ ${R.join(`
218
+ `)}
219
+ }`;if(F=await this.fetchFn(S,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:O}),x="patch",F.status===404){const K=R.join(`
220
+ `);F=await this.fetchFn(S,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:K}),x="put",F=await this.repairContainerAndRetryPutIfNeeded(F,T,S,K,"text/turtle",s.repairContainerOnWriteFailure)}}else if(A){const O=`INSERT DATA {
221
+ ${R.join(`
222
+ `)}
223
+ }`;F=await this.fetchFn(S,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:O}),x="patch"}else{const O=R.join(`
224
+ `);F=await this.fetchFn(S,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:O}),x="put"}if(![200,201,202,204,205].includes(F.status)){const O=await F.text().catch(()=>"");throw new Error(`Write failed for ${S}: ${F.status} ${F.statusText}${O?` - ${O}`:""}`)}await this.sparqlExecutor.invalidateHttpCache(S);const D=S.lastIndexOf("/");if(D>0){const O=S.slice(0,D+1);await this.sparqlExecutor.invalidateHttpCache(O)}await this.sparqlExecutor.invalidateHttpCache(void 0).catch(()=>{}),y.push({success:!0,source:S,status:F.status,via:x})}return y}const c=getContainerUrl(n);c&&s.ensureContainerExists&&await s.ensureContainerExists(c);const h=`INSERT DATA {
225
+ ${a.join(`
226
+ `)}
227
+ }`;let f=await this.fetchFn(n,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:h});if((f.status===404||f.status===201)&&(s.skipResourceExistenceCheck?!0:await this.fetchFn(n,{method:"HEAD"}).then(y=>!y.ok&&y.status!==405))){let y=await this.fetchFn(n,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:""});y=await this.repairContainerAndRetryPutIfNeeded(y,c,n,"","text/turtle",s.repairContainerOnWriteFailure),(y.ok||y.status===409||y.status===201)&&(f=await this.fetchFn(n,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:h}))}if(!f.ok){const g=await f.text().catch(()=>""),y=new Error(`SPARQL UPDATE INSERT failed: ${f.status} ${f.statusText}${g?` - ${g}`:""}`);throw y.status=f.status,y}await this.sparqlExecutor.invalidateHttpCache(n);const p=n.lastIndexOf("/");if(p>0){const g=n.slice(0,p+1);await this.sparqlExecutor.invalidateHttpCache(g)}return await this.sparqlExecutor.invalidateHttpCache(void 0).catch(()=>{}),[{success:!0,source:n,status:f.status,via:"sparql-update"}]}async repairContainerAndRetryPutIfNeeded(e,t,n,s,a,u){return!u||!t||!this.isMissingParentContainerResponse(e)?e:(await u(t),await this.fetchFn(n,{method:"PUT",headers:{"Content-Type":a},body:s}))}isMissingParentContainerResponse(e){return e.status===404||e.status===409}async executeUpdate(e,t,n,s){if(!n.length)return[];const a=[],u=this.uriResolver.getResourceMode(e);for(const c of n){const h=u==="document"?this.uriResolver.getResourceUrl(c):s,f=await this.buildUpdatePatchPayload(c,e,t,h);if(!f)continue;const{deleteTriples:p,insertTriples:g,deleteWherePatterns:y}=f,S=Object.entries(t).filter(([x,D])=>D!==void 0);for(const[x]of S){if(x==="@id"||x==="subject")continue;const D=e.columns?.[x];if(!D||D._virtualId||D.options?.predicate==="@id"||!(D.dataType==="object"||D.dataType==="json"||D.dataType==="array"&&(D.elementType==="object"||D.options?.baseType==="object")))continue;const K=this.tripleBuilder.getPredicateUri(D,e),z=await this.fetchExistingObjects(h,c,K);for(const X of z){let Ee=X;if(!Ee.startsWith("<")&&!Ee.startsWith("_:")&&(Ee=`<${Ee}>`),p.push(`<${c}> <${K}> ${Ee} .`),Ee.startsWith("<")){const q=Ee.slice(1,-1),Y=await this.fetchRecursiveTriplesToDelete(q,e,h);p.push(...Y)}}}const w=Array.from(new Set(p)),R=Array.from(new Set(g)),T=w.filter(x=>!R.includes(x)),A=R.filter(x=>!w.includes(x));if(T.length===0&&A.length===0)continue;const F=await this.executeN3Patch(h,T,A,[],y);a.push(...F),await new Promise(x=>setTimeout(x,200))}return a}async executeDelete(e,t,n){const s=[],a=this.uriResolver.getResourceMode(t);for(const u of e)try{const c=a==="document"?this.uriResolver.getResourceUrl(u):n,h=await this.fetchRecursiveTriplesToDelete(u,t,c),f=Array.from(new Set(h));if(f.length>0){const p=await this.executeN3Patch(c,f,[],[]);s.push(...p)}}catch(c){throw console.error(`[DELETE] Failed to delete subject ${u}:`,c),c}return s}async retryWithBackoff(e,t=3){let n=null,s;for(let a=0;a<t;a++)try{const u=await e();if(n=u.response,u.result!==void 0)return{response:n,result:u.result};if(u.fallback){const c=await u.fallback();return{response:n,result:c}}if(!u.shouldRetry)break;await new Promise(c=>setTimeout(c,1e3*(a+1)))}catch(u){s=u,a<t-1&&await new Promise(c=>setTimeout(c,1e3*(a+1)))}return{response:n,lastError:s}}async buildPatchError(e,t,n){const s=e?await e.text().catch(()=>""):"",a=e?e.status:"Network Error",u=e?e.statusText:t instanceof Error?t.message:String(t),c=new Error(`${n} failed: ${a} ${u}${s?` - ${s}`:""}`);return c.status=a,c}async buildUpdatePatchPayload(e,t,n,s){const a=[],u=[],c=[];for(const[h,f]of Object.entries(n)){if(f===void 0||h==="@id"||h==="subject")continue;const p=t.columns?.[h];if(!p||p._virtualId||p.options?.predicate==="@id")continue;if(p.dataType==="object"||p.dataType==="json"||p.dataType==="array"&&(p.elementType==="object"||p.options?.baseType==="object")){if(f!==null){const A=this.tripleBuilder.buildInsert(e,p,f,t);u.push(...this.tripleBuilder.toN3Strings(A.triples)),A.childTriples&&u.push(...this.tripleBuilder.toN3Strings(A.childTriples))}continue}const y=this.tripleBuilder.getPredicateUri(p,t),S=!!p.options?.inverse,w=h.replace(/[^a-zA-Z0-9_]/g,"_");if(S){if(c.push(`?s_${w} <${y}> <${e}> .`),(await this.fetchInverseSubjects(s,e,y)).forEach(F=>{let x=F;!x.startsWith("<")&&!x.startsWith("_:")&&(x=`<${x}>`),a.push(`${x} <${y}> <${e}> .`)}),f!==null){const F=this.tripleBuilder.buildInsert(e,p,f,t);u.push(...this.tripleBuilder.toN3Strings(F.triples))}continue}if(c.push(`<${e}> <${y}> ?o_${w} .`),(await this.fetchExistingObjects(s,e,y)).forEach(A=>{a.push(`<${e}> <${y}> ${A} .`)}),f===null)continue;const T=this.tripleBuilder.buildInsert(e,p,f,t);u.push(...this.tripleBuilder.toN3Strings(T.triples))}return{deleteTriples:a,insertTriples:u,deleteWherePatterns:c}}async executeN3Patch(e,t,n,s=[],a=[]){if(t.length===0&&n.length===0&&a.length===0)return[];const u=this.buildSparqlUpdate(t,n,a),{response:c,result:h,lastError:f}=await this.retryWithBackoff(async()=>{const p=await this.fetchFn(e,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:u});if(p.ok)return await this.sparqlExecutor.invalidateHttpCache(e),{response:p,result:[{success:!0,source:e,status:p.status,via:"sparql-update"}],shouldRetry:!1};if(p.status===415||p.status===405){const y=a.length>0?[...t,...a]:t,S=a.length>0?a:s;return{response:p,shouldRetry:!1,fallback:()=>this.executeN3PatchInternal(e,y,n,S)}}const g=p.status>=500||p.status===409;return{response:p,shouldRetry:g}});if(h)return h;throw await this.buildPatchError(c,f,"SPARQL UPDATE")}buildSparqlUpdate(e,t,n){const s=[];if(n.length>0)for(const a of n)s.push(`DELETE WHERE {
228
+ ${a}
229
+ }`);return e.length>0&&s.push(`DELETE DATA {
230
+ ${e.join(`
231
+ `)}
232
+ }`),t.length>0&&s.push(`INSERT DATA {
233
+ ${t.join(`
234
+ `)}
235
+ }`),s.join(`;
236
+ `)}async executeN3PatchInternal(e,t,n,s=[]){const a=this.tripleBuilder.buildN3Patch(t,n,s),{response:u,result:c,lastError:h}=await this.retryWithBackoff(async()=>{let f=await this.fetchFn(e,{method:"PATCH",headers:{"Content-Type":"text/n3"},body:a});if(f.status===404){const g=await this.fetchFn(e,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:""});if(!g.ok&&g.status!==409)throw new Error(`Failed to create resource ${e}: ${g.status} ${g.statusText}`);f=await this.fetchFn(e,{method:"PATCH",headers:{"Content-Type":"text/n3"},body:a})}if(f.ok)return await this.sparqlExecutor.invalidateHttpCache(e),{response:f,result:[{success:!0,source:e,status:f.status,via:"n3"}],shouldRetry:!1};const p=f.status>=500||f.status===409;return{response:f,shouldRetry:p}});if(c)return c;throw await this.buildPatchError(u,h,"N3 PATCH")}formatTerm(e){if(!e)return"";if(e.termType==="NamedNode")return`<${e.value}>`;if(e.termType==="BlankNode")return`_:${e.value}`;if(e.termType==="Literal"){const n=`"${String(e.value??"").replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")}"`;if(e.language)return`${n}@${e.language}`;if(e.datatype&&e.datatype.value){if(e.datatype.value==="http://www.w3.org/2001/XMLSchema#integer"||e.datatype.value.endsWith("#integer"))return e.value;if(e.datatype.value!=="http://www.w3.org/2001/XMLSchema#string")return`${n}^^<${e.datatype.value}>`}return n}return String(e.value??e)}async fetchRecursiveTriplesToDelete(e,t,n,s=new Set){if(s.has(e))return[];s.add(e);const a=`SELECT ?p ?o WHERE { <${e}> ?p ?o . }`,u=await this.sparqlExecutor.queryBindings(a,n),c=[],h=[];u.forEach(f=>{const p=f.get("p"),g=f.get("o");if(!(!p||!g)&&(c.push(`<${e}> ${this.formatTerm(p)} ${this.formatTerm(g)} .`),g.termType==="NamedNode")){const y=p.value;for(const[,S]of Object.entries(t.columns)){const w=this.tripleBuilder.getPredicateUri(S,t),R=S.dataType==="object"||S.dataType==="json"||S.dataType==="array"&&(S.elementType==="object"||S.options?.baseType==="object");w===y&&R&&typeof g.value=="string"&&h.push(g.value)}}});for(const f of h){const p=await this.fetchRecursiveTriplesToDelete(f,t,n,s);c.push(...p)}return c}async fetchExistingObjects(e,t,n){const s=`SELECT ?o WHERE { <${t}> <${n}> ?o . }`;return(await this.sparqlExecutor.queryBindings(s,e)).map(u=>{const c=u.get?.("o");return this.formatTerm(c)}).filter(u=>!!u)}async fetchInverseSubjects(e,t,n){const s=`SELECT ?s WHERE { ?s <${n}> <${t}> . }`;return(await this.sparqlExecutor.queryContainer(e,{type:"SELECT",query:s})).map(u=>u.s??u["?s"]).filter(Boolean)}}class LdpStrategy{constructor(e){this.mode="ldp",this.sparqlExecutor=e.sparqlExecutor,this.sparqlConverter=e.sparqlConverter,this.fetchFn=e.fetchFn,this.ldpExecutor=e.ldpExecutor,this.getResolver=e.getResolver,this.listContainerResources=e.listContainerResources,this.findSubjectsForCondition=e.findSubjectsForCondition}async executeSelect(e,t,n){const s=e.baseTable;if(!s)throw new Error("SELECT plan must have a baseTable");const a=this.getResolver(s),u=e.conditionTree,c=await a.resolveSelectSources(s,t,u,g=>this.listContainerResources(g||t));let h;const f=e;if(f._simpleSelectOptions)h=this.sparqlConverter.convertSimpleSelect(f._simpleSelectOptions,void 0,void 0,!1);else if(f._sql){const g=this.sparqlConverter.parseDrizzleAST(f._sql,s);h=this.sparqlConverter.convertSelect(g,s,void 0,void 0,!1)}else h=this.sparqlConverter.convertSelectPlan(e,void 0,void 0,!1);const p=[];for(const g of c)try{const y=await this.sparqlExecutor.queryContainer(g,h);p.push(...y)}catch(y){console.warn(`[LdpStrategy] Failed to query source ${g}:`,y)}return p}async executeInsert(e,t,n){return await this.ldpExecutor.executeInsert(e.rows,e.table,n,{ensureContainerExists:e.ensureContainerExists,repairContainerOnWriteFailure:e.repairContainerOnWriteFailure,skipResourceExistenceCheck:e.skipResourceExistenceCheck,tableRegistry:e.tableRegistry,tableNameRegistry:e.tableNameRegistry})}async executeUpdate(e,t,n){const a=await this.getResolver(e.table).resolveSubjectsForMutation(e.table,e.where,c=>this.findSubjectsForCondition(e.where,e.table,c),()=>this.listContainerResources(t));return a.length===0?[]:await this.ldpExecutor.executeUpdate(e.table,e.data,a,n)}async executeDelete(e,t,n){if(!e.where)return[];const a=await this.getResolver(e.table).resolveSubjectsForMutation(e.table,e.where,c=>this.findSubjectsForCondition(e.where,e.table,c),()=>this.listContainerResources(t));return a.length===0?[]:await this.ldpExecutor.executeDelete(a,e.table,n)}}class SparqlStrategy{constructor(e){this.mode="sparql",this.sparqlExecutor=e.sparqlExecutor,this.sparqlConverter=e.sparqlConverter,this.podUrl=e.podUrl,this.uriResolver=e.uriResolver,this.createQueryEngine=e.createQueryEngine}setPodUrl(e){this.podUrl=e}resolvePodResourceIri(e){if(!e||/^[a-z][a-z0-9+.-]*:/i.test(e))return e;const t=this.podUrl?.trim();if(!t)return e;const n=t.endsWith("/")?t:`${t}/`;if(e.startsWith("/"))return`${n.replace(/\/+$/,"")}${e}`;try{return new URL(e,n).toString()}catch{return e}}resolveTargetGraph(e,t=!1){return e?this.uriResolver.getResourceMode(e)==="document"?t?void 0:this.resolvePodResourceIri(e.config?.containerPath??e.getContainerPath?.()):this.resolvePodResourceIri(e.config?.base):void 0}async executeSelect(e,t,n){const s=e.baseTable,a=this.resolveTargetGraph(s,!0),u=e;let c;const h=a!==void 0;if(u._simpleSelectOptions)c=this.sparqlConverter.convertSimpleSelect(u._simpleSelectOptions,a,void 0,h);else if(u._sql&&e.baseTable){const g=this.sparqlConverter.parseDrizzleAST(u._sql,e.baseTable);c=this.sparqlConverter.convertSelect(g,e.baseTable,a,void 0,h)}else c=this.sparqlConverter.convertSelectPlan(e,a,void 0,h);if(isSameOrigin(n,this.podUrl))return await this.sparqlExecutor.executeQueryWithSource(c,n,n.includes("/sparql")?"sparql":"auto");const{ComunicaSPARQLExecutor:f}=await __vitePreload(async()=>{const{ComunicaSPARQLExecutor:g}=await Promise.resolve().then(()=>sparqlExecutor);return{ComunicaSPARQLExecutor:g}},void 0);return await new f({sources:[n],fetch,logging:!1,createQueryEngine:this.createQueryEngine}).executeQueryWithSource(c,n,n.includes("/sparql")?"sparql":"auto")}async executeInsert(){throw new Error("SPARQL mode INSERT is not supported directly; writes should route through LDP strategy")}async executeUpdate(){throw new Error("SPARQL mode UPDATE is not supported directly; writes should route through LDP strategy")}async executeDelete(){throw new Error("SPARQL mode DELETE is not supported directly; writes should route through LDP strategy")}}class ExecutionStrategyFactoryImpl{constructor(e){this.ldpStrategy=null,this.sparqlStrategy=null,this.deps=e}setPodUrl(e){this.deps.podUrl=e,this.sparqlStrategy?.setPodUrl(e)}getStrategy(e){return e.getSparqlEndpoint?.()?this.getSparqlStrategy():this.getLdpStrategy()}getLdpStrategy(){return this.getLdpStrategyInternal()}getLdpStrategyInternal(){if(!this.ldpStrategy){const e={sparqlExecutor:this.deps.sparqlExecutor,sparqlConverter:this.deps.sparqlConverter,fetchFn:this.deps.sessionFetch,ldpExecutor:this.deps.ldpExecutor,getResolver:this.deps.getResolver,listContainerResources:this.deps.listContainerResources,findSubjectsForCondition:this.deps.findSubjectsForCondition};this.ldpStrategy=new LdpStrategy(e)}return this.ldpStrategy}getSparqlStrategy(){if(!this.sparqlStrategy){const e={sparqlExecutor:this.deps.sparqlExecutor,sparqlConverter:this.deps.sparqlConverter,sessionFetch:this.deps.sessionFetch,podUrl:this.deps.podUrl,uriResolver:this.deps.uriResolver,createQueryEngine:this.deps.createQueryEngine};this.sparqlStrategy=new SparqlStrategy(e)}return this.sparqlStrategy}static getMode(e){return e.getSparqlEndpoint?.()?"sparql":"ldp"}}class BaseResourceResolver{constructor(e){this.podBaseUrl=e}parseId(e,t){return this.extractBaseRelativeResourceId(e,t)}resolveSubject(e,t,n){const s=this.getSubjectBaseUrl(e);let a=t.id??t["@id"]??t.uri;if(a&&this.isAbsoluteUri(a))return a;if(typeof a=="string"){const h=this.resolveBaseRelativeSubjectId(e,a);if(h)return h;a.startsWith("#")&&this.acceptsFragmentOnlyResourceId(e)&&(a=a.slice(1))}const u=this.getEffectiveTemplate(e),c=this.applyTemplate({...t,id:a},u,e,n);return s+c}parseTemplateId(e,t){const n=this.extractTemplateRelativeSubjectId(e,t);return this.extractIdFromTemplate(n,this.getEffectiveTemplate(e))}extractRelativeSubjectId(e,t){const n=this.getBaseUrlForTable(e);return t.startsWith(n)?t.substring(n.length):this.extractIdFallback(t)}extractBaseRelativeResourceId(e,t){const n=this.getContainerUrl(e);if(t.startsWith(n))return t.substring(n.length);const s=this.extractRelativeSubjectId(e,t);return s.startsWith("#")&&!(e.hasCustomTemplate?.()??!1)?`${this.getResourceUrl(e).split("/").filter(Boolean).pop()??""}${s}`:s}extractTemplateRelativeSubjectId(e,t){const n=this.resolveBaseUrl(e);return t.startsWith(n)?t.substring(n.length):this.extractRelativeSubjectId(e,t)}isBaseRelativeSubjectId(e){return!e||this.isAbsoluteUri(e)||e.startsWith("/")?!1:e.startsWith("#")||e.includes("#")||/\.(ttl|jsonld|json)(?:#|$)/i.test(e)}acceptsFragmentOnlyResourceId(e){const t=this.getEffectiveTemplate(e),n=this.getTemplateVariables(t);return t==="#{id}"||t.startsWith("#")&&n.length===1&&n[0].field==="id"}resolveBaseRelativeSubjectId(e,t){if(!this.isBaseRelativeSubjectId(t))return null;const n=this.getSubjectBaseUrl(e);if(t.startsWith("#"))return this.acceptsFragmentOnlyResourceId(e)?`${n}${t}`:null;if(n.endsWith("/"))return`${n}${t}`;const s=n.lastIndexOf("/");return`${s>=0?n.slice(0,s+1):`${n}/`}${t}`}hasVirtualIdColumn(e){return!!e.columns?.id?._virtualId}getBaseUrlForTable(e){return this.resolveBaseUrl(e)}getSubjectBaseUrl(e){return this.acceptsFragmentOnlyResourceId(e)?this.getResourceUrl(e):this.getBaseUrlForTable(e)}getEffectiveTemplate(e){return e.config?.subjectTemplate?e.config.subjectTemplate:this.getDefaultTemplate()}generateUuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}applyTemplate(e,t,n,s){if(!t.includes("{"))return t;const a=this.createTimeContext(e);return t.replace(/(#?)\{([^}]+)\}/g,(u,c,h)=>{const f=this.parseTemplateVariable(h),p=f.field;if(p==="index"&&s!==void 0)return c+String(s+1);if(p in a)return c+a[p];let g=e[p];if(p==="id"&&g==null&&(g=e["@id"]??e.uri),g==null)return`${c}{${h}}`;const y=this.applyTemplateTransforms(g,f,n,p);return c==="#"&&y.startsWith("#")?c+y.slice(1):c+y})}extractVarsFromTemplate(e,t){let n=0;const s=new Map;let a=t.replace(/[.+?^$[\]\\()]/g,"\\$&").replace(/\{([^}]+)\}/g,(u,c)=>{const h=this.parseTemplateVariable(c),f=`var${n++}`;return s.set(f,h.field),`(?<${f}>.+?)`});a=`^${a}$`;try{const u=e.match(new RegExp(a));if(!u?.groups)return null;const c={};for(const[h,f]of Object.entries(u.groups)){const p=s.get(h);if(!(!p||f===void 0)){if(p in c&&c[p]!==f)return null;c[p]=f}}return c}catch{return null}}extractIdFromTemplate(e,t){return this.extractVarsFromTemplate(e,t)?.id??null}extractIdValues(e){if(!e)return[];const t=[];if(typeof e=="object"&&!("type"in e)){for(const[n,s]of Object.entries(e)){const a=this.normalizeConditionColumnName(n);a!=="id"&&a!=="@id"||(Array.isArray(s)?t.push(...s.map(String)):s!=null&&t.push(String(s)))}if(t.length>0)return t}return this.collectIdValues(e,t),t}extractTemplateValues(e,t){if(!e||t.length===0)return{};const n=Array.from(new Set(t.map(a=>this.parseTemplateVariable(a).field))),s={};if(typeof e=="object"&&!("type"in e)){for(const[a,u]of Object.entries(e)){const c=this.normalizeConditionColumnName(a);n.includes(c)&&u!=null&&!Array.isArray(u)&&(s[c]=String(u))}return s}for(const a of n){const u=this.collectColumnValue(e,a);u!==void 0&&(s[a]=u)}return s}collectColumnValue(e,t){if(e){if(e.type==="binary_expr"&&this.normalizeConditionColumnName(e.left)===t&&e.operator==="="&&e.right!=null)return String(e.right);if(e.type==="logical_expr"&&e.operator==="AND"&&Array.isArray(e.expressions))for(const n of e.expressions){const s=this.collectColumnValue(n,t);if(s!==void 0)return s}}}collectIdValues(e,t){if(e){if(e.type==="binary_expr"){const n=this.normalizeConditionColumnName(e.left);(n==="id"||n==="@id")&&(e.operator==="="&&e.right!=null?t.push(String(e.right)):e.operator==="IN"&&Array.isArray(e.right)&&t.push(...e.right.map(String)))}if(e.type==="logical_expr"&&Array.isArray(e.expressions))for(const n of e.expressions)this.collectIdValues(n,t)}}normalizeConditionColumnName(e){let t;if(typeof e=="string")t=e;else if(e&&typeof e=="object"&&"name"in e){const n=e.name;t=typeof n=="string"?n:void 0}return t?t.includes(".")?t.split(".").pop()??t:t:""}parseTemplateVariable(e){const[t,...n]=e.split("|").map(s=>s.trim()).filter(Boolean);return{raw:e,field:t||e,transforms:n}}getTemplateVariables(e){return Array.from(e.matchAll(/\{([^}]+)\}/g)).map(t=>this.parseTemplateVariable(t[1]))}createTimeContext(e){let t;const n=e.createdAt??e.created_at??e.dateCreated;return n instanceof Date?t=n:typeof n=="string"||typeof n=="number"?t=new Date(n):t=new Date,{yyyy:t.getUTCFullYear().toString(),MM:String(t.getUTCMonth()+1).padStart(2,"0"),dd:String(t.getUTCDate()).padStart(2,"0"),HH:String(t.getUTCHours()).padStart(2,"0"),mm:String(t.getUTCMinutes()).padStart(2,"0"),ss:String(t.getUTCSeconds()).padStart(2,"0")}}applyTemplateTransforms(e,t,n,s){let a=this.normalizeTemplateValue(e,n,s);for(const u of t.transforms){if(u==="id"){a=this.extractTemplateId(a,n,s);continue}u==="slug"&&(a=this.slugifyValue(a))}return a}normalizeTemplateValue(e,t,n){const s=String(e);if(!t||!n||!this.isAbsoluteUri(s))return s;const a=t.columns?.[n];return this.isLinkColumn(a)?this.extractTemplateId(s,t,n):s}extractTemplateId(e,t,n){if(e.startsWith("/")){const c=this.podBaseUrl.endsWith("/")?this.podBaseUrl:`${this.podBaseUrl}/`;e=new URL(e.replace(/^\/+/,""),c).toString()}if(!this.isAbsoluteUri(e))return e;const s=t&&n?t.columns?.[n]:void 0,a=s?.getLinkTable?.()??s?.options?.linkTable;if(a)return this.parseTemplateId(a,e)??this.parseId(a,e);const u=this.extractIdFallback(e);return u.startsWith("#")?u.slice(1):u.replace(/\.ttl$/i,"")}isLinkColumn(e){return!!(e?.getLinkTable?.()||e?.options?.linkTable||e?.getLinkTableName?.()||e?.options?.linkTableName||e?.getLinkTarget?.()||e?.options?.linkTarget)}slugifyValue(e){return e.normalize("NFKC").toLowerCase().replace(/[^\p{Letter}\p{Number}]+/gu,"-").replace(/^-+|-+$/g,"")}resolveBaseUrl(e){const t=e.config.base||e.config.name;if(t.startsWith("http://")||t.startsWith("https://"))return t;const n=this.podBaseUrl.endsWith("/")?this.podBaseUrl:`${this.podBaseUrl}/`,s=t.startsWith("/")?t.slice(1):t;return new URL(s,n).toString()}isAbsoluteUri(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("urn:")}extractIdFallback(e){const t=e.indexOf("#");if(t!==-1)return e.substring(t);const n=e.lastIndexOf("/");return n!==-1?e.substring(n+1):e}}const DEFAULT_TEMPLATE$1="{id}";class FragmentResourceResolver extends BaseResourceResolver{constructor(){super(...arguments),this.mode="fragment"}getDefaultTemplate(){return DEFAULT_TEMPLATE$1}getContainerUrl(e){const t=this.getResourceUrl(e),n=t.lastIndexOf("/");return t.substring(0,n+1)}getResourceUrl(e){return this.resolveBaseUrl(e)}getBaseUrlForTable(e){return this.getResourceUrl(e)}getResourceUrlForSubject(e){const t=e.indexOf("#");return t===-1?e:e.substring(0,t)}async resolveSelectSources(e,t,n,s){return[this.getResourceUrl(e)]}async resolveSubjectsForMutation(e,t,n,s){const a=this.extractIdValues(t);if(a.length>0)return a.map(c=>this.resolveSubject(e,{id:c}));const u=this.getResourceUrl(e);return n(u)}}class DebugLogger{constructor(e=!1,t="[drizzle-solid]"){this.enabled=e,this.prefix=t}log(e,...t){this.enabled&&console.log(`${this.prefix} ${e}`,...t)}warn(e,...t){this.enabled&&console.warn(`${this.prefix} ⚠️ ${e}`,...t)}error(e,...t){this.enabled&&console.error(`${this.prefix} ❌ ${e}`,...t)}group(e){this.enabled&&console.group(`${this.prefix} ${e}`)}groupEnd(){this.enabled&&console.groupEnd()}table(e){this.enabled&&console.table(e)}}let globalDebugLogger=null;function setGlobalDebugLogger(i){globalDebugLogger=i}function getGlobalDebugLogger(){return globalDebugLogger||(globalDebugLogger=new DebugLogger(!1)),globalDebugLogger}const DEFAULT_TEMPLATE="{id}";class DocumentResourceResolver extends BaseResourceResolver{constructor(){super(...arguments),this.mode="document"}buildUnsupportedCollectionReadError(e){return new Error(`Document-mode collection queries over plain LDP are not supported for table "${e.config.name}". Configure a global query capability (SPARQL endpoint or index), or use findById()/findByIri() for exact-target reads.`)}buildUnsupportedCollectionMutationError(e){return new Error(`Document-mode collection mutations over plain LDP are not supported for table "${e.config.name}". Use updateById()/updateByIri() or deleteById()/deleteByIri() for exact-target mutations.`)}getDefaultTemplate(){return DEFAULT_TEMPLATE}getContainerUrl(e){const t=e.getContainerPath();if(t.startsWith("http://")||t.startsWith("https://"))return t;const n=this.podBaseUrl.endsWith("/")?this.podBaseUrl:`${this.podBaseUrl}/`,s=t.startsWith("/")?t.slice(1):t;return new URL(s,n).toString()}getResourceUrl(e){return`${this.getContainerUrl(e)}${e.config.name}.ttl`}getBaseUrlForTable(e){return this.getContainerUrl(e)}getResourceUrlForSubject(e){const t=e.indexOf("#");return t!==-1?e.substring(0,t):e}async resolveSelectSources(e,t,n,s){const a=getGlobalDebugLogger(),u=this.getEffectiveTemplate(e),c=Array.from(new Set(this.getTemplateVariables(u).map(p=>p.field))).filter(p=>p!=="id"&&p!=="index"),h=this.extractIdValues(n),f=this.extractTemplateValues(n,c);if(h.length>0&&!("id"in f)&&(f.id=h[0]),a.group(`[Document Resolver] Resolving SELECT sources for table: ${e.name||"unknown"}`),a.log("Template:",u),a.log("ID values from condition:",h),a.log("Template values:",f),h.length>0){const p=h[0];if(this.isAbsoluteUri(p))return a.log("Full URI provided, using directly"),a.groupEnd(),h.map(g=>this.getResourceUrlForSubject(g))}if(h.length>0){if(c.every(y=>y in f)){a.log("All variables present, resolving directly");const y=h.map(S=>{const w=this.resolveSubject(e,{...f,id:S});return this.getResourceUrlForSubject(w)});return a.log("Resolved sources:",y),a.groupEnd(),y}const g=c.filter(y=>!(y in f));throw a.error("Missing required variables:",g),a.groupEnd(),new Error(`Cannot resolve subjectTemplate '${u}': missing required variable(s) [${g.join(", ")}] in query condition. Add eq(table.${g[0]}, value) to your where clause.`)}throw a.error("Document-mode LDP collection query is unsupported without an exact target"),a.groupEnd(),this.buildUnsupportedCollectionReadError(e)}async resolveSubjectsForMutation(e,t,n,s){const a=this.getEffectiveTemplate(e),u=Array.from(new Set(this.getTemplateVariables(a).map(f=>f.field))).filter(f=>f!=="id"&&f!=="index"),c=this.extractIdValues(t),h=this.extractTemplateValues(t,u);if(c.length>0&&!("id"in h)&&(h.id=c[0]),c.length>0){const f=c[0];if(this.isAbsoluteUri(f))return c}if(c.length>0){if(u.every(g=>g in h))return c.map(g=>this.resolveSubject(e,{...h,id:g}));const p=u.filter(g=>!(g in h));throw new Error(`Cannot resolve subjectTemplate '${a}' for mutation: missing required variable(s) [${p.join(", ")}] in query condition. Add eq(table.${p[0]}, value) to your where clause.`)}throw this.buildUnsupportedCollectionMutationError(e)}}class ResourceResolverFactoryImpl{constructor(e,t){this.resolverCache=new WeakMap,this.podBaseUrl=e,this.uriResolver=t??new UriResolverImpl}setPodBaseUrl(e){this.podBaseUrl=e,this.resolverCache=new WeakMap}getResolver(e){const t=this.resolverCache.get(e);if(t)return t;const s=this.determineMode(e)==="document"?new DocumentResourceResolver(this.podBaseUrl):new FragmentResourceResolver(this.podBaseUrl);return this.resolverCache.set(e,s),s}determineMode(e){return this.uriResolver.getResourceMode(e)}}const XSD={STRING:"http://www.w3.org/2001/XMLSchema#string",INTEGER:"http://www.w3.org/2001/XMLSchema#integer",BOOLEAN:"http://www.w3.org/2001/XMLSchema#boolean",DATETIME:"http://www.w3.org/2001/XMLSchema#dateTime",DATE:"http://www.w3.org/2001/XMLSchema#date",DECIMAL:"http://www.w3.org/2001/XMLSchema#decimal",DOUBLE:"http://www.w3.org/2001/XMLSchema#double",ANYURI:"http://www.w3.org/2001/XMLSchema#anyURI"},SHACL={NS:"http://www.w3.org/ns/shacl#",NODE_SHAPE:"http://www.w3.org/ns/shacl#NodeShape",TARGET_CLASS:"http://www.w3.org/ns/shacl#targetClass",PROPERTY:"http://www.w3.org/ns/shacl#property",PATH:"http://www.w3.org/ns/shacl#path",DATATYPE:"http://www.w3.org/ns/shacl#datatype",NODE_KIND:"http://www.w3.org/ns/shacl#nodeKind",MIN_COUNT:"http://www.w3.org/ns/shacl#minCount",MAX_COUNT:"http://www.w3.org/ns/shacl#maxCount",PATTERN:"http://www.w3.org/ns/shacl#pattern",NAME:"http://www.w3.org/ns/shacl#name",DESCRIPTION:"http://www.w3.org/ns/shacl#description",CLASS:"http://www.w3.org/ns/shacl#class",INVERSE_PATH:"http://www.w3.org/ns/shacl#inversePath",IRI:"http://www.w3.org/ns/shacl#IRI",LITERAL:"http://www.w3.org/ns/shacl#Literal",BLANK_NODE:"http://www.w3.org/ns/shacl#BlankNode"};var _a$2;function $constructor(i,e,t){function n(c,h){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:h,constr:u,traits:new Set},enumerable:!1}),c._zod.traits.has(i))return;c._zod.traits.add(i),e(c,h);const f=u.prototype,p=Object.keys(f);for(let g=0;g<p.length;g++){const y=p[g];y in c||(c[y]=f[y].bind(c))}}const s=t?.Parent??Object;class a extends s{}Object.defineProperty(a,"name",{value:i});function u(c){var h;const f=t?.Parent?new a:this;n(f,c),(h=f._zod).deferred??(h.deferred=[]);for(const p of f._zod.deferred)p();return f}return Object.defineProperty(u,"init",{value:n}),Object.defineProperty(u,Symbol.hasInstance,{value:c=>t?.Parent&&c instanceof t.Parent?!0:c?._zod?.traits?.has(i)}),Object.defineProperty(u,"name",{value:i}),u}class $ZodAsyncError extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class $ZodEncodeError extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(_a$2=globalThis).__zod_globalConfig??(_a$2.__zod_globalConfig={});const globalConfig=globalThis.__zod_globalConfig;function config(i){return globalConfig}function getEnumValues(i){const e=Object.values(i).filter(n=>typeof n=="number");return Object.entries(i).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function jsonStringifyReplacer(i,e){return typeof e=="bigint"?e.toString():e}function cached(i){return{get value(){{const e=i();return Object.defineProperty(this,"value",{value:e}),e}}}}function nullish(i){return i==null}function cleanRegex(i){const e=i.startsWith("^")?1:0,t=i.endsWith("$")?i.length-1:i.length;return i.slice(e,t)}function floatSafeRemainder(i,e){const t=i/e,n=Math.round(t),s=Number.EPSILON*Math.max(Math.abs(t),1);return Math.abs(t-n)<s?0:t-n}const EVALUATING=Symbol("evaluating");function defineLazy(i,e,t){let n;Object.defineProperty(i,e,{get(){if(n!==EVALUATING)return n===void 0&&(n=EVALUATING,n=t()),n},set(s){Object.defineProperty(i,e,{value:s})},configurable:!0})}function assignProp(i,e,t){Object.defineProperty(i,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function mergeDefs(...i){const e={};for(const t of i){const n=Object.getOwnPropertyDescriptors(t);Object.assign(e,n)}return Object.defineProperties({},e)}function esc(i){return JSON.stringify(i)}function slugify(i){return i.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const captureStackTrace="captureStackTrace"in Error?Error.captureStackTrace:(...i)=>{};function isObject(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}const allowsEval=cached(()=>{if(globalConfig.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const i=Function;return new i(""),!0}catch{return!1}});function isPlainObject(i){if(isObject(i)===!1)return!1;const e=i.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(isObject(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function shallowClone(i){return isPlainObject(i)?{...i}:Array.isArray(i)?[...i]:i instanceof Map?new Map(i):i instanceof Set?new Set(i):i}const propertyKeyTypes=new Set(["string","number","symbol"]);function escapeRegex(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function clone(i,e,t){const n=new i._zod.constr(e??i._zod.def);return(!e||t?.parent)&&(n._zod.parent=i),n}function normalizeParams(i){const e=i;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function optionalKeys(i){return Object.keys(i).filter(e=>i[e]._zod.optin==="optional"&&i[e]._zod.optout==="optional")}const NUMBER_FORMAT_RANGES={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pick(i,e){const t=i._zod.def,n=t.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const a=mergeDefs(i._zod.def,{get shape(){const u={};for(const c in e){if(!(c in t.shape))throw new Error(`Unrecognized key: "${c}"`);e[c]&&(u[c]=t.shape[c])}return assignProp(this,"shape",u),u},checks:[]});return clone(i,a)}function omit(i,e){const t=i._zod.def,n=t.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const a=mergeDefs(i._zod.def,{get shape(){const u={...i._zod.def.shape};for(const c in e){if(!(c in t.shape))throw new Error(`Unrecognized key: "${c}"`);e[c]&&delete u[c]}return assignProp(this,"shape",u),u},checks:[]});return clone(i,a)}function extend(i,e){if(!isPlainObject(e))throw new Error("Invalid input to extend: expected a plain object");const t=i._zod.def.checks;if(t&&t.length>0){const a=i._zod.def.shape;for(const u in e)if(Object.getOwnPropertyDescriptor(a,u)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=mergeDefs(i._zod.def,{get shape(){const a={...i._zod.def.shape,...e};return assignProp(this,"shape",a),a}});return clone(i,s)}function safeExtend(i,e){if(!isPlainObject(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=mergeDefs(i._zod.def,{get shape(){const n={...i._zod.def.shape,...e};return assignProp(this,"shape",n),n}});return clone(i,t)}function merge(i,e){if(i._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const t=mergeDefs(i._zod.def,{get shape(){const n={...i._zod.def.shape,...e._zod.def.shape};return assignProp(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return clone(i,t)}function partial(i,e,t){const s=e._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const u=mergeDefs(e._zod.def,{get shape(){const c=e._zod.def.shape,h={...c};if(t)for(const f in t){if(!(f in c))throw new Error(`Unrecognized key: "${f}"`);t[f]&&(h[f]=i?new i({type:"optional",innerType:c[f]}):c[f])}else for(const f in c)h[f]=i?new i({type:"optional",innerType:c[f]}):c[f];return assignProp(this,"shape",h),h},checks:[]});return clone(e,u)}function required(i,e,t){const n=mergeDefs(e._zod.def,{get shape(){const s=e._zod.def.shape,a={...s};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(a[u]=new i({type:"nonoptional",innerType:s[u]}))}else for(const u in s)a[u]=new i({type:"nonoptional",innerType:s[u]});return assignProp(this,"shape",a),a}});return clone(e,n)}function aborted(i,e=0){if(i.aborted===!0)return!0;for(let t=e;t<i.issues.length;t++)if(i.issues[t]?.continue!==!0)return!0;return!1}function explicitlyAborted(i,e=0){if(i.aborted===!0)return!0;for(let t=e;t<i.issues.length;t++)if(i.issues[t]?.continue===!1)return!0;return!1}function prefixIssues(i,e){return e.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(i),t})}function unwrapMessage(i){return typeof i=="string"?i:i?.message}function finalizeIssue(i,e,t){const n=i.message?i.message:unwrapMessage(i.inst?._zod.def?.error?.(i))??unwrapMessage(e?.error?.(i))??unwrapMessage(t.customError?.(i))??unwrapMessage(t.localeError?.(i))??"Invalid input",{inst:s,continue:a,input:u,...c}=i;return c.path??(c.path=[]),c.message=n,e?.reportInput&&(c.input=u),c}function getLengthableOrigin(i){return Array.isArray(i)?"array":typeof i=="string"?"string":"unknown"}function issue(...i){const[e,t,n]=i;return typeof e=="string"?{message:e,code:"custom",input:t,inst:n}:{...e}}const initializer$1=(i,e)=>{i.name="$ZodError",Object.defineProperty(i,"_zod",{value:i._zod,enumerable:!1}),Object.defineProperty(i,"issues",{value:e,enumerable:!1}),i.message=JSON.stringify(e,jsonStringifyReplacer,2),Object.defineProperty(i,"toString",{value:()=>i.message,enumerable:!1})},$ZodError=$constructor("$ZodError",initializer$1),$ZodRealError=$constructor("$ZodError",initializer$1,{Parent:Error});function flattenError(i,e=t=>t.message){const t={},n=[];for(const s of i.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}function formatError(i,e=t=>t.message){const t={_errors:[]},n=(s,a=[])=>{for(const u of s.issues)if(u.code==="invalid_union"&&u.errors.length)u.errors.map(c=>n({issues:c},[...a,...u.path]));else if(u.code==="invalid_key")n({issues:u.issues},[...a,...u.path]);else if(u.code==="invalid_element")n({issues:u.issues},[...a,...u.path]);else{const c=[...a,...u.path];if(c.length===0)t._errors.push(e(u));else{let h=t,f=0;for(;f<c.length;){const p=c[f];f===c.length-1?(h[p]=h[p]||{_errors:[]},h[p]._errors.push(e(u))):h[p]=h[p]||{_errors:[]},h=h[p],f++}}}};return n(i),t}const _parse=i=>(e,t,n,s)=>{const a=n?{...n,async:!1}:{async:!1},u=e._zod.run({value:t,issues:[]},a);if(u instanceof Promise)throw new $ZodAsyncError;if(u.issues.length){const c=new(s?.Err??i)(u.issues.map(h=>finalizeIssue(h,a,config())));throw captureStackTrace(c,s?.callee),c}return u.value},_parseAsync=i=>async(e,t,n,s)=>{const a=n?{...n,async:!0}:{async:!0};let u=e._zod.run({value:t,issues:[]},a);if(u instanceof Promise&&(u=await u),u.issues.length){const c=new(s?.Err??i)(u.issues.map(h=>finalizeIssue(h,a,config())));throw captureStackTrace(c,s?.callee),c}return u.value},_safeParse=i=>(e,t,n)=>{const s=n?{...n,async:!1}:{async:!1},a=e._zod.run({value:t,issues:[]},s);if(a instanceof Promise)throw new $ZodAsyncError;return a.issues.length?{success:!1,error:new(i??$ZodError)(a.issues.map(u=>finalizeIssue(u,s,config())))}:{success:!0,data:a.value}},safeParse$1=_safeParse($ZodRealError),_safeParseAsync=i=>async(e,t,n)=>{const s=n?{...n,async:!0}:{async:!0};let a=e._zod.run({value:t,issues:[]},s);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new i(a.issues.map(u=>finalizeIssue(u,s,config())))}:{success:!0,data:a.value}},safeParseAsync$1=_safeParseAsync($ZodRealError),_encode=i=>(e,t,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return _parse(i)(e,t,s)},_decode=i=>(e,t,n)=>_parse(i)(e,t,n),_encodeAsync=i=>async(e,t,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return _parseAsync(i)(e,t,s)},_decodeAsync=i=>async(e,t,n)=>_parseAsync(i)(e,t,n),_safeEncode=i=>(e,t,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return _safeParse(i)(e,t,s)},_safeDecode=i=>(e,t,n)=>_safeParse(i)(e,t,n),_safeEncodeAsync=i=>async(e,t,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return _safeParseAsync(i)(e,t,s)},_safeDecodeAsync=i=>async(e,t,n)=>_safeParseAsync(i)(e,t,n),cuid=/^[cC][0-9a-z]{6,}$/,cuid2=/^[0-9a-z]+$/,ulid=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xid=/^[0-9a-vA-V]{20}$/,ksuid=/^[A-Za-z0-9]{27}$/,nanoid=/^[a-zA-Z0-9_-]{21}$/,duration$1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,guid=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uuid=i=>i?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${i}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,email=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_emoji$1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function emoji(){return new RegExp(_emoji$1,"u")}const ipv4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,cidrv4=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cidrv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,base64url=/^[A-Za-z0-9_-]*$/,httpProtocol=/^https?$/,e164=/^\+[1-9]\d{6,14}$/,dateSource="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",date$2=new RegExp(`^${dateSource}$`);function timeSource(i){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof i.precision=="number"?i.precision===-1?`${e}`:i.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${i.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function time$1(i){return new RegExp(`^${timeSource(i)}$`)}function datetime$1(i){const e=timeSource({precision:i.precision}),t=["Z"];i.local&&t.push(""),i.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${e}(?:${t.join("|")})`;return new RegExp(`^${dateSource}T(?:${n})$`)}const string$1=i=>{const e=i?`[\\s\\S]{${i?.minimum??0},${i?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},integer=/^-?\d+$/,number$1=/^-?\d+(?:\.\d+)?$/,boolean$1=/^(?:true|false)$/i,lowercase=/^[^A-Z]*$/,uppercase=/^[^a-z]*$/,$ZodCheck=$constructor("$ZodCheck",(i,e)=>{var t;i._zod??(i._zod={}),i._zod.def=e,(t=i._zod).onattach??(t.onattach=[])}),numericOriginMap={number:"number",bigint:"bigint",object:"date"},$ZodCheckLessThan=$constructor("$ZodCheckLessThan",(i,e)=>{$ZodCheck.init(i,e);const t=numericOriginMap[typeof e.value];i._zod.onattach.push(n=>{const s=n._zod.bag,a=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<a&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),i._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:i,continue:!e.abort})}}),$ZodCheckGreaterThan=$constructor("$ZodCheckGreaterThan",(i,e)=>{$ZodCheck.init(i,e);const t=numericOriginMap[typeof e.value];i._zod.onattach.push(n=>{const s=n._zod.bag,a=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>a&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),i._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:i,continue:!e.abort})}}),$ZodCheckMultipleOf=$constructor("$ZodCheckMultipleOf",(i,e)=>{$ZodCheck.init(i,e),i._zod.onattach.push(t=>{var n;(n=t._zod.bag).multipleOf??(n.multipleOf=e.value)}),i._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):floatSafeRemainder(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:i,continue:!e.abort})}}),$ZodCheckNumberFormat=$constructor("$ZodCheckNumberFormat",(i,e)=>{$ZodCheck.init(i,e),e.format=e.format||"float64";const t=e.format?.includes("int"),n=t?"int":"number",[s,a]=NUMBER_FORMAT_RANGES[e.format];i._zod.onattach.push(u=>{const c=u._zod.bag;c.format=e.format,c.minimum=s,c.maximum=a,t&&(c.pattern=integer)}),i._zod.check=u=>{const c=u.value;if(t){if(!Number.isInteger(c)){u.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:c,inst:i});return}if(!Number.isSafeInteger(c)){c>0?u.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:i,origin:n,inclusive:!0,continue:!e.abort}):u.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:i,origin:n,inclusive:!0,continue:!e.abort});return}}c<s&&u.issues.push({origin:"number",input:c,code:"too_small",minimum:s,inclusive:!0,inst:i,continue:!e.abort}),c>a&&u.issues.push({origin:"number",input:c,code:"too_big",maximum:a,inclusive:!0,inst:i,continue:!e.abort})}}),$ZodCheckMaxLength=$constructor("$ZodCheckMaxLength",(i,e)=>{var t;$ZodCheck.init(i,e),(t=i._zod.def).when??(t.when=n=>{const s=n.value;return!nullish(s)&&s.length!==void 0}),i._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),i._zod.check=n=>{const s=n.value;if(s.length<=e.maximum)return;const u=getLengthableOrigin(s);n.issues.push({origin:u,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:i,continue:!e.abort})}}),$ZodCheckMinLength=$constructor("$ZodCheckMinLength",(i,e)=>{var t;$ZodCheck.init(i,e),(t=i._zod.def).when??(t.when=n=>{const s=n.value;return!nullish(s)&&s.length!==void 0}),i._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),i._zod.check=n=>{const s=n.value;if(s.length>=e.minimum)return;const u=getLengthableOrigin(s);n.issues.push({origin:u,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:i,continue:!e.abort})}}),$ZodCheckLengthEquals=$constructor("$ZodCheckLengthEquals",(i,e)=>{var t;$ZodCheck.init(i,e),(t=i._zod.def).when??(t.when=n=>{const s=n.value;return!nullish(s)&&s.length!==void 0}),i._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),i._zod.check=n=>{const s=n.value,a=s.length;if(a===e.length)return;const u=getLengthableOrigin(s),c=a>e.length;n.issues.push({origin:u,...c?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:i,continue:!e.abort})}}),$ZodCheckStringFormat=$constructor("$ZodCheckStringFormat",(i,e)=>{var t,n;$ZodCheck.init(i,e),i._zod.onattach.push(s=>{const a=s._zod.bag;a.format=e.format,e.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(e.pattern))}),e.pattern?(t=i._zod).check??(t.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:i,continue:!e.abort})}):(n=i._zod).check??(n.check=()=>{})}),$ZodCheckRegex=$constructor("$ZodCheckRegex",(i,e)=>{$ZodCheckStringFormat.init(i,e),i._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:i,continue:!e.abort})}}),$ZodCheckLowerCase=$constructor("$ZodCheckLowerCase",(i,e)=>{e.pattern??(e.pattern=lowercase),$ZodCheckStringFormat.init(i,e)}),$ZodCheckUpperCase=$constructor("$ZodCheckUpperCase",(i,e)=>{e.pattern??(e.pattern=uppercase),$ZodCheckStringFormat.init(i,e)}),$ZodCheckIncludes=$constructor("$ZodCheckIncludes",(i,e)=>{$ZodCheck.init(i,e);const t=escapeRegex(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=n,i._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),i._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:i,continue:!e.abort})}}),$ZodCheckStartsWith=$constructor("$ZodCheckStartsWith",(i,e)=>{$ZodCheck.init(i,e);const t=new RegExp(`^${escapeRegex(e.prefix)}.*`);e.pattern??(e.pattern=t),i._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(t)}),i._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:i,continue:!e.abort})}}),$ZodCheckEndsWith=$constructor("$ZodCheckEndsWith",(i,e)=>{$ZodCheck.init(i,e);const t=new RegExp(`.*${escapeRegex(e.suffix)}$`);e.pattern??(e.pattern=t),i._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(t)}),i._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:i,continue:!e.abort})}}),$ZodCheckOverwrite=$constructor("$ZodCheckOverwrite",(i,e)=>{$ZodCheck.init(i,e),i._zod.check=t=>{t.value=e.tx(t.value)}});class Doc{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const n=e.split(`
237
+ `).filter(u=>u),s=Math.min(...n.map(u=>u.length-u.trimStart().length)),a=n.map(u=>u.slice(s)).map(u=>" ".repeat(this.indent*2)+u);for(const u of a)this.content.push(u)}compile(){const e=Function,t=this?.args,s=[...(this?.content??[""]).map(a=>` ${a}`)];return new e(...t,s.join(`
238
+ `))}}const version={major:4,minor:4,patch:3},$ZodType=$constructor("$ZodType",(i,e)=>{var t;i??(i={}),i._zod.def=e,i._zod.bag=i._zod.bag||{},i._zod.version=version;const n=[...i._zod.def.checks??[]];i._zod.traits.has("$ZodCheck")&&n.unshift(i);for(const s of n)for(const a of s._zod.onattach)a(i);if(n.length===0)(t=i._zod).deferred??(t.deferred=[]),i._zod.deferred?.push(()=>{i._zod.run=i._zod.parse});else{const s=(u,c,h)=>{let f=aborted(u),p;for(const g of c){if(g._zod.def.when){if(explicitlyAborted(u)||!g._zod.def.when(u))continue}else if(f)continue;const y=u.issues.length,S=g._zod.check(u);if(S instanceof Promise&&h?.async===!1)throw new $ZodAsyncError;if(p||S instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await S,u.issues.length!==y&&(f||(f=aborted(u,y)))});else{if(u.issues.length===y)continue;f||(f=aborted(u,y))}}return p?p.then(()=>u):u},a=(u,c,h)=>{if(aborted(u))return u.aborted=!0,u;const f=s(c,n,h);if(f instanceof Promise){if(h.async===!1)throw new $ZodAsyncError;return f.then(p=>i._zod.parse(p,h))}return i._zod.parse(f,h)};i._zod.run=(u,c)=>{if(c.skipChecks)return i._zod.parse(u,c);if(c.direction==="backward"){const f=i._zod.parse({value:u.value,issues:[]},{...c,skipChecks:!0});return f instanceof Promise?f.then(p=>a(p,u,c)):a(f,u,c)}const h=i._zod.parse(u,c);if(h instanceof Promise){if(c.async===!1)throw new $ZodAsyncError;return h.then(f=>s(f,n,c))}return s(h,n,c)}}defineLazy(i,"~standard",()=>({validate:s=>{try{const a=safeParse$1(i,s);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return safeParseAsync$1(i,s).then(u=>u.success?{value:u.data}:{issues:u.error?.issues})}},vendor:"zod",version:1}))}),$ZodString=$constructor("$ZodString",(i,e)=>{$ZodType.init(i,e),i._zod.pattern=[...i?._zod.bag?.patterns??[]].pop()??string$1(i._zod.bag),i._zod.parse=(t,n)=>{if(e.coerce)try{t.value=String(t.value)}catch{}return typeof t.value=="string"||t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:i}),t}}),$ZodStringFormat=$constructor("$ZodStringFormat",(i,e)=>{$ZodCheckStringFormat.init(i,e),$ZodString.init(i,e)}),$ZodGUID=$constructor("$ZodGUID",(i,e)=>{e.pattern??(e.pattern=guid),$ZodStringFormat.init(i,e)}),$ZodUUID=$constructor("$ZodUUID",(i,e)=>{if(e.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=uuid(n))}else e.pattern??(e.pattern=uuid());$ZodStringFormat.init(i,e)}),$ZodEmail=$constructor("$ZodEmail",(i,e)=>{e.pattern??(e.pattern=email),$ZodStringFormat.init(i,e)}),$ZodURL=$constructor("$ZodURL",(i,e)=>{$ZodStringFormat.init(i,e),i._zod.check=t=>{try{const n=t.value.trim();if(!e.normalize&&e.protocol?.source===httpProtocol.source&&!/^https?:\/\//i.test(n)){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:i,continue:!e.abort});return}const s=new URL(n);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:i,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:i,continue:!e.abort})),e.normalize?t.value=s.href:t.value=n;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:i,continue:!e.abort})}}}),$ZodEmoji=$constructor("$ZodEmoji",(i,e)=>{e.pattern??(e.pattern=emoji()),$ZodStringFormat.init(i,e)}),$ZodNanoID=$constructor("$ZodNanoID",(i,e)=>{e.pattern??(e.pattern=nanoid),$ZodStringFormat.init(i,e)}),$ZodCUID=$constructor("$ZodCUID",(i,e)=>{e.pattern??(e.pattern=cuid),$ZodStringFormat.init(i,e)}),$ZodCUID2=$constructor("$ZodCUID2",(i,e)=>{e.pattern??(e.pattern=cuid2),$ZodStringFormat.init(i,e)}),$ZodULID=$constructor("$ZodULID",(i,e)=>{e.pattern??(e.pattern=ulid),$ZodStringFormat.init(i,e)}),$ZodXID=$constructor("$ZodXID",(i,e)=>{e.pattern??(e.pattern=xid),$ZodStringFormat.init(i,e)}),$ZodKSUID=$constructor("$ZodKSUID",(i,e)=>{e.pattern??(e.pattern=ksuid),$ZodStringFormat.init(i,e)}),$ZodISODateTime=$constructor("$ZodISODateTime",(i,e)=>{e.pattern??(e.pattern=datetime$1(e)),$ZodStringFormat.init(i,e)}),$ZodISODate=$constructor("$ZodISODate",(i,e)=>{e.pattern??(e.pattern=date$2),$ZodStringFormat.init(i,e)}),$ZodISOTime=$constructor("$ZodISOTime",(i,e)=>{e.pattern??(e.pattern=time$1(e)),$ZodStringFormat.init(i,e)}),$ZodISODuration=$constructor("$ZodISODuration",(i,e)=>{e.pattern??(e.pattern=duration$1),$ZodStringFormat.init(i,e)}),$ZodIPv4=$constructor("$ZodIPv4",(i,e)=>{e.pattern??(e.pattern=ipv4),$ZodStringFormat.init(i,e),i._zod.bag.format="ipv4"}),$ZodIPv6=$constructor("$ZodIPv6",(i,e)=>{e.pattern??(e.pattern=ipv6),$ZodStringFormat.init(i,e),i._zod.bag.format="ipv6",i._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:i,continue:!e.abort})}}}),$ZodCIDRv4=$constructor("$ZodCIDRv4",(i,e)=>{e.pattern??(e.pattern=cidrv4),$ZodStringFormat.init(i,e)}),$ZodCIDRv6=$constructor("$ZodCIDRv6",(i,e)=>{e.pattern??(e.pattern=cidrv6),$ZodStringFormat.init(i,e),i._zod.check=t=>{const n=t.value.split("/");try{if(n.length!==2)throw new Error;const[s,a]=n;if(!a)throw new Error;const u=Number(a);if(`${u}`!==a)throw new Error;if(u<0||u>128)throw new Error;new URL(`http://[${s}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:i,continue:!e.abort})}}});function isValidBase64(i){if(i==="")return!0;if(/\s/.test(i)||i.length%4!==0)return!1;try{return atob(i),!0}catch{return!1}}const $ZodBase64=$constructor("$ZodBase64",(i,e)=>{e.pattern??(e.pattern=base64),$ZodStringFormat.init(i,e),i._zod.bag.contentEncoding="base64",i._zod.check=t=>{isValidBase64(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:i,continue:!e.abort})}});function isValidBase64URL(i){if(!base64url.test(i))return!1;const e=i.replace(/[-_]/g,n=>n==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return isValidBase64(t)}const $ZodBase64URL=$constructor("$ZodBase64URL",(i,e)=>{e.pattern??(e.pattern=base64url),$ZodStringFormat.init(i,e),i._zod.bag.contentEncoding="base64url",i._zod.check=t=>{isValidBase64URL(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:i,continue:!e.abort})}}),$ZodE164=$constructor("$ZodE164",(i,e)=>{e.pattern??(e.pattern=e164),$ZodStringFormat.init(i,e)});function isValidJWT(i,e=null){try{const t=i.split(".");if(t.length!==3)return!1;const[n]=t;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const $ZodJWT=$constructor("$ZodJWT",(i,e)=>{$ZodStringFormat.init(i,e),i._zod.check=t=>{isValidJWT(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:i,continue:!e.abort})}}),$ZodNumber=$constructor("$ZodNumber",(i,e)=>{$ZodType.init(i,e),i._zod.pattern=i._zod.bag.pattern??number$1,i._zod.parse=(t,n)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const s=t.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return t;const a=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:s,inst:i,...a?{received:a}:{}}),t}}),$ZodNumberFormat=$constructor("$ZodNumberFormat",(i,e)=>{$ZodCheckNumberFormat.init(i,e),$ZodNumber.init(i,e)}),$ZodBoolean=$constructor("$ZodBoolean",(i,e)=>{$ZodType.init(i,e),i._zod.pattern=boolean$1,i._zod.parse=(t,n)=>{if(e.coerce)try{t.value=!!t.value}catch{}const s=t.value;return typeof s=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:i}),t}}),$ZodAny=$constructor("$ZodAny",(i,e)=>{$ZodType.init(i,e),i._zod.parse=t=>t}),$ZodUnknown=$constructor("$ZodUnknown",(i,e)=>{$ZodType.init(i,e),i._zod.parse=t=>t}),$ZodNever=$constructor("$ZodNever",(i,e)=>{$ZodType.init(i,e),i._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:i}),t)}),$ZodDate=$constructor("$ZodDate",(i,e)=>{$ZodType.init(i,e),i._zod.parse=(t,n)=>{if(e.coerce)try{t.value=new Date(t.value)}catch{}const s=t.value,a=s instanceof Date;return a&&!Number.isNaN(s.getTime())||t.issues.push({expected:"date",code:"invalid_type",input:s,...a?{received:"Invalid Date"}:{},inst:i}),t}});function handleArrayResult(i,e,t){i.issues.length&&e.issues.push(...prefixIssues(t,i.issues)),e.value[t]=i.value}const $ZodArray=$constructor("$ZodArray",(i,e)=>{$ZodType.init(i,e),i._zod.parse=(t,n)=>{const s=t.value;if(!Array.isArray(s))return t.issues.push({expected:"array",code:"invalid_type",input:s,inst:i}),t;t.value=Array(s.length);const a=[];for(let u=0;u<s.length;u++){const c=s[u],h=e.element._zod.run({value:c,issues:[]},n);h instanceof Promise?a.push(h.then(f=>handleArrayResult(f,t,u))):handleArrayResult(h,t,u)}return a.length?Promise.all(a).then(()=>t):t}});function handlePropertyResult(i,e,t,n,s,a){const u=t in n;if(i.issues.length){if(s&&a&&!u)return;e.issues.push(...prefixIssues(t,i.issues))}if(!u&&!s){i.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}i.value===void 0?u&&(e.value[t]=void 0):e.value[t]=i.value}function normalizeDef(i){const e=Object.keys(i.shape);for(const n of e)if(!i.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const t=optionalKeys(i.shape);return{...i,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function handleCatchall(i,e,t,n,s,a){const u=[],c=s.keySet,h=s.catchall._zod,f=h.def.type,p=h.optin==="optional",g=h.optout==="optional";for(const y in e){if(y==="__proto__"||c.has(y))continue;if(f==="never"){u.push(y);continue}const S=h.run({value:e[y],issues:[]},n);S instanceof Promise?i.push(S.then(w=>handlePropertyResult(w,t,y,e,p,g))):handlePropertyResult(S,t,y,e,p,g)}return u.length&&t.issues.push({code:"unrecognized_keys",keys:u,input:e,inst:a}),i.length?Promise.all(i).then(()=>t):t}const $ZodObject=$constructor("$ZodObject",(i,e)=>{if($ZodType.init(i,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){const c=e.shape;Object.defineProperty(e,"shape",{get:()=>{const h={...c};return Object.defineProperty(e,"shape",{value:h}),h}})}const n=cached(()=>normalizeDef(e));defineLazy(i._zod,"propValues",()=>{const c=e.shape,h={};for(const f in c){const p=c[f]._zod;if(p.values){h[f]??(h[f]=new Set);for(const g of p.values)h[f].add(g)}}return h});const s=isObject,a=e.catchall;let u;i._zod.parse=(c,h)=>{u??(u=n.value);const f=c.value;if(!s(f))return c.issues.push({expected:"object",code:"invalid_type",input:f,inst:i}),c;c.value={};const p=[],g=u.shape;for(const y of u.keys){const S=g[y],w=S._zod.optin==="optional",R=S._zod.optout==="optional",T=S._zod.run({value:f[y],issues:[]},h);T instanceof Promise?p.push(T.then(A=>handlePropertyResult(A,c,y,f,w,R))):handlePropertyResult(T,c,y,f,w,R)}return a?handleCatchall(p,f,c,h,n.value,i):p.length?Promise.all(p).then(()=>c):c}}),$ZodObjectJIT=$constructor("$ZodObjectJIT",(i,e)=>{$ZodObject.init(i,e);const t=i._zod.parse,n=cached(()=>normalizeDef(e)),s=y=>{const S=new Doc(["shape","payload","ctx"]),w=n.value,R=x=>{const D=esc(x);return`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`};S.write("const input = payload.value;");const T=Object.create(null);let A=0;for(const x of w.keys)T[x]=`key_${A++}`;S.write("const newResult = {};");for(const x of w.keys){const D=T[x],O=esc(x),K=y[x],z=K?._zod?.optin==="optional",X=K?._zod?.optout==="optional";S.write(`const ${D} = ${R(x)};`),z&&X?S.write(`
239
+ if (${D}.issues.length) {
240
+ if (${O} in input) {
241
+ payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
242
+ ...iss,
243
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
244
+ })));
245
+ }
246
+ }
247
+
248
+ if (${D}.value === undefined) {
249
+ if (${O} in input) {
250
+ newResult[${O}] = undefined;
251
+ }
252
+ } else {
253
+ newResult[${O}] = ${D}.value;
254
+ }
255
+
256
+ `):z?S.write(`
257
+ if (${D}.issues.length) {
258
+ payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
259
+ ...iss,
260
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
261
+ })));
262
+ }
263
+
264
+ if (${D}.value === undefined) {
265
+ if (${O} in input) {
266
+ newResult[${O}] = undefined;
267
+ }
268
+ } else {
269
+ newResult[${O}] = ${D}.value;
270
+ }
271
+
272
+ `):S.write(`
273
+ const ${D}_present = ${O} in input;
274
+ if (${D}.issues.length) {
275
+ payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
276
+ ...iss,
277
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
278
+ })));
279
+ }
280
+ if (!${D}_present && !${D}.issues.length) {
281
+ payload.issues.push({
282
+ code: "invalid_type",
283
+ expected: "nonoptional",
284
+ input: undefined,
285
+ path: [${O}]
286
+ });
287
+ }
288
+
289
+ if (${D}_present) {
290
+ if (${D}.value === undefined) {
291
+ newResult[${O}] = undefined;
292
+ } else {
293
+ newResult[${O}] = ${D}.value;
294
+ }
295
+ }
296
+
297
+ `)}S.write("payload.value = newResult;"),S.write("return payload;");const F=S.compile();return(x,D)=>F(y,x,D)};let a;const u=isObject,c=!globalConfig.jitless,f=c&&allowsEval.value,p=e.catchall;let g;i._zod.parse=(y,S)=>{g??(g=n.value);const w=y.value;return u(w)?c&&f&&S?.async===!1&&S.jitless!==!0?(a||(a=s(e.shape)),y=a(y,S),p?handleCatchall([],w,y,S,g,i):y):t(y,S):(y.issues.push({expected:"object",code:"invalid_type",input:w,inst:i}),y)}});function handleUnionResults(i,e,t,n){for(const a of i)if(a.issues.length===0)return e.value=a.value,e;const s=i.filter(a=>!aborted(a));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:i.map(a=>a.issues.map(u=>finalizeIssue(u,n,config())))}),e)}const $ZodUnion=$constructor("$ZodUnion",(i,e)=>{$ZodType.init(i,e),defineLazy(i._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),defineLazy(i._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),defineLazy(i._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),defineLazy(i._zod,"pattern",()=>{if(e.options.every(n=>n._zod.pattern)){const n=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${n.map(s=>cleanRegex(s.source)).join("|")})$`)}});const t=e.options.length===1?e.options[0]._zod.run:null;i._zod.parse=(n,s)=>{if(t)return t(n,s);let a=!1;const u=[];for(const c of e.options){const h=c._zod.run({value:n.value,issues:[]},s);if(h instanceof Promise)u.push(h),a=!0;else{if(h.issues.length===0)return h;u.push(h)}}return a?Promise.all(u).then(c=>handleUnionResults(c,n,i,s)):handleUnionResults(u,n,i,s)}}),$ZodIntersection=$constructor("$ZodIntersection",(i,e)=>{$ZodType.init(i,e),i._zod.parse=(t,n)=>{const s=t.value,a=e.left._zod.run({value:s,issues:[]},n),u=e.right._zod.run({value:s,issues:[]},n);return a instanceof Promise||u instanceof Promise?Promise.all([a,u]).then(([h,f])=>handleIntersectionResults(t,h,f)):handleIntersectionResults(t,a,u)}});function mergeValues(i,e){if(i===e)return{valid:!0,data:i};if(i instanceof Date&&e instanceof Date&&+i==+e)return{valid:!0,data:i};if(isPlainObject(i)&&isPlainObject(e)){const t=Object.keys(e),n=Object.keys(i).filter(a=>t.indexOf(a)!==-1),s={...i,...e};for(const a of n){const u=mergeValues(i[a],e[a]);if(!u.valid)return{valid:!1,mergeErrorPath:[a,...u.mergeErrorPath]};s[a]=u.data}return{valid:!0,data:s}}if(Array.isArray(i)&&Array.isArray(e)){if(i.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let n=0;n<i.length;n++){const s=i[n],a=e[n],u=mergeValues(s,a);if(!u.valid)return{valid:!1,mergeErrorPath:[n,...u.mergeErrorPath]};t.push(u.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function handleIntersectionResults(i,e,t){const n=new Map;let s;for(const c of e.issues)if(c.code==="unrecognized_keys"){s??(s=c);for(const h of c.keys)n.has(h)||n.set(h,{}),n.get(h).l=!0}else i.issues.push(c);for(const c of t.issues)if(c.code==="unrecognized_keys")for(const h of c.keys)n.has(h)||n.set(h,{}),n.get(h).r=!0;else i.issues.push(c);const a=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length&&s&&i.issues.push({...s,keys:a}),aborted(i))return i;const u=mergeValues(e.value,t.value);if(!u.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`);return i.value=u.data,i}const $ZodEnum=$constructor("$ZodEnum",(i,e)=>{$ZodType.init(i,e);const t=getEnumValues(e.entries),n=new Set(t);i._zod.values=n,i._zod.pattern=new RegExp(`^(${t.filter(s=>propertyKeyTypes.has(typeof s)).map(s=>typeof s=="string"?escapeRegex(s):s.toString()).join("|")})$`),i._zod.parse=(s,a)=>{const u=s.value;return n.has(u)||s.issues.push({code:"invalid_value",values:t,input:u,inst:i}),s}}),$ZodTransform=$constructor("$ZodTransform",(i,e)=>{$ZodType.init(i,e),i._zod.optin="optional",i._zod.parse=(t,n)=>{if(n.direction==="backward")throw new $ZodEncodeError(i.constructor.name);const s=e.transform(t.value,t);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(u=>(t.value=u,t.fallback=!0,t));if(s instanceof Promise)throw new $ZodAsyncError;return t.value=s,t.fallback=!0,t}});function handleOptionalResult(i,e){return e===void 0&&(i.issues.length||i.fallback)?{issues:[],value:void 0}:i}const $ZodOptional=$constructor("$ZodOptional",(i,e)=>{$ZodType.init(i,e),i._zod.optin="optional",i._zod.optout="optional",defineLazy(i._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),defineLazy(i._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${cleanRegex(t.source)})?$`):void 0}),i._zod.parse=(t,n)=>{if(e.innerType._zod.optin==="optional"){const s=t.value,a=e.innerType._zod.run(t,n);return a instanceof Promise?a.then(u=>handleOptionalResult(u,s)):handleOptionalResult(a,s)}return t.value===void 0?t:e.innerType._zod.run(t,n)}}),$ZodExactOptional=$constructor("$ZodExactOptional",(i,e)=>{$ZodOptional.init(i,e),defineLazy(i._zod,"values",()=>e.innerType._zod.values),defineLazy(i._zod,"pattern",()=>e.innerType._zod.pattern),i._zod.parse=(t,n)=>e.innerType._zod.run(t,n)}),$ZodNullable=$constructor("$ZodNullable",(i,e)=>{$ZodType.init(i,e),defineLazy(i._zod,"optin",()=>e.innerType._zod.optin),defineLazy(i._zod,"optout",()=>e.innerType._zod.optout),defineLazy(i._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${cleanRegex(t.source)}|null)$`):void 0}),defineLazy(i._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),i._zod.parse=(t,n)=>t.value===null?t:e.innerType._zod.run(t,n)}),$ZodDefault=$constructor("$ZodDefault",(i,e)=>{$ZodType.init(i,e),i._zod.optin="optional",defineLazy(i._zod,"values",()=>e.innerType._zod.values),i._zod.parse=(t,n)=>{if(n.direction==="backward")return e.innerType._zod.run(t,n);if(t.value===void 0)return t.value=e.defaultValue,t;const s=e.innerType._zod.run(t,n);return s instanceof Promise?s.then(a=>handleDefaultResult(a,e)):handleDefaultResult(s,e)}});function handleDefaultResult(i,e){return i.value===void 0&&(i.value=e.defaultValue),i}const $ZodPrefault=$constructor("$ZodPrefault",(i,e)=>{$ZodType.init(i,e),i._zod.optin="optional",defineLazy(i._zod,"values",()=>e.innerType._zod.values),i._zod.parse=(t,n)=>(n.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,n))}),$ZodNonOptional=$constructor("$ZodNonOptional",(i,e)=>{$ZodType.init(i,e),defineLazy(i._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(n=>n!==void 0)):void 0}),i._zod.parse=(t,n)=>{const s=e.innerType._zod.run(t,n);return s instanceof Promise?s.then(a=>handleNonOptionalResult(a,i)):handleNonOptionalResult(s,i)}});function handleNonOptionalResult(i,e){return!i.issues.length&&i.value===void 0&&i.issues.push({code:"invalid_type",expected:"nonoptional",input:i.value,inst:e}),i}const $ZodCatch=$constructor("$ZodCatch",(i,e)=>{$ZodType.init(i,e),i._zod.optin="optional",defineLazy(i._zod,"optout",()=>e.innerType._zod.optout),defineLazy(i._zod,"values",()=>e.innerType._zod.values),i._zod.parse=(t,n)=>{if(n.direction==="backward")return e.innerType._zod.run(t,n);const s=e.innerType._zod.run(t,n);return s instanceof Promise?s.then(a=>(t.value=a.value,a.issues.length&&(t.value=e.catchValue({...t,error:{issues:a.issues.map(u=>finalizeIssue(u,n,config()))},input:t.value}),t.issues=[],t.fallback=!0),t)):(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(a=>finalizeIssue(a,n,config()))},input:t.value}),t.issues=[],t.fallback=!0),t)}}),$ZodPipe=$constructor("$ZodPipe",(i,e)=>{$ZodType.init(i,e),defineLazy(i._zod,"values",()=>e.in._zod.values),defineLazy(i._zod,"optin",()=>e.in._zod.optin),defineLazy(i._zod,"optout",()=>e.out._zod.optout),defineLazy(i._zod,"propValues",()=>e.in._zod.propValues),i._zod.parse=(t,n)=>{if(n.direction==="backward"){const a=e.out._zod.run(t,n);return a instanceof Promise?a.then(u=>handlePipeResult(u,e.in,n)):handlePipeResult(a,e.in,n)}const s=e.in._zod.run(t,n);return s instanceof Promise?s.then(a=>handlePipeResult(a,e.out,n)):handlePipeResult(s,e.out,n)}});function handlePipeResult(i,e,t){return i.issues.length?(i.aborted=!0,i):e._zod.run({value:i.value,issues:i.issues,fallback:i.fallback},t)}const $ZodReadonly=$constructor("$ZodReadonly",(i,e)=>{$ZodType.init(i,e),defineLazy(i._zod,"propValues",()=>e.innerType._zod.propValues),defineLazy(i._zod,"values",()=>e.innerType._zod.values),defineLazy(i._zod,"optin",()=>e.innerType?._zod?.optin),defineLazy(i._zod,"optout",()=>e.innerType?._zod?.optout),i._zod.parse=(t,n)=>{if(n.direction==="backward")return e.innerType._zod.run(t,n);const s=e.innerType._zod.run(t,n);return s instanceof Promise?s.then(handleReadonlyResult):handleReadonlyResult(s)}});function handleReadonlyResult(i){return i.value=Object.freeze(i.value),i}const $ZodCustom=$constructor("$ZodCustom",(i,e)=>{$ZodCheck.init(i,e),$ZodType.init(i,e),i._zod.parse=(t,n)=>t,i._zod.check=t=>{const n=t.value,s=e.fn(n);if(s instanceof Promise)return s.then(a=>handleRefineResult(a,t,n,i));handleRefineResult(s,t,n,i)}});function handleRefineResult(i,e,t,n){if(!i){const s={code:"custom",input:t,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(issue(s))}}var _a$1;class $ZodRegistry{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const s={...n,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function registry(){return new $ZodRegistry}(_a$1=globalThis).__zod_globalRegistry??(_a$1.__zod_globalRegistry=registry());const globalRegistry=globalThis.__zod_globalRegistry;function _string(i,e){return new i({type:"string",...normalizeParams(e)})}function _email(i,e){return new i({type:"string",format:"email",check:"string_format",abort:!1,...normalizeParams(e)})}function _guid(i,e){return new i({type:"string",format:"guid",check:"string_format",abort:!1,...normalizeParams(e)})}function _uuid(i,e){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,...normalizeParams(e)})}function _uuidv4(i,e){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...normalizeParams(e)})}function _uuidv6(i,e){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...normalizeParams(e)})}function _uuidv7(i,e){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...normalizeParams(e)})}function _url(i,e){return new i({type:"string",format:"url",check:"string_format",abort:!1,...normalizeParams(e)})}function _emoji(i,e){return new i({type:"string",format:"emoji",check:"string_format",abort:!1,...normalizeParams(e)})}function _nanoid(i,e){return new i({type:"string",format:"nanoid",check:"string_format",abort:!1,...normalizeParams(e)})}function _cuid(i,e){return new i({type:"string",format:"cuid",check:"string_format",abort:!1,...normalizeParams(e)})}function _cuid2(i,e){return new i({type:"string",format:"cuid2",check:"string_format",abort:!1,...normalizeParams(e)})}function _ulid(i,e){return new i({type:"string",format:"ulid",check:"string_format",abort:!1,...normalizeParams(e)})}function _xid(i,e){return new i({type:"string",format:"xid",check:"string_format",abort:!1,...normalizeParams(e)})}function _ksuid(i,e){return new i({type:"string",format:"ksuid",check:"string_format",abort:!1,...normalizeParams(e)})}function _ipv4(i,e){return new i({type:"string",format:"ipv4",check:"string_format",abort:!1,...normalizeParams(e)})}function _ipv6(i,e){return new i({type:"string",format:"ipv6",check:"string_format",abort:!1,...normalizeParams(e)})}function _cidrv4(i,e){return new i({type:"string",format:"cidrv4",check:"string_format",abort:!1,...normalizeParams(e)})}function _cidrv6(i,e){return new i({type:"string",format:"cidrv6",check:"string_format",abort:!1,...normalizeParams(e)})}function _base64(i,e){return new i({type:"string",format:"base64",check:"string_format",abort:!1,...normalizeParams(e)})}function _base64url(i,e){return new i({type:"string",format:"base64url",check:"string_format",abort:!1,...normalizeParams(e)})}function _e164(i,e){return new i({type:"string",format:"e164",check:"string_format",abort:!1,...normalizeParams(e)})}function _jwt(i,e){return new i({type:"string",format:"jwt",check:"string_format",abort:!1,...normalizeParams(e)})}function _isoDateTime(i,e){return new i({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...normalizeParams(e)})}function _isoDate(i,e){return new i({type:"string",format:"date",check:"string_format",...normalizeParams(e)})}function _isoTime(i,e){return new i({type:"string",format:"time",check:"string_format",precision:null,...normalizeParams(e)})}function _isoDuration(i,e){return new i({type:"string",format:"duration",check:"string_format",...normalizeParams(e)})}function _number(i,e){return new i({type:"number",checks:[],...normalizeParams(e)})}function _int(i,e){return new i({type:"number",check:"number_format",abort:!1,format:"safeint",...normalizeParams(e)})}function _boolean(i,e){return new i({type:"boolean",...normalizeParams(e)})}function _any(i){return new i({type:"any"})}function _unknown(i){return new i({type:"unknown"})}function _never(i,e){return new i({type:"never",...normalizeParams(e)})}function _date(i,e){return new i({type:"date",...normalizeParams(e)})}function _lt(i,e){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(e),value:i,inclusive:!1})}function _lte(i,e){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(e),value:i,inclusive:!0})}function _gt(i,e){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(e),value:i,inclusive:!1})}function _gte(i,e){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(e),value:i,inclusive:!0})}function _multipleOf(i,e){return new $ZodCheckMultipleOf({check:"multiple_of",...normalizeParams(e),value:i})}function _maxLength(i,e){return new $ZodCheckMaxLength({check:"max_length",...normalizeParams(e),maximum:i})}function _minLength(i,e){return new $ZodCheckMinLength({check:"min_length",...normalizeParams(e),minimum:i})}function _length(i,e){return new $ZodCheckLengthEquals({check:"length_equals",...normalizeParams(e),length:i})}function _regex(i,e){return new $ZodCheckRegex({check:"string_format",format:"regex",...normalizeParams(e),pattern:i})}function _lowercase(i){return new $ZodCheckLowerCase({check:"string_format",format:"lowercase",...normalizeParams(i)})}function _uppercase(i){return new $ZodCheckUpperCase({check:"string_format",format:"uppercase",...normalizeParams(i)})}function _includes(i,e){return new $ZodCheckIncludes({check:"string_format",format:"includes",...normalizeParams(e),includes:i})}function _startsWith(i,e){return new $ZodCheckStartsWith({check:"string_format",format:"starts_with",...normalizeParams(e),prefix:i})}function _endsWith(i,e){return new $ZodCheckEndsWith({check:"string_format",format:"ends_with",...normalizeParams(e),suffix:i})}function _overwrite(i){return new $ZodCheckOverwrite({check:"overwrite",tx:i})}function _normalize(i){return _overwrite(e=>e.normalize(i))}function _trim(){return _overwrite(i=>i.trim())}function _toLowerCase(){return _overwrite(i=>i.toLowerCase())}function _toUpperCase(){return _overwrite(i=>i.toUpperCase())}function _slugify(){return _overwrite(i=>slugify(i))}function _array(i,e,t){return new i({type:"array",element:e,...normalizeParams(t)})}function _refine(i,e,t){return new i({type:"custom",check:"custom",fn:e,...normalizeParams(t)})}function _superRefine(i,e){const t=_check(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(issue(s,n.value,t._zod.def));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=t),a.continue??(a.continue=!t._zod.def.abort),n.issues.push(issue(a))}},i(n.value,n)),e);return t}function _check(i,e){const t=new $ZodCheck({check:"custom",...normalizeParams(e)});return t._zod.check=i,t}function initializeContext(i){let e=i?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:i.processors??{},metadataRegistry:i?.metadata??globalRegistry,target:e,unrepresentable:i?.unrepresentable??"throw",override:i?.override??(()=>{}),io:i?.io??"output",counter:0,seen:new Map,cycles:i?.cycles??"ref",reused:i?.reused??"inline",external:i?.external??void 0}}function process$1(i,e,t={path:[],schemaPath:[]}){var n;const s=i._zod.def,a=e.seen.get(i);if(a)return a.count++,t.schemaPath.includes(i)&&(a.cycle=t.path),a.schema;const u={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(i,u);const c=i._zod.toJSONSchema?.();if(c)u.schema=c;else{const p={...t,schemaPath:[...t.schemaPath,i],path:t.path};if(i._zod.processJSONSchema)i._zod.processJSONSchema(e,u.schema,p);else{const y=u.schema,S=e.processors[s.type];if(!S)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);S(i,e,y,p)}const g=i._zod.parent;g&&(u.ref||(u.ref=g),process$1(g,e,p),e.seen.get(g).isParent=!0)}const h=e.metadataRegistry.get(i);return h&&Object.assign(u.schema,h),e.io==="input"&&isTransforming(i)&&(delete u.schema.examples,delete u.schema.default),e.io==="input"&&"_prefault"in u.schema&&((n=u.schema).default??(n.default=u.schema._prefault)),delete u.schema._prefault,e.seen.get(i).schema}function extractDefs(i,e){const t=i.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const u of i.seen.entries()){const c=i.metadataRegistry.get(u[0])?.id;if(c){const h=n.get(c);if(h&&h!==u[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,u[0])}}const s=u=>{const c=i.target==="draft-2020-12"?"$defs":"definitions";if(i.external){const g=i.external.registry.get(u[0])?.id,y=i.external.uri??(w=>w);if(g)return{ref:y(g)};const S=u[1].defId??u[1].schema.id??`schema${i.counter++}`;return u[1].defId=S,{defId:S,ref:`${y("__shared")}#/${c}/${S}`}}if(u[1]===t)return{ref:"#"};const f=`#/${c}/`,p=u[1].schema.id??`__schema${i.counter++}`;return{defId:p,ref:f+p}},a=u=>{if(u[1].schema.$ref)return;const c=u[1],{ref:h,defId:f}=s(u);c.def={...c.schema},f&&(c.defId=f);const p=c.schema;for(const g in p)delete p[g];p.$ref=h};if(i.cycles==="throw")for(const u of i.seen.entries()){const c=u[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
298
+
299
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of i.seen.entries()){const c=u[1];if(e===u[0]){a(u);continue}if(i.external){const f=i.external.registry.get(u[0])?.id;if(e!==u[0]&&f){a(u);continue}}if(i.metadataRegistry.get(u[0])?.id){a(u);continue}if(c.cycle){a(u);continue}if(c.count>1&&i.reused==="ref"){a(u);continue}}}function finalize(i,e){const t=i.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=c=>{const h=i.seen.get(c);if(h.ref===null)return;const f=h.def??h.schema,p={...f},g=h.ref;if(h.ref=null,g){n(g);const S=i.seen.get(g),w=S.schema;if(w.$ref&&(i.target==="draft-07"||i.target==="draft-04"||i.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(w)):Object.assign(f,w),Object.assign(f,p),c._zod.parent===g)for(const T in f)T==="$ref"||T==="allOf"||T in p||delete f[T];if(w.$ref&&S.def)for(const T in f)T==="$ref"||T==="allOf"||T in S.def&&JSON.stringify(f[T])===JSON.stringify(S.def[T])&&delete f[T]}const y=c._zod.parent;if(y&&y!==g){n(y);const S=i.seen.get(y);if(S?.schema.$ref&&(f.$ref=S.schema.$ref,S.def))for(const w in f)w==="$ref"||w==="allOf"||w in S.def&&JSON.stringify(f[w])===JSON.stringify(S.def[w])&&delete f[w]}i.override({zodSchema:c,jsonSchema:f,path:h.path??[]})};for(const c of[...i.seen.entries()].reverse())n(c[0]);const s={};if(i.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":i.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":i.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":i.target,i.external?.uri){const c=i.external.registry.get(e)?.id;if(!c)throw new Error("Schema is missing an `id` property");s.$id=i.external.uri(c)}Object.assign(s,t.def??t.schema);const a=i.metadataRegistry.get(e)?.id;a!==void 0&&s.id===a&&delete s.id;const u=i.external?.defs??{};for(const c of i.seen.entries()){const h=c[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,u[h.defId]=h.def)}i.external||Object.keys(u).length>0&&(i.target==="draft-2020-12"?s.$defs=u:s.definitions=u);try{const c=JSON.parse(JSON.stringify(s));return Object.defineProperty(c,"~standard",{value:{...e["~standard"],jsonSchema:{input:createStandardJSONSchemaMethod(e,"input",i.processors),output:createStandardJSONSchemaMethod(e,"output",i.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function isTransforming(i,e){const t=e??{seen:new Set};if(t.seen.has(i))return!1;t.seen.add(i);const n=i._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return isTransforming(n.element,t);if(n.type==="set")return isTransforming(n.valueType,t);if(n.type==="lazy")return isTransforming(n.getter(),t);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return isTransforming(n.innerType,t);if(n.type==="intersection")return isTransforming(n.left,t)||isTransforming(n.right,t);if(n.type==="record"||n.type==="map")return isTransforming(n.keyType,t)||isTransforming(n.valueType,t);if(n.type==="pipe")return i._zod.traits.has("$ZodCodec")?!0:isTransforming(n.in,t)||isTransforming(n.out,t);if(n.type==="object"){for(const s in n.shape)if(isTransforming(n.shape[s],t))return!0;return!1}if(n.type==="union"){for(const s of n.options)if(isTransforming(s,t))return!0;return!1}if(n.type==="tuple"){for(const s of n.items)if(isTransforming(s,t))return!0;return!!(n.rest&&isTransforming(n.rest,t))}return!1}const createToJSONSchemaMethod=(i,e={})=>t=>{const n=initializeContext({...t,processors:e});return process$1(i,n),extractDefs(n,i),finalize(n,i)},createStandardJSONSchemaMethod=(i,e,t={})=>n=>{const{libraryOptions:s,target:a}=n??{},u=initializeContext({...s??{},target:a,io:e,processors:t});return process$1(i,u),extractDefs(u,i),finalize(u,i)},formatMap={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},stringProcessor=(i,e,t,n)=>{const s=t;s.type="string";const{minimum:a,maximum:u,format:c,patterns:h,contentEncoding:f}=i._zod.bag;if(typeof a=="number"&&(s.minLength=a),typeof u=="number"&&(s.maxLength=u),c&&(s.format=formatMap[c]??c,s.format===""&&delete s.format,c==="time"&&delete s.format),f&&(s.contentEncoding=f),h&&h.size>0){const p=[...h];p.length===1?s.pattern=p[0].source:p.length>1&&(s.allOf=[...p.map(g=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},numberProcessor=(i,e,t,n)=>{const s=t,{minimum:a,maximum:u,format:c,multipleOf:h,exclusiveMaximum:f,exclusiveMinimum:p}=i._zod.bag;typeof c=="string"&&c.includes("int")?s.type="integer":s.type="number";const g=typeof p=="number"&&p>=(a??Number.NEGATIVE_INFINITY),y=typeof f=="number"&&f<=(u??Number.POSITIVE_INFINITY),S=e.target==="draft-04"||e.target==="openapi-3.0";g?S?(s.minimum=p,s.exclusiveMinimum=!0):s.exclusiveMinimum=p:typeof a=="number"&&(s.minimum=a),y?S?(s.maximum=f,s.exclusiveMaximum=!0):s.exclusiveMaximum=f:typeof u=="number"&&(s.maximum=u),typeof h=="number"&&(s.multipleOf=h)},booleanProcessor=(i,e,t,n)=>{t.type="boolean"},neverProcessor=(i,e,t,n)=>{t.not={}},anyProcessor=(i,e,t,n)=>{},unknownProcessor=(i,e,t,n)=>{},dateProcessor=(i,e,t,n)=>{if(e.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},enumProcessor=(i,e,t,n)=>{const s=i._zod.def,a=getEnumValues(s.entries);a.every(u=>typeof u=="number")&&(t.type="number"),a.every(u=>typeof u=="string")&&(t.type="string"),t.enum=a},customProcessor=(i,e,t,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},transformProcessor=(i,e,t,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},arrayProcessor=(i,e,t,n)=>{const s=t,a=i._zod.def,{minimum:u,maximum:c}=i._zod.bag;typeof u=="number"&&(s.minItems=u),typeof c=="number"&&(s.maxItems=c),s.type="array",s.items=process$1(a.element,e,{...n,path:[...n.path,"items"]})},objectProcessor=(i,e,t,n)=>{const s=t,a=i._zod.def;s.type="object",s.properties={};const u=a.shape;for(const f in u)s.properties[f]=process$1(u[f],e,{...n,path:[...n.path,"properties",f]});const c=new Set(Object.keys(u)),h=new Set([...c].filter(f=>{const p=a.shape[f]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));h.size>0&&(s.required=Array.from(h)),a.catchall?._zod.def.type==="never"?s.additionalProperties=!1:a.catchall?a.catchall&&(s.additionalProperties=process$1(a.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(s.additionalProperties=!1)},unionProcessor=(i,e,t,n)=>{const s=i._zod.def,a=s.inclusive===!1,u=s.options.map((c,h)=>process$1(c,e,{...n,path:[...n.path,a?"oneOf":"anyOf",h]}));a?t.oneOf=u:t.anyOf=u},intersectionProcessor=(i,e,t,n)=>{const s=i._zod.def,a=process$1(s.left,e,{...n,path:[...n.path,"allOf",0]}),u=process$1(s.right,e,{...n,path:[...n.path,"allOf",1]}),c=f=>"allOf"in f&&Object.keys(f).length===1,h=[...c(a)?a.allOf:[a],...c(u)?u.allOf:[u]];t.allOf=h},nullableProcessor=(i,e,t,n)=>{const s=i._zod.def,a=process$1(s.innerType,e,n),u=e.seen.get(i);e.target==="openapi-3.0"?(u.ref=s.innerType,t.nullable=!0):t.anyOf=[a,{type:"null"}]},nonoptionalProcessor=(i,e,t,n)=>{const s=i._zod.def;process$1(s.innerType,e,n);const a=e.seen.get(i);a.ref=s.innerType},defaultProcessor=(i,e,t,n)=>{const s=i._zod.def;process$1(s.innerType,e,n);const a=e.seen.get(i);a.ref=s.innerType,t.default=JSON.parse(JSON.stringify(s.defaultValue))},prefaultProcessor=(i,e,t,n)=>{const s=i._zod.def;process$1(s.innerType,e,n);const a=e.seen.get(i);a.ref=s.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},catchProcessor=(i,e,t,n)=>{const s=i._zod.def;process$1(s.innerType,e,n);const a=e.seen.get(i);a.ref=s.innerType;let u;try{u=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=u},pipeProcessor=(i,e,t,n)=>{const s=i._zod.def,a=s.in._zod.traits.has("$ZodTransform"),u=e.io==="input"?a?s.out:s.in:s.out;process$1(u,e,n);const c=e.seen.get(i);c.ref=u},readonlyProcessor=(i,e,t,n)=>{const s=i._zod.def;process$1(s.innerType,e,n);const a=e.seen.get(i);a.ref=s.innerType,t.readOnly=!0},optionalProcessor=(i,e,t,n)=>{const s=i._zod.def;process$1(s.innerType,e,n);const a=e.seen.get(i);a.ref=s.innerType},ZodISODateTime=$constructor("ZodISODateTime",(i,e)=>{$ZodISODateTime.init(i,e),ZodStringFormat.init(i,e)});function datetime(i){return _isoDateTime(ZodISODateTime,i)}const ZodISODate=$constructor("ZodISODate",(i,e)=>{$ZodISODate.init(i,e),ZodStringFormat.init(i,e)});function date$1(i){return _isoDate(ZodISODate,i)}const ZodISOTime=$constructor("ZodISOTime",(i,e)=>{$ZodISOTime.init(i,e),ZodStringFormat.init(i,e)});function time(i){return _isoTime(ZodISOTime,i)}const ZodISODuration=$constructor("ZodISODuration",(i,e)=>{$ZodISODuration.init(i,e),ZodStringFormat.init(i,e)});function duration(i){return _isoDuration(ZodISODuration,i)}const initializer=(i,e)=>{$ZodError.init(i,e),i.name="ZodError",Object.defineProperties(i,{format:{value:t=>formatError(i,t)},flatten:{value:t=>flattenError(i,t)},addIssue:{value:t=>{i.issues.push(t),i.message=JSON.stringify(i.issues,jsonStringifyReplacer,2)}},addIssues:{value:t=>{i.issues.push(...t),i.message=JSON.stringify(i.issues,jsonStringifyReplacer,2)}},isEmpty:{get(){return i.issues.length===0}}})},ZodError=$constructor("ZodError",initializer),ZodRealError=$constructor("ZodError",initializer,{Parent:Error}),parse=_parse(ZodRealError),parseAsync=_parseAsync(ZodRealError),safeParse=_safeParse(ZodRealError),safeParseAsync=_safeParseAsync(ZodRealError),encode=_encode(ZodRealError),decode=_decode(ZodRealError),encodeAsync=_encodeAsync(ZodRealError),decodeAsync=_decodeAsync(ZodRealError),safeEncode=_safeEncode(ZodRealError),safeDecode=_safeDecode(ZodRealError),safeEncodeAsync=_safeEncodeAsync(ZodRealError),safeDecodeAsync=_safeDecodeAsync(ZodRealError),_installedGroups=new WeakMap;function _installLazyMethods(i,e,t){const n=Object.getPrototypeOf(i);let s=_installedGroups.get(n);if(s||(s=new Set,_installedGroups.set(n,s)),!s.has(e)){s.add(e);for(const a in t){const u=t[a];Object.defineProperty(n,a,{configurable:!0,enumerable:!1,get(){const c=u.bind(this);return Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:c}),c},set(c){Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:c})}})}}}const ZodType=$constructor("ZodType",(i,e)=>($ZodType.init(i,e),Object.assign(i["~standard"],{jsonSchema:{input:createStandardJSONSchemaMethod(i,"input"),output:createStandardJSONSchemaMethod(i,"output")}}),i.toJSONSchema=createToJSONSchemaMethod(i,{}),i.def=e,i.type=e.type,Object.defineProperty(i,"_def",{value:e}),i.parse=(t,n)=>parse(i,t,n,{callee:i.parse}),i.safeParse=(t,n)=>safeParse(i,t,n),i.parseAsync=async(t,n)=>parseAsync(i,t,n,{callee:i.parseAsync}),i.safeParseAsync=async(t,n)=>safeParseAsync(i,t,n),i.spa=i.safeParseAsync,i.encode=(t,n)=>encode(i,t,n),i.decode=(t,n)=>decode(i,t,n),i.encodeAsync=async(t,n)=>encodeAsync(i,t,n),i.decodeAsync=async(t,n)=>decodeAsync(i,t,n),i.safeEncode=(t,n)=>safeEncode(i,t,n),i.safeDecode=(t,n)=>safeDecode(i,t,n),i.safeEncodeAsync=async(t,n)=>safeEncodeAsync(i,t,n),i.safeDecodeAsync=async(t,n)=>safeDecodeAsync(i,t,n),_installLazyMethods(i,"ZodType",{check(...t){const n=this.def;return this.clone(mergeDefs(n,{checks:[...n.checks??[],...t.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,n){return clone(this,t,n)},brand(){return this},register(t,n){return t.add(this,n),this},refine(t,n){return this.check(refine(t,n))},superRefine(t,n){return this.check(superRefine(t,n))},overwrite(t){return this.check(_overwrite(t))},optional(){return optional(this)},exactOptional(){return exactOptional(this)},nullable(){return nullable(this)},nullish(){return optional(nullable(this))},nonoptional(t){return nonoptional(this,t)},array(){return array(this)},or(t){return union([this,t])},and(t){return intersection(this,t)},transform(t){return pipe(this,transform(t))},default(t){return _default(this,t)},prefault(t){return prefault(this,t)},catch(t){return _catch(this,t)},pipe(t){return pipe(this,t)},readonly(){return readonly(this)},describe(t){const n=this.clone();return globalRegistry.add(n,{description:t}),n},meta(...t){if(t.length===0)return globalRegistry.get(this);const n=this.clone();return globalRegistry.add(n,t[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t){return t(this)}}),Object.defineProperty(i,"description",{get(){return globalRegistry.get(i)?.description},configurable:!0}),i)),_ZodString=$constructor("_ZodString",(i,e)=>{$ZodString.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(n,s,a)=>stringProcessor(i,n,s);const t=i._zod.bag;i.format=t.format??null,i.minLength=t.minimum??null,i.maxLength=t.maximum??null,_installLazyMethods(i,"_ZodString",{regex(...n){return this.check(_regex(...n))},includes(...n){return this.check(_includes(...n))},startsWith(...n){return this.check(_startsWith(...n))},endsWith(...n){return this.check(_endsWith(...n))},min(...n){return this.check(_minLength(...n))},max(...n){return this.check(_maxLength(...n))},length(...n){return this.check(_length(...n))},nonempty(...n){return this.check(_minLength(1,...n))},lowercase(n){return this.check(_lowercase(n))},uppercase(n){return this.check(_uppercase(n))},trim(){return this.check(_trim())},normalize(...n){return this.check(_normalize(...n))},toLowerCase(){return this.check(_toLowerCase())},toUpperCase(){return this.check(_toUpperCase())},slugify(){return this.check(_slugify())}})}),ZodString=$constructor("ZodString",(i,e)=>{$ZodString.init(i,e),_ZodString.init(i,e),i.email=t=>i.check(_email(ZodEmail,t)),i.url=t=>i.check(_url(ZodURL,t)),i.jwt=t=>i.check(_jwt(ZodJWT,t)),i.emoji=t=>i.check(_emoji(ZodEmoji,t)),i.guid=t=>i.check(_guid(ZodGUID,t)),i.uuid=t=>i.check(_uuid(ZodUUID,t)),i.uuidv4=t=>i.check(_uuidv4(ZodUUID,t)),i.uuidv6=t=>i.check(_uuidv6(ZodUUID,t)),i.uuidv7=t=>i.check(_uuidv7(ZodUUID,t)),i.nanoid=t=>i.check(_nanoid(ZodNanoID,t)),i.guid=t=>i.check(_guid(ZodGUID,t)),i.cuid=t=>i.check(_cuid(ZodCUID,t)),i.cuid2=t=>i.check(_cuid2(ZodCUID2,t)),i.ulid=t=>i.check(_ulid(ZodULID,t)),i.base64=t=>i.check(_base64(ZodBase64,t)),i.base64url=t=>i.check(_base64url(ZodBase64URL,t)),i.xid=t=>i.check(_xid(ZodXID,t)),i.ksuid=t=>i.check(_ksuid(ZodKSUID,t)),i.ipv4=t=>i.check(_ipv4(ZodIPv4,t)),i.ipv6=t=>i.check(_ipv6(ZodIPv6,t)),i.cidrv4=t=>i.check(_cidrv4(ZodCIDRv4,t)),i.cidrv6=t=>i.check(_cidrv6(ZodCIDRv6,t)),i.e164=t=>i.check(_e164(ZodE164,t)),i.datetime=t=>i.check(datetime(t)),i.date=t=>i.check(date$1(t)),i.time=t=>i.check(time(t)),i.duration=t=>i.check(duration(t))});function string(i){return _string(ZodString,i)}const ZodStringFormat=$constructor("ZodStringFormat",(i,e)=>{$ZodStringFormat.init(i,e),_ZodString.init(i,e)}),ZodEmail=$constructor("ZodEmail",(i,e)=>{$ZodEmail.init(i,e),ZodStringFormat.init(i,e)}),ZodGUID=$constructor("ZodGUID",(i,e)=>{$ZodGUID.init(i,e),ZodStringFormat.init(i,e)}),ZodUUID=$constructor("ZodUUID",(i,e)=>{$ZodUUID.init(i,e),ZodStringFormat.init(i,e)}),ZodURL=$constructor("ZodURL",(i,e)=>{$ZodURL.init(i,e),ZodStringFormat.init(i,e)}),ZodEmoji=$constructor("ZodEmoji",(i,e)=>{$ZodEmoji.init(i,e),ZodStringFormat.init(i,e)}),ZodNanoID=$constructor("ZodNanoID",(i,e)=>{$ZodNanoID.init(i,e),ZodStringFormat.init(i,e)}),ZodCUID=$constructor("ZodCUID",(i,e)=>{$ZodCUID.init(i,e),ZodStringFormat.init(i,e)}),ZodCUID2=$constructor("ZodCUID2",(i,e)=>{$ZodCUID2.init(i,e),ZodStringFormat.init(i,e)}),ZodULID=$constructor("ZodULID",(i,e)=>{$ZodULID.init(i,e),ZodStringFormat.init(i,e)}),ZodXID=$constructor("ZodXID",(i,e)=>{$ZodXID.init(i,e),ZodStringFormat.init(i,e)}),ZodKSUID=$constructor("ZodKSUID",(i,e)=>{$ZodKSUID.init(i,e),ZodStringFormat.init(i,e)}),ZodIPv4=$constructor("ZodIPv4",(i,e)=>{$ZodIPv4.init(i,e),ZodStringFormat.init(i,e)}),ZodIPv6=$constructor("ZodIPv6",(i,e)=>{$ZodIPv6.init(i,e),ZodStringFormat.init(i,e)}),ZodCIDRv4=$constructor("ZodCIDRv4",(i,e)=>{$ZodCIDRv4.init(i,e),ZodStringFormat.init(i,e)}),ZodCIDRv6=$constructor("ZodCIDRv6",(i,e)=>{$ZodCIDRv6.init(i,e),ZodStringFormat.init(i,e)}),ZodBase64=$constructor("ZodBase64",(i,e)=>{$ZodBase64.init(i,e),ZodStringFormat.init(i,e)}),ZodBase64URL=$constructor("ZodBase64URL",(i,e)=>{$ZodBase64URL.init(i,e),ZodStringFormat.init(i,e)}),ZodE164=$constructor("ZodE164",(i,e)=>{$ZodE164.init(i,e),ZodStringFormat.init(i,e)}),ZodJWT=$constructor("ZodJWT",(i,e)=>{$ZodJWT.init(i,e),ZodStringFormat.init(i,e)}),ZodNumber=$constructor("ZodNumber",(i,e)=>{$ZodNumber.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(n,s,a)=>numberProcessor(i,n,s),_installLazyMethods(i,"ZodNumber",{gt(n,s){return this.check(_gt(n,s))},gte(n,s){return this.check(_gte(n,s))},min(n,s){return this.check(_gte(n,s))},lt(n,s){return this.check(_lt(n,s))},lte(n,s){return this.check(_lte(n,s))},max(n,s){return this.check(_lte(n,s))},int(n){return this.check(int(n))},safe(n){return this.check(int(n))},positive(n){return this.check(_gt(0,n))},nonnegative(n){return this.check(_gte(0,n))},negative(n){return this.check(_lt(0,n))},nonpositive(n){return this.check(_lte(0,n))},multipleOf(n,s){return this.check(_multipleOf(n,s))},step(n,s){return this.check(_multipleOf(n,s))},finite(){return this}});const t=i._zod.bag;i.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,i.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,i.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),i.isFinite=!0,i.format=t.format??null});function number(i){return _number(ZodNumber,i)}const ZodNumberFormat=$constructor("ZodNumberFormat",(i,e)=>{$ZodNumberFormat.init(i,e),ZodNumber.init(i,e)});function int(i){return _int(ZodNumberFormat,i)}const ZodBoolean=$constructor("ZodBoolean",(i,e)=>{$ZodBoolean.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>booleanProcessor(i,t,n)});function boolean(i){return _boolean(ZodBoolean,i)}const ZodAny=$constructor("ZodAny",(i,e)=>{$ZodAny.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>anyProcessor()});function any(){return _any(ZodAny)}const ZodUnknown=$constructor("ZodUnknown",(i,e)=>{$ZodUnknown.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>unknownProcessor()});function unknown(){return _unknown(ZodUnknown)}const ZodNever=$constructor("ZodNever",(i,e)=>{$ZodNever.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>neverProcessor(i,t,n)});function never(i){return _never(ZodNever,i)}const ZodDate=$constructor("ZodDate",(i,e)=>{$ZodDate.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(n,s,a)=>dateProcessor(i,n),i.min=(n,s)=>i.check(_gte(n,s)),i.max=(n,s)=>i.check(_lte(n,s));const t=i._zod.bag;i.minDate=t.minimum?new Date(t.minimum):null,i.maxDate=t.maximum?new Date(t.maximum):null});function date(i){return _date(ZodDate,i)}const ZodArray=$constructor("ZodArray",(i,e)=>{$ZodArray.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>arrayProcessor(i,t,n,s),i.element=e.element,_installLazyMethods(i,"ZodArray",{min(t,n){return this.check(_minLength(t,n))},nonempty(t){return this.check(_minLength(1,t))},max(t,n){return this.check(_maxLength(t,n))},length(t,n){return this.check(_length(t,n))},unwrap(){return this.element}})});function array(i,e){return _array(ZodArray,i,e)}const ZodObject=$constructor("ZodObject",(i,e)=>{$ZodObjectJIT.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>objectProcessor(i,t,n,s),defineLazy(i,"shape",()=>e.shape),_installLazyMethods(i,"ZodObject",{keyof(){return _enum(Object.keys(this._zod.def.shape))},catchall(t){return this.clone({...this._zod.def,catchall:t})},passthrough(){return this.clone({...this._zod.def,catchall:unknown()})},loose(){return this.clone({...this._zod.def,catchall:unknown()})},strict(){return this.clone({...this._zod.def,catchall:never()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(t){return extend(this,t)},safeExtend(t){return safeExtend(this,t)},merge(t){return merge(this,t)},pick(t){return pick(this,t)},omit(t){return omit(this,t)},partial(...t){return partial(ZodOptional,this,t[0])},required(...t){return required(ZodNonOptional,this,t[0])}})});function object(i,e){const t={type:"object",shape:i??{},...normalizeParams(e)};return new ZodObject(t)}const ZodUnion=$constructor("ZodUnion",(i,e)=>{$ZodUnion.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>unionProcessor(i,t,n,s),i.options=e.options});function union(i,e){return new ZodUnion({type:"union",options:i,...normalizeParams(e)})}const ZodIntersection=$constructor("ZodIntersection",(i,e)=>{$ZodIntersection.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>intersectionProcessor(i,t,n,s)});function intersection(i,e){return new ZodIntersection({type:"intersection",left:i,right:e})}const ZodEnum=$constructor("ZodEnum",(i,e)=>{$ZodEnum.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(n,s,a)=>enumProcessor(i,n,s),i.enum=e.entries,i.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));i.extract=(n,s)=>{const a={};for(const u of n)if(t.has(u))a[u]=e.entries[u];else throw new Error(`Key ${u} not found in enum`);return new ZodEnum({...e,checks:[],...normalizeParams(s),entries:a})},i.exclude=(n,s)=>{const a={...e.entries};for(const u of n)if(t.has(u))delete a[u];else throw new Error(`Key ${u} not found in enum`);return new ZodEnum({...e,checks:[],...normalizeParams(s),entries:a})}});function _enum(i,e){const t=Array.isArray(i)?Object.fromEntries(i.map(n=>[n,n])):i;return new ZodEnum({type:"enum",entries:t,...normalizeParams(e)})}const ZodTransform=$constructor("ZodTransform",(i,e)=>{$ZodTransform.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>transformProcessor(i,t),i._zod.parse=(t,n)=>{if(n.direction==="backward")throw new $ZodEncodeError(i.constructor.name);t.addIssue=a=>{if(typeof a=="string")t.issues.push(issue(a,t.value,e));else{const u=a;u.fatal&&(u.continue=!1),u.code??(u.code="custom"),u.input??(u.input=t.value),u.inst??(u.inst=i),t.issues.push(issue(u))}};const s=e.transform(t.value,t);return s instanceof Promise?s.then(a=>(t.value=a,t.fallback=!0,t)):(t.value=s,t.fallback=!0,t)}});function transform(i){return new ZodTransform({type:"transform",transform:i})}const ZodOptional=$constructor("ZodOptional",(i,e)=>{$ZodOptional.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>optionalProcessor(i,t,n,s),i.unwrap=()=>i._zod.def.innerType});function optional(i){return new ZodOptional({type:"optional",innerType:i})}const ZodExactOptional=$constructor("ZodExactOptional",(i,e)=>{$ZodExactOptional.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>optionalProcessor(i,t,n,s),i.unwrap=()=>i._zod.def.innerType});function exactOptional(i){return new ZodExactOptional({type:"optional",innerType:i})}const ZodNullable=$constructor("ZodNullable",(i,e)=>{$ZodNullable.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>nullableProcessor(i,t,n,s),i.unwrap=()=>i._zod.def.innerType});function nullable(i){return new ZodNullable({type:"nullable",innerType:i})}const ZodDefault=$constructor("ZodDefault",(i,e)=>{$ZodDefault.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>defaultProcessor(i,t,n,s),i.unwrap=()=>i._zod.def.innerType,i.removeDefault=i.unwrap});function _default(i,e){return new ZodDefault({type:"default",innerType:i,get defaultValue(){return typeof e=="function"?e():shallowClone(e)}})}const ZodPrefault=$constructor("ZodPrefault",(i,e)=>{$ZodPrefault.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>prefaultProcessor(i,t,n,s),i.unwrap=()=>i._zod.def.innerType});function prefault(i,e){return new ZodPrefault({type:"prefault",innerType:i,get defaultValue(){return typeof e=="function"?e():shallowClone(e)}})}const ZodNonOptional=$constructor("ZodNonOptional",(i,e)=>{$ZodNonOptional.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>nonoptionalProcessor(i,t,n,s),i.unwrap=()=>i._zod.def.innerType});function nonoptional(i,e){return new ZodNonOptional({type:"nonoptional",innerType:i,...normalizeParams(e)})}const ZodCatch=$constructor("ZodCatch",(i,e)=>{$ZodCatch.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>catchProcessor(i,t,n,s),i.unwrap=()=>i._zod.def.innerType,i.removeCatch=i.unwrap});function _catch(i,e){return new ZodCatch({type:"catch",innerType:i,catchValue:typeof e=="function"?e:()=>e})}const ZodPipe=$constructor("ZodPipe",(i,e)=>{$ZodPipe.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>pipeProcessor(i,t,n,s),i.in=e.in,i.out=e.out});function pipe(i,e){return new ZodPipe({type:"pipe",in:i,out:e})}const ZodReadonly=$constructor("ZodReadonly",(i,e)=>{$ZodReadonly.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>readonlyProcessor(i,t,n,s),i.unwrap=()=>i._zod.def.innerType});function readonly(i){return new ZodReadonly({type:"readonly",innerType:i})}const ZodCustom=$constructor("ZodCustom",(i,e)=>{$ZodCustom.init(i,e),ZodType.init(i,e),i._zod.processJSONSchema=(t,n,s)=>customProcessor(i,t)});function refine(i,e={}){return _refine(ZodCustom,i,e)}function superRefine(i,e){return _superRefine(i,e)}async function parseSHACL(i,e){const t=new N3Store$1,n=new N3Parser$1({baseIRI:e});return new Promise((s,a)=>{const u=[];n.parse(i,(c,h,f)=>{if(c){a(c);return}if(h)u.push(h);else{t.addQuads(u);try{const p=extractShapes(t);s(p)}catch(p){a(p)}}})})}function extractShapes(i){const e=[],t=i.getQuads(null,new NamedNode$2("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),new NamedNode$2(SHACL.NODE_SHAPE),null);for(const n of t){const s=n.subject;if(s.termType==="NamedNode"||s.termType==="BlankNode"){const a=extractShape(i,s);a&&e.push(a)}}return e}function extractShape(i,e){const t=i.getQuads(e,new NamedNode$2(SHACL.TARGET_CLASS),null,null);if(t.length===0)return null;const n=t[0].object.value,s=i.getQuads(e,new NamedNode$2(SHACL.NAME),null,null),a=s.length>0?s[0].object.value:void 0,u=i.getQuads(e,new NamedNode$2(SHACL.DESCRIPTION),null,null),c=u.length>0?u[0].object.value:void 0,h=i.getQuads(e,new NamedNode$2(SHACL.PROPERTY),null,null),f=[];for(const p of h){const g=p.object,y=extractProperty(i,g);y&&f.push(y)}return{uri:e.value,targetClass:n,name:a,description:c,properties:f}}function extractProperty(i,e){const t=i.getQuads(e,new NamedNode$2(SHACL.PATH),null,null);if(t.length===0)return null;let n,s=!1;const a=t[0].object;if(a.termType==="BlankNode"){const D=i.getQuads(a,new NamedNode$2(SHACL.INVERSE_PATH),null,null);if(D.length>0)n=D[0].object.value,s=!0;else return null}else n=a.value;const u=i.getQuads(e,new NamedNode$2(SHACL.NAME),null,null),c=u.length>0?u[0].object.value:extractNameFromPath(n),h=i.getQuads(e,new NamedNode$2(SHACL.DATATYPE),null,null),f=h.length>0?h[0].object.value:void 0,p=i.getQuads(e,new NamedNode$2(SHACL.NODE_KIND),null,null),g=p.length>0?p[0].object.value:void 0,y=i.getQuads(e,new NamedNode$2(SHACL.MIN_COUNT),null,null),S=y.length>0?parseInt(y[0].object.value,10):void 0,w=i.getQuads(e,new NamedNode$2(SHACL.MAX_COUNT),null,null),R=w.length>0?parseInt(w[0].object.value,10):void 0,T=i.getQuads(e,new NamedNode$2(SHACL.PATTERN),null,null),A=T.length>0?T[0].object.value:void 0,F=i.getQuads(e,new NamedNode$2(SHACL.CLASS),null,null),x=F.length>0?F[0].object.value:void 0;return{path:n,name:c,datatype:f,nodeKind:g,minCount:S,maxCount:R,pattern:A,class:x,inverse:s}}function extractNameFromPath(i){const e=i.lastIndexOf("#");if(e>=0)return i.substring(e+1);const t=i.lastIndexOf("/");return t>=0?i.substring(t+1):i}function xsdToDrizzleType(i){if(!i)return"string";switch(i){case XSD.STRING:return"string";case XSD.INTEGER:return"integer";case XSD.BOOLEAN:return"boolean";case XSD.DATETIME:case XSD.DATE:return"datetime";case XSD.DECIMAL:case XSD.DOUBLE:return"number";case XSD.ANYURI:return"uri";default:return"string"}}function nodeKindToDrizzleType(i){if(i)switch(i){case SHACL.IRI:return"uri";case SHACL.LITERAL:return"string";case SHACL.BLANK_NODE:return"object";default:return}}class DrizzleShapeManager{constructor(e,t){this.podUrl=e.endsWith("/")?e:`${e}/`,this.authenticatedFetch=t??globalThis.fetch}generateShape(e){const t=typeof e.config.type=="string"?e.config.type:e.config.type.value;let s=e.getResourcePath?.()||e.getContainerPath();s&&!s.startsWith("http")&&(s=`${this.podUrl}${s.replace(/^\//,"")}`),s||(s=this.podUrl);const c=`${s.endsWith("/")?`${s}shapes/`:`${s.substring(0,s.lastIndexOf("/")+1)}shapes/`}${e.config.name}Shape.ttl#${e.config.name}Shape`,h=[];return Object.entries(e.columns).forEach(([f,p])=>{if(f==="id")return;const g=getPredicateForColumn(p,e);if(!g||g.includes("example.org/unknown"))return;const y={path:g,name:p.name,minCount:p.options?.required?1:void 0,maxCount:p.dataType==="array"||p.options?.isArray?void 0:1};if(p.options?.inverse&&(y.inverse=!0),p.dataType==="uri"||p.options?.linkTarget)y.datatype=p.dataType==="uri"?XSD.ANYURI:void 0,y.nodeKind=SHACL.IRI,y.class=p.options?.linkTarget;else switch(p.dataType){case"string":y.datatype=XSD.STRING,y.nodeKind=SHACL.LITERAL;break;case"integer":y.datatype=XSD.INTEGER,y.nodeKind=SHACL.LITERAL;break;case"boolean":y.datatype=XSD.BOOLEAN,y.nodeKind=SHACL.LITERAL;break;case"datetime":y.datatype=XSD.DATETIME,y.nodeKind=SHACL.LITERAL;break;case"object":case"json":y.nodeKind=SHACL.BLANK_NODE;break;case"array":y.minCount=p.options?.required?1:0;break}h.push(y)}),{uri:c,name:`${e.config.name} Shape`,description:`SHACL Shape for the ${e.config.name} PodTable.`,targetClass:t,properties:h.filter(f=>f.path!==SHACL.PATH)}}toSHACL(e){const t=[`@prefix sh: <${SHACL.NS}> .`,`@prefix xsd: <${XSD.ANYURI.slice(0,XSD.ANYURI.lastIndexOf("#")+1)}> .`,"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .","@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .","@prefix schema: <https://schema.org/> .","@prefix foaf: <http://xmlns.com/foaf/0.1/> .","@prefix dc: <http://purl.org/dc/terms/> .",`@prefix : <${e.uri.slice(0,e.uri.indexOf("#")+1)}>`,"",`:${e.name?.replace(/\s/g,"")} a sh:NodeShape ;`,` sh:targetClass <${e.targetClass}> ;`," sh:closed false ;"];return e.name&&t.push(` sh:name "${e.name}" ;`),e.description&&(t.push(` sh:description "${e.description}" ;`),t.push(` rdfs:comment """${e.description}""" ;`)),e.properties.forEach(n=>{t.push(" sh:property ["),t.push(` sh:path ${n.inverse?`[ sh:inversePath <${n.path}> ]`:`<${n.path}>`} ;`),n.name&&t.push(` sh:name "${n.name}" ;`),n.datatype&&t.push(` sh:datatype <${n.datatype}> ;`),n.nodeKind&&t.push(` sh:nodeKind <${n.nodeKind}> ;`),typeof n.minCount=="number"&&t.push(` sh:minCount ${n.minCount} ;`),typeof n.maxCount=="number"&&t.push(` sh:maxCount ${n.maxCount} ;`),n.pattern&&t.push(` sh:pattern "${n.pattern}" ;`),n.class&&t.push(` sh:class <${n.class}> ;`),t[t.length-1]=t[t.length-1].replace(/\s;$/,""),t.push(" ] ;")}),t[t.length-1]=t[t.length-1].replace(/\s;$/," ."),t.join(`
300
+ `)}async saveShape(e,t,n){const s=n??this.authenticatedFetch,a=this.toSHACL(e),u=await s(t,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:a});if(!u.ok){const c=await u.text().catch(()=>"");throw new Error(`Failed to save shape to ${t}: ${u.status} ${u.statusText}${c?` - ${c}`:""}`)}}async loadShape(e,t){const n=t??this.authenticatedFetch;try{const s=await n(e,{headers:{Accept:"text/turtle, application/ld+json"}});if(!s.ok)return console.warn(`[ShapeManager] Failed to fetch Shape from ${e}: ${s.status}`),null;const a=await s.text(),u=await parseSHACL(a,e);return u.length===0?(console.warn(`[ShapeManager] No shapes found in ${e}`),null):u.find(h=>h.uri===e||e.includes(h.uri))||u[0]}catch(s){return console.error(`[ShapeManager] Error loading Shape from ${e}:`,s),null}}shapeToTable(e,t){const n=this.extractTableName(e),s={id:string$2("id").primaryKey()};for(const u of e.properties){const c=u.name||this.extractNameFromPath(u.path),h=this.propertyToColumn(u,c);h&&(s[c]=h)}const a=podTable(n,s,{type:e.targetClass,base:t});return{name:n,table:a,shape:e}}extractTableName(e){return e.name?e.name.replace(/\s+/g,"_").replace(/Shape$/i,"").toLowerCase():this.extractNameFromPath(e.targetClass).toLowerCase()}extractNameFromPath(e){const t=e.lastIndexOf("#");if(t>=0)return e.substring(t+1);const n=e.lastIndexOf("/");return n>=0?e.substring(n+1):e}propertyToColumn(e,t){let n="string";if(e.nodeKind){const c=nodeKindToDrizzleType(e.nodeKind);c&&(n=c)}e.datatype&&(n=xsdToDrizzleType(e.datatype)),e.class&&(n="uri");const s=e.maxCount===void 0||e.maxCount>1,a=e.minCount!==void 0&&e.minCount>0;let u;switch(n){case"string":u=string$2(t).predicate(e.path);break;case"integer":u=integer$1(t).predicate(e.path);break;case"boolean":u=boolean$2(t).predicate(e.path);break;case"datetime":u=date$3(t).predicate(e.path);break;case"uri":u=uri(t).predicate(e.path),e.class&&(u=u.link(e.class));break;case"object":u=object$1(t).predicate(e.path);break;default:u=string$2(t).predicate(e.path)}return a&&(u=u.notNull()),s&&(u=u.array()),e.inverse&&(u=u.inverse()),u}validate(e,t){try{return this.shapeToZod(t).parse(e),{valid:!0}}catch(n){const s=n instanceof ZodError?n.issues:n&&Array.isArray(n.errors)?n.errors:void 0;return s?{valid:!1,errors:s.map(a=>({path:a.path?String(a.path[0]):"",message:a.message,constraint:a.code||"unknown",value:void 0}))}:{valid:!1,errors:[{path:"",message:String(n)}]}}}shapeToZod(e){const t={};return e.properties.forEach(n=>{if(!n.name)return;let s=any();if(n.nodeKind===SHACL.IRI)s=string().url().or(string().startsWith("http"));else if(n.datatype)switch(n.datatype){case XSD.STRING:s=string(),n.pattern&&(s=s.regex(new RegExp(n.pattern)));break;case XSD.INTEGER:s=number().int().or(string().regex(/^\d+$/));break;case XSD.DECIMAL:case XSD.DOUBLE:s=number().or(string().regex(/^-?\d*\.?\d+$/));break;case XSD.BOOLEAN:s=boolean().or(string().regex(/^(true|false|1|0)$/i));break;case XSD.DATETIME:case XSD.DATE:s=date().or(string().datetime({offset:!0}));break;case XSD.ANYURI:s=string();break}const a=n.maxCount!==1,u=n.minCount!==void 0&&n.minCount>0;a?(s=array(s),u?s=s.min(n.minCount):s=s.optional()):u||(s=s.optional()),t[n.name]=s}),object(t)}}const CACHE_TTL=300*1e3;class TypeIndexManager{constructor(e,t,n=globalThis.fetch){this.typeIndexCache=null,this.cachedTypeIndexUrl=null,this.webId=e,this.podUrl=t,this.fetchFn=n}getConfig(){return{webId:this.webId,podUrl:this.podUrl,fetch:this.fetchFn,autoCreate:!0}}updateConfig(e){this.webId=e.webId,this.podUrl=e.podUrl,e.fetch&&(this.fetchFn=e.fetch),this.clearCache()}clearCache(){this.typeIndexCache=null}async findTypeIndex(){if(this.typeIndexCache&&Date.now()-this.typeIndexCache.timestamp<CACHE_TTL)return this.typeIndexCache.url;try{let e,t;try{if(console.log("Fetching WebID profile document..."),e=await getSolidDataset(this.webId,{fetch:this.fetchFn}),e||(console.warn("WebID document is empty, attempting to refetch..."),e=await getSolidDataset(this.webId,{fetch:this.fetchFn})),e)if(t=getThing(e,this.webId),t)console.log("Successfully loaded profile from WebID document");else{console.warn("Profile thing not found in dataset, trying alternative approaches...");const s=getThingAll(e);s.length>0&&(t=s[0],console.log("Using first thing from dataset as profile"))}}catch(s){console.warn("Could not fetch WebID document:",s)}if(t){const s=this.extractStorages(t);this.podUrl=resolvePodBase({webId:this.webId,podUrl:this.podUrl,storages:s});const a=getUrl(t,"http://www.w3.org/ns/solid/terms#privateTypeIndex");if(a){const f=Array.isArray(a)?a[0]:a;return console.log(`Found Private TypeIndex in profile: ${f}`),this.cachedTypeIndexUrl=f,f}const u=getUrl(t,"http://www.w3.org/ns/solid/terms#publicTypeIndex");if(u){const f=Array.isArray(u)?u[0]:u;return console.log(`Found Public TypeIndex in profile: ${f}`),this.cachedTypeIndexUrl=f,f}const c=getUrl(t,"http://www.w3.org/ns/solid/terms#typeIndex");if(c){const f=Array.isArray(c)?c[0]:c;return console.log(`Found legacy TypeIndex in profile: ${f}`),this.cachedTypeIndexUrl=f,f}const h=getUrl(t,"http://www.w3.org/ns/pim/space#storage");if(h){const f=Array.isArray(h)?h[0]:h;try{const p=await getSolidDataset(f,{fetch:this.fetchFn}),g=getThing(p,f);if(g){const y=getUrl(g,"http://www.w3.org/ns/solid/terms#privateTypeIndex");if(y){const w=Array.isArray(y)?y[0]:y;return console.log(`Found Private TypeIndex in storage: ${w}`),this.cachedTypeIndexUrl=w,w}const S=getUrl(g,"http://www.w3.org/ns/solid/terms#publicTypeIndex");if(S){const w=Array.isArray(S)?S[0]:S;return console.log(`Found Public TypeIndex in storage: ${w}`),this.cachedTypeIndexUrl=w,w}}}catch(p){console.log("Could not access storage directory:",p)}}}else console.warn("Could not find profile in WebID document, trying fallback methods");const n=[this.joinWithPodBase("settings/privateTypeIndex.ttl"),this.joinWithPodBase("settings/publicTypeIndex.ttl"),this.joinWithPodBase("settings/typeIndex.ttl")];for(const s of n)try{return await getSolidDataset(s,{fetch:this.fetchFn}),console.log(`Found TypeIndex at standard location: ${s}`),this.cachedTypeIndexUrl=s,s}catch{}return console.log("No TypeIndex found"),null}catch(e){return console.error("Error finding TypeIndex:",e),null}}async createTypeIndex(e=!1){return e?this.createPublicTypeIndex():this.createPrivateTypeIndex()}async createPrivateTypeIndex(){const e=this.joinWithPodBase("settings/privateTypeIndex.ttl");try{const t=buildThing(createThing({url:e})).addUrl("http://www.w3.org/1999/02/22-rdf-syntax-ns#type","http://www.w3.org/ns/solid/terms#TypeIndex").addStringNoLocale("http://xmlns.com/foaf/0.1/name","Private Type Index").addStringNoLocale("http://purl.org/dc/terms/description","Private type index for this Pod").build(),n=setThing(createSolidDataset(),t);return await saveSolidDatasetAt(e,n,{fetch:this.fetchFn}),await this.linkTypeIndexToProfile(e,!1),console.log(`Private TypeIndex created and linked to profile: ${e}`),e}catch(t){throw console.error("Error creating private TypeIndex:",t),t}}async createPublicTypeIndex(){const e=this.joinWithPodBase("settings/publicTypeIndex.ttl");try{const t=buildThing(createThing({url:e})).addUrl("http://www.w3.org/1999/02/22-rdf-syntax-ns#type","http://www.w3.org/ns/solid/terms#TypeIndex").addStringNoLocale("http://xmlns.com/foaf/0.1/name","Public Type Index").addStringNoLocale("http://purl.org/dc/terms/description","Public type index for this Pod").build(),n=setThing(createSolidDataset(),t);return await saveSolidDatasetAt(e,n,{fetch:this.fetchFn}),await this.linkTypeIndexToProfile(e,!0),console.log(`Public TypeIndex created and linked to profile: ${e}`),e}catch(t){throw console.error("Error creating public TypeIndex:",t),t}}async linkTypeIndexToProfile(e,t){try{const n=await getSolidDataset(this.webId,{fetch:this.fetchFn}),s=getThing(n,this.webId);if(!s)throw new Error("Could not find profile in WebID document");const a=t?"http://www.w3.org/ns/solid/terms#publicTypeIndex":"http://www.w3.org/ns/solid/terms#privateTypeIndex",u=buildThing(s).addUrl(a,e).build(),c=setThing(n,u);await saveSolidDatasetAt(this.webId,c,{fetch:this.fetchFn}),console.log(`${t?"public":"private"} TypeIndex linked to profile: ${e}`)}catch(n){throw console.error("Error linking TypeIndex to profile:",n),n}}async registerType(e,t){let n=t;if(!n){const s=await this.findTypeIndexByVisibility(e.visibility==="public");if(!s)throw new Error("TypeIndex not found. Please create one first.");n=s}try{let s;try{s=await getSolidDataset(n,{fetch:this.fetchFn})}catch{s=createSolidDataset()}const a=e.instanceContainer||`${this.podUrl}${e.containerPath}`,u=`#${e.forClass.toLowerCase()}`,c=buildThing(createThing({url:`${n}${u}`})).addUrl("http://www.w3.org/1999/02/22-rdf-syntax-ns#type","http://www.w3.org/ns/solid/terms#TypeRegistration").addUrl("http://www.w3.org/ns/solid/terms#forClass",e.rdfClass).addUrl("http://www.w3.org/ns/solid/terms#instanceContainer",a).addStringNoLocale("http://xmlns.com/foaf/0.1/name",e.forClass).build();s=setThing(s,c),await saveSolidDatasetAt(n,s,{fetch:this.fetchFn});const h=e.visibility==="public"?"public":"private";console.log(`Type ${e.forClass} registered to ${h} TypeIndex: ${n}`)}catch(s){throw console.error("Error registering type:",s),s}}async findTypeIndexByVisibility(e){try{let t,n;try{console.log("Fetching WebID profile document for TypeIndex visibility check..."),t=await getSolidDataset(this.webId,{fetch:this.fetchFn}),t&&(n=getThing(t,this.webId))}catch(a){console.warn("Could not fetch WebID document for visibility check:",a)}if(n){const u=getUrl(n,e?"http://www.w3.org/ns/solid/terms#publicTypeIndex":"http://www.w3.org/ns/solid/terms#privateTypeIndex");if(u){const c=Array.isArray(u)?u[0]:u;return console.log(`Found ${e?"public":"private"} TypeIndex in profile: ${c}`),c}}const s=e?this.joinWithPodBase("settings/publicTypeIndex.ttl"):this.joinWithPodBase("settings/privateTypeIndex.ttl");try{return await getSolidDataset(s,{fetch:this.fetchFn}),console.log(`Found ${e?"public":"private"} TypeIndex at standard location: ${s}`),s}catch{return console.log(`No ${e?"public":"private"} TypeIndex found`),null}}catch(t){return console.error(`Error finding ${e?"public":"private"} TypeIndex:`,t),null}}joinWithPodBase(e){try{const t=this.getUserBaseUrl();return new URL(e,t).toString()}catch{return`${this.getUserBaseUrl()}${e}`.replace(/\/+$/,"")}}getUserBaseUrl(e){return resolvePodBase({webId:this.webId,podUrl:this.podUrl,storages:e})}extractStorages(e){try{return e?[...getUrlAll(e,"http://www.w3.org/ns/solid/terms#storage")||[],...getUrlAll(e,"http://www.w3.org/ns/pim/space#storage")||[]].filter(Boolean):[]}catch{return[]}}async discoverTypes(e){const t=e||await this.findTypeIndex();if(!t)return[];try{const n=await getSolidDataset(t,{fetch:this.fetchFn}),s=[],a=getThingAll(n);console.log(`[TypeIndex] Discovery on ${t} found ${a.length} things.`);for(const u of a)if(getUrl(u,"http://www.w3.org/1999/02/22-rdf-syntax-ns#type")==="http://www.w3.org/ns/solid/terms#TypeRegistration"){const h=getUrl(u,"http://www.w3.org/ns/solid/terms#forClass"),f=getUrl(u,"http://www.w3.org/ns/solid/terms#instanceContainer"),p=getStringNoLocale(u,"http://xmlns.com/foaf/0.1/name");if(h&&f){let g=f.replace(this.podUrl,"");g.endsWith("/")||(g+="/"),s.push({rdfClass:h,containerPath:g,forClass:p||this.deriveNameFromRdfClass(h),instanceContainer:f})}}return s}catch(n){return console.error("Error discovering types:",n),[]}}deriveNameFromRdfClass(e){try{const t=new URL(e);return t.hash?t.hash.slice(1):t.pathname.split("/").pop()||"Unknown"}catch{return"Unknown"}}async discoverSpecificType(e){try{const t=await this.findTypeIndex();if(t){const u=(await this.discoverTypes(t)).find(c=>c.rdfClass===e);if(u)return u}const s=(await this.discoverTypesFromProfile()).find(a=>a.rdfClass===e);return s||null}catch(t){return console.error(`Error discovering specific type ${e}:`,t),null}}async discoverSpecificTypes(e){const t=[];for(const n of e){const s=await this.discoverSpecificType(n);s&&t.push(s)}return t}async discoverTable(e){const t=await this.discoverSpecificType(e);if(!t)return null;const n=t.containerPath,s=this.inferColumnsFromRdfClass(e);return{name:t.forClass.toLowerCase(),columns:s,config:{containerPath:n,rdfClass:t.rdfClass}}}async discoverTables(e){const t=[];for(const n of e){const s=await this.discoverTable(n);s&&t.push(s)}return t}inferColumnsFromRdfClass(e){const t={id:{type:"int",primaryKey:!0}};return e.includes("schema.org/Person")?{...t,name:{type:"string",required:!0},email:{type:"string",required:!1}}:e.includes("schema.org/BlogPosting")?{...t,title:{type:"string",required:!0},content:{type:"string",required:!1},author:{type:"string",required:!1}}:e.includes("schema.org/Comment")?{...t,text:{type:"string",required:!0},author:{type:"string",required:!1}}:{...t,name:{type:"string",required:!0}}}async autoDiscoverAndRegister(e){const t=this.webId,n=e??this.webId;e&&e!==this.webId&&(this.webId=e);try{const s=await this.findTypeIndex();if(!s)return console.log("No TypeIndex found for user"),[];const a=await this.discoverTypes(s);return console.log(`Discovered ${a.length} types from TypeIndex for ${n}`),a}catch(s){return console.error("Error in auto discovery:",s),[]}finally{e&&e!==t&&(this.webId=t)}}async isTypeRegistered(e,t){return(await this.discoverTypes(t)).some(s=>s.rdfClass===e)}async discoverTypesFromProfile(){try{const e=await getSolidDataset(this.webId,{fetch:this.fetchFn}),t=getThing(e,this.webId);if(!t)throw new Error("Could not find profile in WebID document");const n=getUrl(t,"http://www.w3.org/ns/pim/space#storage"),s=[];if(n){const a=Array.isArray(n)?n[0]:n,u=await getSolidDataset(a,{fetch:this.fetchFn}),c=getThing(u,a);if(c){const h=getUrl(c,"http://www.w3.org/ns/ldp#contains");if(h){const f=Array.isArray(h)?h:[h];for(const p of f)try{const g=await getSolidDataset(p,{fetch:this.fetchFn}),y=getThing(g,p);if(y){const S=getStringNoLocale(y,"http://xmlns.com/foaf/0.1/name");if(S){const w=this.inferRdfClassFromContainerName(S);let R=p.replace(this.podUrl,"");R.endsWith("/")||(R+="/"),s.push({rdfClass:w,containerPath:R,forClass:this.capitalizeFirst(S),instanceContainer:p})}}}catch(g){console.warn(`Could not access container ${p}:`,g)}}}}return s}catch(e){return console.error("Error discovering types from profile:",e),[]}}inferRdfClassFromContainerName(e){const t=e.toLowerCase();return{people:"http://schema.org/Person",persons:"http://schema.org/Person",users:"http://schema.org/Person",posts:"http://schema.org/BlogPosting",articles:"http://schema.org/Article",events:"http://schema.org/Event",places:"http://schema.org/Place",organizations:"http://schema.org/Organization",products:"http://schema.org/Product",reviews:"http://schema.org/Review",comments:"http://schema.org/Comment",photos:"http://schema.org/ImageObject",images:"http://schema.org/ImageObject",documents:"http://schema.org/Document",files:"http://schema.org/MediaObject"}[t]||`https://example.com/vocab#${this.capitalizeFirst(e)}`}capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}}class PodServices{constructor(e){const t=e.runtime,n=t.getPodUrl(),s=t.getWebId(),a=t.getFetch();this.uriResolver=new UriResolverImpl(n),this.sparqlConverter=new ASTToSPARQLConverter(n,s,this.uriResolver),this.sparqlExecutor=new SolidSPARQLExecutor({sources:[n],fetch:a,logging:!1,createQueryEngine:e.createQueryEngine}),this.ldpExecutor=new LdpExecutor(this.sparqlExecutor,a,this.uriResolver),this.typeIndexManager=new TypeIndexManager(s,n,a);const u=new TypeIndexDiscovery(this.typeIndexManager,n,this.uriResolver);if(e.disableInteropDiscovery)this.discovery=new CompositeDiscovery([u]);else{const c=new InteropDiscovery(s,a,e.clientId);this.discovery=new CompositeDiscovery([u,c])}this.shapeManager=new DrizzleShapeManager(n,a),this.resolverFactory=new ResourceResolverFactoryImpl(n,this.uriResolver),this.strategyFactory=new ExecutionStrategyFactoryImpl({sparqlExecutor:this.sparqlExecutor,sparqlConverter:this.sparqlConverter,sessionFetch:a,podUrl:n,createQueryEngine:e.createQueryEngine,ldpExecutor:this.ldpExecutor,uriResolver:this.uriResolver,getResolver:c=>this.resolverFactory.getResolver(c),listContainerResources:e.listContainerResources,findSubjectsForCondition:e.findSubjectsForCondition})}getUriResolver(){return this.uriResolver}getSparqlConverter(){return this.sparqlConverter}getSparqlExecutor(){return this.sparqlExecutor}getLdpExecutor(){return this.ldpExecutor}getTypeIndexManager(){return this.typeIndexManager}getDiscovery(){return this.discovery}getShapeManager(){return this.shapeManager}getResolverFactory(){return this.resolverFactory}getStrategyFactory(){return this.strategyFactory}}var define_process_env_default={},_a;function isRecord$1(i){return typeof i=="object"&&i!==null}function hasStringValue(i){return isRecord$1(i)&&typeof i.value=="string"}class PodDialect{constructor(e){this.registeredTables=new Set,this.preparedContainers=new Set,this.preparedResources=new Set,this.shortIdSubjectIndex=new Map,this.currentTableRegistry=new Map,this.currentTableNameRegistry=new Map,this.config=e;const t=e.session;this.debugLogger=new DebugLogger(e.debug||typeof process<"u"&&define_process_env_default?.LINX_DEBUG==="1"),setGlobalDebugLogger(this.debugLogger),this.debugLogger.log("Initializing PodDialect with config:",{debug:e.debug,disableInteropDiscovery:e.disableInteropDiscovery,storageTTL:e.storageTTL});const n=t.info.webId,s=t.info.clientId||t.info.client_id||define_process_env_default.SOLID_CLIENT_ID;if(!n)throw new Error("Session中未找到webId");this.runtime=new PodRuntime({session:t,webId:n,podUrl:e.podUrl,storageTTL:e.storageTTL}),this.webId=this.runtime.getWebId(),this.podUrl=this.runtime.getPodUrl(),this.services=new PodServices({runtime:this.runtime,clientId:s,createQueryEngine:e.createQueryEngine,disableInteropDiscovery:e.disableInteropDiscovery,listContainerResources:a=>this.listContainerResources(a),findSubjectsForCondition:(a,u,c)=>this.findSubjectsForCondition(a,u,c)}),this.uriResolver=this.services.getUriResolver(),this.sparqlConverter=this.services.getSparqlConverter(),this.sparqlExecutor=this.services.getSparqlExecutor(),this.ldpExecutor=this.services.getLdpExecutor(),this.typeIndexManager=this.services.getTypeIndexManager(),this.discovery=this.services.getDiscovery(),this.shapeManager=this.services.getShapeManager(),this.resolverFactory=this.services.getResolverFactory(),this.strategyFactory=this.services.getStrategyFactory(),this.executor=new PodExecutor({ensureConnected:async()=>{this.runtime.isConnected()||await this.connect()},ensureTableResourcePath:a=>this.ensureTableResourcePath(a),resolveTableResource:a=>this.resolveTableResource(a),resolveTableUrls:a=>this.resolveTableUrls(a),normalizeResourceUrl:a=>this.normalizeResourceUrl(a),normalizeContainerKey:a=>this.normalizeContainerKey(a),normalizeResourceKey:a=>this.normalizeResourceKey(a),ensureContainerExists:a=>this.ensureContainerExists(a),ensureResourceExists:(a,u)=>this.ensureResourceExists(a,u),shouldSkipResourcePreparation:()=>this.shouldSkipResourcePreparation(),shouldUseWriteTimeResourcePreparation:()=>this.shouldUseWriteTimeResourcePreparation(),shouldContinueAfterResourcePreparationError:()=>this.shouldContinueAfterResourcePreparationError(),getTableRegistries:()=>({tableRegistry:this.currentTableRegistry,tableNameRegistry:this.currentTableNameRegistry}),ensureIdentifierCondition:(a,u,c)=>this.ensureIdentifierCondition(a,u,c),resourceExists:a=>this.resourceExists(a),getStrategy:a=>this.getStrategy(a),getLdpStrategy:()=>this.strategyFactory.getLdpStrategy(),preparedContainers:this.preparedContainers,preparedResources:this.preparedResources,sparqlConverter:this.sparqlConverter,sparqlExecutor:this.sparqlExecutor,isSelectPlan:a=>this.isSelectPlan(a),isInsertPlan:a=>this.isInsertPlan(a),isUpdatePlan:a=>this.isUpdatePlan(a),isDeletePlan:a=>this.isDeletePlan(a)})}getResolver(e){return this.resolverFactory.getResolver(e)}buildShortIdSubjectIndexKey(e,t){const n=e.config?.base??e.getResourcePath?.()??e.getContainerPath?.()??"",s=e.getSubjectTemplate?.()??e.config?.subjectTemplate??"<exact-id>",a=e.getType?.()??e.config?.type??"";return`${e.config?.name??""}|${n}|${s}|${a}|${t}`}registerResourceSubject(e,t){const n=parsePodResourceRef(e,t)?.templateValues.id;if(!n)return;const s=this.buildShortIdSubjectIndexKey(e,n),a=this.shortIdSubjectIndex.get(s)??new Set;a.add(t),this.shortIdSubjectIndex.set(s,a)}unregisterResourceSubject(e,t){const n=parsePodResourceRef(e,t)?.templateValues.id;if(!n)return;const s=this.buildShortIdSubjectIndexKey(e,n),a=this.shortIdSubjectIndex.get(s);a&&(a.delete(t),a.size===0&&this.shortIdSubjectIndex.delete(s))}lookupIndexedResourceSubject(e,t){const n=this.shortIdSubjectIndex.get(this.buildShortIdSubjectIndexKey(e,t));if(!n||n.size===0)return null;if(n.size>1)throw new Error(`Indexed short id '${t}' for resource '${e.config?.name??"resource"}' is ambiguous. Use a base-relative resource id or full IRI to disambiguate.`);return Array.from(n)[0]??null}getStrategy(e){return this.strategyFactory.getStrategy(e)}getShapeManager(){return this.services.getShapeManager()}getUriResolver(){return this.services.getUriResolver()}getDiscovery(){return this.services.getDiscovery()}setSchema(e){const t=new Map,n=new Map;for(const[s,a]of Object.entries(e))if(a&&typeof a=="object"&&"config"in a){const u=a,c=u.getType?.()||u.config?.type,h=u.config?.name||s;if(n.set(h,u),c){const f=t.get(c)||[];f.push(u),t.set(c,f)}}this.currentTableRegistry=t,this.currentTableNameRegistry=n,this.refreshBaseUrlFromRuntime()}refreshBaseUrlFromRuntime(){const e=this.runtime.getPodUrl();e&&(this.podUrl!==e&&(this.podUrl=e,this.preparedContainers.clear(),this.preparedResources.clear()),this.uriResolver.setPodUrl(this.podUrl),this.resolverFactory.setPodBaseUrl(this.podUrl),this.strategyFactory.setPodUrl(this.podUrl),this.typeIndexManager.updateConfig({...this.typeIndexManager.getConfig(),podUrl:this.podUrl}),this.ldpExecutor.setBaseUri(this.podUrl),(this.currentTableRegistry.size>0||this.currentTableNameRegistry.size>0)&&(this.ldpExecutor.setTableRegistry(this.currentTableRegistry,this.currentTableNameRegistry),this.sparqlConverter.setTableRegistry(this.currentTableRegistry,this.currentTableNameRegistry,this.podUrl)))}async findSubjectsForCondition(e,t,n){const s=this.buildSubjectLookupPlan(t,e),a=this.sparqlConverter.convertSelectPlan(s),u=this.normalizeResourceUrl(n);return(await this.executeOnResource(u,a)).map(h=>this.extractSubjectFromRow(h)).filter(h=>!!h)}async connect(){await this.runtime.connect(),this.refreshBaseUrlFromRuntime()}async disconnect(){await this.runtime.disconnect()}isConnected(){return this.runtime.isConnected()}extractUserPathFromWebId(){if(!this.webId)return"";try{const t=new URL(this.webId).pathname.split("/");if(t.length>=2)return`/${t[1]}/`}catch(e){console.warn("Failed to parse webId:",this.webId,e)}return""}resolveTableResource(e){const t=e.getSparqlEndpoint?.();if(t)return{mode:"sparql",endpoint:this.isAbsoluteUrl(t)?t:this.resolveAbsoluteUrl(t)};const{containerUrl:n,resourceUrl:s}=this.resolveLdpResource(e);return{mode:"ldp",containerUrl:n,resourceUrl:s}}resolveTableUrls(e){return this.resolveLdpResource(e)}resolveLdpResource(e){const t=typeof e.getResourcePath=="function"?e.getResourcePath():void 0;if(t){const T=this.resolveAbsoluteUrl(t);if(t.endsWith("/")){const O=T.endsWith("/")?T:`${T}/`;return{containerUrl:O,resourceUrl:O}}const F=this.normalizeResourceUrl(T),x=F.lastIndexOf("/");return{containerUrl:x>=0?`${F.slice(0,x+1)}`:`${F}/`,resourceUrl:F}}const n=e.getContainerPath()||"/data/",s=n.startsWith("http://")||n.startsWith("https://"),a=T=>T.endsWith("/")?T:`${T}/`;if(s){if(n.endsWith("/")){const x=a(n);return{containerUrl:x,resourceUrl:`${x}${e.config.name}.ttl`}}const T=n,A=T.lastIndexOf("/");if(A===-1)throw new Error(`Invalid containerPath for table ${e.config.name}: ${n}`);return{containerUrl:a(T.slice(0,A+1)),resourceUrl:T}}const u=this.extractUserPathFromWebId(),c=n.replace(/^\/+/,""),h=this.podUrl.endsWith("/")?this.podUrl:`${this.podUrl}/`,f=u.replace(/^\/+/,""),p=f&&c.startsWith(f);if(n.endsWith("/")){const T=p?c:`${f}${c}`,A=a(`${h}${T.replace(/^\/+/,"")}`);return{containerUrl:A,resourceUrl:`${A}${e.config.name}.ttl`}}const g=p?c:`${f}${c}`,y=g.lastIndexOf("/"),S=y>=0?g.slice(0,y+1):f,w=a(`${h}${S.replace(/^\/+/,"")}`),R=`${h}${g.replace(/^\/+/,"")}`;return{containerUrl:w,resourceUrl:R}}async resourceExists(e){const t=this.normalizeResourceUrl(e);if(this.preparedResources.has(t))return!0;try{const n=await this.runtime.getFetch()(t,{method:"HEAD"});return n.ok||n.status===409?(this.markResourcePrepared(t),!0):n.status===404?!1:n.status===405?(await this.runtime.getFetch()(t,{method:"GET",headers:{Accept:"text/turtle"}})).ok?(this.markResourcePrepared(t),!0):!1:n.status===401||n.status===403?(this.markResourcePrepared(t),!0):n.ok}catch(n){this.debugLogger.warn("[PodDialect] Failed to check resource existence via HEAD, falling back to GET",n);try{return(await this.runtime.getFetch()(t,{method:"GET",headers:{Accept:"text/turtle"}})).ok?(this.markResourcePrepared(t),!0):!1}catch(s){return this.debugLogger.warn("[PodDialect] Resource existence fallback GET failed",s),!1}}}normalizeResourceUrl(e){if(!e)return e;let t=e;for(;t.endsWith("/")&&!t.endsWith("://");)t=t.slice(0,-1);return t}normalizeContainerKey(e){const t=e.startsWith("http")?e:this.resolveAbsoluteUrl(e);return t.endsWith("/")?t:`${t}/`}normalizeResourceKey(e){const t=e.startsWith("http")?e:this.resolveAbsoluteUrl(e);return this.normalizeResourceUrl(t)}isStorageRootContainer(e){const t=this.runtime.getStorageUrl()??this.runtime.getPodUrl();return this.normalizeContainerKey(e)===this.normalizeContainerKey(t)}markContainerPrepared(e){this.preparedContainers.add(this.normalizeContainerKey(e))}markResourcePrepared(e){this.preparedResources.add(this.normalizeResourceKey(e))}isAbsoluteUrl(e){return/^https?:\/\//i.test(e)}resolveAbsoluteUrl(e){if(!e)return this.podUrl.replace(/\/$/,"");if(this.isAbsoluteUrl(e))return e;const t=e.replace(/^(\.\/)+/,""),n=this.podUrl.endsWith("/")?this.podUrl:`${this.podUrl}/`,s=t.endsWith("/"),u=this.extractUserPathFromWebId().replace(/^\/+|\/+$/g,"");let h=t.replace(/^\/+/,"");const f=u.length>0?`${u}/`:"";if(u.length>0){let g=!1;try{g=new URL(n).pathname.replace(/^\/+|\/+$/g,"").startsWith(u)}catch{g=!1}!g&&(h.length===0||h!==u&&!h.startsWith(f))&&(h=h.length>0?`${u}/${h}`:u)}s&&!h.endsWith("/")&&(h=`${h}/`);const p=new URL(h,n).toString();return!s&&p.endsWith("/")?p.replace(/\/$/,""):p}async ensureResourceExists(e,t={}){const{createIfMissing:n=!0}=t,s=this.normalizeResourceUrl(e);if(this.preparedResources.has(s))return;if(await this.resourceExists(s)){this.markResourcePrepared(s);return}if(!n)throw new Error(`Resource not found: ${s}`);for(let u=0;u<3;u++)try{const c=await this.runtime.getFetch()(s,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:""});if(c.ok||[201,202,204,409].includes(c.status)){await this.sparqlExecutor.invalidateHttpCache(s),this.markResourcePrepared(s);return}if(c.status>=500){this.debugLogger.warn(`[PodDialect] ensureResourceExists attempt ${u+1}/3 failed with ${c.status}, retrying...`),await new Promise(f=>setTimeout(f,1e3));continue}const h=await this.readErrorResponseBody(c);throw new Error(this.formatResourcePreparationError("Failed to create resource",c.status,c.statusText,s,h))}catch(c){if(u===2)throw this.debugLogger.error("[PodDialect] ensureResourceExists failed after 3 attempts:",c),c;this.debugLogger.warn(`[PodDialect] ensureResourceExists attempt ${u+1}/3 failed with error:`,c),await new Promise(h=>setTimeout(h,1e3))}}async executeOnResource(e,t,n){const s=this.normalizeResourceUrl(e);if(n?.mode==="sparql")return await this.executeOnSparqlEndpoint(n.endpoint,t);if(t.type==="SELECT"||t.type==="ASK")return await this.sparqlExecutor.queryContainer(s,t);throw new Error("LDP mode does not support SPARQL UPDATE; use N3 patch helpers instead.")}getFetchForEndpoint(e){return getFetchForOrigin(e,this.podUrl,this.runtime.getFetch())}async executeOnSparqlEndpoint(e,t){const n=this.getFetchForEndpoint(e);if(t.type==="SELECT"||t.type==="ASK")return isSameOrigin(e,this.podUrl)?await this.sparqlExecutor.executeQueryWithSource(t,e,"sparql"):await new ComunicaSPARQLExecutor({sources:[e],fetch,logging:!1,createQueryEngine:this.config.createQueryEngine}).executeQueryWithSource(t,e,"sparql");const s=await n(e,{method:"POST",headers:{"Content-Type":"application/sparql-update"},body:t.query});if(!s.ok){const a=await s.text().catch(()=>"");throw new Error(`SPARQL endpoint update failed: ${s.status} ${s.statusText}${a?` - ${a}`:""}`)}return[{success:!0,source:e,status:s.status,via:"sparql-endpoint"}]}async ensureTableResourcePath(e){const t=typeof e.config.type=="string"?e.config.type:String(e.config.type),n=e.getResourcePath?.();if(!e.config.typeIndex){if(n&&n.trim().length>0)return;console.log(`[AutoDiscover] Table ${e.config.name} has no resourcePath, using default container path`),e.config.containerPath="/data/";return}console.log(`[AutoDiscover] Table ${e.config.name} has typeIndex enabled, discovering from TypeIndex/SAI...`);try{const a=(await this.discovery.discover(t))[0];if(a){let u=a.container;u.endsWith("/")||(u+="/"),a.subjectTemplate&&(e.setSubjectTemplate(a.subjectTemplate),console.log(`[AutoDiscover] ✓ Applied subjectTemplate from discovery: ${a.subjectTemplate}`));const c=this.uriResolver.getResourceMode(e);let h;c==="document"?h=u:h=`${u}${e.config.name}.ttl`,console.log(`[AutoDiscover] ✓ Found resource path from TypeIndex: ${h} (mode: ${c})`),e.setBase(h),await this.tryDiscoverSparqlEndpoint(e,u)}else{if(n&&n.trim().length>0){console.log(`[AutoDiscover] No discovery result, using configured path: ${n}`);return}throw new Error(`[AutoDiscover] No data location found for type ${t}. Please ensure the data is registered in TypeIndex or SAI Registry.`)}}catch(s){if(n&&n.trim().length>0){console.warn("[AutoDiscover] Discovery process failed, using configured path:",n);return}throw console.warn("[AutoDiscover] Discovery process failed:",s),s}}async tryDiscoverSparqlEndpoint(e,t){if(e.getSparqlEndpoint())return;const n=`${t.replace(/\/$/,"")}/-/sparql`;try{(await this.runtime.getFetch()(n,{method:"OPTIONS"})).ok&&(console.log(`[AutoDiscover] ✓ Found SPARQL endpoint: ${n}`),e.setSparqlEndpoint(n))}catch{}}async query(e){return this.executor.query(e)}collectSelectSources(e){const t=new Set,{resourceUrl:n}=this.resolveTableUrls(e.baseTable);if(t.add(n),e.joins)for(const s of e.joins){const{resourceUrl:a}=this.resolveTableUrls(s.table);t.add(a)}return Array.from(t)}buildIdInConditionFromSubjects(e){if(!(!e||e.length===0))return new BinaryExpression("@id","IN",e)}isInsertPlan(e){return!!(e&&typeof e.table<"u"&&Array.isArray(e.rows))}isUpdatePlan(e){return!!(e&&typeof e.table<"u"&&"data"in e)}isDeletePlan(e){if(!e)return!1;const t=e;return typeof t.table>"u"?!1:typeof t.rows>"u"&&typeof t.data>"u"}isSelectPlan(e){return e?typeof e.baseTable<"u":!1}buildSubjectLookupPlan(e,t){const n=e.config.name??"table";return{baseTable:e,baseAlias:n,selectAll:!0,conditionTree:t,aliasToTable:new Map([[n,e]]),tableToAlias:new Map([[e,n]])}}isQueryConditionNode(e){return e instanceof BinaryExpression||e instanceof LogicalExpression||e instanceof UnaryExpression}extractSubjectFromRow(e){const t=e.subject??e["?subject"];return t?typeof t=="string"?t:hasStringValue(t)?t.value:null:null}conditionTargetsIdentifier(e){if(!e)return!1;if(e.type==="binary_expr"){const t=e.left,n=typeof t=="string"?t:t instanceof PodColumnBase?t.name:void 0;if(n==="@id"||n==="id")return!0}if(e.type==="logical_expr"){const t=e.expressions;if(Array.isArray(t))return t.some(n=>this.isQueryConditionNode(n)&&this.conditionTargetsIdentifier(n))}if(e.type==="unary_expr"){const t=e.value;if(t&&typeof t=="object"&&"type"in t)return this.conditionTargetsIdentifier(t)}return!1}async rewriteIdentifierConditionWithSubjects(e,t){const n=this.getResolver(t);try{const s=await n.resolveSubjectsForMutation(t,e,async()=>[],async()=>[]);return this.buildIdInConditionFromSubjects(s)}catch(s){const a=t.getSubjectTemplate?.()??t.config?.subjectTemplate??"<exact-id>";throw(s instanceof Error?s.message:String(s)).includes("missing required variable")?new Error(`Cannot resolve mutation target for table "${t.config.name??"unknown"}" with subjectTemplate "${a}" from where() alone. Use an explicit @id via db.updateByIri()/db.deleteByIri() (or the internal whereByIri()).`):s}}async ensureIdentifierCondition(e,t,n){if(e)return this.conditionTargetsIdentifier(e)?await this.rewriteIdentifierConditionWithSubjects(e,t):await this.rewriteWhereConditionWithSubjects(e,t,n)}async rewriteWhereConditionWithSubjects(e,t,n){if(!e)return;const s=await this.findSubjectsForCondition(e,t,n);return this.buildIdInConditionFromSubjects(s)}async executeSql(e,t){const n=e.queryChunks.join("");let s;if(n.toLowerCase().includes("select"))s="select";else if(n.toLowerCase().includes("insert"))s="insert";else if(n.toLowerCase().includes("update"))s="update";else if(n.toLowerCase().includes("delete"))s="delete";else throw new Error(`Unsupported SQL operation: ${n}`);const a={type:s,table:t,sql:e,values:e.params||[]};return this.query(a)}addNamespace(e,t){this.sparqlConverter.addPrefix(e,t)}getConfig(){return{podUrl:this.podUrl,webId:this.webId,connected:this.runtime.isConnected()}}getAuthenticatedFetch(){return this.runtime.getFetch()}getSPARQLConverter(){return this.sparqlConverter}getSPARQLExecutor(){return this.sparqlExecutor}getPodUrl(){return this.runtime.getPodUrl()}getWebId(){return this.runtime.getWebId()}async discoverDataLocations(e,t){return this.discovery.discover(e,t)}async discoverAll(){return this.discovery.discoverAll?this.discovery.discoverAll():[]}async discoverByApp(e){return this.discovery.discoverByApp?this.discovery.discoverByApp(e):[]}addSource(e){this.sparqlExecutor.addSource(e)}removeSource(e){this.sparqlExecutor.removeSource(e)}getSources(){return this.sparqlExecutor.getSources()}async addSourcesFromTypeIndex(){try{const e=await this.typeIndexManager.discoverTypes();for(const t of e)if(t.instanceContainer)this.sparqlExecutor.addSource(t.instanceContainer);else if(t.containerPath){const n=t.containerPath.startsWith("http")?t.containerPath:`${this.podUrl}${t.containerPath}`;this.sparqlExecutor.addSource(n)}console.log(`✅ 从 TypeIndex 自动添加了 ${e.length} 个数据源`)}catch(e){console.warn("⚠️ 无法从 TypeIndex 自动添加数据源:",e)}}async queryContainer(e,t,n){const s=this.sparqlConverter.parseDrizzleAST(t,n),a=this.sparqlConverter.convertSelect(s,n),u=n?.config?.containerPath||e;return this.sparqlExecutor.queryContainer(u,a)}async getPodMetadata(){if(!this.runtime.isConnected())throw new Error("Not connected to Pod");return{podUrl:this.podUrl,webId:this.webId,connected:this.runtime.isConnected(),sources:this.sparqlExecutor.getSources()}}stripSPARQLProlog(e){return e.replace(/^\s*#.*$/gm,"").trim().replace(/^(?:\s*(?:PREFIX|BASE)\s+[^\n]+\n)*/i,"").trim()}looksLikeRawSQL(e){const t=this.stripSPARQLProlog(e);return!!(/^SELECT\b[\s\S]*\bFROM\b\s+(?!<|[?$])/i.test(t)&&!/\{/m.test(t)||/^INSERT\s+INTO\b/i.test(t)||/^UPDATE\s+[A-Za-z_`"][\w$`"]*\s+SET\b/i.test(t)||/^DELETE\s+FROM\b/i.test(t))}inferSPARQLQueryType(e){const n=this.stripSPARQLProlog(e).match(/^(SELECT|ASK|INSERT|DELETE|UPDATE|WITH|LOAD|CLEAR|CREATE|DROP|COPY|MOVE|ADD|CONSTRUCT|DESCRIBE)\b/i)?.[1]?.toUpperCase();switch(n){case"SELECT":case"ASK":case"INSERT":case"DELETE":case"UPDATE":return n;case"WITH":case"LOAD":case"CLEAR":case"CREATE":case"DROP":case"COPY":case"MOVE":case"ADD":return"UPDATE";default:return}}async executeSPARQL(e){if(!this.runtime.isConnected())throw new Error("Not connected to Pod");if(this.looksLikeRawSQL(e))throw new Error("executeSPARQL only accepts SPARQL text; raw SQL is not supported in Solid dialect");const t=this.inferSPARQLQueryType(e);if(!t)throw new Error("Unsupported SPARQL query type. Supported types: SELECT, ASK, INSERT, DELETE, UPDATE");const n={type:t,query:e,prefixes:{}};return this.sparqlExecutor.executeQuery(n)}async transaction(e){console.log("Starting transaction");try{const t=await e(this);return console.log("Transaction completed successfully"),t}catch(t){throw console.error("Transaction failed:",t),t}}getResourcePreparationMode(){return this.config.resourcePreparation??"best-effort"}shouldSkipResourcePreparation(){return this.getResourcePreparationMode()==="off"}shouldUseWriteTimeResourcePreparation(){const e=this.getResourcePreparationMode();return e==="best-effort"||e==="off"}shouldContinueAfterResourcePreparationError(){return this.getResourcePreparationMode()==="best-effort"}async registerTable(e){if(this.shouldSkipResourcePreparation()){e.markInitialized?.(!0);return}if(e.config.autoRegister===!1){e.markInitialized?.(!0);return}const t=e.config.name??JSON.stringify(e.config);if(this.registeredTables.has(t)){e.markInitialized?.(!0);return}try{const n=this.resolveTableResource(e);if(n.mode!=="sparql")if(this.shouldUseWriteTimeResourcePreparation())try{e.setBase?.(n.resourceUrl)}catch(s){this.debugLogger.warn(`[registerTable] setBase failed for ${e.config.name}:`,s)}else{await this.ensureContainerExists(n.containerUrl);try{await this.ensureResourceExists(n.resourceUrl,{createIfMissing:!0}),this.markResourcePrepared(n.resourceUrl)}catch(s){this.debugLogger.warn(`[registerTable] ensureResourceExists failed for ${n.resourceUrl}:`,s)}this.markContainerPrepared(n.containerUrl);try{e.setBase?.(n.resourceUrl)}catch(s){this.debugLogger.warn(`[registerTable] setBase failed for ${e.config.name}:`,s)}}}catch(n){if(this.debugLogger.warn(`[registerTable] Resource preparation failed for ${e.config.name}:`,n),this.config.resourcePreparation==="strict")throw n}this.registeredTables.add(t),this.shouldUseWriteTimeResourcePreparation()||await this.discovery.register(e,{registryPath:e.config.saiRegistryPath}),e.markInitialized?.(!0)}async findTypeIndex(){return this.typeIndexManager.findTypeIndex()}async createTypeIndex(){return this.typeIndexManager.createTypeIndex()}async discoverTypes(e){return this.typeIndexManager.discoverTypes(e)}async autoDiscoverAndRegister(e){return this.typeIndexManager.autoDiscoverAndRegister(e)}async discoverTypesFromProfile(){return this.typeIndexManager.discoverTypesFromProfile()}async discoverSpecificType(e){return this.typeIndexManager.discoverSpecificType(e)}async discoverSpecificTypes(e){return this.typeIndexManager.discoverSpecificTypes(e)}async discoverTable(e){return this.typeIndexManager.discoverTable(e)}async discoverTables(e){return this.typeIndexManager.discoverTables(e)}async isTypeRegistered(e,t){return this.typeIndexManager.isTypeRegistered(e,t)}getTypeIndexManager(){return this.typeIndexManager}async ensureContainerExists(e){try{const t=this.normalizeContainerKey(e);if(this.preparedContainers.has(t))return;if(this.isStorageRootContainer(t)){this.markContainerPrepared(t);return}const n=await this.runtime.getFetch()(t,{method:"HEAD"});if(n.status===401||n.status===403){this.debugLogger.log(`[Container] ${t} 不允许 HEAD,视为已存在`),this.markContainerPrepared(t);return}if(n.status===404||n.status===500){const s=this.getParentContainer(t);s&&s!==t&&(this.debugLogger.log(`[Container] 先创建父容器: ${s}`),await this.ensureContainerExists(s)),this.debugLogger.log(`[Container] 创建容器: ${t}`);const a=await this.createContainerWithRetry(t);if(a.ok)this.debugLogger.log(`[Container] 容器创建成功: ${a.status}`),await this.sparqlExecutor.invalidateHttpCache(t),this.markContainerPrepared(t);else if(a.status===409)this.debugLogger.log(`[Container] 容器已存在(409冲突): ${t}`),this.markContainerPrepared(t);else{const u=await this.readErrorResponseBody(a);throw new Error(this.formatResourcePreparationError("Failed to create container",a.status,a.statusText,t,u))}}else if(n.status===200)this.debugLogger.log(`[Container] 容器已存在: ${t}`),this.markContainerPrepared(t);else if(n.status===409)this.debugLogger.log(`[Container] 容器已存在(409冲突): ${t}`),this.markContainerPrepared(t);else if(!n.ok)throw new Error(this.formatResourcePreparationError("Failed to check container",n.status,n.statusText,t))}catch(t){throw this.debugLogger.error("[Container] 确保容器存在时出错:",t),t}}async createContainerWithRetry(e){let t=null;for(let n=0;n<3;n+=1){const s=await this.runtime.getFetch()(e,{method:"PUT",headers:{"Content-Type":"text/turtle",Link:'<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"'}});if(t=s,s.ok||s.status===409||s.status<500)return s;this.debugLogger.warn(`[Container] 创建容器失败 ${n+1}/3: ${s.status} ${s.statusText} (${e})`),n<2&&await this.sleep(250*(n+1))}return t}async sleep(e){await new Promise(t=>setTimeout(t,e))}async readErrorResponseBody(e){const t=e;if(typeof t.text!="function")return"";try{return(await t.text()).trim().slice(0,1e3)}catch{return""}}formatResourcePreparationError(e,t,n,s,a=""){const u=a?` - ${a}`:"";return`${e}: ${t} ${n} (${s})${u}`}getParentContainer(e){try{const t=new URL(e),n=t.pathname.split("/").filter(s=>s.length>0);return n.length<=1?null:(n.pop(),t.pathname="/"+n.join("/")+"/",t.toString())}catch(t){return this.debugLogger.error("[Container] 解析父容器 URL 失败:",t),null}}async listContainerResources(e){const t=this.normalizeContainerKey(e),n=[];try{const s={type:"SELECT",query:`
301
+ PREFIX ldp: <http://www.w3.org/ns/ldp#>
302
+ SELECT ?resource WHERE {
303
+ <${t}> ldp:contains ?resource .
304
+ }
305
+ `,prefixes:{ldp:"http://www.w3.org/ns/ldp#"}},a=await this.sparqlExecutor.queryContainer(t,s);for(const u of a){const c=u.resource;if(c){const h=hasStringValue(c)?c.value:String(c);n.push(h)}}}catch(s){console.warn("[listContainerResources] SPARQL query failed:",s)}return n}}_a=entityKind;PodDialect[_a]="PodDialect";function drizzle(i,e){if(!i||!i.info.isLoggedIn)throw new Error("需要有效的已认证Session");const t={session:i,preferredChannels:e?.notifications?.preferredChannels,createQueryEngine:e?.sparql?.createQueryEngine,disableInteropDiscovery:e?.disableInteropDiscovery,podUrl:e?.podUrl??i.info.podUrl,resourcePreparation:e?.resourcePreparation,storageTTL:e?.storageTTL,debug:e?.debug??e?.logger},n=new PodDialect(t);e?.schema&&n.setSchema(e.schema);const s=new PodAsyncSession(n);return new PodDatabase(n,s,e?.schema)}const SOLID_STORAGE_KEYS=new Set(["solid:storage","http://www.w3.org/ns/solid/terms#storage","pim:storage","http://www.w3.org/ns/pim/space#storage"]);async function fetchProfileStorageUrls(i,e){const t=await i(e,{headers:{Accept:"text/turtle, application/ld+json, application/json"},credentials:"include"}).catch(()=>{});if(!t?.ok)return[];const n=t.headers?.get?.("content-type")??"",s=await t.text().catch(()=>"");if(!s)return[];if(n.includes("json"))try{return uniqueNormalizedStorageUrls(extractStorageUrlsFromJson(JSON.parse(s)))}catch{return[]}return uniqueNormalizedStorageUrls(extractStorageUrlsFromTurtle(s))}function extractStorageUrlsFromTurtle(i){return Array.from(i.matchAll(/(?:solid:storage|pim:storage|<http:\/\/www\.w3\.org\/ns\/solid\/terms#storage>|<http:\/\/www\.w3\.org\/ns\/pim\/space#storage>)\s+<([^>]+)>/giu)).map(e=>e[1]).filter(e=>typeof e=="string"&&e.length>0)}function extractStorageUrlsFromJson(i){const e=new Set,t=new WeakSet,n=(s,a=!1)=>{if(typeof s=="string"){a&&e.add(s);return}if(!(!s||typeof s!="object")&&!t.has(s)){if(t.add(s),Array.isArray(s)){for(const u of s)n(u,a);return}for(const[u,c]of Object.entries(s)){const h=SOLID_STORAGE_KEYS.has(u);if(a&&u==="@id"){n(c,!0);continue}n(c,a||h)}}};return n(i),Array.from(e)}function normalizeStorageUrl(i){try{return ensureTrailingSlash(new URL(i).toString())}catch{return}}function uniqueNormalizedStorageUrls(i){const e=new Set;for(const t of i){const n=normalizeStorageUrl(t);n&&e.add(n)}return Array.from(e)}function ensureTrailingSlash(i){return i.replace(/\/+$/u,"")+"/"}const XPOD_LAST_OIDC_ISSUER_STORAGE_KEY="xpod.solid.lastOidcIssuer",XpodSolidRuntimeContext=reactExports.createContext(null),initializedRuntimes=new WeakSet;function snapshotToState(i,e,t){return i.status==="initializing"?{status:"loading",issuer:t}:i.status==="anonymous"?{status:"anonymous",issuer:t}:i.status==="error"?{status:"error",webId:i.webId,error:i.error,podUrl:e?.podUrl,issuer:t}:{status:"authenticated",webId:i.webId,podUrl:e?.podUrl,issuer:t}}async function discoverPodUrlFromWebId({webId:i,fetch:e}){const n=(await fetchProfileStorageUrls(e,i))[0];if(!n)throw new Error("WebID profile does not declare a Solid storage URL");return ensureTrailingSlash(new URL(n).toString())}function createXpodSolidRuntimeValue(i={}){const e=i.sessionFactory?.()??new Session;let t=readIssuerFromSessionInfo(e.info)??readStoredOidcIssuer();const n=createSolidSessionRuntime({session:e}),s={get info(){return e.info},fetch:e.fetch},a=createPodRuntime({adapter:{discoverPod:({webId:u,fetch:c})=>discoverPodUrlFromWebId({webId:u,fetch:c}),openDatabase:({podUrl:u})=>drizzle(s,{podUrl:u,resourcePreparation:"off"}),hydrateCollections:()=>{}}});return{session:n,pod:a,getIssuer:()=>readIssuerFromSessionInfo(e.info)??t??readStoredOidcIssuer(),setIssuer:u=>{const c=normalizeXpodOidcIssuer(u);t=c,c&&writeStoredOidcIssuer(c)}}}let defaultRuntime;function getXpodSolidRuntimeValue(){return defaultRuntime??=createXpodSolidRuntimeValue(),defaultRuntime}function safeAuthError(i){return i.message==="Solid session expired"?i:new Error("Solid login failed. Please reconnect your Pod.")}function useXpodSolidRuntimeContext(){const i=reactExports.useContext(XpodSolidRuntimeContext);if(!i)throw new Error("useXpodSolidRuntime must be used within XpodSolidRuntimeProvider");return i}function readIssuerFromSessionInfo(i){const e=i.issuer??i.oidcIssuer;return normalizeXpodOidcIssuer(e)}function normalizeXpodOidcIssuer(i){if(!(typeof i!="string"||!i.trim()))try{const e=new URL(i.trim());return e.protocol!=="https:"&&e.protocol!=="http:"||e.username||e.password||e.search||e.hash?void 0:e.toString()}catch{return}}function readStoredOidcIssuer(){try{return normalizeXpodOidcIssuer(globalThis.window?.sessionStorage.getItem(XPOD_LAST_OIDC_ISSUER_STORAGE_KEY))}catch{return}}function writeStoredOidcIssuer(i){try{globalThis.window?.sessionStorage.setItem(XPOD_LAST_OIDC_ISSUER_STORAGE_KEY,i)}catch{}}const useXpodSolidRuntime=useXpodSolidRuntimeContext;function SettingsAuthBoundary({children:i,product:e="Settings"}){const t=useXpodSolidRuntime(),n=t.state.status==="loading"?{status:"loading"}:t.state.status==="authenticated"?{status:"authenticated"}:t.state.status==="error"?{status:"error",message:t.state.error.message}:{status:"anonymous"};return jsxRuntimeExports.jsx(AuthBoundary,{state:n,login:t.login,loginView:{title:`Connect Xpod ${e}`,description:e==="Dashboard"?"Use your Solid identity to inspect Xpod status, runtime, logs, RDF, network, and usage.":"Use your Solid identity to manage model, Pod, network, and service settings.",defaultIssuer:window.location.origin},children:i})}const ModelsPage=reactExports.lazy(()=>__vitePreload(()=>import("./ModelsPage-D_IH7AH3.js"),__vite__mapDeps([0,1,2]))),PodPage=reactExports.lazy(()=>__vitePreload(()=>import("./PodPage-Cy1VNObw.js"),__vite__mapDeps([3,4,2,1]))),ServicesPage=reactExports.lazy(()=>__vitePreload(()=>import("./ServicesPage-BsFaxVWC.js"),__vite__mapDeps([5,6,4,2]))),SettingsPage=reactExports.lazy(()=>__vitePreload(()=>import("./SettingsPage-UafNWE_p.js"),__vite__mapDeps([7,6])).then(i=>({default:i.SettingsPage})));function lazyRoute(i){return jsxRuntimeExports.jsx(reactExports.Suspense,{fallback:jsxRuntimeExports.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"Loading settings..."}),children:i})}function guardedRoute(i){return jsxRuntimeExports.jsx(SettingsAuthBoundary,{children:i})}const settingsRoutes=[{element:jsxRuntimeExports.jsx(XpodSettingsLayout,{}),children:[{index:!0,element:jsxRuntimeExports.jsx(Navigate,{to:"/models",replace:!0})},{path:"models",element:guardedRoute(lazyRoute(jsxRuntimeExports.jsx(ModelsPage,{})))},{path:"pod",element:guardedRoute(lazyRoute(jsxRuntimeExports.jsx(PodPage,{view:"settings"})))},{path:"network",element:guardedRoute(lazyRoute(jsxRuntimeExports.jsx(ServicesPage,{product:"settings"}))),children:[{index:!0,element:lazyRoute(jsxRuntimeExports.jsx(SettingsPage,{}))}]},{path:"services",element:guardedRoute(lazyRoute(jsxRuntimeExports.jsx(ServicesPage,{product:"settings"}))),children:[{index:!0,element:lazyRoute(jsxRuntimeExports.jsx(SettingsPage,{}))},{path:"configuration",element:lazyRoute(jsxRuntimeExports.jsx(SettingsPage,{}))}]},{path:"*",element:jsxRuntimeExports.jsx(Navigate,{to:"/models",replace:!0})}]}];function XpodSolidRuntimeProvider({children:i,value:e}){const t=e??getXpodSolidRuntimeValue(),[n,s]=reactExports.useState(()=>t.session.getSnapshot()),[a,u]=reactExports.useState(()=>t.getIssuer()),[c,h]=reactExports.useState(),[f,p]=reactExports.useState(),[g,y]=reactExports.useState();reactExports.useEffect(()=>t.session.subscribe(R=>{s(R),u(t.getIssuer()),R.status!=="authenticated"?(h(void 0),p(void 0),t.pod.clear()):R.webId!==n.webId&&y(void 0)}),[t,n.webId]),reactExports.useEffect(()=>{initializedRuntimes.has(t)||(initializedRuntimes.add(t),t.session.initialize({restorePreviousSession:!0}).then(R=>{s(R),u(t.getIssuer())}))},[t]),reactExports.useEffect(()=>{if(n.status!=="authenticated")return;let R=!1;return t.pod.open({webId:n.webId,fetch:t.session.fetch}).then(T=>{R||(h(T),p(void 0))},T=>{R||p({webId:n.webId,error:T instanceof Error?T:new Error(String(T))})}),()=>{R=!0}},[t,n]);const S=n.status==="authenticated"?n.webId:void 0;reactExports.useEffect(()=>{if(!S)return;let R=!1;return discoverAiClientConfigurationCapability(t.session.fetch).then(T=>{!R&&t.session.getSnapshot().status==="authenticated"&&t.session.getSnapshot().webId===S&&y(T)}),()=>{R=!0}},[S,t]);const w=reactExports.useMemo(()=>{const R=a??t.getIssuer(),T=n.status==="authenticated"&&f?.webId===n.webId?f.error:void 0,A=T?{status:"error",webId:n.webId,podUrl:c?.podUrl,issuer:R,error:T}:snapshotToState(n,c,R);return{session:t.session,pod:t.pod,fetch:t.session.fetch,state:A.status==="error"?{...A,error:safeAuthError(A.error)}:A,webId:A.webId,podUrl:A.podUrl,issuer:A.issuer,currentPod:c,aiClientConfiguration:g,login:async F=>{const x=normalizeXpodOidcIssuer(F);x&&(t.setIssuer(x),u(x),await t.session.login({oidcIssuer:x,redirectUrl:window.location.href}))},logout:async()=>{t.pod.clear(),h(void 0),await t.session.logout()}}},[g,c,a,f,t,n]);return jsxRuntimeExports.jsx(SolidRuntimeProvider,{value:{session:t.session,pod:t.pod,currentPod:c},children:jsxRuntimeExports.jsx(XpodSolidRuntimeContext.Provider,{value:w,children:i})})}async function discoverAiClientConfigurationCapability(i){try{const e=await i("/api/ai/client-configuration/capability",{method:"GET",credentials:"include",headers:{accept:"application/json"}});if(!e.ok||!e.headers.get("content-type")?.includes("application/json"))return await e.arrayBuffer().catch(()=>{}),manualAiClientConfigurationCapability();const t=await e.json();if(isRecord(t)&&t.available===!0&&t.authority==="local-filesystem")return{available:!0,authority:"local-filesystem",manualInstructions:typeof t.manualInstructions=="string"?t.manualInstructions:manualAiClientConfigurationCapability().manualInstructions}}catch{}return manualAiClientConfigurationCapability()}function manualAiClientConfigurationCapability(){return{available:!1,manualInstructions:"manual client setup is available"}}function isRecord(i){return!!(i&&typeof i=="object"&&!Array.isArray(i))}function SettingsRoutes(){return useRoutes(settingsRoutes)}function SettingsApp(){return jsxRuntimeExports.jsx(XpodSolidRuntimeProvider,{children:jsxRuntimeExports.jsx(BrowserRouter,{basename:"/settings",children:jsxRuntimeExports.jsx(SettingsRoutes,{})})})}clientExports.createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(reactExports.StrictMode,{children:jsxRuntimeExports.jsx(SettingsApp,{})}));export{Button as B,Input as I,NavLink as N,Outlet as O,React as R,Server as S,cva as a,createLucideIcon as b,cn as c,clsx as d,useXpodSolidRuntime as e,requireReact as f,useComposedRefs as g,createSlot as h,jsxRuntimeExports as j,reactExports as r,useLocation as u};