@prosopo/procaptcha-bundle 2.1.16 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.d.ts +4 -12
  2. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.d.ts.map +1 -1
  3. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.js.map +1 -1
  4. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captcha.d.ts +11 -0
  5. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captcha.d.ts.map +1 -0
  6. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captcha.js +5 -0
  7. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captcha.js.map +1 -0
  8. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captchaRenderer.d.ts +8 -0
  9. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captchaRenderer.d.ts.map +1 -0
  10. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captchaRenderer.js +11 -0
  11. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captchaRenderer.js.map +1 -0
  12. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts +6 -0
  13. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts.map +1 -0
  14. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.js +11 -0
  15. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.js.map +1 -0
  16. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.d.ts +6 -0
  17. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.d.ts.map +1 -0
  18. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.js +11 -0
  19. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.js.map +1 -0
  20. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/powCaptcha.d.ts +6 -0
  21. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/powCaptcha.d.ts.map +1 -0
  22. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/powCaptcha.js +11 -0
  23. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/powCaptcha.js.map +1 -0
  24. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/componentsList.d.ts +6 -0
  25. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/componentsList.d.ts.map +1 -0
  26. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/componentsList.js +11 -0
  27. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/componentsList.js.map +1 -0
  28. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/webComponent.d.ts +8 -0
  29. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/webComponent.d.ts.map +1 -0
  30. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/webComponent.js +24 -0
  31. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/webComponent.js.map +1 -0
  32. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/widgetRenderer.d.ts +24 -0
  33. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/widgetRenderer.d.ts.map +1 -0
  34. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/widgetRenderer.js +52 -0
  35. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/widgetRenderer.js.map +1 -0
  36. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic.d.ts +2 -3
  37. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic.d.ts.map +1 -1
  38. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic.js +11 -57
  39. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic.js.map +1 -1
  40. package/dist/bundle/{Checkbox-Dg1RwCua.js → Checkbox-DM6n1-r-.js} +67 -67
  41. package/dist/bundle/{ProcaptchaWidget-BlgHuBfn.js → ProcaptchaWidget-CrcxpJLK.js} +8 -8
  42. package/dist/bundle/ProcaptchaWidget-DZb9vegH.js +628 -0
  43. package/dist/bundle/{index-CgI2y2A6.js → index-B27PXNfK.js} +9260 -9186
  44. package/dist/bundle/procaptcha.bundle.js +1 -1
  45. package/dist/bundle/util/defaultCallbacks.d.ts +4 -12
  46. package/dist/bundle/util/defaultCallbacks.d.ts.map +1 -1
  47. package/dist/bundle/util/renderLogic/captcha/captcha.d.ts +11 -0
  48. package/dist/bundle/util/renderLogic/captcha/captcha.d.ts.map +1 -0
  49. package/dist/bundle/util/renderLogic/captcha/captchaRenderer.d.ts +8 -0
  50. package/dist/bundle/util/renderLogic/captcha/captchaRenderer.d.ts.map +1 -0
  51. package/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts +6 -0
  52. package/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts.map +1 -0
  53. package/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.d.ts +6 -0
  54. package/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.d.ts.map +1 -0
  55. package/dist/bundle/util/renderLogic/captcha/components/powCaptcha.d.ts +6 -0
  56. package/dist/bundle/util/renderLogic/captcha/components/powCaptcha.d.ts.map +1 -0
  57. package/dist/bundle/util/renderLogic/captcha/componentsList.d.ts +6 -0
  58. package/dist/bundle/util/renderLogic/captcha/componentsList.d.ts.map +1 -0
  59. package/dist/bundle/util/renderLogic/webComponent.d.ts +8 -0
  60. package/dist/bundle/util/renderLogic/webComponent.d.ts.map +1 -0
  61. package/dist/bundle/util/renderLogic/widgetRenderer.d.ts +24 -0
  62. package/dist/bundle/util/renderLogic/widgetRenderer.d.ts.map +1 -0
  63. package/dist/bundle/util/renderLogic.d.ts +2 -3
  64. package/dist/bundle/util/renderLogic.d.ts.map +1 -1
  65. package/dist/util/defaultCallbacks.d.ts +4 -12
  66. package/dist/util/defaultCallbacks.d.ts.map +1 -1
  67. package/dist/util/defaultCallbacks.js.map +1 -1
  68. package/dist/util/renderLogic/captcha/captcha.d.ts +11 -0
  69. package/dist/util/renderLogic/captcha/captcha.d.ts.map +1 -0
  70. package/dist/util/renderLogic/captcha/captcha.js +5 -0
  71. package/dist/util/renderLogic/captcha/captcha.js.map +1 -0
  72. package/dist/util/renderLogic/captcha/captchaRenderer.d.ts +8 -0
  73. package/dist/util/renderLogic/captcha/captchaRenderer.d.ts.map +1 -0
  74. package/dist/util/renderLogic/captcha/captchaRenderer.js +11 -0
  75. package/dist/util/renderLogic/captcha/captchaRenderer.js.map +1 -0
  76. package/dist/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts +6 -0
  77. package/dist/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts.map +1 -0
  78. package/dist/util/renderLogic/captcha/components/frictionlessCaptcha.js +11 -0
  79. package/dist/util/renderLogic/captcha/components/frictionlessCaptcha.js.map +1 -0
  80. package/dist/util/renderLogic/captcha/components/imageCaptcha.d.ts +6 -0
  81. package/dist/util/renderLogic/captcha/components/imageCaptcha.d.ts.map +1 -0
  82. package/dist/util/renderLogic/captcha/components/imageCaptcha.js +11 -0
  83. package/dist/util/renderLogic/captcha/components/imageCaptcha.js.map +1 -0
  84. package/dist/util/renderLogic/captcha/components/powCaptcha.d.ts +6 -0
  85. package/dist/util/renderLogic/captcha/components/powCaptcha.d.ts.map +1 -0
  86. package/dist/util/renderLogic/captcha/components/powCaptcha.js +11 -0
  87. package/dist/util/renderLogic/captcha/components/powCaptcha.js.map +1 -0
  88. package/dist/util/renderLogic/captcha/componentsList.d.ts +6 -0
  89. package/dist/util/renderLogic/captcha/componentsList.d.ts.map +1 -0
  90. package/dist/util/renderLogic/captcha/componentsList.js +11 -0
  91. package/dist/util/renderLogic/captcha/componentsList.js.map +1 -0
  92. package/dist/util/renderLogic/webComponent.d.ts +8 -0
  93. package/dist/util/renderLogic/webComponent.d.ts.map +1 -0
  94. package/dist/util/renderLogic/webComponent.js +24 -0
  95. package/dist/util/renderLogic/webComponent.js.map +1 -0
  96. package/dist/util/renderLogic/widgetRenderer.d.ts +24 -0
  97. package/dist/util/renderLogic/widgetRenderer.d.ts.map +1 -0
  98. package/dist/util/renderLogic/widgetRenderer.js +52 -0
  99. package/dist/util/renderLogic/widgetRenderer.js.map +1 -0
  100. package/dist/util/renderLogic.d.ts +2 -3
  101. package/dist/util/renderLogic.d.ts.map +1 -1
  102. package/dist/util/renderLogic.js +11 -57
  103. package/dist/util/renderLogic.js.map +1 -1
  104. package/package.json +9 -9
  105. package/stats.html +1 -1
  106. package/dist/bundle/ProcaptchaWidget-DGAVVetC.js +0 -652
@@ -0,0 +1,628 @@
1
+ import { u as ce, h as le, z as O, r as f, l as _, d as L, j as s, a as b, P as k, b as g, c as $, e as y, A as p, f as S, p as F, g as de, i as ue, k as he, m as pe, n as ge, o as X, E as fe, R as me, q as xe, W as Ce, C as be, s as Ae, t as ye, v as we, w as Te, x as Ee, y as Se, L as Ie, B as ve, D as Ne, F as De } from "./index-B27PXNfK.js";
2
+ import { u as q, s as Y, g as He, b as Re, a as ke, E as _e, c as Le, C as Pe } from "./Checkbox-DM6n1-r-.js";
3
+ const Me = (t) => Array.isArray(t) && t !== null, G = new Array(256), J = new Array(256 * 256);
4
+ for (let t = 0; t < 256; t++)
5
+ G[t] = t.toString(16).padStart(2, "0");
6
+ for (let t = 0; t < 256; t++) {
7
+ const e = t << 8;
8
+ for (let n = 0; n < 256; n++)
9
+ J[e | n] = G[t] + G[n];
10
+ }
11
+ function U(t, e) {
12
+ const n = t.length % 2 | 0, r = t.length - n | 0;
13
+ for (let a = 0; a < r; a += 2)
14
+ e += J[t[a] << 8 | t[a + 1]];
15
+ return n && (e += G[t[r] | 0]), e;
16
+ }
17
+ function Oe(t, e = -1, n = !0) {
18
+ const r = n ? "0x" : "";
19
+ if (!(t != null && t.length))
20
+ return r;
21
+ if (e > 0) {
22
+ const a = Math.ceil(e / 8);
23
+ if (t.length > a)
24
+ return `${U(t.subarray(0, a / 2), r)}…${U(t.subarray(t.length - a / 2), "")}`;
25
+ }
26
+ return U(t, r);
27
+ }
28
+ const Ge = (t) => Me(t) ? Oe(new Uint8Array(t)) : t.toString();
29
+ function We(t) {
30
+ return ce(le(t));
31
+ }
32
+ const Z = O.object({
33
+ account: O.string().optional(),
34
+ blockNumber: O.number().optional(),
35
+ providerUrl: O.string().optional()
36
+ }), Be = {
37
+ border: "none",
38
+ paddingTop: "6px",
39
+ paddingBottom: "6px",
40
+ cursor: "pointer",
41
+ height: "39px",
42
+ width: "39px",
43
+ borderRadius: "50%"
44
+ }, Ue = ({ themeColor: t, onReload: e }) => {
45
+ const n = f.useMemo(() => t === "light" ? _ : L, [t]), [r, a] = f.useState(!1), i = f.useMemo(() => ({
46
+ ...{
47
+ ...Be,
48
+ backgroundColor: n.palette.background.default,
49
+ color: r ? n.palette.primary.contrastText : n.palette.background.contrastText
50
+ },
51
+ backgroundColor: r ? n.palette.grey[700] : n.palette.background.default
52
+ }), [r, n]);
53
+ return s("button", { className: "reload-button", "aria-label": "Reload", type: "button", style: i, onMouseEnter: () => a(!0), onMouseLeave: () => a(!1), onClick: (o) => {
54
+ o.preventDefault(), e();
55
+ }, children: b("svg", { width: "27px", height: "27px", viewBox: "0 0 27 27", version: "1.1", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", children: [s("title", { children: "reload" }), s("path", { fill: i.color, transform: "scale(0.0703125)", d: "M234.666667,149.333333 L234.666667,106.666667 L314.564847,106.664112 C287.579138,67.9778918 242.745446,42.6666667 192,42.6666667 C109.525477,42.6666667 42.6666667,109.525477 42.6666667,192 C42.6666667,274.474523 109.525477,341.333333 192,341.333333 C268.201293,341.333333 331.072074,284.258623 340.195444,210.526102 L382.537159,215.817985 C370.807686,310.617565 289.973536,384 192,384 C85.961328,384 1.42108547e-14,298.038672 1.42108547e-14,192 C1.42108547e-14,85.961328 85.961328,1.42108547e-14 192,1.42108547e-14 C252.316171,1.42108547e-14 306.136355,27.8126321 341.335366,71.3127128 L341.333333,1.42108547e-14 L384,1.42108547e-14 L384,149.333333 L234.666667,149.333333 Z" })] }) });
56
+ }, je = (t) => {
57
+ if (!t.hash)
58
+ throw new k("CAPTCHA.MISSING_ITEM_HASH", {
59
+ context: { item: t }
60
+ });
61
+ return t.hash;
62
+ }, $e = ({ challenge: t, solution: e, onClick: n, themeColor: r }) => {
63
+ const a = t.items, i = f.useMemo(() => r === "light" ? _ : L, [r]), o = `${i.spacing.half}px`;
64
+ return s("div", { style: {
65
+ width: "100%",
66
+ height: "100%",
67
+ display: "flex",
68
+ flexDirection: "row",
69
+ flexWrap: "wrap",
70
+ justifyContent: "space-between",
71
+ paddingBottom: o,
72
+ paddingRight: o
73
+ }, children: a.map((d, c) => {
74
+ const u = je(d);
75
+ return s("div", { style: {
76
+ flexGrow: 1,
77
+ flexBasis: "33.3333%",
78
+ boxSizing: "border-box",
79
+ paddingLeft: o,
80
+ paddingTop: o
81
+ }, children: b("div", { style: {
82
+ position: "relative",
83
+ cursor: "pointer",
84
+ height: "100%",
85
+ width: "100%",
86
+ border: 1,
87
+ padding: 0,
88
+ margin: 0,
89
+ borderStyle: "solid",
90
+ borderColor: i.palette.grey[300]
91
+ }, onClick: () => n(u), children: [s("img", { style: {
92
+ width: "100%",
93
+ backgroundColor: i.palette.grey[300],
94
+ display: "block",
95
+ objectFit: "contain",
96
+ aspectRatio: "1/1",
97
+ height: "auto"
98
+ }, src: d.data, alt: `Captcha image ${c + 1}` }), s("div", { style: {
99
+ position: "absolute",
100
+ top: 0,
101
+ left: 0,
102
+ bottom: 0,
103
+ right: 0,
104
+ height: "100%",
105
+ width: "100%",
106
+ display: "flex",
107
+ alignItems: "center",
108
+ justifyContent: "center",
109
+ backgroundColor: "rgba(0,0,0,0.5)",
110
+ visibility: e.includes(u) ? "visible" : "hidden"
111
+ }, children: s("svg", { style: {
112
+ backgroundColor: "transparent",
113
+ display: "block",
114
+ width: "35%",
115
+ height: "35%",
116
+ transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
117
+ userSelect: "none",
118
+ fill: "currentcolor"
119
+ }, focusable: "false", color: "#fff", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "CheckIcon", "aria-label": "Check icon", children: s("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }) })] }) }, d.hash);
120
+ }) });
121
+ };
122
+ function ze(t = {}) {
123
+ return Object.keys(t).reduce((e, n) => ({ ...e, [`data-${n}`]: t[n] }), {});
124
+ }
125
+ function Q({ general: t, dev: e }) {
126
+ return {
127
+ ...ze(t)
128
+ };
129
+ }
130
+ const Fe = {
131
+ display: "inline-flex",
132
+ alignItems: "center",
133
+ justifyContent: "center",
134
+ position: "relative",
135
+ boxSizing: "border-box",
136
+ outline: "0px",
137
+ border: "0px",
138
+ margin: "0px",
139
+ cursor: "pointer",
140
+ userSelect: "none",
141
+ verticalAlign: "middle",
142
+ appearance: void 0,
143
+ textDecoration: "none",
144
+ fontWeight: "500",
145
+ fontSize: "0.875rem",
146
+ lineHeight: "1.75",
147
+ letterSpacing: "0.02857em",
148
+ textTransform: "uppercase",
149
+ minWidth: "64px",
150
+ padding: "6px 16px",
151
+ borderRadius: "4px",
152
+ transition: "background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
153
+ color: "rgb(0, 0, 0)",
154
+ backgroundColor: "#ffffff",
155
+ 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"
156
+ }, K = ({ themeColor: t, buttonType: e, text: n, onClick: r }) => {
157
+ const a = f.useMemo(() => t === "light" ? _ : L, [t]), [i, o] = f.useState(!1), d = f.useMemo(() => {
158
+ const c = {
159
+ ...Fe,
160
+ color: i ? a.palette.primary.contrastText : a.palette.background.contrastText
161
+ };
162
+ return e === "cancel" ? {
163
+ ...c,
164
+ backgroundColor: i ? a.palette.grey[600] : "transparent"
165
+ } : {
166
+ ...c,
167
+ backgroundColor: i ? a.palette.primary.main : a.palette.background.default
168
+ };
169
+ }, [e, i, a]);
170
+ return s("button", { ...Q({ dev: { cy: `button-${e}` } }), onMouseEnter: () => o(!0), onMouseLeave: () => o(!1), style: d, onClick: (c) => {
171
+ c.preventDefault(), r();
172
+ }, "aria-label": n, children: n });
173
+ }, Ke = ({ challenge: t, index: e, solutions: n, onSubmit: r, onCancel: a, onClick: i, onNext: o, onReload: d, themeColor: c }) => {
174
+ const { t: u } = q(), w = t.captchas ? g(t.captchas, e) : null, T = n ? g(n, e) : [], A = f.useMemo(() => c === "light" ? _ : L, [c]), I = `${A.spacing.unit}px`, v = `${A.spacing.half}px`;
175
+ return s(f.Suspense, { fallback: s("div", { children: "Loading..." }), children: s("div", { style: {
176
+ overflowX: "auto",
177
+ overflowY: "auto",
178
+ width: "100%",
179
+ maxWidth: "500px",
180
+ maxHeight: "100%",
181
+ display: "flex",
182
+ flexDirection: "column",
183
+ border: "1px solid #dddddd",
184
+ boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
185
+ borderRadius: "4px",
186
+ backgroundColor: A.palette.background.default,
187
+ userSelect: "none",
188
+ touchAction: "none",
189
+ overscrollBehavior: "none"
190
+ }, children: b("div", { style: {
191
+ backgroundColor: A.palette.background.default,
192
+ display: "flex",
193
+ flexDirection: "column",
194
+ minWidth: "300px"
195
+ }, children: [s("div", { style: {
196
+ display: "flex",
197
+ alignItems: "center",
198
+ width: "100%"
199
+ }, children: s("div", { style: {
200
+ backgroundColor: A.palette.primary.main,
201
+ width: "100%",
202
+ marginTop: I,
203
+ marginLeft: I,
204
+ marginRight: I
205
+ }, children: b("div", { style: {
206
+ paddingLeft: `${A.spacing.half}px`,
207
+ paddingRight: `${A.spacing.half}px`
208
+ }, children: [b("p", { style: {
209
+ color: "#ffffff",
210
+ fontWeight: 700,
211
+ lineHeight: 1.5
212
+ }, children: [u("WIDGET.SELECT_ALL"), ":", " ", s("span", { children: `${u(g(t.captchas, e).target)} ` })] }), s("p", { style: {
213
+ color: "#ffffff",
214
+ fontWeight: 500,
215
+ lineHeight: 0.8,
216
+ fontSize: "0.8rem"
217
+ }, children: u("WIDGET.IF_NONE_CLICK_NEXT") })] }) }) }), s("div", { ...Q({ dev: { cy: `captcha-${e}` } }), style: {
218
+ paddingRight: v,
219
+ paddingLeft: v
220
+ }, children: w && s($e, { challenge: w, solution: T, onClick: i, themeColor: c }) }), s("div", { style: {
221
+ display: "flex",
222
+ alignItems: "center",
223
+ justifyContent: "space-between",
224
+ lineHeight: 1.75,
225
+ padding: I,
226
+ paddingBottom: v,
227
+ paddingTop: v
228
+ }, children: b("div", { style: {
229
+ display: "grid",
230
+ gridAutoFlow: "column",
231
+ gridTemplateColumns: "repeat(3, minmax(0, 1fr)",
232
+ width: "100%"
233
+ }, children: [s("div", { style: { justifySelf: "left" }, children: s(K, { themeColor: c, buttonType: "cancel", onClick: a, text: u("WIDGET.CANCEL"), "aria-label": u("WIDGET.CANCEL") }) }), s("div", { style: { justifySelf: "center" }, children: s(Ue, { themeColor: c, onReload: d }) }), s("div", { style: { justifySelf: "right" }, children: s(K, { themeColor: c, buttonType: "next", text: e < t.captchas.length - 1 ? u("WIDGET.NEXT") : u("WIDGET.SUBMIT"), onClick: e < t.captchas.length - 1 ? o : r, "aria-label": e < t.captchas.length - 1 ? u("WIDGET.NEXT") : u("WIDGET.SUBMIT"), "data-cy": "button-next" }) })] }) })] }) }) });
234
+ };
235
+ function Ve(t) {
236
+ return $([
237
+ t.captchaId,
238
+ t.captchaContentId,
239
+ [...t.solution].sort(),
240
+ t.salt
241
+ ]);
242
+ }
243
+ class V {
244
+ constructor(e) {
245
+ this.hash = e, this.parent = null;
246
+ }
247
+ }
248
+ class Xe {
249
+ constructor() {
250
+ this.leaves = [], this.layers = [];
251
+ }
252
+ getRoot() {
253
+ if (this.root === void 0)
254
+ throw new y("DATASET.MERKLE_ERROR", {
255
+ context: {
256
+ error: "root undefined",
257
+ failedFuncName: this.getRoot.name
258
+ }
259
+ });
260
+ return this.root;
261
+ }
262
+ build(e) {
263
+ this.layers.length && (this.layers = []);
264
+ const n = [];
265
+ for (const r of e) {
266
+ const a = new V(r);
267
+ this.leaves.push(a), n.push(a.hash);
268
+ }
269
+ this.layers.push(n), this.root = this.buildMerkleTree(this.leaves)[0];
270
+ }
271
+ buildMerkleTree(e) {
272
+ const n = e.length;
273
+ if (n === 1)
274
+ return e;
275
+ const r = [];
276
+ let a = 0;
277
+ const i = [];
278
+ for (; a < n; ) {
279
+ const o = e[a];
280
+ if (o === void 0)
281
+ throw new y("DEVELOPER.GENERAL", {
282
+ context: { error: "leftChild undefined" }
283
+ });
284
+ const d = a + 1 < n ? g(e, a + 1) : o, c = this.createParent(o, d);
285
+ i.push(c.hash), r.push(c), a += 2;
286
+ }
287
+ return this.layers.push(i), this.buildMerkleTree(r);
288
+ }
289
+ createParent(e, n) {
290
+ const r = new V($([e.hash, n.hash]));
291
+ return e.parent = r.hash, n.parent = r.hash, r;
292
+ }
293
+ proof(e) {
294
+ const n = [];
295
+ let r = 0;
296
+ for (; r < this.layers.length - 1; ) {
297
+ const i = this.layers[r];
298
+ if (i === void 0)
299
+ throw new y("DATASET.MERKLE_ERROR", {
300
+ context: {
301
+ error: "layer undefined",
302
+ failedFuncName: this.proof.name,
303
+ layerNum: r
304
+ }
305
+ });
306
+ const o = i.indexOf(e);
307
+ let d = o % 2 && o > 0 ? o - 1 : o + 1;
308
+ d > i.length - 1 && (d = o);
309
+ const c = [e], u = g(i, d);
310
+ d > o ? c.push(u) : c.unshift(u), n.push([g(c, 0), g(c, 1)]), r += 1, e = $(c);
311
+ }
312
+ const a = g(this.layers, this.layers.length - 1);
313
+ return [...n, [g(a, 0)]];
314
+ }
315
+ }
316
+ class qe {
317
+ constructor(e, n, r, a, i) {
318
+ this.userAccount = e, this.provider = n, this.providerApi = r, this._web2 = a, this.dappAccount = i;
319
+ }
320
+ get web2() {
321
+ return this._web2;
322
+ }
323
+ async getCaptchaChallenge() {
324
+ try {
325
+ const e = await this.providerApi.getCaptchaChallenge(this.userAccount, this.provider);
326
+ if (e[p.error])
327
+ return e;
328
+ if (window.location.protocol === "https:" || window.location.protocol === "http:")
329
+ for (const n of e.captchas)
330
+ for (const r of n.items)
331
+ r.data && (r.data = r.data.replace(/^http(s)*:\/\//, "//"));
332
+ return e;
333
+ } catch (e) {
334
+ throw new S("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
335
+ context: { error: e }
336
+ });
337
+ }
338
+ }
339
+ async submitCaptchaSolution(e, n, r, a, i) {
340
+ const o = new Xe(), d = r.map((T) => Ve(T));
341
+ if (o.build(d), !o.root)
342
+ throw new k("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
343
+ context: { error: "Merkle tree root is undefined" }
344
+ });
345
+ const c = o.root.hash, u = void 0;
346
+ let w;
347
+ try {
348
+ w = await this.providerApi.submitCaptchaSolution(r, n, this.userAccount, a, i, e);
349
+ } catch (T) {
350
+ throw new k("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
351
+ context: { error: T }
352
+ });
353
+ }
354
+ return [w, c, u];
355
+ }
356
+ }
357
+ const ee = "@prosopo/procaptcha";
358
+ function z() {
359
+ return Z.parse(JSON.parse(We(localStorage.getItem(ee) || "0x7b7d")));
360
+ }
361
+ function te(t) {
362
+ localStorage.setItem(ee, Y(JSON.stringify(Z.parse(t))));
363
+ }
364
+ function Ye(t) {
365
+ te({ ...z(), account: t });
366
+ }
367
+ function Je() {
368
+ return z().account || null;
369
+ }
370
+ const j = {
371
+ setAccount: Ye,
372
+ getAccount: Je,
373
+ setProcaptchaStorage: te,
374
+ getProcaptchaStorage: z
375
+ }, Ze = () => ({
376
+ showModal: !1,
377
+ loading: !1,
378
+ index: 0,
379
+ challenge: void 0,
380
+ solutions: void 0,
381
+ isHuman: !1,
382
+ captchaApi: void 0,
383
+ account: void 0
384
+ });
385
+ function Qe(t, e, n, r, a) {
386
+ const i = He(n, e, r), o = Re(e, n), d = () => {
387
+ const l = {
388
+ userAccountAddress: "",
389
+ ...t
390
+ };
391
+ return e.account && (l.userAccountAddress = e.account.account.address), X.parse(l);
392
+ }, c = async () => {
393
+ i.onOpen(), await F(async () => {
394
+ if (e.loading || e.isHuman)
395
+ return;
396
+ await de(), N(), o({ loading: !0 }), o({
397
+ attemptCount: e.attemptCount ? e.attemptCount + 1 : 1
398
+ });
399
+ const l = d();
400
+ o({ dappAccount: l.account.address }), await ke(100);
401
+ const h = await oe(), x = await ue(d()), m = x.provider.url, D = await v(m), B = new qe(h.account.address, x, D, l.web2, l.account.address || "");
402
+ o({ captchaApi: B });
403
+ const C = await B.getCaptchaChallenge();
404
+ if (C.error)
405
+ o({
406
+ loading: !1,
407
+ error: C.error.message
408
+ });
409
+ else {
410
+ if (C.captchas.length <= 0)
411
+ throw new k("DEVELOPER.PROVIDER_NO_CAPTCHA");
412
+ const M = C.captchas.map((R) => R.timeLimitMs || l.captchas.image.challengeTimeout).reduce((R, E) => R + E), H = setTimeout(() => {
413
+ i.onChallengeExpired(), o({ isHuman: !1, showModal: !1, loading: !1 });
414
+ }, M);
415
+ o({
416
+ index: 0,
417
+ solutions: C.captchas.map(() => []),
418
+ challenge: C,
419
+ showModal: !0,
420
+ timeout: H
421
+ });
422
+ }
423
+ }, c, N, e.attemptCount, 10);
424
+ }, u = async () => {
425
+ await F(async () => {
426
+ if (P(), !e.challenge)
427
+ throw new y("CAPTCHA.NO_CAPTCHA", {
428
+ context: { error: "Cannot submit, no Captcha found in state" }
429
+ });
430
+ o({ showModal: !1 });
431
+ const l = e.challenge, h = he(), x = e.challenge.captchas.map((E, se) => {
432
+ const ie = g(e.solutions, se);
433
+ return {
434
+ captchaId: E.captchaId,
435
+ captchaContentId: E.captchaContentId,
436
+ salt: h,
437
+ solution: ie
438
+ };
439
+ }), m = W(), D = re(m).signer;
440
+ if (!g(l.captchas, 0).datasetId)
441
+ throw new k("CAPTCHA.INVALID_CAPTCHA_ID", {
442
+ context: { error: "No datasetId set for challenge" }
443
+ });
444
+ const C = e.captchaApi;
445
+ if (!C)
446
+ throw new y("CAPTCHA.INVALID_TOKEN", {
447
+ context: { error: "No Captcha API found in state" }
448
+ });
449
+ if (!D || !D.signRaw)
450
+ throw new S("GENERAL.CANT_FIND_KEYRINGPAIR", {
451
+ context: {
452
+ error: "Signer is not defined, cannot sign message to prove account ownership"
453
+ }
454
+ });
455
+ const M = await D.signRaw({
456
+ address: m.account.address,
457
+ data: Y(l[p.timestamp]),
458
+ type: "bytes"
459
+ }), H = await C.submitCaptchaSolution(M.signature, l.requestHash, x, l.timestamp, l.signature.provider.requestHash), R = H[0].verified;
460
+ if (o({
461
+ submission: H,
462
+ isHuman: R,
463
+ loading: !1
464
+ }), e.isHuman) {
465
+ const E = C.provider.provider.url;
466
+ j.setProcaptchaStorage({
467
+ ...j.getProcaptchaStorage(),
468
+ providerUrl: E
469
+ }), i.onHuman(pe({
470
+ [p.providerUrl]: E,
471
+ [p.user]: m.account.address,
472
+ [p.dapp]: ae(),
473
+ [p.commitmentId]: Ge(H[1]),
474
+ [p.timestamp]: l.timestamp,
475
+ [p.signature]: {
476
+ [p.provider]: {
477
+ [p.requestHash]: l.signature.provider.requestHash
478
+ },
479
+ [p.user]: {
480
+ [p.timestamp]: M.signature
481
+ }
482
+ }
483
+ })), ne();
484
+ } else
485
+ i.onFailed();
486
+ }, c, N, e.attemptCount, 10);
487
+ }, w = async () => {
488
+ P(), N(), i.onClose();
489
+ }, T = async () => {
490
+ P(), N(), i.onClose(), await c();
491
+ }, A = (l) => {
492
+ if (!e.challenge)
493
+ throw new y("CAPTCHA.NO_CAPTCHA", {
494
+ context: { error: "Cannot select, no Captcha found in state" }
495
+ });
496
+ if (e.index >= e.challenge.captchas.length || e.index < 0)
497
+ throw new y("CAPTCHA.NO_CAPTCHA", {
498
+ context: {
499
+ error: "Cannot select, index is out of range for this Captcha"
500
+ }
501
+ });
502
+ const h = e.index, x = e.solutions, m = g(x, h);
503
+ m.includes(l) ? m.splice(m.indexOf(l), 1) : m.push(l), o({ solutions: x });
504
+ }, I = () => {
505
+ if (!e.challenge)
506
+ throw new y("CAPTCHA.NO_CAPTCHA", {
507
+ context: { error: "Cannot select, no Captcha found in state" }
508
+ });
509
+ if (e.index + 1 >= e.challenge.captchas.length)
510
+ throw new y("CAPTCHA.NO_CAPTCHA", {
511
+ context: {
512
+ error: "Cannot select, index is out of range for this Captcha"
513
+ }
514
+ });
515
+ o({ index: e.index + 1 });
516
+ }, v = async (l) => {
517
+ const h = d();
518
+ if (!h.account.address)
519
+ throw new S("GENERAL.SITE_KEY_MISSING");
520
+ return new ge(l, h.account.address);
521
+ }, P = () => {
522
+ window.clearTimeout(Number(e.timeout)), o({ timeout: void 0 });
523
+ }, ne = () => {
524
+ const l = t.captchas.image.solutionTimeout, h = setTimeout(() => {
525
+ o({ isHuman: !1 }), i.onExpired();
526
+ }, l);
527
+ o({ successfullChallengeTimeout: h });
528
+ }, N = () => {
529
+ P(), o(Ze()), i.onReset();
530
+ }, oe = async () => {
531
+ const l = d();
532
+ if (!l.web2 && !l.userAccountAddress)
533
+ throw new S("GENERAL.ACCOUNT_NOT_FOUND", {
534
+ context: { error: "Account address has not been set for web3 mode" }
535
+ });
536
+ const x = await (async () => await (l.web2 ? new fe() : new _e()).getAccount(l))();
537
+ return j.setAccount(x.account.address), o({ account: x }), W();
538
+ }, W = () => {
539
+ if (!e.account)
540
+ throw new S("GENERAL.ACCOUNT_NOT_FOUND", {
541
+ context: { error: "Account not loaded" }
542
+ });
543
+ return e.account;
544
+ }, ae = () => {
545
+ if (!e.dappAccount)
546
+ throw new S("GENERAL.SITE_KEY_MISSING");
547
+ return e.dappAccount;
548
+ }, re = (l) => {
549
+ const h = l || W();
550
+ if (!h.extension)
551
+ throw new S("ACCOUNT.NO_POLKADOT_EXTENSION", {
552
+ context: { error: "Extension not loaded" }
553
+ });
554
+ return h.extension;
555
+ };
556
+ return {
557
+ start: c,
558
+ cancel: w,
559
+ submit: u,
560
+ select: A,
561
+ nextRound: I,
562
+ reload: T
563
+ };
564
+ }
565
+ const et = me.memo((t, e) => {
566
+ const { show: n, children: r } = t, i = {
567
+ position: "fixed",
568
+ zIndex: 2147483646,
569
+ inset: 0,
570
+ display: n ? "block" : "none"
571
+ }, o = {
572
+ position: "fixed",
573
+ display: "flex",
574
+ alignItems: "center",
575
+ justifyContent: "center",
576
+ right: 0,
577
+ bottom: 0,
578
+ top: 0,
579
+ left: 0,
580
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
581
+ zIndex: -1
582
+ }, d = {
583
+ position: "absolute",
584
+ top: "50%",
585
+ left: "50%",
586
+ transform: "translate(-50%, -50%)",
587
+ width: "inherit",
588
+ backgroundColor: "transparent",
589
+ border: "none",
590
+ 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,"
591
+ };
592
+ return b("div", { className: "prosopo-modalOuter", style: i, children: [s("div", { className: "prosopo-modalBackground", style: o }), s("div", { className: "prosopo-modalInner", style: d, children: r })] });
593
+ }), ot = (t) => {
594
+ const { t: e } = q(), n = X.parse(t.config), r = t.callbacks || {}, [a, i] = Le(f.useState, f.useRef), o = Qe(n, a, i, r), d = t.config.theme === "light" ? "light" : "dark", c = t.config.theme === "light" ? _ : L;
595
+ return f.useEffect(() => {
596
+ n.language && xe.changeLanguage(n.language);
597
+ }, [n.language]), s("div", { children: b("div", { style: {
598
+ maxWidth: Ce,
599
+ maxHeight: "100%",
600
+ overflowX: "auto"
601
+ }, children: [s(et, { show: a.showModal, children: a.challenge ? s(Ke, { challenge: a.challenge, index: a.index, solutions: a.solutions, onSubmit: o.submit, onCancel: o.cancel, onClick: o.select, onNext: o.nextRound, onReload: o.reload, themeColor: n.theme ?? "light" }) : s("div", { children: "No challenge set." }) }), s(be, { children: s(Ae, { children: b("div", { style: ye, "data-cy": "button-human", children: [" ", b("div", { style: {
602
+ padding: we,
603
+ border: Te,
604
+ backgroundColor: c.palette.background.default,
605
+ borderColor: c.palette.grey[300],
606
+ borderRadius: Ee,
607
+ display: "flex",
608
+ alignItems: "center",
609
+ flexWrap: "wrap",
610
+ justifyContent: "space-between",
611
+ minHeight: `${Se}px`,
612
+ overflow: "hidden"
613
+ }, children: [s("div", { style: { display: "inline-flex", flexDirection: "column" }, children: s("div", { style: {
614
+ alignItems: "center",
615
+ flex: 1
616
+ }, children: s("div", { style: {
617
+ display: "flex",
618
+ alignItems: "center",
619
+ justifyContent: "center",
620
+ flexDirection: "column",
621
+ verticalAlign: "middle"
622
+ }, children: s("div", { style: {
623
+ display: "flex"
624
+ }, children: a.loading ? s(Ie, { themeColor: d, "aria-label": "Loading spinner" }) : s(Pe, { themeColor: d, onChange: o.start, checked: a.isHuman, labelText: e("WIDGET.I_AM_HUMAN"), error: a.error, "aria-label": "human checkbox" }) }) }) }) }), s("div", { style: { display: "inline-flex", flexDirection: "column" }, children: s("a", { href: ve, target: "_blank", "aria-label": Ne, children: s("div", { style: { flex: 1 }, children: s(De, { themeColor: d, "aria-label": "Prosopo logo" }) }) }) })] })] }) }) })] }) });
625
+ };
626
+ export {
627
+ ot as default
628
+ };