altcha 0.4.1 → 0.4.3

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.
@@ -1 +1 @@
1
- var altcha=function(D){"use strict";var Ft=Object.defineProperty;var Ht=(D,z,H)=>z in D?Ft(D,z,{enumerable:!0,configurable:!0,writable:!0,value:H}):D[z]=H;var M=(D,z,H)=>(Ht(D,typeof z!="symbol"?z+"":z,H),H);function z(){}function H(r){return r()}function ye(){return Object.create(null)}function te(r){r.forEach(H)}function ve(r){return typeof r=="function"}function We(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function Be(r){return Object.keys(r).length===0}function v(r,e){r.appendChild(e)}function Ke(r,e,t){const i=Je(r);if(!i.getElementById(e)){const o=C("style");o.id=e,o.textContent=t,Qe(i,o)}}function Je(r){if(!r)return document;const e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function Qe(r,e){return v(r.head||r,e),e.sheet}function j(r,e,t){r.insertBefore(e,t||null)}function N(r){r.parentNode&&r.parentNode.removeChild(r)}function C(r){return document.createElement(r)}function O(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function qe(r){return document.createTextNode(r)}function Y(){return qe(" ")}function ae(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function c(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function et(r){return Array.from(r.childNodes)}function we(r,e,t){r.classList.toggle(e,!!t)}function tt(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function rt(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let re;function ne(r){re=r}function fe(){if(!re)throw new Error("Function called outside component initialization");return re}function nt(r){fe().$$.on_mount.push(r)}function it(r){fe().$$.on_destroy.push(r)}function ot(){const r=fe();return(e,t,{cancelable:i=!1}={})=>{const o=r.$$.callbacks[e];if(o){const l=tt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(r,l)}),!l.defaultPrevented}return!0}}const Q=[],ue=[];let q=[];const pe=[],_e=Promise.resolve();let he=!1;function ke(){he||(he=!0,_e.then(p))}function lt(){return ke(),_e}function de(r){q.push(r)}const me=new Set;let ee=0;function p(){if(ee!==0)return;const r=re;do{try{for(;ee<Q.length;){const e=Q[ee];ee++,ne(e),st(e.$$)}}catch(e){throw Q.length=0,ee=0,e}for(ne(null),Q.length=0,ee=0;ue.length;)ue.pop()();for(let e=0;e<q.length;e+=1){const t=q[e];me.has(t)||(me.add(t),t())}q.length=0}while(Q.length);for(;pe.length;)pe.pop()();he=!1,me.clear(),ne(r)}function st(r){if(r.fragment!==null){r.update(),te(r.before_update);const e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(de)}}function ct(r){const e=[],t=[];q.forEach(i=>r.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),q=e}const at=new Set;function ft(r,e){r&&r.i&&(at.delete(r),r.i(e))}function ut(r,e,t){const{fragment:i,after_update:o}=r.$$;i&&i.m(e,t),de(()=>{const l=r.$$.on_mount.map(H).filter(ve);r.$$.on_destroy?r.$$.on_destroy.push(...l):te(l),r.$$.on_mount=[]}),o.forEach(de)}function ht(r,e){const t=r.$$;t.fragment!==null&&(ct(t.after_update),te(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function dt(r,e){r.$$.dirty[0]===-1&&(Q.push(r),ke(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function mt(r,e,t,i,o,l,s=null,f=[-1]){const a=re;ne(r);const h=r.$$={fragment:null,ctx:[],props:l,update:z,not_equal:o,bound:ye(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:ye(),dirty:f,skip_bound:!1,root:e.target||a.$$.root};s&&s(h.root);let A=!1;if(h.ctx=t?t(r,e.props||{},(L,V,...U)=>{const X=U.length?U[0]:V;return h.ctx&&o(h.ctx[L],h.ctx[L]=X)&&(!h.skip_bound&&h.bound[L]&&h.bound[L](X),A&&dt(r,L)),V}):[],h.update(),A=!0,te(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const L=et(e.target);h.fragment&&h.fragment.l(L),L.forEach(N)}else h.fragment&&h.fragment.c();e.intro&&ft(r.$$.fragment),ut(r,e.target,e.anchor),p()}ne(a)}let xe;typeof HTMLElement=="function"&&(xe=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(l){return()=>{let s;return{c:function(){s=C("slot"),l!=="default"&&c(s,"name",l)},m:function(h,A){j(h,s,A)},d:function(h){h&&N(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=rt(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]=ie(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=ie(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 f=this.$$c.$on(l,s);this.$$l_u.set(s,f)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=ie(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(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function ie(r,e,t,i){var l;const o=(l=t[r])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function gt(r,e,t,i,o,l){let s=class extends xe{constructor(){super(r,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(f=>(e[f].attribute||f).toLowerCase())}};return Object.keys(e).forEach(f=>{Object.defineProperty(s.prototype,f,{get(){return this.$$c&&f in this.$$c?this.$$c[f]:this.$$d[f]},set(a){var h;a=ie(f,a,e),this.$$d[f]=a,(h=this.$$c)==null||h.$set({[f]:a})}})}),i.forEach(f=>{Object.defineProperty(s.prototype,f,{get(){var a;return(a=this.$$c)==null?void 0:a[f]}})}),l&&(s=l(s)),r.element=s,s}class bt{constructor(){M(this,"$$");M(this,"$$set")}$destroy(){ht(this,1),this.$destroy=z}$on(e,t){if(!ve(t))return z;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&&!Be(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const yt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(yt);const Ee="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",vt=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),$e=typeof window<"u"&&window.Blob&&new Blob([vt(Ee)],{type:"text/javascript;charset=utf-8"});function wt(r){let e;try{if(e=$e&&(window.URL||window.webkitURL).createObjectURL($e),!e)throw"";const t=new Worker(e,{name:r==null?void 0:r.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Ee,{name:r==null?void 0:r.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const pt=new TextEncoder;function _t(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function kt(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const o=await Ce(i,r,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Ce(r,e,t){return _t(await crypto.subtle.digest(t.toUpperCase(),pt.encode(r+e)))}function xt(r,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let a=o;a<=i;a+=1){if(l.signal.aborted)return null;if(await Ce(e,a,t)===r)return{number:a,took:Date.now()-s}}return null})(),controller:l}}var g=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(g||{});function Et(r){Ke(r,"svelte-15co9zy",".altcha.svelte-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}")}function Le(r){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-15co9zy"),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){j(o,e,l),v(e,t),v(e,i)},d(o){o&&N(e)}}}function $t(r){let e,t=r[9].label+"",i;return{c(){e=C("label"),c(e,"for",i=r[3]+"_checkbox"),c(e,"class","svelte-15co9zy")},m(o,l){j(o,e,l),e.innerHTML=t},p(o,l){l[0]&512&&t!==(t=o[9].label+"")&&(e.innerHTML=t),l[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&N(e)}}}function Ct(r){let e,t=r[9].verifying+"";return{c(){e=C("span")},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].verifying+"")&&(e.innerHTML=t)},d(i){i&&N(e)}}}function Lt(r){let e,t=r[9].verified+"",i,o;return{c(){e=C("span"),i=Y(),o=C("input"),c(o,"type","hidden"),c(o,"name",r[3]),o.value=r[4]},m(l,s){j(l,e,s),e.innerHTML=t,j(l,i,s),j(l,o,s)},p(l,s){s[0]&512&&t!==(t=l[9].verified+"")&&(e.innerHTML=t),s[0]&8&&c(o,"name",l[3]),s[0]&16&&(o.value=l[4])},d(l){l&&(N(e),N(i),N(o))}}}function Re(r){let e,t,i,o,l,s;return{c(){e=C("div"),t=C("a"),i=O("svg"),o=O("path"),l=O("path"),s=O("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",Ne),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-15co9zy")},m(f,a){j(f,e,a),v(e,t),v(t,i),v(i,o),v(i,l),v(i,s)},p:z,d(f){f&&N(e)}}}function Ie(r){let e,t,i,o;function l(a,h){return a[5]===g.EXPIRED?It:Rt}let s=l(r),f=s(r);return{c(){e=C("div"),t=O("svg"),i=O("path"),o=Y(),f.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-15co9zy")},m(a,h){j(a,e,h),v(e,t),v(t,i),v(e,o),f.m(e,null)},p(a,h){s===(s=l(a))&&f?f.p(a,h):(f.d(1),f=s(a),f&&(f.c(),f.m(e,null)))},d(a){a&&N(e),f.d()}}}function Rt(r){let e,t=r[9].error+"";return{c(){e=C("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].error+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function It(r){let e,t=r[9].expired+"";return{c(){e=C("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].expired+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function ze(r){let e,t,i=r[9].footer+"";return{c(){e=C("div"),t=C("div"),c(t,"class","svelte-15co9zy"),c(e,"class","altcha-footer svelte-15co9zy")},m(o,l){j(o,e,l),v(e,t),t.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(t.innerHTML=i)},d(o){o&&N(e)}}}function zt(r){let e,t,i,o,l,s,f,a,h,A,L,V,U,X,_=r[5]===g.VERIFYING&&Le();function W(d,I){return d[5]===g.VERIFIED?Lt:d[5]===g.VERIFYING?Ct:$t}let F=W(r),k=F(r),x=r[2]!==!0&&Re(),m=(r[8]||r[5]===g.EXPIRED)&&Ie(r),y=r[9].footer&&r[1]!==!0&&ze(r);return{c(){e=C("div"),t=C("div"),_&&_.c(),i=Y(),o=C("div"),l=C("input"),a=Y(),h=C("div"),k.c(),A=Y(),x&&x.c(),L=Y(),m&&m.c(),V=Y(),y&&y.c(),c(l,"type","checkbox"),c(l,"id",s=r[3]+"_checkbox"),l.required=f=r[0]!=="onsubmit",c(l,"class","svelte-15co9zy"),c(o,"class","altcha-checkbox svelte-15co9zy"),we(o,"altcha-hidden",r[5]===g.VERIFYING),c(h,"class","altcha-label svelte-15co9zy"),c(t,"class","altcha-main svelte-15co9zy"),c(e,"class","altcha svelte-15co9zy"),c(e,"data-state",r[5])},m(d,I){j(d,e,I),v(e,t),_&&_.m(t,null),v(t,i),v(t,o),v(o,l),l.checked=r[6],v(t,a),v(t,h),k.m(h,null),v(t,A),x&&x.m(t,null),v(e,L),m&&m.m(e,null),v(e,V),y&&y.m(e,null),r[30](e),U||(X=[ae(l,"change",r[29]),ae(l,"change",r[10]),ae(l,"invalid",r[11])],U=!0)},p(d,I){d[5]===g.VERIFYING?_||(_=Le(),_.c(),_.m(t,i)):_&&(_.d(1),_=null),I[0]&8&&s!==(s=d[3]+"_checkbox")&&c(l,"id",s),I[0]&1&&f!==(f=d[0]!=="onsubmit")&&(l.required=f),I[0]&64&&(l.checked=d[6]),I[0]&32&&we(o,"altcha-hidden",d[5]===g.VERIFYING),F===(F=W(d))&&k?k.p(d,I):(k.d(1),k=F(d),k&&(k.c(),k.m(h,null))),d[2]!==!0?x?x.p(d,I):(x=Re(),x.c(),x.m(t,null)):x&&(x.d(1),x=null),d[8]||d[5]===g.EXPIRED?m?m.p(d,I):(m=Ie(d),m.c(),m.m(e,V)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?y?y.p(d,I):(y=ze(d),y.c(),y.m(e,null)):y&&(y.d(1),y=null),I[0]&32&&c(e,"data-state",d[5])},i:z,o:z,d(d){d&&N(e),_&&_.d(),k.d(),x&&x.d(),m&&m.d(),y&&y.d(),r[30](null),U=!1,te(X)}}}const Ne="https://altcha.org/";function Se(r){return JSON.parse(r)}function Nt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function St(r,e,t){var Xe,Fe;let i,o,l,{auto:s=void 0}=e,{blockspam:f=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:h=void 0}=e,{debug:A=!1}=e,{expire:L=void 0}=e,{hidefooter:V=!1}=e,{hidelogo:U=!1}=e,{name:X="altcha"}=e,{maxnumber:_=1e6}=e,{mockerror:W=!1}=e,{refetchonexpire:F=!0}=e,{spamfilter:k=!1}=e,{strings:x=void 0}=e,{test:m=!1}=e,{verifyurl:y=void 0}=e,{workers:d=navigator.hardwareConcurrency||8}=e;const I=ot(),Ze=["SHA-256","SHA-384","SHA-512"],Ae=(Fe=(Xe=document.documentElement.lang)==null?void 0:Xe.split("-"))==null?void 0:Fe[0];let P=!1,oe,b=null,ge=null,B=null,G=g.UNVERIFIED,be;it(()=>{b&&(b.removeEventListener("submit",Me),b.removeEventListener("reset",Ve),b.removeEventListener("focusin",Te),b=null)}),nt(()=>{R("mounted","0.4.1"),R("workers",d),m&&R("using test mode"),L&&le(L),s!==void 0&&R("auto",s),b=oe.closest("form"),b&&(b.addEventListener("submit",Me),b.addEventListener("reset",Ve),s==="onfocus"&&b.addEventListener("focusin",Te)),s==="onload"&&K()});function R(...n){(A||n.some(u=>u instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Te(n){G===g.UNVERIFIED&&K()}function Me(n){b&&s==="onsubmit"&&G===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),K().then(()=>{b==null||b.requestSubmit()}))}function Ve(){se()}function Ue(n,u){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:u.number,salt:n.salt,signature:n.signature,test:m?!0:void 0,took:u.took}))}function Ge(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(!Ze.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ze.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 jt(){var n;if(W)throw R("mocking error"),new Error("Mocked error.");if(i)return R("using provided json data"),i;if(m)return R("generating test challenge",{test:m}),kt(typeof m!="boolean"?+m:void 0);{if(!a)throw new Error("Attribute challengeurl not set.");R("fetching challenge from",a);const u=await fetch(a,{headers:{"x-altcha-spam-filter":k?"1":"0"}});if(u.status!==200)throw new Error(`Server responded with ${u.status}.`);const w=u.headers.get("Expires"),S=u.headers.get("X-Altcha-Config"),Z=await u.json(),T=new URLSearchParams((n=Z.salt.split("?"))==null?void 0:n[1]),J=T.get("expires")||T.get("expire");if(J){const E=new Date(+J*1e3),$=isNaN(E.getTime())?0:E.getTime()-Date.now();$>0&&le($)}if(S)try{const E=JSON.parse(S);E&&typeof E=="object"&&(E.verifyurl&&(E.verifyurl=new URL(E.verifyurl,new URL(a)).toString()),Oe(E))}catch(E){R("unable to configure from X-Altcha-Config",E)}if(!L&&(w!=null&&w.length)){const E=Date.parse(w);if(E){const $=E-Date.now();$>0&&le($)}}return Z}}function De(){a&&F&&G===g.VERIFIED?K():se(g.EXPIRED,l.expired)}async function Zt(n){let u=null;if("Worker"in window){try{u=await At(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(w){R(w)}if((u==null?void 0:u.number)!==void 0)return{data:n,solution:u}}return{data:n,solution:await xt(n.challenge,n.salt,n.algorithm,n.maxnumber||_).promise}}async function At(n,u,w,S=typeof m=="number"?m:_,Z=Math.ceil(d)){const T=[];if(Z<1)throw new Error("Wrong number of workers configured.");if(Z>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let $=0;$<Z;$++)T.push(new wt);const J=Math.ceil(S/Z),E=await Promise.all(T.map(($,ce)=>{const He=ce*J;return new Promise(Xt=>{$.addEventListener("message",Pe=>{if(Pe.data)for(const Ye of T)Ye!==$&&Ye.postMessage({type:"abort"});Xt(Pe.data)}),$.postMessage({payload:{alg:w,challenge:n,max:He+J,salt:u,start:He},type:"work"})})}));for(const $ of T)$.terminate();return E.find($=>!!$)||null}function Tt(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(G)?k&&(b==null?void 0:b.reportValidity())===!1?t(6,P=!1):K():t(6,P=!0)}function Mt(){G===g.VERIFYING&&alert(l.waitAlert)}function le(n){R("expire",n),clearTimeout(be),n<1?De():be=setTimeout(De,n)}function Vt(n){var w;const u=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((w=u==null?void 0:u.value)==null?void 0:w.slice(u.value.indexOf("@")))||void 0}function Ut(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(w=>`input[name="${w}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((w,S)=>{const Z=S.name,T=S.value.trim();return Z&&T&&(w[Z]=T),w},{})}async function Gt(n){if(!y)throw new Error("Attribute verifyurl not set.");R("requesting server verification from",y);const u={payload:n};if(k){const{email:Z,expectedLanguages:T,expectedCountries:J,fields:E,ipAddress:$,timeZone:ce}=typeof k=="object"?k:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};u.ipAddress=$===!1?void 0:$||"auto",u.email=Z===!1?void 0:Vt(Z),u.fields=E===!1?void 0:Ut(E),u.timeZone=ce===!1?void 0:ce||Nt(),u.expectedCountries=J,u.expectedLanguages=T||(Ae?[Ae]:void 0)}const w=await fetch(y,{body:JSON.stringify(u),headers:{"content-type":"application/json"},method:"POST"});if(w.status!==200)throw new Error(`Server responded with ${w.status}.`);const S=await w.json();if(S!=null&&S.payload&&t(4,B=S.payload),I("serververification",S),f&&S.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Oe(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&K()),n.expire!==void 0&&(le(n.expire),t(14,L=n.expire)),n.challenge&&(Ge(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(12,a=n.challengeurl),n.debug!==void 0&&t(13,A=!!n.debug),n.hidefooter!==void 0&&t(1,V=!!n.hidefooter),n.hidelogo!==void 0&&t(2,U=!!n.hidelogo),n.maxnumber!==void 0&&t(15,_=+n.maxnumber),n.mockerror!==void 0&&t(16,W=!!n.mockerror),n.name!==void 0&&t(3,X=n.name),n.refetchonexpire!==void 0&&t(17,F=!!n.refetchonexpire),n.spamfilter!==void 0&&t(18,k=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(28,o=n.strings),n.test!==void 0&&t(19,m=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(20,y=n.verifyurl),n.workers!==void 0&&t(21,d=+n.workers)}function se(n=g.UNVERIFIED,u=null){clearTimeout(be),t(6,P=!1),t(8,ge=u),t(4,B=null),t(5,G=n)}async function K(){return se(g.VERIFYING),jt().then(n=>(Ge(n),R("challenge",n),Zt(n))).then(({data:n,solution:u})=>{if(R("solution",u),(u==null?void 0:u.number)!==void 0){if(y)return Gt(Ue(n,u));t(4,B=Ue(n,u)),R("payload",B)}else throw R("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{lt().then(()=>{t(5,G=g.VERIFIED),t(6,P=!0),R("verified"),I("verified",{payload:B})})}).catch(n=>{R(n),t(5,G=g.ERROR),t(6,P=!1),t(8,ge=n.message)})}function Dt(){P=this.checked,t(6,P)}function Ot(n){ue[n?"unshift":"push"](()=>{oe=n,t(7,oe)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(22,f=n.blockspam),"challengeurl"in n&&t(12,a=n.challengeurl),"challengejson"in n&&t(23,h=n.challengejson),"debug"in n&&t(13,A=n.debug),"expire"in n&&t(14,L=n.expire),"hidefooter"in n&&t(1,V=n.hidefooter),"hidelogo"in n&&t(2,U=n.hidelogo),"name"in n&&t(3,X=n.name),"maxnumber"in n&&t(15,_=n.maxnumber),"mockerror"in n&&t(16,W=n.mockerror),"refetchonexpire"in n&&t(17,F=n.refetchonexpire),"spamfilter"in n&&t(18,k=n.spamfilter),"strings"in n&&t(24,x=n.strings),"test"in n&&t(19,m=n.test),"verifyurl"in n&&t(20,y=n.verifyurl),"workers"in n&&t(21,d=n.workers)},r.$$.update=()=>{r.$$.dirty[0]&8388608&&(i=h?Se(h):void 0),r.$$.dirty[0]&16777216&&t(28,o=x?Se(x):{}),r.$$.dirty[0]&268435456&&t(9,l={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.",...o}),r.$$.dirty[0]&48&&I("statechange",{payload:B,state:G})},[s,V,U,X,B,G,P,oe,ge,l,Tt,Mt,a,A,L,_,W,F,k,m,y,d,f,h,x,Oe,se,K,o,Dt,Ot]}class je extends bt{constructor(e){super(),mt(this,e,St,zt,We,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,configure:25,reset:26,verify:27},Et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),p()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),p()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),p()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),p()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),p()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),p()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),p()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),p()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),p()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),p()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),p()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),p()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),p()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),p()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),p()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),p()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),p()}get configure(){return this.$$.ctx[25]}get reset(){return this.$$.ctx[26]}get verify(){return this.$$.ctx[27]}}return customElements.define("altcha-widget",gt(je,{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)),D.Altcha=je,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"}),D}({});
1
+ var altcha=function(O){"use strict";var Ft=Object.defineProperty;var Ht=(O,z,P)=>z in O?Ft(O,z,{enumerable:!0,configurable:!0,writable:!0,value:P}):O[z]=P;var M=(O,z,P)=>(Ht(O,typeof z!="symbol"?z+"":z,P),P);function z(){}function P(r){return r()}function ye(){return Object.create(null)}function re(r){r.forEach(P)}function ve(r){return typeof r=="function"}function We(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function Be(r){return Object.keys(r).length===0}function v(r,e){r.appendChild(e)}function Ke(r,e,t){const i=Je(r);if(!i.getElementById(e)){const o=C("style");o.id=e,o.textContent=t,Qe(i,o)}}function Je(r){if(!r)return document;const e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function Qe(r,e){return v(r.head||r,e),e.sheet}function j(r,e,t){r.insertBefore(e,t||null)}function N(r){r.parentNode&&r.parentNode.removeChild(r)}function C(r){return document.createElement(r)}function X(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function qe(r){return document.createTextNode(r)}function W(){return qe(" ")}function fe(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function c(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function et(r){return Array.from(r.childNodes)}function we(r,e,t){r.classList.toggle(e,!!t)}function tt(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function rt(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ne;function ie(r){ne=r}function ue(){if(!ne)throw new Error("Function called outside component initialization");return ne}function nt(r){ue().$$.on_mount.push(r)}function it(r){ue().$$.on_destroy.push(r)}function ot(){const r=ue();return(e,t,{cancelable:i=!1}={})=>{const o=r.$$.callbacks[e];if(o){const l=tt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(r,l)}),!l.defaultPrevented}return!0}}const q=[],he=[];let ee=[];const pe=[],_e=Promise.resolve();let de=!1;function ke(){de||(de=!0,_e.then(p))}function lt(){return ke(),_e}function me(r){ee.push(r)}const ge=new Set;let te=0;function p(){if(te!==0)return;const r=ne;do{try{for(;te<q.length;){const e=q[te];te++,ie(e),st(e.$$)}}catch(e){throw q.length=0,te=0,e}for(ie(null),q.length=0,te=0;he.length;)he.pop()();for(let e=0;e<ee.length;e+=1){const t=ee[e];ge.has(t)||(ge.add(t),t())}ee.length=0}while(q.length);for(;pe.length;)pe.pop()();de=!1,ge.clear(),ie(r)}function st(r){if(r.fragment!==null){r.update(),re(r.before_update);const e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(me)}}function ct(r){const e=[],t=[];ee.forEach(i=>r.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),ee=e}const at=new Set;function ft(r,e){r&&r.i&&(at.delete(r),r.i(e))}function ut(r,e,t){const{fragment:i,after_update:o}=r.$$;i&&i.m(e,t),me(()=>{const l=r.$$.on_mount.map(P).filter(ve);r.$$.on_destroy?r.$$.on_destroy.push(...l):re(l),r.$$.on_mount=[]}),o.forEach(me)}function ht(r,e){const t=r.$$;t.fragment!==null&&(ct(t.after_update),re(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function dt(r,e){r.$$.dirty[0]===-1&&(q.push(r),ke(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function mt(r,e,t,i,o,l,s=null,f=[-1]){const a=ne;ie(r);const h=r.$$={fragment:null,ctx:[],props:l,update:z,not_equal:o,bound:ye(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:ye(),dirty:f,skip_bound:!1,root:e.target||a.$$.root};s&&s(h.root);let A=!1;if(h.ctx=t?t(r,e.props||{},(L,V,...U)=>{const F=U.length?U[0]:V;return h.ctx&&o(h.ctx[L],h.ctx[L]=F)&&(!h.skip_bound&&h.bound[L]&&h.bound[L](F),A&&dt(r,L)),V}):[],h.update(),A=!0,re(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const L=et(e.target);h.fragment&&h.fragment.l(L),L.forEach(N)}else h.fragment&&h.fragment.c();e.intro&&ft(r.$$.fragment),ut(r,e.target,e.anchor),p()}ie(a)}let xe;typeof HTMLElement=="function"&&(xe=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(l){return()=>{let s;return{c:function(){s=C("slot"),l!=="default"&&c(s,"name",l)},m:function(h,A){j(h,s,A)},d:function(h){h&&N(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=rt(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]=oe(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=oe(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 f=this.$$c.$on(l,s);this.$$l_u.set(s,f)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=oe(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(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function oe(r,e,t,i){var l;const o=(l=t[r])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function gt(r,e,t,i,o,l){let s=class extends xe{constructor(){super(r,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(f=>(e[f].attribute||f).toLowerCase())}};return Object.keys(e).forEach(f=>{Object.defineProperty(s.prototype,f,{get(){return this.$$c&&f in this.$$c?this.$$c[f]:this.$$d[f]},set(a){var h;a=oe(f,a,e),this.$$d[f]=a,(h=this.$$c)==null||h.$set({[f]:a})}})}),i.forEach(f=>{Object.defineProperty(s.prototype,f,{get(){var a;return(a=this.$$c)==null?void 0:a[f]}})}),l&&(s=l(s)),r.element=s,s}class bt{constructor(){M(this,"$$");M(this,"$$set")}$destroy(){ht(this,1),this.$destroy=z}$on(e,t){if(!ve(t))return z;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&&!Be(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const yt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(yt);const Ee="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",vt=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),$e=typeof window<"u"&&window.Blob&&new Blob([vt(Ee)],{type:"text/javascript;charset=utf-8"});function wt(r){let e;try{if(e=$e&&(window.URL||window.webkitURL).createObjectURL($e),!e)throw"";const t=new Worker(e,{name:r==null?void 0:r.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Ee,{name:r==null?void 0:r.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const pt=new TextEncoder;function _t(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function kt(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const o=await Ce(i,r,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Ce(r,e,t){return _t(await crypto.subtle.digest(t.toUpperCase(),pt.encode(r+e)))}function xt(r,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let a=o;a<=i;a+=1){if(l.signal.aborted)return null;if(await Ce(e,a,t)===r)return{number:a,took:Date.now()-s}}return null})(),controller:l}}var g=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(g||{});function Et(r){Ke(r,"svelte-15co9zy",".altcha.svelte-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}")}function Le(r){let e,t,i;return{c(){e=X("svg"),t=X("path"),i=X("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-15co9zy"),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){j(o,e,l),v(e,t),v(e,i)},d(o){o&&N(e)}}}function $t(r){let e,t=r[9].label+"",i;return{c(){e=C("label"),c(e,"for",i=r[3]+"_checkbox"),c(e,"class","svelte-15co9zy")},m(o,l){j(o,e,l),e.innerHTML=t},p(o,l){l[0]&512&&t!==(t=o[9].label+"")&&(e.innerHTML=t),l[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&N(e)}}}function Ct(r){let e,t=r[9].verifying+"";return{c(){e=C("span")},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].verifying+"")&&(e.innerHTML=t)},d(i){i&&N(e)}}}function Lt(r){let e,t=r[9].verified+"",i,o;return{c(){e=C("span"),i=W(),o=C("input"),c(o,"type","hidden"),c(o,"name",r[3]),o.value=r[4]},m(l,s){j(l,e,s),e.innerHTML=t,j(l,i,s),j(l,o,s)},p(l,s){s[0]&512&&t!==(t=l[9].verified+"")&&(e.innerHTML=t),s[0]&8&&c(o,"name",l[3]),s[0]&16&&(o.value=l[4])},d(l){l&&(N(e),N(i),N(o))}}}function Re(r){let e,t,i,o,l,s;return{c(){e=C("div"),t=C("a"),i=X("svg"),o=X("path"),l=X("path"),s=X("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",Ne),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-15co9zy")},m(f,a){j(f,e,a),v(e,t),v(t,i),v(i,o),v(i,l),v(i,s)},p:z,d(f){f&&N(e)}}}function Ie(r){let e,t,i,o;function l(a,h){return a[5]===g.EXPIRED?It:Rt}let s=l(r),f=s(r);return{c(){e=C("div"),t=X("svg"),i=X("path"),o=W(),f.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-15co9zy")},m(a,h){j(a,e,h),v(e,t),v(t,i),v(e,o),f.m(e,null)},p(a,h){s===(s=l(a))&&f?f.p(a,h):(f.d(1),f=s(a),f&&(f.c(),f.m(e,null)))},d(a){a&&N(e),f.d()}}}function Rt(r){let e,t=r[9].error+"";return{c(){e=C("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].error+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function It(r){let e,t=r[9].expired+"";return{c(){e=C("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].expired+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function ze(r){let e,t,i=r[9].footer+"";return{c(){e=C("div"),t=C("div"),c(t,"class","svelte-15co9zy"),c(e,"class","altcha-footer svelte-15co9zy")},m(o,l){j(o,e,l),v(e,t),t.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(t.innerHTML=i)},d(o){o&&N(e)}}}function zt(r){let e,t,i,o,l,s,f,a,h,A,L,V,U,F,_=r[5]===g.VERIFYING&&Le();function B(d,I){return d[5]===g.VERIFIED?Lt:d[5]===g.VERIFYING?Ct:$t}let H=B(r),k=H(r),x=r[2]!==!0&&Re(),m=(r[8]||r[5]===g.EXPIRED)&&Ie(r),y=r[9].footer&&r[1]!==!0&&ze(r);return{c(){e=C("div"),t=C("div"),_&&_.c(),i=W(),o=C("div"),l=C("input"),a=W(),h=C("div"),k.c(),A=W(),x&&x.c(),L=W(),m&&m.c(),V=W(),y&&y.c(),c(l,"type","checkbox"),c(l,"id",s=r[3]+"_checkbox"),l.required=f=r[0]!=="onsubmit",c(l,"class","svelte-15co9zy"),c(o,"class","altcha-checkbox svelte-15co9zy"),we(o,"altcha-hidden",r[5]===g.VERIFYING),c(h,"class","altcha-label svelte-15co9zy"),c(t,"class","altcha-main svelte-15co9zy"),c(e,"class","altcha svelte-15co9zy"),c(e,"data-state",r[5])},m(d,I){j(d,e,I),v(e,t),_&&_.m(t,null),v(t,i),v(t,o),v(o,l),l.checked=r[6],v(t,a),v(t,h),k.m(h,null),v(t,A),x&&x.m(t,null),v(e,L),m&&m.m(e,null),v(e,V),y&&y.m(e,null),r[30](e),U||(F=[fe(l,"change",r[29]),fe(l,"change",r[10]),fe(l,"invalid",r[11])],U=!0)},p(d,I){d[5]===g.VERIFYING?_||(_=Le(),_.c(),_.m(t,i)):_&&(_.d(1),_=null),I[0]&8&&s!==(s=d[3]+"_checkbox")&&c(l,"id",s),I[0]&1&&f!==(f=d[0]!=="onsubmit")&&(l.required=f),I[0]&64&&(l.checked=d[6]),I[0]&32&&we(o,"altcha-hidden",d[5]===g.VERIFYING),H===(H=B(d))&&k?k.p(d,I):(k.d(1),k=H(d),k&&(k.c(),k.m(h,null))),d[2]!==!0?x?x.p(d,I):(x=Re(),x.c(),x.m(t,null)):x&&(x.d(1),x=null),d[8]||d[5]===g.EXPIRED?m?m.p(d,I):(m=Ie(d),m.c(),m.m(e,V)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?y?y.p(d,I):(y=ze(d),y.c(),y.m(e,null)):y&&(y.d(1),y=null),I[0]&32&&c(e,"data-state",d[5])},i:z,o:z,d(d){d&&N(e),_&&_.d(),k.d(),x&&x.d(),m&&m.d(),y&&y.d(),r[30](null),U=!1,re(F)}}}const Ne="https://altcha.org/";function Se(r){return JSON.parse(r)}function Nt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function St(r,e,t){var Xe,Fe;let i,o,l,{auto:s=void 0}=e,{blockspam:f=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:h=void 0}=e,{debug:A=!1}=e,{expire:L=void 0}=e,{hidefooter:V=!1}=e,{hidelogo:U=!1}=e,{name:F="altcha"}=e,{maxnumber:_=1e6}=e,{mockerror:B=!1}=e,{refetchonexpire:H=!0}=e,{spamfilter:k=!1}=e,{strings:x=void 0}=e,{test:m=!1}=e,{verifyurl:y=void 0}=e,{workers:d=Math.min(16,navigator.hardwareConcurrency||8)}=e;const I=ot(),Ze=["SHA-256","SHA-384","SHA-512"],Ae=(Fe=(Xe=document.documentElement.lang)==null?void 0:Xe.split("-"))==null?void 0:Fe[0];let Y=!1,le,b=null,be=null,K=null,G=g.UNVERIFIED,D=null;it(()=>{b&&(b.removeEventListener("submit",Me),b.removeEventListener("reset",Ve),b.removeEventListener("focusin",Te),b=null),D&&(clearTimeout(D),D=null)}),nt(()=>{R("mounted","0.4.3"),R("workers",d),m&&R("using test mode"),L&&se(L),s!==void 0&&R("auto",s),b=le.closest("form"),b&&(b.addEventListener("submit",Me),b.addEventListener("reset",Ve),s==="onfocus"&&b.addEventListener("focusin",Te)),s==="onload"&&J()});function R(...n){(A||n.some(u=>u instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Te(n){G===g.UNVERIFIED&&J()}function Me(n){b&&s==="onsubmit"&&G===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),J().then(()=>{b==null||b.requestSubmit()}))}function Ve(){ce()}function Ue(n,u){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:u.number,salt:n.salt,signature:n.signature,test:m?!0:void 0,took:u.took}))}function Ge(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(!Ze.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ze.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 jt(){var n;if(B)throw R("mocking error"),new Error("Mocked error.");if(i)return R("using provided json data"),i;if(m)return R("generating test challenge",{test:m}),kt(typeof m!="boolean"?+m:void 0);{if(!a)throw new Error("Attribute challengeurl not set.");R("fetching challenge from",a);const u=await fetch(a,{headers:{"x-altcha-spam-filter":k?"1":"0"}});if(u.status!==200)throw new Error(`Server responded with ${u.status}.`);const w=u.headers.get("Expires"),S=u.headers.get("X-Altcha-Config"),Z=await u.json(),T=new URLSearchParams((n=Z.salt.split("?"))==null?void 0:n[1]),Q=T.get("expires")||T.get("expire");if(Q){const E=new Date(+Q*1e3),$=isNaN(E.getTime())?0:E.getTime()-Date.now();$>0&&se($)}if(S)try{const E=JSON.parse(S);E&&typeof E=="object"&&(E.verifyurl&&(E.verifyurl=new URL(E.verifyurl,new URL(a)).toString()),Oe(E))}catch(E){R("unable to configure from X-Altcha-Config",E)}if(!L&&(w!=null&&w.length)){const E=Date.parse(w);if(E){const $=E-Date.now();$>0&&se($)}}return Z}}function De(){a&&H&&G===g.VERIFIED?J():ce(g.EXPIRED,l.expired)}async function Zt(n){let u=null;if("Worker"in window){try{u=await At(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(w){R(w)}if((u==null?void 0:u.number)!==void 0)return{data:n,solution:u}}return{data:n,solution:await xt(n.challenge,n.salt,n.algorithm,n.maxnumber||_).promise}}async function At(n,u,w,S=typeof m=="number"?m:_,Z=Math.ceil(d)){const T=[];if(Z<1)throw new Error("Wrong number of workers configured.");if(Z>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let $=0;$<Z;$++)T.push(new wt);const Q=Math.ceil(S/Z),E=await Promise.all(T.map(($,ae)=>{const He=ae*Q;return new Promise(Xt=>{$.addEventListener("message",Pe=>{if(Pe.data)for(const Ye of T)Ye!==$&&Ye.postMessage({type:"abort"});Xt(Pe.data)}),$.postMessage({payload:{alg:w,challenge:n,max:He+Q,salt:u,start:He},type:"work"})})}));for(const $ of T)$.terminate();return E.find($=>!!$)||null}function Tt(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(G)?k&&(b==null?void 0:b.reportValidity())===!1?t(6,Y=!1):J():t(6,Y=!0)}function Mt(){G===g.VERIFYING&&alert(l.waitAlert)}function se(n){R("expire",n),D&&(clearTimeout(D),D=null),n<1?De():D=setTimeout(De,n)}function Vt(n){var w;const u=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((w=u==null?void 0:u.value)==null?void 0:w.slice(u.value.indexOf("@")))||void 0}function Ut(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(w=>`input[name="${w}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((w,S)=>{const Z=S.name,T=S.value.trim();return Z&&T&&(w[Z]=T),w},{})}async function Gt(n){if(!y)throw new Error("Attribute verifyurl not set.");R("requesting server verification from",y);const u={payload:n};if(k){const{email:Z,expectedLanguages:T,expectedCountries:Q,fields:E,ipAddress:$,timeZone:ae}=typeof k=="object"?k:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};u.ipAddress=$===!1?void 0:$||"auto",u.email=Z===!1?void 0:Vt(Z),u.fields=E===!1?void 0:Ut(E),u.timeZone=ae===!1?void 0:ae||Nt(),u.expectedCountries=Q,u.expectedLanguages=T||(Ae?[Ae]:void 0)}const w=await fetch(y,{body:JSON.stringify(u),headers:{"content-type":"application/json"},method:"POST"});if(w.status!==200)throw new Error(`Server responded with ${w.status}.`);const S=await w.json();if(S!=null&&S.payload&&t(4,K=S.payload),I("serververification",S),f&&S.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Oe(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&J()),n.expire!==void 0&&(se(n.expire),t(14,L=n.expire)),n.challenge&&(Ge(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(12,a=n.challengeurl),n.debug!==void 0&&t(13,A=!!n.debug),n.hidefooter!==void 0&&t(1,V=!!n.hidefooter),n.hidelogo!==void 0&&t(2,U=!!n.hidelogo),n.maxnumber!==void 0&&t(15,_=+n.maxnumber),n.mockerror!==void 0&&t(16,B=!!n.mockerror),n.name!==void 0&&t(3,F=n.name),n.refetchonexpire!==void 0&&t(17,H=!!n.refetchonexpire),n.spamfilter!==void 0&&t(18,k=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(28,o=n.strings),n.test!==void 0&&t(19,m=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(20,y=n.verifyurl),n.workers!==void 0&&t(21,d=+n.workers)}function ce(n=g.UNVERIFIED,u=null){D&&(clearTimeout(D),D=null),t(6,Y=!1),t(8,be=u),t(4,K=null),t(5,G=n)}async function J(){return ce(g.VERIFYING),jt().then(n=>(Ge(n),R("challenge",n),Zt(n))).then(({data:n,solution:u})=>{if(R("solution",u),(u==null?void 0:u.number)!==void 0){if(y)return Gt(Ue(n,u));t(4,K=Ue(n,u)),R("payload",K)}else throw R("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{lt().then(()=>{t(5,G=g.VERIFIED),t(6,Y=!0),R("verified"),I("verified",{payload:K})})}).catch(n=>{R(n),t(5,G=g.ERROR),t(6,Y=!1),t(8,be=n.message)})}function Dt(){Y=this.checked,t(6,Y)}function Ot(n){he[n?"unshift":"push"](()=>{le=n,t(7,le)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(22,f=n.blockspam),"challengeurl"in n&&t(12,a=n.challengeurl),"challengejson"in n&&t(23,h=n.challengejson),"debug"in n&&t(13,A=n.debug),"expire"in n&&t(14,L=n.expire),"hidefooter"in n&&t(1,V=n.hidefooter),"hidelogo"in n&&t(2,U=n.hidelogo),"name"in n&&t(3,F=n.name),"maxnumber"in n&&t(15,_=n.maxnumber),"mockerror"in n&&t(16,B=n.mockerror),"refetchonexpire"in n&&t(17,H=n.refetchonexpire),"spamfilter"in n&&t(18,k=n.spamfilter),"strings"in n&&t(24,x=n.strings),"test"in n&&t(19,m=n.test),"verifyurl"in n&&t(20,y=n.verifyurl),"workers"in n&&t(21,d=n.workers)},r.$$.update=()=>{r.$$.dirty[0]&8388608&&(i=h?Se(h):void 0),r.$$.dirty[0]&16777216&&t(28,o=x?Se(x):{}),r.$$.dirty[0]&268435456&&t(9,l={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.",...o}),r.$$.dirty[0]&48&&I("statechange",{payload:K,state:G})},[s,V,U,F,K,G,Y,le,be,l,Tt,Mt,a,A,L,_,B,H,k,m,y,d,f,h,x,Oe,ce,J,o,Dt,Ot]}class je extends bt{constructor(e){super(),mt(this,e,St,zt,We,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,configure:25,reset:26,verify:27},Et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),p()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),p()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),p()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),p()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),p()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),p()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),p()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),p()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),p()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),p()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),p()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),p()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),p()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),p()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),p()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),p()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),p()}get configure(){return this.$$.ctx[25]}get reset(){return this.$$.ctx[26]}get verify(){return this.$$.ctx[27]}}return customElements.define("altcha-widget",gt(je,{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)),O.Altcha=je,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"}),O}({});
package/dist/altcha.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var nt = Object.defineProperty;
2
2
  var it = (r, e, t) => e in r ? nt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
3
  var T = (r, e, t) => (it(r, typeof e != "symbol" ? e + "" : e, t), t);
4
- function Q() {
4
+ function q() {
5
5
  }
6
6
  function Ve(r) {
7
7
  return r();
@@ -9,7 +9,7 @@ function Ve(r) {
9
9
  function Ie() {
10
10
  return /* @__PURE__ */ Object.create(null);
11
11
  }
12
- function te(r) {
12
+ function re(r) {
13
13
  r.forEach(Ve);
14
14
  }
15
15
  function Ue(r) {
@@ -57,13 +57,13 @@ function N(r) {
57
57
  function R(r) {
58
58
  return document.createElement(r);
59
59
  }
60
- function X(r) {
60
+ function O(r) {
61
61
  return document.createElementNS("http://www.w3.org/2000/svg", r);
62
62
  }
63
63
  function ft(r) {
64
64
  return document.createTextNode(r);
65
65
  }
66
- function W() {
66
+ function B() {
67
67
  return ft(" ");
68
68
  }
69
69
  function ae(r, e, t, i) {
@@ -90,14 +90,14 @@ function dt(r) {
90
90
  }
91
91
  ), e;
92
92
  }
93
- let ee;
94
- function q(r) {
95
- ee = r;
93
+ let te;
94
+ function ee(r) {
95
+ te = r;
96
96
  }
97
97
  function me() {
98
- if (!ee)
98
+ if (!te)
99
99
  throw new Error("Function called outside component initialization");
100
- return ee;
100
+ return te;
101
101
  }
102
102
  function mt(r) {
103
103
  me().$$.on_mount.push(r);
@@ -123,8 +123,8 @@ function bt() {
123
123
  return !0;
124
124
  };
125
125
  }
126
- const K = [], ue = [];
127
- let J = [];
126
+ const J = [], ue = [];
127
+ let Q = [];
128
128
  const Ne = [], Ge = /* @__PURE__ */ Promise.resolve();
129
129
  let he = !1;
130
130
  function De() {
@@ -134,45 +134,45 @@ function yt() {
134
134
  return De(), Ge;
135
135
  }
136
136
  function de(r) {
137
- J.push(r);
137
+ Q.push(r);
138
138
  }
139
139
  const fe = /* @__PURE__ */ new Set();
140
- let B = 0;
140
+ let K = 0;
141
141
  function $() {
142
- if (B !== 0)
142
+ if (K !== 0)
143
143
  return;
144
- const r = ee;
144
+ const r = te;
145
145
  do {
146
146
  try {
147
- for (; B < K.length; ) {
148
- const e = K[B];
149
- B++, q(e), vt(e.$$);
147
+ for (; K < J.length; ) {
148
+ const e = J[K];
149
+ K++, ee(e), vt(e.$$);
150
150
  }
151
151
  } catch (e) {
152
- throw K.length = 0, B = 0, e;
152
+ throw J.length = 0, K = 0, e;
153
153
  }
154
- for (q(null), K.length = 0, B = 0; ue.length; )
154
+ for (ee(null), J.length = 0, K = 0; ue.length; )
155
155
  ue.pop()();
156
- for (let e = 0; e < J.length; e += 1) {
157
- const t = J[e];
156
+ for (let e = 0; e < Q.length; e += 1) {
157
+ const t = Q[e];
158
158
  fe.has(t) || (fe.add(t), t());
159
159
  }
160
- J.length = 0;
161
- } while (K.length);
160
+ Q.length = 0;
161
+ } while (J.length);
162
162
  for (; Ne.length; )
163
163
  Ne.pop()();
164
- he = !1, fe.clear(), q(r);
164
+ he = !1, fe.clear(), ee(r);
165
165
  }
166
166
  function vt(r) {
167
167
  if (r.fragment !== null) {
168
- r.update(), te(r.before_update);
168
+ r.update(), re(r.before_update);
169
169
  const e = r.dirty;
170
170
  r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, e), r.after_update.forEach(de);
171
171
  }
172
172
  }
173
173
  function wt(r) {
174
174
  const e = [], t = [];
175
- J.forEach((i) => r.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), J = e;
175
+ Q.forEach((i) => r.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), Q = e;
176
176
  }
177
177
  const pt = /* @__PURE__ */ new Set();
178
178
  function _t(r, e) {
@@ -182,25 +182,25 @@ function kt(r, e, t) {
182
182
  const { fragment: i, after_update: o } = r.$$;
183
183
  i && i.m(e, t), de(() => {
184
184
  const l = r.$$.on_mount.map(Ve).filter(Ue);
185
- r.$$.on_destroy ? r.$$.on_destroy.push(...l) : te(l), r.$$.on_mount = [];
185
+ r.$$.on_destroy ? r.$$.on_destroy.push(...l) : re(l), r.$$.on_mount = [];
186
186
  }), o.forEach(de);
187
187
  }
188
188
  function xt(r, e) {
189
189
  const t = r.$$;
190
- t.fragment !== null && (wt(t.after_update), te(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
190
+ t.fragment !== null && (wt(t.after_update), re(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
191
191
  }
192
192
  function Et(r, e) {
193
- r.$$.dirty[0] === -1 && (K.push(r), De(), r.$$.dirty.fill(0)), r.$$.dirty[e / 31 | 0] |= 1 << e % 31;
193
+ r.$$.dirty[0] === -1 && (J.push(r), De(), r.$$.dirty.fill(0)), r.$$.dirty[e / 31 | 0] |= 1 << e % 31;
194
194
  }
195
195
  function $t(r, e, t, i, o, l, s = null, f = [-1]) {
196
- const a = ee;
197
- q(r);
196
+ const a = te;
197
+ ee(r);
198
198
  const h = r.$$ = {
199
199
  fragment: null,
200
200
  ctx: [],
201
201
  // state
202
202
  props: l,
203
- update: Q,
203
+ update: q,
204
204
  not_equal: o,
205
205
  bound: Ie(),
206
206
  // lifecycle
@@ -219,9 +219,9 @@ function $t(r, e, t, i, o, l, s = null, f = [-1]) {
219
219
  s && s(h.root);
220
220
  let Z = !1;
221
221
  if (h.ctx = t ? t(r, e.props || {}, (C, M, ...V) => {
222
- const G = V.length ? V[0] : M;
223
- return h.ctx && o(h.ctx[C], h.ctx[C] = G) && (!h.skip_bound && h.bound[C] && h.bound[C](G), Z && Et(r, C)), M;
224
- }) : [], h.update(), Z = !0, te(h.before_update), h.fragment = i ? i(h.ctx) : !1, e.target) {
222
+ const D = V.length ? V[0] : M;
223
+ return h.ctx && o(h.ctx[C], h.ctx[C] = D) && (!h.skip_bound && h.bound[C] && h.bound[C](D), Z && Et(r, C)), M;
224
+ }) : [], h.update(), Z = !0, re(h.before_update), h.fragment = i ? i(h.ctx) : !1, e.target) {
225
225
  if (e.hydrate) {
226
226
  const C = ut(e.target);
227
227
  h.fragment && h.fragment.l(C), C.forEach(N);
@@ -229,7 +229,7 @@ function $t(r, e, t, i, o, l, s = null, f = [-1]) {
229
229
  h.fragment && h.fragment.c();
230
230
  e.intro && _t(r.$$.fragment), kt(r, e.target, e.anchor), $();
231
231
  }
232
- q(a);
232
+ ee(a);
233
233
  }
234
234
  let Xe;
235
235
  typeof HTMLElement == "function" && (Xe = class extends HTMLElement {
@@ -297,7 +297,7 @@ typeof HTMLElement == "function" && (Xe = class extends HTMLElement {
297
297
  l in i && (t[l] = [e(l)]);
298
298
  for (const l of this.attributes) {
299
299
  const s = this.$$g_p(l.name);
300
- s in this.$$d || (this.$$d[s] = le(s, l.value, this.$$p_d, "toProp"));
300
+ s in this.$$d || (this.$$d[s] = se(s, l.value, this.$$p_d, "toProp"));
301
301
  }
302
302
  for (const l in this.$$p_d)
303
303
  !(l in this.$$d) && this[l] !== void 0 && (this.$$d[l] = this[l], delete this[l]);
@@ -315,7 +315,7 @@ typeof HTMLElement == "function" && (Xe = class extends HTMLElement {
315
315
  this.$$r = !0;
316
316
  for (const l in this.$$p_d)
317
317
  if (this.$$d[l] = this.$$c.$$.ctx[this.$$c.$$.props[l]], this.$$p_d[l].reflect) {
318
- const s = le(
318
+ const s = se(
319
319
  l,
320
320
  this.$$d[l],
321
321
  this.$$p_d,
@@ -338,7 +338,7 @@ typeof HTMLElement == "function" && (Xe = class extends HTMLElement {
338
338
  // and setting attributes through setAttribute etc, this is helpful
339
339
  attributeChangedCallback(e, t, i) {
340
340
  var o;
341
- 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] }));
341
+ this.$$r || (e = this.$$g_p(e), this.$$d[e] = se(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] }));
342
342
  }
343
343
  disconnectedCallback() {
344
344
  this.$$cn = !1, Promise.resolve().then(() => {
@@ -351,7 +351,7 @@ typeof HTMLElement == "function" && (Xe = class extends HTMLElement {
351
351
  ) || e;
352
352
  }
353
353
  });
354
- function le(r, e, t, i) {
354
+ function se(r, e, t, i) {
355
355
  var l;
356
356
  const o = (l = t[r]) == null ? void 0 : l.type;
357
357
  if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[r])
@@ -399,7 +399,7 @@ function Ct(r, e, t, i, o, l) {
399
399
  },
400
400
  set(a) {
401
401
  var h;
402
- a = le(f, a, e), this.$$d[f] = a, (h = this.$$c) == null || h.$set({ [f]: a });
402
+ a = se(f, a, e), this.$$d[f] = a, (h = this.$$c) == null || h.$set({ [f]: a });
403
403
  }
404
404
  });
405
405
  }), i.forEach((f) => {
@@ -433,7 +433,7 @@ class Lt {
433
433
  }
434
434
  /** @returns {void} */
435
435
  $destroy() {
436
- xt(this, 1), this.$destroy = Q;
436
+ xt(this, 1), this.$destroy = q;
437
437
  }
438
438
  /**
439
439
  * @template {Extract<keyof Events, string>} K
@@ -443,7 +443,7 @@ class Lt {
443
443
  */
444
444
  $on(e, t) {
445
445
  if (!Ue(t))
446
- return Q;
446
+ return q;
447
447
  const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
448
448
  return i.push(t), () => {
449
449
  const o = i.indexOf(t);
@@ -532,7 +532,7 @@ function je(r) {
532
532
  let e, t, i;
533
533
  return {
534
534
  c() {
535
- e = X("svg"), t = X("path"), i = X("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-15co9zy"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg");
535
+ 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-15co9zy"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg");
536
536
  },
537
537
  m(o, l) {
538
538
  j(o, e, l), v(e, t), v(e, i);
@@ -596,7 +596,7 @@ function Vt(r) {
596
596
  ), i, o;
597
597
  return {
598
598
  c() {
599
- e = R("span"), i = W(), o = R("input"), c(o, "type", "hidden"), c(
599
+ e = R("span"), i = B(), o = R("input"), c(o, "type", "hidden"), c(
600
600
  o,
601
601
  "name",
602
602
  /*name*/
@@ -629,12 +629,12 @@ function Ze(r) {
629
629
  let e, t, i, o, l, s;
630
630
  return {
631
631
  c() {
632
- e = R("div"), t = R("a"), i = X("svg"), o = X("path"), l = X("path"), s = X("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", He), c(t, "target", "_blank"), c(t, "class", "altcha-logo svelte-15co9zy");
632
+ e = R("div"), t = R("a"), i = O("svg"), o = O("path"), l = O("path"), s = O("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", He), c(t, "target", "_blank"), c(t, "class", "altcha-logo svelte-15co9zy");
633
633
  },
634
634
  m(f, a) {
635
635
  j(f, e, a), v(e, t), v(t, i), v(i, o), v(i, l), v(i, s);
636
636
  },
637
- p: Q,
637
+ p: q,
638
638
  d(f) {
639
639
  f && N(e);
640
640
  }
@@ -651,7 +651,7 @@ function Ae(r) {
651
651
  let s = l(r), f = s(r);
652
652
  return {
653
653
  c() {
654
- e = R("div"), t = X("svg"), i = X("path"), o = W(), f.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-15co9zy");
654
+ e = R("div"), t = O("svg"), i = O("path"), o = B(), f.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-15co9zy");
655
655
  },
656
656
  m(a, h) {
657
657
  j(a, e, h), v(e, t), v(t, i), v(e, o), f.m(e, null);
@@ -753,11 +753,11 @@ function Te(r) {
753
753
  };
754
754
  }
755
755
  function Dt(r) {
756
- let e, t, i, o, l, s, f, a, h, Z, C, M, V, G, p = (
756
+ let e, t, i, o, l, s, f, a, h, Z, C, M, V, D, p = (
757
757
  /*state*/
758
758
  r[5] === b.VERIFYING && je()
759
759
  );
760
- function F(d, I) {
760
+ function H(d, I) {
761
761
  return (
762
762
  /*state*/
763
763
  d[5] === b.VERIFIED ? Vt : (
@@ -766,7 +766,7 @@ function Dt(r) {
766
766
  )
767
767
  );
768
768
  }
769
- let D = F(r), _ = D(r), k = (
769
+ let X = H(r), _ = X(r), k = (
770
770
  /*hidelogo*/
771
771
  r[2] !== !0 && Ze()
772
772
  ), m = (
@@ -780,7 +780,7 @@ function Dt(r) {
780
780
  );
781
781
  return {
782
782
  c() {
783
- e = R("div"), t = R("div"), p && p.c(), i = W(), o = R("div"), l = R("input"), a = W(), h = R("div"), _.c(), Z = W(), k && k.c(), C = W(), m && m.c(), M = W(), y && y.c(), c(l, "type", "checkbox"), c(l, "id", s = /*name*/
783
+ e = R("div"), t = R("div"), p && p.c(), i = B(), o = R("div"), l = R("input"), a = B(), h = R("div"), _.c(), Z = B(), k && k.c(), C = B(), m && m.c(), M = B(), y && y.c(), c(l, "type", "checkbox"), c(l, "id", s = /*name*/
784
784
  r[3] + "_checkbox"), l.required = f = /*auto*/
785
785
  r[0] !== "onsubmit", c(l, "class", "svelte-15co9zy"), c(o, "class", "altcha-checkbox svelte-15co9zy"), ze(
786
786
  o,
@@ -796,7 +796,7 @@ function Dt(r) {
796
796
  },
797
797
  m(d, I) {
798
798
  j(d, e, I), v(e, t), p && p.m(t, null), v(t, i), v(t, o), v(o, l), l.checked = /*checked*/
799
- r[6], v(t, a), v(t, h), _.m(h, null), v(t, Z), k && k.m(t, null), v(e, C), m && m.m(e, null), v(e, M), y && y.m(e, null), r[30](e), V || (G = [
799
+ r[6], v(t, a), v(t, h), _.m(h, null), v(t, Z), k && k.m(t, null), v(e, C), m && m.m(e, null), v(e, M), y && y.m(e, null), r[30](e), V || (D = [
800
800
  ae(
801
801
  l,
802
802
  "change",
@@ -831,7 +831,7 @@ function Dt(r) {
831
831
  "altcha-hidden",
832
832
  /*state*/
833
833
  d[5] === b.VERIFYING
834
- ), D === (D = F(d)) && _ ? _.p(d, I) : (_.d(1), _ = D(d), _ && (_.c(), _.m(h, null))), /*hidelogo*/
834
+ ), X === (X = H(d)) && _ ? _.p(d, I) : (_.d(1), _ = X(d), _ && (_.c(), _.m(h, null))), /*hidelogo*/
835
835
  d[2] !== !0 ? k ? k.p(d, I) : (k = Ze(), k.c(), k.m(t, null)) : k && (k.d(1), k = null), /*error*/
836
836
  d[8] || /*state*/
837
837
  d[5] === b.EXPIRED ? m ? m.p(d, I) : (m = Ae(d), m.c(), m.m(e, M)) : m && (m.d(1), m = null), /*_strings*/
@@ -844,10 +844,10 @@ function Dt(r) {
844
844
  d[5]
845
845
  );
846
846
  },
847
- i: Q,
848
- o: Q,
847
+ i: q,
848
+ o: q,
849
849
  d(d) {
850
- d && N(e), p && p.d(), _.d(), k && k.d(), m && m.d(), y && y.d(), r[30](null), V = !1, te(G);
850
+ d && N(e), p && p.d(), _.d(), k && k.d(), m && m.d(), y && y.d(), r[30](null), V = !1, re(D);
851
851
  }
852
852
  };
853
853
  }
@@ -863,27 +863,27 @@ function Xt() {
863
863
  }
864
864
  function Ot(r, e, t) {
865
865
  var Ee, $e;
866
- let i, o, l, { auto: s = void 0 } = e, { blockspam: f = void 0 } = e, { challengeurl: a = void 0 } = e, { challengejson: h = void 0 } = e, { debug: Z = !1 } = e, { expire: C = void 0 } = e, { hidefooter: M = !1 } = e, { hidelogo: V = !1 } = e, { name: G = "altcha" } = e, { maxnumber: p = 1e6 } = e, { mockerror: F = !1 } = e, { refetchonexpire: D = !0 } = e, { spamfilter: _ = !1 } = e, { strings: k = void 0 } = e, { test: m = !1 } = e, { verifyurl: y = void 0 } = e, { workers: d = navigator.hardwareConcurrency || 8 } = e;
866
+ let i, o, l, { auto: s = void 0 } = e, { blockspam: f = void 0 } = e, { challengeurl: a = void 0 } = e, { challengejson: h = void 0 } = e, { debug: Z = !1 } = e, { expire: C = void 0 } = e, { hidefooter: M = !1 } = e, { hidelogo: V = !1 } = e, { name: D = "altcha" } = e, { maxnumber: p = 1e6 } = e, { mockerror: H = !1 } = e, { refetchonexpire: X = !0 } = e, { spamfilter: _ = !1 } = e, { strings: k = void 0 } = e, { test: m = !1 } = e, { verifyurl: y = void 0 } = e, { workers: d = Math.min(16, navigator.hardwareConcurrency || 8) } = e;
867
867
  const I = bt(), ge = ["SHA-256", "SHA-384", "SHA-512"], be = ($e = (Ee = document.documentElement.lang) == null ? void 0 : Ee.split("-")) == null ? void 0 : $e[0];
868
- let O = !1, re, g = null, se = null, H = null, U = b.UNVERIFIED, ce;
868
+ let F = !1, ne, g = null, ce = null, Y = null, U = b.UNVERIFIED, G = null;
869
869
  gt(() => {
870
- g && (g.removeEventListener("submit", ve), g.removeEventListener("reset", we), g.removeEventListener("focusin", ye), g = null);
870
+ g && (g.removeEventListener("submit", ve), g.removeEventListener("reset", we), g.removeEventListener("focusin", ye), g = null), G && (clearTimeout(G), G = null);
871
871
  }), mt(() => {
872
- L("mounted", "0.4.1"), L("workers", d), m && L("using test mode"), C && ne(C), s !== void 0 && L("auto", s), g = re.closest("form"), g && (g.addEventListener("submit", ve), g.addEventListener("reset", we), s === "onfocus" && g.addEventListener("focusin", ye)), s === "onload" && Y();
872
+ L("mounted", "0.4.3"), L("workers", d), m && L("using test mode"), C && ie(C), s !== void 0 && L("auto", s), g = ne.closest("form"), g && (g.addEventListener("submit", ve), g.addEventListener("reset", we), s === "onfocus" && g.addEventListener("focusin", ye)), s === "onload" && P();
873
873
  });
874
874
  function L(...n) {
875
875
  (Z || n.some((u) => u instanceof Error)) && console[n[0] instanceof Error ? "error" : "log"]("ALTCHA", ...n);
876
876
  }
877
877
  function ye(n) {
878
- U === b.UNVERIFIED && Y();
878
+ U === b.UNVERIFIED && P();
879
879
  }
880
880
  function ve(n) {
881
- g && s === "onsubmit" && U === b.UNVERIFIED && (n.preventDefault(), n.stopPropagation(), Y().then(() => {
881
+ g && s === "onsubmit" && U === b.UNVERIFIED && (n.preventDefault(), n.stopPropagation(), P().then(() => {
882
882
  g == null || g.requestSubmit();
883
883
  }));
884
884
  }
885
885
  function we() {
886
- ie();
886
+ oe();
887
887
  }
888
888
  function pe(n, u) {
889
889
  return btoa(JSON.stringify({
@@ -910,7 +910,7 @@ function Ot(r, e, t) {
910
910
  }
911
911
  async function Ye() {
912
912
  var n;
913
- if (F)
913
+ if (H)
914
914
  throw L("mocking error"), new Error("Mocked error.");
915
915
  if (i)
916
916
  return L("using provided json data"), i;
@@ -927,10 +927,10 @@ function Ot(r, e, t) {
927
927
  });
928
928
  if (u.status !== 200)
929
929
  throw new Error(`Server responded with ${u.status}.`);
930
- const w = u.headers.get("Expires"), z = u.headers.get("X-Altcha-Config"), S = await u.json(), A = new URLSearchParams((n = S.salt.split("?")) == null ? void 0 : n[1]), P = A.get("expires") || A.get("expire");
931
- if (P) {
932
- const x = new Date(+P * 1e3), E = isNaN(x.getTime()) ? 0 : x.getTime() - Date.now();
933
- E > 0 && ne(E);
930
+ const w = u.headers.get("Expires"), z = u.headers.get("X-Altcha-Config"), S = await u.json(), A = new URLSearchParams((n = S.salt.split("?")) == null ? void 0 : n[1]), W = A.get("expires") || A.get("expire");
931
+ if (W) {
932
+ const x = new Date(+W * 1e3), E = isNaN(x.getTime()) ? 0 : x.getTime() - Date.now();
933
+ E > 0 && ie(E);
934
934
  }
935
935
  if (z)
936
936
  try {
@@ -943,14 +943,14 @@ function Ot(r, e, t) {
943
943
  const x = Date.parse(w);
944
944
  if (x) {
945
945
  const E = x - Date.now();
946
- E > 0 && ne(E);
946
+ E > 0 && ie(E);
947
947
  }
948
948
  }
949
949
  return S;
950
950
  }
951
951
  }
952
952
  function ke() {
953
- a && D && U === b.VERIFIED ? Y() : ie(b.EXPIRED, l.expired);
953
+ a && X && U === b.VERIFIED ? P() : oe(b.EXPIRED, l.expired);
954
954
  }
955
955
  async function Pe(n) {
956
956
  let u = null;
@@ -976,8 +976,8 @@ function Ot(r, e, t) {
976
976
  throw new Error("Too many workers. Max. 16 allowed workers.");
977
977
  for (let E = 0; E < S; E++)
978
978
  A.push(new zt());
979
- const P = Math.ceil(z / S), x = await Promise.all(A.map((E, oe) => {
980
- const Ce = oe * P;
979
+ const W = Math.ceil(z / S), x = await Promise.all(A.map((E, le) => {
980
+ const Ce = le * W;
981
981
  return new Promise((rt) => {
982
982
  E.addEventListener("message", (Le) => {
983
983
  if (Le.data)
@@ -988,7 +988,7 @@ function Ot(r, e, t) {
988
988
  payload: {
989
989
  alg: w,
990
990
  challenge: n,
991
- max: Ce + P,
991
+ max: Ce + W,
992
992
  salt: u,
993
993
  start: Ce
994
994
  },
@@ -1001,13 +1001,13 @@ function Ot(r, e, t) {
1001
1001
  return x.find((E) => !!E) || null;
1002
1002
  }
1003
1003
  function Be() {
1004
- [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(U) ? _ && (g == null ? void 0 : g.reportValidity()) === !1 ? t(6, O = !1) : Y() : t(6, O = !0);
1004
+ [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(U) ? _ && (g == null ? void 0 : g.reportValidity()) === !1 ? t(6, F = !1) : P() : t(6, F = !0);
1005
1005
  }
1006
1006
  function Ke() {
1007
1007
  U === b.VERIFYING && alert(l.waitAlert);
1008
1008
  }
1009
- function ne(n) {
1010
- L("expire", n), clearTimeout(ce), n < 1 ? ke() : ce = setTimeout(ke, n);
1009
+ function ie(n) {
1010
+ L("expire", n), G && (clearTimeout(G), G = null), n < 1 ? ke() : G = setTimeout(ke, n);
1011
1011
  }
1012
1012
  function Je(n) {
1013
1013
  var w;
@@ -1031,7 +1031,7 @@ function Ot(r, e, t) {
1031
1031
  L("requesting server verification from", y);
1032
1032
  const u = { payload: n };
1033
1033
  if (_) {
1034
- const { email: S, expectedLanguages: A, expectedCountries: P, fields: x, ipAddress: E, timeZone: oe } = typeof _ == "object" ? _ : {
1034
+ const { email: S, expectedLanguages: A, expectedCountries: W, fields: x, ipAddress: E, timeZone: le } = typeof _ == "object" ? _ : {
1035
1035
  email: void 0,
1036
1036
  expectedCountries: void 0,
1037
1037
  expectedLanguages: void 0,
@@ -1039,7 +1039,7 @@ function Ot(r, e, t) {
1039
1039
  ipAddress: void 0,
1040
1040
  timeZone: void 0
1041
1041
  };
1042
- u.ipAddress = E === !1 ? void 0 : E || "auto", u.email = S === !1 ? void 0 : Je(S), u.fields = x === !1 ? void 0 : Qe(x), u.timeZone = oe === !1 ? void 0 : oe || Xt(), u.expectedCountries = P, u.expectedLanguages = A || (be ? [be] : void 0);
1042
+ u.ipAddress = E === !1 ? void 0 : E || "auto", u.email = S === !1 ? void 0 : Je(S), u.fields = x === !1 ? void 0 : Qe(x), u.timeZone = le === !1 ? void 0 : le || Xt(), u.expectedCountries = W, u.expectedLanguages = A || (be ? [be] : void 0);
1043
1043
  }
1044
1044
  const w = await fetch(y, {
1045
1045
  body: JSON.stringify(u),
@@ -1049,41 +1049,41 @@ function Ot(r, e, t) {
1049
1049
  if (w.status !== 200)
1050
1050
  throw new Error(`Server responded with ${w.status}.`);
1051
1051
  const z = await w.json();
1052
- if (z != null && z.payload && t(4, H = z.payload), I("serververification", z), f && z.classification === "BAD")
1052
+ if (z != null && z.payload && t(4, Y = z.payload), I("serververification", z), f && z.classification === "BAD")
1053
1053
  throw new Error("SpamFilter returned negative classification.");
1054
1054
  }
1055
1055
  function xe(n) {
1056
- n.auto !== void 0 && (t(0, s = n.auto), s === "onload" && Y()), n.expire !== void 0 && (ne(n.expire), t(14, C = n.expire)), n.challenge && (_e(n.challenge), i = n.challenge), n.challengeurl !== void 0 && t(12, a = n.challengeurl), n.debug !== void 0 && t(13, Z = !!n.debug), n.hidefooter !== void 0 && t(1, M = !!n.hidefooter), n.hidelogo !== void 0 && t(2, V = !!n.hidelogo), n.maxnumber !== void 0 && t(15, p = +n.maxnumber), n.mockerror !== void 0 && t(16, F = !!n.mockerror), n.name !== void 0 && t(3, G = n.name), n.refetchonexpire !== void 0 && t(17, D = !!n.refetchonexpire), n.spamfilter !== void 0 && t(18, _ = typeof n.spamfilter == "object" ? n.spamfilter : !!n.spamfilter), n.strings && t(28, o = n.strings), n.test !== void 0 && t(19, m = typeof n.test == "number" ? n.test : !!n.test), n.verifyurl !== void 0 && t(20, y = n.verifyurl), n.workers !== void 0 && t(21, d = +n.workers);
1056
+ n.auto !== void 0 && (t(0, s = n.auto), s === "onload" && P()), n.expire !== void 0 && (ie(n.expire), t(14, C = n.expire)), n.challenge && (_e(n.challenge), i = n.challenge), n.challengeurl !== void 0 && t(12, a = n.challengeurl), n.debug !== void 0 && t(13, Z = !!n.debug), n.hidefooter !== void 0 && t(1, M = !!n.hidefooter), n.hidelogo !== void 0 && t(2, V = !!n.hidelogo), n.maxnumber !== void 0 && t(15, p = +n.maxnumber), n.mockerror !== void 0 && t(16, H = !!n.mockerror), n.name !== void 0 && t(3, D = n.name), n.refetchonexpire !== void 0 && t(17, X = !!n.refetchonexpire), n.spamfilter !== void 0 && t(18, _ = typeof n.spamfilter == "object" ? n.spamfilter : !!n.spamfilter), n.strings && t(28, o = n.strings), n.test !== void 0 && t(19, m = typeof n.test == "number" ? n.test : !!n.test), n.verifyurl !== void 0 && t(20, y = n.verifyurl), n.workers !== void 0 && t(21, d = +n.workers);
1057
1057
  }
1058
- function ie(n = b.UNVERIFIED, u = null) {
1059
- clearTimeout(ce), t(6, O = !1), t(8, se = u), t(4, H = null), t(5, U = n);
1058
+ function oe(n = b.UNVERIFIED, u = null) {
1059
+ G && (clearTimeout(G), G = null), t(6, F = !1), t(8, ce = u), t(4, Y = null), t(5, U = n);
1060
1060
  }
1061
- async function Y() {
1062
- return ie(b.VERIFYING), Ye().then((n) => (_e(n), L("challenge", n), Pe(n))).then(({ data: n, solution: u }) => {
1061
+ async function P() {
1062
+ return oe(b.VERIFYING), Ye().then((n) => (_e(n), L("challenge", n), Pe(n))).then(({ data: n, solution: u }) => {
1063
1063
  if (L("solution", u), (u == null ? void 0 : u.number) !== void 0) {
1064
1064
  if (y)
1065
1065
  return qe(pe(n, u));
1066
- t(4, H = pe(n, u)), L("payload", H);
1066
+ t(4, Y = pe(n, u)), L("payload", Y);
1067
1067
  } else
1068
1068
  throw L("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned.");
1069
1069
  }).then(() => {
1070
1070
  yt().then(() => {
1071
- t(5, U = b.VERIFIED), t(6, O = !0), L("verified"), I("verified", { payload: H });
1071
+ t(5, U = b.VERIFIED), t(6, F = !0), L("verified"), I("verified", { payload: Y });
1072
1072
  });
1073
1073
  }).catch((n) => {
1074
- L(n), t(5, U = b.ERROR), t(6, O = !1), t(8, se = n.message);
1074
+ L(n), t(5, U = b.ERROR), t(6, F = !1), t(8, ce = n.message);
1075
1075
  });
1076
1076
  }
1077
1077
  function et() {
1078
- O = this.checked, t(6, O);
1078
+ F = this.checked, t(6, F);
1079
1079
  }
1080
1080
  function tt(n) {
1081
1081
  ue[n ? "unshift" : "push"](() => {
1082
- re = n, t(7, re);
1082
+ ne = n, t(7, ne);
1083
1083
  });
1084
1084
  }
1085
1085
  return r.$$set = (n) => {
1086
- "auto" in n && t(0, s = n.auto), "blockspam" in n && t(22, f = n.blockspam), "challengeurl" in n && t(12, a = n.challengeurl), "challengejson" in n && t(23, h = n.challengejson), "debug" in n && t(13, Z = n.debug), "expire" in n && t(14, C = n.expire), "hidefooter" in n && t(1, M = n.hidefooter), "hidelogo" in n && t(2, V = n.hidelogo), "name" in n && t(3, G = n.name), "maxnumber" in n && t(15, p = n.maxnumber), "mockerror" in n && t(16, F = n.mockerror), "refetchonexpire" in n && t(17, D = n.refetchonexpire), "spamfilter" in n && t(18, _ = n.spamfilter), "strings" in n && t(24, k = n.strings), "test" in n && t(19, m = n.test), "verifyurl" in n && t(20, y = n.verifyurl), "workers" in n && t(21, d = n.workers);
1086
+ "auto" in n && t(0, s = n.auto), "blockspam" in n && t(22, f = n.blockspam), "challengeurl" in n && t(12, a = n.challengeurl), "challengejson" in n && t(23, h = n.challengejson), "debug" in n && t(13, Z = n.debug), "expire" in n && t(14, C = n.expire), "hidefooter" in n && t(1, M = n.hidefooter), "hidelogo" in n && t(2, V = n.hidelogo), "name" in n && t(3, D = n.name), "maxnumber" in n && t(15, p = n.maxnumber), "mockerror" in n && t(16, H = n.mockerror), "refetchonexpire" in n && t(17, X = n.refetchonexpire), "spamfilter" in n && t(18, _ = n.spamfilter), "strings" in n && t(24, k = n.strings), "test" in n && t(19, m = n.test), "verifyurl" in n && t(20, y = n.verifyurl), "workers" in n && t(21, d = n.workers);
1087
1087
  }, r.$$.update = () => {
1088
1088
  r.$$.dirty[0] & /*challengejson*/
1089
1089
  8388608 && (i = h ? Me(h) : void 0), r.$$.dirty[0] & /*strings*/
@@ -1098,17 +1098,17 @@ function Ot(r, e, t) {
1098
1098
  waitAlert: "Verifying... please wait.",
1099
1099
  ...o
1100
1100
  }), r.$$.dirty[0] & /*payload, state*/
1101
- 48 && I("statechange", { payload: H, state: U });
1101
+ 48 && I("statechange", { payload: Y, state: U });
1102
1102
  }, [
1103
1103
  s,
1104
1104
  M,
1105
1105
  V,
1106
- G,
1107
- H,
1106
+ D,
1107
+ Y,
1108
1108
  U,
1109
- O,
1110
- re,
1111
- se,
1109
+ F,
1110
+ ne,
1111
+ ce,
1112
1112
  l,
1113
1113
  Be,
1114
1114
  Ke,
@@ -1116,8 +1116,8 @@ function Ot(r, e, t) {
1116
1116
  Z,
1117
1117
  C,
1118
1118
  p,
1119
- F,
1120
- D,
1119
+ H,
1120
+ X,
1121
1121
  _,
1122
1122
  m,
1123
1123
  y,
@@ -1126,8 +1126,8 @@ function Ot(r, e, t) {
1126
1126
  h,
1127
1127
  k,
1128
1128
  xe,
1129
- ie,
1130
- Y,
1129
+ oe,
1130
+ P,
1131
1131
  o,
1132
1132
  et,
1133
1133
  tt
@@ -1 +1 @@
1
- (function(A,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(A=typeof globalThis<"u"?globalThis:A||self,C(A.altcha={}))})(this,function(A){"use strict";var Ft=Object.defineProperty;var Ht=(A,C,H)=>C in A?Ft(A,C,{enumerable:!0,configurable:!0,writable:!0,value:H}):A[C]=H;var V=(A,C,H)=>(Ht(A,typeof C!="symbol"?C+"":C,H),H);function C(){}function H(r){return r()}function ye(){return Object.create(null)}function te(r){r.forEach(H)}function ve(r){return typeof r=="function"}function We(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function Be(r){return Object.keys(r).length===0}function v(r,e){r.appendChild(e)}function Ke(r,e,t){const i=Je(r);if(!i.getElementById(e)){const o=L("style");o.id=e,o.textContent=t,Qe(i,o)}}function Je(r){if(!r)return document;const e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function Qe(r,e){return v(r.head||r,e),e.sheet}function j(r,e,t){r.insertBefore(e,t||null)}function N(r){r.parentNode&&r.parentNode.removeChild(r)}function L(r){return document.createElement(r)}function O(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function qe(r){return document.createTextNode(r)}function Y(){return qe(" ")}function ae(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function c(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function et(r){return Array.from(r.childNodes)}function we(r,e,t){r.classList.toggle(e,!!t)}function tt(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function rt(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let re;function ne(r){re=r}function fe(){if(!re)throw new Error("Function called outside component initialization");return re}function nt(r){fe().$$.on_mount.push(r)}function it(r){fe().$$.on_destroy.push(r)}function ot(){const r=fe();return(e,t,{cancelable:i=!1}={})=>{const o=r.$$.callbacks[e];if(o){const l=tt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(r,l)}),!l.defaultPrevented}return!0}}const Q=[],ue=[];let q=[];const pe=[],_e=Promise.resolve();let he=!1;function ke(){he||(he=!0,_e.then(p))}function lt(){return ke(),_e}function de(r){q.push(r)}const me=new Set;let ee=0;function p(){if(ee!==0)return;const r=re;do{try{for(;ee<Q.length;){const e=Q[ee];ee++,ne(e),st(e.$$)}}catch(e){throw Q.length=0,ee=0,e}for(ne(null),Q.length=0,ee=0;ue.length;)ue.pop()();for(let e=0;e<q.length;e+=1){const t=q[e];me.has(t)||(me.add(t),t())}q.length=0}while(Q.length);for(;pe.length;)pe.pop()();he=!1,me.clear(),ne(r)}function st(r){if(r.fragment!==null){r.update(),te(r.before_update);const e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(de)}}function ct(r){const e=[],t=[];q.forEach(i=>r.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),q=e}const at=new Set;function ft(r,e){r&&r.i&&(at.delete(r),r.i(e))}function ut(r,e,t){const{fragment:i,after_update:o}=r.$$;i&&i.m(e,t),de(()=>{const l=r.$$.on_mount.map(H).filter(ve);r.$$.on_destroy?r.$$.on_destroy.push(...l):te(l),r.$$.on_mount=[]}),o.forEach(de)}function ht(r,e){const t=r.$$;t.fragment!==null&&(ct(t.after_update),te(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function dt(r,e){r.$$.dirty[0]===-1&&(Q.push(r),ke(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function mt(r,e,t,i,o,l,s=null,f=[-1]){const a=re;ne(r);const h=r.$$={fragment:null,ctx:[],props:l,update:C,not_equal:o,bound:ye(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:ye(),dirty:f,skip_bound:!1,root:e.target||a.$$.root};s&&s(h.root);let T=!1;if(h.ctx=t?t(r,e.props||{},(R,U,...G)=>{const X=G.length?G[0]:U;return h.ctx&&o(h.ctx[R],h.ctx[R]=X)&&(!h.skip_bound&&h.bound[R]&&h.bound[R](X),T&&dt(r,R)),U}):[],h.update(),T=!0,te(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const R=et(e.target);h.fragment&&h.fragment.l(R),R.forEach(N)}else h.fragment&&h.fragment.c();e.intro&&ft(r.$$.fragment),ut(r,e.target,e.anchor),p()}ne(a)}let xe;typeof HTMLElement=="function"&&(xe=class extends HTMLElement{constructor(e,t,i){super();V(this,"$$ctor");V(this,"$$s");V(this,"$$c");V(this,"$$cn",!1);V(this,"$$d",{});V(this,"$$r",!1);V(this,"$$p_d",{});V(this,"$$l",{});V(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=L("slot"),l!=="default"&&c(s,"name",l)},m:function(h,T){j(h,s,T)},d:function(h){h&&N(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=rt(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]=ie(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=ie(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 f=this.$$c.$on(l,s);this.$$l_u.set(s,f)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=ie(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(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function ie(r,e,t,i){var l;const o=(l=t[r])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function gt(r,e,t,i,o,l){let s=class extends xe{constructor(){super(r,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(f=>(e[f].attribute||f).toLowerCase())}};return Object.keys(e).forEach(f=>{Object.defineProperty(s.prototype,f,{get(){return this.$$c&&f in this.$$c?this.$$c[f]:this.$$d[f]},set(a){var h;a=ie(f,a,e),this.$$d[f]=a,(h=this.$$c)==null||h.$set({[f]:a})}})}),i.forEach(f=>{Object.defineProperty(s.prototype,f,{get(){var a;return(a=this.$$c)==null?void 0:a[f]}})}),l&&(s=l(s)),r.element=s,s}class bt{constructor(){V(this,"$$");V(this,"$$set")}$destroy(){ht(this,1),this.$destroy=C}$on(e,t){if(!ve(t))return C;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&&!Be(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const yt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(yt);const Ee="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",vt=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),$e=typeof window<"u"&&window.Blob&&new Blob([vt(Ee)],{type:"text/javascript;charset=utf-8"});function wt(r){let e;try{if(e=$e&&(window.URL||window.webkitURL).createObjectURL($e),!e)throw"";const t=new Worker(e,{name:r==null?void 0:r.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Ee,{name:r==null?void 0:r.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const pt=new TextEncoder;function _t(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function kt(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const o=await Ce(i,r,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Ce(r,e,t){return _t(await crypto.subtle.digest(t.toUpperCase(),pt.encode(r+e)))}function xt(r,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let a=o;a<=i;a+=1){if(l.signal.aborted)return null;if(await Ce(e,a,t)===r)return{number:a,took:Date.now()-s}}return null})(),controller:l}}var g=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(g||{});function Et(r){Ke(r,"svelte-15co9zy",".altcha.svelte-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}")}function Le(r){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-15co9zy"),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){j(o,e,l),v(e,t),v(e,i)},d(o){o&&N(e)}}}function $t(r){let e,t=r[9].label+"",i;return{c(){e=L("label"),c(e,"for",i=r[3]+"_checkbox"),c(e,"class","svelte-15co9zy")},m(o,l){j(o,e,l),e.innerHTML=t},p(o,l){l[0]&512&&t!==(t=o[9].label+"")&&(e.innerHTML=t),l[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&N(e)}}}function Ct(r){let e,t=r[9].verifying+"";return{c(){e=L("span")},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].verifying+"")&&(e.innerHTML=t)},d(i){i&&N(e)}}}function Lt(r){let e,t=r[9].verified+"",i,o;return{c(){e=L("span"),i=Y(),o=L("input"),c(o,"type","hidden"),c(o,"name",r[3]),o.value=r[4]},m(l,s){j(l,e,s),e.innerHTML=t,j(l,i,s),j(l,o,s)},p(l,s){s[0]&512&&t!==(t=l[9].verified+"")&&(e.innerHTML=t),s[0]&8&&c(o,"name",l[3]),s[0]&16&&(o.value=l[4])},d(l){l&&(N(e),N(i),N(o))}}}function Re(r){let e,t,i,o,l,s;return{c(){e=L("div"),t=L("a"),i=O("svg"),o=O("path"),l=O("path"),s=O("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",Ne),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-15co9zy")},m(f,a){j(f,e,a),v(e,t),v(t,i),v(i,o),v(i,l),v(i,s)},p:C,d(f){f&&N(e)}}}function Ie(r){let e,t,i,o;function l(a,h){return a[5]===g.EXPIRED?It:Rt}let s=l(r),f=s(r);return{c(){e=L("div"),t=O("svg"),i=O("path"),o=Y(),f.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-15co9zy")},m(a,h){j(a,e,h),v(e,t),v(t,i),v(e,o),f.m(e,null)},p(a,h){s===(s=l(a))&&f?f.p(a,h):(f.d(1),f=s(a),f&&(f.c(),f.m(e,null)))},d(a){a&&N(e),f.d()}}}function Rt(r){let e,t=r[9].error+"";return{c(){e=L("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].error+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function It(r){let e,t=r[9].expired+"";return{c(){e=L("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].expired+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function ze(r){let e,t,i=r[9].footer+"";return{c(){e=L("div"),t=L("div"),c(t,"class","svelte-15co9zy"),c(e,"class","altcha-footer svelte-15co9zy")},m(o,l){j(o,e,l),v(e,t),t.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(t.innerHTML=i)},d(o){o&&N(e)}}}function zt(r){let e,t,i,o,l,s,f,a,h,T,R,U,G,X,_=r[5]===g.VERIFYING&&Le();function W(d,z){return d[5]===g.VERIFIED?Lt:d[5]===g.VERIFYING?Ct:$t}let F=W(r),k=F(r),x=r[2]!==!0&&Re(),m=(r[8]||r[5]===g.EXPIRED)&&Ie(r),y=r[9].footer&&r[1]!==!0&&ze(r);return{c(){e=L("div"),t=L("div"),_&&_.c(),i=Y(),o=L("div"),l=L("input"),a=Y(),h=L("div"),k.c(),T=Y(),x&&x.c(),R=Y(),m&&m.c(),U=Y(),y&&y.c(),c(l,"type","checkbox"),c(l,"id",s=r[3]+"_checkbox"),l.required=f=r[0]!=="onsubmit",c(l,"class","svelte-15co9zy"),c(o,"class","altcha-checkbox svelte-15co9zy"),we(o,"altcha-hidden",r[5]===g.VERIFYING),c(h,"class","altcha-label svelte-15co9zy"),c(t,"class","altcha-main svelte-15co9zy"),c(e,"class","altcha svelte-15co9zy"),c(e,"data-state",r[5])},m(d,z){j(d,e,z),v(e,t),_&&_.m(t,null),v(t,i),v(t,o),v(o,l),l.checked=r[6],v(t,a),v(t,h),k.m(h,null),v(t,T),x&&x.m(t,null),v(e,R),m&&m.m(e,null),v(e,U),y&&y.m(e,null),r[30](e),G||(X=[ae(l,"change",r[29]),ae(l,"change",r[10]),ae(l,"invalid",r[11])],G=!0)},p(d,z){d[5]===g.VERIFYING?_||(_=Le(),_.c(),_.m(t,i)):_&&(_.d(1),_=null),z[0]&8&&s!==(s=d[3]+"_checkbox")&&c(l,"id",s),z[0]&1&&f!==(f=d[0]!=="onsubmit")&&(l.required=f),z[0]&64&&(l.checked=d[6]),z[0]&32&&we(o,"altcha-hidden",d[5]===g.VERIFYING),F===(F=W(d))&&k?k.p(d,z):(k.d(1),k=F(d),k&&(k.c(),k.m(h,null))),d[2]!==!0?x?x.p(d,z):(x=Re(),x.c(),x.m(t,null)):x&&(x.d(1),x=null),d[8]||d[5]===g.EXPIRED?m?m.p(d,z):(m=Ie(d),m.c(),m.m(e,U)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?y?y.p(d,z):(y=ze(d),y.c(),y.m(e,null)):y&&(y.d(1),y=null),z[0]&32&&c(e,"data-state",d[5])},i:C,o:C,d(d){d&&N(e),_&&_.d(),k.d(),x&&x.d(),m&&m.d(),y&&y.d(),r[30](null),G=!1,te(X)}}}const Ne="https://altcha.org/";function Se(r){return JSON.parse(r)}function Nt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function St(r,e,t){var Xe,Fe;let i,o,l,{auto:s=void 0}=e,{blockspam:f=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:h=void 0}=e,{debug:T=!1}=e,{expire:R=void 0}=e,{hidefooter:U=!1}=e,{hidelogo:G=!1}=e,{name:X="altcha"}=e,{maxnumber:_=1e6}=e,{mockerror:W=!1}=e,{refetchonexpire:F=!0}=e,{spamfilter:k=!1}=e,{strings:x=void 0}=e,{test:m=!1}=e,{verifyurl:y=void 0}=e,{workers:d=navigator.hardwareConcurrency||8}=e;const z=ot(),Ze=["SHA-256","SHA-384","SHA-512"],Ae=(Fe=(Xe=document.documentElement.lang)==null?void 0:Xe.split("-"))==null?void 0:Fe[0];let P=!1,oe,b=null,ge=null,B=null,D=g.UNVERIFIED,be;it(()=>{b&&(b.removeEventListener("submit",Me),b.removeEventListener("reset",Ve),b.removeEventListener("focusin",Te),b=null)}),nt(()=>{I("mounted","0.4.1"),I("workers",d),m&&I("using test mode"),R&&le(R),s!==void 0&&I("auto",s),b=oe.closest("form"),b&&(b.addEventListener("submit",Me),b.addEventListener("reset",Ve),s==="onfocus"&&b.addEventListener("focusin",Te)),s==="onload"&&K()});function I(...n){(T||n.some(u=>u instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Te(n){D===g.UNVERIFIED&&K()}function Me(n){b&&s==="onsubmit"&&D===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),K().then(()=>{b==null||b.requestSubmit()}))}function Ve(){se()}function Ue(n,u){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:u.number,salt:n.salt,signature:n.signature,test:m?!0:void 0,took:u.took}))}function Ge(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(!Ze.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ze.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 jt(){var n;if(W)throw I("mocking error"),new Error("Mocked error.");if(i)return I("using provided json data"),i;if(m)return I("generating test challenge",{test:m}),kt(typeof m!="boolean"?+m:void 0);{if(!a)throw new Error("Attribute challengeurl not set.");I("fetching challenge from",a);const u=await fetch(a,{headers:{"x-altcha-spam-filter":k?"1":"0"}});if(u.status!==200)throw new Error(`Server responded with ${u.status}.`);const w=u.headers.get("Expires"),S=u.headers.get("X-Altcha-Config"),Z=await u.json(),M=new URLSearchParams((n=Z.salt.split("?"))==null?void 0:n[1]),J=M.get("expires")||M.get("expire");if(J){const E=new Date(+J*1e3),$=isNaN(E.getTime())?0:E.getTime()-Date.now();$>0&&le($)}if(S)try{const E=JSON.parse(S);E&&typeof E=="object"&&(E.verifyurl&&(E.verifyurl=new URL(E.verifyurl,new URL(a)).toString()),Oe(E))}catch(E){I("unable to configure from X-Altcha-Config",E)}if(!R&&(w!=null&&w.length)){const E=Date.parse(w);if(E){const $=E-Date.now();$>0&&le($)}}return Z}}function De(){a&&F&&D===g.VERIFIED?K():se(g.EXPIRED,l.expired)}async function Zt(n){let u=null;if("Worker"in window){try{u=await At(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(w){I(w)}if((u==null?void 0:u.number)!==void 0)return{data:n,solution:u}}return{data:n,solution:await xt(n.challenge,n.salt,n.algorithm,n.maxnumber||_).promise}}async function At(n,u,w,S=typeof m=="number"?m:_,Z=Math.ceil(d)){const M=[];if(Z<1)throw new Error("Wrong number of workers configured.");if(Z>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let $=0;$<Z;$++)M.push(new wt);const J=Math.ceil(S/Z),E=await Promise.all(M.map(($,ce)=>{const He=ce*J;return new Promise(Xt=>{$.addEventListener("message",Pe=>{if(Pe.data)for(const Ye of M)Ye!==$&&Ye.postMessage({type:"abort"});Xt(Pe.data)}),$.postMessage({payload:{alg:w,challenge:n,max:He+J,salt:u,start:He},type:"work"})})}));for(const $ of M)$.terminate();return E.find($=>!!$)||null}function Tt(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(D)?k&&(b==null?void 0:b.reportValidity())===!1?t(6,P=!1):K():t(6,P=!0)}function Mt(){D===g.VERIFYING&&alert(l.waitAlert)}function le(n){I("expire",n),clearTimeout(be),n<1?De():be=setTimeout(De,n)}function Vt(n){var w;const u=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((w=u==null?void 0:u.value)==null?void 0:w.slice(u.value.indexOf("@")))||void 0}function Ut(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(w=>`input[name="${w}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((w,S)=>{const Z=S.name,M=S.value.trim();return Z&&M&&(w[Z]=M),w},{})}async function Gt(n){if(!y)throw new Error("Attribute verifyurl not set.");I("requesting server verification from",y);const u={payload:n};if(k){const{email:Z,expectedLanguages:M,expectedCountries:J,fields:E,ipAddress:$,timeZone:ce}=typeof k=="object"?k:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};u.ipAddress=$===!1?void 0:$||"auto",u.email=Z===!1?void 0:Vt(Z),u.fields=E===!1?void 0:Ut(E),u.timeZone=ce===!1?void 0:ce||Nt(),u.expectedCountries=J,u.expectedLanguages=M||(Ae?[Ae]:void 0)}const w=await fetch(y,{body:JSON.stringify(u),headers:{"content-type":"application/json"},method:"POST"});if(w.status!==200)throw new Error(`Server responded with ${w.status}.`);const S=await w.json();if(S!=null&&S.payload&&t(4,B=S.payload),z("serververification",S),f&&S.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Oe(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&K()),n.expire!==void 0&&(le(n.expire),t(14,R=n.expire)),n.challenge&&(Ge(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(12,a=n.challengeurl),n.debug!==void 0&&t(13,T=!!n.debug),n.hidefooter!==void 0&&t(1,U=!!n.hidefooter),n.hidelogo!==void 0&&t(2,G=!!n.hidelogo),n.maxnumber!==void 0&&t(15,_=+n.maxnumber),n.mockerror!==void 0&&t(16,W=!!n.mockerror),n.name!==void 0&&t(3,X=n.name),n.refetchonexpire!==void 0&&t(17,F=!!n.refetchonexpire),n.spamfilter!==void 0&&t(18,k=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(28,o=n.strings),n.test!==void 0&&t(19,m=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(20,y=n.verifyurl),n.workers!==void 0&&t(21,d=+n.workers)}function se(n=g.UNVERIFIED,u=null){clearTimeout(be),t(6,P=!1),t(8,ge=u),t(4,B=null),t(5,D=n)}async function K(){return se(g.VERIFYING),jt().then(n=>(Ge(n),I("challenge",n),Zt(n))).then(({data:n,solution:u})=>{if(I("solution",u),(u==null?void 0:u.number)!==void 0){if(y)return Gt(Ue(n,u));t(4,B=Ue(n,u)),I("payload",B)}else throw I("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{lt().then(()=>{t(5,D=g.VERIFIED),t(6,P=!0),I("verified"),z("verified",{payload:B})})}).catch(n=>{I(n),t(5,D=g.ERROR),t(6,P=!1),t(8,ge=n.message)})}function Dt(){P=this.checked,t(6,P)}function Ot(n){ue[n?"unshift":"push"](()=>{oe=n,t(7,oe)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(22,f=n.blockspam),"challengeurl"in n&&t(12,a=n.challengeurl),"challengejson"in n&&t(23,h=n.challengejson),"debug"in n&&t(13,T=n.debug),"expire"in n&&t(14,R=n.expire),"hidefooter"in n&&t(1,U=n.hidefooter),"hidelogo"in n&&t(2,G=n.hidelogo),"name"in n&&t(3,X=n.name),"maxnumber"in n&&t(15,_=n.maxnumber),"mockerror"in n&&t(16,W=n.mockerror),"refetchonexpire"in n&&t(17,F=n.refetchonexpire),"spamfilter"in n&&t(18,k=n.spamfilter),"strings"in n&&t(24,x=n.strings),"test"in n&&t(19,m=n.test),"verifyurl"in n&&t(20,y=n.verifyurl),"workers"in n&&t(21,d=n.workers)},r.$$.update=()=>{r.$$.dirty[0]&8388608&&(i=h?Se(h):void 0),r.$$.dirty[0]&16777216&&t(28,o=x?Se(x):{}),r.$$.dirty[0]&268435456&&t(9,l={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.",...o}),r.$$.dirty[0]&48&&z("statechange",{payload:B,state:D})},[s,U,G,X,B,D,P,oe,ge,l,Tt,Mt,a,T,R,_,W,F,k,m,y,d,f,h,x,Oe,se,K,o,Dt,Ot]}class je extends bt{constructor(e){super(),mt(this,e,St,zt,We,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,configure:25,reset:26,verify:27},Et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),p()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),p()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),p()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),p()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),p()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),p()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),p()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),p()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),p()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),p()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),p()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),p()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),p()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),p()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),p()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),p()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),p()}get configure(){return this.$$.ctx[25]}get reset(){return this.$$.ctx[26]}get verify(){return this.$$.ctx[27]}}customElements.define("altcha-widget",gt(je,{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)),A.Altcha=je,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
1
+ (function(Z,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(Z=typeof globalThis<"u"?globalThis:Z||self,C(Z.altcha={}))})(this,function(Z){"use strict";var Ft=Object.defineProperty;var Ht=(Z,C,P)=>C in Z?Ft(Z,C,{enumerable:!0,configurable:!0,writable:!0,value:P}):Z[C]=P;var V=(Z,C,P)=>(Ht(Z,typeof C!="symbol"?C+"":C,P),P);function C(){}function P(r){return r()}function ye(){return Object.create(null)}function re(r){r.forEach(P)}function ve(r){return typeof r=="function"}function We(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function Be(r){return Object.keys(r).length===0}function v(r,e){r.appendChild(e)}function Ke(r,e,t){const i=Je(r);if(!i.getElementById(e)){const o=L("style");o.id=e,o.textContent=t,Qe(i,o)}}function Je(r){if(!r)return document;const e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function Qe(r,e){return v(r.head||r,e),e.sheet}function j(r,e,t){r.insertBefore(e,t||null)}function N(r){r.parentNode&&r.parentNode.removeChild(r)}function L(r){return document.createElement(r)}function X(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function qe(r){return document.createTextNode(r)}function W(){return qe(" ")}function fe(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function c(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function et(r){return Array.from(r.childNodes)}function we(r,e,t){r.classList.toggle(e,!!t)}function tt(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function rt(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ne;function ie(r){ne=r}function ue(){if(!ne)throw new Error("Function called outside component initialization");return ne}function nt(r){ue().$$.on_mount.push(r)}function it(r){ue().$$.on_destroy.push(r)}function ot(){const r=ue();return(e,t,{cancelable:i=!1}={})=>{const o=r.$$.callbacks[e];if(o){const l=tt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(r,l)}),!l.defaultPrevented}return!0}}const q=[],he=[];let ee=[];const pe=[],_e=Promise.resolve();let de=!1;function ke(){de||(de=!0,_e.then(p))}function lt(){return ke(),_e}function me(r){ee.push(r)}const ge=new Set;let te=0;function p(){if(te!==0)return;const r=ne;do{try{for(;te<q.length;){const e=q[te];te++,ie(e),st(e.$$)}}catch(e){throw q.length=0,te=0,e}for(ie(null),q.length=0,te=0;he.length;)he.pop()();for(let e=0;e<ee.length;e+=1){const t=ee[e];ge.has(t)||(ge.add(t),t())}ee.length=0}while(q.length);for(;pe.length;)pe.pop()();de=!1,ge.clear(),ie(r)}function st(r){if(r.fragment!==null){r.update(),re(r.before_update);const e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(me)}}function ct(r){const e=[],t=[];ee.forEach(i=>r.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),ee=e}const at=new Set;function ft(r,e){r&&r.i&&(at.delete(r),r.i(e))}function ut(r,e,t){const{fragment:i,after_update:o}=r.$$;i&&i.m(e,t),me(()=>{const l=r.$$.on_mount.map(P).filter(ve);r.$$.on_destroy?r.$$.on_destroy.push(...l):re(l),r.$$.on_mount=[]}),o.forEach(me)}function ht(r,e){const t=r.$$;t.fragment!==null&&(ct(t.after_update),re(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function dt(r,e){r.$$.dirty[0]===-1&&(q.push(r),ke(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function mt(r,e,t,i,o,l,s=null,f=[-1]){const a=ne;ie(r);const h=r.$$={fragment:null,ctx:[],props:l,update:C,not_equal:o,bound:ye(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:ye(),dirty:f,skip_bound:!1,root:e.target||a.$$.root};s&&s(h.root);let A=!1;if(h.ctx=t?t(r,e.props||{},(R,U,...G)=>{const F=G.length?G[0]:U;return h.ctx&&o(h.ctx[R],h.ctx[R]=F)&&(!h.skip_bound&&h.bound[R]&&h.bound[R](F),A&&dt(r,R)),U}):[],h.update(),A=!0,re(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const R=et(e.target);h.fragment&&h.fragment.l(R),R.forEach(N)}else h.fragment&&h.fragment.c();e.intro&&ft(r.$$.fragment),ut(r,e.target,e.anchor),p()}ie(a)}let xe;typeof HTMLElement=="function"&&(xe=class extends HTMLElement{constructor(e,t,i){super();V(this,"$$ctor");V(this,"$$s");V(this,"$$c");V(this,"$$cn",!1);V(this,"$$d",{});V(this,"$$r",!1);V(this,"$$p_d",{});V(this,"$$l",{});V(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=L("slot"),l!=="default"&&c(s,"name",l)},m:function(h,A){j(h,s,A)},d:function(h){h&&N(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=rt(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]=oe(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=oe(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 f=this.$$c.$on(l,s);this.$$l_u.set(s,f)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=oe(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(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function oe(r,e,t,i){var l;const o=(l=t[r])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function gt(r,e,t,i,o,l){let s=class extends xe{constructor(){super(r,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(f=>(e[f].attribute||f).toLowerCase())}};return Object.keys(e).forEach(f=>{Object.defineProperty(s.prototype,f,{get(){return this.$$c&&f in this.$$c?this.$$c[f]:this.$$d[f]},set(a){var h;a=oe(f,a,e),this.$$d[f]=a,(h=this.$$c)==null||h.$set({[f]:a})}})}),i.forEach(f=>{Object.defineProperty(s.prototype,f,{get(){var a;return(a=this.$$c)==null?void 0:a[f]}})}),l&&(s=l(s)),r.element=s,s}class bt{constructor(){V(this,"$$");V(this,"$$set")}$destroy(){ht(this,1),this.$destroy=C}$on(e,t){if(!ve(t))return C;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&&!Be(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const yt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(yt);const Ee="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",vt=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),$e=typeof window<"u"&&window.Blob&&new Blob([vt(Ee)],{type:"text/javascript;charset=utf-8"});function wt(r){let e;try{if(e=$e&&(window.URL||window.webkitURL).createObjectURL($e),!e)throw"";const t=new Worker(e,{name:r==null?void 0:r.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Ee,{name:r==null?void 0:r.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const pt=new TextEncoder;function _t(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function kt(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const o=await Ce(i,r,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Ce(r,e,t){return _t(await crypto.subtle.digest(t.toUpperCase(),pt.encode(r+e)))}function xt(r,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let a=o;a<=i;a+=1){if(l.signal.aborted)return null;if(await Ce(e,a,t)===r)return{number:a,took:Date.now()-s}}return null})(),controller:l}}var g=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(g||{});function Et(r){Ke(r,"svelte-15co9zy",".altcha.svelte-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}")}function Le(r){let e,t,i;return{c(){e=X("svg"),t=X("path"),i=X("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-15co9zy"),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){j(o,e,l),v(e,t),v(e,i)},d(o){o&&N(e)}}}function $t(r){let e,t=r[9].label+"",i;return{c(){e=L("label"),c(e,"for",i=r[3]+"_checkbox"),c(e,"class","svelte-15co9zy")},m(o,l){j(o,e,l),e.innerHTML=t},p(o,l){l[0]&512&&t!==(t=o[9].label+"")&&(e.innerHTML=t),l[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&N(e)}}}function Ct(r){let e,t=r[9].verifying+"";return{c(){e=L("span")},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].verifying+"")&&(e.innerHTML=t)},d(i){i&&N(e)}}}function Lt(r){let e,t=r[9].verified+"",i,o;return{c(){e=L("span"),i=W(),o=L("input"),c(o,"type","hidden"),c(o,"name",r[3]),o.value=r[4]},m(l,s){j(l,e,s),e.innerHTML=t,j(l,i,s),j(l,o,s)},p(l,s){s[0]&512&&t!==(t=l[9].verified+"")&&(e.innerHTML=t),s[0]&8&&c(o,"name",l[3]),s[0]&16&&(o.value=l[4])},d(l){l&&(N(e),N(i),N(o))}}}function Re(r){let e,t,i,o,l,s;return{c(){e=L("div"),t=L("a"),i=X("svg"),o=X("path"),l=X("path"),s=X("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",Ne),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-15co9zy")},m(f,a){j(f,e,a),v(e,t),v(t,i),v(i,o),v(i,l),v(i,s)},p:C,d(f){f&&N(e)}}}function Ie(r){let e,t,i,o;function l(a,h){return a[5]===g.EXPIRED?It:Rt}let s=l(r),f=s(r);return{c(){e=L("div"),t=X("svg"),i=X("path"),o=W(),f.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-15co9zy")},m(a,h){j(a,e,h),v(e,t),v(t,i),v(e,o),f.m(e,null)},p(a,h){s===(s=l(a))&&f?f.p(a,h):(f.d(1),f=s(a),f&&(f.c(),f.m(e,null)))},d(a){a&&N(e),f.d()}}}function Rt(r){let e,t=r[9].error+"";return{c(){e=L("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].error+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function It(r){let e,t=r[9].expired+"";return{c(){e=L("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].expired+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function ze(r){let e,t,i=r[9].footer+"";return{c(){e=L("div"),t=L("div"),c(t,"class","svelte-15co9zy"),c(e,"class","altcha-footer svelte-15co9zy")},m(o,l){j(o,e,l),v(e,t),t.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(t.innerHTML=i)},d(o){o&&N(e)}}}function zt(r){let e,t,i,o,l,s,f,a,h,A,R,U,G,F,_=r[5]===g.VERIFYING&&Le();function B(d,z){return d[5]===g.VERIFIED?Lt:d[5]===g.VERIFYING?Ct:$t}let H=B(r),k=H(r),x=r[2]!==!0&&Re(),m=(r[8]||r[5]===g.EXPIRED)&&Ie(r),y=r[9].footer&&r[1]!==!0&&ze(r);return{c(){e=L("div"),t=L("div"),_&&_.c(),i=W(),o=L("div"),l=L("input"),a=W(),h=L("div"),k.c(),A=W(),x&&x.c(),R=W(),m&&m.c(),U=W(),y&&y.c(),c(l,"type","checkbox"),c(l,"id",s=r[3]+"_checkbox"),l.required=f=r[0]!=="onsubmit",c(l,"class","svelte-15co9zy"),c(o,"class","altcha-checkbox svelte-15co9zy"),we(o,"altcha-hidden",r[5]===g.VERIFYING),c(h,"class","altcha-label svelte-15co9zy"),c(t,"class","altcha-main svelte-15co9zy"),c(e,"class","altcha svelte-15co9zy"),c(e,"data-state",r[5])},m(d,z){j(d,e,z),v(e,t),_&&_.m(t,null),v(t,i),v(t,o),v(o,l),l.checked=r[6],v(t,a),v(t,h),k.m(h,null),v(t,A),x&&x.m(t,null),v(e,R),m&&m.m(e,null),v(e,U),y&&y.m(e,null),r[30](e),G||(F=[fe(l,"change",r[29]),fe(l,"change",r[10]),fe(l,"invalid",r[11])],G=!0)},p(d,z){d[5]===g.VERIFYING?_||(_=Le(),_.c(),_.m(t,i)):_&&(_.d(1),_=null),z[0]&8&&s!==(s=d[3]+"_checkbox")&&c(l,"id",s),z[0]&1&&f!==(f=d[0]!=="onsubmit")&&(l.required=f),z[0]&64&&(l.checked=d[6]),z[0]&32&&we(o,"altcha-hidden",d[5]===g.VERIFYING),H===(H=B(d))&&k?k.p(d,z):(k.d(1),k=H(d),k&&(k.c(),k.m(h,null))),d[2]!==!0?x?x.p(d,z):(x=Re(),x.c(),x.m(t,null)):x&&(x.d(1),x=null),d[8]||d[5]===g.EXPIRED?m?m.p(d,z):(m=Ie(d),m.c(),m.m(e,U)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?y?y.p(d,z):(y=ze(d),y.c(),y.m(e,null)):y&&(y.d(1),y=null),z[0]&32&&c(e,"data-state",d[5])},i:C,o:C,d(d){d&&N(e),_&&_.d(),k.d(),x&&x.d(),m&&m.d(),y&&y.d(),r[30](null),G=!1,re(F)}}}const Ne="https://altcha.org/";function Se(r){return JSON.parse(r)}function Nt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function St(r,e,t){var Xe,Fe;let i,o,l,{auto:s=void 0}=e,{blockspam:f=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:h=void 0}=e,{debug:A=!1}=e,{expire:R=void 0}=e,{hidefooter:U=!1}=e,{hidelogo:G=!1}=e,{name:F="altcha"}=e,{maxnumber:_=1e6}=e,{mockerror:B=!1}=e,{refetchonexpire:H=!0}=e,{spamfilter:k=!1}=e,{strings:x=void 0}=e,{test:m=!1}=e,{verifyurl:y=void 0}=e,{workers:d=Math.min(16,navigator.hardwareConcurrency||8)}=e;const z=ot(),Te=["SHA-256","SHA-384","SHA-512"],Ze=(Fe=(Xe=document.documentElement.lang)==null?void 0:Xe.split("-"))==null?void 0:Fe[0];let Y=!1,le,b=null,be=null,K=null,D=g.UNVERIFIED,O=null;it(()=>{b&&(b.removeEventListener("submit",Me),b.removeEventListener("reset",Ve),b.removeEventListener("focusin",Ae),b=null),O&&(clearTimeout(O),O=null)}),nt(()=>{I("mounted","0.4.3"),I("workers",d),m&&I("using test mode"),R&&se(R),s!==void 0&&I("auto",s),b=le.closest("form"),b&&(b.addEventListener("submit",Me),b.addEventListener("reset",Ve),s==="onfocus"&&b.addEventListener("focusin",Ae)),s==="onload"&&J()});function I(...n){(A||n.some(u=>u instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Ae(n){D===g.UNVERIFIED&&J()}function Me(n){b&&s==="onsubmit"&&D===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),J().then(()=>{b==null||b.requestSubmit()}))}function Ve(){ce()}function Ue(n,u){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:u.number,salt:n.salt,signature:n.signature,test:m?!0:void 0,took:u.took}))}function Ge(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(!Te.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Te.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 jt(){var n;if(B)throw I("mocking error"),new Error("Mocked error.");if(i)return I("using provided json data"),i;if(m)return I("generating test challenge",{test:m}),kt(typeof m!="boolean"?+m:void 0);{if(!a)throw new Error("Attribute challengeurl not set.");I("fetching challenge from",a);const u=await fetch(a,{headers:{"x-altcha-spam-filter":k?"1":"0"}});if(u.status!==200)throw new Error(`Server responded with ${u.status}.`);const w=u.headers.get("Expires"),S=u.headers.get("X-Altcha-Config"),T=await u.json(),M=new URLSearchParams((n=T.salt.split("?"))==null?void 0:n[1]),Q=M.get("expires")||M.get("expire");if(Q){const E=new Date(+Q*1e3),$=isNaN(E.getTime())?0:E.getTime()-Date.now();$>0&&se($)}if(S)try{const E=JSON.parse(S);E&&typeof E=="object"&&(E.verifyurl&&(E.verifyurl=new URL(E.verifyurl,new URL(a)).toString()),Oe(E))}catch(E){I("unable to configure from X-Altcha-Config",E)}if(!R&&(w!=null&&w.length)){const E=Date.parse(w);if(E){const $=E-Date.now();$>0&&se($)}}return T}}function De(){a&&H&&D===g.VERIFIED?J():ce(g.EXPIRED,l.expired)}async function Tt(n){let u=null;if("Worker"in window){try{u=await Zt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(w){I(w)}if((u==null?void 0:u.number)!==void 0)return{data:n,solution:u}}return{data:n,solution:await xt(n.challenge,n.salt,n.algorithm,n.maxnumber||_).promise}}async function Zt(n,u,w,S=typeof m=="number"?m:_,T=Math.ceil(d)){const M=[];if(T<1)throw new Error("Wrong number of workers configured.");if(T>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let $=0;$<T;$++)M.push(new wt);const Q=Math.ceil(S/T),E=await Promise.all(M.map(($,ae)=>{const He=ae*Q;return new Promise(Xt=>{$.addEventListener("message",Pe=>{if(Pe.data)for(const Ye of M)Ye!==$&&Ye.postMessage({type:"abort"});Xt(Pe.data)}),$.postMessage({payload:{alg:w,challenge:n,max:He+Q,salt:u,start:He},type:"work"})})}));for(const $ of M)$.terminate();return E.find($=>!!$)||null}function At(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(D)?k&&(b==null?void 0:b.reportValidity())===!1?t(6,Y=!1):J():t(6,Y=!0)}function Mt(){D===g.VERIFYING&&alert(l.waitAlert)}function se(n){I("expire",n),O&&(clearTimeout(O),O=null),n<1?De():O=setTimeout(De,n)}function Vt(n){var w;const u=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((w=u==null?void 0:u.value)==null?void 0:w.slice(u.value.indexOf("@")))||void 0}function Ut(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(w=>`input[name="${w}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((w,S)=>{const T=S.name,M=S.value.trim();return T&&M&&(w[T]=M),w},{})}async function Gt(n){if(!y)throw new Error("Attribute verifyurl not set.");I("requesting server verification from",y);const u={payload:n};if(k){const{email:T,expectedLanguages:M,expectedCountries:Q,fields:E,ipAddress:$,timeZone:ae}=typeof k=="object"?k:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};u.ipAddress=$===!1?void 0:$||"auto",u.email=T===!1?void 0:Vt(T),u.fields=E===!1?void 0:Ut(E),u.timeZone=ae===!1?void 0:ae||Nt(),u.expectedCountries=Q,u.expectedLanguages=M||(Ze?[Ze]:void 0)}const w=await fetch(y,{body:JSON.stringify(u),headers:{"content-type":"application/json"},method:"POST"});if(w.status!==200)throw new Error(`Server responded with ${w.status}.`);const S=await w.json();if(S!=null&&S.payload&&t(4,K=S.payload),z("serververification",S),f&&S.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Oe(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&J()),n.expire!==void 0&&(se(n.expire),t(14,R=n.expire)),n.challenge&&(Ge(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(12,a=n.challengeurl),n.debug!==void 0&&t(13,A=!!n.debug),n.hidefooter!==void 0&&t(1,U=!!n.hidefooter),n.hidelogo!==void 0&&t(2,G=!!n.hidelogo),n.maxnumber!==void 0&&t(15,_=+n.maxnumber),n.mockerror!==void 0&&t(16,B=!!n.mockerror),n.name!==void 0&&t(3,F=n.name),n.refetchonexpire!==void 0&&t(17,H=!!n.refetchonexpire),n.spamfilter!==void 0&&t(18,k=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(28,o=n.strings),n.test!==void 0&&t(19,m=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(20,y=n.verifyurl),n.workers!==void 0&&t(21,d=+n.workers)}function ce(n=g.UNVERIFIED,u=null){O&&(clearTimeout(O),O=null),t(6,Y=!1),t(8,be=u),t(4,K=null),t(5,D=n)}async function J(){return ce(g.VERIFYING),jt().then(n=>(Ge(n),I("challenge",n),Tt(n))).then(({data:n,solution:u})=>{if(I("solution",u),(u==null?void 0:u.number)!==void 0){if(y)return Gt(Ue(n,u));t(4,K=Ue(n,u)),I("payload",K)}else throw I("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{lt().then(()=>{t(5,D=g.VERIFIED),t(6,Y=!0),I("verified"),z("verified",{payload:K})})}).catch(n=>{I(n),t(5,D=g.ERROR),t(6,Y=!1),t(8,be=n.message)})}function Dt(){Y=this.checked,t(6,Y)}function Ot(n){he[n?"unshift":"push"](()=>{le=n,t(7,le)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(22,f=n.blockspam),"challengeurl"in n&&t(12,a=n.challengeurl),"challengejson"in n&&t(23,h=n.challengejson),"debug"in n&&t(13,A=n.debug),"expire"in n&&t(14,R=n.expire),"hidefooter"in n&&t(1,U=n.hidefooter),"hidelogo"in n&&t(2,G=n.hidelogo),"name"in n&&t(3,F=n.name),"maxnumber"in n&&t(15,_=n.maxnumber),"mockerror"in n&&t(16,B=n.mockerror),"refetchonexpire"in n&&t(17,H=n.refetchonexpire),"spamfilter"in n&&t(18,k=n.spamfilter),"strings"in n&&t(24,x=n.strings),"test"in n&&t(19,m=n.test),"verifyurl"in n&&t(20,y=n.verifyurl),"workers"in n&&t(21,d=n.workers)},r.$$.update=()=>{r.$$.dirty[0]&8388608&&(i=h?Se(h):void 0),r.$$.dirty[0]&16777216&&t(28,o=x?Se(x):{}),r.$$.dirty[0]&268435456&&t(9,l={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.",...o}),r.$$.dirty[0]&48&&z("statechange",{payload:K,state:D})},[s,U,G,F,K,D,Y,le,be,l,At,Mt,a,A,R,_,B,H,k,m,y,d,f,h,x,Oe,ce,J,o,Dt,Ot]}class je extends bt{constructor(e){super(),mt(this,e,St,zt,We,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,configure:25,reset:26,verify:27},Et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),p()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),p()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),p()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),p()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),p()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),p()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),p()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),p()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),p()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),p()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),p()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),p()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),p()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),p()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),p()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),p()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),p()}get configure(){return this.$$.ctx[25]}get reset(){return this.$$.ctx[26]}get verify(){return this.$$.ctx[27]}}customElements.define("altcha-widget",gt(je,{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)),Z.Altcha=je,Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "altcha",
3
3
  "description": "GDPR compliant, self-hosted CAPTCHA alternative.",
4
- "version": "0.4.1",
4
+ "version": "0.4.3",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Daniel Regeci"
@@ -51,7 +51,7 @@
51
51
  "prepare": "husky"
52
52
  },
53
53
  "devDependencies": {
54
- "@playwright/test": "^1.41.2",
54
+ "@playwright/test": "^1.44.1",
55
55
  "@sveltejs/vite-plugin-svelte": "^3.0.2",
56
56
  "@tsconfig/svelte": "^5.0.0",
57
57
  "@types/node": "^20.11.19",