{"size": 13748, "ext": "js", "max_stars_repo_path": "whatsapp-clone/build/static/js/main.895ff506.chunk.js", "max_stars_repo_name": "Samuel-Ricardo/WhatsApp-Clone", "max_stars_repo_stars_event_min_datetime": "2021-04-14T19:35:01.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-14T18:55:33.000Z", "max_issues_repo_path": "whatsapp-clone/build/static/js/main.895ff506.chunk.js", "max_issues_repo_name": "Samuel-Ricardo/WhatsApp-Clone", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "whatsapp-clone/build/static/js/main.895ff506.chunk.js", "max_forks_repo_name": "Samuel-Ricardo/WhatsApp-Clone", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 6874.0, "max_line_length": 13700, "alphanum_fraction": 0.6762438173}
(this["webpackJsonpwhatsapp-clone"]=this["webpackJsonpwhatsapp-clone"]||[]).push([[0],{53:function(e,t,a){},55:function(e,t,a){},56:function(e,t,a){},67:function(e,t,a){},68:function(e,t,a){},69:function(e,t,a){},75:function(e,t,a){},76:function(e,t,a){},78:function(e,t,a){"use strict";a.r(t);var c=a(3),n=a.n(c),s=a(24),r=a.n(s),i=(a(53),a(7)),o=a.n(i),l=a(12),u=a(10),d=(a(55),a(45)),j=a.n(d),h=a(46),b=a.n(h),f=a(26),p=a.n(f),v=a(20),O=a.n(v),m=(a(56),"#919191"),x={GHOST:a.p+"static/media/ghost.78a34c6f.png",USER:a.p+"static/media/user-green.cfde39fc.png"},g=a(29),N=a(19),w=(a(58),a(59),a(60),a(61),a(62),a(63),a(64),a(65),N.a.initializeApp({apiKey:"AIzaSyB27158ai7gdqKGFxpHtFQIfhnYtNbVfmE",authDomain:"whatsapp-2-a85f3.firebaseapp.com",projectId:"whatsapp-2-a85f3",storageBucket:"whatsapp-2-a85f3.appspot.com",messagingSenderId:"596771972223",appId:"1:596771972223:web:537307414d253749e28b4a",measurementId:"G-N8LSV7PKW8"})),y=w.firestore(),k={facebookLoginPopup:function(){var e=Object(l.a)(o.a.mark((function e(){var t,a;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new N.a.auth.FacebookAuthProvider,e.next=3,w.auth().signInWithPopup(t);case 3:return a=e.sent,e.abrupt("return",a);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),addUser:function(){var e=Object(l.a)(o.a.mark((function e(t){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y.collection("User").doc(t.id).set({name:t.name,avatar:t.avatar},{merge:!0});case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),getContactList:function(){var e=Object(l.a)(o.a.mark((function e(t){var a;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=[],e.next=3,y.collection("User").get();case 3:return e.sent.forEach((function(e){var c=e.data();e.id!==t&&a.push({id:e.id,name:c.name,avatar:c.avatar})})),e.abrupt("return",a);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),getUser:function(){var e=Object(l.a)(o.a.mark((function e(t){var a,c;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a={},e.next=3,y.collection("User").doc(t).get();case 3:return e.next=5,e.sent.data();case 5:return c=e.sent,a={id:c.id,name:c.name,avatar:c.avatar},e.abrupt("return",a);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),newChat:function(){var e=Object(l.a)(o.a.mark((function e(t,a){var c;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y.collection("Chat").add({messages:[],users:[t.id,a.id]});case 2:return c=e.sent,y.collection("User").doc(t.id).update({chats:N.a.firestore.FieldValue.arrayUnion({chatId:c.id,title:a.name,image:a.avatar,with:[a.id]})}),y.collection("User").doc(a.id).update({chats:N.a.firestore.FieldValue.arrayUnion({chatId:c.id,title:t.name,image:t.avatar,with:[t.id]})}),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e)})));return function(t,a){return e.apply(this,arguments)}}(),onChatList:function(e,t){return y.collection("User").doc(e).onSnapshot((function(e){if(e.exists){var a=e.data();if(a.chats){var c=Object(g.a)(a.chats);c.sort((function(e,t){return void 0===e.lastMessageDate||void 0===t.lastMessageDate?-1:e.lastMessageDate.seconds<t.lastMessageDate.seconds?1:-1})),t(c)}}}))},onChatContent:function(e,t,a){return y.collection("Chat").doc(e).onSnapshot((function(e){if(e.exists){var c=e.data();console.log(c),t(c.messages),a(c.users)}}))},sendMessage:function(){var e=Object(l.a)(o.a.mark((function e(t,a,c,n,s){var r,i,l,u,d,j;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new Date,y.collection("Chat").doc(t.chatId).update({messages:N.a.firestore.FieldValue.arrayUnion({type:c,author:a,body:n,date:r})}),e.t0=o.a.keys(s);case 3:if((e.t1=e.t0()).done){e.next=17;break}return i=e.t1.value,e.next=7,y.collection("User").doc(s[i]).get();case 7:if(l=e.sent,!(u=l.data()).chats){e.next=15;break}for(j in d=Object(g.a)(u.chats))d[j].chatId===t.chatId&&(d[j].lastMessage=n,d[j].lastMessageDate=r);return e.next=15,y.collection("User").doc(s[i]).update({chats:d});case 15:e.next=3;break;case 17:case"end":return e.stop()}}),e)})));return function(t,a,c,n,s){return e.apply(this,arguments)}}()},C=a(2),S=function(e){var t=e.active,a=e.chat,n=(e.setActiveChat,e.onClick),s=a.image,r=Object(c.useState)(""),i=Object(u.a)(r,2),o=i[0],l=i[1];Object(c.useEffect)((function(){if(a.lastMessageDate>0){var e=new Date(1e3*a.lastMessageDate.seconds),t=e.getHours(),c=e.getMinutes();c=c<10?"0"+c:c,l("".concat(t=t<10?"0"+t:t,":").concat(c))}}),[a]);return Object(C.jsxs)("div",{className:"contact-card  ".concat(t?"active":""),onClick:n,children:[Object(C.jsx)("img",{src:void 0===s||null===s||""===s?x.USER:s,className:"avatar"}),Object(C.jsxs)("div",{className:"lines",children:[Object(C.jsxs)("div",{className:"line",children:[Object(C.jsx)("div",{className:"name",children:a.title}),Object(C.jsx)("div",{className:"date",children:o})]}),Object(C.jsx)("div",{className:"line",children:Object(C.jsx)("div",{className:"lastMessage",children:Object(C.jsx)("p",{children:a.lastMessage})})})]})]})},U=(a(67),function(){return Object(C.jsxs)("div",{className:"intro--view",children:[Object(C.jsx)("h1",{children:" Seja Bem Vindo ao Whatsapp 2 "}),Object(C.jsx)("img",{src:x.GHOST,alt:"ghost",className:"intro--image"}),Object(C.jsx)("h2",{children:" Este clone do whatssap vai al\xe9m do visual, teste o chat, inicie uma conversa com algum usu\xe1rio "}),Object(C.jsx)("h5",{children:"...pedro conteudos ):-()"})]})}),I=(a(68),a(39)),E=a.n(I),M=a(41),F=a.n(M),D=a(40),L=a.n(D),R=a(42),H=a.n(R),P=a(43),A=a.n(P),V=a(37),B=a.n(V),G=(a(69),function(e){var t=e.user,a=e.message,n=(e.key,Object(c.useState)("")),s=Object(u.a)(n,2),r=s[0],i=s[1];return Object(c.useEffect)((function(){if(a.date>0){var e=new Date(1e3*a.date.seconds),t=e.getHours(),c=e.getMinutes();c=c<10?"0"+c:c,i("".concat(t=t<10?"0"+t:t,":").concat(c))}}),[a]),Object(C.jsx)("div",{className:"message-line",style:{justifyContent:t.id===a.author?"flex-end":"flex-start"},children:Object(C.jsxs)("div",{className:"message-item",style:{backgroundColor:t.id===a.author?"#DCF8C6":"flex-start"},children:[Object(C.jsx)("div",{className:"message",children:Object(C.jsx)("p",{className:"text",children:a.body})}),Object(C.jsx)("div",{className:"message-data",children:r})]})})}),K=function(e){var t=e.chat,a=e.user,n=Object(c.useState)(!1),s=Object(u.a)(n,2),r=s[0],i=s[1],o=Object(c.useState)(""),l=Object(u.a)(o,2),d=l[0],j=l[1],h=Object(c.useState)(!1),b=Object(u.a)(h,2),f=b[0],v=b[1],g=Object(c.useState)([]),N=Object(u.a)(g,2),w=N[0],y=N[1],S=Object(c.useState)([]),U=Object(u.a)(S,2),I=U[0],M=U[1],D=Object(c.useRef)(),R=null,P=window.SpeechRecognition||window.webkitSpeechRecognition;void 0!==P&&(R=new P),Object(c.useEffect)((function(){D.current.scrollHeight>D.current.offsetHeight&&(D.current.scrollTop=D.current.scrollHeight-D.current.offsetHeight)}),[w]),Object(c.useEffect)((function(){y([]);k.onChatContent(t.chatId,y,M)}),[t.chatId]);var V=function(){""!==d&&(console.log(""),console.log("users: "),console.log(I),console.log(""),k.sendMessage(t,a.id,"text",d,I),j(""),i(!1))};return Object(C.jsxs)("div",{className:"chat-window",children:[Object(C.jsxs)("header",{children:[Object(C.jsxs)("div",{className:"info",children:[Object(C.jsx)("img",{className:"perfil-image",src:void 0===t.image||null===t.image||""===t.image?x.USER:t.image}),Object(C.jsx)("div",{className:"name",children:t.title})]}),Object(C.jsxs)("div",{className:"button-group",children:[Object(C.jsx)("div",{className:"button",children:Object(C.jsx)(O.a,{style:{color:m}})}),Object(C.jsx)("div",{className:"button",children:Object(C.jsx)(E.a,{style:{color:m}})}),Object(C.jsx)("div",{className:"button",children:Object(C.jsx)(p.a,{style:{color:m}})})]})]}),Object(C.jsx)("div",{ref:D,className:"chat-body",children:w.map((function(e,t){return Object(C.jsx)(G,{user:a,message:e},t)}))}),Object(C.jsx)("section",{className:"emoji-area",style:{height:r?"250px":"0px"},children:Object(C.jsx)(B.a,{onEmojiClick:function(e,t){j(""+d+t.emoji)}})}),Object(C.jsxs)("footer",{className:"chat-input",children:[Object(C.jsx)("div",{className:"left",children:Object(C.jsxs)("div",{className:"button-group",style:{width:r?80:40},children:[Object(C.jsx)("div",{className:"button",onClick:function(){i(!1)},children:Object(C.jsx)(L.a,{style:{color:m,width:r?40:0}})}),Object(C.jsx)("div",{className:"button",onClick:function(){i(!0)},children:Object(C.jsx)(F.a,{style:{color:r?"#009688":m,marginLeft:r?0:-40}})})]})}),Object(C.jsx)("div",{className:"center",children:Object(C.jsx)("input",{type:"search",placeholder:"Pedro Digita\xe7\xf5es >:[]",value:d,onChange:function(e){return j(e.target.value)},onKeyUp:function(e){13==e.keyCode&&V()}})}),Object(C.jsx)("div",{className:"right",children:Object(C.jsx)("div",{className:"button-group",children:""!==d?Object(C.jsx)("div",{className:"button",onClick:V,children:Object(C.jsx)(H.a,{style:{color:m}})}):Object(C.jsx)("div",{className:"button",onClick:function(){null!==R&&(R.onstart=function(){v(!0)},R.onend=function(){v(!1)},R.onresult=function(e){j(d+" "+e.result[0][0].transcript)},R.start())},children:Object(C.jsx)(A.a,{style:{color:f?"#126ECE":m}})})})})]})]})},W=(a(75),a(44)),z=a.n(W),T=function(e){var t=e.contacts,a=e.user,n=e.isShowing,s=e.setShowing,r=e.setActiveChat,i=Object(c.useState)(t),d=Object(u.a)(i,2),j=d[0],h=d[1];Object(c.useEffect)((function(){(function(){var e=Object(l.a)(o.a.mark((function e(){var t;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===a){e.next=5;break}return e.next=3,k.getContactList(a.id);case 3:t=e.sent,h(t);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}})()()}),[a]);var b=function(){var e=Object(l.a)(o.a.mark((function e(c){var n;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,k.newChat(a,c);case 2:return n=e.sent,t.push(c),e.next=6,r(n);case 6:f();case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),f=function(){s(!1)};return Object(C.jsxs)("selection",{className:"NewChatPicker",style:{left:n?"0px":"-415px"},children:[Object(C.jsxs)("header",{children:[Object(C.jsx)("div",{className:"button-group",children:Object(C.jsx)("div",{className:"button",onClick:f,children:Object(C.jsx)(z.a,{style:{color:"#FFFFFF"}})})}),Object(C.jsx)("div",{className:"title",children:Object(C.jsx)("p",{children:"Novo Chat"})})]}),Object(C.jsx)("section",{className:"chatlist",children:j.map((function(e,t){return Object(C.jsxs)("div",{className:"contact-card",onClick:function(){return b(e)},children:[Object(C.jsx)("img",{className:"avatar",src:void 0===e.avatar||null===e.avatar||""===e.avatar?x.USER:e.avatar}),Object(C.jsx)("div",{className:"name",children:Object(C.jsx)("p",{children:e.name})})]},t)}))})]})},q=(a(76),function(e){var t=e.onReceive,a=function(){var e=Object(l.a)(o.a.mark((function e(){var a;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,k.facebookLoginPopup();case 2:(a=e.sent)?t(a.user):alert("Error!");case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(C.jsx)("div",{className:"login",children:Object(C.jsx)("button",{onClick:a,children:" Login With Facebook "})})});var J=function(){var e=n.a.useState([]),t=Object(u.a)(e,2),a=t[0],s=t[1],r=n.a.useState(null),i=Object(u.a)(r,2),d=i[0],h=i[1],f=Object(c.useState)({}),v=Object(u.a)(f,2),x=v[0],g=v[1],N=Object(c.useState)(!1),w=Object(u.a)(N,2),y=w[0],I=w[1],E=m;Object(c.useEffect)((function(){if(null!==d)return k.onChatList(d.id,s)}),[d]);var M=function(){var e=Object(l.a)(o.a.mark((function e(t){var a;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return alert("Logando..."),console.log(""),console.log("logando"),console.log(""),console.log(t),a={id:t.uid,name:t.displayName,avatar:t.photoURL},console.log(""),console.log("logeduser"),console.log(""),console.log(a),e.next=12,k.addUser(a);case 12:h(a);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return null===d?Object(C.jsx)(q,{onReceive:M}):Object(C.jsxs)("div",{className:"app-window",children:[Object(C.jsxs)("div",{className:"sidebar",children:[Object(C.jsx)(T,{contacts:a,user:d,isShowing:y,setShowing:I,setActiveChat:g}),Object(C.jsxs)("header",{children:[Object(C.jsx)("div",{children:Object(C.jsx)("img",{src:d.avatar,className:"img-perfil"})}),Object(C.jsxs)("div",{className:"button-group",children:[Object(C.jsx)("div",{className:"button",children:Object(C.jsx)(j.a,{style:{color:E}})}),Object(C.jsx)("div",{className:"button",onClick:function(){I(!0)},children:Object(C.jsx)(b.a,{style:{color:E}})}),Object(C.jsx)("div",{className:"button",children:Object(C.jsx)(p.a,{style:{color:E}})})]})]}),Object(C.jsx)("div",{className:"search-area",children:Object(C.jsxs)("div",{className:"search-input",children:[Object(C.jsx)(O.a,{fontSize:"small",style:{color:E}}),Object(C.jsx)("input",{type:"search",placeholder:"Pedro pesquisas >:()..."})]})}),Object(C.jsx)("div",{className:"chatlist",children:a.map((function(e,t){return Object(C.jsx)(S,{chat:e,setActiveChat:g,onClick:function(){return g(a[t])},active:x.chatId===e.chatId},t)}))})]}),Object(C.jsxs)("div",{className:"content-area",children:[void 0!==x.chatId&&Object(C.jsx)(K,{chat:x,user:d}),void 0===x.chatId&&Object(C.jsx)(U,{})]})]})};r.a.render(Object(C.jsx)(n.a.StrictMode,{children:Object(C.jsx)(J,{})}),document.getElementById("root"))}},[[78,1,2]]]);
//# sourceMappingURL=main.895ff506.chunk.js.map