@usechat/react-native 1.0.14 → 1.0.15
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.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +211 -211
- package/dist/index.mjs +334 -334
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var ke={isInitialized:!1,projectId:null,error:null},
|
|
2
|
+
var ke={isInitialized:!1,projectId:null,error:null},Ks=M=>{ke={isInitialized:!0,projectId:M,error:null}},Ze=M=>{ke={isInitialized:!1,projectId:null,error:M}};var Ka=()=>({...ke}),It=()=>{if(ke.error)throw new Error(`UseChat SDK initialization failed: ${ke.error}
|
|
3
3
|
|
|
4
4
|
Please call initChat() with a valid project ID before using any UseChat components or hooks.
|
|
5
5
|
|
|
@@ -11,453 +11,453 @@ 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' });`)}
|
|
15
|
-
{
|
|
16
|
-
</_o.Provider>},
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<
|
|
14
|
+
await initChat({ projectId: 'your-project-id' });`)},$a=()=>(It(),ke.projectId),qa=()=>ke.isInitialized&&!ke.error;var Ya=async M=>{let{projectId:R,apiUrl:C="http://localhost:3000/api/chat/init",debug:T=!1}=M;if(!R){let S="Project ID is required";throw Ze(S),new Error(S)}try{T&&console.log(`[UseChat SDK] Validating projectId: ${R}`);let S=await fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:R})});if(T&&console.log(`[Chat SDK] Response status: ${S.status}, ok: ${S.ok}`),!S.ok){let P=`HTTP ${S.status}: ${S.statusText}`;try{let z=await S.json();P=z.error||z.message||P}catch{try{let E=await S.text();E&&(P=`Server error: ${E}`)}catch{P=`Failed to initialize chat (HTTP ${S.status})`}}throw Ze(P),new Error(P)}let A;try{let P=await S.text();if(T&&console.log(`[Chat SDK] Response text: ${P}`),!P){let z="Server returned empty response";throw Ze(z),new Error(z)}A=JSON.parse(P)}catch(P){T&&console.error("[Chat SDK] JSON parse error:",P);let z="Server returned invalid JSON response";throw Ze(z),new Error(z)}if(!A||typeof A!="object"){let P="Server returned invalid response format";throw Ze(P),new Error(P)}let I=A;return T&&console.log(`[UseChat SDK] Successfully initialized with projectId: ${R}`),Ks(R),I}catch(S){T&&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")||Ze(A),new Error(A)}};import Js,{useState as Qo,useRef as Xs,useCallback as vt}from"react";import{View as Mt,StyleSheet as Sr}from"react-native";import{createContext as Za,useContext as Qa}from"react";import{StyleSheet as er}from"react-native";import{KeyboardProvider as Mr,KeyboardAvoidingView as Tr}from"react-native-keyboard-controller";import{createContext as Ja,useContext as qs,useState as Xa,useCallback as $s}from"react";var Ga={"input.placeholder":"Type a message...","search.placeholder":"Search chats...","status.online":"Online","status.offline":"Offline","status.typing":"typing...","message.deleted":"This message was deleted","message.sending":"Sending...","message.sent":"Sent","message.delivered":"Delivered","message.read":"Read","message.failed":"Failed to send","action.reply":"Reply","action.copy":"Copy","action.delete":"Delete","action.cancel":"Cancel","action.send":"Send","action.clear":"Clear","action.clearAll":"Clear All","attachment.add":"Add attachment","attachment.remove":"Remove","attachment.clear":"Clear","attachment.attachments":"Attachments:","accessibility.back":"Go back","accessibility.send":"Send message","accessibility.attach":"Add attachment","accessibility.emoji":"Add emoji","accessibility.videoCall":"Start video call","accessibility.voiceCall":"Start voice call","accessibility.info":"Chat info","accessibility.search":"Search chats","accessibility.typing":"Someone is typing","error.fileTooLarge":"File is too large","error.invalidFileType":"Invalid file type","error.maxAttachments":"Maximum attachments reached","error.networkError":"Network error occurred","time.justNow":"Just now","time.minutesAgo":"{{count}} min ago","time.hoursAgo":"{{count}}h ago","time.daysAgo":"{{count}}d ago","time.weeksAgo":"{{count}}w ago","time.monthsAgo":"{{count}}mo ago","time.yearsAgo":"{{count}}y ago","date.today":"Today","date.yesterday":"Yesterday","date.todayWithTime":"Today {{time}}","date.yesterdayWithTime":"Yesterday {{time}}"},_a={"input.placeholder":"Napisz wiadomo\u015B\u0107...","search.placeholder":"Szukaj czat\xF3w...","status.online":"Online","status.offline":"Offline","status.typing":"pisze...","message.deleted":"Ta wiadomo\u015B\u0107 zosta\u0142a usuni\u0119ta","message.sending":"Wysy\u0142anie...","message.sent":"Wys\u0142ano","message.delivered":"Dostarczono","message.read":"Przeczytano","message.failed":"Nie uda\u0142o si\u0119 wys\u0142a\u0107","action.reply":"Odpowiedz","action.copy":"Kopiuj","action.delete":"Usu\u0144","action.cancel":"Anuluj","action.send":"Wy\u015Blij","action.clear":"Wyczy\u015B\u0107","action.clearAll":"Wyczy\u015B\u0107 wszystko","attachment.add":"Dodaj za\u0142\u0105cznik","attachment.remove":"Usu\u0144","attachment.clear":"Wyczy\u015B\u0107","attachment.attachments":"Za\u0142\u0105czniki:","accessibility.back":"Wr\xF3\u0107","accessibility.send":"Wy\u015Blij wiadomo\u015B\u0107","accessibility.attach":"Dodaj za\u0142\u0105cznik","accessibility.emoji":"Dodaj emoji","accessibility.videoCall":"Rozpocznij wideorozmow\u0119","accessibility.voiceCall":"Rozpocznij rozmow\u0119 g\u0142osow\u0105","accessibility.info":"Informacje o czacie","accessibility.search":"Szukaj czat\xF3w","accessibility.typing":"Kto\u015B pisze","error.fileTooLarge":"Plik jest za du\u017Cy","error.invalidFileType":"Nieprawid\u0142owy typ pliku","error.maxAttachments":"Osi\u0105gni\u0119to maksymaln\u0105 liczb\u0119 za\u0142\u0105cznik\xF3w","error.networkError":"Wyst\u0105pi\u0142 b\u0142\u0105d sieci","time.justNow":"W\u0142a\u015Bnie teraz","time.minutesAgo":"{{count}} min temu","time.hoursAgo":"{{count}}h temu","time.daysAgo":"{{count}}d temu","time.weeksAgo":"{{count}}t temu","time.monthsAgo":"{{count}}mies temu","time.yearsAgo":"{{count}}l temu","date.today":"Dzisiaj","date.yesterday":"Wczoraj","date.todayWithTime":"Dzisiaj {{time}}","date.yesterdayWithTime":"Wczoraj {{time}}"},So={en:Ga,pl:_a},Ut=M=>So[M]||So.en,wo=M=>M==="en"||M==="pl";var _o=Ja(void 0),Io=({children:M,locale:R="en",fallbackLocale:C="en"})=>{let[T,S]=Xa(R),A=$s((z,E={})=>{let B=Ut(T)[z];return!B&&T!==C&&(B=Ut(C)[z]),B?B.replace(/\{\{(\w+)\}\}/g,(k,V)=>E[V]?.toString()||k):(console.warn(`Translation missing for key: ${z} in locale: ${T}`),z)},[T,C]),I=$s(z=>{wo(z)?S(z):(console.warn(`Unsupported locale: ${z}. Falling back to 'en'`),S("en"))},[]),P={t:A,locale:T,setLocale:I};return<_o.Provider value={P}>
|
|
15
|
+
{M}
|
|
16
|
+
</_o.Provider>},Ys=()=>{let M=qs(_o);if(!M)throw new Error("useTranslation must be used within an I18nProvider");return M},Ce=()=>{let M=qs(_o);return M?M.t:R=>R};var Gs=Za(null),Cr=({children:M,config:R={},locale:C="en"})=>{let T={keyboardBehavior:"padding",keyboardVerticalOffset:60,enableReactionDetails:!0,enableMessageActions:!0,enableScrollToBottom:!0,enableTypingIndicator:!0,...R};return<Io locale={C}>
|
|
17
|
+
<Gs.Provider value={{config:T}}>
|
|
18
|
+
<Mr>
|
|
19
|
+
<Tr behavior={T.keyboardBehavior}style={[Rr.keyboardContainer]}keyboardVerticalOffset={T.keyboardVerticalOffset}>
|
|
20
20
|
{}
|
|
21
|
-
{
|
|
22
|
-
</
|
|
23
|
-
</
|
|
24
|
-
</
|
|
25
|
-
</Io>},Jo=
|
|
26
|
-
{N||<
|
|
21
|
+
{M}
|
|
22
|
+
</Tr>
|
|
23
|
+
</Mr>
|
|
24
|
+
</Gs.Provider>
|
|
25
|
+
</Io>},Jo=Cr,Kt=()=>{let M=Qa(Gs);if(!M)throw new Error("useChatConfig must be used within a ChatProvider");return M.config},Rr=er.create({container:{flex:1},keyboardContainer:{flex:1,overflow:"hidden"}});import{useState as Xo,useCallback as $t}from"react";var qt=(M={})=>{let{uploader:R,maxAttachments:C=10,maxFileSize:T=10*1024*1024,allowedTypes:S=["image/*","application/pdf","text/*"],onAttachmentAdd:A,onAttachmentRemove:I,onAttachmentUpload:P}=M,[z,E]=Xo([]),[v,B]=Xo(!1),[k,V]=Xo(0),D=$t(N=>{if(z.length>=C){console.warn(`Maximum ${C} attachments allowed`);return}if(N.data?.size&&N.data.size>T){console.warn(`File size exceeds ${T/(1024*1024)}MB limit`);return}if(N.data?.type&&!S.some(ne=>ne.endsWith("/*")?N.data.type.startsWith(ne.slice(0,-1)):N.data.type===ne)){console.warn(`File type ${N.data.type} not allowed`);return}let F={...N,id:N.id||`att_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,uploadStatus:"pending",uploadProgress:0};E(_=>[..._,F]),A&&A(F)},[z.length,C,T,S,A]),L=$t(N=>{E(F=>F.filter(_=>_.id!==N)),I&&I(N)},[I]),O=$t(()=>{E([])},[]),j=$t(async N=>{try{let F;switch(N){case"image":F={type:"image",data:{uri:"mock-image-uri",width:800,height:600,fileName:"image.jpg",fileSize:1024*1024}};break;case"document":F={type:"document",data:{uri:"mock-document-uri",name:"document.pdf",size:2048*1024,mimeType:"application/pdf"}};break;case"location":F={type:"location",data:{coordinates:{latitude:0,longitude:0},address:"Mock Address",timestamp:Date.now()}};break;case"contact":F={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 _={id:`att_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,type:N,data:F.data,fileName:F.data.fileName||F.data.name,fileSize:F.data.fileSize||F.data.size,mimeType:F.data.mimeType,uploadStatus:"pending",uploadProgress:0};D(_)}catch(F){console.error("Error opening picker:",F)}},[D]),H=$t(async()=>{if(!R)return console.warn("No uploader provided, skipping upload"),z;if(z.length===0)return[];B(!0),V(0);try{let N=z.map(async(J,Me)=>{try{E(Ie=>Ie.map(W=>W.id===J.id?{...W,uploadStatus:"uploading",uploadProgress:0}:W));let Z=setInterval(()=>{E(Ie=>Ie.map(W=>W.id===J.id?{...W,uploadProgress:Math.min((W.uploadProgress??0)+10,90)}:W))},100),re=await R.upload(J.data);clearInterval(Z);let oe={...J,uploadStatus:"completed",uploadProgress:100,data:{...J.data,url:re.url,metadata:re.metadata}};return E(Ie=>Ie.map(W=>W.id===J.id?oe:W)),oe}catch(Z){return console.error(`Error uploading attachment ${J.id}:`,Z),E(re=>re.map(oe=>oe.id===J.id?{...oe,uploadStatus:"failed",uploadProgress:0}:oe)),{...J,uploadStatus:"failed",uploadProgress:0}}}),F=await Promise.all(N),ne=F.filter(J=>J.uploadStatus==="completed").length/F.length*100;return V(ne),P&&P(F),F}catch(N){return console.error("Error uploading attachments:",N),z}finally{B(!1)}},[z,R,P]);return{attachments:z,openPicker:j,addAttachment:D,removeAttachment:L,clearAttachments:O,uploadAttachments:H,isUploading:v,uploadProgress:k}};import{useState as Zo,useCallback as Qe}from"react";var _s=(M={})=>{let{onSend:R,onFocus:C,initialValue:T="",maxLength:S=1e3}=M,[A,I]=Zo(T),[P,z]=Zo(40),[E,v]=Zo(!1),B=Qe(H=>{H.length<=S&&I(H)},[S]),k=Qe(H=>{if(!A.trim()&&(!H||H.length===0))return;let N=A.trim();R&&R(N,H),I(""),z(40)},[A,R]),V=Qe(()=>{v(!0),C&&C()},[C]),D=Qe(()=>{v(!1)},[]),L=Qe(H=>{z(Math.max(40,Math.min(H,120)))},[]),O=Qe(()=>{I(""),z(40)},[]),j=Qe(H=>{I(H)},[]);return{message:A,composerHeight:P,isFocused:E,handleTextChange:B,handleSend:k,handleFocus:V,handleBlur:D,handleContentSizeChange:L,clearMessage:O,setMessage:j}};var wr=({messages:M,components:R={},renderProps:C={},onMessageSend:T,onReactionAdd:S,onReactionRemove:A,onMessageDelete:I,onActionPress:P,attachmentUploader:z,maxAttachments:E=10,maxFileSize:v=10*1024*1024,allowedFileTypes:B=["image/*","application/pdf","text/*"],enableReactionDetails:k,enableMessageActions:V=!0,enableScrollToBottom:D,enableTypingIndicator:L,isTyping:O=!1,typingUserName:j,isLoading:H=!1,loadingComponent:N})=>{let F=Kt(),[_,ne]=Qo(!1),J=R.MessageList||He,Me=R.MessageInput||Oe,Z=k??F.enableReactionDetails??!0,re=V??F.enableMessageActions??!0,oe=D??F.enableScrollToBottom??!0,Ie=L??F.enableTypingIndicator??!0,[W,ve]=Qo(null),Te=Xs(null),[Je,Q]=Qo(M||[]),Pe=Xs((M||[]).length+1);Js.useEffect(()=>{M&&(Q(M),Pe.current=M.length+1)},[M]),Js.useEffect(()=>{if(W&&Te.current){let U=setTimeout(()=>{Te.current?.focus()},150);return()=>clearTimeout(U)}},[W]);let ze=qt({uploader:z,maxAttachments:E,maxFileSize:v,allowedTypes:B}),ee=_s({onSend:(U,q)=>{if(W){let Y={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(q&&q.length>0){let K=q[0],te={id:Pe.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:Y,attachments:q,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}}};Q(Ve=>[...Ve,te]),T&&T(te)}else{let K={id:Pe.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:Y};Q(te=>[...te,K]),T&&T(K)}ve(null)}else if(q&&q.length>0){let Y=q[0],K={id:Pe.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",attachments:q,type:Y.type==="image"?"image":"text",...Y.type==="image"&&Y.data&&{imageData:{uri:Y.data.uri||"",width:Y.data.width||300,height:Y.data.height||200,fileName:Y.fileName||"image.jpg",fileSize:Y.fileSize||0}}};Q(te=>[...te,K]),T&&T(K)}else{let Y={id:Pe.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent"};Q(K=>[...K,Y]),T&&T(Y)}ze.clearAttachments()},onFocus:()=>{}}),wt=vt((U,q)=>{console.log("\u{1F525} Chat - addReaction called with messageId:",U,"and emoji:",q),Q(Y=>Y.map(K=>K.id===U?K.reactions?.find(Ve=>Ve.emoji===q)?{...K,reactions:K.reactions?.map(Ve=>Ve.emoji===q?{...Ve,count:Ve.count+1,users:[...Ve.users,"currentUser"]}:Ve)}:{...K,reactions:[...K.reactions||[],{emoji:q,count:1,users:["currentUser"]}]}:K)),S&&S(U,q)},[S]),Xe=vt((U,q)=>{Q(Y=>Y.map(K=>K.id===U?{...K,reactions:K.reactions?.map(te=>te.emoji===q?{...te,count:Math.max(0,te.count-1),users:te.users.filter(Ve=>Ve!=="currentUser")}:te).filter(te=>te.count>0)}:K)),A&&A(U,q)},[A]),Go=vt(U=>{Q(q=>q.map(Y=>Y.id===U?{...Y,deleted:!0,text:"",reactions:void 0}:Y)),I&&I(U)},[I]),se=vt(()=>{ve(null)},[]),Se=vt(U=>{ve(U),setTimeout(()=>{Te.current?.focus()},100)},[]),Wt=vt(U=>{if(_)return;let{layout:q}=U.nativeEvent;q.height<=0||ne(!0)},[_]);if(H)return<Mt style={Tt.container}>
|
|
26
|
+
{N||<Mt style={Tt.loadingContainer}>
|
|
27
27
|
{}
|
|
28
|
-
</
|
|
29
|
-
</
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
</
|
|
33
|
-
</
|
|
34
|
-
<
|
|
35
|
-
<J messages={
|
|
28
|
+
</Mt>}
|
|
29
|
+
</Mt>;if(!_)return<Mt style={Tt.container}>
|
|
30
|
+
<Mt style={Tt.chatContainer}onLayout={Wt}>
|
|
31
|
+
<Mt style={Tt.loadingContainer}>{N}</Mt>
|
|
32
|
+
</Mt>
|
|
33
|
+
</Mt>;let Us=C.renderInput;return<Mt style={Tt.container}>
|
|
34
|
+
<Mt style={Tt.fill}>
|
|
35
|
+
<J messages={Je}isTyping={Ie?O:!1}typingUserName={j}showScrollToBottom={oe}isReplyActive={!!W}enableMessageActions={re}enableReactionDetails={Z}onReactionAdd={wt}onReactionRemove={Xe}onMessageDelete={Go}onReplyMessage={Se}onActionPress={(U,q)=>{U==="reply"?Se(q):P?.(U,q)}}/>
|
|
36
36
|
|
|
37
|
-
{
|
|
37
|
+
{Us?Us({value:ee.message,onChangeText:ee.handleTextChange,onSend:ee.handleSend,onFocus:ee.handleFocus,height:ee.composerHeight,onContentSizeChange:ee.handleContentSizeChange,replyToMessage:W,onCancelReply:se,attachments:ze.attachments,onAttachmentAdd:ze.addAttachment,onAttachmentRemove:ze.removeAttachment,onAttachmentUpload:ze.uploadAttachments}):<Me ref={Te}value={ee.message}onChangeText={ee.handleTextChange}onSend={ee.handleSend}onFocus={ee.handleFocus}height={ee.composerHeight}onContentSizeChange={ee.handleContentSizeChange}replyToMessage={W}onCancelReply={se}onAttachmentSend={(U,q)=>{let Y=U.type==="image",K={id:Pe.current++,text:q?.trim()||"",isMe:!0,timestamp:new Date().toISOString(),status:"sent",type:Y?"image":"text",...Y&&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}}};Q(te=>[...te,K]),T&&T(K),ee.handleTextChange("")}}/>}
|
|
38
38
|
|
|
39
39
|
{}
|
|
40
|
-
</
|
|
40
|
+
</Mt>
|
|
41
41
|
|
|
42
42
|
{}
|
|
43
|
-
</
|
|
44
|
-
<
|
|
45
|
-
<Po onPress={
|
|
46
|
-
<
|
|
43
|
+
</Mt>},Tt=Sr.create({container:{flex:1},chatContainer:{flex:1,overflow:"hidden"},fill:{flex:1},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center"}}),es=wr;import{View as Ne,Text as Ms,TouchableOpacity as Po}from"react-native";import{ArrowLeft as Vr,Info as Dr,Phone as Br,Video as Lr}from"lucide-react-native";import{useContext as Ar}from"react";import{createContext as Ir,useMemo as vr}from"react";var Yt={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 ts=Ir(Yt),Pr=(M,R)=>({colors:{...M.colors,...R.colors},spacing:{...M.spacing,...R.spacing},borderRadius:{...M.borderRadius,...R.borderRadius},typography:{...M.typography,...R.typography}}),Zs=({children:M,theme:R})=>{let C=vr(()=>R?Pr(Yt,R):Yt,[R]);return<ts.Provider value={C}>{M}</ts.Provider>};var $=()=>{let M=Ar(ts);if(!M)throw new Error("useTheme must be used within a ThemeProvider");return M};var jr=({name:M="George Alan",isOnline:R=!0,onBack:C=()=>{},onVideoCall:T=()=>{},onVoiceCall:S=()=>{},onInfo:A=()=>{}})=>{let I=$(),P=Ce();return<Ne 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}}>
|
|
44
|
+
<Ne style={{flex:1,flexDirection:"row",alignItems:"center"}}>
|
|
45
|
+
<Po onPress={C}style={{marginRight:I.spacing.md}}>
|
|
46
|
+
<Vr size={24}color={I.colors.gray[700]}/>
|
|
47
47
|
</Po>
|
|
48
48
|
|
|
49
|
-
<
|
|
49
|
+
<Ne style={{flex:1,flexDirection:"row",alignItems:"center"}}>
|
|
50
50
|
{}
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
<
|
|
51
|
+
<Ne style={{position:"relative",marginRight:I.spacing.md}}>
|
|
52
|
+
<Ne style={{height:40,width:40,alignItems:"center",justifyContent:"center",borderRadius:I.borderRadius.full,backgroundColor:I.colors.gray[200]}}>
|
|
53
|
+
<Ms style={{fontSize:I.typography.fontSize.base,color:I.colors.text}}>
|
|
54
54
|
👤
|
|
55
|
-
</
|
|
56
|
-
</
|
|
57
|
-
{
|
|
58
|
-
</
|
|
55
|
+
</Ms>
|
|
56
|
+
</Ne>
|
|
57
|
+
{R&&<Ne 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}}/>}
|
|
58
|
+
</Ne>
|
|
59
59
|
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
{
|
|
63
|
-
</
|
|
64
|
-
<
|
|
65
|
-
{P(
|
|
66
|
-
</
|
|
67
|
-
</
|
|
68
|
-
</
|
|
69
|
-
</
|
|
60
|
+
<Ne style={{flex:1}}>
|
|
61
|
+
<Ms style={{fontSize:I.typography.fontSize.lg,fontWeight:I.typography.fontWeight.semibold,color:I.colors.text}}>
|
|
62
|
+
{M}
|
|
63
|
+
</Ms>
|
|
64
|
+
<Ms style={{fontSize:I.typography.fontSize.sm,color:I.colors.textSecondary}}>
|
|
65
|
+
{P(R?"status.online":"status.offline")}
|
|
66
|
+
</Ms>
|
|
67
|
+
</Ne>
|
|
68
|
+
</Ne>
|
|
69
|
+
</Ne>
|
|
70
70
|
|
|
71
|
-
<
|
|
71
|
+
<Ne style={{flexDirection:"row",alignItems:"center",gap:I.spacing.lg}}>
|
|
72
72
|
{}
|
|
73
|
-
{
|
|
74
|
-
<
|
|
73
|
+
{T&&<Po onPress={T}>
|
|
74
|
+
<Lr size={24}color={I.colors.gray[700]}/>
|
|
75
75
|
</Po>}
|
|
76
76
|
{S&&<Po onPress={S}>
|
|
77
|
-
<
|
|
77
|
+
<Br size={24}color={I.colors.gray[700]}/>
|
|
78
78
|
</Po>}
|
|
79
79
|
{A&&<Po onPress={A}>
|
|
80
|
-
<
|
|
80
|
+
<Dr size={24}color={I.colors.gray[700]}/>
|
|
81
81
|
</Po>}
|
|
82
|
-
</
|
|
83
|
-
</
|
|
84
|
-
<Vo style={{fontSize:
|
|
85
|
-
{
|
|
82
|
+
</Ne>
|
|
83
|
+
</Ne>},Ao=jr;import{useRef as Qr}from"react";import{View as Jt,Text as Ue,Pressable as Mn,TouchableOpacity as Tn}from"react-native";import Be from"dayjs";import Er from"dayjs/plugin/isToday";import Fr from"dayjs/plugin/isYesterday";import Or from"dayjs/plugin/relativeTime";import Hr from"dayjs/plugin/localizedFormat";import"dayjs/locale/pl";import"dayjs/locale/en";Be.extend(Er);Be.extend(Fr);Be.extend(Or);Be.extend(Hr);var Nr=(M,R="en")=>{let C=Be(M).locale(R);return C.isToday()?R==="pl"?"Dzisiaj":"Today":C.isYesterday()?R==="pl"?"Wczoraj":"Yesterday":C.format("ddd D MMMM")},Qs=(M,R,C="en")=>{let T=Be(M).locale(C);return T.isToday()?R("date.today"):T.isYesterday()?R("date.yesterday"):T.format("ddd D MMMM")},Wr=M=>Be(M).format("YYYY-MM-DD"),zo=(M,R="en")=>{if(M.length===0)return[];let C=[],T=null;return M.forEach((S,A)=>{let I=Wr(S.timestamp);if(T!==I){let z=Nr(S.timestamp,R),E={id:`date-${I}`,listItemType:"date-separator",date:I,displayDate:z};C.push(E),T=I}let P={...S,listItemType:"message"};C.push(P)}),C},Gt=(M,R="en")=>Be(M).locale(R).format("HH:mm"),ea=(M,R="en")=>Be(M).locale(R).fromNow();var ta=(M,R,C="en")=>{let T=Be(M).locale(C);return T.isToday()?R("date.todayWithTime",{time:T.format("HH:mm")}):T.isYesterday()?R("date.yesterdayWithTime",{time:T.format("HH:mm")}):T.format("DD MMM YYYY HH:mm")};import{View as Ts,Text as Vo,Image as Ur}from"react-native";var Kr=({replyTo:M,isMyMessage:R})=>{let C=$(),T=(E,v=50)=>E.length<=v?E:E.substring(0,v)+"...",S=R?"rgba(255, 255, 255, 0.3)":C.colors.primary,A=R?"rgba(255, 255, 255, 0.8)":C.colors.primary,I=R?"rgba(255, 255, 255, 0.7)":C.colors.textSecondary,P=R?"rgba(255, 255, 255, 0.1)":C.colors.surfaceSecondary,z=M.type==="image"&&M.imageData;return<Ts style={{marginBottom:C.spacing.sm,borderRadius:C.borderRadius.md,padding:C.spacing.sm,backgroundColor:P,borderLeftWidth:4,borderLeftColor:S}}>
|
|
84
|
+
<Vo style={{fontSize:C.typography.fontSize.xs,fontWeight:C.typography.fontWeight.medium,color:A,marginBottom:C.spacing.xs}}>
|
|
85
|
+
{M.isMe?"You":M.senderName||"Sender"}
|
|
86
86
|
</Vo>
|
|
87
87
|
|
|
88
|
-
{z?<
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
<Vo style={{fontSize:
|
|
88
|
+
{z?<Ts style={{flexDirection:"row",alignItems:"center"}}>
|
|
89
|
+
<Ur source={{uri:M.imageData.uri}}style={{width:40,height:40,borderRadius:C.borderRadius.sm,marginRight:C.spacing.sm}}resizeMode="cover"/>
|
|
90
|
+
<Ts style={{flex:1}}>
|
|
91
|
+
<Vo style={{fontSize:C.typography.fontSize.xs,color:I,fontStyle:"italic",marginBottom:C.spacing.xs}}>
|
|
92
92
|
📷 Image
|
|
93
93
|
</Vo>
|
|
94
|
-
{
|
|
95
|
-
{M
|
|
94
|
+
{M.text&&M.text.trim()&&<Vo style={{fontSize:C.typography.fontSize.sm,color:I,lineHeight:C.typography.lineHeight.tight}}>
|
|
95
|
+
{T(M.text,30)}
|
|
96
96
|
</Vo>}
|
|
97
|
-
</
|
|
98
|
-
</
|
|
99
|
-
{M
|
|
97
|
+
</Ts>
|
|
98
|
+
</Ts>:<Vo style={{fontSize:C.typography.fontSize.sm,color:I,lineHeight:C.typography.lineHeight.tight}}>
|
|
99
|
+
{T(M.text)}
|
|
100
100
|
</Vo>}
|
|
101
|
-
</
|
|
102
|
-
|
|
101
|
+
</Ts>},Pt=Kr;import{useState as oa,useCallback as _t}from"react";import{View as Do,Image as Ma,Pressable as Ta,Modal as $r,Dimensions as qr,StyleSheet as Yr,Text as Gr}from"react-native";var{width:Cs,height:Ca}=qr.get("window"),_r=({imageData:M,isMe:R,onImagePress:C,onLongPress:T})=>{let S=$(),[A,I]=oa(!1),[P,z]=oa(!1),v=_t(()=>{let O=Cs*.6,j=300;if(!M.width||!M.height)return{width:O,height:j};let H=M.width/M.height,N=O,F=N/H;return F>j&&(F=j,N=F*H),{width:Math.round(N),height:Math.round(F)}},[M.width,M.height])(),B=_t(()=>{C?C():I(!0)},[C]),k=_t(()=>{console.error("Failed to load image:",M.uri),z(!0)},[M.uri]),V=_t(()=>{I(!1)},[]),L=_t(()=>{if(!M.width||!M.height)return{width:Cs,height:Ca*.8};let O=M.width/M.height,j=Cs*.9,H=Ca*.8,N=j,F=N/O;return F>H&&(F=H,N=F*O),{width:Math.round(N),height:Math.round(F)}},[M.width,M.height])();return P?<Do style={[We.errorContainer,{width:v.width,height:v.height,backgroundColor:R?S.colors.messageBubble.sent:S.colors.messageBubble.received,borderRadius:S.borderRadius.lg}]}>
|
|
102
|
+
<Gr style={[We.errorText,{color:R?S.colors.messageBubble.sentText:S.colors.messageBubble.receivedText,fontSize:S.typography.fontSize.sm}]}>
|
|
103
103
|
Failed to load image
|
|
104
|
-
|
|
105
|
-
</
|
|
106
|
-
<
|
|
107
|
-
<
|
|
108
|
-
<
|
|
104
|
+
</Gr>
|
|
105
|
+
</Do>:<>
|
|
106
|
+
<Ta onPress={B}onLongPress={T}delayLongPress={500}>
|
|
107
|
+
<Do style={[We.imageContainer,{borderRadius:S.borderRadius.lg,overflow:"hidden"}]}>
|
|
108
|
+
<Ma source={{uri:M.uri}}style={[We.image,{width:v.width,height:v.height}]}resizeMode='cover'onError={k}/>
|
|
109
109
|
|
|
110
110
|
{}
|
|
111
|
-
<
|
|
112
|
-
</
|
|
113
|
-
</
|
|
111
|
+
<Do style={We.imageOverlay}/>
|
|
112
|
+
</Do>
|
|
113
|
+
</Ta>
|
|
114
114
|
|
|
115
115
|
{}
|
|
116
|
-
|
|
117
|
-
<
|
|
118
|
-
<
|
|
119
|
-
<
|
|
120
|
-
</
|
|
121
|
-
</
|
|
122
|
-
|
|
123
|
-
</>},
|
|
124
|
-
<Lo style={[
|
|
125
|
-
<Lo style={
|
|
126
|
-
<
|
|
127
|
-
<
|
|
116
|
+
<$r visible={A}transparent animationType='fade'onRequestClose={V}>
|
|
117
|
+
<Ta style={We.modalContainer}onPress={V}>
|
|
118
|
+
<Do style={We.modalContent}>
|
|
119
|
+
<Ma source={{uri:M.uri}}style={[We.modalImage,{width:L.width,height:L.height,borderRadius:S.borderRadius.lg}]}resizeMode='contain'/>
|
|
120
|
+
</Do>
|
|
121
|
+
</Ta>
|
|
122
|
+
</$r>
|
|
123
|
+
</>},We=Yr.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"}}),Bo=_r;import{View as Lo,Text as Ra,StyleSheet as Jr}from"react-native";import{Trash2 as Xr}from"lucide-react-native";var Zr=({isMe:M,timestamp:R,senderName:C})=>{let T=$(),S=Ce();return<Lo style={[At.container,{alignSelf:M?"flex-end":"flex-start",maxWidth:"80%"}]}>
|
|
124
|
+
<Lo style={[At.messageBubble,{backgroundColor:T.colors.gray[100],borderColor:T.colors.gray[200]}]}>
|
|
125
|
+
<Lo style={At.content}>
|
|
126
|
+
<Xr size={16}color={T.colors.gray[500]}/>
|
|
127
|
+
<Ra style={[At.deletedText,{color:T.colors.gray[500]}]}>
|
|
128
128
|
{S("message.deleted")}
|
|
129
|
-
</
|
|
129
|
+
</Ra>
|
|
130
130
|
</Lo>
|
|
131
131
|
</Lo>
|
|
132
|
-
<Lo style={[
|
|
133
|
-
<
|
|
134
|
-
{
|
|
135
|
-
</
|
|
132
|
+
<Lo style={[At.metadata,{alignSelf:M?"flex-end":"flex-start"}]}>
|
|
133
|
+
<Ra style={[At.timestamp,{color:T.colors.gray[400]}]}>
|
|
134
|
+
{R}
|
|
135
|
+
</Ra>
|
|
136
136
|
</Lo>
|
|
137
|
-
</Lo>},
|
|
138
|
-
<
|
|
139
|
-
{
|
|
137
|
+
</Lo>},At=Jr.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}}),Eo=Zr;var Cn=({message:M,onLongPress:R,onReactionPress:C})=>{let T=$(),S=Qr(null),A=()=>{S.current?S.current.measureInWindow((z,E,v,B)=>{let k={x:Math.round(z),y:Math.round(E),width:Math.round(v),height:Math.round(B)};R?.(M,k)}):R?.(M)},I=()=>{M.reactions&&M.reactions.length>0&&C?.(M)},P=M.type==="image"&&M.imageData;return M.deleted?<Eo isMe={M.isMe}timestamp={Gt(M.timestamp)}senderName={M.senderName}/>:<Jt style={{marginBottom:T.spacing.md,alignItems:M.isMe?"flex-end":"flex-start",marginHorizontal:T.spacing.sm}}>
|
|
138
|
+
<Mn ref={S}onLongPress={A}delayLongPress={500}style={{maxWidth:P?"75%":"80%",borderRadius:P?T.borderRadius.lg:T.borderRadius.xl,borderBottomRightRadius:M.isMe?4:P?T.borderRadius.lg:T.borderRadius.xl,borderBottomLeftRadius:M.isMe?P?T.borderRadius.lg:T.borderRadius.xl:4,paddingHorizontal:P?0:T.spacing.lg,paddingVertical:P?0:T.spacing.md,backgroundColor:P?"transparent":M.isMe?T.colors.messageBubble.sent:T.colors.messageBubble.received,overflow:"hidden"}}>
|
|
139
|
+
{M.replyTo&&<Pt replyTo={M.replyTo}isMyMessage={M.isMe}/>}
|
|
140
140
|
|
|
141
|
-
{P?<
|
|
142
|
-
{
|
|
143
|
-
</
|
|
141
|
+
{P?<Bo imageData={M.imageData}isMe={M.isMe}onLongPress={A}/>:<Ue style={{fontSize:T.typography.fontSize.base,color:M.isMe?T.colors.messageBubble.sentText:T.colors.messageBubble.receivedText}}>
|
|
142
|
+
{M.text}
|
|
143
|
+
</Ue>}
|
|
144
144
|
|
|
145
145
|
{}
|
|
146
|
-
{P&&
|
|
147
|
-
<
|
|
148
|
-
{
|
|
149
|
-
</
|
|
150
|
-
|
|
151
|
-
</
|
|
146
|
+
{P&&M.text&&M.text.trim()&&<Jt style={{paddingHorizontal:T.spacing.lg,paddingVertical:T.spacing.md,backgroundColor:M.isMe?T.colors.messageBubble.sent:T.colors.messageBubble.received,borderRadius:T.borderRadius.lg,marginTop:T.spacing.xs}}>
|
|
147
|
+
<Ue style={{fontSize:T.typography.fontSize.base,color:M.isMe?T.colors.messageBubble.sentText:T.colors.messageBubble.receivedText}}>
|
|
148
|
+
{M.text}
|
|
149
|
+
</Ue>
|
|
150
|
+
</Jt>}
|
|
151
|
+
</Mn>
|
|
152
152
|
|
|
153
153
|
{}
|
|
154
|
-
{
|
|
155
|
-
{
|
|
156
|
-
<
|
|
154
|
+
{M.reactions&&M.reactions.length>0&&<Tn onPress={I}style={{marginTop:T.spacing.xs,flexDirection:"row",alignItems:"center",backgroundColor:T.colors.background,borderRadius:T.borderRadius.full,justifyContent:M.isMe?"flex-end":"flex-start"}}>
|
|
155
|
+
{M.reactions.map((z,E)=><Jt key={`${z.emoji}-${E}`}style={{flexDirection:"row",alignItems:"center",padding:T.spacing.xs}}>
|
|
156
|
+
<Ue style={{fontSize:T.typography.fontSize.sm}}>
|
|
157
157
|
{z.emoji}
|
|
158
|
-
</
|
|
159
|
-
{z.count>1&&<
|
|
158
|
+
</Ue>
|
|
159
|
+
{z.count>1&&<Ue style={{fontSize:T.typography.fontSize.xs,color:T.colors.textSecondary,marginLeft:T.spacing.xs,fontWeight:T.typography.fontWeight.medium}}>
|
|
160
160
|
{z.count}
|
|
161
|
-
</
|
|
162
|
-
|
|
163
|
-
</
|
|
161
|
+
</Ue>}
|
|
162
|
+
</Jt>)}
|
|
163
|
+
</Tn>}
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
<
|
|
167
|
-
{
|
|
168
|
-
</
|
|
169
|
-
{
|
|
170
|
-
{
|
|
165
|
+
<Jt style={{marginHorizontal:T.spacing.sm,marginTop:T.spacing.xs,flexDirection:"row",alignItems:"center",justifyContent:M.isMe?"flex-end":"flex-start"}}>
|
|
166
|
+
<Ue style={{fontSize:T.typography.fontSize.xs,color:T.colors.textSecondary}}>
|
|
167
|
+
{Gt(M.timestamp)}
|
|
168
|
+
</Ue>
|
|
169
|
+
{M.isMe&&M.status&&<Jt style={{marginLeft:T.spacing.xs}}>
|
|
170
|
+
{M.status==="sent"&&<Ue style={{fontSize:T.typography.fontSize.xs,color:T.colors.gray[400]}}>
|
|
171
171
|
✓
|
|
172
|
-
</
|
|
173
|
-
{
|
|
172
|
+
</Ue>}
|
|
173
|
+
{M.status==="delivered"&&<Ue style={{fontSize:T.typography.fontSize.xs,color:T.colors.gray[400]}}>
|
|
174
174
|
✓✓
|
|
175
|
-
</
|
|
176
|
-
{
|
|
175
|
+
</Ue>}
|
|
176
|
+
{M.status==="read"&&<Ue style={{fontSize:T.typography.fontSize.xs,color:T.colors.primary}}>
|
|
177
177
|
✓✓
|
|
178
|
-
</
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
<
|
|
183
|
-
<
|
|
184
|
-
<
|
|
185
|
-
<
|
|
186
|
-
<
|
|
187
|
-
<
|
|
188
|
-
Replying to {
|
|
178
|
+
</Ue>}
|
|
179
|
+
</Jt>}
|
|
180
|
+
</Jt>
|
|
181
|
+
</Jt>},Fo=Cn;import{View as Le,Text as Vt,TouchableOpacity as Rn,Image as Sn}from"react-native";import{X as In}from"lucide-react-native";var vn=({replyToMessage:M,onCancel:R})=>{let C=$(),T=(I,P=50)=>I.length<=P?I:I.substring(0,P)+"...",S=!!M.replyTo,A=M.type==="image"&&M.imageData;return<Le style={{borderBottomWidth:1,borderBottomColor:C.colors.border,backgroundColor:C.colors.surface,paddingHorizontal:C.spacing.lg,paddingVertical:C.spacing.md}}>
|
|
182
|
+
<Le style={{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}>
|
|
183
|
+
<Le style={{flex:1,marginRight:C.spacing.md}}>
|
|
184
|
+
<Le style={{flexDirection:"row",alignItems:"center",marginBottom:C.spacing.xs}}>
|
|
185
|
+
<Le style={{width:4,backgroundColor:C.colors.primary,borderRadius:C.borderRadius.full,marginRight:C.spacing.md,height:S?48:32}}/>
|
|
186
|
+
<Le style={{flex:1}}>
|
|
187
|
+
<Vt style={{fontSize:C.typography.fontSize.xs,fontWeight:C.typography.fontWeight.medium,color:C.colors.primary,marginBottom:C.spacing.xs}}>
|
|
188
|
+
Replying to {M.isMe?"yourself":M.senderName||"sender"}
|
|
189
189
|
{S&&" (reply thread)"}
|
|
190
|
-
</
|
|
190
|
+
</Vt>
|
|
191
191
|
|
|
192
192
|
{}
|
|
193
|
-
{S&&<
|
|
194
|
-
<
|
|
195
|
-
Originally replying to: {
|
|
196
|
-
</
|
|
197
|
-
<
|
|
198
|
-
{M
|
|
199
|
-
</
|
|
200
|
-
</
|
|
193
|
+
{S&&<Le style={{marginBottom:C.spacing.sm,padding:C.spacing.sm,backgroundColor:C.colors.surfaceSecondary,borderRadius:C.borderRadius.md,borderLeftWidth:2,borderLeftColor:C.colors.gray[300]}}>
|
|
194
|
+
<Vt style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary,marginBottom:C.spacing.xs}}>
|
|
195
|
+
Originally replying to: {M.replyTo.isMe?"yourself":M.replyTo.senderName||"sender"}
|
|
196
|
+
</Vt>
|
|
197
|
+
<Vt style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary,lineHeight:C.typography.lineHeight.tight}}>
|
|
198
|
+
{T(M.replyTo.text,40)}
|
|
199
|
+
</Vt>
|
|
200
|
+
</Le>}
|
|
201
201
|
|
|
202
|
-
{A?<
|
|
203
|
-
<
|
|
204
|
-
<
|
|
205
|
-
<
|
|
202
|
+
{A?<Le style={{flexDirection:"row",alignItems:"center"}}>
|
|
203
|
+
<Sn source={{uri:M.imageData.uri}}style={{width:32,height:32,borderRadius:C.borderRadius.sm,marginRight:C.spacing.sm}}resizeMode="cover"/>
|
|
204
|
+
<Le style={{flex:1}}>
|
|
205
|
+
<Vt style={{fontSize:C.typography.fontSize.xs,color:C.colors.gray[600],fontStyle:"italic",marginBottom:C.spacing.xs}}>
|
|
206
206
|
📷 Image
|
|
207
|
-
</
|
|
208
|
-
{
|
|
209
|
-
{M
|
|
210
|
-
</
|
|
211
|
-
</
|
|
212
|
-
</
|
|
213
|
-
{M
|
|
214
|
-
</
|
|
215
|
-
</
|
|
216
|
-
</
|
|
217
|
-
</
|
|
207
|
+
</Vt>
|
|
208
|
+
{M.text&&M.text.trim()&&<Vt style={{fontSize:C.typography.fontSize.sm,color:C.colors.gray[700],lineHeight:C.typography.lineHeight.tight}}>
|
|
209
|
+
{T(M.text,40)}
|
|
210
|
+
</Vt>}
|
|
211
|
+
</Le>
|
|
212
|
+
</Le>:<Vt style={{fontSize:C.typography.fontSize.sm,color:C.colors.gray[700],lineHeight:C.typography.lineHeight.tight}}>
|
|
213
|
+
{T(M.text)}
|
|
214
|
+
</Vt>}
|
|
215
|
+
</Le>
|
|
216
|
+
</Le>
|
|
217
|
+
</Le>
|
|
218
218
|
|
|
219
|
-
<
|
|
220
|
-
<
|
|
221
|
-
</
|
|
222
|
-
</
|
|
223
|
-
</
|
|
224
|
-
<
|
|
225
|
-
{
|
|
226
|
-
</
|
|
227
|
-
{
|
|
219
|
+
<Rn onPress={R}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}}>
|
|
220
|
+
<In size={16}color={C.colors.textSecondary}/>
|
|
221
|
+
</Rn>
|
|
222
|
+
</Le>
|
|
223
|
+
</Le>},Xt=vn;import{useRef as Ke,useState as Sa,useEffect as ws}from"react";import{View as Zt,Text as Et,TouchableOpacity as Lt,StyleSheet as Rs,Pressable as Bn,ScrollView as Ln,Dimensions as jn,Animated as we,Image as En}from"react-native";import{Reply as Fn,Copy as On,Plus as Hn,Trash2 as Nn}from"lucide-react-native";import{useState as Pn,useEffect as An}from"react";import Vn from"rn-emoji-keyboard";var Dn=({visible:M,onClose:R,onEmojiSelected:C})=>{let[T,S]=Pn(!1);An(()=>{S(!!M)},[M]);let A=P=>{console.log("Selected emoji:",P),C(P.emoji),S(!1),R()},I=()=>{S(!1),R()};return M?<Vn onEmojiSelected={A}open={T}onClose={I}enableSearchBar/>:null},Dt=Dn;var Wn=({visible:M,onPress:R,children:C})=>M?<Zt style={ae.overlay}>
|
|
224
|
+
<Lt style={ae.backdrop}onPress={R}activeOpacity={1}/>
|
|
225
|
+
{C}
|
|
226
|
+
</Zt>:null,{width:Bt,height:Ss}=jn.get("window"),Un=({message:M,positions:R,messagePosition:C,containerRef:T,containerOffset:S,setContainerOffset:A})=>{let I=$(),P=Ke(new we.Value(C.y)).current,z=Ke(new we.Value(0)).current,E=Ke(!1),v=M.type==="image"&&M.imageData;return ws(()=>{E.current=!1,T.current&&T.current.measureInWindow((B,k,V,D)=>{A({x:B,y:k});let L=C.y-k,O=R.messagePreviewTop-k;P.setValue(L),z.setValue(0),requestAnimationFrame(()=>{we.parallel([we.timing(P,{toValue:O,duration:250,useNativeDriver:!1}),we.timing(z,{toValue:1,duration:250,useNativeDriver:!1})]).start(()=>{E.current=!0})})})},[R.messagePreviewTop,C.y,T]),<we.View style={{position:"absolute",top:P,left:C.x,width:C.width,height:M.replyTo?C.height+10:C.height,zIndex:1e3,opacity:z,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"}}>
|
|
227
|
+
{M.replyTo&&<Pt replyTo={M.replyTo}isMyMessage={M.isMe}/>}
|
|
228
228
|
|
|
229
|
-
{v?<
|
|
230
|
-
<
|
|
229
|
+
{v?<Zt>
|
|
230
|
+
<En source={{uri:M.imageData.uri}}style={{width:C.width,height:C.height,borderRadius:I.borderRadius.lg}}resizeMode='cover'/>
|
|
231
231
|
{}
|
|
232
|
-
{
|
|
233
|
-
<
|
|
234
|
-
{
|
|
235
|
-
</
|
|
236
|
-
</
|
|
237
|
-
</
|
|
238
|
-
{
|
|
239
|
-
</
|
|
240
|
-
</
|
|
232
|
+
{M.text&&M.text.trim()&&<Zt 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}}>
|
|
233
|
+
<Et style={{fontSize:I.typography.fontSize.base,color:M.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
|
|
234
|
+
{M.text}
|
|
235
|
+
</Et>
|
|
236
|
+
</Zt>}
|
|
237
|
+
</Zt>:<Et style={{fontSize:I.typography.fontSize.base,color:M.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
|
|
238
|
+
{M.text}
|
|
239
|
+
</Et>}
|
|
240
|
+
</we.View>},Kn=({visible:M,onClose:R,isMyMessage:C,selectedMessage:T,messagePosition:S,onActionPress:A,onEmojiReact:I})=>{let P=Ce(),[z,E]=Sa(!1),v=Ke(null),[B,k]=Sa({x:0,y:0}),V=Ke(new we.Value(0)).current,D=Ke(new we.Value(0)).current,L=Ke(!1),O=Ke(!1),j=Z=>{A(Z),R()},H=Z=>{I?.(Z),R()},N=()=>{E(!0)},F=()=>{E(!1)},_=Z=>{I?.(Z),E(!1),R()},ne=["\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F621}","\u{1F44D}"],Me=(()=>{if(!S)return{emojiBar:{top:Ss/2-200,left:Bt/2-160},actionMenu:{top:Ss/2+50,left:Bt/2-100}};let Z=320,re=60,oe=200,Ie=160,W=20,ve=8,Te,Je,Q,Pe,ze,ee=Ss/2,wt=re+ve+S.height+ve+Ie,Xe=ee-wt/2;return Je=Xe,ze=Xe+re+ve,Pe=Xe+re+ve+S.height+ve,Te=S.x,Q=S.x,Te+Z>Bt-W&&(Te=Bt-Z-W),Te<W&&(Te=W),Q+oe>Bt-W&&(Q=Bt-oe-W),Q<W&&(Q=W),{emojiBar:{top:Je,left:Te},actionMenu:{top:Pe,left:Q},messagePreviewTop:ze,isNearAverageHeight:!0,isNearTop:!0,isEdgeCase:!0}})();return ws(()=>{M&&S&&!O.current&&(V.setValue(0),D.setValue(0),setTimeout(()=>{we.sequence([we.timing(V,{toValue:1,duration:200,useNativeDriver:!1}),we.timing(D,{toValue:1,duration:200,useNativeDriver:!1})]).start(()=>{O.current=!0})},50))},[M,S,V,D]),ws(()=>{M||(L.current=!1,O.current=!1,V.setValue(0),D.setValue(0))},[M,V,D]),M?<>
|
|
241
241
|
{}
|
|
242
|
-
<
|
|
243
|
-
<
|
|
244
|
-
</
|
|
242
|
+
<Wn visible={!0}onPress={R}>
|
|
243
|
+
<Bn style={ae.overlayPressable}onPress={R}/>
|
|
244
|
+
</Wn>
|
|
245
245
|
|
|
246
|
-
<
|
|
246
|
+
<Zt ref={v}style={{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}>
|
|
247
247
|
{}
|
|
248
|
-
</
|
|
248
|
+
</Zt>
|
|
249
249
|
|
|
250
250
|
{}
|
|
251
|
-
{S&&
|
|
251
|
+
{S&&T&&<Un message={T}positions={Me}messagePosition={S}containerRef={v}containerOffset={B}setContainerOffset={k}/>}
|
|
252
252
|
|
|
253
253
|
{}
|
|
254
|
-
<
|
|
255
|
-
<
|
|
256
|
-
{
|
|
257
|
-
<
|
|
258
|
-
</
|
|
259
|
-
<
|
|
260
|
-
<
|
|
261
|
-
</
|
|
262
|
-
</
|
|
263
|
-
</
|
|
254
|
+
<we.View style={[ae.emojiBar,{position:"absolute",top:Me.emojiBar.top-(B.y||0),left:Me.emojiBar.left,opacity:V,pointerEvents:"auto"}]}>
|
|
255
|
+
<Ln horizontal showsHorizontalScrollIndicator={!1}contentContainerStyle={ae.emojiContainer}>
|
|
256
|
+
{ne.map((Z,re)=><Lt key={re}style={ae.emojiButton}onPress={()=>H(Z)}>
|
|
257
|
+
<Et style={ae.emojiText}>{Z}</Et>
|
|
258
|
+
</Lt>)}
|
|
259
|
+
<Lt style={ae.addEmojiButton}onPress={N}>
|
|
260
|
+
<Hn size={20}color='#666'/>
|
|
261
|
+
</Lt>
|
|
262
|
+
</Ln>
|
|
263
|
+
</we.View>
|
|
264
264
|
|
|
265
265
|
{}
|
|
266
|
-
<
|
|
267
|
-
<
|
|
266
|
+
<we.View style={[ae.actionMenu,{position:"absolute",top:Me.actionMenu.top-(B.y||0)+(T?.replyTo?10:0),left:Me.actionMenu.left,opacity:D,pointerEvents:"auto"}]}>
|
|
267
|
+
<Zt style={ae.actionItems}>
|
|
268
268
|
{}
|
|
269
|
-
<
|
|
270
|
-
<
|
|
271
|
-
<
|
|
272
|
-
</
|
|
269
|
+
<Lt style={ae.actionRow}onPress={()=>j("reply")}>
|
|
270
|
+
<Fn size={18}color='#333'/>
|
|
271
|
+
<Et style={ae.actionLabel}>{P("action.reply")}</Et>
|
|
272
|
+
</Lt>
|
|
273
273
|
|
|
274
274
|
{}
|
|
275
|
-
<
|
|
276
|
-
<
|
|
277
|
-
<
|
|
278
|
-
</
|
|
275
|
+
<Lt style={ae.actionRow}onPress={()=>j("copy")}>
|
|
276
|
+
<On size={18}color='#333'/>
|
|
277
|
+
<Et style={ae.actionLabel}>{P("action.copy")}</Et>
|
|
278
|
+
</Lt>
|
|
279
279
|
|
|
280
280
|
{}
|
|
281
|
-
{
|
|
282
|
-
<
|
|
283
|
-
<
|
|
281
|
+
{C&&<Lt style={ae.actionRow}onPress={()=>j("delete")}>
|
|
282
|
+
<Nn size={18}color='#ff4444'/>
|
|
283
|
+
<Et style={[ae.actionLabel,{color:"#ff4444"}]}>
|
|
284
284
|
{P("action.delete")}
|
|
285
|
-
</
|
|
286
|
-
</
|
|
287
|
-
</
|
|
288
|
-
</
|
|
285
|
+
</Et>
|
|
286
|
+
</Lt>}
|
|
287
|
+
</Zt>
|
|
288
|
+
</we.View>
|
|
289
289
|
|
|
290
290
|
{}
|
|
291
|
-
<
|
|
292
|
-
</>:null},
|
|
293
|
-
|
|
291
|
+
<Dt visible={z}onClose={F}onEmojiSelected={_}/>
|
|
292
|
+
</>:null},ae=Rs.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:{...Rs.absoluteFillObject,zIndex:1e3},backdrop:{...Rs.absoluteFillObject,backgroundColor:"rgba(0, 0, 0, 0.8)"}}),Oo=Kn;import{useRef as $n,useEffect as qn,useState as Yn}from"react";import{View as $e,Text as Ee,TouchableOpacity as Ia,ScrollView as Gn,StyleSheet as _n}from"react-native";import Jn from"react-native-actions-sheet";var Xn=({visible:M,onClose:R,reactions:C,messageText:T,onAddReaction:S,onRemoveReaction:A})=>{let I=$n(null),[P,z]=Yn(!1);qn(()=>{M?I.current?.show():I.current?.hide()},[M]);let v=(()=>{let j=[];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 F=0;F<Math.min(H.count,N.length);F++)j.push({id:`${H.emoji}-${F}`,name:N[F].name,avatar:N[F].avatar,emoji:H.emoji,timestamp:new Date().toISOString()})}),j})(),B=C.reduce((j,H)=>j+H.count,0),k=j=>{console.log("Remove reaction called with:",j),console.log("onRemoveReaction prop exists:",!!A),console.log("User is current user:",j.name==="You"),j.name==="You"&&A?(console.log("Calling onRemoveReaction with emoji:",j.emoji),A(j.emoji)):console.log("Not calling onRemoveReaction because:",{isCurrentUser:j.name==="You",hasCallback:!!A})},V=()=>{I.current?.hide(),R(),setTimeout(()=>{z(!0)},300)},D=()=>{z(!1)},L=j=>{console.log("Selected emoji from picker:",j),S?.(j),z(!1),R()},O=()=>{I.current?.hide(),R()};return<>
|
|
293
|
+
<Jn ref={I}onClose={O}containerStyle={G.container}headerAlwaysVisible={!0}gestureEnabled={!0}closeOnTouchBackdrop={!0}>
|
|
294
294
|
{}
|
|
295
|
-
|
|
296
|
-
<
|
|
297
|
-
<
|
|
298
|
-
<
|
|
299
|
-
</
|
|
300
|
-
|
|
295
|
+
<$e style={G.header}>
|
|
296
|
+
<Ee style={G.title}>{B} reactions</Ee>
|
|
297
|
+
<Ia onPress={O}style={G.closeButton}>
|
|
298
|
+
<Ee style={G.closeText}>✕</Ee>
|
|
299
|
+
</Ia>
|
|
300
|
+
</$e>
|
|
301
301
|
|
|
302
302
|
{}
|
|
303
|
-
|
|
304
|
-
<
|
|
305
|
-
{
|
|
306
|
-
</
|
|
307
|
-
|
|
303
|
+
<$e style={G.messagePreview}>
|
|
304
|
+
<Ee style={G.messageText}numberOfLines={2}>
|
|
305
|
+
{T}
|
|
306
|
+
</Ee>
|
|
307
|
+
</$e>
|
|
308
308
|
|
|
309
309
|
{}
|
|
310
|
-
|
|
310
|
+
<$e style={G.reactionButtons}>
|
|
311
311
|
{}
|
|
312
312
|
|
|
313
|
-
{
|
|
314
|
-
<
|
|
315
|
-
<
|
|
316
|
-
|
|
317
|
-
|
|
313
|
+
{C.map((j,H)=><$e key={H}style={G.reactionButton}>
|
|
314
|
+
<Ee style={G.reactionEmoji}>{j.emoji}</Ee>
|
|
315
|
+
<Ee style={G.reactionCount}>{j.count}</Ee>
|
|
316
|
+
</$e>)}
|
|
317
|
+
</$e>
|
|
318
318
|
|
|
319
319
|
{}
|
|
320
|
-
<
|
|
321
|
-
{v.map(j=>{let H=j.name==="You",N=H?
|
|
322
|
-
|
|
323
|
-
<
|
|
324
|
-
|
|
325
|
-
<
|
|
326
|
-
{H&&<
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
<
|
|
331
|
-
|
|
320
|
+
<Gn style={G.userReactionsList}showsVerticalScrollIndicator={!1}>
|
|
321
|
+
{v.map(j=>{let H=j.name==="You",N=H?Ia:$e;return<N key={j.id}style={[G.userReactionItem,H&&G.tappableUserReactionItem]}onPress={H?()=>k(j):void 0}activeOpacity={H?.7:1}>
|
|
322
|
+
<$e style={G.userInfo}>
|
|
323
|
+
<Ee style={G.userAvatar}>{j.avatar}</Ee>
|
|
324
|
+
<$e style={G.userDetails}>
|
|
325
|
+
<Ee style={G.userName}>{j.name}</Ee>
|
|
326
|
+
{H&&<Ee style={G.removeText}>Tap to remove</Ee>}
|
|
327
|
+
</$e>
|
|
328
|
+
</$e>
|
|
329
|
+
<$e style={G.userReactionEmoji}>
|
|
330
|
+
<Ee style={G.emojiText}>{j.emoji}</Ee>
|
|
331
|
+
</$e>
|
|
332
332
|
</N>})}
|
|
333
|
-
</
|
|
334
|
-
|
|
333
|
+
</Gn>
|
|
334
|
+
</Jn>
|
|
335
335
|
|
|
336
336
|
{}
|
|
337
|
-
<
|
|
338
|
-
</>},G=
|
|
337
|
+
<Dt visible={P}onClose={D}onEmojiSelected={L}/>
|
|
338
|
+
</>},G=_n.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}}),Ho=Xn;import Zn,{forwardRef as Qn,useImperativeHandle as ei}from"react";import{View as No,Text as Pa,TouchableOpacity as Aa}from"react-native";import Mi from"react-native-actions-sheet";import{X as Ti}from"lucide-react-native";var Ct=Qn(({onOptionSelect:M,options:R},C)=>{let T=Zn.useRef(null);ei(C,()=>({show:()=>T.current?.show(),hide:()=>T.current?.hide()}));let S=A=>{M(A),T.current?.hide()};return<Mi ref={T}headerAlwaysVisible gestureEnabled={!0}statusBarTranslucent drawUnderStatusBar={!1}containerStyle={{borderTopLeftRadius:20,borderTopRightRadius:20}}>
|
|
339
339
|
<No style={{padding:20,width:"100%"}}>
|
|
340
340
|
|
|
341
341
|
{}
|
|
342
342
|
<No style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:20}}>
|
|
343
|
-
<
|
|
343
|
+
<Pa style={{fontSize:18,fontWeight:"600",color:"#1F2937"}}>
|
|
344
344
|
Share Content
|
|
345
|
-
</
|
|
346
|
-
<
|
|
347
|
-
<
|
|
348
|
-
</
|
|
345
|
+
</Pa>
|
|
346
|
+
<Aa onPress={()=>T.current?.hide()}>
|
|
347
|
+
<Ti size={24}color="#6B7280"/>
|
|
348
|
+
</Aa>
|
|
349
349
|
</No>
|
|
350
350
|
|
|
351
351
|
{}
|
|
352
352
|
<No style={{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",paddingBottom:20}}>
|
|
353
|
-
{
|
|
353
|
+
{R.map(A=>{let I=A.icon;return<Aa key={A.id}style={{width:"30%",aspectRatio:1,marginBottom:20,alignItems:"center",justifyContent:"center"}}onPress={()=>S(A.id)}>
|
|
354
354
|
<No style={{width:60,height:60,borderRadius:30,backgroundColor:"#F3F4F6",alignItems:"center",justifyContent:"center",marginBottom:8}}>
|
|
355
355
|
<I size={24}color={A.color}/>
|
|
356
356
|
</No>
|
|
357
|
-
<
|
|
357
|
+
<Pa style={{fontSize:12,color:"#6B7280",textAlign:"center",fontWeight:"500"}}>
|
|
358
358
|
{A.label}
|
|
359
|
-
</
|
|
360
|
-
</
|
|
359
|
+
</Pa>
|
|
360
|
+
</Aa>})}
|
|
361
361
|
</No>
|
|
362
362
|
</No>
|
|
363
|
-
</
|
|
364
|
-
<
|
|
365
|
-
<
|
|
366
|
-
<
|
|
367
|
-
<
|
|
368
|
-
<
|
|
369
|
-
</
|
|
370
|
-
</
|
|
371
|
-
</
|
|
372
|
-
{({pressed:P})=><
|
|
373
|
-
<
|
|
374
|
-
</
|
|
375
|
-
</
|
|
376
|
-
<
|
|
377
|
-
<
|
|
378
|
-
{
|
|
379
|
-
</
|
|
380
|
-
</
|
|
381
|
-
</Vn>},Uo=Si;import qo,{forwardRef as Ei,useRef as Oi,useImperativeHandle as Fi,useCallback as Hi}from"react";import{View as Ds,TextInput as Ni,TouchableOpacity as Bn,Platform as kn}from"react-native";import{Plus as Wi,Send as Ui,Mic as Ki}from"lucide-react-native";import{useRef as Ii,useCallback as qe}from"react";import{Alert as X}from"react-native";import{Camera as vi,Image as Pi,MapPin as Ai,User as zi,FileText as Vi,BarChart3 as Bi,Calendar as ki}from"lucide-react-native";var wi={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},Vs=async(C,T={})=>{try{let R;try{R=await import("expo-image-manipulator")}catch(k){console.log("expo-image-manipulator not available, returning original image info:",k);let V=`image_${Date.now()}.jpg`;return{uri:C,width:1920,height:1920,fileName:V}}let M={...wi,...T};console.log("Starting image compression...",{uri:C,options:M});let S=await R.manipulateAsync(C,[],{});console.log("Original image info:",{width:S.width,height:S.height,uri:S.uri});let A=[];if(M.maxWidth||M.maxHeight){let{width:k,height:D}=S,V=k,B=D;if(M.maxWidth&&k>M.maxWidth){let L=M.maxWidth/k;V=M.maxWidth,B=D*L}if(M.maxHeight&&B>M.maxHeight){let L=M.maxHeight/B;B=M.maxHeight,V=V*L}(V!==k||B!==D)&&(A.push({resize:{width:Math.round(V),height:Math.round(B)}}),console.log("Resizing image:",{from:{width:k,height:D},to:{width:Math.round(V),height:Math.round(B)}}))}let I={compress:M.quality,format:M.format==="png"?R.SaveFormat?.PNG:R.SaveFormat?.JPEG};console.log("Applying compression with options:",I);let P=await R.manipulateAsync(C,A,I);console.log("Image compression completed:",{originalUri:C,compressedUri:P.uri,finalDimensions:{width:P.width,height:P.height}});let z=Date.now(),E=M.format==="png"?"png":"jpg",v=`compressed_image_${z}.${E}`;return{uri:P.uri,width:P.width,height:P.height,fileName:v}}catch(R){console.error("Error compressing image:",R);let M=R instanceof Error?R.message:"Unknown error";throw new Error(`Failed to compress image: ${M}`)}},Bs=(C,T)=>C>3e3||T>3e3?{maxWidth:1920,maxHeight:1920,quality:.7,format:"jpeg"}:C>1920||T>1920?{maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"}:{quality:.9,format:"jpeg"};var Di=[{id:"photo",label:"Photo",icon:Pi,color:"#3B82F6"},{id:"camera",label:"Camera",icon:vi,color:"#6B7280"},{id:"location",label:"Location",icon:Ai,color:"#10B981"},{id:"contact",label:"Contact",icon:zi,color:"#6B7280"},{id:"document",label:"Document",icon:Vi,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Bi,color:"#F59E0B"},{id:"event",label:"Event",icon:ki,color:"#EF4444"}],Ko=C=>{let T=Ii(null),R=qe(async()=>{console.log("Photo selection initiated");try{let v;try{v=await import("expo-image-picker")}catch(V){console.log("expo-image-picker not available:",V),X.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:k}=await v.requestMediaLibraryPermissionsAsync();if(console.log("Photo library permission status:",k),k!=="granted"){X.alert("Permission needed","Please grant photo library access to select images.");return}console.log("Waiting for UI to stabilize..."),await new Promise(V=>setTimeout(()=>V(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 V=D.assets[0];console.log("Photo selected successfully:",V.uri);try{console.log("Starting image compression...");let B=Bs(V.width||1920,V.height||1920),L=await Vs(V.uri,B);console.log("Image compression completed:",L),C?.({type:"image",data:{...L,originalFileSize:V.fileSize}})}catch(B){console.error("Image compression failed:",B),X.alert("Compression Error","Failed to compress image. Sending original image.",[{text:"OK"}]),C?.({type:"image",data:{uri:V.uri,width:V.width,height:V.height,fileSize:V.fileSize,fileName:V.fileName||"image.jpg"}})}}else console.log("Photo selection was canceled by user")}catch(v){console.error("Error in photo selection process:",v),X.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[C]),M=qe(async()=>{console.log("Camera capture initiated");try{let v;try{v=await import("expo-image-picker")}catch(V){console.log("expo-image-picker not available:",V),X.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:k}=await v.requestCameraPermissionsAsync();if(console.log("Camera permission status:",k),k!=="granted"){X.alert("Permission needed","Please grant camera access to take photos.");return}console.log("Waiting for UI to stabilize..."),await new Promise(V=>setTimeout(()=>V(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 V=D.assets[0];console.log("Photo captured successfully:",V.uri);try{console.log("Starting camera image compression...");let B=Bs(V.width||1920,V.height||1920),L=await Vs(V.uri,B);console.log("Camera image compression completed:",L),C?.({type:"image",data:{...L,originalFileSize:V.fileSize}})}catch(B){console.error("Camera image compression failed:",B),X.alert("Compression Error","Failed to compress captured image. Sending original image.",[{text:"OK"}]),C?.({type:"image",data:{uri:V.uri,width:V.width,height:V.height,fileSize:V.fileSize,fileName:V.fileName||"camera_photo.jpg"}})}}else console.log("Camera capture was canceled by user")}catch(v){console.error("Error in camera capture process:",v),X.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[C]),S=qe(async()=>{console.log("Location sharing initiated");try{let v;try{v=await import("expo-location")}catch(L){console.log("expo-location not available:",L),X.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:k}=await v.requestForegroundPermissionsAsync();if(console.log("Location permission status:",k),k!=="granted"){X.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 V=await v.reverseGeocodeAsync({latitude:D.coords.latitude,longitude:D.coords.longitude}),B={coordinates:{latitude:D.coords.latitude,longitude:D.coords.longitude},address:V[0]||null,timestamp:D.timestamp};console.log("Location shared successfully:",B.coordinates),C?.({type:"location",data:B})}catch(v){console.error("Error in location sharing process:",v),X.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[C]),A=qe(async()=>{try{let v;try{v=await import("expo-contacts")}catch(D){console.log("expo-contacts not available:",D),X.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:k}=await v.requestPermissionsAsync();if(k!=="granted"){X.alert("Permission needed","Please grant contacts access to share contacts.");return}X.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),X.alert("Error","Failed to access contacts. Please try again.")}finally{T.current?.hide()}},[]),I=qe(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),X.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 k=await v.getDocumentAsync({type:"*/*",copyToCacheDirectory:!0,multiple:!1});if(console.log("Document picker result:",k),!k.canceled&&k.assets&&k.assets.length>0){let D=k.assets[0];console.log("Document selected successfully:",D.name),C?.({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),X.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[C]),P=qe(()=>{X.alert("Create Poll","Poll creation feature is coming soon! This would open a poll creation interface.",[{text:"OK",onPress:()=>console.log("Poll creation acknowledged")}])},[]),z=qe(()=>{X.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=qe(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await R();break;case"camera":await M();break;case"location":await S();break;case"contact":await A();break;case"document":await I();break;case"poll":P();break;case"event":z();break;default:console.warn(`Unknown attachment option: ${v}`)}}catch(k){console.error(`Error handling ${v}:`,k),X.alert("Error",`Failed to handle ${v}. Please try again.`)}},[R,M,S,A,I,P,z]);return{menuRef:T,handleOptionSelect:E,options:Di}};import $e,{useRef as Li,useCallback as Ae,createContext as ji,useContext as Pu}from"react";var _t=(C={})=>{let{initialValue:T="",initialHeight:R=50,onValueChange:M,onHeightChange:S,onSend:A,onAttachmentSend:I,onReplyCancel:P,onFocus:z,onBlur:E,maxHeight:v=100,minHeight:k=50,maxLength:D=1e3,placeholder:V="Type a message..."}=C,B=Li(null),[L,F]=$e.useState(T),[j,H]=$e.useState(R),[N,O]=$e.useState(!1),[_,re]=$e.useState(null),[J,Ce]=$e.useState([]),Z=$e.useMemo(()=>({value:L,height:j,isFocused:N,replyToMessage:_,attachments:J}),[L,j,N,_,J]),ae=Ae(se=>{F(se),M?.(se)},[M]),oe=Ae(se=>{let Te=Math.max(k,Math.min(v,se));H(Te),S?.(Te)},[k,v,S]),we=Ae(()=>{O(!0),z?.()},[z]),W=Ae(()=>{O(!1),E?.()},[E]),Ie=Ae(se=>{let{height:Te}=se.nativeEvent.contentSize,Et=Math.max(k,Math.min(v,Te+16));oe(Et)},[k,v,oe]),Me=Ae(()=>{A&&(L||J.length>0)&&(A(L,J,_),F(T),Ce([]),re(null),H(R))},[A,L,J,_,T,R]),Ge=Ae(se=>{I?(I(se,L),L&&F(T)):Ce(Te=>[...Te,{...se,id:Date.now().toString()}])},[I,L,T]),Q=Ae(se=>{Ce(Te=>[...Te,se])},[]),ve=Ae(se=>{Ce(Te=>Te.filter(Et=>Et.id!==se))},[]),ze=Ae(()=>{Ce([])},[]),ee=Ae(()=>{re(null),P?.()},[P]),Tt=Ae(()=>{B.current?.focus()},[]),_e=$e.useMemo(()=>({setValue:ae,setHeight:oe,setFocus:O,setReplyToMessage:re,addAttachment:Q,removeAttachment:ve,clearAttachments:ze,sendMessage:Me,cancelReply:ee,focusInput:Tt,handleAttachmentSelected:Ge,handleContentSizeChange:Ie,handleFocus:we,handleBlur:W}),[ae,oe,O,re,Q,ve,ze,Me,ee,Tt,Ge,Ie,we,W]),Go=$e.useMemo(()=>({textInputRef:B}),[]);return{state:Z,actions:_e,refs:Go}},zu=ji(null);var Ee=Ei(({value:C,onChangeText:T,onSend:R,onFocus:M,height:S,onContentSizeChange:A,replyToMessage:I,onCancelReply:P,onAttachmentSend:z},E)=>{let v=q(),k=Pe(),D=Oi(null);Fi(E,()=>({focus:()=>{D.current?.focus()}}));let{state:V,actions:B}=_t({initialValue:C,initialHeight:S,onValueChange:T,onHeightChange:A,onSend:R,onAttachmentSend:z,onReplyCancel:P,onFocus:M});qo.useEffect(()=>{C!==V.value&&B.setValue(C)},[C,V.value,B]),qo.useEffect(()=>{S!==V.height&&B.setHeight(S)},[S,V.height,B]),qo.useEffect(()=>{I!==V.replyToMessage&&B.setReplyToMessage(I||null)},[I,V.replyToMessage,B]),qo.useEffect(()=>{if(I&&D.current){let j=setTimeout(()=>{D.current?.focus()},100);return()=>clearTimeout(j)}},[I]);let L=Hi(j=>{if(console.log("Attachment selected:",j),z)z(j,C.trim()||void 0),C.trim()&&T("");else switch(j.type){case"image":console.log("Image attachment ready to send:",{uri:j.data.uri,dimensions:{width:j.data.width,height:j.data.height},fileName:j.data.fileName});break;case"document":console.log("Document attachment ready to send:",{name:j.data.name,size:j.data.size});break;case"location":console.log("Location attachment ready to send:",j.data.coordinates);break;case"contact":console.log("Contact attachment ready to send:",j.data);break;default:console.log("Other attachment ready to send:",j)}},[z,C,T]),F=Ko(L);return<>
|
|
382
|
-
{I&&P&&<
|
|
383
|
-
<
|
|
384
|
-
<
|
|
385
|
-
<
|
|
386
|
-
<
|
|
387
|
-
</
|
|
363
|
+
</Mi>});Ct.displayName="AttachmentMenu";import{useEffect as Ci,useRef as Ri}from"react";import{View as Is,StyleSheet as Si,Animated as qe}from"react-native";var wi=({isVisible:M})=>{let R=Ri(new qe.Value(0)).current;return Ci(()=>{if(!M){R.setValue(0);return}let C=qe.loop(qe.sequence([qe.timing(R,{toValue:1,duration:1200,useNativeDriver:!0}),qe.timing(R,{toValue:0,duration:1200,useNativeDriver:!0})]));return C.start(),()=>{C.stop()}},[M,R]),M?<Is style={Ft.container}>
|
|
364
|
+
<Is style={Ft.bubble}>
|
|
365
|
+
<Is style={Ft.dotsContainer}>
|
|
366
|
+
<qe.View style={[Ft.dot,{opacity:R.interpolate({inputRange:[0,.5,1],outputRange:[.3,1,.3]}),transform:[{translateY:R.interpolate({inputRange:[0,.5,1],outputRange:[0,-4,0]})}]}]}/>
|
|
367
|
+
<qe.View style={[Ft.dot,{opacity:R.interpolate({inputRange:[.33,.83,1.33],outputRange:[.3,1,.3]}),transform:[{translateY:R.interpolate({inputRange:[.33,.83,1.33],outputRange:[0,-4,0]})}]}]}/>
|
|
368
|
+
<qe.View style={[Ft.dot,{opacity:R.interpolate({inputRange:[.66,1.16,1.66],outputRange:[.3,1,.3]}),transform:[{translateY:R.interpolate({inputRange:[.66,1.16,1.66],outputRange:[0,-4,0]})}]}]}/>
|
|
369
|
+
</Is>
|
|
370
|
+
</Is>
|
|
371
|
+
</Is>:null},Ft=Si.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}}),Ot=wi;import vs from"react";import{Pressable as Ii,Animated as Ps}from"react-native";import{ChevronDown as Pi}from"lucide-react-native";var Ai=({visible:M,onPress:R,isReplyActive:C=!1})=>{let T=$(),S=vs.useRef(new Ps.Value(0)).current,[A,I]=vs.useState(!1);return vs.useEffect(()=>{Ps.timing(S,{toValue:M?1:0,duration:200,useNativeDriver:!0}).start(()=>{I(M)})},[M,S]),!M&&!A?null:<Ii onPress={R}hitSlop={{top:10,bottom:10,left:10,right:10}}>
|
|
372
|
+
{({pressed:P})=><Ps.View style={[{position:"absolute",bottom:40,right:T.spacing.lg,zIndex:9999,width:32,height:32,backgroundColor:T.colors.background,borderRadius:T.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}]:[]}]}>
|
|
373
|
+
<Pi size={20}color={T.colors.text}/>
|
|
374
|
+
</Ps.View>}
|
|
375
|
+
</Ii>},Wo=Ai;import{View as Va,Text as Vi}from"react-native";var Di=({displayDate:M})=>{let R=$();return<Va style={{marginVertical:R.spacing.lg,alignItems:"center"}}>
|
|
376
|
+
<Va style={{borderRadius:R.borderRadius.full,backgroundColor:R.colors.surfaceSecondary,paddingHorizontal:R.spacing.md,paddingVertical:R.spacing.xs}}>
|
|
377
|
+
<Vi style={{fontSize:R.typography.fontSize.xs,color:R.colors.textSecondary,fontWeight:R.typography.fontWeight.medium}}>
|
|
378
|
+
{M}
|
|
379
|
+
</Vi>
|
|
380
|
+
</Va>
|
|
381
|
+
</Va>},Uo=Di;import $o,{forwardRef as $i,useRef as qi,useImperativeHandle as Yi,useCallback as Gi}from"react";import{View as Vs,TextInput as _i,TouchableOpacity as Da,Platform as Ba}from"react-native";import{Plus as Ji,Send as Xi,Mic as Zi}from"lucide-react-native";import{useRef as ki,useCallback as Ye}from"react";import{Alert as X}from"react-native";import{Camera as Li,Image as ji,MapPin as Ei,User as Fi,FileText as Oi,BarChart3 as Hi,Calendar as Ni}from"lucide-react-native";var Bi={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},As=async(M,R={})=>{try{let C;try{C=await import("expo-image-manipulator")}catch(B){console.log("expo-image-manipulator not available, returning original image info:",B);let V=`image_${Date.now()}.jpg`;return{uri:M,width:1920,height:1920,fileName:V}}let T={...Bi,...R};console.log("Starting image compression...",{uri:M,options:T});let S=await C.manipulateAsync(M,[],{});console.log("Original image info:",{width:S.width,height:S.height,uri:S.uri});let A=[];if(T.maxWidth||T.maxHeight){let{width:B,height:k}=S,V=B,D=k;if(T.maxWidth&&B>T.maxWidth){let L=T.maxWidth/B;V=T.maxWidth,D=k*L}if(T.maxHeight&&D>T.maxHeight){let L=T.maxHeight/D;D=T.maxHeight,V=V*L}(V!==B||D!==k)&&(A.push({resize:{width:Math.round(V),height:Math.round(D)}}),console.log("Resizing image:",{from:{width:B,height:k},to:{width:Math.round(V),height:Math.round(D)}}))}let I={compress:T.quality,format:T.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 z=Date.now(),E=T.format==="png"?"png":"jpg",v=`compressed_image_${z}.${E}`;return{uri:P.uri,width:P.width,height:P.height,fileName:v}}catch(C){console.error("Error compressing image:",C);let T=C instanceof Error?C.message:"Unknown error";throw new Error(`Failed to compress image: ${T}`)}},zs=(M,R)=>M>3e3||R>3e3?{maxWidth:1920,maxHeight:1920,quality:.7,format:"jpeg"}:M>1920||R>1920?{maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"}:{quality:.9,format:"jpeg"};var Wi=[{id:"photo",label:"Photo",icon:ji,color:"#3B82F6"},{id:"camera",label:"Camera",icon:Li,color:"#6B7280"},{id:"location",label:"Location",icon:Ei,color:"#10B981"},{id:"contact",label:"Contact",icon:Fi,color:"#6B7280"},{id:"document",label:"Document",icon:Oi,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Hi,color:"#F59E0B"},{id:"event",label:"Event",icon:Ni,color:"#EF4444"}],Ko=M=>{let R=ki(null),C=Ye(async()=>{console.log("Photo selection initiated");try{let v;try{v=await import("expo-image-picker")}catch(V){console.log("expo-image-picker not available:",V),X.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:B}=await v.requestMediaLibraryPermissionsAsync();if(console.log("Photo library permission status:",B),B!=="granted"){X.alert("Permission needed","Please grant photo library access to select images.");return}console.log("Waiting for UI to stabilize..."),await new Promise(V=>setTimeout(()=>V(void 0),300)),console.log("Launching image picker...");let k=await v.launchImageLibraryAsync({mediaTypes:"images",allowsEditing:!0,aspect:[4,3],quality:.8,allowsMultipleSelection:!1});if(console.log("Image picker result:",k),!k.canceled&&k.assets&&k.assets.length>0){let V=k.assets[0];console.log("Photo selected successfully:",V.uri);try{console.log("Starting image compression...");let D=zs(V.width||1920,V.height||1920),L=await As(V.uri,D);console.log("Image compression completed:",L),M?.({type:"image",data:{...L,originalFileSize:V.fileSize}})}catch(D){console.error("Image compression failed:",D),X.alert("Compression Error","Failed to compress image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:V.uri,width:V.width,height:V.height,fileSize:V.fileSize,fileName:V.fileName||"image.jpg"}})}}else console.log("Photo selection was canceled by user")}catch(v){console.error("Error in photo selection process:",v),X.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),T=Ye(async()=>{console.log("Camera capture initiated");try{let v;try{v=await import("expo-image-picker")}catch(V){console.log("expo-image-picker not available:",V),X.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:B}=await v.requestCameraPermissionsAsync();if(console.log("Camera permission status:",B),B!=="granted"){X.alert("Permission needed","Please grant camera access to take photos.");return}console.log("Waiting for UI to stabilize..."),await new Promise(V=>setTimeout(()=>V(void 0),300)),console.log("Launching camera...");let k=await v.launchCameraAsync({allowsEditing:!0,aspect:[4,3],quality:.8,mediaTypes:"images"});if(console.log("Camera result:",k),!k.canceled&&k.assets&&k.assets.length>0){let V=k.assets[0];console.log("Photo captured successfully:",V.uri);try{console.log("Starting camera image compression...");let D=zs(V.width||1920,V.height||1920),L=await As(V.uri,D);console.log("Camera image compression completed:",L),M?.({type:"image",data:{...L,originalFileSize:V.fileSize}})}catch(D){console.error("Camera image compression failed:",D),X.alert("Compression Error","Failed to compress captured image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:V.uri,width:V.width,height:V.height,fileSize:V.fileSize,fileName:V.fileName||"camera_photo.jpg"}})}}else console.log("Camera capture was canceled by user")}catch(v){console.error("Error in camera capture process:",v),X.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),S=Ye(async()=>{console.log("Location sharing initiated");try{let v;try{v=await import("expo-location")}catch(L){console.log("expo-location not available:",L),X.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:B}=await v.requestForegroundPermissionsAsync();if(console.log("Location permission status:",B),B!=="granted"){X.alert("Permission needed","Please grant location access to share your location.");return}console.log("Getting current location...");let k=await v.getCurrentPositionAsync({accuracy:v.Accuracy.High});console.log("Getting address from coordinates...");let V=await v.reverseGeocodeAsync({latitude:k.coords.latitude,longitude:k.coords.longitude}),D={coordinates:{latitude:k.coords.latitude,longitude:k.coords.longitude},address:V[0]||null,timestamp:k.timestamp};console.log("Location shared successfully:",D.coordinates),M?.({type:"location",data:D})}catch(v){console.error("Error in location sharing process:",v),X.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),A=Ye(async()=>{try{let v;try{v=await import("expo-contacts")}catch(k){console.log("expo-contacts not available:",k),X.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:B}=await v.requestPermissionsAsync();if(B!=="granted"){X.alert("Permission needed","Please grant contacts access to share contacts.");return}X.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),X.alert("Error","Failed to access contacts. Please try again.")}finally{R.current?.hide()}},[]),I=Ye(async()=>{console.log("Document selection initiated");try{let v;try{v=await import("expo-document-picker")}catch(k){console.log("expo-document-picker not available:",k),X.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(k=>setTimeout(()=>k(void 0),300)),console.log("Launching document picker...");let B=await v.getDocumentAsync({type:"*/*",copyToCacheDirectory:!0,multiple:!1});if(console.log("Document picker result:",B),!B.canceled&&B.assets&&B.assets.length>0){let k=B.assets[0];console.log("Document selected successfully:",k.name),M?.({type:"document",data:{uri:k.uri,name:k.name,size:k.size,mimeType:k.mimeType}})}else console.log("Document selection was canceled by user")}catch(v){console.error("Error in document selection process:",v),X.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[M]),P=Ye(()=>{X.alert("Create Poll","Poll creation feature is coming soon! This would open a poll creation interface.",[{text:"OK",onPress:()=>console.log("Poll creation acknowledged")}])},[]),z=Ye(()=>{X.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=Ye(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await C();break;case"camera":await T();break;case"location":await S();break;case"contact":await A();break;case"document":await I();break;case"poll":P();break;case"event":z();break;default:console.warn(`Unknown attachment option: ${v}`)}}catch(B){console.error(`Error handling ${v}:`,B),X.alert("Error",`Failed to handle ${v}. Please try again.`)}},[C,T,S,A,I,P,z]);return{menuRef:R,handleOptionSelect:E,options:Wi}};import Ge,{useRef as Ui,useCallback as Ae,createContext as Ki,useContext as Du}from"react";var Qt=(M={})=>{let{initialValue:R="",initialHeight:C=50,onValueChange:T,onHeightChange:S,onSend:A,onAttachmentSend:I,onReplyCancel:P,onFocus:z,onBlur:E,maxHeight:v=100,minHeight:B=50,maxLength:k=1e3,placeholder:V="Type a message..."}=M,D=Ui(null),[L,O]=Ge.useState(R),[j,H]=Ge.useState(C),[N,F]=Ge.useState(!1),[_,ne]=Ge.useState(null),[J,Me]=Ge.useState([]),Z=Ge.useMemo(()=>({value:L,height:j,isFocused:N,replyToMessage:_,attachments:J}),[L,j,N,_,J]),re=Ae(se=>{O(se),T?.(se)},[T]),oe=Ae(se=>{let Se=Math.max(B,Math.min(v,se));H(Se),S?.(Se)},[B,v,S]),Ie=Ae(()=>{F(!0),z?.()},[z]),W=Ae(()=>{F(!1),E?.()},[E]),ve=Ae(se=>{let{height:Se}=se.nativeEvent.contentSize,Wt=Math.max(B,Math.min(v,Se+16));oe(Wt)},[B,v,oe]),Te=Ae(()=>{A&&(L||J.length>0)&&(A(L,J,_),O(R),Me([]),ne(null),H(C))},[A,L,J,_,R,C]),Je=Ae(se=>{I?(I(se,L),L&&O(R)):Me(Se=>[...Se,{...se,id:Date.now().toString()}])},[I,L,R]),Q=Ae(se=>{Me(Se=>[...Se,se])},[]),Pe=Ae(se=>{Me(Se=>Se.filter(Wt=>Wt.id!==se))},[]),ze=Ae(()=>{Me([])},[]),ee=Ae(()=>{ne(null),P?.()},[P]),wt=Ae(()=>{D.current?.focus()},[]),Xe=Ge.useMemo(()=>({setValue:re,setHeight:oe,setFocus:F,setReplyToMessage:ne,addAttachment:Q,removeAttachment:Pe,clearAttachments:ze,sendMessage:Te,cancelReply:ee,focusInput:wt,handleAttachmentSelected:Je,handleContentSizeChange:ve,handleFocus:Ie,handleBlur:W}),[re,oe,F,ne,Q,Pe,ze,Te,ee,wt,Je,ve,Ie,W]),Go=Ge.useMemo(()=>({textInputRef:D}),[]);return{state:Z,actions:Xe,refs:Go}},ku=Ki(null);var Oe=$i(({value:M,onChangeText:R,onSend:C,onFocus:T,height:S,onContentSizeChange:A,replyToMessage:I,onCancelReply:P,onAttachmentSend:z},E)=>{let v=$(),B=Ce(),k=qi(null);Yi(E,()=>({focus:()=>{k.current?.focus()}}));let{state:V,actions:D}=Qt({initialValue:M,initialHeight:S,onValueChange:R,onHeightChange:A,onSend:C,onAttachmentSend:z,onReplyCancel:P,onFocus:T});$o.useEffect(()=>{M!==V.value&&D.setValue(M)},[M,V.value,D]),$o.useEffect(()=>{S!==V.height&&D.setHeight(S)},[S,V.height,D]),$o.useEffect(()=>{I!==V.replyToMessage&&D.setReplyToMessage(I||null)},[I,V.replyToMessage,D]),$o.useEffect(()=>{if(I&&k.current){let j=setTimeout(()=>{k.current?.focus()},100);return()=>clearTimeout(j)}},[I]);let L=Gi(j=>{if(console.log("Attachment selected:",j),z)z(j,M.trim()||void 0),M.trim()&&R("");else switch(j.type){case"image":console.log("Image attachment ready to send:",{uri:j.data.uri,dimensions:{width:j.data.width,height:j.data.height},fileName:j.data.fileName});break;case"document":console.log("Document attachment ready to send:",{name:j.data.name,size:j.data.size});break;case"location":console.log("Location attachment ready to send:",j.data.coordinates);break;case"contact":console.log("Contact attachment ready to send:",j.data);break;default:console.log("Other attachment ready to send:",j)}},[z,M,R]),O=Ko(L);return<>
|
|
382
|
+
{I&&P&&<Xt replyToMessage={I}onCancel={P}/>}
|
|
383
|
+
<Vs style={{borderTopWidth:1,borderTopColor:v.colors.borderLight,backgroundColor:v.colors.background}}>
|
|
384
|
+
<Vs style={{flexDirection:"row",alignItems:"center",backgroundColor:v.colors.background,paddingHorizontal:v.spacing.lg,paddingVertical:v.spacing.sm,minHeight:S}}>
|
|
385
|
+
<Da style={{marginRight:v.spacing.md}}onPress={()=>O.menuRef.current?.show()}>
|
|
386
|
+
<Ji size={24}color={v.colors.textSecondary}/>
|
|
387
|
+
</Da>
|
|
388
388
|
|
|
389
|
-
<
|
|
390
|
-
<
|
|
391
|
-
</
|
|
389
|
+
<Vs style={{flex:1,flexDirection:"row",alignItems:"center",borderRadius:v.borderRadius.full,backgroundColor:v.colors.surfaceSecondary,paddingHorizontal:v.spacing.lg,paddingVertical:6}}>
|
|
390
|
+
<_i ref={k}style={{flex:1,fontSize:v.typography.fontSize.base,maxHeight:70,minHeight:18,paddingTop:Ba.OS==="ios"?6:3,paddingBottom:Ba.OS==="ios"?6:3,color:v.colors.text}}value={M}onChangeText={R}placeholder={B("input.placeholder")}placeholderTextColor={v.colors.textMuted}multiline maxLength={1e3}onFocus={T}onContentSizeChange={D.handleContentSizeChange}returnKeyType='default'textAlignVertical='center'/>
|
|
391
|
+
</Vs>
|
|
392
392
|
|
|
393
|
-
<
|
|
394
|
-
{
|
|
395
|
-
</
|
|
396
|
-
</
|
|
397
|
-
</
|
|
393
|
+
<Da 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()}>
|
|
394
|
+
{M.trim()?<Xi size={18}color='white'/>:<Zi size={18}color='white'/>}
|
|
395
|
+
</Da>
|
|
396
|
+
</Vs>
|
|
397
|
+
</Vs>
|
|
398
398
|
|
|
399
|
-
<Ct ref={
|
|
400
|
-
</>});
|
|
401
|
-
{
|
|
402
|
-
</
|
|
403
|
-
<
|
|
404
|
-
<
|
|
405
|
-
<
|
|
406
|
-
<
|
|
407
|
-
<
|
|
408
|
-
<
|
|
409
|
-
</
|
|
410
|
-
</
|
|
411
|
-
{
|
|
412
|
-
<Pl style={{color:
|
|
399
|
+
<Ct ref={O.menuRef}onOptionSelect={O.handleOptionSelect}options={O.options}/>
|
|
400
|
+
</>});Oe.displayName="MessageInput";import{View as Yu,TextInput as Gu,TouchableOpacity as _u,Platform as Ju}from"react-native";import{Plus as Zu,Send as Qu,Mic as Mm}from"lucide-react-native";import Rl,{forwardRef as Sl}from"react";import rl,{createContext as nl,useContext as il,useMemo as ll}from"react";import{useMemo as el,useCallback as tl}from"react";function eo(M,R={}){let{initialNumToRender:C=20,maxToRenderPerBatch:T=10,windowSize:S=10}=R,A=el(()=>zo(M).reverse(),[M]),I=tl(P=>P.listItemType==="date-separator"?P.id:P.id.toString(),[]);return{messageItems:A,keyExtractor:I,flatListProps:{initialNumToRender:C,maxToRenderPerBatch:T,windowSize:S,inverted:!0,showsVerticalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",removeClippedSubviews:!1,scrollEventThrottle:16}}}import{useState as ol,useCallback as Rt,useRef as ka}from"react";function Ds(M={}){let{scrollThreshold:R=50,autoScrollToBottom:C=!0}=M,T=ka(null),[S,A]=ol({isNearBottom:!0,isNearTop:!1,showScrollToBottomButton:!1}),I=ka(0),P=Rt(D=>{let{contentOffset:L,contentSize:O,layoutMeasurement:j}=D.nativeEvent,H=L.y,N=Math.abs(H)<R,F=Math.abs(H)>O.height-j.height-R;A({isNearBottom:N,isNearTop:F,showScrollToBottomButton:!N})},[R]),z=Rt(D=>{let L=D>I.current;return I.current=D,L},[]),E=Rt(()=>{},[]),v=Rt((D=!0)=>{T.current&&T.current.scrollToOffset({offset:0,animated:D})},[]),B=Rt((D,L=!0)=>{T.current&&T.current.scrollToOffset({offset:D,animated:L})},[]),k=Rt((D,L=!0)=>{T.current&&T.current.scrollToIndex({index:D,animated:L})},[]),V=Rt(D=>{z(D)&&C&&T.current&&setTimeout(()=>{v()},100)},[z,C,v]);return{flatListRef:T,scrollState:S,handleScroll:P,handleContentSizeChange:E,handleNewMessages:V,scrollToEnd:v,scrollToOffset:B,scrollToIndex:k}}import{useState as sl,useCallback as Bs}from"react";function to(M={}){let{enableMessageActions:R=!0}=M,[C,T]=sl({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0}),S=Bs((P,z)=>{R&&T({actionSheetVisible:!0,selectedMessage:P,messagePosition:z})},[R]),A=Bs(()=>{T({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0})},[]),I=Bs((P,z)=>{if(!C.selectedMessage)return;let{selectedMessage:E}=C;switch(P){case"reply":z?.onReply?.(E);break;case"copy":if(z?.onCopy)z.onCopy(E);else{let v=E.type==="image"&&E.imageData?E.text||"Image message":E.text;import("./clipboard-O4FPD4J6.mjs").then(({copyToClipboard:B})=>{B(v)}).catch(()=>{console.log("Clipboard functionality not available")})}break;case"delete":z?.onDelete?.(E.id);break;default:z?.onCustomAction?.(P,E);break}A()},[C.selectedMessage,A]);return{actionState:C,handleMessageLongPress:S,handleActionSheetClose:A,handleActionPress:I}}import{useState as La,useCallback as oo}from"react";function so(M={}){let{enableReactionDetails:R=!0}=M,[C,T]=La({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),[S,A]=La(null),I=oo(B=>{R&&B.reactions&&B.reactions.length>0&&(A(B),T({isReactionDetailsVisible:!0,selectedReactions:B.reactions,selectedMessageText:B.text}))},[R]),P=oo(()=>{T({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),A(null)},[]),z=oo((B,k)=>{S&&k?.(S.id,B),P()},[S,P]),E=oo((B,k)=>{S&&k?.(S.id,B),P()},[S,P]),v=oo((B,k)=>{S&&k?.(S.id,B)},[S]);return{reactionState:C,selectedMessage:S,handleReactionPress:I,handleReactionDetailsClose:P,handleAddReaction:z,handleRemoveReaction:E,handleEmojiReact:v}}import{useState as al,useCallback as ja}from"react";function ks(){let[M,R]=al({replyToMessage:null}),C=ja(S=>{R({replyToMessage:S})},[]),T=ja(()=>{R({replyToMessage:null})},[]);return{replyState:M,setReplyToMessage:C,clearReply:T}}var Ea=nl(null);function Ht(){let M=il(Ea);if(!M)throw new Error("useMessageListContext must be used within MessageListProvider");return M}function Mo({children:M,messages:R,config:C={},...T}){let S=eo(R,C),A=Ds(C),I=to(C),P=so(C),z=ks();rl.useEffect(()=>{A.handleNewMessages(R.length)},[R.length,A.handleNewMessages]);let E=ll(()=>({messageList:S,scroll:A,actions:I,reactions:P,reply:z,config:C,callbacks:T}),[S,A,I,P,z,C,T]);return<Ea.Provider value={E}>
|
|
401
|
+
{M}
|
|
402
|
+
</Ea.Provider>}import{useCallback as qo}from"react";import{View as Ml,StyleSheet as Tl,FlatList as Cl}from"react-native";var _e={Provider:Mo,Container:({children:M,style:R})=><Ml style={[Fa.container,R]}>{M}</Ml>,Messages:({renderMessage:M,style:R})=>{let{messageList:C,scroll:T,actions:S,reactions:A,callbacks:I}=Ht(),P=qo(({item:E,index:v})=>M&&E.listItemType!=="date-separator"?M({message:E,index:v})||null:E.listItemType==="date-separator"?<Uo date={E.date}displayDate={E.displayDate}/>:<Fo message={E}onLongPress={S.handleMessageLongPress}onReactionPress={A.handleReactionPress}onReactionRemove={I.onReactionRemove}/>,[S.handleMessageLongPress,A.handleReactionPress,I.onReactionRemove,M]),z=qo(E=>{T.handleScroll(E);let{isNearBottom:v,isNearTop:B}=T.scrollState;I.onScrollPositionChange?.(v,B),v&&I.onScrollToBottom?.(),B&&I.onScrollToTop?.()},[T.handleScroll,T.scrollState,I]);return<Cl ref={T.flatListRef}data={C.messageItems}renderItem={P}keyExtractor={C.keyExtractor}contentContainerStyle={[Fa.contentContainer,R]}onContentSizeChange={T.handleContentSizeChange}onScroll={z}{...C.flatListProps}/>},TypingIndicator:({isVisible:M})=>M?<Ot isVisible={M}/>:null,ScrollButton:({visible:M,isReplyActive:R,onPress:C})=>{let{scroll:T}=Ht();return<Wo visible={M??T.scrollState.showScrollToBottomButton}onPress={C??T.scrollToEnd}isReplyActive={R}/>},ActionSheet:()=>{let{actions:M,reactions:R,reply:C,callbacks:T,config:S}=Ht(),A=qo(P=>{M.handleActionPress(P,{onReply:z=>{C.setReplyToMessage(z),T.onReplyMessage?.(z)},onDelete:T.onMessageDelete,onCustomAction:T.onActionPress})},[M.handleActionPress,C.setReplyToMessage,T]),I=qo(P=>{console.log("\u{1F525} MessageListCompound - handleEmojiReact called with emoji:",P);let z=M.actionState.selectedMessage;console.log("\u{1F525} MessageListCompound - selectedMessage:",z?.id,"callbacks.onReactionAdd exists:",!!T.onReactionAdd),z&&T.onReactionAdd?(console.log("\u{1F525} MessageListCompound - Calling onReactionAdd for message:",z.id,"emoji:",P),T.onReactionAdd(z.id,P)):console.log("\u{1F525} MessageListCompound - NOT calling onReactionAdd. selectedMessage:",!!z,"callback exists:",!!T.onReactionAdd)},[M.actionState.selectedMessage,T.onReactionAdd]);return S.enableMessageActions?<Oo 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:R,config:C}=Ht();return C.enableReactionDetails?<Ho visible={M.reactionState.isReactionDetailsVisible}onClose={M.handleReactionDetailsClose}reactions={M.reactionState.selectedReactions}messageText={M.reactionState.selectedMessageText}onRemoveReaction={T=>M.handleRemoveReaction(T,R.onReactionRemove)}/>:null}},Fa=Tl.create({container:{flex:1},contentContainer:{paddingVertical:16}});var He=Sl(({messages:M,isTyping:R,showScrollToBottom:C=!1,isReplyActive:T=!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 Rl.useImperativeHandle(A,()=>({scrollToEnd:(z=!0)=>{},scrollToOffset:(z,E=!0)=>{},scrollToIndex:(z,E=!0)=>{}}),[]),<Mo messages={M}config={I}{...P}>
|
|
403
|
+
<_e.Container>
|
|
404
|
+
<_e.Messages/>
|
|
405
|
+
<_e.TypingIndicator isVisible={R}/>
|
|
406
|
+
<_e.ScrollButton visible={C?void 0:!1}isReplyActive={T}/>
|
|
407
|
+
<_e.ActionSheet/>
|
|
408
|
+
<_e.ReactionDetails/>
|
|
409
|
+
</_e.Container>
|
|
410
|
+
</Mo>});He.displayName="MessageList";import wl from"react";function Re(M){let R=wl.forwardRef((T,S)=>(It(),<M{...T}ref={S}/>)),C=M.displayName||M.name||"Component";return R.displayName=`RequireAuth(${C})`,R}function De(M){return(...R)=>(It(),M(...R))}import{FlatList as Bl,RefreshControl as Ll}from"react-native";import{View as Co,Text as Yo,TouchableOpacity as Vl}from"react-native";import{View as Ls,Image as Il,Text as Pl}from"react-native";var Al=({avatar:M,isOnline:R=!1,size:C="medium"})=>{let T=$(),S=()=>{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=S(),P=A(),E=(()=>{switch(C){case"small":return 14;case"large":return 28;default:return 20}})();return<Ls style={{position:"relative"}}>
|
|
411
|
+
{M&&M.trim()!==""?<Il source={{uri:M}}style={[I,{borderRadius:T.borderRadius.full}]}resizeMode="cover"/>:<Ls style={[I,{borderRadius:T.borderRadius.full,backgroundColor:T.colors.primary,justifyContent:"center",alignItems:"center"}]}>
|
|
412
|
+
<Pl style={{color:T.colors.background,fontSize:E,fontWeight:"600"}}>
|
|
413
413
|
👤
|
|
414
414
|
</Pl>
|
|
415
|
-
</
|
|
415
|
+
</Ls>}
|
|
416
416
|
|
|
417
417
|
{}
|
|
418
|
-
{
|
|
419
|
-
</
|
|
420
|
-
<
|
|
421
|
-
<
|
|
422
|
-
</
|
|
418
|
+
{R&&<Ls style={[P,{position:"absolute",bottom:-2,right:-2,backgroundColor:T.colors.online,borderRadius:T.borderRadius.full,borderWidth:2,borderColor:T.colors.background}]}/>}
|
|
419
|
+
</Ls>},To=Al;var Dl=({item:M,onPress:R})=>{let C=$(),T=M.unreadCount&&M.unreadCount>0;return<Vl style={{flexDirection:"row",alignItems:"center",paddingHorizontal:C.spacing.lg,paddingVertical:C.spacing.md,borderBottomWidth:1,borderBottomColor:C.colors.borderLight,backgroundColor:T?C.colors.unread:C.colors.background}}onPress={()=>R(M)}>
|
|
420
|
+
<Co style={{marginRight:C.spacing.md}}>
|
|
421
|
+
<To avatar={M.avatar}isOnline={M.isOnline}size="medium"/>
|
|
422
|
+
</Co>
|
|
423
423
|
|
|
424
|
-
<
|
|
424
|
+
<Co style={{flex:1,marginRight:C.spacing.md}}>
|
|
425
425
|
{}
|
|
426
|
-
<
|
|
427
|
-
<Yo style={{fontSize:
|
|
428
|
-
{
|
|
426
|
+
<Co style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:C.spacing.xs}}>
|
|
427
|
+
<Yo style={{fontSize:C.typography.fontSize.base,flex:1,fontWeight:T?C.typography.fontWeight.bold:C.typography.fontWeight.semibold,color:C.colors.text}}>
|
|
428
|
+
{M.name}
|
|
429
429
|
</Yo>
|
|
430
|
-
<Yo style={{fontSize:
|
|
431
|
-
{
|
|
430
|
+
<Yo style={{fontSize:C.typography.fontSize.sm,marginLeft:C.spacing.sm,color:T?C.colors.gray[700]:C.colors.textSecondary,fontWeight:T?C.typography.fontWeight.medium:C.typography.fontWeight.normal}}>
|
|
431
|
+
{M.time}
|
|
432
432
|
</Yo>
|
|
433
|
-
</
|
|
433
|
+
</Co>
|
|
434
434
|
|
|
435
435
|
{}
|
|
436
|
-
<
|
|
437
|
-
<Yo style={{fontSize:
|
|
438
|
-
{
|
|
436
|
+
<Co style={{flexDirection:"row",alignItems:"center"}}>
|
|
437
|
+
<Yo style={{fontSize:C.typography.fontSize.sm,flex:1,color:T?C.colors.gray[800]:C.colors.textSecondary,fontWeight:T?C.typography.fontWeight.medium:C.typography.fontWeight.normal}}numberOfLines={1}>
|
|
438
|
+
{M.message}
|
|
439
439
|
</Yo>
|
|
440
|
-
{
|
|
441
|
-
<Yo style={{fontSize:
|
|
442
|
-
{
|
|
440
|
+
{M.unreadCount&&<Co style={{width:20,height:20,backgroundColor:C.colors.primary,borderRadius:C.borderRadius.full,alignItems:"center",justifyContent:"center",marginLeft:C.spacing.sm}}>
|
|
441
|
+
<Yo style={{fontSize:C.typography.fontSize.xs,color:"white",fontWeight:C.typography.fontWeight.bold}}>
|
|
442
|
+
{M.unreadCount}
|
|
443
443
|
</Yo>
|
|
444
|
-
</
|
|
445
|
-
</
|
|
446
|
-
</
|
|
447
|
-
</Vl>},
|
|
448
|
-
<
|
|
449
|
-
{
|
|
450
|
-
</
|
|
451
|
-
</El>},
|
|
452
|
-
<
|
|
453
|
-
<
|
|
444
|
+
</Co>}
|
|
445
|
+
</Co>
|
|
446
|
+
</Co>
|
|
447
|
+
</Vl>},Ro=Dl;var jl=({chats:M,onChatPress:R,onRefresh:C,refreshing:T=!1})=>{let S=({item:A})=><Ro item={A}onPress={R}/>;return<Bl data={M}renderItem={S}keyExtractor={A=>A.id}showsVerticalScrollIndicator={!1}style={{flex:1}}refreshControl={C?<Ll refreshing={T}onRefresh={C}tintColor="#007AFF"colors={["#007AFF"]}/>:void 0}/>},js=jl;import{View as El,Text as Fl}from"react-native";var Ol=({title:M})=>{let R=$();return<El style={{backgroundColor:R.colors.background,paddingHorizontal:R.spacing.lg,paddingVertical:R.spacing.lg,borderBottomWidth:1,borderBottomColor:R.colors.borderLight}}>
|
|
448
|
+
<Fl style={{fontSize:R.typography.fontSize.xxl,fontWeight:R.typography.fontWeight.bold,color:R.colors.text}}>
|
|
449
|
+
{M}
|
|
450
|
+
</Fl>
|
|
451
|
+
</El>},Es=Ol;import{View as Fs,TextInput as Hl,TouchableOpacity as Nl}from"react-native";import{Search as Wl,X as Ul}from"lucide-react-native";var Kl=({value:M,onChangeText:R,onClear:C,placeholder:T})=>{let S=$(),I=Ce()("search.placeholder");return<Fs style={{backgroundColor:S.colors.background,paddingHorizontal:S.spacing.lg,paddingVertical:S.spacing.md,borderBottomWidth:1,borderBottomColor:S.colors.borderLight}}>
|
|
452
|
+
<Fs style={{position:"relative"}}>
|
|
453
|
+
<Fs style={{position:"absolute",left:S.spacing.md,top:"50%",transform:[{translateY:-10}],zIndex:10}}>
|
|
454
454
|
<Wl size={20}color={S.colors.textMuted}/>
|
|
455
|
-
</
|
|
455
|
+
</Fs>
|
|
456
456
|
|
|
457
|
-
<Hl value={
|
|
457
|
+
<Hl value={M}onChangeText={R}placeholder={T||I}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"/>
|
|
458
458
|
|
|
459
|
-
{
|
|
459
|
+
{M.length>0&&<Nl onPress={C}style={{position:"absolute",right:S.spacing.md,top:"50%",transform:[{translateY:-10}]}}hitSlop={{top:10,bottom:10,left:10,right:10}}>
|
|
460
460
|
<Ul size={20}color={S.colors.textMuted}/>
|
|
461
461
|
</Nl>}
|
|
462
|
-
</
|
|
463
|
-
</
|
|
462
|
+
</Fs>
|
|
463
|
+
</Fs>},Os=Kl;import{useState as $l,useCallback as Nt}from"react";import Hs from"dayjs";var St=Hs(),Oa=St.subtract(1,"day"),Ha=St.subtract(2,"day"),Na=St.subtract(3,"day"),ql=[{id:1,text:"Hi! How are you?",isMe:!1,timestamp:Na.hour(10).minute(30).toISOString(),senderName:"Anna"},{id:2,text:"Hey! Great, thanks! And you?",isMe:!0,timestamp:Na.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:Ha.hour(14).minute(20).toISOString(),senderName:"Anna"},{id:4,text:"Maybe we could go to the movies?",isMe:!0,timestamp:Ha.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:Oa.hour(9).minute(15).toISOString(),senderName:"Anna"},{id:6,text:"Great! What movies are you interested in?",isMe:!0,timestamp:Oa.hour(9).minute(20).toISOString()},{id:7,text:"Maybe something action or comedy?",isMe:!1,timestamp:St.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:St.hour(8).minute(35).toISOString()},{id:9,text:"Perfect! What time should we meet?",isMe:!1,timestamp:St.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:St.hour(9).minute(15).toISOString(),reactions:[{emoji:"\u{1F44D}",count:1,users:["anna"]},{emoji:"\u23F0",count:1,users:["me"]}]}],Ns=M=>{let R=ql.map(v=>v.isMe?v:{...v,senderName:M||v.senderName}),[C,T]=$l(R),S=Nt((v,B)=>{if(console.log("sendMessage called with text:",v,"and replyTo:",B),!v.trim())return;let k={id:Date.now(),text:v.trim(),isMe:!0,timestamp:Hs().toISOString(),status:"sent",replyTo:B};T(V=>[...V,k]),setTimeout(()=>{T(V=>V.map(D=>D.id===k.id?{...D,status:"delivered"}:D))},1e3),setTimeout(()=>{T(V=>V.map(D=>D.id===k.id?{...D,status:"read"}:D))},3e3)},[]),A=Nt((v,B,k)=>{let V={id:Date.now(),text:B||"",isMe:!0,timestamp:Hs().toISOString(),status:"sent",type:"image",imageData:v,replyTo:k};T(D=>[...D,V]),setTimeout(()=>{T(D=>D.map(L=>L.id===V.id?{...L,status:"delivered"}:L))},1e3),setTimeout(()=>{T(D=>D.map(L=>L.id===V.id?{...L,status:"read"}:L))},3e3)},[]),I=Nt((v,B)=>{T(k=>k.map(V=>V.id===v?{...V,status:B}:V))},[]),P=Nt((v,B)=>{T(k=>k.map(V=>{if(V.id===v){let D=V.reactions||[],L=D.findIndex(O=>O.emoji===B);if(L>=0){let O=[...D];return O[L]={...O[L],count:O[L].count+1,users:[...O[L].users,"me"]},{...V,reactions:O}}else{let O={emoji:B,count:1,users:["me"]};return{...V,reactions:[...D,O]}}}return V}))},[]),z=Nt((v,B)=>{console.log("removeReaction 1212121 called with messageId:",v,"and emoji:",B),T(k=>k.map(V=>{if(V.id===v){let D=V.reactions||[],L=D.findIndex(O=>O.emoji===B);if(L>=0){let O=D[L];if(O.count>1){let j=[...D];return j[L]={...O,count:O.count-1,users:O.users.filter(H=>H!=="me")},{...V,reactions:j}}else return{...V,reactions:D.filter(j=>j.emoji!==B)}}}return V}))},[]),E=Nt(v=>{console.log("deleteMessage called with messageId:",v),T(B=>{let k=B.map(V=>V.id===v?{...V,deleted:!0}:V);return console.log("Message marked as deleted:",v),k})},[]);return{messages:C,sendMessage:S,sendImageMessage:A,updateMessageStatus:I,addReaction:P,deleteMessage:E,removeReaction:z}};import{useState as Wa,useCallback as Fe}from"react";var Ws=(M={})=>{It();let[R,C]=Wa(M.initialMessages||[]),[T,S]=Wa(!1),A=Fe((D,L)=>{let O={id:Date.now(),text:D,isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:L?{id:L.id,text:L.text,senderName:L.senderName,isMe:L.isMe}:void 0};C(j=>[O,...j])},[]),I=Fe(D=>{C(L=>[D,...L])},[]),P=Fe((D,L)=>{C(O=>O.map(j=>j.id===D?{...j,...L}:j))},[]),z=Fe(D=>{C(L=>L.filter(O=>O.id!==D))},[]),E=Fe((D,L)=>{C(O=>O.map(j=>{if(j.id!==D)return j;let H=j.reactions||[];if(H.find(F=>F.emoji===L))return{...j,reactions:H.map(F=>F.emoji===L?{...F,count:F.count+1,users:[...F.users,"current-user"]}:F)};{let F={emoji:L,count:1,users:["current-user"]};return{...j,reactions:[...H,F]}}}))},[]),v=Fe((D,L)=>{C(O=>O.map(j=>{if(j.id!==D)return j;let H=j.reactions||[],N=H.find(F=>F.emoji===L);return N?N.count<=1?{...j,reactions:H.filter(F=>F.emoji!==L)}:{...j,reactions:H.map(F=>F.emoji===L?{...F,count:F.count-1,users:F.users.filter(_=>_!=="current-user")}:F)}:j}))},[]),B=Fe(D=>{S(D)},[]),k=Fe(()=>{C(M.initialMessages||[]),S(!1)},[M.initialMessages]),V=Fe(D=>R.find(L=>L.id===D),[R]);return{messages:R,isTyping:T,sendMessage:A,addReaction:E,removeReaction:v,setMessages:C,addMessage:I,updateMessage:P,deleteMessage:z,setTyping:B,resetChat:k,getMessageById:V}};import{useState as up,useCallback as mp,useRef as gp,useEffect as pp}from"react";var Ua=()=>{let M=Ce(),R=()=>"en";return{formatDate:P=>Qs(P,M,R()),formatTime:P=>Gt(P,R()),formatRelative:P=>ea(P,R()),formatDateTimeWithTime:P=>ta(P,M,R()),groupMessages:P=>zo(P,R())}};var Wp=Re(es),Up=Re(Jo),Kp=De(Kt),qp=Re(He),Yp=Re(Oe),_p=Re(Ao),Xp=Re(Ot),Qp=Re(js),eh=Re(Ro),th=Re(Es),oh=Re(Os),rh=Re(To),nh=Re(Ct),ch=Re(Zs),dh=De($),hh=De(Ws),fh=De(Ns),yh=De(eo),xh=De(to),bh=De(so),Mh=De(qt),Ch=De(Qt),Sh=De(Ua);export{nh as AttachmentMenu,Wp as Chat,rh as ChatAvatar,th as ChatHeader,eh as ChatItem,Qp as ChatList,oh as ChatListSearchBar,Up as ChatProvider,_p as ChatScreenHeader,Io as I18nProvider,Yp as MessageInput,qp as MessageList,ch as ThemeProvider,Xp as TypingIndicator,Yt as defaultTheme,So as defaultTranslations,Ka as getAuthState,$a as getProjectId,Ut as getTranslation,Ya as initChat,qa as isInitialized,wo as isSupportedLocale,Mh as useAttachments,Kp as useChatConfig,fh as useChatMessages,hh as useChatSDK,Sh as useDateFormatter,xh as useMessageActions,Ch as useMessageInput,yh as useMessageList,bh as useMessageReactions,dh as useTheme,Ys as useTranslation,Ce as useTranslationFunction};
|