1import{d as M,u as $,a as N,b as P,v as q,o as V,c as i,e as c,f as t,g as o,_ as I,w as l,h as n,x as C,t as d,i as U,k as x,F as A,m as u,y as L,j as H,l as J,r as _,s as v}from"./MybY4GKQ.js";import{_ as K}from"./Be_a3qE1.js";import{_ as Q}from"./DM3Ey41o.js";import{_ as W}from"./BMYEx8Iy.js";import"./0hBPEUgy.js";import"./B1eai8RZ.js";import"./Bfv5cchR.js";import"./BJ7wMOIh.js";import"./D4k11_F0.js";const X={class:"px-4 py-6 md:px-6 lg:px-8"},Y={class:"mb-6 flex items-center gap-3"},Z={class:"flex h-9 w-9 items-center justify-center rounded-lg bg-blue-500/10 ring-1 ring-blue-500/20"},ee={class:"max-w-3xl space-y-6"},te={class:"flex items-center gap-2"},se={key:0,class:"space-y-3"},ne={key:1,class:"space-y-4"},oe={class:"flex items-center gap-3"},ie={class:"text-sm font-medium text-zinc-900 dark:text-white"},re={key:0,class:"flex items-center gap-2 rounded-lg bg-amber-50 dark:bg-amber-500/10 px-3 py-2.5 ring-1 ring-amber-200 dark:ring-amber-500/20"},ae={class:"text-xs text-amber-700 dark:text-amber-400"},ce={class:"font-medium"},le={key:1,class:"flex items-center gap-2 text-sm text-zinc-500 dark:text-zinc-400"},de={class:"font-medium text-zinc-700 dark:text-zinc-300"},ue={class:"rounded-lg bg-zinc-50 dark:bg-zinc-800/50 ring-1 ring-zinc-200 dark:ring-zinc-700/50 p-4 space-y-2.5"},pe={class:"flex items-center justify-between"},me={class:"text-xs font-mono text-zinc-700 dark:text-zinc-300"},ge={class:"flex items-center justify-between"},xe={key:0,class:"pt-1 border-t border-zinc-200 dark:border-zinc-700/50"},he={class:"flex flex-wrap gap-1"},fe={key:1,class:"flex items-center justify-between pt-1 border-t border-zinc-200 dark:border-zinc-700/50"},be={class:"text-xs text-zinc-700 dark:text-zinc-300"},ke={key:1,class:"space-y-3 pt-1"},_e={class:"flex items-center justify-between"},ve={key:0,class:"flex items-center gap-2"},ye={class:"flex items-center gap-2"},ze={class:"space-y-3"},we={class:"text-sm font-medium text-zinc-900 dark:text-white"},Ce={class:"text-xs text-zinc-500 dark:text-zinc-400"},Be=M({__name:"google",setup(Ae){$({title:"Google Services | CLSDleads"});const{apiFetch:y}=N(),m=P(),g=q(),s=_(null),h=_(!0),f=_(!1),b=_(!1),E=[{label:"Google Drive",description:"Creates and shares Google Sheets from templates for new delivery integrations.",icon:"i-heroicons-folder",bg:"bg-yellow-500/10",iconColor:"text-yellow-500"},{label:"Google Sheets",description:"Appends lead data to user sheets as leads are delivered.",icon:"i-heroicons-table-cells",bg:"bg-green-500/10",iconColor:"text-green-500"}],F=v(()=>s.value?.expiresAt?s.value.expiresAt-Date.now()<1440*60*1e3:!1),S=v(()=>s.value?.expiresAt?new Date(s.value.expiresAt).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}):""),j=v(()=>s.value?.updatedAt?new Date(s.value.updatedAt).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}):""),B=v(()=>s.value?.scope?s.value.scope.split(" ").map(r=>r.replace("https://www.googleapis.com/auth/","")):[]);async function G(){h.value=!0;try{const r=await y("/api/admin/google/status");s.value=r.data}catch{s.value={connected:!1}}finally{h.value=!1}}async function D(){f.value=!0;try{const r=await y("/api/admin/google/connect");window.location.href=r.data.url}catch(r){m.add({title:"Error",description:r?.message||"Failed to initiate Google OAuth",color:"error"}),f.value=!1}}async function O(){try{await y("/api/admin/google/disconnect",{method:"DELETE"}),s.value={connected:!1},m.add({title:"Disconnected",description:"Google credentials have been removed.",color:"primary"})}catch(r){m.add({title:"Error",description:r?.message||"Failed to disconnect",color:"error"})}b.value=!1}return V(async()=>{if(await G(),g.query.connected==="true")m.add({title:"Connected",description:"Google OAuth credentials saved successfully.",color:"success"}),history.replaceState({},"",g.path);else if(g.query.error){const r={missing_params:"OAuth callback missing required parameters.",invalid_state:"Invalid OAuth state â possible CSRF. Please try again.",token_exchange_failed:"Failed to exchange authorization code for tokens."};m.add({title:"Connection Failed",description:r[g.query.error]||"An unknown error occurred.",color:"error"}),history.replaceState({},"",g.path)}}),(r,e)=>{const p=I,z=K,w=Q,k=H,T=J,R=W;return i(),c("div",X,[t("div",Y,[t("div",Z,[o(p,{name:"i-simple-icons-google",class:"h-5 w-5 text-blue-500 dark:text-blue-400"})]),e[2]||(e[2]=t("div",null,[t("h1",{class:"text-xl font-semibold tracking-tight text-gray-900 dark:text-white"},"Google Services"),t("p",{class:"text-sm text-zinc-500 dark:text-zinc-400"},"OAuth credentials for Google Drive and Sheets")],-1))]),t("div",ee,[o(T,{ui:{root:"ring-1 ring-zinc-200 dark:ring-zinc-800 bg-white dark:bg-zinc-900/60 backdrop-blur-sm",header:"border-b border-zinc-200 dark:border-zinc-800 px-5 py-4",body:"p-5",footer
1:"border-t border-zinc-200 dark:border-zinc-800 px-5 py-4"}},{header:l(()=>[t("div",te,[o(p,{name:"i-heroicons-key",class:"h-4 w-4 text-zinc-500 dark:text-zinc-400"}),e[3]||(e[3]=t("p",{class:"text-sm font-semibold text-zinc-900 dark:text-white"},"Google OAuth Connection",-1))])]),footer:l(()=>[t("div",_e,[o(k,{color:"neutral",variant:"ghost",size:"sm",icon:"i-lucide-refresh-cw",loading:n(h),onClick:G},{default:l(()=>[...e[13]||(e[13]=[u(" Refresh ",-1)])]),_:1},8,["loading"]),n(s)?.connected?(i(),c("div",ve,[o(k,{color:"primary",variant:"ghost",size:"sm",icon:"i-heroicons-arrow-path",loading:n(f),onClick:D},{default:l(()=>[...e[14]||(e[14]=[u(" Reconnect ",-1)])]),_:1},8,["loading"]),o(k,{color:"error",variant:"ghost",size:"sm",icon:"i-heroicons-x-circle",onClick:e[0]||(e[0]=a=>b.value=!0)},{default:l(()=>[...e[15]||(e[15]=[u(" Disconnect ",-1)])]),_:1})])):x("",!0)])]),default:l(()=>[n(h)?(i(),c("div",se,[o(z,{class:"h-5 w-48"}),o(z,{class:"h-4 w-64"}),o(z,{class:"h-9 w-32 mt-2"})])):(i(),c("div",ne,[t("div",oe,[t("div",{class:C(["h-2.5 w-2.5 rounded-full shrink-0 transition-colors",n(s)?.connected?"bg-emerald-500 shadow-[0_0_6px_1px_--theme(--color-emerald-500/0.4)]":"bg-zinc-400"])},null,2),t("span",ie,d(n(s)?.connected?"Connected":"Not connected"),1),n(s)?.connected?(i(),U(w,{key:0,label:"Active",color:"success",variant:"subtle",size:"sm"})):x("",!0)]),n(s)?.connected?(i(),c(A,{key:0},[n(s).expiresAt&&n(F)?(i(),c("div",re,[o(p,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4 shrink-0 text-amber-700 dark:text-amber-400"}),t("p",ae,[e[4]||(e[4]=u(" Access token expires ",-1)),t("span",ce,d(n(S)),1),e[5]||(e[5]=u(". Consider reconnecting. ",-1))])])):n(s).expiresAt?(i(),c("div",le,[o(p,{name:"i-heroicons-clock",class:"h-4 w-4 shrink-0"}),t("span",null,[e[6]||(e[6]=u("Token expires ",-1)),t("span",de,d(n(S)),1)])])):x("",!0),t("div",ue,[t("div",pe,[e[7]||(e[7]=t("span",{class:"text-xs text-zinc-500 dark:text-zinc-400"},"Access Token",-1)),t("span",me,d(n(s).accessTokenPreview),1)]),t("div",ge,[e[8]||(e[8]=t("span",{class:"text-xs text-zinc-500 dark:text-zinc-400"},"Refresh Token",-1)),o(w,{label:n(s).hasRefreshToken?"Present":"Missing",color:n(s).hasRefreshToken?"success":"error",variant:"subtle",size:"xs"},null,8,["label","color"])]),n(s).scope?(i(),c("div",xe,[e[9]||(e[9]=t("span",{class:"text-xs text-zinc-500 dark:text-zinc-400 block mb-1.5"},"Scopes",-1)),t("div",he,[(i(!0),c(A,null,L(n(B),a=>(i(),U(w,{key:a,label:a,color:"neutral",variant:"subtle",size:"xs"},null,8,["label"]))),128))])])):x("",!0),n(s).updatedAt?(i(),c("div",fe,[e[10]||(e[10]=t("span",{class:"text-xs text-zinc-500 dark:text-zinc-400"},"Last Updated",-1)),t("span",be,d(n(j)),1)])):x("",!0)])],64)):(i(),c("div",ke,[e[12]||(e[12]=t("p",{class:"text-sm text-zinc-500 dark:text-zinc-400"}," Connect a Google account to enable Google Drive file management and Google Sheets integration. Transactional email does not use this. It goes through the SMTP relay. ",-1)),o(k,{color:"primary",icon:"i-heroicons-link",loading:n(f),onClick:D},{default:l(()=>[...e[11]||(e[11]=[u(" Connect Google Account ",-1)])]),_:1},8,["loading"])]))]))]),_:1}),o(T,{ui:{root:"ring-1 ring-zinc-200 dark:ring-zinc-800 bg-white dark:bg-zinc-900/60 backdrop-blur-sm",header:"border-b border-zinc-200 dark:border-zinc-800 px-5 py-4",body:"p-5"}},{header:l(()=>[t("div",ye,[o(p,{name:"i-heroicons-information-circle",class:"h-4 w-4 text-zinc-500 dark:text-zinc-400"}),e[16]||(e[16]=t("p",{class:"text-sm font-semibold text-zinc-900 dark:text-white"},"Services Using These Credentials",-1))])]),default:l(()=>[t("div",ze,[(i(),c(A,null,L(E,a=>t("div",{key:a.label,class:"flex items-start gap-3"},[t("div",{class:C(["flex h-8 w-8 items-center justify-center rounded-lg shrink-0",a.bg])},[o(p,{name:a.icon,class:C(["h-4 w-4",a.iconColor])},null,8,["name","class"])],2),t("div",null,[t("p",we,d(a.label),1),t("p",Ce,d(a.description),1)])])),64))])]),_:1})]),o(R,{open:n(b),title:"Disconnect Google",message:"This will remove the stored OAuth credentials. Google Drive and Sheets integrations will stop working until reconnected. Email is unaffected â it goes through the SMTP relay.",description:"Any active deliveries using Google Sheets will fail until new credentials are provided.","confirm-label":"Disconnect",icon:"i-heroicons-exclamation-triangle",variant:"danger","onUpdate:open":e[1]||(e[1]=a=>b.value=a),onConfirm:O},null,8,["open"])])}}});
1export{Be 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.