od-support-chat 1.0.6 → 1.0.7

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.
Binary file
@@ -1,10 +1,10 @@
1
1
  import { FC } from "react";
2
2
 
3
- //#region src/components/lib/chat.d.ts
3
+ //#region src/components/chat/chat.d.ts
4
4
  interface ChatProps {
5
5
  meetingLinkKey: string;
6
6
  customerSupportKey: string;
7
7
  }
8
8
  declare const Chat: FC<ChatProps>;
9
9
  //#endregion
10
- export { Chat, ChatProps };
10
+ export { Chat };
@@ -230,4 +230,4 @@ import e from"./info.guest.js";import t,{useEffect as n,useRef as r,useState as
230
230
  `,b=a.i`
231
231
  width: 25px;
232
232
  font-size: calc(5px + 1vmin);
233
- `;var x,S,C;const w=`optimizetalk.com:8443`,T=({meetingLinkKey:a,customerSupportKey:o})=>{let s=r(null),[c]=i(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[T]=i(c?100:15),[E,D]=i([]),O=r(),[k,A]=i(!0),[j,M]=i(!1),[N,P]=i(!1),[F,I]=i(null),[L,R]=i(null),[z,B]=i(),[V,H]=i(),[U,W]=i(!1),[G,K]=i(``),q=r(null),J=r(null),Y=()=>{let e=1e4,t=Math.floor(Math.random()*(9e4-e+1))+e;return console.log(`Random number: `+t),t},ie=(e,t)=>{x=new WebSocket(`wss://`+w+`/signal`),x.onopen=function(){console.log(`Websocket connection established`),le(),oe(e,t),$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e}),S=setInterval(()=>{$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e})},45e3),Z(e,t),console.log(`WebSocket connection opened to chat room `+G)}},ae=(e,t)=>{P(!0),I(t),console.log(`Params guestName:`+e+`, guestEmail:`+t);var n=L?e:`Guest-`+Y()+`: `+e;R(n),console.log(`Joining : `+n),ie(n,t)};function X(){console.log(`Close the socket`),x!=null&&(console.log(`Send 'leave' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`leave`,data:a}),x.close())}function oe(e,t){x.onmessage=function(n){let r=JSON.parse(n.data);switch(console.log(`Room received type: `+r.type),r.type){case`text`:console.log(`Text message from `+r.from.userName+` received: `+r.data);break;case`join_meeting`:console.log(`Main message `+r.data),r.data&&r.data===`busy`?(console.log(`Customer support is busy`),W(!0),C||se(e,t)):r.data&&r.data===`valid`&&(clearInterval(C),console.log(`Session key `+r.referenceUsers[0].sessionKey),B(r.referenceUsers[0].sessionKey),console.log(`Session accessToken `+r.accessToken),H(r.accessToken),console.log(`Joined to room `+r.roomDetails.roomName),K(r.roomDetails.roomName));break;case`message`:console.log(`Chat message received from `+r.from.userName),console.log(`Chat message `+r.data),ce(),D(e=>[...e,{sender:r.from.userName,msg:r.data}]),Q();break;case`session_expired`:console.log(`Chat session expired!`),P(!1),B(null),H(null),W(!1),X();break;default:console.log(`Room ignoring message type `+r.type)}}}let se=(e,t)=>{C=setInterval(()=>{console.log(`Trying to connect customer support team ...`),Z(e,t)},1e4)},Z=(e,t)=>{$({from:{userName:e,email:t,audio:!1,video:!1},type:`join_meeting`,roomDetails:{roomLinkKey:a},data:o}),console.log(`Meeting join request sent for guest `+e)},ce=()=>{J.current.play()};function le(){x.addEventListener(`close`,e=>{console.log(`websocket connection closed: `,e),clearInterval(S)}),x.onerror=function(e){console.log(`Error: `+e)}}let Q=()=>{s.current?.scrollIntoView({behavior:`smooth`})},ue=e=>{if(e.key===`Enter`){let t=e.target.value;t&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:t}),console.log(`Chat message sent `+t),D(e=>[...e,{sender:L,msg:t}]),O.current.value=``)}},de=()=>{let e=O.current.value;e&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:e}),console.log(`Chat message sent `+e),D(t=>[...t,{sender:L,msg:e}]),O.current.value=``,Q())};function $(e){let t=JSON.stringify(e);x.send(t)}function fe(){X(),A(!1),M(!0),B(null),H(null),W(!1)}function pe(){x=new WebSocket(`wss://`+w+`/signal`),B(null),H(null),A(!0),M(!1),P(!1),W(!1),I(null),R(null),D([])}return n(()=>{Q()},[E,z]),t.createElement(`div`,null,!j&&t.createElement(l,{displayChat:k,maxWidth:T},t.createElement(u,null,t.createElement(d,null,`OD Customer Support`),t.createElement(f,{onClick:()=>fe(),className:`text-gray-700`},t.createElement(`svg`,{width:`60%`,height:`60%`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},t.createElement(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`orange`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})))),!N&&!z&&!U&&t.createElement(e,{startGuestChat:ae,guestEmail:F}),N&&!z&&!U&&t.createElement(t.Fragment,null,t.createElement(y,null,t.createElement(`div`,{className:`text-center mt-5`},`Please wait, connecting`),t.createElement(`div`,{className:`flex flex-col items-center `},t.createElement(`div`,null,t.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),t.createElement(`div`,{className:`absolute text-center bottom-6 font-sm text-sky-400`},`contact us at`),t.createElement(`div`,{className:`absolute text-center bottom-0 font-sm text-sky-400`},`support@origindetector.com.`)))),N&&!z&&U&&t.createElement(t.Fragment,null,t.createElement(y,null,t.createElement(`div`,{className:`text-center text-sm`},`Our customer support team helping other customers, please wait.`),t.createElement(`div`,{className:`text-center mt-5`},`connecting`),t.createElement(`div`,{className:`flex flex-col items-center `},t.createElement(`div`,null,t.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),t.createElement(`div`,{className:`absolute text-center bottom-6 font-sm text-sky-400`},`contact us at`),t.createElement(`div`,{className:`absolute text-center bottom-0 font-sm text-sky-400`},`support@origindetector.com`)))),N&&z&&t.createElement(`div`,null,t.createElement(p,null,`Live Chat`),t.createElement(ne,null,t.createElement(re,null,E&&E.length==0&&t.createElement(`div`,{className:`ml-2 text-sm`},` You are connected to our customer support team, how can we help you today? `),E&&E.length>0&&t.createElement(`div`,null,E&&E.map(({sender:e,msg:n},r)=>e===L?t.createElement(h,{key:r},t.createElement(`strong`,null,L),t.createElement(`p`,null,n)):t.createElement(m,{key:r},t.createElement(`strong`,null,e),t.createElement(`p`,null,n))),t.createElement(`div`,{style:{float:`left`,clear:`both`},ref:s})))),t.createElement(g,null,t.createElement(_,{ref:O,onKeyUp:ue,placeholder:`Enter your message`}),t.createElement(v,{onClick:de},t.createElement(b,{className:`fas fa-paper-plane`}),`Send`))),t.createElement(`audio`,{ref:q,src:`/audio_file/alert-sound.mp3`}),t.createElement(`audio`,{ref:J,src:`/audio_file/ding-small.mp3`})),j&&t.createElement(ee,{className:`cursor-pointer`,onClick:()=>pe(),displayChat:k,maxWidth:T},t.createElement(te,null,t.createElement(`i`,{className:`bx bx-chat`}),`Live Chat`)))};export{T as Chat};
233
+ `;var x,S,C;const w=`optimizetalk.com:8443`,T=({meetingLinkKey:a,customerSupportKey:o})=>{let s=r(null),[c]=i(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[T]=i(c?100:15),[E,D]=i([]),O=r(),[k,A]=i(!0),[j,M]=i(!1),[N,P]=i(!1),[F,I]=i(null),[L,R]=i(null),[z,B]=i(),[V,H]=i(),[U,W]=i(!1),[G,K]=i(``),q=r(null),J=r(null),Y=()=>{let e=1e4,t=Math.floor(Math.random()*(9e4-e+1))+e;return console.log(`Random number: `+t),t},ie=(e,t)=>{x=new WebSocket(`wss://`+w+`/signal`),x.onopen=function(){console.log(`Websocket connection established`),le(),oe(e,t),$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e}),S=setInterval(()=>{$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e})},45e3),Z(e,t),console.log(`WebSocket connection opened to chat room `+G)}},ae=(e,t)=>{P(!0),I(t),console.log(`Params guestName:`+e+`, guestEmail:`+t);var n=L?e:`Guest-`+Y()+`: `+e;R(n),console.log(`Joining : `+n),ie(n,t)};function X(){console.log(`Close the socket`),x!=null&&(console.log(`Send 'leave' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`leave`,data:a}),x.close())}function oe(e,t){x.onmessage=function(n){let r=JSON.parse(n.data);switch(console.log(`Room received type: `+r.type),r.type){case`text`:console.log(`Text message from `+r.from.userName+` received: `+r.data);break;case`join_meeting`:console.log(`Main message `+r.data),r.data&&r.data===`busy`?(console.log(`Customer support is busy`),W(!0),C||se(e,t)):r.data&&r.data===`valid`&&(clearInterval(C),console.log(`Session key `+r.referenceUsers[0].sessionKey),B(r.referenceUsers[0].sessionKey),console.log(`Session accessToken `+r.accessToken),H(r.accessToken),console.log(`Joined to room `+r.roomDetails.roomName),K(r.roomDetails.roomName));break;case`message`:console.log(`Chat message received from `+r.from.userName),console.log(`Chat message `+r.data),ce(),D(e=>[...e,{sender:r.from.userName,msg:r.data}]),Q();break;case`session_expired`:console.log(`Chat session expired!`),P(!1),B(null),H(null),W(!1),X();break;default:console.log(`Room ignoring message type `+r.type)}}}let se=(e,t)=>{C=setInterval(()=>{console.log(`Trying to connect customer support team ...`),Z(e,t)},1e4)},Z=(e,t)=>{$({from:{userName:e,email:t,audio:!1,video:!1},type:`join_meeting`,roomDetails:{roomLinkKey:a},data:o}),console.log(`Meeting join request sent for guest `+e)},ce=()=>{J.current.play()};function le(){x.addEventListener(`close`,e=>{console.log(`websocket connection closed: `,e),clearInterval(S)}),x.onerror=function(e){console.log(`Error: `+e)}}let Q=()=>{s.current?.scrollIntoView({behavior:`smooth`})},ue=e=>{if(e.key===`Enter`){let t=e.target.value;t&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:t}),console.log(`Chat message sent `+t),D(e=>[...e,{sender:L,msg:t}]),O.current.value=``)}},de=()=>{let e=O.current.value;e&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:e}),console.log(`Chat message sent `+e),D(t=>[...t,{sender:L,msg:e}]),O.current.value=``,Q())};function $(e){let t=JSON.stringify(e);x.send(t)}function fe(){X(),A(!1),M(!0),B(null),H(null),W(!1)}function pe(){x=new WebSocket(`wss://`+w+`/signal`),B(null),H(null),A(!0),M(!1),P(!1),W(!1),I(null),R(null),D([])}return n(()=>{Q()},[E,z]),t.createElement(`div`,null,!j&&t.createElement(l,{displayChat:k,maxWidth:T},t.createElement(u,null,t.createElement(d,null,`OD Customer Support`),t.createElement(f,{onClick:()=>fe(),className:`text-gray-700`},t.createElement(`svg`,{width:`60%`,height:`60%`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},t.createElement(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`orange`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})))),!N&&!z&&!U&&t.createElement(e,{startGuestChat:ae,guestEmail:F}),N&&!z&&!U&&t.createElement(t.Fragment,null,t.createElement(y,null,t.createElement(`div`,{className:`text-center mt-5`},`Please wait, connecting`),t.createElement(`div`,{className:`flex flex-col items-center `},t.createElement(`div`,null,t.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),t.createElement(`div`,{className:`absolute text-center bottom-6 font-sm text-sky-400`},`contact us at`),t.createElement(`div`,{className:`absolute text-center bottom-0 font-sm text-sky-400`},`support@origindetector.com.`)))),N&&!z&&U&&t.createElement(t.Fragment,null,t.createElement(y,null,t.createElement(`div`,{className:`text-center text-sm`},`Our customer support team helping other customers, please wait.`),t.createElement(`div`,{className:`text-center mt-5`},`connecting`),t.createElement(`div`,{className:`flex flex-col items-center `},t.createElement(`div`,null,t.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),t.createElement(`div`,{className:`absolute text-center bottom-6 font-sm text-sky-400`},`contact us at`),t.createElement(`div`,{className:`absolute text-center bottom-0 font-sm text-sky-400`},`support@origindetector.com`)))),N&&z&&t.createElement(`div`,null,t.createElement(p,null,`Live Chat`),t.createElement(ne,null,t.createElement(re,null,E&&E.length==0&&t.createElement(`div`,{className:`ml-2 text-sm`},` You are connected to our customer support team, how can we help you today? `),E&&E.length>0&&t.createElement(`div`,null,E&&E.map(({sender:e,msg:n},r)=>e===L?t.createElement(h,{key:r},t.createElement(`strong`,null,L),t.createElement(`p`,null,n)):t.createElement(m,{key:r},t.createElement(`strong`,null,e),t.createElement(`p`,null,n))),t.createElement(`div`,{style:{float:`left`,clear:`both`},ref:s})))),t.createElement(g,null,t.createElement(_,{ref:O,onKeyUp:ue,placeholder:`Enter your message`}),t.createElement(v,{onClick:de},t.createElement(b,{className:`fas fa-paper-plane`}),`Send`))),t.createElement(`audio`,{ref:q,src:`../../alert-sound.mp3`}),t.createElement(`audio`,{ref:J,src:`../../ding-small.mp3`})),j&&t.createElement(ee,{className:`cursor-pointer`,onClick:()=>pe(),displayChat:k,maxWidth:T},t.createElement(te,null,t.createElement(`i`,{className:`bx bx-chat`}),`Live Chat`)))};export{T as default};
@@ -1,10 +1,10 @@
1
1
  import { FC } from "react";
2
2
 
3
- //#region src/components/lib/chatMobile.d.ts
3
+ //#region src/components/chat/chatMobile.d.ts
4
4
  interface ChatMobileProps {
5
5
  meetingLinkKey: string;
6
6
  customerSupportKey: string;
7
7
  }
8
8
  declare const ChatMobile: FC<ChatMobileProps>;
9
9
  //#endregion
10
- export { ChatMobile, ChatMobileProps };
10
+ export { ChatMobile };
@@ -230,4 +230,4 @@ import e from"./info.guestMobile.js";import t,{useEffect as n,useRef as r,useSta
230
230
  `,b=a.i`
231
231
  width: 25px;
232
232
  font-size: calc(5px + 1vmin);
233
- `;var x,S,C;const w=`optimizetalk.com:8443`,T=({meetingLinkKey:a,customerSupportKey:o})=>{let s=r(null),[c]=i(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[T]=i(c?80:20),[E,D]=i([]),O=r(),[k,A]=i(!0),[j,M]=i(!1),[N,P]=i(!1),[F,I]=i(null),[L,R]=i(null),[z,B]=i(),[V,H]=i(),[U,W]=i(!1),[G,K]=i(``),q=r(null),J=r(null),Y=()=>{let e=1e4,t=Math.floor(Math.random()*(9e4-e+1))+e;return console.log(`Random number: `+t),t},ie=(e,t)=>{x=new WebSocket(`wss://`+w+`/signal`),x.onopen=function(){console.log(`Websocket connection established`),le(),oe(e,t),$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e}),S=setInterval(()=>{$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e})},45e3),Z(e,t),console.log(`WebSocket connection opened to chat room `+G)}},ae=(e,t)=>{P(!0),I(t),console.log(`Params guestName:`+e+`, guestEmail:`+t);var n=L?e:`Guest-`+Y()+`: `+e;R(n),console.log(`Joining : `+n),ie(n,t)};function X(){console.log(`Close the socket`),x!=null&&(console.log(`Send 'leave' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`leave`,data:a}),x.close())}function oe(e,t){x.onmessage=function(n){let r=JSON.parse(n.data);switch(console.log(`Room received type: `+r.type),r.type){case`text`:console.log(`Text message from `+r.from.userName+` received: `+r.data);break;case`join_meeting`:console.log(`Main message `+r.data),r.data&&r.data===`busy`?(console.log(`Customer support is busy`),W(!0),C||se(e,t)):r.data&&r.data===`valid`&&(clearInterval(C),console.log(`Session key `+r.referenceUsers[0].sessionKey),B(r.referenceUsers[0].sessionKey),console.log(`Session accessToken `+r.accessToken),H(r.accessToken),console.log(`Joined to room `+r.roomDetails.roomName),K(r.roomDetails.roomName));break;case`message`:console.log(`Chat message received from `+r.from.userName),console.log(`Chat message `+r.data),ce(),D(e=>[...e,{sender:r.from.userName,msg:r.data}]),Q();break;case`session_expired`:console.log(`Chat session expired!`),P(!1),B(null),H(null),W(!1),X();break;default:console.log(`Room ignoring message type `+r.type)}}}let se=(e,t)=>{C=setInterval(()=>{console.log(`Trying to connect customer support team ...`),Z(e,t)},1e4)},Z=(e,t)=>{$({from:{userName:e,email:t,audio:!1,video:!1},type:`join_meeting`,roomDetails:{roomLinkKey:a},data:o}),console.log(`Meeting join request sent for guest `+e)},ce=()=>{J.current.play()};function le(){x.addEventListener(`close`,e=>{console.log(`websocket connection closed: `,e),clearInterval(S)}),x.onerror=function(e){console.log(`Error: `+e)}}let Q=()=>{s.current?.scrollIntoView({behavior:`smooth`})},ue=e=>{if(e.key===`Enter`){let t=e.target.value;t&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:t}),console.log(`Chat message sent `+t),D(e=>[...e,{sender:L,msg:t}]),O.current.value=``)}},de=()=>{let e=O.current.value;e&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:e}),console.log(`Chat message sent `+e),D(t=>[...t,{sender:L,msg:e}]),O.current.value=``,Q())};function $(e){let t=JSON.stringify(e);x.send(t)}function fe(){X(),A(!1),M(!0),B(null),H(null),W(!1)}function pe(){x=new WebSocket(`wss://`+w+`/signal`),B(null),H(null),A(!0),M(!1),P(!1),W(!1),I(null),R(null),D([])}return n(()=>{Q()},[E,z]),t.createElement(`div`,null,!j&&t.createElement(l,{displayChat:k,maxWidth:T},t.createElement(u,null,t.createElement(d,null,`OD Customer Support`),t.createElement(f,{onClick:()=>fe(),className:`text-gray-700`},t.createElement(`svg`,{width:`60%`,height:`60%`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},t.createElement(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`orange`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})))),!N&&!z&&!U&&t.createElement(e,{startGuestChat:ae,guestEmail:F}),N&&!z&&!U&&t.createElement(t.Fragment,null,t.createElement(y,null,t.createElement(`div`,{className:`text-center mt-5`},`Please wait, connecting`),t.createElement(`div`,{className:`flex flex-col items-center `},t.createElement(`div`,null,t.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),t.createElement(`div`,{className:`absolute text-center bottom-6 font-sx text-sky-400`},`contact us at`),t.createElement(`div`,{className:`absolute text-center bottom-0 font-sx text-sky-400`},`support@origindetector.com.`)))),N&&!z&&U&&t.createElement(t.Fragment,null,t.createElement(y,null,t.createElement(`div`,{className:`text-center`},`Our customer support team helping other customers, please wait.`),t.createElement(`div`,{className:`text-center mt-5`},`connecting`),t.createElement(`div`,{className:`flex flex-col items-center `},t.createElement(`div`,null,t.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),t.createElement(`div`,{className:`absolute text-center bottom-6 font-sx text-sky-400`},`contact us at`),t.createElement(`div`,{className:`absolute text-center bottom-0 font-sx text-sky-400`},`support@origindetector.com.`)))),N&&z&&t.createElement(`div`,null,t.createElement(p,null,`Live Chat`),t.createElement(ne,null,t.createElement(re,null,E&&E.length==0&&t.createElement(`div`,{className:`ml-2`},` You are connected to our customer support team, how can we help you today? `),E&&E.length>0&&t.createElement(`div`,null,E&&E.map(({sender:e,msg:n},r)=>e===L?t.createElement(h,{key:r},t.createElement(`strong`,null,L),t.createElement(`p`,null,n)):t.createElement(m,{key:r},t.createElement(`strong`,null,e),t.createElement(`p`,null,n))),t.createElement(`div`,{style:{float:`left`,clear:`both`},ref:s})))),t.createElement(g,null,t.createElement(_,{ref:O,onKeyUp:ue,placeholder:`Enter your message`}),t.createElement(v,{onClick:de},t.createElement(b,{className:`fas fa-paper-plane`}),`Send`))),t.createElement(`audio`,{ref:q,src:`/audio_file/alert-sound.mp3`}),t.createElement(`audio`,{ref:J,src:`/audio_file/ding-small.mp3`})),j&&t.createElement(ee,{className:`cursor-pointer`,onClick:()=>pe(),displayChat:k,maxWidth:T},t.createElement(te,null,t.createElement(`i`,{className:`bx bx-chat`}))))};export{T as ChatMobile};
233
+ `;var x,S,C;const w=`optimizetalk.com:8443`,T=({meetingLinkKey:a,customerSupportKey:o})=>{let s=r(null),[c]=i(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[T]=i(c?80:20),[E,D]=i([]),O=r(),[k,A]=i(!0),[j,M]=i(!1),[N,P]=i(!1),[F,I]=i(null),[L,R]=i(null),[z,B]=i(),[V,H]=i(),[U,W]=i(!1),[G,K]=i(``),q=r(null),J=r(null),Y=()=>{let e=1e4,t=Math.floor(Math.random()*(9e4-e+1))+e;return console.log(`Random number: `+t),t},ie=(e,t)=>{x=new WebSocket(`wss://`+w+`/signal`),x.onopen=function(){console.log(`Websocket connection established`),le(),oe(e,t),$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e}),S=setInterval(()=>{$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e})},45e3),Z(e,t),console.log(`WebSocket connection opened to chat room `+G)}},ae=(e,t)=>{P(!0),I(t),console.log(`Params guestName:`+e+`, guestEmail:`+t);var n=L?e:`Guest-`+Y()+`: `+e;R(n),console.log(`Joining : `+n),ie(n,t)};function X(){console.log(`Close the socket`),x!=null&&(console.log(`Send 'leave' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`leave`,data:a}),x.close())}function oe(e,t){x.onmessage=function(n){let r=JSON.parse(n.data);switch(console.log(`Room received type: `+r.type),r.type){case`text`:console.log(`Text message from `+r.from.userName+` received: `+r.data);break;case`join_meeting`:console.log(`Main message `+r.data),r.data&&r.data===`busy`?(console.log(`Customer support is busy`),W(!0),C||se(e,t)):r.data&&r.data===`valid`&&(clearInterval(C),console.log(`Session key `+r.referenceUsers[0].sessionKey),B(r.referenceUsers[0].sessionKey),console.log(`Session accessToken `+r.accessToken),H(r.accessToken),console.log(`Joined to room `+r.roomDetails.roomName),K(r.roomDetails.roomName));break;case`message`:console.log(`Chat message received from `+r.from.userName),console.log(`Chat message `+r.data),ce(),D(e=>[...e,{sender:r.from.userName,msg:r.data}]),Q();break;case`session_expired`:console.log(`Chat session expired!`),P(!1),B(null),H(null),W(!1),X();break;default:console.log(`Room ignoring message type `+r.type)}}}let se=(e,t)=>{C=setInterval(()=>{console.log(`Trying to connect customer support team ...`),Z(e,t)},1e4)},Z=(e,t)=>{$({from:{userName:e,email:t,audio:!1,video:!1},type:`join_meeting`,roomDetails:{roomLinkKey:a},data:o}),console.log(`Meeting join request sent for guest `+e)},ce=()=>{J.current.play()};function le(){x.addEventListener(`close`,e=>{console.log(`websocket connection closed: `,e),clearInterval(S)}),x.onerror=function(e){console.log(`Error: `+e)}}let Q=()=>{s.current?.scrollIntoView({behavior:`smooth`})},ue=e=>{if(e.key===`Enter`){let t=e.target.value;t&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:t}),console.log(`Chat message sent `+t),D(e=>[...e,{sender:L,msg:t}]),O.current.value=``)}},de=()=>{let e=O.current.value;e&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:e}),console.log(`Chat message sent `+e),D(t=>[...t,{sender:L,msg:e}]),O.current.value=``,Q())};function $(e){let t=JSON.stringify(e);x.send(t)}function fe(){X(),A(!1),M(!0),B(null),H(null),W(!1)}function pe(){x=new WebSocket(`wss://`+w+`/signal`),B(null),H(null),A(!0),M(!1),P(!1),W(!1),I(null),R(null),D([])}return n(()=>{Q()},[E,z]),t.createElement(`div`,null,!j&&t.createElement(l,{displayChat:k,maxWidth:T},t.createElement(u,null,t.createElement(d,null,`OD Customer Support`),t.createElement(f,{onClick:()=>fe(),className:`text-gray-700`},t.createElement(`svg`,{width:`60%`,height:`60%`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},t.createElement(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`orange`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})))),!N&&!z&&!U&&t.createElement(e,{startGuestChat:ae,guestEmail:F}),N&&!z&&!U&&t.createElement(t.Fragment,null,t.createElement(y,null,t.createElement(`div`,{className:`text-center mt-5`},`Please wait, connecting`),t.createElement(`div`,{className:`flex flex-col items-center `},t.createElement(`div`,null,t.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),t.createElement(`div`,{className:`absolute text-center bottom-6 font-sx text-sky-400`},`contact us at`),t.createElement(`div`,{className:`absolute text-center bottom-0 font-sx text-sky-400`},`support@origindetector.com.`)))),N&&!z&&U&&t.createElement(t.Fragment,null,t.createElement(y,null,t.createElement(`div`,{className:`text-center`},`Our customer support team helping other customers, please wait.`),t.createElement(`div`,{className:`text-center mt-5`},`connecting`),t.createElement(`div`,{className:`flex flex-col items-center `},t.createElement(`div`,null,t.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),t.createElement(`div`,{className:`absolute text-center bottom-6 font-sx text-sky-400`},`contact us at`),t.createElement(`div`,{className:`absolute text-center bottom-0 font-sx text-sky-400`},`support@origindetector.com.`)))),N&&z&&t.createElement(`div`,null,t.createElement(p,null,`Live Chat`),t.createElement(ne,null,t.createElement(re,null,E&&E.length==0&&t.createElement(`div`,{className:`ml-2`},` You are connected to our customer support team, how can we help you today? `),E&&E.length>0&&t.createElement(`div`,null,E&&E.map(({sender:e,msg:n},r)=>e===L?t.createElement(h,{key:r},t.createElement(`strong`,null,L),t.createElement(`p`,null,n)):t.createElement(m,{key:r},t.createElement(`strong`,null,e),t.createElement(`p`,null,n))),t.createElement(`div`,{style:{float:`left`,clear:`both`},ref:s})))),t.createElement(g,null,t.createElement(_,{ref:O,onKeyUp:ue,placeholder:`Enter your message`}),t.createElement(v,{onClick:de},t.createElement(b,{className:`fas fa-paper-plane`}),`Send`))),t.createElement(`audio`,{ref:q,src:`../../alert-sound.mp3`}),t.createElement(`audio`,{ref:J,src:`../../ding-small.mp3`})),j&&t.createElement(ee,{className:`cursor-pointer`,onClick:()=>pe(),displayChat:k,maxWidth:T},t.createElement(te,null,t.createElement(`i`,{className:`bx bx-chat`}))))};export{T as default};
Binary file
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Chat, ChatProps } from "./components/lib/chat.js";
2
- import { ChatMobile, ChatMobileProps } from "./components/lib/chatMobile.js";
3
- export { Chat, ChatMobile, type ChatMobileProps, type ChatProps };
1
+ import { ChatMobile } from "./components/chat/chatMobile.js";
2
+ import { Chat } from "./components/chat/chat.js";
3
+ export { Chat, ChatMobile };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Chat as e}from"./components/lib/chat.js";import{ChatMobile as t}from"./components/lib/chatMobile.js";export{e as Chat,t as ChatMobile};
1
+ import e from"./components/chat/chatMobile.js";import t from"./components/chat/chat.js";export{t as Chat,e as ChatMobile};
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "od-support-chat",
3
3
  "private": false,
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
7
7
  "module": "./dist/index.es.js",
8
- "types": "./dist/main.d.ts",
8
+ "types": "./dist/index.d.ts",
9
9
  "scripts": {
10
10
  "build": "tsdown"
11
11
  },
File without changes