import{ap as p,d as I,r as h,O as N,B as j,aS as P,o as d,l as B,w as m,i,g as v,t as L,c as w,j as U,F as g,a as z,L as D,M as F,_ as H,__tla as M}from"./index-af173888.js";import{_ as O,__tla as X}from"./XTextButton-5dd30649.js";import{S as k}from"./constants-a3c69b57.js";import{g as $,__tla as A}from"./profile-2c7c21de.js";import{u as E,__tla as G}from"./useMessage-170c1b43.js";let C,J=Promise.all([(()=>{try{return M}catch{}})(),(()=>{try{return X}catch{}})(),(()=>{try{return A}catch{}})(),(()=>{try{return G}catch{}})()]).then(async()=>{let y,_;y=["src"],_={class:"mr-5"},C=H(I({name:"UserSocial",__name:"UserSocial",props:{activeName:{type:String,required:!0}},emits:["update:activeName"],setup(K,{emit:S}){const f=E(),n=h([]),o=h(),c=N(),b=S,R=()=>{const a=(t="type",new URL(decodeURIComponent(location.href)).searchParams.get(t)??"");var t;const e=c.query.code,s=c.query.state;e&&((l,r,u)=>p.post({url:"/system/social-user/bind",data:{type:l,code:r,state:u}}))(a,e,s).then(()=>{f.success("\u7ED1\u5B9A\u6210\u529F"),b("update:activeName","userSocial")})},q=a=>{const t=location.origin+"/user/profile?"+encodeURIComponent(`type=${a.type}`);((e,s)=>p.get({url:"/system/auth/social-auth-redirect?type="+e+"&redirectUri="+s}))(a.type,encodeURIComponent(t)).then(e=>{window.location.href=e})},x=async a=>{var t,e;await(t=a.type,e=a.openid,p.delete({url:"/system/social-user/unbind",data:{type:t,openid:e}}))&&(a.openid=void 0),f.success("\u89E3\u7ED1\u6210\u529F")};return j(async()=>{await(async()=>{var t;n.value=[];const a=await $();o.value=a;for(const e in k){const s={...k[e]};if(n.value.push(s),(t=o.value)==null?void 0:t.socialUsers){for(const l in o.value.socialUsers)if(s.type===o.value.socialUsers[l].type){s.openid=o.value.socialUsers[l].openid;break}}}})()}),P(()=>c,()=>{R()},{immediate:!0}),(a,t)=>{const e=D,s=O,l=F;return d(),B(l,{data:z(n),"show-header":!1},{default:m(()=>[i(e,{fixed:"left",title:"\u5E8F\u53F7",type:"seq",width:"60"}),i(e,{align:"left",label:"\u793E\u4EA4\u5E73\u53F0",width:"120"},{default:m(({row:r})=>[v("img",{src:r.img,alt:"",class:"h-5 align-middle"},null,8,y),v("p",_,L(r.title),1)]),_:1}),i(e,{align:"center",label:"\u64CD\u4F5C"},{default:m(({row:r})=>[r.openid?(d(),w(g,{key:0},[U(" \u5DF2\u7ED1\u5B9A "),i(s,{class:"mr-5",title:"(\u89E3\u7ED1)",type:"primary",onClick:u=>x(r)},null,8,["onClick"])],64)):(d(),w(g,{key:1},[U(" \u672A\u7ED1\u5B9A "),i(s,{class:"mr-5",title:"(\u7ED1\u5B9A)",type:"primary",onClick:u=>q(r)},null,8,["onClick"])],64))]),_:1})]),_:1},8,["data"])}}}),[["__file","/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-admin/src/views/Profile/components/UserSocial.vue"]])});export{J as __tla,C as default};