"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9317],{11813:function(e,t,a){a.d(t,{T:function(){return o},i:function(){return d}});var r=a(27573),n=a(71357),s=a(63623),i=a(75674),l=a(7653),c=a(2435);function o(e){let{agent:t,author:a}=e,{agentJoin:o}=(0,s.m_)(),[d,u]=(0,l.useState)(!1);return(0,r.jsx)("div",{className:"bg-gray-100 border p-4 text-black",children:(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("div",{className:"mr-4 size-[120px] min-w-[120px] md:size-[160px] md:min-w-[160px] flex items-center justify-center",children:(0,r.jsx)("div",{className:"w-full h-full bg-cover bg-top",style:{backgroundImage:(0,n.j)(t.preview_url)?"url(".concat(t.preview_url,")"):"none",backgroundColor:(0,n.j)(t.preview_url)?"transparent":"#ccc",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"2rem",fontWeight:"bold",color:"#fff"},children:!(0,n.j)(t.preview_url)&&t.name.charAt(0)})}),(0,r.jsxs)("div",{className:"min-w-40 text-md capitalize w-full relative",children:[(0,r.jsxs)("a",{href:"/agents/".concat(t.id),className:"block hover:underline",children:[(0,r.jsx)("div",{className:"font-bold text-lg line-clamp-1 uppercase",children:t.name}),(0,r.jsx)("div",{className:"line-clamp-2",children:t.description})]}),(0,r.jsx)("div",{className:"flex absolute bottom-0 right-0",children:(0,r.jsx)(c.hU,{onClick:async e=>{e.preventDefault(),e.stopPropagation(),u(!0),await o(t.id)},icon:"Chat",size:"small",variant:"primary"})}),(0,r.jsxs)("div",{className:"text-gray-400 line-clamp-1",children:[(0,r.jsx)(i.qO,{className:"mr-1 align-middle size-4 inline-block"})," ",a]})]})]})})}function d(){return(0,r.jsx)("div",{className:"bg-gray-100 border p-4 text-black",children:(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("div",{className:"mr-4 size-[160px] min-w-[160px] flex items-center justify-center bg-cover",children:(0,r.jsx)("div",{className:"h-full w-full bg-gray-300"})}),(0,r.jsxs)("div",{className:"min-w-40 text-md capitalize w-full relative",children:[(0,r.jsx)("div",{className:"bg-gray-300 rounded h-6 mb-4 w-3/4"}),(0,r.jsx)("div",{className:"bg-gray-300 rounded h-4 mb-2 w-full"}),(0,r.jsx)("div",{className:"bg-gray-300 rounded h-4 mb-2 w-full"}),(0,r.jsx)("div",{className:"bg-gray-300 rounded h-4 mb-2 w-full"}),(0,r.jsx)("div",{className:"text-center ml-6 absolute bottom-0 right-0",children:(0,r.jsx)("div",{className:"bg-gray-300 rounded h-3 w-10"})})]})]})})}},89675:function(e,t,a){a.d(t,{Agents:function(){return o}});var r=a(27573),n=a(7653),s=a(11813);function i(e){let{agents:t,loading:a,range:n}=e;return a?(0,r.jsx)(r.Fragment,{children:Array.from({length:n}).map((e,t)=>(0,r.jsx)(s.i,{},t))}):t.length?t.map((e,t)=>(0,r.jsx)(s.T,{agent:e,author:null==e?void 0:e.author.name},t)):"No agents found."}var l=a(32121),c=a(2435);function o(e){let{loadmore:t=!1,search:a=!0,range:s=5,row:o=!1}=e,{supabase:d}=(0,l.$4)(),[u,m]=(0,n.useState)([]),[h,f]=(0,n.useState)(!0),[x,g]=(0,n.useState)(0),[v,p]=(0,n.useState)(s),[j,b]=(0,n.useState)(!0),[N,_]=(0,n.useState)(!1),[w,E]=(0,n.useState)(""),[C,y]=(0,n.useState)(w),I=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:x,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:v;""!==w&&f(!0);let{data:r,error:n}=await d.from("assets").select("*, author: accounts ( id, name )").eq("origin","sdk").ilike("name","%".concat(C,"%")).range(t,a-1).order("created_at",{ascending:!1});n?console.error(n):(e?m(r):m(e=>[...e,...r]),r.length<s?b(!1):b(!0)),f(!1),_(!1)};return(0,n.useEffect)(()=>{let e=setTimeout(()=>{y(w)},300);return()=>{clearTimeout(e)}},[w]),(0,n.useEffect)(()=>{g(0),p(s),I(!0,0,s)},[C]),(0,r.jsxs)(r.Fragment,{children:[a&&(0,r.jsxs)("div",{className:"flex mb-4",children:[(0,r.jsx)("h1",{className:"text-3xl font-bold text-left text-[#2D4155] w-full",children:"Agents"}),(0,r.jsx)("input",{type:"text",placeholder:"Search agents...",value:w,className:"w-60 px-4 py-2 bg-gray-100 border-2 border-gray-900 text-gray-900 text-sm",onChange:e=>{E(e.target.value)}})]}),(0,r.jsx)("div",{className:"grid ".concat(o?"grid-cols-1":"grid-cols-1 md:grid-cols-2"," gap-4"),children:(0,r.jsx)(i,{agents:u,loading:h,range:s})}),t&&(0,r.jsx)("div",{className:"text-center pt-8",children:u.length>0&&j&&(0,r.jsx)(c.zx,{size:"large",onClick:()=>{let e=v+s;g(v),p(e),_(!0),I(!1,v,e)},children:N?"Loading agents...":"Load More"})})]})}},85372:function(e,t,a){a.d(t,{AgentProfile:function(){return f}});var r=a(27573),n=a(7653),s=a(32121),i=a(50294),l=a(75674),c=a(71357),o=a(63623),d=a(2435),u=a(38554),m=a(88146);function h(e){let{agent:t}=e,{supabase:a}=(0,s.$4)(),[i,l]=(0,n.useState)([]),[c,o]=(0,n.useState)(!0);return(0,n.useEffect)(()=>{(async function(){o(!0);let{data:e,error:r}=await a.from("chat_specifications").select("data").eq("user_id",t.id);o(!1),console.log(e),r?console.error("Error fetching rooms:",r):l((null==e?void 0:e.map(e=>e.data.room))||[])})()},[t.id,a]),(0,r.jsx)("div",{className:"w-full",children:c?(0,r.jsx)("div",{className:"mt-4",children:"Loading Rooms"}):i.length>0?(0,r.jsx)("div",{className:"mt-4",children:i.map(e=>(0,r.jsx)(m.default,{href:"/rooms/".concat(e),children:(0,r.jsx)(d.zx,{style:{width:"100%",marginBottom:"8px"},children:e})},e))}):(0,r.jsx)("div",{className:"mt-4",children:"No rooms found"})})}function f(e){var t,a;let{agent:f}=e,{agentJoin:x}=(0,o.m_)(),[g,v]=(0,u.Z)("feed"),{isCopied:p,copyToClipboard:j}=function(e){let{timeout:t=2e3}=e,[a,r]=n.useState(!1);return{isCopied:a,copyToClipboard:e=>{var a;(null===(a=navigator.clipboard)||void 0===a?void 0:a.writeText)&&e&&navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>{r(!1)},t)})}}}({timeout:2e3}),{supabase:b}=(0,s.$4)(),[N,_]=(0,n.useState)([]),[w,E]=(0,n.useState)(!0),C=(null===(a=f.images)||void 0===a?void 0:null===(t=a[0])||void 0===t?void 0:t.url)||"/images/backgrounds/agents/default-agent-profile-background.jpg",y=(0,c.j)(f.preview_url),I=f.name.charAt(0).toUpperCase();return(0,n.useEffect)(()=>{(async function(){E(!0);let{data:e,error:t}=await b.from("chat_specifications").select("data").eq("user_id",f.id);E(!1),console.log(e),t?console.error("Error fetching rooms:",t):_((null==e?void 0:e.map(e=>e.data.room))||[])})()},[f.id,b]),(0,r.jsx)("div",{className:"w-full h-[calc(100vh-64px)] bg-cover bg-center",style:{backgroundImage:'url("'.concat(C,'")')},children:(0,r.jsxs)("div",{className:"w-full max-w-6xl mx-auto h-full pt-20 relative",children:[(0,r.jsxs)("div",{className:"absolute bottom-16 left-4",children:[(0,r.jsx)("div",{className:"mr-4 mb-4 size-40 border-2 border-black rounded-xl bg-opacity-10 overflow-hidden flex items-center justify-center",children:y?(0,r.jsx)(i.default,{src:f.preview_url,alt:"Profile picture",width:160,height:160}):(0,r.jsx)("div",{className:"uppercase text-lg font-bold",children:I})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-6xl uppercase font-bold text-stroke",children:f.name}),(0,r.jsxs)("div",{className:"flex items-center mb-1",children:[(0,r.jsx)("h3",{className:"text-sm bg-gray-800 px-2 py-1",children:f.id}),(0,r.jsxs)(d.zx,{variant:"ghost",size:"small",onClick:()=>{p||j(f.id)},children:[p?(0,r.jsx)(l.NO,{}):(0,r.jsx)(l.vU,{}),(0,r.jsx)("span",{className:"sr-only",children:"Copy ID"})]})]}),(0,r.jsx)("h3",{className:"text-lg mb-4",children:(0,r.jsxs)(m.default,{href:"/accounts/".concat(f.author.id),children:["Created by: ",f.author.name]})}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)(d.zx,{onClick:()=>x(f.id),children:"Chat"}),(0,r.jsx)(d.hU,{onClick:()=>v("feed"),active:"feed"===g,icon:"Info",size:"small",variant:"primary"}),(0,r.jsx)(d.hU,{onClick:()=>v("rooms"),active:"rooms"===g,icon:"Room",size:"small",variant:"primary"})]})]})]}),(0,r.jsx)("div",{className:"absolute top-0 right-0 w-1/2 h-full bg-opacity-90 p-4 overflow-y-auto",children:"rooms"===g&&(0,r.jsx)(h,{agent:f})})]})})}},38696:function(e,t,a){a.d(t,{NZ:function(){return n},OB:function(){return r}});let r={NEXT_PUBLIC_ENVIRONMENT:"production",NEXT_PUBLIC_VERCEL_BRANCH_URL:"chat-git-main-webmixedreality-s-team.vercel.app",NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF:"main",NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA:"1eac6b71f29e75fde5ec50594dae9afb9fd5728a",NEXT_PUBLIC_VERCEL_GIT_PREVIOUS_SHA:"",NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE:"Update README.md",NEXT_PUBLIC_SUPABASE_URL:"https://friddlbqibjnxjoxeocc.supabase.co",NEXT_PUBLIC_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZyaWRkbGJxaWJqbnhqb3hlb2NjIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDM2NjE3NDIsImV4cCI6MjAxOTIzNzc0Mn0.jnvk5X27yFTcJ6jsCkuXOog1ZN825md4clvWuGQ8DMI"},n="main"===r.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF?"production":"development"},38554:function(e,t,a){var r=a(81695),n=a(7653);let s=()=>decodeURIComponent(window.location.hash.replace("#",""));t.Z=e=>{let[t,a]=(0,n.useState)(s()||e||""),i=(0,r.useParams)(),l=(0,n.useCallback)(e=>{e!==t&&(window.location.hash=e,a(e))},[t]);return(0,n.useEffect)(()=>{let t=()=>{a(s())};return l(s()||e||""),window.addEventListener("hashchange",t),window.addEventListener("navigate",t),()=>{window.removeEventListener("hashchange",t),window.removeEventListener("navigate",t)}},[i]),[t,l]}},32121:function(e,t,a){let r,n;a.d(t,{$4:function(){return u},FV:function(){return f}});var s=a(27573),i=a(7653),l=a(15127),c=a(38696),o=a(86830);let d=i.createContext(void 0);function u(){let e=i.useContext(d);if(!e)throw Error("useSupabase must be used within a SupabaseProvider");return e}let m={promise:new Promise((e,t)=>{r=e,n=t}),resolve:r,reject:n},h=e=>{m.resolve(e)};function f(e){let{children:t}=e,[a,r]=i.useState({user:null,supabase:null,isFetchingUser:!0});return i.useEffect(()=>{let e=!0;return(async()=>{let t=await (0,l.v)();if(!e)return;let a=(0,o.Cu)(c.OB,t);if(t){let n=await (0,o.k$)(t);if(!e)return;let s={isFetchingUser:!1,user:n,supabase:a};r(s),h(s)}else{let e={isFetchingUser:!1,user:null,supabase:a};r(e),h(e)}})(),()=>{e=!1}},[]),(0,s.jsx)(d.Provider,{value:a,children:t})}},71357:function(e,t,a){a.d(t,{j:function(){return r}});let r=e=>!!RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(e)},86830:function(e,t,a){a.d(t,{k$:function(){return c},Cu:function(){return l}});var r=a(77031);a(6056);var n=a(46546);let s="".concat(n.fv,"/api"),i={getUser:"".concat(s,"/getUser")};Error.stackTraceLimit=300;let l=(e,t)=>{if(!e)throw Error("cannot make anonymous client for blank env");if(!e.NEXT_PUBLIC_SUPABASE_ANON_KEY)throw Error("no anon key");let a={auth:{persistSession:!1}};return t&&(a.global={headers:{Authorization:"Bearer ".concat(t)}}),(0,r.eI)(e.NEXT_PUBLIC_SUPABASE_URL,e.NEXT_PUBLIC_SUPABASE_ANON_KEY,a)},c=async function(e){let{private:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{let a=new URL("".concat(i.getUser));t&&a.searchParams.set("private","true");let r=await fetch(a,{headers:{Authorization:"Bearer ".concat(e)}});if(r.ok)return(await r.json()).data;{let e=await r.text();return console.warn("error getting user for jwt:",e),null}}catch(e){return console.warn(e),null}}}}]);