1import{d as ce,$ as pe,a0 as he,r as d,c as g,o as fe,Q as ve,E as me,C as p,L as ge,B as a,z as h,D as s,u as n,G as I,N as $,Y as B,O as M}from"./vendor-vue-BlueQChF.js";import{a as _e,u as we,C as J,E as ye,F as be,G as ke,H as xe,I as Ce,h as Se}from"./index-BEPizrPZ.js";import{e as Pe}from"./apiError-zX02PgX9.js";import"./PrivilegeTrialWelcomeDialog.vue_vue_type_style_index_0_scoped_ba72e95a_lang-C8J5lHR0.js";import"./vendor-misc-D0AKwglo.js";import"./useClipboard-DOdQ7bzq.js";import"./vendor-markdown-BgxI06wh.js";/* empty css */import{A as Ae}from"./UserAuthLayout-CFqMZjvq.js";import{u as Te}from"./vendor-i18n-BksPZrLo.js";import"./useBranding-CpVp2POa.js";const Re={class:"space-y-6"},Le={class:"text-center"},Ee={class:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-2xl bg-primary-100 shadow-lg shadow-primary-500/20 dark:bg-primary-900/30"},Ne={key:0,class:"h-8 w-8 animate-spin text-primary-600 dark:text-primary-300",fill:"none",viewBox:"0 0 24 24"},Oe={key:1,class:"h-8 w-8 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},qe={key:2,class:"h-8 w-8 text-primary-600 dark:text-primary-300",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},Ie={class:"text-2xl font-bold text-gray-900 dark:text-white"},$e={class:"mt-2 text-sm text-gray-500 dark:text-dark-400"},Be={key:0,class:"card-glass rounded-2xl p-8 text-center"},Me={class:"mt-4 text-sm text-gray-600 dark:text-gray-300"},Ue={key:1,class:"card-glass rounded-2xl p-8"},He={class:"mb-6 rounded-2xl border border-primary-200 bg-primary-50/70 p-4 dark:border-primary-900/40 dark:bg-primary-900/15"},Ve={class:"text-sm font-medium text-primary-700 dark:text-primary-300"},Fe={class:"mt-1 text-sm text-gray-600 dark:text-gray-300"},Ke={class:"space-y-4"},De={class:"input-label"},ze=["value"],Ge={class:"input-label"},We=["placeholder","disabled"],je={class:"input-label"},Ye=["placeholder","disabled"],Qe={key:0},Ze={class:"input-label"},Je=["placeholder","disabled"],Xe={key:1,class:"text-sm text-red-600 dark:text-red-400"},et=["disabled"],tt={key:2,class:"card-glass rounded-2xl p-6 sm:p-8"},at={class:"rounded-2xl border border-red-200/80 bg-red-50/70 p-4 text-left dark:border-red-900/40 dark:bg-red-950/20"},rt={class:"text-sm leading-6 text-gray-700 dark:text-gray-300"},ot={class:"mt-6 grid gap-3"},R="email_oauth_pending_provider",gt=ce({__name:"UserOAuthCallbackView",setup(nt){const w=pe(),U=he(),{t:r}=Te(),X=_e(),ee=we(),v=d(!1),_=d(!1),k=d(""),m=d(""),x=d(""),C=d(""),f=d(""),u=d(K()),L=d("/usage"),c=d("processing"),E=d("generic"),N=d(!1);let S=null;const H=g(()=>w.query.code||""),V=g(()=>w.query.state||""),P=g(()=>u.value==="google"?"Google":u.value==="github"?"GitHub":r("auth.oauth.providerFallback")),te=g(()=>c.value==="processing"?r("auth.oauth.callbackTitle"):c.value==="registration"?r("auth.oidc.callbackTitle",{providerName:P.value}):r(`auth.oauth.failures.${E.value}.title`)),ae=g(()=>c.value==="processing"?r("auth.oauth.callbackHint"):c.value==="registration"?F.value:r(`auth.oauth.failures.${E.value}.hint`)),F=g(()=>_.value?r("auth.oidc.invitationRequired",{providerName:P.value}):r("auth.oidc.completeRegistration")),re=g(()=>!(!k.value.trim()||m.value.length<6||m.value!==x.value||_.value&&!C.value.trim()));function oe(){const e=typeof window<"u"?window.location.hash:"",t=e.startsWith("#")?e.slice(1):e;return new URLSearchParams(t)}function ne(e){var j,Y,Q,Z;const t=((j=e.get("access_token"))==null?void 0:j.trim())||"";if(!t)return null;const o={access_token:t},l=((Y=e.get("refresh_token"))==null?void 0:Y.trim())||"";l&&(o.refresh_token=l);const i=Number.parseInt(((Q=e.get("expires_in"))==null?void 0:Q.trim())||"",10);Number.isFinite(i)&&i>0&&(o.expires_in=i);const b=((Z=e.get("token_type"))==null?void 0:Z.trim())||"";return b&&(o.token_type=b),o}function O(e){return!e||!e.startsWith("/")||e.startsWith("//")||e.includes("://")||e.includes(` 2`)||e.includes("\r")?"/dashboard":e}function K(){if(typeof window>"u")return null;const e=window.sessionStorage.getItem(R);return e==="github"||e==="google"?e:null}function ie(e){if(typeof window>"u")return;const t=new URLSearchParams;for(const[l,i]of Object.entries(w.query))Array.isArray(i)?i.forEac
2h(b=>{b!=null&&t.append(l,String(b))}):i!=null&&t.set(l,String(i));const o=t.toString()?`?${t.toString()}`:"";window.location.href=J(`/auth/oauth/${e}/callback${o}`)}function D(){if(typeof window>"u"||!window.location.hash)return;const e=window.location.pathname||w.path,t=window.location.search||"";window.history.replaceState(window.history.state,document.title,`${e}${t}`)}function A(){S&&(clearTimeout(S),S=null)}function z(){A(),c.value="processing",N.value=!1,S=setTimeout(()=>{N.value=!0},5e3)}function se(e){switch(e.trim().toLowerCase()){case"provider_error":case"access_denied":return"cancelled";case"invalid_state":case"missing_params":case"pending_auth_session_not_found":case"pending_auth_browser_mismatch":return"expired";case"token_exchange_failed":case"userinfo_failed":case"pending_auth_not_ready":case"network_error":case"err_network":return"unavailable";case"login_blocked":case"user_inactive":return"blocked";default:return"generic"}}function y(e){A(),E.value=se(e||""),c.value="error"}function G(e){const t=Pe(e);return t||(typeof navigator<"u"&&navigator.onLine===!1?"network_error":"unknown")}function W(){typeof window<"u"&&window.sessionStorage.removeItem(R),U.replace("/login")}function le(){if(typeof window>"u"||!u.value){W();return}window.sessionStorage.setItem(R,u.value);const e=new URLSearchParams({redirect:O(L.value)});window.location.href=J(`/auth/oauth/${u.value}/start?${e.toString()}`)}async function q(e,t){ye(e),D(),await ee.setToken(e.access_token),typeof window<"u"&&window.sessionStorage.removeItem(R),be(),X.showSuccess(r("auth.loginSuccess")),await U.replace(O(t))}function ue(e){return typeof e.access_token=="string"&&e.access_token.trim()!==""}async function de(){z();try{const e=await ke(),t=e.redirect||"/dashboard";if(ue(e)){await q(e,t);return}const o=String(e.provider||"").toLowerCase();if((o==="github"||o==="google")&&(u.value=o),L.value=O(t),e.error==="invitation_required"||e.error==="registration_completion_required"){_.value=e.error==="invitation_required"||e.invitation_required===!0,k.value=String(e.resolved_email||e.email||"").trim(),A(),c.value="registration";return}y(e.error)}catch(e){y(G(e))}}async function T(){var t,o;if(f.value="",!k.value.trim()){f.value=r("auth.emailRequired");return}if(m.value.length<6){f.value=r("auth.passwordMinLength");return}if(m.value!==x.value){f.value=r("auth.passwordsDoNotMatch");return}const e=C.value.trim();if(!(_.value&&!e)){if(!u.value){f.value=r("auth.oauth.failures.expired.hint");return}v.value=!0;try{const l={password:m.value,...xe(Ce())};_.value&&(l.invitation_code=e);const{data:i}=await Se.post(`/auth/oauth/${u.value}/complete-registration`,l);await q(i,L.value)}catch(l){const i=l;f.value=((o=(t=i.response)==null?void 0:t.data)==null?void 0:o.message)||i.message||r("auth.oidc.completeRegistrationFailed")}finally{v.value=!1}}}return fe(async()=>{z();const e=oe(),t=ne(e),o=e.get("error")||String(w.query.error||"");if(D(),o){y(o);return}if(t){try{await q(t,e.get("redirect")||"/usage")}catch(i){y(G(i))}return}const l=K();if(l&&(u.value=l),H.value||V.value){if(u.value&&H.value&&V.value){ie(u.value);return}y("missing_params");return}await de()}),ve(A),(e,t)=>(p(),me(n(Ae),{variant:"platform"},{default:ge(()=>[a("div",Re,[a("div",Le,[a("div",Ee,[c.value==="processing"?(p(),h("svg",Ne,[...t[3]||(t[3]=[a("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),a("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):c.value==="error"?(p(),h("svg",Oe,[...t[4]||(t[4]=[a("path",{d:"M12 9v4"},null,-1),a("path",{d:"M12 17h.01"},null,-1),a("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z"},null,-1)])])):(p(),h("svg",qe,[...t[5]||(t[5]=[a("path",{d:"M20 7 10 17l-5-5"},null,-1)])]))]),a("h2",Ie,s(te.value),1),a("p",$e,s(ae.value),1)]),c.value==="processing"?(p(),h("div",Be,[t[6]||(t[6]=a("div",{class:"mx-auto h-10 w-10 animate-spin rounded-full border-2 border-primary-500 border-t-transparent"},null,-1)),a("p",Me,s(N.value?n(r)("auth.oauth.processingLonger"):n(r)("auth.oauth.callbackHint")),1)])):c.value==="registration"?(p(),h("div",Ue,[a("div",He,[a("p",Ve,s(n(r)("auth.oidc.callbackTitle",{providerName:P.value})),1),a("p",Fe,s(F.value),1)]),a("div",Ke,[a("div",null,[a("label",De,s(n(r)("auth.emailLabel")),1),a("input",{class:"input w-full",type:"email",value:k.value,readonly:"",disabled:""},null,8,ze)]),a("div",null,[a("label",Ge,s(n(r)("auth.passwordLabel")),1),$(a("input",{"onUpdate:modelValue":t[0]||(t[0]=o=>m.value=o),type:"password",class:"input w-full",placeholder:n(r)("auth.createPasswordPlaceholder"),disabled:v.value,autocomplete:"new-password",onKeyup:B(T,["enter"])},null,40,We),[[M,m.value]])]),a("div",null,[a("label",je,s(n(r)("auth.confirmPassword")),1),$(a("input",{"onUpdate:modelValue":t[1]||(t[1]=o=>x.value=o),type:"password",class:"input w-full",placeholder:n(r)("auth.confirmPasswordPlaceholder"),disabled:v.value,autocomplete:"new-password",onKeyup:B(T,["enter"])},null,40,Ye),[[M,x.value]])]),_.value?(p(),h("div",Qe,[a("label",Ze,s(n(r)("auth.invitationCodeLabel")),1),$(a("input",{"onUpdate:modelValue":t[2]||(t[2]=o=>C.value=o),type:"text",class:"input w-full",placeholder:n(r)("auth.invitationCodePlaceholder"),disabled:v.value,onKeyup:B(T,["enter"])},null,40,Je),[[M,C.value]])])):I("",!0),f.value?(p(),h("p",Xe,s(f.value),1)):I("",!0),a("button",{class:"btn btn-primary w-full",type:"button",disabled:v.value||!re.value,onClick:T},s(v.value?n(r)("common.processing"):n(r)("auth.oidc.completeRegistration")),9,et)])])):(p(),h("div",tt,[a("div",at,[a("p",rt,s(n(r)("auth.oauth.recoveryHint")),1)]),a("div",ot,[u.value?(p(),h("button",{key:0,class:"btn btn-primary w-full",type:"button",onClick:le},s(n(r)("auth.oauth.retryWithProvider",{providerName:P.value})),1)):I("",!0),a("button",{class:"btn btn-secondary w-full",type:"button",onClick:W},s(n(r)("auth.backToLogin")),1)])]))])]),_:1}))}});
2export{gt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.