(function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.CaptchaFox={},t.Vue))})(this,function(t,e){"use strict";var p,u,f=new Promise((c,o)=>{p=c,u=o}),h="captchaFoxOnLoad",w=`https://cdn.captchafox.com/api.js?render=explicit&onload=${h}`;async function v({nonce:c}={}){if(document.querySelector(`script[src="${w}"]`))return f;window[h]=p;const o=document.createElement("script");return o.src=w,o.async=!0,o.defer=!0,o.onerror=u,c&&(o.nonce=c),document.body.appendChild(o),f}var d=()=>typeof(window==null?void 0:window.captchafox)<"u";const y=e.defineComponent({__name:"CaptchaFox",props:{sitekey:{},lang:{},mode:{},theme:{},i18n:{},modelValue:{},containerClass:{},nonce:{}},emits:["verify","expire","error","close","fail","load","update:modelValue"],setup(c,{expose:o,emit:r}){const a=c,n=e.ref(),x=e.ref(null);o({getResponse(){return!d()||!n.value?(console.warn("[CaptchaFox] Widget has not been loaded"),""):window.captchafox.getResponse(n.value)},reset(){if(!d()||!n.value){console.warn("[CaptchaFox] Widget has not been loaded");return}window.captchafox.reset(n.value)},remove(){if(!d()||!n.value){console.warn("[CaptchaFox] Widget has not been loaded");return}n.value="",window.captchafox.remove(n.value)},execute:()=>!d()||!n.value?Promise.reject("[CaptchaFox] Widget has not been loaded"):window.captchafox.execute(n.value)});const m=async()=>{var l,C;(l=window.captchafox)==null||l.remove(n.value);const i=await((C=window.captchafox)==null?void 0:C.render(x.value,{lang:a.lang,sitekey:a.sitekey,mode:a.mode,theme:a.theme,i18n:a.i18n,onError:s=>r("error",s),onFail:()=>r("fail"),onClose:()=>r("close"),onVerify:s=>{r("verify",s),r("update:modelValue",s)},onExpire:()=>r("expire")}));n.value=i,r("load")};return e.onMounted(()=>{v({nonce:a.nonce}).then(async()=>{d()&&await m()}).catch(i=>{r("error",i),console.error("[CaptchaFox] Could not load script:",i)})}),e.watch([()=>a.lang,()=>a.mode,()=>a.sitekey,()=>a.theme],async()=>{await m()}),(i,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"container",ref:x,class:e.normalizeClass(i.containerClass)},null,2))}}),g="cf-captcha-response";t.CAPTCHA_RESPONSE_KEY=g,t.CaptchaFox=y,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});