diff --git a/README.md b/README.md index 51c5b86..19e44a9 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ https://altcha.org - [PHP](https://github.com/altcha-org/altcha-lib-php) - [Go](https://github.com/altcha-org/altcha-lib-go) - [Python](https://github.com/altcha-org/altcha-lib-py) +- [Java](https://github.com/altcha-org/altcha-lib-java) +- [Ruby](https://github.com/altcha-org/altcha-lib-rb) ## Plugins @@ -89,7 +91,9 @@ Required options (at least one is required): Additional options: +- __analytics__ - Enable analytics with [ALTCHA Forms](https://altcha.org/forms/). See [HTML submissions documentation](https://altcha.org/docs/forms/features/html-submissions). - __auto__ - Automatically verify without user interaction (possible values: `onfocus`, `onload`, `onsubmit`). +- __beaconurl__ - URL to which analytics data will be sent using a beacon POST if the form is abandoned. This option is only used when `analytics` is enabled. - __blockspam__ - Only used in conjunction with the `spamfilter` option. If enabled, it will block form submission and fail verification if the Spam Filter returns a negative classification. This effectively prevents submission of the form. - __delay__ - The artificial delay in milliseconds to apply before the verification (defaults to 0). - __expire__ - The challenge expiration (duration in milliseconds). @@ -103,7 +107,7 @@ Additional options: - __spamfilter__ - Enable [Spam Filter](#spam-filter). - __strings__ - JSON-encoded translation strings. Refer to [customization](/docs/widget-customization). - __refetchonexpire__ - Automatically re-fetch and re-validate when the challenge expires (defaults to true). -- __verifyurl__ - Enable server-side verification by configuring the URL to use for verification requests. This option can be used in conjunction with `spamfilter` to enable server-side verification. +- __verifyurl__ - URL for server-side verification requests. This option is automatically configured when the `spamfilter` option is used. Override this setting only if you are using a custom server implementation. - __workers__ - The number of workers to utilize for PoW (defaults to `navigator.hardwareConcurrency || 8`, max. value `16`). - __workerurl__ - The URL of the Worker script (defaults to `./worker.js`, only works with `external` build). @@ -135,35 +139,41 @@ Available configuration options: ```ts export interface Configure { - auto?: 'onload' | 'onsubmit'; + analytics?: boolean | string; + auto?: 'onfocus' | 'onload' | 'onsubmit'; + beaconurl?: string; challenge?: { algorithm: string; challenge: string; + maxnumber?: number; salt: string; signature: string; }; + challengeurl?: string; debug?: boolean; delay?: number; expire?: number; floating?: 'auto' | 'top' | 'bottom'; floatinganchor?: string; floatingoffset?: number; + autorenew?: boolean; hidefooter?: boolean; hidelogo?: boolean; maxnumber?: number; mockerror?: boolean; name?: string; refetchonexpire?: boolean; - spamfilter: boolean | 'ipAddress' | SpamFilter; + spamfilter?: boolean | 'ipAddress' | SpamFilter; strings?: { - error?: string; - footer?: string; - label?: string; - verified?: string; - verifying?: string; - waitAlert?: string; - }; - test?: boolean | number; + error: string; + expired: string; + footer: string; + label: string; + verified: string; + verifying: string; + waitAlert: string; + } + test?: boolean | number | 'delay'; verifyurl?: string; workers?: number; workerurl?: string; @@ -196,7 +206,7 @@ document.querySelector('#altcha').addEventListener('statechange', (ev) => { ``` > [!IMPORTANT] -> Both programmatic configuration and event listeners have to called/attached after the ALTCHA script loads, such as within window.addEventListener('load', ...). +> Both programmatic configuration and event listeners have to called/attached after the ALTCHA script loads, such as within `window.addEventListener('load', ...)`. ## Spam Filter diff --git a/dist/altcha.d.ts b/dist/altcha.d.ts index 4eea955..020d6e6 100644 --- a/dist/altcha.d.ts +++ b/dist/altcha.d.ts @@ -17,7 +17,9 @@ declare global { interface AltchaServerVerificationEvent extends CustomEvent> {} interface AltchaWidget { + analytics?: boolean | string; auto?: 'onfocus' | 'onload' | 'onsubmit'; + beaconurl?: string; blockspam?: boolean; challengeurl?: string; challengejson?: string; diff --git a/dist/altcha.js b/dist/altcha.js index fb5edfd..0ad96b4 100644 --- a/dist/altcha.js +++ b/dist/altcha.js @@ -1,277 +1,284 @@ -var _t = Object.defineProperty; -var kt = (r, e, t) => e in r ? _t(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t; -var U = (r, e, t) => kt(r, typeof e != "symbol" ? e + "" : e, t); -const tt = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK", xt = (r) => Uint8Array.from(atob(r), (e) => e.charCodeAt(0)), Be = typeof self < "u" && self.Blob && new Blob([xt(tt)], { type: "text/javascript;charset=utf-8" }); -function Et(r) { +var Bt = Object.defineProperty; +var rt = (n) => { + throw TypeError(n); +}; +var Gt = (n, e, t) => e in n ? Bt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; +var T = (n, e, t) => Gt(n, typeof e != "symbol" ? e + "" : e, t), it = (n, e, t) => e.has(n) || rt("Cannot " + t); +var V = (n, e, t) => (it(n, e, "read from private field"), t ? t.call(n) : e.get(n)), ie = (n, e, t) => e.has(n) ? rt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), ot = (n, e, t, i) => (it(n, e, "write to private field"), i ? i.call(n, t) : e.set(n, t), t); +const wt = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK", Ot = (n) => Uint8Array.from(atob(n), (e) => e.charCodeAt(0)), st = typeof self < "u" && self.Blob && new Blob([Ot(wt)], { type: "text/javascript;charset=utf-8" }); +function Xt(n) { let e; try { - if (e = Be && (self.URL || self.webkitURL).createObjectURL(Be), !e) throw ""; + if (e = st && (self.URL || self.webkitURL).createObjectURL(st), !e) throw ""; const t = new Worker(e, { - name: r == null ? void 0 : r.name + name: n == null ? void 0 : n.name }); return t.addEventListener("error", () => { (self.URL || self.webkitURL).revokeObjectURL(e); }), t; } catch { return new Worker( - "data:text/javascript;base64," + tt, + "data:text/javascript;base64," + wt, { - name: r == null ? void 0 : r.name + name: n == null ? void 0 : n.name } ); } finally { e && (self.URL || self.webkitURL).revokeObjectURL(e); } } -function ie() { +function fe() { } -function rt(r) { - return r(); +function yt(n) { + return n(); } -function He() { +function lt() { return /* @__PURE__ */ Object.create(null); } -function fe(r) { - r.forEach(rt); +function _e(n) { + n.forEach(yt); } -function nt(r) { - return typeof r == "function"; +function _t(n) { + return typeof n == "function"; } -function Ct(r, e) { - return r != r ? e == e : r !== e || r && typeof r == "object" || typeof r == "function"; +function Ht(n, e) { + return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function"; } -function Lt(r) { - return Object.keys(r).length === 0; +function Pt(n) { + return Object.keys(n).length === 0; } -function _(r, e) { - r.appendChild(e); +function E(n, e) { + n.appendChild(e); } -function Rt(r, e, t) { - const i = It(r); +function Wt(n, e, t) { + const i = Yt(n); if (!i.getElementById(e)) { - const o = A("style"); - o.id = e, o.textContent = t, zt(i, o); + const o = R("style"); + o.id = e, o.textContent = t, Kt(i, o); } } -function It(r) { - if (!r) return document; - const e = r.getRootNode ? r.getRootNode() : r.ownerDocument; +function Yt(n) { + if (!n) return document; + const e = n.getRootNode ? n.getRootNode() : n.ownerDocument; return e && /** @type {ShadowRoot} */ e.host ? ( /** @type {ShadowRoot} */ e - ) : r.ownerDocument; + ) : n.ownerDocument; } -function zt(r, e) { - return _( +function Kt(n, e) { + return E( /** @type {Document} */ - r.head || r, + n.head || n, e ), e.sheet; } -function $(r, e, t) { - r.insertBefore(e, t || null); +function S(n, e, t) { + n.insertBefore(e, t || null); +} +function N(n) { + n.parentNode && n.parentNode.removeChild(n); } -function j(r) { - r.parentNode && r.parentNode.removeChild(r); +function R(n) { + return document.createElement(n); } -function A(r) { - return document.createElement(r); +function $(n) { + return document.createElementNS("http://www.w3.org/2000/svg", n); } -function O(r) { - return document.createElementNS("http://www.w3.org/2000/svg", r); +function pt(n) { + return document.createTextNode(n); } -function At(r) { - return document.createTextNode(r); +function J() { + return pt(" "); } -function Y() { - return At(" "); +function Jt() { + return pt(""); } -function xe(r, e, t, i) { - return r.addEventListener(e, t, i), () => r.removeEventListener(e, t, i); +function Se(n, e, t, i) { + return n.addEventListener(e, t, i), () => n.removeEventListener(e, t, i); } -function s(r, e, t) { - t == null ? r.removeAttribute(e) : r.getAttribute(e) !== t && r.setAttribute(e, t); +function a(n, e, t) { + t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t); } -function St(r) { - return Array.from(r.childNodes); +function $t(n) { + return Array.from(n.childNodes); } -function Oe(r, e, t) { - r.classList.toggle(e, !!t); +function at(n, e, t) { + n.classList.toggle(e, !!t); } -function Nt(r, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { - return new CustomEvent(r, { detail: e, bubbles: t, cancelable: i }); +function qt(n, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { + return new CustomEvent(n, { detail: e, bubbles: t, cancelable: i }); } -function Zt(r) { +function Qt(n) { const e = {}; - return r.childNodes.forEach( + return n.childNodes.forEach( /** @param {Element} node */ (t) => { e[t.slot || "default"] = !0; } ), e; } -let ae; -function ce(r) { - ae = r; +let ge; +function me(n) { + ge = n; } -function Re() { - if (!ae) throw new Error("Function called outside component initialization"); - return ae; +function Ue() { + if (!ge) throw new Error("Function called outside component initialization"); + return ge; } -function jt(r) { - Re().$$.on_mount.push(r); +function en(n) { + Ue().$$.on_mount.push(n); } -function Mt(r) { - Re().$$.on_destroy.push(r); +function tn(n) { + Ue().$$.on_destroy.push(n); } -function Tt() { - const r = Re(); +function nn() { + const n = Ue(); return (e, t, { cancelable: i = !1 } = {}) => { - const o = r.$$.callbacks[e]; + const o = n.$$.callbacks[e]; if (o) { - const l = Nt( + const s = qt( /** @type {string} */ e, t, { cancelable: i } ); - return o.slice().forEach((c) => { - c.call(r, l); - }), !l.defaultPrevented; + return o.slice().forEach((u) => { + u.call(n, s); + }), !s.defaultPrevented; } return !0; }; } -const re = [], we = []; -let ne = []; -const We = [], it = /* @__PURE__ */ Promise.resolve(); -let Ce = !1; -function ot() { - Ce || (Ce = !0, it.then(y)); +const se = [], ze = []; +let le = []; +const ct = [], kt = /* @__PURE__ */ Promise.resolve(); +let je = !1; +function Et() { + je || (je = !0, kt.then(_)); } -function Vt() { - return ot(), it; +function rn() { + return Et(), kt; } -function Le(r) { - ne.push(r); +function De(n) { + le.push(n); } -const Ee = /* @__PURE__ */ new Set(); -let te = 0; -function y() { - if (te !== 0) +const Me = /* @__PURE__ */ new Set(); +let oe = 0; +function _() { + if (oe !== 0) return; - const r = ae; + const n = ge; do { try { - for (; te < re.length; ) { - const e = re[te]; - te++, ce(e), $t(e.$$); + for (; oe < se.length; ) { + const e = se[oe]; + oe++, me(e), on(e.$$); } } catch (e) { - throw re.length = 0, te = 0, e; + throw se.length = 0, oe = 0, e; } - for (ce(null), re.length = 0, te = 0; we.length; ) we.pop()(); - for (let e = 0; e < ne.length; e += 1) { - const t = ne[e]; - Ee.has(t) || (Ee.add(t), t()); + for (me(null), se.length = 0, oe = 0; ze.length; ) ze.pop()(); + for (let e = 0; e < le.length; e += 1) { + const t = le[e]; + Me.has(t) || (Me.add(t), t()); } - ne.length = 0; - } while (re.length); - for (; We.length; ) - We.pop()(); - Ce = !1, Ee.clear(), ce(r); + le.length = 0; + } while (se.length); + for (; ct.length; ) + ct.pop()(); + je = !1, Me.clear(), me(n); } -function $t(r) { - if (r.fragment !== null) { - r.update(), fe(r.before_update); - const e = r.dirty; - r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, e), r.after_update.forEach(Le); +function on(n) { + if (n.fragment !== null) { + n.update(), _e(n.before_update); + const e = n.dirty; + n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(De); } } -function Dt(r) { +function sn(n) { const e = [], t = []; - ne.forEach((i) => r.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), ne = e; -} -const Ft = /* @__PURE__ */ new Set(); -function Ut(r, e) { - r && r.i && (Ft.delete(r), r.i(e)); -} -function Gt(r, e, t) { - const { fragment: i, after_update: o } = r.$$; - i && i.m(e, t), Le(() => { - const l = r.$$.on_mount.map(rt).filter(nt); - r.$$.on_destroy ? r.$$.on_destroy.push(...l) : fe(l), r.$$.on_mount = []; - }), o.forEach(Le); -} -function Xt(r, e) { - const t = r.$$; - t.fragment !== null && (Dt(t.after_update), fe(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); -} -function Bt(r, e) { - r.$$.dirty[0] === -1 && (re.push(r), ot(), r.$$.dirty.fill(0)), r.$$.dirty[e / 31 | 0] |= 1 << e % 31; -} -function Ht(r, e, t, i, o, l, c = null, a = [-1]) { - const d = ae; - ce(r); - const f = r.$$ = { + le.forEach((i) => n.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), le = e; +} +const ln = /* @__PURE__ */ new Set(); +function an(n, e) { + n && n.i && (ln.delete(n), n.i(e)); +} +function cn(n, e, t) { + const { fragment: i, after_update: o } = n.$$; + i && i.m(e, t), De(() => { + const s = n.$$.on_mount.map(yt).filter(_t); + n.$$.on_destroy ? n.$$.on_destroy.push(...s) : _e(s), n.$$.on_mount = []; + }), o.forEach(De); +} +function fn(n, e) { + const t = n.$$; + t.fragment !== null && (sn(t.after_update), _e(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); +} +function un(n, e) { + n.$$.dirty[0] === -1 && (se.push(n), Et(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31; +} +function dn(n, e, t, i, o, s, u = null, c = [-1]) { + const l = ge; + me(n); + const f = n.$$ = { fragment: null, ctx: [], // state - props: l, - update: ie, + props: s, + update: fe, not_equal: o, - bound: He(), + bound: lt(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], - context: new Map(e.context || (d ? d.$$.context : [])), + context: new Map(e.context || (l ? l.$$.context : [])), // everything else - callbacks: He(), - dirty: a, + callbacks: lt(), + dirty: c, skip_bound: !1, - root: e.target || d.$$.root + root: e.target || l.$$.root }; - c && c(f.root); - let F = !1; - if (f.ctx = t ? t(r, e.props || {}, (N, G, ...D) => { - const k = D.length ? D[0] : G; - return f.ctx && o(f.ctx[N], f.ctx[N] = k) && (!f.skip_bound && f.bound[N] && f.bound[N](k), F && Bt(r, N)), G; - }) : [], f.update(), F = !0, fe(f.before_update), f.fragment = i ? i(f.ctx) : !1, e.target) { + u && u(f.root); + let B = !1; + if (f.ctx = t ? t(n, e.props || {}, (g, G, ...O) => { + const X = O.length ? O[0] : G; + return f.ctx && o(f.ctx[g], f.ctx[g] = X) && (!f.skip_bound && f.bound[g] && f.bound[g](X), B && un(n, g)), G; + }) : [], f.update(), B = !0, _e(f.before_update), f.fragment = i ? i(f.ctx) : !1, e.target) { if (e.hydrate) { - const N = St(e.target); - f.fragment && f.fragment.l(N), N.forEach(j); + const g = $t(e.target); + f.fragment && f.fragment.l(g), g.forEach(N); } else f.fragment && f.fragment.c(); - e.intro && Ut(r.$$.fragment), Gt(r, e.target, e.anchor), y(); + e.intro && an(n.$$.fragment), cn(n, e.target, e.anchor), _(); } - ce(d); + me(l); } -let lt; -typeof HTMLElement == "function" && (lt = class extends HTMLElement { +let xt; +typeof HTMLElement == "function" && (xt = class extends HTMLElement { constructor(e, t, i) { super(); /** The Svelte component constructor */ - U(this, "$$ctor"); + T(this, "$$ctor"); /** Slots */ - U(this, "$$s"); + T(this, "$$s"); /** The Svelte component instance */ - U(this, "$$c"); + T(this, "$$c"); /** Whether or not the custom element is connected */ - U(this, "$$cn", !1); + T(this, "$$cn", !1); /** Component props data */ - U(this, "$$d", {}); + T(this, "$$d", {}); /** `true` if currently in the process of reflecting component props back to attributes */ - U(this, "$$r", !1); + T(this, "$$r", !1); /** @type {Record} Props definition (name, reflected, type etc) */ - U(this, "$$p_d", {}); + T(this, "$$p_d", {}); /** @type {Record} Event listeners */ - U(this, "$$l", {}); + T(this, "$$l", {}); /** @type {Map} Event listener unsubscribe functions */ - U(this, "$$l_u", /* @__PURE__ */ new Map()); + T(this, "$$l_u", /* @__PURE__ */ new Map()); this.$$ctor = e, this.$$s = t, i && this.attachShadow({ mode: "open" }); } addEventListener(e, t, i) { @@ -289,37 +296,37 @@ typeof HTMLElement == "function" && (lt = class extends HTMLElement { } async connectedCallback() { if (this.$$cn = !0, !this.$$c) { - let e = function(l) { + let e = function(s) { return () => { - let c; + let u; return { c: function() { - c = A("slot"), l !== "default" && s(c, "name", l); + u = R("slot"), s !== "default" && a(u, "name", s); }, /** * @param {HTMLElement} target * @param {HTMLElement} [anchor] */ - m: function(f, F) { - $(f, c, F); + m: function(f, B) { + S(f, u, B); }, d: function(f) { - f && j(c); + f && N(u); } }; }; }; if (await Promise.resolve(), !this.$$cn || this.$$c) return; - const t = {}, i = Zt(this); - for (const l of this.$$s) - l in i && (t[l] = [e(l)]); - for (const l of this.attributes) { - const c = this.$$g_p(l.name); - c in this.$$d || (this.$$d[c] = ve(c, l.value, this.$$p_d, "toProp")); + const t = {}, i = Qt(this); + for (const s of this.$$s) + s in i && (t[s] = [e(s)]); + for (const s of this.attributes) { + const u = this.$$g_p(s.name); + u in this.$$d || (this.$$d[u] = Ae(u, s.value, this.$$p_d, "toProp")); } - for (const l in this.$$p_d) - !(l in this.$$d) && this[l] !== void 0 && (this.$$d[l] = this[l], delete this[l]); + for (const s in this.$$p_d) + !(s in this.$$d) && this[s] !== void 0 && (this.$$d[s] = this[s], delete this[s]); this.$$c = new this.$$ctor({ target: this.shadowRoot || this, props: { @@ -332,23 +339,23 @@ typeof HTMLElement == "function" && (lt = class extends HTMLElement { }); const o = () => { this.$$r = !0; - for (const l in this.$$p_d) - if (this.$$d[l] = this.$$c.$$.ctx[this.$$c.$$.props[l]], this.$$p_d[l].reflect) { - const c = ve( - l, - this.$$d[l], + for (const s in this.$$p_d) + if (this.$$d[s] = this.$$c.$$.ctx[this.$$c.$$.props[s]], this.$$p_d[s].reflect) { + const u = Ae( + s, + this.$$d[s], this.$$p_d, "toAttribute" ); - c == null ? this.removeAttribute(this.$$p_d[l].attribute || l) : this.setAttribute(this.$$p_d[l].attribute || l, c); + u == null ? this.removeAttribute(this.$$p_d[s].attribute || s) : this.setAttribute(this.$$p_d[s].attribute || s, u); } this.$$r = !1; }; this.$$c.$$.after_update.push(o), o(); - for (const l in this.$$l) - for (const c of this.$$l[l]) { - const a = this.$$c.$on(l, c); - this.$$l_u.set(c, a); + for (const s in this.$$l) + for (const u of this.$$l[s]) { + const c = this.$$c.$on(s, u); + this.$$l_u.set(u, c); } this.$$l = {}; } @@ -357,7 +364,7 @@ typeof HTMLElement == "function" && (lt = class extends HTMLElement { // and setting attributes through setAttribute etc, this is helpful attributeChangedCallback(e, t, i) { var o; - this.$$r || (e = this.$$g_p(e), this.$$d[e] = ve(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); + this.$$r || (e = this.$$g_p(e), this.$$d[e] = Ae(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); } disconnectedCallback() { this.$$cn = !1, Promise.resolve().then(() => { @@ -370,10 +377,10 @@ typeof HTMLElement == "function" && (lt = class extends HTMLElement { ) || e; } }); -function ve(r, e, t, i) { - var l; - const o = (l = t[r]) == null ? void 0 : l.type; - if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[r]) +function Ae(n, e, t, i) { + var s; + const o = (s = t[n]) == null ? void 0 : s.type; + if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[n]) return e; if (i === "toAttribute") switch (o) { @@ -400,38 +407,38 @@ function ve(r, e, t, i) { return e; } } -function Ot(r, e, t, i, o, l) { - let c = class extends lt { +function hn(n, e, t, i, o, s) { + let u = class extends xt { constructor() { - super(r, t, o), this.$$p_d = e; + super(n, t, o), this.$$p_d = e; } static get observedAttributes() { return Object.keys(e).map( - (a) => (e[a].attribute || a).toLowerCase() + (c) => (e[c].attribute || c).toLowerCase() ); } }; - return Object.keys(e).forEach((a) => { - Object.defineProperty(c.prototype, a, { + return Object.keys(e).forEach((c) => { + Object.defineProperty(u.prototype, c, { get() { - return this.$$c && a in this.$$c ? this.$$c[a] : this.$$d[a]; + return this.$$c && c in this.$$c ? this.$$c[c] : this.$$d[c]; }, - set(d) { + set(l) { var f; - d = ve(a, d, e), this.$$d[a] = d, (f = this.$$c) == null || f.$set({ [a]: d }); + l = Ae(c, l, e), this.$$d[c] = l, (f = this.$$c) == null || f.$set({ [c]: l }); } }); - }), i.forEach((a) => { - Object.defineProperty(c.prototype, a, { + }), i.forEach((c) => { + Object.defineProperty(u.prototype, c, { get() { - var d; - return (d = this.$$c) == null ? void 0 : d[a]; + var l; + return (l = this.$$c) == null ? void 0 : l[c]; } }); - }), r.element = /** @type {any} */ - c, c; + }), n.element = /** @type {any} */ + u, u; } -class Wt { +class mn { constructor() { /** * ### PRIVATE API @@ -440,7 +447,7 @@ class Wt { * * @type {any} */ - U(this, "$$"); + T(this, "$$"); /** * ### PRIVATE API * @@ -448,11 +455,11 @@ class Wt { * * @type {any} */ - U(this, "$$set"); + T(this, "$$set"); } /** @returns {void} */ $destroy() { - Xt(this, 1), this.$destroy = ie; + fn(this, 1), this.$destroy = fe; } /** * @template {Extract} K @@ -461,8 +468,8 @@ class Wt { * @returns {() => void} */ $on(e, t) { - if (!nt(t)) - return ie; + if (!_t(t)) + return fe; const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); return i.push(t), () => { const o = i.indexOf(t); @@ -474,19 +481,19 @@ class Wt { * @returns {void} */ $set(e) { - this.$$set && !Lt(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); + this.$$set && !Pt(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); } } -const Pt = "4"; -typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(Pt); -const Yt = new TextEncoder(); -function Kt(r) { - return [...new Uint8Array(r)].map((e) => e.toString(16).padStart(2, "0")).join(""); +const gn = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(gn); +const bn = new TextEncoder(); +function vn(n) { + return [...new Uint8Array(n)].map((e) => e.toString(16).padStart(2, "0")).join(""); } -async function Jt(r, e = "SHA-256", t = 1e5) { +async function wn(n, e = "SHA-256", t = 1e5) { const i = Date.now().toString(16); - r || (r = Math.round(Math.random() * t)); - const o = await st(i, r, e); + n || (n = Math.round(Math.random() * t)); + const o = await Ct(i, n, e); return { algorithm: e, challenge: o, @@ -494,610 +501,748 @@ async function Jt(r, e = "SHA-256", t = 1e5) { signature: "" }; } -async function st(r, e, t) { - return Kt( +async function Ct(n, e, t) { + return vn( await crypto.subtle.digest( t.toUpperCase(), - Yt.encode(r + e) + bn.encode(n + e) ) ); } -function qt(r, e, t = "SHA-256", i = 1e6, o = 0) { - const l = new AbortController(), c = Date.now(); +function yn(n, e, t = "SHA-256", i = 1e6, o = 0) { + const s = new AbortController(), u = Date.now(); return { promise: (async () => { - for (let d = o; d <= i; d += 1) { - if (l.signal.aborted) + for (let l = o; l <= i; l += 1) { + if (s.signal.aborted) return null; - if (await st(e, d, t) === r) + if (await Ct(e, l, t) === n) return { - number: d, - took: Date.now() - c + number: l, + took: Date.now() - u }; } return null; })(), - controller: l + controller: s }; } -var b = /* @__PURE__ */ ((r) => (r.ERROR = "error", r.VERIFIED = "verified", r.VERIFYING = "verifying", r.UNVERIFIED = "unverified", r.EXPIRED = "expired", r))(b || {}); -function Qt(r) { - Rt(r, "svelte-ddsc3z", '.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}'); +function Lt() { + try { + return Intl.DateTimeFormat().resolvedOptions().timeZone; + } catch { + } +} +var ae, ce, be, ve, we, ye; +class _n { + constructor(e) { + T(this, "beaconUrl", null); + T(this, "error", null); + T(this, "loadTime", Date.now()); + T(this, "submitTime", null); + T(this, "startTime", null); + T(this, "viewTimeThresholdMs", 1500); + ie(this, ae, {}); + ie(this, ce, null); + ie(this, be, this.onFormChange.bind(this)); + ie(this, ve, this.onFormFocus.bind(this)); + ie(this, we, this.onFormSubmit.bind(this)); + ie(this, ye, this.onUnload.bind(this)); + this.elForm = e, window.addEventListener("unload", V(this, ye)), this.elForm.addEventListener("change", V(this, be)), this.elForm.addEventListener("focusin", V(this, ve)), this.elForm.addEventListener("submit", V(this, we)); + } + data() { + const e = Object.entries(V(this, ae)); + return { + correction: e.length && e.filter(([t, i]) => i > 1).length / e.length || 0, + dropoff: !this.submitTime && !this.error && V(this, ce) ? V(this, ce) : null, + error: this.error, + mobile: this.isMobile(), + start: this.startTime, + submit: this.submitTime, + tz: Lt() + }; + } + dataAsBase64() { + try { + return btoa( + JSON.stringify(this.data()) + ); + } catch (e) { + console.error("failed to encode ALTCHA session data to base64", e); + } + return ""; + } + destroy() { + window.removeEventListener("unload", V(this, ye)), this.elForm.removeEventListener("change", V(this, be)), this.elForm.removeEventListener("focusin", V(this, ve)), this.elForm.removeEventListener("submit", V(this, we)); + } + end() { + this.submitTime || (this.submitTime = Date.now()); + } + getFieldName(e, t = 40) { + const i = e.getAttribute("data-group-label"), o = e.getAttribute("name") || e.getAttribute("aria-label"); + return ((i ? i + ": " : "") + o).slice(0, t); + } + isMobile() { + const e = "userAgentData" in navigator && navigator.userAgentData ? navigator.userAgentData : {}; + return "mobile" in e ? e.mobile === !0 : /Mobi/i.test(window.navigator.userAgent); + } + isInput(e) { + return ["INPUT", "SELECT", "TEXTAREA"].includes(e.tagName); + } + onFormFieldChange(e) { + const t = this.getFieldName(e); + t && this.trackFieldChange(t); + } + onFormChange(e) { + const t = e.target; + t && this.isInput(t) && this.onFormFieldChange(t); + } + onFormFocus(e) { + const t = e.target; + if (this.startTime || this.start(), t && this.isInput(t)) { + const i = this.getFieldName(t); + i && ot(this, ce, i); + } + } + onFormSubmit() { + this.end(); + } + onUnload() { + this.loadTime <= Date.now() - this.viewTimeThresholdMs && !this.submitTime && this.sendBeacon(); + } + async sendBeacon() { + if (this.beaconUrl && "sendBeacon" in navigator) + try { + navigator.sendBeacon( + new URL(this.beaconUrl, location.origin), + JSON.stringify(this.data()) + ); + } catch { + } + } + start() { + this.startTime = Date.now(); + } + trackError(e) { + this.error = e === null ? null : String(e); + } + trackFieldChange(e) { + V(this, ae)[e] = (V(this, ae)[e] || 0) + 1; + } +} +ae = new WeakMap(), ce = new WeakMap(), be = new WeakMap(), ve = new WeakMap(), we = new WeakMap(), ye = new WeakMap(); +var w = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(w || {}); +function pn(n) { + Wt(n, "svelte-ddsc3z", '.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}'); } -function Pe(r) { +function ft(n) { let e, t, i; return { c() { - e = O("svg"), t = O("path"), i = O("path"), s(t, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), s(t, "fill", "currentColor"), s(t, "opacity", ".25"), s(i, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), s(i, "fill", "currentColor"), s(i, "class", "altcha-spinner svelte-ddsc3z"), s(e, "width", "24"), s(e, "height", "24"), s(e, "viewBox", "0 0 24 24"), s(e, "xmlns", "http://www.w3.org/2000/svg"); + e = $("svg"), t = $("path"), i = $("path"), a(t, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), a(t, "fill", "currentColor"), a(t, "opacity", ".25"), a(i, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), a(i, "fill", "currentColor"), a(i, "class", "altcha-spinner svelte-ddsc3z"), a(e, "width", "24"), a(e, "height", "24"), a(e, "viewBox", "0 0 24 24"), a(e, "xmlns", "http://www.w3.org/2000/svg"); }, - m(o, l) { - $(o, e, l), _(e, t), _(e, i); + m(o, s) { + S(o, e, s), E(e, t), E(e, i); }, d(o) { - o && j(e); + o && N(e); } }; } -function er(r) { +function kn(n) { let e, t = ( /*_strings*/ - r[11].label + "" + n[13].label + "" ), i; return { c() { - e = A("label"), s(e, "for", i = /*name*/ - r[4] + "_checkbox"), s(e, "class", "svelte-ddsc3z"); + e = R("label"), a(e, "for", i = /*name*/ + n[4] + "_checkbox"), a(e, "class", "svelte-ddsc3z"); }, - m(o, l) { - $(o, e, l), e.innerHTML = t; + m(o, s) { + S(o, e, s), e.innerHTML = t; }, - p(o, l) { - l[0] & /*_strings*/ - 2048 && t !== (t = /*_strings*/ - o[11].label + "") && (e.innerHTML = t), l[0] & /*name*/ + p(o, s) { + s[0] & /*_strings*/ + 8192 && t !== (t = /*_strings*/ + o[13].label + "") && (e.innerHTML = t), s[0] & /*name*/ 16 && i !== (i = /*name*/ - o[4] + "_checkbox") && s(e, "for", i); + o[4] + "_checkbox") && a(e, "for", i); }, d(o) { - o && j(e); + o && N(e); } }; } -function tr(r) { +function En(n) { let e, t = ( /*_strings*/ - r[11].verifying + "" + n[13].verifying + "" ); return { c() { - e = A("span"); + e = R("span"); }, m(i, o) { - $(i, e, o), e.innerHTML = t; + S(i, e, o), e.innerHTML = t; }, p(i, o) { o[0] & /*_strings*/ - 2048 && t !== (t = /*_strings*/ - i[11].verifying + "") && (e.innerHTML = t); + 8192 && t !== (t = /*_strings*/ + i[13].verifying + "") && (e.innerHTML = t); }, d(i) { - i && j(e); + i && N(e); } }; } -function rr(r) { +function xn(n) { let e, t = ( /*_strings*/ - r[11].verified + "" - ), i, o; + n[13].verified + "" + ), i, o, s, u, c = ( + /*session*/ + n[11] && ut(n) + ); return { c() { - e = A("span"), i = Y(), o = A("input"), s(o, "type", "hidden"), s( + e = R("span"), i = J(), o = R("input"), s = J(), c && c.c(), u = Jt(), a(o, "type", "hidden"), a( o, "name", /*name*/ - r[4] + n[4] ), o.value = /*payload*/ - r[5]; + n[6]; }, - m(l, c) { - $(l, e, c), e.innerHTML = t, $(l, i, c), $(l, o, c); + m(l, f) { + S(l, e, f), e.innerHTML = t, S(l, i, f), S(l, o, f), S(l, s, f), c && c.m(l, f), S(l, u, f); }, - p(l, c) { - c[0] & /*_strings*/ - 2048 && t !== (t = /*_strings*/ - l[11].verified + "") && (e.innerHTML = t), c[0] & /*name*/ - 16 && s( + p(l, f) { + f[0] & /*_strings*/ + 8192 && t !== (t = /*_strings*/ + l[13].verified + "") && (e.innerHTML = t), f[0] & /*name*/ + 16 && a( o, "name", /*name*/ l[4] - ), c[0] & /*payload*/ - 32 && (o.value = /*payload*/ - l[5]); + ), f[0] & /*payload*/ + 64 && (o.value = /*payload*/ + l[6]), /*session*/ + l[11] ? c ? c.p(l, f) : (c = ut(l), c.c(), c.m(u.parentNode, u)) : c && (c.d(1), c = null); }, d(l) { - l && (j(e), j(i), j(o)); + l && (N(e), N(i), N(o), N(s), N(u)), c && c.d(l); + } + }; +} +function ut(n) { + let e; + return { + c() { + e = R("input"), a(e, "type", "hidden"), a(e, "name", "__session"), e.value = /*sessionPayload*/ + n[12]; + }, + m(t, i) { + S(t, e, i); + }, + p(t, i) { + i[0] & /*sessionPayload*/ + 4096 && (e.value = /*sessionPayload*/ + t[12]); + }, + d(t) { + t && N(e); } }; } -function Ye(r) { - let e, t, i, o, l, c, a; +function dt(n) { + let e, t, i, o, s, u, c; return { c() { - e = A("div"), t = A("a"), i = O("svg"), o = O("path"), l = O("path"), c = O("path"), s(o, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), s(o, "fill", "currentColor"), s(l, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), s(l, "fill", "currentColor"), s(c, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), s(c, "fill", "currentColor"), s(i, "width", "22"), s(i, "height", "22"), s(i, "viewBox", "0 0 20 20"), s(i, "fill", "none"), s(i, "xmlns", "http://www.w3.org/2000/svg"), s(t, "href", ct), s(t, "target", "_blank"), s(t, "class", "altcha-logo svelte-ddsc3z"), s(t, "aria-label", a = /*_strings*/ - r[11].ariaLinkLabel); + e = R("div"), t = R("a"), i = $("svg"), o = $("path"), s = $("path"), u = $("path"), a(o, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), a(o, "fill", "currentColor"), a(s, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), a(s, "fill", "currentColor"), a(u, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), a(u, "fill", "currentColor"), a(i, "width", "22"), a(i, "height", "22"), a(i, "viewBox", "0 0 20 20"), a(i, "fill", "none"), a(i, "xmlns", "http://www.w3.org/2000/svg"), a(t, "href", Rt), a(t, "target", "_blank"), a(t, "class", "altcha-logo svelte-ddsc3z"), a(t, "aria-label", c = /*_strings*/ + n[13].ariaLinkLabel); }, - m(d, f) { - $(d, e, f), _(e, t), _(t, i), _(i, o), _(i, l), _(i, c); + m(l, f) { + S(l, e, f), E(e, t), E(t, i), E(i, o), E(i, s), E(i, u); }, - p(d, f) { + p(l, f) { f[0] & /*_strings*/ - 2048 && a !== (a = /*_strings*/ - d[11].ariaLinkLabel) && s(t, "aria-label", a); + 8192 && c !== (c = /*_strings*/ + l[13].ariaLinkLabel) && a(t, "aria-label", c); }, - d(d) { - d && j(e); + d(l) { + l && N(e); } }; } -function Ke(r) { +function ht(n) { let e, t, i, o; - function l(d, f) { + function s(l, f) { return ( /*state*/ - d[6] === b.EXPIRED ? ir : nr + l[7] === w.EXPIRED ? Ln : Cn ); } - let c = l(r), a = c(r); + let u = s(n), c = u(n); return { c() { - e = A("div"), t = O("svg"), i = O("path"), o = Y(), a.c(), s(i, "stroke-linecap", "round"), s(i, "stroke-linejoin", "round"), s(i, "d", "M6 18L18 6M6 6l12 12"), s(t, "width", "14"), s(t, "height", "14"), s(t, "xmlns", "http://www.w3.org/2000/svg"), s(t, "fill", "none"), s(t, "viewBox", "0 0 24 24"), s(t, "stroke-width", "1.5"), s(t, "stroke", "currentColor"), s(e, "class", "altcha-error svelte-ddsc3z"); + e = R("div"), t = $("svg"), i = $("path"), o = J(), c.c(), a(i, "stroke-linecap", "round"), a(i, "stroke-linejoin", "round"), a(i, "d", "M6 18L18 6M6 6l12 12"), a(t, "width", "14"), a(t, "height", "14"), a(t, "xmlns", "http://www.w3.org/2000/svg"), a(t, "fill", "none"), a(t, "viewBox", "0 0 24 24"), a(t, "stroke-width", "1.5"), a(t, "stroke", "currentColor"), a(e, "class", "altcha-error svelte-ddsc3z"); }, - m(d, f) { - $(d, e, f), _(e, t), _(t, i), _(e, o), a.m(e, null); + m(l, f) { + S(l, e, f), E(e, t), E(t, i), E(e, o), c.m(e, null); }, - p(d, f) { - c === (c = l(d)) && a ? a.p(d, f) : (a.d(1), a = c(d), a && (a.c(), a.m(e, null))); + p(l, f) { + u === (u = s(l)) && c ? c.p(l, f) : (c.d(1), c = u(l), c && (c.c(), c.m(e, null))); }, - d(d) { - d && j(e), a.d(); + d(l) { + l && N(e), c.d(); } }; } -function nr(r) { +function Cn(n) { let e, t = ( /*_strings*/ - r[11].error + "" + n[13].error + "" ); return { c() { - e = A("div"), s( + e = R("div"), a( e, "title", /*error*/ - r[10] + n[5] ); }, m(i, o) { - $(i, e, o), e.innerHTML = t; + S(i, e, o), e.innerHTML = t; }, p(i, o) { o[0] & /*_strings*/ - 2048 && t !== (t = /*_strings*/ - i[11].error + "") && (e.innerHTML = t), o[0] & /*error*/ - 1024 && s( + 8192 && t !== (t = /*_strings*/ + i[13].error + "") && (e.innerHTML = t), o[0] & /*error*/ + 32 && a( e, "title", /*error*/ - i[10] + i[5] ); }, d(i) { - i && j(e); + i && N(e); } }; } -function ir(r) { +function Ln(n) { let e, t = ( /*_strings*/ - r[11].expired + "" + n[13].expired + "" ); return { c() { - e = A("div"), s( + e = R("div"), a( e, "title", /*error*/ - r[10] + n[5] ); }, m(i, o) { - $(i, e, o), e.innerHTML = t; + S(i, e, o), e.innerHTML = t; }, p(i, o) { o[0] & /*_strings*/ - 2048 && t !== (t = /*_strings*/ - i[11].expired + "") && (e.innerHTML = t), o[0] & /*error*/ - 1024 && s( + 8192 && t !== (t = /*_strings*/ + i[13].expired + "") && (e.innerHTML = t), o[0] & /*error*/ + 32 && a( e, "title", /*error*/ - i[10] + i[5] ); }, d(i) { - i && j(e); + i && N(e); } }; } -function Je(r) { +function mt(n) { let e, t, i = ( /*_strings*/ - r[11].footer + "" + n[13].footer + "" ); return { c() { - e = A("div"), t = A("div"), s(t, "class", "svelte-ddsc3z"), s(e, "class", "altcha-footer svelte-ddsc3z"); + e = R("div"), t = R("div"), a(t, "class", "svelte-ddsc3z"), a(e, "class", "altcha-footer svelte-ddsc3z"); }, - m(o, l) { - $(o, e, l), _(e, t), t.innerHTML = i; + m(o, s) { + S(o, e, s), E(e, t), t.innerHTML = i; }, - p(o, l) { - l[0] & /*_strings*/ - 2048 && i !== (i = /*_strings*/ - o[11].footer + "") && (t.innerHTML = i); + p(o, s) { + s[0] & /*_strings*/ + 8192 && i !== (i = /*_strings*/ + o[13].footer + "") && (t.innerHTML = i); }, d(o) { - o && j(e); + o && N(e); } }; } -function qe(r) { +function gt(n) { let e; return { c() { - e = A("div"), s(e, "class", "altcha-anchor-arrow svelte-ddsc3z"); + e = R("div"), a(e, "class", "altcha-anchor-arrow svelte-ddsc3z"); }, m(t, i) { - $(t, e, i), r[37](e); + S(t, e, i), n[41](e); }, - p: ie, + p: fe, d(t) { - t && j(e), r[37](null); + t && N(e), n[41](null); } }; } -function or(r) { - let e, t, i, o, l, c, a, d, f, F, N, G, D, k, W, S = ( +function Rn(n) { + let e, t, i, o, s, u, c, l, f, B, g, G, O, X, Y, b = ( /*state*/ - r[6] === b.VERIFYING && Pe() + n[7] === w.VERIFYING && ft() ); - function K(h, v) { + function q(h, p) { return ( /*state*/ - h[6] === b.VERIFIED ? rr : ( + h[7] === w.VERIFIED ? xn : ( /*state*/ - h[6] === b.VERIFYING ? tr : er + h[7] === w.VERIFYING ? En : kn ) ); } - let H = K(r), M = H(r), E = ( + let K = q(n), j = K(n), I = ( /*hidelogo*/ - (r[3] !== !0 || /*isFreeSaaS*/ - r[12]) && Ye(r) - ), R = ( + (n[3] !== !0 || /*isFreeSaaS*/ + n[14]) && dt(n) + ), F = ( /*error*/ - (r[10] || /*state*/ - r[6] === b.EXPIRED) && Ke(r) - ), I = ( + (n[5] || /*state*/ + n[7] === w.EXPIRED) && ht(n) + ), x = ( /*_strings*/ - r[11].footer && /*hidefooter*/ - (r[2] !== !0 || /*isFreeSaaS*/ - r[12]) && Je(r) - ), w = ( + n[13].footer && /*hidefooter*/ + (n[2] !== !0 || /*isFreeSaaS*/ + n[14]) && mt(n) + ), A = ( /*floating*/ - r[1] && qe(r) + n[1] && gt(n) ); return { c() { - e = A("div"), t = A("div"), S && S.c(), i = Y(), o = A("div"), l = A("input"), d = Y(), f = A("div"), M.c(), F = Y(), E && E.c(), N = Y(), R && R.c(), G = Y(), I && I.c(), D = Y(), w && w.c(), s(l, "type", "checkbox"), s(l, "id", c = /*name*/ - r[4] + "_checkbox"), l.required = a = /*auto*/ - r[0] !== "onsubmit", s(l, "class", "svelte-ddsc3z"), s(o, "class", "altcha-checkbox svelte-ddsc3z"), Oe( + e = R("div"), t = R("div"), b && b.c(), i = J(), o = R("div"), s = R("input"), l = J(), f = R("div"), j.c(), B = J(), I && I.c(), g = J(), F && F.c(), G = J(), x && x.c(), O = J(), A && A.c(), a(s, "type", "checkbox"), a(s, "id", u = /*name*/ + n[4] + "_checkbox"), s.required = c = /*auto*/ + n[0] !== "onsubmit", a(s, "class", "svelte-ddsc3z"), a(o, "class", "altcha-checkbox svelte-ddsc3z"), at( o, "altcha-hidden", /*state*/ - r[6] === b.VERIFYING - ), s(f, "class", "altcha-label svelte-ddsc3z"), s(t, "class", "altcha-main svelte-ddsc3z"), s(e, "class", "altcha svelte-ddsc3z"), s( + n[7] === w.VERIFYING + ), a(f, "class", "altcha-label svelte-ddsc3z"), a(t, "class", "altcha-main svelte-ddsc3z"), a(e, "class", "altcha svelte-ddsc3z"), a( e, "data-state", /*state*/ - r[6] - ), s( + n[7] + ), a( e, "data-floating", /*floating*/ - r[1] + n[1] ); }, - m(h, v) { - $(h, e, v), _(e, t), S && S.m(t, null), _(t, i), _(t, o), _(o, l), l.checked = /*checked*/ - r[7], _(t, d), _(t, f), M.m(f, null), _(t, F), E && E.m(t, null), _(e, N), R && R.m(e, null), _(e, G), I && I.m(e, null), _(e, D), w && w.m(e, null), r[38](e), k || (W = [ - xe( - l, + m(h, p) { + S(h, e, p), E(e, t), b && b.m(t, null), E(t, i), E(t, o), E(o, s), s.checked = /*checked*/ + n[8], E(t, l), E(t, f), j.m(f, null), E(t, B), I && I.m(t, null), E(e, g), F && F.m(e, null), E(e, G), x && x.m(e, null), E(e, O), A && A.m(e, null), n[42](e), X || (Y = [ + Se( + s, "change", /*input_change_handler*/ - r[36] + n[40] ), - xe( - l, + Se( + s, "change", /*onCheckedChange*/ - r[13] + n[15] ), - xe( - l, + Se( + s, "invalid", /*onInvalid*/ - r[14] + n[16] ) - ], k = !0); + ], X = !0); }, - p(h, v) { + p(h, p) { /*state*/ - h[6] === b.VERIFYING ? S || (S = Pe(), S.c(), S.m(t, i)) : S && (S.d(1), S = null), v[0] & /*name*/ - 16 && c !== (c = /*name*/ - h[4] + "_checkbox") && s(l, "id", c), v[0] & /*auto*/ - 1 && a !== (a = /*auto*/ - h[0] !== "onsubmit") && (l.required = a), v[0] & /*checked*/ - 128 && (l.checked = /*checked*/ - h[7]), v[0] & /*state*/ - 64 && Oe( + h[7] === w.VERIFYING ? b || (b = ft(), b.c(), b.m(t, i)) : b && (b.d(1), b = null), p[0] & /*name*/ + 16 && u !== (u = /*name*/ + h[4] + "_checkbox") && a(s, "id", u), p[0] & /*auto*/ + 1 && c !== (c = /*auto*/ + h[0] !== "onsubmit") && (s.required = c), p[0] & /*checked*/ + 256 && (s.checked = /*checked*/ + h[8]), p[0] & /*state*/ + 128 && at( o, "altcha-hidden", /*state*/ - h[6] === b.VERIFYING - ), H === (H = K(h)) && M ? M.p(h, v) : (M.d(1), M = H(h), M && (M.c(), M.m(f, null))), /*hidelogo*/ + h[7] === w.VERIFYING + ), K === (K = q(h)) && j ? j.p(h, p) : (j.d(1), j = K(h), j && (j.c(), j.m(f, null))), /*hidelogo*/ h[3] !== !0 || /*isFreeSaaS*/ - h[12] ? E ? E.p(h, v) : (E = Ye(h), E.c(), E.m(t, null)) : E && (E.d(1), E = null), /*error*/ - h[10] || /*state*/ - h[6] === b.EXPIRED ? R ? R.p(h, v) : (R = Ke(h), R.c(), R.m(e, G)) : R && (R.d(1), R = null), /*_strings*/ - h[11].footer && /*hidefooter*/ + h[14] ? I ? I.p(h, p) : (I = dt(h), I.c(), I.m(t, null)) : I && (I.d(1), I = null), /*error*/ + h[5] || /*state*/ + h[7] === w.EXPIRED ? F ? F.p(h, p) : (F = ht(h), F.c(), F.m(e, G)) : F && (F.d(1), F = null), /*_strings*/ + h[13].footer && /*hidefooter*/ (h[2] !== !0 || /*isFreeSaaS*/ - h[12]) ? I ? I.p(h, v) : (I = Je(h), I.c(), I.m(e, D)) : I && (I.d(1), I = null), /*floating*/ - h[1] ? w ? w.p(h, v) : (w = qe(h), w.c(), w.m(e, null)) : w && (w.d(1), w = null), v[0] & /*state*/ - 64 && s( + h[14]) ? x ? x.p(h, p) : (x = mt(h), x.c(), x.m(e, O)) : x && (x.d(1), x = null), /*floating*/ + h[1] ? A ? A.p(h, p) : (A = gt(h), A.c(), A.m(e, null)) : A && (A.d(1), A = null), p[0] & /*state*/ + 128 && a( e, "data-state", /*state*/ - h[6] - ), v[0] & /*floating*/ - 2 && s( + h[7] + ), p[0] & /*floating*/ + 2 && a( e, "data-floating", /*floating*/ h[1] ); }, - i: ie, - o: ie, + i: fe, + o: fe, d(h) { - h && j(e), S && S.d(), M.d(), E && E.d(), R && R.d(), I && I.d(), w && w.d(), r[38](null), k = !1, fe(W); + h && N(e), b && b.d(), j.d(), I && I.d(), F && F.d(), x && x.d(), A && A.d(), n[42](null), X = !1, _e(Y); } }; } -const Qe = "Visit Altcha.org", ct = "https://altcha.org/"; -function et(r) { - return JSON.parse(r); -} -function lr() { - try { - return Intl.DateTimeFormat().resolvedOptions().timeZone; - } catch { - } +const bt = "Visit Altcha.org", Rt = "https://altcha.org/"; +function vt(n) { + return JSON.parse(n); } -function sr(r, e, t) { - var Ge, Xe; - let i, o, l, c, { auto: a = void 0 } = e, { blockspam: d = void 0 } = e, { challengeurl: f = void 0 } = e, { challengejson: F = void 0 } = e, { debug: N = !1 } = e, { delay: G = 0 } = e, { expire: D = void 0 } = e, { floating: k = void 0 } = e, { floatinganchor: W = void 0 } = e, { floatingoffset: S = void 0 } = e, { hidefooter: K = !1 } = e, { hidelogo: H = !1 } = e, { name: M = "altcha" } = e, { maxnumber: E = 1e6 } = e, { mockerror: R = !1 } = e, { refetchonexpire: I = !0 } = e, { spamfilter: w = !1 } = e, { strings: h = void 0 } = e, { test: v = !1 } = e, { verifyurl: J = void 0 } = e, { workers: oe = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: ue = void 0 } = e; - const ye = Tt(), Ie = ["SHA-256", "SHA-384", "SHA-512"], ze = (Xe = (Ge = document.documentElement.lang) == null ? void 0 : Ge.split("-")) == null ? void 0 : Xe[0]; - let P = !1, C, q = null, de = null, m = null, pe = null, Q = null, T = b.UNVERIFIED, X = null; - Mt(() => { - m && (m.removeEventListener("submit", Se), m.removeEventListener("reset", Ne), m.removeEventListener("focusin", Ae), m = null), X && (clearTimeout(X), X = null), document.removeEventListener("click", Te), document.removeEventListener("scroll", Ve), window.removeEventListener("resize", De); - }), jt(() => { - x("mounted", "0.6.7"), x("workers", oe), v && x("using test mode"), D && he(D), a !== void 0 && x("auto", a), k !== void 0 && Fe(k), m = C.closest("form"), m && (m.addEventListener("submit", Se, { capture: !0 }), m.addEventListener("reset", Ne), a === "onfocus" && m.addEventListener("focusin", Ae)), a === "onload" && ee(), i && (K || H) && x("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution."); +function In(n, e, t) { + var tt, nt; + let i, o, s, u, { analytics: c = !1 } = e, { auto: l = void 0 } = e, { beaconurl: f = void 0 } = e, { blockspam: B = void 0 } = e, { challengeurl: g = void 0 } = e, { challengejson: G = void 0 } = e, { debug: O = !1 } = e, { delay: X = 0 } = e, { expire: Y = void 0 } = e, { floating: b = void 0 } = e, { floatinganchor: q = void 0 } = e, { floatingoffset: K = void 0 } = e, { hidefooter: j = !1 } = e, { hidelogo: I = !1 } = e, { name: F = "altcha" } = e, { maxnumber: x = 1e6 } = e, { mockerror: A = !1 } = e, { refetchonexpire: h = !0 } = e, { spamfilter: p = !1 } = e, { strings: pe = void 0 } = e, { test: H = !1 } = e, { verifyurl: ee = void 0 } = e, { workers: ue = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: ke = void 0 } = e; + const Fe = nn(), Ze = ["SHA-256", "SHA-384", "SHA-512"], Ve = (nt = (tt = document.documentElement.lang) == null ? void 0 : tt.split("-")) == null ? void 0 : nt[0]; + let Q = !1, C, te = null, Ee = null, m = null, xe = null, P = null, ne = null, D = null, Be = null, U = w.UNVERIFIED; + tn(() => { + m && (m.removeEventListener("submit", Oe), m.removeEventListener("reset", Xe), m.removeEventListener("focusin", Ge), m = null), D && D.destroy(), P && (clearTimeout(P), P = null), document.removeEventListener("click", Ke), document.removeEventListener("scroll", Je), window.removeEventListener("resize", qe); + }), en(() => { + k("mounted", "0.7.0"), k("workers", ue), H && k("using test mode"), Y && Ce(Y), l !== void 0 && k("auto", l), b !== void 0 && Qe(b), m = C.closest("form"), m && (m.addEventListener("submit", Oe, { capture: !0 }), m.addEventListener("reset", Xe), l === "onfocus" && m.addEventListener("focusin", Ge)), c && We(), l === "onload" && re(), i && (j || I) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution."); }); - function x(...n) { - (N || n.some((u) => u instanceof Error)) && console[n[0] instanceof Error ? "error" : "log"]("ALTCHA", ...n); + function k(...r) { + (O || r.some((d) => d instanceof Error)) && console[r[0] instanceof Error ? "error" : "log"]("ALTCHA", ...r); } - function Ae(n) { - T === b.UNVERIFIED && ee(); + function Ge(r) { + U === w.UNVERIFIED && re(); } - function Se(n) { - m && a === "onsubmit" && (T === b.UNVERIFIED ? (n.preventDefault(), n.stopPropagation(), ee().then(() => { + function Oe(r) { + m && D && U === w.VERIFIED && (D.end(), t(12, Be = D.dataAsBase64())), m && l === "onsubmit" && (U === w.UNVERIFIED ? (r.preventDefault(), r.stopPropagation(), re().then(() => { m == null || m.requestSubmit(); - })) : T !== b.VERIFIED && (n.preventDefault(), n.stopPropagation(), T === b.VERIFYING && $e())); + })) : U !== w.VERIFIED && (r.preventDefault(), r.stopPropagation(), U === w.VERIFYING && $e())); } - function Ne() { - ge(); + function Xe() { + Le(); } - function Ze(n, u) { + function He(r, d) { return btoa(JSON.stringify({ - algorithm: n.algorithm, - challenge: n.challenge, - number: u.number, - salt: n.salt, - signature: n.signature, - test: v ? !0 : void 0, - took: u.took + algorithm: r.algorithm, + challenge: r.challenge, + number: d.number, + salt: r.salt, + signature: r.signature, + test: H ? !0 : void 0, + took: d.took })); } - function je(n) { - if (!n.algorithm) + function Pe(r) { + if (!r.algorithm) throw new Error("Invalid challenge. Property algorithm is missing."); - if (n.signature === void 0) + if (r.signature === void 0) throw new Error("Invalid challenge. Property signature is missing."); - if (!Ie.includes(n.algorithm.toUpperCase())) - throw new Error(`Unknown algorithm value. Allowed values: ${Ie.join(", ")}`); - if (!n.challenge || n.challenge.length < 40) + if (!Ze.includes(r.algorithm.toUpperCase())) + throw new Error(`Unknown algorithm value. Allowed values: ${Ze.join(", ")}`); + if (!r.challenge || r.challenge.length < 40) throw new Error("Challenge is too short. Min. 40 chars."); - if (!n.salt || n.salt.length < 10) + if (!r.salt || r.salt.length < 10) throw new Error("Salt is too short. Min. 10 chars."); } - async function at() { - var n; - if (R) - throw x("mocking error"), new Error("Mocked error."); + async function It() { + var r; + if (A) + throw k("mocking error"), new Error("Mocked error."); if (o) - return x("using provided json data"), o; - if (v) - return x("generating test challenge", { test: v }), Jt(typeof v != "boolean" ? +v : void 0); + return k("using provided json data"), o; + if (H) + return k("generating test challenge", { test: H }), wn(typeof H != "boolean" ? +H : void 0); { - if (!f) + if (!g && m) { + const y = m.getAttribute("action"); + y != null && y.includes("/form/") && t(17, g = y + "/altcha"); + } + if (!g) throw new Error("Attribute challengeurl not set."); - x("fetching challenge from", f); - const u = await fetch(f, { - headers: { - "x-altcha-spam-filter": w ? "1" : "0" - } + k("fetching challenge from", g); + const d = await fetch(g, { + headers: p ? { "x-altcha-spam-filter": "1" } : {} }); - if (u.status !== 200) - throw new Error(`Server responded with ${u.status}.`); - const g = u.headers.get("Expires"), z = u.headers.get("X-Altcha-Config"), V = await u.json(), Z = new URLSearchParams((n = V.salt.split("?")) == null ? void 0 : n[1]), B = Z.get("expires") || Z.get("expire"); - if (B) { - const p = new Date(+B * 1e3), L = isNaN(p.getTime()) ? 0 : p.getTime() - Date.now(); - L > 0 && he(L); + if (d.status !== 200) + throw new Error(`Server responded with ${d.status}.`); + const v = d.headers.get("Expires"), z = d.headers.get("X-Altcha-Config"), Z = await d.json(), M = new URLSearchParams((r = Z.salt.split("?")) == null ? void 0 : r[1]), W = M.get("expires") || M.get("expire"); + if (W) { + const y = new Date(+W * 1e3), L = isNaN(y.getTime()) ? 0 : y.getTime() - Date.now(); + L > 0 && Ce(L); } if (z) try { - const p = JSON.parse(z); - p && typeof p == "object" && (p.verifyurl && (p.verifyurl = new URL(p.verifyurl, new URL(f)).toString()), Ue(p)); - } catch (p) { - x("unable to configure from X-Altcha-Config", p); + const y = JSON.parse(z); + y && typeof y == "object" && (y.verifyurl && (y.verifyurl = new URL(y.verifyurl, new URL(g)).toString()), et(y)); + } catch (y) { + k("unable to configure from X-Altcha-Config", y); } - if (!D && (g != null && g.length)) { - const p = Date.parse(g); - if (p) { - const L = p - Date.now(); - L > 0 && he(L); + if (!Y && (v != null && v.length)) { + const y = Date.parse(v); + if (y) { + const L = y - Date.now(); + L > 0 && Ce(L); } } - return V; + return Z; } } - function Me() { - f && I && T === b.VERIFIED ? ee() : ge(b.EXPIRED, c.expired); + function We() { + if (!D) + if (m) { + if (k("analytics enabled"), t(11, D = new _n(m)), f === void 0) { + const r = m.getAttribute("action"); + r && t(19, f = r + "/beacon"); + } + t(11, D.beaconUrl = f || null, D); + } else + k("analytics cannot be enabled - form element not found"); + } + function Ye() { + g && h && U === w.VERIFIED ? re() : Le(w.EXPIRED, u.expired); } - async function ft(n) { - let u = null; + async function At(r) { + let d = null; if ("Worker" in window) { try { - u = await ut(n.challenge, n.salt, n.algorithm, n.maxnumber); - } catch (g) { - x(g); + d = await zt(r.challenge, r.salt, r.algorithm, r.maxnumber); + } catch (v) { + k(v); } - if ((u == null ? void 0 : u.number) !== void 0) - return { data: n, solution: u }; + if ((d == null ? void 0 : d.number) !== void 0) + return { data: r, solution: d }; } return { - data: n, - solution: await qt(n.challenge, n.salt, n.algorithm, n.maxnumber || E).promise + data: r, + solution: await yn(r.challenge, r.salt, r.algorithm, r.maxnumber || x).promise }; } - async function ut(n, u, g, z = typeof v == "number" ? v : E, V = Math.ceil(oe)) { - const Z = []; - V = Math.min(16, Math.max(1, V)); - for (let L = 0; L < V; L++) - Z.push(createAltchaWorker(ue)); - const B = Math.ceil(z / V), p = await Promise.all(Z.map((L, ke) => { - const le = ke * B; - return new Promise((me) => { - L.addEventListener("message", (be) => { - if (be.data) - for (const se of Z) - se !== L && se.postMessage({ type: "abort" }); - me(be.data); + async function zt(r, d, v, z = typeof H == "number" ? H : x, Z = Math.ceil(ue)) { + const M = []; + Z = Math.min(16, Math.max(1, Z)); + for (let L = 0; L < Z; L++) + M.push(createAltchaWorker(ke)); + const W = Math.ceil(z / Z), y = await Promise.all(M.map((L, Ne) => { + const de = Ne * W; + return new Promise((Re) => { + L.addEventListener("message", (Ie) => { + if (Ie.data) + for (const he of M) + he !== L && he.postMessage({ type: "abort" }); + Re(Ie.data); }), L.postMessage({ payload: { - alg: g, - challenge: n, - max: le + B, - salt: u, - start: le + alg: v, + challenge: r, + max: de + W, + salt: d, + start: de }, type: "work" }); }); })); - for (const L of Z) + for (const L of M) L.terminate(); - return p.find((L) => !!L) || null; + return y.find((L) => !!L) || null; } - function dt() { - [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(T) ? w && (m == null ? void 0 : m.reportValidity()) === !1 ? t(7, P = !1) : ee() : t(7, P = !0); + function Ft() { + [w.UNVERIFIED, w.ERROR, w.EXPIRED].includes(U) ? p && (m == null ? void 0 : m.reportValidity()) === !1 ? t(8, Q = !1) : re() : t(8, Q = !0); } - function Te(n) { - const u = n.target; - k && u && !C.contains(u) && T === b.VERIFIED && t(8, C.style.display = "none", C); + function Ke(r) { + const d = r.target; + b && d && !C.contains(d) && U === w.VERIFIED && t(9, C.style.display = "none", C); } - function Ve() { - k && _e(); + function Je() { + b && Te(); } function $e() { - T === b.VERIFYING && c.waitAlert && alert(c.waitAlert); + U === w.VERIFYING && u.waitAlert && alert(u.waitAlert); } - function ht(n) { - k && T !== b.UNVERIFIED && requestAnimationFrame(() => { - _e(); + function Tt(r) { + D && D.trackError(xe); + } + function Nt(r) { + b && U !== w.UNVERIFIED && requestAnimationFrame(() => { + Te(); }); } - function De() { - k && _e(); + function qe() { + b && Te(); } - function he(n) { - x("expire", n), X && (clearTimeout(X), X = null), n < 1 ? Me() : X = setTimeout(Me, n); + function Ce(r) { + k("expire", r), P && (clearTimeout(P), P = null), r < 1 ? Ye() : P = setTimeout(Ye, r); } - function Fe(n) { - x("floating", n), k !== n && (t(8, C.style.left = "", C), t(8, C.style.top = "", C)), t(1, k = n === !0 || n === "" ? "auto" : n === !1 || n === "false" ? void 0 : k), k ? (a || t(0, a = "onsubmit"), document.addEventListener("scroll", Ve), document.addEventListener("click", Te), window.addEventListener("resize", De)) : a === "onsubmit" && t(0, a = void 0); + function Qe(r) { + k("floating", r), b !== r && (t(9, C.style.left = "", C), t(9, C.style.top = "", C)), t(1, b = r === !0 || r === "" ? "auto" : r === !1 || r === "false" ? void 0 : b), b ? (l || t(0, l = "onsubmit"), document.addEventListener("scroll", Je), document.addEventListener("click", Ke), window.addEventListener("resize", qe)) : l === "onsubmit" && t(0, l = void 0); } - function gt(n) { - var g; - const u = m == null ? void 0 : m.querySelector(typeof n == "string" ? `input[name="${n}"]` : 'input[type="email"]:not([data-no-spamfilter])'); - return ((g = u == null ? void 0 : u.value) == null ? void 0 : g.slice(u.value.indexOf("@"))) || void 0; + function St(r) { + var v; + const d = m == null ? void 0 : m.querySelector(typeof r == "string" ? `input[name="${r}"]` : 'input[type="email"]:not([data-no-spamfilter])'); + return ((v = d == null ? void 0 : d.value) == null ? void 0 : v.slice(d.value.indexOf("@"))) || void 0; } - function mt(n) { + function Mt(r) { return [ - ...(m == null ? void 0 : m.querySelectorAll(n != null && n.length ? n.map((g) => `input[name="${g}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] + ...(m == null ? void 0 : m.querySelectorAll(r != null && r.length ? r.map((v) => `input[name="${v}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] ].reduce( - (g, z) => { - const V = z.name, Z = z.value; - return V && Z && (g[V] = /\n/.test(Z) ? Z.replace(new RegExp("(? { + const Z = z.name, M = z.value; + return Z && M && (v[Z] = /\n/.test(M) ? M.replace(new RegExp("(? V : k === "top", p = Math.max(n, Math.min(Z - n - z.width, g.left + g.width / 2 - z.width / 2)); - if (B ? t(8, C.style.top = `${g.top - (z.height + u)}px`, C) : t(8, C.style.top = `${g.bottom + u}px`, C), t(8, C.style.left = `${p}px`, C), C.setAttribute("data-floating", B ? "top" : "bottom"), q) { - const L = q.getBoundingClientRect(); - t(9, q.style.left = g.left - p + g.width / 2 - L.width / 2 + "px", q); + if (Ee || (Ee = (q ? document.querySelector(q) : m == null ? void 0 : m.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || m), Ee) { + const d = parseInt(K, 10) || 12, v = Ee.getBoundingClientRect(), z = C.getBoundingClientRect(), Z = document.documentElement.clientHeight, M = document.documentElement.clientWidth, W = b === "auto" ? v.bottom + z.height + d + r > Z : b === "top", y = Math.max(r, Math.min(M - r - z.width, v.left + v.width / 2 - z.width / 2)); + if (W ? t(9, C.style.top = `${v.top - (z.height + d)}px`, C) : t(9, C.style.top = `${v.bottom + d}px`, C), t(9, C.style.left = `${y}px`, C), C.setAttribute("data-floating", W ? "top" : "bottom"), te) { + const L = te.getBoundingClientRect(); + t(10, te.style.left = v.left - y + v.width / 2 - L.width / 2 + "px", te); } } else - x("unable to find floating anchor element"); + k("unable to find floating anchor element"); } - function Ue(n) { - n.auto !== void 0 && (t(0, a = n.auto), a === "onload" && ee()), n.floatinganchor !== void 0 && t(19, W = n.floatinganchor), n.delay !== void 0 && t(17, G = n.delay), n.floatingoffset !== void 0 && t(20, S = n.floatingoffset), n.floating !== void 0 && Fe(n.floating), n.expire !== void 0 && (he(n.expire), t(18, D = n.expire)), n.challenge && (je(n.challenge), o = n.challenge), n.challengeurl !== void 0 && t(15, f = n.challengeurl), n.debug !== void 0 && t(16, N = !!n.debug), n.hidefooter !== void 0 && t(2, K = !!n.hidefooter), n.hidelogo !== void 0 && t(3, H = !!n.hidelogo), n.maxnumber !== void 0 && t(21, E = +n.maxnumber), n.mockerror !== void 0 && t(22, R = !!n.mockerror), n.name !== void 0 && t(4, M = n.name), n.refetchonexpire !== void 0 && t(23, I = !!n.refetchonexpire), n.spamfilter !== void 0 && t(24, w = typeof n.spamfilter == "object" ? n.spamfilter : !!n.spamfilter), n.strings && t(35, l = n.strings), n.test !== void 0 && t(25, v = typeof n.test == "number" ? n.test : !!n.test), n.verifyurl !== void 0 && t(26, J = n.verifyurl), n.workers !== void 0 && t(27, oe = +n.workers), n.workerurl !== void 0 && t(28, ue = n.workerurl); + function et(r) { + r.analytics && (t(18, c = r.analytics), We()), r.auto !== void 0 && (t(0, l = r.auto), l === "onload" && re()), r.beaconurl && (t(19, f = r.beaconurl), D && t(11, D.beaconUrl = f, D)), r.floatinganchor !== void 0 && t(23, q = r.floatinganchor), r.delay !== void 0 && t(21, X = r.delay), r.floatingoffset !== void 0 && t(24, K = r.floatingoffset), r.floating !== void 0 && Qe(r.floating), r.expire !== void 0 && (Ce(r.expire), t(22, Y = r.expire)), r.challenge && (Pe(r.challenge), o = r.challenge), r.challengeurl !== void 0 && t(17, g = r.challengeurl), r.debug !== void 0 && t(20, O = !!r.debug), r.hidefooter !== void 0 && t(2, j = !!r.hidefooter), r.hidelogo !== void 0 && t(3, I = !!r.hidelogo), r.maxnumber !== void 0 && t(25, x = +r.maxnumber), r.mockerror !== void 0 && t(26, A = !!r.mockerror), r.name !== void 0 && t(4, F = r.name), r.refetchonexpire !== void 0 && t(27, h = !!r.refetchonexpire), r.spamfilter !== void 0 && t(28, p = typeof r.spamfilter == "object" ? r.spamfilter : !!r.spamfilter), r.strings && t(39, s = r.strings), r.test !== void 0 && t(29, H = typeof r.test == "number" ? r.test : !!r.test), r.verifyurl !== void 0 && t(30, ee = r.verifyurl), r.workers !== void 0 && t(31, ue = +r.workers), r.workerurl !== void 0 && t(32, ke = r.workerurl); } - function ge(n = b.UNVERIFIED, u = null) { - X && (clearTimeout(X), X = null), t(7, P = !1), t(10, pe = u), t(5, Q = null), t(6, T = n); + function Le(r = w.UNVERIFIED, d = null) { + P && (clearTimeout(P), P = null), t(8, Q = !1), t(5, xe = d), t(6, ne = null), t(7, U = r); } - async function ee() { - return ge(b.VERIFYING), await new Promise((n) => setTimeout(n, G || 0)), at().then((n) => (je(n), x("challenge", n), ft(n))).then(({ data: n, solution: u }) => { - if (x("solution", u), (u == null ? void 0 : u.number) !== void 0) { - if (J) - return bt(Ze(n, u)); - t(5, Q = Ze(n, u)), x("payload", Q); + async function re() { + return Le(w.VERIFYING), await new Promise((r) => setTimeout(r, X || 0)), It().then((r) => (Pe(r), k("challenge", r), At(r))).then(({ data: r, solution: d }) => { + if (k("solution", d), (d == null ? void 0 : d.number) !== void 0) { + if (ee) + return jt(He(r, d)); + t(6, ne = He(r, d)), k("payload", ne); } else - throw x("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); + throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); }).then(() => { - Vt().then(() => { - t(6, T = b.VERIFIED), t(7, P = !0), x("verified"), ye("verified", { payload: Q }); + rn().then(() => { + t(7, U = w.VERIFIED), t(8, Q = !0), k("verified"), Fe("verified", { payload: ne }); }); - }).catch((n) => { - x(n), t(6, T = b.ERROR), t(7, P = !1), t(10, pe = n.message); + }).catch((r) => { + k(r), t(7, U = w.ERROR), t(8, Q = !1), t(5, xe = r.message); }); } - function wt() { - P = this.checked, t(7, P); + function Ut() { + Q = this.checked, t(8, Q); } - function yt(n) { - we[n ? "unshift" : "push"](() => { - q = n, t(9, q); + function Zt(r) { + ze[r ? "unshift" : "push"](() => { + te = r, t(10, te); }); } - function pt(n) { - we[n ? "unshift" : "push"](() => { - C = n, t(8, C); + function Vt(r) { + ze[r ? "unshift" : "push"](() => { + C = r, t(9, C); }); } - return r.$$set = (n) => { - "auto" in n && t(0, a = n.auto), "blockspam" in n && t(29, d = n.blockspam), "challengeurl" in n && t(15, f = n.challengeurl), "challengejson" in n && t(30, F = n.challengejson), "debug" in n && t(16, N = n.debug), "delay" in n && t(17, G = n.delay), "expire" in n && t(18, D = n.expire), "floating" in n && t(1, k = n.floating), "floatinganchor" in n && t(19, W = n.floatinganchor), "floatingoffset" in n && t(20, S = n.floatingoffset), "hidefooter" in n && t(2, K = n.hidefooter), "hidelogo" in n && t(3, H = n.hidelogo), "name" in n && t(4, M = n.name), "maxnumber" in n && t(21, E = n.maxnumber), "mockerror" in n && t(22, R = n.mockerror), "refetchonexpire" in n && t(23, I = n.refetchonexpire), "spamfilter" in n && t(24, w = n.spamfilter), "strings" in n && t(31, h = n.strings), "test" in n && t(25, v = n.test), "verifyurl" in n && t(26, J = n.verifyurl), "workers" in n && t(27, oe = n.workers), "workerurl" in n && t(28, ue = n.workerurl); - }, r.$$.update = () => { - r.$$.dirty[0] & /*challengeurl*/ - 32768 && t(12, i = !!(f != null && f.includes(".altcha.org")) && !!(f != null && f.includes("apiKey=ckey_"))), r.$$.dirty[0] & /*challengejson*/ - 1073741824 && (o = F ? et(F) : void 0), r.$$.dirty[1] & /*strings*/ - 1 && t(35, l = h ? et(h) : {}), r.$$.dirty[1] & /*parsedStrings*/ - 16 && t(11, c = { - ariaLinkLabel: Qe, + return n.$$set = (r) => { + "analytics" in r && t(18, c = r.analytics), "auto" in r && t(0, l = r.auto), "beaconurl" in r && t(19, f = r.beaconurl), "blockspam" in r && t(33, B = r.blockspam), "challengeurl" in r && t(17, g = r.challengeurl), "challengejson" in r && t(34, G = r.challengejson), "debug" in r && t(20, O = r.debug), "delay" in r && t(21, X = r.delay), "expire" in r && t(22, Y = r.expire), "floating" in r && t(1, b = r.floating), "floatinganchor" in r && t(23, q = r.floatinganchor), "floatingoffset" in r && t(24, K = r.floatingoffset), "hidefooter" in r && t(2, j = r.hidefooter), "hidelogo" in r && t(3, I = r.hidelogo), "name" in r && t(4, F = r.name), "maxnumber" in r && t(25, x = r.maxnumber), "mockerror" in r && t(26, A = r.mockerror), "refetchonexpire" in r && t(27, h = r.refetchonexpire), "spamfilter" in r && t(28, p = r.spamfilter), "strings" in r && t(35, pe = r.strings), "test" in r && t(29, H = r.test), "verifyurl" in r && t(30, ee = r.verifyurl), "workers" in r && t(31, ue = r.workers), "workerurl" in r && t(32, ke = r.workerurl); + }, n.$$.update = () => { + n.$$.dirty[0] & /*challengeurl*/ + 131072 && t(14, i = !!(g != null && g.includes(".altcha.org")) && !!(g != null && g.includes("apiKey=ckey_"))), n.$$.dirty[1] & /*challengejson*/ + 8 && (o = G ? vt(G) : void 0), n.$$.dirty[1] & /*strings*/ + 16 && t(39, s = pe ? vt(pe) : {}), n.$$.dirty[1] & /*parsedStrings*/ + 256 && t(13, u = { + ariaLinkLabel: bt, error: "Verification failed. Try again later.", expired: "Verification expired. Try again.", - footer: `Protected by ALTCHA`, + footer: `Protected by ALTCHA`, label: "I'm not a robot", verified: "Verified", verifying: "Verifying...", waitAlert: "Verifying... please wait.", - ...l - }), r.$$.dirty[0] & /*payload, state*/ - 96 && ye("statechange", { payload: Q, state: T }), r.$$.dirty[0] & /*state*/ - 64 && ht(); + ...s + }), n.$$.dirty[0] & /*payload, state*/ + 192 && Fe("statechange", { payload: ne, state: U }), n.$$.dirty[0] & /*error*/ + 32 && Tt(), n.$$.dirty[0] & /*state*/ + 128 && Nt(); }, [ - a, - k, - K, - H, - M, + l, + b, + j, + I, + F, + xe, + ne, + U, Q, - T, - P, C, - q, - pe, - c, + te, + D, + Be, + u, i, - dt, + Ft, $e, + g, + c, f, - N, - G, - D, - W, - S, - E, - R, - I, - w, - v, - J, - oe, - ue, - d, - F, + O, + X, + Y, + q, + K, + x, + A, h, - Ue, - ge, + p, + H, ee, - l, - wt, - yt, - pt + ue, + ke, + B, + G, + pe, + et, + Le, + re, + s, + Ut, + Zt, + Vt ]; } -class cr extends Wt { +class An extends mn { constructor(e) { - super(), Ht( + super(), dn( this, e, - sr, - or, - Ct, + In, + Rn, + Ht, { + analytics: 18, auto: 0, - blockspam: 29, - challengeurl: 15, - challengejson: 30, - debug: 16, - delay: 17, - expire: 18, + beaconurl: 19, + blockspam: 33, + challengeurl: 17, + challengejson: 34, + debug: 20, + delay: 21, + expire: 22, floating: 1, - floatinganchor: 19, - floatingoffset: 20, + floatinganchor: 23, + floatingoffset: 24, hidefooter: 2, hidelogo: 3, name: 4, - maxnumber: 21, - mockerror: 22, - refetchonexpire: 23, - spamfilter: 24, - strings: 31, - test: 25, - verifyurl: 26, - workers: 27, - workerurl: 28, - configure: 32, - reset: 33, - verify: 34 + maxnumber: 25, + mockerror: 26, + refetchonexpire: 27, + spamfilter: 28, + strings: 35, + test: 29, + verifyurl: 30, + workers: 31, + workerurl: 32, + configure: 36, + reset: 37, + verify: 38 }, - Qt, + pn, [-1, -1, -1] ); } + get analytics() { + return this.$$.ctx[18]; + } + set analytics(e) { + this.$$set({ analytics: e }), _(); + } get auto() { return this.$$.ctx[0]; } set auto(e) { - this.$$set({ auto: e }), y(); + this.$$set({ auto: e }), _(); + } + get beaconurl() { + return this.$$.ctx[19]; + } + set beaconurl(e) { + this.$$set({ beaconurl: e }), _(); } get blockspam() { - return this.$$.ctx[29]; + return this.$$.ctx[33]; } set blockspam(e) { - this.$$set({ blockspam: e }), y(); + this.$$set({ blockspam: e }), _(); } get challengeurl() { - return this.$$.ctx[15]; + return this.$$.ctx[17]; } set challengeurl(e) { - this.$$set({ challengeurl: e }), y(); + this.$$set({ challengeurl: e }), _(); } get challengejson() { - return this.$$.ctx[30]; + return this.$$.ctx[34]; } set challengejson(e) { - this.$$set({ challengejson: e }), y(); + this.$$set({ challengejson: e }), _(); } get debug() { - return this.$$.ctx[16]; + return this.$$.ctx[20]; } set debug(e) { - this.$$set({ debug: e }), y(); + this.$$set({ debug: e }), _(); } get delay() { - return this.$$.ctx[17]; + return this.$$.ctx[21]; } set delay(e) { - this.$$set({ delay: e }), y(); + this.$$set({ delay: e }), _(); } get expire() { - return this.$$.ctx[18]; + return this.$$.ctx[22]; } set expire(e) { - this.$$set({ expire: e }), y(); + this.$$set({ expire: e }), _(); } get floating() { return this.$$.ctx[1]; } set floating(e) { - this.$$set({ floating: e }), y(); + this.$$set({ floating: e }), _(); } get floatinganchor() { - return this.$$.ctx[19]; + return this.$$.ctx[23]; } set floatinganchor(e) { - this.$$set({ floatinganchor: e }), y(); + this.$$set({ floatinganchor: e }), _(); } get floatingoffset() { - return this.$$.ctx[20]; + return this.$$.ctx[24]; } set floatingoffset(e) { - this.$$set({ floatingoffset: e }), y(); + this.$$set({ floatingoffset: e }), _(); } get hidefooter() { return this.$$.ctx[2]; } set hidefooter(e) { - this.$$set({ hidefooter: e }), y(); + this.$$set({ hidefooter: e }), _(); } get hidelogo() { return this.$$.ctx[3]; } set hidelogo(e) { - this.$$set({ hidelogo: e }), y(); + this.$$set({ hidelogo: e }), _(); } get name() { return this.$$.ctx[4]; } set name(e) { - this.$$set({ name: e }), y(); + this.$$set({ name: e }), _(); } get maxnumber() { - return this.$$.ctx[21]; + return this.$$.ctx[25]; } set maxnumber(e) { - this.$$set({ maxnumber: e }), y(); + this.$$set({ maxnumber: e }), _(); } get mockerror() { - return this.$$.ctx[22]; + return this.$$.ctx[26]; } set mockerror(e) { - this.$$set({ mockerror: e }), y(); + this.$$set({ mockerror: e }), _(); } get refetchonexpire() { - return this.$$.ctx[23]; + return this.$$.ctx[27]; } set refetchonexpire(e) { - this.$$set({ refetchonexpire: e }), y(); + this.$$set({ refetchonexpire: e }), _(); } get spamfilter() { - return this.$$.ctx[24]; + return this.$$.ctx[28]; } set spamfilter(e) { - this.$$set({ spamfilter: e }), y(); + this.$$set({ spamfilter: e }), _(); } get strings() { - return this.$$.ctx[31]; + return this.$$.ctx[35]; } set strings(e) { - this.$$set({ strings: e }), y(); + this.$$set({ strings: e }), _(); } get test() { - return this.$$.ctx[25]; + return this.$$.ctx[29]; } set test(e) { - this.$$set({ test: e }), y(); + this.$$set({ test: e }), _(); } get verifyurl() { - return this.$$.ctx[26]; + return this.$$.ctx[30]; } set verifyurl(e) { - this.$$set({ verifyurl: e }), y(); + this.$$set({ verifyurl: e }), _(); } get workers() { - return this.$$.ctx[27]; + return this.$$.ctx[31]; } set workers(e) { - this.$$set({ workers: e }), y(); + this.$$set({ workers: e }), _(); } get workerurl() { - return this.$$.ctx[28]; + return this.$$.ctx[32]; } set workerurl(e) { - this.$$set({ workerurl: e }), y(); + this.$$set({ workerurl: e }), _(); } get configure() { - return this.$$.ctx[32]; + return this.$$.ctx[36]; } get reset() { - return this.$$.ctx[33]; + return this.$$.ctx[37]; } get verify() { - return this.$$.ctx[34]; + return this.$$.ctx[38]; } } -customElements.define("altcha-widget", Ot(cr, { auto: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, delay: {}, expire: {}, floating: {}, floatinganchor: {}, floatingoffset: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, [], ["configure", "reset", "verify"], !1)); -globalThis.createAltchaWorker = (r) => r ? new Worker(new URL(r)) : new Et(); +customElements.define("altcha-widget", hn(An, { analytics: { type: "Boolean" }, auto: {}, beaconurl: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, delay: {}, expire: {}, floating: {}, floatinganchor: {}, floatingoffset: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, [], ["configure", "reset", "verify"], !1)); +globalThis.createAltchaWorker = (n) => n ? new Worker(new URL(n)) : new Xt(); export { - cr as Altcha + An as Altcha }; diff --git a/dist/altcha.umd.cjs b/dist/altcha.umd.cjs index 7fdbac5..032049a 100644 --- a/dist/altcha.umd.cjs +++ b/dist/altcha.umd.cjs @@ -1,2 +1,2 @@ -(function(U,Z){typeof exports=="object"&&typeof module<"u"?Z(exports):typeof define=="function"&&define.amd?define(["exports"],Z):(U=typeof globalThis<"u"?globalThis:U||self,Z(U.altcha={}))})(this,function(U){"use strict";var cr=Object.defineProperty;var ar=(U,Z,ne)=>Z in U?cr(U,Z,{enumerable:!0,configurable:!0,writable:!0,value:ne}):U[Z]=ne;var O=(U,Z,ne)=>ar(U,typeof Z!="symbol"?Z+"":Z,ne);const Z="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",ne=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),Se=typeof self<"u"&&self.Blob&&new Blob([ne(Z)],{type:"text/javascript;charset=utf-8"});function dt(r){let e;try{if(e=Se&&(self.URL||self.webkitURL).createObjectURL(Se),!e)throw"";const t=new Worker(e,{name:r==null?void 0:r.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Z,{name:r==null?void 0:r.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}function ie(){}function Ne(r){return r()}function je(){return Object.create(null)}function ce(r){r.forEach(Ne)}function Te(r){return typeof r=="function"}function ht(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function gt(r){return Object.keys(r).length===0}function p(r,e){r.appendChild(e)}function mt(r,e,t){const i=bt(r);if(!i.getElementById(e)){const o=R("style");o.id=e,o.textContent=t,vt(i,o)}}function bt(r){if(!r)return document;const e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function vt(r,e){return p(r.head||r,e),e.sheet}function M(r,e,t){r.insertBefore(e,t||null)}function T(r){r.parentNode&&r.parentNode.removeChild(r)}function R(r){return document.createElement(r)}function P(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function wt(r){return document.createTextNode(r)}function Y(){return wt(" ")}function ke(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function s(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function yt(r){return Array.from(r.childNodes)}function Ze(r,e,t){r.classList.toggle(e,!!t)}function pt(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function _t(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ae;function fe(r){ae=r}function xe(){if(!ae)throw new Error("Function called outside component initialization");return ae}function kt(r){xe().$$.on_mount.push(r)}function xt(r){xe().$$.on_destroy.push(r)}function Et(){const r=xe();return(e,t,{cancelable:i=!1}={})=>{const o=r.$$.callbacks[e];if(o){const l=pt(e,t,{cancelable:i});return o.slice().forEach(c=>{c.call(r,l)}),!l.defaultPrevented}return!0}}const oe=[],ge=[];let le=[];const Me=[],Ve=Promise.resolve();let Ee=!1;function $e(){Ee||(Ee=!0,Ve.then(w))}function Ct(){return $e(),Ve}function Ce(r){le.push(r)}const Le=new Set;let se=0;function w(){if(se!==0)return;const r=ae;do{try{for(;ser.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),le=e}const It=new Set;function zt(r,e){r&&r.i&&(It.delete(r),r.i(e))}function At(r,e,t){const{fragment:i,after_update:o}=r.$$;i&&i.m(e,t),Ce(()=>{const l=r.$$.on_mount.map(Ne).filter(Te);r.$$.on_destroy?r.$$.on_destroy.push(...l):ce(l),r.$$.on_mount=[]}),o.forEach(Ce)}function St(r,e){const t=r.$$;t.fragment!==null&&(Rt(t.after_update),ce(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Nt(r,e){r.$$.dirty[0]===-1&&(oe.push(r),$e(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<{const k=F.length?F[0]:X;return f.ctx&&o(f.ctx[N],f.ctx[N]=k)&&(!f.skip_bound&&f.bound[N]&&f.bound[N](k),G&&Nt(r,N)),X}):[],f.update(),G=!0,ce(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const N=yt(e.target);f.fragment&&f.fragment.l(N),N.forEach(T)}else f.fragment&&f.fragment.c();e.intro&&zt(r.$$.fragment),At(r,e.target,e.anchor),w()}fe(d)}let De;typeof HTMLElement=="function"&&(De=class extends HTMLElement{constructor(e,t,i){super();O(this,"$$ctor");O(this,"$$s");O(this,"$$c");O(this,"$$cn",!1);O(this,"$$d",{});O(this,"$$r",!1);O(this,"$$p_d",{});O(this,"$$l",{});O(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let c;return{c:function(){c=R("slot"),l!=="default"&&s(c,"name",l)},m:function(f,G){M(f,c,G)},d:function(f){f&&T(c)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=_t(this);for(const l of this.$$s)l in i&&(t[l]=[e(l)]);for(const l of this.attributes){const c=this.$$g_p(l.name);c in this.$$d||(this.$$d[c]=me(c,l.value,this.$$p_d,"toProp"))}for(const l in this.$$p_d)!(l in this.$$d)&&this[l]!==void 0&&(this.$$d[l]=this[l],delete this[l]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const l in this.$$p_d)if(this.$$d[l]=this.$$c.$$.ctx[this.$$c.$$.props[l]],this.$$p_d[l].reflect){const c=me(l,this.$$d[l],this.$$p_d,"toAttribute");c==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,c)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const c of this.$$l[l]){const a=this.$$c.$on(l,c);this.$$l_u.set(c,a)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=me(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function me(r,e,t,i){var l;const o=(l=t[r])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Tt(r,e,t,i,o,l){let c=class extends De{constructor(){super(r,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(c.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(d){var f;d=me(a,d,e),this.$$d[a]=d,(f=this.$$c)==null||f.$set({[a]:d})}})}),i.forEach(a=>{Object.defineProperty(c.prototype,a,{get(){var d;return(d=this.$$c)==null?void 0:d[a]}})}),r.element=c,c}class Zt{constructor(){O(this,"$$");O(this,"$$set")}$destroy(){St(this,1),this.$destroy=ie}$on(e,t){if(!Te(t))return ie;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!gt(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Mt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Mt);const Vt=new TextEncoder;function $t(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Dt(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const o=await Fe(i,r,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Fe(r,e,t){return $t(await crypto.subtle.digest(t.toUpperCase(),Vt.encode(r+e)))}function Ft(r,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,c=Date.now();return{promise:(async()=>{for(let d=o;d<=i;d+=1){if(l.signal.aborted)return null;if(await Fe(e,d,t)===r)return{number:d,took:Date.now()-c}}return null})(),controller:l}}var m=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(m||{});function Ut(r){mt(r,"svelte-ddsc3z",'.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}')}function Ue(r){let e,t,i;return{c(){e=P("svg"),t=P("path"),i=P("path"),s(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),s(t,"fill","currentColor"),s(t,"opacity",".25"),s(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),s(i,"fill","currentColor"),s(i,"class","altcha-spinner svelte-ddsc3z"),s(e,"width","24"),s(e,"height","24"),s(e,"viewBox","0 0 24 24"),s(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){M(o,e,l),p(e,t),p(e,i)},d(o){o&&T(e)}}}function Gt(r){let e,t=r[11].label+"",i;return{c(){e=R("label"),s(e,"for",i=r[4]+"_checkbox"),s(e,"class","svelte-ddsc3z")},m(o,l){M(o,e,l),e.innerHTML=t},p(o,l){l[0]&2048&&t!==(t=o[11].label+"")&&(e.innerHTML=t),l[0]&16&&i!==(i=o[4]+"_checkbox")&&s(e,"for",i)},d(o){o&&T(e)}}}function Ot(r){let e,t=r[11].verifying+"";return{c(){e=R("span")},m(i,o){M(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].verifying+"")&&(e.innerHTML=t)},d(i){i&&T(e)}}}function Xt(r){let e,t=r[11].verified+"",i,o;return{c(){e=R("span"),i=Y(),o=R("input"),s(o,"type","hidden"),s(o,"name",r[4]),o.value=r[5]},m(l,c){M(l,e,c),e.innerHTML=t,M(l,i,c),M(l,o,c)},p(l,c){c[0]&2048&&t!==(t=l[11].verified+"")&&(e.innerHTML=t),c[0]&16&&s(o,"name",l[4]),c[0]&32&&(o.value=l[5])},d(l){l&&(T(e),T(i),T(o))}}}function Ge(r){let e,t,i,o,l,c,a;return{c(){e=R("div"),t=R("a"),i=P("svg"),o=P("path"),l=P("path"),c=P("path"),s(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),s(o,"fill","currentColor"),s(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),s(l,"fill","currentColor"),s(c,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),s(c,"fill","currentColor"),s(i,"width","22"),s(i,"height","22"),s(i,"viewBox","0 0 20 20"),s(i,"fill","none"),s(i,"xmlns","http://www.w3.org/2000/svg"),s(t,"href",Pe),s(t,"target","_blank"),s(t,"class","altcha-logo svelte-ddsc3z"),s(t,"aria-label",a=r[11].ariaLinkLabel)},m(d,f){M(d,e,f),p(e,t),p(t,i),p(i,o),p(i,l),p(i,c)},p(d,f){f[0]&2048&&a!==(a=d[11].ariaLinkLabel)&&s(t,"aria-label",a)},d(d){d&&T(e)}}}function Oe(r){let e,t,i,o;function l(d,f){return d[6]===m.EXPIRED?Ht:Bt}let c=l(r),a=c(r);return{c(){e=R("div"),t=P("svg"),i=P("path"),o=Y(),a.c(),s(i,"stroke-linecap","round"),s(i,"stroke-linejoin","round"),s(i,"d","M6 18L18 6M6 6l12 12"),s(t,"width","14"),s(t,"height","14"),s(t,"xmlns","http://www.w3.org/2000/svg"),s(t,"fill","none"),s(t,"viewBox","0 0 24 24"),s(t,"stroke-width","1.5"),s(t,"stroke","currentColor"),s(e,"class","altcha-error svelte-ddsc3z")},m(d,f){M(d,e,f),p(e,t),p(t,i),p(e,o),a.m(e,null)},p(d,f){c===(c=l(d))&&a?a.p(d,f):(a.d(1),a=c(d),a&&(a.c(),a.m(e,null)))},d(d){d&&T(e),a.d()}}}function Bt(r){let e,t=r[11].error+"";return{c(){e=R("div"),s(e,"title",r[10])},m(i,o){M(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),o[0]&1024&&s(e,"title",i[10])},d(i){i&&T(e)}}}function Ht(r){let e,t=r[11].expired+"";return{c(){e=R("div"),s(e,"title",r[10])},m(i,o){M(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),o[0]&1024&&s(e,"title",i[10])},d(i){i&&T(e)}}}function Xe(r){let e,t,i=r[11].footer+"";return{c(){e=R("div"),t=R("div"),s(t,"class","svelte-ddsc3z"),s(e,"class","altcha-footer svelte-ddsc3z")},m(o,l){M(o,e,l),p(e,t),t.innerHTML=i},p(o,l){l[0]&2048&&i!==(i=o[11].footer+"")&&(t.innerHTML=i)},d(o){o&&T(e)}}}function Be(r){let e;return{c(){e=R("div"),s(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){M(t,e,i),r[37](e)},p:ie,d(t){t&&T(e),r[37](null)}}}function Pt(r){let e,t,i,o,l,c,a,d,f,G,N,X,F,k,K,S=r[6]===m.VERIFYING&&Ue();function q(h,v){return h[6]===m.VERIFIED?Xt:h[6]===m.VERIFYING?Ot:Gt}let W=q(r),V=W(r),E=(r[3]!==!0||r[12])&&Ge(r),I=(r[10]||r[6]===m.EXPIRED)&&Oe(r),z=r[11].footer&&(r[2]!==!0||r[12])&&Xe(r),y=r[1]&&Be(r);return{c(){e=R("div"),t=R("div"),S&&S.c(),i=Y(),o=R("div"),l=R("input"),d=Y(),f=R("div"),V.c(),G=Y(),E&&E.c(),N=Y(),I&&I.c(),X=Y(),z&&z.c(),F=Y(),y&&y.c(),s(l,"type","checkbox"),s(l,"id",c=r[4]+"_checkbox"),l.required=a=r[0]!=="onsubmit",s(l,"class","svelte-ddsc3z"),s(o,"class","altcha-checkbox svelte-ddsc3z"),Ze(o,"altcha-hidden",r[6]===m.VERIFYING),s(f,"class","altcha-label svelte-ddsc3z"),s(t,"class","altcha-main svelte-ddsc3z"),s(e,"class","altcha svelte-ddsc3z"),s(e,"data-state",r[6]),s(e,"data-floating",r[1])},m(h,v){M(h,e,v),p(e,t),S&&S.m(t,null),p(t,i),p(t,o),p(o,l),l.checked=r[7],p(t,d),p(t,f),V.m(f,null),p(t,G),E&&E.m(t,null),p(e,N),I&&I.m(e,null),p(e,X),z&&z.m(e,null),p(e,F),y&&y.m(e,null),r[38](e),k||(K=[ke(l,"change",r[36]),ke(l,"change",r[13]),ke(l,"invalid",r[14])],k=!0)},p(h,v){h[6]===m.VERIFYING?S||(S=Ue(),S.c(),S.m(t,i)):S&&(S.d(1),S=null),v[0]&16&&c!==(c=h[4]+"_checkbox")&&s(l,"id",c),v[0]&1&&a!==(a=h[0]!=="onsubmit")&&(l.required=a),v[0]&128&&(l.checked=h[7]),v[0]&64&&Ze(o,"altcha-hidden",h[6]===m.VERIFYING),W===(W=q(h))&&V?V.p(h,v):(V.d(1),V=W(h),V&&(V.c(),V.m(f,null))),h[3]!==!0||h[12]?E?E.p(h,v):(E=Ge(h),E.c(),E.m(t,null)):E&&(E.d(1),E=null),h[10]||h[6]===m.EXPIRED?I?I.p(h,v):(I=Oe(h),I.c(),I.m(e,X)):I&&(I.d(1),I=null),h[11].footer&&(h[2]!==!0||h[12])?z?z.p(h,v):(z=Xe(h),z.c(),z.m(e,F)):z&&(z.d(1),z=null),h[1]?y?y.p(h,v):(y=Be(h),y.c(),y.m(e,null)):y&&(y.d(1),y=null),v[0]&64&&s(e,"data-state",h[6]),v[0]&2&&s(e,"data-floating",h[1])},i:ie,o:ie,d(h){h&&T(e),S&&S.d(),V.d(),E&&E.d(),I&&I.d(),z&&z.d(),y&&y.d(),r[38](null),k=!1,ce(K)}}}const He="Visit Altcha.org",Pe="https://altcha.org/";function We(r){return JSON.parse(r)}function Wt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Yt(r,e,t){var ft,ut;let i,o,l,c,{auto:a=void 0}=e,{blockspam:d=void 0}=e,{challengeurl:f=void 0}=e,{challengejson:G=void 0}=e,{debug:N=!1}=e,{delay:X=0}=e,{expire:F=void 0}=e,{floating:k=void 0}=e,{floatinganchor:K=void 0}=e,{floatingoffset:S=void 0}=e,{hidefooter:q=!1}=e,{hidelogo:W=!1}=e,{name:V="altcha"}=e,{maxnumber:E=1e6}=e,{mockerror:I=!1}=e,{refetchonexpire:z=!0}=e,{spamfilter:y=!1}=e,{strings:h=void 0}=e,{test:v=!1}=e,{verifyurl:Q=void 0}=e,{workers:ue=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:be=void 0}=e;const Re=Et(),Ke=["SHA-256","SHA-384","SHA-512"],Je=(ut=(ft=document.documentElement.lang)==null?void 0:ft.split("-"))==null?void 0:ut[0];let J=!1,C,ee=null,ve=null,b=null,Ie=null,te=null,$=m.UNVERIFIED,B=null;xt(()=>{b&&(b.removeEventListener("submit",Qe),b.removeEventListener("reset",et),b.removeEventListener("focusin",qe),b=null),B&&(clearTimeout(B),B=null),document.removeEventListener("click",it),document.removeEventListener("scroll",ot),window.removeEventListener("resize",st)}),kt(()=>{x("mounted","0.6.7"),x("workers",ue),v&&x("using test mode"),F&&we(F),a!==void 0&&x("auto",a),k!==void 0&&ct(k),b=C.closest("form"),b&&(b.addEventListener("submit",Qe,{capture:!0}),b.addEventListener("reset",et),a==="onfocus"&&b.addEventListener("focusin",qe)),a==="onload"&&re(),i&&(q||W)&&x("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.")});function x(...n){(N||n.some(u=>u instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function qe(n){$===m.UNVERIFIED&&re()}function Qe(n){b&&a==="onsubmit"&&($===m.UNVERIFIED?(n.preventDefault(),n.stopPropagation(),re().then(()=>{b==null||b.requestSubmit()})):$!==m.VERIFIED&&(n.preventDefault(),n.stopPropagation(),$===m.VERIFYING&<()))}function et(){ye()}function tt(n,u){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:u.number,salt:n.salt,signature:n.signature,test:v?!0:void 0,took:u.took}))}function rt(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Ke.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ke.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function Kt(){var n;if(I)throw x("mocking error"),new Error("Mocked error.");if(o)return x("using provided json data"),o;if(v)return x("generating test challenge",{test:v}),Dt(typeof v!="boolean"?+v:void 0);{if(!f)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",f);const u=await fetch(f,{headers:{"x-altcha-spam-filter":y?"1":"0"}});if(u.status!==200)throw new Error(`Server responded with ${u.status}.`);const g=u.headers.get("Expires"),A=u.headers.get("X-Altcha-Config"),D=await u.json(),j=new URLSearchParams((n=D.salt.split("?"))==null?void 0:n[1]),H=j.get("expires")||j.get("expire");if(H){const _=new Date(+H*1e3),L=isNaN(_.getTime())?0:_.getTime()-Date.now();L>0&&we(L)}if(A)try{const _=JSON.parse(A);_&&typeof _=="object"&&(_.verifyurl&&(_.verifyurl=new URL(_.verifyurl,new URL(f)).toString()),at(_))}catch(_){x("unable to configure from X-Altcha-Config",_)}if(!F&&(g!=null&&g.length)){const _=Date.parse(g);if(_){const L=_-Date.now();L>0&&we(L)}}return D}}function nt(){f&&z&&$===m.VERIFIED?re():ye(m.EXPIRED,c.expired)}async function Jt(n){let u=null;if("Worker"in window){try{u=await qt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(g){x(g)}if((u==null?void 0:u.number)!==void 0)return{data:n,solution:u}}return{data:n,solution:await Ft(n.challenge,n.salt,n.algorithm,n.maxnumber||E).promise}}async function qt(n,u,g,A=typeof v=="number"?v:E,D=Math.ceil(ue)){const j=[];D=Math.min(16,Math.max(1,D));for(let L=0;L{const de=Ae*H;return new Promise(pe=>{L.addEventListener("message",_e=>{if(_e.data)for(const he of j)he!==L&&he.postMessage({type:"abort"});pe(_e.data)}),L.postMessage({payload:{alg:g,challenge:n,max:de+H,salt:u,start:de},type:"work"})})}));for(const L of j)L.terminate();return _.find(L=>!!L)||null}function Qt(){[m.UNVERIFIED,m.ERROR,m.EXPIRED].includes($)?y&&(b==null?void 0:b.reportValidity())===!1?t(7,J=!1):re():t(7,J=!0)}function it(n){const u=n.target;k&&u&&!C.contains(u)&&$===m.VERIFIED&&t(8,C.style.display="none",C)}function ot(){k&&ze()}function lt(){$===m.VERIFYING&&c.waitAlert&&alert(c.waitAlert)}function er(n){k&&$!==m.UNVERIFIED&&requestAnimationFrame(()=>{ze()})}function st(){k&&ze()}function we(n){x("expire",n),B&&(clearTimeout(B),B=null),n<1?nt():B=setTimeout(nt,n)}function ct(n){x("floating",n),k!==n&&(t(8,C.style.left="",C),t(8,C.style.top="",C)),t(1,k=n===!0||n===""?"auto":n===!1||n==="false"?void 0:k),k?(a||t(0,a="onsubmit"),document.addEventListener("scroll",ot),document.addEventListener("click",it),window.addEventListener("resize",st)):a==="onsubmit"&&t(0,a=void 0)}function tr(n){var g;const u=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((g=u==null?void 0:u.value)==null?void 0:g.slice(u.value.indexOf("@")))||void 0}function rr(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(g=>`input[name="${g}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((g,A)=>{const D=A.name,j=A.value;return D&&j&&(g[D]=/\n/.test(j)?j.replace(new RegExp("(?D:k==="top",_=Math.max(n,Math.min(j-n-A.width,g.left+g.width/2-A.width/2));if(H?t(8,C.style.top=`${g.top-(A.height+u)}px`,C):t(8,C.style.top=`${g.bottom+u}px`,C),t(8,C.style.left=`${_}px`,C),C.setAttribute("data-floating",H?"top":"bottom"),ee){const L=ee.getBoundingClientRect();t(9,ee.style.left=g.left-_+g.width/2-L.width/2+"px",ee)}}else x("unable to find floating anchor element")}function at(n){n.auto!==void 0&&(t(0,a=n.auto),a==="onload"&&re()),n.floatinganchor!==void 0&&t(19,K=n.floatinganchor),n.delay!==void 0&&t(17,X=n.delay),n.floatingoffset!==void 0&&t(20,S=n.floatingoffset),n.floating!==void 0&&ct(n.floating),n.expire!==void 0&&(we(n.expire),t(18,F=n.expire)),n.challenge&&(rt(n.challenge),o=n.challenge),n.challengeurl!==void 0&&t(15,f=n.challengeurl),n.debug!==void 0&&t(16,N=!!n.debug),n.hidefooter!==void 0&&t(2,q=!!n.hidefooter),n.hidelogo!==void 0&&t(3,W=!!n.hidelogo),n.maxnumber!==void 0&&t(21,E=+n.maxnumber),n.mockerror!==void 0&&t(22,I=!!n.mockerror),n.name!==void 0&&t(4,V=n.name),n.refetchonexpire!==void 0&&t(23,z=!!n.refetchonexpire),n.spamfilter!==void 0&&t(24,y=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(35,l=n.strings),n.test!==void 0&&t(25,v=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(26,Q=n.verifyurl),n.workers!==void 0&&t(27,ue=+n.workers),n.workerurl!==void 0&&t(28,be=n.workerurl)}function ye(n=m.UNVERIFIED,u=null){B&&(clearTimeout(B),B=null),t(7,J=!1),t(10,Ie=u),t(5,te=null),t(6,$=n)}async function re(){return ye(m.VERIFYING),await new Promise(n=>setTimeout(n,X||0)),Kt().then(n=>(rt(n),x("challenge",n),Jt(n))).then(({data:n,solution:u})=>{if(x("solution",u),(u==null?void 0:u.number)!==void 0){if(Q)return nr(tt(n,u));t(5,te=tt(n,u)),x("payload",te)}else throw x("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{Ct().then(()=>{t(6,$=m.VERIFIED),t(7,J=!0),x("verified"),Re("verified",{payload:te})})}).catch(n=>{x(n),t(6,$=m.ERROR),t(7,J=!1),t(10,Ie=n.message)})}function or(){J=this.checked,t(7,J)}function lr(n){ge[n?"unshift":"push"](()=>{ee=n,t(9,ee)})}function sr(n){ge[n?"unshift":"push"](()=>{C=n,t(8,C)})}return r.$$set=n=>{"auto"in n&&t(0,a=n.auto),"blockspam"in n&&t(29,d=n.blockspam),"challengeurl"in n&&t(15,f=n.challengeurl),"challengejson"in n&&t(30,G=n.challengejson),"debug"in n&&t(16,N=n.debug),"delay"in n&&t(17,X=n.delay),"expire"in n&&t(18,F=n.expire),"floating"in n&&t(1,k=n.floating),"floatinganchor"in n&&t(19,K=n.floatinganchor),"floatingoffset"in n&&t(20,S=n.floatingoffset),"hidefooter"in n&&t(2,q=n.hidefooter),"hidelogo"in n&&t(3,W=n.hidelogo),"name"in n&&t(4,V=n.name),"maxnumber"in n&&t(21,E=n.maxnumber),"mockerror"in n&&t(22,I=n.mockerror),"refetchonexpire"in n&&t(23,z=n.refetchonexpire),"spamfilter"in n&&t(24,y=n.spamfilter),"strings"in n&&t(31,h=n.strings),"test"in n&&t(25,v=n.test),"verifyurl"in n&&t(26,Q=n.verifyurl),"workers"in n&&t(27,ue=n.workers),"workerurl"in n&&t(28,be=n.workerurl)},r.$$.update=()=>{r.$$.dirty[0]&32768&&t(12,i=!!(f!=null&&f.includes(".altcha.org"))&&!!(f!=null&&f.includes("apiKey=ckey_"))),r.$$.dirty[0]&1073741824&&(o=G?We(G):void 0),r.$$.dirty[1]&1&&t(35,l=h?We(h):{}),r.$$.dirty[1]&16&&t(11,c={ariaLinkLabel:He,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),r.$$.dirty[0]&96&&Re("statechange",{payload:te,state:$}),r.$$.dirty[0]&64&&er()},[a,k,q,W,V,te,$,J,C,ee,Ie,c,i,Qt,lt,f,N,X,F,K,S,E,I,z,y,v,Q,ue,be,d,G,h,at,ye,re,l,or,lr,sr]}class Ye extends Zt{constructor(e){super(),jt(this,e,Yt,Pt,ht,{auto:0,blockspam:29,challengeurl:15,challengejson:30,debug:16,delay:17,expire:18,floating:1,floatinganchor:19,floatingoffset:20,hidefooter:2,hidelogo:3,name:4,maxnumber:21,mockerror:22,refetchonexpire:23,spamfilter:24,strings:31,test:25,verifyurl:26,workers:27,workerurl:28,configure:32,reset:33,verify:34},Ut,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[29]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[15]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[30]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[16]}set debug(e){this.$$set({debug:e}),w()}get delay(){return this.$$.ctx[17]}set delay(e){this.$$set({delay:e}),w()}get expire(){return this.$$.ctx[18]}set expire(e){this.$$set({expire:e}),w()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),w()}get floatinganchor(){return this.$$.ctx[19]}set floatinganchor(e){this.$$set({floatinganchor:e}),w()}get floatingoffset(){return this.$$.ctx[20]}set floatingoffset(e){this.$$set({floatingoffset:e}),w()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),w()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),w()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),w()}get maxnumber(){return this.$$.ctx[21]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[22]}set mockerror(e){this.$$set({mockerror:e}),w()}get refetchonexpire(){return this.$$.ctx[23]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[24]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[31]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[25]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[26]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[27]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[28]}set workerurl(e){this.$$set({workerurl:e}),w()}get configure(){return this.$$.ctx[32]}get reset(){return this.$$.ctx[33]}get verify(){return this.$$.ctx[34]}}customElements.define("altcha-widget",Tt(Ye,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=r=>r?new Worker(new URL(r)):new dt,U.Altcha=Ye,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})}); +(function(g,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(g=typeof globalThis<"u"?globalThis:g||self,p(g.altcha={}))})(this,function(g){"use strict";var An=Object.defineProperty;var It=g=>{throw TypeError(g)};var zn=(g,p,j)=>p in g?An(g,p,{enumerable:!0,configurable:!0,writable:!0,value:j}):g[p]=j;var M=(g,p,j)=>zn(g,typeof p!="symbol"?p+"":p,j),At=(g,p,j)=>p.has(g)||It("Cannot "+j);var O=(g,p,j)=>(At(g,p,"read from private field"),j?j.call(g):p.get(g)),le=(g,p,j)=>p.has(g)?It("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(g):p.set(g,j),zt=(g,p,j,me)=>(At(g,p,"write to private field"),me?me.call(g,j):p.set(g,j),j);var de,he,we,ye,pe,_e;const p="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",j=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),me=typeof self<"u"&&self.Blob&&new Blob([j(p)],{type:"text/javascript;charset=utf-8"});function Tt(n){let e;try{if(e=me&&(self.URL||self.webkitURL).createObjectURL(me),!e)throw"";const t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+p,{name:n==null?void 0:n.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}function ae(){}function Oe(n){return n()}function Pe(){return Object.create(null)}function ge(n){n.forEach(Oe)}function Xe(n){return typeof n=="function"}function Ft(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function St(n){return Object.keys(n).length===0}function C(n,e){n.appendChild(e)}function Nt(n,e,t){const i=Mt(n);if(!i.getElementById(e)){const o=L("style");o.id=e,o.textContent=t,jt(i,o)}}function Mt(n){if(!n)return document;const e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function jt(n,e){return C(n.head||n,e),e.sheet}function D(n,e,t){n.insertBefore(e,t||null)}function S(n){n.parentNode&&n.parentNode.removeChild(n)}function L(n){return document.createElement(n)}function $(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function He(n){return document.createTextNode(n)}function q(){return He(" ")}function Dt(){return He("")}function Me(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function a(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Ut(n){return Array.from(n.childNodes)}function We(n,e,t){n.classList.toggle(e,!!t)}function Zt(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function Vt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let be;function ve(n){be=n}function je(){if(!be)throw new Error("Function called outside component initialization");return be}function Bt(n){je().$$.on_mount.push(n)}function Gt(n){je().$$.on_destroy.push(n)}function Ot(){const n=je();return(e,t,{cancelable:i=!1}={})=>{const o=n.$$.callbacks[e];if(o){const s=Zt(e,t,{cancelable:i});return o.slice().forEach(u=>{u.call(n,s)}),!s.defaultPrevented}return!0}}const ce=[],Ce=[];let fe=[];const Ye=[],Ke=Promise.resolve();let De=!1;function Je(){De||(De=!0,Ke.then(k))}function Pt(){return Je(),Ke}function Ue(n){fe.push(n)}const Ze=new Set;let ue=0;function k(){if(ue!==0)return;const n=be;do{try{for(;uen.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),fe=e}const Wt=new Set;function Yt(n,e){n&&n.i&&(Wt.delete(n),n.i(e))}function Kt(n,e,t){const{fragment:i,after_update:o}=n.$$;i&&i.m(e,t),Ue(()=>{const s=n.$$.on_mount.map(Oe).filter(Xe);n.$$.on_destroy?n.$$.on_destroy.push(...s):ge(s),n.$$.on_mount=[]}),o.forEach(Ue)}function Jt(n,e){const t=n.$$;t.fragment!==null&&(Ht(t.after_update),ge(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function $t(n,e){n.$$.dirty[0]===-1&&(ce.push(n),Je(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const W=H.length?H[0]:X;return f.ctx&&o(f.ctx[v],f.ctx[v]=W)&&(!f.skip_bound&&f.bound[v]&&f.bound[v](W),P&&$t(n,v)),X}):[],f.update(),P=!0,ge(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const v=Ut(e.target);f.fragment&&f.fragment.l(v),v.forEach(S)}else f.fragment&&f.fragment.c();e.intro&&Yt(n.$$.fragment),Kt(n,e.target,e.anchor),k()}ve(l)}let $e;typeof HTMLElement=="function"&&($e=class extends HTMLElement{constructor(e,t,i){super();M(this,"$$ctor");M(this,"$$s");M(this,"$$c");M(this,"$$cn",!1);M(this,"$$d",{});M(this,"$$r",!1);M(this,"$$p_d",{});M(this,"$$l",{});M(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(s){return()=>{let u;return{c:function(){u=L("slot"),s!=="default"&&a(u,"name",s)},m:function(f,P){D(f,u,P)},d:function(f){f&&S(u)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=Vt(this);for(const s of this.$$s)s in i&&(t[s]=[e(s)]);for(const s of this.attributes){const u=this.$$g_p(s.name);u in this.$$d||(this.$$d[u]=Le(u,s.value,this.$$p_d,"toProp"))}for(const s in this.$$p_d)!(s in this.$$d)&&this[s]!==void 0&&(this.$$d[s]=this[s],delete this[s]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const s in this.$$p_d)if(this.$$d[s]=this.$$c.$$.ctx[this.$$c.$$.props[s]],this.$$p_d[s].reflect){const u=Le(s,this.$$d[s],this.$$p_d,"toAttribute");u==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,u)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const s in this.$$l)for(const u of this.$$l[s]){const c=this.$$c.$on(s,u);this.$$l_u.set(u,c)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Le(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Le(n,e,t,i){var s;const o=(s=t[n])==null?void 0:s.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Qt(n,e,t,i,o,s){let u=class extends $e{constructor(){super(n,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(c=>(e[c].attribute||c).toLowerCase())}};return Object.keys(e).forEach(c=>{Object.defineProperty(u.prototype,c,{get(){return this.$$c&&c in this.$$c?this.$$c[c]:this.$$d[c]},set(l){var f;l=Le(c,l,e),this.$$d[c]=l,(f=this.$$c)==null||f.$set({[c]:l})}})}),i.forEach(c=>{Object.defineProperty(u.prototype,c,{get(){var l;return(l=this.$$c)==null?void 0:l[c]}})}),n.element=u,u}class en{constructor(){M(this,"$$");M(this,"$$set")}$destroy(){Jt(this,1),this.$destroy=ae}$on(e,t){if(!Xe(t))return ae;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!St(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const tn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(tn);const nn=new TextEncoder;function rn(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function on(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await qe(i,n,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function qe(n,e,t){return rn(await crypto.subtle.digest(t.toUpperCase(),nn.encode(n+e)))}function sn(n,e,t="SHA-256",i=1e6,o=0){const s=new AbortController,u=Date.now();return{promise:(async()=>{for(let l=o;l<=i;l+=1){if(s.signal.aborted)return null;if(await qe(e,l,t)===n)return{number:l,took:Date.now()-u}}return null})(),controller:s}}function Qe(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}class ln{constructor(e){M(this,"beaconUrl",null);M(this,"error",null);M(this,"loadTime",Date.now());M(this,"submitTime",null);M(this,"startTime",null);M(this,"viewTimeThresholdMs",1500);le(this,de,{});le(this,he,null);le(this,we,this.onFormChange.bind(this));le(this,ye,this.onFormFocus.bind(this));le(this,pe,this.onFormSubmit.bind(this));le(this,_e,this.onUnload.bind(this));this.elForm=e,window.addEventListener("unload",O(this,_e)),this.elForm.addEventListener("change",O(this,we)),this.elForm.addEventListener("focusin",O(this,ye)),this.elForm.addEventListener("submit",O(this,pe))}data(){const e=Object.entries(O(this,de));return{correction:e.length&&e.filter(([t,i])=>i>1).length/e.length||0,dropoff:!this.submitTime&&!this.error&&O(this,he)?O(this,he):null,error:this.error,mobile:this.isMobile(),start:this.startTime,submit:this.submitTime,tz:Qe()}}dataAsBase64(){try{return btoa(JSON.stringify(this.data()))}catch(e){console.error("failed to encode ALTCHA session data to base64",e)}return""}destroy(){window.removeEventListener("unload",O(this,_e)),this.elForm.removeEventListener("change",O(this,we)),this.elForm.removeEventListener("focusin",O(this,ye)),this.elForm.removeEventListener("submit",O(this,pe))}end(){this.submitTime||(this.submitTime=Date.now())}getFieldName(e,t=40){const i=e.getAttribute("data-group-label"),o=e.getAttribute("name")||e.getAttribute("aria-label");return((i?i+": ":"")+o).slice(0,t)}isMobile(){const e="userAgentData"in navigator&&navigator.userAgentData?navigator.userAgentData:{};return"mobile"in e?e.mobile===!0:/Mobi/i.test(window.navigator.userAgent)}isInput(e){return["INPUT","SELECT","TEXTAREA"].includes(e.tagName)}onFormFieldChange(e){const t=this.getFieldName(e);t&&this.trackFieldChange(t)}onFormChange(e){const t=e.target;t&&this.isInput(t)&&this.onFormFieldChange(t)}onFormFocus(e){const t=e.target;if(this.startTime||this.start(),t&&this.isInput(t)){const i=this.getFieldName(t);i&&zt(this,he,i)}}onFormSubmit(){this.end()}onUnload(){this.loadTime<=Date.now()-this.viewTimeThresholdMs&&!this.submitTime&&this.sendBeacon()}async sendBeacon(){if(this.beaconUrl&&"sendBeacon"in navigator)try{navigator.sendBeacon(new URL(this.beaconUrl,location.origin),JSON.stringify(this.data()))}catch{}}start(){this.startTime=Date.now()}trackError(e){this.error=e===null?null:String(e)}trackFieldChange(e){O(this,de)[e]=(O(this,de)[e]||0)+1}}de=new WeakMap,he=new WeakMap,we=new WeakMap,ye=new WeakMap,pe=new WeakMap,_e=new WeakMap;var b=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(b||{});function an(n){Nt(n,"svelte-ddsc3z",'.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}')}function et(n){let e,t,i;return{c(){e=$("svg"),t=$("path"),i=$("path"),a(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),a(t,"fill","currentColor"),a(t,"opacity",".25"),a(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),a(i,"fill","currentColor"),a(i,"class","altcha-spinner svelte-ddsc3z"),a(e,"width","24"),a(e,"height","24"),a(e,"viewBox","0 0 24 24"),a(e,"xmlns","http://www.w3.org/2000/svg")},m(o,s){D(o,e,s),C(e,t),C(e,i)},d(o){o&&S(e)}}}function cn(n){let e,t=n[13].label+"",i;return{c(){e=L("label"),a(e,"for",i=n[4]+"_checkbox"),a(e,"class","svelte-ddsc3z")},m(o,s){D(o,e,s),e.innerHTML=t},p(o,s){s[0]&8192&&t!==(t=o[13].label+"")&&(e.innerHTML=t),s[0]&16&&i!==(i=o[4]+"_checkbox")&&a(e,"for",i)},d(o){o&&S(e)}}}function fn(n){let e,t=n[13].verifying+"";return{c(){e=L("span")},m(i,o){D(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].verifying+"")&&(e.innerHTML=t)},d(i){i&&S(e)}}}function un(n){let e,t=n[13].verified+"",i,o,s,u,c=n[11]&&tt(n);return{c(){e=L("span"),i=q(),o=L("input"),s=q(),c&&c.c(),u=Dt(),a(o,"type","hidden"),a(o,"name",n[4]),o.value=n[6]},m(l,f){D(l,e,f),e.innerHTML=t,D(l,i,f),D(l,o,f),D(l,s,f),c&&c.m(l,f),D(l,u,f)},p(l,f){f[0]&8192&&t!==(t=l[13].verified+"")&&(e.innerHTML=t),f[0]&16&&a(o,"name",l[4]),f[0]&64&&(o.value=l[6]),l[11]?c?c.p(l,f):(c=tt(l),c.c(),c.m(u.parentNode,u)):c&&(c.d(1),c=null)},d(l){l&&(S(e),S(i),S(o),S(s),S(u)),c&&c.d(l)}}}function tt(n){let e;return{c(){e=L("input"),a(e,"type","hidden"),a(e,"name","__session"),e.value=n[12]},m(t,i){D(t,e,i)},p(t,i){i[0]&4096&&(e.value=t[12])},d(t){t&&S(e)}}}function nt(n){let e,t,i,o,s,u,c;return{c(){e=L("div"),t=L("a"),i=$("svg"),o=$("path"),s=$("path"),u=$("path"),a(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),a(o,"fill","currentColor"),a(s,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),a(s,"fill","currentColor"),a(u,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),a(u,"fill","currentColor"),a(i,"width","22"),a(i,"height","22"),a(i,"viewBox","0 0 20 20"),a(i,"fill","none"),a(i,"xmlns","http://www.w3.org/2000/svg"),a(t,"href",lt),a(t,"target","_blank"),a(t,"class","altcha-logo svelte-ddsc3z"),a(t,"aria-label",c=n[13].ariaLinkLabel)},m(l,f){D(l,e,f),C(e,t),C(t,i),C(i,o),C(i,s),C(i,u)},p(l,f){f[0]&8192&&c!==(c=l[13].ariaLinkLabel)&&a(t,"aria-label",c)},d(l){l&&S(e)}}}function rt(n){let e,t,i,o;function s(l,f){return l[7]===b.EXPIRED?hn:dn}let u=s(n),c=u(n);return{c(){e=L("div"),t=$("svg"),i=$("path"),o=q(),c.c(),a(i,"stroke-linecap","round"),a(i,"stroke-linejoin","round"),a(i,"d","M6 18L18 6M6 6l12 12"),a(t,"width","14"),a(t,"height","14"),a(t,"xmlns","http://www.w3.org/2000/svg"),a(t,"fill","none"),a(t,"viewBox","0 0 24 24"),a(t,"stroke-width","1.5"),a(t,"stroke","currentColor"),a(e,"class","altcha-error svelte-ddsc3z")},m(l,f){D(l,e,f),C(e,t),C(t,i),C(e,o),c.m(e,null)},p(l,f){u===(u=s(l))&&c?c.p(l,f):(c.d(1),c=u(l),c&&(c.c(),c.m(e,null)))},d(l){l&&S(e),c.d()}}}function dn(n){let e,t=n[13].error+"";return{c(){e=L("div"),a(e,"title",n[5])},m(i,o){D(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].error+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&S(e)}}}function hn(n){let e,t=n[13].expired+"";return{c(){e=L("div"),a(e,"title",n[5])},m(i,o){D(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].expired+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&S(e)}}}function it(n){let e,t,i=n[13].footer+"";return{c(){e=L("div"),t=L("div"),a(t,"class","svelte-ddsc3z"),a(e,"class","altcha-footer svelte-ddsc3z")},m(o,s){D(o,e,s),C(e,t),t.innerHTML=i},p(o,s){s[0]&8192&&i!==(i=o[13].footer+"")&&(t.innerHTML=i)},d(o){o&&S(e)}}}function ot(n){let e;return{c(){e=L("div"),a(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){D(t,e,i),n[41](e)},p:ae,d(t){t&&S(e),n[41](null)}}}function mn(n){let e,t,i,o,s,u,c,l,f,P,v,X,H,W,Q,w=n[7]===b.VERIFYING&&et();function te(h,E){return h[7]===b.VERIFIED?un:h[7]===b.VERIFYING?fn:cn}let ee=te(n),Z=ee(n),z=(n[3]!==!0||n[14])&&nt(n),N=(n[5]||n[7]===b.EXPIRED)&&rt(n),R=n[13].footer&&(n[2]!==!0||n[14])&&it(n),T=n[1]&&ot(n);return{c(){e=L("div"),t=L("div"),w&&w.c(),i=q(),o=L("div"),s=L("input"),l=q(),f=L("div"),Z.c(),P=q(),z&&z.c(),v=q(),N&&N.c(),X=q(),R&&R.c(),H=q(),T&&T.c(),a(s,"type","checkbox"),a(s,"id",u=n[4]+"_checkbox"),s.required=c=n[0]!=="onsubmit",a(s,"class","svelte-ddsc3z"),a(o,"class","altcha-checkbox svelte-ddsc3z"),We(o,"altcha-hidden",n[7]===b.VERIFYING),a(f,"class","altcha-label svelte-ddsc3z"),a(t,"class","altcha-main svelte-ddsc3z"),a(e,"class","altcha svelte-ddsc3z"),a(e,"data-state",n[7]),a(e,"data-floating",n[1])},m(h,E){D(h,e,E),C(e,t),w&&w.m(t,null),C(t,i),C(t,o),C(o,s),s.checked=n[8],C(t,l),C(t,f),Z.m(f,null),C(t,P),z&&z.m(t,null),C(e,v),N&&N.m(e,null),C(e,X),R&&R.m(e,null),C(e,H),T&&T.m(e,null),n[42](e),W||(Q=[Me(s,"change",n[40]),Me(s,"change",n[15]),Me(s,"invalid",n[16])],W=!0)},p(h,E){h[7]===b.VERIFYING?w||(w=et(),w.c(),w.m(t,i)):w&&(w.d(1),w=null),E[0]&16&&u!==(u=h[4]+"_checkbox")&&a(s,"id",u),E[0]&1&&c!==(c=h[0]!=="onsubmit")&&(s.required=c),E[0]&256&&(s.checked=h[8]),E[0]&128&&We(o,"altcha-hidden",h[7]===b.VERIFYING),ee===(ee=te(h))&&Z?Z.p(h,E):(Z.d(1),Z=ee(h),Z&&(Z.c(),Z.m(f,null))),h[3]!==!0||h[14]?z?z.p(h,E):(z=nt(h),z.c(),z.m(t,null)):z&&(z.d(1),z=null),h[5]||h[7]===b.EXPIRED?N?N.p(h,E):(N=rt(h),N.c(),N.m(e,X)):N&&(N.d(1),N=null),h[13].footer&&(h[2]!==!0||h[14])?R?R.p(h,E):(R=it(h),R.c(),R.m(e,H)):R&&(R.d(1),R=null),h[1]?T?T.p(h,E):(T=ot(h),T.c(),T.m(e,null)):T&&(T.d(1),T=null),E[0]&128&&a(e,"data-state",h[7]),E[0]&2&&a(e,"data-floating",h[1])},i:ae,o:ae,d(h){h&&S(e),w&&w.d(),Z.d(),z&&z.d(),N&&N.d(),R&&R.d(),T&&T.d(),n[42](null),W=!1,ge(Q)}}}const st="Visit Altcha.org",lt="https://altcha.org/";function at(n){return JSON.parse(n)}function gn(n,e,t){var Lt,Rt;let i,o,s,u,{analytics:c=!1}=e,{auto:l=void 0}=e,{beaconurl:f=void 0}=e,{blockspam:P=void 0}=e,{challengeurl:v=void 0}=e,{challengejson:X=void 0}=e,{debug:H=!1}=e,{delay:W=0}=e,{expire:Q=void 0}=e,{floating:w=void 0}=e,{floatinganchor:te=void 0}=e,{floatingoffset:ee=void 0}=e,{hidefooter:Z=!1}=e,{hidelogo:z=!1}=e,{name:N="altcha"}=e,{maxnumber:R=1e6}=e,{mockerror:T=!1}=e,{refetchonexpire:h=!0}=e,{spamfilter:E=!1}=e,{strings:Re=void 0}=e,{test:Y=!1}=e,{verifyurl:re=void 0}=e,{workers:ke=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:Ie=void 0}=e;const Ve=Ot(),ft=["SHA-256","SHA-384","SHA-512"],ut=(Rt=(Lt=document.documentElement.lang)==null?void 0:Lt.split("-"))==null?void 0:Rt[0];let ne=!1,I,ie=null,Ae=null,m=null,ze=null,K=null,oe=null,V=null,dt=null,B=b.UNVERIFIED;Gt(()=>{m&&(m.removeEventListener("submit",mt),m.removeEventListener("reset",gt),m.removeEventListener("focusin",ht),m=null),V&&V.destroy(),K&&(clearTimeout(K),K=null),document.removeEventListener("click",pt),document.removeEventListener("scroll",_t),window.removeEventListener("resize",Et)}),Bt(()=>{x("mounted","0.7.0"),x("workers",ke),Y&&x("using test mode"),Q&&Te(Q),l!==void 0&&x("auto",l),w!==void 0&&xt(w),m=I.closest("form"),m&&(m.addEventListener("submit",mt,{capture:!0}),m.addEventListener("reset",gt),l==="onfocus"&&m.addEventListener("focusin",ht)),c&&wt(),l==="onload"&&se(),i&&(Z||z)&&x("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.")});function x(...r){(H||r.some(d=>d instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",...r)}function ht(r){B===b.UNVERIFIED&&se()}function mt(r){m&&V&&B===b.VERIFIED&&(V.end(),t(12,dt=V.dataAsBase64())),m&&l==="onsubmit"&&(B===b.UNVERIFIED?(r.preventDefault(),r.stopPropagation(),se().then(()=>{m==null||m.requestSubmit()})):B!==b.VERIFIED&&(r.preventDefault(),r.stopPropagation(),B===b.VERIFYING&&kt()))}function gt(){Fe()}function bt(r,d){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:d.number,salt:r.salt,signature:r.signature,test:Y?!0:void 0,took:d.took}))}function vt(r){if(!r.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(r.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!ft.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${ft.join(", ")}`);if(!r.challenge||r.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!r.salt||r.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function bn(){var r;if(T)throw x("mocking error"),new Error("Mocked error.");if(o)return x("using provided json data"),o;if(Y)return x("generating test challenge",{test:Y}),on(typeof Y!="boolean"?+Y:void 0);{if(!v&&m){const _=m.getAttribute("action");_!=null&&_.includes("/form/")&&t(17,v=_+"/altcha")}if(!v)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",v);const d=await fetch(v,{headers:E?{"x-altcha-spam-filter":"1"}:{}});if(d.status!==200)throw new Error(`Server responded with ${d.status}.`);const y=d.headers.get("Expires"),F=d.headers.get("X-Altcha-Config"),G=await d.json(),U=new URLSearchParams((r=G.salt.split("?"))==null?void 0:r[1]),J=U.get("expires")||U.get("expire");if(J){const _=new Date(+J*1e3),A=isNaN(_.getTime())?0:_.getTime()-Date.now();A>0&&Te(A)}if(F)try{const _=JSON.parse(F);_&&typeof _=="object"&&(_.verifyurl&&(_.verifyurl=new URL(_.verifyurl,new URL(v)).toString()),Ct(_))}catch(_){x("unable to configure from X-Altcha-Config",_)}if(!Q&&(y!=null&&y.length)){const _=Date.parse(y);if(_){const A=_-Date.now();A>0&&Te(A)}}return G}}function wt(){if(!V)if(m){if(x("analytics enabled"),t(11,V=new ln(m)),f===void 0){const r=m.getAttribute("action");r&&t(19,f=r+"/beacon")}t(11,V.beaconUrl=f||null,V)}else x("analytics cannot be enabled - form element not found")}function yt(){v&&h&&B===b.VERIFIED?se():Fe(b.EXPIRED,u.expired)}async function vn(r){let d=null;if("Worker"in window){try{d=await wn(r.challenge,r.salt,r.algorithm,r.maxnumber)}catch(y){x(y)}if((d==null?void 0:d.number)!==void 0)return{data:r,solution:d}}return{data:r,solution:await sn(r.challenge,r.salt,r.algorithm,r.maxnumber||R).promise}}async function wn(r,d,y,F=typeof Y=="number"?Y:R,G=Math.ceil(ke)){const U=[];G=Math.min(16,Math.max(1,G));for(let A=0;A{const Ee=Ge*J;return new Promise(Se=>{A.addEventListener("message",Ne=>{if(Ne.data)for(const xe of U)xe!==A&&xe.postMessage({type:"abort"});Se(Ne.data)}),A.postMessage({payload:{alg:y,challenge:r,max:Ee+J,salt:d,start:Ee},type:"work"})})}));for(const A of U)A.terminate();return _.find(A=>!!A)||null}function yn(){[b.UNVERIFIED,b.ERROR,b.EXPIRED].includes(B)?E&&(m==null?void 0:m.reportValidity())===!1?t(8,ne=!1):se():t(8,ne=!0)}function pt(r){const d=r.target;w&&d&&!I.contains(d)&&B===b.VERIFIED&&t(9,I.style.display="none",I)}function _t(){w&&Be()}function kt(){B===b.VERIFYING&&u.waitAlert&&alert(u.waitAlert)}function pn(r){V&&V.trackError(ze)}function _n(r){w&&B!==b.UNVERIFIED&&requestAnimationFrame(()=>{Be()})}function Et(){w&&Be()}function Te(r){x("expire",r),K&&(clearTimeout(K),K=null),r<1?yt():K=setTimeout(yt,r)}function xt(r){x("floating",r),w!==r&&(t(9,I.style.left="",I),t(9,I.style.top="",I)),t(1,w=r===!0||r===""?"auto":r===!1||r==="false"?void 0:w),w?(l||t(0,l="onsubmit"),document.addEventListener("scroll",_t),document.addEventListener("click",pt),window.addEventListener("resize",Et)):l==="onsubmit"&&t(0,l=void 0)}function kn(r){var y;const d=m==null?void 0:m.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((y=d==null?void 0:d.value)==null?void 0:y.slice(d.value.indexOf("@")))||void 0}function En(r){return[...(m==null?void 0:m.querySelectorAll(r!=null&&r.length?r.map(y=>`input[name="${y}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((y,F)=>{const G=F.name,U=F.value;return G&&U&&(y[G]=/\n/.test(U)?U.replace(new RegExp("(?G:w==="top",_=Math.max(r,Math.min(U-r-F.width,y.left+y.width/2-F.width/2));if(J?t(9,I.style.top=`${y.top-(F.height+d)}px`,I):t(9,I.style.top=`${y.bottom+d}px`,I),t(9,I.style.left=`${_}px`,I),I.setAttribute("data-floating",J?"top":"bottom"),ie){const A=ie.getBoundingClientRect();t(10,ie.style.left=y.left-_+y.width/2-A.width/2+"px",ie)}}else x("unable to find floating anchor element")}function Ct(r){r.analytics&&(t(18,c=r.analytics),wt()),r.auto!==void 0&&(t(0,l=r.auto),l==="onload"&&se()),r.beaconurl&&(t(19,f=r.beaconurl),V&&t(11,V.beaconUrl=f,V)),r.floatinganchor!==void 0&&t(23,te=r.floatinganchor),r.delay!==void 0&&t(21,W=r.delay),r.floatingoffset!==void 0&&t(24,ee=r.floatingoffset),r.floating!==void 0&&xt(r.floating),r.expire!==void 0&&(Te(r.expire),t(22,Q=r.expire)),r.challenge&&(vt(r.challenge),o=r.challenge),r.challengeurl!==void 0&&t(17,v=r.challengeurl),r.debug!==void 0&&t(20,H=!!r.debug),r.hidefooter!==void 0&&t(2,Z=!!r.hidefooter),r.hidelogo!==void 0&&t(3,z=!!r.hidelogo),r.maxnumber!==void 0&&t(25,R=+r.maxnumber),r.mockerror!==void 0&&t(26,T=!!r.mockerror),r.name!==void 0&&t(4,N=r.name),r.refetchonexpire!==void 0&&t(27,h=!!r.refetchonexpire),r.spamfilter!==void 0&&t(28,E=typeof r.spamfilter=="object"?r.spamfilter:!!r.spamfilter),r.strings&&t(39,s=r.strings),r.test!==void 0&&t(29,Y=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(30,re=r.verifyurl),r.workers!==void 0&&t(31,ke=+r.workers),r.workerurl!==void 0&&t(32,Ie=r.workerurl)}function Fe(r=b.UNVERIFIED,d=null){K&&(clearTimeout(K),K=null),t(8,ne=!1),t(5,ze=d),t(6,oe=null),t(7,B=r)}async function se(){return Fe(b.VERIFYING),await new Promise(r=>setTimeout(r,W||0)),bn().then(r=>(vt(r),x("challenge",r),vn(r))).then(({data:r,solution:d})=>{if(x("solution",d),(d==null?void 0:d.number)!==void 0){if(re)return xn(bt(r,d));t(6,oe=bt(r,d)),x("payload",oe)}else throw x("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{Pt().then(()=>{t(7,B=b.VERIFIED),t(8,ne=!0),x("verified"),Ve("verified",{payload:oe})})}).catch(r=>{x(r),t(7,B=b.ERROR),t(8,ne=!1),t(5,ze=r.message)})}function Ln(){ne=this.checked,t(8,ne)}function Rn(r){Ce[r?"unshift":"push"](()=>{ie=r,t(10,ie)})}function In(r){Ce[r?"unshift":"push"](()=>{I=r,t(9,I)})}return n.$$set=r=>{"analytics"in r&&t(18,c=r.analytics),"auto"in r&&t(0,l=r.auto),"beaconurl"in r&&t(19,f=r.beaconurl),"blockspam"in r&&t(33,P=r.blockspam),"challengeurl"in r&&t(17,v=r.challengeurl),"challengejson"in r&&t(34,X=r.challengejson),"debug"in r&&t(20,H=r.debug),"delay"in r&&t(21,W=r.delay),"expire"in r&&t(22,Q=r.expire),"floating"in r&&t(1,w=r.floating),"floatinganchor"in r&&t(23,te=r.floatinganchor),"floatingoffset"in r&&t(24,ee=r.floatingoffset),"hidefooter"in r&&t(2,Z=r.hidefooter),"hidelogo"in r&&t(3,z=r.hidelogo),"name"in r&&t(4,N=r.name),"maxnumber"in r&&t(25,R=r.maxnumber),"mockerror"in r&&t(26,T=r.mockerror),"refetchonexpire"in r&&t(27,h=r.refetchonexpire),"spamfilter"in r&&t(28,E=r.spamfilter),"strings"in r&&t(35,Re=r.strings),"test"in r&&t(29,Y=r.test),"verifyurl"in r&&t(30,re=r.verifyurl),"workers"in r&&t(31,ke=r.workers),"workerurl"in r&&t(32,Ie=r.workerurl)},n.$$.update=()=>{n.$$.dirty[0]&131072&&t(14,i=!!(v!=null&&v.includes(".altcha.org"))&&!!(v!=null&&v.includes("apiKey=ckey_"))),n.$$.dirty[1]&8&&(o=X?at(X):void 0),n.$$.dirty[1]&16&&t(39,s=Re?at(Re):{}),n.$$.dirty[1]&256&&t(13,u={ariaLinkLabel:st,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...s}),n.$$.dirty[0]&192&&Ve("statechange",{payload:oe,state:B}),n.$$.dirty[0]&32&&pn(),n.$$.dirty[0]&128&&_n()},[l,w,Z,z,N,ze,oe,B,ne,I,ie,V,dt,u,i,yn,kt,v,c,f,H,W,Q,te,ee,R,T,h,E,Y,re,ke,Ie,P,X,Re,Ct,Fe,se,s,Ln,Rn,In]}class ct extends en{constructor(e){super(),qt(this,e,gn,mn,Ft,{analytics:18,auto:0,beaconurl:19,blockspam:33,challengeurl:17,challengejson:34,debug:20,delay:21,expire:22,floating:1,floatinganchor:23,floatingoffset:24,hidefooter:2,hidelogo:3,name:4,maxnumber:25,mockerror:26,refetchonexpire:27,spamfilter:28,strings:35,test:29,verifyurl:30,workers:31,workerurl:32,configure:36,reset:37,verify:38},an,[-1,-1,-1])}get analytics(){return this.$$.ctx[18]}set analytics(e){this.$$set({analytics:e}),k()}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),k()}get beaconurl(){return this.$$.ctx[19]}set beaconurl(e){this.$$set({beaconurl:e}),k()}get blockspam(){return this.$$.ctx[33]}set blockspam(e){this.$$set({blockspam:e}),k()}get challengeurl(){return this.$$.ctx[17]}set challengeurl(e){this.$$set({challengeurl:e}),k()}get challengejson(){return this.$$.ctx[34]}set challengejson(e){this.$$set({challengejson:e}),k()}get debug(){return this.$$.ctx[20]}set debug(e){this.$$set({debug:e}),k()}get delay(){return this.$$.ctx[21]}set delay(e){this.$$set({delay:e}),k()}get expire(){return this.$$.ctx[22]}set expire(e){this.$$set({expire:e}),k()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),k()}get floatinganchor(){return this.$$.ctx[23]}set floatinganchor(e){this.$$set({floatinganchor:e}),k()}get floatingoffset(){return this.$$.ctx[24]}set floatingoffset(e){this.$$set({floatingoffset:e}),k()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),k()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),k()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),k()}get maxnumber(){return this.$$.ctx[25]}set maxnumber(e){this.$$set({maxnumber:e}),k()}get mockerror(){return this.$$.ctx[26]}set mockerror(e){this.$$set({mockerror:e}),k()}get refetchonexpire(){return this.$$.ctx[27]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),k()}get spamfilter(){return this.$$.ctx[28]}set spamfilter(e){this.$$set({spamfilter:e}),k()}get strings(){return this.$$.ctx[35]}set strings(e){this.$$set({strings:e}),k()}get test(){return this.$$.ctx[29]}set test(e){this.$$set({test:e}),k()}get verifyurl(){return this.$$.ctx[30]}set verifyurl(e){this.$$set({verifyurl:e}),k()}get workers(){return this.$$.ctx[31]}set workers(e){this.$$set({workers:e}),k()}get workerurl(){return this.$$.ctx[32]}set workerurl(e){this.$$set({workerurl:e}),k()}get configure(){return this.$$.ctx[36]}get reset(){return this.$$.ctx[37]}get verify(){return this.$$.ctx[38]}}customElements.define("altcha-widget",Qt(ct,{analytics:{type:"Boolean"},auto:{},beaconurl:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=n=>n?new Worker(new URL(n)):new Tt,g.Altcha=ct,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}); diff --git a/dist_external/altcha.d.ts b/dist_external/altcha.d.ts index 4eea955..020d6e6 100644 --- a/dist_external/altcha.d.ts +++ b/dist_external/altcha.d.ts @@ -17,7 +17,9 @@ declare global { interface AltchaServerVerificationEvent extends CustomEvent> {} interface AltchaWidget { + analytics?: boolean | string; auto?: 'onfocus' | 'onload' | 'onsubmit'; + beaconurl?: string; blockspam?: boolean; challengeurl?: string; challengejson?: string; diff --git a/dist_external/altcha.js b/dist_external/altcha.js index 0eaea2e..3e3f282 100644 --- a/dist_external/altcha.js +++ b/dist_external/altcha.js @@ -1,63 +1,70 @@ -var yt = Object.defineProperty; -var vt = (n, e, t) => e in n ? yt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; -var O = (n, e, t) => vt(n, typeof e != "symbol" ? e + "" : e, t); -function ie() { +var Pt = Object.defineProperty; +var it = (n) => { + throw TypeError(n); +}; +var Ut = (n, e, t) => e in n ? Pt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; +var S = (n, e, t) => Ut(n, typeof e != "symbol" ? e + "" : e, t), rt = (n, e, t) => e.has(n) || it("Cannot " + t); +var U = (n, e, t) => (rt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), re = (n, e, t) => e.has(n) ? it("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), ot = (n, e, t, r) => (rt(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t); +function ce() { } -function et(n) { +function wt(n) { return n(); } -function qe() { +function st() { return /* @__PURE__ */ Object.create(null); } -function ue(n) { - n.forEach(et); +function ve(n) { + n.forEach(wt); } -function tt(n) { +function _t(n) { return typeof n == "function"; } -function kt(n, e) { +function Ot(n, e) { return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function"; } -function Et(n) { +function Ht(n) { return Object.keys(n).length === 0; } function p(n, e) { n.appendChild(e); } -function F(n, e, t) { +function M(n, e, t) { n.insertBefore(e, t || null); } function D(n) { n.parentNode && n.parentNode.removeChild(n); } -function M(n) { +function F(n) { return document.createElement(n); } -function Y(n) { +function z(n) { return document.createElementNS("http://www.w3.org/2000/svg", n); } -function pt(n) { +function yt(n) { return document.createTextNode(n); } -function X() { - return pt(" "); +function W() { + return yt(" "); +} +function $t() { + return yt(""); } -function pe(n, e, t, i) { - return n.addEventListener(e, t, i), () => n.removeEventListener(e, t, i); +function Me(n, e, t, r) { + return n.addEventListener(e, t, r), () => n.removeEventListener(e, t, r); } -function s(n, e, t) { +function a(n, e, t) { t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t); } -function xt(n) { +function qt(n) { return Array.from(n.childNodes); } -function Ze(n, e, t) { +function lt(n, e, t) { n.classList.toggle(e, !!t); } -function Ct(n, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { - return new CustomEvent(n, { detail: e, bubbles: t, cancelable: i }); +function Zt(n, e, { bubbles: t = !1, cancelable: r = !1 } = {}) { + return new CustomEvent(n, { detail: e, bubbles: t, cancelable: r }); } -function Lt(n) { +function Yt(n) { const e = {}; return n.childNodes.forEach( /** @param {Element} node */ @@ -66,215 +73,215 @@ function Lt(n) { } ), e; } -let ce; -function fe(n) { - ce = n; +let me; +function ge(n) { + me = n; } -function Ie() { - if (!ce) throw new Error("Function called outside component initialization"); - return ce; +function Be() { + if (!me) throw new Error("Function called outside component initialization"); + return me; } -function It(n) { - Ie().$$.on_mount.push(n); +function Gt(n) { + Be().$$.on_mount.push(n); } -function At(n) { - Ie().$$.on_destroy.push(n); +function Jt(n) { + Be().$$.on_destroy.push(n); } -function Rt() { - const n = Ie(); - return (e, t, { cancelable: i = !1 } = {}) => { +function Xt() { + const n = Be(); + return (e, t, { cancelable: r = !1 } = {}) => { const o = n.$$.callbacks[e]; if (o) { - const l = Ct( + const s = Zt( /** @type {string} */ e, t, - { cancelable: i } + { cancelable: r } ); - return o.slice().forEach((f) => { - f.call(n, l); - }), !l.defaultPrevented; + return o.slice().forEach((u) => { + u.call(n, s); + }), !s.defaultPrevented; } return !0; }; } -const ne = [], we = []; -let re = []; -const Ye = [], nt = /* @__PURE__ */ Promise.resolve(); -let Ce = !1; -function rt() { - Ce || (Ce = !0, nt.then(y)); +const se = [], Fe = []; +let le = []; +const at = [], vt = /* @__PURE__ */ Promise.resolve(); +let je = !1; +function Et() { + je || (je = !0, vt.then(v)); } -function $t() { - return rt(), nt; +function Wt() { + return Et(), vt; } -function Le(n) { - re.push(n); +function Ve(n) { + le.push(n); } -const xe = /* @__PURE__ */ new Set(); -let te = 0; -function y() { - if (te !== 0) +const Ne = /* @__PURE__ */ new Set(); +let oe = 0; +function v() { + if (oe !== 0) return; - const n = ce; + const n = me; do { try { - for (; te < ne.length; ) { - const e = ne[te]; - te++, fe(e), Mt(e.$$); + for (; oe < se.length; ) { + const e = se[oe]; + oe++, ge(e), zt(e.$$); } } catch (e) { - throw ne.length = 0, te = 0, e; + throw se.length = 0, oe = 0, e; } - for (fe(null), ne.length = 0, te = 0; we.length; ) we.pop()(); - for (let e = 0; e < re.length; e += 1) { - const t = re[e]; - xe.has(t) || (xe.add(t), t()); + for (ge(null), se.length = 0, oe = 0; Fe.length; ) Fe.pop()(); + for (let e = 0; e < le.length; e += 1) { + const t = le[e]; + Ne.has(t) || (Ne.add(t), t()); } - re.length = 0; - } while (ne.length); - for (; Ye.length; ) - Ye.pop()(); - Ce = !1, xe.clear(), fe(n); + le.length = 0; + } while (se.length); + for (; at.length; ) + at.pop()(); + je = !1, Ne.clear(), ge(n); } -function Mt(n) { +function zt(n) { if (n.fragment !== null) { - n.update(), ue(n.before_update); + n.update(), ve(n.before_update); const e = n.dirty; - n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(Le); + n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(Ve); } } -function St(n) { +function Kt(n) { const e = [], t = []; - re.forEach((i) => n.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), re = e; + le.forEach((r) => n.indexOf(r) === -1 ? e.push(r) : t.push(r)), t.forEach((r) => r()), le = e; } -const Tt = /* @__PURE__ */ new Set(); -function Dt(n, e) { - n && n.i && (Tt.delete(n), n.i(e)); +const Qt = /* @__PURE__ */ new Set(); +function en(n, e) { + n && n.i && (Qt.delete(n), n.i(e)); } -function Nt(n, e, t) { - const { fragment: i, after_update: o } = n.$$; - i && i.m(e, t), Le(() => { - const l = n.$$.on_mount.map(et).filter(tt); - n.$$.on_destroy ? n.$$.on_destroy.push(...l) : ue(l), n.$$.on_mount = []; - }), o.forEach(Le); +function tn(n, e, t) { + const { fragment: r, after_update: o } = n.$$; + r && r.m(e, t), Ve(() => { + const s = n.$$.on_mount.map(wt).filter(_t); + n.$$.on_destroy ? n.$$.on_destroy.push(...s) : ve(s), n.$$.on_mount = []; + }), o.forEach(Ve); } -function jt(n, e) { +function nn(n, e) { const t = n.$$; - t.fragment !== null && (St(t.after_update), ue(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); + t.fragment !== null && (Kt(t.after_update), ve(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); } -function Vt(n, e) { - n.$$.dirty[0] === -1 && (ne.push(n), rt(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31; +function rn(n, e) { + n.$$.dirty[0] === -1 && (se.push(n), Et(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31; } -function Ft(n, e, t, i, o, l, f = null, c = [-1]) { - const h = ce; - fe(n); - const u = n.$$ = { +function on(n, e, t, r, o, s, u = null, f = [-1]) { + const l = me; + ge(n); + const c = n.$$ = { fragment: null, ctx: [], // state - props: l, - update: ie, + props: s, + update: ce, not_equal: o, - bound: qe(), + bound: st(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], - context: new Map(e.context || (h ? h.$$.context : [])), + context: new Map(e.context || (l ? l.$$.context : [])), // everything else - callbacks: qe(), - dirty: c, + callbacks: st(), + dirty: f, skip_bound: !1, - root: e.target || h.$$.root + root: e.target || l.$$.root }; - f && f(u.root); - let H = !1; - if (u.ctx = t ? t(n, e.props || {}, (S, B, ...P) => { - const k = P.length ? P[0] : B; - return u.ctx && o(u.ctx[S], u.ctx[S] = k) && (!u.skip_bound && u.bound[S] && u.bound[S](k), H && Vt(n, S)), B; - }) : [], u.update(), H = !0, ue(u.before_update), u.fragment = i ? i(u.ctx) : !1, e.target) { + u && u(c.root); + let O = !1; + if (c.ctx = t ? t(n, e.props || {}, (m, H, ...$) => { + const q = $.length ? $[0] : H; + return c.ctx && o(c.ctx[m], c.ctx[m] = q) && (!c.skip_bound && c.bound[m] && c.bound[m](q), O && rn(n, m)), H; + }) : [], c.update(), O = !0, ve(c.before_update), c.fragment = r ? r(c.ctx) : !1, e.target) { if (e.hydrate) { - const S = xt(e.target); - u.fragment && u.fragment.l(S), S.forEach(D); + const m = qt(e.target); + c.fragment && c.fragment.l(m), m.forEach(D); } else - u.fragment && u.fragment.c(); - e.intro && Dt(n.$$.fragment), Nt(n, e.target, e.anchor), y(); + c.fragment && c.fragment.c(); + e.intro && en(n.$$.fragment), tn(n, e.target, e.anchor), v(); } - fe(h); + ge(l); } -let it; -typeof HTMLElement == "function" && (it = class extends HTMLElement { - constructor(e, t, i) { +let kt; +typeof HTMLElement == "function" && (kt = class extends HTMLElement { + constructor(e, t, r) { super(); /** The Svelte component constructor */ - O(this, "$$ctor"); + S(this, "$$ctor"); /** Slots */ - O(this, "$$s"); + S(this, "$$s"); /** The Svelte component instance */ - O(this, "$$c"); + S(this, "$$c"); /** Whether or not the custom element is connected */ - O(this, "$$cn", !1); + S(this, "$$cn", !1); /** Component props data */ - O(this, "$$d", {}); + S(this, "$$d", {}); /** `true` if currently in the process of reflecting component props back to attributes */ - O(this, "$$r", !1); + S(this, "$$r", !1); /** @type {Record} Props definition (name, reflected, type etc) */ - O(this, "$$p_d", {}); + S(this, "$$p_d", {}); /** @type {Record} Event listeners */ - O(this, "$$l", {}); + S(this, "$$l", {}); /** @type {Map} Event listener unsubscribe functions */ - O(this, "$$l_u", /* @__PURE__ */ new Map()); - this.$$ctor = e, this.$$s = t, i && this.attachShadow({ mode: "open" }); + S(this, "$$l_u", /* @__PURE__ */ new Map()); + this.$$ctor = e, this.$$s = t, r && this.attachShadow({ mode: "open" }); } - addEventListener(e, t, i) { + addEventListener(e, t, r) { if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(t), this.$$c) { const o = this.$$c.$on(e, t); this.$$l_u.set(t, o); } - super.addEventListener(e, t, i); + super.addEventListener(e, t, r); } - removeEventListener(e, t, i) { - if (super.removeEventListener(e, t, i), this.$$c) { + removeEventListener(e, t, r) { + if (super.removeEventListener(e, t, r), this.$$c) { const o = this.$$l_u.get(t); o && (o(), this.$$l_u.delete(t)); } } async connectedCallback() { if (this.$$cn = !0, !this.$$c) { - let e = function(l) { + let e = function(s) { return () => { - let f; + let u; return { c: function() { - f = M("slot"), l !== "default" && s(f, "name", l); + u = F("slot"), s !== "default" && a(u, "name", s); }, /** * @param {HTMLElement} target * @param {HTMLElement} [anchor] */ - m: function(u, H) { - F(u, f, H); + m: function(c, O) { + M(c, u, O); }, - d: function(u) { - u && D(f); + d: function(c) { + c && D(u); } }; }; }; if (await Promise.resolve(), !this.$$cn || this.$$c) return; - const t = {}, i = Lt(this); - for (const l of this.$$s) - l in i && (t[l] = [e(l)]); - for (const l of this.attributes) { - const f = this.$$g_p(l.name); - f in this.$$d || (this.$$d[f] = _e(f, l.value, this.$$p_d, "toProp")); + const t = {}, r = Yt(this); + for (const s of this.$$s) + s in r && (t[s] = [e(s)]); + for (const s of this.attributes) { + const u = this.$$g_p(s.name); + u in this.$$d || (this.$$d[u] = Te(u, s.value, this.$$p_d, "toProp")); } - for (const l in this.$$p_d) - !(l in this.$$d) && this[l] !== void 0 && (this.$$d[l] = this[l], delete this[l]); + for (const s in this.$$p_d) + !(s in this.$$d) && this[s] !== void 0 && (this.$$d[s] = this[s], delete this[s]); this.$$c = new this.$$ctor({ target: this.shadowRoot || this, props: { @@ -287,32 +294,32 @@ typeof HTMLElement == "function" && (it = class extends HTMLElement { }); const o = () => { this.$$r = !0; - for (const l in this.$$p_d) - if (this.$$d[l] = this.$$c.$$.ctx[this.$$c.$$.props[l]], this.$$p_d[l].reflect) { - const f = _e( - l, - this.$$d[l], + for (const s in this.$$p_d) + if (this.$$d[s] = this.$$c.$$.ctx[this.$$c.$$.props[s]], this.$$p_d[s].reflect) { + const u = Te( + s, + this.$$d[s], this.$$p_d, "toAttribute" ); - f == null ? this.removeAttribute(this.$$p_d[l].attribute || l) : this.setAttribute(this.$$p_d[l].attribute || l, f); + u == null ? this.removeAttribute(this.$$p_d[s].attribute || s) : this.setAttribute(this.$$p_d[s].attribute || s, u); } this.$$r = !1; }; this.$$c.$$.after_update.push(o), o(); - for (const l in this.$$l) - for (const f of this.$$l[l]) { - const c = this.$$c.$on(l, f); - this.$$l_u.set(f, c); + for (const s in this.$$l) + for (const u of this.$$l[s]) { + const f = this.$$c.$on(s, u); + this.$$l_u.set(u, f); } this.$$l = {}; } } // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte // and setting attributes through setAttribute etc, this is helpful - attributeChangedCallback(e, t, i) { + attributeChangedCallback(e, t, r) { var o; - this.$$r || (e = this.$$g_p(e), this.$$d[e] = _e(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); + this.$$r || (e = this.$$g_p(e), this.$$d[e] = Te(e, r, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); } disconnectedCallback() { this.$$cn = !1, Promise.resolve().then(() => { @@ -325,12 +332,12 @@ typeof HTMLElement == "function" && (it = class extends HTMLElement { ) || e; } }); -function _e(n, e, t, i) { - var l; - const o = (l = t[n]) == null ? void 0 : l.type; - if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[n]) +function Te(n, e, t, r) { + var s; + const o = (s = t[n]) == null ? void 0 : s.type; + if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !r || !t[n]) return e; - if (i === "toAttribute") + if (r === "toAttribute") switch (o) { case "Object": case "Array": @@ -355,38 +362,38 @@ function _e(n, e, t, i) { return e; } } -function Pt(n, e, t, i, o, l) { - let f = class extends it { +function sn(n, e, t, r, o, s) { + let u = class extends kt { constructor() { super(n, t, o), this.$$p_d = e; } static get observedAttributes() { return Object.keys(e).map( - (c) => (e[c].attribute || c).toLowerCase() + (f) => (e[f].attribute || f).toLowerCase() ); } }; - return Object.keys(e).forEach((c) => { - Object.defineProperty(f.prototype, c, { + return Object.keys(e).forEach((f) => { + Object.defineProperty(u.prototype, f, { get() { - return this.$$c && c in this.$$c ? this.$$c[c] : this.$$d[c]; + return this.$$c && f in this.$$c ? this.$$c[f] : this.$$d[f]; }, - set(h) { - var u; - h = _e(c, h, e), this.$$d[c] = h, (u = this.$$c) == null || u.$set({ [c]: h }); + set(l) { + var c; + l = Te(f, l, e), this.$$d[f] = l, (c = this.$$c) == null || c.$set({ [f]: l }); } }); - }), i.forEach((c) => { - Object.defineProperty(f.prototype, c, { + }), r.forEach((f) => { + Object.defineProperty(u.prototype, f, { get() { - var h; - return (h = this.$$c) == null ? void 0 : h[c]; + var l; + return (l = this.$$c) == null ? void 0 : l[f]; } }); }), n.element = /** @type {any} */ - f, f; + u, u; } -class Ht { +class ln { constructor() { /** * ### PRIVATE API @@ -395,7 +402,7 @@ class Ht { * * @type {any} */ - O(this, "$$"); + S(this, "$$"); /** * ### PRIVATE API * @@ -403,11 +410,11 @@ class Ht { * * @type {any} */ - O(this, "$$set"); + S(this, "$$set"); } /** @returns {void} */ $destroy() { - jt(this, 1), this.$destroy = ie; + nn(this, 1), this.$destroy = ce; } /** * @template {Extract} K @@ -416,12 +423,12 @@ class Ht { * @returns {() => void} */ $on(e, t) { - if (!tt(t)) - return ie; - const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); - return i.push(t), () => { - const o = i.indexOf(t); - o !== -1 && i.splice(o, 1); + if (!_t(t)) + return ce; + const r = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); + return r.push(t), () => { + const o = r.indexOf(t); + o !== -1 && r.splice(o, 1); }; } /** @@ -429,627 +436,765 @@ class Ht { * @returns {void} */ $set(e) { - this.$$set && !Et(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); + this.$$set && !Ht(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); } } -const Ot = "4"; -typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(Ot); -const Bt = new TextEncoder(); -function Ut(n) { +const an = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(an); +const fn = new TextEncoder(); +function cn(n) { return [...new Uint8Array(n)].map((e) => e.toString(16).padStart(2, "0")).join(""); } -async function qt(n, e = "SHA-256", t = 1e5) { - const i = Date.now().toString(16); +async function un(n, e = "SHA-256", t = 1e5) { + const r = Date.now().toString(16); n || (n = Math.round(Math.random() * t)); - const o = await ot(i, n, e); + const o = await pt(r, n, e); return { algorithm: e, challenge: o, - salt: i, + salt: r, signature: "" }; } -async function ot(n, e, t) { - return Ut( +async function pt(n, e, t) { + return cn( await crypto.subtle.digest( t.toUpperCase(), - Bt.encode(n + e) + fn.encode(n + e) ) ); } -function Zt(n, e, t = "SHA-256", i = 1e6, o = 0) { - const l = new AbortController(), f = Date.now(); +function hn(n, e, t = "SHA-256", r = 1e6, o = 0) { + const s = new AbortController(), u = Date.now(); return { promise: (async () => { - for (let h = o; h <= i; h += 1) { - if (l.signal.aborted) + for (let l = o; l <= r; l += 1) { + if (s.signal.aborted) return null; - if (await ot(e, h, t) === n) + if (await pt(e, l, t) === n) return { - number: h, - took: Date.now() - f + number: l, + took: Date.now() - u }; } return null; })(), - controller: l + controller: s }; } -var b = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(b || {}); -function Ge(n) { - let e, t, i; +function Ct() { + try { + return Intl.DateTimeFormat().resolvedOptions().timeZone; + } catch { + } +} +var ae, fe, be, we, _e, ye; +class dn { + constructor(e) { + S(this, "beaconUrl", null); + S(this, "error", null); + S(this, "loadTime", Date.now()); + S(this, "submitTime", null); + S(this, "startTime", null); + S(this, "viewTimeThresholdMs", 1500); + re(this, ae, {}); + re(this, fe, null); + re(this, be, this.onFormChange.bind(this)); + re(this, we, this.onFormFocus.bind(this)); + re(this, _e, this.onFormSubmit.bind(this)); + re(this, ye, this.onUnload.bind(this)); + this.elForm = e, window.addEventListener("unload", U(this, ye)), this.elForm.addEventListener("change", U(this, be)), this.elForm.addEventListener("focusin", U(this, we)), this.elForm.addEventListener("submit", U(this, _e)); + } + data() { + const e = Object.entries(U(this, ae)); + return { + correction: e.length && e.filter(([t, r]) => r > 1).length / e.length || 0, + dropoff: !this.submitTime && !this.error && U(this, fe) ? U(this, fe) : null, + error: this.error, + mobile: this.isMobile(), + start: this.startTime, + submit: this.submitTime, + tz: Ct() + }; + } + dataAsBase64() { + try { + return btoa( + JSON.stringify(this.data()) + ); + } catch (e) { + console.error("failed to encode ALTCHA session data to base64", e); + } + return ""; + } + destroy() { + window.removeEventListener("unload", U(this, ye)), this.elForm.removeEventListener("change", U(this, be)), this.elForm.removeEventListener("focusin", U(this, we)), this.elForm.removeEventListener("submit", U(this, _e)); + } + end() { + this.submitTime || (this.submitTime = Date.now()); + } + getFieldName(e, t = 40) { + const r = e.getAttribute("data-group-label"), o = e.getAttribute("name") || e.getAttribute("aria-label"); + return ((r ? r + ": " : "") + o).slice(0, t); + } + isMobile() { + const e = "userAgentData" in navigator && navigator.userAgentData ? navigator.userAgentData : {}; + return "mobile" in e ? e.mobile === !0 : /Mobi/i.test(window.navigator.userAgent); + } + isInput(e) { + return ["INPUT", "SELECT", "TEXTAREA"].includes(e.tagName); + } + onFormFieldChange(e) { + const t = this.getFieldName(e); + t && this.trackFieldChange(t); + } + onFormChange(e) { + const t = e.target; + t && this.isInput(t) && this.onFormFieldChange(t); + } + onFormFocus(e) { + const t = e.target; + if (this.startTime || this.start(), t && this.isInput(t)) { + const r = this.getFieldName(t); + r && ot(this, fe, r); + } + } + onFormSubmit() { + this.end(); + } + onUnload() { + this.loadTime <= Date.now() - this.viewTimeThresholdMs && !this.submitTime && this.sendBeacon(); + } + async sendBeacon() { + if (this.beaconUrl && "sendBeacon" in navigator) + try { + navigator.sendBeacon( + new URL(this.beaconUrl, location.origin), + JSON.stringify(this.data()) + ); + } catch { + } + } + start() { + this.startTime = Date.now(); + } + trackError(e) { + this.error = e === null ? null : String(e); + } + trackFieldChange(e) { + U(this, ae)[e] = (U(this, ae)[e] || 0) + 1; + } +} +ae = new WeakMap(), fe = new WeakMap(), be = new WeakMap(), we = new WeakMap(), _e = new WeakMap(), ye = new WeakMap(); +var _ = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(_ || {}); +function ft(n) { + let e, t, r; return { c() { - e = Y("svg"), t = Y("path"), i = Y("path"), s(t, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), s(t, "fill", "currentColor"), s(t, "opacity", ".25"), s(i, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), s(i, "fill", "currentColor"), s(i, "class", "altcha-spinner"), s(e, "width", "24"), s(e, "height", "24"), s(e, "viewBox", "0 0 24 24"), s(e, "xmlns", "http://www.w3.org/2000/svg"); + e = z("svg"), t = z("path"), r = z("path"), a(t, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), a(t, "fill", "currentColor"), a(t, "opacity", ".25"), a(r, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), a(r, "fill", "currentColor"), a(r, "class", "altcha-spinner"), a(e, "width", "24"), a(e, "height", "24"), a(e, "viewBox", "0 0 24 24"), a(e, "xmlns", "http://www.w3.org/2000/svg"); }, - m(o, l) { - F(o, e, l), p(e, t), p(e, i); + m(o, s) { + M(o, e, s), p(e, t), p(e, r); }, d(o) { o && D(e); } }; } -function Yt(n) { +function gn(n) { let e, t = ( /*_strings*/ - n[11].label + "" - ), i; + n[13].label + "" + ), r; return { c() { - e = M("label"), s(e, "for", i = /*name*/ + e = F("label"), a(e, "for", r = /*name*/ n[4] + "_checkbox"); }, - m(o, l) { - F(o, e, l), e.innerHTML = t; + m(o, s) { + M(o, e, s), e.innerHTML = t; }, - p(o, l) { - l[0] & /*_strings*/ - 2048 && t !== (t = /*_strings*/ - o[11].label + "") && (e.innerHTML = t), l[0] & /*name*/ - 16 && i !== (i = /*name*/ - o[4] + "_checkbox") && s(e, "for", i); + p(o, s) { + s[0] & /*_strings*/ + 8192 && t !== (t = /*_strings*/ + o[13].label + "") && (e.innerHTML = t), s[0] & /*name*/ + 16 && r !== (r = /*name*/ + o[4] + "_checkbox") && a(e, "for", r); }, d(o) { o && D(e); } }; } -function Gt(n) { +function mn(n) { let e, t = ( /*_strings*/ - n[11].verifying + "" + n[13].verifying + "" ); return { c() { - e = M("span"); + e = F("span"); }, - m(i, o) { - F(i, e, o), e.innerHTML = t; + m(r, o) { + M(r, e, o), e.innerHTML = t; }, - p(i, o) { + p(r, o) { o[0] & /*_strings*/ - 2048 && t !== (t = /*_strings*/ - i[11].verifying + "") && (e.innerHTML = t); + 8192 && t !== (t = /*_strings*/ + r[13].verifying + "") && (e.innerHTML = t); }, - d(i) { - i && D(e); + d(r) { + r && D(e); } }; } -function Wt(n) { +function bn(n) { let e, t = ( /*_strings*/ - n[11].verified + "" - ), i, o; + n[13].verified + "" + ), r, o, s, u, f = ( + /*session*/ + n[11] && ct(n) + ); return { c() { - e = M("span"), i = X(), o = M("input"), s(o, "type", "hidden"), s( + e = F("span"), r = W(), o = F("input"), s = W(), f && f.c(), u = $t(), a(o, "type", "hidden"), a( o, "name", /*name*/ n[4] ), o.value = /*payload*/ - n[5]; + n[6]; }, - m(l, f) { - F(l, e, f), e.innerHTML = t, F(l, i, f), F(l, o, f); + m(l, c) { + M(l, e, c), e.innerHTML = t, M(l, r, c), M(l, o, c), M(l, s, c), f && f.m(l, c), M(l, u, c); }, - p(l, f) { - f[0] & /*_strings*/ - 2048 && t !== (t = /*_strings*/ - l[11].verified + "") && (e.innerHTML = t), f[0] & /*name*/ - 16 && s( + p(l, c) { + c[0] & /*_strings*/ + 8192 && t !== (t = /*_strings*/ + l[13].verified + "") && (e.innerHTML = t), c[0] & /*name*/ + 16 && a( o, "name", /*name*/ l[4] - ), f[0] & /*payload*/ - 32 && (o.value = /*payload*/ - l[5]); + ), c[0] & /*payload*/ + 64 && (o.value = /*payload*/ + l[6]), /*session*/ + l[11] ? f ? f.p(l, c) : (f = ct(l), f.c(), f.m(u.parentNode, u)) : f && (f.d(1), f = null); }, d(l) { - l && (D(e), D(i), D(o)); + l && (D(e), D(r), D(o), D(s), D(u)), f && f.d(l); } }; } -function We(n) { - let e, t, i, o, l, f, c; +function ct(n) { + let e; return { c() { - e = M("div"), t = M("a"), i = Y("svg"), o = Y("path"), l = Y("path"), f = Y("path"), s(o, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), s(o, "fill", "currentColor"), s(l, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), s(l, "fill", "currentColor"), s(f, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), s(f, "fill", "currentColor"), s(i, "width", "22"), s(i, "height", "22"), s(i, "viewBox", "0 0 20 20"), s(i, "fill", "none"), s(i, "xmlns", "http://www.w3.org/2000/svg"), s(t, "href", lt), s(t, "target", "_blank"), s(t, "class", "altcha-logo"), s(t, "aria-label", c = /*_strings*/ - n[11].ariaLinkLabel); + e = F("input"), a(e, "type", "hidden"), a(e, "name", "__session"), e.value = /*sessionPayload*/ + n[12]; }, - m(h, u) { - F(h, e, u), p(e, t), p(t, i), p(i, o), p(i, l), p(i, f); + m(t, r) { + M(t, e, r); }, - p(h, u) { - u[0] & /*_strings*/ - 2048 && c !== (c = /*_strings*/ - h[11].ariaLinkLabel) && s(t, "aria-label", c); + p(t, r) { + r[0] & /*sessionPayload*/ + 4096 && (e.value = /*sessionPayload*/ + t[12]); }, - d(h) { - h && D(e); + d(t) { + t && D(e); } }; } -function Xe(n) { - let e, t, i, o; - function l(h, u) { +function ut(n) { + let e, t, r, o, s, u, f; + return { + c() { + e = F("div"), t = F("a"), r = z("svg"), o = z("path"), s = z("path"), u = z("path"), a(o, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), a(o, "fill", "currentColor"), a(s, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), a(s, "fill", "currentColor"), a(u, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), a(u, "fill", "currentColor"), a(r, "width", "22"), a(r, "height", "22"), a(r, "viewBox", "0 0 20 20"), a(r, "fill", "none"), a(r, "xmlns", "http://www.w3.org/2000/svg"), a(t, "href", At), a(t, "target", "_blank"), a(t, "class", "altcha-logo"), a(t, "aria-label", f = /*_strings*/ + n[13].ariaLinkLabel); + }, + m(l, c) { + M(l, e, c), p(e, t), p(t, r), p(r, o), p(r, s), p(r, u); + }, + p(l, c) { + c[0] & /*_strings*/ + 8192 && f !== (f = /*_strings*/ + l[13].ariaLinkLabel) && a(t, "aria-label", f); + }, + d(l) { + l && D(e); + } + }; +} +function ht(n) { + let e, t, r, o; + function s(l, c) { return ( /*state*/ - h[6] === b.EXPIRED ? Jt : Xt + l[7] === _.EXPIRED ? _n : wn ); } - let f = l(n), c = f(n); + let u = s(n), f = u(n); return { c() { - e = M("div"), t = Y("svg"), i = Y("path"), o = X(), c.c(), s(i, "stroke-linecap", "round"), s(i, "stroke-linejoin", "round"), s(i, "d", "M6 18L18 6M6 6l12 12"), s(t, "width", "14"), s(t, "height", "14"), s(t, "xmlns", "http://www.w3.org/2000/svg"), s(t, "fill", "none"), s(t, "viewBox", "0 0 24 24"), s(t, "stroke-width", "1.5"), s(t, "stroke", "currentColor"), s(e, "class", "altcha-error"); + e = F("div"), t = z("svg"), r = z("path"), o = W(), f.c(), a(r, "stroke-linecap", "round"), a(r, "stroke-linejoin", "round"), a(r, "d", "M6 18L18 6M6 6l12 12"), a(t, "width", "14"), a(t, "height", "14"), a(t, "xmlns", "http://www.w3.org/2000/svg"), a(t, "fill", "none"), a(t, "viewBox", "0 0 24 24"), a(t, "stroke-width", "1.5"), a(t, "stroke", "currentColor"), a(e, "class", "altcha-error"); }, - m(h, u) { - F(h, e, u), p(e, t), p(t, i), p(e, o), c.m(e, null); + m(l, c) { + M(l, e, c), p(e, t), p(t, r), p(e, o), f.m(e, null); }, - p(h, u) { - f === (f = l(h)) && c ? c.p(h, u) : (c.d(1), c = f(h), c && (c.c(), c.m(e, null))); + p(l, c) { + u === (u = s(l)) && f ? f.p(l, c) : (f.d(1), f = u(l), f && (f.c(), f.m(e, null))); }, - d(h) { - h && D(e), c.d(); + d(l) { + l && D(e), f.d(); } }; } -function Xt(n) { +function wn(n) { let e, t = ( /*_strings*/ - n[11].error + "" + n[13].error + "" ); return { c() { - e = M("div"), s( + e = F("div"), a( e, "title", /*error*/ - n[10] + n[5] ); }, - m(i, o) { - F(i, e, o), e.innerHTML = t; + m(r, o) { + M(r, e, o), e.innerHTML = t; }, - p(i, o) { + p(r, o) { o[0] & /*_strings*/ - 2048 && t !== (t = /*_strings*/ - i[11].error + "") && (e.innerHTML = t), o[0] & /*error*/ - 1024 && s( + 8192 && t !== (t = /*_strings*/ + r[13].error + "") && (e.innerHTML = t), o[0] & /*error*/ + 32 && a( e, "title", /*error*/ - i[10] + r[5] ); }, - d(i) { - i && D(e); + d(r) { + r && D(e); } }; } -function Jt(n) { +function _n(n) { let e, t = ( /*_strings*/ - n[11].expired + "" + n[13].expired + "" ); return { c() { - e = M("div"), s( + e = F("div"), a( e, "title", /*error*/ - n[10] + n[5] ); }, - m(i, o) { - F(i, e, o), e.innerHTML = t; + m(r, o) { + M(r, e, o), e.innerHTML = t; }, - p(i, o) { + p(r, o) { o[0] & /*_strings*/ - 2048 && t !== (t = /*_strings*/ - i[11].expired + "") && (e.innerHTML = t), o[0] & /*error*/ - 1024 && s( + 8192 && t !== (t = /*_strings*/ + r[13].expired + "") && (e.innerHTML = t), o[0] & /*error*/ + 32 && a( e, "title", /*error*/ - i[10] + r[5] ); }, - d(i) { - i && D(e); + d(r) { + r && D(e); } }; } -function Je(n) { - let e, t, i = ( +function dt(n) { + let e, t, r = ( /*_strings*/ - n[11].footer + "" + n[13].footer + "" ); return { c() { - e = M("div"), t = M("div"), s(e, "class", "altcha-footer"); + e = F("div"), t = F("div"), a(e, "class", "altcha-footer"); }, - m(o, l) { - F(o, e, l), p(e, t), t.innerHTML = i; + m(o, s) { + M(o, e, s), p(e, t), t.innerHTML = r; }, - p(o, l) { - l[0] & /*_strings*/ - 2048 && i !== (i = /*_strings*/ - o[11].footer + "") && (t.innerHTML = i); + p(o, s) { + s[0] & /*_strings*/ + 8192 && r !== (r = /*_strings*/ + o[13].footer + "") && (t.innerHTML = r); }, d(o) { o && D(e); } }; } -function ze(n) { +function gt(n) { let e; return { c() { - e = M("div"), s(e, "class", "altcha-anchor-arrow"); + e = F("div"), a(e, "class", "altcha-anchor-arrow"); }, - m(t, i) { - F(t, e, i), n[37](e); + m(t, r) { + M(t, e, r), n[41](e); }, - p: ie, + p: ce, d(t) { - t && D(e), n[37](null); + t && D(e), n[41](null); } }; } -function zt(n) { - let e, t, i, o, l, f, c, h, u, H, S, B, P, k, G, $ = ( +function yn(n) { + let e, t, r, o, s, u, f, l, c, O, m, H, $, q, J, b = ( /*state*/ - n[6] === b.VERIFYING && Ge() + n[7] === _.VERIFYING && ft() ); - function J(d, _) { + function K(d, E) { return ( /*state*/ - d[6] === b.VERIFIED ? Wt : ( + d[7] === _.VERIFIED ? bn : ( /*state*/ - d[6] === b.VERIFYING ? Gt : Yt + d[7] === _.VERIFYING ? mn : gn ) ); } - let Z = J(n), N = Z(n), x = ( + let X = K(n), j = X(n), I = ( /*hidelogo*/ (n[3] !== !0 || /*isFreeSaaS*/ - n[12]) && We(n) - ), I = ( + n[14]) && ut(n) + ), R = ( /*error*/ - (n[10] || /*state*/ - n[6] === b.EXPIRED) && Xe(n) - ), A = ( + (n[5] || /*state*/ + n[7] === _.EXPIRED) && ht(n) + ), C = ( /*_strings*/ - n[11].footer && /*hidefooter*/ + n[13].footer && /*hidefooter*/ (n[2] !== !0 || /*isFreeSaaS*/ - n[12]) && Je(n) - ), w = ( + n[14]) && dt(n) + ), x = ( /*floating*/ - n[1] && ze(n) + n[1] && gt(n) ); return { c() { - e = M("div"), t = M("div"), $ && $.c(), i = X(), o = M("div"), l = M("input"), h = X(), u = M("div"), N.c(), H = X(), x && x.c(), S = X(), I && I.c(), B = X(), A && A.c(), P = X(), w && w.c(), s(l, "type", "checkbox"), s(l, "id", f = /*name*/ - n[4] + "_checkbox"), l.required = c = /*auto*/ - n[0] !== "onsubmit", s(o, "class", "altcha-checkbox"), Ze( + e = F("div"), t = F("div"), b && b.c(), r = W(), o = F("div"), s = F("input"), l = W(), c = F("div"), j.c(), O = W(), I && I.c(), m = W(), R && R.c(), H = W(), C && C.c(), $ = W(), x && x.c(), a(s, "type", "checkbox"), a(s, "id", u = /*name*/ + n[4] + "_checkbox"), s.required = f = /*auto*/ + n[0] !== "onsubmit", a(o, "class", "altcha-checkbox"), lt( o, "altcha-hidden", /*state*/ - n[6] === b.VERIFYING - ), s(u, "class", "altcha-label"), s(t, "class", "altcha-main"), s(e, "class", "altcha"), s( + n[7] === _.VERIFYING + ), a(c, "class", "altcha-label"), a(t, "class", "altcha-main"), a(e, "class", "altcha"), a( e, "data-state", /*state*/ - n[6] - ), s( + n[7] + ), a( e, "data-floating", /*floating*/ n[1] ); }, - m(d, _) { - F(d, e, _), p(e, t), $ && $.m(t, null), p(t, i), p(t, o), p(o, l), l.checked = /*checked*/ - n[7], p(t, h), p(t, u), N.m(u, null), p(t, H), x && x.m(t, null), p(e, S), I && I.m(e, null), p(e, B), A && A.m(e, null), p(e, P), w && w.m(e, null), n[38](e), k || (G = [ - pe( - l, + m(d, E) { + M(d, e, E), p(e, t), b && b.m(t, null), p(t, r), p(t, o), p(o, s), s.checked = /*checked*/ + n[8], p(t, l), p(t, c), j.m(c, null), p(t, O), I && I.m(t, null), p(e, m), R && R.m(e, null), p(e, H), C && C.m(e, null), p(e, $), x && x.m(e, null), n[42](e), q || (J = [ + Me( + s, "change", /*input_change_handler*/ - n[36] + n[40] ), - pe( - l, + Me( + s, "change", /*onCheckedChange*/ - n[13] + n[15] ), - pe( - l, + Me( + s, "invalid", /*onInvalid*/ - n[14] + n[16] ) - ], k = !0); + ], q = !0); }, - p(d, _) { + p(d, E) { /*state*/ - d[6] === b.VERIFYING ? $ || ($ = Ge(), $.c(), $.m(t, i)) : $ && ($.d(1), $ = null), _[0] & /*name*/ - 16 && f !== (f = /*name*/ - d[4] + "_checkbox") && s(l, "id", f), _[0] & /*auto*/ - 1 && c !== (c = /*auto*/ - d[0] !== "onsubmit") && (l.required = c), _[0] & /*checked*/ - 128 && (l.checked = /*checked*/ - d[7]), _[0] & /*state*/ - 64 && Ze( + d[7] === _.VERIFYING ? b || (b = ft(), b.c(), b.m(t, r)) : b && (b.d(1), b = null), E[0] & /*name*/ + 16 && u !== (u = /*name*/ + d[4] + "_checkbox") && a(s, "id", u), E[0] & /*auto*/ + 1 && f !== (f = /*auto*/ + d[0] !== "onsubmit") && (s.required = f), E[0] & /*checked*/ + 256 && (s.checked = /*checked*/ + d[8]), E[0] & /*state*/ + 128 && lt( o, "altcha-hidden", /*state*/ - d[6] === b.VERIFYING - ), Z === (Z = J(d)) && N ? N.p(d, _) : (N.d(1), N = Z(d), N && (N.c(), N.m(u, null))), /*hidelogo*/ + d[7] === _.VERIFYING + ), X === (X = K(d)) && j ? j.p(d, E) : (j.d(1), j = X(d), j && (j.c(), j.m(c, null))), /*hidelogo*/ d[3] !== !0 || /*isFreeSaaS*/ - d[12] ? x ? x.p(d, _) : (x = We(d), x.c(), x.m(t, null)) : x && (x.d(1), x = null), /*error*/ - d[10] || /*state*/ - d[6] === b.EXPIRED ? I ? I.p(d, _) : (I = Xe(d), I.c(), I.m(e, B)) : I && (I.d(1), I = null), /*_strings*/ - d[11].footer && /*hidefooter*/ + d[14] ? I ? I.p(d, E) : (I = ut(d), I.c(), I.m(t, null)) : I && (I.d(1), I = null), /*error*/ + d[5] || /*state*/ + d[7] === _.EXPIRED ? R ? R.p(d, E) : (R = ht(d), R.c(), R.m(e, H)) : R && (R.d(1), R = null), /*_strings*/ + d[13].footer && /*hidefooter*/ (d[2] !== !0 || /*isFreeSaaS*/ - d[12]) ? A ? A.p(d, _) : (A = Je(d), A.c(), A.m(e, P)) : A && (A.d(1), A = null), /*floating*/ - d[1] ? w ? w.p(d, _) : (w = ze(d), w.c(), w.m(e, null)) : w && (w.d(1), w = null), _[0] & /*state*/ - 64 && s( + d[14]) ? C ? C.p(d, E) : (C = dt(d), C.c(), C.m(e, $)) : C && (C.d(1), C = null), /*floating*/ + d[1] ? x ? x.p(d, E) : (x = gt(d), x.c(), x.m(e, null)) : x && (x.d(1), x = null), E[0] & /*state*/ + 128 && a( e, "data-state", /*state*/ - d[6] - ), _[0] & /*floating*/ - 2 && s( + d[7] + ), E[0] & /*floating*/ + 2 && a( e, "data-floating", /*floating*/ d[1] ); }, - i: ie, - o: ie, + i: ce, + o: ce, d(d) { - d && D(e), $ && $.d(), N.d(), x && x.d(), I && I.d(), A && A.d(), w && w.d(), n[38](null), k = !1, ue(G); + d && D(e), b && b.d(), j.d(), I && I.d(), R && R.d(), C && C.d(), x && x.d(), n[42](null), q = !1, ve(J); } }; } -const Ke = "Visit Altcha.org", lt = "https://altcha.org/"; -function Qe(n) { +const mt = "Visit Altcha.org", At = "https://altcha.org/"; +function bt(n) { return JSON.parse(n); } -function Kt() { - try { - return Intl.DateTimeFormat().resolvedOptions().timeZone; - } catch { - } -} -function Qt(n, e, t) { - var Be, Ue; - let i, o, l, f, { auto: c = void 0 } = e, { blockspam: h = void 0 } = e, { challengeurl: u = void 0 } = e, { challengejson: H = void 0 } = e, { debug: S = !1 } = e, { delay: B = 0 } = e, { expire: P = void 0 } = e, { floating: k = void 0 } = e, { floatinganchor: G = void 0 } = e, { floatingoffset: $ = void 0 } = e, { hidefooter: J = !1 } = e, { hidelogo: Z = !1 } = e, { name: N = "altcha" } = e, { maxnumber: x = 1e6 } = e, { mockerror: I = !1 } = e, { refetchonexpire: A = !0 } = e, { spamfilter: w = !1 } = e, { strings: d = void 0 } = e, { test: _ = !1 } = e, { verifyurl: z = void 0 } = e, { workers: oe = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: ae = void 0 } = e; - const ye = Rt(), Ae = ["SHA-256", "SHA-384", "SHA-512"], Re = (Ue = (Be = document.documentElement.lang) == null ? void 0 : Be.split("-")) == null ? void 0 : Ue[0]; - let W = !1, C, K = null, he = null, m = null, ve = null, Q = null, j = b.UNVERIFIED, U = null; - At(() => { - m && (m.removeEventListener("submit", Me), m.removeEventListener("reset", Se), m.removeEventListener("focusin", $e), m = null), U && (clearTimeout(U), U = null), document.removeEventListener("click", je), document.removeEventListener("scroll", Ve), window.removeEventListener("resize", Pe); - }), It(() => { - E("mounted", "0.6.7"), E("workers", oe), _ && E("using test mode"), P && de(P), c !== void 0 && E("auto", c), k !== void 0 && He(k), m = C.closest("form"), m && (m.addEventListener("submit", Me, { capture: !0 }), m.addEventListener("reset", Se), c === "onfocus" && m.addEventListener("focusin", $e)), c === "onload" && ee(), i && (J || Z) && E("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution."); +function vn(n, e, t) { + var tt, nt; + let r, o, s, u, { analytics: f = !1 } = e, { auto: l = void 0 } = e, { beaconurl: c = void 0 } = e, { blockspam: O = void 0 } = e, { challengeurl: m = void 0 } = e, { challengejson: H = void 0 } = e, { debug: $ = !1 } = e, { delay: q = 0 } = e, { expire: J = void 0 } = e, { floating: b = void 0 } = e, { floatinganchor: K = void 0 } = e, { floatingoffset: X = void 0 } = e, { hidefooter: j = !1 } = e, { hidelogo: I = !1 } = e, { name: R = "altcha" } = e, { maxnumber: C = 1e6 } = e, { mockerror: x = !1 } = e, { refetchonexpire: d = !0 } = e, { spamfilter: E = !1 } = e, { strings: Ee = void 0 } = e, { test: Z = !1 } = e, { verifyurl: ee = void 0 } = e, { workers: ue = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: ke = void 0 } = e; + const Re = Xt(), Pe = ["SHA-256", "SHA-384", "SHA-512"], Ue = (nt = (tt = document.documentElement.lang) == null ? void 0 : tt.split("-")) == null ? void 0 : nt[0]; + let Q = !1, A, te = null, pe = null, g = null, Ce = null, Y = null, ne = null, V = null, Oe = null, B = _.UNVERIFIED; + Jt(() => { + g && (g.removeEventListener("submit", $e), g.removeEventListener("reset", qe), g.removeEventListener("focusin", He), g = null), V && V.destroy(), Y && (clearTimeout(Y), Y = null), document.removeEventListener("click", Xe), document.removeEventListener("scroll", We), window.removeEventListener("resize", Ke); + }), Gt(() => { + k("mounted", "0.7.0"), k("workers", ue), Z && k("using test mode"), J && Ae(J), l !== void 0 && k("auto", l), b !== void 0 && Qe(b), g = A.closest("form"), g && (g.addEventListener("submit", $e, { capture: !0 }), g.addEventListener("reset", qe), l === "onfocus" && g.addEventListener("focusin", He)), f && Ge(), l === "onload" && ie(), r && (j || I) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution."); }); - function E(...r) { - (S || r.some((a) => a instanceof Error)) && console[r[0] instanceof Error ? "error" : "log"]("ALTCHA", ...r); + function k(...i) { + ($ || i.some((h) => h instanceof Error)) && console[i[0] instanceof Error ? "error" : "log"]("ALTCHA", ...i); } - function $e(r) { - j === b.UNVERIFIED && ee(); + function He(i) { + B === _.UNVERIFIED && ie(); } - function Me(r) { - m && c === "onsubmit" && (j === b.UNVERIFIED ? (r.preventDefault(), r.stopPropagation(), ee().then(() => { - m == null || m.requestSubmit(); - })) : j !== b.VERIFIED && (r.preventDefault(), r.stopPropagation(), j === b.VERIFYING && Fe())); + function $e(i) { + g && V && B === _.VERIFIED && (V.end(), t(12, Oe = V.dataAsBase64())), g && l === "onsubmit" && (B === _.UNVERIFIED ? (i.preventDefault(), i.stopPropagation(), ie().then(() => { + g == null || g.requestSubmit(); + })) : B !== _.VERIFIED && (i.preventDefault(), i.stopPropagation(), B === _.VERIFYING && ze())); } - function Se() { - ge(); + function qe() { + Le(); } - function Te(r, a) { + function Ze(i, h) { return btoa(JSON.stringify({ - algorithm: r.algorithm, - challenge: r.challenge, - number: a.number, - salt: r.salt, - signature: r.signature, - test: _ ? !0 : void 0, - took: a.took + algorithm: i.algorithm, + challenge: i.challenge, + number: h.number, + salt: i.salt, + signature: i.signature, + test: Z ? !0 : void 0, + took: h.took })); } - function De(r) { - if (!r.algorithm) + function Ye(i) { + if (!i.algorithm) throw new Error("Invalid challenge. Property algorithm is missing."); - if (r.signature === void 0) + if (i.signature === void 0) throw new Error("Invalid challenge. Property signature is missing."); - if (!Ae.includes(r.algorithm.toUpperCase())) - throw new Error(`Unknown algorithm value. Allowed values: ${Ae.join(", ")}`); - if (!r.challenge || r.challenge.length < 40) + if (!Pe.includes(i.algorithm.toUpperCase())) + throw new Error(`Unknown algorithm value. Allowed values: ${Pe.join(", ")}`); + if (!i.challenge || i.challenge.length < 40) throw new Error("Challenge is too short. Min. 40 chars."); - if (!r.salt || r.salt.length < 10) + if (!i.salt || i.salt.length < 10) throw new Error("Salt is too short. Min. 10 chars."); } - async function st() { - var r; - if (I) - throw E("mocking error"), new Error("Mocked error."); + async function Lt() { + var i; + if (x) + throw k("mocking error"), new Error("Mocked error."); if (o) - return E("using provided json data"), o; - if (_) - return E("generating test challenge", { test: _ }), qt(typeof _ != "boolean" ? +_ : void 0); + return k("using provided json data"), o; + if (Z) + return k("generating test challenge", { test: Z }), un(typeof Z != "boolean" ? +Z : void 0); { - if (!u) + if (!m && g) { + const y = g.getAttribute("action"); + y != null && y.includes("/form/") && t(17, m = y + "/altcha"); + } + if (!m) throw new Error("Attribute challengeurl not set."); - E("fetching challenge from", u); - const a = await fetch(u, { - headers: { - "x-altcha-spam-filter": w ? "1" : "0" - } + k("fetching challenge from", m); + const h = await fetch(m, { + headers: E ? { "x-altcha-spam-filter": "1" } : {} }); - if (a.status !== 200) - throw new Error(`Server responded with ${a.status}.`); - const g = a.headers.get("Expires"), R = a.headers.get("X-Altcha-Config"), V = await a.json(), T = new URLSearchParams((r = V.salt.split("?")) == null ? void 0 : r[1]), q = T.get("expires") || T.get("expire"); - if (q) { - const v = new Date(+q * 1e3), L = isNaN(v.getTime()) ? 0 : v.getTime() - Date.now(); - L > 0 && de(L); + if (h.status !== 200) + throw new Error(`Server responded with ${h.status}.`); + const w = h.headers.get("Expires"), T = h.headers.get("X-Altcha-Config"), P = await h.json(), N = new URLSearchParams((i = P.salt.split("?")) == null ? void 0 : i[1]), G = N.get("expires") || N.get("expire"); + if (G) { + const y = new Date(+G * 1e3), L = isNaN(y.getTime()) ? 0 : y.getTime() - Date.now(); + L > 0 && Ae(L); } - if (R) + if (T) try { - const v = JSON.parse(R); - v && typeof v == "object" && (v.verifyurl && (v.verifyurl = new URL(v.verifyurl, new URL(u)).toString()), Oe(v)); - } catch (v) { - E("unable to configure from X-Altcha-Config", v); + const y = JSON.parse(T); + y && typeof y == "object" && (y.verifyurl && (y.verifyurl = new URL(y.verifyurl, new URL(m)).toString()), et(y)); + } catch (y) { + k("unable to configure from X-Altcha-Config", y); } - if (!P && (g != null && g.length)) { - const v = Date.parse(g); - if (v) { - const L = v - Date.now(); - L > 0 && de(L); + if (!J && (w != null && w.length)) { + const y = Date.parse(w); + if (y) { + const L = y - Date.now(); + L > 0 && Ae(L); } } - return V; + return P; } } - function Ne() { - u && A && j === b.VERIFIED ? ee() : ge(b.EXPIRED, f.expired); + function Ge() { + if (!V) + if (g) { + if (k("analytics enabled"), t(11, V = new dn(g)), c === void 0) { + const i = g.getAttribute("action"); + i && t(19, c = i + "/beacon"); + } + t(11, V.beaconUrl = c || null, V); + } else + k("analytics cannot be enabled - form element not found"); + } + function Je() { + m && d && B === _.VERIFIED ? ie() : Le(_.EXPIRED, u.expired); } - async function ft(r) { - let a = null; + async function It(i) { + let h = null; if ("Worker" in window) { try { - a = await ct(r.challenge, r.salt, r.algorithm, r.maxnumber); - } catch (g) { - E(g); + h = await xt(i.challenge, i.salt, i.algorithm, i.maxnumber); + } catch (w) { + k(w); } - if ((a == null ? void 0 : a.number) !== void 0) - return { data: r, solution: a }; + if ((h == null ? void 0 : h.number) !== void 0) + return { data: i, solution: h }; } return { - data: r, - solution: await Zt(r.challenge, r.salt, r.algorithm, r.maxnumber || x).promise + data: i, + solution: await hn(i.challenge, i.salt, i.algorithm, i.maxnumber || C).promise }; } - async function ct(r, a, g, R = typeof _ == "number" ? _ : x, V = Math.ceil(oe)) { - const T = []; - V = Math.min(16, Math.max(1, V)); - for (let L = 0; L < V; L++) - T.push(createAltchaWorker(ae)); - const q = Math.ceil(R / V), v = await Promise.all(T.map((L, Ee) => { - const le = Ee * q; - return new Promise((me) => { - L.addEventListener("message", (be) => { - if (be.data) - for (const se of T) - se !== L && se.postMessage({ type: "abort" }); - me(be.data); + async function xt(i, h, w, T = typeof Z == "number" ? Z : C, P = Math.ceil(ue)) { + const N = []; + P = Math.min(16, Math.max(1, P)); + for (let L = 0; L < P; L++) + N.push(createAltchaWorker(ke)); + const G = Math.ceil(T / P), y = await Promise.all(N.map((L, De) => { + const he = De * G; + return new Promise((Ie) => { + L.addEventListener("message", (xe) => { + if (xe.data) + for (const de of N) + de !== L && de.postMessage({ type: "abort" }); + Ie(xe.data); }), L.postMessage({ payload: { - alg: g, - challenge: r, - max: le + q, - salt: a, - start: le + alg: w, + challenge: i, + max: he + G, + salt: h, + start: he }, type: "work" }); }); })); - for (const L of T) + for (const L of N) L.terminate(); - return v.find((L) => !!L) || null; + return y.find((L) => !!L) || null; } - function ut() { - [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(j) ? w && (m == null ? void 0 : m.reportValidity()) === !1 ? t(7, W = !1) : ee() : t(7, W = !0); + function Tt() { + [_.UNVERIFIED, _.ERROR, _.EXPIRED].includes(B) ? E && (g == null ? void 0 : g.reportValidity()) === !1 ? t(8, Q = !1) : ie() : t(8, Q = !0); } - function je(r) { - const a = r.target; - k && a && !C.contains(a) && j === b.VERIFIED && t(8, C.style.display = "none", C); + function Xe(i) { + const h = i.target; + b && h && !A.contains(h) && B === _.VERIFIED && t(9, A.style.display = "none", A); } - function Ve() { - k && ke(); + function We() { + b && Se(); } - function Fe() { - j === b.VERIFYING && f.waitAlert && alert(f.waitAlert); + function ze() { + B === _.VERIFYING && u.waitAlert && alert(u.waitAlert); } - function at(r) { - k && j !== b.UNVERIFIED && requestAnimationFrame(() => { - ke(); + function Ft(i) { + V && V.trackError(Ce); + } + function Rt(i) { + b && B !== _.UNVERIFIED && requestAnimationFrame(() => { + Se(); }); } - function Pe() { - k && ke(); + function Ke() { + b && Se(); } - function de(r) { - E("expire", r), U && (clearTimeout(U), U = null), r < 1 ? Ne() : U = setTimeout(Ne, r); + function Ae(i) { + k("expire", i), Y && (clearTimeout(Y), Y = null), i < 1 ? Je() : Y = setTimeout(Je, i); } - function He(r) { - E("floating", r), k !== r && (t(8, C.style.left = "", C), t(8, C.style.top = "", C)), t(1, k = r === !0 || r === "" ? "auto" : r === !1 || r === "false" ? void 0 : k), k ? (c || t(0, c = "onsubmit"), document.addEventListener("scroll", Ve), document.addEventListener("click", je), window.addEventListener("resize", Pe)) : c === "onsubmit" && t(0, c = void 0); + function Qe(i) { + k("floating", i), b !== i && (t(9, A.style.left = "", A), t(9, A.style.top = "", A)), t(1, b = i === !0 || i === "" ? "auto" : i === !1 || i === "false" ? void 0 : b), b ? (l || t(0, l = "onsubmit"), document.addEventListener("scroll", We), document.addEventListener("click", Xe), window.addEventListener("resize", Ke)) : l === "onsubmit" && t(0, l = void 0); } - function ht(r) { - var g; - const a = m == null ? void 0 : m.querySelector(typeof r == "string" ? `input[name="${r}"]` : 'input[type="email"]:not([data-no-spamfilter])'); - return ((g = a == null ? void 0 : a.value) == null ? void 0 : g.slice(a.value.indexOf("@"))) || void 0; + function St(i) { + var w; + const h = g == null ? void 0 : g.querySelector(typeof i == "string" ? `input[name="${i}"]` : 'input[type="email"]:not([data-no-spamfilter])'); + return ((w = h == null ? void 0 : h.value) == null ? void 0 : w.slice(h.value.indexOf("@"))) || void 0; } - function dt(r) { + function Dt(i) { return [ - ...(m == null ? void 0 : m.querySelectorAll(r != null && r.length ? r.map((g) => `input[name="${g}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] + ...(g == null ? void 0 : g.querySelectorAll(i != null && i.length ? i.map((w) => `input[name="${w}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] ].reduce( - (g, R) => { - const V = R.name, T = R.value; - return V && T && (g[V] = /\n/.test(T) ? T.replace(new RegExp("(? { + const P = T.name, N = T.value; + return P && N && (w[P] = /\n/.test(N) ? N.replace(new RegExp("(? V : k === "top", v = Math.max(r, Math.min(T - r - R.width, g.left + g.width / 2 - R.width / 2)); - if (q ? t(8, C.style.top = `${g.top - (R.height + a)}px`, C) : t(8, C.style.top = `${g.bottom + a}px`, C), t(8, C.style.left = `${v}px`, C), C.setAttribute("data-floating", q ? "top" : "bottom"), K) { - const L = K.getBoundingClientRect(); - t(9, K.style.left = g.left - v + g.width / 2 - L.width / 2 + "px", K); + function Se(i = 20) { + if (A) + if (pe || (pe = (K ? document.querySelector(K) : g == null ? void 0 : g.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || g), pe) { + const h = parseInt(X, 10) || 12, w = pe.getBoundingClientRect(), T = A.getBoundingClientRect(), P = document.documentElement.clientHeight, N = document.documentElement.clientWidth, G = b === "auto" ? w.bottom + T.height + h + i > P : b === "top", y = Math.max(i, Math.min(N - i - T.width, w.left + w.width / 2 - T.width / 2)); + if (G ? t(9, A.style.top = `${w.top - (T.height + h)}px`, A) : t(9, A.style.top = `${w.bottom + h}px`, A), t(9, A.style.left = `${y}px`, A), A.setAttribute("data-floating", G ? "top" : "bottom"), te) { + const L = te.getBoundingClientRect(); + t(10, te.style.left = w.left - y + w.width / 2 - L.width / 2 + "px", te); } } else - E("unable to find floating anchor element"); + k("unable to find floating anchor element"); } - function Oe(r) { - r.auto !== void 0 && (t(0, c = r.auto), c === "onload" && ee()), r.floatinganchor !== void 0 && t(19, G = r.floatinganchor), r.delay !== void 0 && t(17, B = r.delay), r.floatingoffset !== void 0 && t(20, $ = r.floatingoffset), r.floating !== void 0 && He(r.floating), r.expire !== void 0 && (de(r.expire), t(18, P = r.expire)), r.challenge && (De(r.challenge), o = r.challenge), r.challengeurl !== void 0 && t(15, u = r.challengeurl), r.debug !== void 0 && t(16, S = !!r.debug), r.hidefooter !== void 0 && t(2, J = !!r.hidefooter), r.hidelogo !== void 0 && t(3, Z = !!r.hidelogo), r.maxnumber !== void 0 && t(21, x = +r.maxnumber), r.mockerror !== void 0 && t(22, I = !!r.mockerror), r.name !== void 0 && t(4, N = r.name), r.refetchonexpire !== void 0 && t(23, A = !!r.refetchonexpire), r.spamfilter !== void 0 && t(24, w = typeof r.spamfilter == "object" ? r.spamfilter : !!r.spamfilter), r.strings && t(35, l = r.strings), r.test !== void 0 && t(25, _ = typeof r.test == "number" ? r.test : !!r.test), r.verifyurl !== void 0 && t(26, z = r.verifyurl), r.workers !== void 0 && t(27, oe = +r.workers), r.workerurl !== void 0 && t(28, ae = r.workerurl); + function et(i) { + i.analytics && (t(18, f = i.analytics), Ge()), i.auto !== void 0 && (t(0, l = i.auto), l === "onload" && ie()), i.beaconurl && (t(19, c = i.beaconurl), V && t(11, V.beaconUrl = c, V)), i.floatinganchor !== void 0 && t(23, K = i.floatinganchor), i.delay !== void 0 && t(21, q = i.delay), i.floatingoffset !== void 0 && t(24, X = i.floatingoffset), i.floating !== void 0 && Qe(i.floating), i.expire !== void 0 && (Ae(i.expire), t(22, J = i.expire)), i.challenge && (Ye(i.challenge), o = i.challenge), i.challengeurl !== void 0 && t(17, m = i.challengeurl), i.debug !== void 0 && t(20, $ = !!i.debug), i.hidefooter !== void 0 && t(2, j = !!i.hidefooter), i.hidelogo !== void 0 && t(3, I = !!i.hidelogo), i.maxnumber !== void 0 && t(25, C = +i.maxnumber), i.mockerror !== void 0 && t(26, x = !!i.mockerror), i.name !== void 0 && t(4, R = i.name), i.refetchonexpire !== void 0 && t(27, d = !!i.refetchonexpire), i.spamfilter !== void 0 && t(28, E = typeof i.spamfilter == "object" ? i.spamfilter : !!i.spamfilter), i.strings && t(39, s = i.strings), i.test !== void 0 && t(29, Z = typeof i.test == "number" ? i.test : !!i.test), i.verifyurl !== void 0 && t(30, ee = i.verifyurl), i.workers !== void 0 && t(31, ue = +i.workers), i.workerurl !== void 0 && t(32, ke = i.workerurl); } - function ge(r = b.UNVERIFIED, a = null) { - U && (clearTimeout(U), U = null), t(7, W = !1), t(10, ve = a), t(5, Q = null), t(6, j = r); + function Le(i = _.UNVERIFIED, h = null) { + Y && (clearTimeout(Y), Y = null), t(8, Q = !1), t(5, Ce = h), t(6, ne = null), t(7, B = i); } - async function ee() { - return ge(b.VERIFYING), await new Promise((r) => setTimeout(r, B || 0)), st().then((r) => (De(r), E("challenge", r), ft(r))).then(({ data: r, solution: a }) => { - if (E("solution", a), (a == null ? void 0 : a.number) !== void 0) { - if (z) - return gt(Te(r, a)); - t(5, Q = Te(r, a)), E("payload", Q); + async function ie() { + return Le(_.VERIFYING), await new Promise((i) => setTimeout(i, q || 0)), Lt().then((i) => (Ye(i), k("challenge", i), It(i))).then(({ data: i, solution: h }) => { + if (k("solution", h), (h == null ? void 0 : h.number) !== void 0) { + if (ee) + return Mt(Ze(i, h)); + t(6, ne = Ze(i, h)), k("payload", ne); } else - throw E("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); + throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); }).then(() => { - $t().then(() => { - t(6, j = b.VERIFIED), t(7, W = !0), E("verified"), ye("verified", { payload: Q }); + Wt().then(() => { + t(7, B = _.VERIFIED), t(8, Q = !0), k("verified"), Re("verified", { payload: ne }); }); - }).catch((r) => { - E(r), t(6, j = b.ERROR), t(7, W = !1), t(10, ve = r.message); + }).catch((i) => { + k(i), t(7, B = _.ERROR), t(8, Q = !1), t(5, Ce = i.message); }); } - function bt() { - W = this.checked, t(7, W); + function jt() { + Q = this.checked, t(8, Q); } - function _t(r) { - we[r ? "unshift" : "push"](() => { - K = r, t(9, K); + function Vt(i) { + Fe[i ? "unshift" : "push"](() => { + te = i, t(10, te); }); } - function wt(r) { - we[r ? "unshift" : "push"](() => { - C = r, t(8, C); + function Bt(i) { + Fe[i ? "unshift" : "push"](() => { + A = i, t(9, A); }); } - return n.$$set = (r) => { - "auto" in r && t(0, c = r.auto), "blockspam" in r && t(29, h = r.blockspam), "challengeurl" in r && t(15, u = r.challengeurl), "challengejson" in r && t(30, H = r.challengejson), "debug" in r && t(16, S = r.debug), "delay" in r && t(17, B = r.delay), "expire" in r && t(18, P = r.expire), "floating" in r && t(1, k = r.floating), "floatinganchor" in r && t(19, G = r.floatinganchor), "floatingoffset" in r && t(20, $ = r.floatingoffset), "hidefooter" in r && t(2, J = r.hidefooter), "hidelogo" in r && t(3, Z = r.hidelogo), "name" in r && t(4, N = r.name), "maxnumber" in r && t(21, x = r.maxnumber), "mockerror" in r && t(22, I = r.mockerror), "refetchonexpire" in r && t(23, A = r.refetchonexpire), "spamfilter" in r && t(24, w = r.spamfilter), "strings" in r && t(31, d = r.strings), "test" in r && t(25, _ = r.test), "verifyurl" in r && t(26, z = r.verifyurl), "workers" in r && t(27, oe = r.workers), "workerurl" in r && t(28, ae = r.workerurl); + return n.$$set = (i) => { + "analytics" in i && t(18, f = i.analytics), "auto" in i && t(0, l = i.auto), "beaconurl" in i && t(19, c = i.beaconurl), "blockspam" in i && t(33, O = i.blockspam), "challengeurl" in i && t(17, m = i.challengeurl), "challengejson" in i && t(34, H = i.challengejson), "debug" in i && t(20, $ = i.debug), "delay" in i && t(21, q = i.delay), "expire" in i && t(22, J = i.expire), "floating" in i && t(1, b = i.floating), "floatinganchor" in i && t(23, K = i.floatinganchor), "floatingoffset" in i && t(24, X = i.floatingoffset), "hidefooter" in i && t(2, j = i.hidefooter), "hidelogo" in i && t(3, I = i.hidelogo), "name" in i && t(4, R = i.name), "maxnumber" in i && t(25, C = i.maxnumber), "mockerror" in i && t(26, x = i.mockerror), "refetchonexpire" in i && t(27, d = i.refetchonexpire), "spamfilter" in i && t(28, E = i.spamfilter), "strings" in i && t(35, Ee = i.strings), "test" in i && t(29, Z = i.test), "verifyurl" in i && t(30, ee = i.verifyurl), "workers" in i && t(31, ue = i.workers), "workerurl" in i && t(32, ke = i.workerurl); }, n.$$.update = () => { n.$$.dirty[0] & /*challengeurl*/ - 32768 && t(12, i = !!(u != null && u.includes(".altcha.org")) && !!(u != null && u.includes("apiKey=ckey_"))), n.$$.dirty[0] & /*challengejson*/ - 1073741824 && (o = H ? Qe(H) : void 0), n.$$.dirty[1] & /*strings*/ - 1 && t(35, l = d ? Qe(d) : {}), n.$$.dirty[1] & /*parsedStrings*/ - 16 && t(11, f = { - ariaLinkLabel: Ke, + 131072 && t(14, r = !!(m != null && m.includes(".altcha.org")) && !!(m != null && m.includes("apiKey=ckey_"))), n.$$.dirty[1] & /*challengejson*/ + 8 && (o = H ? bt(H) : void 0), n.$$.dirty[1] & /*strings*/ + 16 && t(39, s = Ee ? bt(Ee) : {}), n.$$.dirty[1] & /*parsedStrings*/ + 256 && t(13, u = { + ariaLinkLabel: mt, error: "Verification failed. Try again later.", expired: "Verification expired. Try again.", - footer: `Protected by ALTCHA`, + footer: `Protected by ALTCHA`, label: "I'm not a robot", verified: "Verified", verifying: "Verifying...", waitAlert: "Verifying... please wait.", - ...l + ...s }), n.$$.dirty[0] & /*payload, state*/ - 96 && ye("statechange", { payload: Q, state: j }), n.$$.dirty[0] & /*state*/ - 64 && at(); + 192 && Re("statechange", { payload: ne, state: B }), n.$$.dirty[0] & /*error*/ + 32 && Ft(), n.$$.dirty[0] & /*state*/ + 128 && Rt(); }, [ - c, - k, - J, - Z, - N, - Q, + l, + b, j, - W, - C, - K, - ve, - f, - i, - ut, - Fe, - u, - S, + I, + R, + Ce, + ne, B, - P, - G, + Q, + A, + te, + V, + Oe, + u, + r, + Tt, + ze, + m, + f, + c, $, + q, + J, + K, + X, + C, x, - I, - A, - w, - _, - z, - oe, - ae, - h, - H, d, - Oe, - ge, + E, + Z, ee, - l, - bt, - _t, - wt + ue, + ke, + O, + H, + Ee, + et, + Le, + ie, + s, + jt, + Vt, + Bt ]; } -class en extends Ht { +class En extends ln { constructor(e) { - super(), Ft( + super(), on( this, e, - Qt, - zt, - kt, + vn, + yn, + Ot, { + analytics: 18, auto: 0, - blockspam: 29, - challengeurl: 15, - challengejson: 30, - debug: 16, - delay: 17, - expire: 18, + beaconurl: 19, + blockspam: 33, + challengeurl: 17, + challengejson: 34, + debug: 20, + delay: 21, + expire: 22, floating: 1, - floatinganchor: 19, - floatingoffset: 20, + floatinganchor: 23, + floatingoffset: 24, hidefooter: 2, hidelogo: 3, name: 4, - maxnumber: 21, - mockerror: 22, - refetchonexpire: 23, - spamfilter: 24, - strings: 31, - test: 25, - verifyurl: 26, - workers: 27, - workerurl: 28, - configure: 32, - reset: 33, - verify: 34 + maxnumber: 25, + mockerror: 26, + refetchonexpire: 27, + spamfilter: 28, + strings: 35, + test: 29, + verifyurl: 30, + workers: 31, + workerurl: 32, + configure: 36, + reset: 37, + verify: 38 }, null, [-1, -1, -1] ); } + get analytics() { + return this.$$.ctx[18]; + } + set analytics(e) { + this.$$set({ analytics: e }), v(); + } get auto() { return this.$$.ctx[0]; } set auto(e) { - this.$$set({ auto: e }), y(); + this.$$set({ auto: e }), v(); + } + get beaconurl() { + return this.$$.ctx[19]; + } + set beaconurl(e) { + this.$$set({ beaconurl: e }), v(); } get blockspam() { - return this.$$.ctx[29]; + return this.$$.ctx[33]; } set blockspam(e) { - this.$$set({ blockspam: e }), y(); + this.$$set({ blockspam: e }), v(); } get challengeurl() { - return this.$$.ctx[15]; + return this.$$.ctx[17]; } set challengeurl(e) { - this.$$set({ challengeurl: e }), y(); + this.$$set({ challengeurl: e }), v(); } get challengejson() { - return this.$$.ctx[30]; + return this.$$.ctx[34]; } set challengejson(e) { - this.$$set({ challengejson: e }), y(); + this.$$set({ challengejson: e }), v(); } get debug() { - return this.$$.ctx[16]; + return this.$$.ctx[20]; } set debug(e) { - this.$$set({ debug: e }), y(); + this.$$set({ debug: e }), v(); } get delay() { - return this.$$.ctx[17]; + return this.$$.ctx[21]; } set delay(e) { - this.$$set({ delay: e }), y(); + this.$$set({ delay: e }), v(); } get expire() { - return this.$$.ctx[18]; + return this.$$.ctx[22]; } set expire(e) { - this.$$set({ expire: e }), y(); + this.$$set({ expire: e }), v(); } get floating() { return this.$$.ctx[1]; } set floating(e) { - this.$$set({ floating: e }), y(); + this.$$set({ floating: e }), v(); } get floatinganchor() { - return this.$$.ctx[19]; + return this.$$.ctx[23]; } set floatinganchor(e) { - this.$$set({ floatinganchor: e }), y(); + this.$$set({ floatinganchor: e }), v(); } get floatingoffset() { - return this.$$.ctx[20]; + return this.$$.ctx[24]; } set floatingoffset(e) { - this.$$set({ floatingoffset: e }), y(); + this.$$set({ floatingoffset: e }), v(); } get hidefooter() { return this.$$.ctx[2]; } set hidefooter(e) { - this.$$set({ hidefooter: e }), y(); + this.$$set({ hidefooter: e }), v(); } get hidelogo() { return this.$$.ctx[3]; } set hidelogo(e) { - this.$$set({ hidelogo: e }), y(); + this.$$set({ hidelogo: e }), v(); } get name() { return this.$$.ctx[4]; } set name(e) { - this.$$set({ name: e }), y(); + this.$$set({ name: e }), v(); } get maxnumber() { - return this.$$.ctx[21]; + return this.$$.ctx[25]; } set maxnumber(e) { - this.$$set({ maxnumber: e }), y(); + this.$$set({ maxnumber: e }), v(); } get mockerror() { - return this.$$.ctx[22]; + return this.$$.ctx[26]; } set mockerror(e) { - this.$$set({ mockerror: e }), y(); + this.$$set({ mockerror: e }), v(); } get refetchonexpire() { - return this.$$.ctx[23]; + return this.$$.ctx[27]; } set refetchonexpire(e) { - this.$$set({ refetchonexpire: e }), y(); + this.$$set({ refetchonexpire: e }), v(); } get spamfilter() { - return this.$$.ctx[24]; + return this.$$.ctx[28]; } set spamfilter(e) { - this.$$set({ spamfilter: e }), y(); + this.$$set({ spamfilter: e }), v(); } get strings() { - return this.$$.ctx[31]; + return this.$$.ctx[35]; } set strings(e) { - this.$$set({ strings: e }), y(); + this.$$set({ strings: e }), v(); } get test() { - return this.$$.ctx[25]; + return this.$$.ctx[29]; } set test(e) { - this.$$set({ test: e }), y(); + this.$$set({ test: e }), v(); } get verifyurl() { - return this.$$.ctx[26]; + return this.$$.ctx[30]; } set verifyurl(e) { - this.$$set({ verifyurl: e }), y(); + this.$$set({ verifyurl: e }), v(); } get workers() { - return this.$$.ctx[27]; + return this.$$.ctx[31]; } set workers(e) { - this.$$set({ workers: e }), y(); + this.$$set({ workers: e }), v(); } get workerurl() { - return this.$$.ctx[28]; + return this.$$.ctx[32]; } set workerurl(e) { - this.$$set({ workerurl: e }), y(); + this.$$set({ workerurl: e }), v(); } get configure() { - return this.$$.ctx[32]; + return this.$$.ctx[36]; } get reset() { - return this.$$.ctx[33]; + return this.$$.ctx[37]; } get verify() { - return this.$$.ctx[34]; + return this.$$.ctx[38]; } } -customElements.define("altcha-widget", Pt(en, { auto: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, delay: {}, expire: {}, floating: {}, floatinganchor: {}, floatingoffset: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, [], ["configure", "reset", "verify"], !1)); +customElements.define("altcha-widget", sn(En, { analytics: { type: "Boolean" }, auto: {}, beaconurl: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, delay: {}, expire: {}, floating: {}, floatinganchor: {}, floatingoffset: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, [], ["configure", "reset", "verify"], !1)); globalThis.createAltchaWorker = (n) => new Worker(new URL(n || "./worker.js", import.meta.url)); export { - en as Altcha + En as Altcha }; diff --git a/dist_external/altcha.umd.cjs b/dist_external/altcha.umd.cjs index d5972dc..1b8c724 100644 --- a/dist_external/altcha.umd.cjs +++ b/dist_external/altcha.umd.cjs @@ -1,2 +1,2 @@ -(function(O,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(O=typeof globalThis<"u"?globalThis:O||self,D(O.altcha={}))})(this,function(O){"use strict";var tn=Object.defineProperty;var nn=(O,D,q)=>D in O?tn(O,D,{enumerable:!0,configurable:!0,writable:!0,value:q}):O[D]=q;var U=(O,D,q)=>nn(O,typeof D!="symbol"?D+"":D,q);var D=typeof document<"u"?document.currentScript:null;function q(){}function $e(n){return n()}function Se(){return Object.create(null)}function se(n){n.forEach($e)}function Te(n){return typeof n=="function"}function ut(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function at(n){return Object.keys(n).length===0}function k(n,e){n.appendChild(e)}function N(n,e,t){n.insertBefore(e,t||null)}function j(n){n.parentNode&&n.parentNode.removeChild(n)}function $(n){return document.createElement(n)}function W(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function ht(n){return document.createTextNode(n)}function J(){return ht(" ")}function ke(n,e,t,r){return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}function s(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function dt(n){return Array.from(n.childNodes)}function Me(n,e,t){n.classList.toggle(e,!!t)}function gt(n,e,{bubbles:t=!1,cancelable:r=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:r})}function mt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let fe;function ce(n){fe=n}function pe(){if(!fe)throw new Error("Function called outside component initialization");return fe}function bt(n){pe().$$.on_mount.push(n)}function _t(n){pe().$$.on_destroy.push(n)}function wt(){const n=pe();return(e,t,{cancelable:r=!1}={})=>{const o=n.$$.callbacks[e];if(o){const l=gt(e,t,{cancelable:r});return o.slice().forEach(f=>{f.call(n,l)}),!l.defaultPrevented}return!0}}const re=[],de=[];let oe=[];const je=[],De=Promise.resolve();let Ee=!1;function Ne(){Ee||(Ee=!0,De.then(w))}function yt(){return Ne(),De}function xe(n){oe.push(n)}const Ce=new Set;let le=0;function w(){if(le!==0)return;const n=fe;do{try{for(;len.indexOf(r)===-1?e.push(r):t.push(r)),t.forEach(r=>r()),oe=e}const pt=new Set;function Et(n,e){n&&n.i&&(pt.delete(n),n.i(e))}function xt(n,e,t){const{fragment:r,after_update:o}=n.$$;r&&r.m(e,t),xe(()=>{const l=n.$$.on_mount.map($e).filter(Te);n.$$.on_destroy?n.$$.on_destroy.push(...l):se(l),n.$$.on_mount=[]}),o.forEach(xe)}function Ct(n,e){const t=n.$$;t.fragment!==null&&(kt(t.after_update),se(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Lt(n,e){n.$$.dirty[0]===-1&&(re.push(n),Ne(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const p=H.length?H[0]:Z;return u.ctx&&o(u.ctx[T],u.ctx[T]=p)&&(!u.skip_bound&&u.bound[T]&&u.bound[T](p),B&&Lt(n,T)),Z}):[],u.update(),B=!0,se(u.before_update),u.fragment=r?r(u.ctx):!1,e.target){if(e.hydrate){const T=dt(e.target);u.fragment&&u.fragment.l(T),T.forEach(j)}else u.fragment&&u.fragment.c();e.intro&&Et(n.$$.fragment),xt(n,e.target,e.anchor),w()}ce(h)}let Ve;typeof HTMLElement=="function"&&(Ve=class extends HTMLElement{constructor(e,t,r){super();U(this,"$$ctor");U(this,"$$s");U(this,"$$c");U(this,"$$cn",!1);U(this,"$$d",{});U(this,"$$r",!1);U(this,"$$p_d",{});U(this,"$$l",{});U(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,r&&this.attachShadow({mode:"open"})}addEventListener(e,t,r){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,r)}removeEventListener(e,t,r){if(super.removeEventListener(e,t,r),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let f;return{c:function(){f=$("slot"),l!=="default"&&s(f,"name",l)},m:function(u,B){N(u,f,B)},d:function(u){u&&j(f)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},r=mt(this);for(const l of this.$$s)l in r&&(t[l]=[e(l)]);for(const l of this.attributes){const f=this.$$g_p(l.name);f in this.$$d||(this.$$d[f]=ge(f,l.value,this.$$p_d,"toProp"))}for(const l in this.$$p_d)!(l in this.$$d)&&this[l]!==void 0&&(this.$$d[l]=this[l],delete this[l]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const l in this.$$p_d)if(this.$$d[l]=this.$$c.$$.ctx[this.$$c.$$.props[l]],this.$$p_d[l].reflect){const f=ge(l,this.$$d[l],this.$$p_d,"toAttribute");f==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,f)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const f of this.$$l[l]){const c=this.$$c.$on(l,f);this.$$l_u.set(f,c)}this.$$l={}}}attributeChangedCallback(e,t,r){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=ge(e,r,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function ge(n,e,t,r){var l;const o=(l=t[n])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!r||!t[n])return e;if(r==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function At(n,e,t,r,o,l){let f=class extends Ve{constructor(){super(n,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(c=>(e[c].attribute||c).toLowerCase())}};return Object.keys(e).forEach(c=>{Object.defineProperty(f.prototype,c,{get(){return this.$$c&&c in this.$$c?this.$$c[c]:this.$$d[c]},set(h){var u;h=ge(c,h,e),this.$$d[c]=h,(u=this.$$c)==null||u.$set({[c]:h})}})}),r.forEach(c=>{Object.defineProperty(f.prototype,c,{get(){var h;return(h=this.$$c)==null?void 0:h[c]}})}),n.element=f,f}class Rt{constructor(){U(this,"$$");U(this,"$$set")}$destroy(){Ct(this,1),this.$destroy=q}$on(e,t){if(!Te(t))return q;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(t),()=>{const o=r.indexOf(t);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!at(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const $t="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add($t);const St=new TextEncoder;function Tt(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Mt(n,e="SHA-256",t=1e5){const r=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await Fe(r,n,e);return{algorithm:e,challenge:o,salt:r,signature:""}}async function Fe(n,e,t){return Tt(await crypto.subtle.digest(t.toUpperCase(),St.encode(n+e)))}function jt(n,e,t="SHA-256",r=1e6,o=0){const l=new AbortController,f=Date.now();return{promise:(async()=>{for(let h=o;h<=r;h+=1){if(l.signal.aborted)return null;if(await Fe(e,h,t)===n)return{number:h,took:Date.now()-f}}return null})(),controller:l}}var m=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(m||{});function Pe(n){let e,t,r;return{c(){e=W("svg"),t=W("path"),r=W("path"),s(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),s(t,"fill","currentColor"),s(t,"opacity",".25"),s(r,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),s(r,"fill","currentColor"),s(r,"class","altcha-spinner"),s(e,"width","24"),s(e,"height","24"),s(e,"viewBox","0 0 24 24"),s(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){N(o,e,l),k(e,t),k(e,r)},d(o){o&&j(e)}}}function Dt(n){let e,t=n[11].label+"",r;return{c(){e=$("label"),s(e,"for",r=n[4]+"_checkbox")},m(o,l){N(o,e,l),e.innerHTML=t},p(o,l){l[0]&2048&&t!==(t=o[11].label+"")&&(e.innerHTML=t),l[0]&16&&r!==(r=o[4]+"_checkbox")&&s(e,"for",r)},d(o){o&&j(e)}}}function Nt(n){let e,t=n[11].verifying+"";return{c(){e=$("span")},m(r,o){N(r,e,o),e.innerHTML=t},p(r,o){o[0]&2048&&t!==(t=r[11].verifying+"")&&(e.innerHTML=t)},d(r){r&&j(e)}}}function Vt(n){let e,t=n[11].verified+"",r,o;return{c(){e=$("span"),r=J(),o=$("input"),s(o,"type","hidden"),s(o,"name",n[4]),o.value=n[5]},m(l,f){N(l,e,f),e.innerHTML=t,N(l,r,f),N(l,o,f)},p(l,f){f[0]&2048&&t!==(t=l[11].verified+"")&&(e.innerHTML=t),f[0]&16&&s(o,"name",l[4]),f[0]&32&&(o.value=l[5])},d(l){l&&(j(e),j(r),j(o))}}}function He(n){let e,t,r,o,l,f,c;return{c(){e=$("div"),t=$("a"),r=W("svg"),o=W("path"),l=W("path"),f=W("path"),s(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),s(o,"fill","currentColor"),s(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),s(l,"fill","currentColor"),s(f,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),s(f,"fill","currentColor"),s(r,"width","22"),s(r,"height","22"),s(r,"viewBox","0 0 20 20"),s(r,"fill","none"),s(r,"xmlns","http://www.w3.org/2000/svg"),s(t,"href",Ze),s(t,"target","_blank"),s(t,"class","altcha-logo"),s(t,"aria-label",c=n[11].ariaLinkLabel)},m(h,u){N(h,e,u),k(e,t),k(t,r),k(r,o),k(r,l),k(r,f)},p(h,u){u[0]&2048&&c!==(c=h[11].ariaLinkLabel)&&s(t,"aria-label",c)},d(h){h&&j(e)}}}function Oe(n){let e,t,r,o;function l(h,u){return h[6]===m.EXPIRED?Pt:Ft}let f=l(n),c=f(n);return{c(){e=$("div"),t=W("svg"),r=W("path"),o=J(),c.c(),s(r,"stroke-linecap","round"),s(r,"stroke-linejoin","round"),s(r,"d","M6 18L18 6M6 6l12 12"),s(t,"width","14"),s(t,"height","14"),s(t,"xmlns","http://www.w3.org/2000/svg"),s(t,"fill","none"),s(t,"viewBox","0 0 24 24"),s(t,"stroke-width","1.5"),s(t,"stroke","currentColor"),s(e,"class","altcha-error")},m(h,u){N(h,e,u),k(e,t),k(t,r),k(e,o),c.m(e,null)},p(h,u){f===(f=l(h))&&c?c.p(h,u):(c.d(1),c=f(h),c&&(c.c(),c.m(e,null)))},d(h){h&&j(e),c.d()}}}function Ft(n){let e,t=n[11].error+"";return{c(){e=$("div"),s(e,"title",n[10])},m(r,o){N(r,e,o),e.innerHTML=t},p(r,o){o[0]&2048&&t!==(t=r[11].error+"")&&(e.innerHTML=t),o[0]&1024&&s(e,"title",r[10])},d(r){r&&j(e)}}}function Pt(n){let e,t=n[11].expired+"";return{c(){e=$("div"),s(e,"title",n[10])},m(r,o){N(r,e,o),e.innerHTML=t},p(r,o){o[0]&2048&&t!==(t=r[11].expired+"")&&(e.innerHTML=t),o[0]&1024&&s(e,"title",r[10])},d(r){r&&j(e)}}}function Be(n){let e,t,r=n[11].footer+"";return{c(){e=$("div"),t=$("div"),s(e,"class","altcha-footer")},m(o,l){N(o,e,l),k(e,t),t.innerHTML=r},p(o,l){l[0]&2048&&r!==(r=o[11].footer+"")&&(t.innerHTML=r)},d(o){o&&j(e)}}}function Ue(n){let e;return{c(){e=$("div"),s(e,"class","altcha-anchor-arrow")},m(t,r){N(t,e,r),n[37](e)},p:q,d(t){t&&j(e),n[37](null)}}}function Ht(n){let e,t,r,o,l,f,c,h,u,B,T,Z,H,p,z,S=n[6]===m.VERIFYING&&Pe();function Q(d,_){return d[6]===m.VERIFIED?Vt:d[6]===m.VERIFYING?Nt:Dt}let X=Q(n),V=X(n),x=(n[3]!==!0||n[12])&&He(n),I=(n[10]||n[6]===m.EXPIRED)&&Oe(n),A=n[11].footer&&(n[2]!==!0||n[12])&&Be(n),y=n[1]&&Ue(n);return{c(){e=$("div"),t=$("div"),S&&S.c(),r=J(),o=$("div"),l=$("input"),h=J(),u=$("div"),V.c(),B=J(),x&&x.c(),T=J(),I&&I.c(),Z=J(),A&&A.c(),H=J(),y&&y.c(),s(l,"type","checkbox"),s(l,"id",f=n[4]+"_checkbox"),l.required=c=n[0]!=="onsubmit",s(o,"class","altcha-checkbox"),Me(o,"altcha-hidden",n[6]===m.VERIFYING),s(u,"class","altcha-label"),s(t,"class","altcha-main"),s(e,"class","altcha"),s(e,"data-state",n[6]),s(e,"data-floating",n[1])},m(d,_){N(d,e,_),k(e,t),S&&S.m(t,null),k(t,r),k(t,o),k(o,l),l.checked=n[7],k(t,h),k(t,u),V.m(u,null),k(t,B),x&&x.m(t,null),k(e,T),I&&I.m(e,null),k(e,Z),A&&A.m(e,null),k(e,H),y&&y.m(e,null),n[38](e),p||(z=[ke(l,"change",n[36]),ke(l,"change",n[13]),ke(l,"invalid",n[14])],p=!0)},p(d,_){d[6]===m.VERIFYING?S||(S=Pe(),S.c(),S.m(t,r)):S&&(S.d(1),S=null),_[0]&16&&f!==(f=d[4]+"_checkbox")&&s(l,"id",f),_[0]&1&&c!==(c=d[0]!=="onsubmit")&&(l.required=c),_[0]&128&&(l.checked=d[7]),_[0]&64&&Me(o,"altcha-hidden",d[6]===m.VERIFYING),X===(X=Q(d))&&V?V.p(d,_):(V.d(1),V=X(d),V&&(V.c(),V.m(u,null))),d[3]!==!0||d[12]?x?x.p(d,_):(x=He(d),x.c(),x.m(t,null)):x&&(x.d(1),x=null),d[10]||d[6]===m.EXPIRED?I?I.p(d,_):(I=Oe(d),I.c(),I.m(e,Z)):I&&(I.d(1),I=null),d[11].footer&&(d[2]!==!0||d[12])?A?A.p(d,_):(A=Be(d),A.c(),A.m(e,H)):A&&(A.d(1),A=null),d[1]?y?y.p(d,_):(y=Ue(d),y.c(),y.m(e,null)):y&&(y.d(1),y=null),_[0]&64&&s(e,"data-state",d[6]),_[0]&2&&s(e,"data-floating",d[1])},i:q,o:q,d(d){d&&j(e),S&&S.d(),V.d(),x&&x.d(),I&&I.d(),A&&A.d(),y&&y.d(),n[38](null),p=!1,se(z)}}}const qe="Visit Altcha.org",Ze="https://altcha.org/";function Ye(n){return JSON.parse(n)}function Ot(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Bt(n,e,t){var ft,ct;let r,o,l,f,{auto:c=void 0}=e,{blockspam:h=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:B=void 0}=e,{debug:T=!1}=e,{delay:Z=0}=e,{expire:H=void 0}=e,{floating:p=void 0}=e,{floatinganchor:z=void 0}=e,{floatingoffset:S=void 0}=e,{hidefooter:Q=!1}=e,{hidelogo:X=!1}=e,{name:V="altcha"}=e,{maxnumber:x=1e6}=e,{mockerror:I=!1}=e,{refetchonexpire:A=!0}=e,{spamfilter:y=!1}=e,{strings:d=void 0}=e,{test:_=!1}=e,{verifyurl:ee=void 0}=e,{workers:ue=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:me=void 0}=e;const Le=wt(),We=["SHA-256","SHA-384","SHA-512"],Xe=(ct=(ft=document.documentElement.lang)==null?void 0:ft.split("-"))==null?void 0:ct[0];let K=!1,C,te=null,be=null,b=null,Ie=null,ne=null,F=m.UNVERIFIED,Y=null;_t(()=>{b&&(b.removeEventListener("submit",ze),b.removeEventListener("reset",Ke),b.removeEventListener("focusin",Je),b=null),Y&&(clearTimeout(Y),Y=null),document.removeEventListener("click",nt),document.removeEventListener("scroll",it),window.removeEventListener("resize",ot)}),bt(()=>{E("mounted","0.6.7"),E("workers",ue),_&&E("using test mode"),H&&_e(H),c!==void 0&&E("auto",c),p!==void 0&<(p),b=C.closest("form"),b&&(b.addEventListener("submit",ze,{capture:!0}),b.addEventListener("reset",Ke),c==="onfocus"&&b.addEventListener("focusin",Je)),c==="onload"&&ie(),r&&(Q||X)&&E("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.")});function E(...i){(T||i.some(a=>a instanceof Error))&&console[i[0]instanceof Error?"error":"log"]("ALTCHA",...i)}function Je(i){F===m.UNVERIFIED&&ie()}function ze(i){b&&c==="onsubmit"&&(F===m.UNVERIFIED?(i.preventDefault(),i.stopPropagation(),ie().then(()=>{b==null||b.requestSubmit()})):F!==m.VERIFIED&&(i.preventDefault(),i.stopPropagation(),F===m.VERIFYING&&rt()))}function Ke(){we()}function Qe(i,a){return btoa(JSON.stringify({algorithm:i.algorithm,challenge:i.challenge,number:a.number,salt:i.salt,signature:i.signature,test:_?!0:void 0,took:a.took}))}function et(i){if(!i.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(i.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!We.includes(i.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${We.join(", ")}`);if(!i.challenge||i.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!i.salt||i.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function Ut(){var i;if(I)throw E("mocking error"),new Error("Mocked error.");if(o)return E("using provided json data"),o;if(_)return E("generating test challenge",{test:_}),Mt(typeof _!="boolean"?+_:void 0);{if(!u)throw new Error("Attribute challengeurl not set.");E("fetching challenge from",u);const a=await fetch(u,{headers:{"x-altcha-spam-filter":y?"1":"0"}});if(a.status!==200)throw new Error(`Server responded with ${a.status}.`);const g=a.headers.get("Expires"),R=a.headers.get("X-Altcha-Config"),P=await a.json(),M=new URLSearchParams((i=P.salt.split("?"))==null?void 0:i[1]),G=M.get("expires")||M.get("expire");if(G){const v=new Date(+G*1e3),L=isNaN(v.getTime())?0:v.getTime()-Date.now();L>0&&_e(L)}if(R)try{const v=JSON.parse(R);v&&typeof v=="object"&&(v.verifyurl&&(v.verifyurl=new URL(v.verifyurl,new URL(u)).toString()),st(v))}catch(v){E("unable to configure from X-Altcha-Config",v)}if(!H&&(g!=null&&g.length)){const v=Date.parse(g);if(v){const L=v-Date.now();L>0&&_e(L)}}return P}}function tt(){u&&A&&F===m.VERIFIED?ie():we(m.EXPIRED,f.expired)}async function qt(i){let a=null;if("Worker"in window){try{a=await Zt(i.challenge,i.salt,i.algorithm,i.maxnumber)}catch(g){E(g)}if((a==null?void 0:a.number)!==void 0)return{data:i,solution:a}}return{data:i,solution:await jt(i.challenge,i.salt,i.algorithm,i.maxnumber||x).promise}}async function Zt(i,a,g,R=typeof _=="number"?_:x,P=Math.ceil(ue)){const M=[];P=Math.min(16,Math.max(1,P));for(let L=0;L{const ae=Re*G;return new Promise(ye=>{L.addEventListener("message",ve=>{if(ve.data)for(const he of M)he!==L&&he.postMessage({type:"abort"});ye(ve.data)}),L.postMessage({payload:{alg:g,challenge:i,max:ae+G,salt:a,start:ae},type:"work"})})}));for(const L of M)L.terminate();return v.find(L=>!!L)||null}function Yt(){[m.UNVERIFIED,m.ERROR,m.EXPIRED].includes(F)?y&&(b==null?void 0:b.reportValidity())===!1?t(7,K=!1):ie():t(7,K=!0)}function nt(i){const a=i.target;p&&a&&!C.contains(a)&&F===m.VERIFIED&&t(8,C.style.display="none",C)}function it(){p&&Ae()}function rt(){F===m.VERIFYING&&f.waitAlert&&alert(f.waitAlert)}function Gt(i){p&&F!==m.UNVERIFIED&&requestAnimationFrame(()=>{Ae()})}function ot(){p&&Ae()}function _e(i){E("expire",i),Y&&(clearTimeout(Y),Y=null),i<1?tt():Y=setTimeout(tt,i)}function lt(i){E("floating",i),p!==i&&(t(8,C.style.left="",C),t(8,C.style.top="",C)),t(1,p=i===!0||i===""?"auto":i===!1||i==="false"?void 0:p),p?(c||t(0,c="onsubmit"),document.addEventListener("scroll",it),document.addEventListener("click",nt),window.addEventListener("resize",ot)):c==="onsubmit"&&t(0,c=void 0)}function Wt(i){var g;const a=b==null?void 0:b.querySelector(typeof i=="string"?`input[name="${i}"]`:'input[type="email"]:not([data-no-spamfilter])');return((g=a==null?void 0:a.value)==null?void 0:g.slice(a.value.indexOf("@")))||void 0}function Xt(i){return[...(b==null?void 0:b.querySelectorAll(i!=null&&i.length?i.map(g=>`input[name="${g}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((g,R)=>{const P=R.name,M=R.value;return P&&M&&(g[P]=/\n/.test(M)?M.replace(new RegExp("(?P:p==="top",v=Math.max(i,Math.min(M-i-R.width,g.left+g.width/2-R.width/2));if(G?t(8,C.style.top=`${g.top-(R.height+a)}px`,C):t(8,C.style.top=`${g.bottom+a}px`,C),t(8,C.style.left=`${v}px`,C),C.setAttribute("data-floating",G?"top":"bottom"),te){const L=te.getBoundingClientRect();t(9,te.style.left=g.left-v+g.width/2-L.width/2+"px",te)}}else E("unable to find floating anchor element")}function st(i){i.auto!==void 0&&(t(0,c=i.auto),c==="onload"&&ie()),i.floatinganchor!==void 0&&t(19,z=i.floatinganchor),i.delay!==void 0&&t(17,Z=i.delay),i.floatingoffset!==void 0&&t(20,S=i.floatingoffset),i.floating!==void 0&<(i.floating),i.expire!==void 0&&(_e(i.expire),t(18,H=i.expire)),i.challenge&&(et(i.challenge),o=i.challenge),i.challengeurl!==void 0&&t(15,u=i.challengeurl),i.debug!==void 0&&t(16,T=!!i.debug),i.hidefooter!==void 0&&t(2,Q=!!i.hidefooter),i.hidelogo!==void 0&&t(3,X=!!i.hidelogo),i.maxnumber!==void 0&&t(21,x=+i.maxnumber),i.mockerror!==void 0&&t(22,I=!!i.mockerror),i.name!==void 0&&t(4,V=i.name),i.refetchonexpire!==void 0&&t(23,A=!!i.refetchonexpire),i.spamfilter!==void 0&&t(24,y=typeof i.spamfilter=="object"?i.spamfilter:!!i.spamfilter),i.strings&&t(35,l=i.strings),i.test!==void 0&&t(25,_=typeof i.test=="number"?i.test:!!i.test),i.verifyurl!==void 0&&t(26,ee=i.verifyurl),i.workers!==void 0&&t(27,ue=+i.workers),i.workerurl!==void 0&&t(28,me=i.workerurl)}function we(i=m.UNVERIFIED,a=null){Y&&(clearTimeout(Y),Y=null),t(7,K=!1),t(10,Ie=a),t(5,ne=null),t(6,F=i)}async function ie(){return we(m.VERIFYING),await new Promise(i=>setTimeout(i,Z||0)),Ut().then(i=>(et(i),E("challenge",i),qt(i))).then(({data:i,solution:a})=>{if(E("solution",a),(a==null?void 0:a.number)!==void 0){if(ee)return Jt(Qe(i,a));t(5,ne=Qe(i,a)),E("payload",ne)}else throw E("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{yt().then(()=>{t(6,F=m.VERIFIED),t(7,K=!0),E("verified"),Le("verified",{payload:ne})})}).catch(i=>{E(i),t(6,F=m.ERROR),t(7,K=!1),t(10,Ie=i.message)})}function Kt(){K=this.checked,t(7,K)}function Qt(i){de[i?"unshift":"push"](()=>{te=i,t(9,te)})}function en(i){de[i?"unshift":"push"](()=>{C=i,t(8,C)})}return n.$$set=i=>{"auto"in i&&t(0,c=i.auto),"blockspam"in i&&t(29,h=i.blockspam),"challengeurl"in i&&t(15,u=i.challengeurl),"challengejson"in i&&t(30,B=i.challengejson),"debug"in i&&t(16,T=i.debug),"delay"in i&&t(17,Z=i.delay),"expire"in i&&t(18,H=i.expire),"floating"in i&&t(1,p=i.floating),"floatinganchor"in i&&t(19,z=i.floatinganchor),"floatingoffset"in i&&t(20,S=i.floatingoffset),"hidefooter"in i&&t(2,Q=i.hidefooter),"hidelogo"in i&&t(3,X=i.hidelogo),"name"in i&&t(4,V=i.name),"maxnumber"in i&&t(21,x=i.maxnumber),"mockerror"in i&&t(22,I=i.mockerror),"refetchonexpire"in i&&t(23,A=i.refetchonexpire),"spamfilter"in i&&t(24,y=i.spamfilter),"strings"in i&&t(31,d=i.strings),"test"in i&&t(25,_=i.test),"verifyurl"in i&&t(26,ee=i.verifyurl),"workers"in i&&t(27,ue=i.workers),"workerurl"in i&&t(28,me=i.workerurl)},n.$$.update=()=>{n.$$.dirty[0]&32768&&t(12,r=!!(u!=null&&u.includes(".altcha.org"))&&!!(u!=null&&u.includes("apiKey=ckey_"))),n.$$.dirty[0]&1073741824&&(o=B?Ye(B):void 0),n.$$.dirty[1]&1&&t(35,l=d?Ye(d):{}),n.$$.dirty[1]&16&&t(11,f={ariaLinkLabel:qe,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),n.$$.dirty[0]&96&&Le("statechange",{payload:ne,state:F}),n.$$.dirty[0]&64&&Gt()},[c,p,Q,X,V,ne,F,K,C,te,Ie,f,r,Yt,rt,u,T,Z,H,z,S,x,I,A,y,_,ee,ue,me,h,B,d,st,we,ie,l,Kt,Qt,en]}class Ge extends Rt{constructor(e){super(),It(this,e,Bt,Ht,ut,{auto:0,blockspam:29,challengeurl:15,challengejson:30,debug:16,delay:17,expire:18,floating:1,floatinganchor:19,floatingoffset:20,hidefooter:2,hidelogo:3,name:4,maxnumber:21,mockerror:22,refetchonexpire:23,spamfilter:24,strings:31,test:25,verifyurl:26,workers:27,workerurl:28,configure:32,reset:33,verify:34},null,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[29]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[15]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[30]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[16]}set debug(e){this.$$set({debug:e}),w()}get delay(){return this.$$.ctx[17]}set delay(e){this.$$set({delay:e}),w()}get expire(){return this.$$.ctx[18]}set expire(e){this.$$set({expire:e}),w()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),w()}get floatinganchor(){return this.$$.ctx[19]}set floatinganchor(e){this.$$set({floatinganchor:e}),w()}get floatingoffset(){return this.$$.ctx[20]}set floatingoffset(e){this.$$set({floatingoffset:e}),w()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),w()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),w()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),w()}get maxnumber(){return this.$$.ctx[21]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[22]}set mockerror(e){this.$$set({mockerror:e}),w()}get refetchonexpire(){return this.$$.ctx[23]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[24]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[31]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[25]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[26]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[27]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[28]}set workerurl(e){this.$$set({workerurl:e}),w()}get configure(){return this.$$.ctx[32]}get reset(){return this.$$.ctx[33]}get verify(){return this.$$.ctx[34]}}customElements.define("altcha-widget",At(Ge,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=n=>new Worker(new URL(n||"./worker.js",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:D&&D.src||new URL("altcha.umd.cjs",document.baseURI).href)),O.Altcha=Ge,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})}); +(function(m,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(m=typeof globalThis<"u"?globalThis:m||self,v(m.altcha={}))})(this,function(m){"use strict";var kn=Object.defineProperty;var Lt=m=>{throw TypeError(m)};var pn=(m,v,A)=>v in m?kn(m,v,{enumerable:!0,configurable:!0,writable:!0,value:A}):m[v]=A;var j=(m,v,A)=>pn(m,typeof v!="symbol"?v+"":v,A),It=(m,v,A)=>v.has(m)||Lt("Cannot "+A);var $=(m,v,A)=>(It(m,v,"read from private field"),A?A.call(m):v.get(m)),le=(m,v,A)=>v.has(m)?Lt("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(m):v.set(m,A),xt=(m,v,A,de)=>(It(m,v,"write to private field"),de?de.call(m,A):v.set(m,A),A);var ue,he,we,_e,ye,ve;var v=typeof document<"u"?document.currentScript:null;function A(){}function de(i){return i()}function He(){return Object.create(null)}function ge(i){i.forEach(de)}function $e(i){return typeof i=="function"}function Tt(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Rt(i){return Object.keys(i).length===0}function L(i,e){i.appendChild(e)}function V(i,e,t){i.insertBefore(e,t||null)}function D(i){i.parentNode&&i.parentNode.removeChild(i)}function R(i){return document.createElement(i)}function z(i){return document.createElementNS("http://www.w3.org/2000/svg",i)}function qe(i){return document.createTextNode(i)}function K(){return qe(" ")}function Ft(){return qe("")}function De(i,e,t,r){return i.addEventListener(e,t,r),()=>i.removeEventListener(e,t,r)}function f(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function St(i){return Array.from(i.childNodes)}function Ze(i,e,t){i.classList.toggle(e,!!t)}function Mt(i,e,{bubbles:t=!1,cancelable:r=!1}={}){return new CustomEvent(i,{detail:e,bubbles:t,cancelable:r})}function Dt(i){const e={};return i.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let me;function be(i){me=i}function Ne(){if(!me)throw new Error("Function called outside component initialization");return me}function Nt(i){Ne().$$.on_mount.push(i)}function jt(i){Ne().$$.on_destroy.push(i)}function Vt(){const i=Ne();return(e,t,{cancelable:r=!1}={})=>{const o=i.$$.callbacks[e];if(o){const s=Mt(e,t,{cancelable:r});return o.slice().forEach(u=>{u.call(i,s)}),!s.defaultPrevented}return!0}}const fe=[],Ce=[];let ae=[];const Ye=[],Ge=Promise.resolve();let je=!1;function Je(){je||(je=!0,Ge.then(k))}function Ut(){return Je(),Ge}function Ve(i){ae.push(i)}const Ue=new Set;let ce=0;function k(){if(ce!==0)return;const i=me;do{try{for(;cei.indexOf(r)===-1?e.push(r):t.push(r)),t.forEach(r=>r()),ae=e}const Ot=new Set;function Ht(i,e){i&&i.i&&(Ot.delete(i),i.i(e))}function $t(i,e,t){const{fragment:r,after_update:o}=i.$$;r&&r.m(e,t),Ve(()=>{const s=i.$$.on_mount.map(de).filter($e);i.$$.on_destroy?i.$$.on_destroy.push(...s):ge(s),i.$$.on_mount=[]}),o.forEach(Ve)}function qt(i,e){const t=i.$$;t.fragment!==null&&(Bt(t.after_update),ge(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Zt(i,e){i.$$.dirty[0]===-1&&(fe.push(i),Je(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<{const G=Y.length?Y[0]:Z;return c.ctx&&o(c.ctx[w],c.ctx[w]=G)&&(!c.skip_bound&&c.bound[w]&&c.bound[w](G),q&&Zt(i,w)),Z}):[],c.update(),q=!0,ge(c.before_update),c.fragment=r?r(c.ctx):!1,e.target){if(e.hydrate){const w=St(e.target);c.fragment&&c.fragment.l(w),w.forEach(D)}else c.fragment&&c.fragment.c();e.intro&&Ht(i.$$.fragment),$t(i,e.target,e.anchor),k()}be(l)}let Xe;typeof HTMLElement=="function"&&(Xe=class extends HTMLElement{constructor(e,t,r){super();j(this,"$$ctor");j(this,"$$s");j(this,"$$c");j(this,"$$cn",!1);j(this,"$$d",{});j(this,"$$r",!1);j(this,"$$p_d",{});j(this,"$$l",{});j(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,r&&this.attachShadow({mode:"open"})}addEventListener(e,t,r){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,r)}removeEventListener(e,t,r){if(super.removeEventListener(e,t,r),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(s){return()=>{let u;return{c:function(){u=R("slot"),s!=="default"&&f(u,"name",s)},m:function(c,q){V(c,u,q)},d:function(c){c&&D(u)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},r=Dt(this);for(const s of this.$$s)s in r&&(t[s]=[e(s)]);for(const s of this.attributes){const u=this.$$g_p(s.name);u in this.$$d||(this.$$d[u]=Ae(u,s.value,this.$$p_d,"toProp"))}for(const s in this.$$p_d)!(s in this.$$d)&&this[s]!==void 0&&(this.$$d[s]=this[s],delete this[s]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const s in this.$$p_d)if(this.$$d[s]=this.$$c.$$.ctx[this.$$c.$$.props[s]],this.$$p_d[s].reflect){const u=Ae(s,this.$$d[s],this.$$p_d,"toAttribute");u==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,u)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const s in this.$$l)for(const u of this.$$l[s]){const a=this.$$c.$on(s,u);this.$$l_u.set(u,a)}this.$$l={}}}attributeChangedCallback(e,t,r){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Ae(e,r,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Ae(i,e,t,r){var s;const o=(s=t[i])==null?void 0:s.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!r||!t[i])return e;if(r==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Gt(i,e,t,r,o,s){let u=class extends Xe{constructor(){super(i,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(u.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(l){var c;l=Ae(a,l,e),this.$$d[a]=l,(c=this.$$c)==null||c.$set({[a]:l})}})}),r.forEach(a=>{Object.defineProperty(u.prototype,a,{get(){var l;return(l=this.$$c)==null?void 0:l[a]}})}),i.element=u,u}class Jt{constructor(){j(this,"$$");j(this,"$$set")}$destroy(){qt(this,1),this.$destroy=A}$on(e,t){if(!$e(t))return A;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(t),()=>{const o=r.indexOf(t);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!Rt(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Xt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Xt);const Wt=new TextEncoder;function zt(i){return[...new Uint8Array(i)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Kt(i,e="SHA-256",t=1e5){const r=Date.now().toString(16);i||(i=Math.round(Math.random()*t));const o=await We(r,i,e);return{algorithm:e,challenge:o,salt:r,signature:""}}async function We(i,e,t){return zt(await crypto.subtle.digest(t.toUpperCase(),Wt.encode(i+e)))}function Qt(i,e,t="SHA-256",r=1e6,o=0){const s=new AbortController,u=Date.now();return{promise:(async()=>{for(let l=o;l<=r;l+=1){if(s.signal.aborted)return null;if(await We(e,l,t)===i)return{number:l,took:Date.now()-u}}return null})(),controller:s}}function ze(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}class en{constructor(e){j(this,"beaconUrl",null);j(this,"error",null);j(this,"loadTime",Date.now());j(this,"submitTime",null);j(this,"startTime",null);j(this,"viewTimeThresholdMs",1500);le(this,ue,{});le(this,he,null);le(this,we,this.onFormChange.bind(this));le(this,_e,this.onFormFocus.bind(this));le(this,ye,this.onFormSubmit.bind(this));le(this,ve,this.onUnload.bind(this));this.elForm=e,window.addEventListener("unload",$(this,ve)),this.elForm.addEventListener("change",$(this,we)),this.elForm.addEventListener("focusin",$(this,_e)),this.elForm.addEventListener("submit",$(this,ye))}data(){const e=Object.entries($(this,ue));return{correction:e.length&&e.filter(([t,r])=>r>1).length/e.length||0,dropoff:!this.submitTime&&!this.error&&$(this,he)?$(this,he):null,error:this.error,mobile:this.isMobile(),start:this.startTime,submit:this.submitTime,tz:ze()}}dataAsBase64(){try{return btoa(JSON.stringify(this.data()))}catch(e){console.error("failed to encode ALTCHA session data to base64",e)}return""}destroy(){window.removeEventListener("unload",$(this,ve)),this.elForm.removeEventListener("change",$(this,we)),this.elForm.removeEventListener("focusin",$(this,_e)),this.elForm.removeEventListener("submit",$(this,ye))}end(){this.submitTime||(this.submitTime=Date.now())}getFieldName(e,t=40){const r=e.getAttribute("data-group-label"),o=e.getAttribute("name")||e.getAttribute("aria-label");return((r?r+": ":"")+o).slice(0,t)}isMobile(){const e="userAgentData"in navigator&&navigator.userAgentData?navigator.userAgentData:{};return"mobile"in e?e.mobile===!0:/Mobi/i.test(window.navigator.userAgent)}isInput(e){return["INPUT","SELECT","TEXTAREA"].includes(e.tagName)}onFormFieldChange(e){const t=this.getFieldName(e);t&&this.trackFieldChange(t)}onFormChange(e){const t=e.target;t&&this.isInput(t)&&this.onFormFieldChange(t)}onFormFocus(e){const t=e.target;if(this.startTime||this.start(),t&&this.isInput(t)){const r=this.getFieldName(t);r&&xt(this,he,r)}}onFormSubmit(){this.end()}onUnload(){this.loadTime<=Date.now()-this.viewTimeThresholdMs&&!this.submitTime&&this.sendBeacon()}async sendBeacon(){if(this.beaconUrl&&"sendBeacon"in navigator)try{navigator.sendBeacon(new URL(this.beaconUrl,location.origin),JSON.stringify(this.data()))}catch{}}start(){this.startTime=Date.now()}trackError(e){this.error=e===null?null:String(e)}trackFieldChange(e){$(this,ue)[e]=($(this,ue)[e]||0)+1}}ue=new WeakMap,he=new WeakMap,we=new WeakMap,_e=new WeakMap,ye=new WeakMap,ve=new WeakMap;var b=(i=>(i.ERROR="error",i.VERIFIED="verified",i.VERIFYING="verifying",i.UNVERIFIED="unverified",i.EXPIRED="expired",i))(b||{});function Ke(i){let e,t,r;return{c(){e=z("svg"),t=z("path"),r=z("path"),f(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),f(t,"fill","currentColor"),f(t,"opacity",".25"),f(r,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),f(r,"fill","currentColor"),f(r,"class","altcha-spinner"),f(e,"width","24"),f(e,"height","24"),f(e,"viewBox","0 0 24 24"),f(e,"xmlns","http://www.w3.org/2000/svg")},m(o,s){V(o,e,s),L(e,t),L(e,r)},d(o){o&&D(e)}}}function tn(i){let e,t=i[13].label+"",r;return{c(){e=R("label"),f(e,"for",r=i[4]+"_checkbox")},m(o,s){V(o,e,s),e.innerHTML=t},p(o,s){s[0]&8192&&t!==(t=o[13].label+"")&&(e.innerHTML=t),s[0]&16&&r!==(r=o[4]+"_checkbox")&&f(e,"for",r)},d(o){o&&D(e)}}}function nn(i){let e,t=i[13].verifying+"";return{c(){e=R("span")},m(r,o){V(r,e,o),e.innerHTML=t},p(r,o){o[0]&8192&&t!==(t=r[13].verifying+"")&&(e.innerHTML=t)},d(r){r&&D(e)}}}function rn(i){let e,t=i[13].verified+"",r,o,s,u,a=i[11]&&Qe(i);return{c(){e=R("span"),r=K(),o=R("input"),s=K(),a&&a.c(),u=Ft(),f(o,"type","hidden"),f(o,"name",i[4]),o.value=i[6]},m(l,c){V(l,e,c),e.innerHTML=t,V(l,r,c),V(l,o,c),V(l,s,c),a&&a.m(l,c),V(l,u,c)},p(l,c){c[0]&8192&&t!==(t=l[13].verified+"")&&(e.innerHTML=t),c[0]&16&&f(o,"name",l[4]),c[0]&64&&(o.value=l[6]),l[11]?a?a.p(l,c):(a=Qe(l),a.c(),a.m(u.parentNode,u)):a&&(a.d(1),a=null)},d(l){l&&(D(e),D(r),D(o),D(s),D(u)),a&&a.d(l)}}}function Qe(i){let e;return{c(){e=R("input"),f(e,"type","hidden"),f(e,"name","__session"),e.value=i[12]},m(t,r){V(t,e,r)},p(t,r){r[0]&4096&&(e.value=t[12])},d(t){t&&D(e)}}}function et(i){let e,t,r,o,s,u,a;return{c(){e=R("div"),t=R("a"),r=z("svg"),o=z("path"),s=z("path"),u=z("path"),f(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),f(o,"fill","currentColor"),f(s,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),f(s,"fill","currentColor"),f(u,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),f(u,"fill","currentColor"),f(r,"width","22"),f(r,"height","22"),f(r,"viewBox","0 0 20 20"),f(r,"fill","none"),f(r,"xmlns","http://www.w3.org/2000/svg"),f(t,"href",ot),f(t,"target","_blank"),f(t,"class","altcha-logo"),f(t,"aria-label",a=i[13].ariaLinkLabel)},m(l,c){V(l,e,c),L(e,t),L(t,r),L(r,o),L(r,s),L(r,u)},p(l,c){c[0]&8192&&a!==(a=l[13].ariaLinkLabel)&&f(t,"aria-label",a)},d(l){l&&D(e)}}}function tt(i){let e,t,r,o;function s(l,c){return l[7]===b.EXPIRED?sn:on}let u=s(i),a=u(i);return{c(){e=R("div"),t=z("svg"),r=z("path"),o=K(),a.c(),f(r,"stroke-linecap","round"),f(r,"stroke-linejoin","round"),f(r,"d","M6 18L18 6M6 6l12 12"),f(t,"width","14"),f(t,"height","14"),f(t,"xmlns","http://www.w3.org/2000/svg"),f(t,"fill","none"),f(t,"viewBox","0 0 24 24"),f(t,"stroke-width","1.5"),f(t,"stroke","currentColor"),f(e,"class","altcha-error")},m(l,c){V(l,e,c),L(e,t),L(t,r),L(e,o),a.m(e,null)},p(l,c){u===(u=s(l))&&a?a.p(l,c):(a.d(1),a=u(l),a&&(a.c(),a.m(e,null)))},d(l){l&&D(e),a.d()}}}function on(i){let e,t=i[13].error+"";return{c(){e=R("div"),f(e,"title",i[5])},m(r,o){V(r,e,o),e.innerHTML=t},p(r,o){o[0]&8192&&t!==(t=r[13].error+"")&&(e.innerHTML=t),o[0]&32&&f(e,"title",r[5])},d(r){r&&D(e)}}}function sn(i){let e,t=i[13].expired+"";return{c(){e=R("div"),f(e,"title",i[5])},m(r,o){V(r,e,o),e.innerHTML=t},p(r,o){o[0]&8192&&t!==(t=r[13].expired+"")&&(e.innerHTML=t),o[0]&32&&f(e,"title",r[5])},d(r){r&&D(e)}}}function nt(i){let e,t,r=i[13].footer+"";return{c(){e=R("div"),t=R("div"),f(e,"class","altcha-footer")},m(o,s){V(o,e,s),L(e,t),t.innerHTML=r},p(o,s){s[0]&8192&&r!==(r=o[13].footer+"")&&(t.innerHTML=r)},d(o){o&&D(e)}}}function it(i){let e;return{c(){e=R("div"),f(e,"class","altcha-anchor-arrow")},m(t,r){V(t,e,r),i[41](e)},p:A,d(t){t&&D(e),i[41](null)}}}function ln(i){let e,t,r,o,s,u,a,l,c,q,w,Z,Y,G,Q,_=i[7]===b.VERIFYING&&Ke();function te(d,p){return d[7]===b.VERIFIED?rn:d[7]===b.VERIFYING?nn:tn}let ee=te(i),P=ee(i),F=(i[3]!==!0||i[14])&&et(i),N=(i[5]||i[7]===b.EXPIRED)&&tt(i),I=i[13].footer&&(i[2]!==!0||i[14])&&nt(i),S=i[1]&&it(i);return{c(){e=R("div"),t=R("div"),_&&_.c(),r=K(),o=R("div"),s=R("input"),l=K(),c=R("div"),P.c(),q=K(),F&&F.c(),w=K(),N&&N.c(),Z=K(),I&&I.c(),Y=K(),S&&S.c(),f(s,"type","checkbox"),f(s,"id",u=i[4]+"_checkbox"),s.required=a=i[0]!=="onsubmit",f(o,"class","altcha-checkbox"),Ze(o,"altcha-hidden",i[7]===b.VERIFYING),f(c,"class","altcha-label"),f(t,"class","altcha-main"),f(e,"class","altcha"),f(e,"data-state",i[7]),f(e,"data-floating",i[1])},m(d,p){V(d,e,p),L(e,t),_&&_.m(t,null),L(t,r),L(t,o),L(o,s),s.checked=i[8],L(t,l),L(t,c),P.m(c,null),L(t,q),F&&F.m(t,null),L(e,w),N&&N.m(e,null),L(e,Z),I&&I.m(e,null),L(e,Y),S&&S.m(e,null),i[42](e),G||(Q=[De(s,"change",i[40]),De(s,"change",i[15]),De(s,"invalid",i[16])],G=!0)},p(d,p){d[7]===b.VERIFYING?_||(_=Ke(),_.c(),_.m(t,r)):_&&(_.d(1),_=null),p[0]&16&&u!==(u=d[4]+"_checkbox")&&f(s,"id",u),p[0]&1&&a!==(a=d[0]!=="onsubmit")&&(s.required=a),p[0]&256&&(s.checked=d[8]),p[0]&128&&Ze(o,"altcha-hidden",d[7]===b.VERIFYING),ee===(ee=te(d))&&P?P.p(d,p):(P.d(1),P=ee(d),P&&(P.c(),P.m(c,null))),d[3]!==!0||d[14]?F?F.p(d,p):(F=et(d),F.c(),F.m(t,null)):F&&(F.d(1),F=null),d[5]||d[7]===b.EXPIRED?N?N.p(d,p):(N=tt(d),N.c(),N.m(e,Z)):N&&(N.d(1),N=null),d[13].footer&&(d[2]!==!0||d[14])?I?I.p(d,p):(I=nt(d),I.c(),I.m(e,Y)):I&&(I.d(1),I=null),d[1]?S?S.p(d,p):(S=it(d),S.c(),S.m(e,null)):S&&(S.d(1),S=null),p[0]&128&&f(e,"data-state",d[7]),p[0]&2&&f(e,"data-floating",d[1])},i:A,o:A,d(d){d&&D(e),_&&_.d(),P.d(),F&&F.d(),N&&N.d(),I&&I.d(),S&&S.d(),i[42](null),G=!1,ge(Q)}}}const rt="Visit Altcha.org",ot="https://altcha.org/";function st(i){return JSON.parse(i)}function fn(i,e,t){var Ct,At;let r,o,s,u,{analytics:a=!1}=e,{auto:l=void 0}=e,{beaconurl:c=void 0}=e,{blockspam:q=void 0}=e,{challengeurl:w=void 0}=e,{challengejson:Z=void 0}=e,{debug:Y=!1}=e,{delay:G=0}=e,{expire:Q=void 0}=e,{floating:_=void 0}=e,{floatinganchor:te=void 0}=e,{floatingoffset:ee=void 0}=e,{hidefooter:P=!1}=e,{hidelogo:F=!1}=e,{name:N="altcha"}=e,{maxnumber:I=1e6}=e,{mockerror:S=!1}=e,{refetchonexpire:d=!0}=e,{spamfilter:p=!1}=e,{strings:Le=void 0}=e,{test:J=!1}=e,{verifyurl:ie=void 0}=e,{workers:Ee=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:Ie=void 0}=e;const Pe=Vt(),ft=["SHA-256","SHA-384","SHA-512"],at=(At=(Ct=document.documentElement.lang)==null?void 0:Ct.split("-"))==null?void 0:At[0];let ne=!1,x,re=null,xe=null,g=null,Te=null,X=null,oe=null,B=null,ct=null,O=b.UNVERIFIED;jt(()=>{g&&(g.removeEventListener("submit",ht),g.removeEventListener("reset",dt),g.removeEventListener("focusin",ut),g=null),B&&B.destroy(),X&&(clearTimeout(X),X=null),document.removeEventListener("click",_t),document.removeEventListener("scroll",yt),window.removeEventListener("resize",Et)}),Nt(()=>{C("mounted","0.7.0"),C("workers",Ee),J&&C("using test mode"),Q&&Re(Q),l!==void 0&&C("auto",l),_!==void 0&&kt(_),g=x.closest("form"),g&&(g.addEventListener("submit",ht,{capture:!0}),g.addEventListener("reset",dt),l==="onfocus"&&g.addEventListener("focusin",ut)),a&&bt(),l==="onload"&&se(),r&&(P||F)&&C("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.")});function C(...n){(Y||n.some(h=>h instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function ut(n){O===b.UNVERIFIED&&se()}function ht(n){g&&B&&O===b.VERIFIED&&(B.end(),t(12,ct=B.dataAsBase64())),g&&l==="onsubmit"&&(O===b.UNVERIFIED?(n.preventDefault(),n.stopPropagation(),se().then(()=>{g==null||g.requestSubmit()})):O!==b.VERIFIED&&(n.preventDefault(),n.stopPropagation(),O===b.VERIFYING&&vt()))}function dt(){Fe()}function gt(n,h){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:h.number,salt:n.salt,signature:n.signature,test:J?!0:void 0,took:h.took}))}function mt(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!ft.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${ft.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function an(){var n;if(S)throw C("mocking error"),new Error("Mocked error.");if(o)return C("using provided json data"),o;if(J)return C("generating test challenge",{test:J}),Kt(typeof J!="boolean"?+J:void 0);{if(!w&&g){const E=g.getAttribute("action");E!=null&&E.includes("/form/")&&t(17,w=E+"/altcha")}if(!w)throw new Error("Attribute challengeurl not set.");C("fetching challenge from",w);const h=await fetch(w,{headers:p?{"x-altcha-spam-filter":"1"}:{}});if(h.status!==200)throw new Error(`Server responded with ${h.status}.`);const y=h.headers.get("Expires"),M=h.headers.get("X-Altcha-Config"),H=await h.json(),U=new URLSearchParams((n=H.salt.split("?"))==null?void 0:n[1]),W=U.get("expires")||U.get("expire");if(W){const E=new Date(+W*1e3),T=isNaN(E.getTime())?0:E.getTime()-Date.now();T>0&&Re(T)}if(M)try{const E=JSON.parse(M);E&&typeof E=="object"&&(E.verifyurl&&(E.verifyurl=new URL(E.verifyurl,new URL(w)).toString()),pt(E))}catch(E){C("unable to configure from X-Altcha-Config",E)}if(!Q&&(y!=null&&y.length)){const E=Date.parse(y);if(E){const T=E-Date.now();T>0&&Re(T)}}return H}}function bt(){if(!B)if(g){if(C("analytics enabled"),t(11,B=new en(g)),c===void 0){const n=g.getAttribute("action");n&&t(19,c=n+"/beacon")}t(11,B.beaconUrl=c||null,B)}else C("analytics cannot be enabled - form element not found")}function wt(){w&&d&&O===b.VERIFIED?se():Fe(b.EXPIRED,u.expired)}async function cn(n){let h=null;if("Worker"in window){try{h=await un(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(y){C(y)}if((h==null?void 0:h.number)!==void 0)return{data:n,solution:h}}return{data:n,solution:await Qt(n.challenge,n.salt,n.algorithm,n.maxnumber||I).promise}}async function un(n,h,y,M=typeof J=="number"?J:I,H=Math.ceil(Ee)){const U=[];H=Math.min(16,Math.max(1,H));for(let T=0;T{const ke=Oe*W;return new Promise(Se=>{T.addEventListener("message",Me=>{if(Me.data)for(const pe of U)pe!==T&&pe.postMessage({type:"abort"});Se(Me.data)}),T.postMessage({payload:{alg:y,challenge:n,max:ke+W,salt:h,start:ke},type:"work"})})}));for(const T of U)T.terminate();return E.find(T=>!!T)||null}function hn(){[b.UNVERIFIED,b.ERROR,b.EXPIRED].includes(O)?p&&(g==null?void 0:g.reportValidity())===!1?t(8,ne=!1):se():t(8,ne=!0)}function _t(n){const h=n.target;_&&h&&!x.contains(h)&&O===b.VERIFIED&&t(9,x.style.display="none",x)}function yt(){_&&Be()}function vt(){O===b.VERIFYING&&u.waitAlert&&alert(u.waitAlert)}function dn(n){B&&B.trackError(Te)}function gn(n){_&&O!==b.UNVERIFIED&&requestAnimationFrame(()=>{Be()})}function Et(){_&&Be()}function Re(n){C("expire",n),X&&(clearTimeout(X),X=null),n<1?wt():X=setTimeout(wt,n)}function kt(n){C("floating",n),_!==n&&(t(9,x.style.left="",x),t(9,x.style.top="",x)),t(1,_=n===!0||n===""?"auto":n===!1||n==="false"?void 0:_),_?(l||t(0,l="onsubmit"),document.addEventListener("scroll",yt),document.addEventListener("click",_t),window.addEventListener("resize",Et)):l==="onsubmit"&&t(0,l=void 0)}function mn(n){var y;const h=g==null?void 0:g.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((y=h==null?void 0:h.value)==null?void 0:y.slice(h.value.indexOf("@")))||void 0}function bn(n){return[...(g==null?void 0:g.querySelectorAll(n!=null&&n.length?n.map(y=>`input[name="${y}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((y,M)=>{const H=M.name,U=M.value;return H&&U&&(y[H]=/\n/.test(U)?U.replace(new RegExp("(?H:_==="top",E=Math.max(n,Math.min(U-n-M.width,y.left+y.width/2-M.width/2));if(W?t(9,x.style.top=`${y.top-(M.height+h)}px`,x):t(9,x.style.top=`${y.bottom+h}px`,x),t(9,x.style.left=`${E}px`,x),x.setAttribute("data-floating",W?"top":"bottom"),re){const T=re.getBoundingClientRect();t(10,re.style.left=y.left-E+y.width/2-T.width/2+"px",re)}}else C("unable to find floating anchor element")}function pt(n){n.analytics&&(t(18,a=n.analytics),bt()),n.auto!==void 0&&(t(0,l=n.auto),l==="onload"&&se()),n.beaconurl&&(t(19,c=n.beaconurl),B&&t(11,B.beaconUrl=c,B)),n.floatinganchor!==void 0&&t(23,te=n.floatinganchor),n.delay!==void 0&&t(21,G=n.delay),n.floatingoffset!==void 0&&t(24,ee=n.floatingoffset),n.floating!==void 0&&kt(n.floating),n.expire!==void 0&&(Re(n.expire),t(22,Q=n.expire)),n.challenge&&(mt(n.challenge),o=n.challenge),n.challengeurl!==void 0&&t(17,w=n.challengeurl),n.debug!==void 0&&t(20,Y=!!n.debug),n.hidefooter!==void 0&&t(2,P=!!n.hidefooter),n.hidelogo!==void 0&&t(3,F=!!n.hidelogo),n.maxnumber!==void 0&&t(25,I=+n.maxnumber),n.mockerror!==void 0&&t(26,S=!!n.mockerror),n.name!==void 0&&t(4,N=n.name),n.refetchonexpire!==void 0&&t(27,d=!!n.refetchonexpire),n.spamfilter!==void 0&&t(28,p=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(39,s=n.strings),n.test!==void 0&&t(29,J=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(30,ie=n.verifyurl),n.workers!==void 0&&t(31,Ee=+n.workers),n.workerurl!==void 0&&t(32,Ie=n.workerurl)}function Fe(n=b.UNVERIFIED,h=null){X&&(clearTimeout(X),X=null),t(8,ne=!1),t(5,Te=h),t(6,oe=null),t(7,O=n)}async function se(){return Fe(b.VERIFYING),await new Promise(n=>setTimeout(n,G||0)),an().then(n=>(mt(n),C("challenge",n),cn(n))).then(({data:n,solution:h})=>{if(C("solution",h),(h==null?void 0:h.number)!==void 0){if(ie)return wn(gt(n,h));t(6,oe=gt(n,h)),C("payload",oe)}else throw C("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{Ut().then(()=>{t(7,O=b.VERIFIED),t(8,ne=!0),C("verified"),Pe("verified",{payload:oe})})}).catch(n=>{C(n),t(7,O=b.ERROR),t(8,ne=!1),t(5,Te=n.message)})}function yn(){ne=this.checked,t(8,ne)}function vn(n){Ce[n?"unshift":"push"](()=>{re=n,t(10,re)})}function En(n){Ce[n?"unshift":"push"](()=>{x=n,t(9,x)})}return i.$$set=n=>{"analytics"in n&&t(18,a=n.analytics),"auto"in n&&t(0,l=n.auto),"beaconurl"in n&&t(19,c=n.beaconurl),"blockspam"in n&&t(33,q=n.blockspam),"challengeurl"in n&&t(17,w=n.challengeurl),"challengejson"in n&&t(34,Z=n.challengejson),"debug"in n&&t(20,Y=n.debug),"delay"in n&&t(21,G=n.delay),"expire"in n&&t(22,Q=n.expire),"floating"in n&&t(1,_=n.floating),"floatinganchor"in n&&t(23,te=n.floatinganchor),"floatingoffset"in n&&t(24,ee=n.floatingoffset),"hidefooter"in n&&t(2,P=n.hidefooter),"hidelogo"in n&&t(3,F=n.hidelogo),"name"in n&&t(4,N=n.name),"maxnumber"in n&&t(25,I=n.maxnumber),"mockerror"in n&&t(26,S=n.mockerror),"refetchonexpire"in n&&t(27,d=n.refetchonexpire),"spamfilter"in n&&t(28,p=n.spamfilter),"strings"in n&&t(35,Le=n.strings),"test"in n&&t(29,J=n.test),"verifyurl"in n&&t(30,ie=n.verifyurl),"workers"in n&&t(31,Ee=n.workers),"workerurl"in n&&t(32,Ie=n.workerurl)},i.$$.update=()=>{i.$$.dirty[0]&131072&&t(14,r=!!(w!=null&&w.includes(".altcha.org"))&&!!(w!=null&&w.includes("apiKey=ckey_"))),i.$$.dirty[1]&8&&(o=Z?st(Z):void 0),i.$$.dirty[1]&16&&t(39,s=Le?st(Le):{}),i.$$.dirty[1]&256&&t(13,u={ariaLinkLabel:rt,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...s}),i.$$.dirty[0]&192&&Pe("statechange",{payload:oe,state:O}),i.$$.dirty[0]&32&&dn(),i.$$.dirty[0]&128&&gn()},[l,_,P,F,N,Te,oe,O,ne,x,re,B,ct,u,r,hn,vt,w,a,c,Y,G,Q,te,ee,I,S,d,p,J,ie,Ee,Ie,q,Z,Le,pt,Fe,se,s,yn,vn,En]}class lt extends Jt{constructor(e){super(),Yt(this,e,fn,ln,Tt,{analytics:18,auto:0,beaconurl:19,blockspam:33,challengeurl:17,challengejson:34,debug:20,delay:21,expire:22,floating:1,floatinganchor:23,floatingoffset:24,hidefooter:2,hidelogo:3,name:4,maxnumber:25,mockerror:26,refetchonexpire:27,spamfilter:28,strings:35,test:29,verifyurl:30,workers:31,workerurl:32,configure:36,reset:37,verify:38},null,[-1,-1,-1])}get analytics(){return this.$$.ctx[18]}set analytics(e){this.$$set({analytics:e}),k()}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),k()}get beaconurl(){return this.$$.ctx[19]}set beaconurl(e){this.$$set({beaconurl:e}),k()}get blockspam(){return this.$$.ctx[33]}set blockspam(e){this.$$set({blockspam:e}),k()}get challengeurl(){return this.$$.ctx[17]}set challengeurl(e){this.$$set({challengeurl:e}),k()}get challengejson(){return this.$$.ctx[34]}set challengejson(e){this.$$set({challengejson:e}),k()}get debug(){return this.$$.ctx[20]}set debug(e){this.$$set({debug:e}),k()}get delay(){return this.$$.ctx[21]}set delay(e){this.$$set({delay:e}),k()}get expire(){return this.$$.ctx[22]}set expire(e){this.$$set({expire:e}),k()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),k()}get floatinganchor(){return this.$$.ctx[23]}set floatinganchor(e){this.$$set({floatinganchor:e}),k()}get floatingoffset(){return this.$$.ctx[24]}set floatingoffset(e){this.$$set({floatingoffset:e}),k()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),k()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),k()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),k()}get maxnumber(){return this.$$.ctx[25]}set maxnumber(e){this.$$set({maxnumber:e}),k()}get mockerror(){return this.$$.ctx[26]}set mockerror(e){this.$$set({mockerror:e}),k()}get refetchonexpire(){return this.$$.ctx[27]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),k()}get spamfilter(){return this.$$.ctx[28]}set spamfilter(e){this.$$set({spamfilter:e}),k()}get strings(){return this.$$.ctx[35]}set strings(e){this.$$set({strings:e}),k()}get test(){return this.$$.ctx[29]}set test(e){this.$$set({test:e}),k()}get verifyurl(){return this.$$.ctx[30]}set verifyurl(e){this.$$set({verifyurl:e}),k()}get workers(){return this.$$.ctx[31]}set workers(e){this.$$set({workers:e}),k()}get workerurl(){return this.$$.ctx[32]}set workerurl(e){this.$$set({workerurl:e}),k()}get configure(){return this.$$.ctx[36]}get reset(){return this.$$.ctx[37]}get verify(){return this.$$.ctx[38]}}customElements.define("altcha-widget",Gt(lt,{analytics:{type:"Boolean"},auto:{},beaconurl:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=i=>new Worker(new URL(i||"./worker.js",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:v&&v.src||new URL("altcha.umd.cjs",document.baseURI).href)),m.Altcha=lt,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}); diff --git a/package-lock.json b/package-lock.json index ca4816c..e563331 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "altcha", - "version": "0.6.7", + "version": "0.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "altcha", - "version": "0.6.7", + "version": "0.7.0", "license": "MIT", "devDependencies": { "@playwright/test": "^1.44.1", diff --git a/package.json b/package.json index 0f88825..031fec5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "altcha", "description": "GDPR compliant, self-hosted CAPTCHA alternative.", - "version": "0.6.7", + "version": "0.7.0", "license": "MIT", "author": { "name": "Daniel Regeci", diff --git a/src/Altcha.svelte b/src/Altcha.svelte index 168f299..d6c6c5d 100644 --- a/src/Altcha.svelte +++ b/src/Altcha.svelte @@ -7,7 +7,8 @@