/** * Minified by jsDelivr using Terser v5.19.2. * Original file: /gh/altcha-org/altcha@main/dist/altcha.js * * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files */ var je=Object.defineProperty,Ge=(e,t,n)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t,n)=>(Ge(e,"symbol"!=typeof t?t+"":t,n),n);function Z(){}function de(e){return e()}function ie(){return Object.create(null)}function H(e){e.forEach(de)}function ge(e){return"function"==typeof e}function Ae(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}function Se(e){return 0===Object.keys(e).length}function m(e,t){e.appendChild(t)}function Ve(e,t,n){const r=Me(e);if(!r.getElementById(t)){const e=v("style");e.id=t,e.textContent=n,Ue(r,e)}}function Me(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t&&t.host?t:e.ownerDocument}function Ue(e,t){return m(e.head||e,t),t.sheet}function q(e,t,n){e.insertBefore(t,n||null)}function I(e){e.parentNode&&e.parentNode.removeChild(e)}function v(e){return document.createElement(e)}function G(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function Fe(e){return document.createTextNode(e)}function M(){return Fe(" ")}function D(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function c(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ye(e){return Array.from(e.childNodes)}function le(e,t,n){e.classList.toggle(t,!!n)}function Ze(e,t,{bubbles:n=!1,cancelable:r=!1}={}){return new CustomEvent(e,{detail:t,bubbles:n,cancelable:r})}function Oe(e){const t={};return e.childNodes.forEach((e=>{t[e.slot||"default"]=!0})),t}let B;function O(e){B=e}function ee(){if(!B)throw new Error("Function called outside component initialization");return B}function Be(e){ee().$$.on_mount.push(e)}function He(e){ee().$$.on_destroy.push(e)}function We(){const e=ee();return(t,n,{cancelable:r=!1}={})=>{const o=e.$$.callbacks[t];if(o){const c=Ze(t,n,{cancelable:r});return o.slice().forEach((t=>{t.call(e,c)})),!c.defaultPrevented}return!0}}const F=[],z=[];let Y=[];const oe=[],me=Promise.resolve();let J=!1;function we(){J||(J=!0,me.then(C))}function Pe(){return we(),me}function Q(e){Y.push(e)}const K=new Set;let U=0;function C(){if(0!==U)return;const e=B;do{try{for(;U-1===e.indexOf(r)?t.push(r):n.push(r))),n.forEach((e=>e())),Y=t}const De=new Set;function Ke(e,t){e&&e.i&&(De.delete(e),e.i(t))}function ze(e,t,n){const{fragment:r,after_update:o}=e.$$;r&&r.m(t,n),Q((()=>{const t=e.$$.on_mount.map(de).filter(ge);e.$$.on_destroy?e.$$.on_destroy.push(...t):H(t),e.$$.on_mount=[]})),o.forEach(Q)}function Je(e,t){const n=e.$$;null!==n.fragment&&(Xe(n.after_update),H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Qe(e,t){-1===e.$$.dirty[0]&&(F.push(e),we(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const c=r.length?r[0]:n;return a.ctx&&o(a.ctx[t],a.ctx[t]=c)&&(!a.skip_bound&&a.bound[t]&&a.bound[t](c),u&&Qe(e,t)),n})):[],a.update(),u=!0,H(a.before_update),a.fragment=!!r&&r(a.ctx),t.target){if(t.hydrate){const e=Ye(t.target);a.fragment&&a.fragment.l(e),e.forEach(I)}else a.fragment&&a.fragment.c();t.intro&&Ke(e.$$.fragment),ze(e,t.target,t.anchor),C()}O(s)}let be;function P(e,t,n,r){var o;const c=null==(o=n[e])?void 0:o.type;if(t="Boolean"===c&&"boolean"!=typeof t?null!=t:t,!r||!n[e])return t;if("toAttribute"===r)switch(c){case"Object":case"Array":return null==t?null:JSON.stringify(t);case"Boolean":return t?"":null;case"Number":return t??null;default:return t}else switch(c){case"Object":case"Array":return t&&JSON.parse(t);case"Boolean":default:return t;case"Number":return null!=t?+t:t}}function tt(e,t,n,r,o,c){let i=class extends be{constructor(){super(e,n,o),this.$$p_d=t}static get observedAttributes(){return Object.keys(t).map((e=>(t[e].attribute||e).toLowerCase()))}};return Object.keys(t).forEach((e=>{Object.defineProperty(i.prototype,e,{get(){return this.$$c&&e in this.$$c?this.$$c[e]:this.$$d[e]},set(n){var r;n=P(e,n,t),this.$$d[e]=n,null==(r=this.$$c)||r.$set({[e]:n})}})})),r.forEach((e=>{Object.defineProperty(i.prototype,e,{get(){var t;return null==(t=this.$$c)?void 0:t[e]}})})),c&&(i=c(i)),e.element=i,i}"function"==typeof HTMLElement&&(be=class extends HTMLElement{constructor(e,t,n){super(),x(this,"$$ctor"),x(this,"$$s"),x(this,"$$c"),x(this,"$$cn",!1),x(this,"$$d",{}),x(this,"$$r",!1),x(this,"$$p_d",{}),x(this,"$$l",{}),x(this,"$$l_u",new Map),this.$$ctor=e,this.$$s=t,n&&this.attachShadow({mode:"open"})}addEventListener(e,t,n){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const n=this.$$c.$on(e,t);this.$$l_u.set(t,n)}super.addEventListener(e,t,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),this.$$c){const e=this.$$l_u.get(t);e&&(e(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(e){return()=>{let t;return{c:function(){t=v("slot"),"default"!==e&&c(t,"name",e)},m:function(e,n){q(e,t,n)},d:function(e){e&&I(t)}}}};if(await Promise.resolve(),!this.$$cn)return;const t={},n=Oe(this);for(const r of this.$$s)r in n&&(t[r]=[e(r)]);for(const e of this.attributes){const t=this.$$g_p(e.name);t in this.$$d||(this.$$d[t]=P(t,e.value,this.$$p_d,"toProp"))}this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const r=()=>{this.$$r=!0;for(const e in this.$$p_d)if(this.$$d[e]=this.$$c.$$.ctx[this.$$c.$$.props[e]],this.$$p_d[e].reflect){const t=P(e,this.$$d[e],this.$$p_d,"toAttribute");null==t?this.removeAttribute(this.$$p_d[e].attribute||e):this.setAttribute(this.$$p_d[e].attribute||e,t)}this.$$r=!1};this.$$c.$$.after_update.push(r),r();for(const e in this.$$l)for(const t of this.$$l[e]){const n=this.$$c.$on(e,t);this.$$l_u.set(t,n)}this.$$l={}}}attributeChangedCallback(e,t,n){var r;this.$$r||(e=this.$$g_p(e),this.$$d[e]=P(e,n,this.$$p_d,"toProp"),null==(r=this.$$c)||r.$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}});class nt{constructor(){x(this,"$$"),x(this,"$$set")}$destroy(){Je(this,1),this.$destroy=Z}$on(e,t){if(!ge(t))return Z;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){this.$$set&&!Se(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const rt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(rt);const _e="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==",se=typeof window<"u"&&window.Blob&&new Blob([atob(_e)],{type:"text/javascript;charset=utf-8"});function it(){let e;try{if(e=se&&(window.URL||window.webkitURL).createObjectURL(se),!e)throw"";return new Worker(e)}catch{return new Worker("data:application/javascript;base64,"+_e)}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const lt=1e7,ot=new TextEncoder;function st(e){return[...new Uint8Array(e)].map((e=>e.toString(16).padStart(2,"0"))).join("")}async function ct(e=1e5,t="SHA-256"){const n=Date.now().toString(16),r=Math.round(Math.random()*e);return{algorithm:t,challenge:await $e(n,r,t),salt:n,signature:""}}async function $e(e,t,n){return st(await crypto.subtle.digest(n.toUpperCase(),ot.encode(e+t)))}async function at(e,t,n="SHA-256",r=lt){const o=Date.now();for(let c=0;c<=r;c++)if(await $e(t,c,n)===e)return{number:c,took:Date.now()-o};return null}var p=(e=>(e.ERROR="error",e.VERIFIED="verified",e.VERIFYING="verifying",e.UNVERIFIED="unverified",e))(p||{});function ft(e){Ve(e,"svelte-fqcw55",".altcha.svelte-fqcw55.svelte-fqcw55{background:var(--altcha-color-base, transparent);border:1px solid var(--altcha-color-border, #a0a0a0);border-radius:3px;color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:260px;overflow:hidden;position:relative;text-align:left}.altcha.svelte-fqcw55.svelte-fqcw55:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-fqcw55.svelte-fqcw55{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-fqcw55.svelte-fqcw55{flex-grow:1}.altcha-label.svelte-fqcw55 label.svelte-fqcw55{cursor:pointer}.altcha-logo.svelte-fqcw55.svelte-fqcw55{color:currentColor;opacity:0.3}.altcha-logo.svelte-fqcw55.svelte-fqcw55:hover{opacity:1}.altcha-error.svelte-fqcw55.svelte-fqcw55{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-fqcw55.svelte-fqcw55{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-fqcw55.svelte-fqcw55:hover{opacity:1}.altcha-footer.svelte-fqcw55>.svelte-fqcw55:first-child{flex-grow:1}.altcha-footer.svelte-fqcw55 a{color:currentColor}.altcha-checkbox.svelte-fqcw55.svelte-fqcw55{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-fqcw55 input.svelte-fqcw55{width:18px;height:18px;margin:0}.altcha-hidden.svelte-fqcw55.svelte-fqcw55{display:none}.altcha-spinner.svelte-fqcw55.svelte-fqcw55{animation:svelte-fqcw55-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-fqcw55-altcha-spinner{100%{transform:rotate(360deg)}}")}function ce(e){let t,n,r;return{c(){t=G("svg"),n=G("path"),r=G("path"),c(n,"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(n,"fill","currentColor"),c(n,"opacity",".25"),c(r,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(r,"fill","currentColor"),c(r,"class","altcha-spinner svelte-fqcw55"),c(t,"width","24"),c(t,"height","24"),c(t,"viewBox","0 0 24 24"),c(t,"xmlns","http://www.w3.org/2000/svg")},m(e,o){q(e,t,o),m(t,n),m(t,r)},d(e){e&&I(t)}}}function ut(e){let t,n,r=e[9].label+"";return{c(){t=v("label"),c(t,"for",n=e[3]+"_checkbox"),c(t,"class","svelte-fqcw55")},m(e,n){q(e,t,n),t.innerHTML=r},p(e,o){512&o[0]&&r!==(r=e[9].label+"")&&(t.innerHTML=r),8&o[0]&&n!==(n=e[3]+"_checkbox")&&c(t,"for",n)},d(e){e&&I(t)}}}function ht(e){let t,n=e[9].verifying+"";return{c(){t=v("span")},m(e,r){q(e,t,r),t.innerHTML=n},p(e,r){512&r[0]&&n!==(n=e[9].verifying+"")&&(t.innerHTML=n)},d(e){e&&I(t)}}}function dt(e){let t,n,r,o=e[9].verified+"";return{c(){t=v("span"),n=M(),r=v("input"),c(r,"type","hidden"),c(r,"name",e[3]),r.value=e[4]},m(e,c){q(e,t,c),t.innerHTML=o,q(e,n,c),q(e,r,c)},p(e,n){512&n[0]&&o!==(o=e[9].verified+"")&&(t.innerHTML=o),8&n[0]&&c(r,"name",e[3]),16&n[0]&&(r.value=e[4])},d(e){e&&(I(t),I(n),I(r))}}}function ae(e){let t,n,r,o,i,l;return{c(){t=v("div"),n=v("a"),r=G("svg"),o=G("path"),i=G("path"),l=G("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(i,"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(i,"fill","currentColor"),c(l,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(l,"fill","currentColor"),c(r,"width","22"),c(r,"height","22"),c(r,"viewBox","0 0 20 20"),c(r,"fill","none"),c(r,"xmlns","http://www.w3.org/2000/svg"),c(n,"href",ve),c(n,"target","_blank"),c(n,"class","altcha-logo svelte-fqcw55")},m(e,c){q(e,t,c),m(t,n),m(n,r),m(r,o),m(r,i),m(r,l)},p:Z,d(e){e&&I(t)}}}function fe(e){let t,n,r,o,i,l=e[9].error+"";return{c(){t=v("div"),n=G("svg"),r=G("path"),o=M(),i=v("div"),c(r,"stroke-linecap","round"),c(r,"stroke-linejoin","round"),c(r,"d","M6 18L18 6M6 6l12 12"),c(n,"width","14"),c(n,"height","14"),c(n,"xmlns","http://www.w3.org/2000/svg"),c(n,"fill","none"),c(n,"viewBox","0 0 24 24"),c(n,"stroke-width","1.5"),c(n,"stroke","currentColor"),c(i,"title",e[8]),c(t,"class","altcha-error svelte-fqcw55")},m(e,c){q(e,t,c),m(t,n),m(n,r),m(t,o),m(t,i),i.innerHTML=l},p(e,t){512&t[0]&&l!==(l=e[9].error+"")&&(i.innerHTML=l),256&t[0]&&c(i,"title",e[8])},d(e){e&&I(t)}}}function ue(e){let t,n,r=e[9].footer+"";return{c(){t=v("div"),n=v("div"),c(n,"class","svelte-fqcw55"),c(t,"class","altcha-footer svelte-fqcw55")},m(e,o){q(e,t,o),m(t,n),n.innerHTML=r},p(e,t){512&t[0]&&r!==(r=e[9].footer+"")&&(n.innerHTML=r)},d(e){e&&I(t)}}}function gt(e){let t,n,r,o,i,l,s,a,u,h,d,f,$,g,w=e[5]===p.VERIFYING&&ce();function b(e,t){return e[5]===p.VERIFIED?dt:e[5]===p.VERIFYING?ht:ut}let y=b(e),x=y(e),C=!0!==e[2]&&ae(),E=e[8]&&fe(e),k=e[9].footer&&!0!==e[1]&&ue(e);return{c(){t=v("div"),n=v("div"),w&&w.c(),r=M(),o=v("div"),i=v("input"),a=M(),u=v("div"),x.c(),h=M(),C&&C.c(),d=M(),E&&E.c(),f=M(),k&&k.c(),c(i,"type","checkbox"),c(i,"id",l=e[3]+"_checkbox"),i.required=s="onsubmit"!==e[0],c(i,"class","svelte-fqcw55"),c(o,"class","altcha-checkbox svelte-fqcw55"),le(o,"altcha-hidden",e[5]===p.VERIFYING),c(u,"class","altcha-label svelte-fqcw55"),c(n,"class","altcha-main svelte-fqcw55"),c(t,"class","altcha svelte-fqcw55"),c(t,"data-state",e[5])},m(c,l){q(c,t,l),m(t,n),w&&w.m(n,null),m(n,r),m(n,o),m(o,i),i.checked=e[6],m(n,a),m(n,u),x.m(u,null),m(n,h),C&&C.m(n,null),m(t,d),E&&E.m(t,null),m(t,f),k&&k.m(t,null),e[23](t),$||(g=[D(i,"change",e[22]),D(i,"change",e[10]),D(i,"invalid",e[11])],$=!0)},p(e,a){e[5]===p.VERIFYING?w||(w=ce(),w.c(),w.m(n,r)):w&&(w.d(1),w=null),8&a[0]&&l!==(l=e[3]+"_checkbox")&&c(i,"id",l),1&a[0]&&s!==(s="onsubmit"!==e[0])&&(i.required=s),64&a[0]&&(i.checked=e[6]),32&a[0]&&le(o,"altcha-hidden",e[5]===p.VERIFYING),y===(y=b(e))&&x?x.p(e,a):(x.d(1),x=y(e),x&&(x.c(),x.m(u,null))),!0!==e[2]?C?C.p(e,a):(C=ae(),C.c(),C.m(n,null)):C&&(C.d(1),C=null),e[8]?E?E.p(e,a):(E=fe(e),E.c(),E.m(t,f)):E&&(E.d(1),E=null),e[9].footer&&!0!==e[1]?k?k.p(e,a):(k=ue(e),k.c(),k.m(t,null)):k&&(k.d(1),k=null),32&a[0]&&c(t,"data-state",e[5])},i:Z,o:Z,d(n){n&&I(t),w&&w.d(),x.d(),C&&C.d(),E&&E.d(),k&&k.d(),e[23](null),$=!1,H(g)}}}const ve="https://altcha.org/";function he(e){return JSON.parse(e)}function mt(e,t,n){let r,o,c,{auto:i}=t,{challengeurl:l}=t,{challengejson:s}=t,{debug:a=!1}=t,{hidefooter:u=!1}=t,{hidelogo:h=!1}=t,{name:d="altcha"}=t,{maxnumber:f}=t,{mockerror:$=!1}=t,{strings:m}=t,{test:g=!1}=t;const v=We(),w=["SHA-256","SHA-384","SHA-512"];let b,y=!1,x=null,C=null,E=null,k=p.UNVERIFIED;function I(...e){(a||e.some((e=>e instanceof Error)))&&console[e[0]instanceof Error?"error":"log"]("ALTCHA",...e)}function q(e){x&&"onsubmit"===i&&k===p.UNVERIFIED&&(e.preventDefault(),e.stopPropagation(),N().then((()=>{null==x||x.requestSubmit()})))}function _(){L()}async function G(e){let t=null;if("Worker"in window){try{t=await async function(e,t,n){const r=new it;return new Promise((o=>{r.addEventListener("message",(e=>{o(e.data)})),r.postMessage({alg:n,challenge:e,max:f,salt:t})}))}(e.challenge,e.salt,e.algorithm)}catch(e){I(e)}if(void 0!==(null==t?void 0:t.number))return{data:e,solution:t}}return{data:e,solution:await at(e.challenge,e.salt,e.algorithm,f)}}function L(e=p.UNVERIFIED){n(6,y=!1),n(8,C=null),n(4,E=null),n(5,k=e)}async function N(){return L(p.VERIFYING),async function(){if($)throw I("mocking error"),new Error("Mocked error.");if(r)return I("using provided json data"),r;if(g)return I("generating test challenge"),ct();{if(!l)throw new Error("Attribute challengeurl not set.");I("fetching challenge from",l);const e=await fetch(l);if(200!==e.status)throw new Error(`Server responded with ${e.status}.`);return e.json()}}().then((e=>(function(e){if(!e.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(void 0===e.signature)throw new Error("Invalid challenge. Property signature is missing.");if(!w.includes(e.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${w.join(", ")}`);if(!e.challenge||e.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!e.salt||e.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}(e),I("challenge",e),G(e)))).then((({data:e,solution:t})=>{if(I("solution",t),void 0===(null==t?void 0:t.number))throw new Error("Unexpected result returned.");I("verified"),n(5,k=p.VERIFIED),n(6,y=!0),n(4,E=function(e,t){return btoa(JSON.stringify({algorithm:e.algorithm,challenge:e.challenge,number:t.number,salt:e.salt,signature:e.signature,test:!!g||void 0,took:t.took}))}(e,t)),I("payload",E),Pe().then((()=>{v("verified",{payload:E})}))})).catch((e=>{I(e),n(5,k=p.ERROR),n(6,y=!1),n(8,C=e)}))}return He((()=>{x&&(x.removeEventListener("submit",q),x.removeEventListener("reset",_),x=null)})),Be((()=>{I("mounted","0.1.6"),g&&I("using test mode"),void 0!==i&&I("auto",i),x=b.closest("form"),x&&(x.addEventListener("submit",q),x.addEventListener("reset",_)),"onload"===i&&N()})),e.$$set=e=>{"auto"in e&&n(0,i=e.auto),"challengeurl"in e&&n(12,l=e.challengeurl),"challengejson"in e&&n(13,s=e.challengejson),"debug"in e&&n(14,a=e.debug),"hidefooter"in e&&n(1,u=e.hidefooter),"hidelogo"in e&&n(2,h=e.hidelogo),"name"in e&&n(3,d=e.name),"maxnumber"in e&&n(15,f=e.maxnumber),"mockerror"in e&&n(16,$=e.mockerror),"strings"in e&&n(17,m=e.strings),"test"in e&&n(18,g=e.test)},e.$$.update=()=>{8192&e.$$.dirty[0]&&(r=s?he(s):void 0),131072&e.$$.dirty[0]&&n(21,o=m?he(m):{}),2097152&e.$$.dirty[0]&&n(9,c={error:"Verification failed. Try again later.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),48&e.$$.dirty[0]&&v("statechange",{payload:E,state:k})},[i,u,h,d,E,k,y,b,C,c,function(){[p.UNVERIFIED,p.ERROR].includes(k)?N():n(6,y=!0)},function(){k===p.VERIFYING&&alert(c.waitAlert)},l,s,a,f,$,m,g,L,N,o,function(){y=this.checked,n(6,y)},function(e){z[e?"unshift":"push"]((()=>{b=e,n(7,b)}))}]}class wt extends nt{constructor(e){super(),et(this,e,mt,gt,Ae,{auto:0,challengeurl:12,challengejson:13,debug:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,strings:17,test:18,reset:19,verify:20},ft,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),C()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),C()}get challengejson(){return this.$$.ctx[13]}set challengejson(e){this.$$set({challengejson:e}),C()}get debug(){return this.$$.ctx[14]}set debug(e){this.$$set({debug:e}),C()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),C()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),C()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),C()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),C()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),C()}get strings(){return this.$$.ctx[17]}set strings(e){this.$$set({strings:e}),C()}get test(){return this.$$.ctx[18]}set test(e){this.$$set({test:e}),C()}get reset(){return this.$$.ctx[19]}get verify(){return this.$$.ctx[20]}}customElements.define("altcha-widget",tt(wt,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},strings:{},test:{type:"Boolean"}},[],["reset","verify"],!1));export{wt as Altcha}; //# sourceMappingURL=/sm/3946beb23f2e7b329f9d4f976183586f81ab9506ca82e19e9433e759dcf4e908.map