import{am as p,d as I,r as h,L as N,q as L,aM as P,o as d,x as j,w as m,f as i,g as v,t as z,c as w,y as U,F as g,a as D,I as F,J as H,_ as J,__tla as M}from"./index-8dc1e40a.js";import{_ as X,__tla as $}from"./XTextButton-8c2fbcf2.js";import{S as k}from"./constants-a1da293a.js";import{g as A,__tla as B}from"./profile-77dac77c.js";import{u as E,__tla as G}from"./useMessage-7a27dd80.js";let C,K=Promise.all([(()=>{try{return M}catch{}})(),(()=>{try{return $}catch{}})(),(()=>{try{return B}catch{}})(),(()=>{try{return G}catch{}})()]).then(async()=>{let y,_;y=["src"],_={class:"mr-5"},C=J(I({name:"UserSocial",__name:"UserSocial",props:{activeName:{type:String,required:!0}},emits:["update:activeName"],setup(O,{emit:S}){const f=E(),n=h([]),l=h(),c=N(),b=S,q=()=>{const a=(t="type",new URL(decodeURIComponent(location.href)).searchParams.get(t)??"");var t;const e=c.query.code,s=c.query.state;e&&((o,r,u)=>p.post({url:"/system/social-user/bind",data:{type:o,code:r,state:u}}))(a,e,s).then(()=>{f.success("\u7ED1\u5B9A\u6210\u529F"),b("update:activeName","userSocial")})},x=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})},R=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 L(async()=>{await(async()=>{var t;n.value=[];const a=await A();l.value=a;for(const e in k){const s={...k[e]};if(n.value.push(s),(t=l.value)==null?void 0:t.socialUsers){for(const o in l.value.socialUsers)if(s.type===l.value.socialUsers[o].type){s.openid=l.value.socialUsers[o].openid;break}}}})()}),P(()=>c,()=>{q()},{immediate:!0}),(a,t)=>{const e=F,s=X,o=H;return d(),j(o,{data:D(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",_,z(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=>R(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=>x(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{K as __tla,C as default};