diff --git a/dist/altcha.iife.js b/dist/altcha.iife.js index 4d8836f..7182e97 100644 --- a/dist/altcha.iife.js +++ b/dist/altcha.iife.js @@ -1 +1 @@ -var altcha=function(O){"use strict";var Ht=Object.defineProperty;var Pt=(O,S,P)=>S in O?Ht(O,S,{enumerable:!0,configurable:!0,writable:!0,value:P}):O[S]=P;var M=(O,S,P)=>(Pt(O,typeof S!="symbol"?S+"":S,P),P);function S(){}function P(r){return r()}function ye(){return Object.create(null)}function re(r){r.forEach(P)}function ve(r){return typeof r=="function"}function Be(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function Ke(r){return Object.keys(r).length===0}function v(r,e){r.appendChild(e)}function Je(r,e,t){const i=Qe(r);if(!i.getElementById(e)){const o=C("style");o.id=e,o.textContent=t,qe(i,o)}}function Qe(r){if(!r)return document;const e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function qe(r,e){return v(r.head||r,e),e.sheet}function j(r,e,t){r.insertBefore(e,t||null)}function z(r){r.parentNode&&r.parentNode.removeChild(r)}function C(r){return document.createElement(r)}function X(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function et(r){return document.createTextNode(r)}function W(){return et(" ")}function fe(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function c(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function tt(r){return Array.from(r.childNodes)}function we(r,e,t){r.classList.toggle(e,!!t)}function rt(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function nt(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ne;function ie(r){ne=r}function ue(){if(!ne)throw new Error("Function called outside component initialization");return ne}function it(r){ue().$$.on_mount.push(r)}function ot(r){ue().$$.on_destroy.push(r)}function lt(){const r=ue();return(e,t,{cancelable:i=!1}={})=>{const o=r.$$.callbacks[e];if(o){const l=rt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(r,l)}),!l.defaultPrevented}return!0}}const q=[],he=[];let ee=[];const _e=[],pe=Promise.resolve();let de=!1;function ke(){de||(de=!0,pe.then(_))}function st(){return ke(),pe}function me(r){ee.push(r)}const ge=new Set;let te=0;function _(){if(te!==0)return;const r=ne;do{try{for(;ter.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),ee=e}const ft=new Set;function ut(r,e){r&&r.i&&(ft.delete(r),r.i(e))}function ht(r,e,t){const{fragment:i,after_update:o}=r.$$;i&&i.m(e,t),me(()=>{const l=r.$$.on_mount.map(P).filter(ve);r.$$.on_destroy?r.$$.on_destroy.push(...l):re(l),r.$$.on_mount=[]}),o.forEach(me)}function dt(r,e){const t=r.$$;t.fragment!==null&&(at(t.after_update),re(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function mt(r,e){r.$$.dirty[0]===-1&&(q.push(r),ke(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<{const F=U.length?U[0]:V;return u.ctx&&o(u.ctx[L],u.ctx[L]=F)&&(!u.skip_bound&&u.bound[L]&&u.bound[L](F),Z&&mt(r,L)),V}):[],u.update(),Z=!0,re(u.before_update),u.fragment=i?i(u.ctx):!1,e.target){if(e.hydrate){const L=tt(e.target);u.fragment&&u.fragment.l(L),L.forEach(z)}else u.fragment&&u.fragment.c();e.intro&&ut(r.$$.fragment),ht(r,e.target,e.anchor),_()}ie(a)}let Ee;typeof HTMLElement=="function"&&(Ee=class extends HTMLElement{constructor(e,t,i){super();M(this,"$$ctor");M(this,"$$s");M(this,"$$c");M(this,"$$cn",!1);M(this,"$$d",{});M(this,"$$r",!1);M(this,"$$p_d",{});M(this,"$$l",{});M(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=C("slot"),l!=="default"&&c(s,"name",l)},m:function(u,Z){j(u,s,Z)},d:function(u){u&&z(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=nt(this);for(const l of this.$$s)l in i&&(t[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=oe(s,l.value,this.$$p_d,"toProp"))}for(const l in this.$$p_d)!(l in this.$$d)&&this[l]!==void 0&&(this.$$d[l]=this[l],delete this[l]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const l in this.$$p_d)if(this.$$d[l]=this.$$c.$$.ctx[this.$$c.$$.props[l]],this.$$p_d[l].reflect){const s=oe(l,this.$$d[l],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const s of this.$$l[l]){const f=this.$$c.$on(l,s);this.$$l_u.set(s,f)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=oe(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function oe(r,e,t,i){var l;const o=(l=t[r])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function bt(r,e,t,i,o,l){let s=class extends Ee{constructor(){super(r,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(f=>(e[f].attribute||f).toLowerCase())}};return Object.keys(e).forEach(f=>{Object.defineProperty(s.prototype,f,{get(){return this.$$c&&f in this.$$c?this.$$c[f]:this.$$d[f]},set(a){var u;a=oe(f,a,e),this.$$d[f]=a,(u=this.$$c)==null||u.$set({[f]:a})}})}),i.forEach(f=>{Object.defineProperty(s.prototype,f,{get(){var a;return(a=this.$$c)==null?void 0:a[f]}})}),l&&(s=l(s)),r.element=s,s}class yt{constructor(){M(this,"$$");M(this,"$$set")}$destroy(){dt(this,1),this.$destroy=S}$on(e,t){if(!ve(t))return S;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!Ke(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const vt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(vt);const xe="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",wt=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),$e=typeof window<"u"&&window.Blob&&new Blob([wt(xe)],{type:"text/javascript;charset=utf-8"});function _t(r){let e;try{if(e=$e&&(window.URL||window.webkitURL).createObjectURL($e),!e)throw"";const t=new Worker(e,{name:r==null?void 0:r.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+xe,{name:r==null?void 0:r.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const pt=new TextEncoder;function kt(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Et(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const o=await Ce(i,r,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Ce(r,e,t){return kt(await crypto.subtle.digest(t.toUpperCase(),pt.encode(r+e)))}function xt(r,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let a=o;a<=i;a+=1){if(l.signal.aborted)return null;if(await Ce(e,a,t)===r)return{number:a,took:Date.now()-s}}return null})(),controller:l}}var g=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(g||{});function $t(r){Je(r,"svelte-15co9zy",".altcha.svelte-15co9zy.svelte-15co9zy{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-15co9zy.svelte-15co9zy{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}")}function Le(r){let e,t,i;return{c(){e=X("svg"),t=X("path"),i=X("path"),c(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(t,"fill","currentColor"),c(t,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-15co9zy"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){j(o,e,l),v(e,t),v(e,i)},d(o){o&&z(e)}}}function Ct(r){let e,t=r[9].label+"",i;return{c(){e=C("label"),c(e,"for",i=r[3]+"_checkbox"),c(e,"class","svelte-15co9zy")},m(o,l){j(o,e,l),e.innerHTML=t},p(o,l){l[0]&512&&t!==(t=o[9].label+"")&&(e.innerHTML=t),l[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&z(e)}}}function Lt(r){let e,t=r[9].verifying+"";return{c(){e=C("span")},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].verifying+"")&&(e.innerHTML=t)},d(i){i&&z(e)}}}function Rt(r){let e,t=r[9].verified+"",i,o;return{c(){e=C("span"),i=W(),o=C("input"),c(o,"type","hidden"),c(o,"name",r[3]),o.value=r[4]},m(l,s){j(l,e,s),e.innerHTML=t,j(l,i,s),j(l,o,s)},p(l,s){s[0]&512&&t!==(t=l[9].verified+"")&&(e.innerHTML=t),s[0]&8&&c(o,"name",l[3]),s[0]&16&&(o.value=l[4])},d(l){l&&(z(e),z(i),z(o))}}}function Re(r){let e,t,i,o,l,s,f;return{c(){e=C("div"),t=C("a"),i=X("svg"),o=X("path"),l=X("path"),s=X("path"),c(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(o,"fill","currentColor"),c(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(l,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(t,"href",Se),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-15co9zy"),c(t,"aria-label",f=r[9].ariaLinkLabel)},m(a,u){j(a,e,u),v(e,t),v(t,i),v(i,o),v(i,l),v(i,s)},p(a,u){u[0]&512&&f!==(f=a[9].ariaLinkLabel)&&c(t,"aria-label",f)},d(a){a&&z(e)}}}function Ie(r){let e,t,i,o;function l(a,u){return a[5]===g.EXPIRED?zt:It}let s=l(r),f=s(r);return{c(){e=C("div"),t=X("svg"),i=X("path"),o=W(),f.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(t,"width","14"),c(t,"height","14"),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"fill","none"),c(t,"viewBox","0 0 24 24"),c(t,"stroke-width","1.5"),c(t,"stroke","currentColor"),c(e,"class","altcha-error svelte-15co9zy")},m(a,u){j(a,e,u),v(e,t),v(t,i),v(e,o),f.m(e,null)},p(a,u){s===(s=l(a))&&f?f.p(a,u):(f.d(1),f=s(a),f&&(f.c(),f.m(e,null)))},d(a){a&&z(e),f.d()}}}function It(r){let e,t=r[9].error+"";return{c(){e=C("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].error+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&z(e)}}}function zt(r){let e,t=r[9].expired+"";return{c(){e=C("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].expired+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&z(e)}}}function ze(r){let e,t,i=r[9].footer+"";return{c(){e=C("div"),t=C("div"),c(t,"class","svelte-15co9zy"),c(e,"class","altcha-footer svelte-15co9zy")},m(o,l){j(o,e,l),v(e,t),t.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(t.innerHTML=i)},d(o){o&&z(e)}}}function Nt(r){let e,t,i,o,l,s,f,a,u,Z,L,V,U,F,p=r[5]===g.VERIFYING&&Le();function B(d,I){return d[5]===g.VERIFIED?Rt:d[5]===g.VERIFYING?Lt:Ct}let H=B(r),k=H(r),E=r[2]!==!0&&Re(r),m=(r[8]||r[5]===g.EXPIRED)&&Ie(r),y=r[9].footer&&r[1]!==!0&&ze(r);return{c(){e=C("div"),t=C("div"),p&&p.c(),i=W(),o=C("div"),l=C("input"),a=W(),u=C("div"),k.c(),Z=W(),E&&E.c(),L=W(),m&&m.c(),V=W(),y&&y.c(),c(l,"type","checkbox"),c(l,"id",s=r[3]+"_checkbox"),l.required=f=r[0]!=="onsubmit",c(l,"class","svelte-15co9zy"),c(o,"class","altcha-checkbox svelte-15co9zy"),we(o,"altcha-hidden",r[5]===g.VERIFYING),c(u,"class","altcha-label svelte-15co9zy"),c(t,"class","altcha-main svelte-15co9zy"),c(e,"class","altcha svelte-15co9zy"),c(e,"data-state",r[5])},m(d,I){j(d,e,I),v(e,t),p&&p.m(t,null),v(t,i),v(t,o),v(o,l),l.checked=r[6],v(t,a),v(t,u),k.m(u,null),v(t,Z),E&&E.m(t,null),v(e,L),m&&m.m(e,null),v(e,V),y&&y.m(e,null),r[30](e),U||(F=[fe(l,"change",r[29]),fe(l,"change",r[10]),fe(l,"invalid",r[11])],U=!0)},p(d,I){d[5]===g.VERIFYING?p||(p=Le(),p.c(),p.m(t,i)):p&&(p.d(1),p=null),I[0]&8&&s!==(s=d[3]+"_checkbox")&&c(l,"id",s),I[0]&1&&f!==(f=d[0]!=="onsubmit")&&(l.required=f),I[0]&64&&(l.checked=d[6]),I[0]&32&&we(o,"altcha-hidden",d[5]===g.VERIFYING),H===(H=B(d))&&k?k.p(d,I):(k.d(1),k=H(d),k&&(k.c(),k.m(u,null))),d[2]!==!0?E?E.p(d,I):(E=Re(d),E.c(),E.m(t,null)):E&&(E.d(1),E=null),d[8]||d[5]===g.EXPIRED?m?m.p(d,I):(m=Ie(d),m.c(),m.m(e,V)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?y?y.p(d,I):(y=ze(d),y.c(),y.m(e,null)):y&&(y.d(1),y=null),I[0]&32&&c(e,"data-state",d[5])},i:S,o:S,d(d){d&&z(e),p&&p.d(),k.d(),E&&E.d(),m&&m.d(),y&&y.d(),r[30](null),U=!1,re(F)}}}const Ne="Visit Altcha.org",Se="https://altcha.org/";function je(r){return JSON.parse(r)}function St(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function jt(r,e,t){var Fe,He;let i,o,l,{auto:s=void 0}=e,{blockspam:f=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:u=void 0}=e,{debug:Z=!1}=e,{expire:L=void 0}=e,{hidefooter:V=!1}=e,{hidelogo:U=!1}=e,{name:F="altcha"}=e,{maxnumber:p=1e6}=e,{mockerror:B=!1}=e,{refetchonexpire:H=!0}=e,{spamfilter:k=!1}=e,{strings:E=void 0}=e,{test:m=!1}=e,{verifyurl:y=void 0}=e,{workers:d=Math.min(16,navigator.hardwareConcurrency||8)}=e;const I=lt(),Ze=["SHA-256","SHA-384","SHA-512"],Te=(He=(Fe=document.documentElement.lang)==null?void 0:Fe.split("-"))==null?void 0:He[0];let Y=!1,le,b=null,be=null,K=null,G=g.UNVERIFIED,D=null;ot(()=>{b&&(b.removeEventListener("submit",Ve),b.removeEventListener("reset",Ue),b.removeEventListener("focusin",Me),b=null),D&&(clearTimeout(D),D=null)}),it(()=>{R("mounted","0.4.3"),R("workers",d),m&&R("using test mode"),L&&se(L),s!==void 0&&R("auto",s),b=le.closest("form"),b&&(b.addEventListener("submit",Ve),b.addEventListener("reset",Ue),s==="onfocus"&&b.addEventListener("focusin",Me)),s==="onload"&&J()});function R(...n){(Z||n.some(h=>h instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Me(n){G===g.UNVERIFIED&&J()}function Ve(n){b&&s==="onsubmit"&&G===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),J().then(()=>{b==null||b.requestSubmit()}))}function Ue(){ce()}function Ge(n,h){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:h.number,salt:n.salt,signature:n.signature,test:m?!0:void 0,took:h.took}))}function De(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Ze.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ze.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function At(){var n;if(B)throw R("mocking error"),new Error("Mocked error.");if(i)return R("using provided json data"),i;if(m)return R("generating test challenge",{test:m}),Et(typeof m!="boolean"?+m:void 0);{if(!a)throw new Error("Attribute challengeurl not set.");R("fetching challenge from",a);const h=await fetch(a,{headers:{"x-altcha-spam-filter":k?"1":"0"}});if(h.status!==200)throw new Error(`Server responded with ${h.status}.`);const w=h.headers.get("Expires"),N=h.headers.get("X-Altcha-Config"),A=await h.json(),T=new URLSearchParams((n=A.salt.split("?"))==null?void 0:n[1]),Q=T.get("expires")||T.get("expire");if(Q){const x=new Date(+Q*1e3),$=isNaN(x.getTime())?0:x.getTime()-Date.now();$>0&&se($)}if(N)try{const x=JSON.parse(N);x&&typeof x=="object"&&(x.verifyurl&&(x.verifyurl=new URL(x.verifyurl,new URL(a)).toString()),Xe(x))}catch(x){R("unable to configure from X-Altcha-Config",x)}if(!L&&(w!=null&&w.length)){const x=Date.parse(w);if(x){const $=x-Date.now();$>0&&se($)}}return A}}function Oe(){a&&H&&G===g.VERIFIED?J():ce(g.EXPIRED,l.expired)}async function Zt(n){let h=null;if("Worker"in window){try{h=await Tt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(w){R(w)}if((h==null?void 0:h.number)!==void 0)return{data:n,solution:h}}return{data:n,solution:await xt(n.challenge,n.salt,n.algorithm,n.maxnumber||p).promise}}async function Tt(n,h,w,N=typeof m=="number"?m:p,A=Math.ceil(d)){const T=[];if(A<1)throw new Error("Wrong number of workers configured.");if(A>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let $=0;${const Pe=ae*Q;return new Promise(Ft=>{$.addEventListener("message",Ye=>{if(Ye.data)for(const We of T)We!==$&&We.postMessage({type:"abort"});Ft(Ye.data)}),$.postMessage({payload:{alg:w,challenge:n,max:Pe+Q,salt:h,start:Pe},type:"work"})})}));for(const $ of T)$.terminate();return x.find($=>!!$)||null}function Mt(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(G)?k&&(b==null?void 0:b.reportValidity())===!1?t(6,Y=!1):J():t(6,Y=!0)}function Vt(){G===g.VERIFYING&&alert(l.waitAlert)}function se(n){R("expire",n),D&&(clearTimeout(D),D=null),n<1?Oe():D=setTimeout(Oe,n)}function Ut(n){var w;const h=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((w=h==null?void 0:h.value)==null?void 0:w.slice(h.value.indexOf("@")))||void 0}function Gt(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(w=>`input[name="${w}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((w,N)=>{const A=N.name,T=N.value.trim();return A&&T&&(w[A]=T),w},{})}async function Dt(n){if(!y)throw new Error("Attribute verifyurl not set.");R("requesting server verification from",y);const h={payload:n};if(k){const{email:A,expectedLanguages:T,expectedCountries:Q,fields:x,ipAddress:$,timeZone:ae}=typeof k=="object"?k:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};h.ipAddress=$===!1?void 0:$||"auto",h.email=A===!1?void 0:Ut(A),h.fields=x===!1?void 0:Gt(x),h.timeZone=ae===!1?void 0:ae||St(),h.expectedCountries=Q,h.expectedLanguages=T||(Te?[Te]:void 0)}const w=await fetch(y,{body:JSON.stringify(h),headers:{"content-type":"application/json"},method:"POST"});if(w.status!==200)throw new Error(`Server responded with ${w.status}.`);const N=await w.json();if(N!=null&&N.payload&&t(4,K=N.payload),I("serververification",N),f&&N.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Xe(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&J()),n.expire!==void 0&&(se(n.expire),t(14,L=n.expire)),n.challenge&&(De(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(12,a=n.challengeurl),n.debug!==void 0&&t(13,Z=!!n.debug),n.hidefooter!==void 0&&t(1,V=!!n.hidefooter),n.hidelogo!==void 0&&t(2,U=!!n.hidelogo),n.maxnumber!==void 0&&t(15,p=+n.maxnumber),n.mockerror!==void 0&&t(16,B=!!n.mockerror),n.name!==void 0&&t(3,F=n.name),n.refetchonexpire!==void 0&&t(17,H=!!n.refetchonexpire),n.spamfilter!==void 0&&t(18,k=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(28,o=n.strings),n.test!==void 0&&t(19,m=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(20,y=n.verifyurl),n.workers!==void 0&&t(21,d=+n.workers)}function ce(n=g.UNVERIFIED,h=null){D&&(clearTimeout(D),D=null),t(6,Y=!1),t(8,be=h),t(4,K=null),t(5,G=n)}async function J(){return ce(g.VERIFYING),At().then(n=>(De(n),R("challenge",n),Zt(n))).then(({data:n,solution:h})=>{if(R("solution",h),(h==null?void 0:h.number)!==void 0){if(y)return Dt(Ge(n,h));t(4,K=Ge(n,h)),R("payload",K)}else throw R("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{st().then(()=>{t(5,G=g.VERIFIED),t(6,Y=!0),R("verified"),I("verified",{payload:K})})}).catch(n=>{R(n),t(5,G=g.ERROR),t(6,Y=!1),t(8,be=n.message)})}function Ot(){Y=this.checked,t(6,Y)}function Xt(n){he[n?"unshift":"push"](()=>{le=n,t(7,le)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(22,f=n.blockspam),"challengeurl"in n&&t(12,a=n.challengeurl),"challengejson"in n&&t(23,u=n.challengejson),"debug"in n&&t(13,Z=n.debug),"expire"in n&&t(14,L=n.expire),"hidefooter"in n&&t(1,V=n.hidefooter),"hidelogo"in n&&t(2,U=n.hidelogo),"name"in n&&t(3,F=n.name),"maxnumber"in n&&t(15,p=n.maxnumber),"mockerror"in n&&t(16,B=n.mockerror),"refetchonexpire"in n&&t(17,H=n.refetchonexpire),"spamfilter"in n&&t(18,k=n.spamfilter),"strings"in n&&t(24,E=n.strings),"test"in n&&t(19,m=n.test),"verifyurl"in n&&t(20,y=n.verifyurl),"workers"in n&&t(21,d=n.workers)},r.$$.update=()=>{r.$$.dirty[0]&8388608&&(i=u?je(u):void 0),r.$$.dirty[0]&16777216&&t(28,o=E?je(E):{}),r.$$.dirty[0]&268435456&&t(9,l={ariaLinkLabel:Ne,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),r.$$.dirty[0]&48&&I("statechange",{payload:K,state:G})},[s,V,U,F,K,G,Y,le,be,l,Mt,Vt,a,Z,L,p,B,H,k,m,y,d,f,u,E,Xe,ce,J,o,Ot,Xt]}class Ae extends yt{constructor(e){super(),gt(this,e,jt,Nt,Be,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,configure:25,reset:26,verify:27},$t,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),_()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),_()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),_()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),_()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),_()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),_()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),_()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),_()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),_()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),_()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),_()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),_()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),_()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),_()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),_()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),_()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),_()}get configure(){return this.$$.ctx[25]}get reset(){return this.$$.ctx[26]}get verify(){return this.$$.ctx[27]}}return customElements.define("altcha-widget",bt(Ae,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{}},[],["configure","reset","verify"],!1)),O.Altcha=Ae,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"}),O}({}); +var altcha=function(O){"use strict";var Wt=Object.defineProperty;var Pt=(O,M,Q)=>M in O?Wt(O,M,{enumerable:!0,configurable:!0,writable:!0,value:Q}):O[M]=Q;var T=(O,M,Q)=>Pt(O,typeof M!="symbol"?M+"":M,Q);const M="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",Q=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),we=typeof window<"u"&&window.Blob&&new Blob([Q(M)],{type:"text/javascript;charset=utf-8"});function Je(t){let e;try{if(e=we&&(window.URL||window.webkitURL).createObjectURL(we),!e)throw"";const r=new Worker(e,{name:t==null?void 0:t.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),r}catch{return new Worker("data:text/javascript;base64,"+M,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}function re(){}function _e(t){return t()}function pe(){return Object.create(null)}function ne(t){t.forEach(_e)}function ke(t){return typeof t=="function"}function Qe(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function qe(t){return Object.keys(t).length===0}function v(t,e){t.appendChild(e)}function et(t,e,r){const i=tt(t);if(!i.getElementById(e)){const o=C("style");o.id=e,o.textContent=r,rt(i,o)}}function tt(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function rt(t,e){return v(t.head||t,e),e.sheet}function S(t,e,r){t.insertBefore(e,r||null)}function z(t){t.parentNode&&t.parentNode.removeChild(t)}function C(t){return document.createElement(t)}function X(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function nt(t){return document.createTextNode(t)}function P(){return nt(" ")}function ue(t,e,r,i){return t.addEventListener(e,r,i),()=>t.removeEventListener(e,r,i)}function c(t,e,r){r==null?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}function it(t){return Array.from(t.childNodes)}function xe(t,e,r){t.classList.toggle(e,!!r)}function ot(t,e,{bubbles:r=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:r,cancelable:i})}function lt(t){const e={};return t.childNodes.forEach(r=>{e[r.slot||"default"]=!0}),e}let ie;function oe(t){ie=t}function he(){if(!ie)throw new Error("Function called outside component initialization");return ie}function st(t){he().$$.on_mount.push(t)}function ct(t){he().$$.on_destroy.push(t)}function at(){const t=he();return(e,r,{cancelable:i=!1}={})=>{const o=t.$$.callbacks[e];if(o){const l=ot(e,r,{cancelable:i});return o.slice().forEach(s=>{s.call(t,l)}),!l.defaultPrevented}return!0}}const q=[],de=[];let ee=[];const Ee=[],$e=Promise.resolve();let me=!1;function Ce(){me||(me=!0,$e.then(w))}function ft(){return Ce(),$e}function ge(t){ee.push(t)}const be=new Set;let te=0;function w(){if(te!==0)return;const t=ie;do{try{for(;tet.indexOf(i)===-1?e.push(i):r.push(i)),r.forEach(i=>i()),ee=e}const dt=new Set;function mt(t,e){t&&t.i&&(dt.delete(t),t.i(e))}function gt(t,e,r){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,r),ge(()=>{const l=t.$$.on_mount.map(_e).filter(ke);t.$$.on_destroy?t.$$.on_destroy.push(...l):ne(l),t.$$.on_mount=[]}),o.forEach(ge)}function bt(t,e){const r=t.$$;r.fragment!==null&&(ht(r.after_update),ne(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function yt(t,e){t.$$.dirty[0]===-1&&(q.push(t),Ce(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const F=U.length?U[0]:V;return u.ctx&&o(u.ctx[L],u.ctx[L]=F)&&(!u.skip_bound&&u.bound[L]&&u.bound[L](F),j&&yt(t,L)),V}):[],u.update(),j=!0,ne(u.before_update),u.fragment=i?i(u.ctx):!1,e.target){if(e.hydrate){const L=it(e.target);u.fragment&&u.fragment.l(L),L.forEach(z)}else u.fragment&&u.fragment.c();e.intro&&mt(t.$$.fragment),gt(t,e.target,e.anchor),w()}oe(a)}let Le;typeof HTMLElement=="function"&&(Le=class extends HTMLElement{constructor(e,r,i){super();T(this,"$$ctor");T(this,"$$s");T(this,"$$c");T(this,"$$cn",!1);T(this,"$$d",{});T(this,"$$r",!1);T(this,"$$p_d",{});T(this,"$$l",{});T(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=r,i&&this.attachShadow({mode:"open"})}addEventListener(e,r,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(r),this.$$c){const o=this.$$c.$on(e,r);this.$$l_u.set(r,o)}super.addEventListener(e,r,i)}removeEventListener(e,r,i){if(super.removeEventListener(e,r,i),this.$$c){const o=this.$$l_u.get(r);o&&(o(),this.$$l_u.delete(r))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=C("slot"),l!=="default"&&c(s,"name",l)},m:function(u,j){S(u,s,j)},d:function(u){u&&z(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const r={},i=lt(this);for(const l of this.$$s)l in i&&(r[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=le(s,l.value,this.$$p_d,"toProp"))}for(const l in this.$$p_d)!(l in this.$$d)&&this[l]!==void 0&&(this.$$d[l]=this[l],delete this[l]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:r,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const l in this.$$p_d)if(this.$$d[l]=this.$$c.$$.ctx[this.$$c.$$.props[l]],this.$$p_d[l].reflect){const s=le(l,this.$$d[l],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const s of this.$$l[l]){const f=this.$$c.$on(l,s);this.$$l_u.set(s,f)}this.$$l={}}}attributeChangedCallback(e,r,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=le(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(r=>this.$$p_d[r].attribute===e||!this.$$p_d[r].attribute&&r.toLowerCase()===e)||e}});function le(t,e,r,i){var l;const o=(l=r[t])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!r[t])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function wt(t,e,r,i,o,l){let s=class extends Le{constructor(){super(t,r,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(f=>(e[f].attribute||f).toLowerCase())}};return Object.keys(e).forEach(f=>{Object.defineProperty(s.prototype,f,{get(){return this.$$c&&f in this.$$c?this.$$c[f]:this.$$d[f]},set(a){var u;a=le(f,a,e),this.$$d[f]=a,(u=this.$$c)==null||u.$set({[f]:a})}})}),i.forEach(f=>{Object.defineProperty(s.prototype,f,{get(){var a;return(a=this.$$c)==null?void 0:a[f]}})}),l&&(s=l(s)),t.element=s,s}class _t{constructor(){T(this,"$$");T(this,"$$set")}$destroy(){bt(this,1),this.$destroy=re}$on(e,r){if(!ke(r))return re;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(r),()=>{const o=i.indexOf(r);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!qe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const pt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(pt);const kt=new TextEncoder;function xt(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Et(t,e="SHA-256",r=1e5){const i=Date.now().toString(16);t||(t=Math.round(Math.random()*r));const o=await Re(i,t,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Re(t,e,r){return xt(await crypto.subtle.digest(r.toUpperCase(),kt.encode(t+e)))}function $t(t,e,r="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let a=o;a<=i;a+=1){if(l.signal.aborted)return null;if(await Re(e,a,r)===t)return{number:a,took:Date.now()-s}}return null})(),controller:l}}var g=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t.EXPIRED="expired",t))(g||{});function Ct(t){et(t,"svelte-15co9zy",".altcha.svelte-15co9zy.svelte-15co9zy{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-15co9zy.svelte-15co9zy{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}")}function Ie(t){let e,r,i;return{c(){e=X("svg"),r=X("path"),i=X("path"),c(r,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(r,"fill","currentColor"),c(r,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-15co9zy"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){S(o,e,l),v(e,r),v(e,i)},d(o){o&&z(e)}}}function Lt(t){let e,r=t[9].label+"",i;return{c(){e=C("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-15co9zy")},m(o,l){S(o,e,l),e.innerHTML=r},p(o,l){l[0]&512&&r!==(r=o[9].label+"")&&(e.innerHTML=r),l[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&z(e)}}}function Rt(t){let e,r=t[9].verifying+"";return{c(){e=C("span")},m(i,o){S(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].verifying+"")&&(e.innerHTML=r)},d(i){i&&z(e)}}}function It(t){let e,r=t[9].verified+"",i,o;return{c(){e=C("span"),i=P(),o=C("input"),c(o,"type","hidden"),c(o,"name",t[3]),o.value=t[4]},m(l,s){S(l,e,s),e.innerHTML=r,S(l,i,s),S(l,o,s)},p(l,s){s[0]&512&&r!==(r=l[9].verified+"")&&(e.innerHTML=r),s[0]&8&&c(o,"name",l[3]),s[0]&16&&(o.value=l[4])},d(l){l&&(z(e),z(i),z(o))}}}function ze(t){let e,r,i,o,l,s,f;return{c(){e=C("div"),r=C("a"),i=X("svg"),o=X("path"),l=X("path"),s=X("path"),c(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(o,"fill","currentColor"),c(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(l,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(r,"href",je),c(r,"target","_blank"),c(r,"class","altcha-logo svelte-15co9zy"),c(r,"aria-label",f=t[9].ariaLinkLabel)},m(a,u){S(a,e,u),v(e,r),v(r,i),v(i,o),v(i,l),v(i,s)},p(a,u){u[0]&512&&f!==(f=a[9].ariaLinkLabel)&&c(r,"aria-label",f)},d(a){a&&z(e)}}}function Ne(t){let e,r,i,o;function l(a,u){return a[5]===g.EXPIRED?Nt:zt}let s=l(t),f=s(t);return{c(){e=C("div"),r=X("svg"),i=X("path"),o=P(),f.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(r,"width","14"),c(r,"height","14"),c(r,"xmlns","http://www.w3.org/2000/svg"),c(r,"fill","none"),c(r,"viewBox","0 0 24 24"),c(r,"stroke-width","1.5"),c(r,"stroke","currentColor"),c(e,"class","altcha-error svelte-15co9zy")},m(a,u){S(a,e,u),v(e,r),v(r,i),v(e,o),f.m(e,null)},p(a,u){s===(s=l(a))&&f?f.p(a,u):(f.d(1),f=s(a),f&&(f.c(),f.m(e,null)))},d(a){a&&z(e),f.d()}}}function zt(t){let e,r=t[9].error+"";return{c(){e=C("div"),c(e,"title",t[8])},m(i,o){S(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].error+"")&&(e.innerHTML=r),o[0]&256&&c(e,"title",i[8])},d(i){i&&z(e)}}}function Nt(t){let e,r=t[9].expired+"";return{c(){e=C("div"),c(e,"title",t[8])},m(i,o){S(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].expired+"")&&(e.innerHTML=r),o[0]&256&&c(e,"title",i[8])},d(i){i&&z(e)}}}function Se(t){let e,r,i=t[9].footer+"";return{c(){e=C("div"),r=C("div"),c(r,"class","svelte-15co9zy"),c(e,"class","altcha-footer svelte-15co9zy")},m(o,l){S(o,e,l),v(e,r),r.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(r.innerHTML=i)},d(o){o&&z(e)}}}function St(t){let e,r,i,o,l,s,f,a,u,j,L,V,U,F,p=t[5]===g.VERIFYING&&Ie();function Y(d,I){return d[5]===g.VERIFIED?It:d[5]===g.VERIFYING?Rt:Lt}let H=Y(t),k=H(t),x=t[2]!==!0&&ze(t),m=(t[8]||t[5]===g.EXPIRED)&&Ne(t),y=t[9].footer&&t[1]!==!0&&Se(t);return{c(){e=C("div"),r=C("div"),p&&p.c(),i=P(),o=C("div"),l=C("input"),a=P(),u=C("div"),k.c(),j=P(),x&&x.c(),L=P(),m&&m.c(),V=P(),y&&y.c(),c(l,"type","checkbox"),c(l,"id",s=t[3]+"_checkbox"),l.required=f=t[0]!=="onsubmit",c(l,"class","svelte-15co9zy"),c(o,"class","altcha-checkbox svelte-15co9zy"),xe(o,"altcha-hidden",t[5]===g.VERIFYING),c(u,"class","altcha-label svelte-15co9zy"),c(r,"class","altcha-main svelte-15co9zy"),c(e,"class","altcha svelte-15co9zy"),c(e,"data-state",t[5])},m(d,I){S(d,e,I),v(e,r),p&&p.m(r,null),v(r,i),v(r,o),v(o,l),l.checked=t[6],v(r,a),v(r,u),k.m(u,null),v(r,j),x&&x.m(r,null),v(e,L),m&&m.m(e,null),v(e,V),y&&y.m(e,null),t[31](e),U||(F=[ue(l,"change",t[30]),ue(l,"change",t[10]),ue(l,"invalid",t[11])],U=!0)},p(d,I){d[5]===g.VERIFYING?p||(p=Ie(),p.c(),p.m(r,i)):p&&(p.d(1),p=null),I[0]&8&&s!==(s=d[3]+"_checkbox")&&c(l,"id",s),I[0]&1&&f!==(f=d[0]!=="onsubmit")&&(l.required=f),I[0]&64&&(l.checked=d[6]),I[0]&32&&xe(o,"altcha-hidden",d[5]===g.VERIFYING),H===(H=Y(d))&&k?k.p(d,I):(k.d(1),k=H(d),k&&(k.c(),k.m(u,null))),d[2]!==!0?x?x.p(d,I):(x=ze(d),x.c(),x.m(r,null)):x&&(x.d(1),x=null),d[8]||d[5]===g.EXPIRED?m?m.p(d,I):(m=Ne(d),m.c(),m.m(e,V)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?y?y.p(d,I):(y=Se(d),y.c(),y.m(e,null)):y&&(y.d(1),y=null),I[0]&32&&c(e,"data-state",d[5])},i:re,o:re,d(d){d&&z(e),p&&p.d(),k.d(),x&&x.d(),m&&m.d(),y&&y.d(),t[31](null),U=!1,ne(F)}}}const Ae="Visit Altcha.org",je="https://altcha.org/";function Ze(t){return JSON.parse(t)}function At(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function jt(t,e,r){var We,Pe;let i,o,l,{auto:s=void 0}=e,{blockspam:f=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:u=void 0}=e,{debug:j=!1}=e,{expire:L=void 0}=e,{hidefooter:V=!1}=e,{hidelogo:U=!1}=e,{name:F="altcha"}=e,{maxnumber:p=1e6}=e,{mockerror:Y=!1}=e,{refetchonexpire:H=!0}=e,{spamfilter:k=!1}=e,{strings:x=void 0}=e,{test:m=!1}=e,{verifyurl:y=void 0}=e,{workers:d=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:I=void 0}=e;const ye=at(),Me=["SHA-256","SHA-384","SHA-512"],Ve=(Pe=(We=document.documentElement.lang)==null?void 0:We.split("-"))==null?void 0:Pe[0];let W=!1,se,b=null,ve=null,B=null,G=g.UNVERIFIED,D=null;ct(()=>{b&&(b.removeEventListener("submit",Ge),b.removeEventListener("reset",De),b.removeEventListener("focusin",Ue),b=null),D&&(clearTimeout(D),D=null)}),st(()=>{R("mounted","0.4.3"),R("workers",d),m&&R("using test mode"),L&&ce(L),s!==void 0&&R("auto",s),b=se.closest("form"),b&&(b.addEventListener("submit",Ge),b.addEventListener("reset",De),s==="onfocus"&&b.addEventListener("focusin",Ue)),s==="onload"&&K()});function R(...n){(j||n.some(h=>h instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Ue(n){G===g.UNVERIFIED&&K()}function Ge(n){b&&s==="onsubmit"&&G===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),K().then(()=>{b==null||b.requestSubmit()}))}function De(){ae()}function Oe(n,h){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:h.number,salt:n.salt,signature:n.signature,test:m?!0:void 0,took:h.took}))}function Xe(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Me.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Me.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function Zt(){var n;if(Y)throw R("mocking error"),new Error("Mocked error.");if(i)return R("using provided json data"),i;if(m)return R("generating test challenge",{test:m}),Et(typeof m!="boolean"?+m:void 0);{if(!a)throw new Error("Attribute challengeurl not set.");R("fetching challenge from",a);const h=await fetch(a,{headers:{"x-altcha-spam-filter":k?"1":"0"}});if(h.status!==200)throw new Error(`Server responded with ${h.status}.`);const _=h.headers.get("Expires"),N=h.headers.get("X-Altcha-Config"),A=await h.json(),Z=new URLSearchParams((n=A.salt.split("?"))==null?void 0:n[1]),J=Z.get("expires")||Z.get("expire");if(J){const E=new Date(+J*1e3),$=isNaN(E.getTime())?0:E.getTime()-Date.now();$>0&&ce($)}if(N)try{const E=JSON.parse(N);E&&typeof E=="object"&&(E.verifyurl&&(E.verifyurl=new URL(E.verifyurl,new URL(a)).toString()),He(E))}catch(E){R("unable to configure from X-Altcha-Config",E)}if(!L&&(_!=null&&_.length)){const E=Date.parse(_);if(E){const $=E-Date.now();$>0&&ce($)}}return A}}function Fe(){a&&H&&G===g.VERIFIED?K():ae(g.EXPIRED,l.expired)}async function Tt(n){let h=null;if("Worker"in window){try{h=await Mt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(_){R(_)}if((h==null?void 0:h.number)!==void 0)return{data:n,solution:h}}return{data:n,solution:await $t(n.challenge,n.salt,n.algorithm,n.maxnumber||p).promise}}async function Mt(n,h,_,N=typeof m=="number"?m:p,A=Math.ceil(d)){const Z=[];if(A<1)throw new Error("Wrong number of workers configured.");if(A>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let $=0;${const Ye=fe*J;return new Promise(Ht=>{$.addEventListener("message",Be=>{if(Be.data)for(const Ke of Z)Ke!==$&&Ke.postMessage({type:"abort"});Ht(Be.data)}),$.postMessage({payload:{alg:_,challenge:n,max:Ye+J,salt:h,start:Ye},type:"work"})})}));for(const $ of Z)$.terminate();return E.find($=>!!$)||null}function Vt(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(G)?k&&(b==null?void 0:b.reportValidity())===!1?r(6,W=!1):K():r(6,W=!0)}function Ut(){G===g.VERIFYING&&alert(l.waitAlert)}function ce(n){R("expire",n),D&&(clearTimeout(D),D=null),n<1?Fe():D=setTimeout(Fe,n)}function Gt(n){var _;const h=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((_=h==null?void 0:h.value)==null?void 0:_.slice(h.value.indexOf("@")))||void 0}function Dt(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(_=>`input[name="${_}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((_,N)=>{const A=N.name,Z=N.value.trim();return A&&Z&&(_[A]=Z),_},{})}async function Ot(n){if(!y)throw new Error("Attribute verifyurl not set.");R("requesting server verification from",y);const h={payload:n};if(k){const{email:A,expectedLanguages:Z,expectedCountries:J,fields:E,ipAddress:$,timeZone:fe}=typeof k=="object"?k:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};h.ipAddress=$===!1?void 0:$||"auto",h.email=A===!1?void 0:Gt(A),h.fields=E===!1?void 0:Dt(E),h.timeZone=fe===!1?void 0:fe||At(),h.expectedCountries=J,h.expectedLanguages=Z||(Ve?[Ve]:void 0)}const _=await fetch(y,{body:JSON.stringify(h),headers:{"content-type":"application/json"},method:"POST"});if(_.status!==200)throw new Error(`Server responded with ${_.status}.`);const N=await _.json();if(N!=null&&N.payload&&r(4,B=N.payload),ye("serververification",N),f&&N.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function He(n){n.auto!==void 0&&(r(0,s=n.auto),s==="onload"&&K()),n.expire!==void 0&&(ce(n.expire),r(14,L=n.expire)),n.challenge&&(Xe(n.challenge),i=n.challenge),n.challengeurl!==void 0&&r(12,a=n.challengeurl),n.debug!==void 0&&r(13,j=!!n.debug),n.hidefooter!==void 0&&r(1,V=!!n.hidefooter),n.hidelogo!==void 0&&r(2,U=!!n.hidelogo),n.maxnumber!==void 0&&r(15,p=+n.maxnumber),n.mockerror!==void 0&&r(16,Y=!!n.mockerror),n.name!==void 0&&r(3,F=n.name),n.refetchonexpire!==void 0&&r(17,H=!!n.refetchonexpire),n.spamfilter!==void 0&&r(18,k=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&r(29,o=n.strings),n.test!==void 0&&r(19,m=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&r(20,y=n.verifyurl),n.workers!==void 0&&r(21,d=+n.workers)}function ae(n=g.UNVERIFIED,h=null){D&&(clearTimeout(D),D=null),r(6,W=!1),r(8,ve=h),r(4,B=null),r(5,G=n)}async function K(){return ae(g.VERIFYING),Zt().then(n=>(Xe(n),R("challenge",n),Tt(n))).then(({data:n,solution:h})=>{if(R("solution",h),(h==null?void 0:h.number)!==void 0){if(y)return Ot(Oe(n,h));r(4,B=Oe(n,h)),R("payload",B)}else throw R("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{ft().then(()=>{r(5,G=g.VERIFIED),r(6,W=!0),R("verified"),ye("verified",{payload:B})})}).catch(n=>{R(n),r(5,G=g.ERROR),r(6,W=!1),r(8,ve=n.message)})}function Xt(){W=this.checked,r(6,W)}function Ft(n){de[n?"unshift":"push"](()=>{se=n,r(7,se)})}return t.$$set=n=>{"auto"in n&&r(0,s=n.auto),"blockspam"in n&&r(22,f=n.blockspam),"challengeurl"in n&&r(12,a=n.challengeurl),"challengejson"in n&&r(23,u=n.challengejson),"debug"in n&&r(13,j=n.debug),"expire"in n&&r(14,L=n.expire),"hidefooter"in n&&r(1,V=n.hidefooter),"hidelogo"in n&&r(2,U=n.hidelogo),"name"in n&&r(3,F=n.name),"maxnumber"in n&&r(15,p=n.maxnumber),"mockerror"in n&&r(16,Y=n.mockerror),"refetchonexpire"in n&&r(17,H=n.refetchonexpire),"spamfilter"in n&&r(18,k=n.spamfilter),"strings"in n&&r(24,x=n.strings),"test"in n&&r(19,m=n.test),"verifyurl"in n&&r(20,y=n.verifyurl),"workers"in n&&r(21,d=n.workers),"workerurl"in n&&r(25,I=n.workerurl)},t.$$.update=()=>{t.$$.dirty[0]&8388608&&(i=u?Ze(u):void 0),t.$$.dirty[0]&16777216&&r(29,o=x?Ze(x):{}),t.$$.dirty[0]&536870912&&r(9,l={ariaLinkLabel:Ae,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),t.$$.dirty[0]&48&&ye("statechange",{payload:B,state:G})},[s,V,U,F,B,G,W,se,ve,l,Vt,Ut,a,j,L,p,Y,H,k,m,y,d,f,u,x,I,He,ae,K,o,Xt,Ft]}class Te extends _t{constructor(e){super(),vt(this,e,jt,St,Qe,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,workerurl:25,configure:26,reset:27,verify:28},Ct,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),w()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),w()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),w()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),w()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),w()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),w()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[25]}set workerurl(e){this.$$set({workerurl:e}),w()}get configure(){return this.$$.ctx[26]}get reset(){return this.$$.ctx[27]}get verify(){return this.$$.ctx[28]}}return customElements.define("altcha-widget",wt(Te,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=t=>t?new Worker(new URL(t)):new Je,O.Altcha=Te,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"}),O}({}); diff --git a/dist/altcha.js b/dist/altcha.js index 9f65a92..758fc23 100644 --- a/dist/altcha.js +++ b/dist/altcha.js @@ -1,208 +1,227 @@ -var it = Object.defineProperty; -var ot = (r, e, t) => e in r ? it(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t; -var T = (r, e, t) => (ot(r, typeof e != "symbol" ? e + "" : e, t), t); +var ot = Object.defineProperty; +var lt = (t, e, r) => e in t ? ot(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; +var T = (t, e, r) => lt(t, typeof e != "symbol" ? e + "" : e, r); +const Ge = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK", st = (t) => Uint8Array.from(atob(t), (e) => e.charCodeAt(0)), ze = typeof window < "u" && window.Blob && new Blob([st(Ge)], { type: "text/javascript;charset=utf-8" }); +function ct(t) { + let e; + try { + if (e = ze && (window.URL || window.webkitURL).createObjectURL(ze), !e) throw ""; + const r = new Worker(e, { + name: t == null ? void 0 : t.name + }); + return r.addEventListener("error", () => { + (window.URL || window.webkitURL).revokeObjectURL(e); + }), r; + } catch { + return new Worker( + "data:text/javascript;base64," + Ge, + { + name: t == null ? void 0 : t.name + } + ); + } finally { + e && (window.URL || window.webkitURL).revokeObjectURL(e); + } +} function ee() { } -function Ue(r) { - return r(); +function De(t) { + return t(); } -function Ie() { +function Ne() { return /* @__PURE__ */ Object.create(null); } -function re(r) { - r.forEach(Ue); +function re(t) { + t.forEach(De); } -function Ge(r) { - return typeof r == "function"; +function Xe(t) { + return typeof t == "function"; } -function lt(r, e) { - return r != r ? e == e : r !== e || r && typeof r == "object" || typeof r == "function"; +function at(t, e) { + return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function"; } -function st(r) { - return Object.keys(r).length === 0; +function ft(t) { + return Object.keys(t).length === 0; } -function v(r, e) { - r.appendChild(e); +function v(t, e) { + t.appendChild(e); } -function ct(r, e, t) { - const i = at(r); +function ut(t, e, r) { + const i = ht(t); if (!i.getElementById(e)) { const o = R("style"); - o.id = e, o.textContent = t, ft(i, o); + o.id = e, o.textContent = r, dt(i, o); } } -function at(r) { - if (!r) - return document; - const e = r.getRootNode ? r.getRootNode() : r.ownerDocument; +function ht(t) { + if (!t) return document; + const e = t.getRootNode ? t.getRootNode() : t.ownerDocument; return e && /** @type {ShadowRoot} */ e.host ? ( /** @type {ShadowRoot} */ e - ) : r.ownerDocument; + ) : t.ownerDocument; } -function ft(r, e) { +function dt(t, e) { return v( /** @type {Document} */ - r.head || r, + t.head || t, e ), e.sheet; } -function j(r, e, t) { - r.insertBefore(e, t || null); +function S(t, e, r) { + t.insertBefore(e, r || null); } -function N(r) { - r.parentNode && r.parentNode.removeChild(r); +function N(t) { + t.parentNode && t.parentNode.removeChild(t); } -function R(r) { - return document.createElement(r); +function R(t) { + return document.createElement(t); } -function O(r) { - return document.createElementNS("http://www.w3.org/2000/svg", r); +function O(t) { + return document.createElementNS("http://www.w3.org/2000/svg", t); } -function ut(r) { - return document.createTextNode(r); +function mt(t) { + return document.createTextNode(t); } function B() { - return ut(" "); + return mt(" "); } -function ae(r, e, t, i) { - return r.addEventListener(e, t, i), () => r.removeEventListener(e, t, i); +function fe(t, e, r, i) { + return t.addEventListener(e, r, i), () => t.removeEventListener(e, r, i); } -function c(r, e, t) { - t == null ? r.removeAttribute(e) : r.getAttribute(e) !== t && r.setAttribute(e, t); +function c(t, e, r) { + r == null ? t.removeAttribute(e) : t.getAttribute(e) !== r && t.setAttribute(e, r); } -function ht(r) { - return Array.from(r.childNodes); +function gt(t) { + return Array.from(t.childNodes); } -function ze(r, e, t) { - r.classList.toggle(e, !!t); +function Ae(t, e, r) { + t.classList.toggle(e, !!r); } -function dt(r, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { - return new CustomEvent(r, { detail: e, bubbles: t, cancelable: i }); +function bt(t, e, { bubbles: r = !1, cancelable: i = !1 } = {}) { + return new CustomEvent(t, { detail: e, bubbles: r, cancelable: i }); } -function mt(r) { +function yt(t) { const e = {}; - return r.childNodes.forEach( + return t.childNodes.forEach( /** @param {Element} node */ - (t) => { - e[t.slot || "default"] = !0; + (r) => { + e[r.slot || "default"] = !0; } ), e; } let te; -function q(r) { - te = r; +function q(t) { + te = t; } -function me() { - if (!te) - throw new Error("Function called outside component initialization"); +function ge() { + if (!te) throw new Error("Function called outside component initialization"); return te; } -function gt(r) { - me().$$.on_mount.push(r); +function vt(t) { + ge().$$.on_mount.push(t); } -function bt(r) { - me().$$.on_destroy.push(r); +function wt(t) { + ge().$$.on_destroy.push(t); } -function yt() { - const r = me(); - return (e, t, { cancelable: i = !1 } = {}) => { - const o = r.$$.callbacks[e]; +function _t() { + const t = ge(); + return (e, r, { cancelable: i = !1 } = {}) => { + const o = t.$$.callbacks[e]; if (o) { - const l = dt( + const l = bt( /** @type {string} */ e, - t, + r, { cancelable: i } ); return o.slice().forEach((s) => { - s.call(r, l); + s.call(t, l); }), !l.defaultPrevented; } return !0; }; } -const J = [], ue = []; +const J = [], he = []; let Q = []; -const Ne = [], De = /* @__PURE__ */ Promise.resolve(); -let he = !1; -function Xe() { - he || (he = !0, De.then($)); +const Se = [], Oe = /* @__PURE__ */ Promise.resolve(); +let de = !1; +function Fe() { + de || (de = !0, Oe.then(_)); } -function vt() { - return Xe(), De; +function pt() { + return Fe(), Oe; } -function de(r) { - Q.push(r); +function me(t) { + Q.push(t); } -const fe = /* @__PURE__ */ new Set(); +const ue = /* @__PURE__ */ new Set(); let K = 0; -function $() { +function _() { if (K !== 0) return; - const r = te; + const t = te; do { try { for (; K < J.length; ) { const e = J[K]; - K++, q(e), wt(e.$$); + K++, q(e), kt(e.$$); } } catch (e) { throw J.length = 0, K = 0, e; } - for (q(null), J.length = 0, K = 0; ue.length; ) - ue.pop()(); + for (q(null), J.length = 0, K = 0; he.length; ) he.pop()(); for (let e = 0; e < Q.length; e += 1) { - const t = Q[e]; - fe.has(t) || (fe.add(t), t()); + const r = Q[e]; + ue.has(r) || (ue.add(r), r()); } Q.length = 0; } while (J.length); - for (; Ne.length; ) - Ne.pop()(); - he = !1, fe.clear(), q(r); + for (; Se.length; ) + Se.pop()(); + de = !1, ue.clear(), q(t); } -function wt(r) { - if (r.fragment !== null) { - r.update(), re(r.before_update); - const e = r.dirty; - r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, e), r.after_update.forEach(de); +function kt(t) { + if (t.fragment !== null) { + t.update(), re(t.before_update); + const e = t.dirty; + t.dirty = [-1], t.fragment && t.fragment.p(t.ctx, e), t.after_update.forEach(me); } } -function _t(r) { - const e = [], t = []; - Q.forEach((i) => r.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), Q = e; +function xt(t) { + const e = [], r = []; + Q.forEach((i) => t.indexOf(i) === -1 ? e.push(i) : r.push(i)), r.forEach((i) => i()), Q = e; } -const pt = /* @__PURE__ */ new Set(); -function kt(r, e) { - r && r.i && (pt.delete(r), r.i(e)); +const Et = /* @__PURE__ */ new Set(); +function $t(t, e) { + t && t.i && (Et.delete(t), t.i(e)); } -function xt(r, e, t) { - const { fragment: i, after_update: o } = r.$$; - i && i.m(e, t), de(() => { - const l = r.$$.on_mount.map(Ue).filter(Ge); - r.$$.on_destroy ? r.$$.on_destroy.push(...l) : re(l), r.$$.on_mount = []; - }), o.forEach(de); +function Ct(t, e, r) { + const { fragment: i, after_update: o } = t.$$; + i && i.m(e, r), me(() => { + const l = t.$$.on_mount.map(De).filter(Xe); + t.$$.on_destroy ? t.$$.on_destroy.push(...l) : re(l), t.$$.on_mount = []; + }), o.forEach(me); } -function Et(r, e) { - const t = r.$$; - t.fragment !== null && (_t(t.after_update), re(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); +function Lt(t, e) { + const r = t.$$; + r.fragment !== null && (xt(r.after_update), re(r.on_destroy), r.fragment && r.fragment.d(e), r.on_destroy = r.fragment = null, r.ctx = []); } -function $t(r, e) { - r.$$.dirty[0] === -1 && (J.push(r), Xe(), r.$$.dirty.fill(0)), r.$$.dirty[e / 31 | 0] |= 1 << e % 31; +function Rt(t, e) { + t.$$.dirty[0] === -1 && (J.push(t), Fe(), t.$$.dirty.fill(0)), t.$$.dirty[e / 31 | 0] |= 1 << e % 31; } -function Ct(r, e, t, i, o, l, s = null, f = [-1]) { +function It(t, e, r, i, o, l, s = null, f = [-1]) { const a = te; - q(r); - const u = r.$$ = { + q(t); + const u = t.$$ = { fragment: null, ctx: [], // state props: l, update: ee, not_equal: o, - bound: Ie(), + bound: Ne(), // lifecycle on_mount: [], on_destroy: [], @@ -211,29 +230,29 @@ function Ct(r, e, t, i, o, l, s = null, f = [-1]) { after_update: [], context: new Map(e.context || (a ? a.$$.context : [])), // everything else - callbacks: Ie(), + callbacks: Ne(), dirty: f, skip_bound: !1, root: e.target || a.$$.root }; s && s(u.root); - let Z = !1; - if (u.ctx = t ? t(r, e.props || {}, (C, M, ...V) => { + let j = !1; + if (u.ctx = r ? r(t, e.props || {}, (C, M, ...V) => { const D = V.length ? V[0] : M; - return u.ctx && o(u.ctx[C], u.ctx[C] = D) && (!u.skip_bound && u.bound[C] && u.bound[C](D), Z && $t(r, C)), M; - }) : [], u.update(), Z = !0, re(u.before_update), u.fragment = i ? i(u.ctx) : !1, e.target) { + return u.ctx && o(u.ctx[C], u.ctx[C] = D) && (!u.skip_bound && u.bound[C] && u.bound[C](D), j && Rt(t, C)), M; + }) : [], u.update(), j = !0, re(u.before_update), u.fragment = i ? i(u.ctx) : !1, e.target) { if (e.hydrate) { - const C = ht(e.target); + const C = gt(e.target); u.fragment && u.fragment.l(C), C.forEach(N); } else u.fragment && u.fragment.c(); - e.intro && kt(r.$$.fragment), xt(r, e.target, e.anchor), $(); + e.intro && $t(t.$$.fragment), Ct(t, e.target, e.anchor), _(); } q(a); } -let Oe; -typeof HTMLElement == "function" && (Oe = class extends HTMLElement { - constructor(e, t, i) { +let He; +typeof HTMLElement == "function" && (He = class extends HTMLElement { + constructor(e, r, i) { super(); /** The Svelte component constructor */ T(this, "$$ctor"); @@ -253,19 +272,19 @@ typeof HTMLElement == "function" && (Oe = class extends HTMLElement { T(this, "$$l", {}); /** @type {Map} Event listener unsubscribe functions */ T(this, "$$l_u", /* @__PURE__ */ new Map()); - this.$$ctor = e, this.$$s = t, i && this.attachShadow({ mode: "open" }); + this.$$ctor = e, this.$$s = r, i && this.attachShadow({ mode: "open" }); } - addEventListener(e, t, i) { - if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(t), this.$$c) { - const o = this.$$c.$on(e, t); - this.$$l_u.set(t, o); + addEventListener(e, r, i) { + if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(r), this.$$c) { + const o = this.$$c.$on(e, r); + this.$$l_u.set(r, o); } - super.addEventListener(e, t, i); + super.addEventListener(e, r, i); } - removeEventListener(e, t, i) { - if (super.removeEventListener(e, t, i), this.$$c) { - const o = this.$$l_u.get(t); - o && (o(), this.$$l_u.delete(t)); + removeEventListener(e, r, i) { + if (super.removeEventListener(e, r, i), this.$$c) { + const o = this.$$l_u.get(r); + o && (o(), this.$$l_u.delete(r)); } } async connectedCallback() { @@ -281,8 +300,8 @@ typeof HTMLElement == "function" && (Oe = class extends HTMLElement { * @param {HTMLElement} target * @param {HTMLElement} [anchor] */ - m: function(u, Z) { - j(u, s, Z); + m: function(u, j) { + S(u, s, j); }, d: function(u) { u && N(s); @@ -292,9 +311,9 @@ typeof HTMLElement == "function" && (Oe = class extends HTMLElement { }; if (await Promise.resolve(), !this.$$cn || this.$$c) return; - const t = {}, i = mt(this); + const r = {}, i = yt(this); for (const l of this.$$s) - l in i && (t[l] = [e(l)]); + l in i && (r[l] = [e(l)]); for (const l of this.attributes) { const s = this.$$g_p(l.name); s in this.$$d || (this.$$d[s] = se(s, l.value, this.$$p_d, "toProp")); @@ -305,7 +324,7 @@ typeof HTMLElement == "function" && (Oe = class extends HTMLElement { target: this.shadowRoot || this, props: { ...this.$$d, - $$slots: t, + $$slots: r, $$scope: { ctx: [] } @@ -336,7 +355,7 @@ typeof HTMLElement == "function" && (Oe = class extends HTMLElement { } // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte // and setting attributes through setAttribute etc, this is helpful - attributeChangedCallback(e, t, i) { + attributeChangedCallback(e, r, i) { var o; this.$$r || (e = this.$$g_p(e), this.$$d[e] = se(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); } @@ -347,14 +366,14 @@ typeof HTMLElement == "function" && (Oe = class extends HTMLElement { } $$g_p(e) { return Object.keys(this.$$p_d).find( - (t) => this.$$p_d[t].attribute === e || !this.$$p_d[t].attribute && t.toLowerCase() === e + (r) => this.$$p_d[r].attribute === e || !this.$$p_d[r].attribute && r.toLowerCase() === e ) || e; } }); -function se(r, e, t, i) { +function se(t, e, r, i) { var l; - const o = (l = t[r]) == null ? void 0 : l.type; - if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[r]) + const o = (l = r[t]) == null ? void 0 : l.type; + if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !r[t]) return e; if (i === "toAttribute") switch (o) { @@ -381,10 +400,10 @@ function se(r, e, t, i) { return e; } } -function Lt(r, e, t, i, o, l) { - let s = class extends Oe { +function zt(t, e, r, i, o, l) { + let s = class extends He { constructor() { - super(r, t, o), this.$$p_d = e; + super(t, r, o), this.$$p_d = e; } static get observedAttributes() { return Object.keys(e).map( @@ -409,10 +428,10 @@ function Lt(r, e, t, i, o, l) { return (a = this.$$c) == null ? void 0 : a[f]; } }); - }), l && (s = l(s)), r.element = /** @type {any} */ + }), l && (s = l(s)), t.element = /** @type {any} */ s, s; } -class Rt { +class Nt { constructor() { /** * ### PRIVATE API @@ -433,7 +452,7 @@ class Rt { } /** @returns {void} */ $destroy() { - Et(this, 1), this.$destroy = ee; + Lt(this, 1), this.$destroy = ee; } /** * @template {Extract} K @@ -441,12 +460,12 @@ class Rt { * @param {((e: Events[K]) => void) | null | undefined} callback * @returns {() => void} */ - $on(e, t) { - if (!Ge(t)) + $on(e, r) { + if (!Xe(r)) return ee; const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); - return i.push(t), () => { - const o = i.indexOf(t); + return i.push(r), () => { + const o = i.indexOf(r); o !== -1 && i.splice(o, 1); }; } @@ -455,42 +474,19 @@ class Rt { * @returns {void} */ $set(e) { - this.$$set && !st(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); - } -} -const It = "4"; -typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(It); -const Fe = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK", zt = (r) => Uint8Array.from(atob(r), (e) => e.charCodeAt(0)), Se = typeof window < "u" && window.Blob && new Blob([zt(Fe)], { type: "text/javascript;charset=utf-8" }); -function Nt(r) { - let e; - try { - if (e = Se && (window.URL || window.webkitURL).createObjectURL(Se), !e) - throw ""; - const t = new Worker(e, { - name: r == null ? void 0 : r.name - }); - return t.addEventListener("error", () => { - (window.URL || window.webkitURL).revokeObjectURL(e); - }), t; - } catch { - return new Worker( - "data:text/javascript;base64," + Fe, - { - name: r == null ? void 0 : r.name - } - ); - } finally { - e && (window.URL || window.webkitURL).revokeObjectURL(e); + this.$$set && !ft(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); } } +const At = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(At); const St = new TextEncoder(); -function jt(r) { - return [...new Uint8Array(r)].map((e) => e.toString(16).padStart(2, "0")).join(""); +function jt(t) { + return [...new Uint8Array(t)].map((e) => e.toString(16).padStart(2, "0")).join(""); } -async function Zt(r, e = "SHA-256", t = 1e5) { +async function Zt(t, e = "SHA-256", r = 1e5) { const i = Date.now().toString(16); - r || (r = Math.round(Math.random() * t)); - const o = await He(i, r, e); + t || (t = Math.round(Math.random() * r)); + const o = await We(i, t, e); return { algorithm: e, challenge: o, @@ -498,22 +494,22 @@ async function Zt(r, e = "SHA-256", t = 1e5) { signature: "" }; } -async function He(r, e, t) { +async function We(t, e, r) { return jt( await crypto.subtle.digest( - t.toUpperCase(), - St.encode(r + e) + r.toUpperCase(), + St.encode(t + e) ) ); } -function At(r, e, t = "SHA-256", i = 1e6, o = 0) { +function Tt(t, e, r = "SHA-256", i = 1e6, o = 0) { const l = new AbortController(), s = Date.now(); return { promise: (async () => { for (let a = o; a <= i; a += 1) { if (l.signal.aborted) return null; - if (await He(e, a, t) === r) + if (await We(e, a, r) === t) return { number: a, took: Date.now() - s @@ -524,41 +520,41 @@ function At(r, e, t = "SHA-256", i = 1e6, o = 0) { controller: l }; } -var b = /* @__PURE__ */ ((r) => (r.ERROR = "error", r.VERIFIED = "verified", r.VERIFYING = "verifying", r.UNVERIFIED = "unverified", r.EXPIRED = "expired", r))(b || {}); -function Tt(r) { - ct(r, "svelte-15co9zy", ".altcha.svelte-15co9zy.svelte-15co9zy{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-15co9zy.svelte-15co9zy{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}"); +var b = /* @__PURE__ */ ((t) => (t.ERROR = "error", t.VERIFIED = "verified", t.VERIFYING = "verifying", t.UNVERIFIED = "unverified", t.EXPIRED = "expired", t))(b || {}); +function Mt(t) { + ut(t, "svelte-15co9zy", ".altcha.svelte-15co9zy.svelte-15co9zy{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-15co9zy.svelte-15co9zy{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}"); } -function je(r) { - let e, t, i; +function je(t) { + let e, r, i; return { c() { - e = O("svg"), t = O("path"), i = O("path"), c(t, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), c(t, "fill", "currentColor"), c(t, "opacity", ".25"), c(i, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), c(i, "fill", "currentColor"), c(i, "class", "altcha-spinner svelte-15co9zy"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg"); + e = O("svg"), r = O("path"), i = O("path"), c(r, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), c(r, "fill", "currentColor"), c(r, "opacity", ".25"), c(i, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), c(i, "fill", "currentColor"), c(i, "class", "altcha-spinner svelte-15co9zy"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg"); }, m(o, l) { - j(o, e, l), v(e, t), v(e, i); + S(o, e, l), v(e, r), v(e, i); }, d(o) { o && N(e); } }; } -function Mt(r) { - let e, t = ( +function Vt(t) { + let e, r = ( /*_strings*/ - r[9].label + "" + t[9].label + "" ), i; return { c() { e = R("label"), c(e, "for", i = /*name*/ - r[3] + "_checkbox"), c(e, "class", "svelte-15co9zy"); + t[3] + "_checkbox"), c(e, "class", "svelte-15co9zy"); }, m(o, l) { - j(o, e, l), e.innerHTML = t; + S(o, e, l), e.innerHTML = r; }, p(o, l) { l[0] & /*_strings*/ - 512 && t !== (t = /*_strings*/ - o[9].label + "") && (e.innerHTML = t), l[0] & /*name*/ + 512 && r !== (r = /*_strings*/ + o[9].label + "") && (e.innerHTML = r), l[0] & /*name*/ 8 && i !== (i = /*name*/ o[3] + "_checkbox") && c(e, "for", i); }, @@ -567,32 +563,32 @@ function Mt(r) { } }; } -function Vt(r) { - let e, t = ( +function Ut(t) { + let e, r = ( /*_strings*/ - r[9].verifying + "" + t[9].verifying + "" ); return { c() { e = R("span"); }, m(i, o) { - j(i, e, o), e.innerHTML = t; + S(i, e, o), e.innerHTML = r; }, p(i, o) { o[0] & /*_strings*/ - 512 && t !== (t = /*_strings*/ - i[9].verifying + "") && (e.innerHTML = t); + 512 && r !== (r = /*_strings*/ + i[9].verifying + "") && (e.innerHTML = r); }, d(i) { i && N(e); } }; } -function Ut(r) { - let e, t = ( +function Gt(t) { + let e, r = ( /*_strings*/ - r[9].verified + "" + t[9].verified + "" ), i, o; return { c() { @@ -600,17 +596,17 @@ function Ut(r) { o, "name", /*name*/ - r[3] + t[3] ), o.value = /*payload*/ - r[4]; + t[4]; }, m(l, s) { - j(l, e, s), e.innerHTML = t, j(l, i, s), j(l, o, s); + S(l, e, s), e.innerHTML = r, S(l, i, s), S(l, o, s); }, p(l, s) { s[0] & /*_strings*/ - 512 && t !== (t = /*_strings*/ - l[9].verified + "") && (e.innerHTML = t), s[0] & /*name*/ + 512 && r !== (r = /*_strings*/ + l[9].verified + "") && (e.innerHTML = r), s[0] & /*name*/ 8 && c( o, "name", @@ -625,41 +621,41 @@ function Ut(r) { } }; } -function Ze(r) { - let e, t, i, o, l, s, f; +function Ze(t) { + let e, r, i, o, l, s, f; return { c() { - e = R("div"), t = R("a"), i = O("svg"), o = O("path"), l = O("path"), s = O("path"), c(o, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), c(o, "fill", "currentColor"), c(l, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), c(l, "fill", "currentColor"), c(s, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), c(s, "fill", "currentColor"), c(i, "width", "22"), c(i, "height", "22"), c(i, "viewBox", "0 0 20 20"), c(i, "fill", "none"), c(i, "xmlns", "http://www.w3.org/2000/svg"), c(t, "href", Ye), c(t, "target", "_blank"), c(t, "class", "altcha-logo svelte-15co9zy"), c(t, "aria-label", f = /*_strings*/ - r[9].ariaLinkLabel); + e = R("div"), r = R("a"), i = O("svg"), o = O("path"), l = O("path"), s = O("path"), c(o, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), c(o, "fill", "currentColor"), c(l, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), c(l, "fill", "currentColor"), c(s, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), c(s, "fill", "currentColor"), c(i, "width", "22"), c(i, "height", "22"), c(i, "viewBox", "0 0 20 20"), c(i, "fill", "none"), c(i, "xmlns", "http://www.w3.org/2000/svg"), c(r, "href", Ye), c(r, "target", "_blank"), c(r, "class", "altcha-logo svelte-15co9zy"), c(r, "aria-label", f = /*_strings*/ + t[9].ariaLinkLabel); }, m(a, u) { - j(a, e, u), v(e, t), v(t, i), v(i, o), v(i, l), v(i, s); + S(a, e, u), v(e, r), v(r, i), v(i, o), v(i, l), v(i, s); }, p(a, u) { u[0] & /*_strings*/ 512 && f !== (f = /*_strings*/ - a[9].ariaLinkLabel) && c(t, "aria-label", f); + a[9].ariaLinkLabel) && c(r, "aria-label", f); }, d(a) { a && N(e); } }; } -function Ae(r) { - let e, t, i, o; +function Te(t) { + let e, r, i, o; function l(a, u) { return ( /*state*/ - a[5] === b.EXPIRED ? Dt : Gt + a[5] === b.EXPIRED ? Xt : Dt ); } - let s = l(r), f = s(r); + let s = l(t), f = s(t); return { c() { - e = R("div"), t = O("svg"), i = O("path"), o = B(), f.c(), c(i, "stroke-linecap", "round"), c(i, "stroke-linejoin", "round"), c(i, "d", "M6 18L18 6M6 6l12 12"), c(t, "width", "14"), c(t, "height", "14"), c(t, "xmlns", "http://www.w3.org/2000/svg"), c(t, "fill", "none"), c(t, "viewBox", "0 0 24 24"), c(t, "stroke-width", "1.5"), c(t, "stroke", "currentColor"), c(e, "class", "altcha-error svelte-15co9zy"); + e = R("div"), r = O("svg"), i = O("path"), o = B(), f.c(), c(i, "stroke-linecap", "round"), c(i, "stroke-linejoin", "round"), c(i, "d", "M6 18L18 6M6 6l12 12"), c(r, "width", "14"), c(r, "height", "14"), c(r, "xmlns", "http://www.w3.org/2000/svg"), c(r, "fill", "none"), c(r, "viewBox", "0 0 24 24"), c(r, "stroke-width", "1.5"), c(r, "stroke", "currentColor"), c(e, "class", "altcha-error svelte-15co9zy"); }, m(a, u) { - j(a, e, u), v(e, t), v(t, i), v(e, o), f.m(e, null); + S(a, e, u), v(e, r), v(r, i), v(e, o), f.m(e, null); }, p(a, u) { s === (s = l(a)) && f ? f.p(a, u) : (f.d(1), f = s(a), f && (f.c(), f.m(e, null))); @@ -669,10 +665,10 @@ function Ae(r) { } }; } -function Gt(r) { - let e, t = ( +function Dt(t) { + let e, r = ( /*_strings*/ - r[9].error + "" + t[9].error + "" ); return { c() { @@ -680,16 +676,16 @@ function Gt(r) { e, "title", /*error*/ - r[8] + t[8] ); }, m(i, o) { - j(i, e, o), e.innerHTML = t; + S(i, e, o), e.innerHTML = r; }, p(i, o) { o[0] & /*_strings*/ - 512 && t !== (t = /*_strings*/ - i[9].error + "") && (e.innerHTML = t), o[0] & /*error*/ + 512 && r !== (r = /*_strings*/ + i[9].error + "") && (e.innerHTML = r), o[0] & /*error*/ 256 && c( e, "title", @@ -702,10 +698,10 @@ function Gt(r) { } }; } -function Dt(r) { - let e, t = ( +function Xt(t) { + let e, r = ( /*_strings*/ - r[9].expired + "" + t[9].expired + "" ); return { c() { @@ -713,16 +709,16 @@ function Dt(r) { e, "title", /*error*/ - r[8] + t[8] ); }, m(i, o) { - j(i, e, o), e.innerHTML = t; + S(i, e, o), e.innerHTML = r; }, p(i, o) { o[0] & /*_strings*/ - 512 && t !== (t = /*_strings*/ - i[9].expired + "") && (e.innerHTML = t), o[0] & /*error*/ + 512 && r !== (r = /*_strings*/ + i[9].expired + "") && (e.innerHTML = r), o[0] & /*error*/ 256 && c( e, "title", @@ -735,113 +731,113 @@ function Dt(r) { } }; } -function Te(r) { - let e, t, i = ( +function Me(t) { + let e, r, i = ( /*_strings*/ - r[9].footer + "" + t[9].footer + "" ); return { c() { - e = R("div"), t = R("div"), c(t, "class", "svelte-15co9zy"), c(e, "class", "altcha-footer svelte-15co9zy"); + e = R("div"), r = R("div"), c(r, "class", "svelte-15co9zy"), c(e, "class", "altcha-footer svelte-15co9zy"); }, m(o, l) { - j(o, e, l), v(e, t), t.innerHTML = i; + S(o, e, l), v(e, r), r.innerHTML = i; }, p(o, l) { l[0] & /*_strings*/ 512 && i !== (i = /*_strings*/ - o[9].footer + "") && (t.innerHTML = i); + o[9].footer + "") && (r.innerHTML = i); }, d(o) { o && N(e); } }; } -function Xt(r) { - let e, t, i, o, l, s, f, a, u, Z, C, M, V, D, _ = ( +function Ot(t) { + let e, r, i, o, l, s, f, a, u, j, C, M, V, D, p = ( /*state*/ - r[5] === b.VERIFYING && je() + t[5] === b.VERIFYING && je() ); function H(d, I) { return ( /*state*/ - d[5] === b.VERIFIED ? Ut : ( + d[5] === b.VERIFIED ? Gt : ( /*state*/ - d[5] === b.VERIFYING ? Vt : Mt + d[5] === b.VERIFYING ? Ut : Vt ) ); } - let X = H(r), p = X(r), k = ( + let X = H(t), k = X(t), x = ( /*hidelogo*/ - r[2] !== !0 && Ze(r) + t[2] !== !0 && Ze(t) ), m = ( /*error*/ - (r[8] || /*state*/ - r[5] === b.EXPIRED) && Ae(r) + (t[8] || /*state*/ + t[5] === b.EXPIRED) && Te(t) ), y = ( /*_strings*/ - r[9].footer && /*hidefooter*/ - r[1] !== !0 && Te(r) + t[9].footer && /*hidefooter*/ + t[1] !== !0 && Me(t) ); return { c() { - e = R("div"), t = R("div"), _ && _.c(), i = B(), o = R("div"), l = R("input"), a = B(), u = R("div"), p.c(), Z = B(), k && k.c(), C = B(), m && m.c(), M = B(), y && y.c(), c(l, "type", "checkbox"), c(l, "id", s = /*name*/ - r[3] + "_checkbox"), l.required = f = /*auto*/ - r[0] !== "onsubmit", c(l, "class", "svelte-15co9zy"), c(o, "class", "altcha-checkbox svelte-15co9zy"), ze( + e = R("div"), r = R("div"), p && p.c(), i = B(), o = R("div"), l = R("input"), a = B(), u = R("div"), k.c(), j = B(), x && x.c(), C = B(), m && m.c(), M = B(), y && y.c(), c(l, "type", "checkbox"), c(l, "id", s = /*name*/ + t[3] + "_checkbox"), l.required = f = /*auto*/ + t[0] !== "onsubmit", c(l, "class", "svelte-15co9zy"), c(o, "class", "altcha-checkbox svelte-15co9zy"), Ae( o, "altcha-hidden", /*state*/ - r[5] === b.VERIFYING - ), c(u, "class", "altcha-label svelte-15co9zy"), c(t, "class", "altcha-main svelte-15co9zy"), c(e, "class", "altcha svelte-15co9zy"), c( + t[5] === b.VERIFYING + ), c(u, "class", "altcha-label svelte-15co9zy"), c(r, "class", "altcha-main svelte-15co9zy"), c(e, "class", "altcha svelte-15co9zy"), c( e, "data-state", /*state*/ - r[5] + t[5] ); }, m(d, I) { - j(d, e, I), v(e, t), _ && _.m(t, null), v(t, i), v(t, o), v(o, l), l.checked = /*checked*/ - r[6], v(t, a), v(t, u), p.m(u, null), v(t, Z), k && k.m(t, null), v(e, C), m && m.m(e, null), v(e, M), y && y.m(e, null), r[30](e), V || (D = [ - ae( + S(d, e, I), v(e, r), p && p.m(r, null), v(r, i), v(r, o), v(o, l), l.checked = /*checked*/ + t[6], v(r, a), v(r, u), k.m(u, null), v(r, j), x && x.m(r, null), v(e, C), m && m.m(e, null), v(e, M), y && y.m(e, null), t[31](e), V || (D = [ + fe( l, "change", /*input_change_handler*/ - r[29] + t[30] ), - ae( + fe( l, "change", /*onCheckedChange*/ - r[10] + t[10] ), - ae( + fe( l, "invalid", /*onInvalid*/ - r[11] + t[11] ) ], V = !0); }, p(d, I) { /*state*/ - d[5] === b.VERIFYING ? _ || (_ = je(), _.c(), _.m(t, i)) : _ && (_.d(1), _ = null), I[0] & /*name*/ + d[5] === b.VERIFYING ? p || (p = je(), p.c(), p.m(r, i)) : p && (p.d(1), p = null), I[0] & /*name*/ 8 && s !== (s = /*name*/ d[3] + "_checkbox") && c(l, "id", s), I[0] & /*auto*/ 1 && f !== (f = /*auto*/ d[0] !== "onsubmit") && (l.required = f), I[0] & /*checked*/ 64 && (l.checked = /*checked*/ d[6]), I[0] & /*state*/ - 32 && ze( + 32 && Ae( o, "altcha-hidden", /*state*/ d[5] === b.VERIFYING - ), X === (X = H(d)) && p ? p.p(d, I) : (p.d(1), p = X(d), p && (p.c(), p.m(u, null))), /*hidelogo*/ - d[2] !== !0 ? k ? k.p(d, I) : (k = Ze(d), k.c(), k.m(t, null)) : k && (k.d(1), k = null), /*error*/ + ), X === (X = H(d)) && k ? k.p(d, I) : (k.d(1), k = X(d), k && (k.c(), k.m(u, null))), /*hidelogo*/ + d[2] !== !0 ? x ? x.p(d, I) : (x = Ze(d), x.c(), x.m(r, null)) : x && (x.d(1), x = null), /*error*/ d[8] || /*state*/ - d[5] === b.EXPIRED ? m ? m.p(d, I) : (m = Ae(d), m.c(), m.m(e, M)) : m && (m.d(1), m = null), /*_strings*/ + d[5] === b.EXPIRED ? m ? m.p(d, I) : (m = Te(d), m.c(), m.m(e, M)) : m && (m.d(1), m = null), /*_strings*/ d[9].footer && /*hidefooter*/ - d[1] !== !0 ? y ? y.p(d, I) : (y = Te(d), y.c(), y.m(e, null)) : y && (y.d(1), y = null), I[0] & /*state*/ + d[1] !== !0 ? y ? y.p(d, I) : (y = Me(d), y.c(), y.m(e, null)) : y && (y.d(1), y = null), I[0] & /*state*/ 32 && c( e, "data-state", @@ -852,45 +848,45 @@ function Xt(r) { i: ee, o: ee, d(d) { - d && N(e), _ && _.d(), p.d(), k && k.d(), m && m.d(), y && y.d(), r[30](null), V = !1, re(D); + d && N(e), p && p.d(), k.d(), x && x.d(), m && m.d(), y && y.d(), t[31](null), V = !1, re(D); } }; } -const Me = "Visit Altcha.org", Ye = "https://altcha.org/"; -function Ve(r) { - return JSON.parse(r); +const Ve = "Visit Altcha.org", Ye = "https://altcha.org/"; +function Ue(t) { + return JSON.parse(t); } -function Ot() { +function Ft() { try { return Intl.DateTimeFormat().resolvedOptions().timeZone; } catch { } } -function Ft(r, e, t) { - var Ee, $e; - let i, o, l, { auto: s = void 0 } = e, { blockspam: f = void 0 } = e, { challengeurl: a = void 0 } = e, { challengejson: u = void 0 } = e, { debug: Z = !1 } = e, { expire: C = void 0 } = e, { hidefooter: M = !1 } = e, { hidelogo: V = !1 } = e, { name: D = "altcha" } = e, { maxnumber: _ = 1e6 } = e, { mockerror: H = !1 } = e, { refetchonexpire: X = !0 } = e, { spamfilter: p = !1 } = e, { strings: k = void 0 } = e, { test: m = !1 } = e, { verifyurl: y = void 0 } = e, { workers: d = Math.min(16, navigator.hardwareConcurrency || 8) } = e; - const I = yt(), ge = ["SHA-256", "SHA-384", "SHA-512"], be = ($e = (Ee = document.documentElement.lang) == null ? void 0 : Ee.split("-")) == null ? void 0 : $e[0]; - let F = !1, ne, g = null, ce = null, Y = null, U = b.UNVERIFIED, G = null; - bt(() => { - g && (g.removeEventListener("submit", ve), g.removeEventListener("reset", we), g.removeEventListener("focusin", ye), g = null), G && (clearTimeout(G), G = null); - }), gt(() => { - L("mounted", "0.4.3"), L("workers", d), m && L("using test mode"), C && ie(C), s !== void 0 && L("auto", s), g = ne.closest("form"), g && (g.addEventListener("submit", ve), g.addEventListener("reset", we), s === "onfocus" && g.addEventListener("focusin", ye)), s === "onload" && P(); +function Ht(t, e, r) { + var $e, Ce; + let i, o, l, { auto: s = void 0 } = e, { blockspam: f = void 0 } = e, { challengeurl: a = void 0 } = e, { challengejson: u = void 0 } = e, { debug: j = !1 } = e, { expire: C = void 0 } = e, { hidefooter: M = !1 } = e, { hidelogo: V = !1 } = e, { name: D = "altcha" } = e, { maxnumber: p = 1e6 } = e, { mockerror: H = !1 } = e, { refetchonexpire: X = !0 } = e, { spamfilter: k = !1 } = e, { strings: x = void 0 } = e, { test: m = !1 } = e, { verifyurl: y = void 0 } = e, { workers: d = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: I = void 0 } = e; + const ce = _t(), be = ["SHA-256", "SHA-384", "SHA-512"], ye = (Ce = ($e = document.documentElement.lang) == null ? void 0 : $e.split("-")) == null ? void 0 : Ce[0]; + let F = !1, ne, g = null, ae = null, W = null, U = b.UNVERIFIED, G = null; + wt(() => { + g && (g.removeEventListener("submit", we), g.removeEventListener("reset", _e), g.removeEventListener("focusin", ve), g = null), G && (clearTimeout(G), G = null); + }), vt(() => { + L("mounted", "0.4.3"), L("workers", d), m && L("using test mode"), C && ie(C), s !== void 0 && L("auto", s), g = ne.closest("form"), g && (g.addEventListener("submit", we), g.addEventListener("reset", _e), s === "onfocus" && g.addEventListener("focusin", ve)), s === "onload" && Y(); }); function L(...n) { - (Z || n.some((h) => h instanceof Error)) && console[n[0] instanceof Error ? "error" : "log"]("ALTCHA", ...n); - } - function ye(n) { - U === b.UNVERIFIED && P(); + (j || n.some((h) => h instanceof Error)) && console[n[0] instanceof Error ? "error" : "log"]("ALTCHA", ...n); } function ve(n) { - g && s === "onsubmit" && U === b.UNVERIFIED && (n.preventDefault(), n.stopPropagation(), P().then(() => { + U === b.UNVERIFIED && Y(); + } + function we(n) { + g && s === "onsubmit" && U === b.UNVERIFIED && (n.preventDefault(), n.stopPropagation(), Y().then(() => { g == null || g.requestSubmit(); })); } - function we() { + function _e() { oe(); } - function _e(n, h) { + function pe(n, h) { return btoa(JSON.stringify({ algorithm: n.algorithm, challenge: n.challenge, @@ -901,13 +897,13 @@ function Ft(r, e, t) { took: h.took })); } - function pe(n) { + function ke(n) { if (!n.algorithm) throw new Error("Invalid challenge. Property algorithm is missing."); if (n.signature === void 0) throw new Error("Invalid challenge. Property signature is missing."); - if (!ge.includes(n.algorithm.toUpperCase())) - throw new Error(`Unknown algorithm value. Allowed values: ${ge.join(", ")}`); + if (!be.includes(n.algorithm.toUpperCase())) + throw new Error(`Unknown algorithm value. Allowed values: ${be.join(", ")}`); if (!n.challenge || n.challenge.length < 40) throw new Error("Challenge is too short. Min. 40 chars."); if (!n.salt || n.salt.length < 10) @@ -927,41 +923,41 @@ function Ft(r, e, t) { L("fetching challenge from", a); const h = await fetch(a, { headers: { - "x-altcha-spam-filter": p ? "1" : "0" + "x-altcha-spam-filter": k ? "1" : "0" } }); if (h.status !== 200) throw new Error(`Server responded with ${h.status}.`); - const w = h.headers.get("Expires"), z = h.headers.get("X-Altcha-Config"), S = await h.json(), A = new URLSearchParams((n = S.salt.split("?")) == null ? void 0 : n[1]), W = A.get("expires") || A.get("expire"); - if (W) { - const x = new Date(+W * 1e3), E = isNaN(x.getTime()) ? 0 : x.getTime() - Date.now(); - E > 0 && ie(E); + const w = h.headers.get("Expires"), z = h.headers.get("X-Altcha-Config"), A = await h.json(), Z = new URLSearchParams((n = A.salt.split("?")) == null ? void 0 : n[1]), P = Z.get("expires") || Z.get("expire"); + if (P) { + const E = new Date(+P * 1e3), $ = isNaN(E.getTime()) ? 0 : E.getTime() - Date.now(); + $ > 0 && ie($); } if (z) try { - const x = JSON.parse(z); - x && typeof x == "object" && (x.verifyurl && (x.verifyurl = new URL(x.verifyurl, new URL(a)).toString()), xe(x)); - } catch (x) { - L("unable to configure from X-Altcha-Config", x); + const E = JSON.parse(z); + E && typeof E == "object" && (E.verifyurl && (E.verifyurl = new URL(E.verifyurl, new URL(a)).toString()), Ee(E)); + } catch (E) { + L("unable to configure from X-Altcha-Config", E); } if (!C && (w != null && w.length)) { - const x = Date.parse(w); - if (x) { - const E = x - Date.now(); - E > 0 && ie(E); + const E = Date.parse(w); + if (E) { + const $ = E - Date.now(); + $ > 0 && ie($); } } - return S; + return A; } } - function ke() { - a && X && U === b.VERIFIED ? P() : oe(b.EXPIRED, l.expired); + function xe() { + a && X && U === b.VERIFIED ? Y() : oe(b.EXPIRED, l.expired); } - async function We(n) { + async function Be(n) { let h = null; if ("Worker" in window) { try { - h = await Be(n.challenge, n.salt, n.algorithm, n.maxnumber); + h = await Ke(n.challenge, n.salt, n.algorithm, n.maxnumber); } catch (w) { L(w); } @@ -970,73 +966,73 @@ function Ft(r, e, t) { } return { data: n, - solution: await At(n.challenge, n.salt, n.algorithm, n.maxnumber || _).promise + solution: await Tt(n.challenge, n.salt, n.algorithm, n.maxnumber || p).promise }; } - async function Be(n, h, w, z = typeof m == "number" ? m : _, S = Math.ceil(d)) { - const A = []; - if (S < 1) + async function Ke(n, h, w, z = typeof m == "number" ? m : p, A = Math.ceil(d)) { + const Z = []; + if (A < 1) throw new Error("Wrong number of workers configured."); - if (S > 16) + if (A > 16) throw new Error("Too many workers. Max. 16 allowed workers."); - for (let E = 0; E < S; E++) - A.push(new Nt()); - const W = Math.ceil(z / S), x = await Promise.all(A.map((E, le) => { - const Ce = le * W; - return new Promise((nt) => { - E.addEventListener("message", (Le) => { - if (Le.data) - for (const Re of A) - Re !== E && Re.postMessage({ type: "abort" }); - nt(Le.data); - }), E.postMessage({ + for (let $ = 0; $ < A; $++) + Z.push(createAltchaWorker(I)); + const P = Math.ceil(z / A), E = await Promise.all(Z.map(($, le) => { + const Le = le * P; + return new Promise((it) => { + $.addEventListener("message", (Re) => { + if (Re.data) + for (const Ie of Z) + Ie !== $ && Ie.postMessage({ type: "abort" }); + it(Re.data); + }), $.postMessage({ payload: { alg: w, challenge: n, - max: Ce + W, + max: Le + P, salt: h, - start: Ce + start: Le }, type: "work" }); }); })); - for (const E of A) - E.terminate(); - return x.find((E) => !!E) || null; - } - function Ke() { - [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(U) ? p && (g == null ? void 0 : g.reportValidity()) === !1 ? t(6, F = !1) : P() : t(6, F = !0); + for (const $ of Z) + $.terminate(); + return E.find(($) => !!$) || null; } function Je() { + [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(U) ? k && (g == null ? void 0 : g.reportValidity()) === !1 ? r(6, F = !1) : Y() : r(6, F = !0); + } + function Qe() { U === b.VERIFYING && alert(l.waitAlert); } function ie(n) { - L("expire", n), G && (clearTimeout(G), G = null), n < 1 ? ke() : G = setTimeout(ke, n); + L("expire", n), G && (clearTimeout(G), G = null), n < 1 ? xe() : G = setTimeout(xe, n); } - function Qe(n) { + function qe(n) { var w; const h = g == null ? void 0 : g.querySelector(typeof n == "string" ? `input[name="${n}"]` : 'input[type="email"]:not([data-no-spamfilter])'); return ((w = h == null ? void 0 : h.value) == null ? void 0 : w.slice(h.value.indexOf("@"))) || void 0; } - function qe(n) { + function et(n) { return [ ...(g == null ? void 0 : g.querySelectorAll(n != null && n.length ? n.map((w) => `input[name="${w}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] ].reduce( (w, z) => { - const S = z.name, A = z.value.trim(); - return S && A && (w[S] = A), w; + const A = z.name, Z = z.value.trim(); + return A && Z && (w[A] = Z), w; }, {} ); } - async function et(n) { + async function tt(n) { if (!y) throw new Error("Attribute verifyurl not set."); L("requesting server verification from", y); const h = { payload: n }; - if (p) { - const { email: S, expectedLanguages: A, expectedCountries: W, fields: x, ipAddress: E, timeZone: le } = typeof p == "object" ? p : { + if (k) { + const { email: A, expectedLanguages: Z, expectedCountries: P, fields: E, ipAddress: $, timeZone: le } = typeof k == "object" ? k : { email: void 0, expectedCountries: void 0, expectedLanguages: void 0, @@ -1044,7 +1040,7 @@ function Ft(r, e, t) { ipAddress: void 0, timeZone: void 0 }; - h.ipAddress = E === !1 ? void 0 : E || "auto", h.email = S === !1 ? void 0 : Qe(S), h.fields = x === !1 ? void 0 : qe(x), h.timeZone = le === !1 ? void 0 : le || Ot(), h.expectedCountries = W, h.expectedLanguages = A || (be ? [be] : void 0); + h.ipAddress = $ === !1 ? void 0 : $ || "auto", h.email = A === !1 ? void 0 : qe(A), h.fields = E === !1 ? void 0 : et(E), h.timeZone = le === !1 ? void 0 : le || Ft(), h.expectedCountries = P, h.expectedLanguages = Z || (ye ? [ye] : void 0); } const w = await fetch(y, { body: JSON.stringify(h), @@ -1054,99 +1050,100 @@ function Ft(r, e, t) { if (w.status !== 200) throw new Error(`Server responded with ${w.status}.`); const z = await w.json(); - if (z != null && z.payload && t(4, Y = z.payload), I("serververification", z), f && z.classification === "BAD") + if (z != null && z.payload && r(4, W = z.payload), ce("serververification", z), f && z.classification === "BAD") throw new Error("SpamFilter returned negative classification."); } - function xe(n) { - n.auto !== void 0 && (t(0, s = n.auto), s === "onload" && P()), n.expire !== void 0 && (ie(n.expire), t(14, C = n.expire)), n.challenge && (pe(n.challenge), i = n.challenge), n.challengeurl !== void 0 && t(12, a = n.challengeurl), n.debug !== void 0 && t(13, Z = !!n.debug), n.hidefooter !== void 0 && t(1, M = !!n.hidefooter), n.hidelogo !== void 0 && t(2, V = !!n.hidelogo), n.maxnumber !== void 0 && t(15, _ = +n.maxnumber), n.mockerror !== void 0 && t(16, H = !!n.mockerror), n.name !== void 0 && t(3, D = n.name), n.refetchonexpire !== void 0 && t(17, X = !!n.refetchonexpire), n.spamfilter !== void 0 && t(18, p = typeof n.spamfilter == "object" ? n.spamfilter : !!n.spamfilter), n.strings && t(28, o = n.strings), n.test !== void 0 && t(19, m = typeof n.test == "number" ? n.test : !!n.test), n.verifyurl !== void 0 && t(20, y = n.verifyurl), n.workers !== void 0 && t(21, d = +n.workers); + function Ee(n) { + n.auto !== void 0 && (r(0, s = n.auto), s === "onload" && Y()), n.expire !== void 0 && (ie(n.expire), r(14, C = n.expire)), n.challenge && (ke(n.challenge), i = n.challenge), n.challengeurl !== void 0 && r(12, a = n.challengeurl), n.debug !== void 0 && r(13, j = !!n.debug), n.hidefooter !== void 0 && r(1, M = !!n.hidefooter), n.hidelogo !== void 0 && r(2, V = !!n.hidelogo), n.maxnumber !== void 0 && r(15, p = +n.maxnumber), n.mockerror !== void 0 && r(16, H = !!n.mockerror), n.name !== void 0 && r(3, D = n.name), n.refetchonexpire !== void 0 && r(17, X = !!n.refetchonexpire), n.spamfilter !== void 0 && r(18, k = typeof n.spamfilter == "object" ? n.spamfilter : !!n.spamfilter), n.strings && r(29, o = n.strings), n.test !== void 0 && r(19, m = typeof n.test == "number" ? n.test : !!n.test), n.verifyurl !== void 0 && r(20, y = n.verifyurl), n.workers !== void 0 && r(21, d = +n.workers); } function oe(n = b.UNVERIFIED, h = null) { - G && (clearTimeout(G), G = null), t(6, F = !1), t(8, ce = h), t(4, Y = null), t(5, U = n); + G && (clearTimeout(G), G = null), r(6, F = !1), r(8, ae = h), r(4, W = null), r(5, U = n); } - async function P() { - return oe(b.VERIFYING), Pe().then((n) => (pe(n), L("challenge", n), We(n))).then(({ data: n, solution: h }) => { + async function Y() { + return oe(b.VERIFYING), Pe().then((n) => (ke(n), L("challenge", n), Be(n))).then(({ data: n, solution: h }) => { if (L("solution", h), (h == null ? void 0 : h.number) !== void 0) { if (y) - return et(_e(n, h)); - t(4, Y = _e(n, h)), L("payload", Y); + return tt(pe(n, h)); + r(4, W = pe(n, h)), L("payload", W); } else throw L("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); }).then(() => { - vt().then(() => { - t(5, U = b.VERIFIED), t(6, F = !0), L("verified"), I("verified", { payload: Y }); + pt().then(() => { + r(5, U = b.VERIFIED), r(6, F = !0), L("verified"), ce("verified", { payload: W }); }); }).catch((n) => { - L(n), t(5, U = b.ERROR), t(6, F = !1), t(8, ce = n.message); + L(n), r(5, U = b.ERROR), r(6, F = !1), r(8, ae = n.message); }); } - function tt() { - F = this.checked, t(6, F); + function rt() { + F = this.checked, r(6, F); } - function rt(n) { - ue[n ? "unshift" : "push"](() => { - ne = n, t(7, ne); + function nt(n) { + he[n ? "unshift" : "push"](() => { + ne = n, r(7, ne); }); } - return r.$$set = (n) => { - "auto" in n && t(0, s = n.auto), "blockspam" in n && t(22, f = n.blockspam), "challengeurl" in n && t(12, a = n.challengeurl), "challengejson" in n && t(23, u = n.challengejson), "debug" in n && t(13, Z = n.debug), "expire" in n && t(14, C = n.expire), "hidefooter" in n && t(1, M = n.hidefooter), "hidelogo" in n && t(2, V = n.hidelogo), "name" in n && t(3, D = n.name), "maxnumber" in n && t(15, _ = n.maxnumber), "mockerror" in n && t(16, H = n.mockerror), "refetchonexpire" in n && t(17, X = n.refetchonexpire), "spamfilter" in n && t(18, p = n.spamfilter), "strings" in n && t(24, k = n.strings), "test" in n && t(19, m = n.test), "verifyurl" in n && t(20, y = n.verifyurl), "workers" in n && t(21, d = n.workers); - }, r.$$.update = () => { - r.$$.dirty[0] & /*challengejson*/ - 8388608 && (i = u ? Ve(u) : void 0), r.$$.dirty[0] & /*strings*/ - 16777216 && t(28, o = k ? Ve(k) : {}), r.$$.dirty[0] & /*parsedStrings*/ - 268435456 && t(9, l = { - ariaLinkLabel: Me, + return t.$$set = (n) => { + "auto" in n && r(0, s = n.auto), "blockspam" in n && r(22, f = n.blockspam), "challengeurl" in n && r(12, a = n.challengeurl), "challengejson" in n && r(23, u = n.challengejson), "debug" in n && r(13, j = n.debug), "expire" in n && r(14, C = n.expire), "hidefooter" in n && r(1, M = n.hidefooter), "hidelogo" in n && r(2, V = n.hidelogo), "name" in n && r(3, D = n.name), "maxnumber" in n && r(15, p = n.maxnumber), "mockerror" in n && r(16, H = n.mockerror), "refetchonexpire" in n && r(17, X = n.refetchonexpire), "spamfilter" in n && r(18, k = n.spamfilter), "strings" in n && r(24, x = n.strings), "test" in n && r(19, m = n.test), "verifyurl" in n && r(20, y = n.verifyurl), "workers" in n && r(21, d = n.workers), "workerurl" in n && r(25, I = n.workerurl); + }, t.$$.update = () => { + t.$$.dirty[0] & /*challengejson*/ + 8388608 && (i = u ? Ue(u) : void 0), t.$$.dirty[0] & /*strings*/ + 16777216 && r(29, o = x ? Ue(x) : {}), t.$$.dirty[0] & /*parsedStrings*/ + 536870912 && r(9, l = { + ariaLinkLabel: Ve, error: "Verification failed. Try again later.", expired: "Verification expired. Try again.", - footer: `Protected by ALTCHA`, + footer: `Protected by ALTCHA`, label: "I'm not a robot", verified: "Verified", verifying: "Verifying...", waitAlert: "Verifying... please wait.", ...o - }), r.$$.dirty[0] & /*payload, state*/ - 48 && I("statechange", { payload: Y, state: U }); + }), t.$$.dirty[0] & /*payload, state*/ + 48 && ce("statechange", { payload: W, state: U }); }, [ s, M, V, D, - Y, + W, U, F, ne, - ce, + ae, l, - Ke, Je, + Qe, a, - Z, + j, C, - _, + p, H, X, - p, + k, m, y, d, f, u, - k, - xe, + x, + I, + Ee, oe, - P, + Y, o, - tt, - rt + rt, + nt ]; } -class Ht extends Rt { +class Wt extends Nt { constructor(e) { - super(), Ct( + super(), It( this, e, - Ft, - Xt, - lt, + Ht, + Ot, + at, { auto: 0, blockspam: 22, @@ -1165,11 +1162,12 @@ class Ht extends Rt { test: 19, verifyurl: 20, workers: 21, - configure: 25, - reset: 26, - verify: 27 + workerurl: 25, + configure: 26, + reset: 27, + verify: 28 }, - Tt, + Mt, [-1, -1] ); } @@ -1177,115 +1175,122 @@ class Ht extends Rt { return this.$$.ctx[0]; } set auto(e) { - this.$$set({ auto: e }), $(); + this.$$set({ auto: e }), _(); } get blockspam() { return this.$$.ctx[22]; } set blockspam(e) { - this.$$set({ blockspam: e }), $(); + this.$$set({ blockspam: e }), _(); } get challengeurl() { return this.$$.ctx[12]; } set challengeurl(e) { - this.$$set({ challengeurl: e }), $(); + this.$$set({ challengeurl: e }), _(); } get challengejson() { return this.$$.ctx[23]; } set challengejson(e) { - this.$$set({ challengejson: e }), $(); + this.$$set({ challengejson: e }), _(); } get debug() { return this.$$.ctx[13]; } set debug(e) { - this.$$set({ debug: e }), $(); + this.$$set({ debug: e }), _(); } get expire() { return this.$$.ctx[14]; } set expire(e) { - this.$$set({ expire: e }), $(); + this.$$set({ expire: e }), _(); } get hidefooter() { return this.$$.ctx[1]; } set hidefooter(e) { - this.$$set({ hidefooter: e }), $(); + this.$$set({ hidefooter: e }), _(); } get hidelogo() { return this.$$.ctx[2]; } set hidelogo(e) { - this.$$set({ hidelogo: e }), $(); + this.$$set({ hidelogo: e }), _(); } get name() { return this.$$.ctx[3]; } set name(e) { - this.$$set({ name: e }), $(); + this.$$set({ name: e }), _(); } get maxnumber() { return this.$$.ctx[15]; } set maxnumber(e) { - this.$$set({ maxnumber: e }), $(); + this.$$set({ maxnumber: e }), _(); } get mockerror() { return this.$$.ctx[16]; } set mockerror(e) { - this.$$set({ mockerror: e }), $(); + this.$$set({ mockerror: e }), _(); } get refetchonexpire() { return this.$$.ctx[17]; } set refetchonexpire(e) { - this.$$set({ refetchonexpire: e }), $(); + this.$$set({ refetchonexpire: e }), _(); } get spamfilter() { return this.$$.ctx[18]; } set spamfilter(e) { - this.$$set({ spamfilter: e }), $(); + this.$$set({ spamfilter: e }), _(); } get strings() { return this.$$.ctx[24]; } set strings(e) { - this.$$set({ strings: e }), $(); + this.$$set({ strings: e }), _(); } get test() { return this.$$.ctx[19]; } set test(e) { - this.$$set({ test: e }), $(); + this.$$set({ test: e }), _(); } get verifyurl() { return this.$$.ctx[20]; } set verifyurl(e) { - this.$$set({ verifyurl: e }), $(); + this.$$set({ verifyurl: e }), _(); } get workers() { return this.$$.ctx[21]; } set workers(e) { - this.$$set({ workers: e }), $(); + this.$$set({ workers: e }), _(); } - get configure() { + get workerurl() { return this.$$.ctx[25]; } - get reset() { + set workerurl(e) { + this.$$set({ workerurl: e }), _(); + } + get configure() { return this.$$.ctx[26]; } - get verify() { + get reset() { return this.$$.ctx[27]; } + get verify() { + return this.$$.ctx[28]; + } } -customElements.define("altcha-widget", Lt(Ht, { auto: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, expire: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {} }, [], ["configure", "reset", "verify"], !1)); +customElements.define("altcha-widget", zt(Wt, { auto: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, expire: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, [], ["configure", "reset", "verify"], !1)); +globalThis.createAltchaWorker = (t) => t ? new Worker(new URL(t)) : new ct(); export { - Ht as Altcha + Wt as Altcha }; diff --git a/dist/altcha.umd.cjs b/dist/altcha.umd.cjs index 46df186..641a7ec 100644 --- a/dist/altcha.umd.cjs +++ b/dist/altcha.umd.cjs @@ -1 +1 @@ -(function(T,I){typeof exports=="object"&&typeof module<"u"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):(T=typeof globalThis<"u"?globalThis:T||self,I(T.altcha={}))})(this,function(T){"use strict";var Ht=Object.defineProperty;var Pt=(T,I,P)=>I in T?Ht(T,I,{enumerable:!0,configurable:!0,writable:!0,value:P}):T[I]=P;var V=(T,I,P)=>(Pt(T,typeof I!="symbol"?I+"":I,P),P);function I(){}function P(r){return r()}function ye(){return Object.create(null)}function re(r){r.forEach(P)}function ve(r){return typeof r=="function"}function Be(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function Ke(r){return Object.keys(r).length===0}function v(r,e){r.appendChild(e)}function Je(r,e,t){const i=Qe(r);if(!i.getElementById(e)){const o=C("style");o.id=e,o.textContent=t,qe(i,o)}}function Qe(r){if(!r)return document;const e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function qe(r,e){return v(r.head||r,e),e.sheet}function j(r,e,t){r.insertBefore(e,t||null)}function N(r){r.parentNode&&r.parentNode.removeChild(r)}function C(r){return document.createElement(r)}function X(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function et(r){return document.createTextNode(r)}function W(){return et(" ")}function fe(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function c(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function tt(r){return Array.from(r.childNodes)}function we(r,e,t){r.classList.toggle(e,!!t)}function rt(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function nt(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ne;function ie(r){ne=r}function ue(){if(!ne)throw new Error("Function called outside component initialization");return ne}function it(r){ue().$$.on_mount.push(r)}function ot(r){ue().$$.on_destroy.push(r)}function lt(){const r=ue();return(e,t,{cancelable:i=!1}={})=>{const o=r.$$.callbacks[e];if(o){const l=rt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(r,l)}),!l.defaultPrevented}return!0}}const q=[],he=[];let ee=[];const pe=[],_e=Promise.resolve();let de=!1;function ke(){de||(de=!0,_e.then(p))}function st(){return ke(),_e}function me(r){ee.push(r)}const ge=new Set;let te=0;function p(){if(te!==0)return;const r=ne;do{try{for(;ter.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),ee=e}const ft=new Set;function ut(r,e){r&&r.i&&(ft.delete(r),r.i(e))}function ht(r,e,t){const{fragment:i,after_update:o}=r.$$;i&&i.m(e,t),me(()=>{const l=r.$$.on_mount.map(P).filter(ve);r.$$.on_destroy?r.$$.on_destroy.push(...l):re(l),r.$$.on_mount=[]}),o.forEach(me)}function dt(r,e){const t=r.$$;t.fragment!==null&&(at(t.after_update),re(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function mt(r,e){r.$$.dirty[0]===-1&&(q.push(r),ke(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<{const F=G.length?G[0]:U;return u.ctx&&o(u.ctx[L],u.ctx[L]=F)&&(!u.skip_bound&&u.bound[L]&&u.bound[L](F),Z&&mt(r,L)),U}):[],u.update(),Z=!0,re(u.before_update),u.fragment=i?i(u.ctx):!1,e.target){if(e.hydrate){const L=tt(e.target);u.fragment&&u.fragment.l(L),L.forEach(N)}else u.fragment&&u.fragment.c();e.intro&&ut(r.$$.fragment),ht(r,e.target,e.anchor),p()}ie(a)}let xe;typeof HTMLElement=="function"&&(xe=class extends HTMLElement{constructor(e,t,i){super();V(this,"$$ctor");V(this,"$$s");V(this,"$$c");V(this,"$$cn",!1);V(this,"$$d",{});V(this,"$$r",!1);V(this,"$$p_d",{});V(this,"$$l",{});V(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=C("slot"),l!=="default"&&c(s,"name",l)},m:function(u,Z){j(u,s,Z)},d:function(u){u&&N(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=nt(this);for(const l of this.$$s)l in i&&(t[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=oe(s,l.value,this.$$p_d,"toProp"))}for(const l in this.$$p_d)!(l in this.$$d)&&this[l]!==void 0&&(this.$$d[l]=this[l],delete this[l]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const l in this.$$p_d)if(this.$$d[l]=this.$$c.$$.ctx[this.$$c.$$.props[l]],this.$$p_d[l].reflect){const s=oe(l,this.$$d[l],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const s of this.$$l[l]){const f=this.$$c.$on(l,s);this.$$l_u.set(s,f)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=oe(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function oe(r,e,t,i){var l;const o=(l=t[r])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function bt(r,e,t,i,o,l){let s=class extends xe{constructor(){super(r,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(f=>(e[f].attribute||f).toLowerCase())}};return Object.keys(e).forEach(f=>{Object.defineProperty(s.prototype,f,{get(){return this.$$c&&f in this.$$c?this.$$c[f]:this.$$d[f]},set(a){var u;a=oe(f,a,e),this.$$d[f]=a,(u=this.$$c)==null||u.$set({[f]:a})}})}),i.forEach(f=>{Object.defineProperty(s.prototype,f,{get(){var a;return(a=this.$$c)==null?void 0:a[f]}})}),l&&(s=l(s)),r.element=s,s}class yt{constructor(){V(this,"$$");V(this,"$$set")}$destroy(){dt(this,1),this.$destroy=I}$on(e,t){if(!ve(t))return I;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!Ke(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const vt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(vt);const Ee="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",wt=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),$e=typeof window<"u"&&window.Blob&&new Blob([wt(Ee)],{type:"text/javascript;charset=utf-8"});function pt(r){let e;try{if(e=$e&&(window.URL||window.webkitURL).createObjectURL($e),!e)throw"";const t=new Worker(e,{name:r==null?void 0:r.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Ee,{name:r==null?void 0:r.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const _t=new TextEncoder;function kt(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function xt(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const o=await Ce(i,r,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Ce(r,e,t){return kt(await crypto.subtle.digest(t.toUpperCase(),_t.encode(r+e)))}function Et(r,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let a=o;a<=i;a+=1){if(l.signal.aborted)return null;if(await Ce(e,a,t)===r)return{number:a,took:Date.now()-s}}return null})(),controller:l}}var g=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(g||{});function $t(r){Je(r,"svelte-15co9zy",".altcha.svelte-15co9zy.svelte-15co9zy{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-15co9zy.svelte-15co9zy{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}")}function Le(r){let e,t,i;return{c(){e=X("svg"),t=X("path"),i=X("path"),c(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(t,"fill","currentColor"),c(t,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-15co9zy"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){j(o,e,l),v(e,t),v(e,i)},d(o){o&&N(e)}}}function Ct(r){let e,t=r[9].label+"",i;return{c(){e=C("label"),c(e,"for",i=r[3]+"_checkbox"),c(e,"class","svelte-15co9zy")},m(o,l){j(o,e,l),e.innerHTML=t},p(o,l){l[0]&512&&t!==(t=o[9].label+"")&&(e.innerHTML=t),l[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&N(e)}}}function Lt(r){let e,t=r[9].verifying+"";return{c(){e=C("span")},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].verifying+"")&&(e.innerHTML=t)},d(i){i&&N(e)}}}function Rt(r){let e,t=r[9].verified+"",i,o;return{c(){e=C("span"),i=W(),o=C("input"),c(o,"type","hidden"),c(o,"name",r[3]),o.value=r[4]},m(l,s){j(l,e,s),e.innerHTML=t,j(l,i,s),j(l,o,s)},p(l,s){s[0]&512&&t!==(t=l[9].verified+"")&&(e.innerHTML=t),s[0]&8&&c(o,"name",l[3]),s[0]&16&&(o.value=l[4])},d(l){l&&(N(e),N(i),N(o))}}}function Re(r){let e,t,i,o,l,s,f;return{c(){e=C("div"),t=C("a"),i=X("svg"),o=X("path"),l=X("path"),s=X("path"),c(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(o,"fill","currentColor"),c(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(l,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(t,"href",Se),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-15co9zy"),c(t,"aria-label",f=r[9].ariaLinkLabel)},m(a,u){j(a,e,u),v(e,t),v(t,i),v(i,o),v(i,l),v(i,s)},p(a,u){u[0]&512&&f!==(f=a[9].ariaLinkLabel)&&c(t,"aria-label",f)},d(a){a&&N(e)}}}function Ie(r){let e,t,i,o;function l(a,u){return a[5]===g.EXPIRED?zt:It}let s=l(r),f=s(r);return{c(){e=C("div"),t=X("svg"),i=X("path"),o=W(),f.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(t,"width","14"),c(t,"height","14"),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"fill","none"),c(t,"viewBox","0 0 24 24"),c(t,"stroke-width","1.5"),c(t,"stroke","currentColor"),c(e,"class","altcha-error svelte-15co9zy")},m(a,u){j(a,e,u),v(e,t),v(t,i),v(e,o),f.m(e,null)},p(a,u){s===(s=l(a))&&f?f.p(a,u):(f.d(1),f=s(a),f&&(f.c(),f.m(e,null)))},d(a){a&&N(e),f.d()}}}function It(r){let e,t=r[9].error+"";return{c(){e=C("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].error+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function zt(r){let e,t=r[9].expired+"";return{c(){e=C("div"),c(e,"title",r[8])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&512&&t!==(t=i[9].expired+"")&&(e.innerHTML=t),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function ze(r){let e,t,i=r[9].footer+"";return{c(){e=C("div"),t=C("div"),c(t,"class","svelte-15co9zy"),c(e,"class","altcha-footer svelte-15co9zy")},m(o,l){j(o,e,l),v(e,t),t.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(t.innerHTML=i)},d(o){o&&N(e)}}}function Nt(r){let e,t,i,o,l,s,f,a,u,Z,L,U,G,F,_=r[5]===g.VERIFYING&&Le();function B(d,z){return d[5]===g.VERIFIED?Rt:d[5]===g.VERIFYING?Lt:Ct}let H=B(r),k=H(r),x=r[2]!==!0&&Re(r),m=(r[8]||r[5]===g.EXPIRED)&&Ie(r),y=r[9].footer&&r[1]!==!0&&ze(r);return{c(){e=C("div"),t=C("div"),_&&_.c(),i=W(),o=C("div"),l=C("input"),a=W(),u=C("div"),k.c(),Z=W(),x&&x.c(),L=W(),m&&m.c(),U=W(),y&&y.c(),c(l,"type","checkbox"),c(l,"id",s=r[3]+"_checkbox"),l.required=f=r[0]!=="onsubmit",c(l,"class","svelte-15co9zy"),c(o,"class","altcha-checkbox svelte-15co9zy"),we(o,"altcha-hidden",r[5]===g.VERIFYING),c(u,"class","altcha-label svelte-15co9zy"),c(t,"class","altcha-main svelte-15co9zy"),c(e,"class","altcha svelte-15co9zy"),c(e,"data-state",r[5])},m(d,z){j(d,e,z),v(e,t),_&&_.m(t,null),v(t,i),v(t,o),v(o,l),l.checked=r[6],v(t,a),v(t,u),k.m(u,null),v(t,Z),x&&x.m(t,null),v(e,L),m&&m.m(e,null),v(e,U),y&&y.m(e,null),r[30](e),G||(F=[fe(l,"change",r[29]),fe(l,"change",r[10]),fe(l,"invalid",r[11])],G=!0)},p(d,z){d[5]===g.VERIFYING?_||(_=Le(),_.c(),_.m(t,i)):_&&(_.d(1),_=null),z[0]&8&&s!==(s=d[3]+"_checkbox")&&c(l,"id",s),z[0]&1&&f!==(f=d[0]!=="onsubmit")&&(l.required=f),z[0]&64&&(l.checked=d[6]),z[0]&32&&we(o,"altcha-hidden",d[5]===g.VERIFYING),H===(H=B(d))&&k?k.p(d,z):(k.d(1),k=H(d),k&&(k.c(),k.m(u,null))),d[2]!==!0?x?x.p(d,z):(x=Re(d),x.c(),x.m(t,null)):x&&(x.d(1),x=null),d[8]||d[5]===g.EXPIRED?m?m.p(d,z):(m=Ie(d),m.c(),m.m(e,U)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?y?y.p(d,z):(y=ze(d),y.c(),y.m(e,null)):y&&(y.d(1),y=null),z[0]&32&&c(e,"data-state",d[5])},i:I,o:I,d(d){d&&N(e),_&&_.d(),k.d(),x&&x.d(),m&&m.d(),y&&y.d(),r[30](null),G=!1,re(F)}}}const Ne="Visit Altcha.org",Se="https://altcha.org/";function je(r){return JSON.parse(r)}function St(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function jt(r,e,t){var Fe,He;let i,o,l,{auto:s=void 0}=e,{blockspam:f=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:u=void 0}=e,{debug:Z=!1}=e,{expire:L=void 0}=e,{hidefooter:U=!1}=e,{hidelogo:G=!1}=e,{name:F="altcha"}=e,{maxnumber:_=1e6}=e,{mockerror:B=!1}=e,{refetchonexpire:H=!0}=e,{spamfilter:k=!1}=e,{strings:x=void 0}=e,{test:m=!1}=e,{verifyurl:y=void 0}=e,{workers:d=Math.min(16,navigator.hardwareConcurrency||8)}=e;const z=lt(),Te=["SHA-256","SHA-384","SHA-512"],Ze=(He=(Fe=document.documentElement.lang)==null?void 0:Fe.split("-"))==null?void 0:He[0];let Y=!1,le,b=null,be=null,K=null,D=g.UNVERIFIED,O=null;ot(()=>{b&&(b.removeEventListener("submit",Ve),b.removeEventListener("reset",Ue),b.removeEventListener("focusin",Me),b=null),O&&(clearTimeout(O),O=null)}),it(()=>{R("mounted","0.4.3"),R("workers",d),m&&R("using test mode"),L&&se(L),s!==void 0&&R("auto",s),b=le.closest("form"),b&&(b.addEventListener("submit",Ve),b.addEventListener("reset",Ue),s==="onfocus"&&b.addEventListener("focusin",Me)),s==="onload"&&J()});function R(...n){(Z||n.some(h=>h instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Me(n){D===g.UNVERIFIED&&J()}function Ve(n){b&&s==="onsubmit"&&D===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),J().then(()=>{b==null||b.requestSubmit()}))}function Ue(){ce()}function Ge(n,h){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:h.number,salt:n.salt,signature:n.signature,test:m?!0:void 0,took:h.took}))}function De(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Te.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Te.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function At(){var n;if(B)throw R("mocking error"),new Error("Mocked error.");if(i)return R("using provided json data"),i;if(m)return R("generating test challenge",{test:m}),xt(typeof m!="boolean"?+m:void 0);{if(!a)throw new Error("Attribute challengeurl not set.");R("fetching challenge from",a);const h=await fetch(a,{headers:{"x-altcha-spam-filter":k?"1":"0"}});if(h.status!==200)throw new Error(`Server responded with ${h.status}.`);const w=h.headers.get("Expires"),S=h.headers.get("X-Altcha-Config"),A=await h.json(),M=new URLSearchParams((n=A.salt.split("?"))==null?void 0:n[1]),Q=M.get("expires")||M.get("expire");if(Q){const E=new Date(+Q*1e3),$=isNaN(E.getTime())?0:E.getTime()-Date.now();$>0&&se($)}if(S)try{const E=JSON.parse(S);E&&typeof E=="object"&&(E.verifyurl&&(E.verifyurl=new URL(E.verifyurl,new URL(a)).toString()),Xe(E))}catch(E){R("unable to configure from X-Altcha-Config",E)}if(!L&&(w!=null&&w.length)){const E=Date.parse(w);if(E){const $=E-Date.now();$>0&&se($)}}return A}}function Oe(){a&&H&&D===g.VERIFIED?J():ce(g.EXPIRED,l.expired)}async function Tt(n){let h=null;if("Worker"in window){try{h=await Zt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(w){R(w)}if((h==null?void 0:h.number)!==void 0)return{data:n,solution:h}}return{data:n,solution:await Et(n.challenge,n.salt,n.algorithm,n.maxnumber||_).promise}}async function Zt(n,h,w,S=typeof m=="number"?m:_,A=Math.ceil(d)){const M=[];if(A<1)throw new Error("Wrong number of workers configured.");if(A>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let $=0;${const Pe=ae*Q;return new Promise(Ft=>{$.addEventListener("message",Ye=>{if(Ye.data)for(const We of M)We!==$&&We.postMessage({type:"abort"});Ft(Ye.data)}),$.postMessage({payload:{alg:w,challenge:n,max:Pe+Q,salt:h,start:Pe},type:"work"})})}));for(const $ of M)$.terminate();return E.find($=>!!$)||null}function Mt(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(D)?k&&(b==null?void 0:b.reportValidity())===!1?t(6,Y=!1):J():t(6,Y=!0)}function Vt(){D===g.VERIFYING&&alert(l.waitAlert)}function se(n){R("expire",n),O&&(clearTimeout(O),O=null),n<1?Oe():O=setTimeout(Oe,n)}function Ut(n){var w;const h=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((w=h==null?void 0:h.value)==null?void 0:w.slice(h.value.indexOf("@")))||void 0}function Gt(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(w=>`input[name="${w}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((w,S)=>{const A=S.name,M=S.value.trim();return A&&M&&(w[A]=M),w},{})}async function Dt(n){if(!y)throw new Error("Attribute verifyurl not set.");R("requesting server verification from",y);const h={payload:n};if(k){const{email:A,expectedLanguages:M,expectedCountries:Q,fields:E,ipAddress:$,timeZone:ae}=typeof k=="object"?k:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};h.ipAddress=$===!1?void 0:$||"auto",h.email=A===!1?void 0:Ut(A),h.fields=E===!1?void 0:Gt(E),h.timeZone=ae===!1?void 0:ae||St(),h.expectedCountries=Q,h.expectedLanguages=M||(Ze?[Ze]:void 0)}const w=await fetch(y,{body:JSON.stringify(h),headers:{"content-type":"application/json"},method:"POST"});if(w.status!==200)throw new Error(`Server responded with ${w.status}.`);const S=await w.json();if(S!=null&&S.payload&&t(4,K=S.payload),z("serververification",S),f&&S.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Xe(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&J()),n.expire!==void 0&&(se(n.expire),t(14,L=n.expire)),n.challenge&&(De(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(12,a=n.challengeurl),n.debug!==void 0&&t(13,Z=!!n.debug),n.hidefooter!==void 0&&t(1,U=!!n.hidefooter),n.hidelogo!==void 0&&t(2,G=!!n.hidelogo),n.maxnumber!==void 0&&t(15,_=+n.maxnumber),n.mockerror!==void 0&&t(16,B=!!n.mockerror),n.name!==void 0&&t(3,F=n.name),n.refetchonexpire!==void 0&&t(17,H=!!n.refetchonexpire),n.spamfilter!==void 0&&t(18,k=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(28,o=n.strings),n.test!==void 0&&t(19,m=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(20,y=n.verifyurl),n.workers!==void 0&&t(21,d=+n.workers)}function ce(n=g.UNVERIFIED,h=null){O&&(clearTimeout(O),O=null),t(6,Y=!1),t(8,be=h),t(4,K=null),t(5,D=n)}async function J(){return ce(g.VERIFYING),At().then(n=>(De(n),R("challenge",n),Tt(n))).then(({data:n,solution:h})=>{if(R("solution",h),(h==null?void 0:h.number)!==void 0){if(y)return Dt(Ge(n,h));t(4,K=Ge(n,h)),R("payload",K)}else throw R("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{st().then(()=>{t(5,D=g.VERIFIED),t(6,Y=!0),R("verified"),z("verified",{payload:K})})}).catch(n=>{R(n),t(5,D=g.ERROR),t(6,Y=!1),t(8,be=n.message)})}function Ot(){Y=this.checked,t(6,Y)}function Xt(n){he[n?"unshift":"push"](()=>{le=n,t(7,le)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(22,f=n.blockspam),"challengeurl"in n&&t(12,a=n.challengeurl),"challengejson"in n&&t(23,u=n.challengejson),"debug"in n&&t(13,Z=n.debug),"expire"in n&&t(14,L=n.expire),"hidefooter"in n&&t(1,U=n.hidefooter),"hidelogo"in n&&t(2,G=n.hidelogo),"name"in n&&t(3,F=n.name),"maxnumber"in n&&t(15,_=n.maxnumber),"mockerror"in n&&t(16,B=n.mockerror),"refetchonexpire"in n&&t(17,H=n.refetchonexpire),"spamfilter"in n&&t(18,k=n.spamfilter),"strings"in n&&t(24,x=n.strings),"test"in n&&t(19,m=n.test),"verifyurl"in n&&t(20,y=n.verifyurl),"workers"in n&&t(21,d=n.workers)},r.$$.update=()=>{r.$$.dirty[0]&8388608&&(i=u?je(u):void 0),r.$$.dirty[0]&16777216&&t(28,o=x?je(x):{}),r.$$.dirty[0]&268435456&&t(9,l={ariaLinkLabel:Ne,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),r.$$.dirty[0]&48&&z("statechange",{payload:K,state:D})},[s,U,G,F,K,D,Y,le,be,l,Mt,Vt,a,Z,L,_,B,H,k,m,y,d,f,u,x,Xe,ce,J,o,Ot,Xt]}class Ae extends yt{constructor(e){super(),gt(this,e,jt,Nt,Be,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,configure:25,reset:26,verify:27},$t,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),p()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),p()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),p()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),p()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),p()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),p()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),p()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),p()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),p()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),p()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),p()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),p()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),p()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),p()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),p()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),p()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),p()}get configure(){return this.$$.ctx[25]}get reset(){return this.$$.ctx[26]}get verify(){return this.$$.ctx[27]}}customElements.define("altcha-widget",bt(Ae,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{}},[],["configure","reset","verify"],!1)),T.Altcha=Ae,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}); +(function(T,z){typeof exports=="object"&&typeof module<"u"?z(exports):typeof define=="function"&&define.amd?define(["exports"],z):(T=typeof globalThis<"u"?globalThis:T||self,z(T.altcha={}))})(this,function(T){"use strict";var Wt=Object.defineProperty;var Pt=(T,z,Q)=>z in T?Wt(T,z,{enumerable:!0,configurable:!0,writable:!0,value:Q}):T[z]=Q;var V=(T,z,Q)=>Pt(T,typeof z!="symbol"?z+"":z,Q);const z="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",Q=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),we=typeof window<"u"&&window.Blob&&new Blob([Q(z)],{type:"text/javascript;charset=utf-8"});function Je(t){let e;try{if(e=we&&(window.URL||window.webkitURL).createObjectURL(we),!e)throw"";const r=new Worker(e,{name:t==null?void 0:t.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),r}catch{return new Worker("data:text/javascript;base64,"+z,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}function re(){}function _e(t){return t()}function pe(){return Object.create(null)}function ne(t){t.forEach(_e)}function ke(t){return typeof t=="function"}function Qe(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function qe(t){return Object.keys(t).length===0}function v(t,e){t.appendChild(e)}function et(t,e,r){const i=tt(t);if(!i.getElementById(e)){const o=C("style");o.id=e,o.textContent=r,rt(i,o)}}function tt(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function rt(t,e){return v(t.head||t,e),e.sheet}function j(t,e,r){t.insertBefore(e,r||null)}function N(t){t.parentNode&&t.parentNode.removeChild(t)}function C(t){return document.createElement(t)}function X(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function nt(t){return document.createTextNode(t)}function P(){return nt(" ")}function ue(t,e,r,i){return t.addEventListener(e,r,i),()=>t.removeEventListener(e,r,i)}function c(t,e,r){r==null?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}function it(t){return Array.from(t.childNodes)}function xe(t,e,r){t.classList.toggle(e,!!r)}function ot(t,e,{bubbles:r=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:r,cancelable:i})}function lt(t){const e={};return t.childNodes.forEach(r=>{e[r.slot||"default"]=!0}),e}let ie;function oe(t){ie=t}function he(){if(!ie)throw new Error("Function called outside component initialization");return ie}function st(t){he().$$.on_mount.push(t)}function ct(t){he().$$.on_destroy.push(t)}function at(){const t=he();return(e,r,{cancelable:i=!1}={})=>{const o=t.$$.callbacks[e];if(o){const l=ot(e,r,{cancelable:i});return o.slice().forEach(s=>{s.call(t,l)}),!l.defaultPrevented}return!0}}const q=[],de=[];let ee=[];const Ee=[],$e=Promise.resolve();let me=!1;function Ce(){me||(me=!0,$e.then(w))}function ft(){return Ce(),$e}function ge(t){ee.push(t)}const be=new Set;let te=0;function w(){if(te!==0)return;const t=ie;do{try{for(;tet.indexOf(i)===-1?e.push(i):r.push(i)),r.forEach(i=>i()),ee=e}const dt=new Set;function mt(t,e){t&&t.i&&(dt.delete(t),t.i(e))}function gt(t,e,r){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,r),ge(()=>{const l=t.$$.on_mount.map(_e).filter(ke);t.$$.on_destroy?t.$$.on_destroy.push(...l):ne(l),t.$$.on_mount=[]}),o.forEach(ge)}function bt(t,e){const r=t.$$;r.fragment!==null&&(ht(r.after_update),ne(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function yt(t,e){t.$$.dirty[0]===-1&&(q.push(t),Ce(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const F=G.length?G[0]:U;return u.ctx&&o(u.ctx[L],u.ctx[L]=F)&&(!u.skip_bound&&u.bound[L]&&u.bound[L](F),Z&&yt(t,L)),U}):[],u.update(),Z=!0,ne(u.before_update),u.fragment=i?i(u.ctx):!1,e.target){if(e.hydrate){const L=it(e.target);u.fragment&&u.fragment.l(L),L.forEach(N)}else u.fragment&&u.fragment.c();e.intro&&mt(t.$$.fragment),gt(t,e.target,e.anchor),w()}oe(a)}let Le;typeof HTMLElement=="function"&&(Le=class extends HTMLElement{constructor(e,r,i){super();V(this,"$$ctor");V(this,"$$s");V(this,"$$c");V(this,"$$cn",!1);V(this,"$$d",{});V(this,"$$r",!1);V(this,"$$p_d",{});V(this,"$$l",{});V(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=r,i&&this.attachShadow({mode:"open"})}addEventListener(e,r,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(r),this.$$c){const o=this.$$c.$on(e,r);this.$$l_u.set(r,o)}super.addEventListener(e,r,i)}removeEventListener(e,r,i){if(super.removeEventListener(e,r,i),this.$$c){const o=this.$$l_u.get(r);o&&(o(),this.$$l_u.delete(r))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=C("slot"),l!=="default"&&c(s,"name",l)},m:function(u,Z){j(u,s,Z)},d:function(u){u&&N(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const r={},i=lt(this);for(const l of this.$$s)l in i&&(r[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=le(s,l.value,this.$$p_d,"toProp"))}for(const l in this.$$p_d)!(l in this.$$d)&&this[l]!==void 0&&(this.$$d[l]=this[l],delete this[l]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:r,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const l in this.$$p_d)if(this.$$d[l]=this.$$c.$$.ctx[this.$$c.$$.props[l]],this.$$p_d[l].reflect){const s=le(l,this.$$d[l],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const s of this.$$l[l]){const f=this.$$c.$on(l,s);this.$$l_u.set(s,f)}this.$$l={}}}attributeChangedCallback(e,r,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=le(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(r=>this.$$p_d[r].attribute===e||!this.$$p_d[r].attribute&&r.toLowerCase()===e)||e}});function le(t,e,r,i){var l;const o=(l=r[t])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!r[t])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function wt(t,e,r,i,o,l){let s=class extends Le{constructor(){super(t,r,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(f=>(e[f].attribute||f).toLowerCase())}};return Object.keys(e).forEach(f=>{Object.defineProperty(s.prototype,f,{get(){return this.$$c&&f in this.$$c?this.$$c[f]:this.$$d[f]},set(a){var u;a=le(f,a,e),this.$$d[f]=a,(u=this.$$c)==null||u.$set({[f]:a})}})}),i.forEach(f=>{Object.defineProperty(s.prototype,f,{get(){var a;return(a=this.$$c)==null?void 0:a[f]}})}),l&&(s=l(s)),t.element=s,s}class _t{constructor(){V(this,"$$");V(this,"$$set")}$destroy(){bt(this,1),this.$destroy=re}$on(e,r){if(!ke(r))return re;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(r),()=>{const o=i.indexOf(r);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!qe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const pt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(pt);const kt=new TextEncoder;function xt(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Et(t,e="SHA-256",r=1e5){const i=Date.now().toString(16);t||(t=Math.round(Math.random()*r));const o=await Re(i,t,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Re(t,e,r){return xt(await crypto.subtle.digest(r.toUpperCase(),kt.encode(t+e)))}function $t(t,e,r="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let a=o;a<=i;a+=1){if(l.signal.aborted)return null;if(await Re(e,a,r)===t)return{number:a,took:Date.now()-s}}return null})(),controller:l}}var g=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t.EXPIRED="expired",t))(g||{});function Ct(t){et(t,"svelte-15co9zy",".altcha.svelte-15co9zy.svelte-15co9zy{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-15co9zy.svelte-15co9zy{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}")}function Ie(t){let e,r,i;return{c(){e=X("svg"),r=X("path"),i=X("path"),c(r,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(r,"fill","currentColor"),c(r,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-15co9zy"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){j(o,e,l),v(e,r),v(e,i)},d(o){o&&N(e)}}}function Lt(t){let e,r=t[9].label+"",i;return{c(){e=C("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-15co9zy")},m(o,l){j(o,e,l),e.innerHTML=r},p(o,l){l[0]&512&&r!==(r=o[9].label+"")&&(e.innerHTML=r),l[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&N(e)}}}function Rt(t){let e,r=t[9].verifying+"";return{c(){e=C("span")},m(i,o){j(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].verifying+"")&&(e.innerHTML=r)},d(i){i&&N(e)}}}function It(t){let e,r=t[9].verified+"",i,o;return{c(){e=C("span"),i=P(),o=C("input"),c(o,"type","hidden"),c(o,"name",t[3]),o.value=t[4]},m(l,s){j(l,e,s),e.innerHTML=r,j(l,i,s),j(l,o,s)},p(l,s){s[0]&512&&r!==(r=l[9].verified+"")&&(e.innerHTML=r),s[0]&8&&c(o,"name",l[3]),s[0]&16&&(o.value=l[4])},d(l){l&&(N(e),N(i),N(o))}}}function ze(t){let e,r,i,o,l,s,f;return{c(){e=C("div"),r=C("a"),i=X("svg"),o=X("path"),l=X("path"),s=X("path"),c(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(o,"fill","currentColor"),c(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(l,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(r,"href",Ae),c(r,"target","_blank"),c(r,"class","altcha-logo svelte-15co9zy"),c(r,"aria-label",f=t[9].ariaLinkLabel)},m(a,u){j(a,e,u),v(e,r),v(r,i),v(i,o),v(i,l),v(i,s)},p(a,u){u[0]&512&&f!==(f=a[9].ariaLinkLabel)&&c(r,"aria-label",f)},d(a){a&&N(e)}}}function Ne(t){let e,r,i,o;function l(a,u){return a[5]===g.EXPIRED?Nt:zt}let s=l(t),f=s(t);return{c(){e=C("div"),r=X("svg"),i=X("path"),o=P(),f.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(r,"width","14"),c(r,"height","14"),c(r,"xmlns","http://www.w3.org/2000/svg"),c(r,"fill","none"),c(r,"viewBox","0 0 24 24"),c(r,"stroke-width","1.5"),c(r,"stroke","currentColor"),c(e,"class","altcha-error svelte-15co9zy")},m(a,u){j(a,e,u),v(e,r),v(r,i),v(e,o),f.m(e,null)},p(a,u){s===(s=l(a))&&f?f.p(a,u):(f.d(1),f=s(a),f&&(f.c(),f.m(e,null)))},d(a){a&&N(e),f.d()}}}function zt(t){let e,r=t[9].error+"";return{c(){e=C("div"),c(e,"title",t[8])},m(i,o){j(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].error+"")&&(e.innerHTML=r),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function Nt(t){let e,r=t[9].expired+"";return{c(){e=C("div"),c(e,"title",t[8])},m(i,o){j(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].expired+"")&&(e.innerHTML=r),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function Se(t){let e,r,i=t[9].footer+"";return{c(){e=C("div"),r=C("div"),c(r,"class","svelte-15co9zy"),c(e,"class","altcha-footer svelte-15co9zy")},m(o,l){j(o,e,l),v(e,r),r.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(r.innerHTML=i)},d(o){o&&N(e)}}}function St(t){let e,r,i,o,l,s,f,a,u,Z,L,U,G,F,p=t[5]===g.VERIFYING&&Ie();function Y(d,I){return d[5]===g.VERIFIED?It:d[5]===g.VERIFYING?Rt:Lt}let H=Y(t),k=H(t),x=t[2]!==!0&&ze(t),m=(t[8]||t[5]===g.EXPIRED)&&Ne(t),y=t[9].footer&&t[1]!==!0&&Se(t);return{c(){e=C("div"),r=C("div"),p&&p.c(),i=P(),o=C("div"),l=C("input"),a=P(),u=C("div"),k.c(),Z=P(),x&&x.c(),L=P(),m&&m.c(),U=P(),y&&y.c(),c(l,"type","checkbox"),c(l,"id",s=t[3]+"_checkbox"),l.required=f=t[0]!=="onsubmit",c(l,"class","svelte-15co9zy"),c(o,"class","altcha-checkbox svelte-15co9zy"),xe(o,"altcha-hidden",t[5]===g.VERIFYING),c(u,"class","altcha-label svelte-15co9zy"),c(r,"class","altcha-main svelte-15co9zy"),c(e,"class","altcha svelte-15co9zy"),c(e,"data-state",t[5])},m(d,I){j(d,e,I),v(e,r),p&&p.m(r,null),v(r,i),v(r,o),v(o,l),l.checked=t[6],v(r,a),v(r,u),k.m(u,null),v(r,Z),x&&x.m(r,null),v(e,L),m&&m.m(e,null),v(e,U),y&&y.m(e,null),t[31](e),G||(F=[ue(l,"change",t[30]),ue(l,"change",t[10]),ue(l,"invalid",t[11])],G=!0)},p(d,I){d[5]===g.VERIFYING?p||(p=Ie(),p.c(),p.m(r,i)):p&&(p.d(1),p=null),I[0]&8&&s!==(s=d[3]+"_checkbox")&&c(l,"id",s),I[0]&1&&f!==(f=d[0]!=="onsubmit")&&(l.required=f),I[0]&64&&(l.checked=d[6]),I[0]&32&&xe(o,"altcha-hidden",d[5]===g.VERIFYING),H===(H=Y(d))&&k?k.p(d,I):(k.d(1),k=H(d),k&&(k.c(),k.m(u,null))),d[2]!==!0?x?x.p(d,I):(x=ze(d),x.c(),x.m(r,null)):x&&(x.d(1),x=null),d[8]||d[5]===g.EXPIRED?m?m.p(d,I):(m=Ne(d),m.c(),m.m(e,U)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?y?y.p(d,I):(y=Se(d),y.c(),y.m(e,null)):y&&(y.d(1),y=null),I[0]&32&&c(e,"data-state",d[5])},i:re,o:re,d(d){d&&N(e),p&&p.d(),k.d(),x&&x.d(),m&&m.d(),y&&y.d(),t[31](null),G=!1,ne(F)}}}const je="Visit Altcha.org",Ae="https://altcha.org/";function Te(t){return JSON.parse(t)}function jt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function At(t,e,r){var We,Pe;let i,o,l,{auto:s=void 0}=e,{blockspam:f=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:u=void 0}=e,{debug:Z=!1}=e,{expire:L=void 0}=e,{hidefooter:U=!1}=e,{hidelogo:G=!1}=e,{name:F="altcha"}=e,{maxnumber:p=1e6}=e,{mockerror:Y=!1}=e,{refetchonexpire:H=!0}=e,{spamfilter:k=!1}=e,{strings:x=void 0}=e,{test:m=!1}=e,{verifyurl:y=void 0}=e,{workers:d=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:I=void 0}=e;const ye=at(),Me=["SHA-256","SHA-384","SHA-512"],Ve=(Pe=(We=document.documentElement.lang)==null?void 0:We.split("-"))==null?void 0:Pe[0];let W=!1,se,b=null,ve=null,B=null,D=g.UNVERIFIED,O=null;ct(()=>{b&&(b.removeEventListener("submit",Ge),b.removeEventListener("reset",De),b.removeEventListener("focusin",Ue),b=null),O&&(clearTimeout(O),O=null)}),st(()=>{R("mounted","0.4.3"),R("workers",d),m&&R("using test mode"),L&&ce(L),s!==void 0&&R("auto",s),b=se.closest("form"),b&&(b.addEventListener("submit",Ge),b.addEventListener("reset",De),s==="onfocus"&&b.addEventListener("focusin",Ue)),s==="onload"&&K()});function R(...n){(Z||n.some(h=>h instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Ue(n){D===g.UNVERIFIED&&K()}function Ge(n){b&&s==="onsubmit"&&D===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),K().then(()=>{b==null||b.requestSubmit()}))}function De(){ae()}function Oe(n,h){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:h.number,salt:n.salt,signature:n.signature,test:m?!0:void 0,took:h.took}))}function Xe(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Me.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Me.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function Tt(){var n;if(Y)throw R("mocking error"),new Error("Mocked error.");if(i)return R("using provided json data"),i;if(m)return R("generating test challenge",{test:m}),Et(typeof m!="boolean"?+m:void 0);{if(!a)throw new Error("Attribute challengeurl not set.");R("fetching challenge from",a);const h=await fetch(a,{headers:{"x-altcha-spam-filter":k?"1":"0"}});if(h.status!==200)throw new Error(`Server responded with ${h.status}.`);const _=h.headers.get("Expires"),S=h.headers.get("X-Altcha-Config"),A=await h.json(),M=new URLSearchParams((n=A.salt.split("?"))==null?void 0:n[1]),J=M.get("expires")||M.get("expire");if(J){const E=new Date(+J*1e3),$=isNaN(E.getTime())?0:E.getTime()-Date.now();$>0&&ce($)}if(S)try{const E=JSON.parse(S);E&&typeof E=="object"&&(E.verifyurl&&(E.verifyurl=new URL(E.verifyurl,new URL(a)).toString()),He(E))}catch(E){R("unable to configure from X-Altcha-Config",E)}if(!L&&(_!=null&&_.length)){const E=Date.parse(_);if(E){const $=E-Date.now();$>0&&ce($)}}return A}}function Fe(){a&&H&&D===g.VERIFIED?K():ae(g.EXPIRED,l.expired)}async function Zt(n){let h=null;if("Worker"in window){try{h=await Mt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(_){R(_)}if((h==null?void 0:h.number)!==void 0)return{data:n,solution:h}}return{data:n,solution:await $t(n.challenge,n.salt,n.algorithm,n.maxnumber||p).promise}}async function Mt(n,h,_,S=typeof m=="number"?m:p,A=Math.ceil(d)){const M=[];if(A<1)throw new Error("Wrong number of workers configured.");if(A>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let $=0;${const Ye=fe*J;return new Promise(Ht=>{$.addEventListener("message",Be=>{if(Be.data)for(const Ke of M)Ke!==$&&Ke.postMessage({type:"abort"});Ht(Be.data)}),$.postMessage({payload:{alg:_,challenge:n,max:Ye+J,salt:h,start:Ye},type:"work"})})}));for(const $ of M)$.terminate();return E.find($=>!!$)||null}function Vt(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(D)?k&&(b==null?void 0:b.reportValidity())===!1?r(6,W=!1):K():r(6,W=!0)}function Ut(){D===g.VERIFYING&&alert(l.waitAlert)}function ce(n){R("expire",n),O&&(clearTimeout(O),O=null),n<1?Fe():O=setTimeout(Fe,n)}function Gt(n){var _;const h=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((_=h==null?void 0:h.value)==null?void 0:_.slice(h.value.indexOf("@")))||void 0}function Dt(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(_=>`input[name="${_}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((_,S)=>{const A=S.name,M=S.value.trim();return A&&M&&(_[A]=M),_},{})}async function Ot(n){if(!y)throw new Error("Attribute verifyurl not set.");R("requesting server verification from",y);const h={payload:n};if(k){const{email:A,expectedLanguages:M,expectedCountries:J,fields:E,ipAddress:$,timeZone:fe}=typeof k=="object"?k:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};h.ipAddress=$===!1?void 0:$||"auto",h.email=A===!1?void 0:Gt(A),h.fields=E===!1?void 0:Dt(E),h.timeZone=fe===!1?void 0:fe||jt(),h.expectedCountries=J,h.expectedLanguages=M||(Ve?[Ve]:void 0)}const _=await fetch(y,{body:JSON.stringify(h),headers:{"content-type":"application/json"},method:"POST"});if(_.status!==200)throw new Error(`Server responded with ${_.status}.`);const S=await _.json();if(S!=null&&S.payload&&r(4,B=S.payload),ye("serververification",S),f&&S.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function He(n){n.auto!==void 0&&(r(0,s=n.auto),s==="onload"&&K()),n.expire!==void 0&&(ce(n.expire),r(14,L=n.expire)),n.challenge&&(Xe(n.challenge),i=n.challenge),n.challengeurl!==void 0&&r(12,a=n.challengeurl),n.debug!==void 0&&r(13,Z=!!n.debug),n.hidefooter!==void 0&&r(1,U=!!n.hidefooter),n.hidelogo!==void 0&&r(2,G=!!n.hidelogo),n.maxnumber!==void 0&&r(15,p=+n.maxnumber),n.mockerror!==void 0&&r(16,Y=!!n.mockerror),n.name!==void 0&&r(3,F=n.name),n.refetchonexpire!==void 0&&r(17,H=!!n.refetchonexpire),n.spamfilter!==void 0&&r(18,k=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&r(29,o=n.strings),n.test!==void 0&&r(19,m=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&r(20,y=n.verifyurl),n.workers!==void 0&&r(21,d=+n.workers)}function ae(n=g.UNVERIFIED,h=null){O&&(clearTimeout(O),O=null),r(6,W=!1),r(8,ve=h),r(4,B=null),r(5,D=n)}async function K(){return ae(g.VERIFYING),Tt().then(n=>(Xe(n),R("challenge",n),Zt(n))).then(({data:n,solution:h})=>{if(R("solution",h),(h==null?void 0:h.number)!==void 0){if(y)return Ot(Oe(n,h));r(4,B=Oe(n,h)),R("payload",B)}else throw R("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{ft().then(()=>{r(5,D=g.VERIFIED),r(6,W=!0),R("verified"),ye("verified",{payload:B})})}).catch(n=>{R(n),r(5,D=g.ERROR),r(6,W=!1),r(8,ve=n.message)})}function Xt(){W=this.checked,r(6,W)}function Ft(n){de[n?"unshift":"push"](()=>{se=n,r(7,se)})}return t.$$set=n=>{"auto"in n&&r(0,s=n.auto),"blockspam"in n&&r(22,f=n.blockspam),"challengeurl"in n&&r(12,a=n.challengeurl),"challengejson"in n&&r(23,u=n.challengejson),"debug"in n&&r(13,Z=n.debug),"expire"in n&&r(14,L=n.expire),"hidefooter"in n&&r(1,U=n.hidefooter),"hidelogo"in n&&r(2,G=n.hidelogo),"name"in n&&r(3,F=n.name),"maxnumber"in n&&r(15,p=n.maxnumber),"mockerror"in n&&r(16,Y=n.mockerror),"refetchonexpire"in n&&r(17,H=n.refetchonexpire),"spamfilter"in n&&r(18,k=n.spamfilter),"strings"in n&&r(24,x=n.strings),"test"in n&&r(19,m=n.test),"verifyurl"in n&&r(20,y=n.verifyurl),"workers"in n&&r(21,d=n.workers),"workerurl"in n&&r(25,I=n.workerurl)},t.$$.update=()=>{t.$$.dirty[0]&8388608&&(i=u?Te(u):void 0),t.$$.dirty[0]&16777216&&r(29,o=x?Te(x):{}),t.$$.dirty[0]&536870912&&r(9,l={ariaLinkLabel:je,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),t.$$.dirty[0]&48&&ye("statechange",{payload:B,state:D})},[s,U,G,F,B,D,W,se,ve,l,Vt,Ut,a,Z,L,p,Y,H,k,m,y,d,f,u,x,I,He,ae,K,o,Xt,Ft]}class Ze extends _t{constructor(e){super(),vt(this,e,At,St,Qe,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,workerurl:25,configure:26,reset:27,verify:28},Ct,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),w()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),w()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),w()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),w()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),w()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),w()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[25]}set workerurl(e){this.$$set({workerurl:e}),w()}get configure(){return this.$$.ctx[26]}get reset(){return this.$$.ctx[27]}get verify(){return this.$$.ctx[28]}}customElements.define("altcha-widget",wt(Ze,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=t=>t?new Worker(new URL(t)):new Je,T.Altcha=Ze,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}); diff --git a/dist/altcha.css b/dist_external/altcha.css similarity index 100% rename from dist/altcha.css rename to dist_external/altcha.css diff --git a/dist_external/altcha.d.ts b/dist_external/altcha.d.ts new file mode 100644 index 0000000..2507b79 --- /dev/null +++ b/dist_external/altcha.d.ts @@ -0,0 +1 @@ +declare module 'altcha'; diff --git a/dist_external/altcha.iife.js b/dist_external/altcha.iife.js new file mode 100644 index 0000000..14119de --- /dev/null +++ b/dist_external/altcha.iife.js @@ -0,0 +1 @@ +var altcha=function(B){"use strict";var Pt=Object.defineProperty;var Ht=(B,V,O)=>V in B?Pt(B,V,{enumerable:!0,configurable:!0,writable:!0,value:O}):B[V]=O;var D=(B,V,O)=>Ht(B,typeof V!="symbol"?V+"":V,O);var V=typeof document<"u"?document.currentScript:null;function O(){}function we(r){return r()}function ye(){return Object.create(null)}function re(r){r.forEach(we)}function ve(r){return typeof r=="function"}function Je(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function We(r){return Object.keys(r).length===0}function w(r,e){r.appendChild(e)}function T(r,e,t){r.insertBefore(e,t||null)}function R(r){r.parentNode&&r.parentNode.removeChild(r)}function I(r){return document.createElement(r)}function Z(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function ze(r){return document.createTextNode(r)}function Y(){return ze(" ")}function ue(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function c(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function Ke(r){return Array.from(r.childNodes)}function ke(r,e,t){r.classList.toggle(e,!!t)}function Qe(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function et(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ne;function ie(r){ne=r}function ae(){if(!ne)throw new Error("Function called outside component initialization");return ne}function tt(r){ae().$$.on_mount.push(r)}function rt(r){ae().$$.on_destroy.push(r)}function nt(){const r=ae();return(e,t,{cancelable:i=!1}={})=>{const l=r.$$.callbacks[e];if(l){const o=Qe(e,t,{cancelable:i});return l.slice().forEach(s=>{s.call(r,o)}),!o.defaultPrevented}return!0}}const Q=[],he=[];let ee=[];const pe=[],Ee=Promise.resolve();let de=!1;function $e(){de||(de=!0,Ee.then(y))}function it(){return $e(),Ee}function ge(r){ee.push(r)}const me=new Set;let te=0;function y(){if(te!==0)return;const r=ne;do{try{for(;ter.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),ee=e}const st=new Set;function ct(r,e){r&&r.i&&(st.delete(r),r.i(e))}function ft(r,e,t){const{fragment:i,after_update:l}=r.$$;i&&i.m(e,t),ge(()=>{const o=r.$$.on_mount.map(we).filter(ve);r.$$.on_destroy?r.$$.on_destroy.push(...o):re(o),r.$$.on_mount=[]}),l.forEach(ge)}function ut(r,e){const t=r.$$;t.fragment!==null&&(ot(t.after_update),re(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function at(r,e){r.$$.dirty[0]===-1&&(Q.push(r),$e(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<{const q=H.length?H[0]:P;return a.ctx&&l(a.ctx[C],a.ctx[C]=q)&&(!a.skip_bound&&a.bound[C]&&a.bound[C](q),j&&at(r,C)),P}):[],a.update(),j=!0,re(a.before_update),a.fragment=i?i(a.ctx):!1,e.target){if(e.hydrate){const C=Ke(e.target);a.fragment&&a.fragment.l(C),C.forEach(R)}else a.fragment&&a.fragment.c();e.intro&&ct(r.$$.fragment),ft(r,e.target,e.anchor),y()}ie(f)}let xe;typeof HTMLElement=="function"&&(xe=class extends HTMLElement{constructor(e,t,i){super();D(this,"$$ctor");D(this,"$$s");D(this,"$$c");D(this,"$$cn",!1);D(this,"$$d",{});D(this,"$$r",!1);D(this,"$$p_d",{});D(this,"$$l",{});D(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const l=this.$$c.$on(e,t);this.$$l_u.set(t,l)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const l=this.$$l_u.get(t);l&&(l(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(o){return()=>{let s;return{c:function(){s=I("slot"),o!=="default"&&c(s,"name",o)},m:function(a,j){T(a,s,j)},d:function(a){a&&R(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=et(this);for(const o of this.$$s)o in i&&(t[o]=[e(o)]);for(const o of this.attributes){const s=this.$$g_p(o.name);s in this.$$d||(this.$$d[s]=le(s,o.value,this.$$p_d,"toProp"))}for(const o in this.$$p_d)!(o in this.$$d)&&this[o]!==void 0&&(this.$$d[o]=this[o],delete this[o]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const l=()=>{this.$$r=!0;for(const o in this.$$p_d)if(this.$$d[o]=this.$$c.$$.ctx[this.$$c.$$.props[o]],this.$$p_d[o].reflect){const s=le(o,this.$$d[o],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[o].attribute||o):this.setAttribute(this.$$p_d[o].attribute||o,s)}this.$$r=!1};this.$$c.$$.after_update.push(l),l();for(const o in this.$$l)for(const s of this.$$l[o]){const u=this.$$c.$on(o,s);this.$$l_u.set(s,u)}this.$$l={}}}attributeChangedCallback(e,t,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=le(e,i,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function le(r,e,t,i){var o;const l=(o=t[r])==null?void 0:o.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])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 dt(r,e,t,i,l,o){let s=class extends xe{constructor(){super(r,t,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(u=>(e[u].attribute||u).toLowerCase())}};return Object.keys(e).forEach(u=>{Object.defineProperty(s.prototype,u,{get(){return this.$$c&&u in this.$$c?this.$$c[u]:this.$$d[u]},set(f){var a;f=le(u,f,e),this.$$d[u]=f,(a=this.$$c)==null||a.$set({[u]:f})}})}),i.forEach(u=>{Object.defineProperty(s.prototype,u,{get(){var f;return(f=this.$$c)==null?void 0:f[u]}})}),o&&(s=o(s)),r.element=s,s}class gt{constructor(){D(this,"$$");D(this,"$$set")}$destroy(){ut(this,1),this.$destroy=O}$on(e,t){if(!ve(t))return O;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const l=i.indexOf(t);l!==-1&&i.splice(l,1)}}$set(e){this.$$set&&!We(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const mt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(mt);const bt=new TextEncoder;function _t(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function wt(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const l=await Ce(i,r,e);return{algorithm:e,challenge:l,salt:i,signature:""}}async function Ce(r,e,t){return _t(await crypto.subtle.digest(t.toUpperCase(),bt.encode(r+e)))}function yt(r,e,t="SHA-256",i=1e6,l=0){const o=new AbortController,s=Date.now();return{promise:(async()=>{for(let f=l;f<=i;f+=1){if(o.signal.aborted)return null;if(await Ce(e,f,t)===r)return{number:f,took:Date.now()-s}}return null})(),controller:o}}var m=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(m||{});function Le(r){let e,t,i;return{c(){e=Z("svg"),t=Z("path"),i=Z("path"),c(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(t,"fill","currentColor"),c(t,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(l,o){T(l,e,o),w(e,t),w(e,i)},d(l){l&&R(e)}}}function vt(r){let e,t=r[9].label+"",i;return{c(){e=I("label"),c(e,"for",i=r[3]+"_checkbox")},m(l,o){T(l,e,o),e.innerHTML=t},p(l,o){o[0]&512&&t!==(t=l[9].label+"")&&(e.innerHTML=t),o[0]&8&&i!==(i=l[3]+"_checkbox")&&c(e,"for",i)},d(l){l&&R(e)}}}function kt(r){let e,t=r[9].verifying+"";return{c(){e=I("span")},m(i,l){T(i,e,l),e.innerHTML=t},p(i,l){l[0]&512&&t!==(t=i[9].verifying+"")&&(e.innerHTML=t)},d(i){i&&R(e)}}}function pt(r){let e,t=r[9].verified+"",i,l;return{c(){e=I("span"),i=Y(),l=I("input"),c(l,"type","hidden"),c(l,"name",r[3]),l.value=r[4]},m(o,s){T(o,e,s),e.innerHTML=t,T(o,i,s),T(o,l,s)},p(o,s){s[0]&512&&t!==(t=o[9].verified+"")&&(e.innerHTML=t),s[0]&8&&c(l,"name",o[3]),s[0]&16&&(l.value=o[4])},d(o){o&&(R(e),R(i),R(l))}}}function Ie(r){let e,t,i,l,o,s,u;return{c(){e=I("div"),t=I("a"),i=Z("svg"),l=Z("path"),o=Z("path"),s=Z("path"),c(l,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(l,"fill","currentColor"),c(o,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(o,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(t,"href",Te),c(t,"target","_blank"),c(t,"class","altcha-logo"),c(t,"aria-label",u=r[9].ariaLinkLabel)},m(f,a){T(f,e,a),w(e,t),w(t,i),w(i,l),w(i,o),w(i,s)},p(f,a){a[0]&512&&u!==(u=f[9].ariaLinkLabel)&&c(t,"aria-label",u)},d(f){f&&R(e)}}}function Ae(r){let e,t,i,l;function o(f,a){return f[5]===m.EXPIRED?$t:Et}let s=o(r),u=s(r);return{c(){e=I("div"),t=Z("svg"),i=Z("path"),l=Y(),u.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(t,"width","14"),c(t,"height","14"),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"fill","none"),c(t,"viewBox","0 0 24 24"),c(t,"stroke-width","1.5"),c(t,"stroke","currentColor"),c(e,"class","altcha-error")},m(f,a){T(f,e,a),w(e,t),w(t,i),w(e,l),u.m(e,null)},p(f,a){s===(s=o(f))&&u?u.p(f,a):(u.d(1),u=s(f),u&&(u.c(),u.m(e,null)))},d(f){f&&R(e),u.d()}}}function Et(r){let e,t=r[9].error+"";return{c(){e=I("div"),c(e,"title",r[8])},m(i,l){T(i,e,l),e.innerHTML=t},p(i,l){l[0]&512&&t!==(t=i[9].error+"")&&(e.innerHTML=t),l[0]&256&&c(e,"title",i[8])},d(i){i&&R(e)}}}function $t(r){let e,t=r[9].expired+"";return{c(){e=I("div"),c(e,"title",r[8])},m(i,l){T(i,e,l),e.innerHTML=t},p(i,l){l[0]&512&&t!==(t=i[9].expired+"")&&(e.innerHTML=t),l[0]&256&&c(e,"title",i[8])},d(i){i&&R(e)}}}function Re(r){let e,t,i=r[9].footer+"";return{c(){e=I("div"),t=I("div"),c(e,"class","altcha-footer")},m(l,o){T(l,e,o),w(e,t),t.innerHTML=i},p(l,o){o[0]&512&&i!==(i=l[9].footer+"")&&(t.innerHTML=i)},d(l){l&&R(e)}}}function xt(r){let e,t,i,l,o,s,u,f,a,j,C,P,H,q,k=r[5]===m.VERIFYING&&Le();function J(d,A){return d[5]===m.VERIFIED?pt:d[5]===m.VERIFYING?kt:vt}let G=J(r),p=G(r),E=r[2]!==!0&&Ie(r),g=(r[8]||r[5]===m.EXPIRED)&&Ae(r),_=r[9].footer&&r[1]!==!0&&Re(r);return{c(){e=I("div"),t=I("div"),k&&k.c(),i=Y(),l=I("div"),o=I("input"),f=Y(),a=I("div"),p.c(),j=Y(),E&&E.c(),C=Y(),g&&g.c(),P=Y(),_&&_.c(),c(o,"type","checkbox"),c(o,"id",s=r[3]+"_checkbox"),o.required=u=r[0]!=="onsubmit",c(l,"class","altcha-checkbox"),ke(l,"altcha-hidden",r[5]===m.VERIFYING),c(a,"class","altcha-label"),c(t,"class","altcha-main"),c(e,"class","altcha"),c(e,"data-state",r[5])},m(d,A){T(d,e,A),w(e,t),k&&k.m(t,null),w(t,i),w(t,l),w(l,o),o.checked=r[6],w(t,f),w(t,a),p.m(a,null),w(t,j),E&&E.m(t,null),w(e,C),g&&g.m(e,null),w(e,P),_&&_.m(e,null),r[31](e),H||(q=[ue(o,"change",r[30]),ue(o,"change",r[10]),ue(o,"invalid",r[11])],H=!0)},p(d,A){d[5]===m.VERIFYING?k||(k=Le(),k.c(),k.m(t,i)):k&&(k.d(1),k=null),A[0]&8&&s!==(s=d[3]+"_checkbox")&&c(o,"id",s),A[0]&1&&u!==(u=d[0]!=="onsubmit")&&(o.required=u),A[0]&64&&(o.checked=d[6]),A[0]&32&&ke(l,"altcha-hidden",d[5]===m.VERIFYING),G===(G=J(d))&&p?p.p(d,A):(p.d(1),p=G(d),p&&(p.c(),p.m(a,null))),d[2]!==!0?E?E.p(d,A):(E=Ie(d),E.c(),E.m(t,null)):E&&(E.d(1),E=null),d[8]||d[5]===m.EXPIRED?g?g.p(d,A):(g=Ae(d),g.c(),g.m(e,P)):g&&(g.d(1),g=null),d[9].footer&&d[1]!==!0?_?_.p(d,A):(_=Re(d),_.c(),_.m(e,null)):_&&(_.d(1),_=null),A[0]&32&&c(e,"data-state",d[5])},i:O,o:O,d(d){d&&R(e),k&&k.d(),p.d(),E&&E.d(),g&&g.d(),_&&_.d(),r[31](null),H=!1,re(q)}}}const Me="Visit Altcha.org",Te="https://altcha.org/";function Se(r){return JSON.parse(r)}function Ct(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Lt(r,e,t){var Ze,qe;let i,l,o,{auto:s=void 0}=e,{blockspam:u=void 0}=e,{challengeurl:f=void 0}=e,{challengejson:a=void 0}=e,{debug:j=!1}=e,{expire:C=void 0}=e,{hidefooter:P=!1}=e,{hidelogo:H=!1}=e,{name:q="altcha"}=e,{maxnumber:k=1e6}=e,{mockerror:J=!1}=e,{refetchonexpire:G=!0}=e,{spamfilter:p=!1}=e,{strings:E=void 0}=e,{test:g=!1}=e,{verifyurl:_=void 0}=e,{workers:d=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:A=void 0}=e;const be=nt(),Ne=["SHA-256","SHA-384","SHA-512"],De=(qe=(Ze=document.documentElement.lang)==null?void 0:Ze.split("-"))==null?void 0:qe[0];let X=!1,oe,b=null,_e=null,W=null,F=m.UNVERIFIED,U=null;rt(()=>{b&&(b.removeEventListener("submit",Oe),b.removeEventListener("reset",Pe),b.removeEventListener("focusin",Ve),b=null),U&&(clearTimeout(U),U=null)}),tt(()=>{L("mounted","0.4.3"),L("workers",d),g&&L("using test mode"),C&&se(C),s!==void 0&&L("auto",s),b=oe.closest("form"),b&&(b.addEventListener("submit",Oe),b.addEventListener("reset",Pe),s==="onfocus"&&b.addEventListener("focusin",Ve)),s==="onload"&&z()});function L(...n){(j||n.some(h=>h instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Ve(n){F===m.UNVERIFIED&&z()}function Oe(n){b&&s==="onsubmit"&&F===m.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),z().then(()=>{b==null||b.requestSubmit()}))}function Pe(){ce()}function He(n,h){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:h.number,salt:n.salt,signature:n.signature,test:g?!0:void 0,took:h.took}))}function Fe(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Ne.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ne.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function It(){var n;if(J)throw L("mocking error"),new Error("Mocked error.");if(i)return L("using provided json data"),i;if(g)return L("generating test challenge",{test:g}),wt(typeof g!="boolean"?+g:void 0);{if(!f)throw new Error("Attribute challengeurl not set.");L("fetching challenge from",f);const h=await fetch(f,{headers:{"x-altcha-spam-filter":p?"1":"0"}});if(h.status!==200)throw new Error(`Server responded with ${h.status}.`);const v=h.headers.get("Expires"),M=h.headers.get("X-Altcha-Config"),S=await h.json(),N=new URLSearchParams((n=S.salt.split("?"))==null?void 0:n[1]),K=N.get("expires")||N.get("expire");if(K){const $=new Date(+K*1e3),x=isNaN($.getTime())?0:$.getTime()-Date.now();x>0&&se(x)}if(M)try{const $=JSON.parse(M);$&&typeof $=="object"&&($.verifyurl&&($.verifyurl=new URL($.verifyurl,new URL(f)).toString()),Be($))}catch($){L("unable to configure from X-Altcha-Config",$)}if(!C&&(v!=null&&v.length)){const $=Date.parse(v);if($){const x=$-Date.now();x>0&&se(x)}}return S}}function Ue(){f&&G&&F===m.VERIFIED?z():ce(m.EXPIRED,o.expired)}async function At(n){let h=null;if("Worker"in window){try{h=await Rt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(v){L(v)}if((h==null?void 0:h.number)!==void 0)return{data:n,solution:h}}return{data:n,solution:await yt(n.challenge,n.salt,n.algorithm,n.maxnumber||k).promise}}async function Rt(n,h,v,M=typeof g=="number"?g:k,S=Math.ceil(d)){const N=[];if(S<1)throw new Error("Wrong number of workers configured.");if(S>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let x=0;x{const Ge=fe*K;return new Promise(Ot=>{x.addEventListener("message",Xe=>{if(Xe.data)for(const Ye of N)Ye!==x&&Ye.postMessage({type:"abort"});Ot(Xe.data)}),x.postMessage({payload:{alg:v,challenge:n,max:Ge+K,salt:h,start:Ge},type:"work"})})}));for(const x of N)x.terminate();return $.find(x=>!!x)||null}function Mt(){[m.UNVERIFIED,m.ERROR,m.EXPIRED].includes(F)?p&&(b==null?void 0:b.reportValidity())===!1?t(6,X=!1):z():t(6,X=!0)}function Tt(){F===m.VERIFYING&&alert(o.waitAlert)}function se(n){L("expire",n),U&&(clearTimeout(U),U=null),n<1?Ue():U=setTimeout(Ue,n)}function St(n){var v;const h=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((v=h==null?void 0:h.value)==null?void 0:v.slice(h.value.indexOf("@")))||void 0}function jt(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(v=>`input[name="${v}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((v,M)=>{const S=M.name,N=M.value.trim();return S&&N&&(v[S]=N),v},{})}async function Nt(n){if(!_)throw new Error("Attribute verifyurl not set.");L("requesting server verification from",_);const h={payload:n};if(p){const{email:S,expectedLanguages:N,expectedCountries:K,fields:$,ipAddress:x,timeZone:fe}=typeof p=="object"?p:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};h.ipAddress=x===!1?void 0:x||"auto",h.email=S===!1?void 0:St(S),h.fields=$===!1?void 0:jt($),h.timeZone=fe===!1?void 0:fe||Ct(),h.expectedCountries=K,h.expectedLanguages=N||(De?[De]:void 0)}const v=await fetch(_,{body:JSON.stringify(h),headers:{"content-type":"application/json"},method:"POST"});if(v.status!==200)throw new Error(`Server responded with ${v.status}.`);const M=await v.json();if(M!=null&&M.payload&&t(4,W=M.payload),be("serververification",M),u&&M.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Be(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&z()),n.expire!==void 0&&(se(n.expire),t(14,C=n.expire)),n.challenge&&(Fe(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(12,f=n.challengeurl),n.debug!==void 0&&t(13,j=!!n.debug),n.hidefooter!==void 0&&t(1,P=!!n.hidefooter),n.hidelogo!==void 0&&t(2,H=!!n.hidelogo),n.maxnumber!==void 0&&t(15,k=+n.maxnumber),n.mockerror!==void 0&&t(16,J=!!n.mockerror),n.name!==void 0&&t(3,q=n.name),n.refetchonexpire!==void 0&&t(17,G=!!n.refetchonexpire),n.spamfilter!==void 0&&t(18,p=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(29,l=n.strings),n.test!==void 0&&t(19,g=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(20,_=n.verifyurl),n.workers!==void 0&&t(21,d=+n.workers)}function ce(n=m.UNVERIFIED,h=null){U&&(clearTimeout(U),U=null),t(6,X=!1),t(8,_e=h),t(4,W=null),t(5,F=n)}async function z(){return ce(m.VERIFYING),It().then(n=>(Fe(n),L("challenge",n),At(n))).then(({data:n,solution:h})=>{if(L("solution",h),(h==null?void 0:h.number)!==void 0){if(_)return Nt(He(n,h));t(4,W=He(n,h)),L("payload",W)}else throw L("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{it().then(()=>{t(5,F=m.VERIFIED),t(6,X=!0),L("verified"),be("verified",{payload:W})})}).catch(n=>{L(n),t(5,F=m.ERROR),t(6,X=!1),t(8,_e=n.message)})}function Dt(){X=this.checked,t(6,X)}function Vt(n){he[n?"unshift":"push"](()=>{oe=n,t(7,oe)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(22,u=n.blockspam),"challengeurl"in n&&t(12,f=n.challengeurl),"challengejson"in n&&t(23,a=n.challengejson),"debug"in n&&t(13,j=n.debug),"expire"in n&&t(14,C=n.expire),"hidefooter"in n&&t(1,P=n.hidefooter),"hidelogo"in n&&t(2,H=n.hidelogo),"name"in n&&t(3,q=n.name),"maxnumber"in n&&t(15,k=n.maxnumber),"mockerror"in n&&t(16,J=n.mockerror),"refetchonexpire"in n&&t(17,G=n.refetchonexpire),"spamfilter"in n&&t(18,p=n.spamfilter),"strings"in n&&t(24,E=n.strings),"test"in n&&t(19,g=n.test),"verifyurl"in n&&t(20,_=n.verifyurl),"workers"in n&&t(21,d=n.workers),"workerurl"in n&&t(25,A=n.workerurl)},r.$$.update=()=>{r.$$.dirty[0]&8388608&&(i=a?Se(a):void 0),r.$$.dirty[0]&16777216&&t(29,l=E?Se(E):{}),r.$$.dirty[0]&536870912&&t(9,o={ariaLinkLabel:Me,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),r.$$.dirty[0]&48&&be("statechange",{payload:W,state:F})},[s,P,H,q,W,F,X,oe,_e,o,Mt,Tt,f,j,C,k,J,G,p,g,_,d,u,a,E,A,Be,ce,z,l,Dt,Vt]}class je extends gt{constructor(e){super(),ht(this,e,Lt,xt,Je,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,workerurl:25,configure:26,reset:27,verify:28},null,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),y()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),y()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),y()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),y()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),y()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),y()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),y()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),y()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),y()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),y()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),y()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),y()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),y()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),y()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),y()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),y()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),y()}get workerurl(){return this.$$.ctx[25]}set workerurl(e){this.$$set({workerurl:e}),y()}get configure(){return this.$$.ctx[26]}get reset(){return this.$$.ctx[27]}get verify(){return this.$$.ctx[28]}}return customElements.define("altcha-widget",dt(je,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=r=>new Worker(new URL(r||"./worker.js",V&&V.src||new URL("altcha.iife.js",document.baseURI).href)),B.Altcha=je,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"}),B}({}); diff --git a/dist_external/altcha.js b/dist_external/altcha.js new file mode 100644 index 0000000..ef970aa --- /dev/null +++ b/dist_external/altcha.js @@ -0,0 +1,1248 @@ +var nt = Object.defineProperty; +var it = (r, e, t) => e in r ? nt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t; +var D = (r, e, t) => it(r, typeof e != "symbol" ? e + "" : e, t); +function ee() { +} +function Pe(r) { + return r(); +} +function Re() { + return /* @__PURE__ */ Object.create(null); +} +function re(r) { + r.forEach(Pe); +} +function He(r) { + return typeof r == "function"; +} +function lt(r, e) { + return r != r ? e == e : r !== e || r && typeof r == "object" || typeof r == "function"; +} +function ot(r) { + return Object.keys(r).length === 0; +} +function v(r, e) { + r.appendChild(e); +} +function j(r, e, t) { + r.insertBefore(e, t || null); +} +function M(r) { + r.parentNode && r.parentNode.removeChild(r); +} +function I(r) { + return document.createElement(r); +} +function B(r) { + return document.createElementNS("http://www.w3.org/2000/svg", r); +} +function st(r) { + return document.createTextNode(r); +} +function J() { + return st(" "); +} +function ue(r, e, t, i) { + return r.addEventListener(e, t, i), () => r.removeEventListener(e, t, i); +} +function c(r, e, t) { + t == null ? r.removeAttribute(e) : r.getAttribute(e) !== t && r.setAttribute(e, t); +} +function ct(r) { + return Array.from(r.childNodes); +} +function Me(r, e, t) { + r.classList.toggle(e, !!t); +} +function ft(r, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { + return new CustomEvent(r, { detail: e, bubbles: t, cancelable: i }); +} +function ut(r) { + const e = {}; + return r.childNodes.forEach( + /** @param {Element} node */ + (t) => { + e[t.slot || "default"] = !0; + } + ), e; +} +let te; +function Q(r) { + te = r; +} +function me() { + if (!te) throw new Error("Function called outside component initialization"); + return te; +} +function at(r) { + me().$$.on_mount.push(r); +} +function ht(r) { + me().$$.on_destroy.push(r); +} +function dt() { + const r = me(); + return (e, t, { cancelable: i = !1 } = {}) => { + const l = r.$$.callbacks[e]; + if (l) { + const o = ft( + /** @type {string} */ + e, + t, + { cancelable: i } + ); + return l.slice().forEach((s) => { + s.call(r, o); + }), !o.defaultPrevented; + } + return !0; + }; +} +const z = [], he = []; +let K = []; +const Te = [], Fe = /* @__PURE__ */ Promise.resolve(); +let de = !1; +function Ue() { + de || (de = !0, Fe.then(y)); +} +function gt() { + return Ue(), Fe; +} +function ge(r) { + K.push(r); +} +const ae = /* @__PURE__ */ new Set(); +let W = 0; +function y() { + if (W !== 0) + return; + const r = te; + do { + try { + for (; W < z.length; ) { + const e = z[W]; + W++, Q(e), mt(e.$$); + } + } catch (e) { + throw z.length = 0, W = 0, e; + } + for (Q(null), z.length = 0, W = 0; he.length; ) he.pop()(); + for (let e = 0; e < K.length; e += 1) { + const t = K[e]; + ae.has(t) || (ae.add(t), t()); + } + K.length = 0; + } while (z.length); + for (; Te.length; ) + Te.pop()(); + de = !1, ae.clear(), Q(r); +} +function mt(r) { + if (r.fragment !== null) { + r.update(), re(r.before_update); + const e = r.dirty; + r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, e), r.after_update.forEach(ge); + } +} +function bt(r) { + const e = [], t = []; + K.forEach((i) => r.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), K = e; +} +const _t = /* @__PURE__ */ new Set(); +function wt(r, e) { + r && r.i && (_t.delete(r), r.i(e)); +} +function yt(r, e, t) { + const { fragment: i, after_update: l } = r.$$; + i && i.m(e, t), ge(() => { + const o = r.$$.on_mount.map(Pe).filter(He); + r.$$.on_destroy ? r.$$.on_destroy.push(...o) : re(o), r.$$.on_mount = []; + }), l.forEach(ge); +} +function vt(r, e) { + const t = r.$$; + t.fragment !== null && (bt(t.after_update), re(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); +} +function kt(r, e) { + r.$$.dirty[0] === -1 && (z.push(r), Ue(), r.$$.dirty.fill(0)), r.$$.dirty[e / 31 | 0] |= 1 << e % 31; +} +function pt(r, e, t, i, l, o, s = null, u = [-1]) { + const f = te; + Q(r); + const a = r.$$ = { + fragment: null, + ctx: [], + // state + props: o, + update: ee, + not_equal: l, + bound: Re(), + // lifecycle + on_mount: [], + on_destroy: [], + on_disconnect: [], + before_update: [], + after_update: [], + context: new Map(e.context || (f ? f.$$.context : [])), + // everything else + callbacks: Re(), + dirty: u, + skip_bound: !1, + root: e.target || f.$$.root + }; + s && s(a.root); + let N = !1; + if (a.ctx = t ? t(r, e.props || {}, (C, V, ...O) => { + const F = O.length ? O[0] : V; + return a.ctx && l(a.ctx[C], a.ctx[C] = F) && (!a.skip_bound && a.bound[C] && a.bound[C](F), N && kt(r, C)), V; + }) : [], a.update(), N = !0, re(a.before_update), a.fragment = i ? i(a.ctx) : !1, e.target) { + if (e.hydrate) { + const C = ct(e.target); + a.fragment && a.fragment.l(C), C.forEach(M); + } else + a.fragment && a.fragment.c(); + e.intro && wt(r.$$.fragment), yt(r, e.target, e.anchor), y(); + } + Q(f); +} +let Be; +typeof HTMLElement == "function" && (Be = class extends HTMLElement { + constructor(e, t, i) { + super(); + /** The Svelte component constructor */ + D(this, "$$ctor"); + /** Slots */ + D(this, "$$s"); + /** The Svelte component instance */ + D(this, "$$c"); + /** Whether or not the custom element is connected */ + D(this, "$$cn", !1); + /** Component props data */ + D(this, "$$d", {}); + /** `true` if currently in the process of reflecting component props back to attributes */ + D(this, "$$r", !1); + /** @type {Record} Props definition (name, reflected, type etc) */ + D(this, "$$p_d", {}); + /** @type {Record} Event listeners */ + D(this, "$$l", {}); + /** @type {Map} Event listener unsubscribe functions */ + D(this, "$$l_u", /* @__PURE__ */ new Map()); + this.$$ctor = e, this.$$s = t, i && this.attachShadow({ mode: "open" }); + } + addEventListener(e, t, i) { + if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(t), this.$$c) { + const l = this.$$c.$on(e, t); + this.$$l_u.set(t, l); + } + super.addEventListener(e, t, i); + } + removeEventListener(e, t, i) { + if (super.removeEventListener(e, t, i), this.$$c) { + const l = this.$$l_u.get(t); + l && (l(), this.$$l_u.delete(t)); + } + } + async connectedCallback() { + if (this.$$cn = !0, !this.$$c) { + let e = function(o) { + return () => { + let s; + return { + c: function() { + s = I("slot"), o !== "default" && c(s, "name", o); + }, + /** + * @param {HTMLElement} target + * @param {HTMLElement} [anchor] + */ + m: function(a, N) { + j(a, s, N); + }, + d: function(a) { + a && M(s); + } + }; + }; + }; + if (await Promise.resolve(), !this.$$cn || this.$$c) + return; + const t = {}, i = ut(this); + for (const o of this.$$s) + o in i && (t[o] = [e(o)]); + for (const o of this.attributes) { + const s = this.$$g_p(o.name); + s in this.$$d || (this.$$d[s] = se(s, o.value, this.$$p_d, "toProp")); + } + for (const o in this.$$p_d) + !(o in this.$$d) && this[o] !== void 0 && (this.$$d[o] = this[o], delete this[o]); + this.$$c = new this.$$ctor({ + target: this.shadowRoot || this, + props: { + ...this.$$d, + $$slots: t, + $$scope: { + ctx: [] + } + } + }); + const l = () => { + this.$$r = !0; + for (const o in this.$$p_d) + if (this.$$d[o] = this.$$c.$$.ctx[this.$$c.$$.props[o]], this.$$p_d[o].reflect) { + const s = se( + o, + this.$$d[o], + this.$$p_d, + "toAttribute" + ); + s == null ? this.removeAttribute(this.$$p_d[o].attribute || o) : this.setAttribute(this.$$p_d[o].attribute || o, s); + } + this.$$r = !1; + }; + this.$$c.$$.after_update.push(l), l(); + for (const o in this.$$l) + for (const s of this.$$l[o]) { + const u = this.$$c.$on(o, s); + this.$$l_u.set(s, u); + } + this.$$l = {}; + } + } + // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte + // and setting attributes through setAttribute etc, this is helpful + attributeChangedCallback(e, t, i) { + var l; + this.$$r || (e = this.$$g_p(e), this.$$d[e] = se(e, i, this.$$p_d, "toProp"), (l = this.$$c) == null || l.$set({ [e]: this.$$d[e] })); + } + disconnectedCallback() { + this.$$cn = !1, Promise.resolve().then(() => { + this.$$cn || (this.$$c.$destroy(), this.$$c = void 0); + }); + } + $$g_p(e) { + return Object.keys(this.$$p_d).find( + (t) => this.$$p_d[t].attribute === e || !this.$$p_d[t].attribute && t.toLowerCase() === e + ) || e; + } +}); +function se(r, e, t, i) { + var o; + const l = (o = t[r]) == null ? void 0 : o.type; + if (e = l === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[r]) + 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 Et(r, e, t, i, l, o) { + let s = class extends Be { + constructor() { + super(r, t, l), this.$$p_d = e; + } + static get observedAttributes() { + return Object.keys(e).map( + (u) => (e[u].attribute || u).toLowerCase() + ); + } + }; + return Object.keys(e).forEach((u) => { + Object.defineProperty(s.prototype, u, { + get() { + return this.$$c && u in this.$$c ? this.$$c[u] : this.$$d[u]; + }, + set(f) { + var a; + f = se(u, f, e), this.$$d[u] = f, (a = this.$$c) == null || a.$set({ [u]: f }); + } + }); + }), i.forEach((u) => { + Object.defineProperty(s.prototype, u, { + get() { + var f; + return (f = this.$$c) == null ? void 0 : f[u]; + } + }); + }), o && (s = o(s)), r.element = /** @type {any} */ + s, s; +} +class $t { + constructor() { + /** + * ### PRIVATE API + * + * Do not use, may change at any time + * + * @type {any} + */ + D(this, "$$"); + /** + * ### PRIVATE API + * + * Do not use, may change at any time + * + * @type {any} + */ + D(this, "$$set"); + } + /** @returns {void} */ + $destroy() { + vt(this, 1), this.$destroy = ee; + } + /** + * @template {Extract} K + * @param {K} type + * @param {((e: Events[K]) => void) | null | undefined} callback + * @returns {() => void} + */ + $on(e, t) { + if (!He(t)) + return ee; + const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); + return i.push(t), () => { + const l = i.indexOf(t); + l !== -1 && i.splice(l, 1); + }; + } + /** + * @param {Partial} props + * @returns {void} + */ + $set(e) { + this.$$set && !ot(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); + } +} +const xt = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(xt); +const Ct = new TextEncoder(); +function Lt(r) { + return [...new Uint8Array(r)].map((e) => e.toString(16).padStart(2, "0")).join(""); +} +async function It(r, e = "SHA-256", t = 1e5) { + const i = Date.now().toString(16); + r || (r = Math.round(Math.random() * t)); + const l = await Ze(i, r, e); + return { + algorithm: e, + challenge: l, + salt: i, + signature: "" + }; +} +async function Ze(r, e, t) { + return Lt( + await crypto.subtle.digest( + t.toUpperCase(), + Ct.encode(r + e) + ) + ); +} +function At(r, e, t = "SHA-256", i = 1e6, l = 0) { + const o = new AbortController(), s = Date.now(); + return { + promise: (async () => { + for (let f = l; f <= i; f += 1) { + if (o.signal.aborted) + return null; + if (await Ze(e, f, t) === r) + return { + number: f, + took: Date.now() - s + }; + } + return null; + })(), + controller: o + }; +} +var b = /* @__PURE__ */ ((r) => (r.ERROR = "error", r.VERIFIED = "verified", r.VERIFYING = "verifying", r.UNVERIFIED = "unverified", r.EXPIRED = "expired", r))(b || {}); +function je(r) { + let e, t, i; + return { + c() { + e = B("svg"), t = B("path"), i = B("path"), c(t, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), c(t, "fill", "currentColor"), c(t, "opacity", ".25"), c(i, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), c(i, "fill", "currentColor"), c(i, "class", "altcha-spinner"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg"); + }, + m(l, o) { + j(l, e, o), v(e, t), v(e, i); + }, + d(l) { + l && M(e); + } + }; +} +function Rt(r) { + let e, t = ( + /*_strings*/ + r[9].label + "" + ), i; + return { + c() { + e = I("label"), c(e, "for", i = /*name*/ + r[3] + "_checkbox"); + }, + m(l, o) { + j(l, e, o), e.innerHTML = t; + }, + p(l, o) { + o[0] & /*_strings*/ + 512 && t !== (t = /*_strings*/ + l[9].label + "") && (e.innerHTML = t), o[0] & /*name*/ + 8 && i !== (i = /*name*/ + l[3] + "_checkbox") && c(e, "for", i); + }, + d(l) { + l && M(e); + } + }; +} +function Mt(r) { + let e, t = ( + /*_strings*/ + r[9].verifying + "" + ); + return { + c() { + e = I("span"); + }, + m(i, l) { + j(i, e, l), e.innerHTML = t; + }, + p(i, l) { + l[0] & /*_strings*/ + 512 && t !== (t = /*_strings*/ + i[9].verifying + "") && (e.innerHTML = t); + }, + d(i) { + i && M(e); + } + }; +} +function Tt(r) { + let e, t = ( + /*_strings*/ + r[9].verified + "" + ), i, l; + return { + c() { + e = I("span"), i = J(), l = I("input"), c(l, "type", "hidden"), c( + l, + "name", + /*name*/ + r[3] + ), l.value = /*payload*/ + r[4]; + }, + m(o, s) { + j(o, e, s), e.innerHTML = t, j(o, i, s), j(o, l, s); + }, + p(o, s) { + s[0] & /*_strings*/ + 512 && t !== (t = /*_strings*/ + o[9].verified + "") && (e.innerHTML = t), s[0] & /*name*/ + 8 && c( + l, + "name", + /*name*/ + o[3] + ), s[0] & /*payload*/ + 16 && (l.value = /*payload*/ + o[4]); + }, + d(o) { + o && (M(e), M(i), M(l)); + } + }; +} +function Ne(r) { + let e, t, i, l, o, s, u; + return { + c() { + e = I("div"), t = I("a"), i = B("svg"), l = B("path"), o = B("path"), s = B("path"), c(l, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), c(l, "fill", "currentColor"), c(o, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), c(o, "fill", "currentColor"), c(s, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), c(s, "fill", "currentColor"), c(i, "width", "22"), c(i, "height", "22"), c(i, "viewBox", "0 0 20 20"), c(i, "fill", "none"), c(i, "xmlns", "http://www.w3.org/2000/svg"), c(t, "href", qe), c(t, "target", "_blank"), c(t, "class", "altcha-logo"), c(t, "aria-label", u = /*_strings*/ + r[9].ariaLinkLabel); + }, + m(f, a) { + j(f, e, a), v(e, t), v(t, i), v(i, l), v(i, o), v(i, s); + }, + p(f, a) { + a[0] & /*_strings*/ + 512 && u !== (u = /*_strings*/ + f[9].ariaLinkLabel) && c(t, "aria-label", u); + }, + d(f) { + f && M(e); + } + }; +} +function Se(r) { + let e, t, i, l; + function o(f, a) { + return ( + /*state*/ + f[5] === b.EXPIRED ? Nt : jt + ); + } + let s = o(r), u = s(r); + return { + c() { + e = I("div"), t = B("svg"), i = B("path"), l = J(), u.c(), c(i, "stroke-linecap", "round"), c(i, "stroke-linejoin", "round"), c(i, "d", "M6 18L18 6M6 6l12 12"), c(t, "width", "14"), c(t, "height", "14"), c(t, "xmlns", "http://www.w3.org/2000/svg"), c(t, "fill", "none"), c(t, "viewBox", "0 0 24 24"), c(t, "stroke-width", "1.5"), c(t, "stroke", "currentColor"), c(e, "class", "altcha-error"); + }, + m(f, a) { + j(f, e, a), v(e, t), v(t, i), v(e, l), u.m(e, null); + }, + p(f, a) { + s === (s = o(f)) && u ? u.p(f, a) : (u.d(1), u = s(f), u && (u.c(), u.m(e, null))); + }, + d(f) { + f && M(e), u.d(); + } + }; +} +function jt(r) { + let e, t = ( + /*_strings*/ + r[9].error + "" + ); + return { + c() { + e = I("div"), c( + e, + "title", + /*error*/ + r[8] + ); + }, + m(i, l) { + j(i, e, l), e.innerHTML = t; + }, + p(i, l) { + l[0] & /*_strings*/ + 512 && t !== (t = /*_strings*/ + i[9].error + "") && (e.innerHTML = t), l[0] & /*error*/ + 256 && c( + e, + "title", + /*error*/ + i[8] + ); + }, + d(i) { + i && M(e); + } + }; +} +function Nt(r) { + let e, t = ( + /*_strings*/ + r[9].expired + "" + ); + return { + c() { + e = I("div"), c( + e, + "title", + /*error*/ + r[8] + ); + }, + m(i, l) { + j(i, e, l), e.innerHTML = t; + }, + p(i, l) { + l[0] & /*_strings*/ + 512 && t !== (t = /*_strings*/ + i[9].expired + "") && (e.innerHTML = t), l[0] & /*error*/ + 256 && c( + e, + "title", + /*error*/ + i[8] + ); + }, + d(i) { + i && M(e); + } + }; +} +function De(r) { + let e, t, i = ( + /*_strings*/ + r[9].footer + "" + ); + return { + c() { + e = I("div"), t = I("div"), c(e, "class", "altcha-footer"); + }, + m(l, o) { + j(l, e, o), v(e, t), t.innerHTML = i; + }, + p(l, o) { + o[0] & /*_strings*/ + 512 && i !== (i = /*_strings*/ + l[9].footer + "") && (t.innerHTML = i); + }, + d(l) { + l && M(e); + } + }; +} +function St(r) { + let e, t, i, l, o, s, u, f, a, N, C, V, O, F, k = ( + /*state*/ + r[5] === b.VERIFYING && je() + ); + function q(d, A) { + return ( + /*state*/ + d[5] === b.VERIFIED ? Tt : ( + /*state*/ + d[5] === b.VERIFYING ? Mt : Rt + ) + ); + } + let U = q(r), p = U(r), E = ( + /*hidelogo*/ + r[2] !== !0 && Ne(r) + ), g = ( + /*error*/ + (r[8] || /*state*/ + r[5] === b.EXPIRED) && Se(r) + ), _ = ( + /*_strings*/ + r[9].footer && /*hidefooter*/ + r[1] !== !0 && De(r) + ); + return { + c() { + e = I("div"), t = I("div"), k && k.c(), i = J(), l = I("div"), o = I("input"), f = J(), a = I("div"), p.c(), N = J(), E && E.c(), C = J(), g && g.c(), V = J(), _ && _.c(), c(o, "type", "checkbox"), c(o, "id", s = /*name*/ + r[3] + "_checkbox"), o.required = u = /*auto*/ + r[0] !== "onsubmit", c(l, "class", "altcha-checkbox"), Me( + l, + "altcha-hidden", + /*state*/ + r[5] === b.VERIFYING + ), c(a, "class", "altcha-label"), c(t, "class", "altcha-main"), c(e, "class", "altcha"), c( + e, + "data-state", + /*state*/ + r[5] + ); + }, + m(d, A) { + j(d, e, A), v(e, t), k && k.m(t, null), v(t, i), v(t, l), v(l, o), o.checked = /*checked*/ + r[6], v(t, f), v(t, a), p.m(a, null), v(t, N), E && E.m(t, null), v(e, C), g && g.m(e, null), v(e, V), _ && _.m(e, null), r[31](e), O || (F = [ + ue( + o, + "change", + /*input_change_handler*/ + r[30] + ), + ue( + o, + "change", + /*onCheckedChange*/ + r[10] + ), + ue( + o, + "invalid", + /*onInvalid*/ + r[11] + ) + ], O = !0); + }, + p(d, A) { + /*state*/ + d[5] === b.VERIFYING ? k || (k = je(), k.c(), k.m(t, i)) : k && (k.d(1), k = null), A[0] & /*name*/ + 8 && s !== (s = /*name*/ + d[3] + "_checkbox") && c(o, "id", s), A[0] & /*auto*/ + 1 && u !== (u = /*auto*/ + d[0] !== "onsubmit") && (o.required = u), A[0] & /*checked*/ + 64 && (o.checked = /*checked*/ + d[6]), A[0] & /*state*/ + 32 && Me( + l, + "altcha-hidden", + /*state*/ + d[5] === b.VERIFYING + ), U === (U = q(d)) && p ? p.p(d, A) : (p.d(1), p = U(d), p && (p.c(), p.m(a, null))), /*hidelogo*/ + d[2] !== !0 ? E ? E.p(d, A) : (E = Ne(d), E.c(), E.m(t, null)) : E && (E.d(1), E = null), /*error*/ + d[8] || /*state*/ + d[5] === b.EXPIRED ? g ? g.p(d, A) : (g = Se(d), g.c(), g.m(e, V)) : g && (g.d(1), g = null), /*_strings*/ + d[9].footer && /*hidefooter*/ + d[1] !== !0 ? _ ? _.p(d, A) : (_ = De(d), _.c(), _.m(e, null)) : _ && (_.d(1), _ = null), A[0] & /*state*/ + 32 && c( + e, + "data-state", + /*state*/ + d[5] + ); + }, + i: ee, + o: ee, + d(d) { + d && M(e), k && k.d(), p.d(), E && E.d(), g && g.d(), _ && _.d(), r[31](null), O = !1, re(F); + } + }; +} +const Ve = "Visit Altcha.org", qe = "https://altcha.org/"; +function Oe(r) { + return JSON.parse(r); +} +function Dt() { + try { + return Intl.DateTimeFormat().resolvedOptions().timeZone; + } catch { + } +} +function Vt(r, e, t) { + var xe, Ce; + let i, l, o, { auto: s = void 0 } = e, { blockspam: u = void 0 } = e, { challengeurl: f = void 0 } = e, { challengejson: a = void 0 } = e, { debug: N = !1 } = e, { expire: C = void 0 } = e, { hidefooter: V = !1 } = e, { hidelogo: O = !1 } = e, { name: F = "altcha" } = e, { maxnumber: k = 1e6 } = e, { mockerror: q = !1 } = e, { refetchonexpire: U = !0 } = e, { spamfilter: p = !1 } = e, { strings: E = void 0 } = e, { test: g = !1 } = e, { verifyurl: _ = void 0 } = e, { workers: d = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: A = void 0 } = e; + const ce = dt(), be = ["SHA-256", "SHA-384", "SHA-512"], _e = (Ce = (xe = document.documentElement.lang) == null ? void 0 : xe.split("-")) == null ? void 0 : Ce[0]; + let Z = !1, ne, m = null, fe = null, G = null, P = b.UNVERIFIED, H = null; + ht(() => { + m && (m.removeEventListener("submit", ye), m.removeEventListener("reset", ve), m.removeEventListener("focusin", we), m = null), H && (clearTimeout(H), H = null); + }), at(() => { + L("mounted", "0.4.3"), L("workers", d), g && L("using test mode"), C && ie(C), s !== void 0 && L("auto", s), m = ne.closest("form"), m && (m.addEventListener("submit", ye), m.addEventListener("reset", ve), s === "onfocus" && m.addEventListener("focusin", we)), s === "onload" && X(); + }); + function L(...n) { + (N || n.some((h) => h instanceof Error)) && console[n[0] instanceof Error ? "error" : "log"]("ALTCHA", ...n); + } + function we(n) { + P === b.UNVERIFIED && X(); + } + function ye(n) { + m && s === "onsubmit" && P === b.UNVERIFIED && (n.preventDefault(), n.stopPropagation(), X().then(() => { + m == null || m.requestSubmit(); + })); + } + function ve() { + le(); + } + function ke(n, h) { + return btoa(JSON.stringify({ + algorithm: n.algorithm, + challenge: n.challenge, + number: h.number, + salt: n.salt, + signature: n.signature, + test: g ? !0 : void 0, + took: h.took + })); + } + function pe(n) { + if (!n.algorithm) + throw new Error("Invalid challenge. Property algorithm is missing."); + if (n.signature === void 0) + throw new Error("Invalid challenge. Property signature is missing."); + if (!be.includes(n.algorithm.toUpperCase())) + throw new Error(`Unknown algorithm value. Allowed values: ${be.join(", ")}`); + if (!n.challenge || n.challenge.length < 40) + throw new Error("Challenge is too short. Min. 40 chars."); + if (!n.salt || n.salt.length < 10) + throw new Error("Salt is too short. Min. 10 chars."); + } + async function Ge() { + var n; + if (q) + throw L("mocking error"), new Error("Mocked error."); + if (i) + return L("using provided json data"), i; + if (g) + return L("generating test challenge", { test: g }), It(typeof g != "boolean" ? +g : void 0); + { + if (!f) + throw new Error("Attribute challengeurl not set."); + L("fetching challenge from", f); + const h = await fetch(f, { + headers: { + "x-altcha-spam-filter": p ? "1" : "0" + } + }); + if (h.status !== 200) + throw new Error(`Server responded with ${h.status}.`); + const w = h.headers.get("Expires"), R = h.headers.get("X-Altcha-Config"), T = await h.json(), S = new URLSearchParams((n = T.salt.split("?")) == null ? void 0 : n[1]), Y = S.get("expires") || S.get("expire"); + if (Y) { + const $ = new Date(+Y * 1e3), x = isNaN($.getTime()) ? 0 : $.getTime() - Date.now(); + x > 0 && ie(x); + } + if (R) + try { + const $ = JSON.parse(R); + $ && typeof $ == "object" && ($.verifyurl && ($.verifyurl = new URL($.verifyurl, new URL(f)).toString()), $e($)); + } catch ($) { + L("unable to configure from X-Altcha-Config", $); + } + if (!C && (w != null && w.length)) { + const $ = Date.parse(w); + if ($) { + const x = $ - Date.now(); + x > 0 && ie(x); + } + } + return T; + } + } + function Ee() { + f && U && P === b.VERIFIED ? X() : le(b.EXPIRED, o.expired); + } + async function Xe(n) { + let h = null; + if ("Worker" in window) { + try { + h = await Ye(n.challenge, n.salt, n.algorithm, n.maxnumber); + } catch (w) { + L(w); + } + if ((h == null ? void 0 : h.number) !== void 0) + return { data: n, solution: h }; + } + return { + data: n, + solution: await At(n.challenge, n.salt, n.algorithm, n.maxnumber || k).promise + }; + } + async function Ye(n, h, w, R = typeof g == "number" ? g : k, T = Math.ceil(d)) { + const S = []; + if (T < 1) + throw new Error("Wrong number of workers configured."); + if (T > 16) + throw new Error("Too many workers. Max. 16 allowed workers."); + for (let x = 0; x < T; x++) + S.push(createAltchaWorker(A)); + const Y = Math.ceil(R / T), $ = await Promise.all(S.map((x, oe) => { + const Le = oe * Y; + return new Promise((rt) => { + x.addEventListener("message", (Ie) => { + if (Ie.data) + for (const Ae of S) + Ae !== x && Ae.postMessage({ type: "abort" }); + rt(Ie.data); + }), x.postMessage({ + payload: { + alg: w, + challenge: n, + max: Le + Y, + salt: h, + start: Le + }, + type: "work" + }); + }); + })); + for (const x of S) + x.terminate(); + return $.find((x) => !!x) || null; + } + function Je() { + [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(P) ? p && (m == null ? void 0 : m.reportValidity()) === !1 ? t(6, Z = !1) : X() : t(6, Z = !0); + } + function We() { + P === b.VERIFYING && alert(o.waitAlert); + } + function ie(n) { + L("expire", n), H && (clearTimeout(H), H = null), n < 1 ? Ee() : H = setTimeout(Ee, n); + } + function ze(n) { + var w; + const h = m == null ? void 0 : m.querySelector(typeof n == "string" ? `input[name="${n}"]` : 'input[type="email"]:not([data-no-spamfilter])'); + return ((w = h == null ? void 0 : h.value) == null ? void 0 : w.slice(h.value.indexOf("@"))) || void 0; + } + function Ke(n) { + return [ + ...(m == null ? void 0 : m.querySelectorAll(n != null && n.length ? n.map((w) => `input[name="${w}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] + ].reduce( + (w, R) => { + const T = R.name, S = R.value.trim(); + return T && S && (w[T] = S), w; + }, + {} + ); + } + async function Qe(n) { + if (!_) + throw new Error("Attribute verifyurl not set."); + L("requesting server verification from", _); + const h = { payload: n }; + if (p) { + const { email: T, expectedLanguages: S, expectedCountries: Y, fields: $, ipAddress: x, timeZone: oe } = typeof p == "object" ? p : { + email: void 0, + expectedCountries: void 0, + expectedLanguages: void 0, + fields: void 0, + ipAddress: void 0, + timeZone: void 0 + }; + h.ipAddress = x === !1 ? void 0 : x || "auto", h.email = T === !1 ? void 0 : ze(T), h.fields = $ === !1 ? void 0 : Ke($), h.timeZone = oe === !1 ? void 0 : oe || Dt(), h.expectedCountries = Y, h.expectedLanguages = S || (_e ? [_e] : void 0); + } + const w = await fetch(_, { + body: JSON.stringify(h), + headers: { "content-type": "application/json" }, + method: "POST" + }); + if (w.status !== 200) + throw new Error(`Server responded with ${w.status}.`); + const R = await w.json(); + if (R != null && R.payload && t(4, G = R.payload), ce("serververification", R), u && R.classification === "BAD") + throw new Error("SpamFilter returned negative classification."); + } + function $e(n) { + n.auto !== void 0 && (t(0, s = n.auto), s === "onload" && X()), n.expire !== void 0 && (ie(n.expire), t(14, C = n.expire)), n.challenge && (pe(n.challenge), i = n.challenge), n.challengeurl !== void 0 && t(12, f = n.challengeurl), n.debug !== void 0 && t(13, N = !!n.debug), n.hidefooter !== void 0 && t(1, V = !!n.hidefooter), n.hidelogo !== void 0 && t(2, O = !!n.hidelogo), n.maxnumber !== void 0 && t(15, k = +n.maxnumber), n.mockerror !== void 0 && t(16, q = !!n.mockerror), n.name !== void 0 && t(3, F = n.name), n.refetchonexpire !== void 0 && t(17, U = !!n.refetchonexpire), n.spamfilter !== void 0 && t(18, p = typeof n.spamfilter == "object" ? n.spamfilter : !!n.spamfilter), n.strings && t(29, l = n.strings), n.test !== void 0 && t(19, g = typeof n.test == "number" ? n.test : !!n.test), n.verifyurl !== void 0 && t(20, _ = n.verifyurl), n.workers !== void 0 && t(21, d = +n.workers); + } + function le(n = b.UNVERIFIED, h = null) { + H && (clearTimeout(H), H = null), t(6, Z = !1), t(8, fe = h), t(4, G = null), t(5, P = n); + } + async function X() { + return le(b.VERIFYING), Ge().then((n) => (pe(n), L("challenge", n), Xe(n))).then(({ data: n, solution: h }) => { + if (L("solution", h), (h == null ? void 0 : h.number) !== void 0) { + if (_) + return Qe(ke(n, h)); + t(4, G = ke(n, h)), L("payload", G); + } else + throw L("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); + }).then(() => { + gt().then(() => { + t(5, P = b.VERIFIED), t(6, Z = !0), L("verified"), ce("verified", { payload: G }); + }); + }).catch((n) => { + L(n), t(5, P = b.ERROR), t(6, Z = !1), t(8, fe = n.message); + }); + } + function et() { + Z = this.checked, t(6, Z); + } + function tt(n) { + he[n ? "unshift" : "push"](() => { + ne = n, t(7, ne); + }); + } + return r.$$set = (n) => { + "auto" in n && t(0, s = n.auto), "blockspam" in n && t(22, u = n.blockspam), "challengeurl" in n && t(12, f = n.challengeurl), "challengejson" in n && t(23, a = n.challengejson), "debug" in n && t(13, N = n.debug), "expire" in n && t(14, C = n.expire), "hidefooter" in n && t(1, V = n.hidefooter), "hidelogo" in n && t(2, O = n.hidelogo), "name" in n && t(3, F = n.name), "maxnumber" in n && t(15, k = n.maxnumber), "mockerror" in n && t(16, q = n.mockerror), "refetchonexpire" in n && t(17, U = n.refetchonexpire), "spamfilter" in n && t(18, p = n.spamfilter), "strings" in n && t(24, E = n.strings), "test" in n && t(19, g = n.test), "verifyurl" in n && t(20, _ = n.verifyurl), "workers" in n && t(21, d = n.workers), "workerurl" in n && t(25, A = n.workerurl); + }, r.$$.update = () => { + r.$$.dirty[0] & /*challengejson*/ + 8388608 && (i = a ? Oe(a) : void 0), r.$$.dirty[0] & /*strings*/ + 16777216 && t(29, l = E ? Oe(E) : {}), r.$$.dirty[0] & /*parsedStrings*/ + 536870912 && t(9, o = { + ariaLinkLabel: Ve, + error: "Verification failed. Try again later.", + expired: "Verification expired. Try again.", + footer: `Protected by ALTCHA`, + label: "I'm not a robot", + verified: "Verified", + verifying: "Verifying...", + waitAlert: "Verifying... please wait.", + ...l + }), r.$$.dirty[0] & /*payload, state*/ + 48 && ce("statechange", { payload: G, state: P }); + }, [ + s, + V, + O, + F, + G, + P, + Z, + ne, + fe, + o, + Je, + We, + f, + N, + C, + k, + q, + U, + p, + g, + _, + d, + u, + a, + E, + A, + $e, + le, + X, + l, + et, + tt + ]; +} +class Ot extends $t { + constructor(e) { + super(), pt( + this, + e, + Vt, + St, + lt, + { + auto: 0, + blockspam: 22, + challengeurl: 12, + challengejson: 23, + debug: 13, + expire: 14, + hidefooter: 1, + hidelogo: 2, + name: 3, + maxnumber: 15, + mockerror: 16, + refetchonexpire: 17, + spamfilter: 18, + strings: 24, + test: 19, + verifyurl: 20, + workers: 21, + workerurl: 25, + configure: 26, + reset: 27, + verify: 28 + }, + null, + [-1, -1] + ); + } + get auto() { + return this.$$.ctx[0]; + } + set auto(e) { + this.$$set({ auto: e }), y(); + } + get blockspam() { + return this.$$.ctx[22]; + } + set blockspam(e) { + this.$$set({ blockspam: e }), y(); + } + get challengeurl() { + return this.$$.ctx[12]; + } + set challengeurl(e) { + this.$$set({ challengeurl: e }), y(); + } + get challengejson() { + return this.$$.ctx[23]; + } + set challengejson(e) { + this.$$set({ challengejson: e }), y(); + } + get debug() { + return this.$$.ctx[13]; + } + set debug(e) { + this.$$set({ debug: e }), y(); + } + get expire() { + return this.$$.ctx[14]; + } + set expire(e) { + this.$$set({ expire: e }), y(); + } + get hidefooter() { + return this.$$.ctx[1]; + } + set hidefooter(e) { + this.$$set({ hidefooter: e }), y(); + } + get hidelogo() { + return this.$$.ctx[2]; + } + set hidelogo(e) { + this.$$set({ hidelogo: e }), y(); + } + get name() { + return this.$$.ctx[3]; + } + set name(e) { + this.$$set({ name: e }), y(); + } + get maxnumber() { + return this.$$.ctx[15]; + } + set maxnumber(e) { + this.$$set({ maxnumber: e }), y(); + } + get mockerror() { + return this.$$.ctx[16]; + } + set mockerror(e) { + this.$$set({ mockerror: e }), y(); + } + get refetchonexpire() { + return this.$$.ctx[17]; + } + set refetchonexpire(e) { + this.$$set({ refetchonexpire: e }), y(); + } + get spamfilter() { + return this.$$.ctx[18]; + } + set spamfilter(e) { + this.$$set({ spamfilter: e }), y(); + } + get strings() { + return this.$$.ctx[24]; + } + set strings(e) { + this.$$set({ strings: e }), y(); + } + get test() { + return this.$$.ctx[19]; + } + set test(e) { + this.$$set({ test: e }), y(); + } + get verifyurl() { + return this.$$.ctx[20]; + } + set verifyurl(e) { + this.$$set({ verifyurl: e }), y(); + } + get workers() { + return this.$$.ctx[21]; + } + set workers(e) { + this.$$set({ workers: e }), y(); + } + get workerurl() { + return this.$$.ctx[25]; + } + set workerurl(e) { + this.$$set({ workerurl: e }), y(); + } + get configure() { + return this.$$.ctx[26]; + } + get reset() { + return this.$$.ctx[27]; + } + get verify() { + return this.$$.ctx[28]; + } +} +customElements.define("altcha-widget", Et(Ot, { auto: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, expire: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, [], ["configure", "reset", "verify"], !1)); +globalThis.createAltchaWorker = (r) => new Worker(new URL(r || "./worker.js", import.meta.url)); +export { + Ot as Altcha +}; diff --git a/dist_external/altcha.umd.cjs b/dist_external/altcha.umd.cjs new file mode 100644 index 0000000..beeeb32 --- /dev/null +++ b/dist_external/altcha.umd.cjs @@ -0,0 +1 @@ +(function(N,R){typeof exports=="object"&&typeof module<"u"?R(exports):typeof define=="function"&&define.amd?define(["exports"],R):(N=typeof globalThis<"u"?globalThis:N||self,R(N.altcha={}))})(this,function(N){"use strict";var Pt=Object.defineProperty;var Ht=(N,R,P)=>R in N?Pt(N,R,{enumerable:!0,configurable:!0,writable:!0,value:P}):N[R]=P;var O=(N,R,P)=>Ht(N,typeof R!="symbol"?R+"":R,P);var R=typeof document<"u"?document.currentScript:null;function P(){}function we(r){return r()}function ye(){return Object.create(null)}function re(r){r.forEach(we)}function pe(r){return typeof r=="function"}function Je(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function We(r){return Object.keys(r).length===0}function w(r,e){r.appendChild(e)}function j(r,e,t){r.insertBefore(e,t||null)}function T(r){r.parentNode&&r.parentNode.removeChild(r)}function I(r){return document.createElement(r)}function Z(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function ze(r){return document.createTextNode(r)}function Y(){return ze(" ")}function ue(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function f(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function Ke(r){return Array.from(r.childNodes)}function ve(r,e,t){r.classList.toggle(e,!!t)}function Qe(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function et(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ne;function ie(r){ne=r}function ae(){if(!ne)throw new Error("Function called outside component initialization");return ne}function tt(r){ae().$$.on_mount.push(r)}function rt(r){ae().$$.on_destroy.push(r)}function nt(){const r=ae();return(e,t,{cancelable:i=!1}={})=>{const l=r.$$.callbacks[e];if(l){const o=Qe(e,t,{cancelable:i});return l.slice().forEach(s=>{s.call(r,o)}),!o.defaultPrevented}return!0}}const Q=[],he=[];let ee=[];const ke=[],Ee=Promise.resolve();let de=!1;function $e(){de||(de=!0,Ee.then(y))}function it(){return $e(),Ee}function ge(r){ee.push(r)}const me=new Set;let te=0;function y(){if(te!==0)return;const r=ne;do{try{for(;ter.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),ee=e}const st=new Set;function ft(r,e){r&&r.i&&(st.delete(r),r.i(e))}function ct(r,e,t){const{fragment:i,after_update:l}=r.$$;i&&i.m(e,t),ge(()=>{const o=r.$$.on_mount.map(we).filter(pe);r.$$.on_destroy?r.$$.on_destroy.push(...o):re(o),r.$$.on_mount=[]}),l.forEach(ge)}function ut(r,e){const t=r.$$;t.fragment!==null&&(ot(t.after_update),re(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function at(r,e){r.$$.dirty[0]===-1&&(Q.push(r),$e(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<{const q=F.length?F[0]:H;return a.ctx&&l(a.ctx[C],a.ctx[C]=q)&&(!a.skip_bound&&a.bound[C]&&a.bound[C](q),D&&at(r,C)),H}):[],a.update(),D=!0,re(a.before_update),a.fragment=i?i(a.ctx):!1,e.target){if(e.hydrate){const C=Ke(e.target);a.fragment&&a.fragment.l(C),C.forEach(T)}else a.fragment&&a.fragment.c();e.intro&&ft(r.$$.fragment),ct(r,e.target,e.anchor),y()}ie(c)}let xe;typeof HTMLElement=="function"&&(xe=class extends HTMLElement{constructor(e,t,i){super();O(this,"$$ctor");O(this,"$$s");O(this,"$$c");O(this,"$$cn",!1);O(this,"$$d",{});O(this,"$$r",!1);O(this,"$$p_d",{});O(this,"$$l",{});O(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const l=this.$$c.$on(e,t);this.$$l_u.set(t,l)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const l=this.$$l_u.get(t);l&&(l(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(o){return()=>{let s;return{c:function(){s=I("slot"),o!=="default"&&f(s,"name",o)},m:function(a,D){j(a,s,D)},d:function(a){a&&T(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=et(this);for(const o of this.$$s)o in i&&(t[o]=[e(o)]);for(const o of this.attributes){const s=this.$$g_p(o.name);s in this.$$d||(this.$$d[s]=le(s,o.value,this.$$p_d,"toProp"))}for(const o in this.$$p_d)!(o in this.$$d)&&this[o]!==void 0&&(this.$$d[o]=this[o],delete this[o]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const l=()=>{this.$$r=!0;for(const o in this.$$p_d)if(this.$$d[o]=this.$$c.$$.ctx[this.$$c.$$.props[o]],this.$$p_d[o].reflect){const s=le(o,this.$$d[o],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[o].attribute||o):this.setAttribute(this.$$p_d[o].attribute||o,s)}this.$$r=!1};this.$$c.$$.after_update.push(l),l();for(const o in this.$$l)for(const s of this.$$l[o]){const u=this.$$c.$on(o,s);this.$$l_u.set(s,u)}this.$$l={}}}attributeChangedCallback(e,t,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=le(e,i,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function le(r,e,t,i){var o;const l=(o=t[r])==null?void 0:o.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])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 dt(r,e,t,i,l,o){let s=class extends xe{constructor(){super(r,t,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(u=>(e[u].attribute||u).toLowerCase())}};return Object.keys(e).forEach(u=>{Object.defineProperty(s.prototype,u,{get(){return this.$$c&&u in this.$$c?this.$$c[u]:this.$$d[u]},set(c){var a;c=le(u,c,e),this.$$d[u]=c,(a=this.$$c)==null||a.$set({[u]:c})}})}),i.forEach(u=>{Object.defineProperty(s.prototype,u,{get(){var c;return(c=this.$$c)==null?void 0:c[u]}})}),o&&(s=o(s)),r.element=s,s}class gt{constructor(){O(this,"$$");O(this,"$$set")}$destroy(){ut(this,1),this.$destroy=P}$on(e,t){if(!pe(t))return P;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const l=i.indexOf(t);l!==-1&&i.splice(l,1)}}$set(e){this.$$set&&!We(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const mt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(mt);const bt=new TextEncoder;function _t(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function wt(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const l=await Ce(i,r,e);return{algorithm:e,challenge:l,salt:i,signature:""}}async function Ce(r,e,t){return _t(await crypto.subtle.digest(t.toUpperCase(),bt.encode(r+e)))}function yt(r,e,t="SHA-256",i=1e6,l=0){const o=new AbortController,s=Date.now();return{promise:(async()=>{for(let c=l;c<=i;c+=1){if(o.signal.aborted)return null;if(await Ce(e,c,t)===r)return{number:c,took:Date.now()-s}}return null})(),controller:o}}var m=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(m||{});function Le(r){let e,t,i;return{c(){e=Z("svg"),t=Z("path"),i=Z("path"),f(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),f(t,"fill","currentColor"),f(t,"opacity",".25"),f(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"),f(i,"fill","currentColor"),f(i,"class","altcha-spinner"),f(e,"width","24"),f(e,"height","24"),f(e,"viewBox","0 0 24 24"),f(e,"xmlns","http://www.w3.org/2000/svg")},m(l,o){j(l,e,o),w(e,t),w(e,i)},d(l){l&&T(e)}}}function pt(r){let e,t=r[9].label+"",i;return{c(){e=I("label"),f(e,"for",i=r[3]+"_checkbox")},m(l,o){j(l,e,o),e.innerHTML=t},p(l,o){o[0]&512&&t!==(t=l[9].label+"")&&(e.innerHTML=t),o[0]&8&&i!==(i=l[3]+"_checkbox")&&f(e,"for",i)},d(l){l&&T(e)}}}function vt(r){let e,t=r[9].verifying+"";return{c(){e=I("span")},m(i,l){j(i,e,l),e.innerHTML=t},p(i,l){l[0]&512&&t!==(t=i[9].verifying+"")&&(e.innerHTML=t)},d(i){i&&T(e)}}}function kt(r){let e,t=r[9].verified+"",i,l;return{c(){e=I("span"),i=Y(),l=I("input"),f(l,"type","hidden"),f(l,"name",r[3]),l.value=r[4]},m(o,s){j(o,e,s),e.innerHTML=t,j(o,i,s),j(o,l,s)},p(o,s){s[0]&512&&t!==(t=o[9].verified+"")&&(e.innerHTML=t),s[0]&8&&f(l,"name",o[3]),s[0]&16&&(l.value=o[4])},d(o){o&&(T(e),T(i),T(l))}}}function Ie(r){let e,t,i,l,o,s,u;return{c(){e=I("div"),t=I("a"),i=Z("svg"),l=Z("path"),o=Z("path"),s=Z("path"),f(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"),f(l,"fill","currentColor"),f(o,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),f(o,"fill","currentColor"),f(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"),f(s,"fill","currentColor"),f(i,"width","22"),f(i,"height","22"),f(i,"viewBox","0 0 20 20"),f(i,"fill","none"),f(i,"xmlns","http://www.w3.org/2000/svg"),f(t,"href",Me),f(t,"target","_blank"),f(t,"class","altcha-logo"),f(t,"aria-label",u=r[9].ariaLinkLabel)},m(c,a){j(c,e,a),w(e,t),w(t,i),w(i,l),w(i,o),w(i,s)},p(c,a){a[0]&512&&u!==(u=c[9].ariaLinkLabel)&&f(t,"aria-label",u)},d(c){c&&T(e)}}}function Ae(r){let e,t,i,l;function o(c,a){return c[5]===m.EXPIRED?$t:Et}let s=o(r),u=s(r);return{c(){e=I("div"),t=Z("svg"),i=Z("path"),l=Y(),u.c(),f(i,"stroke-linecap","round"),f(i,"stroke-linejoin","round"),f(i,"d","M6 18L18 6M6 6l12 12"),f(t,"width","14"),f(t,"height","14"),f(t,"xmlns","http://www.w3.org/2000/svg"),f(t,"fill","none"),f(t,"viewBox","0 0 24 24"),f(t,"stroke-width","1.5"),f(t,"stroke","currentColor"),f(e,"class","altcha-error")},m(c,a){j(c,e,a),w(e,t),w(t,i),w(e,l),u.m(e,null)},p(c,a){s===(s=o(c))&&u?u.p(c,a):(u.d(1),u=s(c),u&&(u.c(),u.m(e,null)))},d(c){c&&T(e),u.d()}}}function Et(r){let e,t=r[9].error+"";return{c(){e=I("div"),f(e,"title",r[8])},m(i,l){j(i,e,l),e.innerHTML=t},p(i,l){l[0]&512&&t!==(t=i[9].error+"")&&(e.innerHTML=t),l[0]&256&&f(e,"title",i[8])},d(i){i&&T(e)}}}function $t(r){let e,t=r[9].expired+"";return{c(){e=I("div"),f(e,"title",r[8])},m(i,l){j(i,e,l),e.innerHTML=t},p(i,l){l[0]&512&&t!==(t=i[9].expired+"")&&(e.innerHTML=t),l[0]&256&&f(e,"title",i[8])},d(i){i&&T(e)}}}function Re(r){let e,t,i=r[9].footer+"";return{c(){e=I("div"),t=I("div"),f(e,"class","altcha-footer")},m(l,o){j(l,e,o),w(e,t),t.innerHTML=i},p(l,o){o[0]&512&&i!==(i=l[9].footer+"")&&(t.innerHTML=i)},d(l){l&&T(e)}}}function xt(r){let e,t,i,l,o,s,u,c,a,D,C,H,F,q,v=r[5]===m.VERIFYING&&Le();function J(d,A){return d[5]===m.VERIFIED?kt:d[5]===m.VERIFYING?vt:pt}let G=J(r),k=G(r),E=r[2]!==!0&&Ie(r),g=(r[8]||r[5]===m.EXPIRED)&&Ae(r),_=r[9].footer&&r[1]!==!0&&Re(r);return{c(){e=I("div"),t=I("div"),v&&v.c(),i=Y(),l=I("div"),o=I("input"),c=Y(),a=I("div"),k.c(),D=Y(),E&&E.c(),C=Y(),g&&g.c(),H=Y(),_&&_.c(),f(o,"type","checkbox"),f(o,"id",s=r[3]+"_checkbox"),o.required=u=r[0]!=="onsubmit",f(l,"class","altcha-checkbox"),ve(l,"altcha-hidden",r[5]===m.VERIFYING),f(a,"class","altcha-label"),f(t,"class","altcha-main"),f(e,"class","altcha"),f(e,"data-state",r[5])},m(d,A){j(d,e,A),w(e,t),v&&v.m(t,null),w(t,i),w(t,l),w(l,o),o.checked=r[6],w(t,c),w(t,a),k.m(a,null),w(t,D),E&&E.m(t,null),w(e,C),g&&g.m(e,null),w(e,H),_&&_.m(e,null),r[31](e),F||(q=[ue(o,"change",r[30]),ue(o,"change",r[10]),ue(o,"invalid",r[11])],F=!0)},p(d,A){d[5]===m.VERIFYING?v||(v=Le(),v.c(),v.m(t,i)):v&&(v.d(1),v=null),A[0]&8&&s!==(s=d[3]+"_checkbox")&&f(o,"id",s),A[0]&1&&u!==(u=d[0]!=="onsubmit")&&(o.required=u),A[0]&64&&(o.checked=d[6]),A[0]&32&&ve(l,"altcha-hidden",d[5]===m.VERIFYING),G===(G=J(d))&&k?k.p(d,A):(k.d(1),k=G(d),k&&(k.c(),k.m(a,null))),d[2]!==!0?E?E.p(d,A):(E=Ie(d),E.c(),E.m(t,null)):E&&(E.d(1),E=null),d[8]||d[5]===m.EXPIRED?g?g.p(d,A):(g=Ae(d),g.c(),g.m(e,H)):g&&(g.d(1),g=null),d[9].footer&&d[1]!==!0?_?_.p(d,A):(_=Re(d),_.c(),_.m(e,null)):_&&(_.d(1),_=null),A[0]&32&&f(e,"data-state",d[5])},i:P,o:P,d(d){d&&T(e),v&&v.d(),k.d(),E&&E.d(),g&&g.d(),_&&_.d(),r[31](null),F=!1,re(q)}}}const Te="Visit Altcha.org",Me="https://altcha.org/";function je(r){return JSON.parse(r)}function Ct(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Lt(r,e,t){var Ze,qe;let i,l,o,{auto:s=void 0}=e,{blockspam:u=void 0}=e,{challengeurl:c=void 0}=e,{challengejson:a=void 0}=e,{debug:D=!1}=e,{expire:C=void 0}=e,{hidefooter:H=!1}=e,{hidelogo:F=!1}=e,{name:q="altcha"}=e,{maxnumber:v=1e6}=e,{mockerror:J=!1}=e,{refetchonexpire:G=!0}=e,{spamfilter:k=!1}=e,{strings:E=void 0}=e,{test:g=!1}=e,{verifyurl:_=void 0}=e,{workers:d=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:A=void 0}=e;const be=nt(),Ne=["SHA-256","SHA-384","SHA-512"],De=(qe=(Ze=document.documentElement.lang)==null?void 0:Ze.split("-"))==null?void 0:qe[0];let X=!1,oe,b=null,_e=null,W=null,U=m.UNVERIFIED,B=null;rt(()=>{b&&(b.removeEventListener("submit",Oe),b.removeEventListener("reset",Pe),b.removeEventListener("focusin",Ve),b=null),B&&(clearTimeout(B),B=null)}),tt(()=>{L("mounted","0.4.3"),L("workers",d),g&&L("using test mode"),C&&se(C),s!==void 0&&L("auto",s),b=oe.closest("form"),b&&(b.addEventListener("submit",Oe),b.addEventListener("reset",Pe),s==="onfocus"&&b.addEventListener("focusin",Ve)),s==="onload"&&z()});function L(...n){(D||n.some(h=>h instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Ve(n){U===m.UNVERIFIED&&z()}function Oe(n){b&&s==="onsubmit"&&U===m.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),z().then(()=>{b==null||b.requestSubmit()}))}function Pe(){fe()}function He(n,h){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:h.number,salt:n.salt,signature:n.signature,test:g?!0:void 0,took:h.took}))}function Fe(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Ne.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ne.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function It(){var n;if(J)throw L("mocking error"),new Error("Mocked error.");if(i)return L("using provided json data"),i;if(g)return L("generating test challenge",{test:g}),wt(typeof g!="boolean"?+g:void 0);{if(!c)throw new Error("Attribute challengeurl not set.");L("fetching challenge from",c);const h=await fetch(c,{headers:{"x-altcha-spam-filter":k?"1":"0"}});if(h.status!==200)throw new Error(`Server responded with ${h.status}.`);const p=h.headers.get("Expires"),M=h.headers.get("X-Altcha-Config"),S=await h.json(),V=new URLSearchParams((n=S.salt.split("?"))==null?void 0:n[1]),K=V.get("expires")||V.get("expire");if(K){const $=new Date(+K*1e3),x=isNaN($.getTime())?0:$.getTime()-Date.now();x>0&&se(x)}if(M)try{const $=JSON.parse(M);$&&typeof $=="object"&&($.verifyurl&&($.verifyurl=new URL($.verifyurl,new URL(c)).toString()),Be($))}catch($){L("unable to configure from X-Altcha-Config",$)}if(!C&&(p!=null&&p.length)){const $=Date.parse(p);if($){const x=$-Date.now();x>0&&se(x)}}return S}}function Ue(){c&&G&&U===m.VERIFIED?z():fe(m.EXPIRED,o.expired)}async function At(n){let h=null;if("Worker"in window){try{h=await Rt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(p){L(p)}if((h==null?void 0:h.number)!==void 0)return{data:n,solution:h}}return{data:n,solution:await yt(n.challenge,n.salt,n.algorithm,n.maxnumber||v).promise}}async function Rt(n,h,p,M=typeof g=="number"?g:v,S=Math.ceil(d)){const V=[];if(S<1)throw new Error("Wrong number of workers configured.");if(S>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let x=0;x{const Ge=ce*K;return new Promise(Ot=>{x.addEventListener("message",Xe=>{if(Xe.data)for(const Ye of V)Ye!==x&&Ye.postMessage({type:"abort"});Ot(Xe.data)}),x.postMessage({payload:{alg:p,challenge:n,max:Ge+K,salt:h,start:Ge},type:"work"})})}));for(const x of V)x.terminate();return $.find(x=>!!x)||null}function Tt(){[m.UNVERIFIED,m.ERROR,m.EXPIRED].includes(U)?k&&(b==null?void 0:b.reportValidity())===!1?t(6,X=!1):z():t(6,X=!0)}function Mt(){U===m.VERIFYING&&alert(o.waitAlert)}function se(n){L("expire",n),B&&(clearTimeout(B),B=null),n<1?Ue():B=setTimeout(Ue,n)}function jt(n){var p;const h=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((p=h==null?void 0:h.value)==null?void 0:p.slice(h.value.indexOf("@")))||void 0}function St(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(p=>`input[name="${p}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((p,M)=>{const S=M.name,V=M.value.trim();return S&&V&&(p[S]=V),p},{})}async function Nt(n){if(!_)throw new Error("Attribute verifyurl not set.");L("requesting server verification from",_);const h={payload:n};if(k){const{email:S,expectedLanguages:V,expectedCountries:K,fields:$,ipAddress:x,timeZone:ce}=typeof k=="object"?k:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};h.ipAddress=x===!1?void 0:x||"auto",h.email=S===!1?void 0:jt(S),h.fields=$===!1?void 0:St($),h.timeZone=ce===!1?void 0:ce||Ct(),h.expectedCountries=K,h.expectedLanguages=V||(De?[De]:void 0)}const p=await fetch(_,{body:JSON.stringify(h),headers:{"content-type":"application/json"},method:"POST"});if(p.status!==200)throw new Error(`Server responded with ${p.status}.`);const M=await p.json();if(M!=null&&M.payload&&t(4,W=M.payload),be("serververification",M),u&&M.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Be(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&z()),n.expire!==void 0&&(se(n.expire),t(14,C=n.expire)),n.challenge&&(Fe(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(12,c=n.challengeurl),n.debug!==void 0&&t(13,D=!!n.debug),n.hidefooter!==void 0&&t(1,H=!!n.hidefooter),n.hidelogo!==void 0&&t(2,F=!!n.hidelogo),n.maxnumber!==void 0&&t(15,v=+n.maxnumber),n.mockerror!==void 0&&t(16,J=!!n.mockerror),n.name!==void 0&&t(3,q=n.name),n.refetchonexpire!==void 0&&t(17,G=!!n.refetchonexpire),n.spamfilter!==void 0&&t(18,k=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(29,l=n.strings),n.test!==void 0&&t(19,g=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(20,_=n.verifyurl),n.workers!==void 0&&t(21,d=+n.workers)}function fe(n=m.UNVERIFIED,h=null){B&&(clearTimeout(B),B=null),t(6,X=!1),t(8,_e=h),t(4,W=null),t(5,U=n)}async function z(){return fe(m.VERIFYING),It().then(n=>(Fe(n),L("challenge",n),At(n))).then(({data:n,solution:h})=>{if(L("solution",h),(h==null?void 0:h.number)!==void 0){if(_)return Nt(He(n,h));t(4,W=He(n,h)),L("payload",W)}else throw L("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{it().then(()=>{t(5,U=m.VERIFIED),t(6,X=!0),L("verified"),be("verified",{payload:W})})}).catch(n=>{L(n),t(5,U=m.ERROR),t(6,X=!1),t(8,_e=n.message)})}function Dt(){X=this.checked,t(6,X)}function Vt(n){he[n?"unshift":"push"](()=>{oe=n,t(7,oe)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(22,u=n.blockspam),"challengeurl"in n&&t(12,c=n.challengeurl),"challengejson"in n&&t(23,a=n.challengejson),"debug"in n&&t(13,D=n.debug),"expire"in n&&t(14,C=n.expire),"hidefooter"in n&&t(1,H=n.hidefooter),"hidelogo"in n&&t(2,F=n.hidelogo),"name"in n&&t(3,q=n.name),"maxnumber"in n&&t(15,v=n.maxnumber),"mockerror"in n&&t(16,J=n.mockerror),"refetchonexpire"in n&&t(17,G=n.refetchonexpire),"spamfilter"in n&&t(18,k=n.spamfilter),"strings"in n&&t(24,E=n.strings),"test"in n&&t(19,g=n.test),"verifyurl"in n&&t(20,_=n.verifyurl),"workers"in n&&t(21,d=n.workers),"workerurl"in n&&t(25,A=n.workerurl)},r.$$.update=()=>{r.$$.dirty[0]&8388608&&(i=a?je(a):void 0),r.$$.dirty[0]&16777216&&t(29,l=E?je(E):{}),r.$$.dirty[0]&536870912&&t(9,o={ariaLinkLabel:Te,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),r.$$.dirty[0]&48&&be("statechange",{payload:W,state:U})},[s,H,F,q,W,U,X,oe,_e,o,Tt,Mt,c,D,C,v,J,G,k,g,_,d,u,a,E,A,Be,fe,z,l,Dt,Vt]}class Se extends gt{constructor(e){super(),ht(this,e,Lt,xt,Je,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,workerurl:25,configure:26,reset:27,verify:28},null,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),y()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),y()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),y()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),y()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),y()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),y()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),y()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),y()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),y()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),y()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),y()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),y()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),y()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),y()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),y()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),y()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),y()}get workerurl(){return this.$$.ctx[25]}set workerurl(e){this.$$set({workerurl:e}),y()}get configure(){return this.$$.ctx[26]}get reset(){return this.$$.ctx[27]}get verify(){return this.$$.ctx[28]}}customElements.define("altcha-widget",dt(Se,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=r=>new Worker(new URL(r||"./worker.js",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:R&&R.src||new URL("altcha.umd.cjs",document.baseURI).href)),N.Altcha=Se,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}); diff --git a/dist_external/worker.js b/dist_external/worker.js new file mode 100644 index 0000000..eb5f2cc --- /dev/null +++ b/dist_external/worker.js @@ -0,0 +1 @@ +(function(){"use strict";const f=new TextEncoder;function d(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}async function p(e,t,o){return d(await crypto.subtle.digest(o.toUpperCase(),f.encode(e+t)))}function g(e,t,o="SHA-256",l=1e6,c=0){const a=new AbortController,i=Date.now();return{promise:(async()=>{for(let n=c;n<=l;n+=1){if(a.signal.aborted)return null;if(await p(t,n,o)===e)return{number:n,took:Date.now()-i}}return null})(),controller:a}}let r;onmessage=async e=>{const{type:t,payload:o}=e.data;if(t==="abort")r==null||r.abort(),r=void 0;else if(t==="work"){const{alg:l,challenge:c,max:a,salt:i,start:u}=o||{},n=g(c,i,l,a,u);r=n.controller,n.promise.then(s=>{self.postMessage(s&&{...s,worker:!0})})}}})(); diff --git a/package-lock.json b/package-lock.json index c2d577f..ad8c16d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "svelte-check": "^3.4.6", "tslib": "^2.6.0", "typescript": "^5.0.2", - "vite": "^5.1.4", + "vite": "^5.3.0", "vitest": "^0.34.6" } }, @@ -43,9 +43,9 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.2.tgz", - "integrity": "sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", "cpu": [ "ppc64" ], @@ -59,9 +59,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.2.tgz", - "integrity": "sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", "cpu": [ "arm" ], @@ -75,9 +75,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.2.tgz", - "integrity": "sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", "cpu": [ "arm64" ], @@ -91,9 +91,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.2.tgz", - "integrity": "sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", "cpu": [ "x64" ], @@ -107,9 +107,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.2.tgz", - "integrity": "sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", "cpu": [ "arm64" ], @@ -123,9 +123,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.2.tgz", - "integrity": "sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", "cpu": [ "x64" ], @@ -139,9 +139,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.2.tgz", - "integrity": "sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", "cpu": [ "arm64" ], @@ -155,9 +155,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.2.tgz", - "integrity": "sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", "cpu": [ "x64" ], @@ -171,9 +171,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.2.tgz", - "integrity": "sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", "cpu": [ "arm" ], @@ -187,9 +187,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.2.tgz", - "integrity": "sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", "cpu": [ "arm64" ], @@ -203,9 +203,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.2.tgz", - "integrity": "sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", "cpu": [ "ia32" ], @@ -219,9 +219,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.2.tgz", - "integrity": "sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", "cpu": [ "loong64" ], @@ -235,9 +235,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.2.tgz", - "integrity": "sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", "cpu": [ "mips64el" ], @@ -251,9 +251,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.2.tgz", - "integrity": "sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", "cpu": [ "ppc64" ], @@ -267,9 +267,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.2.tgz", - "integrity": "sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", "cpu": [ "riscv64" ], @@ -283,9 +283,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.2.tgz", - "integrity": "sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", "cpu": [ "s390x" ], @@ -299,9 +299,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.2.tgz", - "integrity": "sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", "cpu": [ "x64" ], @@ -315,9 +315,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.2.tgz", - "integrity": "sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", "cpu": [ "x64" ], @@ -331,9 +331,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.2.tgz", - "integrity": "sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", "cpu": [ "x64" ], @@ -347,9 +347,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.2.tgz", - "integrity": "sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", "cpu": [ "x64" ], @@ -363,9 +363,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.2.tgz", - "integrity": "sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", "cpu": [ "arm64" ], @@ -379,9 +379,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.2.tgz", - "integrity": "sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", "cpu": [ "ia32" ], @@ -395,9 +395,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.2.tgz", - "integrity": "sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", "cpu": [ "x64" ], @@ -1068,12 +1068,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -1413,9 +1413,9 @@ "dev": true }, "node_modules/esbuild": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz", - "integrity": "sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", "dev": true, "hasInstallScript": true, "bin": { @@ -1425,29 +1425,29 @@ "node": ">=12" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.20.2", - "@esbuild/android-arm": "0.20.2", - "@esbuild/android-arm64": "0.20.2", - "@esbuild/android-x64": "0.20.2", - "@esbuild/darwin-arm64": "0.20.2", - "@esbuild/darwin-x64": "0.20.2", - "@esbuild/freebsd-arm64": "0.20.2", - "@esbuild/freebsd-x64": "0.20.2", - "@esbuild/linux-arm": "0.20.2", - "@esbuild/linux-arm64": "0.20.2", - "@esbuild/linux-ia32": "0.20.2", - "@esbuild/linux-loong64": "0.20.2", - "@esbuild/linux-mips64el": "0.20.2", - "@esbuild/linux-ppc64": "0.20.2", - "@esbuild/linux-riscv64": "0.20.2", - "@esbuild/linux-s390x": "0.20.2", - "@esbuild/linux-x64": "0.20.2", - "@esbuild/netbsd-x64": "0.20.2", - "@esbuild/openbsd-x64": "0.20.2", - "@esbuild/sunos-x64": "0.20.2", - "@esbuild/win32-arm64": "0.20.2", - "@esbuild/win32-ia32": "0.20.2", - "@esbuild/win32-x64": "0.20.2" + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" } }, "node_modules/escape-html": { @@ -1557,9 +1557,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" @@ -3100,12 +3100,12 @@ } }, "node_modules/vite": { - "version": "5.2.9", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.9.tgz", - "integrity": "sha512-uOQWfuZBlc6Y3W/DTuQ1Sr+oIXWvqljLvS881SVmAj00d5RdgShLcuXWxseWPd4HXwiYBFW/vXHfKFeqj9uQnw==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.0.tgz", + "integrity": "sha512-hA6vAVK977NyW1Qw+fLvqSo7xDPej7von7C3DwwqPRmnnnK36XEBC/J3j1V5lP8fbt7y0TgTKJbpNGSwM+Bdeg==", "dev": true, "dependencies": { - "esbuild": "^0.20.1", + "esbuild": "^0.21.3", "postcss": "^8.4.38", "rollup": "^4.13.0" }, diff --git a/package.json b/package.json index 069d7db..661fbce 100644 --- a/package.json +++ b/package.json @@ -36,13 +36,19 @@ "require": "./dist/altcha.umd.cjs" }, "./altcha.css": { - "import": "./dist/altcha.css", - "require": "./dist/altcha.css" + "import": "./dist_external/altcha.css", + "require": "./dist_external/altcha.css" + }, + "./worker.js": { + "import": "./dist_external/worker.js", + "require": "./dist_external/worker.js" } }, "scripts": { "dev": "vite", - "build": "rimraf dist && vite build && echo \"declare module 'altcha';\" > dist/altcha.d.ts", + "build": "npm run build:bundle && npm run build:external", + "build:bundle": "rimraf dist && vite build && echo \"declare module 'altcha';\" > dist/altcha.d.ts", + "build:external": "rimraf dist_external && BUILD_EXTERNAL=1 vite build && echo \"declare module 'altcha';\" > dist_external/altcha.d.ts", "preview": "vite preview", "check": "svelte-check --tsconfig ./tsconfig.json", "format": "prettier --write ./src/**/*", @@ -67,7 +73,7 @@ "svelte-check": "^3.4.6", "tslib": "^2.6.0", "typescript": "^5.0.2", - "vite": "^5.1.4", + "vite": "^5.3.0", "vitest": "^0.34.6" } } diff --git a/src/Altcha.svelte b/src/Altcha.svelte index 6fbd807..4272653 100644 --- a/src/Altcha.svelte +++ b/src/Altcha.svelte @@ -11,7 +11,6 @@