import{p as R,r as u,i as L,q as B,o as p,c as v,a as r,t as _,f as C,u as b}from"./app-22d7fab3.js";import{i as m}from"./http-1f667af7.js";function y(){return y=Object.assign?Object.assign.bind():function(c){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(c[a]=t[a])}return c},y.apply(this,arguments)}var E=function(){var e=!1,t=[],a=function(){if(!e){e=!0;for(var n=0,f=t.length;n<f;n++)t[n]()}},i=function(n){if(!e){t.push(n);return}n()},s={resolved:function(){return e},resolve:a,promise:{then:i}};return s},S=Object.prototype.hasOwnProperty;function A(){var c=E();return{notify:function(){c.resolve()},wait:function(){return c.promise},render:function(t,a,i){this.wait().then(function(){i(window.grecaptcha.render(t,a))})},reset:function(t){typeof t>"u"||(this.assertLoaded(),this.wait().then(function(){return window.grecaptcha.reset(t)}))},execute:function(t){typeof t>"u"||(this.assertLoaded(),this.wait().then(function(){return window.grecaptcha.execute(t)}))},checkRecaptchaLoad:function(){S.call(window,"grecaptcha")&&S.call(window.grecaptcha,"render")&&this.notify()},assertLoaded:function(){if(!c.resolved())throw new Error("ReCAPTCHA has not been loaded")}}}var l=A();typeof window<"u"&&(window.vueRecaptchaApiLoaded=l.notify);var M=R({name:"VueRecaptcha",props:{sitekey:{type:String,required:!0},theme:{type:String},badge:{type:String},type:{type:String},size:{type:String},tabindex:{type:String},loadRecaptchaScript:{type:Boolean,default:!0},recaptchaScriptId:{type:String,default:"__RECAPTCHA_SCRIPT"},recaptchaHost:{type:String,default:"www.google.com"},language:{type:String,default:""}},emits:["render","verify","expired","error"],setup:function(e,t){var a=t.slots,i=t.emit,s=u(null),o=u(null),n=function(h){i("verify",h)},f=function(){i("expired")},x=function(){i("error")};return L(function(){if(l.checkRecaptchaLoad(),e.loadRecaptchaScript&&!document.getElementById(e.recaptchaScriptId)){var d=document.createElement("script");d.id=e.recaptchaScriptId,d.src="https://"+e.recaptchaHost+"/recaptcha/api.js?onload=vueRecaptchaApiLoaded&render=explicit&hl="+e.language,d.async=!0,d.defer=!0,document.head.appendChild(d)}var h=y({},e,{callback:n,"expired-callback":f,"error-callback":x}),g=s.value,k=a.default?g.children[0]:g;l.render(k,h,function(w){o.value=w,i("render",w)})}),{root:s,widgetId:o,reset:function(){l.reset(o.value)},execute:function(){l.execute(o.value)}}},render:function(){var e=this.$slots.default,t;return typeof e=="function"?t=e():t=e,B("div",{ref:"root"},t)}});const O=r("h3",null,"流量补给",-1),P={key:0},V={key:1},j=r("p",null,"完成验证码以签到",-1),H=r("button",{type:"button",class:"btn btn-primary",style:{display:"none"},id:"signinButton","data-bs-toggle":"modal","data-bs-target":"#signinModal"},null,-1),I={class:"modal fade",id:"signinModal",tabindex:"-1","aria-labelledby":"signinModalLabel","aria-hidden":"true"},q={class:"modal-dialog"},T={class:"modal-content"},$=r("div",{class:"modal-header"},[r("h1",{class:"modal-title fs-5",id:"signinModalLabel"},"签到")],-1),G={class:"modal-body"},N=r("div",{class:"modal-footer"},[r("button",{type:"button",class:"btn btn-primary","data-bs-dismiss":"modal"},"确定")],-1),F={name:"Sign",setup(c){const e=window.Base.ReCaptcha,t=u(""),a=u({last_sign_at:null,traffic:0}),i=u("");window.matchMedia("(prefers-color-scheme: dark)").matches?i.value="dark":i.value="light",m.get("user").then(o=>{a.value.traffic=o.data.traffic});function s(o){m.post("traffic",{recaptcha:o}).then(n=>{a.value=n.data,t.value=`获得了 ${n.data.traffic} GB 流量！`,n.data.traffic===0&&(t.value="没有获得流量～"),document.querySelector("#signinButton").click()}).finally(()=>{m.get("user").then(n=>{a.value.traffic=n.data.traffic}).finally(()=>{})})}return(o,n)=>(p(),v("div",null,[O,r("div",null,[r("p",null,"当前流量: "+_(a.value.traffic)+"GB",1),a.value.is_signed?(p(),v("div",P,"今日已签到")):(p(),v("div",V,[j,C(b(M),{sitekey:b(e),theme:i.value,loadRecaptchaScript:"",recaptchaHost:"www.recaptcha.net",onVerify:s},null,8,["sitekey","theme"])]))]),H,r("div",I,[r("div",q,[r("div",T,[$,r("div",G," 签到成功！"+_(t.value),1),N])])])]))}};export{F as default};
