1import{j as e}from"./vendor-ui-B72TISsr.js";import{i as de,u as me,f as xe,a as w}from"./vendor-react-DRDp5jUv.js";import{c as K,i as G,e as $,s as v,a as ue,X as M,a3 as he,a4 as pe,a5 as ge,a6 as fe}from"./App-Ca4m7kiA.js";import{u as je}from"./useMutation-Bp2NQQEU.js";import{B as f}from"./button-DNJNxBCj.js";import{C as Ne,a as be,b as ve,c as ye,d as we}from"./card-Bnkt4Dpy.js";import{B as ke}from"./badge-CGDPPfKZ.js";import{A as Ce,a as _e,b as Te}from"./avatar-NGYIouNA.js";import{S as k}from"./separator-CIp2Zzfu.js";import{t as d}from"./sonner-shim-DJmp-ZGn.js";import{i as qe,b as Ae}from"./agentTools-BupGlf5H.js";import{d as Pe,r as Le,c as Ee,g as Se}from"./toolAccessTokenService-uW47Wgh6.js";import{N as $e}from"./aiAgents-Cv9oN43M.js";import{g as Be}from"./aiTeammateProfileCopy-DUTKp92r.js";import{a as Fe}from"./useLocationSharing-dtvF5edg.js";import{A as Q}from"./arrow-left-BLcGnQ6f.js";import{M as L}from"./map-pin-CmjGQ_Gh.js";import{C as z}from"./check-niKk_k3v.js";import{L as C}from"./loader-circle-4X-Tv8UU.js";import{P as O}from"./featureFlags-CqUii2f3.js";import{M as E}from"./message-square-DUt6RE1L.js";import{B as Ie}from"./bot-D8yGT5J8.js";import{S as R}from"./sparkles-JXWKs5Af.js";import"./vendor-supabase-D_kvcy1s.js";import"./vendor-capacitor-DBH9BLG3.js";import"./SecureStorageService-CZimPf89.js";import"./hideNativeSplash-CUK-rfN2.js";import"./vendor-tiptap-D9zhQH0w.js";import"./avatarAssets-BU8op_oT.js";import"./radar-avatar-Qezc-P5h.js";import"./vera-avatar-DQt_DfCb.js";import"./nola-avatar-CeW6za6Y.js";import"./cora-avatar-DynfxAxz.js";import"./green-dolphin-Clhykk-s.js";import"./synapse-akrKn89j.js";const Ue=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],S=K("book-open",Ue);const De=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],W=K("trending-up",De),Me=(r,h)=>{const c=G(),j=h?.enabled!==!1&&!!r,{data:y=[],isLoading:_,error:T}=$({queryKey:["quick-prompts",r],queryFn:async()=>{if(!r)return[];const{data:l,error:i}=await v.from("quick_prompts").select("*").eq("agent_id",r).order("usage_count",{ascending:!1}).order("created_at",{ascending:!1});if(i)throw console.error("Error fetching quick prompts:",i),i;return l},enabled:j,staleTime:1e3*60*5,gcTime:1e3*60*30}),x=je({mutationFn:async l=>{const{error:i}=await v.rpc("increment_quick_prompt_usage",{prompt_id:l});if(i)throw console.error("Error incrementing usage:",i),i},onSuccess:(l,i)=>{c.setQueryData(["quick-prompts",r],(A=[])=>A.map(p=>p.id===i?{...p,usage_count:p.usage_count+1}:p))},onError:l=>{console.error("Failed to increment usage:",l)}});return{quickPrompts:y,isLoading:_,error:T,incrementUsage:l=>{x.mutate(l)},isIncrementing:x.isPending}},ys=()=>{const{agentId:r}=de(),h=me(),{user:c}=ue(),[j]=xe(),y=G(),[_,T]=w.useState(null),[x,q]=w.useState(null),[l,i]=w.useState(null),A=qe(c?.email),{featureEnabled:p,status:u,ready:B,isBusy:g,enable:H,disable:Y,openSettings:V}=Fe(),{data:F=[]}=$({queryKey:["tool-connections",c?.id],queryFn:Se,enabled:!!c?.id&&A,staleTime:3e4}),N=j.get("prompt"),b=j.get("prompts")==="0"||j.get("prompts")==="false",{data:o,isLoading:X,error:J}=$({queryKey:["ai-agent-profile",r],queryFn:async()=>{if(!r)throw new Error("Agent ID is required");const{data:s,error:a}=await v.from("profiles").select("*").eq("id",r).eq("type","ai_agent").single();if(a)throw console.error("Error fetching agent profile:",a),a;return s},enabled:!!r}),{quickPrompts:I,isLoading:Z,incrementUsage:ee}=Me(r||"",{enabled:!b});w.useEffect(()=>{(async()=>{if(!(!c?.id||!r))try{const{data:a,error:t}=await v.from("direct_conversations").select("id").or(`and(user1_id.eq.${c.id},user2_id.eq.${r}),and(user1_id.eq.${r},user2_id.eq.${c.id})`).limit(1).single();if(a&&!t){q(a.id);return}const{data:n,error:m}=await v.from("direct_conversations").insert({user1_id:c.id,user2_id:r}).select("id").single();if(m){console.error("Error creating conversation:",m);return}n&&q(n.id)}catch(a){console.error("Error finding/creating conversation:",a)}})()},[c?.id,r]);const se=(s,a)=>{T(s),ee(s),x?h(`/app?conversation=${x}&prompt=${encodeURIComponent(a)}`):d.error("Unable to start chat. Please try again.")},ae=()=>{h(x?`/app?conversation=${x}`:"/app")},re=async(s,a)=>
1{if(!l){i(s);try{const t=F.find(n=>n.tool_id===s);if(t&&t.status!=="connected")await Le(s),d.success(`${a} reconnected.`);else{const n=await Ee(s);d.success(n.account_email?`${a} connected (${n.account_email}).`:`${a} connected.`)}await y.invalidateQueries({queryKey:["tool-connections",c?.id]})}catch(t){const n=t instanceof Error?t.message:"Failed to connect";n!=="Authorization cancelled"&&d.error(`Could not connect ${a}: ${n}`)}finally{i(null)}}},te=async(s,a)=>{if(!l){i(s);try{await Pe(s),d.success(`${a} disconnected.`),await y.invalidateQueries({queryKey:["tool-connections",c?.id]})}catch(t){const n=t instanceof Error?t.message:"Failed to disconnect";d.error(`Could not disconnect ${a}: ${n}`)}finally{i(null)}}},ne=async()=>{const s=await H();if(s.enabled){d.success("Location sharing is on for Nola.");return}if(s.blocked){const a=await V();d.error(a?"Location is blocked for ateams. Turn it on in Settings, then come back.":"Location is blocked for ateams. Allow location access in your device or browser settings.");return}if(!s.supported){d.error("This device doesn't support location sharing.");return}d.message("Location permission wasn't granted.")},ie=async()=>{await Y(),d.success("Nola will stop using your location on this device.")},oe=s=>s.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2),ce=s=>{switch(s.toLowerCase()){case"tempo":return e.jsx(W,{className:"h-4 w-4"});case"vera":return e.jsx(R,{className:"h-4 w-4"});case"radar":return e.jsx(S,{className:"h-4 w-4"});case"cora":return e.jsx(R,{className:"h-4 w-4"});case"nola":return e.jsx(S,{className:"h-4 w-4"});default:return e.jsx(Ie,{className:"h-4 w-4"})}};if(X)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading agent profile..."})]})});if(J||!o)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-destructive mb-4",children:"Agent Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"The AI agent you're looking for doesn't exist."}),e.jsxs(f,{onClick:()=>h("/app"),variant:"outline",children:[e.jsx(Q,{className:"h-4 w-4 mr-2"}),"Back to Home"]})]})});const U=Ae(o.name),P=U.length>0,D=p&&o.id===$e,le=new Map(F.map(s=>[s.tool_id,s]));return e.jsx("div",{className:"h-dvh bg-background overflow-y-auto overscroll-contain",style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:e.jsxs("div",{className:"container mx-auto px-4 py-4 sm:py-8 max-w-4xl pb-[max(1.5rem,env(safe-area-inset-bottom))]",children:[e.jsxs("div",{className:"mb-6 sm:mb-8",children:[e.jsxs(f,{onClick:ae,variant:"ghost",className:"mb-4 sm:mb-6 -ml-2 min-h-[44px] touch-manipulation",children:[e.jsx(Q,{className:"h-4 w-4 mr-2"}),"Back to Chat"]}),e.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[e.jsxs(Ce,{className:"h-20 w-20 sm:h-28 sm:w-28 md:h-32 md:w-32 flex-shrink-0 transition-all",children:[e.jsx(_e,{src:o.avatar_url||void 0}),e.jsx(Te,{className:"text-2xl sm:text-3xl md:text-4xl",children:oe(o.name)})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3",children:[e.jsx("h1",{className:"text-2xl sm:text-4xl font-bold truncate",children:o.name}),e.jsxs(ke,{variant:"secondary",className:"flex items-center gap-1 w-fit",children:[ce(o.name),"AI Collaborator"]})]})})]})]}),e.jsx(k,{className:"my-6 sm:my-8"}),e.jsx("div",{className:"mb-6 sm:mb-8",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-3 lg:gap-8",children:[e.jsx("div",{className:"lg:w-32 flex-shrink-0",children:e.jsxs("h2",{className:"text-base sm:text-lg font-semibold flex items-center gap-2",children:[e.jsx(S,{className:"h-5 w-5"}),"Description"]})}),e.jsx("div",{className:"flex-1 min-w-0",children:(()=>{const s=Be(o.name)?.profileBullets;return s?.length===1?e.jsx("p",{className:"text-muted-foreground leading-relaxed text-sm sm:text-base",children:s[0]}):s&&s.length>1?e.jsx("ul",{className:"list-disc pl-5 space-y-1.5 text-muted-foreground text-sm sm:text-base leading-relaxed",children:s.map(a=>e.jsx("li",{children:a},a))}):e.jsx("p",{className:"text-muted-foreground leading-relaxed text-sm sm:text-base",children:o.description||"No description available for this AI agent."})})()})]})}),(D||P||N||!b)&&e.jsx(k,{className:"my-6 sm:my-8"}),D&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-6 sm:mb-8",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 lg:gap-6",children:[e.jsx("div",{className:"lg:w-32 flex-shrink-0",children:e.jsxs("h2",{className:"text-base sm:text-lg font-semibold flex items-center gap-2",children:[e.jsx(L,{className:"h-5 w-5"}),"Location"]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Let ",o.name," use your approximate location to answer questions about places near you."]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-4",children:["Your location is only attached to messages you send to ",o.name,", is never shown in the conversation, and is never visible to your teammates."]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.jsxs("div",{className:"flex flex-col gap-3 p-4 rounded-lg border border-border bg-card transition-all hover:border-primary/50",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(L,{className:"h-8 w-8 flex-shrink-0 text-muted-foreground","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:"Use my location"}),u.enabled&&e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full bg-green-500","aria-label":"On",children:e.jsx(z,{className:"h-3 w-3 text-white",strokeWidth:3})})]}),u.enabled&&e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:"On for this device"}
1),u.blocked&&e.jsx("div",{className:"text-xs text-amber-600 dark:text-amber-400 truncate",children:"Blocked in device settings"}),B&&!u.supported&&e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:"Not available on this device"})]})]}),u.enabled?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full min-h-[44px] sm:min-h-0 text-muted-foreground hover:text-destructive touch-manipulation",disabled:g,onClick:ie,children:[g?e.jsx(C,{className:"h-3.5 w-3.5 mr-2 animate-spin"}):e.jsx(M,{className:"h-3.5 w-3.5 mr-2"}),g?"Workingâ¦":"Turn off"]}):e.jsxs(f,{variant:"outline",size:"sm",className:"w-full min-h-[44px] sm:min-h-0 touch-manipulation",disabled:g||B&&!u.supported,onClick:ne,children:[g?e.jsx(C,{className:"h-3.5 w-3.5 mr-2 animate-spin"}):e.jsx(L,{className:"h-3.5 w-3.5 mr-2"}),g?"Workingâ¦":u.blocked?"Open settings":"Turn on"]})]})})]})]})}),(P||N||!b)&&e.jsx(k,{className:"my-6 sm:my-8"})]}),P&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-6 sm:mb-8",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 lg:gap-6",children:[e.jsx("div",{className:"lg:w-32 flex-shrink-0",children:e.jsxs("h2",{className:"text-base sm:text-lg font-semibold flex items-center gap-2",children:[e.jsx(O,{className:"h-5 w-5"}),"Tools"]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Connect your accounts to let ",o.name," work with these tools on your behalf. We only access data to perform actions you request."]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-4",children:["By connecting, you agree to our"," ",e.jsx("a",{href:"/ateams_privacy.html#google-workplace-integrations",className:"underline hover:text-foreground",target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"})," ","and Google's"," ",e.jsx("a",{href:"https://developers.google.com/terms/api-services-user-data-policy",className:"underline hover:text-foreground",target:"_blank",rel:"noopener noreferrer",children:"API Services User Data Policy"}),"."]}),e.jsx(he,{delayDuration:150,children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:U.map(s=>{const a=le.get(s.id),t=a?.status==="connected",n=!!a&&!t,m=l===s.id;return e.jsxs("div",{className:"flex flex-col gap-3 p-4 rounded-lg border border-border bg-card transition-all hover:border-primary/50",children:[e.jsxs(pe,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-3 cursor-default min-w-0",children:[e.jsx("img",{src:s.icon,alt:`${s.label} logo`,className:"h-8 w-8 flex-shrink-0 object-contain",loading:"lazy"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:s.label}),t&&e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full bg-green-500","aria-label":"Connected",children:e.jsx(z,{className:"h-3 w-3 text-white",strokeWidth:3})})]}),t&&a?.account_email&&e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:a.account_email}),n&&e.jsx("div",{className:"text-xs text-amber-600 dark:text-amber-400 truncate",children:"Access revoked. Reconnect required"})]})]})}),e.jsx(fe,{side:"top",className:"max-w-[240px]",children:s.description})]}),t?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full min-h-[44px] sm:min-h-0 text-muted-foreground hover:text-destructive touch-manipulation",disabled:m,onClick:()=>te(s.id,s.label),children:[m?e.jsx(C,{className:"h-3.5 w-3.5 mr-2 animate-spin"}):e.jsx(M,{className:"h-3.5 w-3.5 mr-2"}),m?"Workingâ¦":"Disconnect"]}):e.jsxs(f,{variant:"outline",size:"sm",className:"w-full min-h-[44px] sm:min-h-0 touch-manipulation",disabled:m,onClick:()=>re(s.id,s.label),children:[m?e.jsx(C,{className:"h-3.5 w-3.5 mr-2 animate-spin"}):e.jsx(O,{className:"h-3.5 w-3.5 mr-2"}),m?"Connectingâ¦":n?"Reconnect":"Connect"]})]},s.id)})})})]})]})}),(N||!b)&&e.jsx(k,{className:"my-6 sm:my-8"})]}),N&&e.jsxs(Ne,{className:"mt-6 border-primary/20 bg-primary/5",children:[e.jsxs(be,{children:[e.jsxs(ve,{className:"flex items-center gap-2 text-primary",children:[e.jsx(E,{className:"h-5 w-5"}),"Ready to Chat"]}),e.jsxs(ye,{children:["You have a prompt ready to send to ",o.name]})]}),e.jsx(we,{children:e.jsx("div",{className:"p-4 rounded-lg bg-background border",children:e.jsx("p",{className:"text-sm leading-relaxed",children:N})})})]}),!b&&e.jsx("div",{className:"mb-8",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 lg:gap-6",children:[e.jsx("div",{className:"lg:w-32 flex-shrink-0",children:e.jsxs("h2",{className:"text-base sm:text-lg font-semibold flex items-center gap-2",children:[e.jsx(E,{className:"h-5 w-5"}),"Quick Prompts"]})}),e.jsx("div",{className:"flex-1 min-w-0",children:Z?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading prompts..."})]}):I.length>0?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 ga
1p-3",children:I.slice(0,10).map(s=>e.jsx("div",{className:`p-4 rounded-lg border cursor-pointer transition-all touch-manipulation hover:bg-muted/50 hover:border-primary/50 active:bg-muted/50 ${_===s.id?"bg-primary/10 border-primary":"border-border"}`,onClick:()=>se(s.id,s.prompt_text),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("p",{className:"text-sm leading-relaxed break-words",children:s.prompt_text}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(W,{className:"h-3 w-3"}),e.jsx("span",{children:s.usage_count})]})]})},s.id))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(E,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No quick prompts available for this agent."})]})})]})})]})})};export{ys as AIAgentProfilePage};
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.