altcha 0.7.0 → 0.9.0

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,2 +1,2 @@
1
- (function(g,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(g=typeof globalThis<"u"?globalThis:g||self,p(g.altcha={}))})(this,function(g){"use strict";var An=Object.defineProperty;var It=g=>{throw TypeError(g)};var zn=(g,p,j)=>p in g?An(g,p,{enumerable:!0,configurable:!0,writable:!0,value:j}):g[p]=j;var M=(g,p,j)=>zn(g,typeof p!="symbol"?p+"":p,j),At=(g,p,j)=>p.has(g)||It("Cannot "+j);var O=(g,p,j)=>(At(g,p,"read from private field"),j?j.call(g):p.get(g)),le=(g,p,j)=>p.has(g)?It("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(g):p.set(g,j),zt=(g,p,j,me)=>(At(g,p,"write to private field"),me?me.call(g,j):p.set(g,j),j);var de,he,we,ye,pe,_e;const p="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",j=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),me=typeof self<"u"&&self.Blob&&new Blob([j(p)],{type:"text/javascript;charset=utf-8"});function Tt(n){let e;try{if(e=me&&(self.URL||self.webkitURL).createObjectURL(me),!e)throw"";const t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+p,{name:n==null?void 0:n.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}function ae(){}function Oe(n){return n()}function Pe(){return Object.create(null)}function ge(n){n.forEach(Oe)}function Xe(n){return typeof n=="function"}function Ft(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function St(n){return Object.keys(n).length===0}function C(n,e){n.appendChild(e)}function Nt(n,e,t){const i=Mt(n);if(!i.getElementById(e)){const o=L("style");o.id=e,o.textContent=t,jt(i,o)}}function Mt(n){if(!n)return document;const e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function jt(n,e){return C(n.head||n,e),e.sheet}function D(n,e,t){n.insertBefore(e,t||null)}function S(n){n.parentNode&&n.parentNode.removeChild(n)}function L(n){return document.createElement(n)}function $(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function He(n){return document.createTextNode(n)}function q(){return He(" ")}function Dt(){return He("")}function Me(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function a(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Ut(n){return Array.from(n.childNodes)}function We(n,e,t){n.classList.toggle(e,!!t)}function Zt(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function Vt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let be;function ve(n){be=n}function je(){if(!be)throw new Error("Function called outside component initialization");return be}function Bt(n){je().$$.on_mount.push(n)}function Gt(n){je().$$.on_destroy.push(n)}function Ot(){const n=je();return(e,t,{cancelable:i=!1}={})=>{const o=n.$$.callbacks[e];if(o){const s=Zt(e,t,{cancelable:i});return o.slice().forEach(u=>{u.call(n,s)}),!s.defaultPrevented}return!0}}const ce=[],Ce=[];let fe=[];const Ye=[],Ke=Promise.resolve();let De=!1;function Je(){De||(De=!0,Ke.then(k))}function Pt(){return Je(),Ke}function Ue(n){fe.push(n)}const Ze=new Set;let ue=0;function k(){if(ue!==0)return;const n=be;do{try{for(;ue<ce.length;){const e=ce[ue];ue++,ve(e),Xt(e.$$)}}catch(e){throw ce.length=0,ue=0,e}for(ve(null),ce.length=0,ue=0;Ce.length;)Ce.pop()();for(let e=0;e<fe.length;e+=1){const t=fe[e];Ze.has(t)||(Ze.add(t),t())}fe.length=0}while(ce.length);for(;Ye.length;)Ye.pop()();De=!1,Ze.clear(),ve(n)}function Xt(n){if(n.fragment!==null){n.update(),ge(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Ue)}}function Ht(n){const e=[],t=[];fe.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),fe=e}const Wt=new Set;function Yt(n,e){n&&n.i&&(Wt.delete(n),n.i(e))}function Kt(n,e,t){const{fragment:i,after_update:o}=n.$$;i&&i.m(e,t),Ue(()=>{const s=n.$$.on_mount.map(Oe).filter(Xe);n.$$.on_destroy?n.$$.on_destroy.push(...s):ge(s),n.$$.on_mount=[]}),o.forEach(Ue)}function Jt(n,e){const t=n.$$;t.fragment!==null&&(Ht(t.after_update),ge(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function $t(n,e){n.$$.dirty[0]===-1&&(ce.push(n),Je(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function qt(n,e,t,i,o,s,u=null,c=[-1]){const l=be;ve(n);const f=n.$$={fragment:null,ctx:[],props:s,update:ae,not_equal:o,bound:Pe(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:Pe(),dirty:c,skip_bound:!1,root:e.target||l.$$.root};u&&u(f.root);let P=!1;if(f.ctx=t?t(n,e.props||{},(v,X,...H)=>{const W=H.length?H[0]:X;return f.ctx&&o(f.ctx[v],f.ctx[v]=W)&&(!f.skip_bound&&f.bound[v]&&f.bound[v](W),P&&$t(n,v)),X}):[],f.update(),P=!0,ge(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const v=Ut(e.target);f.fragment&&f.fragment.l(v),v.forEach(S)}else f.fragment&&f.fragment.c();e.intro&&Yt(n.$$.fragment),Kt(n,e.target,e.anchor),k()}ve(l)}let $e;typeof HTMLElement=="function"&&($e=class extends HTMLElement{constructor(e,t,i){super();M(this,"$$ctor");M(this,"$$s");M(this,"$$c");M(this,"$$cn",!1);M(this,"$$d",{});M(this,"$$r",!1);M(this,"$$p_d",{});M(this,"$$l",{});M(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(s){return()=>{let u;return{c:function(){u=L("slot"),s!=="default"&&a(u,"name",s)},m:function(f,P){D(f,u,P)},d:function(f){f&&S(u)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=Vt(this);for(const s of this.$$s)s in i&&(t[s]=[e(s)]);for(const s of this.attributes){const u=this.$$g_p(s.name);u in this.$$d||(this.$$d[u]=Le(u,s.value,this.$$p_d,"toProp"))}for(const s in this.$$p_d)!(s in this.$$d)&&this[s]!==void 0&&(this.$$d[s]=this[s],delete this[s]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const s in this.$$p_d)if(this.$$d[s]=this.$$c.$$.ctx[this.$$c.$$.props[s]],this.$$p_d[s].reflect){const u=Le(s,this.$$d[s],this.$$p_d,"toAttribute");u==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,u)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const s in this.$$l)for(const u of this.$$l[s]){const c=this.$$c.$on(s,u);this.$$l_u.set(u,c)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Le(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Le(n,e,t,i){var s;const o=(s=t[n])==null?void 0:s.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Qt(n,e,t,i,o,s){let u=class extends $e{constructor(){super(n,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(c=>(e[c].attribute||c).toLowerCase())}};return Object.keys(e).forEach(c=>{Object.defineProperty(u.prototype,c,{get(){return this.$$c&&c in this.$$c?this.$$c[c]:this.$$d[c]},set(l){var f;l=Le(c,l,e),this.$$d[c]=l,(f=this.$$c)==null||f.$set({[c]:l})}})}),i.forEach(c=>{Object.defineProperty(u.prototype,c,{get(){var l;return(l=this.$$c)==null?void 0:l[c]}})}),n.element=u,u}class en{constructor(){M(this,"$$");M(this,"$$set")}$destroy(){Jt(this,1),this.$destroy=ae}$on(e,t){if(!Xe(t))return ae;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!St(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const tn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(tn);const nn=new TextEncoder;function rn(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function on(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await qe(i,n,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function qe(n,e,t){return rn(await crypto.subtle.digest(t.toUpperCase(),nn.encode(n+e)))}function sn(n,e,t="SHA-256",i=1e6,o=0){const s=new AbortController,u=Date.now();return{promise:(async()=>{for(let l=o;l<=i;l+=1){if(s.signal.aborted)return null;if(await qe(e,l,t)===n)return{number:l,took:Date.now()-u}}return null})(),controller:s}}function Qe(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}class ln{constructor(e){M(this,"beaconUrl",null);M(this,"error",null);M(this,"loadTime",Date.now());M(this,"submitTime",null);M(this,"startTime",null);M(this,"viewTimeThresholdMs",1500);le(this,de,{});le(this,he,null);le(this,we,this.onFormChange.bind(this));le(this,ye,this.onFormFocus.bind(this));le(this,pe,this.onFormSubmit.bind(this));le(this,_e,this.onUnload.bind(this));this.elForm=e,window.addEventListener("unload",O(this,_e)),this.elForm.addEventListener("change",O(this,we)),this.elForm.addEventListener("focusin",O(this,ye)),this.elForm.addEventListener("submit",O(this,pe))}data(){const e=Object.entries(O(this,de));return{correction:e.length&&e.filter(([t,i])=>i>1).length/e.length||0,dropoff:!this.submitTime&&!this.error&&O(this,he)?O(this,he):null,error:this.error,mobile:this.isMobile(),start:this.startTime,submit:this.submitTime,tz:Qe()}}dataAsBase64(){try{return btoa(JSON.stringify(this.data()))}catch(e){console.error("failed to encode ALTCHA session data to base64",e)}return""}destroy(){window.removeEventListener("unload",O(this,_e)),this.elForm.removeEventListener("change",O(this,we)),this.elForm.removeEventListener("focusin",O(this,ye)),this.elForm.removeEventListener("submit",O(this,pe))}end(){this.submitTime||(this.submitTime=Date.now())}getFieldName(e,t=40){const i=e.getAttribute("data-group-label"),o=e.getAttribute("name")||e.getAttribute("aria-label");return((i?i+": ":"")+o).slice(0,t)}isMobile(){const e="userAgentData"in navigator&&navigator.userAgentData?navigator.userAgentData:{};return"mobile"in e?e.mobile===!0:/Mobi/i.test(window.navigator.userAgent)}isInput(e){return["INPUT","SELECT","TEXTAREA"].includes(e.tagName)}onFormFieldChange(e){const t=this.getFieldName(e);t&&this.trackFieldChange(t)}onFormChange(e){const t=e.target;t&&this.isInput(t)&&this.onFormFieldChange(t)}onFormFocus(e){const t=e.target;if(this.startTime||this.start(),t&&this.isInput(t)){const i=this.getFieldName(t);i&&zt(this,he,i)}}onFormSubmit(){this.end()}onUnload(){this.loadTime<=Date.now()-this.viewTimeThresholdMs&&!this.submitTime&&this.sendBeacon()}async sendBeacon(){if(this.beaconUrl&&"sendBeacon"in navigator)try{navigator.sendBeacon(new URL(this.beaconUrl,location.origin),JSON.stringify(this.data()))}catch{}}start(){this.startTime=Date.now()}trackError(e){this.error=e===null?null:String(e)}trackFieldChange(e){O(this,de)[e]=(O(this,de)[e]||0)+1}}de=new WeakMap,he=new WeakMap,we=new WeakMap,ye=new WeakMap,pe=new WeakMap,_e=new WeakMap;var b=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(b||{});function an(n){Nt(n,"svelte-ddsc3z",'.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}')}function et(n){let e,t,i;return{c(){e=$("svg"),t=$("path"),i=$("path"),a(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),a(t,"fill","currentColor"),a(t,"opacity",".25"),a(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),a(i,"fill","currentColor"),a(i,"class","altcha-spinner svelte-ddsc3z"),a(e,"width","24"),a(e,"height","24"),a(e,"viewBox","0 0 24 24"),a(e,"xmlns","http://www.w3.org/2000/svg")},m(o,s){D(o,e,s),C(e,t),C(e,i)},d(o){o&&S(e)}}}function cn(n){let e,t=n[13].label+"",i;return{c(){e=L("label"),a(e,"for",i=n[4]+"_checkbox"),a(e,"class","svelte-ddsc3z")},m(o,s){D(o,e,s),e.innerHTML=t},p(o,s){s[0]&8192&&t!==(t=o[13].label+"")&&(e.innerHTML=t),s[0]&16&&i!==(i=o[4]+"_checkbox")&&a(e,"for",i)},d(o){o&&S(e)}}}function fn(n){let e,t=n[13].verifying+"";return{c(){e=L("span")},m(i,o){D(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].verifying+"")&&(e.innerHTML=t)},d(i){i&&S(e)}}}function un(n){let e,t=n[13].verified+"",i,o,s,u,c=n[11]&&tt(n);return{c(){e=L("span"),i=q(),o=L("input"),s=q(),c&&c.c(),u=Dt(),a(o,"type","hidden"),a(o,"name",n[4]),o.value=n[6]},m(l,f){D(l,e,f),e.innerHTML=t,D(l,i,f),D(l,o,f),D(l,s,f),c&&c.m(l,f),D(l,u,f)},p(l,f){f[0]&8192&&t!==(t=l[13].verified+"")&&(e.innerHTML=t),f[0]&16&&a(o,"name",l[4]),f[0]&64&&(o.value=l[6]),l[11]?c?c.p(l,f):(c=tt(l),c.c(),c.m(u.parentNode,u)):c&&(c.d(1),c=null)},d(l){l&&(S(e),S(i),S(o),S(s),S(u)),c&&c.d(l)}}}function tt(n){let e;return{c(){e=L("input"),a(e,"type","hidden"),a(e,"name","__session"),e.value=n[12]},m(t,i){D(t,e,i)},p(t,i){i[0]&4096&&(e.value=t[12])},d(t){t&&S(e)}}}function nt(n){let e,t,i,o,s,u,c;return{c(){e=L("div"),t=L("a"),i=$("svg"),o=$("path"),s=$("path"),u=$("path"),a(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),a(o,"fill","currentColor"),a(s,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),a(s,"fill","currentColor"),a(u,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),a(u,"fill","currentColor"),a(i,"width","22"),a(i,"height","22"),a(i,"viewBox","0 0 20 20"),a(i,"fill","none"),a(i,"xmlns","http://www.w3.org/2000/svg"),a(t,"href",lt),a(t,"target","_blank"),a(t,"class","altcha-logo svelte-ddsc3z"),a(t,"aria-label",c=n[13].ariaLinkLabel)},m(l,f){D(l,e,f),C(e,t),C(t,i),C(i,o),C(i,s),C(i,u)},p(l,f){f[0]&8192&&c!==(c=l[13].ariaLinkLabel)&&a(t,"aria-label",c)},d(l){l&&S(e)}}}function rt(n){let e,t,i,o;function s(l,f){return l[7]===b.EXPIRED?hn:dn}let u=s(n),c=u(n);return{c(){e=L("div"),t=$("svg"),i=$("path"),o=q(),c.c(),a(i,"stroke-linecap","round"),a(i,"stroke-linejoin","round"),a(i,"d","M6 18L18 6M6 6l12 12"),a(t,"width","14"),a(t,"height","14"),a(t,"xmlns","http://www.w3.org/2000/svg"),a(t,"fill","none"),a(t,"viewBox","0 0 24 24"),a(t,"stroke-width","1.5"),a(t,"stroke","currentColor"),a(e,"class","altcha-error svelte-ddsc3z")},m(l,f){D(l,e,f),C(e,t),C(t,i),C(e,o),c.m(e,null)},p(l,f){u===(u=s(l))&&c?c.p(l,f):(c.d(1),c=u(l),c&&(c.c(),c.m(e,null)))},d(l){l&&S(e),c.d()}}}function dn(n){let e,t=n[13].error+"";return{c(){e=L("div"),a(e,"title",n[5])},m(i,o){D(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].error+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&S(e)}}}function hn(n){let e,t=n[13].expired+"";return{c(){e=L("div"),a(e,"title",n[5])},m(i,o){D(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].expired+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&S(e)}}}function it(n){let e,t,i=n[13].footer+"";return{c(){e=L("div"),t=L("div"),a(t,"class","svelte-ddsc3z"),a(e,"class","altcha-footer svelte-ddsc3z")},m(o,s){D(o,e,s),C(e,t),t.innerHTML=i},p(o,s){s[0]&8192&&i!==(i=o[13].footer+"")&&(t.innerHTML=i)},d(o){o&&S(e)}}}function ot(n){let e;return{c(){e=L("div"),a(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){D(t,e,i),n[41](e)},p:ae,d(t){t&&S(e),n[41](null)}}}function mn(n){let e,t,i,o,s,u,c,l,f,P,v,X,H,W,Q,w=n[7]===b.VERIFYING&&et();function te(h,E){return h[7]===b.VERIFIED?un:h[7]===b.VERIFYING?fn:cn}let ee=te(n),Z=ee(n),z=(n[3]!==!0||n[14])&&nt(n),N=(n[5]||n[7]===b.EXPIRED)&&rt(n),R=n[13].footer&&(n[2]!==!0||n[14])&&it(n),T=n[1]&&ot(n);return{c(){e=L("div"),t=L("div"),w&&w.c(),i=q(),o=L("div"),s=L("input"),l=q(),f=L("div"),Z.c(),P=q(),z&&z.c(),v=q(),N&&N.c(),X=q(),R&&R.c(),H=q(),T&&T.c(),a(s,"type","checkbox"),a(s,"id",u=n[4]+"_checkbox"),s.required=c=n[0]!=="onsubmit",a(s,"class","svelte-ddsc3z"),a(o,"class","altcha-checkbox svelte-ddsc3z"),We(o,"altcha-hidden",n[7]===b.VERIFYING),a(f,"class","altcha-label svelte-ddsc3z"),a(t,"class","altcha-main svelte-ddsc3z"),a(e,"class","altcha svelte-ddsc3z"),a(e,"data-state",n[7]),a(e,"data-floating",n[1])},m(h,E){D(h,e,E),C(e,t),w&&w.m(t,null),C(t,i),C(t,o),C(o,s),s.checked=n[8],C(t,l),C(t,f),Z.m(f,null),C(t,P),z&&z.m(t,null),C(e,v),N&&N.m(e,null),C(e,X),R&&R.m(e,null),C(e,H),T&&T.m(e,null),n[42](e),W||(Q=[Me(s,"change",n[40]),Me(s,"change",n[15]),Me(s,"invalid",n[16])],W=!0)},p(h,E){h[7]===b.VERIFYING?w||(w=et(),w.c(),w.m(t,i)):w&&(w.d(1),w=null),E[0]&16&&u!==(u=h[4]+"_checkbox")&&a(s,"id",u),E[0]&1&&c!==(c=h[0]!=="onsubmit")&&(s.required=c),E[0]&256&&(s.checked=h[8]),E[0]&128&&We(o,"altcha-hidden",h[7]===b.VERIFYING),ee===(ee=te(h))&&Z?Z.p(h,E):(Z.d(1),Z=ee(h),Z&&(Z.c(),Z.m(f,null))),h[3]!==!0||h[14]?z?z.p(h,E):(z=nt(h),z.c(),z.m(t,null)):z&&(z.d(1),z=null),h[5]||h[7]===b.EXPIRED?N?N.p(h,E):(N=rt(h),N.c(),N.m(e,X)):N&&(N.d(1),N=null),h[13].footer&&(h[2]!==!0||h[14])?R?R.p(h,E):(R=it(h),R.c(),R.m(e,H)):R&&(R.d(1),R=null),h[1]?T?T.p(h,E):(T=ot(h),T.c(),T.m(e,null)):T&&(T.d(1),T=null),E[0]&128&&a(e,"data-state",h[7]),E[0]&2&&a(e,"data-floating",h[1])},i:ae,o:ae,d(h){h&&S(e),w&&w.d(),Z.d(),z&&z.d(),N&&N.d(),R&&R.d(),T&&T.d(),n[42](null),W=!1,ge(Q)}}}const st="Visit Altcha.org",lt="https://altcha.org/";function at(n){return JSON.parse(n)}function gn(n,e,t){var Lt,Rt;let i,o,s,u,{analytics:c=!1}=e,{auto:l=void 0}=e,{beaconurl:f=void 0}=e,{blockspam:P=void 0}=e,{challengeurl:v=void 0}=e,{challengejson:X=void 0}=e,{debug:H=!1}=e,{delay:W=0}=e,{expire:Q=void 0}=e,{floating:w=void 0}=e,{floatinganchor:te=void 0}=e,{floatingoffset:ee=void 0}=e,{hidefooter:Z=!1}=e,{hidelogo:z=!1}=e,{name:N="altcha"}=e,{maxnumber:R=1e6}=e,{mockerror:T=!1}=e,{refetchonexpire:h=!0}=e,{spamfilter:E=!1}=e,{strings:Re=void 0}=e,{test:Y=!1}=e,{verifyurl:re=void 0}=e,{workers:ke=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:Ie=void 0}=e;const Ve=Ot(),ft=["SHA-256","SHA-384","SHA-512"],ut=(Rt=(Lt=document.documentElement.lang)==null?void 0:Lt.split("-"))==null?void 0:Rt[0];let ne=!1,I,ie=null,Ae=null,m=null,ze=null,K=null,oe=null,V=null,dt=null,B=b.UNVERIFIED;Gt(()=>{m&&(m.removeEventListener("submit",mt),m.removeEventListener("reset",gt),m.removeEventListener("focusin",ht),m=null),V&&V.destroy(),K&&(clearTimeout(K),K=null),document.removeEventListener("click",pt),document.removeEventListener("scroll",_t),window.removeEventListener("resize",Et)}),Bt(()=>{x("mounted","0.7.0"),x("workers",ke),Y&&x("using test mode"),Q&&Te(Q),l!==void 0&&x("auto",l),w!==void 0&&xt(w),m=I.closest("form"),m&&(m.addEventListener("submit",mt,{capture:!0}),m.addEventListener("reset",gt),l==="onfocus"&&m.addEventListener("focusin",ht)),c&&wt(),l==="onload"&&se(),i&&(Z||z)&&x("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.")});function x(...r){(H||r.some(d=>d instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",...r)}function ht(r){B===b.UNVERIFIED&&se()}function mt(r){m&&V&&B===b.VERIFIED&&(V.end(),t(12,dt=V.dataAsBase64())),m&&l==="onsubmit"&&(B===b.UNVERIFIED?(r.preventDefault(),r.stopPropagation(),se().then(()=>{m==null||m.requestSubmit()})):B!==b.VERIFIED&&(r.preventDefault(),r.stopPropagation(),B===b.VERIFYING&&kt()))}function gt(){Fe()}function bt(r,d){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:d.number,salt:r.salt,signature:r.signature,test:Y?!0:void 0,took:d.took}))}function vt(r){if(!r.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(r.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!ft.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${ft.join(", ")}`);if(!r.challenge||r.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!r.salt||r.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function bn(){var r;if(T)throw x("mocking error"),new Error("Mocked error.");if(o)return x("using provided json data"),o;if(Y)return x("generating test challenge",{test:Y}),on(typeof Y!="boolean"?+Y:void 0);{if(!v&&m){const _=m.getAttribute("action");_!=null&&_.includes("/form/")&&t(17,v=_+"/altcha")}if(!v)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",v);const d=await fetch(v,{headers:E?{"x-altcha-spam-filter":"1"}:{}});if(d.status!==200)throw new Error(`Server responded with ${d.status}.`);const y=d.headers.get("Expires"),F=d.headers.get("X-Altcha-Config"),G=await d.json(),U=new URLSearchParams((r=G.salt.split("?"))==null?void 0:r[1]),J=U.get("expires")||U.get("expire");if(J){const _=new Date(+J*1e3),A=isNaN(_.getTime())?0:_.getTime()-Date.now();A>0&&Te(A)}if(F)try{const _=JSON.parse(F);_&&typeof _=="object"&&(_.verifyurl&&(_.verifyurl=new URL(_.verifyurl,new URL(v)).toString()),Ct(_))}catch(_){x("unable to configure from X-Altcha-Config",_)}if(!Q&&(y!=null&&y.length)){const _=Date.parse(y);if(_){const A=_-Date.now();A>0&&Te(A)}}return G}}function wt(){if(!V)if(m){if(x("analytics enabled"),t(11,V=new ln(m)),f===void 0){const r=m.getAttribute("action");r&&t(19,f=r+"/beacon")}t(11,V.beaconUrl=f||null,V)}else x("analytics cannot be enabled - form element not found")}function yt(){v&&h&&B===b.VERIFIED?se():Fe(b.EXPIRED,u.expired)}async function vn(r){let d=null;if("Worker"in window){try{d=await wn(r.challenge,r.salt,r.algorithm,r.maxnumber)}catch(y){x(y)}if((d==null?void 0:d.number)!==void 0)return{data:r,solution:d}}return{data:r,solution:await sn(r.challenge,r.salt,r.algorithm,r.maxnumber||R).promise}}async function wn(r,d,y,F=typeof Y=="number"?Y:R,G=Math.ceil(ke)){const U=[];G=Math.min(16,Math.max(1,G));for(let A=0;A<G;A++)U.push(createAltchaWorker(Ie));const J=Math.ceil(F/G),_=await Promise.all(U.map((A,Ge)=>{const Ee=Ge*J;return new Promise(Se=>{A.addEventListener("message",Ne=>{if(Ne.data)for(const xe of U)xe!==A&&xe.postMessage({type:"abort"});Se(Ne.data)}),A.postMessage({payload:{alg:y,challenge:r,max:Ee+J,salt:d,start:Ee},type:"work"})})}));for(const A of U)A.terminate();return _.find(A=>!!A)||null}function yn(){[b.UNVERIFIED,b.ERROR,b.EXPIRED].includes(B)?E&&(m==null?void 0:m.reportValidity())===!1?t(8,ne=!1):se():t(8,ne=!0)}function pt(r){const d=r.target;w&&d&&!I.contains(d)&&B===b.VERIFIED&&t(9,I.style.display="none",I)}function _t(){w&&Be()}function kt(){B===b.VERIFYING&&u.waitAlert&&alert(u.waitAlert)}function pn(r){V&&V.trackError(ze)}function _n(r){w&&B!==b.UNVERIFIED&&requestAnimationFrame(()=>{Be()})}function Et(){w&&Be()}function Te(r){x("expire",r),K&&(clearTimeout(K),K=null),r<1?yt():K=setTimeout(yt,r)}function xt(r){x("floating",r),w!==r&&(t(9,I.style.left="",I),t(9,I.style.top="",I)),t(1,w=r===!0||r===""?"auto":r===!1||r==="false"?void 0:w),w?(l||t(0,l="onsubmit"),document.addEventListener("scroll",_t),document.addEventListener("click",pt),window.addEventListener("resize",Et)):l==="onsubmit"&&t(0,l=void 0)}function kn(r){var y;const d=m==null?void 0:m.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((y=d==null?void 0:d.value)==null?void 0:y.slice(d.value.indexOf("@")))||void 0}function En(r){return[...(m==null?void 0:m.querySelectorAll(r!=null&&r.length?r.map(y=>`input[name="${y}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((y,F)=>{const G=F.name,U=F.value;return G&&U&&(y[G]=/\n/.test(U)?U.replace(new RegExp("(?<!\\r)\\n","g"),`\r
2
- `):U),y},{})}async function xn(r){if(!re)throw new Error("Attribute verifyurl not set.");x("requesting server verification from",re);const d={payload:r};if(E){const{blockedCountries:G,classifier:U,disableRules:J,email:_,expectedLanguages:A,expectedCountries:Ge,fields:Ee,ipAddress:Se,text:Ne,timeZone:xe}=Cn();d.blockedCountries=G,d.classifier=U,d.disableRules=J,d.email=_===!1?void 0:kn(_),d.expectedCountries=Ge,d.expectedLanguages=A||(ut?[ut]:void 0),d.fields=Ee===!1?void 0:En(Ee),d.ipAddress=Se===!1?void 0:Se||"auto",d.text=Ne,d.timeZone=xe===!1?void 0:xe||Qe()}const y=await fetch(re,{body:JSON.stringify(d),headers:{"content-type":"application/json"},method:"POST"});if(y.status!==200)throw new Error(`Server responded with ${y.status}.`);const F=await y.json();if(F!=null&&F.payload&&t(6,oe=F.payload),Ve("serververification",F),P&&F.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Cn(){return E==="ipAddress"?{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:!1,expectedCountries:void 0,expectedLanguages:void 0,fields:!1,ipAddress:void 0,text:void 0,timeZone:void 0}:typeof E=="object"?E:{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,text:void 0,timeZone:void 0}}function Be(r=20){if(I)if(Ae||(Ae=(te?document.querySelector(te):m==null?void 0:m.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])'))||m),Ae){const d=parseInt(ee,10)||12,y=Ae.getBoundingClientRect(),F=I.getBoundingClientRect(),G=document.documentElement.clientHeight,U=document.documentElement.clientWidth,J=w==="auto"?y.bottom+F.height+d+r>G:w==="top",_=Math.max(r,Math.min(U-r-F.width,y.left+y.width/2-F.width/2));if(J?t(9,I.style.top=`${y.top-(F.height+d)}px`,I):t(9,I.style.top=`${y.bottom+d}px`,I),t(9,I.style.left=`${_}px`,I),I.setAttribute("data-floating",J?"top":"bottom"),ie){const A=ie.getBoundingClientRect();t(10,ie.style.left=y.left-_+y.width/2-A.width/2+"px",ie)}}else x("unable to find floating anchor element")}function Ct(r){r.analytics&&(t(18,c=r.analytics),wt()),r.auto!==void 0&&(t(0,l=r.auto),l==="onload"&&se()),r.beaconurl&&(t(19,f=r.beaconurl),V&&t(11,V.beaconUrl=f,V)),r.floatinganchor!==void 0&&t(23,te=r.floatinganchor),r.delay!==void 0&&t(21,W=r.delay),r.floatingoffset!==void 0&&t(24,ee=r.floatingoffset),r.floating!==void 0&&xt(r.floating),r.expire!==void 0&&(Te(r.expire),t(22,Q=r.expire)),r.challenge&&(vt(r.challenge),o=r.challenge),r.challengeurl!==void 0&&t(17,v=r.challengeurl),r.debug!==void 0&&t(20,H=!!r.debug),r.hidefooter!==void 0&&t(2,Z=!!r.hidefooter),r.hidelogo!==void 0&&t(3,z=!!r.hidelogo),r.maxnumber!==void 0&&t(25,R=+r.maxnumber),r.mockerror!==void 0&&t(26,T=!!r.mockerror),r.name!==void 0&&t(4,N=r.name),r.refetchonexpire!==void 0&&t(27,h=!!r.refetchonexpire),r.spamfilter!==void 0&&t(28,E=typeof r.spamfilter=="object"?r.spamfilter:!!r.spamfilter),r.strings&&t(39,s=r.strings),r.test!==void 0&&t(29,Y=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(30,re=r.verifyurl),r.workers!==void 0&&t(31,ke=+r.workers),r.workerurl!==void 0&&t(32,Ie=r.workerurl)}function Fe(r=b.UNVERIFIED,d=null){K&&(clearTimeout(K),K=null),t(8,ne=!1),t(5,ze=d),t(6,oe=null),t(7,B=r)}async function se(){return Fe(b.VERIFYING),await new Promise(r=>setTimeout(r,W||0)),bn().then(r=>(vt(r),x("challenge",r),vn(r))).then(({data:r,solution:d})=>{if(x("solution",d),(d==null?void 0:d.number)!==void 0){if(re)return xn(bt(r,d));t(6,oe=bt(r,d)),x("payload",oe)}else throw x("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{Pt().then(()=>{t(7,B=b.VERIFIED),t(8,ne=!0),x("verified"),Ve("verified",{payload:oe})})}).catch(r=>{x(r),t(7,B=b.ERROR),t(8,ne=!1),t(5,ze=r.message)})}function Ln(){ne=this.checked,t(8,ne)}function Rn(r){Ce[r?"unshift":"push"](()=>{ie=r,t(10,ie)})}function In(r){Ce[r?"unshift":"push"](()=>{I=r,t(9,I)})}return n.$$set=r=>{"analytics"in r&&t(18,c=r.analytics),"auto"in r&&t(0,l=r.auto),"beaconurl"in r&&t(19,f=r.beaconurl),"blockspam"in r&&t(33,P=r.blockspam),"challengeurl"in r&&t(17,v=r.challengeurl),"challengejson"in r&&t(34,X=r.challengejson),"debug"in r&&t(20,H=r.debug),"delay"in r&&t(21,W=r.delay),"expire"in r&&t(22,Q=r.expire),"floating"in r&&t(1,w=r.floating),"floatinganchor"in r&&t(23,te=r.floatinganchor),"floatingoffset"in r&&t(24,ee=r.floatingoffset),"hidefooter"in r&&t(2,Z=r.hidefooter),"hidelogo"in r&&t(3,z=r.hidelogo),"name"in r&&t(4,N=r.name),"maxnumber"in r&&t(25,R=r.maxnumber),"mockerror"in r&&t(26,T=r.mockerror),"refetchonexpire"in r&&t(27,h=r.refetchonexpire),"spamfilter"in r&&t(28,E=r.spamfilter),"strings"in r&&t(35,Re=r.strings),"test"in r&&t(29,Y=r.test),"verifyurl"in r&&t(30,re=r.verifyurl),"workers"in r&&t(31,ke=r.workers),"workerurl"in r&&t(32,Ie=r.workerurl)},n.$$.update=()=>{n.$$.dirty[0]&131072&&t(14,i=!!(v!=null&&v.includes(".altcha.org"))&&!!(v!=null&&v.includes("apiKey=ckey_"))),n.$$.dirty[1]&8&&(o=X?at(X):void 0),n.$$.dirty[1]&16&&t(39,s=Re?at(Re):{}),n.$$.dirty[1]&256&&t(13,u={ariaLinkLabel:st,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by <a href="${lt}" target="_blank" aria-label="${s.ariaLinkLabel||st}">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...s}),n.$$.dirty[0]&192&&Ve("statechange",{payload:oe,state:B}),n.$$.dirty[0]&32&&pn(),n.$$.dirty[0]&128&&_n()},[l,w,Z,z,N,ze,oe,B,ne,I,ie,V,dt,u,i,yn,kt,v,c,f,H,W,Q,te,ee,R,T,h,E,Y,re,ke,Ie,P,X,Re,Ct,Fe,se,s,Ln,Rn,In]}class ct extends en{constructor(e){super(),qt(this,e,gn,mn,Ft,{analytics:18,auto:0,beaconurl:19,blockspam:33,challengeurl:17,challengejson:34,debug:20,delay:21,expire:22,floating:1,floatinganchor:23,floatingoffset:24,hidefooter:2,hidelogo:3,name:4,maxnumber:25,mockerror:26,refetchonexpire:27,spamfilter:28,strings:35,test:29,verifyurl:30,workers:31,workerurl:32,configure:36,reset:37,verify:38},an,[-1,-1,-1])}get analytics(){return this.$$.ctx[18]}set analytics(e){this.$$set({analytics:e}),k()}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),k()}get beaconurl(){return this.$$.ctx[19]}set beaconurl(e){this.$$set({beaconurl:e}),k()}get blockspam(){return this.$$.ctx[33]}set blockspam(e){this.$$set({blockspam:e}),k()}get challengeurl(){return this.$$.ctx[17]}set challengeurl(e){this.$$set({challengeurl:e}),k()}get challengejson(){return this.$$.ctx[34]}set challengejson(e){this.$$set({challengejson:e}),k()}get debug(){return this.$$.ctx[20]}set debug(e){this.$$set({debug:e}),k()}get delay(){return this.$$.ctx[21]}set delay(e){this.$$set({delay:e}),k()}get expire(){return this.$$.ctx[22]}set expire(e){this.$$set({expire:e}),k()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),k()}get floatinganchor(){return this.$$.ctx[23]}set floatinganchor(e){this.$$set({floatinganchor:e}),k()}get floatingoffset(){return this.$$.ctx[24]}set floatingoffset(e){this.$$set({floatingoffset:e}),k()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),k()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),k()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),k()}get maxnumber(){return this.$$.ctx[25]}set maxnumber(e){this.$$set({maxnumber:e}),k()}get mockerror(){return this.$$.ctx[26]}set mockerror(e){this.$$set({mockerror:e}),k()}get refetchonexpire(){return this.$$.ctx[27]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),k()}get spamfilter(){return this.$$.ctx[28]}set spamfilter(e){this.$$set({spamfilter:e}),k()}get strings(){return this.$$.ctx[35]}set strings(e){this.$$set({strings:e}),k()}get test(){return this.$$.ctx[29]}set test(e){this.$$set({test:e}),k()}get verifyurl(){return this.$$.ctx[30]}set verifyurl(e){this.$$set({verifyurl:e}),k()}get workers(){return this.$$.ctx[31]}set workers(e){this.$$set({workers:e}),k()}get workerurl(){return this.$$.ctx[32]}set workerurl(e){this.$$set({workerurl:e}),k()}get configure(){return this.$$.ctx[36]}get reset(){return this.$$.ctx[37]}get verify(){return this.$$.ctx[38]}}customElements.define("altcha-widget",Qt(ct,{analytics:{type:"Boolean"},auto:{},beaconurl:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=n=>n?new Worker(new URL(n)):new Tt,g.Altcha=ct,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
1
+ (function(D,F){typeof exports=="object"&&typeof module<"u"?F(exports):typeof define=="function"&&define.amd?define(["exports"],F):(D=typeof globalThis<"u"?globalThis:D||self,F(D.altcha={}))})(this,function(D){"use strict";var Vn=Object.defineProperty;var Gn=(D,F,ce)=>F in D?Vn(D,F,{enumerable:!0,configurable:!0,writable:!0,value:ce}):D[F]=ce;var K=(D,F,ce)=>Gn(D,typeof F!="symbol"?F+"":F,ce);const F="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIHAoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiB3KGUsdCxyKXtyZXR1cm4gcChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChyLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGIoZSx0LHI9IlNIQS0yNTYiLG49MWU2LHM9MCl7Y29uc3Qgbz1uZXcgQWJvcnRDb250cm9sbGVyLGE9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgYz1zO2M8PW47Yys9MSl7aWYoby5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCB3KHQsYyxyKT09PWUpcmV0dXJue251bWJlcjpjLHRvb2s6RGF0ZS5ub3coKS1hfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjpvfX1mdW5jdGlvbiBoKGUpe2NvbnN0IHQ9YXRvYihlKSxyPW5ldyBVaW50OEFycmF5KHQubGVuZ3RoKTtmb3IobGV0IG49MDtuPHQubGVuZ3RoO24rKylyW25dPXQuY2hhckNvZGVBdChuKTtyZXR1cm4gcn1mdW5jdGlvbiBnKGUsdD0xMil7Y29uc3Qgcj1uZXcgVWludDhBcnJheSh0KTtmb3IobGV0IG49MDtuPHQ7bisrKXJbbl09ZSUyNTYsZT1NYXRoLmZsb29yKGUvMjU2KTtyZXR1cm4gcn1hc3luYyBmdW5jdGlvbiBtKGUsdD0iIixyPTFlNixuPTApe2NvbnN0IHM9IkFFUy1HQ00iLG89bmV3IEFib3J0Q29udHJvbGxlcixhPURhdGUubm93KCksbD1hc3luYygpPT57Zm9yKGxldCB1PW47dTw9cjt1Kz0xKXtpZihvLnNpZ25hbC5hYm9ydGVkfHwhY3x8IXkpcmV0dXJuIG51bGw7dHJ5e2NvbnN0IGQ9YXdhaXQgY3J5cHRvLnN1YnRsZS5kZWNyeXB0KHtuYW1lOnMsaXY6Zyh1KX0sYyx5KTtpZihkKXJldHVybntjbGVhclRleHQ6bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKGQpLHRvb2s6RGF0ZS5ub3coKS1hfX1jYXRjaHt9fXJldHVybiBudWxsfTtsZXQgYz1udWxsLHk9bnVsbDt0cnl7eT1oKGUpO2NvbnN0IHU9YXdhaXQgY3J5cHRvLnN1YnRsZS5kaWdlc3QoIlNIQS0yNTYiLGYuZW5jb2RlKHQpKTtjPWF3YWl0IGNyeXB0by5zdWJ0bGUuaW1wb3J0S2V5KCJyYXciLHUscywhMSxbImRlY3J5cHQiXSl9Y2F0Y2h7cmV0dXJue3Byb21pc2U6UHJvbWlzZS5yZWplY3QoKSxjb250cm9sbGVyOm99fXJldHVybntwcm9taXNlOmwoKSxjb250cm9sbGVyOm99fWxldCBpO29ubWVzc2FnZT1hc3luYyBlPT57Y29uc3R7dHlwZTp0LHBheWxvYWQ6cixzdGFydDpuLG1heDpzfT1lLmRhdGE7bGV0IG89bnVsbDtpZih0PT09ImFib3J0IilpPT1udWxsfHxpLmFib3J0KCksaT12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtpZigib2JmdXNjYXRlZCJpbiByKXtjb25zdHtrZXk6YSxvYmZ1c2NhdGVkOmx9PXJ8fHt9O289YXdhaXQgbShsLGEscyxuKX1lbHNle2NvbnN0e2FsZ29yaXRobTphLGNoYWxsZW5nZTpsLHNhbHQ6Y309cnx8e307bz1iKGwsYyxhLHMsbil9aT1vLmNvbnRyb2xsZXIsby5wcm9taXNlLnRoZW4oYT0+e3NlbGYucG9zdE1lc3NhZ2UoYSYmey4uLmEsd29ya2VyOiEwfSl9KX19fSkoKTsK",ce=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),Ge=typeof self<"u"&&self.Blob&&new Blob([ce(F)],{type:"text/javascript;charset=utf-8"});function It(n){let e;try{if(e=Ge&&(self.URL||self.webkitURL).createObjectURL(Ge),!e)throw"";const t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+F,{name:n==null?void 0:n.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}function Ee(){}function Lt(n,e){for(const t in e)n[t]=e[t];return n}function He(n){return n()}function Ye(){return Object.create(null)}function ge(n){n.forEach(He)}function Xe(n){return typeof n=="function"}function Nt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function zt(n){return Object.keys(n).length===0}function St(n,e,t,i){if(n){const o=Fe(n,e,t,i);return n[0](o)}}function Fe(n,e,t,i){return n[1]&&i?Lt(t.ctx.slice(),n[1](i(e))):t.ctx}function Tt(n,e,t,i){if(n[2]&&i){const o=n[2](i(t));if(e.dirty===void 0)return o;if(typeof o=="object"){const l=[],s=Math.max(e.dirty.length,o.length);for(let d=0;d<s;d+=1)l[d]=e.dirty[d]|o[d];return l}return e.dirty|o}return e.dirty}function At(n,e,t,i,o,l){if(o){const s=Fe(e,t,i,l);n.p(s,o)}}function Zt(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let i=0;i<t;i++)e[i]=-1;return e}return-1}function C(n,e){n.appendChild(e)}function Vt(n,e,t){const i=Gt(n);if(!i.getElementById(e)){const o=S("style");o.id=e,o.textContent=t,Ht(i,o)}}function Gt(n){if(!n)return document;const e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Ht(n,e){return C(n.head||n,e),e.sheet}function X(n,e,t){n.insertBefore(e,t||null)}function H(n){n.parentNode&&n.parentNode.removeChild(n)}function S(n){return document.createElement(n)}function Q(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function Yt(n){return document.createTextNode(n)}function $(){return Yt(" ")}function ze(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function a(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Xt(n){return Array.from(n.childNodes)}function je(n,e,t){n.classList.toggle(e,!!t)}function Ft(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function jt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let me;function be(n){me=n}function Se(){if(!me)throw new Error("Function called outside component initialization");return me}function Dt(n){Se().$$.on_mount.push(n)}function Pt(n){Se().$$.on_destroy.push(n)}function Wt(){const n=Se();return(e,t,{cancelable:i=!1}={})=>{const o=n.$$.callbacks[e];if(o){const l=Ft(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(n,l)}),!l.defaultPrevented}return!0}}const ae=[],Re=[];let fe=[];const De=[],Pe=Promise.resolve();let Te=!1;function We(){Te||(Te=!0,Pe.then(w))}function Mt(){return We(),Pe}function Ae(n){fe.push(n)}const Ze=new Set;let ue=0;function w(){if(ue!==0)return;const n=me;do{try{for(;ue<ae.length;){const e=ae[ue];ue++,be(e),Ut(e.$$)}}catch(e){throw ae.length=0,ue=0,e}for(be(null),ae.length=0,ue=0;Re.length;)Re.pop()();for(let e=0;e<fe.length;e+=1){const t=fe[e];Ze.has(t)||(Ze.add(t),t())}fe.length=0}while(ae.length);for(;De.length;)De.pop()();Te=!1,Ze.clear(),be(n)}function Ut(n){if(n.fragment!==null){n.update(),ge(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Ae)}}function Kt(n){const e=[],t=[];fe.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),fe=e}const Ce=new Set;let Bt;function Me(n,e){n&&n.i&&(Ce.delete(n),n.i(e))}function Ot(n,e,t,i){if(n&&n.o){if(Ce.has(n))return;Ce.add(n),Bt.c.push(()=>{Ce.delete(n)}),n.o(e)}}function Jt(n,e,t){const{fragment:i,after_update:o}=n.$$;i&&i.m(e,t),Ae(()=>{const l=n.$$.on_mount.map(He).filter(Xe);n.$$.on_destroy?n.$$.on_destroy.push(...l):ge(l),n.$$.on_mount=[]}),o.forEach(Ae)}function Qt(n,e){const t=n.$$;t.fragment!==null&&(Kt(t.after_update),ge(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function $t(n,e){n.$$.dirty[0]===-1&&(ae.push(n),We(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function qt(n,e,t,i,o,l,s=null,d=[-1]){const h=me;be(n);const f=n.$$={fragment:null,ctx:[],props:l,update:Ee,not_equal:o,bound:Ye(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(h?h.$$.context:[])),callbacks:Ye(),dirty:d,skip_bound:!1,root:e.target||h.$$.root};s&&s(f.root);let I=!1;if(f.ctx=t?t(n,e.props||{},(b,O,...P)=>{const W=P.length?P[0]:O;return f.ctx&&o(f.ctx[b],f.ctx[b]=W)&&(!f.skip_bound&&f.bound[b]&&f.bound[b](W),I&&$t(n,b)),O}):[],f.update(),I=!0,ge(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const b=Xt(e.target);f.fragment&&f.fragment.l(b),b.forEach(H)}else f.fragment&&f.fragment.c();e.intro&&Me(n.$$.fragment),Jt(n,e.target,e.anchor),w()}be(h)}let Ue;typeof HTMLElement=="function"&&(Ue=class extends HTMLElement{constructor(e,t,i){super();K(this,"$$ctor");K(this,"$$s");K(this,"$$c");K(this,"$$cn",!1);K(this,"$$d",{});K(this,"$$r",!1);K(this,"$$p_d",{});K(this,"$$l",{});K(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=S("slot"),l!=="default"&&a(s,"name",l)},m:function(f,I){X(f,s,I)},d:function(f){f&&H(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=jt(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 d=this.$$c.$on(l,s);this.$$l_u.set(s,d)}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&&(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(n,e,t,i){var l;const o=(l=t[n])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function en(n,e,t,i,o,l){let s=class extends Ue{constructor(){super(n,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(d=>(e[d].attribute||d).toLowerCase())}};return Object.keys(e).forEach(d=>{Object.defineProperty(s.prototype,d,{get(){return this.$$c&&d in this.$$c?this.$$c[d]:this.$$d[d]},set(h){var f;h=Ie(d,h,e),this.$$d[d]=h,(f=this.$$c)==null||f.$set({[d]:h})}})}),i.forEach(d=>{Object.defineProperty(s.prototype,d,{get(){var h;return(h=this.$$c)==null?void 0:h[d]}})}),n.element=s,s}class tn{constructor(){K(this,"$$");K(this,"$$set")}$destroy(){Qt(this,1),this.$destroy=Ee}$on(e,t){if(!Xe(t))return Ee;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&&!zt(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const nn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(nn);const Ke=new TextEncoder;function rn(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function on(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await Be(i,n,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Be(n,e,t){return rn(await crypto.subtle.digest(t.toUpperCase(),Ke.encode(n+e)))}function ln(n,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let h=o;h<=i;h+=1){if(l.signal.aborted)return null;if(await Be(e,h,t)===n)return{number:h,took:Date.now()-s}}return null})(),controller:l}}function sn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function cn(n){const e=atob(n),t=new Uint8Array(e.length);for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}function an(n,e=12){const t=new Uint8Array(e);for(let i=0;i<e;i++)t[i]=n%256,n=Math.floor(n/256);return t}async function fn(n,e="",t=1e6,i=0){const o="AES-GCM",l=new AbortController,s=Date.now(),d=async()=>{for(let I=i;I<=t;I+=1){if(l.signal.aborted||!h||!f)return null;try{const b=await crypto.subtle.decrypt({name:o,iv:an(I)},h,f);if(b)return{clearText:new TextDecoder().decode(b),took:Date.now()-s}}catch{}}return null};let h=null,f=null;try{f=cn(n);const I=await crypto.subtle.digest("SHA-256",Ke.encode(e));h=await crypto.subtle.importKey("raw",I,o,!1,["decrypt"])}catch{return{promise:Promise.reject(),controller:l}}return{promise:d(),controller:l}}var g=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(g||{});function un(n){Vt(n,"svelte-ddsc3z",'.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}')}function Oe(n){let e,t,i;return{c(){e=Q("svg"),t=Q("path"),i=Q("path"),a(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),a(t,"fill","currentColor"),a(t,"opacity",".25"),a(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),a(i,"fill","currentColor"),a(i,"class","altcha-spinner svelte-ddsc3z"),a(e,"width","24"),a(e,"height","24"),a(e,"viewBox","0 0 24 24"),a(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){X(o,e,l),C(e,t),C(e,i)},d(o){o&&H(e)}}}function dn(n){let e,t=n[11].label+"",i;return{c(){e=S("label"),a(e,"for",i=n[4]+"_checkbox"),a(e,"class","svelte-ddsc3z")},m(o,l){X(o,e,l),e.innerHTML=t},p(o,l){l[0]&2048&&t!==(t=o[11].label+"")&&(e.innerHTML=t),l[0]&16&&i!==(i=o[4]+"_checkbox")&&a(e,"for",i)},d(o){o&&H(e)}}}function hn(n){let e,t=n[11].verifying+"";return{c(){e=S("span")},m(i,o){X(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].verifying+"")&&(e.innerHTML=t)},d(i){i&&H(e)}}}function gn(n){let e,t=n[11].verified+"",i,o;return{c(){e=S("span"),i=$(),o=S("input"),a(o,"type","hidden"),a(o,"name",n[4]),o.value=n[6]},m(l,s){X(l,e,s),e.innerHTML=t,X(l,i,s),X(l,o,s)},p(l,s){s[0]&2048&&t!==(t=l[11].verified+"")&&(e.innerHTML=t),s[0]&16&&a(o,"name",l[4]),s[0]&64&&(o.value=l[6])},d(l){l&&(H(e),H(i),H(o))}}}function Je(n){let e,t,i,o,l,s,d;return{c(){e=S("div"),t=S("a"),i=Q("svg"),o=Q("path"),l=Q("path"),s=Q("path"),a(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),a(o,"fill","currentColor"),a(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"),a(l,"fill","currentColor"),a(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"),a(s,"fill","currentColor"),a(i,"width","22"),a(i,"height","22"),a(i,"viewBox","0 0 20 20"),a(i,"fill","none"),a(i,"xmlns","http://www.w3.org/2000/svg"),a(t,"href",tt),a(t,"target","_blank"),a(t,"class","altcha-logo svelte-ddsc3z"),a(t,"aria-label",d=n[11].ariaLinkLabel)},m(h,f){X(h,e,f),C(e,t),C(t,i),C(i,o),C(i,l),C(i,s)},p(h,f){f[0]&2048&&d!==(d=h[11].ariaLinkLabel)&&a(t,"aria-label",d)},d(h){h&&H(e)}}}function Qe(n){let e,t,i,o;function l(h,f){return h[7]===g.EXPIRED?bn:mn}let s=l(n),d=s(n);return{c(){e=S("div"),t=Q("svg"),i=Q("path"),o=$(),d.c(),a(i,"stroke-linecap","round"),a(i,"stroke-linejoin","round"),a(i,"d","M6 18L18 6M6 6l12 12"),a(t,"width","14"),a(t,"height","14"),a(t,"xmlns","http://www.w3.org/2000/svg"),a(t,"fill","none"),a(t,"viewBox","0 0 24 24"),a(t,"stroke-width","1.5"),a(t,"stroke","currentColor"),a(e,"class","altcha-error svelte-ddsc3z")},m(h,f){X(h,e,f),C(e,t),C(t,i),C(e,o),d.m(e,null)},p(h,f){s===(s=l(h))&&d?d.p(h,f):(d.d(1),d=s(h),d&&(d.c(),d.m(e,null)))},d(h){h&&H(e),d.d()}}}function mn(n){let e,t=n[11].error+"";return{c(){e=S("div"),a(e,"title",n[5])},m(i,o){X(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&H(e)}}}function bn(n){let e,t=n[11].expired+"";return{c(){e=S("div"),a(e,"title",n[5])},m(i,o){X(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&H(e)}}}function $e(n){let e,t,i=n[11].footer+"";return{c(){e=S("div"),t=S("div"),a(t,"class","svelte-ddsc3z"),a(e,"class","altcha-footer svelte-ddsc3z")},m(o,l){X(o,e,l),C(e,t),t.innerHTML=i},p(o,l){l[0]&2048&&i!==(i=o[11].footer+"")&&(t.innerHTML=i)},d(o){o&&H(e)}}}function qe(n){let e;return{c(){e=S("div"),a(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){X(t,e,i),n[48](e)},p:Ee,d(t){t&&H(e),n[48](null)}}}function yn(n){let e,t,i,o,l,s,d,h,f,I,b,O,P,W,T,N,q;const ee=n[46].default,G=St(ee,n,n[45],null);let A=n[7]===g.VERIFYING&&Oe();function te(u,y){return u[7]===g.VERIFIED?gn:u[7]===g.VERIFYING?hn:dn}let B=te(n),Y=B(n),x=(n[3]!==!0||n[12])&&Je(n),Z=(n[5]||n[7]===g.EXPIRED)&&Qe(n),z=n[11].footer&&(n[2]!==!0||n[12])&&$e(n),_=n[1]&&qe(n);return{c(){G&&G.c(),e=$(),t=S("div"),i=S("div"),A&&A.c(),o=$(),l=S("div"),s=S("input"),f=$(),I=S("div"),Y.c(),b=$(),x&&x.c(),O=$(),Z&&Z.c(),P=$(),z&&z.c(),W=$(),_&&_.c(),a(s,"type","checkbox"),a(s,"id",d=n[4]+"_checkbox"),s.required=h=n[0]!=="onsubmit"&&(!n[1]||n[0]!=="off"),a(s,"class","svelte-ddsc3z"),a(l,"class","altcha-checkbox svelte-ddsc3z"),je(l,"altcha-hidden",n[7]===g.VERIFYING),a(I,"class","altcha-label svelte-ddsc3z"),a(i,"class","altcha-main svelte-ddsc3z"),a(t,"class","altcha svelte-ddsc3z"),a(t,"data-state",n[7]),a(t,"data-floating",n[1])},m(u,y){G&&G.m(u,y),X(u,e,y),X(u,t,y),C(t,i),A&&A.m(i,null),C(i,o),C(i,l),C(l,s),s.checked=n[8],C(i,f),C(i,I),Y.m(I,null),C(i,b),x&&x.m(i,null),C(t,O),Z&&Z.m(t,null),C(t,P),z&&z.m(t,null),C(t,W),_&&_.m(t,null),n[49](t),T=!0,N||(q=[ze(s,"change",n[47]),ze(s,"change",n[13]),ze(s,"invalid",n[14])],N=!0)},p(u,y){G&&G.p&&(!T||y[1]&16384)&&At(G,ee,u,u[45],T?Tt(ee,u[45],y,null):Zt(u[45]),null),u[7]===g.VERIFYING?A||(A=Oe(),A.c(),A.m(i,o)):A&&(A.d(1),A=null),(!T||y[0]&16&&d!==(d=u[4]+"_checkbox"))&&a(s,"id",d),(!T||y[0]&3&&h!==(h=u[0]!=="onsubmit"&&(!u[1]||u[0]!=="off")))&&(s.required=h),y[0]&256&&(s.checked=u[8]),(!T||y[0]&128)&&je(l,"altcha-hidden",u[7]===g.VERIFYING),B===(B=te(u))&&Y?Y.p(u,y):(Y.d(1),Y=B(u),Y&&(Y.c(),Y.m(I,null))),u[3]!==!0||u[12]?x?x.p(u,y):(x=Je(u),x.c(),x.m(i,null)):x&&(x.d(1),x=null),u[5]||u[7]===g.EXPIRED?Z?Z.p(u,y):(Z=Qe(u),Z.c(),Z.m(t,P)):Z&&(Z.d(1),Z=null),u[11].footer&&(u[2]!==!0||u[12])?z?z.p(u,y):(z=$e(u),z.c(),z.m(t,W)):z&&(z.d(1),z=null),u[1]?_?_.p(u,y):(_=qe(u),_.c(),_.m(t,null)):_&&(_.d(1),_=null),(!T||y[0]&128)&&a(t,"data-state",u[7]),(!T||y[0]&2)&&a(t,"data-floating",u[1])},i(u){T||(Me(G,u),T=!0)},o(u){Ot(G,u),T=!1},d(u){u&&(H(e),H(t)),G&&G.d(u),A&&A.d(),Y.d(),x&&x.d(),Z&&Z.d(),z&&z.d(),_&&_.d(),n[49](null),N=!1,ge(q)}}}const et="Visit Altcha.org",tt="https://altcha.org/";function nt(n){return JSON.parse(n)}function vn(n,e,t){var Et,Rt;let i,o,l,s,{$$slots:d={},$$scope:h}=e,{auto:f=void 0}=e,{blockspam:I=void 0}=e,{challengeurl:b=void 0}=e,{challengejson:O=void 0}=e,{debug:P=!1}=e,{delay:W=0}=e,{expire:T=void 0}=e,{floating:N=void 0}=e,{floatinganchor:q=void 0}=e,{floatingoffset:ee=void 0}=e,{hidefooter:G=!1}=e,{hidelogo:A=!1}=e,{name:te="altcha"}=e,{maxnumber:B=1e6}=e,{mockerror:Y=!1}=e,{obfuscated:x=void 0}=e,{plugins:Z=void 0}=e,{refetchonexpire:z=!0}=e,{spamfilter:_=!1}=e,{strings:u=void 0}=e,{test:y=!1}=e,{verifyurl:ne=void 0}=e,{workers:de=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:ye=void 0}=e;const ve=Wt(),it=["SHA-256","SHA-384","SHA-512"],ot=(Rt=(Et=document.documentElement.lang)==null?void 0:Et.split("-"))==null?void 0:Rt[0];let oe=!1,E,le=null,he=null,v=null,pe=null,J=null,se=null,re=[],R=g.UNVERIFIED;Pt(()=>{pn(),v&&(v.removeEventListener("submit",ut),v.removeEventListener("reset",dt),v.removeEventListener("focusin",ft),v=null),J&&(clearTimeout(J),J=null),document.removeEventListener("click",ct),document.removeEventListener("scroll",at),window.removeEventListener("resize",gt)}),Dt(()=>{k("mounted","0.9.0"),k("workers",de),En(),k("plugins",re.length?re.map(r=>r.constructor.pluginName).join(", "):"none"),y&&k("using test mode"),T&&Ne(T),f!==void 0&&k("auto",f),N!==void 0&&mt(N),v=E.closest("form"),v&&(v.addEventListener("submit",ut,{capture:!0}),v.addEventListener("reset",dt),f==="onfocus"&&v.addEventListener("focusin",ft)),f==="onload"&&(x?we():ie()),i&&(G||A)&&k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."),requestAnimationFrame(()=>{ve("load")})});function lt(r,c){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:c.number,salt:r.salt,signature:r.signature,test:y?!0:void 0,took:c.took}))}function pn(){for(const r of re)r.destroy()}function st(){b&&z&&R===g.VERIFIED?ie():_e(g.EXPIRED,s.expired)}async function wn(){var r;if(Y)throw k("mocking error"),new Error("Mocked error.");if(o)return k("using provided json data"),o;if(y)return k("generating test challenge",{test:y}),on(typeof y!="boolean"?+y:void 0);{if(!b&&v){const p=v.getAttribute("action");p!=null&&p.includes("/form/")&&t(15,b=p+"/altcha")}if(!b)throw new Error("Attribute challengeurl not set.");k("fetching challenge from",b);const c=await fetch(b,{headers:_?{"x-altcha-spam-filter":"1"}:{}});if(c.status!==200)throw new Error(`Server responded with ${c.status}.`);const m=c.headers.get("Expires"),L=c.headers.get("X-Altcha-Config"),M=await c.json(),j=new URLSearchParams((r=M.salt.split("?"))==null?void 0:r[1]),V=j.get("expires")||j.get("expire");if(V){const p=new Date(+V*1e3),U=isNaN(p.getTime())?0:p.getTime()-Date.now();U>0&&Ne(U)}if(L)try{const p=JSON.parse(L);p&&typeof p=="object"&&(p.verifyurl&&(p.verifyurl=new URL(p.verifyurl,new URL(b)).toString()),vt(p))}catch(p){k("unable to configure from X-Altcha-Config",p)}if(!T&&(m!=null&&m.length)){const p=Date.parse(m);if(p){const U=p-Date.now();U>0&&Ne(U)}}return M}}function _n(r){var m;const c=v==null?void 0:v.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((m=c==null?void 0:c.value)==null?void 0:m.slice(c.value.indexOf("@")))||void 0}function kn(){return _==="ipAddress"?{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:!1,expectedCountries:void 0,expectedLanguages:void 0,fields:!1,ipAddress:void 0,text:void 0,timeZone:void 0}:typeof _=="object"?_:{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,text:void 0,timeZone:void 0}}function xn(r){return[...(v==null?void 0:v.querySelectorAll(r!=null&&r.length?r.map(m=>`input[name="${m}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((m,L)=>{const M=L.name,j=L.value;return M&&j&&(m[M]=/\n/.test(j)?j.replace(new RegExp("(?<!\\r)\\n","g"),`\r
2
+ `):j),m},{})}function En(){const r=Z!==void 0?Z.split(","):void 0;for(const c of globalThis.altchaPlugins)(!r||r.includes(c.pluginName))&&re.push(new c({el:E,clarify:we,dispatch:ve,getConfiguration:pt,getFloatingAnchor:wt,getState:_t,log:k,reset:_e,solve:yt,setState:xt,setFloatingAnchor:kt,verify:ie}))}function k(...r){(P||r.some(c=>c instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",`[name=${te}]`,...r)}function Rn(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(R)?_&&(v==null?void 0:v.reportValidity())===!1?t(8,oe=!1):x?we():ie():t(8,oe=!0)}function ct(r){const c=r.target;N&&c&&!E.contains(c)&&(R===g.VERIFIED||f==="off"&&R===g.UNVERIFIED)&&t(9,E.style.display="none",E)}function at(){N&&R!==g.UNVERIFIED&&Le()}function Cn(r){for(const c of re)typeof c.onErrorChange=="function"&&c.onErrorChange(pe)}function ft(r){R===g.UNVERIFIED&&ie()}function ut(r){v&&f==="onsubmit"?R===g.UNVERIFIED?(r.preventDefault(),r.stopPropagation(),ie().then(()=>{v==null||v.requestSubmit()})):R!==g.VERIFIED&&(r.preventDefault(),r.stopPropagation(),R===g.VERIFYING&&ht()):v&&N&&f==="off"&&R===g.UNVERIFIED&&(r.preventDefault(),r.stopPropagation(),t(9,E.style.display="block",E),Le())}function dt(){_e()}function ht(){R===g.VERIFYING&&s.waitAlert&&alert(s.waitAlert)}function In(r){for(const c of re)typeof c.onStateChange=="function"&&c.onStateChange(R);N&&R!==g.UNVERIFIED&&requestAnimationFrame(()=>{Le()}),t(8,oe=R===g.VERIFIED)}function gt(){N&&Le()}function Le(r=20){if(E)if(he||(he=(q?document.querySelector(q):v==null?void 0:v.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])'))||v),he){const c=parseInt(ee,10)||12,m=he.getBoundingClientRect(),L=E.getBoundingClientRect(),M=document.documentElement.clientHeight,j=document.documentElement.clientWidth,V=N==="auto"?m.bottom+L.height+c+r>M:N==="top",p=Math.max(r,Math.min(j-r-L.width,m.left+m.width/2-L.width/2));if(V?t(9,E.style.top=`${m.top-(L.height+c)}px`,E):t(9,E.style.top=`${m.bottom+c}px`,E),t(9,E.style.left=`${p}px`,E),E.setAttribute("data-floating",V?"top":"bottom"),le){const U=le.getBoundingClientRect();t(10,le.style.left=m.left-p+m.width/2-U.width/2+"px",le)}}else k("unable to find floating anchor element")}async function Ln(r){if(!ne)throw new Error("Attribute verifyurl not set.");k("requesting server verification from",ne);const c={payload:r};if(_){const{blockedCountries:M,classifier:j,disableRules:V,email:p,expectedLanguages:U,expectedCountries:Ve,fields:ke,ipAddress:xe,text:Zn,timeZone:Ct}=kn();c.blockedCountries=M,c.classifier=j,c.disableRules=V,c.email=p===!1?void 0:_n(p),c.expectedCountries=Ve,c.expectedLanguages=U||(ot?[ot]:void 0),c.fields=ke===!1?void 0:xn(ke),c.ipAddress=xe===!1?void 0:xe||"auto",c.text=Zn,c.timeZone=Ct===!1?void 0:Ct||sn()}const m=await fetch(ne,{body:JSON.stringify(c),headers:{"content-type":"application/json"},method:"POST"});if(m.status!==200)throw new Error(`Server responded with ${m.status}.`);const L=await m.json();if(L!=null&&L.payload&&t(6,se=L.payload),ve("serververification",L),I&&L.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Ne(r){k("expire",r),J&&(clearTimeout(J),J=null),r<1?st():J=setTimeout(st,r)}function mt(r){k("floating",r),N!==r&&(t(9,E.style.left="",E),t(9,E.style.top="",E)),t(1,N=r===!0||r===""?"auto":r===!1||r==="false"?void 0:N),N?(f||t(0,f="onsubmit"),document.addEventListener("scroll",at),document.addEventListener("click",ct),window.addEventListener("resize",gt)):f==="onsubmit"&&t(0,f=void 0)}function bt(r){if(!r.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(r.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!it.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${it.join(", ")}`);if(!r.challenge||r.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!r.salt||r.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function yt(r){let c=null;if("Worker"in window){try{c=await Nn(r,r.maxnumber)}catch(m){k(m)}if((c==null?void 0:c.number)!==void 0||"obfuscated"in r)return{data:r,solution:c}}if("obfuscated"in r){const m=await fn(r.obfuscated,r.key,r.maxnumber);return{data:r,solution:await m.promise}}return{data:r,solution:await ln(r.challenge,r.salt,r.algorithm,r.maxnumber||B).promise}}async function Nn(r,c=typeof y=="number"?y:B,m=Math.ceil(de)){const L=[];m=Math.min(16,Math.max(1,m));for(let V=0;V<m;V++)L.push(altchaCreateWorker(ye));const M=Math.ceil(c/m),j=await Promise.all(L.map((V,p)=>{const U=p*M;return new Promise(Ve=>{V.addEventListener("message",ke=>{if(ke.data)for(const xe of L)xe!==V&&xe.postMessage({type:"abort"});Ve(ke.data)}),V.postMessage({payload:r,max:U+M,start:U,type:"work"})})}));for(const V of L)V.terminate();return j.find(V=>!!V)||null}async function we(){if(!x){t(7,R=g.ERROR);return}const r=re.find(c=>c.constructor.pluginName==="obfuscation");if(!r||!("clarify"in r)){t(7,R=g.ERROR),k("Plugin `obfuscation` not found. Import `altcha/plugins/obfuscation` to load it.");return}if("clarify"in r&&typeof r.clarify=="function")return r.clarify()}function vt(r){r.obfuscated!==void 0&&t(24,x=r.obfuscated),r.auto!==void 0&&(t(0,f=r.auto),f==="onload"&&(x?we():ie())),r.blockspam!==void 0&&t(16,I=!!r.blockspam),r.floatinganchor!==void 0&&t(20,q=r.floatinganchor),r.delay!==void 0&&t(18,W=r.delay),r.floatingoffset!==void 0&&t(21,ee=r.floatingoffset),r.floating!==void 0&&mt(r.floating),r.expire!==void 0&&(Ne(r.expire),t(19,T=r.expire)),r.challenge&&(bt(r.challenge),o=r.challenge),r.challengeurl!==void 0&&t(15,b=r.challengeurl),r.debug!==void 0&&t(17,P=!!r.debug),r.hidefooter!==void 0&&t(2,G=!!r.hidefooter),r.hidelogo!==void 0&&t(3,A=!!r.hidelogo),r.maxnumber!==void 0&&t(22,B=+r.maxnumber),r.mockerror!==void 0&&t(23,Y=!!r.mockerror),r.name!==void 0&&t(4,te=r.name),r.refetchonexpire!==void 0&&t(25,z=!!r.refetchonexpire),r.spamfilter!==void 0&&t(26,_=typeof r.spamfilter=="object"?r.spamfilter:!!r.spamfilter),r.strings&&t(44,l=r.strings),r.test!==void 0&&t(27,y=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(28,ne=r.verifyurl),r.workers!==void 0&&t(29,de=+r.workers),r.workerurl!==void 0&&t(30,ye=r.workerurl)}function pt(){return{auto:f,blockspam:I,challengeurl:b,debug:P,delay:W,expire:T,floating:N,floatinganchor:q,floatingoffset:ee,hidefooter:G,hidelogo:A,name:te,maxnumber:B,mockerror:Y,obfuscated:x,refetchonexpire:z,spamfilter:_,strings:s,test:y,verifyurl:ne,workers:de,workerurl:ye}}function wt(){return he}function zn(r){return re.find(c=>c.constructor.pluginName===r)}function _t(){return R}function _e(r=g.UNVERIFIED,c=null){J&&(clearTimeout(J),J=null),t(8,oe=!1),t(5,pe=c),t(6,se=null),t(7,R=r)}function kt(r){he=r}function xt(r,c=null){t(7,R=r),t(5,pe=c)}async function ie(){return _e(g.VERIFYING),await new Promise(r=>setTimeout(r,W||0)),wn().then(r=>(bt(r),k("challenge",r),yt(r))).then(({data:r,solution:c})=>{if(k("solution",c),"challenge"in r&&c&&!("clearText"in c))if((c==null?void 0:c.number)!==void 0){if(ne)return Ln(lt(r,c));t(6,se=lt(r,c)),k("payload",se)}else throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{Mt().then(()=>{t(7,R=g.VERIFIED),k("verified"),ve("verified",{payload:se})})}).catch(r=>{k(r),t(7,R=g.ERROR),t(5,pe=r.message)})}function Sn(){oe=this.checked,t(8,oe)}function Tn(r){Re[r?"unshift":"push"](()=>{le=r,t(10,le)})}function An(r){Re[r?"unshift":"push"](()=>{E=r,t(9,E)})}return n.$$set=r=>{"auto"in r&&t(0,f=r.auto),"blockspam"in r&&t(16,I=r.blockspam),"challengeurl"in r&&t(15,b=r.challengeurl),"challengejson"in r&&t(31,O=r.challengejson),"debug"in r&&t(17,P=r.debug),"delay"in r&&t(18,W=r.delay),"expire"in r&&t(19,T=r.expire),"floating"in r&&t(1,N=r.floating),"floatinganchor"in r&&t(20,q=r.floatinganchor),"floatingoffset"in r&&t(21,ee=r.floatingoffset),"hidefooter"in r&&t(2,G=r.hidefooter),"hidelogo"in r&&t(3,A=r.hidelogo),"name"in r&&t(4,te=r.name),"maxnumber"in r&&t(22,B=r.maxnumber),"mockerror"in r&&t(23,Y=r.mockerror),"obfuscated"in r&&t(24,x=r.obfuscated),"plugins"in r&&t(32,Z=r.plugins),"refetchonexpire"in r&&t(25,z=r.refetchonexpire),"spamfilter"in r&&t(26,_=r.spamfilter),"strings"in r&&t(33,u=r.strings),"test"in r&&t(27,y=r.test),"verifyurl"in r&&t(28,ne=r.verifyurl),"workers"in r&&t(29,de=r.workers),"workerurl"in r&&t(30,ye=r.workerurl),"$$scope"in r&&t(45,h=r.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&32768&&t(12,i=!!(b!=null&&b.includes(".altcha.org"))&&!!(b!=null&&b.includes("apiKey=ckey_"))),n.$$.dirty[1]&1&&(o=O?nt(O):void 0),n.$$.dirty[1]&4&&t(44,l=u?nt(u):{}),n.$$.dirty[1]&8192&&t(11,s={ariaLinkLabel:et,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by <a href="${tt}" target="_blank" aria-label="${l.ariaLinkLabel||et}">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),n.$$.dirty[0]&192&&ve("statechange",{payload:se,state:R}),n.$$.dirty[0]&32&&Cn(),n.$$.dirty[0]&128&&In()},[f,N,G,A,te,pe,se,R,oe,E,le,s,i,Rn,ht,b,I,P,W,T,q,ee,B,Y,x,z,_,y,ne,de,ye,O,Z,u,we,vt,pt,wt,zn,_t,_e,kt,xt,ie,l,h,d,Sn,Tn,An]}class rt extends tn{constructor(e){super(),qt(this,e,vn,yn,Nt,{auto:0,blockspam:16,challengeurl:15,challengejson:31,debug:17,delay:18,expire:19,floating:1,floatinganchor:20,floatingoffset:21,hidefooter:2,hidelogo:3,name:4,maxnumber:22,mockerror:23,obfuscated:24,plugins:32,refetchonexpire:25,spamfilter:26,strings:33,test:27,verifyurl:28,workers:29,workerurl:30,clarify:34,configure:35,getConfiguration:36,getFloatingAnchor:37,getPlugin:38,getState:39,reset:40,setFloatingAnchor:41,setState:42,verify:43},un,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[16]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[15]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[31]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[17]}set debug(e){this.$$set({debug:e}),w()}get delay(){return this.$$.ctx[18]}set delay(e){this.$$set({delay:e}),w()}get expire(){return this.$$.ctx[19]}set expire(e){this.$$set({expire:e}),w()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),w()}get floatinganchor(){return this.$$.ctx[20]}set floatinganchor(e){this.$$set({floatinganchor:e}),w()}get floatingoffset(){return this.$$.ctx[21]}set floatingoffset(e){this.$$set({floatingoffset:e}),w()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),w()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),w()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),w()}get maxnumber(){return this.$$.ctx[22]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[23]}set mockerror(e){this.$$set({mockerror:e}),w()}get obfuscated(){return this.$$.ctx[24]}set obfuscated(e){this.$$set({obfuscated:e}),w()}get plugins(){return this.$$.ctx[32]}set plugins(e){this.$$set({plugins:e}),w()}get refetchonexpire(){return this.$$.ctx[25]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[26]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[33]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[27]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[28]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[29]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[30]}set workerurl(e){this.$$set({workerurl:e}),w()}get clarify(){return this.$$.ctx[34]}get configure(){return this.$$.ctx[35]}get getConfiguration(){return this.$$.ctx[36]}get getFloatingAnchor(){return this.$$.ctx[37]}get getPlugin(){return this.$$.ctx[38]}get getState(){return this.$$.ctx[39]}get reset(){return this.$$.ctx[40]}get setFloatingAnchor(){return this.$$.ctx[41]}get setState(){return this.$$.ctx[42]}get verify(){return this.$$.ctx[43]}}customElements.define("altcha-widget",en(rt,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},obfuscated:{},plugins:{},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},["default"],["clarify","configure","getConfiguration","getFloatingAnchor","getPlugin","getState","reset","setFloatingAnchor","setState","verify"],!1)),globalThis.altchaCreateWorker=n=>n?new Worker(new URL(n)):new It,globalThis.altchaPlugins=globalThis.altchaPlugins||[],D.Altcha=rt,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
@@ -3,6 +3,9 @@ export {};
3
3
  declare module 'altcha';
4
4
 
5
5
  declare global {
6
+ var altchaCreateWorker: (url?: string) => Worker;
7
+ var altchaPlugins: any[];
8
+
6
9
  type AltchaState = 'error' | 'expired' | 'verified' | 'verifying' | 'unverified';
7
10
 
8
11
  interface AltchaStateChangeEvent extends CustomEvent<{
@@ -16,10 +19,8 @@ declare global {
16
19
 
17
20
  interface AltchaServerVerificationEvent extends CustomEvent<Record<string, unknown>> {}
18
21
 
19
- interface AltchaWidget {
20
- analytics?: boolean | string;
21
- auto?: 'onfocus' | 'onload' | 'onsubmit';
22
- beaconurl?: string;
22
+ interface AltchaWidgetOptions {
23
+ auto?: 'off' | 'onfocus' | 'onload' | 'onsubmit';
23
24
  blockspam?: boolean;
24
25
  challengeurl?: string;
25
26
  challengejson?: string;
@@ -31,9 +32,10 @@ declare global {
31
32
  floatingoffset?: number;
32
33
  hidefooter?: boolean;
33
34
  hidelogo?: boolean;
34
- name?: string;
35
35
  maxnumber?: number;
36
36
  mockerror?: boolean;
37
+ name?: string;
38
+ obfuscated?: string;
37
39
  refetchonexpire?: boolean;
38
40
  spamfilter?: boolean | 'ipAddress';
39
41
  strings?: string;
@@ -43,6 +45,22 @@ declare global {
43
45
  workerurl?: string;
44
46
  }
45
47
 
48
+ interface AltchaWidgetMethods {
49
+ configure: (options: AltchaWidgetOptions) => void;
50
+ clarify: () => Promise<void>;
51
+ getConfiguration: () => AltchaWidgetOptions;
52
+ getFloatingAnchor: () => HTMLElement | null;
53
+ getPlugin: <T = unknown>(name: string) => T;
54
+ getState: () => AltchaState;
55
+ reset: (newState: AltchaState = 'unverified', err: string | null = null) => void;
56
+ setFloatingAnchor: (el: HTMLElement) => void;
57
+ setState: (newState: AltchaState, err: string | null = null) => void;
58
+ verify: () => Promise<void>;
59
+ }
60
+
61
+ interface AltchaWidget extends AltchaWidgetOptions extends AltchaWidgetMethods {
62
+ }
63
+
46
64
  declare namespace svelteHTML {
47
65
  interface IntrinsicElements {
48
66
  'altcha-widget': AltchaWidgetSvelte;
@@ -74,6 +92,7 @@ declare global {
74
92
  }
75
93
 
76
94
  interface AltchaWidgetReact extends AltchaWidget extends React.HTMLAttributes<HTMLElement> {
95
+ children?: React.ReactNode;
77
96
  ref?: React.RefObject<HTMLElement>;
78
97
  style?: AltchaWidgetCSSProperties;
79
98
  }