1import{c as q}from"./Cqe64Gcu.js";import{e as P,u as S,k as L,f as N,A as $,B,l as z,C as w,o as f,c as g,a as c,g as y,t as d,b as v,w as E,z as R,h as V,i as p,D as I,E as G,d as M}from"./Dqk0Ip7M.js";import{c as O}from"./Db3OHJUX.js";const D=q("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const F=q("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),J={class:"flex items-center justify-center min-h-screen"},Q={class:"text-center"},U={key:0,class:"space-y-4"},X={class:"text-lg"},j={key:1,class:"space-y-4"},H={class:"text-red-600 dark:text-red-400"},K={class:"text-xl font-semibold mb-2"},W={key:2,class:"space-y-4"},Y={class:"text-green-600 dark:text-green-400"},Z={class:"text-xl font-semibold mb-2"},ae=P({__name:"callback",setup(ee){S({meta:[{name:"robots",content:"noindex, nofollow"}]});const o=L(),k=N(),i=p(!0),m=p(!1),_=p(!1),h=p(""),b=$(),u=B(),A=G(),a=e=>Array.isArray(e)?typeof e[0]=="string"?e[0]:null:typeof e=="string"?e:null,T=()=>{const e=a(o.query.customer);if(e)try{return JSON.parse(e)}catch{}const t=a(o.query.customer_id)||a(o.query.customerId),r=a(o.query.email),n=a(o.query.name);return!t&&!r&&!n?null:{id:t?Number(t):void 0,email:r,name:n}},C=async(e,t=null)=>{if(b.setToken(e,"customer"),A.public.apiProxy)try{await $fetch("/api/auth/session",{method:"POST",body:{token:e,type:"customer"}})}catch(n){console.warn("Google callback session cookie could not be created; using local token fallback.",n)}if(t)u.setAuth({customer:t},"customer");else try{await u.initializeAuth()}catch{u.userType="customer",u.isAuthenticated=!0}i.value=!1,_.value=!0,await k.replace({path:"/customer/google/callback",query:{}});const r=O()||"/";setTimeout(()=>k.push(r),800)};return z(async()=>{if(o.query.error){i.value=!1,m.value=!0,h.value=String(o.query.error);return}const e=a(o.query.code),t=a(o.query.state);if(e)try{const s=await $fetch("/api/customer/google/callback",{method:"GET",query:t?{code:e,state:t}:{code:e}}),x=s?.access_token||s?.token||s?.auth_token;if(!x)throw new Error("No access token received from Google callback.");await C(x,s?.customer||null);return}catch{i.value=!1,m.value=!0,h.value="Authentication failed. Please try again.";return}const r=a(o.query.access_token)||a(o.query.token)||a(o.query.auth_token);if(r)try{const s=T();await C(r,s);return}catch{i.value=!1,m.value=!0,h.value="Authentication failed. Please try again.";return}const n=w("auth_session"),l=w("customer_info");if(n.value){try{if(b.setTokenType("customer"),l.value){const s=JSON.parse(String(l.value));u.setAuth({customer:s},"customer")}else await u.initializeAuth();l.value=null}catch{}i.value=!1,_.value=!0,setTimeout(()=>k.push("/"),1500);return}i.value=!1,m.value=!0,h.value="Authentication failed. Please try again."}),(e,t)=>{const r=F,n=I("UiButton"),l=D;return f(),g("div",J,[c("div",Q,[y(i)?(f(),g("div",U,[t[1]||(t[1]=c("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900 dark:border-gray-100 mx-auto"},null,-1)),c("p",X,d(e.$t("auth.processing_login")||"Processing your login..."),1)])):y(m)?(f(),g("div",j,[c("div",H,[v(r,{class:"h-12 w-12 mx-auto mb-4"}),c("h2",K,d(e.$t("auth.login_failed")||"Login Failed"),1),c("p",null,d(y(h)),1)]),v(n,{onClick:t[0]||(t[0]=s=>("navigateTo"in e?e.navigateTo:y(R))("/login"))},{default:E(()=>[M(d(e.$t("auth.back_to_login")||"Back to Login"),1)]),_:1})])):y(_)?(f(),g("div",W,[c("div",Y,[v(l,{class:"h-12 w-12 mx-auto mb-4"}),c("h2",Z,d(e.$t("auth.login_success")||"Login Successful"),1),c("p",null,d(e.$t("auth.redirecting")||"Redirecting..."),1)])])):V("",!0)])])}}});export{ae 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.