diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..8e34625 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "es5", + "plugins": ["prettier-plugin-svelte"], + "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] +} \ No newline at end of file diff --git a/README.md b/README.md index f4b5745..c23e151 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,17 @@ Required options (at least one is required): Additional options: -- __auto__ - Automatically verify without user interaction (possible values: `onload`, `onsubmit`). +- __auto__ - Automatically verify without user interaction (possible values: `onfocus`, `onload`, `onsubmit`). +- __blockspam__ - Only used in conjunction with the `spamfilter` option. If enabled, it will block form submission and fail verification if the Spam Filter returns a negative classification. This effectively prevents submission of the form. - __expire__ - The challenge expiration (duration in milliseconds). - __hidefooter__ - Hide the footer (ALTCHA link). - __hidelogo__ - Hide the ALTCHA logo. - __maxnumber__ - The max. number to iterate to (defaults to 1,000,000). - __name__ - The name of the hidden field containing the payload (defaults to "altcha"). +- __spamfilter__ - Enable [Spam Filter](#spam-filter). - __strings__ - JSON-encoded translation strings. Refer to [customization](/docs/widget-customization). - __refetchonexpire__ - Automatically re-fetch and re-validate when the challenge expires (defaults to true). +- __verifyurl__ - Enable server-side verification by configuring the URL to use for verification requests. This option can be used in conjunction with `spamfilter` to enable server-side verification. - __workers__ - The number of workers to utilize for PoW (defaults to `navigator.hardwareConcurrency || 8`). Development / testing options: @@ -112,6 +115,7 @@ export interface Configure { mockerror?: boolean; name?: string; refetchonexpire?: boolean; + spamfilter: boolean | SpamFilter; strings?: { error?: string; footer?: string; @@ -121,12 +125,14 @@ export interface Configure { waitAlert?: string; }; test?: boolean; + verifyurl?: string; workers?: number; } ``` ## Events +- __serververification__ - Triggers upon a server verification (only in conjunction with `spamfilter`). - __statechange__ - Triggers whenever an internal `state` changes. - __verified__ - Triggers when the challenge is verified. @@ -152,6 +158,40 @@ document.querySelector('#altcha').addEventListener('statechange', (ev) => { > [!IMPORTANT] > Both programmatic configuration and event listeners have to called/attached after the ALTCHA script loads, such as within window.addEventListener('load', ...). +## Spam Filter + +The widget integrates with ALTCHA's [Spam Filter API](https://altcha.org/docs/api/spam-filter-api) to allow checking submitted form data for potential spam. + +The Spam Filter API analyzes various signals in the submitted data to determine if it exhibits characteristics of spam. This non-invasive filtering helps reduce spam submissions without frustrating legitimate users. + +### Spam Filter Configuration + +The Spam Filter can be enabled with default configuration by setting the `spamfilter` option to `true`, or it can be customized using the following configuration schema: + +```ts +interface SpamFilter { + email?: string | false; + expectedLanguages?: string[]; + expectedCountries?: string[]; + fields?: string[] | false; + ipAddress?: string | false; + timeZone?: string | false; +} +``` + +SpamFilter configuration options: + +- __email__ - The name of the input field for the user's email. Disable email checking with `false`. +- __expectedLanguages__ - An array of expected languages as 2-letter codes (ISO 639 alpha-2). +- __expectedCountries__ - An array of expected countries as 2-letter codes (ISO 3166-1 alpha-2). +- __fields__ - An array of input names to send to the spam filter. +- __ipAddress__ - The user's IP is detected automatically but can be overridden or disabled with `false`. +- __timeZone__ - The user's timezone is detected automatically but can be overridden or disabled with `false`. + +### Exclude Inputs from Spam Checking + +By default, all text inputs and textareas within the parent form are spam-checked. To exclude a specific input, add the `data-no-spamfilter` attribute. Alternatively, explicitly list the checked fields using the `fields` config option. + ## Contributing See [Contributing Guide](https://github.com/altcha-org/altcha/blob/main/CONTRIBUTING.md) and please follow our [Code of Conduct](https://github.com/altcha-org/altcha/blob/main/CODE_OF_CONDUCT.md). diff --git a/dist/altcha.iife.js b/dist/altcha.iife.js index 2f15ed2..a3e32a0 100644 --- a/dist/altcha.iife.js +++ b/dist/altcha.iife.js @@ -1 +1,2 @@ -var altcha=function(j){"use strict";var St=Object.defineProperty;var At=(j,L,P)=>L in j?St(j,L,{enumerable:!0,configurable:!0,writable:!0,value:P}):j[L]=P;var M=(j,L,P)=>(At(j,typeof L!="symbol"?L+"":L,P),P);function L(){}function P(t){return t()}function he(){return Object.create(null)}function K(t){t.forEach(P)}function de(t){return typeof t=="function"}function Ve(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Ze(t){return Object.keys(t).length===0}function b(t,e){t.appendChild(e)}function He(t,e,r){const i=Pe(t);if(!i.getElementById(e)){const o=w("style");o.id=e,o.textContent=r,Fe(i,o)}}function Pe(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Fe(t,e){return b(t.head||t,e),e.sheet}function I(t,e,r){t.insertBefore(e,r||null)}function R(t){t.parentNode&&t.parentNode.removeChild(t)}function w(t){return document.createElement(t)}function V(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Oe(t){return document.createTextNode(t)}function F(){return Oe(" ")}function ne(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 We(t){return Array.from(t.childNodes)}function ge(t,e,r){t.classList.toggle(e,!!r)}function De(t,e,{bubbles:r=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:r,cancelable:i})}function Be(t){const e={};return t.childNodes.forEach(r=>{e[r.slot||"default"]=!0}),e}let J;function z(t){J=t}function ie(){if(!J)throw new Error("Function called outside component initialization");return J}function Ye(t){ie().$$.on_mount.push(t)}function Ue(t){ie().$$.on_destroy.push(t)}function Xe(){const t=ie();return(e,r,{cancelable:i=!1}={})=>{const o=t.$$.callbacks[e];if(o){const l=De(e,r,{cancelable:i});return o.slice().forEach(s=>{s.call(t,l)}),!l.defaultPrevented}return!0}}const W=[],oe=[];let D=[];const be=[],me=Promise.resolve();let le=!1;function ve(){le||(le=!0,me.then(x))}function Ke(){return ve(),me}function se(t){D.push(t)}const ce=new Set;let B=0;function x(){if(B!==0)return;const t=J;do{try{for(;Bt.indexOf(i)===-1?e.push(i):r.push(i)),r.forEach(i=>i()),D=e}const Qe=new Set;function qe(t,e){t&&t.i&&(Qe.delete(t),t.i(e))}function et(t,e,r){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,r),se(()=>{const l=t.$$.on_mount.map(P).filter(de);t.$$.on_destroy?t.$$.on_destroy.push(...l):K(l),t.$$.on_mount=[]}),o.forEach(se)}function tt(t,e){const r=t.$$;r.fragment!==null&&(ze(r.after_update),K(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function rt(t,e){t.$$.dirty[0]===-1&&(W.push(t),ve(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const S=A.length?A[0]:N;return f.ctx&&o(f.ctx[m],f.ctx[m]=S)&&(!f.skip_bound&&f.bound[m]&&f.bound[m](S),p&&rt(t,m)),N}):[],f.update(),p=!0,K(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const m=We(e.target);f.fragment&&f.fragment.l(m),m.forEach(R)}else f.fragment&&f.fragment.c();e.intro&&qe(t.$$.fragment),et(t,e.target,e.anchor),x()}z(a)}let we;typeof HTMLElement=="function"&&(we=class extends HTMLElement{constructor(e,r,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=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=w("slot"),l!=="default"&&c(s,"name",l)},m:function(f,p){I(f,s,p)},d:function(f){f&&R(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const r={},i=Be(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]=Q(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=Q(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 u=this.$$c.$on(l,s);this.$$l_u.set(s,u)}this.$$l={}}}attributeChangedCallback(e,r,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Q(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 Q(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 it(t,e,r,i,o,l){let s=class extends we{constructor(){super(t,r,o),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(a){var f;a=Q(u,a,e),this.$$d[u]=a,(f=this.$$c)==null||f.$set({[u]:a})}})}),i.forEach(u=>{Object.defineProperty(s.prototype,u,{get(){var a;return(a=this.$$c)==null?void 0:a[u]}})}),l&&(s=l(s)),t.element=s,s}class ot{constructor(){M(this,"$$");M(this,"$$set")}$destroy(){tt(this,1),this.$destroy=L}$on(e,r){if(!de(r))return L;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&&!Ze(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const lt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(lt);const _e="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGcodCl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KHQpXS5tYXAoZT0+ZS50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBoKHQsZSxvKXtyZXR1cm4gZyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUodCtlKSkpfWZ1bmN0aW9uIG0odCxlLG89IlNIQS0yNTYiLGk9MWU2LHA9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyO3JldHVybntwcm9taXNlOm5ldyBQcm9taXNlKChzLGMpPT57Y29uc3Qgcj1EYXRlLm5vdygpLGQ9bD0+e2Euc2lnbmFsLmFib3J0ZWR8fGw+aT9zKG51bGwpOmgoZSxsLG8pLnRoZW4odz0+e3c9PT10P3Moe251bWJlcjpsLHRvb2s6RGF0ZS5ub3coKS1yfSk6ZChsKzEpfSkuY2F0Y2goYyl9O2QocCl9KSxjb250cm9sbGVyOmF9fWxldCBuO29ubWVzc2FnZT1hc3luYyB0PT57Y29uc3R7dHlwZTplLHBheWxvYWQ6b309dC5kYXRhO2lmKGU9PT0iYWJvcnQiKW49PW51bGx8fG4uYWJvcnQoKSxuPXZvaWQgMDtlbHNlIGlmKGU9PT0id29yayIpe2NvbnN0e2FsZzppLGNoYWxsZW5nZTpwLG1heDphLHNhbHQ6dSxzdGFydDpzfT1vfHx7fSxjPW0ocCx1LGksYSxzKTtuPWMuY29udHJvbGxlcixjLnByb21pc2UudGhlbihyPT57c2VsZi5wb3N0TWVzc2FnZShyJiZ7Li4ucix3b3JrZXI6ITB9KX0pfX19KSgpOwo=",st=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),pe=typeof window<"u"&&window.Blob&&new Blob([st(_e)],{type:"text/javascript;charset=utf-8"});function ct(t){let e;try{if(e=pe&&(window.URL||window.webkitURL).createObjectURL(pe),!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,"+_e,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const ut=new TextEncoder;function ft(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function at(t,e="SHA-256",r=1e5){const i=Date.now().toString(16);t||(t=Math.round(Math.random()*r));const o=await ye(i,t,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function ye(t,e,r){return ft(await crypto.subtle.digest(r.toUpperCase(),ut.encode(t+e)))}function ht(t,e,r="SHA-256",i=1e6,o=0){const l=new AbortController;return{promise:new Promise((u,a)=>{const f=Date.now(),p=m=>{l.signal.aborted||m>i?u(null):ye(e,m,r).then(N=>{N===t?u({number:m,took:Date.now()-f}):p(m+1)}).catch(a)};p(o)}),controller:l}}var g=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t.EXPIRED="expired",t))(g||{});function dt(t){He(t,"svelte-vuofbg",".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}")}function ke(t){let e,r,i;return{c(){e=V("svg"),r=V("path"),i=V("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-vuofbg"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){I(o,e,l),b(e,r),b(e,i)},d(o){o&&R(e)}}}function gt(t){let e,r=t[9].label+"",i;return{c(){e=w("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-vuofbg")},m(o,l){I(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&&R(e)}}}function bt(t){let e,r=t[9].verifying+"";return{c(){e=w("span")},m(i,o){I(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].verifying+"")&&(e.innerHTML=r)},d(i){i&&R(e)}}}function mt(t){let e,r=t[9].verified+"",i,o;return{c(){e=w("span"),i=F(),o=w("input"),c(o,"type","hidden"),c(o,"name",t[3]),o.value=t[4]},m(l,s){I(l,e,s),e.innerHTML=r,I(l,i,s),I(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&&(R(e),R(i),R(o))}}}function $e(t){let e,r,i,o,l,s;return{c(){e=w("div"),r=w("a"),i=V("svg"),o=V("path"),l=V("path"),s=V("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",Ce),c(r,"target","_blank"),c(r,"class","altcha-logo svelte-vuofbg")},m(u,a){I(u,e,a),b(e,r),b(r,i),b(i,o),b(i,l),b(i,s)},p:L,d(u){u&&R(e)}}}function Ee(t){let e,r,i,o;function l(a,f){return a[5]===g.EXPIRED?wt:vt}let s=l(t),u=s(t);return{c(){e=w("div"),r=V("svg"),i=V("path"),o=F(),u.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-vuofbg")},m(a,f){I(a,e,f),b(e,r),b(r,i),b(e,o),u.m(e,null)},p(a,f){s===(s=l(a))&&u?u.p(a,f):(u.d(1),u=s(a),u&&(u.c(),u.m(e,null)))},d(a){a&&R(e),u.d()}}}function vt(t){let e,r=t[9].error+"";return{c(){e=w("div"),c(e,"title",t[8])},m(i,o){I(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&&R(e)}}}function wt(t){let e,r=t[9].expired+"";return{c(){e=w("div"),c(e,"title",t[8])},m(i,o){I(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&&R(e)}}}function xe(t){let e,r,i=t[9].footer+"";return{c(){e=w("div"),r=w("div"),c(r,"class","svelte-vuofbg"),c(e,"class","altcha-footer svelte-vuofbg")},m(o,l){I(o,e,l),b(e,r),r.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(r.innerHTML=i)},d(o){o&&R(e)}}}function _t(t){let e,r,i,o,l,s,u,a,f,p,m,N,A,S,_=t[5]===g.VERIFYING&&ke();function O(h,E){return h[5]===g.VERIFIED?mt:h[5]===g.VERIFYING?bt:gt}let Z=O(t),y=Z(t),v=t[2]!==!0&&$e(),k=(t[8]||t[5]===g.EXPIRED)&&Ee(t),$=t[9].footer&&t[1]!==!0&&xe(t);return{c(){e=w("div"),r=w("div"),_&&_.c(),i=F(),o=w("div"),l=w("input"),a=F(),f=w("div"),y.c(),p=F(),v&&v.c(),m=F(),k&&k.c(),N=F(),$&&$.c(),c(l,"type","checkbox"),c(l,"id",s=t[3]+"_checkbox"),l.required=u=t[0]!=="onsubmit",c(l,"class","svelte-vuofbg"),c(o,"class","altcha-checkbox svelte-vuofbg"),ge(o,"altcha-hidden",t[5]===g.VERIFYING),c(f,"class","altcha-label svelte-vuofbg"),c(r,"class","altcha-main svelte-vuofbg"),c(e,"class","altcha svelte-vuofbg"),c(e,"data-state",t[5])},m(h,E){I(h,e,E),b(e,r),_&&_.m(r,null),b(r,i),b(r,o),b(o,l),l.checked=t[6],b(r,a),b(r,f),y.m(f,null),b(r,p),v&&v.m(r,null),b(e,m),k&&k.m(e,null),b(e,N),$&&$.m(e,null),t[27](e),A||(S=[ne(l,"change",t[26]),ne(l,"change",t[10]),ne(l,"invalid",t[11])],A=!0)},p(h,E){h[5]===g.VERIFYING?_||(_=ke(),_.c(),_.m(r,i)):_&&(_.d(1),_=null),E[0]&8&&s!==(s=h[3]+"_checkbox")&&c(l,"id",s),E[0]&1&&u!==(u=h[0]!=="onsubmit")&&(l.required=u),E[0]&64&&(l.checked=h[6]),E[0]&32&&ge(o,"altcha-hidden",h[5]===g.VERIFYING),Z===(Z=O(h))&&y?y.p(h,E):(y.d(1),y=Z(h),y&&(y.c(),y.m(f,null))),h[2]!==!0?v?v.p(h,E):(v=$e(),v.c(),v.m(r,null)):v&&(v.d(1),v=null),h[8]||h[5]===g.EXPIRED?k?k.p(h,E):(k=Ee(h),k.c(),k.m(e,N)):k&&(k.d(1),k=null),h[9].footer&&h[1]!==!0?$?$.p(h,E):($=xe(h),$.c(),$.m(e,null)):$&&($.d(1),$=null),E[0]&32&&c(e,"data-state",h[5])},i:L,o:L,d(h){h&&R(e),_&&_.d(),y.d(),v&&v.d(),k&&k.d(),$&&$.d(),t[27](null),A=!1,K(S)}}}const Ce="https://altcha.org/";function Le(t){return JSON.parse(t)}function pt(t,e,r){let i,o,l,{auto:s=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:a=void 0}=e,{debug:f=!1}=e,{expire:p=void 0}=e,{hidefooter:m=!1}=e,{hidelogo:N=!1}=e,{name:A="altcha"}=e,{maxnumber:S=1e6}=e,{mockerror:_=!1}=e,{refetchonexpire:O=!0}=e,{strings:Z=void 0}=e,{test:y=!1}=e,{workers:v=navigator.hardwareConcurrency||8}=e;const k=Xe(),$=["SHA-256","SHA-384","SHA-512"];let h=!1,E,T=null,ue=null,Y=null,H=g.UNVERIFIED,fe;Ue(()=>{T&&(T.removeEventListener("submit",Ie),T.removeEventListener("reset",Ne),T=null)}),Ye(()=>{C("mounted","0.2.3"),C("workers",v),y&&C("using test mode"),p&&ae(p),s!==void 0&&C("auto",s),T=E.closest("form"),T&&(T.addEventListener("submit",Ie),T.addEventListener("reset",Ne)),s==="onload"&&U()});function C(...n){(f||n.some(d=>d instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Ie(n){T&&s==="onsubmit"&&H===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),U().then(()=>{T==null||T.requestSubmit()}))}function Ne(){q()}function yt(n,d){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:d.number,salt:n.salt,signature:n.signature,test:y?!0:void 0,took:d.took}))}function Te(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(!$.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${$.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 kt(){if(_)throw C("mocking error"),new Error("Mocked error.");if(i)return C("using provided json data"),i;if(y)return C("generating test challenge"),at();{if(!u)throw new Error("Attribute challengeurl not set.");C("fetching challenge from",u);const n=await fetch(u);if(n.status!==200)throw new Error(`Server responded with ${n.status}.`);const d=n.headers.get("Expires");if(!p&&(d!=null&&d.length)){const X=Date.parse(d);if(X){const ee=X-Date.now();ee>0&&ae(ee)}}return n.json()}}function Me(){u&&O&&H===g.VERIFIED?U():q(g.EXPIRED,l.expired)}async function $t(n){let d=null;if("Worker"in window){try{d=await Et(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(X){C(X)}if((d==null?void 0:d.number)!==void 0)return{data:n,solution:d}}return{data:n,solution:await ht(n.challenge,n.salt,n.algorithm,n.maxnumber||S).promise}}async function Et(n,d,X,ee=S,te=Math.ceil(v)){const re=[];if(te<1)throw new Error("Wrong number of workers configured.");if(te>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let G=0;G{const Ae=Tt*Se;return new Promise(Mt=>{G.addEventListener("message",Ge=>{if(Ge.data)for(const je of re)je!==G&&je.postMessage({type:"abort"});Mt(Ge.data)}),G.postMessage({payload:{alg:X,challenge:n,max:Ae+Se,salt:d,start:Ae},type:"work"})})}));for(const G of re)G.terminate();return Nt.find(G=>!!G)||null}function xt(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(H)?U():r(6,h=!0)}function Ct(){H===g.VERIFYING&&alert(l.waitAlert)}function ae(n){C("expire",n),clearTimeout(fe),n<1?Me():fe=setTimeout(Me,n)}function Lt(n){n.auto!==void 0&&(r(0,s=n.auto),s==="onload"&&U()),n.expire!==void 0&&(ae(n.expire),r(13,p=n.expire)),n.challenge&&(Te(n.challenge),i=n.challenge),n.debug!==void 0&&r(12,f=!!n.debug),n.hidefooter!==void 0&&r(1,m=!!n.hidefooter),n.hidelogo!==void 0&&r(2,N=!!n.hidelogo),n.maxnumber!==void 0&&r(14,S=+n.maxnumber),n.mockerror!==void 0&&r(15,_=!!n.mockerror),n.name!==void 0&&r(3,A=n.name),n.refetchonexpire!==void 0&&r(16,O=!!n.refetchonexpire),n.strings&&r(25,o=n.strings),n.test!==void 0&&r(17,y=!!n.test),n.workers!==void 0&&r(18,v=+n.workers)}function q(n=g.UNVERIFIED,d=null){clearTimeout(fe),r(6,h=!1),r(8,ue=d),r(4,Y=null),r(5,H=n)}async function U(){return q(g.VERIFYING),kt().then(n=>(Te(n),C("challenge",n),$t(n))).then(({data:n,solution:d})=>{if(C("solution",d),(d==null?void 0:d.number)!==void 0)C("verified"),r(5,H=g.VERIFIED),r(6,h=!0),r(4,Y=yt(n,d)),C("payload",Y),Ke().then(()=>{k("verified",{payload:Y})});else throw C("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).catch(n=>{C(n),r(5,H=g.ERROR),r(6,h=!1),r(8,ue=n.message)})}function Rt(){h=this.checked,r(6,h)}function It(n){oe[n?"unshift":"push"](()=>{E=n,r(7,E)})}return t.$$set=n=>{"auto"in n&&r(0,s=n.auto),"challengeurl"in n&&r(19,u=n.challengeurl),"challengejson"in n&&r(20,a=n.challengejson),"debug"in n&&r(12,f=n.debug),"expire"in n&&r(13,p=n.expire),"hidefooter"in n&&r(1,m=n.hidefooter),"hidelogo"in n&&r(2,N=n.hidelogo),"name"in n&&r(3,A=n.name),"maxnumber"in n&&r(14,S=n.maxnumber),"mockerror"in n&&r(15,_=n.mockerror),"refetchonexpire"in n&&r(16,O=n.refetchonexpire),"strings"in n&&r(21,Z=n.strings),"test"in n&&r(17,y=n.test),"workers"in n&&r(18,v=n.workers)},t.$$.update=()=>{t.$$.dirty[0]&1048576&&(i=a?Le(a):void 0),t.$$.dirty[0]&2097152&&r(25,o=Z?Le(Z):{}),t.$$.dirty[0]&33554432&&r(9,l={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&&k("statechange",{payload:Y,state:H})},[s,m,N,A,Y,H,h,E,ue,l,xt,Ct,f,p,S,_,O,y,v,u,a,Z,Lt,q,U,o,Rt,It]}class Re extends ot{constructor(e){super(),nt(this,e,pt,_t,Ve,{auto:0,challengeurl:19,challengejson:20,debug:12,expire:13,hidefooter:1,hidelogo:2,name:3,maxnumber:14,mockerror:15,refetchonexpire:16,strings:21,test:17,workers:18,configure:22,reset:23,verify:24},dt,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),x()}get challengeurl(){return this.$$.ctx[19]}set challengeurl(e){this.$$set({challengeurl:e}),x()}get challengejson(){return this.$$.ctx[20]}set challengejson(e){this.$$set({challengejson:e}),x()}get debug(){return this.$$.ctx[12]}set debug(e){this.$$set({debug:e}),x()}get expire(){return this.$$.ctx[13]}set expire(e){this.$$set({expire:e}),x()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),x()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),x()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),x()}get maxnumber(){return this.$$.ctx[14]}set maxnumber(e){this.$$set({maxnumber:e}),x()}get mockerror(){return this.$$.ctx[15]}set mockerror(e){this.$$set({mockerror:e}),x()}get refetchonexpire(){return this.$$.ctx[16]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),x()}get strings(){return this.$$.ctx[21]}set strings(e){this.$$set({strings:e}),x()}get test(){return this.$$.ctx[17]}set test(e){this.$$set({test:e}),x()}get workers(){return this.$$.ctx[18]}set workers(e){this.$$set({workers:e}),x()}get configure(){return this.$$.ctx[22]}get reset(){return this.$$.ctx[23]}get verify(){return this.$$.ctx[24]}}return customElements.define("altcha-widget",it(Re,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},strings:{},test:{type:"Boolean"},workers:{}},[],["configure","reset","verify"],!1)),j.Altcha=Re,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),j}({}); +var altcha=function(V){"use strict";var Wt=Object.defineProperty;var Bt=(V,S,W)=>S in V?Wt(V,S,{enumerable:!0,configurable:!0,writable:!0,value:W}):V[S]=W;var Z=(V,S,W)=>(Bt(V,typeof S!="symbol"?S+"":S,W),W);function S(){}function W(n){return n()}function pe(){return Object.create(null)}function q(n){n.forEach(W)}function ye(n){return typeof n=="function"}function Xe(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Ke(n){return Object.keys(n).length===0}function w(n,e){n.appendChild(e)}function Je(n,e,t){const i=ze(n);if(!i.getElementById(e)){const l=$("style");l.id=e,l.textContent=t,Qe(i,l)}}function ze(n){if(!n)return document;const e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Qe(n,e){return w(n.head||n,e),e.sheet}function T(n,e,t){n.insertBefore(e,t||null)}function N(n){n.parentNode&&n.parentNode.removeChild(n)}function $(n){return document.createElement(n)}function O(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function qe(n){return document.createTextNode(n)}function U(){return qe(" ")}function ce(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function c(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function et(n){return Array.from(n.childNodes)}function ve(n,e,t){n.classList.toggle(e,!!t)}function tt(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function nt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ee;function te(n){ee=n}function ae(){if(!ee)throw new Error("Function called outside component initialization");return ee}function rt(n){ae().$$.on_mount.push(n)}function it(n){ae().$$.on_destroy.push(n)}function lt(){const n=ae();return(e,t,{cancelable:i=!1}={})=>{const l=n.$$.callbacks[e];if(l){const o=tt(e,t,{cancelable:i});return l.slice().forEach(s=>{s.call(n,o)}),!o.defaultPrevented}return!0}}const J=[],fe=[];let z=[];const we=[],_e=Promise.resolve();let ue=!1;function ke(){ue||(ue=!0,_e.then(_))}function ot(){return ke(),_e}function he(n){z.push(n)}const de=new Set;let Q=0;function _(){if(Q!==0)return;const n=ee;do{try{for(;Qn.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),z=e}const at=new Set;function ft(n,e){n&&n.i&&(at.delete(n),n.i(e))}function ut(n,e,t){const{fragment:i,after_update:l}=n.$$;i&&i.m(e,t),he(()=>{const o=n.$$.on_mount.map(W).filter(ye);n.$$.on_destroy?n.$$.on_destroy.push(...o):q(o),n.$$.on_mount=[]}),l.forEach(he)}function ht(n,e){const t=n.$$;t.fragment!==null&&(ct(t.after_update),q(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function dt(n,e){n.$$.dirty[0]===-1&&(J.push(n),ke(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const H=G.length?G[0]:M;return f.ctx&&l(f.ctx[g],f.ctx[g]=H)&&(!f.skip_bound&&f.bound[g]&&f.bound[g](H),R&&dt(n,g)),M}):[],f.update(),R=!0,q(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const g=et(e.target);f.fragment&&f.fragment.l(g),g.forEach(N)}else f.fragment&&f.fragment.c();e.intro&&ft(n.$$.fragment),ut(n,e.target,e.anchor),_()}te(u)}let xe;typeof HTMLElement=="function"&&(xe=class extends HTMLElement{constructor(e,t,i){super();Z(this,"$$ctor");Z(this,"$$s");Z(this,"$$c");Z(this,"$$cn",!1);Z(this,"$$d",{});Z(this,"$$r",!1);Z(this,"$$p_d",{});Z(this,"$$l",{});Z(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=$("slot"),o!=="default"&&c(s,"name",o)},m:function(f,R){T(f,s,R)},d:function(f){f&&N(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=nt(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]=ne(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=ne(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 a=this.$$c.$on(o,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,t,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=ne(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 ne(n,e,t,i){var o;const l=(o=t[n])==null?void 0:o.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])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 mt(n,e,t,i,l,o){let s=class extends xe{constructor(){super(n,t,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(u){var f;u=ne(a,u,e),this.$$d[a]=u,(f=this.$$c)==null||f.$set({[a]:u})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var u;return(u=this.$$c)==null?void 0:u[a]}})}),o&&(s=o(s)),n.element=s,s}class bt{constructor(){Z(this,"$$");Z(this,"$$set")}$destroy(){ht(this,1),this.$destroy=S}$on(e,t){if(!ye(t))return S;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&&!Ke(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 Ee="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGcodCl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KHQpXS5tYXAoZT0+ZS50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBoKHQsZSxvKXtyZXR1cm4gZyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUodCtlKSkpfWZ1bmN0aW9uIG0odCxlLG89IlNIQS0yNTYiLGk9MWU2LHA9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyO3JldHVybntwcm9taXNlOm5ldyBQcm9taXNlKChzLGMpPT57Y29uc3Qgcj1EYXRlLm5vdygpLGQ9bD0+e2Euc2lnbmFsLmFib3J0ZWR8fGw+aT9zKG51bGwpOmgoZSxsLG8pLnRoZW4odz0+e3c9PT10P3Moe251bWJlcjpsLHRvb2s6RGF0ZS5ub3coKS1yfSk6ZChsKzEpfSkuY2F0Y2goYyl9O2QocCl9KSxjb250cm9sbGVyOmF9fWxldCBuO29ubWVzc2FnZT1hc3luYyB0PT57Y29uc3R7dHlwZTplLHBheWxvYWQ6b309dC5kYXRhO2lmKGU9PT0iYWJvcnQiKW49PW51bGx8fG4uYWJvcnQoKSxuPXZvaWQgMDtlbHNlIGlmKGU9PT0id29yayIpe2NvbnN0e2FsZzppLGNoYWxsZW5nZTpwLG1heDphLHNhbHQ6dSxzdGFydDpzfT1vfHx7fSxjPW0ocCx1LGksYSxzKTtuPWMuY29udHJvbGxlcixjLnByb21pc2UudGhlbihyPT57c2VsZi5wb3N0TWVzc2FnZShyJiZ7Li4ucix3b3JrZXI6ITB9KX0pfX19KSgpOwo=",yt=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),$e=typeof window<"u"&&window.Blob&&new Blob([yt(Ee)],{type:"text/javascript;charset=utf-8"});function vt(n){let e;try{if(e=$e&&(window.URL||window.webkitURL).createObjectURL($e),!e)throw"";const t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Ee,{name:n==null?void 0:n.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const wt=new TextEncoder;function _t(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function kt(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const l=await Ce(i,n,e);return{algorithm:e,challenge:l,salt:i,signature:""}}async function Ce(n,e,t){return _t(await crypto.subtle.digest(t.toUpperCase(),wt.encode(n+e)))}function xt(n,e,t="SHA-256",i=1e6,l=0){const o=new AbortController;return{promise:new Promise((a,u)=>{const f=Date.now(),R=g=>{o.signal.aborted||g>i?a(null):Ce(e,g,t).then(M=>{M===n?a({number:g,took:Date.now()-f}):R(g+1)}).catch(u)};R(l)}),controller:o}}var y=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(y||{});function Et(n){Je(n,"svelte-14ngypa",`.altcha.svelte-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-14ngypa.svelte-14ngypa{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-14ngypa.svelte-14ngypa{flex-grow:1}.altcha-label.svelte-14ngypa label.svelte-14ngypa{cursor:pointer}.altcha-logo.svelte-14ngypa.svelte-14ngypa{color:currentColor;opacity:0.3}.altcha-logo.svelte-14ngypa.svelte-14ngypa:hover{opacity:1}.altcha-error.svelte-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa:hover{opacity:1}.altcha-footer.svelte-14ngypa>.svelte-14ngypa:first-child{flex-grow:1}.altcha-footer.svelte-14ngypa a{color:currentColor}.altcha-checkbox.svelte-14ngypa.svelte-14ngypa{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-14ngypa input.svelte-14ngypa{width:18px;height:18px;margin:0}.altcha-hidden.svelte-14ngypa.svelte-14ngypa{display:none}.altcha-spinner.svelte-14ngypa.svelte-14ngypa{animation:svelte-14ngypa-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-14ngypa-altcha-spinner{100%{transform:rotate(360deg)}}`)}function Le(n){let e,t,i;return{c(){e=O("svg"),t=O("path"),i=O("path"),c(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(t,"fill","currentColor"),c(t,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-14ngypa"),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&&N(e)}}}function $t(n){let e,t=n[9].label+"",i;return{c(){e=$("label"),c(e,"for",i=n[3]+"_checkbox"),c(e,"class","svelte-14ngypa")},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&&N(e)}}}function Ct(n){let e,t=n[9].verifying+"";return{c(){e=$("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&&N(e)}}}function Lt(n){let e,t=n[9].verified+"",i,l;return{c(){e=$("span"),i=U(),l=$("input"),c(l,"type","hidden"),c(l,"name",n[3]),l.value=n[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&&(N(e),N(i),N(l))}}}function Ie(n){let e,t,i,l,o,s;return{c(){e=$("div"),t=$("a"),i=O("svg"),l=O("path"),o=O("path"),s=O("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",Ne),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-14ngypa")},m(a,u){T(a,e,u),w(e,t),w(t,i),w(i,l),w(i,o),w(i,s)},p:S,d(a){a&&N(e)}}}function Re(n){let e,t,i,l;function o(u,f){return u[5]===y.EXPIRED?Rt:It}let s=o(n),a=s(n);return{c(){e=$("div"),t=O("svg"),i=O("path"),l=U(),a.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-14ngypa")},m(u,f){T(u,e,f),w(e,t),w(t,i),w(e,l),a.m(e,null)},p(u,f){s===(s=o(u))&&a?a.p(u,f):(a.d(1),a=s(u),a&&(a.c(),a.m(e,null)))},d(u){u&&N(e),a.d()}}}function It(n){let e,t=n[9].error+"";return{c(){e=$("div"),c(e,"title",n[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&&N(e)}}}function Rt(n){let e,t=n[9].expired+"";return{c(){e=$("div"),c(e,"title",n[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&&N(e)}}}function Se(n){let e,t,i=n[9].footer+"";return{c(){e=$("div"),t=$("div"),c(t,"class","svelte-14ngypa"),c(e,"class","altcha-footer svelte-14ngypa")},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&&N(e)}}}function St(n){let e,t,i,l,o,s,a,u,f,R,g,M,G,H,k=n[5]===y.VERIFYING&&Le();function Y(d,I){return d[5]===y.VERIFIED?Lt:d[5]===y.VERIFYING?Ct:$t}let P=Y(n),x=P(n),E=n[2]!==!0&&Ie(),m=(n[8]||n[5]===y.EXPIRED)&&Re(n),v=n[9].footer&&n[1]!==!0&&Se(n);return{c(){e=$("div"),t=$("div"),k&&k.c(),i=U(),l=$("div"),o=$("input"),u=U(),f=$("div"),x.c(),R=U(),E&&E.c(),g=U(),m&&m.c(),M=U(),v&&v.c(),c(o,"type","checkbox"),c(o,"id",s=n[3]+"_checkbox"),o.required=a=n[0]!=="onsubmit",c(o,"class","svelte-14ngypa"),c(l,"class","altcha-checkbox svelte-14ngypa"),ve(l,"altcha-hidden",n[5]===y.VERIFYING),c(f,"class","altcha-label svelte-14ngypa"),c(t,"class","altcha-main svelte-14ngypa"),c(e,"class","altcha svelte-14ngypa"),c(e,"data-state",n[5])},m(d,I){T(d,e,I),w(e,t),k&&k.m(t,null),w(t,i),w(t,l),w(l,o),o.checked=n[6],w(t,u),w(t,f),x.m(f,null),w(t,R),E&&E.m(t,null),w(e,g),m&&m.m(e,null),w(e,M),v&&v.m(e,null),n[30](e),G||(H=[ce(o,"change",n[29]),ce(o,"change",n[10]),ce(o,"invalid",n[11])],G=!0)},p(d,I){d[5]===y.VERIFYING?k||(k=Le(),k.c(),k.m(t,i)):k&&(k.d(1),k=null),I[0]&8&&s!==(s=d[3]+"_checkbox")&&c(o,"id",s),I[0]&1&&a!==(a=d[0]!=="onsubmit")&&(o.required=a),I[0]&64&&(o.checked=d[6]),I[0]&32&&ve(l,"altcha-hidden",d[5]===y.VERIFYING),P===(P=Y(d))&&x?x.p(d,I):(x.d(1),x=P(d),x&&(x.c(),x.m(f,null))),d[2]!==!0?E?E.p(d,I):(E=Ie(),E.c(),E.m(t,null)):E&&(E.d(1),E=null),d[8]||d[5]===y.EXPIRED?m?m.p(d,I):(m=Re(d),m.c(),m.m(e,M)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?v?v.p(d,I):(v=Se(d),v.c(),v.m(e,null)):v&&(v.d(1),v=null),I[0]&32&&c(e,"data-state",d[5])},i:S,o:S,d(d){d&&N(e),k&&k.d(),x.d(),E&&E.d(),m&&m.d(),v&&v.d(),n[30](null),G=!1,q(H)}}}const Ne="https://altcha.org/";function Te(n){return JSON.parse(n)}function Nt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Tt(n,e,t){var Fe,We;let i,l,o,{auto:s=void 0}=e,{blockspam:a=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:f=void 0}=e,{debug:R=!1}=e,{expire:g=void 0}=e,{hidefooter:M=!1}=e,{hidelogo:G=!1}=e,{name:H="altcha"}=e,{maxnumber:k=1e6}=e,{mockerror:Y=!1}=e,{refetchonexpire:P=!0}=e,{spamfilter:x=!1}=e,{strings:E=void 0}=e,{test:m=!1}=e,{verifyurl:v=void 0}=e,{workers:d=navigator.hardwareConcurrency||8}=e;const I=lt(),je=["SHA-256","SHA-384","SHA-512"],Me=(We=(Fe=document.documentElement.lang)==null?void 0:Fe.split("-"))==null?void 0:We[0];let B=!1,re,b=null,ge=null,X=null,D=y.UNVERIFIED,me;it(()=>{b&&(b.removeEventListener("submit",Ge),b.removeEventListener("reset",Ve),b.removeEventListener("focusin",Ze),b=null)}),rt(()=>{C("mounted","0.2.3"),C("workers",d),m&&C("using test mode"),g&&be(g),s!==void 0&&C("auto",s),b=re.closest("form"),b&&(b.addEventListener("submit",Ge),b.addEventListener("reset",Ve),s==="onfocus"&&b.addEventListener("focusin",Ze)),s==="onload"&&K()});function C(...r){(R||r.some(h=>h instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",...r)}function Ze(r){K()}function Ge(r){b&&s==="onsubmit"&&D===y.UNVERIFIED&&(r.preventDefault(),r.stopPropagation(),K().then(()=>{b==null||b.requestSubmit()}))}function Ve(){ie()}function Oe(r,h){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:h.number,salt:r.salt,signature:r.signature,test:m?!0:void 0,took:h.took}))}function He(r){if(!r.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(r.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!je.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${je.join(", ")}`);if(!r.challenge||r.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!r.salt||r.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function At(){if(Y)throw C("mocking error"),new Error("Mocked error.");if(i)return C("using provided json data"),i;if(m)return C("generating test challenge"),kt(typeof m!="boolean"?+m:void 0);{if(!u)throw new Error("Attribute challengeurl not set.");C("fetching challenge from",u);const r=await fetch(u,{headers:{"x-altcha-spam-filter":x?"1":"0"}});if(r.status!==200)throw new Error(`Server responded with ${r.status}.`);const h=r.headers.get("Expires"),L=r.headers.get("X-Altcha-Config");if(L)try{const p=JSON.parse(L);p&&typeof p=="object"&&(p.verifyurl&&(p.verifyurl=new URL(p.verifyurl,new URL(u)).toString()),De(p))}catch(p){C("unable to configure from X-Altcha-Config",p)}if(!g&&(h!=null&&h.length)){const p=Date.parse(h);if(p){const A=p-Date.now();A>0&&be(A)}}return r.json()}}function Pe(){u&&P&&D===y.VERIFIED?K():ie(y.EXPIRED,o.expired)}async function jt(r){let h=null;if("Worker"in window){try{h=await Mt(r.challenge,r.salt,r.algorithm,r.maxnumber)}catch(L){C(L)}if((h==null?void 0:h.number)!==void 0)return{data:r,solution:h}}return{data:r,solution:await xt(r.challenge,r.salt,r.algorithm,r.maxnumber||k).promise}}async function Mt(r,h,L,p=k,A=Math.ceil(d)){const F=[];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 j=0;j{const Be=se*le;return new Promise(Ft=>{j.addEventListener("message",Ue=>{if(Ue.data)for(const Ye of F)Ye!==j&&Ye.postMessage({type:"abort"});Ft(Ue.data)}),j.postMessage({payload:{alg:L,challenge:r,max:Be+le,salt:h,start:Be},type:"work"})})}));for(const j of F)j.terminate();return oe.find(j=>!!j)||null}function Zt(){[y.UNVERIFIED,y.ERROR,y.EXPIRED].includes(D)?x&&(b==null?void 0:b.reportValidity())===!1?t(6,B=!1):K():t(6,B=!0)}function Gt(){D===y.VERIFYING&&alert(o.waitAlert)}function be(r){C("expire",r),clearTimeout(me),r<1?Pe():me=setTimeout(Pe,r)}function Vt(r){var L;const h=b==null?void 0:b.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((L=h==null?void 0:h.value)==null?void 0:L.slice(h.value.indexOf("@")))||void 0}function Ot(r){return[...(b==null?void 0:b.querySelectorAll(r!=null&&r.length?r.map(L=>`input[name="${L}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((L,p)=>{const A=p.name,F=p.value.trim();return A&&F&&(L[A]=F),L},{})}async function Ht(r){if(!v)throw new Error("Attribute verifyurl not set.");C("requesting server verification from",v);const h={payload:r};if(x){const{email:A,expectedLanguages:F,expectedCountries:le,fields:oe,ipAddress:j,timeZone:se}=typeof x=="object"?x:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};h.ipAddress=j===!1?void 0:j||"auto",h.email=A===!1?void 0:Vt(A),h.fields=oe===!1?void 0:Ot(oe),h.timeZone=se===!1?void 0:se||Nt(),h.expectedCountries=le,h.expectedLanguages=F||(Me?[Me]:void 0)}const L=await fetch(v,{body:JSON.stringify(h),headers:{"content-type":"application/json"},method:"POST"});if(L.status!==200)throw new Error(`Server responded with ${L.status}.`);const p=await L.json();if(p!=null&&p.payload&&t(4,X=p.payload),I("serververification",p),a&&p.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function De(r){r.auto!==void 0&&(t(0,s=r.auto),s==="onload"&&K()),r.expire!==void 0&&(be(r.expire),t(13,g=r.expire)),r.challenge&&(He(r.challenge),i=r.challenge),r.debug!==void 0&&t(12,R=!!r.debug),r.hidefooter!==void 0&&t(1,M=!!r.hidefooter),r.hidelogo!==void 0&&t(2,G=!!r.hidelogo),r.maxnumber!==void 0&&t(14,k=+r.maxnumber),r.mockerror!==void 0&&t(15,Y=!!r.mockerror),r.name!==void 0&&t(3,H=r.name),r.refetchonexpire!==void 0&&t(16,P=!!r.refetchonexpire),r.spamfilter!==void 0&&t(17,x=r.spamfilter),r.strings&&t(28,l=r.strings),r.test!==void 0&&t(18,m=!!r.test),r.verifyurl!==void 0&&t(19,v=r.verifyurl),r.workers!==void 0&&t(20,d=+r.workers)}function ie(r=y.UNVERIFIED,h=null){clearTimeout(me),t(6,B=!1),t(8,ge=h),t(4,X=null),t(5,D=r)}async function K(){return ie(y.VERIFYING),At().then(r=>(He(r),C("challenge",r),jt(r))).then(({data:r,solution:h})=>{if(C("solution",h),(h==null?void 0:h.number)!==void 0){if(v)return Ht(Oe(r,h));t(4,X=Oe(r,h)),C("payload",X)}else throw C("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{ot().then(()=>{t(5,D=y.VERIFIED),t(6,B=!0),C("verified"),I("verified",{payload:X})})}).catch(r=>{C(r),t(5,D=y.ERROR),t(6,B=!1),t(8,ge=r.message)})}function Pt(){B=this.checked,t(6,B)}function Dt(r){fe[r?"unshift":"push"](()=>{re=r,t(7,re)})}return n.$$set=r=>{"auto"in r&&t(0,s=r.auto),"blockspam"in r&&t(21,a=r.blockspam),"challengeurl"in r&&t(22,u=r.challengeurl),"challengejson"in r&&t(23,f=r.challengejson),"debug"in r&&t(12,R=r.debug),"expire"in r&&t(13,g=r.expire),"hidefooter"in r&&t(1,M=r.hidefooter),"hidelogo"in r&&t(2,G=r.hidelogo),"name"in r&&t(3,H=r.name),"maxnumber"in r&&t(14,k=r.maxnumber),"mockerror"in r&&t(15,Y=r.mockerror),"refetchonexpire"in r&&t(16,P=r.refetchonexpire),"spamfilter"in r&&t(17,x=r.spamfilter),"strings"in r&&t(24,E=r.strings),"test"in r&&t(18,m=r.test),"verifyurl"in r&&t(19,v=r.verifyurl),"workers"in r&&t(20,d=r.workers)},n.$$.update=()=>{n.$$.dirty[0]&8388608&&(i=f?Te(f):void 0),n.$$.dirty[0]&16777216&&t(28,l=E?Te(E):{}),n.$$.dirty[0]&268435456&&t(9,o={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}),n.$$.dirty[0]&48&&I("statechange",{payload:X,state:D})},[s,M,G,H,X,D,B,re,ge,o,Zt,Gt,R,g,k,Y,P,x,m,v,d,a,u,f,E,De,ie,K,l,Pt,Dt]}class Ae extends bt{constructor(e){super(),gt(this,e,Tt,St,Xe,{auto:0,blockspam:21,challengeurl:22,challengejson:23,debug:12,expire:13,hidefooter:1,hidelogo:2,name:3,maxnumber:14,mockerror:15,refetchonexpire:16,spamfilter:17,strings:24,test:18,verifyurl:19,workers:20,configure:25,reset:26,verify:27},Et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),_()}get blockspam(){return this.$$.ctx[21]}set blockspam(e){this.$$set({blockspam:e}),_()}get challengeurl(){return this.$$.ctx[22]}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[12]}set debug(e){this.$$set({debug:e}),_()}get expire(){return this.$$.ctx[13]}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[14]}set maxnumber(e){this.$$set({maxnumber:e}),_()}get mockerror(){return this.$$.ctx[15]}set mockerror(e){this.$$set({mockerror:e}),_()}get refetchonexpire(){return this.$$.ctx[16]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),_()}get spamfilter(){return this.$$.ctx[17]}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[18]}set test(e){this.$$set({test:e}),_()}get verifyurl(){return this.$$.ctx[19]}set verifyurl(e){this.$$set({verifyurl:e}),_()}get workers(){return this.$$.ctx[20]}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",mt(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)),V.Altcha=Ae,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),V}({}); diff --git a/dist/altcha.js b/dist/altcha.js index ded939c..156948e 100644 --- a/dist/altcha.js +++ b/dist/altcha.js @@ -1,344 +1,344 @@ -var Ue = Object.defineProperty; -var Xe = (t, e, r) => e in t ? Ue(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; -var T = (t, e, r) => (Xe(t, typeof e != "symbol" ? e + "" : e, r), r); -function Y() { +var rt = Object.defineProperty; +var it = (n, e, t) => e in n ? rt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; +var M = (n, e, t) => (it(n, typeof e != "symbol" ? e + "" : e, t), t); +function J() { } -function Le(t) { - return t(); +function Ve(n) { + return n(); } -function we() { +function Re() { return /* @__PURE__ */ Object.create(null); } -function K(t) { - t.forEach(Le); +function q(n) { + n.forEach(Ve); } -function Re(t) { - return typeof t == "function"; +function Oe(n) { + return typeof n == "function"; } -function Ke(t, e) { - return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function"; +function lt(n, e) { + return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function"; } -function Je(t) { - return Object.keys(t).length === 0; +function ot(n) { + return Object.keys(n).length === 0; } -function b(t, e) { - t.appendChild(e); +function w(n, e) { + n.appendChild(e); } -function ze(t, e, r) { - const i = Qe(t); +function st(n, e, t) { + const i = ct(n); if (!i.getElementById(e)) { - const o = _("style"); - o.id = e, o.textContent = r, qe(i, o); + const l = L("style"); + l.id = e, l.textContent = t, at(i, l); } } -function Qe(t) { - if (!t) +function ct(n) { + if (!n) return document; - const e = t.getRootNode ? t.getRootNode() : t.ownerDocument; + const e = n.getRootNode ? n.getRootNode() : n.ownerDocument; return e && /** @type {ShadowRoot} */ e.host ? ( /** @type {ShadowRoot} */ e - ) : t.ownerDocument; + ) : n.ownerDocument; } -function qe(t, e) { - return b( +function at(n, e) { + return w( /** @type {Document} */ - t.head || t, + n.head || n, e ), e.sheet; } -function R(t, e, r) { - t.insertBefore(e, r || null); +function A(n, e, t) { + n.insertBefore(e, t || null); } -function L(t) { - t.parentNode && t.parentNode.removeChild(t); +function N(n) { + n.parentNode && n.parentNode.removeChild(n); } -function _(t) { - return document.createElement(t); +function L(n) { + return document.createElement(n); } -function V(t) { - return document.createElementNS("http://www.w3.org/2000/svg", t); +function P(n) { + return document.createElementNS("http://www.w3.org/2000/svg", n); } -function et(t) { - return document.createTextNode(t); +function ft(n) { + return document.createTextNode(n); } -function H() { - return et(" "); +function U() { + return ft(" "); } -function ie(t, e, r, i) { - return t.addEventListener(e, r, i), () => t.removeEventListener(e, r, i); +function ae(n, e, t, i) { + return n.addEventListener(e, t, i), () => n.removeEventListener(e, t, i); } -function c(t, e, r) { - r == null ? t.removeAttribute(e) : t.getAttribute(e) !== r && t.setAttribute(e, r); +function c(n, e, t) { + t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t); } -function tt(t) { - return Array.from(t.childNodes); +function ut(n) { + return Array.from(n.childNodes); } -function _e(t, e, r) { - t.classList.toggle(e, !!r); +function Ne(n, e, t) { + n.classList.toggle(e, !!t); } -function rt(t, e, { bubbles: r = !1, cancelable: i = !1 } = {}) { - return new CustomEvent(t, { detail: e, bubbles: r, cancelable: i }); +function ht(n, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { + return new CustomEvent(n, { detail: e, bubbles: t, cancelable: i }); } -function nt(t) { +function dt(n) { const e = {}; - return t.childNodes.forEach( + return n.childNodes.forEach( /** @param {Element} node */ - (r) => { - e[r.slot || "default"] = !0; + (t) => { + e[t.slot || "default"] = !0; } ), e; } -let X; -function U(t) { - X = t; +let Q; +function z(n) { + Q = n; } -function ue() { - if (!X) +function ge() { + if (!Q) throw new Error("Function called outside component initialization"); - return X; + return Q; } -function it(t) { - ue().$$.on_mount.push(t); +function gt(n) { + ge().$$.on_mount.push(n); } -function ot(t) { - ue().$$.on_destroy.push(t); +function mt(n) { + ge().$$.on_destroy.push(n); } -function lt() { - const t = ue(); - return (e, r, { cancelable: i = !1 } = {}) => { - const o = t.$$.callbacks[e]; - if (o) { - const l = rt( +function bt() { + const n = ge(); + return (e, t, { cancelable: i = !1 } = {}) => { + const l = n.$$.callbacks[e]; + if (l) { + const o = ht( /** @type {string} */ e, - r, + t, { cancelable: i } ); - return o.slice().forEach((s) => { - s.call(t, l); - }), !l.defaultPrevented; + return l.slice().forEach((s) => { + s.call(n, o); + }), !o.defaultPrevented; } return !0; }; } -const D = [], le = []; -let B = []; -const pe = [], Ie = /* @__PURE__ */ Promise.resolve(); -let se = !1; -function Ne() { - se || (se = !0, Ie.then(C)); +const X = [], ue = []; +let K = []; +const Se = [], He = /* @__PURE__ */ Promise.resolve(); +let he = !1; +function Pe() { + he || (he = !0, He.then(E)); } -function st() { - return Ne(), Ie; +function pt() { + return Pe(), He; } -function ce(t) { - B.push(t); +function de(n) { + K.push(n); } -const oe = /* @__PURE__ */ new Set(); -let W = 0; -function C() { - if (W !== 0) +const fe = /* @__PURE__ */ new Set(); +let Y = 0; +function E() { + if (Y !== 0) return; - const t = X; + const n = Q; do { try { - for (; W < D.length; ) { - const e = D[W]; - W++, U(e), ct(e.$$); + for (; Y < X.length; ) { + const e = X[Y]; + Y++, z(e), yt(e.$$); } } catch (e) { - throw D.length = 0, W = 0, e; + throw X.length = 0, Y = 0, e; } - for (U(null), D.length = 0, W = 0; le.length; ) - le.pop()(); - for (let e = 0; e < B.length; e += 1) { - const r = B[e]; - oe.has(r) || (oe.add(r), r()); + for (z(null), X.length = 0, Y = 0; ue.length; ) + ue.pop()(); + for (let e = 0; e < K.length; e += 1) { + const t = K[e]; + fe.has(t) || (fe.add(t), t()); } - B.length = 0; - } while (D.length); - for (; pe.length; ) - pe.pop()(); - se = !1, oe.clear(), U(t); + K.length = 0; + } while (X.length); + for (; Se.length; ) + Se.pop()(); + he = !1, fe.clear(), z(n); } -function ct(t) { - if (t.fragment !== null) { - t.update(), K(t.before_update); - const e = t.dirty; - t.dirty = [-1], t.fragment && t.fragment.p(t.ctx, e), t.after_update.forEach(ce); +function yt(n) { + if (n.fragment !== null) { + n.update(), q(n.before_update); + const e = n.dirty; + n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(de); } } -function ut(t) { - const e = [], r = []; - B.forEach((i) => t.indexOf(i) === -1 ? e.push(i) : r.push(i)), r.forEach((i) => i()), B = e; +function vt(n) { + const e = [], t = []; + K.forEach((i) => n.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), K = e; } -const ft = /* @__PURE__ */ new Set(); -function at(t, e) { - t && t.i && (ft.delete(t), t.i(e)); +const wt = /* @__PURE__ */ new Set(); +function _t(n, e) { + n && n.i && (wt.delete(n), n.i(e)); } -function ht(t, e, r) { - const { fragment: i, after_update: o } = t.$$; - i && i.m(e, r), ce(() => { - const l = t.$$.on_mount.map(Le).filter(Re); - t.$$.on_destroy ? t.$$.on_destroy.push(...l) : K(l), t.$$.on_mount = []; - }), o.forEach(ce); +function kt(n, e, t) { + const { fragment: i, after_update: l } = n.$$; + i && i.m(e, t), de(() => { + const o = n.$$.on_mount.map(Ve).filter(Oe); + n.$$.on_destroy ? n.$$.on_destroy.push(...o) : q(o), n.$$.on_mount = []; + }), l.forEach(de); } -function dt(t, e) { - const r = t.$$; - r.fragment !== null && (ut(r.after_update), K(r.on_destroy), r.fragment && r.fragment.d(e), r.on_destroy = r.fragment = null, r.ctx = []); +function xt(n, e) { + const t = n.$$; + t.fragment !== null && (vt(t.after_update), q(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); } -function gt(t, e) { - t.$$.dirty[0] === -1 && (D.push(t), Ne(), t.$$.dirty.fill(0)), t.$$.dirty[e / 31 | 0] |= 1 << e % 31; +function Et(n, e) { + n.$$.dirty[0] === -1 && (X.push(n), Pe(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31; } -function bt(t, e, r, i, o, l, s = null, u = [-1]) { - const a = X; - U(t); - const f = t.$$ = { +function $t(n, e, t, i, l, o, s = null, a = [-1]) { + const u = Q; + z(n); + const f = n.$$ = { fragment: null, ctx: [], // state - props: l, - update: Y, - not_equal: o, - bound: we(), + props: o, + update: J, + not_equal: l, + bound: Re(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], - context: new Map(e.context || (a ? a.$$.context : [])), + context: new Map(e.context || (u ? u.$$.context : [])), // everything else - callbacks: we(), - dirty: u, + callbacks: Re(), + dirty: a, skip_bound: !1, - root: e.target || a.$$.root + root: e.target || u.$$.root }; s && s(f.root); - let p = !1; - if (f.ctx = r ? r(t, e.props || {}, (m, I, ...G) => { - const M = G.length ? G[0] : I; - return f.ctx && o(f.ctx[m], f.ctx[m] = M) && (!f.skip_bound && f.bound[m] && f.bound[m](M), p && gt(t, m)), I; - }) : [], f.update(), p = !0, K(f.before_update), f.fragment = i ? i(f.ctx) : !1, e.target) { + let R = !1; + if (f.ctx = t ? t(n, e.props || {}, (g, j, ...Z) => { + const G = Z.length ? Z[0] : j; + return f.ctx && l(f.ctx[g], f.ctx[g] = G) && (!f.skip_bound && f.bound[g] && f.bound[g](G), R && Et(n, g)), j; + }) : [], f.update(), R = !0, q(f.before_update), f.fragment = i ? i(f.ctx) : !1, e.target) { if (e.hydrate) { - const m = tt(e.target); - f.fragment && f.fragment.l(m), m.forEach(L); + const g = ut(e.target); + f.fragment && f.fragment.l(g), g.forEach(N); } else f.fragment && f.fragment.c(); - e.intro && at(t.$$.fragment), ht(t, e.target, e.anchor), C(); + e.intro && _t(n.$$.fragment), kt(n, e.target, e.anchor), E(); } - U(a); + z(u); } -let Te; -typeof HTMLElement == "function" && (Te = class extends HTMLElement { - constructor(e, r, i) { +let De; +typeof HTMLElement == "function" && (De = class extends HTMLElement { + constructor(e, t, i) { super(); /** The Svelte component constructor */ - T(this, "$$ctor"); + M(this, "$$ctor"); /** Slots */ - T(this, "$$s"); + M(this, "$$s"); /** The Svelte component instance */ - T(this, "$$c"); + M(this, "$$c"); /** Whether or not the custom element is connected */ - T(this, "$$cn", !1); + M(this, "$$cn", !1); /** Component props data */ - T(this, "$$d", {}); + M(this, "$$d", {}); /** `true` if currently in the process of reflecting component props back to attributes */ - T(this, "$$r", !1); + M(this, "$$r", !1); /** @type {Record} Props definition (name, reflected, type etc) */ - T(this, "$$p_d", {}); + M(this, "$$p_d", {}); /** @type {Record} Event listeners */ - T(this, "$$l", {}); + M(this, "$$l", {}); /** @type {Map} Event listener unsubscribe functions */ - T(this, "$$l_u", /* @__PURE__ */ new Map()); - this.$$ctor = e, this.$$s = r, i && this.attachShadow({ mode: "open" }); + M(this, "$$l_u", /* @__PURE__ */ new Map()); + this.$$ctor = e, this.$$s = t, 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); + 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, r, i); + super.addEventListener(e, t, 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)); + 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(l) { + let e = function(o) { return () => { let s; return { c: function() { - s = _("slot"), l !== "default" && c(s, "name", l); + s = L("slot"), o !== "default" && c(s, "name", o); }, /** * @param {HTMLElement} target * @param {HTMLElement} [anchor] */ - m: function(f, p) { - R(f, s, p); + m: function(f, R) { + A(f, s, R); }, d: function(f) { - f && L(s); + f && N(s); } }; }; }; if (await Promise.resolve(), !this.$$cn || this.$$c) return; - const r = {}, i = nt(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] = ee(s, l.value, this.$$p_d, "toProp")); + const t = {}, i = dt(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 l in this.$$p_d) - !(l in this.$$d) && this[l] !== void 0 && (this.$$d[l] = this[l], delete this[l]); + 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: r, + $$slots: t, $$scope: { ctx: [] } } }); - const o = () => { + const l = () => { 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 = ee( - l, - this.$$d[l], + 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[l].attribute || l) : this.setAttribute(this.$$p_d[l].attribute || l, s); + 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(o), o(); - for (const l in this.$$l) - for (const s of this.$$l[l]) { - const u = this.$$c.$on(l, s); - this.$$l_u.set(s, u); + this.$$c.$$.after_update.push(l), l(); + for (const o in this.$$l) + for (const s of this.$$l[o]) { + const a = this.$$c.$on(o, s); + this.$$l_u.set(s, a); } 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, r, i) { - var o; - this.$$r || (e = this.$$g_p(e), this.$$d[e] = ee(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); + 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(() => { @@ -347,17 +347,17 @@ typeof HTMLElement == "function" && (Te = class extends HTMLElement { } $$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 + (t) => this.$$p_d[t].attribute === e || !this.$$p_d[t].attribute && t.toLowerCase() === e ) || e; } }); -function ee(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]) +function le(n, e, t, i) { + var o; + const l = (o = t[n]) == null ? void 0 : o.type; + if (e = l === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[n]) return e; if (i === "toAttribute") - switch (o) { + switch (l) { case "Object": case "Array": return e == null ? null : JSON.stringify(e); @@ -369,7 +369,7 @@ function ee(t, e, r, i) { return e; } else - switch (o) { + switch (l) { case "Object": case "Array": return e && JSON.parse(e); @@ -381,38 +381,38 @@ function ee(t, e, r, i) { return e; } } -function mt(t, e, r, i, o, l) { - let s = class extends Te { +function Ct(n, e, t, i, l, o) { + let s = class extends De { constructor() { - super(t, r, o), this.$$p_d = e; + super(n, t, l), this.$$p_d = e; } static get observedAttributes() { return Object.keys(e).map( - (u) => (e[u].attribute || u).toLowerCase() + (a) => (e[a].attribute || a).toLowerCase() ); } }; - return Object.keys(e).forEach((u) => { - Object.defineProperty(s.prototype, u, { + return Object.keys(e).forEach((a) => { + Object.defineProperty(s.prototype, a, { get() { - return this.$$c && u in this.$$c ? this.$$c[u] : this.$$d[u]; + return this.$$c && a in this.$$c ? this.$$c[a] : this.$$d[a]; }, - set(a) { + set(u) { var f; - a = ee(u, a, e), this.$$d[u] = a, (f = this.$$c) == null || f.$set({ [u]: a }); + u = le(a, u, e), this.$$d[a] = u, (f = this.$$c) == null || f.$set({ [a]: u }); } }); - }), i.forEach((u) => { - Object.defineProperty(s.prototype, u, { + }), i.forEach((a) => { + Object.defineProperty(s.prototype, a, { get() { - var a; - return (a = this.$$c) == null ? void 0 : a[u]; + var u; + return (u = this.$$c) == null ? void 0 : u[a]; } }); - }), l && (s = l(s)), t.element = /** @type {any} */ + }), o && (s = o(s)), n.element = /** @type {any} */ s, s; } -class vt { +class Lt { constructor() { /** * ### PRIVATE API @@ -421,7 +421,7 @@ class vt { * * @type {any} */ - T(this, "$$"); + M(this, "$$"); /** * ### PRIVATE API * @@ -429,11 +429,11 @@ class vt { * * @type {any} */ - T(this, "$$set"); + M(this, "$$set"); } /** @returns {void} */ $destroy() { - dt(this, 1), this.$destroy = Y; + xt(this, 1), this.$destroy = J; } /** * @template {Extract} K @@ -441,13 +441,13 @@ class vt { * @param {((e: Events[K]) => void) | null | undefined} callback * @returns {() => void} */ - $on(e, r) { - if (!Re(r)) - return Y; + $on(e, t) { + if (!Oe(t)) + return J; const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); - return i.push(r), () => { - const o = i.indexOf(r); - o !== -1 && i.splice(o, 1); + return i.push(t), () => { + const l = i.indexOf(t); + l !== -1 && i.splice(l, 1); }; } /** @@ -455,614 +455,692 @@ class vt { * @returns {void} */ $set(e) { - this.$$set && !Je(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); + this.$$set && !ot(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); } } -const wt = "4"; -typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(wt); -const Me = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGcodCl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KHQpXS5tYXAoZT0+ZS50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBoKHQsZSxvKXtyZXR1cm4gZyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUodCtlKSkpfWZ1bmN0aW9uIG0odCxlLG89IlNIQS0yNTYiLGk9MWU2LHA9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyO3JldHVybntwcm9taXNlOm5ldyBQcm9taXNlKChzLGMpPT57Y29uc3Qgcj1EYXRlLm5vdygpLGQ9bD0+e2Euc2lnbmFsLmFib3J0ZWR8fGw+aT9zKG51bGwpOmgoZSxsLG8pLnRoZW4odz0+e3c9PT10P3Moe251bWJlcjpsLHRvb2s6RGF0ZS5ub3coKS1yfSk6ZChsKzEpfSkuY2F0Y2goYyl9O2QocCl9KSxjb250cm9sbGVyOmF9fWxldCBuO29ubWVzc2FnZT1hc3luYyB0PT57Y29uc3R7dHlwZTplLHBheWxvYWQ6b309dC5kYXRhO2lmKGU9PT0iYWJvcnQiKW49PW51bGx8fG4uYWJvcnQoKSxuPXZvaWQgMDtlbHNlIGlmKGU9PT0id29yayIpe2NvbnN0e2FsZzppLGNoYWxsZW5nZTpwLG1heDphLHNhbHQ6dSxzdGFydDpzfT1vfHx7fSxjPW0ocCx1LGksYSxzKTtuPWMuY29udHJvbGxlcixjLnByb21pc2UudGhlbihyPT57c2VsZi5wb3N0TWVzc2FnZShyJiZ7Li4ucix3b3JrZXI6ITB9KX0pfX19KSgpOwo=", _t = (t) => Uint8Array.from(atob(t), (e) => e.charCodeAt(0)), ye = typeof window < "u" && window.Blob && new Blob([_t(Me)], { type: "text/javascript;charset=utf-8" }); -function pt(t) { +const It = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(It); +const Fe = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGcodCl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KHQpXS5tYXAoZT0+ZS50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBoKHQsZSxvKXtyZXR1cm4gZyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUodCtlKSkpfWZ1bmN0aW9uIG0odCxlLG89IlNIQS0yNTYiLGk9MWU2LHA9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyO3JldHVybntwcm9taXNlOm5ldyBQcm9taXNlKChzLGMpPT57Y29uc3Qgcj1EYXRlLm5vdygpLGQ9bD0+e2Euc2lnbmFsLmFib3J0ZWR8fGw+aT9zKG51bGwpOmgoZSxsLG8pLnRoZW4odz0+e3c9PT10P3Moe251bWJlcjpsLHRvb2s6RGF0ZS5ub3coKS1yfSk6ZChsKzEpfSkuY2F0Y2goYyl9O2QocCl9KSxjb250cm9sbGVyOmF9fWxldCBuO29ubWVzc2FnZT1hc3luYyB0PT57Y29uc3R7dHlwZTplLHBheWxvYWQ6b309dC5kYXRhO2lmKGU9PT0iYWJvcnQiKW49PW51bGx8fG4uYWJvcnQoKSxuPXZvaWQgMDtlbHNlIGlmKGU9PT0id29yayIpe2NvbnN0e2FsZzppLGNoYWxsZW5nZTpwLG1heDphLHNhbHQ6dSxzdGFydDpzfT1vfHx7fSxjPW0ocCx1LGksYSxzKTtuPWMuY29udHJvbGxlcixjLnByb21pc2UudGhlbihyPT57c2VsZi5wb3N0TWVzc2FnZShyJiZ7Li4ucix3b3JrZXI6ITB9KX0pfX19KSgpOwo=", Rt = (n) => Uint8Array.from(atob(n), (e) => e.charCodeAt(0)), Te = typeof window < "u" && window.Blob && new Blob([Rt(Fe)], { type: "text/javascript;charset=utf-8" }); +function Nt(n) { let e; try { - if (e = ye && (window.URL || window.webkitURL).createObjectURL(ye), !e) + if (e = Te && (window.URL || window.webkitURL).createObjectURL(Te), !e) throw ""; - const r = new Worker(e, { - name: t == null ? void 0 : t.name + const t = new Worker(e, { + name: n == null ? void 0 : n.name }); - return r.addEventListener("error", () => { + return t.addEventListener("error", () => { (window.URL || window.webkitURL).revokeObjectURL(e); - }), r; + }), t; } catch { return new Worker( - "data:text/javascript;base64," + Me, + "data:text/javascript;base64," + Fe, { - name: t == null ? void 0 : t.name + name: n == null ? void 0 : n.name } ); } finally { e && (window.URL || window.webkitURL).revokeObjectURL(e); } } -const yt = new TextEncoder(); -function kt(t) { - return [...new Uint8Array(t)].map((e) => e.toString(16).padStart(2, "0")).join(""); +const St = new TextEncoder(); +function Tt(n) { + return [...new Uint8Array(n)].map((e) => e.toString(16).padStart(2, "0")).join(""); } -async function $t(t, e = "SHA-256", r = 1e5) { +async function At(n, e = "SHA-256", t = 1e5) { const i = Date.now().toString(16); - t || (t = Math.round(Math.random() * r)); - const o = await Ge(i, t, e); + n || (n = Math.round(Math.random() * t)); + const l = await We(i, n, e); return { algorithm: e, - challenge: o, + challenge: l, salt: i, signature: "" }; } -async function Ge(t, e, r) { - return kt(await crypto.subtle.digest(r.toUpperCase(), yt.encode(t + e))); +async function We(n, e, t) { + return Tt( + await crypto.subtle.digest( + t.toUpperCase(), + St.encode(n + e) + ) + ); } -function xt(t, e, r = "SHA-256", i = 1e6, o = 0) { - const l = new AbortController(); +function jt(n, e, t = "SHA-256", i = 1e6, l = 0) { + const o = new AbortController(); return { - promise: new Promise((u, a) => { - const f = Date.now(), p = (m) => { - l.signal.aborted || m > i ? u(null) : Ge(e, m, r).then((I) => { - I === t ? u({ - number: m, + promise: new Promise((a, u) => { + const f = Date.now(), R = (g) => { + o.signal.aborted || g > i ? a(null) : We(e, g, t).then((j) => { + j === n ? a({ + number: g, took: Date.now() - f - }) : p(m + 1); - }).catch(a); + }) : R(g + 1); + }).catch(u); }; - p(o); + R(l); }), - controller: l + controller: o }; } -var g = /* @__PURE__ */ ((t) => (t.ERROR = "error", t.VERIFIED = "verified", t.VERIFYING = "verifying", t.UNVERIFIED = "unverified", t.EXPIRED = "expired", t))(g || {}); -function Et(t) { - ze(t, "svelte-vuofbg", ".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}"); +var v = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(v || {}); +function Mt(n) { + st(n, "svelte-14ngypa", `.altcha.svelte-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-14ngypa.svelte-14ngypa{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-14ngypa.svelte-14ngypa{flex-grow:1}.altcha-label.svelte-14ngypa label.svelte-14ngypa{cursor:pointer}.altcha-logo.svelte-14ngypa.svelte-14ngypa{color:currentColor;opacity:0.3}.altcha-logo.svelte-14ngypa.svelte-14ngypa:hover{opacity:1}.altcha-error.svelte-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa:hover{opacity:1}.altcha-footer.svelte-14ngypa>.svelte-14ngypa:first-child{flex-grow:1}.altcha-footer.svelte-14ngypa a{color:currentColor}.altcha-checkbox.svelte-14ngypa.svelte-14ngypa{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-14ngypa input.svelte-14ngypa{width:18px;height:18px;margin:0}.altcha-hidden.svelte-14ngypa.svelte-14ngypa{display:none}.altcha-spinner.svelte-14ngypa.svelte-14ngypa{animation:svelte-14ngypa-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-14ngypa-altcha-spinner{100%{transform:rotate(360deg)}}`); } -function ke(t) { - let e, r, i; +function Ae(n) { + let e, t, i; return { c() { - e = V("svg"), r = V("path"), i = V("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-vuofbg"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg"); + e = P("svg"), t = P("path"), i = P("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-14ngypa"), 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) { - R(o, e, l), b(e, r), b(e, i); + m(l, o) { + A(l, e, o), w(e, t), w(e, i); }, - d(o) { - o && L(e); + d(l) { + l && N(e); } }; } -function Ct(t) { - let e, r = ( +function Zt(n) { + let e, t = ( /*_strings*/ - t[9].label + "" + n[9].label + "" ), i; return { c() { - e = _("label"), c(e, "for", i = /*name*/ - t[3] + "_checkbox"), c(e, "class", "svelte-vuofbg"); + e = L("label"), c(e, "for", i = /*name*/ + n[3] + "_checkbox"), c(e, "class", "svelte-14ngypa"); }, - m(o, l) { - R(o, e, l), e.innerHTML = r; + m(l, o) { + A(l, e, o), e.innerHTML = t; }, - p(o, l) { - l[0] & /*_strings*/ - 512 && r !== (r = /*_strings*/ - o[9].label + "") && (e.innerHTML = r), l[0] & /*name*/ - 8 && i !== (i = /*name*/ - o[3] + "_checkbox") && c(e, "for", i); - }, - d(o) { - o && L(e); - } - }; -} -function Lt(t) { - let e, r = ( - /*_strings*/ - t[9].verifying + "" - ); - return { - c() { - e = _("span"); - }, - m(i, o) { - R(i, e, o), e.innerHTML = r; - }, - p(i, o) { + p(l, o) { o[0] & /*_strings*/ - 512 && r !== (r = /*_strings*/ - i[9].verifying + "") && (e.innerHTML = r); - }, - d(i) { - i && L(e); - } - }; -} -function Rt(t) { - let e, r = ( - /*_strings*/ - t[9].verified + "" - ), i, o; - return { - c() { - e = _("span"), i = H(), o = _("input"), c(o, "type", "hidden"), c( - o, - "name", - /*name*/ - t[3] - ), o.value = /*payload*/ - t[4]; - }, - m(l, s) { - R(l, e, s), e.innerHTML = r, R(l, i, s), R(l, o, s); - }, - p(l, s) { - s[0] & /*_strings*/ - 512 && r !== (r = /*_strings*/ - l[9].verified + "") && (e.innerHTML = r), s[0] & /*name*/ - 8 && c( - o, - "name", - /*name*/ - l[3] - ), s[0] & /*payload*/ - 16 && (o.value = /*payload*/ - l[4]); + 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 && (L(e), L(i), L(o)); + l && N(e); } }; } -function $e(t) { - let e, r, i, o, l, s; - return { - c() { - e = _("div"), r = _("a"), i = V("svg"), o = V("path"), l = V("path"), s = V("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", Se), c(r, "target", "_blank"), c(r, "class", "altcha-logo svelte-vuofbg"); - }, - m(u, a) { - R(u, e, a), b(e, r), b(r, i), b(i, o), b(i, l), b(i, s); - }, - p: Y, - d(u) { - u && L(e); - } - }; -} -function xe(t) { - let e, r, i, o; - function l(a, f) { - return ( - /*state*/ - a[5] === g.EXPIRED ? Nt : It - ); - } - let s = l(t), u = s(t); - return { - c() { - e = _("div"), r = V("svg"), i = V("path"), o = H(), u.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-vuofbg"); - }, - m(a, f) { - R(a, e, f), b(e, r), b(r, i), b(e, o), u.m(e, null); - }, - p(a, f) { - s === (s = l(a)) && u ? u.p(a, f) : (u.d(1), u = s(a), u && (u.c(), u.m(e, null))); - }, - d(a) { - a && L(e), u.d(); - } - }; -} -function It(t) { - let e, r = ( +function Gt(n) { + let e, t = ( /*_strings*/ - t[9].error + "" + n[9].verifying + "" ); return { c() { - e = _("div"), c( - e, - "title", - /*error*/ - t[8] - ); + e = L("span"); }, - m(i, o) { - R(i, e, o), e.innerHTML = r; + m(i, l) { + A(i, e, l), e.innerHTML = t; }, - p(i, o) { - o[0] & /*_strings*/ - 512 && r !== (r = /*_strings*/ - i[9].error + "") && (e.innerHTML = r), o[0] & /*error*/ - 256 && c( - e, - "title", - /*error*/ - i[8] - ); - }, - d(i) { - i && L(e); - } - }; -} -function Nt(t) { - let e, r = ( - /*_strings*/ - t[9].expired + "" - ); - return { - c() { - e = _("div"), c( - e, - "title", - /*error*/ - t[8] - ); - }, - m(i, o) { - R(i, e, o), e.innerHTML = r; - }, - p(i, o) { - o[0] & /*_strings*/ - 512 && r !== (r = /*_strings*/ - i[9].expired + "") && (e.innerHTML = r), o[0] & /*error*/ - 256 && c( - e, - "title", - /*error*/ - i[8] - ); - }, - d(i) { - i && L(e); - } - }; -} -function Ee(t) { - let e, r, i = ( - /*_strings*/ - t[9].footer + "" - ); - return { - c() { - e = _("div"), r = _("div"), c(r, "class", "svelte-vuofbg"), c(e, "class", "altcha-footer svelte-vuofbg"); - }, - m(o, l) { - R(o, e, l), b(e, r), r.innerHTML = i; - }, - p(o, l) { + p(i, l) { l[0] & /*_strings*/ - 512 && i !== (i = /*_strings*/ - o[9].footer + "") && (r.innerHTML = i); + 512 && t !== (t = /*_strings*/ + i[9].verifying + "") && (e.innerHTML = t); + }, + d(i) { + i && N(e); + } + }; +} +function Vt(n) { + let e, t = ( + /*_strings*/ + n[9].verified + "" + ), i, l; + return { + c() { + e = L("span"), i = U(), l = L("input"), c(l, "type", "hidden"), c( + l, + "name", + /*name*/ + n[3] + ), l.value = /*payload*/ + n[4]; + }, + m(o, s) { + A(o, e, s), e.innerHTML = t, A(o, i, s), A(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 && L(e); + o && (N(e), N(i), N(l)); } }; } -function Tt(t) { - let e, r, i, o, l, s, u, a, f, p, m, I, G, M, w = ( - /*state*/ - t[5] === g.VERIFYING && ke() - ); - function Z(h, x) { +function je(n) { + let e, t, i, l, o, s; + return { + c() { + e = L("div"), t = L("a"), i = P("svg"), l = P("path"), o = P("path"), s = P("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", Be), c(t, "target", "_blank"), c(t, "class", "altcha-logo svelte-14ngypa"); + }, + m(a, u) { + A(a, e, u), w(e, t), w(t, i), w(i, l), w(i, o), w(i, s); + }, + p: J, + d(a) { + a && N(e); + } + }; +} +function Me(n) { + let e, t, i, l; + function o(u, f) { return ( /*state*/ - h[5] === g.VERIFIED ? Rt : ( + u[5] === v.EXPIRED ? Ht : Ot + ); + } + let s = o(n), a = s(n); + return { + c() { + e = L("div"), t = P("svg"), i = P("path"), l = U(), a.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-14ngypa"); + }, + m(u, f) { + A(u, e, f), w(e, t), w(t, i), w(e, l), a.m(e, null); + }, + p(u, f) { + s === (s = o(u)) && a ? a.p(u, f) : (a.d(1), a = s(u), a && (a.c(), a.m(e, null))); + }, + d(u) { + u && N(e), a.d(); + } + }; +} +function Ot(n) { + let e, t = ( + /*_strings*/ + n[9].error + "" + ); + return { + c() { + e = L("div"), c( + e, + "title", + /*error*/ + n[8] + ); + }, + m(i, l) { + A(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 && N(e); + } + }; +} +function Ht(n) { + let e, t = ( + /*_strings*/ + n[9].expired + "" + ); + return { + c() { + e = L("div"), c( + e, + "title", + /*error*/ + n[8] + ); + }, + m(i, l) { + A(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 && N(e); + } + }; +} +function Ze(n) { + let e, t, i = ( + /*_strings*/ + n[9].footer + "" + ); + return { + c() { + e = L("div"), t = L("div"), c(t, "class", "svelte-14ngypa"), c(e, "class", "altcha-footer svelte-14ngypa"); + }, + m(l, o) { + A(l, e, o), w(e, t), t.innerHTML = i; + }, + p(l, o) { + o[0] & /*_strings*/ + 512 && i !== (i = /*_strings*/ + l[9].footer + "") && (t.innerHTML = i); + }, + d(l) { + l && N(e); + } + }; +} +function Pt(n) { + let e, t, i, l, o, s, a, u, f, R, g, j, Z, G, _ = ( + /*state*/ + n[5] === v.VERIFYING && Ae() + ); + function F(d, I) { + return ( + /*state*/ + d[5] === v.VERIFIED ? Vt : ( /*state*/ - h[5] === g.VERIFYING ? Lt : Ct + d[5] === v.VERIFYING ? Gt : Zt ) ); } - let A = Z(t), y = A(t), v = ( + let V = F(n), k = V(n), x = ( /*hidelogo*/ - t[2] !== !0 && $e() - ), k = ( + n[2] !== !0 && je() + ), m = ( /*error*/ - (t[8] || /*state*/ - t[5] === g.EXPIRED) && xe(t) - ), $ = ( + (n[8] || /*state*/ + n[5] === v.EXPIRED) && Me(n) + ), y = ( /*_strings*/ - t[9].footer && /*hidefooter*/ - t[1] !== !0 && Ee(t) + n[9].footer && /*hidefooter*/ + n[1] !== !0 && Ze(n) ); return { c() { - e = _("div"), r = _("div"), w && w.c(), i = H(), o = _("div"), l = _("input"), a = H(), f = _("div"), y.c(), p = H(), v && v.c(), m = H(), k && k.c(), I = H(), $ && $.c(), c(l, "type", "checkbox"), c(l, "id", s = /*name*/ - t[3] + "_checkbox"), l.required = u = /*auto*/ - t[0] !== "onsubmit", c(l, "class", "svelte-vuofbg"), c(o, "class", "altcha-checkbox svelte-vuofbg"), _e( - o, + e = L("div"), t = L("div"), _ && _.c(), i = U(), l = L("div"), o = L("input"), u = U(), f = L("div"), k.c(), R = U(), x && x.c(), g = U(), m && m.c(), j = U(), y && y.c(), c(o, "type", "checkbox"), c(o, "id", s = /*name*/ + n[3] + "_checkbox"), o.required = a = /*auto*/ + n[0] !== "onsubmit", c(o, "class", "svelte-14ngypa"), c(l, "class", "altcha-checkbox svelte-14ngypa"), Ne( + l, "altcha-hidden", /*state*/ - t[5] === g.VERIFYING - ), c(f, "class", "altcha-label svelte-vuofbg"), c(r, "class", "altcha-main svelte-vuofbg"), c(e, "class", "altcha svelte-vuofbg"), c( + n[5] === v.VERIFYING + ), c(f, "class", "altcha-label svelte-14ngypa"), c(t, "class", "altcha-main svelte-14ngypa"), c(e, "class", "altcha svelte-14ngypa"), c( e, "data-state", /*state*/ - t[5] + n[5] ); }, - m(h, x) { - R(h, e, x), b(e, r), w && w.m(r, null), b(r, i), b(r, o), b(o, l), l.checked = /*checked*/ - t[6], b(r, a), b(r, f), y.m(f, null), b(r, p), v && v.m(r, null), b(e, m), k && k.m(e, null), b(e, I), $ && $.m(e, null), t[27](e), G || (M = [ - ie( - l, + m(d, I) { + A(d, e, I), w(e, t), _ && _.m(t, null), w(t, i), w(t, l), w(l, o), o.checked = /*checked*/ + n[6], w(t, u), w(t, f), k.m(f, null), w(t, R), x && x.m(t, null), w(e, g), m && m.m(e, null), w(e, j), y && y.m(e, null), n[30](e), Z || (G = [ + ae( + o, "change", /*input_change_handler*/ - t[26] + n[29] ), - ie( - l, + ae( + o, "change", /*onCheckedChange*/ - t[10] + n[10] ), - ie( - l, + ae( + o, "invalid", /*onInvalid*/ - t[11] + n[11] ) - ], G = !0); + ], Z = !0); }, - p(h, x) { + p(d, I) { /*state*/ - h[5] === g.VERIFYING ? w || (w = ke(), w.c(), w.m(r, i)) : w && (w.d(1), w = null), x[0] & /*name*/ + d[5] === v.VERIFYING ? _ || (_ = Ae(), _.c(), _.m(t, i)) : _ && (_.d(1), _ = null), I[0] & /*name*/ 8 && s !== (s = /*name*/ - h[3] + "_checkbox") && c(l, "id", s), x[0] & /*auto*/ - 1 && u !== (u = /*auto*/ - h[0] !== "onsubmit") && (l.required = u), x[0] & /*checked*/ - 64 && (l.checked = /*checked*/ - h[6]), x[0] & /*state*/ - 32 && _e( - o, + d[3] + "_checkbox") && c(o, "id", s), I[0] & /*auto*/ + 1 && a !== (a = /*auto*/ + d[0] !== "onsubmit") && (o.required = a), I[0] & /*checked*/ + 64 && (o.checked = /*checked*/ + d[6]), I[0] & /*state*/ + 32 && Ne( + l, "altcha-hidden", /*state*/ - h[5] === g.VERIFYING - ), A === (A = Z(h)) && y ? y.p(h, x) : (y.d(1), y = A(h), y && (y.c(), y.m(f, null))), /*hidelogo*/ - h[2] !== !0 ? v ? v.p(h, x) : (v = $e(), v.c(), v.m(r, null)) : v && (v.d(1), v = null), /*error*/ - h[8] || /*state*/ - h[5] === g.EXPIRED ? k ? k.p(h, x) : (k = xe(h), k.c(), k.m(e, I)) : k && (k.d(1), k = null), /*_strings*/ - h[9].footer && /*hidefooter*/ - h[1] !== !0 ? $ ? $.p(h, x) : ($ = Ee(h), $.c(), $.m(e, null)) : $ && ($.d(1), $ = null), x[0] & /*state*/ + d[5] === v.VERIFYING + ), V === (V = F(d)) && k ? k.p(d, I) : (k.d(1), k = V(d), k && (k.c(), k.m(f, null))), /*hidelogo*/ + d[2] !== !0 ? x ? x.p(d, I) : (x = je(), x.c(), x.m(t, null)) : x && (x.d(1), x = null), /*error*/ + d[8] || /*state*/ + d[5] === v.EXPIRED ? m ? m.p(d, I) : (m = Me(d), m.c(), m.m(e, j)) : m && (m.d(1), m = null), /*_strings*/ + d[9].footer && /*hidefooter*/ + 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] & /*state*/ 32 && c( e, "data-state", /*state*/ - h[5] + d[5] ); }, - i: Y, - o: Y, - d(h) { - h && L(e), w && w.d(), y.d(), v && v.d(), k && k.d(), $ && $.d(), t[27](null), G = !1, K(M); + i: J, + o: J, + d(d) { + d && N(e), _ && _.d(), k.d(), x && x.d(), m && m.d(), y && y.d(), n[30](null), Z = !1, q(G); } }; } -const Se = "https://altcha.org/"; -function Ce(t) { - return JSON.parse(t); +const Be = "https://altcha.org/"; +function Ge(n) { + return JSON.parse(n); } -function Mt(t, e, r) { - let i, o, l, { auto: s = void 0 } = e, { challengeurl: u = void 0 } = e, { challengejson: a = void 0 } = e, { debug: f = !1 } = e, { expire: p = void 0 } = e, { hidefooter: m = !1 } = e, { hidelogo: I = !1 } = e, { name: G = "altcha" } = e, { maxnumber: M = 1e6 } = e, { mockerror: w = !1 } = e, { refetchonexpire: Z = !0 } = e, { strings: A = void 0 } = e, { test: y = !1 } = e, { workers: v = navigator.hardwareConcurrency || 8 } = e; - const k = lt(), $ = ["SHA-256", "SHA-384", "SHA-512"]; - let h = !1, x, N = null, te = null, F = null, j = g.UNVERIFIED, re; - ot(() => { - N && (N.removeEventListener("submit", fe), N.removeEventListener("reset", ae), N = null); - }), it(() => { - E("mounted", "0.2.3"), E("workers", v), y && E("using test mode"), p && ne(p), s !== void 0 && E("auto", s), N = x.closest("form"), N && (N.addEventListener("submit", fe), N.addEventListener("reset", ae)), s === "onload" && P(); +function Dt() { + try { + return Intl.DateTimeFormat().resolvedOptions().timeZone; + } catch { + } +} +function Ft(n, e, t) { + var Ee, $e; + let i, l, o, { auto: s = void 0 } = e, { blockspam: a = void 0 } = e, { challengeurl: u = void 0 } = e, { challengejson: f = void 0 } = e, { debug: R = !1 } = e, { expire: g = void 0 } = e, { hidefooter: j = !1 } = e, { hidelogo: Z = !1 } = e, { name: G = "altcha" } = e, { maxnumber: _ = 1e6 } = e, { mockerror: F = !1 } = e, { refetchonexpire: V = !0 } = e, { spamfilter: k = !1 } = e, { strings: x = void 0 } = e, { test: m = !1 } = e, { verifyurl: y = void 0 } = e, { workers: d = navigator.hardwareConcurrency || 8 } = e; + const I = bt(), me = ["SHA-256", "SHA-384", "SHA-512"], be = ($e = (Ee = document.documentElement.lang) == null ? void 0 : Ee.split("-")) == null ? void 0 : $e[0]; + let D = !1, ee, b = null, oe = null, W = null, O = v.UNVERIFIED, se; + mt(() => { + b && (b.removeEventListener("submit", ye), b.removeEventListener("reset", ve), b.removeEventListener("focusin", pe), b = null); + }), gt(() => { + $("mounted", "0.2.3"), $("workers", d), m && $("using test mode"), g && ce(g), s !== void 0 && $("auto", s), b = ee.closest("form"), b && (b.addEventListener("submit", ye), b.addEventListener("reset", ve), s === "onfocus" && b.addEventListener("focusin", pe)), s === "onload" && B(); }); - function E(...n) { - (f || n.some((d) => d instanceof Error)) && console[n[0] instanceof Error ? "error" : "log"]("ALTCHA", ...n); + function $(...r) { + (R || r.some((h) => h instanceof Error)) && console[r[0] instanceof Error ? "error" : "log"]("ALTCHA", ...r); } - function fe(n) { - N && s === "onsubmit" && j === g.UNVERIFIED && (n.preventDefault(), n.stopPropagation(), P().then(() => { - N == null || N.requestSubmit(); + function pe(r) { + B(); + } + function ye(r) { + b && s === "onsubmit" && O === v.UNVERIFIED && (r.preventDefault(), r.stopPropagation(), B().then(() => { + b == null || b.requestSubmit(); })); } - function ae() { - J(); + function ve() { + te(); } - function Ae(n, d) { + function we(r, h) { return btoa(JSON.stringify({ - algorithm: n.algorithm, - challenge: n.challenge, - number: d.number, - salt: n.salt, - signature: n.signature, - test: y ? !0 : void 0, - took: d.took + algorithm: r.algorithm, + challenge: r.challenge, + number: h.number, + salt: r.salt, + signature: r.signature, + test: m ? !0 : void 0, + took: h.took })); } - function he(n) { - if (!n.algorithm) + function _e(r) { + if (!r.algorithm) throw new Error("Invalid challenge. Property algorithm is missing."); - if (n.signature === void 0) + if (r.signature === void 0) throw new Error("Invalid challenge. Property signature is missing."); - if (!$.includes(n.algorithm.toUpperCase())) - throw new Error(`Unknown algorithm value. Allowed values: ${$.join(", ")}`); - if (!n.challenge || n.challenge.length < 40) + if (!me.includes(r.algorithm.toUpperCase())) + throw new Error(`Unknown algorithm value. Allowed values: ${me.join(", ")}`); + if (!r.challenge || r.challenge.length < 40) throw new Error("Challenge is too short. Min. 40 chars."); - if (!n.salt || n.salt.length < 10) + if (!r.salt || r.salt.length < 10) throw new Error("Salt is too short. Min. 10 chars."); } - async function je() { - if (w) - throw E("mocking error"), new Error("Mocked error."); + async function Ue() { + if (F) + throw $("mocking error"), new Error("Mocked error."); if (i) - return E("using provided json data"), i; - if (y) - return E("generating test challenge"), $t(); + return $("using provided json data"), i; + if (m) + return $("generating test challenge"), At(typeof m != "boolean" ? +m : void 0); { if (!u) throw new Error("Attribute challengeurl not set."); - E("fetching challenge from", u); - const n = await fetch(u); - if (n.status !== 200) - throw new Error(`Server responded with ${n.status}.`); - const d = n.headers.get("Expires"); - if (!p && (d != null && d.length)) { - const O = Date.parse(d); - if (O) { - const z = O - Date.now(); - z > 0 && ne(z); + $("fetching challenge from", u); + const r = await fetch(u, { + headers: { + "x-altcha-spam-filter": k ? "1" : "0" + } + }); + if (r.status !== 200) + throw new Error(`Server responded with ${r.status}.`); + const h = r.headers.get("Expires"), C = r.headers.get("X-Altcha-Config"); + if (C) + try { + const p = JSON.parse(C); + p && typeof p == "object" && (p.verifyurl && (p.verifyurl = new URL(p.verifyurl, new URL(u)).toString()), xe(p)); + } catch (p) { + $("unable to configure from X-Altcha-Config", p); + } + if (!g && (h != null && h.length)) { + const p = Date.parse(h); + if (p) { + const S = p - Date.now(); + S > 0 && ce(S); } } - return n.json(); + return r.json(); } } - function de() { - u && Z && j === g.VERIFIED ? P() : J(g.EXPIRED, l.expired); + function ke() { + u && V && O === v.VERIFIED ? B() : te(v.EXPIRED, o.expired); } - async function Ve(n) { - let d = null; + async function Ye(r) { + let h = null; if ("Worker" in window) { try { - d = await Ze(n.challenge, n.salt, n.algorithm, n.maxnumber); - } catch (O) { - E(O); + h = await Xe(r.challenge, r.salt, r.algorithm, r.maxnumber); + } catch (C) { + $(C); } - if ((d == null ? void 0 : d.number) !== void 0) - return { data: n, solution: d }; + if ((h == null ? void 0 : h.number) !== void 0) + return { data: r, solution: h }; } return { - data: n, - solution: await xt(n.challenge, n.salt, n.algorithm, n.maxnumber || M).promise + data: r, + solution: await jt(r.challenge, r.salt, r.algorithm, r.maxnumber || _).promise }; } - async function Ze(n, d, O, z = M, Q = Math.ceil(v)) { - const q = []; - if (Q < 1) + async function Xe(r, h, C, p = _, S = Math.ceil(d)) { + const H = []; + if (S < 1) throw new Error("Wrong number of workers configured."); - if (Q > 16) + if (S > 16) throw new Error("Too many workers. Max. 16 allowed workers."); - for (let S = 0; S < Q; S++) - q.push(new pt()); - const ge = Math.ceil(z / Q), De = await Promise.all(q.map((S, Be) => { - const be = Be * ge; - return new Promise((Ye) => { - S.addEventListener("message", (me) => { - if (me.data) - for (const ve of q) - ve !== S && ve.postMessage({ type: "abort" }); - Ye(me.data); - }), S.postMessage({ + for (let T = 0; T < S; T++) + H.push(new Nt()); + const ne = Math.ceil(p / S), re = await Promise.all(H.map((T, ie) => { + const Ce = ie * ne; + return new Promise((nt) => { + T.addEventListener("message", (Le) => { + if (Le.data) + for (const Ie of H) + Ie !== T && Ie.postMessage({ type: "abort" }); + nt(Le.data); + }), T.postMessage({ payload: { - alg: O, - challenge: n, - max: be + ge, - salt: d, - start: be + alg: C, + challenge: r, + max: Ce + ne, + salt: h, + start: Ce }, type: "work" }); }); })); - for (const S of q) - S.terminate(); - return De.find((S) => !!S) || null; + for (const T of H) + T.terminate(); + return re.find((T) => !!T) || null; } - function He() { - [g.UNVERIFIED, g.ERROR, g.EXPIRED].includes(j) ? P() : r(6, h = !0); + function Ke() { + [v.UNVERIFIED, v.ERROR, v.EXPIRED].includes(O) ? k && (b == null ? void 0 : b.reportValidity()) === !1 ? t(6, D = !1) : B() : t(6, D = !0); } - function Fe() { - j === g.VERIFYING && alert(l.waitAlert); + function Je() { + O === v.VERIFYING && alert(o.waitAlert); } - function ne(n) { - E("expire", n), clearTimeout(re), n < 1 ? de() : re = setTimeout(de, n); + function ce(r) { + $("expire", r), clearTimeout(se), r < 1 ? ke() : se = setTimeout(ke, r); } - function Pe(n) { - n.auto !== void 0 && (r(0, s = n.auto), s === "onload" && P()), n.expire !== void 0 && (ne(n.expire), r(13, p = n.expire)), n.challenge && (he(n.challenge), i = n.challenge), n.debug !== void 0 && r(12, f = !!n.debug), n.hidefooter !== void 0 && r(1, m = !!n.hidefooter), n.hidelogo !== void 0 && r(2, I = !!n.hidelogo), n.maxnumber !== void 0 && r(14, M = +n.maxnumber), n.mockerror !== void 0 && r(15, w = !!n.mockerror), n.name !== void 0 && r(3, G = n.name), n.refetchonexpire !== void 0 && r(16, Z = !!n.refetchonexpire), n.strings && r(25, o = n.strings), n.test !== void 0 && r(17, y = !!n.test), n.workers !== void 0 && r(18, v = +n.workers); + function ze(r) { + var C; + const h = b == null ? void 0 : b.querySelector(typeof r == "string" ? `input[name="${r}"]` : 'input[type="email"]:not([data-no-spamfilter])'); + return ((C = h == null ? void 0 : h.value) == null ? void 0 : C.slice(h.value.indexOf("@"))) || void 0; } - function J(n = g.UNVERIFIED, d = null) { - clearTimeout(re), r(6, h = !1), r(8, te = d), r(4, F = null), r(5, j = n); + function Qe(r) { + return [ + ...(b == null ? void 0 : b.querySelectorAll(r != null && r.length ? r.map((C) => `input[name="${C}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] + ].reduce( + (C, p) => { + const S = p.name, H = p.value.trim(); + return S && H && (C[S] = H), C; + }, + {} + ); } - async function P() { - return J(g.VERIFYING), je().then((n) => (he(n), E("challenge", n), Ve(n))).then(({ data: n, solution: d }) => { - if (E("solution", d), (d == null ? void 0 : d.number) !== void 0) - E("verified"), r(5, j = g.VERIFIED), r(6, h = !0), r(4, F = Ae(n, d)), E("payload", F), st().then(() => { - k("verified", { payload: F }); - }); - else - throw E("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); - }).catch((n) => { - E(n), r(5, j = g.ERROR), r(6, h = !1), r(8, te = n.message); + async function qe(r) { + if (!y) + throw new Error("Attribute verifyurl not set."); + $("requesting server verification from", y); + const h = { payload: r }; + if (k) { + const { email: S, expectedLanguages: H, expectedCountries: ne, fields: re, ipAddress: T, timeZone: ie } = typeof k == "object" ? k : { + email: void 0, + expectedCountries: void 0, + expectedLanguages: void 0, + fields: void 0, + ipAddress: void 0, + timeZone: void 0 + }; + h.ipAddress = T === !1 ? void 0 : T || "auto", h.email = S === !1 ? void 0 : ze(S), h.fields = re === !1 ? void 0 : Qe(re), h.timeZone = ie === !1 ? void 0 : ie || Dt(), h.expectedCountries = ne, h.expectedLanguages = H || (be ? [be] : void 0); + } + const C = await fetch(y, { + body: JSON.stringify(h), + headers: { "content-type": "application/json" }, + method: "POST" + }); + if (C.status !== 200) + throw new Error(`Server responded with ${C.status}.`); + const p = await C.json(); + if (p != null && p.payload && t(4, W = p.payload), I("serververification", p), a && p.classification === "BAD") + throw new Error("SpamFilter returned negative classification."); + } + function xe(r) { + r.auto !== void 0 && (t(0, s = r.auto), s === "onload" && B()), r.expire !== void 0 && (ce(r.expire), t(13, g = r.expire)), r.challenge && (_e(r.challenge), i = r.challenge), r.debug !== void 0 && t(12, R = !!r.debug), r.hidefooter !== void 0 && t(1, j = !!r.hidefooter), r.hidelogo !== void 0 && t(2, Z = !!r.hidelogo), r.maxnumber !== void 0 && t(14, _ = +r.maxnumber), r.mockerror !== void 0 && t(15, F = !!r.mockerror), r.name !== void 0 && t(3, G = r.name), r.refetchonexpire !== void 0 && t(16, V = !!r.refetchonexpire), r.spamfilter !== void 0 && t(17, k = r.spamfilter), r.strings && t(28, l = r.strings), r.test !== void 0 && t(18, m = !!r.test), r.verifyurl !== void 0 && t(19, y = r.verifyurl), r.workers !== void 0 && t(20, d = +r.workers); + } + function te(r = v.UNVERIFIED, h = null) { + clearTimeout(se), t(6, D = !1), t(8, oe = h), t(4, W = null), t(5, O = r); + } + async function B() { + return te(v.VERIFYING), Ue().then((r) => (_e(r), $("challenge", r), Ye(r))).then(({ data: r, solution: h }) => { + if ($("solution", h), (h == null ? void 0 : h.number) !== void 0) { + if (y) + return qe(we(r, h)); + t(4, W = we(r, h)), $("payload", W); + } else + throw $("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); + }).then(() => { + pt().then(() => { + t(5, O = v.VERIFIED), t(6, D = !0), $("verified"), I("verified", { payload: W }); + }); + }).catch((r) => { + $(r), t(5, O = v.ERROR), t(6, D = !1), t(8, oe = r.message); }); } - function Oe() { - h = this.checked, r(6, h); + function et() { + D = this.checked, t(6, D); } - function We(n) { - le[n ? "unshift" : "push"](() => { - x = n, r(7, x); + function tt(r) { + ue[r ? "unshift" : "push"](() => { + ee = r, t(7, ee); }); } - return t.$$set = (n) => { - "auto" in n && r(0, s = n.auto), "challengeurl" in n && r(19, u = n.challengeurl), "challengejson" in n && r(20, a = n.challengejson), "debug" in n && r(12, f = n.debug), "expire" in n && r(13, p = n.expire), "hidefooter" in n && r(1, m = n.hidefooter), "hidelogo" in n && r(2, I = n.hidelogo), "name" in n && r(3, G = n.name), "maxnumber" in n && r(14, M = n.maxnumber), "mockerror" in n && r(15, w = n.mockerror), "refetchonexpire" in n && r(16, Z = n.refetchonexpire), "strings" in n && r(21, A = n.strings), "test" in n && r(17, y = n.test), "workers" in n && r(18, v = n.workers); - }, t.$$.update = () => { - t.$$.dirty[0] & /*challengejson*/ - 1048576 && (i = a ? Ce(a) : void 0), t.$$.dirty[0] & /*strings*/ - 2097152 && r(25, o = A ? Ce(A) : {}), t.$$.dirty[0] & /*parsedStrings*/ - 33554432 && r(9, l = { + return n.$$set = (r) => { + "auto" in r && t(0, s = r.auto), "blockspam" in r && t(21, a = r.blockspam), "challengeurl" in r && t(22, u = r.challengeurl), "challengejson" in r && t(23, f = r.challengejson), "debug" in r && t(12, R = r.debug), "expire" in r && t(13, g = r.expire), "hidefooter" in r && t(1, j = r.hidefooter), "hidelogo" in r && t(2, Z = r.hidelogo), "name" in r && t(3, G = r.name), "maxnumber" in r && t(14, _ = r.maxnumber), "mockerror" in r && t(15, F = r.mockerror), "refetchonexpire" in r && t(16, V = r.refetchonexpire), "spamfilter" in r && t(17, k = r.spamfilter), "strings" in r && t(24, x = r.strings), "test" in r && t(18, m = r.test), "verifyurl" in r && t(19, y = r.verifyurl), "workers" in r && t(20, d = r.workers); + }, n.$$.update = () => { + n.$$.dirty[0] & /*challengejson*/ + 8388608 && (i = f ? Ge(f) : void 0), n.$$.dirty[0] & /*strings*/ + 16777216 && t(28, l = x ? Ge(x) : {}), n.$$.dirty[0] & /*parsedStrings*/ + 268435456 && t(9, o = { 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 - }), t.$$.dirty[0] & /*payload, state*/ - 48 && k("statechange", { payload: F, state: j }); + ...l + }), n.$$.dirty[0] & /*payload, state*/ + 48 && I("statechange", { payload: W, state: O }); }, [ s, - m, - I, - G, - F, j, - h, - x, - te, - l, - He, - Fe, - f, - p, - M, - w, Z, - y, - v, - u, - a, - A, - Pe, - J, - P, + G, + W, + O, + D, + ee, + oe, o, - Oe, - We + Ke, + Je, + R, + g, + _, + F, + V, + k, + m, + y, + d, + a, + u, + f, + x, + xe, + te, + B, + l, + et, + tt ]; } -class Gt extends vt { +class Wt extends Lt { constructor(e) { - super(), bt( + super(), $t( this, e, - Mt, - Tt, - Ke, + Ft, + Pt, + lt, { auto: 0, - challengeurl: 19, - challengejson: 20, + blockspam: 21, + challengeurl: 22, + challengejson: 23, debug: 12, expire: 13, hidefooter: 1, @@ -1071,14 +1149,16 @@ class Gt extends vt { maxnumber: 14, mockerror: 15, refetchonexpire: 16, - strings: 21, - test: 17, - workers: 18, - configure: 22, - reset: 23, - verify: 24 + spamfilter: 17, + strings: 24, + test: 18, + verifyurl: 19, + workers: 20, + configure: 25, + reset: 26, + verify: 27 }, - Et, + Mt, [-1, -1] ); } @@ -1086,97 +1166,115 @@ class Gt extends vt { return this.$$.ctx[0]; } set auto(e) { - this.$$set({ auto: e }), C(); + this.$$set({ auto: e }), E(); + } + get blockspam() { + return this.$$.ctx[21]; + } + set blockspam(e) { + this.$$set({ blockspam: e }), E(); } get challengeurl() { - return this.$$.ctx[19]; + return this.$$.ctx[22]; } set challengeurl(e) { - this.$$set({ challengeurl: e }), C(); + this.$$set({ challengeurl: e }), E(); } get challengejson() { - return this.$$.ctx[20]; + return this.$$.ctx[23]; } set challengejson(e) { - this.$$set({ challengejson: e }), C(); + this.$$set({ challengejson: e }), E(); } get debug() { return this.$$.ctx[12]; } set debug(e) { - this.$$set({ debug: e }), C(); + this.$$set({ debug: e }), E(); } get expire() { return this.$$.ctx[13]; } set expire(e) { - this.$$set({ expire: e }), C(); + this.$$set({ expire: e }), E(); } get hidefooter() { return this.$$.ctx[1]; } set hidefooter(e) { - this.$$set({ hidefooter: e }), C(); + this.$$set({ hidefooter: e }), E(); } get hidelogo() { return this.$$.ctx[2]; } set hidelogo(e) { - this.$$set({ hidelogo: e }), C(); + this.$$set({ hidelogo: e }), E(); } get name() { return this.$$.ctx[3]; } set name(e) { - this.$$set({ name: e }), C(); + this.$$set({ name: e }), E(); } get maxnumber() { return this.$$.ctx[14]; } set maxnumber(e) { - this.$$set({ maxnumber: e }), C(); + this.$$set({ maxnumber: e }), E(); } get mockerror() { return this.$$.ctx[15]; } set mockerror(e) { - this.$$set({ mockerror: e }), C(); + this.$$set({ mockerror: e }), E(); } get refetchonexpire() { return this.$$.ctx[16]; } set refetchonexpire(e) { - this.$$set({ refetchonexpire: e }), C(); + this.$$set({ refetchonexpire: e }), E(); } - get strings() { - return this.$$.ctx[21]; - } - set strings(e) { - this.$$set({ strings: e }), C(); - } - get test() { + get spamfilter() { return this.$$.ctx[17]; } - set test(e) { - this.$$set({ test: e }), C(); + set spamfilter(e) { + this.$$set({ spamfilter: e }), E(); } - get workers() { - return this.$$.ctx[18]; - } - set workers(e) { - this.$$set({ workers: e }), C(); - } - get configure() { - return this.$$.ctx[22]; - } - get reset() { - return this.$$.ctx[23]; - } - get verify() { + get strings() { return this.$$.ctx[24]; } + set strings(e) { + this.$$set({ strings: e }), E(); + } + get test() { + return this.$$.ctx[18]; + } + set test(e) { + this.$$set({ test: e }), E(); + } + get verifyurl() { + return this.$$.ctx[19]; + } + set verifyurl(e) { + this.$$set({ verifyurl: e }), E(); + } + get workers() { + return this.$$.ctx[20]; + } + set workers(e) { + this.$$set({ workers: e }), E(); + } + get configure() { + return this.$$.ctx[25]; + } + get reset() { + return this.$$.ctx[26]; + } + get verify() { + return this.$$.ctx[27]; + } } -customElements.define("altcha-widget", mt(Gt, { auto: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, expire: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, refetchonexpire: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, workers: {} }, [], ["configure", "reset", "verify"], !1)); +customElements.define("altcha-widget", Ct(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: {} }, [], ["configure", "reset", "verify"], !1)); export { - Gt as Altcha + Wt as Altcha }; diff --git a/dist/altcha.umd.cjs b/dist/altcha.umd.cjs index 1570f6c..82b5974 100644 --- a/dist/altcha.umd.cjs +++ b/dist/altcha.umd.cjs @@ -1 +1,2 @@ -(function(N,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(N=typeof globalThis<"u"?globalThis:N||self,w(N.altcha={}))})(this,function(N){"use strict";var St=Object.defineProperty;var jt=(N,w,P)=>w in N?St(N,w,{enumerable:!0,configurable:!0,writable:!0,value:P}):N[w]=P;var S=(N,w,P)=>(jt(N,typeof w!="symbol"?w+"":w,P),P);function w(){}function P(t){return t()}function he(){return Object.create(null)}function K(t){t.forEach(P)}function de(t){return typeof t=="function"}function Ve(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Ze(t){return Object.keys(t).length===0}function b(t,e){t.appendChild(e)}function He(t,e,r){const i=Pe(t);if(!i.getElementById(e)){const o=_("style");o.id=e,o.textContent=r,Fe(i,o)}}function Pe(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Fe(t,e){return b(t.head||t,e),e.sheet}function I(t,e,r){t.insertBefore(e,r||null)}function R(t){t.parentNode&&t.parentNode.removeChild(t)}function _(t){return document.createElement(t)}function V(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Oe(t){return document.createTextNode(t)}function F(){return Oe(" ")}function ne(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 We(t){return Array.from(t.childNodes)}function ge(t,e,r){t.classList.toggle(e,!!r)}function De(t,e,{bubbles:r=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:r,cancelable:i})}function Be(t){const e={};return t.childNodes.forEach(r=>{e[r.slot||"default"]=!0}),e}let J;function z(t){J=t}function ie(){if(!J)throw new Error("Function called outside component initialization");return J}function Ye(t){ie().$$.on_mount.push(t)}function Ue(t){ie().$$.on_destroy.push(t)}function Xe(){const t=ie();return(e,r,{cancelable:i=!1}={})=>{const o=t.$$.callbacks[e];if(o){const l=De(e,r,{cancelable:i});return o.slice().forEach(s=>{s.call(t,l)}),!l.defaultPrevented}return!0}}const W=[],oe=[];let D=[];const be=[],me=Promise.resolve();let le=!1;function ve(){le||(le=!0,me.then(C))}function Ke(){return ve(),me}function se(t){D.push(t)}const ce=new Set;let B=0;function C(){if(B!==0)return;const t=J;do{try{for(;Bt.indexOf(i)===-1?e.push(i):r.push(i)),r.forEach(i=>i()),D=e}const Qe=new Set;function qe(t,e){t&&t.i&&(Qe.delete(t),t.i(e))}function et(t,e,r){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,r),se(()=>{const l=t.$$.on_mount.map(P).filter(de);t.$$.on_destroy?t.$$.on_destroy.push(...l):K(l),t.$$.on_mount=[]}),o.forEach(se)}function tt(t,e){const r=t.$$;r.fragment!==null&&(ze(r.after_update),K(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function rt(t,e){t.$$.dirty[0]===-1&&(W.push(t),ve(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const j=A.length?A[0]:T;return f.ctx&&o(f.ctx[m],f.ctx[m]=j)&&(!f.skip_bound&&f.bound[m]&&f.bound[m](j),y&&rt(t,m)),T}):[],f.update(),y=!0,K(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const m=We(e.target);f.fragment&&f.fragment.l(m),m.forEach(R)}else f.fragment&&f.fragment.c();e.intro&&qe(t.$$.fragment),et(t,e.target,e.anchor),C()}z(a)}let we;typeof HTMLElement=="function"&&(we=class extends HTMLElement{constructor(e,r,i){super();S(this,"$$ctor");S(this,"$$s");S(this,"$$c");S(this,"$$cn",!1);S(this,"$$d",{});S(this,"$$r",!1);S(this,"$$p_d",{});S(this,"$$l",{});S(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=_("slot"),l!=="default"&&c(s,"name",l)},m:function(f,y){I(f,s,y)},d:function(f){f&&R(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const r={},i=Be(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]=Q(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=Q(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 u=this.$$c.$on(l,s);this.$$l_u.set(s,u)}this.$$l={}}}attributeChangedCallback(e,r,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Q(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 Q(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 it(t,e,r,i,o,l){let s=class extends we{constructor(){super(t,r,o),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(a){var f;a=Q(u,a,e),this.$$d[u]=a,(f=this.$$c)==null||f.$set({[u]:a})}})}),i.forEach(u=>{Object.defineProperty(s.prototype,u,{get(){var a;return(a=this.$$c)==null?void 0:a[u]}})}),l&&(s=l(s)),t.element=s,s}class ot{constructor(){S(this,"$$");S(this,"$$set")}$destroy(){tt(this,1),this.$destroy=w}$on(e,r){if(!de(r))return w;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&&!Ze(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const lt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(lt);const _e="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGcodCl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KHQpXS5tYXAoZT0+ZS50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBoKHQsZSxvKXtyZXR1cm4gZyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUodCtlKSkpfWZ1bmN0aW9uIG0odCxlLG89IlNIQS0yNTYiLGk9MWU2LHA9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyO3JldHVybntwcm9taXNlOm5ldyBQcm9taXNlKChzLGMpPT57Y29uc3Qgcj1EYXRlLm5vdygpLGQ9bD0+e2Euc2lnbmFsLmFib3J0ZWR8fGw+aT9zKG51bGwpOmgoZSxsLG8pLnRoZW4odz0+e3c9PT10P3Moe251bWJlcjpsLHRvb2s6RGF0ZS5ub3coKS1yfSk6ZChsKzEpfSkuY2F0Y2goYyl9O2QocCl9KSxjb250cm9sbGVyOmF9fWxldCBuO29ubWVzc2FnZT1hc3luYyB0PT57Y29uc3R7dHlwZTplLHBheWxvYWQ6b309dC5kYXRhO2lmKGU9PT0iYWJvcnQiKW49PW51bGx8fG4uYWJvcnQoKSxuPXZvaWQgMDtlbHNlIGlmKGU9PT0id29yayIpe2NvbnN0e2FsZzppLGNoYWxsZW5nZTpwLG1heDphLHNhbHQ6dSxzdGFydDpzfT1vfHx7fSxjPW0ocCx1LGksYSxzKTtuPWMuY29udHJvbGxlcixjLnByb21pc2UudGhlbihyPT57c2VsZi5wb3N0TWVzc2FnZShyJiZ7Li4ucix3b3JrZXI6ITB9KX0pfX19KSgpOwo=",st=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),pe=typeof window<"u"&&window.Blob&&new Blob([st(_e)],{type:"text/javascript;charset=utf-8"});function ct(t){let e;try{if(e=pe&&(window.URL||window.webkitURL).createObjectURL(pe),!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,"+_e,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const ut=new TextEncoder;function ft(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function at(t,e="SHA-256",r=1e5){const i=Date.now().toString(16);t||(t=Math.round(Math.random()*r));const o=await ye(i,t,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function ye(t,e,r){return ft(await crypto.subtle.digest(r.toUpperCase(),ut.encode(t+e)))}function ht(t,e,r="SHA-256",i=1e6,o=0){const l=new AbortController;return{promise:new Promise((u,a)=>{const f=Date.now(),y=m=>{l.signal.aborted||m>i?u(null):ye(e,m,r).then(T=>{T===t?u({number:m,took:Date.now()-f}):y(m+1)}).catch(a)};y(o)}),controller:l}}var g=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t.EXPIRED="expired",t))(g||{});function dt(t){He(t,"svelte-vuofbg",".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}")}function ke(t){let e,r,i;return{c(){e=V("svg"),r=V("path"),i=V("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-vuofbg"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){I(o,e,l),b(e,r),b(e,i)},d(o){o&&R(e)}}}function gt(t){let e,r=t[9].label+"",i;return{c(){e=_("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-vuofbg")},m(o,l){I(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&&R(e)}}}function bt(t){let e,r=t[9].verifying+"";return{c(){e=_("span")},m(i,o){I(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].verifying+"")&&(e.innerHTML=r)},d(i){i&&R(e)}}}function mt(t){let e,r=t[9].verified+"",i,o;return{c(){e=_("span"),i=F(),o=_("input"),c(o,"type","hidden"),c(o,"name",t[3]),o.value=t[4]},m(l,s){I(l,e,s),e.innerHTML=r,I(l,i,s),I(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&&(R(e),R(i),R(o))}}}function $e(t){let e,r,i,o,l,s;return{c(){e=_("div"),r=_("a"),i=V("svg"),o=V("path"),l=V("path"),s=V("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",Ce),c(r,"target","_blank"),c(r,"class","altcha-logo svelte-vuofbg")},m(u,a){I(u,e,a),b(e,r),b(r,i),b(i,o),b(i,l),b(i,s)},p:w,d(u){u&&R(e)}}}function xe(t){let e,r,i,o;function l(a,f){return a[5]===g.EXPIRED?wt:vt}let s=l(t),u=s(t);return{c(){e=_("div"),r=V("svg"),i=V("path"),o=F(),u.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-vuofbg")},m(a,f){I(a,e,f),b(e,r),b(r,i),b(e,o),u.m(e,null)},p(a,f){s===(s=l(a))&&u?u.p(a,f):(u.d(1),u=s(a),u&&(u.c(),u.m(e,null)))},d(a){a&&R(e),u.d()}}}function vt(t){let e,r=t[9].error+"";return{c(){e=_("div"),c(e,"title",t[8])},m(i,o){I(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&&R(e)}}}function wt(t){let e,r=t[9].expired+"";return{c(){e=_("div"),c(e,"title",t[8])},m(i,o){I(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&&R(e)}}}function Ee(t){let e,r,i=t[9].footer+"";return{c(){e=_("div"),r=_("div"),c(r,"class","svelte-vuofbg"),c(e,"class","altcha-footer svelte-vuofbg")},m(o,l){I(o,e,l),b(e,r),r.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(r.innerHTML=i)},d(o){o&&R(e)}}}function _t(t){let e,r,i,o,l,s,u,a,f,y,m,T,A,j,p=t[5]===g.VERIFYING&&ke();function O(h,E){return h[5]===g.VERIFIED?mt:h[5]===g.VERIFYING?bt:gt}let Z=O(t),k=Z(t),v=t[2]!==!0&&$e(),$=(t[8]||t[5]===g.EXPIRED)&&xe(t),x=t[9].footer&&t[1]!==!0&&Ee(t);return{c(){e=_("div"),r=_("div"),p&&p.c(),i=F(),o=_("div"),l=_("input"),a=F(),f=_("div"),k.c(),y=F(),v&&v.c(),m=F(),$&&$.c(),T=F(),x&&x.c(),c(l,"type","checkbox"),c(l,"id",s=t[3]+"_checkbox"),l.required=u=t[0]!=="onsubmit",c(l,"class","svelte-vuofbg"),c(o,"class","altcha-checkbox svelte-vuofbg"),ge(o,"altcha-hidden",t[5]===g.VERIFYING),c(f,"class","altcha-label svelte-vuofbg"),c(r,"class","altcha-main svelte-vuofbg"),c(e,"class","altcha svelte-vuofbg"),c(e,"data-state",t[5])},m(h,E){I(h,e,E),b(e,r),p&&p.m(r,null),b(r,i),b(r,o),b(o,l),l.checked=t[6],b(r,a),b(r,f),k.m(f,null),b(r,y),v&&v.m(r,null),b(e,m),$&&$.m(e,null),b(e,T),x&&x.m(e,null),t[27](e),A||(j=[ne(l,"change",t[26]),ne(l,"change",t[10]),ne(l,"invalid",t[11])],A=!0)},p(h,E){h[5]===g.VERIFYING?p||(p=ke(),p.c(),p.m(r,i)):p&&(p.d(1),p=null),E[0]&8&&s!==(s=h[3]+"_checkbox")&&c(l,"id",s),E[0]&1&&u!==(u=h[0]!=="onsubmit")&&(l.required=u),E[0]&64&&(l.checked=h[6]),E[0]&32&&ge(o,"altcha-hidden",h[5]===g.VERIFYING),Z===(Z=O(h))&&k?k.p(h,E):(k.d(1),k=Z(h),k&&(k.c(),k.m(f,null))),h[2]!==!0?v?v.p(h,E):(v=$e(),v.c(),v.m(r,null)):v&&(v.d(1),v=null),h[8]||h[5]===g.EXPIRED?$?$.p(h,E):($=xe(h),$.c(),$.m(e,T)):$&&($.d(1),$=null),h[9].footer&&h[1]!==!0?x?x.p(h,E):(x=Ee(h),x.c(),x.m(e,null)):x&&(x.d(1),x=null),E[0]&32&&c(e,"data-state",h[5])},i:w,o:w,d(h){h&&R(e),p&&p.d(),k.d(),v&&v.d(),$&&$.d(),x&&x.d(),t[27](null),A=!1,K(j)}}}const Ce="https://altcha.org/";function Le(t){return JSON.parse(t)}function pt(t,e,r){let i,o,l,{auto:s=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:a=void 0}=e,{debug:f=!1}=e,{expire:y=void 0}=e,{hidefooter:m=!1}=e,{hidelogo:T=!1}=e,{name:A="altcha"}=e,{maxnumber:j=1e6}=e,{mockerror:p=!1}=e,{refetchonexpire:O=!0}=e,{strings:Z=void 0}=e,{test:k=!1}=e,{workers:v=navigator.hardwareConcurrency||8}=e;const $=Xe(),x=["SHA-256","SHA-384","SHA-512"];let h=!1,E,M=null,ue=null,Y=null,H=g.UNVERIFIED,fe;Ue(()=>{M&&(M.removeEventListener("submit",Ie),M.removeEventListener("reset",Ne),M=null)}),Ye(()=>{L("mounted","0.2.3"),L("workers",v),k&&L("using test mode"),y&&ae(y),s!==void 0&&L("auto",s),M=E.closest("form"),M&&(M.addEventListener("submit",Ie),M.addEventListener("reset",Ne)),s==="onload"&&U()});function L(...n){(f||n.some(d=>d instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Ie(n){M&&s==="onsubmit"&&H===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),U().then(()=>{M==null||M.requestSubmit()}))}function Ne(){q()}function yt(n,d){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:d.number,salt:n.salt,signature:n.signature,test:k?!0:void 0,took:d.took}))}function Te(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(!x.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${x.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 kt(){if(p)throw L("mocking error"),new Error("Mocked error.");if(i)return L("using provided json data"),i;if(k)return L("generating test challenge"),at();{if(!u)throw new Error("Attribute challengeurl not set.");L("fetching challenge from",u);const n=await fetch(u);if(n.status!==200)throw new Error(`Server responded with ${n.status}.`);const d=n.headers.get("Expires");if(!y&&(d!=null&&d.length)){const X=Date.parse(d);if(X){const ee=X-Date.now();ee>0&&ae(ee)}}return n.json()}}function Me(){u&&O&&H===g.VERIFIED?U():q(g.EXPIRED,l.expired)}async function $t(n){let d=null;if("Worker"in window){try{d=await xt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(X){L(X)}if((d==null?void 0:d.number)!==void 0)return{data:n,solution:d}}return{data:n,solution:await ht(n.challenge,n.salt,n.algorithm,n.maxnumber||j).promise}}async function xt(n,d,X,ee=j,te=Math.ceil(v)){const re=[];if(te<1)throw new Error("Wrong number of workers configured.");if(te>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let G=0;G{const je=Tt*Se;return new Promise(Mt=>{G.addEventListener("message",Ae=>{if(Ae.data)for(const Ge of re)Ge!==G&&Ge.postMessage({type:"abort"});Mt(Ae.data)}),G.postMessage({payload:{alg:X,challenge:n,max:je+Se,salt:d,start:je},type:"work"})})}));for(const G of re)G.terminate();return Nt.find(G=>!!G)||null}function Et(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(H)?U():r(6,h=!0)}function Ct(){H===g.VERIFYING&&alert(l.waitAlert)}function ae(n){L("expire",n),clearTimeout(fe),n<1?Me():fe=setTimeout(Me,n)}function Lt(n){n.auto!==void 0&&(r(0,s=n.auto),s==="onload"&&U()),n.expire!==void 0&&(ae(n.expire),r(13,y=n.expire)),n.challenge&&(Te(n.challenge),i=n.challenge),n.debug!==void 0&&r(12,f=!!n.debug),n.hidefooter!==void 0&&r(1,m=!!n.hidefooter),n.hidelogo!==void 0&&r(2,T=!!n.hidelogo),n.maxnumber!==void 0&&r(14,j=+n.maxnumber),n.mockerror!==void 0&&r(15,p=!!n.mockerror),n.name!==void 0&&r(3,A=n.name),n.refetchonexpire!==void 0&&r(16,O=!!n.refetchonexpire),n.strings&&r(25,o=n.strings),n.test!==void 0&&r(17,k=!!n.test),n.workers!==void 0&&r(18,v=+n.workers)}function q(n=g.UNVERIFIED,d=null){clearTimeout(fe),r(6,h=!1),r(8,ue=d),r(4,Y=null),r(5,H=n)}async function U(){return q(g.VERIFYING),kt().then(n=>(Te(n),L("challenge",n),$t(n))).then(({data:n,solution:d})=>{if(L("solution",d),(d==null?void 0:d.number)!==void 0)L("verified"),r(5,H=g.VERIFIED),r(6,h=!0),r(4,Y=yt(n,d)),L("payload",Y),Ke().then(()=>{$("verified",{payload:Y})});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.")}).catch(n=>{L(n),r(5,H=g.ERROR),r(6,h=!1),r(8,ue=n.message)})}function Rt(){h=this.checked,r(6,h)}function It(n){oe[n?"unshift":"push"](()=>{E=n,r(7,E)})}return t.$$set=n=>{"auto"in n&&r(0,s=n.auto),"challengeurl"in n&&r(19,u=n.challengeurl),"challengejson"in n&&r(20,a=n.challengejson),"debug"in n&&r(12,f=n.debug),"expire"in n&&r(13,y=n.expire),"hidefooter"in n&&r(1,m=n.hidefooter),"hidelogo"in n&&r(2,T=n.hidelogo),"name"in n&&r(3,A=n.name),"maxnumber"in n&&r(14,j=n.maxnumber),"mockerror"in n&&r(15,p=n.mockerror),"refetchonexpire"in n&&r(16,O=n.refetchonexpire),"strings"in n&&r(21,Z=n.strings),"test"in n&&r(17,k=n.test),"workers"in n&&r(18,v=n.workers)},t.$$.update=()=>{t.$$.dirty[0]&1048576&&(i=a?Le(a):void 0),t.$$.dirty[0]&2097152&&r(25,o=Z?Le(Z):{}),t.$$.dirty[0]&33554432&&r(9,l={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&&$("statechange",{payload:Y,state:H})},[s,m,T,A,Y,H,h,E,ue,l,Et,Ct,f,y,j,p,O,k,v,u,a,Z,Lt,q,U,o,Rt,It]}class Re extends ot{constructor(e){super(),nt(this,e,pt,_t,Ve,{auto:0,challengeurl:19,challengejson:20,debug:12,expire:13,hidefooter:1,hidelogo:2,name:3,maxnumber:14,mockerror:15,refetchonexpire:16,strings:21,test:17,workers:18,configure:22,reset:23,verify:24},dt,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),C()}get challengeurl(){return this.$$.ctx[19]}set challengeurl(e){this.$$set({challengeurl:e}),C()}get challengejson(){return this.$$.ctx[20]}set challengejson(e){this.$$set({challengejson:e}),C()}get debug(){return this.$$.ctx[12]}set debug(e){this.$$set({debug:e}),C()}get expire(){return this.$$.ctx[13]}set expire(e){this.$$set({expire:e}),C()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),C()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),C()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),C()}get maxnumber(){return this.$$.ctx[14]}set maxnumber(e){this.$$set({maxnumber:e}),C()}get mockerror(){return this.$$.ctx[15]}set mockerror(e){this.$$set({mockerror:e}),C()}get refetchonexpire(){return this.$$.ctx[16]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),C()}get strings(){return this.$$.ctx[21]}set strings(e){this.$$set({strings:e}),C()}get test(){return this.$$.ctx[17]}set test(e){this.$$set({test:e}),C()}get workers(){return this.$$.ctx[18]}set workers(e){this.$$set({workers:e}),C()}get configure(){return this.$$.ctx[22]}get reset(){return this.$$.ctx[23]}get verify(){return this.$$.ctx[24]}}customElements.define("altcha-widget",it(Re,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},strings:{},test:{type:"Boolean"},workers:{}},[],["configure","reset","verify"],!1)),N.Altcha=Re,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}); +(function(M,$){typeof exports=="object"&&typeof module<"u"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(M=typeof globalThis<"u"?globalThis:M||self,$(M.altcha={}))})(this,function(M){"use strict";var Wt=Object.defineProperty;var Bt=(M,$,W)=>$ in M?Wt(M,$,{enumerable:!0,configurable:!0,writable:!0,value:W}):M[$]=W;var G=(M,$,W)=>(Bt(M,typeof $!="symbol"?$+"":$,W),W);function $(){}function W(n){return n()}function pe(){return Object.create(null)}function q(n){n.forEach(W)}function ye(n){return typeof n=="function"}function Xe(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Ke(n){return Object.keys(n).length===0}function w(n,e){n.appendChild(e)}function Je(n,e,t){const i=ze(n);if(!i.getElementById(e)){const l=C("style");l.id=e,l.textContent=t,Qe(i,l)}}function ze(n){if(!n)return document;const e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Qe(n,e){return w(n.head||n,e),e.sheet}function N(n,e,t){n.insertBefore(e,t||null)}function T(n){n.parentNode&&n.parentNode.removeChild(n)}function C(n){return document.createElement(n)}function O(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function qe(n){return document.createTextNode(n)}function U(){return qe(" ")}function ce(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function c(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function et(n){return Array.from(n.childNodes)}function ve(n,e,t){n.classList.toggle(e,!!t)}function tt(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function nt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ee;function te(n){ee=n}function ae(){if(!ee)throw new Error("Function called outside component initialization");return ee}function rt(n){ae().$$.on_mount.push(n)}function it(n){ae().$$.on_destroy.push(n)}function lt(){const n=ae();return(e,t,{cancelable:i=!1}={})=>{const l=n.$$.callbacks[e];if(l){const o=tt(e,t,{cancelable:i});return l.slice().forEach(s=>{s.call(n,o)}),!o.defaultPrevented}return!0}}const J=[],fe=[];let z=[];const we=[],_e=Promise.resolve();let ue=!1;function ke(){ue||(ue=!0,_e.then(_))}function ot(){return ke(),_e}function he(n){z.push(n)}const de=new Set;let Q=0;function _(){if(Q!==0)return;const n=ee;do{try{for(;Qn.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),z=e}const at=new Set;function ft(n,e){n&&n.i&&(at.delete(n),n.i(e))}function ut(n,e,t){const{fragment:i,after_update:l}=n.$$;i&&i.m(e,t),he(()=>{const o=n.$$.on_mount.map(W).filter(ye);n.$$.on_destroy?n.$$.on_destroy.push(...o):q(o),n.$$.on_mount=[]}),l.forEach(he)}function ht(n,e){const t=n.$$;t.fragment!==null&&(ct(t.after_update),q(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function dt(n,e){n.$$.dirty[0]===-1&&(J.push(n),ke(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const H=V.length?V[0]:Z;return f.ctx&&l(f.ctx[g],f.ctx[g]=H)&&(!f.skip_bound&&f.bound[g]&&f.bound[g](H),S&&dt(n,g)),Z}):[],f.update(),S=!0,q(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const g=et(e.target);f.fragment&&f.fragment.l(g),g.forEach(T)}else f.fragment&&f.fragment.c();e.intro&&ft(n.$$.fragment),ut(n,e.target,e.anchor),_()}te(u)}let xe;typeof HTMLElement=="function"&&(xe=class extends HTMLElement{constructor(e,t,i){super();G(this,"$$ctor");G(this,"$$s");G(this,"$$c");G(this,"$$cn",!1);G(this,"$$d",{});G(this,"$$r",!1);G(this,"$$p_d",{});G(this,"$$l",{});G(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=C("slot"),o!=="default"&&c(s,"name",o)},m:function(f,S){N(f,s,S)},d:function(f){f&&T(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=nt(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]=ne(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=ne(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 a=this.$$c.$on(o,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,t,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=ne(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 ne(n,e,t,i){var o;const l=(o=t[n])==null?void 0:o.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])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 mt(n,e,t,i,l,o){let s=class extends xe{constructor(){super(n,t,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(u){var f;u=ne(a,u,e),this.$$d[a]=u,(f=this.$$c)==null||f.$set({[a]:u})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var u;return(u=this.$$c)==null?void 0:u[a]}})}),o&&(s=o(s)),n.element=s,s}class bt{constructor(){G(this,"$$");G(this,"$$set")}$destroy(){ht(this,1),this.$destroy=$}$on(e,t){if(!ye(t))return $;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&&!Ke(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 Ee="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGcodCl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KHQpXS5tYXAoZT0+ZS50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBoKHQsZSxvKXtyZXR1cm4gZyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUodCtlKSkpfWZ1bmN0aW9uIG0odCxlLG89IlNIQS0yNTYiLGk9MWU2LHA9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyO3JldHVybntwcm9taXNlOm5ldyBQcm9taXNlKChzLGMpPT57Y29uc3Qgcj1EYXRlLm5vdygpLGQ9bD0+e2Euc2lnbmFsLmFib3J0ZWR8fGw+aT9zKG51bGwpOmgoZSxsLG8pLnRoZW4odz0+e3c9PT10P3Moe251bWJlcjpsLHRvb2s6RGF0ZS5ub3coKS1yfSk6ZChsKzEpfSkuY2F0Y2goYyl9O2QocCl9KSxjb250cm9sbGVyOmF9fWxldCBuO29ubWVzc2FnZT1hc3luYyB0PT57Y29uc3R7dHlwZTplLHBheWxvYWQ6b309dC5kYXRhO2lmKGU9PT0iYWJvcnQiKW49PW51bGx8fG4uYWJvcnQoKSxuPXZvaWQgMDtlbHNlIGlmKGU9PT0id29yayIpe2NvbnN0e2FsZzppLGNoYWxsZW5nZTpwLG1heDphLHNhbHQ6dSxzdGFydDpzfT1vfHx7fSxjPW0ocCx1LGksYSxzKTtuPWMuY29udHJvbGxlcixjLnByb21pc2UudGhlbihyPT57c2VsZi5wb3N0TWVzc2FnZShyJiZ7Li4ucix3b3JrZXI6ITB9KX0pfX19KSgpOwo=",yt=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),$e=typeof window<"u"&&window.Blob&&new Blob([yt(Ee)],{type:"text/javascript;charset=utf-8"});function vt(n){let e;try{if(e=$e&&(window.URL||window.webkitURL).createObjectURL($e),!e)throw"";const t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Ee,{name:n==null?void 0:n.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const wt=new TextEncoder;function _t(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function kt(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const l=await Ce(i,n,e);return{algorithm:e,challenge:l,salt:i,signature:""}}async function Ce(n,e,t){return _t(await crypto.subtle.digest(t.toUpperCase(),wt.encode(n+e)))}function xt(n,e,t="SHA-256",i=1e6,l=0){const o=new AbortController;return{promise:new Promise((a,u)=>{const f=Date.now(),S=g=>{o.signal.aborted||g>i?a(null):Ce(e,g,t).then(Z=>{Z===n?a({number:g,took:Date.now()-f}):S(g+1)}).catch(u)};S(l)}),controller:o}}var y=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(y||{});function Et(n){Je(n,"svelte-14ngypa",`.altcha.svelte-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-14ngypa.svelte-14ngypa{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-14ngypa.svelte-14ngypa{flex-grow:1}.altcha-label.svelte-14ngypa label.svelte-14ngypa{cursor:pointer}.altcha-logo.svelte-14ngypa.svelte-14ngypa{color:currentColor;opacity:0.3}.altcha-logo.svelte-14ngypa.svelte-14ngypa:hover{opacity:1}.altcha-error.svelte-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa{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-14ngypa.svelte-14ngypa:hover{opacity:1}.altcha-footer.svelte-14ngypa>.svelte-14ngypa:first-child{flex-grow:1}.altcha-footer.svelte-14ngypa a{color:currentColor}.altcha-checkbox.svelte-14ngypa.svelte-14ngypa{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-14ngypa input.svelte-14ngypa{width:18px;height:18px;margin:0}.altcha-hidden.svelte-14ngypa.svelte-14ngypa{display:none}.altcha-spinner.svelte-14ngypa.svelte-14ngypa{animation:svelte-14ngypa-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-14ngypa-altcha-spinner{100%{transform:rotate(360deg)}}`)}function Le(n){let e,t,i;return{c(){e=O("svg"),t=O("path"),i=O("path"),c(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(t,"fill","currentColor"),c(t,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-14ngypa"),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){N(l,e,o),w(e,t),w(e,i)},d(l){l&&T(e)}}}function $t(n){let e,t=n[9].label+"",i;return{c(){e=C("label"),c(e,"for",i=n[3]+"_checkbox"),c(e,"class","svelte-14ngypa")},m(l,o){N(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&&T(e)}}}function Ct(n){let e,t=n[9].verifying+"";return{c(){e=C("span")},m(i,l){N(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 Lt(n){let e,t=n[9].verified+"",i,l;return{c(){e=C("span"),i=U(),l=C("input"),c(l,"type","hidden"),c(l,"name",n[3]),l.value=n[4]},m(o,s){N(o,e,s),e.innerHTML=t,N(o,i,s),N(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&&(T(e),T(i),T(l))}}}function Ie(n){let e,t,i,l,o,s;return{c(){e=C("div"),t=C("a"),i=O("svg"),l=O("path"),o=O("path"),s=O("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 svelte-14ngypa")},m(a,u){N(a,e,u),w(e,t),w(t,i),w(i,l),w(i,o),w(i,s)},p:$,d(a){a&&T(e)}}}function Re(n){let e,t,i,l;function o(u,f){return u[5]===y.EXPIRED?Rt:It}let s=o(n),a=s(n);return{c(){e=C("div"),t=O("svg"),i=O("path"),l=U(),a.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-14ngypa")},m(u,f){N(u,e,f),w(e,t),w(t,i),w(e,l),a.m(e,null)},p(u,f){s===(s=o(u))&&a?a.p(u,f):(a.d(1),a=s(u),a&&(a.c(),a.m(e,null)))},d(u){u&&T(e),a.d()}}}function It(n){let e,t=n[9].error+"";return{c(){e=C("div"),c(e,"title",n[8])},m(i,l){N(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&&T(e)}}}function Rt(n){let e,t=n[9].expired+"";return{c(){e=C("div"),c(e,"title",n[8])},m(i,l){N(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&&T(e)}}}function Se(n){let e,t,i=n[9].footer+"";return{c(){e=C("div"),t=C("div"),c(t,"class","svelte-14ngypa"),c(e,"class","altcha-footer svelte-14ngypa")},m(l,o){N(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 St(n){let e,t,i,l,o,s,a,u,f,S,g,Z,V,H,k=n[5]===y.VERIFYING&&Le();function Y(d,R){return d[5]===y.VERIFIED?Lt:d[5]===y.VERIFYING?Ct:$t}let P=Y(n),x=P(n),E=n[2]!==!0&&Ie(),m=(n[8]||n[5]===y.EXPIRED)&&Re(n),v=n[9].footer&&n[1]!==!0&&Se(n);return{c(){e=C("div"),t=C("div"),k&&k.c(),i=U(),l=C("div"),o=C("input"),u=U(),f=C("div"),x.c(),S=U(),E&&E.c(),g=U(),m&&m.c(),Z=U(),v&&v.c(),c(o,"type","checkbox"),c(o,"id",s=n[3]+"_checkbox"),o.required=a=n[0]!=="onsubmit",c(o,"class","svelte-14ngypa"),c(l,"class","altcha-checkbox svelte-14ngypa"),ve(l,"altcha-hidden",n[5]===y.VERIFYING),c(f,"class","altcha-label svelte-14ngypa"),c(t,"class","altcha-main svelte-14ngypa"),c(e,"class","altcha svelte-14ngypa"),c(e,"data-state",n[5])},m(d,R){N(d,e,R),w(e,t),k&&k.m(t,null),w(t,i),w(t,l),w(l,o),o.checked=n[6],w(t,u),w(t,f),x.m(f,null),w(t,S),E&&E.m(t,null),w(e,g),m&&m.m(e,null),w(e,Z),v&&v.m(e,null),n[30](e),V||(H=[ce(o,"change",n[29]),ce(o,"change",n[10]),ce(o,"invalid",n[11])],V=!0)},p(d,R){d[5]===y.VERIFYING?k||(k=Le(),k.c(),k.m(t,i)):k&&(k.d(1),k=null),R[0]&8&&s!==(s=d[3]+"_checkbox")&&c(o,"id",s),R[0]&1&&a!==(a=d[0]!=="onsubmit")&&(o.required=a),R[0]&64&&(o.checked=d[6]),R[0]&32&&ve(l,"altcha-hidden",d[5]===y.VERIFYING),P===(P=Y(d))&&x?x.p(d,R):(x.d(1),x=P(d),x&&(x.c(),x.m(f,null))),d[2]!==!0?E?E.p(d,R):(E=Ie(),E.c(),E.m(t,null)):E&&(E.d(1),E=null),d[8]||d[5]===y.EXPIRED?m?m.p(d,R):(m=Re(d),m.c(),m.m(e,Z)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?v?v.p(d,R):(v=Se(d),v.c(),v.m(e,null)):v&&(v.d(1),v=null),R[0]&32&&c(e,"data-state",d[5])},i:$,o:$,d(d){d&&T(e),k&&k.d(),x.d(),E&&E.d(),m&&m.d(),v&&v.d(),n[30](null),V=!1,q(H)}}}const Te="https://altcha.org/";function Ne(n){return JSON.parse(n)}function Tt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Nt(n,e,t){var Fe,We;let i,l,o,{auto:s=void 0}=e,{blockspam:a=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:f=void 0}=e,{debug:S=!1}=e,{expire:g=void 0}=e,{hidefooter:Z=!1}=e,{hidelogo:V=!1}=e,{name:H="altcha"}=e,{maxnumber:k=1e6}=e,{mockerror:Y=!1}=e,{refetchonexpire:P=!0}=e,{spamfilter:x=!1}=e,{strings:E=void 0}=e,{test:m=!1}=e,{verifyurl:v=void 0}=e,{workers:d=navigator.hardwareConcurrency||8}=e;const R=lt(),je=["SHA-256","SHA-384","SHA-512"],Me=(We=(Fe=document.documentElement.lang)==null?void 0:Fe.split("-"))==null?void 0:We[0];let B=!1,re,b=null,ge=null,X=null,D=y.UNVERIFIED,me;it(()=>{b&&(b.removeEventListener("submit",Ge),b.removeEventListener("reset",Ve),b.removeEventListener("focusin",Ze),b=null)}),rt(()=>{L("mounted","0.2.3"),L("workers",d),m&&L("using test mode"),g&&be(g),s!==void 0&&L("auto",s),b=re.closest("form"),b&&(b.addEventListener("submit",Ge),b.addEventListener("reset",Ve),s==="onfocus"&&b.addEventListener("focusin",Ze)),s==="onload"&&K()});function L(...r){(S||r.some(h=>h instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",...r)}function Ze(r){K()}function Ge(r){b&&s==="onsubmit"&&D===y.UNVERIFIED&&(r.preventDefault(),r.stopPropagation(),K().then(()=>{b==null||b.requestSubmit()}))}function Ve(){ie()}function Oe(r,h){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:h.number,salt:r.salt,signature:r.signature,test:m?!0:void 0,took:h.took}))}function He(r){if(!r.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(r.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!je.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${je.join(", ")}`);if(!r.challenge||r.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!r.salt||r.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function At(){if(Y)throw L("mocking error"),new Error("Mocked error.");if(i)return L("using provided json data"),i;if(m)return L("generating test challenge"),kt(typeof m!="boolean"?+m:void 0);{if(!u)throw new Error("Attribute challengeurl not set.");L("fetching challenge from",u);const r=await fetch(u,{headers:{"x-altcha-spam-filter":x?"1":"0"}});if(r.status!==200)throw new Error(`Server responded with ${r.status}.`);const h=r.headers.get("Expires"),I=r.headers.get("X-Altcha-Config");if(I)try{const p=JSON.parse(I);p&&typeof p=="object"&&(p.verifyurl&&(p.verifyurl=new URL(p.verifyurl,new URL(u)).toString()),De(p))}catch(p){L("unable to configure from X-Altcha-Config",p)}if(!g&&(h!=null&&h.length)){const p=Date.parse(h);if(p){const A=p-Date.now();A>0&&be(A)}}return r.json()}}function Pe(){u&&P&&D===y.VERIFIED?K():ie(y.EXPIRED,o.expired)}async function jt(r){let h=null;if("Worker"in window){try{h=await Mt(r.challenge,r.salt,r.algorithm,r.maxnumber)}catch(I){L(I)}if((h==null?void 0:h.number)!==void 0)return{data:r,solution:h}}return{data:r,solution:await xt(r.challenge,r.salt,r.algorithm,r.maxnumber||k).promise}}async function Mt(r,h,I,p=k,A=Math.ceil(d)){const F=[];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 j=0;j{const Be=se*le;return new Promise(Ft=>{j.addEventListener("message",Ue=>{if(Ue.data)for(const Ye of F)Ye!==j&&Ye.postMessage({type:"abort"});Ft(Ue.data)}),j.postMessage({payload:{alg:I,challenge:r,max:Be+le,salt:h,start:Be},type:"work"})})}));for(const j of F)j.terminate();return oe.find(j=>!!j)||null}function Zt(){[y.UNVERIFIED,y.ERROR,y.EXPIRED].includes(D)?x&&(b==null?void 0:b.reportValidity())===!1?t(6,B=!1):K():t(6,B=!0)}function Gt(){D===y.VERIFYING&&alert(o.waitAlert)}function be(r){L("expire",r),clearTimeout(me),r<1?Pe():me=setTimeout(Pe,r)}function Vt(r){var I;const h=b==null?void 0:b.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((I=h==null?void 0:h.value)==null?void 0:I.slice(h.value.indexOf("@")))||void 0}function Ot(r){return[...(b==null?void 0:b.querySelectorAll(r!=null&&r.length?r.map(I=>`input[name="${I}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((I,p)=>{const A=p.name,F=p.value.trim();return A&&F&&(I[A]=F),I},{})}async function Ht(r){if(!v)throw new Error("Attribute verifyurl not set.");L("requesting server verification from",v);const h={payload:r};if(x){const{email:A,expectedLanguages:F,expectedCountries:le,fields:oe,ipAddress:j,timeZone:se}=typeof x=="object"?x:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};h.ipAddress=j===!1?void 0:j||"auto",h.email=A===!1?void 0:Vt(A),h.fields=oe===!1?void 0:Ot(oe),h.timeZone=se===!1?void 0:se||Tt(),h.expectedCountries=le,h.expectedLanguages=F||(Me?[Me]:void 0)}const I=await fetch(v,{body:JSON.stringify(h),headers:{"content-type":"application/json"},method:"POST"});if(I.status!==200)throw new Error(`Server responded with ${I.status}.`);const p=await I.json();if(p!=null&&p.payload&&t(4,X=p.payload),R("serververification",p),a&&p.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function De(r){r.auto!==void 0&&(t(0,s=r.auto),s==="onload"&&K()),r.expire!==void 0&&(be(r.expire),t(13,g=r.expire)),r.challenge&&(He(r.challenge),i=r.challenge),r.debug!==void 0&&t(12,S=!!r.debug),r.hidefooter!==void 0&&t(1,Z=!!r.hidefooter),r.hidelogo!==void 0&&t(2,V=!!r.hidelogo),r.maxnumber!==void 0&&t(14,k=+r.maxnumber),r.mockerror!==void 0&&t(15,Y=!!r.mockerror),r.name!==void 0&&t(3,H=r.name),r.refetchonexpire!==void 0&&t(16,P=!!r.refetchonexpire),r.spamfilter!==void 0&&t(17,x=r.spamfilter),r.strings&&t(28,l=r.strings),r.test!==void 0&&t(18,m=!!r.test),r.verifyurl!==void 0&&t(19,v=r.verifyurl),r.workers!==void 0&&t(20,d=+r.workers)}function ie(r=y.UNVERIFIED,h=null){clearTimeout(me),t(6,B=!1),t(8,ge=h),t(4,X=null),t(5,D=r)}async function K(){return ie(y.VERIFYING),At().then(r=>(He(r),L("challenge",r),jt(r))).then(({data:r,solution:h})=>{if(L("solution",h),(h==null?void 0:h.number)!==void 0){if(v)return Ht(Oe(r,h));t(4,X=Oe(r,h)),L("payload",X)}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(()=>{ot().then(()=>{t(5,D=y.VERIFIED),t(6,B=!0),L("verified"),R("verified",{payload:X})})}).catch(r=>{L(r),t(5,D=y.ERROR),t(6,B=!1),t(8,ge=r.message)})}function Pt(){B=this.checked,t(6,B)}function Dt(r){fe[r?"unshift":"push"](()=>{re=r,t(7,re)})}return n.$$set=r=>{"auto"in r&&t(0,s=r.auto),"blockspam"in r&&t(21,a=r.blockspam),"challengeurl"in r&&t(22,u=r.challengeurl),"challengejson"in r&&t(23,f=r.challengejson),"debug"in r&&t(12,S=r.debug),"expire"in r&&t(13,g=r.expire),"hidefooter"in r&&t(1,Z=r.hidefooter),"hidelogo"in r&&t(2,V=r.hidelogo),"name"in r&&t(3,H=r.name),"maxnumber"in r&&t(14,k=r.maxnumber),"mockerror"in r&&t(15,Y=r.mockerror),"refetchonexpire"in r&&t(16,P=r.refetchonexpire),"spamfilter"in r&&t(17,x=r.spamfilter),"strings"in r&&t(24,E=r.strings),"test"in r&&t(18,m=r.test),"verifyurl"in r&&t(19,v=r.verifyurl),"workers"in r&&t(20,d=r.workers)},n.$$.update=()=>{n.$$.dirty[0]&8388608&&(i=f?Ne(f):void 0),n.$$.dirty[0]&16777216&&t(28,l=E?Ne(E):{}),n.$$.dirty[0]&268435456&&t(9,o={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}),n.$$.dirty[0]&48&&R("statechange",{payload:X,state:D})},[s,Z,V,H,X,D,B,re,ge,o,Zt,Gt,S,g,k,Y,P,x,m,v,d,a,u,f,E,De,ie,K,l,Pt,Dt]}class Ae extends bt{constructor(e){super(),gt(this,e,Nt,St,Xe,{auto:0,blockspam:21,challengeurl:22,challengejson:23,debug:12,expire:13,hidefooter:1,hidelogo:2,name:3,maxnumber:14,mockerror:15,refetchonexpire:16,spamfilter:17,strings:24,test:18,verifyurl:19,workers:20,configure:25,reset:26,verify:27},Et,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),_()}get blockspam(){return this.$$.ctx[21]}set blockspam(e){this.$$set({blockspam:e}),_()}get challengeurl(){return this.$$.ctx[22]}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[12]}set debug(e){this.$$set({debug:e}),_()}get expire(){return this.$$.ctx[13]}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[14]}set maxnumber(e){this.$$set({maxnumber:e}),_()}get mockerror(){return this.$$.ctx[15]}set mockerror(e){this.$$set({mockerror:e}),_()}get refetchonexpire(){return this.$$.ctx[16]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),_()}get spamfilter(){return this.$$.ctx[17]}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[18]}set test(e){this.$$set({test:e}),_()}get verifyurl(){return this.$$.ctx[19]}set verifyurl(e){this.$$set({verifyurl:e}),_()}get workers(){return this.$$.ctx[20]}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]}}customElements.define("altcha-widget",mt(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)),M.Altcha=Ae,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})}); diff --git a/index.html b/index.html index b6c5f0a..e55328a 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Vite + Svelte + TS + ALTCHA
diff --git a/package-lock.json b/package-lock.json index 64b17bc..cd9ea2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "altcha", - "version": "0.2.0", + "version": "0.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "altcha", - "version": "0.2.0", + "version": "0.2.3", "license": "MIT", "devDependencies": { "@playwright/test": "^1.41.2", @@ -17,6 +17,8 @@ "cors": "^2.8.5", "express": "^4.18.2", "husky": "^9.0.11", + "prettier": "3.2.5", + "prettier-plugin-svelte": "^3.2.3", "sass": "^1.71.1", "svelte": "^4.2.11", "svelte-check": "^3.4.6", @@ -40,9 +42,9 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz", - "integrity": "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.2.tgz", + "integrity": "sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==", "cpu": [ "ppc64" ], @@ -56,9 +58,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.12.tgz", - "integrity": "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.2.tgz", + "integrity": "sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==", "cpu": [ "arm" ], @@ -72,9 +74,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz", - "integrity": "sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.2.tgz", + "integrity": "sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==", "cpu": [ "arm64" ], @@ -88,9 +90,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.12.tgz", - "integrity": "sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.2.tgz", + "integrity": "sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==", "cpu": [ "x64" ], @@ -104,9 +106,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz", - "integrity": "sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==", + "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==", "cpu": [ "arm64" ], @@ -120,9 +122,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz", - "integrity": "sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.2.tgz", + "integrity": "sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==", "cpu": [ "x64" ], @@ -136,9 +138,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz", - "integrity": "sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.2.tgz", + "integrity": "sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==", "cpu": [ "arm64" ], @@ -152,9 +154,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz", - "integrity": "sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.2.tgz", + "integrity": "sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==", "cpu": [ "x64" ], @@ -168,9 +170,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz", - "integrity": "sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.2.tgz", + "integrity": "sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==", "cpu": [ "arm" ], @@ -184,9 +186,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz", - "integrity": "sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==", + "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==", "cpu": [ "arm64" ], @@ -200,9 +202,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz", - "integrity": "sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.2.tgz", + "integrity": "sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==", "cpu": [ "ia32" ], @@ -216,9 +218,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz", - "integrity": "sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.2.tgz", + "integrity": "sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==", "cpu": [ "loong64" ], @@ -232,9 +234,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz", - "integrity": "sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.2.tgz", + "integrity": "sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==", "cpu": [ "mips64el" ], @@ -248,9 +250,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz", - "integrity": "sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.2.tgz", + "integrity": "sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==", "cpu": [ "ppc64" ], @@ -264,9 +266,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz", - "integrity": "sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.2.tgz", + "integrity": "sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==", "cpu": [ "riscv64" ], @@ -280,9 +282,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz", - "integrity": "sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.2.tgz", + "integrity": "sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==", "cpu": [ "s390x" ], @@ -296,9 +298,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz", - "integrity": "sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.2.tgz", + "integrity": "sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==", "cpu": [ "x64" ], @@ -312,9 +314,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz", - "integrity": "sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.2.tgz", + "integrity": "sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==", "cpu": [ "x64" ], @@ -328,9 +330,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz", - "integrity": "sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.2.tgz", + "integrity": "sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==", "cpu": [ "x64" ], @@ -344,9 +346,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz", - "integrity": "sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.2.tgz", + "integrity": "sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==", "cpu": [ "x64" ], @@ -360,9 +362,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz", - "integrity": "sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.2.tgz", + "integrity": "sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==", "cpu": [ "arm64" ], @@ -376,9 +378,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz", - "integrity": "sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.2.tgz", + "integrity": "sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==", "cpu": [ "ia32" ], @@ -392,9 +394,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz", - "integrity": "sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.2.tgz", + "integrity": "sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==", "cpu": [ "x64" ], @@ -518,9 +520,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.12.0.tgz", - "integrity": "sha512-+ac02NL/2TCKRrJu2wffk1kZ+RyqxVUlbjSagNgPm94frxtr+XDL12E5Ll1enWskLrtrZ2r8L3wED1orIibV/w==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.3.tgz", + "integrity": "sha512-X9alQ3XM6I9IlSlmC8ddAvMSyG1WuHk5oUnXGw+yUBs3BFoTizmG1La/Gr8fVJvDWAq+zlYTZ9DBgrlKRVY06g==", "cpu": [ "arm" ], @@ -531,9 +533,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.12.0.tgz", - "integrity": "sha512-OBqcX2BMe6nvjQ0Nyp7cC90cnumt8PXmO7Dp3gfAju/6YwG0Tj74z1vKrfRz7qAv23nBcYM8BCbhrsWqO7PzQQ==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.3.tgz", + "integrity": "sha512-eQK5JIi+POhFpzk+LnjKIy4Ks+pwJ+NXmPxOCSvOKSNRPONzKuUvWE+P9JxGZVxrtzm6BAYMaL50FFuPe0oWMQ==", "cpu": [ "arm64" ], @@ -544,9 +546,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.12.0.tgz", - "integrity": "sha512-X64tZd8dRE/QTrBIEs63kaOBG0b5GVEd3ccoLtyf6IdXtHdh8h+I56C2yC3PtC9Ucnv0CpNFJLqKFVgCYe0lOQ==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.3.tgz", + "integrity": "sha512-Od4vE6f6CTT53yM1jgcLqNfItTsLt5zE46fdPaEmeFHvPs5SjZYlLpHrSiHEKR1+HdRfxuzXHjDOIxQyC3ptBA==", "cpu": [ "arm64" ], @@ -557,9 +559,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.12.0.tgz", - "integrity": "sha512-cc71KUZoVbUJmGP2cOuiZ9HSOP14AzBAThn3OU+9LcA1+IUqswJyR1cAJj3Mg55HbjZP6OLAIscbQsQLrpgTOg==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.3.tgz", + "integrity": "sha512-0IMAO21axJeNIrvS9lSe/PGthc8ZUS+zC53O0VhF5gMxfmcKAP4ESkKOCwEi6u2asUrt4mQv2rjY8QseIEb1aw==", "cpu": [ "x64" ], @@ -570,9 +572,22 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.12.0.tgz", - "integrity": "sha512-a6w/Y3hyyO6GlpKL2xJ4IOh/7d+APaqLYdMf86xnczU3nurFTaVN9s9jOXQg97BE4nYm/7Ga51rjec5nfRdrvA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.3.tgz", + "integrity": "sha512-ge2DC7tHRHa3caVEoSbPRJpq7azhG+xYsd6u2MEnJ6XzPSzQsTKyXvh6iWjXRf7Rt9ykIUWHtl0Uz3T6yXPpKw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.14.3.tgz", + "integrity": "sha512-ljcuiDI4V3ySuc7eSk4lQ9wU8J8r8KrOUvB2U+TtK0TiW6OFDmJ+DdIjjwZHIw9CNxzbmXY39wwpzYuFDwNXuw==", "cpu": [ "arm" ], @@ -583,9 +598,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.12.0.tgz", - "integrity": "sha512-0fZBq27b+D7Ar5CQMofVN8sggOVhEtzFUwOwPppQt0k+VR+7UHMZZY4y+64WJ06XOhBTKXtQB/Sv0NwQMXyNAA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.3.tgz", + "integrity": "sha512-Eci2us9VTHm1eSyn5/eEpaC7eP/mp5n46gTRB3Aar3BgSvDQGJZuicyq6TsH4HngNBgVqC5sDYxOzTExSU+NjA==", "cpu": [ "arm64" ], @@ -596,9 +611,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.12.0.tgz", - "integrity": "sha512-eTvzUS3hhhlgeAv6bfigekzWZjaEX9xP9HhxB0Dvrdbkk5w/b+1Sxct2ZuDxNJKzsRStSq1EaEkVSEe7A7ipgQ==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.3.tgz", + "integrity": "sha512-UrBoMLCq4E92/LCqlh+blpqMz5h1tJttPIniwUgOFJyjWI1qrtrDhhpHPuFxULlUmjFHfloWdixtDhSxJt5iKw==", "cpu": [ "arm64" ], @@ -608,10 +623,23 @@ "linux" ] }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.3.tgz", + "integrity": "sha512-5aRjvsS8q1nWN8AoRfrq5+9IflC3P1leMoy4r2WjXyFqf3qcqsxRCfxtZIV58tCxd+Yv7WELPcO9mY9aeQyAmw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.12.0.tgz", - "integrity": "sha512-ix+qAB9qmrCRiaO71VFfY8rkiAZJL8zQRXveS27HS+pKdjwUfEhqo2+YF2oI+H/22Xsiski+qqwIBxVewLK7sw==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.3.tgz", + "integrity": "sha512-sk/Qh1j2/RJSX7FhEpJn8n0ndxy/uf0kI/9Zc4b1ELhqULVdTfN6HL31CDaTChiBAOgLcsJ1sgVZjWv8XNEsAQ==", "cpu": [ "riscv64" ], @@ -621,10 +649,23 @@ "linux" ] }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.3.tgz", + "integrity": "sha512-jOO/PEaDitOmY9TgkxF/TQIjXySQe5KVYB57H/8LRP/ux0ZoO8cSHCX17asMSv3ruwslXW/TLBcxyaUzGRHcqg==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.12.0.tgz", - "integrity": "sha512-TenQhZVOtw/3qKOPa7d+QgkeM6xY0LtwzR8OplmyL5LrgTWIXpTQg2Q2ycBf8jm+SFW2Wt/DTn1gf7nFp3ssVA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.3.tgz", + "integrity": "sha512-8ybV4Xjy59xLMyWo3GCfEGqtKV5M5gCSrZlxkPGvEPCGDLNla7v48S662HSGwRd6/2cSneMQWiv+QzcttLrrOA==", "cpu": [ "x64" ], @@ -635,9 +676,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.12.0.tgz", - "integrity": "sha512-LfFdRhNnW0zdMvdCb5FNuWlls2WbbSridJvxOvYWgSBOYZtgBfW9UGNJG//rwMqTX1xQE9BAodvMH9tAusKDUw==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.3.tgz", + "integrity": "sha512-s+xf1I46trOY10OqAtZ5Rm6lzHre/UiLA1J2uOhCFXWkbZrJRkYBPO6FhvGfHmdtQ3Bx793MNa7LvoWFAm93bg==", "cpu": [ "x64" ], @@ -648,9 +689,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.12.0.tgz", - "integrity": "sha512-JPDxovheWNp6d7AHCgsUlkuCKvtu3RB55iNEkaQcf0ttsDU/JZF+iQnYcQJSk/7PtT4mjjVG8N1kpwnI9SLYaw==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.3.tgz", + "integrity": "sha512-+4h2WrGOYsOumDQ5S2sYNyhVfrue+9tc9XcLWLh+Kw3UOxAvrfOrSMFon60KspcDdytkNDh7K2Vs6eMaYImAZg==", "cpu": [ "arm64" ], @@ -661,9 +702,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.12.0.tgz", - "integrity": "sha512-fjtuvMWRGJn1oZacG8IPnzIV6GF2/XG+h71FKn76OYFqySXInJtseAqdprVTDTyqPxQOG9Exak5/E9Z3+EJ8ZA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.3.tgz", + "integrity": "sha512-T1l7y/bCeL/kUwh9OD4PQT4aM7Bq43vX05htPJJ46RTI4r5KNt6qJRzAfNfM+OYMNEVBWQzR2Gyk+FXLZfogGw==", "cpu": [ "ia32" ], @@ -674,9 +715,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.12.0.tgz", - "integrity": "sha512-ZYmr5mS2wd4Dew/JjT0Fqi2NPB/ZhZ2VvPp7SmvPZb4Y1CG/LRcS6tcRo2cYU7zLK5A7cdbhWnnWmUjoI4qapg==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.3.tgz", + "integrity": "sha512-/BypzV0H1y1HzgYpxqRaXGBRqfodgoBBCcsrujT6QRcakDQdfU+Lq9PENPh5jB4I44YWq+0C2eHsHya+nZY1sA==", "cpu": [ "x64" ], @@ -1159,9 +1200,9 @@ } }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "dev": true, "engines": { "node": ">= 0.6" @@ -1343,9 +1384,9 @@ "dev": true }, "node_modules/esbuild": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz", - "integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz", + "integrity": "sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==", "dev": true, "hasInstallScript": true, "bin": { @@ -1355,29 +1396,29 @@ "node": ">=12" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.19.12", - "@esbuild/android-arm": "0.19.12", - "@esbuild/android-arm64": "0.19.12", - "@esbuild/android-x64": "0.19.12", - "@esbuild/darwin-arm64": "0.19.12", - "@esbuild/darwin-x64": "0.19.12", - "@esbuild/freebsd-arm64": "0.19.12", - "@esbuild/freebsd-x64": "0.19.12", - "@esbuild/linux-arm": "0.19.12", - "@esbuild/linux-arm64": "0.19.12", - "@esbuild/linux-ia32": "0.19.12", - "@esbuild/linux-loong64": "0.19.12", - "@esbuild/linux-mips64el": "0.19.12", - "@esbuild/linux-ppc64": "0.19.12", - "@esbuild/linux-riscv64": "0.19.12", - "@esbuild/linux-s390x": "0.19.12", - "@esbuild/linux-x64": "0.19.12", - "@esbuild/netbsd-x64": "0.19.12", - "@esbuild/openbsd-x64": "0.19.12", - "@esbuild/sunos-x64": "0.19.12", - "@esbuild/win32-arm64": "0.19.12", - "@esbuild/win32-ia32": "0.19.12", - "@esbuild/win32-x64": "0.19.12" + "@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" } }, "node_modules/escape-html": { @@ -1405,17 +1446,17 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dev": true, "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -1446,30 +1487,6 @@ "node": ">= 0.10.0" } }, - "node_modules/express/node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", - "dev": true, - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.1", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, "node_modules/express/node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -1485,21 +1502,6 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, - "node_modules/express/node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", - "dev": true, - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -2318,9 +2320,9 @@ } }, "node_modules/postcss": { - "version": "8.4.35", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.35.tgz", - "integrity": "sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==", + "version": "8.4.38", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", + "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", "dev": true, "funding": [ { @@ -2339,12 +2341,37 @@ "dependencies": { "nanoid": "^3.3.7", "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" + "source-map-js": "^1.2.0" }, "engines": { "node": "^10 || ^12 || >=14" } }, + "node_modules/prettier": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-svelte": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-3.2.3.tgz", + "integrity": "sha512-wJq8RunyFlWco6U0WJV5wNCM7zpBFakS76UBSbmzMGpncpK98NZABaE+s7n8/APDCEVNHXC5Mpq+MLebQtsRlg==", + "dev": true, + "peerDependencies": { + "prettier": "^3.0.0", + "svelte": "^3.2.0 || ^4.0.0-next.0 || ^5.0.0-next.0" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", @@ -2481,9 +2508,9 @@ } }, "node_modules/rollup": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.12.0.tgz", - "integrity": "sha512-wz66wn4t1OHIJw3+XU7mJJQV/2NAfw5OAk6G6Hoo3zcvz/XOfQ52Vgi+AN4Uxoxi0KBBwk2g8zPrTDA4btSB/Q==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.14.3.tgz", + "integrity": "sha512-ag5tTQKYsj1bhrFC9+OEWqb5O6VYgtQDO9hPDBMmIbePwhfSr+ExlcU741t8Dhw5DkPCQf6noz0jb36D6W9/hw==", "dev": true, "dependencies": { "@types/estree": "1.0.5" @@ -2496,19 +2523,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.12.0", - "@rollup/rollup-android-arm64": "4.12.0", - "@rollup/rollup-darwin-arm64": "4.12.0", - "@rollup/rollup-darwin-x64": "4.12.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.12.0", - "@rollup/rollup-linux-arm64-gnu": "4.12.0", - "@rollup/rollup-linux-arm64-musl": "4.12.0", - "@rollup/rollup-linux-riscv64-gnu": "4.12.0", - "@rollup/rollup-linux-x64-gnu": "4.12.0", - "@rollup/rollup-linux-x64-musl": "4.12.0", - "@rollup/rollup-win32-arm64-msvc": "4.12.0", - "@rollup/rollup-win32-ia32-msvc": "4.12.0", - "@rollup/rollup-win32-x64-msvc": "4.12.0", + "@rollup/rollup-android-arm-eabi": "4.14.3", + "@rollup/rollup-android-arm64": "4.14.3", + "@rollup/rollup-darwin-arm64": "4.14.3", + "@rollup/rollup-darwin-x64": "4.14.3", + "@rollup/rollup-linux-arm-gnueabihf": "4.14.3", + "@rollup/rollup-linux-arm-musleabihf": "4.14.3", + "@rollup/rollup-linux-arm64-gnu": "4.14.3", + "@rollup/rollup-linux-arm64-musl": "4.14.3", + "@rollup/rollup-linux-powerpc64le-gnu": "4.14.3", + "@rollup/rollup-linux-riscv64-gnu": "4.14.3", + "@rollup/rollup-linux-s390x-gnu": "4.14.3", + "@rollup/rollup-linux-x64-gnu": "4.14.3", + "@rollup/rollup-linux-x64-musl": "4.14.3", + "@rollup/rollup-win32-arm64-msvc": "4.14.3", + "@rollup/rollup-win32-ia32-msvc": "4.14.3", + "@rollup/rollup-win32-x64-msvc": "4.14.3", "fsevents": "~2.3.2" } }, @@ -2725,9 +2755,9 @@ } }, "node_modules/source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", + "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3026,14 +3056,14 @@ } }, "node_modules/vite": { - "version": "5.1.4", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.1.4.tgz", - "integrity": "sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg==", + "version": "5.2.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.9.tgz", + "integrity": "sha512-uOQWfuZBlc6Y3W/DTuQ1Sr+oIXWvqljLvS881SVmAj00d5RdgShLcuXWxseWPd4HXwiYBFW/vXHfKFeqj9uQnw==", "dev": true, "dependencies": { - "esbuild": "^0.19.3", - "postcss": "^8.4.35", - "rollup": "^4.2.0" + "esbuild": "^0.20.1", + "postcss": "^8.4.38", + "rollup": "^4.13.0" }, "bin": { "vite": "bin/vite.js" diff --git a/package.json b/package.json index 3a2fedc..8433ab6 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "build": "rimraf dist && vite build && echo \"declare module 'altcha';\" > dist/altcha.d.ts", "preview": "vite preview", "check": "svelte-check --tsconfig ./tsconfig.json", + "format": "prettier --write ./src/**/*", "test": "vitest run tests/helpers.test.ts", "test:e2e": "playwright test", "prepare": "husky" @@ -53,6 +54,8 @@ "cors": "^2.8.5", "express": "^4.18.2", "husky": "^9.0.11", + "prettier": "3.2.5", + "prettier-plugin-svelte": "^3.2.3", "sass": "^1.71.1", "svelte": "^4.2.11", "svelte-check": "^3.4.6", diff --git a/server/server-deno.ts b/server/server-deno.ts new file mode 100644 index 0000000..3c6ea55 --- /dev/null +++ b/server/server-deno.ts @@ -0,0 +1,65 @@ +/** + * An example server implementation for ALTCHA using Deno. + * + * Run: deno run --allow-net server-deno.ts + */ + +import { Hono } from 'https://deno.land/x/hono/mod.ts'; +import { cors } from 'https://deno.land/x/hono/middleware/cors/index.ts'; +import { + createChallenge, + verifySolution, +} from 'https://deno.land/x/altcha/mod.ts'; + +// Configure your secret HMAC key +const HMAC_KEY = 'secret.hmac.key'; + +const app = new Hono(); + +function url(ref: string, hash: string = '') { + const url = new URL(ref); + url.hash = hash; + return url.toString(); +} + +app.use('/*', cors()); + +// Configure this endpoint as `challengeurl` +app.get('/altcha', async (c) => + c.json( + await createChallenge({ + hmacKey: HMAC_KEY, + }) + ) +); + +// Form submission endpoint +app.post('/submit', async (c) => { + const ref = c.req.header('referer'); + const form = await c.req.formData(); + + // The verification payload is received as `altcha` field + const payload = form.get('altcha'); + + console.log('Body:', Object.fromEntries(form)); + + if (!payload) { + return c.text('Invalid payload', 400); + } + + if (await verifySolution(payload as string, HMAC_KEY)) { + console.log('VERIFIED.'); + if (ref) { + return c.redirect(url(ref, '#success')); + } + return c.text('Submitted!'); + } + + console.log('INVALID ALTCHA.'); + if (ref) { + return c.redirect(url(ref, '#failure')); + } + return c.text('ALTCHA check failed.', 400); +}); + +Deno.serve(app.fetch); diff --git a/server/server.js b/server/server.js deleted file mode 100644 index 4ce632e..0000000 --- a/server/server.js +++ /dev/null @@ -1,79 +0,0 @@ -import { createHash, createHmac, randomInt, randomBytes } from 'node:crypto'; -import express from 'express'; -import cors from 'cors'; -import bodyParser from 'body-parser'; - -const ALTCHA_ALG = 'SHA-256'; -const ALTCHA_ALG_NODE = ALTCHA_ALG.replace('-', ''); // node doesn't support alg with dashes -const ALTCHA_NUM_RANGE = [10000, 50000]; // adjust complexity -const ALTCHA_HMAC_KEY = 'secret.hmac.key'; // !! change this key !! - -function createALTCHA(salt = randomBytes(12).toString('hex'), number = randomInt(...ALTCHA_NUM_RANGE)) { - const challenge = createHash(ALTCHA_ALG_NODE).update(salt + number).digest('hex'); - return { - algorithm: ALTCHA_ALG, - challenge, - maxnumber: ALTCHA_NUM_RANGE[1], - salt, - signature: createHmac(ALTCHA_ALG_NODE, ALTCHA_HMAC_KEY).update(challenge).digest('hex'), - }; -} - -function verifyALTCHA(payload) { - let json; - try { - json = JSON.parse(atob(payload)); - } catch { - // invalid payload - return false; - } - if (json) { - const { algorithm, challenge, salt, signature, number } = json; - const check = createALTCHA(salt, number); - if (algorithm === check.algorithm && challenge === check.challenge && signature == check.signature) { - return true; - } - } - return false; -} - -function url(ref, hash = '') { - const url = new URL(ref); - url.hash = hash; - return url.toString(); -} - -const app = express(); - -app.use(cors()); -app.use(bodyParser.urlencoded()); - -// Endpoint to fetch a new challenge -app.get('/altcha', function (req, res) { - res.send(createALTCHA()); -}); - -// Endpoint to handle form submission -app.post('/submit', function (req, res) { - const ref = req.header('referer'); - const { altcha } = req.body || {}; - if (verifyALTCHA(altcha)) { - console.log('VERIFIED. Body:', req.body); - if (ref) { - res.redirect(url(ref, '#success')); - } else { - res.send('Submitted!'); - } - - } else { - console.log('INVALID ALTCHA. Body:', req.body); - if (ref) { - res.redirect(url(ref, '#failure')); - } else { - res.status(403); - res.send('ALTCHA check failed.'); - } - } -}); - -app.listen(3000); \ No newline at end of file diff --git a/src/Altcha.svelte b/src/Altcha.svelte index 272eb5c..dbcde1a 100644 --- a/src/Altcha.svelte +++ b/src/Altcha.svelte @@ -1,16 +1,26 @@ - +