altcha 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/altcha.iife.js +1 -1
- package/dist/altcha.js +222 -222
- package/dist/altcha.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/altcha.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var altcha=function(A){"use strict";var wt=Object.defineProperty;var bt=(A,y,U)=>y in A?wt(A,y,{enumerable:!0,configurable:!0,writable:!0,value:U}):A[y]=U;var I=(A,y,U)=>(bt(A,typeof y!="symbol"?y+"":y,U),U);function y(){}function U(t){return t()}function re(){return Object.create(null)}function W(t){t.forEach(U)}function ie(t){return typeof t=="function"}function ke(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Ee(t){return Object.keys(t).length===0}function v(t,e){t.appendChild(e)}function Ce(t,e,n){const i=xe(t);if(!i.getElementById(e)){const l=_("style");l.id=e,l.textContent=n,Le(i,l)}}function xe(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Le(t,e){return v(t.head||t,e),e.sheet}function R(t,e,n){t.insertBefore(e,n||null)}function L(t){t.parentNode&&t.parentNode.removeChild(t)}function _(t){return document.createElement(t)}function G(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Ie(t){return document.createTextNode(t)}function F(){return Ie(" ")}function K(t,e,n,i){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n,i)}function c(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Re(t){return Array.from(t.childNodes)}function le(t,e,n){t.classList.toggle(e,!!n)}function Ne(t,e,{bubbles:n=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:i})}function je(t){const e={};return t.childNodes.forEach(n=>{e[n.slot||"default"]=!0}),e}let P;function T(t){P=t}function z(){if(!P)throw new Error("Function called outside component initialization");return P}function Ae(t){z().$$.on_mount.push(t)}function Ge(t){z().$$.on_destroy.push(t)}function Se(){const t=z();return(e,n,{cancelable:i=!1}={})=>{const l=t.$$.callbacks[e];if(l){const r=Ne(e,n,{cancelable:i});return l.slice().forEach(s=>{s.call(t,r)}),!r.defaultPrevented}return!0}}const Z=[],J=[];let B=[];const oe=[],se=Promise.resolve();let Q=!1;function ce(){Q||(Q=!0,se.then(E))}function Me(){return ce(),se}function q(t){B.push(t)}const ee=new Set;let H=0;function E(){if(H!==0)return;const t=P;do{try{for(;H<Z.length;){const e=Z[H];H++,T(e),Ue(e.$$)}}catch(e){throw Z.length=0,H=0,e}for(T(null),Z.length=0,H=0;J.length;)J.pop()();for(let e=0;e<B.length;e+=1){const n=B[e];ee.has(n)||(ee.add(n),n())}B.length=0}while(Z.length);for(;oe.length;)oe.pop()();Q=!1,ee.clear(),T(t)}function Ue(t){if(t.fragment!==null){t.update(),W(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(q)}}function Ve(t){const e=[],n=[];B.forEach(i=>t.indexOf(i)===-1?e.push(i):n.push(i)),n.forEach(i=>i()),B=e}const Oe=new Set;function Fe(t,e){t&&t.i&&(Oe.delete(t),t.i(e))}function Ye(t,e,n){const{fragment:i,after_update:l}=t.$$;i&&i.m(e,n),q(()=>{const r=t.$$.on_mount.map(U).filter(ie);t.$$.on_destroy?t.$$.on_destroy.push(...r):W(r),t.$$.on_mount=[]}),l.forEach(q)}function Ze(t,e){const n=t.$$;n.fragment!==null&&(Ve(n.after_update),W(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Be(t,e){t.$$.dirty[0]===-1&&(Z.push(t),ce(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function He(t,e,n,i,l,r,s=null,a=[-1]){const f=P;T(t);const u=t.$$={fragment:null,ctx:[],props:r,update:y,not_equal:l,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(f?f.$$.context:[])),callbacks:re(),dirty:a,skip_bound:!1,root:e.target||f.$$.root};s&&s(u.root);let j=!1;if(u.ctx=n?n(t,e.props||{},(k,S,...N)=>{const M=N.length?N[0]:S;return u.ctx&&l(u.ctx[k],u.ctx[k]=M)&&(!u.skip_bound&&u.bound[k]&&u.bound[k](M),j&&Be(t,k)),S}):[],u.update(),j=!0,W(u.before_update),u.fragment=i?i(u.ctx):!1,e.target){if(e.hydrate){const k=Re(e.target);u.fragment&&u.fragment.l(k),k.forEach(L)}else u.fragment&&u.fragment.c();e.intro&&Fe(t.$$.fragment),Ye(t,e.target,e.anchor),E()}T(f)}let ae;typeof HTMLElement=="function"&&(ae=class extends HTMLElement{constructor(e,n,i){super();I(this,"$$ctor");I(this,"$$s");I(this,"$$c");I(this,"$$cn",!1);I(this,"$$d",{});I(this,"$$r",!1);I(this,"$$p_d",{});I(this,"$$l",{});I(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=n,i&&this.attachShadow({mode:"open"})}addEventListener(e,n,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(n),this.$$c){const l=this.$$c.$on(e,n);this.$$l_u.set(n,l)}super.addEventListener(e,n,i)}removeEventListener(e,n,i){if(super.removeEventListener(e,n,i),this.$$c){const l=this.$$l_u.get(n);l&&(l(),this.$$l_u.delete(n))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return()=>{let s;return{c:function(){s=_("slot"),r!=="default"&&c(s,"name",r)},m:function(u,j){R(u,s,j)},d:function(u){u&&L(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const n={},i=je(this);for(const r of this.$$s)r in i&&(n[r]=[e(r)]);for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=X(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:n,$$scope:{ctx:[]}}});const l=()=>{this.$$r=!0;for(const r in this.$$p_d)if(this.$$d[r]=this.$$c.$$.ctx[this.$$c.$$.props[r]],this.$$p_d[r].reflect){const s=X(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1};this.$$c.$$.after_update.push(l),l();for(const r in this.$$l)for(const s of this.$$l[r]){const a=this.$$c.$on(r,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,n,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=X(e,i,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(n=>this.$$p_d[n].attribute===e||!this.$$p_d[n].attribute&&n.toLowerCase()===e)||e}});function X(t,e,n,i){var r;const l=(r=n[t])==null?void 0:r.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!n[t])return e;if(i==="toAttribute")switch(l){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(l){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function We(t,e,n,i,l,r){let s=class extends ae{constructor(){super(t,n,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(f){var u;f=X(a,f,e),this.$$d[a]=f,(u=this.$$c)==null||u.$set({[a]:f})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var f;return(f=this.$$c)==null?void 0:f[a]}})}),r&&(s=r(s)),t.element=s,s}class Pe{constructor(){I(this,"$$");I(this,"$$set")}$destroy(){Ze(this,1),this.$destroy=y}$on(e,n){if(!ie(n))return y;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{const l=i.indexOf(n);l!==-1&&i.splice(l,1)}}$set(e){this.$$set&&!Ee(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Te="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Te);const ue="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==",Xe=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),fe=typeof window<"u"&&window.Blob&&new Blob([Xe(ue)],{type:"text/javascript;charset=utf-8"});function De(t){let e;try{if(e=fe&&(window.URL||window.webkitURL).createObjectURL(fe),!e)throw"";const n=new Worker(e,{name:t==null?void 0:t.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),n}catch{return new Worker("data:text/javascript;base64,"+ue,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const Ke=1e7,ze=new TextEncoder;function Je(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Qe(t=1e5,e="SHA-256"){const n=Date.now().toString(16),i=Math.round(Math.random()*t),l=await he(n,i,e);return{algorithm:e,challenge:l,salt:n,signature:""}}async function he(t,e,n){return Je(await crypto.subtle.digest(n.toUpperCase(),ze.encode(t+e)))}async function qe(t,e,n="SHA-256",i=Ke){const l=Date.now();for(let r=0;r<=i;r++)if(await he(e,r,n)===t)return{number:r,took:Date.now()-l};return null}var p=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t))(p||{});function et(t){Ce(t,"svelte-1wvv726",".altcha.svelte-1wvv726.svelte-1wvv726{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 3px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-1wvv726.svelte-1wvv726:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-1wvv726.svelte-1wvv726{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-1wvv726.svelte-1wvv726{flex-grow:1}.altcha-label.svelte-1wvv726 label.svelte-1wvv726{cursor:pointer}.altcha-logo.svelte-1wvv726.svelte-1wvv726{color:currentColor;opacity:0.3}.altcha-logo.svelte-1wvv726.svelte-1wvv726:hover{opacity:1}.altcha-error.svelte-1wvv726.svelte-1wvv726{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-1wvv726.svelte-1wvv726{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-1wvv726.svelte-1wvv726:hover{opacity:1}.altcha-footer.svelte-1wvv726>.svelte-1wvv726:first-child{flex-grow:1}.altcha-footer.svelte-1wvv726 a{color:currentColor}.altcha-checkbox.svelte-1wvv726.svelte-1wvv726{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-1wvv726 input.svelte-1wvv726{width:18px;height:18px;margin:0}.altcha-hidden.svelte-1wvv726.svelte-1wvv726{display:none}.altcha-spinner.svelte-1wvv726.svelte-1wvv726{animation:svelte-1wvv726-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-1wvv726-altcha-spinner{100%{transform:rotate(360deg)}}")}function de(t){let e,n,i;return{c(){e=G("svg"),n=G("path"),i=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(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-1wvv726"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(l,r){R(l,e,r),v(e,n),v(e,i)},d(l){l&&L(e)}}}function tt(t){let e,n=t[9].label+"",i;return{c(){e=_("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-1wvv726")},m(l,r){R(l,e,r),e.innerHTML=n},p(l,r){r[0]&512&&n!==(n=l[9].label+"")&&(e.innerHTML=n),r[0]&8&&i!==(i=l[3]+"_checkbox")&&c(e,"for",i)},d(l){l&&L(e)}}}function nt(t){let e,n=t[9].verifying+"";return{c(){e=_("span")},m(i,l){R(i,e,l),e.innerHTML=n},p(i,l){l[0]&512&&n!==(n=i[9].verifying+"")&&(e.innerHTML=n)},d(i){i&&L(e)}}}function rt(t){let e,n=t[9].verified+"",i,l;return{c(){e=_("span"),i=F(),l=_("input"),c(l,"type","hidden"),c(l,"name",t[3]),l.value=t[4]},m(r,s){R(r,e,s),e.innerHTML=n,R(r,i,s),R(r,l,s)},p(r,s){s[0]&512&&n!==(n=r[9].verified+"")&&(e.innerHTML=n),s[0]&8&&c(l,"name",r[3]),s[0]&16&&(l.value=r[4])},d(r){r&&(L(e),L(i),L(l))}}}function ve(t){let e,n,i,l,r,s;return{c(){e=_("div"),n=_("a"),i=G("svg"),l=G("path"),r=G("path"),s=G("path"),c(l,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(l,"fill","currentColor"),c(r,"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(r,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(n,"href",we),c(n,"target","_blank"),c(n,"class","altcha-logo svelte-1wvv726")},m(a,f){R(a,e,f),v(e,n),v(n,i),v(i,l),v(i,r),v(i,s)},p:y,d(a){a&&L(e)}}}function ge(t){let e,n,i,l,r,s=t[9].error+"";return{c(){e=_("div"),n=G("svg"),i=G("path"),l=F(),r=_("div"),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"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(r,"title",t[8]),c(e,"class","altcha-error svelte-1wvv726")},m(a,f){R(a,e,f),v(e,n),v(n,i),v(e,l),v(e,r),r.innerHTML=s},p(a,f){f[0]&512&&s!==(s=a[9].error+"")&&(r.innerHTML=s),f[0]&256&&c(r,"title",a[8])},d(a){a&&L(e)}}}function me(t){let e,n,i=t[9].footer+"";return{c(){e=_("div"),n=_("div"),c(n,"class","svelte-1wvv726"),c(e,"class","altcha-footer svelte-1wvv726")},m(l,r){R(l,e,r),v(e,n),n.innerHTML=i},p(l,r){r[0]&512&&i!==(i=l[9].footer+"")&&(n.innerHTML=i)},d(l){l&&L(e)}}}function it(t){let e,n,i,l,r,s,a,f,u,j,k,S,N,M,b=t[5]===p.VERIFYING&&de();function V(h,w){return h[5]===p.VERIFIED?rt:h[5]===p.VERIFYING?nt:tt}let Y=V(t),C=Y(t),g=t[2]!==!0&&ve(),m=t[8]&&ge(t),d=t[9].footer&&t[1]!==!0&&me(t);return{c(){e=_("div"),n=_("div"),b&&b.c(),i=F(),l=_("div"),r=_("input"),f=F(),u=_("div"),C.c(),j=F(),g&&g.c(),k=F(),m&&m.c(),S=F(),d&&d.c(),c(r,"type","checkbox"),c(r,"id",s=t[3]+"_checkbox"),r.required=a=t[0]!=="onsubmit",c(r,"class","svelte-1wvv726"),c(l,"class","altcha-checkbox svelte-1wvv726"),le(l,"altcha-hidden",t[5]===p.VERIFYING),c(u,"class","altcha-label svelte-1wvv726"),c(n,"class","altcha-main svelte-1wvv726"),c(e,"class","altcha svelte-1wvv726"),c(e,"data-state",t[5])},m(h,w){R(h,e,w),v(e,n),b&&b.m(n,null),v(n,i),v(n,l),v(l,r),r.checked=t[6],v(n,f),v(n,u),C.m(u,null),v(n,j),g&&g.m(n,null),v(e,k),m&&m.m(e,null),v(e,S),d&&d.m(e,null),t[23](e),N||(M=[K(r,"change",t[22]),K(r,"change",t[10]),K(r,"invalid",t[11])],N=!0)},p(h,w){h[5]===p.VERIFYING?b||(b=de(),b.c(),b.m(n,i)):b&&(b.d(1),b=null),w[0]&8&&s!==(s=h[3]+"_checkbox")&&c(r,"id",s),w[0]&1&&a!==(a=h[0]!=="onsubmit")&&(r.required=a),w[0]&64&&(r.checked=h[6]),w[0]&32&&le(l,"altcha-hidden",h[5]===p.VERIFYING),Y===(Y=V(h))&&C?C.p(h,w):(C.d(1),C=Y(h),C&&(C.c(),C.m(u,null))),h[2]!==!0?g?g.p(h,w):(g=ve(),g.c(),g.m(n,null)):g&&(g.d(1),g=null),h[8]?m?m.p(h,w):(m=ge(h),m.c(),m.m(e,S)):m&&(m.d(1),m=null),h[9].footer&&h[1]!==!0?d?d.p(h,w):(d=me(h),d.c(),d.m(e,null)):d&&(d.d(1),d=null),w[0]&32&&c(e,"data-state",h[5])},i:y,o:y,d(h){h&&L(e),b&&b.d(),C.d(),g&&g.d(),m&&m.d(),d&&d.d(),t[23](null),N=!1,W(M)}}}const we="https://altcha.org/";function be(t){return JSON.parse(t)}function lt(t,e,n){let i,l,r,{auto:s=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:f=void 0}=e,{debug:u=!1}=e,{hidefooter:j=!1}=e,{hidelogo:k=!1}=e,{name:S="altcha"}=e,{maxnumber:N=void 0}=e,{mockerror:M=!1}=e,{strings:b=void 0}=e,{test:V=!1}=e;const Y=Se(),C=["SHA-256","SHA-384","SHA-512"];let g=!1,m,d=null,h=null,w=null,O=p.UNVERIFIED;Ge(()=>{d&&(d.removeEventListener("submit",_e),d.removeEventListener("reset",pe),d=null)}),Ae(()=>{x("mounted","0.1.7"),V&&x("using test mode"),s!==void 0&&x("auto",s),d=m.closest("form"),d&&(d.addEventListener("submit",_e),d.addEventListener("reset",pe)),s==="onload"&&D()});function x(...o){(u||o.some($=>$ instanceof Error))&&console[o[0]instanceof Error?"error":"log"]("ALTCHA",...o)}function _e(o){d&&s==="onsubmit"&&O===p.UNVERIFIED&&(o.preventDefault(),o.stopPropagation(),D().then(()=>{d==null||d.requestSubmit()}))}function pe(){te()}function ot(o,$){return btoa(JSON.stringify({algorithm:o.algorithm,challenge:o.challenge,number:$.number,salt:o.salt,signature:o.signature,test:V?!0:void 0,took:$.took}))}function st(o){if(!o.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(o.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!C.includes(o.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${C.join(", ")}`);if(!o.challenge||o.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!o.salt||o.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function ct(){if(M)throw x("mocking error"),new Error("Mocked error.");if(i)return x("using provided json data"),i;if(V)return x("generating test challenge"),Qe();{if(!a)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",a);const o=await fetch(a);if(o.status!==200)throw new Error(`Server responded with ${o.status}.`);return o.json()}}async function at(o){let $=null;if("Worker"in window){try{$=await ut(o.challenge,o.salt,o.algorithm)}catch(ne){x(ne)}if(($==null?void 0:$.number)!==void 0)return{data:o,solution:$}}return{data:o,solution:await qe(o.challenge,o.salt,o.algorithm,N)}}async function ut(o,$,ne){const ye=new De;return new Promise(gt=>{ye.addEventListener("message",mt=>{gt(mt.data)}),ye.postMessage({alg:ne,challenge:o,max:N,salt:$})})}function ft(){[p.UNVERIFIED,p.ERROR].includes(O)?D():n(6,g=!0)}function ht(){O===p.VERIFYING&&alert(r.waitAlert)}function te(o=p.UNVERIFIED){n(6,g=!1),n(8,h=null),n(4,w=null),n(5,O=o)}async function D(){return te(p.VERIFYING),ct().then(o=>(st(o),x("challenge",o),at(o))).then(({data:o,solution:$})=>{if(x("solution",$),($==null?void 0:$.number)!==void 0)x("verified"),n(5,O=p.VERIFIED),n(6,g=!0),n(4,w=ot(o,$)),x("payload",w),Me().then(()=>{Y("verified",{payload:w})});else throw new Error("Unexpected result returned.")}).catch(o=>{x(o),n(5,O=p.ERROR),n(6,g=!1),n(8,h=o)})}function dt(){g=this.checked,n(6,g)}function vt(o){J[o?"unshift":"push"](()=>{m=o,n(7,m)})}return t.$$set=o=>{"auto"in o&&n(0,s=o.auto),"challengeurl"in o&&n(12,a=o.challengeurl),"challengejson"in o&&n(13,f=o.challengejson),"debug"in o&&n(14,u=o.debug),"hidefooter"in o&&n(1,j=o.hidefooter),"hidelogo"in o&&n(2,k=o.hidelogo),"name"in o&&n(3,S=o.name),"maxnumber"in o&&n(15,N=o.maxnumber),"mockerror"in o&&n(16,M=o.mockerror),"strings"in o&&n(17,b=o.strings),"test"in o&&n(18,V=o.test)},t.$$.update=()=>{t.$$.dirty[0]&8192&&(i=f?be(f):void 0),t.$$.dirty[0]&131072&&n(21,l=b?be(b):{}),t.$$.dirty[0]&2097152&&n(9,r={error:"Verification failed. Try again later.",footer:`Protected by <a href="${we}" target="_blank">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),t.$$.dirty[0]&48&&Y("statechange",{payload:w,state:O})},[s,j,k,S,w,O,g,m,h,r,ft,ht,a,f,u,N,M,b,V,te,D,l,dt,vt]}class $e extends Pe{constructor(e){super(),He(this,e,lt,it,ke,{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},et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),E()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),E()}get challengejson(){return this.$$.ctx[13]}set challengejson(e){this.$$set({challengejson:e}),E()}get debug(){return this.$$.ctx[14]}set debug(e){this.$$set({debug:e}),E()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),E()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),E()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),E()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),E()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),E()}get strings(){return this.$$.ctx[17]}set strings(e){this.$$set({strings:e}),E()}get test(){return this.$$.ctx[18]}set test(e){this.$$set({test:e}),E()}get reset(){return this.$$.ctx[19]}get verify(){return this.$$.ctx[20]}}return customElements.define("altcha-widget",We($e,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},strings:{},test:{type:"Boolean"}},[],["reset","verify"],!1)),A.Altcha=$e,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),A}({});
|
|
1
|
+
var altcha=function(A){"use strict";var vt=Object.defineProperty;var $t=(A,y,U)=>y in A?vt(A,y,{enumerable:!0,configurable:!0,writable:!0,value:U}):A[y]=U;var I=(A,y,U)=>($t(A,typeof y!="symbol"?y+"":y,U),U);function y(){}function U(t){return t()}function re(){return Object.create(null)}function W(t){t.forEach(U)}function oe(t){return typeof t=="function"}function ke(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Ee(t){return Object.keys(t).length===0}function g(t,e){t.appendChild(e)}function Ce(t,e,n){const o=xe(t);if(!o.getElementById(e)){const i=w("style");i.id=e,i.textContent=n,Le(o,i)}}function xe(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Le(t,e){return g(t.head||t,e),e.sheet}function R(t,e,n){t.insertBefore(e,n||null)}function L(t){t.parentNode&&t.parentNode.removeChild(t)}function w(t){return document.createElement(t)}function G(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Ie(t){return document.createTextNode(t)}function F(){return Ie(" ")}function K(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function c(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Re(t){return Array.from(t.childNodes)}function ie(t,e,n){t.classList.toggle(e,!!n)}function Ne(t,e,{bubbles:n=!1,cancelable:o=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:o})}function je(t){const e={};return t.childNodes.forEach(n=>{e[n.slot||"default"]=!0}),e}let P;function T(t){P=t}function z(){if(!P)throw new Error("Function called outside component initialization");return P}function Ae(t){z().$$.on_mount.push(t)}function Ge(t){z().$$.on_destroy.push(t)}function Se(){const t=z();return(e,n,{cancelable:o=!1}={})=>{const i=t.$$.callbacks[e];if(i){const r=Ne(e,n,{cancelable:o});return i.slice().forEach(s=>{s.call(t,r)}),!r.defaultPrevented}return!0}}const Z=[],J=[];let B=[];const le=[],se=Promise.resolve();let Q=!1;function ce(){Q||(Q=!0,se.then(E))}function Me(){return ce(),se}function q(t){B.push(t)}const ee=new Set;let H=0;function E(){if(H!==0)return;const t=P;do{try{for(;H<Z.length;){const e=Z[H];H++,T(e),Ue(e.$$)}}catch(e){throw Z.length=0,H=0,e}for(T(null),Z.length=0,H=0;J.length;)J.pop()();for(let e=0;e<B.length;e+=1){const n=B[e];ee.has(n)||(ee.add(n),n())}B.length=0}while(Z.length);for(;le.length;)le.pop()();Q=!1,ee.clear(),T(t)}function Ue(t){if(t.fragment!==null){t.update(),W(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(q)}}function Ve(t){const e=[],n=[];B.forEach(o=>t.indexOf(o)===-1?e.push(o):n.push(o)),n.forEach(o=>o()),B=e}const Oe=new Set;function Fe(t,e){t&&t.i&&(Oe.delete(t),t.i(e))}function Ye(t,e,n){const{fragment:o,after_update:i}=t.$$;o&&o.m(e,n),q(()=>{const r=t.$$.on_mount.map(U).filter(oe);t.$$.on_destroy?t.$$.on_destroy.push(...r):W(r),t.$$.on_mount=[]}),i.forEach(q)}function Ze(t,e){const n=t.$$;n.fragment!==null&&(Ve(n.after_update),W(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Be(t,e){t.$$.dirty[0]===-1&&(Z.push(t),ce(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function He(t,e,n,o,i,r,s=null,a=[-1]){const f=P;T(t);const u=t.$$={fragment:null,ctx:[],props:r,update:y,not_equal:i,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(f?f.$$.context:[])),callbacks:re(),dirty:a,skip_bound:!1,root:e.target||f.$$.root};s&&s(u.root);let j=!1;if(u.ctx=n?n(t,e.props||{},(k,S,...N)=>{const M=N.length?N[0]:S;return u.ctx&&i(u.ctx[k],u.ctx[k]=M)&&(!u.skip_bound&&u.bound[k]&&u.bound[k](M),j&&Be(t,k)),S}):[],u.update(),j=!0,W(u.before_update),u.fragment=o?o(u.ctx):!1,e.target){if(e.hydrate){const k=Re(e.target);u.fragment&&u.fragment.l(k),k.forEach(L)}else u.fragment&&u.fragment.c();e.intro&&Fe(t.$$.fragment),Ye(t,e.target,e.anchor),E()}T(f)}let ae;typeof HTMLElement=="function"&&(ae=class extends HTMLElement{constructor(e,n,o){super();I(this,"$$ctor");I(this,"$$s");I(this,"$$c");I(this,"$$cn",!1);I(this,"$$d",{});I(this,"$$r",!1);I(this,"$$p_d",{});I(this,"$$l",{});I(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=n,o&&this.attachShadow({mode:"open"})}addEventListener(e,n,o){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(n),this.$$c){const i=this.$$c.$on(e,n);this.$$l_u.set(n,i)}super.addEventListener(e,n,o)}removeEventListener(e,n,o){if(super.removeEventListener(e,n,o),this.$$c){const i=this.$$l_u.get(n);i&&(i(),this.$$l_u.delete(n))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return()=>{let s;return{c:function(){s=w("slot"),r!=="default"&&c(s,"name",r)},m:function(u,j){R(u,s,j)},d:function(u){u&&L(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const n={},o=je(this);for(const r of this.$$s)r in o&&(n[r]=[e(r)]);for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=X(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:n,$$scope:{ctx:[]}}});const i=()=>{this.$$r=!0;for(const r in this.$$p_d)if(this.$$d[r]=this.$$c.$$.ctx[this.$$c.$$.props[r]],this.$$p_d[r].reflect){const s=X(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1};this.$$c.$$.after_update.push(i),i();for(const r in this.$$l)for(const s of this.$$l[r]){const a=this.$$c.$on(r,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,n,o){var i;this.$$r||(e=this.$$g_p(e),this.$$d[e]=X(e,o,this.$$p_d,"toProp"),(i=this.$$c)==null||i.$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(n=>this.$$p_d[n].attribute===e||!this.$$p_d[n].attribute&&n.toLowerCase()===e)||e}});function X(t,e,n,o){var r;const i=(r=n[t])==null?void 0:r.type;if(e=i==="Boolean"&&typeof e!="boolean"?e!=null:e,!o||!n[t])return e;if(o==="toAttribute")switch(i){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(i){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function We(t,e,n,o,i,r){let s=class extends ae{constructor(){super(t,n,i),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(f){var u;f=X(a,f,e),this.$$d[a]=f,(u=this.$$c)==null||u.$set({[a]:f})}})}),o.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var f;return(f=this.$$c)==null?void 0:f[a]}})}),r&&(s=r(s)),t.element=s,s}class Pe{constructor(){I(this,"$$");I(this,"$$set")}$destroy(){Ze(this,1),this.$destroy=y}$on(e,n){if(!oe(n))return y;const o=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return o.push(n),()=>{const i=o.indexOf(n);i!==-1&&o.splice(i,1)}}$set(e){this.$$set&&!Ee(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Te="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Te);const ue="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==",Xe=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),fe=typeof window<"u"&&window.Blob&&new Blob([Xe(ue)],{type:"text/javascript;charset=utf-8"});function De(t){let e;try{if(e=fe&&(window.URL||window.webkitURL).createObjectURL(fe),!e)throw"";const n=new Worker(e,{name:t==null?void 0:t.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),n}catch{return new Worker("data:text/javascript;base64,"+ue,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const Ke=1e7,ze=new TextEncoder;function Je(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Qe(t=1e5,e="SHA-256"){const n=Date.now().toString(16),o=Math.round(Math.random()*t),i=await he(n,o,e);return{algorithm:e,challenge:i,salt:n,signature:""}}async function he(t,e,n){return Je(await crypto.subtle.digest(n.toUpperCase(),ze.encode(t+e)))}async function qe(t,e,n="SHA-256",o=Ke){const i=Date.now();for(let r=0;r<=o;r++)if(await he(e,r,n)===t)return{number:r,took:Date.now()-i};return null}var p=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t))(p||{});function et(t){Ce(t,"svelte-vuofbg",".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}")}function de(t){let e,n,o;return{c(){e=G("svg"),n=G("path"),o=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(o,"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(o,"fill","currentColor"),c(o,"class","altcha-spinner svelte-vuofbg"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(i,r){R(i,e,r),g(e,n),g(e,o)},d(i){i&&L(e)}}}function tt(t){let e,n=t[9].label+"",o;return{c(){e=w("label"),c(e,"for",o=t[3]+"_checkbox"),c(e,"class","svelte-vuofbg")},m(i,r){R(i,e,r),e.innerHTML=n},p(i,r){r[0]&512&&n!==(n=i[9].label+"")&&(e.innerHTML=n),r[0]&8&&o!==(o=i[3]+"_checkbox")&&c(e,"for",o)},d(i){i&&L(e)}}}function nt(t){let e,n=t[9].verifying+"";return{c(){e=w("span")},m(o,i){R(o,e,i),e.innerHTML=n},p(o,i){i[0]&512&&n!==(n=o[9].verifying+"")&&(e.innerHTML=n)},d(o){o&&L(e)}}}function rt(t){let e,n=t[9].verified+"",o,i;return{c(){e=w("span"),o=F(),i=w("input"),c(i,"type","hidden"),c(i,"name",t[3]),i.value=t[4]},m(r,s){R(r,e,s),e.innerHTML=n,R(r,o,s),R(r,i,s)},p(r,s){s[0]&512&&n!==(n=r[9].verified+"")&&(e.innerHTML=n),s[0]&8&&c(i,"name",r[3]),s[0]&16&&(i.value=r[4])},d(r){r&&(L(e),L(o),L(i))}}}function ge(t){let e,n,o,i,r,s;return{c(){e=w("div"),n=w("a"),o=G("svg"),i=G("path"),r=G("path"),s=G("path"),c(i,"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(i,"fill","currentColor"),c(r,"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(r,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(o,"width","22"),c(o,"height","22"),c(o,"viewBox","0 0 20 20"),c(o,"fill","none"),c(o,"xmlns","http://www.w3.org/2000/svg"),c(n,"href",ve),c(n,"target","_blank"),c(n,"class","altcha-logo svelte-vuofbg")},m(a,f){R(a,e,f),g(e,n),g(n,o),g(o,i),g(o,r),g(o,s)},p:y,d(a){a&&L(e)}}}function be(t){let e,n,o,i,r,s=t[9].error+"";return{c(){e=w("div"),n=G("svg"),o=G("path"),i=F(),r=w("div"),c(o,"stroke-linecap","round"),c(o,"stroke-linejoin","round"),c(o,"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(r,"title",t[8]),c(e,"class","altcha-error svelte-vuofbg")},m(a,f){R(a,e,f),g(e,n),g(n,o),g(e,i),g(e,r),r.innerHTML=s},p(a,f){f[0]&512&&s!==(s=a[9].error+"")&&(r.innerHTML=s),f[0]&256&&c(r,"title",a[8])},d(a){a&&L(e)}}}function me(t){let e,n,o=t[9].footer+"";return{c(){e=w("div"),n=w("div"),c(n,"class","svelte-vuofbg"),c(e,"class","altcha-footer svelte-vuofbg")},m(i,r){R(i,e,r),g(e,n),n.innerHTML=o},p(i,r){r[0]&512&&o!==(o=i[9].footer+"")&&(n.innerHTML=o)},d(i){i&&L(e)}}}function ot(t){let e,n,o,i,r,s,a,f,u,j,k,S,N,M,$=t[5]===p.VERIFYING&&de();function V(h,v){return h[5]===p.VERIFIED?rt:h[5]===p.VERIFYING?nt:tt}let Y=V(t),C=Y(t),b=t[2]!==!0&&ge(),m=t[8]&&be(t),d=t[9].footer&&t[1]!==!0&&me(t);return{c(){e=w("div"),n=w("div"),$&&$.c(),o=F(),i=w("div"),r=w("input"),f=F(),u=w("div"),C.c(),j=F(),b&&b.c(),k=F(),m&&m.c(),S=F(),d&&d.c(),c(r,"type","checkbox"),c(r,"id",s=t[3]+"_checkbox"),r.required=a=t[0]!=="onsubmit",c(r,"class","svelte-vuofbg"),c(i,"class","altcha-checkbox svelte-vuofbg"),ie(i,"altcha-hidden",t[5]===p.VERIFYING),c(u,"class","altcha-label svelte-vuofbg"),c(n,"class","altcha-main svelte-vuofbg"),c(e,"class","altcha svelte-vuofbg"),c(e,"data-state",t[5])},m(h,v){R(h,e,v),g(e,n),$&&$.m(n,null),g(n,o),g(n,i),g(i,r),r.checked=t[6],g(n,f),g(n,u),C.m(u,null),g(n,j),b&&b.m(n,null),g(e,k),m&&m.m(e,null),g(e,S),d&&d.m(e,null),t[23](e),N||(M=[K(r,"change",t[22]),K(r,"change",t[10]),K(r,"invalid",t[11])],N=!0)},p(h,v){h[5]===p.VERIFYING?$||($=de(),$.c(),$.m(n,o)):$&&($.d(1),$=null),v[0]&8&&s!==(s=h[3]+"_checkbox")&&c(r,"id",s),v[0]&1&&a!==(a=h[0]!=="onsubmit")&&(r.required=a),v[0]&64&&(r.checked=h[6]),v[0]&32&&ie(i,"altcha-hidden",h[5]===p.VERIFYING),Y===(Y=V(h))&&C?C.p(h,v):(C.d(1),C=Y(h),C&&(C.c(),C.m(u,null))),h[2]!==!0?b?b.p(h,v):(b=ge(),b.c(),b.m(n,null)):b&&(b.d(1),b=null),h[8]?m?m.p(h,v):(m=be(h),m.c(),m.m(e,S)):m&&(m.d(1),m=null),h[9].footer&&h[1]!==!0?d?d.p(h,v):(d=me(h),d.c(),d.m(e,null)):d&&(d.d(1),d=null),v[0]&32&&c(e,"data-state",h[5])},i:y,o:y,d(h){h&&L(e),$&&$.d(),C.d(),b&&b.d(),m&&m.d(),d&&d.d(),t[23](null),N=!1,W(M)}}}const ve="https://altcha.org/";function $e(t){return JSON.parse(t)}function it(t,e,n){let o,i,r,{auto:s=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:f=void 0}=e,{debug:u=!1}=e,{hidefooter:j=!1}=e,{hidelogo:k=!1}=e,{name:S="altcha"}=e,{maxnumber:N=void 0}=e,{mockerror:M=!1}=e,{strings:$=void 0}=e,{test:V=!1}=e;const Y=Se(),C=["SHA-256","SHA-384","SHA-512"];let b=!1,m,d=null,h=null,v=null,O=p.UNVERIFIED;Ge(()=>{d&&(d.removeEventListener("submit",we),d.removeEventListener("reset",pe),d=null)}),Ae(()=>{x("mounted","0.1.8"),V&&x("using test mode"),s!==void 0&&x("auto",s),d=m.closest("form"),d&&(d.addEventListener("submit",we),d.addEventListener("reset",pe)),s==="onload"&&D()});function x(...l){(u||l.some(_=>_ instanceof Error))&&console[l[0]instanceof Error?"error":"log"]("ALTCHA",...l)}function we(l){d&&s==="onsubmit"&&O===p.UNVERIFIED&&(l.preventDefault(),l.stopPropagation(),D().then(()=>{d==null||d.requestSubmit()}))}function pe(){te()}function lt(l,_){return btoa(JSON.stringify({algorithm:l.algorithm,challenge:l.challenge,number:_.number,salt:l.salt,signature:l.signature,test:V?!0:void 0,took:_.took}))}function st(l){if(!l.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(l.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!C.includes(l.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${C.join(", ")}`);if(!l.challenge||l.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!l.salt||l.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function ct(){if(M)throw x("mocking error"),new Error("Mocked error.");if(o)return x("using provided json data"),o;if(V)return x("generating test challenge"),Qe();{if(!a)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",a);const l=await fetch(a);if(l.status!==200)throw new Error(`Server responded with ${l.status}.`);return l.json()}}async function at(l){let _=null;if("Worker"in window){try{_=await ut(l.challenge,l.salt,l.algorithm)}catch(ne){x(ne)}if((_==null?void 0:_.number)!==void 0)return{data:l,solution:_}}return{data:l,solution:await qe(l.challenge,l.salt,l.algorithm,N)}}async function ut(l,_,ne){const ye=new De;return new Promise(bt=>{ye.addEventListener("message",mt=>{bt(mt.data)}),ye.postMessage({alg:ne,challenge:l,max:N,salt:_})})}function ft(){[p.UNVERIFIED,p.ERROR].includes(O)?D():n(6,b=!0)}function ht(){O===p.VERIFYING&&alert(r.waitAlert)}function te(l=p.UNVERIFIED){n(6,b=!1),n(8,h=null),n(4,v=null),n(5,O=l)}async function D(){return te(p.VERIFYING),ct().then(l=>(st(l),x("challenge",l),at(l))).then(({data:l,solution:_})=>{if(x("solution",_),(_==null?void 0:_.number)!==void 0)x("verified"),n(5,O=p.VERIFIED),n(6,b=!0),n(4,v=lt(l,_)),x("payload",v),Me().then(()=>{Y("verified",{payload:v})});else throw new Error("Unexpected result returned.")}).catch(l=>{x(l),n(5,O=p.ERROR),n(6,b=!1),n(8,h=l)})}function dt(){b=this.checked,n(6,b)}function gt(l){J[l?"unshift":"push"](()=>{m=l,n(7,m)})}return t.$$set=l=>{"auto"in l&&n(0,s=l.auto),"challengeurl"in l&&n(12,a=l.challengeurl),"challengejson"in l&&n(13,f=l.challengejson),"debug"in l&&n(14,u=l.debug),"hidefooter"in l&&n(1,j=l.hidefooter),"hidelogo"in l&&n(2,k=l.hidelogo),"name"in l&&n(3,S=l.name),"maxnumber"in l&&n(15,N=l.maxnumber),"mockerror"in l&&n(16,M=l.mockerror),"strings"in l&&n(17,$=l.strings),"test"in l&&n(18,V=l.test)},t.$$.update=()=>{t.$$.dirty[0]&8192&&(o=f?$e(f):void 0),t.$$.dirty[0]&131072&&n(21,i=$?$e($):{}),t.$$.dirty[0]&2097152&&n(9,r={error:"Verification failed. Try again later.",footer:`Protected by <a href="${ve}" target="_blank">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...i}),t.$$.dirty[0]&48&&Y("statechange",{payload:v,state:O})},[s,j,k,S,v,O,b,m,h,r,ft,ht,a,f,u,N,M,$,V,te,D,i,dt,gt]}class _e extends Pe{constructor(e){super(),He(this,e,it,ot,ke,{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},et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),E()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),E()}get challengejson(){return this.$$.ctx[13]}set challengejson(e){this.$$set({challengejson:e}),E()}get debug(){return this.$$.ctx[14]}set debug(e){this.$$set({debug:e}),E()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),E()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),E()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),E()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),E()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),E()}get strings(){return this.$$.ctx[17]}set strings(e){this.$$set({strings:e}),E()}get test(){return this.$$.ctx[18]}set test(e){this.$$set({test:e}),E()}get reset(){return this.$$.ctx[19]}get verify(){return this.$$.ctx[20]}}return customElements.define("altcha-widget",We(_e,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},strings:{},test:{type:"Boolean"}},[],["reset","verify"],!1)),A.Altcha=_e,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),A}({});
|
package/dist/altcha.js
CHANGED
|
@@ -6,13 +6,13 @@ function Z() {
|
|
|
6
6
|
function de(t) {
|
|
7
7
|
return t();
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function oe() {
|
|
10
10
|
return /* @__PURE__ */ Object.create(null);
|
|
11
11
|
}
|
|
12
12
|
function W(t) {
|
|
13
13
|
t.forEach(de);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function ge(t) {
|
|
16
16
|
return typeof t == "function";
|
|
17
17
|
}
|
|
18
18
|
function Se(t, e) {
|
|
@@ -21,14 +21,14 @@ function Se(t, e) {
|
|
|
21
21
|
function Ue(t) {
|
|
22
22
|
return Object.keys(t).length === 0;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function b(t, e) {
|
|
25
25
|
t.appendChild(e);
|
|
26
26
|
}
|
|
27
27
|
function Ve(t, e, n) {
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
30
|
-
const
|
|
31
|
-
|
|
28
|
+
const o = Me(t);
|
|
29
|
+
if (!o.getElementById(e)) {
|
|
30
|
+
const i = w("style");
|
|
31
|
+
i.id = e, i.textContent = n, Fe(o, i);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
function Me(t) {
|
|
@@ -42,7 +42,7 @@ function Me(t) {
|
|
|
42
42
|
) : t.ownerDocument;
|
|
43
43
|
}
|
|
44
44
|
function Fe(t, e) {
|
|
45
|
-
return
|
|
45
|
+
return b(
|
|
46
46
|
/** @type {Document} */
|
|
47
47
|
t.head || t,
|
|
48
48
|
e
|
|
@@ -54,7 +54,7 @@ function R(t, e, n) {
|
|
|
54
54
|
function L(t) {
|
|
55
55
|
t.parentNode && t.parentNode.removeChild(t);
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function w(t) {
|
|
58
58
|
return document.createElement(t);
|
|
59
59
|
}
|
|
60
60
|
function G(t) {
|
|
@@ -66,8 +66,8 @@ function Oe(t) {
|
|
|
66
66
|
function M() {
|
|
67
67
|
return Oe(" ");
|
|
68
68
|
}
|
|
69
|
-
function K(t, e, n,
|
|
70
|
-
return t.addEventListener(e, n,
|
|
69
|
+
function K(t, e, n, o) {
|
|
70
|
+
return t.addEventListener(e, n, o), () => t.removeEventListener(e, n, o);
|
|
71
71
|
}
|
|
72
72
|
function c(t, e, n) {
|
|
73
73
|
n == null ? t.removeAttribute(e) : t.getAttribute(e) !== n && t.setAttribute(e, n);
|
|
@@ -75,11 +75,11 @@ function c(t, e, n) {
|
|
|
75
75
|
function Ye(t) {
|
|
76
76
|
return Array.from(t.childNodes);
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function ie(t, e, n) {
|
|
79
79
|
t.classList.toggle(e, !!n);
|
|
80
80
|
}
|
|
81
|
-
function Ze(t, e, { bubbles: n = !1, cancelable:
|
|
82
|
-
return new CustomEvent(t, { detail: e, bubbles: n, cancelable:
|
|
81
|
+
function Ze(t, e, { bubbles: n = !1, cancelable: o = !1 } = {}) {
|
|
82
|
+
return new CustomEvent(t, { detail: e, bubbles: n, cancelable: o });
|
|
83
83
|
}
|
|
84
84
|
function Be(t) {
|
|
85
85
|
const e = {};
|
|
@@ -107,16 +107,16 @@ function We(t) {
|
|
|
107
107
|
}
|
|
108
108
|
function Pe() {
|
|
109
109
|
const t = ee();
|
|
110
|
-
return (e, n, { cancelable:
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
110
|
+
return (e, n, { cancelable: o = !1 } = {}) => {
|
|
111
|
+
const i = t.$$.callbacks[e];
|
|
112
|
+
if (i) {
|
|
113
113
|
const r = Ze(
|
|
114
114
|
/** @type {string} */
|
|
115
115
|
e,
|
|
116
116
|
n,
|
|
117
|
-
{ cancelable:
|
|
117
|
+
{ cancelable: o }
|
|
118
118
|
);
|
|
119
|
-
return
|
|
119
|
+
return i.slice().forEach((s) => {
|
|
120
120
|
s.call(t, r);
|
|
121
121
|
}), !r.defaultPrevented;
|
|
122
122
|
}
|
|
@@ -125,13 +125,13 @@ function Pe() {
|
|
|
125
125
|
}
|
|
126
126
|
const O = [], J = [];
|
|
127
127
|
let Y = [];
|
|
128
|
-
const
|
|
128
|
+
const le = [], be = /* @__PURE__ */ Promise.resolve();
|
|
129
129
|
let Q = !1;
|
|
130
130
|
function me() {
|
|
131
|
-
Q || (Q = !0,
|
|
131
|
+
Q || (Q = !0, be.then(C));
|
|
132
132
|
}
|
|
133
133
|
function Te() {
|
|
134
|
-
return me(),
|
|
134
|
+
return me(), be;
|
|
135
135
|
}
|
|
136
136
|
function q(t) {
|
|
137
137
|
Y.push(t);
|
|
@@ -159,8 +159,8 @@ function C() {
|
|
|
159
159
|
}
|
|
160
160
|
Y.length = 0;
|
|
161
161
|
} while (O.length);
|
|
162
|
-
for (;
|
|
163
|
-
|
|
162
|
+
for (; le.length; )
|
|
163
|
+
le.pop()();
|
|
164
164
|
Q = !1, z.clear(), B(t);
|
|
165
165
|
}
|
|
166
166
|
function Xe(t) {
|
|
@@ -172,18 +172,18 @@ function Xe(t) {
|
|
|
172
172
|
}
|
|
173
173
|
function De(t) {
|
|
174
174
|
const e = [], n = [];
|
|
175
|
-
Y.forEach((
|
|
175
|
+
Y.forEach((o) => t.indexOf(o) === -1 ? e.push(o) : n.push(o)), n.forEach((o) => o()), Y = e;
|
|
176
176
|
}
|
|
177
177
|
const Ke = /* @__PURE__ */ new Set();
|
|
178
178
|
function ze(t, e) {
|
|
179
179
|
t && t.i && (Ke.delete(t), t.i(e));
|
|
180
180
|
}
|
|
181
181
|
function Je(t, e, n) {
|
|
182
|
-
const { fragment:
|
|
183
|
-
|
|
184
|
-
const r = t.$$.on_mount.map(de).filter(
|
|
182
|
+
const { fragment: o, after_update: i } = t.$$;
|
|
183
|
+
o && o.m(e, n), q(() => {
|
|
184
|
+
const r = t.$$.on_mount.map(de).filter(ge);
|
|
185
185
|
t.$$.on_destroy ? t.$$.on_destroy.push(...r) : W(r), t.$$.on_mount = [];
|
|
186
|
-
}),
|
|
186
|
+
}), i.forEach(q);
|
|
187
187
|
}
|
|
188
188
|
function Qe(t, e) {
|
|
189
189
|
const n = t.$$;
|
|
@@ -192,7 +192,7 @@ function Qe(t, e) {
|
|
|
192
192
|
function qe(t, e) {
|
|
193
193
|
t.$$.dirty[0] === -1 && (O.push(t), me(), t.$$.dirty.fill(0)), t.$$.dirty[e / 31 | 0] |= 1 << e % 31;
|
|
194
194
|
}
|
|
195
|
-
function et(t, e, n,
|
|
195
|
+
function et(t, e, n, o, i, r, s = null, a = [-1]) {
|
|
196
196
|
const f = H;
|
|
197
197
|
B(t);
|
|
198
198
|
const u = t.$$ = {
|
|
@@ -201,8 +201,8 @@ function et(t, e, n, i, l, r, s = null, a = [-1]) {
|
|
|
201
201
|
// state
|
|
202
202
|
props: r,
|
|
203
203
|
update: Z,
|
|
204
|
-
not_equal:
|
|
205
|
-
bound:
|
|
204
|
+
not_equal: i,
|
|
205
|
+
bound: oe(),
|
|
206
206
|
// lifecycle
|
|
207
207
|
on_mount: [],
|
|
208
208
|
on_destroy: [],
|
|
@@ -211,7 +211,7 @@ function et(t, e, n, i, l, r, s = null, a = [-1]) {
|
|
|
211
211
|
after_update: [],
|
|
212
212
|
context: new Map(e.context || (f ? f.$$.context : [])),
|
|
213
213
|
// everything else
|
|
214
|
-
callbacks:
|
|
214
|
+
callbacks: oe(),
|
|
215
215
|
dirty: a,
|
|
216
216
|
skip_bound: !1,
|
|
217
217
|
root: e.target || f.$$.root
|
|
@@ -220,8 +220,8 @@ function et(t, e, n, i, l, r, s = null, a = [-1]) {
|
|
|
220
220
|
let N = !1;
|
|
221
221
|
if (u.ctx = n ? n(t, e.props || {}, (y, j, ...I) => {
|
|
222
222
|
const A = I.length ? I[0] : j;
|
|
223
|
-
return u.ctx &&
|
|
224
|
-
}) : [], u.update(), N = !0, W(u.before_update), u.fragment =
|
|
223
|
+
return u.ctx && i(u.ctx[y], u.ctx[y] = A) && (!u.skip_bound && u.bound[y] && u.bound[y](A), N && qe(t, y)), j;
|
|
224
|
+
}) : [], u.update(), N = !0, W(u.before_update), u.fragment = o ? o(u.ctx) : !1, e.target) {
|
|
225
225
|
if (e.hydrate) {
|
|
226
226
|
const y = Ye(e.target);
|
|
227
227
|
u.fragment && u.fragment.l(y), y.forEach(L);
|
|
@@ -231,9 +231,9 @@ function et(t, e, n, i, l, r, s = null, a = [-1]) {
|
|
|
231
231
|
}
|
|
232
232
|
B(f);
|
|
233
233
|
}
|
|
234
|
-
let
|
|
235
|
-
typeof HTMLElement == "function" && (
|
|
236
|
-
constructor(e, n,
|
|
234
|
+
let ve;
|
|
235
|
+
typeof HTMLElement == "function" && (ve = class extends HTMLElement {
|
|
236
|
+
constructor(e, n, o) {
|
|
237
237
|
super();
|
|
238
238
|
/** The Svelte component constructor */
|
|
239
239
|
x(this, "$$ctor");
|
|
@@ -253,19 +253,19 @@ typeof HTMLElement == "function" && (we = class extends HTMLElement {
|
|
|
253
253
|
x(this, "$$l", {});
|
|
254
254
|
/** @type {Map<Function, Function>} Event listener unsubscribe functions */
|
|
255
255
|
x(this, "$$l_u", /* @__PURE__ */ new Map());
|
|
256
|
-
this.$$ctor = e, this.$$s = n,
|
|
256
|
+
this.$$ctor = e, this.$$s = n, o && this.attachShadow({ mode: "open" });
|
|
257
257
|
}
|
|
258
|
-
addEventListener(e, n,
|
|
258
|
+
addEventListener(e, n, o) {
|
|
259
259
|
if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(n), this.$$c) {
|
|
260
|
-
const
|
|
261
|
-
this.$$l_u.set(n,
|
|
260
|
+
const i = this.$$c.$on(e, n);
|
|
261
|
+
this.$$l_u.set(n, i);
|
|
262
262
|
}
|
|
263
|
-
super.addEventListener(e, n,
|
|
263
|
+
super.addEventListener(e, n, o);
|
|
264
264
|
}
|
|
265
|
-
removeEventListener(e, n,
|
|
266
|
-
if (super.removeEventListener(e, n,
|
|
267
|
-
const
|
|
268
|
-
|
|
265
|
+
removeEventListener(e, n, o) {
|
|
266
|
+
if (super.removeEventListener(e, n, o), this.$$c) {
|
|
267
|
+
const i = this.$$l_u.get(n);
|
|
268
|
+
i && (i(), this.$$l_u.delete(n));
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
async connectedCallback() {
|
|
@@ -275,7 +275,7 @@ typeof HTMLElement == "function" && (we = class extends HTMLElement {
|
|
|
275
275
|
let s;
|
|
276
276
|
return {
|
|
277
277
|
c: function() {
|
|
278
|
-
s =
|
|
278
|
+
s = w("slot"), r !== "default" && c(s, "name", r);
|
|
279
279
|
},
|
|
280
280
|
/**
|
|
281
281
|
* @param {HTMLElement} target
|
|
@@ -292,9 +292,9 @@ typeof HTMLElement == "function" && (we = class extends HTMLElement {
|
|
|
292
292
|
};
|
|
293
293
|
if (await Promise.resolve(), !this.$$cn || this.$$c)
|
|
294
294
|
return;
|
|
295
|
-
const n = {},
|
|
295
|
+
const n = {}, o = Be(this);
|
|
296
296
|
for (const r of this.$$s)
|
|
297
|
-
r in
|
|
297
|
+
r in o && (n[r] = [e(r)]);
|
|
298
298
|
for (const r of this.attributes) {
|
|
299
299
|
const s = this.$$g_p(r.name);
|
|
300
300
|
s in this.$$d || (this.$$d[s] = T(s, r.value, this.$$p_d, "toProp"));
|
|
@@ -311,7 +311,7 @@ typeof HTMLElement == "function" && (we = class extends HTMLElement {
|
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
});
|
|
314
|
-
const
|
|
314
|
+
const i = () => {
|
|
315
315
|
this.$$r = !0;
|
|
316
316
|
for (const r in this.$$p_d)
|
|
317
317
|
if (this.$$d[r] = this.$$c.$$.ctx[this.$$c.$$.props[r]], this.$$p_d[r].reflect) {
|
|
@@ -325,7 +325,7 @@ typeof HTMLElement == "function" && (we = class extends HTMLElement {
|
|
|
325
325
|
}
|
|
326
326
|
this.$$r = !1;
|
|
327
327
|
};
|
|
328
|
-
this.$$c.$$.after_update.push(
|
|
328
|
+
this.$$c.$$.after_update.push(i), i();
|
|
329
329
|
for (const r in this.$$l)
|
|
330
330
|
for (const s of this.$$l[r]) {
|
|
331
331
|
const a = this.$$c.$on(r, s);
|
|
@@ -336,9 +336,9 @@ typeof HTMLElement == "function" && (we = class extends HTMLElement {
|
|
|
336
336
|
}
|
|
337
337
|
// We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
|
|
338
338
|
// and setting attributes through setAttribute etc, this is helpful
|
|
339
|
-
attributeChangedCallback(e, n,
|
|
340
|
-
var
|
|
341
|
-
this.$$r || (e = this.$$g_p(e), this.$$d[e] = T(e,
|
|
339
|
+
attributeChangedCallback(e, n, o) {
|
|
340
|
+
var i;
|
|
341
|
+
this.$$r || (e = this.$$g_p(e), this.$$d[e] = T(e, o, this.$$p_d, "toProp"), (i = this.$$c) == null || i.$set({ [e]: this.$$d[e] }));
|
|
342
342
|
}
|
|
343
343
|
disconnectedCallback() {
|
|
344
344
|
this.$$cn = !1, Promise.resolve().then(() => {
|
|
@@ -351,13 +351,13 @@ typeof HTMLElement == "function" && (we = class extends HTMLElement {
|
|
|
351
351
|
) || e;
|
|
352
352
|
}
|
|
353
353
|
});
|
|
354
|
-
function T(t, e, n,
|
|
354
|
+
function T(t, e, n, o) {
|
|
355
355
|
var r;
|
|
356
|
-
const
|
|
357
|
-
if (e =
|
|
356
|
+
const i = (r = n[t]) == null ? void 0 : r.type;
|
|
357
|
+
if (e = i === "Boolean" && typeof e != "boolean" ? e != null : e, !o || !n[t])
|
|
358
358
|
return e;
|
|
359
|
-
if (
|
|
360
|
-
switch (
|
|
359
|
+
if (o === "toAttribute")
|
|
360
|
+
switch (i) {
|
|
361
361
|
case "Object":
|
|
362
362
|
case "Array":
|
|
363
363
|
return e == null ? null : JSON.stringify(e);
|
|
@@ -369,7 +369,7 @@ function T(t, e, n, i) {
|
|
|
369
369
|
return e;
|
|
370
370
|
}
|
|
371
371
|
else
|
|
372
|
-
switch (
|
|
372
|
+
switch (i) {
|
|
373
373
|
case "Object":
|
|
374
374
|
case "Array":
|
|
375
375
|
return e && JSON.parse(e);
|
|
@@ -381,10 +381,10 @@ function T(t, e, n, i) {
|
|
|
381
381
|
return e;
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
|
-
function tt(t, e, n,
|
|
385
|
-
let s = class extends
|
|
384
|
+
function tt(t, e, n, o, i, r) {
|
|
385
|
+
let s = class extends ve {
|
|
386
386
|
constructor() {
|
|
387
|
-
super(t, n,
|
|
387
|
+
super(t, n, i), this.$$p_d = e;
|
|
388
388
|
}
|
|
389
389
|
static get observedAttributes() {
|
|
390
390
|
return Object.keys(e).map(
|
|
@@ -402,7 +402,7 @@ function tt(t, e, n, i, l, r) {
|
|
|
402
402
|
f = T(a, f, e), this.$$d[a] = f, (u = this.$$c) == null || u.$set({ [a]: f });
|
|
403
403
|
}
|
|
404
404
|
});
|
|
405
|
-
}),
|
|
405
|
+
}), o.forEach((a) => {
|
|
406
406
|
Object.defineProperty(s.prototype, a, {
|
|
407
407
|
get() {
|
|
408
408
|
var f;
|
|
@@ -442,12 +442,12 @@ class nt {
|
|
|
442
442
|
* @returns {() => void}
|
|
443
443
|
*/
|
|
444
444
|
$on(e, n) {
|
|
445
|
-
if (!
|
|
445
|
+
if (!ge(n))
|
|
446
446
|
return Z;
|
|
447
|
-
const
|
|
448
|
-
return
|
|
449
|
-
const
|
|
450
|
-
|
|
447
|
+
const o = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
|
|
448
|
+
return o.push(n), () => {
|
|
449
|
+
const i = o.indexOf(n);
|
|
450
|
+
i !== -1 && o.splice(i, 1);
|
|
451
451
|
};
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
@@ -460,8 +460,8 @@ class nt {
|
|
|
460
460
|
}
|
|
461
461
|
const rt = "4";
|
|
462
462
|
typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(rt);
|
|
463
|
-
const
|
|
464
|
-
function
|
|
463
|
+
const $e = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==", ot = (t) => Uint8Array.from(atob(t), (e) => e.charCodeAt(0)), se = typeof window < "u" && window.Blob && new Blob([ot($e)], { type: "text/javascript;charset=utf-8" });
|
|
464
|
+
function it(t) {
|
|
465
465
|
let e;
|
|
466
466
|
try {
|
|
467
467
|
if (e = se && (window.URL || window.webkitURL).createObjectURL(se), !e)
|
|
@@ -474,7 +474,7 @@ function lt(t) {
|
|
|
474
474
|
}), n;
|
|
475
475
|
} catch {
|
|
476
476
|
return new Worker(
|
|
477
|
-
"data:text/javascript;base64," +
|
|
477
|
+
"data:text/javascript;base64," + $e,
|
|
478
478
|
{
|
|
479
479
|
name: t == null ? void 0 : t.name
|
|
480
480
|
}
|
|
@@ -483,47 +483,47 @@ function lt(t) {
|
|
|
483
483
|
e && (window.URL || window.webkitURL).revokeObjectURL(e);
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
const
|
|
486
|
+
const lt = 1e7, st = new TextEncoder();
|
|
487
487
|
function ct(t) {
|
|
488
488
|
return [...new Uint8Array(t)].map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
489
489
|
}
|
|
490
490
|
async function at(t = 1e5, e = "SHA-256") {
|
|
491
|
-
const n = Date.now().toString(16),
|
|
491
|
+
const n = Date.now().toString(16), o = Math.round(Math.random() * t), i = await _e(n, o, e);
|
|
492
492
|
return {
|
|
493
493
|
algorithm: e,
|
|
494
|
-
challenge:
|
|
494
|
+
challenge: i,
|
|
495
495
|
salt: n,
|
|
496
496
|
signature: ""
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
|
-
async function
|
|
499
|
+
async function _e(t, e, n) {
|
|
500
500
|
return ct(await crypto.subtle.digest(n.toUpperCase(), st.encode(t + e)));
|
|
501
501
|
}
|
|
502
|
-
async function ut(t, e, n = "SHA-256",
|
|
503
|
-
const
|
|
504
|
-
for (let r = 0; r <=
|
|
505
|
-
if (await
|
|
502
|
+
async function ut(t, e, n = "SHA-256", o = lt) {
|
|
503
|
+
const i = Date.now();
|
|
504
|
+
for (let r = 0; r <= o; r++)
|
|
505
|
+
if (await _e(e, r, n) === t)
|
|
506
506
|
return {
|
|
507
507
|
number: r,
|
|
508
|
-
took: Date.now() -
|
|
508
|
+
took: Date.now() - i
|
|
509
509
|
};
|
|
510
510
|
return null;
|
|
511
511
|
}
|
|
512
512
|
var p = /* @__PURE__ */ ((t) => (t.ERROR = "error", t.VERIFIED = "verified", t.VERIFYING = "verifying", t.UNVERIFIED = "unverified", t))(p || {});
|
|
513
513
|
function ft(t) {
|
|
514
|
-
Ve(t, "svelte-
|
|
514
|
+
Ve(t, "svelte-vuofbg", ".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}");
|
|
515
515
|
}
|
|
516
516
|
function ce(t) {
|
|
517
|
-
let e, n,
|
|
517
|
+
let e, n, o;
|
|
518
518
|
return {
|
|
519
519
|
c() {
|
|
520
|
-
e = G("svg"), n = G("path"),
|
|
520
|
+
e = G("svg"), n = G("path"), o = 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(o, "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(o, "fill", "currentColor"), c(o, "class", "altcha-spinner svelte-vuofbg"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg");
|
|
521
521
|
},
|
|
522
|
-
m(
|
|
523
|
-
R(
|
|
522
|
+
m(i, r) {
|
|
523
|
+
R(i, e, r), b(e, n), b(e, o);
|
|
524
524
|
},
|
|
525
|
-
d(
|
|
526
|
-
|
|
525
|
+
d(i) {
|
|
526
|
+
i && L(e);
|
|
527
527
|
}
|
|
528
528
|
};
|
|
529
529
|
}
|
|
@@ -531,24 +531,24 @@ function ht(t) {
|
|
|
531
531
|
let e, n = (
|
|
532
532
|
/*_strings*/
|
|
533
533
|
t[9].label + ""
|
|
534
|
-
),
|
|
534
|
+
), o;
|
|
535
535
|
return {
|
|
536
536
|
c() {
|
|
537
|
-
e =
|
|
538
|
-
t[3] + "_checkbox"), c(e, "class", "svelte-
|
|
537
|
+
e = w("label"), c(e, "for", o = /*name*/
|
|
538
|
+
t[3] + "_checkbox"), c(e, "class", "svelte-vuofbg");
|
|
539
539
|
},
|
|
540
|
-
m(
|
|
541
|
-
R(
|
|
540
|
+
m(i, r) {
|
|
541
|
+
R(i, e, r), e.innerHTML = n;
|
|
542
542
|
},
|
|
543
|
-
p(
|
|
543
|
+
p(i, r) {
|
|
544
544
|
r[0] & /*_strings*/
|
|
545
545
|
512 && n !== (n = /*_strings*/
|
|
546
|
-
|
|
547
|
-
8 &&
|
|
548
|
-
|
|
546
|
+
i[9].label + "") && (e.innerHTML = n), r[0] & /*name*/
|
|
547
|
+
8 && o !== (o = /*name*/
|
|
548
|
+
i[3] + "_checkbox") && c(e, "for", o);
|
|
549
549
|
},
|
|
550
|
-
d(
|
|
551
|
-
|
|
550
|
+
d(i) {
|
|
551
|
+
i && L(e);
|
|
552
552
|
}
|
|
553
553
|
};
|
|
554
554
|
}
|
|
@@ -559,65 +559,65 @@ function dt(t) {
|
|
|
559
559
|
);
|
|
560
560
|
return {
|
|
561
561
|
c() {
|
|
562
|
-
e =
|
|
562
|
+
e = w("span");
|
|
563
563
|
},
|
|
564
|
-
m(
|
|
565
|
-
R(
|
|
564
|
+
m(o, i) {
|
|
565
|
+
R(o, e, i), e.innerHTML = n;
|
|
566
566
|
},
|
|
567
|
-
p(
|
|
568
|
-
|
|
567
|
+
p(o, i) {
|
|
568
|
+
i[0] & /*_strings*/
|
|
569
569
|
512 && n !== (n = /*_strings*/
|
|
570
|
-
|
|
570
|
+
o[9].verifying + "") && (e.innerHTML = n);
|
|
571
571
|
},
|
|
572
|
-
d(
|
|
573
|
-
|
|
572
|
+
d(o) {
|
|
573
|
+
o && L(e);
|
|
574
574
|
}
|
|
575
575
|
};
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function gt(t) {
|
|
578
578
|
let e, n = (
|
|
579
579
|
/*_strings*/
|
|
580
580
|
t[9].verified + ""
|
|
581
|
-
),
|
|
581
|
+
), o, i;
|
|
582
582
|
return {
|
|
583
583
|
c() {
|
|
584
|
-
e =
|
|
585
|
-
|
|
584
|
+
e = w("span"), o = M(), i = w("input"), c(i, "type", "hidden"), c(
|
|
585
|
+
i,
|
|
586
586
|
"name",
|
|
587
587
|
/*name*/
|
|
588
588
|
t[3]
|
|
589
|
-
),
|
|
589
|
+
), i.value = /*payload*/
|
|
590
590
|
t[4];
|
|
591
591
|
},
|
|
592
592
|
m(r, s) {
|
|
593
|
-
R(r, e, s), e.innerHTML = n, R(r,
|
|
593
|
+
R(r, e, s), e.innerHTML = n, R(r, o, s), R(r, i, s);
|
|
594
594
|
},
|
|
595
595
|
p(r, s) {
|
|
596
596
|
s[0] & /*_strings*/
|
|
597
597
|
512 && n !== (n = /*_strings*/
|
|
598
598
|
r[9].verified + "") && (e.innerHTML = n), s[0] & /*name*/
|
|
599
599
|
8 && c(
|
|
600
|
-
|
|
600
|
+
i,
|
|
601
601
|
"name",
|
|
602
602
|
/*name*/
|
|
603
603
|
r[3]
|
|
604
604
|
), s[0] & /*payload*/
|
|
605
|
-
16 && (
|
|
605
|
+
16 && (i.value = /*payload*/
|
|
606
606
|
r[4]);
|
|
607
607
|
},
|
|
608
608
|
d(r) {
|
|
609
|
-
r && (L(e), L(
|
|
609
|
+
r && (L(e), L(o), L(i));
|
|
610
610
|
}
|
|
611
611
|
};
|
|
612
612
|
}
|
|
613
613
|
function ae(t) {
|
|
614
|
-
let e, n,
|
|
614
|
+
let e, n, o, i, r, s;
|
|
615
615
|
return {
|
|
616
616
|
c() {
|
|
617
|
-
e =
|
|
617
|
+
e = w("div"), n = w("a"), o = G("svg"), i = G("path"), r = G("path"), s = G("path"), c(i, "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(i, "fill", "currentColor"), c(r, "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(r, "fill", "currentColor"), c(s, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), c(s, "fill", "currentColor"), c(o, "width", "22"), c(o, "height", "22"), c(o, "viewBox", "0 0 20 20"), c(o, "fill", "none"), c(o, "xmlns", "http://www.w3.org/2000/svg"), c(n, "href", we), c(n, "target", "_blank"), c(n, "class", "altcha-logo svelte-vuofbg");
|
|
618
618
|
},
|
|
619
619
|
m(a, f) {
|
|
620
|
-
R(a, e, f),
|
|
620
|
+
R(a, e, f), b(e, n), b(n, o), b(o, i), b(o, r), b(o, s);
|
|
621
621
|
},
|
|
622
622
|
p: Z,
|
|
623
623
|
d(a) {
|
|
@@ -626,21 +626,21 @@ function ae(t) {
|
|
|
626
626
|
};
|
|
627
627
|
}
|
|
628
628
|
function ue(t) {
|
|
629
|
-
let e, n,
|
|
629
|
+
let e, n, o, i, r, s = (
|
|
630
630
|
/*_strings*/
|
|
631
631
|
t[9].error + ""
|
|
632
632
|
);
|
|
633
633
|
return {
|
|
634
634
|
c() {
|
|
635
|
-
e =
|
|
635
|
+
e = w("div"), n = G("svg"), o = G("path"), i = M(), r = w("div"), c(o, "stroke-linecap", "round"), c(o, "stroke-linejoin", "round"), c(o, "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(
|
|
636
636
|
r,
|
|
637
637
|
"title",
|
|
638
638
|
/*error*/
|
|
639
639
|
t[8]
|
|
640
|
-
), c(e, "class", "altcha-error svelte-
|
|
640
|
+
), c(e, "class", "altcha-error svelte-vuofbg");
|
|
641
641
|
},
|
|
642
642
|
m(a, f) {
|
|
643
|
-
R(a, e, f),
|
|
643
|
+
R(a, e, f), b(e, n), b(n, o), b(e, i), b(e, r), r.innerHTML = s;
|
|
644
644
|
},
|
|
645
645
|
p(a, f) {
|
|
646
646
|
f[0] & /*_strings*/
|
|
@@ -659,42 +659,42 @@ function ue(t) {
|
|
|
659
659
|
};
|
|
660
660
|
}
|
|
661
661
|
function fe(t) {
|
|
662
|
-
let e, n,
|
|
662
|
+
let e, n, o = (
|
|
663
663
|
/*_strings*/
|
|
664
664
|
t[9].footer + ""
|
|
665
665
|
);
|
|
666
666
|
return {
|
|
667
667
|
c() {
|
|
668
|
-
e =
|
|
668
|
+
e = w("div"), n = w("div"), c(n, "class", "svelte-vuofbg"), c(e, "class", "altcha-footer svelte-vuofbg");
|
|
669
669
|
},
|
|
670
|
-
m(
|
|
671
|
-
R(
|
|
670
|
+
m(i, r) {
|
|
671
|
+
R(i, e, r), b(e, n), n.innerHTML = o;
|
|
672
672
|
},
|
|
673
|
-
p(
|
|
673
|
+
p(i, r) {
|
|
674
674
|
r[0] & /*_strings*/
|
|
675
|
-
512 &&
|
|
676
|
-
|
|
675
|
+
512 && o !== (o = /*_strings*/
|
|
676
|
+
i[9].footer + "") && (n.innerHTML = o);
|
|
677
677
|
},
|
|
678
|
-
d(
|
|
679
|
-
|
|
678
|
+
d(i) {
|
|
679
|
+
i && L(e);
|
|
680
680
|
}
|
|
681
681
|
};
|
|
682
682
|
}
|
|
683
|
-
function
|
|
684
|
-
let e, n,
|
|
683
|
+
function bt(t) {
|
|
684
|
+
let e, n, o, i, r, s, a, f, u, N, y, j, I, A, $ = (
|
|
685
685
|
/*state*/
|
|
686
686
|
t[5] === p.VERIFYING && ce()
|
|
687
687
|
);
|
|
688
|
-
function S(h,
|
|
688
|
+
function S(h, v) {
|
|
689
689
|
return (
|
|
690
690
|
/*state*/
|
|
691
|
-
h[5] === p.VERIFIED ?
|
|
691
|
+
h[5] === p.VERIFIED ? gt : (
|
|
692
692
|
/*state*/
|
|
693
693
|
h[5] === p.VERIFYING ? dt : ht
|
|
694
694
|
)
|
|
695
695
|
);
|
|
696
696
|
}
|
|
697
|
-
let V = S(t), k = V(t),
|
|
697
|
+
let V = S(t), k = V(t), g = (
|
|
698
698
|
/*hidelogo*/
|
|
699
699
|
t[2] !== !0 && ae()
|
|
700
700
|
), m = (
|
|
@@ -707,23 +707,23 @@ function gt(t) {
|
|
|
707
707
|
);
|
|
708
708
|
return {
|
|
709
709
|
c() {
|
|
710
|
-
e =
|
|
710
|
+
e = w("div"), n = w("div"), $ && $.c(), o = M(), i = w("div"), r = w("input"), f = M(), u = w("div"), k.c(), N = M(), g && g.c(), y = M(), m && m.c(), j = M(), d && d.c(), c(r, "type", "checkbox"), c(r, "id", s = /*name*/
|
|
711
711
|
t[3] + "_checkbox"), r.required = a = /*auto*/
|
|
712
|
-
t[0] !== "onsubmit", c(r, "class", "svelte-
|
|
713
|
-
|
|
712
|
+
t[0] !== "onsubmit", c(r, "class", "svelte-vuofbg"), c(i, "class", "altcha-checkbox svelte-vuofbg"), ie(
|
|
713
|
+
i,
|
|
714
714
|
"altcha-hidden",
|
|
715
715
|
/*state*/
|
|
716
716
|
t[5] === p.VERIFYING
|
|
717
|
-
), c(u, "class", "altcha-label svelte-
|
|
717
|
+
), c(u, "class", "altcha-label svelte-vuofbg"), c(n, "class", "altcha-main svelte-vuofbg"), c(e, "class", "altcha svelte-vuofbg"), c(
|
|
718
718
|
e,
|
|
719
719
|
"data-state",
|
|
720
720
|
/*state*/
|
|
721
721
|
t[5]
|
|
722
722
|
);
|
|
723
723
|
},
|
|
724
|
-
m(h,
|
|
725
|
-
R(h, e,
|
|
726
|
-
t[6],
|
|
724
|
+
m(h, v) {
|
|
725
|
+
R(h, e, v), b(e, n), $ && $.m(n, null), b(n, o), b(n, i), b(i, r), r.checked = /*checked*/
|
|
726
|
+
t[6], b(n, f), b(n, u), k.m(u, null), b(n, N), g && g.m(n, null), b(e, y), m && m.m(e, null), b(e, j), d && d.m(e, null), t[23](e), I || (A = [
|
|
727
727
|
K(
|
|
728
728
|
r,
|
|
729
729
|
"change",
|
|
@@ -744,25 +744,25 @@ function gt(t) {
|
|
|
744
744
|
)
|
|
745
745
|
], I = !0);
|
|
746
746
|
},
|
|
747
|
-
p(h,
|
|
747
|
+
p(h, v) {
|
|
748
748
|
/*state*/
|
|
749
|
-
h[5] === p.VERIFYING ?
|
|
749
|
+
h[5] === p.VERIFYING ? $ || ($ = ce(), $.c(), $.m(n, o)) : $ && ($.d(1), $ = null), v[0] & /*name*/
|
|
750
750
|
8 && s !== (s = /*name*/
|
|
751
|
-
h[3] + "_checkbox") && c(r, "id", s),
|
|
751
|
+
h[3] + "_checkbox") && c(r, "id", s), v[0] & /*auto*/
|
|
752
752
|
1 && a !== (a = /*auto*/
|
|
753
|
-
h[0] !== "onsubmit") && (r.required = a),
|
|
753
|
+
h[0] !== "onsubmit") && (r.required = a), v[0] & /*checked*/
|
|
754
754
|
64 && (r.checked = /*checked*/
|
|
755
|
-
h[6]),
|
|
756
|
-
32 &&
|
|
757
|
-
|
|
755
|
+
h[6]), v[0] & /*state*/
|
|
756
|
+
32 && ie(
|
|
757
|
+
i,
|
|
758
758
|
"altcha-hidden",
|
|
759
759
|
/*state*/
|
|
760
760
|
h[5] === p.VERIFYING
|
|
761
|
-
), V === (V = S(h)) && k ? k.p(h,
|
|
762
|
-
h[2] !== !0 ?
|
|
763
|
-
h[8] ? m ? m.p(h,
|
|
761
|
+
), V === (V = S(h)) && k ? k.p(h, v) : (k.d(1), k = V(h), k && (k.c(), k.m(u, null))), /*hidelogo*/
|
|
762
|
+
h[2] !== !0 ? g ? g.p(h, v) : (g = ae(), g.c(), g.m(n, null)) : g && (g.d(1), g = null), /*error*/
|
|
763
|
+
h[8] ? m ? m.p(h, v) : (m = ue(h), m.c(), m.m(e, j)) : m && (m.d(1), m = null), /*_strings*/
|
|
764
764
|
h[9].footer && /*hidefooter*/
|
|
765
|
-
h[1] !== !0 ? d ? d.p(h,
|
|
765
|
+
h[1] !== !0 ? d ? d.p(h, v) : (d = fe(h), d.c(), d.m(e, null)) : d && (d.d(1), d = null), v[0] & /*state*/
|
|
766
766
|
32 && c(
|
|
767
767
|
e,
|
|
768
768
|
"data-state",
|
|
@@ -773,151 +773,151 @@ function gt(t) {
|
|
|
773
773
|
i: Z,
|
|
774
774
|
o: Z,
|
|
775
775
|
d(h) {
|
|
776
|
-
h && L(e),
|
|
776
|
+
h && L(e), $ && $.d(), k.d(), g && g.d(), m && m.d(), d && d.d(), t[23](null), I = !1, W(A);
|
|
777
777
|
}
|
|
778
778
|
};
|
|
779
779
|
}
|
|
780
|
-
const
|
|
780
|
+
const we = "https://altcha.org/";
|
|
781
781
|
function he(t) {
|
|
782
782
|
return JSON.parse(t);
|
|
783
783
|
}
|
|
784
784
|
function mt(t, e, n) {
|
|
785
|
-
let
|
|
785
|
+
let o, i, r, { auto: s = void 0 } = e, { challengeurl: a = void 0 } = e, { challengejson: f = void 0 } = e, { debug: u = !1 } = e, { hidefooter: N = !1 } = e, { hidelogo: y = !1 } = e, { name: j = "altcha" } = e, { maxnumber: I = void 0 } = e, { mockerror: A = !1 } = e, { strings: $ = void 0 } = e, { test: S = !1 } = e;
|
|
786
786
|
const V = Pe(), k = ["SHA-256", "SHA-384", "SHA-512"];
|
|
787
|
-
let
|
|
787
|
+
let g = !1, m, d = null, h = null, v = null, U = p.UNVERIFIED;
|
|
788
788
|
We(() => {
|
|
789
789
|
d && (d.removeEventListener("submit", te), d.removeEventListener("reset", ne), d = null);
|
|
790
790
|
}), He(() => {
|
|
791
|
-
E("mounted", "0.1.
|
|
791
|
+
E("mounted", "0.1.8"), S && E("using test mode"), s !== void 0 && E("auto", s), d = m.closest("form"), d && (d.addEventListener("submit", te), d.addEventListener("reset", ne)), s === "onload" && P();
|
|
792
792
|
});
|
|
793
|
-
function E(...
|
|
794
|
-
(u ||
|
|
793
|
+
function E(...l) {
|
|
794
|
+
(u || l.some((_) => _ instanceof Error)) && console[l[0] instanceof Error ? "error" : "log"]("ALTCHA", ...l);
|
|
795
795
|
}
|
|
796
|
-
function te(
|
|
797
|
-
d && s === "onsubmit" && U === p.UNVERIFIED && (
|
|
796
|
+
function te(l) {
|
|
797
|
+
d && s === "onsubmit" && U === p.UNVERIFIED && (l.preventDefault(), l.stopPropagation(), P().then(() => {
|
|
798
798
|
d == null || d.requestSubmit();
|
|
799
799
|
}));
|
|
800
800
|
}
|
|
801
801
|
function ne() {
|
|
802
802
|
X();
|
|
803
803
|
}
|
|
804
|
-
function pe(
|
|
804
|
+
function pe(l, _) {
|
|
805
805
|
return btoa(JSON.stringify({
|
|
806
|
-
algorithm:
|
|
807
|
-
challenge:
|
|
808
|
-
number:
|
|
809
|
-
salt:
|
|
810
|
-
signature:
|
|
806
|
+
algorithm: l.algorithm,
|
|
807
|
+
challenge: l.challenge,
|
|
808
|
+
number: _.number,
|
|
809
|
+
salt: l.salt,
|
|
810
|
+
signature: l.signature,
|
|
811
811
|
test: S ? !0 : void 0,
|
|
812
|
-
took:
|
|
812
|
+
took: _.took
|
|
813
813
|
}));
|
|
814
814
|
}
|
|
815
|
-
function ye(
|
|
816
|
-
if (!
|
|
815
|
+
function ye(l) {
|
|
816
|
+
if (!l.algorithm)
|
|
817
817
|
throw new Error("Invalid challenge. Property algorithm is missing.");
|
|
818
|
-
if (
|
|
818
|
+
if (l.signature === void 0)
|
|
819
819
|
throw new Error("Invalid challenge. Property signature is missing.");
|
|
820
|
-
if (!k.includes(
|
|
820
|
+
if (!k.includes(l.algorithm.toUpperCase()))
|
|
821
821
|
throw new Error(`Unknown algorithm value. Allowed values: ${k.join(", ")}`);
|
|
822
|
-
if (!
|
|
822
|
+
if (!l.challenge || l.challenge.length < 40)
|
|
823
823
|
throw new Error("Challenge is too short. Min. 40 chars.");
|
|
824
|
-
if (!
|
|
824
|
+
if (!l.salt || l.salt.length < 10)
|
|
825
825
|
throw new Error("Salt is too short. Min. 10 chars.");
|
|
826
826
|
}
|
|
827
827
|
async function ke() {
|
|
828
828
|
if (A)
|
|
829
829
|
throw E("mocking error"), new Error("Mocked error.");
|
|
830
|
-
if (
|
|
831
|
-
return E("using provided json data"),
|
|
830
|
+
if (o)
|
|
831
|
+
return E("using provided json data"), o;
|
|
832
832
|
if (S)
|
|
833
833
|
return E("generating test challenge"), at();
|
|
834
834
|
{
|
|
835
835
|
if (!a)
|
|
836
836
|
throw new Error("Attribute challengeurl not set.");
|
|
837
837
|
E("fetching challenge from", a);
|
|
838
|
-
const
|
|
839
|
-
if (
|
|
840
|
-
throw new Error(`Server responded with ${
|
|
841
|
-
return
|
|
838
|
+
const l = await fetch(a);
|
|
839
|
+
if (l.status !== 200)
|
|
840
|
+
throw new Error(`Server responded with ${l.status}.`);
|
|
841
|
+
return l.json();
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
|
-
async function Ee(
|
|
845
|
-
let
|
|
844
|
+
async function Ee(l) {
|
|
845
|
+
let _ = null;
|
|
846
846
|
if ("Worker" in window) {
|
|
847
847
|
try {
|
|
848
|
-
|
|
848
|
+
_ = await Ce(l.challenge, l.salt, l.algorithm);
|
|
849
849
|
} catch (D) {
|
|
850
850
|
E(D);
|
|
851
851
|
}
|
|
852
|
-
if ((
|
|
853
|
-
return { data:
|
|
852
|
+
if ((_ == null ? void 0 : _.number) !== void 0)
|
|
853
|
+
return { data: l, solution: _ };
|
|
854
854
|
}
|
|
855
855
|
return {
|
|
856
|
-
data:
|
|
857
|
-
solution: await ut(
|
|
856
|
+
data: l,
|
|
857
|
+
solution: await ut(l.challenge, l.salt, l.algorithm, I)
|
|
858
858
|
};
|
|
859
859
|
}
|
|
860
|
-
async function Ce(
|
|
861
|
-
const re = new
|
|
860
|
+
async function Ce(l, _, D) {
|
|
861
|
+
const re = new it();
|
|
862
862
|
return new Promise((Ne) => {
|
|
863
863
|
re.addEventListener("message", (je) => {
|
|
864
864
|
Ne(je.data);
|
|
865
|
-
}), re.postMessage({ alg: D, challenge:
|
|
865
|
+
}), re.postMessage({ alg: D, challenge: l, max: I, salt: _ });
|
|
866
866
|
});
|
|
867
867
|
}
|
|
868
868
|
function xe() {
|
|
869
|
-
[p.UNVERIFIED, p.ERROR].includes(U) ? P() : n(6,
|
|
869
|
+
[p.UNVERIFIED, p.ERROR].includes(U) ? P() : n(6, g = !0);
|
|
870
870
|
}
|
|
871
871
|
function Le() {
|
|
872
872
|
U === p.VERIFYING && alert(r.waitAlert);
|
|
873
873
|
}
|
|
874
|
-
function X(
|
|
875
|
-
n(6,
|
|
874
|
+
function X(l = p.UNVERIFIED) {
|
|
875
|
+
n(6, g = !1), n(8, h = null), n(4, v = null), n(5, U = l);
|
|
876
876
|
}
|
|
877
877
|
async function P() {
|
|
878
|
-
return X(p.VERIFYING), ke().then((
|
|
879
|
-
if (E("solution",
|
|
880
|
-
E("verified"), n(5, U = p.VERIFIED), n(6,
|
|
881
|
-
V("verified", { payload:
|
|
878
|
+
return X(p.VERIFYING), ke().then((l) => (ye(l), E("challenge", l), Ee(l))).then(({ data: l, solution: _ }) => {
|
|
879
|
+
if (E("solution", _), (_ == null ? void 0 : _.number) !== void 0)
|
|
880
|
+
E("verified"), n(5, U = p.VERIFIED), n(6, g = !0), n(4, v = pe(l, _)), E("payload", v), Te().then(() => {
|
|
881
|
+
V("verified", { payload: v });
|
|
882
882
|
});
|
|
883
883
|
else
|
|
884
884
|
throw new Error("Unexpected result returned.");
|
|
885
|
-
}).catch((
|
|
886
|
-
E(
|
|
885
|
+
}).catch((l) => {
|
|
886
|
+
E(l), n(5, U = p.ERROR), n(6, g = !1), n(8, h = l);
|
|
887
887
|
});
|
|
888
888
|
}
|
|
889
889
|
function Ie() {
|
|
890
|
-
|
|
890
|
+
g = this.checked, n(6, g);
|
|
891
891
|
}
|
|
892
|
-
function Re(
|
|
893
|
-
J[
|
|
894
|
-
m =
|
|
892
|
+
function Re(l) {
|
|
893
|
+
J[l ? "unshift" : "push"](() => {
|
|
894
|
+
m = l, n(7, m);
|
|
895
895
|
});
|
|
896
896
|
}
|
|
897
|
-
return t.$$set = (
|
|
898
|
-
"auto" in
|
|
897
|
+
return t.$$set = (l) => {
|
|
898
|
+
"auto" in l && n(0, s = l.auto), "challengeurl" in l && n(12, a = l.challengeurl), "challengejson" in l && n(13, f = l.challengejson), "debug" in l && n(14, u = l.debug), "hidefooter" in l && n(1, N = l.hidefooter), "hidelogo" in l && n(2, y = l.hidelogo), "name" in l && n(3, j = l.name), "maxnumber" in l && n(15, I = l.maxnumber), "mockerror" in l && n(16, A = l.mockerror), "strings" in l && n(17, $ = l.strings), "test" in l && n(18, S = l.test);
|
|
899
899
|
}, t.$$.update = () => {
|
|
900
900
|
t.$$.dirty[0] & /*challengejson*/
|
|
901
|
-
8192 && (
|
|
902
|
-
131072 && n(21,
|
|
901
|
+
8192 && (o = f ? he(f) : void 0), t.$$.dirty[0] & /*strings*/
|
|
902
|
+
131072 && n(21, i = $ ? he($) : {}), t.$$.dirty[0] & /*parsedStrings*/
|
|
903
903
|
2097152 && n(9, r = {
|
|
904
904
|
error: "Verification failed. Try again later.",
|
|
905
|
-
footer: `Protected by <a href="${
|
|
905
|
+
footer: `Protected by <a href="${we}" target="_blank">ALTCHA</a>`,
|
|
906
906
|
label: "I'm not a robot",
|
|
907
907
|
verified: "Verified",
|
|
908
908
|
verifying: "Verifying...",
|
|
909
909
|
waitAlert: "Verifying... please wait.",
|
|
910
|
-
...
|
|
910
|
+
...i
|
|
911
911
|
}), t.$$.dirty[0] & /*payload, state*/
|
|
912
|
-
48 && V("statechange", { payload:
|
|
912
|
+
48 && V("statechange", { payload: v, state: U });
|
|
913
913
|
}, [
|
|
914
914
|
s,
|
|
915
915
|
N,
|
|
916
916
|
y,
|
|
917
917
|
j,
|
|
918
|
-
w,
|
|
919
|
-
U,
|
|
920
918
|
v,
|
|
919
|
+
U,
|
|
920
|
+
g,
|
|
921
921
|
m,
|
|
922
922
|
h,
|
|
923
923
|
r,
|
|
@@ -928,22 +928,22 @@ function mt(t, e, n) {
|
|
|
928
928
|
u,
|
|
929
929
|
I,
|
|
930
930
|
A,
|
|
931
|
-
|
|
931
|
+
$,
|
|
932
932
|
S,
|
|
933
933
|
X,
|
|
934
934
|
P,
|
|
935
|
-
|
|
935
|
+
i,
|
|
936
936
|
Ie,
|
|
937
937
|
Re
|
|
938
938
|
];
|
|
939
939
|
}
|
|
940
|
-
class
|
|
940
|
+
class vt extends nt {
|
|
941
941
|
constructor(e) {
|
|
942
942
|
super(), et(
|
|
943
943
|
this,
|
|
944
944
|
e,
|
|
945
945
|
mt,
|
|
946
|
-
|
|
946
|
+
bt,
|
|
947
947
|
Se,
|
|
948
948
|
{
|
|
949
949
|
auto: 0,
|
|
@@ -1037,7 +1037,7 @@ class wt extends nt {
|
|
|
1037
1037
|
return this.$$.ctx[20];
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
|
-
customElements.define("altcha-widget", tt(
|
|
1040
|
+
customElements.define("altcha-widget", tt(vt, { auto: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, strings: {}, test: { type: "Boolean" } }, [], ["reset", "verify"], !1));
|
|
1041
1041
|
export {
|
|
1042
|
-
|
|
1042
|
+
vt as Altcha
|
|
1043
1043
|
};
|
package/dist/altcha.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(L,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(L=typeof globalThis<"u"?globalThis:L||self,b(L.altcha={}))})(this,function(L){"use strict";var wt=Object.defineProperty;var bt=(L,b,U)=>b in L?wt(L,b,{enumerable:!0,configurable:!0,writable:!0,value:U}):L[b]=U;var R=(L,b,U)=>(bt(L,typeof b!="symbol"?b+"":b,U),U);function b(){}function U(t){return t()}function re(){return Object.create(null)}function W(t){t.forEach(U)}function ie(t){return typeof t=="function"}function ke(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Ee(t){return Object.keys(t).length===0}function v(t,e){t.appendChild(e)}function Ce(t,e,n){const i=xe(t);if(!i.getElementById(e)){const l=p("style");l.id=e,l.textContent=n,Le(i,l)}}function xe(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Le(t,e){return v(t.head||t,e),e.sheet}function N(t,e,n){t.insertBefore(e,n||null)}function I(t){t.parentNode&&t.parentNode.removeChild(t)}function p(t){return document.createElement(t)}function G(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Ie(t){return document.createTextNode(t)}function F(){return Ie(" ")}function K(t,e,n,i){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n,i)}function c(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Re(t){return Array.from(t.childNodes)}function le(t,e,n){t.classList.toggle(e,!!n)}function Ne(t,e,{bubbles:n=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:i})}function je(t){const e={};return t.childNodes.forEach(n=>{e[n.slot||"default"]=!0}),e}let T;function P(t){T=t}function z(){if(!T)throw new Error("Function called outside component initialization");return T}function Ae(t){z().$$.on_mount.push(t)}function Ge(t){z().$$.on_destroy.push(t)}function Se(){const t=z();return(e,n,{cancelable:i=!1}={})=>{const l=t.$$.callbacks[e];if(l){const r=Ne(e,n,{cancelable:i});return l.slice().forEach(s=>{s.call(t,r)}),!r.defaultPrevented}return!0}}const Z=[],J=[];let B=[];const oe=[],se=Promise.resolve();let Q=!1;function ce(){Q||(Q=!0,se.then(E))}function Me(){return ce(),se}function q(t){B.push(t)}const ee=new Set;let H=0;function E(){if(H!==0)return;const t=T;do{try{for(;H<Z.length;){const e=Z[H];H++,P(e),Ue(e.$$)}}catch(e){throw Z.length=0,H=0,e}for(P(null),Z.length=0,H=0;J.length;)J.pop()();for(let e=0;e<B.length;e+=1){const n=B[e];ee.has(n)||(ee.add(n),n())}B.length=0}while(Z.length);for(;oe.length;)oe.pop()();Q=!1,ee.clear(),P(t)}function Ue(t){if(t.fragment!==null){t.update(),W(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(q)}}function Ve(t){const e=[],n=[];B.forEach(i=>t.indexOf(i)===-1?e.push(i):n.push(i)),n.forEach(i=>i()),B=e}const Oe=new Set;function Fe(t,e){t&&t.i&&(Oe.delete(t),t.i(e))}function Ye(t,e,n){const{fragment:i,after_update:l}=t.$$;i&&i.m(e,n),q(()=>{const r=t.$$.on_mount.map(U).filter(ie);t.$$.on_destroy?t.$$.on_destroy.push(...r):W(r),t.$$.on_mount=[]}),l.forEach(q)}function Ze(t,e){const n=t.$$;n.fragment!==null&&(Ve(n.after_update),W(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Be(t,e){t.$$.dirty[0]===-1&&(Z.push(t),ce(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function He(t,e,n,i,l,r,s=null,a=[-1]){const f=T;P(t);const u=t.$$={fragment:null,ctx:[],props:r,update:b,not_equal:l,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(f?f.$$.context:[])),callbacks:re(),dirty:a,skip_bound:!1,root:e.target||f.$$.root};s&&s(u.root);let A=!1;if(u.ctx=n?n(t,e.props||{},(k,S,...j)=>{const M=j.length?j[0]:S;return u.ctx&&l(u.ctx[k],u.ctx[k]=M)&&(!u.skip_bound&&u.bound[k]&&u.bound[k](M),A&&Be(t,k)),S}):[],u.update(),A=!0,W(u.before_update),u.fragment=i?i(u.ctx):!1,e.target){if(e.hydrate){const k=Re(e.target);u.fragment&&u.fragment.l(k),k.forEach(I)}else u.fragment&&u.fragment.c();e.intro&&Fe(t.$$.fragment),Ye(t,e.target,e.anchor),E()}P(f)}let ae;typeof HTMLElement=="function"&&(ae=class extends HTMLElement{constructor(e,n,i){super();R(this,"$$ctor");R(this,"$$s");R(this,"$$c");R(this,"$$cn",!1);R(this,"$$d",{});R(this,"$$r",!1);R(this,"$$p_d",{});R(this,"$$l",{});R(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=n,i&&this.attachShadow({mode:"open"})}addEventListener(e,n,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(n),this.$$c){const l=this.$$c.$on(e,n);this.$$l_u.set(n,l)}super.addEventListener(e,n,i)}removeEventListener(e,n,i){if(super.removeEventListener(e,n,i),this.$$c){const l=this.$$l_u.get(n);l&&(l(),this.$$l_u.delete(n))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return()=>{let s;return{c:function(){s=p("slot"),r!=="default"&&c(s,"name",r)},m:function(u,A){N(u,s,A)},d:function(u){u&&I(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const n={},i=je(this);for(const r of this.$$s)r in i&&(n[r]=[e(r)]);for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=X(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:n,$$scope:{ctx:[]}}});const l=()=>{this.$$r=!0;for(const r in this.$$p_d)if(this.$$d[r]=this.$$c.$$.ctx[this.$$c.$$.props[r]],this.$$p_d[r].reflect){const s=X(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1};this.$$c.$$.after_update.push(l),l();for(const r in this.$$l)for(const s of this.$$l[r]){const a=this.$$c.$on(r,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,n,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=X(e,i,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(n=>this.$$p_d[n].attribute===e||!this.$$p_d[n].attribute&&n.toLowerCase()===e)||e}});function X(t,e,n,i){var r;const l=(r=n[t])==null?void 0:r.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!n[t])return e;if(i==="toAttribute")switch(l){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(l){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function We(t,e,n,i,l,r){let s=class extends ae{constructor(){super(t,n,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(f){var u;f=X(a,f,e),this.$$d[a]=f,(u=this.$$c)==null||u.$set({[a]:f})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var f;return(f=this.$$c)==null?void 0:f[a]}})}),r&&(s=r(s)),t.element=s,s}class Te{constructor(){R(this,"$$");R(this,"$$set")}$destroy(){Ze(this,1),this.$destroy=b}$on(e,n){if(!ie(n))return b;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{const l=i.indexOf(n);l!==-1&&i.splice(l,1)}}$set(e){this.$$set&&!Ee(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Pe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Pe);const ue="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==",Xe=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),fe=typeof window<"u"&&window.Blob&&new Blob([Xe(ue)],{type:"text/javascript;charset=utf-8"});function De(t){let e;try{if(e=fe&&(window.URL||window.webkitURL).createObjectURL(fe),!e)throw"";const n=new Worker(e,{name:t==null?void 0:t.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),n}catch{return new Worker("data:text/javascript;base64,"+ue,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const Ke=1e7,ze=new TextEncoder;function Je(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Qe(t=1e5,e="SHA-256"){const n=Date.now().toString(16),i=Math.round(Math.random()*t),l=await he(n,i,e);return{algorithm:e,challenge:l,salt:n,signature:""}}async function he(t,e,n){return Je(await crypto.subtle.digest(n.toUpperCase(),ze.encode(t+e)))}async function qe(t,e,n="SHA-256",i=Ke){const l=Date.now();for(let r=0;r<=i;r++)if(await he(e,r,n)===t)return{number:r,took:Date.now()-l};return null}var y=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t))(y||{});function et(t){Ce(t,"svelte-1wvv726",".altcha.svelte-1wvv726.svelte-1wvv726{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 3px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-1wvv726.svelte-1wvv726:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-1wvv726.svelte-1wvv726{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-1wvv726.svelte-1wvv726{flex-grow:1}.altcha-label.svelte-1wvv726 label.svelte-1wvv726{cursor:pointer}.altcha-logo.svelte-1wvv726.svelte-1wvv726{color:currentColor;opacity:0.3}.altcha-logo.svelte-1wvv726.svelte-1wvv726:hover{opacity:1}.altcha-error.svelte-1wvv726.svelte-1wvv726{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-1wvv726.svelte-1wvv726{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-1wvv726.svelte-1wvv726:hover{opacity:1}.altcha-footer.svelte-1wvv726>.svelte-1wvv726:first-child{flex-grow:1}.altcha-footer.svelte-1wvv726 a{color:currentColor}.altcha-checkbox.svelte-1wvv726.svelte-1wvv726{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-1wvv726 input.svelte-1wvv726{width:18px;height:18px;margin:0}.altcha-hidden.svelte-1wvv726.svelte-1wvv726{display:none}.altcha-spinner.svelte-1wvv726.svelte-1wvv726{animation:svelte-1wvv726-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-1wvv726-altcha-spinner{100%{transform:rotate(360deg)}}")}function de(t){let e,n,i;return{c(){e=G("svg"),n=G("path"),i=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(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-1wvv726"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(l,r){N(l,e,r),v(e,n),v(e,i)},d(l){l&&I(e)}}}function tt(t){let e,n=t[9].label+"",i;return{c(){e=p("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-1wvv726")},m(l,r){N(l,e,r),e.innerHTML=n},p(l,r){r[0]&512&&n!==(n=l[9].label+"")&&(e.innerHTML=n),r[0]&8&&i!==(i=l[3]+"_checkbox")&&c(e,"for",i)},d(l){l&&I(e)}}}function nt(t){let e,n=t[9].verifying+"";return{c(){e=p("span")},m(i,l){N(i,e,l),e.innerHTML=n},p(i,l){l[0]&512&&n!==(n=i[9].verifying+"")&&(e.innerHTML=n)},d(i){i&&I(e)}}}function rt(t){let e,n=t[9].verified+"",i,l;return{c(){e=p("span"),i=F(),l=p("input"),c(l,"type","hidden"),c(l,"name",t[3]),l.value=t[4]},m(r,s){N(r,e,s),e.innerHTML=n,N(r,i,s),N(r,l,s)},p(r,s){s[0]&512&&n!==(n=r[9].verified+"")&&(e.innerHTML=n),s[0]&8&&c(l,"name",r[3]),s[0]&16&&(l.value=r[4])},d(r){r&&(I(e),I(i),I(l))}}}function ve(t){let e,n,i,l,r,s;return{c(){e=p("div"),n=p("a"),i=G("svg"),l=G("path"),r=G("path"),s=G("path"),c(l,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(l,"fill","currentColor"),c(r,"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(r,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(n,"href",we),c(n,"target","_blank"),c(n,"class","altcha-logo svelte-1wvv726")},m(a,f){N(a,e,f),v(e,n),v(n,i),v(i,l),v(i,r),v(i,s)},p:b,d(a){a&&I(e)}}}function ge(t){let e,n,i,l,r,s=t[9].error+"";return{c(){e=p("div"),n=G("svg"),i=G("path"),l=F(),r=p("div"),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"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(r,"title",t[8]),c(e,"class","altcha-error svelte-1wvv726")},m(a,f){N(a,e,f),v(e,n),v(n,i),v(e,l),v(e,r),r.innerHTML=s},p(a,f){f[0]&512&&s!==(s=a[9].error+"")&&(r.innerHTML=s),f[0]&256&&c(r,"title",a[8])},d(a){a&&I(e)}}}function me(t){let e,n,i=t[9].footer+"";return{c(){e=p("div"),n=p("div"),c(n,"class","svelte-1wvv726"),c(e,"class","altcha-footer svelte-1wvv726")},m(l,r){N(l,e,r),v(e,n),n.innerHTML=i},p(l,r){r[0]&512&&i!==(i=l[9].footer+"")&&(n.innerHTML=i)},d(l){l&&I(e)}}}function it(t){let e,n,i,l,r,s,a,f,u,A,k,S,j,M,$=t[5]===y.VERIFYING&&de();function V(h,w){return h[5]===y.VERIFIED?rt:h[5]===y.VERIFYING?nt:tt}let Y=V(t),C=Y(t),g=t[2]!==!0&&ve(),m=t[8]&&ge(t),d=t[9].footer&&t[1]!==!0&&me(t);return{c(){e=p("div"),n=p("div"),$&&$.c(),i=F(),l=p("div"),r=p("input"),f=F(),u=p("div"),C.c(),A=F(),g&&g.c(),k=F(),m&&m.c(),S=F(),d&&d.c(),c(r,"type","checkbox"),c(r,"id",s=t[3]+"_checkbox"),r.required=a=t[0]!=="onsubmit",c(r,"class","svelte-1wvv726"),c(l,"class","altcha-checkbox svelte-1wvv726"),le(l,"altcha-hidden",t[5]===y.VERIFYING),c(u,"class","altcha-label svelte-1wvv726"),c(n,"class","altcha-main svelte-1wvv726"),c(e,"class","altcha svelte-1wvv726"),c(e,"data-state",t[5])},m(h,w){N(h,e,w),v(e,n),$&&$.m(n,null),v(n,i),v(n,l),v(l,r),r.checked=t[6],v(n,f),v(n,u),C.m(u,null),v(n,A),g&&g.m(n,null),v(e,k),m&&m.m(e,null),v(e,S),d&&d.m(e,null),t[23](e),j||(M=[K(r,"change",t[22]),K(r,"change",t[10]),K(r,"invalid",t[11])],j=!0)},p(h,w){h[5]===y.VERIFYING?$||($=de(),$.c(),$.m(n,i)):$&&($.d(1),$=null),w[0]&8&&s!==(s=h[3]+"_checkbox")&&c(r,"id",s),w[0]&1&&a!==(a=h[0]!=="onsubmit")&&(r.required=a),w[0]&64&&(r.checked=h[6]),w[0]&32&&le(l,"altcha-hidden",h[5]===y.VERIFYING),Y===(Y=V(h))&&C?C.p(h,w):(C.d(1),C=Y(h),C&&(C.c(),C.m(u,null))),h[2]!==!0?g?g.p(h,w):(g=ve(),g.c(),g.m(n,null)):g&&(g.d(1),g=null),h[8]?m?m.p(h,w):(m=ge(h),m.c(),m.m(e,S)):m&&(m.d(1),m=null),h[9].footer&&h[1]!==!0?d?d.p(h,w):(d=me(h),d.c(),d.m(e,null)):d&&(d.d(1),d=null),w[0]&32&&c(e,"data-state",h[5])},i:b,o:b,d(h){h&&I(e),$&&$.d(),C.d(),g&&g.d(),m&&m.d(),d&&d.d(),t[23](null),j=!1,W(M)}}}const we="https://altcha.org/";function be(t){return JSON.parse(t)}function lt(t,e,n){let i,l,r,{auto:s=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:f=void 0}=e,{debug:u=!1}=e,{hidefooter:A=!1}=e,{hidelogo:k=!1}=e,{name:S="altcha"}=e,{maxnumber:j=void 0}=e,{mockerror:M=!1}=e,{strings:$=void 0}=e,{test:V=!1}=e;const Y=Se(),C=["SHA-256","SHA-384","SHA-512"];let g=!1,m,d=null,h=null,w=null,O=y.UNVERIFIED;Ge(()=>{d&&(d.removeEventListener("submit",_e),d.removeEventListener("reset",pe),d=null)}),Ae(()=>{x("mounted","0.1.7"),V&&x("using test mode"),s!==void 0&&x("auto",s),d=m.closest("form"),d&&(d.addEventListener("submit",_e),d.addEventListener("reset",pe)),s==="onload"&&D()});function x(...o){(u||o.some(_=>_ instanceof Error))&&console[o[0]instanceof Error?"error":"log"]("ALTCHA",...o)}function _e(o){d&&s==="onsubmit"&&O===y.UNVERIFIED&&(o.preventDefault(),o.stopPropagation(),D().then(()=>{d==null||d.requestSubmit()}))}function pe(){te()}function ot(o,_){return btoa(JSON.stringify({algorithm:o.algorithm,challenge:o.challenge,number:_.number,salt:o.salt,signature:o.signature,test:V?!0:void 0,took:_.took}))}function st(o){if(!o.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(o.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!C.includes(o.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${C.join(", ")}`);if(!o.challenge||o.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!o.salt||o.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function ct(){if(M)throw x("mocking error"),new Error("Mocked error.");if(i)return x("using provided json data"),i;if(V)return x("generating test challenge"),Qe();{if(!a)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",a);const o=await fetch(a);if(o.status!==200)throw new Error(`Server responded with ${o.status}.`);return o.json()}}async function at(o){let _=null;if("Worker"in window){try{_=await ut(o.challenge,o.salt,o.algorithm)}catch(ne){x(ne)}if((_==null?void 0:_.number)!==void 0)return{data:o,solution:_}}return{data:o,solution:await qe(o.challenge,o.salt,o.algorithm,j)}}async function ut(o,_,ne){const ye=new De;return new Promise(gt=>{ye.addEventListener("message",mt=>{gt(mt.data)}),ye.postMessage({alg:ne,challenge:o,max:j,salt:_})})}function ft(){[y.UNVERIFIED,y.ERROR].includes(O)?D():n(6,g=!0)}function ht(){O===y.VERIFYING&&alert(r.waitAlert)}function te(o=y.UNVERIFIED){n(6,g=!1),n(8,h=null),n(4,w=null),n(5,O=o)}async function D(){return te(y.VERIFYING),ct().then(o=>(st(o),x("challenge",o),at(o))).then(({data:o,solution:_})=>{if(x("solution",_),(_==null?void 0:_.number)!==void 0)x("verified"),n(5,O=y.VERIFIED),n(6,g=!0),n(4,w=ot(o,_)),x("payload",w),Me().then(()=>{Y("verified",{payload:w})});else throw new Error("Unexpected result returned.")}).catch(o=>{x(o),n(5,O=y.ERROR),n(6,g=!1),n(8,h=o)})}function dt(){g=this.checked,n(6,g)}function vt(o){J[o?"unshift":"push"](()=>{m=o,n(7,m)})}return t.$$set=o=>{"auto"in o&&n(0,s=o.auto),"challengeurl"in o&&n(12,a=o.challengeurl),"challengejson"in o&&n(13,f=o.challengejson),"debug"in o&&n(14,u=o.debug),"hidefooter"in o&&n(1,A=o.hidefooter),"hidelogo"in o&&n(2,k=o.hidelogo),"name"in o&&n(3,S=o.name),"maxnumber"in o&&n(15,j=o.maxnumber),"mockerror"in o&&n(16,M=o.mockerror),"strings"in o&&n(17,$=o.strings),"test"in o&&n(18,V=o.test)},t.$$.update=()=>{t.$$.dirty[0]&8192&&(i=f?be(f):void 0),t.$$.dirty[0]&131072&&n(21,l=$?be($):{}),t.$$.dirty[0]&2097152&&n(9,r={error:"Verification failed. Try again later.",footer:`Protected by <a href="${we}" target="_blank">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),t.$$.dirty[0]&48&&Y("statechange",{payload:w,state:O})},[s,A,k,S,w,O,g,m,h,r,ft,ht,a,f,u,j,M,$,V,te,D,l,dt,vt]}class $e extends Te{constructor(e){super(),He(this,e,lt,it,ke,{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},et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),E()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),E()}get challengejson(){return this.$$.ctx[13]}set challengejson(e){this.$$set({challengejson:e}),E()}get debug(){return this.$$.ctx[14]}set debug(e){this.$$set({debug:e}),E()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),E()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),E()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),E()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),E()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),E()}get strings(){return this.$$.ctx[17]}set strings(e){this.$$set({strings:e}),E()}get test(){return this.$$.ctx[18]}set test(e){this.$$set({test:e}),E()}get reset(){return this.$$.ctx[19]}get verify(){return this.$$.ctx[20]}}customElements.define("altcha-widget",We($e,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},strings:{},test:{type:"Boolean"}},[],["reset","verify"],!1)),L.Altcha=$e,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(L,$){typeof exports=="object"&&typeof module<"u"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(L=typeof globalThis<"u"?globalThis:L||self,$(L.altcha={}))})(this,function(L){"use strict";var vt=Object.defineProperty;var $t=(L,$,U)=>$ in L?vt(L,$,{enumerable:!0,configurable:!0,writable:!0,value:U}):L[$]=U;var R=(L,$,U)=>($t(L,typeof $!="symbol"?$+"":$,U),U);function $(){}function U(t){return t()}function re(){return Object.create(null)}function W(t){t.forEach(U)}function oe(t){return typeof t=="function"}function ke(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Ee(t){return Object.keys(t).length===0}function g(t,e){t.appendChild(e)}function Ce(t,e,n){const o=xe(t);if(!o.getElementById(e)){const i=p("style");i.id=e,i.textContent=n,Le(o,i)}}function xe(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Le(t,e){return g(t.head||t,e),e.sheet}function N(t,e,n){t.insertBefore(e,n||null)}function I(t){t.parentNode&&t.parentNode.removeChild(t)}function p(t){return document.createElement(t)}function G(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Ie(t){return document.createTextNode(t)}function F(){return Ie(" ")}function K(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function c(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Re(t){return Array.from(t.childNodes)}function ie(t,e,n){t.classList.toggle(e,!!n)}function Ne(t,e,{bubbles:n=!1,cancelable:o=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:o})}function je(t){const e={};return t.childNodes.forEach(n=>{e[n.slot||"default"]=!0}),e}let T;function P(t){T=t}function z(){if(!T)throw new Error("Function called outside component initialization");return T}function Ae(t){z().$$.on_mount.push(t)}function Ge(t){z().$$.on_destroy.push(t)}function Se(){const t=z();return(e,n,{cancelable:o=!1}={})=>{const i=t.$$.callbacks[e];if(i){const r=Ne(e,n,{cancelable:o});return i.slice().forEach(s=>{s.call(t,r)}),!r.defaultPrevented}return!0}}const Z=[],J=[];let B=[];const le=[],se=Promise.resolve();let Q=!1;function ce(){Q||(Q=!0,se.then(E))}function Me(){return ce(),se}function q(t){B.push(t)}const ee=new Set;let H=0;function E(){if(H!==0)return;const t=T;do{try{for(;H<Z.length;){const e=Z[H];H++,P(e),Ue(e.$$)}}catch(e){throw Z.length=0,H=0,e}for(P(null),Z.length=0,H=0;J.length;)J.pop()();for(let e=0;e<B.length;e+=1){const n=B[e];ee.has(n)||(ee.add(n),n())}B.length=0}while(Z.length);for(;le.length;)le.pop()();Q=!1,ee.clear(),P(t)}function Ue(t){if(t.fragment!==null){t.update(),W(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(q)}}function Ve(t){const e=[],n=[];B.forEach(o=>t.indexOf(o)===-1?e.push(o):n.push(o)),n.forEach(o=>o()),B=e}const Oe=new Set;function Fe(t,e){t&&t.i&&(Oe.delete(t),t.i(e))}function Ye(t,e,n){const{fragment:o,after_update:i}=t.$$;o&&o.m(e,n),q(()=>{const r=t.$$.on_mount.map(U).filter(oe);t.$$.on_destroy?t.$$.on_destroy.push(...r):W(r),t.$$.on_mount=[]}),i.forEach(q)}function Ze(t,e){const n=t.$$;n.fragment!==null&&(Ve(n.after_update),W(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Be(t,e){t.$$.dirty[0]===-1&&(Z.push(t),ce(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function He(t,e,n,o,i,r,s=null,a=[-1]){const f=T;P(t);const u=t.$$={fragment:null,ctx:[],props:r,update:$,not_equal:i,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(f?f.$$.context:[])),callbacks:re(),dirty:a,skip_bound:!1,root:e.target||f.$$.root};s&&s(u.root);let A=!1;if(u.ctx=n?n(t,e.props||{},(k,S,...j)=>{const M=j.length?j[0]:S;return u.ctx&&i(u.ctx[k],u.ctx[k]=M)&&(!u.skip_bound&&u.bound[k]&&u.bound[k](M),A&&Be(t,k)),S}):[],u.update(),A=!0,W(u.before_update),u.fragment=o?o(u.ctx):!1,e.target){if(e.hydrate){const k=Re(e.target);u.fragment&&u.fragment.l(k),k.forEach(I)}else u.fragment&&u.fragment.c();e.intro&&Fe(t.$$.fragment),Ye(t,e.target,e.anchor),E()}P(f)}let ae;typeof HTMLElement=="function"&&(ae=class extends HTMLElement{constructor(e,n,o){super();R(this,"$$ctor");R(this,"$$s");R(this,"$$c");R(this,"$$cn",!1);R(this,"$$d",{});R(this,"$$r",!1);R(this,"$$p_d",{});R(this,"$$l",{});R(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=n,o&&this.attachShadow({mode:"open"})}addEventListener(e,n,o){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(n),this.$$c){const i=this.$$c.$on(e,n);this.$$l_u.set(n,i)}super.addEventListener(e,n,o)}removeEventListener(e,n,o){if(super.removeEventListener(e,n,o),this.$$c){const i=this.$$l_u.get(n);i&&(i(),this.$$l_u.delete(n))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return()=>{let s;return{c:function(){s=p("slot"),r!=="default"&&c(s,"name",r)},m:function(u,A){N(u,s,A)},d:function(u){u&&I(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const n={},o=je(this);for(const r of this.$$s)r in o&&(n[r]=[e(r)]);for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=X(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:n,$$scope:{ctx:[]}}});const i=()=>{this.$$r=!0;for(const r in this.$$p_d)if(this.$$d[r]=this.$$c.$$.ctx[this.$$c.$$.props[r]],this.$$p_d[r].reflect){const s=X(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1};this.$$c.$$.after_update.push(i),i();for(const r in this.$$l)for(const s of this.$$l[r]){const a=this.$$c.$on(r,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,n,o){var i;this.$$r||(e=this.$$g_p(e),this.$$d[e]=X(e,o,this.$$p_d,"toProp"),(i=this.$$c)==null||i.$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(n=>this.$$p_d[n].attribute===e||!this.$$p_d[n].attribute&&n.toLowerCase()===e)||e}});function X(t,e,n,o){var r;const i=(r=n[t])==null?void 0:r.type;if(e=i==="Boolean"&&typeof e!="boolean"?e!=null:e,!o||!n[t])return e;if(o==="toAttribute")switch(i){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(i){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function We(t,e,n,o,i,r){let s=class extends ae{constructor(){super(t,n,i),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(f){var u;f=X(a,f,e),this.$$d[a]=f,(u=this.$$c)==null||u.$set({[a]:f})}})}),o.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var f;return(f=this.$$c)==null?void 0:f[a]}})}),r&&(s=r(s)),t.element=s,s}class Te{constructor(){R(this,"$$");R(this,"$$set")}$destroy(){Ze(this,1),this.$destroy=$}$on(e,n){if(!oe(n))return $;const o=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return o.push(n),()=>{const i=o.indexOf(n);i!==-1&&o.splice(i,1)}}$set(e){this.$$set&&!Ee(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Pe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Pe);const ue="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==",Xe=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),fe=typeof window<"u"&&window.Blob&&new Blob([Xe(ue)],{type:"text/javascript;charset=utf-8"});function De(t){let e;try{if(e=fe&&(window.URL||window.webkitURL).createObjectURL(fe),!e)throw"";const n=new Worker(e,{name:t==null?void 0:t.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),n}catch{return new Worker("data:text/javascript;base64,"+ue,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const Ke=1e7,ze=new TextEncoder;function Je(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Qe(t=1e5,e="SHA-256"){const n=Date.now().toString(16),o=Math.round(Math.random()*t),i=await he(n,o,e);return{algorithm:e,challenge:i,salt:n,signature:""}}async function he(t,e,n){return Je(await crypto.subtle.digest(n.toUpperCase(),ze.encode(t+e)))}async function qe(t,e,n="SHA-256",o=Ke){const i=Date.now();for(let r=0;r<=o;r++)if(await he(e,r,n)===t)return{number:r,took:Date.now()-i};return null}var y=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t))(y||{});function et(t){Ce(t,"svelte-vuofbg",".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}")}function de(t){let e,n,o;return{c(){e=G("svg"),n=G("path"),o=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(o,"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(o,"fill","currentColor"),c(o,"class","altcha-spinner svelte-vuofbg"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(i,r){N(i,e,r),g(e,n),g(e,o)},d(i){i&&I(e)}}}function tt(t){let e,n=t[9].label+"",o;return{c(){e=p("label"),c(e,"for",o=t[3]+"_checkbox"),c(e,"class","svelte-vuofbg")},m(i,r){N(i,e,r),e.innerHTML=n},p(i,r){r[0]&512&&n!==(n=i[9].label+"")&&(e.innerHTML=n),r[0]&8&&o!==(o=i[3]+"_checkbox")&&c(e,"for",o)},d(i){i&&I(e)}}}function nt(t){let e,n=t[9].verifying+"";return{c(){e=p("span")},m(o,i){N(o,e,i),e.innerHTML=n},p(o,i){i[0]&512&&n!==(n=o[9].verifying+"")&&(e.innerHTML=n)},d(o){o&&I(e)}}}function rt(t){let e,n=t[9].verified+"",o,i;return{c(){e=p("span"),o=F(),i=p("input"),c(i,"type","hidden"),c(i,"name",t[3]),i.value=t[4]},m(r,s){N(r,e,s),e.innerHTML=n,N(r,o,s),N(r,i,s)},p(r,s){s[0]&512&&n!==(n=r[9].verified+"")&&(e.innerHTML=n),s[0]&8&&c(i,"name",r[3]),s[0]&16&&(i.value=r[4])},d(r){r&&(I(e),I(o),I(i))}}}function ge(t){let e,n,o,i,r,s;return{c(){e=p("div"),n=p("a"),o=G("svg"),i=G("path"),r=G("path"),s=G("path"),c(i,"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(i,"fill","currentColor"),c(r,"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(r,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(o,"width","22"),c(o,"height","22"),c(o,"viewBox","0 0 20 20"),c(o,"fill","none"),c(o,"xmlns","http://www.w3.org/2000/svg"),c(n,"href",ve),c(n,"target","_blank"),c(n,"class","altcha-logo svelte-vuofbg")},m(a,f){N(a,e,f),g(e,n),g(n,o),g(o,i),g(o,r),g(o,s)},p:$,d(a){a&&I(e)}}}function be(t){let e,n,o,i,r,s=t[9].error+"";return{c(){e=p("div"),n=G("svg"),o=G("path"),i=F(),r=p("div"),c(o,"stroke-linecap","round"),c(o,"stroke-linejoin","round"),c(o,"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(r,"title",t[8]),c(e,"class","altcha-error svelte-vuofbg")},m(a,f){N(a,e,f),g(e,n),g(n,o),g(e,i),g(e,r),r.innerHTML=s},p(a,f){f[0]&512&&s!==(s=a[9].error+"")&&(r.innerHTML=s),f[0]&256&&c(r,"title",a[8])},d(a){a&&I(e)}}}function me(t){let e,n,o=t[9].footer+"";return{c(){e=p("div"),n=p("div"),c(n,"class","svelte-vuofbg"),c(e,"class","altcha-footer svelte-vuofbg")},m(i,r){N(i,e,r),g(e,n),n.innerHTML=o},p(i,r){r[0]&512&&o!==(o=i[9].footer+"")&&(n.innerHTML=o)},d(i){i&&I(e)}}}function ot(t){let e,n,o,i,r,s,a,f,u,A,k,S,j,M,_=t[5]===y.VERIFYING&&de();function V(h,v){return h[5]===y.VERIFIED?rt:h[5]===y.VERIFYING?nt:tt}let Y=V(t),C=Y(t),b=t[2]!==!0&&ge(),m=t[8]&&be(t),d=t[9].footer&&t[1]!==!0&&me(t);return{c(){e=p("div"),n=p("div"),_&&_.c(),o=F(),i=p("div"),r=p("input"),f=F(),u=p("div"),C.c(),A=F(),b&&b.c(),k=F(),m&&m.c(),S=F(),d&&d.c(),c(r,"type","checkbox"),c(r,"id",s=t[3]+"_checkbox"),r.required=a=t[0]!=="onsubmit",c(r,"class","svelte-vuofbg"),c(i,"class","altcha-checkbox svelte-vuofbg"),ie(i,"altcha-hidden",t[5]===y.VERIFYING),c(u,"class","altcha-label svelte-vuofbg"),c(n,"class","altcha-main svelte-vuofbg"),c(e,"class","altcha svelte-vuofbg"),c(e,"data-state",t[5])},m(h,v){N(h,e,v),g(e,n),_&&_.m(n,null),g(n,o),g(n,i),g(i,r),r.checked=t[6],g(n,f),g(n,u),C.m(u,null),g(n,A),b&&b.m(n,null),g(e,k),m&&m.m(e,null),g(e,S),d&&d.m(e,null),t[23](e),j||(M=[K(r,"change",t[22]),K(r,"change",t[10]),K(r,"invalid",t[11])],j=!0)},p(h,v){h[5]===y.VERIFYING?_||(_=de(),_.c(),_.m(n,o)):_&&(_.d(1),_=null),v[0]&8&&s!==(s=h[3]+"_checkbox")&&c(r,"id",s),v[0]&1&&a!==(a=h[0]!=="onsubmit")&&(r.required=a),v[0]&64&&(r.checked=h[6]),v[0]&32&&ie(i,"altcha-hidden",h[5]===y.VERIFYING),Y===(Y=V(h))&&C?C.p(h,v):(C.d(1),C=Y(h),C&&(C.c(),C.m(u,null))),h[2]!==!0?b?b.p(h,v):(b=ge(),b.c(),b.m(n,null)):b&&(b.d(1),b=null),h[8]?m?m.p(h,v):(m=be(h),m.c(),m.m(e,S)):m&&(m.d(1),m=null),h[9].footer&&h[1]!==!0?d?d.p(h,v):(d=me(h),d.c(),d.m(e,null)):d&&(d.d(1),d=null),v[0]&32&&c(e,"data-state",h[5])},i:$,o:$,d(h){h&&I(e),_&&_.d(),C.d(),b&&b.d(),m&&m.d(),d&&d.d(),t[23](null),j=!1,W(M)}}}const ve="https://altcha.org/";function $e(t){return JSON.parse(t)}function it(t,e,n){let o,i,r,{auto:s=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:f=void 0}=e,{debug:u=!1}=e,{hidefooter:A=!1}=e,{hidelogo:k=!1}=e,{name:S="altcha"}=e,{maxnumber:j=void 0}=e,{mockerror:M=!1}=e,{strings:_=void 0}=e,{test:V=!1}=e;const Y=Se(),C=["SHA-256","SHA-384","SHA-512"];let b=!1,m,d=null,h=null,v=null,O=y.UNVERIFIED;Ge(()=>{d&&(d.removeEventListener("submit",we),d.removeEventListener("reset",pe),d=null)}),Ae(()=>{x("mounted","0.1.8"),V&&x("using test mode"),s!==void 0&&x("auto",s),d=m.closest("form"),d&&(d.addEventListener("submit",we),d.addEventListener("reset",pe)),s==="onload"&&D()});function x(...l){(u||l.some(w=>w instanceof Error))&&console[l[0]instanceof Error?"error":"log"]("ALTCHA",...l)}function we(l){d&&s==="onsubmit"&&O===y.UNVERIFIED&&(l.preventDefault(),l.stopPropagation(),D().then(()=>{d==null||d.requestSubmit()}))}function pe(){te()}function lt(l,w){return btoa(JSON.stringify({algorithm:l.algorithm,challenge:l.challenge,number:w.number,salt:l.salt,signature:l.signature,test:V?!0:void 0,took:w.took}))}function st(l){if(!l.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(l.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!C.includes(l.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${C.join(", ")}`);if(!l.challenge||l.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!l.salt||l.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function ct(){if(M)throw x("mocking error"),new Error("Mocked error.");if(o)return x("using provided json data"),o;if(V)return x("generating test challenge"),Qe();{if(!a)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",a);const l=await fetch(a);if(l.status!==200)throw new Error(`Server responded with ${l.status}.`);return l.json()}}async function at(l){let w=null;if("Worker"in window){try{w=await ut(l.challenge,l.salt,l.algorithm)}catch(ne){x(ne)}if((w==null?void 0:w.number)!==void 0)return{data:l,solution:w}}return{data:l,solution:await qe(l.challenge,l.salt,l.algorithm,j)}}async function ut(l,w,ne){const ye=new De;return new Promise(bt=>{ye.addEventListener("message",mt=>{bt(mt.data)}),ye.postMessage({alg:ne,challenge:l,max:j,salt:w})})}function ft(){[y.UNVERIFIED,y.ERROR].includes(O)?D():n(6,b=!0)}function ht(){O===y.VERIFYING&&alert(r.waitAlert)}function te(l=y.UNVERIFIED){n(6,b=!1),n(8,h=null),n(4,v=null),n(5,O=l)}async function D(){return te(y.VERIFYING),ct().then(l=>(st(l),x("challenge",l),at(l))).then(({data:l,solution:w})=>{if(x("solution",w),(w==null?void 0:w.number)!==void 0)x("verified"),n(5,O=y.VERIFIED),n(6,b=!0),n(4,v=lt(l,w)),x("payload",v),Me().then(()=>{Y("verified",{payload:v})});else throw new Error("Unexpected result returned.")}).catch(l=>{x(l),n(5,O=y.ERROR),n(6,b=!1),n(8,h=l)})}function dt(){b=this.checked,n(6,b)}function gt(l){J[l?"unshift":"push"](()=>{m=l,n(7,m)})}return t.$$set=l=>{"auto"in l&&n(0,s=l.auto),"challengeurl"in l&&n(12,a=l.challengeurl),"challengejson"in l&&n(13,f=l.challengejson),"debug"in l&&n(14,u=l.debug),"hidefooter"in l&&n(1,A=l.hidefooter),"hidelogo"in l&&n(2,k=l.hidelogo),"name"in l&&n(3,S=l.name),"maxnumber"in l&&n(15,j=l.maxnumber),"mockerror"in l&&n(16,M=l.mockerror),"strings"in l&&n(17,_=l.strings),"test"in l&&n(18,V=l.test)},t.$$.update=()=>{t.$$.dirty[0]&8192&&(o=f?$e(f):void 0),t.$$.dirty[0]&131072&&n(21,i=_?$e(_):{}),t.$$.dirty[0]&2097152&&n(9,r={error:"Verification failed. Try again later.",footer:`Protected by <a href="${ve}" target="_blank">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...i}),t.$$.dirty[0]&48&&Y("statechange",{payload:v,state:O})},[s,A,k,S,v,O,b,m,h,r,ft,ht,a,f,u,j,M,_,V,te,D,i,dt,gt]}class _e extends Te{constructor(e){super(),He(this,e,it,ot,ke,{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},et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),E()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),E()}get challengejson(){return this.$$.ctx[13]}set challengejson(e){this.$$set({challengejson:e}),E()}get debug(){return this.$$.ctx[14]}set debug(e){this.$$set({debug:e}),E()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),E()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),E()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),E()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),E()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),E()}get strings(){return this.$$.ctx[17]}set strings(e){this.$$set({strings:e}),E()}get test(){return this.$$.ctx[18]}set test(e){this.$$set({test:e}),E()}get reset(){return this.$$.ctx[19]}get verify(){return this.$$.ctx[20]}}customElements.define("altcha-widget",We(_e,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},strings:{},test:{type:"Boolean"}},[],["reset","verify"],!1)),L.Altcha=_e,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});
|