@prosopo/procaptcha-bundle 0.3.39 → 0.3.41

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