@prosopo/procaptcha-bundle 0.3.4 → 0.3.36

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.
@@ -1,19 +1,24 @@
1
- import { r as f, l as Q, d as Z, j as d, a as E, b as g, A as $, h as ce, P as Ie, R as Te, C as Ne, W as Se, c as Pe, e as Oe, f as De, g as _e, i as ke, L as Le, k as He, m as Re, n as Ue } from "./index-DNBOJlnJ.js";
2
- import { _ as Me, a as We, b as je, I as Ge, R as Fe, g as ze, c as Be, d as $e, i as Ke, P as z, o as Ve, E as Ye, e as S, f as oe, h as v, j as V, k as le, s as Xe, l as qe, w as de, t as ne, m as Je, n as Qe, p as Ze, r as et, q as tt, u as nt, v as rt, A as ot, W as at, K as st, x as it, C as ct, y as lt, z as dt } from "./utils-wnaO-SHm.js";
3
- function ut() {
1
+ import { z as X, r as f, l as Q, d as Z, j as u, a as E, b as g, A as K, h as ue, P as Te, R as Pe, C as Oe, W as De, c as ke, e as Le, f as He, g as _e, i as Re, L as Me, k as We, m as Ue, n as je } from "./index-D8kIYYhv.js";
2
+ import { _ as Ge, a as ze, b as Fe, I as Be, R as $e, g as Ke, c as Ve, d as Ye, i as Xe, P as F, o as qe, E as Je, e as P, f as ae, h as v, j as V, k as de, s as xe, l as Qe, m as Ze, w as pe, t as re, n as et, p as tt, r as nt, q as rt, u as ot, v as at, A as st, W as ct, K as it, x as lt, C as ut, y as dt, z as pt } from "./utils-D1z4XROV.js";
3
+ const ve = X.object({
4
+ account: X.string().optional(),
5
+ blockNumber: X.number().optional(),
6
+ providerUrl: X.string().optional()
7
+ });
8
+ function ht() {
4
9
  if (console && console.warn) {
5
10
  for (var t, e = arguments.length, n = new Array(e), r = 0; r < e; r++)
6
11
  n[r] = arguments[r];
7
12
  typeof n[0] == "string" && (n[0] = "react-i18next:: ".concat(n[0])), (t = console).warn.apply(t, n);
8
13
  }
9
14
  }
10
- var ue = {};
11
- function ae() {
15
+ var he = {};
16
+ function se() {
12
17
  for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++)
13
18
  e[n] = arguments[n];
14
- typeof e[0] == "string" && ue[e[0]] || (typeof e[0] == "string" && (ue[e[0]] = /* @__PURE__ */ new Date()), ut.apply(void 0, e));
19
+ typeof e[0] == "string" && he[e[0]] || (typeof e[0] == "string" && (he[e[0]] = /* @__PURE__ */ new Date()), ht.apply(void 0, e));
15
20
  }
16
- function pe(t, e, n) {
21
+ function fe(t, e, n) {
17
22
  t.loadNamespaces(e, function() {
18
23
  if (t.isInitialized)
19
24
  n();
@@ -27,58 +32,58 @@ function pe(t, e, n) {
27
32
  }
28
33
  });
29
34
  }
30
- function pt(t, e) {
35
+ function ft(t, e) {
31
36
  var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, r = e.languages[0], a = e.options ? e.options.fallbackLng : !1, s = e.languages[e.languages.length - 1];
32
37
  if (r.toLowerCase() === "cimode")
33
38
  return !0;
34
- var o = function(l, p) {
35
- var w = e.services.backendConnector.state["".concat(l, "|").concat(p)];
36
- return w === -1 || w === 2;
39
+ var o = function(l, d) {
40
+ var b = e.services.backendConnector.state["".concat(l, "|").concat(d)];
41
+ return b === -1 || b === 2;
37
42
  };
38
43
  return n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && e.services.backendConnector.backend && e.isLanguageChangingTo && !o(e.isLanguageChangingTo, t) ? !1 : !!(e.hasResourceBundle(r, t) || !e.services.backendConnector.backend || e.options.resources && !e.options.partialBundledLanguages || o(r, t) && (!a || o(s, t)));
39
44
  }
40
- function ht(t, e) {
45
+ function gt(t, e) {
41
46
  var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
42
47
  if (!e.languages || !e.languages.length)
43
- return ae("i18n.languages were undefined or empty", e.languages), !0;
48
+ return se("i18n.languages were undefined or empty", e.languages), !0;
44
49
  var r = e.options.ignoreJSONStructure !== void 0;
45
50
  return r ? e.hasLoadedNamespace(t, {
46
51
  precheck: function(s, o) {
47
52
  if (n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && s.services.backendConnector.backend && s.isLanguageChangingTo && !o(s.isLanguageChangingTo, t))
48
53
  return !1;
49
54
  }
50
- }) : pt(t, e, n);
55
+ }) : ft(t, e, n);
51
56
  }
52
- function ft(t, e) {
57
+ function mt(t, e) {
53
58
  var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
54
59
  if (n != null) {
55
- var r, a, s, o, c = [], l = !0, p = !1;
60
+ var r, a, s, o, i = [], l = !0, d = !1;
56
61
  try {
57
62
  if (s = (n = n.call(t)).next, e === 0) {
58
63
  if (Object(n) !== n)
59
64
  return;
60
65
  l = !1;
61
66
  } else
62
- for (; !(l = (r = s.call(n)).done) && (c.push(r.value), c.length !== e); l = !0)
67
+ for (; !(l = (r = s.call(n)).done) && (i.push(r.value), i.length !== e); l = !0)
63
68
  ;
64
- } catch (w) {
65
- p = !0, a = w;
69
+ } catch (b) {
70
+ d = !0, a = b;
66
71
  } finally {
67
72
  try {
68
73
  if (!l && n.return != null && (o = n.return(), Object(o) !== o))
69
74
  return;
70
75
  } finally {
71
- if (p)
76
+ if (d)
72
77
  throw a;
73
78
  }
74
79
  }
75
- return c;
80
+ return i;
76
81
  }
77
82
  }
78
- function gt(t, e) {
79
- return Me(t) || ft(t, e) || We(t, e) || je();
83
+ function wt(t, e) {
84
+ return Ge(t) || mt(t, e) || ze(t, e) || Fe();
80
85
  }
81
- function he(t, e) {
86
+ function ge(t, e) {
82
87
  var n = Object.keys(t);
83
88
  if (Object.getOwnPropertySymbols) {
84
89
  var r = Object.getOwnPropertySymbols(t);
@@ -88,81 +93,81 @@ function he(t, e) {
88
93
  }
89
94
  return n;
90
95
  }
91
- function re(t) {
96
+ function oe(t) {
92
97
  for (var e = 1; e < arguments.length; e++) {
93
98
  var n = arguments[e] != null ? arguments[e] : {};
94
- e % 2 ? he(Object(n), !0).forEach(function(r) {
95
- Be(t, r, n[r]);
96
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : he(Object(n)).forEach(function(r) {
99
+ e % 2 ? ge(Object(n), !0).forEach(function(r) {
100
+ Ve(t, r, n[r]);
101
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : ge(Object(n)).forEach(function(r) {
97
102
  Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
98
103
  });
99
104
  }
100
105
  return t;
101
106
  }
102
- var mt = function(e, n) {
107
+ var bt = function(e, n) {
103
108
  var r = f.useRef();
104
109
  return f.useEffect(function() {
105
110
  r.current = n ? r.current : e;
106
111
  }, [e, n]), r.current;
107
112
  };
108
- function wt(t) {
109
- var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = e.i18n, r = f.useContext(Ge) || {}, a = r.i18n, s = r.defaultNS, o = n || a || $e();
110
- if (o && !o.reportNamespaces && (o.reportNamespaces = new Fe()), !o) {
111
- ae("You will need to pass in an i18next instance by using initReactI18next");
112
- var c = function(x) {
113
+ function yt(t) {
114
+ var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = e.i18n, r = f.useContext(Be) || {}, a = r.i18n, s = r.defaultNS, o = n || a || Ye();
115
+ if (o && !o.reportNamespaces && (o.reportNamespaces = new $e()), !o) {
116
+ se("You will need to pass in an i18next instance by using initReactI18next");
117
+ var i = function(x) {
113
118
  return Array.isArray(x) ? x[x.length - 1] : x;
114
- }, l = [c, {}, !1];
115
- return l.t = c, l.i18n = {}, l.ready = !1, l;
119
+ }, l = [i, {}, !1];
120
+ return l.t = i, l.i18n = {}, l.ready = !1, l;
116
121
  }
117
- o.options.react && o.options.react.wait !== void 0 && ae("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
118
- var p = re(re(re({}, ze()), o.options.react), e), w = p.useSuspense, I = p.keyPrefix, m = t || s || o.options && o.options.defaultNS;
122
+ o.options.react && o.options.react.wait !== void 0 && se("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
123
+ var d = oe(oe(oe({}, Ke()), o.options.react), e), b = d.useSuspense, I = d.keyPrefix, m = t || s || o.options && o.options.defaultNS;
119
124
  m = typeof m == "string" ? [m] : m || ["translation"], o.reportNamespaces.addUsedNamespaces && o.reportNamespaces.addUsedNamespaces(m);
120
- var D = (o.isInitialized || o.initializedStoreOnce) && m.every(function(A) {
121
- return ht(A, o, p);
125
+ var L = (o.isInitialized || o.initializedStoreOnce) && m.every(function(A) {
126
+ return gt(A, o, d);
122
127
  });
123
- function k() {
124
- return o.getFixedT(null, p.nsMode === "fallback" ? m : m[0], I);
128
+ function H() {
129
+ return o.getFixedT(null, d.nsMode === "fallback" ? m : m[0], I);
125
130
  }
126
- var U = f.useState(k), M = gt(U, 2), W = M[0], L = M[1], j = m.join(), Y = mt(j), b = f.useRef(!0);
131
+ var W = f.useState(H), U = wt(W, 2), j = U[0], _ = U[1], G = m.join(), Y = bt(G), y = f.useRef(!0);
127
132
  f.useEffect(function() {
128
- var A = p.bindI18n, x = p.bindI18nStore;
129
- b.current = !0, !D && !w && pe(o, m, function() {
130
- b.current && L(k);
131
- }), D && Y && Y !== j && b.current && L(k);
133
+ var A = d.bindI18n, x = d.bindI18nStore;
134
+ y.current = !0, !L && !b && fe(o, m, function() {
135
+ y.current && _(H);
136
+ }), L && Y && Y !== G && y.current && _(H);
132
137
  function B() {
133
- b.current && L(k);
138
+ y.current && _(H);
134
139
  }
135
140
  return A && o && o.on(A, B), x && o && o.store.on(x, B), function() {
136
- b.current = !1, A && o && A.split(" ").forEach(function(i) {
137
- return o.off(i, B);
138
- }), x && o && x.split(" ").forEach(function(i) {
139
- return o.store.off(i, B);
141
+ y.current = !1, A && o && A.split(" ").forEach(function(c) {
142
+ return o.off(c, B);
143
+ }), x && o && x.split(" ").forEach(function(c) {
144
+ return o.store.off(c, B);
140
145
  });
141
146
  };
142
- }, [o, j]);
143
- var T = f.useRef(!0);
147
+ }, [o, G]);
148
+ var N = f.useRef(!0);
144
149
  f.useEffect(function() {
145
- b.current && !T.current && L(k), T.current = !1;
150
+ y.current && !N.current && _(H), N.current = !1;
146
151
  }, [o, I]);
147
- var H = [W, o, D];
148
- if (H.t = W, H.i18n = o, H.ready = D, D || !D && !w)
149
- return H;
152
+ var R = [j, o, L];
153
+ if (R.t = j, R.i18n = o, R.ready = L, L || !L && !b)
154
+ return R;
150
155
  throw new Promise(function(A) {
151
- pe(o, m, function() {
156
+ fe(o, m, function() {
152
157
  A();
153
158
  });
154
159
  });
155
160
  }
156
- function yt(t) {
157
- return wt("translation", { i18n: Ke, ...t });
161
+ function Ct(t) {
162
+ return yt("translation", { i18n: Xe, ...t });
158
163
  }
159
- const bt = (t) => {
164
+ const xt = (t) => {
160
165
  if (!t.hash)
161
- throw new z("CAPTCHA.MISSING_ITEM_HASH", { context: { item: t } });
166
+ throw new F("CAPTCHA.MISSING_ITEM_HASH", { context: { item: t } });
162
167
  return t.hash;
163
- }, Ct = ({ challenge: t, solution: e, onClick: n, themeColor: r }) => {
168
+ }, vt = ({ challenge: t, solution: e, onClick: n, themeColor: r }) => {
164
169
  const a = t.captcha.items, s = f.useMemo(() => r === "light" ? Q : Z, [r]), o = "ontouchstart" in window;
165
- return d("div", { style: {
170
+ return u("div", { style: {
166
171
  paddingRight: 0.5,
167
172
  paddingBottom: 0.5,
168
173
  width: "100%",
@@ -170,31 +175,31 @@ const bt = (t) => {
170
175
  display: "flex",
171
176
  flexDirection: "row",
172
177
  flexWrap: "wrap"
173
- }, children: a.map((c, l) => {
174
- const p = bt(c);
175
- return d("div", { style: {
178
+ }, children: a.map((i, l) => {
179
+ const d = xt(i);
180
+ return u("div", { style: {
176
181
  paddingTop: "4px",
177
182
  paddingLeft: "4px",
178
183
  flexGrow: 1,
179
184
  flexBasis: "33.3333%",
180
185
  boxSizing: "border-box"
181
- }, children: E("div", { style: { cursor: "pointer", height: "100%", width: "100%" }, onClick: o ? void 0 : () => n(p), onTouchStart: o ? () => n(p) : void 0, children: [d("div", { style: { border: 1, borderColor: s.palette.grey[300] }, children: d("img", { style: {
186
+ }, children: E("div", { style: { cursor: "pointer", height: "100%", width: "100%" }, onClick: o ? void 0 : () => n(d), onTouchStart: o ? () => n(d) : void 0, children: [u("div", { style: { border: 1, borderColor: s.palette.grey[300] }, children: u("img", { style: {
182
187
  width: "100%",
183
188
  backgroundColor: s.palette.grey[300],
184
- opacity: e.includes(p) && o ? "50%" : "100%",
189
+ opacity: e.includes(d) && o ? "50%" : "100%",
185
190
  display: "block",
186
191
  objectFit: "contain",
187
192
  aspectRatio: "1/1",
188
193
  height: "auto"
189
- }, src: c.data, alt: `Captcha image ${l + 1}` }) }), d("div", { style: {
194
+ }, src: i.data, alt: `Captcha image ${l + 1}` }) }), u("div", { style: {
190
195
  position: "relative",
191
196
  width: "100%",
192
197
  height: "100%",
193
198
  top: "-100%",
194
- visibility: e.includes(p) ? "visible" : "hidden",
199
+ visibility: e.includes(d) ? "visible" : "hidden",
195
200
  transition: "opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
196
201
  opacity: 1
197
- }, children: d("div", { style: {
202
+ }, children: u("div", { style: {
198
203
  position: "absolute",
199
204
  top: 0,
200
205
  left: 0,
@@ -206,7 +211,7 @@ const bt = (t) => {
206
211
  alignItems: "center",
207
212
  justifyContent: "center",
208
213
  backgroundColor: "rgba(0,0,0,0.5)"
209
- }, children: d("svg", { style: {
214
+ }, children: u("svg", { style: {
210
215
  backgroundColor: "transparent",
211
216
  display: "block",
212
217
  width: "35%",
@@ -214,18 +219,18 @@ const bt = (t) => {
214
219
  transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
215
220
  userSelect: "none",
216
221
  fill: "currentcolor"
217
- }, focusable: "false", color: "#fff", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "CheckIcon", children: d("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }) }) })] }) }, l);
222
+ }, focusable: "false", color: "#fff", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "CheckIcon", children: u("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }) }) })] }) }, l);
218
223
  }) });
219
224
  };
220
- function xt(t = {}) {
225
+ function At(t = {}) {
221
226
  return Object.keys(t).reduce((e, n) => ({ ...e, [`data-${n}`]: t[n] }), {});
222
227
  }
223
- function se({ general: t, dev: e }) {
228
+ function ce({ general: t, dev: e }) {
224
229
  return {
225
- ...xt(t)
230
+ ...At(t)
226
231
  };
227
232
  }
228
- const vt = {
233
+ const Et = {
229
234
  display: "inline-flex",
230
235
  alignItems: "center",
231
236
  justifyContent: "center",
@@ -251,10 +256,10 @@ const vt = {
251
256
  color: "rgb(0, 0, 0)",
252
257
  backgroundColor: "#ffffff",
253
258
  boxShadow: "rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px"
254
- }, At = ({ themeColor: t, buttonType: e, text: n, onClick: r }) => {
255
- const a = f.useMemo(() => t === "light" ? Q : Z, [t]), [s, o] = f.useState(!1), c = f.useMemo(() => {
259
+ }, It = ({ themeColor: t, buttonType: e, text: n, onClick: r }) => {
260
+ const a = f.useMemo(() => t === "light" ? Q : Z, [t]), [s, o] = f.useState(!1), i = f.useMemo(() => {
256
261
  const l = {
257
- ...vt,
262
+ ...Et,
258
263
  color: s ? a.palette.primary.contrastText : a.palette.background.contrastText
259
264
  };
260
265
  return e === "cancel" ? {
@@ -265,12 +270,12 @@ const vt = {
265
270
  backgroundColor: s ? a.palette.primary.main : a.palette.background.default
266
271
  };
267
272
  }, [e, s, a]);
268
- return d("button", { ...se({ dev: { cy: `button-${e}` } }), onMouseEnter: () => o(!0), onMouseLeave: () => o(!1), style: c, onClick: (l) => {
273
+ return u("button", { ...ce({ dev: { cy: `button-${e}` } }), onMouseEnter: () => o(!0), onMouseLeave: () => o(!1), style: i, onClick: (l) => {
269
274
  l.preventDefault(), r();
270
275
  }, children: n });
271
- }, fe = At, Et = ({ challenge: t, index: e, solutions: n, onSubmit: r, onCancel: a, onClick: s, onNext: o, themeColor: c }) => {
272
- const { t: l } = yt(), p = t.captchas ? g(t.captchas, e) : null, w = n ? g(n, e) : [], I = f.useMemo(() => c === "light" ? Q : Z, [c]);
273
- return d(f.Suspense, { fallback: d("div", { children: "Loading..." }), children: d("div", { style: {
276
+ }, me = It, Nt = ({ challenge: t, index: e, solutions: n, onSubmit: r, onCancel: a, onClick: s, onNext: o, themeColor: i }) => {
277
+ const { t: l } = Ct(), d = t.captchas ? g(t.captchas, e) : null, b = n ? g(n, e) : [], I = f.useMemo(() => i === "light" ? Q : Z, [i]);
278
+ return u(f.Suspense, { fallback: u("div", { children: "Loading..." }), children: u("div", { style: {
274
279
  overflowX: "auto",
275
280
  overflowY: "auto",
276
281
  width: "100%",
@@ -293,17 +298,17 @@ const vt = {
293
298
  color: "#ffffff",
294
299
  fontWeight: 700,
295
300
  lineHeight: 1.5
296
- }, children: [l("WIDGET.SELECT_ALL"), ": "] }), d("p", { style: {
301
+ }, children: [l("WIDGET.SELECT_ALL"), ": "] }), u("p", { style: {
297
302
  color: "#ffffff",
298
303
  fontWeight: 700,
299
304
  textTransform: "capitalize",
300
305
  lineHeight: 1.5
301
- }, children: `${g(t.captchas, e).captcha.target}` })] }), d("div", { ...se({ dev: { cy: "captcha-" + e } }), children: p && d(Ct, { challenge: p, solution: w, onClick: s, themeColor: c }) }), d("div", { style: {
306
+ }, children: `${g(t.captchas, e).captcha.target}` })] }), u("div", { ...ce({ dev: { cy: "captcha-" + e } }), children: d && u(vt, { challenge: d, solution: b, onClick: s, themeColor: i }) }), u("div", { style: {
302
307
  display: "flex",
303
308
  alignItems: "center",
304
309
  justifyContent: "center",
305
310
  width: "100%"
306
- }, ...se({ dev: { cy: "dots-captcha" } }) }), d("div", { style: {
311
+ }, ...ce({ dev: { cy: "dots-captcha" } }) }), u("div", { style: {
307
312
  padding: "8px 16px",
308
313
  display: "flex",
309
314
  width: "100%"
@@ -313,8 +318,8 @@ const vt = {
313
318
  alignItems: "center",
314
319
  justifyContent: "space-between",
315
320
  lineHeight: 1.75
316
- }, children: [d(fe, { themeColor: c, buttonType: "cancel", onClick: a, text: l("WIDGET.CANCEL") }), d(fe, { themeColor: c, buttonType: "next", text: e < t.captchas.length - 1 ? l("WIDGET.NEXT") : l("WIDGET.SUBMIT"), onClick: e < t.captchas.length - 1 ? o : r })] })] }) }) });
317
- }, It = Et;
321
+ }, children: [u(me, { themeColor: i, buttonType: "cancel", onClick: a, text: l("WIDGET.CANCEL") }), u(me, { themeColor: i, buttonType: "next", text: e < t.captchas.length - 1 ? l("WIDGET.NEXT") : l("WIDGET.SUBMIT"), onClick: e < t.captchas.length - 1 ? o : r })] })] }) }) });
322
+ }, St = Nt;
318
323
  function Tt(t) {
319
324
  return new Promise((e) => {
320
325
  document.readyState === "complete" ? e(t()) : window.addEventListener("load", () => e(t()));
@@ -322,49 +327,49 @@ function Tt(t) {
322
327
  }
323
328
  const J = window;
324
329
  J.injectedWeb3 = J.injectedWeb3 || {};
325
- be();
326
- let ge = null;
327
- function be() {
330
+ Ae();
331
+ let we = null;
332
+ function Ae() {
328
333
  return Object.values(J.injectedWeb3).filter(({ connect: t, enable: e }) => !!(t || e)).length !== 0;
329
334
  }
330
- function Nt(t) {
331
- return Promise.all(Object.entries(J.injectedWeb3).map(([e, { connect: n, enable: r, version: a }]) => Promise.resolve().then(() => n ? n(t) : r ? r(t).then((s) => Ve({ name: e, version: a || "unknown" }, s)) : Promise.reject(new Error("No connect(..) or enable(...) hook found"))).catch(({ message: s }) => {
335
+ function Pt(t) {
336
+ return Promise.all(Object.entries(J.injectedWeb3).map(([e, { connect: n, enable: r, version: a }]) => Promise.resolve().then(() => n ? n(t) : r ? r(t).then((s) => qe({ name: e, version: a || "unknown" }, s)) : Promise.reject(new Error("No connect(..) or enable(...) hook found"))).catch(({ message: s }) => {
332
337
  console.error(`Error initializing ${e}: ${s}`);
333
338
  }))).then((e) => e.filter((n) => !!n));
334
339
  }
335
- function St(t, e = []) {
340
+ function Ot(t, e = []) {
336
341
  if (!t)
337
342
  throw new Error("You must pass a name for your app to the web3Enable function");
338
343
  const n = e.length ? Promise.all(e.map((r) => r().catch(() => !1))) : Promise.resolve([!0]);
339
- return ge = Tt(() => n.then(() => Nt(t).then((r) => r.map((a) => (a.accounts.subscribe || (a.accounts.subscribe = (s) => (a.accounts.get().then(s).catch(console.error), () => {
344
+ return we = Tt(() => n.then(() => Pt(t).then((r) => r.map((a) => (a.accounts.subscribe || (a.accounts.subscribe = (s) => (a.accounts.get().then(s).catch(console.error), () => {
340
345
  })), a))).catch(() => []).then((r) => {
341
346
  const a = r.map(({ name: s, version: o }) => `${s}/${o}`);
342
- return be(), console.info(`web3Enable: Enabled ${r.length} extension${r.length !== 1 ? "s" : ""}: ${a.join(", ")}`), r;
343
- }))), ge;
347
+ return Ae(), `${r.length}`, r.length, `${a.join(", ")}`, r;
348
+ }))), we;
344
349
  }
345
- class Pt extends Ye {
350
+ class Dt extends Je {
346
351
  async getAccount(e) {
347
352
  const { dappName: n, userAccountAddress: r } = e;
348
353
  if (!r)
349
- throw new S("WIDGET.NO_ACCOUNTS_FOUND", { context: { error: "No account address provided" } });
350
- const a = await St(n);
354
+ throw new P("WIDGET.NO_ACCOUNTS_FOUND", { context: { error: "No account address provided" } });
355
+ const a = await Ot(n);
351
356
  if (a.length === 0)
352
- throw new S("WIDGET.NO_EXTENSION_FOUND");
357
+ throw new P("WIDGET.NO_EXTENSION_FOUND");
353
358
  for (const s of a) {
354
- const c = (await s.accounts.get()).find((l) => l.address === r);
355
- if (c)
356
- return { account: c, extension: s };
359
+ const i = (await s.accounts.get()).find((l) => l.address === r);
360
+ if (i)
361
+ return { account: i, extension: s };
357
362
  }
358
- throw new S("WIDGET.ACCOUNT_NOT_FOUND", {
363
+ throw new P("WIDGET.ACCOUNT_NOT_FOUND", {
359
364
  context: { error: `No account found matching ${r}` }
360
365
  });
361
366
  }
362
367
  }
363
- async function Ot(t) {
368
+ async function kt(t) {
364
369
  try {
365
370
  const e = await fetch(t);
366
371
  if (!e.ok)
367
- throw new oe("API.BAD_REQUEST", {
372
+ throw new ae("API.BAD_REQUEST", {
368
373
  context: { error: `Network response was not ok, status: ${e.status}`, url: t }
369
374
  });
370
375
  const n = await e.arrayBuffer();
@@ -373,48 +378,48 @@ async function Ot(t) {
373
378
  throw new v("DATABASE.IMAGE_GET_FAILED", { context: { error: e } });
374
379
  }
375
380
  }
376
- const Dt = "NO_SOLUTION";
377
- function Ce(t, e = !1, n = !1, r) {
381
+ const Lt = "NO_SOLUTION";
382
+ function Ee(t, e = !1, n = !1, r) {
378
383
  try {
379
384
  const a = t.items.map((s, o) => {
380
385
  if (s.hash)
381
386
  return s.hash;
382
- throw new z("CAPTCHA.MISSING_ITEM_HASH", {
387
+ throw new F("CAPTCHA.MISSING_ITEM_HASH", {
383
388
  context: {
384
- computeCaptchaHashName: Ce.name,
389
+ computeCaptchaHashName: Ee.name,
385
390
  index: o
386
391
  }
387
392
  });
388
393
  });
389
394
  return V([
390
395
  t.target,
391
- ...e ? _t(t.solution) : [],
396
+ ...e ? Ht(t.solution) : [],
392
397
  n ? t.salt : "",
393
398
  r ? a.sort() : a
394
399
  ]);
395
400
  } catch (a) {
396
- throw new z("DATASET.HASH_ERROR", { context: { error: a } });
401
+ throw new F("DATASET.HASH_ERROR", { context: { error: a } });
397
402
  }
398
403
  }
399
- function _t(t) {
400
- return t !== void 0 ? t.sort() : [Dt];
404
+ function Ht(t) {
405
+ return t !== void 0 ? t.sort() : [Lt];
401
406
  }
402
- async function kt(t) {
407
+ async function _t(t) {
403
408
  if (t.type === "text")
404
- return { ...t, hash: le(t.data) };
409
+ return { ...t, hash: de(t.data) };
405
410
  if (t.type === "image")
406
- return { ...t, hash: le(await Ot(t.data)) };
407
- throw new z("CAPTCHA.INVALID_ITEM_FORMAT");
411
+ return { ...t, hash: de(await kt(t.data)) };
412
+ throw new F("CAPTCHA.INVALID_ITEM_FORMAT");
408
413
  }
409
- function Lt(t) {
414
+ function Rt(t) {
410
415
  return V([t.captchaId, t.captchaContentId, [...t.solution].sort(), t.salt]);
411
416
  }
412
- class me {
417
+ class be {
413
418
  constructor(e) {
414
419
  this.hash = e, this.parent = null;
415
420
  }
416
421
  }
417
- class Ht {
422
+ class Mt {
418
423
  constructor() {
419
424
  this.leaves = [], this.layers = [];
420
425
  }
@@ -422,7 +427,7 @@ class Ht {
422
427
  this.layers.length && (this.layers = []);
423
428
  const n = [];
424
429
  for (const r of e) {
425
- const a = new me(r);
430
+ const a = new be(r);
426
431
  this.leaves.push(a), n.push(a.hash);
427
432
  }
428
433
  this.layers.push(n), this.root = this.buildMerkleTree(this.leaves)[0];
@@ -437,14 +442,14 @@ class Ht {
437
442
  for (; a < n; ) {
438
443
  const o = e[a];
439
444
  if (o === void 0)
440
- throw new S("DEVELOPER.GENERAL", { context: { error: "leftChild undefined" } });
441
- const c = a + 1 < n ? g(e, a + 1) : o, l = this.createParent(o, c);
445
+ throw new P("DEVELOPER.GENERAL", { context: { error: "leftChild undefined" } });
446
+ const i = a + 1 < n ? g(e, a + 1) : o, l = this.createParent(o, i);
442
447
  s.push(l.hash), r.push(l), a += 2;
443
448
  }
444
449
  return this.layers.push(s), this.buildMerkleTree(r);
445
450
  }
446
451
  createParent(e, n) {
447
- const r = new me(V([e.hash, n.hash]));
452
+ const r = new be(V([e.hash, n.hash]));
448
453
  return e.parent = r.hash, n.parent = r.hash, r;
449
454
  }
450
455
  proof(e) {
@@ -453,20 +458,20 @@ class Ht {
453
458
  for (; r < this.layers.length - 1; ) {
454
459
  const s = this.layers[r];
455
460
  if (s === void 0)
456
- throw new S("DATASET.MERKLE_ERROR", {
461
+ throw new P("DATASET.MERKLE_ERROR", {
457
462
  context: { error: "layer undefined", failedFuncName: this.proof.name, layerNum: r }
458
463
  });
459
464
  const o = s.indexOf(e);
460
- let c = o % 2 && o > 0 ? o - 1 : o + 1;
461
- c > s.length - 1 && (c = o);
462
- const l = [e], p = g(s, c);
463
- c > o ? l.push(p) : l.unshift(p), n.push([g(l, 0), g(l, 1)]), r += 1, e = V(l);
465
+ let i = o % 2 && o > 0 ? o - 1 : o + 1;
466
+ i > s.length - 1 && (i = o);
467
+ const l = [e], d = g(s, i);
468
+ i > o ? l.push(d) : l.unshift(d), n.push([g(l, 0), g(l, 1)]), r += 1, e = V(l);
464
469
  }
465
470
  const a = g(this.layers, this.layers.length - 1);
466
471
  return [...n, [g(a, 0)]];
467
472
  }
468
473
  }
469
- function Rt(t, e) {
474
+ function Wt(t, e) {
470
475
  try {
471
476
  if (g(e, 0).indexOf(t) === -1)
472
477
  return !1;
@@ -506,62 +511,62 @@ class Ut {
506
511
  if (e.provider.datasetIdContent.toString() !== g(s, 0))
507
512
  throw new v("CAPTCHA.INVALID_DATASET_CONTENT_ID");
508
513
  for (const o of n.captchas) {
509
- if (!Mt(o))
514
+ if (!jt(o))
510
515
  throw new v("CAPTCHA.INVALID_CAPTCHA_CHALLENGE");
511
- if (!Rt(o.captcha.captchaContentId, o.proof))
516
+ if (!Wt(o.captcha.captchaContentId, o.proof))
512
517
  throw new v("CAPTCHA.INVALID_CAPTCHA_CHALLENGE");
513
518
  }
514
519
  }
515
520
  async submitCaptchaSolution(e, n, r, a, s) {
516
- const o = new Ht(), c = a.map((m) => Lt(m));
517
- o.build(c);
518
- const l = o.root.hash, p = void 0;
519
- let w;
521
+ const o = new Mt(), i = a.map((m) => Rt(m));
522
+ o.build(i);
523
+ const l = o.root.hash, d = void 0;
524
+ let b;
520
525
  if (this.web2) {
521
526
  if (!e || !e.signRaw)
522
527
  throw new v("GENERAL.CANT_FIND_KEYRINGPAIR", {
523
528
  context: { error: "Signer is not defined, cannot sign message to prove account ownership" }
524
529
  });
525
- w = (await e.signRaw({
530
+ b = (await e.signRaw({
526
531
  address: this.userAccount,
527
- data: Xe(n),
532
+ data: xe(n),
528
533
  type: "bytes"
529
534
  })).signature;
530
535
  }
531
536
  let I;
532
537
  try {
533
- I = await this.providerApi.submitCaptchaSolution(a, n, this.contract.pair.address, s, w);
538
+ I = await this.providerApi.submitCaptchaSolution(a, n, this.contract.pair.address, s, b);
534
539
  } catch (m) {
535
- throw new z("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error: m } });
540
+ throw new F("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error: m } });
536
541
  }
537
- return [I, l, p];
542
+ return [I, l, d];
538
543
  }
539
544
  }
540
- async function Mt(t) {
545
+ async function jt(t) {
541
546
  const e = t.captcha, n = t.proof;
542
- if (!(await Promise.all(e.items.map(async (a) => (await kt(a)).hash === a.hash))).every((a) => a === !0))
547
+ if (!(await Promise.all(e.items.map(async (a) => (await _t(a)).hash === a.hash))).every((a) => a === !0))
543
548
  return !1;
544
- const r = Ce(e, !1, !1, !1);
549
+ const r = Ee(e, !1, !1, !1);
545
550
  return r !== e.captchaContentId ? !1 : g(n, 0).indexOf(r) !== -1;
546
551
  }
547
- const Wt = Ut, xe = "@prosopo/current_account", ve = "@prosopo/provider";
548
- function jt(t) {
549
- localStorage.setItem(xe, t);
552
+ const Gt = Ut, Ie = "@prosopo/procaptcha";
553
+ function ie() {
554
+ return ve.parse(JSON.parse(Qe(localStorage.getItem(Ie) || "0x7b7d")));
550
555
  }
551
- function Gt() {
552
- return localStorage.getItem(xe);
556
+ function Ne(t) {
557
+ localStorage.setItem(Ie, xe(JSON.stringify(ve.parse(t))));
553
558
  }
554
- function Ft(t) {
555
- localStorage.setItem(ve, t);
559
+ function zt(t) {
560
+ Ne({ ...ie(), account: t });
556
561
  }
557
- function zt() {
558
- return localStorage.getItem(ve);
562
+ function Ft() {
563
+ return ie().account || null;
559
564
  }
560
- const K = {
561
- setAccount: jt,
562
- getAccount: Gt,
563
- setProviderUrl: Ft,
564
- getProviderUrl: zt
565
+ const z = {
566
+ setAccount: zt,
567
+ getAccount: Ft,
568
+ setProcaptchaStorage: Ne,
569
+ getProcaptchaStorage: ie
565
570
  }, Bt = () => ({
566
571
  showModal: !1,
567
572
  loading: !1,
@@ -571,7 +576,7 @@ const K = {
571
576
  isHuman: !1,
572
577
  captchaApi: void 0,
573
578
  account: void 0
574
- }), we = (t) => {
579
+ }), ye = (t) => {
575
580
  const e = t.networks[t.defaultNetwork];
576
581
  if (!e)
577
582
  throw new v("DEVELOPER.NETWORK_NOT_FOUND", {
@@ -580,223 +585,221 @@ const K = {
580
585
  return e;
581
586
  };
582
587
  function $t(t, e, n, r) {
583
- const a = qe(n, e, r), s = (i) => {
584
- const u = i instanceof Error ? i : new Error(String(i));
585
- a.onError(u);
586
- }, o = Je(e, n), c = () => {
587
- const i = {
588
+ const a = Ze(n, e, r), s = (c) => {
589
+ const p = c instanceof Error ? c : new Error(String(c));
590
+ a.onError(p);
591
+ }, o = et(e, n), i = () => {
592
+ const c = {
588
593
  userAccountAddress: "",
589
594
  ...t
590
595
  };
591
- return e.account && (i.userAccountAddress = e.account.account.address), Ie.parse(i);
592
- }, l = async (i) => {
596
+ return e.account && (c.userAccountAddress = e.account.account.address), Te.parse(c);
597
+ }, l = async (c) => {
593
598
  try {
594
- await i();
595
- } catch (u) {
596
- console.error(u), s(u), o({ isHuman: !1, showModal: !1, loading: !1 });
599
+ await c();
600
+ } catch (p) {
601
+ console.error(p), s(p), o({ isHuman: !1, showModal: !1, loading: !1 });
597
602
  }
598
- }, p = async () => {
603
+ }, d = async () => {
599
604
  a.onOpen(), await l(async () => {
600
605
  if (e.loading || e.isHuman)
601
606
  return;
602
- L(), o({ loading: !0 });
603
- const i = c();
604
- o({ dappAccount: i.account.address }), await Qe(100);
605
- const u = await Y(), h = await x();
606
- let y = !1;
607
+ _(), o({ loading: !0 });
608
+ const c = i();
609
+ o({ dappAccount: c.account.address }), await tt(100);
610
+ const p = await Y(), h = await x();
611
+ let w = !1;
607
612
  try {
608
- y = (await h.query.dappOperatorIsHumanUser(u.account.address, i.solutionThreshold)).value.unwrap().unwrap();
609
- } catch (N) {
613
+ w = (await h.query.dappOperatorIsHumanUser(p.account.address, c.solutionThreshold)).value.unwrap().unwrap();
614
+ } catch (T) {
610
615
  }
611
- if (y) {
616
+ if (w) {
612
617
  o({ isHuman: !0, loading: !1 }), a.onHuman({
613
- user: u.account.address,
614
- dapp: T()
615
- }), W();
618
+ user: p.account.address,
619
+ dapp: N()
620
+ }), j();
616
621
  return;
617
622
  }
618
- const C = K.getProviderUrl();
619
- let P;
620
- if (C) {
621
- P = await U(C);
623
+ const C = z.getProcaptchaStorage();
624
+ let O;
625
+ if (C.providerUrl && C.blockNumber) {
626
+ O = await W(C.providerUrl);
622
627
  try {
623
- const N = await P.verifyDappUser(T(), u.account.address, void 0, t.challengeValidLength);
624
- if (N.verified) {
628
+ const T = await O.verifyDappUser(N(), p.account.address, C.blockNumber, void 0, t.challengeValidLength);
629
+ if (T.verified) {
625
630
  o({ isHuman: !0, loading: !1 });
626
- const te = {
627
- [$.providerUrl]: C,
628
- [$.user]: u.account.address,
629
- [$.dapp]: T(),
630
- [$.commitmentId]: ce(N.commitmentId),
631
- [$.blockNumber]: N.blockNumber
631
+ const ne = {
632
+ [K.providerUrl]: C.providerUrl,
633
+ [K.user]: p.account.address,
634
+ [K.dapp]: N(),
635
+ [K.commitmentId]: ue(T.commitmentId),
636
+ [K.blockNumber]: T.blockNumber
632
637
  };
633
- a.onHuman(te), W();
638
+ a.onHuman(ne), j();
634
639
  return;
635
640
  }
636
641
  } catch {
637
- console.error("Error contacting provider from storage", C);
642
+ console.error("Error contacting provider from storage", C.providerUrl);
638
643
  }
639
644
  }
640
- const O = {
641
- address: u.account.address,
642
- data: Ze("message"),
643
- type: "bytes"
644
- };
645
- await u.extension.signer.signRaw(O);
646
- const _ = await de(h.query.getRandomActiveProvider, h.query)(u.account.address, T()), R = parseInt(_.blockNumber.toString()), X = ne(_.provider.url.toString());
647
- P = await U(X);
648
- const F = await (await k(h, _, P)).getCaptchaChallenge();
649
- if (F.captchas.length <= 0)
650
- throw new oe("DEVELOPER.PROVIDER_NO_CAPTCHA");
651
- const ee = F.captchas.map((N) => N.captcha.timeLimitMs || 30 * 1e3).reduce((N, te) => N + te), Ee = setTimeout(() => {
645
+ const D = await pe(h.query.getRandomActiveProvider, h.query)(p.account.address, N()), k = parseInt(D.blockNumber.toString()), M = re(D.provider.url.toString());
646
+ O = await W(M);
647
+ const S = await (await H(h, D, O)).getCaptchaChallenge();
648
+ if (S.captchas.length <= 0)
649
+ throw new ae("DEVELOPER.PROVIDER_NO_CAPTCHA");
650
+ const ee = S.captchas.map((T) => T.captcha.timeLimitMs || 30 * 1e3).reduce((T, ne) => T + ne), te = setTimeout(() => {
652
651
  a.onChallengeExpired(), o({ isHuman: !1, showModal: !1, loading: !1 });
653
652
  }, ee);
654
653
  o({
655
654
  index: 0,
656
- solutions: F.captchas.map(() => []),
657
- challenge: F,
655
+ solutions: S.captchas.map(() => []),
656
+ challenge: S,
658
657
  showModal: !0,
659
- timeout: Ee,
660
- blockNumber: R
658
+ timeout: te,
659
+ blockNumber: k
661
660
  });
662
661
  });
663
- }, w = async () => {
662
+ }, b = async () => {
664
663
  await l(async () => {
665
- if (M(), !e.challenge)
666
- throw new S("CAPTCHA.NO_CAPTCHA", {
664
+ if (U(), !e.challenge)
665
+ throw new P("CAPTCHA.NO_CAPTCHA", {
667
666
  context: { error: "Cannot submit, no Captcha found in state" }
668
667
  });
669
668
  o({ showModal: !1 });
670
- const i = e.challenge, u = et(), h = e.challenge.captchas.map((G, F) => {
671
- const ee = g(e.solutions, F);
669
+ const c = e.challenge, p = nt(), h = e.challenge.captchas.map((S, ee) => {
670
+ const te = g(e.solutions, ee);
672
671
  return {
673
- captchaId: G.captcha.captchaId,
674
- captchaContentId: G.captcha.captchaContentId,
675
- salt: u,
676
- solution: ee
672
+ captchaId: S.captcha.captchaId,
673
+ captchaContentId: S.captcha.captchaContentId,
674
+ salt: p,
675
+ solution: te
677
676
  };
678
- }), y = b(), C = H(), P = A(y).signer, O = g(i.captchas, 0);
679
- if (!O.captcha.datasetId)
680
- throw new z("CAPTCHA.INVALID_CAPTCHA_ID", {
677
+ }), w = y(), C = R(), O = A(w).signer, D = g(c.captchas, 0);
678
+ if (!D.captcha.datasetId)
679
+ throw new F("CAPTCHA.INVALID_CAPTCHA_ID", {
681
680
  context: { error: "No datasetId set for challenge" }
682
681
  });
683
- const _ = j(), R = await _.submitCaptchaSolution(P, i.requestHash, O.captcha.datasetId, h, u), X = R[0].verified;
684
- if (X || a.onFailed(), o({
685
- submission: R,
686
- isHuman: X,
682
+ const k = G(), M = await k.submitCaptchaSolution(O, c.requestHash, D.captcha.datasetId, h, p), $ = M[0].verified;
683
+ if ($ || a.onFailed(), o({
684
+ submission: M,
685
+ isHuman: $,
687
686
  loading: !1
688
687
  }), e.isHuman) {
689
- const G = ne(_.provider.provider.url.toString());
690
- K.setProviderUrl(G), a.onHuman({
691
- providerUrl: G,
692
- user: y.account.address,
693
- dapp: T(),
694
- commitmentId: ce(R[1]),
688
+ const S = re(k.provider.provider.url.toString());
689
+ z.setProcaptchaStorage({ ...z.getProcaptchaStorage(), providerUrl: S, blockNumber: C }), a.onHuman({
690
+ providerUrl: S,
691
+ user: w.account.address,
692
+ dapp: N(),
693
+ commitmentId: ue(M[1]),
695
694
  blockNumber: C
696
- }), W();
695
+ }), j();
697
696
  }
698
697
  });
699
698
  }, I = async () => {
700
- M(), L(), a.onClose();
701
- }, m = (i) => {
699
+ U(), _(), a.onClose();
700
+ }, m = (c) => {
702
701
  if (!e.challenge)
703
- throw new S("CAPTCHA.NO_CAPTCHA", {
702
+ throw new P("CAPTCHA.NO_CAPTCHA", {
704
703
  context: { error: "Cannot select, no Captcha found in state" }
705
704
  });
706
705
  if (e.index >= e.challenge.captchas.length || e.index < 0)
707
- throw new S("CAPTCHA.NO_CAPTCHA", {
706
+ throw new P("CAPTCHA.NO_CAPTCHA", {
708
707
  context: { error: "Cannot select, index is out of range for this Captcha" }
709
708
  });
710
- const u = e.index, h = e.solutions, y = g(h, u);
711
- y.includes(i) ? y.splice(y.indexOf(i), 1) : y.push(i), o({ solutions: h });
712
- }, D = () => {
709
+ const p = e.index, h = e.solutions, w = g(h, p);
710
+ w.includes(c) ? w.splice(w.indexOf(c), 1) : w.push(c), o({ solutions: h });
711
+ }, L = () => {
713
712
  if (!e.challenge)
714
- throw new S("CAPTCHA.NO_CAPTCHA", {
713
+ throw new P("CAPTCHA.NO_CAPTCHA", {
715
714
  context: { error: "Cannot select, no Captcha found in state" }
716
715
  });
717
716
  if (e.index + 1 >= e.challenge.captchas.length)
718
- throw new S("CAPTCHA.NO_CAPTCHA", {
717
+ throw new P("CAPTCHA.NO_CAPTCHA", {
719
718
  context: { error: "Cannot select, index is out of range for this Captcha" }
720
719
  });
721
720
  o({ index: e.index + 1 });
722
- }, k = async (i, u, h) => {
723
- const y = c(), C = new Wt(b().account.address, i, u, h, y.web2, T());
724
- return o({ captchaApi: C }), j();
725
- }, U = async (i) => {
726
- const u = c(), h = we(u);
727
- if (!u.account.address)
721
+ }, H = async (c, p, h) => {
722
+ const w = i(), C = new Gt(y().account.address, c, p, h, w.web2, N());
723
+ return o({ captchaApi: C }), G();
724
+ }, W = async (c) => {
725
+ const p = i(), h = ye(p);
726
+ if (!p.account.address)
728
727
  throw new v("GENERAL.SITE_KEY_MISSING");
729
- return new tt(h, i, u.account.address);
730
- }, M = () => {
728
+ return new rt(h, c, p.account.address);
729
+ }, U = () => {
731
730
  window.clearTimeout(e.timeout), o({ timeout: void 0 });
732
- }, W = () => {
733
- const i = t.challengeValidLength || 12e4, u = setTimeout(() => {
734
- o({ isHuman: !1 }), a.onExpired();
735
- }, i);
736
- o({ successfullChallengeTimeout: u });
737
- }, L = () => {
738
- M(), o(Bt());
739
731
  }, j = () => {
732
+ const c = t.challengeValidLength || 12e4, p = setTimeout(() => {
733
+ o({ isHuman: !1 }), a.onExpired();
734
+ }, c);
735
+ o({ successfullChallengeTimeout: p });
736
+ }, _ = () => {
737
+ U(), o(Bt());
738
+ }, G = () => {
740
739
  if (!e.captchaApi)
741
- throw new oe("API.UNKNOWN", { context: { error: "Captcha api not set", state: e } });
740
+ throw new ae("API.UNKNOWN", { context: { error: "Captcha api not set", state: e } });
742
741
  return e.captchaApi;
743
742
  }, Y = async () => {
744
- const i = c();
745
- if (!i.web2 && !i.userAccountAddress)
743
+ const c = i();
744
+ if (!c.web2 && !c.userAccountAddress)
746
745
  throw new v("GENERAL.ACCOUNT_NOT_FOUND", {
747
746
  context: { error: "Account address has not been set for web3 mode" }
748
747
  });
749
- const h = await (i.web2 ? new nt() : new Pt()).getAccount(i);
750
- return K.setAccount(h.account.address), o({ account: h }), b();
751
- }, b = () => {
748
+ const h = await (c.web2 ? new ot() : new Dt()).getAccount(c);
749
+ return z.setAccount(h.account.address), o({ account: h }), y();
750
+ }, y = () => {
752
751
  if (!e.account)
753
752
  throw new v("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account not loaded" } });
754
753
  return e.account;
755
- }, T = () => {
754
+ }, N = () => {
756
755
  if (!e.dappAccount)
757
756
  throw new v("GENERAL.SITE_KEY_MISSING");
758
757
  return e.dappAccount;
759
- }, H = () => {
758
+ }, R = () => {
760
759
  if (!e.blockNumber)
761
- throw new rt("CAPTCHA.INVALID_BLOCK_NO", { context: { error: "Block number not found" } });
760
+ throw new at("CAPTCHA.INVALID_BLOCK_NO", { context: { error: "Block number not found" } });
762
761
  return e.blockNumber;
763
- }, A = (i) => {
764
- if (i = i || b(), !i.extension)
762
+ }, A = (c) => {
763
+ if (c = c || y(), !c.extension)
765
764
  throw new v("ACCOUNT.NO_POLKADOT_EXTENSION", { context: { error: "Extension not loaded" } });
766
- return i.extension;
765
+ return c.extension;
767
766
  }, x = async () => {
768
- const i = c(), u = we(i), h = await ot.create({ provider: new at(u.endpoint), initWasm: !1 }), y = "sr25519", C = new st({ type: y, ss58Format: h.registry.chainSS58 });
769
- return new it(h, JSON.parse(ct), u.contract.address, "prosopo", 0, C.addFromAddress(b().account.address));
767
+ const c = i(), p = ye(c), h = await st.create({
768
+ provider: new ct(p.endpoint),
769
+ initWasm: !1,
770
+ noInitWarn: !0
771
+ }), w = "sr25519", C = new it({ type: w, ss58Format: h.registry.chainSS58 });
772
+ return new lt(h, JSON.parse(ut), p.contract.address, "prosopo", 0, C.addFromAddress(y().account.address));
770
773
  };
771
774
  return {
772
- start: p,
775
+ start: d,
773
776
  cancel: I,
774
- submit: w,
777
+ submit: b,
775
778
  select: m,
776
- nextRound: D,
777
- exportData: async (i) => {
778
- var P;
779
- const u = K.getProviderUrl();
780
- let h;
781
- if (u)
782
- h = await U(u);
779
+ nextRound: L,
780
+ exportData: async (c) => {
781
+ var D;
782
+ const h = z.getProcaptchaStorage().providerUrl;
783
+ let w;
784
+ if (h)
785
+ w = await W(h);
783
786
  else {
784
- const O = await x(), _ = await de(O.query.getRandomActiveProvider, O.query)(b().account.address, T()), R = ne(_.provider.url.toString());
785
- h = await U(R);
787
+ const k = await x(), M = await pe(k.query.getRandomActiveProvider, k.query)(y().account.address, N()), $ = re(M.provider.url.toString());
788
+ w = await W($);
786
789
  }
787
- if (!(K.getProviderUrl() || ((P = e.captchaApi) == null ? void 0 : P.provider.provider.url.toString())))
790
+ if (!(z.getProcaptchaStorage().providerUrl || ((D = e.captchaApi) == null ? void 0 : D.provider.provider.url.toString())))
788
791
  return;
789
- let C = "";
792
+ let O = "";
790
793
  try {
791
- C = b().account.address;
792
- } catch (O) {
793
- console.error(O);
794
+ O = y().account.address;
795
+ } catch (k) {
796
+ console.error(k);
794
797
  }
795
- await h.submitUserEvents(i, C);
798
+ await w.submitUserEvents(c, O);
796
799
  }
797
800
  };
798
801
  }
799
- const Kt = 1e4, ie = (t, e) => {
802
+ const Kt = 1e4, le = (t, e) => {
800
803
  e((n) => {
801
804
  let r = [...n, t];
802
805
  return r.length > Kt && (r = r.slice(1)), r;
@@ -807,33 +810,33 @@ const Kt = 1e4, ie = (t, e) => {
807
810
  y: t.y,
808
811
  timestamp: t.timeStamp
809
812
  };
810
- ie(n, e);
811
- }, ye = (t, e) => {
813
+ le(n, e);
814
+ }, Ce = (t, e) => {
812
815
  const n = {
813
816
  key: t.key,
814
817
  timestamp: t.timeStamp,
815
818
  isShiftKey: t.shiftKey,
816
819
  isCtrlKey: t.ctrlKey
817
820
  };
818
- ie(n, e);
821
+ le(n, e);
819
822
  }, q = (t, e) => {
820
823
  for (const n of Array.from(t.touches))
821
- ie({ x: n.clientX, y: n.clientY, timestamp: t.timeStamp }, e);
824
+ le({ x: n.clientX, y: n.clientY, timestamp: t.timeStamp }, e);
822
825
  }, Yt = (t, e, n, r) => {
823
- const a = Ae(r);
824
- a && (a.addEventListener("mousemove", (s) => Vt(s, t)), a.addEventListener("keydown", (s) => ye(s, n)), a.addEventListener("keyup", (s) => ye(s, n)), a.addEventListener("touchstart", (s) => q(s, e)), a.addEventListener("touchend", (s) => q(s, e)), a.addEventListener("touchcancel", (s) => q(s, e)), a.addEventListener("touchmove", (s) => q(s, e)));
825
- }, Ae = (t) => t.tagName === "FORM" ? t : t.parentElement ? Ae(t.parentElement) : null, Xt = ({ onProcessData: t, sendData: e, account: n }) => {
826
- const [r, a] = f.useState([]), [s, o] = f.useState([]), [c, l] = f.useState([]), p = f.useRef(null);
826
+ const a = Se(r);
827
+ a && (a.addEventListener("mousemove", (s) => Vt(s, t)), a.addEventListener("keydown", (s) => Ce(s, n)), a.addEventListener("keyup", (s) => Ce(s, n)), a.addEventListener("touchstart", (s) => q(s, e)), a.addEventListener("touchend", (s) => q(s, e)), a.addEventListener("touchcancel", (s) => q(s, e)), a.addEventListener("touchmove", (s) => q(s, e)));
828
+ }, Se = (t) => t.tagName === "FORM" ? t : t.parentElement ? Se(t.parentElement) : null, Xt = ({ onProcessData: t, sendData: e, account: n }) => {
829
+ const [r, a] = f.useState([]), [s, o] = f.useState([]), [i, l] = f.useState([]), d = f.useRef(null);
827
830
  return f.useEffect(() => {
828
- p && p.current && Yt(a, o, l, p.current);
831
+ d && d.current && Yt(a, o, l, d.current);
829
832
  }, []), f.useEffect(() => {
830
833
  n && t({
831
834
  mouseEvents: r,
832
835
  touchEvents: s,
833
- keyboardEvents: c
836
+ keyboardEvents: i
834
837
  });
835
- }, [e, n]), d("div", { ref: p });
836
- }, qt = Xt, Jt = Te.memo((t, e) => {
838
+ }, [e, n]), u("div", { ref: d });
839
+ }, qt = Xt, Jt = Pe.memo((t, e) => {
837
840
  const { show: n, children: r } = t, s = {
838
841
  position: "fixed",
839
842
  zIndex: 2147483646,
@@ -850,7 +853,7 @@ const Kt = 1e4, ie = (t, e) => {
850
853
  left: 0,
851
854
  backgroundColor: "rgba(0, 0, 0, 0.5)",
852
855
  zIndex: -1
853
- }, c = {
856
+ }, i = {
854
857
  position: "absolute",
855
858
  top: "50%",
856
859
  left: "50%",
@@ -860,22 +863,22 @@ const Kt = 1e4, ie = (t, e) => {
860
863
  border: "none",
861
864
  boxShadow: "rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px,"
862
865
  };
863
- return E("div", { className: "modalOuter", style: s, children: [d("div", { className: "modalBackground", style: o }), d("div", { className: "modalInner", style: c, children: r })] });
866
+ return E("div", { className: "modalOuter", style: s, children: [u("div", { className: "modalBackground", style: o }), u("div", { className: "modalInner", style: i, children: r })] });
864
867
  }), Qt = Jt, tn = (t) => {
865
- const e = t.config, n = t.callbacks || {}, [r, a] = lt(f.useState, f.useRef), s = $t(e, r, a, n), o = t.config.theme === "light" ? "light" : "dark", c = t.config.theme === "light" ? Q : Z;
866
- return d("div", { children: E("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: [d(Qt, { show: r.showModal, children: r.challenge ? d(It, { challenge: r.challenge, index: r.index, solutions: r.solutions, onSubmit: s.submit, onCancel: s.cancel, onClick: s.select, onNext: s.nextRound, themeColor: e.theme ?? "light" }) : d("div", { children: "No challenge set." }) }), E(Ne, { children: [d(Se, { children: E("div", { style: Pe, "data-cy": "button-human", children: [" ", E("div", { style: {
867
- padding: Oe,
868
- border: De,
869
- backgroundColor: c.palette.background.default,
870
- borderColor: c.palette.grey[300],
868
+ const e = t.config, n = t.callbacks || {}, [r, a] = dt(f.useState, f.useRef), s = $t(e, r, a, n), o = t.config.theme === "light" ? "light" : "dark", i = t.config.theme === "light" ? Q : Z;
869
+ return u("div", { children: E("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: [u(Qt, { show: r.showModal, children: r.challenge ? u(St, { challenge: r.challenge, index: r.index, solutions: r.solutions, onSubmit: s.submit, onCancel: s.cancel, onClick: s.select, onNext: s.nextRound, themeColor: e.theme ?? "light" }) : u("div", { children: "No challenge set." }) }), E(Oe, { children: [u(De, { children: E("div", { style: ke, "data-cy": "button-human", children: [" ", E("div", { style: {
870
+ padding: Le,
871
+ border: He,
872
+ backgroundColor: i.palette.background.default,
873
+ borderColor: i.palette.grey[300],
871
874
  borderRadius: _e,
872
875
  display: "flex",
873
876
  alignItems: "center",
874
877
  flexWrap: "wrap",
875
878
  justifyContent: "space-between",
876
- minHeight: `${ke}px`,
879
+ minHeight: `${Re}px`,
877
880
  overflow: "hidden"
878
- }, children: [d("div", { style: { display: "inline-flex", flexDirection: "column" }, children: d("div", { style: {
881
+ }, children: [u("div", { style: { display: "inline-flex", flexDirection: "column" }, children: u("div", { style: {
879
882
  alignItems: "center",
880
883
  flex: 1
881
884
  }, children: E("div", { style: {
@@ -884,11 +887,11 @@ const Kt = 1e4, ie = (t, e) => {
884
887
  justifyContent: "center",
885
888
  flexDirection: "column",
886
889
  verticalAlign: "middle"
887
- }, children: [d("div", { style: {
890
+ }, children: [u("div", { style: {
888
891
  display: r.loading ? "none" : "flex"
889
- }, children: d(dt, { themeColor: o, onChange: s.start, checked: r.isHuman, labelText: "I am human" }) }), d("div", { style: {
892
+ }, children: u(pt, { themeColor: o, onChange: s.start, checked: r.isHuman, labelText: "I am human" }) }), u("div", { style: {
890
893
  display: r.loading ? "flex" : "none"
891
- }, children: d("div", { style: { display: "inline-flex" }, children: d(Le, { themeColor: o }) }) })] }) }) }), d("div", { style: { display: "inline-flex", flexDirection: "column" }, children: d("a", { href: He, target: "_blank", "aria-label": Re, children: d("div", { style: { flex: 1 }, children: d(Ue, { themeColor: o }) }) }) })] })] }) }), e.devOnlyWatchEvents && d(qt, { onProcessData: s.exportData, sendData: r.sendData, account: r.account })] })] }) });
894
+ }, children: u("div", { style: { display: "inline-flex" }, children: u(Me, { themeColor: o }) }) })] }) }) }), u("div", { style: { display: "inline-flex", flexDirection: "column" }, children: u("a", { href: We, target: "_blank", "aria-label": Ue, children: u("div", { style: { flex: 1 }, children: u(je, { themeColor: o }) }) }) })] })] }) }), e.devOnlyWatchEvents && u(qt, { onProcessData: s.exportData, sendData: r.sendData, account: r.account })] })] }) });
892
895
  };
893
896
  export {
894
897
  tn as default