@prosopo/procaptcha-bundle 2.3.2 → 2.4.1

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