@subiz/widget-v4 4.0.50 → 4.0.55
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/assets/img/default.jpg +0 -0
- package/assets/less/message.less +101 -10
- package/compiled_src/chatbox/Event.js +6 -0
- package/compiled_src/chatbox/OrderAttachments.js +109 -0
- package/compiled_src/chatbox/ProductAttachments.js +9 -7
- package/compiled_src/notif/notif.js +6 -2
- package/compiled_src/plugin.js +1 -1
- package/compiled_src/store/api.js +1 -0
- package/compiled_src/util/campaign.js +6 -1
- package/compiled_src/util/common.js +7 -0
- package/dist/{17cbc0a3e5f.178.js → 17d7ef81b7a.178.js} +1 -1
- package/dist/{17cbc0a3e5f.213.js → 17d7ef81b7a.213.js} +0 -0
- package/dist/{17cbc0a3e5f.362.js → 17d7ef81b7a.362.js} +1 -1
- package/dist/17d7ef81b7a.441.js +1 -0
- package/dist/17d7ef81b7a.605.js +1 -0
- package/dist/{17cbc0a3e5f.619.js → 17d7ef81b7a.619.js} +1 -1
- package/dist/{17cbc0a3e5f.678.js → 17d7ef81b7a.678.js} +0 -0
- package/dist/17d7ef81b7a.74.js +1 -0
- package/dist/{17cbc0a3e5f.782.js → 17d7ef81b7a.782.js} +1 -1
- package/dist/17d7ef81b7a.app.js +1 -0
- package/dist/{17cbc0a3e5f.index.html → 17d7ef81b7a.index.html} +1 -1
- package/dist/{17cbc0a3e5f.library.html → 17d7ef81b7a.library.html} +1 -1
- package/dist/17d7ef81b7a.library.js +1 -0
- package/dist/{17cbc0a3e5f.preview.html → 17d7ef81b7a.preview.html} +1 -1
- package/dist/17d7ef81b7a.preview.js +1 -0
- package/dist/17d7ef81b7a.screenshoot.js +1 -0
- package/dist/17d7ef84382.178.js +406 -0
- package/dist/17d7ef84382.213.js +3223 -0
- package/dist/17d7ef84382.362.js +107 -0
- package/dist/17d7ef84382.441.js +2706 -0
- package/dist/17d7ef84382.605.js +391 -0
- package/dist/17d7ef84382.619.js +777 -0
- package/dist/17d7ef84382.678.js +107 -0
- package/dist/17d7ef84382.74.js +4732 -0
- package/dist/17d7ef84382.782.js +107 -0
- package/dist/17d7ef84382.screenshoot.js +5719 -0
- package/dist/HASH +1 -1
- package/dist/assets/img/default.06e6ee0.jpg +0 -0
- package/dist/screenshoot.html +7 -0
- package/package.json +12 -12
- package/screenshoot.html +15 -0
- package/screenshoot.js +28 -0
- package/src/chatbox/Event.js +2 -0
- package/src/chatbox/OrderAttachments.js +107 -0
- package/src/chatbox/ProductAttachments.js +14 -8
- package/src/notif/notif.js +36 -27
- package/src/plugin.js +1 -1
- package/src/store/api.js +2 -5
- package/src/store/store.js +9 -8
- package/src/util/campaign.js +14 -11
- package/src/util/common.js +6 -0
- package/take.js +36 -0
- package/webpack.dev.js +7 -0
- package/webpack.prod.js +12 -2
- package/webpack.screenshoot.js +28 -0
- package/dist/17cbc0a3e5f.605.js +0 -1
- package/dist/17cbc0a3e5f.712.js +0 -1
- package/dist/17cbc0a3e5f.84.js +0 -1
- package/dist/17cbc0a3e5f.app.js +0 -1
- package/dist/17cbc0a3e5f.library.js +0 -1
- package/dist/17cbc0a3e5f.preview.js +0 -1
|
@@ -0,0 +1,4732 @@
|
|
|
1
|
+
(self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[74],{
|
|
2
|
+
|
|
3
|
+
/***/ 1074:
|
|
4
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
// ESM COMPAT FLAG
|
|
8
|
+
__webpack_require__.r(__webpack_exports__);
|
|
9
|
+
|
|
10
|
+
// EXPORTS
|
|
11
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
12
|
+
"default": () => (/* binding */ Main)
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// EXTERNAL MODULE: ./src/util/index.js + 2 modules
|
|
16
|
+
var util = __webpack_require__(819);
|
|
17
|
+
// EXTERNAL MODULE: ./src/common.js
|
|
18
|
+
var common = __webpack_require__(2493);
|
|
19
|
+
// EXTERNAL MODULE: ./node_modules/preact/dist/preact.module.js
|
|
20
|
+
var preact_module = __webpack_require__(6400);
|
|
21
|
+
;// CONCATENATED MODULE: ./src/chatbox/Emoji.js
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Emoji extends common/* Com */.M {
|
|
26
|
+
render() {
|
|
27
|
+
var emojiCode = this.props.emojiCode;
|
|
28
|
+
if (util/* default.size */.Z.size(emojiCode) < 3) return null;
|
|
29
|
+
var emojiText = emojiCode.replace(/:/g, '');
|
|
30
|
+
return (0,preact_module.h)("i", {
|
|
31
|
+
"data-tooltip": emojiCode,
|
|
32
|
+
class: `emoji emoji--${emojiText}`
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
;// CONCATENATED MODULE: ./src/chatbox/ChatButton.js
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
var defaultBubble = __webpack_require__(6755);
|
|
42
|
+
|
|
43
|
+
let defaultAvatar = __webpack_require__(4761);
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ChatButton extends common/* Com */.M {
|
|
48
|
+
constructor(props) {
|
|
49
|
+
super(props);
|
|
50
|
+
this.setState({
|
|
51
|
+
opacity: 0,
|
|
52
|
+
previewEvent: {},
|
|
53
|
+
displayPreview: false
|
|
54
|
+
});
|
|
55
|
+
this.loadGreeting();
|
|
56
|
+
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
57
|
+
this.props.store.onConvoEvent(this, ev => {
|
|
58
|
+
if (util/* default.get */.Z.get(ev, 'type') !== 'message_sent') return;
|
|
59
|
+
let bytype = util/* default.get */.Z.get(ev, 'by.type');
|
|
60
|
+
if (bytype !== 'system' && bytype !== 'agent') return;
|
|
61
|
+
let isquickreplies = false;
|
|
62
|
+
util/* default.map */.Z.map(util/* default.get */.Z.get(ev, 'data.message.attachments', []), att => {
|
|
63
|
+
if (!att) return;
|
|
64
|
+
|
|
65
|
+
if (att.type === 'quick_replies') {
|
|
66
|
+
isquickreplies = true;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
if (isquickreplies) return;
|
|
70
|
+
this.setState({
|
|
71
|
+
displayPreview: true,
|
|
72
|
+
previewEvent: ev
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fixMissingSetting(chatbox) {
|
|
78
|
+
chatbox = util/* default.cloneDeep */.Z.cloneDeep(chatbox);
|
|
79
|
+
|
|
80
|
+
if (util/* default.get */.Z.get(chatbox, 'desktop_button.background_image_url')) {
|
|
81
|
+
chatbox.desktop_button.background_image_url = this.props.store.replaceFileUrl(chatbox.desktop_button.background_image_url);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (util/* default.get */.Z.get(chatbox, 'desktop_button.background_mask_url')) {
|
|
85
|
+
chatbox.desktop_button.background_mask_url = this.props.store.replaceFileUrl(chatbox.desktop_button.background_mask_url);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (util/* default.get */.Z.get(chatbox, 'mobile_button.background_image_url')) {
|
|
89
|
+
chatbox.mobile_button.background_image_url = this.props.store.replaceFileUrl(chatbox.mobile_button.background_image_url);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (util/* default.get */.Z.get(chatbox, 'mobile_button.background_mask_url')) {
|
|
93
|
+
chatbox.mobile_button.background_mask_url = this.props.store.replaceFileUrl(chatbox.mobile_button.background_mask_url);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return chatbox;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
render() {
|
|
100
|
+
let accountSetting = this.props.plugin.chatbox;
|
|
101
|
+
let position = util/* default.get */.Z.get(accountSetting, 'desktop_button.position') || 'right';
|
|
102
|
+
|
|
103
|
+
if (this.props.store.isMobile()) {
|
|
104
|
+
position = util/* default.get */.Z.get(accountSetting, 'mobile_button.position') || position;
|
|
105
|
+
let hiddenButtonMobile = util/* default.get */.Z.get(accountSetting, 'mobile_button.hidden');
|
|
106
|
+
if (hiddenButtonMobile) return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let hiddenButtonDesktop = util/* default.get */.Z.get(accountSetting, 'desktop_button.hidden');
|
|
110
|
+
if (hiddenButtonDesktop) return null;
|
|
111
|
+
let cls = 'widget-layout widget-layout--' + position;
|
|
112
|
+
let opacity = this.state.opacity;
|
|
113
|
+
|
|
114
|
+
if (!this.props.isShow) {
|
|
115
|
+
cls += ' widget-layout--hidden';
|
|
116
|
+
opacity = 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return (0,preact_module.h)("div", {
|
|
120
|
+
class: cls,
|
|
121
|
+
style: 'opacity: ' + opacity + ' !important'
|
|
122
|
+
}, this.renderPreview(), this.renderButton());
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
ClearPreview() {
|
|
126
|
+
this.setState({
|
|
127
|
+
previewEvent: {}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
ShowGreeting() {
|
|
132
|
+
let greeting = util/* default.get */.Z.get(this.props.plugin, 'chatbox.greeting', {});
|
|
133
|
+
let agentM = this.props.store.matchAgent('*');
|
|
134
|
+
let byid = greeting.agent_id;
|
|
135
|
+
if (!byid) byid = randomAgent(agentM).id;
|
|
136
|
+
let text = this.props.t.i18n(util/* default.get */.Z.get(greeting, 'greeting', {})) || greeting.message;
|
|
137
|
+
this.setState({
|
|
138
|
+
previewEvent: {
|
|
139
|
+
by: {
|
|
140
|
+
id: byid,
|
|
141
|
+
type: 'agent'
|
|
142
|
+
},
|
|
143
|
+
data: {
|
|
144
|
+
message: {
|
|
145
|
+
text,
|
|
146
|
+
format: 'plaintext'
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
displayPreview: true
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
HideGreeting() {
|
|
155
|
+
this.setState({
|
|
156
|
+
previewEvent: {}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
loadGreeting() {
|
|
161
|
+
let accountSetting = this.props.plugin.chatbox;
|
|
162
|
+
if (new util/* default.Date */.Z.Date().getTime() - this.props.store.matchClosePreviewAt() < Ms30Mins) return;
|
|
163
|
+
let greeting = util/* default.get */.Z.get(accountSetting, 'greeting', {});
|
|
164
|
+
|
|
165
|
+
if (!greeting.message || !greeting.enabled) {
|
|
166
|
+
this.setState({
|
|
167
|
+
previewEvent: {}
|
|
168
|
+
});
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
this.ShowGreeting();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
onClick() {
|
|
176
|
+
let lastview = this.props.store.matchLastview();
|
|
177
|
+
|
|
178
|
+
if (util/* default.get */.Z.get(lastview, 'view')) {
|
|
179
|
+
if (lastview.view !== 'list' || util/* default.size */.Z.size(this.props.store.matchConvo('*')) > 0) {
|
|
180
|
+
return this.props.onClick && this.props.onClick(Object.assign({}, lastview.opts, {
|
|
181
|
+
view: lastview.view
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return this.onPreviewClick();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
onPreviewClick(e) {
|
|
190
|
+
let cid = util/* default.convoOfEv */.Z.convoOfEv(this.state.previewEvent);
|
|
191
|
+
|
|
192
|
+
if (!cid) {
|
|
193
|
+
let convos = util/* default.map */.Z.map(this.props.store.matchConvo('*'));
|
|
194
|
+
let convo = util/* default.find */.Z.find(convos, convo => !util/* default.isConvoSeen */.Z.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
195
|
+
if (!convo) convo = convos[0] || {};
|
|
196
|
+
cid = convo.id;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this.closePreview(e);
|
|
200
|
+
this.props.onClick && this.props.onClick({
|
|
201
|
+
view: 'chat',
|
|
202
|
+
cid
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
renderUnread() {
|
|
207
|
+
let unreadcount = this.props.store.matchUnread();
|
|
208
|
+
if (unreadcount === 0) return null;
|
|
209
|
+
return (0,preact_module.h)("div", {
|
|
210
|
+
class: "chat-button--unread"
|
|
211
|
+
}, unreadcount);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
renderPreview() {
|
|
215
|
+
let account = this.props.store.matchAccount();
|
|
216
|
+
let accountSetting = this.props.plugin.chatbox;
|
|
217
|
+
let byid = util/* default.get */.Z.get(this.state.previewEvent, 'by.display_id', util/* default.get */.Z.get(this.state.previewEvent, 'by.id'));
|
|
218
|
+
let agent = util/* default.cloneDeep */.Z.cloneDeep(this.props.store.matchAgent(byid)) || {};
|
|
219
|
+
agent.fullname = agent.fullname || util/* default.get */.Z.get(account, 'name') || this.props.t('agent');
|
|
220
|
+
agent.avatar_url = agent.avatar_url || defaultAvatar;
|
|
221
|
+
let position = util/* default.get */.Z.get(accountSetting, 'desktop_button.position') || 'right';
|
|
222
|
+
|
|
223
|
+
if (this.props.store.isMobile()) {
|
|
224
|
+
position = util/* default.get */.Z.get(accountSetting, 'mobile_button.position') || position;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
let cls = 'widget-preview widget-preview--' + position;
|
|
228
|
+
if (!this.state.displayPreview) cls += ' widget-preview--hidden';
|
|
229
|
+
var tags = this.renderMessagePreview(this.state.previewEvent, this.props.t('sent_you_a_message'));
|
|
230
|
+
if (util/* default.size */.Z.size(tags) === 0) cls += ' widget-preview--hidden';
|
|
231
|
+
return (0,preact_module.h)("div", {
|
|
232
|
+
class: cls
|
|
233
|
+
}, (0,preact_module.h)("div", {
|
|
234
|
+
class: "widget-preview--body"
|
|
235
|
+
}, (0,preact_module.h)("img", {
|
|
236
|
+
alt: "widget avatar",
|
|
237
|
+
class: "widget-preview--avatar",
|
|
238
|
+
src: this.props.store.replaceFileUrl(agent.avatar_url),
|
|
239
|
+
onError: ev => this.onProfileError(ev),
|
|
240
|
+
onload: _ => this.onProfileReady()
|
|
241
|
+
}), (0,preact_module.h)("div", {
|
|
242
|
+
class: "widget-preview--content",
|
|
243
|
+
onClick: e => this.onPreviewClick(e)
|
|
244
|
+
}, (0,preact_module.h)("div", {
|
|
245
|
+
class: "widget-preview--title"
|
|
246
|
+
}, agent.fullname), (0,preact_module.h)("p", {
|
|
247
|
+
class: "widget-preview--message"
|
|
248
|
+
}, tags)), (0,preact_module.h)("div", {
|
|
249
|
+
class: "widget-preview--btn-close",
|
|
250
|
+
onClick: e => this.closePreview(e)
|
|
251
|
+
})), (0,preact_module.h)("div", {
|
|
252
|
+
class: "widget-preview--action",
|
|
253
|
+
onClick: e => this.onPreviewClick(e)
|
|
254
|
+
}, (0,preact_module.h)("div", {
|
|
255
|
+
class: "widget-preview--action-text"
|
|
256
|
+
}, this.props.t('chat_now'))));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
onProfileReady() {
|
|
260
|
+
if (this.state.buttonLoaded) this.setState({
|
|
261
|
+
opacity: 1
|
|
262
|
+
});
|
|
263
|
+
this.setState({
|
|
264
|
+
profileLoaded: true
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
onButtonReady() {
|
|
269
|
+
if (this.state.profileLoaded) this.setState({
|
|
270
|
+
opacity: 1
|
|
271
|
+
});
|
|
272
|
+
this.setState({
|
|
273
|
+
buttonLoaded: true
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
renderButton() {
|
|
278
|
+
let accountSetting = this.props.plugin.chatbox;
|
|
279
|
+
accountSetting = this.fixMissingSetting(accountSetting);
|
|
280
|
+
let imgsrc = util/* default.get */.Z.get(accountSetting, 'desktop_button.background_image_url') || util/* default.get */.Z.get(accountSetting, 'desktop_button.background_mask_url') || defaultBubble;
|
|
281
|
+
let background = util/* default.get */.Z.get(accountSetting, 'background') || DEF_BG;
|
|
282
|
+
let position = util/* default.get */.Z.get(accountSetting, 'desktop_button.position') || 'right';
|
|
283
|
+
let imgurl = util/* default.get */.Z.get(accountSetting, 'desktop_button.background_image_url');
|
|
284
|
+
let maskurl = util/* default.get */.Z.get(accountSetting, 'desktop_button.background_mask_url');
|
|
285
|
+
|
|
286
|
+
if (this.props.store.isMobile()) {
|
|
287
|
+
imgsrc = util/* default.get */.Z.get(accountSetting, 'mobile_button.background_image_url') || util/* default.get */.Z.get(accountSetting, 'mobile_button.background_mask_url') || imgsrc;
|
|
288
|
+
position = util/* default.get */.Z.get(accountSetting, 'mobile_button.position') || position;
|
|
289
|
+
let mobileimgurl = util/* default.get */.Z.get(accountSetting, 'mobile_button.background_image_url');
|
|
290
|
+
let mobilemaskurl = util/* default.get */.Z.get(accountSetting, 'mobile_button.background_mask_url');
|
|
291
|
+
|
|
292
|
+
if (mobileimgurl || mobilemaskurl) {
|
|
293
|
+
imgurl = mobileimgurl;
|
|
294
|
+
maskurl = mobilemaskurl;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
let whitebgcls = 'chat-button--white-bg';
|
|
299
|
+
if (!imgurl && maskurl) whitebgcls += ' chat-button--white-bg--mask-only';
|
|
300
|
+
let imgcontainerstyle = '';
|
|
301
|
+
imgurl = this.props.store.replaceFileUrl(imgurl);
|
|
302
|
+
imgsrc = this.props.store.replaceFileUrl(imgsrc);
|
|
303
|
+
maskurl = this.props.store.replaceFileUrl(maskurl);
|
|
304
|
+
|
|
305
|
+
if (!imgurl && !maskurl) {
|
|
306
|
+
whitebgcls += ' chat-button--white-bg--mask-only';
|
|
307
|
+
imgcontainerstyle = `
|
|
308
|
+
-webkit-mask-image: url("${encodeURI(DEF_BG_URL)}") !important;
|
|
309
|
+
-o-mask-image: url("${encodeURI(DEF_BG_URL)}") !important;
|
|
310
|
+
-moz-mask-image: url("${encodeURI(DEF_BG_URL)}") !important;
|
|
311
|
+
mask-image: url("${encodeURI(DEF_BG_URL)}") !important;
|
|
312
|
+
height: 70px !important;
|
|
313
|
+
width: 70px !important;
|
|
314
|
+
background: ${background} !important;
|
|
315
|
+
`;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (imgurl && maskurl) {
|
|
319
|
+
imgcontainerstyle = `
|
|
320
|
+
-webkit-mask-image: url("${encodeURI(maskurl)}") !important;
|
|
321
|
+
-o-mask-image: url("${encodeURI(maskurl)}") !important;
|
|
322
|
+
-moz-mask-image: url("${encodeURI(maskurl)}") !important;
|
|
323
|
+
mask-image: url("${encodeURI(maskurl)}") !important;
|
|
324
|
+
background-image: url("${encodeURI(imgurl)}") !important;
|
|
325
|
+
background-repeat: no-repeat !important;
|
|
326
|
+
`;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (imgurl && !maskurl) {
|
|
330
|
+
imgcontainerstyle = `
|
|
331
|
+
background-image: url("${encodeURI(imgurl)}") !important;
|
|
332
|
+
background-repeat: no-repeat !important;
|
|
333
|
+
`;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (!imgurl && maskurl) {
|
|
337
|
+
imgcontainerstyle = `
|
|
338
|
+
-webkit-mask-image: url("${encodeURI(maskurl)}") !important;
|
|
339
|
+
-o-mask-image: url("${encodeURI(maskurl)}") !important;
|
|
340
|
+
-moz-mask-image: url("${encodeURI(maskurl)}") !important;
|
|
341
|
+
mask-image: url("${encodeURI(maskurl)}") !important;
|
|
342
|
+
height: 70px !important;
|
|
343
|
+
width: 70px !important;
|
|
344
|
+
background: ${background} !important;
|
|
345
|
+
`;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
let cls = 'chat-button chat-button--' + position;
|
|
349
|
+
return (0,preact_module.h)("div", {
|
|
350
|
+
class: cls,
|
|
351
|
+
onClick: e => this.onClick(e)
|
|
352
|
+
}, (0,preact_module.h)("div", {
|
|
353
|
+
class: whitebgcls
|
|
354
|
+
}), (0,preact_module.h)("div", {
|
|
355
|
+
class: "chat-button--img-container",
|
|
356
|
+
style: imgcontainerstyle
|
|
357
|
+
}, (0,preact_module.h)("img", {
|
|
358
|
+
width: "70",
|
|
359
|
+
height: "70",
|
|
360
|
+
alt: "chat button",
|
|
361
|
+
class: "chat-button--img",
|
|
362
|
+
onload: () => this.onButtonReady(),
|
|
363
|
+
src: imgsrc,
|
|
364
|
+
onError: (e, a) => this.onChatButtonError(e, a)
|
|
365
|
+
})), this.renderUnread());
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
onProfileError(ev) {
|
|
369
|
+
var $el = ev.target;
|
|
370
|
+
$el.src = defaultAvatar;
|
|
371
|
+
this.onProfileReady();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
onChatButtonError(ev) {
|
|
375
|
+
if (this._onChatButtonErrorExecuted) return;
|
|
376
|
+
this._onChatButtonErrorExecuted = true;
|
|
377
|
+
var $el = ev.target;
|
|
378
|
+
$el.src = defaultBubble;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
renderMessagePreview(ev, defmsg) {
|
|
382
|
+
defmsg = defmsg || 'Sent you a message';
|
|
383
|
+
let message = util/* default.get */.Z.get(ev, 'data.message.text');
|
|
384
|
+
var format = util/* default.get */.Z.get(ev, 'data.message.format');
|
|
385
|
+
if (format && format !== 'plaintext') message = defmsg;
|
|
386
|
+
if (!message && util/* default.size */.Z.size(util/* default.get */.Z.get(ev, 'data.message.attachments')) > 0) message = defmsg;
|
|
387
|
+
if (!message) return null;
|
|
388
|
+
let byType = util/* default.get */.Z.get(ev, 'by.type');
|
|
389
|
+
var tags = util/* default.extractText */.Z.extractText(message).map(tag => {
|
|
390
|
+
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
391
|
+
emojiCode: tag.text,
|
|
392
|
+
byType: byType
|
|
393
|
+
});
|
|
394
|
+
return tag.text;
|
|
395
|
+
});
|
|
396
|
+
return tags;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
closePreview(e) {
|
|
400
|
+
if (e) {
|
|
401
|
+
e.preventDefault();
|
|
402
|
+
e.stopPropagation();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
this.setState({
|
|
406
|
+
displayPreview: false
|
|
407
|
+
});
|
|
408
|
+
this.props.store.closePreview();
|
|
409
|
+
this.forceUpdate();
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function randomAgent(agentM) {
|
|
415
|
+
var agents = util/* default.filter */.Z.filter(agentM, ag => ag.type === 'agent');
|
|
416
|
+
return agents[Math.floor(Math.random() * util/* default.size */.Z.size(agents))] || {};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const Ms30Mins = 30 * 60 * 1000;
|
|
420
|
+
const DEF_BG_URL = 'https://file-subiz.com/bubble_11.svg';
|
|
421
|
+
const DEF_BG = 'linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)';
|
|
422
|
+
;// CONCATENATED MODULE: ./src/chatbox/PoweredBy.js
|
|
423
|
+
var logo = __webpack_require__(8430);
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
class PoweredBy extends common/* Com */.M {
|
|
428
|
+
constructor(props) {
|
|
429
|
+
super(props);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
render() {
|
|
433
|
+
if (this.props.store.isMobile()) return null;
|
|
434
|
+
let user = this.props.store.matchUser();
|
|
435
|
+
var link = `https://subiz.com.vn/?utm_source=id-${user.account_id}&utm_medium=widget&utm_campaign=widget_referral`;
|
|
436
|
+
return (0,preact_module.h)("div", {
|
|
437
|
+
class: "poweredby"
|
|
438
|
+
}, (0,preact_module.h)("a", {
|
|
439
|
+
href: link,
|
|
440
|
+
class: "poweredby--text",
|
|
441
|
+
target: "_blank",
|
|
442
|
+
rel: "noreferrer"
|
|
443
|
+
}, (0,preact_module.h)("img", {
|
|
444
|
+
width: "14",
|
|
445
|
+
height: "10",
|
|
446
|
+
class: "poweredby--subiz-logo",
|
|
447
|
+
src: logo,
|
|
448
|
+
alt: "power by"
|
|
449
|
+
}), " Subiz"));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
}
|
|
453
|
+
;// CONCATENATED MODULE: ./src/chatbox/AgentsAvatar.js
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
class AgentsAvatar extends common/* Com */.M {
|
|
458
|
+
constructor(props) {
|
|
459
|
+
super(props);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
render() {
|
|
463
|
+
let accountSetting = this.props.plugin.chatbox;
|
|
464
|
+
let agentM = this.props.store.matchAgent('*');
|
|
465
|
+
var agents = util/* default.map */.Z.map(this.props.agent_ids, id => agentM[id]);
|
|
466
|
+
|
|
467
|
+
if (this.props.agent_ids === undefined || util/* default.size */.Z.size(this.props.agent_ids) === 0) {
|
|
468
|
+
var agids = util/* default.get */.Z.get(accountSetting, 'header.agent_ids', []);
|
|
469
|
+
agids = util/* default.filter */.Z.filter(agids, id => !!agentM[id]);
|
|
470
|
+
|
|
471
|
+
if (agids.length !== 0) {
|
|
472
|
+
agents = util/* default.map */.Z.map(agids, id => agentM[id]);
|
|
473
|
+
} else {
|
|
474
|
+
agents = util/* default.filter */.Z.filter(agentM, agent => agent.type === 'agent');
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
agents = util/* default.filter */.Z.filter(agents, ag => !!ag);
|
|
479
|
+
let acc = this.props.store.matchAccount();
|
|
480
|
+
var tooltippos = this.props.tooltipPos || 'bottom';
|
|
481
|
+
var mode = this.props.mode || 'primary';
|
|
482
|
+
|
|
483
|
+
if (agents.length === 0) {
|
|
484
|
+
return (0,preact_module.h)("div", {
|
|
485
|
+
class: `group-avatar group-avatar--${mode}`
|
|
486
|
+
}, (0,preact_module.h)("div", {
|
|
487
|
+
class: "d-inline-block pos-relative",
|
|
488
|
+
"data-tooltip": acc.name,
|
|
489
|
+
"data-tooltip-position": tooltippos
|
|
490
|
+
}, (0,preact_module.h)("img", {
|
|
491
|
+
width: 35,
|
|
492
|
+
height: 35,
|
|
493
|
+
alt: "agent avatar left",
|
|
494
|
+
class: "avatar group-avatar--agent-left",
|
|
495
|
+
src: this.props.store.replaceFileUrl(acc.logo_url) || __webpack_require__(9895)
|
|
496
|
+
})));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (agents.length === 1) {
|
|
500
|
+
var agent = agents[0];
|
|
501
|
+
var groupClass = mode === 'primary' ? 'group-avatar--agent-middle' : 'group-avatar--agent-left';
|
|
502
|
+
return (0,preact_module.h)("div", {
|
|
503
|
+
class: `group-avatar group-avatar--${mode}`
|
|
504
|
+
}, (0,preact_module.h)("div", {
|
|
505
|
+
class: "d-inline-block pos-relative",
|
|
506
|
+
"data-tooltip": agent.fullname || acc.name,
|
|
507
|
+
"data-tooltip-position": tooltippos
|
|
508
|
+
}, (0,preact_module.h)("img", {
|
|
509
|
+
width: 35,
|
|
510
|
+
height: 35,
|
|
511
|
+
class: `avatar ${groupClass}`,
|
|
512
|
+
alt: "agent avatar",
|
|
513
|
+
src: this.props.store.replaceFileUrl(agent.avatar_url) || __webpack_require__(4761)
|
|
514
|
+
})));
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (agents.length === 2) {
|
|
518
|
+
let leftAgent = agents[0];
|
|
519
|
+
let rightAgent = agents[1];
|
|
520
|
+
return (0,preact_module.h)("div", {
|
|
521
|
+
class: `group-avatar group-avatar--${mode}`
|
|
522
|
+
}, (0,preact_module.h)("div", {
|
|
523
|
+
class: "d-inline-block pos-relative",
|
|
524
|
+
"data-tooltip": leftAgent.fullname || acc.name,
|
|
525
|
+
"data-tooltip-position": tooltippos
|
|
526
|
+
}, (0,preact_module.h)("img", {
|
|
527
|
+
width: 35,
|
|
528
|
+
height: 35,
|
|
529
|
+
alt: "agent avatar left",
|
|
530
|
+
class: "avatar group-avatar--agent-left",
|
|
531
|
+
src: this.props.store.replaceFileUrl(leftAgent.avatar_url) || __webpack_require__(4761)
|
|
532
|
+
})), (0,preact_module.h)("div", {
|
|
533
|
+
class: "d-inline-block pos-relative",
|
|
534
|
+
"data-tooltip": rightAgent.fullname || acc.name,
|
|
535
|
+
"data-tooltip-position": tooltippos
|
|
536
|
+
}, (0,preact_module.h)("img", {
|
|
537
|
+
alt: "agent avatar right",
|
|
538
|
+
width: 35,
|
|
539
|
+
height: 35,
|
|
540
|
+
class: "avatar group-avatar--agent-right",
|
|
541
|
+
src: this.props.store.replaceFileUrl(rightAgent.avatar_url) || __webpack_require__(4761)
|
|
542
|
+
})));
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
let leftAgent = agents[0];
|
|
546
|
+
let middleAgent = agents[1];
|
|
547
|
+
let rightAgent = agents[2];
|
|
548
|
+
return (0,preact_module.h)("div", {
|
|
549
|
+
class: `group-avatar group-avatar--${mode}`
|
|
550
|
+
}, (0,preact_module.h)("div", {
|
|
551
|
+
class: "d-inline-block pos-relative",
|
|
552
|
+
"data-tooltip": leftAgent.fullname || acc.name,
|
|
553
|
+
"data-tooltip-position": tooltippos
|
|
554
|
+
}, (0,preact_module.h)("img", {
|
|
555
|
+
width: 35,
|
|
556
|
+
height: 35,
|
|
557
|
+
alt: "agent avatar left",
|
|
558
|
+
class: "avatar group-avatar--agent-left",
|
|
559
|
+
src: this.props.store.replaceFileUrl(leftAgent.avatar_url) || __webpack_require__(4761)
|
|
560
|
+
})), (0,preact_module.h)("div", {
|
|
561
|
+
class: "d-inline-block pos-relative",
|
|
562
|
+
"data-tooltip": middleAgent.fullname || acc.name,
|
|
563
|
+
"data-tooltip-position": tooltippos
|
|
564
|
+
}, (0,preact_module.h)("img", {
|
|
565
|
+
alt: "agent avatar middle",
|
|
566
|
+
width: 35,
|
|
567
|
+
height: 35,
|
|
568
|
+
class: "avatar group-avatar--agent-middle",
|
|
569
|
+
src: this.props.store.replaceFileUrl(middleAgent.avatar_url) || __webpack_require__(4761)
|
|
570
|
+
})), (0,preact_module.h)("div", {
|
|
571
|
+
class: "d-inline-block pos-relative",
|
|
572
|
+
"data-tooltip": rightAgent.fullname || acc.name,
|
|
573
|
+
"data-tooltip-position": tooltippos
|
|
574
|
+
}, (0,preact_module.h)("img", {
|
|
575
|
+
width: 35,
|
|
576
|
+
height: 35,
|
|
577
|
+
alt: "agent avatar right",
|
|
578
|
+
class: "avatar group-avatar--agent-right",
|
|
579
|
+
src: this.props.store.replaceFileUrl(rightAgent.avatar_url) || __webpack_require__(4761)
|
|
580
|
+
})));
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
}
|
|
584
|
+
;// CONCATENATED MODULE: ./src/chatbox/Header.js
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
class Header extends common/* Com */.M {
|
|
591
|
+
constructor(props) {
|
|
592
|
+
super(props);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
render() {
|
|
596
|
+
let headerMode = 'collapsed';
|
|
597
|
+
let cls = 'widget-header';
|
|
598
|
+
let renderSocial = false;
|
|
599
|
+
let renderTeam = false;
|
|
600
|
+
let renderCollapsed = this.props.view !== 'list' && headerMode === 'collapsed';
|
|
601
|
+
let accSetting = this.props.plugin.chatbox || {};
|
|
602
|
+
let layout = util/* default.get */.Z.get(accSetting, 'header.layout');
|
|
603
|
+
|
|
604
|
+
if (renderCollapsed) {
|
|
605
|
+
cls += ' widget-header--collapsed';
|
|
606
|
+
} else {
|
|
607
|
+
cls += ' widget-header--convo-expanded';
|
|
608
|
+
renderSocial = layout === 'social';
|
|
609
|
+
renderTeam = !renderSocial;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
return (0,preact_module.h)("div", {
|
|
613
|
+
class: cls
|
|
614
|
+
}, this.renderCollapsedHeader(renderCollapsed), this.renderSocial(renderSocial), this.renderTeam(renderTeam));
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
renderCollapsedHeader(show) {
|
|
618
|
+
let accSetting = this.props.plugin.chatbox || {};
|
|
619
|
+
let acc = this.props.store.matchAccount();
|
|
620
|
+
let state = acc.is_online ? this.props.t('agent_online') : this.props.t('agent_offline');
|
|
621
|
+
let tagline = util/* default.get */.Z.get(accSetting, `tagline`, {});
|
|
622
|
+
let desc = this.props.t.i18n(tagline) || accSetting.introduction || state;
|
|
623
|
+
let agentIdsJoined = util/* default.map */.Z.map(this.getAgentJoined(this.props.cid), agent => agent.id);
|
|
624
|
+
let cls = 'widget-header--inner widget-header--inner--collapsed';
|
|
625
|
+
if (!show) cls += ' widget-header--inner--hidden';
|
|
626
|
+
return (0,preact_module.h)("div", {
|
|
627
|
+
class: cls
|
|
628
|
+
}, this.renderBackButton(), (0,preact_module.h)(AgentsAvatar, {
|
|
629
|
+
plugin: this.props.plugin,
|
|
630
|
+
store: this.props.store,
|
|
631
|
+
mode: "secondary",
|
|
632
|
+
agent_ids: agentIdsJoined
|
|
633
|
+
}), (0,preact_module.h)("div", {
|
|
634
|
+
class: "widget-header--title-container"
|
|
635
|
+
}, (0,preact_module.h)("div", {
|
|
636
|
+
class: "widget-header--title"
|
|
637
|
+
}, this.getTitle()), (0,preact_module.h)("div", {
|
|
638
|
+
class: "widget-header--description",
|
|
639
|
+
title: desc
|
|
640
|
+
}, desc)), this.renderCloseButton());
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
renderSocial(show) {
|
|
644
|
+
let accSetting = this.props.plugin.chatbox || {};
|
|
645
|
+
let acc = this.props.store.matchAccount();
|
|
646
|
+
let links = util/* default.get */.Z.get(accSetting, 'header.links') || [];
|
|
647
|
+
let $links = util/* default.map */.Z.map(links, link => {
|
|
648
|
+
if (!link.url || !link.type || link.type === 'subiz') return null;
|
|
649
|
+
|
|
650
|
+
if (link.type === 'email') {
|
|
651
|
+
return (0,preact_module.h)("div", null, (0,preact_module.h)("a", {
|
|
652
|
+
href: `mailto:${link.url}`,
|
|
653
|
+
title: link.url
|
|
654
|
+
}, (0,preact_module.h)("i", {
|
|
655
|
+
class: `social__links-logo social__links-logo--${link.type}`
|
|
656
|
+
})));
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
return (0,preact_module.h)("div", null, (0,preact_module.h)("a", {
|
|
660
|
+
href: link.url,
|
|
661
|
+
target: "_blank",
|
|
662
|
+
title: link.url,
|
|
663
|
+
rel: "noreferrer"
|
|
664
|
+
}, (0,preact_module.h)("i", {
|
|
665
|
+
class: `social__links-logo social__links-logo--${link.type}`
|
|
666
|
+
})));
|
|
667
|
+
});
|
|
668
|
+
const DEFTEAMINTO = `Chúng tôi sẵn sàng trợ giúp :wave:.
|
|
669
|
+
Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi của bạn`;
|
|
670
|
+
let tagline = util/* default.get */.Z.get(accSetting, `tagline`, {});
|
|
671
|
+
var teamintro = this.props.t.i18n(tagline) || accSetting.introduction || this.props.t('team_intro') || DEFTEAMINTO;
|
|
672
|
+
var tags = util/* default.extractText */.Z.extractText(teamintro).map(tag => {
|
|
673
|
+
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
674
|
+
emojiCode: tag.text
|
|
675
|
+
});
|
|
676
|
+
return tag.text;
|
|
677
|
+
});
|
|
678
|
+
let cls = 'widget-header--inner widget-header--inner--expanded';
|
|
679
|
+
if (!show) cls += ' widget-header--inner--hidden';
|
|
680
|
+
return (0,preact_module.h)("div", {
|
|
681
|
+
class: cls
|
|
682
|
+
}, (0,preact_module.h)("div", {
|
|
683
|
+
class: "widget-header-expand-container"
|
|
684
|
+
}, (0,preact_module.h)("div", {
|
|
685
|
+
class: "widget-header--top-wrapper"
|
|
686
|
+
}, (0,preact_module.h)("div", {
|
|
687
|
+
class: "widget-header--title"
|
|
688
|
+
}, this.getTitle()), this.renderCloseButton()), (0,preact_module.h)("div", {
|
|
689
|
+
class: "widget_header__body widget_header__body__social"
|
|
690
|
+
}, (0,preact_module.h)("img", {
|
|
691
|
+
alt: "logo",
|
|
692
|
+
class: "social__account_logo",
|
|
693
|
+
src: this.props.store.replaceFileUrl(util/* default.get */.Z.get(acc, 'logo_url'))
|
|
694
|
+
}), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
695
|
+
class: "social__introduction"
|
|
696
|
+
}, tags), (0,preact_module.h)("div", {
|
|
697
|
+
class: "social__links"
|
|
698
|
+
}, $links)))));
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
renderTeam(show) {
|
|
702
|
+
let accSetting = this.props.plugin.chatbox || {};
|
|
703
|
+
const DEFTEAMINTO = `Chúng tôi sẵn sàng trợ giúp :wave:.
|
|
704
|
+
Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi của bạn`;
|
|
705
|
+
let tagline = util/* default.get */.Z.get(accSetting, `tagline`, {});
|
|
706
|
+
var teamintro = this.props.t.i18n(tagline) || accSetting.introduction || this.props.t('team_intro') || DEFTEAMINTO;
|
|
707
|
+
var tags = util/* default.extractText */.Z.extractText(teamintro).map(tag => {
|
|
708
|
+
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
709
|
+
emojiCode: tag.text
|
|
710
|
+
});
|
|
711
|
+
return tag.text;
|
|
712
|
+
});
|
|
713
|
+
let cls = 'widget-header--inner widget-header--inner--expanded';
|
|
714
|
+
if (!show) cls += ' widget-header--inner--hidden';
|
|
715
|
+
return (0,preact_module.h)("div", {
|
|
716
|
+
class: cls
|
|
717
|
+
}, (0,preact_module.h)("div", {
|
|
718
|
+
class: "widget-header-expand-container"
|
|
719
|
+
}, (0,preact_module.h)("div", {
|
|
720
|
+
class: "widget-header--top-wrapper"
|
|
721
|
+
}, (0,preact_module.h)("div", {
|
|
722
|
+
class: "widget-header--title"
|
|
723
|
+
}, this.getTitle()), this.renderCloseButton()), (0,preact_module.h)("div", {
|
|
724
|
+
class: "widget_header__body"
|
|
725
|
+
}, (0,preact_module.h)("div", {
|
|
726
|
+
class: "widget-header--avatar-wrapper"
|
|
727
|
+
}, (0,preact_module.h)(AgentsAvatar, {
|
|
728
|
+
plugin: this.props.plugin,
|
|
729
|
+
store: this.props.store,
|
|
730
|
+
mode: "primary"
|
|
731
|
+
})), (0,preact_module.h)("div", {
|
|
732
|
+
class: "widget-header--title-container"
|
|
733
|
+
}, (0,preact_module.h)("div", {
|
|
734
|
+
class: "widget-header--description"
|
|
735
|
+
}, tags)))));
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
getTitle() {
|
|
739
|
+
let accSetting = this.props.plugin.chatbox || {};
|
|
740
|
+
let acc = this.props.store.matchAccount();
|
|
741
|
+
let agentsJoined = this.getAgentJoined(this.props.cid);
|
|
742
|
+
let caption = util/* default.get */.Z.get(this.props.plugin, 'chatbox.caption', {});
|
|
743
|
+
let title = this.props.t.i18n(caption) || accSetting.title;
|
|
744
|
+
return getJoinedNameMember(agentsJoined) || title || acc.name || this.props.t('widget_title');
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
renderBackButton() {
|
|
748
|
+
let allconvos = this.props.store.matchConvo('*');
|
|
749
|
+
if (util/* default.size */.Z.size(allconvos) === 0) return null;
|
|
750
|
+
var $unreadcount = null;
|
|
751
|
+
let user = this.props.store.matchUser();
|
|
752
|
+
let unreadcount = 0;
|
|
753
|
+
util/* default.map */.Z.map(allconvos, convo => {
|
|
754
|
+
if (convo.id == this.props.cid) return;
|
|
755
|
+
if (!util/* default.isConvoSeen */.Z.isConvoSeen(convo, user.id)) unreadcount++;
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
if (unreadcount !== 0) {
|
|
759
|
+
$unreadcount = (0,preact_module.h)("span", {
|
|
760
|
+
class: "widget-header--total-unread-convo"
|
|
761
|
+
}, unreadcount);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
return (0,preact_module.h)("div", {
|
|
765
|
+
class: `widget-header--wrap-button-back ${unreadcount ? 'widget-header--has-convo-unred' : ''}`,
|
|
766
|
+
onClick: e => this.onBackClick(e)
|
|
767
|
+
}, (0,preact_module.h)("div", {
|
|
768
|
+
class: "widget-header--button-back",
|
|
769
|
+
"data-tooltip": this.props.t('menu_back')
|
|
770
|
+
}), $unreadcount);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
renderCloseButton() {
|
|
774
|
+
return (0,preact_module.h)("div", {
|
|
775
|
+
class: "widget-header--button widget-header--button-close",
|
|
776
|
+
"data-tooltip": this.props.t('close'),
|
|
777
|
+
"data-tooltip-position": "bottom",
|
|
778
|
+
onClick: e => this.onCloseClick(e)
|
|
779
|
+
}, (0,preact_module.h)("span", {
|
|
780
|
+
class: "widget-header--button-close-icon"
|
|
781
|
+
}));
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
onBackClick(e) {
|
|
785
|
+
e.stopPropagation();
|
|
786
|
+
e.preventDefault();
|
|
787
|
+
this.props.onGotoList && this.props.onGotoList();
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
onCloseClick(e) {
|
|
791
|
+
e.stopPropagation();
|
|
792
|
+
e.preventDefault();
|
|
793
|
+
this.props.onClose && this.props.onClose();
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
getAgentJoined(cid) {
|
|
797
|
+
var convo = this.props.store.matchConvo(cid) || {};
|
|
798
|
+
let joined = util/* default.filter */.Z.filter(convo.members, mem => mem.type === 'agent' && mem.membership === 'active');
|
|
799
|
+
return joined;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
let getJoinedNameMember = agents => util/* default.map */.Z.map(agents, agent => agent.name).join(', ');
|
|
805
|
+
;// CONCATENATED MODULE: ./src/chatbox/MessageInput.js
|
|
806
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
class MessageInput extends common/* Com */.M {
|
|
813
|
+
constructor(props) {
|
|
814
|
+
super(props);
|
|
815
|
+
|
|
816
|
+
_defineProperty(this, "onEnter", util/* default.throttle */.Z.throttle(function () {
|
|
817
|
+
this.submitMessage();
|
|
818
|
+
}, 50));
|
|
819
|
+
|
|
820
|
+
this.refFileInput = (0,preact_module/* createRef */.Vf)();
|
|
821
|
+
this.refMessageInput = (0,preact_module/* createRef */.Vf)();
|
|
822
|
+
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
823
|
+
this.props.store.onConvoEvent(this, ev => {
|
|
824
|
+
var evcid = util/* default.convoOfEv */.Z.convoOfEv(ev);
|
|
825
|
+
if (evcid !== this.props.cid) return;
|
|
826
|
+
this.forceUpdate();
|
|
827
|
+
});
|
|
828
|
+
this.focus();
|
|
829
|
+
this._forceUpdate = util/* default.throttle */.Z.throttle(() => {
|
|
830
|
+
this.forceUpdate();
|
|
831
|
+
}, 500);
|
|
832
|
+
this.resizeInput = util/* default.throttle */.Z.throttle(function () {
|
|
833
|
+
const input = this.refMessageInput.current;
|
|
834
|
+
input.style.setProperty('height', '1em', 'important');
|
|
835
|
+
const height = Math.min(200, input.scrollHeight);
|
|
836
|
+
input.style.setProperty('height', `${height}px`, 'important');
|
|
837
|
+
}, 5);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
render() {
|
|
841
|
+
var buttons = (0,preact_module.h)("div", {
|
|
842
|
+
class: "d-flex flex-row align-self-end"
|
|
843
|
+
}, this.renderEmoji(), (0,preact_module.h)("div", {
|
|
844
|
+
"data-tooltip-poasition": "top-left",
|
|
845
|
+
class: "message-input--button message-input--attachment-button",
|
|
846
|
+
onClick: e => this.selectFile(e)
|
|
847
|
+
}));
|
|
848
|
+
var msg = util/* default.trim */.Z.trim(this.refMessageInput.current && this.refMessageInput.current.value);
|
|
849
|
+
|
|
850
|
+
if (msg.length > 0) {
|
|
851
|
+
buttons = (0,preact_module.h)("div", {
|
|
852
|
+
class: "d-flex flex-row align-self-end"
|
|
853
|
+
}, this.renderEmoji(), (0,preact_module.h)("div", {
|
|
854
|
+
"data-tooltip-position": "top-left",
|
|
855
|
+
class: "message-input--button message-input--send-button",
|
|
856
|
+
onClick: () => this.submitMessage()
|
|
857
|
+
}));
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
var containercls = '';
|
|
861
|
+
var disabled = this.hasUnfinishRequiredFormOrLock() || this.props.disabled;
|
|
862
|
+
if (disabled) containercls = 'message-input--disabled';
|
|
863
|
+
return (0,preact_module.h)("div", {
|
|
864
|
+
class: `message-input ${containercls}`,
|
|
865
|
+
onClick: e => {
|
|
866
|
+
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
867
|
+
}
|
|
868
|
+
}, (0,preact_module.h)("input", {
|
|
869
|
+
class: "d-none",
|
|
870
|
+
ref: this.refFileInput,
|
|
871
|
+
type: "file",
|
|
872
|
+
onChange: e => this.sendFile(e),
|
|
873
|
+
multiple: true
|
|
874
|
+
}), (0,preact_module.h)("textarea", {
|
|
875
|
+
disabled: disabled,
|
|
876
|
+
class: "message-input--input",
|
|
877
|
+
maxlength: "1024",
|
|
878
|
+
placeholder: this.props.t('message_input_help'),
|
|
879
|
+
ref: this.refMessageInput,
|
|
880
|
+
rows: "1",
|
|
881
|
+
onInput: e => this.onChange(e),
|
|
882
|
+
onPaste: e => this.pasteImage(e),
|
|
883
|
+
"data-emojiable": "true",
|
|
884
|
+
onKeydown: e => this.onKeydown(e)
|
|
885
|
+
}), buttons);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
hasUnfinishRequiredFormOrLock() {
|
|
889
|
+
let convo = this.props.store.matchConvo(this.props.cid);
|
|
890
|
+
if (util/* default.get */.Z.get(convo, 'state') === 'ended') return false;
|
|
891
|
+
let events = this.props.store.listEvents(this.props.cid);
|
|
892
|
+
events = util/* default.orderBy */.Z.orderBy(events, 'created', 'desc').filter(ev => ev.type === 'message_sent');
|
|
893
|
+
let attachments = util/* default.get */.Z.get(events[0], 'data.message.attachments', []);
|
|
894
|
+
let lock = util/* default.find */.Z.find(attachments, att => util/* default.get */.Z.get(att, 'lock_input'));
|
|
895
|
+
if (lock) return true;
|
|
896
|
+
var last_agent_sent;
|
|
897
|
+
|
|
898
|
+
for (let ev of events) {
|
|
899
|
+
if (util/* default.get */.Z.get(ev, 'by.type') === 'user') continue;
|
|
900
|
+
last_agent_sent = ev;
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
attachments = util/* default.get */.Z.get(last_agent_sent, 'data.message.attachments', []);
|
|
905
|
+
let pendingForms = util/* default.filter */.Z.filter(attachments, att => {
|
|
906
|
+
if (!att) return false;
|
|
907
|
+
if (att.type !== 'form' && att.type !== 'ask_info_form') return false;
|
|
908
|
+
var form = att.form;
|
|
909
|
+
if (!form) return false;
|
|
910
|
+
var state = util/* default.parseJSON */.Z.parseJSON(form.state) || {};
|
|
911
|
+
if (!state.require_finished && att.type !== 'ask_info_form') return false;
|
|
912
|
+
if (isSummited(att.form)) return false;
|
|
913
|
+
return true;
|
|
914
|
+
});
|
|
915
|
+
return util/* default.size */.Z.size(pendingForms) > 0;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
renderEmojiPopup() {
|
|
919
|
+
if (!this.state.openEmoji) return null;
|
|
920
|
+
return (0,preact_module.h)("div", {
|
|
921
|
+
class: "emoji-picker",
|
|
922
|
+
"v-clickaway": e => this.setState({
|
|
923
|
+
openEmoji: false
|
|
924
|
+
})
|
|
925
|
+
}, (0,preact_module.h)("div", {
|
|
926
|
+
class: "emoji-picker-background-item"
|
|
927
|
+
}, (0,preact_module.h)("div", {
|
|
928
|
+
onClick: () => this.emojiPick(':like:'),
|
|
929
|
+
"data-tooltip": ":like:",
|
|
930
|
+
class: "emoji-picker--item emoji--like"
|
|
931
|
+
})), (0,preact_module.h)("div", {
|
|
932
|
+
class: "emoji-picker-background-item"
|
|
933
|
+
}, (0,preact_module.h)("div", {
|
|
934
|
+
onClick: () => this.emojiPick(':unlike:'),
|
|
935
|
+
"data-tooltip": ":unlike:",
|
|
936
|
+
class: "emoji-picker--item emoji--unlike"
|
|
937
|
+
})), (0,preact_module.h)("div", {
|
|
938
|
+
class: "emoji-picker-background-item"
|
|
939
|
+
}, (0,preact_module.h)("div", {
|
|
940
|
+
onClick: () => this.emojiPick(':angry:'),
|
|
941
|
+
"data-tooltip": ":angry:",
|
|
942
|
+
class: "emoji-picker--item emoji--angry"
|
|
943
|
+
})), (0,preact_module.h)("div", {
|
|
944
|
+
class: "emoji-picker-background-item"
|
|
945
|
+
}, (0,preact_module.h)("div", {
|
|
946
|
+
onClick: () => this.emojiPick(':confused:'),
|
|
947
|
+
"data-tooltip": ":confused:",
|
|
948
|
+
class: "emoji-picker--item emoji--confused"
|
|
949
|
+
})), (0,preact_module.h)("div", {
|
|
950
|
+
class: "emoji-picker-background-item"
|
|
951
|
+
}, (0,preact_module.h)("div", {
|
|
952
|
+
onClick: () => this.emojiPick(':crying:'),
|
|
953
|
+
"data-tooltip": ":crying:",
|
|
954
|
+
class: "emoji-picker--item emoji--crying"
|
|
955
|
+
})), (0,preact_module.h)("div", {
|
|
956
|
+
class: "emoji-picker-background-item"
|
|
957
|
+
}, (0,preact_module.h)("div", {
|
|
958
|
+
onClick: () => this.emojiPick(':grinning:'),
|
|
959
|
+
"data-tooltip": ":grinning:",
|
|
960
|
+
class: "emoji-picker--item emoji--grinning"
|
|
961
|
+
})), (0,preact_module.h)("div", {
|
|
962
|
+
class: "emoji-picker-background-item"
|
|
963
|
+
}, (0,preact_module.h)("div", {
|
|
964
|
+
onClick: () => this.emojiPick(':heart-eyes:'),
|
|
965
|
+
"data-tooltip": ":heart-eyes:",
|
|
966
|
+
class: "emoji-picker--item emoji--heart-eyes"
|
|
967
|
+
})), (0,preact_module.h)("div", {
|
|
968
|
+
class: "emoji-picker-background-item"
|
|
969
|
+
}, (0,preact_module.h)("div", {
|
|
970
|
+
onClick: () => this.emojiPick(':neutral:'),
|
|
971
|
+
"data-tooltip": ":neutral:",
|
|
972
|
+
class: "emoji-picker--item emoji--neutral"
|
|
973
|
+
})), (0,preact_module.h)("div", {
|
|
974
|
+
class: "emoji-picker-background-item"
|
|
975
|
+
}, (0,preact_module.h)("div", {
|
|
976
|
+
onClick: () => this.emojiPick(':sad:'),
|
|
977
|
+
"data-tooltip": ":sad:",
|
|
978
|
+
class: "emoji-picker--item emoji--sad"
|
|
979
|
+
})), (0,preact_module.h)("div", {
|
|
980
|
+
class: "emoji-picker-background-item"
|
|
981
|
+
}, (0,preact_module.h)("div", {
|
|
982
|
+
onClick: () => this.emojiPick(':sleepy:'),
|
|
983
|
+
"data-tooltip": ":sleepy:",
|
|
984
|
+
class: "emoji-picker--item emoji--sleepy"
|
|
985
|
+
})), (0,preact_module.h)("div", {
|
|
986
|
+
class: "emoji-picker-background-item"
|
|
987
|
+
}, (0,preact_module.h)("div", {
|
|
988
|
+
onClick: () => this.emojiPick(':smiling:'),
|
|
989
|
+
"data-tooltip": ":smiling:",
|
|
990
|
+
class: "emoji-picker--item emoji--smiling"
|
|
991
|
+
})), (0,preact_module.h)("div", {
|
|
992
|
+
class: "emoji-picker-background-item"
|
|
993
|
+
}, (0,preact_module.h)("div", {
|
|
994
|
+
onClick: () => this.emojiPick(':surprised:'),
|
|
995
|
+
"data-tooltip": ":surprised:",
|
|
996
|
+
class: "emoji-picker--item emoji--surprised"
|
|
997
|
+
})), (0,preact_module.h)("div", {
|
|
998
|
+
class: "emoji-picker-background-item"
|
|
999
|
+
}, (0,preact_module.h)("div", {
|
|
1000
|
+
onClick: () => this.emojiPick(':tired:'),
|
|
1001
|
+
"data-tooltip": ":tired:",
|
|
1002
|
+
class: "emoji-picker--item emoji--tired"
|
|
1003
|
+
})), (0,preact_module.h)("div", {
|
|
1004
|
+
class: "emoji-picker-background-item"
|
|
1005
|
+
}, (0,preact_module.h)("div", {
|
|
1006
|
+
onClick: () => this.emojiPick(':tongue-out:'),
|
|
1007
|
+
"data-tooltip": ":tongue-out:",
|
|
1008
|
+
class: "emoji-picker--item emoji--tongue-out"
|
|
1009
|
+
})), (0,preact_module.h)("div", {
|
|
1010
|
+
class: "emoji-picker-background-item"
|
|
1011
|
+
}, (0,preact_module.h)("div", {
|
|
1012
|
+
onClick: () => this.emojiPick(':wink:'),
|
|
1013
|
+
"data-tooltip": ":wink:",
|
|
1014
|
+
class: "emoji-picker--item emoji--wink"
|
|
1015
|
+
})));
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
focus() {
|
|
1019
|
+
if (this.props.disabled) return;
|
|
1020
|
+
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
1021
|
+
setTimeout(() => {
|
|
1022
|
+
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
1023
|
+
});
|
|
1024
|
+
setTimeout(() => {
|
|
1025
|
+
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
1026
|
+
}, 100);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
renderEmoji() {
|
|
1030
|
+
return (0,preact_module.h)("div", null, this.renderEmojiPopup(), (0,preact_module.h)("div", {
|
|
1031
|
+
class: "message-input--button message-input--emoji-button",
|
|
1032
|
+
onClick: e => this.toggleEmoji(e)
|
|
1033
|
+
}));
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
toggleEmoji(e) {
|
|
1037
|
+
e.stopPropagation();
|
|
1038
|
+
this.focus();
|
|
1039
|
+
if (this.props.disabled) return;
|
|
1040
|
+
this.setState({
|
|
1041
|
+
openEmoji: !this.state.openEmoji
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
emojiPick(code) {
|
|
1046
|
+
const input = this.refMessageInput.current;
|
|
1047
|
+
const position = input.selectionStart;
|
|
1048
|
+
const message = this.refMessageInput.current.value;
|
|
1049
|
+
this.setState({
|
|
1050
|
+
openEmoji: false
|
|
1051
|
+
});
|
|
1052
|
+
this.refMessageInput.current.value = [message.slice(0, position), code, message.slice(position)].join('');
|
|
1053
|
+
this.resizeInput();
|
|
1054
|
+
input.focus();
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
onKeydown(e) {
|
|
1058
|
+
if (e.keyCode === 13 && e.shiftKey === false) {
|
|
1059
|
+
this.onEnter();
|
|
1060
|
+
return e.preventDefault();
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
this._forceUpdate();
|
|
1064
|
+
|
|
1065
|
+
this.sendTyping();
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
onChange() {
|
|
1069
|
+
this.resizeInput();
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
selectFile() {
|
|
1073
|
+
if (this.props.disabled) return;
|
|
1074
|
+
this.refFileInput.current.click();
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
sendFile() {
|
|
1078
|
+
let $input = this.refFileInput.current;
|
|
1079
|
+
|
|
1080
|
+
this._sendFile($input.files);
|
|
1081
|
+
|
|
1082
|
+
$input.value = '';
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
_sendFile(files) {
|
|
1086
|
+
if (util/* default.size */.Z.size(files) === 0) return;
|
|
1087
|
+
if (this.props.disabled) return;
|
|
1088
|
+
let attachments = util/* default.map */.Z.map(files, file => {
|
|
1089
|
+
return {
|
|
1090
|
+
type: 'file',
|
|
1091
|
+
mimetype: file.type,
|
|
1092
|
+
name: file.name,
|
|
1093
|
+
_file: file,
|
|
1094
|
+
size: file.size
|
|
1095
|
+
};
|
|
1096
|
+
});
|
|
1097
|
+
this.props.onSend && this.props.onSend({
|
|
1098
|
+
attachments
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
async submitMessage(msg) {
|
|
1103
|
+
msg = msg || util/* default.trim */.Z.trim(this.refMessageInput.current.value) || '';
|
|
1104
|
+
if (!msg) return;
|
|
1105
|
+
if (this.props.disabled) return;
|
|
1106
|
+
this.refMessageInput.current.value = '';
|
|
1107
|
+
this.resizeInput();
|
|
1108
|
+
this.setState({
|
|
1109
|
+
openEmoji: false
|
|
1110
|
+
});
|
|
1111
|
+
this.props.onSend && this.props.onSend({
|
|
1112
|
+
text: msg,
|
|
1113
|
+
format: 'plaintext'
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
sendTyping() {
|
|
1118
|
+
if (!this.props.cid) return;
|
|
1119
|
+
return this.props.store.typing(this.props.cid);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
pasteImage(event) {
|
|
1123
|
+
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) return;
|
|
1124
|
+
let now = new util/* default.Date */.Z.Date();
|
|
1125
|
+
let year = now.getFullYear();
|
|
1126
|
+
let month = now.getMonth() + 1;
|
|
1127
|
+
let date = now.getDate();
|
|
1128
|
+
let hour = now.getHours();
|
|
1129
|
+
let min = now.getMinutes();
|
|
1130
|
+
let sec = now.getSeconds();
|
|
1131
|
+
const name = `Paste-image-${year}-${month}-${date}-${hour}-${min}-${sec}`;
|
|
1132
|
+
let blob = null;
|
|
1133
|
+
const copiedData = event.clipboardData.items[0];
|
|
1134
|
+
|
|
1135
|
+
if (copiedData.type.indexOf('image') === 0) {
|
|
1136
|
+
blob = copiedData.getAsFile();
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
if (!blob) return;
|
|
1140
|
+
const parts = [blob, new ArrayBuffer()];
|
|
1141
|
+
const file = new File(parts, `${name}.png`, {
|
|
1142
|
+
type: 'image/png'
|
|
1143
|
+
});
|
|
1144
|
+
|
|
1145
|
+
this._sendFile([file]);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
function isSummited(form) {
|
|
1151
|
+
let fields = util/* default.get */.Z.get(form, 'fields') || [];
|
|
1152
|
+
return util/* default.find */.Z.find(fields, field => !!field.answered);
|
|
1153
|
+
}
|
|
1154
|
+
;// CONCATENATED MODULE: ./src/chatbox/ImageAttachments.js
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
class ImageAttachment extends common/* Com */.M {
|
|
1159
|
+
constructor(props) {
|
|
1160
|
+
super(props);
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
render() {
|
|
1164
|
+
var attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
1165
|
+
var images = [];
|
|
1166
|
+
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
1167
|
+
util/* default.each */.Z.each(attachments, (att, i) => {
|
|
1168
|
+
if (!att) return;
|
|
1169
|
+
if (!util/* default.includes */.Z.includes(att.mimetype, 'image')) return;
|
|
1170
|
+
if (!att.url) return;
|
|
1171
|
+
var uri = att.url;
|
|
1172
|
+
|
|
1173
|
+
if (!uri.startsWith('https://') && !uri.startsWith('http://') && !uri.startsWith('content://') && !uri.startsWith('data:')) {
|
|
1174
|
+
att.url = this.props.store.FileURL + uri;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
images.push(att);
|
|
1178
|
+
});
|
|
1179
|
+
if (images.length === 0) return null;
|
|
1180
|
+
var $images = util/* default.map */.Z.map(images, (image, index) => (0,preact_module.h)("div", {
|
|
1181
|
+
class: `image-attachment image-attachment--${byType}`
|
|
1182
|
+
}, (0,preact_module.h)("a", {
|
|
1183
|
+
href: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
1184
|
+
target: "_blank"
|
|
1185
|
+
}, (0,preact_module.h)("img", {
|
|
1186
|
+
alt: true,
|
|
1187
|
+
class: "image-attachment__img",
|
|
1188
|
+
src: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
1189
|
+
onload: e => this.props.onLoad && this.props.onLoad()
|
|
1190
|
+
}))));
|
|
1191
|
+
|
|
1192
|
+
if (byType === 'agent') {
|
|
1193
|
+
return (0,preact_module.h)("div", {
|
|
1194
|
+
class: "message-agent"
|
|
1195
|
+
}, $images);
|
|
1196
|
+
} else {
|
|
1197
|
+
return (0,preact_module.h)("div", {
|
|
1198
|
+
class: "message-user"
|
|
1199
|
+
}, $images);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
}
|
|
1204
|
+
;// CONCATENATED MODULE: ./src/chatbox/AudioAttachments.js
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
class AudioAttachments extends common/* Com */.M {
|
|
1209
|
+
constructor(props) {
|
|
1210
|
+
super(props);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
render() {
|
|
1214
|
+
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
1215
|
+
var attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
1216
|
+
var audios = [];
|
|
1217
|
+
util/* default.each */.Z.each(attachments, (att, i) => {
|
|
1218
|
+
if (!att) return;
|
|
1219
|
+
if (util/* default.includes */.Z.includes(att.mimetype, 'audio')) audios.push(att);
|
|
1220
|
+
});
|
|
1221
|
+
if (audios.length === 0) return null;
|
|
1222
|
+
var $audios = util/* default.map */.Z.map(audios, (audio, index) => {
|
|
1223
|
+
return (0,preact_module.h)("div", {
|
|
1224
|
+
key: index,
|
|
1225
|
+
class: `audio-attachment audio-attachment--${byType}`
|
|
1226
|
+
}, (0,preact_module.h)("audio", {
|
|
1227
|
+
class: "audio-attachment__audio",
|
|
1228
|
+
controls: true
|
|
1229
|
+
}, (0,preact_module.h)("source", {
|
|
1230
|
+
src: this.props.store.replaceFileUrl(audio.url),
|
|
1231
|
+
type: audio.mimetype
|
|
1232
|
+
})));
|
|
1233
|
+
});
|
|
1234
|
+
return (0,preact_module.h)("div", {
|
|
1235
|
+
class: `message-${byType}`
|
|
1236
|
+
}, $audios);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
}
|
|
1240
|
+
;// CONCATENATED MODULE: ./src/chatbox/FileAttachments.js
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
class FileAttachments extends common/* Com */.M {
|
|
1245
|
+
render() {
|
|
1246
|
+
var byType = util/* default.get */.Z.get(this.props.ev, 'by.type', 'agent');
|
|
1247
|
+
var attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
1248
|
+
var files = [];
|
|
1249
|
+
util/* default.each */.Z.each(attachments, att => {
|
|
1250
|
+
if (!att) return;
|
|
1251
|
+
if (!att.url && !att._file) return;
|
|
1252
|
+
|
|
1253
|
+
if (!util/* default.includes */.Z.includes(att.mimetype, 'video') && !util/* default.includes */.Z.includes(att.mimetype, 'audio') && !util/* default.includes */.Z.includes(att.mimetype, 'image') && att.type !== 'button' && att.type !== 'quick_replies' && att.type !== 'form' && att.type !== 'form_submit') {
|
|
1254
|
+
files.push(att);
|
|
1255
|
+
}
|
|
1256
|
+
});
|
|
1257
|
+
if (files.length === 0) return null;
|
|
1258
|
+
var $files = util/* default.map */.Z.map(files, (file, index) => {
|
|
1259
|
+
return (0,preact_module.h)("div", {
|
|
1260
|
+
key: index,
|
|
1261
|
+
class: `file-attachment file-attachment--${byType}`
|
|
1262
|
+
}, (0,preact_module.h)("a", {
|
|
1263
|
+
class: "file-attachment--link",
|
|
1264
|
+
href: this.props.store.replaceFileUrl(file.url),
|
|
1265
|
+
target: "_blank"
|
|
1266
|
+
}, (0,preact_module.h)("span", {
|
|
1267
|
+
class: "file-attachment--download mr-2"
|
|
1268
|
+
}), (0,preact_module.h)("span", {
|
|
1269
|
+
class: "file-attachment--filename"
|
|
1270
|
+
}, file.name)));
|
|
1271
|
+
});
|
|
1272
|
+
return (0,preact_module.h)("div", {
|
|
1273
|
+
class: `message-${byType}`
|
|
1274
|
+
}, $files);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
}
|
|
1278
|
+
;// CONCATENATED MODULE: ./src/chatbox/Buttons.js
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
|
|
1282
|
+
class Buttons extends common/* Com */.M {
|
|
1283
|
+
constructor(props) {
|
|
1284
|
+
super(props);
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
render() {
|
|
1288
|
+
if (util/* default.size */.Z.size(this.props.buttons) === 0) return null;
|
|
1289
|
+
var $buttons = util/* default.map */.Z.map(this.props.buttons, (button, index) => {
|
|
1290
|
+
if (button.type === 'call_button') {
|
|
1291
|
+
return (0,preact_module.h)("a", {
|
|
1292
|
+
class: "url-button-attachment",
|
|
1293
|
+
href: 'tel:' + button.phone_number,
|
|
1294
|
+
key: index,
|
|
1295
|
+
title: button.title
|
|
1296
|
+
}, button.title);
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
if (button.type === 'url_button') {
|
|
1300
|
+
return (0,preact_module.h)("a", {
|
|
1301
|
+
class: "url-button-attachment",
|
|
1302
|
+
href: button.url,
|
|
1303
|
+
target: "_blank",
|
|
1304
|
+
key: index,
|
|
1305
|
+
title: button.title
|
|
1306
|
+
}, button.title || button.url);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
if (button.type === 'postback_button') {
|
|
1310
|
+
return (0,preact_module.h)("a", {
|
|
1311
|
+
class: "url-button-attachment",
|
|
1312
|
+
href: "javascript:;",
|
|
1313
|
+
onClick: _ => this.props.onSelect(button)
|
|
1314
|
+
}, button.title);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
if (button.type === 'widget_ask_desktop_notify_button') return null;
|
|
1318
|
+
if (button.type === 'widget_ask_contact_info_button') return null;
|
|
1319
|
+
return null;
|
|
1320
|
+
});
|
|
1321
|
+
return (0,preact_module.h)("div", {
|
|
1322
|
+
class: "button-attachments"
|
|
1323
|
+
}, $buttons);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
}
|
|
1327
|
+
;// CONCATENATED MODULE: ./src/chatbox/ButtonAttachments.js
|
|
1328
|
+
|
|
1329
|
+
|
|
1330
|
+
|
|
1331
|
+
|
|
1332
|
+
class ButtonAttachments extends common/* Com */.M {
|
|
1333
|
+
constructor(props) {
|
|
1334
|
+
super(props);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
render() {
|
|
1338
|
+
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
1339
|
+
if (byType === 'user') return null;
|
|
1340
|
+
let buttons = [];
|
|
1341
|
+
let attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
1342
|
+
util/* default.each */.Z.each(attachments, (att, i) => {
|
|
1343
|
+
if (!att || util/* default.get */.Z.get(att, 'type') !== 'button') return;
|
|
1344
|
+
util/* default.each */.Z.each(util/* default.get */.Z.get(att, 'buttons') || [], btn => buttons.push(btn));
|
|
1345
|
+
});
|
|
1346
|
+
return (0,preact_module.h)(Buttons, {
|
|
1347
|
+
store: this.props.store,
|
|
1348
|
+
buttons: buttons
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
}
|
|
1353
|
+
;// CONCATENATED MODULE: ./src/chatbox/QuickReplies.js
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
class QuickReplies extends common/* Com */.M {
|
|
1358
|
+
constructor(props) {
|
|
1359
|
+
super(props);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
render() {
|
|
1363
|
+
if (util/* default.get */.Z.get(this.props.ev, 'by.type') === 'user') return null;
|
|
1364
|
+
let quickreplies = [];
|
|
1365
|
+
util/* default.map */.Z.map(util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []), att => {
|
|
1366
|
+
if (!att) return;
|
|
1367
|
+
|
|
1368
|
+
if (att.type === 'quick_replies') {
|
|
1369
|
+
quickreplies = util/* default.get */.Z.get(att, 'quick_replies', []);
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
quickreplies = util/* default.filter */.Z.filter(quickreplies, r => r.title);
|
|
1373
|
+
if (quickreplies.length === 0) return null;
|
|
1374
|
+
let cid = util/* default.convoOfEv */.Z.convoOfEv(this.props.ev);
|
|
1375
|
+
let convo = this.props.store.matchConvo(cid);
|
|
1376
|
+
if (util/* default.get */.Z.get(convo, 'state') === 'ended') return null;
|
|
1377
|
+
let events = util/* default.map */.Z.map(this.props.store.listEvents(cid));
|
|
1378
|
+
events = util/* default.orderBy */.Z.orderBy(events, 'created', 'asc').filter(ev => ev.type === 'message_sent');
|
|
1379
|
+
let evindex = 0;
|
|
1380
|
+
|
|
1381
|
+
for (var i = 0; i < events.length; i++) {
|
|
1382
|
+
if (events[i].id === this.props.ev.id) {
|
|
1383
|
+
evindex = i;
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
for (var i = evindex + 1; i < events.length; i++) {
|
|
1389
|
+
if (util/* default.get */.Z.get(events[i], 'by.type') === 'user') return null;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
let $replies = util/* default.map */.Z.map(quickreplies, r => (0,preact_module.h)("div", {
|
|
1393
|
+
class: "message_quick_reply",
|
|
1394
|
+
onClick: e => this.props.onSelect(r)
|
|
1395
|
+
}, r.title));
|
|
1396
|
+
return (0,preact_module.h)("div", {
|
|
1397
|
+
class: "message_quick_replies"
|
|
1398
|
+
}, $replies);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
}
|
|
1402
|
+
;// CONCATENATED MODULE: ./src/chatbox/ListField.js
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
|
|
1406
|
+
class ListField extends common/* Com */.M {
|
|
1407
|
+
constructor(props) {
|
|
1408
|
+
super(props);
|
|
1409
|
+
this.setState({
|
|
1410
|
+
search: '',
|
|
1411
|
+
isShow: false
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
render() {
|
|
1416
|
+
let fields = util/* default.filter */.Z.filter(this.props.items, item => {
|
|
1417
|
+
let search = this.state.search.toLowerCase();
|
|
1418
|
+
let name = item || '';
|
|
1419
|
+
return name.toLowerCase().indexOf(search) > -1;
|
|
1420
|
+
});
|
|
1421
|
+
let $fields = util/* default.map */.Z.map(fields, field => {
|
|
1422
|
+
return (0,preact_module.h)("li", {
|
|
1423
|
+
class: "custom-select--item-options",
|
|
1424
|
+
onClick: () => this.add(field)
|
|
1425
|
+
}, field);
|
|
1426
|
+
});
|
|
1427
|
+
let $selected = util/* default.map */.Z.map(this.props.selected, (item, i) => {
|
|
1428
|
+
return (0,preact_module.h)("div", {
|
|
1429
|
+
class: "custom-select--selected-item",
|
|
1430
|
+
onClick: e => this.remove(e, i)
|
|
1431
|
+
}, item, (0,preact_module.h)("i", {
|
|
1432
|
+
class: "icn-delete delete-tag"
|
|
1433
|
+
}));
|
|
1434
|
+
});
|
|
1435
|
+
let $dropdown = (0,preact_module.h)("div", {
|
|
1436
|
+
class: "custom-select--wrap-options"
|
|
1437
|
+
}, (0,preact_module.h)("input", {
|
|
1438
|
+
onClick: e => {
|
|
1439
|
+
e.preventDefault();
|
|
1440
|
+
e.stopPropagation();
|
|
1441
|
+
this.setState({
|
|
1442
|
+
isShow: true
|
|
1443
|
+
});
|
|
1444
|
+
},
|
|
1445
|
+
type: "text",
|
|
1446
|
+
onInput: e => this.setState({
|
|
1447
|
+
search: e.target.value
|
|
1448
|
+
}),
|
|
1449
|
+
value: this.state.search,
|
|
1450
|
+
placeholder: "T\xECm ki\u1EBFm",
|
|
1451
|
+
class: "custom-select--input-search"
|
|
1452
|
+
}), (0,preact_module.h)("ul", {
|
|
1453
|
+
class: "custom-select--items-options"
|
|
1454
|
+
}, $fields));
|
|
1455
|
+
|
|
1456
|
+
if (!this.state.isShow) {
|
|
1457
|
+
$dropdown = null;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
return (0,preact_module.h)("div", {
|
|
1461
|
+
class: "form-control custom-select"
|
|
1462
|
+
}, (0,preact_module.h)(common/* Clickaway */.u, {
|
|
1463
|
+
onClickaway: e => this.clickaway()
|
|
1464
|
+
}, (0,preact_module.h)("div", {
|
|
1465
|
+
class: "custom-select--wrap-selected",
|
|
1466
|
+
onClick: () => this.setState({
|
|
1467
|
+
isShow: !this.state.isShow
|
|
1468
|
+
})
|
|
1469
|
+
}, (0,preact_module.h)("div", {
|
|
1470
|
+
class: "custom-select--selected-items"
|
|
1471
|
+
}, $selected), $dropdown, (0,preact_module.h)("div", {
|
|
1472
|
+
class: "custom-select--icon-dropdown"
|
|
1473
|
+
}, (0,preact_module.h)("svg", {
|
|
1474
|
+
width: "24",
|
|
1475
|
+
height: "24",
|
|
1476
|
+
viewBox: "0 0 24 24",
|
|
1477
|
+
fill: "none",
|
|
1478
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1479
|
+
}, (0,preact_module.h)("g", {
|
|
1480
|
+
opacity: "0.6"
|
|
1481
|
+
}, (0,preact_module.h)("path", {
|
|
1482
|
+
d: "M7 9.5L12 14.5L17 9.5H7Z",
|
|
1483
|
+
fill: "black"
|
|
1484
|
+
})))))));
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
clickaway() {
|
|
1488
|
+
this.setState({
|
|
1489
|
+
isShow: false
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
add(field) {
|
|
1494
|
+
this.props.onAddItem && this.props.onAddItem(field);
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
remove(e, index) {
|
|
1498
|
+
e.preventDefault();
|
|
1499
|
+
e.stopPropagation();
|
|
1500
|
+
this.props.onRemoveItem && this.props.onRemoveItem(index);
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
}
|
|
1504
|
+
;// CONCATENATED MODULE: ./src/chatbox/FormAttachment.js
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
class FormAttachment extends common/* Com */.M {
|
|
1510
|
+
constructor(props) {
|
|
1511
|
+
super(props);
|
|
1512
|
+
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
1513
|
+
let user = this.props.store.matchUser();
|
|
1514
|
+
let fields = util/* default.get */.Z.get(this.props.form, 'fields') || [];
|
|
1515
|
+
let formData = util/* default.map */.Z.map(fields, field => {
|
|
1516
|
+
let is_required = field.is_required || false;
|
|
1517
|
+
var state = util/* default.parseJSON */.Z.parseJSON(field.state) || {};
|
|
1518
|
+
if (!is_required) is_required = state.require || false;
|
|
1519
|
+
var userattr = util/* default.getUserAttr */.Z.getUserAttr(user, field.name, state.type || 'text');
|
|
1520
|
+
return {
|
|
1521
|
+
name: field.name,
|
|
1522
|
+
items: field.items,
|
|
1523
|
+
value: util/* default.parseJSON */.Z.parseJSON(field.answer) || util/* default.parseJSON */.Z.parseJSON(field.default_answer) || userattr,
|
|
1524
|
+
is_required,
|
|
1525
|
+
label: field.title,
|
|
1526
|
+
type: field.input_type
|
|
1527
|
+
};
|
|
1528
|
+
});
|
|
1529
|
+
this.setState({
|
|
1530
|
+
formData
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
isSummited() {
|
|
1535
|
+
let found = util/* default.find */.Z.find(this.state.formData, field => !!field.answered);
|
|
1536
|
+
if (found) return true;
|
|
1537
|
+
let convo = this.props.store.matchConvo(util/* default.convoOfEv */.Z.convoOfEv(this.props.ev));
|
|
1538
|
+
return convo.state === 'ended';
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
render() {
|
|
1542
|
+
if (util/* default.size */.Z.size(this.state.formData) === 0) return null;
|
|
1543
|
+
let $fields = this.renderFields();
|
|
1544
|
+
let $submitbutton = null;
|
|
1545
|
+
|
|
1546
|
+
if (!this.isSummited()) {
|
|
1547
|
+
$submitbutton = (0,preact_module.h)("div", {
|
|
1548
|
+
class: "mt-2"
|
|
1549
|
+
}, (0,preact_module.h)("button", {
|
|
1550
|
+
onClick: _ => this.submit(),
|
|
1551
|
+
type: "button",
|
|
1552
|
+
class: "form-attachment--submit-btn"
|
|
1553
|
+
}, this.props.t('btn_submit_form_attachment')));
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
return (0,preact_module.h)("div", {
|
|
1557
|
+
class: "form-attachment",
|
|
1558
|
+
onClick: e => e.stopPropagation()
|
|
1559
|
+
}, this.props.t(this.props.form.title) || this.props.t('capture_lead_title'), $fields, $submitbutton);
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
focus() {
|
|
1563
|
+
if (this.props.store.isPreview) return;
|
|
1564
|
+
if (util/* default.size */.Z.size(this.state.formData) === 0) return;
|
|
1565
|
+
let $field;
|
|
1566
|
+
|
|
1567
|
+
if (this.isFormFilled()) {
|
|
1568
|
+
var keys = Object.keys(this.state.formData);
|
|
1569
|
+
var lastkey = keys[util/* default.size */.Z.size(keys) - 1];
|
|
1570
|
+
var lastfield = this.state.formData[lastkey];
|
|
1571
|
+
$field = this['field.' + encode(lastfield.name)];
|
|
1572
|
+
} else {
|
|
1573
|
+
var firstunfilledfield = this.firstUnfilledField();
|
|
1574
|
+
if (!firstunfilledfield) return;
|
|
1575
|
+
$field = this['field.' + encode(firstunfilledfield.name)];
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
if ($field) $field.focus();
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
firstUnfilledField() {
|
|
1582
|
+
return util/* default.find */.Z.find(this.state.formData, field => field.value == null || field.value === '');
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
isFormFilled() {
|
|
1586
|
+
return !util/* default.find */.Z.find(this.state.formData, field => field.value == null || field.value === '');
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
onInputChange(index, val) {
|
|
1590
|
+
let formData = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
1591
|
+
formData[index].value = val;
|
|
1592
|
+
this.setState({
|
|
1593
|
+
formData
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
onListAddItem(index, val) {
|
|
1598
|
+
let formData = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
1599
|
+
let field = formData[index];
|
|
1600
|
+
field.value = field.value || [];
|
|
1601
|
+
field.value.push(val);
|
|
1602
|
+
this.setState({
|
|
1603
|
+
formData
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
onListRemoveItem(index, vindex) {
|
|
1608
|
+
let formData = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
1609
|
+
let field = formData[index];
|
|
1610
|
+
field.value = field.value || [];
|
|
1611
|
+
field.value.splice(vindex, 1);
|
|
1612
|
+
this.setState({
|
|
1613
|
+
formData
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
renderFields() {
|
|
1618
|
+
if (util/* default.size */.Z.size(this.state.formData) === 0) return null;
|
|
1619
|
+
let $fields = null;
|
|
1620
|
+
$fields = util/* default.map */.Z.map(this.state.formData, (field, index) => {
|
|
1621
|
+
let $field = null;
|
|
1622
|
+
var errclass = field.error ? 'input--error' : '';
|
|
1623
|
+
|
|
1624
|
+
if (field.type === 'text') {
|
|
1625
|
+
if (this.isSummited()) {
|
|
1626
|
+
$field = (0,preact_module.h)("div", {
|
|
1627
|
+
class: "form-control--container"
|
|
1628
|
+
}, (0,preact_module.h)("input", {
|
|
1629
|
+
disabled: true,
|
|
1630
|
+
ref: ref => {
|
|
1631
|
+
this['field.' + encode(field.name)] = ref;
|
|
1632
|
+
},
|
|
1633
|
+
value: field.value,
|
|
1634
|
+
onInput: e => this.onInputChange(index, e.target.value),
|
|
1635
|
+
class: `form-control ${errclass}`,
|
|
1636
|
+
type: "text"
|
|
1637
|
+
}), (0,preact_module.h)("i", {
|
|
1638
|
+
class: "form-control--check"
|
|
1639
|
+
}));
|
|
1640
|
+
} else {
|
|
1641
|
+
$field = (0,preact_module.h)("input", {
|
|
1642
|
+
ref: ref => {
|
|
1643
|
+
this['field.' + encode(field.name)] = ref;
|
|
1644
|
+
},
|
|
1645
|
+
value: field.value,
|
|
1646
|
+
onInput: e => this.onInputChange(index, e.target.value),
|
|
1647
|
+
class: `form-control ${errclass}`,
|
|
1648
|
+
type: "text"
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
} else if (field.type === 'number') {
|
|
1652
|
+
if (this.isSummited()) {
|
|
1653
|
+
$field = (0,preact_module.h)("div", {
|
|
1654
|
+
class: "form-control--container"
|
|
1655
|
+
}, (0,preact_module.h)("input", {
|
|
1656
|
+
disabled: true,
|
|
1657
|
+
ref: ref => {
|
|
1658
|
+
this['field.' + encode(field.name)] = ref;
|
|
1659
|
+
},
|
|
1660
|
+
value: field.value,
|
|
1661
|
+
onInput: e => this.onInputChange(index, e.target.value),
|
|
1662
|
+
class: `form-control ${errclass}`,
|
|
1663
|
+
type: "number"
|
|
1664
|
+
}), (0,preact_module.h)("i", {
|
|
1665
|
+
class: "form-control--check"
|
|
1666
|
+
}));
|
|
1667
|
+
} else {
|
|
1668
|
+
$field = (0,preact_module.h)("input", {
|
|
1669
|
+
ref: ref => {
|
|
1670
|
+
this['field.' + encode(field.name)] = ref;
|
|
1671
|
+
},
|
|
1672
|
+
value: field.value,
|
|
1673
|
+
onInput: e => this.onInputChange(index, e.target.value),
|
|
1674
|
+
class: `form-control ${errclass}`,
|
|
1675
|
+
type: "number"
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
} else if (field.type === 'boolean') {
|
|
1679
|
+
$field = (0,preact_module.h)("div", {
|
|
1680
|
+
class: "checkbox"
|
|
1681
|
+
}, (0,preact_module.h)("input", {
|
|
1682
|
+
ref: ref => {
|
|
1683
|
+
this['field.' + encode(field.name)] = ref;
|
|
1684
|
+
},
|
|
1685
|
+
type: "checkbox",
|
|
1686
|
+
id: 'checkbox.' + this.props.ev.id + '.' + field.name,
|
|
1687
|
+
onChange: e => this.onInputChange(index, ev.target.checked),
|
|
1688
|
+
checked: field.value
|
|
1689
|
+
}), (0,preact_module.h)("label", {
|
|
1690
|
+
class: "checkbox--label",
|
|
1691
|
+
for: 'checkbox.' + this.props.ev.id + '.' + field.name
|
|
1692
|
+
}, field.label), (0,preact_module.h)("div", {
|
|
1693
|
+
class: "checkbox--check"
|
|
1694
|
+
}, (0,preact_module.h)("div", null)));
|
|
1695
|
+
} else if (field.type === 'list') {
|
|
1696
|
+
let selected = field.value || [];
|
|
1697
|
+
let items = util/* default.filter */.Z.filter(util/* default.get */.Z.get(field, 'items', []), item => !selected.includes(item));
|
|
1698
|
+
$field = (0,preact_module.h)(ListField, {
|
|
1699
|
+
selected: selected,
|
|
1700
|
+
items: items,
|
|
1701
|
+
onAddItem: e => this.onListAddItem(index, e),
|
|
1702
|
+
onRemoveItem: item => this.onListRemoveItem(index, item)
|
|
1703
|
+
});
|
|
1704
|
+
} else if (field.type === 'datetime') {
|
|
1705
|
+
$field = (0,preact_module.h)("input", {
|
|
1706
|
+
ref: ref => {
|
|
1707
|
+
this['field.' + encode(field.name)] = ref;
|
|
1708
|
+
},
|
|
1709
|
+
value: field.value,
|
|
1710
|
+
onInput: e => this.onInputChange(index, e.target.value),
|
|
1711
|
+
class: `form-control ${errclass}`,
|
|
1712
|
+
type: "date"
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
let label = field.label;
|
|
1717
|
+
|
|
1718
|
+
if (field.name === 'fullname') {
|
|
1719
|
+
label = this.props.t('fullname');
|
|
1720
|
+
} else if (field.name === 'emails') {
|
|
1721
|
+
label = this.props.t('email');
|
|
1722
|
+
} else if (field.name === 'phones') {
|
|
1723
|
+
label = this.props.t('phones');
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
return (0,preact_module.h)("div", null, (0,preact_module.h)("p", {
|
|
1727
|
+
class: "label mt-3"
|
|
1728
|
+
}, label, field.is_required ? (0,preact_module.h)("span", {
|
|
1729
|
+
class: "ml-1 red"
|
|
1730
|
+
}, "*") : ''), field.error ? (0,preact_module.h)("div", {
|
|
1731
|
+
class: "form-control--valid-input--error"
|
|
1732
|
+
}, field.error) : '', $field);
|
|
1733
|
+
});
|
|
1734
|
+
return (0,preact_module.h)("div", null, $fields);
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
async submit() {
|
|
1738
|
+
var hasError = false;
|
|
1739
|
+
util/* default.map */.Z.map(this.state.formData, field => {
|
|
1740
|
+
if (field.is_required && (field.value === undefined || field.value === '' || util/* default.size */.Z.size(field.value) === 0 && Array.isArray(field.value))) {
|
|
1741
|
+
field.error = this.props.t('error_empty');
|
|
1742
|
+
hasError = true;
|
|
1743
|
+
} else {
|
|
1744
|
+
field.error = '';
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
if (field.name === 'emails' && field.value) {
|
|
1748
|
+
if (!util/* default.isEmail */.Z.isEmail(field.value)) {
|
|
1749
|
+
field.error = this.props.t('error_email_invalid');
|
|
1750
|
+
hasError = true;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
this.forceUpdate();
|
|
1755
|
+
if (hasError) return;
|
|
1756
|
+
let user = {};
|
|
1757
|
+
let formData = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
1758
|
+
util/* default.map */.Z.map(formData, field => {
|
|
1759
|
+
var attr = {
|
|
1760
|
+
key: field.name
|
|
1761
|
+
};
|
|
1762
|
+
field.answered = new util/* default.Date */.Z.Date().getTime();
|
|
1763
|
+
|
|
1764
|
+
if (field.type === 'number') {
|
|
1765
|
+
attr.number = parseInt(field.value);
|
|
1766
|
+
field.answer = util/* default.stringify */.Z.stringify(attr.number);
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
if (field.type === 'datetime') {
|
|
1770
|
+
attr.datetime = new util/* default.Date */.Z.Date(field.value).toISOString();
|
|
1771
|
+
field.answer = util/* default.stringify */.Z.stringify(attr.datetime);
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
if (field.type === 'list') {
|
|
1775
|
+
attr.list = field.value;
|
|
1776
|
+
field.answer = util/* default.stringify */.Z.stringify(attr.list);
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
if (field.type === 'text' || field.type === 'boolean') {
|
|
1780
|
+
attr[field.type] = field.value;
|
|
1781
|
+
field.answer = util/* default.stringify */.Z.stringify(field.value);
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
util/* default.setUserAttr */.Z.setUserAttr(user, attr);
|
|
1785
|
+
});
|
|
1786
|
+
util/* default.map */.Z.map(formData, field => {
|
|
1787
|
+
let ffield = util/* default.find */.Z.find(this.props.form.fields, ffield => ffield.name === field.name);
|
|
1788
|
+
if (!ffield) return;
|
|
1789
|
+
ffield.answered = field.answered;
|
|
1790
|
+
});
|
|
1791
|
+
this.setState({
|
|
1792
|
+
formData
|
|
1793
|
+
});
|
|
1794
|
+
this.props.store.setUser(user);
|
|
1795
|
+
let message = {
|
|
1796
|
+
attachments: [{
|
|
1797
|
+
type: 'form_submit',
|
|
1798
|
+
form_submit: {
|
|
1799
|
+
state: '{"user_id":"' + this.props.store.matchUser().id + '"}',
|
|
1800
|
+
form_message_id: util/* default.get */.Z.get(this.props.ev, 'id'),
|
|
1801
|
+
fields: formData
|
|
1802
|
+
}
|
|
1803
|
+
}]
|
|
1804
|
+
};
|
|
1805
|
+
let cid = util/* default.convoOfEv */.Z.convoOfEv(this.props.ev);
|
|
1806
|
+
this.props.store.sendConvoEvent(cid, 'message_sent', {
|
|
1807
|
+
message
|
|
1808
|
+
});
|
|
1809
|
+
this.props.onSubmit && this.props.onSubmit();
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
function encode(key) {
|
|
1815
|
+
return btoa(key).split('=').join('');
|
|
1816
|
+
}
|
|
1817
|
+
;// CONCATENATED MODULE: ./src/chatbox/FormAttachments.js
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
class FormAttachments extends common/* Com */.M {
|
|
1823
|
+
constructor(props) {
|
|
1824
|
+
super(props);
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
render() {
|
|
1828
|
+
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
1829
|
+
if (byType === 'user') return;
|
|
1830
|
+
let forms = [];
|
|
1831
|
+
let attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments') || [];
|
|
1832
|
+
util/* default.each */.Z.each(attachments, att => {
|
|
1833
|
+
if (!att) return;
|
|
1834
|
+
if (att.type !== 'form' && att.type !== 'ask_info_form') return;
|
|
1835
|
+
att.form._type = att.type;
|
|
1836
|
+
forms.push(att.form);
|
|
1837
|
+
});
|
|
1838
|
+
let $forms = util/* default.map */.Z.map(forms, (form, formIndex) => {
|
|
1839
|
+
return (0,preact_module.h)(FormAttachment, {
|
|
1840
|
+
store: this.props.store,
|
|
1841
|
+
onSubmit: this.props.onSubmit,
|
|
1842
|
+
ref: ref => {
|
|
1843
|
+
this['form.' + formIndex] = ref;
|
|
1844
|
+
},
|
|
1845
|
+
key: formIndex,
|
|
1846
|
+
form: form,
|
|
1847
|
+
ev: this.props.ev,
|
|
1848
|
+
t: this.props.t
|
|
1849
|
+
});
|
|
1850
|
+
});
|
|
1851
|
+
if ($forms.length === 0) return null;
|
|
1852
|
+
return (0,preact_module.h)("div", {
|
|
1853
|
+
class: "message-agent"
|
|
1854
|
+
}, $forms);
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
focus() {
|
|
1858
|
+
var $form = this['form.0'];
|
|
1859
|
+
if ($form) $form.focus();
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
}
|
|
1863
|
+
;// CONCATENATED MODULE: ./src/chatbox/FormSubmitAttachments.js
|
|
1864
|
+
|
|
1865
|
+
|
|
1866
|
+
|
|
1867
|
+
class FormSubmitAttachments extends common/* Com */.M {
|
|
1868
|
+
constructor(props) {
|
|
1869
|
+
super(props);
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
render() {
|
|
1873
|
+
return null;
|
|
1874
|
+
let submits = [];
|
|
1875
|
+
let attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments') || [];
|
|
1876
|
+
util/* default.each */.Z.each(attachments, att => {
|
|
1877
|
+
if (!att) return;
|
|
1878
|
+
if (att.type !== 'form_submit') return;
|
|
1879
|
+
if (!att.form_submit) return;
|
|
1880
|
+
submits.push(att.form_submit);
|
|
1881
|
+
});
|
|
1882
|
+
let $submits = util/* default.map */.Z.map(submits, (submit, index) => (0,preact_module.h)("div", {
|
|
1883
|
+
class: "info-message"
|
|
1884
|
+
}, (0,preact_module.h)("span", null, this.props.tt('prechat_form_thanks'))));
|
|
1885
|
+
return (0,preact_module.h)("div", null, $submits);
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
}
|
|
1889
|
+
;// CONCATENATED MODULE: ./src/chatbox/touchscroll.js
|
|
1890
|
+
function bind(el) {
|
|
1891
|
+
if (!el) return;
|
|
1892
|
+
el.removeEventListener('touchstart', el.md, 0);
|
|
1893
|
+
window.removeEventListener('touchend', el.mu, 0);
|
|
1894
|
+
window.removeEventListener('touchmove', el.mm, 0);
|
|
1895
|
+
var lastClientX, pushed;
|
|
1896
|
+
|
|
1897
|
+
el.md = function (e) {
|
|
1898
|
+
let touch = getFirstTouch(e);
|
|
1899
|
+
|
|
1900
|
+
if (!el.hasAttribute('nochilddrag') || !document.elementFromPoint(touch.pageX, touch.pageY)) {
|
|
1901
|
+
pushed = 1;
|
|
1902
|
+
lastClientX = touch.clientX;
|
|
1903
|
+
e.preventDefault();
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1906
|
+
|
|
1907
|
+
el.mu = () => {
|
|
1908
|
+
pushed = 0;
|
|
1909
|
+
};
|
|
1910
|
+
|
|
1911
|
+
el.mm = function (e) {
|
|
1912
|
+
if (!pushed) return;
|
|
1913
|
+
let touch = getFirstTouch(e);
|
|
1914
|
+
el.scrollLeft -= -lastClientX + touch.clientX;
|
|
1915
|
+
lastClientX = touch.clientX;
|
|
1916
|
+
};
|
|
1917
|
+
|
|
1918
|
+
el.addEventListener('touchstart', el.md, {
|
|
1919
|
+
passive: true
|
|
1920
|
+
});
|
|
1921
|
+
window.addEventListener('touchend', el.mu, {
|
|
1922
|
+
passive: true
|
|
1923
|
+
});
|
|
1924
|
+
window.addEventListener('touchmove', el.mm, {
|
|
1925
|
+
passive: true
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
function getFirstTouch(ev) {
|
|
1930
|
+
if (!ev.touches) return {};
|
|
1931
|
+
if (!ev.touches.length) return {};
|
|
1932
|
+
return ev.touches[0];
|
|
1933
|
+
}
|
|
1934
|
+
;// CONCATENATED MODULE: ./src/chatbox/GenericTemplateAttachments.js
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
|
|
1938
|
+
|
|
1939
|
+
|
|
1940
|
+
class GenericTemplateAttachments extends common/* Com */.M {
|
|
1941
|
+
constructor(props) {
|
|
1942
|
+
super(props);
|
|
1943
|
+
this.state = {
|
|
1944
|
+
focusing: 0
|
|
1945
|
+
};
|
|
1946
|
+
this.galleryRef = (0,preact_module/* createRef */.Vf)();
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
componentDidMount() {
|
|
1950
|
+
this.bindDrag();
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
focus(eleindex) {
|
|
1954
|
+
this.setState({
|
|
1955
|
+
focusing: eleindex
|
|
1956
|
+
});
|
|
1957
|
+
this.galleryRef.current.scrollLeft = 190 * eleindex - 20;
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
render() {
|
|
1961
|
+
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
1962
|
+
if (byType === 'user') return null;
|
|
1963
|
+
let attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
1964
|
+
let generics = util/* default.filter */.Z.filter(attachments, att => util/* default.get */.Z.get(att, 'type') === 'generic');
|
|
1965
|
+
if (generics.length === 0) return null;
|
|
1966
|
+
var $generics = util/* default.map */.Z.map(generics, (gen, index) => {
|
|
1967
|
+
var $eles = util/* default.map */.Z.map(gen.elements, ele => {
|
|
1968
|
+
let $title = ele.title ? (0,preact_module.h)("div", {
|
|
1969
|
+
class: "generic-attachment--element-title"
|
|
1970
|
+
}, ele.title) : null;
|
|
1971
|
+
let $subtitle = ele.subtitle ? (0,preact_module.h)("div", {
|
|
1972
|
+
class: "generic-attachment--element-subtitle"
|
|
1973
|
+
}, ele.subtitle) : null;
|
|
1974
|
+
return (0,preact_module.h)("div", {
|
|
1975
|
+
class: "generic-attachment--element swiper-slide"
|
|
1976
|
+
}, (0,preact_module.h)("div", null, (0,preact_module.h)("img", {
|
|
1977
|
+
alt: "generic attachment element",
|
|
1978
|
+
class: "generic-attachment--element-img",
|
|
1979
|
+
src: this.props.store.replaceFileUrl(ele.image_url)
|
|
1980
|
+
})), $title, $subtitle, (0,preact_module.h)(Buttons, {
|
|
1981
|
+
buttons: ele.buttons,
|
|
1982
|
+
onSelect: button => this.props.onSelect(button)
|
|
1983
|
+
}));
|
|
1984
|
+
});
|
|
1985
|
+
let elements = util/* default.get */.Z.get(attachments, '0.elements', []);
|
|
1986
|
+
let leftNavigatorCls = 'generic-attachment-navigator generic-attachment-navigator--left';
|
|
1987
|
+
let rightNavigatorCls = 'generic-attachment-navigator generic-attachment-navigator--right';
|
|
1988
|
+
if (this.state.focusing === 0) leftNavigatorCls += ' generic-attachment-navigator--disabled';
|
|
1989
|
+
if (this.state.focusing === elements.length - 1) rightNavigatorCls += ' generic-attachment-navigator--disabled';
|
|
1990
|
+
return (0,preact_module.h)("div", {
|
|
1991
|
+
class: "generic-attachment-container"
|
|
1992
|
+
}, (0,preact_module.h)("div", {
|
|
1993
|
+
class: "generic-attachment",
|
|
1994
|
+
ref: this.galleryRef
|
|
1995
|
+
}, $eles), !this.props.store.isMobile() && (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
|
|
1996
|
+
class: leftNavigatorCls,
|
|
1997
|
+
onClick: _ => this.focus(this.state.focusing - 1)
|
|
1998
|
+
}, (0,preact_module.h)("span", {
|
|
1999
|
+
class: "generic-attachment-navigator-icon"
|
|
2000
|
+
}, "\u2039")), (0,preact_module.h)("div", {
|
|
2001
|
+
class: rightNavigatorCls,
|
|
2002
|
+
onClick: _ => this.focus(this.state.focusing + 1)
|
|
2003
|
+
}, (0,preact_module.h)("span", {
|
|
2004
|
+
class: "generic-attachment-navigator-icon"
|
|
2005
|
+
}, "\u203A"))));
|
|
2006
|
+
});
|
|
2007
|
+
return $generics;
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
bindDrag() {
|
|
2011
|
+
if (!this.props.store.isMobile()) return;
|
|
2012
|
+
let eles = document.getElementsByClassName('generic-attachment');
|
|
2013
|
+
util/* default.map */.Z.map(eles, ele => bind(ele, () => {}));
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
}
|
|
2017
|
+
;// CONCATENATED MODULE: ./src/chatbox/ProductAttachments.js
|
|
2018
|
+
|
|
2019
|
+
|
|
2020
|
+
|
|
2021
|
+
class ProductAttachments extends common/* Com */.M {
|
|
2022
|
+
render() {
|
|
2023
|
+
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
2024
|
+
if (byType === 'user') return null;
|
|
2025
|
+
let attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
2026
|
+
let products = util/* default.filter */.Z.filter(attachments, att => util/* default.get */.Z.get(att, 'type') === 'product' || util/* default.get */.Z.get(att, 'type') === 'product_preview');
|
|
2027
|
+
products = products.filter(product => product.product && product.product.name);
|
|
2028
|
+
if (products.length === 0) return null;
|
|
2029
|
+
let acc = this.props.store.matchAccount();
|
|
2030
|
+
let $products = util/* default.map */.Z.map(products, (att, index) => {
|
|
2031
|
+
let product = att.product;
|
|
2032
|
+
let $detailbtn = null;
|
|
2033
|
+
let url = product.url || product.mobile_url;
|
|
2034
|
+
if (this.props.store.isMobile()) url = product.mobile_url || product.url;
|
|
2035
|
+
if (url) $detailbtn = (0,preact_module.h)("a", {
|
|
2036
|
+
class: "product_attachment__btn",
|
|
2037
|
+
href: url,
|
|
2038
|
+
target: "_blank"
|
|
2039
|
+
}, this.props.t('detail'), (0,preact_module.h)("img", {
|
|
2040
|
+
src: __webpack_require__(8453),
|
|
2041
|
+
class: "product_attachment__btn_external_link"
|
|
2042
|
+
}));
|
|
2043
|
+
let $title = (0,preact_module.h)("a", {
|
|
2044
|
+
href: url,
|
|
2045
|
+
class: "product_attachment__title",
|
|
2046
|
+
target: "_blank"
|
|
2047
|
+
}, product.name);
|
|
2048
|
+
let $subtitle = null;
|
|
2049
|
+
let desc = product.description || product.long_description;
|
|
2050
|
+
if (desc) $subtitle = (0,preact_module.h)("div", {
|
|
2051
|
+
class: "product_attachment__subtitle"
|
|
2052
|
+
}, desc);
|
|
2053
|
+
let $price = null;
|
|
2054
|
+
|
|
2055
|
+
if (product.price) {
|
|
2056
|
+
$price = (0,preact_module.h)("div", {
|
|
2057
|
+
class: "product_attachment__price"
|
|
2058
|
+
}, product.currency || util/* default.get */.Z.get(acc, 'currency', ''), " ", util/* default.formatCurrency */.Z.formatCurrency(product.price));
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
return (0,preact_module.h)("div", {
|
|
2062
|
+
class: 'product_attachment product_attachment__' + byType
|
|
2063
|
+
}, (0,preact_module.h)("div", null, (0,preact_module.h)("a", {
|
|
2064
|
+
href: this.props.store.replaceFileUrl(product.image),
|
|
2065
|
+
target: "_blank"
|
|
2066
|
+
}, (0,preact_module.h)("img", {
|
|
2067
|
+
class: "product_attachment__img",
|
|
2068
|
+
src: this.props.store.replaceFileUrl(product.image)
|
|
2069
|
+
}))), $title, $subtitle, $price, (0,preact_module.h)("div", {
|
|
2070
|
+
class: "product_attachment__btns"
|
|
2071
|
+
}, $detailbtn));
|
|
2072
|
+
});
|
|
2073
|
+
return $products;
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
}
|
|
2077
|
+
;// CONCATENATED MODULE: ./src/chatbox/OrderAttachments.js
|
|
2078
|
+
|
|
2079
|
+
|
|
2080
|
+
|
|
2081
|
+
class OrderAttachments_ProductAttachments extends common/* Com */.M {
|
|
2082
|
+
render() {
|
|
2083
|
+
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
2084
|
+
if (byType === 'user') return null;
|
|
2085
|
+
let acc = this.props.store.matchAccount();
|
|
2086
|
+
var attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
2087
|
+
let orders = util/* default.filter */.Z.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
|
|
2088
|
+
if (orders.length === 0) return null;
|
|
2089
|
+
let $orders = util/* default.map */.Z.map(orders, (order, index) => {
|
|
2090
|
+
let $note = null;
|
|
2091
|
+
|
|
2092
|
+
if (order.note) {
|
|
2093
|
+
$note = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
2094
|
+
class: "order_attachment__label"
|
|
2095
|
+
}, this.props.t('note')), (0,preact_module.h)("div", {
|
|
2096
|
+
class: "order_attachment__text_truncate"
|
|
2097
|
+
}, order.note));
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
let $products = null;
|
|
2101
|
+
|
|
2102
|
+
if (util/* default.size */.Z.size(order.items) > 0) {
|
|
2103
|
+
$products = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
2104
|
+
class: "order_attachment__label"
|
|
2105
|
+
}, this.props.t('product')), util/* default.map */.Z.map(order.items, item => {
|
|
2106
|
+
let product = item.product || {};
|
|
2107
|
+
return (0,preact_module.h)("div", {
|
|
2108
|
+
class: "order_attachment__product"
|
|
2109
|
+
}, (0,preact_module.h)("img", {
|
|
2110
|
+
class: "order_attachment__product_img",
|
|
2111
|
+
src: (util/* default.get */.Z.get(product, 'images.0'), __webpack_require__(9270))
|
|
2112
|
+
}), (0,preact_module.h)("div", {
|
|
2113
|
+
style: "overflow: hidden !important;"
|
|
2114
|
+
}, (0,preact_module.h)("div", {
|
|
2115
|
+
class: "order_attachment__product_name"
|
|
2116
|
+
}, product.name), (0,preact_module.h)("div", {
|
|
2117
|
+
class: "order_attachment__product_desc"
|
|
2118
|
+
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
2119
|
+
class: "order_attachment__product_desc"
|
|
2120
|
+
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default.formatCurrency */.Z.formatCurrency(product.price))));
|
|
2121
|
+
}));
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
let $total = (0,preact_module.h)("div", {
|
|
2125
|
+
class: "order_attachment__footer"
|
|
2126
|
+
}, (0,preact_module.h)("div", null, this.props.t('total')), ' ', (0,preact_module.h)("div", null, (0,preact_module.h)("b", null, util/* default.formatCurrency */.Z.formatCurrency(order.total))));
|
|
2127
|
+
let addr = util/* default.get */.Z.get(order, 'shipping.address', {});
|
|
2128
|
+
let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
2129
|
+
let address = fulladdr;
|
|
2130
|
+
let phoneattr = util/* default.find */.Z.find(util/* default.get */.Z.get(order, 'user.attributes', []), attr => attr.key === 'phones') || {
|
|
2131
|
+
key: 'phones',
|
|
2132
|
+
text: ''
|
|
2133
|
+
};
|
|
2134
|
+
let phone = util/* default.get */.Z.get(order, 'shipping.address.phone', '').trim();
|
|
2135
|
+
phone = phone || util/* default.trim */.Z.trim(phoneattr.text);
|
|
2136
|
+
if (phone) phone = this.props.t('phn') + ': ' + phone;
|
|
2137
|
+
let $shipto = null;
|
|
2138
|
+
|
|
2139
|
+
if (address || phone) {
|
|
2140
|
+
$shipto = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
2141
|
+
class: "order_attachment__label"
|
|
2142
|
+
}, this.props.t('ship_to')), (0,preact_module.h)("div", {
|
|
2143
|
+
class: "order_attachment__text_truncate"
|
|
2144
|
+
}, address), (0,preact_module.h)("div", {
|
|
2145
|
+
class: "order_attachment__text_truncate"
|
|
2146
|
+
}, phone));
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
return (0,preact_module.h)("div", {
|
|
2150
|
+
class: `order_attachment order_attachment__${byType}`
|
|
2151
|
+
}, (0,preact_module.h)("div", {
|
|
2152
|
+
class: "order_attachment__header"
|
|
2153
|
+
}, this.props.t('order'), (0,preact_module.h)("span", {
|
|
2154
|
+
class: "order_attachment__text_muted order_attachment__text_sm"
|
|
2155
|
+
}, "#", order.id)), $products, $shipto, (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
2156
|
+
class: "order_attachment__label"
|
|
2157
|
+
}, this.props.t('payment')), (0,preact_module.h)("div", null, "COD")), $note, $total);
|
|
2158
|
+
});
|
|
2159
|
+
return $orders;
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
}
|
|
2163
|
+
;// CONCATENATED MODULE: ./src/chatbox/VideoAttachments.js
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
|
|
2167
|
+
class VideoAttachments extends common/* Com */.M {
|
|
2168
|
+
constructor(props) {
|
|
2169
|
+
super(props);
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
render() {
|
|
2173
|
+
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
2174
|
+
var attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
2175
|
+
var videos = [];
|
|
2176
|
+
util/* default.each */.Z.each(attachments, (att, i) => {
|
|
2177
|
+
if (!att) return;
|
|
2178
|
+
if (util/* default.includes */.Z.includes(att.mimetype, 'video')) videos.push(att);
|
|
2179
|
+
});
|
|
2180
|
+
if (videos.length === 0) return null;
|
|
2181
|
+
var $videos = util/* default.map */.Z.map(videos, (video, index) => {
|
|
2182
|
+
return (0,preact_module.h)("div", {
|
|
2183
|
+
class: `video-attachment video-attachment--${byType}`
|
|
2184
|
+
}, (0,preact_module.h)("video", {
|
|
2185
|
+
class: "video-attachment__video",
|
|
2186
|
+
src: this.props.store.replaceFileUrl(video.url),
|
|
2187
|
+
width: "100%",
|
|
2188
|
+
height: "",
|
|
2189
|
+
poster: this.props.store.replaceFileUrl(video.thumbnail_url),
|
|
2190
|
+
controls: "controls",
|
|
2191
|
+
preload: "metadata",
|
|
2192
|
+
onclick: "this.play()"
|
|
2193
|
+
}));
|
|
2194
|
+
});
|
|
2195
|
+
return (0,preact_module.h)("div", {
|
|
2196
|
+
class: `message-${byType}`
|
|
2197
|
+
}, $videos);
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
}
|
|
2201
|
+
;// CONCATENATED MODULE: ./src/chatbox/ShadowDomRoot.js
|
|
2202
|
+
|
|
2203
|
+
|
|
2204
|
+
class ShadowDomRoot extends common/* Com */.M {
|
|
2205
|
+
constructor(props) {
|
|
2206
|
+
super(props);
|
|
2207
|
+
this.ref = (0,preact_module/* createRef */.Vf)();
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
componentDidMount() {
|
|
2211
|
+
this.shadowRoot = this.ref.current.attachShadow({
|
|
2212
|
+
mode: 'open'
|
|
2213
|
+
});
|
|
2214
|
+
this.update(this.props.html);
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
update(html) {
|
|
2218
|
+
this.shadowRoot.innerHTML = `<style type="text/css">
|
|
2219
|
+
body { font-family: 'Roboto', sans-serif!important; font-size: 14px!important; line-height: 20px; overflow-y: hidden; margin:0 }
|
|
2220
|
+
h{ font-size: 14/18px!important; }
|
|
2221
|
+
a { text-decoration: none;}
|
|
2222
|
+
img { max-width: 100%; display: block; margin: 10px auto; }
|
|
2223
|
+
* { white-space: normal }
|
|
2224
|
+
ul > li { margin-bottom: 5px }
|
|
2225
|
+
ul:last-child { margin-bottom: 0 }
|
|
2226
|
+
p:first-child { margin-top: 0;}
|
|
2227
|
+
p:last-child { margin-bottom: 0;}
|
|
2228
|
+
</style>
|
|
2229
|
+
<div>${html}</div>`;
|
|
2230
|
+
let links = this.shadowRoot.querySelectorAll('a');
|
|
2231
|
+
|
|
2232
|
+
for (var i = 0; i < links.length; i++) links[i].target = '_blank';
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
render() {
|
|
2236
|
+
return (0,preact_module.h)("div", {
|
|
2237
|
+
ref: this.ref,
|
|
2238
|
+
style: "white-space: normal !important"
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
}
|
|
2243
|
+
;// CONCATENATED MODULE: ./src/chatbox/TextMessage.js
|
|
2244
|
+
|
|
2245
|
+
let mustrerender = [];
|
|
2246
|
+
|
|
2247
|
+
let marked = (obj, text) => {
|
|
2248
|
+
mustrerender.push(obj);
|
|
2249
|
+
return '';
|
|
2250
|
+
};
|
|
2251
|
+
|
|
2252
|
+
const loadMarked = () => __webpack_require__.e(/* import() */ 441).then(__webpack_require__.bind(__webpack_require__, 7441));
|
|
2253
|
+
|
|
2254
|
+
(async () => {
|
|
2255
|
+
let markedf = (await loadMarked()).marked;
|
|
2256
|
+
|
|
2257
|
+
marked = (obj, text) => markedf(text);
|
|
2258
|
+
|
|
2259
|
+
util/* default.map */.Z.map(mustrerender, obj => obj.forceUpdate());
|
|
2260
|
+
mustrerender = [];
|
|
2261
|
+
})();
|
|
2262
|
+
|
|
2263
|
+
|
|
2264
|
+
|
|
2265
|
+
|
|
2266
|
+
|
|
2267
|
+
class TextMessage extends common/* Com */.M {
|
|
2268
|
+
render() {
|
|
2269
|
+
var format = util/* default.get */.Z.get(this.props.ev, 'data.message.format', 'plaintext');
|
|
2270
|
+
if (format === 'markdown') return this.renderMarkdown();
|
|
2271
|
+
var text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
|
|
2272
|
+
text = util/* default.trim */.Z.trim(text);
|
|
2273
|
+
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
2274
|
+
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
2275
|
+
var tags = util/* default.extractText */.Z.extractText(text).map(tag => {
|
|
2276
|
+
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
2277
|
+
emojiCode: tag.text,
|
|
2278
|
+
byType: byType
|
|
2279
|
+
});
|
|
2280
|
+
|
|
2281
|
+
if (tag.type === 'link') {
|
|
2282
|
+
return (0,preact_module.h)("a", {
|
|
2283
|
+
href: tag.text,
|
|
2284
|
+
target: "_blank"
|
|
2285
|
+
}, tag.text);
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
if (tag.type === 'phone') return (0,preact_module.h)("a", {
|
|
2289
|
+
href: 'tel:' + tag.text
|
|
2290
|
+
}, tag.text);
|
|
2291
|
+
if (tag.type === 'email') return (0,preact_module.h)("a", {
|
|
2292
|
+
href: 'mailto:' + tag.text
|
|
2293
|
+
}, tag.text);
|
|
2294
|
+
return tag.text;
|
|
2295
|
+
});
|
|
2296
|
+
if (util/* default.size */.Z.size(tags) === 0) return null;
|
|
2297
|
+
|
|
2298
|
+
if (byType === 'agent') {
|
|
2299
|
+
return (0,preact_module.h)("div", {
|
|
2300
|
+
class: "message-agent message-text--agent"
|
|
2301
|
+
}, tags);
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
return (0,preact_module.h)("div", {
|
|
2305
|
+
class: "message-user message-text--user"
|
|
2306
|
+
}, tags);
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
renderMarkdown() {
|
|
2310
|
+
var text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
|
|
2311
|
+
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
2312
|
+
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
2313
|
+
text = util/* default.trim */.Z.trim(text);
|
|
2314
|
+
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
2315
|
+
|
|
2316
|
+
if (byType === 'agent') {
|
|
2317
|
+
return (0,preact_module.h)("div", {
|
|
2318
|
+
class: "markdown-message message-agent message-text--agent"
|
|
2319
|
+
}, (0,preact_module.h)(ShadowDomRoot, {
|
|
2320
|
+
html: marked(this, text)
|
|
2321
|
+
}));
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
return (0,preact_module.h)("div", {
|
|
2325
|
+
class: "d-flex flex-column align-items-end"
|
|
2326
|
+
}, (0,preact_module.h)("div", {
|
|
2327
|
+
class: "markdown-message message-user message-text--user"
|
|
2328
|
+
}, (0,preact_module.h)(ShadowDomRoot, {
|
|
2329
|
+
html: marked(this, text)
|
|
2330
|
+
})));
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
}
|
|
2334
|
+
;// CONCATENATED MODULE: ./src/chatbox/time.js
|
|
2335
|
+
|
|
2336
|
+
var g_pub = new util/* default.Pubsub */.Z.Pubsub();
|
|
2337
|
+
setInterval(() => g_pub.publish('time'), 20 * 1000);
|
|
2338
|
+
|
|
2339
|
+
|
|
2340
|
+
class Time extends common/* Com */.M {
|
|
2341
|
+
constructor(props) {
|
|
2342
|
+
super(props);
|
|
2343
|
+
this.setState({
|
|
2344
|
+
t: '',
|
|
2345
|
+
langCode: 'en_US'
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
updateTime() {
|
|
2350
|
+
var t = '';
|
|
2351
|
+
|
|
2352
|
+
if (this.props.ago) {
|
|
2353
|
+
if (this.props.short) {
|
|
2354
|
+
if (Math.abs(this.props.time - new util/* default.Date */.Z.Date().getTime()) > 86400000 * 10) {
|
|
2355
|
+
let tim = new util/* default.Date */.Z.Date(this.props.time);
|
|
2356
|
+
let tzyear = tim.getFullYear();
|
|
2357
|
+
let locale = util/* default.get */.Z.get(navigator, 'languages.0', 'en-US');
|
|
2358
|
+
let tzmonthname = tim.toLocaleDateString(locale, {
|
|
2359
|
+
month: 'short'
|
|
2360
|
+
});
|
|
2361
|
+
let tzdate = tim.getDate();
|
|
2362
|
+
t = tzdate + ' ' + tzmonthname + ' ' + tzyear;
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
if (!t && this.props.time > 0) t = ago(this.props.time, new util/* default.Date */.Z.Date().getTime());
|
|
2367
|
+
} else t = util/* default.shortTime */.Z.shortTime(this.props.time, this.props.tzoffset);
|
|
2368
|
+
|
|
2369
|
+
if (this.props.uppercase) t = t.toUpperCase();
|
|
2370
|
+
if (t === this.state.t) return;
|
|
2371
|
+
this.setState({
|
|
2372
|
+
t
|
|
2373
|
+
});
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
componentDidMount() {
|
|
2377
|
+
g_pub.on2(this, 'time', () => this.updateTime());
|
|
2378
|
+
this.updateTime();
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
render() {
|
|
2382
|
+
return (0,preact_module.h)("span", null, this.state.t);
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
function ago(timeA, timeB) {
|
|
2388
|
+
const relObj = {
|
|
2389
|
+
s: '%d s',
|
|
2390
|
+
m: '1m',
|
|
2391
|
+
mm: '%dm',
|
|
2392
|
+
h: '1h',
|
|
2393
|
+
hh: '%dh',
|
|
2394
|
+
d: '1d',
|
|
2395
|
+
dd: '%dd',
|
|
2396
|
+
M: '1M',
|
|
2397
|
+
MM: '%M',
|
|
2398
|
+
y: '1y',
|
|
2399
|
+
yy: '%dy'
|
|
2400
|
+
};
|
|
2401
|
+
const loc = relObj;
|
|
2402
|
+
const T = [{
|
|
2403
|
+
l: 's',
|
|
2404
|
+
r: 44,
|
|
2405
|
+
d: 1000
|
|
2406
|
+
}, {
|
|
2407
|
+
l: 'm',
|
|
2408
|
+
r: 89
|
|
2409
|
+
}, {
|
|
2410
|
+
l: 'mm',
|
|
2411
|
+
r: 44,
|
|
2412
|
+
d: 60000
|
|
2413
|
+
}, {
|
|
2414
|
+
l: 'h',
|
|
2415
|
+
r: 89
|
|
2416
|
+
}, {
|
|
2417
|
+
l: 'hh',
|
|
2418
|
+
r: 21,
|
|
2419
|
+
d: 3600000
|
|
2420
|
+
}, {
|
|
2421
|
+
l: 'd',
|
|
2422
|
+
r: 35
|
|
2423
|
+
}, {
|
|
2424
|
+
l: 'dd',
|
|
2425
|
+
r: 25,
|
|
2426
|
+
d: 86400000
|
|
2427
|
+
}, {
|
|
2428
|
+
l: 'M',
|
|
2429
|
+
r: 45
|
|
2430
|
+
}, {
|
|
2431
|
+
l: 'MM',
|
|
2432
|
+
r: 10,
|
|
2433
|
+
d: 30 * 86400000
|
|
2434
|
+
}, {
|
|
2435
|
+
l: 'y',
|
|
2436
|
+
r: 17
|
|
2437
|
+
}, {
|
|
2438
|
+
l: 'yy',
|
|
2439
|
+
d: 365 * 86400000
|
|
2440
|
+
}];
|
|
2441
|
+
const Tl = T.length;
|
|
2442
|
+
let result;
|
|
2443
|
+
let out;
|
|
2444
|
+
|
|
2445
|
+
for (let i = 0; i < Tl; i += 1) {
|
|
2446
|
+
let t = T[i];
|
|
2447
|
+
|
|
2448
|
+
if (t.d) {
|
|
2449
|
+
result = (timeA - timeB) / t.d;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
let abs = Math.round(Math.abs(result));
|
|
2453
|
+
|
|
2454
|
+
if (abs <= t.r || !t.r) {
|
|
2455
|
+
if (abs <= 1 && i > 0) t = T[i - 1];
|
|
2456
|
+
out = loc[t.l].replace('%d', abs);
|
|
2457
|
+
break;
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
return out;
|
|
2462
|
+
}
|
|
2463
|
+
;// CONCATENATED MODULE: ./src/chatbox/InfoMessage.js
|
|
2464
|
+
|
|
2465
|
+
|
|
2466
|
+
function getRateLang(rating) {
|
|
2467
|
+
if (!rating) return 'poor';
|
|
2468
|
+
if (rating < 2) return 'poor';
|
|
2469
|
+
if (rating < 4) return 'average';
|
|
2470
|
+
return 'great';
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
|
|
2474
|
+
|
|
2475
|
+
|
|
2476
|
+
class InfoMessage extends common/* Com */.M {
|
|
2477
|
+
render() {
|
|
2478
|
+
let ev = this.props.ev.ev;
|
|
2479
|
+
var $time = null;
|
|
2480
|
+
|
|
2481
|
+
if (this.props.ev.show_time) {
|
|
2482
|
+
$time = (0,preact_module.h)("div", {
|
|
2483
|
+
class: "convo-event-time"
|
|
2484
|
+
}, (0,preact_module.h)(Time, {
|
|
2485
|
+
time: ev.created
|
|
2486
|
+
}));
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
if (ev.type === 'conversation_rated') {
|
|
2490
|
+
var rating = util/* default.get */.Z.get(ev, 'data.conversation.ratings.0', {
|
|
2491
|
+
no_rating: true,
|
|
2492
|
+
rating: 0
|
|
2493
|
+
});
|
|
2494
|
+
if (rating.no_rating) return null;
|
|
2495
|
+
return (0,preact_module.h)("div", {
|
|
2496
|
+
class: "convo-event"
|
|
2497
|
+
}, $time, (0,preact_module.h)("div", {
|
|
2498
|
+
class: "info-message"
|
|
2499
|
+
}, this.props.t('rated_as') + ' ' + this.props.t(getRateLang(rating.rating)).toLowerCase()));
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
if (ev.type === 'conversation_state_updated' && util/* default.get */.Z.get(ev, 'data.conversation.state') === 'ended') {
|
|
2503
|
+
return (0,preact_module.h)("div", {
|
|
2504
|
+
class: "convo-event"
|
|
2505
|
+
}, $time, (0,preact_module.h)("div", {
|
|
2506
|
+
class: "info-message"
|
|
2507
|
+
}, this.props.t('conversation_ended')));
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
return null;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
}
|
|
2514
|
+
;// CONCATENATED MODULE: ./src/chatbox/Event.js
|
|
2515
|
+
|
|
2516
|
+
|
|
2517
|
+
|
|
2518
|
+
|
|
2519
|
+
|
|
2520
|
+
|
|
2521
|
+
|
|
2522
|
+
|
|
2523
|
+
|
|
2524
|
+
|
|
2525
|
+
|
|
2526
|
+
|
|
2527
|
+
|
|
2528
|
+
|
|
2529
|
+
|
|
2530
|
+
|
|
2531
|
+
|
|
2532
|
+
class Event extends common/* Com */.M {
|
|
2533
|
+
constructor(props) {
|
|
2534
|
+
super(props);
|
|
2535
|
+
this.refForm = (0,preact_module/* createRef */.Vf)();
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
render() {
|
|
2539
|
+
var ev = util/* default.get */.Z.get(this.props.event, 'ev', {});
|
|
2540
|
+
|
|
2541
|
+
switch (ev.type) {
|
|
2542
|
+
case 'conversation_joined':
|
|
2543
|
+
break;
|
|
2544
|
+
|
|
2545
|
+
case 'message_sent':
|
|
2546
|
+
return this.renderMessageSent();
|
|
2547
|
+
|
|
2548
|
+
case 'conversation_state_updated':
|
|
2549
|
+
case 'conversation_rating_requested':
|
|
2550
|
+
case 'conversation_rated':
|
|
2551
|
+
if (!util/* default.startsWith */.Z.startsWith(ev.id, 'ev')) return null;
|
|
2552
|
+
return (0,preact_module.h)(InfoMessage, {
|
|
2553
|
+
t: this.props.t,
|
|
2554
|
+
store: this.props.store,
|
|
2555
|
+
ev: this.props.event
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
return null;
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
focus() {
|
|
2563
|
+
this.refForm.current && this.refForm.current.focus();
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
chooseQuickReply(reply) {
|
|
2567
|
+
let ev = util/* default.get */.Z.get(this.props.event, 'ev', {});
|
|
2568
|
+
let message = {
|
|
2569
|
+
text: reply.title,
|
|
2570
|
+
format: 'plaintext'
|
|
2571
|
+
};
|
|
2572
|
+
|
|
2573
|
+
if (reply.payload) {
|
|
2574
|
+
message.attachments = [{
|
|
2575
|
+
type: 'postback',
|
|
2576
|
+
postback: {
|
|
2577
|
+
event_id: ev.id,
|
|
2578
|
+
payload: reply.payload
|
|
2579
|
+
}
|
|
2580
|
+
}];
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
this.props.onSend(message);
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
choosePostbackBtn(button) {
|
|
2587
|
+
let ev = util/* default.get */.Z.get(this.props.event, 'ev', {});
|
|
2588
|
+
let message = {
|
|
2589
|
+
text: button.title,
|
|
2590
|
+
format: 'plaintext'
|
|
2591
|
+
};
|
|
2592
|
+
|
|
2593
|
+
if (button.payload) {
|
|
2594
|
+
message.attachments = [{
|
|
2595
|
+
type: 'postback',
|
|
2596
|
+
postback: {
|
|
2597
|
+
event_id: ev.id,
|
|
2598
|
+
payload: button.payload
|
|
2599
|
+
}
|
|
2600
|
+
}];
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
this.props.onSend(message);
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
renderAgentAvatar(ev) {
|
|
2607
|
+
let bytype = util/* default.get */.Z.get(ev, 'by.type');
|
|
2608
|
+
let byid = util/* default.get */.Z.get(ev, 'by.display_id', util/* default.get */.Z.get(ev, 'by.id'));
|
|
2609
|
+
if (bytype === 'user') return null;
|
|
2610
|
+
var senderName = this.getSenderName(ev);
|
|
2611
|
+
let acc = this.props.store.matchAccount();
|
|
2612
|
+
|
|
2613
|
+
var uri = acc.logo_url || __webpack_require__(9895);
|
|
2614
|
+
|
|
2615
|
+
let agentM = this.props.store.matchAgent('*');
|
|
2616
|
+
|
|
2617
|
+
if (byid !== 'system' || bytype !== 'dummy') {
|
|
2618
|
+
uri = util/* default.get */.Z.get(agentM[byid], 'avatar_url') || acc.logo_url || __webpack_require__(4761);
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
return (0,preact_module.h)("div", {
|
|
2622
|
+
class: "message-sender"
|
|
2623
|
+
}, (0,preact_module.h)("img", {
|
|
2624
|
+
alt: "sender",
|
|
2625
|
+
class: "message-sender-avatar",
|
|
2626
|
+
src: this.props.store.replaceFileUrl(uri)
|
|
2627
|
+
}), (0,preact_module.h)("p", {
|
|
2628
|
+
class: "message-sender-name"
|
|
2629
|
+
}, senderName));
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
renderMessageSent() {
|
|
2633
|
+
let ev = this.props.event.ev;
|
|
2634
|
+
var $time = null;
|
|
2635
|
+
|
|
2636
|
+
if (this.props.event.show_time) {
|
|
2637
|
+
$time = (0,preact_module.h)("div", {
|
|
2638
|
+
class: "convo-event-time"
|
|
2639
|
+
}, (0,preact_module.h)(Time, {
|
|
2640
|
+
time: ev.created
|
|
2641
|
+
}));
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
let t = new util/* default.Date */.Z.Date(ev.created).toLocaleString();
|
|
2645
|
+
|
|
2646
|
+
if (util/* default.get */.Z.get(ev, 'by.type') !== 'user') {
|
|
2647
|
+
let $sender = null;
|
|
2648
|
+
if (this.props.event.mode === 'lead') $sender = this.renderAgentAvatar(ev);
|
|
2649
|
+
return (0,preact_module.h)("div", {
|
|
2650
|
+
class: "convo-event agent-message",
|
|
2651
|
+
title: t
|
|
2652
|
+
}, $time, $sender, (0,preact_module.h)(TextMessage, {
|
|
2653
|
+
store: this.props.store,
|
|
2654
|
+
ev: ev
|
|
2655
|
+
}), (0,preact_module.h)(ImageAttachment, {
|
|
2656
|
+
store: this.props.store,
|
|
2657
|
+
ev: ev
|
|
2658
|
+
}), (0,preact_module.h)(AudioAttachments, {
|
|
2659
|
+
store: this.props.store,
|
|
2660
|
+
ev: ev
|
|
2661
|
+
}), (0,preact_module.h)(VideoAttachments, {
|
|
2662
|
+
store: this.props.store,
|
|
2663
|
+
ev: ev
|
|
2664
|
+
}), (0,preact_module.h)(FileAttachments, {
|
|
2665
|
+
store: this.props.store,
|
|
2666
|
+
ev: ev
|
|
2667
|
+
}), (0,preact_module.h)(ButtonAttachments, {
|
|
2668
|
+
store: this.props.store,
|
|
2669
|
+
ev: ev
|
|
2670
|
+
}), (0,preact_module.h)(FormAttachments, {
|
|
2671
|
+
store: this.props.store,
|
|
2672
|
+
onSubmit: this.props.onFormSubmit,
|
|
2673
|
+
ref: this.refForm,
|
|
2674
|
+
ev: ev,
|
|
2675
|
+
t: this.props.t
|
|
2676
|
+
}), (0,preact_module.h)(FormSubmitAttachments, {
|
|
2677
|
+
store: this.props.store,
|
|
2678
|
+
ev: ev,
|
|
2679
|
+
t: this.props.t
|
|
2680
|
+
}), (0,preact_module.h)(GenericTemplateAttachments, {
|
|
2681
|
+
store: this.props.store,
|
|
2682
|
+
ev: ev,
|
|
2683
|
+
onSelect: e => this.choosePostbackBtn(e)
|
|
2684
|
+
}), (0,preact_module.h)(ProductAttachments, {
|
|
2685
|
+
t: this.props.t,
|
|
2686
|
+
store: this.props.store,
|
|
2687
|
+
ev: ev
|
|
2688
|
+
}), (0,preact_module.h)(OrderAttachments_ProductAttachments, {
|
|
2689
|
+
t: this.props.t,
|
|
2690
|
+
store: this.props.store,
|
|
2691
|
+
ev: ev
|
|
2692
|
+
}), (0,preact_module.h)(QuickReplies, {
|
|
2693
|
+
store: this.props.store,
|
|
2694
|
+
ev: ev,
|
|
2695
|
+
onSelect: e => this.chooseQuickReply(e)
|
|
2696
|
+
}));
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
if (util/* default.getMsgField */.Z.getMsgField(ev, 'idempotency') === ev.id && this.props.store.now() - ev.created < 900) {
|
|
2700
|
+
setTimeout(() => this.setState({
|
|
2701
|
+
refresh: this.state.refresh
|
|
2702
|
+
}), 1000);
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
let $dot = (0,preact_module.h)("div", {
|
|
2706
|
+
class: "sending_dot"
|
|
2707
|
+
});
|
|
2708
|
+
|
|
2709
|
+
if (this.props.store.now() - ev.created < 900 || util/* default.getMsgField */.Z.getMsgField(ev, 'idempotency') !== ev.id) {
|
|
2710
|
+
$dot = (0,preact_module.h)("div", {
|
|
2711
|
+
class: "sending_dot sending_dot__hide"
|
|
2712
|
+
});
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
let $sender = null;
|
|
2716
|
+
if (this.props.event.mode === 'lead') $sender = (0,preact_module.h)("div", {
|
|
2717
|
+
class: "pt-3"
|
|
2718
|
+
});
|
|
2719
|
+
let $error = null;
|
|
2720
|
+
|
|
2721
|
+
if (ev._error && ev.type === 'message_sent') {
|
|
2722
|
+
$error = (0,preact_module.h)("a", {
|
|
2723
|
+
class: "message_error",
|
|
2724
|
+
src: "javascript:;",
|
|
2725
|
+
onClick: e => this.resendMessage()
|
|
2726
|
+
}, (0,preact_module.h)("div", {
|
|
2727
|
+
class: "message_error__text"
|
|
2728
|
+
}, this.props.t('error_send_message')), (0,preact_module.h)("div", {
|
|
2729
|
+
class: "message_error__icon"
|
|
2730
|
+
}));
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2733
|
+
return (0,preact_module.h)("div", {
|
|
2734
|
+
class: "convo-event user-message",
|
|
2735
|
+
title: t
|
|
2736
|
+
}, $time, $sender, (0,preact_module.h)("div", {
|
|
2737
|
+
class: "message-user__container"
|
|
2738
|
+
}, $dot, (0,preact_module.h)(TextMessage, {
|
|
2739
|
+
store: this.props.store,
|
|
2740
|
+
ev: ev,
|
|
2741
|
+
refresh: this.state.refresh
|
|
2742
|
+
}), (0,preact_module.h)(ImageAttachment, {
|
|
2743
|
+
store: this.props.store,
|
|
2744
|
+
ev: ev
|
|
2745
|
+
}), (0,preact_module.h)(AudioAttachments, {
|
|
2746
|
+
store: this.props.store,
|
|
2747
|
+
ev: ev
|
|
2748
|
+
}), (0,preact_module.h)(VideoAttachments, {
|
|
2749
|
+
store: this.props.store,
|
|
2750
|
+
ev: ev
|
|
2751
|
+
}), (0,preact_module.h)(FileAttachments, {
|
|
2752
|
+
store: this.props.store,
|
|
2753
|
+
ev: ev
|
|
2754
|
+
}), (0,preact_module.h)(ButtonAttachments, {
|
|
2755
|
+
store: this.props.store,
|
|
2756
|
+
ev: ev
|
|
2757
|
+
}), (0,preact_module.h)(FormAttachments, {
|
|
2758
|
+
store: this.props.store,
|
|
2759
|
+
onSubmit: this.props.onFormSubmit,
|
|
2760
|
+
ref: this.refForm,
|
|
2761
|
+
ev: ev
|
|
2762
|
+
}), (0,preact_module.h)(ProductAttachments, {
|
|
2763
|
+
t: this.props.t,
|
|
2764
|
+
store: this.props.store,
|
|
2765
|
+
ev: ev
|
|
2766
|
+
}), (0,preact_module.h)(FormSubmitAttachments, {
|
|
2767
|
+
store: this.props.store,
|
|
2768
|
+
ev: ev
|
|
2769
|
+
})), $error);
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2772
|
+
renderUpdateConvo(ev) {
|
|
2773
|
+
var state = util/* default.get */.Z.get(ev, 'data.conversation.state');
|
|
2774
|
+
if (state === 'active') return null;
|
|
2775
|
+
if (state === 'pending') return null;
|
|
2776
|
+
return (0,preact_module.h)("div", {
|
|
2777
|
+
class: "message-system"
|
|
2778
|
+
}, this.props.t('conversation_state_updated', {
|
|
2779
|
+
state
|
|
2780
|
+
}));
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
resendMessage() {
|
|
2784
|
+
let cid = util/* default.convoOfEv */.Z.convoOfEv(this.props.event.ev);
|
|
2785
|
+
const message = util/* default.get */.Z.get(this.props.event, 'ev.data.message');
|
|
2786
|
+
this.props.store.sendConvoEvent(cid, 'message_sent', {
|
|
2787
|
+
message
|
|
2788
|
+
});
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
getSenderName(ev) {
|
|
2792
|
+
let bytype = util/* default.get */.Z.get(ev, 'by.type');
|
|
2793
|
+
let byid = util/* default.get */.Z.get(ev, 'by.display_id', util/* default.get */.Z.get(ev, 'by.id'));
|
|
2794
|
+
if (byid === 'system' || bytype === 'dummy') return 'system';
|
|
2795
|
+
let user = this.props.store.matchUser();
|
|
2796
|
+
let acc = this.props.store.matchAccount();
|
|
2797
|
+
if (bytype === 'user') return util/* default.getUserDisplayName */.Z.getUserDisplayName(user);
|
|
2798
|
+
if (bytype === 'agent') return util/* default.getAgentDisplayName */.Z.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
|
|
2799
|
+
return '';
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2802
|
+
}
|
|
2803
|
+
;// CONCATENATED MODULE: ./src/chatbox/spinner.js
|
|
2804
|
+
const loadingimg = __webpack_require__(6484);
|
|
2805
|
+
|
|
2806
|
+
|
|
2807
|
+
|
|
2808
|
+
class Spinner extends common/* Com */.M {
|
|
2809
|
+
render() {
|
|
2810
|
+
let mode = (this.props.mode + '').toLowerCase();
|
|
2811
|
+
let mainColor = mode === 'dark' ? '#000000dd' : mode === 'blue' ? 'rgba(52, 152, 220, .8)' : '#ffffffdd';
|
|
2812
|
+
let borderColor = mode === 'dark' ? '#00000055' : mode === 'blue' ? 'rgba(52, 152, 220, .15)' : '#ffffff55';
|
|
2813
|
+
let size = this.props.size || 14;
|
|
2814
|
+
let borderWidth = Math.ceil(size / 14);
|
|
2815
|
+
let style = `width: ${size}px !important;height: ${size}px!important;color: ${borderColor} !important;border-width: ${borderWidth}px !important;
|
|
2816
|
+
border-left-color: ${borderColor} !important;border-top-color: ${borderColor} !important;
|
|
2817
|
+
border-bottom-color: ${borderColor} !important;border-right-color: ${mainColor} !important;`;
|
|
2818
|
+
|
|
2819
|
+
if (this.props.static) {
|
|
2820
|
+
let style = `width: ${size}px;height: ${size}px;`;
|
|
2821
|
+
if (size < 40) return (0,preact_module.h)(LoaderIcon, {
|
|
2822
|
+
size: size + '',
|
|
2823
|
+
style: `stroke:${mainColor}`
|
|
2824
|
+
});
|
|
2825
|
+
|
|
2826
|
+
if (this.props.center) {
|
|
2827
|
+
return (0,preact_module.h)("div", {
|
|
2828
|
+
class: "loading"
|
|
2829
|
+
}, (0,preact_module.h)("img", {
|
|
2830
|
+
alt: "loading",
|
|
2831
|
+
style: style,
|
|
2832
|
+
src: loadingimg
|
|
2833
|
+
}));
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
return (0,preact_module.h)("img", {
|
|
2837
|
+
alt: "loading",
|
|
2838
|
+
style: style,
|
|
2839
|
+
src: loadingimg
|
|
2840
|
+
});
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
return (0,preact_module.h)("div", {
|
|
2844
|
+
class: "spinner1",
|
|
2845
|
+
style: style
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
}
|
|
2850
|
+
;// CONCATENATED MODULE: ./src/chatbox/Events.js
|
|
2851
|
+
|
|
2852
|
+
|
|
2853
|
+
|
|
2854
|
+
const convoemptyimg = __webpack_require__(6188);
|
|
2855
|
+
|
|
2856
|
+
|
|
2857
|
+
|
|
2858
|
+
|
|
2859
|
+
|
|
2860
|
+
class Events extends common/* Com */.M {
|
|
2861
|
+
constructor(props) {
|
|
2862
|
+
super(props);
|
|
2863
|
+
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
2864
|
+
this.props.store.onConvoEvent(this, ev => this.onEvent(ev));
|
|
2865
|
+
this.loadConvo();
|
|
2866
|
+
this.refBody = null;
|
|
2867
|
+
this.checkAndSeen = util/* default.throttle */.Z.throttle(() => {
|
|
2868
|
+
if (this.props.isShow && this.isBottom() && this.props.store.browserVisibility === 'visible' && document.hasFocus()) {
|
|
2869
|
+
this.props.store.seenConvo(this.props.cid);
|
|
2870
|
+
}
|
|
2871
|
+
}, 500);
|
|
2872
|
+
this.checkAndSeen();
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
componentDidUpdate(prevProps) {
|
|
2876
|
+
if (prevProps.cid !== this.props.cid) this.loadConvo();
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
render() {
|
|
2880
|
+
if (this.state.error) return this.renderError();
|
|
2881
|
+
let events = util/* default.map */.Z.map(this.props.store.listEvents(this.props.cid));
|
|
2882
|
+
|
|
2883
|
+
if (!this.state.loading && util/* default.size */.Z.size(events) === 0) {
|
|
2884
|
+
return (0,preact_module.h)("div", {
|
|
2885
|
+
ref: ref => this.refBody = ref,
|
|
2886
|
+
class: "widget-body--events-container"
|
|
2887
|
+
}, (0,preact_module.h)("div", {
|
|
2888
|
+
class: "widget-body--empty"
|
|
2889
|
+
}, (0,preact_module.h)("div", {
|
|
2890
|
+
class: "widget-body--empty-icon"
|
|
2891
|
+
}), (0,preact_module.h)("div", {
|
|
2892
|
+
class: "widget-body--empty-text"
|
|
2893
|
+
}, this.props.t('empty_convo_text'))), (0,preact_module.h)(PoweredBy, {
|
|
2894
|
+
store: this.props.store
|
|
2895
|
+
}));
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
events = util/* default.orderBy */.Z.orderBy(events, 'created', 'asc');
|
|
2899
|
+
let convo = this.props.store.matchConvo(this.props.cid);
|
|
2900
|
+
events = util/* default.map */.Z.map(events, ev => ({
|
|
2901
|
+
ev: ev
|
|
2902
|
+
}));
|
|
2903
|
+
processEvents(convo, events);
|
|
2904
|
+
let $events = util/* default.map */.Z.map(events, ev => (0,preact_module.h)(Event, {
|
|
2905
|
+
store: this.props.store,
|
|
2906
|
+
onFormSubmit: this.props.onFormSubmit,
|
|
2907
|
+
onSend: this.props.onSend,
|
|
2908
|
+
onPostback: this.props.onPostback,
|
|
2909
|
+
event: ev,
|
|
2910
|
+
t: this.props.t,
|
|
2911
|
+
key: ev.ev.id
|
|
2912
|
+
}));
|
|
2913
|
+
let $loading = null;
|
|
2914
|
+
let style = 'opacity: 1 !important';
|
|
2915
|
+
|
|
2916
|
+
if (this.state.loading || this.props.creating) {
|
|
2917
|
+
$loading = (0,preact_module.h)(Spinner, {
|
|
2918
|
+
static: true,
|
|
2919
|
+
mode: "blue",
|
|
2920
|
+
size: "120",
|
|
2921
|
+
center: true
|
|
2922
|
+
});
|
|
2923
|
+
style = 'opacity: 0 !important';
|
|
2924
|
+
}
|
|
2925
|
+
|
|
2926
|
+
return (0,preact_module.h)(preact_module/* Fragment */.HY, null, $loading, (0,preact_module.h)("div", {
|
|
2927
|
+
style: style,
|
|
2928
|
+
ref: ref => this.refBody = ref,
|
|
2929
|
+
class: "widget-body--events-container",
|
|
2930
|
+
onMouseOver: this.checkAndSeen
|
|
2931
|
+
}, (0,preact_module.h)("div", {
|
|
2932
|
+
class: "widget-body--events"
|
|
2933
|
+
}, $events), (0,preact_module.h)(PoweredBy, {
|
|
2934
|
+
store: this.props.store
|
|
2935
|
+
})));
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
renderError() {
|
|
2939
|
+
let $tryAgainBtn = (0,preact_module.h)("a", {
|
|
2940
|
+
href: "#",
|
|
2941
|
+
onclick: _ => this.loadConvo()
|
|
2942
|
+
}, this.props.t('try_again'));
|
|
2943
|
+
if (this.state.loading) $tryAgainBtn = (0,preact_module.h)(Spinner, {
|
|
2944
|
+
size: "16",
|
|
2945
|
+
mode: "blue"
|
|
2946
|
+
});
|
|
2947
|
+
return (0,preact_module.h)("div", {
|
|
2948
|
+
class: "widget-body--events-container widget-body--events-container__error"
|
|
2949
|
+
}, (0,preact_module.h)("img", {
|
|
2950
|
+
alt: "empty",
|
|
2951
|
+
src: convoemptyimg
|
|
2952
|
+
}), (0,preact_module.h)("div", {
|
|
2953
|
+
class: "widget_body__events__error_msg"
|
|
2954
|
+
}, this.props.t('load_convo_error')), (0,preact_module.h)("div", {
|
|
2955
|
+
class: "widget_body__events__error_retry"
|
|
2956
|
+
}, $tryAgainBtn));
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
focus() {
|
|
2960
|
+
let events = this.props.store.listEvents(this.props.cid);
|
|
2961
|
+
events = util/* default.orderBy */.Z.orderBy(util/* default.map */.Z.map(events), 'created', 'desc');
|
|
2962
|
+
var last_agent_sent;
|
|
2963
|
+
|
|
2964
|
+
for (let ev of events) {
|
|
2965
|
+
if (util/* default.get */.Z.get(ev, 'type') !== 'message_sent') continue;
|
|
2966
|
+
if (util/* default.get */.Z.get(ev, 'by.type') === 'user') continue;
|
|
2967
|
+
last_agent_sent = ev;
|
|
2968
|
+
break;
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
if (util/* default.get */.Z.get(last_agent_sent, 'by.type') === 'user') last_agent_sent = null;
|
|
2972
|
+
let attachments = util/* default.get */.Z.get(last_agent_sent, 'data.message.attachments', []);
|
|
2973
|
+
let convo = this.props.store.matchConvo(this.props.cid);
|
|
2974
|
+
let pendingForms = util/* default.filter */.Z.filter(attachments, att => {
|
|
2975
|
+
if (!att) return false;
|
|
2976
|
+
if (att.type !== 'form' && att.type !== 'ask_info_form') return false;
|
|
2977
|
+
var form = att.form;
|
|
2978
|
+
if (!form) return false;
|
|
2979
|
+
var state = util/* default.parseJSON */.Z.parseJSON(form.state) || {};
|
|
2980
|
+
if (!state.require_finished && att.type !== 'ask_info_form') return false;
|
|
2981
|
+
if (Events_isSummited(att.form)) return false;
|
|
2982
|
+
if (convo.state === 'ended') return false;
|
|
2983
|
+
return true;
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
onEvent(newev) {
|
|
2988
|
+
if (util/* default.convoOfEv */.Z.convoOfEv(newev) !== this.props.cid) return;
|
|
2989
|
+
let isBottom = this.isBottom();
|
|
2990
|
+
var byme = false;
|
|
2991
|
+
if (util/* default.get */.Z.get(newev, 'type') === 'message_sent' && newev.id === util/* default.getMsgField */.Z.getMsgField(newev, 'idempotency')) byme = true;
|
|
2992
|
+
if (byme || isBottom) this.scrollToBottom();
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
async loadConvo() {
|
|
2996
|
+
if (!this.props.cid) return;
|
|
2997
|
+
this.lastContentOffsetY = 0;
|
|
2998
|
+
this.setState({
|
|
2999
|
+
loading: true
|
|
3000
|
+
});
|
|
3001
|
+
let events = this.props.store.listEvents(this.props.cid);
|
|
3002
|
+
|
|
3003
|
+
if (util/* default.size */.Z.size(events) === 0) {
|
|
3004
|
+
let cid = this.props.cid;
|
|
3005
|
+
let {
|
|
3006
|
+
error
|
|
3007
|
+
} = await this.props.store.fetchMoreEvents(cid);
|
|
3008
|
+
this.setState({
|
|
3009
|
+
loading: false
|
|
3010
|
+
});
|
|
3011
|
+
if (cid !== this.props.cid) return;
|
|
3012
|
+
|
|
3013
|
+
if (error) {
|
|
3014
|
+
this.setState({
|
|
3015
|
+
error: true
|
|
3016
|
+
});
|
|
3017
|
+
return;
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
this.setState({
|
|
3022
|
+
loading: true
|
|
3023
|
+
});
|
|
3024
|
+
this.props.store.fetchMoreEvents(this.props.cid);
|
|
3025
|
+
this.setState({
|
|
3026
|
+
error: false
|
|
3027
|
+
});
|
|
3028
|
+
this.scrollToBottom();
|
|
3029
|
+
setTimeout(() => this.setState({
|
|
3030
|
+
loading: false
|
|
3031
|
+
}), 50);
|
|
3032
|
+
}
|
|
3033
|
+
|
|
3034
|
+
isBottom() {
|
|
3035
|
+
let $container = this.refBody;
|
|
3036
|
+
if (!$container) return false;
|
|
3037
|
+
return $container.scrollHeight < $container.scrollTop + $container.offsetHeight + 50;
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
scrollToBottom() {
|
|
3041
|
+
setTimeout(() => {
|
|
3042
|
+
const $div = this.refBody;
|
|
3043
|
+
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
3044
|
+
});
|
|
3045
|
+
setTimeout(() => {
|
|
3046
|
+
const $div = this.refBody;
|
|
3047
|
+
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
3048
|
+
}, 200);
|
|
3049
|
+
|
|
3050
|
+
if (this.props.isShow) {
|
|
3051
|
+
if (this.props.store.browserVisibility === 'visible' && document.hasFocus()) {
|
|
3052
|
+
this.props.store.seenConvo(this.props.cid);
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
function processEvents(convo, events) {
|
|
3060
|
+
events = events.filter(event => visibleEvent(event.ev));
|
|
3061
|
+
if (events.length < 1) return;
|
|
3062
|
+
|
|
3063
|
+
for (var i = 1; i < events.length; i++) {
|
|
3064
|
+
let curEvent = events[i];
|
|
3065
|
+
let lastEvent = events[i - 1];
|
|
3066
|
+
|
|
3067
|
+
if (visibleEvent(curEvent.ev)) {
|
|
3068
|
+
let elapsedSec = util/* default.unixSec */.Z.unixSec(curEvent.ev.created) - util/* default.unixSec */.Z.unixSec(lastEvent.ev.created);
|
|
3069
|
+
if (elapsedSec > 120) curEvent.show_time = true;
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
for (var i = 0; i < events.length; i++) {
|
|
3074
|
+
let curEvent = events[i];
|
|
3075
|
+
|
|
3076
|
+
if (util/* default.get */.Z.get(curEvent, 'ev.type') === 'message_sent') {
|
|
3077
|
+
curEvent.show_time = true;
|
|
3078
|
+
break;
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
for (var i = 0; i < events.length; i++) {
|
|
3083
|
+
let curEvent = events[i];
|
|
3084
|
+
let prevEvent = events[i - 1];
|
|
3085
|
+
|
|
3086
|
+
if (curEvent.ev.type === 'message_sent') {
|
|
3087
|
+
curEvent.mode = 'lead';
|
|
3088
|
+
|
|
3089
|
+
if (util/* default.get */.Z.get(prevEvent, 'ev.type') === 'message_sent' && util/* default.get */.Z.get(prevEvent, 'ev.by.id') === util/* default.get */.Z.get(curEvent, 'ev.by.id')) {
|
|
3090
|
+
curEvent.mode = 'follow';
|
|
3091
|
+
}
|
|
3092
|
+
|
|
3093
|
+
continue;
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
|
|
3098
|
+
function visibleEvent(ev) {
|
|
3099
|
+
let type = util/* default.get */.Z.get(ev, 'type');
|
|
3100
|
+
return type === 'message_sent' || type === 'conversation_state_updated';
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
function Events_isSummited(form) {
|
|
3104
|
+
let fields = util/* default.get */.Z.get(form, 'fields') || [];
|
|
3105
|
+
return util/* default.find */.Z.find(fields, field => !!field.answered);
|
|
3106
|
+
}
|
|
3107
|
+
;// CONCATENATED MODULE: ./src/chatbox/Typing.js
|
|
3108
|
+
|
|
3109
|
+
|
|
3110
|
+
|
|
3111
|
+
class Typing extends common/* Com */.M {
|
|
3112
|
+
constructor(props) {
|
|
3113
|
+
super(props);
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
componentDidMount() {
|
|
3117
|
+
this.setState({
|
|
3118
|
+
isShow: false,
|
|
3119
|
+
ev: {}
|
|
3120
|
+
});
|
|
3121
|
+
this.props.store.onConvoEvent(this, ev => {
|
|
3122
|
+
if (util/* default.convoOfEv */.Z.convoOfEv(ev) !== this.props.cid) return;
|
|
3123
|
+
let user = this.props.store.matchUser();
|
|
3124
|
+
if (util/* default.get */.Z.get(ev, 'by.id') === user.id) return;
|
|
3125
|
+
let oldby = util/* default.get */.Z.get(this.state.ev, 'by.id');
|
|
3126
|
+
if (oldby && util/* default.get */.Z.get(ev, 'by.id') !== oldby) return;
|
|
3127
|
+
|
|
3128
|
+
if (util/* default.get */.Z.get(ev, 'type') === 'message_sent') {
|
|
3129
|
+
if (this.timer) clearTimeout(this.timer);
|
|
3130
|
+
this.timer = null;
|
|
3131
|
+
this.setState({
|
|
3132
|
+
isShow: false
|
|
3133
|
+
});
|
|
3134
|
+
return;
|
|
3135
|
+
}
|
|
3136
|
+
|
|
3137
|
+
if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
|
|
3138
|
+
this.setState({
|
|
3139
|
+
ev: ev,
|
|
3140
|
+
isShow: true
|
|
3141
|
+
});
|
|
3142
|
+
if (this.timer) clearTimeout(this.timer);
|
|
3143
|
+
this.timer = setTimeout(() => {
|
|
3144
|
+
if (util/* default.convoOfEv */.Z.convoOfEv(ev) !== this.props.cid) return;
|
|
3145
|
+
this.timer = null;
|
|
3146
|
+
this.setState({
|
|
3147
|
+
isShow: false
|
|
3148
|
+
});
|
|
3149
|
+
}, 10000);
|
|
3150
|
+
});
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
render() {
|
|
3154
|
+
let account = this.props.store.matchAccount();
|
|
3155
|
+
var cls = this.state.isShow ? '' : 'typing--hidden';
|
|
3156
|
+
let byid = util/* default.get */.Z.get(this.state.ev, 'by.display_id', util/* default.get */.Z.get(this.state.ev, 'by.id'));
|
|
3157
|
+
let agentName = util/* default.getAgentDisplayName */.Z.getAgentDisplayName(account, this.props.store.matchAgent(byid));
|
|
3158
|
+
return (0,preact_module.h)("div", {
|
|
3159
|
+
class: `typing ${cls}`
|
|
3160
|
+
}, agentName, " ", this.props.t('typing'));
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
}
|
|
3164
|
+
;// CONCATENATED MODULE: ./src/chatbox/releaseAnimation.js
|
|
3165
|
+
|
|
3166
|
+
/* harmony default export */ const releaseAnimation = (class {
|
|
3167
|
+
constructor(config) {
|
|
3168
|
+
this.duration = config.duration || 100;
|
|
3169
|
+
this.breakingV = config.breakingV || 7.0;
|
|
3170
|
+
this.maxY = config.maxY || 500;
|
|
3171
|
+
this.minY = config.minY || 0;
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3174
|
+
play(v, y0, cb) {
|
|
3175
|
+
this.stop();
|
|
3176
|
+
var t0;
|
|
3177
|
+
|
|
3178
|
+
var run = t => {
|
|
3179
|
+
if (!t) t = new util/* default.Date */.Z.Date().getTime();
|
|
3180
|
+
var deltaT = t - t0;
|
|
3181
|
+
var [newy, done] = this.calcY(v, y0, deltaT);
|
|
3182
|
+
cb(newy);
|
|
3183
|
+
if (done) return this.stop();
|
|
3184
|
+
this.animationframe = window.requestAnimationFrame(run);
|
|
3185
|
+
};
|
|
3186
|
+
|
|
3187
|
+
this.animationframe = window.requestAnimationFrame(t => {
|
|
3188
|
+
t0 = t || new util/* default.Date */.Z.Date().getTime();
|
|
3189
|
+
run(t0);
|
|
3190
|
+
});
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
calcY(v, y0, t) {
|
|
3194
|
+
var towardY;
|
|
3195
|
+
if (y0 > this.maxY) towardY = this.maxY;else if (y0 < this.minY) towardY = this.minY;else if (Math.abs(v) < this.breakingV) {
|
|
3196
|
+
if (Math.abs(this.maxY - y0) < Math.abs(this.minY - y0)) {
|
|
3197
|
+
towardY = this.maxY;
|
|
3198
|
+
} else {
|
|
3199
|
+
towardY = this.minY;
|
|
3200
|
+
}
|
|
3201
|
+
} else {
|
|
3202
|
+
if (v < 0) towardY = this.maxY;else towardY = this.minY;
|
|
3203
|
+
}
|
|
3204
|
+
var y = linearTransform(y0, towardY, t, this.duration);
|
|
3205
|
+
return [y, eqFloat(y, towardY)];
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
stop() {
|
|
3209
|
+
window.cancelAnimationFrame(this.animationframe);
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
});
|
|
3213
|
+
|
|
3214
|
+
function linearTransform(from, to, t, duration) {
|
|
3215
|
+
if (eqFloat(from, to)) return from;
|
|
3216
|
+
var s = to - from;
|
|
3217
|
+
var v = s / duration;
|
|
3218
|
+
var x = from + v * t;
|
|
3219
|
+
if (from < to && x > to) x = to;else if (to < from && x < to) x = to;
|
|
3220
|
+
return x;
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
function eqFloat(a, b) {
|
|
3224
|
+
return Math.abs(a - b) <= 0.001;
|
|
3225
|
+
}
|
|
3226
|
+
;// CONCATENATED MODULE: ./src/chatbox/Rating.js
|
|
3227
|
+
function Rating_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3228
|
+
|
|
3229
|
+
|
|
3230
|
+
|
|
3231
|
+
const POPUP_MAX_HEIGHT = 400;
|
|
3232
|
+
const POPUP_HARD_MAX_HEIGHT = 500;
|
|
3233
|
+
const POPUP_MIN_HEIGHT = 0;
|
|
3234
|
+
|
|
3235
|
+
|
|
3236
|
+
class Rating extends common/* Com */.M {
|
|
3237
|
+
constructor(props) {
|
|
3238
|
+
super(props);
|
|
3239
|
+
|
|
3240
|
+
Rating_defineProperty(this, "state", {
|
|
3241
|
+
hide: true,
|
|
3242
|
+
ratingHeight: 0,
|
|
3243
|
+
overlayOpacity: 0.3,
|
|
3244
|
+
comment: ''
|
|
3245
|
+
});
|
|
3246
|
+
|
|
3247
|
+
this.refComment = (0,preact_module/* createRef */.Vf)();
|
|
3248
|
+
this.refRating = (0,preact_module/* createRef */.Vf)();
|
|
3249
|
+
this.refHandle = (0,preact_module/* createRef */.Vf)();
|
|
3250
|
+
}
|
|
3251
|
+
|
|
3252
|
+
componentDidMount() {
|
|
3253
|
+
this.props.store.onUpdate(this, () => {
|
|
3254
|
+
if (this.shoudDisplay()) this.open();
|
|
3255
|
+
});
|
|
3256
|
+
this.props.store.onConvoEvent(this, ev => {
|
|
3257
|
+
var cid = util/* default.convoOfEv */.Z.convoOfEv(ev);
|
|
3258
|
+
if (cid !== this.props.cid) return;
|
|
3259
|
+
if (this.shoudDisplay()) this.open();
|
|
3260
|
+
});
|
|
3261
|
+
|
|
3262
|
+
this.mouseUp = e => this.onMouseUp(e);
|
|
3263
|
+
|
|
3264
|
+
this.mouseMove = e => this.onMouseMove(e);
|
|
3265
|
+
|
|
3266
|
+
this.mouseDown = e => this.onMouseDown(e);
|
|
3267
|
+
|
|
3268
|
+
var $ratingHandle = this.refHandle.current;
|
|
3269
|
+
$ratingHandle.addEventListener('mousedown', this.mouseDown, {
|
|
3270
|
+
passive: true
|
|
3271
|
+
});
|
|
3272
|
+
$ratingHandle.addEventListener('touchstart', this.mouseDown, {
|
|
3273
|
+
passive: true
|
|
3274
|
+
});
|
|
3275
|
+
window.addEventListener('mouseup', this.mouseUp, {
|
|
3276
|
+
passive: true
|
|
3277
|
+
});
|
|
3278
|
+
window.addEventListener('touchend', this.mouseUp, {
|
|
3279
|
+
passive: true
|
|
3280
|
+
});
|
|
3281
|
+
window.addEventListener('mousemove', this.mouseMove, {
|
|
3282
|
+
passive: true
|
|
3283
|
+
});
|
|
3284
|
+
window.addEventListener('touchmove', this.mouseMove, {
|
|
3285
|
+
passive: true
|
|
3286
|
+
});
|
|
3287
|
+
this.animation = new releaseAnimation({
|
|
3288
|
+
maxY: POPUP_MAX_HEIGHT,
|
|
3289
|
+
minY: POPUP_MIN_HEIGHT,
|
|
3290
|
+
duration: 150
|
|
3291
|
+
});
|
|
3292
|
+
this.close();
|
|
3293
|
+
if (this.shoudDisplay() || this.props.forceView === 'rating') this.open();
|
|
3294
|
+
}
|
|
3295
|
+
|
|
3296
|
+
componentWillUnmount() {
|
|
3297
|
+
var $ratingHandle = this.refHandle.current;
|
|
3298
|
+
$ratingHandle.removeEventListener('mousedown', this.mouseDown, 0);
|
|
3299
|
+
$ratingHandle.removeEventListener('touchstart', this.mouseDown, 0);
|
|
3300
|
+
window.removeEventListener('mouseup', this.mouseUp, 0);
|
|
3301
|
+
window.removeEventListener('touchend', this.mouseUp, 0);
|
|
3302
|
+
window.removeEventListener('mousemove', this.mouseMove, 0);
|
|
3303
|
+
window.removeEventListener('touchmove', this.mouseMove, 0);
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
render() {
|
|
3307
|
+
let cls = this.state.hide ? 'd-none' : '';
|
|
3308
|
+
return (0,preact_module.h)("div", {
|
|
3309
|
+
class: cls
|
|
3310
|
+
}, (0,preact_module.h)("div", {
|
|
3311
|
+
class: "rating--overlay",
|
|
3312
|
+
style: `opacity: ${this.state.overlayOpacity * 0.5} !important;`
|
|
3313
|
+
}), (0,preact_module.h)("div", {
|
|
3314
|
+
class: "rating",
|
|
3315
|
+
ref: this.refRating,
|
|
3316
|
+
style: `color:red; height: ${this.state.ratingHeight}px !important;`
|
|
3317
|
+
}, (0,preact_module.h)("div", {
|
|
3318
|
+
class: "rating--handle",
|
|
3319
|
+
ref: this.refHandle
|
|
3320
|
+
}, (0,preact_module.h)("div", {
|
|
3321
|
+
class: "rating--thumb"
|
|
3322
|
+
})), (0,preact_module.h)("div", {
|
|
3323
|
+
class: "rating--content"
|
|
3324
|
+
}, (0,preact_module.h)("div", {
|
|
3325
|
+
class: "rating--heading"
|
|
3326
|
+
}, this.props.t('rating_title'), (0,preact_module.h)("div", {
|
|
3327
|
+
class: "rating--close-btn",
|
|
3328
|
+
onClick: e => this.onCloseRating(e)
|
|
3329
|
+
})), (0,preact_module.h)("div", {
|
|
3330
|
+
class: "rating--description"
|
|
3331
|
+
}, this.props.t('rating_description')), (0,preact_module.h)("textarea", {
|
|
3332
|
+
ref: this.refComment,
|
|
3333
|
+
type: "text",
|
|
3334
|
+
class: "rating--comment"
|
|
3335
|
+
}), (0,preact_module.h)("div", {
|
|
3336
|
+
class: "rating-faces-container"
|
|
3337
|
+
}, (0,preact_module.h)("div", {
|
|
3338
|
+
class: "rating-face-container",
|
|
3339
|
+
onClick: e => this.onRatingPoor(e)
|
|
3340
|
+
}, (0,preact_module.h)("img", {
|
|
3341
|
+
alt: "poor",
|
|
3342
|
+
src: __webpack_require__(8367)
|
|
3343
|
+
}), (0,preact_module.h)("p", {
|
|
3344
|
+
class: "rating-face--text"
|
|
3345
|
+
}, this.props.t('poor'))), (0,preact_module.h)("div", {
|
|
3346
|
+
class: "rating-face-container",
|
|
3347
|
+
onClick: e => this.onRatingAverage(e)
|
|
3348
|
+
}, (0,preact_module.h)("img", {
|
|
3349
|
+
alt: "average",
|
|
3350
|
+
src: __webpack_require__(6535)
|
|
3351
|
+
}), (0,preact_module.h)("p", {
|
|
3352
|
+
class: "rating-face--text"
|
|
3353
|
+
}, this.props.t('average'))), (0,preact_module.h)("div", {
|
|
3354
|
+
class: "rating-face-container",
|
|
3355
|
+
onClick: e => this.onRatingGreat(e)
|
|
3356
|
+
}, (0,preact_module.h)("img", {
|
|
3357
|
+
alt: "great",
|
|
3358
|
+
src: __webpack_require__(3824)
|
|
3359
|
+
}), (0,preact_module.h)("p", {
|
|
3360
|
+
class: "rating-face--text"
|
|
3361
|
+
}, this.props.t('great')))), (0,preact_module.h)("div", {
|
|
3362
|
+
class: "rating-no-thanks",
|
|
3363
|
+
onClick: e => this.onCloseRating(e)
|
|
3364
|
+
}, this.props.t('no_thanks')))));
|
|
3365
|
+
}
|
|
3366
|
+
|
|
3367
|
+
shoudDisplay() {
|
|
3368
|
+
if (!this.props.cid) return false;
|
|
3369
|
+
var requested;
|
|
3370
|
+
var rated;
|
|
3371
|
+
var ended;
|
|
3372
|
+
let user = this.props.store.matchUser();
|
|
3373
|
+
util/* default.map */.Z.map(this.props.store.listEvents(this.props.cid), ev => {
|
|
3374
|
+
if (util/* default.get */.Z.get(ev, 'type') === 'conversation_state_updated' && util/* default.get */.Z.get(ev, 'data.conversation.state') === 'ended') {
|
|
3375
|
+
ended = ev;
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3378
|
+
if (util/* default.get */.Z.get(ev, 'type') === 'conversation_rating_requested') requested = ev;
|
|
3379
|
+
if (util/* default.get */.Z.get(ev, 'type') === 'conversation_rated' && util/* default.get */.Z.get(ev, 'by.id') === user.id) rated = ev;
|
|
3380
|
+
});
|
|
3381
|
+
if (rated) return false;
|
|
3382
|
+
let accountSetting = this.props.plugin.chatbox;
|
|
3383
|
+
var auto = accountSetting.auto_request_rating && ended;
|
|
3384
|
+
return requested || auto;
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
onCloseRating() {
|
|
3388
|
+
this.props.onRate && this.props.onRate({
|
|
3389
|
+
no_rating: true,
|
|
3390
|
+
comment: this.refComment.current.value
|
|
3391
|
+
});
|
|
3392
|
+
this.close();
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3395
|
+
onRatingPoor() {
|
|
3396
|
+
this.props.onRate && this.props.onRate({
|
|
3397
|
+
rating: 1,
|
|
3398
|
+
comment: this.refComment.current.value
|
|
3399
|
+
});
|
|
3400
|
+
this.close();
|
|
3401
|
+
}
|
|
3402
|
+
|
|
3403
|
+
onRatingAverage() {
|
|
3404
|
+
this.props.onRate && this.props.onRate({
|
|
3405
|
+
rating: 3,
|
|
3406
|
+
comment: this.refComment.current.value
|
|
3407
|
+
});
|
|
3408
|
+
this.close();
|
|
3409
|
+
}
|
|
3410
|
+
|
|
3411
|
+
onRatingGreat() {
|
|
3412
|
+
this.props.onRate && this.props.onRate({
|
|
3413
|
+
rating: 5,
|
|
3414
|
+
comment: this.refComment.current.value
|
|
3415
|
+
});
|
|
3416
|
+
this.close();
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3419
|
+
open() {
|
|
3420
|
+
if (!this.state.hide) return;
|
|
3421
|
+
this.setState({
|
|
3422
|
+
hide: false
|
|
3423
|
+
});
|
|
3424
|
+
if (!this.refRating.current) return;
|
|
3425
|
+
setTimeout(() => {
|
|
3426
|
+
if (this.refComment.current) this.refComment.current.focus();
|
|
3427
|
+
}, 400);
|
|
3428
|
+
this.refComment.current.value = '';
|
|
3429
|
+
var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
|
|
3430
|
+
var h0 = parseFloat(popupStyle.height);
|
|
3431
|
+
this.animation.play(-20, h0, h => {
|
|
3432
|
+
this.setState({
|
|
3433
|
+
ratingHeight: h,
|
|
3434
|
+
overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
|
|
3435
|
+
});
|
|
3436
|
+
});
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3439
|
+
close() {
|
|
3440
|
+
if (this.state.hide) return;
|
|
3441
|
+
if (!this.refRating.current) return;
|
|
3442
|
+
var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
|
|
3443
|
+
var h0 = parseFloat(popupStyle.height);
|
|
3444
|
+
this.animation.play(20, h0, h => {
|
|
3445
|
+
this.setState({
|
|
3446
|
+
ratingHeight: h,
|
|
3447
|
+
overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
|
|
3448
|
+
});
|
|
3449
|
+
|
|
3450
|
+
if (h < POPUP_MIN_HEIGHT + 10) {
|
|
3451
|
+
if (!this.state.hide) {
|
|
3452
|
+
this.setState({
|
|
3453
|
+
hide: true
|
|
3454
|
+
});
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
});
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3460
|
+
onMouseDown(e) {
|
|
3461
|
+
this.mousePushed = true;
|
|
3462
|
+
this.animation.stop();
|
|
3463
|
+
e.preventDefault();
|
|
3464
|
+
if (e.touches && e.touches[0]) e = e.touches[0];
|
|
3465
|
+
this.mousePushedDy = e.pageY - window.pageYOffset - this.refRating.current.getBoundingClientRect().y;
|
|
3466
|
+
}
|
|
3467
|
+
|
|
3468
|
+
onMouseUp(e) {
|
|
3469
|
+
if (!this.mousePushed) return;
|
|
3470
|
+
if (e.touches && e.touches[0]) e = e.touches[0];
|
|
3471
|
+
this.mousePushed = false;
|
|
3472
|
+
var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
|
|
3473
|
+
var h0 = parseFloat(popupStyle.height);
|
|
3474
|
+
this.animation.play(this.mouseVelocity, h0, h => {
|
|
3475
|
+
this.setState({
|
|
3476
|
+
ratingHeight: h,
|
|
3477
|
+
overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
|
|
3478
|
+
});
|
|
3479
|
+
|
|
3480
|
+
if (h < POPUP_MIN_HEIGHT + 10) {
|
|
3481
|
+
if (!this.state.hide) {
|
|
3482
|
+
this.setState({
|
|
3483
|
+
hide: true
|
|
3484
|
+
});
|
|
3485
|
+
this.props.onRate && this.props.onRate({
|
|
3486
|
+
no_rating: true
|
|
3487
|
+
});
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
});
|
|
3491
|
+
}
|
|
3492
|
+
|
|
3493
|
+
onMouseMove(e) {
|
|
3494
|
+
if (!this.mousePushed) return;
|
|
3495
|
+
if (e.touches && e.touches[0]) e = e.touches[0];
|
|
3496
|
+
var my = e.pageY;
|
|
3497
|
+
this.mouseVelocity = my - this.lastMouseY;
|
|
3498
|
+
this.lastMouseY = my;
|
|
3499
|
+
my = my - this.mousePushedDy;
|
|
3500
|
+
var K = 10000;
|
|
3501
|
+
var height = this.refRating.current.getBoundingClientRect().bottom - my;
|
|
3502
|
+
|
|
3503
|
+
if (height > POPUP_MAX_HEIGHT) {
|
|
3504
|
+
var beta = K / (POPUP_HARD_MAX_HEIGHT - POPUP_MAX_HEIGHT) - POPUP_MAX_HEIGHT;
|
|
3505
|
+
height = POPUP_HARD_MAX_HEIGHT - K / (height + beta);
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3508
|
+
this.setState({
|
|
3509
|
+
ratingHeight: height,
|
|
3510
|
+
overlayOpacity: Math.min(1, (height - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
|
|
3511
|
+
});
|
|
3512
|
+
}
|
|
3513
|
+
|
|
3514
|
+
}
|
|
3515
|
+
;// CONCATENATED MODULE: ./src/chatbox/Widget.js
|
|
3516
|
+
|
|
3517
|
+
|
|
3518
|
+
|
|
3519
|
+
|
|
3520
|
+
|
|
3521
|
+
|
|
3522
|
+
var send = __webpack_require__(9737);
|
|
3523
|
+
|
|
3524
|
+
var checkedimg = __webpack_require__(8909);
|
|
3525
|
+
|
|
3526
|
+
var empty = __webpack_require__(29);
|
|
3527
|
+
|
|
3528
|
+
|
|
3529
|
+
|
|
3530
|
+
|
|
3531
|
+
|
|
3532
|
+
|
|
3533
|
+
const Widget_defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png';
|
|
3534
|
+
|
|
3535
|
+
|
|
3536
|
+
|
|
3537
|
+
|
|
3538
|
+
class Widget extends common/* Com */.M {
|
|
3539
|
+
constructor(props) {
|
|
3540
|
+
super(props);
|
|
3541
|
+
this.userSent = {};
|
|
3542
|
+
this.setState({
|
|
3543
|
+
creating: false,
|
|
3544
|
+
clickedJoin: false,
|
|
3545
|
+
formData: {}
|
|
3546
|
+
});
|
|
3547
|
+
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
3548
|
+
}
|
|
3549
|
+
|
|
3550
|
+
componentDidMount() {
|
|
3551
|
+
if (!this.props.store.isMobile()) this.focusInput();
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
componentDidUpdate(prevProp) {
|
|
3555
|
+
if (prevProp.isShow !== this.props.isShow) {
|
|
3556
|
+
if (this.props.isShow && !this.props.store.isMobile()) this.focusInput();
|
|
3557
|
+
if (this.props.isShow && this.props.store.isMobile()) this.blur();
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3560
|
+
if (prevProp.cid !== this.props.cid) {
|
|
3561
|
+
this.setState({
|
|
3562
|
+
clickedJoin: false
|
|
3563
|
+
});
|
|
3564
|
+
setTimeout(() => {
|
|
3565
|
+
this.events && this.events.focus();
|
|
3566
|
+
if (!this.props.store.isMobile()) this.focusInput();
|
|
3567
|
+
}, 100);
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3570
|
+
this.updateFormDataFields();
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
shouldShowForm() {
|
|
3574
|
+
let formRequired = this.isFormRequired();
|
|
3575
|
+
return formRequired && !this.props.cid || formRequired && this.props.cid && this.state.clickedJoin;
|
|
3576
|
+
}
|
|
3577
|
+
|
|
3578
|
+
render() {
|
|
3579
|
+
let formRequired = this.isFormRequired();
|
|
3580
|
+
let showform = this.shouldShowForm();
|
|
3581
|
+
let form;
|
|
3582
|
+
let accountSetting = this.props.plugin.chatbox || {};
|
|
3583
|
+
let acc = this.props.store.matchAccount() || {};
|
|
3584
|
+
let submitLabel = this.props.t('prechat_form_btn');
|
|
3585
|
+
if (util/* default.get */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
3586
|
+
let offlineEnabled = util/* default.get */.Z.get(accountSetting, 'offline_form.enabled');
|
|
3587
|
+
|
|
3588
|
+
if (this.isOffline(acc, accountSetting) && offlineEnabled) {
|
|
3589
|
+
form = accountSetting.offline_form;
|
|
3590
|
+
submitLabel = this.props.t('offline_form_btn');
|
|
3591
|
+
}
|
|
3592
|
+
|
|
3593
|
+
if (this.props.view === 'offline_form') {
|
|
3594
|
+
showform = true;
|
|
3595
|
+
form = accountSetting.offline_form;
|
|
3596
|
+
submitLabel = this.props.t('offline_form_btn');
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
if (this.props.view === 'prechat_form') {
|
|
3600
|
+
showform = true;
|
|
3601
|
+
form = accountSetting.prechat_form;
|
|
3602
|
+
submitLabel = this.props.t('prechat_form_btn');
|
|
3603
|
+
}
|
|
3604
|
+
|
|
3605
|
+
let $body = null;
|
|
3606
|
+
if (this.props.view === 'list') $body = this.renderConvoList();else if (showform) $body = this.renderForm(form, submitLabel);else $body = this.renderChat();
|
|
3607
|
+
let position = util/* default.get */.Z.get(accountSetting, 'desktop_button.position') || 'right';
|
|
3608
|
+
if (this.props.store.isMobile()) position = util/* default.get */.Z.get(accountSetting, 'mobile_button.position', position);
|
|
3609
|
+
let cls = 'widget-container widget-container--' + position;
|
|
3610
|
+
if (!this.props.isShow) cls += ' widget-container--hide';
|
|
3611
|
+
return (0,preact_module.h)("div", {
|
|
3612
|
+
class: cls
|
|
3613
|
+
}, (0,preact_module.h)(Header, {
|
|
3614
|
+
t: this.props.t,
|
|
3615
|
+
plugin: this.props.plugin,
|
|
3616
|
+
store: this.props.store,
|
|
3617
|
+
cid: this.props.cid,
|
|
3618
|
+
view: this.props.view,
|
|
3619
|
+
onClose: this.props.onClose,
|
|
3620
|
+
onGotoList: () => this.props.onGo({
|
|
3621
|
+
view: 'list'
|
|
3622
|
+
})
|
|
3623
|
+
}), $body);
|
|
3624
|
+
}
|
|
3625
|
+
|
|
3626
|
+
async submitPrechatForm(form) {
|
|
3627
|
+
var hasError = false;
|
|
3628
|
+
util/* default.map */.Z.map(this.state.formData, (field, key) => {
|
|
3629
|
+
if (field.is_required && (field.value === undefined || field.value === '' || util/* default.size */.Z.size(field.value) === 0 && Array.isArray(field.value))) {
|
|
3630
|
+
field.error = this.props.t('error_empty');
|
|
3631
|
+
hasError = true;
|
|
3632
|
+
} else field.error = '';
|
|
3633
|
+
|
|
3634
|
+
if (key.substr(5) === 'emails' && !util/* default.isEmail */.Z.isEmail(field.value) && field.is_required) {
|
|
3635
|
+
field.error = this.props.t('error_email_invalid');
|
|
3636
|
+
hasError = true;
|
|
3637
|
+
}
|
|
3638
|
+
|
|
3639
|
+
if (key.substr(5) === 'phones' && !util/* default.isPhone */.Z.isPhone(field.value) && field.is_required) {
|
|
3640
|
+
field.error = this.props.t('error_phone_invalid');
|
|
3641
|
+
hasError = true;
|
|
3642
|
+
}
|
|
3643
|
+
});
|
|
3644
|
+
if (hasError) return this.forceUpdate();
|
|
3645
|
+
let data = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
3646
|
+
let user = util/* default.cloneDeep */.Z.cloneDeep(this.props.store.matchUser());
|
|
3647
|
+
util/* default.map */.Z.map(data, (field, key) => {
|
|
3648
|
+
if (!key.startsWith('attr:')) return;
|
|
3649
|
+
var attr = {
|
|
3650
|
+
key: key.substr(5)
|
|
3651
|
+
};
|
|
3652
|
+
if (field.type === 'number') attr.number = parseInt(field.value);
|
|
3653
|
+
if (field.type === 'datetime') attr.datetime = new util/* default.Date */.Z.Date(field.value).toISOString();
|
|
3654
|
+
if (field.type === 'list') attr.list = field.value;
|
|
3655
|
+
if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
|
|
3656
|
+
util/* default.setUserAttr */.Z.setUserAttr(user, attr);
|
|
3657
|
+
});
|
|
3658
|
+
let firstmsg = util/* default.get */.Z.get(data, 'question.value');
|
|
3659
|
+
let groupid = util/* default.get */.Z.get(data, 'group.value', '');
|
|
3660
|
+
|
|
3661
|
+
if (this.props.cid) {
|
|
3662
|
+
this.props.store.setUser(user);
|
|
3663
|
+
this.setState({
|
|
3664
|
+
clickedJoin: false
|
|
3665
|
+
});
|
|
3666
|
+
await this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
3667
|
+
message: {
|
|
3668
|
+
text: firstmsg,
|
|
3669
|
+
format: 'plaintext',
|
|
3670
|
+
fields: [{
|
|
3671
|
+
key: 'to_agent_group',
|
|
3672
|
+
value: util/* default.stringify */.Z.stringify(groupid)
|
|
3673
|
+
}]
|
|
3674
|
+
}
|
|
3675
|
+
});
|
|
3676
|
+
if (form.end_conversation_after_submit) await this.props.store.endConvo(this.props.cid);
|
|
3677
|
+
return;
|
|
3678
|
+
}
|
|
3679
|
+
|
|
3680
|
+
this.setState({
|
|
3681
|
+
creating: true
|
|
3682
|
+
});
|
|
3683
|
+
let message = {
|
|
3684
|
+
text: firstmsg,
|
|
3685
|
+
format: 'plaintext'
|
|
3686
|
+
};
|
|
3687
|
+
let req = {
|
|
3688
|
+
group_id: groupid,
|
|
3689
|
+
message: firstmsg,
|
|
3690
|
+
locale: this.props.t.locale(),
|
|
3691
|
+
initial_by: user.id
|
|
3692
|
+
};
|
|
3693
|
+
this.setState({
|
|
3694
|
+
creatingError: null
|
|
3695
|
+
});
|
|
3696
|
+
const {
|
|
3697
|
+
error,
|
|
3698
|
+
convo
|
|
3699
|
+
} = await this.props.store.startConvo(req);
|
|
3700
|
+
this.props.store.setUser(user);
|
|
3701
|
+
|
|
3702
|
+
if (error) {
|
|
3703
|
+
this.setState({
|
|
3704
|
+
creating: false,
|
|
3705
|
+
creatingError: error
|
|
3706
|
+
});
|
|
3707
|
+
return;
|
|
3708
|
+
}
|
|
3709
|
+
|
|
3710
|
+
let newconvoid = convo.id;
|
|
3711
|
+
this.userSent[newconvoid] = true;
|
|
3712
|
+
this.props.onGo({
|
|
3713
|
+
view: 'chat',
|
|
3714
|
+
cid: newconvoid
|
|
3715
|
+
});
|
|
3716
|
+
this.props.store.sendConvoEvent(newconvoid, 'message_sent', {
|
|
3717
|
+
message
|
|
3718
|
+
});
|
|
3719
|
+
this.setState({
|
|
3720
|
+
creating: false,
|
|
3721
|
+
clickedJoin: false
|
|
3722
|
+
});
|
|
3723
|
+
if (!this.props.store.isMobile()) this.focusInput();
|
|
3724
|
+
}
|
|
3725
|
+
|
|
3726
|
+
formMounted(form) {
|
|
3727
|
+
let formData = this.fillForm(form);
|
|
3728
|
+
formData['question'] = {
|
|
3729
|
+
key: 'question',
|
|
3730
|
+
is_required: true,
|
|
3731
|
+
label: this.props.t.i18n(util/* default.get */.Z.get(form, `i18n_question_label`, {})) || form.question_label,
|
|
3732
|
+
type: 'text'
|
|
3733
|
+
};
|
|
3734
|
+
this.setState({
|
|
3735
|
+
formData
|
|
3736
|
+
});
|
|
3737
|
+
if (!this.props.store.isMobile()) this.focusInput();
|
|
3738
|
+
}
|
|
3739
|
+
|
|
3740
|
+
onBooleanChange(key, e) {
|
|
3741
|
+
let formData = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
3742
|
+
let field = util/* default.find */.Z.find(formData, (_, fkkey) => fkkey === key);
|
|
3743
|
+
if (!field) return;
|
|
3744
|
+
field.value = e.target.checked;
|
|
3745
|
+
this.setState({
|
|
3746
|
+
formData
|
|
3747
|
+
});
|
|
3748
|
+
}
|
|
3749
|
+
|
|
3750
|
+
onInputChange(key, val) {
|
|
3751
|
+
let formData = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
3752
|
+
let field = util/* default.find */.Z.find(formData, (_, fkkey) => fkkey === key);
|
|
3753
|
+
if (!field) return;
|
|
3754
|
+
field.value = val;
|
|
3755
|
+
this.setState({
|
|
3756
|
+
formData
|
|
3757
|
+
});
|
|
3758
|
+
}
|
|
3759
|
+
|
|
3760
|
+
onListAddItem(key, val) {
|
|
3761
|
+
let formData = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
3762
|
+
let field = util/* default.find */.Z.find(formData, (_, fkkey) => fkkey === key);
|
|
3763
|
+
if (!field) return;
|
|
3764
|
+
field.value = field.value || [];
|
|
3765
|
+
field.value.push(val);
|
|
3766
|
+
this.setState({
|
|
3767
|
+
formData
|
|
3768
|
+
});
|
|
3769
|
+
}
|
|
3770
|
+
|
|
3771
|
+
onListRemoveItem(key, index) {
|
|
3772
|
+
let formData = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
3773
|
+
let field = util/* default.find */.Z.find(formData, (_, fkkey) => fkkey === key);
|
|
3774
|
+
if (!field) return;
|
|
3775
|
+
field.value = field.value || [];
|
|
3776
|
+
field.value.splice(index, 1);
|
|
3777
|
+
this.setState({
|
|
3778
|
+
formData
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3781
|
+
|
|
3782
|
+
renderFields() {
|
|
3783
|
+
if (util/* default.size */.Z.size(this.state.formData) === 0) return null;
|
|
3784
|
+
let $fields = util/* default.map */.Z.map(this.state.formData, (field, key) => {
|
|
3785
|
+
let $field = null;
|
|
3786
|
+
var errclass = field.error ? 'input--error' : '';
|
|
3787
|
+
|
|
3788
|
+
if (field.type === 'text') {
|
|
3789
|
+
if (key === 'question') {
|
|
3790
|
+
$field = (0,preact_module.h)("textarea", {
|
|
3791
|
+
class: "form-control",
|
|
3792
|
+
ref: ref => {
|
|
3793
|
+
this['form_' + Widget_encode(key)] = ref;
|
|
3794
|
+
},
|
|
3795
|
+
value: field.value || '',
|
|
3796
|
+
onInput: e => this.onInputChange(key, e.target.value),
|
|
3797
|
+
row: "4",
|
|
3798
|
+
class: "form-control"
|
|
3799
|
+
});
|
|
3800
|
+
} else {
|
|
3801
|
+
$field = (0,preact_module.h)("input", {
|
|
3802
|
+
value: field.value || '',
|
|
3803
|
+
onInput: e => this.onInputChange(key, e.target.value),
|
|
3804
|
+
ref: ref => {
|
|
3805
|
+
this['form_' + Widget_encode(key)] = ref;
|
|
3806
|
+
},
|
|
3807
|
+
class: `form-control ${errclass}`,
|
|
3808
|
+
type: "text"
|
|
3809
|
+
});
|
|
3810
|
+
}
|
|
3811
|
+
} else if (field.type === 'number') {
|
|
3812
|
+
$field = (0,preact_module.h)("input", {
|
|
3813
|
+
value: field.value,
|
|
3814
|
+
onInput: e => this.onInputChange(key, e.target.value),
|
|
3815
|
+
ref: ref => {
|
|
3816
|
+
this['form_' + Widget_encode(key)] = ref;
|
|
3817
|
+
},
|
|
3818
|
+
class: `form-control ${errclass}`,
|
|
3819
|
+
type: "number"
|
|
3820
|
+
});
|
|
3821
|
+
} else if (field.type === 'boolean') {
|
|
3822
|
+
$field = (0,preact_module.h)("div", {
|
|
3823
|
+
class: "checkbox"
|
|
3824
|
+
}, (0,preact_module.h)("input", {
|
|
3825
|
+
type: "checkbox",
|
|
3826
|
+
id: 'form-checkbox' + Widget_encode(key),
|
|
3827
|
+
onInput: e => this.onBooleanChange(key, e),
|
|
3828
|
+
checked: field.value
|
|
3829
|
+
}), (0,preact_module.h)("label", {
|
|
3830
|
+
class: "checkbox--label",
|
|
3831
|
+
for: 'form-checkbox' + Widget_encode(key)
|
|
3832
|
+
}, field.label), (0,preact_module.h)("div", {
|
|
3833
|
+
class: "checkbox--check"
|
|
3834
|
+
}, (0,preact_module.h)("div", null)));
|
|
3835
|
+
} else if (field.type === 'group') {
|
|
3836
|
+
$field = util/* default.map */.Z.map(field.list, item => (0,preact_module.h)("div", {
|
|
3837
|
+
class: "radio"
|
|
3838
|
+
}, (0,preact_module.h)("input", {
|
|
3839
|
+
type: "radio",
|
|
3840
|
+
id: 'form-radio' + Widget_encode(key) + Widget_encode(item.value),
|
|
3841
|
+
checked: field.value === item.value,
|
|
3842
|
+
onInput: e => this.onInputChange(key, item.value)
|
|
3843
|
+
}), (0,preact_module.h)("label", {
|
|
3844
|
+
class: "radio--label",
|
|
3845
|
+
for: 'form-radio' + Widget_encode(key) + Widget_encode(item.value)
|
|
3846
|
+
}, item.label), (0,preact_module.h)("div", {
|
|
3847
|
+
class: "radio--check"
|
|
3848
|
+
}, (0,preact_module.h)("div", {
|
|
3849
|
+
class: "inside"
|
|
3850
|
+
}))));
|
|
3851
|
+
} else if (field.type === 'list') {
|
|
3852
|
+
let selected = this.state.formData[key].value || [];
|
|
3853
|
+
let items = util/* default.filter */.Z.filter(util/* default.get */.Z.get(field, 'list', []), item => {
|
|
3854
|
+
return !util/* default.includes */.Z.includes(selected, item);
|
|
3855
|
+
});
|
|
3856
|
+
$field = (0,preact_module.h)(ListField, {
|
|
3857
|
+
selected: selected,
|
|
3858
|
+
items: items,
|
|
3859
|
+
onAddItem: item => this.onListAddItem(key, item),
|
|
3860
|
+
onRemoveItem: item => this.onListRemoveItem(key, item)
|
|
3861
|
+
});
|
|
3862
|
+
} else if (field.type === 'datetime') {
|
|
3863
|
+
$field = (0,preact_module.h)("input", {
|
|
3864
|
+
value: field.value,
|
|
3865
|
+
onInput: e => this.onInputChange(key, e.target.value),
|
|
3866
|
+
class: `form-control ${errclass}`,
|
|
3867
|
+
type: "date"
|
|
3868
|
+
});
|
|
3869
|
+
}
|
|
3870
|
+
|
|
3871
|
+
let label = '';
|
|
3872
|
+
|
|
3873
|
+
if (field.key === 'fullname') {
|
|
3874
|
+
label = this.props.t('fullname');
|
|
3875
|
+
} else if (field.key === 'emails') {
|
|
3876
|
+
label = this.props.t('email');
|
|
3877
|
+
} else if (field.key === 'phones') {
|
|
3878
|
+
label = this.props.t('phones');
|
|
3879
|
+
} else if (field.key === 'question') {
|
|
3880
|
+
label = field.label || this.props.t('your_question');
|
|
3881
|
+
}
|
|
3882
|
+
|
|
3883
|
+
if (field.label) label = field.label;
|
|
3884
|
+
return (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
3885
|
+
class: "label"
|
|
3886
|
+
}, label, field.is_required ? (0,preact_module.h)("span", {
|
|
3887
|
+
class: "ml-1 red"
|
|
3888
|
+
}, "*") : ''), field.error ? (0,preact_module.h)("div", {
|
|
3889
|
+
class: "form-control--valid-input--error"
|
|
3890
|
+
}, field.error) : '', $field);
|
|
3891
|
+
});
|
|
3892
|
+
return (0,preact_module.h)("div", {
|
|
3893
|
+
class: "pt-2"
|
|
3894
|
+
}, $fields);
|
|
3895
|
+
}
|
|
3896
|
+
|
|
3897
|
+
renderForm(form, submitLabel) {
|
|
3898
|
+
let $loading = null;
|
|
3899
|
+
if (this.state.creating) $loading = (0,preact_module.h)("span", {
|
|
3900
|
+
class: "ml-2"
|
|
3901
|
+
}, (0,preact_module.h)(Spinner, {
|
|
3902
|
+
size: "16",
|
|
3903
|
+
mode: "white"
|
|
3904
|
+
}));
|
|
3905
|
+
let title = this.props.t.i18n(util/* default.get */.Z.get(form, `i18n_title`, {}));
|
|
3906
|
+
if (!title) title = util/* default.get */.Z.get(form, 'title', this.props.t('capture_lead_title'));
|
|
3907
|
+
title = title.replace('↵', '');
|
|
3908
|
+
return (0,preact_module.h)("div", {
|
|
3909
|
+
class: "widget-body"
|
|
3910
|
+
}, (0,preact_module.h)(FormMounter, {
|
|
3911
|
+
form: form,
|
|
3912
|
+
onMount: f => this.formMounted(f)
|
|
3913
|
+
}), (0,preact_module.h)("div", {
|
|
3914
|
+
class: "widget-body--content flex-grow-1 pl-3 pr-3 d-flex flex-column"
|
|
3915
|
+
}, (0,preact_module.h)("div", {
|
|
3916
|
+
class: "flex-grow-1"
|
|
3917
|
+
}, (0,preact_module.h)("div", {
|
|
3918
|
+
class: "form mt-3 pl-3 pr-3 pt-3 pb-3 d-flex flex-column"
|
|
3919
|
+
}, (0,preact_module.h)("div", null, title), this.renderFields())), (0,preact_module.h)(PoweredBy, {
|
|
3920
|
+
store: this.props.store,
|
|
3921
|
+
t: this.props.t
|
|
3922
|
+
})), (0,preact_module.h)("div", {
|
|
3923
|
+
class: "message-input message-input--preform"
|
|
3924
|
+
}, (0,preact_module.h)("button", {
|
|
3925
|
+
class: "btn--start-convo",
|
|
3926
|
+
onClick: _ => this.submitPrechatForm(form)
|
|
3927
|
+
}, submitLabel, " ", $loading)));
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
goToConvo(cid) {
|
|
3931
|
+
this.props.onGo({
|
|
3932
|
+
view: 'chat',
|
|
3933
|
+
cid
|
|
3934
|
+
});
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3937
|
+
renderConvoList() {
|
|
3938
|
+
let convoM = this.props.store.matchConvo('*');
|
|
3939
|
+
var convos = util/* default.map */.Z.map(convoM, convo => this.props.store.matchConvo(convo.id));
|
|
3940
|
+
convos = util/* default.filter */.Z.filter(convos, convo => !!convo);
|
|
3941
|
+
convos = util/* default.orderBy */.Z.orderBy(convos, 'created', 'desc');
|
|
3942
|
+
var $convos = util/* default.map */.Z.map(convos, convo => {
|
|
3943
|
+
let ags = util/* default.filter */.Z.filter(convo.members, m => {
|
|
3944
|
+
return (m.type === 'agent' || m.type === 'bot') && m.membership === 'active';
|
|
3945
|
+
});
|
|
3946
|
+
let agentids = util/* default.map */.Z.map(ags, m => m.id);
|
|
3947
|
+
agentids = agentids || util/* default.agentsOfConvo */.Z.agentsOfConvo(convo)[0];
|
|
3948
|
+
return (0,preact_module.h)("div", {
|
|
3949
|
+
class: "convo-list--item",
|
|
3950
|
+
onClick: () => this.goToConvo(convo.id),
|
|
3951
|
+
key: convo.id
|
|
3952
|
+
}, (0,preact_module.h)(AgentsAvatar, {
|
|
3953
|
+
plugin: this.props.plugin,
|
|
3954
|
+
store: this.props.store,
|
|
3955
|
+
mode: "member",
|
|
3956
|
+
class: "d-flex flex-row",
|
|
3957
|
+
tooltipPos: "right",
|
|
3958
|
+
agent_ids: agentids
|
|
3959
|
+
}), this.renderConvoSummary(convo));
|
|
3960
|
+
});
|
|
3961
|
+
let $body = (0,preact_module.h)("div", {
|
|
3962
|
+
class: "convo-list--list"
|
|
3963
|
+
}, $convos);
|
|
3964
|
+
|
|
3965
|
+
if (util/* default.size */.Z.size(convos) === 0) {
|
|
3966
|
+
$body = (0,preact_module.h)("div", {
|
|
3967
|
+
class: "convo-list--list"
|
|
3968
|
+
}, (0,preact_module.h)("div", {
|
|
3969
|
+
class: "empty-container"
|
|
3970
|
+
}, (0,preact_module.h)("img", {
|
|
3971
|
+
alt: "empty",
|
|
3972
|
+
src: empty
|
|
3973
|
+
}), (0,preact_module.h)("div", {
|
|
3974
|
+
class: "empty-desc"
|
|
3975
|
+
}, this.props.t('empty_convo'))));
|
|
3976
|
+
}
|
|
3977
|
+
|
|
3978
|
+
return (0,preact_module.h)("div", {
|
|
3979
|
+
class: "convo-list"
|
|
3980
|
+
}, (0,preact_module.h)("div", {
|
|
3981
|
+
class: "convo-list--container"
|
|
3982
|
+
}, (0,preact_module.h)("div", {
|
|
3983
|
+
class: "convo-list--title"
|
|
3984
|
+
}, this.props.t('conversations')), $body), (0,preact_module.h)("div", {
|
|
3985
|
+
class: "convo-list--footer"
|
|
3986
|
+
}, (0,preact_module.h)("button", {
|
|
3987
|
+
class: "btn--start-convo",
|
|
3988
|
+
onClick: _ => this.goToConvo('')
|
|
3989
|
+
}, (0,preact_module.h)("span", null, this.props.t('start_conversation')), (0,preact_module.h)("img", {
|
|
3990
|
+
src: send,
|
|
3991
|
+
alt: "send button",
|
|
3992
|
+
width: "26",
|
|
3993
|
+
height: "26"
|
|
3994
|
+
})), (0,preact_module.h)(PoweredBy, {
|
|
3995
|
+
store: this.props.store
|
|
3996
|
+
})));
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
blur() {
|
|
4000
|
+
if (this.props.store.isPreview) return;
|
|
4001
|
+
var $input = this.msgInput;
|
|
4002
|
+
if (!$input) return;
|
|
4003
|
+
setTimeout(() => $input && $input.blur());
|
|
4004
|
+
setTimeout(() => $input && $input.blur(), 300);
|
|
4005
|
+
}
|
|
4006
|
+
|
|
4007
|
+
focusInput() {
|
|
4008
|
+
if (this.props.store.isPreview) return;
|
|
4009
|
+
|
|
4010
|
+
if (this.shouldShowForm()) {
|
|
4011
|
+
let firstemptykey = '';
|
|
4012
|
+
util/* default.map */.Z.map(this.state.formData, (field, key) => {
|
|
4013
|
+
if (field.type !== 'text') return;
|
|
4014
|
+
if (firstemptykey) return;
|
|
4015
|
+
if (!field.value) firstemptykey = key;
|
|
4016
|
+
});
|
|
4017
|
+
setTimeout(() => {
|
|
4018
|
+
var $input = this['form_' + Widget_encode(firstemptykey)];
|
|
4019
|
+
if (!$input) return;
|
|
4020
|
+
$input.focus();
|
|
4021
|
+
}, 300);
|
|
4022
|
+
return;
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
var $input = this.msgInput;
|
|
4026
|
+
if (!$input) return;
|
|
4027
|
+
setTimeout(() => $input.focus());
|
|
4028
|
+
setTimeout(() => $input.focus(), 300);
|
|
4029
|
+
}
|
|
4030
|
+
|
|
4031
|
+
onRate(rating) {
|
|
4032
|
+
if (!this.props.cid) return;
|
|
4033
|
+
this.props.store.sendConvoEvent(this.props.cid, 'conversation_rated', {
|
|
4034
|
+
conversation: {
|
|
4035
|
+
ratings: [rating]
|
|
4036
|
+
}
|
|
4037
|
+
});
|
|
4038
|
+
this.focusInput();
|
|
4039
|
+
}
|
|
4040
|
+
|
|
4041
|
+
async sendMessage(message) {
|
|
4042
|
+
let text = message.text;
|
|
4043
|
+
|
|
4044
|
+
if (!this.props.cid) {
|
|
4045
|
+
this.creating = true;
|
|
4046
|
+
const {
|
|
4047
|
+
convo,
|
|
4048
|
+
error
|
|
4049
|
+
} = await this.props.store.startConvo({
|
|
4050
|
+
locale: this.props.t.locale(),
|
|
4051
|
+
message: text,
|
|
4052
|
+
initial_by: this.props.store.matchUser().id
|
|
4053
|
+
});
|
|
4054
|
+
|
|
4055
|
+
if (error) {}
|
|
4056
|
+
|
|
4057
|
+
this.creating = false;
|
|
4058
|
+
this.props.store.sendConvoEvent(convo.id, 'message_sent', {
|
|
4059
|
+
message
|
|
4060
|
+
});
|
|
4061
|
+
this.props.onGo({
|
|
4062
|
+
view: 'chat',
|
|
4063
|
+
cid: convo.id
|
|
4064
|
+
});
|
|
4065
|
+
return;
|
|
4066
|
+
}
|
|
4067
|
+
|
|
4068
|
+
this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
4069
|
+
message
|
|
4070
|
+
});
|
|
4071
|
+
}
|
|
4072
|
+
|
|
4073
|
+
createPostback(postback) {
|
|
4074
|
+
this.props.store.createPostback(this.props.cid, postback);
|
|
4075
|
+
}
|
|
4076
|
+
|
|
4077
|
+
renderChat() {
|
|
4078
|
+
let $input = (0,preact_module.h)(MessageInput, {
|
|
4079
|
+
store: this.props.store,
|
|
4080
|
+
ref: ref => this.msgInput = ref,
|
|
4081
|
+
cid: this.props.cid,
|
|
4082
|
+
onSend: e => this.sendMessage(e),
|
|
4083
|
+
t: this.props.t
|
|
4084
|
+
});
|
|
4085
|
+
let convo = this.props.store.matchConvo(this.props.cid) || {};
|
|
4086
|
+
|
|
4087
|
+
if (this.isFormRequired() || convo.state === 'ended') {
|
|
4088
|
+
$input = (0,preact_module.h)("div", {
|
|
4089
|
+
class: "message-input message-input--preform"
|
|
4090
|
+
}, (0,preact_module.h)("button", {
|
|
4091
|
+
class: "btn--start-convo",
|
|
4092
|
+
onClick: e => this.onStartConvoClick(e)
|
|
4093
|
+
}, this.props.t('offline_preform_btn')));
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
return (0,preact_module.h)("div", {
|
|
4097
|
+
class: "widget-body"
|
|
4098
|
+
}, (0,preact_module.h)("div", {
|
|
4099
|
+
class: "widget-body--content",
|
|
4100
|
+
onClick: e => this.onContainerClick(e)
|
|
4101
|
+
}, (0,preact_module.h)(Events, {
|
|
4102
|
+
isShow: this.props.isShow,
|
|
4103
|
+
store: this.props.store,
|
|
4104
|
+
onFormSubmit: e => this.onEventFormSubmit(e),
|
|
4105
|
+
ref: ref => this.events = ref,
|
|
4106
|
+
cid: this.props.cid,
|
|
4107
|
+
creating: this.creating,
|
|
4108
|
+
onSend: e => this.sendMessage(e),
|
|
4109
|
+
onPostback: e => this.createPostback(e),
|
|
4110
|
+
t: this.props.t
|
|
4111
|
+
}), (0,preact_module.h)(Typing, {
|
|
4112
|
+
store: this.props.store,
|
|
4113
|
+
cid: this.props.cid,
|
|
4114
|
+
t: this.props.t
|
|
4115
|
+
})), (0,preact_module.h)(Rating, {
|
|
4116
|
+
forceView: this.props.view,
|
|
4117
|
+
plugin: this.props.plugin,
|
|
4118
|
+
store: this.props.store,
|
|
4119
|
+
onRate: e => this.onRate(e),
|
|
4120
|
+
cid: this.props.cid,
|
|
4121
|
+
t: this.props.t
|
|
4122
|
+
}), $input);
|
|
4123
|
+
}
|
|
4124
|
+
|
|
4125
|
+
async onStartConvoClick() {
|
|
4126
|
+
var convo = this.props.store.matchConvo(this.props.cid) || {};
|
|
4127
|
+
if (convo.state === 'ended') return this.props.onGo({
|
|
4128
|
+
view: 'chat',
|
|
4129
|
+
cid: ''
|
|
4130
|
+
});
|
|
4131
|
+
this.setState({
|
|
4132
|
+
clickedJoin: true
|
|
4133
|
+
});
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
onEventFormSubmit() {
|
|
4137
|
+
this.focusInput();
|
|
4138
|
+
}
|
|
4139
|
+
|
|
4140
|
+
onContainerClick() {
|
|
4141
|
+
var selection = window.getSelection();
|
|
4142
|
+
if (selection.toString().length > 0) return;
|
|
4143
|
+
if (!this.props.store.isMobile()) this.focusInput();
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4146
|
+
isFormRequired() {
|
|
4147
|
+
let form;
|
|
4148
|
+
let accountSetting = this.props.plugin.chatbox || {};
|
|
4149
|
+
let acc = this.props.store.matchAccount() || {};
|
|
4150
|
+
if (util/* default.get */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
4151
|
+
let offlineEnabled = util/* default.get */.Z.get(accountSetting, 'offline_form.enabled');
|
|
4152
|
+
if (this.isOffline(acc, accountSetting) && offlineEnabled) form = accountSetting.offline_form;
|
|
4153
|
+
if (!form) return false;
|
|
4154
|
+
let formData = this.fillForm(form);
|
|
4155
|
+
let convo = this.props.store.matchConvo(this.props.cid) || {};
|
|
4156
|
+
if (convo.state === 'ended') return true;
|
|
4157
|
+
if (this.userHasSent(this.props.cid)) return false;
|
|
4158
|
+
if (convo.state && convo.state !== 'pending') delete formData.group;
|
|
4159
|
+
return !!util/* default.find */.Z.find(formData, field => field.value == null || field.value === '');
|
|
4160
|
+
}
|
|
4161
|
+
|
|
4162
|
+
renderConvoSummary(convo) {
|
|
4163
|
+
let agentM = this.props.store.matchAgent('*');
|
|
4164
|
+
let ags = util/* default.filter */.Z.filter(convo.members, m => {
|
|
4165
|
+
return (m.type === 'agent' || m.type === 'bot') && m.membership === 'active';
|
|
4166
|
+
});
|
|
4167
|
+
let agentids = util/* default.map */.Z.map(ags, m => m.id);
|
|
4168
|
+
agentids = agentids || util/* default.agentsOfConvo */.Z.agentsOfConvo(convo)[0];
|
|
4169
|
+
let agents = util/* default.map */.Z.map(agentids, id => agentM[id] || {
|
|
4170
|
+
avatar_url: Widget_defaultAvatar,
|
|
4171
|
+
fullname: 'Offline Agent'
|
|
4172
|
+
});
|
|
4173
|
+
var name = util/* default.each */.Z.each(agents, ag => ag.fullname).join(', ');
|
|
4174
|
+
if (!name) name = this.props.store.matchAccount().name;
|
|
4175
|
+
if (!name) name = this.props.t('agent');
|
|
4176
|
+
var $you = null;
|
|
4177
|
+
|
|
4178
|
+
if (convo.lastSenderType === 'user') {
|
|
4179
|
+
$you = (0,preact_module.h)("span", {
|
|
4180
|
+
class: "yourmessage"
|
|
4181
|
+
}, this.props.t('you'), ":");
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4184
|
+
let seen = util/* default.isConvoSeen */.Z.isConvoSeen(convo, this.props.store.matchUser().id);
|
|
4185
|
+
var lastmsg = this.renderMessagePreview(convo.last_message_sent || {
|
|
4186
|
+
data: {
|
|
4187
|
+
message: util/* default.get */.Z.get(convo, 'last_message')
|
|
4188
|
+
}
|
|
4189
|
+
});
|
|
4190
|
+
var time = util/* default.getMs */.Z.getMs(util/* default.get */.Z.get(convo, 'last_message_sent.created')) || util/* default.getMs */.Z.getMs(util/* default.get */.Z.get(convo, 'last_sent.created')) || util/* default.getMs */.Z.getMs(convo.created);
|
|
4191
|
+
var $tim = (0,preact_module.h)(Time, {
|
|
4192
|
+
ago: true,
|
|
4193
|
+
time: time,
|
|
4194
|
+
key: time,
|
|
4195
|
+
short: true
|
|
4196
|
+
});
|
|
4197
|
+
let $unread = seen ? null : (0,preact_module.h)("div", {
|
|
4198
|
+
class: "convo-list--item-unread"
|
|
4199
|
+
});
|
|
4200
|
+
|
|
4201
|
+
if (convo.state === 'ended') {
|
|
4202
|
+
$unread = (0,preact_module.h)("img", {
|
|
4203
|
+
alt: "conversation ended",
|
|
4204
|
+
class: "convo-list--convo-completed",
|
|
4205
|
+
src: checkedimg,
|
|
4206
|
+
title: this.props.t('conversation_ended')
|
|
4207
|
+
});
|
|
4208
|
+
}
|
|
4209
|
+
|
|
4210
|
+
return (0,preact_module.h)("div", {
|
|
4211
|
+
class: "convo-list--convo-last-info"
|
|
4212
|
+
}, (0,preact_module.h)("div", {
|
|
4213
|
+
class: "d-flex flex-row"
|
|
4214
|
+
}, (0,preact_module.h)("div", {
|
|
4215
|
+
class: "convo-list--convo-name"
|
|
4216
|
+
}, name), (0,preact_module.h)("div", {
|
|
4217
|
+
class: "convo-list--convo-time"
|
|
4218
|
+
}, $tim)), (0,preact_module.h)("div", {
|
|
4219
|
+
class: "d-flex flex-row"
|
|
4220
|
+
}, (0,preact_module.h)("div", {
|
|
4221
|
+
class: "convo-list--convo-last-message"
|
|
4222
|
+
}, $you, lastmsg), $unread));
|
|
4223
|
+
}
|
|
4224
|
+
|
|
4225
|
+
agentsOfConvo(convo) {
|
|
4226
|
+
let agentM = this.props.store.matchAgent('*');
|
|
4227
|
+
var agentids = util/* default.agentsOfConvo */.Z.agentsOfConvo(convo, true);
|
|
4228
|
+
return util/* default.map */.Z.map(agentids, id => agentM[id] || {
|
|
4229
|
+
avatar_url: Widget_defaultAvatar,
|
|
4230
|
+
fullname: 'Offline Agent'
|
|
4231
|
+
});
|
|
4232
|
+
}
|
|
4233
|
+
|
|
4234
|
+
renderMessagePreview(ev) {
|
|
4235
|
+
let defmsg = this.props.t('sent_you_a_message');
|
|
4236
|
+
let message = util/* default.get */.Z.get(ev, 'data.message.text');
|
|
4237
|
+
var format = util/* default.get */.Z.get(ev, 'data.message.format');
|
|
4238
|
+
if (format !== 'plaintext') message = defmsg;
|
|
4239
|
+
if (!message && util/* default.size */.Z.size(util/* default.get */.Z.get(ev, 'data.message.attachments')) > 0) message = defmsg;
|
|
4240
|
+
if (!message) return null;
|
|
4241
|
+
let byType = util/* default.get */.Z.get(ev, 'by.type');
|
|
4242
|
+
return (0,preact_module.h)("div", {
|
|
4243
|
+
class: "convo-list--convo-last-mes"
|
|
4244
|
+
}, util/* default.map */.Z.map(util/* default.extractText */.Z.extractText(message), tag => {
|
|
4245
|
+
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
4246
|
+
emojiCode: tag.text,
|
|
4247
|
+
byType: byType
|
|
4248
|
+
});
|
|
4249
|
+
return tag.text;
|
|
4250
|
+
}));
|
|
4251
|
+
}
|
|
4252
|
+
|
|
4253
|
+
userHasSent(cid) {
|
|
4254
|
+
var convo = this.props.store.matchConvo(cid) || {};
|
|
4255
|
+
let user = this.props.store.matchUser();
|
|
4256
|
+
if (this.userSent[cid]) return true;
|
|
4257
|
+
let joined = util/* default.find */.Z.find(convo.members, mem => mem.id === user.id && (mem.membership === 'active' || mem.last_sent > 0));
|
|
4258
|
+
return joined;
|
|
4259
|
+
}
|
|
4260
|
+
|
|
4261
|
+
isOffline(acc, accSetting) {
|
|
4262
|
+
let enableWhen = util/* default.get */.Z.get(accSetting, 'offline_form.enable_when');
|
|
4263
|
+
let isonline = true;
|
|
4264
|
+
if (enableWhen === 'all_agents_offline') isonline = acc.is_online;
|
|
4265
|
+
if (enableWhen === 'out_of_bussiness_hour') isonline = acc.is_in_business_hour;
|
|
4266
|
+
return !isonline;
|
|
4267
|
+
}
|
|
4268
|
+
|
|
4269
|
+
updateFormDataFields() {
|
|
4270
|
+
let form;
|
|
4271
|
+
let accountSetting = this.props.plugin.chatbox || {};
|
|
4272
|
+
let acc = this.props.store.matchAccount() || {};
|
|
4273
|
+
if (util/* default.get */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
4274
|
+
let offlineEnabled = util/* default.get */.Z.get(accountSetting, 'offline_form.enabled');
|
|
4275
|
+
|
|
4276
|
+
if (this.isOffline(acc, accountSetting) && offlineEnabled) {
|
|
4277
|
+
form = accountSetting.offline_form;
|
|
4278
|
+
}
|
|
4279
|
+
|
|
4280
|
+
if (this.props.view === 'offline_form') {
|
|
4281
|
+
form = accountSetting.offline_form;
|
|
4282
|
+
}
|
|
4283
|
+
|
|
4284
|
+
if (this.props.view === 'prechat_form') {
|
|
4285
|
+
form = accountSetting.prechat_form;
|
|
4286
|
+
}
|
|
4287
|
+
|
|
4288
|
+
if (util/* default.size */.Z.size(form) === 0) return [];
|
|
4289
|
+
var data = {};
|
|
4290
|
+
util/* default.each */.Z.each(form.fields, f => {
|
|
4291
|
+
var newf = Object.assign({}, f);
|
|
4292
|
+
|
|
4293
|
+
if (f.type === 'list') {
|
|
4294
|
+
newf.list = f.list;
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4297
|
+
newf.label = this.props.t.i18n(util/* default.get */.Z.get(f, `i18n_label`, {})) || f.label;
|
|
4298
|
+
data['attr:' + f.key] = newf;
|
|
4299
|
+
});
|
|
4300
|
+
|
|
4301
|
+
if (form.group_required && util/* default.size */.Z.size(form.groups) > 0) {
|
|
4302
|
+
data['group'] = {
|
|
4303
|
+
key: 'group',
|
|
4304
|
+
is_required: !!form.group_required,
|
|
4305
|
+
label: this.props.t.i18n(util/* default.get */.Z.get(form, `i18n_group_label`, {})) || form.group_label,
|
|
4306
|
+
type: 'group',
|
|
4307
|
+
list: util/* default.map */.Z.map(form.groups, group => ({
|
|
4308
|
+
value: group.id,
|
|
4309
|
+
label: group.name
|
|
4310
|
+
}))
|
|
4311
|
+
};
|
|
4312
|
+
}
|
|
4313
|
+
|
|
4314
|
+
data['question'] = {
|
|
4315
|
+
key: 'question',
|
|
4316
|
+
is_required: true,
|
|
4317
|
+
label: this.props.t.i18n(util/* default.get */.Z.get(form, `i18n_question_label`, {})) || form.question_label,
|
|
4318
|
+
type: 'text'
|
|
4319
|
+
};
|
|
4320
|
+
|
|
4321
|
+
if (this.isFormChanged(this.state.formData, data)) {
|
|
4322
|
+
this.setState({
|
|
4323
|
+
formData: data
|
|
4324
|
+
});
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
|
|
4328
|
+
isFormChanged(oldForm, newForm) {
|
|
4329
|
+
let oldKeys = Object.keys(oldForm);
|
|
4330
|
+
let newKeys = Object.keys(newForm);
|
|
4331
|
+
if (oldKeys.length !== newKeys.length) return true;
|
|
4332
|
+
|
|
4333
|
+
for (let i = 0; i < oldKeys.length; i++) {
|
|
4334
|
+
if (util/* default.get */.Z.get(oldForm, `${oldKeys[i]}.label`) !== util/* default.get */.Z.get(newForm, `${newKeys[i]}.label`)) return true;
|
|
4335
|
+
if (util/* default.get */.Z.get(oldForm, `${oldKeys[i]}.is_required`) !== util/* default.get */.Z.get(newForm, `${newKeys[i]}.is_required`)) return true;
|
|
4336
|
+
|
|
4337
|
+
if (util/* default.stringify */.Z.stringify(util/* default.get */.Z.get(oldForm, `${oldKeys[i]}.list`)) !== util/* default.stringify */.Z.stringify(util/* default.get */.Z.get(newForm, `${newKeys[i]}.list`))) {
|
|
4338
|
+
return true;
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
|
|
4342
|
+
return false;
|
|
4343
|
+
}
|
|
4344
|
+
|
|
4345
|
+
fillForm(form) {
|
|
4346
|
+
if (util/* default.size */.Z.size(form) === 0) return [];
|
|
4347
|
+
var data = {};
|
|
4348
|
+
let user = this.props.store.matchUser();
|
|
4349
|
+
util/* default.each */.Z.each(form.fields, f => {
|
|
4350
|
+
var newf = Object.assign({}, f);
|
|
4351
|
+
newf.value = util/* default.getUserAttr */.Z.getUserAttr(user, f.key, f.type);
|
|
4352
|
+
if (f.type === 'boolean' && !newf.value) newf.value = false;
|
|
4353
|
+
|
|
4354
|
+
if (f.type === 'datetime' && newf.value) {
|
|
4355
|
+
newf.value = new util/* default.Date */.Z.Date(data.value).toLocaleDateString('en-CA');
|
|
4356
|
+
}
|
|
4357
|
+
|
|
4358
|
+
if (f.type === 'list') {
|
|
4359
|
+
newf.list = f.list;
|
|
4360
|
+
}
|
|
4361
|
+
|
|
4362
|
+
newf.label = this.props.t.i18n(util/* default.get */.Z.get(f, `i18n_label`, {})) || f.label;
|
|
4363
|
+
data['attr:' + f.key] = newf;
|
|
4364
|
+
});
|
|
4365
|
+
|
|
4366
|
+
if (form.group_required && util/* default.size */.Z.size(form.groups) > 0) {
|
|
4367
|
+
data['group'] = {
|
|
4368
|
+
key: 'group',
|
|
4369
|
+
is_required: !!form.group_required,
|
|
4370
|
+
label: this.props.t.i18n(util/* default.get */.Z.get(form, `i18n_group_label`, {})) || form.group_label,
|
|
4371
|
+
type: 'group',
|
|
4372
|
+
list: util/* default.map */.Z.map(form.groups, group => ({
|
|
4373
|
+
value: group.id,
|
|
4374
|
+
label: group.name
|
|
4375
|
+
}))
|
|
4376
|
+
};
|
|
4377
|
+
}
|
|
4378
|
+
|
|
4379
|
+
return data;
|
|
4380
|
+
}
|
|
4381
|
+
|
|
4382
|
+
}
|
|
4383
|
+
|
|
4384
|
+
class FormMounter extends common/* Com */.M {
|
|
4385
|
+
componentDidMount() {
|
|
4386
|
+
this.props.onMount(this.props.form);
|
|
4387
|
+
}
|
|
4388
|
+
|
|
4389
|
+
}
|
|
4390
|
+
|
|
4391
|
+
function Widget_encode(key) {
|
|
4392
|
+
return btoa(key).split('=').join('');
|
|
4393
|
+
}
|
|
4394
|
+
;// CONCATENATED MODULE: ./src/chatbox/main.js
|
|
4395
|
+
|
|
4396
|
+
|
|
4397
|
+
|
|
4398
|
+
|
|
4399
|
+
|
|
4400
|
+
|
|
4401
|
+
let promiseMainCSS = (() => __webpack_require__.e(/* import() */ 178).then(__webpack_require__.bind(__webpack_require__, 178)))();
|
|
4402
|
+
|
|
4403
|
+
class Main extends common/* Com */.M {
|
|
4404
|
+
constructor(props) {
|
|
4405
|
+
super(props);
|
|
4406
|
+
this.refButton = (0,preact_module/* createRef */.Vf)();
|
|
4407
|
+
}
|
|
4408
|
+
|
|
4409
|
+
async refreshCSS() {
|
|
4410
|
+
let plugins = this.props.store.matchPlugin();
|
|
4411
|
+
let found = util/* default.find */.Z.find(plugins, plugin => plugin.id === this.props.plugin.id);
|
|
4412
|
+
if (!found) return;
|
|
4413
|
+
let css = (await promiseMainCSS).default.default.toString();
|
|
4414
|
+
var outcss = util/* default.replaceCssVariable */.Z.replaceCssVariable(css, this.props.plugin.chatbox);
|
|
4415
|
+
util/* default.setCss */.Z.setCss(this.props.plugin.id, this.$cssStyleDiv, outcss);
|
|
4416
|
+
}
|
|
4417
|
+
|
|
4418
|
+
componentWillUnmount() {
|
|
4419
|
+
util/* default.setCss */.Z.setCss(this.props.plugin.id, this.$cssStyleDiv, '');
|
|
4420
|
+
}
|
|
4421
|
+
|
|
4422
|
+
async componentDidMount() {
|
|
4423
|
+
this.$cssStyleDiv = document.getElementById('subiz-style-for-' + this.props.plugin.id);
|
|
4424
|
+
|
|
4425
|
+
if (!this.$cssStyleDiv) {
|
|
4426
|
+
this.$cssStyleDiv = document.createElement('style');
|
|
4427
|
+
document.head.appendChild(this.$cssStyleDiv);
|
|
4428
|
+
this.$cssStyleDiv.type = 'text/css';
|
|
4429
|
+
this.$cssStyleDiv.id = 'subiz-style-for-' + this.props.plugin.id;
|
|
4430
|
+
}
|
|
4431
|
+
|
|
4432
|
+
this.setState({
|
|
4433
|
+
cssready: false,
|
|
4434
|
+
isShowWidget: false,
|
|
4435
|
+
widgetView: '',
|
|
4436
|
+
widgetConvoId: ''
|
|
4437
|
+
});
|
|
4438
|
+
this.checkExpand();
|
|
4439
|
+
this.props.store.onResetCSS(this, () => this.refreshCSS());
|
|
4440
|
+
this.props.store.onConvoEvent(this, _ => this.checkExpand());
|
|
4441
|
+
this.props.store.onUpdate(this, _ => this.checkExpand());
|
|
4442
|
+
await this.refreshCSS();
|
|
4443
|
+
this.setState({
|
|
4444
|
+
cssready: true
|
|
4445
|
+
});
|
|
4446
|
+
|
|
4447
|
+
if (this.props.store.matchIsOpen() && this.props.store.matchLastview().view) {
|
|
4448
|
+
if (this.props.store.isMobile()) return;
|
|
4449
|
+
this.showWidget(Object.assign({}, this.props.store.matchLastview().opts, {
|
|
4450
|
+
view: this.props.store.matchLastview().view
|
|
4451
|
+
}));
|
|
4452
|
+
} else {
|
|
4453
|
+
this.hideWidget();
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4457
|
+
render() {
|
|
4458
|
+
if (!this.state.cssready) return null;
|
|
4459
|
+
if (util/* default.isUserBanned */.Z.isUserBanned(this.props.store.matchUser())) return null;
|
|
4460
|
+
if (!this.props.t) return null;
|
|
4461
|
+
var cls = this.props.store.isMobile() ? 'mobile' : 'desktop';
|
|
4462
|
+
return (0,preact_module.h)("div", {
|
|
4463
|
+
class: cls
|
|
4464
|
+
}, (0,preact_module.h)(ChatButton, {
|
|
4465
|
+
plugin: this.props.plugin,
|
|
4466
|
+
store: this.props.store,
|
|
4467
|
+
key: "chat_button",
|
|
4468
|
+
ref: this.refButton,
|
|
4469
|
+
isShow: !this.state.isShowWidget,
|
|
4470
|
+
onClick: e => this.showWidget(e),
|
|
4471
|
+
t: this.props.t
|
|
4472
|
+
}), (0,preact_module.h)(Widget, {
|
|
4473
|
+
plugin: this.props.plugin,
|
|
4474
|
+
store: this.props.store,
|
|
4475
|
+
view: this.state.widgetView,
|
|
4476
|
+
cid: this.state.widgetConvoId,
|
|
4477
|
+
isShow: this.state.isShowWidget,
|
|
4478
|
+
onClose: a => this.onWidgetClose(a),
|
|
4479
|
+
onGo: a => this.showWidget(a),
|
|
4480
|
+
t: this.props.t
|
|
4481
|
+
}));
|
|
4482
|
+
}
|
|
4483
|
+
|
|
4484
|
+
checkExpand() {
|
|
4485
|
+
if (this.props.store.isMobile()) return;
|
|
4486
|
+
if (this.props.plugin._no_auto_expand) return;
|
|
4487
|
+
if (this.props.store.matchHasManuallyClosed()) return;
|
|
4488
|
+
let convoM = this.props.store.matchConvo('*');
|
|
4489
|
+
let redconvo = util/* default.find */.Z.find(convoM, convo => !util/* default.isConvoSeen */.Z.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
4490
|
+
if (!redconvo || !redconvo.id) return;
|
|
4491
|
+
if (!this.state.isShowWidget) this.showWidget({
|
|
4492
|
+
view: 'chat',
|
|
4493
|
+
cid: redconvo.id
|
|
4494
|
+
});
|
|
4495
|
+
}
|
|
4496
|
+
|
|
4497
|
+
getCurrentView() {
|
|
4498
|
+
return {
|
|
4499
|
+
is_show_widget: this.state.isShowWidget,
|
|
4500
|
+
conversation_id: this.state.widgetConvoId,
|
|
4501
|
+
view: this.state.widgetView
|
|
4502
|
+
};
|
|
4503
|
+
}
|
|
4504
|
+
|
|
4505
|
+
async showWidget(p) {
|
|
4506
|
+
this.refButton.current && this.refButton.current.ClearPreview();
|
|
4507
|
+
|
|
4508
|
+
if (!p.view) {
|
|
4509
|
+
let lastview = this.props.store.matchLastview() || {};
|
|
4510
|
+
p.view = util/* default.get */.Z.get(lastview, 'view');
|
|
4511
|
+
p.cid = util/* default.get */.Z.get(lastview, 'opts.cid');
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4514
|
+
p = p || {};
|
|
4515
|
+
if (this.props.store.isMobile()) modifyViewport();
|
|
4516
|
+
this.setState({
|
|
4517
|
+
widgetConvoId: p.cid,
|
|
4518
|
+
widgetView: p.view
|
|
4519
|
+
});
|
|
4520
|
+
this.props.store.setIsOpen(true);
|
|
4521
|
+
this.forceUpdate();
|
|
4522
|
+
this.setState({
|
|
4523
|
+
isShowWidget: true
|
|
4524
|
+
});
|
|
4525
|
+
this.props.store.setLastview(p.view, {
|
|
4526
|
+
cid: p.cid
|
|
4527
|
+
});
|
|
4528
|
+
}
|
|
4529
|
+
|
|
4530
|
+
showGreeting() {
|
|
4531
|
+
this.refButton.current && this.refButton.current.ShowGreeting();
|
|
4532
|
+
}
|
|
4533
|
+
|
|
4534
|
+
hideGreeting() {
|
|
4535
|
+
this.refButton.current && this.refButton.current.HideGreeting();
|
|
4536
|
+
}
|
|
4537
|
+
|
|
4538
|
+
hideWidget() {
|
|
4539
|
+
restoreViewport();
|
|
4540
|
+
this.props.store.setIsOpen(false);
|
|
4541
|
+
this.setState({
|
|
4542
|
+
isShowWidget: false
|
|
4543
|
+
});
|
|
4544
|
+
}
|
|
4545
|
+
|
|
4546
|
+
onWidgetClose() {
|
|
4547
|
+
this.refButton.current && this.refButton.current.ClearPreview();
|
|
4548
|
+
this.props.store.setHasManuallyClosed();
|
|
4549
|
+
this.hideWidget();
|
|
4550
|
+
}
|
|
4551
|
+
|
|
4552
|
+
}
|
|
4553
|
+
|
|
4554
|
+
function restoreViewport() {
|
|
4555
|
+
let metatag = document.getElementById('subiz-meta-viewport');
|
|
4556
|
+
if (metatag) metatag.remove();
|
|
4557
|
+
}
|
|
4558
|
+
|
|
4559
|
+
function modifyViewport() {
|
|
4560
|
+
let metatag = document.createElement('meta');
|
|
4561
|
+
metatag.httpEquiv = 'X-UA-Compatible';
|
|
4562
|
+
metatag.name = 'viewport';
|
|
4563
|
+
metatag.id = 'subiz-meta-viewport';
|
|
4564
|
+
metatag.content = 'maximum-scale=1.0, user-scalable=no, width=device-width, initial-scale=1.0';
|
|
4565
|
+
document.getElementsByTagName('head')[0].appendChild(metatag);
|
|
4566
|
+
}
|
|
4567
|
+
|
|
4568
|
+
/***/ }),
|
|
4569
|
+
|
|
4570
|
+
/***/ 2493:
|
|
4571
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
4572
|
+
|
|
4573
|
+
"use strict";
|
|
4574
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4575
|
+
/* harmony export */ "M": () => (/* binding */ Com),
|
|
4576
|
+
/* harmony export */ "u": () => (/* binding */ Clickaway)
|
|
4577
|
+
/* harmony export */ });
|
|
4578
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6400);
|
|
4579
|
+
/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(819);
|
|
4580
|
+
|
|
4581
|
+
|
|
4582
|
+
class Com extends preact__WEBPACK_IMPORTED_MODULE_0__/* .Component */ .wA {
|
|
4583
|
+
constructor(props) {
|
|
4584
|
+
super(props);
|
|
4585
|
+
this._isMounted = true;
|
|
4586
|
+
setTimeout(() => {
|
|
4587
|
+
if (this.componentWillUnmount) {
|
|
4588
|
+
let old = this.componentWillUnmount.bind(this);
|
|
4589
|
+
|
|
4590
|
+
this.componentWillUnmount = () => {
|
|
4591
|
+
old();
|
|
4592
|
+
this._isMounted = false;
|
|
4593
|
+
};
|
|
4594
|
+
}
|
|
4595
|
+
}, 10);
|
|
4596
|
+
}
|
|
4597
|
+
|
|
4598
|
+
}
|
|
4599
|
+
class Clickaway extends Com {
|
|
4600
|
+
constructor(props) {
|
|
4601
|
+
super(props);
|
|
4602
|
+
this.setWrapperRef = this.setWrapperRef.bind(this);
|
|
4603
|
+
this.onClick = this.onClick.bind(this);
|
|
4604
|
+
}
|
|
4605
|
+
|
|
4606
|
+
componentDidMount() {
|
|
4607
|
+
document.addEventListener('mousedown', this.onClick);
|
|
4608
|
+
}
|
|
4609
|
+
|
|
4610
|
+
componentWillUnmount() {
|
|
4611
|
+
document.removeEventListener('mousedown', this.onClick);
|
|
4612
|
+
}
|
|
4613
|
+
|
|
4614
|
+
setWrapperRef(node) {
|
|
4615
|
+
this.wrapperRef = node;
|
|
4616
|
+
}
|
|
4617
|
+
|
|
4618
|
+
onClick(event) {
|
|
4619
|
+
if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {
|
|
4620
|
+
this.props.onClickaway && this.props.onClickaway();
|
|
4621
|
+
}
|
|
4622
|
+
}
|
|
4623
|
+
|
|
4624
|
+
render() {
|
|
4625
|
+
return (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", {
|
|
4626
|
+
ref: this.setWrapperRef
|
|
4627
|
+
}, this.props.children);
|
|
4628
|
+
}
|
|
4629
|
+
|
|
4630
|
+
}
|
|
4631
|
+
|
|
4632
|
+
/***/ }),
|
|
4633
|
+
|
|
4634
|
+
/***/ 6755:
|
|
4635
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4636
|
+
|
|
4637
|
+
module.exports = __webpack_require__.p + "assets/img/bubble_default.7d5e4ab.svg";
|
|
4638
|
+
|
|
4639
|
+
/***/ }),
|
|
4640
|
+
|
|
4641
|
+
/***/ 6188:
|
|
4642
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4643
|
+
|
|
4644
|
+
module.exports = __webpack_require__.p + "assets/img/convos_empty.2353007.svg";
|
|
4645
|
+
|
|
4646
|
+
/***/ }),
|
|
4647
|
+
|
|
4648
|
+
/***/ 9270:
|
|
4649
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4650
|
+
|
|
4651
|
+
module.exports = __webpack_require__.p + "assets/img/default.06e6ee0.jpg";
|
|
4652
|
+
|
|
4653
|
+
/***/ }),
|
|
4654
|
+
|
|
4655
|
+
/***/ 4761:
|
|
4656
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4657
|
+
|
|
4658
|
+
module.exports = __webpack_require__.p + "assets/img/default_avatar.5b74dc1.png";
|
|
4659
|
+
|
|
4660
|
+
/***/ }),
|
|
4661
|
+
|
|
4662
|
+
/***/ 8909:
|
|
4663
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4664
|
+
|
|
4665
|
+
module.exports = __webpack_require__.p + "assets/img/done_gray.d7e8203.svg";
|
|
4666
|
+
|
|
4667
|
+
/***/ }),
|
|
4668
|
+
|
|
4669
|
+
/***/ 29:
|
|
4670
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4671
|
+
|
|
4672
|
+
module.exports = __webpack_require__.p + "assets/img/empty.29bed2d.svg";
|
|
4673
|
+
|
|
4674
|
+
/***/ }),
|
|
4675
|
+
|
|
4676
|
+
/***/ 8453:
|
|
4677
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4678
|
+
|
|
4679
|
+
module.exports = __webpack_require__.p + "assets/img/external-link.90577cc.svg";
|
|
4680
|
+
|
|
4681
|
+
/***/ }),
|
|
4682
|
+
|
|
4683
|
+
/***/ 9895:
|
|
4684
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4685
|
+
|
|
4686
|
+
module.exports = __webpack_require__.p + "assets/img/image_default.be0698b.png";
|
|
4687
|
+
|
|
4688
|
+
/***/ }),
|
|
4689
|
+
|
|
4690
|
+
/***/ 6484:
|
|
4691
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4692
|
+
|
|
4693
|
+
module.exports = __webpack_require__.p + "assets/img/loading_static.8f403ae.svg";
|
|
4694
|
+
|
|
4695
|
+
/***/ }),
|
|
4696
|
+
|
|
4697
|
+
/***/ 6535:
|
|
4698
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4699
|
+
|
|
4700
|
+
module.exports = __webpack_require__.p + "assets/img/rating--average.1ea492c.svg";
|
|
4701
|
+
|
|
4702
|
+
/***/ }),
|
|
4703
|
+
|
|
4704
|
+
/***/ 3824:
|
|
4705
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4706
|
+
|
|
4707
|
+
module.exports = __webpack_require__.p + "assets/img/rating--great.e3d712e.svg";
|
|
4708
|
+
|
|
4709
|
+
/***/ }),
|
|
4710
|
+
|
|
4711
|
+
/***/ 8367:
|
|
4712
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4713
|
+
|
|
4714
|
+
module.exports = __webpack_require__.p + "assets/img/rating--poor.2938a25.svg";
|
|
4715
|
+
|
|
4716
|
+
/***/ }),
|
|
4717
|
+
|
|
4718
|
+
/***/ 9737:
|
|
4719
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4720
|
+
|
|
4721
|
+
module.exports = __webpack_require__.p + "assets/img/send.6db52a9.svg";
|
|
4722
|
+
|
|
4723
|
+
/***/ }),
|
|
4724
|
+
|
|
4725
|
+
/***/ 8430:
|
|
4726
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4727
|
+
|
|
4728
|
+
module.exports = __webpack_require__.p + "assets/img/subiz-mono.877e9f5.svg";
|
|
4729
|
+
|
|
4730
|
+
/***/ })
|
|
4731
|
+
|
|
4732
|
+
}]);
|