altcha 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -59,14 +59,17 @@ Required options (at least one is required):
59
59
 
60
60
  Additional options:
61
61
 
62
- - __auto__ - Automatically verify without user interaction (possible values: `onload`, `onsubmit`).
62
+ - __auto__ - Automatically verify without user interaction (possible values: `onfocus`, `onload`, `onsubmit`).
63
+ - __blockspam__ - Only used in conjunction with the `spamfilter` option. If enabled, it will block form submission and fail verification if the Spam Filter returns a negative classification. This effectively prevents submission of the form.
63
64
  - __expire__ - The challenge expiration (duration in milliseconds).
64
65
  - __hidefooter__ - Hide the footer (ALTCHA link).
65
66
  - __hidelogo__ - Hide the ALTCHA logo.
66
67
  - __maxnumber__ - The max. number to iterate to (defaults to 1,000,000).
67
68
  - __name__ - The name of the hidden field containing the payload (defaults to "altcha").
69
+ - __spamfilter__ - Enable [Spam Filter](#spam-filter).
68
70
  - __strings__ - JSON-encoded translation strings. Refer to [customization](/docs/widget-customization).
69
71
  - __refetchonexpire__ - Automatically re-fetch and re-validate when the challenge expires (defaults to true).
72
+ - __verifyurl__ - Enable server-side verification by configuring the URL to use for verification requests. This option can be used in conjunction with `spamfilter` to enable server-side verification.
70
73
  - __workers__ - The number of workers to utilize for PoW (defaults to `navigator.hardwareConcurrency || 8`).
71
74
 
72
75
  Development / testing options:
@@ -112,6 +115,7 @@ export interface Configure {
112
115
  mockerror?: boolean;
113
116
  name?: string;
114
117
  refetchonexpire?: boolean;
118
+ spamfilter: boolean | SpamFilter;
115
119
  strings?: {
116
120
  error?: string;
117
121
  footer?: string;
@@ -120,13 +124,15 @@ export interface Configure {
120
124
  verifying?: string;
121
125
  waitAlert?: string;
122
126
  };
123
- test?: boolean;
127
+ test?: boolean | number;
128
+ verifyurl?: string;
124
129
  workers?: number;
125
130
  }
126
131
  ```
127
132
 
128
133
  ## Events
129
134
 
135
+ - __serververification__ - Triggers upon a server verification (only in conjunction with `spamfilter`).
130
136
  - __statechange__ - Triggers whenever an internal `state` changes.
131
137
  - __verified__ - Triggers when the challenge is verified.
132
138
 
@@ -152,6 +158,40 @@ document.querySelector('#altcha').addEventListener('statechange', (ev) => {
152
158
  > [!IMPORTANT]
153
159
  > Both programmatic configuration and event listeners have to called/attached after the ALTCHA script loads, such as within window.addEventListener('load', ...).
154
160
 
161
+ ## Spam Filter
162
+
163
+ The widget integrates with ALTCHA's [Spam Filter API](https://altcha.org/docs/api/spam-filter-api) to allow checking submitted form data for potential spam.
164
+
165
+ The Spam Filter API analyzes various signals in the submitted data to determine if it exhibits characteristics of spam. This non-invasive filtering helps reduce spam submissions without frustrating legitimate users.
166
+
167
+ ### Spam Filter Configuration
168
+
169
+ The Spam Filter can be enabled with default configuration by setting the `spamfilter` option to `true`, or it can be customized using the following configuration schema:
170
+
171
+ ```ts
172
+ interface SpamFilter {
173
+ email?: string | false;
174
+ expectedLanguages?: string[];
175
+ expectedCountries?: string[];
176
+ fields?: string[] | false;
177
+ ipAddress?: string | false;
178
+ timeZone?: string | false;
179
+ }
180
+ ```
181
+
182
+ SpamFilter configuration options:
183
+
184
+ - __email__ - The name of the input field for the user's email. Disable email checking with `false`.
185
+ - __expectedLanguages__ - An array of expected languages as 2-letter codes (ISO 639 alpha-2).
186
+ - __expectedCountries__ - An array of expected countries as 2-letter codes (ISO 3166-1 alpha-2).
187
+ - __fields__ - An array of input names to send to the spam filter.
188
+ - __ipAddress__ - The user's IP is detected automatically but can be overridden or disabled with `false`.
189
+ - __timeZone__ - The user's timezone is detected automatically but can be overridden or disabled with `false`.
190
+
191
+ ### Exclude Inputs from Spam Checking
192
+
193
+ By default, all text inputs and textareas within the parent form are spam-checked. To exclude a specific input, add the `data-no-spamfilter` attribute. Alternatively, explicitly list the checked fields using the `fields` config option.
194
+
155
195
  ## Contributing
156
196
  See [Contributing Guide](https://github.com/altcha-org/altcha/blob/main/CONTRIBUTING.md) and please follow our [Code of Conduct](https://github.com/altcha-org/altcha/blob/main/CODE_OF_CONDUCT.md).
157
197
 
@@ -1 +1,2 @@
1
- var altcha=function(j){"use strict";var St=Object.defineProperty;var At=(j,L,P)=>L in j?St(j,L,{enumerable:!0,configurable:!0,writable:!0,value:P}):j[L]=P;var M=(j,L,P)=>(At(j,typeof L!="symbol"?L+"":L,P),P);function L(){}function P(t){return t()}function he(){return Object.create(null)}function K(t){t.forEach(P)}function de(t){return typeof t=="function"}function Ve(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Ze(t){return Object.keys(t).length===0}function b(t,e){t.appendChild(e)}function He(t,e,r){const i=Pe(t);if(!i.getElementById(e)){const o=w("style");o.id=e,o.textContent=r,Fe(i,o)}}function Pe(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Fe(t,e){return b(t.head||t,e),e.sheet}function I(t,e,r){t.insertBefore(e,r||null)}function R(t){t.parentNode&&t.parentNode.removeChild(t)}function w(t){return document.createElement(t)}function V(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Oe(t){return document.createTextNode(t)}function F(){return Oe(" ")}function ne(t,e,r,i){return t.addEventListener(e,r,i),()=>t.removeEventListener(e,r,i)}function c(t,e,r){r==null?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}function We(t){return Array.from(t.childNodes)}function ge(t,e,r){t.classList.toggle(e,!!r)}function De(t,e,{bubbles:r=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:r,cancelable:i})}function Be(t){const e={};return t.childNodes.forEach(r=>{e[r.slot||"default"]=!0}),e}let J;function z(t){J=t}function ie(){if(!J)throw new Error("Function called outside component initialization");return J}function Ye(t){ie().$$.on_mount.push(t)}function Ue(t){ie().$$.on_destroy.push(t)}function Xe(){const t=ie();return(e,r,{cancelable:i=!1}={})=>{const o=t.$$.callbacks[e];if(o){const l=De(e,r,{cancelable:i});return o.slice().forEach(s=>{s.call(t,l)}),!l.defaultPrevented}return!0}}const W=[],oe=[];let D=[];const be=[],me=Promise.resolve();let le=!1;function ve(){le||(le=!0,me.then(x))}function Ke(){return ve(),me}function se(t){D.push(t)}const ce=new Set;let B=0;function x(){if(B!==0)return;const t=J;do{try{for(;B<W.length;){const e=W[B];B++,z(e),Je(e.$$)}}catch(e){throw W.length=0,B=0,e}for(z(null),W.length=0,B=0;oe.length;)oe.pop()();for(let e=0;e<D.length;e+=1){const r=D[e];ce.has(r)||(ce.add(r),r())}D.length=0}while(W.length);for(;be.length;)be.pop()();le=!1,ce.clear(),z(t)}function Je(t){if(t.fragment!==null){t.update(),K(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(se)}}function ze(t){const e=[],r=[];D.forEach(i=>t.indexOf(i)===-1?e.push(i):r.push(i)),r.forEach(i=>i()),D=e}const Qe=new Set;function qe(t,e){t&&t.i&&(Qe.delete(t),t.i(e))}function et(t,e,r){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,r),se(()=>{const l=t.$$.on_mount.map(P).filter(de);t.$$.on_destroy?t.$$.on_destroy.push(...l):K(l),t.$$.on_mount=[]}),o.forEach(se)}function tt(t,e){const r=t.$$;r.fragment!==null&&(ze(r.after_update),K(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function rt(t,e){t.$$.dirty[0]===-1&&(W.push(t),ve(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function nt(t,e,r,i,o,l,s=null,u=[-1]){const a=J;z(t);const f=t.$$={fragment:null,ctx:[],props:l,update:L,not_equal:o,bound:he(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:he(),dirty:u,skip_bound:!1,root:e.target||a.$$.root};s&&s(f.root);let p=!1;if(f.ctx=r?r(t,e.props||{},(m,N,...A)=>{const S=A.length?A[0]:N;return f.ctx&&o(f.ctx[m],f.ctx[m]=S)&&(!f.skip_bound&&f.bound[m]&&f.bound[m](S),p&&rt(t,m)),N}):[],f.update(),p=!0,K(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const m=We(e.target);f.fragment&&f.fragment.l(m),m.forEach(R)}else f.fragment&&f.fragment.c();e.intro&&qe(t.$$.fragment),et(t,e.target,e.anchor),x()}z(a)}let we;typeof HTMLElement=="function"&&(we=class extends HTMLElement{constructor(e,r,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=r,i&&this.attachShadow({mode:"open"})}addEventListener(e,r,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(r),this.$$c){const o=this.$$c.$on(e,r);this.$$l_u.set(r,o)}super.addEventListener(e,r,i)}removeEventListener(e,r,i){if(super.removeEventListener(e,r,i),this.$$c){const o=this.$$l_u.get(r);o&&(o(),this.$$l_u.delete(r))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=w("slot"),l!=="default"&&c(s,"name",l)},m:function(f,p){I(f,s,p)},d:function(f){f&&R(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const r={},i=Be(this);for(const l of this.$$s)l in i&&(r[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=Q(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:r,$$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=Q(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 u=this.$$c.$on(l,s);this.$$l_u.set(s,u)}this.$$l={}}}attributeChangedCallback(e,r,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Q(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.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(r=>this.$$p_d[r].attribute===e||!this.$$p_d[r].attribute&&r.toLowerCase()===e)||e}});function Q(t,e,r,i){var l;const o=(l=r[t])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!r[t])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 it(t,e,r,i,o,l){let s=class extends we{constructor(){super(t,r,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(u=>(e[u].attribute||u).toLowerCase())}};return Object.keys(e).forEach(u=>{Object.defineProperty(s.prototype,u,{get(){return this.$$c&&u in this.$$c?this.$$c[u]:this.$$d[u]},set(a){var f;a=Q(u,a,e),this.$$d[u]=a,(f=this.$$c)==null||f.$set({[u]:a})}})}),i.forEach(u=>{Object.defineProperty(s.prototype,u,{get(){var a;return(a=this.$$c)==null?void 0:a[u]}})}),l&&(s=l(s)),t.element=s,s}class ot{constructor(){M(this,"$$");M(this,"$$set")}$destroy(){tt(this,1),this.$destroy=L}$on(e,r){if(!de(r))return L;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(r),()=>{const o=i.indexOf(r);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!Ze(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const lt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(lt);const _e="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGcodCl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KHQpXS5tYXAoZT0+ZS50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBoKHQsZSxvKXtyZXR1cm4gZyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUodCtlKSkpfWZ1bmN0aW9uIG0odCxlLG89IlNIQS0yNTYiLGk9MWU2LHA9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyO3JldHVybntwcm9taXNlOm5ldyBQcm9taXNlKChzLGMpPT57Y29uc3Qgcj1EYXRlLm5vdygpLGQ9bD0+e2Euc2lnbmFsLmFib3J0ZWR8fGw+aT9zKG51bGwpOmgoZSxsLG8pLnRoZW4odz0+e3c9PT10P3Moe251bWJlcjpsLHRvb2s6RGF0ZS5ub3coKS1yfSk6ZChsKzEpfSkuY2F0Y2goYyl9O2QocCl9KSxjb250cm9sbGVyOmF9fWxldCBuO29ubWVzc2FnZT1hc3luYyB0PT57Y29uc3R7dHlwZTplLHBheWxvYWQ6b309dC5kYXRhO2lmKGU9PT0iYWJvcnQiKW49PW51bGx8fG4uYWJvcnQoKSxuPXZvaWQgMDtlbHNlIGlmKGU9PT0id29yayIpe2NvbnN0e2FsZzppLGNoYWxsZW5nZTpwLG1heDphLHNhbHQ6dSxzdGFydDpzfT1vfHx7fSxjPW0ocCx1LGksYSxzKTtuPWMuY29udHJvbGxlcixjLnByb21pc2UudGhlbihyPT57c2VsZi5wb3N0TWVzc2FnZShyJiZ7Li4ucix3b3JrZXI6ITB9KX0pfX19KSgpOwo=",st=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),pe=typeof window<"u"&&window.Blob&&new Blob([st(_e)],{type:"text/javascript;charset=utf-8"});function ct(t){let e;try{if(e=pe&&(window.URL||window.webkitURL).createObjectURL(pe),!e)throw"";const r=new Worker(e,{name:t==null?void 0:t.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),r}catch{return new Worker("data:text/javascript;base64,"+_e,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const ut=new TextEncoder;function ft(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function at(t,e="SHA-256",r=1e5){const i=Date.now().toString(16);t||(t=Math.round(Math.random()*r));const o=await ye(i,t,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function ye(t,e,r){return ft(await crypto.subtle.digest(r.toUpperCase(),ut.encode(t+e)))}function ht(t,e,r="SHA-256",i=1e6,o=0){const l=new AbortController;return{promise:new Promise((u,a)=>{const f=Date.now(),p=m=>{l.signal.aborted||m>i?u(null):ye(e,m,r).then(N=>{N===t?u({number:m,took:Date.now()-f}):p(m+1)}).catch(a)};p(o)}),controller:l}}var g=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t.EXPIRED="expired",t))(g||{});function dt(t){He(t,"svelte-vuofbg",".altcha.svelte-vuofbg.svelte-vuofbg{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);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{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-vuofbg.svelte-vuofbg{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-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}")}function ke(t){let e,r,i;return{c(){e=V("svg"),r=V("path"),i=V("path"),c(r,"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(r,"fill","currentColor"),c(r,"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-vuofbg"),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){I(o,e,l),b(e,r),b(e,i)},d(o){o&&R(e)}}}function gt(t){let e,r=t[9].label+"",i;return{c(){e=w("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-vuofbg")},m(o,l){I(o,e,l),e.innerHTML=r},p(o,l){l[0]&512&&r!==(r=o[9].label+"")&&(e.innerHTML=r),l[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&R(e)}}}function bt(t){let e,r=t[9].verifying+"";return{c(){e=w("span")},m(i,o){I(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].verifying+"")&&(e.innerHTML=r)},d(i){i&&R(e)}}}function mt(t){let e,r=t[9].verified+"",i,o;return{c(){e=w("span"),i=F(),o=w("input"),c(o,"type","hidden"),c(o,"name",t[3]),o.value=t[4]},m(l,s){I(l,e,s),e.innerHTML=r,I(l,i,s),I(l,o,s)},p(l,s){s[0]&512&&r!==(r=l[9].verified+"")&&(e.innerHTML=r),s[0]&8&&c(o,"name",l[3]),s[0]&16&&(o.value=l[4])},d(l){l&&(R(e),R(i),R(o))}}}function $e(t){let e,r,i,o,l,s;return{c(){e=w("div"),r=w("a"),i=V("svg"),o=V("path"),l=V("path"),s=V("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(r,"href",Ce),c(r,"target","_blank"),c(r,"class","altcha-logo svelte-vuofbg")},m(u,a){I(u,e,a),b(e,r),b(r,i),b(i,o),b(i,l),b(i,s)},p:L,d(u){u&&R(e)}}}function Ee(t){let e,r,i,o;function l(a,f){return a[5]===g.EXPIRED?wt:vt}let s=l(t),u=s(t);return{c(){e=w("div"),r=V("svg"),i=V("path"),o=F(),u.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(r,"width","14"),c(r,"height","14"),c(r,"xmlns","http://www.w3.org/2000/svg"),c(r,"fill","none"),c(r,"viewBox","0 0 24 24"),c(r,"stroke-width","1.5"),c(r,"stroke","currentColor"),c(e,"class","altcha-error svelte-vuofbg")},m(a,f){I(a,e,f),b(e,r),b(r,i),b(e,o),u.m(e,null)},p(a,f){s===(s=l(a))&&u?u.p(a,f):(u.d(1),u=s(a),u&&(u.c(),u.m(e,null)))},d(a){a&&R(e),u.d()}}}function vt(t){let e,r=t[9].error+"";return{c(){e=w("div"),c(e,"title",t[8])},m(i,o){I(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].error+"")&&(e.innerHTML=r),o[0]&256&&c(e,"title",i[8])},d(i){i&&R(e)}}}function wt(t){let e,r=t[9].expired+"";return{c(){e=w("div"),c(e,"title",t[8])},m(i,o){I(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].expired+"")&&(e.innerHTML=r),o[0]&256&&c(e,"title",i[8])},d(i){i&&R(e)}}}function xe(t){let e,r,i=t[9].footer+"";return{c(){e=w("div"),r=w("div"),c(r,"class","svelte-vuofbg"),c(e,"class","altcha-footer svelte-vuofbg")},m(o,l){I(o,e,l),b(e,r),r.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(r.innerHTML=i)},d(o){o&&R(e)}}}function _t(t){let e,r,i,o,l,s,u,a,f,p,m,N,A,S,_=t[5]===g.VERIFYING&&ke();function O(h,E){return h[5]===g.VERIFIED?mt:h[5]===g.VERIFYING?bt:gt}let Z=O(t),y=Z(t),v=t[2]!==!0&&$e(),k=(t[8]||t[5]===g.EXPIRED)&&Ee(t),$=t[9].footer&&t[1]!==!0&&xe(t);return{c(){e=w("div"),r=w("div"),_&&_.c(),i=F(),o=w("div"),l=w("input"),a=F(),f=w("div"),y.c(),p=F(),v&&v.c(),m=F(),k&&k.c(),N=F(),$&&$.c(),c(l,"type","checkbox"),c(l,"id",s=t[3]+"_checkbox"),l.required=u=t[0]!=="onsubmit",c(l,"class","svelte-vuofbg"),c(o,"class","altcha-checkbox svelte-vuofbg"),ge(o,"altcha-hidden",t[5]===g.VERIFYING),c(f,"class","altcha-label svelte-vuofbg"),c(r,"class","altcha-main svelte-vuofbg"),c(e,"class","altcha svelte-vuofbg"),c(e,"data-state",t[5])},m(h,E){I(h,e,E),b(e,r),_&&_.m(r,null),b(r,i),b(r,o),b(o,l),l.checked=t[6],b(r,a),b(r,f),y.m(f,null),b(r,p),v&&v.m(r,null),b(e,m),k&&k.m(e,null),b(e,N),$&&$.m(e,null),t[27](e),A||(S=[ne(l,"change",t[26]),ne(l,"change",t[10]),ne(l,"invalid",t[11])],A=!0)},p(h,E){h[5]===g.VERIFYING?_||(_=ke(),_.c(),_.m(r,i)):_&&(_.d(1),_=null),E[0]&8&&s!==(s=h[3]+"_checkbox")&&c(l,"id",s),E[0]&1&&u!==(u=h[0]!=="onsubmit")&&(l.required=u),E[0]&64&&(l.checked=h[6]),E[0]&32&&ge(o,"altcha-hidden",h[5]===g.VERIFYING),Z===(Z=O(h))&&y?y.p(h,E):(y.d(1),y=Z(h),y&&(y.c(),y.m(f,null))),h[2]!==!0?v?v.p(h,E):(v=$e(),v.c(),v.m(r,null)):v&&(v.d(1),v=null),h[8]||h[5]===g.EXPIRED?k?k.p(h,E):(k=Ee(h),k.c(),k.m(e,N)):k&&(k.d(1),k=null),h[9].footer&&h[1]!==!0?$?$.p(h,E):($=xe(h),$.c(),$.m(e,null)):$&&($.d(1),$=null),E[0]&32&&c(e,"data-state",h[5])},i:L,o:L,d(h){h&&R(e),_&&_.d(),y.d(),v&&v.d(),k&&k.d(),$&&$.d(),t[27](null),A=!1,K(S)}}}const Ce="https://altcha.org/";function Le(t){return JSON.parse(t)}function pt(t,e,r){let i,o,l,{auto:s=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:a=void 0}=e,{debug:f=!1}=e,{expire:p=void 0}=e,{hidefooter:m=!1}=e,{hidelogo:N=!1}=e,{name:A="altcha"}=e,{maxnumber:S=1e6}=e,{mockerror:_=!1}=e,{refetchonexpire:O=!0}=e,{strings:Z=void 0}=e,{test:y=!1}=e,{workers:v=navigator.hardwareConcurrency||8}=e;const k=Xe(),$=["SHA-256","SHA-384","SHA-512"];let h=!1,E,T=null,ue=null,Y=null,H=g.UNVERIFIED,fe;Ue(()=>{T&&(T.removeEventListener("submit",Ie),T.removeEventListener("reset",Ne),T=null)}),Ye(()=>{C("mounted","0.2.3"),C("workers",v),y&&C("using test mode"),p&&ae(p),s!==void 0&&C("auto",s),T=E.closest("form"),T&&(T.addEventListener("submit",Ie),T.addEventListener("reset",Ne)),s==="onload"&&U()});function C(...n){(f||n.some(d=>d instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Ie(n){T&&s==="onsubmit"&&H===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),U().then(()=>{T==null||T.requestSubmit()}))}function Ne(){q()}function yt(n,d){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:d.number,salt:n.salt,signature:n.signature,test:y?!0:void 0,took:d.took}))}function Te(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(!$.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${$.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function kt(){if(_)throw C("mocking error"),new Error("Mocked error.");if(i)return C("using provided json data"),i;if(y)return C("generating test challenge"),at();{if(!u)throw new Error("Attribute challengeurl not set.");C("fetching challenge from",u);const n=await fetch(u);if(n.status!==200)throw new Error(`Server responded with ${n.status}.`);const d=n.headers.get("Expires");if(!p&&(d!=null&&d.length)){const X=Date.parse(d);if(X){const ee=X-Date.now();ee>0&&ae(ee)}}return n.json()}}function Me(){u&&O&&H===g.VERIFIED?U():q(g.EXPIRED,l.expired)}async function $t(n){let d=null;if("Worker"in window){try{d=await Et(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(X){C(X)}if((d==null?void 0:d.number)!==void 0)return{data:n,solution:d}}return{data:n,solution:await ht(n.challenge,n.salt,n.algorithm,n.maxnumber||S).promise}}async function Et(n,d,X,ee=S,te=Math.ceil(v)){const re=[];if(te<1)throw new Error("Wrong number of workers configured.");if(te>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let G=0;G<te;G++)re.push(new ct);const Se=Math.ceil(ee/te),Nt=await Promise.all(re.map((G,Tt)=>{const Ae=Tt*Se;return new Promise(Mt=>{G.addEventListener("message",Ge=>{if(Ge.data)for(const je of re)je!==G&&je.postMessage({type:"abort"});Mt(Ge.data)}),G.postMessage({payload:{alg:X,challenge:n,max:Ae+Se,salt:d,start:Ae},type:"work"})})}));for(const G of re)G.terminate();return Nt.find(G=>!!G)||null}function xt(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(H)?U():r(6,h=!0)}function Ct(){H===g.VERIFYING&&alert(l.waitAlert)}function ae(n){C("expire",n),clearTimeout(fe),n<1?Me():fe=setTimeout(Me,n)}function Lt(n){n.auto!==void 0&&(r(0,s=n.auto),s==="onload"&&U()),n.expire!==void 0&&(ae(n.expire),r(13,p=n.expire)),n.challenge&&(Te(n.challenge),i=n.challenge),n.debug!==void 0&&r(12,f=!!n.debug),n.hidefooter!==void 0&&r(1,m=!!n.hidefooter),n.hidelogo!==void 0&&r(2,N=!!n.hidelogo),n.maxnumber!==void 0&&r(14,S=+n.maxnumber),n.mockerror!==void 0&&r(15,_=!!n.mockerror),n.name!==void 0&&r(3,A=n.name),n.refetchonexpire!==void 0&&r(16,O=!!n.refetchonexpire),n.strings&&r(25,o=n.strings),n.test!==void 0&&r(17,y=!!n.test),n.workers!==void 0&&r(18,v=+n.workers)}function q(n=g.UNVERIFIED,d=null){clearTimeout(fe),r(6,h=!1),r(8,ue=d),r(4,Y=null),r(5,H=n)}async function U(){return q(g.VERIFYING),kt().then(n=>(Te(n),C("challenge",n),$t(n))).then(({data:n,solution:d})=>{if(C("solution",d),(d==null?void 0:d.number)!==void 0)C("verified"),r(5,H=g.VERIFIED),r(6,h=!0),r(4,Y=yt(n,d)),C("payload",Y),Ke().then(()=>{k("verified",{payload:Y})});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.")}).catch(n=>{C(n),r(5,H=g.ERROR),r(6,h=!1),r(8,ue=n.message)})}function Rt(){h=this.checked,r(6,h)}function It(n){oe[n?"unshift":"push"](()=>{E=n,r(7,E)})}return t.$$set=n=>{"auto"in n&&r(0,s=n.auto),"challengeurl"in n&&r(19,u=n.challengeurl),"challengejson"in n&&r(20,a=n.challengejson),"debug"in n&&r(12,f=n.debug),"expire"in n&&r(13,p=n.expire),"hidefooter"in n&&r(1,m=n.hidefooter),"hidelogo"in n&&r(2,N=n.hidelogo),"name"in n&&r(3,A=n.name),"maxnumber"in n&&r(14,S=n.maxnumber),"mockerror"in n&&r(15,_=n.mockerror),"refetchonexpire"in n&&r(16,O=n.refetchonexpire),"strings"in n&&r(21,Z=n.strings),"test"in n&&r(17,y=n.test),"workers"in n&&r(18,v=n.workers)},t.$$.update=()=>{t.$$.dirty[0]&1048576&&(i=a?Le(a):void 0),t.$$.dirty[0]&2097152&&r(25,o=Z?Le(Z):{}),t.$$.dirty[0]&33554432&&r(9,l={error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by <a href="${Ce}" target="_blank">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),t.$$.dirty[0]&48&&k("statechange",{payload:Y,state:H})},[s,m,N,A,Y,H,h,E,ue,l,xt,Ct,f,p,S,_,O,y,v,u,a,Z,Lt,q,U,o,Rt,It]}class Re extends ot{constructor(e){super(),nt(this,e,pt,_t,Ve,{auto:0,challengeurl:19,challengejson:20,debug:12,expire:13,hidefooter:1,hidelogo:2,name:3,maxnumber:14,mockerror:15,refetchonexpire:16,strings:21,test:17,workers:18,configure:22,reset:23,verify:24},dt,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),x()}get challengeurl(){return this.$$.ctx[19]}set challengeurl(e){this.$$set({challengeurl:e}),x()}get challengejson(){return this.$$.ctx[20]}set challengejson(e){this.$$set({challengejson:e}),x()}get debug(){return this.$$.ctx[12]}set debug(e){this.$$set({debug:e}),x()}get expire(){return this.$$.ctx[13]}set expire(e){this.$$set({expire:e}),x()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),x()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),x()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),x()}get maxnumber(){return this.$$.ctx[14]}set maxnumber(e){this.$$set({maxnumber:e}),x()}get mockerror(){return this.$$.ctx[15]}set mockerror(e){this.$$set({mockerror:e}),x()}get refetchonexpire(){return this.$$.ctx[16]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),x()}get strings(){return this.$$.ctx[21]}set strings(e){this.$$set({strings:e}),x()}get test(){return this.$$.ctx[17]}set test(e){this.$$set({test:e}),x()}get workers(){return this.$$.ctx[18]}set workers(e){this.$$set({workers:e}),x()}get configure(){return this.$$.ctx[22]}get reset(){return this.$$.ctx[23]}get verify(){return this.$$.ctx[24]}}return customElements.define("altcha-widget",it(Re,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},strings:{},test:{type:"Boolean"},workers:{}},[],["configure","reset","verify"],!1)),j.Altcha=Re,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),j}({});
1
+ var altcha=function(V){"use strict";var Wt=Object.defineProperty;var Bt=(V,S,W)=>S in V?Wt(V,S,{enumerable:!0,configurable:!0,writable:!0,value:W}):V[S]=W;var Z=(V,S,W)=>(Bt(V,typeof S!="symbol"?S+"":S,W),W);function S(){}function W(n){return n()}function pe(){return Object.create(null)}function q(n){n.forEach(W)}function ye(n){return typeof n=="function"}function Xe(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Ke(n){return Object.keys(n).length===0}function w(n,e){n.appendChild(e)}function Je(n,e,t){const i=ze(n);if(!i.getElementById(e)){const l=$("style");l.id=e,l.textContent=t,Qe(i,l)}}function ze(n){if(!n)return document;const e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Qe(n,e){return w(n.head||n,e),e.sheet}function T(n,e,t){n.insertBefore(e,t||null)}function N(n){n.parentNode&&n.parentNode.removeChild(n)}function $(n){return document.createElement(n)}function O(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function qe(n){return document.createTextNode(n)}function U(){return qe(" ")}function ce(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function c(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function et(n){return Array.from(n.childNodes)}function ve(n,e,t){n.classList.toggle(e,!!t)}function tt(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function nt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ee;function te(n){ee=n}function ae(){if(!ee)throw new Error("Function called outside component initialization");return ee}function rt(n){ae().$$.on_mount.push(n)}function it(n){ae().$$.on_destroy.push(n)}function lt(){const n=ae();return(e,t,{cancelable:i=!1}={})=>{const l=n.$$.callbacks[e];if(l){const o=tt(e,t,{cancelable:i});return l.slice().forEach(s=>{s.call(n,o)}),!o.defaultPrevented}return!0}}const J=[],fe=[];let z=[];const we=[],_e=Promise.resolve();let ue=!1;function ke(){ue||(ue=!0,_e.then(_))}function ot(){return ke(),_e}function he(n){z.push(n)}const de=new Set;let Q=0;function _(){if(Q!==0)return;const n=ee;do{try{for(;Q<J.length;){const e=J[Q];Q++,te(e),st(e.$$)}}catch(e){throw J.length=0,Q=0,e}for(te(null),J.length=0,Q=0;fe.length;)fe.pop()();for(let e=0;e<z.length;e+=1){const t=z[e];de.has(t)||(de.add(t),t())}z.length=0}while(J.length);for(;we.length;)we.pop()();ue=!1,de.clear(),te(n)}function st(n){if(n.fragment!==null){n.update(),q(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(he)}}function ct(n){const e=[],t=[];z.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),z=e}const at=new Set;function ft(n,e){n&&n.i&&(at.delete(n),n.i(e))}function ut(n,e,t){const{fragment:i,after_update:l}=n.$$;i&&i.m(e,t),he(()=>{const o=n.$$.on_mount.map(W).filter(ye);n.$$.on_destroy?n.$$.on_destroy.push(...o):q(o),n.$$.on_mount=[]}),l.forEach(he)}function ht(n,e){const t=n.$$;t.fragment!==null&&(ct(t.after_update),q(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function dt(n,e){n.$$.dirty[0]===-1&&(J.push(n),ke(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function gt(n,e,t,i,l,o,s=null,a=[-1]){const u=ee;te(n);const f=n.$$={fragment:null,ctx:[],props:o,update:S,not_equal:l,bound:pe(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(u?u.$$.context:[])),callbacks:pe(),dirty:a,skip_bound:!1,root:e.target||u.$$.root};s&&s(f.root);let R=!1;if(f.ctx=t?t(n,e.props||{},(m,M,...G)=>{const H=G.length?G[0]:M;return f.ctx&&l(f.ctx[m],f.ctx[m]=H)&&(!f.skip_bound&&f.bound[m]&&f.bound[m](H),R&&dt(n,m)),M}):[],f.update(),R=!0,q(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const m=et(e.target);f.fragment&&f.fragment.l(m),m.forEach(N)}else f.fragment&&f.fragment.c();e.intro&&ft(n.$$.fragment),ut(n,e.target,e.anchor),_()}te(u)}let xe;typeof HTMLElement=="function"&&(xe=class extends HTMLElement{constructor(e,t,i){super();Z(this,"$$ctor");Z(this,"$$s");Z(this,"$$c");Z(this,"$$cn",!1);Z(this,"$$d",{});Z(this,"$$r",!1);Z(this,"$$p_d",{});Z(this,"$$l",{});Z(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 l=this.$$c.$on(e,t);this.$$l_u.set(t,l)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const l=this.$$l_u.get(t);l&&(l(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(o){return()=>{let s;return{c:function(){s=$("slot"),o!=="default"&&c(s,"name",o)},m:function(f,R){T(f,s,R)},d:function(f){f&&N(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=nt(this);for(const o of this.$$s)o in i&&(t[o]=[e(o)]);for(const o of this.attributes){const s=this.$$g_p(o.name);s in this.$$d||(this.$$d[s]=ne(s,o.value,this.$$p_d,"toProp"))}for(const o in this.$$p_d)!(o in this.$$d)&&this[o]!==void 0&&(this.$$d[o]=this[o],delete this[o]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const l=()=>{this.$$r=!0;for(const o in this.$$p_d)if(this.$$d[o]=this.$$c.$$.ctx[this.$$c.$$.props[o]],this.$$p_d[o].reflect){const s=ne(o,this.$$d[o],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[o].attribute||o):this.setAttribute(this.$$p_d[o].attribute||o,s)}this.$$r=!1};this.$$c.$$.after_update.push(l),l();for(const o in this.$$l)for(const s of this.$$l[o]){const a=this.$$c.$on(o,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,t,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=ne(e,i,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(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,i){var o;const l=(o=t[n])==null?void 0:o.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(l){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(l){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function mt(n,e,t,i,l,o){let s=class extends xe{constructor(){super(n,t,l),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(u){var f;u=ne(a,u,e),this.$$d[a]=u,(f=this.$$c)==null||f.$set({[a]:u})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var u;return(u=this.$$c)==null?void 0:u[a]}})}),o&&(s=o(s)),n.element=s,s}class bt{constructor(){Z(this,"$$");Z(this,"$$set")}$destroy(){ht(this,1),this.$destroy=S}$on(e,t){if(!ye(t))return S;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const l=i.indexOf(t);l!==-1&&i.splice(l,1)}}$set(e){this.$$set&&!Ke(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const pt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(pt);const Ee="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGcodCl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KHQpXS5tYXAoZT0+ZS50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBoKHQsZSxvKXtyZXR1cm4gZyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUodCtlKSkpfWZ1bmN0aW9uIG0odCxlLG89IlNIQS0yNTYiLGk9MWU2LHA9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyO3JldHVybntwcm9taXNlOm5ldyBQcm9taXNlKChzLGMpPT57Y29uc3Qgcj1EYXRlLm5vdygpLGQ9bD0+e2Euc2lnbmFsLmFib3J0ZWR8fGw+aT9zKG51bGwpOmgoZSxsLG8pLnRoZW4odz0+e3c9PT10P3Moe251bWJlcjpsLHRvb2s6RGF0ZS5ub3coKS1yfSk6ZChsKzEpfSkuY2F0Y2goYyl9O2QocCl9KSxjb250cm9sbGVyOmF9fWxldCBuO29ubWVzc2FnZT1hc3luYyB0PT57Y29uc3R7dHlwZTplLHBheWxvYWQ6b309dC5kYXRhO2lmKGU9PT0iYWJvcnQiKW49PW51bGx8fG4uYWJvcnQoKSxuPXZvaWQgMDtlbHNlIGlmKGU9PT0id29yayIpe2NvbnN0e2FsZzppLGNoYWxsZW5nZTpwLG1heDphLHNhbHQ6dSxzdGFydDpzfT1vfHx7fSxjPW0ocCx1LGksYSxzKTtuPWMuY29udHJvbGxlcixjLnByb21pc2UudGhlbihyPT57c2VsZi5wb3N0TWVzc2FnZShyJiZ7Li4ucix3b3JrZXI6ITB9KX0pfX19KSgpOwo=",yt=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),$e=typeof window<"u"&&window.Blob&&new Blob([yt(Ee)],{type:"text/javascript;charset=utf-8"});function vt(n){let e;try{if(e=$e&&(window.URL||window.webkitURL).createObjectURL($e),!e)throw"";const t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Ee,{name:n==null?void 0:n.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const wt=new TextEncoder;function _t(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function kt(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const l=await Ce(i,n,e);return{algorithm:e,challenge:l,salt:i,signature:""}}async function Ce(n,e,t){return _t(await crypto.subtle.digest(t.toUpperCase(),wt.encode(n+e)))}function xt(n,e,t="SHA-256",i=1e6,l=0){const o=new AbortController;return{promise:new Promise((a,u)=>{const f=Date.now(),R=m=>{o.signal.aborted||m>i?a(null):Ce(e,m,t).then(M=>{M===n?a({number:m,took:Date.now()-f}):R(m+1)}).catch(u)};R(l)}),controller:o}}var y=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(y||{});function Et(n){Je(n,"svelte-14ngypa",`.altcha.svelte-14ngypa.svelte-14ngypa{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid
2
+ 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);overflow:hidden;position:relative;text-align:left}.altcha.svelte-14ngypa.svelte-14ngypa:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-14ngypa.svelte-14ngypa{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-14ngypa.svelte-14ngypa{flex-grow:1}.altcha-label.svelte-14ngypa label.svelte-14ngypa{cursor:pointer}.altcha-logo.svelte-14ngypa.svelte-14ngypa{color:currentColor;opacity:0.3}.altcha-logo.svelte-14ngypa.svelte-14ngypa:hover{opacity:1}.altcha-error.svelte-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa:hover{opacity:1}.altcha-footer.svelte-14ngypa>.svelte-14ngypa:first-child{flex-grow:1}.altcha-footer.svelte-14ngypa a{color:currentColor}.altcha-checkbox.svelte-14ngypa.svelte-14ngypa{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-14ngypa input.svelte-14ngypa{width:18px;height:18px;margin:0}.altcha-hidden.svelte-14ngypa.svelte-14ngypa{display:none}.altcha-spinner.svelte-14ngypa.svelte-14ngypa{animation:svelte-14ngypa-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-14ngypa-altcha-spinner{100%{transform:rotate(360deg)}}`)}function Le(n){let e,t,i;return{c(){e=O("svg"),t=O("path"),i=O("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-14ngypa"),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(l,o){T(l,e,o),w(e,t),w(e,i)},d(l){l&&N(e)}}}function $t(n){let e,t=n[9].label+"",i;return{c(){e=$("label"),c(e,"for",i=n[3]+"_checkbox"),c(e,"class","svelte-14ngypa")},m(l,o){T(l,e,o),e.innerHTML=t},p(l,o){o[0]&512&&t!==(t=l[9].label+"")&&(e.innerHTML=t),o[0]&8&&i!==(i=l[3]+"_checkbox")&&c(e,"for",i)},d(l){l&&N(e)}}}function Ct(n){let e,t=n[9].verifying+"";return{c(){e=$("span")},m(i,l){T(i,e,l),e.innerHTML=t},p(i,l){l[0]&512&&t!==(t=i[9].verifying+"")&&(e.innerHTML=t)},d(i){i&&N(e)}}}function Lt(n){let e,t=n[9].verified+"",i,l;return{c(){e=$("span"),i=U(),l=$("input"),c(l,"type","hidden"),c(l,"name",n[3]),l.value=n[4]},m(o,s){T(o,e,s),e.innerHTML=t,T(o,i,s),T(o,l,s)},p(o,s){s[0]&512&&t!==(t=o[9].verified+"")&&(e.innerHTML=t),s[0]&8&&c(l,"name",o[3]),s[0]&16&&(l.value=o[4])},d(o){o&&(N(e),N(i),N(l))}}}function Ie(n){let e,t,i,l,o,s;return{c(){e=$("div"),t=$("a"),i=O("svg"),l=O("path"),o=O("path"),s=O("path"),c(l,"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(l,"fill","currentColor"),c(o,"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(o,"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",Ne),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-14ngypa")},m(a,u){T(a,e,u),w(e,t),w(t,i),w(i,l),w(i,o),w(i,s)},p:S,d(a){a&&N(e)}}}function Re(n){let e,t,i,l;function o(u,f){return u[5]===y.EXPIRED?Rt:It}let s=o(n),a=s(n);return{c(){e=$("div"),t=O("svg"),i=O("path"),l=U(),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-14ngypa")},m(u,f){T(u,e,f),w(e,t),w(t,i),w(e,l),a.m(e,null)},p(u,f){s===(s=o(u))&&a?a.p(u,f):(a.d(1),a=s(u),a&&(a.c(),a.m(e,null)))},d(u){u&&N(e),a.d()}}}function It(n){let e,t=n[9].error+"";return{c(){e=$("div"),c(e,"title",n[8])},m(i,l){T(i,e,l),e.innerHTML=t},p(i,l){l[0]&512&&t!==(t=i[9].error+"")&&(e.innerHTML=t),l[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function Rt(n){let e,t=n[9].expired+"";return{c(){e=$("div"),c(e,"title",n[8])},m(i,l){T(i,e,l),e.innerHTML=t},p(i,l){l[0]&512&&t!==(t=i[9].expired+"")&&(e.innerHTML=t),l[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function Se(n){let e,t,i=n[9].footer+"";return{c(){e=$("div"),t=$("div"),c(t,"class","svelte-14ngypa"),c(e,"class","altcha-footer svelte-14ngypa")},m(l,o){T(l,e,o),w(e,t),t.innerHTML=i},p(l,o){o[0]&512&&i!==(i=l[9].footer+"")&&(t.innerHTML=i)},d(l){l&&N(e)}}}function St(n){let e,t,i,l,o,s,a,u,f,R,m,M,G,H,k=n[5]===y.VERIFYING&&Le();function Y(d,I){return d[5]===y.VERIFIED?Lt:d[5]===y.VERIFYING?Ct:$t}let P=Y(n),x=P(n),E=n[2]!==!0&&Ie(),g=(n[8]||n[5]===y.EXPIRED)&&Re(n),v=n[9].footer&&n[1]!==!0&&Se(n);return{c(){e=$("div"),t=$("div"),k&&k.c(),i=U(),l=$("div"),o=$("input"),u=U(),f=$("div"),x.c(),R=U(),E&&E.c(),m=U(),g&&g.c(),M=U(),v&&v.c(),c(o,"type","checkbox"),c(o,"id",s=n[3]+"_checkbox"),o.required=a=n[0]!=="onsubmit",c(o,"class","svelte-14ngypa"),c(l,"class","altcha-checkbox svelte-14ngypa"),ve(l,"altcha-hidden",n[5]===y.VERIFYING),c(f,"class","altcha-label svelte-14ngypa"),c(t,"class","altcha-main svelte-14ngypa"),c(e,"class","altcha svelte-14ngypa"),c(e,"data-state",n[5])},m(d,I){T(d,e,I),w(e,t),k&&k.m(t,null),w(t,i),w(t,l),w(l,o),o.checked=n[6],w(t,u),w(t,f),x.m(f,null),w(t,R),E&&E.m(t,null),w(e,m),g&&g.m(e,null),w(e,M),v&&v.m(e,null),n[30](e),G||(H=[ce(o,"change",n[29]),ce(o,"change",n[10]),ce(o,"invalid",n[11])],G=!0)},p(d,I){d[5]===y.VERIFYING?k||(k=Le(),k.c(),k.m(t,i)):k&&(k.d(1),k=null),I[0]&8&&s!==(s=d[3]+"_checkbox")&&c(o,"id",s),I[0]&1&&a!==(a=d[0]!=="onsubmit")&&(o.required=a),I[0]&64&&(o.checked=d[6]),I[0]&32&&ve(l,"altcha-hidden",d[5]===y.VERIFYING),P===(P=Y(d))&&x?x.p(d,I):(x.d(1),x=P(d),x&&(x.c(),x.m(f,null))),d[2]!==!0?E?E.p(d,I):(E=Ie(),E.c(),E.m(t,null)):E&&(E.d(1),E=null),d[8]||d[5]===y.EXPIRED?g?g.p(d,I):(g=Re(d),g.c(),g.m(e,M)):g&&(g.d(1),g=null),d[9].footer&&d[1]!==!0?v?v.p(d,I):(v=Se(d),v.c(),v.m(e,null)):v&&(v.d(1),v=null),I[0]&32&&c(e,"data-state",d[5])},i:S,o:S,d(d){d&&N(e),k&&k.d(),x.d(),E&&E.d(),g&&g.d(),v&&v.d(),n[30](null),G=!1,q(H)}}}const Ne="https://altcha.org/";function Te(n){return JSON.parse(n)}function Nt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Tt(n,e,t){var Fe,We;let i,l,o,{auto:s=void 0}=e,{blockspam:a=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:f=void 0}=e,{debug:R=!1}=e,{expire:m=void 0}=e,{hidefooter:M=!1}=e,{hidelogo:G=!1}=e,{name:H="altcha"}=e,{maxnumber:k=1e6}=e,{mockerror:Y=!1}=e,{refetchonexpire:P=!0}=e,{spamfilter:x=!1}=e,{strings:E=void 0}=e,{test:g=!1}=e,{verifyurl:v=void 0}=e,{workers:d=navigator.hardwareConcurrency||8}=e;const I=lt(),je=["SHA-256","SHA-384","SHA-512"],Me=(We=(Fe=document.documentElement.lang)==null?void 0:Fe.split("-"))==null?void 0:We[0];let B=!1,re,b=null,ge=null,X=null,D=y.UNVERIFIED,me;it(()=>{b&&(b.removeEventListener("submit",Ge),b.removeEventListener("reset",Ve),b.removeEventListener("focusin",Ze),b=null)}),rt(()=>{C("mounted","0.3.1"),C("workers",d),g&&C("using test mode"),m&&be(m),s!==void 0&&C("auto",s),b=re.closest("form"),b&&(b.addEventListener("submit",Ge),b.addEventListener("reset",Ve),s==="onfocus"&&b.addEventListener("focusin",Ze)),s==="onload"&&K()});function C(...r){(R||r.some(h=>h instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",...r)}function Ze(r){K()}function Ge(r){b&&s==="onsubmit"&&D===y.UNVERIFIED&&(r.preventDefault(),r.stopPropagation(),K().then(()=>{b==null||b.requestSubmit()}))}function Ve(){ie()}function Oe(r,h){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:h.number,salt:r.salt,signature:r.signature,test:g?!0:void 0,took:h.took}))}function He(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(!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 At(){if(Y)throw C("mocking error"),new Error("Mocked error.");if(i)return C("using provided json data"),i;if(g)return C("generating test challenge",{test:g}),kt(typeof g!="boolean"?+g:void 0);{if(!u)throw new Error("Attribute challengeurl not set.");C("fetching challenge from",u);const r=await fetch(u,{headers:{"x-altcha-spam-filter":x?"1":"0"}});if(r.status!==200)throw new Error(`Server responded with ${r.status}.`);const h=r.headers.get("Expires"),L=r.headers.get("X-Altcha-Config");if(L)try{const p=JSON.parse(L);p&&typeof p=="object"&&(p.verifyurl&&(p.verifyurl=new URL(p.verifyurl,new URL(u)).toString()),De(p))}catch(p){C("unable to configure from X-Altcha-Config",p)}if(!m&&(h!=null&&h.length)){const p=Date.parse(h);if(p){const A=p-Date.now();A>0&&be(A)}}return r.json()}}function Pe(){u&&P&&D===y.VERIFIED?K():ie(y.EXPIRED,o.expired)}async function jt(r){let h=null;if("Worker"in window){try{h=await Mt(r.challenge,r.salt,r.algorithm,r.maxnumber)}catch(L){C(L)}if((h==null?void 0:h.number)!==void 0)return{data:r,solution:h}}return{data:r,solution:await xt(r.challenge,r.salt,r.algorithm,r.maxnumber||k).promise}}async function Mt(r,h,L,p=k,A=Math.ceil(d)){const F=[];if(A<1)throw new Error("Wrong number of workers configured.");if(A>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let j=0;j<A;j++)F.push(new vt);const le=Math.ceil(p/A),oe=await Promise.all(F.map((j,se)=>{const Be=se*le;return new Promise(Ft=>{j.addEventListener("message",Ue=>{if(Ue.data)for(const Ye of F)Ye!==j&&Ye.postMessage({type:"abort"});Ft(Ue.data)}),j.postMessage({payload:{alg:L,challenge:r,max:Be+le,salt:h,start:Be},type:"work"})})}));for(const j of F)j.terminate();return oe.find(j=>!!j)||null}function Zt(){[y.UNVERIFIED,y.ERROR,y.EXPIRED].includes(D)?x&&(b==null?void 0:b.reportValidity())===!1?t(6,B=!1):K():t(6,B=!0)}function Gt(){D===y.VERIFYING&&alert(o.waitAlert)}function be(r){C("expire",r),clearTimeout(me),r<1?Pe():me=setTimeout(Pe,r)}function Vt(r){var L;const h=b==null?void 0:b.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((L=h==null?void 0:h.value)==null?void 0:L.slice(h.value.indexOf("@")))||void 0}function Ot(r){return[...(b==null?void 0:b.querySelectorAll(r!=null&&r.length?r.map(L=>`input[name="${L}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((L,p)=>{const A=p.name,F=p.value.trim();return A&&F&&(L[A]=F),L},{})}async function Ht(r){if(!v)throw new Error("Attribute verifyurl not set.");C("requesting server verification from",v);const h={payload:r};if(x){const{email:A,expectedLanguages:F,expectedCountries:le,fields:oe,ipAddress:j,timeZone:se}=typeof x=="object"?x:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};h.ipAddress=j===!1?void 0:j||"auto",h.email=A===!1?void 0:Vt(A),h.fields=oe===!1?void 0:Ot(oe),h.timeZone=se===!1?void 0:se||Nt(),h.expectedCountries=le,h.expectedLanguages=F||(Me?[Me]:void 0)}const L=await fetch(v,{body:JSON.stringify(h),headers:{"content-type":"application/json"},method:"POST"});if(L.status!==200)throw new Error(`Server responded with ${L.status}.`);const p=await L.json();if(p!=null&&p.payload&&t(4,X=p.payload),I("serververification",p),a&&p.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function De(r){r.auto!==void 0&&(t(0,s=r.auto),s==="onload"&&K()),r.expire!==void 0&&(be(r.expire),t(13,m=r.expire)),r.challenge&&(He(r.challenge),i=r.challenge),r.debug!==void 0&&t(12,R=!!r.debug),r.hidefooter!==void 0&&t(1,M=!!r.hidefooter),r.hidelogo!==void 0&&t(2,G=!!r.hidelogo),r.maxnumber!==void 0&&t(14,k=+r.maxnumber),r.mockerror!==void 0&&t(15,Y=!!r.mockerror),r.name!==void 0&&t(3,H=r.name),r.refetchonexpire!==void 0&&t(16,P=!!r.refetchonexpire),r.spamfilter!==void 0&&t(17,x=r.spamfilter),r.strings&&t(28,l=r.strings),r.test!==void 0&&t(18,g=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(19,v=r.verifyurl),r.workers!==void 0&&t(20,d=+r.workers)}function ie(r=y.UNVERIFIED,h=null){clearTimeout(me),t(6,B=!1),t(8,ge=h),t(4,X=null),t(5,D=r)}async function K(){return ie(y.VERIFYING),At().then(r=>(He(r),C("challenge",r),jt(r))).then(({data:r,solution:h})=>{if(C("solution",h),(h==null?void 0:h.number)!==void 0){if(v)return Ht(Oe(r,h));t(4,X=Oe(r,h)),C("payload",X)}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(()=>{ot().then(()=>{t(5,D=y.VERIFIED),t(6,B=!0),C("verified"),I("verified",{payload:X})})}).catch(r=>{C(r),t(5,D=y.ERROR),t(6,B=!1),t(8,ge=r.message)})}function Pt(){B=this.checked,t(6,B)}function Dt(r){fe[r?"unshift":"push"](()=>{re=r,t(7,re)})}return n.$$set=r=>{"auto"in r&&t(0,s=r.auto),"blockspam"in r&&t(21,a=r.blockspam),"challengeurl"in r&&t(22,u=r.challengeurl),"challengejson"in r&&t(23,f=r.challengejson),"debug"in r&&t(12,R=r.debug),"expire"in r&&t(13,m=r.expire),"hidefooter"in r&&t(1,M=r.hidefooter),"hidelogo"in r&&t(2,G=r.hidelogo),"name"in r&&t(3,H=r.name),"maxnumber"in r&&t(14,k=r.maxnumber),"mockerror"in r&&t(15,Y=r.mockerror),"refetchonexpire"in r&&t(16,P=r.refetchonexpire),"spamfilter"in r&&t(17,x=r.spamfilter),"strings"in r&&t(24,E=r.strings),"test"in r&&t(18,g=r.test),"verifyurl"in r&&t(19,v=r.verifyurl),"workers"in r&&t(20,d=r.workers)},n.$$.update=()=>{n.$$.dirty[0]&8388608&&(i=f?Te(f):void 0),n.$$.dirty[0]&16777216&&t(28,l=E?Te(E):{}),n.$$.dirty[0]&268435456&&t(9,o={error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by <a href="${Ne}" target="_blank">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),n.$$.dirty[0]&48&&I("statechange",{payload:X,state:D})},[s,M,G,H,X,D,B,re,ge,o,Zt,Gt,R,m,k,Y,P,x,g,v,d,a,u,f,E,De,ie,K,l,Pt,Dt]}class Ae extends bt{constructor(e){super(),gt(this,e,Tt,St,Xe,{auto:0,blockspam:21,challengeurl:22,challengejson:23,debug:12,expire:13,hidefooter:1,hidelogo:2,name:3,maxnumber:14,mockerror:15,refetchonexpire:16,spamfilter:17,strings:24,test:18,verifyurl:19,workers:20,configure:25,reset:26,verify:27},Et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),_()}get blockspam(){return this.$$.ctx[21]}set blockspam(e){this.$$set({blockspam:e}),_()}get challengeurl(){return this.$$.ctx[22]}set challengeurl(e){this.$$set({challengeurl:e}),_()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),_()}get debug(){return this.$$.ctx[12]}set debug(e){this.$$set({debug:e}),_()}get expire(){return this.$$.ctx[13]}set expire(e){this.$$set({expire:e}),_()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),_()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),_()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),_()}get maxnumber(){return this.$$.ctx[14]}set maxnumber(e){this.$$set({maxnumber:e}),_()}get mockerror(){return this.$$.ctx[15]}set mockerror(e){this.$$set({mockerror:e}),_()}get refetchonexpire(){return this.$$.ctx[16]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),_()}get spamfilter(){return this.$$.ctx[17]}set spamfilter(e){this.$$set({spamfilter:e}),_()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),_()}get test(){return this.$$.ctx[18]}set test(e){this.$$set({test:e}),_()}get verifyurl(){return this.$$.ctx[19]}set verifyurl(e){this.$$set({verifyurl:e}),_()}get workers(){return this.$$.ctx[20]}set workers(e){this.$$set({workers:e}),_()}get configure(){return this.$$.ctx[25]}get reset(){return this.$$.ctx[26]}get verify(){return this.$$.ctx[27]}}return customElements.define("altcha-widget",mt(Ae,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{}},[],["configure","reset","verify"],!1)),V.Altcha=Ae,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),V}({});