od-support-chat 1.0.1 → 1.0.3

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.
@@ -1 +1,6 @@
1
- export { };
1
+ import { FC } from "react";
2
+
3
+ //#region src/components/lib/chat.d.ts
4
+ declare const Chat: FC<Object>;
5
+ //#endregion
6
+ export { Chat };
@@ -1,4 +1,4 @@
1
- import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-components";const n=t`
1
+ import e from"./info.guest.js";import t,{useEffect as n,useRef as r,useState as i}from"react";import a,{keyframes as o}from"styled-components";const s=o`
2
2
  from {
3
3
  opacity: 0;
4
4
  transform: translateY(20px);
@@ -7,7 +7,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
7
7
  opacity: 1;
8
8
  transform: translateY(0);
9
9
  }
10
- `,r=t`
10
+ `,c=o`
11
11
  from {
12
12
  opacity: 1;
13
13
  transform: translateY(0);
@@ -16,7 +16,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
16
16
  opacity: 0;
17
17
  transform: translateY(20px);
18
18
  }
19
- `;e.div`
19
+ `,l=a.div`
20
20
  position: fixed;
21
21
  right: 0;
22
22
  top: 50%;
@@ -29,8 +29,8 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
29
29
  transition: all 0.5s ease;
30
30
  overflow: hidden;
31
31
  z-index: 10000;
32
- animation: ${({displayChat:e})=>e?n:r} 0.3s ease-in-out forwards;
33
- `,e.div`
32
+ animation: ${({displayChat:e})=>e?s:c} 0.3s ease-in-out forwards;
33
+ `,ee=a.div`
34
34
  position: fixed;
35
35
  right: 0;
36
36
  bottom: 10%;
@@ -41,8 +41,8 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
41
41
  transition: all 0.5s ease;
42
42
  overflow: hidden;
43
43
  z-index: 10000;
44
- animation: ${({displayChat:e})=>e?r:n} 0.3s ease-in-out forwards;
45
- `,e.div`
44
+ animation: ${({displayChat:e})=>e?c:s} 0.3s ease-in-out forwards;
45
+ `,u=a.div`
46
46
  position: absolute;
47
47
  top: 5;
48
48
  margin-left: 5px;
@@ -55,7 +55,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
55
55
  font-size: 14px;
56
56
  color: rgb(78, 161, 211);
57
57
  padding: 5px;
58
- `,e.div`
58
+ `,d=a.div`
59
59
  display: flex;
60
60
  flex-direction: column;
61
61
  align-items: flex-start;
@@ -63,7 +63,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
63
63
  font-weight: 600;
64
64
  font-size: 12px;
65
65
  color: rgb(78, 161, 211);
66
- `,e.div`
66
+ `,f=a.div`
67
67
  position: absolute;
68
68
  top: 0;
69
69
  right: 0;
@@ -75,7 +75,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
75
75
  :hover {
76
76
  cursor: pointer;
77
77
  }
78
- `,e.div`
78
+ `,p=a.div`
79
79
  position: absolute;
80
80
  text-align: center;
81
81
  align-items: center;
@@ -93,7 +93,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
93
93
  color: white;
94
94
  padding: 5px;
95
95
  background-color: rgb(78, 161, 211);
96
- `,e.div`
96
+ `,te=a.div`
97
97
  position: absolute;
98
98
  text-align: center;
99
99
  align-items: center;
@@ -110,7 +110,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
110
110
  color: white;
111
111
  padding: 10px;
112
112
  background-color: rgb(78, 161, 211);
113
- `,e.div`
113
+ `,ne=a.div`
114
114
  position: absolute;
115
115
  top: 80px;
116
116
  margin-left: 5px;
@@ -120,13 +120,13 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
120
120
  max-height: 83%;
121
121
  overflow-x: hidden;
122
122
  overflow-y: auto;
123
- `,e.div`
123
+ `,re=a.div`
124
124
  display: flex;
125
125
  width: 100%;
126
126
  flex-direction: column;
127
127
  padding: 15px;
128
128
  color: #454552;
129
- `,e.div`
129
+ `,m=a.div`
130
130
  width: 100%;
131
131
  display: flex;
132
132
  flex-direction: column;
@@ -152,7 +152,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
152
152
  font-size: 12px;
153
153
  text-align: left;
154
154
  }
155
- `,e.div`
155
+ `,h=a.div`
156
156
  width: 100%;
157
157
  display: flex;
158
158
  flex-direction: column;
@@ -179,7 +179,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
179
179
  text-align: left;
180
180
  background-color: #f5f5f5;
181
181
  }
182
- `,e.div`
182
+ `,g=a.div`
183
183
  position: absolute;
184
184
  display: flex;
185
185
  bottom: 10px;
@@ -189,7 +189,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
189
189
  align-items: center;
190
190
  width: 100%;
191
191
  gap: 5px;
192
- `,e.input`
192
+ `,_=a.input`
193
193
  bottom: 0;
194
194
  width: 70%;
195
195
  height: 25px;
@@ -203,7 +203,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
203
203
  :focus {
204
204
  outline: none;
205
205
  }
206
- `,e.div`
206
+ `,v=a.div`
207
207
  height: 25px;
208
208
  outline: none;
209
209
  border: none;
@@ -219,7 +219,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
219
219
  font-size: 1rem;
220
220
  font-weight: 500;
221
221
  cursor: pointer;
222
- `,e.div`
222
+ `,y=a.div`
223
223
  position: absolute;
224
224
  top: 80px;
225
225
  margin-left: 25px;
@@ -227,7 +227,7 @@ import"./info.guest.js";import"react";import e,{keyframes as t}from"styled-compo
227
227
  height: 65%;
228
228
  width: 83%;
229
229
  margin-bottom: 25px;
230
- `,e.i`
230
+ `,b=a.i`
231
231
  width: 25px;
232
232
  font-size: calc(5px + 1vmin);
233
- `;
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};
@@ -1 +1,6 @@
1
- export { };
1
+ import { FC } from "react";
2
+
3
+ //#region src/components/lib/chatMobile.d.ts
4
+ declare const ChatMobile: FC<Object>;
5
+ //#endregion
6
+ export { ChatMobile };
@@ -1,4 +1,4 @@
1
- import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled-components";const n=t`
1
+ import e from"./info.guestMobile.js";import t,{useEffect as n,useRef as r,useState as i}from"react";import a,{keyframes as o}from"styled-components";const s=o`
2
2
  from {
3
3
  opacity: 0;
4
4
  transform: translateY(20px);
@@ -7,7 +7,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
7
7
  opacity: 1;
8
8
  transform: translateY(0);
9
9
  }
10
- `,r=t`
10
+ `,c=o`
11
11
  from {
12
12
  opacity: 1;
13
13
  transform: translateY(0);
@@ -16,7 +16,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
16
16
  opacity: 0;
17
17
  transform: translateY(20px);
18
18
  }
19
- `;e.div`
19
+ `,l=a.div`
20
20
  position: fixed;
21
21
  left: 10%;
22
22
  top: 50%;
@@ -29,8 +29,8 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
29
29
  transition: all 0.5s ease;
30
30
  overflow: hidden;
31
31
  z-index: 10000;
32
- animation: ${({displayChat:e})=>e?n:r} 0.3s ease-in-out forwards;
33
- `,e.div`
32
+ animation: ${({displayChat:e})=>e?s:c} 0.3s ease-in-out forwards;
33
+ `,ee=a.div`
34
34
  position: fixed;
35
35
  right: 0;
36
36
  bottom: 2%;
@@ -41,8 +41,8 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
41
41
  transition: all 0.5s ease;
42
42
  overflow: hidden;
43
43
  z-index: 10000;
44
- animation: ${({displayChat:e})=>e?r:n} 0.3s ease-in-out forwards;
45
- `,e.div`
44
+ animation: ${({displayChat:e})=>e?c:s} 0.3s ease-in-out forwards;
45
+ `,u=a.div`
46
46
  position: absolute;
47
47
  top: 5;
48
48
  margin-left: 5px;
@@ -55,7 +55,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
55
55
  font-size: 14px;
56
56
  color: rgb(78, 161, 211);
57
57
  padding: 5px;
58
- `,e.div`
58
+ `,d=a.div`
59
59
  display: flex;
60
60
  flex-direction: column;
61
61
  align-items: flex-start;
@@ -63,7 +63,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
63
63
  font-weight: 600;
64
64
  font-size: 12px;
65
65
  color: rgb(78, 161, 211);
66
- `,e.div`
66
+ `,f=a.div`
67
67
  position: absolute;
68
68
  top: 0;
69
69
  right: 0;
@@ -75,7 +75,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
75
75
  :hover {
76
76
  cursor: pointer;
77
77
  }
78
- `,e.div`
78
+ `,p=a.div`
79
79
  position: absolute;
80
80
  text-align: center;
81
81
  align-items: center;
@@ -93,7 +93,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
93
93
  color: white;
94
94
  padding: 5px;
95
95
  background-color: rgb(78, 161, 211);
96
- `,e.div`
96
+ `,te=a.div`
97
97
  position: absolute;
98
98
  text-align: center;
99
99
  align-items: center;
@@ -110,7 +110,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
110
110
  color: white;
111
111
  padding: 10px;
112
112
  background-color: rgb(78, 161, 211);
113
- `,e.div`
113
+ `,ne=a.div`
114
114
  position: absolute;
115
115
  top: 80px;
116
116
  margin-left: 5px;
@@ -120,13 +120,13 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
120
120
  max-height: 83%;
121
121
  overflow-x: hidden;
122
122
  overflow-y: auto;
123
- `,e.div`
123
+ `,re=a.div`
124
124
  display: flex;
125
125
  width: 100%;
126
126
  flex-direction: column;
127
127
  padding: 15px;
128
128
  color: #454552;
129
- `,e.div`
129
+ `,m=a.div`
130
130
  width: 100%;
131
131
  display: flex;
132
132
  flex-direction: column;
@@ -152,7 +152,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
152
152
  font-size: 12px;
153
153
  text-align: left;
154
154
  }
155
- `,e.div`
155
+ `,h=a.div`
156
156
  width: 100%;
157
157
  display: flex;
158
158
  flex-direction: column;
@@ -179,7 +179,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
179
179
  text-align: left;
180
180
  background-color: #f5f5f5;
181
181
  }
182
- `,e.div`
182
+ `,g=a.div`
183
183
  position: absolute;
184
184
  display: flex;
185
185
  bottom: 10px;
@@ -189,7 +189,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
189
189
  align-items: center;
190
190
  width: 100%;
191
191
  gap: 5px;
192
- `,e.input`
192
+ `,_=a.input`
193
193
  bottom: 0;
194
194
  width: 70%;
195
195
  height: 25px;
@@ -203,7 +203,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
203
203
  :focus {
204
204
  outline: none;
205
205
  }
206
- `,e.div`
206
+ `,v=a.div`
207
207
  height: 25px;
208
208
  outline: none;
209
209
  border: none;
@@ -219,7 +219,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
219
219
  font-size: 1rem;
220
220
  font-weight: 500;
221
221
  cursor: pointer;
222
- `,e.div`
222
+ `,y=a.div`
223
223
  position: absolute;
224
224
  top: 80px;
225
225
  margin-left: 25px;
@@ -227,7 +227,7 @@ import"./info.guestMobile.js";import"react";import e,{keyframes as t}from"styled
227
227
  height: 65%;
228
228
  width: 83%;
229
229
  margin-bottom: 25px;
230
- `,e.i`
230
+ `,b=a.i`
231
231
  width: 25px;
232
232
  font-size: calc(5px + 1vmin);
233
- `;
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};
@@ -1,4 +1,4 @@
1
- import"react";import e from"styled-components";import"react-hook-form";import"tailwind-merge";import{object as t,string as n}from"zod";import"@hookform/resolvers/zod";e.div`
1
+ import{useState as e}from"react";import t from"styled-components";import{useForm as n}from"react-hook-form";import{twMerge as r}from"tailwind-merge";import{object as i,string as a}from"zod";import{zodResolver as o}from"@hookform/resolvers/zod";const s=t.div`
2
2
  position: relative;
3
3
  text-align: center;
4
4
  align-items: center;
@@ -14,7 +14,7 @@ import"react";import e from"styled-components";import"react-hook-form";import"ta
14
14
  color: white;
15
15
  padding: 5px;
16
16
  background-color: rgb(78, 161, 211);
17
- `,e.div`
17
+ `,c=t.div`
18
18
  position: absolute;
19
19
  top: 40px;
20
20
  margin-left: 5px;
@@ -24,4 +24,4 @@ import"react";import e from"styled-components";import"react-hook-form";import"ta
24
24
  max-height: 100%;
25
25
  overflow-x: hidden;
26
26
  overflow-y: auto;
27
- `,t({name:n().min(1,`Name is required`),email:n().min(1,`Email is required`).email(`Invalid email address`)});
27
+ `,l=i({name:a().min(1,`Name is required`),email:a().min(1,`Email is required`).email(`Invalid email address`)}),u=({startGuestChat:t,guestEmail:i})=>{let[a,u]=e(),d=n({resolver:o(l)}),{handleSubmit:f,formState:{errors:p}}=d;return React.createElement(c,null,React.createElement(s,null,`Live Chat`),!!i&&React.createElement(`div`,{className:`flex items-center justify-center gap-5 `},React.createElement(`button`,{onClick:()=>t(i),className:`inline-block rounded bg-green-700 px-6 pb-2 pt-2.5 text-xs font-medium leading-normal text-white shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] dark:shadow-[0_4px_9px_-4px_rgba(59,113,202,0.5)] dark:hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)]`},`Start Chat`)),!i&&React.createElement(`form`,{className:`w-full`,onSubmit:f(async e=>{console.log(`Guest: `+e.name),console.log(`Guest Email: `+e.email),t(e.name,e.email)})},React.createElement(`div`,{className:`flex flex-col items-left`},React.createElement(`div`,{className:`max-w-1xl bg-white`},React.createElement(`div`,{className:`relative border-slate-300 flex flex-col items-center`},React.createElement(`div`,null,React.createElement(`label`,{className:`block text-gray-700 text-sm mb-1`,htmlFor:`title`},`Name`),React.createElement(`input`,{className:r(`appearance-none border border-gray-400 rounded w-40 px-1 py-1 text-sm text-gray-700 mb-1 leading-tight focus:outline-none`,`${p.name&&`border-red-500`}`),...d.register(`name`)}),React.createElement(`p`,{className:r(`text-red-500 text-xs italic mb-2 invisible`,`${p.name&&`visible`}`)},p.name?.message)),React.createElement(`div`,null,React.createElement(`label`,{className:`block text-gray-700 text-sm mb-1`,htmlFor:`title`},`Email`),React.createElement(`input`,{type:`email`,className:r(`appearance-none border border-gray-400 rounded w-40 px-1 py-1 text-sm text-gray-700 mb-2 leading-tight focus:outline-none`,`${p.email&&`border-red-500`}`),...d.register(`email`)}),React.createElement(`p`,{className:r(`text-red-500 text-xs italic mb-2 invisible`,`${p.email&&`visible`}`)},p.email?.message))))),React.createElement(`div`,{className:`mb-2 text-gray-600 `},React.createElement(`h2`,{className:`text-sm text-red-600 font-normal`},a)),React.createElement(`div`,{className:`flex items-center justify-center gap-5 `},React.createElement(`button`,{className:`inline-block rounded bg-green-700 px-6 pb-2 pt-2.5 text-xs font-medium leading-normal text-white shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] dark:shadow-[0_4px_9px_-4px_rgba(59,113,202,0.5)] dark:hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)]`},`Start Chat`))))};export{u as default};
@@ -1,4 +1,4 @@
1
- import"react";import e from"styled-components";import"react-hook-form";import"tailwind-merge";import{object as t,string as n}from"zod";import"@hookform/resolvers/zod";e.div`
1
+ import{useState as e}from"react";import t from"styled-components";import{useForm as n}from"react-hook-form";import{twMerge as r}from"tailwind-merge";import{object as i,string as a}from"zod";import{zodResolver as o}from"@hookform/resolvers/zod";const s=t.div`
2
2
  position: relative;
3
3
  text-align: center;
4
4
  align-items: center;
@@ -14,7 +14,7 @@ import"react";import e from"styled-components";import"react-hook-form";import"ta
14
14
  color: white;
15
15
  padding: 5px;
16
16
  background-color: rgb(78, 161, 211);
17
- `,e.div`
17
+ `,c=t.div`
18
18
  position: absolute;
19
19
  top: 40px;
20
20
  margin-left: 5px;
@@ -24,4 +24,4 @@ import"react";import e from"styled-components";import"react-hook-form";import"ta
24
24
  font-size: 14px;
25
25
  overflow-x: hidden;
26
26
  overflow-y: auto;
27
- `,t({name:n().min(1,`Name is required`),email:n().min(1,`Email is required`).email(`Invalid email address`)});
27
+ `,l=i({name:a().min(1,`Name is required`),email:a().min(1,`Email is required`).email(`Invalid email address`)}),u=({startGuestChat:t,guestEmail:i})=>{let[a,u]=e(),d=n({resolver:o(l)}),{handleSubmit:f,formState:{errors:p}}=d;return React.createElement(c,null,React.createElement(s,null,`Live Chat`),!!i&&React.createElement(`div`,{className:`flex items-center justify-center gap-5 `},React.createElement(`button`,{onClick:()=>t(i),className:`inline-block rounded bg-green-700 px-6 pb-2 pt-2.5 text-xs font-medium leading-normal text-white shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] dark:shadow-[0_4px_9px_-4px_rgba(59,113,202,0.5)] dark:hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)]`},`Start Chat`)),!i&&React.createElement(`form`,{className:`w-full`,onSubmit:f(async e=>{console.log(`Guest: `+e.name),console.log(`Guest Email: `+e.email),t(e.name,e.email)})},React.createElement(`div`,{className:`flex flex-col items-left`},React.createElement(`div`,{className:`max-w-1xl bg-white`},React.createElement(`div`,{className:`relative border-slate-300 flex flex-col items-center`},React.createElement(`div`,null,React.createElement(`label`,{className:`block text-gray-700 text-normal mb-1`,htmlFor:`title`},`Name`),React.createElement(`input`,{className:r(`appearance-none border border-gray-400 rounded w-full text-gray-700 mb-1 px-1 py-1 leading-tight focus:outline-none`,`${p.name&&`border-red-500`}`),...d.register(`name`)}),React.createElement(`p`,{className:r(`text-red-500 text-xs italic invisible`,`${p.name&&`visible`}`)},p.name?.message)),React.createElement(`div`,null,React.createElement(`label`,{className:`block text-gray-700 text-normal mb-1`,htmlFor:`title`},`Email`),React.createElement(`input`,{type:`email`,className:r(`appearance-none border border-gray-400 rounded w-full text-gray-700 mb-1 px-1 py-1 leading-tight focus:outline-none`,`${p.email&&`border-red-500`}`),...d.register(`email`)}),React.createElement(`p`,{className:r(`text-red-500 text-xs italic mb-2 invisible`,`${p.email&&`visible`}`)},p.email?.message))))),React.createElement(`div`,{className:`mb-2 text-gray-600 `},React.createElement(`h2`,{className:`text-sm text-red-600 font-normal`},a)),React.createElement(`div`,{className:`flex items-center justify-center gap-5 `},React.createElement(`button`,{className:`inline-block rounded bg-green-700 px-6 pb-2 pt-2.5 text-xs font-medium leading-normal text-white shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] dark:shadow-[0_4px_9px_-4px_rgba(59,113,202,0.5)] dark:hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)]`},`Start Chat`))))};export{u as default};
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
- export { };
1
+ import { Chat } from "./components/lib/chat.js";
2
+ import { ChatMobile } from "./components/lib/chatMobile.js";
3
+ export { Chat, ChatMobile };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./components/lib/chat.js";import"./components/lib/chatMobile.js";
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};
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "od-support-chat",
3
3
  "private": false,
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "type": "module",
6
- "main": "./dist/od-support-chat.umd.js",
7
- "module": "./dist/od-support-chat.es.js",
6
+ "main": "./dist/index.umd.js",
7
+ "module": "./dist/index.es.js",
8
8
  "types": "./dist/main.d.ts",
9
9
  "scripts": {
10
10
  "build": "tsdown"
11
11
  },
12
12
  "exports": {
13
13
  ".": {
14
- "import": "./dist/od-support-chat.es.js",
15
- "require": "./dist/od-support-chat.umd.js",
14
+ "import": "./dist/index.es.js",
15
+ "require": "./dist/index.umd.js",
16
16
  "types": "./dist/index.d.ts"
17
17
  }
18
18
  },