import{M as C}from"./MkSignin-ikEPb45Z.js";import{$ as A,i as t,M as k,f as B,aT as E,aZ as L,A as N,n as S}from"./app-JmgyQoR0.js";import{b as V,a as q,D as u,h as s,i as U,j as h,z as i,t as e,u as a,l as r,H as j,E as o,K as d,x as _,F as x,G as z}from"./vue-y3KLWBaS.js";import"./2fa-ubAA2qBP.js";const D={key:0},F={key:0,class:"waiting _section"},G={class:"_content"},T={key:1,class:"denied _section"},H={class:"_content"},I={key:2,class:"accepted _section"},K={class:"_content"},O={key:0},P={key:1},Q={key:3,class:"_section"},R={key:0,class:"_title"},Z={key:1,class:"_title"},J={class:"_content"},W=a("i",{class:"ph-shield-warning ph-bold ph-xl",style:{"margin-right":"0.5rem"}},null,-1),X={class:"_footer"},Y={key:1,class:"signin"},ss=V({__name:"miauth",props:{session:{},callback:{},name:{},icon:{},permission:{}},setup(y){const c=y,p=c.permission.split(",");let l=q(null);function v(n){return n.includes("write")?"pencil-simple":"eye"}async function f(){if(l.value="waiting",await B("miauth/gen-token",{session:c.session,name:c.name,iconUrl:c.icon,permission:p}),l.value="accepted",c.callback){const n=new URL(c.callback);if(["javascript:","file:","data:","mailto:","tel:"].includes(n.protocol))throw new Error("invalid url");location.href=E(c.callback,L({session:c.session}))}}function g(){l.value="denied"}function M(n){N(n.i)}return(n,os)=>{const b=u("MkLoading"),w=u("MkEllipsis"),$=u("MkSpacer");return s(),U($,{"content-max":800},{default:h(()=>[i(A)?(s(),e("div",D,[l.value=="waiting"?(s(),e("div",F,[a("div",G,[r(b)])])):j("",!0),l.value=="denied"?(s(),e("div",T,[a("div",H,[a("p",null,o(i(t).ts._auth.denied),1)])])):l.value=="accepted"?(s(),e("div",I,[a("div",K,[n.callback?(s(),e("p",O,[d(o(i(t).ts._auth.callback),1),r(w)])):(s(),e("p",P,o(i(t).ts._auth.pleaseGoBack),1))])])):(s(),e("div",Q,[n.name?(s(),e("div",R,o(i(t).t("_auth.shareAccess",{name:n.name})),1)):(s(),e("div",Z,o(i(t).ts._auth.shareAccessAsk),1)),a("div",J,[a("p",null,o(i(t).ts._auth.permissionAsk),1),i(p).length===32?(s(),e("div",{key:0,class:_([n.$style.permissions])},[a("div",{class:_([n.$style.permission]),style:{"background-color":"var(--error)",color:"var(--fgOnAccent)"}},[W,d(" "+o(i(t).ts._permissions.allPermissions),1)],2)],2)):(s(),e("div",{key:1,class:_([n.$style.permissions])},[(s(!0),e(x,null,z(i(p),m=>(s(),e("div",{key:m,class:_([n.$style.permission])},[a("i",{class:_([[`ph-${v(m)}`],"ph-bold ph-xl"]),style:{"margin-right":"0.5rem"}},null,2),d(" "+o(i(t).t(`_permissions.${m}`)),1)],2))),128))],2))]),a("div",X,[r(k,{inline:"",onClick:g},{default:h(()=>[d(o(i(t).ts.cancel),1)]),_:1}),r(k,{inline:"",primary:"",onClick:f},{default:h(()=>[d(o(i(t).ts.accept),1)]),_:1})])]))])):(s(),e("div",Y,[r(C,{onLogin:M})]))]),_:1})}}}),es="_permissions_s3eqd_1",ns="_permission_s3eqd_1",is={permissions:es,permission:ns},ts={$style:is},ds=S(ss,[["__cssModules",ts]]);export{ds as default};
