import{a as j,u as G,a2 as R,S as q,r as f,x as J,o as Q,c as X,I as x,a1 as Y,d as r,j as a,e as o,k as _,f as s,i as d,L as Z,l as m,m as i,t as n,w as ee,g,F as se,D as te,h as oe,U as ne,n as A,G as z,H as y}from"./app-CzxRjCVM.js";import{F as ae}from"./Form-EFIuWKGI.js";import{_ as ie}from"./SettingTabs-CcdxaQB3.js";import{S as le}from"./Spinner-C-V0HKYn.js";/*! 2FAuth version 5.4.3 - Copyright (c) 2024 Bubka - https://github.com/Bubka/2FAuth */const re={class:"options-tabs"},ce={key:0,class:"notification is-warning has-text-centered"},ue=["innerHTML"],de={class:"title is-4 has-text-grey-light"},_e={class:"is-size-7-mobile"},me={class:"mt-3"},pe={key:2},fe={class:"tags is-pulled-right"},he=["onClick"],ve=["onClick","title"],ke={key:1,class:"is-size-7-mobile is-size-6 my-3"},ge={key:2,class:"pat is-family-monospace is-size-6 is-size-7-mobile has-text-success"},ye={class:"mt-2 is-size-7 is-pulled-right"},be={key:0,class:"is-overlay modal-otp modal-background"},Te={class:"main-section"},we={class:"field is-grouped"},Ce={class:"control"},Fe={class:"control"},Ae={__name:"OAuth",setup($e){const L=Z("2fauth"),p=j(),b=G(),E=R(L.prefix+"returnTo","accounts"),{copy:M}=q({legacy:!0}),c=f([]),T=f(!1),h=f(!1),v=f(null),w=f(null),C=J(()=>appSettings.enableSso&&appSettings.useSsoOnly||b.authenticated_by_proxy);Q(()=>{F()});const u=X(new ae({name:""}));function F(){T.value=!0,x.getPersonalAccessTokens({returnError:!0}).then(e=>{c.value=[],e.data.forEach(l=>{l.id===w.value?(l.value=v.value,c.value.unshift(l)):c.value.push(l)})}).catch(e=>{e.response.status===405||p.error(e)}).finally(()=>{T.value=!1,w.value=null,v.value=null})}function $(){I(),C.value?p.warn({text:y("errors.unsupported_with_reverseproxy")}):h.value=!0}function N(){u.post("/oauth/personal-access-tokens").then(e=>{v.value=e.data.accessToken,w.value=e.data.token.id,F(),h.value=!1,u.reset()})}function P(e){confirm(y("settings.confirm.revoke"))&&x.deletePersonalAccessToken(e).then(l=>{c.value=c.value.filter(k=>k.id!==e),p.success({text:y("settings.token_revoked")})})}function I(){c.value.forEach(e=>{e.value=null}),v.value=null}function K(e){M(e),p.success({text:y("commons.copied_to_clipboard")})}function U(){h.value=!1,u.reset()}return Y(e=>{e.name.startsWith("settings.")||p.clear()}),(e,l)=>{const k=m("FontAwesomeIcon"),D=m("ButtonBackCloseCancel"),H=m("VueFooter"),V=m("FormWrapper"),O=m("FormField"),B=m("VueButton");return i(),r("div",null,[a(ie,{activeTab:"settings.oauth.tokens"}),o("div",re,[a(V,null,{default:_(()=>[s(C)&&s(b).oauth_provider?(i(),r("div",ce,n(e.$t("auth.sso_only_x_settings_are_disabled",{auth_method:"OAuth"})),1)):d("",!0),s(C)&&s(b).authenticated_by_proxy?(i(),r("div",{key:1,class:"notification is-warning has-text-centered",innerHTML:e.$t("auth.auth_handled_by_proxy")},null,8,ue)):d("",!0),o("h4",de,n(e.$t("settings.personal_access_tokens")),1),o("div",_e,n(e.$t("settings.token_legend")),1),o("div",me,[o("a",{tabindex:"0",class:"is-link",onClick:$,onKeyup:ee($,["enter"])},[a(k,{icon:["fas","plus-circle"]}),g(" "+n(e.$t("settings.generate_new_token")),1)],32)]),s(c).length>0?(i(),r("div",pe,[(i(!0),r(se,null,te(s(c),t=>(i(),r("div",{key:t.id,class:"group-item is-size-5 is-size-6-mobile"},[t.value?(i(),oe(k,{key:0,class:"has-text-success",icon:["fas","check"]})):d("",!0),g(" "+n(t.name)+" ",1),o("div",fe,[a(s(ne),null,{default:_(({mode:S})=>[t.value?(i(),r("button",{key:0,type:"button",class:A(["button tag",{"is-link":S!="dark"}]),onClick:z(W=>K(t.value),["stop"])},n(e.$t("commons.copy")),11,he)):d("",!0),o("button",{type:"button",class:A(["button tag",S==="dark"?"is-dark":"is-white"]),onClick:W=>P(t.id),title:e.$t("settings.revoke")},n(e.$t("settings.revoke")),11,ve)]),_:2},1024)]),t.value?(i(),r("span",ke,n(e.$t("settings.make_sure_copy_token")),1)):d("",!0),t.value?(i(),r("span",ge,n(t.value),1)):d("",!0)]))),128)),o("div",ye,n(e.$t("settings.revoking_a_token_is_permanent")),1)])):d("",!0),a(le,{isVisible:s(T)&&s(c).length===0},null,8,["isVisible"]),a(H,{showButtons:!0},{default:_(()=>[a(D,{returnTo:{name:s(E)},action:"close"},null,8,["returnTo"])]),_:1})]),_:1})]),s(h)?(i(),r("div",be,[o("main",Te,[a(V,{title:"settings.forms.new_token"},{default:_(()=>[o("form",{onSubmit:z(N,["prevent"]),onKeydown:l[1]||(l[1]=t=>s(u).onKeydown(t))},[a(O,{modelValue:s(u).name,"onUpdate:modelValue":l[0]||(l[0]=t=>s(u).name=t),fieldName:"name",fieldError:s(u).errors.get("name"),inputType:"text",label:"commons.name",autofocus:""},null,8,["modelValue","fieldError"]),o("div",we,[o("div",Ce,[a(B,{id:"btnGenerateToken",isLoading:s(u).isBusy},{default:_(()=>[g(n(e.$t("commons.generate")),1)]),_:1},8,["isLoading"])]),o("div",Fe,[a(B,{onClick:U,nativeType:"button",id:"btnCancel",color:"is-text"},{default:_(()=>[g(n(e.$t("commons.cancel")),1)]),_:1})])])],32)]),_:1})])])):d("",!0)])}}};export{Ae as default}; //# sourceMappingURL=OAuth-B7q39fAh.js.map