@asgard-js/react 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/chatbot/chatbot-container/chatbot-full-screen-container.d.ts.map +1 -1
- package/dist/components/chatbot/chatbot.d.ts +2 -2
- package/dist/components/chatbot/chatbot.d.ts.map +1 -1
- package/dist/components/templates/hint-template/hint-template.d.ts.map +1 -1
- package/dist/components/templates/text-template/bot-typing-box.d.ts.map +1 -1
- package/dist/context/asgard-service-context.d.ts +3 -6
- package/dist/context/asgard-service-context.d.ts.map +1 -1
- package/dist/context/asgard-template-context.d.ts +16 -0
- package/dist/context/asgard-template-context.d.ts.map +1 -0
- package/dist/context/index.d.ts +4 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/hooks/use-asgard-service-client.d.ts.map +1 -1
- package/dist/hooks/use-channel.d.ts +0 -1
- package/dist/hooks/use-channel.d.ts.map +1 -1
- package/dist/index.js +587 -540
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as c, jsxs as m, Fragment as mt } from "react/jsx-runtime";
|
|
2
2
|
import * as g from "react";
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { AsgardServiceClient as
|
|
5
|
-
function
|
|
6
|
-
return
|
|
3
|
+
import { createContext as F, useMemo as v, useContext as W, useRef as R, useEffect as C, useState as w, useCallback as b, useLayoutEffect as rt, memo as ft } from "react";
|
|
4
|
+
import { AsgardServiceClient as bt, EventType as V, Conversation as pt, Channel as Ct, MessageTemplateType as O } from "@asgard-js/core";
|
|
5
|
+
function X(n) {
|
|
6
|
+
return n !== null && typeof n == "object" && !Array.isArray(n);
|
|
7
7
|
}
|
|
8
|
-
function st(
|
|
9
|
-
const o = { ...
|
|
8
|
+
function st(n, t) {
|
|
9
|
+
const o = { ...n };
|
|
10
10
|
if (!t) return o;
|
|
11
|
-
for (const [
|
|
12
|
-
if (!
|
|
13
|
-
o[
|
|
11
|
+
for (const [e, r] of Object.entries(t)) {
|
|
12
|
+
if (!X(r)) {
|
|
13
|
+
o[e] = r;
|
|
14
14
|
continue;
|
|
15
15
|
}
|
|
16
|
-
o[
|
|
16
|
+
o[e] = st(X(o[e]) ? o[e] : {}, r);
|
|
17
17
|
}
|
|
18
18
|
return o;
|
|
19
19
|
}
|
|
@@ -34,213 +34,208 @@ const ct = {
|
|
|
34
34
|
color: "var(--asg-color-text)",
|
|
35
35
|
backgroundColor: "var(--asg-color-primary)"
|
|
36
36
|
}
|
|
37
|
-
}, it =
|
|
37
|
+
}, it = F(
|
|
38
38
|
ct
|
|
39
39
|
);
|
|
40
|
-
function
|
|
41
|
-
const { children: t, theme: o = {} } =
|
|
40
|
+
function vt(n) {
|
|
41
|
+
const { children: t, theme: o = {} } = n, e = v(
|
|
42
42
|
() => st(ct, o),
|
|
43
43
|
[o]
|
|
44
44
|
);
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
function
|
|
51
|
-
const { config: t } =
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
}, [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
return /* @__PURE__ */ c(it.Provider, { value: e, children: t });
|
|
46
|
+
}
|
|
47
|
+
function L() {
|
|
48
|
+
return W(it);
|
|
49
|
+
}
|
|
50
|
+
function xt(n) {
|
|
51
|
+
const { config: t } = n, { onRunInit: o, onProcess: e, onMessage: r, onRunDone: s, onRunError: a } = t, i = R(null);
|
|
52
|
+
return i.current || (i.current = new bt(t)), C(() => () => {
|
|
53
|
+
i.current && (i.current.close(), i.current = null);
|
|
54
|
+
}, []), C(() => {
|
|
55
|
+
!i.current || !o || i.current.on(V.INIT, o);
|
|
56
|
+
}, [o]), C(() => {
|
|
57
|
+
!i.current || !e || i.current.on(V.PROCESS, e);
|
|
58
|
+
}, [e]), C(() => {
|
|
59
|
+
!i.current || !r || i.current.on(V.MESSAGE, r);
|
|
60
|
+
}, [r]), C(() => {
|
|
61
|
+
!i.current || !s || i.current.on(V.DONE, s);
|
|
62
|
+
}, [s]), C(() => {
|
|
63
|
+
!i.current || !a || i.current.on(V.ERROR, a);
|
|
64
|
+
}, [a]), i.current;
|
|
65
|
+
}
|
|
66
|
+
function wt(n) {
|
|
67
|
+
const { client: t, customChannelId: o, customMessageId: e, initMessages: r } = n;
|
|
64
68
|
if (!t)
|
|
65
69
|
throw new Error("Client instance is required");
|
|
66
70
|
if (!o)
|
|
67
71
|
throw new Error("Custom channel id is required");
|
|
68
|
-
const [
|
|
69
|
-
const
|
|
70
|
-
showDebugMessage: c,
|
|
72
|
+
const [s, a] = w(null), [i, u] = w(!0), [d, h] = w(!1), [_, l] = w(!1), [p, f] = w(null), x = b(async () => {
|
|
73
|
+
const k = new pt({
|
|
71
74
|
messages: new Map(
|
|
72
75
|
r == null ? void 0 : r.map((H) => [H.messageId, H])
|
|
73
76
|
)
|
|
74
77
|
});
|
|
75
|
-
|
|
76
|
-
const
|
|
78
|
+
h(!0), l(!0), f(k);
|
|
79
|
+
const gt = await Ct.reset(
|
|
77
80
|
{
|
|
78
81
|
client: t,
|
|
79
82
|
customChannelId: o,
|
|
80
|
-
customMessageId:
|
|
81
|
-
conversation:
|
|
83
|
+
customMessageId: e,
|
|
84
|
+
conversation: k,
|
|
82
85
|
statesObserver: (H) => {
|
|
83
|
-
|
|
86
|
+
l(H.isConnecting), f(H.conversation);
|
|
84
87
|
}
|
|
85
88
|
},
|
|
86
89
|
{
|
|
87
90
|
onSseCompleted() {
|
|
88
|
-
|
|
91
|
+
h(!1);
|
|
89
92
|
},
|
|
90
93
|
onSseError() {
|
|
91
|
-
|
|
94
|
+
h(!1);
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
);
|
|
95
|
-
a(
|
|
96
|
-
}, [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
c
|
|
102
|
-
]), S = b(() => {
|
|
103
|
-
a((L) => (L == null || L.close(), null)), d(!1), f(!1), _(!1), v(null);
|
|
104
|
-
}, []), W = b(
|
|
105
|
-
(L) => {
|
|
106
|
-
i == null || i.sendMessage({ text: L });
|
|
107
|
-
},
|
|
108
|
-
[i]
|
|
98
|
+
a(gt);
|
|
99
|
+
}, [t, o, e, r]), N = b(() => {
|
|
100
|
+
a((k) => (k == null || k.close(), null)), u(!1), h(!1), l(!1), f(null);
|
|
101
|
+
}, []), K = b(
|
|
102
|
+
(k) => s == null ? void 0 : s.sendMessage({ text: k }),
|
|
103
|
+
[s]
|
|
109
104
|
);
|
|
110
|
-
return
|
|
111
|
-
!
|
|
112
|
-
}, [
|
|
105
|
+
return C(() => {
|
|
106
|
+
!s && i && x();
|
|
107
|
+
}, [s, i, x]), C(() => () => N(), [N]), v(
|
|
113
108
|
() => ({
|
|
114
|
-
isOpen:
|
|
115
|
-
isResetting:
|
|
116
|
-
isConnecting:
|
|
117
|
-
conversation:
|
|
118
|
-
sendMessage:
|
|
119
|
-
resetChannel:
|
|
120
|
-
closeChannel:
|
|
109
|
+
isOpen: i,
|
|
110
|
+
isResetting: d,
|
|
111
|
+
isConnecting: _,
|
|
112
|
+
conversation: p,
|
|
113
|
+
sendMessage: K,
|
|
114
|
+
resetChannel: x,
|
|
115
|
+
closeChannel: N
|
|
121
116
|
}),
|
|
122
117
|
[
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
118
|
+
i,
|
|
119
|
+
d,
|
|
120
|
+
_,
|
|
121
|
+
p,
|
|
122
|
+
K,
|
|
123
|
+
x,
|
|
124
|
+
N
|
|
130
125
|
]
|
|
131
126
|
);
|
|
132
127
|
}
|
|
133
|
-
function
|
|
134
|
-
const [o,
|
|
135
|
-
return
|
|
128
|
+
function yt(n, t) {
|
|
129
|
+
const [o, e] = w(n);
|
|
130
|
+
return C(() => {
|
|
136
131
|
const r = window.setTimeout(() => {
|
|
137
|
-
n
|
|
132
|
+
e(n);
|
|
138
133
|
}, t ?? 300);
|
|
139
134
|
return () => clearTimeout(r);
|
|
140
|
-
}, [
|
|
135
|
+
}, [n, t]), o;
|
|
141
136
|
}
|
|
142
|
-
const
|
|
143
|
-
function
|
|
137
|
+
const q = typeof window < "u" ? rt : null;
|
|
138
|
+
function Tt() {
|
|
144
139
|
return window.visualViewport ? [window.visualViewport.width, window.visualViewport.height] : [window.innerWidth, window.innerHeight];
|
|
145
140
|
}
|
|
146
|
-
function
|
|
147
|
-
const [
|
|
148
|
-
const
|
|
141
|
+
function Et() {
|
|
142
|
+
const [n, t] = w(), o = b(() => {
|
|
143
|
+
const e = Tt();
|
|
149
144
|
t(
|
|
150
|
-
(r) => r && r[0] ===
|
|
145
|
+
(r) => r && r[0] === e[0] && r[1] === e[1] ? r : e
|
|
151
146
|
);
|
|
152
147
|
}, []);
|
|
153
|
-
return
|
|
148
|
+
return q == null || q(o, [o]), C(() => {
|
|
154
149
|
var r;
|
|
155
|
-
function
|
|
150
|
+
function e() {
|
|
156
151
|
o(), setTimeout(o, 1e3);
|
|
157
152
|
}
|
|
158
|
-
return window.addEventListener("resize",
|
|
159
|
-
var
|
|
160
|
-
window.removeEventListener("resize",
|
|
153
|
+
return window.addEventListener("resize", e), window.addEventListener("orientationchange", e), (r = window.visualViewport) == null || r.addEventListener("resize", e), () => {
|
|
154
|
+
var s;
|
|
155
|
+
window.removeEventListener("resize", e), window.removeEventListener("orientationchange", e), (s = window.visualViewport) == null || s.removeEventListener("resize", e);
|
|
161
156
|
};
|
|
162
|
-
}, [o]),
|
|
157
|
+
}, [o]), n;
|
|
163
158
|
}
|
|
164
|
-
function
|
|
165
|
-
return ["INPUT", "TEXTAREA"].includes(
|
|
166
|
-
|
|
167
|
-
) ||
|
|
159
|
+
function Y(n) {
|
|
160
|
+
return ["INPUT", "TEXTAREA"].includes(n.tagName) && !["button", "submit", "checkbox", "file", "image"].includes(
|
|
161
|
+
n.type
|
|
162
|
+
) || n.hasAttribute("contenteditable");
|
|
168
163
|
}
|
|
169
|
-
function
|
|
170
|
-
const [
|
|
171
|
-
return
|
|
164
|
+
function Nt() {
|
|
165
|
+
const [n, t] = w(!1);
|
|
166
|
+
return C(() => {
|
|
172
167
|
function o(r) {
|
|
173
168
|
if (!r.target) return;
|
|
174
|
-
const
|
|
175
|
-
|
|
169
|
+
const s = r.target;
|
|
170
|
+
Y(s) && t(!0);
|
|
176
171
|
}
|
|
177
|
-
function
|
|
172
|
+
function e(r) {
|
|
178
173
|
if (!r.target) return;
|
|
179
|
-
const
|
|
180
|
-
|
|
174
|
+
const s = r.target;
|
|
175
|
+
Y(s) && t(!1);
|
|
181
176
|
}
|
|
182
|
-
return document.addEventListener("focusin", o), document.addEventListener("focusout",
|
|
183
|
-
document.removeEventListener("focusin", o), document.removeEventListener("focusout",
|
|
177
|
+
return document.addEventListener("focusin", o), document.addEventListener("focusout", e), () => {
|
|
178
|
+
document.removeEventListener("focusin", o), document.removeEventListener("focusout", e);
|
|
184
179
|
};
|
|
185
|
-
}, []),
|
|
180
|
+
}, []), n;
|
|
186
181
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
function
|
|
182
|
+
function kt() {
|
|
183
|
+
C(() => {
|
|
184
|
+
function n() {
|
|
190
185
|
window.scrollTo(0, 0);
|
|
191
186
|
}
|
|
192
|
-
return window.addEventListener("scroll",
|
|
193
|
-
window.removeEventListener("scroll",
|
|
187
|
+
return window.addEventListener("scroll", n), () => {
|
|
188
|
+
window.removeEventListener("scroll", n);
|
|
194
189
|
};
|
|
195
190
|
}, []);
|
|
196
191
|
}
|
|
197
|
-
function at(
|
|
198
|
-
if (
|
|
199
|
-
return
|
|
200
|
-
const t =
|
|
192
|
+
function at(n) {
|
|
193
|
+
if (n.scrollHeight > n.offsetHeight)
|
|
194
|
+
return n;
|
|
195
|
+
const t = n.parentElement;
|
|
201
196
|
if (t)
|
|
202
197
|
return at(t);
|
|
203
198
|
}
|
|
204
|
-
function
|
|
205
|
-
|
|
206
|
-
const t =
|
|
199
|
+
function St(n) {
|
|
200
|
+
C(() => {
|
|
201
|
+
const t = n.current;
|
|
207
202
|
if (!t) return;
|
|
208
203
|
let o;
|
|
209
|
-
function
|
|
210
|
-
|
|
204
|
+
function e(s) {
|
|
205
|
+
s.touches.length === 1 && (o = s.touches[0]);
|
|
211
206
|
}
|
|
212
|
-
function r(
|
|
213
|
-
if (
|
|
214
|
-
const
|
|
215
|
-
if (Math.abs(
|
|
216
|
-
const
|
|
207
|
+
function r(s) {
|
|
208
|
+
if (s.touches.length !== 1 || !o) return;
|
|
209
|
+
const a = o.pageY - s.targetTouches[0].pageY, i = o.pageX - s.targetTouches[0].pageX;
|
|
210
|
+
if (Math.abs(i) > Math.abs(a)) return;
|
|
211
|
+
const u = s.target, d = at(u);
|
|
217
212
|
if (!d) {
|
|
218
|
-
|
|
213
|
+
s.preventDefault();
|
|
219
214
|
return;
|
|
220
215
|
}
|
|
221
|
-
const h =
|
|
222
|
-
if (h &&
|
|
223
|
-
|
|
216
|
+
const h = a < 0, _ = d.scrollTop === 0;
|
|
217
|
+
if (h && _) {
|
|
218
|
+
s.preventDefault();
|
|
224
219
|
return;
|
|
225
220
|
}
|
|
226
|
-
const
|
|
227
|
-
if (!h &&
|
|
228
|
-
|
|
221
|
+
const l = d.scrollTop === d.scrollHeight - d.clientHeight;
|
|
222
|
+
if (!h && l) {
|
|
223
|
+
s.preventDefault();
|
|
229
224
|
return;
|
|
230
225
|
}
|
|
231
226
|
}
|
|
232
|
-
return t.addEventListener("touchstart",
|
|
233
|
-
t.removeEventListener("touchstart",
|
|
227
|
+
return t.addEventListener("touchstart", e), t.addEventListener("touchmove", r), () => {
|
|
228
|
+
t.removeEventListener("touchstart", e), t.removeEventListener("touchmove", r);
|
|
234
229
|
};
|
|
235
|
-
}, [
|
|
230
|
+
}, [n]);
|
|
236
231
|
}
|
|
237
|
-
const
|
|
238
|
-
function
|
|
232
|
+
const D = typeof window < "u" ? rt : null;
|
|
233
|
+
function Rt(n) {
|
|
239
234
|
const t = b(() => {
|
|
240
235
|
const o = window.innerHeight * 0.01;
|
|
241
|
-
|
|
242
|
-
}, [
|
|
243
|
-
|
|
236
|
+
n.current && n.current.style.setProperty("--vh", `${o}px`);
|
|
237
|
+
}, [n]);
|
|
238
|
+
D == null || D(t, [t]), C(() => {
|
|
244
239
|
function o() {
|
|
245
240
|
t(), setTimeout(t, 1e3);
|
|
246
241
|
}
|
|
@@ -249,21 +244,21 @@ function Lt(e) {
|
|
|
249
244
|
};
|
|
250
245
|
}, [t]);
|
|
251
246
|
}
|
|
252
|
-
function
|
|
253
|
-
const { ref: t, onResize: o } =
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
for (const
|
|
257
|
-
const { width:
|
|
258
|
-
o(
|
|
247
|
+
function Lt(n) {
|
|
248
|
+
const { ref: t, onResize: o } = n;
|
|
249
|
+
C(() => {
|
|
250
|
+
const e = new ResizeObserver((r) => {
|
|
251
|
+
for (const s of r) {
|
|
252
|
+
const { width: a, height: i } = s.contentRect;
|
|
253
|
+
o(a, i);
|
|
259
254
|
}
|
|
260
255
|
});
|
|
261
|
-
return t.current &&
|
|
262
|
-
|
|
256
|
+
return t.current && e.observe(t.current), () => {
|
|
257
|
+
e.disconnect();
|
|
263
258
|
};
|
|
264
259
|
}, [t, o]);
|
|
265
260
|
}
|
|
266
|
-
const lt =
|
|
261
|
+
const lt = F({
|
|
267
262
|
avatar: void 0,
|
|
268
263
|
client: null,
|
|
269
264
|
isOpen: !1,
|
|
@@ -273,69 +268,81 @@ const lt = nt({
|
|
|
273
268
|
messageBoxBottomRef: { current: null },
|
|
274
269
|
botTypingPlaceholder: void 0
|
|
275
270
|
});
|
|
276
|
-
function Mt(
|
|
271
|
+
function Mt(n) {
|
|
277
272
|
const {
|
|
278
273
|
avatar: t,
|
|
279
274
|
children: o,
|
|
280
|
-
config:
|
|
275
|
+
config: e,
|
|
281
276
|
botTypingPlaceholder: r,
|
|
282
|
-
customChannelId:
|
|
283
|
-
initMessages:
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
showDebugMessage: a == null ? void 0 : a.showDebugMessage
|
|
298
|
-
}), S = C(
|
|
277
|
+
customChannelId: s,
|
|
278
|
+
initMessages: a
|
|
279
|
+
} = n, i = R(null), u = xt({ config: e }), {
|
|
280
|
+
isOpen: d,
|
|
281
|
+
isResetting: h,
|
|
282
|
+
isConnecting: _,
|
|
283
|
+
conversation: l,
|
|
284
|
+
sendMessage: p,
|
|
285
|
+
resetChannel: f,
|
|
286
|
+
closeChannel: x
|
|
287
|
+
} = wt({
|
|
288
|
+
client: u,
|
|
289
|
+
customChannelId: s,
|
|
290
|
+
initMessages: a
|
|
291
|
+
}), N = v(
|
|
299
292
|
() => ({
|
|
300
293
|
avatar: t,
|
|
301
|
-
client:
|
|
302
|
-
isOpen:
|
|
303
|
-
isResetting:
|
|
304
|
-
isConnecting:
|
|
305
|
-
messages: (
|
|
306
|
-
sendMessage:
|
|
307
|
-
resetChannel:
|
|
308
|
-
closeChannel:
|
|
294
|
+
client: u,
|
|
295
|
+
isOpen: d,
|
|
296
|
+
isResetting: h,
|
|
297
|
+
isConnecting: _,
|
|
298
|
+
messages: (l == null ? void 0 : l.messages) ?? null,
|
|
299
|
+
sendMessage: p,
|
|
300
|
+
resetChannel: f,
|
|
301
|
+
closeChannel: x,
|
|
309
302
|
botTypingPlaceholder: r,
|
|
310
|
-
messageBoxBottomRef:
|
|
303
|
+
messageBoxBottomRef: i
|
|
311
304
|
}),
|
|
312
305
|
[
|
|
313
306
|
t,
|
|
307
|
+
u,
|
|
314
308
|
d,
|
|
315
309
|
h,
|
|
310
|
+
_,
|
|
311
|
+
l == null ? void 0 : l.messages,
|
|
312
|
+
p,
|
|
316
313
|
f,
|
|
317
|
-
|
|
318
|
-
_ == null ? void 0 : _.messages,
|
|
319
|
-
m,
|
|
320
|
-
v,
|
|
321
|
-
E,
|
|
314
|
+
x,
|
|
322
315
|
r
|
|
323
316
|
]
|
|
324
317
|
);
|
|
325
|
-
return /* @__PURE__ */
|
|
326
|
-
}
|
|
327
|
-
function
|
|
328
|
-
return
|
|
329
|
-
}
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
318
|
+
return /* @__PURE__ */ c(lt.Provider, { value: N, children: o });
|
|
319
|
+
}
|
|
320
|
+
function T() {
|
|
321
|
+
return W(lt);
|
|
322
|
+
}
|
|
323
|
+
const ut = F({
|
|
324
|
+
onErrorClick: void 0,
|
|
325
|
+
errorMessageRenderer: void 0
|
|
326
|
+
});
|
|
327
|
+
function zt(n) {
|
|
328
|
+
const { children: t, onErrorClick: o, errorMessageRenderer: e } = n, r = v(
|
|
329
|
+
() => ({ onErrorClick: o, errorMessageRenderer: e }),
|
|
330
|
+
[e, o]
|
|
331
|
+
);
|
|
332
|
+
return /* @__PURE__ */ c(ut.Provider, { value: r, children: t });
|
|
333
|
+
}
|
|
334
|
+
function Ht() {
|
|
335
|
+
return W(ut);
|
|
336
|
+
}
|
|
337
|
+
const Vt = "_chatbot_header_luxt4_1", At = "_chatbot_header__content_luxt4_4", Ot = "_chatbot_header__title_luxt4_12", Bt = "_chatbot_header__extra_luxt4_23", P = {
|
|
338
|
+
chatbot_header: Vt,
|
|
339
|
+
chatbot_header__content: At,
|
|
340
|
+
chatbot_header__title: Ot,
|
|
341
|
+
chatbot_header__extra: Bt
|
|
342
|
+
}, It = (n) => /* @__PURE__ */ g.createElement("svg", { width: 33, height: 32, viewBox: "0 0 33 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...n }, /* @__PURE__ */ g.createElement("g", { clipPath: "url(#clip0_3084_29383)" }, /* @__PURE__ */ g.createElement("path", { d: "M0.410645 16C0.410645 7.16344 7.57409 0 16.4106 0C25.2472 0 32.4106 7.16344 32.4106 16C32.4106 24.8366 25.2472 32 16.4106 32C7.57409 32 0.410645 24.8366 0.410645 16Z", fill: "#333333" }), /* @__PURE__ */ g.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M16.5788 6.33398C19.8925 6.33398 22.5788 9.02028 22.5788 12.334C22.5788 14.2211 21.7075 15.9048 20.3453 17.0047C23.6487 18.3735 26.0607 21.6974 26.4106 25.6673H24.4569C24.0206 21.6274 20.9742 18.4911 17.2591 18.3397L16.9776 18.334H16.5788H15.8437C12.0019 18.334 8.81164 21.5258 8.36437 25.6673H6.41064C6.76857 21.607 9.28344 18.2225 12.7029 16.9143C11.4036 15.8137 10.5788 14.1701 10.5788 12.334C10.5788 9.02028 13.265 6.33398 16.5788 6.33398ZM16.5788 16.334C18.7879 16.334 20.5788 14.5431 20.5788 12.334C20.5788 10.1248 18.7879 8.33398 16.5788 8.33398C14.3696 8.33398 12.5788 10.1248 12.5788 12.334C12.5788 14.5431 14.3696 16.334 16.5788 16.334Z", fill: "#8C8C8C" })), /* @__PURE__ */ g.createElement("defs", null, /* @__PURE__ */ g.createElement("clipPath", { id: "clip0_3084_29383" }, /* @__PURE__ */ g.createElement("path", { d: "M0.410645 16C0.410645 7.16344 7.57409 0 16.4106 0C25.2472 0 32.4106 7.16344 32.4106 16C32.4106 24.8366 25.2472 32 16.4106 32C7.57409 32 0.410645 24.8366 0.410645 16Z", fill: "white" }))));
|
|
343
|
+
function Pt(n) {
|
|
344
|
+
const { avatar: t } = n;
|
|
345
|
+
return t ? /* @__PURE__ */ c(
|
|
339
346
|
"img",
|
|
340
347
|
{
|
|
341
348
|
src: t,
|
|
@@ -346,142 +353,142 @@ function Bt(e) {
|
|
|
346
353
|
borderRadius: "50%"
|
|
347
354
|
}
|
|
348
355
|
}
|
|
349
|
-
) : /* @__PURE__ */
|
|
356
|
+
) : /* @__PURE__ */ c(It, {});
|
|
350
357
|
}
|
|
351
|
-
const
|
|
352
|
-
function
|
|
353
|
-
const { title: t, onReset: o, onClose:
|
|
358
|
+
const Zt = (n) => /* @__PURE__ */ g.createElement("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...n }, /* @__PURE__ */ g.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M3.49453 2.3352C6.44049 -0.226723 10.9105 -0.106316 13.7142 2.69633C16.6428 5.62613 16.6428 10.3739 13.7144 13.3035C10.7846 16.2322 6.03581 16.2322 3.1073 13.3036C2.30873 12.505 1.71132 11.5536 1.34188 10.5109L1.78892 10.3525L1.34171 10.5106L1.22791 10.162C1.01752 9.46018 0.910643 8.73159 0.910643 7.9997H2.4542L2.46382 8.33865C2.49584 8.9024 2.60763 9.46037 2.79674 9.99539L2.7968 9.99536L2.90116 10.2683C3.19714 10.9887 3.63414 11.6475 4.19876 12.2121C6.52451 14.5379 10.2961 14.5379 12.6229 12.212C14.9486 9.88539 14.9486 6.11464 12.6227 3.78781C10.3306 1.49653 6.63579 1.46263 4.30292 3.68622L6.68087 3.68698V5.22954H3.49394H1.95141V3.68698V0.5H3.49394L3.49453 2.3352Z", fill: "#8C8C8C" })), qt = (n) => /* @__PURE__ */ g.createElement("svg", { width: 15, height: 14, viewBox: "0 0 15 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...n }, /* @__PURE__ */ g.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M13.3496 0L7.41062 5.938L1.47162 0L0.411621 1.06L6.34962 6.999L0.411621 12.938L1.47162 13.999L7.41062 8.059L13.3496 13.999L14.4096 12.938L8.47162 6.999L14.4096 1.06L13.3496 0Z", fill: "#8C8C8C" }));
|
|
359
|
+
function Dt(n) {
|
|
360
|
+
const { title: t, onReset: o, onClose: e } = n, { chatbot: r } = L(), { avatar: s, isResetting: a, resetChannel: i, closeChannel: u } = T(), d = v(
|
|
354
361
|
() => ({
|
|
355
362
|
maxWidth: (r == null ? void 0 : r.contentMaxWidth) ?? "1200px",
|
|
356
363
|
borderBottomColor: r == null ? void 0 : r.borderColor
|
|
357
364
|
}),
|
|
358
365
|
[r]
|
|
359
366
|
), h = b(
|
|
360
|
-
(
|
|
361
|
-
|
|
367
|
+
(l) => {
|
|
368
|
+
a || (l.stopPropagation(), o == null || o(), i == null || i());
|
|
362
369
|
},
|
|
363
|
-
[
|
|
364
|
-
),
|
|
365
|
-
(
|
|
366
|
-
|
|
370
|
+
[a, o, i]
|
|
371
|
+
), _ = b(
|
|
372
|
+
(l) => {
|
|
373
|
+
a || (l.stopPropagation(), e == null || e(), u == null || u());
|
|
367
374
|
},
|
|
368
|
-
[
|
|
375
|
+
[a, e, u]
|
|
369
376
|
);
|
|
370
|
-
return /* @__PURE__ */
|
|
371
|
-
/* @__PURE__ */
|
|
372
|
-
/* @__PURE__ */
|
|
373
|
-
/* @__PURE__ */
|
|
377
|
+
return /* @__PURE__ */ c("div", { className: P.chatbot_header, children: /* @__PURE__ */ m("div", { className: P.chatbot_header__content, style: d, children: [
|
|
378
|
+
/* @__PURE__ */ m("div", { className: P.chatbot_header__title, children: [
|
|
379
|
+
/* @__PURE__ */ c(Pt, { avatar: s }),
|
|
380
|
+
/* @__PURE__ */ c("h4", { children: t })
|
|
374
381
|
] }),
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
/* @__PURE__ */
|
|
377
|
-
/* @__PURE__ */
|
|
382
|
+
/* @__PURE__ */ m("div", { className: P.chatbot_header__extra, children: [
|
|
383
|
+
/* @__PURE__ */ c("div", { onClick: h, children: /* @__PURE__ */ c(Zt, {}) }),
|
|
384
|
+
/* @__PURE__ */ c("div", { onClick: _, children: /* @__PURE__ */ c(qt, {}) })
|
|
378
385
|
] })
|
|
379
386
|
] }) });
|
|
380
387
|
}
|
|
381
|
-
const
|
|
382
|
-
chatbot_body:
|
|
383
|
-
chatbot_body__content:
|
|
384
|
-
},
|
|
385
|
-
template_box:
|
|
388
|
+
const $t = "_chatbot_body_f6sqm_1", Ft = "_chatbot_body__content_f6sqm_5", J = {
|
|
389
|
+
chatbot_body: $t,
|
|
390
|
+
chatbot_body__content: Ft
|
|
391
|
+
}, Wt = "_template_box_1ozig_1", M = {
|
|
392
|
+
template_box: Wt,
|
|
386
393
|
"template_box--bot": "_template_box--bot_1ozig_7",
|
|
387
394
|
"template_box--horizontal": "_template_box--horizontal_1ozig_7",
|
|
388
395
|
"template_box--vertical": "_template_box--vertical_1ozig_10",
|
|
389
396
|
"template_box--user": "_template_box--user_1ozig_14"
|
|
390
397
|
};
|
|
391
|
-
function
|
|
392
|
-
var t, o,
|
|
393
|
-
if (typeof
|
|
394
|
-
else if (typeof
|
|
395
|
-
var r =
|
|
396
|
-
for (t = 0; t < r; t++)
|
|
397
|
-
} else for (o in
|
|
398
|
-
return
|
|
399
|
-
}
|
|
400
|
-
function
|
|
401
|
-
for (var
|
|
402
|
-
return
|
|
403
|
-
}
|
|
404
|
-
function
|
|
405
|
-
const { type: t, direction: o = "horizontal", children:
|
|
398
|
+
function dt(n) {
|
|
399
|
+
var t, o, e = "";
|
|
400
|
+
if (typeof n == "string" || typeof n == "number") e += n;
|
|
401
|
+
else if (typeof n == "object") if (Array.isArray(n)) {
|
|
402
|
+
var r = n.length;
|
|
403
|
+
for (t = 0; t < r; t++) n[t] && (o = dt(n[t])) && (e && (e += " "), e += o);
|
|
404
|
+
} else for (o in n) n[o] && (e && (e += " "), e += o);
|
|
405
|
+
return e;
|
|
406
|
+
}
|
|
407
|
+
function E() {
|
|
408
|
+
for (var n, t, o = 0, e = "", r = arguments.length; o < r; o++) (n = arguments[o]) && (t = dt(n)) && (e && (e += " "), e += t);
|
|
409
|
+
return e;
|
|
410
|
+
}
|
|
411
|
+
function I(n) {
|
|
412
|
+
const { type: t, direction: o = "horizontal", children: e } = n, r = v(() => {
|
|
406
413
|
switch (t) {
|
|
407
414
|
case "user":
|
|
408
|
-
return
|
|
415
|
+
return E(M.template_box, M["template_box--user"]);
|
|
409
416
|
case "bot":
|
|
410
417
|
default:
|
|
411
|
-
return
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
o === "horizontal" ?
|
|
418
|
+
return E(
|
|
419
|
+
M.template_box,
|
|
420
|
+
M["template_box--bot"],
|
|
421
|
+
o === "horizontal" ? M["template_box--horizontal"] : M["template_box--vertical"]
|
|
415
422
|
);
|
|
416
423
|
}
|
|
417
424
|
}, [o, t]);
|
|
418
|
-
return /* @__PURE__ */
|
|
425
|
+
return /* @__PURE__ */ c("div", { className: r, children: e });
|
|
419
426
|
}
|
|
420
|
-
const jt = "_template_box_content_fs2wk_1",
|
|
427
|
+
const jt = "_template_box_content_fs2wk_1", Ut = "_content_fs2wk_8", G = {
|
|
421
428
|
template_box_content: jt,
|
|
422
|
-
content:
|
|
423
|
-
},
|
|
424
|
-
quick_replies_box:
|
|
425
|
-
quick_reply:
|
|
429
|
+
content: Ut
|
|
430
|
+
}, Kt = "_quick_replies_box_zoq7y_1", Xt = "_quick_reply_zoq7y_7", Q = {
|
|
431
|
+
quick_replies_box: Kt,
|
|
432
|
+
quick_reply: Xt
|
|
426
433
|
};
|
|
427
|
-
function
|
|
428
|
-
const { quickReplies: t } =
|
|
429
|
-
(
|
|
430
|
-
o == null || o(
|
|
434
|
+
function Yt(n) {
|
|
435
|
+
const { quickReplies: t } = n, { sendMessage: o, isConnecting: e } = T(), r = b(
|
|
436
|
+
(s) => {
|
|
437
|
+
o == null || o(s);
|
|
431
438
|
},
|
|
432
439
|
[o]
|
|
433
440
|
);
|
|
434
|
-
return t != null && t.length ? /* @__PURE__ */
|
|
441
|
+
return t != null && t.length ? /* @__PURE__ */ c("div", { className: Q.quick_replies_box, children: t.map((s) => /* @__PURE__ */ c(
|
|
435
442
|
"button",
|
|
436
443
|
{
|
|
437
|
-
className:
|
|
438
|
-
disabled:
|
|
439
|
-
onClick: () => r(
|
|
440
|
-
children:
|
|
444
|
+
className: Q.quick_reply,
|
|
445
|
+
disabled: e,
|
|
446
|
+
onClick: () => r(s.text),
|
|
447
|
+
children: s.text
|
|
441
448
|
},
|
|
442
|
-
|
|
449
|
+
s.text
|
|
443
450
|
)) }) : null;
|
|
444
451
|
}
|
|
445
|
-
function
|
|
446
|
-
return
|
|
452
|
+
function $(n) {
|
|
453
|
+
return n.toLocaleTimeString("zh-TW", {
|
|
447
454
|
timeZone: "Asia/Taipei",
|
|
448
455
|
hour: "2-digit",
|
|
449
456
|
minute: "2-digit",
|
|
450
457
|
hour12: !1
|
|
451
458
|
});
|
|
452
459
|
}
|
|
453
|
-
const
|
|
454
|
-
time:
|
|
460
|
+
const Jt = "_time_rgg92_1", Gt = {
|
|
461
|
+
time: Jt
|
|
455
462
|
};
|
|
456
|
-
function
|
|
457
|
-
const { time: t, className: o } =
|
|
458
|
-
return t ? /* @__PURE__ */
|
|
459
|
-
}
|
|
460
|
-
function
|
|
461
|
-
const { quickReplies: t, time: o, children:
|
|
462
|
-
return /* @__PURE__ */
|
|
463
|
-
/* @__PURE__ */
|
|
464
|
-
|
|
465
|
-
/* @__PURE__ */
|
|
463
|
+
function j(n) {
|
|
464
|
+
const { time: t, className: o } = n;
|
|
465
|
+
return t ? /* @__PURE__ */ c("div", { className: E(Gt.time, o), children: $(t) }) : null;
|
|
466
|
+
}
|
|
467
|
+
function U(n) {
|
|
468
|
+
const { quickReplies: t, time: o, children: e } = n;
|
|
469
|
+
return /* @__PURE__ */ m("div", { className: G.template_box_content, children: [
|
|
470
|
+
/* @__PURE__ */ m("div", { className: G.content, children: [
|
|
471
|
+
e,
|
|
472
|
+
/* @__PURE__ */ c(j, { time: o })
|
|
466
473
|
] }),
|
|
467
|
-
!!(t != null && t.length) && /* @__PURE__ */
|
|
474
|
+
!!(t != null && t.length) && /* @__PURE__ */ c(Yt, { quickReplies: t })
|
|
468
475
|
] });
|
|
469
476
|
}
|
|
470
|
-
const
|
|
471
|
-
bot_avatar:
|
|
472
|
-
},
|
|
473
|
-
const { avatar: t } =
|
|
474
|
-
return t ? /* @__PURE__ */
|
|
475
|
-
}),
|
|
476
|
-
card_root:
|
|
477
|
-
card_content:
|
|
478
|
-
card_title:
|
|
479
|
-
card_description:
|
|
480
|
-
card_actions:
|
|
477
|
+
const Qt = "_bot_avatar_xrs9x_1", tt = {
|
|
478
|
+
bot_avatar: Qt
|
|
479
|
+
}, te = (n) => /* @__PURE__ */ g.createElement("svg", { viewBox: "0 0 25 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...n }, /* @__PURE__ */ g.createElement("path", { d: "M0.40625 12C0.40625 5.37258 5.77883 0 12.4062 0C19.0337 0 24.4062 5.37258 24.4062 12C24.4062 18.6274 19.0337 24 12.4062 24C5.77883 24 0.40625 18.6274 0.40625 12Z", fill: "#585858" }), /* @__PURE__ */ g.createElement("path", { d: "M6.40625 18.75V15C6.40625 14.5875 6.55313 14.2344 6.84688 13.9406C7.14063 13.6469 7.49375 13.5 7.90625 13.5H16.9062C17.3188 13.5 17.6719 13.6469 17.9656 13.9406C18.2594 14.2344 18.4062 14.5875 18.4062 15V18.75H6.40625ZM10.1562 12.75C9.11875 12.75 8.23438 12.3844 7.50312 11.6531C6.77187 10.9219 6.40625 10.0375 6.40625 9C6.40625 7.9625 6.77187 7.07812 7.50312 6.34687C8.23438 5.61562 9.11875 5.25 10.1562 5.25H14.6562C15.6938 5.25 16.5781 5.61562 17.3094 6.34687C18.0406 7.07812 18.4062 7.9625 18.4062 9C18.4062 10.0375 18.0406 10.9219 17.3094 11.6531C16.5781 12.3844 15.6938 12.75 14.6562 12.75H10.1562ZM7.90625 17.25H16.9062V15H7.90625V17.25ZM10.1562 11.25H14.6562C15.2812 11.25 15.8125 11.0312 16.25 10.5938C16.6875 10.1562 16.9062 9.625 16.9062 9C16.9062 8.375 16.6875 7.84375 16.25 7.40625C15.8125 6.96875 15.2812 6.75 14.6562 6.75H10.1562C9.53125 6.75 9 6.96875 8.5625 7.40625C8.125 7.84375 7.90625 8.375 7.90625 9C7.90625 9.625 8.125 10.1562 8.5625 10.5938C9 11.0312 9.53125 11.25 10.1562 11.25ZM10.1562 9.75C10.3688 9.75 10.5469 9.67812 10.6906 9.53438C10.8344 9.39062 10.9062 9.2125 10.9062 9C10.9062 8.7875 10.8344 8.60938 10.6906 8.46562C10.5469 8.32187 10.3688 8.25 10.1562 8.25C9.94375 8.25 9.76562 8.32187 9.62187 8.46562C9.47812 8.60938 9.40625 8.7875 9.40625 9C9.40625 9.2125 9.47812 9.39062 9.62187 9.53438C9.76562 9.67812 9.94375 9.75 10.1562 9.75ZM14.6562 9.75C14.8687 9.75 15.0469 9.67812 15.1906 9.53438C15.3344 9.39062 15.4062 9.2125 15.4062 9C15.4062 8.7875 15.3344 8.60938 15.1906 8.46562C15.0469 8.32187 14.8687 8.25 14.6562 8.25C14.4438 8.25 14.2656 8.32187 14.1219 8.46562C13.9781 8.60938 13.9062 8.7875 13.9062 9C13.9062 9.2125 13.9781 9.39062 14.1219 9.53438C14.2656 9.67812 14.4438 9.75 14.6562 9.75Z", fill: "white" })), Z = ft((n) => {
|
|
480
|
+
const { avatar: t } = n;
|
|
481
|
+
return t ? /* @__PURE__ */ c("img", { src: t, alt: "Bot Avatar", className: tt.bot_avatar }) : /* @__PURE__ */ c("div", { className: tt.bot_avatar, children: /* @__PURE__ */ c(te, {}) });
|
|
482
|
+
}), ee = "_card_root_1ygom_1", ne = "_card_content_1ygom_10", oe = "_card_title_1ygom_17", re = "_card_description_1ygom_23", se = "_card_actions_1ygom_37", A = {
|
|
483
|
+
card_root: ee,
|
|
484
|
+
card_content: ne,
|
|
485
|
+
card_title: oe,
|
|
486
|
+
card_description: re,
|
|
487
|
+
card_actions: se
|
|
481
488
|
};
|
|
482
|
-
function
|
|
483
|
-
var
|
|
484
|
-
const { template: t } =
|
|
489
|
+
function _t(n) {
|
|
490
|
+
var a;
|
|
491
|
+
const { template: t } = n, { sendMessage: o } = T(), e = v(() => (t == null ? void 0 : t.thumbnailImageUrl.replace(/^http:/, "").replace(/^https:/, "")) || "https://via.assets.so/img.jpg?w=200&h=270&tc=white&bg=#eeeeee", [t]), r = v(() => {
|
|
485
492
|
switch (t == null ? void 0 : t.imageAspectRatio) {
|
|
486
493
|
case "square":
|
|
487
494
|
return "1 / 1";
|
|
@@ -489,25 +496,25 @@ function dt(e) {
|
|
|
489
496
|
default:
|
|
490
497
|
return "1.51 / 1";
|
|
491
498
|
}
|
|
492
|
-
}, [t]),
|
|
493
|
-
(
|
|
494
|
-
switch (
|
|
499
|
+
}, [t]), s = b(
|
|
500
|
+
(i) => function() {
|
|
501
|
+
switch (i.type) {
|
|
495
502
|
case "message":
|
|
496
|
-
o == null || o(
|
|
503
|
+
o == null || o(i.text);
|
|
497
504
|
return;
|
|
498
505
|
case "uri":
|
|
499
|
-
window.open(
|
|
506
|
+
window.open(i.uri, "_blank");
|
|
500
507
|
return;
|
|
501
508
|
}
|
|
502
509
|
},
|
|
503
510
|
[o]
|
|
504
511
|
);
|
|
505
|
-
return /* @__PURE__ */
|
|
506
|
-
(t == null ? void 0 : t.thumbnailImageUrl) && /* @__PURE__ */
|
|
512
|
+
return /* @__PURE__ */ m("div", { className: A.card_root, children: [
|
|
513
|
+
(t == null ? void 0 : t.thumbnailImageUrl) && /* @__PURE__ */ c(
|
|
507
514
|
"img",
|
|
508
515
|
{
|
|
509
516
|
alt: t == null ? void 0 : t.title,
|
|
510
|
-
src:
|
|
517
|
+
src: e,
|
|
511
518
|
style: {
|
|
512
519
|
display: "block",
|
|
513
520
|
width: "100%",
|
|
@@ -517,74 +524,74 @@ function dt(e) {
|
|
|
517
524
|
}
|
|
518
525
|
}
|
|
519
526
|
),
|
|
520
|
-
/* @__PURE__ */
|
|
521
|
-
/* @__PURE__ */
|
|
522
|
-
/* @__PURE__ */
|
|
523
|
-
/* @__PURE__ */
|
|
527
|
+
/* @__PURE__ */ m("div", { className: A.card_content, children: [
|
|
528
|
+
/* @__PURE__ */ c("h5", { className: A.card_title, children: t == null ? void 0 : t.title }),
|
|
529
|
+
/* @__PURE__ */ c("div", { className: A.card_description, children: t == null ? void 0 : t.text }),
|
|
530
|
+
/* @__PURE__ */ c("div", { className: A.card_actions, children: (a = t == null ? void 0 : t.buttons) == null ? void 0 : a.map((i, u) => /* @__PURE__ */ c("button", { onClick: s(i.action), children: i.label }, u)) })
|
|
524
531
|
] })
|
|
525
532
|
] });
|
|
526
533
|
}
|
|
527
|
-
function
|
|
528
|
-
const { message: t } =
|
|
529
|
-
return /* @__PURE__ */
|
|
530
|
-
/* @__PURE__ */
|
|
531
|
-
/* @__PURE__ */
|
|
532
|
-
|
|
534
|
+
function ce(n) {
|
|
535
|
+
const { message: t } = n, { avatar: o } = T(), e = t.message.template;
|
|
536
|
+
return /* @__PURE__ */ m(I, { type: "bot", direction: "horizontal", children: [
|
|
537
|
+
/* @__PURE__ */ c(Z, { avatar: o }),
|
|
538
|
+
/* @__PURE__ */ c(
|
|
539
|
+
U,
|
|
533
540
|
{
|
|
534
541
|
time: t.time,
|
|
535
|
-
quickReplies:
|
|
536
|
-
children: /* @__PURE__ */
|
|
542
|
+
quickReplies: e == null ? void 0 : e.quickReplies,
|
|
543
|
+
children: /* @__PURE__ */ c(_t, { template: e })
|
|
537
544
|
}
|
|
538
545
|
)
|
|
539
546
|
] });
|
|
540
547
|
}
|
|
541
|
-
const
|
|
542
|
-
text:
|
|
548
|
+
const ie = "_text_5fknl_1", ae = "_dot_5fknl_31", y = {
|
|
549
|
+
text: ie,
|
|
543
550
|
"text--user": "_text--user_5fknl_8",
|
|
544
551
|
"text--bot": "_text--bot_5fknl_14",
|
|
545
552
|
"typing-indicator": "_typing-indicator_5fknl_26",
|
|
546
|
-
dot:
|
|
553
|
+
dot: ae
|
|
547
554
|
};
|
|
548
|
-
function
|
|
549
|
-
var
|
|
550
|
-
const { message: t } =
|
|
551
|
-
var
|
|
555
|
+
function et(n) {
|
|
556
|
+
var s;
|
|
557
|
+
const { message: t } = n, { avatar: o } = T(), e = L(), r = v(() => {
|
|
558
|
+
var a, i, u, d;
|
|
552
559
|
switch (t.type) {
|
|
553
560
|
case "user":
|
|
554
561
|
return {
|
|
555
|
-
color: (
|
|
556
|
-
backgroundColor: (
|
|
562
|
+
color: (a = e == null ? void 0 : e.userMessage) == null ? void 0 : a.color,
|
|
563
|
+
backgroundColor: (i = e == null ? void 0 : e.userMessage) == null ? void 0 : i.backgroundColor
|
|
557
564
|
};
|
|
558
565
|
case "bot":
|
|
559
566
|
return {
|
|
560
|
-
color: (
|
|
561
|
-
backgroundColor: (d =
|
|
567
|
+
color: (u = e == null ? void 0 : e.botMessage) == null ? void 0 : u.color,
|
|
568
|
+
backgroundColor: (d = e == null ? void 0 : e.botMessage) == null ? void 0 : d.backgroundColor
|
|
562
569
|
};
|
|
563
570
|
default:
|
|
564
571
|
return {};
|
|
565
572
|
}
|
|
566
|
-
}, [t,
|
|
567
|
-
return t.type === "error" ? null : t.type === "user" ? /* @__PURE__ */
|
|
568
|
-
/* @__PURE__ */
|
|
573
|
+
}, [t, e]);
|
|
574
|
+
return t.type === "error" ? null : t.type === "user" ? /* @__PURE__ */ m(I, { type: "user", direction: "horizontal", children: [
|
|
575
|
+
/* @__PURE__ */ c(
|
|
569
576
|
"div",
|
|
570
577
|
{
|
|
571
|
-
className:
|
|
578
|
+
className: E(y.text, y["text--user"]),
|
|
572
579
|
style: r,
|
|
573
580
|
children: t.text
|
|
574
581
|
}
|
|
575
582
|
),
|
|
576
|
-
/* @__PURE__ */
|
|
577
|
-
] }) : /* @__PURE__ */
|
|
578
|
-
/* @__PURE__ */
|
|
579
|
-
/* @__PURE__ */
|
|
580
|
-
|
|
583
|
+
/* @__PURE__ */ c(j, { time: t.time })
|
|
584
|
+
] }) : /* @__PURE__ */ m(I, { type: "bot", direction: "horizontal", children: [
|
|
585
|
+
/* @__PURE__ */ c(Z, { avatar: o }),
|
|
586
|
+
/* @__PURE__ */ c(
|
|
587
|
+
U,
|
|
581
588
|
{
|
|
582
589
|
time: t.time,
|
|
583
|
-
quickReplies: (
|
|
584
|
-
children: /* @__PURE__ */
|
|
590
|
+
quickReplies: (s = t.message.template) == null ? void 0 : s.quickReplies,
|
|
591
|
+
children: /* @__PURE__ */ c(
|
|
585
592
|
"div",
|
|
586
593
|
{
|
|
587
|
-
className:
|
|
594
|
+
className: E(y.text, y["text--bot"]),
|
|
588
595
|
style: r,
|
|
589
596
|
children: t.message.text
|
|
590
597
|
}
|
|
@@ -593,343 +600,383 @@ function G(e) {
|
|
|
593
600
|
)
|
|
594
601
|
] });
|
|
595
602
|
}
|
|
596
|
-
function
|
|
597
|
-
const { isTyping: t, typingText: o } =
|
|
598
|
-
var
|
|
599
|
-
(
|
|
600
|
-
}, [
|
|
601
|
-
|
|
602
|
-
const
|
|
603
|
+
function ht(n) {
|
|
604
|
+
const { isTyping: t, typingText: o } = n, { messageBoxBottomRef: e, avatar: r } = T(), s = L(), a = R(null), i = b(() => {
|
|
605
|
+
var _;
|
|
606
|
+
(_ = e.current) == null || _.scrollIntoView({ behavior: "smooth" });
|
|
607
|
+
}, [e]);
|
|
608
|
+
Lt({ ref: a, onResize: i });
|
|
609
|
+
const u = yt(t, 500), d = v(
|
|
603
610
|
() => {
|
|
604
|
-
var
|
|
611
|
+
var _, l;
|
|
605
612
|
return {
|
|
606
|
-
color: (
|
|
607
|
-
backgroundColor: (
|
|
613
|
+
color: (_ = s == null ? void 0 : s.botMessage) == null ? void 0 : _.color,
|
|
614
|
+
backgroundColor: (l = s == null ? void 0 : s.botMessage) == null ? void 0 : l.backgroundColor
|
|
608
615
|
};
|
|
609
616
|
},
|
|
610
|
-
[
|
|
617
|
+
[s]
|
|
618
|
+
), h = v(
|
|
619
|
+
() => {
|
|
620
|
+
var _;
|
|
621
|
+
return {
|
|
622
|
+
backgroundColor: (_ = s == null ? void 0 : s.botMessage) == null ? void 0 : _.color
|
|
623
|
+
};
|
|
624
|
+
},
|
|
625
|
+
[s]
|
|
611
626
|
);
|
|
612
|
-
return
|
|
613
|
-
/* @__PURE__ */
|
|
614
|
-
/* @__PURE__ */
|
|
627
|
+
return u ? /* @__PURE__ */ m(I, { type: "bot", direction: "horizontal", children: [
|
|
628
|
+
/* @__PURE__ */ c(Z, { avatar: r }),
|
|
629
|
+
/* @__PURE__ */ c(U, { time: /* @__PURE__ */ new Date(), children: /* @__PURE__ */ c(
|
|
615
630
|
"div",
|
|
616
631
|
{
|
|
617
|
-
ref:
|
|
618
|
-
className:
|
|
632
|
+
ref: a,
|
|
633
|
+
className: E(y.text, y["text--bot"]),
|
|
619
634
|
style: d,
|
|
620
|
-
children: /* @__PURE__ */
|
|
635
|
+
children: /* @__PURE__ */ m("span", { children: [
|
|
621
636
|
o ?? "",
|
|
622
|
-
|
|
623
|
-
/* @__PURE__ */
|
|
624
|
-
/* @__PURE__ */
|
|
625
|
-
/* @__PURE__ */
|
|
637
|
+
u && /* @__PURE__ */ m("span", { className: y["typing-indicator"], children: [
|
|
638
|
+
/* @__PURE__ */ c("div", { className: y.dot, style: h }),
|
|
639
|
+
/* @__PURE__ */ c("div", { className: y.dot, style: h }),
|
|
640
|
+
/* @__PURE__ */ c("div", { className: y.dot, style: h })
|
|
626
641
|
] })
|
|
627
642
|
] })
|
|
628
643
|
}
|
|
629
644
|
) })
|
|
630
645
|
] }) : null;
|
|
631
646
|
}
|
|
632
|
-
function
|
|
633
|
-
const { placeholder: t } =
|
|
634
|
-
() => Array.from((
|
|
635
|
-
(
|
|
647
|
+
function le(n) {
|
|
648
|
+
const { placeholder: t } = n, { isConnecting: o, messages: e } = T(), r = v(
|
|
649
|
+
() => Array.from((e == null ? void 0 : e.values()) ?? []).some(
|
|
650
|
+
(s) => s.type === "bot" && s.isTyping
|
|
636
651
|
),
|
|
637
|
-
[
|
|
652
|
+
[e]
|
|
638
653
|
);
|
|
639
|
-
return o && !r ? /* @__PURE__ */
|
|
654
|
+
return o && !r ? /* @__PURE__ */ c(ht, { isTyping: !0, typingText: t }) : null;
|
|
640
655
|
}
|
|
641
|
-
const
|
|
642
|
-
carousel_root:
|
|
643
|
-
carousel_time:
|
|
656
|
+
const ue = "_carousel_root_sv1hc_1", de = "_carousel_time_sv1hc_12", nt = {
|
|
657
|
+
carousel_root: ue,
|
|
658
|
+
carousel_time: de
|
|
644
659
|
};
|
|
645
|
-
function
|
|
660
|
+
function _e(n) {
|
|
646
661
|
var r;
|
|
647
|
-
const { message: t } =
|
|
648
|
-
return /* @__PURE__ */
|
|
649
|
-
/* @__PURE__ */
|
|
650
|
-
/* @__PURE__ */
|
|
651
|
-
/* @__PURE__ */
|
|
662
|
+
const { message: t } = n, { avatar: o } = T(), e = t.message.template;
|
|
663
|
+
return /* @__PURE__ */ m(I, { type: "bot", direction: "vertical", children: [
|
|
664
|
+
/* @__PURE__ */ c(Z, { avatar: o }),
|
|
665
|
+
/* @__PURE__ */ c("div", { className: nt.carousel_root, children: (r = e.columns) == null ? void 0 : r.map((s, a) => /* @__PURE__ */ c(_t, { template: s }, a)) }),
|
|
666
|
+
/* @__PURE__ */ c(j, { className: nt.carousel_time, time: t.time })
|
|
652
667
|
] });
|
|
653
668
|
}
|
|
654
|
-
const
|
|
655
|
-
hint_root:
|
|
656
|
-
|
|
657
|
-
|
|
669
|
+
const he = "_hint_root_1bw94_1", ge = "_error_hint_title_1bw94_16", me = "_error_hint_message_1bw94_22", fe = "_time_1bw94_31", z = {
|
|
670
|
+
hint_root: he,
|
|
671
|
+
error_hint_title: ge,
|
|
672
|
+
error_hint_message: me,
|
|
673
|
+
time: fe
|
|
658
674
|
};
|
|
659
|
-
function
|
|
660
|
-
const { message: t } = e
|
|
675
|
+
function ot(n) {
|
|
676
|
+
const { message: t } = n, { onErrorClick: o, errorMessageRenderer: e } = Ht(), r = b(() => {
|
|
677
|
+
o == null || o(t);
|
|
678
|
+
}, [t, o]);
|
|
661
679
|
if (t.type === "user") return null;
|
|
662
680
|
if (t.type === "error")
|
|
663
|
-
return /* @__PURE__ */
|
|
664
|
-
/* @__PURE__ */
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
681
|
+
return /* @__PURE__ */ c("div", { className: z.hint_root, children: (e == null ? void 0 : e(t)) ?? /* @__PURE__ */ m(mt, { children: [
|
|
682
|
+
/* @__PURE__ */ m("div", { className: z.error_hint_title, children: [
|
|
683
|
+
/* @__PURE__ */ c("span", { className: z.time, children: $(t.time) }),
|
|
684
|
+
/* @__PURE__ */ c("span", { children: "Unexpected error" })
|
|
685
|
+
] }),
|
|
686
|
+
o && /* @__PURE__ */ m(
|
|
687
|
+
"div",
|
|
688
|
+
{
|
|
689
|
+
className: z.error_hint_message,
|
|
690
|
+
onClick: r,
|
|
691
|
+
children: [
|
|
692
|
+
"Click ",
|
|
693
|
+
/* @__PURE__ */ c("span", { children: "here" }),
|
|
694
|
+
" to view the report."
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
)
|
|
698
|
+
] }) });
|
|
699
|
+
const s = t.message.template;
|
|
700
|
+
return s.type !== O.HINT ? null : /* @__PURE__ */ m("div", { className: z.hint_root, children: [
|
|
701
|
+
/* @__PURE__ */ c("div", { className: z.time, children: $(t.time) }),
|
|
702
|
+
s.text
|
|
671
703
|
] });
|
|
672
704
|
}
|
|
673
|
-
function
|
|
705
|
+
function be(n) {
|
|
674
706
|
var o;
|
|
675
|
-
const { message: t } =
|
|
707
|
+
const { message: t } = n;
|
|
676
708
|
if (t.type === "user")
|
|
677
|
-
return /* @__PURE__ */
|
|
709
|
+
return /* @__PURE__ */ c(et, { message: t });
|
|
678
710
|
if (t.type === "error")
|
|
679
|
-
return /* @__PURE__ */
|
|
711
|
+
return /* @__PURE__ */ c(ot, { message: t });
|
|
680
712
|
if (t.isTyping)
|
|
681
|
-
return /* @__PURE__ */
|
|
682
|
-
|
|
713
|
+
return /* @__PURE__ */ c(
|
|
714
|
+
ht,
|
|
683
715
|
{
|
|
684
716
|
isTyping: t.isTyping,
|
|
685
717
|
typingText: t.typingText
|
|
686
718
|
}
|
|
687
719
|
);
|
|
688
720
|
switch ((o = t.message.template) == null ? void 0 : o.type) {
|
|
689
|
-
case
|
|
690
|
-
return /* @__PURE__ */
|
|
691
|
-
case
|
|
692
|
-
return /* @__PURE__ */
|
|
693
|
-
case
|
|
694
|
-
return /* @__PURE__ */
|
|
695
|
-
case
|
|
696
|
-
return /* @__PURE__ */
|
|
721
|
+
case O.TEXT:
|
|
722
|
+
return /* @__PURE__ */ c(et, { message: t });
|
|
723
|
+
case O.HINT:
|
|
724
|
+
return /* @__PURE__ */ c(ot, { message: t });
|
|
725
|
+
case O.BUTTON:
|
|
726
|
+
return /* @__PURE__ */ c(ce, { message: t });
|
|
727
|
+
case O.CAROUSEL:
|
|
728
|
+
return /* @__PURE__ */ c(_e, { message: t });
|
|
697
729
|
default:
|
|
698
|
-
return /* @__PURE__ */
|
|
730
|
+
return /* @__PURE__ */ c("div", {});
|
|
699
731
|
}
|
|
700
732
|
}
|
|
701
|
-
function
|
|
702
|
-
const { chatbot:
|
|
703
|
-
|
|
704
|
-
var
|
|
705
|
-
(
|
|
733
|
+
function pe() {
|
|
734
|
+
const { chatbot: n } = L(), { messages: t, messageBoxBottomRef: o, botTypingPlaceholder: e } = T();
|
|
735
|
+
C(() => {
|
|
736
|
+
var s;
|
|
737
|
+
(s = o.current) == null || s.scrollIntoView({ behavior: "smooth" });
|
|
706
738
|
}, [t, o]);
|
|
707
|
-
const r =
|
|
739
|
+
const r = v(
|
|
708
740
|
() => ({
|
|
709
|
-
maxWidth: (
|
|
741
|
+
maxWidth: (n == null ? void 0 : n.contentMaxWidth) ?? "1200px"
|
|
710
742
|
}),
|
|
711
|
-
[
|
|
743
|
+
[n]
|
|
712
744
|
);
|
|
713
|
-
return /* @__PURE__ */
|
|
714
|
-
Array.from((t == null ? void 0 : t.values()) ?? []).map((
|
|
715
|
-
|
|
745
|
+
return /* @__PURE__ */ c("div", { className: J.chatbot_body, children: /* @__PURE__ */ m("div", { className: J.chatbot_body__content, style: r, children: [
|
|
746
|
+
Array.from((t == null ? void 0 : t.values()) ?? []).map((s) => /* @__PURE__ */ c(
|
|
747
|
+
be,
|
|
716
748
|
{
|
|
717
|
-
message:
|
|
749
|
+
message: s
|
|
718
750
|
},
|
|
719
|
-
|
|
751
|
+
s.messageId
|
|
720
752
|
)),
|
|
721
|
-
/* @__PURE__ */
|
|
722
|
-
|
|
753
|
+
/* @__PURE__ */ c(
|
|
754
|
+
le,
|
|
723
755
|
{
|
|
724
|
-
placeholder:
|
|
756
|
+
placeholder: e ?? "正在輸入訊息"
|
|
725
757
|
}
|
|
726
758
|
),
|
|
727
|
-
/* @__PURE__ */
|
|
759
|
+
/* @__PURE__ */ c("div", { ref: o })
|
|
728
760
|
] }) });
|
|
729
761
|
}
|
|
730
|
-
const
|
|
731
|
-
chatbot_footer:
|
|
732
|
-
chatbot_footer__content:
|
|
733
|
-
chatbot_textarea:
|
|
734
|
-
chatbot_submit_button:
|
|
735
|
-
chatbot_submit_button__disabled:
|
|
736
|
-
},
|
|
737
|
-
function
|
|
738
|
-
const { setValue: t, className: o } =
|
|
739
|
-
|
|
740
|
-
const
|
|
741
|
-
if (!
|
|
742
|
-
const
|
|
743
|
-
|
|
744
|
-
for (let
|
|
745
|
-
|
|
746
|
-
},
|
|
747
|
-
alert(`語音識別錯誤: ${JSON.stringify(
|
|
748
|
-
},
|
|
762
|
+
const Ce = "_chatbot_footer_1slg7_1", ve = "_chatbot_footer__content_1slg7_4", xe = "_chatbot_textarea_1slg7_14", we = "_chatbot_submit_button_1slg7_29", ye = "_chatbot_submit_button__disabled_1slg7_54", S = {
|
|
763
|
+
chatbot_footer: Ce,
|
|
764
|
+
chatbot_footer__content: ve,
|
|
765
|
+
chatbot_textarea: xe,
|
|
766
|
+
chatbot_submit_button: we,
|
|
767
|
+
chatbot_submit_button__disabled: ye
|
|
768
|
+
}, Te = (n) => /* @__PURE__ */ g.createElement("svg", { width: 15, height: 12, viewBox: "0 0 15 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...n }, /* @__PURE__ */ g.createElement("path", { d: "M0.823242 11.6953V0.945312L14.3328 6.32031L0.823242 11.6953ZM1.90658 10.0911L11.3649 6.32031L1.90658 2.54948V4.98052L5.92574 6.32031L1.90658 7.6601V10.0911Z", fill: "white" })), Ee = (n) => /* @__PURE__ */ g.createElement("svg", { width: 11, height: 16, viewBox: "0 0 11 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...n }, /* @__PURE__ */ g.createElement("path", { d: "M5.40658 9.90397C4.82435 9.90397 4.33158 9.7023 3.92824 9.29897C3.52491 8.89564 3.32324 8.40286 3.32324 7.82064V2.82064C3.32324 2.23842 3.52491 1.74564 3.92824 1.3423C4.33158 0.938971 4.82435 0.737305 5.40658 0.737305C5.9888 0.737305 6.48158 0.938971 6.88491 1.3423C7.28824 1.74564 7.48991 2.23842 7.48991 2.82064V7.82064C7.48991 8.40286 7.28824 8.89564 6.88491 9.29897C6.48158 9.7023 5.9888 9.90397 5.40658 9.90397ZM4.86491 15.1123V12.8654C3.56213 12.7208 2.47949 12.1724 1.61699 11.2202C0.754492 10.2679 0.323242 9.13467 0.323242 7.82064H1.40658C1.40658 8.92731 1.79706 9.87064 2.57803 10.6506C3.35887 11.4306 4.30331 11.8206 5.41137 11.8206C6.51928 11.8206 7.46213 11.4306 8.23991 10.6506C9.01769 9.87064 9.40658 8.92731 9.40658 7.82064H10.4899C10.4899 9.13467 10.0587 10.2679 9.19616 11.2202C8.33366 12.1724 7.25102 12.7208 5.94824 12.8654V15.1123H4.86491ZM5.40658 8.82064C5.68991 8.82064 5.92741 8.7248 6.11908 8.53314C6.31074 8.34147 6.40658 8.10397 6.40658 7.82064V2.82064C6.40658 2.5373 6.31074 2.2998 6.11908 2.10814C5.92741 1.91647 5.68991 1.82064 5.40658 1.82064C5.12324 1.82064 4.88574 1.91647 4.69408 2.10814C4.50241 2.2998 4.40658 2.5373 4.40658 2.82064V7.82064C4.40658 8.10397 4.50241 8.34147 4.69408 8.53314C4.88574 8.7248 5.12324 8.82064 5.40658 8.82064Z", fill: "white" })), Ne = (n) => /* @__PURE__ */ g.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", xmlns: "http://www.w3.org/2000/svg", ...n }, /* @__PURE__ */ g.createElement("circle", { cx: 20, cy: 20, r: 18, fill: "#D04444" }), /* @__PURE__ */ g.createElement("rect", { x: 12, y: 12, width: 16, height: 16, fill: "#FFFFFF", rx: 2, ry: 2 }));
|
|
769
|
+
function ke(n) {
|
|
770
|
+
const { setValue: t, className: o } = n, [e, r] = w(!1), s = R(null);
|
|
771
|
+
C(() => {
|
|
772
|
+
const l = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
773
|
+
if (!l) return;
|
|
774
|
+
const p = new l();
|
|
775
|
+
p.lang = "zh-TW", p.continuous = !0, p.interimResults = !0, p.onresult = (f) => {
|
|
776
|
+
for (let x = f.resultIndex; x < f.results.length; x++)
|
|
777
|
+
f.results[x].isFinal && t((N) => N + f.results[x][0].transcript);
|
|
778
|
+
}, p.onerror = (f) => {
|
|
779
|
+
alert(`語音識別錯誤: ${JSON.stringify(f.error)}`);
|
|
780
|
+
}, p.onend = () => {
|
|
749
781
|
r(!1);
|
|
750
|
-
},
|
|
782
|
+
}, s.current = p;
|
|
751
783
|
}, [t]);
|
|
752
|
-
const
|
|
753
|
-
if (!
|
|
784
|
+
const a = b(() => {
|
|
785
|
+
if (!s.current) {
|
|
754
786
|
alert("無法開始辨識: 語音識別器未初始化,請檢查是否有授權使用麥克風");
|
|
755
787
|
return;
|
|
756
788
|
}
|
|
757
789
|
try {
|
|
758
|
-
|
|
759
|
-
} catch (
|
|
760
|
-
alert(`無法開始辨識: ${JSON.stringify(
|
|
790
|
+
s.current.start(), r(!0);
|
|
791
|
+
} catch (l) {
|
|
792
|
+
alert(`無法開始辨識: ${JSON.stringify(l)}`);
|
|
761
793
|
}
|
|
762
|
-
}, []),
|
|
763
|
-
|
|
764
|
-
}, []),
|
|
765
|
-
(
|
|
766
|
-
|
|
794
|
+
}, []), i = b(() => {
|
|
795
|
+
s.current && (s.current.stop(), r(!1));
|
|
796
|
+
}, []), u = b(
|
|
797
|
+
(l) => {
|
|
798
|
+
e || (l.preventDefault(), a());
|
|
767
799
|
},
|
|
768
|
-
[
|
|
800
|
+
[e, a]
|
|
769
801
|
), d = b(
|
|
770
|
-
(
|
|
771
|
-
|
|
802
|
+
(l) => {
|
|
803
|
+
e && (l.preventDefault(), i());
|
|
772
804
|
},
|
|
773
|
-
[
|
|
805
|
+
[e, i]
|
|
774
806
|
), h = b(
|
|
775
|
-
(
|
|
776
|
-
|
|
807
|
+
(l) => {
|
|
808
|
+
e || (l.preventDefault(), a());
|
|
777
809
|
},
|
|
778
|
-
[
|
|
779
|
-
),
|
|
780
|
-
(
|
|
781
|
-
|
|
810
|
+
[e, a]
|
|
811
|
+
), _ = b(
|
|
812
|
+
(l) => {
|
|
813
|
+
e && (l.preventDefault(), i());
|
|
782
814
|
},
|
|
783
|
-
[
|
|
815
|
+
[e, i]
|
|
784
816
|
);
|
|
785
|
-
return /* @__PURE__ */
|
|
817
|
+
return /* @__PURE__ */ c(
|
|
786
818
|
"div",
|
|
787
819
|
{
|
|
788
820
|
className: o,
|
|
789
|
-
onMouseDown:
|
|
821
|
+
onMouseDown: u,
|
|
790
822
|
onMouseUp: d,
|
|
791
823
|
onTouchStart: h,
|
|
792
|
-
onTouchEnd:
|
|
793
|
-
children:
|
|
824
|
+
onTouchEnd: _,
|
|
825
|
+
children: e ? /* @__PURE__ */ c(Ne, {}) : /* @__PURE__ */ c(Ee, {})
|
|
794
826
|
}
|
|
795
827
|
);
|
|
796
828
|
}
|
|
797
|
-
function
|
|
798
|
-
const { sendMessage:
|
|
799
|
-
() => t || !
|
|
800
|
-
[t,
|
|
801
|
-
), d =
|
|
829
|
+
function Se() {
|
|
830
|
+
const { sendMessage: n, isConnecting: t } = T(), { chatbot: o } = L(), [e, r] = w(""), [s, a] = w(!1), i = R(null), u = v(
|
|
831
|
+
() => t || !e.trim(),
|
|
832
|
+
[t, e]
|
|
833
|
+
), d = v(
|
|
802
834
|
() => ({
|
|
803
835
|
maxWidth: (o == null ? void 0 : o.contentMaxWidth) ?? "1200px",
|
|
804
836
|
borderTopColor: o == null ? void 0 : o.borderColor
|
|
805
837
|
}),
|
|
806
838
|
[o]
|
|
807
839
|
), h = b(
|
|
808
|
-
(
|
|
809
|
-
const
|
|
810
|
-
|
|
840
|
+
(p) => {
|
|
841
|
+
const f = p.target, x = f.value;
|
|
842
|
+
f.style.height = "36px", x && (f.style.height = `${f.scrollHeight}px`), r(p.target.value);
|
|
811
843
|
},
|
|
812
844
|
[]
|
|
813
|
-
),
|
|
814
|
-
!
|
|
815
|
-
}, [
|
|
816
|
-
(
|
|
817
|
-
if (
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
|
|
845
|
+
), _ = b(() => {
|
|
846
|
+
!s && !t && (n == null || n(e), r(""), i.current && (i.current.style.height = "36px"));
|
|
847
|
+
}, [s, t, n, e]), l = b(
|
|
848
|
+
(p) => {
|
|
849
|
+
if (p.key === "Enter" && !s && !t && e.trim()) {
|
|
850
|
+
n == null || n(e), r("");
|
|
851
|
+
const f = p.target;
|
|
852
|
+
f.style.height = "36px";
|
|
821
853
|
}
|
|
822
854
|
},
|
|
823
|
-
[
|
|
855
|
+
[s, t, n, e]
|
|
824
856
|
);
|
|
825
|
-
return /* @__PURE__ */
|
|
826
|
-
/* @__PURE__ */
|
|
857
|
+
return /* @__PURE__ */ c("div", { className: S.chatbot_footer, children: /* @__PURE__ */ m("div", { className: S.chatbot_footer__content, style: d, children: [
|
|
858
|
+
/* @__PURE__ */ c(
|
|
827
859
|
"textarea",
|
|
828
860
|
{
|
|
829
|
-
ref:
|
|
830
|
-
className:
|
|
861
|
+
ref: i,
|
|
862
|
+
className: S.chatbot_textarea,
|
|
831
863
|
disabled: t,
|
|
832
864
|
cols: 40,
|
|
833
|
-
value:
|
|
865
|
+
value: e,
|
|
834
866
|
placeholder: "Enter message",
|
|
835
867
|
onChange: h,
|
|
836
|
-
onKeyDown:
|
|
837
|
-
onCompositionStart: () =>
|
|
838
|
-
onCompositionEnd: () =>
|
|
868
|
+
onKeyDown: l,
|
|
869
|
+
onCompositionStart: () => a(!0),
|
|
870
|
+
onCompositionEnd: () => a(!1)
|
|
839
871
|
}
|
|
840
872
|
),
|
|
841
|
-
|
|
873
|
+
e ? /* @__PURE__ */ c(
|
|
842
874
|
"button",
|
|
843
875
|
{
|
|
844
|
-
className:
|
|
845
|
-
|
|
846
|
-
|
|
876
|
+
className: E(
|
|
877
|
+
S.chatbot_submit_button,
|
|
878
|
+
u && S.chatbot_submit_button__disabled
|
|
847
879
|
),
|
|
848
|
-
disabled:
|
|
849
|
-
onClick:
|
|
850
|
-
children: /* @__PURE__ */
|
|
880
|
+
disabled: u,
|
|
881
|
+
onClick: _,
|
|
882
|
+
children: /* @__PURE__ */ c(Te, {})
|
|
851
883
|
}
|
|
852
|
-
) : /* @__PURE__ */
|
|
853
|
-
|
|
884
|
+
) : /* @__PURE__ */ c(
|
|
885
|
+
ke,
|
|
854
886
|
{
|
|
855
887
|
setValue: r,
|
|
856
|
-
className:
|
|
857
|
-
|
|
858
|
-
t &&
|
|
888
|
+
className: E(
|
|
889
|
+
S.chatbot_submit_button,
|
|
890
|
+
t && S.chatbot_submit_button__disabled
|
|
859
891
|
)
|
|
860
892
|
}
|
|
861
893
|
)
|
|
862
894
|
] }) });
|
|
863
895
|
}
|
|
864
|
-
const
|
|
865
|
-
chatbot_root:
|
|
866
|
-
full_screen:
|
|
867
|
-
chatbot_container:
|
|
868
|
-
screen_keyboard_open:
|
|
896
|
+
const Re = "_chatbot_root_1t5cx_1", Le = "_full_screen_1t5cx_122", Me = "_chatbot_container_1t5cx_130", ze = "_screen_keyboard_open_1t5cx_135", B = {
|
|
897
|
+
chatbot_root: Re,
|
|
898
|
+
full_screen: Le,
|
|
899
|
+
chatbot_container: Me,
|
|
900
|
+
screen_keyboard_open: ze
|
|
869
901
|
};
|
|
870
|
-
function
|
|
871
|
-
const { children: t } =
|
|
872
|
-
|
|
873
|
-
const [,
|
|
874
|
-
|
|
902
|
+
function He(n) {
|
|
903
|
+
const { children: t } = n, o = R(null), e = L();
|
|
904
|
+
St(o), kt();
|
|
905
|
+
const [, r] = Et() ?? [], s = Nt(), a = v(() => {
|
|
906
|
+
var i, u;
|
|
907
|
+
return Object.assign(
|
|
908
|
+
(i = e == null ? void 0 : e.chatbot) != null && i.backgroundColor ? {
|
|
909
|
+
backgroundColor: (u = e.chatbot) == null ? void 0 : u.backgroundColor
|
|
910
|
+
} : {},
|
|
911
|
+
s ? { height: r } : {}
|
|
912
|
+
);
|
|
913
|
+
}, [r, s, e]);
|
|
914
|
+
return /* @__PURE__ */ c("div", { className: B.full_screen, children: /* @__PURE__ */ c(
|
|
875
915
|
"div",
|
|
876
916
|
{
|
|
877
917
|
ref: o,
|
|
878
|
-
className:
|
|
879
|
-
|
|
880
|
-
|
|
918
|
+
className: E(
|
|
919
|
+
B.chatbot_container,
|
|
920
|
+
s && B.screen_keyboard_open
|
|
881
921
|
),
|
|
882
|
-
style:
|
|
922
|
+
style: a,
|
|
883
923
|
children: t
|
|
884
924
|
}
|
|
885
925
|
) });
|
|
886
926
|
}
|
|
887
|
-
function
|
|
888
|
-
const { fullScreen: t, children: o } =
|
|
889
|
-
|
|
890
|
-
const r =
|
|
891
|
-
return /* @__PURE__ */
|
|
927
|
+
function Ve(n) {
|
|
928
|
+
const { fullScreen: t, children: o } = n, e = R(null);
|
|
929
|
+
Rt(e);
|
|
930
|
+
const r = L();
|
|
931
|
+
return /* @__PURE__ */ c("div", { ref: e, className: B.chatbot_root, children: t ? /* @__PURE__ */ c(He, { children: o }) : /* @__PURE__ */ c("div", { className: B.chatbot_container, style: r == null ? void 0 : r.chatbot, children: o }) });
|
|
892
932
|
}
|
|
893
|
-
function
|
|
933
|
+
function Ie(n) {
|
|
894
934
|
const {
|
|
895
935
|
title: t,
|
|
896
936
|
theme: o,
|
|
897
|
-
config:
|
|
937
|
+
config: e,
|
|
898
938
|
customChannelId: r,
|
|
899
|
-
initMessages:
|
|
900
|
-
debugMode: i = !1,
|
|
939
|
+
initMessages: s,
|
|
901
940
|
fullScreen: a = !1,
|
|
902
|
-
avatar:
|
|
903
|
-
botTypingPlaceholder:
|
|
904
|
-
onReset:
|
|
905
|
-
onClose:
|
|
906
|
-
|
|
907
|
-
|
|
941
|
+
avatar: i,
|
|
942
|
+
botTypingPlaceholder: u,
|
|
943
|
+
onReset: d,
|
|
944
|
+
onClose: h,
|
|
945
|
+
onErrorClick: _,
|
|
946
|
+
errorMessageRenderer: l
|
|
947
|
+
} = n;
|
|
948
|
+
return /* @__PURE__ */ c(vt, { theme: o, children: /* @__PURE__ */ c(
|
|
908
949
|
Mt,
|
|
909
950
|
{
|
|
910
|
-
avatar:
|
|
911
|
-
config:
|
|
951
|
+
avatar: i,
|
|
952
|
+
config: e,
|
|
912
953
|
customChannelId: r,
|
|
913
|
-
initMessages:
|
|
914
|
-
botTypingPlaceholder:
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
/* @__PURE__ */
|
|
918
|
-
|
|
919
|
-
|
|
954
|
+
initMessages: s,
|
|
955
|
+
botTypingPlaceholder: u,
|
|
956
|
+
children: /* @__PURE__ */ m(Ve, { fullScreen: a, children: [
|
|
957
|
+
/* @__PURE__ */ c(Dt, { title: t, onReset: d, onClose: h }),
|
|
958
|
+
/* @__PURE__ */ c(
|
|
959
|
+
zt,
|
|
960
|
+
{
|
|
961
|
+
onErrorClick: _,
|
|
962
|
+
errorMessageRenderer: l,
|
|
963
|
+
children: /* @__PURE__ */ c(pe, {})
|
|
964
|
+
}
|
|
965
|
+
),
|
|
966
|
+
/* @__PURE__ */ c(Se, {})
|
|
920
967
|
] })
|
|
921
968
|
}
|
|
922
969
|
) });
|
|
923
970
|
}
|
|
924
971
|
export {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
972
|
+
Ie as Chatbot,
|
|
973
|
+
xt as useAsgardServiceClient,
|
|
974
|
+
wt as useChannel,
|
|
975
|
+
yt as useDebounce,
|
|
976
|
+
Nt as useIsOnScreenKeyboardOpen,
|
|
977
|
+
kt as useOnScreenKeyboardScrollFix,
|
|
978
|
+
St as usePreventOverScrolling,
|
|
979
|
+
Lt as useResizeObserver,
|
|
980
|
+
Rt as useUpdateVh,
|
|
981
|
+
Et as useViewportSize
|
|
935
982
|
};
|