@cedros/login-react 0.0.1

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 (200) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1183 -0
  3. package/dist/EmailRegisterForm-D_uCEdX9.cjs +1 -0
  4. package/dist/EmailRegisterForm-D_uCEdX9.cjs.map +1 -0
  5. package/dist/EmailRegisterForm-m3rX3A6X.js +2923 -0
  6. package/dist/EmailRegisterForm-m3rX3A6X.js.map +1 -0
  7. package/dist/ErrorMessage-Bm1j5mBT.js +2042 -0
  8. package/dist/ErrorMessage-Bm1j5mBT.js.map +1 -0
  9. package/dist/ErrorMessage-CntMyn93.cjs +1 -0
  10. package/dist/ErrorMessage-CntMyn93.cjs.map +1 -0
  11. package/dist/GoogleLoginButton-CJNJ-THo.cjs +1 -0
  12. package/dist/GoogleLoginButton-CJNJ-THo.cjs.map +1 -0
  13. package/dist/GoogleLoginButton-CvDoOc-0.js +227 -0
  14. package/dist/GoogleLoginButton-CvDoOc-0.js.map +1 -0
  15. package/dist/SolanaLoginButton-BlSgPW50.cjs +1 -0
  16. package/dist/SolanaLoginButton-BlSgPW50.cjs.map +1 -0
  17. package/dist/SolanaLoginButton-h32xN2PQ.js +261 -0
  18. package/dist/SolanaLoginButton-h32xN2PQ.js.map +1 -0
  19. package/dist/assets/argon2Worker-Bi5TuQvD.js +1 -0
  20. package/dist/assets/argon2Worker-Bi5TuQvD.js.map +1 -0
  21. package/dist/components/LoginButton.d.ts +23 -0
  22. package/dist/components/LoginForm.d.ts +9 -0
  23. package/dist/components/LoginModal.d.ts +9 -0
  24. package/dist/components/admin/AdminUserDetail.d.ts +21 -0
  25. package/dist/components/admin/AdminUserList.d.ts +25 -0
  26. package/dist/components/admin/CedrosAdminDashboard.d.ts +48 -0
  27. package/dist/components/admin/SystemSettings.d.ts +19 -0
  28. package/dist/components/apple/AppleLoginButton.d.ts +29 -0
  29. package/dist/components/deposit/CreditBalance.d.ts +19 -0
  30. package/dist/components/deposit/DepositFlow.d.ts +118 -0
  31. package/dist/components/deposit/FeeConfigDisplay.d.ts +15 -0
  32. package/dist/components/deposit/History.d.ts +21 -0
  33. package/dist/components/deposit/TieredAmountSlider.d.ts +19 -0
  34. package/dist/components/deposit/TokenSelector.d.ts +23 -0
  35. package/dist/components/deposit/admin/AdminDepositList.d.ts +21 -0
  36. package/dist/components/deposit/admin/AdminDepositStats.d.ts +15 -0
  37. package/dist/components/deposit/admin/AdminPrivacyPeriodDeposits.d.ts +19 -0
  38. package/dist/components/deposit/admin/AdminWithdrawalHistory.d.ts +19 -0
  39. package/dist/components/deposit/admin/AdminWithdrawalQueue.d.ts +23 -0
  40. package/dist/components/deposit/admin/PrivacySystemStatus.d.ts +15 -0
  41. package/dist/components/deposit/admin/index.d.ts +17 -0
  42. package/dist/components/deposit/index.d.ts +12 -0
  43. package/dist/components/deposit/tierUtils.d.ts +8 -0
  44. package/dist/components/deposit/tokens.d.ts +19 -0
  45. package/dist/components/email/EmailLoginForm.d.ts +11 -0
  46. package/dist/components/email/EmailRegisterForm.d.ts +14 -0
  47. package/dist/components/email/ForgotPasswordForm.d.ts +17 -0
  48. package/dist/components/email/PasswordInput.d.ts +14 -0
  49. package/dist/components/email/ResetPasswordForm.d.ts +22 -0
  50. package/dist/components/google/GoogleLoginButton.d.ts +12 -0
  51. package/dist/components/invites/InviteForm.d.ts +38 -0
  52. package/dist/components/invites/InviteList.d.ts +40 -0
  53. package/dist/components/members/MemberList.d.ts +47 -0
  54. package/dist/components/org/CreateOrgForm.d.ts +7 -0
  55. package/dist/components/org/OrgAvatar.d.ts +7 -0
  56. package/dist/components/org/OrgListView.d.ts +9 -0
  57. package/dist/components/org/OrgSelector.d.ts +51 -0
  58. package/dist/components/org/OrgSwitcher.d.ts +47 -0
  59. package/dist/components/org/icons.d.ts +8 -0
  60. package/dist/components/sessions/SessionList.d.ts +33 -0
  61. package/dist/components/shared/ErrorBoundary.d.ts +38 -0
  62. package/dist/components/shared/ErrorMessage.d.ts +14 -0
  63. package/dist/components/shared/LoadingSpinner.d.ts +16 -0
  64. package/dist/components/solana/SolanaLoginButton.d.ts +49 -0
  65. package/dist/components/templates/FullPageLayout.d.ts +40 -0
  66. package/dist/components/templates/SplitPageLayout.d.ts +44 -0
  67. package/dist/components/templates/index.d.ts +4 -0
  68. package/dist/components/totp/OtpInput.d.ts +32 -0
  69. package/dist/components/totp/QrCode.d.ts +21 -0
  70. package/dist/components/totp/TotpSettings.d.ts +38 -0
  71. package/dist/components/totp/TotpSetup.d.ts +23 -0
  72. package/dist/components/totp/TotpVerify.d.ts +25 -0
  73. package/dist/components/totp/index.d.ts +10 -0
  74. package/dist/components/wallet/CapabilityWarning.d.ts +11 -0
  75. package/dist/components/wallet/PasskeyPrompt.d.ts +34 -0
  76. package/dist/components/wallet/RecoveryPhraseDisplay.d.ts +18 -0
  77. package/dist/components/wallet/RecoveryPhraseInput.d.ts +21 -0
  78. package/dist/components/wallet/WalletAddressRow.d.ts +10 -0
  79. package/dist/components/wallet/WalletEnrollment.d.ts +15 -0
  80. package/dist/components/wallet/WalletManager.d.ts +9 -0
  81. package/dist/components/wallet/WalletRecovery.d.ts +19 -0
  82. package/dist/components/wallet/WalletStatus.d.ts +28 -0
  83. package/dist/components/wallet/WalletUnlock.d.ts +23 -0
  84. package/dist/components/wallet/index.d.ts +23 -0
  85. package/dist/components/webauthn/PasskeyLoginButton.d.ts +8 -0
  86. package/dist/context/CedrosLoginContext.d.ts +24 -0
  87. package/dist/context/CedrosLoginProvider.d.ts +17 -0
  88. package/dist/context/EmbeddedWalletExposure.d.ts +19 -0
  89. package/dist/context/useCedrosLogin.d.ts +12 -0
  90. package/dist/crypto/aesGcm.d.ts +89 -0
  91. package/dist/crypto/argon2.d.ts +65 -0
  92. package/dist/crypto/argon2Worker.d.ts +1 -0
  93. package/dist/crypto/argon2WorkerClient.d.ts +28 -0
  94. package/dist/crypto/bip39.d.ts +106 -0
  95. package/dist/crypto/capabilities.d.ts +35 -0
  96. package/dist/crypto/entropy.d.ts +56 -0
  97. package/dist/crypto/hkdf.d.ts +38 -0
  98. package/dist/crypto/index.d.ts +30 -0
  99. package/dist/crypto/secureWipe.d.ts +90 -0
  100. package/dist/crypto/shamir.d.ts +52 -0
  101. package/dist/crypto/solanaKeypair.d.ts +63 -0
  102. package/dist/crypto/types.d.ts +134 -0
  103. package/dist/crypto/webauthnPrf.d.ts +118 -0
  104. package/dist/email-only.cjs +1 -0
  105. package/dist/email-only.cjs.map +1 -0
  106. package/dist/email-only.d.ts +16 -0
  107. package/dist/email-only.js +15 -0
  108. package/dist/email-only.js.map +1 -0
  109. package/dist/google-only.cjs +1 -0
  110. package/dist/google-only.cjs.map +1 -0
  111. package/dist/google-only.d.ts +13 -0
  112. package/dist/google-only.js +11 -0
  113. package/dist/google-only.js.map +1 -0
  114. package/dist/hooks/useAdminDeposits.d.ts +10 -0
  115. package/dist/hooks/useAdminUsers.d.ts +28 -0
  116. package/dist/hooks/useAppleAuth.d.ts +52 -0
  117. package/dist/hooks/useAuth.d.ts +34 -0
  118. package/dist/hooks/useAuthSession.d.ts +19 -0
  119. package/dist/hooks/useAuthorize.d.ts +62 -0
  120. package/dist/hooks/useCredits.d.ts +11 -0
  121. package/dist/hooks/useDeposit.d.ts +16 -0
  122. package/dist/hooks/useEmailAuth.d.ts +60 -0
  123. package/dist/hooks/useGoogleAuth.d.ts +67 -0
  124. package/dist/hooks/useInstantLink.d.ts +42 -0
  125. package/dist/hooks/useInvites.d.ts +57 -0
  126. package/dist/hooks/useMembers.d.ts +52 -0
  127. package/dist/hooks/useOrgs.d.ts +49 -0
  128. package/dist/hooks/usePasswordReset.d.ts +32 -0
  129. package/dist/hooks/usePendingRecovery.d.ts +34 -0
  130. package/dist/hooks/useRateLimiter.d.ts +58 -0
  131. package/dist/hooks/useSessions.d.ts +45 -0
  132. package/dist/hooks/useSolanaAuth.d.ts +30 -0
  133. package/dist/hooks/useSystemSettings.d.ts +47 -0
  134. package/dist/hooks/useThemeManager.d.ts +11 -0
  135. package/dist/hooks/useTotp.d.ts +52 -0
  136. package/dist/hooks/useTotpVerify.d.ts +38 -0
  137. package/dist/hooks/useTransactionSigning.d.ts +45 -0
  138. package/dist/hooks/useWallet.d.ts +10 -0
  139. package/dist/hooks/useWalletDiscovery.d.ts +24 -0
  140. package/dist/hooks/useWalletEnrollment.d.ts +9 -0
  141. package/dist/hooks/useWalletMaterial.d.ts +10 -0
  142. package/dist/hooks/useWalletRecovery.d.ts +9 -0
  143. package/dist/hooks/useWalletSigning.d.ts +31 -0
  144. package/dist/hooks/useWebAuthn.d.ts +25 -0
  145. package/dist/i18n/I18nProvider.d.ts +16 -0
  146. package/dist/i18n/context.d.ts +6 -0
  147. package/dist/i18n/index.d.ts +5 -0
  148. package/dist/i18n/translations.d.ts +66 -0
  149. package/dist/i18n/useI18n.d.ts +9 -0
  150. package/dist/index.cjs +2061 -0
  151. package/dist/index.cjs.map +1 -0
  152. package/dist/index.d.ts +126 -0
  153. package/dist/index.js +14910 -0
  154. package/dist/index.js.map +1 -0
  155. package/dist/login-react.css +1 -0
  156. package/dist/solana-only.cjs +1 -0
  157. package/dist/solana-only.cjs.map +1 -0
  158. package/dist/solana-only.d.ts +13 -0
  159. package/dist/solana-only.js +11 -0
  160. package/dist/solana-only.js.map +1 -0
  161. package/dist/style.cjs +1 -0
  162. package/dist/style.cjs.map +1 -0
  163. package/dist/style.js +1 -0
  164. package/dist/style.js.map +1 -0
  165. package/dist/types/adminUser.d.ts +112 -0
  166. package/dist/types/auth.d.ts +122 -0
  167. package/dist/types/config.d.ts +266 -0
  168. package/dist/types/deposit.d.ts +488 -0
  169. package/dist/types/index.d.ts +11 -0
  170. package/dist/types/invite.d.ts +71 -0
  171. package/dist/types/member.d.ts +45 -0
  172. package/dist/types/org.d.ts +101 -0
  173. package/dist/types/session.d.ts +28 -0
  174. package/dist/types/systemSettings.d.ts +81 -0
  175. package/dist/types/totp.d.ts +52 -0
  176. package/dist/types/wallet.d.ts +309 -0
  177. package/dist/utils/adminUserApi.d.ts +51 -0
  178. package/dist/utils/apiClient.d.ts +78 -0
  179. package/dist/utils/cryptoShim.d.ts +17 -0
  180. package/dist/utils/csrf.d.ts +1 -0
  181. package/dist/utils/deviceDetection.d.ts +17 -0
  182. package/dist/utils/embeddedWallet.d.ts +75 -0
  183. package/dist/utils/inviteApi.d.ts +31 -0
  184. package/dist/utils/memberApi.d.ts +23 -0
  185. package/dist/utils/orgApi.d.ts +36 -0
  186. package/dist/utils/sanitization.d.ts +66 -0
  187. package/dist/utils/sessionApi.d.ts +16 -0
  188. package/dist/utils/silentWalletEnroll.d.ts +41 -0
  189. package/dist/utils/systemSettingsApi.d.ts +18 -0
  190. package/dist/utils/tabSync.d.ts +46 -0
  191. package/dist/utils/tokenManager.d.ts +107 -0
  192. package/dist/utils/unlockCredential.d.ts +5 -0
  193. package/dist/utils/validation.d.ts +48 -0
  194. package/dist/utils/walletDetection.d.ts +23 -0
  195. package/dist/utils/webauthnJson.d.ts +21 -0
  196. package/dist/validation-BeXIfuHB.cjs +1 -0
  197. package/dist/validation-BeXIfuHB.cjs.map +1 -0
  198. package/dist/validation-BebL7hMF.js +56 -0
  199. package/dist/validation-BebL7hMF.js.map +1 -0
  200. package/package.json +109 -0
@@ -0,0 +1,2923 @@
1
+ import { jsxs as O, jsx as k, Fragment as fe } from "react/jsx-runtime";
2
+ import { useRef as bt, useState as D, useCallback as M, useEffect as _e, useMemo as He, useId as wt } from "react";
3
+ import { D as Oe, b as Kt, t as Ae, c as Wt, w as yt, g as Yt, d as Xt, e as Ft, f as Qt, i as Be, A as ve, j as Jt, u as de, h as ue, L as Ge, E as xt } from "./ErrorMessage-Bm1j5mBT.js";
4
+ import { b as Ue, v as er } from "./validation-BebL7hMF.js";
5
+ let ne = null, tr = 0;
6
+ const le = /* @__PURE__ */ new Map();
7
+ function rr() {
8
+ return typeof Worker > "u" ? null : (ne || (ne = new Worker(new URL(
9
+ /* @vite-ignore */
10
+ "/assets/argon2Worker-Bi5TuQvD.js",
11
+ import.meta.url
12
+ ), {
13
+ type: "module"
14
+ }), ne.onmessage = (t) => {
15
+ const { id: e, key: r, error: n } = t.data, s = le.get(e);
16
+ if (s) {
17
+ if (le.delete(e), n) {
18
+ s.reject(new Error(n));
19
+ return;
20
+ }
21
+ if (!r) {
22
+ s.reject(new Error("Argon2 worker returned no key"));
23
+ return;
24
+ }
25
+ s.resolve(r);
26
+ }
27
+ }, ne.onerror = (t) => {
28
+ const e = t instanceof ErrorEvent ? t.error : new Error("Argon2 worker error");
29
+ for (const r of le.values())
30
+ r.reject(e instanceof Error ? e : new Error(String(e)));
31
+ le.clear(), ne?.terminate(), ne = null;
32
+ }), ne);
33
+ }
34
+ async function nr(t, e, r = Oe) {
35
+ const n = rr();
36
+ return n ? new Promise((s, o) => {
37
+ const c = tr++;
38
+ le.set(c, { resolve: s, reject: o });
39
+ const a = {
40
+ id: c,
41
+ password: t,
42
+ salt: e,
43
+ params: r
44
+ };
45
+ n.postMessage(a);
46
+ }) : Kt(t, e, r);
47
+ }
48
+ function sr(t) {
49
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
50
+ }
51
+ function or(t) {
52
+ if (Object.prototype.hasOwnProperty.call(t, "__esModule")) return t;
53
+ var e = t.default;
54
+ if (typeof e == "function") {
55
+ var r = function n() {
56
+ var s = !1;
57
+ try {
58
+ s = this instanceof n;
59
+ } catch {
60
+ }
61
+ return s ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments);
62
+ };
63
+ r.prototype = e.prototype;
64
+ } else r = {};
65
+ return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(t).forEach(function(n) {
66
+ var s = Object.getOwnPropertyDescriptor(t, n);
67
+ Object.defineProperty(r, n, s.get ? s : {
68
+ enumerable: !0,
69
+ get: function() {
70
+ return t[n];
71
+ }
72
+ });
73
+ }), r;
74
+ }
75
+ var we = { exports: {} };
76
+ const ir = globalThis.crypto, ar = globalThis.crypto, cr = globalThis.crypto.subtle, lr = globalThis.crypto.getRandomValues.bind(globalThis.crypto), fr = globalThis.crypto.randomUUID.bind(globalThis.crypto), ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
77
+ __proto__: null,
78
+ default: ir,
79
+ getRandomValues: lr,
80
+ randomUUID: fr,
81
+ subtle: cr,
82
+ webcrypto: ar
83
+ }, Symbol.toStringTag, { value: "Module" })), dr = /* @__PURE__ */ or(ur);
84
+ var hr = we.exports, Fe;
85
+ function mr() {
86
+ return Fe || (Fe = 1, (function(t, e) {
87
+ (function(r, n) {
88
+ t.exports = n(dr);
89
+ })(hr, function(r) {
90
+ var n, s, o, c, a;
91
+ function i() {
92
+ n = {
93
+ bits: 8,
94
+ // default number of bits
95
+ radix: 16,
96
+ // work with HEX by default
97
+ minBits: 3,
98
+ maxBits: 20,
99
+ // this permits 1,048,575 shares, though going this high is NOT recommended in JS!
100
+ bytesPerChar: 2,
101
+ maxBytesPerChar: 6,
102
+ // Math.pow(256,7) > Math.pow(2,53)
103
+ // Primitive polynomials (in decimal form) for Galois Fields GF(2^n), for 2 <= n <= 30
104
+ // The index of each term in the array corresponds to the n for that polynomial
105
+ // i.e. to get the polynomial for n=16, use primitivePolynomials[16]
106
+ primitivePolynomials: [
107
+ null,
108
+ null,
109
+ 1,
110
+ 3,
111
+ 3,
112
+ 5,
113
+ 3,
114
+ 3,
115
+ 29,
116
+ 17,
117
+ 9,
118
+ 5,
119
+ 83,
120
+ 27,
121
+ 43,
122
+ 3,
123
+ 45,
124
+ 9,
125
+ 39,
126
+ 39,
127
+ 9,
128
+ 5,
129
+ 3,
130
+ 33,
131
+ 27,
132
+ 9,
133
+ 71,
134
+ 39,
135
+ 9,
136
+ 5,
137
+ 83
138
+ ]
139
+ }, s = {}, o = new Array(1024).join("0"), c = !0, a = [
140
+ "nodeCryptoRandomBytes",
141
+ "browserCryptoGetRandomValues",
142
+ "testRandom"
143
+ ];
144
+ }
145
+ function p() {
146
+ return !!(s && s.rng && typeof s.rng == "function");
147
+ }
148
+ function w(l, u) {
149
+ var f;
150
+ if (u === 0 || u === 1)
151
+ return l;
152
+ if (u && u > 1024)
153
+ throw new Error(
154
+ "Padding must be multiples of no larger than 1024 bits."
155
+ );
156
+ return u = u || s.bits, l && (f = l.length % u), f ? (o + l).slice(
157
+ -(u - f + l.length)
158
+ ) : l;
159
+ }
160
+ function h(l) {
161
+ var u = "", f, d;
162
+ for (d = l.length - 1; d >= 0; d--) {
163
+ if (f = parseInt(l[d], 16), isNaN(f))
164
+ throw new Error("Invalid hex character.");
165
+ u = w(f.toString(2), 4) + u;
166
+ }
167
+ return u;
168
+ }
169
+ function A(l) {
170
+ var u = "", f, d;
171
+ for (l = w(l, 4), d = l.length; d >= 4; d -= 4) {
172
+ if (f = parseInt(l.slice(d - 4, d), 2), isNaN(f))
173
+ throw new Error("Invalid binary character.");
174
+ u = f.toString(16) + u;
175
+ }
176
+ return u;
177
+ }
178
+ function N() {
179
+ return !!(r && typeof r == "object" && (typeof r.getRandomValues == "function" || typeof r.getRandomValues == "object") && (typeof Uint32Array == "function" || typeof Uint32Array == "object"));
180
+ }
181
+ function R() {
182
+ return typeof r == "object" && typeof r.randomBytes == "function";
183
+ }
184
+ function B(l) {
185
+ function u(x, v, I, C) {
186
+ var L = 0, _, U = "", V;
187
+ for (v && (_ = v.length - 1); L < _ || U.length < x; )
188
+ V = Math.abs(parseInt(v[L], I)), U = U + w(V.toString(2), C), L++;
189
+ return U = U.substr(-x), (U.match(/0/g) || []).length === U.length ? null : U;
190
+ }
191
+ function f(x) {
192
+ var v, I, C, L, _ = null;
193
+ for (C = 16, L = 4, I = Math.ceil(x / 8); _ === null; )
194
+ v = r.randomBytes(I), _ = u(x, v.toString("hex"), C, L);
195
+ return _;
196
+ }
197
+ function d(x) {
198
+ var v, I, C, L = null;
199
+ for (I = 10, C = 32, v = Math.ceil(x / 32); L === null; )
200
+ L = u(
201
+ x,
202
+ r.getRandomValues(new Uint32Array(v)),
203
+ I,
204
+ C
205
+ );
206
+ return L;
207
+ }
208
+ function y(x) {
209
+ var v, I, C, L, _, U = null;
210
+ L = 10, _ = 32, I = Math.ceil(x / 32), C = 123456789, v = new Uint32Array(I);
211
+ for (var V = 0; V < v.length; V++)
212
+ v[V] = C;
213
+ for (; U === null; )
214
+ U = u(x, v, L, _);
215
+ return U;
216
+ }
217
+ if (l && l === "testRandom")
218
+ return s.typeCSPRNG = l, y;
219
+ if (l && l === "nodeCryptoRandomBytes")
220
+ return s.typeCSPRNG = l, f;
221
+ if (l && l === "browserCryptoGetRandomValues")
222
+ return s.typeCSPRNG = l, d;
223
+ if (R())
224
+ return s.typeCSPRNG = "nodeCryptoRandomBytes", f;
225
+ if (N())
226
+ return s.typeCSPRNG = "browserCryptoGetRandomValues", d;
227
+ }
228
+ function S(l, u) {
229
+ var f = [], d;
230
+ for (u && (l = w(l, u)), d = l.length; d > s.bits; d -= s.bits)
231
+ f.push(parseInt(l.slice(d - s.bits, d), 2));
232
+ return f.push(parseInt(l.slice(0, d), 2)), f;
233
+ }
234
+ function m(l, u) {
235
+ var f = s.logs[l], d = 0, y;
236
+ for (y = u.length - 1; y >= 0; y--)
237
+ d !== 0 ? d = s.exps[(f + s.logs[d]) % s.maxShares] ^ u[y] : d = u[y];
238
+ return d;
239
+ }
240
+ function b(l, u, f) {
241
+ var d = 0, y, x, v, I;
242
+ for (v = 0, y = u.length; v < y; v++)
243
+ if (f[v]) {
244
+ for (x = s.logs[f[v]], I = 0; I < y; I++)
245
+ if (v !== I) {
246
+ if (l === u[I]) {
247
+ x = -1;
248
+ break;
249
+ }
250
+ x = (x + s.logs[l ^ u[I]] - s.logs[u[v] ^ u[I]] + s.maxShares) % s.maxShares;
251
+ }
252
+ d = x === -1 ? d : d ^ s.exps[x];
253
+ }
254
+ return d;
255
+ }
256
+ function g(l, u, f) {
257
+ var d = [], y = [l], x, v;
258
+ for (x = 1; x < f; x++)
259
+ y[x] = parseInt(s.rng(s.bits), 2);
260
+ for (x = 1, v = u + 1; x < v; x++)
261
+ d[x - 1] = {
262
+ x,
263
+ y: m(x, y)
264
+ };
265
+ return d;
266
+ }
267
+ function E(l, u, f) {
268
+ var d, y, x, v, I;
269
+ if (u = parseInt(u, s.radix), l = parseInt(l, 10) || s.bits, d = l.toString(36).toUpperCase(), x = Math.pow(2, l) - 1, v = x.toString(s.radix).length, y = w(u.toString(s.radix), v), typeof u != "number" || u % 1 !== 0 || u < 1 || u > x)
270
+ throw new Error(
271
+ "Share id must be an integer between 1 and " + x + ", inclusive."
272
+ );
273
+ return I = d + y + f, I;
274
+ }
275
+ var T = {
276
+ init: function(l, u) {
277
+ var f = [], d = [], y = 1, x, v;
278
+ if (i(), l && (typeof l != "number" || l % 1 !== 0 || l < n.minBits || l > n.maxBits))
279
+ throw new Error(
280
+ "Number of bits must be an integer between " + n.minBits + " and " + n.maxBits + ", inclusive."
281
+ );
282
+ if (u && a.indexOf(u) === -1)
283
+ throw new Error("Invalid RNG type argument : '" + u + "'");
284
+ for (s.radix = n.radix, s.bits = l || n.bits, s.size = Math.pow(2, s.bits), s.maxShares = s.size - 1, x = n.primitivePolynomials[s.bits], v = 0; v < s.size; v++)
285
+ d[v] = y, f[y] = v, y = y << 1, y >= s.size && (y = y ^ x, y = y & s.maxShares);
286
+ if (s.logs = f, s.exps = d, u && this.setRNG(u), p() || this.setRNG(), !p() || !s.bits || !s.size || !s.maxShares || !s.logs || !s.exps || s.logs.length !== s.size || s.exps.length !== s.size)
287
+ throw new Error("Initialization failed.");
288
+ },
289
+ // Evaluates the Lagrange interpolation polynomial at x=`at` for
290
+ // individual config.bits-length segments of each share in the `shares`
291
+ // Array. Each share is expressed in base `inputRadix`. The output
292
+ // is expressed in base `outputRadix'.
293
+ combine: function(l, u) {
294
+ var f, d, y, x, v = "", I, C, L, _ = [], U = [];
295
+ for (u = u || 0, f = 0, y = l.length; f < y; f++) {
296
+ if (C = this.extractShareComponents(l[f]), I === void 0)
297
+ I = C.bits;
298
+ else if (C.bits !== I)
299
+ throw new Error(
300
+ "Mismatched shares: Different bit settings."
301
+ );
302
+ if (s.bits !== I && this.init(I), _.indexOf(C.id) === -1)
303
+ for (_.push(C.id), L = S(h(C.data)), d = 0, x = L.length; d < x; d++)
304
+ U[d] = U[d] || [], U[d][_.length - 1] = L[d];
305
+ }
306
+ for (f = 0, y = U.length; f < y; f++)
307
+ v = w(b(u, _, U[f]).toString(2)) + v;
308
+ return A(
309
+ u >= 1 ? v : v.slice(v.indexOf("1") + 1)
310
+ );
311
+ },
312
+ getConfig: function() {
313
+ var l = {};
314
+ return l.radix = s.radix, l.bits = s.bits, l.maxShares = s.maxShares, l.hasCSPRNG = p(), l.typeCSPRNG = s.typeCSPRNG, l;
315
+ },
316
+ // Given a public share, extract the bits (Integer), share ID (Integer), and share data (Hex)
317
+ // and return an Object containing those components.
318
+ extractShareComponents: function(l) {
319
+ var u, f, d, y, x = {}, v, I;
320
+ if (u = parseInt(l.substr(0, 1), 36), u && (typeof u != "number" || u % 1 !== 0 || u < n.minBits || u > n.maxBits))
321
+ throw new Error(
322
+ "Invalid share : Number of bits must be an integer between " + n.minBits + " and " + n.maxBits + ", inclusive."
323
+ );
324
+ if (y = Math.pow(2, u) - 1, d = (Math.pow(2, u) - 1).toString(s.radix).length, v = "^([a-kA-K3-9]{1})([a-fA-F0-9]{" + d + "})([a-fA-F0-9]+)$", I = new RegExp(v).exec(l), I && (f = parseInt(I[2], s.radix)), typeof f != "number" || f % 1 !== 0 || f < 1 || f > y)
325
+ throw new Error(
326
+ "Invalid share : Share id must be an integer between 1 and " + s.maxShares + ", inclusive."
327
+ );
328
+ if (I && I[3])
329
+ return x.bits = u, x.id = f, x.data = I[3], x;
330
+ throw new Error("The share data provided is invalid : " + l);
331
+ },
332
+ // Set the PRNG to use. If no RNG function is supplied, pick a default using getRNG()
333
+ setRNG: function(l) {
334
+ var u = "Random number generator is invalid ", f = " Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";
335
+ if (l && typeof l == "string" && a.indexOf(l) === -1)
336
+ throw new Error("Invalid RNG type argument : '" + l + "'");
337
+ if (l || (l = B()), l && typeof l == "string" && (l = B(l)), c) {
338
+ if (l && typeof l != "function")
339
+ throw new Error(u + "(Not a function)." + f);
340
+ if (l && typeof l(s.bits) != "string")
341
+ throw new Error(
342
+ u + "(Output is not a string)." + f
343
+ );
344
+ if (l && !parseInt(l(s.bits), 2))
345
+ throw new Error(
346
+ u + "(Binary string output not parseable to an Integer)." + f
347
+ );
348
+ if (l && l(s.bits).length > s.bits)
349
+ throw new Error(
350
+ u + "(Output length is greater than config.bits)." + f
351
+ );
352
+ if (l && l(s.bits).length < s.bits)
353
+ throw new Error(
354
+ u + "(Output length is less than config.bits)." + f
355
+ );
356
+ }
357
+ return s.rng = l, !0;
358
+ },
359
+ // Converts a given UTF16 character string to the HEX representation.
360
+ // Each character of the input string is represented by
361
+ // `bytesPerChar` bytes in the output string which defaults to 2.
362
+ str2hex: function(l, u) {
363
+ var f, d, y = "", x, v, I, C;
364
+ if (typeof l != "string")
365
+ throw new Error("Input must be a character string.");
366
+ if (u || (u = n.bytesPerChar), typeof u != "number" || u < 1 || u > n.maxBytesPerChar || u % 1 !== 0)
367
+ throw new Error(
368
+ "Bytes per character must be an integer between 1 and " + n.maxBytesPerChar + ", inclusive."
369
+ );
370
+ for (f = 2 * u, d = Math.pow(16, f) - 1, I = 0, C = l.length; I < C; I++) {
371
+ if (v = l[I].charCodeAt(), isNaN(v))
372
+ throw new Error("Invalid character: " + l[I]);
373
+ if (v > d)
374
+ throw x = Math.ceil(Math.log(v + 1) / Math.log(256)), new Error(
375
+ "Invalid character code (" + v + "). Maximum allowable is 256^bytes-1 (" + d + "). To convert this character, use at least " + x + " bytes."
376
+ );
377
+ y = w(v.toString(16), f) + y;
378
+ }
379
+ return y;
380
+ },
381
+ // Converts a given HEX number string to a UTF16 character string.
382
+ hex2str: function(l, u) {
383
+ var f, d = "", y, x;
384
+ if (typeof l != "string")
385
+ throw new Error("Input must be a hexadecimal string.");
386
+ if (u = u || n.bytesPerChar, typeof u != "number" || u % 1 !== 0 || u < 1 || u > n.maxBytesPerChar)
387
+ throw new Error(
388
+ "Bytes per character must be an integer between 1 and " + n.maxBytesPerChar + ", inclusive."
389
+ );
390
+ for (f = 2 * u, l = w(l, f), y = 0, x = l.length; y < x; y += f)
391
+ d = String.fromCharCode(
392
+ parseInt(l.slice(y, y + f), 16)
393
+ ) + d;
394
+ return d;
395
+ },
396
+ // Generates a random bits-length number string using the PRNG
397
+ random: function(l) {
398
+ if (typeof l != "number" || l % 1 !== 0 || l < 2 || l > 65536)
399
+ throw new Error(
400
+ "Number of bits must be an Integer between 1 and 65536."
401
+ );
402
+ return A(s.rng(l));
403
+ },
404
+ // Divides a `secret` number String str expressed in radix `inputRadix` (optional, default 16)
405
+ // into `numShares` shares, each expressed in radix `outputRadix` (optional, default to `inputRadix`),
406
+ // requiring `threshold` number of shares to reconstruct the secret.
407
+ // Optionally, zero-pads the secret to a length that is a multiple of padLength before sharing.
408
+ share: function(l, u, f, d) {
409
+ var y, x, v = new Array(u), I = new Array(u), C, L, _;
410
+ if (d = d || 128, typeof l != "string")
411
+ throw new Error("Secret must be a string.");
412
+ if (typeof u != "number" || u % 1 !== 0 || u < 2)
413
+ throw new Error(
414
+ "Number of shares must be an integer between 2 and 2^bits-1 (" + s.maxShares + "), inclusive."
415
+ );
416
+ if (u > s.maxShares)
417
+ throw y = Math.ceil(Math.log(u + 1) / Math.LN2), new Error(
418
+ "Number of shares must be an integer between 2 and 2^bits-1 (" + s.maxShares + "), inclusive. To create " + u + " shares, use at least " + y + " bits."
419
+ );
420
+ if (typeof f != "number" || f % 1 !== 0 || f < 2)
421
+ throw new Error(
422
+ "Threshold number of shares must be an integer between 2 and 2^bits-1 (" + s.maxShares + "), inclusive."
423
+ );
424
+ if (f > s.maxShares)
425
+ throw y = Math.ceil(Math.log(f + 1) / Math.LN2), new Error(
426
+ "Threshold number of shares must be an integer between 2 and 2^bits-1 (" + s.maxShares + "), inclusive. To use a threshold of " + f + ", use at least " + y + " bits."
427
+ );
428
+ if (f > u)
429
+ throw new Error(
430
+ "Threshold number of shares was " + f + " but must be less than or equal to the " + u + " shares specified as the total to generate."
431
+ );
432
+ if (typeof d != "number" || d % 1 !== 0 || d < 0 || d > 1024)
433
+ throw new Error(
434
+ "Zero-pad length must be an integer between 0 and 1024 inclusive."
435
+ );
436
+ for (l = "1" + h(l), l = S(l, d), C = 0, _ = l.length; C < _; C++)
437
+ for (x = g(l[C], u, f), L = 0; L < u; L++)
438
+ v[L] = v[L] || x[L].x.toString(s.radix), I[L] = w(x[L].y.toString(2)) + (I[L] || "");
439
+ for (C = 0; C < u; C++)
440
+ v[C] = E(
441
+ s.bits,
442
+ v[C],
443
+ A(I[C])
444
+ );
445
+ return v;
446
+ },
447
+ // Generate a new share with id `id` (a number between 1 and 2^bits-1)
448
+ // `id` can be a Number or a String in the default radix (16)
449
+ newShare: function(l, u) {
450
+ var f, d;
451
+ if (l && typeof l == "string" && (l = parseInt(l, s.radix)), d = l.toString(s.radix), l && d && u && u[0])
452
+ return f = this.extractShareComponents(u[0]), E(
453
+ f.bits,
454
+ d,
455
+ this.combine(u, l)
456
+ );
457
+ throw new Error(
458
+ "Invalid 'id' or 'shares' Array argument to newShare()."
459
+ );
460
+ },
461
+ /* test-code */
462
+ // export private functions so they can be unit tested directly.
463
+ _reset: i,
464
+ _padLeft: w,
465
+ _hex2bin: h,
466
+ _bin2hex: A,
467
+ _hasCryptoGetRandomValues: N,
468
+ _hasCryptoRandomBytes: R,
469
+ _getRNG: B,
470
+ _isSetRNG: p,
471
+ _splitNumStringToIntArray: S,
472
+ _horner: m,
473
+ _lagrange: b,
474
+ _getShares: g,
475
+ _constructPublicShareString: E
476
+ /* end-test-code */
477
+ };
478
+ return T.init(), T;
479
+ });
480
+ })(we)), we.exports;
481
+ }
482
+ var gr = mr();
483
+ const Et = /* @__PURE__ */ sr(gr), pr = 2, br = 3;
484
+ function wr(t) {
485
+ if (t.length !== 16)
486
+ throw new Error(`Invalid seed length: expected 16, got ${t.length}`);
487
+ const e = vt(t), r = Et.share(e, br, pr);
488
+ if (r.length !== 3)
489
+ throw new Error(`Unexpected share count: ${r.length}`);
490
+ const n = Se(r[0]), s = Se(r[1]), o = Se(r[2]);
491
+ return {
492
+ shareA: Ae(n),
493
+ shareB: Ae(s),
494
+ shareC: Ae(o)
495
+ };
496
+ }
497
+ function Yn(t, e) {
498
+ const r = Qe(t), n = Qe(e);
499
+ try {
500
+ const s = Et.combine([r, n]), o = At(s);
501
+ if (o.length !== 16)
502
+ throw new Error(`Reconstructed seed has wrong length: ${o.length}`);
503
+ return Wt(o);
504
+ } catch {
505
+ throw new Error("Failed to reconstruct seed from shares");
506
+ }
507
+ }
508
+ function vt(t) {
509
+ return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
510
+ }
511
+ function At(t) {
512
+ if (!/^[0-9a-fA-F]*$/.test(t))
513
+ throw new Error("Invalid hex string: contains non-hex characters");
514
+ if (t.length % 2 !== 0)
515
+ throw new Error(`Invalid hex string: length ${t.length} is odd (must be even)`);
516
+ const e = new Uint8Array(t.length / 2);
517
+ for (let r = 0; r < e.length; r++)
518
+ e[r] = parseInt(t.substr(r * 2, 2), 16);
519
+ return e;
520
+ }
521
+ function Se(t) {
522
+ const e = t.length % 2 === 0 ? t : "0" + t;
523
+ return At(e);
524
+ }
525
+ function Qe(t) {
526
+ const e = vt(t);
527
+ return e.startsWith("0") && !e.startsWith("00") ? e.substring(1) : e;
528
+ }
529
+ function yr(t) {
530
+ return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
531
+ }
532
+ function je(t, ...e) {
533
+ if (!yr(t))
534
+ throw new Error("Uint8Array expected");
535
+ if (e.length > 0 && !e.includes(t.length))
536
+ throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
537
+ }
538
+ function Je(t, e = !0) {
539
+ if (t.destroyed)
540
+ throw new Error("Hash instance has been destroyed");
541
+ if (e && t.finished)
542
+ throw new Error("Hash#digest() has already been called");
543
+ }
544
+ function xr(t, e) {
545
+ je(t);
546
+ const r = e.outputLen;
547
+ if (t.length < r)
548
+ throw new Error("digestInto() expects output buffer of length at least " + r);
549
+ }
550
+ function De(...t) {
551
+ for (let e = 0; e < t.length; e++)
552
+ t[e].fill(0);
553
+ }
554
+ function Re(t) {
555
+ return new DataView(t.buffer, t.byteOffset, t.byteLength);
556
+ }
557
+ function W(t, e) {
558
+ return t << 32 - e | t >>> e;
559
+ }
560
+ function Er(t) {
561
+ if (typeof t != "string")
562
+ throw new Error("string expected");
563
+ return new Uint8Array(new TextEncoder().encode(t));
564
+ }
565
+ function Bt(t) {
566
+ return typeof t == "string" && (t = Er(t)), je(t), t;
567
+ }
568
+ class vr {
569
+ }
570
+ function Ar(t) {
571
+ const e = (n) => t().update(Bt(n)).digest(), r = t();
572
+ return e.outputLen = r.outputLen, e.blockLen = r.blockLen, e.create = () => t(), e;
573
+ }
574
+ function Br(t, e, r, n) {
575
+ if (typeof t.setBigUint64 == "function")
576
+ return t.setBigUint64(e, r, n);
577
+ const s = BigInt(32), o = BigInt(4294967295), c = Number(r >> s & o), a = Number(r & o), i = n ? 4 : 0, p = n ? 0 : 4;
578
+ t.setUint32(e + i, c, n), t.setUint32(e + p, a, n);
579
+ }
580
+ function Sr(t, e, r) {
581
+ return t & e ^ ~t & r;
582
+ }
583
+ function Rr(t, e, r) {
584
+ return t & e ^ t & r ^ e & r;
585
+ }
586
+ let Ir = class extends vr {
587
+ constructor(e, r, n, s) {
588
+ super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = e, this.outputLen = r, this.padOffset = n, this.isLE = s, this.buffer = new Uint8Array(e), this.view = Re(this.buffer);
589
+ }
590
+ update(e) {
591
+ Je(this), e = Bt(e), je(e);
592
+ const { view: r, buffer: n, blockLen: s } = this, o = e.length;
593
+ for (let c = 0; c < o; ) {
594
+ const a = Math.min(s - this.pos, o - c);
595
+ if (a === s) {
596
+ const i = Re(e);
597
+ for (; s <= o - c; c += s)
598
+ this.process(i, c);
599
+ continue;
600
+ }
601
+ n.set(e.subarray(c, c + a), this.pos), this.pos += a, c += a, this.pos === s && (this.process(r, 0), this.pos = 0);
602
+ }
603
+ return this.length += e.length, this.roundClean(), this;
604
+ }
605
+ digestInto(e) {
606
+ Je(this), xr(e, this), this.finished = !0;
607
+ const { buffer: r, view: n, blockLen: s, isLE: o } = this;
608
+ let { pos: c } = this;
609
+ r[c++] = 128, De(this.buffer.subarray(c)), this.padOffset > s - c && (this.process(n, 0), c = 0);
610
+ for (let h = c; h < s; h++)
611
+ r[h] = 0;
612
+ Br(n, s - 8, BigInt(this.length * 8), o), this.process(n, 0);
613
+ const a = Re(e), i = this.outputLen;
614
+ if (i % 4)
615
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
616
+ const p = i / 4, w = this.get();
617
+ if (p > w.length)
618
+ throw new Error("_sha2: outputLen bigger than state");
619
+ for (let h = 0; h < p; h++)
620
+ a.setUint32(4 * h, w[h], o);
621
+ }
622
+ digest() {
623
+ const { buffer: e, outputLen: r } = this;
624
+ this.digestInto(e);
625
+ const n = e.slice(0, r);
626
+ return this.destroy(), n;
627
+ }
628
+ _cloneInto(e) {
629
+ e || (e = new this.constructor()), e.set(...this.get());
630
+ const { blockLen: r, buffer: n, length: s, finished: o, destroyed: c, pos: a } = this;
631
+ return e.destroyed = c, e.finished = o, e.length = s, e.pos = a, s % r && e.buffer.set(n), e;
632
+ }
633
+ clone() {
634
+ return this._cloneInto();
635
+ }
636
+ };
637
+ const Q = /* @__PURE__ */ Uint32Array.from([
638
+ 1779033703,
639
+ 3144134277,
640
+ 1013904242,
641
+ 2773480762,
642
+ 1359893119,
643
+ 2600822924,
644
+ 528734635,
645
+ 1541459225
646
+ ]), Nr = /* @__PURE__ */ Uint32Array.from([
647
+ 1116352408,
648
+ 1899447441,
649
+ 3049323471,
650
+ 3921009573,
651
+ 961987163,
652
+ 1508970993,
653
+ 2453635748,
654
+ 2870763221,
655
+ 3624381080,
656
+ 310598401,
657
+ 607225278,
658
+ 1426881987,
659
+ 1925078388,
660
+ 2162078206,
661
+ 2614888103,
662
+ 3248222580,
663
+ 3835390401,
664
+ 4022224774,
665
+ 264347078,
666
+ 604807628,
667
+ 770255983,
668
+ 1249150122,
669
+ 1555081692,
670
+ 1996064986,
671
+ 2554220882,
672
+ 2821834349,
673
+ 2952996808,
674
+ 3210313671,
675
+ 3336571891,
676
+ 3584528711,
677
+ 113926993,
678
+ 338241895,
679
+ 666307205,
680
+ 773529912,
681
+ 1294757372,
682
+ 1396182291,
683
+ 1695183700,
684
+ 1986661051,
685
+ 2177026350,
686
+ 2456956037,
687
+ 2730485921,
688
+ 2820302411,
689
+ 3259730800,
690
+ 3345764771,
691
+ 3516065817,
692
+ 3600352804,
693
+ 4094571909,
694
+ 275423344,
695
+ 430227734,
696
+ 506948616,
697
+ 659060556,
698
+ 883997877,
699
+ 958139571,
700
+ 1322822218,
701
+ 1537002063,
702
+ 1747873779,
703
+ 1955562222,
704
+ 2024104815,
705
+ 2227730452,
706
+ 2361852424,
707
+ 2428436474,
708
+ 2756734187,
709
+ 3204031479,
710
+ 3329325298
711
+ ]), J = /* @__PURE__ */ new Uint32Array(64);
712
+ class kr extends Ir {
713
+ constructor(e = 32) {
714
+ super(64, e, 8, !1), this.A = Q[0] | 0, this.B = Q[1] | 0, this.C = Q[2] | 0, this.D = Q[3] | 0, this.E = Q[4] | 0, this.F = Q[5] | 0, this.G = Q[6] | 0, this.H = Q[7] | 0;
715
+ }
716
+ get() {
717
+ const { A: e, B: r, C: n, D: s, E: o, F: c, G: a, H: i } = this;
718
+ return [e, r, n, s, o, c, a, i];
719
+ }
720
+ // prettier-ignore
721
+ set(e, r, n, s, o, c, a, i) {
722
+ this.A = e | 0, this.B = r | 0, this.C = n | 0, this.D = s | 0, this.E = o | 0, this.F = c | 0, this.G = a | 0, this.H = i | 0;
723
+ }
724
+ process(e, r) {
725
+ for (let h = 0; h < 16; h++, r += 4)
726
+ J[h] = e.getUint32(r, !1);
727
+ for (let h = 16; h < 64; h++) {
728
+ const A = J[h - 15], N = J[h - 2], R = W(A, 7) ^ W(A, 18) ^ A >>> 3, B = W(N, 17) ^ W(N, 19) ^ N >>> 10;
729
+ J[h] = B + J[h - 7] + R + J[h - 16] | 0;
730
+ }
731
+ let { A: n, B: s, C: o, D: c, E: a, F: i, G: p, H: w } = this;
732
+ for (let h = 0; h < 64; h++) {
733
+ const A = W(a, 6) ^ W(a, 11) ^ W(a, 25), N = w + A + Sr(a, i, p) + Nr[h] + J[h] | 0, B = (W(n, 2) ^ W(n, 13) ^ W(n, 22)) + Rr(n, s, o) | 0;
734
+ w = p, p = i, i = a, a = c + N | 0, c = o, o = s, s = n, n = N + B | 0;
735
+ }
736
+ n = n + this.A | 0, s = s + this.B | 0, o = o + this.C | 0, c = c + this.D | 0, a = a + this.E | 0, i = i + this.F | 0, p = p + this.G | 0, w = w + this.H | 0, this.set(n, s, o, c, a, i, p, w);
737
+ }
738
+ roundClean() {
739
+ De(J);
740
+ }
741
+ destroy() {
742
+ this.set(0, 0, 0, 0, 0, 0, 0, 0), De(this.buffer);
743
+ }
744
+ }
745
+ const Cr = /* @__PURE__ */ Ar(() => new kr());
746
+ function St(t) {
747
+ return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
748
+ }
749
+ function Ze(t, e = "") {
750
+ if (!Number.isSafeInteger(t) || t < 0) {
751
+ const r = e && `"${e}" `;
752
+ throw new Error(`${r}expected integer >= 0, got ${t}`);
753
+ }
754
+ }
755
+ function H(t, e, r = "") {
756
+ const n = St(t), s = t?.length, o = e !== void 0;
757
+ if (!n || o && s !== e) {
758
+ const c = r && `"${r}" `, a = o ? ` of length ${e}` : "", i = n ? `length=${s}` : `type=${typeof t}`;
759
+ throw new Error(c + "expected Uint8Array" + a + ", got " + i);
760
+ }
761
+ return t;
762
+ }
763
+ function et(t, e = !0) {
764
+ if (t.destroyed)
765
+ throw new Error("Hash instance has been destroyed");
766
+ if (e && t.finished)
767
+ throw new Error("Hash#digest() has already been called");
768
+ }
769
+ function Lr(t, e) {
770
+ H(t, void 0, "digestInto() output");
771
+ const r = e.outputLen;
772
+ if (t.length < r)
773
+ throw new Error('"digestInto() output" expected to be of length >=' + r);
774
+ }
775
+ function Me(...t) {
776
+ for (let e = 0; e < t.length; e++)
777
+ t[e].fill(0);
778
+ }
779
+ function Ie(t) {
780
+ return new DataView(t.buffer, t.byteOffset, t.byteLength);
781
+ }
782
+ const Rt = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Tr = /* @__PURE__ */ Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0"));
783
+ function Pe(t) {
784
+ if (H(t), Rt)
785
+ return t.toHex();
786
+ let e = "";
787
+ for (let r = 0; r < t.length; r++)
788
+ e += Tr[t[r]];
789
+ return e;
790
+ }
791
+ const X = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
792
+ function tt(t) {
793
+ if (t >= X._0 && t <= X._9)
794
+ return t - X._0;
795
+ if (t >= X.A && t <= X.F)
796
+ return t - (X.A - 10);
797
+ if (t >= X.a && t <= X.f)
798
+ return t - (X.a - 10);
799
+ }
800
+ function It(t) {
801
+ if (typeof t != "string")
802
+ throw new Error("hex string expected, got " + typeof t);
803
+ if (Rt)
804
+ return Uint8Array.fromHex(t);
805
+ const e = t.length, r = e / 2;
806
+ if (e % 2)
807
+ throw new Error("hex string expected, got unpadded hex of length " + e);
808
+ const n = new Uint8Array(r);
809
+ for (let s = 0, o = 0; s < r; s++, o += 2) {
810
+ const c = tt(t.charCodeAt(o)), a = tt(t.charCodeAt(o + 1));
811
+ if (c === void 0 || a === void 0) {
812
+ const i = t[o] + t[o + 1];
813
+ throw new Error('hex string expected, got non-hex character "' + i + '" at index ' + o);
814
+ }
815
+ n[s] = c * 16 + a;
816
+ }
817
+ return n;
818
+ }
819
+ function rt(...t) {
820
+ let e = 0;
821
+ for (let n = 0; n < t.length; n++) {
822
+ const s = t[n];
823
+ H(s), e += s.length;
824
+ }
825
+ const r = new Uint8Array(e);
826
+ for (let n = 0, s = 0; n < t.length; n++) {
827
+ const o = t[n];
828
+ r.set(o, s), s += o.length;
829
+ }
830
+ return r;
831
+ }
832
+ function _r(t, e = {}) {
833
+ const r = (s, o) => t(o).update(s).digest(), n = t(void 0);
834
+ return r.outputLen = n.outputLen, r.blockLen = n.blockLen, r.create = (s) => t(s), Object.assign(r, e), Object.freeze(r);
835
+ }
836
+ function Or(t = 32) {
837
+ const e = typeof globalThis == "object" ? globalThis.crypto : null;
838
+ if (typeof e?.getRandomValues != "function")
839
+ throw new Error("crypto.getRandomValues must be defined");
840
+ return e.getRandomValues(new Uint8Array(t));
841
+ }
842
+ const Ur = (t) => ({
843
+ oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, t])
844
+ });
845
+ class Dr {
846
+ blockLen;
847
+ outputLen;
848
+ padOffset;
849
+ isLE;
850
+ // For partial updates less than block size
851
+ buffer;
852
+ view;
853
+ finished = !1;
854
+ length = 0;
855
+ pos = 0;
856
+ destroyed = !1;
857
+ constructor(e, r, n, s) {
858
+ this.blockLen = e, this.outputLen = r, this.padOffset = n, this.isLE = s, this.buffer = new Uint8Array(e), this.view = Ie(this.buffer);
859
+ }
860
+ update(e) {
861
+ et(this), H(e);
862
+ const { view: r, buffer: n, blockLen: s } = this, o = e.length;
863
+ for (let c = 0; c < o; ) {
864
+ const a = Math.min(s - this.pos, o - c);
865
+ if (a === s) {
866
+ const i = Ie(e);
867
+ for (; s <= o - c; c += s)
868
+ this.process(i, c);
869
+ continue;
870
+ }
871
+ n.set(e.subarray(c, c + a), this.pos), this.pos += a, c += a, this.pos === s && (this.process(r, 0), this.pos = 0);
872
+ }
873
+ return this.length += e.length, this.roundClean(), this;
874
+ }
875
+ digestInto(e) {
876
+ et(this), Lr(e, this), this.finished = !0;
877
+ const { buffer: r, view: n, blockLen: s, isLE: o } = this;
878
+ let { pos: c } = this;
879
+ r[c++] = 128, Me(this.buffer.subarray(c)), this.padOffset > s - c && (this.process(n, 0), c = 0);
880
+ for (let h = c; h < s; h++)
881
+ r[h] = 0;
882
+ n.setBigUint64(s - 8, BigInt(this.length * 8), o), this.process(n, 0);
883
+ const a = Ie(e), i = this.outputLen;
884
+ if (i % 4)
885
+ throw new Error("_sha2: outputLen must be aligned to 32bit");
886
+ const p = i / 4, w = this.get();
887
+ if (p > w.length)
888
+ throw new Error("_sha2: outputLen bigger than state");
889
+ for (let h = 0; h < p; h++)
890
+ a.setUint32(4 * h, w[h], o);
891
+ }
892
+ digest() {
893
+ const { buffer: e, outputLen: r } = this;
894
+ this.digestInto(e);
895
+ const n = e.slice(0, r);
896
+ return this.destroy(), n;
897
+ }
898
+ _cloneInto(e) {
899
+ e ||= new this.constructor(), e.set(...this.get());
900
+ const { blockLen: r, buffer: n, length: s, finished: o, destroyed: c, pos: a } = this;
901
+ return e.destroyed = c, e.finished = o, e.length = s, e.pos = a, s % r && e.buffer.set(n), e;
902
+ }
903
+ clone() {
904
+ return this._cloneInto();
905
+ }
906
+ }
907
+ const G = /* @__PURE__ */ Uint32Array.from([
908
+ 1779033703,
909
+ 4089235720,
910
+ 3144134277,
911
+ 2227873595,
912
+ 1013904242,
913
+ 4271175723,
914
+ 2773480762,
915
+ 1595750129,
916
+ 1359893119,
917
+ 2917565137,
918
+ 2600822924,
919
+ 725511199,
920
+ 528734635,
921
+ 4215389547,
922
+ 1541459225,
923
+ 327033209
924
+ ]), ge = /* @__PURE__ */ BigInt(2 ** 32 - 1), nt = /* @__PURE__ */ BigInt(32);
925
+ function Mr(t, e = !1) {
926
+ return e ? { h: Number(t & ge), l: Number(t >> nt & ge) } : { h: Number(t >> nt & ge) | 0, l: Number(t & ge) | 0 };
927
+ }
928
+ function qr(t, e = !1) {
929
+ const r = t.length;
930
+ let n = new Uint32Array(r), s = new Uint32Array(r);
931
+ for (let o = 0; o < r; o++) {
932
+ const { h: c, l: a } = Mr(t[o], e);
933
+ [n[o], s[o]] = [c, a];
934
+ }
935
+ return [n, s];
936
+ }
937
+ const st = (t, e, r) => t >>> r, ot = (t, e, r) => t << 32 - r | e >>> r, ie = (t, e, r) => t >>> r | e << 32 - r, ae = (t, e, r) => t << 32 - r | e >>> r, pe = (t, e, r) => t << 64 - r | e >>> r - 32, be = (t, e, r) => t >>> r - 32 | e << 64 - r;
938
+ function F(t, e, r, n) {
939
+ const s = (e >>> 0) + (n >>> 0);
940
+ return { h: t + r + (s / 2 ** 32 | 0) | 0, l: s | 0 };
941
+ }
942
+ const Vr = (t, e, r) => (t >>> 0) + (e >>> 0) + (r >>> 0), $r = (t, e, r, n) => e + r + n + (t / 2 ** 32 | 0) | 0, Hr = (t, e, r, n) => (t >>> 0) + (e >>> 0) + (r >>> 0) + (n >>> 0), Gr = (t, e, r, n, s) => e + r + n + s + (t / 2 ** 32 | 0) | 0, jr = (t, e, r, n, s) => (t >>> 0) + (e >>> 0) + (r >>> 0) + (n >>> 0) + (s >>> 0), Zr = (t, e, r, n, s, o) => e + r + n + s + o + (t / 2 ** 32 | 0) | 0, Nt = qr([
943
+ "0x428a2f98d728ae22",
944
+ "0x7137449123ef65cd",
945
+ "0xb5c0fbcfec4d3b2f",
946
+ "0xe9b5dba58189dbbc",
947
+ "0x3956c25bf348b538",
948
+ "0x59f111f1b605d019",
949
+ "0x923f82a4af194f9b",
950
+ "0xab1c5ed5da6d8118",
951
+ "0xd807aa98a3030242",
952
+ "0x12835b0145706fbe",
953
+ "0x243185be4ee4b28c",
954
+ "0x550c7dc3d5ffb4e2",
955
+ "0x72be5d74f27b896f",
956
+ "0x80deb1fe3b1696b1",
957
+ "0x9bdc06a725c71235",
958
+ "0xc19bf174cf692694",
959
+ "0xe49b69c19ef14ad2",
960
+ "0xefbe4786384f25e3",
961
+ "0x0fc19dc68b8cd5b5",
962
+ "0x240ca1cc77ac9c65",
963
+ "0x2de92c6f592b0275",
964
+ "0x4a7484aa6ea6e483",
965
+ "0x5cb0a9dcbd41fbd4",
966
+ "0x76f988da831153b5",
967
+ "0x983e5152ee66dfab",
968
+ "0xa831c66d2db43210",
969
+ "0xb00327c898fb213f",
970
+ "0xbf597fc7beef0ee4",
971
+ "0xc6e00bf33da88fc2",
972
+ "0xd5a79147930aa725",
973
+ "0x06ca6351e003826f",
974
+ "0x142929670a0e6e70",
975
+ "0x27b70a8546d22ffc",
976
+ "0x2e1b21385c26c926",
977
+ "0x4d2c6dfc5ac42aed",
978
+ "0x53380d139d95b3df",
979
+ "0x650a73548baf63de",
980
+ "0x766a0abb3c77b2a8",
981
+ "0x81c2c92e47edaee6",
982
+ "0x92722c851482353b",
983
+ "0xa2bfe8a14cf10364",
984
+ "0xa81a664bbc423001",
985
+ "0xc24b8b70d0f89791",
986
+ "0xc76c51a30654be30",
987
+ "0xd192e819d6ef5218",
988
+ "0xd69906245565a910",
989
+ "0xf40e35855771202a",
990
+ "0x106aa07032bbd1b8",
991
+ "0x19a4c116b8d2d0c8",
992
+ "0x1e376c085141ab53",
993
+ "0x2748774cdf8eeb99",
994
+ "0x34b0bcb5e19b48a8",
995
+ "0x391c0cb3c5c95a63",
996
+ "0x4ed8aa4ae3418acb",
997
+ "0x5b9cca4f7763e373",
998
+ "0x682e6ff3d6b2b8a3",
999
+ "0x748f82ee5defb2fc",
1000
+ "0x78a5636f43172f60",
1001
+ "0x84c87814a1f0ab72",
1002
+ "0x8cc702081a6439ec",
1003
+ "0x90befffa23631e28",
1004
+ "0xa4506cebde82bde9",
1005
+ "0xbef9a3f7b2c67915",
1006
+ "0xc67178f2e372532b",
1007
+ "0xca273eceea26619c",
1008
+ "0xd186b8c721c0c207",
1009
+ "0xeada7dd6cde0eb1e",
1010
+ "0xf57d4f7fee6ed178",
1011
+ "0x06f067aa72176fba",
1012
+ "0x0a637dc5a2c898a6",
1013
+ "0x113f9804bef90dae",
1014
+ "0x1b710b35131c471b",
1015
+ "0x28db77f523047d84",
1016
+ "0x32caab7b40c72493",
1017
+ "0x3c9ebe0a15c9bebc",
1018
+ "0x431d67c49c100d4c",
1019
+ "0x4cc5d4becb3e42b6",
1020
+ "0x597f299cfc657e2a",
1021
+ "0x5fcb6fab3ad6faec",
1022
+ "0x6c44198c4a475817"
1023
+ ].map((t) => BigInt(t))), Pr = Nt[0], zr = Nt[1], ee = /* @__PURE__ */ new Uint32Array(80), te = /* @__PURE__ */ new Uint32Array(80);
1024
+ class Kr extends Dr {
1025
+ constructor(e) {
1026
+ super(128, e, 16, !1);
1027
+ }
1028
+ // prettier-ignore
1029
+ get() {
1030
+ const { Ah: e, Al: r, Bh: n, Bl: s, Ch: o, Cl: c, Dh: a, Dl: i, Eh: p, El: w, Fh: h, Fl: A, Gh: N, Gl: R, Hh: B, Hl: S } = this;
1031
+ return [e, r, n, s, o, c, a, i, p, w, h, A, N, R, B, S];
1032
+ }
1033
+ // prettier-ignore
1034
+ set(e, r, n, s, o, c, a, i, p, w, h, A, N, R, B, S) {
1035
+ this.Ah = e | 0, this.Al = r | 0, this.Bh = n | 0, this.Bl = s | 0, this.Ch = o | 0, this.Cl = c | 0, this.Dh = a | 0, this.Dl = i | 0, this.Eh = p | 0, this.El = w | 0, this.Fh = h | 0, this.Fl = A | 0, this.Gh = N | 0, this.Gl = R | 0, this.Hh = B | 0, this.Hl = S | 0;
1036
+ }
1037
+ process(e, r) {
1038
+ for (let g = 0; g < 16; g++, r += 4)
1039
+ ee[g] = e.getUint32(r), te[g] = e.getUint32(r += 4);
1040
+ for (let g = 16; g < 80; g++) {
1041
+ const E = ee[g - 15] | 0, T = te[g - 15] | 0, l = ie(E, T, 1) ^ ie(E, T, 8) ^ st(E, T, 7), u = ae(E, T, 1) ^ ae(E, T, 8) ^ ot(E, T, 7), f = ee[g - 2] | 0, d = te[g - 2] | 0, y = ie(f, d, 19) ^ pe(f, d, 61) ^ st(f, d, 6), x = ae(f, d, 19) ^ be(f, d, 61) ^ ot(f, d, 6), v = Hr(u, x, te[g - 7], te[g - 16]), I = Gr(v, l, y, ee[g - 7], ee[g - 16]);
1042
+ ee[g] = I | 0, te[g] = v | 0;
1043
+ }
1044
+ let { Ah: n, Al: s, Bh: o, Bl: c, Ch: a, Cl: i, Dh: p, Dl: w, Eh: h, El: A, Fh: N, Fl: R, Gh: B, Gl: S, Hh: m, Hl: b } = this;
1045
+ for (let g = 0; g < 80; g++) {
1046
+ const E = ie(h, A, 14) ^ ie(h, A, 18) ^ pe(h, A, 41), T = ae(h, A, 14) ^ ae(h, A, 18) ^ be(h, A, 41), l = h & N ^ ~h & B, u = A & R ^ ~A & S, f = jr(b, T, u, zr[g], te[g]), d = Zr(f, m, E, l, Pr[g], ee[g]), y = f | 0, x = ie(n, s, 28) ^ pe(n, s, 34) ^ pe(n, s, 39), v = ae(n, s, 28) ^ be(n, s, 34) ^ be(n, s, 39), I = n & o ^ n & a ^ o & a, C = s & c ^ s & i ^ c & i;
1047
+ m = B | 0, b = S | 0, B = N | 0, S = R | 0, N = h | 0, R = A | 0, { h, l: A } = F(p | 0, w | 0, d | 0, y | 0), p = a | 0, w = i | 0, a = o | 0, i = c | 0, o = n | 0, c = s | 0;
1048
+ const L = Vr(y, v, C);
1049
+ n = $r(L, d, x, I), s = L | 0;
1050
+ }
1051
+ ({ h: n, l: s } = F(this.Ah | 0, this.Al | 0, n | 0, s | 0)), { h: o, l: c } = F(this.Bh | 0, this.Bl | 0, o | 0, c | 0), { h: a, l: i } = F(this.Ch | 0, this.Cl | 0, a | 0, i | 0), { h: p, l: w } = F(this.Dh | 0, this.Dl | 0, p | 0, w | 0), { h, l: A } = F(this.Eh | 0, this.El | 0, h | 0, A | 0), { h: N, l: R } = F(this.Fh | 0, this.Fl | 0, N | 0, R | 0), { h: B, l: S } = F(this.Gh | 0, this.Gl | 0, B | 0, S | 0), { h: m, l: b } = F(this.Hh | 0, this.Hl | 0, m | 0, b | 0), this.set(n, s, o, c, a, i, p, w, h, A, N, R, B, S, m, b);
1052
+ }
1053
+ roundClean() {
1054
+ Me(ee, te);
1055
+ }
1056
+ destroy() {
1057
+ Me(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1058
+ }
1059
+ }
1060
+ class Wr extends Kr {
1061
+ Ah = G[0] | 0;
1062
+ Al = G[1] | 0;
1063
+ Bh = G[2] | 0;
1064
+ Bl = G[3] | 0;
1065
+ Ch = G[4] | 0;
1066
+ Cl = G[5] | 0;
1067
+ Dh = G[6] | 0;
1068
+ Dl = G[7] | 0;
1069
+ Eh = G[8] | 0;
1070
+ El = G[9] | 0;
1071
+ Fh = G[10] | 0;
1072
+ Fl = G[11] | 0;
1073
+ Gh = G[12] | 0;
1074
+ Gl = G[13] | 0;
1075
+ Hh = G[14] | 0;
1076
+ Hl = G[15] | 0;
1077
+ constructor() {
1078
+ super(64);
1079
+ }
1080
+ }
1081
+ const Yr = /* @__PURE__ */ _r(
1082
+ () => new Wr(),
1083
+ /* @__PURE__ */ Ur(3)
1084
+ );
1085
+ const kt = /* @__PURE__ */ BigInt(0), it = /* @__PURE__ */ BigInt(1);
1086
+ function qe(t, e = "") {
1087
+ if (typeof t != "boolean") {
1088
+ const r = e && `"${e}" `;
1089
+ throw new Error(r + "expected boolean, got type=" + typeof t);
1090
+ }
1091
+ return t;
1092
+ }
1093
+ function Xr(t) {
1094
+ if (typeof t == "bigint") {
1095
+ if (!ye(t))
1096
+ throw new Error("positive bigint expected, got " + t);
1097
+ } else
1098
+ Ze(t);
1099
+ return t;
1100
+ }
1101
+ function Ct(t) {
1102
+ if (typeof t != "string")
1103
+ throw new Error("hex string expected, got " + typeof t);
1104
+ return t === "" ? kt : BigInt("0x" + t);
1105
+ }
1106
+ function Fr(t) {
1107
+ return Ct(Pe(t));
1108
+ }
1109
+ function xe(t) {
1110
+ return Ct(Pe(Ve(H(t)).reverse()));
1111
+ }
1112
+ function Lt(t, e) {
1113
+ Ze(e), t = Xr(t);
1114
+ const r = It(t.toString(16).padStart(e * 2, "0"));
1115
+ if (r.length !== e)
1116
+ throw new Error("number too large");
1117
+ return r;
1118
+ }
1119
+ function Qr(t, e) {
1120
+ return Lt(t, e).reverse();
1121
+ }
1122
+ function Ve(t) {
1123
+ return Uint8Array.from(t);
1124
+ }
1125
+ const ye = (t) => typeof t == "bigint" && kt <= t;
1126
+ function Jr(t, e, r) {
1127
+ return ye(t) && ye(e) && ye(r) && e <= t && t < r;
1128
+ }
1129
+ function at(t, e, r, n) {
1130
+ if (!Jr(e, r, n))
1131
+ throw new Error("expected valid " + t + ": " + r + " <= n < " + n + ", got " + e);
1132
+ }
1133
+ const en = (t) => (it << BigInt(t)) - it;
1134
+ function ze(t, e = {}, r = {}) {
1135
+ if (!t || typeof t != "object")
1136
+ throw new Error("expected valid options object");
1137
+ function n(o, c, a) {
1138
+ const i = t[o];
1139
+ if (a && i === void 0)
1140
+ return;
1141
+ const p = typeof i;
1142
+ if (p !== c || i === null)
1143
+ throw new Error(`param "${o}" is invalid: expected ${c}, got ${p}`);
1144
+ }
1145
+ const s = (o, c) => Object.entries(o).forEach(([a, i]) => n(a, i, c));
1146
+ s(e, !1), s(r, !0);
1147
+ }
1148
+ function ct(t) {
1149
+ const e = /* @__PURE__ */ new WeakMap();
1150
+ return (r, ...n) => {
1151
+ const s = e.get(r);
1152
+ if (s !== void 0)
1153
+ return s;
1154
+ const o = t(r, ...n);
1155
+ return e.set(r, o), o;
1156
+ };
1157
+ }
1158
+ const Z = /* @__PURE__ */ BigInt(0), j = /* @__PURE__ */ BigInt(1), se = /* @__PURE__ */ BigInt(2), Tt = /* @__PURE__ */ BigInt(3), _t = /* @__PURE__ */ BigInt(4), Ot = /* @__PURE__ */ BigInt(5), tn = /* @__PURE__ */ BigInt(7), Ut = /* @__PURE__ */ BigInt(8), rn = /* @__PURE__ */ BigInt(9), Dt = /* @__PURE__ */ BigInt(16);
1159
+ function q(t, e) {
1160
+ const r = t % e;
1161
+ return r >= Z ? r : e + r;
1162
+ }
1163
+ function Y(t, e, r) {
1164
+ let n = t;
1165
+ for (; e-- > Z; )
1166
+ n *= n, n %= r;
1167
+ return n;
1168
+ }
1169
+ function lt(t, e) {
1170
+ if (t === Z)
1171
+ throw new Error("invert: expected non-zero number");
1172
+ if (e <= Z)
1173
+ throw new Error("invert: expected positive modulus, got " + e);
1174
+ let r = q(t, e), n = e, s = Z, o = j;
1175
+ for (; r !== Z; ) {
1176
+ const a = n / r, i = n % r, p = s - o * a;
1177
+ n = r, r = i, s = o, o = p;
1178
+ }
1179
+ if (n !== j)
1180
+ throw new Error("invert: does not exist");
1181
+ return q(s, e);
1182
+ }
1183
+ function Ke(t, e, r) {
1184
+ if (!t.eql(t.sqr(e), r))
1185
+ throw new Error("Cannot find square root");
1186
+ }
1187
+ function Mt(t, e) {
1188
+ const r = (t.ORDER + j) / _t, n = t.pow(e, r);
1189
+ return Ke(t, n, e), n;
1190
+ }
1191
+ function nn(t, e) {
1192
+ const r = (t.ORDER - Ot) / Ut, n = t.mul(e, se), s = t.pow(n, r), o = t.mul(e, s), c = t.mul(t.mul(o, se), s), a = t.mul(o, t.sub(c, t.ONE));
1193
+ return Ke(t, a, e), a;
1194
+ }
1195
+ function sn(t) {
1196
+ const e = We(t), r = qt(t), n = r(e, e.neg(e.ONE)), s = r(e, n), o = r(e, e.neg(n)), c = (t + tn) / Dt;
1197
+ return (a, i) => {
1198
+ let p = a.pow(i, c), w = a.mul(p, n);
1199
+ const h = a.mul(p, s), A = a.mul(p, o), N = a.eql(a.sqr(w), i), R = a.eql(a.sqr(h), i);
1200
+ p = a.cmov(p, w, N), w = a.cmov(A, h, R);
1201
+ const B = a.eql(a.sqr(w), i), S = a.cmov(p, w, B);
1202
+ return Ke(a, S, i), S;
1203
+ };
1204
+ }
1205
+ function qt(t) {
1206
+ if (t < Tt)
1207
+ throw new Error("sqrt is not defined for small field");
1208
+ let e = t - j, r = 0;
1209
+ for (; e % se === Z; )
1210
+ e /= se, r++;
1211
+ let n = se;
1212
+ const s = We(t);
1213
+ for (; ft(s, n) === 1; )
1214
+ if (n++ > 1e3)
1215
+ throw new Error("Cannot find square root: probably non-prime P");
1216
+ if (r === 1)
1217
+ return Mt;
1218
+ let o = s.pow(n, e);
1219
+ const c = (e + j) / se;
1220
+ return function(i, p) {
1221
+ if (i.is0(p))
1222
+ return p;
1223
+ if (ft(i, p) !== 1)
1224
+ throw new Error("Cannot find square root");
1225
+ let w = r, h = i.mul(i.ONE, o), A = i.pow(p, e), N = i.pow(p, c);
1226
+ for (; !i.eql(A, i.ONE); ) {
1227
+ if (i.is0(A))
1228
+ return i.ZERO;
1229
+ let R = 1, B = i.sqr(A);
1230
+ for (; !i.eql(B, i.ONE); )
1231
+ if (R++, B = i.sqr(B), R === w)
1232
+ throw new Error("Cannot find square root");
1233
+ const S = j << BigInt(w - R - 1), m = i.pow(h, S);
1234
+ w = R, h = i.sqr(m), A = i.mul(A, h), N = i.mul(N, m);
1235
+ }
1236
+ return N;
1237
+ };
1238
+ }
1239
+ function on(t) {
1240
+ return t % _t === Tt ? Mt : t % Ut === Ot ? nn : t % Dt === rn ? sn(t) : qt(t);
1241
+ }
1242
+ const an = (t, e) => (q(t, e) & j) === j, cn = [
1243
+ "create",
1244
+ "isValid",
1245
+ "is0",
1246
+ "neg",
1247
+ "inv",
1248
+ "sqrt",
1249
+ "sqr",
1250
+ "eql",
1251
+ "add",
1252
+ "sub",
1253
+ "mul",
1254
+ "pow",
1255
+ "div",
1256
+ "addN",
1257
+ "subN",
1258
+ "mulN",
1259
+ "sqrN"
1260
+ ];
1261
+ function ln(t) {
1262
+ const e = {
1263
+ ORDER: "bigint",
1264
+ BYTES: "number",
1265
+ BITS: "number"
1266
+ }, r = cn.reduce((n, s) => (n[s] = "function", n), e);
1267
+ return ze(t, r), t;
1268
+ }
1269
+ function fn(t, e, r) {
1270
+ if (r < Z)
1271
+ throw new Error("invalid exponent, negatives unsupported");
1272
+ if (r === Z)
1273
+ return t.ONE;
1274
+ if (r === j)
1275
+ return e;
1276
+ let n = t.ONE, s = e;
1277
+ for (; r > Z; )
1278
+ r & j && (n = t.mul(n, s)), s = t.sqr(s), r >>= j;
1279
+ return n;
1280
+ }
1281
+ function Vt(t, e, r = !1) {
1282
+ const n = new Array(e.length).fill(r ? t.ZERO : void 0), s = e.reduce((c, a, i) => t.is0(a) ? c : (n[i] = c, t.mul(c, a)), t.ONE), o = t.inv(s);
1283
+ return e.reduceRight((c, a, i) => t.is0(a) ? c : (n[i] = t.mul(c, n[i]), t.mul(c, a)), o), n;
1284
+ }
1285
+ function ft(t, e) {
1286
+ const r = (t.ORDER - j) / se, n = t.pow(e, r), s = t.eql(n, t.ONE), o = t.eql(n, t.ZERO), c = t.eql(n, t.neg(t.ONE));
1287
+ if (!s && !o && !c)
1288
+ throw new Error("invalid Legendre symbol result");
1289
+ return s ? 1 : o ? 0 : -1;
1290
+ }
1291
+ function un(t, e) {
1292
+ e !== void 0 && Ze(e);
1293
+ const r = e !== void 0 ? e : t.toString(2).length, n = Math.ceil(r / 8);
1294
+ return { nBitLength: r, nByteLength: n };
1295
+ }
1296
+ class dn {
1297
+ ORDER;
1298
+ BITS;
1299
+ BYTES;
1300
+ isLE;
1301
+ ZERO = Z;
1302
+ ONE = j;
1303
+ _lengths;
1304
+ _sqrt;
1305
+ // cached sqrt
1306
+ _mod;
1307
+ constructor(e, r = {}) {
1308
+ if (e <= Z)
1309
+ throw new Error("invalid field: expected ORDER > 0, got " + e);
1310
+ let n;
1311
+ this.isLE = !1, r != null && typeof r == "object" && (typeof r.BITS == "number" && (n = r.BITS), typeof r.sqrt == "function" && (this.sqrt = r.sqrt), typeof r.isLE == "boolean" && (this.isLE = r.isLE), r.allowedLengths && (this._lengths = r.allowedLengths?.slice()), typeof r.modFromBytes == "boolean" && (this._mod = r.modFromBytes));
1312
+ const { nBitLength: s, nByteLength: o } = un(e, n);
1313
+ if (o > 2048)
1314
+ throw new Error("invalid field: expected ORDER of <= 2048 bytes");
1315
+ this.ORDER = e, this.BITS = s, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
1316
+ }
1317
+ create(e) {
1318
+ return q(e, this.ORDER);
1319
+ }
1320
+ isValid(e) {
1321
+ if (typeof e != "bigint")
1322
+ throw new Error("invalid field element: expected bigint, got " + typeof e);
1323
+ return Z <= e && e < this.ORDER;
1324
+ }
1325
+ is0(e) {
1326
+ return e === Z;
1327
+ }
1328
+ // is valid and invertible
1329
+ isValidNot0(e) {
1330
+ return !this.is0(e) && this.isValid(e);
1331
+ }
1332
+ isOdd(e) {
1333
+ return (e & j) === j;
1334
+ }
1335
+ neg(e) {
1336
+ return q(-e, this.ORDER);
1337
+ }
1338
+ eql(e, r) {
1339
+ return e === r;
1340
+ }
1341
+ sqr(e) {
1342
+ return q(e * e, this.ORDER);
1343
+ }
1344
+ add(e, r) {
1345
+ return q(e + r, this.ORDER);
1346
+ }
1347
+ sub(e, r) {
1348
+ return q(e - r, this.ORDER);
1349
+ }
1350
+ mul(e, r) {
1351
+ return q(e * r, this.ORDER);
1352
+ }
1353
+ pow(e, r) {
1354
+ return fn(this, e, r);
1355
+ }
1356
+ div(e, r) {
1357
+ return q(e * lt(r, this.ORDER), this.ORDER);
1358
+ }
1359
+ // Same as above, but doesn't normalize
1360
+ sqrN(e) {
1361
+ return e * e;
1362
+ }
1363
+ addN(e, r) {
1364
+ return e + r;
1365
+ }
1366
+ subN(e, r) {
1367
+ return e - r;
1368
+ }
1369
+ mulN(e, r) {
1370
+ return e * r;
1371
+ }
1372
+ inv(e) {
1373
+ return lt(e, this.ORDER);
1374
+ }
1375
+ sqrt(e) {
1376
+ return this._sqrt || (this._sqrt = on(this.ORDER)), this._sqrt(this, e);
1377
+ }
1378
+ toBytes(e) {
1379
+ return this.isLE ? Qr(e, this.BYTES) : Lt(e, this.BYTES);
1380
+ }
1381
+ fromBytes(e, r = !1) {
1382
+ H(e);
1383
+ const { _lengths: n, BYTES: s, isLE: o, ORDER: c, _mod: a } = this;
1384
+ if (n) {
1385
+ if (!n.includes(e.length) || e.length > s)
1386
+ throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
1387
+ const p = new Uint8Array(s);
1388
+ p.set(e, o ? 0 : p.length - e.length), e = p;
1389
+ }
1390
+ if (e.length !== s)
1391
+ throw new Error("Field.fromBytes: expected " + s + " bytes, got " + e.length);
1392
+ let i = o ? xe(e) : Fr(e);
1393
+ if (a && (i = q(i, c)), !r && !this.isValid(i))
1394
+ throw new Error("invalid field element: outside of range 0..ORDER");
1395
+ return i;
1396
+ }
1397
+ // TODO: we don't need it here, move out to separate fn
1398
+ invertBatch(e) {
1399
+ return Vt(this, e);
1400
+ }
1401
+ // We can't move this out because Fp6, Fp12 implement it
1402
+ // and it's unclear what to return in there.
1403
+ cmov(e, r, n) {
1404
+ return n ? r : e;
1405
+ }
1406
+ }
1407
+ function We(t, e = {}) {
1408
+ return new dn(t, e);
1409
+ }
1410
+ const Ee = /* @__PURE__ */ BigInt(0), $e = /* @__PURE__ */ BigInt(1);
1411
+ function ut(t, e) {
1412
+ const r = e.negate();
1413
+ return t ? r : e;
1414
+ }
1415
+ function Ne(t, e) {
1416
+ const r = Vt(t.Fp, e.map((n) => n.Z));
1417
+ return e.map((n, s) => t.fromAffine(n.toAffine(r[s])));
1418
+ }
1419
+ function $t(t, e) {
1420
+ if (!Number.isSafeInteger(t) || t <= 0 || t > e)
1421
+ throw new Error("invalid window size, expected [1.." + e + "], got W=" + t);
1422
+ }
1423
+ function ke(t, e) {
1424
+ $t(t, e);
1425
+ const r = Math.ceil(e / t) + 1, n = 2 ** (t - 1), s = 2 ** t, o = en(t), c = BigInt(t);
1426
+ return { windows: r, windowSize: n, mask: o, maxNumber: s, shiftBy: c };
1427
+ }
1428
+ function dt(t, e, r) {
1429
+ const { windowSize: n, mask: s, maxNumber: o, shiftBy: c } = r;
1430
+ let a = Number(t & s), i = t >> c;
1431
+ a > n && (a -= o, i += $e);
1432
+ const p = e * n, w = p + Math.abs(a) - 1, h = a === 0, A = a < 0, N = e % 2 !== 0;
1433
+ return { nextN: i, offset: w, isZero: h, isNeg: A, isNegF: N, offsetF: p };
1434
+ }
1435
+ const Ce = /* @__PURE__ */ new WeakMap(), Ht = /* @__PURE__ */ new WeakMap();
1436
+ function Le(t) {
1437
+ return Ht.get(t) || 1;
1438
+ }
1439
+ function ht(t) {
1440
+ if (t !== Ee)
1441
+ throw new Error("invalid wNAF");
1442
+ }
1443
+ class hn {
1444
+ BASE;
1445
+ ZERO;
1446
+ Fn;
1447
+ bits;
1448
+ // Parametrized with a given Point class (not individual point)
1449
+ constructor(e, r) {
1450
+ this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = r;
1451
+ }
1452
+ // non-const time multiplication ladder
1453
+ _unsafeLadder(e, r, n = this.ZERO) {
1454
+ let s = e;
1455
+ for (; r > Ee; )
1456
+ r & $e && (n = n.add(s)), s = s.double(), r >>= $e;
1457
+ return n;
1458
+ }
1459
+ /**
1460
+ * Creates a wNAF precomputation window. Used for caching.
1461
+ * Default window size is set by `utils.precompute()` and is equal to 8.
1462
+ * Number of precomputed points depends on the curve size:
1463
+ * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
1464
+ * - 𝑊 is the window size
1465
+ * - 𝑛 is the bitlength of the curve order.
1466
+ * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
1467
+ * @param point Point instance
1468
+ * @param W window size
1469
+ * @returns precomputed point tables flattened to a single array
1470
+ */
1471
+ precomputeWindow(e, r) {
1472
+ const { windows: n, windowSize: s } = ke(r, this.bits), o = [];
1473
+ let c = e, a = c;
1474
+ for (let i = 0; i < n; i++) {
1475
+ a = c, o.push(a);
1476
+ for (let p = 1; p < s; p++)
1477
+ a = a.add(c), o.push(a);
1478
+ c = a.double();
1479
+ }
1480
+ return o;
1481
+ }
1482
+ /**
1483
+ * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
1484
+ * More compact implementation:
1485
+ * https://github.com/paulmillr/noble-secp256k1/blob/47cb1669b6e506ad66b35fe7d76132ae97465da2/index.ts#L502-L541
1486
+ * @returns real and fake (for const-time) points
1487
+ */
1488
+ wNAF(e, r, n) {
1489
+ if (!this.Fn.isValid(n))
1490
+ throw new Error("invalid scalar");
1491
+ let s = this.ZERO, o = this.BASE;
1492
+ const c = ke(e, this.bits);
1493
+ for (let a = 0; a < c.windows; a++) {
1494
+ const { nextN: i, offset: p, isZero: w, isNeg: h, isNegF: A, offsetF: N } = dt(n, a, c);
1495
+ n = i, w ? o = o.add(ut(A, r[N])) : s = s.add(ut(h, r[p]));
1496
+ }
1497
+ return ht(n), { p: s, f: o };
1498
+ }
1499
+ /**
1500
+ * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
1501
+ * @param acc accumulator point to add result of multiplication
1502
+ * @returns point
1503
+ */
1504
+ wNAFUnsafe(e, r, n, s = this.ZERO) {
1505
+ const o = ke(e, this.bits);
1506
+ for (let c = 0; c < o.windows && n !== Ee; c++) {
1507
+ const { nextN: a, offset: i, isZero: p, isNeg: w } = dt(n, c, o);
1508
+ if (n = a, !p) {
1509
+ const h = r[i];
1510
+ s = s.add(w ? h.negate() : h);
1511
+ }
1512
+ }
1513
+ return ht(n), s;
1514
+ }
1515
+ getPrecomputes(e, r, n) {
1516
+ let s = Ce.get(r);
1517
+ return s || (s = this.precomputeWindow(r, e), e !== 1 && (typeof n == "function" && (s = n(s)), Ce.set(r, s))), s;
1518
+ }
1519
+ cached(e, r, n) {
1520
+ const s = Le(e);
1521
+ return this.wNAF(s, this.getPrecomputes(s, e, n), r);
1522
+ }
1523
+ unsafe(e, r, n, s) {
1524
+ const o = Le(e);
1525
+ return o === 1 ? this._unsafeLadder(e, r, s) : this.wNAFUnsafe(o, this.getPrecomputes(o, e, n), r, s);
1526
+ }
1527
+ // We calculate precomputes for elliptic curve point multiplication
1528
+ // using windowed method. This specifies window size and
1529
+ // stores precomputed values. Usually only base point would be precomputed.
1530
+ createCache(e, r) {
1531
+ $t(r, this.bits), Ht.set(e, r), Ce.delete(e);
1532
+ }
1533
+ hasCache(e) {
1534
+ return Le(e) !== 1;
1535
+ }
1536
+ }
1537
+ function mt(t, e, r) {
1538
+ if (e) {
1539
+ if (e.ORDER !== t)
1540
+ throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
1541
+ return ln(e), e;
1542
+ } else
1543
+ return We(t, { isLE: r });
1544
+ }
1545
+ function mn(t, e, r = {}, n) {
1546
+ if (n === void 0 && (n = t === "edwards"), !e || typeof e != "object")
1547
+ throw new Error(`expected valid ${t} CURVE object`);
1548
+ for (const i of ["p", "n", "h"]) {
1549
+ const p = e[i];
1550
+ if (!(typeof p == "bigint" && p > Ee))
1551
+ throw new Error(`CURVE.${i} must be positive bigint`);
1552
+ }
1553
+ const s = mt(e.p, r.Fp, n), o = mt(e.n, r.Fn, n), a = ["Gx", "Gy", "a", "d"];
1554
+ for (const i of a)
1555
+ if (!s.isValid(e[i]))
1556
+ throw new Error(`CURVE.${i} must be valid field element of CURVE.Fp`);
1557
+ return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: s, Fn: o };
1558
+ }
1559
+ function gn(t, e) {
1560
+ return function(n) {
1561
+ const s = t(n);
1562
+ return { secretKey: s, publicKey: e(s) };
1563
+ };
1564
+ }
1565
+ const re = BigInt(0), $ = BigInt(1), Te = BigInt(2), pn = BigInt(8);
1566
+ function bn(t, e, r, n) {
1567
+ const s = t.sqr(r), o = t.sqr(n), c = t.add(t.mul(e.a, s), o), a = t.add(t.ONE, t.mul(e.d, t.mul(s, o)));
1568
+ return t.eql(c, a);
1569
+ }
1570
+ function wn(t, e = {}) {
1571
+ const r = mn("edwards", t, e, e.FpFnLE), { Fp: n, Fn: s } = r;
1572
+ let o = r.CURVE;
1573
+ const { h: c } = o;
1574
+ ze(e, {}, { uvRatio: "function" });
1575
+ const a = Te << BigInt(s.BYTES * 8) - $, i = (S) => n.create(S), p = e.uvRatio || ((S, m) => {
1576
+ try {
1577
+ return { isValid: !0, value: n.sqrt(n.div(S, m)) };
1578
+ } catch {
1579
+ return { isValid: !1, value: re };
1580
+ }
1581
+ });
1582
+ if (!bn(n, o, o.Gx, o.Gy))
1583
+ throw new Error("bad curve params: generator point");
1584
+ function w(S, m, b = !1) {
1585
+ const g = b ? $ : re;
1586
+ return at("coordinate " + S, m, g, a), m;
1587
+ }
1588
+ function h(S) {
1589
+ if (!(S instanceof R))
1590
+ throw new Error("EdwardsPoint expected");
1591
+ }
1592
+ const A = ct((S, m) => {
1593
+ const { X: b, Y: g, Z: E } = S, T = S.is0();
1594
+ m == null && (m = T ? pn : n.inv(E));
1595
+ const l = i(b * m), u = i(g * m), f = n.mul(E, m);
1596
+ if (T)
1597
+ return { x: re, y: $ };
1598
+ if (f !== $)
1599
+ throw new Error("invZ was invalid");
1600
+ return { x: l, y: u };
1601
+ }), N = ct((S) => {
1602
+ const { a: m, d: b } = o;
1603
+ if (S.is0())
1604
+ throw new Error("bad point: ZERO");
1605
+ const { X: g, Y: E, Z: T, T: l } = S, u = i(g * g), f = i(E * E), d = i(T * T), y = i(d * d), x = i(u * m), v = i(d * i(x + f)), I = i(y + i(b * i(u * f)));
1606
+ if (v !== I)
1607
+ throw new Error("bad point: equation left != right (1)");
1608
+ const C = i(g * E), L = i(T * l);
1609
+ if (C !== L)
1610
+ throw new Error("bad point: equation left != right (2)");
1611
+ return !0;
1612
+ });
1613
+ class R {
1614
+ // base / generator point
1615
+ static BASE = new R(o.Gx, o.Gy, $, i(o.Gx * o.Gy));
1616
+ // zero / infinity / identity point
1617
+ static ZERO = new R(re, $, $, re);
1618
+ // 0, 1, 1, 0
1619
+ // math field
1620
+ static Fp = n;
1621
+ // scalar field
1622
+ static Fn = s;
1623
+ X;
1624
+ Y;
1625
+ Z;
1626
+ T;
1627
+ constructor(m, b, g, E) {
1628
+ this.X = w("x", m), this.Y = w("y", b), this.Z = w("z", g, !0), this.T = w("t", E), Object.freeze(this);
1629
+ }
1630
+ static CURVE() {
1631
+ return o;
1632
+ }
1633
+ static fromAffine(m) {
1634
+ if (m instanceof R)
1635
+ throw new Error("extended point not allowed");
1636
+ const { x: b, y: g } = m || {};
1637
+ return w("x", b), w("y", g), new R(b, g, $, i(b * g));
1638
+ }
1639
+ // Uses algo from RFC8032 5.1.3.
1640
+ static fromBytes(m, b = !1) {
1641
+ const g = n.BYTES, { a: E, d: T } = o;
1642
+ m = Ve(H(m, g, "point")), qe(b, "zip215");
1643
+ const l = Ve(m), u = m[g - 1];
1644
+ l[g - 1] = u & -129;
1645
+ const f = xe(l), d = b ? a : n.ORDER;
1646
+ at("point.y", f, re, d);
1647
+ const y = i(f * f), x = i(y - $), v = i(T * y - E);
1648
+ let { isValid: I, value: C } = p(x, v);
1649
+ if (!I)
1650
+ throw new Error("bad point: invalid y coordinate");
1651
+ const L = (C & $) === $, _ = (u & 128) !== 0;
1652
+ if (!b && C === re && _)
1653
+ throw new Error("bad point: x=0 and x_0=1");
1654
+ return _ !== L && (C = i(-C)), R.fromAffine({ x: C, y: f });
1655
+ }
1656
+ static fromHex(m, b = !1) {
1657
+ return R.fromBytes(It(m), b);
1658
+ }
1659
+ get x() {
1660
+ return this.toAffine().x;
1661
+ }
1662
+ get y() {
1663
+ return this.toAffine().y;
1664
+ }
1665
+ precompute(m = 8, b = !0) {
1666
+ return B.createCache(this, m), b || this.multiply(Te), this;
1667
+ }
1668
+ // Useful in fromAffine() - not for fromBytes(), which always created valid points.
1669
+ assertValidity() {
1670
+ N(this);
1671
+ }
1672
+ // Compare one point to another.
1673
+ equals(m) {
1674
+ h(m);
1675
+ const { X: b, Y: g, Z: E } = this, { X: T, Y: l, Z: u } = m, f = i(b * u), d = i(T * E), y = i(g * u), x = i(l * E);
1676
+ return f === d && y === x;
1677
+ }
1678
+ is0() {
1679
+ return this.equals(R.ZERO);
1680
+ }
1681
+ negate() {
1682
+ return new R(i(-this.X), this.Y, this.Z, i(-this.T));
1683
+ }
1684
+ // Fast algo for doubling Extended Point.
1685
+ // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd
1686
+ // Cost: 4M + 4S + 1*a + 6add + 1*2.
1687
+ double() {
1688
+ const { a: m } = o, { X: b, Y: g, Z: E } = this, T = i(b * b), l = i(g * g), u = i(Te * i(E * E)), f = i(m * T), d = b + g, y = i(i(d * d) - T - l), x = f + l, v = x - u, I = f - l, C = i(y * v), L = i(x * I), _ = i(y * I), U = i(v * x);
1689
+ return new R(C, L, U, _);
1690
+ }
1691
+ // Fast algo for adding 2 Extended Points.
1692
+ // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
1693
+ // Cost: 9M + 1*a + 1*d + 7add.
1694
+ add(m) {
1695
+ h(m);
1696
+ const { a: b, d: g } = o, { X: E, Y: T, Z: l, T: u } = this, { X: f, Y: d, Z: y, T: x } = m, v = i(E * f), I = i(T * d), C = i(u * g * x), L = i(l * y), _ = i((E + T) * (f + d) - v - I), U = L - C, V = L + C, z = i(I - b * v), oe = i(_ * U), he = i(V * z), ce = i(_ * z), me = i(U * V);
1697
+ return new R(oe, he, me, ce);
1698
+ }
1699
+ subtract(m) {
1700
+ return this.add(m.negate());
1701
+ }
1702
+ // Constant-time multiplication.
1703
+ multiply(m) {
1704
+ if (!s.isValidNot0(m))
1705
+ throw new Error("invalid scalar: expected 1 <= sc < curve.n");
1706
+ const { p: b, f: g } = B.cached(this, m, (E) => Ne(R, E));
1707
+ return Ne(R, [b, g])[0];
1708
+ }
1709
+ // Non-constant-time multiplication. Uses double-and-add algorithm.
1710
+ // It's faster, but should only be used when you don't care about
1711
+ // an exposed private key e.g. sig verification.
1712
+ // Does NOT allow scalars higher than CURVE.n.
1713
+ // Accepts optional accumulator to merge with multiply (important for sparse scalars)
1714
+ multiplyUnsafe(m, b = R.ZERO) {
1715
+ if (!s.isValid(m))
1716
+ throw new Error("invalid scalar: expected 0 <= sc < curve.n");
1717
+ return m === re ? R.ZERO : this.is0() || m === $ ? this : B.unsafe(this, m, (g) => Ne(R, g), b);
1718
+ }
1719
+ // Checks if point is of small order.
1720
+ // If you add something to small order point, you will have "dirty"
1721
+ // point with torsion component.
1722
+ // Multiplies point by cofactor and checks if the result is 0.
1723
+ isSmallOrder() {
1724
+ return this.multiplyUnsafe(c).is0();
1725
+ }
1726
+ // Multiplies point by curve order and checks if the result is 0.
1727
+ // Returns `false` is the point is dirty.
1728
+ isTorsionFree() {
1729
+ return B.unsafe(this, o.n).is0();
1730
+ }
1731
+ // Converts Extended point to default (x, y) coordinates.
1732
+ // Can accept precomputed Z^-1 - for example, from invertBatch.
1733
+ toAffine(m) {
1734
+ return A(this, m);
1735
+ }
1736
+ clearCofactor() {
1737
+ return c === $ ? this : this.multiplyUnsafe(c);
1738
+ }
1739
+ toBytes() {
1740
+ const { x: m, y: b } = this.toAffine(), g = n.toBytes(b);
1741
+ return g[g.length - 1] |= m & $ ? 128 : 0, g;
1742
+ }
1743
+ toHex() {
1744
+ return Pe(this.toBytes());
1745
+ }
1746
+ toString() {
1747
+ return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
1748
+ }
1749
+ }
1750
+ const B = new hn(R, s.BITS);
1751
+ return R.BASE.precompute(8), R;
1752
+ }
1753
+ function yn(t, e, r = {}) {
1754
+ if (typeof e != "function")
1755
+ throw new Error('"hash" function param is required');
1756
+ ze(r, {}, {
1757
+ adjustScalarBytes: "function",
1758
+ randomBytes: "function",
1759
+ domain: "function",
1760
+ prehash: "function",
1761
+ mapToCurve: "function"
1762
+ });
1763
+ const { prehash: n } = r, { BASE: s, Fp: o, Fn: c } = t, a = r.randomBytes || Or, i = r.adjustScalarBytes || ((f) => f), p = r.domain || ((f, d, y) => {
1764
+ if (qe(y, "phflag"), d.length || y)
1765
+ throw new Error("Contexts/pre-hash are not supported");
1766
+ return f;
1767
+ });
1768
+ function w(f) {
1769
+ return c.create(xe(f));
1770
+ }
1771
+ function h(f) {
1772
+ const d = g.secretKey;
1773
+ H(f, g.secretKey, "secretKey");
1774
+ const y = H(e(f), 2 * d, "hashedSecretKey"), x = i(y.slice(0, d)), v = y.slice(d, 2 * d), I = w(x);
1775
+ return { head: x, prefix: v, scalar: I };
1776
+ }
1777
+ function A(f) {
1778
+ const { head: d, prefix: y, scalar: x } = h(f), v = s.multiply(x), I = v.toBytes();
1779
+ return { head: d, prefix: y, scalar: x, point: v, pointBytes: I };
1780
+ }
1781
+ function N(f) {
1782
+ return A(f).pointBytes;
1783
+ }
1784
+ function R(f = Uint8Array.of(), ...d) {
1785
+ const y = rt(...d);
1786
+ return w(e(p(y, H(f, void 0, "context"), !!n)));
1787
+ }
1788
+ function B(f, d, y = {}) {
1789
+ f = H(f, void 0, "message"), n && (f = n(f));
1790
+ const { prefix: x, scalar: v, pointBytes: I } = A(d), C = R(y.context, x, f), L = s.multiply(C).toBytes(), _ = R(y.context, L, I, f), U = c.create(C + _ * v);
1791
+ if (!c.isValid(U))
1792
+ throw new Error("sign failed: invalid s");
1793
+ const V = rt(L, c.toBytes(U));
1794
+ return H(V, g.signature, "result");
1795
+ }
1796
+ const S = { zip215: !0 };
1797
+ function m(f, d, y, x = S) {
1798
+ const { context: v, zip215: I } = x, C = g.signature;
1799
+ f = H(f, C, "signature"), d = H(d, void 0, "message"), y = H(y, g.publicKey, "publicKey"), I !== void 0 && qe(I, "zip215"), n && (d = n(d));
1800
+ const L = C / 2, _ = f.subarray(0, L), U = xe(f.subarray(L, C));
1801
+ let V, z, oe;
1802
+ try {
1803
+ V = t.fromBytes(y, I), z = t.fromBytes(_, I), oe = s.multiplyUnsafe(U);
1804
+ } catch {
1805
+ return !1;
1806
+ }
1807
+ if (!I && V.isSmallOrder())
1808
+ return !1;
1809
+ const he = R(v, z.toBytes(), V.toBytes(), d);
1810
+ return z.add(V.multiplyUnsafe(he)).subtract(oe).clearCofactor().is0();
1811
+ }
1812
+ const b = o.BYTES, g = {
1813
+ secretKey: b,
1814
+ publicKey: b,
1815
+ signature: 2 * b,
1816
+ seed: b
1817
+ };
1818
+ function E(f = a(g.seed)) {
1819
+ return H(f, g.seed, "seed");
1820
+ }
1821
+ function T(f) {
1822
+ return St(f) && f.length === c.BYTES;
1823
+ }
1824
+ function l(f, d) {
1825
+ try {
1826
+ return !!t.fromBytes(f, d);
1827
+ } catch {
1828
+ return !1;
1829
+ }
1830
+ }
1831
+ const u = {
1832
+ getExtendedPublicKey: A,
1833
+ randomSecretKey: E,
1834
+ isValidSecretKey: T,
1835
+ isValidPublicKey: l,
1836
+ /**
1837
+ * Converts ed public key to x public key. Uses formula:
1838
+ * - ed25519:
1839
+ * - `(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)`
1840
+ * - `(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))`
1841
+ * - ed448:
1842
+ * - `(u, v) = ((y-1)/(y+1), sqrt(156324)*u/x)`
1843
+ * - `(x, y) = (sqrt(156324)*u/v, (1+u)/(1-u))`
1844
+ */
1845
+ toMontgomery(f) {
1846
+ const { y: d } = t.fromBytes(f), y = g.publicKey, x = y === 32;
1847
+ if (!x && y !== 57)
1848
+ throw new Error("only defined for 25519 and 448");
1849
+ const v = x ? o.div($ + d, $ - d) : o.div(d - $, d + $);
1850
+ return o.toBytes(v);
1851
+ },
1852
+ toMontgomerySecret(f) {
1853
+ const d = g.secretKey;
1854
+ H(f, d);
1855
+ const y = e(f.subarray(0, d));
1856
+ return i(y).subarray(0, d);
1857
+ }
1858
+ };
1859
+ return Object.freeze({
1860
+ keygen: gn(E, N),
1861
+ getPublicKey: N,
1862
+ sign: B,
1863
+ verify: m,
1864
+ utils: u,
1865
+ Point: t,
1866
+ lengths: g
1867
+ });
1868
+ }
1869
+ const xn = BigInt(1), gt = BigInt(2), En = BigInt(5), vn = BigInt(8), Ye = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"), An = {
1870
+ p: Ye,
1871
+ n: BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),
1872
+ h: vn,
1873
+ a: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),
1874
+ d: BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),
1875
+ Gx: BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),
1876
+ Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
1877
+ };
1878
+ function Bn(t) {
1879
+ const e = BigInt(10), r = BigInt(20), n = BigInt(40), s = BigInt(80), o = Ye, a = t * t % o * t % o, i = Y(a, gt, o) * a % o, p = Y(i, xn, o) * t % o, w = Y(p, En, o) * p % o, h = Y(w, e, o) * w % o, A = Y(h, r, o) * h % o, N = Y(A, n, o) * A % o, R = Y(N, s, o) * N % o, B = Y(R, s, o) * N % o, S = Y(B, e, o) * w % o;
1880
+ return { pow_p_5_8: Y(S, gt, o) * t % o, b2: a };
1881
+ }
1882
+ function Sn(t) {
1883
+ return t[0] &= 248, t[31] &= 127, t[31] |= 64, t;
1884
+ }
1885
+ const pt = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
1886
+ function Rn(t, e) {
1887
+ const r = Ye, n = q(e * e * e, r), s = q(n * n * e, r), o = Bn(t * s).pow_p_5_8;
1888
+ let c = q(t * n * o, r);
1889
+ const a = q(e * c * c, r), i = c, p = q(c * pt, r), w = a === t, h = a === q(-t, r), A = a === q(-t * pt, r);
1890
+ return w && (c = i), (h || A) && (c = p), an(c, r) && (c = q(-c, r)), { isValid: w || h, value: c };
1891
+ }
1892
+ const In = /* @__PURE__ */ wn(An, { uvRatio: Rn });
1893
+ function Nn(t) {
1894
+ return yn(In, Yr, Object.assign({ adjustScalarBytes: Sn }, t));
1895
+ }
1896
+ const kn = /* @__PURE__ */ Nn({}), Cn = Cr, Ln = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
1897
+ function Tn(t) {
1898
+ if (t.length !== 16)
1899
+ throw new Error(`Invalid seed length: expected 16, got ${t.length}`);
1900
+ const e = Cn(t), r = kn.getPublicKey(e), n = new Uint8Array(64);
1901
+ return n.set(e, 0), n.set(r, 32), yt(e), { publicKey: r, secretKey: n };
1902
+ }
1903
+ function _n(t) {
1904
+ const e = Tn(t), r = e.publicKey;
1905
+ return yt(e.secretKey), r;
1906
+ }
1907
+ function On(t) {
1908
+ if (t.length !== 32)
1909
+ throw new Error(`Invalid public key length: expected 32, got ${t.length}`);
1910
+ return Un(t);
1911
+ }
1912
+ function Un(t) {
1913
+ let e = 0;
1914
+ for (let s = 0; s < t.length && t[s] === 0; s++)
1915
+ e++;
1916
+ let r = 0n;
1917
+ for (let s = 0; s < t.length; s++)
1918
+ r = r * 256n + BigInt(t[s]);
1919
+ let n = "";
1920
+ for (; r > 0n; ) {
1921
+ const s = Number(r % 58n);
1922
+ n = Ln[s] + n, r = r / 58n;
1923
+ }
1924
+ return "1".repeat(e) + n;
1925
+ }
1926
+ const Dn = ["https:"], Gt = ["javascript:", "data:", "vbscript:", "file:"];
1927
+ function Fn(t) {
1928
+ if (!t || typeof t != "string")
1929
+ return;
1930
+ const e = t.trim();
1931
+ if (!e)
1932
+ return;
1933
+ const r = e.toLowerCase();
1934
+ for (const n of Gt)
1935
+ if (r.startsWith(n))
1936
+ return;
1937
+ try {
1938
+ const n = new URL(e);
1939
+ return Dn.includes(n.protocol) ? e : void 0;
1940
+ } catch {
1941
+ return;
1942
+ }
1943
+ }
1944
+ function Mn(t) {
1945
+ if (!t || typeof t != "string")
1946
+ return;
1947
+ const e = t.trim();
1948
+ if (!e)
1949
+ return;
1950
+ const r = e.toLowerCase();
1951
+ for (const n of Gt)
1952
+ if (r.startsWith(n))
1953
+ return;
1954
+ try {
1955
+ const n = new URL(e);
1956
+ return n.protocol !== "https:" && n.protocol !== "http:" ? void 0 : e;
1957
+ } catch {
1958
+ return;
1959
+ }
1960
+ }
1961
+ async function qn(t) {
1962
+ const { password: e, serverUrl: r, accessToken: n, timeoutMs: s = 3e4 } = t, o = [];
1963
+ try {
1964
+ const c = Yt();
1965
+ o.push(c);
1966
+ const { shareA: a, shareB: i } = wr(c);
1967
+ o.push(a, i);
1968
+ const p = Xt(), w = await nr(e, p, Oe);
1969
+ o.push(w);
1970
+ const h = await Ft(a, Qt(w)), A = _n(c), N = On(A), R = {
1971
+ solanaPubkey: N,
1972
+ shareAAuthMethod: "password",
1973
+ shareACiphertext: h.ciphertext,
1974
+ shareANonce: h.nonce,
1975
+ shareB: Be(i),
1976
+ shareAKdfSalt: Be(p),
1977
+ shareAKdfParams: Oe,
1978
+ // Send seed as recovery data - server will store based on recovery mode
1979
+ recoveryData: Be(c)
1980
+ };
1981
+ return await new ve({
1982
+ baseUrl: r,
1983
+ timeoutMs: s,
1984
+ getAccessToken: n ? () => n : void 0
1985
+ }).post("/wallet/enroll", R), {
1986
+ success: !0,
1987
+ solanaPubkey: N
1988
+ };
1989
+ } catch (c) {
1990
+ const a = c instanceof Error ? c.message : "Wallet enrollment failed";
1991
+ return console.warn("[silentWalletEnroll] Failed:", a), {
1992
+ success: !1,
1993
+ error: a
1994
+ };
1995
+ } finally {
1996
+ Jt(...o);
1997
+ }
1998
+ }
1999
+ function Xe(t = {}) {
2000
+ const { maxAttempts: e = 5, windowMs: r = 6e4 } = t, n = bt([]), [s, o] = D(!1), [, c] = D(0), a = M(() => {
2001
+ c((B) => B + 1);
2002
+ }, []), i = M(() => {
2003
+ const B = Date.now();
2004
+ n.current = n.current.filter((S) => B - S < r);
2005
+ }, [r]), p = M(() => {
2006
+ i(), o((B) => n.current.length === 0 && B ? !1 : B);
2007
+ }, [i]), w = M(() => (i(), Math.max(0, e - n.current.length)), [i, e]), h = M(() => {
2008
+ if (i(), n.current.length === 0)
2009
+ return 0;
2010
+ const S = n.current[0] + r;
2011
+ return Math.max(0, S - Date.now());
2012
+ }, [i, r]), A = M(() => (i(), n.current.length < e), [i, e]), N = M(() => {
2013
+ if (p(), n.current.length >= e) {
2014
+ const B = h(), S = Math.ceil(B / 1e3);
2015
+ throw new Error(
2016
+ `Too many attempts. Please wait ${S} second${S === 1 ? "" : "s"} before trying again.`
2017
+ );
2018
+ }
2019
+ n.current.push(Date.now()), o((B) => B || !0), a();
2020
+ }, [p, e, h, a]), R = M(() => {
2021
+ n.current = [], o((B) => B && !1), a();
2022
+ }, [a]);
2023
+ return _e(() => {
2024
+ if (!s) return;
2025
+ const B = window.setInterval(() => {
2026
+ p(), a();
2027
+ }, 1e3);
2028
+ return () => {
2029
+ window.clearInterval(B);
2030
+ };
2031
+ }, [s, a, p]), {
2032
+ checkLimit: N,
2033
+ isAllowed: A,
2034
+ getRemainingAttempts: w,
2035
+ getTimeUntilReset: h,
2036
+ reset: R
2037
+ };
2038
+ }
2039
+ function Vn(t) {
2040
+ return "mfaRequired" in t && t.mfaRequired === !0;
2041
+ }
2042
+ function jt() {
2043
+ const { config: t, _internal: e } = de(), [r, n] = D(!1), [s, o] = D(null), {
2044
+ checkLimit: c,
2045
+ getRemainingAttempts: a,
2046
+ getTimeUntilReset: i,
2047
+ reset: p
2048
+ } = Xe({ maxAttempts: 5, windowMs: 6e4 }), w = He(
2049
+ () => new ve({
2050
+ baseUrl: t.serverUrl,
2051
+ timeoutMs: t.requestTimeout,
2052
+ retryAttempts: t.retryAttempts
2053
+ }),
2054
+ [t.serverUrl, t.requestTimeout, t.retryAttempts]
2055
+ ), h = t.callbacks, A = t.features?.walletEnrollment !== !1, N = t.serverUrl, R = M(
2056
+ async (m, b) => {
2057
+ if (!Ue(m)) {
2058
+ const g = {
2059
+ code: "VALIDATION_ERROR",
2060
+ message: "Please enter a valid email address"
2061
+ };
2062
+ throw o(g), g;
2063
+ }
2064
+ try {
2065
+ c();
2066
+ } catch (g) {
2067
+ const E = {
2068
+ code: "RATE_LIMITED",
2069
+ message: g instanceof Error ? g.message : "Too many attempts"
2070
+ };
2071
+ throw o(E), E;
2072
+ }
2073
+ n(!0), o(null);
2074
+ try {
2075
+ const g = await w.post("/login", {
2076
+ email: m,
2077
+ password: b
2078
+ });
2079
+ if (Vn(g))
2080
+ return {
2081
+ mfaRequired: !0,
2082
+ mfaToken: g.mfaToken,
2083
+ email: m,
2084
+ userId: g.userId
2085
+ };
2086
+ const E = g;
2087
+ return h?.onLoginSuccess?.(E.user, "email"), e?.handleLoginSuccess(E.user, E.tokens), p(), {
2088
+ mfaRequired: !1,
2089
+ response: E
2090
+ };
2091
+ } catch (g) {
2092
+ const E = ue(g, "Login failed");
2093
+ throw o(E), E;
2094
+ } finally {
2095
+ n(!1);
2096
+ }
2097
+ },
2098
+ [w, h, e, c, p]
2099
+ ), B = M(
2100
+ async (m, b, g) => {
2101
+ if (!Ue(m)) {
2102
+ const E = {
2103
+ code: "VALIDATION_ERROR",
2104
+ message: "Please enter a valid email address"
2105
+ };
2106
+ throw o(E), E;
2107
+ }
2108
+ try {
2109
+ c();
2110
+ } catch (E) {
2111
+ const T = {
2112
+ code: "RATE_LIMITED",
2113
+ message: E instanceof Error ? E.message : "Too many attempts"
2114
+ };
2115
+ throw o(T), T;
2116
+ }
2117
+ n(!0), o(null);
2118
+ try {
2119
+ const E = await w.post("/register", { email: m, password: b, name: g });
2120
+ if (h?.onLoginSuccess?.(E.user, "email"), e?.handleLoginSuccess(E.user, E.tokens), p(), A) {
2121
+ const T = E.tokens?.accessToken ?? "";
2122
+ qn({
2123
+ password: b,
2124
+ serverUrl: N,
2125
+ accessToken: T
2126
+ }).then((l) => {
2127
+ l.success ? console.log("[useEmailAuth] Wallet auto-enrolled:", l.solanaPubkey) : console.warn("[useEmailAuth] Wallet auto-enrollment failed:", l.error);
2128
+ });
2129
+ }
2130
+ return E;
2131
+ } catch (E) {
2132
+ const T = ue(E, "Registration failed");
2133
+ throw o(T), T;
2134
+ } finally {
2135
+ n(!1);
2136
+ }
2137
+ },
2138
+ [
2139
+ w,
2140
+ h,
2141
+ e,
2142
+ c,
2143
+ p,
2144
+ N,
2145
+ A
2146
+ ]
2147
+ ), S = M(() => o(null), []);
2148
+ return {
2149
+ login: R,
2150
+ register: B,
2151
+ isLoading: r,
2152
+ error: s,
2153
+ clearError: S,
2154
+ // M-10: Point-in-time snapshots for UI display (see interface JSDoc)
2155
+ remainingAttempts: a(),
2156
+ timeUntilReset: i()
2157
+ };
2158
+ }
2159
+ function $n(t) {
2160
+ return typeof t == "object" && t !== null && "mfaRequired" in t && t.mfaRequired === !0;
2161
+ }
2162
+ function Hn() {
2163
+ const { config: t, _internal: e } = de(), [r, n] = D(!1), [s, o] = D(!1), [c, a] = D(null), i = He(
2164
+ () => new ve({
2165
+ baseUrl: t.serverUrl,
2166
+ timeoutMs: t.requestTimeout,
2167
+ retryAttempts: t.retryAttempts
2168
+ }),
2169
+ [t.serverUrl, t.requestTimeout, t.retryAttempts]
2170
+ ), { checkLimit: p, getRemainingAttempts: w } = Xe({
2171
+ maxAttempts: 3,
2172
+ windowMs: 3e5
2173
+ }), h = M(
2174
+ async (B) => {
2175
+ if (!Ue(B)) {
2176
+ const S = {
2177
+ code: "VALIDATION_ERROR",
2178
+ message: "Please enter a valid email address"
2179
+ };
2180
+ throw a(S), S;
2181
+ }
2182
+ try {
2183
+ p();
2184
+ } catch (S) {
2185
+ const m = {
2186
+ code: "RATE_LIMITED",
2187
+ message: S instanceof Error ? S.message : "Too many attempts"
2188
+ };
2189
+ throw a(m), m;
2190
+ }
2191
+ n(!0), a(null), o(!1);
2192
+ try {
2193
+ await i.post("/instant-link", { email: B }), o(!0);
2194
+ } catch (S) {
2195
+ const m = ue(S, "Failed to send sign-in link");
2196
+ throw a(m), m;
2197
+ } finally {
2198
+ n(!1);
2199
+ }
2200
+ },
2201
+ [i, p]
2202
+ ), A = M(
2203
+ async (B) => {
2204
+ if (!B || B.trim().length === 0) {
2205
+ const S = {
2206
+ code: "VALIDATION_ERROR",
2207
+ message: "Invalid or missing sign-in link token"
2208
+ };
2209
+ throw a(S), S;
2210
+ }
2211
+ n(!0), a(null), o(!1);
2212
+ try {
2213
+ const S = await i.post(
2214
+ "/instant-link/verify",
2215
+ {
2216
+ token: B
2217
+ }
2218
+ );
2219
+ return $n(S) || (t.callbacks?.onLoginSuccess?.(S.user, "email"), e?.handleLoginSuccess(S.user, S.tokens)), S;
2220
+ } catch (S) {
2221
+ const m = ue(S, "Failed to verify sign-in link");
2222
+ throw a(m), m;
2223
+ } finally {
2224
+ n(!1);
2225
+ }
2226
+ },
2227
+ [i, t.callbacks, e]
2228
+ ), N = M(() => a(null), []), R = M(() => {
2229
+ a(null), o(!1), n(!1);
2230
+ }, []);
2231
+ return {
2232
+ sendInstantLink: h,
2233
+ verifyInstantLink: A,
2234
+ isLoading: r,
2235
+ isSuccess: s,
2236
+ error: c,
2237
+ clearError: N,
2238
+ reset: R,
2239
+ remainingAttempts: w()
2240
+ };
2241
+ }
2242
+ function Zt({
2243
+ label: t = "Password",
2244
+ labelAction: e,
2245
+ showStrengthMeter: r = !1,
2246
+ onValidationChange: n,
2247
+ error: s,
2248
+ className: o = "",
2249
+ onChange: c,
2250
+ value: a,
2251
+ ...i
2252
+ }) {
2253
+ const [p, w] = D(!1), [h, A] = D(null), N = wt(), R = (S) => {
2254
+ const m = S.target.value;
2255
+ if (r || n) {
2256
+ const b = er(m);
2257
+ A(b), n?.(b);
2258
+ }
2259
+ c?.(S);
2260
+ }, B = {
2261
+ weak: "var(--cedros-destructive, #ef4444)",
2262
+ fair: "var(--cedros-warning, #f59e0b)",
2263
+ good: "var(--cedros-success, #22c55e)",
2264
+ strong: "var(--cedros-success, #22c55e)"
2265
+ };
2266
+ return /* @__PURE__ */ O("div", { className: `cedros-password-input ${o}`, children: [
2267
+ /* @__PURE__ */ O("div", { className: "cedros-label-row", children: [
2268
+ /* @__PURE__ */ k("label", { htmlFor: N, className: "cedros-label", children: t }),
2269
+ e
2270
+ ] }),
2271
+ /* @__PURE__ */ O("div", { className: "cedros-password-wrapper", children: [
2272
+ /* @__PURE__ */ k(
2273
+ "input",
2274
+ {
2275
+ id: N,
2276
+ type: p ? "text" : "password",
2277
+ className: "cedros-input",
2278
+ onChange: R,
2279
+ value: a,
2280
+ "aria-invalid": s ? "true" : void 0,
2281
+ "aria-describedby": s ? `${N}-error` : void 0,
2282
+ ...i
2283
+ }
2284
+ ),
2285
+ /* @__PURE__ */ k(
2286
+ "button",
2287
+ {
2288
+ type: "button",
2289
+ className: "cedros-password-toggle",
2290
+ onClick: () => w(!p),
2291
+ "aria-label": p ? "Hide password" : "Show password",
2292
+ "aria-pressed": p,
2293
+ children: p ? /* @__PURE__ */ O("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
2294
+ /* @__PURE__ */ k(
2295
+ "path",
2296
+ {
2297
+ d: "M2.5 10s3-6 7.5-6 7.5 6 7.5 6-3 6-7.5 6-7.5-6-7.5-6z",
2298
+ stroke: "currentColor",
2299
+ strokeWidth: "1.5"
2300
+ }
2301
+ ),
2302
+ /* @__PURE__ */ k("circle", { cx: "10", cy: "10", r: "2.5", stroke: "currentColor", strokeWidth: "1.5" }),
2303
+ /* @__PURE__ */ k("path", { d: "M3 17L17 3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
2304
+ ] }) : /* @__PURE__ */ O("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
2305
+ /* @__PURE__ */ k(
2306
+ "path",
2307
+ {
2308
+ d: "M2.5 10s3-6 7.5-6 7.5 6 7.5 6-3 6-7.5 6-7.5-6-7.5-6z",
2309
+ stroke: "currentColor",
2310
+ strokeWidth: "1.5"
2311
+ }
2312
+ ),
2313
+ /* @__PURE__ */ k("circle", { cx: "10", cy: "10", r: "2.5", stroke: "currentColor", strokeWidth: "1.5" })
2314
+ ] })
2315
+ }
2316
+ )
2317
+ ] }),
2318
+ s && /* @__PURE__ */ k("p", { id: `${N}-error`, className: "cedros-input-error", children: s }),
2319
+ r && h && a?.length > 0 && /* @__PURE__ */ O("div", { className: "cedros-password-strength", children: [
2320
+ /* @__PURE__ */ k("div", { className: "cedros-strength-bar", children: /* @__PURE__ */ k(
2321
+ "div",
2322
+ {
2323
+ className: "cedros-strength-fill",
2324
+ style: {
2325
+ width: `${h.strength === "weak" ? 25 : h.strength === "fair" ? 50 : h.strength === "good" ? 75 : 100}%`,
2326
+ backgroundColor: B[h.strength]
2327
+ }
2328
+ }
2329
+ ) }),
2330
+ /* @__PURE__ */ k("span", { className: "cedros-strength-label", children: h.strength })
2331
+ ] })
2332
+ ] });
2333
+ }
2334
+ function Gn() {
2335
+ const { config: t, _internal: e } = de(), [r, n] = D("idle"), [s, o] = D(!1), [c, a] = D(null), {
2336
+ checkLimit: i,
2337
+ getRemainingAttempts: p,
2338
+ getTimeUntilReset: w,
2339
+ reset: h
2340
+ } = Xe({ maxAttempts: 5, windowMs: 12e4 }), A = He(
2341
+ () => new ve({
2342
+ baseUrl: t.serverUrl,
2343
+ timeoutMs: t.requestTimeout,
2344
+ retryAttempts: t.retryAttempts
2345
+ }),
2346
+ [t.serverUrl, t.requestTimeout, t.retryAttempts]
2347
+ ), N = M(
2348
+ async (S, m) => {
2349
+ const b = /^[A-Z0-9]{16}$/i.test(m) || /^[A-Z0-9]{4}(-[A-Z0-9]{4}){3}$/i.test(m);
2350
+ if (!(/^\d{6}$/.test(m) || b)) {
2351
+ const E = {
2352
+ code: "VALIDATION_ERROR",
2353
+ message: "Please enter a valid 6-digit code or recovery code"
2354
+ };
2355
+ throw a(E), E;
2356
+ }
2357
+ try {
2358
+ i();
2359
+ } catch (E) {
2360
+ const T = {
2361
+ code: "RATE_LIMITED",
2362
+ message: E instanceof Error ? E.message : "Too many attempts"
2363
+ };
2364
+ throw a(T), T;
2365
+ }
2366
+ o(!0), a(null), n("verifying");
2367
+ try {
2368
+ const E = await A.post("/login/mfa", { mfaToken: S, code: m });
2369
+ return n("success"), h(), e && E.user && E.tokens && e.handleLoginSuccess(E.user, E.tokens), E;
2370
+ } catch (E) {
2371
+ const T = ue(E, "Invalid verification code");
2372
+ throw a(T), n("error"), T;
2373
+ } finally {
2374
+ o(!1);
2375
+ }
2376
+ },
2377
+ [A, e, i, h]
2378
+ ), R = M(() => a(null), []), B = M(() => {
2379
+ a(null), n("idle"), o(!1);
2380
+ }, []);
2381
+ return {
2382
+ state: r,
2383
+ isLoading: s,
2384
+ error: c,
2385
+ verifyTotp: N,
2386
+ clearError: R,
2387
+ reset: B,
2388
+ // Point-in-time snapshots for UI display
2389
+ remainingAttempts: p(),
2390
+ timeUntilReset: w()
2391
+ };
2392
+ }
2393
+ const K = 6;
2394
+ function jn({
2395
+ value: t = "",
2396
+ onChange: e,
2397
+ onComplete: r,
2398
+ disabled: n = !1,
2399
+ error: s,
2400
+ autoFocus: o = !1,
2401
+ className: c = ""
2402
+ }) {
2403
+ const a = bt([]), [i, p] = D(t.padEnd(K, "")), w = wt();
2404
+ _e(() => {
2405
+ p(t.padEnd(K, ""));
2406
+ }, [t]);
2407
+ const h = M((m) => {
2408
+ m >= 0 && m < K && a.current[m]?.focus();
2409
+ }, []), A = M(
2410
+ (m) => {
2411
+ const b = m.replace(/\D/g, "").slice(0, K);
2412
+ p(b.padEnd(K, "")), e?.(b), b.length === K && r?.(b);
2413
+ },
2414
+ [e, r]
2415
+ ), N = M(
2416
+ (m, b) => {
2417
+ if (!/^\d?$/.test(b)) return;
2418
+ const g = i.split("");
2419
+ g[m] = b;
2420
+ const E = g.join("").replace(/ /g, "");
2421
+ A(E), b && m < K - 1 && h(m + 1);
2422
+ },
2423
+ [i, A, h]
2424
+ ), R = M(
2425
+ (m, b) => {
2426
+ if (b.key === "Backspace") {
2427
+ b.preventDefault();
2428
+ const g = i.split("");
2429
+ g[m] && g[m] !== " " ? (g[m] = " ", A(g.join("").replace(/ /g, ""))) : m > 0 && (g[m - 1] = " ", A(g.join("").replace(/ /g, "")), h(m - 1));
2430
+ } else b.key === "ArrowLeft" && m > 0 ? (b.preventDefault(), h(m - 1)) : b.key === "ArrowRight" && m < K - 1 && (b.preventDefault(), h(m + 1));
2431
+ },
2432
+ [i, A, h]
2433
+ ), B = M(
2434
+ (m) => {
2435
+ m.preventDefault();
2436
+ const g = m.clipboardData.getData("text").replace(/\D/g, "").slice(0, K);
2437
+ g && (A(g), h(Math.min(g.length, K - 1)));
2438
+ },
2439
+ [A, h]
2440
+ ), S = M((m) => {
2441
+ m.target.select();
2442
+ }, []);
2443
+ return _e(() => {
2444
+ o && !n && a.current[0]?.focus();
2445
+ }, [o, n]), /* @__PURE__ */ O("div", { className: `cedros-otp-input ${c}`, children: [
2446
+ /* @__PURE__ */ k("div", { className: "cedros-otp-slots", role: "group", "aria-label": "One-time password", children: Array.from({ length: K }).map((m, b) => /* @__PURE__ */ k(
2447
+ "input",
2448
+ {
2449
+ ref: (g) => {
2450
+ a.current[b] = g;
2451
+ },
2452
+ id: `${w}-${b}`,
2453
+ type: "text",
2454
+ inputMode: "numeric",
2455
+ pattern: "[0-9]*",
2456
+ maxLength: 1,
2457
+ className: `cedros-otp-slot ${s ? "cedros-otp-slot-error" : ""}`,
2458
+ value: i[b] === " " ? "" : i[b] || "",
2459
+ onChange: (g) => N(b, g.target.value),
2460
+ onKeyDown: (g) => R(b, g),
2461
+ onPaste: B,
2462
+ onFocus: S,
2463
+ disabled: n,
2464
+ autoComplete: "one-time-code",
2465
+ "aria-label": `Digit ${b + 1}`,
2466
+ "aria-invalid": s ? "true" : void 0
2467
+ },
2468
+ b
2469
+ )) }),
2470
+ s && /* @__PURE__ */ k("p", { className: "cedros-otp-error", role: "alert", children: s })
2471
+ ] });
2472
+ }
2473
+ function Zn({
2474
+ mfaToken: t,
2475
+ email: e,
2476
+ onSuccess: r,
2477
+ onBack: n,
2478
+ className: s = ""
2479
+ }) {
2480
+ const { verifyTotp: o, isLoading: c, error: a, clearError: i } = Gn(), [p, w] = D(""), [h, A] = D(!1), [N, R] = D(""), B = async (b) => {
2481
+ const g = b || (h ? N : p);
2482
+ if (g)
2483
+ try {
2484
+ await o(t, g), r?.();
2485
+ } catch {
2486
+ h ? R("") : w("");
2487
+ }
2488
+ }, S = (b) => {
2489
+ B(b);
2490
+ }, m = () => {
2491
+ A(!h), i(), w(""), R("");
2492
+ };
2493
+ return /* @__PURE__ */ O("div", { className: `cedros-totp-verify ${s}`, children: [
2494
+ /* @__PURE__ */ O("div", { className: "cedros-totp-verify-header", children: [
2495
+ /* @__PURE__ */ O(
2496
+ "svg",
2497
+ {
2498
+ className: "cedros-totp-verify-icon",
2499
+ width: "48",
2500
+ height: "48",
2501
+ viewBox: "0 0 48 48",
2502
+ fill: "none",
2503
+ "aria-hidden": "true",
2504
+ children: [
2505
+ /* @__PURE__ */ k("rect", { x: "8", y: "20", width: "32", height: "24", rx: "4", stroke: "currentColor", strokeWidth: "2" }),
2506
+ /* @__PURE__ */ k(
2507
+ "path",
2508
+ {
2509
+ d: "M16 20V14a8 8 0 1 1 16 0v6",
2510
+ stroke: "currentColor",
2511
+ strokeWidth: "2",
2512
+ strokeLinecap: "round"
2513
+ }
2514
+ ),
2515
+ /* @__PURE__ */ k("circle", { cx: "24", cy: "32", r: "3", fill: "currentColor" })
2516
+ ]
2517
+ }
2518
+ ),
2519
+ /* @__PURE__ */ k("h3", { className: "cedros-totp-title", children: "Two-factor authentication" }),
2520
+ /* @__PURE__ */ k("p", { className: "cedros-totp-description", children: h ? "Enter one of your recovery codes to sign in." : "Enter the 6-digit code from your authenticator app." }),
2521
+ e && /* @__PURE__ */ k("p", { className: "cedros-totp-email", children: e })
2522
+ ] }),
2523
+ h ? /* @__PURE__ */ O("div", { className: "cedros-totp-backup-input", children: [
2524
+ /* @__PURE__ */ k(
2525
+ "input",
2526
+ {
2527
+ type: "text",
2528
+ className: `cedros-input ${a ? "cedros-input-error" : ""}`,
2529
+ placeholder: "Enter recovery code",
2530
+ value: N,
2531
+ onChange: (b) => {
2532
+ R(b.target.value.toUpperCase()), i();
2533
+ },
2534
+ onKeyDown: (b) => {
2535
+ b.key === "Enter" && N && B();
2536
+ },
2537
+ disabled: c,
2538
+ autoFocus: !0,
2539
+ autoComplete: "one-time-code"
2540
+ }
2541
+ ),
2542
+ a && /* @__PURE__ */ k("p", { className: "cedros-input-error", role: "alert", children: a.message })
2543
+ ] }) : /* @__PURE__ */ k(
2544
+ jn,
2545
+ {
2546
+ value: p,
2547
+ onChange: (b) => {
2548
+ w(b), i();
2549
+ },
2550
+ onComplete: S,
2551
+ disabled: c,
2552
+ error: a?.message,
2553
+ autoFocus: !0
2554
+ }
2555
+ ),
2556
+ /* @__PURE__ */ k(
2557
+ "button",
2558
+ {
2559
+ type: "button",
2560
+ className: "cedros-button cedros-button-primary cedros-button-md cedros-button-full",
2561
+ onClick: () => B(),
2562
+ disabled: c || (h ? !N : p.length !== 6),
2563
+ children: c ? /* @__PURE__ */ O(fe, { children: [
2564
+ /* @__PURE__ */ k(Ge, { size: "sm" }),
2565
+ /* @__PURE__ */ k("span", { children: "Verifying..." })
2566
+ ] }) : "Verify"
2567
+ }
2568
+ ),
2569
+ /* @__PURE__ */ O("div", { className: "cedros-totp-verify-footer", children: [
2570
+ /* @__PURE__ */ k(
2571
+ "button",
2572
+ {
2573
+ type: "button",
2574
+ className: "cedros-link cedros-link-sm",
2575
+ onClick: m,
2576
+ disabled: c,
2577
+ children: h ? "Use authenticator app" : "Use a recovery code"
2578
+ }
2579
+ ),
2580
+ n && /* @__PURE__ */ O(fe, { children: [
2581
+ /* @__PURE__ */ k("span", { className: "cedros-totp-verify-divider", children: "•" }),
2582
+ /* @__PURE__ */ k(
2583
+ "button",
2584
+ {
2585
+ type: "button",
2586
+ className: "cedros-link cedros-link-sm",
2587
+ onClick: n,
2588
+ disabled: c,
2589
+ children: "Back to login"
2590
+ }
2591
+ )
2592
+ ] })
2593
+ ] })
2594
+ ] });
2595
+ }
2596
+ function Qn({
2597
+ onSuccess: t,
2598
+ onSwitchToRegister: e,
2599
+ onForgotPassword: r,
2600
+ className: n = ""
2601
+ }) {
2602
+ const { config: s } = de(), { login: o, isLoading: c, error: a, clearError: i } = jt(), {
2603
+ sendInstantLink: p,
2604
+ isLoading: w,
2605
+ isSuccess: h,
2606
+ error: A,
2607
+ clearError: N,
2608
+ reset: R
2609
+ } = Hn(), [B, S] = D(""), [m, b] = D(""), [g, E] = D(null), [T, l] = D(""), u = s.forms?.forgotPassword?.mode ?? "reset", f = async (L) => {
2610
+ L.preventDefault();
2611
+ try {
2612
+ const _ = await o(B, m);
2613
+ _.mfaRequired ? (E(_.mfaToken), l(_.email)) : t?.();
2614
+ } catch {
2615
+ }
2616
+ }, d = () => {
2617
+ E(null), l(""), t?.();
2618
+ }, y = () => {
2619
+ E(null), l(""), b("");
2620
+ }, x = async () => {
2621
+ if (u === "instantLink")
2622
+ try {
2623
+ await p(B);
2624
+ } catch {
2625
+ }
2626
+ else
2627
+ r?.();
2628
+ };
2629
+ if (g)
2630
+ return /* @__PURE__ */ k(
2631
+ Zn,
2632
+ {
2633
+ mfaToken: g,
2634
+ email: T,
2635
+ onSuccess: d,
2636
+ onBack: y,
2637
+ className: n
2638
+ }
2639
+ );
2640
+ if (h)
2641
+ return /* @__PURE__ */ O("div", { className: `cedros-instant-link-success ${n}`, children: [
2642
+ /* @__PURE__ */ O(
2643
+ "svg",
2644
+ {
2645
+ className: "cedros-success-icon",
2646
+ width: "48",
2647
+ height: "48",
2648
+ viewBox: "0 0 48 48",
2649
+ fill: "none",
2650
+ "aria-hidden": "true",
2651
+ children: [
2652
+ /* @__PURE__ */ k("circle", { cx: "24", cy: "24", r: "22", stroke: "currentColor", strokeWidth: "2" }),
2653
+ /* @__PURE__ */ k(
2654
+ "path",
2655
+ {
2656
+ d: "M14 24l7 7 13-13",
2657
+ stroke: "currentColor",
2658
+ strokeWidth: "2",
2659
+ strokeLinecap: "round",
2660
+ strokeLinejoin: "round"
2661
+ }
2662
+ )
2663
+ ]
2664
+ }
2665
+ ),
2666
+ /* @__PURE__ */ k("h3", { className: "cedros-success-title", children: "Check your email" }),
2667
+ /* @__PURE__ */ O("p", { className: "cedros-success-message", children: [
2668
+ "We sent a sign-in link to ",
2669
+ /* @__PURE__ */ k("strong", { children: B }),
2670
+ ". Click the link to sign in."
2671
+ ] }),
2672
+ /* @__PURE__ */ k(
2673
+ "button",
2674
+ {
2675
+ type: "button",
2676
+ className: "cedros-button cedros-button-md cedros-button-outline",
2677
+ onClick: R,
2678
+ children: "Back to login"
2679
+ }
2680
+ )
2681
+ ] });
2682
+ const v = a || A, I = () => {
2683
+ i(), N();
2684
+ }, C = c || w;
2685
+ return /* @__PURE__ */ O("form", { onSubmit: f, className: `cedros-form ${n}`, children: [
2686
+ /* @__PURE__ */ O("div", { className: "cedros-form-field", children: [
2687
+ /* @__PURE__ */ k("label", { htmlFor: "email", className: "cedros-label", children: "Email" }),
2688
+ /* @__PURE__ */ k(
2689
+ "input",
2690
+ {
2691
+ id: "email",
2692
+ type: "email",
2693
+ className: "cedros-input",
2694
+ value: B,
2695
+ onChange: (L) => S(L.target.value),
2696
+ placeholder: "you@example.com",
2697
+ required: !0,
2698
+ "aria-required": "true",
2699
+ autoComplete: "email",
2700
+ disabled: C
2701
+ }
2702
+ )
2703
+ ] }),
2704
+ /* @__PURE__ */ k("div", { className: "cedros-form-field", children: /* @__PURE__ */ k(
2705
+ Zt,
2706
+ {
2707
+ value: m,
2708
+ onChange: (L) => b(L.target.value),
2709
+ placeholder: "Enter your password",
2710
+ required: !0,
2711
+ autoComplete: "current-password",
2712
+ disabled: C,
2713
+ labelAction: r || u === "instantLink" ? /* @__PURE__ */ k(
2714
+ "button",
2715
+ {
2716
+ type: "button",
2717
+ className: "cedros-link cedros-link-sm",
2718
+ onClick: x,
2719
+ disabled: w,
2720
+ children: w ? "Sending..." : "Forgot your password?"
2721
+ }
2722
+ ) : void 0
2723
+ }
2724
+ ) }),
2725
+ /* @__PURE__ */ k(xt, { error: v, onDismiss: I }),
2726
+ /* @__PURE__ */ k(
2727
+ "button",
2728
+ {
2729
+ type: "submit",
2730
+ className: "cedros-button cedros-button-primary cedros-button-md cedros-button-full",
2731
+ disabled: C || !B || !m,
2732
+ "aria-busy": c,
2733
+ children: c ? /* @__PURE__ */ O(fe, { children: [
2734
+ /* @__PURE__ */ k(Ge, { size: "sm", announce: !0, label: "Signing in" }),
2735
+ /* @__PURE__ */ k("span", { children: "Signing in..." })
2736
+ ] }) : "Sign in"
2737
+ }
2738
+ ),
2739
+ e && /* @__PURE__ */ O("p", { className: "cedros-form-footer", children: [
2740
+ "Don't have an account?",
2741
+ " ",
2742
+ /* @__PURE__ */ k("button", { type: "button", className: "cedros-link", onClick: e, children: "Sign up" })
2743
+ ] })
2744
+ ] });
2745
+ }
2746
+ function Jn({
2747
+ onSuccess: t,
2748
+ onSwitchToLogin: e,
2749
+ className: r = ""
2750
+ }) {
2751
+ const { config: n } = de(), { register: s, isLoading: o, error: c, clearError: a } = jt(), [i, p] = D(""), [w, h] = D(""), [A, N] = D(""), [R, B] = D(""), [S, m] = D(null), [b, g] = D(null), E = n.forms?.termsOfService, T = n.forms?.emailOptIn, l = E?.show ?? !1, u = E?.required ?? !0, f = E?.defaultChecked ?? !1, d = E?.label ?? "I agree to the Terms of Service", y = E?.url, x = Mn(y), v = T?.show ?? !1, I = T?.defaultChecked ?? !1, C = T?.label ?? "Send me updates and news", [L, _] = D(f), [U, V] = D(I), z = A === R, oe = S?.isValid ?? !1, ce = w && A && R && z && oe && (!l || !u || L) && !o, me = async (P) => {
2752
+ if (P.preventDefault(), g(null), l && u && !L) {
2753
+ g({
2754
+ code: "VALIDATION_ERROR",
2755
+ message: "You must agree to the Terms of Service to continue"
2756
+ });
2757
+ return;
2758
+ }
2759
+ if (ce)
2760
+ try {
2761
+ await s(w, A, i || void 0), t?.();
2762
+ } catch {
2763
+ }
2764
+ }, Pt = c || b, zt = () => {
2765
+ a(), g(null);
2766
+ };
2767
+ return /* @__PURE__ */ O("form", { onSubmit: me, className: `cedros-form ${r}`, children: [
2768
+ /* @__PURE__ */ O("div", { className: "cedros-form-field", children: [
2769
+ /* @__PURE__ */ O("label", { htmlFor: "name", className: "cedros-label", children: [
2770
+ "Name ",
2771
+ /* @__PURE__ */ k("span", { className: "cedros-optional", children: "(optional)" })
2772
+ ] }),
2773
+ /* @__PURE__ */ k(
2774
+ "input",
2775
+ {
2776
+ id: "name",
2777
+ type: "text",
2778
+ className: "cedros-input",
2779
+ value: i,
2780
+ onChange: (P) => p(P.target.value),
2781
+ placeholder: "Your name",
2782
+ autoComplete: "name",
2783
+ disabled: o
2784
+ }
2785
+ )
2786
+ ] }),
2787
+ /* @__PURE__ */ O("div", { className: "cedros-form-field", children: [
2788
+ /* @__PURE__ */ k("label", { htmlFor: "register-email", className: "cedros-label", children: "Email" }),
2789
+ /* @__PURE__ */ k(
2790
+ "input",
2791
+ {
2792
+ id: "register-email",
2793
+ type: "email",
2794
+ className: "cedros-input",
2795
+ value: w,
2796
+ onChange: (P) => h(P.target.value),
2797
+ placeholder: "you@example.com",
2798
+ required: !0,
2799
+ "aria-required": "true",
2800
+ autoComplete: "email",
2801
+ disabled: o
2802
+ }
2803
+ )
2804
+ ] }),
2805
+ /* @__PURE__ */ k("div", { className: "cedros-form-field", children: /* @__PURE__ */ k(
2806
+ Zt,
2807
+ {
2808
+ value: A,
2809
+ onChange: (P) => N(P.target.value),
2810
+ placeholder: "Create a password",
2811
+ required: !0,
2812
+ autoComplete: "new-password",
2813
+ disabled: o,
2814
+ showStrengthMeter: !0,
2815
+ onValidationChange: m
2816
+ }
2817
+ ) }),
2818
+ /* @__PURE__ */ O("div", { className: "cedros-form-field", children: [
2819
+ /* @__PURE__ */ k("label", { htmlFor: "confirm-password", className: "cedros-label", children: "Confirm Password" }),
2820
+ /* @__PURE__ */ k(
2821
+ "input",
2822
+ {
2823
+ id: "confirm-password",
2824
+ type: "password",
2825
+ className: "cedros-input",
2826
+ value: R,
2827
+ onChange: (P) => B(P.target.value),
2828
+ placeholder: "Confirm your password",
2829
+ required: !0,
2830
+ "aria-required": "true",
2831
+ autoComplete: "new-password",
2832
+ disabled: o,
2833
+ "aria-invalid": R && !z ? "true" : void 0,
2834
+ "aria-describedby": R && !z ? "confirm-password-error" : void 0
2835
+ }
2836
+ ),
2837
+ R && !z && /* @__PURE__ */ k("p", { id: "confirm-password-error", className: "cedros-input-error", role: "alert", children: "Passwords do not match" })
2838
+ ] }),
2839
+ l && /* @__PURE__ */ k("div", { className: "cedros-form-field cedros-checkbox-field", children: /* @__PURE__ */ O("label", { className: "cedros-checkbox-label", children: [
2840
+ /* @__PURE__ */ k(
2841
+ "input",
2842
+ {
2843
+ type: "checkbox",
2844
+ className: "cedros-checkbox",
2845
+ checked: L,
2846
+ onChange: (P) => _(P.target.checked),
2847
+ disabled: o,
2848
+ "aria-required": u
2849
+ }
2850
+ ),
2851
+ /* @__PURE__ */ O("span", { className: "cedros-checkbox-text", children: [
2852
+ x ? /* @__PURE__ */ O(fe, { children: [
2853
+ d.replace("Terms of Service", "").trim() || "I agree to the",
2854
+ " ",
2855
+ /* @__PURE__ */ k(
2856
+ "a",
2857
+ {
2858
+ href: x,
2859
+ target: "_blank",
2860
+ rel: "noopener noreferrer",
2861
+ className: "cedros-link",
2862
+ children: "Terms of Service"
2863
+ }
2864
+ )
2865
+ ] }) : d,
2866
+ u && /* @__PURE__ */ k("span", { className: "cedros-required", children: "*" })
2867
+ ] })
2868
+ ] }) }),
2869
+ v && /* @__PURE__ */ k("div", { className: "cedros-form-field cedros-checkbox-field", children: /* @__PURE__ */ O("label", { className: "cedros-checkbox-label", children: [
2870
+ /* @__PURE__ */ k(
2871
+ "input",
2872
+ {
2873
+ type: "checkbox",
2874
+ className: "cedros-checkbox",
2875
+ checked: U,
2876
+ onChange: (P) => V(P.target.checked),
2877
+ disabled: o
2878
+ }
2879
+ ),
2880
+ /* @__PURE__ */ k("span", { className: "cedros-checkbox-text", children: C })
2881
+ ] }) }),
2882
+ /* @__PURE__ */ k(xt, { error: Pt, onDismiss: zt }),
2883
+ /* @__PURE__ */ k(
2884
+ "button",
2885
+ {
2886
+ type: "submit",
2887
+ className: "cedros-button cedros-button-primary cedros-button-md cedros-button-full",
2888
+ disabled: !ce,
2889
+ "aria-busy": o,
2890
+ children: o ? /* @__PURE__ */ O(fe, { children: [
2891
+ /* @__PURE__ */ k(Ge, { size: "sm", announce: !0, label: "Creating account" }),
2892
+ /* @__PURE__ */ k("span", { children: "Creating account..." })
2893
+ ] }) : "Create account"
2894
+ }
2895
+ ),
2896
+ e && /* @__PURE__ */ O("p", { className: "cedros-form-footer", children: [
2897
+ "Already have an account?",
2898
+ " ",
2899
+ /* @__PURE__ */ k("button", { type: "button", className: "cedros-link", onClick: e, children: "Sign in" })
2900
+ ] })
2901
+ ] });
2902
+ }
2903
+ export {
2904
+ Qn as E,
2905
+ jn as O,
2906
+ Zt as P,
2907
+ Zn as T,
2908
+ Jn as a,
2909
+ je as b,
2910
+ Fn as c,
2911
+ Xe as d,
2912
+ wr as e,
2913
+ nr as f,
2914
+ _n as g,
2915
+ Yn as h,
2916
+ sr as i,
2917
+ Mn as j,
2918
+ Hn as k,
2919
+ Gn as l,
2920
+ On as p,
2921
+ Cr as s,
2922
+ jt as u
2923
+ };