PageSourceSearch

https://www.efuturanetworks.com/_next/static/chunks/8015.0b3769e193e06a1d.js

js efuturanetworks.com collected 2026-10-05 03:19:51 UTC 45,829 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8015],{15197:(e,a,t)=>{"use strict";t.d(a,{h:()=>h});var s=t(54568),i=t(7620),r=t(12598),n=t(60844),l=t(54925),c=t(18335),o=t(45234),d=t(97509),u=t(99100),m=t(89481);t(92400);let p=async()=>{let e={lat:null,lng:null};try{if(!navigator.permissions||!navigator.geolocation)return e;let a=await navigator.permissions.query({name:"geolocation"});if("granted"!==a.state)return e;return await new Promise(a=>navigator.geolocation.getCurrentPosition(e=>a({lat:e.coords.latitude,lng:e.coords.longitude}),()=>a(e),{maximumAge:6e4,timeout:3e3}))}catch(a){return e}},h=e=>{var a;let{latestItem:t,onCapture:h,onOpenGallery:v,onClose:x}=e,g=(0,i.useRef)(null),b=(0,i.useRef)(null),f=(0,i.useRef)(null),y=(0,i.useRef)(null),j=(0,i.useRef)(null),[_,w]=(0,i.useState)("photo"),[S,k]=(0,i.useState)("environment"),[N,C]=(0,i.useState)(!1),[A,z]=(0,i.useState)(null),[I,E]=(0,i.useState)(!1),[T,M]=(0,i.useState)(0),[q,R]=(0,i.useState)(!1),[P,D]=(0,i.useState)(0),[L,F]=(0,i.useState)(null),[O,U]=(0,i.useState)(null),W=e=>{F(e),setTimeout(()=>F(null),2500)},B=()=>{var e;null==(e=b.current)||e.getTracks().forEach(e=>e.stop()),b.current=null};(0,i.useEffect)(()=>{let e=!1;return C(!1),z(null),(async()=>{try{var a;if(!(null==(a=navigator.mediaDevices)?void 0:a.getUserMedia))throw Error("unsupported");let t=await navigator.mediaDevices.getUserMedia({video:{facingMode:S,width:{ideal:1920},height:{ideal:1080}},audio:!1});if(e)return void t.getTracks().forEach(e=>e.stop());B(),b.current=t,g.current&&(g.current.srcObject=t,await g.current.play().catch(()=>{})),C(!0)}catch(a){if(e)return;z((null==a?void 0:a.name)==="NotAllowedError"?"Camera access is blocked. Allow the camera for this site in your browser settings, or use your phone's camera below.":"This device's camera isn't available here. You can still use your phone's camera below.")}})(),()=>{e=!0}},[S]),(0,i.useEffect)(()=>()=>{var e,a;try{(null==(a=y.current)?void 0:a.state)==="recording"&&y.current.stop()}catch(e){}B(),null==(e=f.current)||e.getTracks().forEach(e=>e.stop())},[]),(0,i.useEffect)(()=>{if(!I)return;M(0);let e=setInterval(()=>M(e=>e+1),1e3);return()=>clearInterval(e)},[I]);let G=(0,i.useCallback)(async(e,a)=>{let t=URL.createObjectURL(e);U(e=>(e&&URL.revokeObjectURL(e.url),{url:t,video:a})),D(e=>e+1);let s=await p(),i=await h(e,s);D(e=>e-1),i||W(a?"Couldn't save that video.":"Couldn't save that photo.")},[h]),K=async()=>{var e,a;let t=g.current;if(!t||!N||!t.videoWidth)return;let s=document.createElement("canvas");s.width=t.videoWidth,s.height=t.videoHeight;let i=s.getContext("2d");if(!i)return;"user"===S&&(i.translate(s.width,0),i.scale(-1,1)),i.drawImage(t,0,0),R(!0),setTimeout(()=>R(!1),120),null==(e=(a=navigator).vibrate)||e.call(a,20);let r=await new Promise(e=>
1s.toBlob(e,"image/jpeg",.92));r&&G(new File([r],"photo_".concat(Date.now(),".jpg"),{type:"image/jpeg"}),!1)},V=async()=>{var e,a;let t=b.current,s="undefined"==typeof MediaRecorder?"":["video/mp4;codecs=avc1","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"].find(e=>MediaRecorder.isTypeSupported(e))||"";if(!t||!N||!s){s||W("Video recording isn't supported in this browser.");return}let i=[];try{f.current||(f.current=await navigator.mediaDevices.getUserMedia({audio:!0})),i=f.current.getAudioTracks()}catch(e){W("Recording without sound (microphone not allowed).")}let r=new MediaStream([...t.getVideoTracks(),...i]),n=[],l=0,c=new MediaRecorder(r,{mimeType:s,videoBitsPerSecond:4e6});c.ondataavailable=e=>{e.data.size&&(n.push(e.data),(l+=e.data.size)>0x2d00000&&"recording"===c.state&&(W("Maximum video length reached."),c.stop()))},c.onstop=()=>{E(!1);let e=s.split(";")[0],a=new Blob(n,{type:e});a.size&&G(new File([a],"video_".concat(Date.now(),".").concat("video/mp4"===e?"mp4":"webm"),{type:e}),!0)},y.current=c,c.start(1e3),E(!0),null==(e=(a=navigator).vibrate)||e.call(a,30)},Y=O||(t?{url:t.cropped_url||t.original_url,video:!!(null==(a=t.content_type)?void 0:a.startsWith("video/"))}:null);return(0,d.createPortal)((0,s.jsxs)("div",{className:"camera-view",children:[(0,s.jsxs)("div",{className:"camera-top",children:[(0,s.jsx)("button",{className:"camera-icon-btn",onClick:x,"aria-label":"Close camera",disabled:I,children:(0,s.jsx)(r.A,{size:24})}),I&&(0,s.jsxs)("div",{className:"camera-rec-timer",children:[(0,s.jsx)("span",{className:"camera-rec-dot"}),(e=>"".concat(Math.floor(e/60),":").concat(String(e%60).padStart(2,"0")))(T)]}),(0,s.jsx)("span",{style:{width:44}})]}),(0,s.jsxs)("div",{className:"camera-stage",children:[(0,s.jsx)("video",{ref:g,className:"camera-preview ".concat("user"===S?"mirrored":""),playsInline:!0,muted:!0,autoPlay:!0}),!N&&!A&&(0,s.jsx)(n.A,{size:36,className:"spinner camera-center"}),A&&(0,s.jsxs)("div",{className:"camera-error",children:[(0,s.jsx)(l.A,{size:40}),(0,s.jsx)("p",{children:A}),(0,s.jsx)("button",{className:"camera-fallback-btn",onClick:()=>{var e;return null==(e=j.current)?void 0:e.click()},children:"Open phone camera"})]}),(0,s.jsx)(u.N,{children:q&&(0,s.jsx)(m.P.div,{className:"camera-flash",initial:{opacity:.9},animate:{opacity:0},exit:{opacity:0}})}),L&&(0,s.jsx)("div",{className:"camera-notice",children:L})]}),(0,s.jsxs)("div",{className:"camera-bottom",children:[(0,s.jsx)("div",{className:"camera-modes",children:["video","photo"].map(e=>(0,s.jsx)("button",{className:"camera-mode ".concat(_===e?"active":""),disabled:I,onClick:()=>w(e),children:"photo"===e?"PHOTO":"VIDEO"},e))}),(0,s.jsxs)("div",{className:"camera-controls",children:[(0,s.jsxs)("button",{className:"camera-thumb",onClick:v,disabled:I,"aria-label":"Open gallery",children:[Y?Y.video?(0,s.jsx)("video",{src:"".concat(Y.url,"#t=0.1"),muted:!0,playsInline:!0,preload:"metadata"}):(0,s.jsx)("img",{src:Y.url,alt:"Latest in gallery"}):(0,s.jsx)(c.A,{size:22}),P>0&&(0,s.jsx)("span",{className:"camera-thumb-saving",children:(0,s.jsx)(n.A,{size:18,className:"spinner"})})]}),(0,s.jsx)("button",{className:"camera-shutter ".concat(_," ").concat(I?"recording":""),onClick:()=>{"photo"===_?K():I?(()=>{var e;(null==(e=y.current)?void 0:e.state)==="recording"&&y.current.stop()})():V()},disabled:!N,"aria-label":"photo"===_?"Take photo":I?"Stop recording":"Start recording",children:(0,s.jsx)("span",{})}),(0,s.jsx)("button",{className:"camera-icon-btn camera-flip",onClick:()=>k(e=>"environment"===e?"user":"environment"),disabled:I,"aria-label":"Switch camera",children:(0,s.jsx)(o.A,{size:24})})]})]}),(0,s.jsx)("input",{ref:j,type:"file",hidden:!0,accept:"video"===_?"video/*":"image/*",capture:"environment",onChange:e=>{var a;let t=null==(a=e.target.files)?void 0:a[0];t&&G(t,t.type.startsWith("video/")),e.target.value=""}})]}),document.body)}},20637:(e,a,t)=>{"use strict";t.d(a,{p:()=>n});var s=t(54568),i=t(89481),r=t(889);t(67040);let n=e=>{let{icon:a,title:t,message:n,action:l}=e;return(0,s.jsxs)(i.P.div,{className:"empty-state-container",initial:{opacity:0,scale:.9}
1,animate:{opacity:1,scale:1},transition:{duration:.5},children:[(0,s.jsxs)("div",{className:"empty-state-visual",children:[(0,s.jsx)("div",{className:"blob-gradient"}),(0,s.jsx)(a,{size:48,className:"main-icon"}),(0,s.jsx)(i.P.div,{className:"sparkle-one",animate:{rotate:360},transition:{duration:10,repeat:1/0,ease:"linear"},children:(0,s.jsx)(r.A,{size:20})})]}),(0,s.jsx)("h3",{children:t}),(0,s.jsx)("p",{children:n}),l&&(0,s.jsx)("button",{className:"premium-btn",onClick:l.onClick,children:l.label})]})}},28015:(e,a,t)=>{"use strict";t.r(a),t.d(a,{MessagesView:()=>J});var s=t(54568),i=t(7620),r=t(97509),n=t(90008),l=t(4869),c=t(22995),o=t(63104),d=t(20637),u=t(6158),m=t(60844),p=t(20415),h=t(64751),v=t(56178),x=t(46395),g=t(6438),b=t(12598),f=t(29304),y=t(18335);let j=(0,t(12119).A)("images",[["path",{d:"m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16",key:"9kzy35"}],["path",{d:"M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2",key:"1t0f0t"}],["circle",{cx:"13",cy:"7",r:"1",fill:"currentColor",key:"1obus6"}],["rect",{x:"8",y:"2",width:"14",height:"14",rx:"2",key:"1gvhby"}]]);var _=t(54925),w=t(45130),S=t(70577),k=t(14502),N=t(84990),C=t(51166),A=t(19146),z=t(73102),I=t(26862),E=t(95355),T=t(98266),M=t(70419),q=t(11456),R=t(65202),P=t(12494);let D=["❤️","\uD83D\uDC4D","\uD83D\uDE2E","\uD83D\uDE22","\uD83D\uDE02"],L=e=>{let{messageId:a,user:t}=e,[r,l]=(0,i.useState)({}),[c,o]=(0,i.useState)(null),[d,u]=(0,i.useState)(!1),m=async()=>{let{data:e}=await n.supabase.rpc("get_channel_message_reaction_counts",{p_message_id:a}),t={};(e||[]).forEach(e=>{t[e.emoji]=Number(e.count)}),l(t)},p=async()=>{if(!t)return;let{data:e}=await n.supabase.from("channel_message_reactions").select("emoji").eq("message_id",a).eq("user_id",t.id).maybeSingle();o((null==e?void 0:e.emoji)||null)};(0,i.useEffect)(()=>{m(),p()},[a]);let h=async e=>{if(!t)return;u(!1);let s=c===e?null:e;l(e=>{let a={...e};return c&&(a[c]=Math.max(0,(a[c]||0)-1)),s&&(a[s]=(a[s]||0)+1),a}),o(s);try{null===s?await n.supabase.from("channel_message_reactions").delete().match({message_id:a,user_id:t.id}):await n.supabase.from("channel_message_reactions").upsert({message_id:a,user_id:t.id,emoji:s})}catch(e){console.error("Failed to react to channel message",e),m(),p()}},v=Object.entries(r).filter(e=>{let[,a]=e;return a>0});return(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap",marginTop:"10px",position:"relative"},children:[v.map(e=>{let[a,t]=e;return(0,s.jsxs)("button",{onClick:()=>h(a),style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 10px",borderRadius:"999px",border:c===a?"1px solid var(--primary)":"1px solid var(--border)",background:c===a?"var(--glass-bg-strong)":"var(--bg-soft)",color:"var(--text)",fontSize:"0.8rem",cursor:"pointer"},children:[(0,s.jsx)("span",{children:a}),(0,s.jsx)("span",{children:t})]},a)}),(0,s.jsx)("button",{onClick:()=>u(e=>!e),style:{width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--border)",background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:"0.9rem",display:"flex",alignItems:"center",justifyContent:"center"},children:"+"}),d&&(0,s.jsx)("div",{style:{position:"absolute",bottom:"36px",left:0,zIndex:20,display:"flex",gap:"4px",padding:"6px 8px",background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:"999px",boxShadow:"0 8px 20px rgba(0,0,0,0.25)"},children:D.map(e=>(0,s.jsx)("button",{onClick:()=>h(e),style:{background:"none",border:"none",cursor:"pointer",fontSize:"1.2rem",padding:"2px"},children:e},e))})]})};var F=t(83017);let O={admin:"Admin announcements reach every resident on the platform.",civic:"Official announcements from verified city and county staff, scoped to your area.",subscription:"Updates from the people and pages you follow."},U={critical:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},W=e=>{let{channelType:a,user:t}=e,[r,l]=(0,i.useState)([]),[c,u]=(0,i.useState)(!0),[p,h]=(0,i.useState)(""),[v,x]=(0,i.useState)("info"),[g,b]=(0,i.useState)(!1),y="admin"===a?(0,F.qc)(t.role):"civic"===a&&(0,F.nL)(t.role),j=async()=>{u(!0);let{data:e,error:t}=await n.supabase.from("channel_messages").select("id, sender_id, content, media_url, severity, created_at, sender:sender_id(name, avatar_url)").eq("channel_type",a).order("created_at",{ascending:!1}).limit(50);t||l(e||[]),u(!1)};(0,i.useEffect)(()=>{j()},[a]);let _=async()=>
1{if(p.trim()&&!g){b(!0);try{let e={channel_type:a,sender_id:t.id,content:p.trim()};"civic"===a&&(e.county=t.county||null,e.community=t.community||null,e.severity=v);let{data:s,error:i}=await n.supabase.from("channel_messages").insert(e).select("id").single();if(i)throw i;h(""),await j(),"admin"===a&&(null==s?void 0:s.id)&&(fetch("/api/channels/admin-broadcast-email",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channelMessageId:s.id})}).catch(e=>console.error("Admin broadcast email dispatch failed",e)),n.supabase.auth.getSession().then(e=>{let{data:{session:a}}=e;a&&fetch("/api/push/notify-channel",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a.access_token)},body:JSON.stringify({channelType:"admin",title:"Admin Announcement",body:p.trim().slice(0,120),url:"/?env=social&tab=4"})}).catch(e=>console.error("Admin broadcast push dispatch failed",e))}))}catch(e){console.error("Failed to send channel message",e)}finally{b(!1)}}};return(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,s.jsx)("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border)",color:"var(--text-muted)",fontSize:"0.85rem"},children:O[a]}),y&&(0,s.jsxs)("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border)",display:"flex",flexDirection:"column",gap:"10px"},children:["civic"===a&&(0,s.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"center",fontSize:"0.8rem",color:"var(--text-muted)"},children:[(0,s.jsxs)("span",{children:["Scope: ",t.county||t.community||"your area"]}),(0,s.jsxs)("select",{value:v,onChange:e=>x(e.target.value),style:{marginLeft:"auto",padding:"4px 8px",borderRadius:"8px",border:"1px solid var(--border)",background:"var(--bg-soft)",color:"var(--text)",fontSize:"0.8rem"},children:[(0,s.jsx)("option",{value:"info",children:"Info"}),(0,s.jsx)("option",{value:"warning",children:"Warning"}),(0,s.jsx)("option",{value:"critical",children:"Critical"})]})]}),(0,s.jsxs)("div",{style:{display:"flex",gap:"10px",alignItems:"flex-start"},children:["civic"===a?(0,s.jsx)(q.A,{size:20,color:U[v],style:{marginTop:"8px",flexShrink:0}}):(0,s.jsx)(M.A,{size:20,color:"var(--primary)",style:{marginTop:"8px",flexShrink:0}}),(0,s.jsx)("textarea",{value:p,onChange:e=>h(e.target.value),placeholder:"civic"===a?"Write an official announcement for your area...":"Write an announcement for everyone...",rows:2,style:{flex:1,resize:"vertical",padding:"10px 12px",borderRadius:"12px",border:"1px solid var(--border)",background:"var(--bg-soft)",color:"var(--text)",fontFamily:"inherit",fontSize:"0.9rem",outline:"none"}}),(0,s.jsx)("button",{onClick:_,disabled:!p.trim()||g,style:{width:"40px",height:"40px",borderRadius:"50%",border:"none",background:"var(--primary)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",cursor:p.trim()?"pointer":"not-allowed",opacity:p.trim()?1:.5,flexShrink:0},children:g?(0,s.jsx)(m.A,{size:18,className:"animate-spin"}):(0,s.jsx)(f.A,{size:18})})]})]}),(0,s.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px",display:"flex",flexDirection:"column",gap:"16px"},children:c?(0,s.jsx)("div",{style:{display:"flex",justifyContent:"center",padding:"40px"},children:(0,s.jsx)(m.A,{className:"animate-spin",color:"var(--primary)"})}):0===r.length?(0,s.jsx)(d.p,{icon:"civic"===a?q.A:"subscription"===a?T.A:M.A,title:"No Messages",message:"subscription"===a?"Follow people and pages to see their updates here.":"Nothing here yet."}):r.map(e=>{var i,r,n;return(0,s.jsxs)("div",{style:{background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:"16px",padding:"16px",position:"relative",overflow:"hidden"},children:["civic"===a&&e.severity&&(0,s.jsx)("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:"4px",background:U[e.severity]}}),(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",marginBottom:"8px"},children:[(0,s.jsx)(o.e,{name:null==(i=e.sender)?void 0:i.name,url:(null==(r=e.sender)?void 0:r.avatar_url)||void 0,size:32}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{style:{fontWeight:700,fontSize:"0.9rem",color:"var(--text)"},children:(null==(n=e.sender)?void 0:n.name)||"Unknown"}),(0,s.jsx)("div",{style:{fontSize:"0.75rem",color:"var(--text-muted)"}
1,children:new Date(e.created_at).toLocaleString()})]}),"civic"===a&&e.severity&&(0,s.jsx)("span",{style:{marginLeft:"auto",padding:"3px 8px",borderRadius:"999px",fontSize:"0.7rem",fontWeight:800,textTransform:"uppercase",color:U[e.severity],background:"".concat(U[e.severity],"20")},children:e.severity})]}),e.content&&(0,s.jsx)("p",{style:{margin:0,color:"var(--text)",lineHeight:1.6,fontSize:"0.95rem"},children:e.content}),e.media_url&&(0,s.jsx)("img",{src:e.media_url,alt:"",style:{width:"100%",borderRadius:"12px",marginTop:"10px",objectFit:"cover"}}),(0,s.jsx)(L,{messageId:e.id,user:t})]},e.id)})})]})};var B=t(3485),G=t(96897),K=t(96666),V=t(22260),Y=t(15197),X=t(65773),Q=t(16325);t(69853);let H=e=>{if(!e)return"";let a=new Date(e),t=new Date;return a.toDateString()===t.toDateString()?a.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):(t.getTime()-a.getTime())/864e5<7?a.toLocaleDateString([],{weekday:"short"}):a.getFullYear()===t.getFullYear()?a.toLocaleDateString([],{month:"short",day:"numeric"}):a.toLocaleDateString([],{month:"numeric",day:"numeric",year:"2-digit"})},J=e=>{let{user:a,initialChatId:t,pageId:D}=e,[L,F]=(0,i.useState)("recent"),O="admin"===L||"civic_alerts"===L||"subscriptions"===L,[U,J]=(0,i.useState)(t||null),Z=(0,i.useRef)(U);(0,i.useEffect)(()=>{Z.current=U},[U]);let $=(0,i.useRef)(!1),[ee,ea]=(0,i.useState)(""),[et,es]=(0,i.useState)([]),[ei,er]=(0,i.useState)(()=>D||new URLSearchParams(window.location.search).get("pageInbox")),en=(0,i.useRef)(ei);(0,i.useEffect)(()=>{en.current=ei},[ei]);let el=ei||a.id,ec=["messages",a.id,ei||"me"],eo=(0,i.useRef)(ec);eo.current=ec;let ed=(0,l.jE)(),{data:eu=[]}=(0,c.I)({queryKey:["my_page_inboxes",a.id],staleTime:3e4,queryFn:async()=>{let{data:e}=await n.supabase.schema("consumer").rpc("my_page_inboxes");return e||[]}}),{data:em=[],isLoading:ep}=(0,c.I)({queryKey:ec,queryFn:async()=>{let e=n.supabase.schema("consumer").from("messages").select("*");e=ei?e.eq("page_id",ei):e.or("sender_id.eq.".concat(a.id,",receiver_id.eq.").concat(a.id));let{data:t,error:s}=await e.order("created_at",{ascending:!1}).limit(2e3);if(s)throw s;return(t||[]).reverse().map(e=>{let a=e.content||"",t=e.media_url,s=a.match(/\[MEDIA:(.+?)\]/);return s&&(t=s[1],a=a.replace(s[0],"").trim()),{...e,content:a,media_url:t}})},staleTime:3e5}),eh=(0,i.useMemo)(()=>em.filter(e=>null!==(0,Q.pC)(e,a.id,ei)),[em,a.id,ei]),[ev,ex]=(0,i.useState)({});(0,i.useEffect)(()=>{let e=Array.from(new Set(eh.map(e=>e.media_url).filter(e=>!!e&&!ev[e])));if(0===e.length)return;let a=!1;return(0,Q.Qs)(e).then(e=>{!a&&Object.keys(e).length&&ex(a=>({...a,...e}))}),()=>{a=!0}},[eh]);let[eg,eb]=(0,i.useState)(""),[ef,ey]=(0,i.useState)([]),[ej,e_]=(0,i.useState)(!1),[ew,eS]=(0,i.useState)(!1),[ek,eN]=(0,i.useState)(!1),[eC,eA]=(0,i.useState)(!1),[ez,eI]=(0,i.useState)(!1),[eE,eT]=(0,i.useState)(0),[eM,eq]=(0,i.useState)(!1),[eR,eP]=(0,i.useState)(!1),[eD,eL]=(0,i.useState)(!1),[eF,eO]=(0,i.useState)(null),eU=(0,i.useRef)(null),eW=(0,i.useRef)(null),eB=(0,i.useRef)([]),{onlineUsers:eG}=(0,u.n)(),[eK,eV]=(0,i.useState)(()=>window.matchMedia("(max-width: 768px)").matches);(0,i.useEffect)(()=>{let e=window.matchMedia("(max-width: 768px)"),a=()=>eV(e.matches);return e.addEventListener("change",a),()=>e.removeEventListener("change",a)},[]);let eY=(0,B.G)(),eX=(0,i.useRef)(null),eQ=(0,i.useRef)(null),eH=(0,i.useRef)(null),eJ=(0,i.useRef)(!1);(0,i.useEffect)(()=>{(()=>{var e;null==(e=eX.current)||e.scrollIntoView({behavior:"smooth"})})()},[eh,U,ek]),(0,i.useEffect)(()=>{if(!U||!a||!1===a.enable_typing_indicators||ei||$.current)return;let e=[a.id,U].sort().join("-"),t=n.supabase.channel("broadcast-typing-".concat(e)).on("broadcast",{event:"typing"},e=>{var a,t;(null==(a=e.payload)?void 0:a.userId)===U&&eN((null==(t=e.payload)?void 0:t.isTyping)||!1)}).subscribe(async e=>{"SUBSCRIBED"===e&&eJ.current&&await t.send({type:"broadcast",event:"typing",payload:{userId:a.id,isTyping:!0}})});return eH.current=t,()=>{n.supabase.removeChannel(t),eH.current=null,eN(!1)}},[U,a,ei]),(0,i.useEffect)(()=>{eJ.current=ew,eH.current&&(null==a?void 0:a.enable_typing_indicators)!==!1&&eH.current.send({type:"broadcast",event:"typing",payload:{userId:a.id,isTyping:ew}})},[ew,a]);let eZ=e=>{let t=en.current,s=t||a.id;ed.setQueryData(eo.current,i=>(i||[]).map(i=>(0,Q.pC)(i,a.id,t)!==e||i.receiver_id!==s||i.read_at||i.is_read?i:{...i,is_read:!0})),t?(0,Q.rU)({pageId:t,userId:a.id,customerId:e,asPage:!0}):$.current?(0,Q.rU)({pageId:e,userId:a.id,asPage:!1}):(0,Q.vs)(a.id,e),t&&ed.invalidateQueries({queryKey:["my_page_inboxes",a.id]})},e$=e=>{ed.setQueryData(eo.current,a=>{let t=a||[],s=t.findIndex(a=>a.id===e.id);if(s>-1){let a=[...t];return a[s]={...a[s],...e},a}return[...t,e]})};(0,i.useEffect)(()=>{let e=e=>{e$(e);let t=en.current,s=(0,Q.pC)(e,a.id,t);s&&s===Z.current&&e.receiver_id===(t||a.id)&&eZ(s),e.page_id&&ed.invalidateQueries({queryKey:["my_page_inboxes",a.id]})},t=n.supabase.channel("messages-rx-".concat(a.id)).on("postgres_changes",{event:"INSERT",schema:"consumer",table:"messages",filter:"receiver_id=eq.".concat(a.id)},a=>e(a.new)).subscribe(),s=n.supabase.channel("messages-tx-".concat(a.id)).on("postgres_changes",{event:"INSERT",schema:"consumer",table:"messages",filter:"sender_id=eq.".concat(a.id)},a=>e(a.new)).on("postgres_changes",{event:"UPDATE",schema:"consumer",table:"messages",filter:"sender_id=eq.".concat(a.id)},a=>e(a.new)).subscribe(),i=eu.map(t=>n.supabase.channel("messages-page-".concat(t.id,"-").concat(a.id)).on("postgres_changes",{event:"INSERT",schema:"consumer",table:"messages",filter:"receiver_id=eq.".concat(t.id)},a=>e(a.new)).subscribe());return()=>{n.supabase.removeChannel(t),n.supabase.removeChannel(s),i.forEac
1h(e=>n.supabase.removeChannel(e))}},[a.id,eu.map(e=>e.id).join(",")]),(0,i.useEffect)(()=>{U&&eZ(U)},[U]);let e0=i.useRef(null);(0,i.useEffect)(()=>()=>{e0.current&&clearTimeout(e0.current)},[]);let e1=async(e,t)=>{let s=Z.current;if(!s)return!1;let i=en.current||($.current?s:null),{data:r,error:n}=await (0,Q.pW)({sender:{id:a.id,name:a.name},receiverId:s,text:e,mediaPath:null==t?void 0:t.path,mediaType:null==t?void 0:t.type,pageId:i});return n?(alert(n),!1):(r&&e$(r),!0)},e2=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!Z.current)return!1;eA(!0);try{let{path:s,mediaType:i}=await (0,Q.sc)(a.id,e,t);return await e1(null,{path:s,type:i})}catch(e){var s;return console.error("Upload error:",e),alert((null==e||null==(s=e.message)?void 0:s.includes("50 MB"))?e.message:"That file couldn't be sent."),!1}finally{eA(!1)}},e4=async e=>{let a=Array.from(e.target.files||[]);for(let t of(e.target.value="",a))await e2(t)},e6=async e=>{eP(!1);try{let a=await (0,X.FO)(e);await e2(a,"gallery")}catch(e){console.error("Gallery pick failed:",e),alert("Couldn't attach that from your gallery.")}},e8=async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),a="undefined"==typeof MediaRecorder?"":["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/aac"].find(e=>MediaRecorder.isTypeSupported(e))||"",t=a?new MediaRecorder(e,{mimeType:a}):new MediaRecorder(e);eW.current=t,eB.current=[],t.ondataavailable=e=>{e.data.size>0&&eB.current.push(e.data)},t.onstop=async()=>{e.getTracks().forEach(e=>e.stop());let s=(t.mimeType||a||"audio/webm").split(";")[0],i=new Blob(eB.current,{type:s});if(i.size>0&&Z.current){let e=s.includes("mp4")||s.includes("aac")?"m4a":"webm";await e2(new File([i],"voice_".concat(Date.now(),".").concat(e),{type:s}),"voice")}},t.start(),eI(!0),eT(0),eU.current=setInterval(()=>{eT(e=>e+1)},1e3)}catch(e){alert("Could not access microphone"),console.error(e)}},e9=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];eW.current&&ez&&(e&&(eB.current=[]),eW.current.stop(),eI(!1),clearInterval(eU.current),eT(0))};(0,i.useEffect)(()=>{let e=()=>{let e=(0,K.ws)("chat");e&&"chat"===e.target&&ea(e.text)};return e(),window.addEventListener(K.zV,e),()=>window.removeEventListener(K.zV,e)},[]);let e5=()=>{ee.trim()&&(ea(""),eS(!1),e0.current&&clearTimeout(e0.current),e1(ee).then(e=>{e||ea(ee)}))},{data:e3}=(0,c.I)({queryKey:["messages_directory",a.id],staleTime:6e5,queryFn:async()=>{let e=[],t=[],s=[],i=[],[{data:r},{data:l},{data:c},{data:o},{data:d},{data:u},{data:m},{data:p}]=await Promise.all([n.supabase.from("friend_requests").select("sender_id, receiver_id, sender:sender_id(id, name, avatar_url), receiver:receiver_id(id, name, avatar_url)").or("sender_id.eq.".concat(a.id,",receiver_id.eq.").concat(a.id)).eq("status","accepted"),n.supabase.from("pro_connections").select("requester_id, recipient_id").or("requester_id.eq.".concat(a.id,",recipient_id.eq.").concat(a.id)).eq("status","accepted"),n.supabase.from("gigs").select("id").eq("requester_id",a.id),n.supabase.from("gig_applications").select("gig_id").eq("applicant_id",a.id),n.supabase.from("rides").select("rider_id, driver_id").or("rider_id.eq.".concat(a.id,",driver_id.eq.").concat(a.id)).not("driver_id","is",null),n.supabase.from("orders").select("customer_id, driver_id").eq("fulfillment_type","delivery").or("customer_id.eq.".concat(a.id,",driver_id.eq.").concat(a.id)).not("driver_id","is",null),n.supabase.from("profiles").select("id, name, avatar_url, role").in("role",["business","v_business"]).limit(20),n.supabase.schema("gov").from("civic_directory").select("*").limit(20)]);(r||[]).forEach(t=>{let s=t.sender_id===a.id?t.receiver:t.sender;(null==s?void 0:s.id)&&e.push({id:s.id,name:s.name,avatar_url:s.avatar_url})});let h=new Set,v=(c||[]).map(e=>e.id),x=(o||[]).map(e=>e.gig_id),[{data:g},{data:b}]=await Promise.all([v.length?n.supabase.from("gig_applications").select("applicant_id").in("gig_id",v):Promise.resolve({data:[]}),x.length?n.supabase.from("gigs").select("requester_id").in("id",x):Promise.resolve({data:[]})]);
1(g||[]).forEach(e=>h.add(e.applicant_id)),(b||[]).forEach(e=>h.add(e.requester_id));let f=new Set;(d||[]).forEach(e=>{let t=e.rider_id===a.id?e.driver_id:e.rider_id;t&&f.add(t)}),(u||[]).forEach(e=>{let t=e.customer_id===a.id?e.driver_id:e.customer_id;t&&f.add(t)});let y=(l||[]).map(e=>e.requester_id===a.id?e.recipient_id:e.requester_id),j=Array.from(new Set([...y,...h,...f])).filter(e=>e&&e!==a.id),{data:_}=j.length?await n.supabase.from("profiles").select("id, name, avatar_url").in("id",j):{data:[]},w=new Map((_||[]).map(e=>[e.id,e]));return y.forEach(e=>{let a=w.get(e);a&&t.push(a)}),h.forEach(e=>{let a=w.get(e);a&&s.push(a)}),f.forEach(e=>{let a=w.get(e);a&&i.push(a)}),{friends:e,proPlus:t,gigs:s,trips:i,businesses:(m||[]).filter(e=>e.id!==a.id),civic:p||[]}}}),e7=(0,i.useMemo)(()=>new Set(ei?[]:eh.filter(e=>e.page_id).map(e=>e.page_id)),[eh,ei]),ae=(0,i.useMemo)(()=>Array.from(new Set(eh.map(e=>(0,Q.pC)(e,a.id,ei)))).filter(e=>!e7.has(e)).sort(),[eh,a.id,ei,e7]),aa=(0,i.useMemo)(()=>Array.from(e7).sort(),[e7]),{data:at=[]}=(0,c.I)({queryKey:["messages_pages",aa.join(",")],enabled:aa.length>0,staleTime:6e5,queryFn:async()=>{let{data:e}=await n.supabase.from("pages").select("id, name, avatar_url").in("id",aa);return e||[]}}),{data:as=[]}=(0,c.I)({queryKey:["messages_partners",ae.join(",")],enabled:ae.length>0,staleTime:6e5,queryFn:async()=>{let{data:e}=await n.supabase.from("profiles").select("id, name, avatar_url, role").in("id",ae);return e||[]}}),ai=(0,i.useMemo)(()=>{let e=new Map;eh.forEach(t=>{let s=(0,Q.pC)(t,a.id,ei);if(!s)return;let i=e.get(s),r=((null==i?void 0:i.unread)||0)+ +!!((e,a)=>e.receiver_id===a&&!e.read_at&&!e.is_read)(t,el),n=(null==i?void 0:i.isClassifieds)||(t.content||"").includes("[Classifieds]"),l=!i||new Date(t.created_at)>new Date(i.last.created_at)?t:i.last;e.set(s,{last:l,unread:r,isClassifieds:n})});let t=new Map(as.map(e=>[e.id,e])),s=new Map(at.map(e=>[e.id,e])),i=Array.from(e.entries()).map(e=>{let[i,{last:r,unread:n,isClassifieds:l}]=e,c=e7.has(i),o=c?s.get(i):t.get(i),d=(0,Q.vk)(r,a.id,ei),u=(0,Q.IL)(r);return{otherId:i,name:(null==o?void 0:o.name)||(c?"Page":"SETX 360 member"),avatar:(null==o?void 0:o.avatar_url)||void 0,lastMessage:d&&u?"You: ".concat(u):u,lastAt:r.created_at,unreadCount:n,role:c?"page":(null==o?void 0:o.role)||null,isClassifieds:l,messageable:!0,isPage:c}}).sort((e,a)=>new Date(a.lastAt).getTime()-new Date(e.lastAt).getTime());if(ei)return i;let r=(e,a)=>{let t=i.find(a=>a.otherId===e.id);if(t)return void Object.assign(t,a);i.push({otherId:e.id,name:e.name||"SETX 360 member",avatar:e.avatar_url||void 0,lastMessage:"Start a conversation...",lastAt:null,unreadCount:0,role:e.role||null,messageable:!0,...a})};return e3&&(e3.friends.forEach(e=>r(e,{isFriend:!0})),e3.proPlus.forEach(e=>r(e,{isProPlus:!0})),e3.gigs.forEach(e=>r(e,{isGig:!0})),e3.trips.forEach(e=>r(e,{isInteraction:!0})),e3.businesses.forEach(e=>{i.find(a=>a.otherId===e.id)||r(e,{})}),e3.civic.forEach(e=>{i.find(a=>a.otherId===e.id)||i.push({otherId:e.id,name:e.name||e.title||"Civic office",avatar:e.avatar_url,lastMessage:e.department||"Civic office",lastAt:null,unreadCount:0,role:"civic",messageable:!1})}
1)),et.forEach(e=>{i.find(a=>a.otherId===e.otherId)||i.unshift(e)}),i},[eh,as,at,e7,e3,et,a.id,ei,el]);(0,i.useEffect)(()=>{if(!U||ep||ei||ai.some(e=>e.otherId===U))return;let e=!1;return(async()=>{let{data:t}=await n.supabase.from("pages").select("id, name, avatar_url").eq("id",U).maybeSingle(),{data:s}=t?{data:null}:await n.supabase.from("profiles").select("id, name, avatar_url").eq("id",U).maybeSingle(),i=t||s;if(!e){if(!i){let{data:t}=await n.supabase.from("stores").select("owner_id").eq("id",U).maybeSingle();!e&&(null==t?void 0:t.owner_id)&&t.owner_id!==a.id&&J(t.owner_id);return}es(e=>e.some(e=>e.otherId===i.id)?e:[{otherId:i.id,name:i.name||(t?"Page":"SETX 360 member"),avatar:i.avatar_url||void 0,lastMessage:"Start a conversation...",lastAt:null,unreadCount:0,messageable:!0,isPage:!!t,role:t?"page":null},...e])}})(),()=>{e=!0}},[U,ai,ep,ei]),(0,i.useEffect)(()=>{t&&J(t)},[t]);let ar=async e=>{if(eb(e),!e.trim())return void ey([]);e_(!0);let{data:a}=await n.supabase.rpc("search_chat_users",{search_query:e});ey(a||[]),e_(!1)},an=e=>{J(e.id),eb(""),ey([]),ai.find(a=>a.otherId===e.id)||es(a=>[{otherId:e.id,name:e.name,avatar:e.avatar_url,lastMessage:"Start a conversation...",lastAt:null,unreadCount:0,messageable:!0},...a])},al=ai.filter(e=>"recent"===L?!!e.lastAt:"friends"===L?e.isFriend:"interactions"===L?e.isInteraction:"businesses"===L?["business","v_business"].includes(e.role||""):"civic"===L?"civic"===e.role:"proplus"===L?e.isProPlus:"gigs"===L?e.isGig:"classifieds"===L?e.isClassifieds&&!e.isFriend:"other"!==L||!!e.lastAt&&!e.isFriend&&!e.isProPlus&&!e.isGig&&!e.isInteraction&&!e.isClassifieds&&"civic"!==e.role&&!["business","v_business"].includes(e.role||"")),ac=ai.find(e=>e.otherId===U);$.current=!!(null==ac?void 0:ac.isPage);let ao=eh.filter(e=>(0,Q.pC)(e,a.id,ei)===U),ad=ei?eu.find(e=>e.id===ei):null,au=e=>{er(e),J(null),F("recent"),es([])},am=(0,s.jsx)(s.Fragment,{children:U?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"chat-header",children:[(0,s.jsx)("button",{className:"back-btn",onClick:()=>J(null),children:(0,s.jsx)(h.A,{size:20})}),ac&&(0,s.jsxs)("button",{className:"chat-header-profile",onClick:()=>ac.messageable&&!ac.isPage&&(0,Q.UO)(ac.otherId),disabled:!ac.messageable||!!ac.isPage,"aria-label":"View ".concat(ac.name,"'s profile"),children:[(0,s.jsxs)("div",{style:{position:"relative"},children:[(0,s.jsx)(o.e,{name:ac.name,url:ac.avatar,size:40}),eG.has(ac.otherId)&&(0,s.jsx)("span",{className:"online-indicator",title:"Online",style:{width:10,height:10,bottom:2,right:2}})]}),(0,s.jsxs)("div",{className:"chat-user-info-stack",children:[(0,s.jsx)("span",{className:"chat-user-name",children:ac.name}),ek?(0,s.jsx)("span",{className:"typing-status-text",children:"typing..."}):eG.has(ac.otherId)?(0,s.jsx)("span",{className:"online-status-text",children:"Active now"}):null]})]}),(null==ac?void 0:ac.messageable)&&!ac.isPage&&(0,s.jsx)(G._,{platform:"messages",title:"Ask Sabine about this chat",context:{type:"conversation",title:"Chat with ".concat(ac.name),text:ao.slice(-12).map(e=>"".concat((0,Q.vk)(e,a.id,ei)?"Me":ac.name,": ").concat(e.content||"[media]")).join("\n")}}),(null==ac?void 0:ac.messageable)&&!ac.isPage&&!ei&&eY&&(0,s.jsx)("button",{className:"chat-call-btn","aria-label":"Call ".concat(ac.name),title:"Call",onClick:()=>eY.startCall(ac.otherId,ac.name),children:(0,s.jsx)(v.A,{size:20})})]}),(0,s.jsxs)("div",{className:"chat-history",children:[ao.map((e,t)=>{let i=(0,Q.vk)(e,a.id,ei),r=t===ao.length-1||new Date(ao[t+1].created_at).getTime()-new Date(e.created_at).getTime()>3e5,n="audio"===(0,Q.c1)(e)&&"Voice Note"===e.content?"":e.content;return(0,s.jsx)("div",{className:"chat-bubble-wrapper ".concat(i?"sent":"received"),children:(0,s.jsxs)("div",{className:"bubble-content-stack",children:[(e=>{let a=(0,Q.c1)(e);if(!a||!e.media_url)return null;let t=ev[e.media_url];return t?"audio"===a?(0,s.jsx)("audio",{src:t,controls:!0,preload:"metadata",className:"chat-media chat-audio"}):"video"===a?(0,s.jsxs)("div",{className:"chat-media chat-media-visual",onClick:()=>eO({url:t,type:"video"}),children:[(0,s.jsx)("video",{src:"".concat(t,"#t=0.1"),muted:!0,playsInl
1ine:!0,preload:"metadata"}),(0,s.jsx)("span",{className:"chat-media-play",children:"▶"})]}):(0,s.jsx)("div",{className:"chat-media chat-media-visual",onClick:()=>eO({url:t,type:"image"}),children:(0,s.jsx)("img",{src:t,alt:"Photo",loading:"lazy"})}):(0,s.jsx)("div",{className:"chat-media chat-media-loading",children:(0,s.jsx)(m.A,{className:"animate-spin",size:20})})})(e),n&&(0,s.jsx)("div",{className:"chat-bubble",children:(0,s.jsx)("span",{className:"msg-text",children:n})}),(0,s.jsxs)("div",{className:"message-status-row",children:[r&&(0,s.jsx)("span",{className:"chat-timestamp",children:H(e.created_at)}),i&&(0,s.jsx)("span",{className:"read-status-icon ".concat(e.read_at?"read":""),title:e.read_at?"Read at ".concat(new Date(e.read_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})):"Sent",children:e.read_at?(0,s.jsx)(x.A,{size:14,color:"var(--primary)"}):(0,s.jsx)(g.A,{size:14})})]})]})},e.id)}),ek&&(0,s.jsx)("div",{className:"chat-bubble-wrapper received",children:(0,s.jsxs)("div",{className:"typing-indicator-bubble chat-bubble",children:[(0,s.jsx)("div",{className:"typing-dot"}),(0,s.jsx)("div",{className:"typing-dot"}),(0,s.jsx)("div",{className:"typing-dot"})]})}),(0,s.jsx)("div",{ref:eX})]}),(0,s.jsxs)("div",{className:"chat-input-area",children:[(0,s.jsx)("input",{type:"file",ref:eQ,style:{display:"none"},accept:"image/*,video/*",multiple:!0,onChange:e4}),ac&&!ac.messageable?(0,s.jsx)("div",{className:"chat-unavailable",children:"This office can't receive messages in SETX 360 yet."}):ez?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:"24px",padding:"8px 12px",width:"100%"},children:[(0,s.jsx)("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:"#ef4444",animation:"rec-pulse 1s ease-in-out infinite",flexShrink:0}}),(0,s.jsx)("div",{style:{display:"flex",alignItems:"center",gap:"3px",flex:1},children:Array.from({length:20}).map((e,a)=>(0,s.jsx)("div",{style:{width:"3px",borderRadius:"2px",background:"#ef4444",height:"".concat(8+6*Math.sin(.8*a+eE)+8*Math.random(),"px"),animation:"wave-bar ".concat(.4+a%3*.15,"s ease-in-out infinite alternate"),animationDelay:"".concat(.05*a,"s"),opacity:.6+a%2*.4}},a))}),(0,s.jsxs)("span",{style:{fontSize:"0.82rem",color:"#ef4444",fontWeight:600,flexShrink:0,minWidth:"36px"},children:[String(Math.floor(eE/60)).padStart(2,"0"),":",String(eE%60).padStart(2,"0")]}),(0,s.jsx)("button",{onClick:()=>e9(!0),"aria-label":"Cancel recording",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",display:"flex"},children:(0,s.jsx)(b.A,{size:20})}),(0,s.jsx)("button",{onClick:()=>e9(!1),"aria-label":"Send voice message",style:{background:"#ef4444",border:"none",borderRadius:"50%",width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:(0,s.jsx)(f.A,{size:16,color:"#fff"})})]}):(0,s.jsxs)("div",{className:"chat-input-wrapper",children:[(0,s.jsxs)("div",{style:{position:"relative"},children:[(0,s.jsx)("button",{className:"attach-btn",onClick:()=>eq(e=>!e),disabled:eC,"aria-label":"Attach",children:eC?(0,s.jsx)(m.A,{className:"animate-spin",size:20}):(0,s.jsx)(y.A,{size:20})}),eM&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"chat-attach-backdrop",onClick:()=>eq(!1)}),(0,s.jsxs)("div",{className:"chat-attach-menu",children:[(0,s.jsxs)("button",{onClick:()=>{eq(!1),eP(!0)},children:[(0,s.jsx)(j,{size:18})," SETX 360 Gallery"]}),(0,s.jsxs)("button",{onClick:()=>{eq(!1),eL(!0)},children:[(0,s.jsx)(_.A,{size:18})," Camera"]}),(0,s.jsxs)("button",{onClick:()=>{var e;eq(!1),null==(e=eQ.current)||e.click()},children:[(0,s.jsx)(w.A,{size:18})," Photos & videos"]})]})]})]}),(0,s.jsx)("input",{type:"text",placeholder:ad?"Reply as ".concat(ad.name,"..."):"Type a message...",maxLength:5e3,value:ee,onChange:e=>{ea(e.target.value),ew||!1===a.enable_typing_indicators||eS(!0),e0.current&&clearTimeout(e0.current),e0.current=setTimeout(()=>eS(!1),3e3)},onKeyDown:e=>"Enter"===e.key&&e5()}),ee.trim()?(0,s.jsx)("button",{className:"send-btn primary",onClick:e5,"aria-label":"Send",children:(0,s.jsx)(f.A,{size:18})}):(0,s.jsx)("button",{className:"voice-btn",onClick:e8,"aria-label":"Record voice message",children:(0,s.jsx)(S.A,{size:18})})]}),(0,s.jsx)("style",{children:"\n                @keyframes rec-pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }\n                @keyframes wave-bar { from{transform:scaleY(0.4)} to{transform:scaleY(1)} }\n              "})]})]}):(0,s.jsxs)("div",{className:"empty-chat",children:[(0,s.jsx)(p.A,{size:64}),(0,s.jsx)("h2",{children:"Your Messages"}),(0,s.jsx)("p",{children:"Select a conversation or start a new one to chat."})]})});return(0,s.jsxs)("div",{className:"messages-layout ".concat(U?"chat-active":""),children:[(0,s.jsxs)("div",{className:"messages-sidebar",style:O?{width:"100%",display:"flex",flexDirection:"column"}:void 0,children:[(0,s.jsxs)("div",{className:"messages-header",children:[(0,s.jsx)("h2",{children:ad?"".concat(ad.name," inbox"):"Messages"}),eu.length>0&&(0,s.jsxs)("div",{className:"inbox-switcher no-scrollbar",role:"tablist","aria-label":"Choose inbox",children:[(0,s.jsx)("button",{role:"tab","aria-selected":!ei,className:"inbox-chip ".concat(ei?"":"active"),onClick:()=>au(null),children:"Me"}),eu.map(e=>(0,s.jsxs)("button",{role:"tab","aria-selected":ei===e.id,className:"inbox-chip ".concat(ei===e.id?"active":""),onClick:()=>au(e.id),children:[(0,s.jsx)(o.e,{name:e.name,url:e.avatar_url||void 0,size:20}),(0,s.jsx)("span",{children:e.name}),Number(e.unread)>0&&(0,s.jsx)("span",{className:"inbox-chip-badge",children:e.unread})]},e.id))]}
1),!ei&&(0,s.jsxs)("nav",{className:"contacts-tabs no-scrollbar",style:{marginTop:"12px",display:"flex",overflowX:"auto",gap:"8px",paddingBottom:"8px"},children:[(0,s.jsxs)("button",{className:"tab-btn ".concat("recent"===L?"active":""),onClick:()=>F("recent"),children:[(0,s.jsx)(k.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Recent"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("friends"===L?"active":""),onClick:()=>F("friends"),children:[(0,s.jsx)(N.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Friends"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("interactions"===L?"active":""),onClick:()=>F("interactions"),children:[(0,s.jsx)(C.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Trips"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("other"===L?"active":""),onClick:()=>F("other"),children:[(0,s.jsx)(p.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Other"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("businesses"===L?"active":""),onClick:()=>F("businesses"),children:[(0,s.jsx)(A.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Businesses"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("civic"===L?"active":""),onClick:()=>F("civic"),children:[(0,s.jsx)(z.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Civic"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("proplus"===L?"active":""),onClick:()=>F("proplus"),children:[(0,s.jsx)(I.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Connect"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("gigs"===L?"active":""),onClick:()=>F("gigs"),children:[(0,s.jsx)(A.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Gigs"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("classifieds"===L?"active":""),onClick:()=>F("classifieds"),children:[(0,s.jsx)(E.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Classifieds"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("subscriptions"===L?"active":""),onClick:()=>F("subscriptions"),children:[(0,s.jsx)(T.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Subscriptions"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("admin"===L?"active":""),onClick:()=>F("admin"),children:[(0,s.jsx)(M.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Admin"})]}),(0,s.jsxs)("button",{className:"tab-btn ".concat("civic_alerts"===L?"active":""),onClick:()=>F("civic_alerts"),children:[(0,s.jsx)(q.A,{size:14})," ",(0,s.jsx)("span",{style:{fontSize:"0.8rem"},children:"Civic Alerts"})]})]}),!O&&!ei&&(0,s.jsxs)("div",{className:"search-conversations",style:{marginTop:"8px"},children:[(0,s.jsx)(R.A,{size:18}),(0,s.jsx)("input",{type:"text",placeholder:"Search by name or @handle...",value:eg,onChange:e=>ar(e.target.value)})]}),!O&&eg&&(0,s.jsx)("div",{className:"search-results-dropdown",style:{position:"absolute",top:"100px",left:0,right:0,background:"var(--bg)",zIndex:10,borderBottom:"1px solid var(--border)",boxShadow:"0 4px 6px rgba(0,0,0,0.1)"},children:ej?(0,s.jsx)("div",{style:{padding:"16px",textAlign:"center"},children:(0,s.jsx)(m.A,{className:"animate-spin",size:16})}):ef.length>0?ef.map(e=>(0,s.jsxs)("div",{role:"button",tabIndex:0,"aria-label":"Message ".concat(e.name),onClick:()=>an(e),onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),an(e))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",cursor:"pointer",borderBottom:"1px solid var(--border)"},children:[(0,s.jsx)(o.e,{name:e.name,url:e.avatar_url,size:32}),(0,s.jsx)("span",{style:{fontWeight:600},children:e.name}),(0,s.jsx)(P.A,{size:16,style:{marginLeft:"auto",color:"var(--primary)"}})]},e.id)):(0,s.jsx)("div",{style:{padding:"16px",textAlign:"center",fontSize:"0.9rem",color:"var(--text-muted)"},children:"No users found"})})]}),O?(0,s.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,s.jsx)(W,{channelType:"civic_alerts"===L?"civic":"subscriptions"===L?"subscription":"admin",user:a})}):(0,s.jsx)("div",{className:"conversation-list",children:ep?(0,s.jsx)("div",{style:{display:"flex",justifyContent:"center",padding:"40px"},children:(0,s.jsx)(m.A,{className:"animate-spin",color:"var(--primary)"})}):0===al.length?(0,s.jsx)(d.p,{icon:p.A,title:"No Messages",message:"No conversations foun
1d in this section."}):al.map(e=>(0,s.jsxs)("div",{className:"conversation-item ".concat(U===e.otherId?"active":""),onClick:()=>J(e.otherId),children:[(0,s.jsxs)("div",{style:{position:"relative"},children:[(0,s.jsx)(o.e,{name:e.name,url:e.avatar,size:48}),eG.has(e.otherId)&&(0,s.jsx)("span",{className:"online-indicator",title:"Online"})]}),(0,s.jsxs)("div",{className:"conversation-info",children:[(0,s.jsxs)("div",{className:"conv-header-row",children:[(0,s.jsxs)("span",{className:"conv-name",style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.name,"civic"===e.role&&(0,s.jsx)(z.A,{size:12,style:{color:"var(--primary)"}}),e.isProPlus&&(0,s.jsx)(I.A,{size:12,style:{color:"#fbbf24"}}),e.isGig&&(0,s.jsx)("span",{style:{fontSize:"0.6rem",padding:"2px 4px",background:"rgba(16, 185, 129, 0.1)",color:"var(--gigs-green)",borderRadius:"8px"},children:"Gig"})]}),(0,s.jsx)("span",{className:"conv-time",children:H(e.lastAt)})]}),(0,s.jsx)("div",{className:"conv-preview",style:{color:e.unreadCount>0?"var(--text)":"var(--text-muted)",fontWeight:e.unreadCount>0?600:400},children:e.lastMessage})]}),e.unreadCount>0&&U!==e.otherId&&(0,s.jsx)("div",{className:"unread-badge",children:e.unreadCount})]},e.otherId))})]}),!O&&(eK&&U&&"undefined"!=typeof document?(0,r.createPortal)((0,s.jsx)("div",{className:"chat-area chat-area-portal",children:am}),document.body):(0,s.jsx)("div",{className:"chat-area",children:am})),eR&&(0,s.jsx)(V.W,{userId:a.id,pickTarget:"general",onClose:()=>eP(!1),onPick:e6}),eD&&(0,s.jsx)(Y.h,{latestItem:null,onCapture:async e=>(eL(!1),e2(e,"camera")),onOpenGallery:()=>{eL(!1),eP(!0)},onClose:()=>eL(!1)}),eF&&"undefined"!=typeof document&&(0,r.createPortal)((0,s.jsxs)("div",{className:"chat-media-viewer",onClick:()=>eO(null),children:[(0,s.jsx)("button",{className:"chat-media-viewer-close","aria-label":"Close",onClick:()=>eO(null),children:(0,s.jsx)(b.A,{size:24})}),"video"===eF.type?(0,s.jsx)("video",{src:eF.url,controls:!0,autoPlay:!0,playsInline:!0,onClick:e=>e.stopPropagation()}):(0,s.jsx)("img",{src:eF.url,alt:"Photo",onClick:e=>e.stopPropagation()})]}),document.body)]})}},46395:(e,a,t)=>{"use strict";t.d(a,{A:()=>s});let s=(0,t(12119).A)("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]])},67040:()=>{},69853:()=>{},70577:(e,a,t)=>{"use strict";t.d(a,{A:()=>s});let s=(0,t(12119).A)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]])},92400:()=>{},98266:(e,a,t)=>{"use strict";t.d(a,{A:()=>s});let s=(0,t(12119).A)("rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]])}}]);

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.