import{p as R,r as f,i as L,q as B,o as m,c as g,a,t as b,f as C,u as x,j as E,v as M}from"./app-65af0faa.js";import{i as h}from"./http-74266e01.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 n in t)Object.prototype.hasOwnProperty.call(t,n)&&(c[n]=t[n])}return c},y.apply(this,arguments)}var V=function(){var e=!1,t=[],n=function(){if(!e){e=!0;for(var s=0,r=t.length;s<r;s++)t[s]()}},i=function(s){if(!e){t.push(s);return}s()},u={resolved:function(){return e},resolve:n,promise:{then:i}};return u},S=Object.prototype.hasOwnProperty;function j(){var c=V();return{notify:function(){c.resolve()},wait:function(){return c.promise},render:function(t,n,i){this.wait().then(function(){i(window.grecaptcha.render(t,n))})},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 p=j();typeof window<"u"&&(window.vueRecaptchaApiLoaded=p.notify);var A=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 n=t.slots,i=t.emit,u=f(null),l=f(null),s=function(v){i("verify",v)},r=function(){i("expired")},d=function(){i("error")};return L(function(){if(p.checkRecaptchaLoad(),e.loadRecaptchaScript&&!document.getElementById(e.recaptchaScriptId)){var o=document.createElement("script");o.id=e.recaptchaScriptId,o.src="https://"+e.recaptchaHost+"/recaptcha/api.js?onload=vueRecaptchaApiLoaded&render=explicit&hl="+e.language,o.async=!0,o.defer=!0,document.head.appendChild(o)}var v=y({},e,{callback:s,"expired-callback":r,"error-callback":d}),_=u.value,k=n.default?_.children[0]:_;p.render(k,v,function(w){l.value=w,i("render",w)})}),{root:u,widgetId:l,reset:function(){p.reset(l.value)},execute:function(){p.execute(l.value)}}},render:function(){var e=this.$slots.default,t;return typeof e=="function"?t=e():t=e,B("div",{ref:"root"},t)}});const O=a("h3",null,"流量补给",-1),P={key:0},H={key:1},I=a("p",null,"完成验证码以签到",-1),T={class:"mt-4"},q=a("h3",null,"兑换流量激活码",-1),$={class:"input-group mt-3"},D=a("button",{id:"signinButton",class:"btn btn-primary","data-bs-target":"#signinModal","data-bs-toggle":"modal",style:{display:"none"},type:"button"},null,-1),G={id:"signinModal","aria-hidden":"true","aria-labelledby":"signinModalLabel",class:"modal fade",tabindex:"-1"},N={class:"modal-dialog"},z={class:"modal-content"},U=a("div",{class:"modal-header"},[a("h1",{id:"signinModalLabel",class:"modal-title fs-5"},"签到")],-1),F={class:"modal-body"},J=a("div",{class:"modal-footer"},[a("button",{class:"btn btn-primary","data-bs-dismiss":"modal",type:"button"},"确定")],-1),W={name:"Sign",setup(c){const e=window.Base.ReCaptcha,t=f(""),n=f({last_sign_at:null,traffic:0}),i=f(""),u=f("");window.matchMedia("(prefers-color-scheme: dark)").matches?i.value="dark":i.value="light",h.get("user").then(r=>{n.value.traffic=r.data.traffic});function l(r){h.post("traffic",{recaptcha:r}).then(d=>{n.value=d.data,t.value=`获得了 ${d.data.traffic} GB 流量！`,d.data.traffic===0&&(t.value="没有获得流量～"),document.querySelector("#signinButton").click()}).finally(()=>{h.get("user").then(d=>{n.value.traffic=d.data.traffic}).finally(()=>{})})}function s(){h.post("/codes/use",{code:u.value}).then(r=>{alert(r.data.message)}).catch(r=>{alert(r.data.message)}).finally(()=>{h.get("user").then(r=>{n.value.traffic=r.data.traffic})})}return(r,d)=>(m(),g("div",null,[O,a("div",null,[a("p",null,"当前流量: "+b(n.value.traffic)+"GB",1),n.value.is_signed?(m(),g("div",P,"今日已签到")):(m(),g("div",H,[I,C(x(A),{sitekey:x(e),theme:i.value,loadRecaptchaScript:"",recaptchaHost:"www.recaptcha.net",onVerify:l},null,8,["sitekey","theme"])]))]),a("div",T,[q,a("div",$,[E(a("input",{"onUpdate:modelValue":d[0]||(d[0]=o=>u.value=o),class:"form-control",type:"text"},null,512),[[M,u.value]]),a("button",{class:"btn btn-primary",onClick:s},"兑换")])]),D,a("div",G,[a("div",N,[a("div",z,[U,a("div",F," 签到成功！"+b(t.value),1),J])])])]))}};export{W as default};
