@dstorage-tech/dstorage-sdk 0.0.4

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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +530 -0
  3. package/dist/KeypairEncryptionAdapter-AE75YC4W-AOWNSH2M.mjs +9 -0
  4. package/dist/KeypairEncryptionAdapter-AE75YC4W-BAVHRNNJ.mjs +1 -0
  5. package/dist/KeypairEncryptionAdapter-AE75YC4W-BEYO4RUO.mjs +1 -0
  6. package/dist/KeypairEncryptionAdapter-AE75YC4W-VAOH6AAL.mjs +9 -0
  7. package/dist/KeypairEncryptionAdapter-XUKCLRFU-6ERIZN2M.mjs +1 -0
  8. package/dist/KeypairEncryptionAdapter-XUKCLRFU-AYDAZ2TZ.mjs +9 -0
  9. package/dist/KeypairEncryptionAdapter-XUKCLRFU-ERPYK5S4.mjs +8 -0
  10. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-6DFVUVD6.mjs +1 -0
  11. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-O5AJPX42.mjs +1 -0
  12. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-SI6TBLTQ.mjs +9 -0
  13. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-WEPFOTSJ.mjs +9 -0
  14. package/dist/MnemonicEncryptionAdapter-RCHUETBP-DZPBGQG6.mjs +8 -0
  15. package/dist/MnemonicEncryptionAdapter-RCHUETBP-ELAMJMMO.mjs +1 -0
  16. package/dist/MnemonicEncryptionAdapter-RCHUETBP-M7NHGSHO.mjs +9 -0
  17. package/dist/PasswordEncryptionAdapter-CWOXUGR4-2YZ64B4A.mjs +1 -0
  18. package/dist/PasswordEncryptionAdapter-CWOXUGR4-DCEGC2NX.mjs +1 -0
  19. package/dist/PasswordEncryptionAdapter-CWOXUGR4-QEGGYPFJ.mjs +13 -0
  20. package/dist/PasswordEncryptionAdapter-CWOXUGR4-ZYUBUYUI.mjs +13 -0
  21. package/dist/PasswordEncryptionAdapter-ECHND672-3DEFO6FP.mjs +13 -0
  22. package/dist/PasswordEncryptionAdapter-ECHND672-MUTHAMZY.mjs +12 -0
  23. package/dist/PasswordEncryptionAdapter-ECHND672-XVBPHPPT.mjs +1 -0
  24. package/dist/browser.d.mts +2418 -0
  25. package/dist/browser.mjs +5175 -0
  26. package/dist/chunk-25I6ZXUC.mjs +9403 -0
  27. package/dist/chunk-4X5K43JF.mjs +62 -0
  28. package/dist/chunk-4YMF57VY.mjs +1 -0
  29. package/dist/chunk-5MZ7FPPY.mjs +1 -0
  30. package/dist/chunk-5P4EW2YL.mjs +1 -0
  31. package/dist/chunk-5QOKJEH3.mjs +8 -0
  32. package/dist/chunk-5RW7SGA7.mjs +1 -0
  33. package/dist/chunk-62RSKZ6T.mjs +118 -0
  34. package/dist/chunk-6IAQVMSM.mjs +102 -0
  35. package/dist/chunk-BBJCQFWP.mjs +275 -0
  36. package/dist/chunk-BWLEAAFW.mjs +2599 -0
  37. package/dist/chunk-EYF3263P.mjs +2049 -0
  38. package/dist/chunk-FJ7LSZOW.mjs +5537 -0
  39. package/dist/chunk-GUYENY5N.mjs +1 -0
  40. package/dist/chunk-HDD6SUU4.mjs +276 -0
  41. package/dist/chunk-JMPRZK5D.mjs +62 -0
  42. package/dist/chunk-L5QD6GHB.mjs +101 -0
  43. package/dist/chunk-O37NHERH.mjs +17 -0
  44. package/dist/chunk-OLGVVM5Y.mjs +102 -0
  45. package/dist/chunk-PKHRAYFD.mjs +1 -0
  46. package/dist/chunk-PLAOCKSS.mjs +101 -0
  47. package/dist/chunk-QKA2DCR6.mjs +118 -0
  48. package/dist/chunk-RPSRFFXN.mjs +275 -0
  49. package/dist/chunk-TESUOXRJ.mjs +1 -0
  50. package/dist/chunk-TMLXCRJU.mjs +1 -0
  51. package/dist/chunk-TNRKN4LB.mjs +1 -0
  52. package/dist/chunk-TSZ37JDY.mjs +2596 -0
  53. package/dist/chunk-U3MS6KMF.mjs +1 -0
  54. package/dist/chunk-UBALMYIY.mjs +2049 -0
  55. package/dist/chunk-UDYXMII2.mjs +121 -0
  56. package/dist/chunk-UJCSKKID.mjs +30 -0
  57. package/dist/chunk-UOOF4V2Y.mjs +1 -0
  58. package/dist/chunk-VDZ7F7MP.mjs +1329 -0
  59. package/dist/chunk-X4LEBNK6.mjs +276 -0
  60. package/dist/chunk-Z2TH6U4C.mjs +3 -0
  61. package/dist/chunk-Z6DUAI5B.mjs +121 -0
  62. package/dist/chunk-ZEPZ4QDD.mjs +1 -0
  63. package/dist/chunk-ZGUY5EIR.mjs +1 -0
  64. package/dist/cjs-RMZ3L2IO.mjs +5 -0
  65. package/dist/contract-api-AO4RGPLT-4HRCMSCE.mjs +279 -0
  66. package/dist/contract-api-AO4RGPLT-ADH6ZDKC.mjs +279 -0
  67. package/dist/contract-api-AO4RGPLT-ENC72WCG.mjs +280 -0
  68. package/dist/contract-api-AO4RGPLT-PAMIPEI3.mjs +1 -0
  69. package/dist/contract-api-AO4RGPLT-W3RSVP5A.mjs +1 -0
  70. package/dist/contract-api-AO4RGPLT-WENYDV6I.mjs +1 -0
  71. package/dist/contract-api-TJ7JPHZA-6FUBJ6DS.mjs +279 -0
  72. package/dist/contract-api-TJ7JPHZA-ZWP3EH7D.mjs +279 -0
  73. package/dist/contracts/dataregistry/managed/keys/removeReference.prover +0 -0
  74. package/dist/contracts/dataregistry/managed/keys/removeReference.verifier +0 -0
  75. package/dist/contracts/dataregistry/managed/keys/storeReference.prover +0 -0
  76. package/dist/contracts/dataregistry/managed/keys/storeReference.verifier +0 -0
  77. package/dist/contracts/dataregistry/managed/keys/updateReference.prover +0 -0
  78. package/dist/contracts/dataregistry/managed/keys/updateReference.verifier +0 -0
  79. package/dist/contracts/dataregistry/managed/zkir/removeReference.bzkir +0 -0
  80. package/dist/contracts/dataregistry/managed/zkir/removeReference.zkir +138 -0
  81. package/dist/contracts/dataregistry/managed/zkir/storeReference.bzkir +0 -0
  82. package/dist/contracts/dataregistry/managed/zkir/storeReference.zkir +158 -0
  83. package/dist/contracts/dataregistry/managed/zkir/updateReference.bzkir +0 -0
  84. package/dist/contracts/dataregistry/managed/zkir/updateReference.zkir +190 -0
  85. package/dist/dataregistry-simulator-E6RTGGWT-5YEGBW7P.mjs +108 -0
  86. package/dist/dataregistry-simulator-E6RTGGWT-DJS4MHBD.mjs +109 -0
  87. package/dist/dataregistry-simulator-E6RTGGWT-QGCYR3VF.mjs +1 -0
  88. package/dist/dist-655VYUPJ.mjs +1 -0
  89. package/dist/dist-INTAFXQ7.mjs +65 -0
  90. package/dist/dist-MEZZWKP4.mjs +1 -0
  91. package/dist/dist-MOLWJ4Y7.mjs +64 -0
  92. package/dist/dist-UD4WRMYJ.mjs +65 -0
  93. package/dist/errors.d.mts +117 -0
  94. package/dist/errors.d.ts +117 -0
  95. package/dist/errors.js +2308 -0
  96. package/dist/errors.mjs +2278 -0
  97. package/dist/esm5-AGBDHMNS.mjs +1 -0
  98. package/dist/esm5-GFOBLUFI.mjs +350 -0
  99. package/dist/in-memory-private-state-NGOP37V7-DXWZE42Q.mjs +48 -0
  100. package/dist/in-memory-private-state-NGOP37V7-QXT3RUEH.mjs +49 -0
  101. package/dist/in-memory-private-state-NGOP37V7-XFJFNFCQ.mjs +1 -0
  102. package/dist/index.d.mts +2843 -0
  103. package/dist/index.d.ts +2843 -0
  104. package/dist/index.js +19639 -0
  105. package/dist/index.mjs +5177 -0
  106. package/package.json +87 -0
@@ -0,0 +1,276 @@
1
+ import {
2
+ EncryptionErrorCode
3
+ } from "./chunk-O37NHERH.mjs";
4
+ import {
5
+ DStorageError,
6
+ deriveKek,
7
+ unwrapKey,
8
+ wrapKey
9
+ } from "./chunk-BWLEAAFW.mjs";
10
+
11
+ // ../encryption/dist/chunk-6IHXTW2Y.mjs
12
+ import { scrypt } from "@noble/hashes/scrypt.js";
13
+ var KDF_PRESETS = {
14
+ v1: { N: 131072, r: 8, p: 1 },
15
+ "v1-lite": { N: 65536, r: 8, p: 1 }
16
+ };
17
+ var PasswordEncryptionAdapter = class _PasswordEncryptionAdapter {
18
+ constructor(config) {
19
+ this.name = "password";
20
+ validatePassword(
21
+ config.password,
22
+ config.minPasswordLength ?? 12,
23
+ config.minEntropyBits ?? 60,
24
+ config.additionalValidators
25
+ );
26
+ this.salt = resolveSalt(config.salt);
27
+ const resolved = resolveParams(config.preset, config.params);
28
+ this.N = resolved.N;
29
+ this.r = resolved.r;
30
+ this.p = resolved.p;
31
+ const passwordBytes = new TextEncoder().encode(config.password);
32
+ const seed = scrypt(passwordBytes, this.salt, {
33
+ N: this.N,
34
+ r: this.r,
35
+ p: this.p,
36
+ dkLen: 64
37
+ });
38
+ this.kekMaterialPromise = globalThis.crypto.subtle.importKey("raw", seed, "HKDF", false, ["deriveBits"]).then(
39
+ (key) => {
40
+ seed.fill(0);
41
+ return key;
42
+ },
43
+ (err) => {
44
+ seed.fill(0);
45
+ throw err;
46
+ }
47
+ );
48
+ }
49
+ /**
50
+ * Reconstruct an adapter from parameters previously stored via `getKdfParams()`.
51
+ * Use this when loading existing encrypted data — ensures the exact same N/r/p
52
+ * are used regardless of what the current SDK defaults are.
53
+ *
54
+ * @example
55
+ * const adapter = PasswordEncryptionAdapter.fromKdfParams({
56
+ * password,
57
+ * salt: meta.salt,
58
+ * kdf: meta.kdf,
59
+ * N: meta.N,
60
+ * r: meta.r,
61
+ * p: meta.p,
62
+ * });
63
+ */
64
+ static fromKdfParams(config) {
65
+ if (config.kdf !== "scrypt") {
66
+ throw new DStorageError(
67
+ EncryptionErrorCode.PASSWORD_UNSUPPORTED_KDF,
68
+ `[dStorage] PasswordEncryptionAdapter.fromKdfParams: unsupported kdf "${config.kdf}". Only "scrypt" is supported.`
69
+ );
70
+ }
71
+ return new _PasswordEncryptionAdapter({
72
+ password: config.password,
73
+ salt: config.salt,
74
+ params: { N: config.N, r: config.r, p: config.p },
75
+ ...config.minPasswordLength !== void 0 && {
76
+ minPasswordLength: config.minPasswordLength
77
+ },
78
+ ...config.minEntropyBits !== void 0 && {
79
+ minEntropyBits: config.minEntropyBits
80
+ },
81
+ ...config.additionalValidators !== void 0 && {
82
+ additionalValidators: config.additionalValidators
83
+ }
84
+ });
85
+ }
86
+ /**
87
+ * Returns the resolved KDF parameters to store alongside encrypted data.
88
+ *
89
+ * These values are language- and SDK-agnostic: any scrypt implementation
90
+ * can re-derive the key from `{ kdf, N, r, p }` + the original salt and
91
+ * password, without any knowledge of this SDK's preset names.
92
+ *
93
+ * @example
94
+ * const meta = {
95
+ * ...adapter.getKdfParams(), // { kdf: "scrypt", N: 131072, r: 8, p: 1 }
96
+ * salt: "myapp:alice@example.com",
97
+ * };
98
+ * await db.save({ encryptedData, meta });
99
+ */
100
+ getKdfParams() {
101
+ return { kdf: "scrypt", N: this.N, r: this.r, p: this.p };
102
+ }
103
+ async wrapDek(dek) {
104
+ const kekMaterial = await this.kekMaterialPromise;
105
+ const kek = await deriveKek(kekMaterial);
106
+ try {
107
+ return {
108
+ algorithm: "xchacha20poly1305-v1",
109
+ kekDerivation: "hkdf-sha256-v1",
110
+ wrappedDek: await wrapKey(dek, kek)
111
+ };
112
+ } finally {
113
+ kek.fill(0);
114
+ }
115
+ }
116
+ async unwrapDek({ wrappedDek }) {
117
+ const kekMaterial = await this.kekMaterialPromise;
118
+ const kek = await deriveKek(kekMaterial);
119
+ try {
120
+ return unwrapKey(wrappedDek, kek);
121
+ } finally {
122
+ kek.fill(0);
123
+ }
124
+ }
125
+ /**
126
+ * Deterministically derive a ML-KEM keypair from this adapter's key material.
127
+ *
128
+ * Uses Web Crypto HKDF to derive a 64-byte ML-KEM seed from the stored
129
+ * CryptoKey, domain-separated from the symmetric KEK derivation path with
130
+ * info="dstorage:mlkem-seed:v1". This is equivalent to noble's
131
+ * hkdf(sha256, scryptOutput, undefined, info, 64) but avoids materialising
132
+ * the raw scrypt output in a JS-accessible variable.
133
+ *
134
+ * Same password + salt + variant always produces the same keypair.
135
+ *
136
+ * @param context Domain-separation string bound into the KEK derivation
137
+ * @param variant ML-KEM variant. Default: "mlkem768".
138
+ */
139
+ async intoKeypairEncryptionAdapter(context, variant) {
140
+ const { KeypairEncryptionAdapter } = await import("./KeypairEncryptionAdapter-XUKCLRFU-AYDAZ2TZ.mjs");
141
+ const { mlkemGenerateKeypairFromSeed } = await import("./dist-INTAFXQ7.mjs");
142
+ const kekMaterial = await this.kekMaterialPromise;
143
+ const mlkemBits = await globalThis.crypto.subtle.deriveBits(
144
+ {
145
+ name: "HKDF",
146
+ hash: "SHA-256",
147
+ salt: new Uint8Array(32),
148
+ info: new TextEncoder().encode("dstorage:mlkem-seed:v1")
149
+ },
150
+ kekMaterial,
151
+ 512
152
+ // 64 bytes
153
+ );
154
+ const mlkemSeed = new Uint8Array(mlkemBits);
155
+ try {
156
+ const { pk, sk } = mlkemGenerateKeypairFromSeed(mlkemSeed, variant);
157
+ return KeypairEncryptionAdapter.fromKeypair(pk, sk, context, variant);
158
+ } finally {
159
+ mlkemSeed.fill(0);
160
+ }
161
+ }
162
+ };
163
+ function resolveSalt(salt) {
164
+ const bytes = typeof salt === "string" ? new TextEncoder().encode(salt) : salt;
165
+ if (bytes.length === 0) {
166
+ throw new DStorageError(
167
+ EncryptionErrorCode.PASSWORD_EMPTY_SALT,
168
+ '[dStorage] PasswordEncryptionAdapter: salt must not be empty. Provide an app-specific domain label, e.g. "myapp:v1:alice@example.com".'
169
+ );
170
+ }
171
+ return bytes;
172
+ }
173
+ function resolveParams(preset, params) {
174
+ if (preset !== void 0) {
175
+ if (!(preset in KDF_PRESETS)) {
176
+ throw new DStorageError(
177
+ EncryptionErrorCode.PASSWORD_UNKNOWN_PRESET,
178
+ `[dStorage] PasswordEncryptionAdapter: unknown preset "${preset}". Valid presets: ${Object.keys(KDF_PRESETS).join(", ")}.`
179
+ );
180
+ }
181
+ return KDF_PRESETS[preset];
182
+ }
183
+ return {
184
+ N: params?.N ?? KDF_PRESETS["v1"].N,
185
+ r: params?.r ?? KDF_PRESETS["v1"].r,
186
+ p: params?.p ?? KDF_PRESETS["v1"].p
187
+ };
188
+ }
189
+ function estimateEntropyBits(password) {
190
+ let pool = 0;
191
+ if (/[a-z]/.test(password)) pool += 26;
192
+ if (/[A-Z]/.test(password)) pool += 26;
193
+ if (/[0-9]/.test(password)) pool += 10;
194
+ if (/[^a-zA-Z0-9]/.test(password)) pool += 32;
195
+ return pool === 0 ? 0 : Math.log2(pool) * password.length;
196
+ }
197
+ function hasSequentialRun(pw, runLength = 5) {
198
+ for (let i = 0; i <= pw.length - runLength; i++) {
199
+ let ascending = true;
200
+ let descending = true;
201
+ for (let j = 1; j < runLength; j++) {
202
+ const diff = pw.charCodeAt(i + j) - pw.charCodeAt(i + j - 1);
203
+ if (diff !== 1) ascending = false;
204
+ if (diff !== -1) descending = false;
205
+ if (!ascending && !descending) break;
206
+ }
207
+ if (ascending || descending) return true;
208
+ }
209
+ return false;
210
+ }
211
+ var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
212
+ function hasKeyboardWalk(pw, minLen = 5) {
213
+ const lower = pw.toLowerCase();
214
+ for (const row of KEYBOARD_ROWS) {
215
+ for (let i = 0; i <= row.length - minLen; i++) {
216
+ const fwd = row.slice(i, i + minLen);
217
+ const rev = fwd.split("").reverse().join("");
218
+ if (lower.includes(fwd) || lower.includes(rev)) return true;
219
+ }
220
+ }
221
+ return false;
222
+ }
223
+ function generatePqsPassword() {
224
+ while (true) {
225
+ const bytes = globalThis.crypto.getRandomValues(new Uint8Array(32));
226
+ const b64 = btoa(Array.from(bytes, (b) => String.fromCharCode(b)).join(""));
227
+ const password = b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
228
+ if (new Set(password).size >= 3 && !hasSequentialRun(password) && !hasKeyboardWalk(password)) {
229
+ return password;
230
+ }
231
+ }
232
+ }
233
+ function validatePassword(password, minLength, minEntropyBits, additionalValidators) {
234
+ if (password.length < minLength) {
235
+ throw new DStorageError(
236
+ EncryptionErrorCode.PASSWORD_TOO_SHORT,
237
+ `[dStorage] Password too short: ${password.length} character(s) (minimum ${minLength}). Use a longer passphrase.`
238
+ );
239
+ }
240
+ if (new Set(password).size < 3) {
241
+ throw new DStorageError(
242
+ EncryptionErrorCode.PASSWORD_TOO_FEW_DISTINCT,
243
+ "[dStorage] Password is too weak: too few distinct characters."
244
+ );
245
+ }
246
+ if (hasSequentialRun(password)) {
247
+ throw new DStorageError(
248
+ EncryptionErrorCode.PASSWORD_SEQUENTIAL_RUN,
249
+ "[dStorage] Password is too weak: contains a sequential character run (e.g. abcde, 12345)."
250
+ );
251
+ }
252
+ if (hasKeyboardWalk(password)) {
253
+ throw new DStorageError(
254
+ EncryptionErrorCode.PASSWORD_KEYBOARD_WALK,
255
+ "[dStorage] Password is too weak: contains a keyboard-row pattern (e.g. qwerty, asdfg)."
256
+ );
257
+ }
258
+ const entropy = estimateEntropyBits(password);
259
+ if (entropy < minEntropyBits) {
260
+ throw new DStorageError(
261
+ EncryptionErrorCode.PASSWORD_ENTROPY_TOO_LOW,
262
+ `[dStorage] Password entropy too low: ~${Math.round(entropy)} bits (minimum ${minEntropyBits} bits). Use a longer password with a mix of uppercase, lowercase, digits, and symbols.`
263
+ );
264
+ }
265
+ if (additionalValidators) {
266
+ for (const validate of additionalValidators) {
267
+ validate(password);
268
+ }
269
+ }
270
+ }
271
+
272
+ export {
273
+ KDF_PRESETS,
274
+ PasswordEncryptionAdapter,
275
+ generatePqsPassword
276
+ };
@@ -0,0 +1,3 @@
1
+ var ct=function(r,t){return ct=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])},ct(r,t)};function E(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");ct(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function Zt(r,t,e,o){function n(i){return i instanceof e?i:new e(function(u){u(i)})}return new(e||(e=Promise))(function(i,u){function f(l){try{c(o.next(l))}catch(s){u(s)}}function a(l){try{c(o.throw(l))}catch(s){u(s)}}function c(l){l.done?i(l.value):n(l.value).then(f,a)}c((o=o.apply(r,t||[])).next())})}function br(r,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=f(0),u.throw=f(1),u.return=f(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function f(c){return function(l){return a([c,l])}}function a(c){if(o)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(e=0)),e;)try{if(o=1,n&&(i=c[0]&2?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,n=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){e.label=c[1];break}if(c[0]===6&&e.label<i[1]){e.label=i[1],i=c;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(c);break}i[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(r,e)}catch(l){c=[6,l],n=0}finally{o=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function P(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],o=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&o>=r.length&&(r=void 0),{value:r&&r[o++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function A(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var o=e.call(r),n,i=[],u;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(f){u={error:f}}finally{try{n&&!n.done&&(e=o.return)&&e.call(o)}finally{if(u)throw u.error}}return i}function _(r,t,e){if(e||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return r.concat(i||Array.prototype.slice.call(t))}function fr(r){return this instanceof fr?(this.v=r,this):new fr(r)}function Ht(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=e.apply(r,t||[]),n,i=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),f("next"),f("throw"),f("return",u),n[Symbol.asyncIterator]=function(){return this},n;function u(d){return function(x){return Promise.resolve(x).then(d,s)}}function f(d,x){o[d]&&(n[d]=function(b){return new Promise(function(g,S){i.push([d,b,g,S])>1||a(d,b)})},x&&(n[d]=x(n[d])))}function a(d,x){try{c(o[d](x))}catch(b){h(i[0][3],b)}}function c(d){d.value instanceof fr?Promise.resolve(d.value.v).then(l,s):h(i[0][2],d)}function l(d){a("next",d)}function s(d){a("throw",d)}function h(d,x){d(x),i.shift(),i.length&&a(i[0][0],i[0][1])}}function Xt(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof P=="function"?P(r):r[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(i){e[i]=r[i]&&function(u){return new Promise(function(f,a){u=r[i](u),n(f,a,u.done,u.value)})}}function n(i,u,f,a){Promise.resolve(a).then(function(c){i({value:c,done:f})},u)}}function y(r){return typeof r=="function"}function U(r){var t=function(o){Error.call(o),o.stack=new Error().stack},e=r(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Or=U(function(r){return function(e){r(this),this.message=e?e.length+` errors occurred during unsubscription:
2
+ `+e.map(function(o,n){return n+1+") "+o.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function L(r,t){if(r){var e=r.indexOf(t);0<=e&&r.splice(e,1)}}var j=(function(){function r(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var t,e,o,n,i;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var f=P(u),a=f.next();!a.done;a=f.next()){var c=a.value;c.remove(this)}}catch(b){t={error:b}}finally{try{a&&!a.done&&(e=f.return)&&e.call(f)}finally{if(t)throw t.error}}else u.remove(this);var l=this.initialTeardown;if(y(l))try{l()}catch(b){i=b instanceof Or?b.errors:[b]}var s=this._finalizers;if(s){this._finalizers=null;try{for(var h=P(s),d=h.next();!d.done;d=h.next()){var x=d.value;try{re(x)}catch(b){i=i??[],b instanceof Or?i=_(_([],A(i)),A(b.errors)):i.push(b)}}}catch(b){o={error:b}}finally{try{d&&!d.done&&(n=h.return)&&n.call(h)}finally{if(o)throw o.error}}}if(i)throw new Or(i)}},r.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)re(t);else{if(t instanceof r){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},r.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},r.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},r.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&L(e,t)},r.prototype.remove=function(t){var e=this._finalizers;e&&L(e,t),t instanceof r&&t._removeParent(this)},r.EMPTY=(function(){var t=new r;return t.closed=!0,t})(),r})();var mt=j.EMPTY;function Ur(r){return r instanceof j||r&&"closed"in r&&y(r.remove)&&y(r.add)&&y(r.unsubscribe)}function re(r){y(r)?r():r.unsubscribe()}var G={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var yr={setTimeout:function(r,t){for(var e=[],o=2;o<arguments.length;o++)e[o-2]=arguments[o];var n=yr.delegate;return n?.setTimeout?n.setTimeout.apply(n,_([r,t],A(e))):setTimeout.apply(void 0,_([r,t],A(e)))},clearTimeout:function(r){var t=yr.delegate;return(t?.clearTimeout||clearTimeout)(r)},delegate:void 0};function qr(r){yr.setTimeout(function(){var t=G.onUnhandledError;if(t)t(r);else throw r})}function O(){}var te=(function(){return pt("C",void 0,void 0)})();function ee(r){return pt("E",void 0,r)}function oe(r){return pt("N",r,void 0)}function pt(r,t,e){return{kind:r,value:t,error:e}}var ar=null;function gr(r){if(G.useDeprecatedSynchronousErrorHandling){var t=!ar;if(t&&(ar={errorThrown:!1,error:null}),r(),t){var e=ar,o=e.errorThrown,n=e.error;if(ar=null,o)throw n}}else r()}function ne(r){G.useDeprecatedSynchronousErrorHandling&&ar&&(ar.errorThrown=!0,ar.error=r)}var wr=(function(r){E(t,r);function t(e){var o=r.call(this)||this;return o.isStopped=!1,e?(o.destination=e,Ur(e)&&e.add(o)):o.destination=qe,o}return t.create=function(e,o,n){return new Z(e,o,n)},t.prototype.next=function(e){this.isStopped?st(oe(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?st(ee(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?st(te,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(j);var Ne=Function.prototype.bind;function lt(r,t){return Ne.call(r,t)}var We=(function(){function r(t){this.partialObserver=t}return r.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(o){Dr(o)}},r.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(o){Dr(o)}else Dr(t)},r.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){Dr(e)}},r})(),Z=(function(r){E(t,r);function t(e,o,n){var i=r.call(this)||this,u;if(y(e)||!e)u={next:e??void 0,error:o??void 0,complete:n??void 0};else{var f;i&&G.useDeprecatedNextContext?(f=Object.create(e),f.unsubscribe=function(){return i.unsubscribe()},u={next:e.next&&lt(e.next,f),error:e.error&&lt(e.error,f),complete:e.complete&&lt(e.complete,f)}):u=e}return i.destination=new We(u),i}return t})(wr);function Dr(r){G.useDeprecatedSynchronousErrorHandling?ne(r):qr(r)}function Ue(r){throw r}function st(r,t){var e=G.onStoppedNotification;e&&yr.setTimeout(function(){return e(r,t)})}var qe={closed:!0,next:O,error:Ue,complete:O};var cr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function F(r){return r}function Ir(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return vt(r)}function vt(r){return r.length===0?F:r.length===1?r[0]:function(e){return r.reduce(function(o,n){return n(o)},e)}}var w=(function(){function r(t){t&&(this._subscribe=t)}return r.prototype.lift=function(t){var e=new r;return e.source=this,e.operator=t,e},r.prototype.subscribe=function(t,e,o){var n=this,i=Ye(t)?t:new Z(t,e,o);return gr(function(){var u=n,f=u.operator,a=u.source;i.add(f?f.call(i,a):a?n._subscribe(i):n._trySubscribe(i))}),i},r.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},r.prototype.forEach=function(t,e){var o=this;return e=ie(e),new e(function(n,i){var u=new Z({next:function(f){try{t(f)}catch(a){i(a),u.unsubscribe()}},error:i,complete:n});o.subscribe(u)})},r.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},r.prototype[cr]=function(){return this},r.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return vt(t)(this)},r.prototype.toPromise=function(t){var e=this;return t=ie(t),new t(function(o,n){var i;e.subscribe(function(u){return i=u},function(u){return n(u)},function(){return o(i)})})},r.create=function(t){return new r(t)},r})();function ie(r){var t;return(t=r??G.Promise)!==null&&t!==void 0?t:Promise}function De(r){return r&&y(r.next)&&y(r.error)&&y(r.complete)}function Ye(r){return r&&r instanceof wr||De(r)&&Ur(r)}function dt(r){return y(r?.lift)}function m(r){return function(t){if(dt(t))return t.lift(function(e){try{return r(e,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function p(r,t,e,o,n){return new Fr(r,t,e,o,n)}var Fr=(function(r){E(t,r);function t(e,o,n,i,u,f){var a=r.call(this,e)||this;return a.onFinalize=u,a.shouldUnsubscribe=f,a._next=o?function(c){try{o(c)}catch(l){e.error(l)}}:r.prototype._next,a._error=i?function(c){try{i(c)}catch(l){e.error(l)}finally{this.unsubscribe()}}:r.prototype._error,a._complete=n?function(){try{n()}catch(c){e.error(c)}finally{this.unsubscribe()}}:r.prototype._complete,a}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;r.prototype.unsubscribe.call(this),!o&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t})(wr);function ht(){return m(function(r,t){var e=null;r._refCount++;var o=p(t,void 0,void 0,void 0,function(){if(!r||r._refCount<=0||0<--r._refCount){e=null;return}var n=r._connection,i=e;e=null,n&&(!i||n===i)&&n.unsubscribe(),t.unsubscribe()});r.subscribe(o),o.closed||(e=r.connect())})}var mr=(function(r){E(t,r);function t(e,o){var n=r.call(this)||this;return n.source=e,n.subjectFactory=o,n._subject=null,n._refCount=0,n._connection=null,dt(e)&&(n.lift=e.lift),n}return t.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},t.prototype.getSubject=function(){var e=this._subject;return(!e||e.isStopped)&&(this._subject=this.subjectFactory()),this._subject},t.prototype._teardown=function(){this._refCount=0;var e=this._connection;this._subject=this._connection=null,e?.unsubscribe()},t.prototype.connect=function(){var e=this,o=this._connection;if(!o){o=this._connection=new j;var n=this.getSubject();o.add(this.source.subscribe(p(n,void 0,function(){e._teardown(),n.complete()},function(i){e._teardown(),n.error(i)},function(){return e._teardown()}))),o.closed&&(this._connection=null,o=j.EMPTY)}return o},t.prototype.refCount=function(){return ht()(this)},t})(w);var xt={now:function(){return(xt.delegate||performance).now()},delegate:void 0};var H={schedule:function(r){var t=requestAnimationFrame,e=cancelAnimationFrame,o=H.delegate;o&&(t=o.requestAnimationFrame,e=o.cancelAnimationFrame);var n=t(function(i){e=void 0,r(i)});return new j(function(){return e?.(n)})},requestAnimationFrame:function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=H.delegate;return(e?.requestAnimationFrame||requestAnimationFrame).apply(void 0,_([],A(r)))},cancelAnimationFrame:function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=H.delegate;return(e?.cancelAnimationFrame||cancelAnimationFrame).apply(void 0,_([],A(r)))},delegate:void 0};function ze(r){return r?ue(r):Ge}function ue(r){return new w(function(t){var e=r||xt,o=e.now(),n=0,i=function(){t.closed||(n=H.requestAnimationFrame(function(u){n=0;var f=e.now();t.next({timestamp:r?f:u,elapsed:f-o}),i()}))};return i(),function(){n&&H.cancelAnimationFrame(n)}})}var Ge=ue();var bt=U(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var I=(function(r){E(t,r);function t(){var e=r.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var o=new fe(this,this);return o.operator=e,o},t.prototype._throwIfClosed=function(){if(this.closed)throw new bt},t.prototype.next=function(e){var o=this;gr(function(){var n,i;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var u=P(o.currentObservers),f=u.next();!f.done;f=u.next()){var a=f.value;a.next(e)}}catch(c){n={error:c}}finally{try{f&&!f.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var o=this;gr(function(){if(o._throwIfClosed(),!o.isStopped){o.hasError=o.isStopped=!0,o.thrownError=e;for(var n=o.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;gr(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var o=e.observers;o.length;)o.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var o=this,n=this,i=n.hasError,u=n.isStopped,f=n.observers;return i||u?mt:(this.currentObservers=null,f.push(e),new j(function(){o.currentObservers=null,L(f,e)}))},t.prototype._checkFinalizedStatuses=function(e){var o=this,n=o.hasError,i=o.thrownError,u=o.isStopped;n?e.error(i):u&&e.complete()},t.prototype.asObservable=function(){var e=new w;return e.source=this,e},t.create=function(e,o){return new fe(e,o)},t})(w);var fe=(function(r){E(t,r);function t(e,o){var n=r.call(this)||this;return n.destination=e,n.source=o,n}return t.prototype.next=function(e){var o,n;(n=(o=this.destination)===null||o===void 0?void 0:o.next)===null||n===void 0||n.call(o,e)},t.prototype.error=function(e){var o,n;(n=(o=this.destination)===null||o===void 0?void 0:o.error)===null||n===void 0||n.call(o,e)},t.prototype.complete=function(){var e,o;(o=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||o===void 0||o.call(e)},t.prototype._subscribe=function(e){var o,n;return(n=(o=this.source)===null||o===void 0?void 0:o.subscribe(e))!==null&&n!==void 0?n:mt},t})(I);var yt=(function(r){E(t,r);function t(e){var o=r.call(this)||this;return o._value=e,o}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var o=r.prototype._subscribe.call(this,e);return!o.closed&&e.next(this._value),o},t.prototype.getValue=function(){var e=this,o=e.hasError,n=e.thrownError,i=e._value;if(o)throw n;return this._throwIfClosed(),i},t.prototype.next=function(e){r.prototype.next.call(this,this._value=e)},t})(I);var pr={now:function(){return(pr.delegate||Date).now()},delegate:void 0};var Tr=(function(r){E(t,r);function t(e,o,n){e===void 0&&(e=1/0),o===void 0&&(o=1/0),n===void 0&&(n=pr);var i=r.call(this)||this;return i._bufferSize=e,i._windowTime=o,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=o===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,o),i}return t.prototype.next=function(e){var o=this,n=o.isStopped,i=o._buffer,u=o._infiniteTimeWindow,f=o._timestampProvider,a=o._windowTime;n||(i.push(e),!u&&i.push(f.now()+a)),this._trimBuffer(),r.prototype.next.call(this,e)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var o=this._innerSubscribe(e),n=this,i=n._infiniteTimeWindow,u=n._buffer,f=u.slice(),a=0;a<f.length&&!e.closed;a+=i?1:2)e.next(f[a]);return this._checkFinalizedStatuses(e),o},t.prototype._trimBuffer=function(){var e=this,o=e._bufferSize,n=e._timestampProvider,i=e._buffer,u=e._infiniteTimeWindow,f=(u?1:2)*o;if(o<1/0&&f<i.length&&i.splice(0,i.length-f),!u){for(var a=n.now(),c=0,l=1;l<i.length&&i[l]<=a;l+=2)c=l;c&&i.splice(0,c+1)}},t})(I);var jr=(function(r){E(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._value=null,e._hasValue=!1,e._isComplete=!1,e}return t.prototype._checkFinalizedStatuses=function(e){var o=this,n=o.hasError,i=o._hasValue,u=o._value,f=o.thrownError,a=o.isStopped,c=o._isComplete;n?e.error(f):(a||c)&&(i&&e.next(u),e.complete())},t.prototype.next=function(e){this.isStopped||(this._value=e,this._hasValue=!0)},t.prototype.complete=function(){var e=this,o=e._hasValue,n=e._value,i=e._isComplete;i||(this._isComplete=!0,o&&r.prototype.next.call(this,n),r.prototype.complete.call(this))},t})(I);var ae=(function(r){E(t,r);function t(e,o){return r.call(this)||this}return t.prototype.schedule=function(e,o){return o===void 0&&(o=0),this},t})(j);var Pr={setInterval:function(r,t){for(var e=[],o=2;o<arguments.length;o++)e[o-2]=arguments[o];var n=Pr.delegate;return n?.setInterval?n.setInterval.apply(n,_([r,t],A(e))):setInterval.apply(void 0,_([r,t],A(e)))},clearInterval:function(r){var t=Pr.delegate;return(t?.clearInterval||clearInterval)(r)},delegate:void 0};var Q=(function(r){E(t,r);function t(e,o){var n=r.call(this,e,o)||this;return n.scheduler=e,n.work=o,n.pending=!1,n}return t.prototype.schedule=function(e,o){var n;if(o===void 0&&(o=0),this.closed)return this;this.state=e;var i=this.id,u=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(u,i,o)),this.pending=!0,this.delay=o,this.id=(n=this.id)!==null&&n!==void 0?n:this.requestAsyncId(u,this.id,o),this},t.prototype.requestAsyncId=function(e,o,n){return n===void 0&&(n=0),Pr.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,o,n){if(n===void 0&&(n=0),n!=null&&this.delay===n&&this.pending===!1)return o;o!=null&&Pr.clearInterval(o)},t.prototype.execute=function(e,o){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,o);if(n)return n;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,o){var n=!1,i;try{this.work(e)}catch(u){n=!0,i=u||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,o=e.id,n=e.scheduler,i=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,L(i,this),o!=null&&(this.id=this.recycleAsyncId(n,o,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},t})(ae);var Ke=1,gt,wt={};function ce(r){return r in wt?(delete wt[r],!0):!1}var St={setImmediate:function(r){var t=Ke++;return wt[t]=!0,gt||(gt=Promise.resolve()),gt.then(function(){return ce(t)&&r()}),t},clearImmediate:function(r){ce(r)}};var Qe=St.setImmediate,Be=St.clearImmediate,Cr={setImmediate:function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=Cr.delegate;return(e?.setImmediate||Qe).apply(void 0,_([],A(r)))},clearImmediate:function(r){var t=Cr.delegate;return(t?.clearImmediate||Be)(r)},delegate:void 0};var me=(function(r){E(t,r);function t(e,o){var n=r.call(this,e,o)||this;return n.scheduler=e,n.work=o,n}return t.prototype.requestAsyncId=function(e,o,n){return n===void 0&&(n=0),n!==null&&n>0?r.prototype.requestAsyncId.call(this,e,o,n):(e.actions.push(this),e._scheduled||(e._scheduled=Cr.setImmediate(e.flush.bind(e,void 0))))},t.prototype.recycleAsyncId=function(e,o,n){var i;if(n===void 0&&(n=0),n!=null?n>0:this.delay>0)return r.prototype.recycleAsyncId.call(this,e,o,n);var u=e.actions;o!=null&&((i=u[u.length-1])===null||i===void 0?void 0:i.id)!==o&&(Cr.clearImmediate(o),e._scheduled===o&&(e._scheduled=void 0))},t})(Q);var Yr=(function(){function r(t,e){e===void 0&&(e=r.now),this.schedulerActionCtor=t,this.now=e}return r.prototype.schedule=function(t,e,o){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(o,e)},r.now=pr.now,r})();var B=(function(r){E(t,r);function t(e,o){o===void 0&&(o=Yr.now);var n=r.call(this,e,o)||this;return n.actions=[],n._active=!1,n}return t.prototype.flush=function(e){var o=this.actions;if(this._active){o.push(e);return}var n;this._active=!0;do if(n=e.execute(e.state,e.delay))break;while(e=o.shift());if(this._active=!1,n){for(;e=o.shift();)e.unsubscribe();throw n}},t})(Yr);var pe=(function(r){E(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.flush=function(e){this._active=!0;var o=this._scheduled;this._scheduled=void 0;var n=this.actions,i;e=e||n.shift();do if(i=e.execute(e.state,e.delay))break;while((e=n[0])&&e.id===o&&n.shift());if(this._active=!1,i){for(;(e=n[0])&&e.id===o&&n.shift();)e.unsubscribe();throw i}},t})(B);var le=new pe(me),$e=le;var C=new B(Q),Rr=C;var se=(function(r){E(t,r);function t(e,o){var n=r.call(this,e,o)||this;return n.scheduler=e,n.work=o,n}return t.prototype.schedule=function(e,o){return o===void 0&&(o=0),o>0?r.prototype.schedule.call(this,e,o):(this.delay=o,this.state=e,this.scheduler.flush(this),this)},t.prototype.execute=function(e,o){return o>0||this.closed?r.prototype.execute.call(this,e,o):this._execute(e,o)},t.prototype.requestAsyncId=function(e,o,n){return n===void 0&&(n=0),n!=null&&n>0||n==null&&this.delay>0?r.prototype.requestAsyncId.call(this,e,o,n):(e.flush(this),0)},t})(Q);var ve=(function(r){E(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t})(B);var de=new ve(se),Je=de;var he=(function(r){E(t,r);function t(e,o){var n=r.call(this,e,o)||this;return n.scheduler=e,n.work=o,n}return t.prototype.requestAsyncId=function(e,o,n){return n===void 0&&(n=0),n!==null&&n>0?r.prototype.requestAsyncId.call(this,e,o,n):(e.actions.push(this),e._scheduled||(e._scheduled=H.requestAnimationFrame(function(){return e.flush(void 0)})))},t.prototype.recycleAsyncId=function(e,o,n){var i;if(n===void 0&&(n=0),n!=null?n>0:this.delay>0)return r.prototype.recycleAsyncId.call(this,e,o,n);var u=e.actions;o!=null&&o===e._scheduled&&((i=u[u.length-1])===null||i===void 0?void 0:i.id)!==o&&(H.cancelAnimationFrame(o),e._scheduled=void 0)},t})(Q);var xe=(function(r){E(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.flush=function(e){this._active=!0;var o;e?o=e.id:(o=this._scheduled,this._scheduled=void 0);var n=this.actions,i;e=e||n.shift();do if(i=e.execute(e.state,e.delay))break;while((e=n[0])&&e.id===o&&n.shift());if(this._active=!1,i){for(;(e=n[0])&&e.id===o&&n.shift();)e.unsubscribe();throw i}},t})(B);var be=new xe(he),Ze=be;var He=(function(r){E(t,r);function t(e,o){e===void 0&&(e=ye),o===void 0&&(o=1/0);var n=r.call(this,e,function(){return n.frame})||this;return n.maxFrames=o,n.frame=0,n.index=-1,n}return t.prototype.flush=function(){for(var e=this,o=e.actions,n=e.maxFrames,i,u;(u=o[0])&&u.delay<=n&&(o.shift(),this.frame=u.delay,!(i=u.execute(u.state,u.delay))););if(i){for(;u=o.shift();)u.unsubscribe();throw i}},t.frameTimeFactor=10,t})(B);var ye=(function(r){E(t,r);function t(e,o,n){n===void 0&&(n=e.index+=1);var i=r.call(this,e,o)||this;return i.scheduler=e,i.work=o,i.index=n,i.active=!0,i.index=e.index=n,i}return t.prototype.schedule=function(e,o){if(o===void 0&&(o=0),Number.isFinite(o)){if(!this.id)return r.prototype.schedule.call(this,e,o);this.active=!1;var n=new t(this.scheduler,this.work);return this.add(n),n.schedule(e,o)}else return j.EMPTY},t.prototype.requestAsyncId=function(e,o,n){n===void 0&&(n=0),this.delay=e.frame+n;var i=e.actions;return i.push(this),i.sort(t.sortActions),1},t.prototype.recycleAsyncId=function(e,o,n){n===void 0&&(n=0)},t.prototype._execute=function(e,o){if(this.active===!0)return r.prototype._execute.call(this,e,o)},t.sortActions=function(e,o){return e.delay===o.delay?e.index===o.index?0:e.index>o.index?1:-1:e.delay>o.delay?1:-1},t})(Q);var M=new w(function(r){return r.complete()});function Xe(r){return r?ro(r):M}function ro(r){return new w(function(t){return r.schedule(function(){return t.complete()})})}function tr(r){return r&&y(r.schedule)}function At(r){return r[r.length-1]}function $(r){return y(At(r))?r.pop():void 0}function k(r){return tr(At(r))?r.pop():void 0}function zr(r,t){return typeof At(r)=="number"?r.pop():t}var Sr=(function(r){return r&&typeof r.length=="number"&&typeof r!="function"});function Gr(r){return y(r?.then)}function Kr(r){return y(r[cr])}function Qr(r){return Symbol.asyncIterator&&y(r?.[Symbol.asyncIterator])}function Br(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function to(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var $r=to();function Jr(r){return y(r?.[$r])}function Zr(r){return Ht(this,arguments,function(){var e,o,n,i;return br(this,function(u){switch(u.label){case 0:e=r.getReader(),u.label=1;case 1:u.trys.push([1,,9,10]),u.label=2;case 2:return[4,fr(e.read())];case 3:return o=u.sent(),n=o.value,i=o.done,i?[4,fr(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,fr(n)];case 6:return[4,u.sent()];case 7:return u.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Hr(r){return y(r?.getReader)}function v(r){if(r instanceof w)return r;if(r!=null){if(Kr(r))return eo(r);if(Sr(r))return oo(r);if(Gr(r))return no(r);if(Qr(r))return ge(r);if(Jr(r))return io(r);if(Hr(r))return uo(r)}throw Br(r)}function eo(r){return new w(function(t){var e=r[cr]();if(y(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function oo(r){return new w(function(t){for(var e=0;e<r.length&&!t.closed;e++)t.next(r[e]);t.complete()})}function no(r){return new w(function(t){r.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,qr)})}function io(r){return new w(function(t){var e,o;try{for(var n=P(r),i=n.next();!i.done;i=n.next()){var u=i.value;if(t.next(u),t.closed)return}}catch(f){e={error:f}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(e)throw e.error}}t.complete()})}function ge(r){return new w(function(t){fo(r,t).catch(function(e){return t.error(e)})})}function uo(r){return ge(Zr(r))}function fo(r,t){var e,o,n,i;return Zt(this,void 0,void 0,function(){var u,f;return br(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),e=Xt(r),a.label=1;case 1:return[4,e.next()];case 2:if(o=a.sent(),!!o.done)return[3,4];if(u=o.value,t.next(u),t.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return f=a.sent(),n={error:f},[3,11];case 6:return a.trys.push([6,,9,10]),o&&!o.done&&(i=e.return)?[4,i.call(e)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(n)throw n.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function R(r,t,e,o,n){o===void 0&&(o=0),n===void 0&&(n=!1);var i=t.schedule(function(){e(),n?r.add(this.schedule(null,o)):this.unsubscribe()},o);if(r.add(i),!n)return i}function lr(r,t){return t===void 0&&(t=0),m(function(e,o){e.subscribe(p(o,function(n){return R(o,r,function(){return o.next(n)},t)},function(){return R(o,r,function(){return o.complete()},t)},function(n){return R(o,r,function(){return o.error(n)},t)}))})}function sr(r,t){return t===void 0&&(t=0),m(function(e,o){o.add(r.schedule(function(){return e.subscribe(o)},t))})}function we(r,t){return v(r).pipe(sr(t),lr(t))}function Se(r,t){return v(r).pipe(sr(t),lr(t))}function Ae(r,t){return new w(function(e){var o=0;return t.schedule(function(){o===r.length?e.complete():(e.next(r[o++]),e.closed||this.schedule())})})}function Xr(r,t){return new w(function(e){var o;return R(e,t,function(){o=r[$r](),R(e,t,function(){var n,i,u;try{n=o.next(),i=n.value,u=n.done}catch(f){e.error(f);return}u?e.complete():e.next(i)},0,!0)}),function(){return y(o?.return)&&o.return()}})}function rt(r,t){if(!r)throw new Error("Iterable cannot be null");return new w(function(e){R(e,t,function(){var o=r[Symbol.asyncIterator]();R(e,t,function(){o.next().then(function(n){n.done?e.complete():e.next(n.value)})},0,!0)})})}function _e(r,t){return rt(Zr(r),t)}function _t(r,t){if(r!=null){if(Kr(r))return we(r,t);if(Sr(r))return Ae(r,t);if(Gr(r))return Se(r,t);if(Qr(r))return rt(r,t);if(Jr(r))return Xr(r,t);if(Hr(r))return _e(r,t)}throw Br(r)}function N(r,t){return t?_t(r,t):v(r)}function Mr(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r);return N(r,e)}function Et(r,t){var e=y(r)?r:function(){return r},o=function(n){return n.error(e())};return new w(t?function(n){return t.schedule(o,0,n)}:o)}var Ot;(function(r){r.NEXT="N",r.ERROR="E",r.COMPLETE="C"})(Ot||(Ot={}));var kr=(function(){function r(t,e,o){this.kind=t,this.value=e,this.error=o,this.hasValue=t==="N"}return r.prototype.observe=function(t){return It(this,t)},r.prototype.do=function(t,e,o){var n=this,i=n.kind,u=n.value,f=n.error;return i==="N"?t?.(u):i==="E"?e?.(f):o?.()},r.prototype.accept=function(t,e,o){var n;return y((n=t)===null||n===void 0?void 0:n.next)?this.observe(t):this.do(t,e,o)},r.prototype.toObservable=function(){var t=this,e=t.kind,o=t.value,n=t.error,i=e==="N"?Mr(o):e==="E"?Et(function(){return n}):e==="C"?M:0;if(!i)throw new TypeError("Unexpected notification kind "+e);return i},r.createNext=function(t){return new r("N",t)},r.createError=function(t){return new r("E",void 0,t)},r.createComplete=function(){return r.completeNotification},r.completeNotification=new r("C"),r})();function It(r,t){var e,o,n,i=r,u=i.kind,f=i.value,a=i.error;if(typeof u!="string")throw new TypeError('Invalid notification, missing "kind"');u==="N"?(e=t.next)===null||e===void 0||e.call(t,f):u==="E"?(o=t.error)===null||o===void 0||o.call(t,a):(n=t.complete)===null||n===void 0||n.call(t)}function ao(r){return!!r&&(r instanceof w||y(r.lift)&&y(r.subscribe))}var D=U(function(r){return function(){r(this),this.name="EmptyError",this.message="no elements in sequence"}});function co(r,t){var e=typeof t=="object";return new Promise(function(o,n){var i=!1,u;r.subscribe({next:function(f){u=f,i=!0},error:n,complete:function(){i?o(u):e?o(t.defaultValue):n(new D)}})})}function mo(r,t){var e=typeof t=="object";return new Promise(function(o,n){var i=new Z({next:function(u){o(u),i.unsubscribe()},error:n,complete:function(){e?o(t.defaultValue):n(new D)}});r.subscribe(i)})}var tt=U(function(r){return function(){r(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}});var Ft=U(function(r){return function(e){r(this),this.name="NotFoundError",this.message=e}});var Tt=U(function(r){return function(e){r(this),this.name="SequenceError",this.message=e}});function Ar(r){return r instanceof Date&&!isNaN(r)}var Ee=U(function(r){return function(e){e===void 0&&(e=null),r(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}});function jt(r,t){var e=Ar(r)?{first:r}:typeof r=="number"?{each:r}:r,o=e.first,n=e.each,i=e.with,u=i===void 0?po:i,f=e.scheduler,a=f===void 0?t??C:f,c=e.meta,l=c===void 0?null:c;if(o==null&&n==null)throw new TypeError("No timeout provided.");return m(function(s,h){var d,x,b=null,g=0,S=function(T){x=R(h,a,function(){try{d.unsubscribe(),v(u({meta:l,lastValue:b,seen:g})).subscribe(h)}catch(W){h.error(W)}},T)};d=s.subscribe(p(h,function(T){x?.unsubscribe(),g++,h.next(b=T),n>0&&S(n)},void 0,void 0,function(){x?.closed||x?.unsubscribe(),b=null})),!g&&S(o!=null?typeof o=="number"?o:+o-a.now():n)})}function po(r){throw new Ee(r)}function Y(r,t){return m(function(e,o){var n=0;e.subscribe(p(o,function(i){o.next(r.call(t,i,n++))}))})}var lo=Array.isArray;function so(r,t){return lo(t)?r.apply(void 0,_([],A(t))):r(t)}function q(r){return Y(function(t){return so(r,t)})}function _r(r,t,e,o){if(e)if(tr(e))o=e;else return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return _r(r,t,o).apply(this,n).pipe(q(e))};return o?function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return _r(r,t).apply(this,n).pipe(sr(o),lr(o))}:function(){for(var n=this,i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];var f=new jr,a=!0;return new w(function(c){var l=f.subscribe(c);if(a){a=!1;var s=!1,h=!1;t.apply(n,_(_([],A(i)),[function(){for(var d=[],x=0;x<arguments.length;x++)d[x]=arguments[x];if(r){var b=d.shift();if(b!=null){f.error(b);return}}f.next(1<d.length?d:d[0]),h=!0,s&&f.complete()}])),h&&f.complete(),s=!0}return l})}}function vo(r,t,e){return _r(!1,r,t,e)}function ho(r,t,e){return _r(!0,r,t,e)}var xo=Array.isArray,bo=Object.getPrototypeOf,yo=Object.prototype,go=Object.keys;function et(r){if(r.length===1){var t=r[0];if(xo(t))return{args:t,keys:null};if(wo(t)){var e=go(t);return{args:e.map(function(o){return t[o]}),keys:e}}}return{args:r,keys:null}}function wo(r){return r&&typeof r=="object"&&bo(r)===yo}function ot(r,t){return r.reduce(function(e,o,n){return e[o]=t[n],e},{})}function Pt(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r),o=$(r),n=et(r),i=n.args,u=n.keys;if(i.length===0)return N([],e);var f=new w(Ct(i,e,u?function(a){return ot(u,a)}:F));return o?f.pipe(q(o)):f}function Ct(r,t,e){return e===void 0&&(e=F),function(o){Oe(t,function(){for(var n=r.length,i=new Array(n),u=n,f=n,a=function(l){Oe(t,function(){var s=N(r[l],t),h=!1;s.subscribe(p(o,function(d){i[l]=d,h||(h=!0,f--),f||o.next(e(i.slice()))},function(){--u||o.complete()}))},o)},c=0;c<n;c++)a(c)},o)}}function Oe(r,t,e){r?R(e,r,t):t()}function Er(r,t,e,o,n,i,u,f){var a=[],c=0,l=0,s=!1,h=function(){s&&!a.length&&!c&&t.complete()},d=function(b){return c<o?x(b):a.push(b)},x=function(b){i&&t.next(b),c++;var g=!1;v(e(b,l++)).subscribe(p(t,function(S){n?.(S),i?d(S):t.next(S)},function(){g=!0},void 0,function(){if(g)try{c--;for(var S=function(){var T=a.shift();u?R(t,u,function(){return x(T)}):x(T)};a.length&&c<o;)S();h()}catch(T){t.error(T)}}))};return r.subscribe(p(t,d,function(){s=!0,h()})),function(){f?.()}}function V(r,t,e){return e===void 0&&(e=1/0),y(t)?V(function(o,n){return Y(function(i,u){return t(o,i,n,u)})(v(r(o,n)))},e):(typeof t=="number"&&(e=t),m(function(o,n){return Er(o,n,r,e)}))}function vr(r){return r===void 0&&(r=1/0),V(F,r)}function Vr(){return vr(1)}function er(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Vr()(N(r,k(r)))}function dr(r){return new w(function(t){v(r()).subscribe(t)})}var So={connector:function(){return new I},resetOnDisconnect:!0};function Ao(r,t){t===void 0&&(t=So);var e=null,o=t.connector,n=t.resetOnDisconnect,i=n===void 0?!0:n,u=o(),f=new w(function(a){return u.subscribe(a)});return f.connect=function(){return(!e||e.closed)&&(e=dr(function(){return r}).subscribe(u),i&&e.add(function(){return u=o()})),e},f}function _o(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=$(r),o=et(r),n=o.args,i=o.keys,u=new w(function(f){var a=n.length;if(!a){f.complete();return}for(var c=new Array(a),l=a,s=a,h=function(x){var b=!1;v(n[x]).subscribe(p(f,function(g){b||(b=!0,s--),c[x]=g},function(){return l--},void 0,function(){(!l||!b)&&(s||f.next(i?ot(i,c):c),f.complete())}))},d=0;d<a;d++)h(d)});return e?u.pipe(q(e)):u}var Eo=["addListener","removeListener"],Oo=["addEventListener","removeEventListener"],Io=["on","off"];function Rt(r,t,e,o){if(y(e)&&(o=e,e=void 0),o)return Rt(r,t,e).pipe(q(o));var n=A(jo(r)?Oo.map(function(f){return function(a){return r[f](t,a,e)}}):Fo(r)?Eo.map(Ie(r,t)):To(r)?Io.map(Ie(r,t)):[],2),i=n[0],u=n[1];if(!i&&Sr(r))return V(function(f){return Rt(f,t,e)})(v(r));if(!i)throw new TypeError("Invalid event target");return new w(function(f){var a=function(){for(var c=[],l=0;l<arguments.length;l++)c[l]=arguments[l];return f.next(1<c.length?c:c[0])};return i(a),function(){return u(a)}})}function Ie(r,t){return function(e){return function(o){return r[e](t,o)}}}function Fo(r){return y(r.addListener)&&y(r.removeListener)}function To(r){return y(r.on)&&y(r.off)}function jo(r){return y(r.addEventListener)&&y(r.removeEventListener)}function Fe(r,t,e){return e?Fe(r,t).pipe(q(e)):new w(function(o){var n=function(){for(var u=[],f=0;f<arguments.length;f++)u[f]=arguments[f];return o.next(u.length===1?u[0]:u)},i=r(n);return y(t)?function(){return t(n,i)}:void 0})}function Po(r,t,e,o,n){var i,u,f,a;arguments.length===1?(i=r,a=i.initialState,t=i.condition,e=i.iterate,u=i.resultSelector,f=u===void 0?F:u,n=i.scheduler):(a=r,!o||tr(o)?(f=F,n=o):f=o);function c(){var l;return br(this,function(s){switch(s.label){case 0:l=a,s.label=1;case 1:return!t||t(l)?[4,f(l)]:[3,4];case 2:s.sent(),s.label=3;case 3:return l=e(l),[3,1];case 4:return[2]}})}return dr(n?function(){return Xr(c(),n)}:c)}function Co(r,t,e){return dr(function(){return r()?t:e})}function z(r,t,e){r===void 0&&(r=0),e===void 0&&(e=Rr);var o=-1;return t!=null&&(tr(t)?e=t:o=t),new w(function(n){var i=Ar(r)?+r-e.now():r;i<0&&(i=0);var u=0;return e.schedule(function(){n.closed||(n.next(u++),0<=o?this.schedule(void 0,o):n.complete())},i)})}function Mt(r,t){return r===void 0&&(r=0),t===void 0&&(t=C),r<0&&(r=0),z(r,r,t)}function Ro(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r),o=zr(r,1/0),n=r;return n.length?n.length===1?v(n[0]):vr(o)(N(n,e)):M}var Te=new w(O);function Mo(){return Te}var ko=Array.isArray;function J(r){return r.length===1&&ko(r[0])?r[0]:r}function kt(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=J(r);return new w(function(o){var n=0,i=function(){if(n<e.length){var u=void 0;try{u=v(e[n++])}catch{i();return}var f=new Fr(o,void 0,O,O);u.subscribe(f),f.add(i)}else o.complete()};i()})}function Vo(r,t){return N(Object.entries(r),t)}function je(r,t){return function(e,o){return!r.call(t,e,o)}}function K(r,t){return m(function(e,o){var n=0;e.subscribe(p(o,function(i){return r.call(t,i,n++)&&o.next(i)}))})}function Lo(r,t,e){return[K(t,e)(v(r)),K(je(t,e))(v(r))]}function No(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return r=J(r),r.length===1?v(r[0]):new w(Vt(r))}function Vt(r){return function(t){for(var e=[],o=function(i){e.push(v(r[i]).subscribe(p(t,function(u){if(e){for(var f=0;f<e.length;f++)f!==i&&e[f].unsubscribe();e=null}t.next(u)})))},n=0;e&&!t.closed&&n<r.length;n++)o(n)}}function Wo(r,t,e){if(t==null&&(t=r,r=0),t<=0)return M;var o=t+r;return new w(e?function(n){var i=r;return e.schedule(function(){i<o?(n.next(i++),this.schedule()):n.complete()})}:function(n){for(var i=r;i<o&&!n.closed;)n.next(i++);n.complete()})}function Uo(r,t){return new w(function(e){var o=r(),n=t(o),i=n?v(n):M;return i.subscribe(e),function(){o&&o.unsubscribe()}})}function Lr(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=$(r),o=J(r);return o.length?new w(function(n){var i=o.map(function(){return[]}),u=o.map(function(){return!1});n.add(function(){i=u=null});for(var f=function(c){v(o[c]).subscribe(p(n,function(l){if(i[c].push(l),i.every(function(h){return h.length})){var s=i.map(function(h){return h.shift()});n.next(e?e.apply(void 0,_([],A(s))):s),i.some(function(h,d){return!h.length&&u[d]})&&n.complete()}},function(){u[c]=!0,!i[c].length&&n.complete()}))},a=0;!n.closed&&a<o.length;a++)f(a);return function(){i=u=null}}):M}function Lt(r){return m(function(t,e){var o=!1,n=null,i=null,u=!1,f=function(){if(i?.unsubscribe(),i=null,o){o=!1;var c=n;n=null,e.next(c)}u&&e.complete()},a=function(){i=null,u&&e.complete()};t.subscribe(p(e,function(c){o=!0,n=c,i||v(r(c)).subscribe(i=p(e,f,a))},function(){u=!0,(!o||!i||i.closed)&&e.complete()}))})}function qo(r,t){return t===void 0&&(t=C),Lt(function(){return z(r,t)})}function Do(r){return m(function(t,e){var o=[];return t.subscribe(p(e,function(n){return o.push(n)},function(){e.next(o),e.complete()})),v(r).subscribe(p(e,function(){var n=o;o=[],e.next(n)},O)),function(){o=null}})}function Yo(r,t){return t===void 0&&(t=null),t=t??r,m(function(e,o){var n=[],i=0;e.subscribe(p(o,function(u){var f,a,c,l,s=null;i++%t===0&&n.push([]);try{for(var h=P(n),d=h.next();!d.done;d=h.next()){var x=d.value;x.push(u),r<=x.length&&(s=s??[],s.push(x))}}catch(S){f={error:S}}finally{try{d&&!d.done&&(a=h.return)&&a.call(h)}finally{if(f)throw f.error}}if(s)try{for(var b=P(s),g=b.next();!g.done;g=b.next()){var x=g.value;L(n,x),o.next(x)}}catch(S){c={error:S}}finally{try{g&&!g.done&&(l=b.return)&&l.call(b)}finally{if(c)throw c.error}}},function(){var u,f;try{for(var a=P(n),c=a.next();!c.done;c=a.next()){var l=c.value;o.next(l)}}catch(s){u={error:s}}finally{try{c&&!c.done&&(f=a.return)&&f.call(a)}finally{if(u)throw u.error}}o.complete()},void 0,function(){n=null}))})}function zo(r){for(var t,e,o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];var i=(t=k(o))!==null&&t!==void 0?t:C,u=(e=o[0])!==null&&e!==void 0?e:null,f=o[1]||1/0;return m(function(a,c){var l=[],s=!1,h=function(b){var g=b.buffer,S=b.subs;S.unsubscribe(),L(l,b),c.next(g),s&&d()},d=function(){if(l){var b=new j;c.add(b);var g=[],S={buffer:g,subs:b};l.push(S),R(b,i,function(){return h(S)},r)}};u!==null&&u>=0?R(c,i,d,u,!0):s=!0,d();var x=p(c,function(b){var g,S,T=l.slice();try{for(var W=P(T),rr=W.next();!rr.done;rr=W.next()){var ir=rr.value,ur=ir.buffer;ur.push(b),f<=ur.length&&h(ir)}}catch(Le){g={error:Le}}finally{try{rr&&!rr.done&&(S=W.return)&&S.call(W)}finally{if(g)throw g.error}}},function(){for(;l?.length;)c.next(l.shift().buffer);x?.unsubscribe(),c.complete(),c.unsubscribe()},void 0,function(){return l=null});a.subscribe(x)})}function Go(r,t){return m(function(e,o){var n=[];v(r).subscribe(p(o,function(i){var u=[];n.push(u);var f=new j,a=function(){L(n,u),o.next(u),f.unsubscribe()};f.add(v(t(i)).subscribe(p(o,a,O)))},O)),e.subscribe(p(o,function(i){var u,f;try{for(var a=P(n),c=a.next();!c.done;c=a.next()){var l=c.value;l.push(i)}}catch(s){u={error:s}}finally{try{c&&!c.done&&(f=a.return)&&f.call(a)}finally{if(u)throw u.error}}},function(){for(;n.length>0;)o.next(n.shift());o.complete()}))})}function Ko(r){return m(function(t,e){var o=null,n=null,i=function(){n?.unsubscribe();var u=o;o=[],u&&e.next(u),v(r()).subscribe(n=p(e,i,O))};i(),t.subscribe(p(e,function(u){return o?.push(u)},function(){o&&e.next(o),e.complete()},void 0,function(){return o=n=null}))})}function Pe(r){return m(function(t,e){var o=null,n=!1,i;o=t.subscribe(p(e,void 0,void 0,function(u){i=v(r(u,Pe(r)(t))),o?(o.unsubscribe(),o=null,i.subscribe(e)):n=!0})),n&&(o.unsubscribe(),o=null,i.subscribe(e))})}function nt(r,t,e,o,n){return function(i,u){var f=e,a=t,c=0;i.subscribe(p(u,function(l){var s=c++;a=f?r(a,l,s):(f=!0,l),o&&u.next(a)},n&&(function(){f&&u.next(a),u.complete()})))}}function X(r,t){return m(nt(r,t,arguments.length>=2,!1,!0))}var Qo=function(r,t){return r.push(t),r};function Nt(){return m(function(r,t){X(Qo,[])(r).subscribe(t)})}function it(r,t){return Ir(Nt(),V(function(e){return r(e)}),t?q(t):F)}function Wt(r){return it(Pt,r)}var Bo=Wt;function Ut(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=$(r);return e?Ir(Ut.apply(void 0,_([],A(r))),q(e)):m(function(o,n){Ct(_([o],A(J(r))))(n)})}function $o(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Ut.apply(void 0,_([],A(r)))}function ut(r,t){return y(t)?V(r,t,1):V(r,1)}function Jo(r,t){return y(t)?ut(function(){return r},t):ut(function(){return r})}function Ce(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r);return m(function(o,n){Vr()(N(_([o],A(r)),e)).subscribe(n)})}function Zo(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Ce.apply(void 0,_([],A(r)))}function Re(r){return new w(function(t){return r.subscribe(t)})}var Ho={connector:function(){return new I}};function Nr(r,t){t===void 0&&(t=Ho);var e=t.connector;return m(function(o,n){var i=e();v(r(Re(i))).subscribe(n),n.add(o.subscribe(i))})}function Xo(r){return X(function(t,e,o){return!r||r(e,o)?t+1:t},0)}function rn(r){return m(function(t,e){var o=!1,n=null,i=null,u=function(){if(i?.unsubscribe(),i=null,o){o=!1;var f=n;n=null,e.next(f)}};t.subscribe(p(e,function(f){i?.unsubscribe(),o=!0,n=f,i=p(e,u,O),v(r(f)).subscribe(i)},function(){u(),e.complete()},void 0,function(){n=i=null}))})}function tn(r,t){return t===void 0&&(t=C),m(function(e,o){var n=null,i=null,u=null,f=function(){if(n){n.unsubscribe(),n=null;var c=i;i=null,o.next(c)}};function a(){var c=u+r,l=t.now();if(l<c){n=this.schedule(void 0,c-l),o.add(n);return}f()}e.subscribe(p(o,function(c){i=c,u=t.now(),n||(n=t.schedule(a,r),o.add(n))},function(){f(),o.complete()},void 0,function(){i=n=null}))})}function hr(r){return m(function(t,e){var o=!1;t.subscribe(p(e,function(n){o=!0,e.next(n)},function(){o||e.next(r),e.complete()}))})}function or(r){return r<=0?function(){return M}:m(function(t,e){var o=0;t.subscribe(p(e,function(n){++o<=r&&(e.next(n),r<=o&&e.complete())}))})}function qt(){return m(function(r,t){r.subscribe(p(t,O))})}function Dt(r){return Y(function(){return r})}function ft(r,t){return t?function(e){return er(t.pipe(or(1),qt()),e.pipe(ft(r)))}:V(function(e,o){return v(r(e,o)).pipe(or(1),Dt(e))})}function en(r,t){t===void 0&&(t=C);var e=z(r,t);return ft(function(){return e})}function on(){return m(function(r,t){r.subscribe(p(t,function(e){return It(e,t)}))})}function nn(r,t){return m(function(e,o){var n=new Set;e.subscribe(p(o,function(i){var u=r?r(i):i;n.has(u)||(n.add(u),o.next(i))})),t&&v(t).subscribe(p(o,function(){return n.clear()},O))})}function Yt(r,t){return t===void 0&&(t=F),r=r??un,m(function(e,o){var n,i=!0;e.subscribe(p(o,function(u){var f=t(u);(i||!r(n,f))&&(i=!1,n=f,o.next(u))}))})}function un(r,t){return r===t}function fn(r,t){return Yt(function(e,o){return t?t(e[r],o[r]):e[r]===o[r]})}function xr(r){return r===void 0&&(r=an),m(function(t,e){var o=!1;t.subscribe(p(e,function(n){o=!0,e.next(n)},function(){return o?e.complete():e.error(r())}))})}function an(){return new D}function cn(r,t){if(r<0)throw new tt;var e=arguments.length>=2;return function(o){return o.pipe(K(function(n,i){return i===r}),or(1),e?hr(t):xr(function(){return new tt}))}}function mn(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return function(e){return er(e,Mr.apply(void 0,_([],A(r))))}}function pn(r,t){return m(function(e,o){var n=0;e.subscribe(p(o,function(i){r.call(t,i,n++,e)||(o.next(!1),o.complete())},function(){o.next(!0),o.complete()}))})}function at(r,t){return t?function(e){return e.pipe(at(function(o,n){return v(r(o,n)).pipe(Y(function(i,u){return t(o,i,n,u)}))}))}:m(function(e,o){var n=0,i=null,u=!1;e.subscribe(p(o,function(f){i||(i=p(o,void 0,function(){i=null,u&&o.complete()}),v(r(f,n++)).subscribe(i))},function(){u=!0,!i&&o.complete()}))})}function zt(){return at(F)}var ln=zt;function sn(r,t,e){return t===void 0&&(t=1/0),t=(t||0)<1?1/0:t,m(function(o,n){return Er(o,n,r,t,void 0,!0,e)})}function vn(r){return m(function(t,e){try{t.subscribe(e)}finally{e.add(r)}})}function dn(r,t){return m(Gt(r,t,"value"))}function Gt(r,t,e){var o=e==="index";return function(n,i){var u=0;n.subscribe(p(i,function(f){var a=u++;r.call(t,f,a,n)&&(i.next(o?a:f),i.complete())},function(){i.next(o?-1:void 0),i.complete()}))}}function hn(r,t){return m(Gt(r,t,"index"))}function xn(r,t){var e=arguments.length>=2;return function(o){return o.pipe(r?K(function(n,i){return r(n,i,o)}):F,or(1),e?hr(t):xr(function(){return new D}))}}function bn(r,t,e,o){return m(function(n,i){var u;!t||typeof t=="function"?u=t:(e=t.duration,u=t.element,o=t.connector);var f=new Map,a=function(x){f.forEach(x),x(i)},c=function(x){return a(function(b){return b.error(x)})},l=0,s=!1,h=new Fr(i,function(x){try{var b=r(x),g=f.get(b);if(!g){f.set(b,g=o?o():new I);var S=d(b,g);if(i.next(S),e){var T=p(g,function(){g.complete(),T?.unsubscribe()},void 0,void 0,function(){return f.delete(b)});h.add(v(e(S)).subscribe(T))}}g.next(u?u(x):x)}catch(W){c(W)}},function(){return a(function(x){return x.complete()})},c,function(){return f.clear()},function(){return s=!0,l===0});n.subscribe(h);function d(x,b){var g=new w(function(S){l++;var T=b.subscribe(S);return function(){T.unsubscribe(),--l===0&&s&&h.unsubscribe()}});return g.key=x,g}})}function yn(){return m(function(r,t){r.subscribe(p(t,function(){t.next(!1),t.complete()},function(){t.next(!0),t.complete()}))})}function Kt(r){return r<=0?function(){return M}:m(function(t,e){var o=[];t.subscribe(p(e,function(n){o.push(n),r<o.length&&o.shift()},function(){var n,i;try{for(var u=P(o),f=u.next();!f.done;f=u.next()){var a=f.value;e.next(a)}}catch(c){n={error:c}}finally{try{f&&!f.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}e.complete()},void 0,function(){o=null}))})}function gn(r,t){var e=arguments.length>=2;return function(o){return o.pipe(r?K(function(n,i){return r(n,i,o)}):F,Kt(1),e?hr(t):xr(function(){return new D}))}}function wn(){return m(function(r,t){r.subscribe(p(t,function(e){t.next(kr.createNext(e))},function(){t.next(kr.createComplete()),t.complete()},function(e){t.next(kr.createError(e)),t.complete()}))})}function Sn(r){return X(y(r)?function(t,e){return r(t,e)>0?t:e}:function(t,e){return t>e?t:e})}var An=V;function _n(r,t,e){return e===void 0&&(e=1/0),y(t)?V(function(){return r},t,e):(typeof t=="number"&&(e=t),V(function(){return r},e))}function En(r,t,e){return e===void 0&&(e=1/0),m(function(o,n){var i=t;return Er(o,n,function(u,f){return r(i,u,f)},e,function(u){i=u},!1,void 0,function(){return i=null})})}function Me(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r),o=zr(r,1/0);return m(function(n,i){vr(o)(N(_([n],A(r)),e)).subscribe(i)})}function On(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Me.apply(void 0,_([],A(r)))}function In(r){return X(y(r)?function(t,e){return r(t,e)<0?t:e}:function(t,e){return t<e?t:e})}function Wr(r,t){var e=y(r)?r:function(){return r};return y(t)?Nr(t,{connector:e}):function(o){return new mr(o,e)}}function Fn(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=J(r);return function(o){return kt.apply(void 0,_([o],A(e)))}}function Tn(){return m(function(r,t){var e,o=!1;r.subscribe(p(t,function(n){var i=e;e=n,o&&t.next([i,n]),o=!0}))})}function jn(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=r.length;if(e===0)throw new Error("list of properties cannot be empty.");return Y(function(o){for(var n=o,i=0;i<e;i++){var u=n?.[r[i]];if(typeof u<"u")n=u;else return}return n})}function Pn(r){return r?function(t){return Nr(r)(t)}:function(t){return Wr(new I)(t)}}function Cn(r){return function(t){var e=new yt(r);return new mr(t,function(){return e})}}function Rn(){return function(r){var t=new jr;return new mr(r,function(){return t})}}function Mn(r,t,e,o){e&&!y(e)&&(o=e);var n=y(e)?e:void 0;return function(i){return Wr(new Tr(r,t,o),n)(i)}}function kn(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return r.length?m(function(e,o){Vt(_([e],A(r)))(o)}):F}function Vn(r){var t,e=1/0,o;return r!=null&&(typeof r=="object"?(t=r.count,e=t===void 0?1/0:t,o=r.delay):e=r),e<=0?function(){return M}:m(function(n,i){var u=0,f,a=function(){if(f?.unsubscribe(),f=null,o!=null){var l=typeof o=="number"?z(o):v(o(u)),s=p(i,function(){s.unsubscribe(),c()});l.subscribe(s)}else c()},c=function(){var l=!1;f=n.subscribe(p(i,void 0,function(){++u<e?f?a():l=!0:i.complete()})),l&&a()};c()})}function Ln(r){return m(function(t,e){var o,n=!1,i,u=!1,f=!1,a=function(){return f&&u&&(e.complete(),!0)},c=function(){return i||(i=new I,v(r(i)).subscribe(p(e,function(){o?l():n=!0},function(){u=!0,a()}))),i},l=function(){f=!1,o=t.subscribe(p(e,void 0,function(){f=!0,!a()&&c().next()})),n&&(o.unsubscribe(),o=null,n=!1,l())};l()})}function Nn(r){r===void 0&&(r=1/0);var t;r&&typeof r=="object"?t=r:t={count:r};var e=t.count,o=e===void 0?1/0:e,n=t.delay,i=t.resetOnSuccess,u=i===void 0?!1:i;return o<=0?F:m(function(f,a){var c=0,l,s=function(){var h=!1;l=f.subscribe(p(a,function(d){u&&(c=0),a.next(d)},void 0,function(d){if(c++<o){var x=function(){l?(l.unsubscribe(),l=null,s()):h=!0};if(n!=null){var b=typeof n=="number"?z(n):v(n(d,c)),g=p(a,function(){g.unsubscribe(),x()},function(){a.complete()});b.subscribe(g)}else x()}else a.error(d)})),h&&(l.unsubscribe(),l=null,s())};s()})}function Wn(r){return m(function(t,e){var o,n=!1,i,u=function(){o=t.subscribe(p(e,void 0,void 0,function(f){i||(i=new I,v(r(i)).subscribe(p(e,function(){return o?u():n=!0}))),i&&i.next(f)})),n&&(o.unsubscribe(),o=null,n=!1,u())};u()})}function Qt(r){return m(function(t,e){var o=!1,n=null;t.subscribe(p(e,function(i){o=!0,n=i})),v(r).subscribe(p(e,function(){if(o){o=!1;var i=n;n=null,e.next(i)}},O))})}function Un(r,t){return t===void 0&&(t=C),Qt(Mt(r,t))}function qn(r,t){return m(nt(r,t,arguments.length>=2,!0))}function Dn(r,t){return t===void 0&&(t=function(e,o){return e===o}),m(function(e,o){var n=ke(),i=ke(),u=function(a){o.next(a),o.complete()},f=function(a,c){var l=p(o,function(s){var h=c.buffer,d=c.complete;h.length===0?d?u(!1):a.buffer.push(s):!t(s,h.shift())&&u(!1)},function(){a.complete=!0;var s=c.complete,h=c.buffer;s&&u(h.length===0),l?.unsubscribe()});return l};e.subscribe(f(n,i)),v(r).subscribe(f(i,n))})}function ke(){return{buffer:[],complete:!1}}function $t(r){r===void 0&&(r={});var t=r.connector,e=t===void 0?function(){return new I}:t,o=r.resetOnError,n=o===void 0?!0:o,i=r.resetOnComplete,u=i===void 0?!0:i,f=r.resetOnRefCountZero,a=f===void 0?!0:f;return function(c){var l,s,h,d=0,x=!1,b=!1,g=function(){s?.unsubscribe(),s=void 0},S=function(){g(),l=h=void 0,x=b=!1},T=function(){var W=l;S(),W?.unsubscribe()};return m(function(W,rr){d++,!b&&!x&&g();var ir=h=h??e();rr.add(function(){d--,d===0&&!b&&!x&&(s=Bt(T,a))}),ir.subscribe(rr),!l&&d>0&&(l=new Z({next:function(ur){return ir.next(ur)},error:function(ur){b=!0,g(),s=Bt(S,n,ur),ir.error(ur)},complete:function(){x=!0,g(),s=Bt(S,u),ir.complete()}}),v(W).subscribe(l))})(c)}}function Bt(r,t){for(var e=[],o=2;o<arguments.length;o++)e[o-2]=arguments[o];if(t===!0){r();return}if(t!==!1){var n=new Z({next:function(){n.unsubscribe(),r()}});return v(t.apply(void 0,_([],A(e)))).subscribe(n)}}function Yn(r,t,e){var o,n,i,u,f=!1;return r&&typeof r=="object"?(o=r.bufferSize,u=o===void 0?1/0:o,n=r.windowTime,t=n===void 0?1/0:n,i=r.refCount,f=i===void 0?!1:i,e=r.scheduler):u=r??1/0,$t({connector:function(){return new Tr(u,t,e)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:f})}function zn(r){return m(function(t,e){var o=!1,n,i=!1,u=0;t.subscribe(p(e,function(f){i=!0,(!r||r(f,u++,t))&&(o&&e.error(new Tt("Too many matching values")),o=!0,n=f)},function(){o?(e.next(n),e.complete()):e.error(i?new Ft("No matching values"):new D)}))})}function Gn(r){return K(function(t,e){return r<=e})}function Kn(r){return r<=0?F:m(function(t,e){var o=new Array(r),n=0;return t.subscribe(p(e,function(i){var u=n++;if(u<r)o[u]=i;else{var f=u%r,a=o[f];o[f]=i,e.next(a)}})),function(){o=null}})}function Qn(r){return m(function(t,e){var o=!1,n=p(e,function(){n?.unsubscribe(),o=!0},O);v(r).subscribe(n),t.subscribe(p(e,function(i){return o&&e.next(i)}))})}function Bn(r){return m(function(t,e){var o=!1,n=0;t.subscribe(p(e,function(i){return(o||(o=!r(i,n++)))&&e.next(i)}))})}function $n(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r);return m(function(o,n){(e?er(r,o,e):er(r,o)).subscribe(n)})}function nr(r,t){return m(function(e,o){var n=null,i=0,u=!1,f=function(){return u&&!n&&o.complete()};e.subscribe(p(o,function(a){n?.unsubscribe();var c=0,l=i++;v(r(a,l)).subscribe(n=p(o,function(s){return o.next(t?t(a,s,l,c++):s)},function(){n=null,f()}))},function(){u=!0,f()}))})}function Jn(){return nr(F)}function Zn(r,t){return y(t)?nr(function(){return r},t):nr(function(){return r})}function Hn(r,t){return m(function(e,o){var n=t;return nr(function(i,u){return r(n,i,u)},function(i,u){return n=u,u})(e).subscribe(o),function(){n=null}})}function Xn(r){return m(function(t,e){v(r).subscribe(p(e,function(){return e.complete()},O)),!e.closed&&t.subscribe(e)})}function ri(r,t){return t===void 0&&(t=!1),m(function(e,o){var n=0;e.subscribe(p(o,function(i){var u=r(i,n++);(u||t)&&o.next(i),!u&&o.complete()}))})}function ti(r,t,e){var o=y(r)||t||e?{next:r,error:t,complete:e}:r;return o?m(function(n,i){var u;(u=o.subscribe)===null||u===void 0||u.call(o);var f=!0;n.subscribe(p(i,function(a){var c;(c=o.next)===null||c===void 0||c.call(o,a),i.next(a)},function(){var a;f=!1,(a=o.complete)===null||a===void 0||a.call(o),i.complete()},function(a){var c;f=!1,(c=o.error)===null||c===void 0||c.call(o,a),i.error(a)},function(){var a,c;f&&((a=o.unsubscribe)===null||a===void 0||a.call(o)),(c=o.finalize)===null||c===void 0||c.call(o)}))}):F}function Jt(r,t){return m(function(e,o){var n=t??{},i=n.leading,u=i===void 0?!0:i,f=n.trailing,a=f===void 0?!1:f,c=!1,l=null,s=null,h=!1,d=function(){s?.unsubscribe(),s=null,a&&(g(),h&&o.complete())},x=function(){s=null,h&&o.complete()},b=function(S){return s=v(r(S)).subscribe(p(o,d,x))},g=function(){if(c){c=!1;var S=l;l=null,o.next(S),!h&&b(S)}};e.subscribe(p(o,function(S){c=!0,l=S,!(s&&!s.closed)&&(u?g():b(S))},function(){h=!0,!(a&&c&&s&&!s.closed)&&o.complete()}))})}function ei(r,t,e){t===void 0&&(t=C);var o=z(r,t);return Jt(function(){return o},e)}function oi(r){return r===void 0&&(r=C),m(function(t,e){var o=r.now();t.subscribe(p(e,function(n){var i=r.now(),u=i-o;o=i,e.next(new ni(n,u))}))})}var ni=(function(){function r(t,e){this.value=t,this.interval=e}return r})();function ii(r,t,e){var o,n,i;if(e=e??Rr,Ar(r)?o=r:typeof r=="number"&&(n=r),t)i=function(){return t};else throw new TypeError("No observable provided to switch to");if(o==null&&n==null)throw new TypeError("No timeout provided.");return jt({first:o,each:n,scheduler:e,with:i})}function ui(r){return r===void 0&&(r=pr),Y(function(t){return{value:t,timestamp:r.now()}})}function fi(r){return m(function(t,e){var o=new I;e.next(o.asObservable());var n=function(i){o.error(i),e.error(i)};return t.subscribe(p(e,function(i){return o?.next(i)},function(){o.complete(),e.complete()},n)),v(r).subscribe(p(e,function(){o.complete(),e.next(o=new I)},O,n)),function(){o?.unsubscribe(),o=null}})}function ai(r,t){t===void 0&&(t=0);var e=t>0?t:r;return m(function(o,n){var i=[new I],u=[],f=0;n.next(i[0].asObservable()),o.subscribe(p(n,function(a){var c,l;try{for(var s=P(i),h=s.next();!h.done;h=s.next()){var d=h.value;d.next(a)}}catch(g){c={error:g}}finally{try{h&&!h.done&&(l=s.return)&&l.call(s)}finally{if(c)throw c.error}}var x=f-r+1;if(x>=0&&x%e===0&&i.shift().complete(),++f%e===0){var b=new I;i.push(b),n.next(b.asObservable())}},function(){for(;i.length>0;)i.shift().complete();n.complete()},function(a){for(;i.length>0;)i.shift().error(a);n.error(a)},function(){u=null,i=null}))})}function ci(r){for(var t,e,o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];var i=(t=k(o))!==null&&t!==void 0?t:C,u=(e=o[0])!==null&&e!==void 0?e:null,f=o[1]||1/0;return m(function(a,c){var l=[],s=!1,h=function(g){var S=g.window,T=g.subs;S.complete(),T.unsubscribe(),L(l,g),s&&d()},d=function(){if(l){var g=new j;c.add(g);var S=new I,T={window:S,subs:g,seen:0};l.push(T),c.next(S.asObservable()),R(g,i,function(){return h(T)},r)}};u!==null&&u>=0?R(c,i,d,u,!0):s=!0,d();var x=function(g){return l.slice().forEach(g)},b=function(g){x(function(S){var T=S.window;return g(T)}),g(c),c.unsubscribe()};return a.subscribe(p(c,function(g){x(function(S){S.window.next(g),f<=++S.seen&&h(S)})},function(){return b(function(g){return g.complete()})},function(g){return b(function(S){return S.error(g)})})),function(){l=null}})}function mi(r,t){return m(function(e,o){var n=[],i=function(u){for(;0<n.length;)n.shift().error(u);o.error(u)};v(r).subscribe(p(o,function(u){var f=new I;n.push(f);var a=new j,c=function(){L(n,f),f.complete(),a.unsubscribe()},l;try{l=v(t(u))}catch(s){i(s);return}o.next(f.asObservable()),a.add(l.subscribe(p(o,c,O,i)))},O)),e.subscribe(p(o,function(u){var f,a,c=n.slice();try{for(var l=P(c),s=l.next();!s.done;s=l.next()){var h=s.value;h.next(u)}}catch(d){f={error:d}}finally{try{s&&!s.done&&(a=l.return)&&a.call(l)}finally{if(f)throw f.error}}},function(){for(;0<n.length;)n.shift().complete();o.complete()},i,function(){for(;0<n.length;)n.shift().unsubscribe()}))})}function pi(r){return m(function(t,e){var o,n,i=function(f){o.error(f),e.error(f)},u=function(){n?.unsubscribe(),o?.complete(),o=new I,e.next(o.asObservable());var f;try{f=v(r())}catch(a){i(a);return}f.subscribe(n=p(e,u,u,i))};u(),t.subscribe(p(e,function(f){return o.next(f)},function(){o.complete(),e.complete()},i,function(){n?.unsubscribe(),o=null}))})}function li(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=$(r);return m(function(o,n){for(var i=r.length,u=new Array(i),f=r.map(function(){return!1}),a=!1,c=function(s){v(r[s]).subscribe(p(n,function(h){u[s]=h,!a&&!f[s]&&(f[s]=!0,(a=f.every(F))&&(f=null))},O))},l=0;l<i;l++)c(l);o.subscribe(p(n,function(s){if(a){var h=_([s],A(u));n.next(e?e.apply(void 0,_([],A(h))):h)}}))})}function si(r){return it(Lr,r)}function Ve(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return m(function(e,o){Lr.apply(void 0,_([e],A(r))).subscribe(o)})}function vi(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Ve.apply(void 0,_([],A(r)))}export{Or as a,j as b,G as c,O as d,wr as e,cr as f,F as g,Ir as h,w as i,ht as j,mr as k,ze as l,bt as m,I as n,yt as o,Tr as p,jr as q,Yr as r,le as s,$e as t,C as u,Rr as v,de as w,Je as x,be as y,Ze as z,He as A,ye as B,M as C,Xe as D,lr as E,sr as F,_t as G,N as H,Mr as I,Et as J,Ot as K,kr as L,ao as M,D as N,co as O,mo as P,tt as Q,Ft as R,Tt as S,Ee as T,jt as U,Y as V,vo as W,ho as X,Pt as Y,V as Z,vr as _,Vr as $,er as aa,dr as ba,Ao as ca,_o as da,Rt as ea,Fe as fa,Po as ga,Co as ha,z as ia,Mt as ja,Ro as ka,Te as la,Mo as ma,kt as na,Vo as oa,K as pa,Lo as qa,No as ra,Wo as sa,Uo as ta,Lr as ua,Lt as va,qo as wa,Do as xa,Yo as ya,zo as za,Go as Aa,Ko as Ba,Pe as Ca,X as Da,Nt as Ea,Wt as Fa,Bo as Ga,$o as Ha,ut as Ia,Jo as Ja,Zo as Ka,Nr as La,Xo as Ma,rn as Na,tn as Oa,hr as Pa,or as Qa,qt as Ra,Dt as Sa,ft as Ta,en as Ua,on as Va,nn as Wa,Yt as Xa,fn as Ya,xr as Za,cn as _a,mn as $a,pn as ab,at as bb,zt as cb,ln as db,sn as eb,vn as fb,dn as gb,hn as hb,xn as ib,bn as jb,yn as kb,Kt as lb,gn as mb,wn as nb,Sn as ob,An as pb,_n as qb,En as rb,On as sb,In as tb,Wr as ub,Fn as vb,Tn as wb,jn as xb,Pn as yb,Cn as zb,Rn as Ab,Mn as Bb,kn as Cb,Vn as Db,Ln as Eb,Nn as Fb,Wn as Gb,Qt as Hb,Un as Ib,qn as Jb,Dn as Kb,$t as Lb,Yn as Mb,zn as Nb,Gn as Ob,Kn as Pb,Qn as Qb,Bn as Rb,$n as Sb,nr as Tb,Jn as Ub,Zn as Vb,Hn as Wb,Xn as Xb,ri as Yb,ti as Zb,Jt as _b,ei as $b,oi as ac,ii as bc,ui as cc,fi as dc,ai as ec,ci as fc,mi as gc,pi as hc,li as ic,si as jc,vi as kc};
@@ -0,0 +1,121 @@
1
+ import {
2
+ EncryptionErrorCode
3
+ } from "./chunk-O37NHERH.mjs";
4
+ import {
5
+ DStorageError,
6
+ mlkemGenerateKeypair,
7
+ mlkemUnwrapDek,
8
+ mlkemWrapDek
9
+ } from "./chunk-BWLEAAFW.mjs";
10
+
11
+ // ../encryption/dist/chunk-NAJYQ4J6.mjs
12
+ var KeypairEncryptionAdapter = class _KeypairEncryptionAdapter {
13
+ constructor(pk, sk, context, variant) {
14
+ this.publicKey = pk;
15
+ this.secretKey = sk;
16
+ this.context = context;
17
+ this.variant = variant;
18
+ this.name = variant;
19
+ }
20
+ /**
21
+ * Upload-only adapter — holds only the Public Key.
22
+ * wrapDek() works normally; unwrapDek() throws (no SK available).
23
+ */
24
+ static fromPublicKey(pk, context, variant = "mlkem768") {
25
+ return new _KeypairEncryptionAdapter(pk, void 0, context, variant);
26
+ }
27
+ /**
28
+ * Full adapter — holds both Public Key and Secret Key.
29
+ * Both wrapDek() and unwrapDek() work.
30
+ */
31
+ static fromKeypair(pk, sk, context, variant = "mlkem768") {
32
+ return new _KeypairEncryptionAdapter(pk, sk, context, variant);
33
+ }
34
+ /**
35
+ * Generate a fresh random ML-KEM keypair.
36
+ *
37
+ * Returns the adapter (with both PK+SK) plus the raw keys so the caller
38
+ * can persist the secret key and share the public key separately.
39
+ *
40
+ * @param context Domain-separation string bound into the KEK derivation
41
+ * @param variant Default: "mlkem768".
42
+ */
43
+ static generateKeypair(context, variant = "mlkem768") {
44
+ const { pk, sk } = mlkemGenerateKeypair(variant);
45
+ return {
46
+ adapter: new _KeypairEncryptionAdapter(pk, sk, context, variant),
47
+ publicKey: pk,
48
+ secretKey: sk
49
+ };
50
+ }
51
+ /**
52
+ * Deterministically derive a ML-KEM keypair from a BIP-39 mnemonic phrase or hex seed.
53
+ *
54
+ * Delegates to MnemonicEncryptionAdapter.intoKeypairEncryptionAdapter() so all
55
+ * mnemonic/seed handling lives in a single place.
56
+ *
57
+ * Same inputs + variant always produce the same keypair.
58
+ *
59
+ * `seedHex` may be either 32 bytes (64 hex chars) or 64 bytes (128 hex chars) —
60
+ * both are expanded to the 64-byte ML-KEM seed via HKDF.
61
+ *
62
+ * @param input { mnemonic } (24-word BIP-39) or { seedHex } (32- or 64-byte hex)
63
+ * @param context Domain-separation string bound into the KEK derivation
64
+ * @param variant Default: "mlkem768"
65
+ */
66
+ static async fromMnemonic(input, context, variant = "mlkem768") {
67
+ const { MnemonicEncryptionAdapter } = await import("./MnemonicEncryptionAdapter-RCHUETBP-DZPBGQG6.mjs");
68
+ const ms = new MnemonicEncryptionAdapter(input);
69
+ return ms.intoKeypairEncryptionAdapter(context, variant);
70
+ }
71
+ /**
72
+ * Deterministically derive a ML-KEM keypair from a password and salt.
73
+ *
74
+ * Delegates to PasswordEncryptionAdapter.intoKeypairEncryptionAdapter() so all
75
+ * password handling (scrypt params, entropy validation, 64-byte seed derivation)
76
+ * lives in a single place.
77
+ *
78
+ * Same password + salt + variant always produces the same keypair.
79
+ *
80
+ * @param password User password (validated for entropy)
81
+ * @param salt Domain salt — must not be empty
82
+ * @param context Domain-separation string bound into the KEK derivation
83
+ * @param variant Default: "mlkem768"
84
+ * @param params Optional custom scrypt params
85
+ */
86
+ static async fromPassword(password, salt, context, variant = "mlkem768", params) {
87
+ const { PasswordEncryptionAdapter } = await import("./PasswordEncryptionAdapter-ECHND672-MUTHAMZY.mjs");
88
+ const ps = new PasswordEncryptionAdapter({
89
+ password,
90
+ salt,
91
+ ...params ? { params } : {}
92
+ });
93
+ return ps.intoKeypairEncryptionAdapter(context, variant);
94
+ }
95
+ /**
96
+ * Zero the Secret Key bytes and mark this adapter as read-only.
97
+ * Call when the adapter is no longer needed to minimise the window
98
+ * during which raw ML-KEM key material sits in GC-reachable memory.
99
+ * After destroy(), unwrapDek() will throw.
100
+ */
101
+ destroy() {
102
+ this.secretKey?.fill(0);
103
+ this.secretKey = void 0;
104
+ }
105
+ async wrapDek(dek) {
106
+ return mlkemWrapDek(dek, this.publicKey, this.context, this.variant);
107
+ }
108
+ async unwrapDek(data) {
109
+ if (!this.secretKey) {
110
+ throw new DStorageError(
111
+ EncryptionErrorCode.KEYPAIR_MISSING_SECRET_KEY,
112
+ `[dStorage] KeypairEncryptionAdapter(${this.variant}): cannot unwrapDek \u2014 no Secret Key is available. Use fromKeypair() or fromPassword() to create an adapter with a SK.`
113
+ );
114
+ }
115
+ return mlkemUnwrapDek(data, this.secretKey, this.context);
116
+ }
117
+ };
118
+
119
+ export {
120
+ KeypairEncryptionAdapter
121
+ };
@@ -0,0 +1 @@
1
+ import{a as m}from"./chunk-PKHRAYFD.mjs";import{A as c,B as p,a as o,y as s}from"./chunk-EYF3263P.mjs";var h=class n{constructor(e,t,r,i){this.publicKey=e,this.secretKey=t,this.context=r,this.variant=i,this.name=i}static fromPublicKey(e,t,r="mlkem768"){return new n(e,void 0,t,r)}static fromKeypair(e,t,r,i="mlkem768"){return new n(e,t,r,i)}static generateKeypair(e,t="mlkem768"){let{pk:r,sk:i}=s(t);return{adapter:new n(r,i,e,t),publicKey:r,secretKey:i}}static async fromMnemonic(e,t,r="mlkem768"){let{MnemonicEncryptionAdapter:i}=await import("./MnemonicEncryptionAdapter-J6IE5OKA-O5AJPX42.mjs");return new i(e).intoKeypairEncryptionAdapter(t,r)}static async fromPassword(e,t,r,i="mlkem768",a){let{PasswordEncryptionAdapter:y}=await import("./PasswordEncryptionAdapter-CWOXUGR4-2YZ64B4A.mjs");return new y({password:e,salt:t,...a?{params:a}:{}}).intoKeypairEncryptionAdapter(r,i)}destroy(){this.secretKey?.fill(0),this.secretKey=void 0}async wrapDek(e){return c(e,this.publicKey,this.context,this.variant)}async unwrapDek(e){if(!this.secretKey)throw new o(m.KEYPAIR_MISSING_SECRET_KEY,`[dStorage] KeypairEncryptionAdapter(${this.variant}): cannot unwrapDek \u2014 no Secret Key is available. Use fromKeypair() or fromPassword() to create an adapter with a SK.`);return p(e,this.secretKey,this.context)}};export{h as a};
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty,i=(e,r,t)=>r in e?a(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,l=(e,r,t)=>i(e,typeof r!="symbol"?r+"":r,t);export{l as a};
@@ -0,0 +1,5 @@
1
+ import {
2
+ require_cjs
3
+ } from "./chunk-25I6ZXUC.mjs";
4
+ import "./chunk-UJCSKKID.mjs";
5
+ export default require_cjs();