@usechat/react-native 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var Me={isInitialized:!1,projectId:null,error:null},Is=M=>{Me={isInitialized:!0,projectId:M,error:null}},Oe=M=>{Me={isInitialized:!1,projectId:null,error:M}};var or=()=>({...Me}),qe=()=>{if(Me.error)throw new Error(`UseChat SDK initialization failed: ${Me.error}
2
+ var Me={isInitialized:!1,projectId:null,error:null},Is=M=>{Me={isInitialized:!0,projectId:M,error:null}},Oe=M=>{Me={isInitialized:!1,projectId:null,error:M}};var tr=()=>({...Me}),qe=()=>{if(Me.error)throw new Error(`UseChat SDK initialization failed: ${Me.error}
3
3
 
4
4
  Please call initChat() with a valid project ID before using any UseChat components or hooks.
5
5
 
@@ -11,34 +11,34 @@ Please call initChat() with a valid project ID before using any UseChat componen
11
11
 
12
12
  Example:
13
13
  import { initChat } from '@usechat/react-native';
14
- await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),rr=()=>Me.isInitialized&&!Me.error;var nr=async M=>{let{projectId:S,apiUrl:C="http://localhost:3000/api/chat/init",debug:R=!1}=M;if(!S){let T="Project ID is required";throw Oe(T),new Error(T)}try{R&&console.log(`[UseChat SDK] Validating projectId: ${S}`);let T=await fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:S})});if(R&&console.log(`[Chat SDK] Response status: ${T.status}, ok: ${T.ok}`),!T.ok){let P=`HTTP ${T.status}: ${T.statusText}`;try{let B=await T.json();P=B.error||B.message||P}catch{try{let j=await T.text();j&&(P=`Server error: ${j}`)}catch{P=`Failed to initialize chat (HTTP ${T.status})`}}throw Oe(P),new Error(P)}let A;try{let P=await T.text();if(R&&console.log(`[Chat SDK] Response text: ${P}`),!P){let B="Server returned empty response";throw Oe(B),new Error(B)}A=JSON.parse(P)}catch(P){R&&console.error("[Chat SDK] JSON parse error:",P);let B="Server returned invalid JSON response";throw Oe(B),new Error(B)}if(!A||typeof A!="object"){let P="Server returned invalid response format";throw Oe(P),new Error(P)}let I=A;return R&&console.log(`[UseChat SDK] Successfully initialized with projectId: ${S}`),Is(S),I}catch(T){R&&console.error("[Chat SDK] Init error:",T);let A;throw T instanceof TypeError&&T.message.includes("fetch")?A="Network error: Unable to connect to server. Please check your internet connection.":T instanceof Error?A=T.message:A="Failed to initialize chat: Unknown error",A.includes("Project ID is required")||Oe(A),new Error(A)}};import As,{useState as Vo,useRef as zs,useCallback as $e}from"react";import{View as He,StyleSheet as Tr}from"react-native";import{createContext as ar,useContext as ir}from"react";import{StyleSheet as lr}from"react-native";import{KeyboardProvider as Mr,KeyboardAvoidingView as Cr}from"react-native-keyboard-controller";var vs=ar(null),Rr=({children:M,config:S={}})=>{let C={keyboardBehavior:"padding",keyboardVerticalOffset:60,enableReactionDetails:!0,enableMessageActions:!0,enableScrollToBottom:!0,enableTypingIndicator:!0,...S};return<vs.Provider value={{config:C}}>
14
+ await initChat({ projectId: 'your-project-id' });`)},or=()=>(qe(),Me.projectId),sr=()=>Me.isInitialized&&!Me.error;var rr=async M=>{let{projectId:T,apiUrl:R="http://localhost:3000/api/chat/init",debug:C=!1}=M;if(!T){let S="Project ID is required";throw Oe(S),new Error(S)}try{C&&console.log(`[UseChat SDK] Validating projectId: ${T}`);let S=await fetch(R,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:T})});if(C&&console.log(`[Chat SDK] Response status: ${S.status}, ok: ${S.ok}`),!S.ok){let P=`HTTP ${S.status}: ${S.statusText}`;try{let B=await S.json();P=B.error||B.message||P}catch{try{let E=await S.text();E&&(P=`Server error: ${E}`)}catch{P=`Failed to initialize chat (HTTP ${S.status})`}}throw Oe(P),new Error(P)}let A;try{let P=await S.text();if(C&&console.log(`[Chat SDK] Response text: ${P}`),!P){let B="Server returned empty response";throw Oe(B),new Error(B)}A=JSON.parse(P)}catch(P){C&&console.error("[Chat SDK] JSON parse error:",P);let B="Server returned invalid JSON response";throw Oe(B),new Error(B)}if(!A||typeof A!="object"){let P="Server returned invalid response format";throw Oe(P),new Error(P)}let I=A;return C&&console.log(`[UseChat SDK] Successfully initialized with projectId: ${T}`),Is(T),I}catch(S){C&&console.error("[Chat SDK] Init error:",S);let A;throw S instanceof TypeError&&S.message.includes("fetch")?A="Network error: Unable to connect to server. Please check your internet connection.":S instanceof Error?A=S.message:A="Failed to initialize chat: Unknown error",A.includes("Project ID is required")||Oe(A),new Error(A)}};import As,{useState as Vo,useRef as zs,useCallback as $e}from"react";import{View as He,StyleSheet as Sr}from"react-native";import{createContext as nr,useContext as ar}from"react";import{StyleSheet as ir}from"react-native";import{KeyboardProvider as Mr,KeyboardAvoidingView as Cr}from"react-native-keyboard-controller";var vs=nr(null),Rr=({children:M,config:T={}})=>{let R={keyboardBehavior:"padding",keyboardVerticalOffset:60,enableReactionDetails:!0,enableMessageActions:!0,enableScrollToBottom:!0,enableTypingIndicator:!0,...T};return<vs.Provider value={{config:R}}>
15
15
  <Mr>
16
- <Cr behavior={C.keyboardBehavior}style={[Sr.keyboardContainer]}keyboardVerticalOffset={C.keyboardVerticalOffset}>
16
+ <Cr behavior={R.keyboardBehavior}style={[Tr.keyboardContainer]}keyboardVerticalOffset={R.keyboardVerticalOffset}>
17
17
  {}
18
18
  {M}
19
19
  </Cr>
20
20
  </Mr>
21
- </vs.Provider>},Ao=Rr,Tt=()=>{let M=ir(vs);if(!M)throw new Error("useChatConfig must be used within a ChatProvider");return M.config},Sr=lr.create({container:{flex:1},keyboardContainer:{flex:1,overflow:"hidden"}});import{useState as zo,useCallback as wt}from"react";var It=(M={})=>{let{uploader:S,maxAttachments:C=10,maxFileSize:R=10*1024*1024,allowedTypes:T=["image/*","application/pdf","text/*"],onAttachmentAdd:A,onAttachmentRemove:I,onAttachmentUpload:P}=M,[B,j]=zo([]),[v,V]=zo(!1),[D,z]=zo(0),L=wt(N=>{if(B.length>=C){console.warn(`Maximum ${C} attachments allowed`);return}if(N.data?.size&&N.data.size>R){console.warn(`File size exceeds ${R/(1024*1024)}MB limit`);return}if(N.data?.type&&!T.some(ie=>ie.endsWith("/*")?N.data.type.startsWith(ie.slice(0,-1)):N.data.type===ie)){console.warn(`File type ${N.data.type} not allowed`);return}let E={...N,id:N.id||`att_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,uploadStatus:"pending",uploadProgress:0};j(J=>[...J,E]),A&&A(E)},[B.length,C,R,T,A]),k=wt(N=>{j(E=>E.filter(J=>J.id!==N)),I&&I(N)},[I]),O=wt(()=>{j([])},[]),F=wt(async N=>{try{let E;switch(N){case"image":E={type:"image",data:{uri:"mock-image-uri",width:800,height:600,fileName:"image.jpg",fileSize:1024*1024}};break;case"document":E={type:"document",data:{uri:"mock-document-uri",name:"document.pdf",size:2048*1024,mimeType:"application/pdf"}};break;case"location":E={type:"location",data:{coordinates:{latitude:0,longitude:0},address:"Mock Address",timestamp:Date.now()}};break;case"contact":E={type:"contact",data:{id:"contact-1",name:"John Doe",phoneNumbers:["+1234567890"],emails:["john@example.com"]}};break;default:throw new Error(`Unsupported attachment type: ${N}`)}let J={id:`att_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,type:N,data:E.data,fileName:E.data.fileName||E.data.name,fileSize:E.data.fileSize||E.data.size,mimeType:E.data.mimeType,uploadStatus:"pending",uploadProgress:0};L(J)}catch(E){console.error("Error opening picker:",E)}},[L]),H=wt(async()=>{if(!S)return console.warn("No uploader provided, skipping upload"),B;if(B.length===0)return[];V(!0),z(0);try{let N=B.map(async(Y,X)=>{try{j(Z=>Z.map(W=>W.id===Y.id?{...W,uploadStatus:"uploading",uploadProgress:0}:W));let le=setInterval(()=>{j(Z=>Z.map(W=>W.id===Y.id?{...W,uploadProgress:Math.min((W.uploadProgress??0)+10,90)}:W))},100),me=await S.upload(Y.data);clearInterval(le);let re={...Y,uploadStatus:"completed",uploadProgress:100,data:{...Y.data,url:me.url,metadata:me.metadata}};return j(Z=>Z.map(W=>W.id===Y.id?re:W)),re}catch(le){return console.error(`Error uploading attachment ${Y.id}:`,le),j(me=>me.map(re=>re.id===Y.id?{...re,uploadStatus:"failed",uploadProgress:0}:re)),{...Y,uploadStatus:"failed",uploadProgress:0}}}),E=await Promise.all(N),ie=E.filter(Y=>Y.uploadStatus==="completed").length/E.length*100;return z(ie),P&&P(E),E}catch(N){return console.error("Error uploading attachments:",N),B}finally{V(!1)}},[B,S,P]);return{attachments:B,openPicker:F,addAttachment:L,removeAttachment:k,clearAttachments:O,uploadAttachments:H,isUploading:v,uploadProgress:D}};import{useState as Bo,useCallback as Fe}from"react";var Ps=(M={})=>{let{onSend:S,onFocus:C,initialValue:R="",maxLength:T=1e3}=M,[A,I]=Bo(R),[P,B]=Bo(40),[j,v]=Bo(!1),V=Fe(H=>{H.length<=T&&I(H)},[T]),D=Fe(H=>{if(!A.trim()&&(!H||H.length===0))return;let N=A.trim();S&&S(N,H),I(""),B(40)},[A,S]),z=Fe(()=>{v(!0),C&&C()},[C]),L=Fe(()=>{v(!1)},[]),k=Fe(H=>{B(Math.max(40,Math.min(H,120)))},[]),O=Fe(()=>{I(""),B(40)},[]),F=Fe(H=>{I(H)},[]);return{message:A,composerHeight:P,isFocused:j,handleTextChange:V,handleSend:D,handleFocus:z,handleBlur:L,handleContentSizeChange:k,clearMessage:O,setMessage:F}};var wr=({messages:M,components:S={},renderProps:C={},onMessageSend:R,onReactionAdd:T,onReactionRemove:A,onMessageDelete:I,onActionPress:P,attachmentUploader:B,maxAttachments:j=10,maxFileSize:v=10*1024*1024,allowedFileTypes:V=["image/*","application/pdf","text/*"],enableReactionDetails:D,enableMessageActions:z=!0,enableScrollToBottom:L,enableTypingIndicator:k,isTyping:O=!1,typingUserName:F,isLoading:H=!1,loadingComponent:N})=>{let E=Tt(),[J,ie]=Vo(!1),Y=S.MessageList||Ie,X=S.MessageInput||we,le=D??E.enableReactionDetails??!0,me=z??E.enableMessageActions??!0,re=L??E.enableScrollToBottom??!0,Z=k??E.enableTypingIndicator??!0,[W,ce]=Vo(null),ye=zs(null),[he,ne]=Vo(M||[]),ge=zs((M||[]).length+1);As.useEffect(()=>{M&&(ne(M),ge.current=M.length+1)},[M]),As.useEffect(()=>{if(W&&ye.current){let U=setTimeout(()=>{ye.current?.focus()},150);return()=>clearTimeout(U)}},[W]);let xe=It({uploader:B,maxAttachments:j,maxFileSize:v,allowedTypes:V}),ee=Ps({onSend:(U,$)=>{if(W){let G={id:W.id,text:W.text,senderName:W.senderName,senderId:W.senderId,isMe:W.isMe,timestamp:W.timestamp,type:W.type==="image"?"image":"text",imageData:W.imageData};if($&&$.length>0){let K=$[0],te={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:G,attachments:$,type:K.type==="image"?"image":"text",...K.type==="image"&&K.data&&{imageData:{uri:K.data.uri||"",width:K.data.width||300,height:K.data.height||200,fileName:K.fileName||"image.jpg",fileSize:K.fileSize||0}}};ne(fe=>[...fe,te]),R&&R(te)}else{let K={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:G};ne(te=>[...te,K]),R&&R(K)}ce(null)}else if($&&$.length>0){let G=$[0],K={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",attachments:$,type:G.type==="image"?"image":"text",...G.type==="image"&&G.data&&{imageData:{uri:G.data.uri||"",width:G.data.width||300,height:G.data.height||200,fileName:G.fileName||"image.jpg",fileSize:G.fileSize||0}}};ne(te=>[...te,K]),R&&R(K)}else{let G={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent"};ne(K=>[...K,G]),R&&R(G)}xe.clearAttachments()},onFocus:()=>{}}),Te=$e((U,$)=>{console.log("\u{1F525} Chat - addReaction called with messageId:",U,"and emoji:",$),ne(G=>G.map(K=>K.id===U?K.reactions?.find(fe=>fe.emoji===$)?{...K,reactions:K.reactions?.map(fe=>fe.emoji===$?{...fe,count:fe.count+1,users:[...fe.users,"currentUser"]}:fe)}:{...K,reactions:[...K.reactions||[],{emoji:$,count:1,users:["currentUser"]}]}:K)),T&&T(U,$)},[T]),vo=$e((U,$)=>{ne(G=>G.map(K=>K.id===U?{...K,reactions:K.reactions?.map(te=>te.emoji===$?{...te,count:Math.max(0,te.count-1),users:te.users.filter(fe=>fe!=="currentUser")}:te).filter(te=>te.count>0)}:K)),A&&A(U,$)},[A]),Po=$e(U=>{ne($=>$.map(G=>G.id===U?{...G,deleted:!0,text:"",reactions:void 0}:G)),I&&I(U)},[I]),oe=$e(()=>{ce(null)},[]),de=$e(U=>{ce(U),setTimeout(()=>{ye.current?.focus()},100)},[]),St=$e(U=>{if(J)return;let{layout:$}=U.nativeEvent;$.height<=0||ie(!0)},[J]);if(H)return<He style={Ne.container}>
21
+ </vs.Provider>},Ao=Rr,St=()=>{let M=ar(vs);if(!M)throw new Error("useChatConfig must be used within a ChatProvider");return M.config},Tr=ir.create({container:{flex:1},keyboardContainer:{flex:1,overflow:"hidden"}});import{useState as zo,useCallback as wt}from"react";var It=(M={})=>{let{uploader:T,maxAttachments:R=10,maxFileSize:C=10*1024*1024,allowedTypes:S=["image/*","application/pdf","text/*"],onAttachmentAdd:A,onAttachmentRemove:I,onAttachmentUpload:P}=M,[B,E]=zo([]),[v,V]=zo(!1),[D,z]=zo(0),L=wt(N=>{if(B.length>=R){console.warn(`Maximum ${R} attachments allowed`);return}if(N.data?.size&&N.data.size>C){console.warn(`File size exceeds ${C/(1024*1024)}MB limit`);return}if(N.data?.type&&!S.some(ie=>ie.endsWith("/*")?N.data.type.startsWith(ie.slice(0,-1)):N.data.type===ie)){console.warn(`File type ${N.data.type} not allowed`);return}let j={...N,id:N.id||`att_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,uploadStatus:"pending",uploadProgress:0};E(J=>[...J,j]),A&&A(j)},[B.length,R,C,S,A]),k=wt(N=>{E(j=>j.filter(J=>J.id!==N)),I&&I(N)},[I]),O=wt(()=>{E([])},[]),F=wt(async N=>{try{let j;switch(N){case"image":j={type:"image",data:{uri:"mock-image-uri",width:800,height:600,fileName:"image.jpg",fileSize:1024*1024}};break;case"document":j={type:"document",data:{uri:"mock-document-uri",name:"document.pdf",size:2048*1024,mimeType:"application/pdf"}};break;case"location":j={type:"location",data:{coordinates:{latitude:0,longitude:0},address:"Mock Address",timestamp:Date.now()}};break;case"contact":j={type:"contact",data:{id:"contact-1",name:"John Doe",phoneNumbers:["+1234567890"],emails:["john@example.com"]}};break;default:throw new Error(`Unsupported attachment type: ${N}`)}let J={id:`att_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,type:N,data:j.data,fileName:j.data.fileName||j.data.name,fileSize:j.data.fileSize||j.data.size,mimeType:j.data.mimeType,uploadStatus:"pending",uploadProgress:0};L(J)}catch(j){console.error("Error opening picker:",j)}},[L]),H=wt(async()=>{if(!T)return console.warn("No uploader provided, skipping upload"),B;if(B.length===0)return[];V(!0),z(0);try{let N=B.map(async(Y,X)=>{try{E(Z=>Z.map(W=>W.id===Y.id?{...W,uploadStatus:"uploading",uploadProgress:0}:W));let le=setInterval(()=>{E(Z=>Z.map(W=>W.id===Y.id?{...W,uploadProgress:Math.min((W.uploadProgress??0)+10,90)}:W))},100),me=await T.upload(Y.data);clearInterval(le);let re={...Y,uploadStatus:"completed",uploadProgress:100,data:{...Y.data,url:me.url,metadata:me.metadata}};return E(Z=>Z.map(W=>W.id===Y.id?re:W)),re}catch(le){return console.error(`Error uploading attachment ${Y.id}:`,le),E(me=>me.map(re=>re.id===Y.id?{...re,uploadStatus:"failed",uploadProgress:0}:re)),{...Y,uploadStatus:"failed",uploadProgress:0}}}),j=await Promise.all(N),ie=j.filter(Y=>Y.uploadStatus==="completed").length/j.length*100;return z(ie),P&&P(j),j}catch(N){return console.error("Error uploading attachments:",N),B}finally{V(!1)}},[B,T,P]);return{attachments:B,openPicker:F,addAttachment:L,removeAttachment:k,clearAttachments:O,uploadAttachments:H,isUploading:v,uploadProgress:D}};import{useState as Bo,useCallback as Fe}from"react";var Ps=(M={})=>{let{onSend:T,onFocus:R,initialValue:C="",maxLength:S=1e3}=M,[A,I]=Bo(C),[P,B]=Bo(40),[E,v]=Bo(!1),V=Fe(H=>{H.length<=S&&I(H)},[S]),D=Fe(H=>{if(!A.trim()&&(!H||H.length===0))return;let N=A.trim();T&&T(N,H),I(""),B(40)},[A,T]),z=Fe(()=>{v(!0),R&&R()},[R]),L=Fe(()=>{v(!1)},[]),k=Fe(H=>{B(Math.max(40,Math.min(H,120)))},[]),O=Fe(()=>{I(""),B(40)},[]),F=Fe(H=>{I(H)},[]);return{message:A,composerHeight:P,isFocused:E,handleTextChange:V,handleSend:D,handleFocus:z,handleBlur:L,handleContentSizeChange:k,clearMessage:O,setMessage:F}};var wr=({messages:M,components:T={},renderProps:R={},onMessageSend:C,onReactionAdd:S,onReactionRemove:A,onMessageDelete:I,onActionPress:P,attachmentUploader:B,maxAttachments:E=10,maxFileSize:v=10*1024*1024,allowedFileTypes:V=["image/*","application/pdf","text/*"],enableReactionDetails:D,enableMessageActions:z=!0,enableScrollToBottom:L,enableTypingIndicator:k,isTyping:O=!1,typingUserName:F,isLoading:H=!1,loadingComponent:N})=>{let j=St(),[J,ie]=Vo(!1),Y=T.MessageList||Ie,X=T.MessageInput||we,le=D??j.enableReactionDetails??!0,me=z??j.enableMessageActions??!0,re=L??j.enableScrollToBottom??!0,Z=k??j.enableTypingIndicator??!0,[W,ce]=Vo(null),ye=zs(null),[he,ne]=Vo(M||[]),ge=zs((M||[]).length+1);As.useEffect(()=>{M&&(ne(M),ge.current=M.length+1)},[M]),As.useEffect(()=>{if(W&&ye.current){let U=setTimeout(()=>{ye.current?.focus()},150);return()=>clearTimeout(U)}},[W]);let xe=It({uploader:B,maxAttachments:E,maxFileSize:v,allowedTypes:V}),ee=Ps({onSend:(U,$)=>{if(W){let G={id:W.id,text:W.text,senderName:W.senderName,senderId:W.senderId,isMe:W.isMe,timestamp:W.timestamp,type:W.type==="image"?"image":"text",imageData:W.imageData};if($&&$.length>0){let K=$[0],te={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:G,attachments:$,type:K.type==="image"?"image":"text",...K.type==="image"&&K.data&&{imageData:{uri:K.data.uri||"",width:K.data.width||300,height:K.data.height||200,fileName:K.fileName||"image.jpg",fileSize:K.fileSize||0}}};ne(fe=>[...fe,te]),C&&C(te)}else{let K={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:G};ne(te=>[...te,K]),C&&C(K)}ce(null)}else if($&&$.length>0){let G=$[0],K={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",attachments:$,type:G.type==="image"?"image":"text",...G.type==="image"&&G.data&&{imageData:{uri:G.data.uri||"",width:G.data.width||300,height:G.data.height||200,fileName:G.fileName||"image.jpg",fileSize:G.fileSize||0}}};ne(te=>[...te,K]),C&&C(K)}else{let G={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent"};ne(K=>[...K,G]),C&&C(G)}xe.clearAttachments()},onFocus:()=>{}}),Se=$e((U,$)=>{console.log("\u{1F525} Chat - addReaction called with messageId:",U,"and emoji:",$),ne(G=>G.map(K=>K.id===U?K.reactions?.find(fe=>fe.emoji===$)?{...K,reactions:K.reactions?.map(fe=>fe.emoji===$?{...fe,count:fe.count+1,users:[...fe.users,"currentUser"]}:fe)}:{...K,reactions:[...K.reactions||[],{emoji:$,count:1,users:["currentUser"]}]}:K)),S&&S(U,$)},[S]),vo=$e((U,$)=>{ne(G=>G.map(K=>K.id===U?{...K,reactions:K.reactions?.map(te=>te.emoji===$?{...te,count:Math.max(0,te.count-1),users:te.users.filter(fe=>fe!=="currentUser")}:te).filter(te=>te.count>0)}:K)),A&&A(U,$)},[A]),Po=$e(U=>{ne($=>$.map(G=>G.id===U?{...G,deleted:!0,text:"",reactions:void 0}:G)),I&&I(U)},[I]),oe=$e(()=>{ce(null)},[]),de=$e(U=>{ce(U),setTimeout(()=>{ye.current?.focus()},100)},[]),Tt=$e(U=>{if(J)return;let{layout:$}=U.nativeEvent;$.height<=0||ie(!0)},[J]);if(H)return<He style={Ne.container}>
22
22
  {N||<He style={Ne.loadingContainer}>
23
23
  {}
24
24
  </He>}
25
25
  </He>;if(!J)return<He style={Ne.container}>
26
- <He style={Ne.chatContainer}onLayout={St}>
26
+ <He style={Ne.chatContainer}onLayout={Tt}>
27
27
  <He style={Ne.loadingContainer}>{N}</He>
28
28
  </He>
29
- </He>;let ws=C.renderInput;return<He style={Ne.container}>
29
+ </He>;let ws=R.renderInput;return<He style={Ne.container}>
30
30
  <He style={Ne.fill}>
31
- <Y messages={he}isTyping={Z?O:!1}typingUserName={F}showScrollToBottom={re}isReplyActive={!!W}enableMessageActions={me}enableReactionDetails={le}onReactionAdd={Te}onReactionRemove={vo}onMessageDelete={Po}onReplyMessage={de}onActionPress={(U,$)=>{U==="reply"?de($):P?.(U,$)}}/>
31
+ <Y messages={he}isTyping={Z?O:!1}typingUserName={F}showScrollToBottom={re}isReplyActive={!!W}enableMessageActions={me}enableReactionDetails={le}onReactionAdd={Se}onReactionRemove={vo}onMessageDelete={Po}onReplyMessage={de}onActionPress={(U,$)=>{U==="reply"?de($):P?.(U,$)}}/>
32
32
 
33
- {ws?ws({value:ee.message,onChangeText:ee.handleTextChange,onSend:ee.handleSend,onFocus:ee.handleFocus,height:ee.composerHeight,onContentSizeChange:ee.handleContentSizeChange,replyToMessage:W,onCancelReply:oe,attachments:xe.attachments,onAttachmentAdd:xe.addAttachment,onAttachmentRemove:xe.removeAttachment,onAttachmentUpload:xe.uploadAttachments}):<X ref={ye}value={ee.message}onChangeText={ee.handleTextChange}onSend={ee.handleSend}onFocus={ee.handleFocus}height={ee.composerHeight}onContentSizeChange={ee.handleContentSizeChange}replyToMessage={W}onCancelReply={oe}onAttachmentSend={(U,$)=>{let G=U.type==="image",K={id:ge.current++,text:$?.trim()||"",isMe:!0,timestamp:new Date().toISOString(),status:"sent",type:G?"image":"text",...G&&U.data&&{imageData:{uri:U.data.uri||"",width:U.data.width||300,height:U.data.height||200,fileName:U.data.fileName||U.data.name||"image.jpg",fileSize:U.data.fileSize||U.data.size||0}}};ne(te=>[...te,K]),R&&R(K),ee.handleTextChange("")}}/>}
33
+ {ws?ws({value:ee.message,onChangeText:ee.handleTextChange,onSend:ee.handleSend,onFocus:ee.handleFocus,height:ee.composerHeight,onContentSizeChange:ee.handleContentSizeChange,replyToMessage:W,onCancelReply:oe,attachments:xe.attachments,onAttachmentAdd:xe.addAttachment,onAttachmentRemove:xe.removeAttachment,onAttachmentUpload:xe.uploadAttachments}):<X ref={ye}value={ee.message}onChangeText={ee.handleTextChange}onSend={ee.handleSend}onFocus={ee.handleFocus}height={ee.composerHeight}onContentSizeChange={ee.handleContentSizeChange}replyToMessage={W}onCancelReply={oe}onAttachmentSend={(U,$)=>{let G=U.type==="image",K={id:ge.current++,text:$?.trim()||"",isMe:!0,timestamp:new Date().toISOString(),status:"sent",type:G?"image":"text",...G&&U.data&&{imageData:{uri:U.data.uri||"",width:U.data.width||300,height:U.data.height||200,fileName:U.data.fileName||U.data.name||"image.jpg",fileSize:U.data.fileSize||U.data.size||0}}};ne(te=>[...te,K]),C&&C(K),ee.handleTextChange("")}}/>}
34
34
 
35
35
  {}
36
36
  </He>
37
37
 
38
38
  {}
39
- </He>},Ne=Tr.create({container:{flex:1},chatContainer:{flex:1,overflow:"hidden"},fill:{flex:1},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center"}}),Do=wr;import{View as Pe,Text as Lo,TouchableOpacity as Ut}from"react-native";import{ArrowLeft as Br,Info as Vr,Phone as Dr,Video as Lr}from"lucide-react-native";import{useContext as Ar}from"react";import{createContext as Ir,useMemo as vr}from"react";var vt={colors:{primary:"#3B82F6",secondary:"#34B7F1",background:"#FFFFFF",surface:"#F7F8FA",surfaceSecondary:"#F3F4F6",text:"#111827",textSecondary:"#6B7280",textMuted:"#9CA3AF",border:"#E5E7EB",borderLight:"#F3F4F6",success:"#10B981",error:"#EF4444",warning:"#F59E0B",unread:"#EBF8FF",online:"#10B981",messageBubble:{sent:"#3B82F6",received:"#E5E7EB",sentText:"#FFFFFF",receivedText:"#111827"},gray:{50:"#F9FAFB",100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",400:"#9CA3AF",500:"#6B7280",600:"#4B5563",700:"#374151",800:"#1F2937",900:"#111827"},blue:{50:"#EBF8FF",500:"#3B82F6",600:"#2563EB"},green:{500:"#10B981"}},spacing:{xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},borderRadius:{sm:4,md:8,lg:12,xl:16,full:9999},typography:{fontFamily:"System",fontSize:{xs:12,sm:14,base:16,lg:18,xl:20,xxl:24},fontWeight:{normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeight:{tight:16,normal:20,relaxed:24}}};var ko=Ir(vt),Pr=(M,S)=>({colors:{...M.colors,...S.colors},spacing:{...M.spacing,...S.spacing},borderRadius:{...M.borderRadius,...S.borderRadius},typography:{...M.typography,...S.typography}}),Bs=({children:M,theme:S})=>{let C=vr(()=>S?Pr(vt,S):vt,[S]);return<ko.Provider value={C}>{M}</ko.Provider>};var q=()=>{let M=Ar(ko);if(!M)throw new Error("useTheme must be used within a ThemeProvider");return M};var Er=({name:M="George Alan",isOnline:S=!0,onBack:C=()=>{},onVideoCall:R=()=>{},onVoiceCall:T=()=>{},onInfo:A=()=>{}})=>{let I=q();return<Pe style={{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderBottomWidth:1,borderBottomColor:I.colors.borderLight,backgroundColor:I.colors.background,paddingHorizontal:I.spacing.lg,paddingVertical:I.spacing.md,zIndex:50}}>
39
+ </He>},Ne=Sr.create({container:{flex:1},chatContainer:{flex:1,overflow:"hidden"},fill:{flex:1},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center"}}),Do=wr;import{View as Pe,Text as Lo,TouchableOpacity as Ut}from"react-native";import{ArrowLeft as Br,Info as Vr,Phone as Dr,Video as Lr}from"lucide-react-native";import{useContext as Ar}from"react";import{createContext as Ir,useMemo as vr}from"react";var vt={colors:{primary:"#3B82F6",secondary:"#34B7F1",background:"#FFFFFF",surface:"#F7F8FA",surfaceSecondary:"#F3F4F6",text:"#111827",textSecondary:"#6B7280",textMuted:"#9CA3AF",border:"#E5E7EB",borderLight:"#F3F4F6",success:"#10B981",error:"#EF4444",warning:"#F59E0B",unread:"#EBF8FF",online:"#10B981",messageBubble:{sent:"#3B82F6",received:"#E5E7EB",sentText:"#FFFFFF",receivedText:"#111827"},gray:{50:"#F9FAFB",100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",400:"#9CA3AF",500:"#6B7280",600:"#4B5563",700:"#374151",800:"#1F2937",900:"#111827"},blue:{50:"#EBF8FF",500:"#3B82F6",600:"#2563EB"},green:{500:"#10B981"}},spacing:{xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},borderRadius:{sm:4,md:8,lg:12,xl:16,full:9999},typography:{fontFamily:"System",fontSize:{xs:12,sm:14,base:16,lg:18,xl:20,xxl:24},fontWeight:{normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeight:{tight:16,normal:20,relaxed:24}}};var ko=Ir(vt),Pr=(M,T)=>({colors:{...M.colors,...T.colors},spacing:{...M.spacing,...T.spacing},borderRadius:{...M.borderRadius,...T.borderRadius},typography:{...M.typography,...T.typography}}),Bs=({children:M,theme:T})=>{let R=vr(()=>T?Pr(vt,T):vt,[T]);return<ko.Provider value={R}>{M}</ko.Provider>};var q=()=>{let M=Ar(ko);if(!M)throw new Error("useTheme must be used within a ThemeProvider");return M};var Er=({name:M="George Alan",isOnline:T=!0,onBack:R=()=>{},onVideoCall:C=()=>{},onVoiceCall:S=()=>{},onInfo:A=()=>{}})=>{let I=q();return<Pe style={{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderBottomWidth:1,borderBottomColor:I.colors.borderLight,backgroundColor:I.colors.background,paddingHorizontal:I.spacing.lg,paddingVertical:I.spacing.md,zIndex:50}}>
40
40
  <Pe style={{flex:1,flexDirection:"row",alignItems:"center"}}>
41
- <Ut onPress={C}style={{marginRight:I.spacing.md}}>
41
+ <Ut onPress={R}style={{marginRight:I.spacing.md}}>
42
42
  <Br size={24}color={I.colors.gray[700]}/>
43
43
  </Ut>
44
44
 
@@ -50,7 +50,7 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
50
50
  👤
51
51
  </Lo>
52
52
  </Pe>
53
- {S&&<Pe style={{position:"absolute",bottom:-2,right:-2,height:12,width:12,borderRadius:I.borderRadius.full,borderWidth:1,borderColor:I.colors.background,backgroundColor:I.colors.online}}/>}
53
+ {T&&<Pe style={{position:"absolute",bottom:-2,right:-2,height:12,width:12,borderRadius:I.borderRadius.full,borderWidth:1,borderColor:I.colors.background,backgroundColor:I.colors.online}}/>}
54
54
  </Pe>
55
55
 
56
56
  <Pe style={{flex:1}}>
@@ -58,7 +58,7 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
58
58
  {M}
59
59
  </Lo>
60
60
  <Lo style={{fontSize:I.typography.fontSize.sm,color:I.colors.textSecondary}}>
61
- {S?"Online":"Offline"}
61
+ {T?"Online":"Offline"}
62
62
  </Lo>
63
63
  </Pe>
64
64
  </Pe>
@@ -66,41 +66,41 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
66
66
 
67
67
  <Pe style={{flexDirection:"row",alignItems:"center",gap:I.spacing.lg}}>
68
68
  {}
69
- {R&&<Ut onPress={R}>
69
+ {C&&<Ut onPress={C}>
70
70
  <Lr size={24}color={I.colors.gray[700]}/>
71
71
  </Ut>}
72
- {T&&<Ut onPress={T}>
72
+ {S&&<Ut onPress={S}>
73
73
  <Dr size={24}color={I.colors.gray[700]}/>
74
74
  </Ut>}
75
75
  {A&&<Ut onPress={A}>
76
76
  <Vr size={24}color={I.colors.gray[700]}/>
77
77
  </Ut>}
78
78
  </Pe>
79
- </Pe>},Kt=Er;import{useRef as Xr}from"react";import{View as Bt,Text as Be,Pressable as Qr,TouchableOpacity as Zr}from"react-native";import Pt from"dayjs";import jr from"dayjs/plugin/isToday";import Or from"dayjs/plugin/isYesterday";Pt.extend(jr);Pt.extend(Or);var Fr=M=>{let S=Pt(M);return S.isToday()?"Today":S.isYesterday()?"Yesterday":S.format("ddd D MMMM")},Hr=M=>Pt(M).format("YYYY-MM-DD"),Vs=M=>{if(M.length===0)return[];let S=[],C=null;return M.forEach((R,T)=>{let A=Hr(R.timestamp);if(C!==A){let P=Fr(R.timestamp),B={id:`date-${A}`,listItemType:"date-separator",date:A,displayDate:P};S.push(B),C=A}let I={...R,listItemType:"message"};S.push(I)}),S},Eo=M=>Pt(M).format("HH:mm");import{View as Oo,Text as $t,Image as Nr}from"react-native";var Wr=({replyTo:M,isMyMessage:S})=>{let C=q(),R=(j,v=50)=>j.length<=v?j:j.substring(0,v)+"...",T=S?"rgba(255, 255, 255, 0.3)":C.colors.primary,A=S?"rgba(255, 255, 255, 0.8)":C.colors.primary,I=S?"rgba(255, 255, 255, 0.7)":C.colors.textSecondary,P=S?"rgba(255, 255, 255, 0.1)":C.colors.surfaceSecondary,B=M.type==="image"&&M.imageData;return<Oo style={{marginBottom:C.spacing.sm,borderRadius:C.borderRadius.md,padding:C.spacing.sm,backgroundColor:P,borderLeftWidth:4,borderLeftColor:T}}>
80
- <$t style={{fontSize:C.typography.fontSize.xs,fontWeight:C.typography.fontWeight.medium,color:A,marginBottom:C.spacing.xs}}>
79
+ </Pe>},Kt=Er;import{useRef as Xr}from"react";import{View as Bt,Text as Be,Pressable as Qr,TouchableOpacity as Zr}from"react-native";import Pt from"dayjs";import jr from"dayjs/plugin/isToday";import Or from"dayjs/plugin/isYesterday";Pt.extend(jr);Pt.extend(Or);var Fr=M=>{let T=Pt(M);return T.isToday()?"Today":T.isYesterday()?"Yesterday":T.format("ddd D MMMM")},Hr=M=>Pt(M).format("YYYY-MM-DD"),Vs=M=>{if(M.length===0)return[];let T=[],R=null;return M.forEach((C,S)=>{let A=Hr(C.timestamp);if(R!==A){let P=Fr(C.timestamp),B={id:`date-${A}`,listItemType:"date-separator",date:A,displayDate:P};T.push(B),R=A}let I={...C,listItemType:"message"};T.push(I)}),T},Eo=M=>Pt(M).format("HH:mm");import{View as Oo,Text as $t,Image as Nr}from"react-native";var Wr=({replyTo:M,isMyMessage:T})=>{let R=q(),C=(E,v=50)=>E.length<=v?E:E.substring(0,v)+"...",S=T?"rgba(255, 255, 255, 0.3)":R.colors.primary,A=T?"rgba(255, 255, 255, 0.8)":R.colors.primary,I=T?"rgba(255, 255, 255, 0.7)":R.colors.textSecondary,P=T?"rgba(255, 255, 255, 0.1)":R.colors.surfaceSecondary,B=M.type==="image"&&M.imageData;return<Oo style={{marginBottom:R.spacing.sm,borderRadius:R.borderRadius.md,padding:R.spacing.sm,backgroundColor:P,borderLeftWidth:4,borderLeftColor:S}}>
80
+ <$t style={{fontSize:R.typography.fontSize.xs,fontWeight:R.typography.fontWeight.medium,color:A,marginBottom:R.spacing.xs}}>
81
81
  {M.isMe?"You":M.senderName||"Sender"}
82
82
  </$t>
83
83
 
84
84
  {B?<Oo style={{flexDirection:"row",alignItems:"center"}}>
85
- <Nr source={{uri:M.imageData.uri}}style={{width:40,height:40,borderRadius:C.borderRadius.sm,marginRight:C.spacing.sm}}resizeMode="cover"/>
85
+ <Nr source={{uri:M.imageData.uri}}style={{width:40,height:40,borderRadius:R.borderRadius.sm,marginRight:R.spacing.sm}}resizeMode="cover"/>
86
86
  <Oo style={{flex:1}}>
87
- <$t style={{fontSize:C.typography.fontSize.xs,color:I,fontStyle:"italic",marginBottom:C.spacing.xs}}>
87
+ <$t style={{fontSize:R.typography.fontSize.xs,color:I,fontStyle:"italic",marginBottom:R.spacing.xs}}>
88
88
  📷 Image
89
89
  </$t>
90
- {M.text&&M.text.trim()&&<$t style={{fontSize:C.typography.fontSize.sm,color:I,lineHeight:C.typography.lineHeight.tight}}>
91
- {R(M.text,30)}
90
+ {M.text&&M.text.trim()&&<$t style={{fontSize:R.typography.fontSize.sm,color:I,lineHeight:R.typography.lineHeight.tight}}>
91
+ {C(M.text,30)}
92
92
  </$t>}
93
93
  </Oo>
94
- </Oo>:<$t style={{fontSize:C.typography.fontSize.sm,color:I,lineHeight:C.typography.lineHeight.tight}}>
95
- {R(M.text)}
94
+ </Oo>:<$t style={{fontSize:R.typography.fontSize.sm,color:I,lineHeight:R.typography.lineHeight.tight}}>
95
+ {C(M.text)}
96
96
  </$t>}
97
- </Oo>},Ye=Wr;import{useState as Ds,useCallback as At}from"react";import{View as Yt,Image as Ls,Pressable as Es,Modal as Ur,Dimensions as Kr,StyleSheet as qr,Text as $r}from"react-native";var{width:Fo,height:js}=Kr.get("window"),Yr=({imageData:M,isMe:S,onImagePress:C,onLongPress:R})=>{let T=q(),[A,I]=Ds(!1),[P,B]=Ds(!1),v=At(()=>{let O=Fo*.6,F=300;if(!M.width||!M.height)return{width:O,height:F};let H=M.width/M.height,N=O,E=N/H;return E>F&&(E=F,N=E*H),{width:Math.round(N),height:Math.round(E)}},[M.width,M.height])(),V=At(()=>{C?C():I(!0)},[C]),D=At(()=>{console.error("Failed to load image:",M.uri),B(!0)},[M.uri]),z=At(()=>{I(!1)},[]),k=At(()=>{if(!M.width||!M.height)return{width:Fo,height:js*.8};let O=M.width/M.height,F=Fo*.9,H=js*.8,N=F,E=N/O;return E>H&&(E=H,N=E*O),{width:Math.round(N),height:Math.round(E)}},[M.width,M.height])();return P?<Yt style={[Ae.errorContainer,{width:v.width,height:v.height,backgroundColor:S?T.colors.messageBubble.sent:T.colors.messageBubble.received,borderRadius:T.borderRadius.lg}]}>
98
- <$r style={[Ae.errorText,{color:S?T.colors.messageBubble.sentText:T.colors.messageBubble.receivedText,fontSize:T.typography.fontSize.sm}]}>
97
+ </Oo>},Ye=Wr;import{useState as Ds,useCallback as At}from"react";import{View as Yt,Image as Ls,Pressable as Es,Modal as Ur,Dimensions as Kr,StyleSheet as qr,Text as $r}from"react-native";var{width:Fo,height:js}=Kr.get("window"),Yr=({imageData:M,isMe:T,onImagePress:R,onLongPress:C})=>{let S=q(),[A,I]=Ds(!1),[P,B]=Ds(!1),v=At(()=>{let O=Fo*.6,F=300;if(!M.width||!M.height)return{width:O,height:F};let H=M.width/M.height,N=O,j=N/H;return j>F&&(j=F,N=j*H),{width:Math.round(N),height:Math.round(j)}},[M.width,M.height])(),V=At(()=>{R?R():I(!0)},[R]),D=At(()=>{console.error("Failed to load image:",M.uri),B(!0)},[M.uri]),z=At(()=>{I(!1)},[]),k=At(()=>{if(!M.width||!M.height)return{width:Fo,height:js*.8};let O=M.width/M.height,F=Fo*.9,H=js*.8,N=F,j=N/O;return j>H&&(j=H,N=j*O),{width:Math.round(N),height:Math.round(j)}},[M.width,M.height])();return P?<Yt style={[Ae.errorContainer,{width:v.width,height:v.height,backgroundColor:T?S.colors.messageBubble.sent:S.colors.messageBubble.received,borderRadius:S.borderRadius.lg}]}>
98
+ <$r style={[Ae.errorText,{color:T?S.colors.messageBubble.sentText:S.colors.messageBubble.receivedText,fontSize:S.typography.fontSize.sm}]}>
99
99
  Failed to load image
100
100
  </$r>
101
101
  </Yt>:<>
102
- <Es onPress={V}onLongPress={R}delayLongPress={500}>
103
- <Yt style={[Ae.imageContainer,{borderRadius:T.borderRadius.lg,overflow:"hidden"}]}>
102
+ <Es onPress={V}onLongPress={C}delayLongPress={500}>
103
+ <Yt style={[Ae.imageContainer,{borderRadius:S.borderRadius.lg,overflow:"hidden"}]}>
104
104
  <Ls source={{uri:M.uri}}style={[Ae.image,{width:v.width,height:v.height}]}resizeMode='cover'onError={D}/>
105
105
 
106
106
  {}
@@ -112,118 +112,118 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
112
112
  <Ur visible={A}transparent animationType='fade'onRequestClose={z}>
113
113
  <Es style={Ae.modalContainer}onPress={z}>
114
114
  <Yt style={Ae.modalContent}>
115
- <Ls source={{uri:M.uri}}style={[Ae.modalImage,{width:k.width,height:k.height,borderRadius:T.borderRadius.lg}]}resizeMode='contain'/>
115
+ <Ls source={{uri:M.uri}}style={[Ae.modalImage,{width:k.width,height:k.height,borderRadius:S.borderRadius.lg}]}resizeMode='contain'/>
116
116
  </Yt>
117
117
  </Es>
118
118
  </Ur>
119
- </>},Ae=qr.create({imageContainer:{position:"relative"},image:{backgroundColor:"#f0f0f0"},imageOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"transparent"},errorContainer:{justifyContent:"center",alignItems:"center",borderWidth:1,borderColor:"#e0e0e0"},errorText:{textAlign:"center",fontWeight:"500"},modalContainer:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.9)",justifyContent:"center",alignItems:"center"},modalContent:{justifyContent:"center",alignItems:"center"},modalImage:{backgroundColor:"transparent"}}),Gt=Yr;import{View as _t,Text as Os,StyleSheet as Gr}from"react-native";import{Trash2 as _r}from"lucide-react-native";var Jr=({isMe:M,timestamp:S,senderName:C})=>{let R=q();return<_t style={[Ge.container,{alignSelf:M?"flex-end":"flex-start",maxWidth:"80%"}]}>
120
- <_t style={[Ge.messageBubble,{backgroundColor:R.colors.gray[100],borderColor:R.colors.gray[200]}]}>
119
+ </>},Ae=qr.create({imageContainer:{position:"relative"},image:{backgroundColor:"#f0f0f0"},imageOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"transparent"},errorContainer:{justifyContent:"center",alignItems:"center",borderWidth:1,borderColor:"#e0e0e0"},errorText:{textAlign:"center",fontWeight:"500"},modalContainer:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.9)",justifyContent:"center",alignItems:"center"},modalContent:{justifyContent:"center",alignItems:"center"},modalImage:{backgroundColor:"transparent"}}),Gt=Yr;import{View as _t,Text as Os,StyleSheet as Gr}from"react-native";import{Trash2 as _r}from"lucide-react-native";var Jr=({isMe:M,timestamp:T,senderName:R})=>{let C=q();return<_t style={[Ge.container,{alignSelf:M?"flex-end":"flex-start",maxWidth:"80%"}]}>
120
+ <_t style={[Ge.messageBubble,{backgroundColor:C.colors.gray[100],borderColor:C.colors.gray[200]}]}>
121
121
  <_t style={Ge.content}>
122
- <_r size={16}color={R.colors.gray[500]}/>
123
- <Os style={[Ge.deletedText,{color:R.colors.gray[500]}]}>
122
+ <_r size={16}color={C.colors.gray[500]}/>
123
+ <Os style={[Ge.deletedText,{color:C.colors.gray[500]}]}>
124
124
  This message was deleted
125
125
  </Os>
126
126
  </_t>
127
127
  </_t>
128
128
  <_t style={[Ge.metadata,{alignSelf:M?"flex-end":"flex-start"}]}>
129
- <Os style={[Ge.timestamp,{color:R.colors.gray[400]}]}>
130
- {S}
129
+ <Os style={[Ge.timestamp,{color:C.colors.gray[400]}]}>
130
+ {T}
131
131
  </Os>
132
132
  </_t>
133
- </_t>},Ge=Gr.create({container:{marginVertical:4,marginHorizontal:15},messageBubble:{borderRadius:18,paddingHorizontal:16,paddingVertical:12,borderWidth:1,borderStyle:"dashed"},content:{flexDirection:"row",alignItems:"center",justifyContent:"center"},deletedText:{fontSize:14,fontStyle:"italic",marginLeft:8},metadata:{marginTop:4,paddingHorizontal:4},timestamp:{fontSize:11}}),Jt=Jr;var en=({message:M,onLongPress:S,onReactionPress:C})=>{let R=q(),T=Xr(null),A=()=>{T.current?T.current.measureInWindow((B,j,v,V)=>{let D={x:Math.round(B),y:Math.round(j),width:Math.round(v),height:Math.round(V)};S?.(M,D)}):S?.(M)},I=()=>{M.reactions&&M.reactions.length>0&&C?.(M)},P=M.type==="image"&&M.imageData;return M.deleted?<Jt isMe={M.isMe}timestamp={Eo(M.timestamp)}senderName={M.senderName}/>:<Bt style={{marginBottom:R.spacing.md,alignItems:M.isMe?"flex-end":"flex-start",marginHorizontal:R.spacing.sm}}>
134
- <Qr ref={T}onLongPress={A}delayLongPress={500}style={{maxWidth:P?"75%":"80%",borderRadius:P?R.borderRadius.lg:R.borderRadius.xl,borderBottomRightRadius:M.isMe?4:P?R.borderRadius.lg:R.borderRadius.xl,borderBottomLeftRadius:M.isMe?P?R.borderRadius.lg:R.borderRadius.xl:4,paddingHorizontal:P?0:R.spacing.lg,paddingVertical:P?0:R.spacing.md,backgroundColor:P?"transparent":M.isMe?R.colors.messageBubble.sent:R.colors.messageBubble.received,overflow:"hidden"}}>
133
+ </_t>},Ge=Gr.create({container:{marginVertical:4,marginHorizontal:15},messageBubble:{borderRadius:18,paddingHorizontal:16,paddingVertical:12,borderWidth:1,borderStyle:"dashed"},content:{flexDirection:"row",alignItems:"center",justifyContent:"center"},deletedText:{fontSize:14,fontStyle:"italic",marginLeft:8},metadata:{marginTop:4,paddingHorizontal:4},timestamp:{fontSize:11}}),Jt=Jr;var en=({message:M,onLongPress:T,onReactionPress:R})=>{let C=q(),S=Xr(null),A=()=>{S.current?S.current.measureInWindow((B,E,v,V)=>{let D={x:Math.round(B),y:Math.round(E),width:Math.round(v),height:Math.round(V)};T?.(M,D)}):T?.(M)},I=()=>{M.reactions&&M.reactions.length>0&&R?.(M)},P=M.type==="image"&&M.imageData;return M.deleted?<Jt isMe={M.isMe}timestamp={Eo(M.timestamp)}senderName={M.senderName}/>:<Bt style={{marginBottom:C.spacing.md,alignItems:M.isMe?"flex-end":"flex-start",marginHorizontal:C.spacing.sm}}>
134
+ <Qr ref={S}onLongPress={A}delayLongPress={500}style={{maxWidth:P?"75%":"80%",borderRadius:P?C.borderRadius.lg:C.borderRadius.xl,borderBottomRightRadius:M.isMe?4:P?C.borderRadius.lg:C.borderRadius.xl,borderBottomLeftRadius:M.isMe?P?C.borderRadius.lg:C.borderRadius.xl:4,paddingHorizontal:P?0:C.spacing.lg,paddingVertical:P?0:C.spacing.md,backgroundColor:P?"transparent":M.isMe?C.colors.messageBubble.sent:C.colors.messageBubble.received,overflow:"hidden"}}>
135
135
  {M.replyTo&&<Ye replyTo={M.replyTo}isMyMessage={M.isMe}/>}
136
136
 
137
- {P?<Gt imageData={M.imageData}isMe={M.isMe}onLongPress={A}/>:<Be style={{fontSize:R.typography.fontSize.base,color:M.isMe?R.colors.messageBubble.sentText:R.colors.messageBubble.receivedText}}>
137
+ {P?<Gt imageData={M.imageData}isMe={M.isMe}onLongPress={A}/>:<Be style={{fontSize:C.typography.fontSize.base,color:M.isMe?C.colors.messageBubble.sentText:C.colors.messageBubble.receivedText}}>
138
138
  {M.text}
139
139
  </Be>}
140
140
 
141
141
  {}
142
- {P&&M.text&&M.text.trim()&&<Bt style={{paddingHorizontal:R.spacing.lg,paddingVertical:R.spacing.md,backgroundColor:M.isMe?R.colors.messageBubble.sent:R.colors.messageBubble.received,borderRadius:R.borderRadius.lg,marginTop:R.spacing.xs}}>
143
- <Be style={{fontSize:R.typography.fontSize.base,color:M.isMe?R.colors.messageBubble.sentText:R.colors.messageBubble.receivedText}}>
142
+ {P&&M.text&&M.text.trim()&&<Bt style={{paddingHorizontal:C.spacing.lg,paddingVertical:C.spacing.md,backgroundColor:M.isMe?C.colors.messageBubble.sent:C.colors.messageBubble.received,borderRadius:C.borderRadius.lg,marginTop:C.spacing.xs}}>
143
+ <Be style={{fontSize:C.typography.fontSize.base,color:M.isMe?C.colors.messageBubble.sentText:C.colors.messageBubble.receivedText}}>
144
144
  {M.text}
145
145
  </Be>
146
146
  </Bt>}
147
147
  </Qr>
148
148
 
149
149
  {}
150
- {M.reactions&&M.reactions.length>0&&<Zr onPress={I}style={{marginTop:R.spacing.xs,flexDirection:"row",alignItems:"center",backgroundColor:R.colors.background,borderRadius:R.borderRadius.full,justifyContent:M.isMe?"flex-end":"flex-start"}}>
151
- {M.reactions.map((B,j)=><Bt key={`${B.emoji}-${j}`}style={{flexDirection:"row",alignItems:"center",padding:R.spacing.xs}}>
152
- <Be style={{fontSize:R.typography.fontSize.sm}}>
150
+ {M.reactions&&M.reactions.length>0&&<Zr onPress={I}style={{marginTop:C.spacing.xs,flexDirection:"row",alignItems:"center",backgroundColor:C.colors.background,borderRadius:C.borderRadius.full,justifyContent:M.isMe?"flex-end":"flex-start"}}>
151
+ {M.reactions.map((B,E)=><Bt key={`${B.emoji}-${E}`}style={{flexDirection:"row",alignItems:"center",padding:C.spacing.xs}}>
152
+ <Be style={{fontSize:C.typography.fontSize.sm}}>
153
153
  {B.emoji}
154
154
  </Be>
155
- {B.count>1&&<Be style={{fontSize:R.typography.fontSize.xs,color:R.colors.textSecondary,marginLeft:R.spacing.xs,fontWeight:R.typography.fontWeight.medium}}>
155
+ {B.count>1&&<Be style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary,marginLeft:C.spacing.xs,fontWeight:C.typography.fontWeight.medium}}>
156
156
  {B.count}
157
157
  </Be>}
158
158
  </Bt>)}
159
159
  </Zr>}
160
160
 
161
- <Bt style={{marginHorizontal:R.spacing.sm,marginTop:R.spacing.xs,flexDirection:"row",alignItems:"center",justifyContent:M.isMe?"flex-end":"flex-start"}}>
162
- <Be style={{fontSize:R.typography.fontSize.xs,color:R.colors.textSecondary}}>
161
+ <Bt style={{marginHorizontal:C.spacing.sm,marginTop:C.spacing.xs,flexDirection:"row",alignItems:"center",justifyContent:M.isMe?"flex-end":"flex-start"}}>
162
+ <Be style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary}}>
163
163
  {Eo(M.timestamp)}
164
164
  </Be>
165
- {M.isMe&&M.status&&<Bt style={{marginLeft:R.spacing.xs}}>
166
- {M.status==="sent"&&<Be style={{fontSize:R.typography.fontSize.xs,color:R.colors.gray[400]}}>
165
+ {M.isMe&&M.status&&<Bt style={{marginLeft:C.spacing.xs}}>
166
+ {M.status==="sent"&&<Be style={{fontSize:C.typography.fontSize.xs,color:C.colors.gray[400]}}>
167
167
 
168
168
  </Be>}
169
- {M.status==="delivered"&&<Be style={{fontSize:R.typography.fontSize.xs,color:R.colors.gray[400]}}>
169
+ {M.status==="delivered"&&<Be style={{fontSize:C.typography.fontSize.xs,color:C.colors.gray[400]}}>
170
170
  ✓✓
171
171
  </Be>}
172
- {M.status==="read"&&<Be style={{fontSize:R.typography.fontSize.xs,color:R.colors.primary}}>
172
+ {M.status==="read"&&<Be style={{fontSize:C.typography.fontSize.xs,color:C.colors.primary}}>
173
173
  ✓✓
174
174
  </Be>}
175
175
  </Bt>}
176
176
  </Bt>
177
- </Bt>},Xt=en;import{View as Ce,Text as _e,TouchableOpacity as Mn,Image as Cn}from"react-native";import{X as Rn}from"lucide-react-native";var Sn=({replyToMessage:M,onCancel:S})=>{let C=q(),R=(I,P=50)=>I.length<=P?I:I.substring(0,P)+"...",T=!!M.replyTo,A=M.type==="image"&&M.imageData;return<Ce style={{borderBottomWidth:1,borderBottomColor:C.colors.border,backgroundColor:C.colors.surface,paddingHorizontal:C.spacing.lg,paddingVertical:C.spacing.md}}>
177
+ </Bt>},Xt=en;import{View as Ce,Text as _e,TouchableOpacity as Mn,Image as Cn}from"react-native";import{X as Rn}from"lucide-react-native";var Tn=({replyToMessage:M,onCancel:T})=>{let R=q(),C=(I,P=50)=>I.length<=P?I:I.substring(0,P)+"...",S=!!M.replyTo,A=M.type==="image"&&M.imageData;return<Ce style={{borderBottomWidth:1,borderBottomColor:R.colors.border,backgroundColor:R.colors.surface,paddingHorizontal:R.spacing.lg,paddingVertical:R.spacing.md}}>
178
178
  <Ce style={{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}>
179
- <Ce style={{flex:1,marginRight:C.spacing.md}}>
180
- <Ce style={{flexDirection:"row",alignItems:"center",marginBottom:C.spacing.xs}}>
181
- <Ce style={{width:4,backgroundColor:C.colors.primary,borderRadius:C.borderRadius.full,marginRight:C.spacing.md,height:T?48:32}}/>
179
+ <Ce style={{flex:1,marginRight:R.spacing.md}}>
180
+ <Ce style={{flexDirection:"row",alignItems:"center",marginBottom:R.spacing.xs}}>
181
+ <Ce style={{width:4,backgroundColor:R.colors.primary,borderRadius:R.borderRadius.full,marginRight:R.spacing.md,height:S?48:32}}/>
182
182
  <Ce style={{flex:1}}>
183
- <_e style={{fontSize:C.typography.fontSize.xs,fontWeight:C.typography.fontWeight.medium,color:C.colors.primary,marginBottom:C.spacing.xs}}>
183
+ <_e style={{fontSize:R.typography.fontSize.xs,fontWeight:R.typography.fontWeight.medium,color:R.colors.primary,marginBottom:R.spacing.xs}}>
184
184
  Replying to {M.isMe?"yourself":M.senderName||"sender"}
185
- {T&&" (reply thread)"}
185
+ {S&&" (reply thread)"}
186
186
  </_e>
187
187
 
188
188
  {}
189
- {T&&<Ce style={{marginBottom:C.spacing.sm,padding:C.spacing.sm,backgroundColor:C.colors.surfaceSecondary,borderRadius:C.borderRadius.md,borderLeftWidth:2,borderLeftColor:C.colors.gray[300]}}>
190
- <_e style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary,marginBottom:C.spacing.xs}}>
189
+ {S&&<Ce style={{marginBottom:R.spacing.sm,padding:R.spacing.sm,backgroundColor:R.colors.surfaceSecondary,borderRadius:R.borderRadius.md,borderLeftWidth:2,borderLeftColor:R.colors.gray[300]}}>
190
+ <_e style={{fontSize:R.typography.fontSize.xs,color:R.colors.textSecondary,marginBottom:R.spacing.xs}}>
191
191
  Originally replying to: {M.replyTo.isMe?"yourself":M.replyTo.senderName||"sender"}
192
192
  </_e>
193
- <_e style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary,lineHeight:C.typography.lineHeight.tight}}>
194
- {R(M.replyTo.text,40)}
193
+ <_e style={{fontSize:R.typography.fontSize.xs,color:R.colors.textSecondary,lineHeight:R.typography.lineHeight.tight}}>
194
+ {C(M.replyTo.text,40)}
195
195
  </_e>
196
196
  </Ce>}
197
197
 
198
198
  {A?<Ce style={{flexDirection:"row",alignItems:"center"}}>
199
- <Cn source={{uri:M.imageData.uri}}style={{width:32,height:32,borderRadius:C.borderRadius.sm,marginRight:C.spacing.sm}}resizeMode="cover"/>
199
+ <Cn source={{uri:M.imageData.uri}}style={{width:32,height:32,borderRadius:R.borderRadius.sm,marginRight:R.spacing.sm}}resizeMode="cover"/>
200
200
  <Ce style={{flex:1}}>
201
- <_e style={{fontSize:C.typography.fontSize.xs,color:C.colors.gray[600],fontStyle:"italic",marginBottom:C.spacing.xs}}>
201
+ <_e style={{fontSize:R.typography.fontSize.xs,color:R.colors.gray[600],fontStyle:"italic",marginBottom:R.spacing.xs}}>
202
202
  📷 Image
203
203
  </_e>
204
- {M.text&&M.text.trim()&&<_e style={{fontSize:C.typography.fontSize.sm,color:C.colors.gray[700],lineHeight:C.typography.lineHeight.tight}}>
205
- {R(M.text,40)}
204
+ {M.text&&M.text.trim()&&<_e style={{fontSize:R.typography.fontSize.sm,color:R.colors.gray[700],lineHeight:R.typography.lineHeight.tight}}>
205
+ {C(M.text,40)}
206
206
  </_e>}
207
207
  </Ce>
208
- </Ce>:<_e style={{fontSize:C.typography.fontSize.sm,color:C.colors.gray[700],lineHeight:C.typography.lineHeight.tight}}>
209
- {R(M.text)}
208
+ </Ce>:<_e style={{fontSize:R.typography.fontSize.sm,color:R.colors.gray[700],lineHeight:R.typography.lineHeight.tight}}>
209
+ {C(M.text)}
210
210
  </_e>}
211
211
  </Ce>
212
212
  </Ce>
213
213
  </Ce>
214
214
 
215
- <Mn onPress={S}style={{height:32,width:32,alignItems:"center",justifyContent:"center",borderRadius:C.borderRadius.full,backgroundColor:C.colors.gray[200]}}hitSlop={{top:8,bottom:8,left:8,right:8}}>
216
- <Rn size={16}color={C.colors.textSecondary}/>
215
+ <Mn onPress={T}style={{height:32,width:32,alignItems:"center",justifyContent:"center",borderRadius:R.borderRadius.full,backgroundColor:R.colors.gray[200]}}hitSlop={{top:8,bottom:8,left:8,right:8}}>
216
+ <Rn size={16}color={R.colors.textSecondary}/>
217
217
  </Mn>
218
218
  </Ce>
219
- </Ce>},Vt=Sn;import{useRef as Ve,useState as Fs,useEffect as Wo}from"react";import{View as Dt,Text as Ze,TouchableOpacity as Qe,StyleSheet as Ho,Pressable as Pn,ScrollView as An,Dimensions as zn,Animated as ue,Image as Bn}from"react-native";import{Reply as Vn,Copy as Dn,Plus as Ln,Trash2 as En}from"lucide-react-native";import{useState as Tn,useEffect as wn}from"react";import In from"rn-emoji-keyboard";var vn=({visible:M,onClose:S,onEmojiSelected:C})=>{let[R,T]=Tn(!1);wn(()=>{T(!!M)},[M]);let A=P=>{console.log("Selected emoji:",P),C(P.emoji),T(!1),S()},I=()=>{T(!1),S()};return M?<In onEmojiSelected={A}open={R}onClose={I}enableSearchBar/>:null},Je=vn;var On=({visible:M,onPress:S,children:C})=>M?<Dt style={se.overlay}>
220
- <Qe style={se.backdrop}onPress={S}activeOpacity={1}/>
221
- {C}
222
- </Dt>:null,{width:Xe,height:No}=zn.get("window"),Fn=({message:M,positions:S,messagePosition:C,containerRef:R,containerOffset:T,setContainerOffset:A})=>{let I=q(),P=Ve(new ue.Value(C.y)).current,B=Ve(new ue.Value(0)).current,j=Ve(!1),v=M.type==="image"&&M.imageData;return Wo(()=>{j.current=!1,R.current&&R.current.measureInWindow((V,D,z,L)=>{A({x:V,y:D});let k=C.y-D,O=S.messagePreviewTop-D;P.setValue(k),B.setValue(0),requestAnimationFrame(()=>{ue.parallel([ue.timing(P,{toValue:O,duration:250,useNativeDriver:!1}),ue.timing(B,{toValue:1,duration:250,useNativeDriver:!1})]).start(()=>{j.current=!0})})})},[S.messagePreviewTop,C.y,R]),<ue.View style={{position:"absolute",top:P,left:C.x,width:C.width,height:M.replyTo?C.height+10:C.height,zIndex:1e3,opacity:B,maxWidth:v?"75%":"80%",borderRadius:v?I.borderRadius.lg:I.borderRadius.xl,paddingHorizontal:v?0:I.spacing.lg,paddingVertical:v?0:I.spacing.md,backgroundColor:v?"transparent":M.isMe?I.colors.messageBubble.sent:I.colors.messageBubble.received,overflow:"hidden"}}>
219
+ </Ce>},Vt=Tn;import{useRef as Ve,useState as Fs,useEffect as Wo}from"react";import{View as Dt,Text as Ze,TouchableOpacity as Qe,StyleSheet as Ho,Pressable as Pn,ScrollView as An,Dimensions as zn,Animated as ue,Image as Bn}from"react-native";import{Reply as Vn,Copy as Dn,Plus as Ln,Trash2 as En}from"lucide-react-native";import{useState as Sn,useEffect as wn}from"react";import In from"rn-emoji-keyboard";var vn=({visible:M,onClose:T,onEmojiSelected:R})=>{let[C,S]=Sn(!1);wn(()=>{S(!!M)},[M]);let A=P=>{console.log("Selected emoji:",P),R(P.emoji),S(!1),T()},I=()=>{S(!1),T()};return M?<In onEmojiSelected={A}open={C}onClose={I}enableSearchBar/>:null},Je=vn;var On=({visible:M,onPress:T,children:R})=>M?<Dt style={se.overlay}>
220
+ <Qe style={se.backdrop}onPress={T}activeOpacity={1}/>
221
+ {R}
222
+ </Dt>:null,{width:Xe,height:No}=zn.get("window"),Fn=({message:M,positions:T,messagePosition:R,containerRef:C,containerOffset:S,setContainerOffset:A})=>{let I=q(),P=Ve(new ue.Value(R.y)).current,B=Ve(new ue.Value(0)).current,E=Ve(!1),v=M.type==="image"&&M.imageData;return Wo(()=>{E.current=!1,C.current&&C.current.measureInWindow((V,D,z,L)=>{A({x:V,y:D});let k=R.y-D,O=T.messagePreviewTop-D;P.setValue(k),B.setValue(0),requestAnimationFrame(()=>{ue.parallel([ue.timing(P,{toValue:O,duration:250,useNativeDriver:!1}),ue.timing(B,{toValue:1,duration:250,useNativeDriver:!1})]).start(()=>{E.current=!0})})})},[T.messagePreviewTop,R.y,C]),<ue.View style={{position:"absolute",top:P,left:R.x,width:R.width,height:M.replyTo?R.height+10:R.height,zIndex:1e3,opacity:B,maxWidth:v?"75%":"80%",borderRadius:v?I.borderRadius.lg:I.borderRadius.xl,paddingHorizontal:v?0:I.spacing.lg,paddingVertical:v?0:I.spacing.md,backgroundColor:v?"transparent":M.isMe?I.colors.messageBubble.sent:I.colors.messageBubble.received,overflow:"hidden"}}>
223
223
  {M.replyTo&&<Ye replyTo={M.replyTo}isMyMessage={M.isMe}/>}
224
224
 
225
225
  {v?<Dt>
226
- <Bn source={{uri:M.imageData.uri}}style={{width:C.width,height:C.height,borderRadius:I.borderRadius.lg}}resizeMode='cover'/>
226
+ <Bn source={{uri:M.imageData.uri}}style={{width:R.width,height:R.height,borderRadius:I.borderRadius.lg}}resizeMode='cover'/>
227
227
  {}
228
228
  {M.text&&M.text.trim()&&<Dt style={{paddingHorizontal:I.spacing.lg,paddingVertical:I.spacing.md,backgroundColor:M.isMe?I.colors.messageBubble.sent:I.colors.messageBubble.received,borderRadius:I.borderRadius.lg,marginTop:I.spacing.xs}}>
229
229
  <Ze style={{fontSize:I.typography.fontSize.base,color:M.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
@@ -233,18 +233,18 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
233
233
  </Dt>:<Ze style={{fontSize:I.typography.fontSize.base,color:M.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
234
234
  {M.text}
235
235
  </Ze>}
236
- </ue.View>},Hn=({visible:M,onClose:S,isMyMessage:C,selectedMessage:R,messagePosition:T,onActionPress:A,onEmojiReact:I})=>{let[P,B]=Fs(!1),j=Ve(null),[v,V]=Fs({x:0,y:0}),D=Ve(new ue.Value(0)).current,z=Ve(new ue.Value(0)).current,L=Ve(!1),k=Ve(!1),O=X=>{A(X),S()},F=X=>{I?.(X),S()},H=()=>{B(!0)},N=()=>{B(!1)},E=X=>{I?.(X),B(!1),S()},J=["\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F621}","\u{1F44D}"],Y=(()=>{if(!T)return{emojiBar:{top:No/2-200,left:Xe/2-160},actionMenu:{top:No/2+50,left:Xe/2-100}};let X=320,le=60,me=200,re=160,Z=20,W=8,ce,ye,he,ne,ge,xe=No/2,ee=le+W+T.height+W+re,Te=xe-ee/2;return ye=Te,ge=Te+le+W,ne=Te+le+W+T.height+W,ce=T.x,he=T.x,ce+X>Xe-Z&&(ce=Xe-X-Z),ce<Z&&(ce=Z),he+me>Xe-Z&&(he=Xe-me-Z),he<Z&&(he=Z),{emojiBar:{top:ye,left:ce},actionMenu:{top:ne,left:he},messagePreviewTop:ge,isNearAverageHeight:!0,isNearTop:!0,isEdgeCase:!0}})();return Wo(()=>{M&&T&&!k.current&&(D.setValue(0),z.setValue(0),setTimeout(()=>{ue.sequence([ue.timing(D,{toValue:1,duration:200,useNativeDriver:!1}),ue.timing(z,{toValue:1,duration:200,useNativeDriver:!1})]).start(()=>{k.current=!0})},50))},[M,T,D,z]),Wo(()=>{M||(L.current=!1,k.current=!1,D.setValue(0),z.setValue(0))},[M,D,z]),M?<>
236
+ </ue.View>},Hn=({visible:M,onClose:T,isMyMessage:R,selectedMessage:C,messagePosition:S,onActionPress:A,onEmojiReact:I})=>{let[P,B]=Fs(!1),E=Ve(null),[v,V]=Fs({x:0,y:0}),D=Ve(new ue.Value(0)).current,z=Ve(new ue.Value(0)).current,L=Ve(!1),k=Ve(!1),O=X=>{A(X),T()},F=X=>{I?.(X),T()},H=()=>{B(!0)},N=()=>{B(!1)},j=X=>{I?.(X),B(!1),T()},J=["\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F621}","\u{1F44D}"],Y=(()=>{if(!S)return{emojiBar:{top:No/2-200,left:Xe/2-160},actionMenu:{top:No/2+50,left:Xe/2-100}};let X=320,le=60,me=200,re=160,Z=20,W=8,ce,ye,he,ne,ge,xe=No/2,ee=le+W+S.height+W+re,Se=xe-ee/2;return ye=Se,ge=Se+le+W,ne=Se+le+W+S.height+W,ce=S.x,he=S.x,ce+X>Xe-Z&&(ce=Xe-X-Z),ce<Z&&(ce=Z),he+me>Xe-Z&&(he=Xe-me-Z),he<Z&&(he=Z),{emojiBar:{top:ye,left:ce},actionMenu:{top:ne,left:he},messagePreviewTop:ge,isNearAverageHeight:!0,isNearTop:!0,isEdgeCase:!0}})();return Wo(()=>{M&&S&&!k.current&&(D.setValue(0),z.setValue(0),setTimeout(()=>{ue.sequence([ue.timing(D,{toValue:1,duration:200,useNativeDriver:!1}),ue.timing(z,{toValue:1,duration:200,useNativeDriver:!1})]).start(()=>{k.current=!0})},50))},[M,S,D,z]),Wo(()=>{M||(L.current=!1,k.current=!1,D.setValue(0),z.setValue(0))},[M,D,z]),M?<>
237
237
  {}
238
- <On visible={!0}onPress={S}>
239
- <Pn style={se.overlayPressable}onPress={S}/>
238
+ <On visible={!0}onPress={T}>
239
+ <Pn style={se.overlayPressable}onPress={T}/>
240
240
  </On>
241
241
 
242
- <Dt ref={j}style={{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}>
242
+ <Dt ref={E}style={{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}>
243
243
  {}
244
244
  </Dt>
245
245
 
246
246
  {}
247
- {T&&R&&<Fn message={R}positions={Y}messagePosition={T}containerRef={j}containerOffset={v}setContainerOffset={V}/>}
247
+ {S&&C&&<Fn message={C}positions={Y}messagePosition={S}containerRef={E}containerOffset={v}setContainerOffset={V}/>}
248
248
 
249
249
  {}
250
250
  <ue.View style={[se.emojiBar,{position:"absolute",top:Y.emojiBar.top-(v.y||0),left:Y.emojiBar.left,opacity:D,pointerEvents:"auto"}]}>
@@ -259,7 +259,7 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
259
259
  </ue.View>
260
260
 
261
261
  {}
262
- <ue.View style={[se.actionMenu,{position:"absolute",top:Y.actionMenu.top-(v.y||0)+(R?.replyTo?10:0),left:Y.actionMenu.left,opacity:z,pointerEvents:"auto"}]}>
262
+ <ue.View style={[se.actionMenu,{position:"absolute",top:Y.actionMenu.top-(v.y||0)+(C?.replyTo?10:0),left:Y.actionMenu.left,opacity:z,pointerEvents:"auto"}]}>
263
263
  <Dt style={se.actionItems}>
264
264
  {}
265
265
  <Qe style={se.actionRow}onPress={()=>O("reply")}>
@@ -274,7 +274,7 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
274
274
  </Qe>
275
275
 
276
276
  {}
277
- {C&&<Qe style={se.actionRow}onPress={()=>O("delete")}>
277
+ {R&&<Qe style={se.actionRow}onPress={()=>O("delete")}>
278
278
  <En size={18}color='#ff4444'/>
279
279
  <Ze style={[se.actionLabel,{color:"#ff4444"}]}>
280
280
  Delete
@@ -284,8 +284,8 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
284
284
  </ue.View>
285
285
 
286
286
  {}
287
- <Je visible={P}onClose={N}onEmojiSelected={E}/>
288
- </>:null},se=Ho.create({spotlightOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0},overlayPressable:{flex:1,backgroundColor:"transparent"},emojiBar:{backgroundColor:"white",borderRadius:25,paddingHorizontal:12,paddingVertical:8,shadowColor:"#000",shadowOffset:{width:0,height:4},shadowOpacity:.25,shadowRadius:12,elevation:12,zIndex:1001,maxWidth:320},emojiContainer:{flexDirection:"row",alignItems:"center",paddingHorizontal:4},emojiButton:{width:36,height:36,borderRadius:18,backgroundColor:"#f8f9fa",justifyContent:"center",alignItems:"center",marginHorizontal:3},emojiText:{fontSize:18},addEmojiButton:{width:36,height:36,borderRadius:18,backgroundColor:"#f8f9fa",justifyContent:"center",alignItems:"center",marginHorizontal:3},actionMenu:{backgroundColor:"white",borderRadius:12,shadowColor:"#000",shadowOffset:{width:0,height:4},shadowOpacity:.25,shadowRadius:12,elevation:12,zIndex:1001,minWidth:160,maxWidth:200},actionItems:{paddingVertical:4},actionRow:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:16,minHeight:44},actionLabel:{fontSize:15,color:"#333",marginLeft:12,fontWeight:"500"},hiddenEmojiInput:{position:"absolute",left:-9999,opacity:0,height:0,width:0},overlay:{...Ho.absoluteFillObject,zIndex:1e3},backdrop:{...Ho.absoluteFillObject,backgroundColor:"rgba(0, 0, 0, 0.8)"}}),Qt=Hn;import{useRef as Nn,useEffect as Wn,useState as Un}from"react";import{View as De,Text as Re,TouchableOpacity as Hs,ScrollView as Kn,StyleSheet as qn}from"react-native";import $n from"react-native-actions-sheet";var Yn=({visible:M,onClose:S,reactions:C,messageText:R,onAddReaction:T,onRemoveReaction:A})=>{let I=Nn(null),[P,B]=Un(!1);Wn(()=>{M?I.current?.show():I.current?.hide()},[M]);let v=(()=>{let F=[];return C.forEach(H=>{let N=[{id:"1",name:"You",avatar:"\u{1F464}"},{id:"2",name:"Anna",avatar:"\u{1F469}"},{id:"3",name:"Young Beetle",avatar:"\u{1F697}"},{id:"4",name:"Lele",avatar:"\u{1F3AD}"},{id:"5",name:"Needle",avatar:"\u{1F3E0}"}];for(let E=0;E<Math.min(H.count,N.length);E++)F.push({id:`${H.emoji}-${E}`,name:N[E].name,avatar:N[E].avatar,emoji:H.emoji,timestamp:new Date().toISOString()})}),F})(),V=C.reduce((F,H)=>F+H.count,0),D=F=>{console.log("Remove reaction called with:",F),console.log("onRemoveReaction prop exists:",!!A),console.log("User is current user:",F.name==="You"),F.name==="You"&&A?(console.log("Calling onRemoveReaction with emoji:",F.emoji),A(F.emoji)):console.log("Not calling onRemoveReaction because:",{isCurrentUser:F.name==="You",hasCallback:!!A})},z=()=>{I.current?.hide(),S(),setTimeout(()=>{B(!0)},300)},L=()=>{B(!1)},k=F=>{console.log("Selected emoji from picker:",F),T?.(F),B(!1),S()},O=()=>{I.current?.hide(),S()};return<>
287
+ <Je visible={P}onClose={N}onEmojiSelected={j}/>
288
+ </>:null},se=Ho.create({spotlightOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0},overlayPressable:{flex:1,backgroundColor:"transparent"},emojiBar:{backgroundColor:"white",borderRadius:25,paddingHorizontal:12,paddingVertical:8,shadowColor:"#000",shadowOffset:{width:0,height:4},shadowOpacity:.25,shadowRadius:12,elevation:12,zIndex:1001,maxWidth:320},emojiContainer:{flexDirection:"row",alignItems:"center",paddingHorizontal:4},emojiButton:{width:36,height:36,borderRadius:18,backgroundColor:"#f8f9fa",justifyContent:"center",alignItems:"center",marginHorizontal:3},emojiText:{fontSize:18},addEmojiButton:{width:36,height:36,borderRadius:18,backgroundColor:"#f8f9fa",justifyContent:"center",alignItems:"center",marginHorizontal:3},actionMenu:{backgroundColor:"white",borderRadius:12,shadowColor:"#000",shadowOffset:{width:0,height:4},shadowOpacity:.25,shadowRadius:12,elevation:12,zIndex:1001,minWidth:160,maxWidth:200},actionItems:{paddingVertical:4},actionRow:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:16,minHeight:44},actionLabel:{fontSize:15,color:"#333",marginLeft:12,fontWeight:"500"},hiddenEmojiInput:{position:"absolute",left:-9999,opacity:0,height:0,width:0},overlay:{...Ho.absoluteFillObject,zIndex:1e3},backdrop:{...Ho.absoluteFillObject,backgroundColor:"rgba(0, 0, 0, 0.8)"}}),Qt=Hn;import{useRef as Nn,useEffect as Wn,useState as Un}from"react";import{View as De,Text as Re,TouchableOpacity as Hs,ScrollView as Kn,StyleSheet as qn}from"react-native";import $n from"react-native-actions-sheet";var Yn=({visible:M,onClose:T,reactions:R,messageText:C,onAddReaction:S,onRemoveReaction:A})=>{let I=Nn(null),[P,B]=Un(!1);Wn(()=>{M?I.current?.show():I.current?.hide()},[M]);let v=(()=>{let F=[];return R.forEach(H=>{let N=[{id:"1",name:"You",avatar:"\u{1F464}"},{id:"2",name:"Anna",avatar:"\u{1F469}"},{id:"3",name:"Young Beetle",avatar:"\u{1F697}"},{id:"4",name:"Lele",avatar:"\u{1F3AD}"},{id:"5",name:"Needle",avatar:"\u{1F3E0}"}];for(let j=0;j<Math.min(H.count,N.length);j++)F.push({id:`${H.emoji}-${j}`,name:N[j].name,avatar:N[j].avatar,emoji:H.emoji,timestamp:new Date().toISOString()})}),F})(),V=R.reduce((F,H)=>F+H.count,0),D=F=>{console.log("Remove reaction called with:",F),console.log("onRemoveReaction prop exists:",!!A),console.log("User is current user:",F.name==="You"),F.name==="You"&&A?(console.log("Calling onRemoveReaction with emoji:",F.emoji),A(F.emoji)):console.log("Not calling onRemoveReaction because:",{isCurrentUser:F.name==="You",hasCallback:!!A})},z=()=>{I.current?.hide(),T(),setTimeout(()=>{B(!0)},300)},L=()=>{B(!1)},k=F=>{console.log("Selected emoji from picker:",F),S?.(F),B(!1),T()},O=()=>{I.current?.hide(),T()};return<>
289
289
  <$n ref={I}onClose={O}containerStyle={_.container}headerAlwaysVisible={!0}gestureEnabled={!0}closeOnTouchBackdrop={!0}>
290
290
  {}
291
291
  <De style={_.header}>
@@ -298,7 +298,7 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
298
298
  {}
299
299
  <De style={_.messagePreview}>
300
300
  <Re style={_.messageText}numberOfLines={2}>
301
- {R}
301
+ {C}
302
302
  </Re>
303
303
  </De>
304
304
 
@@ -306,7 +306,7 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
306
306
  <De style={_.reactionButtons}>
307
307
  {}
308
308
 
309
- {C.map((F,H)=><De key={H}style={_.reactionButton}>
309
+ {R.map((F,H)=><De key={H}style={_.reactionButton}>
310
310
  <Re style={_.reactionEmoji}>{F.emoji}</Re>
311
311
  <Re style={_.reactionCount}>{F.count}</Re>
312
312
  </De>)}
@@ -331,7 +331,7 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
331
331
 
332
332
  {}
333
333
  <Je visible={P}onClose={L}onEmojiSelected={k}/>
334
- </>},_=qn.create({container:{backgroundColor:"white",borderTopLeftRadius:20,borderTopRightRadius:20,paddingTop:20,paddingBottom:40,maxHeight:"70%"},header:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:20,paddingBottom:15,borderBottomWidth:1,borderBottomColor:"#f0f0f0"},title:{fontSize:18,fontWeight:"600",color:"#333"},closeButton:{padding:5},closeText:{fontSize:18,color:"#666",fontWeight:"500"},messagePreview:{paddingHorizontal:20,paddingVertical:15,borderBottomWidth:1,borderBottomColor:"#f0f0f0"},messageText:{fontSize:14,color:"#666",lineHeight:20},reactionButtons:{flexDirection:"row",paddingHorizontal:20,paddingVertical:15,gap:10},addReactionButton:{flexDirection:"row",alignItems:"center",backgroundColor:"#f8f9fa",borderWidth:1,borderColor:"#e9ecef",borderRadius:20,paddingHorizontal:12,paddingVertical:8},addReactionIcon:{fontSize:16,marginRight:4},addReactionText:{fontSize:14,color:"#666",fontWeight:"500"},reactionButton:{flexDirection:"row",alignItems:"center",backgroundColor:"#28a745",borderRadius:20,paddingHorizontal:12,paddingVertical:8},reactionEmoji:{fontSize:16,marginRight:4},reactionCount:{fontSize:14,color:"white",fontWeight:"600"},userReactionsList:{paddingHorizontal:20,paddingTop:10},userReactionItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,borderBottomWidth:1,borderBottomColor:"#f8f9fa"},tappableUserReactionItem:{backgroundColor:"#f8f9fa",borderRadius:8,paddingHorizontal:8,marginVertical:2},userInfo:{flexDirection:"row",alignItems:"center",flex:1},userAvatar:{fontSize:24,marginRight:12},userDetails:{flex:1},userName:{fontSize:16,fontWeight:"500",color:"#333"},removeText:{fontSize:12,color:"#dc3545",marginTop:2,fontWeight:"500"},userReactionEmoji:{backgroundColor:"#f8f9fa",borderRadius:16,paddingHorizontal:8,paddingVertical:4},emojiText:{fontSize:16}}),Zt=Yn;import Gn,{forwardRef as _n,useImperativeHandle as Jn}from"react";import{View as Mo,Text as Ns,TouchableOpacity as Ws}from"react-native";import Xn from"react-native-actions-sheet";import{X as Qn}from"lucide-react-native";var We=_n(({onOptionSelect:M,options:S},C)=>{let R=Gn.useRef(null);Jn(C,()=>({show:()=>R.current?.show(),hide:()=>R.current?.hide()}));let T=A=>{M(A),R.current?.hide()};return<Xn ref={R}headerAlwaysVisible gestureEnabled={!0}statusBarTranslucent drawUnderStatusBar={!1}containerStyle={{borderTopLeftRadius:20,borderTopRightRadius:20}}>
334
+ </>},_=qn.create({container:{backgroundColor:"white",borderTopLeftRadius:20,borderTopRightRadius:20,paddingTop:20,paddingBottom:40,maxHeight:"70%"},header:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:20,paddingBottom:15,borderBottomWidth:1,borderBottomColor:"#f0f0f0"},title:{fontSize:18,fontWeight:"600",color:"#333"},closeButton:{padding:5},closeText:{fontSize:18,color:"#666",fontWeight:"500"},messagePreview:{paddingHorizontal:20,paddingVertical:15,borderBottomWidth:1,borderBottomColor:"#f0f0f0"},messageText:{fontSize:14,color:"#666",lineHeight:20},reactionButtons:{flexDirection:"row",paddingHorizontal:20,paddingVertical:15,gap:10},addReactionButton:{flexDirection:"row",alignItems:"center",backgroundColor:"#f8f9fa",borderWidth:1,borderColor:"#e9ecef",borderRadius:20,paddingHorizontal:12,paddingVertical:8},addReactionIcon:{fontSize:16,marginRight:4},addReactionText:{fontSize:14,color:"#666",fontWeight:"500"},reactionButton:{flexDirection:"row",alignItems:"center",backgroundColor:"#28a745",borderRadius:20,paddingHorizontal:12,paddingVertical:8},reactionEmoji:{fontSize:16,marginRight:4},reactionCount:{fontSize:14,color:"white",fontWeight:"600"},userReactionsList:{paddingHorizontal:20,paddingTop:10},userReactionItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,borderBottomWidth:1,borderBottomColor:"#f8f9fa"},tappableUserReactionItem:{backgroundColor:"#f8f9fa",borderRadius:8,paddingHorizontal:8,marginVertical:2},userInfo:{flexDirection:"row",alignItems:"center",flex:1},userAvatar:{fontSize:24,marginRight:12},userDetails:{flex:1},userName:{fontSize:16,fontWeight:"500",color:"#333"},removeText:{fontSize:12,color:"#dc3545",marginTop:2,fontWeight:"500"},userReactionEmoji:{backgroundColor:"#f8f9fa",borderRadius:16,paddingHorizontal:8,paddingVertical:4},emojiText:{fontSize:16}}),Zt=Yn;import Gn,{forwardRef as _n,useImperativeHandle as Jn}from"react";import{View as Mo,Text as Ns,TouchableOpacity as Ws}from"react-native";import Xn from"react-native-actions-sheet";import{X as Qn}from"lucide-react-native";var We=_n(({onOptionSelect:M,options:T},R)=>{let C=Gn.useRef(null);Jn(R,()=>({show:()=>C.current?.show(),hide:()=>C.current?.hide()}));let S=A=>{M(A),C.current?.hide()};return<Xn ref={C}headerAlwaysVisible gestureEnabled={!0}statusBarTranslucent drawUnderStatusBar={!1}containerStyle={{borderTopLeftRadius:20,borderTopRightRadius:20}}>
335
335
  <Mo style={{padding:20,width:"100%"}}>
336
336
 
337
337
  {}
@@ -339,14 +339,14 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
339
339
  <Ns style={{fontSize:18,fontWeight:"600",color:"#1F2937"}}>
340
340
  Share Content
341
341
  </Ns>
342
- <Ws onPress={()=>R.current?.hide()}>
342
+ <Ws onPress={()=>C.current?.hide()}>
343
343
  <Qn size={24}color="#6B7280"/>
344
344
  </Ws>
345
345
  </Mo>
346
346
 
347
347
  {}
348
348
  <Mo style={{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",paddingBottom:20}}>
349
- {S.map(A=>{let I=A.icon;return<Ws key={A.id}style={{width:"30%",aspectRatio:1,marginBottom:20,alignItems:"center",justifyContent:"center"}}onPress={()=>T(A.id)}>
349
+ {T.map(A=>{let I=A.icon;return<Ws key={A.id}style={{width:"30%",aspectRatio:1,marginBottom:20,alignItems:"center",justifyContent:"center"}}onPress={()=>S(A.id)}>
350
350
  <Mo style={{width:60,height:60,borderRadius:30,backgroundColor:"#F3F4F6",alignItems:"center",justifyContent:"center",marginBottom:8}}>
351
351
  <I size={24}color={A.color}/>
352
352
  </Mo>
@@ -356,100 +356,104 @@ await initChat({ projectId: 'your-project-id' });`)},sr=()=>(qe(),Me.projectId),
356
356
  </Ws>})}
357
357
  </Mo>
358
358
  </Mo>
359
- </Xn>});We.displayName="AttachmentMenu";import{useEffect as Zn,useRef as ea}from"react";import{View as Uo,StyleSheet as ta,Animated as ke}from"react-native";var oa=({isVisible:M})=>{let S=ea(new ke.Value(0)).current;return Zn(()=>{if(!M){S.setValue(0);return}let C=ke.loop(ke.sequence([ke.timing(S,{toValue:1,duration:1200,useNativeDriver:!0}),ke.timing(S,{toValue:0,duration:1200,useNativeDriver:!0})]));return C.start(),()=>{C.stop()}},[M,S]),M?<Uo style={et.container}>
359
+ </Xn>});We.displayName="AttachmentMenu";import{useEffect as Zn,useRef as ea}from"react";import{View as Uo,StyleSheet as ta,Animated as ke}from"react-native";var oa=({isVisible:M})=>{let T=ea(new ke.Value(0)).current;return Zn(()=>{if(!M){T.setValue(0);return}let R=ke.loop(ke.sequence([ke.timing(T,{toValue:1,duration:1200,useNativeDriver:!0}),ke.timing(T,{toValue:0,duration:1200,useNativeDriver:!0})]));return R.start(),()=>{R.stop()}},[M,T]),M?<Uo style={et.container}>
360
360
  <Uo style={et.bubble}>
361
361
  <Uo style={et.dotsContainer}>
362
- <ke.View style={[et.dot,{opacity:S.interpolate({inputRange:[0,.5,1],outputRange:[.3,1,.3]}),transform:[{translateY:S.interpolate({inputRange:[0,.5,1],outputRange:[0,-4,0]})}]}]}/>
363
- <ke.View style={[et.dot,{opacity:S.interpolate({inputRange:[.33,.83,1.33],outputRange:[.3,1,.3]}),transform:[{translateY:S.interpolate({inputRange:[.33,.83,1.33],outputRange:[0,-4,0]})}]}]}/>
364
- <ke.View style={[et.dot,{opacity:S.interpolate({inputRange:[.66,1.16,1.66],outputRange:[.3,1,.3]}),transform:[{translateY:S.interpolate({inputRange:[.66,1.16,1.66],outputRange:[0,-4,0]})}]}]}/>
362
+ <ke.View style={[et.dot,{opacity:T.interpolate({inputRange:[0,.5,1],outputRange:[.3,1,.3]}),transform:[{translateY:T.interpolate({inputRange:[0,.5,1],outputRange:[0,-4,0]})}]}]}/>
363
+ <ke.View style={[et.dot,{opacity:T.interpolate({inputRange:[.33,.83,1.33],outputRange:[.3,1,.3]}),transform:[{translateY:T.interpolate({inputRange:[.33,.83,1.33],outputRange:[0,-4,0]})}]}]}/>
364
+ <ke.View style={[et.dot,{opacity:T.interpolate({inputRange:[.66,1.16,1.66],outputRange:[.3,1,.3]}),transform:[{translateY:T.interpolate({inputRange:[.66,1.16,1.66],outputRange:[0,-4,0]})}]}]}/>
365
365
  </Uo>
366
366
  </Uo>
367
- </Uo>:null},et=ta.create({container:{paddingHorizontal:15,paddingVertical:5},bubble:{backgroundColor:"#fff",borderRadius:18,paddingHorizontal:12,paddingVertical:8,alignSelf:"flex-start",maxWidth:"80%"},senderNameContainer:{marginBottom:4},senderName:{fontSize:12,color:"#666",fontWeight:"500"},dotsContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center"},dot:{width:6,height:6,borderRadius:3,backgroundColor:"#999",marginHorizontal:3}}),Mt=oa;import Ko from"react";import{Pressable as Ma,Animated as qo}from"react-native";import{ChevronDown as Ca}from"lucide-react-native";var Ra=({visible:M,onPress:S,isReplyActive:C=!1})=>{let R=q(),T=Ko.useRef(new qo.Value(0)).current,[A,I]=Ko.useState(!1);return Ko.useEffect(()=>{qo.timing(T,{toValue:M?1:0,duration:200,useNativeDriver:!0}).start(()=>{I(M)})},[M,T]),!M&&!A?null:<Ma onPress={S}hitSlop={{top:10,bottom:10,left:10,right:10}}>
368
- {({pressed:P})=><qo.View style={[{position:"absolute",bottom:40,right:R.spacing.lg,zIndex:9999,width:32,height:32,backgroundColor:R.colors.background,borderRadius:R.borderRadius.xl,justifyContent:"center",alignItems:"center",shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.25,shadowRadius:3.84,elevation:5,opacity:T,transform:P?[{scale:.95}]:[]}]}>
369
- <Ca size={20}color={R.colors.text}/>
367
+ </Uo>:null},et=ta.create({container:{paddingHorizontal:15,paddingVertical:5},bubble:{backgroundColor:"#fff",borderRadius:18,paddingHorizontal:12,paddingVertical:8,alignSelf:"flex-start",maxWidth:"80%"},senderNameContainer:{marginBottom:4},senderName:{fontSize:12,color:"#666",fontWeight:"500"},dotsContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center"},dot:{width:6,height:6,borderRadius:3,backgroundColor:"#999",marginHorizontal:3}}),Mt=oa;import Ko from"react";import{Pressable as Ma,Animated as qo}from"react-native";import{ChevronDown as Ca}from"lucide-react-native";var Ra=({visible:M,onPress:T,isReplyActive:R=!1})=>{let C=q(),S=Ko.useRef(new qo.Value(0)).current,[A,I]=Ko.useState(!1);return Ko.useEffect(()=>{qo.timing(S,{toValue:M?1:0,duration:200,useNativeDriver:!0}).start(()=>{I(M)})},[M,S]),!M&&!A?null:<Ma onPress={T}hitSlop={{top:10,bottom:10,left:10,right:10}}>
368
+ {({pressed:P})=><qo.View style={[{position:"absolute",bottom:40,right:C.spacing.lg,zIndex:9999,width:32,height:32,backgroundColor:C.colors.background,borderRadius:C.borderRadius.xl,justifyContent:"center",alignItems:"center",shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.25,shadowRadius:3.84,elevation:5,opacity:S,transform:P?[{scale:.95}]:[]}]}>
369
+ <Ca size={20}color={C.colors.text}/>
370
370
  </qo.View>}
371
- </Ma>},Co=Ra;import{View as Us,Text as Sa}from"react-native";var Ta=({displayDate:M})=>{let S=q();return<Us style={{marginVertical:S.spacing.lg,alignItems:"center"}}>
372
- <Us style={{borderRadius:S.borderRadius.full,backgroundColor:S.colors.surfaceSecondary,paddingHorizontal:S.spacing.md,paddingVertical:S.spacing.xs}}>
373
- <Sa style={{fontSize:S.typography.fontSize.xs,color:S.colors.textSecondary,fontWeight:S.typography.fontWeight.medium}}>
371
+ </Ma>},Co=Ra;import{View as Us,Text as Ta}from"react-native";var Sa=({displayDate:M})=>{let T=q();return<Us style={{marginVertical:T.spacing.lg,alignItems:"center"}}>
372
+ <Us style={{borderRadius:T.borderRadius.full,backgroundColor:T.colors.surfaceSecondary,paddingHorizontal:T.spacing.md,paddingVertical:T.spacing.xs}}>
373
+ <Ta style={{fontSize:T.typography.fontSize.xs,color:T.colors.textSecondary,fontWeight:T.typography.fontWeight.medium}}>
374
374
  {M}
375
- </Sa>
375
+ </Ta>
376
376
  </Us>
377
- </Us>},Ro=Ta;import To,{forwardRef as ja,useRef as Oa,useImperativeHandle as Fa,useCallback as Ha}from"react";import{View as Go,TextInput as Na,TouchableOpacity as Ks,Platform as qs}from"react-native";import{Plus as Wa,Send as Ua,Mic as Ka}from"lucide-react-native";import{useRef as Ia,useCallback as Le}from"react";import{Alert as Q}from"react-native";import{Camera as va,Image as Pa,MapPin as Aa,User as za,FileText as Ba,BarChart3 as Va,Calendar as Da}from"lucide-react-native";var wa={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},$o=async(M,S={})=>{try{let C;try{C=await import("expo-image-manipulator")}catch(V){console.log("expo-image-manipulator not available, returning original image info:",V);let z=`image_${Date.now()}.jpg`;return{uri:M,width:1920,height:1920,fileName:z}}let R={...wa,...S};console.log("Starting image compression...",{uri:M,options:R});let T=await C.manipulateAsync(M,[],{});console.log("Original image info:",{width:T.width,height:T.height,uri:T.uri});let A=[];if(R.maxWidth||R.maxHeight){let{width:V,height:D}=T,z=V,L=D;if(R.maxWidth&&V>R.maxWidth){let k=R.maxWidth/V;z=R.maxWidth,L=D*k}if(R.maxHeight&&L>R.maxHeight){let k=R.maxHeight/L;L=R.maxHeight,z=z*k}(z!==V||L!==D)&&(A.push({resize:{width:Math.round(z),height:Math.round(L)}}),console.log("Resizing image:",{from:{width:V,height:D},to:{width:Math.round(z),height:Math.round(L)}}))}let I={compress:R.quality,format:R.format==="png"?C.SaveFormat?.PNG:C.SaveFormat?.JPEG};console.log("Applying compression with options:",I);let P=await C.manipulateAsync(M,A,I);console.log("Image compression completed:",{originalUri:M,compressedUri:P.uri,finalDimensions:{width:P.width,height:P.height}});let B=Date.now(),j=R.format==="png"?"png":"jpg",v=`compressed_image_${B}.${j}`;return{uri:P.uri,width:P.width,height:P.height,fileName:v}}catch(C){console.error("Error compressing image:",C);let R=C instanceof Error?C.message:"Unknown error";throw new Error(`Failed to compress image: ${R}`)}},Yo=(M,S)=>M>3e3||S>3e3?{maxWidth:1920,maxHeight:1920,quality:.7,format:"jpeg"}:M>1920||S>1920?{maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"}:{quality:.9,format:"jpeg"};var ka=[{id:"photo",label:"Photo",icon:Pa,color:"#3B82F6"},{id:"camera",label:"Camera",icon:va,color:"#6B7280"},{id:"location",label:"Location",icon:Aa,color:"#10B981"},{id:"contact",label:"Contact",icon:za,color:"#6B7280"},{id:"document",label:"Document",icon:Ba,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Va,color:"#F59E0B"},{id:"event",label:"Event",icon:Da,color:"#EF4444"}],So=M=>{let S=Ia(null),C=Le(async()=>{console.log("Photo selection initiated");try{let v;try{v=await import("expo-image-picker")}catch(z){console.log("expo-image-picker not available:",z),Q.alert("Feature Not Available","Photo selection requires expo-image-picker to be installed. Please install expo-image-picker to use this feature.",[{text:"OK"}]);return}console.log("Requesting photo library permissions...");let{status:V}=await v.requestMediaLibraryPermissionsAsync();if(console.log("Photo library permission status:",V),V!=="granted"){Q.alert("Permission needed","Please grant photo library access to select images.");return}console.log("Waiting for UI to stabilize..."),await new Promise(z=>setTimeout(()=>z(void 0),300)),console.log("Launching image picker...");let D=await v.launchImageLibraryAsync({mediaTypes:"images",allowsEditing:!0,aspect:[4,3],quality:.8,allowsMultipleSelection:!1});if(console.log("Image picker result:",D),!D.canceled&&D.assets&&D.assets.length>0){let z=D.assets[0];console.log("Photo selected successfully:",z.uri);try{console.log("Starting image compression...");let L=Yo(z.width||1920,z.height||1920),k=await $o(z.uri,L);console.log("Image compression completed:",k),M?.({type:"image",data:{...k,originalFileSize:z.fileSize}})}catch(L){console.error("Image compression failed:",L),Q.alert("Compression Error","Failed to compress image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:z.uri,width:z.width,height:z.height,fileSize:z.fileSize,fileName:z.fileName||"image.jpg"}})}}else console.log("Photo selection was canceled by user")}catch(v){console.error("Error in photo selection process:",v),Q.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),R=Le(async()=>{console.log("Camera capture initiated");try{let v;try{v=await import("expo-image-picker")}catch(z){console.log("expo-image-picker not available:",z),Q.alert("Feature Not Available","Camera capture requires expo-image-picker to be installed. Please install expo-image-picker to use this feature.",[{text:"OK"}]);return}console.log("Requesting camera permissions...");let{status:V}=await v.requestCameraPermissionsAsync();if(console.log("Camera permission status:",V),V!=="granted"){Q.alert("Permission needed","Please grant camera access to take photos.");return}console.log("Waiting for UI to stabilize..."),await new Promise(z=>setTimeout(()=>z(void 0),300)),console.log("Launching camera...");let D=await v.launchCameraAsync({allowsEditing:!0,aspect:[4,3],quality:.8,mediaTypes:"images"});if(console.log("Camera result:",D),!D.canceled&&D.assets&&D.assets.length>0){let z=D.assets[0];console.log("Photo captured successfully:",z.uri);try{console.log("Starting camera image compression...");let L=Yo(z.width||1920,z.height||1920),k=await $o(z.uri,L);console.log("Camera image compression completed:",k),M?.({type:"image",data:{...k,originalFileSize:z.fileSize}})}catch(L){console.error("Camera image compression failed:",L),Q.alert("Compression Error","Failed to compress captured image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:z.uri,width:z.width,height:z.height,fileSize:z.fileSize,fileName:z.fileName||"camera_photo.jpg"}})}}else console.log("Camera capture was canceled by user")}catch(v){console.error("Error in camera capture process:",v),Q.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),T=Le(async()=>{console.log("Location sharing initiated");try{let v;try{v=await import("expo-location")}catch(k){console.log("expo-location not available:",k),Q.alert("Feature Not Available","Location sharing requires expo-location to be installed. Please install expo-location to use this feature.",[{text:"OK"}]);return}console.log("Requesting location permissions...");let{status:V}=await v.requestForegroundPermissionsAsync();if(console.log("Location permission status:",V),V!=="granted"){Q.alert("Permission needed","Please grant location access to share your location.");return}console.log("Getting current location...");let D=await v.getCurrentPositionAsync({accuracy:v.Accuracy.High});console.log("Getting address from coordinates...");let z=await v.reverseGeocodeAsync({latitude:D.coords.latitude,longitude:D.coords.longitude}),L={coordinates:{latitude:D.coords.latitude,longitude:D.coords.longitude},address:z[0]||null,timestamp:D.timestamp};console.log("Location shared successfully:",L.coordinates),M?.({type:"location",data:L})}catch(v){console.error("Error in location sharing process:",v),Q.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),A=Le(async()=>{try{let v;try{v=await import("expo-contacts")}catch(D){console.log("expo-contacts not available:",D),Q.alert("Feature Not Available","Contact sharing requires expo-contacts to be installed. Please install expo-contacts to use this feature.",[{text:"OK"}]);return}let{status:V}=await v.requestPermissionsAsync();if(V!=="granted"){Q.alert("Permission needed","Please grant contacts access to share contacts.");return}Q.alert("Contact Sharing","Contact selection feature is coming soon! This would open a contact picker.",[{text:"OK",onPress:()=>console.log("Contact sharing acknowledged")}])}catch(v){console.error("Error accessing contacts:",v),Q.alert("Error","Failed to access contacts. Please try again.")}finally{S.current?.hide()}},[]),I=Le(async()=>{console.log("Document selection initiated");try{let v;try{v=await import("expo-document-picker")}catch(D){console.log("expo-document-picker not available:",D),Q.alert("Feature Not Available","Document selection requires expo-document-picker to be installed. Please install expo-document-picker to use this feature.",[{text:"OK"}]);return}console.log("Waiting for UI to stabilize..."),await new Promise(D=>setTimeout(()=>D(void 0),300)),console.log("Launching document picker...");let V=await v.getDocumentAsync({type:"*/*",copyToCacheDirectory:!0,multiple:!1});if(console.log("Document picker result:",V),!V.canceled&&V.assets&&V.assets.length>0){let D=V.assets[0];console.log("Document selected successfully:",D.name),M?.({type:"document",data:{uri:D.uri,name:D.name,size:D.size,mimeType:D.mimeType}})}else console.log("Document selection was canceled by user")}catch(v){console.error("Error in document selection process:",v),Q.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[M]),P=Le(()=>{Q.alert("Create Poll","Poll creation feature is coming soon! This would open a poll creation interface.",[{text:"OK",onPress:()=>console.log("Poll creation acknowledged")}])},[]),B=Le(()=>{Q.alert("Create Event","Event creation feature is coming soon! This would open an event creation interface.",[{text:"OK",onPress:()=>console.log("Event creation acknowledged")}])},[]),j=Le(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await C();break;case"camera":await R();break;case"location":await T();break;case"contact":await A();break;case"document":await I();break;case"poll":P();break;case"event":B();break;default:console.warn(`Unknown attachment option: ${v}`)}}catch(V){console.error(`Error handling ${v}:`,V),Q.alert("Error",`Failed to handle ${v}. Please try again.`)}},[C,R,T,A,I,P,B]);return{menuRef:S,handleOptionSelect:j,options:ka}};import Ee,{useRef as La,useCallback as pe,createContext as Ea,useContext as md}from"react";var kt=(M={})=>{let{initialValue:S="",initialHeight:C=50,onValueChange:R,onHeightChange:T,onSend:A,onAttachmentSend:I,onReplyCancel:P,onFocus:B,onBlur:j,maxHeight:v=100,minHeight:V=50,maxLength:D=1e3,placeholder:z="Type a message..."}=M,L=La(null),[k,O]=Ee.useState(S),[F,H]=Ee.useState(C),[N,E]=Ee.useState(!1),[J,ie]=Ee.useState(null),[Y,X]=Ee.useState([]),le=Ee.useMemo(()=>({value:k,height:F,isFocused:N,replyToMessage:J,attachments:Y}),[k,F,N,J,Y]),me=pe(oe=>{O(oe),R?.(oe)},[R]),re=pe(oe=>{let de=Math.max(V,Math.min(v,oe));H(de),T?.(de)},[V,v,T]),Z=pe(()=>{E(!0),B?.()},[B]),W=pe(()=>{E(!1),j?.()},[j]),ce=pe(oe=>{let{height:de}=oe.nativeEvent.contentSize,St=Math.max(V,Math.min(v,de+16));re(St)},[V,v,re]),ye=pe(()=>{A&&(k||Y.length>0)&&(A(k,Y,J),O(S),X([]),ie(null),H(C))},[A,k,Y,J,S,C]),he=pe(oe=>{I?(I(oe,k),k&&O(S)):X(de=>[...de,{...oe,id:Date.now().toString()}])},[I,k,S]),ne=pe(oe=>{X(de=>[...de,oe])},[]),ge=pe(oe=>{X(de=>de.filter(St=>St.id!==oe))},[]),xe=pe(()=>{X([])},[]),ee=pe(()=>{ie(null),P?.()},[P]),Te=pe(()=>{L.current?.focus()},[]),vo=Ee.useMemo(()=>({setValue:me,setHeight:re,setFocus:E,setReplyToMessage:ie,addAttachment:ne,removeAttachment:ge,clearAttachments:xe,sendMessage:ye,cancelReply:ee,focusInput:Te,handleAttachmentSelected:he,handleContentSizeChange:ce,handleFocus:Z,handleBlur:W}),[me,re,E,ie,ne,ge,xe,ye,ee,Te,he,ce,Z,W]),Po=Ee.useMemo(()=>({textInputRef:L}),[]);return{state:le,actions:vo,refs:Po}},pd=Ea(null);var we=ja(({value:M,onChangeText:S,onSend:C,onFocus:R,height:T,onContentSizeChange:A,replyToMessage:I,onCancelReply:P,onAttachmentSend:B},j)=>{let v=q(),V=Oa(null);Fa(j,()=>({focus:()=>{V.current?.focus()}}));let{state:D,actions:z}=kt({initialValue:M,initialHeight:T,onValueChange:S,onHeightChange:A,onSend:C,onAttachmentSend:B,onReplyCancel:P,onFocus:R});To.useEffect(()=>{M!==D.value&&z.setValue(M)},[M,D.value,z]),To.useEffect(()=>{T!==D.height&&z.setHeight(T)},[T,D.height,z]),To.useEffect(()=>{I!==D.replyToMessage&&z.setReplyToMessage(I||null)},[I,D.replyToMessage,z]),To.useEffect(()=>{if(I&&V.current){let O=setTimeout(()=>{V.current?.focus()},100);return()=>clearTimeout(O)}},[I]);let L=Ha(O=>{if(console.log("Attachment selected:",O),B)B(O,M.trim()||void 0),M.trim()&&S("");else switch(O.type){case"image":console.log("Image attachment ready to send:",{uri:O.data.uri,dimensions:{width:O.data.width,height:O.data.height},fileName:O.data.fileName});break;case"document":console.log("Document attachment ready to send:",{name:O.data.name,size:O.data.size});break;case"location":console.log("Location attachment ready to send:",O.data.coordinates);break;case"contact":console.log("Contact attachment ready to send:",O.data);break;default:console.log("Other attachment ready to send:",O)}},[B,M,S]),k=So(L);return<>
377
+ </Us>},Ro=Sa;import So,{forwardRef as ja,useRef as Oa,useImperativeHandle as Fa,useCallback as Ha}from"react";import{View as Go,TextInput as Na,TouchableOpacity as Ks,Platform as qs}from"react-native";import{Plus as Wa,Send as Ua,Mic as Ka}from"lucide-react-native";import{useRef as Ia,useCallback as Le}from"react";import{Alert as Q}from"react-native";import{Camera as va,Image as Pa,MapPin as Aa,User as za,FileText as Ba,BarChart3 as Va,Calendar as Da}from"lucide-react-native";var wa={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},$o=async(M,T={})=>{try{let R;try{R=await import("expo-image-manipulator")}catch(V){console.log("expo-image-manipulator not available, returning original image info:",V);let z=`image_${Date.now()}.jpg`;return{uri:M,width:1920,height:1920,fileName:z}}let C={...wa,...T};console.log("Starting image compression...",{uri:M,options:C});let S=await R.manipulateAsync(M,[],{});console.log("Original image info:",{width:S.width,height:S.height,uri:S.uri});let A=[];if(C.maxWidth||C.maxHeight){let{width:V,height:D}=S,z=V,L=D;if(C.maxWidth&&V>C.maxWidth){let k=C.maxWidth/V;z=C.maxWidth,L=D*k}if(C.maxHeight&&L>C.maxHeight){let k=C.maxHeight/L;L=C.maxHeight,z=z*k}(z!==V||L!==D)&&(A.push({resize:{width:Math.round(z),height:Math.round(L)}}),console.log("Resizing image:",{from:{width:V,height:D},to:{width:Math.round(z),height:Math.round(L)}}))}let I={compress:C.quality,format:C.format==="png"?R.SaveFormat?.PNG:R.SaveFormat?.JPEG};console.log("Applying compression with options:",I);let P=await R.manipulateAsync(M,A,I);console.log("Image compression completed:",{originalUri:M,compressedUri:P.uri,finalDimensions:{width:P.width,height:P.height}});let B=Date.now(),E=C.format==="png"?"png":"jpg",v=`compressed_image_${B}.${E}`;return{uri:P.uri,width:P.width,height:P.height,fileName:v}}catch(R){console.error("Error compressing image:",R);let C=R instanceof Error?R.message:"Unknown error";throw new Error(`Failed to compress image: ${C}`)}},Yo=(M,T)=>M>3e3||T>3e3?{maxWidth:1920,maxHeight:1920,quality:.7,format:"jpeg"}:M>1920||T>1920?{maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"}:{quality:.9,format:"jpeg"};var ka=[{id:"photo",label:"Photo",icon:Pa,color:"#3B82F6"},{id:"camera",label:"Camera",icon:va,color:"#6B7280"},{id:"location",label:"Location",icon:Aa,color:"#10B981"},{id:"contact",label:"Contact",icon:za,color:"#6B7280"},{id:"document",label:"Document",icon:Ba,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Va,color:"#F59E0B"},{id:"event",label:"Event",icon:Da,color:"#EF4444"}],To=M=>{let T=Ia(null),R=Le(async()=>{console.log("Photo selection initiated");try{let v;try{v=await import("expo-image-picker")}catch(z){console.log("expo-image-picker not available:",z),Q.alert("Feature Not Available","Photo selection requires expo-image-picker to be installed. Please install expo-image-picker to use this feature.",[{text:"OK"}]);return}console.log("Requesting photo library permissions...");let{status:V}=await v.requestMediaLibraryPermissionsAsync();if(console.log("Photo library permission status:",V),V!=="granted"){Q.alert("Permission needed","Please grant photo library access to select images.");return}console.log("Waiting for UI to stabilize..."),await new Promise(z=>setTimeout(()=>z(void 0),300)),console.log("Launching image picker...");let D=await v.launchImageLibraryAsync({mediaTypes:"images",allowsEditing:!0,aspect:[4,3],quality:.8,allowsMultipleSelection:!1});if(console.log("Image picker result:",D),!D.canceled&&D.assets&&D.assets.length>0){let z=D.assets[0];console.log("Photo selected successfully:",z.uri);try{console.log("Starting image compression...");let L=Yo(z.width||1920,z.height||1920),k=await $o(z.uri,L);console.log("Image compression completed:",k),M?.({type:"image",data:{...k,originalFileSize:z.fileSize}})}catch(L){console.error("Image compression failed:",L),Q.alert("Compression Error","Failed to compress image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:z.uri,width:z.width,height:z.height,fileSize:z.fileSize,fileName:z.fileName||"image.jpg"}})}}else console.log("Photo selection was canceled by user")}catch(v){console.error("Error in photo selection process:",v),Q.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),C=Le(async()=>{console.log("Camera capture initiated");try{let v;try{v=await import("expo-image-picker")}catch(z){console.log("expo-image-picker not available:",z),Q.alert("Feature Not Available","Camera capture requires expo-image-picker to be installed. Please install expo-image-picker to use this feature.",[{text:"OK"}]);return}console.log("Requesting camera permissions...");let{status:V}=await v.requestCameraPermissionsAsync();if(console.log("Camera permission status:",V),V!=="granted"){Q.alert("Permission needed","Please grant camera access to take photos.");return}console.log("Waiting for UI to stabilize..."),await new Promise(z=>setTimeout(()=>z(void 0),300)),console.log("Launching camera...");let D=await v.launchCameraAsync({allowsEditing:!0,aspect:[4,3],quality:.8,mediaTypes:"images"});if(console.log("Camera result:",D),!D.canceled&&D.assets&&D.assets.length>0){let z=D.assets[0];console.log("Photo captured successfully:",z.uri);try{console.log("Starting camera image compression...");let L=Yo(z.width||1920,z.height||1920),k=await $o(z.uri,L);console.log("Camera image compression completed:",k),M?.({type:"image",data:{...k,originalFileSize:z.fileSize}})}catch(L){console.error("Camera image compression failed:",L),Q.alert("Compression Error","Failed to compress captured image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:z.uri,width:z.width,height:z.height,fileSize:z.fileSize,fileName:z.fileName||"camera_photo.jpg"}})}}else console.log("Camera capture was canceled by user")}catch(v){console.error("Error in camera capture process:",v),Q.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),S=Le(async()=>{console.log("Location sharing initiated");try{let v;try{v=await import("expo-location")}catch(k){console.log("expo-location not available:",k),Q.alert("Feature Not Available","Location sharing requires expo-location to be installed. Please install expo-location to use this feature.",[{text:"OK"}]);return}console.log("Requesting location permissions...");let{status:V}=await v.requestForegroundPermissionsAsync();if(console.log("Location permission status:",V),V!=="granted"){Q.alert("Permission needed","Please grant location access to share your location.");return}console.log("Getting current location...");let D=await v.getCurrentPositionAsync({accuracy:v.Accuracy.High});console.log("Getting address from coordinates...");let z=await v.reverseGeocodeAsync({latitude:D.coords.latitude,longitude:D.coords.longitude}),L={coordinates:{latitude:D.coords.latitude,longitude:D.coords.longitude},address:z[0]||null,timestamp:D.timestamp};console.log("Location shared successfully:",L.coordinates),M?.({type:"location",data:L})}catch(v){console.error("Error in location sharing process:",v),Q.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),A=Le(async()=>{try{let v;try{v=await import("expo-contacts")}catch(D){console.log("expo-contacts not available:",D),Q.alert("Feature Not Available","Contact sharing requires expo-contacts to be installed. Please install expo-contacts to use this feature.",[{text:"OK"}]);return}let{status:V}=await v.requestPermissionsAsync();if(V!=="granted"){Q.alert("Permission needed","Please grant contacts access to share contacts.");return}Q.alert("Contact Sharing","Contact selection feature is coming soon! This would open a contact picker.",[{text:"OK",onPress:()=>console.log("Contact sharing acknowledged")}])}catch(v){console.error("Error accessing contacts:",v),Q.alert("Error","Failed to access contacts. Please try again.")}finally{T.current?.hide()}},[]),I=Le(async()=>{console.log("Document selection initiated");try{let v;try{v=await import("expo-document-picker")}catch(D){console.log("expo-document-picker not available:",D),Q.alert("Feature Not Available","Document selection requires expo-document-picker to be installed. Please install expo-document-picker to use this feature.",[{text:"OK"}]);return}console.log("Waiting for UI to stabilize..."),await new Promise(D=>setTimeout(()=>D(void 0),300)),console.log("Launching document picker...");let V=await v.getDocumentAsync({type:"*/*",copyToCacheDirectory:!0,multiple:!1});if(console.log("Document picker result:",V),!V.canceled&&V.assets&&V.assets.length>0){let D=V.assets[0];console.log("Document selected successfully:",D.name),M?.({type:"document",data:{uri:D.uri,name:D.name,size:D.size,mimeType:D.mimeType}})}else console.log("Document selection was canceled by user")}catch(v){console.error("Error in document selection process:",v),Q.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[M]),P=Le(()=>{Q.alert("Create Poll","Poll creation feature is coming soon! This would open a poll creation interface.",[{text:"OK",onPress:()=>console.log("Poll creation acknowledged")}])},[]),B=Le(()=>{Q.alert("Create Event","Event creation feature is coming soon! This would open an event creation interface.",[{text:"OK",onPress:()=>console.log("Event creation acknowledged")}])},[]),E=Le(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await R();break;case"camera":await C();break;case"location":await S();break;case"contact":await A();break;case"document":await I();break;case"poll":P();break;case"event":B();break;default:console.warn(`Unknown attachment option: ${v}`)}}catch(V){console.error(`Error handling ${v}:`,V),Q.alert("Error",`Failed to handle ${v}. Please try again.`)}},[R,C,S,A,I,P,B]);return{menuRef:T,handleOptionSelect:E,options:ka}};import Ee,{useRef as La,useCallback as pe,createContext as Ea,useContext as hd}from"react";var kt=(M={})=>{let{initialValue:T="",initialHeight:R=50,onValueChange:C,onHeightChange:S,onSend:A,onAttachmentSend:I,onReplyCancel:P,onFocus:B,onBlur:E,maxHeight:v=100,minHeight:V=50,maxLength:D=1e3,placeholder:z="Type a message..."}=M,L=La(null),[k,O]=Ee.useState(T),[F,H]=Ee.useState(R),[N,j]=Ee.useState(!1),[J,ie]=Ee.useState(null),[Y,X]=Ee.useState([]),le=Ee.useMemo(()=>({value:k,height:F,isFocused:N,replyToMessage:J,attachments:Y}),[k,F,N,J,Y]),me=pe(oe=>{O(oe),C?.(oe)},[C]),re=pe(oe=>{let de=Math.max(V,Math.min(v,oe));H(de),S?.(de)},[V,v,S]),Z=pe(()=>{j(!0),B?.()},[B]),W=pe(()=>{j(!1),E?.()},[E]),ce=pe(oe=>{let{height:de}=oe.nativeEvent.contentSize,Tt=Math.max(V,Math.min(v,de+16));re(Tt)},[V,v,re]),ye=pe(()=>{A&&(k||Y.length>0)&&(A(k,Y,J),O(T),X([]),ie(null),H(R))},[A,k,Y,J,T,R]),he=pe(oe=>{I?(I(oe,k),k&&O(T)):X(de=>[...de,{...oe,id:Date.now().toString()}])},[I,k,T]),ne=pe(oe=>{X(de=>[...de,oe])},[]),ge=pe(oe=>{X(de=>de.filter(Tt=>Tt.id!==oe))},[]),xe=pe(()=>{X([])},[]),ee=pe(()=>{ie(null),P?.()},[P]),Se=pe(()=>{L.current?.focus()},[]),vo=Ee.useMemo(()=>({setValue:me,setHeight:re,setFocus:j,setReplyToMessage:ie,addAttachment:ne,removeAttachment:ge,clearAttachments:xe,sendMessage:ye,cancelReply:ee,focusInput:Se,handleAttachmentSelected:he,handleContentSizeChange:ce,handleFocus:Z,handleBlur:W}),[me,re,j,ie,ne,ge,xe,ye,ee,Se,he,ce,Z,W]),Po=Ee.useMemo(()=>({textInputRef:L}),[]);return{state:le,actions:vo,refs:Po}},yd=Ea(null);var we=ja(({value:M,onChangeText:T,onSend:R,onFocus:C,height:S,onContentSizeChange:A,replyToMessage:I,onCancelReply:P,onAttachmentSend:B},E)=>{let v=q(),V=Oa(null);Fa(E,()=>({focus:()=>{V.current?.focus()}}));let{state:D,actions:z}=kt({initialValue:M,initialHeight:S,onValueChange:T,onHeightChange:A,onSend:R,onAttachmentSend:B,onReplyCancel:P,onFocus:C});So.useEffect(()=>{M!==D.value&&z.setValue(M)},[M,D.value,z]),So.useEffect(()=>{S!==D.height&&z.setHeight(S)},[S,D.height,z]),So.useEffect(()=>{I!==D.replyToMessage&&z.setReplyToMessage(I||null)},[I,D.replyToMessage,z]),So.useEffect(()=>{if(I&&V.current){let O=setTimeout(()=>{V.current?.focus()},100);return()=>clearTimeout(O)}},[I]);let L=Ha(O=>{if(console.log("Attachment selected:",O),B)B(O,M.trim()||void 0),M.trim()&&T("");else switch(O.type){case"image":console.log("Image attachment ready to send:",{uri:O.data.uri,dimensions:{width:O.data.width,height:O.data.height},fileName:O.data.fileName});break;case"document":console.log("Document attachment ready to send:",{name:O.data.name,size:O.data.size});break;case"location":console.log("Location attachment ready to send:",O.data.coordinates);break;case"contact":console.log("Contact attachment ready to send:",O.data);break;default:console.log("Other attachment ready to send:",O)}},[B,M,T]),k=To(L);return<>
378
378
  {I&&P&&<Vt replyToMessage={I}onCancel={P}/>}
379
379
  <Go style={{borderTopWidth:1,borderTopColor:v.colors.borderLight,backgroundColor:v.colors.background}}>
380
- <Go style={{flexDirection:"row",alignItems:"center",backgroundColor:v.colors.background,paddingHorizontal:v.spacing.lg,paddingVertical:v.spacing.sm,minHeight:T}}>
380
+ <Go style={{flexDirection:"row",alignItems:"center",backgroundColor:v.colors.background,paddingHorizontal:v.spacing.lg,paddingVertical:v.spacing.sm,minHeight:S}}>
381
381
  <Ks style={{marginRight:v.spacing.md}}onPress={()=>k.menuRef.current?.show()}>
382
382
  <Wa size={24}color={v.colors.textSecondary}/>
383
383
  </Ks>
384
384
 
385
385
  <Go style={{flex:1,flexDirection:"row",alignItems:"center",borderRadius:v.borderRadius.full,backgroundColor:v.colors.surfaceSecondary,paddingHorizontal:v.spacing.lg,paddingVertical:6}}>
386
- <Na ref={V}style={{flex:1,fontSize:v.typography.fontSize.base,maxHeight:70,minHeight:18,paddingTop:qs.OS==="ios"?6:3,paddingBottom:qs.OS==="ios"?6:3,color:v.colors.text}}value={M}onChangeText={S}placeholder='Type a message...'placeholderTextColor={v.colors.textMuted}multiline maxLength={1e3}onFocus={R}onContentSizeChange={z.handleContentSizeChange}returnKeyType='default'textAlignVertical='center'/>
386
+ <Na ref={V}style={{flex:1,fontSize:v.typography.fontSize.base,maxHeight:70,minHeight:18,paddingTop:qs.OS==="ios"?6:3,paddingBottom:qs.OS==="ios"?6:3,color:v.colors.text}}value={M}onChangeText={T}placeholder='Type a message...'placeholderTextColor={v.colors.textMuted}multiline maxLength={1e3}onFocus={C}onContentSizeChange={z.handleContentSizeChange}returnKeyType='default'textAlignVertical='center'/>
387
387
  </Go>
388
388
 
389
- <Ks onPress={C}style={{marginLeft:v.spacing.md,height:40,width:40,alignItems:"center",justifyContent:"center",borderRadius:v.borderRadius.full,backgroundColor:M.trim()?v.colors.primary:v.colors.gray[300]}}disabled={!M.trim()}>
389
+ <Ks onPress={R}style={{marginLeft:v.spacing.md,height:40,width:40,alignItems:"center",justifyContent:"center",borderRadius:v.borderRadius.full,backgroundColor:M.trim()?v.colors.primary:v.colors.gray[300]}}disabled={!M.trim()}>
390
390
  {M.trim()?<Ua size={18}color='white'/>:<Ka size={18}color='white'/>}
391
391
  </Ks>
392
392
  </Go>
393
393
  </Go>
394
394
 
395
395
  <We ref={k.menuRef}onOptionSelect={k.handleOptionSelect}options={k.options}/>
396
- </>});we.displayName="MessageInput";import{View as Id,TextInput as Pd,TouchableOpacity as Ad,Platform as zd}from"react-native";import{Plus as Vd,Send as Dd,Mic as Ld}from"lucide-react-native";import Si,{forwardRef as Ti}from"react";import Xa,{createContext as Qa,useContext as Za,useMemo as ei}from"react";import{useMemo as $a,useCallback as Ya}from"react";function Lt(M,S={}){let{initialNumToRender:C=20,maxToRenderPerBatch:R=10,windowSize:T=10}=S,A=$a(()=>Vs(M).reverse(),[M]),I=Ya(P=>P.listItemType==="date-separator"?P.id:P.id.toString(),[]);return{messageItems:A,keyExtractor:I,flatListProps:{initialNumToRender:C,maxToRenderPerBatch:R,windowSize:T,inverted:!0,showsVerticalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",removeClippedSubviews:!1,scrollEventThrottle:16}}}import{useState as Ga,useCallback as Ue,useRef as $s}from"react";function _o(M={}){let{scrollThreshold:S=50,autoScrollToBottom:C=!0}=M,R=$s(null),[T,A]=Ga({isNearBottom:!0,isNearTop:!1,showScrollToBottomButton:!1}),I=$s(0),P=Ue(L=>{let{contentOffset:k,contentSize:O,layoutMeasurement:F}=L.nativeEvent,H=k.y,N=Math.abs(H)<S,E=Math.abs(H)>O.height-F.height-S;A({isNearBottom:N,isNearTop:E,showScrollToBottomButton:!N})},[S]),B=Ue(L=>{let k=L>I.current;return I.current=L,k},[]),j=Ue(()=>{},[]),v=Ue((L=!0)=>{R.current&&R.current.scrollToOffset({offset:0,animated:L})},[]),V=Ue((L,k=!0)=>{R.current&&R.current.scrollToOffset({offset:L,animated:k})},[]),D=Ue((L,k=!0)=>{R.current&&R.current.scrollToIndex({index:L,animated:k})},[]),z=Ue(L=>{B(L)&&C&&R.current&&setTimeout(()=>{v()},100)},[B,C,v]);return{flatListRef:R,scrollState:T,handleScroll:P,handleContentSizeChange:j,handleNewMessages:z,scrollToEnd:v,scrollToOffset:V,scrollToIndex:D}}import{useState as _a,useCallback as Jo}from"react";function Et(M={}){let{enableMessageActions:S=!0}=M,[C,R]=_a({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0}),T=Jo((P,B)=>{S&&R({actionSheetVisible:!0,selectedMessage:P,messagePosition:B})},[S]),A=Jo(()=>{R({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0})},[]),I=Jo((P,B)=>{if(!C.selectedMessage)return;let{selectedMessage:j}=C;switch(P){case"reply":B?.onReply?.(j);break;case"copy":if(B?.onCopy)B.onCopy(j);else{let v=j.type==="image"&&j.imageData?j.text||"Image message":j.text;import("./clipboard-O4FPD4J6.mjs").then(({copyToClipboard:V})=>{V(v)}).catch(()=>{console.log("Clipboard functionality not available")})}break;case"delete":B?.onDelete?.(j.id);break;default:B?.onCustomAction?.(P,j);break}A()},[C.selectedMessage,A]);return{actionState:C,handleMessageLongPress:T,handleActionSheetClose:A,handleActionPress:I}}import{useState as Ys,useCallback as jt}from"react";function Ot(M={}){let{enableReactionDetails:S=!0}=M,[C,R]=Ys({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),[T,A]=Ys(null),I=jt(V=>{S&&V.reactions&&V.reactions.length>0&&(A(V),R({isReactionDetailsVisible:!0,selectedReactions:V.reactions,selectedMessageText:V.text}))},[S]),P=jt(()=>{R({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),A(null)},[]),B=jt((V,D)=>{T&&D?.(T.id,V),P()},[T,P]),j=jt((V,D)=>{T&&D?.(T.id,V),P()},[T,P]),v=jt((V,D)=>{T&&D?.(T.id,V)},[T]);return{reactionState:C,selectedMessage:T,handleReactionPress:I,handleReactionDetailsClose:P,handleAddReaction:B,handleRemoveReaction:j,handleEmojiReact:v}}import{useState as Ja,useCallback as Gs}from"react";function Xo(){let[M,S]=Ja({replyToMessage:null}),C=Gs(T=>{S({replyToMessage:T})},[]),R=Gs(()=>{S({replyToMessage:null})},[]);return{replyState:M,setReplyToMessage:C,clearReply:R}}var _s=Qa(null);function Ct(){let M=Za(_s);if(!M)throw new Error("useMessageListContext must be used within MessageListProvider");return M}function Ft({children:M,messages:S,config:C={},...R}){let T=Lt(S,C),A=_o(C),I=Et(C),P=Ot(C),B=Xo();Xa.useEffect(()=>{A.handleNewMessages(S.length)},[S.length,A.handleNewMessages]);let j=ei(()=>({messageList:T,scroll:A,actions:I,reactions:P,reply:B,config:C,callbacks:R}),[T,A,I,P,B,C,R]);return<_s.Provider value={j}>
396
+ </>});we.displayName="MessageInput";import{View as Ad,TextInput as Bd,TouchableOpacity as Vd,Platform as Dd}from"react-native";import{Plus as Ld,Send as Ed,Mic as Od}from"lucide-react-native";import Ti,{forwardRef as Si}from"react";import Xa,{createContext as Qa,useContext as Za,useMemo as ei}from"react";import{useMemo as $a,useCallback as Ya}from"react";function Lt(M,T={}){let{initialNumToRender:R=20,maxToRenderPerBatch:C=10,windowSize:S=10}=T,A=$a(()=>Vs(M).reverse(),[M]),I=Ya(P=>P.listItemType==="date-separator"?P.id:P.id.toString(),[]);return{messageItems:A,keyExtractor:I,flatListProps:{initialNumToRender:R,maxToRenderPerBatch:C,windowSize:S,inverted:!0,showsVerticalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",removeClippedSubviews:!1,scrollEventThrottle:16}}}import{useState as Ga,useCallback as Ue,useRef as $s}from"react";function _o(M={}){let{scrollThreshold:T=50,autoScrollToBottom:R=!0}=M,C=$s(null),[S,A]=Ga({isNearBottom:!0,isNearTop:!1,showScrollToBottomButton:!1}),I=$s(0),P=Ue(L=>{let{contentOffset:k,contentSize:O,layoutMeasurement:F}=L.nativeEvent,H=k.y,N=Math.abs(H)<T,j=Math.abs(H)>O.height-F.height-T;A({isNearBottom:N,isNearTop:j,showScrollToBottomButton:!N})},[T]),B=Ue(L=>{let k=L>I.current;return I.current=L,k},[]),E=Ue(()=>{},[]),v=Ue((L=!0)=>{C.current&&C.current.scrollToOffset({offset:0,animated:L})},[]),V=Ue((L,k=!0)=>{C.current&&C.current.scrollToOffset({offset:L,animated:k})},[]),D=Ue((L,k=!0)=>{C.current&&C.current.scrollToIndex({index:L,animated:k})},[]),z=Ue(L=>{B(L)&&R&&C.current&&setTimeout(()=>{v()},100)},[B,R,v]);return{flatListRef:C,scrollState:S,handleScroll:P,handleContentSizeChange:E,handleNewMessages:z,scrollToEnd:v,scrollToOffset:V,scrollToIndex:D}}import{useState as _a,useCallback as Jo}from"react";function Et(M={}){let{enableMessageActions:T=!0}=M,[R,C]=_a({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0}),S=Jo((P,B)=>{T&&C({actionSheetVisible:!0,selectedMessage:P,messagePosition:B})},[T]),A=Jo(()=>{C({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0})},[]),I=Jo((P,B)=>{if(!R.selectedMessage)return;let{selectedMessage:E}=R;switch(P){case"reply":B?.onReply?.(E);break;case"copy":if(B?.onCopy)B.onCopy(E);else{let v=E.type==="image"&&E.imageData?E.text||"Image message":E.text;import("./clipboard-O4FPD4J6.mjs").then(({copyToClipboard:V})=>{V(v)}).catch(()=>{console.log("Clipboard functionality not available")})}break;case"delete":B?.onDelete?.(E.id);break;default:B?.onCustomAction?.(P,E);break}A()},[R.selectedMessage,A]);return{actionState:R,handleMessageLongPress:S,handleActionSheetClose:A,handleActionPress:I}}import{useState as Ys,useCallback as jt}from"react";function Ot(M={}){let{enableReactionDetails:T=!0}=M,[R,C]=Ys({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),[S,A]=Ys(null),I=jt(V=>{T&&V.reactions&&V.reactions.length>0&&(A(V),C({isReactionDetailsVisible:!0,selectedReactions:V.reactions,selectedMessageText:V.text}))},[T]),P=jt(()=>{C({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),A(null)},[]),B=jt((V,D)=>{S&&D?.(S.id,V),P()},[S,P]),E=jt((V,D)=>{S&&D?.(S.id,V),P()},[S,P]),v=jt((V,D)=>{S&&D?.(S.id,V)},[S]);return{reactionState:R,selectedMessage:S,handleReactionPress:I,handleReactionDetailsClose:P,handleAddReaction:B,handleRemoveReaction:E,handleEmojiReact:v}}import{useState as Ja,useCallback as Gs}from"react";function Xo(){let[M,T]=Ja({replyToMessage:null}),R=Gs(S=>{T({replyToMessage:S})},[]),C=Gs(()=>{T({replyToMessage:null})},[]);return{replyState:M,setReplyToMessage:R,clearReply:C}}var _s=Qa(null);function Ct(){let M=Za(_s);if(!M)throw new Error("useMessageListContext must be used within MessageListProvider");return M}function Ft({children:M,messages:T,config:R={},...C}){let S=Lt(T,R),A=_o(R),I=Et(R),P=Ot(R),B=Xo();Xa.useEffect(()=>{A.handleNewMessages(T.length)},[T.length,A.handleNewMessages]);let E=ei(()=>({messageList:S,scroll:A,actions:I,reactions:P,reply:B,config:R,callbacks:C}),[S,A,I,P,B,R,C]);return<_s.Provider value={E}>
397
397
  {M}
398
- </_s.Provider>}import{useCallback as wo}from"react";import{View as Mi,StyleSheet as Ci,FlatList as Ri}from"react-native";var je={Provider:Ft,Container:({children:M,style:S})=><Mi style={[Js.container,S]}>{M}</Mi>,Messages:({renderMessage:M,style:S})=>{let{messageList:C,scroll:R,actions:T,reactions:A,callbacks:I}=Ct(),P=wo(({item:j,index:v})=>M&&j.listItemType!=="date-separator"?M({message:j,index:v})||null:j.listItemType==="date-separator"?<Ro date={j.date}displayDate={j.displayDate}/>:<Xt message={j}onLongPress={T.handleMessageLongPress}onReactionPress={A.handleReactionPress}onReactionRemove={I.onReactionRemove}/>,[T.handleMessageLongPress,A.handleReactionPress,I.onReactionRemove,M]),B=wo(j=>{R.handleScroll(j);let{isNearBottom:v,isNearTop:V}=R.scrollState;I.onScrollPositionChange?.(v,V),v&&I.onScrollToBottom?.(),V&&I.onScrollToTop?.()},[R.handleScroll,R.scrollState,I]);return<Ri ref={R.flatListRef}data={C.messageItems}renderItem={P}keyExtractor={C.keyExtractor}contentContainerStyle={[Js.contentContainer,S]}onContentSizeChange={R.handleContentSizeChange}onScroll={B}{...C.flatListProps}/>},TypingIndicator:({isVisible:M})=>M?<Mt isVisible={M}/>:null,ScrollButton:({visible:M,isReplyActive:S,onPress:C})=>{let{scroll:R}=Ct();return<Co visible={M??R.scrollState.showScrollToBottomButton}onPress={C??R.scrollToEnd}isReplyActive={S}/>},ActionSheet:()=>{let{actions:M,reactions:S,reply:C,callbacks:R,config:T}=Ct(),A=wo(P=>{M.handleActionPress(P,{onReply:B=>{C.setReplyToMessage(B),R.onReplyMessage?.(B)},onDelete:R.onMessageDelete,onCustomAction:R.onActionPress})},[M.handleActionPress,C.setReplyToMessage,R]),I=wo(P=>{console.log("\u{1F525} MessageListCompound - handleEmojiReact called with emoji:",P);let B=M.actionState.selectedMessage;console.log("\u{1F525} MessageListCompound - selectedMessage:",B?.id,"callbacks.onReactionAdd exists:",!!R.onReactionAdd),B&&R.onReactionAdd?(console.log("\u{1F525} MessageListCompound - Calling onReactionAdd for message:",B.id,"emoji:",P),R.onReactionAdd(B.id,P)):console.log("\u{1F525} MessageListCompound - NOT calling onReactionAdd. selectedMessage:",!!B,"callback exists:",!!R.onReactionAdd)},[M.actionState.selectedMessage,R.onReactionAdd]);return T.enableMessageActions?<Qt visible={M.actionState.actionSheetVisible}onClose={M.handleActionSheetClose}isMyMessage={M.actionState.selectedMessage?.isMe||!1}selectedMessage={M.actionState.selectedMessage||void 0}messagePosition={M.actionState.messagePosition}onActionPress={A}onEmojiReact={I}/>:null},ReactionDetails:()=>{let{reactions:M,callbacks:S,config:C}=Ct();return C.enableReactionDetails?<Zt visible={M.reactionState.isReactionDetailsVisible}onClose={M.handleReactionDetailsClose}reactions={M.reactionState.selectedReactions}messageText={M.reactionState.selectedMessageText}onRemoveReaction={R=>M.handleRemoveReaction(R,S.onReactionRemove)}/>:null}},Js=Ci.create({container:{flex:1},contentContainer:{paddingVertical:16}});var Ie=Ti(({messages:M,isTyping:S,showScrollToBottom:C=!1,isReplyActive:R=!1,...T},A)=>{let I={scrollThreshold:T.scrollThreshold,autoScrollToBottom:T.autoScrollToBottom,enableMessageActions:T.enableMessageActions,enableReactionDetails:T.enableReactionDetails},P={onScrollToBottom:T.onScrollToBottom,onScrollToTop:T.onScrollToTop,onScrollPositionChange:T.onScrollPositionChange,onReactionAdd:T.onReactionAdd,onReactionRemove:T.onReactionRemove,onMessageDelete:T.onMessageDelete,onReplyMessage:T.onReplyMessage,onActionPress:T.onActionPress};return Si.useImperativeHandle(A,()=>({scrollToEnd:(B=!0)=>{},scrollToOffset:(B,j=!0)=>{},scrollToIndex:(B,j=!0)=>{}}),[]),<Ft messages={M}config={I}{...P}>
398
+ </_s.Provider>}import{useCallback as wo}from"react";import{View as Mi,StyleSheet as Ci,FlatList as Ri}from"react-native";var je={Provider:Ft,Container:({children:M,style:T})=><Mi style={[Js.container,T]}>{M}</Mi>,Messages:({renderMessage:M,style:T})=>{let{messageList:R,scroll:C,actions:S,reactions:A,callbacks:I}=Ct(),P=wo(({item:E,index:v})=>M&&E.listItemType!=="date-separator"?M({message:E,index:v})||null:E.listItemType==="date-separator"?<Ro date={E.date}displayDate={E.displayDate}/>:<Xt message={E}onLongPress={S.handleMessageLongPress}onReactionPress={A.handleReactionPress}onReactionRemove={I.onReactionRemove}/>,[S.handleMessageLongPress,A.handleReactionPress,I.onReactionRemove,M]),B=wo(E=>{C.handleScroll(E);let{isNearBottom:v,isNearTop:V}=C.scrollState;I.onScrollPositionChange?.(v,V),v&&I.onScrollToBottom?.(),V&&I.onScrollToTop?.()},[C.handleScroll,C.scrollState,I]);return<Ri ref={C.flatListRef}data={R.messageItems}renderItem={P}keyExtractor={R.keyExtractor}contentContainerStyle={[Js.contentContainer,T]}onContentSizeChange={C.handleContentSizeChange}onScroll={B}{...R.flatListProps}/>},TypingIndicator:({isVisible:M})=>M?<Mt isVisible={M}/>:null,ScrollButton:({visible:M,isReplyActive:T,onPress:R})=>{let{scroll:C}=Ct();return<Co visible={M??C.scrollState.showScrollToBottomButton}onPress={R??C.scrollToEnd}isReplyActive={T}/>},ActionSheet:()=>{let{actions:M,reactions:T,reply:R,callbacks:C,config:S}=Ct(),A=wo(P=>{M.handleActionPress(P,{onReply:B=>{R.setReplyToMessage(B),C.onReplyMessage?.(B)},onDelete:C.onMessageDelete,onCustomAction:C.onActionPress})},[M.handleActionPress,R.setReplyToMessage,C]),I=wo(P=>{console.log("\u{1F525} MessageListCompound - handleEmojiReact called with emoji:",P);let B=M.actionState.selectedMessage;console.log("\u{1F525} MessageListCompound - selectedMessage:",B?.id,"callbacks.onReactionAdd exists:",!!C.onReactionAdd),B&&C.onReactionAdd?(console.log("\u{1F525} MessageListCompound - Calling onReactionAdd for message:",B.id,"emoji:",P),C.onReactionAdd(B.id,P)):console.log("\u{1F525} MessageListCompound - NOT calling onReactionAdd. selectedMessage:",!!B,"callback exists:",!!C.onReactionAdd)},[M.actionState.selectedMessage,C.onReactionAdd]);return S.enableMessageActions?<Qt visible={M.actionState.actionSheetVisible}onClose={M.handleActionSheetClose}isMyMessage={M.actionState.selectedMessage?.isMe||!1}selectedMessage={M.actionState.selectedMessage||void 0}messagePosition={M.actionState.messagePosition}onActionPress={A}onEmojiReact={I}/>:null},ReactionDetails:()=>{let{reactions:M,callbacks:T,config:R}=Ct();return R.enableReactionDetails?<Zt visible={M.reactionState.isReactionDetailsVisible}onClose={M.handleReactionDetailsClose}reactions={M.reactionState.selectedReactions}messageText={M.reactionState.selectedMessageText}onRemoveReaction={C=>M.handleRemoveReaction(C,T.onReactionRemove)}/>:null}},Js=Ci.create({container:{flex:1},contentContainer:{paddingVertical:16}});var Ie=Si(({messages:M,isTyping:T,showScrollToBottom:R=!1,isReplyActive:C=!1,...S},A)=>{let I={scrollThreshold:S.scrollThreshold,autoScrollToBottom:S.autoScrollToBottom,enableMessageActions:S.enableMessageActions,enableReactionDetails:S.enableReactionDetails},P={onScrollToBottom:S.onScrollToBottom,onScrollToTop:S.onScrollToTop,onScrollPositionChange:S.onScrollPositionChange,onReactionAdd:S.onReactionAdd,onReactionRemove:S.onReactionRemove,onMessageDelete:S.onMessageDelete,onReplyMessage:S.onReplyMessage,onActionPress:S.onActionPress};return Ti.useImperativeHandle(A,()=>({scrollToEnd:(B=!0)=>{},scrollToOffset:(B,E=!0)=>{},scrollToIndex:(B,E=!0)=>{}}),[]),<Ft messages={M}config={I}{...P}>
399
399
  <je.Container>
400
400
  <je.Messages/>
401
- <je.TypingIndicator isVisible={S}/>
402
- <je.ScrollButton visible={C?void 0:!1}isReplyActive={R}/>
401
+ <je.TypingIndicator isVisible={T}/>
402
+ <je.ScrollButton visible={R?void 0:!1}isReplyActive={C}/>
403
403
  <je.ActionSheet/>
404
404
  <je.ReactionDetails/>
405
405
  </je.Container>
406
- </Ft>});Ie.displayName="MessageList";import wi from"react";function ae(M){let S=wi.forwardRef((R,T)=>(qe(),<M{...R}ref={T}/>)),C=M.displayName||M.name||"Component";return S.displayName=`RequireAuth(${C})`,S}function be(M){return(...S)=>(qe(),M(...S))}import{FlatList as Bi,RefreshControl as Vi}from"react-native";import{View as Nt,Text as Io,TouchableOpacity as Pi}from"react-native";import{View as Xs,Image as Ii}from"react-native";var vi=({avatar:M,isOnline:S=!1,size:C="medium"})=>{let R=q(),T=()=>{switch(C){case"small":return{width:32,height:32};case"large":return{width:64,height:64};default:return{width:48,height:48}}},A=()=>{switch(C){case"small":return{width:12,height:12};case"large":return{width:24,height:24};default:return{width:16,height:16}}},I=T(),P=A();return<Xs style={{position:"relative"}}>
407
- <Ii source={{uri:M}}style={[I,{borderRadius:R.borderRadius.full}]}resizeMode="cover"/>
406
+ </Ft>});Ie.displayName="MessageList";import wi from"react";function ae(M){let T=wi.forwardRef((C,S)=>(qe(),<M{...C}ref={S}/>)),R=M.displayName||M.name||"Component";return T.displayName=`RequireAuth(${R})`,T}function be(M){return(...T)=>(qe(),M(...T))}import{FlatList as Di,RefreshControl as Li}from"react-native";import{View as Nt,Text as Io,TouchableOpacity as Bi}from"react-native";import{View as Qo,Image as Ii,Text as Pi}from"react-native";var Ai=({avatar:M,isOnline:T=!1,size:R="medium"})=>{let C=q(),S=()=>{switch(R){case"small":return{width:32,height:32};case"large":return{width:64,height:64};default:return{width:48,height:48}}},A=()=>{switch(R){case"small":return{width:12,height:12};case"large":return{width:24,height:24};default:return{width:16,height:16}}},I=S(),P=A(),E=(()=>{switch(R){case"small":return 14;case"large":return 28;default:return 20}})();return<Qo style={{position:"relative"}}>
407
+ {M&&M.trim()!==""?<Ii source={{uri:M}}style={[I,{borderRadius:C.borderRadius.full}]}resizeMode="cover"/>:<Qo style={[I,{borderRadius:C.borderRadius.full,backgroundColor:C.colors.primary,justifyContent:"center",alignItems:"center"}]}>
408
+ <Pi style={{color:C.colors.background,fontSize:E,fontWeight:"600"}}>
409
+ 👤
410
+ </Pi>
411
+ </Qo>}
408
412
 
409
413
  {}
410
- {S&&<Xs style={[P,{position:"absolute",bottom:-2,right:-2,backgroundColor:R.colors.online,borderRadius:R.borderRadius.full,borderWidth:2,borderColor:R.colors.background}]}/>}
411
- </Xs>},Ht=vi;var Ai=({item:M,onPress:S})=>{let C=q(),R=M.unreadCount&&M.unreadCount>0;return<Pi style={{flexDirection:"row",alignItems:"center",paddingHorizontal:C.spacing.lg,paddingVertical:C.spacing.md,borderBottomWidth:1,borderBottomColor:C.colors.borderLight,backgroundColor:R?C.colors.unread:C.colors.background}}onPress={()=>S(M)}>
412
- <Nt style={{marginRight:C.spacing.md}}>
414
+ {T&&<Qo style={[P,{position:"absolute",bottom:-2,right:-2,backgroundColor:C.colors.online,borderRadius:C.borderRadius.full,borderWidth:2,borderColor:C.colors.background}]}/>}
415
+ </Qo>},Ht=Ai;var Vi=({item:M,onPress:T})=>{let R=q(),C=M.unreadCount&&M.unreadCount>0;return<Bi style={{flexDirection:"row",alignItems:"center",paddingHorizontal:R.spacing.lg,paddingVertical:R.spacing.md,borderBottomWidth:1,borderBottomColor:R.colors.borderLight,backgroundColor:C?R.colors.unread:R.colors.background}}onPress={()=>T(M)}>
416
+ <Nt style={{marginRight:R.spacing.md}}>
413
417
  <Ht avatar={M.avatar}isOnline={M.isOnline}size="medium"/>
414
418
  </Nt>
415
419
 
416
- <Nt style={{flex:1,marginRight:C.spacing.md}}>
420
+ <Nt style={{flex:1,marginRight:R.spacing.md}}>
417
421
  {}
418
- <Nt style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:C.spacing.xs}}>
419
- <Io style={{fontSize:C.typography.fontSize.base,flex:1,fontWeight:R?C.typography.fontWeight.bold:C.typography.fontWeight.semibold,color:C.colors.text}}>
422
+ <Nt style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:R.spacing.xs}}>
423
+ <Io style={{fontSize:R.typography.fontSize.base,flex:1,fontWeight:C?R.typography.fontWeight.bold:R.typography.fontWeight.semibold,color:R.colors.text}}>
420
424
  {M.name}
421
425
  </Io>
422
- <Io style={{fontSize:C.typography.fontSize.sm,marginLeft:C.spacing.sm,color:R?C.colors.gray[700]:C.colors.textSecondary,fontWeight:R?C.typography.fontWeight.medium:C.typography.fontWeight.normal}}>
426
+ <Io style={{fontSize:R.typography.fontSize.sm,marginLeft:R.spacing.sm,color:C?R.colors.gray[700]:R.colors.textSecondary,fontWeight:C?R.typography.fontWeight.medium:R.typography.fontWeight.normal}}>
423
427
  {M.time}
424
428
  </Io>
425
429
  </Nt>
426
430
 
427
431
  {}
428
432
  <Nt style={{flexDirection:"row",alignItems:"center"}}>
429
- <Io style={{fontSize:C.typography.fontSize.sm,flex:1,color:R?C.colors.gray[800]:C.colors.textSecondary,fontWeight:R?C.typography.fontWeight.medium:C.typography.fontWeight.normal}}numberOfLines={1}>
433
+ <Io style={{fontSize:R.typography.fontSize.sm,flex:1,color:C?R.colors.gray[800]:R.colors.textSecondary,fontWeight:C?R.typography.fontWeight.medium:R.typography.fontWeight.normal}}numberOfLines={1}>
430
434
  {M.message}
431
435
  </Io>
432
- {M.unreadCount&&<Nt style={{width:20,height:20,backgroundColor:C.colors.primary,borderRadius:C.borderRadius.full,alignItems:"center",justifyContent:"center",marginLeft:C.spacing.sm}}>
433
- <Io style={{fontSize:C.typography.fontSize.xs,color:"white",fontWeight:C.typography.fontWeight.bold}}>
436
+ {M.unreadCount&&<Nt style={{width:20,height:20,backgroundColor:R.colors.primary,borderRadius:R.borderRadius.full,alignItems:"center",justifyContent:"center",marginLeft:R.spacing.sm}}>
437
+ <Io style={{fontSize:R.typography.fontSize.xs,color:"white",fontWeight:R.typography.fontWeight.bold}}>
434
438
  {M.unreadCount}
435
439
  </Io>
436
440
  </Nt>}
437
441
  </Nt>
438
442
  </Nt>
439
- </Pi>},Wt=Ai;var Di=({chats:M,onChatPress:S,onRefresh:C,refreshing:R=!1})=>{let T=({item:A})=><Wt item={A}onPress={S}/>;return<Bi data={M}renderItem={T}keyExtractor={A=>A.id}showsVerticalScrollIndicator={!1}style={{flex:1}}refreshControl={C?<Vi refreshing={R}onRefresh={C}tintColor="#007AFF"colors={["#007AFF"]}/>:void 0}/>},Qo=Di;import{View as Li,Text as Ei}from"react-native";var ji=({title:M})=>{let S=q();return<Li style={{backgroundColor:S.colors.background,paddingHorizontal:S.spacing.lg,paddingVertical:S.spacing.lg,borderBottomWidth:1,borderBottomColor:S.colors.borderLight}}>
440
- <Ei style={{fontSize:S.typography.fontSize.xxl,fontWeight:S.typography.fontWeight.bold,color:S.colors.text}}>
443
+ </Bi>},Wt=Vi;var Ei=({chats:M,onChatPress:T,onRefresh:R,refreshing:C=!1})=>{let S=({item:A})=><Wt item={A}onPress={T}/>;return<Di data={M}renderItem={S}keyExtractor={A=>A.id}showsVerticalScrollIndicator={!1}style={{flex:1}}refreshControl={R?<Li refreshing={C}onRefresh={R}tintColor="#007AFF"colors={["#007AFF"]}/>:void 0}/>},Zo=Ei;import{View as Oi,Text as Fi}from"react-native";var Hi=({title:M})=>{let T=q();return<Oi style={{backgroundColor:T.colors.background,paddingHorizontal:T.spacing.lg,paddingVertical:T.spacing.lg,borderBottomWidth:1,borderBottomColor:T.colors.borderLight}}>
444
+ <Fi style={{fontSize:T.typography.fontSize.xxl,fontWeight:T.typography.fontWeight.bold,color:T.colors.text}}>
441
445
  {M}
442
- </Ei>
443
- </Li>},Zo=ji;import{View as Ms,TextInput as Oi,TouchableOpacity as Fi}from"react-native";import{Search as Hi,X as Ni}from"lucide-react-native";var Wi=({value:M,onChangeText:S,onClear:C,placeholder:R="Search chats..."})=>{let T=q();return<Ms style={{backgroundColor:T.colors.background,paddingHorizontal:T.spacing.lg,paddingVertical:T.spacing.md,borderBottomWidth:1,borderBottomColor:T.colors.borderLight}}>
446
+ </Fi>
447
+ </Oi>},es=Hi;import{View as Ms,TextInput as Ni,TouchableOpacity as Wi}from"react-native";import{Search as Ui,X as Ki}from"lucide-react-native";var qi=({value:M,onChangeText:T,onClear:R,placeholder:C="Search chats..."})=>{let S=q();return<Ms style={{backgroundColor:S.colors.background,paddingHorizontal:S.spacing.lg,paddingVertical:S.spacing.md,borderBottomWidth:1,borderBottomColor:S.colors.borderLight}}>
444
448
  <Ms style={{position:"relative"}}>
445
- <Ms style={{position:"absolute",left:T.spacing.md,top:"50%",transform:[{translateY:-10}],zIndex:10}}>
446
- <Hi size={20}color={T.colors.textMuted}/>
449
+ <Ms style={{position:"absolute",left:S.spacing.md,top:"50%",transform:[{translateY:-10}],zIndex:10}}>
450
+ <Ui size={20}color={S.colors.textMuted}/>
447
451
  </Ms>
448
452
 
449
- <Oi value={M}onChangeText={S}placeholder={R}placeholderTextColor={T.colors.textMuted}style={{backgroundColor:T.colors.surfaceSecondary,borderRadius:T.borderRadius.full,paddingLeft:48,paddingRight:40,paddingVertical:T.spacing.md,color:T.colors.text,fontSize:T.typography.fontSize.base}}autoCapitalize="none"autoCorrect={!1}clearButtonMode="never"/>
453
+ <Ni value={M}onChangeText={T}placeholder={C}placeholderTextColor={S.colors.textMuted}style={{backgroundColor:S.colors.surfaceSecondary,borderRadius:S.borderRadius.full,paddingLeft:48,paddingRight:40,paddingVertical:S.spacing.md,color:S.colors.text,fontSize:S.typography.fontSize.base}}autoCapitalize="none"autoCorrect={!1}clearButtonMode="never"/>
450
454
 
451
- {M.length>0&&<Fi onPress={C}style={{position:"absolute",right:T.spacing.md,top:"50%",transform:[{translateY:-10}]}}hitSlop={{top:10,bottom:10,left:10,right:10}}>
452
- <Ni size={20}color={T.colors.textMuted}/>
453
- </Fi>}
455
+ {M.length>0&&<Wi onPress={R}style={{position:"absolute",right:S.spacing.md,top:"50%",transform:[{translateY:-10}]}}hitSlop={{top:10,bottom:10,left:10,right:10}}>
456
+ <Ki size={20}color={S.colors.textMuted}/>
457
+ </Wi>}
454
458
  </Ms>
455
- </Ms>},Cs=Wi;import{useState as Ui,useCallback as Rt}from"react";import Rs from"dayjs";var Ke=Rs(),Qs=Ke.subtract(1,"day"),Zs=Ke.subtract(2,"day"),er=Ke.subtract(3,"day"),Ki=[{id:1,text:"Hi! How are you?",isMe:!1,timestamp:er.hour(10).minute(30).toISOString(),senderName:"Anna"},{id:2,text:"Hey! Great, thanks! And you?",isMe:!0,timestamp:er.hour(10).minute(31).toISOString(),reactions:[{emoji:"\u2764\uFE0F",count:1,users:["anna"]}]},{id:3,text:"Good too! What are we doing tonight?",isMe:!1,timestamp:Zs.hour(14).minute(20).toISOString(),senderName:"Anna"},{id:4,text:"Maybe we could go to the movies?",isMe:!0,timestamp:Zs.hour(14).minute(25).toISOString(),reactions:[{emoji:"\u{1F44D}",count:2,users:["anna","me"]},{emoji:"\u{1F3AC}",count:1,users:["anna"]}]},{id:5,text:"Good idea! I'll check the showtimes",isMe:!1,timestamp:Qs.hour(9).minute(15).toISOString(),senderName:"Anna"},{id:6,text:"Great! What movies are you interested in?",isMe:!0,timestamp:Qs.hour(9).minute(20).toISOString()},{id:7,text:"Maybe something action or comedy?",isMe:!1,timestamp:Ke.hour(8).minute(30).toISOString(),senderName:"Anna",reactions:[{emoji:"\u{1F602}",count:1,users:["me"]},{emoji:"\u{1F3AD}",count:1,users:["anna"]}]},{id:8,text:"Sounds great! I'll check what's playing",isMe:!0,timestamp:Ke.hour(8).minute(35).toISOString()},{id:9,text:"Perfect! What time should we meet?",isMe:!1,timestamp:Ke.hour(9).minute(10).toISOString(),senderName:"Anna",replyTo:{id:8,text:"Sounds great! I'll check what's playing",senderName:void 0,isMe:!0,type:"text"}},{id:10,text:"How about 7:00 PM? The show is at 8:00 PM",isMe:!0,timestamp:Ke.hour(9).minute(15).toISOString(),reactions:[{emoji:"\u{1F44D}",count:1,users:["anna"]},{emoji:"\u23F0",count:1,users:["me"]}]}],Ss=M=>{let S=Ki.map(v=>v.isMe?v:{...v,senderName:M||v.senderName}),[C,R]=Ui(S),T=Rt((v,V)=>{if(console.log("sendMessage called with text:",v,"and replyTo:",V),!v.trim())return;let D={id:Date.now(),text:v.trim(),isMe:!0,timestamp:Rs().toISOString(),status:"sent",replyTo:V};R(z=>[...z,D]),setTimeout(()=>{R(z=>z.map(L=>L.id===D.id?{...L,status:"delivered"}:L))},1e3),setTimeout(()=>{R(z=>z.map(L=>L.id===D.id?{...L,status:"read"}:L))},3e3)},[]),A=Rt((v,V,D)=>{let z={id:Date.now(),text:V||"",isMe:!0,timestamp:Rs().toISOString(),status:"sent",type:"image",imageData:v,replyTo:D};R(L=>[...L,z]),setTimeout(()=>{R(L=>L.map(k=>k.id===z.id?{...k,status:"delivered"}:k))},1e3),setTimeout(()=>{R(L=>L.map(k=>k.id===z.id?{...k,status:"read"}:k))},3e3)},[]),I=Rt((v,V)=>{R(D=>D.map(z=>z.id===v?{...z,status:V}:z))},[]),P=Rt((v,V)=>{R(D=>D.map(z=>{if(z.id===v){let L=z.reactions||[],k=L.findIndex(O=>O.emoji===V);if(k>=0){let O=[...L];return O[k]={...O[k],count:O[k].count+1,users:[...O[k].users,"me"]},{...z,reactions:O}}else{let O={emoji:V,count:1,users:["me"]};return{...z,reactions:[...L,O]}}}return z}))},[]),B=Rt((v,V)=>{console.log("removeReaction 1212121 called with messageId:",v,"and emoji:",V),R(D=>D.map(z=>{if(z.id===v){let L=z.reactions||[],k=L.findIndex(O=>O.emoji===V);if(k>=0){let O=L[k];if(O.count>1){let F=[...L];return F[k]={...O,count:O.count-1,users:O.users.filter(H=>H!=="me")},{...z,reactions:F}}else return{...z,reactions:L.filter(F=>F.emoji!==V)}}}return z}))},[]),j=Rt(v=>{console.log("deleteMessage called with messageId:",v),R(V=>{let D=V.map(z=>z.id===v?{...z,deleted:!0}:z);return console.log("Message marked as deleted:",v),D})},[]);return{messages:C,sendMessage:T,sendImageMessage:A,updateMessageStatus:I,addReaction:P,deleteMessage:j,removeReaction:B}};import{useState as tr,useCallback as Se}from"react";var Ts=(M={})=>{qe();let[S,C]=tr(M.initialMessages||[]),[R,T]=tr(!1),A=Se((L,k)=>{let O={id:Date.now(),text:L,isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:k?{id:k.id,text:k.text,senderName:k.senderName,isMe:k.isMe}:void 0};C(F=>[O,...F])},[]),I=Se(L=>{C(k=>[L,...k])},[]),P=Se((L,k)=>{C(O=>O.map(F=>F.id===L?{...F,...k}:F))},[]),B=Se(L=>{C(k=>k.filter(O=>O.id!==L))},[]),j=Se((L,k)=>{C(O=>O.map(F=>{if(F.id!==L)return F;let H=F.reactions||[];if(H.find(E=>E.emoji===k))return{...F,reactions:H.map(E=>E.emoji===k?{...E,count:E.count+1,users:[...E.users,"current-user"]}:E)};{let E={emoji:k,count:1,users:["current-user"]};return{...F,reactions:[...H,E]}}}))},[]),v=Se((L,k)=>{C(O=>O.map(F=>{if(F.id!==L)return F;let H=F.reactions||[],N=H.find(E=>E.emoji===k);return N?N.count<=1?{...F,reactions:H.filter(E=>E.emoji!==k)}:{...F,reactions:H.map(E=>E.emoji===k?{...E,count:E.count-1,users:E.users.filter(J=>J!=="current-user")}:E)}:F}))},[]),V=Se(L=>{T(L)},[]),D=Se(()=>{C(M.initialMessages||[]),T(!1)},[M.initialMessages]),z=Se(L=>S.find(k=>k.id===L),[S]);return{messages:S,isTyping:R,sendMessage:A,addReaction:j,removeReaction:v,setMessages:C,addMessage:I,updateMessage:P,deleteMessage:B,setTyping:V,resetChat:D,getMessageById:z}};import{useState as wm,useCallback as Im,useRef as vm,useEffect as Pm}from"react";var Xm=ae(Do),Qm=ae(Ao),Zm=be(Tt),tg=ae(Ie),og=ae(we),rg=ae(Kt),ag=ae(Mt),lg=ae(Qo),cg=ae(Wt),dg=ae(Zo),ug=ae(Cs),pg=ae(Ht),hg=ae(We),xg=ae(Bs),bg=be(q),Tg=be(Ts),wg=be(Ss),Ig=be(Lt),vg=be(Et),Pg=be(Ot),Ag=be(It),Bg=be(kt);export{hg as AttachmentMenu,Xm as Chat,pg as ChatAvatar,dg as ChatHeader,cg as ChatItem,lg as ChatList,ug as ChatListSearchBar,Qm as ChatProvider,rg as ChatScreenHeader,og as MessageInput,tg as MessageList,xg as ThemeProvider,ag as TypingIndicator,vt as defaultTheme,or as getAuthState,sr as getProjectId,nr as initChat,rr as isInitialized,Ag as useAttachments,Zm as useChatConfig,wg as useChatMessages,Tg as useChatSDK,vg as useMessageActions,Bg as useMessageInput,Ig as useMessageList,Pg as useMessageReactions,bg as useTheme};
459
+ </Ms>},Cs=qi;import{useState as $i,useCallback as Rt}from"react";import Rs from"dayjs";var Ke=Rs(),Xs=Ke.subtract(1,"day"),Qs=Ke.subtract(2,"day"),Zs=Ke.subtract(3,"day"),Yi=[{id:1,text:"Hi! How are you?",isMe:!1,timestamp:Zs.hour(10).minute(30).toISOString(),senderName:"Anna"},{id:2,text:"Hey! Great, thanks! And you?",isMe:!0,timestamp:Zs.hour(10).minute(31).toISOString(),reactions:[{emoji:"\u2764\uFE0F",count:1,users:["anna"]}]},{id:3,text:"Good too! What are we doing tonight?",isMe:!1,timestamp:Qs.hour(14).minute(20).toISOString(),senderName:"Anna"},{id:4,text:"Maybe we could go to the movies?",isMe:!0,timestamp:Qs.hour(14).minute(25).toISOString(),reactions:[{emoji:"\u{1F44D}",count:2,users:["anna","me"]},{emoji:"\u{1F3AC}",count:1,users:["anna"]}]},{id:5,text:"Good idea! I'll check the showtimes",isMe:!1,timestamp:Xs.hour(9).minute(15).toISOString(),senderName:"Anna"},{id:6,text:"Great! What movies are you interested in?",isMe:!0,timestamp:Xs.hour(9).minute(20).toISOString()},{id:7,text:"Maybe something action or comedy?",isMe:!1,timestamp:Ke.hour(8).minute(30).toISOString(),senderName:"Anna",reactions:[{emoji:"\u{1F602}",count:1,users:["me"]},{emoji:"\u{1F3AD}",count:1,users:["anna"]}]},{id:8,text:"Sounds great! I'll check what's playing",isMe:!0,timestamp:Ke.hour(8).minute(35).toISOString()},{id:9,text:"Perfect! What time should we meet?",isMe:!1,timestamp:Ke.hour(9).minute(10).toISOString(),senderName:"Anna",replyTo:{id:8,text:"Sounds great! I'll check what's playing",senderName:void 0,isMe:!0,type:"text"}},{id:10,text:"How about 7:00 PM? The show is at 8:00 PM",isMe:!0,timestamp:Ke.hour(9).minute(15).toISOString(),reactions:[{emoji:"\u{1F44D}",count:1,users:["anna"]},{emoji:"\u23F0",count:1,users:["me"]}]}],Ts=M=>{let T=Yi.map(v=>v.isMe?v:{...v,senderName:M||v.senderName}),[R,C]=$i(T),S=Rt((v,V)=>{if(console.log("sendMessage called with text:",v,"and replyTo:",V),!v.trim())return;let D={id:Date.now(),text:v.trim(),isMe:!0,timestamp:Rs().toISOString(),status:"sent",replyTo:V};C(z=>[...z,D]),setTimeout(()=>{C(z=>z.map(L=>L.id===D.id?{...L,status:"delivered"}:L))},1e3),setTimeout(()=>{C(z=>z.map(L=>L.id===D.id?{...L,status:"read"}:L))},3e3)},[]),A=Rt((v,V,D)=>{let z={id:Date.now(),text:V||"",isMe:!0,timestamp:Rs().toISOString(),status:"sent",type:"image",imageData:v,replyTo:D};C(L=>[...L,z]),setTimeout(()=>{C(L=>L.map(k=>k.id===z.id?{...k,status:"delivered"}:k))},1e3),setTimeout(()=>{C(L=>L.map(k=>k.id===z.id?{...k,status:"read"}:k))},3e3)},[]),I=Rt((v,V)=>{C(D=>D.map(z=>z.id===v?{...z,status:V}:z))},[]),P=Rt((v,V)=>{C(D=>D.map(z=>{if(z.id===v){let L=z.reactions||[],k=L.findIndex(O=>O.emoji===V);if(k>=0){let O=[...L];return O[k]={...O[k],count:O[k].count+1,users:[...O[k].users,"me"]},{...z,reactions:O}}else{let O={emoji:V,count:1,users:["me"]};return{...z,reactions:[...L,O]}}}return z}))},[]),B=Rt((v,V)=>{console.log("removeReaction 1212121 called with messageId:",v,"and emoji:",V),C(D=>D.map(z=>{if(z.id===v){let L=z.reactions||[],k=L.findIndex(O=>O.emoji===V);if(k>=0){let O=L[k];if(O.count>1){let F=[...L];return F[k]={...O,count:O.count-1,users:O.users.filter(H=>H!=="me")},{...z,reactions:F}}else return{...z,reactions:L.filter(F=>F.emoji!==V)}}}return z}))},[]),E=Rt(v=>{console.log("deleteMessage called with messageId:",v),C(V=>{let D=V.map(z=>z.id===v?{...z,deleted:!0}:z);return console.log("Message marked as deleted:",v),D})},[]);return{messages:R,sendMessage:S,sendImageMessage:A,updateMessageStatus:I,addReaction:P,deleteMessage:E,removeReaction:B}};import{useState as er,useCallback as Te}from"react";var Ss=(M={})=>{qe();let[T,R]=er(M.initialMessages||[]),[C,S]=er(!1),A=Te((L,k)=>{let O={id:Date.now(),text:L,isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:k?{id:k.id,text:k.text,senderName:k.senderName,isMe:k.isMe}:void 0};R(F=>[O,...F])},[]),I=Te(L=>{R(k=>[L,...k])},[]),P=Te((L,k)=>{R(O=>O.map(F=>F.id===L?{...F,...k}:F))},[]),B=Te(L=>{R(k=>k.filter(O=>O.id!==L))},[]),E=Te((L,k)=>{R(O=>O.map(F=>{if(F.id!==L)return F;let H=F.reactions||[];if(H.find(j=>j.emoji===k))return{...F,reactions:H.map(j=>j.emoji===k?{...j,count:j.count+1,users:[...j.users,"current-user"]}:j)};{let j={emoji:k,count:1,users:["current-user"]};return{...F,reactions:[...H,j]}}}))},[]),v=Te((L,k)=>{R(O=>O.map(F=>{if(F.id!==L)return F;let H=F.reactions||[],N=H.find(j=>j.emoji===k);return N?N.count<=1?{...F,reactions:H.filter(j=>j.emoji!==k)}:{...F,reactions:H.map(j=>j.emoji===k?{...j,count:j.count-1,users:j.users.filter(J=>J!=="current-user")}:j)}:F}))},[]),V=Te(L=>{S(L)},[]),D=Te(()=>{R(M.initialMessages||[]),S(!1)},[M.initialMessages]),z=Te(L=>T.find(k=>k.id===L),[T]);return{messages:T,isTyping:C,sendMessage:A,addReaction:E,removeReaction:v,setMessages:R,addMessage:I,updateMessage:P,deleteMessage:B,setTyping:V,resetChat:D,getMessageById:z}};import{useState as Pm,useCallback as Am,useRef as zm,useEffect as Bm}from"react";var eg=ae(Do),tg=ae(Ao),og=be(St),rg=ae(Ie),ng=ae(we),ig=ae(Kt),cg=ae(Mt),ug=ae(Zo),mg=ae(Wt),gg=ae(es),pg=ae(Cs),yg=ae(Ht),xg=ae(We),Cg=ae(Bs),Rg=be(q),vg=be(Ss),Pg=be(Ts),Ag=be(Lt),zg=be(Et),Bg=be(Ot),Vg=be(It),kg=be(kt);export{xg as AttachmentMenu,eg as Chat,yg as ChatAvatar,gg as ChatHeader,mg as ChatItem,ug as ChatList,pg as ChatListSearchBar,tg as ChatProvider,ig as ChatScreenHeader,ng as MessageInput,rg as MessageList,Cg as ThemeProvider,cg as TypingIndicator,vt as defaultTheme,tr as getAuthState,or as getProjectId,rr as initChat,sr as isInitialized,Vg as useAttachments,og as useChatConfig,Pg as useChatMessages,vg as useChatSDK,zg as useMessageActions,kg as useMessageInput,Ag as useMessageList,Bg as useMessageReactions,Rg as useTheme};