@usechat/react-native 1.0.14 → 1.0.16
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 +238 -238
- package/dist/index.mjs +340 -340
- package/package.json +18 -15
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var ea=Object.create;var So=Object.defineProperty;var ta=Object.getOwnPropertyDescriptor;var oa=Object.getOwnPropertyNames;var sa=Object.getPrototypeOf,aa=Object.prototype.hasOwnProperty;var na=(M,R)=>()=>(M&&(R=M(M=0)),R);var fs=(M,R)=>{for(var T in R)So(M,T,{get:R[T],enumerable:!0})},ys=(M,R,T,C)=>{if(R&&typeof R=="object"||typeof R=="function")for(let S of oa(R))!aa.call(M,S)&&S!==T&&So(M,S,{get:()=>R[S],enumerable:!(C=ta(R,S))||C.enumerable});return M};var $=(M,R,T)=>(T=M!=null?ea(sa(M)):{},ys(R||!M||!M.__esModule?So(T,"default",{value:M,enumerable:!0}):T,M)),ra=M=>ys(So({},"__esModule",{value:!0}),M);var qs={};fs(qs,{copyToClipboard:()=>Ba,isClipboardAvailable:()=>Da});var Ba,Da,Ys=na(()=>{"use strict";Ba=async M=>{console.log("copyToClipboard called with text:",M);try{try{let{setStringAsync:R}=await import("expo-clipboard");console.log("expo-clipboard imported successfully"),console.log("setStringAsync function:",R),await R(M),console.log("Text copied to clipboard successfully")}catch(R){throw console.error("Failed to import expo-clipboard:",R),new Error("expo-clipboard not available")}try{let R=await import("react-native-toast-message"),T=R.default||R;console.log("react-native-toast-message imported successfully"),T.show({type:"success",text1:"Copied to clipboard",text2:"Message copied successfully",position:"bottom",visibilityTime:2e3}),console.log("Toast shown successfully")}catch(R){console.log("Toast not available, but message copied to clipboard"),console.error("Toast import error:",R)}return!0}catch(R){console.error("Failed to copy to clipboard:",R);try{let T=await import("react-native-toast-message");(T.default||T).show({type:"error",text1:"Copy failed",text2:"Failed to copy message to clipboard",position:"bottom",visibilityTime:2e3})}catch(T){console.error("Copy failed: expo-clipboard not available"),console.error("Toast import error:",T)}return!1}},Da=async()=>{try{return await import("expo-clipboard"),!0}catch{return!1}}});var dn={};fs(dn,{AttachmentMenu:()=>Za,Chat:()=>Ha,ChatAvatar:()=>Xa,ChatHeader:()=>_a,ChatItem:()=>Ga,ChatList:()=>$a,ChatListSearchBar:()=>Ja,ChatProvider:()=>Na,ChatScreenHeader:()=>qa,I18nProvider:()=>$t,MessageInput:()=>Ka,MessageList:()=>Ua,ThemeProvider:()=>Qa,TypingIndicator:()=>Ya,defaultTheme:()=>At,defaultTranslations:()=>qt,getAuthState:()=>Ms,getProjectId:()=>Ts,getTranslation:()=>Pt,initChat:()=>Rs,isInitialized:()=>Cs,isSupportedLocale:()=>Yt,useAttachments:()=>rn,useChatConfig:()=>Wa,useChatMessages:()=>on,useChatSDK:()=>tn,useDateFormatter:()=>cn,useMessageActions:()=>an,useMessageInput:()=>ln,useMessageList:()=>sn,useMessageReactions:()=>nn,useTheme:()=>en,useTranslation:()=>Qo,useTranslationFunction:()=>ke});module.exports=ra(dn);var lt={isInitialized:!1,projectId:null,error:null},xs=M=>{lt={isInitialized:!0,projectId:M,error:null}},bs=M=>{lt={isInitialized:!1,projectId:null,error:M}};var Ms=()=>({...lt}),vt=()=>{if(lt.error)throw new Error(`UseChat SDK initialization failed: ${lt.error}
|
|
3
3
|
|
|
4
4
|
Please call initChat() with a valid project ID before using any UseChat components or hooks.
|
|
5
5
|
|
|
@@ -11,38 +11,38 @@ 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
|
-
</
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<
|
|
14
|
+
await initChat({ projectId: 'your-project-id' });`)},Ts=()=>(vt(),lt.projectId),Cs=()=>lt.isInitialized&&!lt.error;var Rs=async M=>{let{projectId:R,debug:T=!1}=M;if(!R){let C="Project ID is required";throw bs(C),new Error(C)}return T&&console.log(`[UseChat SDK] Initializing with projectId: ${R}`),xs(R),T&&console.log(`[UseChat SDK] Successfully initialized with projectId: ${R}`),{success:!0,message:"Chat SDK initialized",projectId:R,activatedAt:new Date().toISOString()}};var Pe=$(require("react")),rt=require("react-native");var wo=require("react"),Ss=require("react-native"),Io=require("react-native-keyboard-controller");var at=require("react");var ia={"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}}"},la={"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}}"},qt={en:ia,pl:la},Pt=M=>qt[M]||qt.en,Yt=M=>M==="en"||M==="pl";var Zo=(0,at.createContext)(void 0),$t=({children:M,locale:R="en",fallbackLocale:T="en"})=>{let[C,S]=(0,at.useState)(R),V=(0,at.useCallback)((D,E={})=>{let B=Pt(C)[D];return!B&&C!==T&&(B=Pt(T)[D]),B?B.replace(/\{\{(\w+)\}\}/g,(k,A)=>E[A]?.toString()||k):(console.warn(`Translation missing for key: ${D} in locale: ${C}`),D)},[C,T]),I=(0,at.useCallback)(D=>{Yt(D)?S(D):(console.warn(`Unsupported locale: ${D}. Falling back to 'en'`),S("en"))},[]),P={t:V,locale:C,setLocale:I};return<Zo.Provider value={P}>
|
|
15
|
+
{M}
|
|
16
|
+
</Zo.Provider>},Qo=()=>{let M=(0,at.useContext)(Zo);if(!M)throw new Error("useTranslation must be used within an I18nProvider");return M},ke=()=>{let M=(0,at.useContext)(Zo);return M?M.t:R=>R};var ws=(0,wo.createContext)(null),ca=({children:M,config:R={},locale:T="en"})=>{let C={keyboardBehavior:"padding",keyboardVerticalOffset:60,enableReactionDetails:!0,enableMessageActions:!0,enableScrollToBottom:!0,enableTypingIndicator:!0,...R};return<$t locale={T}>
|
|
17
|
+
<ws.Provider value={{config:C}}>
|
|
18
|
+
<Io.KeyboardProvider>
|
|
19
|
+
<Io.KeyboardAvoidingView behavior={C.keyboardBehavior}style={[da.keyboardContainer]}keyboardVerticalOffset={C.keyboardVerticalOffset}>
|
|
20
20
|
{}
|
|
21
|
-
{
|
|
22
|
-
</
|
|
23
|
-
</
|
|
24
|
-
</
|
|
25
|
-
|
|
26
|
-
{N||<
|
|
21
|
+
{M}
|
|
22
|
+
</Io.KeyboardAvoidingView>
|
|
23
|
+
</Io.KeyboardProvider>
|
|
24
|
+
</ws.Provider>
|
|
25
|
+
</$t>},es=ca,Gt=()=>{let M=(0,wo.useContext)(ws);if(!M)throw new Error("useChatConfig must be used within a ChatProvider");return M.config},da=Ss.StyleSheet.create({container:{flex:1},keyboardContainer:{flex:1,overflow:"hidden"}});var nt=require("react"),_t=(M={})=>{let{uploader:R,maxAttachments:T=10,maxFileSize:C=10*1024*1024,allowedTypes:S=["image/*","application/pdf","text/*"],onAttachmentAdd:V,onAttachmentRemove:I,onAttachmentUpload:P}=M,[D,E]=(0,nt.useState)([]),[v,B]=(0,nt.useState)(!1),[k,A]=(0,nt.useState)(0),z=(0,nt.useCallback)(N=>{if(D.length>=T){console.warn(`Maximum ${T} attachments allowed`);return}if(N.data?.size&&N.data.size>C){console.warn(`File size exceeds ${C/(1024*1024)}MB limit`);return}if(N.data?.type&&!S.some(je=>je.endsWith("/*")?N.data.type.startsWith(je.slice(0,-1)):N.data.type===je)){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(te=>[...te,F]),V&&V(F)},[D.length,T,C,S,V]),L=(0,nt.useCallback)(N=>{E(F=>F.filter(te=>te.id!==N)),I&&I(N)},[I]),O=(0,nt.useCallback)(()=>{E([])},[]),j=(0,nt.useCallback)(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 te={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};z(te)}catch(F){console.error("Error opening picker:",F)}},[z]),H=(0,nt.useCallback)(async()=>{if(!R)return console.warn("No uploader provided, skipping upload"),D;if(D.length===0)return[];B(!0),A(0);try{let N=D.map(async(Me,Ee)=>{try{E(Ye=>Ye.map(U=>U.id===Me.id?{...U,uploadStatus:"uploading",uploadProgress:0}:U));let Te=setInterval(()=>{E(Ye=>Ye.map(U=>U.id===Me.id?{...U,uploadProgress:Math.min((U.uploadProgress??0)+10,90)}:U))},100),De=await R.upload(Me.data);clearInterval(Te);let Ae={...Me,uploadStatus:"completed",uploadProgress:100,data:{...Me.data,url:De.url,metadata:De.metadata}};return E(Ye=>Ye.map(U=>U.id===Me.id?Ae:U)),Ae}catch(Te){return console.error(`Error uploading attachment ${Me.id}:`,Te),E(De=>De.map(Ae=>Ae.id===Me.id?{...Ae,uploadStatus:"failed",uploadProgress:0}:Ae)),{...Me,uploadStatus:"failed",uploadProgress:0}}}),F=await Promise.all(N),je=F.filter(Me=>Me.uploadStatus==="completed").length/F.length*100;return A(je),P&&P(F),F}catch(N){return console.error("Error uploading attachments:",N),D}finally{B(!1)}},[D,R,P]);return{attachments:D,openPicker:j,addAttachment:z,removeAttachment:L,clearAttachments:O,uploadAttachments:H,isUploading:v,uploadProgress:k}};var _e=require("react"),Is=(M={})=>{let{onSend:R,onFocus:T,initialValue:C="",maxLength:S=1e3}=M,[V,I]=(0,_e.useState)(C),[P,D]=(0,_e.useState)(40),[E,v]=(0,_e.useState)(!1),B=(0,_e.useCallback)(H=>{H.length<=S&&I(H)},[S]),k=(0,_e.useCallback)(H=>{if(!V.trim()&&(!H||H.length===0))return;let N=V.trim();R&&R(N,H),I(""),D(40)},[V,R]),A=(0,_e.useCallback)(()=>{v(!0),T&&T()},[T]),z=(0,_e.useCallback)(()=>{v(!1)},[]),L=(0,_e.useCallback)(H=>{D(Math.max(40,Math.min(H,120)))},[]),O=(0,_e.useCallback)(()=>{I(""),D(40)},[]),j=(0,_e.useCallback)(H=>{I(H)},[]);return{message:V,composerHeight:P,isFocused:E,handleTextChange:B,handleSend:k,handleFocus:A,handleBlur:z,handleContentSizeChange:L,clearMessage:O,setMessage:j}};var ua=({messages:M,components:R={},renderProps:T={},onMessageSend:C,onReactionAdd:S,onReactionRemove:V,onMessageDelete:I,onActionPress:P,attachmentUploader:D,maxAttachments:E=10,maxFileSize:v=10*1024*1024,allowedFileTypes:B=["image/*","application/pdf","text/*"],enableReactionDetails:k,enableMessageActions:A=!0,enableScrollToBottom:z,enableTypingIndicator:L,isTyping:O=!1,typingUserName:j,isLoading:H=!1,loadingComponent:N})=>{let F=Gt(),[te,je]=(0,Pe.useState)(!1),Me=R.MessageList||pt,Ee=R.MessageInput||mt,Te=k??F.enableReactionDetails??!0,De=A??F.enableMessageActions??!0,Ae=z??F.enableScrollToBottom??!0,Ye=L??F.enableTypingIndicator??!0,[U,$e]=(0,Pe.useState)(null),Fe=(0,Pe.useRef)(null),[Tt,Ce]=(0,Pe.useState)(M||[]),Ge=(0,Pe.useRef)((M||[]).length+1);Pe.default.useEffect(()=>{M&&(Ce(M),Ge.current=M.length+1)},[M]),Pe.default.useEffect(()=>{if(U&&Fe.current){let K=setTimeout(()=>{Fe.current?.focus()},150);return()=>clearTimeout(K)}},[U]);let Xe=_t({uploader:D,maxAttachments:E,maxFileSize:v,allowedTypes:B}),we=Is({onSend:(K,_)=>{if(U){let X={id:U.id,text:U.text,senderName:U.senderName,senderId:U.senderId,isMe:U.isMe,timestamp:U.timestamp,type:U.type==="image"?"image":"text",imageData:U.imageData};if(_&&_.length>0){let q=_[0],ve={id:Ge.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:X,attachments:_,type:q.type==="image"?"image":"text",...q.type==="image"&&q.data&&{imageData:{uri:q.data.uri||"",width:q.data.width||300,height:q.data.height||200,fileName:q.fileName||"image.jpg",fileSize:q.fileSize||0}}};Ce(Ze=>[...Ze,ve]),C&&C(ve)}else{let q={id:Ge.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:X};Ce(ve=>[...ve,q]),C&&C(q)}$e(null)}else if(_&&_.length>0){let X=_[0],q={id:Ge.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",attachments:_,type:X.type==="image"?"image":"text",...X.type==="image"&&X.data&&{imageData:{uri:X.data.uri||"",width:X.data.width||300,height:X.data.height||200,fileName:X.fileName||"image.jpg",fileSize:X.fileSize||0}}};Ce(ve=>[...ve,q]),C&&C(q)}else{let X={id:Ge.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent"};Ce(q=>[...q,X]),C&&C(X)}Xe.clearAttachments()},onFocus:()=>{}}),It=(0,Pe.useCallback)((K,_)=>{console.log("\u{1F525} Chat - addReaction called with messageId:",K,"and emoji:",_),Ce(X=>X.map(q=>q.id===K?q.reactions?.find(Ze=>Ze.emoji===_)?{...q,reactions:q.reactions?.map(Ze=>Ze.emoji===_?{...Ze,count:Ze.count+1,users:[...Ze.users,"currentUser"]}:Ze)}:{...q,reactions:[...q.reactions||[],{emoji:_,count:1,users:["currentUser"]}]}:q)),S&&S(K,_)},[S]),Ct=(0,Pe.useCallback)((K,_)=>{Ce(X=>X.map(q=>q.id===K?{...q,reactions:q.reactions?.map(ve=>ve.emoji===_?{...ve,count:Math.max(0,ve.count-1),users:ve.users.filter(Ze=>Ze!=="currentUser")}:ve).filter(ve=>ve.count>0)}:q)),V&&V(K,_)},[V]),Xo=(0,Pe.useCallback)(K=>{Ce(_=>_.map(X=>X.id===K?{...X,deleted:!0,text:"",reactions:void 0}:X)),I&&I(K)},[I]),ze=(0,Pe.useCallback)(()=>{$e(null)},[]),Ne=(0,Pe.useCallback)(K=>{$e(K),setTimeout(()=>{Fe.current?.focus()},100)},[]),Kt=(0,Pe.useCallback)(K=>{if(te)return;let{layout:_}=K.nativeEvent;_.height<=0||je(!0)},[te]);if(H)return<rt.View style={Rt.container}>
|
|
26
|
+
{N||<rt.View style={Rt.loadingContainer}>
|
|
27
27
|
{}
|
|
28
|
-
</
|
|
29
|
-
</
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
</
|
|
33
|
-
</
|
|
34
|
-
<
|
|
35
|
-
<
|
|
28
|
+
</rt.View>}
|
|
29
|
+
</rt.View>;if(!te)return<rt.View style={Rt.container}>
|
|
30
|
+
<rt.View style={Rt.chatContainer}onLayout={Kt}>
|
|
31
|
+
<rt.View style={Rt.loadingContainer}>{N}</rt.View>
|
|
32
|
+
</rt.View>
|
|
33
|
+
</rt.View>;let hs=T.renderInput;return<rt.View style={Rt.container}>
|
|
34
|
+
<rt.View style={Rt.fill}>
|
|
35
|
+
<Me messages={Tt}isTyping={Ye?O:!1}typingUserName={j}showScrollToBottom={Ae}isReplyActive={!!U}enableMessageActions={De}enableReactionDetails={Te}onReactionAdd={It}onReactionRemove={Ct}onMessageDelete={Xo}onReplyMessage={Ne}onActionPress={(K,_)=>{K==="reply"?Ne(_):P?.(K,_)}}/>
|
|
36
36
|
|
|
37
|
-
{
|
|
37
|
+
{hs?hs({value:we.message,onChangeText:we.handleTextChange,onSend:we.handleSend,onFocus:we.handleFocus,height:we.composerHeight,onContentSizeChange:we.handleContentSizeChange,replyToMessage:U,onCancelReply:ze,attachments:Xe.attachments,onAttachmentAdd:Xe.addAttachment,onAttachmentRemove:Xe.removeAttachment,onAttachmentUpload:Xe.uploadAttachments}):<Ee ref={Fe}value={we.message}onChangeText={we.handleTextChange}onSend={we.handleSend}onFocus={we.handleFocus}height={we.composerHeight}onContentSizeChange={we.handleContentSizeChange}replyToMessage={U}onCancelReply={ze}onAttachmentSend={(K,_)=>{let X=K.type==="image",q={id:Ge.current++,text:_?.trim()||"",isMe:!0,timestamp:new Date().toISOString(),status:"sent",type:X?"image":"text",...X&&K.data&&{imageData:{uri:K.data.uri||"",width:K.data.width||300,height:K.data.height||200,fileName:K.data.fileName||K.data.name||"image.jpg",fileSize:K.data.fileSize||K.data.size||0}}};Ce(ve=>[...ve,q]),C&&C(q),we.handleTextChange("")}}/>}
|
|
38
38
|
|
|
39
39
|
{}
|
|
40
|
-
</
|
|
40
|
+
</rt.View>
|
|
41
41
|
|
|
42
42
|
{}
|
|
43
|
-
</
|
|
43
|
+
</rt.View>},Rt=rt.StyleSheet.create({container:{flex:1},chatContainer:{flex:1,overflow:"hidden"},fill:{flex:1},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center"}}),ts=ua;var Ie=require("react-native"),gt=require("lucide-react-native");var Ps=require("react");var vo=require("react");var At={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 os=(0,vo.createContext)(At),ma=(M,R)=>({colors:{...M.colors,...R.colors},spacing:{...M.spacing,...R.spacing},borderRadius:{...M.borderRadius,...R.borderRadius},typography:{...M.typography,...R.typography}}),vs=({children:M,theme:R})=>{let T=(0,vo.useMemo)(()=>R?ma(At,R):At,[R]);return<os.Provider value={T}>{M}</os.Provider>};var Y=()=>{let M=(0,Ps.useContext)(os);if(!M)throw new Error("useTheme must be used within a ThemeProvider");return M};var pa=({name:M="George Alan",isOnline:R=!0,onBack:T=()=>{},onVideoCall:C=()=>{},onVoiceCall:S=()=>{},onInfo:V=()=>{}})=>{let I=Y(),P=ke();return<Ie.View 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
44
|
<Ie.View style={{flex:1,flexDirection:"row",alignItems:"center"}}>
|
|
45
|
-
<Ie.TouchableOpacity onPress={
|
|
45
|
+
<Ie.TouchableOpacity onPress={T}style={{marginRight:I.spacing.md}}>
|
|
46
46
|
<gt.ArrowLeft size={24}color={I.colors.gray[700]}/>
|
|
47
47
|
</Ie.TouchableOpacity>
|
|
48
48
|
|
|
@@ -59,7 +59,7 @@ await initChat({ projectId: 'your-project-id' });`)},vs=()=>(At(),lt.projectId),
|
|
|
59
59
|
|
|
60
60
|
<Ie.View style={{flex:1}}>
|
|
61
61
|
<Ie.Text style={{fontSize:I.typography.fontSize.lg,fontWeight:I.typography.fontWeight.semibold,color:I.colors.text}}>
|
|
62
|
-
{
|
|
62
|
+
{M}
|
|
63
63
|
</Ie.Text>
|
|
64
64
|
<Ie.Text style={{fontSize:I.typography.fontSize.sm,color:I.colors.textSecondary}}>
|
|
65
65
|
{P(R?"status.online":"status.offline")}
|
|
@@ -70,42 +70,42 @@ await initChat({ projectId: 'your-project-id' });`)},vs=()=>(At(),lt.projectId),
|
|
|
70
70
|
|
|
71
71
|
<Ie.View style={{flexDirection:"row",alignItems:"center",gap:I.spacing.lg}}>
|
|
72
72
|
{}
|
|
73
|
-
{
|
|
73
|
+
{C&&<Ie.TouchableOpacity onPress={C}>
|
|
74
74
|
<gt.Video size={24}color={I.colors.gray[700]}/>
|
|
75
75
|
</Ie.TouchableOpacity>}
|
|
76
76
|
{S&&<Ie.TouchableOpacity onPress={S}>
|
|
77
77
|
<gt.Phone size={24}color={I.colors.gray[700]}/>
|
|
78
78
|
</Ie.TouchableOpacity>}
|
|
79
|
-
{
|
|
79
|
+
{V&&<Ie.TouchableOpacity onPress={V}>
|
|
80
80
|
<gt.Info size={24}color={I.colors.gray[700]}/>
|
|
81
81
|
</Ie.TouchableOpacity>}
|
|
82
82
|
</Ie.View>
|
|
83
|
-
</Ie.View>},
|
|
84
|
-
<et.Text style={{fontSize:
|
|
85
|
-
{
|
|
83
|
+
</Ie.View>},Po=pa;var Fs=require("react"),Se=require("react-native");var Qe=$(require("dayjs")),As=$(require("dayjs/plugin/isToday")),zs=$(require("dayjs/plugin/isYesterday")),Vs=$(require("dayjs/plugin/relativeTime")),Bs=$(require("dayjs/plugin/localizedFormat")),Jn=require("dayjs/locale/pl"),Xn=require("dayjs/locale/en");Qe.default.extend(As.default);Qe.default.extend(zs.default);Qe.default.extend(Vs.default);Qe.default.extend(Bs.default);var ga=(M,R="en")=>{let T=(0,Qe.default)(M).locale(R);return T.isToday()?R==="pl"?"Dzisiaj":"Today":T.isYesterday()?R==="pl"?"Wczoraj":"Yesterday":T.format("ddd D MMMM")},Ds=(M,R,T="en")=>{let C=(0,Qe.default)(M).locale(T);return C.isToday()?R("date.today"):C.isYesterday()?R("date.yesterday"):C.format("ddd D MMMM")},ha=M=>(0,Qe.default)(M).format("YYYY-MM-DD"),Ao=(M,R="en")=>{if(M.length===0)return[];let T=[],C=null;return M.forEach((S,V)=>{let I=ha(S.timestamp);if(C!==I){let D=ga(S.timestamp,R),E={id:`date-${I}`,listItemType:"date-separator",date:I,displayDate:D};T.push(E),C=I}let P={...S,listItemType:"message"};T.push(P)}),T},Jt=(M,R="en")=>(0,Qe.default)(M).locale(R).format("HH:mm"),ks=(M,R="en")=>(0,Qe.default)(M).locale(R).fromNow();var Ls=(M,R,T="en")=>{let C=(0,Qe.default)(M).locale(T);return C.isToday()?R("date.todayWithTime",{time:C.format("HH:mm")}):C.isYesterday()?R("date.yesterdayWithTime",{time:C.format("HH:mm")}):C.format("DD MMM YYYY HH:mm")};var et=require("react-native");var fa=({replyTo:M,isMyMessage:R})=>{let T=Y(),C=(E,v=50)=>E.length<=v?E:E.substring(0,v)+"...",S=R?"rgba(255, 255, 255, 0.3)":T.colors.primary,V=R?"rgba(255, 255, 255, 0.8)":T.colors.primary,I=R?"rgba(255, 255, 255, 0.7)":T.colors.textSecondary,P=R?"rgba(255, 255, 255, 0.1)":T.colors.surfaceSecondary,D=M.type==="image"&&M.imageData;return<et.View style={{marginBottom:T.spacing.sm,borderRadius:T.borderRadius.md,padding:T.spacing.sm,backgroundColor:P,borderLeftWidth:4,borderLeftColor:S}}>
|
|
84
|
+
<et.Text style={{fontSize:T.typography.fontSize.xs,fontWeight:T.typography.fontWeight.medium,color:V,marginBottom:T.spacing.xs}}>
|
|
85
|
+
{M.isMe?"You":M.senderName||"Sender"}
|
|
86
86
|
</et.Text>
|
|
87
87
|
|
|
88
|
-
{
|
|
89
|
-
<et.Image source={{uri:
|
|
88
|
+
{D?<et.View style={{flexDirection:"row",alignItems:"center"}}>
|
|
89
|
+
<et.Image source={{uri:M.imageData.uri}}style={{width:40,height:40,borderRadius:T.borderRadius.sm,marginRight:T.spacing.sm}}resizeMode="cover"/>
|
|
90
90
|
<et.View style={{flex:1}}>
|
|
91
|
-
<et.Text style={{fontSize:
|
|
91
|
+
<et.Text style={{fontSize:T.typography.fontSize.xs,color:I,fontStyle:"italic",marginBottom:T.spacing.xs}}>
|
|
92
92
|
📷 Image
|
|
93
93
|
</et.Text>
|
|
94
|
-
{
|
|
95
|
-
{
|
|
94
|
+
{M.text&&M.text.trim()&&<et.Text style={{fontSize:T.typography.fontSize.sm,color:I,lineHeight:T.typography.lineHeight.tight}}>
|
|
95
|
+
{C(M.text,30)}
|
|
96
96
|
</et.Text>}
|
|
97
97
|
</et.View>
|
|
98
|
-
</et.View>:<et.Text style={{fontSize:
|
|
99
|
-
{
|
|
98
|
+
</et.View>:<et.Text style={{fontSize:T.typography.fontSize.sm,color:I,lineHeight:T.typography.lineHeight.tight}}>
|
|
99
|
+
{C(M.text)}
|
|
100
100
|
</et.Text>}
|
|
101
|
-
</et.View>},
|
|
101
|
+
</et.View>},Vt=fa;var ct=require("react"),Re=require("react-native");var{width:ss,height:js}=Re.Dimensions.get("window"),ya=({imageData:M,isMe:R,onImagePress:T,onLongPress:C})=>{let S=Y(),[V,I]=(0,ct.useState)(!1),[P,D]=(0,ct.useState)(!1),v=(0,ct.useCallback)(()=>{let O=ss*.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=(0,ct.useCallback)(()=>{T?T():I(!0)},[T]),k=(0,ct.useCallback)(()=>{console.error("Failed to load image:",M.uri),D(!0)},[M.uri]),A=(0,ct.useCallback)(()=>{I(!1)},[]),L=(0,ct.useCallback)(()=>{if(!M.width||!M.height)return{width:ss,height:js*.8};let O=M.width/M.height,j=ss*.9,H=js*.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?<Re.View style={[ht.errorContainer,{width:v.width,height:v.height,backgroundColor:R?S.colors.messageBubble.sent:S.colors.messageBubble.received,borderRadius:S.borderRadius.lg}]}>
|
|
102
102
|
<Re.Text style={[ht.errorText,{color:R?S.colors.messageBubble.sentText:S.colors.messageBubble.receivedText,fontSize:S.typography.fontSize.sm}]}>
|
|
103
103
|
Failed to load image
|
|
104
104
|
</Re.Text>
|
|
105
105
|
</Re.View>:<>
|
|
106
|
-
<Re.Pressable onPress={
|
|
106
|
+
<Re.Pressable onPress={B}onLongPress={C}delayLongPress={500}>
|
|
107
107
|
<Re.View style={[ht.imageContainer,{borderRadius:S.borderRadius.lg,overflow:"hidden"}]}>
|
|
108
|
-
<Re.Image source={{uri:
|
|
108
|
+
<Re.Image source={{uri:M.uri}}style={[ht.image,{width:v.width,height:v.height}]}resizeMode='cover'onError={k}/>
|
|
109
109
|
|
|
110
110
|
{}
|
|
111
111
|
<Re.View style={ht.imageOverlay}/>
|
|
@@ -113,148 +113,148 @@ await initChat({ projectId: 'your-project-id' });`)},vs=()=>(At(),lt.projectId),
|
|
|
113
113
|
</Re.Pressable>
|
|
114
114
|
|
|
115
115
|
{}
|
|
116
|
-
<Re.Modal visible={
|
|
117
|
-
<Re.Pressable style={ht.modalContainer}onPress={
|
|
116
|
+
<Re.Modal visible={V}transparent animationType='fade'onRequestClose={A}>
|
|
117
|
+
<Re.Pressable style={ht.modalContainer}onPress={A}>
|
|
118
118
|
<Re.View style={ht.modalContent}>
|
|
119
|
-
<Re.Image source={{uri:
|
|
119
|
+
<Re.Image source={{uri:M.uri}}style={[ht.modalImage,{width:L.width,height:L.height,borderRadius:S.borderRadius.lg}]}resizeMode='contain'/>
|
|
120
120
|
</Re.View>
|
|
121
121
|
</Re.Pressable>
|
|
122
122
|
</Re.Modal>
|
|
123
|
-
</>},ht=Re.StyleSheet.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"}}),
|
|
124
|
-
<
|
|
125
|
-
<
|
|
126
|
-
<
|
|
127
|
-
<
|
|
123
|
+
</>},ht=Re.StyleSheet.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"}}),Vo=ya;var it=require("react-native"),Es=require("lucide-react-native");var xa=({isMe:M,timestamp:R,senderName:T})=>{let C=Y(),S=ke();return<it.View style={[Bt.container,{alignSelf:M?"flex-end":"flex-start",maxWidth:"80%"}]}>
|
|
124
|
+
<it.View style={[Bt.messageBubble,{backgroundColor:C.colors.gray[100],borderColor:C.colors.gray[200]}]}>
|
|
125
|
+
<it.View style={Bt.content}>
|
|
126
|
+
<Es.Trash2 size={16}color={C.colors.gray[500]}/>
|
|
127
|
+
<it.Text style={[Bt.deletedText,{color:C.colors.gray[500]}]}>
|
|
128
128
|
{S("message.deleted")}
|
|
129
|
-
</
|
|
130
|
-
</
|
|
131
|
-
</
|
|
132
|
-
<
|
|
133
|
-
<
|
|
129
|
+
</it.Text>
|
|
130
|
+
</it.View>
|
|
131
|
+
</it.View>
|
|
132
|
+
<it.View style={[Bt.metadata,{alignSelf:M?"flex-end":"flex-start"}]}>
|
|
133
|
+
<it.Text style={[Bt.timestamp,{color:C.colors.gray[400]}]}>
|
|
134
134
|
{R}
|
|
135
|
-
</
|
|
136
|
-
</
|
|
137
|
-
</
|
|
138
|
-
<Se.Pressable ref={S}onLongPress={
|
|
139
|
-
{
|
|
135
|
+
</it.Text>
|
|
136
|
+
</it.View>
|
|
137
|
+
</it.View>},Bt=it.StyleSheet.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}}),Bo=xa;var ba=({message:M,onLongPress:R,onReactionPress:T})=>{let C=Y(),S=(0,Fs.useRef)(null),V=()=>{S.current?S.current.measureInWindow((D,E,v,B)=>{let k={x:Math.round(D),y:Math.round(E),width:Math.round(v),height:Math.round(B)};R?.(M,k)}):R?.(M)},I=()=>{M.reactions&&M.reactions.length>0&&T?.(M)},P=M.type==="image"&&M.imageData;return M.deleted?<Bo isMe={M.isMe}timestamp={Jt(M.timestamp)}senderName={M.senderName}/>:<Se.View style={{marginBottom:C.spacing.md,alignItems:M.isMe?"flex-end":"flex-start",marginHorizontal:C.spacing.sm}}>
|
|
138
|
+
<Se.Pressable ref={S}onLongPress={V}delayLongPress={500}style={{maxWidth:P?"75%":"80%",borderRadius:P?C.borderRadius.lg:C.borderRadius.xl,borderBottomRightRadius:M.isMe?4:P?C.borderRadius.lg:C.borderRadius.xl,borderBottomLeftRadius:M.isMe?P?C.borderRadius.lg:C.borderRadius.xl:4,paddingHorizontal:P?0:C.spacing.lg,paddingVertical:P?0:C.spacing.md,backgroundColor:P?"transparent":M.isMe?C.colors.messageBubble.sent:C.colors.messageBubble.received,overflow:"hidden"}}>
|
|
139
|
+
{M.replyTo&&<Vt replyTo={M.replyTo}isMyMessage={M.isMe}/>}
|
|
140
140
|
|
|
141
|
-
{P?<
|
|
142
|
-
{
|
|
141
|
+
{P?<Vo imageData={M.imageData}isMe={M.isMe}onLongPress={V}/>:<Se.Text style={{fontSize:C.typography.fontSize.base,color:M.isMe?C.colors.messageBubble.sentText:C.colors.messageBubble.receivedText}}>
|
|
142
|
+
{M.text}
|
|
143
143
|
</Se.Text>}
|
|
144
144
|
|
|
145
145
|
{}
|
|
146
|
-
{P&&
|
|
147
|
-
<Se.Text style={{fontSize:
|
|
148
|
-
{
|
|
146
|
+
{P&&M.text&&M.text.trim()&&<Se.View style={{paddingHorizontal:C.spacing.lg,paddingVertical:C.spacing.md,backgroundColor:M.isMe?C.colors.messageBubble.sent:C.colors.messageBubble.received,borderRadius:C.borderRadius.lg,marginTop:C.spacing.xs}}>
|
|
147
|
+
<Se.Text style={{fontSize:C.typography.fontSize.base,color:M.isMe?C.colors.messageBubble.sentText:C.colors.messageBubble.receivedText}}>
|
|
148
|
+
{M.text}
|
|
149
149
|
</Se.Text>
|
|
150
150
|
</Se.View>}
|
|
151
151
|
</Se.Pressable>
|
|
152
152
|
|
|
153
153
|
{}
|
|
154
|
-
{
|
|
155
|
-
{
|
|
156
|
-
<Se.Text style={{fontSize:
|
|
157
|
-
{
|
|
154
|
+
{M.reactions&&M.reactions.length>0&&<Se.TouchableOpacity onPress={I}style={{marginTop:C.spacing.xs,flexDirection:"row",alignItems:"center",backgroundColor:C.colors.background,borderRadius:C.borderRadius.full,justifyContent:M.isMe?"flex-end":"flex-start"}}>
|
|
155
|
+
{M.reactions.map((D,E)=><Se.View key={`${D.emoji}-${E}`}style={{flexDirection:"row",alignItems:"center",padding:C.spacing.xs}}>
|
|
156
|
+
<Se.Text style={{fontSize:C.typography.fontSize.sm}}>
|
|
157
|
+
{D.emoji}
|
|
158
158
|
</Se.Text>
|
|
159
|
-
{
|
|
160
|
-
{
|
|
159
|
+
{D.count>1&&<Se.Text style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary,marginLeft:C.spacing.xs,fontWeight:C.typography.fontWeight.medium}}>
|
|
160
|
+
{D.count}
|
|
161
161
|
</Se.Text>}
|
|
162
162
|
</Se.View>)}
|
|
163
163
|
</Se.TouchableOpacity>}
|
|
164
164
|
|
|
165
|
-
<Se.View style={{marginHorizontal:
|
|
166
|
-
<Se.Text style={{fontSize:
|
|
167
|
-
{
|
|
165
|
+
<Se.View style={{marginHorizontal:C.spacing.sm,marginTop:C.spacing.xs,flexDirection:"row",alignItems:"center",justifyContent:M.isMe?"flex-end":"flex-start"}}>
|
|
166
|
+
<Se.Text style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary}}>
|
|
167
|
+
{Jt(M.timestamp)}
|
|
168
168
|
</Se.Text>
|
|
169
|
-
{
|
|
170
|
-
{
|
|
169
|
+
{M.isMe&&M.status&&<Se.View style={{marginLeft:C.spacing.xs}}>
|
|
170
|
+
{M.status==="sent"&&<Se.Text style={{fontSize:C.typography.fontSize.xs,color:C.colors.gray[400]}}>
|
|
171
171
|
✓
|
|
172
172
|
</Se.Text>}
|
|
173
|
-
{
|
|
173
|
+
{M.status==="delivered"&&<Se.Text style={{fontSize:C.typography.fontSize.xs,color:C.colors.gray[400]}}>
|
|
174
174
|
✓✓
|
|
175
175
|
</Se.Text>}
|
|
176
|
-
{
|
|
176
|
+
{M.status==="read"&&<Se.Text style={{fontSize:C.typography.fontSize.xs,color:C.colors.primary}}>
|
|
177
177
|
✓✓
|
|
178
178
|
</Se.Text>}
|
|
179
179
|
</Se.View>}
|
|
180
180
|
</Se.View>
|
|
181
|
-
</Se.View>},
|
|
181
|
+
</Se.View>},Do=ba;var Z=require("react-native"),Os=require("lucide-react-native");var Ma=({replyToMessage:M,onCancel:R})=>{let T=Y(),C=(I,P=50)=>I.length<=P?I:I.substring(0,P)+"...",S=!!M.replyTo,V=M.type==="image"&&M.imageData;return<Z.View style={{borderBottomWidth:1,borderBottomColor:T.colors.border,backgroundColor:T.colors.surface,paddingHorizontal:T.spacing.lg,paddingVertical:T.spacing.md}}>
|
|
182
182
|
<Z.View style={{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}>
|
|
183
|
-
<Z.View style={{flex:1,marginRight:
|
|
184
|
-
<Z.View style={{flexDirection:"row",alignItems:"center",marginBottom:
|
|
185
|
-
<Z.View style={{width:4,backgroundColor:
|
|
183
|
+
<Z.View style={{flex:1,marginRight:T.spacing.md}}>
|
|
184
|
+
<Z.View style={{flexDirection:"row",alignItems:"center",marginBottom:T.spacing.xs}}>
|
|
185
|
+
<Z.View style={{width:4,backgroundColor:T.colors.primary,borderRadius:T.borderRadius.full,marginRight:T.spacing.md,height:S?48:32}}/>
|
|
186
186
|
<Z.View style={{flex:1}}>
|
|
187
|
-
<Z.Text style={{fontSize:
|
|
188
|
-
Replying to {
|
|
187
|
+
<Z.Text style={{fontSize:T.typography.fontSize.xs,fontWeight:T.typography.fontWeight.medium,color:T.colors.primary,marginBottom:T.spacing.xs}}>
|
|
188
|
+
Replying to {M.isMe?"yourself":M.senderName||"sender"}
|
|
189
189
|
{S&&" (reply thread)"}
|
|
190
190
|
</Z.Text>
|
|
191
191
|
|
|
192
192
|
{}
|
|
193
|
-
{S&&<Z.View style={{marginBottom:
|
|
194
|
-
<Z.Text style={{fontSize:
|
|
195
|
-
Originally replying to: {
|
|
193
|
+
{S&&<Z.View style={{marginBottom:T.spacing.sm,padding:T.spacing.sm,backgroundColor:T.colors.surfaceSecondary,borderRadius:T.borderRadius.md,borderLeftWidth:2,borderLeftColor:T.colors.gray[300]}}>
|
|
194
|
+
<Z.Text style={{fontSize:T.typography.fontSize.xs,color:T.colors.textSecondary,marginBottom:T.spacing.xs}}>
|
|
195
|
+
Originally replying to: {M.replyTo.isMe?"yourself":M.replyTo.senderName||"sender"}
|
|
196
196
|
</Z.Text>
|
|
197
|
-
<Z.Text style={{fontSize:
|
|
198
|
-
{
|
|
197
|
+
<Z.Text style={{fontSize:T.typography.fontSize.xs,color:T.colors.textSecondary,lineHeight:T.typography.lineHeight.tight}}>
|
|
198
|
+
{C(M.replyTo.text,40)}
|
|
199
199
|
</Z.Text>
|
|
200
200
|
</Z.View>}
|
|
201
201
|
|
|
202
|
-
{
|
|
203
|
-
<Z.Image source={{uri:
|
|
202
|
+
{V?<Z.View style={{flexDirection:"row",alignItems:"center"}}>
|
|
203
|
+
<Z.Image source={{uri:M.imageData.uri}}style={{width:32,height:32,borderRadius:T.borderRadius.sm,marginRight:T.spacing.sm}}resizeMode="cover"/>
|
|
204
204
|
<Z.View style={{flex:1}}>
|
|
205
|
-
<Z.Text style={{fontSize:
|
|
205
|
+
<Z.Text style={{fontSize:T.typography.fontSize.xs,color:T.colors.gray[600],fontStyle:"italic",marginBottom:T.spacing.xs}}>
|
|
206
206
|
📷 Image
|
|
207
207
|
</Z.Text>
|
|
208
|
-
{
|
|
209
|
-
{
|
|
208
|
+
{M.text&&M.text.trim()&&<Z.Text style={{fontSize:T.typography.fontSize.sm,color:T.colors.gray[700],lineHeight:T.typography.lineHeight.tight}}>
|
|
209
|
+
{C(M.text,40)}
|
|
210
210
|
</Z.Text>}
|
|
211
211
|
</Z.View>
|
|
212
|
-
</Z.View>:<Z.Text style={{fontSize:
|
|
213
|
-
{
|
|
212
|
+
</Z.View>:<Z.Text style={{fontSize:T.typography.fontSize.sm,color:T.colors.gray[700],lineHeight:T.typography.lineHeight.tight}}>
|
|
213
|
+
{C(M.text)}
|
|
214
214
|
</Z.Text>}
|
|
215
215
|
</Z.View>
|
|
216
216
|
</Z.View>
|
|
217
217
|
</Z.View>
|
|
218
218
|
|
|
219
|
-
<Z.TouchableOpacity onPress={R}style={{height:32,width:32,alignItems:"center",justifyContent:"center",borderRadius:
|
|
220
|
-
<
|
|
219
|
+
<Z.TouchableOpacity onPress={R}style={{height:32,width:32,alignItems:"center",justifyContent:"center",borderRadius:T.borderRadius.full,backgroundColor:T.colors.gray[200]}}hitSlop={{top:8,bottom:8,left:8,right:8}}>
|
|
220
|
+
<Os.X size={16}color={T.colors.textSecondary}/>
|
|
221
221
|
</Z.TouchableOpacity>
|
|
222
222
|
</Z.View>
|
|
223
|
-
</Z.View>},
|
|
223
|
+
</Z.View>},Xt=Ma;var Be=require("react"),W=require("react-native"),ft=require("lucide-react-native");var ko=require("react"),Hs=$(require("rn-emoji-keyboard")),Ta=({visible:M,onClose:R,onEmojiSelected:T})=>{let[C,S]=(0,ko.useState)(!1);(0,ko.useEffect)(()=>{S(!!M)},[M]);let V=P=>{console.log("Selected emoji:",P),T(P.emoji),S(!1),R()},I=()=>{S(!1),R()};return M?<Hs.default onEmojiSelected={V}open={C}onClose={I}enableSearchBar/>:null},Dt=Ta;var Ca=({visible:M,onPress:R,children:T})=>M?<W.View style={Ve.overlay}>
|
|
224
224
|
<W.TouchableOpacity style={Ve.backdrop}onPress={R}activeOpacity={1}/>
|
|
225
|
-
{
|
|
226
|
-
</W.View>:null,{width:
|
|
227
|
-
{
|
|
225
|
+
{T}
|
|
226
|
+
</W.View>:null,{width:kt,height:as}=W.Dimensions.get("window"),Ra=({message:M,positions:R,messagePosition:T,containerRef:C,containerOffset:S,setContainerOffset:V})=>{let I=Y(),P=(0,Be.useRef)(new W.Animated.Value(T.y)).current,D=(0,Be.useRef)(new W.Animated.Value(0)).current,E=(0,Be.useRef)(!1),v=M.type==="image"&&M.imageData;return(0,Be.useEffect)(()=>{E.current=!1,C.current&&C.current.measureInWindow((B,k,A,z)=>{V({x:B,y:k});let L=T.y-k,O=R.messagePreviewTop-k;P.setValue(L),D.setValue(0),requestAnimationFrame(()=>{W.Animated.parallel([W.Animated.timing(P,{toValue:O,duration:250,useNativeDriver:!1}),W.Animated.timing(D,{toValue:1,duration:250,useNativeDriver:!1})]).start(()=>{E.current=!0})})})},[R.messagePreviewTop,T.y,C]),<W.Animated.View style={{position:"absolute",top:P,left:T.x,width:T.width,height:M.replyTo?T.height+10:T.height,zIndex:1e3,opacity:D,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&&<Vt replyTo={M.replyTo}isMyMessage={M.isMe}/>}
|
|
228
228
|
|
|
229
229
|
{v?<W.View>
|
|
230
|
-
<W.Image source={{uri:
|
|
230
|
+
<W.Image source={{uri:M.imageData.uri}}style={{width:T.width,height:T.height,borderRadius:I.borderRadius.lg}}resizeMode='cover'/>
|
|
231
231
|
{}
|
|
232
|
-
{
|
|
233
|
-
<W.Text style={{fontSize:I.typography.fontSize.base,color:
|
|
234
|
-
{
|
|
232
|
+
{M.text&&M.text.trim()&&<W.View 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
|
+
<W.Text style={{fontSize:I.typography.fontSize.base,color:M.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
|
|
234
|
+
{M.text}
|
|
235
235
|
</W.Text>
|
|
236
236
|
</W.View>}
|
|
237
|
-
</W.View>:<W.Text style={{fontSize:I.typography.fontSize.base,color:
|
|
238
|
-
{
|
|
237
|
+
</W.View>:<W.Text style={{fontSize:I.typography.fontSize.base,color:M.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
|
|
238
|
+
{M.text}
|
|
239
239
|
</W.Text>}
|
|
240
|
-
</W.Animated.View>},
|
|
240
|
+
</W.Animated.View>},Sa=({visible:M,onClose:R,isMyMessage:T,selectedMessage:C,messagePosition:S,onActionPress:V,onEmojiReact:I})=>{let P=ke(),[D,E]=(0,Be.useState)(!1),v=(0,Be.useRef)(null),[B,k]=(0,Be.useState)({x:0,y:0}),A=(0,Be.useRef)(new W.Animated.Value(0)).current,z=(0,Be.useRef)(new W.Animated.Value(0)).current,L=(0,Be.useRef)(!1),O=(0,Be.useRef)(!1),j=Te=>{V(Te),R()},H=Te=>{I?.(Te),R()},N=()=>{E(!0)},F=()=>{E(!1)},te=Te=>{I?.(Te),E(!1),R()},je=["\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F621}","\u{1F44D}"],Ee=(()=>{if(!S)return{emojiBar:{top:as/2-200,left:kt/2-160},actionMenu:{top:as/2+50,left:kt/2-100}};let Te=320,De=60,Ae=200,Ye=160,U=20,$e=8,Fe,Tt,Ce,Ge,Xe,we=as/2,It=De+$e+S.height+$e+Ye,Ct=we-It/2;return Tt=Ct,Xe=Ct+De+$e,Ge=Ct+De+$e+S.height+$e,Fe=S.x,Ce=S.x,Fe+Te>kt-U&&(Fe=kt-Te-U),Fe<U&&(Fe=U),Ce+Ae>kt-U&&(Ce=kt-Ae-U),Ce<U&&(Ce=U),{emojiBar:{top:Tt,left:Fe},actionMenu:{top:Ge,left:Ce},messagePreviewTop:Xe,isNearAverageHeight:!0,isNearTop:!0,isEdgeCase:!0}})();return(0,Be.useEffect)(()=>{M&&S&&!O.current&&(A.setValue(0),z.setValue(0),setTimeout(()=>{W.Animated.sequence([W.Animated.timing(A,{toValue:1,duration:200,useNativeDriver:!1}),W.Animated.timing(z,{toValue:1,duration:200,useNativeDriver:!1})]).start(()=>{O.current=!0})},50))},[M,S,A,z]),(0,Be.useEffect)(()=>{M||(L.current=!1,O.current=!1,A.setValue(0),z.setValue(0))},[M,A,z]),M?<>
|
|
241
241
|
{}
|
|
242
|
-
<
|
|
242
|
+
<Ca visible={!0}onPress={R}>
|
|
243
243
|
<W.Pressable style={Ve.overlayPressable}onPress={R}/>
|
|
244
|
-
</
|
|
244
|
+
</Ca>
|
|
245
245
|
|
|
246
246
|
<W.View ref={v}style={{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}>
|
|
247
247
|
{}
|
|
248
248
|
</W.View>
|
|
249
249
|
|
|
250
250
|
{}
|
|
251
|
-
{S&&
|
|
251
|
+
{S&&C&&<Ra message={C}positions={Ee}messagePosition={S}containerRef={v}containerOffset={B}setContainerOffset={k}/>}
|
|
252
252
|
|
|
253
253
|
{}
|
|
254
|
-
<W.Animated.View style={[Ve.emojiBar,{position:"absolute",top:Ee.emojiBar.top-(
|
|
254
|
+
<W.Animated.View style={[Ve.emojiBar,{position:"absolute",top:Ee.emojiBar.top-(B.y||0),left:Ee.emojiBar.left,opacity:A,pointerEvents:"auto"}]}>
|
|
255
255
|
<W.ScrollView horizontal showsHorizontalScrollIndicator={!1}contentContainerStyle={Ve.emojiContainer}>
|
|
256
|
-
{
|
|
257
|
-
<W.Text style={Ve.emojiText}>{
|
|
256
|
+
{je.map((Te,De)=><W.TouchableOpacity key={De}style={Ve.emojiButton}onPress={()=>H(Te)}>
|
|
257
|
+
<W.Text style={Ve.emojiText}>{Te}</W.Text>
|
|
258
258
|
</W.TouchableOpacity>)}
|
|
259
259
|
<W.TouchableOpacity style={Ve.addEmojiButton}onPress={N}>
|
|
260
260
|
<ft.Plus size={20}color='#666'/>
|
|
@@ -263,7 +263,7 @@ await initChat({ projectId: 'your-project-id' });`)},vs=()=>(At(),lt.projectId),
|
|
|
263
263
|
</W.Animated.View>
|
|
264
264
|
|
|
265
265
|
{}
|
|
266
|
-
<W.Animated.View style={[Ve.actionMenu,{position:"absolute",top:Ee.actionMenu.top-(
|
|
266
|
+
<W.Animated.View style={[Ve.actionMenu,{position:"absolute",top:Ee.actionMenu.top-(B.y||0)+(C?.replyTo?10:0),left:Ee.actionMenu.left,opacity:z,pointerEvents:"auto"}]}>
|
|
267
267
|
<W.View style={Ve.actionItems}>
|
|
268
268
|
{}
|
|
269
269
|
<W.TouchableOpacity style={Ve.actionRow}onPress={()=>j("reply")}>
|
|
@@ -278,7 +278,7 @@ await initChat({ projectId: 'your-project-id' });`)},vs=()=>(At(),lt.projectId),
|
|
|
278
278
|
</W.TouchableOpacity>
|
|
279
279
|
|
|
280
280
|
{}
|
|
281
|
-
{
|
|
281
|
+
{T&&<W.TouchableOpacity style={Ve.actionRow}onPress={()=>j("delete")}>
|
|
282
282
|
<ft.Trash2 size={18}color='#ff4444'/>
|
|
283
283
|
<W.Text style={[Ve.actionLabel,{color:"#ff4444"}]}>
|
|
284
284
|
{P("action.delete")}
|
|
@@ -288,54 +288,54 @@ await initChat({ projectId: 'your-project-id' });`)},vs=()=>(At(),lt.projectId),
|
|
|
288
288
|
</W.Animated.View>
|
|
289
289
|
|
|
290
290
|
{}
|
|
291
|
-
<
|
|
292
|
-
</>:null},Ve=W.StyleSheet.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:{...W.StyleSheet.absoluteFillObject,zIndex:1e3},backdrop:{...W.StyleSheet.absoluteFillObject,backgroundColor:"rgba(0, 0, 0, 0.8)"}}),
|
|
293
|
-
<
|
|
291
|
+
<Dt visible={D}onClose={F}onEmojiSelected={te}/>
|
|
292
|
+
</>:null},Ve=W.StyleSheet.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:{...W.StyleSheet.absoluteFillObject,zIndex:1e3},backdrop:{...W.StyleSheet.absoluteFillObject,backgroundColor:"rgba(0, 0, 0, 0.8)"}}),Lo=Sa;var Lt=require("react"),J=require("react-native"),Ns=$(require("react-native-actions-sheet"));var wa=({visible:M,onClose:R,reactions:T,messageText:C,onAddReaction:S,onRemoveReaction:V})=>{let I=(0,Lt.useRef)(null),[P,D]=(0,Lt.useState)(!1);(0,Lt.useEffect)(()=>{M?I.current?.show():I.current?.hide()},[M]);let v=(()=>{let j=[];return T.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=T.reduce((j,H)=>j+H.count,0),k=j=>{console.log("Remove reaction called with:",j),console.log("onRemoveReaction prop exists:",!!V),console.log("User is current user:",j.name==="You"),j.name==="You"&&V?(console.log("Calling onRemoveReaction with emoji:",j.emoji),V(j.emoji)):console.log("Not calling onRemoveReaction because:",{isCurrentUser:j.name==="You",hasCallback:!!V})},A=()=>{I.current?.hide(),R(),setTimeout(()=>{D(!0)},300)},z=()=>{D(!1)},L=j=>{console.log("Selected emoji from picker:",j),S?.(j),D(!1),R()},O=()=>{I.current?.hide(),R()};return<>
|
|
293
|
+
<Ns.default ref={I}onClose={O}containerStyle={Q.container}headerAlwaysVisible={!0}gestureEnabled={!0}closeOnTouchBackdrop={!0}>
|
|
294
294
|
{}
|
|
295
|
-
<
|
|
296
|
-
<
|
|
297
|
-
<
|
|
298
|
-
<
|
|
299
|
-
</
|
|
300
|
-
</
|
|
295
|
+
<J.View style={Q.header}>
|
|
296
|
+
<J.Text style={Q.title}>{B} reactions</J.Text>
|
|
297
|
+
<J.TouchableOpacity onPress={O}style={Q.closeButton}>
|
|
298
|
+
<J.Text style={Q.closeText}>✕</J.Text>
|
|
299
|
+
</J.TouchableOpacity>
|
|
300
|
+
</J.View>
|
|
301
301
|
|
|
302
302
|
{}
|
|
303
|
-
<
|
|
304
|
-
<
|
|
305
|
-
{
|
|
306
|
-
</
|
|
307
|
-
</
|
|
303
|
+
<J.View style={Q.messagePreview}>
|
|
304
|
+
<J.Text style={Q.messageText}numberOfLines={2}>
|
|
305
|
+
{C}
|
|
306
|
+
</J.Text>
|
|
307
|
+
</J.View>
|
|
308
308
|
|
|
309
309
|
{}
|
|
310
|
-
<
|
|
310
|
+
<J.View style={Q.reactionButtons}>
|
|
311
311
|
{}
|
|
312
312
|
|
|
313
|
-
{
|
|
314
|
-
<
|
|
315
|
-
<
|
|
316
|
-
</
|
|
317
|
-
</
|
|
313
|
+
{T.map((j,H)=><J.View key={H}style={Q.reactionButton}>
|
|
314
|
+
<J.Text style={Q.reactionEmoji}>{j.emoji}</J.Text>
|
|
315
|
+
<J.Text style={Q.reactionCount}>{j.count}</J.Text>
|
|
316
|
+
</J.View>)}
|
|
317
|
+
</J.View>
|
|
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
|
+
<J.ScrollView style={Q.userReactionsList}showsVerticalScrollIndicator={!1}>
|
|
321
|
+
{v.map(j=>{let H=j.name==="You",N=H?J.TouchableOpacity:J.View;return<N key={j.id}style={[Q.userReactionItem,H&&Q.tappableUserReactionItem]}onPress={H?()=>k(j):void 0}activeOpacity={H?.7:1}>
|
|
322
|
+
<J.View style={Q.userInfo}>
|
|
323
|
+
<J.Text style={Q.userAvatar}>{j.avatar}</J.Text>
|
|
324
|
+
<J.View style={Q.userDetails}>
|
|
325
|
+
<J.Text style={Q.userName}>{j.name}</J.Text>
|
|
326
|
+
{H&&<J.Text style={Q.removeText}>Tap to remove</J.Text>}
|
|
327
|
+
</J.View>
|
|
328
|
+
</J.View>
|
|
329
|
+
<J.View style={Q.userReactionEmoji}>
|
|
330
|
+
<J.Text style={Q.emojiText}>{j.emoji}</J.Text>
|
|
331
|
+
</J.View>
|
|
332
332
|
</N>})}
|
|
333
|
-
</
|
|
334
|
-
</
|
|
333
|
+
</J.ScrollView>
|
|
334
|
+
</Ns.default>
|
|
335
335
|
|
|
336
336
|
{}
|
|
337
|
-
<
|
|
338
|
-
</>},Q=
|
|
337
|
+
<Dt visible={P}onClose={z}onEmojiSelected={L}/>
|
|
338
|
+
</>},Q=J.StyleSheet.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}}),Eo=wa;var jt=$(require("react")),tt=require("react-native"),Ws=$(require("react-native-actions-sheet")),Us=require("lucide-react-native"),St=(0,jt.forwardRef)(({onOptionSelect:M,options:R},T)=>{let C=jt.default.useRef(null);(0,jt.useImperativeHandle)(T,()=>({show:()=>C.current?.show(),hide:()=>C.current?.hide()}));let S=V=>{M(V),C.current?.hide()};return<Ws.default ref={C}headerAlwaysVisible gestureEnabled={!0}statusBarTranslucent drawUnderStatusBar={!1}containerStyle={{borderTopLeftRadius:20,borderTopRightRadius:20}}>
|
|
339
339
|
<tt.View style={{padding:20,width:"100%"}}>
|
|
340
340
|
|
|
341
341
|
{}
|
|
@@ -343,121 +343,121 @@ await initChat({ projectId: 'your-project-id' });`)},vs=()=>(At(),lt.projectId),
|
|
|
343
343
|
<tt.Text style={{fontSize:18,fontWeight:"600",color:"#1F2937"}}>
|
|
344
344
|
Share Content
|
|
345
345
|
</tt.Text>
|
|
346
|
-
<tt.TouchableOpacity onPress={()=>
|
|
347
|
-
<
|
|
346
|
+
<tt.TouchableOpacity onPress={()=>C.current?.hide()}>
|
|
347
|
+
<Us.X size={24}color="#6B7280"/>
|
|
348
348
|
</tt.TouchableOpacity>
|
|
349
349
|
</tt.View>
|
|
350
350
|
|
|
351
351
|
{}
|
|
352
352
|
<tt.View style={{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",paddingBottom:20}}>
|
|
353
|
-
{R.map(
|
|
353
|
+
{R.map(V=>{let I=V.icon;return<tt.TouchableOpacity key={V.id}style={{width:"30%",aspectRatio:1,marginBottom:20,alignItems:"center",justifyContent:"center"}}onPress={()=>S(V.id)}>
|
|
354
354
|
<tt.View style={{width:60,height:60,borderRadius:30,backgroundColor:"#F3F4F6",alignItems:"center",justifyContent:"center",marginBottom:8}}>
|
|
355
|
-
<I size={24}color={
|
|
355
|
+
<I size={24}color={V.color}/>
|
|
356
356
|
</tt.View>
|
|
357
357
|
<tt.Text style={{fontSize:12,color:"#6B7280",textAlign:"center",fontWeight:"500"}}>
|
|
358
|
-
{
|
|
358
|
+
{V.label}
|
|
359
359
|
</tt.Text>
|
|
360
360
|
</tt.TouchableOpacity>})}
|
|
361
361
|
</tt.View>
|
|
362
362
|
</tt.View>
|
|
363
|
-
</
|
|
364
|
-
<
|
|
365
|
-
<
|
|
366
|
-
<
|
|
367
|
-
<
|
|
368
|
-
<
|
|
369
|
-
</
|
|
370
|
-
</
|
|
371
|
-
</
|
|
372
|
-
{({pressed:P})=><
|
|
373
|
-
|
|
374
|
-
</
|
|
375
|
-
</
|
|
376
|
-
<
|
|
377
|
-
<
|
|
378
|
-
{
|
|
379
|
-
</
|
|
380
|
-
</
|
|
381
|
-
</Mo.View>},Yo=Vn;var Ue=X(require("react")),Xe=require("react-native"),Kt=require("lucide-react-native");var ot=require("react"),ee=require("react-native"),Fe=require("lucide-react-native");var Bn={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},ms=async(C,R={})=>{try{let M;try{M=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 T={...Bn,...R};console.log("Starting image compression...",{uri:C,options:T});let S=await M.manipulateAsync(C,[],{});console.log("Original image info:",{width:S.width,height:S.height,uri:S.uri});let A=[];if(T.maxWidth||T.maxHeight){let{width:k,height:D}=S,V=k,B=D;if(T.maxWidth&&k>T.maxWidth){let L=T.maxWidth/k;V=T.maxWidth,B=D*L}if(T.maxHeight&&B>T.maxHeight){let L=T.maxHeight/B;B=T.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:T.quality,format:T.format==="png"?M.SaveFormat?.PNG:M.SaveFormat?.JPEG};console.log("Applying compression with options:",I);let P=await M.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=T.format==="png"?"png":"jpg",v=`compressed_image_${z}.${E}`;return{uri:P.uri,width:P.width,height:P.height,fileName:v}}catch(M){console.error("Error compressing image:",M);let T=M instanceof Error?M.message:"Unknown error";throw new Error(`Failed to compress image: ${T}`)}},ps=(C,R)=>C>3e3||R>3e3?{maxWidth:1920,maxHeight:1920,quality:.7,format:"jpeg"}:C>1920||R>1920?{maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"}:{quality:.9,format:"jpeg"};var kn=[{id:"photo",label:"Photo",icon:Fe.Image,color:"#3B82F6"},{id:"camera",label:"Camera",icon:Fe.Camera,color:"#6B7280"},{id:"location",label:"Location",icon:Fe.MapPin,color:"#10B981"},{id:"contact",label:"Contact",icon:Fe.User,color:"#6B7280"},{id:"document",label:"Document",icon:Fe.FileText,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Fe.BarChart3,color:"#F59E0B"},{id:"event",label:"Event",icon:Fe.Calendar,color:"#EF4444"}],Go=C=>{let R=(0,ot.useRef)(null),M=(0,ot.useCallback)(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),ee.Alert.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"){ee.Alert.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=ps(V.width||1920,V.height||1920),L=await ms(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),ee.Alert.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),ee.Alert.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[C]),T=(0,ot.useCallback)(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),ee.Alert.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"){ee.Alert.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=ps(V.width||1920,V.height||1920),L=await ms(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),ee.Alert.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),ee.Alert.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[C]),S=(0,ot.useCallback)(async()=>{console.log("Location sharing initiated");try{let v;try{v=await import("expo-location")}catch(L){console.log("expo-location not available:",L),ee.Alert.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"){ee.Alert.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),ee.Alert.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[C]),A=(0,ot.useCallback)(async()=>{try{let v;try{v=await import("expo-contacts")}catch(D){console.log("expo-contacts not available:",D),ee.Alert.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"){ee.Alert.alert("Permission needed","Please grant contacts access to share contacts.");return}ee.Alert.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),ee.Alert.alert("Error","Failed to access contacts. Please try again.")}finally{R.current?.hide()}},[]),I=(0,ot.useCallback)(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),ee.Alert.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),ee.Alert.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[C]),P=(0,ot.useCallback)(()=>{ee.Alert.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=(0,ot.useCallback)(()=>{ee.Alert.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=(0,ot.useCallback)(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await M();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(k){console.error(`Error handling ${v}:`,k),ee.Alert.alert("Error",`Failed to handle ${v}. Please try again.`)}},[M,T,S,A,I,P,z]);return{menuRef:R,handleOptionSelect:E,options:kn}};var Y=X(require("react")),To=(C={})=>{let{initialValue:R="",initialHeight:M=50,onValueChange:T,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=(0,Y.useRef)(null),[L,F]=Y.default.useState(R),[j,H]=Y.default.useState(M),[N,O]=Y.default.useState(!1),[te,Le]=Y.default.useState(null),[Ce,Ee]=Y.default.useState([]),Me=Y.default.useMemo(()=>({value:L,height:j,isFocused:N,replyToMessage:te,attachments:Ce}),[L,j,N,te,Ce]),ke=(0,Y.useCallback)(ze=>{F(ze),T?.(ze)},[T]),Ae=(0,Y.useCallback)(ze=>{let Ne=Math.max(k,Math.min(v,ze));H(Ne),S?.(Ne)},[k,v,S]),Ye=(0,Y.useCallback)(()=>{O(!0),z?.()},[z]),U=(0,Y.useCallback)(()=>{O(!1),E?.()},[E]),Ge=(0,Y.useCallback)(ze=>{let{height:Ne}=ze.nativeEvent.contentSize,Gt=Math.max(k,Math.min(v,Ne+16));Ae(Gt)},[k,v,Ae]),Oe=(0,Y.useCallback)(()=>{A&&(L||Ce.length>0)&&(A(L,Ce,te),F(R),Ee([]),Le(null),H(M))},[A,L,Ce,te,R,M]),Mt=(0,Y.useCallback)(ze=>{I?(I(ze,L),L&&F(R)):Ee(Ne=>[...Ne,{...ze,id:Date.now().toString()}])},[I,L,R]),Te=(0,Y.useCallback)(ze=>{Ee(Ne=>[...Ne,ze])},[]),_e=(0,Y.useCallback)(ze=>{Ee(Ne=>Ne.filter(Gt=>Gt.id!==ze))},[]),Ze=(0,Y.useCallback)(()=>{Ee([])},[]),we=(0,Y.useCallback)(()=>{Le(null),P?.()},[P]),Pt=(0,Y.useCallback)(()=>{B.current?.focus()},[]),Tt=Y.default.useMemo(()=>({setValue:ke,setHeight:Ae,setFocus:O,setReplyToMessage:Le,addAttachment:Te,removeAttachment:_e,clearAttachments:Ze,sendMessage:Oe,cancelReply:we,focusInput:Pt,handleAttachmentSelected:Mt,handleContentSizeChange:Ge,handleFocus:Ye,handleBlur:U}),[ke,Ae,O,Le,Te,_e,Ze,Oe,we,Pt,Mt,Ge,Ye,U]),ss=Y.default.useMemo(()=>({textInputRef:B}),[]);return{state:Me,actions:Tt,refs:ss}},si=(0,Y.createContext)(null);var mt=(0,Ue.forwardRef)(({value:C,onChangeText:R,onSend:M,onFocus:T,height:S,onContentSizeChange:A,replyToMessage:I,onCancelReply:P,onAttachmentSend:z},E)=>{let v=$(),k=We(),D=(0,Ue.useRef)(null);(0,Ue.useImperativeHandle)(E,()=>({focus:()=>{D.current?.focus()}}));let{state:V,actions:B}=To({initialValue:C,initialHeight:S,onValueChange:R,onHeightChange:A,onSend:M,onAttachmentSend:z,onReplyCancel:P,onFocus:T});Ue.default.useEffect(()=>{C!==V.value&&B.setValue(C)},[C,V.value,B]),Ue.default.useEffect(()=>{S!==V.height&&B.setHeight(S)},[S,V.height,B]),Ue.default.useEffect(()=>{I!==V.replyToMessage&&B.setReplyToMessage(I||null)},[I,V.replyToMessage,B]),Ue.default.useEffect(()=>{if(I&&D.current){let j=setTimeout(()=>{D.current?.focus()},100);return()=>clearTimeout(j)}},[I]);let L=(0,Ue.useCallback)(j=>{if(console.log("Attachment selected:",j),z)z(j,C.trim()||void 0),C.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,C,R]),F=Go(L);return<>
|
|
382
|
-
{I&&P&&<
|
|
383
|
-
<
|
|
384
|
-
<
|
|
385
|
-
<
|
|
386
|
-
<
|
|
387
|
-
</
|
|
363
|
+
</Ws.default>});St.displayName="AttachmentMenu";var Fo=require("react"),Le=require("react-native"),Ia=({isVisible:M})=>{let R=(0,Fo.useRef)(new Le.Animated.Value(0)).current;return(0,Fo.useEffect)(()=>{if(!M){R.setValue(0);return}let T=Le.Animated.loop(Le.Animated.sequence([Le.Animated.timing(R,{toValue:1,duration:1200,useNativeDriver:!0}),Le.Animated.timing(R,{toValue:0,duration:1200,useNativeDriver:!0})]));return T.start(),()=>{T.stop()}},[M,R]),M?<Le.View style={Et.container}>
|
|
364
|
+
<Le.View style={Et.bubble}>
|
|
365
|
+
<Le.View style={Et.dotsContainer}>
|
|
366
|
+
<Le.Animated.View style={[Et.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
|
+
<Le.Animated.View style={[Et.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
|
+
<Le.Animated.View style={[Et.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
|
+
</Le.View>
|
|
370
|
+
</Le.View>
|
|
371
|
+
</Le.View>:null},Et=Le.StyleSheet.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}}),Ft=Ia;var Oo=$(require("react")),Ot=require("react-native"),Ks=require("lucide-react-native");var va=({visible:M,onPress:R,isReplyActive:T=!1})=>{let C=Y(),S=Oo.default.useRef(new Ot.Animated.Value(0)).current,[V,I]=Oo.default.useState(!1);return Oo.default.useEffect(()=>{Ot.Animated.timing(S,{toValue:M?1:0,duration:200,useNativeDriver:!0}).start(()=>{I(M)})},[M,S]),!M&&!V?null:<Ot.Pressable onPress={R}hitSlop={{top:10,bottom:10,left:10,right:10}}>
|
|
372
|
+
{({pressed:P})=><Ot.Animated.View style={[{position:"absolute",bottom:40,right:C.spacing.lg,zIndex:9999,width:32,height:32,backgroundColor:C.colors.background,borderRadius:C.borderRadius.xl,justifyContent:"center",alignItems:"center",shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.25,shadowRadius:3.84,elevation:5,opacity:S,transform:P?[{scale:.95}]:[]}]}>
|
|
373
|
+
<Ks.ChevronDown size={20}color={C.colors.text}/>
|
|
374
|
+
</Ot.Animated.View>}
|
|
375
|
+
</Ot.Pressable>},Ho=va;var Zt=require("react-native");var Pa=({displayDate:M})=>{let R=Y();return<Zt.View style={{marginVertical:R.spacing.lg,alignItems:"center"}}>
|
|
376
|
+
<Zt.View style={{borderRadius:R.borderRadius.full,backgroundColor:R.colors.surfaceSecondary,paddingHorizontal:R.spacing.md,paddingVertical:R.spacing.xs}}>
|
|
377
|
+
<Zt.Text style={{fontSize:R.typography.fontSize.xs,color:R.colors.textSecondary,fontWeight:R.typography.fontWeight.medium}}>
|
|
378
|
+
{M}
|
|
379
|
+
</Zt.Text>
|
|
380
|
+
</Zt.View>
|
|
381
|
+
</Zt.View>},No=Pa;var We=$(require("react")),Je=require("react-native"),Ht=require("lucide-react-native");var ot=require("react"),ee=require("react-native"),Oe=require("lucide-react-native");var Aa={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},ns=async(M,R={})=>{try{let T;try{T=await import("expo-image-manipulator")}catch(B){console.log("expo-image-manipulator not available, returning original image info:",B);let A=`image_${Date.now()}.jpg`;return{uri:M,width:1920,height:1920,fileName:A}}let C={...Aa,...R};console.log("Starting image compression...",{uri:M,options:C});let S=await T.manipulateAsync(M,[],{});console.log("Original image info:",{width:S.width,height:S.height,uri:S.uri});let V=[];if(C.maxWidth||C.maxHeight){let{width:B,height:k}=S,A=B,z=k;if(C.maxWidth&&B>C.maxWidth){let L=C.maxWidth/B;A=C.maxWidth,z=k*L}if(C.maxHeight&&z>C.maxHeight){let L=C.maxHeight/z;z=C.maxHeight,A=A*L}(A!==B||z!==k)&&(V.push({resize:{width:Math.round(A),height:Math.round(z)}}),console.log("Resizing image:",{from:{width:B,height:k},to:{width:Math.round(A),height:Math.round(z)}}))}let I={compress:C.quality,format:C.format==="png"?T.SaveFormat?.PNG:T.SaveFormat?.JPEG};console.log("Applying compression with options:",I);let P=await T.manipulateAsync(M,V,I);console.log("Image compression completed:",{originalUri:M,compressedUri:P.uri,finalDimensions:{width:P.width,height:P.height}});let D=Date.now(),E=C.format==="png"?"png":"jpg",v=`compressed_image_${D}.${E}`;return{uri:P.uri,width:P.width,height:P.height,fileName:v}}catch(T){console.error("Error compressing image:",T);let C=T instanceof Error?T.message:"Unknown error";throw new Error(`Failed to compress image: ${C}`)}},rs=(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 za=[{id:"photo",label:"Photo",icon:Oe.Image,color:"#3B82F6"},{id:"camera",label:"Camera",icon:Oe.Camera,color:"#6B7280"},{id:"location",label:"Location",icon:Oe.MapPin,color:"#10B981"},{id:"contact",label:"Contact",icon:Oe.User,color:"#6B7280"},{id:"document",label:"Document",icon:Oe.FileText,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Oe.BarChart3,color:"#F59E0B"},{id:"event",label:"Event",icon:Oe.Calendar,color:"#EF4444"}],Wo=M=>{let R=(0,ot.useRef)(null),T=(0,ot.useCallback)(async()=>{console.log("Photo selection initiated");try{let v;try{v=await import("expo-image-picker")}catch(A){console.log("expo-image-picker not available:",A),ee.Alert.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"){ee.Alert.alert("Permission needed","Please grant photo library access to select images.");return}console.log("Waiting for UI to stabilize..."),await new Promise(A=>setTimeout(()=>A(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 A=k.assets[0];console.log("Photo selected successfully:",A.uri);try{console.log("Starting image compression...");let z=rs(A.width||1920,A.height||1920),L=await ns(A.uri,z);console.log("Image compression completed:",L),M?.({type:"image",data:{...L,originalFileSize:A.fileSize}})}catch(z){console.error("Image compression failed:",z),ee.Alert.alert("Compression Error","Failed to compress image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:A.uri,width:A.width,height:A.height,fileSize:A.fileSize,fileName:A.fileName||"image.jpg"}})}}else console.log("Photo selection was canceled by user")}catch(v){console.error("Error in photo selection process:",v),ee.Alert.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),C=(0,ot.useCallback)(async()=>{console.log("Camera capture initiated");try{let v;try{v=await import("expo-image-picker")}catch(A){console.log("expo-image-picker not available:",A),ee.Alert.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"){ee.Alert.alert("Permission needed","Please grant camera access to take photos.");return}console.log("Waiting for UI to stabilize..."),await new Promise(A=>setTimeout(()=>A(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 A=k.assets[0];console.log("Photo captured successfully:",A.uri);try{console.log("Starting camera image compression...");let z=rs(A.width||1920,A.height||1920),L=await ns(A.uri,z);console.log("Camera image compression completed:",L),M?.({type:"image",data:{...L,originalFileSize:A.fileSize}})}catch(z){console.error("Camera image compression failed:",z),ee.Alert.alert("Compression Error","Failed to compress captured image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:A.uri,width:A.width,height:A.height,fileSize:A.fileSize,fileName:A.fileName||"camera_photo.jpg"}})}}else console.log("Camera capture was canceled by user")}catch(v){console.error("Error in camera capture process:",v),ee.Alert.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),S=(0,ot.useCallback)(async()=>{console.log("Location sharing initiated");try{let v;try{v=await import("expo-location")}catch(L){console.log("expo-location not available:",L),ee.Alert.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"){ee.Alert.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 A=await v.reverseGeocodeAsync({latitude:k.coords.latitude,longitude:k.coords.longitude}),z={coordinates:{latitude:k.coords.latitude,longitude:k.coords.longitude},address:A[0]||null,timestamp:k.timestamp};console.log("Location shared successfully:",z.coordinates),M?.({type:"location",data:z})}catch(v){console.error("Error in location sharing process:",v),ee.Alert.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),V=(0,ot.useCallback)(async()=>{try{let v;try{v=await import("expo-contacts")}catch(k){console.log("expo-contacts not available:",k),ee.Alert.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"){ee.Alert.alert("Permission needed","Please grant contacts access to share contacts.");return}ee.Alert.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),ee.Alert.alert("Error","Failed to access contacts. Please try again.")}finally{R.current?.hide()}},[]),I=(0,ot.useCallback)(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),ee.Alert.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),ee.Alert.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[M]),P=(0,ot.useCallback)(()=>{ee.Alert.alert("Create Poll","Poll creation feature is coming soon! This would open a poll creation interface.",[{text:"OK",onPress:()=>console.log("Poll creation acknowledged")}])},[]),D=(0,ot.useCallback)(()=>{ee.Alert.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=(0,ot.useCallback)(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await T();break;case"camera":await C();break;case"location":await S();break;case"contact":await V();break;case"document":await I();break;case"poll":P();break;case"event":D();break;default:console.warn(`Unknown attachment option: ${v}`)}}catch(B){console.error(`Error handling ${v}:`,B),ee.Alert.alert("Error",`Failed to handle ${v}. Please try again.`)}},[T,C,S,V,I,P,D]);return{menuRef:R,handleOptionSelect:E,options:za}};var G=$(require("react")),Qt=(M={})=>{let{initialValue:R="",initialHeight:T=50,onValueChange:C,onHeightChange:S,onSend:V,onAttachmentSend:I,onReplyCancel:P,onFocus:D,onBlur:E,maxHeight:v=100,minHeight:B=50,maxLength:k=1e3,placeholder:A="Type a message..."}=M,z=(0,G.useRef)(null),[L,O]=G.default.useState(R),[j,H]=G.default.useState(T),[N,F]=G.default.useState(!1),[te,je]=G.default.useState(null),[Me,Ee]=G.default.useState([]),Te=G.default.useMemo(()=>({value:L,height:j,isFocused:N,replyToMessage:te,attachments:Me}),[L,j,N,te,Me]),De=(0,G.useCallback)(ze=>{O(ze),C?.(ze)},[C]),Ae=(0,G.useCallback)(ze=>{let Ne=Math.max(B,Math.min(v,ze));H(Ne),S?.(Ne)},[B,v,S]),Ye=(0,G.useCallback)(()=>{F(!0),D?.()},[D]),U=(0,G.useCallback)(()=>{F(!1),E?.()},[E]),$e=(0,G.useCallback)(ze=>{let{height:Ne}=ze.nativeEvent.contentSize,Kt=Math.max(B,Math.min(v,Ne+16));Ae(Kt)},[B,v,Ae]),Fe=(0,G.useCallback)(()=>{V&&(L||Me.length>0)&&(V(L,Me,te),O(R),Ee([]),je(null),H(T))},[V,L,Me,te,R,T]),Tt=(0,G.useCallback)(ze=>{I?(I(ze,L),L&&O(R)):Ee(Ne=>[...Ne,{...ze,id:Date.now().toString()}])},[I,L,R]),Ce=(0,G.useCallback)(ze=>{Ee(Ne=>[...Ne,ze])},[]),Ge=(0,G.useCallback)(ze=>{Ee(Ne=>Ne.filter(Kt=>Kt.id!==ze))},[]),Xe=(0,G.useCallback)(()=>{Ee([])},[]),we=(0,G.useCallback)(()=>{je(null),P?.()},[P]),It=(0,G.useCallback)(()=>{z.current?.focus()},[]),Ct=G.default.useMemo(()=>({setValue:De,setHeight:Ae,setFocus:F,setReplyToMessage:je,addAttachment:Ce,removeAttachment:Ge,clearAttachments:Xe,sendMessage:Fe,cancelReply:we,focusInput:It,handleAttachmentSelected:Tt,handleContentSizeChange:$e,handleFocus:Ye,handleBlur:U}),[De,Ae,F,je,Ce,Ge,Xe,Fe,we,It,Tt,$e,Ye,U]),Xo=G.default.useMemo(()=>({textInputRef:z}),[]);return{state:Te,actions:Ct,refs:Xo}},ai=(0,G.createContext)(null);var mt=(0,We.forwardRef)(({value:M,onChangeText:R,onSend:T,onFocus:C,height:S,onContentSizeChange:V,replyToMessage:I,onCancelReply:P,onAttachmentSend:D},E)=>{let v=Y(),B=ke(),k=(0,We.useRef)(null);(0,We.useImperativeHandle)(E,()=>({focus:()=>{k.current?.focus()}}));let{state:A,actions:z}=Qt({initialValue:M,initialHeight:S,onValueChange:R,onHeightChange:V,onSend:T,onAttachmentSend:D,onReplyCancel:P,onFocus:C});We.default.useEffect(()=>{M!==A.value&&z.setValue(M)},[M,A.value,z]),We.default.useEffect(()=>{S!==A.height&&z.setHeight(S)},[S,A.height,z]),We.default.useEffect(()=>{I!==A.replyToMessage&&z.setReplyToMessage(I||null)},[I,A.replyToMessage,z]),We.default.useEffect(()=>{if(I&&k.current){let j=setTimeout(()=>{k.current?.focus()},100);return()=>clearTimeout(j)}},[I]);let L=(0,We.useCallback)(j=>{if(console.log("Attachment selected:",j),D)D(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)}},[D,M,R]),O=Wo(L);return<>
|
|
382
|
+
{I&&P&&<Xt replyToMessage={I}onCancel={P}/>}
|
|
383
|
+
<Je.View style={{borderTopWidth:1,borderTopColor:v.colors.borderLight,backgroundColor:v.colors.background}}>
|
|
384
|
+
<Je.View style={{flexDirection:"row",alignItems:"center",backgroundColor:v.colors.background,paddingHorizontal:v.spacing.lg,paddingVertical:v.spacing.sm,minHeight:S}}>
|
|
385
|
+
<Je.TouchableOpacity style={{marginRight:v.spacing.md}}onPress={()=>O.menuRef.current?.show()}>
|
|
386
|
+
<Ht.Plus size={24}color={v.colors.textSecondary}/>
|
|
387
|
+
</Je.TouchableOpacity>
|
|
388
388
|
|
|
389
|
-
<
|
|
390
|
-
<
|
|
391
|
-
</
|
|
389
|
+
<Je.View style={{flex:1,flexDirection:"row",alignItems:"center",borderRadius:v.borderRadius.full,backgroundColor:v.colors.surfaceSecondary,paddingHorizontal:v.spacing.lg,paddingVertical:6}}>
|
|
390
|
+
<Je.TextInput ref={k}style={{flex:1,fontSize:v.typography.fontSize.base,maxHeight:70,minHeight:18,paddingTop:Je.Platform.OS==="ios"?6:3,paddingBottom:Je.Platform.OS==="ios"?6:3,color:v.colors.text}}value={M}onChangeText={R}placeholder={B("input.placeholder")}placeholderTextColor={v.colors.textMuted}multiline maxLength={1e3}onFocus={C}onContentSizeChange={z.handleContentSizeChange}returnKeyType='default'textAlignVertical='center'/>
|
|
391
|
+
</Je.View>
|
|
392
392
|
|
|
393
|
-
<
|
|
394
|
-
{
|
|
395
|
-
</
|
|
396
|
-
</
|
|
397
|
-
</
|
|
393
|
+
<Je.TouchableOpacity onPress={T}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()?<Ht.Send size={18}color='white'/>:<Ht.Mic size={18}color='white'/>}
|
|
395
|
+
</Je.TouchableOpacity>
|
|
396
|
+
</Je.View>
|
|
397
|
+
</Je.View>
|
|
398
398
|
|
|
399
|
-
<
|
|
400
|
-
</>});mt.displayName="MessageInput";var
|
|
401
|
-
{
|
|
402
|
-
|
|
399
|
+
<St ref={O.menuRef}onOptionSelect={O.handleOptionSelect}options={O.options}/>
|
|
400
|
+
</>});mt.displayName="MessageInput";var Uo=require("react-native"),is=require("lucide-react-native");var qo=$(require("react"));var yt=$(require("react"));var Ko=require("react");function eo(M,R={}){let{initialNumToRender:T=20,maxToRenderPerBatch:C=10,windowSize:S=10}=R,V=(0,Ko.useMemo)(()=>Ao(M).reverse(),[M]),I=(0,Ko.useCallback)(P=>P.listItemType==="date-separator"?P.id:P.id.toString(),[]);return{messageItems:V,keyExtractor:I,flatListProps:{initialNumToRender:T,maxToRenderPerBatch:C,windowSize:S,inverted:!0,showsVerticalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",removeClippedSubviews:!1,scrollEventThrottle:16}}}var Ue=require("react");function ls(M={}){let{scrollThreshold:R=50,autoScrollToBottom:T=!0}=M,C=(0,Ue.useRef)(null),[S,V]=(0,Ue.useState)({isNearBottom:!0,isNearTop:!1,showScrollToBottomButton:!1}),I=(0,Ue.useRef)(0),P=(0,Ue.useCallback)(z=>{let{contentOffset:L,contentSize:O,layoutMeasurement:j}=z.nativeEvent,H=L.y,N=Math.abs(H)<R,F=Math.abs(H)>O.height-j.height-R;V({isNearBottom:N,isNearTop:F,showScrollToBottomButton:!N})},[R]),D=(0,Ue.useCallback)(z=>{let L=z>I.current;return I.current=z,L},[]),E=(0,Ue.useCallback)(()=>{},[]),v=(0,Ue.useCallback)((z=!0)=>{C.current&&C.current.scrollToOffset({offset:0,animated:z})},[]),B=(0,Ue.useCallback)((z,L=!0)=>{C.current&&C.current.scrollToOffset({offset:z,animated:L})},[]),k=(0,Ue.useCallback)((z,L=!0)=>{C.current&&C.current.scrollToIndex({index:z,animated:L})},[]),A=(0,Ue.useCallback)(z=>{D(z)&&T&&C.current&&setTimeout(()=>{v()},100)},[D,T,v]);return{flatListRef:C,scrollState:S,handleScroll:P,handleContentSizeChange:E,handleNewMessages:A,scrollToEnd:v,scrollToOffset:B,scrollToIndex:k}}var Nt=require("react");function to(M={}){let{enableMessageActions:R=!0}=M,[T,C]=(0,Nt.useState)({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0}),S=(0,Nt.useCallback)((P,D)=>{R&&C({actionSheetVisible:!0,selectedMessage:P,messagePosition:D})},[R]),V=(0,Nt.useCallback)(()=>{C({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0})},[]),I=(0,Nt.useCallback)((P,D)=>{if(!T.selectedMessage)return;let{selectedMessage:E}=T;switch(P){case"reply":D?.onReply?.(E);break;case"copy":if(D?.onCopy)D.onCopy(E);else{let v=E.type==="image"&&E.imageData?E.text||"Image message":E.text;Promise.resolve().then(()=>(Ys(),qs)).then(({copyToClipboard:B})=>{B(v)}).catch(()=>{console.log("Clipboard functionality not available")})}break;case"delete":D?.onDelete?.(E.id);break;default:D?.onCustomAction?.(P,E);break}V()},[T.selectedMessage,V]);return{actionState:T,handleMessageLongPress:S,handleActionSheetClose:V,handleActionPress:I}}var dt=require("react");function oo(M={}){let{enableReactionDetails:R=!0}=M,[T,C]=(0,dt.useState)({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),[S,V]=(0,dt.useState)(null),I=(0,dt.useCallback)(B=>{R&&B.reactions&&B.reactions.length>0&&(V(B),C({isReactionDetailsVisible:!0,selectedReactions:B.reactions,selectedMessageText:B.text}))},[R]),P=(0,dt.useCallback)(()=>{C({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),V(null)},[]),D=(0,dt.useCallback)((B,k)=>{S&&k?.(S.id,B),P()},[S,P]),E=(0,dt.useCallback)((B,k)=>{S&&k?.(S.id,B),P()},[S,P]),v=(0,dt.useCallback)((B,k)=>{S&&k?.(S.id,B)},[S]);return{reactionState:T,selectedMessage:S,handleReactionPress:I,handleReactionDetailsClose:P,handleAddReaction:D,handleRemoveReaction:E,handleEmojiReact:v}}var so=require("react");function cs(){let[M,R]=(0,so.useState)({replyToMessage:null}),T=(0,so.useCallback)(S=>{R({replyToMessage:S})},[]),C=(0,so.useCallback)(()=>{R({replyToMessage:null})},[]);return{replyState:M,setReplyToMessage:T,clearReply:C}}var $s=(0,yt.createContext)(null);function Wt(){let M=(0,yt.useContext)($s);if(!M)throw new Error("useMessageListContext must be used within MessageListProvider");return M}function Mo({children:M,messages:R,config:T={},...C}){let S=eo(R,T),V=ls(T),I=to(T),P=oo(T),D=cs();yt.default.useEffect(()=>{V.handleNewMessages(R.length)},[R.length,V.handleNewMessages]);let E=(0,yt.useMemo)(()=>({messageList:S,scroll:V,actions:I,reactions:P,reply:D,config:T,callbacks:C}),[S,V,I,P,D,T,C]);return<$s.Provider value={E}>
|
|
401
|
+
{M}
|
|
402
|
+
</$s.Provider>}var To=require("react"),Ut=require("react-native");var xt={Provider:Mo,Container:({children:M,style:R})=><Ut.View style={[Gs.container,R]}>{M}</Ut.View>,Messages:({renderMessage:M,style:R})=>{let{messageList:T,scroll:C,actions:S,reactions:V,callbacks:I}=Wt(),P=(0,To.useCallback)(({item:E,index:v})=>M&&E.listItemType!=="date-separator"?M({message:E,index:v})||null:E.listItemType==="date-separator"?<No date={E.date}displayDate={E.displayDate}/>:<Do message={E}onLongPress={S.handleMessageLongPress}onReactionPress={V.handleReactionPress}onReactionRemove={I.onReactionRemove}/>,[S.handleMessageLongPress,V.handleReactionPress,I.onReactionRemove,M]),D=(0,To.useCallback)(E=>{C.handleScroll(E);let{isNearBottom:v,isNearTop:B}=C.scrollState;I.onScrollPositionChange?.(v,B),v&&I.onScrollToBottom?.(),B&&I.onScrollToTop?.()},[C.handleScroll,C.scrollState,I]);return<Ut.FlatList ref={C.flatListRef}data={T.messageItems}renderItem={P}keyExtractor={T.keyExtractor}contentContainerStyle={[Gs.contentContainer,R]}onContentSizeChange={C.handleContentSizeChange}onScroll={D}{...T.flatListProps}/>},TypingIndicator:({isVisible:M})=>M?<Ft isVisible={M}/>:null,ScrollButton:({visible:M,isReplyActive:R,onPress:T})=>{let{scroll:C}=Wt();return<Ho visible={M??C.scrollState.showScrollToBottomButton}onPress={T??C.scrollToEnd}isReplyActive={R}/>},ActionSheet:()=>{let{actions:M,reactions:R,reply:T,callbacks:C,config:S}=Wt(),V=(0,To.useCallback)(P=>{M.handleActionPress(P,{onReply:D=>{T.setReplyToMessage(D),C.onReplyMessage?.(D)},onDelete:C.onMessageDelete,onCustomAction:C.onActionPress})},[M.handleActionPress,T.setReplyToMessage,C]),I=(0,To.useCallback)(P=>{console.log("\u{1F525} MessageListCompound - handleEmojiReact called with emoji:",P);let D=M.actionState.selectedMessage;console.log("\u{1F525} MessageListCompound - selectedMessage:",D?.id,"callbacks.onReactionAdd exists:",!!C.onReactionAdd),D&&C.onReactionAdd?(console.log("\u{1F525} MessageListCompound - Calling onReactionAdd for message:",D.id,"emoji:",P),C.onReactionAdd(D.id,P)):console.log("\u{1F525} MessageListCompound - NOT calling onReactionAdd. selectedMessage:",!!D,"callback exists:",!!C.onReactionAdd)},[M.actionState.selectedMessage,C.onReactionAdd]);return S.enableMessageActions?<Lo visible={M.actionState.actionSheetVisible}onClose={M.handleActionSheetClose}isMyMessage={M.actionState.selectedMessage?.isMe||!1}selectedMessage={M.actionState.selectedMessage||void 0}messagePosition={M.actionState.messagePosition}onActionPress={V}onEmojiReact={I}/>:null},ReactionDetails:()=>{let{reactions:M,callbacks:R,config:T}=Wt();return T.enableReactionDetails?<Eo visible={M.reactionState.isReactionDetailsVisible}onClose={M.handleReactionDetailsClose}reactions={M.reactionState.selectedReactions}messageText={M.reactionState.selectedMessageText}onRemoveReaction={C=>M.handleRemoveReaction(C,R.onReactionRemove)}/>:null}},Gs=Ut.StyleSheet.create({container:{flex:1},contentContainer:{paddingVertical:16}});var pt=(0,qo.forwardRef)(({messages:M,isTyping:R,showScrollToBottom:T=!1,isReplyActive:C=!1,...S},V)=>{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 qo.default.useImperativeHandle(V,()=>({scrollToEnd:(D=!0)=>{},scrollToOffset:(D,E=!0)=>{},scrollToIndex:(D,E=!0)=>{}}),[]),<Mo messages={M}config={I}{...P}>
|
|
403
403
|
<xt.Container>
|
|
404
404
|
<xt.Messages/>
|
|
405
405
|
<xt.TypingIndicator isVisible={R}/>
|
|
406
|
-
<xt.ScrollButton visible={
|
|
406
|
+
<xt.ScrollButton visible={T?void 0:!1}isReplyActive={C}/>
|
|
407
407
|
<xt.ActionSheet/>
|
|
408
408
|
<xt.ReactionDetails/>
|
|
409
409
|
</xt.Container>
|
|
410
|
-
</
|
|
411
|
-
{
|
|
412
|
-
<bt.Text style={{color:
|
|
410
|
+
</Mo>});pt.displayName="MessageList";var _s=$(require("react"));function He(M){let R=_s.default.forwardRef((C,S)=>(vt(),<M{...C}ref={S}/>)),T=M.displayName||M.name||"Component";return R.displayName=`RequireAuth(${T})`,R}function st(M){return(...R)=>(vt(),M(...R))}var Yo=require("react-native");var Ke=require("react-native");var bt=require("react-native");var ka=({avatar:M,isOnline:R=!1,size:T="medium"})=>{let C=Y(),S=()=>{switch(T){case"small":return{width:32,height:32};case"large":return{width:64,height:64};default:return{width:48,height:48}}},V=()=>{switch(T){case"small":return{width:12,height:12};case"large":return{width:24,height:24};default:return{width:16,height:16}}},I=S(),P=V(),E=(()=>{switch(T){case"small":return 14;case"large":return 28;default:return 20}})();return<bt.View style={{position:"relative"}}>
|
|
411
|
+
{M&&M.trim()!==""?<bt.Image source={{uri:M}}style={[I,{borderRadius:C.borderRadius.full}]}resizeMode="cover"/>:<bt.View style={[I,{borderRadius:C.borderRadius.full,backgroundColor:C.colors.primary,justifyContent:"center",alignItems:"center"}]}>
|
|
412
|
+
<bt.Text style={{color:C.colors.background,fontSize:E,fontWeight:"600"}}>
|
|
413
413
|
👤
|
|
414
414
|
</bt.Text>
|
|
415
415
|
</bt.View>}
|
|
416
416
|
|
|
417
417
|
{}
|
|
418
|
-
{R&&<bt.View style={[P,{position:"absolute",bottom:-2,right:-2,backgroundColor:
|
|
419
|
-
</bt.View>},
|
|
420
|
-
<
|
|
421
|
-
<
|
|
422
|
-
</
|
|
418
|
+
{R&&<bt.View style={[P,{position:"absolute",bottom:-2,right:-2,backgroundColor:C.colors.online,borderRadius:C.borderRadius.full,borderWidth:2,borderColor:C.colors.background}]}/>}
|
|
419
|
+
</bt.View>},Co=ka;var La=({item:M,onPress:R})=>{let T=Y(),C=M.unreadCount&&M.unreadCount>0;return<Ke.TouchableOpacity style={{flexDirection:"row",alignItems:"center",paddingHorizontal:T.spacing.lg,paddingVertical:T.spacing.md,borderBottomWidth:1,borderBottomColor:T.colors.borderLight,backgroundColor:C?T.colors.unread:T.colors.background}}onPress={()=>R(M)}>
|
|
420
|
+
<Ke.View style={{marginRight:T.spacing.md}}>
|
|
421
|
+
<Co avatar={M.avatar}isOnline={M.isOnline}size="medium"/>
|
|
422
|
+
</Ke.View>
|
|
423
423
|
|
|
424
|
-
<
|
|
424
|
+
<Ke.View style={{flex:1,marginRight:T.spacing.md}}>
|
|
425
425
|
{}
|
|
426
|
-
<
|
|
427
|
-
<
|
|
428
|
-
{
|
|
429
|
-
</
|
|
430
|
-
<
|
|
431
|
-
{
|
|
432
|
-
</
|
|
433
|
-
</
|
|
426
|
+
<Ke.View style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:T.spacing.xs}}>
|
|
427
|
+
<Ke.Text style={{fontSize:T.typography.fontSize.base,flex:1,fontWeight:C?T.typography.fontWeight.bold:T.typography.fontWeight.semibold,color:T.colors.text}}>
|
|
428
|
+
{M.name}
|
|
429
|
+
</Ke.Text>
|
|
430
|
+
<Ke.Text style={{fontSize:T.typography.fontSize.sm,marginLeft:T.spacing.sm,color:C?T.colors.gray[700]:T.colors.textSecondary,fontWeight:C?T.typography.fontWeight.medium:T.typography.fontWeight.normal}}>
|
|
431
|
+
{M.time}
|
|
432
|
+
</Ke.Text>
|
|
433
|
+
</Ke.View>
|
|
434
434
|
|
|
435
435
|
{}
|
|
436
|
-
<
|
|
437
|
-
<
|
|
438
|
-
{
|
|
439
|
-
</
|
|
440
|
-
{
|
|
441
|
-
<
|
|
442
|
-
{
|
|
443
|
-
</
|
|
444
|
-
</
|
|
445
|
-
</
|
|
446
|
-
</
|
|
447
|
-
</
|
|
448
|
-
|
|
449
|
-
{
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
<
|
|
453
|
-
<
|
|
454
|
-
<
|
|
455
|
-
</
|
|
436
|
+
<Ke.View style={{flexDirection:"row",alignItems:"center"}}>
|
|
437
|
+
<Ke.Text style={{fontSize:T.typography.fontSize.sm,flex:1,color:C?T.colors.gray[800]:T.colors.textSecondary,fontWeight:C?T.typography.fontWeight.medium:T.typography.fontWeight.normal}}numberOfLines={1}>
|
|
438
|
+
{M.message}
|
|
439
|
+
</Ke.Text>
|
|
440
|
+
{M.unreadCount&&<Ke.View style={{width:20,height:20,backgroundColor:T.colors.primary,borderRadius:T.borderRadius.full,alignItems:"center",justifyContent:"center",marginLeft:T.spacing.sm}}>
|
|
441
|
+
<Ke.Text style={{fontSize:T.typography.fontSize.xs,color:"white",fontWeight:T.typography.fontWeight.bold}}>
|
|
442
|
+
{M.unreadCount}
|
|
443
|
+
</Ke.Text>
|
|
444
|
+
</Ke.View>}
|
|
445
|
+
</Ke.View>
|
|
446
|
+
</Ke.View>
|
|
447
|
+
</Ke.TouchableOpacity>},Ro=La;var ja=({chats:M,onChatPress:R,onRefresh:T,refreshing:C=!1})=>{let S=({item:V})=><Ro item={V}onPress={R}/>;return<Yo.FlatList data={M}renderItem={S}keyExtractor={V=>V.id}showsVerticalScrollIndicator={!1}style={{flex:1}}refreshControl={T?<Yo.RefreshControl refreshing={C}onRefresh={T}tintColor="#007AFF"colors={["#007AFF"]}/>:void 0}/>},ds=ja;var $o=require("react-native");var Ea=({title:M})=>{let R=Y();return<$o.View style={{backgroundColor:R.colors.background,paddingHorizontal:R.spacing.lg,paddingVertical:R.spacing.lg,borderBottomWidth:1,borderBottomColor:R.colors.borderLight}}>
|
|
448
|
+
<$o.Text style={{fontSize:R.typography.fontSize.xxl,fontWeight:R.typography.fontWeight.bold,color:R.colors.text}}>
|
|
449
|
+
{M}
|
|
450
|
+
</$o.Text>
|
|
451
|
+
</$o.View>},us=Ea;var Mt=require("react-native"),Go=require("lucide-react-native");var Fa=({value:M,onChangeText:R,onClear:T,placeholder:C})=>{let S=Y(),I=ke()("search.placeholder");return<Mt.View style={{backgroundColor:S.colors.background,paddingHorizontal:S.spacing.lg,paddingVertical:S.spacing.md,borderBottomWidth:1,borderBottomColor:S.colors.borderLight}}>
|
|
452
|
+
<Mt.View style={{position:"relative"}}>
|
|
453
|
+
<Mt.View style={{position:"absolute",left:S.spacing.md,top:"50%",transform:[{translateY:-10}],zIndex:10}}>
|
|
454
|
+
<Go.Search size={20}color={S.colors.textMuted}/>
|
|
455
|
+
</Mt.View>
|
|
456
456
|
|
|
457
|
-
<
|
|
457
|
+
<Mt.TextInput value={M}onChangeText={R}placeholder={C||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
|
-
{
|
|
460
|
-
<
|
|
461
|
-
</
|
|
462
|
-
</
|
|
463
|
-
</
|
|
459
|
+
{M.length>0&&<Mt.TouchableOpacity onPress={T}style={{position:"absolute",right:S.spacing.md,top:"50%",transform:[{translateY:-10}]}}hitSlop={{top:10,bottom:10,left:10,right:10}}>
|
|
460
|
+
<Go.X size={20}color={S.colors.textMuted}/>
|
|
461
|
+
</Mt.TouchableOpacity>}
|
|
462
|
+
</Mt.View>
|
|
463
|
+
</Mt.View>},ms=Fa;var ut=require("react"),_o=$(require("dayjs")),wt=(0,_o.default)(),Js=wt.subtract(1,"day"),Xs=wt.subtract(2,"day"),Zs=wt.subtract(3,"day"),Oa=[{id:1,text:"Hi! How are you?",isMe:!1,timestamp:Zs.hour(10).minute(30).toISOString(),senderName:"Anna"},{id:2,text:"Hey! Great, thanks! And you?",isMe:!0,timestamp:Zs.hour(10).minute(31).toISOString(),reactions:[{emoji:"\u2764\uFE0F",count:1,users:["anna"]}]},{id:3,text:"Good too! What are we doing tonight?",isMe:!1,timestamp:Xs.hour(14).minute(20).toISOString(),senderName:"Anna"},{id:4,text:"Maybe we could go to the movies?",isMe:!0,timestamp:Xs.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:Js.hour(9).minute(15).toISOString(),senderName:"Anna"},{id:6,text:"Great! What movies are you interested in?",isMe:!0,timestamp:Js.hour(9).minute(20).toISOString()},{id:7,text:"Maybe something action or comedy?",isMe:!1,timestamp:wt.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:wt.hour(8).minute(35).toISOString()},{id:9,text:"Perfect! What time should we meet?",isMe:!1,timestamp:wt.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:wt.hour(9).minute(15).toISOString(),reactions:[{emoji:"\u{1F44D}",count:1,users:["anna"]},{emoji:"\u23F0",count:1,users:["me"]}]}],ps=M=>{let R=Oa.map(v=>v.isMe?v:{...v,senderName:M||v.senderName}),[T,C]=(0,ut.useState)(R),S=(0,ut.useCallback)((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:(0,_o.default)().toISOString(),status:"sent",replyTo:B};C(A=>[...A,k]),setTimeout(()=>{C(A=>A.map(z=>z.id===k.id?{...z,status:"delivered"}:z))},1e3),setTimeout(()=>{C(A=>A.map(z=>z.id===k.id?{...z,status:"read"}:z))},3e3)},[]),V=(0,ut.useCallback)((v,B,k)=>{let A={id:Date.now(),text:B||"",isMe:!0,timestamp:(0,_o.default)().toISOString(),status:"sent",type:"image",imageData:v,replyTo:k};C(z=>[...z,A]),setTimeout(()=>{C(z=>z.map(L=>L.id===A.id?{...L,status:"delivered"}:L))},1e3),setTimeout(()=>{C(z=>z.map(L=>L.id===A.id?{...L,status:"read"}:L))},3e3)},[]),I=(0,ut.useCallback)((v,B)=>{C(k=>k.map(A=>A.id===v?{...A,status:B}:A))},[]),P=(0,ut.useCallback)((v,B)=>{C(k=>k.map(A=>{if(A.id===v){let z=A.reactions||[],L=z.findIndex(O=>O.emoji===B);if(L>=0){let O=[...z];return O[L]={...O[L],count:O[L].count+1,users:[...O[L].users,"me"]},{...A,reactions:O}}else{let O={emoji:B,count:1,users:["me"]};return{...A,reactions:[...z,O]}}}return A}))},[]),D=(0,ut.useCallback)((v,B)=>{console.log("removeReaction 1212121 called with messageId:",v,"and emoji:",B),C(k=>k.map(A=>{if(A.id===v){let z=A.reactions||[],L=z.findIndex(O=>O.emoji===B);if(L>=0){let O=z[L];if(O.count>1){let j=[...z];return j[L]={...O,count:O.count-1,users:O.users.filter(H=>H!=="me")},{...A,reactions:j}}else return{...A,reactions:z.filter(j=>j.emoji!==B)}}}return A}))},[]),E=(0,ut.useCallback)(v=>{console.log("deleteMessage called with messageId:",v),C(B=>{let k=B.map(A=>A.id===v?{...A,deleted:!0}:A);return console.log("Message marked as deleted:",v),k})},[]);return{messages:T,sendMessage:S,sendImageMessage:V,updateMessageStatus:I,addReaction:P,deleteMessage:E,removeReaction:D}};var qe=require("react");var gs=(M={})=>{vt();let[R,T]=(0,qe.useState)(M.initialMessages||[]),[C,S]=(0,qe.useState)(!1),V=(0,qe.useCallback)((z,L)=>{let O={id:Date.now(),text:z,isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:L?{id:L.id,text:L.text,senderName:L.senderName,isMe:L.isMe}:void 0};T(j=>[O,...j])},[]),I=(0,qe.useCallback)(z=>{T(L=>[z,...L])},[]),P=(0,qe.useCallback)((z,L)=>{T(O=>O.map(j=>j.id===z?{...j,...L}:j))},[]),D=(0,qe.useCallback)(z=>{T(L=>L.filter(O=>O.id!==z))},[]),E=(0,qe.useCallback)((z,L)=>{T(O=>O.map(j=>{if(j.id!==z)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=(0,qe.useCallback)((z,L)=>{T(O=>O.map(j=>{if(j.id!==z)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(te=>te!=="current-user")}:F)}:j}))},[]),B=(0,qe.useCallback)(z=>{S(z)},[]),k=(0,qe.useCallback)(()=>{T(M.initialMessages||[]),S(!1)},[M.initialMessages]),A=(0,qe.useCallback)(z=>R.find(L=>L.id===z),[R]);return{messages:R,isTyping:C,sendMessage:V,addReaction:E,removeReaction:v,setMessages:T,addMessage:I,updateMessage:P,deleteMessage:D,setTyping:B,resetChat:k,getMessageById:A}};var Jo=require("react");var Qs=()=>{let M=ke(),R=()=>"en";return{formatDate:P=>Ds(P,M,R()),formatTime:P=>Jt(P,R()),formatRelative:P=>ks(P,R()),formatDateTimeWithTime:P=>Ls(P,M,R()),groupMessages:P=>Ao(P,R())}};var Ha=He(ts),Na=He(es),Wa=st(Gt),Ua=He(pt),Ka=He(mt),qa=He(Po),Ya=He(Ft),$a=He(ds),Ga=He(Ro),_a=He(us),Ja=He(ms),Xa=He(Co),Za=He(St),Qa=He(vs),en=st(Y),tn=st(gs),on=st(ps),sn=st(eo),an=st(to),nn=st(oo),rn=st(_t),ln=st(Qt),cn=st(Qs);0&&(module.exports={AttachmentMenu,Chat,ChatAvatar,ChatHeader,ChatItem,ChatList,ChatListSearchBar,ChatProvider,ChatScreenHeader,I18nProvider,MessageInput,MessageList,ThemeProvider,TypingIndicator,defaultTheme,defaultTranslations,getAuthState,getProjectId,getTranslation,initChat,isInitialized,isSupportedLocale,useAttachments,useChatConfig,useChatMessages,useChatSDK,useDateFormatter,useMessageActions,useMessageInput,useMessageList,useMessageReactions,useTheme,useTranslation,useTranslationFunction});
|