diff --git a/README.md b/README.md index 23080a2..3dc629c 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,15 @@ ALTCHA uses a proof-of-work mechanism to protect your website, APIs, and online services from spam and abuse. Unlike other solutions, ALTCHA is self-hosted, does not use cookies nor fingerprinting, does not track users, and is fully compliant with GDPR. -https://altcha.org +Visit [ALTCHA](https://altcha.org) for more information. -## Benefits +## Features -- __Friction-less__ - Using PoW instead of visual puzzles. -- __Cookie-less__ - GDPR compliant by design. -- __Self-hosted__ - Without reliance on external providers in self-hosted mode. -- __SaaS available__ - Visit [altcha.org](https://altcha.org/docs/api) to get started with the SaaS API. +- **Frictionless CAPTCHA Alternative** - Employs proof-of-work (PoW) instead of visual puzzles. +- **Data Obfuscation** - Safeguards your email address from scraping. +- **Cookie-less** - Designed to be GDPR compliant by default. +- **Self-hosted** - Operates independently without relying on external providers. +- **SaaS Available** - Get started with the SaaS API at [altcha.org/docs/api](https://altcha.org/docs/api). ## Examples @@ -105,8 +106,9 @@ Additional options: - __hidelogo__ - Hide the ALTCHA logo. - __maxnumber__ - The max. number to iterate to (defaults to 1,000,000). - __name__ - The name of the hidden field containing the payload (defaults to "altcha"). +- __obfuscated__ - The [obfuscated data](https://altcha.org/docs/obfuscation) provided as a base64-encoded string. Use only without `challengeurl`/`challengejson`. - __spamfilter__ - Enable [Spam Filter](#spam-filter). -- __strings__ - JSON-encoded translation strings. Refer to [customization](/docs/widget-customization). +- __strings__ - JSON-encoded translation strings. Refer to [customization](https://altcha.org/docs/widget-customization). - __refetchonexpire__ - Automatically re-fetch and re-validate when the challenge expires (defaults to true). - __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`). @@ -163,6 +165,7 @@ export interface Configure { maxnumber?: number; mockerror?: boolean; name?: string; + obfuscated?: string; refetchonexpire?: boolean; spamfilter?: boolean | 'ipAddress' | SpamFilter; strings?: { diff --git a/dist/altcha.d.ts b/dist/altcha.d.ts index 020d6e6..ef75e1e 100644 --- a/dist/altcha.d.ts +++ b/dist/altcha.d.ts @@ -16,7 +16,7 @@ declare global { interface AltchaServerVerificationEvent extends CustomEvent> {} - interface AltchaWidget { + interface AltchaWidgetOptions { analytics?: boolean | string; auto?: 'onfocus' | 'onload' | 'onsubmit'; beaconurl?: string; @@ -31,9 +31,10 @@ declare global { floatingoffset?: number; hidefooter?: boolean; hidelogo?: boolean; - name?: string; maxnumber?: number; mockerror?: boolean; + name?: string; + obfuscated?: string; refetchonexpire?: boolean; spamfilter?: boolean | 'ipAddress'; strings?: string; @@ -43,6 +44,16 @@ declare global { workerurl?: string; } + interface AltchaWidgetMethods { + configure: (options: AltchaWidgetOptions) => void; + clarify: () => Promise; + reset: (newState: AltchaState = 'unverified', err: string | null = null) => void; + verify: () => Promise; + } + + interface AltchaWidget extends AltchaWidgetOptions extends AltchaWidgetMethods { + } + declare namespace svelteHTML { interface IntrinsicElements { 'altcha-widget': AltchaWidgetSvelte; @@ -74,6 +85,7 @@ declare global { } interface AltchaWidgetReact extends AltchaWidget extends React.HTMLAttributes { + children?: React.ReactNode; ref?: React.RefObject; style?: AltchaWidgetCSSProperties; } diff --git a/dist/altcha.js b/dist/altcha.js index 0ad96b4..e0295b8 100644 --- a/dist/altcha.js +++ b/dist/altcha.js @@ -1,15 +1,15 @@ -var Bt = Object.defineProperty; -var rt = (n) => { +var $t = Object.defineProperty; +var ut = (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) { +var en = (n, e, t) => e in n ? $t(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; +var D = (n, e, t) => en(n, typeof e != "symbol" ? e + "" : e, t), dt = (n, e, t) => e.has(n) || ut("Cannot " + t); +var W = (n, e, t) => (dt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), fe = (n, e, t) => e.has(n) ? ut("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), ht = (n, e, t, i) => (dt(n, e, "write to private field"), i ? i.call(n, t) : e.set(n, t), t); +const Rt = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIHAoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiB3KGUsdCxyKXtyZXR1cm4gcChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChyLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGIoZSx0LHI9IlNIQS0yNTYiLG49MWU2LHM9MCl7Y29uc3Qgbz1uZXcgQWJvcnRDb250cm9sbGVyLGE9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgYz1zO2M8PW47Yys9MSl7aWYoby5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCB3KHQsYyxyKT09PWUpcmV0dXJue251bWJlcjpjLHRvb2s6RGF0ZS5ub3coKS1hfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjpvfX1mdW5jdGlvbiBoKGUpe2NvbnN0IHQ9YXRvYihlKSxyPW5ldyBVaW50OEFycmF5KHQubGVuZ3RoKTtmb3IobGV0IG49MDtuPHQubGVuZ3RoO24rKylyW25dPXQuY2hhckNvZGVBdChuKTtyZXR1cm4gcn1mdW5jdGlvbiBnKGUsdD0xMil7Y29uc3Qgcj1uZXcgVWludDhBcnJheSh0KTtmb3IobGV0IG49MDtuPHQ7bisrKXJbbl09ZSUyNTYsZT1NYXRoLmZsb29yKGUvMjU2KTtyZXR1cm4gcn1hc3luYyBmdW5jdGlvbiBtKGUsdD0iIixyPTFlNixuPTApe2NvbnN0IHM9IkFFUy1HQ00iLG89bmV3IEFib3J0Q29udHJvbGxlcixhPURhdGUubm93KCksbD1hc3luYygpPT57Zm9yKGxldCB1PW47dTw9cjt1Kz0xKXtpZihvLnNpZ25hbC5hYm9ydGVkfHwhY3x8IXkpcmV0dXJuIG51bGw7dHJ5e2NvbnN0IGQ9YXdhaXQgY3J5cHRvLnN1YnRsZS5kZWNyeXB0KHtuYW1lOnMsaXY6Zyh1KX0sYyx5KTtpZihkKXJldHVybntjbGVhclRleHQ6bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKGQpLHRvb2s6RGF0ZS5ub3coKS1hfX1jYXRjaHt9fXJldHVybiBudWxsfTtsZXQgYz1udWxsLHk9bnVsbDt0cnl7eT1oKGUpO2NvbnN0IHU9YXdhaXQgY3J5cHRvLnN1YnRsZS5kaWdlc3QoIlNIQS0yNTYiLGYuZW5jb2RlKHQpKTtjPWF3YWl0IGNyeXB0by5zdWJ0bGUuaW1wb3J0S2V5KCJyYXciLHUscywhMSxbImRlY3J5cHQiXSl9Y2F0Y2h7cmV0dXJue3Byb21pc2U6UHJvbWlzZS5yZWplY3QoKSxjb250cm9sbGVyOm99fXJldHVybntwcm9taXNlOmwoKSxjb250cm9sbGVyOm99fWxldCBpO29ubWVzc2FnZT1hc3luYyBlPT57Y29uc3R7dHlwZTp0LHBheWxvYWQ6cixzdGFydDpuLG1heDpzfT1lLmRhdGE7bGV0IG89bnVsbDtpZih0PT09ImFib3J0IilpPT1udWxsfHxpLmFib3J0KCksaT12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtpZigib2JmdXNjYXRlZCJpbiByKXtjb25zdHtrZXk6YSxvYmZ1c2NhdGVkOmx9PXJ8fHt9O289YXdhaXQgbShsLGEscyxuKX1lbHNle2NvbnN0e2FsZ29yaXRobTphLGNoYWxsZW5nZTpsLHNhbHQ6Y309cnx8e307bz1iKGwsYyxhLHMsbil9aT1vLmNvbnRyb2xsZXIsby5wcm9taXNlLnRoZW4oYT0+e3NlbGYucG9zdE1lc3NhZ2UoYSYmey4uLmEsd29ya2VyOiEwfSl9KX19fSkoKTsK", tn = (n) => Uint8Array.from(atob(n), (e) => e.charCodeAt(0)), mt = typeof self < "u" && self.Blob && new Blob([tn(Rt)], { type: "text/javascript;charset=utf-8" }); +function nn(n) { let e; try { - if (e = st && (self.URL || self.webkitURL).createObjectURL(st), !e) throw ""; + if (e = mt && (self.URL || self.webkitURL).createObjectURL(mt), !e) throw ""; const t = new Worker(e, { name: n == null ? void 0 : n.name }); @@ -18,7 +18,7 @@ function Xt(n) { }), t; } catch { return new Worker( - "data:text/javascript;base64," + wt, + "data:text/javascript;base64," + Rt, { name: n == null ? void 0 : n.name } @@ -27,37 +27,83 @@ function Xt(n) { e && (self.URL || self.webkitURL).revokeObjectURL(e); } } -function fe() { +function Se() { } -function yt(n) { +function rn(n, e) { + for (const t in e) n[t] = e[t]; + return ( + /** @type {T & S} */ + n + ); +} +function Lt(n) { return n(); } -function lt() { +function gt() { return /* @__PURE__ */ Object.create(null); } -function _e(n) { - n.forEach(yt); +function Ie(n) { + n.forEach(Lt); } -function _t(n) { +function It(n) { return typeof n == "function"; } -function Ht(n, e) { +function on(n, e) { return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function"; } -function Pt(n) { +function ln(n) { return Object.keys(n).length === 0; } -function E(n, e) { +function sn(n, e, t, i) { + if (n) { + const o = Tt(n, e, t, i); + return n[0](o); + } +} +function Tt(n, e, t, i) { + return n[1] && i ? rn(t.ctx.slice(), n[1](i(e))) : t.ctx; +} +function cn(n, e, t, i) { + if (n[2] && i) { + const o = n[2](i(t)); + if (e.dirty === void 0) + return o; + if (typeof o == "object") { + const l = [], s = Math.max(e.dirty.length, o.length); + for (let c = 0; c < s; c += 1) + l[c] = e.dirty[c] | o[c]; + return l; + } + return e.dirty | o; + } + return e.dirty; +} +function an(n, e, t, i, o, l) { + if (o) { + const s = Tt(e, t, i, l); + n.p(s, o); + } +} +function fn(n) { + if (n.ctx.length > 32) { + const e = [], t = n.ctx.length / 32; + for (let i = 0; i < t; i++) + e[i] = -1; + return e; + } + return -1; +} +function L(n, e) { n.appendChild(e); } -function Wt(n, e, t) { - const i = Yt(n); +function un(n, e, t) { + const i = dn(n); if (!i.getElementById(e)) { - const o = R("style"); - o.id = e, o.textContent = t, Kt(i, o); + const o = N("style"); + o.id = e, o.textContent = t, hn(i, o); } } -function Yt(n) { +function dn(n) { if (!n) return document; const e = n.getRootNode ? n.getRootNode() : n.ownerDocument; return e && /** @type {ShadowRoot} */ @@ -66,50 +112,50 @@ function Yt(n) { e ) : n.ownerDocument; } -function Kt(n, e) { - return E( +function hn(n, e) { + return L( /** @type {Document} */ n.head || n, e ), e.sheet; } -function S(n, e, t) { +function Y(n, e, t) { n.insertBefore(e, t || null); } -function N(n) { +function S(n) { n.parentNode && n.parentNode.removeChild(n); } -function R(n) { +function N(n) { return document.createElement(n); } -function $(n) { +function ie(n) { return document.createElementNS("http://www.w3.org/2000/svg", n); } -function pt(n) { +function Nt(n) { return document.createTextNode(n); } -function J() { - return pt(" "); +function q() { + return Nt(" "); } -function Jt() { - return pt(""); +function mn() { + return Nt(""); } -function Se(n, e, t, i) { +function De(n, e, t, i) { return n.addEventListener(e, t, i), () => n.removeEventListener(e, t, i); } -function a(n, e, t) { +function f(n, e, t) { t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t); } -function $t(n) { +function gn(n) { return Array.from(n.childNodes); } -function at(n, e, t) { +function bt(n, e, t) { n.classList.toggle(e, !!t); } -function qt(n, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { +function bn(n, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { return new CustomEvent(n, { detail: e, bubbles: t, cancelable: i }); } -function Qt(n) { +function yn(n) { const e = {}; return n.childNodes.forEach( /** @param {Element} node */ @@ -118,167 +164,176 @@ function Qt(n) { } ), e; } -let ge; -function me(n) { - ge = n; +let Ee; +function ke(n) { + Ee = n; } -function Ue() { - if (!ge) throw new Error("Function called outside component initialization"); - return ge; +function Me() { + if (!Ee) throw new Error("Function called outside component initialization"); + return Ee; } -function en(n) { - Ue().$$.on_mount.push(n); +function vn(n) { + Me().$$.on_mount.push(n); } -function tn(n) { - Ue().$$.on_destroy.push(n); +function wn(n) { + Me().$$.on_destroy.push(n); } -function nn() { - const n = Ue(); +function pn() { + const n = Me(); return (e, t, { cancelable: i = !1 } = {}) => { const o = n.$$.callbacks[e]; if (o) { - const s = qt( + const l = bn( /** @type {string} */ e, t, { cancelable: i } ); - return o.slice().forEach((u) => { - u.call(n, s); - }), !s.defaultPrevented; + return o.slice().forEach((s) => { + s.call(n, l); + }), !l.defaultPrevented; } return !0; }; } -const se = [], ze = []; -let le = []; -const ct = [], kt = /* @__PURE__ */ Promise.resolve(); -let je = !1; -function Et() { - je || (je = !0, kt.then(_)); +const de = [], Ze = []; +let he = []; +const yt = [], At = /* @__PURE__ */ Promise.resolve(); +let Ue = !1; +function zt() { + Ue || (Ue = !0, At.then(p)); } -function rn() { - return Et(), kt; +function _n() { + return zt(), At; } -function De(n) { - le.push(n); +function Xe(n) { + he.push(n); } -const Me = /* @__PURE__ */ new Set(); -let oe = 0; -function _() { - if (oe !== 0) +const Ye = /* @__PURE__ */ new Set(); +let ue = 0; +function p() { + if (ue !== 0) return; - const n = ge; + const n = Ee; do { try { - for (; oe < se.length; ) { - const e = se[oe]; - oe++, me(e), on(e.$$); + for (; ue < de.length; ) { + const e = de[ue]; + ue++, ke(e), kn(e.$$); } } catch (e) { - throw se.length = 0, oe = 0, e; + throw de.length = 0, ue = 0, e; } - 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()); + for (ke(null), de.length = 0, ue = 0; Ze.length; ) Ze.pop()(); + for (let e = 0; e < he.length; e += 1) { + const t = he[e]; + Ye.has(t) || (Ye.add(t), t()); } - le.length = 0; - } while (se.length); - for (; ct.length; ) - ct.pop()(); - je = !1, Me.clear(), me(n); + he.length = 0; + } while (de.length); + for (; yt.length; ) + yt.pop()(); + Ue = !1, Ye.clear(), ke(n); } -function on(n) { +function kn(n) { if (n.fragment !== null) { - n.update(), _e(n.before_update); + n.update(), Ie(n.before_update); const e = n.dirty; - n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(De); + n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(Xe); } } -function sn(n) { +function En(n) { const e = [], t = []; - le.forEach((i) => n.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), le = e; + he.forEach((i) => n.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), he = e; } -const ln = /* @__PURE__ */ new Set(); -function an(n, e) { - n && n.i && (ln.delete(n), n.i(e)); +const ze = /* @__PURE__ */ new Set(); +let xn; +function Ft(n, e) { + n && n.i && (ze.delete(n), n.i(e)); +} +function Cn(n, e, t, i) { + if (n && n.o) { + if (ze.has(n)) return; + ze.add(n), xn.c.push(() => { + ze.delete(n); + }), n.o(e); + } } -function cn(n, e, t) { +function Rn(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); + i && i.m(e, t), Xe(() => { + const l = n.$$.on_mount.map(Lt).filter(It); + n.$$.on_destroy ? n.$$.on_destroy.push(...l) : Ie(l), n.$$.on_mount = []; + }), o.forEach(Xe); } -function fn(n, e) { +function Ln(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 = []); + t.fragment !== null && (En(t.after_update), Ie(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 In(n, e) { + n.$$.dirty[0] === -1 && (de.push(n), zt(), 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.$$ = { +function Tn(n, e, t, i, o, l, s = null, c = [-1]) { + const a = Ee; + ke(n); + const d = n.$$ = { fragment: null, ctx: [], // state - props: s, - update: fe, + props: l, + update: Se, not_equal: o, - bound: lt(), + bound: gt(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], - context: new Map(e.context || (l ? l.$$.context : [])), + context: new Map(e.context || (a ? a.$$.context : [])), // everything else - callbacks: lt(), + callbacks: gt(), dirty: c, skip_bound: !1, - root: e.target || l.$$.root + root: e.target || a.$$.root }; - 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) { + s && s(d.root); + let v = !1; + if (d.ctx = t ? t(n, e.props || {}, (R, $, ...k) => { + const K = k.length ? k[0] : $; + return d.ctx && o(d.ctx[R], d.ctx[R] = K) && (!d.skip_bound && d.bound[R] && d.bound[R](K), v && In(n, R)), $; + }) : [], d.update(), v = !0, Ie(d.before_update), d.fragment = i ? i(d.ctx) : !1, e.target) { if (e.hydrate) { - const g = $t(e.target); - f.fragment && f.fragment.l(g), g.forEach(N); + const R = gn(e.target); + d.fragment && d.fragment.l(R), R.forEach(S); } else - f.fragment && f.fragment.c(); - e.intro && an(n.$$.fragment), cn(n, e.target, e.anchor), _(); + d.fragment && d.fragment.c(); + e.intro && Ft(n.$$.fragment), Rn(n, e.target, e.anchor), p(); } - me(l); + ke(a); } -let xt; -typeof HTMLElement == "function" && (xt = class extends HTMLElement { +let St; +typeof HTMLElement == "function" && (St = class extends HTMLElement { constructor(e, t, i) { super(); /** The Svelte component constructor */ - T(this, "$$ctor"); + D(this, "$$ctor"); /** Slots */ - T(this, "$$s"); + D(this, "$$s"); /** The Svelte component instance */ - T(this, "$$c"); + D(this, "$$c"); /** Whether or not the custom element is connected */ - T(this, "$$cn", !1); + D(this, "$$cn", !1); /** Component props data */ - T(this, "$$d", {}); + D(this, "$$d", {}); /** `true` if currently in the process of reflecting component props back to attributes */ - T(this, "$$r", !1); + D(this, "$$r", !1); /** @type {Record} Props definition (name, reflected, type etc) */ - T(this, "$$p_d", {}); + D(this, "$$p_d", {}); /** @type {Record} Event listeners */ - T(this, "$$l", {}); + D(this, "$$l", {}); /** @type {Map} Event listener unsubscribe functions */ - T(this, "$$l_u", /* @__PURE__ */ new Map()); + D(this, "$$l_u", /* @__PURE__ */ new Map()); this.$$ctor = e, this.$$s = t, i && this.attachShadow({ mode: "open" }); } addEventListener(e, t, i) { @@ -296,37 +351,37 @@ typeof HTMLElement == "function" && (xt = class extends HTMLElement { } async connectedCallback() { if (this.$$cn = !0, !this.$$c) { - let e = function(s) { + let e = function(l) { return () => { - let u; + let s; return { c: function() { - u = R("slot"), s !== "default" && a(u, "name", s); + s = N("slot"), l !== "default" && f(s, "name", l); }, /** * @param {HTMLElement} target * @param {HTMLElement} [anchor] */ - m: function(f, B) { - S(f, u, B); + m: function(d, v) { + Y(d, s, v); }, - d: function(f) { - f && N(u); + d: function(d) { + d && S(s); } }; }; }; if (await Promise.resolve(), !this.$$cn || this.$$c) return; - 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")); + const t = {}, i = yn(this); + for (const l of this.$$s) + l in i && (t[l] = [e(l)]); + for (const l of this.attributes) { + const s = this.$$g_p(l.name); + s in this.$$d || (this.$$d[s] = Fe(s, l.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]); + 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: { @@ -339,23 +394,23 @@ typeof HTMLElement == "function" && (xt = class extends HTMLElement { }); 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], + for (const l in this.$$p_d) + if (this.$$d[l] = this.$$c.$$.ctx[this.$$c.$$.props[l]], this.$$p_d[l].reflect) { + const s = Fe( + l, + this.$$d[l], this.$$p_d, "toAttribute" ); - u == null ? this.removeAttribute(this.$$p_d[s].attribute || s) : this.setAttribute(this.$$p_d[s].attribute || s, u); + s == null ? this.removeAttribute(this.$$p_d[l].attribute || l) : this.setAttribute(this.$$p_d[l].attribute || l, s); } 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); + for (const l in this.$$l) + for (const s of this.$$l[l]) { + const c = this.$$c.$on(l, s); + this.$$l_u.set(s, c); } this.$$l = {}; } @@ -364,7 +419,7 @@ typeof HTMLElement == "function" && (xt = 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] = Ae(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] = Fe(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); } disconnectedCallback() { this.$$cn = !1, Promise.resolve().then(() => { @@ -377,9 +432,9 @@ typeof HTMLElement == "function" && (xt = class extends HTMLElement { ) || e; } }); -function Ae(n, e, t, i) { - var s; - const o = (s = t[n]) == null ? void 0 : s.type; +function Fe(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]) return e; if (i === "toAttribute") @@ -407,8 +462,8 @@ function Ae(n, e, t, i) { return e; } } -function hn(n, e, t, i, o, s) { - let u = class extends xt { +function Nn(n, e, t, i, o, l) { + let s = class extends St { constructor() { super(n, t, o), this.$$p_d = e; } @@ -419,26 +474,26 @@ function hn(n, e, t, i, o, s) { } }; return Object.keys(e).forEach((c) => { - Object.defineProperty(u.prototype, c, { + Object.defineProperty(s.prototype, c, { get() { return this.$$c && c in this.$$c ? this.$$c[c] : this.$$d[c]; }, - set(l) { - var f; - l = Ae(c, l, e), this.$$d[c] = l, (f = this.$$c) == null || f.$set({ [c]: l }); + set(a) { + var d; + a = Fe(c, a, e), this.$$d[c] = a, (d = this.$$c) == null || d.$set({ [c]: a }); } }); }), i.forEach((c) => { - Object.defineProperty(u.prototype, c, { + Object.defineProperty(s.prototype, c, { get() { - var l; - return (l = this.$$c) == null ? void 0 : l[c]; + var a; + return (a = this.$$c) == null ? void 0 : a[c]; } }); }), n.element = /** @type {any} */ - u, u; + s, s; } -class mn { +class An { constructor() { /** * ### PRIVATE API @@ -447,7 +502,7 @@ class mn { * * @type {any} */ - T(this, "$$"); + D(this, "$$"); /** * ### PRIVATE API * @@ -455,11 +510,11 @@ class mn { * * @type {any} */ - T(this, "$$set"); + D(this, "$$set"); } /** @returns {void} */ $destroy() { - fn(this, 1), this.$destroy = fe; + Ln(this, 1), this.$destroy = Se; } /** * @template {Extract} K @@ -468,8 +523,8 @@ class mn { * @returns {() => void} */ $on(e, t) { - if (!_t(t)) - return fe; + if (!It(t)) + return Se; const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); return i.push(t), () => { const o = i.indexOf(t); @@ -481,19 +536,19 @@ class mn { * @returns {void} */ $set(e) { - this.$$set && !Pt(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); + this.$$set && !ln(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); } } -const gn = "4"; -typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(gn); -const bn = new TextEncoder(); -function vn(n) { +const zn = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(zn); +const Zt = new TextEncoder(); +function Fn(n) { return [...new Uint8Array(n)].map((e) => e.toString(16).padStart(2, "0")).join(""); } -async function wn(n, e = "SHA-256", t = 1e5) { +async function Sn(n, e = "SHA-256", t = 1e5) { const i = Date.now().toString(16); n || (n = Math.round(Math.random() * t)); - const o = await Ct(i, n, e); + const o = await Vt(i, n, e); return { algorithm: e, challenge: o, @@ -501,65 +556,126 @@ async function wn(n, e = "SHA-256", t = 1e5) { signature: "" }; } -async function Ct(n, e, t) { - return vn( +async function Vt(n, e, t) { + return Fn( await crypto.subtle.digest( t.toUpperCase(), - bn.encode(n + e) + Zt.encode(n + e) ) ); } -function yn(n, e, t = "SHA-256", i = 1e6, o = 0) { - const s = new AbortController(), u = Date.now(); +function Zn(n, e, t = "SHA-256", i = 1e6, o = 0) { + const l = new AbortController(), s = Date.now(); return { promise: (async () => { - for (let l = o; l <= i; l += 1) { - if (s.signal.aborted) + for (let a = o; a <= i; a += 1) { + if (l.signal.aborted) return null; - if (await Ct(e, l, t) === n) + if (await Vt(e, a, t) === n) return { - number: l, - took: Date.now() - u + number: a, + took: Date.now() - s }; } return null; })(), - controller: s + controller: l }; } -function Lt() { +function Ht() { try { return Intl.DateTimeFormat().resolvedOptions().timeZone; } catch { } } -var ae, ce, be, ve, we, ye; -class _n { +function Vn(n) { + const e = atob(n), t = new Uint8Array(e.length); + for (let i = 0; i < e.length; i++) + t[i] = e.charCodeAt(i); + return t; +} +function Hn(n, e = 12) { + const t = new Uint8Array(e); + for (let i = 0; i < e; i++) + t[i] = n % 256, n = Math.floor(n / 256); + return t; +} +async function Gn(n, e = "", t = 1e6, i = 0) { + const o = "AES-GCM", l = new AbortController(), s = Date.now(), c = async () => { + for (let v = i; v <= t; v += 1) { + if (l.signal.aborted || !a || !d) + return null; + try { + const R = await crypto.subtle.decrypt( + { + name: o, + iv: Hn(v) + }, + a, + d + ); + if (R) + return { + clearText: new TextDecoder().decode(R), + took: Date.now() - s + }; + } catch { + } + } + return null; + }; + let a = null, d = null; + try { + d = Vn(n); + const v = await crypto.subtle.digest( + "SHA-256", + Zt.encode(e) + ); + a = await crypto.subtle.importKey( + "raw", + v, + o, + !1, + ["decrypt"] + ); + } catch { + return { + promise: Promise.reject(), + controller: l + }; + } + return { + promise: c(), + controller: l + }; +} +var me, ge, xe, Ce, Re, Le; +class Dn { 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)); + D(this, "beaconUrl", null); + D(this, "error", null); + D(this, "loadTime", Date.now()); + D(this, "submitTime", null); + D(this, "startTime", null); + D(this, "viewTimeThresholdMs", 1500); + fe(this, me, {}); + fe(this, ge, null); + fe(this, xe, this.onFormChange.bind(this)); + fe(this, Ce, this.onFormFocus.bind(this)); + fe(this, Re, this.onFormSubmit.bind(this)); + fe(this, Le, this.onUnload.bind(this)); + this.elForm = e, window.addEventListener("unload", W(this, Le)), this.elForm.addEventListener("change", W(this, xe)), this.elForm.addEventListener("focusin", W(this, Ce)), this.elForm.addEventListener("submit", W(this, Re)); } data() { - const e = Object.entries(V(this, ae)); + const e = Object.entries(W(this, me)); 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, + dropoff: !this.submitTime && !this.error && W(this, ge) ? W(this, ge) : null, error: this.error, mobile: this.isMobile(), start: this.startTime, submit: this.submitTime, - tz: Lt() + tz: Ht() }; } dataAsBase64() { @@ -573,7 +689,7 @@ class _n { 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)); + window.removeEventListener("unload", W(this, Le)), this.elForm.removeEventListener("change", W(this, xe)), this.elForm.removeEventListener("focusin", W(this, Ce)), this.elForm.removeEventListener("submit", W(this, Re)); } end() { this.submitTime || (this.submitTime = Date.now()); @@ -601,7 +717,7 @@ class _n { const t = e.target; if (this.startTime || this.start(), t && this.isInput(t)) { const i = this.getFieldName(t); - i && ot(this, ce, i); + i && ht(this, ge, i); } } onFormSubmit() { @@ -627,64 +743,64 @@ class _n { this.error = e === null ? null : String(e); } trackFieldChange(e) { - V(this, ae)[e] = (V(this, ae)[e] || 0) + 1; + W(this, me)[e] = (W(this, me)[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)}}'); +me = new WeakMap(), ge = new WeakMap(), xe = new WeakMap(), Ce = new WeakMap(), Re = new WeakMap(), Le = new WeakMap(); +var y = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(y || {}); +function Yn(n) { + un(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 ft(n) { +function vt(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"); + e = ie("svg"), t = ie("path"), i = ie("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(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"), f(i, "fill", "currentColor"), f(i, "class", "altcha-spinner svelte-ddsc3z"), 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) { - S(o, e, s), E(e, t), E(e, i); + m(o, l) { + Y(o, e, l), L(e, t), L(e, i); }, d(o) { - o && N(e); + o && S(e); } }; } -function kn(n) { +function Un(n) { let e, t = ( /*_strings*/ n[13].label + "" ), i; return { c() { - e = R("label"), a(e, "for", i = /*name*/ - n[4] + "_checkbox"), a(e, "class", "svelte-ddsc3z"); + e = N("label"), f(e, "for", i = /*name*/ + n[4] + "_checkbox"), f(e, "class", "svelte-ddsc3z"); }, - m(o, s) { - S(o, e, s), e.innerHTML = t; + m(o, l) { + Y(o, e, l), e.innerHTML = t; }, - p(o, s) { - s[0] & /*_strings*/ + p(o, l) { + l[0] & /*_strings*/ 8192 && t !== (t = /*_strings*/ - o[13].label + "") && (e.innerHTML = t), s[0] & /*name*/ + o[13].label + "") && (e.innerHTML = t), l[0] & /*name*/ 16 && i !== (i = /*name*/ - o[4] + "_checkbox") && a(e, "for", i); + o[4] + "_checkbox") && f(e, "for", i); }, d(o) { - o && N(e); + o && S(e); } }; } -function En(n) { +function Xn(n) { let e, t = ( /*_strings*/ n[13].verifying + "" ); return { c() { - e = R("span"); + e = N("span"); }, m(i, o) { - S(i, e, o), e.innerHTML = t; + Y(i, e, o), e.innerHTML = t; }, p(i, o) { o[0] & /*_strings*/ @@ -692,21 +808,21 @@ function En(n) { i[13].verifying + "") && (e.innerHTML = t); }, d(i) { - i && N(e); + i && S(e); } }; } -function xn(n) { +function Mn(n) { let e, t = ( /*_strings*/ n[13].verified + "" - ), i, o, s, u, c = ( + ), i, o, l, s, c = ( /*session*/ - n[11] && ut(n) + n[11] && wt(n) ); return { c() { - e = R("span"), i = J(), o = R("input"), s = J(), c && c.c(), u = Jt(), a(o, "type", "hidden"), a( + e = N("span"), i = q(), o = N("input"), l = q(), c && c.c(), s = mn(), f(o, "type", "hidden"), f( o, "name", /*name*/ @@ -714,37 +830,37 @@ function xn(n) { ), o.value = /*payload*/ n[6]; }, - 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); + m(a, d) { + Y(a, e, d), e.innerHTML = t, Y(a, i, d), Y(a, o, d), Y(a, l, d), c && c.m(a, d), Y(a, s, d); }, - p(l, f) { - f[0] & /*_strings*/ + p(a, d) { + d[0] & /*_strings*/ 8192 && t !== (t = /*_strings*/ - l[13].verified + "") && (e.innerHTML = t), f[0] & /*name*/ - 16 && a( + a[13].verified + "") && (e.innerHTML = t), d[0] & /*name*/ + 16 && f( o, "name", /*name*/ - l[4] - ), f[0] & /*payload*/ + a[4] + ), d[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); + a[6]), /*session*/ + a[11] ? c ? c.p(a, d) : (c = wt(a), c.c(), c.m(s.parentNode, s)) : c && (c.d(1), c = null); }, - d(l) { - l && (N(e), N(i), N(o), N(s), N(u)), c && c.d(l); + d(a) { + a && (S(e), S(i), S(o), S(l), S(s)), c && c.d(a); } }; } -function ut(n) { +function wt(n) { let e; return { c() { - e = R("input"), a(e, "type", "hidden"), a(e, "name", "__session"), e.value = /*sessionPayload*/ + e = N("input"), f(e, "type", "hidden"), f(e, "name", "__session"), e.value = /*sessionPayload*/ n[12]; }, m(t, i) { - S(t, e, i); + Y(t, e, i); }, p(t, i) { i[0] & /*sessionPayload*/ @@ -752,62 +868,62 @@ function ut(n) { t[12]); }, d(t) { - t && N(e); + t && S(e); } }; } -function dt(n) { - let e, t, i, o, s, u, c; +function pt(n) { + let e, t, i, o, l, s, c; return { c() { - 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*/ + e = N("div"), t = N("a"), i = ie("svg"), o = ie("path"), l = ie("path"), s = ie("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(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"), f(l, "fill", "currentColor"), f(s, "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(s, "fill", "currentColor"), f(i, "width", "22"), f(i, "height", "22"), f(i, "viewBox", "0 0 20 20"), f(i, "fill", "none"), f(i, "xmlns", "http://www.w3.org/2000/svg"), f(t, "href", Gt), f(t, "target", "_blank"), f(t, "class", "altcha-logo svelte-ddsc3z"), f(t, "aria-label", c = /*_strings*/ n[13].ariaLinkLabel); }, - m(l, f) { - S(l, e, f), E(e, t), E(t, i), E(i, o), E(i, s), E(i, u); + m(a, d) { + Y(a, e, d), L(e, t), L(t, i), L(i, o), L(i, l), L(i, s); }, - p(l, f) { - f[0] & /*_strings*/ + p(a, d) { + d[0] & /*_strings*/ 8192 && c !== (c = /*_strings*/ - l[13].ariaLinkLabel) && a(t, "aria-label", c); + a[13].ariaLinkLabel) && f(t, "aria-label", c); }, - d(l) { - l && N(e); + d(a) { + a && S(e); } }; } -function ht(n) { +function _t(n) { let e, t, i, o; - function s(l, f) { + function l(a, d) { return ( /*state*/ - l[7] === w.EXPIRED ? Ln : Cn + a[7] === y.EXPIRED ? Wn : jn ); } - let u = s(n), c = u(n); + let s = l(n), c = s(n); return { c() { - 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"); + e = N("div"), t = ie("svg"), i = ie("path"), o = q(), c.c(), f(i, "stroke-linecap", "round"), f(i, "stroke-linejoin", "round"), f(i, "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 svelte-ddsc3z"); }, - m(l, f) { - S(l, e, f), E(e, t), E(t, i), E(e, o), c.m(e, null); + m(a, d) { + Y(a, e, d), L(e, t), L(t, i), L(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))); + p(a, d) { + s === (s = l(a)) && c ? c.p(a, d) : (c.d(1), c = s(a), c && (c.c(), c.m(e, null))); }, - d(l) { - l && N(e), c.d(); + d(a) { + a && S(e), c.d(); } }; } -function Cn(n) { +function jn(n) { let e, t = ( /*_strings*/ n[13].error + "" ); return { c() { - e = R("div"), a( + e = N("div"), f( e, "title", /*error*/ @@ -815,13 +931,13 @@ function Cn(n) { ); }, m(i, o) { - S(i, e, o), e.innerHTML = t; + Y(i, e, o), e.innerHTML = t; }, p(i, o) { o[0] & /*_strings*/ 8192 && t !== (t = /*_strings*/ i[13].error + "") && (e.innerHTML = t), o[0] & /*error*/ - 32 && a( + 32 && f( e, "title", /*error*/ @@ -829,18 +945,18 @@ function Cn(n) { ); }, d(i) { - i && N(e); + i && S(e); } }; } -function Ln(n) { +function Wn(n) { let e, t = ( /*_strings*/ n[13].expired + "" ); return { c() { - e = R("div"), a( + e = N("div"), f( e, "title", /*error*/ @@ -848,13 +964,13 @@ function Ln(n) { ); }, m(i, o) { - S(i, e, o), e.innerHTML = t; + Y(i, e, o), e.innerHTML = t; }, p(i, o) { o[0] & /*_strings*/ 8192 && t !== (t = /*_strings*/ i[13].expired + "") && (e.innerHTML = t), o[0] & /*error*/ - 32 && a( + 32 && f( e, "title", /*error*/ @@ -862,387 +978,437 @@ function Ln(n) { ); }, d(i) { - i && N(e); + i && S(e); } }; } -function mt(n) { +function kt(n) { let e, t, i = ( /*_strings*/ n[13].footer + "" ); return { c() { - e = R("div"), t = R("div"), a(t, "class", "svelte-ddsc3z"), a(e, "class", "altcha-footer svelte-ddsc3z"); + e = N("div"), t = N("div"), f(t, "class", "svelte-ddsc3z"), f(e, "class", "altcha-footer svelte-ddsc3z"); }, - m(o, s) { - S(o, e, s), E(e, t), t.innerHTML = i; + m(o, l) { + Y(o, e, l), L(e, t), t.innerHTML = i; }, - p(o, s) { - s[0] & /*_strings*/ + p(o, l) { + l[0] & /*_strings*/ 8192 && i !== (i = /*_strings*/ o[13].footer + "") && (t.innerHTML = i); }, d(o) { - o && N(e); + o && S(e); } }; } -function gt(n) { +function Et(n) { let e; return { c() { - e = R("div"), a(e, "class", "altcha-anchor-arrow svelte-ddsc3z"); + e = N("div"), f(e, "class", "altcha-anchor-arrow svelte-ddsc3z"); }, m(t, i) { - S(t, e, i), n[41](e); + Y(t, e, i), n[46](e); }, - p: fe, + p: Se, d(t) { - t && N(e), n[41](null); + t && S(e), n[46](null); } }; } -function Rn(n) { - let e, t, i, o, s, u, c, l, f, B, g, G, O, X, Y, b = ( +function Bn(n) { + let e, t, i, o, l, s, c, a, d, v, R, $, k, K, X, ee, te; + const A = ( + /*#slots*/ + n[44].default + ), U = sn( + A, + n, + /*$$scope*/ + n[43], + null + ); + let Z = ( /*state*/ - n[7] === w.VERIFYING && ft() + n[7] === y.VERIFYING && vt() ); - function q(h, p) { + function oe(h, x) { return ( /*state*/ - h[7] === w.VERIFIED ? xn : ( + h[7] === y.VERIFIED ? Mn : ( /*state*/ - h[7] === w.VERIFYING ? En : kn + h[7] === y.VERIFYING ? Xn : Un ) ); } - let K = q(n), j = K(n), I = ( + let ne = oe(n), j = ne(n), I = ( /*hidelogo*/ (n[3] !== !0 || /*isFreeSaaS*/ - n[14]) && dt(n) - ), F = ( + n[14]) && pt(n) + ), z = ( /*error*/ (n[5] || /*state*/ - n[7] === w.EXPIRED) && ht(n) - ), x = ( + n[7] === y.EXPIRED) && _t(n) + ), E = ( /*_strings*/ n[13].footer && /*hidefooter*/ (n[2] !== !0 || /*isFreeSaaS*/ - n[14]) && mt(n) - ), A = ( + n[14]) && kt(n) + ), F = ( /*floating*/ - n[1] && gt(n) + n[1] && Et(n) ); return { c() { - 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, + U && U.c(), e = q(), t = N("div"), i = N("div"), Z && Z.c(), o = q(), l = N("div"), s = N("input"), d = q(), v = N("div"), j.c(), R = q(), I && I.c(), $ = q(), z && z.c(), k = q(), E && E.c(), K = q(), F && F.c(), f(s, "type", "checkbox"), f(s, "id", c = /*name*/ + n[4] + "_checkbox"), s.required = a = /*auto*/ + n[0] !== "onsubmit", f(s, "class", "svelte-ddsc3z"), f(l, "class", "altcha-checkbox svelte-ddsc3z"), bt( + l, "altcha-hidden", /*state*/ - 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, + n[7] === y.VERIFYING + ), f(v, "class", "altcha-label svelte-ddsc3z"), f(i, "class", "altcha-main svelte-ddsc3z"), f(t, "class", "altcha svelte-ddsc3z"), f( + t, "data-state", /*state*/ n[7] - ), a( - e, + ), f( + t, "data-floating", /*floating*/ n[1] ); }, - 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( + m(h, x) { + U && U.m(h, x), Y(h, e, x), Y(h, t, x), L(t, i), Z && Z.m(i, null), L(i, o), L(i, l), L(l, s), s.checked = /*checked*/ + n[8], L(i, d), L(i, v), j.m(v, null), L(i, R), I && I.m(i, null), L(t, $), z && z.m(t, null), L(t, k), E && E.m(t, null), L(t, K), F && F.m(t, null), n[47](t), X = !0, ee || (te = [ + De( s, "change", /*input_change_handler*/ - n[40] + n[45] ), - Se( + De( s, "change", /*onCheckedChange*/ n[15] ), - Se( + De( s, "invalid", /*onInvalid*/ n[16] ) - ], X = !0); + ], ee = !0); }, - p(h, p) { - /*state*/ - 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*/ + p(h, x) { + U && U.p && (!X || x[1] & /*$$scope*/ + 4096) && an( + U, + A, + h, + /*$$scope*/ + h[43], + X ? cn( + A, + /*$$scope*/ + h[43], + x, + null + ) : fn( + /*$$scope*/ + h[43] + ), + null + ), /*state*/ + h[7] === y.VERIFYING ? Z || (Z = vt(), Z.c(), Z.m(i, o)) : Z && (Z.d(1), Z = null), (!X || x[0] & /*name*/ + 16 && c !== (c = /*name*/ + h[4] + "_checkbox")) && f(s, "id", c), (!X || x[0] & /*auto*/ + 1 && a !== (a = /*auto*/ + h[0] !== "onsubmit")) && (s.required = a), x[0] & /*checked*/ 256 && (s.checked = /*checked*/ - h[8]), p[0] & /*state*/ - 128 && at( - o, + h[8]), (!X || x[0] & /*state*/ + 128) && bt( + l, "altcha-hidden", /*state*/ - 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[7] === y.VERIFYING + ), ne === (ne = oe(h)) && j ? j.p(h, x) : (j.d(1), j = ne(h), j && (j.c(), j.m(v, null))), /*hidelogo*/ h[3] !== !0 || /*isFreeSaaS*/ - h[14] ? I ? I.p(h, p) : (I = dt(h), I.c(), I.m(t, null)) : I && (I.d(1), I = null), /*error*/ + h[14] ? I ? I.p(h, x) : (I = pt(h), I.c(), I.m(i, 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[7] === y.EXPIRED ? z ? z.p(h, x) : (z = _t(h), z.c(), z.m(t, k)) : z && (z.d(1), z = null), /*_strings*/ h[13].footer && /*hidefooter*/ (h[2] !== !0 || /*isFreeSaaS*/ - 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, + h[14]) ? E ? E.p(h, x) : (E = kt(h), E.c(), E.m(t, K)) : E && (E.d(1), E = null), /*floating*/ + h[1] ? F ? F.p(h, x) : (F = Et(h), F.c(), F.m(t, null)) : F && (F.d(1), F = null), (!X || x[0] & /*state*/ + 128) && f( + t, "data-state", /*state*/ h[7] - ), p[0] & /*floating*/ - 2 && a( - e, + ), (!X || x[0] & /*floating*/ + 2) && f( + t, "data-floating", /*floating*/ h[1] ); }, - i: fe, - o: fe, + i(h) { + X || (Ft(U, h), X = !0); + }, + o(h) { + Cn(U, h), X = !1; + }, d(h) { - 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); + h && (S(e), S(t)), U && U.d(h), Z && Z.d(), j.d(), I && I.d(), z && z.d(), E && E.d(), F && F.d(), n[47](null), ee = !1, Ie(te); } }; } -const bt = "Visit Altcha.org", Rt = "https://altcha.org/"; -function vt(n) { +const xt = "Visit Altcha.org", Gt = "https://altcha.org/"; +function Ct(n) { return JSON.parse(n); } -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 Kn(n, e, t) { + var ct, at; + let i, o, l, s, { $$slots: c = {}, $$scope: a } = e, { analytics: d = !1 } = e, { auto: v = void 0 } = e, { beaconurl: R = void 0 } = e, { blockspam: $ = void 0 } = e, { challengeurl: k = void 0 } = e, { challengejson: K = void 0 } = e, { debug: X = !1 } = e, { delay: ee = 0 } = e, { expire: te = void 0 } = e, { floating: A = void 0 } = e, { floatinganchor: U = void 0 } = e, { floatingoffset: Z = void 0 } = e, { hidefooter: oe = !1 } = e, { hidelogo: ne = !1 } = e, { name: j = "altcha" } = e, { maxnumber: I = 1e6 } = e, { mockerror: z = !1 } = e, { obfuscated: E = void 0 } = e, { refetchonexpire: F = !0 } = e, { spamfilter: h = !1 } = e, { strings: x = void 0 } = e, { test: P = !1 } = e, { verifyurl: le = void 0 } = e, { workers: be = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: Te = void 0 } = e; + const Ve = pn(), je = ["SHA-256", "SHA-384", "SHA-512"], We = (at = (ct = document.documentElement.lang) == null ? void 0 : ct.split("-")) == null ? void 0 : at[0]; + let O = !1, J = null, _, se = null, Ne = null, b = null, re = null, ye = null, Q = null, ce = null, M = null, Be = null, T = y.UNVERIFIED; + wn(() => { + b && (b.removeEventListener("submit", Oe), b.removeEventListener("reset", Je), b.removeEventListener("focusin", Pe), b = null), re && _.removeEventListener("click", Ke), M && M.destroy(), Q && (clearTimeout(Q), Q = null), document.removeEventListener("click", nt), document.removeEventListener("scroll", rt), window.removeEventListener("resize", ot); + }), vn(() => { + var r, u; + C("mounted", "0.8.0"), C("workers", be), P && C("using test mode"), te && Ae(te), v !== void 0 && C("auto", v), A !== void 0 && lt(A), b = _.closest("form"), b && (b.addEventListener("submit", Oe, { capture: !0 }), b.addEventListener("reset", Je), v === "onfocus" && b.addEventListener("focusin", Pe)), re = ((r = _.parentElement) == null ? void 0 : r.querySelector("[data-clarify-button]")) || ((u = _.parentElement) == null ? void 0 : u.querySelector("button, a")), re && re.addEventListener("click", Ke), d && $e(), v === "onload" && (E ? we() : ae()), i && (oe || ne) && C("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution."); }); - function k(...r) { - (O || r.some((d) => d instanceof Error)) && console[r[0] instanceof Error ? "error" : "log"]("ALTCHA", ...r); + function C(...r) { + (X || r.some((u) => u instanceof Error)) && console[r[0] instanceof Error ? "error" : "log"]("ALTCHA", ...r); } - function Ge(r) { - U === w.UNVERIFIED && re(); + function Ke(r) { + r.preventDefault(), T === y.UNVERIFIED && we(); + } + function Pe(r) { + T === y.UNVERIFIED && ae(); } 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(); - })) : U !== w.VERIFIED && (r.preventDefault(), r.stopPropagation(), U === w.VERIFYING && $e())); + b && M && T === y.VERIFIED && (M.end(), t(12, Be = M.dataAsBase64())), b && v === "onsubmit" && (T === y.UNVERIFIED ? (r.preventDefault(), r.stopPropagation(), ae().then(() => { + b == null || b.requestSubmit(); + })) : T !== y.VERIFIED && (r.preventDefault(), r.stopPropagation(), T === y.VERIFYING && it())); } - function Xe() { - Le(); + function Je() { + ve(); } - function He(r, d) { + function Qe(r, u) { return btoa(JSON.stringify({ algorithm: r.algorithm, challenge: r.challenge, - number: d.number, + number: u.number, salt: r.salt, signature: r.signature, - test: H ? !0 : void 0, - took: d.took + test: P ? !0 : void 0, + took: u.took })); } - function Pe(r) { + function qe(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 (!Ze.includes(r.algorithm.toUpperCase())) - throw new Error(`Unknown algorithm value. Allowed values: ${Ze.join(", ")}`); + if (!je.includes(r.algorithm.toUpperCase())) + throw new Error(`Unknown algorithm value. Allowed values: ${je.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 It() { + async function Dt() { var r; - if (A) - throw k("mocking error"), new Error("Mocked error."); + if (z) + throw C("mocking error"), new Error("Mocked error."); if (o) - return k("using provided json data"), o; - if (H) - return k("generating test challenge", { test: H }), wn(typeof H != "boolean" ? +H : void 0); + return C("using provided json data"), o; + if (P) + return C("generating test challenge", { test: P }), Sn(typeof P != "boolean" ? +P : void 0); { - if (!g && m) { - const y = m.getAttribute("action"); - y != null && y.includes("/form/") && t(17, g = y + "/altcha"); + if (!k && b) { + const w = b.getAttribute("action"); + w != null && w.includes("/form/") && t(17, k = w + "/altcha"); } - if (!g) + if (!k) throw new Error("Attribute challengeurl not set."); - k("fetching challenge from", g); - const d = await fetch(g, { - headers: p ? { "x-altcha-spam-filter": "1" } : {} + C("fetching challenge from", k); + const u = await fetch(k, { + headers: h ? { "x-altcha-spam-filter": "1" } : {} }); - 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 (u.status !== 200) + throw new Error(`Server responded with ${u.status}.`); + const m = u.headers.get("Expires"), g = u.headers.get("X-Altcha-Config"), V = await u.json(), H = new URLSearchParams((r = V.salt.split("?")) == null ? void 0 : r[1]), G = H.get("expires") || H.get("expire"); + if (G) { + const w = new Date(+G * 1e3), B = isNaN(w.getTime()) ? 0 : w.getTime() - Date.now(); + B > 0 && Ae(B); } - if (z) + if (g) try { - 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); + const w = JSON.parse(g); + w && typeof w == "object" && (w.verifyurl && (w.verifyurl = new URL(w.verifyurl, new URL(k)).toString()), st(w)); + } catch (w) { + C("unable to configure from X-Altcha-Config", w); } - if (!Y && (v != null && v.length)) { - const y = Date.parse(v); - if (y) { - const L = y - Date.now(); - L > 0 && Ce(L); + if (!te && (m != null && m.length)) { + const w = Date.parse(m); + if (w) { + const B = w - Date.now(); + B > 0 && Ae(B); } } - return Z; + return V; } } - 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"); + function $e() { + if (!M) + if (b) { + if (C("analytics enabled"), t(11, M = new Dn(b)), R === void 0) { + const r = b.getAttribute("action"); + r && t(19, R = r + "/beacon"); } - t(11, D.beaconUrl = f || null, D); + t(11, M.beaconUrl = R || null, M); } else - k("analytics cannot be enabled - form element not found"); + C("analytics cannot be enabled - form element not found"); } - function Ye() { - g && h && U === w.VERIFIED ? re() : Le(w.EXPIRED, u.expired); + function et() { + k && F && T === y.VERIFIED ? ae() : ve(y.EXPIRED, s.expired); } - async function At(r) { - let d = null; + async function tt(r) { + let u = null; if ("Worker" in window) { try { - d = await zt(r.challenge, r.salt, r.algorithm, r.maxnumber); - } catch (v) { - k(v); + u = await Yt(r, r.maxnumber); + } catch (m) { + C(m); } - if ((d == null ? void 0 : d.number) !== void 0) - return { data: r, solution: d }; + if ((u == null ? void 0 : u.number) !== void 0 || "obfuscated" in r) + return { data: r, solution: u }; + } + if ("obfuscated" in r) { + const m = await Gn(r.obfuscated, r.key, r.maxnumber); + return { data: r, solution: await m.promise }; } return { data: r, - solution: await yn(r.challenge, r.salt, r.algorithm, r.maxnumber || x).promise + solution: await Zn(r.challenge, r.salt, r.algorithm, r.maxnumber || I).promise }; } - 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: v, - challenge: r, - max: de + W, - salt: d, - start: de - }, + async function Yt(r, u = typeof P == "number" ? P : I, m = Math.ceil(be)) { + const g = []; + m = Math.min(16, Math.max(1, m)); + for (let G = 0; G < m; G++) + g.push(createAltchaWorker(Te)); + const V = Math.ceil(u / m), H = await Promise.all(g.map((G, w) => { + const B = w * V; + return new Promise((Ge) => { + G.addEventListener("message", (pe) => { + if (pe.data) + for (const _e of g) + _e !== G && _e.postMessage({ type: "abort" }); + Ge(pe.data); + }), G.postMessage({ + payload: r, + max: B + V, + start: B, type: "work" }); }); })); - for (const L of M) - L.terminate(); - return y.find((L) => !!L) || null; + for (const G of g) + G.terminate(); + return H.find((G) => !!G) || null; } - 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 Ut() { + [y.UNVERIFIED, y.ERROR, y.EXPIRED].includes(T) ? h && (b == null ? void 0 : b.reportValidity()) === !1 ? t(8, O = !1) : E ? we() : ae() : t(8, O = !0); } - function Ke(r) { - const d = r.target; - b && d && !C.contains(d) && U === w.VERIFIED && t(9, C.style.display = "none", C); + function nt(r) { + const u = r.target; + A && u && !_.contains(u) && T === y.VERIFIED && t(9, _.style.display = "none", _); } - function Je() { - b && Te(); + function rt() { + A && He(); } - function $e() { - U === w.VERIFYING && u.waitAlert && alert(u.waitAlert); + function it() { + T === y.VERIFYING && s.waitAlert && alert(s.waitAlert); + } + function Xt(r) { + var u; + if (J) { + const m = J.match(/^(mailto|tel|sms|https?):/); + let g; + if (m) { + const [V] = J.slice(J.indexOf(":") + 1).replace(/^\/\//, "").split("?"); + g = document.createElement("a"), g.href = J, g.innerHTML = V; + } else + g = document.createTextNode(J); + re && g && (re.after(g), (u = re.parentElement) == null || u.removeChild(re)); + } } - function Tt(r) { - D && D.trackError(xe); + function Mt(r) { + M && M.trackError(ye); } - function Nt(r) { - b && U !== w.UNVERIFIED && requestAnimationFrame(() => { - Te(); + function jt(r) { + A && T !== y.UNVERIFIED && requestAnimationFrame(() => { + He(); }); } - function qe() { - b && Te(); + function ot() { + A && He(); } - function Ce(r) { - k("expire", r), P && (clearTimeout(P), P = null), r < 1 ? Ye() : P = setTimeout(Ye, r); + function Ae(r) { + C("expire", r), Q && (clearTimeout(Q), Q = null), r < 1 ? et() : Q = setTimeout(et, r); } - 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 lt(r) { + C("floating", r), A !== r && (t(9, _.style.left = "", _), t(9, _.style.top = "", _)), t(1, A = r === !0 || r === "" ? "auto" : r === !1 || r === "false" ? void 0 : A), A ? (v || t(0, v = "onsubmit"), document.addEventListener("scroll", rt), document.addEventListener("click", nt), window.addEventListener("resize", ot)) : v === "onsubmit" && t(0, v = 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 Wt(r) { + var m; + const u = b == null ? void 0 : b.querySelector(typeof r == "string" ? `input[name="${r}"]` : 'input[type="email"]:not([data-no-spamfilter])'); + return ((m = u == null ? void 0 : u.value) == null ? void 0 : m.slice(u.value.indexOf("@"))) || void 0; } - function Mt(r) { + function Bt(r) { return [ - ...(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])')) || [] + ...(b == null ? void 0 : b.querySelectorAll(r != null && r.length ? r.map((m) => `input[name="${m}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] ].reduce( - (v, z) => { - const Z = z.name, M = z.value; - return Z && M && (v[Z] = /\n/.test(M) ? M.replace(new RegExp("(? { + const V = g.name, H = g.value; + return V && H && (m[V] = /\n/.test(H) ? H.replace(new RegExp("(? 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); + function He(r = 20) { + if (_) + if (Ne || (Ne = (U ? document.querySelector(U) : b == null ? void 0 : b.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || b || re), Ne) { + const u = parseInt(Z, 10) || 12, m = Ne.getBoundingClientRect(), g = _.getBoundingClientRect(), V = document.documentElement.clientHeight, H = document.documentElement.clientWidth, G = A === "auto" ? m.bottom + g.height + u + r > V : A === "top", w = Math.max(r, Math.min(H - r - g.width, m.left + m.width / 2 - g.width / 2)); + if (G ? t(9, _.style.top = `${m.top - (g.height + u)}px`, _) : t(9, _.style.top = `${m.bottom + u}px`, _), t(9, _.style.left = `${w}px`, _), _.setAttribute("data-floating", G ? "top" : "bottom"), se) { + const B = se.getBoundingClientRect(); + t(10, se.style.left = m.left - w + m.width / 2 - B.width / 2 + "px", se); } } else - k("unable to find floating anchor element"); - } - 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 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 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 k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); + C("unable to find floating anchor element"); + } + function st(r) { + r.analytics && (t(18, d = r.analytics), $e()), r.obfuscated !== void 0 && t(27, E = r.obfuscated), r.auto !== void 0 && (t(0, v = r.auto), v === "onload" && (E ? we() : ae())), r.beaconurl && (t(19, R = r.beaconurl), M && t(11, M.beaconUrl = R, M)), r.floatinganchor !== void 0 && t(23, U = r.floatinganchor), r.delay !== void 0 && t(21, ee = r.delay), r.floatingoffset !== void 0 && t(24, Z = r.floatingoffset), r.floating !== void 0 && lt(r.floating), r.expire !== void 0 && (Ae(r.expire), t(22, te = r.expire)), r.challenge && (qe(r.challenge), o = r.challenge), r.challengeurl !== void 0 && t(17, k = r.challengeurl), r.debug !== void 0 && t(20, X = !!r.debug), r.hidefooter !== void 0 && t(2, oe = !!r.hidefooter), r.hidelogo !== void 0 && t(3, ne = !!r.hidelogo), r.maxnumber !== void 0 && t(25, I = +r.maxnumber), r.mockerror !== void 0 && t(26, z = !!r.mockerror), r.name !== void 0 && t(4, j = r.name), r.refetchonexpire !== void 0 && t(28, F = !!r.refetchonexpire), r.spamfilter !== void 0 && t(29, h = typeof r.spamfilter == "object" ? r.spamfilter : !!r.spamfilter), r.strings && t(42, l = r.strings), r.test !== void 0 && t(30, P = typeof r.test == "number" ? r.test : !!r.test), r.verifyurl !== void 0 && t(31, le = r.verifyurl), r.workers !== void 0 && t(32, be = +r.workers), r.workerurl !== void 0 && t(33, Te = r.workerurl); + } + function ve(r = y.UNVERIFIED, u = null) { + Q && (clearTimeout(Q), Q = null), t(8, O = !1), t(5, ye = u), t(6, ce = null), t(7, T = r); + } + async function ae() { + return ve(y.VERIFYING), await new Promise((r) => setTimeout(r, ee || 0)), Dt().then((r) => (qe(r), C("challenge", r), tt(r))).then(({ data: r, solution: u }) => { + if (C("solution", u), "challenge" in r && u && !("clearText" in u)) + if ((u == null ? void 0 : u.number) !== void 0) { + if (le) + return Kt(Qe(r, u)); + t(6, ce = Qe(r, u)), C("payload", ce); + } 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(() => { - rn().then(() => { - t(7, U = w.VERIFIED), t(8, Q = !0), k("verified"), Fe("verified", { payload: ne }); + _n().then(() => { + t(7, T = y.VERIFIED), t(8, O = !0), C("verified"), Ve("verified", { payload: ce }); }); }).catch((r) => { - k(r), t(7, U = w.ERROR), t(8, Q = !1), t(5, xe = r.message); + C(r), t(7, T = y.ERROR), t(8, O = !1), t(5, ye = r.message); }); } - function Ut() { - Q = this.checked, t(8, Q); + async function we() { + if (!E) { + t(7, T = y.ERROR); + return; + } + ve(y.VERIFYING), await new Promise((H) => setTimeout(H, ee || 0)); + const [r, u] = E.split("?"); + let g = new URLSearchParams(u || "").get("key") || void 0; + if (g) { + const H = g.match(/^\(prompt:?(.*)\)$/); + H && (g = prompt(H[1] || "Enter Key:") || void 0); + } + const { solution: V } = await tt({ obfuscated: r, key: g, maxnumber: I }); + V && "clearText" in V ? (t(41, J = V.clearText), t(7, T = y.VERIFIED), t(8, O = !0), A && _ && t(9, _.style.display = "none", _)) : (t(7, T = y.ERROR), t(8, O = !1), t(5, ye = "Unable to decrypt data.")); } - function Zt(r) { - ze[r ? "unshift" : "push"](() => { - te = r, t(10, te); + function Ot() { + O = this.checked, t(8, O); + } + function Jt(r) { + Ze[r ? "unshift" : "push"](() => { + se = r, t(10, se); }); } - function Vt(r) { - ze[r ? "unshift" : "push"](() => { - C = r, t(9, C); + function Qt(r) { + Ze[r ? "unshift" : "push"](() => { + _ = r, t(9, _); }); } 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); + "analytics" in r && t(18, d = r.analytics), "auto" in r && t(0, v = r.auto), "beaconurl" in r && t(19, R = r.beaconurl), "blockspam" in r && t(34, $ = r.blockspam), "challengeurl" in r && t(17, k = r.challengeurl), "challengejson" in r && t(35, K = r.challengejson), "debug" in r && t(20, X = r.debug), "delay" in r && t(21, ee = r.delay), "expire" in r && t(22, te = r.expire), "floating" in r && t(1, A = r.floating), "floatinganchor" in r && t(23, U = r.floatinganchor), "floatingoffset" in r && t(24, Z = r.floatingoffset), "hidefooter" in r && t(2, oe = r.hidefooter), "hidelogo" in r && t(3, ne = r.hidelogo), "name" in r && t(4, j = r.name), "maxnumber" in r && t(25, I = r.maxnumber), "mockerror" in r && t(26, z = r.mockerror), "obfuscated" in r && t(27, E = r.obfuscated), "refetchonexpire" in r && t(28, F = r.refetchonexpire), "spamfilter" in r && t(29, h = r.spamfilter), "strings" in r && t(36, x = r.strings), "test" in r && t(30, P = r.test), "verifyurl" in r && t(31, le = r.verifyurl), "workers" in r && t(32, be = r.workers), "workerurl" in r && t(33, Te = r.workerurl), "$$scope" in r && t(43, a = r.$$scope); }, 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, + 131072 && t(14, i = !!(k != null && k.includes(".altcha.org")) && !!(k != null && k.includes("apiKey=ckey_"))), n.$$.dirty[1] & /*challengejson*/ + 16 && (o = K ? Ct(K) : void 0), n.$$.dirty[1] & /*strings*/ + 32 && t(42, l = x ? Ct(x) : {}), n.$$.dirty[1] & /*parsedStrings*/ + 2048 && t(13, s = { + ariaLinkLabel: xt, 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.", - ...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(); + ...l + }), n.$$.dirty[0] & /*state, payload*/ + 192 | n.$$.dirty[1] & /*clarifiedData*/ + 1024 && Ve("statechange", J ? { clarifiedData: J, state: T } : { payload: ce, state: T }), n.$$.dirty[0] & /*error*/ + 32 && Mt(), n.$$.dirty[0] & /*state*/ + 128 && jt(), n.$$.dirty[1] & /*clarifiedData*/ + 1024 && Xt(); }, [ - l, - b, - j, - I, - F, - xe, + v, + A, + oe, ne, - U, - Q, - C, - te, - D, + j, + ye, + ce, + T, + O, + _, + se, + M, Be, - u, + s, i, - Ft, - $e, - g, - c, - f, - O, + Ut, + it, + k, + d, + R, X, - Y, - q, + ee, + te, + U, + Z, + I, + z, + E, + F, + h, + P, + le, + be, + Te, + $, K, x, - A, - h, - p, - H, - ee, - ue, - ke, - B, - G, - pe, - et, - Le, - re, - s, - Ut, - Zt, - Vt + st, + ve, + ae, + we, + J, + l, + a, + c, + Ot, + Jt, + Qt ]; } -class An extends mn { +class Pn extends An { constructor(e) { - super(), dn( + super(), Tn( this, e, - In, - Rn, - Ht, + Kn, + Bn, + on, { analytics: 18, auto: 0, beaconurl: 19, - blockspam: 33, + blockspam: 34, challengeurl: 17, - challengejson: 34, + challengejson: 35, debug: 20, delay: 21, expire: 22, @@ -1405,18 +1594,20 @@ class An extends mn { 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 + obfuscated: 27, + refetchonexpire: 28, + spamfilter: 29, + strings: 36, + test: 30, + verifyurl: 31, + workers: 32, + workerurl: 33, + configure: 37, + reset: 38, + verify: 39, + clarify: 40 }, - pn, + Yn, [-1, -1, -1] ); } @@ -1424,158 +1615,167 @@ class An extends mn { return this.$$.ctx[18]; } set analytics(e) { - this.$$set({ analytics: e }), _(); + this.$$set({ analytics: e }), p(); } get auto() { return this.$$.ctx[0]; } set auto(e) { - this.$$set({ auto: e }), _(); + this.$$set({ auto: e }), p(); } get beaconurl() { return this.$$.ctx[19]; } set beaconurl(e) { - this.$$set({ beaconurl: e }), _(); + this.$$set({ beaconurl: e }), p(); } get blockspam() { - return this.$$.ctx[33]; + return this.$$.ctx[34]; } set blockspam(e) { - this.$$set({ blockspam: e }), _(); + this.$$set({ blockspam: e }), p(); } get challengeurl() { return this.$$.ctx[17]; } set challengeurl(e) { - this.$$set({ challengeurl: e }), _(); + this.$$set({ challengeurl: e }), p(); } get challengejson() { - return this.$$.ctx[34]; + return this.$$.ctx[35]; } set challengejson(e) { - this.$$set({ challengejson: e }), _(); + this.$$set({ challengejson: e }), p(); } get debug() { return this.$$.ctx[20]; } set debug(e) { - this.$$set({ debug: e }), _(); + this.$$set({ debug: e }), p(); } get delay() { return this.$$.ctx[21]; } set delay(e) { - this.$$set({ delay: e }), _(); + this.$$set({ delay: e }), p(); } get expire() { return this.$$.ctx[22]; } set expire(e) { - this.$$set({ expire: e }), _(); + this.$$set({ expire: e }), p(); } get floating() { return this.$$.ctx[1]; } set floating(e) { - this.$$set({ floating: e }), _(); + this.$$set({ floating: e }), p(); } get floatinganchor() { return this.$$.ctx[23]; } set floatinganchor(e) { - this.$$set({ floatinganchor: e }), _(); + this.$$set({ floatinganchor: e }), p(); } get floatingoffset() { return this.$$.ctx[24]; } set floatingoffset(e) { - this.$$set({ floatingoffset: e }), _(); + this.$$set({ floatingoffset: e }), p(); } get hidefooter() { return this.$$.ctx[2]; } set hidefooter(e) { - this.$$set({ hidefooter: e }), _(); + this.$$set({ hidefooter: e }), p(); } get hidelogo() { return this.$$.ctx[3]; } set hidelogo(e) { - this.$$set({ hidelogo: e }), _(); + this.$$set({ hidelogo: e }), p(); } get name() { return this.$$.ctx[4]; } set name(e) { - this.$$set({ name: e }), _(); + this.$$set({ name: e }), p(); } get maxnumber() { return this.$$.ctx[25]; } set maxnumber(e) { - this.$$set({ maxnumber: e }), _(); + this.$$set({ maxnumber: e }), p(); } get mockerror() { return this.$$.ctx[26]; } set mockerror(e) { - this.$$set({ mockerror: e }), _(); + this.$$set({ mockerror: e }), p(); } - get refetchonexpire() { + get obfuscated() { return this.$$.ctx[27]; } + set obfuscated(e) { + this.$$set({ obfuscated: e }), p(); + } + get refetchonexpire() { + return this.$$.ctx[28]; + } set refetchonexpire(e) { - this.$$set({ refetchonexpire: e }), _(); + this.$$set({ refetchonexpire: e }), p(); } get spamfilter() { - return this.$$.ctx[28]; + return this.$$.ctx[29]; } set spamfilter(e) { - this.$$set({ spamfilter: e }), _(); + this.$$set({ spamfilter: e }), p(); } get strings() { - return this.$$.ctx[35]; + return this.$$.ctx[36]; } set strings(e) { - this.$$set({ strings: e }), _(); + this.$$set({ strings: e }), p(); } get test() { - return this.$$.ctx[29]; + return this.$$.ctx[30]; } set test(e) { - this.$$set({ test: e }), _(); + this.$$set({ test: e }), p(); } get verifyurl() { - return this.$$.ctx[30]; + return this.$$.ctx[31]; } set verifyurl(e) { - this.$$set({ verifyurl: e }), _(); + this.$$set({ verifyurl: e }), p(); } get workers() { - return this.$$.ctx[31]; + return this.$$.ctx[32]; } set workers(e) { - this.$$set({ workers: e }), _(); + this.$$set({ workers: e }), p(); } get workerurl() { - return this.$$.ctx[32]; + return this.$$.ctx[33]; } set workerurl(e) { - this.$$set({ workerurl: e }), _(); + this.$$set({ workerurl: e }), p(); } get configure() { - return this.$$.ctx[36]; + return this.$$.ctx[37]; } get reset() { - return this.$$.ctx[37]; + return this.$$.ctx[38]; } get verify() { - return this.$$.ctx[38]; + return this.$$.ctx[39]; + } + get clarify() { + return this.$$.ctx[40]; } } -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(); +customElements.define("altcha-widget", Nn(Pn, { 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" }, obfuscated: {}, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, ["default"], ["configure", "reset", "verify", "clarify"], !1)); +globalThis.createAltchaWorker = (n) => n ? new Worker(new URL(n)) : new nn(); export { - An as Altcha + Pn as Altcha }; diff --git a/dist/altcha.umd.cjs b/dist/altcha.umd.cjs index 032049a..1db302f 100644 --- a/dist/altcha.umd.cjs +++ b/dist/altcha.umd.cjs @@ -1,2 +1,2 @@ -(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"})}); +(function(w,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(w=typeof globalThis<"u"?globalThis:w||self,p(w.altcha={}))})(this,function(w){"use strict";var Pn=Object.defineProperty;var Dt=w=>{throw TypeError(w)};var On=(w,p,M)=>p in w?Pn(w,p,{enumerable:!0,configurable:!0,writable:!0,value:M}):w[p]=M;var X=(w,p,M)=>On(w,typeof p!="symbol"?p+"":p,M),Yt=(w,p,M)=>p.has(w)||Dt("Cannot "+M);var P=(w,p,M)=>(Yt(w,p,"read from private field"),M?M.call(w):p.get(w)),he=(w,p,M)=>p.has(w)?Dt("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(w):p.set(w,M),Ut=(w,p,M,we)=>(Yt(w,p,"write to private field"),we?we.call(w,M):p.set(w,M),M);var ye,ve,Ee,xe,Ce,Re;const p="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIHAoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiB3KGUsdCxyKXtyZXR1cm4gcChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChyLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGIoZSx0LHI9IlNIQS0yNTYiLG49MWU2LHM9MCl7Y29uc3Qgbz1uZXcgQWJvcnRDb250cm9sbGVyLGE9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgYz1zO2M8PW47Yys9MSl7aWYoby5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCB3KHQsYyxyKT09PWUpcmV0dXJue251bWJlcjpjLHRvb2s6RGF0ZS5ub3coKS1hfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjpvfX1mdW5jdGlvbiBoKGUpe2NvbnN0IHQ9YXRvYihlKSxyPW5ldyBVaW50OEFycmF5KHQubGVuZ3RoKTtmb3IobGV0IG49MDtuPHQubGVuZ3RoO24rKylyW25dPXQuY2hhckNvZGVBdChuKTtyZXR1cm4gcn1mdW5jdGlvbiBnKGUsdD0xMil7Y29uc3Qgcj1uZXcgVWludDhBcnJheSh0KTtmb3IobGV0IG49MDtuPHQ7bisrKXJbbl09ZSUyNTYsZT1NYXRoLmZsb29yKGUvMjU2KTtyZXR1cm4gcn1hc3luYyBmdW5jdGlvbiBtKGUsdD0iIixyPTFlNixuPTApe2NvbnN0IHM9IkFFUy1HQ00iLG89bmV3IEFib3J0Q29udHJvbGxlcixhPURhdGUubm93KCksbD1hc3luYygpPT57Zm9yKGxldCB1PW47dTw9cjt1Kz0xKXtpZihvLnNpZ25hbC5hYm9ydGVkfHwhY3x8IXkpcmV0dXJuIG51bGw7dHJ5e2NvbnN0IGQ9YXdhaXQgY3J5cHRvLnN1YnRsZS5kZWNyeXB0KHtuYW1lOnMsaXY6Zyh1KX0sYyx5KTtpZihkKXJldHVybntjbGVhclRleHQ6bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKGQpLHRvb2s6RGF0ZS5ub3coKS1hfX1jYXRjaHt9fXJldHVybiBudWxsfTtsZXQgYz1udWxsLHk9bnVsbDt0cnl7eT1oKGUpO2NvbnN0IHU9YXdhaXQgY3J5cHRvLnN1YnRsZS5kaWdlc3QoIlNIQS0yNTYiLGYuZW5jb2RlKHQpKTtjPWF3YWl0IGNyeXB0by5zdWJ0bGUuaW1wb3J0S2V5KCJyYXciLHUscywhMSxbImRlY3J5cHQiXSl9Y2F0Y2h7cmV0dXJue3Byb21pc2U6UHJvbWlzZS5yZWplY3QoKSxjb250cm9sbGVyOm99fXJldHVybntwcm9taXNlOmwoKSxjb250cm9sbGVyOm99fWxldCBpO29ubWVzc2FnZT1hc3luYyBlPT57Y29uc3R7dHlwZTp0LHBheWxvYWQ6cixzdGFydDpuLG1heDpzfT1lLmRhdGE7bGV0IG89bnVsbDtpZih0PT09ImFib3J0IilpPT1udWxsfHxpLmFib3J0KCksaT12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtpZigib2JmdXNjYXRlZCJpbiByKXtjb25zdHtrZXk6YSxvYmZ1c2NhdGVkOmx9PXJ8fHt9O289YXdhaXQgbShsLGEscyxuKX1lbHNle2NvbnN0e2FsZ29yaXRobTphLGNoYWxsZW5nZTpsLHNhbHQ6Y309cnx8e307bz1iKGwsYyxhLHMsbil9aT1vLmNvbnRyb2xsZXIsby5wcm9taXNlLnRoZW4oYT0+e3NlbGYucG9zdE1lc3NhZ2UoYSYmey4uLmEsd29ya2VyOiEwfSl9KX19fSkoKTsK",M=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),we=typeof self<"u"&&self.Blob&&new Blob([M(p)],{type:"text/javascript;charset=utf-8"});function Xt(n){let e;try{if(e=we&&(self.URL||self.webkitURL).createObjectURL(we),!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 Se(){}function Mt(n,e){for(const t in e)n[t]=e[t];return n}function Pe(n){return n()}function Oe(){return Object.create(null)}function pe(n){n.forEach(Pe)}function Je(n){return typeof n=="function"}function jt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Wt(n){return Object.keys(n).length===0}function Bt(n,e,t,i){if(n){const o=Qe(n,e,t,i);return n[0](o)}}function Qe(n,e,t,i){return n[1]&&i?Mt(t.ctx.slice(),n[1](i(e))):t.ctx}function Kt(n,e,t,i){if(n[2]&&i){const o=n[2](i(t));if(e.dirty===void 0)return o;if(typeof o=="object"){const l=[],s=Math.max(e.dirty.length,o.length);for(let a=0;a32){const e=[],t=n.ctx.length/32;for(let i=0;in.removeEventListener(e,t,i)}function c(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function en(n){return Array.from(n.childNodes)}function $e(n,e,t){n.classList.toggle(e,!!t)}function tn(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function nn(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let _e;function ke(n){_e=n}function Ue(){if(!_e)throw new Error("Function called outside component initialization");return _e}function rn(n){Ue().$$.on_mount.push(n)}function on(n){Ue().$$.on_destroy.push(n)}function ln(){const n=Ue();return(e,t,{cancelable:i=!1}={})=>{const o=n.$$.callbacks[e];if(o){const l=tn(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(n,l)}),!l.defaultPrevented}return!0}}const me=[],Fe=[];let be=[];const et=[],tt=Promise.resolve();let Xe=!1;function nt(){Xe||(Xe=!0,tt.then(_))}function sn(){return nt(),tt}function Me(n){be.push(n)}const je=new Set;let ge=0;function _(){if(ge!==0)return;const n=_e;do{try{for(;gen.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),be=e}const Ze=new Set;let fn;function rt(n,e){n&&n.i&&(Ze.delete(n),n.i(e))}function un(n,e,t,i){if(n&&n.o){if(Ze.has(n))return;Ze.add(n),fn.c.push(()=>{Ze.delete(n)}),n.o(e)}}function dn(n,e,t){const{fragment:i,after_update:o}=n.$$;i&&i.m(e,t),Me(()=>{const l=n.$$.on_mount.map(Pe).filter(Je);n.$$.on_destroy?n.$$.on_destroy.push(...l):pe(l),n.$$.on_mount=[]}),o.forEach(Me)}function hn(n,e){const t=n.$$;t.fragment!==null&&(an(t.after_update),pe(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function mn(n,e){n.$$.dirty[0]===-1&&(me.push(n),nt(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const J=x.length?x[0]:re;return d.ctx&&o(d.ctx[T],d.ctx[T]=J)&&(!d.skip_bound&&d.bound[T]&&d.bound[T](J),v&&mn(n,T)),re}):[],d.update(),v=!0,pe(d.before_update),d.fragment=i?i(d.ctx):!1,e.target){if(e.hydrate){const T=en(e.target);d.fragment&&d.fragment.l(T),T.forEach(S)}else d.fragment&&d.fragment.c();e.intro&&rt(n.$$.fragment),dn(n,e.target,e.anchor),_()}ke(f)}let it;typeof HTMLElement=="function"&&(it=class extends HTMLElement{constructor(e,t,i){super();X(this,"$$ctor");X(this,"$$s");X(this,"$$c");X(this,"$$cn",!1);X(this,"$$d",{});X(this,"$$r",!1);X(this,"$$p_d",{});X(this,"$$l",{});X(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 s;return{c:function(){s=A("slot"),l!=="default"&&c(s,"name",l)},m:function(d,v){H(d,s,v)},d:function(d){d&&S(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=nn(this);for(const l of this.$$s)l in i&&(t[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=Ve(s,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 s=Ve(l,this.$$d[l],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const s of this.$$l[l]){const a=this.$$c.$on(l,s);this.$$l_u.set(s,a)}this.$$l={}}}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]}))}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 Ve(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])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 gn(n,e,t,i,o,l){let s=class extends it{constructor(){super(n,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(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(f){var d;f=Ve(a,f,e),this.$$d[a]=f,(d=this.$$c)==null||d.$set({[a]:f})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var f;return(f=this.$$c)==null?void 0:f[a]}})}),n.element=s,s}class yn{constructor(){X(this,"$$");X(this,"$$set")}$destroy(){hn(this,1),this.$destroy=Se}$on(e,t){if(!Je(t))return Se;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&&!Wt(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const vn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(vn);const ot=new TextEncoder;function wn(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function pn(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await lt(i,n,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function lt(n,e,t){return wn(await crypto.subtle.digest(t.toUpperCase(),ot.encode(n+e)))}function _n(n,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let f=o;f<=i;f+=1){if(l.signal.aborted)return null;if(await lt(e,f,t)===n)return{number:f,took:Date.now()-s}}return null})(),controller:l}}function st(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function kn(n){const e=atob(n),t=new Uint8Array(e.length);for(let i=0;i{for(let v=i;v<=t;v+=1){if(l.signal.aborted||!f||!d)return null;try{const T=await crypto.subtle.decrypt({name:o,iv:En(v)},f,d);if(T)return{clearText:new TextDecoder().decode(T),took:Date.now()-s}}catch{}}return null};let f=null,d=null;try{d=kn(n);const v=await crypto.subtle.digest("SHA-256",ot.encode(e));f=await crypto.subtle.importKey("raw",v,o,!1,["decrypt"])}catch{return{promise:Promise.reject(),controller:l}}return{promise:a(),controller:l}}class Cn{constructor(e){X(this,"beaconUrl",null);X(this,"error",null);X(this,"loadTime",Date.now());X(this,"submitTime",null);X(this,"startTime",null);X(this,"viewTimeThresholdMs",1500);he(this,ye,{});he(this,ve,null);he(this,Ee,this.onFormChange.bind(this));he(this,xe,this.onFormFocus.bind(this));he(this,Ce,this.onFormSubmit.bind(this));he(this,Re,this.onUnload.bind(this));this.elForm=e,window.addEventListener("unload",P(this,Re)),this.elForm.addEventListener("change",P(this,Ee)),this.elForm.addEventListener("focusin",P(this,xe)),this.elForm.addEventListener("submit",P(this,Ce))}data(){const e=Object.entries(P(this,ye));return{correction:e.length&&e.filter(([t,i])=>i>1).length/e.length||0,dropoff:!this.submitTime&&!this.error&&P(this,ve)?P(this,ve):null,error:this.error,mobile:this.isMobile(),start:this.startTime,submit:this.submitTime,tz:st()}}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",P(this,Re)),this.elForm.removeEventListener("change",P(this,Ee)),this.elForm.removeEventListener("focusin",P(this,xe)),this.elForm.removeEventListener("submit",P(this,Ce))}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&&Ut(this,ve,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){P(this,ye)[e]=(P(this,ye)[e]||0)+1}}ye=new WeakMap,ve=new WeakMap,Ee=new WeakMap,xe=new WeakMap,Ce=new WeakMap,Re=new WeakMap;var g=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(g||{});function Rn(n){Jt(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 ct(n){let e,t,i;return{c(){e=ne("svg"),t=ne("path"),i=ne("path"),c(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"),c(t,"fill","currentColor"),c(t,"opacity",".25"),c(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"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-ddsc3z"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){H(o,e,l),I(e,t),I(e,i)},d(o){o&&S(e)}}}function Ln(n){let e,t=n[13].label+"",i;return{c(){e=A("label"),c(e,"for",i=n[4]+"_checkbox"),c(e,"class","svelte-ddsc3z")},m(o,l){H(o,e,l),e.innerHTML=t},p(o,l){l[0]&8192&&t!==(t=o[13].label+"")&&(e.innerHTML=t),l[0]&16&&i!==(i=o[4]+"_checkbox")&&c(e,"for",i)},d(o){o&&S(e)}}}function In(n){let e,t=n[13].verifying+"";return{c(){e=A("span")},m(i,o){H(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 Tn(n){let e,t=n[13].verified+"",i,o,l,s,a=n[11]&&at(n);return{c(){e=A("span"),i=q(),o=A("input"),l=q(),a&&a.c(),s=$t(),c(o,"type","hidden"),c(o,"name",n[4]),o.value=n[6]},m(f,d){H(f,e,d),e.innerHTML=t,H(f,i,d),H(f,o,d),H(f,l,d),a&&a.m(f,d),H(f,s,d)},p(f,d){d[0]&8192&&t!==(t=f[13].verified+"")&&(e.innerHTML=t),d[0]&16&&c(o,"name",f[4]),d[0]&64&&(o.value=f[6]),f[11]?a?a.p(f,d):(a=at(f),a.c(),a.m(s.parentNode,s)):a&&(a.d(1),a=null)},d(f){f&&(S(e),S(i),S(o),S(l),S(s)),a&&a.d(f)}}}function at(n){let e;return{c(){e=A("input"),c(e,"type","hidden"),c(e,"name","__session"),e.value=n[12]},m(t,i){H(t,e,i)},p(t,i){i[0]&4096&&(e.value=t[12])},d(t){t&&S(e)}}}function ft(n){let e,t,i,o,l,s,a;return{c(){e=A("div"),t=A("a"),i=ne("svg"),o=ne("path"),l=ne("path"),s=ne("path"),c(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"),c(o,"fill","currentColor"),c(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"),c(l,"fill","currentColor"),c(s,"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"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(t,"href",bt),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-ddsc3z"),c(t,"aria-label",a=n[13].ariaLinkLabel)},m(f,d){H(f,e,d),I(e,t),I(t,i),I(i,o),I(i,l),I(i,s)},p(f,d){d[0]&8192&&a!==(a=f[13].ariaLinkLabel)&&c(t,"aria-label",a)},d(f){f&&S(e)}}}function ut(n){let e,t,i,o;function l(f,d){return f[7]===g.EXPIRED?An:Nn}let s=l(n),a=s(n);return{c(){e=A("div"),t=ne("svg"),i=ne("path"),o=q(),a.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(t,"width","14"),c(t,"height","14"),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"fill","none"),c(t,"viewBox","0 0 24 24"),c(t,"stroke-width","1.5"),c(t,"stroke","currentColor"),c(e,"class","altcha-error svelte-ddsc3z")},m(f,d){H(f,e,d),I(e,t),I(t,i),I(e,o),a.m(e,null)},p(f,d){s===(s=l(f))&&a?a.p(f,d):(a.d(1),a=s(f),a&&(a.c(),a.m(e,null)))},d(f){f&&S(e),a.d()}}}function Nn(n){let e,t=n[13].error+"";return{c(){e=A("div"),c(e,"title",n[5])},m(i,o){H(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].error+"")&&(e.innerHTML=t),o[0]&32&&c(e,"title",i[5])},d(i){i&&S(e)}}}function An(n){let e,t=n[13].expired+"";return{c(){e=A("div"),c(e,"title",n[5])},m(i,o){H(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].expired+"")&&(e.innerHTML=t),o[0]&32&&c(e,"title",i[5])},d(i){i&&S(e)}}}function dt(n){let e,t,i=n[13].footer+"";return{c(){e=A("div"),t=A("div"),c(t,"class","svelte-ddsc3z"),c(e,"class","altcha-footer svelte-ddsc3z")},m(o,l){H(o,e,l),I(e,t),t.innerHTML=i},p(o,l){l[0]&8192&&i!==(i=o[13].footer+"")&&(t.innerHTML=i)},d(o){o&&S(e)}}}function ht(n){let e;return{c(){e=A("div"),c(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){H(t,e,i),n[46](e)},p:Se,d(t){t&&S(e),n[46](null)}}}function zn(n){let e,t,i,o,l,s,a,f,d,v,T,re,x,J,W,ie,oe;const F=n[44].default,j=Bt(F,n,n[43],null);let G=n[7]===g.VERIFYING&&ct();function ce(h,R){return h[7]===g.VERIFIED?Tn:h[7]===g.VERIFYING?In:Ln}let le=ce(n),K=le(n),N=(n[3]!==!0||n[14])&&ft(n),Z=(n[5]||n[7]===g.EXPIRED)&&ut(n),C=n[13].footer&&(n[2]!==!0||n[14])&&dt(n),V=n[1]&&ht(n);return{c(){j&&j.c(),e=q(),t=A("div"),i=A("div"),G&&G.c(),o=q(),l=A("div"),s=A("input"),d=q(),v=A("div"),K.c(),T=q(),N&&N.c(),re=q(),Z&&Z.c(),x=q(),C&&C.c(),J=q(),V&&V.c(),c(s,"type","checkbox"),c(s,"id",a=n[4]+"_checkbox"),s.required=f=n[0]!=="onsubmit",c(s,"class","svelte-ddsc3z"),c(l,"class","altcha-checkbox svelte-ddsc3z"),$e(l,"altcha-hidden",n[7]===g.VERIFYING),c(v,"class","altcha-label svelte-ddsc3z"),c(i,"class","altcha-main svelte-ddsc3z"),c(t,"class","altcha svelte-ddsc3z"),c(t,"data-state",n[7]),c(t,"data-floating",n[1])},m(h,R){j&&j.m(h,R),H(h,e,R),H(h,t,R),I(t,i),G&&G.m(i,null),I(i,o),I(i,l),I(l,s),s.checked=n[8],I(i,d),I(i,v),K.m(v,null),I(i,T),N&&N.m(i,null),I(t,re),Z&&Z.m(t,null),I(t,x),C&&C.m(t,null),I(t,J),V&&V.m(t,null),n[47](t),W=!0,ie||(oe=[Ye(s,"change",n[45]),Ye(s,"change",n[15]),Ye(s,"invalid",n[16])],ie=!0)},p(h,R){j&&j.p&&(!W||R[1]&4096)&&Pt(j,F,h,h[43],W?Kt(F,h[43],R,null):Ot(h[43]),null),h[7]===g.VERIFYING?G||(G=ct(),G.c(),G.m(i,o)):G&&(G.d(1),G=null),(!W||R[0]&16&&a!==(a=h[4]+"_checkbox"))&&c(s,"id",a),(!W||R[0]&1&&f!==(f=h[0]!=="onsubmit"))&&(s.required=f),R[0]&256&&(s.checked=h[8]),(!W||R[0]&128)&&$e(l,"altcha-hidden",h[7]===g.VERIFYING),le===(le=ce(h))&&K?K.p(h,R):(K.d(1),K=le(h),K&&(K.c(),K.m(v,null))),h[3]!==!0||h[14]?N?N.p(h,R):(N=ft(h),N.c(),N.m(i,null)):N&&(N.d(1),N=null),h[5]||h[7]===g.EXPIRED?Z?Z.p(h,R):(Z=ut(h),Z.c(),Z.m(t,x)):Z&&(Z.d(1),Z=null),h[13].footer&&(h[2]!==!0||h[14])?C?C.p(h,R):(C=dt(h),C.c(),C.m(t,J)):C&&(C.d(1),C=null),h[1]?V?V.p(h,R):(V=ht(h),V.c(),V.m(t,null)):V&&(V.d(1),V=null),(!W||R[0]&128)&&c(t,"data-state",h[7]),(!W||R[0]&2)&&c(t,"data-floating",h[1])},i(h){W||(rt(j,h),W=!0)},o(h){un(j,h),W=!1},d(h){h&&(S(e),S(t)),j&&j.d(h),G&&G.d(),K.d(),N&&N.d(),Z&&Z.d(),C&&C.d(),V&&V.d(),n[47](null),ie=!1,pe(oe)}}}const mt="Visit Altcha.org",bt="https://altcha.org/";function gt(n){return JSON.parse(n)}function Sn(n,e,t){var Vt,Ht;let i,o,l,s,{$$slots:a={},$$scope:f}=e,{analytics:d=!1}=e,{auto:v=void 0}=e,{beaconurl:T=void 0}=e,{blockspam:re=void 0}=e,{challengeurl:x=void 0}=e,{challengejson:J=void 0}=e,{debug:W=!1}=e,{delay:ie=0}=e,{expire:oe=void 0}=e,{floating:F=void 0}=e,{floatinganchor:j=void 0}=e,{floatingoffset:G=void 0}=e,{hidefooter:ce=!1}=e,{hidelogo:le=!1}=e,{name:K="altcha"}=e,{maxnumber:N=1e6}=e,{mockerror:Z=!1}=e,{obfuscated:C=void 0}=e,{refetchonexpire:V=!0}=e,{spamfilter:h=!1}=e,{strings:R=void 0}=e,{test:Q=!1}=e,{verifyurl:ae=void 0}=e,{workers:Le=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:He=void 0}=e;const We=ln(),vt=["SHA-256","SHA-384","SHA-512"],wt=(Ht=(Vt=document.documentElement.lang)==null?void 0:Vt.split("-"))==null?void 0:Ht[0];let $=!1,ee=null,E,fe=null,Ge=null,y=null,se=null,Ie=null,te=null,ue=null,B=null,pt=null,z=g.UNVERIFIED;on(()=>{y&&(y.removeEventListener("submit",Et),y.removeEventListener("reset",xt),y.removeEventListener("focusin",kt),y=null),se&&E.removeEventListener("click",_t),B&&B.destroy(),te&&(clearTimeout(te),te=null),document.removeEventListener("click",Nt),document.removeEventListener("scroll",At),window.removeEventListener("resize",St)}),rn(()=>{var r,u;L("mounted","0.8.0"),L("workers",Le),Q&&L("using test mode"),oe&&De(oe),v!==void 0&&L("auto",v),F!==void 0&&Ft(F),y=E.closest("form"),y&&(y.addEventListener("submit",Et,{capture:!0}),y.addEventListener("reset",xt),v==="onfocus"&&y.addEventListener("focusin",kt)),se=((r=E.parentElement)==null?void 0:r.querySelector("[data-clarify-button]"))||((u=E.parentElement)==null?void 0:u.querySelector("button, a")),se&&se.addEventListener("click",_t),d&&Lt(),v==="onload"&&(C?Ne():de()),i&&(ce||le)&&L("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.")});function L(...r){(W||r.some(u=>u instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",...r)}function _t(r){r.preventDefault(),z===g.UNVERIFIED&&Ne()}function kt(r){z===g.UNVERIFIED&&de()}function Et(r){y&&B&&z===g.VERIFIED&&(B.end(),t(12,pt=B.dataAsBase64())),y&&v==="onsubmit"&&(z===g.UNVERIFIED?(r.preventDefault(),r.stopPropagation(),de().then(()=>{y==null||y.requestSubmit()})):z!==g.VERIFIED&&(r.preventDefault(),r.stopPropagation(),z===g.VERIFYING&&zt()))}function xt(){Te()}function Ct(r,u){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:u.number,salt:r.salt,signature:r.signature,test:Q?!0:void 0,took:u.took}))}function Rt(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(!vt.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${vt.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 Fn(){var r;if(Z)throw L("mocking error"),new Error("Mocked error.");if(o)return L("using provided json data"),o;if(Q)return L("generating test challenge",{test:Q}),pn(typeof Q!="boolean"?+Q:void 0);{if(!x&&y){const k=y.getAttribute("action");k!=null&&k.includes("/form/")&&t(17,x=k+"/altcha")}if(!x)throw new Error("Attribute challengeurl not set.");L("fetching challenge from",x);const u=await fetch(x,{headers:h?{"x-altcha-spam-filter":"1"}:{}});if(u.status!==200)throw new Error(`Server responded with ${u.status}.`);const m=u.headers.get("Expires"),b=u.headers.get("X-Altcha-Config"),D=await u.json(),Y=new URLSearchParams((r=D.salt.split("?"))==null?void 0:r[1]),U=Y.get("expires")||Y.get("expire");if(U){const k=new Date(+U*1e3),O=isNaN(k.getTime())?0:k.getTime()-Date.now();O>0&&De(O)}if(b)try{const k=JSON.parse(b);k&&typeof k=="object"&&(k.verifyurl&&(k.verifyurl=new URL(k.verifyurl,new URL(x)).toString()),Zt(k))}catch(k){L("unable to configure from X-Altcha-Config",k)}if(!oe&&(m!=null&&m.length)){const k=Date.parse(m);if(k){const O=k-Date.now();O>0&&De(O)}}return D}}function Lt(){if(!B)if(y){if(L("analytics enabled"),t(11,B=new Cn(y)),T===void 0){const r=y.getAttribute("action");r&&t(19,T=r+"/beacon")}t(11,B.beaconUrl=T||null,B)}else L("analytics cannot be enabled - form element not found")}function It(){x&&V&&z===g.VERIFIED?de():Te(g.EXPIRED,s.expired)}async function Tt(r){let u=null;if("Worker"in window){try{u=await Zn(r,r.maxnumber)}catch(m){L(m)}if((u==null?void 0:u.number)!==void 0||"obfuscated"in r)return{data:r,solution:u}}if("obfuscated"in r){const m=await xn(r.obfuscated,r.key,r.maxnumber);return{data:r,solution:await m.promise}}return{data:r,solution:await _n(r.challenge,r.salt,r.algorithm,r.maxnumber||N).promise}}async function Zn(r,u=typeof Q=="number"?Q:N,m=Math.ceil(Le)){const b=[];m=Math.min(16,Math.max(1,m));for(let U=0;U{const O=k*D;return new Promise(Ke=>{U.addEventListener("message",Ae=>{if(Ae.data)for(const ze of b)ze!==U&&ze.postMessage({type:"abort"});Ke(Ae.data)}),U.postMessage({payload:r,max:O+D,start:O,type:"work"})})}));for(const U of b)U.terminate();return Y.find(U=>!!U)||null}function Vn(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(z)?h&&(y==null?void 0:y.reportValidity())===!1?t(8,$=!1):C?Ne():de():t(8,$=!0)}function Nt(r){const u=r.target;F&&u&&!E.contains(u)&&z===g.VERIFIED&&t(9,E.style.display="none",E)}function At(){F&&Be()}function zt(){z===g.VERIFYING&&s.waitAlert&&alert(s.waitAlert)}function Hn(r){var u;if(ee){const m=ee.match(/^(mailto|tel|sms|https?):/);let b;if(m){const[D]=ee.slice(ee.indexOf(":")+1).replace(/^\/\//,"").split("?");b=document.createElement("a"),b.href=ee,b.innerHTML=D}else b=document.createTextNode(ee);se&&b&&(se.after(b),(u=se.parentElement)==null||u.removeChild(se))}}function Gn(r){B&&B.trackError(Ie)}function Dn(r){F&&z!==g.UNVERIFIED&&requestAnimationFrame(()=>{Be()})}function St(){F&&Be()}function De(r){L("expire",r),te&&(clearTimeout(te),te=null),r<1?It():te=setTimeout(It,r)}function Ft(r){L("floating",r),F!==r&&(t(9,E.style.left="",E),t(9,E.style.top="",E)),t(1,F=r===!0||r===""?"auto":r===!1||r==="false"?void 0:F),F?(v||t(0,v="onsubmit"),document.addEventListener("scroll",At),document.addEventListener("click",Nt),window.addEventListener("resize",St)):v==="onsubmit"&&t(0,v=void 0)}function Yn(r){var m;const u=y==null?void 0:y.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((m=u==null?void 0:u.value)==null?void 0:m.slice(u.value.indexOf("@")))||void 0}function Un(r){return[...(y==null?void 0:y.querySelectorAll(r!=null&&r.length?r.map(m=>`input[name="${m}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((m,b)=>{const D=b.name,Y=b.value;return D&&Y&&(m[D]=/\n/.test(Y)?Y.replace(new RegExp("(?D:F==="top",k=Math.max(r,Math.min(Y-r-b.width,m.left+m.width/2-b.width/2));if(U?t(9,E.style.top=`${m.top-(b.height+u)}px`,E):t(9,E.style.top=`${m.bottom+u}px`,E),t(9,E.style.left=`${k}px`,E),E.setAttribute("data-floating",U?"top":"bottom"),fe){const O=fe.getBoundingClientRect();t(10,fe.style.left=m.left-k+m.width/2-O.width/2+"px",fe)}}else L("unable to find floating anchor element")}function Zt(r){r.analytics&&(t(18,d=r.analytics),Lt()),r.obfuscated!==void 0&&t(27,C=r.obfuscated),r.auto!==void 0&&(t(0,v=r.auto),v==="onload"&&(C?Ne():de())),r.beaconurl&&(t(19,T=r.beaconurl),B&&t(11,B.beaconUrl=T,B)),r.floatinganchor!==void 0&&t(23,j=r.floatinganchor),r.delay!==void 0&&t(21,ie=r.delay),r.floatingoffset!==void 0&&t(24,G=r.floatingoffset),r.floating!==void 0&&Ft(r.floating),r.expire!==void 0&&(De(r.expire),t(22,oe=r.expire)),r.challenge&&(Rt(r.challenge),o=r.challenge),r.challengeurl!==void 0&&t(17,x=r.challengeurl),r.debug!==void 0&&t(20,W=!!r.debug),r.hidefooter!==void 0&&t(2,ce=!!r.hidefooter),r.hidelogo!==void 0&&t(3,le=!!r.hidelogo),r.maxnumber!==void 0&&t(25,N=+r.maxnumber),r.mockerror!==void 0&&t(26,Z=!!r.mockerror),r.name!==void 0&&t(4,K=r.name),r.refetchonexpire!==void 0&&t(28,V=!!r.refetchonexpire),r.spamfilter!==void 0&&t(29,h=typeof r.spamfilter=="object"?r.spamfilter:!!r.spamfilter),r.strings&&t(42,l=r.strings),r.test!==void 0&&t(30,Q=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(31,ae=r.verifyurl),r.workers!==void 0&&t(32,Le=+r.workers),r.workerurl!==void 0&&t(33,He=r.workerurl)}function Te(r=g.UNVERIFIED,u=null){te&&(clearTimeout(te),te=null),t(8,$=!1),t(5,Ie=u),t(6,ue=null),t(7,z=r)}async function de(){return Te(g.VERIFYING),await new Promise(r=>setTimeout(r,ie||0)),Fn().then(r=>(Rt(r),L("challenge",r),Tt(r))).then(({data:r,solution:u})=>{if(L("solution",u),"challenge"in r&&u&&!("clearText"in u))if((u==null?void 0:u.number)!==void 0){if(ae)return Xn(Ct(r,u));t(6,ue=Ct(r,u)),L("payload",ue)}else throw L("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{sn().then(()=>{t(7,z=g.VERIFIED),t(8,$=!0),L("verified"),We("verified",{payload:ue})})}).catch(r=>{L(r),t(7,z=g.ERROR),t(8,$=!1),t(5,Ie=r.message)})}async function Ne(){if(!C){t(7,z=g.ERROR);return}Te(g.VERIFYING),await new Promise(Y=>setTimeout(Y,ie||0));const[r,u]=C.split("?");let b=new URLSearchParams(u||"").get("key")||void 0;if(b){const Y=b.match(/^\(prompt:?(.*)\)$/);Y&&(b=prompt(Y[1]||"Enter Key:")||void 0)}const{solution:D}=await Tt({obfuscated:r,key:b,maxnumber:N});D&&"clearText"in D?(t(41,ee=D.clearText),t(7,z=g.VERIFIED),t(8,$=!0),F&&E&&t(9,E.style.display="none",E)):(t(7,z=g.ERROR),t(8,$=!1),t(5,Ie="Unable to decrypt data."))}function jn(){$=this.checked,t(8,$)}function Wn(r){Fe[r?"unshift":"push"](()=>{fe=r,t(10,fe)})}function Bn(r){Fe[r?"unshift":"push"](()=>{E=r,t(9,E)})}return n.$$set=r=>{"analytics"in r&&t(18,d=r.analytics),"auto"in r&&t(0,v=r.auto),"beaconurl"in r&&t(19,T=r.beaconurl),"blockspam"in r&&t(34,re=r.blockspam),"challengeurl"in r&&t(17,x=r.challengeurl),"challengejson"in r&&t(35,J=r.challengejson),"debug"in r&&t(20,W=r.debug),"delay"in r&&t(21,ie=r.delay),"expire"in r&&t(22,oe=r.expire),"floating"in r&&t(1,F=r.floating),"floatinganchor"in r&&t(23,j=r.floatinganchor),"floatingoffset"in r&&t(24,G=r.floatingoffset),"hidefooter"in r&&t(2,ce=r.hidefooter),"hidelogo"in r&&t(3,le=r.hidelogo),"name"in r&&t(4,K=r.name),"maxnumber"in r&&t(25,N=r.maxnumber),"mockerror"in r&&t(26,Z=r.mockerror),"obfuscated"in r&&t(27,C=r.obfuscated),"refetchonexpire"in r&&t(28,V=r.refetchonexpire),"spamfilter"in r&&t(29,h=r.spamfilter),"strings"in r&&t(36,R=r.strings),"test"in r&&t(30,Q=r.test),"verifyurl"in r&&t(31,ae=r.verifyurl),"workers"in r&&t(32,Le=r.workers),"workerurl"in r&&t(33,He=r.workerurl),"$$scope"in r&&t(43,f=r.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&131072&&t(14,i=!!(x!=null&&x.includes(".altcha.org"))&&!!(x!=null&&x.includes("apiKey=ckey_"))),n.$$.dirty[1]&16&&(o=J?gt(J):void 0),n.$$.dirty[1]&32&&t(42,l=R?gt(R):{}),n.$$.dirty[1]&2048&&t(13,s={ariaLinkLabel:mt,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]&192|n.$$.dirty[1]&1024&&We("statechange",ee?{clarifiedData:ee,state:z}:{payload:ue,state:z}),n.$$.dirty[0]&32&&Gn(),n.$$.dirty[0]&128&&Dn(),n.$$.dirty[1]&1024&&Hn()},[v,F,ce,le,K,Ie,ue,z,$,E,fe,B,pt,s,i,Vn,zt,x,d,T,W,ie,oe,j,G,N,Z,C,V,h,Q,ae,Le,He,re,J,R,Zt,Te,de,Ne,ee,l,f,a,jn,Wn,Bn]}class yt extends yn{constructor(e){super(),bn(this,e,Sn,zn,jt,{analytics:18,auto:0,beaconurl:19,blockspam:34,challengeurl:17,challengejson:35,debug:20,delay:21,expire:22,floating:1,floatinganchor:23,floatingoffset:24,hidefooter:2,hidelogo:3,name:4,maxnumber:25,mockerror:26,obfuscated:27,refetchonexpire:28,spamfilter:29,strings:36,test:30,verifyurl:31,workers:32,workerurl:33,configure:37,reset:38,verify:39,clarify:40},Rn,[-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}),_()}get beaconurl(){return this.$$.ctx[19]}set beaconurl(e){this.$$set({beaconurl:e}),_()}get blockspam(){return this.$$.ctx[34]}set blockspam(e){this.$$set({blockspam:e}),_()}get challengeurl(){return this.$$.ctx[17]}set challengeurl(e){this.$$set({challengeurl:e}),_()}get challengejson(){return this.$$.ctx[35]}set challengejson(e){this.$$set({challengejson:e}),_()}get debug(){return this.$$.ctx[20]}set debug(e){this.$$set({debug:e}),_()}get delay(){return this.$$.ctx[21]}set delay(e){this.$$set({delay:e}),_()}get expire(){return this.$$.ctx[22]}set expire(e){this.$$set({expire:e}),_()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),_()}get floatinganchor(){return this.$$.ctx[23]}set floatinganchor(e){this.$$set({floatinganchor:e}),_()}get floatingoffset(){return this.$$.ctx[24]}set floatingoffset(e){this.$$set({floatingoffset:e}),_()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),_()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),_()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),_()}get maxnumber(){return this.$$.ctx[25]}set maxnumber(e){this.$$set({maxnumber:e}),_()}get mockerror(){return this.$$.ctx[26]}set mockerror(e){this.$$set({mockerror:e}),_()}get obfuscated(){return this.$$.ctx[27]}set obfuscated(e){this.$$set({obfuscated:e}),_()}get refetchonexpire(){return this.$$.ctx[28]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),_()}get spamfilter(){return this.$$.ctx[29]}set spamfilter(e){this.$$set({spamfilter:e}),_()}get strings(){return this.$$.ctx[36]}set strings(e){this.$$set({strings:e}),_()}get test(){return this.$$.ctx[30]}set test(e){this.$$set({test:e}),_()}get verifyurl(){return this.$$.ctx[31]}set verifyurl(e){this.$$set({verifyurl:e}),_()}get workers(){return this.$$.ctx[32]}set workers(e){this.$$set({workers:e}),_()}get workerurl(){return this.$$.ctx[33]}set workerurl(e){this.$$set({workerurl:e}),_()}get configure(){return this.$$.ctx[37]}get reset(){return this.$$.ctx[38]}get verify(){return this.$$.ctx[39]}get clarify(){return this.$$.ctx[40]}}customElements.define("altcha-widget",gn(yt,{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"},obfuscated:{},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},["default"],["configure","reset","verify","clarify"],!1)),globalThis.createAltchaWorker=n=>n?new Worker(new URL(n)):new Xt,w.Altcha=yt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}); diff --git a/dist_external/altcha.d.ts b/dist_external/altcha.d.ts index 020d6e6..ef75e1e 100644 --- a/dist_external/altcha.d.ts +++ b/dist_external/altcha.d.ts @@ -16,7 +16,7 @@ declare global { interface AltchaServerVerificationEvent extends CustomEvent> {} - interface AltchaWidget { + interface AltchaWidgetOptions { analytics?: boolean | string; auto?: 'onfocus' | 'onload' | 'onsubmit'; beaconurl?: string; @@ -31,9 +31,10 @@ declare global { floatingoffset?: number; hidefooter?: boolean; hidelogo?: boolean; - name?: string; maxnumber?: number; mockerror?: boolean; + name?: string; + obfuscated?: string; refetchonexpire?: boolean; spamfilter?: boolean | 'ipAddress'; strings?: string; @@ -43,6 +44,16 @@ declare global { workerurl?: string; } + interface AltchaWidgetMethods { + configure: (options: AltchaWidgetOptions) => void; + clarify: () => Promise; + reset: (newState: AltchaState = 'unverified', err: string | null = null) => void; + verify: () => Promise; + } + + interface AltchaWidget extends AltchaWidgetOptions extends AltchaWidgetMethods { + } + declare namespace svelteHTML { interface IntrinsicElements { 'altcha-widget': AltchaWidgetSvelte; @@ -74,6 +85,7 @@ declare global { } interface AltchaWidgetReact extends AltchaWidget extends React.HTMLAttributes { + children?: React.ReactNode; ref?: React.RefObject; style?: AltchaWidgetCSSProperties; } diff --git a/dist_external/altcha.js b/dist_external/altcha.js index 3e3f282..68bfef2 100644 --- a/dist_external/altcha.js +++ b/dist_external/altcha.js @@ -1,70 +1,116 @@ -var Pt = Object.defineProperty; -var it = (n) => { +var Kt = Object.defineProperty; +var ut = (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() { +var Qt = (n, e, t) => e in n ? Kt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; +var P = (n, e, t) => Qt(n, typeof e != "symbol" ? e + "" : e, t), ht = (n, e, t) => e.has(n) || ut("Cannot " + t); +var G = (n, e, t) => (ht(n, e, "read from private field"), t ? t.call(n) : e.get(n)), fe = (n, e, t) => e.has(n) ? ut("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), dt = (n, e, t, r) => (ht(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t); +function Me() { } -function wt(n) { +function $t(n, e) { + for (const t in e) n[t] = e[t]; + return ( + /** @type {T & S} */ + n + ); +} +function At(n) { return n(); } -function st() { +function mt() { return /* @__PURE__ */ Object.create(null); } -function ve(n) { - n.forEach(wt); +function Ie(n) { + n.forEach(At); } -function _t(n) { +function xt(n) { return typeof n == "function"; } -function Ot(n, e) { +function en(n, e) { return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function"; } -function Ht(n) { +function tn(n) { return Object.keys(n).length === 0; } -function p(n, e) { +function nn(n, e, t, r) { + if (n) { + const o = Lt(n, e, t, r); + return n[0](o); + } +} +function Lt(n, e, t, r) { + return n[1] && r ? $t(t.ctx.slice(), n[1](r(e))) : t.ctx; +} +function rn(n, e, t, r) { + if (n[2] && r) { + const o = n[2](r(t)); + if (e.dirty === void 0) + return o; + if (typeof o == "object") { + const s = [], l = Math.max(e.dirty.length, o.length); + for (let c = 0; c < l; c += 1) + s[c] = e.dirty[c] | o[c]; + return s; + } + return e.dirty | o; + } + return e.dirty; +} +function on(n, e, t, r, o, s) { + if (o) { + const l = Lt(e, t, r, s); + n.p(l, o); + } +} +function sn(n) { + if (n.ctx.length > 32) { + const e = [], t = n.ctx.length / 32; + for (let r = 0; r < t; r++) + e[r] = -1; + return e; + } + return -1; +} +function I(n, e) { n.appendChild(e); } -function M(n, e, t) { +function B(n, e, t) { n.insertBefore(e, t || null); } -function D(n) { +function S(n) { n.parentNode && n.parentNode.removeChild(n); } -function F(n) { +function M(n) { return document.createElement(n); } -function z(n) { +function re(n) { return document.createElementNS("http://www.w3.org/2000/svg", n); } -function yt(n) { +function It(n) { return document.createTextNode(n); } -function W() { - return yt(" "); +function Q() { + return It(" "); } -function $t() { - return yt(""); +function ln() { + return It(""); } -function Me(n, e, t, r) { +function Pe(n, e, t, r) { return n.addEventListener(e, t, r), () => n.removeEventListener(e, t, r); } -function a(n, e, t) { +function u(n, e, t) { t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t); } -function qt(n) { +function cn(n) { return Array.from(n.childNodes); } -function lt(n, e, t) { +function gt(n, e, t) { n.classList.toggle(e, !!t); } -function Zt(n, e, { bubbles: t = !1, cancelable: r = !1 } = {}) { +function an(n, e, { bubbles: t = !1, cancelable: r = !1 } = {}) { return new CustomEvent(n, { detail: e, bubbles: t, cancelable: r }); } -function Yt(n) { +function fn(n) { const e = {}; return n.childNodes.forEach( /** @param {Element} node */ @@ -73,167 +119,176 @@ function Yt(n) { } ), e; } -let me; -function ge(n) { - me = n; +let pe; +function ke(n) { + pe = n; } -function Be() { - if (!me) throw new Error("Function called outside component initialization"); - return me; +function qe() { + if (!pe) throw new Error("Function called outside component initialization"); + return pe; } -function Gt(n) { - Be().$$.on_mount.push(n); +function un(n) { + qe().$$.on_mount.push(n); } -function Jt(n) { - Be().$$.on_destroy.push(n); +function hn(n) { + qe().$$.on_destroy.push(n); } -function Xt() { - const n = Be(); +function dn() { + const n = qe(); return (e, t, { cancelable: r = !1 } = {}) => { const o = n.$$.callbacks[e]; if (o) { - const s = Zt( + const s = an( /** @type {string} */ e, t, { cancelable: r } ); - return o.slice().forEach((u) => { - u.call(n, s); + return o.slice().forEach((l) => { + l.call(n, s); }), !s.defaultPrevented; } return !0; }; } -const se = [], Fe = []; -let le = []; -const at = [], vt = /* @__PURE__ */ Promise.resolve(); -let je = !1; -function Et() { - je || (je = !0, vt.then(v)); +const he = [], Ne = []; +let de = []; +const bt = [], Tt = /* @__PURE__ */ Promise.resolve(); +let Oe = !1; +function Rt() { + Oe || (Oe = !0, Tt.then(E)); } -function Wt() { - return Et(), vt; +function mn() { + return Rt(), Tt; } -function Ve(n) { - le.push(n); +function He(n) { + de.push(n); } -const Ne = /* @__PURE__ */ new Set(); -let oe = 0; -function v() { - if (oe !== 0) +const Be = /* @__PURE__ */ new Set(); +let ue = 0; +function E() { + if (ue !== 0) return; - const n = me; + const n = pe; do { try { - for (; oe < se.length; ) { - const e = se[oe]; - oe++, ge(e), zt(e.$$); + for (; ue < he.length; ) { + const e = he[ue]; + ue++, ke(e), gn(e.$$); } } catch (e) { - throw se.length = 0, oe = 0, e; + throw he.length = 0, ue = 0, e; } - 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()); + for (ke(null), he.length = 0, ue = 0; Ne.length; ) Ne.pop()(); + for (let e = 0; e < de.length; e += 1) { + const t = de[e]; + Be.has(t) || (Be.add(t), t()); } - le.length = 0; - } while (se.length); - for (; at.length; ) - at.pop()(); - je = !1, Ne.clear(), ge(n); + de.length = 0; + } while (he.length); + for (; bt.length; ) + bt.pop()(); + Oe = !1, Be.clear(), ke(n); } -function zt(n) { +function gn(n) { if (n.fragment !== null) { - n.update(), ve(n.before_update); + n.update(), Ie(n.before_update); const e = n.dirty; - n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(Ve); + n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(He); } } -function Kt(n) { +function bn(n) { const e = [], t = []; - le.forEach((r) => n.indexOf(r) === -1 ? e.push(r) : t.push(r)), t.forEach((r) => r()), le = e; + de.forEach((r) => n.indexOf(r) === -1 ? e.push(r) : t.push(r)), t.forEach((r) => r()), de = e; } -const Qt = /* @__PURE__ */ new Set(); -function en(n, e) { - n && n.i && (Qt.delete(n), n.i(e)); +const De = /* @__PURE__ */ new Set(); +let yn; +function Ft(n, e) { + n && n.i && (De.delete(n), n.i(e)); +} +function wn(n, e, t, r) { + if (n && n.o) { + if (De.has(n)) return; + De.add(n), yn.c.push(() => { + De.delete(n); + }), n.o(e); + } } -function tn(n, e, t) { +function _n(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); + r && r.m(e, t), He(() => { + const s = n.$$.on_mount.map(At).filter(xt); + n.$$.on_destroy ? n.$$.on_destroy.push(...s) : Ie(s), n.$$.on_mount = []; + }), o.forEach(He); } -function nn(n, e) { +function En(n, e) { const t = n.$$; - 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 = []); + t.fragment !== null && (bn(t.after_update), Ie(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); } -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 vn(n, e) { + n.$$.dirty[0] === -1 && (he.push(n), Rt(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31; } -function on(n, e, t, r, o, s, u = null, f = [-1]) { - const l = me; - ge(n); - const c = n.$$ = { +function kn(n, e, t, r, o, s, l = null, c = [-1]) { + const a = pe; + ke(n); + const h = n.$$ = { fragment: null, ctx: [], // state props: s, - update: ce, + update: Me, not_equal: o, - bound: st(), + bound: mt(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], - context: new Map(e.context || (l ? l.$$.context : [])), + context: new Map(e.context || (a ? a.$$.context : [])), // everything else - callbacks: st(), - dirty: f, + callbacks: mt(), + dirty: c, skip_bound: !1, - root: e.target || l.$$.root + root: e.target || a.$$.root }; - 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) { + l && l(h.root); + let w = !1; + if (h.ctx = t ? t(n, e.props || {}, (x, $, ...k) => { + const J = k.length ? k[0] : $; + return h.ctx && o(h.ctx[x], h.ctx[x] = J) && (!h.skip_bound && h.bound[x] && h.bound[x](J), w && vn(n, x)), $; + }) : [], h.update(), w = !0, Ie(h.before_update), h.fragment = r ? r(h.ctx) : !1, e.target) { if (e.hydrate) { - const m = qt(e.target); - c.fragment && c.fragment.l(m), m.forEach(D); + const x = cn(e.target); + h.fragment && h.fragment.l(x), x.forEach(S); } else - c.fragment && c.fragment.c(); - e.intro && en(n.$$.fragment), tn(n, e.target, e.anchor), v(); + h.fragment && h.fragment.c(); + e.intro && Ft(n.$$.fragment), _n(n, e.target, e.anchor), E(); } - ge(l); + ke(a); } -let kt; -typeof HTMLElement == "function" && (kt = class extends HTMLElement { +let Dt; +typeof HTMLElement == "function" && (Dt = class extends HTMLElement { constructor(e, t, r) { super(); /** The Svelte component constructor */ - S(this, "$$ctor"); + P(this, "$$ctor"); /** Slots */ - S(this, "$$s"); + P(this, "$$s"); /** The Svelte component instance */ - S(this, "$$c"); + P(this, "$$c"); /** Whether or not the custom element is connected */ - S(this, "$$cn", !1); + P(this, "$$cn", !1); /** Component props data */ - S(this, "$$d", {}); + P(this, "$$d", {}); /** `true` if currently in the process of reflecting component props back to attributes */ - S(this, "$$r", !1); + P(this, "$$r", !1); /** @type {Record} Props definition (name, reflected, type etc) */ - S(this, "$$p_d", {}); + P(this, "$$p_d", {}); /** @type {Record} Event listeners */ - S(this, "$$l", {}); + P(this, "$$l", {}); /** @type {Map} Event listener unsubscribe functions */ - S(this, "$$l_u", /* @__PURE__ */ new Map()); + P(this, "$$l_u", /* @__PURE__ */ new Map()); this.$$ctor = e, this.$$s = t, r && this.attachShadow({ mode: "open" }); } addEventListener(e, t, r) { @@ -253,32 +308,32 @@ typeof HTMLElement == "function" && (kt = class extends HTMLElement { if (this.$$cn = !0, !this.$$c) { let e = function(s) { return () => { - let u; + let l; return { c: function() { - u = F("slot"), s !== "default" && a(u, "name", s); + l = M("slot"), s !== "default" && u(l, "name", s); }, /** * @param {HTMLElement} target * @param {HTMLElement} [anchor] */ - m: function(c, O) { - M(c, u, O); + m: function(h, w) { + B(h, l, w); }, - d: function(c) { - c && D(u); + d: function(h) { + h && S(l); } }; }; }; if (await Promise.resolve(), !this.$$cn || this.$$c) return; - const t = {}, r = Yt(this); + const t = {}, r = fn(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")); + const l = this.$$g_p(s.name); + l in this.$$d || (this.$$d[l] = Se(l, 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]); @@ -296,21 +351,21 @@ typeof HTMLElement == "function" && (kt = class extends HTMLElement { 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 = Te( + const l = Se( 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); + l == null ? this.removeAttribute(this.$$p_d[s].attribute || s) : this.setAttribute(this.$$p_d[s].attribute || s, l); } this.$$r = !1; }; this.$$c.$$.after_update.push(o), o(); 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); + for (const l of this.$$l[s]) { + const c = this.$$c.$on(s, l); + this.$$l_u.set(l, c); } this.$$l = {}; } @@ -319,7 +374,7 @@ typeof HTMLElement == "function" && (kt = class extends HTMLElement { // and setting attributes through setAttribute etc, this is helpful attributeChangedCallback(e, t, r) { var o; - 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] })); + this.$$r || (e = this.$$g_p(e), this.$$d[e] = Se(e, r, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); } disconnectedCallback() { this.$$cn = !1, Promise.resolve().then(() => { @@ -332,7 +387,7 @@ typeof HTMLElement == "function" && (kt = class extends HTMLElement { ) || e; } }); -function Te(n, e, t, r) { +function Se(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]) @@ -362,38 +417,38 @@ function Te(n, e, t, r) { return e; } } -function sn(n, e, t, r, o, s) { - let u = class extends kt { +function pn(n, e, t, r, o, s) { + let l = class extends Dt { constructor() { super(n, t, o), this.$$p_d = e; } static get observedAttributes() { return Object.keys(e).map( - (f) => (e[f].attribute || f).toLowerCase() + (c) => (e[c].attribute || c).toLowerCase() ); } }; - return Object.keys(e).forEach((f) => { - Object.defineProperty(u.prototype, f, { + return Object.keys(e).forEach((c) => { + Object.defineProperty(l.prototype, c, { get() { - return this.$$c && f in this.$$c ? this.$$c[f] : this.$$d[f]; + return this.$$c && c in this.$$c ? this.$$c[c] : this.$$d[c]; }, - set(l) { - var c; - l = Te(f, l, e), this.$$d[f] = l, (c = this.$$c) == null || c.$set({ [f]: l }); + set(a) { + var h; + a = Se(c, a, e), this.$$d[c] = a, (h = this.$$c) == null || h.$set({ [c]: a }); } }); - }), r.forEach((f) => { - Object.defineProperty(u.prototype, f, { + }), r.forEach((c) => { + Object.defineProperty(l.prototype, c, { get() { - var l; - return (l = this.$$c) == null ? void 0 : l[f]; + var a; + return (a = this.$$c) == null ? void 0 : a[c]; } }); }), n.element = /** @type {any} */ - u, u; + l, l; } -class ln { +class Cn { constructor() { /** * ### PRIVATE API @@ -402,7 +457,7 @@ class ln { * * @type {any} */ - S(this, "$$"); + P(this, "$$"); /** * ### PRIVATE API * @@ -410,11 +465,11 @@ class ln { * * @type {any} */ - S(this, "$$set"); + P(this, "$$set"); } /** @returns {void} */ $destroy() { - nn(this, 1), this.$destroy = ce; + En(this, 1), this.$destroy = Me; } /** * @template {Extract} K @@ -423,8 +478,8 @@ class ln { * @returns {() => void} */ $on(e, t) { - if (!_t(t)) - return ce; + if (!xt(t)) + return Me; const r = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); return r.push(t), () => { const o = r.indexOf(t); @@ -436,19 +491,19 @@ class ln { * @returns {void} */ $set(e) { - this.$$set && !Ht(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); + this.$$set && !tn(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); } } -const an = "4"; -typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(an); -const fn = new TextEncoder(); -function cn(n) { +const An = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(An); +const St = new TextEncoder(); +function xn(n) { return [...new Uint8Array(n)].map((e) => e.toString(16).padStart(2, "0")).join(""); } -async function un(n, e = "SHA-256", t = 1e5) { +async function Ln(n, e = "SHA-256", t = 1e5) { const r = Date.now().toString(16); n || (n = Math.round(Math.random() * t)); - const o = await pt(r, n, e); + const o = await Mt(r, n, e); return { algorithm: e, challenge: o, @@ -456,25 +511,25 @@ async function un(n, e = "SHA-256", t = 1e5) { signature: "" }; } -async function pt(n, e, t) { - return cn( +async function Mt(n, e, t) { + return xn( await crypto.subtle.digest( t.toUpperCase(), - fn.encode(n + e) + St.encode(n + e) ) ); } -function hn(n, e, t = "SHA-256", r = 1e6, o = 0) { - const s = new AbortController(), u = Date.now(); +function In(n, e, t = "SHA-256", r = 1e6, o = 0) { + const s = new AbortController(), l = Date.now(); return { promise: (async () => { - for (let l = o; l <= r; l += 1) { + for (let a = o; a <= r; a += 1) { if (s.signal.aborted) return null; - if (await pt(e, l, t) === n) + if (await Mt(e, a, t) === n) return { - number: l, - took: Date.now() - u + number: a, + took: Date.now() - l }; } return null; @@ -482,39 +537,100 @@ function hn(n, e, t = "SHA-256", r = 1e6, o = 0) { controller: s }; } -function Ct() { +function Nt() { try { return Intl.DateTimeFormat().resolvedOptions().timeZone; } catch { } } -var ae, fe, be, we, _e, ye; -class dn { +function Tn(n) { + const e = atob(n), t = new Uint8Array(e.length); + for (let r = 0; r < e.length; r++) + t[r] = e.charCodeAt(r); + return t; +} +function Rn(n, e = 12) { + const t = new Uint8Array(e); + for (let r = 0; r < e; r++) + t[r] = n % 256, n = Math.floor(n / 256); + return t; +} +async function Fn(n, e = "", t = 1e6, r = 0) { + const o = "AES-GCM", s = new AbortController(), l = Date.now(), c = async () => { + for (let w = r; w <= t; w += 1) { + if (s.signal.aborted || !a || !h) + return null; + try { + const x = await crypto.subtle.decrypt( + { + name: o, + iv: Rn(w) + }, + a, + h + ); + if (x) + return { + clearText: new TextDecoder().decode(x), + took: Date.now() - l + }; + } catch { + } + } + return null; + }; + let a = null, h = null; + try { + h = Tn(n); + const w = await crypto.subtle.digest( + "SHA-256", + St.encode(e) + ); + a = await crypto.subtle.importKey( + "raw", + w, + o, + !1, + ["decrypt"] + ); + } catch { + return { + promise: Promise.reject(), + controller: s + }; + } + return { + promise: c(), + controller: s + }; +} +var me, ge, Ce, Ae, xe, Le; +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)); + P(this, "beaconUrl", null); + P(this, "error", null); + P(this, "loadTime", Date.now()); + P(this, "submitTime", null); + P(this, "startTime", null); + P(this, "viewTimeThresholdMs", 1500); + fe(this, me, {}); + fe(this, ge, null); + fe(this, Ce, this.onFormChange.bind(this)); + fe(this, Ae, this.onFormFocus.bind(this)); + fe(this, xe, this.onFormSubmit.bind(this)); + fe(this, Le, this.onUnload.bind(this)); + this.elForm = e, window.addEventListener("unload", G(this, Le)), this.elForm.addEventListener("change", G(this, Ce)), this.elForm.addEventListener("focusin", G(this, Ae)), this.elForm.addEventListener("submit", G(this, xe)); } data() { - const e = Object.entries(U(this, ae)); + const e = Object.entries(G(this, me)); 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, + dropoff: !this.submitTime && !this.error && G(this, ge) ? G(this, ge) : null, error: this.error, mobile: this.isMobile(), start: this.startTime, submit: this.submitTime, - tz: Ct() + tz: Nt() }; } dataAsBase64() { @@ -528,7 +644,7 @@ class dn { 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)); + window.removeEventListener("unload", G(this, Le)), this.elForm.removeEventListener("change", G(this, Ce)), this.elForm.removeEventListener("focusin", G(this, Ae)), this.elForm.removeEventListener("submit", G(this, xe)); } end() { this.submitTime || (this.submitTime = Date.now()); @@ -556,7 +672,7 @@ class dn { const t = e.target; if (this.startTime || this.start(), t && this.isInput(t)) { const r = this.getFieldName(t); - r && ot(this, fe, r); + r && dt(this, ge, r); } } onFormSubmit() { @@ -582,61 +698,61 @@ class dn { this.error = e === null ? null : String(e); } trackFieldChange(e) { - U(this, ae)[e] = (U(this, ae)[e] || 0) + 1; + G(this, me)[e] = (G(this, me)[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) { +me = new WeakMap(), ge = new WeakMap(), Ce = new WeakMap(), Ae = new WeakMap(), xe = new WeakMap(), Le = new WeakMap(); +var y = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(y || {}); +function yt(n) { let e, t, r; return { c() { - 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"); + e = re("svg"), t = re("path"), r = re("path"), u(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"), u(t, "fill", "currentColor"), u(t, "opacity", ".25"), u(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"), u(r, "fill", "currentColor"), u(r, "class", "altcha-spinner"), u(e, "width", "24"), u(e, "height", "24"), u(e, "viewBox", "0 0 24 24"), u(e, "xmlns", "http://www.w3.org/2000/svg"); }, m(o, s) { - M(o, e, s), p(e, t), p(e, r); + B(o, e, s), I(e, t), I(e, r); }, d(o) { - o && D(e); + o && S(e); } }; } -function gn(n) { +function Sn(n) { let e, t = ( /*_strings*/ n[13].label + "" ), r; return { c() { - e = F("label"), a(e, "for", r = /*name*/ + e = M("label"), u(e, "for", r = /*name*/ n[4] + "_checkbox"); }, m(o, s) { - M(o, e, s), e.innerHTML = t; + B(o, e, s), e.innerHTML = t; }, 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); + o[4] + "_checkbox") && u(e, "for", r); }, d(o) { - o && D(e); + o && S(e); } }; } -function mn(n) { +function Mn(n) { let e, t = ( /*_strings*/ n[13].verifying + "" ); return { c() { - e = F("span"); + e = M("span"); }, m(r, o) { - M(r, e, o), e.innerHTML = t; + B(r, e, o), e.innerHTML = t; }, p(r, o) { o[0] & /*_strings*/ @@ -644,21 +760,21 @@ function mn(n) { r[13].verifying + "") && (e.innerHTML = t); }, d(r) { - r && D(e); + r && S(e); } }; } -function bn(n) { +function Nn(n) { let e, t = ( /*_strings*/ n[13].verified + "" - ), r, o, s, u, f = ( + ), r, o, s, l, c = ( /*session*/ - n[11] && ct(n) + n[11] && wt(n) ); return { c() { - e = F("span"), r = W(), o = F("input"), s = W(), f && f.c(), u = $t(), a(o, "type", "hidden"), a( + e = M("span"), r = Q(), o = M("input"), s = Q(), c && c.c(), l = ln(), u(o, "type", "hidden"), u( o, "name", /*name*/ @@ -666,37 +782,37 @@ function bn(n) { ), o.value = /*payload*/ n[6]; }, - 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); + m(a, h) { + B(a, e, h), e.innerHTML = t, B(a, r, h), B(a, o, h), B(a, s, h), c && c.m(a, h), B(a, l, h); }, - p(l, c) { - c[0] & /*_strings*/ + p(a, h) { + h[0] & /*_strings*/ 8192 && t !== (t = /*_strings*/ - l[13].verified + "") && (e.innerHTML = t), c[0] & /*name*/ - 16 && a( + a[13].verified + "") && (e.innerHTML = t), h[0] & /*name*/ + 16 && u( o, "name", /*name*/ - l[4] - ), c[0] & /*payload*/ + a[4] + ), h[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); + a[6]), /*session*/ + a[11] ? c ? c.p(a, h) : (c = wt(a), c.c(), c.m(l.parentNode, l)) : c && (c.d(1), c = null); }, - d(l) { - l && (D(e), D(r), D(o), D(s), D(u)), f && f.d(l); + d(a) { + a && (S(e), S(r), S(o), S(s), S(l)), c && c.d(a); } }; } -function ct(n) { +function wt(n) { let e; return { c() { - e = F("input"), a(e, "type", "hidden"), a(e, "name", "__session"), e.value = /*sessionPayload*/ + e = M("input"), u(e, "type", "hidden"), u(e, "name", "__session"), e.value = /*sessionPayload*/ n[12]; }, m(t, r) { - M(t, e, r); + B(t, e, r); }, p(t, r) { r[0] & /*sessionPayload*/ @@ -704,62 +820,62 @@ function ct(n) { t[12]); }, d(t) { - t && D(e); + t && S(e); } }; } -function ut(n) { - let e, t, r, o, s, u, f; +function _t(n) { + let e, t, r, o, s, l, c; 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*/ + e = M("div"), t = M("a"), r = re("svg"), o = re("path"), s = re("path"), l = re("path"), u(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"), u(o, "fill", "currentColor"), u(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"), u(s, "fill", "currentColor"), u(l, "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"), u(l, "fill", "currentColor"), u(r, "width", "22"), u(r, "height", "22"), u(r, "viewBox", "0 0 20 20"), u(r, "fill", "none"), u(r, "xmlns", "http://www.w3.org/2000/svg"), u(t, "href", Vt), u(t, "target", "_blank"), u(t, "class", "altcha-logo"), u(t, "aria-label", c = /*_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); + m(a, h) { + B(a, e, h), I(e, t), I(t, r), I(r, o), I(r, s), I(r, l); }, - p(l, c) { - c[0] & /*_strings*/ - 8192 && f !== (f = /*_strings*/ - l[13].ariaLinkLabel) && a(t, "aria-label", f); + p(a, h) { + h[0] & /*_strings*/ + 8192 && c !== (c = /*_strings*/ + a[13].ariaLinkLabel) && u(t, "aria-label", c); }, - d(l) { - l && D(e); + d(a) { + a && S(e); } }; } -function ht(n) { +function Et(n) { let e, t, r, o; - function s(l, c) { + function s(a, h) { return ( /*state*/ - l[7] === _.EXPIRED ? _n : wn + a[7] === y.EXPIRED ? jn : Vn ); } - let u = s(n), f = u(n); + let l = s(n), c = l(n); return { c() { - 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"); + e = M("div"), t = re("svg"), r = re("path"), o = Q(), c.c(), u(r, "stroke-linecap", "round"), u(r, "stroke-linejoin", "round"), u(r, "d", "M6 18L18 6M6 6l12 12"), u(t, "width", "14"), u(t, "height", "14"), u(t, "xmlns", "http://www.w3.org/2000/svg"), u(t, "fill", "none"), u(t, "viewBox", "0 0 24 24"), u(t, "stroke-width", "1.5"), u(t, "stroke", "currentColor"), u(e, "class", "altcha-error"); }, - m(l, c) { - M(l, e, c), p(e, t), p(t, r), p(e, o), f.m(e, null); + m(a, h) { + B(a, e, h), I(e, t), I(t, r), I(e, o), 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))); + p(a, h) { + l === (l = s(a)) && c ? c.p(a, h) : (c.d(1), c = l(a), c && (c.c(), c.m(e, null))); }, - d(l) { - l && D(e), f.d(); + d(a) { + a && S(e), c.d(); } }; } -function wn(n) { +function Vn(n) { let e, t = ( /*_strings*/ n[13].error + "" ); return { c() { - e = F("div"), a( + e = M("div"), u( e, "title", /*error*/ @@ -767,13 +883,13 @@ function wn(n) { ); }, m(r, o) { - M(r, e, o), e.innerHTML = t; + B(r, e, o), e.innerHTML = t; }, p(r, o) { o[0] & /*_strings*/ 8192 && t !== (t = /*_strings*/ r[13].error + "") && (e.innerHTML = t), o[0] & /*error*/ - 32 && a( + 32 && u( e, "title", /*error*/ @@ -781,18 +897,18 @@ function wn(n) { ); }, d(r) { - r && D(e); + r && S(e); } }; } -function _n(n) { +function jn(n) { let e, t = ( /*_strings*/ n[13].expired + "" ); return { c() { - e = F("div"), a( + e = M("div"), u( e, "title", /*error*/ @@ -800,13 +916,13 @@ function _n(n) { ); }, m(r, o) { - M(r, e, o), e.innerHTML = t; + B(r, e, o), e.innerHTML = t; }, p(r, o) { o[0] & /*_strings*/ 8192 && t !== (t = /*_strings*/ r[13].expired + "") && (e.innerHTML = t), o[0] & /*error*/ - 32 && a( + 32 && u( e, "title", /*error*/ @@ -814,21 +930,21 @@ function _n(n) { ); }, d(r) { - r && D(e); + r && S(e); } }; } -function dt(n) { +function vt(n) { let e, t, r = ( /*_strings*/ n[13].footer + "" ); return { c() { - e = F("div"), t = F("div"), a(e, "class", "altcha-footer"); + e = M("div"), t = M("div"), u(e, "class", "altcha-footer"); }, m(o, s) { - M(o, e, s), p(e, t), t.innerHTML = r; + B(o, e, s), I(e, t), t.innerHTML = r; }, p(o, s) { s[0] & /*_strings*/ @@ -836,365 +952,415 @@ function dt(n) { o[13].footer + "") && (t.innerHTML = r); }, d(o) { - o && D(e); + o && S(e); } }; } -function gt(n) { +function kt(n) { let e; return { c() { - e = F("div"), a(e, "class", "altcha-anchor-arrow"); + e = M("div"), u(e, "class", "altcha-anchor-arrow"); }, m(t, r) { - M(t, e, r), n[41](e); + B(t, e, r), n[46](e); }, - p: ce, + p: Me, d(t) { - t && D(e), n[41](null); + t && S(e), n[46](null); } }; } -function yn(n) { - let e, t, r, o, s, u, f, l, c, O, m, H, $, q, J, b = ( +function Un(n) { + let e, t, r, o, s, l, c, a, h, w, x, $, k, J, H, ee, te; + const R = ( + /*#slots*/ + n[44].default + ), O = nn( + R, + n, + /*$$scope*/ + n[43], + null + ); + let N = ( /*state*/ - n[7] === _.VERIFYING && ft() + n[7] === y.VERIFYING && yt() ); - function K(d, E) { + function oe(d, C) { return ( /*state*/ - d[7] === _.VERIFIED ? bn : ( + d[7] === y.VERIFIED ? Nn : ( /*state*/ - d[7] === _.VERIFYING ? mn : gn + d[7] === y.VERIFYING ? Mn : Sn ) ); } - let X = K(n), j = X(n), I = ( + let ne = oe(n), Z = ne(n), L = ( /*hidelogo*/ (n[3] !== !0 || /*isFreeSaaS*/ - n[14]) && ut(n) - ), R = ( + n[14]) && _t(n) + ), F = ( /*error*/ (n[5] || /*state*/ - n[7] === _.EXPIRED) && ht(n) - ), C = ( + n[7] === y.EXPIRED) && Et(n) + ), p = ( /*_strings*/ n[13].footer && /*hidefooter*/ (n[2] !== !0 || /*isFreeSaaS*/ - n[14]) && dt(n) - ), x = ( + n[14]) && vt(n) + ), D = ( /*floating*/ - n[1] && gt(n) + n[1] && kt(n) ); return { c() { - 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, + O && O.c(), e = Q(), t = M("div"), r = M("div"), N && N.c(), o = Q(), s = M("div"), l = M("input"), h = Q(), w = M("div"), Z.c(), x = Q(), L && L.c(), $ = Q(), F && F.c(), k = Q(), p && p.c(), J = Q(), D && D.c(), u(l, "type", "checkbox"), u(l, "id", c = /*name*/ + n[4] + "_checkbox"), l.required = a = /*auto*/ + n[0] !== "onsubmit", u(s, "class", "altcha-checkbox"), gt( + s, "altcha-hidden", /*state*/ - n[7] === _.VERIFYING - ), a(c, "class", "altcha-label"), a(t, "class", "altcha-main"), a(e, "class", "altcha"), a( - e, + n[7] === y.VERIFYING + ), u(w, "class", "altcha-label"), u(r, "class", "altcha-main"), u(t, "class", "altcha"), u( + t, "data-state", /*state*/ n[7] - ), a( - e, + ), u( + t, "data-floating", /*floating*/ n[1] ); }, - 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, + m(d, C) { + O && O.m(d, C), B(d, e, C), B(d, t, C), I(t, r), N && N.m(r, null), I(r, o), I(r, s), I(s, l), l.checked = /*checked*/ + n[8], I(r, h), I(r, w), Z.m(w, null), I(r, x), L && L.m(r, null), I(t, $), F && F.m(t, null), I(t, k), p && p.m(t, null), I(t, J), D && D.m(t, null), n[47](t), H = !0, ee || (te = [ + Pe( + l, "change", /*input_change_handler*/ - n[40] + n[45] ), - Me( - s, + Pe( + l, "change", /*onCheckedChange*/ n[15] ), - Me( - s, + Pe( + l, "invalid", /*onInvalid*/ n[16] ) - ], q = !0); + ], ee = !0); }, - p(d, E) { - /*state*/ - 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, + p(d, C) { + O && O.p && (!H || C[1] & /*$$scope*/ + 4096) && on( + O, + R, + d, + /*$$scope*/ + d[43], + H ? rn( + R, + /*$$scope*/ + d[43], + C, + null + ) : sn( + /*$$scope*/ + d[43] + ), + null + ), /*state*/ + d[7] === y.VERIFYING ? N || (N = yt(), N.c(), N.m(r, o)) : N && (N.d(1), N = null), (!H || C[0] & /*name*/ + 16 && c !== (c = /*name*/ + d[4] + "_checkbox")) && u(l, "id", c), (!H || C[0] & /*auto*/ + 1 && a !== (a = /*auto*/ + d[0] !== "onsubmit")) && (l.required = a), C[0] & /*checked*/ + 256 && (l.checked = /*checked*/ + d[8]), (!H || C[0] & /*state*/ + 128) && gt( + s, "altcha-hidden", /*state*/ - 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[7] === y.VERIFYING + ), ne === (ne = oe(d)) && Z ? Z.p(d, C) : (Z.d(1), Z = ne(d), Z && (Z.c(), Z.m(w, null))), /*hidelogo*/ d[3] !== !0 || /*isFreeSaaS*/ - d[14] ? I ? I.p(d, E) : (I = ut(d), I.c(), I.m(t, null)) : I && (I.d(1), I = null), /*error*/ + d[14] ? L ? L.p(d, C) : (L = _t(d), L.c(), L.m(r, null)) : L && (L.d(1), L = 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[7] === y.EXPIRED ? F ? F.p(d, C) : (F = Et(d), F.c(), F.m(t, k)) : F && (F.d(1), F = null), /*_strings*/ d[13].footer && /*hidefooter*/ (d[2] !== !0 || /*isFreeSaaS*/ - 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, + d[14]) ? p ? p.p(d, C) : (p = vt(d), p.c(), p.m(t, J)) : p && (p.d(1), p = null), /*floating*/ + d[1] ? D ? D.p(d, C) : (D = kt(d), D.c(), D.m(t, null)) : D && (D.d(1), D = null), (!H || C[0] & /*state*/ + 128) && u( + t, "data-state", /*state*/ d[7] - ), E[0] & /*floating*/ - 2 && a( - e, + ), (!H || C[0] & /*floating*/ + 2) && u( + t, "data-floating", /*floating*/ d[1] ); }, - i: ce, - o: ce, + i(d) { + H || (Ft(O, d), H = !0); + }, + o(d) { + wn(O, d), H = !1; + }, d(d) { - 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); + d && (S(e), S(t)), O && O.d(d), N && N.d(), Z.d(), L && L.d(), F && F.d(), p && p.d(), D && D.d(), n[47](null), ee = !1, Ie(te); } }; } -const mt = "Visit Altcha.org", At = "https://altcha.org/"; -function bt(n) { +const pt = "Visit Altcha.org", Vt = "https://altcha.org/"; +function Ct(n) { return JSON.parse(n); } -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 Pn(n, e, t) { + var ct, at; + let r, o, s, l, { $$slots: c = {}, $$scope: a } = e, { analytics: h = !1 } = e, { auto: w = void 0 } = e, { beaconurl: x = void 0 } = e, { blockspam: $ = void 0 } = e, { challengeurl: k = void 0 } = e, { challengejson: J = void 0 } = e, { debug: H = !1 } = e, { delay: ee = 0 } = e, { expire: te = void 0 } = e, { floating: R = void 0 } = e, { floatinganchor: O = void 0 } = e, { floatingoffset: N = void 0 } = e, { hidefooter: oe = !1 } = e, { hidelogo: ne = !1 } = e, { name: Z = "altcha" } = e, { maxnumber: L = 1e6 } = e, { mockerror: F = !1 } = e, { obfuscated: p = void 0 } = e, { refetchonexpire: D = !0 } = e, { spamfilter: d = !1 } = e, { strings: C = void 0 } = e, { test: X = !1 } = e, { verifyurl: se = void 0 } = e, { workers: be = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: Te = void 0 } = e; + const Ve = dn(), Ze = ["SHA-256", "SHA-384", "SHA-512"], Ge = (at = (ct = document.documentElement.lang) == null ? void 0 : ct.split("-")) == null ? void 0 : at[0]; + let W = !1, z = null, v, le = null, Re = null, b = null, ie = null, ye = null, K = null, ce = null, q = null, Ye = null, T = y.UNVERIFIED; + hn(() => { + b && (b.removeEventListener("submit", We), b.removeEventListener("reset", ze), b.removeEventListener("focusin", Xe), b = null), ie && v.removeEventListener("click", Je), q && q.destroy(), K && (clearTimeout(K), K = null), document.removeEventListener("click", nt), document.removeEventListener("scroll", it), window.removeEventListener("resize", ot); + }), un(() => { + var i, f; + A("mounted", "0.8.0"), A("workers", be), X && A("using test mode"), te && Fe(te), w !== void 0 && A("auto", w), R !== void 0 && st(R), b = v.closest("form"), b && (b.addEventListener("submit", We, { capture: !0 }), b.addEventListener("reset", ze), w === "onfocus" && b.addEventListener("focusin", Xe)), ie = ((i = v.parentElement) == null ? void 0 : i.querySelector("[data-clarify-button]")) || ((f = v.parentElement) == null ? void 0 : f.querySelector("button, a")), ie && ie.addEventListener("click", Je), h && $e(), w === "onload" && (p ? _e() : ae()), r && (oe || ne) && A("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution."); }); - function k(...i) { - ($ || i.some((h) => h instanceof Error)) && console[i[0] instanceof Error ? "error" : "log"]("ALTCHA", ...i); + function A(...i) { + (H || i.some((f) => f instanceof Error)) && console[i[0] instanceof Error ? "error" : "log"]("ALTCHA", ...i); } - function He(i) { - B === _.UNVERIFIED && ie(); + function Je(i) { + i.preventDefault(), T === y.UNVERIFIED && _e(); } - 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 Xe(i) { + T === y.UNVERIFIED && ae(); } - function qe() { - Le(); + function We(i) { + b && q && T === y.VERIFIED && (q.end(), t(12, Ye = q.dataAsBase64())), b && w === "onsubmit" && (T === y.UNVERIFIED ? (i.preventDefault(), i.stopPropagation(), ae().then(() => { + b == null || b.requestSubmit(); + })) : T !== y.VERIFIED && (i.preventDefault(), i.stopPropagation(), T === y.VERIFYING && rt())); } - function Ze(i, h) { + function ze() { + we(); + } + function Ke(i, f) { return btoa(JSON.stringify({ algorithm: i.algorithm, challenge: i.challenge, - number: h.number, + number: f.number, salt: i.salt, signature: i.signature, - test: Z ? !0 : void 0, - took: h.took + test: X ? !0 : void 0, + took: f.took })); } - function Ye(i) { + function Qe(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 (!Pe.includes(i.algorithm.toUpperCase())) - throw new Error(`Unknown algorithm value. Allowed values: ${Pe.join(", ")}`); + if (!Ze.includes(i.algorithm.toUpperCase())) + throw new Error(`Unknown algorithm value. Allowed values: ${Ze.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 Lt() { + async function jt() { var i; - if (x) - throw k("mocking error"), new Error("Mocked error."); + if (F) + throw A("mocking error"), new Error("Mocked error."); if (o) - return k("using provided json data"), o; - if (Z) - return k("generating test challenge", { test: Z }), un(typeof Z != "boolean" ? +Z : void 0); + return A("using provided json data"), o; + if (X) + return A("generating test challenge", { test: X }), Ln(typeof X != "boolean" ? +X : void 0); { - if (!m && g) { - const y = g.getAttribute("action"); - y != null && y.includes("/form/") && t(17, m = y + "/altcha"); + if (!k && b) { + const _ = b.getAttribute("action"); + _ != null && _.includes("/form/") && t(17, k = _ + "/altcha"); } - if (!m) + if (!k) throw new Error("Attribute challengeurl not set."); - k("fetching challenge from", m); - const h = await fetch(m, { - headers: E ? { "x-altcha-spam-filter": "1" } : {} + A("fetching challenge from", k); + const f = await fetch(k, { + headers: d ? { "x-altcha-spam-filter": "1" } : {} }); - 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 (f.status !== 200) + throw new Error(`Server responded with ${f.status}.`); + const m = f.headers.get("Expires"), g = f.headers.get("X-Altcha-Config"), V = await f.json(), j = new URLSearchParams((i = V.salt.split("?")) == null ? void 0 : i[1]), U = j.get("expires") || j.get("expire"); + if (U) { + const _ = new Date(+U * 1e3), Y = isNaN(_.getTime()) ? 0 : _.getTime() - Date.now(); + Y > 0 && Fe(Y); } - if (T) + if (g) try { - 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); + const _ = JSON.parse(g); + _ && typeof _ == "object" && (_.verifyurl && (_.verifyurl = new URL(_.verifyurl, new URL(k)).toString()), lt(_)); + } catch (_) { + A("unable to configure from X-Altcha-Config", _); } - if (!J && (w != null && w.length)) { - const y = Date.parse(w); - if (y) { - const L = y - Date.now(); - L > 0 && Ae(L); + if (!te && (m != null && m.length)) { + const _ = Date.parse(m); + if (_) { + const Y = _ - Date.now(); + Y > 0 && Fe(Y); } } - return P; + return V; } } - 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"); + function $e() { + if (!q) + if (b) { + if (A("analytics enabled"), t(11, q = new Dn(b)), x === void 0) { + const i = b.getAttribute("action"); + i && t(19, x = i + "/beacon"); } - t(11, V.beaconUrl = c || null, V); + t(11, q.beaconUrl = x || null, q); } else - k("analytics cannot be enabled - form element not found"); + A("analytics cannot be enabled - form element not found"); } - function Je() { - m && d && B === _.VERIFIED ? ie() : Le(_.EXPIRED, u.expired); + function et() { + k && D && T === y.VERIFIED ? ae() : we(y.EXPIRED, l.expired); } - async function It(i) { - let h = null; + async function tt(i) { + let f = null; if ("Worker" in window) { try { - h = await xt(i.challenge, i.salt, i.algorithm, i.maxnumber); - } catch (w) { - k(w); + f = await Ut(i, i.maxnumber); + } catch (m) { + A(m); } - if ((h == null ? void 0 : h.number) !== void 0) - return { data: i, solution: h }; + if ((f == null ? void 0 : f.number) !== void 0 || "obfuscated" in i) + return { data: i, solution: f }; + } + if ("obfuscated" in i) { + const m = await Fn(i.obfuscated, i.key, i.maxnumber); + return { data: i, solution: await m.promise }; } return { data: i, - solution: await hn(i.challenge, i.salt, i.algorithm, i.maxnumber || C).promise + solution: await In(i.challenge, i.salt, i.algorithm, i.maxnumber || L).promise }; } - 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: w, - challenge: i, - max: he + G, - salt: h, - start: he - }, + async function Ut(i, f = typeof X == "number" ? X : L, m = Math.ceil(be)) { + const g = []; + m = Math.min(16, Math.max(1, m)); + for (let U = 0; U < m; U++) + g.push(createAltchaWorker(Te)); + const V = Math.ceil(f / m), j = await Promise.all(g.map((U, _) => { + const Y = _ * V; + return new Promise((Ue) => { + U.addEventListener("message", (Ee) => { + if (Ee.data) + for (const ve of g) + ve !== U && ve.postMessage({ type: "abort" }); + Ue(Ee.data); + }), U.postMessage({ + payload: i, + max: Y + V, + start: Y, type: "work" }); }); })); - for (const L of N) - L.terminate(); - return y.find((L) => !!L) || null; + for (const U of g) + U.terminate(); + return j.find((U) => !!U) || null; } - 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 Pt() { + [y.UNVERIFIED, y.ERROR, y.EXPIRED].includes(T) ? d && (b == null ? void 0 : b.reportValidity()) === !1 ? t(8, W = !1) : p ? _e() : ae() : t(8, W = !0); } - function Xe(i) { - const h = i.target; - b && h && !A.contains(h) && B === _.VERIFIED && t(9, A.style.display = "none", A); + function nt(i) { + const f = i.target; + R && f && !v.contains(f) && T === y.VERIFIED && t(9, v.style.display = "none", v); } - function We() { - b && Se(); + function it() { + R && je(); } - function ze() { - B === _.VERIFYING && u.waitAlert && alert(u.waitAlert); + function rt() { + T === y.VERIFYING && l.waitAlert && alert(l.waitAlert); } - function Ft(i) { - V && V.trackError(Ce); + function Bt(i) { + var f; + if (z) { + const m = z.match(/^(mailto|tel|sms|https?):/); + let g; + if (m) { + const [V] = z.slice(z.indexOf(":") + 1).replace(/^\/\//, "").split("?"); + g = document.createElement("a"), g.href = z, g.innerHTML = V; + } else + g = document.createTextNode(z); + ie && g && (ie.after(g), (f = ie.parentElement) == null || f.removeChild(ie)); + } } - function Rt(i) { - b && B !== _.UNVERIFIED && requestAnimationFrame(() => { - Se(); + function Ot(i) { + q && q.trackError(ye); + } + function Ht(i) { + R && T !== y.UNVERIFIED && requestAnimationFrame(() => { + je(); }); } - function Ke() { - b && Se(); + function ot() { + R && je(); } - function Ae(i) { - k("expire", i), Y && (clearTimeout(Y), Y = null), i < 1 ? Je() : Y = setTimeout(Je, i); + function Fe(i) { + A("expire", i), K && (clearTimeout(K), K = null), i < 1 ? et() : K = setTimeout(et, i); } - 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 st(i) { + A("floating", i), R !== i && (t(9, v.style.left = "", v), t(9, v.style.top = "", v)), t(1, R = i === !0 || i === "" ? "auto" : i === !1 || i === "false" ? void 0 : R), R ? (w || t(0, w = "onsubmit"), document.addEventListener("scroll", it), document.addEventListener("click", nt), window.addEventListener("resize", ot)) : w === "onsubmit" && t(0, w = 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 qt(i) { + var m; + const f = b == null ? void 0 : b.querySelector(typeof i == "string" ? `input[name="${i}"]` : 'input[type="email"]:not([data-no-spamfilter])'); + return ((m = f == null ? void 0 : f.value) == null ? void 0 : m.slice(f.value.indexOf("@"))) || void 0; } - function Dt(i) { + function Zt(i) { return [ - ...(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])')) || [] + ...(b == null ? void 0 : b.querySelectorAll(i != null && i.length ? i.map((m) => `input[name="${m}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] ].reduce( - (w, T) => { - const P = T.name, N = T.value; - return P && N && (w[P] = /\n/.test(N) ? N.replace(new RegExp("(? { + const V = g.name, j = g.value; + return V && j && (m[V] = /\n/.test(j) ? j.replace(new RegExp("(? 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); + function je(i = 20) { + if (v) + if (Re || (Re = (O ? document.querySelector(O) : b == null ? void 0 : b.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || b || ie), Re) { + const f = parseInt(N, 10) || 12, m = Re.getBoundingClientRect(), g = v.getBoundingClientRect(), V = document.documentElement.clientHeight, j = document.documentElement.clientWidth, U = R === "auto" ? m.bottom + g.height + f + i > V : R === "top", _ = Math.max(i, Math.min(j - i - g.width, m.left + m.width / 2 - g.width / 2)); + if (U ? t(9, v.style.top = `${m.top - (g.height + f)}px`, v) : t(9, v.style.top = `${m.bottom + f}px`, v), t(9, v.style.left = `${_}px`, v), v.setAttribute("data-floating", U ? "top" : "bottom"), le) { + const Y = le.getBoundingClientRect(); + t(10, le.style.left = m.left - _ + m.width / 2 - Y.width / 2 + "px", le); } } else - k("unable to find floating anchor element"); - } - 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 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 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 k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); + A("unable to find floating anchor element"); + } + function lt(i) { + i.analytics && (t(18, h = i.analytics), $e()), i.obfuscated !== void 0 && t(27, p = i.obfuscated), i.auto !== void 0 && (t(0, w = i.auto), w === "onload" && (p ? _e() : ae())), i.beaconurl && (t(19, x = i.beaconurl), q && t(11, q.beaconUrl = x, q)), i.floatinganchor !== void 0 && t(23, O = i.floatinganchor), i.delay !== void 0 && t(21, ee = i.delay), i.floatingoffset !== void 0 && t(24, N = i.floatingoffset), i.floating !== void 0 && st(i.floating), i.expire !== void 0 && (Fe(i.expire), t(22, te = i.expire)), i.challenge && (Qe(i.challenge), o = i.challenge), i.challengeurl !== void 0 && t(17, k = i.challengeurl), i.debug !== void 0 && t(20, H = !!i.debug), i.hidefooter !== void 0 && t(2, oe = !!i.hidefooter), i.hidelogo !== void 0 && t(3, ne = !!i.hidelogo), i.maxnumber !== void 0 && t(25, L = +i.maxnumber), i.mockerror !== void 0 && t(26, F = !!i.mockerror), i.name !== void 0 && t(4, Z = i.name), i.refetchonexpire !== void 0 && t(28, D = !!i.refetchonexpire), i.spamfilter !== void 0 && t(29, d = typeof i.spamfilter == "object" ? i.spamfilter : !!i.spamfilter), i.strings && t(42, s = i.strings), i.test !== void 0 && t(30, X = typeof i.test == "number" ? i.test : !!i.test), i.verifyurl !== void 0 && t(31, se = i.verifyurl), i.workers !== void 0 && t(32, be = +i.workers), i.workerurl !== void 0 && t(33, Te = i.workerurl); + } + function we(i = y.UNVERIFIED, f = null) { + K && (clearTimeout(K), K = null), t(8, W = !1), t(5, ye = f), t(6, ce = null), t(7, T = i); + } + async function ae() { + return we(y.VERIFYING), await new Promise((i) => setTimeout(i, ee || 0)), jt().then((i) => (Qe(i), A("challenge", i), tt(i))).then(({ data: i, solution: f }) => { + if (A("solution", f), "challenge" in i && f && !("clearText" in f)) + if ((f == null ? void 0 : f.number) !== void 0) { + if (se) + return Gt(Ke(i, f)); + t(6, ce = Ke(i, f)), A("payload", ce); + } else + throw A("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); }).then(() => { - Wt().then(() => { - t(7, B = _.VERIFIED), t(8, Q = !0), k("verified"), Re("verified", { payload: ne }); + mn().then(() => { + t(7, T = y.VERIFIED), t(8, W = !0), A("verified"), Ve("verified", { payload: ce }); }); }).catch((i) => { - k(i), t(7, B = _.ERROR), t(8, Q = !1), t(5, Ce = i.message); + A(i), t(7, T = y.ERROR), t(8, W = !1), t(5, ye = i.message); }); } - function jt() { - Q = this.checked, t(8, Q); + async function _e() { + if (!p) { + t(7, T = y.ERROR); + return; + } + we(y.VERIFYING), await new Promise((j) => setTimeout(j, ee || 0)); + const [i, f] = p.split("?"); + let g = new URLSearchParams(f || "").get("key") || void 0; + if (g) { + const j = g.match(/^\(prompt:?(.*)\)$/); + j && (g = prompt(j[1] || "Enter Key:") || void 0); + } + const { solution: V } = await tt({ obfuscated: i, key: g, maxnumber: L }); + V && "clearText" in V ? (t(41, z = V.clearText), t(7, T = y.VERIFIED), t(8, W = !0), R && v && t(9, v.style.display = "none", v)) : (t(7, T = y.ERROR), t(8, W = !1), t(5, ye = "Unable to decrypt data.")); + } + function Jt() { + W = this.checked, t(8, W); } - function Vt(i) { - Fe[i ? "unshift" : "push"](() => { - te = i, t(10, te); + function Xt(i) { + Ne[i ? "unshift" : "push"](() => { + le = i, t(10, le); }); } - function Bt(i) { - Fe[i ? "unshift" : "push"](() => { - A = i, t(9, A); + function Wt(i) { + Ne[i ? "unshift" : "push"](() => { + v = i, t(9, v); }); } 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); + "analytics" in i && t(18, h = i.analytics), "auto" in i && t(0, w = i.auto), "beaconurl" in i && t(19, x = i.beaconurl), "blockspam" in i && t(34, $ = i.blockspam), "challengeurl" in i && t(17, k = i.challengeurl), "challengejson" in i && t(35, J = i.challengejson), "debug" in i && t(20, H = i.debug), "delay" in i && t(21, ee = i.delay), "expire" in i && t(22, te = i.expire), "floating" in i && t(1, R = i.floating), "floatinganchor" in i && t(23, O = i.floatinganchor), "floatingoffset" in i && t(24, N = i.floatingoffset), "hidefooter" in i && t(2, oe = i.hidefooter), "hidelogo" in i && t(3, ne = i.hidelogo), "name" in i && t(4, Z = i.name), "maxnumber" in i && t(25, L = i.maxnumber), "mockerror" in i && t(26, F = i.mockerror), "obfuscated" in i && t(27, p = i.obfuscated), "refetchonexpire" in i && t(28, D = i.refetchonexpire), "spamfilter" in i && t(29, d = i.spamfilter), "strings" in i && t(36, C = i.strings), "test" in i && t(30, X = i.test), "verifyurl" in i && t(31, se = i.verifyurl), "workers" in i && t(32, be = i.workers), "workerurl" in i && t(33, Te = i.workerurl), "$$scope" in i && t(43, a = i.$$scope); }, n.$$.update = () => { n.$$.dirty[0] & /*challengeurl*/ - 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, + 131072 && t(14, r = !!(k != null && k.includes(".altcha.org")) && !!(k != null && k.includes("apiKey=ckey_"))), n.$$.dirty[1] & /*challengejson*/ + 16 && (o = J ? Ct(J) : void 0), n.$$.dirty[1] & /*strings*/ + 32 && t(42, s = C ? Ct(C) : {}), n.$$.dirty[1] & /*parsedStrings*/ + 2048 && t(13, l = { + ariaLinkLabel: pt, 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.", ...s - }), n.$$.dirty[0] & /*payload, state*/ - 192 && Re("statechange", { payload: ne, state: B }), n.$$.dirty[0] & /*error*/ - 32 && Ft(), n.$$.dirty[0] & /*state*/ - 128 && Rt(); + }), n.$$.dirty[0] & /*state, payload*/ + 192 | n.$$.dirty[1] & /*clarifiedData*/ + 1024 && Ve("statechange", z ? { clarifiedData: z, state: T } : { payload: ce, state: T }), n.$$.dirty[0] & /*error*/ + 32 && Ot(), n.$$.dirty[0] & /*state*/ + 128 && Ht(), n.$$.dirty[1] & /*clarifiedData*/ + 1024 && Bt(); }, [ - l, - b, - j, - I, + w, R, - Ce, + oe, ne, - B, - Q, - A, - te, - V, - Oe, - u, - r, - Tt, - ze, - m, - f, - c, - $, + Z, + ye, + ce, + T, + W, + v, + le, q, - J, - K, - X, - C, + Ye, + l, + r, + Pt, + rt, + k, + h, x, - d, - E, - Z, + H, ee, - ue, - ke, + te, O, - H, - Ee, - et, - Le, - ie, + N, + L, + F, + p, + D, + d, + X, + se, + be, + Te, + $, + J, + C, + lt, + we, + ae, + _e, + z, s, - jt, - Vt, - Bt + a, + c, + Jt, + Xt, + Wt ]; } -class En extends ln { +class Bn extends Cn { constructor(e) { - super(), on( + super(), kn( this, e, - vn, - yn, - Ot, + Pn, + Un, + en, { analytics: 18, auto: 0, beaconurl: 19, - blockspam: 33, + blockspam: 34, challengeurl: 17, - challengejson: 34, + challengejson: 35, debug: 20, delay: 21, expire: 22, @@ -1357,16 +1546,18 @@ class En extends ln { 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 + obfuscated: 27, + refetchonexpire: 28, + spamfilter: 29, + strings: 36, + test: 30, + verifyurl: 31, + workers: 32, + workerurl: 33, + configure: 37, + reset: 38, + verify: 39, + clarify: 40 }, null, [-1, -1, -1] @@ -1376,158 +1567,167 @@ class En extends ln { return this.$$.ctx[18]; } set analytics(e) { - this.$$set({ analytics: e }), v(); + this.$$set({ analytics: e }), E(); } get auto() { return this.$$.ctx[0]; } set auto(e) { - this.$$set({ auto: e }), v(); + this.$$set({ auto: e }), E(); } get beaconurl() { return this.$$.ctx[19]; } set beaconurl(e) { - this.$$set({ beaconurl: e }), v(); + this.$$set({ beaconurl: e }), E(); } get blockspam() { - return this.$$.ctx[33]; + return this.$$.ctx[34]; } set blockspam(e) { - this.$$set({ blockspam: e }), v(); + this.$$set({ blockspam: e }), E(); } get challengeurl() { return this.$$.ctx[17]; } set challengeurl(e) { - this.$$set({ challengeurl: e }), v(); + this.$$set({ challengeurl: e }), E(); } get challengejson() { - return this.$$.ctx[34]; + return this.$$.ctx[35]; } set challengejson(e) { - this.$$set({ challengejson: e }), v(); + this.$$set({ challengejson: e }), E(); } get debug() { return this.$$.ctx[20]; } set debug(e) { - this.$$set({ debug: e }), v(); + this.$$set({ debug: e }), E(); } get delay() { return this.$$.ctx[21]; } set delay(e) { - this.$$set({ delay: e }), v(); + this.$$set({ delay: e }), E(); } get expire() { return this.$$.ctx[22]; } set expire(e) { - this.$$set({ expire: e }), v(); + this.$$set({ expire: e }), E(); } get floating() { return this.$$.ctx[1]; } set floating(e) { - this.$$set({ floating: e }), v(); + this.$$set({ floating: e }), E(); } get floatinganchor() { return this.$$.ctx[23]; } set floatinganchor(e) { - this.$$set({ floatinganchor: e }), v(); + this.$$set({ floatinganchor: e }), E(); } get floatingoffset() { return this.$$.ctx[24]; } set floatingoffset(e) { - this.$$set({ floatingoffset: e }), v(); + this.$$set({ floatingoffset: e }), E(); } get hidefooter() { return this.$$.ctx[2]; } set hidefooter(e) { - this.$$set({ hidefooter: e }), v(); + this.$$set({ hidefooter: e }), E(); } get hidelogo() { return this.$$.ctx[3]; } set hidelogo(e) { - this.$$set({ hidelogo: e }), v(); + this.$$set({ hidelogo: e }), E(); } get name() { return this.$$.ctx[4]; } set name(e) { - this.$$set({ name: e }), v(); + this.$$set({ name: e }), E(); } get maxnumber() { return this.$$.ctx[25]; } set maxnumber(e) { - this.$$set({ maxnumber: e }), v(); + this.$$set({ maxnumber: e }), E(); } get mockerror() { return this.$$.ctx[26]; } set mockerror(e) { - this.$$set({ mockerror: e }), v(); + this.$$set({ mockerror: e }), E(); } - get refetchonexpire() { + get obfuscated() { return this.$$.ctx[27]; } + set obfuscated(e) { + this.$$set({ obfuscated: e }), E(); + } + get refetchonexpire() { + return this.$$.ctx[28]; + } set refetchonexpire(e) { - this.$$set({ refetchonexpire: e }), v(); + this.$$set({ refetchonexpire: e }), E(); } get spamfilter() { - return this.$$.ctx[28]; + return this.$$.ctx[29]; } set spamfilter(e) { - this.$$set({ spamfilter: e }), v(); + this.$$set({ spamfilter: e }), E(); } get strings() { - return this.$$.ctx[35]; + return this.$$.ctx[36]; } set strings(e) { - this.$$set({ strings: e }), v(); + this.$$set({ strings: e }), E(); } get test() { - return this.$$.ctx[29]; + return this.$$.ctx[30]; } set test(e) { - this.$$set({ test: e }), v(); + this.$$set({ test: e }), E(); } get verifyurl() { - return this.$$.ctx[30]; + return this.$$.ctx[31]; } set verifyurl(e) { - this.$$set({ verifyurl: e }), v(); + this.$$set({ verifyurl: e }), E(); } get workers() { - return this.$$.ctx[31]; + return this.$$.ctx[32]; } set workers(e) { - this.$$set({ workers: e }), v(); + this.$$set({ workers: e }), E(); } get workerurl() { - return this.$$.ctx[32]; + return this.$$.ctx[33]; } set workerurl(e) { - this.$$set({ workerurl: e }), v(); + this.$$set({ workerurl: e }), E(); } get configure() { - return this.$$.ctx[36]; + return this.$$.ctx[37]; } get reset() { - return this.$$.ctx[37]; + return this.$$.ctx[38]; } get verify() { - return this.$$.ctx[38]; + return this.$$.ctx[39]; + } + get clarify() { + return this.$$.ctx[40]; } } -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)); +customElements.define("altcha-widget", pn(Bn, { 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" }, obfuscated: {}, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, ["default"], ["configure", "reset", "verify", "clarify"], !1)); globalThis.createAltchaWorker = (n) => new Worker(new URL(n || "./worker.js", import.meta.url)); export { - En as Altcha + Bn as Altcha }; diff --git a/dist_external/altcha.umd.cjs b/dist_external/altcha.umd.cjs index 1b8c724..88a3641 100644 --- a/dist_external/altcha.umd.cjs +++ b/dist_external/altcha.umd.cjs @@ -1,2 +1,2 @@ -(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"})}); +(function(w,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(w=typeof globalThis<"u"?globalThis:w||self,E(w.altcha={}))})(this,function(w){"use strict";var Bn=Object.defineProperty;var Vt=w=>{throw TypeError(w)};var Hn=(w,E,F)=>E in w?Bn(w,E,{enumerable:!0,configurable:!0,writable:!0,value:F}):w[E]=F;var q=(w,E,F)=>Hn(w,typeof E!="symbol"?E+"":E,F),Pt=(w,E,F)=>E.has(w)||Vt("Cannot "+F);var X=(w,E,F)=>(Pt(w,E,"read from private field"),F?F.call(w):E.get(w)),de=(w,E,F)=>E.has(w)?Vt("Cannot add the same private member more than once"):E instanceof WeakSet?E.add(w):E.set(w,F),Ot=(w,E,F,Se)=>(Pt(w,E,"write to private field"),Se?Se.call(w,F):E.set(w,F),F);var ye,_e,pe,ke,Ce,Ae;var E=typeof document<"u"?document.currentScript:null;function F(){}function Se(n,e){for(const t in e)n[t]=e[t];return n}function Je(n){return n()}function Xe(){return Object.create(null)}function we(n){n.forEach(Je)}function We(n){return typeof n=="function"}function Bt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Ht(n){return Object.keys(n).length===0}function qt(n,e,t,r){if(n){const o=ze(n,e,t,r);return n[0](o)}}function ze(n,e,t,r){return n[1]&&r?Se(t.ctx.slice(),n[1](r(e))):t.ctx}function Zt(n,e,t,r){if(n[2]&&r){const o=n[2](r(t));if(e.dirty===void 0)return o;if(typeof o=="object"){const s=[],l=Math.max(e.dirty.length,o.length);for(let c=0;c32){const e=[],t=n.ctx.length/32;for(let r=0;rn.removeEventListener(e,t,r)}function a(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Xt(n){return Array.from(n.childNodes)}function Qe(n,e,t){n.classList.toggle(e,!!t)}function Wt(n,e,{bubbles:t=!1,cancelable:r=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:r})}function zt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let Ee;function ve(n){Ee=n}function Oe(){if(!Ee)throw new Error("Function called outside component initialization");return Ee}function Kt(n){Oe().$$.on_mount.push(n)}function Qt(n){Oe().$$.on_destroy.push(n)}function $t(){const n=Oe();return(e,t,{cancelable:r=!1}={})=>{const o=n.$$.callbacks[e];if(o){const s=Wt(e,t,{cancelable:r});return o.slice().forEach(l=>{l.call(n,s)}),!s.defaultPrevented}return!0}}const me=[],De=[];let ge=[];const $e=[],et=Promise.resolve();let Be=!1;function tt(){Be||(Be=!0,et.then(v))}function en(){return tt(),et}function He(n){ge.push(n)}const qe=new Set;let be=0;function v(){if(be!==0)return;const n=Ee;do{try{for(;ben.indexOf(r)===-1?e.push(r):t.push(r)),t.forEach(r=>r()),ge=e}const Me=new Set;let rn;function nt(n,e){n&&n.i&&(Me.delete(n),n.i(e))}function on(n,e,t,r){if(n&&n.o){if(Me.has(n))return;Me.add(n),rn.c.push(()=>{Me.delete(n)}),n.o(e)}}function sn(n,e,t){const{fragment:r,after_update:o}=n.$$;r&&r.m(e,t),He(()=>{const s=n.$$.on_mount.map(Je).filter(We);n.$$.on_destroy?n.$$.on_destroy.push(...s):we(s),n.$$.on_mount=[]}),o.forEach(He)}function ln(n,e){const t=n.$$;t.fragment!==null&&(nn(t.after_update),we(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function cn(n,e){n.$$.dirty[0]===-1&&(me.push(n),tt(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const z=C.length?C[0]:ie;return h.ctx&&o(h.ctx[I],h.ctx[I]=z)&&(!h.skip_bound&&h.bound[I]&&h.bound[I](z),_&&cn(n,I)),ie}):[],h.update(),_=!0,we(h.before_update),h.fragment=r?r(h.ctx):!1,e.target){if(e.hydrate){const I=Xt(e.target);h.fragment&&h.fragment.l(I),I.forEach(D)}else h.fragment&&h.fragment.c();e.intro&&nt(n.$$.fragment),sn(n,e.target,e.anchor),v()}ve(f)}let it;typeof HTMLElement=="function"&&(it=class extends HTMLElement{constructor(e,t,r){super();q(this,"$$ctor");q(this,"$$s");q(this,"$$c");q(this,"$$cn",!1);q(this,"$$d",{});q(this,"$$r",!1);q(this,"$$p_d",{});q(this,"$$l",{});q(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 l;return{c:function(){l=M("slot"),s!=="default"&&a(l,"name",s)},m:function(h,_){V(h,l,_)},d:function(h){h&&D(l)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},r=zt(this);for(const s of this.$$s)s in r&&(t[s]=[e(s)]);for(const s of this.attributes){const l=this.$$g_p(s.name);l in this.$$d||(this.$$d[l]=Ne(l,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 l=Ne(s,this.$$d[s],this.$$p_d,"toAttribute");l==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,l)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const s in this.$$l)for(const l of this.$$l[s]){const c=this.$$c.$on(s,l);this.$$l_u.set(l,c)}this.$$l={}}}attributeChangedCallback(e,t,r){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Ne(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 Ne(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(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 an(n,e,t,r,o,s){let l=class extends it{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(l.prototype,c,{get(){return this.$$c&&c in this.$$c?this.$$c[c]:this.$$d[c]},set(f){var h;f=Ne(c,f,e),this.$$d[c]=f,(h=this.$$c)==null||h.$set({[c]:f})}})}),r.forEach(c=>{Object.defineProperty(l.prototype,c,{get(){var f;return(f=this.$$c)==null?void 0:f[c]}})}),n.element=l,l}class un{constructor(){q(this,"$$");q(this,"$$set")}$destroy(){ln(this,1),this.$destroy=F}$on(e,t){if(!We(t))return F;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&&!Ht(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const hn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(hn);const rt=new TextEncoder;function dn(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function mn(n,e="SHA-256",t=1e5){const r=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await ot(r,n,e);return{algorithm:e,challenge:o,salt:r,signature:""}}async function ot(n,e,t){return dn(await crypto.subtle.digest(t.toUpperCase(),rt.encode(n+e)))}function gn(n,e,t="SHA-256",r=1e6,o=0){const s=new AbortController,l=Date.now();return{promise:(async()=>{for(let f=o;f<=r;f+=1){if(s.signal.aborted)return null;if(await ot(e,f,t)===n)return{number:f,took:Date.now()-l}}return null})(),controller:s}}function st(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function bn(n){const e=atob(n),t=new Uint8Array(e.length);for(let r=0;r{for(let _=r;_<=t;_+=1){if(s.signal.aborted||!f||!h)return null;try{const I=await crypto.subtle.decrypt({name:o,iv:yn(_)},f,h);if(I)return{clearText:new TextDecoder().decode(I),took:Date.now()-l}}catch{}}return null};let f=null,h=null;try{h=bn(n);const _=await crypto.subtle.digest("SHA-256",rt.encode(e));f=await crypto.subtle.importKey("raw",_,o,!1,["decrypt"])}catch{return{promise:Promise.reject(),controller:s}}return{promise:c(),controller:s}}class wn{constructor(e){q(this,"beaconUrl",null);q(this,"error",null);q(this,"loadTime",Date.now());q(this,"submitTime",null);q(this,"startTime",null);q(this,"viewTimeThresholdMs",1500);de(this,ye,{});de(this,_e,null);de(this,pe,this.onFormChange.bind(this));de(this,ke,this.onFormFocus.bind(this));de(this,Ce,this.onFormSubmit.bind(this));de(this,Ae,this.onUnload.bind(this));this.elForm=e,window.addEventListener("unload",X(this,Ae)),this.elForm.addEventListener("change",X(this,pe)),this.elForm.addEventListener("focusin",X(this,ke)),this.elForm.addEventListener("submit",X(this,Ce))}data(){const e=Object.entries(X(this,ye));return{correction:e.length&&e.filter(([t,r])=>r>1).length/e.length||0,dropoff:!this.submitTime&&!this.error&&X(this,_e)?X(this,_e):null,error:this.error,mobile:this.isMobile(),start:this.startTime,submit:this.submitTime,tz:st()}}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",X(this,Ae)),this.elForm.removeEventListener("change",X(this,pe)),this.elForm.removeEventListener("focusin",X(this,ke)),this.elForm.removeEventListener("submit",X(this,Ce))}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,_e,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){X(this,ye)[e]=(X(this,ye)[e]||0)+1}}ye=new WeakMap,_e=new WeakMap,pe=new WeakMap,ke=new WeakMap,Ce=new WeakMap,Ae=new WeakMap;var b=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(b||{});function lt(n){let e,t,r;return{c(){e=ne("svg"),t=ne("path"),r=ne("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,s){V(o,e,s),T(e,t),T(e,r)},d(o){o&&D(e)}}}function En(n){let e,t=n[13].label+"",r;return{c(){e=M("label"),a(e,"for",r=n[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")&&a(e,"for",r)},d(o){o&&D(e)}}}function vn(n){let e,t=n[13].verifying+"";return{c(){e=M("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 pn(n){let e,t=n[13].verified+"",r,o,s,l,c=n[11]&&ct(n);return{c(){e=M("span"),r=Q(),o=M("input"),s=Q(),c&&c.c(),l=Jt(),a(o,"type","hidden"),a(o,"name",n[4]),o.value=n[6]},m(f,h){V(f,e,h),e.innerHTML=t,V(f,r,h),V(f,o,h),V(f,s,h),c&&c.m(f,h),V(f,l,h)},p(f,h){h[0]&8192&&t!==(t=f[13].verified+"")&&(e.innerHTML=t),h[0]&16&&a(o,"name",f[4]),h[0]&64&&(o.value=f[6]),f[11]?c?c.p(f,h):(c=ct(f),c.c(),c.m(l.parentNode,l)):c&&(c.d(1),c=null)},d(f){f&&(D(e),D(r),D(o),D(s),D(l)),c&&c.d(f)}}}function ct(n){let e;return{c(){e=M("input"),a(e,"type","hidden"),a(e,"name","__session"),e.value=n[12]},m(t,r){V(t,e,r)},p(t,r){r[0]&4096&&(e.value=t[12])},d(t){t&&D(e)}}}function ft(n){let e,t,r,o,s,l,c;return{c(){e=M("div"),t=M("a"),r=ne("svg"),o=ne("path"),s=ne("path"),l=ne("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(l,"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(l,"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",mt),a(t,"target","_blank"),a(t,"class","altcha-logo"),a(t,"aria-label",c=n[13].ariaLinkLabel)},m(f,h){V(f,e,h),T(e,t),T(t,r),T(r,o),T(r,s),T(r,l)},p(f,h){h[0]&8192&&c!==(c=f[13].ariaLinkLabel)&&a(t,"aria-label",c)},d(f){f&&D(e)}}}function at(n){let e,t,r,o;function s(f,h){return f[7]===b.EXPIRED?Cn:kn}let l=s(n),c=l(n);return{c(){e=M("div"),t=ne("svg"),r=ne("path"),o=Q(),c.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(f,h){V(f,e,h),T(e,t),T(t,r),T(e,o),c.m(e,null)},p(f,h){l===(l=s(f))&&c?c.p(f,h):(c.d(1),c=l(f),c&&(c.c(),c.m(e,null)))},d(f){f&&D(e),c.d()}}}function kn(n){let e,t=n[13].error+"";return{c(){e=M("div"),a(e,"title",n[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&&a(e,"title",r[5])},d(r){r&&D(e)}}}function Cn(n){let e,t=n[13].expired+"";return{c(){e=M("div"),a(e,"title",n[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&&a(e,"title",r[5])},d(r){r&&D(e)}}}function ut(n){let e,t,r=n[13].footer+"";return{c(){e=M("div"),t=M("div"),a(e,"class","altcha-footer")},m(o,s){V(o,e,s),T(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 ht(n){let e;return{c(){e=M("div"),a(e,"class","altcha-anchor-arrow")},m(t,r){V(t,e,r),n[46](e)},p:F,d(t){t&&D(e),n[46](null)}}}function An(n){let e,t,r,o,s,l,c,f,h,_,I,ie,C,z,G,re,oe;const N=n[44].default,Z=qt(N,n,n[43],null);let P=n[7]===b.VERIFYING&<();function ce(d,L){return d[7]===b.VERIFIED?pn:d[7]===b.VERIFYING?vn:En}let se=ce(n),J=se(n),R=(n[3]!==!0||n[14])&&ft(n),j=(n[5]||n[7]===b.EXPIRED)&&at(n),A=n[13].footer&&(n[2]!==!0||n[14])&&ut(n),U=n[1]&&ht(n);return{c(){Z&&Z.c(),e=Q(),t=M("div"),r=M("div"),P&&P.c(),o=Q(),s=M("div"),l=M("input"),h=Q(),_=M("div"),J.c(),I=Q(),R&&R.c(),ie=Q(),j&&j.c(),C=Q(),A&&A.c(),z=Q(),U&&U.c(),a(l,"type","checkbox"),a(l,"id",c=n[4]+"_checkbox"),l.required=f=n[0]!=="onsubmit",a(s,"class","altcha-checkbox"),Qe(s,"altcha-hidden",n[7]===b.VERIFYING),a(_,"class","altcha-label"),a(r,"class","altcha-main"),a(t,"class","altcha"),a(t,"data-state",n[7]),a(t,"data-floating",n[1])},m(d,L){Z&&Z.m(d,L),V(d,e,L),V(d,t,L),T(t,r),P&&P.m(r,null),T(r,o),T(r,s),T(s,l),l.checked=n[8],T(r,h),T(r,_),J.m(_,null),T(r,I),R&&R.m(r,null),T(t,ie),j&&j.m(t,null),T(t,C),A&&A.m(t,null),T(t,z),U&&U.m(t,null),n[47](t),G=!0,re||(oe=[Pe(l,"change",n[45]),Pe(l,"change",n[15]),Pe(l,"invalid",n[16])],re=!0)},p(d,L){Z&&Z.p&&(!G||L[1]&4096)&&Gt(Z,N,d,d[43],G?Zt(N,d[43],L,null):Yt(d[43]),null),d[7]===b.VERIFYING?P||(P=lt(),P.c(),P.m(r,o)):P&&(P.d(1),P=null),(!G||L[0]&16&&c!==(c=d[4]+"_checkbox"))&&a(l,"id",c),(!G||L[0]&1&&f!==(f=d[0]!=="onsubmit"))&&(l.required=f),L[0]&256&&(l.checked=d[8]),(!G||L[0]&128)&&Qe(s,"altcha-hidden",d[7]===b.VERIFYING),se===(se=ce(d))&&J?J.p(d,L):(J.d(1),J=se(d),J&&(J.c(),J.m(_,null))),d[3]!==!0||d[14]?R?R.p(d,L):(R=ft(d),R.c(),R.m(r,null)):R&&(R.d(1),R=null),d[5]||d[7]===b.EXPIRED?j?j.p(d,L):(j=at(d),j.c(),j.m(t,C)):j&&(j.d(1),j=null),d[13].footer&&(d[2]!==!0||d[14])?A?A.p(d,L):(A=ut(d),A.c(),A.m(t,z)):A&&(A.d(1),A=null),d[1]?U?U.p(d,L):(U=ht(d),U.c(),U.m(t,null)):U&&(U.d(1),U=null),(!G||L[0]&128)&&a(t,"data-state",d[7]),(!G||L[0]&2)&&a(t,"data-floating",d[1])},i(d){G||(nt(Z,d),G=!0)},o(d){on(Z,d),G=!1},d(d){d&&(D(e),D(t)),Z&&Z.d(d),P&&P.d(),J.d(),R&&R.d(),j&&j.d(),A&&A.d(),U&&U.d(),n[47](null),re=!1,we(oe)}}}const dt="Visit Altcha.org",mt="https://altcha.org/";function gt(n){return JSON.parse(n)}function Ln(n,e,t){var Nt,jt;let r,o,s,l,{$$slots:c={},$$scope:f}=e,{analytics:h=!1}=e,{auto:_=void 0}=e,{beaconurl:I=void 0}=e,{blockspam:ie=void 0}=e,{challengeurl:C=void 0}=e,{challengejson:z=void 0}=e,{debug:G=!1}=e,{delay:re=0}=e,{expire:oe=void 0}=e,{floating:N=void 0}=e,{floatinganchor:Z=void 0}=e,{floatingoffset:P=void 0}=e,{hidefooter:ce=!1}=e,{hidelogo:se=!1}=e,{name:J="altcha"}=e,{maxnumber:R=1e6}=e,{mockerror:j=!1}=e,{obfuscated:A=void 0}=e,{refetchonexpire:U=!0}=e,{spamfilter:d=!1}=e,{strings:L=void 0}=e,{test:K=!1}=e,{verifyurl:fe=void 0}=e,{workers:Le=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:je=void 0}=e;const Ze=$t(),yt=["SHA-256","SHA-384","SHA-512"],_t=(jt=(Nt=document.documentElement.lang)==null?void 0:Nt.split("-"))==null?void 0:jt[0];let $=!1,ee=null,k,ae=null,Ue=null,y=null,le=null,xe=null,te=null,ue=null,Y=null,wt=null,S=b.UNVERIFIED;Qt(()=>{y&&(y.removeEventListener("submit",pt),y.removeEventListener("reset",kt),y.removeEventListener("focusin",vt),y=null),le&&k.removeEventListener("click",Et),Y&&Y.destroy(),te&&(clearTimeout(te),te=null),document.removeEventListener("click",Tt),document.removeEventListener("scroll",Rt),window.removeEventListener("resize",St)}),Kt(()=>{var i,u;x("mounted","0.8.0"),x("workers",Le),K&&x("using test mode"),oe&&Ve(oe),_!==void 0&&x("auto",_),N!==void 0&&Dt(N),y=k.closest("form"),y&&(y.addEventListener("submit",pt,{capture:!0}),y.addEventListener("reset",kt),_==="onfocus"&&y.addEventListener("focusin",vt)),le=((i=k.parentElement)==null?void 0:i.querySelector("[data-clarify-button]"))||((u=k.parentElement)==null?void 0:u.querySelector("button, a")),le&&le.addEventListener("click",Et),h&&Lt(),_==="onload"&&(A?Te():he()),r&&(ce||se)&&x("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.")});function x(...i){(G||i.some(u=>u instanceof Error))&&console[i[0]instanceof Error?"error":"log"]("ALTCHA",...i)}function Et(i){i.preventDefault(),S===b.UNVERIFIED&&Te()}function vt(i){S===b.UNVERIFIED&&he()}function pt(i){y&&Y&&S===b.VERIFIED&&(Y.end(),t(12,wt=Y.dataAsBase64())),y&&_==="onsubmit"&&(S===b.UNVERIFIED?(i.preventDefault(),i.stopPropagation(),he().then(()=>{y==null||y.requestSubmit()})):S!==b.VERIFIED&&(i.preventDefault(),i.stopPropagation(),S===b.VERIFYING&&Ft()))}function kt(){Ie()}function Ct(i,u){return btoa(JSON.stringify({algorithm:i.algorithm,challenge:i.challenge,number:u.number,salt:i.salt,signature:i.signature,test:K?!0:void 0,took:u.took}))}function At(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(!yt.includes(i.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${yt.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 xn(){var i;if(j)throw x("mocking error"),new Error("Mocked error.");if(o)return x("using provided json data"),o;if(K)return x("generating test challenge",{test:K}),mn(typeof K!="boolean"?+K:void 0);{if(!C&&y){const p=y.getAttribute("action");p!=null&&p.includes("/form/")&&t(17,C=p+"/altcha")}if(!C)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",C);const u=await fetch(C,{headers:d?{"x-altcha-spam-filter":"1"}:{}});if(u.status!==200)throw new Error(`Server responded with ${u.status}.`);const m=u.headers.get("Expires"),g=u.headers.get("X-Altcha-Config"),O=await u.json(),B=new URLSearchParams((i=O.salt.split("?"))==null?void 0:i[1]),H=B.get("expires")||B.get("expire");if(H){const p=new Date(+H*1e3),W=isNaN(p.getTime())?0:p.getTime()-Date.now();W>0&&Ve(W)}if(g)try{const p=JSON.parse(g);p&&typeof p=="object"&&(p.verifyurl&&(p.verifyurl=new URL(p.verifyurl,new URL(C)).toString()),Mt(p))}catch(p){x("unable to configure from X-Altcha-Config",p)}if(!oe&&(m!=null&&m.length)){const p=Date.parse(m);if(p){const W=p-Date.now();W>0&&Ve(W)}}return O}}function Lt(){if(!Y)if(y){if(x("analytics enabled"),t(11,Y=new wn(y)),I===void 0){const i=y.getAttribute("action");i&&t(19,I=i+"/beacon")}t(11,Y.beaconUrl=I||null,Y)}else x("analytics cannot be enabled - form element not found")}function xt(){C&&U&&S===b.VERIFIED?he():Ie(b.EXPIRED,l.expired)}async function It(i){let u=null;if("Worker"in window){try{u=await In(i,i.maxnumber)}catch(m){x(m)}if((u==null?void 0:u.number)!==void 0||"obfuscated"in i)return{data:i,solution:u}}if("obfuscated"in i){const m=await _n(i.obfuscated,i.key,i.maxnumber);return{data:i,solution:await m.promise}}return{data:i,solution:await gn(i.challenge,i.salt,i.algorithm,i.maxnumber||R).promise}}async function In(i,u=typeof K=="number"?K:R,m=Math.ceil(Le)){const g=[];m=Math.min(16,Math.max(1,m));for(let H=0;H{const W=p*O;return new Promise(Ye=>{H.addEventListener("message",Re=>{if(Re.data)for(const Fe of g)Fe!==H&&Fe.postMessage({type:"abort"});Ye(Re.data)}),H.postMessage({payload:i,max:W+O,start:W,type:"work"})})}));for(const H of g)H.terminate();return B.find(H=>!!H)||null}function Tn(){[b.UNVERIFIED,b.ERROR,b.EXPIRED].includes(S)?d&&(y==null?void 0:y.reportValidity())===!1?t(8,$=!1):A?Te():he():t(8,$=!0)}function Tt(i){const u=i.target;N&&u&&!k.contains(u)&&S===b.VERIFIED&&t(9,k.style.display="none",k)}function Rt(){N&&Ge()}function Ft(){S===b.VERIFYING&&l.waitAlert&&alert(l.waitAlert)}function Rn(i){var u;if(ee){const m=ee.match(/^(mailto|tel|sms|https?):/);let g;if(m){const[O]=ee.slice(ee.indexOf(":")+1).replace(/^\/\//,"").split("?");g=document.createElement("a"),g.href=ee,g.innerHTML=O}else g=document.createTextNode(ee);le&&g&&(le.after(g),(u=le.parentElement)==null||u.removeChild(le))}}function Fn(i){Y&&Y.trackError(xe)}function Sn(i){N&&S!==b.UNVERIFIED&&requestAnimationFrame(()=>{Ge()})}function St(){N&&Ge()}function Ve(i){x("expire",i),te&&(clearTimeout(te),te=null),i<1?xt():te=setTimeout(xt,i)}function Dt(i){x("floating",i),N!==i&&(t(9,k.style.left="",k),t(9,k.style.top="",k)),t(1,N=i===!0||i===""?"auto":i===!1||i==="false"?void 0:N),N?(_||t(0,_="onsubmit"),document.addEventListener("scroll",Rt),document.addEventListener("click",Tt),window.addEventListener("resize",St)):_==="onsubmit"&&t(0,_=void 0)}function Dn(i){var m;const u=y==null?void 0:y.querySelector(typeof i=="string"?`input[name="${i}"]`:'input[type="email"]:not([data-no-spamfilter])');return((m=u==null?void 0:u.value)==null?void 0:m.slice(u.value.indexOf("@")))||void 0}function Mn(i){return[...(y==null?void 0:y.querySelectorAll(i!=null&&i.length?i.map(m=>`input[name="${m}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((m,g)=>{const O=g.name,B=g.value;return O&&B&&(m[O]=/\n/.test(B)?B.replace(new RegExp("(?O:N==="top",p=Math.max(i,Math.min(B-i-g.width,m.left+m.width/2-g.width/2));if(H?t(9,k.style.top=`${m.top-(g.height+u)}px`,k):t(9,k.style.top=`${m.bottom+u}px`,k),t(9,k.style.left=`${p}px`,k),k.setAttribute("data-floating",H?"top":"bottom"),ae){const W=ae.getBoundingClientRect();t(10,ae.style.left=m.left-p+m.width/2-W.width/2+"px",ae)}}else x("unable to find floating anchor element")}function Mt(i){i.analytics&&(t(18,h=i.analytics),Lt()),i.obfuscated!==void 0&&t(27,A=i.obfuscated),i.auto!==void 0&&(t(0,_=i.auto),_==="onload"&&(A?Te():he())),i.beaconurl&&(t(19,I=i.beaconurl),Y&&t(11,Y.beaconUrl=I,Y)),i.floatinganchor!==void 0&&t(23,Z=i.floatinganchor),i.delay!==void 0&&t(21,re=i.delay),i.floatingoffset!==void 0&&t(24,P=i.floatingoffset),i.floating!==void 0&&Dt(i.floating),i.expire!==void 0&&(Ve(i.expire),t(22,oe=i.expire)),i.challenge&&(At(i.challenge),o=i.challenge),i.challengeurl!==void 0&&t(17,C=i.challengeurl),i.debug!==void 0&&t(20,G=!!i.debug),i.hidefooter!==void 0&&t(2,ce=!!i.hidefooter),i.hidelogo!==void 0&&t(3,se=!!i.hidelogo),i.maxnumber!==void 0&&t(25,R=+i.maxnumber),i.mockerror!==void 0&&t(26,j=!!i.mockerror),i.name!==void 0&&t(4,J=i.name),i.refetchonexpire!==void 0&&t(28,U=!!i.refetchonexpire),i.spamfilter!==void 0&&t(29,d=typeof i.spamfilter=="object"?i.spamfilter:!!i.spamfilter),i.strings&&t(42,s=i.strings),i.test!==void 0&&t(30,K=typeof i.test=="number"?i.test:!!i.test),i.verifyurl!==void 0&&t(31,fe=i.verifyurl),i.workers!==void 0&&t(32,Le=+i.workers),i.workerurl!==void 0&&t(33,je=i.workerurl)}function Ie(i=b.UNVERIFIED,u=null){te&&(clearTimeout(te),te=null),t(8,$=!1),t(5,xe=u),t(6,ue=null),t(7,S=i)}async function he(){return Ie(b.VERIFYING),await new Promise(i=>setTimeout(i,re||0)),xn().then(i=>(At(i),x("challenge",i),It(i))).then(({data:i,solution:u})=>{if(x("solution",u),"challenge"in i&&u&&!("clearText"in u))if((u==null?void 0:u.number)!==void 0){if(fe)return Nn(Ct(i,u));t(6,ue=Ct(i,u)),x("payload",ue)}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(()=>{en().then(()=>{t(7,S=b.VERIFIED),t(8,$=!0),x("verified"),Ze("verified",{payload:ue})})}).catch(i=>{x(i),t(7,S=b.ERROR),t(8,$=!1),t(5,xe=i.message)})}async function Te(){if(!A){t(7,S=b.ERROR);return}Ie(b.VERIFYING),await new Promise(B=>setTimeout(B,re||0));const[i,u]=A.split("?");let g=new URLSearchParams(u||"").get("key")||void 0;if(g){const B=g.match(/^\(prompt:?(.*)\)$/);B&&(g=prompt(B[1]||"Enter Key:")||void 0)}const{solution:O}=await It({obfuscated:i,key:g,maxnumber:R});O&&"clearText"in O?(t(41,ee=O.clearText),t(7,S=b.VERIFIED),t(8,$=!0),N&&k&&t(9,k.style.display="none",k)):(t(7,S=b.ERROR),t(8,$=!1),t(5,xe="Unable to decrypt data."))}function Un(){$=this.checked,t(8,$)}function Vn(i){De[i?"unshift":"push"](()=>{ae=i,t(10,ae)})}function Pn(i){De[i?"unshift":"push"](()=>{k=i,t(9,k)})}return n.$$set=i=>{"analytics"in i&&t(18,h=i.analytics),"auto"in i&&t(0,_=i.auto),"beaconurl"in i&&t(19,I=i.beaconurl),"blockspam"in i&&t(34,ie=i.blockspam),"challengeurl"in i&&t(17,C=i.challengeurl),"challengejson"in i&&t(35,z=i.challengejson),"debug"in i&&t(20,G=i.debug),"delay"in i&&t(21,re=i.delay),"expire"in i&&t(22,oe=i.expire),"floating"in i&&t(1,N=i.floating),"floatinganchor"in i&&t(23,Z=i.floatinganchor),"floatingoffset"in i&&t(24,P=i.floatingoffset),"hidefooter"in i&&t(2,ce=i.hidefooter),"hidelogo"in i&&t(3,se=i.hidelogo),"name"in i&&t(4,J=i.name),"maxnumber"in i&&t(25,R=i.maxnumber),"mockerror"in i&&t(26,j=i.mockerror),"obfuscated"in i&&t(27,A=i.obfuscated),"refetchonexpire"in i&&t(28,U=i.refetchonexpire),"spamfilter"in i&&t(29,d=i.spamfilter),"strings"in i&&t(36,L=i.strings),"test"in i&&t(30,K=i.test),"verifyurl"in i&&t(31,fe=i.verifyurl),"workers"in i&&t(32,Le=i.workers),"workerurl"in i&&t(33,je=i.workerurl),"$$scope"in i&&t(43,f=i.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&131072&&t(14,r=!!(C!=null&&C.includes(".altcha.org"))&&!!(C!=null&&C.includes("apiKey=ckey_"))),n.$$.dirty[1]&16&&(o=z?gt(z):void 0),n.$$.dirty[1]&32&&t(42,s=L?gt(L):{}),n.$$.dirty[1]&2048&&t(13,l={ariaLinkLabel:dt,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|n.$$.dirty[1]&1024&&Ze("statechange",ee?{clarifiedData:ee,state:S}:{payload:ue,state:S}),n.$$.dirty[0]&32&&Fn(),n.$$.dirty[0]&128&&Sn(),n.$$.dirty[1]&1024&&Rn()},[_,N,ce,se,J,xe,ue,S,$,k,ae,Y,wt,l,r,Tn,Ft,C,h,I,G,re,oe,Z,P,R,j,A,U,d,K,fe,Le,je,ie,z,L,Mt,Ie,he,Te,ee,s,f,c,Un,Vn,Pn]}class bt extends un{constructor(e){super(),fn(this,e,Ln,An,Bt,{analytics:18,auto:0,beaconurl:19,blockspam:34,challengeurl:17,challengejson:35,debug:20,delay:21,expire:22,floating:1,floatinganchor:23,floatingoffset:24,hidefooter:2,hidelogo:3,name:4,maxnumber:25,mockerror:26,obfuscated:27,refetchonexpire:28,spamfilter:29,strings:36,test:30,verifyurl:31,workers:32,workerurl:33,configure:37,reset:38,verify:39,clarify:40},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}),v()}get beaconurl(){return this.$$.ctx[19]}set beaconurl(e){this.$$set({beaconurl:e}),v()}get blockspam(){return this.$$.ctx[34]}set blockspam(e){this.$$set({blockspam:e}),v()}get challengeurl(){return this.$$.ctx[17]}set challengeurl(e){this.$$set({challengeurl:e}),v()}get challengejson(){return this.$$.ctx[35]}set challengejson(e){this.$$set({challengejson:e}),v()}get debug(){return this.$$.ctx[20]}set debug(e){this.$$set({debug:e}),v()}get delay(){return this.$$.ctx[21]}set delay(e){this.$$set({delay:e}),v()}get expire(){return this.$$.ctx[22]}set expire(e){this.$$set({expire:e}),v()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),v()}get floatinganchor(){return this.$$.ctx[23]}set floatinganchor(e){this.$$set({floatinganchor:e}),v()}get floatingoffset(){return this.$$.ctx[24]}set floatingoffset(e){this.$$set({floatingoffset:e}),v()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),v()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),v()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),v()}get maxnumber(){return this.$$.ctx[25]}set maxnumber(e){this.$$set({maxnumber:e}),v()}get mockerror(){return this.$$.ctx[26]}set mockerror(e){this.$$set({mockerror:e}),v()}get obfuscated(){return this.$$.ctx[27]}set obfuscated(e){this.$$set({obfuscated:e}),v()}get refetchonexpire(){return this.$$.ctx[28]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),v()}get spamfilter(){return this.$$.ctx[29]}set spamfilter(e){this.$$set({spamfilter:e}),v()}get strings(){return this.$$.ctx[36]}set strings(e){this.$$set({strings:e}),v()}get test(){return this.$$.ctx[30]}set test(e){this.$$set({test:e}),v()}get verifyurl(){return this.$$.ctx[31]}set verifyurl(e){this.$$set({verifyurl:e}),v()}get workers(){return this.$$.ctx[32]}set workers(e){this.$$set({workers:e}),v()}get workerurl(){return this.$$.ctx[33]}set workerurl(e){this.$$set({workerurl:e}),v()}get configure(){return this.$$.ctx[37]}get reset(){return this.$$.ctx[38]}get verify(){return this.$$.ctx[39]}get clarify(){return this.$$.ctx[40]}}customElements.define("altcha-widget",an(bt,{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"},obfuscated:{},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},["default"],["configure","reset","verify","clarify"],!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:E&&E.src||new URL("altcha.umd.cjs",document.baseURI).href)),w.Altcha=bt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}); diff --git a/dist_external/worker.js b/dist_external/worker.js index eb5f2cc..d57824d 100644 --- a/dist_external/worker.js +++ b/dist_external/worker.js @@ -1 +1 @@ -(function(){"use strict";const f=new TextEncoder;function d(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}async function p(e,t,o){return d(await crypto.subtle.digest(o.toUpperCase(),f.encode(e+t)))}function g(e,t,o="SHA-256",l=1e6,c=0){const a=new AbortController,i=Date.now();return{promise:(async()=>{for(let n=c;n<=l;n+=1){if(a.signal.aborted)return null;if(await p(t,n,o)===e)return{number:n,took:Date.now()-i}}return null})(),controller:a}}let r;onmessage=async e=>{const{type:t,payload:o}=e.data;if(t==="abort")r==null||r.abort(),r=void 0;else if(t==="work"){const{alg:l,challenge:c,max:a,salt:i,start:u}=o||{},n=g(c,i,l,a,u);r=n.controller,n.promise.then(s=>{self.postMessage(s&&{...s,worker:!0})})}}})(); +(function(){"use strict";const f=new TextEncoder;function p(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}async function w(e,t,r){return p(await crypto.subtle.digest(r.toUpperCase(),f.encode(e+t)))}function b(e,t,r="SHA-256",n=1e6,s=0){const o=new AbortController,a=Date.now();return{promise:(async()=>{for(let c=s;c<=n;c+=1){if(o.signal.aborted)return null;if(await w(t,c,r)===e)return{number:c,took:Date.now()-a}}return null})(),controller:o}}function h(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n{for(let u=n;u<=r;u+=1){if(o.signal.aborted||!c||!y)return null;try{const d=await crypto.subtle.decrypt({name:s,iv:g(u)},c,y);if(d)return{clearText:new TextDecoder().decode(d),took:Date.now()-a}}catch{}}return null};let c=null,y=null;try{y=h(e);const u=await crypto.subtle.digest("SHA-256",f.encode(t));c=await crypto.subtle.importKey("raw",u,s,!1,["decrypt"])}catch{return{promise:Promise.reject(),controller:o}}return{promise:l(),controller:o}}let i;onmessage=async e=>{const{type:t,payload:r,start:n,max:s}=e.data;let o=null;if(t==="abort")i==null||i.abort(),i=void 0;else if(t==="work"){if("obfuscated"in r){const{key:a,obfuscated:l}=r||{};o=await m(l,a,s,n)}else{const{algorithm:a,challenge:l,salt:c}=r||{};o=b(l,c,a,s,n)}i=o.controller,o.promise.then(a=>{self.postMessage(a&&{...a,worker:!0})})}}})(); diff --git a/package-lock.json b/package-lock.json index e563331..cebe6a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "altcha", - "version": "0.7.0", + "version": "0.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "altcha", - "version": "0.7.0", + "version": "0.8.0", "license": "MIT", "devDependencies": { "@playwright/test": "^1.44.1", diff --git a/package.json b/package.json index 031fec5..3b7f6e0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "altcha", "description": "GDPR compliant, self-hosted CAPTCHA alternative.", - "version": "0.7.0", + "version": "0.8.0", "license": "MIT", "author": { "name": "Daniel Regeci", diff --git a/scripts/obfuscate.ts b/scripts/obfuscate.ts new file mode 100644 index 0000000..c4edd8e --- /dev/null +++ b/scripts/obfuscate.ts @@ -0,0 +1,64 @@ +/** + * Run this script with Bun: + * + * bun run scripts/obfuscate.ts "mailto:..." + * + * or with Node: + * + * npx tsx scripts/obfuscate.ts "mailto:..." + */ + +const MAX_NUMBER = parseInt(process.env.MAX_NUMBER || '10000', 10); +const NUMBER = process.env.NUMBER ? parseInt(process.env.NUMBER || '0', 10) : undefined; +const KEY = process.env.KEY || ''; + +function randomInt(max: number) { + const ab = new Uint32Array(1); + crypto.getRandomValues(ab); + const randomNumber = ab[0] / (0xffffffff + 1); + return Math.floor(randomNumber * max + 1); +} + +async function uInt8ArrayToBase64(ua: Uint8Array) { + return Buffer.from(ua).toString('base64'); +} + +function numberToUint8Array(num: number, len: number = 12) { + const ua = new Uint8Array(len); + for (let i = 0; i < len; i++) { + ua[i] = num % 256; + num = Math.floor(num / 256); + } + return ua; +} + +async function obfuscateData( + raw: string, + key: string = '', + number: number = NUMBER || randomInt(MAX_NUMBER), +) { + const encoder = new TextEncoder(); + const encodedData = encoder.encode(raw); + const algorithm = { name: 'AES-GCM', iv: numberToUint8Array(number) }; + const keyHash = await crypto.subtle.digest( + 'SHA-256', + encoder.encode(key) + ); + const keyData = await crypto.subtle.importKey( + 'raw', + keyHash, + algorithm, + false, + ['encrypt'] + ); + const encryptedData = await crypto.subtle.encrypt( + algorithm, + keyData, + encodedData + ); + return uInt8ArrayToBase64(new Uint8Array(encryptedData)); +} + +console.log(await obfuscateData(process.argv[process.argv.length - 1], KEY)); + +export {}; \ No newline at end of file diff --git a/src/Altcha.svelte b/src/Altcha.svelte index d6c6c5d..60304ba 100644 --- a/src/Altcha.svelte +++ b/src/Altcha.svelte @@ -7,7 +7,12 @@ + +
{#if state === State.VERIFYING} @@ -850,7 +959,7 @@ {#if session} - + {/if} {:else if state === State.VERIFYING} {@html _strings.verifying} diff --git a/src/App.svelte b/src/App.svelte index 7611bc1..8642c36 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -15,6 +15,7 @@ let mockerror: boolean = false; let altcha: Altcha; + let altchaObfuscated: Altcha; onMount(() => { location.hash = ''; @@ -100,6 +101,20 @@
+ +
+ Email: + console.log('Event: statechange:', ev.detail)} + delay={1500} + name="email" + floating + > + (click to reveal) + +