@asgard-js/react 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/chatbot/chatbot-header.d.ts.map +1 -1
- package/dist/components/chatbot/chatbot.d.ts +1 -0
- package/dist/components/chatbot/chatbot.d.ts.map +1 -1
- package/dist/components/chatbot/profile-icon.d.ts +5 -1
- package/dist/components/chatbot/profile-icon.d.ts.map +1 -1
- package/dist/components/templates/avatar/avatar.d.ts.map +1 -1
- package/dist/components/templates/quick-replies/quick-replies.d.ts.map +1 -1
- package/dist/context/asgard-service-context.d.ts +2 -0
- package/dist/context/asgard-service-context.d.ts.map +1 -1
- package/dist/hooks/use-channel.d.ts +1 -0
- package/dist/hooks/use-channel.d.ts.map +1 -1
- package/dist/index.js +291 -268
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatbot-header.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot-header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"chatbot-header.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot-header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKlC,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAgBlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatbot.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAQpE,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1C;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"chatbot.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAQpE,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1C;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,CA4BtD"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface ProfileIconProps {
|
|
4
|
+
avatar?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function ProfileIcon(props: ProfileIconProps): ReactNode;
|
|
7
|
+
export {};
|
|
4
8
|
//# sourceMappingURL=profile-icon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-icon.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/profile-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"profile-icon.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/profile-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,CA+C9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/avatar/avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/avatar/avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,wBAAgB,MAAM,IAAI,SAAS,CA0BlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quick-replies.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/quick-replies/quick-replies.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AAI/C,UAAU,iBAAiB;IACzB,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"quick-replies.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/quick-replies/quick-replies.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AAI/C,UAAU,iBAAiB;IACzB,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CA8BhE"}
|
|
@@ -3,6 +3,7 @@ import { DetailedHTMLProps, HTMLAttributes, ReactNode, RefObject } from 'react';
|
|
|
3
3
|
import { AsgardServiceClient, ClientConfig, ConversationBotMessage, ConversationMessage } from '@asgard-js/core';
|
|
4
4
|
|
|
5
5
|
interface AsgardServiceContextType {
|
|
6
|
+
avatar?: string;
|
|
6
7
|
client: AsgardServiceClient | null;
|
|
7
8
|
isConnecting: boolean;
|
|
8
9
|
messages: Map<string, ConversationMessage> | null;
|
|
@@ -13,6 +14,7 @@ interface AsgardServiceContextType {
|
|
|
13
14
|
export declare const AsgardServiceContext: import('react').Context<AsgardServiceContextType>;
|
|
14
15
|
interface AsgardServiceContextProviderProps extends DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
15
16
|
children: ReactNode;
|
|
17
|
+
avatar?: string;
|
|
16
18
|
config: ClientConfig;
|
|
17
19
|
customChannelId: string;
|
|
18
20
|
customMessageId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asgard-service-context.d.ts","sourceRoot":"","sources":["../../src/context/asgard-service-context.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,SAAS,EAIV,MAAM,OAAO,CAAC;AACf,OAAO,EAGL,gBAAgB,EACjB,MAAM,WAAW,CAAC;AAEnB,UAAU,wBAAwB;IAChC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAAC;IAClD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,IAAI,CAAC;IAC3D,mBAAmB,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IAC/C,WAAW,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC9C;AAED,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"asgard-service-context.d.ts","sourceRoot":"","sources":["../../src/context/asgard-service-context.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,SAAS,EAIV,MAAM,OAAO,CAAC;AACf,OAAO,EAGL,gBAAgB,EACjB,MAAM,WAAW,CAAC;AAEnB,UAAU,wBAAwB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAAC;IAClD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,IAAI,CAAC;IAC3D,mBAAmB,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IAC/C,WAAW,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC9C;AAED,eAAO,MAAM,oBAAoB,mDAQ/B,CAAC;AAEH,UAAU,iCACR,SAAQ,iBAAiB,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzE,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACzC,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACtC;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,iCAAiC,GACvC,SAAS,CA0CX;AAED,wBAAgB,gBAAgB,IAAI,wBAAwB,CAE3D"}
|
|
@@ -10,6 +10,7 @@ interface UseChannelProps {
|
|
|
10
10
|
onResetChannelInit?: (event: SseResponse<EventType.INIT>) => void;
|
|
11
11
|
}
|
|
12
12
|
export interface UseChannelReturn {
|
|
13
|
+
isConnecting: boolean;
|
|
13
14
|
messages: Map<string, ConversationMessage> | null;
|
|
14
15
|
typingMessages: Map<string, ConversationBotMessage> | null;
|
|
15
16
|
sendMessage: (text: string, customMessageId?: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-channel.d.ts","sourceRoot":"","sources":["../../src/hooks/use-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAEnB,sBAAsB,EACtB,mBAAmB,EACnB,SAAS,EACT,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAGzB,UAAU,eAAe;IACvB,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACrC,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACzC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;CACnE;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAAC;IAClD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,IAAI,CAAC;IAC3D,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"use-channel.d.ts","sourceRoot":"","sources":["../../src/hooks/use-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAEnB,sBAAsB,EACtB,mBAAmB,EACnB,SAAS,EACT,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAGzB,UAAU,eAAe;IACvB,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACrC,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACzC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;CACnE;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAAC;IAClD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,IAAI,CAAC;IAC3D,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,CA+EnE"}
|
package/dist/index.js
CHANGED
|
@@ -1,96 +1,101 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { AsgardServiceClient as
|
|
4
|
-
function
|
|
1
|
+
import { jsx as n, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as R, useEffect as T, useState as w, useCallback as f, useMemo as N, createContext as W, useContext as X } from "react";
|
|
3
|
+
import { AsgardServiceClient as G, Conversation as J, MessageTemplateType as y } from "@asgard-js/core";
|
|
4
|
+
function P(o) {
|
|
5
5
|
var t, e, s = "";
|
|
6
|
-
if (typeof
|
|
7
|
-
else if (typeof
|
|
8
|
-
var c =
|
|
9
|
-
for (t = 0; t < c; t++)
|
|
10
|
-
} else for (e in
|
|
6
|
+
if (typeof o == "string" || typeof o == "number") s += o;
|
|
7
|
+
else if (typeof o == "object") if (Array.isArray(o)) {
|
|
8
|
+
var c = o.length;
|
|
9
|
+
for (t = 0; t < c; t++) o[t] && (e = P(o[t])) && (s && (s += " "), s += e);
|
|
10
|
+
} else for (e in o) o[e] && (s && (s += " "), s += e);
|
|
11
11
|
return s;
|
|
12
12
|
}
|
|
13
13
|
function u() {
|
|
14
|
-
for (var
|
|
14
|
+
for (var o, t, e = 0, s = "", c = arguments.length; e < c; e++) (o = arguments[e]) && (t = P(o)) && (s && (s += " "), s += t);
|
|
15
15
|
return s;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const { config: t } =
|
|
19
|
-
return e.current || (e.current = new
|
|
17
|
+
function Y(o) {
|
|
18
|
+
const { config: t } = o, e = R(null);
|
|
19
|
+
return e.current || (e.current = new G(t)), T(() => () => {
|
|
20
20
|
e.current && (e.current.close(), e.current = null);
|
|
21
21
|
}, [t]), e.current;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const { client: t, customChannelId: e, initMessages: s, options: c } =
|
|
23
|
+
function tt(o) {
|
|
24
|
+
const { client: t, customChannelId: e, initMessages: s, options: c } = o;
|
|
25
25
|
if (!t)
|
|
26
26
|
throw new Error("Client instance is required");
|
|
27
27
|
if (!e)
|
|
28
28
|
throw new Error("Custom channel id is required");
|
|
29
|
-
const [
|
|
30
|
-
new
|
|
29
|
+
const [r, _] = w(!1), [i, l] = w(
|
|
30
|
+
new J({
|
|
31
31
|
messages: new Map(
|
|
32
|
-
s == null ? void 0 : s.map((
|
|
32
|
+
s == null ? void 0 : s.map((h) => [h.messageId, h])
|
|
33
33
|
),
|
|
34
34
|
typingMessages: null
|
|
35
35
|
})
|
|
36
36
|
);
|
|
37
|
-
|
|
37
|
+
T(() => {
|
|
38
38
|
t.setChannel({
|
|
39
39
|
customChannelId: e,
|
|
40
40
|
customMessageId: ""
|
|
41
41
|
});
|
|
42
42
|
}, [t, e]);
|
|
43
|
-
const
|
|
44
|
-
(
|
|
45
|
-
_((
|
|
46
|
-
const
|
|
47
|
-
|
|
43
|
+
const d = f(
|
|
44
|
+
(h, b) => {
|
|
45
|
+
_(!0), l((C) => {
|
|
46
|
+
const x = C.pushMessage(
|
|
47
|
+
C,
|
|
48
48
|
{
|
|
49
49
|
type: "user",
|
|
50
|
-
messageId:
|
|
51
|
-
text:
|
|
50
|
+
messageId: b ?? crypto.randomUUID(),
|
|
51
|
+
text: h,
|
|
52
52
|
time: /* @__PURE__ */ new Date()
|
|
53
53
|
}
|
|
54
54
|
);
|
|
55
55
|
return t.sendMessage(
|
|
56
56
|
{
|
|
57
57
|
customChannelId: e,
|
|
58
|
-
customMessageId:
|
|
59
|
-
text:
|
|
58
|
+
customMessageId: b,
|
|
59
|
+
text: h
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
|
-
onSseMessage: (
|
|
63
|
-
|
|
64
|
-
(
|
|
62
|
+
onSseMessage: (z) => {
|
|
63
|
+
l(
|
|
64
|
+
(j) => x.onMessage(j, z, {
|
|
65
65
|
showDebugMessage: c == null ? void 0 : c.showDebugMessage
|
|
66
66
|
})
|
|
67
67
|
);
|
|
68
|
+
},
|
|
69
|
+
onSseCompleted: () => {
|
|
70
|
+
_(!1);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
|
-
),
|
|
73
|
+
), x;
|
|
71
74
|
});
|
|
72
75
|
},
|
|
73
76
|
[t, e, c]
|
|
74
77
|
);
|
|
75
|
-
return
|
|
78
|
+
return N(
|
|
76
79
|
() => ({
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
isConnecting: r,
|
|
81
|
+
messages: i.messages,
|
|
82
|
+
typingMessages: i.typingMessages,
|
|
83
|
+
sendMessage: d
|
|
80
84
|
}),
|
|
81
|
-
[
|
|
85
|
+
[i, r, d]
|
|
82
86
|
);
|
|
83
87
|
}
|
|
84
|
-
function
|
|
85
|
-
const [e, s] =
|
|
86
|
-
return
|
|
88
|
+
function et(o, t) {
|
|
89
|
+
const [e, s] = w(o);
|
|
90
|
+
return T(() => {
|
|
87
91
|
const c = window.setTimeout(() => {
|
|
88
|
-
s(
|
|
92
|
+
s(o);
|
|
89
93
|
}, t ?? 300);
|
|
90
94
|
return () => clearTimeout(c);
|
|
91
|
-
}, [
|
|
95
|
+
}, [o, t]), e;
|
|
92
96
|
}
|
|
93
|
-
const
|
|
97
|
+
const L = W({
|
|
98
|
+
avatar: void 0,
|
|
94
99
|
client: null,
|
|
95
100
|
isConnecting: !1,
|
|
96
101
|
messages: null,
|
|
@@ -99,45 +104,59 @@ const E = F({
|
|
|
99
104
|
sendMessage: () => {
|
|
100
105
|
}
|
|
101
106
|
});
|
|
102
|
-
function
|
|
107
|
+
function ot(o) {
|
|
103
108
|
const {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
avatar: t,
|
|
110
|
+
children: e,
|
|
111
|
+
config: s,
|
|
112
|
+
customChannelId: c,
|
|
113
|
+
customMessageId: r,
|
|
114
|
+
delayTime: _,
|
|
115
|
+
initMessages: i,
|
|
110
116
|
options: l,
|
|
111
|
-
...
|
|
112
|
-
} =
|
|
113
|
-
client:
|
|
114
|
-
customChannelId:
|
|
115
|
-
initMessages:
|
|
117
|
+
...d
|
|
118
|
+
} = o, h = R(null), b = Y({ config: s }), { messages: C, typingMessages: x, sendMessage: z, isConnecting: j } = tt({
|
|
119
|
+
client: b,
|
|
120
|
+
customChannelId: c,
|
|
121
|
+
initMessages: i,
|
|
116
122
|
options: l
|
|
117
|
-
}),
|
|
123
|
+
}), Q = N(
|
|
118
124
|
() => ({
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
avatar: t,
|
|
126
|
+
client: b,
|
|
127
|
+
isConnecting: j,
|
|
128
|
+
messages: C,
|
|
129
|
+
typingMessages: x,
|
|
130
|
+
sendMessage: z,
|
|
124
131
|
messageBoxBottomRef: h
|
|
125
132
|
}),
|
|
126
|
-
[
|
|
133
|
+
[t, b, j, C, z, x]
|
|
127
134
|
);
|
|
128
|
-
return /* @__PURE__ */
|
|
135
|
+
return /* @__PURE__ */ n(L.Provider, { value: Q, children: /* @__PURE__ */ n("div", { ...d, children: e }) });
|
|
129
136
|
}
|
|
130
|
-
function
|
|
131
|
-
return
|
|
137
|
+
function m() {
|
|
138
|
+
return X(L);
|
|
132
139
|
}
|
|
133
|
-
const
|
|
134
|
-
chatbot_header:
|
|
135
|
-
chatbot_header__content:
|
|
136
|
-
chatbot_header__title:
|
|
137
|
-
chatbot_header__extra:
|
|
140
|
+
const nt = "_chatbot_header_1xj9n_1", st = "_chatbot_header__content_1xj9n_1", ct = "_chatbot_header__title_1xj9n_9", rt = "_chatbot_header__extra_1xj9n_20", k = {
|
|
141
|
+
chatbot_header: nt,
|
|
142
|
+
chatbot_header__content: st,
|
|
143
|
+
chatbot_header__title: ct,
|
|
144
|
+
chatbot_header__extra: rt
|
|
138
145
|
};
|
|
139
|
-
function
|
|
140
|
-
|
|
146
|
+
function at(o) {
|
|
147
|
+
const { avatar: t } = o;
|
|
148
|
+
return t ? /* @__PURE__ */ n(
|
|
149
|
+
"img",
|
|
150
|
+
{
|
|
151
|
+
src: t,
|
|
152
|
+
alt: "avatar",
|
|
153
|
+
style: {
|
|
154
|
+
width: 33,
|
|
155
|
+
height: 32,
|
|
156
|
+
borderRadius: "50%"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
) : /* @__PURE__ */ a(
|
|
141
160
|
"svg",
|
|
142
161
|
{
|
|
143
162
|
width: "33",
|
|
@@ -146,15 +165,15 @@ function st() {
|
|
|
146
165
|
fill: "none",
|
|
147
166
|
xmlns: "http://www.w3.org/2000/svg",
|
|
148
167
|
children: [
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ a("g", { "clip-path": "url(#clip0_3084_29383)", children: [
|
|
169
|
+
/* @__PURE__ */ n(
|
|
151
170
|
"path",
|
|
152
171
|
{
|
|
153
172
|
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",
|
|
154
173
|
fill: "#333333"
|
|
155
174
|
}
|
|
156
175
|
),
|
|
157
|
-
/* @__PURE__ */
|
|
176
|
+
/* @__PURE__ */ n(
|
|
158
177
|
"path",
|
|
159
178
|
{
|
|
160
179
|
"fill-rule": "evenodd",
|
|
@@ -164,7 +183,7 @@ function st() {
|
|
|
164
183
|
}
|
|
165
184
|
)
|
|
166
185
|
] }),
|
|
167
|
-
/* @__PURE__ */
|
|
186
|
+
/* @__PURE__ */ n("defs", { children: /* @__PURE__ */ n("clipPath", { id: "clip0_3084_29383", children: /* @__PURE__ */ n(
|
|
168
187
|
"path",
|
|
169
188
|
{
|
|
170
189
|
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",
|
|
@@ -175,96 +194,98 @@ function st() {
|
|
|
175
194
|
}
|
|
176
195
|
);
|
|
177
196
|
}
|
|
178
|
-
function
|
|
179
|
-
const { title: t } =
|
|
180
|
-
return /* @__PURE__ */
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
/* @__PURE__ */
|
|
183
|
-
/* @__PURE__ */
|
|
197
|
+
function it(o) {
|
|
198
|
+
const { title: t } = o, { avatar: e } = m();
|
|
199
|
+
return /* @__PURE__ */ n("div", { className: k.chatbot_header, children: /* @__PURE__ */ a("div", { className: k.chatbot_header__content, children: [
|
|
200
|
+
/* @__PURE__ */ a("div", { className: k.chatbot_header__title, children: [
|
|
201
|
+
/* @__PURE__ */ n(at, { avatar: e }),
|
|
202
|
+
/* @__PURE__ */ n("h4", { children: t })
|
|
184
203
|
] }),
|
|
185
|
-
/* @__PURE__ */
|
|
204
|
+
/* @__PURE__ */ n("div", { className: k.chatbot_header__extra })
|
|
186
205
|
] }) });
|
|
187
206
|
}
|
|
188
|
-
const
|
|
189
|
-
chatbot_body:
|
|
190
|
-
chatbot_body__content:
|
|
191
|
-
},
|
|
192
|
-
template_box:
|
|
207
|
+
const lt = "_chatbot_body_1f0gq_1", _t = "_chatbot_body__content_1f0gq_7", S = {
|
|
208
|
+
chatbot_body: lt,
|
|
209
|
+
chatbot_body__content: _t
|
|
210
|
+
}, dt = "_template_box_1ozig_1", g = {
|
|
211
|
+
template_box: dt,
|
|
193
212
|
"template_box--bot": "_template_box--bot_1ozig_7",
|
|
194
213
|
"template_box--horizontal": "_template_box--horizontal_1ozig_7",
|
|
195
214
|
"template_box--vertical": "_template_box--vertical_1ozig_10",
|
|
196
215
|
"template_box--user": "_template_box--user_1ozig_14"
|
|
197
216
|
};
|
|
198
|
-
function
|
|
199
|
-
const { type: t, direction: e = "horizontal", children: s } =
|
|
217
|
+
function M(o) {
|
|
218
|
+
const { type: t, direction: e = "horizontal", children: s } = o, c = N(() => {
|
|
200
219
|
switch (t) {
|
|
201
220
|
case "user":
|
|
202
|
-
return u(
|
|
221
|
+
return u(g.template_box, g["template_box--user"]);
|
|
203
222
|
case "bot":
|
|
204
223
|
default:
|
|
205
224
|
return u(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
e === "horizontal" ?
|
|
225
|
+
g.template_box,
|
|
226
|
+
g["template_box--bot"],
|
|
227
|
+
e === "horizontal" ? g["template_box--horizontal"] : g["template_box--vertical"]
|
|
209
228
|
);
|
|
210
229
|
}
|
|
211
230
|
}, [e, t]);
|
|
212
|
-
return /* @__PURE__ */
|
|
231
|
+
return /* @__PURE__ */ n("div", { className: c, children: s });
|
|
213
232
|
}
|
|
214
|
-
const
|
|
215
|
-
template_box_content:
|
|
216
|
-
content:
|
|
217
|
-
},
|
|
218
|
-
quick_replies_box:
|
|
219
|
-
quick_reply:
|
|
233
|
+
const ht = "_template_box_content_12ojl_1", ut = "_content_12ojl_7", A = {
|
|
234
|
+
template_box_content: ht,
|
|
235
|
+
content: ut
|
|
236
|
+
}, mt = "_quick_replies_box_zoq7y_1", bt = "_quick_reply_zoq7y_7", Z = {
|
|
237
|
+
quick_replies_box: mt,
|
|
238
|
+
quick_reply: bt
|
|
220
239
|
};
|
|
221
|
-
function
|
|
222
|
-
const { quickReplies: t } =
|
|
223
|
-
(
|
|
224
|
-
e(
|
|
240
|
+
function gt(o) {
|
|
241
|
+
const { quickReplies: t } = o, { sendMessage: e, isConnecting: s } = m(), c = f(
|
|
242
|
+
(r) => {
|
|
243
|
+
e(r);
|
|
225
244
|
},
|
|
226
245
|
[e]
|
|
227
246
|
);
|
|
228
|
-
return t != null && t.length ? /* @__PURE__ */
|
|
229
|
-
"
|
|
247
|
+
return t != null && t.length ? /* @__PURE__ */ n("div", { className: Z.quick_replies_box, children: t.map((r) => /* @__PURE__ */ n(
|
|
248
|
+
"button",
|
|
230
249
|
{
|
|
231
|
-
className:
|
|
232
|
-
|
|
233
|
-
|
|
250
|
+
className: Z.quick_reply,
|
|
251
|
+
disabled: s,
|
|
252
|
+
onClick: () => c(r.text),
|
|
253
|
+
children: r.text
|
|
234
254
|
},
|
|
235
|
-
|
|
255
|
+
r.text
|
|
236
256
|
)) }) : null;
|
|
237
257
|
}
|
|
238
|
-
function
|
|
239
|
-
return
|
|
258
|
+
function F(o) {
|
|
259
|
+
return o.toLocaleTimeString("zh-TW", {
|
|
240
260
|
timeZone: "Asia/Taipei",
|
|
241
261
|
hour: "2-digit",
|
|
242
262
|
minute: "2-digit",
|
|
243
263
|
hour12: !1
|
|
244
264
|
});
|
|
245
265
|
}
|
|
246
|
-
const
|
|
247
|
-
time:
|
|
266
|
+
const pt = "_time_rgg92_1", ft = {
|
|
267
|
+
time: pt
|
|
248
268
|
};
|
|
249
|
-
function
|
|
250
|
-
const { time: t, className: e } =
|
|
251
|
-
return t ? /* @__PURE__ */
|
|
269
|
+
function q(o) {
|
|
270
|
+
const { time: t, className: e } = o;
|
|
271
|
+
return t ? /* @__PURE__ */ n("div", { className: u(ft.time, e), children: F(t) }) : null;
|
|
252
272
|
}
|
|
253
|
-
function
|
|
254
|
-
const { quickReplies: t, time: e, children: s } =
|
|
255
|
-
return /* @__PURE__ */
|
|
256
|
-
/* @__PURE__ */
|
|
273
|
+
function $(o) {
|
|
274
|
+
const { quickReplies: t, time: e, children: s } = o;
|
|
275
|
+
return /* @__PURE__ */ a("div", { className: A.template_box_content, children: [
|
|
276
|
+
/* @__PURE__ */ a("div", { className: A.content, children: [
|
|
257
277
|
s,
|
|
258
|
-
/* @__PURE__ */
|
|
278
|
+
/* @__PURE__ */ n(q, { time: e })
|
|
259
279
|
] }),
|
|
260
|
-
!!(t != null && t.length) && /* @__PURE__ */
|
|
280
|
+
!!(t != null && t.length) && /* @__PURE__ */ n(gt, { quickReplies: t })
|
|
261
281
|
] });
|
|
262
282
|
}
|
|
263
|
-
const
|
|
264
|
-
bot_avatar:
|
|
283
|
+
const Ct = "_bot_avatar_xrs9x_1", U = {
|
|
284
|
+
bot_avatar: Ct
|
|
265
285
|
};
|
|
266
|
-
function
|
|
267
|
-
|
|
286
|
+
function H() {
|
|
287
|
+
const { avatar: o } = m();
|
|
288
|
+
return o ? /* @__PURE__ */ n("img", { src: o, alt: "Bot Avatar", className: U.bot_avatar }) : /* @__PURE__ */ n("div", { className: U.bot_avatar, children: /* @__PURE__ */ a(
|
|
268
289
|
"svg",
|
|
269
290
|
{
|
|
270
291
|
style: { width: "100%", height: "100%" },
|
|
@@ -272,14 +293,14 @@ function z() {
|
|
|
272
293
|
fill: "none",
|
|
273
294
|
xmlns: "http://www.w3.org/2000/svg",
|
|
274
295
|
children: [
|
|
275
|
-
/* @__PURE__ */
|
|
296
|
+
/* @__PURE__ */ n(
|
|
276
297
|
"path",
|
|
277
298
|
{
|
|
278
299
|
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",
|
|
279
300
|
fill: "#585858"
|
|
280
301
|
}
|
|
281
302
|
),
|
|
282
|
-
/* @__PURE__ */
|
|
303
|
+
/* @__PURE__ */ n(
|
|
283
304
|
"path",
|
|
284
305
|
{
|
|
285
306
|
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",
|
|
@@ -290,54 +311,54 @@ function z() {
|
|
|
290
311
|
}
|
|
291
312
|
) });
|
|
292
313
|
}
|
|
293
|
-
const
|
|
294
|
-
text:
|
|
314
|
+
const xt = "_text_1djgp_1", vt = "_dot_1djgp_18", yt = "_blink_1djgp_1", p = {
|
|
315
|
+
text: xt,
|
|
295
316
|
"text--bot": "_text--bot_1djgp_7",
|
|
296
317
|
"typing-indicator": "_typing-indicator_1djgp_13",
|
|
297
|
-
dot:
|
|
298
|
-
blink:
|
|
318
|
+
dot: vt,
|
|
319
|
+
blink: yt
|
|
299
320
|
};
|
|
300
|
-
function
|
|
301
|
-
const { children: t, onResize: e } =
|
|
302
|
-
return
|
|
303
|
-
const c = new ResizeObserver((
|
|
304
|
-
for (const _ of
|
|
305
|
-
const { width:
|
|
306
|
-
e(
|
|
321
|
+
function wt(o) {
|
|
322
|
+
const { children: t, onResize: e } = o, s = R(null);
|
|
323
|
+
return T(() => {
|
|
324
|
+
const c = new ResizeObserver((r) => {
|
|
325
|
+
for (const _ of r) {
|
|
326
|
+
const { width: i, height: l } = _.contentRect;
|
|
327
|
+
e(i, l);
|
|
307
328
|
}
|
|
308
329
|
});
|
|
309
330
|
return s.current && c.observe(s.current), () => {
|
|
310
331
|
c.disconnect();
|
|
311
332
|
};
|
|
312
|
-
}, [s, e]), /* @__PURE__ */
|
|
333
|
+
}, [s, e]), /* @__PURE__ */ n("div", { ref: s, children: t });
|
|
313
334
|
}
|
|
314
|
-
function
|
|
315
|
-
const { typingMessage: t } =
|
|
316
|
-
var
|
|
317
|
-
(
|
|
318
|
-
}, [e]), c =
|
|
319
|
-
return c ? /* @__PURE__ */
|
|
320
|
-
/* @__PURE__ */
|
|
321
|
-
/* @__PURE__ */
|
|
322
|
-
/* @__PURE__ */
|
|
323
|
-
c && /* @__PURE__ */
|
|
324
|
-
/* @__PURE__ */
|
|
325
|
-
/* @__PURE__ */
|
|
326
|
-
/* @__PURE__ */
|
|
335
|
+
function Nt(o) {
|
|
336
|
+
const { typingMessage: t } = o, { messageBoxBottomRef: e } = m(), s = f(() => {
|
|
337
|
+
var r;
|
|
338
|
+
(r = e.current) == null || r.scrollIntoView({ behavior: "smooth" });
|
|
339
|
+
}, [e]), c = et(t == null ? void 0 : t.isTyping, 500);
|
|
340
|
+
return c ? /* @__PURE__ */ a(M, { type: "bot", direction: "horizontal", children: [
|
|
341
|
+
/* @__PURE__ */ n(H, {}),
|
|
342
|
+
/* @__PURE__ */ n($, { time: /* @__PURE__ */ new Date(), children: /* @__PURE__ */ n("div", { className: u(p.text, p["text--bot"]), children: /* @__PURE__ */ a(wt, { onResize: s, children: [
|
|
343
|
+
/* @__PURE__ */ n("span", { children: (t == null ? void 0 : t.typingText) ?? "" }),
|
|
344
|
+
c && /* @__PURE__ */ a("span", { className: p["typing-indicator"], children: [
|
|
345
|
+
/* @__PURE__ */ n("div", { className: p.dot }),
|
|
346
|
+
/* @__PURE__ */ n("div", { className: p.dot }),
|
|
347
|
+
/* @__PURE__ */ n("div", { className: p.dot })
|
|
327
348
|
] })
|
|
328
349
|
] }) }) })
|
|
329
350
|
] }) : null;
|
|
330
351
|
}
|
|
331
|
-
const
|
|
332
|
-
card_root:
|
|
333
|
-
card_content:
|
|
334
|
-
card_title:
|
|
335
|
-
card_description:
|
|
336
|
-
card_actions:
|
|
352
|
+
const Mt = "_card_root_1ygom_1", Tt = "_card_content_1ygom_10", zt = "_card_title_1ygom_17", jt = "_card_description_1ygom_23", kt = "_card_actions_1ygom_37", v = {
|
|
353
|
+
card_root: Mt,
|
|
354
|
+
card_content: Tt,
|
|
355
|
+
card_title: zt,
|
|
356
|
+
card_description: jt,
|
|
357
|
+
card_actions: kt
|
|
337
358
|
};
|
|
338
|
-
function
|
|
359
|
+
function K(o) {
|
|
339
360
|
var _;
|
|
340
|
-
const { template: t } =
|
|
361
|
+
const { template: t } = o, { sendMessage: e } = m(), s = N(() => (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]), c = N(() => {
|
|
341
362
|
switch (t == null ? void 0 : t.imageAspectRatio) {
|
|
342
363
|
case "square":
|
|
343
364
|
return "1 / 1";
|
|
@@ -345,21 +366,21 @@ function P(n) {
|
|
|
345
366
|
default:
|
|
346
367
|
return "1.51 / 1";
|
|
347
368
|
}
|
|
348
|
-
}, [t]),
|
|
349
|
-
(
|
|
350
|
-
switch (
|
|
369
|
+
}, [t]), r = f(
|
|
370
|
+
(i) => function() {
|
|
371
|
+
switch (i.type) {
|
|
351
372
|
case "message":
|
|
352
|
-
e(
|
|
373
|
+
e(i.text);
|
|
353
374
|
return;
|
|
354
375
|
case "uri":
|
|
355
|
-
window.open(
|
|
376
|
+
window.open(i.uri, "_blank");
|
|
356
377
|
return;
|
|
357
378
|
}
|
|
358
379
|
},
|
|
359
380
|
[e]
|
|
360
381
|
);
|
|
361
|
-
return /* @__PURE__ */
|
|
362
|
-
(t == null ? void 0 : t.thumbnailImageUrl) && /* @__PURE__ */
|
|
382
|
+
return /* @__PURE__ */ a("div", { className: v.card_root, children: [
|
|
383
|
+
(t == null ? void 0 : t.thumbnailImageUrl) && /* @__PURE__ */ n(
|
|
363
384
|
"img",
|
|
364
385
|
{
|
|
365
386
|
alt: t == null ? void 0 : t.title,
|
|
@@ -372,186 +393,188 @@ function P(n) {
|
|
|
372
393
|
}
|
|
373
394
|
}
|
|
374
395
|
),
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
/* @__PURE__ */
|
|
377
|
-
/* @__PURE__ */
|
|
378
|
-
/* @__PURE__ */
|
|
396
|
+
/* @__PURE__ */ a("div", { className: v.card_content, children: [
|
|
397
|
+
/* @__PURE__ */ n("h5", { className: v.card_title, children: t == null ? void 0 : t.title }),
|
|
398
|
+
/* @__PURE__ */ n("div", { className: v.card_description, children: t == null ? void 0 : t.text }),
|
|
399
|
+
/* @__PURE__ */ n("div", { className: v.card_actions, children: (_ = t == null ? void 0 : t.buttons) == null ? void 0 : _.map((i, l) => /* @__PURE__ */ n("button", { onClick: r(i.action), children: i.label }, l)) })
|
|
379
400
|
] })
|
|
380
401
|
] });
|
|
381
402
|
}
|
|
382
|
-
function
|
|
383
|
-
const { conversationMessage: t } =
|
|
384
|
-
return /* @__PURE__ */
|
|
385
|
-
/* @__PURE__ */
|
|
386
|
-
/* @__PURE__ */
|
|
387
|
-
|
|
403
|
+
function Bt(o) {
|
|
404
|
+
const { conversationMessage: t } = o, e = t.message.template;
|
|
405
|
+
return /* @__PURE__ */ a(M, { type: "bot", direction: "horizontal", children: [
|
|
406
|
+
/* @__PURE__ */ n(H, {}),
|
|
407
|
+
/* @__PURE__ */ n(
|
|
408
|
+
$,
|
|
388
409
|
{
|
|
389
410
|
time: t.time,
|
|
390
411
|
quickReplies: e == null ? void 0 : e.quickReplies,
|
|
391
|
-
children: /* @__PURE__ */
|
|
412
|
+
children: /* @__PURE__ */ n(K, { template: e })
|
|
392
413
|
}
|
|
393
414
|
)
|
|
394
415
|
] });
|
|
395
416
|
}
|
|
396
|
-
const
|
|
397
|
-
text:
|
|
417
|
+
const Ht = "_text_sbjtw_1", It = "_content_sbjtw_19", B = {
|
|
418
|
+
text: Ht,
|
|
398
419
|
"text--user": "_text--user_sbjtw_7",
|
|
399
420
|
"text--bot": "_text--bot_sbjtw_13",
|
|
400
|
-
content:
|
|
421
|
+
content: It
|
|
401
422
|
};
|
|
402
|
-
function
|
|
423
|
+
function D(o) {
|
|
403
424
|
var e;
|
|
404
|
-
const { conversationMessage: t } =
|
|
405
|
-
return t.type === "user" ? /* @__PURE__ */
|
|
406
|
-
/* @__PURE__ */
|
|
407
|
-
/* @__PURE__ */
|
|
408
|
-
] }) : /* @__PURE__ */
|
|
409
|
-
/* @__PURE__ */
|
|
410
|
-
/* @__PURE__ */
|
|
411
|
-
|
|
425
|
+
const { conversationMessage: t } = o;
|
|
426
|
+
return t.type === "user" ? /* @__PURE__ */ a(M, { type: "user", direction: "horizontal", children: [
|
|
427
|
+
/* @__PURE__ */ n("div", { className: u(B.text, B["text--user"]), children: t.text }),
|
|
428
|
+
/* @__PURE__ */ n(q, { time: t.time })
|
|
429
|
+
] }) : /* @__PURE__ */ a(M, { type: "bot", direction: "horizontal", children: [
|
|
430
|
+
/* @__PURE__ */ n(H, {}),
|
|
431
|
+
/* @__PURE__ */ n(
|
|
432
|
+
$,
|
|
412
433
|
{
|
|
413
434
|
time: t.time,
|
|
414
435
|
quickReplies: (e = t.message.template) == null ? void 0 : e.quickReplies,
|
|
415
|
-
children: /* @__PURE__ */
|
|
436
|
+
children: /* @__PURE__ */ n("div", { className: u(B.text, B["text--bot"]), children: t.message.text })
|
|
416
437
|
}
|
|
417
438
|
)
|
|
418
439
|
] });
|
|
419
440
|
}
|
|
420
|
-
const
|
|
421
|
-
carousel_root:
|
|
422
|
-
carousel_time:
|
|
441
|
+
const Rt = "_carousel_root_sv1hc_1", qt = "_carousel_time_sv1hc_12", V = {
|
|
442
|
+
carousel_root: Rt,
|
|
443
|
+
carousel_time: qt
|
|
423
444
|
};
|
|
424
|
-
function
|
|
445
|
+
function $t(o) {
|
|
425
446
|
var s;
|
|
426
|
-
const { conversationMessage: t } =
|
|
427
|
-
return /* @__PURE__ */
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
/* @__PURE__ */
|
|
430
|
-
/* @__PURE__ */
|
|
447
|
+
const { conversationMessage: t } = o, e = t.message.template;
|
|
448
|
+
return /* @__PURE__ */ a(M, { type: "bot", direction: "vertical", children: [
|
|
449
|
+
/* @__PURE__ */ n(H, {}),
|
|
450
|
+
/* @__PURE__ */ n("div", { className: V.carousel_root, children: (s = e.columns) == null ? void 0 : s.map((c, r) => /* @__PURE__ */ n(K, { template: c }, r)) }),
|
|
451
|
+
/* @__PURE__ */ n(q, { className: V.carousel_time, time: t.time })
|
|
431
452
|
] });
|
|
432
453
|
}
|
|
433
|
-
const
|
|
434
|
-
hint_root:
|
|
435
|
-
time:
|
|
454
|
+
const St = "_hint_root_g119q_1", At = "_time_g119q_14", E = {
|
|
455
|
+
hint_root: St,
|
|
456
|
+
time: At
|
|
436
457
|
};
|
|
437
|
-
function
|
|
438
|
-
const { conversationMessage: t } =
|
|
458
|
+
function Zt(o) {
|
|
459
|
+
const { conversationMessage: t } = o;
|
|
439
460
|
if (t.type === "user") return null;
|
|
440
461
|
const e = t.message.template;
|
|
441
|
-
return e.type !==
|
|
442
|
-
/* @__PURE__ */
|
|
462
|
+
return e.type !== y.HINT ? null : /* @__PURE__ */ a("div", { className: E.hint_root, children: [
|
|
463
|
+
/* @__PURE__ */ n("div", { className: E.time, children: F(t.time) }),
|
|
443
464
|
e.text
|
|
444
465
|
] });
|
|
445
466
|
}
|
|
446
|
-
function
|
|
447
|
-
const { conversationMessage: t } =
|
|
467
|
+
function Ut(o) {
|
|
468
|
+
const { conversationMessage: t } = o;
|
|
448
469
|
if (t.type === "user")
|
|
449
|
-
return /* @__PURE__ */
|
|
470
|
+
return /* @__PURE__ */ n(D, { conversationMessage: t });
|
|
450
471
|
const e = t.message.template;
|
|
451
472
|
switch (e == null ? void 0 : e.type) {
|
|
452
|
-
case
|
|
453
|
-
return /* @__PURE__ */
|
|
454
|
-
case
|
|
455
|
-
return /* @__PURE__ */
|
|
456
|
-
case
|
|
457
|
-
return /* @__PURE__ */
|
|
458
|
-
case
|
|
459
|
-
return /* @__PURE__ */
|
|
473
|
+
case y.TEXT:
|
|
474
|
+
return /* @__PURE__ */ n(D, { conversationMessage: t });
|
|
475
|
+
case y.HINT:
|
|
476
|
+
return /* @__PURE__ */ n(Zt, { conversationMessage: t });
|
|
477
|
+
case y.BUTTON:
|
|
478
|
+
return /* @__PURE__ */ n(Bt, { conversationMessage: t });
|
|
479
|
+
case y.CAROUSEL:
|
|
480
|
+
return /* @__PURE__ */ n($t, { conversationMessage: t });
|
|
460
481
|
default:
|
|
461
|
-
return /* @__PURE__ */
|
|
482
|
+
return /* @__PURE__ */ n("div", { children: "Unknown template" });
|
|
462
483
|
}
|
|
463
484
|
}
|
|
464
|
-
function
|
|
465
|
-
const { messages:
|
|
466
|
-
return
|
|
485
|
+
function Dt() {
|
|
486
|
+
const { messages: o, typingMessages: t, messageBoxBottomRef: e } = m();
|
|
487
|
+
return T(() => {
|
|
467
488
|
var s;
|
|
468
489
|
(s = e.current) == null || s.scrollIntoView({ behavior: "smooth" });
|
|
469
|
-
}, [
|
|
470
|
-
Array.from((
|
|
471
|
-
|
|
490
|
+
}, [o, e]), /* @__PURE__ */ n("div", { className: S.chatbot_body, children: /* @__PURE__ */ a("div", { className: S.chatbot_body__content, children: [
|
|
491
|
+
Array.from((o == null ? void 0 : o.values()) ?? []).map((s) => /* @__PURE__ */ n(
|
|
492
|
+
Ut,
|
|
472
493
|
{
|
|
473
494
|
conversationMessage: s
|
|
474
495
|
},
|
|
475
496
|
crypto.randomUUID()
|
|
476
497
|
)),
|
|
477
|
-
Array.from((t == null ? void 0 : t.values()) ?? []).map((s) => /* @__PURE__ */
|
|
478
|
-
|
|
498
|
+
Array.from((t == null ? void 0 : t.values()) ?? []).map((s) => /* @__PURE__ */ n(
|
|
499
|
+
Nt,
|
|
479
500
|
{
|
|
480
501
|
typingMessage: s
|
|
481
502
|
},
|
|
482
503
|
crypto.randomUUID()
|
|
483
504
|
)),
|
|
484
|
-
/* @__PURE__ */
|
|
505
|
+
/* @__PURE__ */ n("div", { ref: e })
|
|
485
506
|
] }) });
|
|
486
507
|
}
|
|
487
|
-
const
|
|
488
|
-
chatbot_footer:
|
|
489
|
-
chatbot_footer__content:
|
|
490
|
-
chatbot_textarea:
|
|
508
|
+
const Vt = "_chatbot_footer_3box0_1", Et = "_chatbot_footer__content_3box0_1", Ot = "_chatbot_textarea_3box0_8", I = {
|
|
509
|
+
chatbot_footer: Vt,
|
|
510
|
+
chatbot_footer__content: Et,
|
|
511
|
+
chatbot_textarea: Ot
|
|
491
512
|
};
|
|
492
|
-
function
|
|
493
|
-
const { sendMessage:
|
|
494
|
-
(
|
|
495
|
-
const
|
|
496
|
-
|
|
513
|
+
function Pt() {
|
|
514
|
+
const { sendMessage: o, isConnecting: t } = m(), [e, s] = w(""), [c, r] = w(!1), _ = f(
|
|
515
|
+
(l) => {
|
|
516
|
+
const d = l.target, h = d.value;
|
|
517
|
+
d.style.height = "20px", h && (d.style.height = `${d.scrollHeight - 16}px`), s(l.target.value);
|
|
497
518
|
},
|
|
498
519
|
[]
|
|
499
|
-
),
|
|
500
|
-
(
|
|
501
|
-
|
|
520
|
+
), i = f(
|
|
521
|
+
(l) => {
|
|
522
|
+
l.key === "Enter" && !c && !t && (o(e), s(""));
|
|
502
523
|
},
|
|
503
|
-
[c, t,
|
|
524
|
+
[c, t, o, e]
|
|
504
525
|
);
|
|
505
|
-
return /* @__PURE__ */
|
|
526
|
+
return /* @__PURE__ */ n("div", { className: I.chatbot_footer, children: /* @__PURE__ */ n("div", { className: I.chatbot_footer__content, children: /* @__PURE__ */ n(
|
|
506
527
|
"textarea",
|
|
507
528
|
{
|
|
508
|
-
className:
|
|
529
|
+
className: I.chatbot_textarea,
|
|
509
530
|
disabled: t,
|
|
510
531
|
cols: 40,
|
|
511
532
|
value: e,
|
|
512
533
|
placeholder: "Enter message",
|
|
513
534
|
onChange: _,
|
|
514
|
-
onKeyDown:
|
|
515
|
-
onCompositionStart: () =>
|
|
516
|
-
onCompositionEnd: () =>
|
|
535
|
+
onKeyDown: i,
|
|
536
|
+
onCompositionStart: () => r(!0),
|
|
537
|
+
onCompositionEnd: () => r(!1)
|
|
517
538
|
}
|
|
518
539
|
) }) });
|
|
519
540
|
}
|
|
520
|
-
const
|
|
521
|
-
chatbot_root:
|
|
522
|
-
chatbot_root__fullScreen:
|
|
541
|
+
const Lt = "_chatbot_root_1jllh_1", Ft = "_chatbot_root__fullScreen_1jllh_12", O = {
|
|
542
|
+
chatbot_root: Lt,
|
|
543
|
+
chatbot_root__fullScreen: Ft
|
|
523
544
|
};
|
|
524
|
-
function
|
|
545
|
+
function Xt(o) {
|
|
525
546
|
const {
|
|
526
547
|
title: t,
|
|
527
548
|
config: e,
|
|
528
549
|
customChannelId: s,
|
|
529
550
|
initMessages: c,
|
|
530
|
-
fullScreen:
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
551
|
+
fullScreen: r = !1,
|
|
552
|
+
avatar: _,
|
|
553
|
+
options: i
|
|
554
|
+
} = o;
|
|
555
|
+
return /* @__PURE__ */ a(
|
|
556
|
+
ot,
|
|
535
557
|
{
|
|
536
558
|
className: u(
|
|
537
|
-
|
|
538
|
-
|
|
559
|
+
O.chatbot_root,
|
|
560
|
+
r && O.chatbot_root__fullScreen
|
|
539
561
|
),
|
|
562
|
+
avatar: _,
|
|
540
563
|
config: e,
|
|
541
564
|
customChannelId: s,
|
|
542
565
|
initMessages: c,
|
|
543
|
-
options:
|
|
566
|
+
options: i,
|
|
544
567
|
children: [
|
|
545
|
-
/* @__PURE__ */
|
|
546
|
-
/* @__PURE__ */
|
|
547
|
-
/* @__PURE__ */
|
|
568
|
+
/* @__PURE__ */ n(it, { title: t }),
|
|
569
|
+
/* @__PURE__ */ n(Dt, {}),
|
|
570
|
+
/* @__PURE__ */ n(Pt, {})
|
|
548
571
|
]
|
|
549
572
|
}
|
|
550
573
|
);
|
|
551
574
|
}
|
|
552
575
|
export {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
576
|
+
Xt as Chatbot,
|
|
577
|
+
Y as useAsgardServiceClient,
|
|
578
|
+
tt as useChannel,
|
|
579
|
+
et as useDebounce
|
|
557
580
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
._chatbot_header_1xj9n_1 ._chatbot_header__content_1xj9n_1{margin:0 auto;max-width:1200px;padding:16px;display:flex;justify-content:space-between}._chatbot_header__title_1xj9n_9{display:flex;flex-direction:row;align-items:center;gap:8px}._chatbot_header__title_1xj9n_9>h4{margin:0;color:#fff}._chatbot_header__extra_1xj9n_20{display:flex;flex-direction:row;align-items:center;gap:8px}._chatbot_body_1f0gq_1{border-top:1px solid #434343;border-bottom:1px solid #434343;overflow-x:hidden;overflow-y:scroll}._chatbot_body_1f0gq_1 ._chatbot_body__content_1f0gq_7{margin:0 auto;display:flex;flex-direction:column;padding:16px;gap:16px;max-width:1200px}._template_box_1ozig_1{width:100%;display:flex;gap:8px}._template_box--bot_1ozig_7._template_box--horizontal_1ozig_7{flex-direction:row}._template_box--bot_1ozig_7._template_box--vertical_1ozig_10{flex-direction:column}._template_box--user_1ozig_14{flex-direction:row-reverse}._template_box_content_12ojl_1{display:flex;flex-direction:column;gap:8px}._content_12ojl_7{display:flex;flex-direction:row;gap:8px}.
|
|
1
|
+
._chatbot_header_1xj9n_1 ._chatbot_header__content_1xj9n_1{margin:0 auto;max-width:1200px;padding:16px;display:flex;justify-content:space-between}._chatbot_header__title_1xj9n_9{display:flex;flex-direction:row;align-items:center;gap:8px}._chatbot_header__title_1xj9n_9>h4{margin:0;color:#fff}._chatbot_header__extra_1xj9n_20{display:flex;flex-direction:row;align-items:center;gap:8px}._chatbot_body_1f0gq_1{border-top:1px solid #434343;border-bottom:1px solid #434343;overflow-x:hidden;overflow-y:scroll}._chatbot_body_1f0gq_1 ._chatbot_body__content_1f0gq_7{margin:0 auto;display:flex;flex-direction:column;padding:16px;gap:16px;max-width:1200px}._template_box_1ozig_1{width:100%;display:flex;gap:8px}._template_box--bot_1ozig_7._template_box--horizontal_1ozig_7{flex-direction:row}._template_box--bot_1ozig_7._template_box--vertical_1ozig_10{flex-direction:column}._template_box--user_1ozig_14{flex-direction:row-reverse}._template_box_content_12ojl_1{display:flex;flex-direction:column;gap:8px}._content_12ojl_7{display:flex;flex-direction:row;gap:8px}._quick_replies_box_zoq7y_1{display:flex;flex-wrap:wrap;gap:8px}._quick_reply_zoq7y_7{font:inherit;font-size:13px;padding:4px 8px;border-radius:8px;border:1px solid #434343;background:#58585833;color:#fff;cursor:pointer}._time_rgg92_1{display:flex;align-items:flex-end;font-size:12px;color:#8c8c8c}._bot_avatar_xrs9x_1{flex:0 0 auto;width:24px;height:24px;border-radius:50%}._text_1djgp_1{padding:8px 12px;border-radius:8px;color:#fff}._text--bot_1djgp_7{max-width:70%;background:#585858;border-top-left-radius:0}._typing-indicator_1djgp_13{display:inline-flex;align-items:flex-end;justify-content:center}._typing-indicator_1djgp_13 ._dot_1djgp_18{width:2px;height:2px;margin:0 2px;background-color:#fff;border-radius:50%;animation:_blink_1djgp_1 1.4s infinite ease-in-out both}._typing-indicator_1djgp_13 ._dot_1djgp_18:nth-child(1){animation-delay:0s}._typing-indicator_1djgp_13 ._dot_1djgp_18:nth-child(2){animation-delay:.2s}._typing-indicator_1djgp_13 ._dot_1djgp_18:nth-child(3){animation-delay:.4s}@keyframes _blink_1djgp_1{0%,80%,to{opacity:.2;transform:translateY(0)}40%{opacity:1;transform:translateY(-5px)}}._card_root_1ygom_1{width:255px;height:368px;max-height:380px;border-radius:8px;background:#333;overflow:hidden}._card_content_1ygom_10{display:flex;flex-direction:column;gap:8px;padding:12px}._card_title_1ygom_17{color:#fff;margin:0;font-size:15px}._card_description_1ygom_23{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;color:#8c8c8c;font-size:13px;font-weight:400;line-height:20px;text-underline-position:from-font;text-decoration-skip-ink:none;text-overflow:ellipsis}._card_actions_1ygom_37{display:flex;flex-direction:column;gap:8px}._card_actions_1ygom_37>button{width:100%;height:32px;line-height:32px;text-align:center;border:none;border-radius:4px;background:#4767eb;color:#fff;font-size:15px;cursor:pointer}._text_sbjtw_1{padding:8px 12px;border-radius:8px;color:#fff}._text--user_sbjtw_7{max-width:75%;background:#4767eb;border-top-right-radius:0}._text--bot_sbjtw_13{max-width:70%;background:#585858;border-top-left-radius:0}._content_sbjtw_19{display:flex;flex-direction:column;gap:8px}._carousel_root_sv1hc_1{width:100%;display:flex;flex-wrap:nowrap;overflow-x:scroll;gap:8px}._carousel_root_sv1hc_1>div{flex:0 0 auto}._carousel_time_sv1hc_12{justify-content:flex-end}._hint_root_g119q_1{margin:0 auto;display:flex;flex-direction:column;align-items:center;padding:4px 12px;gap:4px;border-radius:2px;background:#58585833;font-size:13px;color:#fff}._time_g119q_14{font-size:12px;color:#8c8c8c}._chatbot_footer_3box0_1 ._chatbot_footer__content_3box0_1{margin:0 auto;max-width:1200px;padding:16px;gap:16px}._chatbot_textarea_3box0_8{font:inherit;width:calc(100% - 20px);height:20px;max-height:240px;padding:8px 8px 8px 12px;background:#1f1f1f;border:1px solid rgb(67,67,67);border-radius:2px;color:#8c8c8c;resize:none;overflow:hidden}._chatbot_root_1jllh_1{min-width:375px;width:100%;height:100%;background-color:#141414;border-radius:8px;font-size:15px;display:grid;grid-template-rows:max-content auto max-content}._chatbot_root__fullScreen_1jllh_12{position:fixed;top:0;left:0;right:0;bottom:0;z-index:9999;border-radius:0}
|