@linkedrecords/browser 0.1.0

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 (265) hide show
  1. package/LICENSE +661 -0
  2. package/Readme.md +154 -0
  3. package/dist/browser_sdk.js +3 -0
  4. package/dist/browser_sdk.js.LICENSE.txt +254 -0
  5. package/dist/browser_sdk.js.map +1 -0
  6. package/dist/docs/app/[[...slug]]/page.d.ts +13 -0
  7. package/dist/docs/app/[[...slug]]/page.d.ts.map +1 -0
  8. package/dist/docs/app/layout.d.ts +10 -0
  9. package/dist/docs/app/layout.d.ts.map +1 -0
  10. package/dist/docs/lib/source.d.ts +2 -0
  11. package/dist/docs/lib/source.d.ts.map +1 -0
  12. package/dist/docs/mdx-components.d.ts +3 -0
  13. package/dist/docs/mdx-components.d.ts.map +1 -0
  14. package/dist/docs/source.config.d.ts +4 -0
  15. package/dist/docs/source.config.d.ts.map +1 -0
  16. package/dist/instrumentation.js +283 -0
  17. package/dist/instrumentation.js.map +1 -0
  18. package/dist/lib/cache/index.d.ts +4 -0
  19. package/dist/lib/cache/index.d.ts.map +1 -0
  20. package/dist/lib/client-server-bus/client/index.d.ts +3 -0
  21. package/dist/lib/client-server-bus/client/index.d.ts.map +1 -0
  22. package/dist/lib/client-server-bus/drivers/ws/client/index.d.ts +23 -0
  23. package/dist/lib/client-server-bus/drivers/ws/client/index.d.ts.map +1 -0
  24. package/dist/lib/client-server-bus/drivers/ws/server/index.d.ts +14 -0
  25. package/dist/lib/client-server-bus/drivers/ws/server/index.d.ts.map +1 -0
  26. package/dist/lib/client-server-bus/server/index.d.ts +4 -0
  27. package/dist/lib/client-server-bus/server/index.d.ts.map +1 -0
  28. package/dist/lib/cookie-settings-from-env/index.d.ts +8 -0
  29. package/dist/lib/cookie-settings-from-env/index.d.ts.map +1 -0
  30. package/dist/lib/is_logger.d.ts +6 -0
  31. package/dist/lib/is_logger.d.ts.map +1 -0
  32. package/dist/lib/pg-log/index.d.ts +9 -0
  33. package/dist/lib/pg-log/index.d.ts.map +1 -0
  34. package/dist/lib/queued-tasks/In_memory_queued_tasks.d.ts +9 -0
  35. package/dist/lib/queued-tasks/In_memory_queued_tasks.d.ts.map +1 -0
  36. package/dist/lib/queued-tasks/index.d.ts +7 -0
  37. package/dist/lib/queued-tasks/index.d.ts.map +1 -0
  38. package/dist/lib/queued-tasks/redis_queued_tasks.d.ts +7 -0
  39. package/dist/lib/queued-tasks/redis_queued_tasks.d.ts.map +1 -0
  40. package/dist/lib/quota/index.d.ts +16 -0
  41. package/dist/lib/quota/index.d.ts.map +1 -0
  42. package/dist/lib/stream-to-string/index.d.ts +4 -0
  43. package/dist/lib/stream-to-string/index.d.ts.map +1 -0
  44. package/dist/lib/utils/all_prefixes.d.ts +2 -0
  45. package/dist/lib/utils/all_prefixes.d.ts.map +1 -0
  46. package/dist/lib/utils/chunk_array.d.ts +2 -0
  47. package/dist/lib/utils/chunk_array.d.ts.map +1 -0
  48. package/dist/lib/utils/read_body.d.ts +3 -0
  49. package/dist/lib/utils/read_body.d.ts.map +1 -0
  50. package/dist/lib/utils/safe_compare.d.ts +2 -0
  51. package/dist/lib/utils/safe_compare.d.ts.map +1 -0
  52. package/dist/lib/utils/save_compare.d.ts +2 -0
  53. package/dist/lib/utils/save_compare.d.ts.map +1 -0
  54. package/dist/lib/utils/sql_values.d.ts +11 -0
  55. package/dist/lib/utils/sql_values.d.ts.map +1 -0
  56. package/dist/lib/utils/unset.d.ts +2 -0
  57. package/dist/lib/utils/unset.d.ts.map +1 -0
  58. package/dist/node_modules/redis-semaphore/src/errors/LostLockError.d.ts +3 -0
  59. package/dist/node_modules/redis-semaphore/src/errors/LostLockError.d.ts.map +1 -0
  60. package/dist/report.html +57 -0
  61. package/dist/server.js +6737 -0
  62. package/dist/server.js.map +1 -0
  63. package/dist/specs/browser_sdk/attribute.spec.d.ts +2 -0
  64. package/dist/specs/browser_sdk/attribute.spec.d.ts.map +1 -0
  65. package/dist/specs/browser_sdk/blob_attribute.spec.d.ts +2 -0
  66. package/dist/specs/browser_sdk/blob_attribute.spec.d.ts.map +1 -0
  67. package/dist/specs/browser_sdk/fact.spec.d.ts +2 -0
  68. package/dist/specs/browser_sdk/fact.spec.d.ts.map +1 -0
  69. package/dist/specs/browser_sdk/key_value_attribute.spec.d.ts +2 -0
  70. package/dist/specs/browser_sdk/key_value_attribute.spec.d.ts.map +1 -0
  71. package/dist/specs/browser_sdk/long_text_attribute.spec.d.ts +2 -0
  72. package/dist/specs/browser_sdk/long_text_attribute.spec.d.ts.map +1 -0
  73. package/dist/specs/browser_sdk/oidc-auth.spec.d.ts +2 -0
  74. package/dist/specs/browser_sdk/oidc-auth.spec.d.ts.map +1 -0
  75. package/dist/specs/browser_sdk/userinfo.spec.d.ts +2 -0
  76. package/dist/specs/browser_sdk/userinfo.spec.d.ts.map +1 -0
  77. package/dist/specs/helpers/dummy-oidc-server.d.ts +3 -0
  78. package/dist/specs/helpers/dummy-oidc-server.d.ts.map +1 -0
  79. package/dist/specs/helpers/index.d.ts +9 -0
  80. package/dist/specs/helpers/index.d.ts.map +1 -0
  81. package/dist/specs/helpers/karma-setup.d.ts +2 -0
  82. package/dist/specs/helpers/karma-setup.d.ts.map +1 -0
  83. package/dist/specs/helpers/mock-oidc-server.d.ts +28 -0
  84. package/dist/specs/helpers/mock-oidc-server.d.ts.map +1 -0
  85. package/dist/specs/helpers/test-oidc-manager.d.ts +24 -0
  86. package/dist/specs/helpers/test-oidc-manager.d.ts.map +1 -0
  87. package/dist/specs.wdio/browser_sdk/auth.spec.d.ts +2 -0
  88. package/dist/specs.wdio/browser_sdk/auth.spec.d.ts.map +1 -0
  89. package/dist/specs.wdio/browser_sdk/query_subscription.spec.d.ts +2 -0
  90. package/dist/specs.wdio/browser_sdk/query_subscription.spec.d.ts.map +1 -0
  91. package/dist/specs.wdio/browser_sdk/quota.spec.d.ts +2 -0
  92. package/dist/specs.wdio/browser_sdk/quota.spec.d.ts.map +1 -0
  93. package/dist/specs.wdio/browser_sdk/userinfo.spec.d.ts +2 -0
  94. package/dist/specs.wdio/browser_sdk/userinfo.spec.d.ts.map +1 -0
  95. package/dist/specs.wdio/helpers/lr_expects.d.ts +7 -0
  96. package/dist/specs.wdio/helpers/lr_expects.d.ts.map +1 -0
  97. package/dist/specs.wdio/helpers/session.d.ts +42 -0
  98. package/dist/specs.wdio/helpers/session.d.ts.map +1 -0
  99. package/dist/specs.wdio/helpers/timer.d.ts +21 -0
  100. package/dist/specs.wdio/helpers/timer.d.ts.map +1 -0
  101. package/dist/specs.wdio/helpers/wdio_remote.d.ts +7 -0
  102. package/dist/specs.wdio/helpers/wdio_remote.d.ts.map +1 -0
  103. package/dist/specs.wdio/load/documents/documents.spec.d.ts +2 -0
  104. package/dist/specs.wdio/load/documents/documents.spec.d.ts.map +1 -0
  105. package/dist/specs.wdio/load/documents.spec.d.ts +2 -0
  106. package/dist/specs.wdio/load/documents.spec.d.ts.map +1 -0
  107. package/dist/specs.wdio/quota_upgrade/paddle.spec.d.ts +2 -0
  108. package/dist/specs.wdio/quota_upgrade/paddle.spec.d.ts.map +1 -0
  109. package/dist/specs.wdio/testapp/client.d.ts +2 -0
  110. package/dist/specs.wdio/testapp/client.d.ts.map +1 -0
  111. package/dist/specs.wdio/testapp/server.d.ts +2 -0
  112. package/dist/specs.wdio/testapp/server.d.ts.map +1 -0
  113. package/dist/specs.wdio/tinytodo/tinytodo.d.ts +25 -0
  114. package/dist/specs.wdio/tinytodo/tinytodo.d.ts.map +1 -0
  115. package/dist/specs.wdio/tinytodo/tinytodo.spec.d.ts +2 -0
  116. package/dist/specs.wdio/tinytodo/tinytodo.spec.d.ts.map +1 -0
  117. package/dist/specs.wdio/tinytodo/tinytodo_expects.d.ts +8 -0
  118. package/dist/specs.wdio/tinytodo/tinytodo_expects.d.ts.map +1 -0
  119. package/dist/src/attributes/abstract/abstract_attribute_change.d.ts +7 -0
  120. package/dist/src/attributes/abstract/abstract_attribute_change.d.ts.map +1 -0
  121. package/dist/src/attributes/abstract/abstract_attribute_client.d.ts +58 -0
  122. package/dist/src/attributes/abstract/abstract_attribute_client.d.ts.map +1 -0
  123. package/dist/src/attributes/abstract/abstract_attribute_server.d.ts +39 -0
  124. package/dist/src/attributes/abstract/abstract_attribute_server.d.ts.map +1 -0
  125. package/dist/src/attributes/abstract/is_attribute_change.d.ts +7 -0
  126. package/dist/src/attributes/abstract/is_attribute_change.d.ts.map +1 -0
  127. package/dist/src/attributes/abstract/is_attribute_storage.d.ts +52 -0
  128. package/dist/src/attributes/abstract/is_attribute_storage.d.ts.map +1 -0
  129. package/dist/src/attributes/abstract/is_serializable.d.ts +4 -0
  130. package/dist/src/attributes/abstract/is_serializable.d.ts.map +1 -0
  131. package/dist/src/attributes/abstract/serialized_change_with_metadata.d.ts +11 -0
  132. package/dist/src/attributes/abstract/serialized_change_with_metadata.d.ts.map +1 -0
  133. package/dist/src/attributes/attribute_query.d.ts +55 -0
  134. package/dist/src/attributes/attribute_query.d.ts.map +1 -0
  135. package/dist/src/attributes/attribute_storage/blob/index.d.ts +38 -0
  136. package/dist/src/attributes/attribute_storage/blob/index.d.ts.map +1 -0
  137. package/dist/src/attributes/attribute_storage/index.d.ts +33 -0
  138. package/dist/src/attributes/attribute_storage/index.d.ts.map +1 -0
  139. package/dist/src/attributes/attribute_storage/psql/index.d.ts +39 -0
  140. package/dist/src/attributes/attribute_storage/psql/index.d.ts.map +1 -0
  141. package/dist/src/attributes/attribute_storage/psql_with_history/index.d.ts +35 -0
  142. package/dist/src/attributes/attribute_storage/psql_with_history/index.d.ts.map +1 -0
  143. package/dist/src/attributes/attribute_storage/s3/index.d.ts +38 -0
  144. package/dist/src/attributes/attribute_storage/s3/index.d.ts.map +1 -0
  145. package/dist/src/attributes/attribute_storage/types.d.ts +27 -0
  146. package/dist/src/attributes/attribute_storage/types.d.ts.map +1 -0
  147. package/dist/src/attributes/blob/blob_change.d.ts +7 -0
  148. package/dist/src/attributes/blob/blob_change.d.ts.map +1 -0
  149. package/dist/src/attributes/blob/client/index.d.ts +18 -0
  150. package/dist/src/attributes/blob/client/index.d.ts.map +1 -0
  151. package/dist/src/attributes/blob/server/index.d.ts +27 -0
  152. package/dist/src/attributes/blob/server/index.d.ts.map +1 -0
  153. package/dist/src/attributes/errors/authorization_error.d.ts +6 -0
  154. package/dist/src/attributes/errors/authorization_error.d.ts.map +1 -0
  155. package/dist/src/attributes/key_value/client/index.d.ts +19 -0
  156. package/dist/src/attributes/key_value/client/index.d.ts.map +1 -0
  157. package/dist/src/attributes/key_value/key_value_change.d.ts +16 -0
  158. package/dist/src/attributes/key_value/key_value_change.d.ts.map +1 -0
  159. package/dist/src/attributes/key_value/server/index.d.ts +28 -0
  160. package/dist/src/attributes/key_value/server/index.d.ts.map +1 -0
  161. package/dist/src/attributes/long_text/client/buffer.d.ts +12 -0
  162. package/dist/src/attributes/long_text/client/buffer.d.ts.map +1 -0
  163. package/dist/src/attributes/long_text/client/index.d.ts +25 -0
  164. package/dist/src/attributes/long_text/client/index.d.ts.map +1 -0
  165. package/dist/src/attributes/long_text/long_text_change.d.ts +16 -0
  166. package/dist/src/attributes/long_text/long_text_change.d.ts.map +1 -0
  167. package/dist/src/attributes/long_text/server/index.d.ts +27 -0
  168. package/dist/src/attributes/long_text/server/index.d.ts.map +1 -0
  169. package/dist/src/browser_sdk/attributes_repository.d.ts +46 -0
  170. package/dist/src/browser_sdk/attributes_repository.d.ts.map +1 -0
  171. package/dist/src/browser_sdk/facts_repository.d.ts +11 -0
  172. package/dist/src/browser_sdk/facts_repository.d.ts.map +1 -0
  173. package/dist/src/browser_sdk/index.d.ts +69 -0
  174. package/dist/src/browser_sdk/index.d.ts.map +1 -0
  175. package/dist/src/browser_sdk/oidc.d.ts +29 -0
  176. package/dist/src/browser_sdk/oidc.d.ts.map +1 -0
  177. package/dist/src/dev-oidc/config.d.ts +13 -0
  178. package/dist/src/dev-oidc/config.d.ts.map +1 -0
  179. package/dist/src/dev-oidc/endpoints.d.ts +8 -0
  180. package/dist/src/dev-oidc/endpoints.d.ts.map +1 -0
  181. package/dist/src/dev-oidc/index.d.ts +5 -0
  182. package/dist/src/dev-oidc/index.d.ts.map +1 -0
  183. package/dist/src/dev-oidc/keys.d.ts +9 -0
  184. package/dist/src/dev-oidc/keys.d.ts.map +1 -0
  185. package/dist/src/dev-oidc/login-page.d.ts +3 -0
  186. package/dist/src/dev-oidc/login-page.d.ts.map +1 -0
  187. package/dist/src/facts/client/index.d.ts +15 -0
  188. package/dist/src/facts/client/index.d.ts.map +1 -0
  189. package/dist/src/facts/fact_query.d.ts +8 -0
  190. package/dist/src/facts/fact_query.d.ts.map +1 -0
  191. package/dist/src/facts/server/auth_cache.d.ts +12 -0
  192. package/dist/src/facts/server/auth_cache.d.ts.map +1 -0
  193. package/dist/src/facts/server/authorization_sql_builder.d.ts +22 -0
  194. package/dist/src/facts/server/authorization_sql_builder.d.ts.map +1 -0
  195. package/dist/src/facts/server/fact_box.d.ts +20 -0
  196. package/dist/src/facts/server/fact_box.d.ts.map +1 -0
  197. package/dist/src/facts/server/index.d.ts +64 -0
  198. package/dist/src/facts/server/index.d.ts.map +1 -0
  199. package/dist/src/facts/server/predicate_extractor.d.ts +8 -0
  200. package/dist/src/facts/server/predicate_extractor.d.ts.map +1 -0
  201. package/dist/src/facts/server/query_subscription_service.d.ts +14 -0
  202. package/dist/src/facts/server/query_subscription_service.d.ts.map +1 -0
  203. package/dist/src/facts/server/subscription_service.d.ts +1 -0
  204. package/dist/src/facts/server/subscription_service.d.ts.map +1 -0
  205. package/dist/src/quota/index.d.ts +38 -0
  206. package/dist/src/quota/index.d.ts.map +1 -0
  207. package/dist/src/server/cache.d.ts +7 -0
  208. package/dist/src/server/cache.d.ts.map +1 -0
  209. package/dist/src/server/controllers/attributes_controller.d.ts +16 -0
  210. package/dist/src/server/controllers/attributes_controller.d.ts.map +1 -0
  211. package/dist/src/server/controllers/facts_controller.d.ts +7 -0
  212. package/dist/src/server/controllers/facts_controller.d.ts.map +1 -0
  213. package/dist/src/server/controllers/oidc_controller.d.ts +5 -0
  214. package/dist/src/server/controllers/oidc_controller.d.ts.map +1 -0
  215. package/dist/src/server/controllers/quota_controller.d.ts +5 -0
  216. package/dist/src/server/controllers/quota_controller.d.ts.map +1 -0
  217. package/dist/src/server/controllers/subscription_controller.d.ts +9 -0
  218. package/dist/src/server/controllers/subscription_controller.d.ts.map +1 -0
  219. package/dist/src/server/controllers/userinfo_controller.d.ts +7 -0
  220. package/dist/src/server/controllers/userinfo_controller.d.ts.map +1 -0
  221. package/dist/src/server/index.d.ts +2 -0
  222. package/dist/src/server/index.d.ts.map +1 -0
  223. package/dist/src/server/instrumentation/config.d.ts +14 -0
  224. package/dist/src/server/instrumentation/config.d.ts.map +1 -0
  225. package/dist/src/server/instrumentation/index.d.ts +11 -0
  226. package/dist/src/server/instrumentation/index.d.ts.map +1 -0
  227. package/dist/src/server/instrumentation/manual/minio.d.ts +8 -0
  228. package/dist/src/server/instrumentation/manual/minio.d.ts.map +1 -0
  229. package/dist/src/server/instrumentation/manual/socketio.d.ts +9 -0
  230. package/dist/src/server/instrumentation/manual/socketio.d.ts.map +1 -0
  231. package/dist/src/server/instrumentation.d.ts +10 -0
  232. package/dist/src/server/instrumentation.d.ts.map +1 -0
  233. package/dist/src/server/middleware/attribute.d.ts +5 -0
  234. package/dist/src/server/middleware/attribute.d.ts.map +1 -0
  235. package/dist/src/server/middleware/authentication.d.ts +2 -0
  236. package/dist/src/server/middleware/authentication.d.ts.map +1 -0
  237. package/dist/src/server/middleware/clear_cookies.d.ts +2 -0
  238. package/dist/src/server/middleware/clear_cookies.d.ts.map +1 -0
  239. package/dist/src/server/middleware/error_handler.d.ts +2 -0
  240. package/dist/src/server/middleware/error_handler.d.ts.map +1 -0
  241. package/dist/src/server/middleware/fact.d.ts +2 -0
  242. package/dist/src/server/middleware/fact.d.ts.map +1 -0
  243. package/dist/src/server/middleware/quota_upgrade.d.ts +3 -0
  244. package/dist/src/server/middleware/quota_upgrade.d.ts.map +1 -0
  245. package/dist/src/server/payment_provider/abstract_provider.d.ts +8 -0
  246. package/dist/src/server/payment_provider/abstract_provider.d.ts.map +1 -0
  247. package/dist/src/server/payment_provider/index.d.ts +5 -0
  248. package/dist/src/server/payment_provider/index.d.ts.map +1 -0
  249. package/dist/src/server/payment_provider/paddle.d.ts +16 -0
  250. package/dist/src/server/payment_provider/paddle.d.ts.map +1 -0
  251. package/dist/src/server/quota/index.d.ts +43 -0
  252. package/dist/src/server/quota/index.d.ts.map +1 -0
  253. package/dist/src/server/routes.d.ts +3 -0
  254. package/dist/src/server/routes.d.ts.map +1 -0
  255. package/dist/src/server/service_bus_mount.d.ts +10 -0
  256. package/dist/src/server/service_bus_mount.d.ts.map +1 -0
  257. package/dist/src/server/services/predicate_extractor.d.ts +24 -0
  258. package/dist/src/server/services/predicate_extractor.d.ts.map +1 -0
  259. package/dist/src/server/services/query_subscription_service.d.ts +42 -0
  260. package/dist/src/server/services/query_subscription_service.d.ts.map +1 -0
  261. package/dist/src/server/services/subscription_hooks.d.ts +18 -0
  262. package/dist/src/server/services/subscription_hooks.d.ts.map +1 -0
  263. package/dist/wdio.conf.d.ts +3 -0
  264. package/dist/wdio.conf.d.ts.map +1 -0
  265. package/package.json +121 -0
@@ -0,0 +1,3 @@
1
+ /*! For license information please see browser_sdk.js.LICENSE.txt */
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var s=t();for(var r in s)("object"==typeof exports?exports:e)[r]=s[r]}}(self,()=>(()=>{var e={"../../node_modules/changesets/lib/Builder.js"(e,t,s){var r=s("../../node_modules/changesets/lib/Changeset.js"),n=s("../../node_modules/changesets/lib/operations/Retain.js"),i=s("../../node_modules/changesets/lib/operations/Skip.js"),o=s("../../node_modules/changesets/lib/operations/Insert.js");function a(){this.ops=[],this.addendum="",this.removendum=""}e.exports=a,a.prototype.keep=a.prototype.retain=function(e){return this.ops.push(new n(e)),this},a.prototype.delete=a.prototype.skip=function(e){return this.removendum+=e,this.ops.push(new i(e.length)),this},a.prototype.add=a.prototype.insert=function(e){return this.addendum+=e,this.ops.push(new o(e.length)),this},a.prototype.end=function(){var e=new r(this.ops);return e.addendum=this.addendum,e.removendum=this.removendum,e}},"../../node_modules/changesets/lib/Changeset.js"(e,t,s){function r(e){this.addendum="",this.removendum="",this.inputLength=0,this.outputLength=0,Array.isArray(e)||(e=arguments);for(var t=0;t<e.length;t++)this.push(e[t]),this.inputLength+=e[t].input,this.outputLength+=e[t].output}r.prototype=Object.create(Array.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e.exports=r;var n=s("../../node_modules/changesets/lib/TextTransform.js"),i=s("../../node_modules/changesets/lib/ChangesetTransform.js"),o=s("../../node_modules/changesets/lib/operations/Retain.js"),a=s("../../node_modules/changesets/lib/operations/Skip.js"),c=s("../../node_modules/changesets/lib/operations/Insert.js"),u=s("../../node_modules/changesets/lib/Builder.js");r.prototype.subrange=function(e,t){for(var s,r,n=[],i=0,o=0,a=0;o<this.length&&i<t;o++)(s=this[o]).input+a>=e&&(s.input?0!==(r=s.length!=1/0?s.length-Math.max(0,e-a)-Math.max(0,s.length+a-(e+t)):t)&&n.push(s.derive(r)):(n.push(s.derive(s.length)),r=0),i+=r),a+=s.input;return n},r.prototype.merge=function(e,t){if(e.inputLength!==this.outputLength)throw new Error("Changeset lengths for merging don't match! Input length of younger cs: "+e.inputLength+", output length of older cs:"+this.outputLength);var s=[],n=0,i=0,o=0,a=0,c="",u="";!function(e,t,s){for(var r,n,i=e.map(function(e){return e.clone()}),o=t.map(function(e){return e.clone()});i.length||o.length;)n=i[0]?i[0].clone():null,r=o[0]?o[0].clone():null,n&&(r&&(n=n.derive(Math.min(n.length,r.length))),i[0].length>n.length?i[0]=i[0].derive(i[0].length-n.length):i.shift()),r&&(n&&(r=r.derive(Math.min(n.length,r.length))),o[0].length>r.length?o[0]=o[0].derive(o[0].length-r.length):o.shift()),s(n,r),n&&n.length&&i.unshift(n),r&&r.length&&o.unshift(r)}(this,e,function(t,r){if(t&&!t.output)return s.push(t.merge().clone()),u+=this.removendum.substr(i,t.length),i+=t.length,void(t.length=0);if(r&&!r.input)return s.push(r.merge().clone()),c+=e.addendum.substr(o,r.length),o+=r.length,void(r.length=0);if(!(r&&r.input&&t))throw console.log("oops",arguments),new Error("oops. This case hasn't been considered by the developer (error code: PBCAC)");r.output?(s.push(t.merge(r).clone()),t.input||(c+=this.addendum.substr(n,t.length),n+=t.length),t.length=0,r.length=0):!r.output&&t.input?(s.push(r.merge(t).clone()),u+=e.removendum.substr(a,r.length),a+=r.length,t.length=0,r.length=0):(n+=t.length,t.length=0,r.length=0)}.bind(this));var d=new r(s);return d.addendum=c,d.removendum=u,d},r.prototype.transformAgainst=function(e,t){if(this.inputLength!=e.inputLength)throw new Error("Can't transform changesets with differing inputLength: "+this.inputLength+" and "+e.inputLength);var s=new i(this,[new o(1/0)]);return e.forEach(function(e){var r=this.subrange(s.pos,1/0)[0];!r||r.input||e.input||t&&s.writeOutput(s.readInput(r.length)),e.apply(s)}.bind(this)),s.result()},r.prototype.substract=function(e,t){return this.transformAgainst(e.invert(),t)},r.prototype.invert=function(){var e=new r(this.map(function(e){return e.invert()}));return e.addendum=this.removendum,e.removendum=this.addendum,e},r.prototype.apply=function(e){if(e.length!=this.inputLength)throw new Error("Input length doesn't match expected length. expected: "+this.inputLength+"; actual: "+e.length);var t=new n(e,this.addendum,this.removendum);return this.forEach(function(e){e.apply(t)}.bind(this)),t.result()},r.prototype.inspect=function(){var e=0;return this.map(function(t){var s="";if(!t.input)return s=this.addendum.substr(e,t.length),e+=t.length,s;for(var r=0;r<t.length;r++)s+=t.symbol;return s}.bind(this)).join("")},r.prototype.pack=function(){return this.map(function(e){return e.pack()}).join("")+"|"+this.addendum.replace(/%/g,"%25").replace(/\|/g,"%7C")+"|"+this.removendum.replace(/%/g,"%25").replace(/\|/g,"%7C")},r.prototype.toString=function(){return this.pack()},r.unpack=function(e){if(""==e)throw new Error("Cannot unpack from empty string");var t=e.split("|"),s=t[0],n=t[1].replace(/%7c/gi,"|").replace(/%25/g,"%"),i=t[2].replace(/%7c/gi,"|").replace(/%25/g,"%"),u=s.match(/[=+-]([^=+-])+/g);if(!u)throw new Error("Cannot unpack invalidly serialized op string");var d=[];u.forEach(function(e){var t=e.substr(0,1),s=e.substr(1);if(a.prototype.symbol==t)return d.push(a.unpack(s));if(c.prototype.symbol==t)return d.push(c.unpack(s));if(o.prototype.symbol==t)return d.push(o.unpack(s));throw new Error("Invalid changeset representation passed to Changeset.unpack")});var h=new r(d);return h.addendum=n,h.removendum=i,h},r.create=function(){return new u},r.fromDiff=function(e){var t=[],s="",n="";e.forEach(function(e){-1==e[0]&&(t.push(new a(e[1].length)),s+=e[1]),1==e[0]&&(t.push(new c(e[1].length)),n+=e[1]),0==e[0]&&t.push(new o(e[1].length))});var i=new r(t);return i.addendum=n,i.removendum=s,i}},"../../node_modules/changesets/lib/ChangesetTransform.js"(e,t,s){s("../../node_modules/changesets/lib/operations/Retain.js"),s("../../node_modules/changesets/lib/operations/Skip.js"),s("../../node_modules/changesets/lib/operations/Insert.js");var r=s("../../node_modules/changesets/lib/Changeset.js");function n(e,t){this.output=[],this.addendum=t,this.newRemovendum="",this.newAddendum="",this.cs=e,this.pos=0,this.addendumPointer=0,this.removendumPointer=0}e.exports=n,n.prototype.readInput=function(e){var t=this.cs.subrange(this.pos,e);return this.pos+=e,t},n.prototype.readAddendum=function(e){var t=this.subrange(this.addendum,this.addendumPointer,e);return this.addendumPointer+=e,t},n.prototype.writeRemovendum=function(e){e.filter(function(e){return!e.output}).forEach(function(e){this.removendumPointer+=e.length}.bind(this))},n.prototype.writeOutput=function(e){this.output=this.output.concat(e),e.filter(function(e){return!e.output}).forEach(function(e){this.newRemovendum+=this.cs.removendum.substr(this.removendumPointer,e.length),this.removendumPointer+=e.length}.bind(this))},n.prototype.subrange=function(e,t,s){return s?this.cs.subrange.call(e,t,s):e.filter(function(e){return!e.input})},n.prototype.result=function(){this.writeOutput(this.readInput(1/0));var e=new r(this.output);return e.addendum=this.cs.addendum,e.removendum=this.newRemovendum,e}},"../../node_modules/changesets/lib/Operator.js"(e){function t(){}e.exports=t,t.prototype.clone=function(){return this.derive(this.length)},t.prototype.derive=function(e){return new this.constructor(e)},t.prototype.pack=function(){return this.symbol+this.length.toString(36)}},"../../node_modules/changesets/lib/TextTransform.js"(e,t,s){function r(e,t,s){this.output="",this.input=e,this.addendum=t,this.removendum=s,this.pos=0,this.addPos=0,this.remPos=0}s("../../node_modules/changesets/lib/operations/Retain.js"),s("../../node_modules/changesets/lib/operations/Skip.js"),s("../../node_modules/changesets/lib/operations/Insert.js"),s("../../node_modules/changesets/lib/Changeset.js"),e.exports=r,r.prototype.readInput=function(e){var t=this.input.substr(this.pos,e);return this.pos+=e,t},r.prototype.readAddendum=function(e){var t=this.addendum.substr(this.addPos,e);return this.addPos+=e,t},r.prototype.writeRemovendum=function(e){this.remPos+=e.length},r.prototype.writeOutput=function(e){this.output+=e},r.prototype.subrange=function(e,t,s){return e.substr(t,s)},r.prototype.result=function(){return this.writeOutput(this.readInput(1/0)),this.output}},"../../node_modules/changesets/lib/index.js"(e,t,s){var r=s("../../node_modules/changesets/lib/Changeset.js"),n=s("../../node_modules/changesets/lib/operations/Retain.js"),i=s("../../node_modules/changesets/lib/operations/Skip.js"),o=s("../../node_modules/changesets/lib/operations/Insert.js");t.Operator=s("../../node_modules/changesets/lib/Operator.js"),t.Changeset=r,t.Insert=o,t.Retain=n,t.Skip=i,"undefined"!=typeof window&&(window.changesets=t),t.pack=function(e){return e.pack()},t.unpack=function(e){return r.unpack(e)},t.name="changesets",t.url="https://github.com/marcelklehr/changesets",t.create=function(e){return e||""},t.apply=function(e,s){return(s=t.unpack(s)).apply(e)},t.transform=function(e,s,r){return e=t.unpack(e),s=t.unpack(s),t.pack(e.transformAgainst(s,"left"==r))},t.compose=function(e,s){return e=t.unpack(e),s=t.unpack(s),t.pack(e.merge(s))},t.invert=function(e){return t.pack(t.unpack(e).invert())}},"../../node_modules/changesets/lib/operations/Insert.js"(e,t,s){var r=s("../../node_modules/changesets/lib/Operator.js");function n(e){this.length=e,this.input=0,this.output=e}n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),e.exports=n,n.prototype.symbol="+";var i=s("../../node_modules/changesets/lib/operations/Skip.js");s("../../node_modules/changesets/lib/operations/Retain.js"),n.prototype.apply=function(e){e.writeOutput(e.readAddendum(this.output))},n.prototype.merge=function(){return this},n.prototype.invert=function(){return new i(this.length)},n.unpack=function(e){return new n(parseInt(e,36))}},"../../node_modules/changesets/lib/operations/Retain.js"(e,t,s){var r=s("../../node_modules/changesets/lib/Operator.js");function n(e){this.length=e,this.input=e,this.output=e}n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),e.exports=n,n.prototype.symbol="=",n.prototype.apply=function(e){e.writeOutput(e.readInput(this.input))},n.prototype.invert=function(){return this},n.prototype.merge=function(e){return this},n.unpack=function(e){return new n(parseInt(e,36))}},"../../node_modules/changesets/lib/operations/Skip.js"(e,t,s){var r=s("../../node_modules/changesets/lib/Operator.js");function n(e){this.length=e,this.input=e,this.output=0}n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),e.exports=n,n.prototype.symbol="-";var i=s("../../node_modules/changesets/lib/operations/Insert.js");s("../../node_modules/changesets/lib/operations/Retain.js"),s("../../node_modules/changesets/lib/Changeset.js"),n.prototype.apply=function(e){var t=e.readInput(this.input);e.writeRemovendum(t),e.writeOutput(e.subrange(t,0,this.output))},n.prototype.merge=function(e){return this},n.prototype.invert=function(){return new i(this.length)},n.unpack=function(e){return new n(parseInt(e,36))}},"../../node_modules/debug/src/browser.js"(e,t,s){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(n=r))}),t.splice(n,0,s)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=s("../../node_modules/debug/src/common.js")(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},"../../node_modules/debug/src/common.js"(e,t,s){e.exports=function(e){function t(e){let s,n,i,o=null;function a(...e){if(!a.enabled)return;const r=a,n=Number(new Date),i=n-(s||n);r.diff=i,r.prev=s,r.curr=n,s=n,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(s,n)=>{if("%%"===s)return"%";o++;const i=t.formatters[n];if("function"==typeof i){const t=e[o];s=i.call(r,t),e.splice(o,1),o--}return s}),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(n!==t.namespaces&&(n=t.namespaces,i=t.enabled(e)),i),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,s){const r=t(this.namespace+(void 0===s?":":s)+e);return r.log=this.log,r}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let s;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),n=r.length;for(s=0;s<n;s++)r[s]&&("-"===(e=r[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let s,r;for(s=0,r=t.skips.length;s<r;s++)if(t.skips[s].test(e))return!1;for(s=0,r=t.names.length;s<r;s++)if(t.names[s].test(e))return!0;return!1},t.humanize=s("../../node_modules/ms/index.js"),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(s=>{t[s]=e[s]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t}},"../../node_modules/diff_match_patch/lib/diff_match_patch.js"(e,t){function s(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Diff_DualThreshold=32,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=function(){for(var e=0,t=1,s=2;t!=s;)e++,t=s,s<<=1;return e}()}var r=-1;function n(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0}s.prototype.diff_main=function(e,t,s){if(null==e||null==t)throw new Error("Null input. (diff_main)");if(e==t)return[[0,e]];void 0===s&&(s=!0);var r=s,n=this.diff_commonPrefix(e,t),i=e.substring(0,n);e=e.substring(n),t=t.substring(n),n=this.diff_commonSuffix(e,t);var o=e.substring(e.length-n);e=e.substring(0,e.length-n),t=t.substring(0,t.length-n);var a=this.diff_compute(e,t,r);return i&&a.unshift([0,i]),o&&a.push([0,o]),this.diff_cleanupMerge(a),a},s.prototype.diff_compute=function(e,t,s){var n;if(!e)return[[1,t]];if(!t)return[[r,e]];var i=e.length>t.length?e:t,o=e.length>t.length?t:e,a=i.indexOf(o);if(-1!=a)return n=[[1,i.substring(0,a)],[0,o],[1,i.substring(a+o.length)]],e.length>t.length&&(n[0][0]=n[2][0]=r),n;i=o=null;var c,u=this.diff_halfMatch(e,t);if(u){var d=u[0],h=u[1],l=u[2],p=u[3],g=u[4],f=this.diff_main(d,l,s),_=this.diff_main(h,p,s);return f.concat([[0,g]],_)}if(s&&(e.length<100||t.length<100)&&(s=!1),s&&(e=(k=this.diff_linesToChars(e,t))[0],t=k[1],c=k[2]),(n=this.diff_map(e,t))||(n=[[r,e],[1,t]]),s){this.diff_charsToLines(n,c),this.diff_cleanupSemantic(n),n.push([0,""]);for(var m=0,b=0,w=0,y="",v="";m<n.length;){switch(n[m][0]){case 1:w++,v+=n[m][1];break;case r:b++,y+=n[m][1];break;case 0:if(b>=1&&w>=1){var k=this.diff_main(y,v,!1);n.splice(m-b-w,b+w),m=m-b-w;for(var S=k.length-1;S>=0;S--)n.splice(m,0,k[S]);m+=k.length}w=0,b=0,y="",v=""}m++}n.pop()}return n},s.prototype.diff_linesToChars=function(e,t){var s=[],r={};function n(e){for(var t="",n=0,i=-1,o=s.length;i<e.length-1;){-1==(i=e.indexOf("\n",n))&&(i=e.length-1);var a=e.substring(n,i+1);n=i+1,(r.hasOwnProperty?r.hasOwnProperty(a):void 0!==r[a])?t+=String.fromCharCode(r[a]):(t+=String.fromCharCode(o),r[a]=o,s[o++]=a)}return t}return s[0]="",[n(e),n(t),s]},s.prototype.diff_charsToLines=function(e,t){for(var s=0;s<e.length;s++){for(var r=e[s][1],n=[],i=0;i<r.length;i++)n[i]=t[r.charCodeAt(i)];e[s][1]=n.join("")}},s.prototype.diff_map=function(e,t){var s,r,n,i=(new Date).getTime()+1e3*this.Diff_Timeout,o=e.length,a=t.length,c=o+a-1,u=2*this.Diff_DualThreshold<c,d=[],h=[],l={},p={};l[1]=0,p[1]=0;for(var g={},f=!1,_=(o+a)%2,m=0;m<c;m++){if(this.Diff_Timeout>0&&(new Date).getTime()>i)return null;d[m]={};for(var b=-m;b<=m;b+=2){for(r=(s=b==-m||b!=m&&l[b-1]<l[b+1]?l[b+1]:l[b-1]+1)-b,u&&(n=s+","+r,_&&void 0!==g[n]&&(f=!0),_||(g[n]=m));!f&&s<o&&r<a&&e.charAt(s)==t.charAt(r);)s++,r++,u&&(n=s+","+r,_&&void 0!==g[n]&&(f=!0),_||(g[n]=m));if(l[b]=s,d[m][s+","+r]=!0,s==o&&r==a)return this.diff_path1(d,e,t);if(f)return h=h.slice(0,g[n]+1),this.diff_path1(d,e.substring(0,s),t.substring(0,r)).concat(this.diff_path2(h,e.substring(s),t.substring(r)))}if(u)for(h[m]={},b=-m;b<=m;b+=2){for(n=o-(s=b==-m||b!=m&&p[b-1]<p[b+1]?p[b+1]:p[b-1]+1)+","+(a-(r=s-b)),_||void 0===g[n]||(f=!0),_&&(g[n]=m);!f&&s<o&&r<a&&e.charAt(o-s-1)==t.charAt(a-r-1);)n=o-++s+","+(a-++r),_||void 0===g[n]||(f=!0),_&&(g[n]=m);if(p[b]=s,h[m][s+","+r]=!0,f)return d=d.slice(0,g[n]+1),this.diff_path1(d,e.substring(0,o-s),t.substring(0,a-r)).concat(this.diff_path2(h,e.substring(o-s),t.substring(a-r)))}}return null},s.prototype.diff_path1=function(e,t,s){for(var n=[],i=t.length,o=s.length,a=null,c=e.length-2;c>=0;c--)for(;;){if(void 0!==e[c][i-1+","+o]){i--,a===r?n[0][1]=t.charAt(i)+n[0][1]:n.unshift([r,t.charAt(i)]),a=r;break}if(void 0!==e[c][i+","+(o-1)]){o--,1===a?n[0][1]=s.charAt(o)+n[0][1]:n.unshift([1,s.charAt(o)]),a=1;break}if(i--,o--,t.charAt(i)!=s.charAt(o))throw new Error("No diagonal. Can't happen. (diff_path1)");0===a?n[0][1]=t.charAt(i)+n[0][1]:n.unshift([0,t.charAt(i)]),a=0}return n},s.prototype.diff_path2=function(e,t,s){for(var n=[],i=0,o=t.length,a=s.length,c=null,u=e.length-2;u>=0;u--)for(;;){if(void 0!==e[u][o-1+","+a]){o--,c===r?n[i-1][1]+=t.charAt(t.length-o-1):n[i++]=[r,t.charAt(t.length-o-1)],c=r;break}if(void 0!==e[u][o+","+(a-1)]){a--,1===c?n[i-1][1]+=s.charAt(s.length-a-1):n[i++]=[1,s.charAt(s.length-a-1)],c=1;break}if(o--,a--,t.charAt(t.length-o-1)!=s.charAt(s.length-a-1))throw new Error("No diagonal. Can't happen. (diff_path2)");0===c?n[i-1][1]+=t.charAt(t.length-o-1):n[i++]=[0,t.charAt(t.length-o-1)],c=0}return n},s.prototype.diff_commonPrefix=function(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var s=0,r=Math.min(e.length,t.length),n=r,i=0;s<n;)e.substring(i,n)==t.substring(i,n)?i=s=n:r=n,n=Math.floor((r-s)/2+s);return n},s.prototype.diff_commonSuffix=function(e,t){if(!e||!t||e.charAt(e.length-1)!=t.charAt(t.length-1))return 0;for(var s=0,r=Math.min(e.length,t.length),n=r,i=0;s<n;)e.substring(e.length-n,e.length-i)==t.substring(t.length-n,t.length-i)?i=s=n:r=n,n=Math.floor((r-s)/2+s);return n},s.prototype.diff_halfMatch=function(e,t){var s=e.length>t.length?e:t,r=e.length>t.length?t:e;if(s.length<10||r.length<1)return null;var n=this;function i(e,t,s){for(var r,i,o,a,c=e.substring(s,s+Math.floor(e.length/4)),u=-1,d="";-1!=(u=t.indexOf(c,u+1));){var h=n.diff_commonPrefix(e.substring(s),t.substring(u)),l=n.diff_commonSuffix(e.substring(0,s),t.substring(0,u));d.length<l+h&&(d=t.substring(u-l,u)+t.substring(u,u+h),r=e.substring(0,s-l),i=e.substring(s+h),o=t.substring(0,u-l),a=t.substring(u+h))}return d.length>=e.length/2?[r,i,o,a,d]:null}var o,a,c,u,d,h=i(s,r,Math.ceil(s.length/4)),l=i(s,r,Math.ceil(s.length/2));return h||l?(o=l?h&&h[4].length>l[4].length?h:l:h,e.length>t.length?(a=o[0],c=o[1],u=o[2],d=o[3]):(u=o[0],d=o[1],a=o[2],c=o[3]),[a,c,u,d,o[4]]):null},s.prototype.diff_cleanupSemantic=function(e){for(var t=!1,s=[],n=0,i=null,o=0,a=0,c=0;o<e.length;)0==e[o][0]?(s[n++]=o,a=c,c=0,i=e[o][1]):(c+=e[o][1].length,null!==i&&i.length<=a&&i.length<=c&&(e.splice(s[n-1],0,[r,i]),e[s[n-1]+1][0]=1,n--,o=--n>0?s[n-1]:-1,a=0,c=0,i=null,t=!0)),o++;t&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e)},s.prototype.diff_cleanupSemanticLossless=function(e){var t=/[^a-zA-Z0-9]/,s=/\s/,r=/[\r\n]/,n=/\n\r?\n$/,i=/^\r?\n\r?\n/;function o(e,o){if(!e||!o)return 5;var a=0;return(e.charAt(e.length-1).match(t)||o.charAt(0).match(t))&&(a++,(e.charAt(e.length-1).match(s)||o.charAt(0).match(s))&&(a++,(e.charAt(e.length-1).match(r)||o.charAt(0).match(r))&&(a++,(e.match(n)||o.match(i))&&a++))),a}for(var a=1;a<e.length-1;){if(0==e[a-1][0]&&0==e[a+1][0]){var c=e[a-1][1],u=e[a][1],d=e[a+1][1],h=this.diff_commonSuffix(c,u);if(h){var l=u.substring(u.length-h);c=c.substring(0,c.length-h),u=l+u.substring(0,u.length-h),d=l+d}for(var p=c,g=u,f=d,_=o(c,u)+o(u,d);u.charAt(0)===d.charAt(0);){c+=u.charAt(0),u=u.substring(1)+d.charAt(0),d=d.substring(1);var m=o(c,u)+o(u,d);m>=_&&(_=m,p=c,g=u,f=d)}e[a-1][1]!=p&&(p?e[a-1][1]=p:(e.splice(a-1,1),a--),e[a][1]=g,f?e[a+1][1]=f:(e.splice(a+1,1),a--))}a++}},s.prototype.diff_cleanupEfficiency=function(e){for(var t=!1,s=[],n=0,i="",o=0,a=!1,c=!1,u=!1,d=!1;o<e.length;)0==e[o][0]?(e[o][1].length<this.Diff_EditCost&&(u||d)?(s[n++]=o,a=u,c=d,i=e[o][1]):(n=0,i=""),u=d=!1):(e[o][0]==r?d=!0:u=!0,i&&(a&&c&&u&&d||i.length<this.Diff_EditCost/2&&a+c+u+d==3)&&(e.splice(s[n-1],0,[r,i]),e[s[n-1]+1][0]=1,n--,i="",a&&c?(u=d=!0,n=0):(o=--n>0?s[n-1]:-1,u=d=!1),t=!0)),o++;t&&this.diff_cleanupMerge(e)},s.prototype.diff_cleanupMerge=function(e){e.push([0,""]);for(var t,s=0,n=0,i=0,o="",a="";s<e.length;)switch(e[s][0]){case 1:i++,a+=e[s][1],s++;break;case r:n++,o+=e[s][1],s++;break;case 0:0!==n||0!==i?(0!==n&&0!==i&&(0!==(t=this.diff_commonPrefix(a,o))&&(s-n-i>0&&0==e[s-n-i-1][0]?e[s-n-i-1][1]+=a.substring(0,t):(e.splice(0,0,[0,a.substring(0,t)]),s++),a=a.substring(t),o=o.substring(t)),0!==(t=this.diff_commonSuffix(a,o))&&(e[s][1]=a.substring(a.length-t)+e[s][1],a=a.substring(0,a.length-t),o=o.substring(0,o.length-t))),0===n?e.splice(s-n-i,n+i,[1,a]):0===i?e.splice(s-n-i,n+i,[r,o]):e.splice(s-n-i,n+i,[r,o],[1,a]),s=s-n-i+(n?1:0)+(i?1:0)+1):0!==s&&0==e[s-1][0]?(e[s-1][1]+=e[s][1],e.splice(s,1)):s++,i=0,n=0,o="",a=""}""===e[e.length-1][1]&&e.pop();var c=!1;for(s=1;s<e.length-1;)0==e[s-1][0]&&0==e[s+1][0]&&(e[s][1].substring(e[s][1].length-e[s-1][1].length)==e[s-1][1]?(e[s][1]=e[s-1][1]+e[s][1].substring(0,e[s][1].length-e[s-1][1].length),e[s+1][1]=e[s-1][1]+e[s+1][1],e.splice(s-1,1),c=!0):e[s][1].substring(0,e[s+1][1].length)==e[s+1][1]&&(e[s-1][1]+=e[s+1][1],e[s][1]=e[s][1].substring(e[s+1][1].length)+e[s+1][1],e.splice(s+1,1),c=!0)),s++;c&&this.diff_cleanupMerge(e)},s.prototype.diff_xIndex=function(e,t){var s,n=0,i=0,o=0,a=0;for(s=0;s<e.length&&(1!==e[s][0]&&(n+=e[s][1].length),e[s][0]!==r&&(i+=e[s][1].length),!(n>t));s++)o=n,a=i;return e.length!=s&&e[s][0]===r?a:a+(t-o)},s.prototype.diff_prettyHtml=function(e){for(var t=[],s=0,n=0;n<e.length;n++){var i=e[n][0],o=e[n][1],a=o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"&para;<BR>");switch(i){case 1:t[n]='<INS STYLE="background:#E6FFE6;" TITLE="i='+s+'">'+a+"</INS>";break;case r:t[n]='<DEL STYLE="background:#FFE6E6;" TITLE="i='+s+'">'+a+"</DEL>";break;case 0:t[n]='<SPAN TITLE="i='+s+'">'+a+"</SPAN>"}i!==r&&(s+=o.length)}return t.join("")},s.prototype.diff_text1=function(e){for(var t=[],s=0;s<e.length;s++)1!==e[s][0]&&(t[s]=e[s][1]);return t.join("")},s.prototype.diff_text2=function(e){for(var t=[],s=0;s<e.length;s++)e[s][0]!==r&&(t[s]=e[s][1]);return t.join("")},s.prototype.diff_levenshtein=function(e){for(var t=0,s=0,n=0,i=0;i<e.length;i++){var o=e[i][0],a=e[i][1];switch(o){case 1:s+=a.length;break;case r:n+=a.length;break;case 0:t+=Math.max(s,n),s=0,n=0}}return t+Math.max(s,n)},s.prototype.diff_toDelta=function(e){for(var t=[],s=0;s<e.length;s++)switch(e[s][0]){case 1:t[s]="+"+encodeURI(e[s][1]);break;case r:t[s]="-"+e[s][1].length;break;case 0:t[s]="="+e[s][1].length}return t.join("\t").replace(/\x00/g,"%00").replace(/%20/g," ")},s.prototype.diff_fromDelta=function(e,t){for(var s=[],n=0,i=0,o=(t=t.replace(/%00/g,"\0")).split(/\t/g),a=0;a<o.length;a++){var c=o[a].substring(1);switch(o[a].charAt(0)){case"+":try{s[n++]=[1,decodeURI(c)]}catch(e){throw new Error("Illegal escape in diff_fromDelta: "+c)}break;case"-":case"=":var u=parseInt(c,10);if(isNaN(u)||u<0)throw new Error("Invalid number in diff_fromDelta: "+c);var d=e.substring(i,i+=u);"="==o[a].charAt(0)?s[n++]=[0,d]:s[n++]=[r,d];break;default:if(o[a])throw new Error("Invalid diff operation in diff_fromDelta: "+o[a])}}if(i!=e.length)throw new Error("Delta length ("+i+") does not equal source text length ("+e.length+").");return s},s.prototype.match_main=function(e,t,s){if(null==e||null==t||null==s)throw new Error("Null input. (match_main)");return s=Math.max(0,Math.min(s,e.length)),e==t?0:e.length?e.substring(s,s+t.length)==t?s:this.match_bitap(e,t,s):-1},s.prototype.match_bitap=function(e,t,s){if(t.length>this.Match_MaxBits)throw new Error("Pattern too long for this browser.");var r=this.match_alphabet(t),n=this;function i(e,r){var i=e/t.length,o=Math.abs(s-r);return n.Match_Distance?i+o/n.Match_Distance:o?1:i}var o=this.Match_Threshold,a=e.indexOf(t,s);-1!=a&&(o=Math.min(i(0,a),o),-1!=(a=e.lastIndexOf(t,s+t.length))&&(o=Math.min(i(0,a),o)));var c,u,d=1<<t.length-1;a=-1;for(var h,l=t.length+e.length,p=0;p<t.length;p++){for(c=0,u=l;c<u;)i(p,s+u)<=o?c=u:l=u,u=Math.floor((l-c)/2+c);l=u;var g=Math.max(1,s-u+1),f=Math.min(s+u,e.length)+t.length,_=Array(f+2);_[f+1]=(1<<p)-1;for(var m=f;m>=g;m--){var b=r[e.charAt(m-1)];if(_[m]=0===p?(_[m+1]<<1|1)&b:(_[m+1]<<1|1)&b|(h[m+1]|h[m])<<1|1|h[m+1],_[m]&d){var w=i(p,m-1);if(w<=o){if(o=w,!((a=m-1)>s))break;g=Math.max(1,2*s-a)}}}if(i(p+1,s)>o)break;h=_}return a},s.prototype.match_alphabet=function(e){for(var t={},s=0;s<e.length;s++)t[e.charAt(s)]=0;for(s=0;s<e.length;s++)t[e.charAt(s)]|=1<<e.length-s-1;return t},s.prototype.patch_addContext=function(e,t){if(0!=t.length){for(var s=t.substring(e.start2,e.start2+e.length1),r=0;t.indexOf(s)!=t.lastIndexOf(s)&&s.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)r+=this.Patch_Margin,s=t.substring(e.start2-r,e.start2+e.length1+r);r+=this.Patch_Margin;var n=t.substring(e.start2-r,e.start2);n&&e.diffs.unshift([0,n]);var i=t.substring(e.start2+e.length1,e.start2+e.length1+r);i&&e.diffs.push([0,i]),e.start1-=n.length,e.start2-=n.length,e.length1+=n.length+i.length,e.length2+=n.length+i.length}},s.prototype.patch_make=function(e,t,s){var i,o;if("string"==typeof e&&"string"==typeof t&&void 0===s)i=e,(o=this.diff_main(i,t,!0)).length>2&&(this.diff_cleanupSemantic(o),this.diff_cleanupEfficiency(o));else if(e&&"object"==typeof e&&void 0===t&&void 0===s)o=e,i=this.diff_text1(o);else if("string"==typeof e&&t&&"object"==typeof t&&void 0===s)i=e,o=t;else{if("string"!=typeof e||"string"!=typeof t||!s||"object"!=typeof s)throw new Error("Unknown call format to patch_make.");i=e,o=s}if(0===o.length)return[];for(var a=[],c=new n,u=0,d=0,h=0,l=i,p=i,g=0;g<o.length;g++){var f=o[g][0],_=o[g][1];switch(u||0===f||(c.start1=d,c.start2=h),f){case 1:c.diffs[u++]=o[g],c.length2+=_.length,p=p.substring(0,h)+_+p.substring(h);break;case r:c.length1+=_.length,c.diffs[u++]=o[g],p=p.substring(0,h)+p.substring(h+_.length);break;case 0:_.length<=2*this.Patch_Margin&&u&&o.length!=g+1?(c.diffs[u++]=o[g],c.length1+=_.length,c.length2+=_.length):_.length>=2*this.Patch_Margin&&u&&(this.patch_addContext(c,l),a.push(c),c=new n,u=0,l=p,d=h)}1!==f&&(d+=_.length),f!==r&&(h+=_.length)}return u&&(this.patch_addContext(c,l),a.push(c)),a},s.prototype.patch_deepCopy=function(e){for(var t=[],s=0;s<e.length;s++){var r=e[s],i=new n;i.diffs=[];for(var o=0;o<r.diffs.length;o++)i.diffs[o]=r.diffs[o].slice();i.start1=r.start1,i.start2=r.start2,i.length1=r.length1,i.length2=r.length2,t[s]=i}return t},s.prototype.patch_apply=function(e,t){if(0==e.length)return[t,[]];e=this.patch_deepCopy(e);var s=this.patch_addPadding(e);t=s+t+s,this.patch_splitMax(e);for(var n=0,i=[],o=0;o<e.length;o++){var a,c,u=e[o].start2+n,d=this.diff_text1(e[o].diffs),h=-1;if(d.length>this.Match_MaxBits?-1!=(a=this.match_main(t,d.substring(0,this.Match_MaxBits),u))&&(-1==(h=this.match_main(t,d.substring(d.length-this.Match_MaxBits),u+d.length-this.Match_MaxBits))||a>=h)&&(a=-1):a=this.match_main(t,d,u),-1==a)i[o]=!1,n-=e[o].length2-e[o].length1;else if(i[o]=!0,n=a-u,d==(c=-1==h?t.substring(a,a+d.length):t.substring(a,h+this.Match_MaxBits)))t=t.substring(0,a)+this.diff_text2(e[o].diffs)+t.substring(a+d.length);else{var l=this.diff_main(d,c,!1);if(d.length>this.Match_MaxBits&&this.diff_levenshtein(l)/d.length>this.Patch_DeleteThreshold)i[o]=!1;else{this.diff_cleanupSemanticLossless(l);for(var p,g=0,f=0;f<e[o].diffs.length;f++){var _=e[o].diffs[f];0!==_[0]&&(p=this.diff_xIndex(l,g)),1===_[0]?t=t.substring(0,a+p)+_[1]+t.substring(a+p):_[0]===r&&(t=t.substring(0,a+p)+t.substring(a+this.diff_xIndex(l,g+_[1].length))),_[0]!==r&&(g+=_[1].length)}}}}return[t=t.substring(s.length,t.length-s.length),i]},s.prototype.patch_addPadding=function(e){for(var t=this.Patch_Margin,s="",r=1;r<=t;r++)s+=String.fromCharCode(r);for(r=0;r<e.length;r++)e[r].start1+=t,e[r].start2+=t;var n=e[0],i=n.diffs;if(0==i.length||0!=i[0][0])i.unshift([0,s]),n.start1-=t,n.start2-=t,n.length1+=t,n.length2+=t;else if(t>i[0][1].length){var o=t-i[0][1].length;i[0][1]=s.substring(i[0][1].length)+i[0][1],n.start1-=o,n.start2-=o,n.length1+=o,n.length2+=o}return 0==(i=(n=e[e.length-1]).diffs).length||0!=i[i.length-1][0]?(i.push([0,s]),n.length1+=t,n.length2+=t):t>i[i.length-1][1].length&&(o=t-i[i.length-1][1].length,i[i.length-1][1]+=s.substring(0,o),n.length1+=o,n.length2+=o),s},s.prototype.patch_splitMax=function(e){for(var t=0;t<e.length;t++)if(e[t].length1>this.Match_MaxBits){var s=e[t];e.splice(t--,1);for(var i=this.Match_MaxBits,o=s.start1,a=s.start2,c="";0!==s.diffs.length;){var u=new n,d=!0;for(u.start1=o-c.length,u.start2=a-c.length,""!==c&&(u.length1=u.length2=c.length,u.diffs.push([0,c]));0!==s.diffs.length&&u.length1<i-this.Patch_Margin;){var h=s.diffs[0][0],l=s.diffs[0][1];1===h?(u.length2+=l.length,a+=l.length,u.diffs.push(s.diffs.shift()),d=!1):h===r&&1==u.diffs.length&&0==u.diffs[0][0]&&l.length>2*i?(u.length1+=l.length,o+=l.length,d=!1,u.diffs.push([h,l]),s.diffs.shift()):(l=l.substring(0,i-u.length1-this.Patch_Margin),u.length1+=l.length,o+=l.length,0===h?(u.length2+=l.length,a+=l.length):d=!1,u.diffs.push([h,l]),l==s.diffs[0][1]?s.diffs.shift():s.diffs[0][1]=s.diffs[0][1].substring(l.length))}c=(c=this.diff_text2(u.diffs)).substring(c.length-this.Patch_Margin);var p=this.diff_text1(s.diffs).substring(0,this.Patch_Margin);""!==p&&(u.length1+=p.length,u.length2+=p.length,0!==u.diffs.length&&0===u.diffs[u.diffs.length-1][0]?u.diffs[u.diffs.length-1][1]+=p:u.diffs.push([0,p])),d||e.splice(++t,0,u)}}},s.prototype.patch_toText=function(e){for(var t=[],s=0;s<e.length;s++)t[s]=e[s];return t.join("")},s.prototype.patch_fromText=function(e){var t=[];if(!e)return t;for(var s=(e=e.replace(/%00/g,"\0")).split("\n"),i=0;i<s.length;){var o=s[i].match(/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/);if(!o)throw new Error("Invalid patch string: "+s[i]);var a=new n;for(t.push(a),a.start1=parseInt(o[1],10),""===o[2]?(a.start1--,a.length1=1):"0"==o[2]?a.length1=0:(a.start1--,a.length1=parseInt(o[2],10)),a.start2=parseInt(o[3],10),""===o[4]?(a.start2--,a.length2=1):"0"==o[4]?a.length2=0:(a.start2--,a.length2=parseInt(o[4],10)),i++;i<s.length;){var c=s[i].charAt(0);try{var u=decodeURI(s[i].substring(1))}catch(e){throw new Error("Illegal escape in patch_fromText: "+u)}if("-"==c)a.diffs.push([r,u]);else if("+"==c)a.diffs.push([1,u]);else if(" "==c)a.diffs.push([0,u]);else{if("@"==c)break;if(""!==c)throw new Error('Invalid patch mode "'+c+'" in: '+u)}i++}}return t},n.prototype.toString=function(){for(var e,t=["@@ -"+(0===this.length1?this.start1+",0":1==this.length1?this.start1+1:this.start1+1+","+this.length1)+" +"+(0===this.length2?this.start2+",0":1==this.length2?this.start2+1:this.start2+1+","+this.length2)+" @@\n"],s=0;s<this.diffs.length;s++){switch(this.diffs[s][0]){case 1:e="+";break;case r:e="-";break;case 0:e=" "}t[s+1]=e+encodeURI(this.diffs[s][1])+"\n"}return t.join("").replace(/\x00/g,"%00").replace(/%20/g," ")},t.diff_match_patch=s,t.patch_obj=n,t.DIFF_DELETE=r,t.DIFF_INSERT=1,t.DIFF_EQUAL=0},"../../node_modules/engine.io-client/node_modules/debug/src/browser.js"(e,t,s){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(n=r))}),t.splice(n,0,s)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=s("../../node_modules/engine.io-client/node_modules/debug/src/common.js")(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},"../../node_modules/engine.io-client/node_modules/debug/src/common.js"(e,t,s){e.exports=function(e){function t(e){let s,n,i,o=null;function a(...e){if(!a.enabled)return;const r=a,n=Number(new Date),i=n-(s||n);r.diff=i,r.prev=s,r.curr=n,s=n,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(s,n)=>{if("%%"===s)return"%";o++;const i=t.formatters[n];if("function"==typeof i){const t=e[o];s=i.call(r,t),e.splice(o,1),o--}return s}),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(n!==t.namespaces&&(n=t.namespaces,i=t.enabled(e)),i),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,s){const r=t(this.namespace+(void 0===s?":":s)+e);return r.log=this.log,r}function n(e,t){let s=0,r=0,n=-1,i=0;for(;s<e.length;)if(r<t.length&&(t[r]===e[s]||"*"===t[r]))"*"===t[r]?(n=r,i=s,r++):(s++,r++);else{if(-1===n)return!1;r=n+1,i++,s=i}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const s=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of s)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const s of t.skips)if(n(e,s))return!1;for(const s of t.names)if(n(e,s))return!0;return!1},t.humanize=s("../../node_modules/engine.io-client/node_modules/ms/index.js"),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(s=>{t[s]=e[s]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t}},"../../node_modules/engine.io-client/node_modules/ms/index.js"(e){var t=1e3,s=60*t,r=60*s,n=24*r,i=7*n;function o(e,t,s,r){var n=t>=1.5*s;return Math.round(e/s)+" "+r+(n?"s":"")}e.exports=function(e,a){a=a||{};var c,u,d=typeof e;if("string"===d&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*i;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*s;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===d&&isFinite(e))return a.long?(c=e,(u=Math.abs(c))>=n?o(c,u,n,"day"):u>=r?o(c,u,r,"hour"):u>=s?o(c,u,s,"minute"):u>=t?o(c,u,t,"second"):c+" ms"):function(e){var i=Math.abs(e);return i>=n?Math.round(e/n)+"d":i>=r?Math.round(e/r)+"h":i>=s?Math.round(e/s)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},"../../node_modules/flat/index.js"(e){function t(e){return e&&e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function s(e){return e}function r(e,r){const n=(r=r||{}).delimiter||".",i=r.maxDepth,o=r.transformKey||s,a={};return function e(s,c,u){u=u||1,Object.keys(s).forEach(function(d){const h=s[d],l=r.safe&&Array.isArray(h),p=Object.prototype.toString.call(h),g=t(h),f="[object Object]"===p||"[object Array]"===p,_=c?c+n+o(d):o(d);if(!l&&!g&&f&&Object.keys(h).length&&(!r.maxDepth||u<i))return e(h,_,u+1);a[_]=h})}(e),a}e.exports=r,r.flatten=r,r.unflatten=function e(n,i){const o=(i=i||{}).delimiter||".",a=i.overwrite||!1,c=i.transformKey||s,u={};if(t(n)||"[object Object]"!==Object.prototype.toString.call(n))return n;function d(e){const t=Number(e);return isNaN(t)||-1!==e.indexOf(".")||i.object?e:t}return n=Object.keys(n).reduce(function(e,t){const s=Object.prototype.toString.call(n[t]);return"[object Object]"!==s&&"[object Array]"!==s||function(e){const t=Object.prototype.toString.call(e),s="[object Object]"===t;return!e||("[object Array]"===t?!e.length:s?!Object.keys(e).length:void 0)}(n[t])?(e[t]=n[t],e):function(e,t,s){return Object.keys(s).reduce(function(t,r){return t[e+o+r]=s[r],t},t)}(t,e,r(n[t],i))},{}),Object.keys(n).forEach(function(t){const s=t.split(o).map(c);let r=d(s.shift()),h=d(s[0]),l=u;for(;void 0!==h;){if("__proto__"===r)return;const e=Object.prototype.toString.call(l[r]),t="[object Object]"===e||"[object Array]"===e;if(!a&&!t&&void 0!==l[r])return;(a&&!t||!a&&null==l[r])&&(l[r]="number"!=typeof h||i.object?{}:[]),l=l[r],s.length>0&&(r=d(s.shift()),h=d(s[0]))}l[r]=e(n[t],i)}),u}},"../../node_modules/get-value/index.js"(e,t,s){const r=s("../../node_modules/isobject/index.js");function n(e,t,s){return"function"==typeof s.join?s.join(e):e[0]+t+e[1]}function i(e,t,s){return"function"!=typeof s.isValid||s.isValid(e,t)}function o(e){return r(e)||Array.isArray(e)||"function"==typeof e}e.exports=function(e,t,s){if(r(s)||(s={default:s}),!o(e))return void 0!==s.default?s.default:e;"number"==typeof t&&(t=String(t));const a=Array.isArray(t),c="string"==typeof t,u=s.separator||".",d=s.joinChar||("string"==typeof u?u:".");if(!c&&!a)return e;if(c&&t in e)return i(t,e,s)?e[t]:s.default;let h=a?t:function(e,t,s){return"function"==typeof s.split?s.split(e):e.split(t)}(t,u,s),l=h.length,p=0;do{let t=h[p];for("number"==typeof t&&(t=String(t));t&&"\\"===t.slice(-1);)t=n([t.slice(0,-1),h[++p]||""],d,s);if(t in e){if(!i(t,e,s))return s.default;e=e[t]}else{let r=!1,o=p+1;for(;o<l;)if(t=n([t,h[o++]],d,s),r=t in e){if(!i(t,e,s))return s.default;e=e[t],p=o-1;break}if(!r)return s.default}}while(++p<l&&o(e));return p===l?e:s.default}},"../../node_modules/is-plain-object/index.js"(e,t,s){"use strict";var r=s("../../node_modules/isobject/index.js");function n(e){return!0===r(e)&&"[object Object]"===Object.prototype.toString.call(e)}e.exports=function(e){var t,s;return!1!==n(e)&&"function"==typeof(t=e.constructor)&&!1!==n(s=t.prototype)&&!1!==s.hasOwnProperty("isPrototypeOf")}},"../../node_modules/is-primitive/index.js"(e){"use strict";e.exports=function(e){return"object"==typeof e?null===e:"function"!=typeof e}},"../../node_modules/isobject/index.js"(e){"use strict";e.exports=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}},"../../node_modules/ms/index.js"(e){var t=1e3,s=60*t,r=60*s,n=24*r,i=7*n;function o(e,t,s,r){var n=t>=1.5*s;return Math.round(e/s)+" "+r+(n?"s":"")}e.exports=function(e,a){a=a||{};var c,u,d=typeof e;if("string"===d&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*i;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*s;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===d&&isFinite(e))return a.long?(c=e,(u=Math.abs(c))>=n?o(c,u,n,"day"):u>=r?o(c,u,r,"hour"):u>=s?o(c,u,s,"minute"):u>=t?o(c,u,t,"second"):c+" ms"):function(e){var i=Math.abs(e);return i>=n?Math.round(e/n)+"d":i>=r?Math.round(e/r)+"h":i>=s?Math.round(e/s)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},"../../node_modules/oidc-client-ts/dist/umd/oidc-client-ts.js"(e,t,s){"use strict";var r,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var s in t)n(e,s,{get:t[s],enumerable:!0})})(c,{AccessTokenEvents:()=>x,CheckSessionIFrame:()=>T,DPoPState:()=>z,ErrorResponse:()=>j,ErrorTimeout:()=>E,InMemoryWebStorage:()=>P,IndexedDbDPoPStore:()=>fe,Log:()=>p,Logger:()=>g,MetadataService:()=>A,OidcClient:()=>Q,OidcClientSettingsStore:()=>F,SessionMonitor:()=>Y,SigninResponse:()=>H,SigninState:()=>L,SignoutResponse:()=>W,State:()=>D,User:()=>X,UserManager:()=>pe,UserManagerSettingsStore:()=>ne,Version:()=>ge,WebStorageStateStore:()=>R}),e.exports=(r=c,((e,t,s,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))a.call(e,s)||void 0===s||n(e,s,{get:()=>t[s],enumerable:!(r=i(t,s))||r.enumerable});return e})(n({},"__esModule",{value:!0}),r));var u,d,h,l={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},p=(e=>(e[e.NONE=0]="NONE",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e))(p||{});(h=p||(p={})).reset=function(){u=3,d=l},h.setLevel=function(e){if(!(0<=e&&e<=4))throw new Error("Invalid log level");u=e},h.setLogger=function(e){d=e};var g=class e{constructor(e){this._name=e}debug(...t){u>=4&&d.debug(e._format(this._name,this._method),...t)}info(...t){u>=3&&d.info(e._format(this._name,this._method),...t)}warn(...t){u>=2&&d.warn(e._format(this._name,this._method),...t)}error(...t){u>=1&&d.error(e._format(this._name,this._method),...t)}throw(e){throw this.error(e),e}create(e){const t=Object.create(this);return t._method=e,t.debug("begin"),t}static createStatic(t,s){const r=new e(`${t}.${s}`);return r.debug("begin"),r}static _format(e,t){const s=`[${e}]`;return t?`${s} ${t}:`:s}static debug(t,...s){u>=4&&d.debug(e._format(t),...s)}static info(t,...s){u>=3&&d.info(e._format(t),...s)}static warn(t,...s){u>=2&&d.warn(e._format(t),...s)}static error(t,...s){u>=1&&d.error(e._format(t),...s)}};p.reset();var f=s("../../node_modules/jwt-decode/build/cjs/index.js"),_=class{static decode(e){try{return(0,f.jwtDecode)(e)}catch(e){throw g.error("JwtUtils.decode",e),e}}static async generateSignedJwt(e,t,s){const r=`${w.encodeBase64Url((new TextEncoder).encode(JSON.stringify(e)))}.${w.encodeBase64Url((new TextEncoder).encode(JSON.stringify(t)))}`,n=await window.crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},s,(new TextEncoder).encode(r));return`${r}.${w.encodeBase64Url(new Uint8Array(n))}`}},m=e=>btoa([...new Uint8Array(e)].map(e=>String.fromCharCode(e)).join("")),b=class e{static _randomWord(){const e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}static generateUUIDv4(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^e._randomWord()&15>>+t/4).toString(16)).replace(/-/g,"")}static generateCodeVerifier(){return e.generateUUIDv4()+e.generateUUIDv4()+e.generateUUIDv4()}static async generateCodeChallenge(e){if(!crypto.subtle)throw new Error("Crypto.subtle is available only in secure contexts (HTTPS).");try{const t=(new TextEncoder).encode(e),s=await crypto.subtle.digest("SHA-256",t);return m(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(e){throw g.error("CryptoUtils.generateCodeChallenge",e),e}}static generateBasicAuth(e,t){const s=(new TextEncoder).encode([e,t].join(":"));return m(s)}static async hash(e,t){const s=(new TextEncoder).encode(t),r=await crypto.subtle.digest(e,s);return new Uint8Array(r)}static async customCalculateJwkThumbprint(t){let s;switch(t.kty){case"RSA":s={e:t.e,kty:t.kty,n:t.n};break;case"EC":s={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case"OKP":s={crv:t.crv,kty:t.kty,x:t.x};break;case"oct":s={crv:t.k,kty:t.kty};break;default:throw new Error("Unknown jwk type")}const r=await e.hash("SHA-256",JSON.stringify(s));return e.encodeBase64Url(r)}static async generateDPoPProof({url:t,accessToken:s,httpMethod:r,keyPair:n,nonce:i}){let o,a;const c={jti:window.crypto.randomUUID(),htm:null!=r?r:"GET",htu:t,iat:Math.floor(Date.now()/1e3)};s&&(o=await e.hash("SHA-256",s),a=e.encodeBase64Url(o),c.ath=a),i&&(c.nonce=i);try{const e=await crypto.subtle.exportKey("jwk",n.publicKey),t={alg:"ES256",typ:"dpop+jwt",jwk:{crv:e.crv,kty:e.kty,x:e.x,y:e.y}};return await _.generateSignedJwt(t,c,n.privateKey)}catch(e){throw e instanceof TypeError?new Error(`Error exporting dpop public key: ${e.message}`):e}}static async generateDPoPJkt(t){try{const s=await crypto.subtle.exportKey("jwk",t.publicKey);return await e.customCalculateJwkThumbprint(s)}catch(e){throw e instanceof TypeError?new Error(`Could not retrieve dpop keys from storage: ${e.message}`):e}}static async generateDPoPKeys(){return await window.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign","verify"])}};b.encodeBase64Url=e=>m(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");var w=b,y=class{constructor(e){this._name=e,this._callbacks=[],this._logger=new g(`Event('${this._name}')`)}addHandler(e){return this._callbacks.push(e),()=>this.removeHandler(e)}removeHandler(e){const t=this._callbacks.lastIndexOf(e);t>=0&&this._callbacks.splice(t,1)}async raise(...e){this._logger.debug("raise:",...e);for(const t of this._callbacks)await t(...e)}},v=class{static center({...e}){var t;return null==e.width&&(e.width=null!=(t=[800,720,600,480].find(e=>e<=window.outerWidth/1.618))?t:360),null!=e.left||(e.left=Math.max(0,Math.round(window.screenX+(window.outerWidth-e.width)/2))),null!=e.height&&(null!=e.top||(e.top=Math.max(0,Math.round(window.screenY+(window.outerHeight-e.height)/2)))),e}static serialize(e){return Object.entries(e).filter(([,e])=>null!=e).map(([e,t])=>`${e}=${"boolean"!=typeof t?t:t?"yes":"no"}`).join(",")}},k=class e extends y{constructor(){super(...arguments),this._logger=new g(`Timer('${this._name}')`),this._timerHandle=null,this._expiration=0,this._callback=()=>{const t=this._expiration-e.getEpochTime();this._logger.debug("timer completes in",t),this._expiration<=e.getEpochTime()&&(this.cancel(),super.raise())}}static getEpochTime(){return Math.floor(Date.now()/1e3)}init(t){const s=this._logger.create("init");t=Math.max(Math.floor(t),1);const r=e.getEpochTime()+t;if(this.expiration===r&&this._timerHandle)return void s.debug("skipping since already initialized for expiration at",this.expiration);this.cancel(),s.debug("using duration",t),this._expiration=r;const n=Math.min(t,5);this._timerHandle=setInterval(this._callback,1e3*n)}get expiration(){return this._expiration}cancel(){this._logger.create("cancel"),this._timerHandle&&(clearInterval(this._timerHandle),this._timerHandle=null)}},S=class{static readParams(e,t="query"){if(!e)throw new TypeError("Invalid URL");const s=new URL(e,"http://127.0.0.1")["fragment"===t?"hash":"search"];return new URLSearchParams(s.slice(1))}},C=";",j=class extends Error{constructor(e,t){var s,r,n;if(super(e.error_description||e.error||""),this.form=t,this.name="ErrorResponse",!e.error)throw g.error("ErrorResponse","No error passed"),new Error("No error passed");this.error=e.error,this.error_description=null!=(s=e.error_description)?s:null,this.error_uri=null!=(r=e.error_uri)?r:null,this.state=e.userState,this.session_state=null!=(n=e.session_state)?n:null,this.url_state=e.url_state}},E=class extends Error{constructor(e){super(e),this.name="ErrorTimeout"}},x=class{constructor(e){this._logger=new g("AccessTokenEvents"),this._expiringTimer=new k("Access token expiring"),this._expiredTimer=new k("Access token expired"),this._expiringNotificationTimeInSeconds=e.expiringNotificationTimeInSeconds}async load(e){const t=this._logger.create("load");if(e.access_token&&void 0!==e.expires_in){const s=e.expires_in;if(t.debug("access token present, remaining duration:",s),s>0){let e=s-this._expiringNotificationTimeInSeconds;e<=0&&(e=1),t.debug("registering expiring timer, raising in",e,"seconds"),this._expiringTimer.init(e)}else t.debug("canceling existing expiring timer because we're past expiration."),this._expiringTimer.cancel();const r=s+1;t.debug("registering expired timer, raising in",r,"seconds"),this._expiredTimer.init(r)}else this._expiringTimer.cancel(),this._expiredTimer.cancel()}async unload(){this._logger.debug("unload: canceling existing access token timers"),this._expiringTimer.cancel(),this._expiredTimer.cancel()}addAccessTokenExpiring(e){return this._expiringTimer.addHandler(e)}removeAccessTokenExpiring(e){this._expiringTimer.removeHandler(e)}addAccessTokenExpired(e){return this._expiredTimer.addHandler(e)}removeAccessTokenExpired(e){this._expiredTimer.removeHandler(e)}},T=class{constructor(e,t,s,r,n){this._callback=e,this._client_id=t,this._intervalInSeconds=r,this._stopOnError=n,this._logger=new g("CheckSessionIFrame"),this._timer=null,this._session_state=null,this._message=e=>{e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&("error"===e.data?(this._logger.error("error message from check session op iframe"),this._stopOnError&&this.stop()):"changed"===e.data?(this._logger.debug("changed message from check session op iframe"),this.stop(),this._callback()):this._logger.debug(e.data+" message from check session op iframe"))};const i=new URL(s);this._frame_origin=i.origin,this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="fixed",this._frame.style.left="-1000px",this._frame.style.top="0",this._frame.width="0",this._frame.height="0",this._frame.src=i.href}load(){return new Promise(e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),window.addEventListener("message",this._message,!1)})}start(e){if(this._session_state===e)return;this._logger.create("start"),this.stop(),this._session_state=e;const t=()=>{this._frame.contentWindow&&this._session_state&&this._frame.contentWindow.postMessage(this._client_id+" "+this._session_state,this._frame_origin)};t(),this._timer=setInterval(t,1e3*this._intervalInSeconds)}stop(){this._logger.create("stop"),this._session_state=null,this._timer&&(clearInterval(this._timer),this._timer=null)}},P=class{constructor(){this._logger=new g("InMemoryWebStorage"),this._data={}}clear(){this._logger.create("clear"),this._data={}}getItem(e){return this._logger.create(`getItem('${e}')`),this._data[e]}setItem(e,t){this._logger.create(`setItem('${e}')`),this._data[e]=t}removeItem(e){this._logger.create(`removeItem('${e}')`),delete this._data[e]}get length(){return Object.getOwnPropertyNames(this._data).length}key(e){return Object.getOwnPropertyNames(this._data)[e]}},I=class extends Error{constructor(e,t){super(t),this.name="ErrorDPoPNonce",this.nonce=e}},O=class{constructor(e=[],t=null,s={}){this._jwtHandler=t,this._extraHeaders=s,this._logger=new g("JsonService"),this._contentTypes=[],this._contentTypes.push(...e,"application/json"),t&&this._contentTypes.push("application/jwt")}async fetchWithTimeout(e,t={}){const{timeoutInSeconds:s,...r}=t;if(!s)return await fetch(e,r);const n=new AbortController,i=setTimeout(()=>n.abort(),1e3*s);try{return await fetch(e,{...t,signal:n.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw new E("Network timed out");throw e}finally{clearTimeout(i)}}async getJson(e,{token:t,credentials:s,timeoutInSeconds:r}={}){const n=this._logger.create("getJson"),i={Accept:this._contentTypes.join(", ")};let o;t&&(n.debug("token passed, setting Authorization header"),i.Authorization="Bearer "+t),this._appendExtraHeaders(i);try{n.debug("url:",e),o=await this.fetchWithTimeout(e,{method:"GET",headers:i,timeoutInSeconds:r,credentials:s})}catch(e){throw n.error("Network Error"),e}n.debug("HTTP response received, status",o.status);const a=o.headers.get("Content-Type");if(a&&!this._contentTypes.find(e=>a.startsWith(e))&&n.throw(new Error(`Invalid response Content-Type: ${null!=a?a:"undefined"}, from URL: ${e}`)),o.ok&&this._jwtHandler&&(null==a?void 0:a.startsWith("application/jwt")))return await this._jwtHandler(await o.text());let c;try{c=await o.json()}catch(e){if(n.error("Error parsing JSON response",e),o.ok)throw e;throw new Error(`${o.statusText} (${o.status})`)}if(!o.ok){if(n.error("Error from server:",c),c.error)throw new j(c);throw new Error(`${o.statusText} (${o.status}): ${JSON.stringify(c)}`)}return c}async postForm(e,{body:t,basicAuth:s,timeoutInSeconds:r,initCredentials:n,extraHeaders:i}){const o=this._logger.create("postForm"),a={Accept:this._contentTypes.join(", "),"Content-Type":"application/x-www-form-urlencoded",...i};let c;void 0!==s&&(a.Authorization="Basic "+s),this._appendExtraHeaders(a);try{o.debug("url:",e),c=await this.fetchWithTimeout(e,{method:"POST",headers:a,body:t,timeoutInSeconds:r,credentials:n})}catch(e){throw o.error("Network error"),e}o.debug("HTTP response received, status",c.status);const u=c.headers.get("Content-Type");if(u&&!this._contentTypes.find(e=>u.startsWith(e)))throw new Error(`Invalid response Content-Type: ${null!=u?u:"undefined"}, from URL: ${e}`);const d=await c.text();let h={};if(d)try{h=JSON.parse(d)}catch(e){if(o.error("Error parsing JSON response",e),c.ok)throw e;throw new Error(`${c.statusText} (${c.status})`)}if(!c.ok){if(o.error("Error from server:",h),c.headers.has("dpop-nonce")){const e=c.headers.get("dpop-nonce");throw new I(e,`${JSON.stringify(h)}`)}if(h.error)throw new j(h,t);throw new Error(`${c.statusText} (${c.status}): ${JSON.stringify(h)}`)}return h}_appendExtraHeaders(e){const t=this._logger.create("appendExtraHeaders"),s=Object.keys(this._extraHeaders),r=["accept","content-type"],n=["authorization"];0!==s.length&&s.forEach(s=>{if(r.includes(s.toLocaleLowerCase()))return void t.warn("Protected header could not be set",s,r);if(n.includes(s.toLocaleLowerCase())&&Object.keys(e).includes(s))return void t.warn("Header could not be overridden",s,n);const i="function"==typeof this._extraHeaders[s]?this._extraHeaders[s]():this._extraHeaders[s];i&&""!==i&&(e[s]=i)})}},A=class{constructor(e){this._settings=e,this._logger=new g("MetadataService"),this._signingKeys=null,this._metadata=null,this._metadataUrl=this._settings.metadataUrl,this._jsonService=new O(["application/jwk-set+json"],null,this._settings.extraHeaders),this._settings.signingKeys&&(this._logger.debug("using signingKeys from settings"),this._signingKeys=this._settings.signingKeys),this._settings.metadata&&(this._logger.debug("using metadata from settings"),this._metadata=this._settings.metadata),this._settings.fetchRequestCredentials&&(this._logger.debug("using fetchRequestCredentials from settings"),this._fetchRequestCredentials=this._settings.fetchRequestCredentials)}resetSigningKeys(){this._signingKeys=null}async getMetadata(){const e=this._logger.create("getMetadata");if(this._metadata)return e.debug("using cached values"),this._metadata;if(!this._metadataUrl)throw e.throw(new Error("No authority or metadataUrl configured on settings")),null;e.debug("getting metadata from",this._metadataUrl);const t=await this._jsonService.getJson(this._metadataUrl,{credentials:this._fetchRequestCredentials,timeoutInSeconds:this._settings.requestTimeoutInSeconds});return e.debug("merging remote JSON with seed metadata"),this._metadata=Object.assign({},t,this._settings.metadataSeed),this._metadata}getIssuer(){return this._getMetadataProperty("issuer")}getAuthorizationEndpoint(){return this._getMetadataProperty("authorization_endpoint")}getUserInfoEndpoint(){return this._getMetadataProperty("userinfo_endpoint")}getTokenEndpoint(e=!0){return this._getMetadataProperty("token_endpoint",e)}getCheckSessionIframe(){return this._getMetadataProperty("check_session_iframe",!0)}getEndSessionEndpoint(){return this._getMetadataProperty("end_session_endpoint",!0)}getRevocationEndpoint(e=!0){return this._getMetadataProperty("revocation_endpoint",e)}getKeysEndpoint(e=!0){return this._getMetadataProperty("jwks_uri",e)}async _getMetadataProperty(e,t=!1){const s=this._logger.create(`_getMetadataProperty('${e}')`),r=await this.getMetadata();if(s.debug("resolved"),void 0===r[e]){if(!0===t)return void s.warn("Metadata does not contain optional property");s.throw(new Error("Metadata does not contain property "+e))}return r[e]}async getSigningKeys(){const e=this._logger.create("getSigningKeys");if(this._signingKeys)return e.debug("returning signingKeys from cache"),this._signingKeys;const t=await this.getKeysEndpoint(!1);e.debug("got jwks_uri",t);const s=await this._jsonService.getJson(t,{timeoutInSeconds:this._settings.requestTimeoutInSeconds});if(e.debug("got key set",s),!Array.isArray(s.keys))throw e.throw(new Error("Missing keys on keyset")),null;return this._signingKeys=s.keys,this._signingKeys}},R=class{constructor({prefix:e="oidc.",store:t=localStorage}={}){this._logger=new g("WebStorageStateStore"),this._store=t,this._prefix=e}async set(e,t){this._logger.create(`set('${e}')`),e=this._prefix+e,await this._store.setItem(e,t)}async get(e){return this._logger.create(`get('${e}')`),e=this._prefix+e,await this._store.getItem(e)}async remove(e){this._logger.create(`remove('${e}')`),e=this._prefix+e;const t=await this._store.getItem(e);return await this._store.removeItem(e),t}async getAllKeys(){this._logger.create("getAllKeys");const e=await this._store.length,t=[];for(let s=0;s<e;s++){const e=await this._store.key(s);e&&0===e.indexOf(this._prefix)&&t.push(e.substr(this._prefix.length))}return t}},F=class{constructor({authority:e,metadataUrl:t,metadata:s,signingKeys:r,metadataSeed:n,client_id:i,client_secret:o,response_type:a="code",scope:c="openid",redirect_uri:u,post_logout_redirect_uri:d,client_authentication:h="client_secret_post",prompt:l,display:p,max_age:g,ui_locales:f,acr_values:_,resource:m,response_mode:b,filterProtocolClaims:w=!0,loadUserInfo:y=!1,requestTimeoutInSeconds:v,staleStateAgeInSeconds:k=900,mergeClaimsStrategy:S={array:"replace"},disablePKCE:C=!1,stateStore:j,revokeTokenAdditionalContentTypes:E,fetchRequestCredentials:x,refreshTokenAllowedScope:T,extraQueryParams:I={},extraTokenParams:O={},extraHeaders:A={},dpop:F,omitScopeWhenRequesting:M=!1}){var U;if(this.authority=e,t?this.metadataUrl=t:(this.metadataUrl=e,e&&(this.metadataUrl.endsWith("/")||(this.metadataUrl+="/"),this.metadataUrl+=".well-known/openid-configuration")),this.metadata=s,this.metadataSeed=n,this.signingKeys=r,this.client_id=i,this.client_secret=o,this.response_type=a,this.scope=c,this.redirect_uri=u,this.post_logout_redirect_uri=d,this.client_authentication=h,this.prompt=l,this.display=p,this.max_age=g,this.ui_locales=f,this.acr_values=_,this.resource=m,this.response_mode=b,this.filterProtocolClaims=null==w||w,this.loadUserInfo=!!y,this.staleStateAgeInSeconds=k,this.mergeClaimsStrategy=S,this.omitScopeWhenRequesting=M,this.disablePKCE=!!C,this.revokeTokenAdditionalContentTypes=E,this.fetchRequestCredentials=x||"same-origin",this.requestTimeoutInSeconds=v,j)this.stateStore=j;else{const e="undefined"!=typeof window?window.localStorage:new P;this.stateStore=new R({store:e})}if(this.refreshTokenAllowedScope=T,this.extraQueryParams=I,this.extraTokenParams=O,this.extraHeaders=A,this.dpop=F,this.dpop&&!(null==(U=this.dpop)?void 0:U.store))throw new Error("A DPoPStore is required when dpop is enabled")}},M=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new g("UserInfoService"),this._getClaimsFromJwt=async e=>{const t=this._logger.create("_getClaimsFromJwt");try{const s=_.decode(e);return t.debug("JWT decoding successful"),s}catch(e){throw t.error("Error parsing JWT response"),e}},this._jsonService=new O(void 0,this._getClaimsFromJwt,this._settings.extraHeaders)}async getClaims(e){const t=this._logger.create("getClaims");e||this._logger.throw(new Error("No token passed"));const s=await this._metadataService.getUserInfoEndpoint();t.debug("got userinfo url",s);const r=await this._jsonService.getJson(s,{token:e,credentials:this._settings.fetchRequestCredentials,timeoutInSeconds:this._settings.requestTimeoutInSeconds});return t.debug("got claims",r),r}},U=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new g("TokenClient"),this._jsonService=new O(this._settings.revokeTokenAdditionalContentTypes,null,this._settings.extraHeaders)}async exchangeCode({grant_type:e="authorization_code",redirect_uri:t=this._settings.redirect_uri,client_id:s=this._settings.client_id,client_secret:r=this._settings.client_secret,extraHeaders:n,...i}){const o=this._logger.create("exchangeCode");s||o.throw(new Error("A client_id is required")),t||o.throw(new Error("A redirect_uri is required")),i.code||o.throw(new Error("A code is required"));const a=new URLSearchParams({grant_type:e,redirect_uri:t});for(const[e,t]of Object.entries(i))null!=t&&a.set(e,t);let c;switch(this._settings.client_authentication){case"client_secret_basic":if(null==r)throw o.throw(new Error("A client_secret is required")),null;c=w.generateBasicAuth(s,r);break;case"client_secret_post":a.append("client_id",s),r&&a.append("client_secret",r)}const u=await this._metadataService.getTokenEndpoint(!1);o.debug("got token endpoint");const d=await this._jsonService.postForm(u,{body:a,basicAuth:c,timeoutInSeconds:this._settings.requestTimeoutInSeconds,initCredentials:this._settings.fetchRequestCredentials,extraHeaders:n});return o.debug("got response"),d}async exchangeCredentials({grant_type:e="password",client_id:t=this._settings.client_id,client_secret:s=this._settings.client_secret,scope:r=this._settings.scope,...n}){const i=this._logger.create("exchangeCredentials");t||i.throw(new Error("A client_id is required"));const o=new URLSearchParams({grant_type:e});this._settings.omitScopeWhenRequesting||o.set("scope",r);for(const[e,t]of Object.entries(n))null!=t&&o.set(e,t);let a;switch(this._settings.client_authentication){case"client_secret_basic":if(null==s)throw i.throw(new Error("A client_secret is required")),null;a=w.generateBasicAuth(t,s);break;case"client_secret_post":o.append("client_id",t),s&&o.append("client_secret",s)}const c=await this._metadataService.getTokenEndpoint(!1);i.debug("got token endpoint");const u=await this._jsonService.postForm(c,{body:o,basicAuth:a,timeoutInSeconds:this._settings.requestTimeoutInSeconds,initCredentials:this._settings.fetchRequestCredentials});return i.debug("got response"),u}async exchangeRefreshToken({grant_type:e="refresh_token",client_id:t=this._settings.client_id,client_secret:s=this._settings.client_secret,timeoutInSeconds:r,extraHeaders:n,...i}){const o=this._logger.create("exchangeRefreshToken");t||o.throw(new Error("A client_id is required")),i.refresh_token||o.throw(new Error("A refresh_token is required"));const a=new URLSearchParams({grant_type:e});for(const[e,t]of Object.entries(i))Array.isArray(t)?t.forEach(t=>a.append(e,t)):null!=t&&a.set(e,t);let c;switch(this._settings.client_authentication){case"client_secret_basic":if(null==s)throw o.throw(new Error("A client_secret is required")),null;c=w.generateBasicAuth(t,s);break;case"client_secret_post":a.append("client_id",t),s&&a.append("client_secret",s)}const u=await this._metadataService.getTokenEndpoint(!1);o.debug("got token endpoint");const d=await this._jsonService.postForm(u,{body:a,basicAuth:c,timeoutInSeconds:r,initCredentials:this._settings.fetchRequestCredentials,extraHeaders:n});return o.debug("got response"),d}async revoke(e){var t;const s=this._logger.create("revoke");e.token||s.throw(new Error("A token is required"));const r=await this._metadataService.getRevocationEndpoint(!1);s.debug(`got revocation endpoint, revoking ${null!=(t=e.token_type_hint)?t:"default token type"}`);const n=new URLSearchParams;for(const[t,s]of Object.entries(e))null!=s&&n.set(t,s);n.set("client_id",this._settings.client_id),this._settings.client_secret&&n.set("client_secret",this._settings.client_secret),await this._jsonService.postForm(r,{body:n,timeoutInSeconds:this._settings.requestTimeoutInSeconds}),s.debug("got response")}},N=class{constructor(e,t,s){this._settings=e,this._metadataService=t,this._claimsService=s,this._logger=new g("ResponseValidator"),this._userInfoService=new M(this._settings,this._metadataService),this._tokenClient=new U(this._settings,this._metadataService)}async validateSigninResponse(e,t,s){const r=this._logger.create("validateSigninResponse");this._processSigninState(e,t),r.debug("state processed"),await this._processCode(e,t,s),r.debug("code processed"),e.isOpenId&&this._validateIdTokenAttributes(e),r.debug("tokens validated"),await this._processClaims(e,null==t?void 0:t.skipUserInfo,e.isOpenId),r.debug("claims processed")}async validateCredentialsResponse(e,t){const s=this._logger.create("validateCredentialsResponse"),r=e.isOpenId&&!!e.id_token;r&&this._validateIdTokenAttributes(e),s.debug("tokens validated"),await this._processClaims(e,t,r),s.debug("claims processed")}async validateRefreshResponse(e,t){const s=this._logger.create("validateRefreshResponse");e.userState=t.data,null!=e.session_state||(e.session_state=t.session_state),null!=e.scope||(e.scope=t.scope),e.isOpenId&&e.id_token&&(this._validateIdTokenAttributes(e,t.id_token),s.debug("ID Token validated")),e.id_token||(e.id_token=t.id_token,e.profile=t.profile);const r=e.isOpenId&&!!e.id_token;await this._processClaims(e,!1,r),s.debug("claims processed")}validateSignoutResponse(e,t){const s=this._logger.create("validateSignoutResponse");if(t.id!==e.state&&s.throw(new Error("State does not match")),s.debug("state validated"),e.userState=t.data,e.error)throw s.warn("Response was error",e.error),new j(e)}_processSigninState(e,t){const s=this._logger.create("_processSigninState");if(t.id!==e.state&&s.throw(new Error("State does not match")),t.client_id||s.throw(new Error("No client_id on state")),t.authority||s.throw(new Error("No authority on state")),this._settings.authority!==t.authority&&s.throw(new Error("authority mismatch on settings vs. signin state")),this._settings.client_id&&this._settings.client_id!==t.client_id&&s.throw(new Error("client_id mismatch on settings vs. signin state")),s.debug("state validated"),e.userState=t.data,e.url_state=t.url_state,null!=e.scope||(e.scope=t.scope),e.error)throw s.warn("Response was error",e.error),new j(e);t.code_verifier&&!e.code&&s.throw(new Error("Expected code in response"))}async _processClaims(e,t=!1,s=!0){const r=this._logger.create("_processClaims");if(e.profile=this._claimsService.filterProtocolClaims(e.profile),t||!this._settings.loadUserInfo||!e.access_token)return void r.debug("not loading user info");r.debug("loading user info");const n=await this._userInfoService.getClaims(e.access_token);r.debug("user info claims received from user info endpoint"),s&&n.sub!==e.profile.sub&&r.throw(new Error("subject from UserInfo response does not match subject in ID Token")),e.profile=this._claimsService.mergeClaims(e.profile,this._claimsService.filterProtocolClaims(n)),r.debug("user info claims received, updated profile:",e.profile)}async _processCode(e,t,s){const r=this._logger.create("_processCode");if(e.code){r.debug("Validating code");const n=await this._tokenClient.exchangeCode({client_id:t.client_id,client_secret:t.client_secret,code:e.code,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier,extraHeaders:s,...t.extraTokenParams});Object.assign(e,n)}else r.debug("No code to process")}_validateIdTokenAttributes(e,t){var s;const r=this._logger.create("_validateIdTokenAttributes");r.debug("decoding ID Token JWT");const n=_.decode(null!=(s=e.id_token)?s:"");if(n.sub||r.throw(new Error("ID Token is missing a subject claim")),t){const e=_.decode(t);n.sub!==e.sub&&r.throw(new Error("sub in id_token does not match current sub")),n.auth_time&&n.auth_time!==e.auth_time&&r.throw(new Error("auth_time in id_token does not match original auth_time")),n.azp&&n.azp!==e.azp&&r.throw(new Error("azp in id_token does not match original azp")),!n.azp&&e.azp&&r.throw(new Error("azp not in id_token, but present in original id_token"))}e.profile=n}},D=class e{constructor(e){this.id=e.id||w.generateUUIDv4(),this.data=e.data,e.created&&e.created>0?this.created=e.created:this.created=k.getEpochTime(),this.request_type=e.request_type,this.url_state=e.url_state}toStorageString(){return new g("State").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,url_state:this.url_state})}static fromStorageString(t){return g.createStatic("State","fromStorageString"),Promise.resolve(new e(JSON.parse(t)))}static async clearStaleState(t,s){const r=g.createStatic("State","clearStaleState"),n=k.getEpochTime()-s,i=await t.getAllKeys();r.debug("got keys",i);for(let s=0;s<i.length;s++){const o=i[s],a=await t.get(o);let c=!1;if(a)try{const t=await e.fromStorageString(a);r.debug("got item from key:",o,t.created),t.created<=n&&(c=!0)}catch(e){r.error("Error parsing state for key:",o,e),c=!0}else r.debug("no item in storage for key:",o),c=!0;c&&(r.debug("removed item for key:",o),t.remove(o))}}},L=class e extends D{constructor(e){super(e),this.code_verifier=e.code_verifier,this.code_challenge=e.code_challenge,this.authority=e.authority,this.client_id=e.client_id,this.redirect_uri=e.redirect_uri,this.scope=e.scope,this.client_secret=e.client_secret,this.extraTokenParams=e.extraTokenParams,this.response_mode=e.response_mode,this.skipUserInfo=e.skipUserInfo}static async create(t){const s=!0===t.code_verifier?w.generateCodeVerifier():t.code_verifier||void 0,r=s?await w.generateCodeChallenge(s):void 0;return new e({...t,code_verifier:s,code_challenge:r})}toStorageString(){return new g("SigninState").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,url_state:this.url_state,code_verifier:this.code_verifier,authority:this.authority,client_id:this.client_id,redirect_uri:this.redirect_uri,scope:this.scope,client_secret:this.client_secret,extraTokenParams:this.extraTokenParams,response_mode:this.response_mode,skipUserInfo:this.skipUserInfo})}static fromStorageString(t){g.createStatic("SigninState","fromStorageString");const s=JSON.parse(t);return e.create(s)}},q=class e{constructor(e){this.url=e.url,this.state=e.state}static async create({url:t,authority:s,client_id:r,redirect_uri:n,response_type:i,scope:o,state_data:a,response_mode:c,request_type:u,client_secret:d,nonce:h,url_state:l,resource:p,skipUserInfo:g,extraQueryParams:f,extraTokenParams:_,disablePKCE:m,dpopJkt:b,omitScopeWhenRequesting:w,...y}){if(!t)throw this._logger.error("create: No url passed"),new Error("url");if(!r)throw this._logger.error("create: No client_id passed"),new Error("client_id");if(!n)throw this._logger.error("create: No redirect_uri passed"),new Error("redirect_uri");if(!i)throw this._logger.error("create: No response_type passed"),new Error("response_type");if(!o)throw this._logger.error("create: No scope passed"),new Error("scope");if(!s)throw this._logger.error("create: No authority passed"),new Error("authority");const v=await L.create({data:a,request_type:u,url_state:l,code_verifier:!m,client_id:r,authority:s,redirect_uri:n,response_mode:c,client_secret:d,scope:o,extraTokenParams:_,skipUserInfo:g}),k=new URL(t);k.searchParams.append("client_id",r),k.searchParams.append("redirect_uri",n),k.searchParams.append("response_type",i),w||k.searchParams.append("scope",o),h&&k.searchParams.append("nonce",h),b&&k.searchParams.append("dpop_jkt",b);let S=v.id;l&&(S=`${S}${C}${l}`),k.searchParams.append("state",S),v.code_challenge&&(k.searchParams.append("code_challenge",v.code_challenge),k.searchParams.append("code_challenge_method","S256")),p&&(Array.isArray(p)?p:[p]).forEach(e=>k.searchParams.append("resource",e));for(const[e,t]of Object.entries({response_mode:c,...y,...f}))null!=t&&k.searchParams.append(e,t.toString());return new e({url:k.href,state:v})}};q._logger=new g("SigninRequest");var B=q,H=class{constructor(e){if(this.access_token="",this.token_type="",this.profile={},this.state=e.get("state"),this.session_state=e.get("session_state"),this.state){const e=decodeURIComponent(this.state).split(C);this.state=e[0],e.length>1&&(this.url_state=e.slice(1).join(C))}this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri"),this.code=e.get("code")}get expires_in(){if(void 0!==this.expires_at)return this.expires_at-k.getEpochTime()}set expires_in(e){"string"==typeof e&&(e=Number(e)),void 0!==e&&e>=0&&(this.expires_at=Math.floor(e)+k.getEpochTime())}get isOpenId(){var e;return(null==(e=this.scope)?void 0:e.split(" ").includes("openid"))||!!this.id_token}},$=class{constructor({url:e,state_data:t,id_token_hint:s,post_logout_redirect_uri:r,extraQueryParams:n,request_type:i,client_id:o,url_state:a}){if(this._logger=new g("SignoutRequest"),!e)throw this._logger.error("ctor: No url passed"),new Error("url");const c=new URL(e);if(s&&c.searchParams.append("id_token_hint",s),o&&c.searchParams.append("client_id",o),r&&(c.searchParams.append("post_logout_redirect_uri",r),t||a)){this.state=new D({data:t,request_type:i,url_state:a});let e=this.state.id;a&&(e=`${e}${C}${a}`),c.searchParams.append("state",e)}for(const[e,t]of Object.entries({...n}))null!=t&&c.searchParams.append(e,t.toString());this.url=c.href}},W=class{constructor(e){if(this.state=e.get("state"),this.state){const e=decodeURIComponent(this.state).split(C);this.state=e[0],e.length>1&&(this.url_state=e.slice(1).join(C))}this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri")}},J=["nbf","jti","auth_time","nonce","acr","amr","azp","at_hash"],K=["sub","iss","aud","exp","iat"],V=class{constructor(e){this._settings=e,this._logger=new g("ClaimsService")}filterProtocolClaims(e){const t={...e};if(this._settings.filterProtocolClaims){let e;e=Array.isArray(this._settings.filterProtocolClaims)?this._settings.filterProtocolClaims:J;for(const s of e)K.includes(s)||delete t[s]}return t}mergeClaims(e,t){const s={...e};for(const[e,r]of Object.entries(t))if(s[e]!==r)if(Array.isArray(s[e])||Array.isArray(r))if("replace"==this._settings.mergeClaimsStrategy.array)s[e]=r;else{const t=Array.isArray(s[e])?s[e]:[s[e]];for(const e of Array.isArray(r)?r:[r])t.includes(e)||t.push(e);s[e]=t}else"object"==typeof s[e]&&"object"==typeof r?s[e]=this.mergeClaims(s[e],r):s[e]=r;return s}},z=class{constructor(e,t){this.keys=e,this.nonce=t}},Q=class{constructor(e,t){this._logger=new g("OidcClient"),this.settings=e instanceof F?e:new F(e),this.metadataService=null!=t?t:new A(this.settings),this._claimsService=new V(this.settings),this._validator=new N(this.settings,this.metadataService,this._claimsService),this._tokenClient=new U(this.settings,this.metadataService)}async createSigninRequest({state:e,request:t,request_uri:s,request_type:r,id_token_hint:n,login_hint:i,skipUserInfo:o,nonce:a,url_state:c,response_type:u=this.settings.response_type,scope:d=this.settings.scope,redirect_uri:h=this.settings.redirect_uri,prompt:l=this.settings.prompt,display:p=this.settings.display,max_age:g=this.settings.max_age,ui_locales:f=this.settings.ui_locales,acr_values:_=this.settings.acr_values,resource:m=this.settings.resource,response_mode:b=this.settings.response_mode,extraQueryParams:w=this.settings.extraQueryParams,extraTokenParams:y=this.settings.extraTokenParams,dpopJkt:v,omitScopeWhenRequesting:k=this.settings.omitScopeWhenRequesting}){const S=this._logger.create("createSigninRequest");if("code"!==u)throw new Error("Only the Authorization Code flow (with PKCE) is supported");const C=await this.metadataService.getAuthorizationEndpoint();S.debug("Received authorization endpoint",C);const j=await B.create({url:C,authority:this.settings.authority,client_id:this.settings.client_id,redirect_uri:h,response_type:u,scope:d,state_data:e,url_state:c,prompt:l,display:p,max_age:g,ui_locales:f,id_token_hint:n,login_hint:i,acr_values:_,dpopJkt:v,resource:m,request:t,request_uri:s,extraQueryParams:w,extraTokenParams:y,request_type:r,response_mode:b,client_secret:this.settings.client_secret,skipUserInfo:o,nonce:a,disablePKCE:this.settings.disablePKCE,omitScopeWhenRequesting:k});await this.clearStaleState();const E=j.state;return await this.settings.stateStore.set(E.id,E.toStorageString()),j}async readSigninResponseState(e,t=!1){const s=this._logger.create("readSigninResponseState"),r=new H(S.readParams(e,this.settings.response_mode));if(!r.state)throw s.throw(new Error("No state in response")),null;const n=await this.settings.stateStore[t?"remove":"get"](r.state);if(!n)throw s.throw(new Error("No matching state found in storage")),null;return{state:await L.fromStorageString(n),response:r}}async processSigninResponse(e,t,s=!0){const r=this._logger.create("processSigninResponse"),{state:n,response:i}=await this.readSigninResponseState(e,s);if(r.debug("received state from storage; validating response"),this.settings.dpop&&this.settings.dpop.store){const e=await this.getDpopProof(this.settings.dpop.store);t={...t,DPoP:e}}try{await this._validator.validateSigninResponse(i,n,t)}catch(e){if(!(e instanceof I&&this.settings.dpop))throw e;{const s=await this.getDpopProof(this.settings.dpop.store,e.nonce);t.DPoP=s,await this._validator.validateSigninResponse(i,n,t)}}return i}async getDpopProof(e,t){let s,r;return(await e.getAllKeys()).includes(this.settings.client_id)?(r=await e.get(this.settings.client_id),r.nonce!==t&&t&&(r.nonce=t,await e.set(this.settings.client_id,r))):(s=await w.generateDPoPKeys(),r=new z(s,t),await e.set(this.settings.client_id,r)),await w.generateDPoPProof({url:await this.metadataService.getTokenEndpoint(!1),httpMethod:"POST",keyPair:r.keys,nonce:r.nonce})}async processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:s=!1,extraTokenParams:r={}}){const n=await this._tokenClient.exchangeCredentials({username:e,password:t,...r}),i=new H(new URLSearchParams);return Object.assign(i,n),await this._validator.validateCredentialsResponse(i,s),i}async useRefreshToken({state:e,redirect_uri:t,resource:s,timeoutInSeconds:r,extraHeaders:n,extraTokenParams:i}){var o;const a=this._logger.create("useRefreshToken");let c,u;if(void 0===this.settings.refreshTokenAllowedScope)c=e.scope;else{const t=this.settings.refreshTokenAllowedScope.split(" ");c=((null==(o=e.scope)?void 0:o.split(" "))||[]).filter(e=>t.includes(e)).join(" ")}if(this.settings.dpop&&this.settings.dpop.store){const e=await this.getDpopProof(this.settings.dpop.store);n={...n,DPoP:e}}try{u=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:c,redirect_uri:t,resource:s,timeoutInSeconds:r,extraHeaders:n,...i})}catch(o){if(!(o instanceof I&&this.settings.dpop))throw o;n.DPoP=await this.getDpopProof(this.settings.dpop.store,o.nonce),u=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:c,redirect_uri:t,resource:s,timeoutInSeconds:r,extraHeaders:n,...i})}const d=new H(new URLSearchParams);return Object.assign(d,u),a.debug("validating response",d),await this._validator.validateRefreshResponse(d,{...e,scope:c}),d}async createSignoutRequest({state:e,id_token_hint:t,client_id:s,request_type:r,url_state:n,post_logout_redirect_uri:i=this.settings.post_logout_redirect_uri,extraQueryParams:o=this.settings.extraQueryParams}={}){const a=this._logger.create("createSignoutRequest"),c=await this.metadataService.getEndSessionEndpoint();if(!c)throw a.throw(new Error("No end session endpoint")),null;a.debug("Received end session endpoint",c),s||!i||t||(s=this.settings.client_id);const u=new $({url:c,id_token_hint:t,client_id:s,post_logout_redirect_uri:i,state_data:e,extraQueryParams:o,request_type:r,url_state:n});await this.clearStaleState();const d=u.state;return d&&(a.debug("Signout request has state to persist"),await this.settings.stateStore.set(d.id,d.toStorageString())),u}async readSignoutResponseState(e,t=!1){const s=this._logger.create("readSignoutResponseState"),r=new W(S.readParams(e,this.settings.response_mode));if(!r.state){if(s.debug("No state in response"),r.error)throw s.warn("Response was error:",r.error),new j(r);return{state:void 0,response:r}}const n=await this.settings.stateStore[t?"remove":"get"](r.state);if(!n)throw s.throw(new Error("No matching state found in storage")),null;return{state:await D.fromStorageString(n),response:r}}async processSignoutResponse(e){const t=this._logger.create("processSignoutResponse"),{state:s,response:r}=await this.readSignoutResponseState(e,!0);return s?(t.debug("Received state from storage; validating response"),this._validator.validateSignoutResponse(r,s)):t.debug("No state from storage; skipping response validation"),r}clearStaleState(){return this._logger.create("clearStaleState"),D.clearStaleState(this.settings.stateStore,this.settings.staleStateAgeInSeconds)}async revokeToken(e,t){return this._logger.create("revokeToken"),await this._tokenClient.revoke({token:e,token_type_hint:t})}},Y=class{constructor(e){this._userManager=e,this._logger=new g("SessionMonitor"),this._start=async e=>{const t=e.session_state;if(!t)return;const s=this._logger.create("_start");if(e.profile?(this._sub=e.profile.sub,s.debug("session_state",t,", sub",this._sub)):(this._sub=void 0,s.debug("session_state",t,", anonymous user")),this._checkSessionIFrame)this._checkSessionIFrame.start(t);else try{const e=await this._userManager.metadataService.getCheckSessionIframe();if(e){s.debug("initializing check session iframe");const r=this._userManager.settings.client_id,n=this._userManager.settings.checkSessionIntervalInSeconds,i=this._userManager.settings.stopCheckSessionOnError,o=new T(this._callback,r,e,n,i);await o.load(),this._checkSessionIFrame=o,o.start(t)}else s.warn("no check session iframe found in the metadata")}catch(e){s.error("Error from getCheckSessionIframe:",e instanceof Error?e.message:e)}},this._stop=()=>{const e=this._logger.create("_stop");if(this._sub=void 0,this._checkSessionIFrame&&this._checkSessionIFrame.stop(),this._userManager.settings.monitorAnonymousSession){const t=setInterval(async()=>{clearInterval(t);try{const e=await this._userManager.querySessionStatus();if(e){const t={session_state:e.session_state,profile:e.sub?{sub:e.sub}:null};this._start(t)}}catch(t){e.error("error from querySessionStatus",t instanceof Error?t.message:t)}},1e3)}},this._callback=async()=>{const e=this._logger.create("_callback");try{const t=await this._userManager.querySessionStatus();let s=!0;t&&this._checkSessionIFrame?t.sub===this._sub?(s=!1,this._checkSessionIFrame.start(t.session_state),e.debug("same sub still logged in at OP, session state has changed, restarting check session iframe; session_state",t.session_state),await this._userManager.events._raiseUserSessionChanged()):e.debug("different subject signed into OP",t.sub):e.debug("subject no longer signed into OP"),s?this._sub?await this._userManager.events._raiseUserSignedOut():await this._userManager.events._raiseUserSignedIn():e.debug("no change in session detected, no event to raise")}catch(t){this._sub&&(e.debug("Error calling queryCurrentSigninSession; raising signed out event",t),await this._userManager.events._raiseUserSignedOut())}},e||this._logger.throw(new Error("No user manager passed")),this._userManager.events.addUserLoaded(this._start),this._userManager.events.addUserUnloaded(this._stop),this._init().catch(e=>{this._logger.error(e)})}async _init(){this._logger.create("_init");const e=await this._userManager.getUser();if(e)this._start(e);else if(this._userManager.settings.monitorAnonymousSession){const e=await this._userManager.querySessionStatus();if(e){const t={session_state:e.session_state,profile:e.sub?{sub:e.sub}:null};this._start(t)}}}},X=class e{constructor(e){var t;this.id_token=e.id_token,this.session_state=null!=(t=e.session_state)?t:null,this.access_token=e.access_token,this.refresh_token=e.refresh_token,this.token_type=e.token_type,this.scope=e.scope,this.profile=e.profile,this.expires_at=e.expires_at,this.state=e.userState,this.url_state=e.url_state}get expires_in(){if(void 0!==this.expires_at)return this.expires_at-k.getEpochTime()}set expires_in(e){void 0!==e&&(this.expires_at=Math.floor(e)+k.getEpochTime())}get expired(){const e=this.expires_in;if(void 0!==e)return e<=0}get scopes(){var e,t;return null!=(t=null==(e=this.scope)?void 0:e.split(" "))?t:[]}toStorageString(){return new g("User").create("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})}static fromStorageString(t){return g.createStatic("User","fromStorageString"),new e(JSON.parse(t))}},G="oidc-client",Z=class{constructor(){this._abort=new y("Window navigation aborted"),this._disposeHandlers=new Set,this._window=null}async navigate(e){const t=this._logger.create("navigate");if(!this._window)throw new Error("Attempted to navigate on a disposed window");t.debug("setting URL in window"),this._window.location.replace(e.url);const{url:s,keepOpen:r}=await new Promise((s,r)=>{const n=n=>{var i;const o=n.data,a=null!=(i=e.scriptOrigin)?i:window.location.origin;if(n.origin===a&&(null==o?void 0:o.source)===G){try{const s=S.readParams(o.url,e.response_mode).get("state");if(s||t.warn("no state found in response url"),n.source!==this._window&&s!==e.state)return}catch{this._dispose(),r(new Error("Invalid response from window"))}s(o)}};window.addEventListener("message",n,!1),this._disposeHandlers.add(()=>window.removeEventListener("message",n,!1));const i=new BroadcastChannel(`oidc-client-popup-${e.state}`);i.addEventListener("message",n,!1),this._disposeHandlers.add(()=>i.close()),this._disposeHandlers.add(this._abort.addHandler(e=>{this._dispose(),r(e)}))});return t.debug("got response from window"),this._dispose(),r||this.close(),{url:s}}_dispose(){this._logger.create("_dispose");for(const e of this._disposeHandlers)e();this._disposeHandlers.clear()}static _notifyParent(e,t,s=!1,r=window.location.origin){const n={source:G,url:t,keepOpen:s},i=new g("_notifyParent");if(e)i.debug("With parent. Using parent.postMessage."),e.postMessage(n,r);else{i.debug("No parent. Using BroadcastChannel.");const e=new URL(t).searchParams.get("state");if(!e)throw new Error("No parent and no state in URL. Can't complete notification.");const s=new BroadcastChannel(`oidc-client-popup-${e}`);s.postMessage(n),s.close()}}},ee={location:!1,toolbar:!1,height:640,closePopupWindowAfterInSeconds:-1},te="_blank",se=60,re=2,ne=class extends F{constructor(e){const{popup_redirect_uri:t=e.redirect_uri,popup_post_logout_redirect_uri:s=e.post_logout_redirect_uri,popupWindowFeatures:r=ee,popupWindowTarget:n=te,redirectMethod:i="assign",redirectTarget:o="self",iframeNotifyParentOrigin:a=e.iframeNotifyParentOrigin,iframeScriptOrigin:c=e.iframeScriptOrigin,requestTimeoutInSeconds:u,silent_redirect_uri:d=e.redirect_uri,silentRequestTimeoutInSeconds:h,automaticSilentRenew:l=!0,validateSubOnSilentRenew:p=!0,includeIdTokenInSilentRenew:g=!1,monitorSession:f=!1,monitorAnonymousSession:_=!1,checkSessionIntervalInSeconds:m=re,query_status_response_type:b="code",stopCheckSessionOnError:w=!0,revokeTokenTypes:y=["access_token","refresh_token"],revokeTokensOnSignout:v=!1,includeIdTokenInSilentSignout:k=!1,accessTokenExpiringNotificationTimeInSeconds:S=se,userStore:C}=e;if(super(e),this.popup_redirect_uri=t,this.popup_post_logout_redirect_uri=s,this.popupWindowFeatures=r,this.popupWindowTarget=n,this.redirectMethod=i,this.redirectTarget=o,this.iframeNotifyParentOrigin=a,this.iframeScriptOrigin=c,this.silent_redirect_uri=d,this.silentRequestTimeoutInSeconds=h||u||10,this.automaticSilentRenew=l,this.validateSubOnSilentRenew=p,this.includeIdTokenInSilentRenew=g,this.monitorSession=f,this.monitorAnonymousSession=_,this.checkSessionIntervalInSeconds=m,this.stopCheckSessionOnError=w,this.query_status_response_type=b,this.revokeTokenTypes=y,this.revokeTokensOnSignout=v,this.includeIdTokenInSilentSignout=k,this.accessTokenExpiringNotificationTimeInSeconds=S,C)this.userStore=C;else{const e="undefined"!=typeof window?window.sessionStorage:new P;this.userStore=new R({store:e})}}},ie=class e extends Z{constructor({silentRequestTimeoutInSeconds:t=10}){super(),this._logger=new g("IFrameWindow"),this._timeoutInSeconds=t,this._frame=e.createHiddenIframe(),this._window=this._frame.contentWindow}static createHiddenIframe(){const e=window.document.createElement("iframe");return e.style.visibility="hidden",e.style.position="fixed",e.style.left="-1000px",e.style.top="0",e.width="0",e.height="0",window.document.body.appendChild(e),e}async navigate(e){this._logger.debug("navigate: Using timeout of:",this._timeoutInSeconds);const t=setTimeout(()=>{this._abort.raise(new E("IFrame timed out without a response"))},1e3*this._timeoutInSeconds);return this._disposeHandlers.add(()=>clearTimeout(t)),await super.navigate(e)}close(){var e;this._frame&&(this._frame.parentNode&&(this._frame.addEventListener("load",e=>{var t;const s=e.target;null==(t=s.parentNode)||t.removeChild(s),this._abort.raise(new Error("IFrame removed from DOM"))},!0),null==(e=this._frame.contentWindow)||e.location.replace("about:blank")),this._frame=null),this._window=null}static notifyParent(e,t){return super._notifyParent(window.parent,e,!1,t)}},oe=class{constructor(e){this._settings=e,this._logger=new g("IFrameNavigator")}async prepare({silentRequestTimeoutInSeconds:e=this._settings.silentRequestTimeoutInSeconds}){return new ie({silentRequestTimeoutInSeconds:e})}async callback(e){this._logger.create("callback"),ie.notifyParent(e,this._settings.iframeNotifyParentOrigin)}},ae=class extends Z{constructor({popupWindowTarget:e=te,popupWindowFeatures:t={},popupSignal:s}){super(),this._logger=new g("PopupWindow");const r=v.center({...ee,...t});this._window=window.open(void 0,e,v.serialize(r)),s&&s.addEventListener("abort",()=>{var e;this._abort.raise(new Error(null!=(e=s.reason)?e:"Popup aborted"))}),t.closePopupWindowAfterInSeconds&&t.closePopupWindowAfterInSeconds>0&&setTimeout(()=>{this._window&&"boolean"==typeof this._window.closed&&!this._window.closed?this.close():this._abort.raise(new Error("Popup blocked by user"))},1e3*t.closePopupWindowAfterInSeconds)}async navigate(e){var t;null==(t=this._window)||t.focus();const s=setInterval(()=>{this._window&&!this._window.closed||(this._logger.debug("Popup closed by user or isolated by redirect"),r(),this._disposeHandlers.delete(r))},500),r=()=>clearInterval(s);return this._disposeHandlers.add(r),await super.navigate(e)}close(){this._window&&(this._window.closed||(this._window.close(),this._abort.raise(new Error("Popup closed")))),this._window=null}static notifyOpener(e,t){super._notifyParent(window.opener,e,t),t||window.opener||window.close()}},ce=class{constructor(e){this._settings=e,this._logger=new g("PopupNavigator")}async prepare({popupWindowFeatures:e=this._settings.popupWindowFeatures,popupWindowTarget:t=this._settings.popupWindowTarget,popupSignal:s}){return new ae({popupWindowFeatures:e,popupWindowTarget:t,popupSignal:s})}async callback(e,{keepOpen:t=!1}){this._logger.create("callback"),ae.notifyOpener(e,t)}},ue=class{constructor(e){this._settings=e,this._logger=new g("RedirectNavigator")}async prepare({redirectMethod:e=this._settings.redirectMethod,redirectTarget:t=this._settings.redirectTarget}){var s;this._logger.create("prepare");let r=window.self;"top"===t&&(r=null!=(s=window.top)?s:window.self);const n=r.location[e].bind(r.location);let i;return{navigate:async e=>{this._logger.create("navigate");const t=new Promise((e,t)=>{i=t});return n(e.url),await t},close:()=>{this._logger.create("close"),null==i||i(new Error("Redirect aborted")),r.stop()}}}async callback(){}},de=class extends x{constructor(e){super({expiringNotificationTimeInSeconds:e.accessTokenExpiringNotificationTimeInSeconds}),this._logger=new g("UserManagerEvents"),this._userLoaded=new y("User loaded"),this._userUnloaded=new y("User unloaded"),this._silentRenewError=new y("Silent renew error"),this._userSignedIn=new y("User signed in"),this._userSignedOut=new y("User signed out"),this._userSessionChanged=new y("User session changed")}async load(e,t=!0){await super.load(e),t&&await this._userLoaded.raise(e)}async unload(){await super.unload(),await this._userUnloaded.raise()}addUserLoaded(e){return this._userLoaded.addHandler(e)}removeUserLoaded(e){return this._userLoaded.removeHandler(e)}addUserUnloaded(e){return this._userUnloaded.addHandler(e)}removeUserUnloaded(e){return this._userUnloaded.removeHandler(e)}addSilentRenewError(e){return this._silentRenewError.addHandler(e)}removeSilentRenewError(e){return this._silentRenewError.removeHandler(e)}async _raiseSilentRenewError(e){await this._silentRenewError.raise(e)}addUserSignedIn(e){return this._userSignedIn.addHandler(e)}removeUserSignedIn(e){this._userSignedIn.removeHandler(e)}async _raiseUserSignedIn(){await this._userSignedIn.raise()}addUserSignedOut(e){return this._userSignedOut.addHandler(e)}removeUserSignedOut(e){this._userSignedOut.removeHandler(e)}async _raiseUserSignedOut(){await this._userSignedOut.raise()}addUserSessionChanged(e){return this._userSessionChanged.addHandler(e)}removeUserSessionChanged(e){this._userSessionChanged.removeHandler(e)}async _raiseUserSessionChanged(){await this._userSessionChanged.raise()}},he=class{constructor(e){this._userManager=e,this._logger=new g("SilentRenewService"),this._isStarted=!1,this._retryTimer=new k("Retry Silent Renew"),this._tokenExpiring=async()=>{const e=this._logger.create("_tokenExpiring");try{await this._userManager.signinSilent(),e.debug("silent token renewal successful")}catch(t){if(t instanceof E)return e.warn("ErrorTimeout from signinSilent:",t,"retry in 5s"),void this._retryTimer.init(5);e.error("Error from signinSilent:",t),await this._userManager.events._raiseSilentRenewError(t)}}}async start(){const e=this._logger.create("start");if(!this._isStarted){this._isStarted=!0,this._userManager.events.addAccessTokenExpiring(this._tokenExpiring),this._retryTimer.addHandler(this._tokenExpiring);try{await this._userManager.getUser()}catch(t){e.error("getUser error",t)}}}stop(){this._isStarted&&(this._retryTimer.cancel(),this._retryTimer.removeHandler(this._tokenExpiring),this._userManager.events.removeAccessTokenExpiring(this._tokenExpiring),this._isStarted=!1)}},le=class{constructor(e){this.refresh_token=e.refresh_token,this.id_token=e.id_token,this.session_state=e.session_state,this.scope=e.scope,this.profile=e.profile,this.data=e.state}},pe=class{constructor(e,t,s,r){this._logger=new g("UserManager"),this.settings=new ne(e),this._client=new Q(e),this._redirectNavigator=null!=t?t:new ue(this.settings),this._popupNavigator=null!=s?s:new ce(this.settings),this._iframeNavigator=null!=r?r:new oe(this.settings),this._events=new de(this.settings),this._silentRenewService=new he(this),this.settings.automaticSilentRenew&&this.startSilentRenew(),this._sessionMonitor=null,this.settings.monitorSession&&(this._sessionMonitor=new Y(this))}get events(){return this._events}get metadataService(){return this._client.metadataService}async getUser(e=!1){const t=this._logger.create("getUser"),s=await this._loadUser();return s?(t.info("user loaded"),await this._events.load(s,e),s):(t.info("user not found in storage"),null)}async removeUser(){const e=this._logger.create("removeUser");await this.storeUser(null),e.info("user removed from storage"),await this._events.unload()}async signinRedirect(e={}){var t;this._logger.create("signinRedirect");const{redirectMethod:s,...r}=e;let n;(null==(t=this.settings.dpop)?void 0:t.bind_authorization_code)&&(n=await this.generateDPoPJkt(this.settings.dpop));const i=await this._redirectNavigator.prepare({redirectMethod:s});await this._signinStart({request_type:"si:r",dpopJkt:n,...r},i)}async signinRedirectCallback(e=window.location.href){const t=this._logger.create("signinRedirectCallback"),s=await this._signinEnd(e);return s.profile&&s.profile.sub?t.info("success, signed in subject",s.profile.sub):t.info("no subject"),s}async signinResourceOwnerCredentials({username:e,password:t,skipUserInfo:s=!1}){const r=this._logger.create("signinResourceOwnerCredential"),n=await this._client.processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:s,extraTokenParams:this.settings.extraTokenParams});r.debug("got signin response");const i=await this._buildUser(n);return i.profile&&i.profile.sub?r.info("success, signed in subject",i.profile.sub):r.info("no subject"),i}async signinPopup(e={}){var t;const s=this._logger.create("signinPopup");let r;(null==(t=this.settings.dpop)?void 0:t.bind_authorization_code)&&(r=await this.generateDPoPJkt(this.settings.dpop));const{popupWindowFeatures:n,popupWindowTarget:i,popupSignal:o,...a}=e,c=this.settings.popup_redirect_uri;c||s.throw(new Error("No popup_redirect_uri configured"));const u=await this._popupNavigator.prepare({popupWindowFeatures:n,popupWindowTarget:i,popupSignal:o}),d=await this._signin({request_type:"si:p",redirect_uri:c,display:"popup",dpopJkt:r,...a},u);return d&&(d.profile&&d.profile.sub?s.info("success, signed in subject",d.profile.sub):s.info("no subject")),d}async signinPopupCallback(e=window.location.href,t=!1){const s=this._logger.create("signinPopupCallback");await this._popupNavigator.callback(e,{keepOpen:t}),s.info("success")}async signinSilent(e={}){var t,s;const r=this._logger.create("signinSilent"),{silentRequestTimeoutInSeconds:n,...i}=e;let o,a=await this._loadUser();if(null==a?void 0:a.refresh_token){r.debug("using refresh token");const e=new le(a);return await this._useRefreshToken({state:e,redirect_uri:i.redirect_uri,resource:i.resource,extraTokenParams:i.extraTokenParams,timeoutInSeconds:n})}(null==(t=this.settings.dpop)?void 0:t.bind_authorization_code)&&(o=await this.generateDPoPJkt(this.settings.dpop));const c=this.settings.silent_redirect_uri;let u;c||r.throw(new Error("No silent_redirect_uri configured")),a&&this.settings.validateSubOnSilentRenew&&(r.debug("subject prior to silent renew:",a.profile.sub),u=a.profile.sub);const d=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:n});return a=await this._signin({request_type:"si:s",redirect_uri:c,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?null==a?void 0:a.id_token:void 0,dpopJkt:o,...i},d,u),a&&((null==(s=a.profile)?void 0:s.sub)?r.info("success, signed in subject",a.profile.sub):r.info("no subject")),a}async _useRefreshToken(e){const t=await this._client.useRefreshToken({timeoutInSeconds:this.settings.silentRequestTimeoutInSeconds,...e}),s=new X({...e.state,...t});return await this.storeUser(s),await this._events.load(s),s}async signinSilentCallback(e=window.location.href){const t=this._logger.create("signinSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async signinCallback(e=window.location.href){const{state:t}=await this._client.readSigninResponseState(e);switch(t.request_type){case"si:r":return await this.signinRedirectCallback(e);case"si:p":await this.signinPopupCallback(e);break;case"si:s":await this.signinSilentCallback(e);break;default:throw new Error("invalid response_type in state")}}async signoutCallback(e=window.location.href,t=!1){const{state:s}=await this._client.readSignoutResponseState(e);if(s)switch(s.request_type){case"so:r":return await this.signoutRedirectCallback(e);case"so:p":await this.signoutPopupCallback(e,t);break;case"so:s":await this.signoutSilentCallback(e);break;default:throw new Error("invalid response_type in state")}}async querySessionStatus(e={}){const t=this._logger.create("querySessionStatus"),{silentRequestTimeoutInSeconds:s,...r}=e,n=this.settings.silent_redirect_uri;n||t.throw(new Error("No silent_redirect_uri configured"));const i=await this._loadUser(),o=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:s}),a=await this._signinStart({request_type:"si:s",redirect_uri:n,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?null==i?void 0:i.id_token:void 0,response_type:this.settings.query_status_response_type,scope:"openid",skipUserInfo:!0,...r},o);try{const e={},s=await this._client.processSigninResponse(a.url,e);return t.debug("got signin response"),s.session_state&&s.profile.sub?(t.info("success for subject",s.profile.sub),{session_state:s.session_state,sub:s.profile.sub}):(t.info("success, user not authenticated"),null)}catch(e){if(this.settings.monitorAnonymousSession&&e instanceof j)switch(e.error){case"login_required":case"consent_required":case"interaction_required":case"account_selection_required":return t.info("success for anonymous user"),{session_state:e.session_state}}throw e}}async _signin(e,t,s){const r=await this._signinStart(e,t);return await this._signinEnd(r.url,s)}async _signinStart(e,t){const s=this._logger.create("_signinStart");try{const r=await this._client.createSigninRequest(e);return s.debug("got signin request"),await t.navigate({url:r.url,state:r.state.id,response_mode:r.state.response_mode,scriptOrigin:this.settings.iframeScriptOrigin})}catch(e){throw s.debug("error after preparing navigator, closing navigator window"),t.close(),e}}async _signinEnd(e,t){const s=this._logger.create("_signinEnd"),r=await this._client.processSigninResponse(e,{});return s.debug("got signin response"),await this._buildUser(r,t)}async _buildUser(e,t){const s=this._logger.create("_buildUser"),r=new X(e);if(t){if(t!==r.profile.sub)throw s.debug("current user does not match user returned from signin. sub from signin:",r.profile.sub),new j({...e,error:"login_required"});s.debug("current user matches user returned from signin")}return await this.storeUser(r),s.debug("user stored"),await this._events.load(r),r}async signoutRedirect(e={}){const t=this._logger.create("signoutRedirect"),{redirectMethod:s,...r}=e,n=await this._redirectNavigator.prepare({redirectMethod:s});await this._signoutStart({request_type:"so:r",post_logout_redirect_uri:this.settings.post_logout_redirect_uri,...r},n),t.info("success")}async signoutRedirectCallback(e=window.location.href){const t=this._logger.create("signoutRedirectCallback"),s=await this._signoutEnd(e);return t.info("success"),s}async signoutPopup(e={}){const t=this._logger.create("signoutPopup"),{popupWindowFeatures:s,popupWindowTarget:r,popupSignal:n,...i}=e,o=this.settings.popup_post_logout_redirect_uri,a=await this._popupNavigator.prepare({popupWindowFeatures:s,popupWindowTarget:r,popupSignal:n});await this._signout({request_type:"so:p",post_logout_redirect_uri:o,state:null==o?void 0:{},...i},a),t.info("success")}async signoutPopupCallback(e=window.location.href,t=!1){const s=this._logger.create("signoutPopupCallback");await this._popupNavigator.callback(e,{keepOpen:t}),s.info("success")}async _signout(e,t){const s=await this._signoutStart(e,t);return await this._signoutEnd(s.url)}async _signoutStart(e={},t){var s;const r=this._logger.create("_signoutStart");try{const n=await this._loadUser();r.debug("loaded current user from storage"),this.settings.revokeTokensOnSignout&&await this._revokeInternal(n);const i=e.id_token_hint||n&&n.id_token;i&&(r.debug("setting id_token_hint in signout request"),e.id_token_hint=i),await this.removeUser(),r.debug("user removed, creating signout request");const o=await this._client.createSignoutRequest(e);return r.debug("got signout request"),await t.navigate({url:o.url,state:null==(s=o.state)?void 0:s.id,scriptOrigin:this.settings.iframeScriptOrigin})}catch(e){throw r.debug("error after preparing navigator, closing navigator window"),t.close(),e}}async _signoutEnd(e){const t=this._logger.create("_signoutEnd"),s=await this._client.processSignoutResponse(e);return t.debug("got signout response"),s}async signoutSilent(e={}){var t;const s=this._logger.create("signoutSilent"),{silentRequestTimeoutInSeconds:r,...n}=e,i=this.settings.includeIdTokenInSilentSignout?null==(t=await this._loadUser())?void 0:t.id_token:void 0,o=this.settings.popup_post_logout_redirect_uri,a=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:r});await this._signout({request_type:"so:s",post_logout_redirect_uri:o,id_token_hint:i,...n},a),s.info("success")}async signoutSilentCallback(e=window.location.href){const t=this._logger.create("signoutSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async revokeTokens(e){const t=await this._loadUser();await this._revokeInternal(t,e)}async _revokeInternal(e,t=this.settings.revokeTokenTypes){const s=this._logger.create("_revokeInternal");if(!e)return;const r=t.filter(t=>"string"==typeof e[t]);if(r.length){for(const t of r)await this._client.revokeToken(e[t],t),s.info(`${t} revoked successfully`),"access_token"!==t&&(e[t]=null);await this.storeUser(e),s.debug("user stored"),await this._events.load(e)}else s.debug("no need to revoke due to no token(s)")}startSilentRenew(){this._logger.create("startSilentRenew"),this._silentRenewService.start()}stopSilentRenew(){this._silentRenewService.stop()}get _userStoreKey(){return`user:${this.settings.authority}:${this.settings.client_id}`}async _loadUser(){const e=this._logger.create("_loadUser"),t=await this.settings.userStore.get(this._userStoreKey);return t?(e.debug("user storageString loaded"),X.fromStorageString(t)):(e.debug("no user storageString"),null)}async storeUser(e){const t=this._logger.create("storeUser");if(e){t.debug("storing user");const s=e.toStorageString();await this.settings.userStore.set(this._userStoreKey,s)}else this._logger.debug("removing user"),await this.settings.userStore.remove(this._userStoreKey),this.settings.dpop&&await this.settings.dpop.store.remove(this.settings.client_id)}async clearStaleState(){await this._client.clearStaleState()}async dpopProof(e,t,s,r){var n,i;const o=await(null==(i=null==(n=this.settings.dpop)?void 0:n.store)?void 0:i.get(this.settings.client_id));if(o)return await w.generateDPoPProof({url:e,accessToken:null==t?void 0:t.access_token,httpMethod:s,keyPair:o.keys,nonce:r})}async generateDPoPJkt(e){let t=await e.store.get(this.settings.client_id);if(!t){const s=await w.generateDPoPKeys();t=new z(s),await e.store.set(this.settings.client_id,t)}return await w.generateDPoPJkt(t.keys)}},ge="3.3.0",fe=class{constructor(){this._dbName="oidc",this._storeName="dpop"}async set(e,t){const s=await this.createStore(this._dbName,this._storeName);await s("readwrite",s=>(s.put(t,e),this.promisifyRequest(s.transaction)))}async get(e){const t=await this.createStore(this._dbName,this._storeName);return await t("readonly",t=>this.promisifyRequest(t.get(e)))}async remove(e){const t=await this.get(e),s=await this.createStore(this._dbName,this._storeName);return await s("readwrite",t=>this.promisifyRequest(t.delete(e))),t}async getAllKeys(){const e=await this.createStore(this._dbName,this._storeName);return await e("readonly",e=>this.promisifyRequest(e.getAllKeys()))}promisifyRequest(e){return new Promise((t,s)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>s(e.error)})}async createStore(e,t){const s=indexedDB.open(e);s.onupgradeneeded=()=>s.result.createObjectStore(t);const r=await this.promisifyRequest(s);return async(e,s)=>{const n=r.transaction(t,e).objectStore(t);return await s(n)}}}},"../../node_modules/set-value/index.js"(e,t,s){"use strict";const{deleteProperty:r}=Reflect,n=s("../../node_modules/is-primitive/index.js"),i=s("../../node_modules/is-plain-object/index.js"),o=e=>"object"==typeof e&&null!==e||"function"==typeof e,a=e=>{if(!n(e))throw new TypeError("Object keys must be strings or symbols");if((e=>"__proto__"===e||"constructor"===e||"prototype"===e)(e))throw new Error(`Cannot set unsafe key: "${e}"`)},c=(e,t)=>t&&"function"==typeof t.split?t.split(e):"symbol"==typeof e?[e]:Array.isArray(e)?e:((e,t,s)=>{const r=(e=>Array.isArray(e)?e.flat().map(String).join(","):e)(t?((e,t)=>{if("string"!=typeof e||!t)return e;let s=e+";";return void 0!==t.arrays&&(s+=`arrays=${t.arrays};`),void 0!==t.separator&&(s+=`separator=${t.separator};`),void 0!==t.split&&(s+=`split=${t.split};`),void 0!==t.merge&&(s+=`merge=${t.merge};`),void 0!==t.preservePaths&&(s+=`preservePaths=${t.preservePaths};`),s})(e,t):e);a(r);const n=d.cache.get(r)||s();return d.cache.set(r,n),n})(e,t,()=>((e,t={})=>{const s=t.separator||".",r="/"!==s&&t.preservePaths;if("string"==typeof e&&!1!==r&&/\//.test(e))return[e];const n=[];let i="";const o=e=>{let t;""!==e.trim()&&Number.isInteger(t=Number(e))?n.push(t):n.push(e)};for(let t=0;t<e.length;t++){const r=e[t];"\\"!==r?r!==s?i+=r:(o(i),i=""):i+=e[++t]}return i&&o(i),n})(e,t)),u=(e,t,s,n)=>{if(a(t),void 0===s)r(e,t);else if(n&&n.merge){const r="function"===n.merge?n.merge:Object.assign;r&&i(e[t])&&i(s)?e[t]=r(e[t],s):e[t]=s}else e[t]=s;return e},d=(e,t,s,r)=>{if(!t||!o(e))return e;const n=c(t,r);let i=e;for(let e=0;e<n.length;e++){const t=n[e],c=n[e+1];if(a(t),void 0===c){u(i,t,s,r);break}"number"!=typeof c||Array.isArray(i[t])?(o(i[t])||(i[t]={}),i=i[t]):i=i[t]=[]}return e};d.split=c,d.cache=new Map,d.clear=()=>{d.cache=new Map},e.exports=d},"../../node_modules/socket.io-client/node_modules/debug/src/browser.js"(e,t,s){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(n=r))}),t.splice(n,0,s)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=s("../../node_modules/socket.io-client/node_modules/debug/src/common.js")(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},"../../node_modules/socket.io-client/node_modules/debug/src/common.js"(e,t,s){e.exports=function(e){function t(e){let s,n,i,o=null;function a(...e){if(!a.enabled)return;const r=a,n=Number(new Date),i=n-(s||n);r.diff=i,r.prev=s,r.curr=n,s=n,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(s,n)=>{if("%%"===s)return"%";o++;const i=t.formatters[n];if("function"==typeof i){const t=e[o];s=i.call(r,t),e.splice(o,1),o--}return s}),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(n!==t.namespaces&&(n=t.namespaces,i=t.enabled(e)),i),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,s){const r=t(this.namespace+(void 0===s?":":s)+e);return r.log=this.log,r}function n(e,t){let s=0,r=0,n=-1,i=0;for(;s<e.length;)if(r<t.length&&(t[r]===e[s]||"*"===t[r]))"*"===t[r]?(n=r,i=s,r++):(s++,r++);else{if(-1===n)return!1;r=n+1,i++,s=i}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const s=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of s)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const s of t.skips)if(n(e,s))return!1;for(const s of t.names)if(n(e,s))return!0;return!1},t.humanize=s("../../node_modules/socket.io-client/node_modules/ms/index.js"),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(s=>{t[s]=e[s]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t}},"../../node_modules/socket.io-client/node_modules/ms/index.js"(e){var t=1e3,s=60*t,r=60*s,n=24*r,i=7*n;function o(e,t,s,r){var n=t>=1.5*s;return Math.round(e/s)+" "+r+(n?"s":"")}e.exports=function(e,a){a=a||{};var c,u,d=typeof e;if("string"===d&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*i;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*s;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===d&&isFinite(e))return a.long?(c=e,(u=Math.abs(c))>=n?o(c,u,n,"day"):u>=r?o(c,u,r,"hour"):u>=s?o(c,u,s,"minute"):u>=t?o(c,u,t,"second"):c+" ms"):function(e){var i=Math.abs(e);return i>=n?Math.round(e/n)+"d":i>=r?Math.round(e/r)+"h":i>=s?Math.round(e/s)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},"../../lib/client-server-bus/client/index.ts"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s("../../lib/client-server-bus/drivers/ws/client/index.ts"));t.default=n.default},"../../lib/client-server-bus/drivers/ws/client/index.ts"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=s("../../node_modules/socket.io-client/build/cjs/index.js");t.default=class{subscriptions={};connections={};connectionsInEstablishment={};isPaused=!1;connectionInterruptedSubscribers=[];messagesWhilePaused=[];getBearerToken;constructor(e){this.getBearerToken=e}subscribeConnectionInterrupted(e){this.connectionInterruptedSubscribers.push(e)}async subscribe(e,t,s,r){const n=new URL(e),i=`${n.origin}-${t}`,o=await this.ensureConnection(n.origin),a=await new Promise(e=>{o.emit("subscribe",{channel:t,readToken:s},e)});if("unauthorized"===a.status)throw new Error("unauthorized");if("subscribed"!==a.status)throw new Error(`unknown error when subscribing to ${t}`);return this.subscriptions[i]=this.subscriptions[i]||[],this.subscriptions[i].push(r),[i,r]}async send(e,t,s){const r=new URL(e),n=await this.ensureConnection(r.origin),i=await new Promise(e=>{n.emit("message",{channel:t,message:s},e)});if("unauthorized"===i.status)throw new Error("unauthorized");if("delivered"!==i.status)throw new Error(`unknown error when sending message to ${t}`)}async unsubscribe([e,t]){this.subscriptions[e]&&(this.subscriptions[e]=this.subscriptions[e].filter(e=>e!==t))}unsubscribeAll(){Object.values(this.connections).forEach(e=>{e.close()}),this.connections={}}pauseNotification(){this.isPaused=!0}unpauseNotification(){this.messagesWhilePaused.forEach(({cb:e,data:t})=>{e(t)}),this.messagesWhilePaused=[]}async getWSAsync(e){const t={withCredentials:!0,path:e.pathname,transports:["websocket"]};if(this.getBearerToken){const e=await this.getBearerToken();e&&(t.auth={token:`Bearer ${e}`})}return new Promise((s,n)=>{const i=(0,r.io)(e.origin,t);i.on("connect",()=>{s(i)}),i.on("error",e=>{console.log("==> websocket error",e),this.connectionInterruptedSubscribers.forEach(t=>{t(e)})}),i.on("disconnect",e=>{["ping timeout","transport close","transport error"].includes(e)?console.log("Connection disconnected. Socket.io will try to reconnect..."):this.connectionInterruptedSubscribers.forEach(t=>{t(new Error(`Websocket connection closed because: ${e}`))})}),i.io.on("reconnect_error",e=>{this.connectionInterruptedSubscribers.forEach(t=>{console.log(`Websocket reconnect error: ${e}`),t(new Error(`Websocket reconnect error: ${e}`))})}),i.io.on("reconnect_failed",()=>{this.connectionInterruptedSubscribers.forEach(e=>{console.log("Websocket reconnect failed!"),e(new Error("Websocket reconnect failed!"))})}),i.on("connect_error",n)})}async ensureConnection(e){const t=new URL(e);return t.pathname="/ws",this.connectionsInEstablishment[t.origin]?await this.connectionsInEstablishment[t.origin]:(this.connections[t.origin]||(this.connectionsInEstablishment[t.origin]=this.getWSAsync(t),this.connections[t.origin]=await this.connectionsInEstablishment[t.origin],this.connections[t.origin].on("data",e=>{const{sseChannel:s}=e;if(!s)return;delete e.sseChannel;const r=this.subscriptions[`${t.origin}-${s}`];r&&r.forEach(t=>{this.isPaused?this.messagesWhilePaused.push({cb:t,data:e}):t(e)})})),this.connections[e])}}},"../../lib/utils/all_prefixes.ts"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=[],s=[];return e.forEach(e=>{s.push(e),t.push([...s])}),t}},"../../lib/utils/unset.ts"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){const s=t.split(".");let r=e;for(let e=0;e<s.length-1;e+=1){const t=s[e];if(!r.hasOwnProperty(t)||"object"!=typeof r[t])return;r=r[t]}const n=s[s.length-1];r.hasOwnProperty(n)&&delete r[n]}},"../attributes/abstract/abstract_attribute_client.ts"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{linkedRecords;clientServerBus;id;actorId;clientId;createdAt;updatedAt;serverURL;observers;isInitialized;version;value;attrSubscription=void 0;readToken;constructor(e,t,s){this.id=s,this.linkedRecords=e,this.clientServerBus=t,this.serverURL=e.serverURL,this.createdAt=void 0,this.updatedAt=void 0,this.observers=[],this.clientId=e.getAttributeClientId(),e.actorId?this.actorId=e.actorId:e.ensureUserIdIsKnown().then(e=>{this.actorId=e}),this.version="0",this.value=this.getDefaultValue(),this.isInitialized=!1}static getDataTypeName(){throw new Error("getDataTypeName needs to be implemented in child class")}static isAttributeId(e){return e.split("-")[0]===this.prototype.getDataTypePrefix()}async create(e,t){if(this.id)throw new Error(`Cannot create attribute because it has an id assigned (${this.id})`);const s={method:"POST",body:await this.getCreatePayload(e,t)};"string"!=typeof s.body&&(s.isJSON=!1);const r=`/attributes?dtp=${this.getDataTypePrefix()}&clientId=${this.clientId}`,n=await this.linkedRecords.fetch(r,s);if(!n)return;if(200!==n.status)throw new Error(`Error creating attribute: ${await n.text()}`);const i=await n.json();if(this.id=i.id,!this.id||!this.id.trim())throw new Error("Unknown error occurred: The attribute was not assigned an ID by the server");await this.load(i)}getId(){if(!this.id)throw new Error("getId can not return the attribute id as id is undefined");return this.id}getClientId(){if(!this.clientId)throw new Error("clientId can not return the attribute id as id is undefined");return this.clientId}getServerURL(){if(!this.serverURL)throw new Error("serverURL can not return the attribute id as id is undefined");return this.serverURL.toString()}getDataURL(){return new URL(`/attributes/${this.id}?clientId=${this.clientId}&valueOnly=true`,this.linkedRecords.serverURL).toString()}async getCreatePayload(e,t=[]){const s=await this.linkedRecords.ensureUserIdIsKnown();if(!s)throw new Error("actorId is unknown, can not create payload!");return JSON.stringify({clientId:this.clientId,actorId:s,facts:t,value:e})}async get(){if(await this.load()){if(!this.actorId)throw new Error("actorId is unknown, can not get attribute value!");return{value:this.value,changeId:this.version,actorId:this.actorId}}}async getValue(){if(await this.load())return this.value}async set(e){await this.load(),e!==this.value&&await this.rawSet(e)}async change(e){return await this.load(),this.rawChange(e)}async subscribe(e){await this.load(),this.observers.push(e)}unload(){this.attrSubscription&&this.clientServerBus.unsubscribe(this.attrSubscription)}async load(e,t=!1){let s=e;if(this.isInitialized&&!t)return!0;if(!this.id)throw new Error("cannot load an attribute without id");if(!s){const e=`/attributes/${this.id}?clientId=${this.clientId}`,t=await this.linkedRecords.fetch(e);if(!t)return!1;const r=await t.json();s={changeId:r.changeId,value:r.value,createdAt:new Date(r.createdAt),updatedAt:new Date(r.updatedAt)}}const r="string"==typeof s.value?s.value:JSON.stringify(s.value);if(!r&&""!==r)throw new Error("invalid server state");if(this.version=s.changeId,this.value=await this.deserializeValue(r),this.createdAt=new Date(s.createdAt),this.updatedAt=new Date(s.updatedAt),this.readToken=s.readToken,this.isInitialized=!0,this.onLoad(),this.notifySubscribers(void 0,void 0),!this.attrSubscription){const e=new URL(`/attributes/${this.id}/changes?clientId=${this.clientId}`,this.serverURL),t=e=>{"quota_violation"!==e.error?e.attributeId===this.id&&(this.updatedAt=new Date(e.updatedAt),this.onServerMessage(e)):this.linkedRecords.handleQuotaViolationError(e)};this.attrSubscription=await this.clientServerBus.subscribe(e.toString(),this.id,this.readToken,t)}return!0}async sendToServer(e){if(!this.id)throw Error("cannot send message to server as attribute does not has an id");try{return await this.clientServerBus.send(this.serverURL.toString(),this.id,e),!0}catch(e){if(e.message&&e.message.match&&e.message.match(/unauthorized/)){if(!this.linkedRecords.authorizationErrorHandler)throw new Error("User is not allowed to perform operation");this.linkedRecords.authorizationErrorHandler()}else this.linkedRecords.handleConnectionError(e);return!1}}notifySubscribers(e,t){this.observers.forEach(s=>{s(e,t)})}}},"../attributes/abstract/serialized_change_with_metadata.ts"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{attributeId;actorId;clientId;change;updatedAt;constructor(e,t,s,r,n=void 0){this.attributeId=e,this.actorId=t,this.clientId=s,this.change=r,this.updatedAt=n}toJSON(){return{attributeId:this.attributeId,change:this.change.toJSON(),actorId:this.actorId,clientId:this.clientId,updatedAt:this.updatedAt}}}},"../attributes/blob/client/index.ts"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s("../attributes/abstract/abstract_attribute_client.ts"));class i extends n.default{static getDataTypePrefix(){return"bl"}static getDataTypeName(){return"blob"}getDataTypePrefix(){return i.getDataTypePrefix()}getDataTypeName(){return i.getDataTypeName()}getDefaultValue(){return new Blob}async deserializeValue(e){return new Blob([e])}async getCreatePayload(e){const t=await this.linkedRecords.ensureUserIdIsKnown();if(!t)throw new Error("actorId is unknown, can not create blob payload!");const s=new FormData;return s.append("change",e,"blob"),s.append("actorId",t),s.append("clientId",this.clientId),s}async rawSet(e){this.value=e,this.transmitChange(this.value)}async rawChange(e){return this.value=e.value,this.transmitChange(this.value)}onServerMessage(e){e.clientId!==this.clientId&&this.notifySubscribers(e.change,e)}async transmitChange(e){if(!this.id)throw new Error("change can not be transmitted because attribute does not has an id");if(!this.actorId)throw new Error("actorId is unknown, can not transmit change!");const t=new FormData,s=`/attributes/${this.id}?clientId=${this.clientId}&actorId=${this.actorId}`;return t.append("change",e,"blob"),t.append("attributeId",this.id),t.append("actorId",this.actorId),t.append("clientId",this.clientId),!!await this.linkedRecords.fetch(s,{method:"PATCH",body:t,isJSON:!1,doNotHandleExpiredSessions:!0})}onLoad(){}}t.default=i},"../attributes/key_value/client/index.ts"(e,t,s){"use strict";var r,n=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=r(e),o=0;o<s.length;o++)"default"!==s[o]&&n(t,e,s[o]);return i(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const c=o(s("../../node_modules/flat/index.js")),u=a(s("../../node_modules/get-value/index.js")),d=a(s("../attributes/abstract/abstract_attribute_client.ts")),h=a(s("../attributes/abstract/serialized_change_with_metadata.ts")),l=a(s("../attributes/key_value/key_value_change.ts")),p=a(s("../../lib/utils/all_prefixes.ts"));class g extends d.default{static getDataTypePrefix(){return"kv"}static getDataTypeName(){return"keyValue"}getDataTypePrefix(){return g.getDataTypePrefix()}getDataTypeName(){return g.getDataTypeName()}getDefaultValue(){return{}}deserializeValue(e){return Promise.resolve((0,c.unflatten)(JSON.parse(e)))}async getValue(){if(await this.load())return this.value?JSON.parse(JSON.stringify(this.value)):this.value}async patch(e){return this.change(new l.default(Object.entries(e).map(([e,t])=>({key:e,value:t}))))}async rawSet(e){let t=[];const s=(0,c.default)(this.value),r=(0,c.default)(e);Object.entries(s).forEach(([e])=>{(0,p.default)(e.split(".")).forEach(e=>{t.push({key:e.join("."),value:null})})}),t=t.filter(({key:t})=>null===(0,u.default)(e,t)||void 0===(0,u.default)(e,t)),Object.entries(r).forEach(([e,r])=>{s[e]!==r&&t.push({key:e,value:r})}),t.length&&await this.change(new l.default(t))}async rawChange(e){const t=e.change.filter(({key:e,value:t})=>!(this.value[e]||!t)||!(!this.value[e]||t)||JSON.stringify(this.value[e])!==JSON.stringify(t));if(0===t.length)return!0;const s=await this.transmitChange(new l.default(t,this.version));return s&&(this.notifySubscribers(e),this.value=e.apply(this.value)),s}onLoad(){}onServerMessage(e){const t=new l.default(e.change,e.change.changeId);e.clientId!==this.clientId&&(this.value=t.apply(this.value),this.version=t.changeId,this.notifySubscribers(t,e))}transmitChange(e){if(!this.id)throw new Error("change can not be transmitted because attribute does not has an id");if(!this.actorId)throw new Error("actorId is unknown, can not transmit change!");return this.sendToServer(new h.default(this.id,this.actorId,this.clientId,e))}}t.default=g},"../attributes/key_value/key_value_change.ts"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s("../../node_modules/set-value/index.js")),i=r(s("../../lib/utils/unset.ts"));class o{changeId;change;static fromJSON(e,t){return new o(e,t)}static fromString(e){return new o(JSON.parse(e))}constructor(e,t){this.changeId=t??"uncommitted",this.change=e}toString(){return JSON.stringify(this.change)}toJSON(){return this.change}apply(e){const t=JSON.parse(JSON.stringify(e));return this.change.forEach?(this.change.forEach(e=>{null===e.value?(0,i.default)(t,e.key):(0,n.default)(t,e.key,e.value)}),t):t}merge(e){let t=[];return this.change.forEach(e=>{t=t.filter(t=>t.key!==e.key),t.push(e)}),e.change.forEach(e=>{t=t.filter(t=>t.key!==e.key),t.push(e)}),new o(t)}}t.default=o},"../attributes/long_text/client/buffer.ts"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{value;inFlightOp;init(e){this.inFlightOp=e}add(e){this.value=this.value?this.value.merge(e):e}transformAgainst(e){if(!this.inFlightOp)return e;const t=e.transformAgainst(this.inFlightOp,!0);if(this.inFlightOp=this.inFlightOp?.transformAgainst(e,!1),!this.value)return t;const s=t.transformAgainst(this.value,!0);return this.value=this.value?.transformAgainst(t,!1),s}get bridge(){if(this.inFlightOp)return this.value?this.inFlightOp.merge(this.value):this.inFlightOp}clear(){this.value=void 0,this.inFlightOp=void 0}getValue(){return this.value}}},"../attributes/long_text/client/index.ts"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s("../attributes/abstract/abstract_attribute_client.ts")),i=r(s("../attributes/abstract/serialized_change_with_metadata.ts")),o=r(s("../attributes/long_text/long_text_change.ts")),a=r(s("../attributes/long_text/client/buffer.ts"));class c extends n.default{buffer=new a.default;changeInTransmission=void 0;changeInTransmissionSendAt=void 0;static serverApprovalTimeoutInMS=2500;static getDataTypePrefix(){return"l"}static getDataTypeName(){return"longText"}getDataTypePrefix(){return"l"}getDataTypeName(){return c.getDataTypeName()}getDefaultValue(){return""}deserializeValue(e){return Promise.resolve(e)}async rawSet(e){const t=o.default.fromDiff(this.value,e);await this.change(t)}async rawChange(e){if(this.value=e.apply(this.value),this.changeInTransmission)this.getLastChangeTransmittedMillisecondsAgo()>c.serverApprovalTimeoutInMS&&this.linkedRecords.handleConnectionError(new Error(`No approval received from server after ${c.serverApprovalTimeoutInMS} ms`)),this.buffer.add(e);else if(!await this.transmitChange(new o.default(e.changeset,this.version)))return!1;return this.notifySubscribers(e),!0}getLastChangeTransmittedMillisecondsAgo(){return this.changeInTransmissionSendAt?(new Date).getTime()-this.changeInTransmissionSendAt.getTime():-1}onLoad(){this.changeInTransmission=void 0,this.changeInTransmissionSendAt=void 0,this.buffer.clear()}onServerMessage(e){e.clientId===this.clientId?this.processApproval(e):this.processForeignChange(e)}processForeignChange(e){let t,s;try{s=o.default.fromString(e.change.changeset),t=this.buffer.transformAgainst(s),this.value=t.apply(this.value),this.version=e.change.changeId,this.notifySubscribers(t,e)}catch(e){console.log(this.value),console.log(t?.changeset?.inspect()),console.log("ERROR: processing foreign change failed (probably because of a previous message loss). Reload server state to recover.",e),this.buffer.clear(),this.load(void 0,!0)}}processApproval(e){const t=this.buffer.getValue();this.changeInTransmission=void 0,this.changeInTransmissionSendAt=void 0,this.version=e.change.changeId,this.buffer.clear(),t&&this.transmitChange(new o.default(t.changeset,e.change.changeId))}transmitChange(e){if(!this.id)throw new Error("change can not be transmitted because attribute does not has an id");if(!this.actorId)throw new Error("actorId is unknown, can not transmit change!");return this.changeInTransmissionSendAt=new Date,this.changeInTransmission=new i.default(this.id,this.actorId,this.clientId,e),this.buffer.init(e),this.sendToServer(this.changeInTransmission)}}t.default=c},"../attributes/long_text/long_text_change.ts"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=s("../../node_modules/changesets/lib/index.js"),n=new(s("../../node_modules/diff_match_patch/lib/diff_match_patch.js").diff_match_patch);class i{changeset;changeId;constructor(e,t){this.changeset=e,this.changeId=t??"uncommitted"}static fromString(e){return new i(r.Changeset.unpack(e))}static fromDiff(e,t){return new i(r.Changeset.fromDiff(n.diff_main(e,t)))}apply(e){return this.changeset.apply(e)}toString(){return"string"==typeof this.changeset?this.changeset:this.changeset.pack()}transformAgainst(e,t){return e?new i(this.changeset.transformAgainst(e.changeset,t)):this}merge(e){return new i(this.changeset.merge(e.changeset))}toJSON(){return{changeset:this.toString(),changeId:this.changeId}}}t.default=i},"../facts/client/index.ts"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{linkedRecords;subject;predicate;object;constructor(e,t,s,r){this.linkedRecords=e,this.subject=t,this.predicate=s,this.object=r}toJSON(){return{subject:this.subject,predicate:this.predicate,object:this.object}}async save(){await this.linkedRecords.fetch("/facts",{method:"POST",body:JSON.stringify({subject:this.subject,predicate:this.predicate,object:this.object})})}}},"./attributes_repository.ts"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s("../attributes/long_text/client/index.ts")),i=r(s("../attributes/key_value/client/index.ts")),o=r(s("../attributes/blob/client/index.ts")),a=e=>JSON.stringify(e,(e,t)=>t===i.default?"KeyValueAttribute":t===n.default?"LongTextAttribute":t===o.default?"BlobAttribute":t),c=(e,t)=>e.id<t.id?-1:e.id>t.id?1:0;class u{linkedRecords;getClientServerBus;attributeCache;static attributeTypes=[n.default,i.default,o.default];constructor(e,t){this.linkedRecords=e,this.getClientServerBus=t,this.attributeCache={}}async idToAttribute(e,t=!1,s){const[r]=e.split("-"),n=u.attributeTypes.find(e=>e.getDataTypePrefix()===r);if(!n)return;if(this.attributeCache[e]&&!t)return this.attributeCache[e];const i=new n(this.linkedRecords,await this.getClientServerBus(),e);return s&&await i.load(s),this.attributeCache[e]=i,i}async createKeyValue(e,t){return await this.create("keyValue",e||{},t)}async createLongText(e,t){return await this.create("longText",e||"",t)}async createBlob(e,t){return await this.create("blob",e||"",t)}async create(e,t,s){const r=u.attributeTypes.find(t=>t.getDataTypeName()===e);if(!r)throw new Error(`Attribute Type ${e} is unknown`);const n=new r(this.linkedRecords,await this.getClientServerBus());return await n.create(t,s),n}async createAll(e){const t=`/attribute-compositions?clientId=${this.linkedRecords.clientId}`,s=await this.linkedRecords.fetch(t,{method:"POST",body:a(e)});if(!s)throw new Error("error creating attribute composition");const r=await s.json(),n={};return await Promise.all(Object.entries(r).map(async([e,t])=>{if(t.id){const s=await this.idToAttribute(t.id,!1,t);if(!s)throw new Error(`Error transforming id to attribute: ${t.id}`);n[e]=s}})),n}async find(e,t=!1){const s=await this.idToAttribute(e,t);if(!s)throw new Error(`Attribute ID ${e} is unknown`);if(await s.get())return s}async findAll(e,t=!1){const s=new URLSearchParams;s.append("query",a(e));const r=await this.linkedRecords.fetch(`/attributes?${s.toString()}`),n=await r.json(),i={};return await Promise.all(Object.keys(n).map(async e=>{Array.isArray(n[e])?i[e]=(await Promise.all(n[e].map(e=>this.idToAttribute(e.id,t,e)))).sort(c):n[e]?i[e]=await this.idToAttribute(n[e].id,t,n[e]):i[e]=null})),i}async findAndLoadAll(e){const t=await this.findAll(e),s=[];return Object.keys(t).forEach(e=>{t[e]&&(Array.isArray(t[e])?t[e].forEach(e=>{s.push(e.load())}):s.push(t[e].load()))}),await Promise.all(s),t}async subscribeToQuery(e,t){if(!this.linkedRecords.actorId)throw new Error("Not ready to subscribe to queries yet: this.linkedRecords.actorId is not initialized");const s=await this.getClientServerBus(),r=new URL("query-sub",this.linkedRecords.serverURL).toString(),n=`query-sub:${this.linkedRecords.actorId}:${a(e)}`,i=()=>{this.findAndLoadAll(e).then(t)},o=await s.subscribe(r,n,void 0,i);return i(),()=>{s.unsubscribe(o)}}clearCache(){this.attributeCache={}}}t.default=u},"./facts_repository.ts"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s("../facts/client/index.ts"));t.default=class{linkedRecords;constructor(e){this.linkedRecords=e}async createAll(e){const t=await this.linkedRecords.fetch("/facts",{method:"POST",body:JSON.stringify(e)});return t?(await t.json()).map(e=>new n.default(this.linkedRecords,e.subject,e.predicate,e.object)):[]}async findAll(e){if(Array.isArray(e))return(await Promise.all(e.map(e=>this.findAll(e)))).flat();const{subject:t,predicate:s,object:r}=e,i=new URLSearchParams;t&&i.append("subject",JSON.stringify(t)),s&&i.append("predicate",JSON.stringify(s)),r&&i.append("object",JSON.stringify(r));const o=await this.linkedRecords.fetch(`/facts?${i.toString()}`);return(await o.json()).map(e=>new n.default(this.linkedRecords,e.subject,e.predicate,e.object))}async deleteAll(e){await this.linkedRecords.fetch("/facts/delete",{method:"POST",body:JSON.stringify(e)})}}},"./index.ts"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LongTextChange=t.KeyValueChange=t.KeyValueAttribute=t.LongTextAttribute=void 0;const n=s("../../node_modules/uuidv7/dist/index.cjs"),i=r(s("../attributes/long_text/client/index.ts"));t.LongTextAttribute=i.default;const o=r(s("../attributes/key_value/client/index.ts"));t.KeyValueAttribute=o.default;const a=r(s("../attributes/key_value/key_value_change.ts"));t.KeyValueChange=a.default;const c=r(s("../attributes/long_text/long_text_change.ts"));t.LongTextChange=c.default;const u=r(s("../../lib/client-server-bus/client/index.ts")),d=r(s("./facts_repository.ts")),h=r(s("./attributes_repository.ts")),l=s("./oidc.ts"),p={};class g{static fetchUserInfoPromise;KeyValueChange=a.default;clientServerBus;serverURL;loginHandler;connectionLostHandler;unknownServerErrorHandler;quotaViolationErrorHandler;authorizationErrorHandler;attributeClientIdSuffix=0;clientId;actorId;Attribute;Fact;oidcManager;qetQuotaPromise={};static getPublicClient(e){const t=new URL(e).toString().replace(/\/$/,""),s=p[t];if(void 0!==s)return s;const r={redirect_uri:`${window.location.origin}/callback`},n=new g(new URL(e),r);return n.setConnectionLostHandler(e=>{console.error("linkedRecords connection lost error:",e)}),n.setUnknownServerErrorHandler(()=>{console.error("server error")}),n.setLoginHandler(()=>{window.location.search.includes("email-not-verified")?console.log("the user must verify its email address."):n.login(),console.log("login required, set a login handler which prompts the user to login via linkedRecords.setLoginHandler")}),p[t]=n,n}constructor(e,t,s=!0,r=!1){if(this.serverURL=e,t&&(this.oidcManager=new l.OIDCManager(t,e)),this.clientServerBus=new u.default(()=>this.getAccessToken()),this.clientServerBus.subscribeConnectionInterrupted(()=>{this.connectionLostHandler&&this.connectionLostHandler()}),this.Attribute=new h.default(this,()=>this.getClientServerBus()),this.clientId=(0,n.uuidv7)(),this.Fact=new d.default(this),r||this.ensureUserIdIsKnown(),this.oidcManager&&s&&"undefined"!=typeof window&&window.location&&window.location.search){const e=new URLSearchParams(window.location.search);e.has("code")&&e.has("state")&&this.oidcManager.handleRedirectCallback().then(()=>{window.history.replaceState({},document.title,window.location.pathname)})}}getAttributeClientId(){return this.attributeClientIdSuffix+=1,`${this.clientId}-${this.attributeClientIdSuffix}`}async getClientServerBus(){return this.clientServerBus}async getUserIdByEmail(e){const t=await this.fetch(`/userinfo?email=${encodeURIComponent(e)}`);return(await t.json()).id}async isAuthorizedToSeeMemberOf(e){return!!await this.fetch(`/attributes/${e}/members?clientId=${this.clientId}`,{doNotHandleExpiredSessions:!0})}async getMembersOf(e){const t=await this.fetch(`/attributes/${e}/members?clientId=${this.clientId}`);if(!t)throw new Error(`Unauthorized member query for ${e}`);const s=await t.json();if(s.notVisibleToUser)throw new Error(`Unauthorized member query for ${e}`);return s}async getQuota(e){if(this.qetQuotaPromise[e||""])return this.qetQuotaPromise[e||""];this.qetQuotaPromise[e||""]=this.ensureUserIdIsKnown().then(t=>this.fetch(`/quota/${e||t}`)).then(e=>e.json());const t=await this.qetQuotaPromise[e||""];return delete this.qetQuotaPromise[e||""],t}async fetch(e,t){const s=await(this.oidcManager?.isOnRedirectUriRoute()),{headers:r,method:n="GET",body:i,isJSON:o=!0,doNotHandleExpiredSessions:a=!1,skipWaitForUserId:c=!1}=t||{};s&&await new Promise(e=>{setTimeout(e,2e3)}),c||await this.ensureUserIdIsKnown();const u=new URL(e,this.serverURL).toString(),d={method:n,credentials:"include"},h=r?{...r}:{};if(this.oidcManager){const e=await this.oidcManager.getAccessToken();e&&(h.Authorization=`Bearer ${e}`,d.credentials="same-origin")}i&&(d.body=i),Object.keys(h).length>0&&(d.headers=h),o&&(d.headers||(d.headers={}),d.headers.Accept="application/json",d.headers["Content-Type"]="application/json");const l=await this.withConnectionLostHandler(()=>fetch(u,d));if(401===l.status)return console.error(`Authentication Error when calling ${n} ${e} ${await l.text()}`),a||this.handleExpiredLoginSession(),!1;if(403===l.status){const e=l.clone();return(await e.text()).startsWith("Not enough storage space")?this.handleQuotaViolationError(l):this.handleAuthorizationError(l),!1}return l.ok?l:(this.handleUnknownServerError(l),!1)}async withConnectionLostHandler(e){try{return await e()}catch(e){return"Failed to fetch"===e.message&&this.handleConnectionError(e),!1}}setConnectionLostHandler(e){this.connectionLostHandler=e}handleConnectionError(e){this.connectionLostHandler?this.connectionLostHandler(e):console.log("Connection Lost",e)}setLoginHandler(e){this.loginHandler=e}handleExpiredLoginSession(){this.loginHandler&&this.loginHandler()}setUnknownServerErrorHandler(e){this.unknownServerErrorHandler=e}handleUnknownServerError(e){this.unknownServerErrorHandler?this.unknownServerErrorHandler(e):console.log("UnknownServerError",e)}setQuotaViolationErrorHandler(e){this.quotaViolationErrorHandler=e}handleQuotaViolationError(e){this.quotaViolationErrorHandler?this.quotaViolationErrorHandler(e):this.handleUnknownServerError(e)}setAuthorizationErrorHandler(e){this.authorizationErrorHandler=e}handleAuthorizationError(e){if(!this.authorizationErrorHandler)throw new Error("User is not allowed to perform operation");this.authorizationErrorHandler(e)}async fetchUserInfo(){g.fetchUserInfoPromise||(g.fetchUserInfoPromise=this.fetch("/userinfo",{skipWaitForUserId:!0}).then(async e=>{if(e&&401!==e.status)return await e.json();this.handleExpiredLoginSession()}));try{return await g.fetchUserInfoPromise}finally{g.fetchUserInfoPromise=void 0}}async ensureUserIdIsKnown(){if(this.actorId&&"string"==typeof this.actorId)return this.actorId;const e=await this.fetchUserInfo();return e?(this.actorId=e.userId,this.actorId):void 0}async getCurrentUserEmail(){const e=await this.fetchUserInfo();if(!e||!e.userEmail)throw new Error("Error fetching user info");return e.userEmail}async login(){if(!this.oidcManager)throw new Error("OIDC not configured");await this.oidcManager.login()}async handleRedirectCallback(){if(!this.oidcManager)throw new Error("OIDC not configured");return this.oidcManager.handleRedirectCallback()}async logout(){if(!this.oidcManager)throw new Error("OIDC not configured");await this.oidcManager.logout()}async isAuthenticated(){return!!this.oidcManager&&this.oidcManager.isAuthenticated()}async getUser(){return this.oidcManager?this.oidcManager.getUser():null}async getAccessToken(){return this.oidcManager?this.oidcManager.getAccessToken():null}}t.default=g},"./oidc.ts"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OIDCManager=void 0;const r=s("../../node_modules/oidc-client-ts/dist/umd/oidc-client-ts.js");t.OIDCManager=class{userManager;user=null;ready;redirectOriginPath;constructor(e,t){const{redirect_uri:s}=e;this.ready=this.initialize(e,t);try{const e=new URL(s);this.redirectOriginPath=`${e.origin}${e.pathname}`}catch(e){throw new Error(`Invalid redirect URI ${s}`)}}async initialize(e,t){const{authority:s,client_id:n,redirect_uri:i,post_logout_redirect_uri:o,scope:a,response_type:c,silent_redirect_uri:u,automaticSilentRenew:d,useSessionStorage:h}=e;let l=s,p=n;if(!l){const e=t.toString().replace(/\/$/,""),s=await fetch(`${e}/oidc/discovery`);if(!s.ok)throw new Error(`Failed to discover OIDC authority: ${s.status} ${s.statusText}`);const r=await s.json();if(l=r&&"string"==typeof r.authority?r.authority:void 0,!l)throw new Error("OIDC discovery did not return an authority");p||(p=r.client_id)}if(!p)throw new Error("OIDC discovery did not return an clientId, you need to provide one when initializing LinkedRecords");const g={authority:l,client_id:p,redirect_uri:i,post_logout_redirect_uri:o,scope:a||"openid profile email",response_type:c||"code",userStore:new r.WebStorageStateStore({store:h?window.sessionStorage:window.localStorage}),silent_redirect_uri:u,automaticSilentRenew:d??!0,extraQueryParams:{audience:t.host}};this.userManager=new r.UserManager(g)}async login(){if(await this.ready,await this.isOnRedirectUriRoute())return;await this.userManager.removeUser();const e=window.location.pathname+window.location.search+window.location.hash;window.sessionStorage.setItem("lr_return_to",e),await this.userManager.signinRedirect()}async handleRedirectCallback(){await this.ready,this.user=await this.userManager.signinRedirectCallback();const e=window.sessionStorage.getItem("lr_return_to");return window.sessionStorage.removeItem("lr_return_to"),e&&"string"==typeof e&&(window.location.href=e),this.user}async logout(){await this.ready,await this.userManager.removeUser(),await this.userManager.signoutRedirect()}async getUser(){return await this.ready,this.user||(this.user=await this.userManager.getUser()),this.user}async isAuthenticated(){const e=await this.getUser();return!!e&&!e.expired}async getAccessToken(){const e=await this.getUser();return e&&!e.expired?e.access_token:null}async signinSilent(){return await this.ready,this.user=await this.userManager.signinSilent(),this.user}async isOnRedirectUriRoute(){return`${window.location.origin}${window.location.pathname}`===this.redirectOriginPath}}},"../../node_modules/engine.io-client/build/cjs/contrib/has-cors.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasCORS=void 0;let s=!1;try{s="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}t.hasCORS=s},"../../node_modules/engine.io-client/build/cjs/contrib/parseqs.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){let t="";for(let s in e)e.hasOwnProperty(s)&&(t.length&&(t+="&"),t+=encodeURIComponent(s)+"="+encodeURIComponent(e[s]));return t},t.decode=function(e){let t={},s=e.split("&");for(let e=0,r=s.length;e<r;e++){let r=s[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}},"../../node_modules/engine.io-client/build/cjs/contrib/parseuri.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=function(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),i=e.indexOf("]");-1!=n&&-1!=i&&(e=e.substring(0,n)+e.substring(n,i).replace(/:/g,";")+e.substring(i,e.length));let o=s.exec(e||""),a={},c=14;for(;c--;)a[r[c]]=o[c]||"";return-1!=n&&-1!=i&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(e,t){const s=t.replace(/\/{2,9}/g,"/").split("/");return"/"!=t.slice(0,1)&&0!==t.length||s.splice(0,1),"/"==t.slice(-1)&&s.splice(s.length-1,1),s}(0,a.path),a.queryKey=function(e,t){const s={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(s[t]=r)}),s}(0,a.query),a};const s=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"]},"../../node_modules/engine.io-client/build/cjs/globals.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultBinaryType=t.globalThisShim=t.nextTick=void 0,t.createCookieJar=function(){},t.nextTick="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),t.globalThisShim="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")(),t.defaultBinaryType="arraybuffer"},"../../node_modules/engine.io-client/build/cjs/index.js"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.nextTick=t.parse=t.installTimerFunctions=t.transports=t.TransportError=t.Transport=t.protocol=t.SocketWithUpgrade=t.SocketWithoutUpgrade=t.Socket=void 0;const r=s("../../node_modules/engine.io-client/build/cjs/socket.js");Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return r.Socket}});var n=s("../../node_modules/engine.io-client/build/cjs/socket.js");Object.defineProperty(t,"SocketWithoutUpgrade",{enumerable:!0,get:function(){return n.SocketWithoutUpgrade}}),Object.defineProperty(t,"SocketWithUpgrade",{enumerable:!0,get:function(){return n.SocketWithUpgrade}}),t.protocol=r.Socket.protocol;var i=s("../../node_modules/engine.io-client/build/cjs/transport.js");Object.defineProperty(t,"Transport",{enumerable:!0,get:function(){return i.Transport}}),Object.defineProperty(t,"TransportError",{enumerable:!0,get:function(){return i.TransportError}});var o=s("../../node_modules/engine.io-client/build/cjs/transports/index.js");Object.defineProperty(t,"transports",{enumerable:!0,get:function(){return o.transports}});var a=s("../../node_modules/engine.io-client/build/cjs/util.js");Object.defineProperty(t,"installTimerFunctions",{enumerable:!0,get:function(){return a.installTimerFunctions}});var c=s("../../node_modules/engine.io-client/build/cjs/contrib/parseuri.js");Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return c.parse}});var u=s("../../node_modules/engine.io-client/build/cjs/globals.js");Object.defineProperty(t,"nextTick",{enumerable:!0,get:function(){return u.nextTick}});var d=s("../../node_modules/engine.io-client/build/cjs/transports/polling-fetch.js");Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return d.Fetch}});var h=s("../../node_modules/engine.io-client/build/cjs/transports/polling-xhr.js");Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return h.XHR}});var l=s("../../node_modules/engine.io-client/build/cjs/transports/polling-xhr.js");Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return l.XHR}});var p=s("../../node_modules/engine.io-client/build/cjs/transports/websocket.js");Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return p.WS}});var g=s("../../node_modules/engine.io-client/build/cjs/transports/websocket.js");Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return g.WS}});var f=s("../../node_modules/engine.io-client/build/cjs/transports/webtransport.js");Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return f.WT}})},"../../node_modules/engine.io-client/build/cjs/socket.js"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=t.SocketWithUpgrade=t.SocketWithoutUpgrade=void 0;const n=s("../../node_modules/engine.io-client/build/cjs/transports/index.js"),i=s("../../node_modules/engine.io-client/build/cjs/util.js"),o=s("../../node_modules/engine.io-client/build/cjs/contrib/parseqs.js"),a=s("../../node_modules/engine.io-client/build/cjs/contrib/parseuri.js"),c=s("../../node_modules/@socket.io/component-emitter/index.mjs"),u=s("../../node_modules/engine.io-parser/build/cjs/index.js"),d=s("../../node_modules/engine.io-client/build/cjs/globals.js"),h=(0,r(s("../../node_modules/engine.io-client/node_modules/debug/src/browser.js")).default)("engine.io-client:socket"),l="function"==typeof addEventListener&&"function"==typeof removeEventListener,p=[];l&&addEventListener("offline",()=>{h("closing %d connection(s) because the network was lost",p.length),p.forEach(e=>e())},!1);class g extends c.Emitter{constructor(e,t){if(super(),this.binaryType=d.defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const s=(0,a.parse)(e);t.hostname=s.host,t.secure="https"===s.protocol||"wss"===s.protocol,t.port=s.port,s.query&&(t.query=s.query)}else t.host&&(t.hostname=(0,a.parse)(t.host).host);(0,i.installTimerFunctions)(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=(0,o.decode)(this.opts.query)),l&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(h("adding listener for the 'offline' event"),this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},p.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=(0,d.createCookieJar)()),this._open()}createTransport(e){h('creating transport "%s"',e);const t=Object.assign({},this.opts.query);t.EIO=u.protocol,t.transport=e,this.id&&(t.sid=this.id);const s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return h("options: %j",s),new this._transportsByName[e](s)}_open(){if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);const e=this.opts.rememberUpgrade&&g.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){h("setting transport %s",e.name),this.transport&&(h("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){h("socket open"),this.readyState="open",g.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(h('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}else h('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();h("flushing %d packets in socket",e.length),this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const s=this.writeBuffer[t].data;if(s&&(e+=(0,i.byteLength)(s)),t>0&&e>this._maxPayload)return h("only send %d out of %d packets",t,this.writeBuffer.length),this.writeBuffer.slice(0,t);e+=2}return h("payload size is %d (max: %d)",e,this._maxPayload),this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(h("throttled timer detected, scheduling connection close"),this._pingTimeoutTime=0,(0,d.nextTick)(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,s){return this._sendPacket("message",e,t,s),this}send(e,t,s){return this._sendPacket("message",e,t,s),this}_sendPacket(e,t,s,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof s&&(r=s,s=null),"closing"===this.readyState||"closed"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const n={type:e,data:t,options:s};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),h("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(h("socket error %j",e),g.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return h("trying next transport"),this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(h('socket close with reason: "%s"',e),this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),l&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=p.indexOf(this._offlineEventListener);-1!==e&&(h("removing listener for the 'offline' event"),p.splice(e,1))}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}t.SocketWithoutUpgrade=g,g.protocol=u.protocol;class f extends g{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade){h("starting upgrade probes");for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}}_probe(e){h('probing transport "%s"',e);let t=this.createTransport(e),s=!1;g.priorWebsocketSuccess=!1;const r=()=>{s||(h('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",r=>{if(!s)if("pong"===r.type&&"probe"===r.data){if(h('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;g.priorWebsocketSuccess="websocket"===t.name,h('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{s||"closed"!==this.readyState&&(h("changing transport and sending upgrade packet"),u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{h('probe transport "%s" failed',e);const s=new Error("probe error");s.transport=t.name,this.emitReserved("upgradeError",s)}}))};function n(){s||(s=!0,u(),t.close(),t=null)}const i=s=>{const r=new Error("probe error: "+s);r.transport=t.name,n(),h('probe transport "%s" failed because of error: %s',e,s),this.emitReserved("upgradeError",r)};function o(){i("transport closed")}function a(){i("socket closed")}function c(e){t&&e.name!==t.name&&(h('"%s" works - aborting "%s"',e.name,t.name),n())}const u=()=>{t.removeListener("open",r),t.removeListener("error",i),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",i),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}}t.SocketWithUpgrade=f,t.Socket=class extends f{constructor(e,t={}){const s="object"==typeof e?e:t;(!s.transports||s.transports&&"string"==typeof s.transports[0])&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(e=>n.transports[e]).filter(e=>!!e)),super(e,s)}}},"../../node_modules/engine.io-client/build/cjs/transport.js"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Transport=t.TransportError=void 0;const n=s("../../node_modules/engine.io-parser/build/cjs/index.js"),i=s("../../node_modules/@socket.io/component-emitter/index.mjs"),o=s("../../node_modules/engine.io-client/build/cjs/util.js"),a=s("../../node_modules/engine.io-client/build/cjs/contrib/parseqs.js"),c=(0,r(s("../../node_modules/engine.io-client/node_modules/debug/src/browser.js")).default)("engine.io-client:transport");class u extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}t.TransportError=u;class d extends i.Emitter{constructor(e){super(),this.writable=!1,(0,o.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new u(e,t,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState?this.write(e):c("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=(0,n.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&443!==Number(this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=(0,a.encode)(e);return t.length?"?"+t:""}}t.Transport=d},"../../node_modules/engine.io-client/build/cjs/transports/index.js"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.transports=void 0;const r=s("../../node_modules/engine.io-client/build/cjs/transports/polling-xhr.js"),n=s("../../node_modules/engine.io-client/build/cjs/transports/websocket.js"),i=s("../../node_modules/engine.io-client/build/cjs/transports/webtransport.js");t.transports={websocket:n.WS,webtransport:i.WT,polling:r.XHR}},"../../node_modules/engine.io-client/build/cjs/transports/polling-fetch.js"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fetch=void 0;const r=s("../../node_modules/engine.io-client/build/cjs/transports/polling.js");class n extends r.Polling{doPoll(){this._fetch().then(e=>{if(!e.ok)return this.onError("fetch read error",e.status,e);e.text().then(e=>this.onData(e))}).catch(e=>{this.onError("fetch read error",e)})}doWrite(e,t){this._fetch(e).then(e=>{if(!e.ok)return this.onError("fetch write error",e.status,e);t()}).catch(e=>{this.onError("fetch write error",e)})}_fetch(e){var t;const s=void 0!==e,r=new Headers(this.opts.extraHeaders);return s&&r.set("content-type","text/plain;charset=UTF-8"),null===(t=this.socket._cookieJar)||void 0===t||t.appendCookies(r),fetch(this.uri(),{method:s?"POST":"GET",body:s?e:null,headers:r,credentials:this.opts.withCredentials?"include":"omit"}).then(e=>{var t;return null===(t=this.socket._cookieJar)||void 0===t||t.parseCookies(e.headers.getSetCookie()),e})}}t.Fetch=n},"../../node_modules/engine.io-client/build/cjs/transports/polling-xhr.js"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XHR=t.Request=t.BaseXHR=void 0;const n=s("../../node_modules/engine.io-client/build/cjs/transports/polling.js"),i=s("../../node_modules/@socket.io/component-emitter/index.mjs"),o=s("../../node_modules/engine.io-client/build/cjs/util.js"),a=s("../../node_modules/engine.io-client/build/cjs/globals.js"),c=s("../../node_modules/engine.io-client/build/cjs/contrib/has-cors.js"),u=(0,r(s("../../node_modules/engine.io-client/node_modules/debug/src/browser.js")).default)("engine.io-client:polling");function d(){}class h extends n.Polling{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let s=location.port;s||(s=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){u("xhr poll");const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e,t)=>{this.onError("xhr poll error",e,t)}),this.pollXhr=e}}t.BaseXHR=h;class l extends i.Emitter{constructor(e,t,s){super(),this.createRequest=e,(0,o.installTimerFunctions)(this,s),this._opts=s,this._method=s.method||"GET",this._uri=t,this._data=void 0!==s.data?s.data:null,this._create()}_create(){var e;const t=(0,o.pick)(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(t);try{u("xhr open %s: %s",this._method,this._uri),s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&s.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(e){}if("POST"===this._method)try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{s.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this._opts.cookieJar)||void 0===e||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var e;3===s.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(s.getResponseHeader("set-cookie"))),4===s.readyState&&(200===s.status||1223===s.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof s.status?s.status:0)},0))},u("xhr data %s",this._data),s.send(this._data)}catch(e){return void this.setTimeoutFn(()=>{this._onError(e)},0)}"undefined"!=typeof document&&(this._index=l.requestsCount++,l.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=d,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete l.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(t.Request=l,l.requestsCount=0,l.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",p);else if("function"==typeof addEventListener){const e="onpagehide"in a.globalThisShim?"pagehide":"unload";addEventListener(e,p,!1)}function p(){for(let e in l.requests)l.requests.hasOwnProperty(e)&&l.requests[e].abort()}const g=function(){const e=f({xdomain:!1});return e&&null!==e.responseType}();function f(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||c.hasCORS))return new XMLHttpRequest}catch(e){}if(!t)try{return new(a.globalThisShim[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}t.XHR=class extends h{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=g&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new l(f,this.uri(),e)}}},"../../node_modules/engine.io-client/build/cjs/transports/polling.js"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Polling=void 0;const n=s("../../node_modules/engine.io-client/build/cjs/transport.js"),i=s("../../node_modules/engine.io-client/build/cjs/util.js"),o=s("../../node_modules/engine.io-parser/build/cjs/index.js"),a=(0,r(s("../../node_modules/engine.io-client/node_modules/debug/src/browser.js")).default)("engine.io-client:polling");class c extends n.Transport{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{a("paused"),this.readyState="paused",e()};if(this._polling||!this.writable){let e=0;this._polling&&(a("we are currently polling - waiting to pause"),e++,this.once("pollComplete",function(){a("pre-pause polling complete"),--e||t()})),this.writable||(a("we are currently writing - waiting to pause"),e++,this.once("drain",function(){a("pre-pause writing complete"),--e||t()}))}else t()}_poll(){a("polling"),this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){a("polling got data %s",e),(0,o.decodePayload)(e,this.socket.binaryType).forEach(e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)}),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState?this._poll():a('ignoring poll - transport state "%s"',this.readyState))}doClose(){const e=()=>{a("writing close packet"),this.write([{type:"close"}])};"open"===this.readyState?(a("transport open - closing"),e()):(a("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,o.encodePayload)(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,i.randomString)()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}t.Polling=c},"../../node_modules/engine.io-client/build/cjs/transports/websocket.js"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WS=t.BaseWS=void 0;const n=s("../../node_modules/engine.io-client/build/cjs/transport.js"),i=s("../../node_modules/engine.io-client/build/cjs/util.js"),o=s("../../node_modules/engine.io-parser/build/cjs/index.js"),a=s("../../node_modules/engine.io-client/build/cjs/globals.js"),c=(0,r(s("../../node_modules/engine.io-client/node_modules/debug/src/browser.js")).default)("engine.io-client:websocket"),u="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class d extends n.Transport{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,s=u?{}:(0,i.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;(0,o.encodePacket)(s,this.supportsBinary,e=>{try{this.doWrite(s,e)}catch(e){c("websocket closed before onclose event")}r&&(0,a.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,i.randomString)()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}t.BaseWS=d;const h=a.globalThisShim.WebSocket||a.globalThisShim.MozWebSocket;t.WS=class extends d{createSocket(e,t,s){return u?new h(e,t,s):t?new h(e,t):new h(e)}doWrite(e,t){this.ws.send(t)}}},"../../node_modules/engine.io-client/build/cjs/transports/webtransport.js"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WT=void 0;const n=s("../../node_modules/engine.io-client/build/cjs/transport.js"),i=s("../../node_modules/engine.io-client/build/cjs/globals.js"),o=s("../../node_modules/engine.io-parser/build/cjs/index.js"),a=(0,r(s("../../node_modules/engine.io-client/node_modules/debug/src/browser.js")).default)("engine.io-client:webtransport");class c extends n.Transport{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{a("transport closed gracefully"),this.onClose()}).catch(e=>{a("transport closed due to %s",e),this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=(0,o.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),r=(0,o.createPacketEncoderStream)();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const n=()=>{s.read().then(({done:e,value:t})=>{e?a("session is closed"):(a("received chunk: %o",t),this.onPacket(t),n())}).catch(e=>{a("an error occurred while reading: %s",e)})};n();const i={type:"open"};this.query.sid&&(i.data=`{"sid":"${this.query.sid}"}`),this._writer.write(i).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;this._writer.write(s).then(()=>{r&&(0,i.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}}t.WT=c},"../../node_modules/engine.io-client/build/cjs/util.js"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pick=function(e,...t){return t.reduce((t,s)=>(e.hasOwnProperty(s)&&(t[s]=e[s]),t),{})},t.installTimerFunctions=function(e,t){t.useNativeTimers?(e.setTimeoutFn=n.bind(r.globalThisShim),e.clearTimeoutFn=i.bind(r.globalThisShim)):(e.setTimeoutFn=r.globalThisShim.setTimeout.bind(r.globalThisShim),e.clearTimeoutFn=r.globalThisShim.clearTimeout.bind(r.globalThisShim))},t.byteLength=function(e){return"string"==typeof e?function(e){let t=0,s=0;for(let r=0,n=e.length;r<n;r++)t=e.charCodeAt(r),t<128?s+=1:t<2048?s+=2:t<55296||t>=57344?s+=3:(r++,s+=4);return s}(e):Math.ceil(1.33*(e.byteLength||e.size))},t.randomString=function(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)};const r=s("../../node_modules/engine.io-client/build/cjs/globals.js"),n=r.globalThisShim.setTimeout,i=r.globalThisShim.clearTimeout},"../../node_modules/engine.io-parser/build/cjs/commons.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_PACKET=t.PACKET_TYPES_REVERSE=t.PACKET_TYPES=void 0;const s=Object.create(null);t.PACKET_TYPES=s,s.open="0",s.close="1",s.ping="2",s.pong="3",s.message="4",s.upgrade="5",s.noop="6";const r=Object.create(null);t.PACKET_TYPES_REVERSE=r,Object.keys(s).forEach(e=>{r[s[e]]=e}),t.ERROR_PACKET={type:"error",data:"parser error"}},"../../node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=void 0;const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)r[s.charCodeAt(e)]=e;t.encode=e=>{let t,r=new Uint8Array(e),n=r.length,i="";for(t=0;t<n;t+=3)i+=s[r[t]>>2],i+=s[(3&r[t])<<4|r[t+1]>>4],i+=s[(15&r[t+1])<<2|r[t+2]>>6],i+=s[63&r[t+2]];return n%3==2?i=i.substring(0,i.length-1)+"=":n%3==1&&(i=i.substring(0,i.length-2)+"=="),i},t.decode=e=>{let t,s,n,i,o,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);const d=new ArrayBuffer(a),h=new Uint8Array(d);for(t=0;t<c;t+=4)s=r[e.charCodeAt(t)],n=r[e.charCodeAt(t+1)],i=r[e.charCodeAt(t+2)],o=r[e.charCodeAt(t+3)],h[u++]=s<<2|n>>4,h[u++]=(15&n)<<4|i>>2,h[u++]=(3&i)<<6|63&o;return d}},"../../node_modules/engine.io-parser/build/cjs/decodePacket.browser.js"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePacket=void 0;const r=s("../../node_modules/engine.io-parser/build/cjs/commons.js"),n=s("../../node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js"),i="function"==typeof ArrayBuffer;t.decodePacket=(e,t)=>{if("string"!=typeof e)return{type:"message",data:a(e,t)};const s=e.charAt(0);return"b"===s?{type:"message",data:o(e.substring(1),t)}:r.PACKET_TYPES_REVERSE[s]?e.length>1?{type:r.PACKET_TYPES_REVERSE[s],data:e.substring(1)}:{type:r.PACKET_TYPES_REVERSE[s]}:r.ERROR_PACKET};const o=(e,t)=>{if(i){const s=(0,n.decode)(e);return a(s,t)}return{base64:!0,data:e}},a=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},"../../node_modules/engine.io-parser/build/cjs/encodePacket.browser.js"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodePacket=t.encodePacketToBinary=void 0;const r=s("../../node_modules/engine.io-parser/build/cjs/commons.js"),n="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),i="function"==typeof ArrayBuffer,o=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,a=({type:e,data:t},s,a)=>n&&t instanceof Blob?s?a(t):c(t,a):i&&(t instanceof ArrayBuffer||o(t))?s?a(t):c(new Blob([t]),a):a(r.PACKET_TYPES[e]+(t||""));t.encodePacket=a;const c=(e,t)=>{const s=new FileReader;return s.onload=function(){const e=s.result.split(",")[1];t("b"+(e||""))},s.readAsDataURL(e)};function u(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let d;t.encodePacketToBinary=function(e,t){return n&&e.data instanceof Blob?e.data.arrayBuffer().then(u).then(t):i&&(e.data instanceof ArrayBuffer||o(e.data))?t(u(e.data)):void a(e,!1,e=>{d||(d=new TextEncoder),t(d.encode(e))})}},"../../node_modules/engine.io-parser/build/cjs/index.js"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePayload=t.decodePacket=t.encodePayload=t.encodePacket=t.protocol=t.createPacketDecoderStream=t.createPacketEncoderStream=void 0;const r=s("../../node_modules/engine.io-parser/build/cjs/encodePacket.browser.js");Object.defineProperty(t,"encodePacket",{enumerable:!0,get:function(){return r.encodePacket}});const n=s("../../node_modules/engine.io-parser/build/cjs/decodePacket.browser.js");Object.defineProperty(t,"decodePacket",{enumerable:!0,get:function(){return n.decodePacket}});const i=s("../../node_modules/engine.io-parser/build/cjs/commons.js"),o=String.fromCharCode(30);let a;function c(e){return e.reduce((e,t)=>e+t.length,0)}function u(e,t){if(e[0].length===t)return e.shift();const s=new Uint8Array(t);let r=0;for(let n=0;n<t;n++)s[n]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),s}t.encodePayload=(e,t)=>{const s=e.length,n=new Array(s);let i=0;e.forEach((e,a)=>{(0,r.encodePacket)(e,!1,e=>{n[a]=e,++i===s&&t(n.join(o))})})},t.decodePayload=(e,t)=>{const s=e.split(o),r=[];for(let e=0;e<s.length;e++){const i=(0,n.decodePacket)(s[e],t);if(r.push(i),"error"===i.type)break}return r},t.createPacketEncoderStream=function(){return new TransformStream({transform(e,t){(0,r.encodePacketToBinary)(e,s=>{const r=s.length;let n;if(r<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,r);else if(r<65536){n=new Uint8Array(3);const e=new DataView(n.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{n=new Uint8Array(9);const e=new DataView(n.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(n[0]|=128),t.enqueue(n),t.enqueue(s)})}})},t.createPacketDecoderStream=function(e,t){a||(a=new TextDecoder);const s=[];let r=0,o=-1,d=!1;return new TransformStream({transform(h,l){for(s.push(h);;){if(0===r){if(c(s)<1)break;const e=u(s,1);d=!(128&~e[0]),o=127&e[0],r=o<126?3:126===o?1:2}else if(1===r){if(c(s)<2)break;const e=u(s,2);o=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(c(s)<8)break;const e=u(s,8),t=new DataView(e.buffer,e.byteOffset,e.length),n=t.getUint32(0);if(n>Math.pow(2,21)-1){l.enqueue(i.ERROR_PACKET);break}o=n*Math.pow(2,32)+t.getUint32(4),r=3}else{if(c(s)<o)break;const e=u(s,o);l.enqueue((0,n.decodePacket)(d?e:a.decode(e),t)),r=0}if(0===o||o>e){l.enqueue(i.ERROR_PACKET);break}}}})},t.protocol=4},"../../node_modules/jwt-decode/build/cjs/index.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.jwtDecode=t.InvalidTokenError=void 0;class s extends Error{}t.InvalidTokenError=s,s.prototype.name="InvalidTokenError",t.jwtDecode=function(e,t){if("string"!=typeof e)throw new s("Invalid token specified: must be a string");t||(t={});const r=!0===t.header?0:1,n=e.split(".")[r];if("string"!=typeof n)throw new s(`Invalid token specified: missing part #${r+1}`);let i;try{i=function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,(e,t)=>{let s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s}))}(t)}catch(e){return atob(t)}}(n)}catch(e){throw new s(`Invalid token specified: invalid base64 for part #${r+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new s(`Invalid token specified: invalid json for part #${r+1} (${e.message})`)}}},"../../node_modules/socket.io-client/build/cjs/contrib/backo2.js"(e,t){"use strict";function s(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Object.defineProperty(t,"__esModule",{value:!0}),t.Backoff=s,s.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+s:e-s}return 0|Math.min(e,this.max)},s.prototype.reset=function(){this.attempts=0},s.prototype.setMin=function(e){this.ms=e},s.prototype.setMax=function(e){this.max=e},s.prototype.setJitter=function(e){this.jitter=e}},"../../node_modules/socket.io-client/build/cjs/index.js"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.Socket=t.Manager=t.protocol=void 0,t.io=u,t.connect=u,t.default=u;const n=s("../../node_modules/socket.io-client/build/cjs/url.js"),i=s("../../node_modules/socket.io-client/build/cjs/manager.js");Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return i.Manager}});const o=s("../../node_modules/socket.io-client/build/cjs/socket.js");Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return o.Socket}});const a=(0,r(s("../../node_modules/socket.io-client/node_modules/debug/src/browser.js")).default)("socket.io-client"),c={};function u(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const s=(0,n.url)(e,t.path||"/socket.io"),r=s.source,o=s.id,u=s.path,d=c[o]&&u in c[o].nsps;let h;return t.forceNew||t["force new connection"]||!1===t.multiplex||d?(a("ignoring socket cache for %s",r),h=new i.Manager(r,t)):(c[o]||(a("new io instance for %s",r),c[o]=new i.Manager(r,t)),h=c[o]),s.query&&!t.query&&(t.query=s.queryKey),h.socket(s.path,t)}Object.assign(u,{Manager:i.Manager,Socket:o.Socket,io:u,connect:u});var d=s("../../node_modules/socket.io-parser/build/cjs/index.js");Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return d.protocol}});var h=s("../../node_modules/engine.io-client/build/cjs/index.js");Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return h.Fetch}}),Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return h.NodeXHR}}),Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return h.XHR}}),Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return h.NodeWebSocket}}),Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return h.WebSocket}}),Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return h.WebTransport}}),e.exports=u},"../../node_modules/socket.io-client/build/cjs/manager.js"(e,t,s){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&r(t,e,s);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Manager=void 0;const a=s("../../node_modules/engine.io-client/build/cjs/index.js"),c=s("../../node_modules/socket.io-client/build/cjs/socket.js"),u=i(s("../../node_modules/socket.io-parser/build/cjs/index.js")),d=s("../../node_modules/socket.io-client/build/cjs/on.js"),h=s("../../node_modules/socket.io-client/build/cjs/contrib/backo2.js"),l=s("../../node_modules/@socket.io/component-emitter/index.mjs"),p=(0,o(s("../../node_modules/socket.io-client/node_modules/debug/src/browser.js")).default)("socket.io-client:manager");class g extends l.Emitter{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,(0,a.installTimerFunctions)(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(s=t.randomizationFactor)&&void 0!==s?s:.5),this.backoff=new h.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||u;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(p("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;p("opening %s",this.uri),this.engine=new a.Socket(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=(0,d.on)(t,"open",function(){s.onopen(),e&&e()}),n=t=>{p("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},i=(0,d.on)(t,"error",n);if(!1!==this._timeout){const e=this._timeout;p("connect attempt will timeout after %d",e);const s=this.setTimeoutFn(()=>{p("connect attempt timed out after %d",e),r(),n(new Error("timeout")),t.close()},e);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}return this.subs.push(r),this.subs.push(i),this}connect(e){return this.open(e)}onopen(){p("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push((0,d.on)(e,"ping",this.onping.bind(this)),(0,d.on)(e,"data",this.ondata.bind(this)),(0,d.on)(e,"error",this.onerror.bind(this)),(0,d.on)(e,"close",this.onclose.bind(this)),(0,d.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){(0,a.nextTick)(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){p("error",e),this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new c.Socket(this,e,t),this.nsps[e]=s),s}_destroy(e){const t=Object.keys(this.nsps);for(const e of t)if(this.nsps[e].active)return void p("socket %s is still active, skipping close",e);this._close()}_packet(e){p("writing packet %j",e);const t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){p("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){p("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;p("closed due to %s",e),this.cleanup(),null===(s=this.engine)||void 0===s||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)p("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();p("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(p("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(p("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):(p("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}t.Manager=g},"../../node_modules/socket.io-client/build/cjs/on.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.on=function(e,t,s){return e.on(t,s),function(){e.off(t,s)}}},"../../node_modules/socket.io-client/build/cjs/socket.js"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=void 0;const n=s("../../node_modules/socket.io-parser/build/cjs/index.js"),i=s("../../node_modules/socket.io-client/build/cjs/on.js"),o=s("../../node_modules/@socket.io/component-emitter/index.mjs"),a=(0,r(s("../../node_modules/socket.io-client/node_modules/debug/src/browser.js")).default)("socket.io-client:socket"),c=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class u extends o.Emitter{constructor(e,t,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[(0,i.on)(e,"open",this.onopen.bind(this)),(0,i.on)(e,"packet",this.onpacket.bind(this)),(0,i.on)(e,"error",this.onerror.bind(this)),(0,i.on)(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,r,i;if(c.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:n.PacketType.EVENT,data:t,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++;a("emitting packet with ack id %d",e);const s=t.pop();this._registerAckCallback(e,s),o.id=e}const u=null===(r=null===(s=this.io.engine)||void 0===s?void 0:s.transport)||void 0===r?void 0:r.writable,d=this.connected&&!(null===(i=this.io.engine)||void 0===i?void 0:i._hasPingExpired());return this.flags.volatile&&!u?a("discard packet as the transport is not currently writable"):d?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o),this.flags={},this}_registerAckCallback(e,t){var s;const r=null!==(s=this.flags.timeout)&&void 0!==s?s:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const n=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&(a("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(t,1));a("event with ack id %d has timed out after %d ms",e,r),t.call(this,new Error("operation has timed out"))},r),i=(...e)=>{this.io.clearTimeoutFn(n),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((s,r)=>{const n=(e,t)=>e?r(e):s(t);n.withError=!0,t.push(n),this.emit(e,...t)})}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>s!==this._queue[0]?a("packet [%d] already acknowledged",s.id):(null!==e?s.tryCount>this._opts.retries&&(a("packet [%d] is discarded after %d tries",s.id,s.tryCount),this._queue.shift(),t&&t(e)):(a("packet [%d] was successfully sent",s.id),this._queue.shift(),t&&t(null,...r)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(a("draining queue"),!this.connected||0===this._queue.length)return;const t=this._queue[0];!t.pending||e?(t.pending=!0,t.tryCount++,a("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)):a("packet [%d] has already been sent and is waiting for an ack",t.id)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){a("transport is open - connecting"),"function"==typeof this.auth?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:n.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){a("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case n.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case n.PacketType.EVENT:case n.PacketType.BINARY_EVENT:this.onevent(e);break;case n.PacketType.ACK:case n.PacketType.BINARY_ACK:this.onack(e);break;case n.PacketType.DISCONNECT:this.ondisconnect();break;case n.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const s of t)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let s=!1;return function(...r){s||(s=!0,a("sending ack %j",r),t.packet({type:n.PacketType.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t?(delete this.acks[e.id],a("calling ack %s with %j",e.id,e.data),t.withError&&e.data.unshift(null),t.apply(this,e.data)):a("bad ack %s",e.id)}onconnect(e,t){a("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:n.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const s of t)s.apply(this,e.data)}}}t.Socket=u},"../../node_modules/socket.io-client/build/cjs/url.js"(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.url=function(e,t="",s){let r=e;s=s||"undefined"!=typeof location&&location,null==e&&(e=s.protocol+"//"+s.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?s.protocol+e:s.host+e),/^(https?|wss?):\/\//.test(e)||(i("protocol-less url %s",e),e=void 0!==s?s.protocol+"//"+e:"https://"+e),i("parse %s",e),r=(0,n.parse)(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(s&&s.port===r.port?"":":"+r.port),r};const n=s("../../node_modules/engine.io-client/build/cjs/index.js"),i=(0,r(s("../../node_modules/socket.io-client/node_modules/debug/src/browser.js")).default)("socket.io-client:url")},"../../node_modules/socket.io-parser/build/cjs/binary.js"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reconstructPacket=t.deconstructPacket=void 0;const r=s("../../node_modules/socket.io-parser/build/cjs/is-binary.js");function n(e,t){if(!e)return e;if((0,r.isBinary)(e)){const s={_placeholder:!0,num:t.length};return t.push(e),s}if(Array.isArray(e)){const s=new Array(e.length);for(let r=0;r<e.length;r++)s[r]=n(e[r],t);return s}if("object"==typeof e&&!(e instanceof Date)){const s={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(s[r]=n(e[r],t));return s}return e}function i(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let s=0;s<e.length;s++)e[s]=i(e[s],t);else if("object"==typeof e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(e[s]=i(e[s],t));return e}t.deconstructPacket=function(e){const t=[],s=e.data,r=e;return r.data=n(s,t),r.attachments=t.length,{packet:r,buffers:t}},t.reconstructPacket=function(e,t){return e.data=i(e.data,t),delete e.attachments,e}},"../../node_modules/socket.io-parser/build/cjs/index.js"(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Decoder=t.Encoder=t.PacketType=t.protocol=void 0;const r=s("../../node_modules/@socket.io/component-emitter/index.mjs"),n=s("../../node_modules/socket.io-parser/build/cjs/binary.js"),i=s("../../node_modules/socket.io-parser/build/cjs/is-binary.js"),o=(0,s("../../node_modules/debug/src/browser.js").default)("socket.io-parser"),a=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;function u(e){return"[object Object]"===Object.prototype.toString.call(e)}t.protocol=5,function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(c=t.PacketType||(t.PacketType={})),t.Encoder=class{constructor(e){this.replacer=e}encode(e){return o("encoding packet %j",e),e.type!==c.EVENT&&e.type!==c.ACK||!(0,i.hasBinary)(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==c.BINARY_EVENT&&e.type!==c.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),o("encoded %j as %s",e,t),t}encodeAsBinary(e){const t=(0,n.deconstructPacket)(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}};class d extends r.Emitter{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const s=t.type===c.BINARY_EVENT;s||t.type===c.BINARY_ACK?(t.type=s?c.EVENT:c.ACK,this.reconstructor=new h(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!(0,i.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const s={type:Number(e.charAt(0))};if(void 0===c[s.type])throw new Error("unknown packet type "+s.type);if(s.type===c.BINARY_EVENT||s.type===c.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const n=e.substring(r,t);if(n!=Number(n)||"-"!==e.charAt(t))throw new Error("Illegal attachments");s.attachments=Number(n)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);s.nsp=e.substring(r,t)}else s.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const s=e.charAt(t);if(null==s||Number(s)!=s){--t;break}if(t===e.length)break}s.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!d.isPayloadValid(s.type,r))throw new Error("invalid payload");s.data=r}return o("decoded %s as %j",e,s),s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return u(t);case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||u(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}t.Decoder=d;class h{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=(0,n.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}},"../../node_modules/socket.io-parser/build/cjs/is-binary.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasBinary=t.isBinary=void 0;const s="function"==typeof ArrayBuffer,r=Object.prototype.toString,n="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===r.call(Blob),i="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===r.call(File);function o(e){return s&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||n&&e instanceof Blob||i&&e instanceof File}t.isBinary=o,t.hasBinary=function e(t,s){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let s=0,r=t.length;s<r;s++)if(e(t[s]))return!0;return!1}if(o(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&e(t[s]))return!0;return!1}},"../../node_modules/uuidv7/dist/index.cjs"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4obj=t.uuidv4=t.uuidv7obj=t.uuidv7=t.V7Generator=t.UUID=void 0;const s="0123456789abcdef";class r{constructor(e){this.bytes=e}static ofInner(e){if(16!==e.length)throw new TypeError("not 128-bit length");return new r(e)}static fromFieldsV7(e,t,s,n){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(s)||!Number.isInteger(n)||e<0||t<0||s<0||n<0||e>0xffffffffffff||t>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const i=new Uint8Array(16);return i[0]=e/2**40,i[1]=e/2**32,i[2]=e/2**24,i[3]=e/65536,i[4]=e/256,i[5]=e,i[6]=112|t>>>8,i[7]=t,i[8]=128|s>>>24,i[9]=s>>>16,i[10]=s>>>8,i[11]=s,i[12]=n>>>24,i[13]=n>>>16,i[14]=n>>>8,i[15]=n,new r(i)}static parse(e){var t,s,n,i;let o;switch(e.length){case 32:o=null===(t=/^[0-9a-f]{32}$/i.exec(e))||void 0===t?void 0:t[0];break;case 36:o=null===(s=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(e))||void 0===s?void 0:s.slice(1,6).join("");break;case 38:o=null===(n=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(e))||void 0===n?void 0:n.slice(1,6).join("");break;case 45:o=null===(i=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(e))||void 0===i?void 0:i.slice(1,6).join("")}if(o){const e=new Uint8Array(16);for(let t=0;t<16;t+=4){const s=parseInt(o.substring(2*t,2*t+8),16);e[t+0]=s>>>24,e[t+1]=s>>>16,e[t+2]=s>>>8,e[t+3]=s}return new r(e)}throw new SyntaxError("could not parse UUID string")}toString(){let e="";for(let t=0;t<this.bytes.length;t++)e+=s.charAt(this.bytes[t]>>>4),e+=s.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");return e}toHex(){let e="";for(let t=0;t<this.bytes.length;t++)e+=s.charAt(this.bytes[t]>>>4),e+=s.charAt(15&this.bytes[t]);return e}toJSON(){return this.toString()}getVariant(){const e=this.bytes[8]>>>4;if(e<0)throw new Error("unreachable");if(e<=7)return this.bytes.every(e=>0===e)?"NIL":"VAR_0";if(e<=11)return"VAR_10";if(e<=13)return"VAR_110";if(e<=15)return this.bytes.every(e=>255===e)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return"VAR_10"===this.getVariant()?this.bytes[6]>>>4:void 0}clone(){return new r(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(let t=0;t<16;t++){const s=this.bytes[t]-e.bytes[t];if(0!==s)return Math.sign(s)}return 0}}t.UUID=r;class n{constructor(e){this.timestamp=0,this.counter=0,this.random=null!=e?e:i()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(e,t){let s=this.generateOrAbortCore(e,t);return void 0===s&&(this.timestamp=0,s=this.generateOrAbortCore(e,t)),s}generateOrAbortCore(e,t){if(!Number.isInteger(e)||e<1||e>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(t<0||t>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+t>=this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return r.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}generateV4(){const e=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return e[6]=64|e[6]>>>4,e[8]=128|e[8]>>>2,r.ofInner(e)}}t.V7Generator=n;const i=()=>{if("undefined"!=typeof crypto&&void 0!==crypto.getRandomValues)return new o;if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");return{nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}};class o{constructor(){this.buffer=new Uint32Array(8),this.cursor=65535}nextUint32(){return this.cursor>=this.buffer.length&&(crypto.getRandomValues(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}let a;t.uuidv7=()=>(0,t.uuidv7obj)().toString(),t.uuidv7obj=()=>(a||(a=new n)).generate(),t.uuidv4=()=>(0,t.uuidv4obj)().toString(),t.uuidv4obj=()=>(a||(a=new n)).generateV4()},"../../node_modules/@socket.io/component-emitter/index.mjs"(e,t,s){"use strict";function r(e){if(e)return function(e){for(var t in r.prototype)e[t]=r.prototype[t];return e}(e)}s.r(t),s.d(t,{Emitter:()=>r}),r.prototype.on=r.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},r.prototype.once=function(e,t){function s(){this.off(e,s),t.apply(this,arguments)}return s.fn=t,this.on(e,s),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var n=0;n<r.length;n++)if((s=r[n])===t||s.fn===t){r.splice(n,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},r.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),s=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(s){r=0;for(var n=(s=s.slice(0)).length;r<n;++r)s[r].apply(this,t)}return this},r.prototype.emitReserved=r.prototype.emit,r.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},r.prototype.hasListeners=function(e){return!!this.listeners(e).length}}},t={};function s(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};if(!(r in e)){delete t[r];var o=new Error("Cannot find module '"+r+"'");throw o.code="MODULE_NOT_FOUND",o}return e[r].call(i.exports,i,i.exports,s),i.exports}return s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s("./index.ts")})());
3
+ //# sourceMappingURL=browser_sdk.js.map