import{az as I,d as G,$ as J,u as K,r as C,x as T,e as N,a as l,w as W,k as $,v as j,o as p,c as y,f as n,B as c,C as H,E as S,F as P,R as M,A as Q,G as X,aD as U,a9 as Y,aa as Z,ao as ee,ce as se,V as ae,K as te,W as oe,__tla as re}from"./index-92ad187a.js";import{_ as le,__tla as ne}from"./LoginFormTitle.vue_vue_type_script_setup_true_lang-d6513d00.js";import{u as ce,L as V,__tla as ie}from"./useLogin-8ecc0208.js";let z,ue=Promise.all([(()=>{try{return re}catch{}})(),(()=>{try{return ne}catch{}})(),(()=>{try{return ie}catch{}})()]).then(async()=>{let k,O,q;k={class:"form-cont"},O={key:0},q={key:1},z=G({name:"SSOLogin",__name:"SSOLogin",setup(pe){const i=J(),{currentRoute:F}=K(),{getLoginState:R,setLoginState:A}=ce(),b=C({name:"",logo:""}),s=T({responseType:"",clientId:"",redirectUri:"",state:"",scopes:[]}),B=N(()=>l(R)===V.SSO),u=T({scopes:[]}),d=C(!1),D=async()=>{if(i.query.client_id===void 0)return;if(s.responseType=i.query.response_type,s.clientId=i.query.client_id,s.redirectUri=i.query.redirect_uri,s.state=i.query.state,i.query.scope&&(s.scopes=i.query.scope.split(" ")),s.scopes.length>0){const e=await L(!0,s.scopes,[]);if(e)return void(location.href=e)}const t=await(a=s.clientId,I.get({url:"/system/oauth2/authorize?clientId="+a}));var a;let o;if(b.value=t.client,s.scopes.length>0){o=[];for(const e of t.scopes)s.scopes.indexOf(e.key)>=0&&o.push(e)}else{o=t.scopes;for(const e of o)s.scopes.push(e.key)}for(const e of o)e.value&&u.scopes.push(e.key)},x=async t=>{let a,o;t?(a=u.scopes,o=s.scopes.filter(e=>a.indexOf(e)===-1)):(a=[],o=s.scopes),d.value=!0;try{const e=await L(!1,a,o);if(!e)return;location.href=e}finally{d.value=!1}},L=(t,a,o)=>((e,m,h,f,_,g,r)=>{const v={};for(const w of g)v[w]=!0;for(const w of r)v[w]=!1;return I.post({url:"/system/oauth2/authorize",headers:{"Content-type":"application/x-www-form-urlencoded"},params:{response_type:e,client_id:m,redirect_uri:h,state:f,auto_approve:_,scope:JSON.stringify(v)}})})(s.responseType,s.clientId,s.redirectUri,s.state,t,a,o),E=t=>{switch(t){case"user.read":return"\u8BBF\u95EE\u4F60\u7684\u4E2A\u4EBA\u4FE1\u606F";case"user.write":return"\u4FEE\u6539\u4F60\u7684\u4E2A\u4EBA\u4FE1\u606F";default:return t}};return W(()=>F.value,t=>{t.name==="SSOLogin"&&(A(V.SSO),D())},{immediate:!0}),(t,a)=>{const o=Y,e=Z,m=ee,h=se,f=ae,_=te,g=oe;return $((p(),y("div",k,[n(le,{style:{width:"100%"}}),n(e,{class:"form",style:{float:"none"},value:"uname"},{default:c(()=>[n(o,{label:l(b).name,name:"uname"},null,8,["label"])]),_:1}),H("div",null,[n(g,{model:l(u),class:"login-form"},{default:c(()=>[S(" \u6B64\u7B2C\u4E09\u65B9\u5E94\u7528\u8BF7\u6C42\u83B7\u5F97\u4EE5\u4E0B\u6743\u9650\uFF1A "),n(f,{prop:"scopes"},{default:c(()=>[n(h,{modelValue:l(u).scopes,"onUpdate:modelValue":a[0]||(a[0]=r=>l(u).scopes=r)},{default:c(()=>[(p(!0),y(P,null,M(l(s).scopes,r=>(p(),Q(m,{key:r,label:r,style:{display:"block","margin-bottom":"-10px"}},{default:c(()=>[S(X(E(r)),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])]),_:1}),n(f,{class:"w-1/1"},{default:c(()=>[n(_,{loading:l(d),class:"w-6/10",type:"primary",onClick:a[1]||(a[1]=U(r=>x(!0),["prevent"]))},{default:c(()=>[l(d)?(p(),y("span",q,"\u6388 \u6743 \u4E2D...")):(p(),y("span",O,"\u540C\u610F\u6388\u6743"))]),_:1},8,["loading"]),n(_,{class:"w-3/10",onClick:a[2]||(a[2]=U(r=>x(!1),["prevent"]))},{default:c(()=>[S("\u62D2\u7EDD")]),_:1})]),_:1})]),_:1},8,["model"])])],512)),[[j,l(B)]])}}})});export{z as _,ue as __tla};
