1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[70673],{50834:function(e,t,n){n.d(t,{Ac:function(){return l},Tb:function(){return c}});var r=n(65724),o=n(22273),s=n(28266),i=n(76205);let a=e=>{let{type:t="new_message",avatarUrl:n,senderName:s,message:a,conversationId:l,onClick:c,onClose:u,className:d,timestamp:f}=e;return(0,r.jsxs)("div",{"data-sonner-toast":!0,role:"alert","aria-live":"polite",onClick:c,className:(0,i.cn)("relative flex w-[360px] max-w-[90vw] items-center gap-3 p-4","rounded-xl bg-[#ffffff] text-[#0d0d0d] shadow-lg","border border-gray-100","cursor-pointer transition-all duration-200","hover:scale-[1.02] hover:shadow-xl",c&&"active:scale-[0.98]",d),children:[(0,r.jsx)("button",{"aria-label":"Close notification",type:"button",onClick:e=>{e.stopPropagation(),null==u||u()},className:"absolute right-2 top-2 inline-flex h-6 w-6 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600",children:(0,r.jsx)(o.Z,{className:"h-4 w-4"})}),(0,r.jsxs)("div",{className:"relative flex-shrink-0",children:[n?(0,r.jsx)("div",{className:"h-10 w-10 overflow-hidden rounded-full ring-2 ring-gray-100",children:(0,r.jsx)("img",{src:n,alt:"".concat(s," avatar"),className:"h-full w-full object-cover"})}):(0,r.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-gradient-to-br from-sky-400 to-blue-600 text-sm font-semibold text-white ring-2 ring-gray-100",children:s.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}),("user_online"===t||"user_offline"===t)&&(0,r.jsx)("div",{className:(0,i.cn)("absolute -bottom-0.5 -right-0.5 h-3.5 w-3.5 rounded-full border-2 border-white","user_online"===t?"bg-green-500":"bg-gray-400")})]}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 pr-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"truncate text-[15px] font-semibold text-[#0d0d0d]",children:s}),f&&(0,r.jsx)("span",{className:"flex-shrink-0 text-xs text-gray-400",children:f})]}),(0,r.jsx)("p",{className:"mt-0.5 truncate text-sm text-gray-600",children:a})]}),(0,r.jsx)("div",{className:"flex-shrink-0 text-gray-400",children:(()=>{switch(t){case"new_message":return(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5",children:(0,r.jsx)("path",{stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10Z"})});case"message_reaction":return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2"}),(0,r.jsx)("path",{stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",d:"M8 14s1.5 2 4 2 4-2 4-2"}),(0,r.jsx)("circle",{cx:"9",cy:"10",r:"1",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"15",cy:"10",r:"1",fill:"currentColor"})]});case"mention":return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"4",stroke:"currentColor",strokeWidth:"2"}),(0,r.jsx)("path",{stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",d:"M16 8v5a3 3 0 0 0 6 0V12a10 10 0 1 0-4 8"})]});case"comment":return(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5",children:(0,r.jsx)("path",{stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round",d:"M21 12a8 8 0 0 1-8 8H5l-2 2V12a8 8 0 0 1 8-8h2a8 8 0 0 1 8 8Z"})});case"like":return(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5",children:(0,r.jsx)("path",{stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round",d:"M12 20s-7-4.35-7-9a4 4 0 0 1 7-2.65A4 4 0 0 1 19 11c0 4.65-7 9-7 9Z"})});case"follow":return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5",children:[(0,r.jsx)("circle",{cx:"9",cy:"8",r:"3.5",stroke:"currentColor",strokeWidth:"2"}),(0,r.jsx)("path",{stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",d:"M3 20a6 6 0 0 1 12 0M18 8v6M21 11h-6"})]});case"repost":return(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5",children:(0,r.jsx)("path",{stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",d:"M4 9V7a2 2 0 0 1 2-2h11l-3-3m3 11v2a2 2 0 0 1-2 2H4l3 3"})});case"user_online":return(0,r.jsx)("div",{className:"flex h-5 w-5 items-center justify-center",children:(0,r.jsx)("div",{className:"h-3 w-3 rounded-full bg-green-500"})});case"user_offline":return(0,r.jsx)("div",{className:"flex h-5 w-5 items-center justify-center",children:(0,r.jsx)("div",{className:"h-3 w-3 rounded-full bg-gray-400"})});case"error":return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5 text-red-500",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2"}),(0,r.jsx)("path",{stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",d:"M12 8v4M12 16h.01"})]});case"success":return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5 text-green-500",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2"}),(0,r.jsx)("path",{stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",d:"m9 12 2 2 4-4"})]});default:return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2"}),(0,r.jsx)("path",{stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",d:"M12 8v4M12 16h.01"})]})}})()})]})},l=e=>{let{type:t="new_message",avatarUrl:n,senderName:o,message:i,conversationId:l,onClick:c,duration:u=5e3,playSound:d=!1}=e;if(d)try{let e=new Audio("/sounds/notification.mp3");e.volume=.3,e.play().catch(()=>{})}catch(e){}return s.Am.custom(e=>(0,r.jsx)(a,{type:t,avatarUrl:n,senderName:o,message:i,conversationId:l,onClick:()=>{null==c||c(),s.Am.dismiss(e)},onClose:()=>s.Am.dismiss(e),timestamp:"now"}),{duration:u,position:"bottom-right"})}
1,c={newMessage:(e,t,n)=>l({type:"new_message",senderName:e,message:t,...n}),reaction:(e,t,n)=>l({type:"message_reaction",senderName:e,message:"Reacted with ".concat(t),...n}),mention:(e,t,n)=>l({type:"mention",senderName:e,message:t,...n}),userOnline:(e,t)=>l({type:"user_online",senderName:e,message:"is now online",...t}),userOffline:(e,t)=>l({type:"user_offline",senderName:e,message:"went offline",...t}),error:(e,t)=>l({type:"error",senderName:"Error",message:e,...t}),success:(e,t)=>l({type:"success",senderName:"Success",message:e,...t}),info:(e,t)=>l({type:"info",senderName:"Info",message:e,...t})}},70673:function(e,t,n){n.d(t,{NotificationProvider:function(){return p},P:function(){return w}});var r=n(65724),o=n(54704),s=n(2512),i=n(50834),a=n(26016),l=n(64937);let c=new Map(Object.entries({message:{type:"new_message",who:"New message",what:"You have a new message"},community_chat:{type:"new_message",who:"New message",what:"You have a new message"},message_reaction:{type:"message_reaction",who:"New reaction",what:"Someone reacted to your message"},mention:{type:"mention",who:"New mention",what:"You were mentioned"},comment:{type:"comment",who:"New comment",what:"Someone commented on your post"},reply:{type:"comment",who:"New reply",what:"Someone replied to you"},like:{type:"like",who:"New like",what:"Someone liked your post"},comment_like:{type:"like",who:"New like",what:"Someone liked your comment"},follow:{type:"follow",who:"New follower",what:"Someone started following you"},repost:{type:"repost",who:"New repost",what:"Someone reposted your post"}})),u=e=>{if("string"!=typeof e)return;let t=e.trim();return t.length>0?t:void 0};var d=n(79449);let f=(0,s.createContext)(null),m="chat:notification-prefs";function h(){return"undefined"==typeof Notification?"unsupported":Notification.permission}function p(e){let{userId:t,children:n}=e,p=(0,o.useRouter)(),[w,v]=(0,s.useState)(0),[x,g]=(0,s.useState)(()=>(function(){try{let e=window.localStorage.getItem(m);if(e){let t=JSON.parse(e);return{soundEnabled:!1!==t.soundEnabled,desktopEnabled:!1!==t.desktopEnabled}}}catch(e){}return{soundEnabled:!0,desktopEnabled:!0}})()),[y,k]=(0,s.useState)(()=>h()),N=(0,s.useRef)(x);(0,s.useEffect)(()=>{N.current=x},[x]);let b=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!t){b.current=null;return}let e=!1;return(async()=>{try{let t=await fetch("/api/v2/notifications/preferences");if(!t.ok)return;let n=await t.json();!e&&(null==n?void 0:n.success)&&(b.current=n.data)}catch(e){}})(),()=>{e=!0}},[t]);let j=(0,s.useRef)(new Map),_=(0,s.useCallback)(e=>{let t=Date.now(),n=j.current,r=n.get(e);if(r&&t-r<5e3)return!0;if(n.set(e,t),n.size>200){let e=t-1e4;for(let[t,r]of Array.from(n.entries()))r<e&&n.delete(t)}return!1},[]),C=(0,s.useCallback)(e=>{g(t=>{let n={...t,...e};try{window.localStorage.setItem(m,JSON.stringify(n))}catch(e){}return n})},[]),S=(0,s.useCallback)(async()=>{if("undefined"==typeof Notification)return"unsupported";try{let e=await Notification.requestPermission();return k(e),e}catch(e){return Notification.permission}},[]),E=(0,s.useCallback)(e=>{v(t=>Math.max(0,t+e))},[]),M=(0,s.useCallback)(()=>v(0),[]);(0,s.useEffect)(()=>{if(!t)return;let e=!1;return fetch("/api/v2/notifications/unread-count").then(e=>e.ok?e.json():null).then(t=>{var n,r,o,s;if(e||!(null==t?void 0:t.success))return;let i=Number(null!==(s=null!==(o=null===(n=t.data)||void 0===n?void 0:n.total)&&void 0!==o?o:null===(r=t.data)||void 0===r?void 0:r.notifications)&&void 0!==s?s:0);Number.isFinite(i)&&v(i)}).catch(()=>{}),()=>{e=!0}},[t]),(0,s.useEffect)(()=>{if(!t)return;let e=(0,d.getSupabaseBrowserClient)(),n=e.channel("notifications:".concat(t)).on("postgres_changes",{event:"INSERT",schema:"public",table:"notifications",filter:"user_id=eq.".concat(t)},e=>{var t,n,r;let o=null==e?void 0:e.new;if(!o||!o.id||_(o.id))return;o.is_read||v(e=>e+1);let s=function(e){var t,n,r;let o=c.get(e.notification_type||"");if(!o)return null;let s=e.metadata||{};return{type:o.type,senderName:null!==(n=null!==(t=u(s.actor_name))&&void 0!==t?t:u(e.title))&&void 0!==n?n:o.who,message:null!==(r=u(e.message))&&void 0!==r?r:o.what}}(o);if(!s)return;let{senderName:d,message:f,type:m}=s,h=(null===(t=o.metadata)||void 0===t?void 0:t.conversation_id)||void 0,w=()=>{p.push((0,a.T)(o)||"/notifications")};if((0,l.hX)(b.current))return;let x=N.current,g="undefined"!=typeof document&&"hidden"===document.visibilityState;if(g||(0,i.Ac)({type:m,senderName:d,message:f,avatarUrl:(null===(n=o.metadata)||void 0===n?void 0:n.actor_avatar)||void 0,conversationId:h,onClick:w,playSound:x.soundEnabled}),g&&x.desktopEnabled&&"undefined"!=typeof Notification&&"granted"===Notification.permission)try{let e=new Notification(d,{body:f,icon:(null===(r=o.metadata)||void 0===r?void 0:r.actor_avatar)||"/favicon.ico",tag:"chat:".concat(o.id)});e.onclick=()=>{try{window.focus()}catch(e){}w(),e.close()}}catch(e){}}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"notifications",filter:"user_id=eq.".concat(t)},e=>{let t=null==e?void 0:e.old,n=null==e?void 0:e.new;n&&t&&!1===t.is_read&&!0===n.is_read&&v(e=>Math.max(0,e-1))}).subscribe();return()=>{try{e.removeChannel(n)}catch(e){}}},[t,_,p]),(0,s.useEffect)(()=>
1{if("undefined"==typeof Notification)return;let e=window.setInterval(()=>{let e=Notification.permission;k(t=>t===e?t:e)},15e3);return()=>window.clearInterval(e)},[]);let W=(0,s.useMemo)(()=>({unreadCount:w,bumpUnread:E,resetUnread:M,preferences:x,setPreferences:C,permission:y,requestPermission:S}),[w,E,M,x,C,y,S]);return(0,r.jsx)(f.Provider,{value:W,children:n})}function w(){return(0,s.useContext)(f)||{unreadCount:0,bumpUnread:()=>void 0,resetUnread:()=>void 0,preferences:{soundEnabled:!0,desktopEnabled:!0},setPreferences:()=>void 0,permission:h(),requestPermission:async()=>h()}}},26016:function(e,t,n){n.d(t,{T:function(){return o}});let r=e=>"string"==typeof e&&e.length>0?e:void 0;function o(e){let t=e.metadata||{},n=r(t.conversation_id);if(n)return"/community/chat?id=".concat(encodeURIComponent(n));let o=r(e.community_id)||r(t.community_id),s=r(t.room_id);if(o&&s)return"/chats?tab=community&community=".concat(encodeURIComponent(o),"&room=").concat(encodeURIComponent(s));let i=r(t.post_id)||("post"===e.entity_type?r(e.entity_id):void 0);if(i)return"/post/".concat(encodeURIComponent(i));if("user"===e.entity_type){let e=r(t.actor_user_name);if(e)return"/profile/".concat(encodeURIComponent(e.replace(/^@/,"")))}return null}},64937:function(e,t,n){function r(e){if("string"!=typeof e)return null;let t=e.trim().match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return n>23||r>59?null:60*n+r}function o(e){let t=(Math.trunc(e)%1440+1440)%1440;return"".concat(String(Math.floor(t/60)).padStart(2,"0"),":").concat(String(t%60).padStart(2,"0"))}function s(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date;if(!(null==e?void 0:e.quiet_hours_enabled))return!1;
1let o=r(e.quiet_hours_start),s=r(e.quiet_hours_end);return null!==o&&null!==s&&(t=60*n.getHours()+n.getMinutes(),o===s||(o<s?t>=o&&t<s:t>=o||t<s))}n.d(t,{hS:function(){return o},hX:function(){return s},wK:function(){return r}})},79449:function(e,t,n){n.d(t,{N:function(){return a},getSupabaseBrowserClient:function(){return i},supabase:function(){return l}});var r=n(96616);let o="__SUPABASE_BROWSER_CLIENT__",s=null,i=()=>{if(!s){let e=globalThis[o];e?s=e:(s=(0,r.createClientComponentClient)(),globalThis[o]=s)}return s},a=i,l=i()}}]);
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.