@asgard-js/react 0.0.5 → 0.0.6
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/README.md +142 -21
- package/dist/components/conversation-message-renderer/conversation-message-renderer.d.ts.map +1 -1
- package/dist/components/templates/hint-template/hint-template.d.ts.map +1 -1
- package/dist/components/templates/text-template/text-template.d.ts.map +1 -1
- package/dist/hooks/use-channel.d.ts.map +1 -1
- package/dist/index.js +280 -269
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ This package provides React components and hooks for integrating with the Asgard
|
|
|
7
7
|
To install the React package, use the following command:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
yarn add
|
|
10
|
+
yarn add @asgard-js/core @asgard-js/react
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
@@ -16,7 +16,7 @@ Here's a basic example of how to use the React components:
|
|
|
16
16
|
|
|
17
17
|
```javascript
|
|
18
18
|
import React from 'react';
|
|
19
|
-
import { Chatbot } from '
|
|
19
|
+
import { Chatbot } from '@asgard-js/react';
|
|
20
20
|
|
|
21
21
|
const App = () => {
|
|
22
22
|
return (
|
|
@@ -25,13 +25,25 @@ const App = () => {
|
|
|
25
25
|
config={{
|
|
26
26
|
apiKey: 'your-api-key',
|
|
27
27
|
endpoint: 'https://api.asgard-ai.com',
|
|
28
|
+
onExecutionError: (error) => {
|
|
29
|
+
console.error('Execution error:', error);
|
|
30
|
+
},
|
|
31
|
+
transformSsePayload: (payload) => {
|
|
32
|
+
return payload;
|
|
33
|
+
}
|
|
28
34
|
}}
|
|
29
35
|
customChannelId="your-channel-id"
|
|
30
36
|
initMessages={[]}
|
|
37
|
+
debugMode={false}
|
|
31
38
|
fullScreen={false}
|
|
32
39
|
avatar="https://example.com/avatar.png"
|
|
33
40
|
botTypingPlaceholder="Bot is typing..."
|
|
34
|
-
|
|
41
|
+
onReset={() => {
|
|
42
|
+
console.log('Chat reset');
|
|
43
|
+
}}
|
|
44
|
+
onClose={() => {
|
|
45
|
+
console.log('Chat closed');
|
|
46
|
+
}}
|
|
35
47
|
/>
|
|
36
48
|
);
|
|
37
49
|
};
|
|
@@ -42,43 +54,152 @@ export default App;
|
|
|
42
54
|
### Chatbot Component Props
|
|
43
55
|
|
|
44
56
|
- **title**: `string` - The title of the chatbot.
|
|
45
|
-
- **config**: `ClientConfig` - Configuration object for the Asgard service client
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
- **
|
|
51
|
-
- **
|
|
57
|
+
- **config**: `ClientConfig` - Configuration object for the Asgard service client, including:
|
|
58
|
+
- `apiKey`: `string` (required) - API key for authentication
|
|
59
|
+
- `endpoint`: `string` (required) - API endpoint URL
|
|
60
|
+
- `onExecutionError?`: `(error: ErrorEventData) => void` - Error handler for execution errors
|
|
61
|
+
- `transformSsePayload?`: `(payload: FetchSsePayload) => FetchSsePayload` - SSE payload transformer
|
|
62
|
+
- **customChannelId**: `string` - Custom channel identifier for the chat session
|
|
63
|
+
- **initMessages**: `ConversationMessage[]` - Initial messages to display in the chat
|
|
64
|
+
- **debugMode**: `boolean` - Enable debug mode, defaults to `false`
|
|
65
|
+
- **fullScreen**: `boolean` - Display chatbot in full screen mode, defaults to `false`
|
|
66
|
+
- **avatar**: `string` - URL for the chatbot's avatar image
|
|
67
|
+
- **botTypingPlaceholder**: `string` - Text to display while the bot is typing
|
|
68
|
+
- **theme**: `Partial<AsgardThemeContextValue>` - Custom theme configuration
|
|
69
|
+
- **onReset**: `() => void` - Callback function when chat is reset
|
|
70
|
+
- **onClose**: `() => void` - Callback function when chat is closed
|
|
71
|
+
|
|
72
|
+
### Theme Configuration
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
interface AsgardThemeContextValue {
|
|
76
|
+
chatbot: {
|
|
77
|
+
width?: string;
|
|
78
|
+
height?: string;
|
|
79
|
+
maxWidth?: string;
|
|
80
|
+
minWidth?: string;
|
|
81
|
+
maxHeight?: string;
|
|
82
|
+
minHeight?: string;
|
|
83
|
+
backgroundColor?: string;
|
|
84
|
+
borderColor?: string;
|
|
85
|
+
borderRadius?: string;
|
|
86
|
+
contentMaxWidth?: string;
|
|
87
|
+
};
|
|
88
|
+
botMessage: {
|
|
89
|
+
color?: string;
|
|
90
|
+
backgroundColor?: string;
|
|
91
|
+
};
|
|
92
|
+
userMessage: {
|
|
93
|
+
color?: string;
|
|
94
|
+
backgroundColor?: string;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Default Theme
|
|
100
|
+
|
|
101
|
+
The default theme uses CSS variables for consistent styling:
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
const defaultTheme = {
|
|
105
|
+
chatbot: {
|
|
106
|
+
width: '375px',
|
|
107
|
+
height: '640px',
|
|
108
|
+
backgroundColor: 'var(--asg-color-bg)',
|
|
109
|
+
borderColor: 'var(--asg-color-border)',
|
|
110
|
+
borderRadius: 'var(--asg-radius-md)',
|
|
111
|
+
contentMaxWidth: '1200px',
|
|
112
|
+
},
|
|
113
|
+
botMessage: {
|
|
114
|
+
color: 'var(--asg-color-text)',
|
|
115
|
+
backgroundColor: 'var(--asg-color-secondary)',
|
|
116
|
+
},
|
|
117
|
+
userMessage: {
|
|
118
|
+
color: 'var(--asg-color-text)',
|
|
119
|
+
backgroundColor: 'var(--asg-color-primary)',
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Usage Example
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
const App = () => {
|
|
128
|
+
const customTheme = {
|
|
129
|
+
chatbot: {
|
|
130
|
+
width: '400px',
|
|
131
|
+
height: '600px',
|
|
132
|
+
backgroundColor: '#ffffff',
|
|
133
|
+
borderRadius: '12px',
|
|
134
|
+
},
|
|
135
|
+
botMessage: {
|
|
136
|
+
backgroundColor: '#f0f0f0',
|
|
137
|
+
},
|
|
138
|
+
userMessage: {
|
|
139
|
+
backgroundColor: '#007bff',
|
|
140
|
+
color: '#ffffff',
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<Chatbot
|
|
146
|
+
// ... other props
|
|
147
|
+
theme={customTheme}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Note: When `fullScreen` prop is set to `true`, the chatbot's width and height will be set to `100vw` and `100vh` respectively, and `borderRadius` will be set to zero, regardless of theme settings.
|
|
52
154
|
|
|
53
155
|
## Development
|
|
54
156
|
|
|
55
|
-
To
|
|
157
|
+
To develop the React package locally, follow these steps:
|
|
56
158
|
|
|
57
|
-
1. Clone the repository and navigate to the
|
|
58
|
-
2. Install dependencies:
|
|
159
|
+
1. Clone the repository and navigate to the project root directory.
|
|
59
160
|
|
|
161
|
+
2. Install dependencies:
|
|
60
162
|
```sh
|
|
61
163
|
yarn install
|
|
62
164
|
```
|
|
63
165
|
|
|
64
|
-
3.
|
|
166
|
+
3. Start development:
|
|
167
|
+
|
|
168
|
+
You can use the following commands to work with the React package:
|
|
65
169
|
|
|
66
170
|
```sh
|
|
67
|
-
|
|
68
|
-
|
|
171
|
+
# Lint the React package
|
|
172
|
+
yarn lint:react
|
|
69
173
|
|
|
70
|
-
|
|
174
|
+
# Run tests
|
|
175
|
+
yarn test:react
|
|
71
176
|
|
|
72
|
-
|
|
73
|
-
yarn
|
|
177
|
+
# Build the package
|
|
178
|
+
yarn build:react
|
|
179
|
+
|
|
180
|
+
# Watch mode for development
|
|
181
|
+
yarn watch:react
|
|
182
|
+
|
|
183
|
+
# Run the demo application
|
|
184
|
+
yarn serve:react-demo
|
|
74
185
|
```
|
|
75
186
|
|
|
76
|
-
|
|
187
|
+
For working with both core and React packages:
|
|
77
188
|
|
|
78
189
|
```sh
|
|
79
|
-
|
|
190
|
+
# Lint both packages
|
|
191
|
+
yarn lint:packages
|
|
192
|
+
|
|
193
|
+
# Build core package (required for React package)
|
|
194
|
+
yarn build:core
|
|
195
|
+
|
|
196
|
+
# Release packages
|
|
197
|
+
yarn release:core # Release core package
|
|
198
|
+
yarn release:react # Release React package
|
|
80
199
|
```
|
|
81
200
|
|
|
201
|
+
All builds will be available in the `dist` directory of their respective packages.
|
|
202
|
+
|
|
82
203
|
## Contributing
|
|
83
204
|
|
|
84
205
|
We welcome contributions! Please read our [contributing guide](../../CONTRIBUTING.md) to get started.
|
package/dist/components/conversation-message-renderer/conversation-message-renderer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-message-renderer.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-message-renderer/conversation-message-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAuB,MAAM,iBAAiB,CAAC;AAS3E,UAAU,gCAAgC;IACxC,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,gCAAgC,GACtC,SAAS,
|
|
1
|
+
{"version":3,"file":"conversation-message-renderer.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-message-renderer/conversation-message-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAuB,MAAM,iBAAiB,CAAC;AAS3E,UAAU,gCAAgC;IACxC,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,gCAAgC,GACtC,SAAS,CAgCX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hint-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/hint-template/hint-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAE,mBAAmB,EAAuB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"hint-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/hint-template/hint-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAE,mBAAmB,EAAuB,MAAM,iBAAiB,CAAC;AAG3E,UAAU,iBAAiB;IACzB,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAuBhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/text-template/text-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAOtD,UAAU,iBAAiB;IACzB,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"text-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/text-template/text-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAOtD,UAAU,iBAAiB;IACzB,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CA+BhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-channel.d.ts","sourceRoot":"","sources":["../../src/hooks/use-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAGnB,YAAY,EACZ,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AAGzB,UAAU,eAAe;IACvB,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACrC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;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,EAGnB,YAAY,EACZ,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AAGzB,UAAU,eAAe;IACvB,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACrC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,CAgHnE"}
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as r, jsxs as m } from "react/jsx-runtime";
|
|
2
2
|
import * as u from "react";
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { AsgardServiceClient as
|
|
5
|
-
function
|
|
3
|
+
import { createContext as ot, useMemo as y, useContext as nt, useRef as A, useEffect as L, useState as R, useCallback as g, memo as _t } from "react";
|
|
4
|
+
import { AsgardServiceClient as ut, Conversation as dt, Channel as ht, MessageTemplateType as V } from "@asgard-js/core";
|
|
5
|
+
function rt(e) {
|
|
6
6
|
var t, o, n = "";
|
|
7
7
|
if (typeof e == "string" || typeof e == "number") n += e;
|
|
8
8
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
9
|
-
var
|
|
10
|
-
for (t = 0; t <
|
|
9
|
+
var s = e.length;
|
|
10
|
+
for (t = 0; t < s; t++) e[t] && (o = rt(e[t])) && (n && (n += " "), n += o);
|
|
11
11
|
} else for (o in e) e[o] && (n && (n += " "), n += o);
|
|
12
12
|
return n;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
for (var e, t, o = 0, n = "",
|
|
14
|
+
function w() {
|
|
15
|
+
for (var e, t, o = 0, n = "", s = arguments.length; o < s; o++) (e = arguments[o]) && (t = rt(e)) && (n && (n += " "), n += t);
|
|
16
16
|
return n;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function U(e) {
|
|
19
19
|
return e !== null && typeof e == "object" && !Array.isArray(e);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function D(e, t) {
|
|
22
22
|
const o = { ...e };
|
|
23
23
|
if (!t) return o;
|
|
24
|
-
for (const [n,
|
|
25
|
-
if (!
|
|
26
|
-
o[n] =
|
|
24
|
+
for (const [n, s] of Object.entries(t)) {
|
|
25
|
+
if (!U(s)) {
|
|
26
|
+
o[n] = s;
|
|
27
27
|
continue;
|
|
28
28
|
}
|
|
29
|
-
o[n] =
|
|
29
|
+
o[n] = D(U(o[n]) ? o[n] : {}, s);
|
|
30
30
|
}
|
|
31
31
|
return o;
|
|
32
32
|
}
|
|
33
|
-
const
|
|
33
|
+
const st = {
|
|
34
34
|
chatbot: {
|
|
35
35
|
width: "375px",
|
|
36
36
|
height: "640px",
|
|
@@ -47,14 +47,14 @@ const nt = {
|
|
|
47
47
|
color: "var(--asg-color-text)",
|
|
48
48
|
backgroundColor: "var(--asg-color-primary)"
|
|
49
49
|
}
|
|
50
|
-
},
|
|
51
|
-
|
|
50
|
+
}, ct = ot(
|
|
51
|
+
st
|
|
52
52
|
);
|
|
53
|
-
function
|
|
54
|
-
const { children: t, fullScreen: o, theme: n = {} } = e,
|
|
55
|
-
() =>
|
|
56
|
-
|
|
57
|
-
o ?
|
|
53
|
+
function mt(e) {
|
|
54
|
+
const { children: t, fullScreen: o, theme: n = {} } = e, s = y(
|
|
55
|
+
() => D(
|
|
56
|
+
st,
|
|
57
|
+
o ? D(n, {
|
|
58
58
|
chatbot: {
|
|
59
59
|
width: "100vw",
|
|
60
60
|
height: "100vh",
|
|
@@ -64,63 +64,66 @@ function ht(e) {
|
|
|
64
64
|
),
|
|
65
65
|
[o, n]
|
|
66
66
|
);
|
|
67
|
-
return /* @__PURE__ */
|
|
67
|
+
return /* @__PURE__ */ r(ct.Provider, { value: s, children: t });
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
69
|
+
function j() {
|
|
70
|
+
return nt(ct);
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
const { config: t } = e, o =
|
|
74
|
-
return o.current || (o.current = new
|
|
72
|
+
function gt(e) {
|
|
73
|
+
const { config: t } = e, o = A(null);
|
|
74
|
+
return o.current || (o.current = new ut(t)), L(() => () => {
|
|
75
75
|
o.current && (o.current.close(), o.current = null);
|
|
76
76
|
}, [t]), o.current;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function bt(e) {
|
|
79
79
|
const {
|
|
80
80
|
client: t,
|
|
81
81
|
customChannelId: o,
|
|
82
82
|
customMessageId: n,
|
|
83
|
-
initMessages:
|
|
83
|
+
initMessages: s,
|
|
84
84
|
showDebugMessage: c
|
|
85
85
|
} = e;
|
|
86
86
|
if (!t)
|
|
87
87
|
throw new Error("Client instance is required");
|
|
88
88
|
if (!o)
|
|
89
89
|
throw new Error("Custom channel id is required");
|
|
90
|
-
const [i, a] =
|
|
91
|
-
const x = new
|
|
90
|
+
const [i, a] = R(null), [_, f] = R(!0), [v, b] = R(!1), [l, d] = R(!1), [h, p] = R(null), C = g(async () => {
|
|
91
|
+
const x = new dt({
|
|
92
92
|
showDebugMessage: c,
|
|
93
93
|
messages: new Map(
|
|
94
|
-
|
|
94
|
+
s == null ? void 0 : s.map((N) => [N.messageId, N])
|
|
95
95
|
)
|
|
96
96
|
});
|
|
97
|
-
|
|
98
|
-
const
|
|
97
|
+
b(!0), d(!0), p(x);
|
|
98
|
+
const P = await ht.reset(
|
|
99
99
|
{
|
|
100
100
|
client: t,
|
|
101
101
|
customChannelId: o,
|
|
102
102
|
customMessageId: n,
|
|
103
103
|
conversation: x,
|
|
104
|
-
statesObserver: (
|
|
105
|
-
d(
|
|
104
|
+
statesObserver: (N) => {
|
|
105
|
+
d(N.isConnecting), p(N.conversation);
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
onSseCompleted() {
|
|
110
|
-
|
|
110
|
+
b(!1);
|
|
111
|
+
},
|
|
112
|
+
onSseError() {
|
|
113
|
+
b(!1);
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
);
|
|
114
|
-
a(
|
|
117
|
+
a(P);
|
|
115
118
|
}, [
|
|
116
119
|
t,
|
|
117
120
|
o,
|
|
118
121
|
n,
|
|
119
|
-
|
|
122
|
+
s,
|
|
120
123
|
c
|
|
121
124
|
]), M = g(() => {
|
|
122
|
-
a((x) => (x == null || x.close(), null)),
|
|
123
|
-
}, []),
|
|
125
|
+
a((x) => (x == null || x.close(), null)), f(!1), b(!1), d(!1), p(null);
|
|
126
|
+
}, []), B = g(
|
|
124
127
|
(x) => {
|
|
125
128
|
i == null || i.sendMessage({ text: x });
|
|
126
129
|
},
|
|
@@ -134,7 +137,7 @@ function gt(e) {
|
|
|
134
137
|
isResetting: v,
|
|
135
138
|
isConnecting: l,
|
|
136
139
|
conversation: h,
|
|
137
|
-
sendMessage:
|
|
140
|
+
sendMessage: B,
|
|
138
141
|
resetChannel: C,
|
|
139
142
|
closeChannel: M
|
|
140
143
|
}),
|
|
@@ -143,22 +146,22 @@ function gt(e) {
|
|
|
143
146
|
v,
|
|
144
147
|
l,
|
|
145
148
|
h,
|
|
146
|
-
|
|
149
|
+
B,
|
|
147
150
|
C,
|
|
148
151
|
M
|
|
149
152
|
]
|
|
150
153
|
);
|
|
151
154
|
}
|
|
152
|
-
function
|
|
153
|
-
const [o, n] =
|
|
155
|
+
function ft(e, t) {
|
|
156
|
+
const [o, n] = R(e);
|
|
154
157
|
return L(() => {
|
|
155
|
-
const
|
|
158
|
+
const s = window.setTimeout(() => {
|
|
156
159
|
n(e);
|
|
157
160
|
}, t ?? 300);
|
|
158
|
-
return () => clearTimeout(
|
|
161
|
+
return () => clearTimeout(s);
|
|
159
162
|
}, [e, t]), o;
|
|
160
163
|
}
|
|
161
|
-
const
|
|
164
|
+
const it = ot({
|
|
162
165
|
avatar: void 0,
|
|
163
166
|
client: null,
|
|
164
167
|
isOpen: !1,
|
|
@@ -168,32 +171,32 @@ const rt = tt({
|
|
|
168
171
|
messageBoxBottomRef: { current: null },
|
|
169
172
|
botTypingPlaceholder: void 0
|
|
170
173
|
});
|
|
171
|
-
function
|
|
174
|
+
function pt(e) {
|
|
172
175
|
const {
|
|
173
176
|
avatar: t,
|
|
174
177
|
children: o,
|
|
175
178
|
config: n,
|
|
176
|
-
botTypingPlaceholder:
|
|
179
|
+
botTypingPlaceholder: s,
|
|
177
180
|
customChannelId: c,
|
|
178
181
|
customMessageId: i,
|
|
179
182
|
delayTime: a,
|
|
180
183
|
initMessages: _,
|
|
181
|
-
options:
|
|
184
|
+
options: f,
|
|
182
185
|
...v
|
|
183
|
-
} = e,
|
|
186
|
+
} = e, b = A(null), l = gt({ config: n }), {
|
|
184
187
|
isOpen: d,
|
|
185
188
|
isResetting: h,
|
|
186
189
|
isConnecting: p,
|
|
187
190
|
conversation: C,
|
|
188
191
|
sendMessage: M,
|
|
189
|
-
resetChannel:
|
|
192
|
+
resetChannel: B,
|
|
190
193
|
closeChannel: x
|
|
191
|
-
} =
|
|
194
|
+
} = bt({
|
|
192
195
|
client: l,
|
|
193
196
|
customChannelId: c,
|
|
194
197
|
initMessages: _,
|
|
195
|
-
showDebugMessage:
|
|
196
|
-
}),
|
|
198
|
+
showDebugMessage: f == null ? void 0 : f.showDebugMessage
|
|
199
|
+
}), P = y(
|
|
197
200
|
() => ({
|
|
198
201
|
avatar: t,
|
|
199
202
|
client: l,
|
|
@@ -202,10 +205,10 @@ function ft(e) {
|
|
|
202
205
|
isConnecting: p,
|
|
203
206
|
messages: (C == null ? void 0 : C.messages) ?? null,
|
|
204
207
|
sendMessage: M,
|
|
205
|
-
resetChannel:
|
|
208
|
+
resetChannel: B,
|
|
206
209
|
closeChannel: x,
|
|
207
|
-
botTypingPlaceholder:
|
|
208
|
-
messageBoxBottomRef:
|
|
210
|
+
botTypingPlaceholder: s,
|
|
211
|
+
messageBoxBottomRef: b
|
|
209
212
|
}),
|
|
210
213
|
[
|
|
211
214
|
t,
|
|
@@ -215,25 +218,25 @@ function ft(e) {
|
|
|
215
218
|
p,
|
|
216
219
|
C == null ? void 0 : C.messages,
|
|
217
220
|
M,
|
|
218
|
-
|
|
221
|
+
B,
|
|
219
222
|
x,
|
|
220
|
-
|
|
223
|
+
s
|
|
221
224
|
]
|
|
222
|
-
),
|
|
223
|
-
return /* @__PURE__ */
|
|
225
|
+
), N = j();
|
|
226
|
+
return /* @__PURE__ */ r(it.Provider, { value: P, children: /* @__PURE__ */ r("div", { style: N == null ? void 0 : N.chatbot, ...v, children: o }) });
|
|
224
227
|
}
|
|
225
|
-
function
|
|
226
|
-
return
|
|
228
|
+
function T() {
|
|
229
|
+
return nt(it);
|
|
227
230
|
}
|
|
228
|
-
const
|
|
229
|
-
chatbot_header:
|
|
230
|
-
chatbot_header__content:
|
|
231
|
-
chatbot_header__title:
|
|
232
|
-
chatbot_header__extra:
|
|
233
|
-
},
|
|
234
|
-
function
|
|
231
|
+
const Ct = "_chatbot_header_cqlve_1", vt = "_chatbot_header__content_cqlve_1", xt = "_chatbot_header__title_cqlve_9", yt = "_chatbot_header__extra_cqlve_20", I = {
|
|
232
|
+
chatbot_header: Ct,
|
|
233
|
+
chatbot_header__content: vt,
|
|
234
|
+
chatbot_header__title: xt,
|
|
235
|
+
chatbot_header__extra: yt
|
|
236
|
+
}, wt = (e) => /* @__PURE__ */ u.createElement("svg", { width: 33, height: 32, viewBox: "0 0 33 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ u.createElement("g", { clipPath: "url(#clip0_3084_29383)" }, /* @__PURE__ */ u.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__ */ u.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__ */ u.createElement("defs", null, /* @__PURE__ */ u.createElement("clipPath", { id: "clip0_3084_29383" }, /* @__PURE__ */ u.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" }))));
|
|
237
|
+
function Tt(e) {
|
|
235
238
|
const { avatar: t } = e;
|
|
236
|
-
return t ? /* @__PURE__ */
|
|
239
|
+
return t ? /* @__PURE__ */ r(
|
|
237
240
|
"img",
|
|
238
241
|
{
|
|
239
242
|
src: t,
|
|
@@ -244,89 +247,89 @@ function wt(e) {
|
|
|
244
247
|
borderRadius: "50%"
|
|
245
248
|
}
|
|
246
249
|
}
|
|
247
|
-
) : /* @__PURE__ */
|
|
250
|
+
) : /* @__PURE__ */ r(wt, {});
|
|
248
251
|
}
|
|
249
|
-
const
|
|
250
|
-
function
|
|
251
|
-
const { title: t, onReset: o, onClose: n } = e, { chatbot:
|
|
252
|
+
const Nt = (e) => /* @__PURE__ */ u.createElement("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ u.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" })), Rt = (e) => /* @__PURE__ */ u.createElement("svg", { width: 15, height: 14, viewBox: "0 0 15 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ u.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" }));
|
|
253
|
+
function Mt(e) {
|
|
254
|
+
const { title: t, onReset: o, onClose: n } = e, { chatbot: s } = j(), { avatar: c, isResetting: i, resetChannel: a, closeChannel: _ } = T(), f = y(
|
|
252
255
|
() => ({
|
|
253
|
-
maxWidth: (
|
|
256
|
+
maxWidth: (s == null ? void 0 : s.contentMaxWidth) ?? "1200px"
|
|
254
257
|
}),
|
|
255
|
-
[
|
|
258
|
+
[s]
|
|
256
259
|
), v = g(
|
|
257
260
|
(l) => {
|
|
258
261
|
i || (l.stopPropagation(), o == null || o(), a == null || a());
|
|
259
262
|
},
|
|
260
263
|
[i, o, a]
|
|
261
|
-
),
|
|
264
|
+
), b = g(
|
|
262
265
|
(l) => {
|
|
263
266
|
i || (l.stopPropagation(), n == null || n(), _ == null || _());
|
|
264
267
|
},
|
|
265
268
|
[i, n, _]
|
|
266
269
|
);
|
|
267
|
-
return /* @__PURE__ */
|
|
268
|
-
/* @__PURE__ */ m("div", { className:
|
|
269
|
-
/* @__PURE__ */
|
|
270
|
-
/* @__PURE__ */
|
|
270
|
+
return /* @__PURE__ */ r("div", { className: I.chatbot_header, children: /* @__PURE__ */ m("div", { className: I.chatbot_header__content, style: f, children: [
|
|
271
|
+
/* @__PURE__ */ m("div", { className: I.chatbot_header__title, children: [
|
|
272
|
+
/* @__PURE__ */ r(Tt, { avatar: c }),
|
|
273
|
+
/* @__PURE__ */ r("h4", { children: t })
|
|
271
274
|
] }),
|
|
272
|
-
/* @__PURE__ */ m("div", { className:
|
|
273
|
-
/* @__PURE__ */
|
|
274
|
-
/* @__PURE__ */
|
|
275
|
+
/* @__PURE__ */ m("div", { className: I.chatbot_header__extra, children: [
|
|
276
|
+
/* @__PURE__ */ r("div", { onClick: v, children: /* @__PURE__ */ r(Nt, {}) }),
|
|
277
|
+
/* @__PURE__ */ r("div", { onClick: b, children: /* @__PURE__ */ r(Rt, {}) })
|
|
275
278
|
] })
|
|
276
279
|
] }) });
|
|
277
280
|
}
|
|
278
|
-
const
|
|
279
|
-
chatbot_body:
|
|
280
|
-
chatbot_body__content:
|
|
281
|
-
},
|
|
282
|
-
template_box:
|
|
281
|
+
const St = "_chatbot_body_1f0gq_1", Lt = "_chatbot_body__content_1f0gq_7", J = {
|
|
282
|
+
chatbot_body: St,
|
|
283
|
+
chatbot_body__content: Lt
|
|
284
|
+
}, Et = "_template_box_1ozig_1", E = {
|
|
285
|
+
template_box: Et,
|
|
283
286
|
"template_box--bot": "_template_box--bot_1ozig_7",
|
|
284
287
|
"template_box--horizontal": "_template_box--horizontal_1ozig_7",
|
|
285
288
|
"template_box--vertical": "_template_box--vertical_1ozig_10",
|
|
286
289
|
"template_box--user": "_template_box--user_1ozig_14"
|
|
287
290
|
};
|
|
288
|
-
function
|
|
289
|
-
const { type: t, direction: o = "horizontal", children: n } = e,
|
|
291
|
+
function q(e) {
|
|
292
|
+
const { type: t, direction: o = "horizontal", children: n } = e, s = y(() => {
|
|
290
293
|
switch (t) {
|
|
291
294
|
case "user":
|
|
292
|
-
return
|
|
295
|
+
return w(E.template_box, E["template_box--user"]);
|
|
293
296
|
case "bot":
|
|
294
297
|
default:
|
|
295
|
-
return
|
|
298
|
+
return w(
|
|
296
299
|
E.template_box,
|
|
297
300
|
E["template_box--bot"],
|
|
298
301
|
o === "horizontal" ? E["template_box--horizontal"] : E["template_box--vertical"]
|
|
299
302
|
);
|
|
300
303
|
}
|
|
301
304
|
}, [o, t]);
|
|
302
|
-
return /* @__PURE__ */
|
|
305
|
+
return /* @__PURE__ */ r("div", { className: s, children: n });
|
|
303
306
|
}
|
|
304
|
-
const
|
|
305
|
-
template_box_content:
|
|
307
|
+
const kt = "_template_box_content_12ojl_1", Bt = "_content_12ojl_7", K = {
|
|
308
|
+
template_box_content: kt,
|
|
306
309
|
content: Bt
|
|
307
|
-
},
|
|
308
|
-
quick_replies_box:
|
|
309
|
-
quick_reply:
|
|
310
|
+
}, Ht = "_quick_replies_box_zoq7y_1", zt = "_quick_reply_zoq7y_7", Q = {
|
|
311
|
+
quick_replies_box: Ht,
|
|
312
|
+
quick_reply: zt
|
|
310
313
|
};
|
|
311
|
-
function
|
|
312
|
-
const { quickReplies: t } = e, { sendMessage: o, isConnecting: n } =
|
|
314
|
+
function Vt(e) {
|
|
315
|
+
const { quickReplies: t } = e, { sendMessage: o, isConnecting: n } = T(), s = g(
|
|
313
316
|
(c) => {
|
|
314
317
|
o == null || o(c);
|
|
315
318
|
},
|
|
316
319
|
[o]
|
|
317
320
|
);
|
|
318
|
-
return t != null && t.length ? /* @__PURE__ */
|
|
321
|
+
return t != null && t.length ? /* @__PURE__ */ r("div", { className: Q.quick_replies_box, children: t.map((c) => /* @__PURE__ */ r(
|
|
319
322
|
"button",
|
|
320
323
|
{
|
|
321
|
-
className:
|
|
324
|
+
className: Q.quick_reply,
|
|
322
325
|
disabled: n,
|
|
323
|
-
onClick: () =>
|
|
326
|
+
onClick: () => s(c.text),
|
|
324
327
|
children: c.text
|
|
325
328
|
},
|
|
326
329
|
c.text
|
|
327
330
|
)) }) : null;
|
|
328
331
|
}
|
|
329
|
-
function
|
|
332
|
+
function O(e) {
|
|
330
333
|
return e.toLocaleTimeString("zh-TW", {
|
|
331
334
|
timeZone: "Asia/Taipei",
|
|
332
335
|
hour: "2-digit",
|
|
@@ -334,84 +337,84 @@ function ct(e) {
|
|
|
334
337
|
hour12: !1
|
|
335
338
|
});
|
|
336
339
|
}
|
|
337
|
-
const
|
|
338
|
-
time:
|
|
340
|
+
const qt = "_time_rgg92_1", At = {
|
|
341
|
+
time: qt
|
|
339
342
|
};
|
|
340
|
-
function
|
|
343
|
+
function F(e) {
|
|
341
344
|
const { time: t, className: o } = e;
|
|
342
|
-
return t ? /* @__PURE__ */
|
|
345
|
+
return t ? /* @__PURE__ */ r("div", { className: w(At.time, o), children: O(t) }) : null;
|
|
343
346
|
}
|
|
344
|
-
function
|
|
347
|
+
function W(e) {
|
|
345
348
|
const { quickReplies: t, time: o, children: n } = e;
|
|
346
|
-
return /* @__PURE__ */ m("div", { className:
|
|
347
|
-
/* @__PURE__ */ m("div", { className:
|
|
349
|
+
return /* @__PURE__ */ m("div", { className: K.template_box_content, children: [
|
|
350
|
+
/* @__PURE__ */ m("div", { className: K.content, children: [
|
|
348
351
|
n,
|
|
349
|
-
/* @__PURE__ */
|
|
352
|
+
/* @__PURE__ */ r(F, { time: o })
|
|
350
353
|
] }),
|
|
351
|
-
!!(t != null && t.length) && /* @__PURE__ */
|
|
354
|
+
!!(t != null && t.length) && /* @__PURE__ */ r(Vt, { quickReplies: t })
|
|
352
355
|
] });
|
|
353
356
|
}
|
|
354
|
-
const
|
|
355
|
-
bot_avatar:
|
|
356
|
-
},
|
|
357
|
+
const It = "_bot_avatar_xrs9x_1", X = {
|
|
358
|
+
bot_avatar: It
|
|
359
|
+
}, Zt = (e) => /* @__PURE__ */ u.createElement("svg", { viewBox: "0 0 25 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ u.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__ */ u.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" })), $ = _t((e) => {
|
|
357
360
|
const { avatar: t } = e;
|
|
358
|
-
return t ? /* @__PURE__ */
|
|
359
|
-
}),
|
|
360
|
-
text:
|
|
361
|
+
return t ? /* @__PURE__ */ r("img", { src: t, alt: "Bot Avatar", className: X.bot_avatar }) : /* @__PURE__ */ r("div", { className: X.bot_avatar, children: /* @__PURE__ */ r(Zt, {}) });
|
|
362
|
+
}), jt = "_text_1djgp_1", $t = "_dot_1djgp_18", k = {
|
|
363
|
+
text: jt,
|
|
361
364
|
"text--bot": "_text--bot_1djgp_7",
|
|
362
365
|
"typing-indicator": "_typing-indicator_1djgp_13",
|
|
363
|
-
dot:
|
|
366
|
+
dot: $t
|
|
364
367
|
};
|
|
365
|
-
function
|
|
366
|
-
const { children: t, onResize: o } = e, n =
|
|
368
|
+
function Pt(e) {
|
|
369
|
+
const { children: t, onResize: o } = e, n = A(null);
|
|
367
370
|
return L(() => {
|
|
368
|
-
const
|
|
371
|
+
const s = new ResizeObserver((c) => {
|
|
369
372
|
for (const i of c) {
|
|
370
373
|
const { width: a, height: _ } = i.contentRect;
|
|
371
374
|
o(a, _);
|
|
372
375
|
}
|
|
373
376
|
});
|
|
374
|
-
return n.current &&
|
|
375
|
-
|
|
377
|
+
return n.current && s.observe(n.current), () => {
|
|
378
|
+
s.disconnect();
|
|
376
379
|
};
|
|
377
|
-
}, [n, o]), /* @__PURE__ */
|
|
380
|
+
}, [n, o]), /* @__PURE__ */ r("div", { ref: n, children: t });
|
|
378
381
|
}
|
|
379
|
-
function
|
|
380
|
-
const { isTyping: t, typingText: o } = e, { messageBoxBottomRef: n, avatar:
|
|
382
|
+
function at(e) {
|
|
383
|
+
const { isTyping: t, typingText: o } = e, { messageBoxBottomRef: n, avatar: s } = T(), c = g(() => {
|
|
381
384
|
var a;
|
|
382
385
|
(a = n.current) == null || a.scrollIntoView({ behavior: "smooth" });
|
|
383
|
-
}, [n]), i =
|
|
384
|
-
return i ? /* @__PURE__ */ m(
|
|
385
|
-
/* @__PURE__ */
|
|
386
|
-
/* @__PURE__ */
|
|
387
|
-
/* @__PURE__ */
|
|
388
|
-
i && /* @__PURE__ */ m("span", { className:
|
|
389
|
-
/* @__PURE__ */
|
|
390
|
-
/* @__PURE__ */
|
|
391
|
-
/* @__PURE__ */
|
|
386
|
+
}, [n]), i = ft(t, 500);
|
|
387
|
+
return i ? /* @__PURE__ */ m(q, { type: "bot", direction: "horizontal", children: [
|
|
388
|
+
/* @__PURE__ */ r($, { avatar: s }),
|
|
389
|
+
/* @__PURE__ */ r(W, { time: /* @__PURE__ */ new Date(), children: /* @__PURE__ */ r("div", { className: w(k.text, k["text--bot"]), children: /* @__PURE__ */ m(Pt, { onResize: c, children: [
|
|
390
|
+
/* @__PURE__ */ r("span", { children: o ?? "" }),
|
|
391
|
+
i && /* @__PURE__ */ m("span", { className: k["typing-indicator"], children: [
|
|
392
|
+
/* @__PURE__ */ r("div", { className: k.dot }),
|
|
393
|
+
/* @__PURE__ */ r("div", { className: k.dot }),
|
|
394
|
+
/* @__PURE__ */ r("div", { className: k.dot })
|
|
392
395
|
] })
|
|
393
396
|
] }) }) })
|
|
394
397
|
] }) : null;
|
|
395
398
|
}
|
|
396
|
-
function
|
|
397
|
-
const { placeholder: t } = e, { isConnecting: o, messages: n } =
|
|
399
|
+
function Dt(e) {
|
|
400
|
+
const { placeholder: t } = e, { isConnecting: o, messages: n } = T(), s = y(
|
|
398
401
|
() => Array.from((n == null ? void 0 : n.values()) ?? []).some(
|
|
399
402
|
(c) => c.type === "bot" && c.isTyping
|
|
400
403
|
),
|
|
401
404
|
[n]
|
|
402
405
|
);
|
|
403
|
-
return o && !
|
|
406
|
+
return o && !s ? /* @__PURE__ */ r(at, { isTyping: !0, typingText: t }) : null;
|
|
404
407
|
}
|
|
405
|
-
const
|
|
406
|
-
card_root:
|
|
407
|
-
card_content:
|
|
408
|
-
card_title:
|
|
409
|
-
card_description:
|
|
410
|
-
card_actions:
|
|
408
|
+
const Ot = "_card_root_1ygom_1", Ft = "_card_content_1ygom_10", Wt = "_card_title_1ygom_17", Ut = "_card_description_1ygom_23", Jt = "_card_actions_1ygom_37", H = {
|
|
409
|
+
card_root: Ot,
|
|
410
|
+
card_content: Ft,
|
|
411
|
+
card_title: Wt,
|
|
412
|
+
card_description: Ut,
|
|
413
|
+
card_actions: Jt
|
|
411
414
|
};
|
|
412
|
-
function
|
|
415
|
+
function lt(e) {
|
|
413
416
|
var i;
|
|
414
|
-
const { template: t } = e, { sendMessage: o } =
|
|
417
|
+
const { template: t } = e, { sendMessage: o } = T(), n = y(() => (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]), s = y(() => {
|
|
415
418
|
switch (t == null ? void 0 : t.imageAspectRatio) {
|
|
416
419
|
case "square":
|
|
417
420
|
return "1 / 1";
|
|
@@ -433,7 +436,7 @@ function at(e) {
|
|
|
433
436
|
[o]
|
|
434
437
|
);
|
|
435
438
|
return /* @__PURE__ */ m("div", { className: H.card_root, children: [
|
|
436
|
-
(t == null ? void 0 : t.thumbnailImageUrl) && /* @__PURE__ */
|
|
439
|
+
(t == null ? void 0 : t.thumbnailImageUrl) && /* @__PURE__ */ r(
|
|
437
440
|
"img",
|
|
438
441
|
{
|
|
439
442
|
alt: t == null ? void 0 : t.title,
|
|
@@ -443,144 +446,152 @@ function at(e) {
|
|
|
443
446
|
width: "100%",
|
|
444
447
|
maxHeight: "170px",
|
|
445
448
|
objectFit: t == null ? void 0 : t.imageSize,
|
|
446
|
-
aspectRatio:
|
|
449
|
+
aspectRatio: s
|
|
447
450
|
}
|
|
448
451
|
}
|
|
449
452
|
),
|
|
450
453
|
/* @__PURE__ */ m("div", { className: H.card_content, children: [
|
|
451
|
-
/* @__PURE__ */
|
|
452
|
-
/* @__PURE__ */
|
|
453
|
-
/* @__PURE__ */
|
|
454
|
+
/* @__PURE__ */ r("h5", { className: H.card_title, children: t == null ? void 0 : t.title }),
|
|
455
|
+
/* @__PURE__ */ r("div", { className: H.card_description, children: t == null ? void 0 : t.text }),
|
|
456
|
+
/* @__PURE__ */ r("div", { className: H.card_actions, children: (i = t == null ? void 0 : t.buttons) == null ? void 0 : i.map((a, _) => /* @__PURE__ */ r("button", { onClick: c(a.action), children: a.label }, _)) })
|
|
454
457
|
] })
|
|
455
458
|
] });
|
|
456
459
|
}
|
|
457
|
-
function
|
|
458
|
-
const { message: t } = e, { avatar: o } =
|
|
459
|
-
return /* @__PURE__ */ m(
|
|
460
|
-
/* @__PURE__ */
|
|
461
|
-
/* @__PURE__ */
|
|
462
|
-
|
|
460
|
+
function Kt(e) {
|
|
461
|
+
const { message: t } = e, { avatar: o } = T(), n = t.message.template;
|
|
462
|
+
return /* @__PURE__ */ m(q, { type: "bot", direction: "horizontal", children: [
|
|
463
|
+
/* @__PURE__ */ r($, { avatar: o }),
|
|
464
|
+
/* @__PURE__ */ r(
|
|
465
|
+
W,
|
|
463
466
|
{
|
|
464
467
|
time: t.time,
|
|
465
468
|
quickReplies: n == null ? void 0 : n.quickReplies,
|
|
466
|
-
children: /* @__PURE__ */
|
|
469
|
+
children: /* @__PURE__ */ r(lt, { template: n })
|
|
467
470
|
}
|
|
468
471
|
)
|
|
469
472
|
] });
|
|
470
473
|
}
|
|
471
|
-
const
|
|
472
|
-
text:
|
|
474
|
+
const Qt = "_text_sbjtw_1", Z = {
|
|
475
|
+
text: Qt,
|
|
473
476
|
"text--user": "_text--user_sbjtw_7",
|
|
474
477
|
"text--bot": "_text--bot_sbjtw_13"
|
|
475
478
|
};
|
|
476
|
-
function
|
|
479
|
+
function G(e) {
|
|
477
480
|
var n;
|
|
478
|
-
const { message: t } = e, { avatar: o } =
|
|
479
|
-
return t.type === "user" ? /* @__PURE__ */ m(
|
|
480
|
-
/* @__PURE__ */
|
|
481
|
-
/* @__PURE__ */
|
|
482
|
-
] }) : /* @__PURE__ */ m(
|
|
483
|
-
/* @__PURE__ */
|
|
484
|
-
/* @__PURE__ */
|
|
485
|
-
|
|
481
|
+
const { message: t } = e, { avatar: o } = T();
|
|
482
|
+
return t.type === "error" ? null : t.type === "user" ? /* @__PURE__ */ m(q, { type: "user", direction: "horizontal", children: [
|
|
483
|
+
/* @__PURE__ */ r("div", { className: w(Z.text, Z["text--user"]), children: t.text }),
|
|
484
|
+
/* @__PURE__ */ r(F, { time: t.time })
|
|
485
|
+
] }) : /* @__PURE__ */ m(q, { type: "bot", direction: "horizontal", children: [
|
|
486
|
+
/* @__PURE__ */ r($, { avatar: o }),
|
|
487
|
+
/* @__PURE__ */ r(
|
|
488
|
+
W,
|
|
486
489
|
{
|
|
487
490
|
time: t.time,
|
|
488
491
|
quickReplies: (n = t.message.template) == null ? void 0 : n.quickReplies,
|
|
489
|
-
children: /* @__PURE__ */
|
|
492
|
+
children: /* @__PURE__ */ r("div", { className: w(Z.text, Z["text--bot"]), children: t.message.text })
|
|
490
493
|
}
|
|
491
494
|
)
|
|
492
495
|
] });
|
|
493
496
|
}
|
|
494
|
-
const
|
|
495
|
-
carousel_root:
|
|
496
|
-
carousel_time:
|
|
497
|
+
const Xt = "_carousel_root_sv1hc_1", Gt = "_carousel_time_sv1hc_12", Y = {
|
|
498
|
+
carousel_root: Xt,
|
|
499
|
+
carousel_time: Gt
|
|
497
500
|
};
|
|
498
|
-
function
|
|
499
|
-
var
|
|
500
|
-
const { message: t } = e, { avatar: o } =
|
|
501
|
-
return /* @__PURE__ */ m(
|
|
502
|
-
/* @__PURE__ */
|
|
503
|
-
/* @__PURE__ */
|
|
504
|
-
/* @__PURE__ */
|
|
501
|
+
function Yt(e) {
|
|
502
|
+
var s;
|
|
503
|
+
const { message: t } = e, { avatar: o } = T(), n = t.message.template;
|
|
504
|
+
return /* @__PURE__ */ m(q, { type: "bot", direction: "vertical", children: [
|
|
505
|
+
/* @__PURE__ */ r($, { avatar: o }),
|
|
506
|
+
/* @__PURE__ */ r("div", { className: Y.carousel_root, children: (s = n.columns) == null ? void 0 : s.map((c, i) => /* @__PURE__ */ r(lt, { template: c }, i)) }),
|
|
507
|
+
/* @__PURE__ */ r(F, { className: Y.carousel_time, time: t.time })
|
|
505
508
|
] });
|
|
506
509
|
}
|
|
507
|
-
const
|
|
508
|
-
hint_root:
|
|
509
|
-
|
|
510
|
+
const te = "_hint_root_k5fud_1", ee = "_hint_root__error_k5fud_13", oe = "_time_k5fud_17", z = {
|
|
511
|
+
hint_root: te,
|
|
512
|
+
hint_root__error: ee,
|
|
513
|
+
time: oe
|
|
510
514
|
};
|
|
511
|
-
function
|
|
515
|
+
function tt(e) {
|
|
512
516
|
const { message: t } = e;
|
|
513
517
|
if (t.type === "user") return null;
|
|
518
|
+
if (t.type === "error")
|
|
519
|
+
return /* @__PURE__ */ m("div", { className: w(z.hint_root, z.hint_root__error), children: [
|
|
520
|
+
/* @__PURE__ */ r("div", { className: z.time, children: O(t.time) }),
|
|
521
|
+
/* @__PURE__ */ r("span", { children: "Unexpected error" })
|
|
522
|
+
] });
|
|
514
523
|
const o = t.message.template;
|
|
515
|
-
return o.type !==
|
|
516
|
-
/* @__PURE__ */
|
|
524
|
+
return o.type !== V.HINT ? null : /* @__PURE__ */ m("div", { className: z.hint_root, children: [
|
|
525
|
+
/* @__PURE__ */ r("div", { className: z.time, children: O(t.time) }),
|
|
517
526
|
o.text
|
|
518
527
|
] });
|
|
519
528
|
}
|
|
520
|
-
function
|
|
529
|
+
function ne(e) {
|
|
521
530
|
var o;
|
|
522
531
|
const { message: t } = e;
|
|
523
532
|
if (t.type === "user")
|
|
524
|
-
return /* @__PURE__ */
|
|
533
|
+
return /* @__PURE__ */ r(G, { message: t });
|
|
534
|
+
if (t.type === "error")
|
|
535
|
+
return /* @__PURE__ */ r(tt, { message: t });
|
|
525
536
|
if (t.isTyping)
|
|
526
|
-
return /* @__PURE__ */
|
|
527
|
-
|
|
537
|
+
return /* @__PURE__ */ r(
|
|
538
|
+
at,
|
|
528
539
|
{
|
|
529
540
|
isTyping: t.isTyping,
|
|
530
541
|
typingText: t.typingText
|
|
531
542
|
}
|
|
532
543
|
);
|
|
533
544
|
switch ((o = t.message.template) == null ? void 0 : o.type) {
|
|
534
|
-
case
|
|
535
|
-
return /* @__PURE__ */
|
|
536
|
-
case
|
|
537
|
-
return /* @__PURE__ */
|
|
538
|
-
case
|
|
539
|
-
return /* @__PURE__ */
|
|
540
|
-
case
|
|
541
|
-
return /* @__PURE__ */
|
|
545
|
+
case V.TEXT:
|
|
546
|
+
return /* @__PURE__ */ r(G, { message: t });
|
|
547
|
+
case V.HINT:
|
|
548
|
+
return /* @__PURE__ */ r(tt, { message: t });
|
|
549
|
+
case V.BUTTON:
|
|
550
|
+
return /* @__PURE__ */ r(Kt, { message: t });
|
|
551
|
+
case V.CAROUSEL:
|
|
552
|
+
return /* @__PURE__ */ r(Yt, { message: t });
|
|
542
553
|
default:
|
|
543
|
-
return /* @__PURE__ */
|
|
554
|
+
return /* @__PURE__ */ r("div", {});
|
|
544
555
|
}
|
|
545
556
|
}
|
|
546
|
-
function
|
|
547
|
-
const { chatbot: e } =
|
|
557
|
+
function re() {
|
|
558
|
+
const { chatbot: e } = j(), { messages: t, messageBoxBottomRef: o, botTypingPlaceholder: n } = T();
|
|
548
559
|
L(() => {
|
|
549
560
|
var c;
|
|
550
561
|
(c = o.current) == null || c.scrollIntoView({ behavior: "smooth" });
|
|
551
562
|
}, [t, o]);
|
|
552
|
-
const
|
|
563
|
+
const s = y(
|
|
553
564
|
() => ({
|
|
554
565
|
maxWidth: (e == null ? void 0 : e.contentMaxWidth) ?? "1200px"
|
|
555
566
|
}),
|
|
556
567
|
[e]
|
|
557
568
|
);
|
|
558
|
-
return /* @__PURE__ */
|
|
559
|
-
Array.from((t == null ? void 0 : t.values()) ?? []).map((c) => /* @__PURE__ */
|
|
560
|
-
|
|
569
|
+
return /* @__PURE__ */ r("div", { className: J.chatbot_body, children: /* @__PURE__ */ m("div", { className: J.chatbot_body__content, style: s, children: [
|
|
570
|
+
Array.from((t == null ? void 0 : t.values()) ?? []).map((c) => /* @__PURE__ */ r(
|
|
571
|
+
ne,
|
|
561
572
|
{
|
|
562
573
|
message: c
|
|
563
574
|
},
|
|
564
575
|
c.messageId
|
|
565
576
|
)),
|
|
566
|
-
/* @__PURE__ */
|
|
567
|
-
|
|
577
|
+
/* @__PURE__ */ r(
|
|
578
|
+
Dt,
|
|
568
579
|
{
|
|
569
580
|
placeholder: n ?? "正在輸入訊息"
|
|
570
581
|
}
|
|
571
582
|
),
|
|
572
|
-
/* @__PURE__ */
|
|
583
|
+
/* @__PURE__ */ r("div", { ref: o })
|
|
573
584
|
] }) });
|
|
574
585
|
}
|
|
575
|
-
const se = "_chatbot_footer_1uvgs_1",
|
|
586
|
+
const se = "_chatbot_footer_1uvgs_1", ce = "_chatbot_footer__content_1uvgs_1", ie = "_chatbot_textarea_1uvgs_11", ae = "_chatbot_submit_button_1uvgs_26", le = "_chatbot_submit_button__disabled_1uvgs_51", S = {
|
|
576
587
|
chatbot_footer: se,
|
|
577
|
-
chatbot_footer__content:
|
|
578
|
-
chatbot_textarea:
|
|
579
|
-
chatbot_submit_button:
|
|
580
|
-
chatbot_submit_button__disabled:
|
|
581
|
-
},
|
|
582
|
-
function
|
|
583
|
-
const { setValue: t, className: o } = e, [n,
|
|
588
|
+
chatbot_footer__content: ce,
|
|
589
|
+
chatbot_textarea: ie,
|
|
590
|
+
chatbot_submit_button: ae,
|
|
591
|
+
chatbot_submit_button__disabled: le
|
|
592
|
+
}, _e = (e) => /* @__PURE__ */ u.createElement("svg", { width: 15, height: 12, viewBox: "0 0 15 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ u.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" })), ue = (e) => /* @__PURE__ */ u.createElement("svg", { width: 11, height: 16, viewBox: "0 0 11 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ u.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" })), de = (e) => /* @__PURE__ */ u.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ u.createElement("circle", { cx: 20, cy: 20, r: 18, fill: "#D04444" }), /* @__PURE__ */ u.createElement("rect", { x: 12, y: 12, width: 16, height: 16, fill: "#FFFFFF", rx: 2, ry: 2 }));
|
|
593
|
+
function he(e) {
|
|
594
|
+
const { setValue: t, className: o } = e, [n, s] = R(!1), c = A(null);
|
|
584
595
|
L(() => {
|
|
585
596
|
const l = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
586
597
|
if (!l) return;
|
|
@@ -591,7 +602,7 @@ function de(e) {
|
|
|
591
602
|
}, d.onerror = (h) => {
|
|
592
603
|
alert(`語音識別錯誤: ${JSON.stringify(h.error)}`);
|
|
593
604
|
}, d.onend = () => {
|
|
594
|
-
|
|
605
|
+
s(!1);
|
|
595
606
|
}, c.current = d;
|
|
596
607
|
}, [t]);
|
|
597
608
|
const i = g(() => {
|
|
@@ -600,18 +611,18 @@ function de(e) {
|
|
|
600
611
|
return;
|
|
601
612
|
}
|
|
602
613
|
try {
|
|
603
|
-
c.current.start(),
|
|
614
|
+
c.current.start(), s(!0);
|
|
604
615
|
} catch (l) {
|
|
605
616
|
alert(`無法開始辨識: ${JSON.stringify(l)}`);
|
|
606
617
|
}
|
|
607
618
|
}, []), a = g(() => {
|
|
608
|
-
c.current && (c.current.stop(),
|
|
619
|
+
c.current && (c.current.stop(), s(!1));
|
|
609
620
|
}, []), _ = g(
|
|
610
621
|
(l) => {
|
|
611
622
|
n || (l.preventDefault(), i());
|
|
612
623
|
},
|
|
613
624
|
[n, i]
|
|
614
|
-
),
|
|
625
|
+
), f = g(
|
|
615
626
|
(l) => {
|
|
616
627
|
n && (l.preventDefault(), a());
|
|
617
628
|
},
|
|
@@ -621,26 +632,26 @@ function de(e) {
|
|
|
621
632
|
n || (l.preventDefault(), i());
|
|
622
633
|
},
|
|
623
634
|
[n, i]
|
|
624
|
-
),
|
|
635
|
+
), b = g(
|
|
625
636
|
(l) => {
|
|
626
637
|
n && (l.preventDefault(), a());
|
|
627
638
|
},
|
|
628
639
|
[n, a]
|
|
629
640
|
);
|
|
630
|
-
return /* @__PURE__ */
|
|
641
|
+
return /* @__PURE__ */ r(
|
|
631
642
|
"div",
|
|
632
643
|
{
|
|
633
644
|
className: o,
|
|
634
645
|
onMouseDown: _,
|
|
635
|
-
onMouseUp:
|
|
646
|
+
onMouseUp: f,
|
|
636
647
|
onTouchStart: v,
|
|
637
|
-
onTouchEnd:
|
|
638
|
-
children: n ? /* @__PURE__ */
|
|
648
|
+
onTouchEnd: b,
|
|
649
|
+
children: n ? /* @__PURE__ */ r(de, {}) : /* @__PURE__ */ r(ue, {})
|
|
639
650
|
}
|
|
640
651
|
);
|
|
641
652
|
}
|
|
642
|
-
function
|
|
643
|
-
const { sendMessage: e, isConnecting: t } =
|
|
653
|
+
function me() {
|
|
654
|
+
const { sendMessage: e, isConnecting: t } = T(), { chatbot: o } = j(), [n, s] = R(""), [c, i] = R(!1), a = A(null), _ = y(() => t || !n, [t, n]), f = y(
|
|
644
655
|
() => ({
|
|
645
656
|
maxWidth: (o == null ? void 0 : o.contentMaxWidth) ?? "1200px"
|
|
646
657
|
}),
|
|
@@ -648,23 +659,23 @@ function he() {
|
|
|
648
659
|
), v = g(
|
|
649
660
|
(d) => {
|
|
650
661
|
const h = d.target, p = h.value;
|
|
651
|
-
h.style.height = "36px", p && (h.style.height = `${h.scrollHeight}px`),
|
|
662
|
+
h.style.height = "36px", p && (h.style.height = `${h.scrollHeight}px`), s(d.target.value);
|
|
652
663
|
},
|
|
653
664
|
[]
|
|
654
|
-
),
|
|
655
|
-
!c && !t && (e == null || e(n),
|
|
665
|
+
), b = g(() => {
|
|
666
|
+
!c && !t && (e == null || e(n), s(""), a.current && (a.current.style.height = "36px"));
|
|
656
667
|
}, [c, t, e, n]), l = g(
|
|
657
668
|
(d) => {
|
|
658
669
|
if (d.key === "Enter" && !c && !t) {
|
|
659
|
-
e == null || e(n),
|
|
670
|
+
e == null || e(n), s("");
|
|
660
671
|
const h = d.target;
|
|
661
672
|
h.style.height = "36px";
|
|
662
673
|
}
|
|
663
674
|
},
|
|
664
675
|
[c, t, e, n]
|
|
665
676
|
);
|
|
666
|
-
return /* @__PURE__ */
|
|
667
|
-
/* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ r("div", { className: S.chatbot_footer, children: /* @__PURE__ */ m("div", { className: S.chatbot_footer__content, style: f, children: [
|
|
678
|
+
/* @__PURE__ */ r(
|
|
668
679
|
"textarea",
|
|
669
680
|
{
|
|
670
681
|
ref: a,
|
|
@@ -679,22 +690,22 @@ function he() {
|
|
|
679
690
|
onCompositionEnd: () => i(!1)
|
|
680
691
|
}
|
|
681
692
|
),
|
|
682
|
-
n ? /* @__PURE__ */
|
|
693
|
+
n ? /* @__PURE__ */ r(
|
|
683
694
|
"button",
|
|
684
695
|
{
|
|
685
|
-
className:
|
|
696
|
+
className: w(
|
|
686
697
|
S.chatbot_submit_button,
|
|
687
698
|
_ && S.chatbot_submit_button__disabled
|
|
688
699
|
),
|
|
689
700
|
disabled: _,
|
|
690
|
-
onClick:
|
|
691
|
-
children: /* @__PURE__ */
|
|
701
|
+
onClick: b,
|
|
702
|
+
children: /* @__PURE__ */ r(_e, {})
|
|
692
703
|
}
|
|
693
|
-
) : /* @__PURE__ */
|
|
694
|
-
|
|
704
|
+
) : /* @__PURE__ */ r(
|
|
705
|
+
he,
|
|
695
706
|
{
|
|
696
|
-
setValue:
|
|
697
|
-
className:
|
|
707
|
+
setValue: s,
|
|
708
|
+
className: w(
|
|
698
709
|
S.chatbot_submit_button,
|
|
699
710
|
t && S.chatbot_submit_button__disabled
|
|
700
711
|
)
|
|
@@ -702,48 +713,48 @@ function he() {
|
|
|
702
713
|
)
|
|
703
714
|
] }) });
|
|
704
715
|
}
|
|
705
|
-
const
|
|
706
|
-
chatbot_root:
|
|
707
|
-
chatbot_root__fullScreen:
|
|
716
|
+
const ge = "_chatbot_root_od4qx_1", be = "_chatbot_root__fullScreen_od4qx_126", et = {
|
|
717
|
+
chatbot_root: ge,
|
|
718
|
+
chatbot_root__fullScreen: be
|
|
708
719
|
};
|
|
709
|
-
function
|
|
720
|
+
function ve(e) {
|
|
710
721
|
const {
|
|
711
722
|
title: t,
|
|
712
723
|
theme: o,
|
|
713
724
|
config: n,
|
|
714
|
-
customChannelId:
|
|
725
|
+
customChannelId: s,
|
|
715
726
|
initMessages: c,
|
|
716
727
|
debugMode: i = !1,
|
|
717
728
|
fullScreen: a = !1,
|
|
718
729
|
avatar: _,
|
|
719
|
-
botTypingPlaceholder:
|
|
730
|
+
botTypingPlaceholder: f,
|
|
720
731
|
onReset: v,
|
|
721
|
-
onClose:
|
|
732
|
+
onClose: b
|
|
722
733
|
} = e;
|
|
723
|
-
return /* @__PURE__ */
|
|
724
|
-
|
|
734
|
+
return /* @__PURE__ */ r(mt, { fullScreen: a, theme: o, children: /* @__PURE__ */ m(
|
|
735
|
+
pt,
|
|
725
736
|
{
|
|
726
|
-
className:
|
|
727
|
-
|
|
728
|
-
a &&
|
|
737
|
+
className: w(
|
|
738
|
+
et.chatbot_root,
|
|
739
|
+
a && et.chatbot_root__fullScreen
|
|
729
740
|
),
|
|
730
741
|
avatar: _,
|
|
731
742
|
config: n,
|
|
732
|
-
customChannelId:
|
|
743
|
+
customChannelId: s,
|
|
733
744
|
initMessages: c,
|
|
734
|
-
botTypingPlaceholder:
|
|
745
|
+
botTypingPlaceholder: f,
|
|
735
746
|
options: { showDebugMessage: i },
|
|
736
747
|
children: [
|
|
737
|
-
/* @__PURE__ */
|
|
738
|
-
/* @__PURE__ */
|
|
739
|
-
/* @__PURE__ */
|
|
748
|
+
/* @__PURE__ */ r(Mt, { title: t, onReset: v, onClose: b }),
|
|
749
|
+
/* @__PURE__ */ r(re, {}),
|
|
750
|
+
/* @__PURE__ */ r(me, {})
|
|
740
751
|
]
|
|
741
752
|
}
|
|
742
753
|
) });
|
|
743
754
|
}
|
|
744
755
|
export {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
756
|
+
ve as Chatbot,
|
|
757
|
+
gt as useAsgardServiceClient,
|
|
758
|
+
bt as useChannel,
|
|
759
|
+
ft as useDebounce
|
|
749
760
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
._chatbot_header_cqlve_1 ._chatbot_header__content_cqlve_1{margin:0 auto;max-width:1200px;padding:var(--asg-spacing-4);display:flex;justify-content:space-between}._chatbot_header__title_cqlve_9{display:flex;flex-direction:row;align-items:center;gap:var(--asg-spacing-2)}._chatbot_header__title_cqlve_9>h4{margin:0;color:#fff}._chatbot_header__extra_cqlve_20{display:flex;flex-direction:row;align-items:center;gap:var(--asg-spacing-3)}._chatbot_header__extra_cqlve_20>div{width:24px;height:24px;display:flex;justify-content:center;align-items:center}._chatbot_header__extra_cqlve_20>div>svg{width:15px;height:15px;cursor:pointer}._chatbot_header__extra_cqlve_20>div>svg:hover{opacity:.5}._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}.
|
|
1
|
+
._chatbot_header_cqlve_1 ._chatbot_header__content_cqlve_1{margin:0 auto;max-width:1200px;padding:var(--asg-spacing-4);display:flex;justify-content:space-between}._chatbot_header__title_cqlve_9{display:flex;flex-direction:row;align-items:center;gap:var(--asg-spacing-2)}._chatbot_header__title_cqlve_9>h4{margin:0;color:#fff}._chatbot_header__extra_cqlve_20{display:flex;flex-direction:row;align-items:center;gap:var(--asg-spacing-3)}._chatbot_header__extra_cqlve_20>div{width:24px;height:24px;display:flex;justify-content:center;align-items:center}._chatbot_header__extra_cqlve_20>div>svg{width:15px;height:15px;cursor:pointer}._chatbot_header__extra_cqlve_20>div>svg:hover{opacity:.5}._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_k5fud_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}._hint_root_k5fud_1._hint_root__error_k5fud_13{color:var(--asg-color-error)}._time_k5fud_17{font-size:12px;color:#8c8c8c}._chatbot_footer_1uvgs_1 ._chatbot_footer__content_1uvgs_1{display:grid;align-items:flex-end;grid-template-columns:auto 24px;margin:0 auto;max-width:1200px;padding:var(--asg-spacing-3) var(--asg-spacing-4);gap:var(--asg-spacing-2)}._chatbot_textarea_1uvgs_11{font:inherit;font-size:16px;height:36px;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_submit_button_1uvgs_26{font:inherit;width:24px;height:100%;max-height:38px;display:flex;justify-content:center;align-items:center;font-size:16px;border:none;background:transparent;border-radius:50%;color:#fff;cursor:pointer}._chatbot_submit_button_1uvgs_26>svg{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;width:auto;min-width:16px;height:60%;max-height:38px;min-height:16px}._chatbot_submit_button_1uvgs_26._chatbot_submit_button__disabled_1uvgs_51>svg>path{fill:#8c8c8c}._chatbot_root_od4qx_1{--asg-color-blue-1: #edf0fd;--asg-color-blue-2: #d3dbfa;--asg-color-blue-3: #b0bef6;--asg-color-blue-4: #6882ef;--asg-color-blue-5: #8b9ff2;--asg-color-blue-6: #4767eb;--asg-color-blue-7: #3c58c8;--asg-color-blue-8: #3249a7;--asg-color-blue-9: #283b86;--asg-color-blue-10: #202e6a;--asg-color-orange-1: #ffeded;--asg-color-orange-2: #ffd4d5;--asg-color-orange-3: #ffb2b3;--asg-color-orange-4: #ff8f90;--asg-color-orange-5: #ff6d6f;--asg-color-orange-6: #ff4d4f;--asg-color-orange-7: #d94143;--asg-color-orange-8: #b53738;--asg-color-orange-9: #912c2d;--asg-color-orange-10: #732324;--asg-color-green-1: #eef9e8;--asg-color-green-2: #d5f1c8;--asg-color-green-3: #b5e69d;--asg-color-green-4: #92da6f;--asg-color-green-5: #71cf43;--asg-color-green-6: #52c41a;--asg-color-green-7: #46a716;--asg-color-green-8: #3a8b12;--asg-color-green-9: #2f700f;--asg-color-green-10: #25580c;--asg-color-yellow-1: #fef7eb;--asg-color-yellow-2: #fdebcf;--asg-color-yellow-3: #fcdba9;--asg-color-yellow-4: #facb82;--asg-color-yellow-5: #f8bb5c;--asg-color-yellow-6: #f7ac38;--asg-color-yellow-7: #d29230;--asg-color-yellow-8: #af7a28;--asg-color-yellow-9: #8d6220;--asg-color-yellow-10: #6f4d19;--asg-color-grey-1: #f3f3f3;--asg-color-grey-2: #e2e2e2;--asg-color-grey-3: #cbcbcb;--asg-color-grey-4: #b2b2b2;--asg-color-grey-5: #9b9b9b;--asg-color-grey-6: #585858;--asg-color-grey-7: #717171;--asg-color-grey-8: #5e5e5e;--asg-color-grey-9: #4c4c4c;--asg-color-grey-10: #3c3c3c;--asg-color-primary: #4767eb;--asg-color-primary-light: #8b9ff2;--asg-color-primary-dark: #3249a7;--asg-color-primary-on-primary: #ffffff;--asg-color-primary-hover-bg: rgba(139, 159, 242, .15);--asg-color-primary-selected-bg: rgba(71, 103, 235, .2);--asg-color-secondary: #585858;--asg-color-secondary-light: #b2b2b2;--asg-color-secondary-dark: #4c4c4c;--asg-color-secondary-on-secondary: #ffffff;--asg-color-secondary-hover-bg: rgba(178, 178, 178, .15);--asg-color-secondary-selected-bg: rgba(88, 88, 88, .2);--asg-color-error: #ff4d4f;--asg-color-error-light: #ff6d6f;--asg-color-error-dark: #d94143;--asg-color-error-on-error: #ffffff;--asg-color-error-hover-bg: rgba(255, 109, 111, .15);--asg-color-error-selected-bg: rgba(255, 77, 79, .2);--asg-color-warning: #f7ac38;--asg-color-warning-light: #f8bb5c;--asg-color-warning-dark: #af7a28;--asg-color-warning-on-warning: #ffffff;--asg-color-warning-hover-bg: rgba(248, 187, 92, .15);--asg-color-warning-selected-bg: rgba(247, 172, 56, .2);--asg-color-success: #52c41a;--asg-color-success-light: #71cf43;--asg-color-success-dark: #3a8b12;--asg-color-success-on-success: #ffffff;--asg-color-success-hover-bg: rgba(113, 207, 67, .15);--asg-color-success-selected-bg: rgba(82, 196, 26, .2);--asg-color-action-active: #ffffff;--asg-color-action-inactive: #8c8c8c;--asg-color-action-disabled: #595959;--asg-color-action-disabled-bg: #393939;--asg-color-text-primary: #ffffff;--asg-color-text-secondary: #8c8c8c;--asg-color-text-disabled: #595959;--asg-color-bg: #141414;--asg-color-surface: #1f1f1f;--asg-color-divider: #333333;--asg-color-border: #434343;--asg-color-overlay-dark: rgba(0, 0, 0, .5);--asg-color-overlay-light: rgba(31, 31, 31, .9);--asg-radius-none: 0px;--asg-radius-xxs: 2px;--asg-radius-xs: 4px;--asg-radius-s: 6px;--asg-radius-md: 8px;--asg-radius-lg: 10px;--asg-radius-xl: 12px;--asg-radius-2xl: 16px;--asg-radius-3xl: 20px;--asg-radius-4xl: 24px;--asg-spacing-1: 4px;--asg-spacing-2: 8px;--asg-spacing-3: 12px;--asg-spacing-4: 16px;--asg-spacing-5: 24px;--asg-spacing-6: 32px;--asg-spacing-7: 40px;--asg-spacing-8: 48px;--asg-spacing-9: 64px;--asg-spacing-10: 96px;--asg-spacing-11: 160px;width:100%;height:100%;font-size:15px;display:grid;grid-template-rows:max-content auto max-content}._chatbot_root_od4qx_1 *{box-sizing:border-box}._chatbot_root__fullScreen_od4qx_126{position:fixed;top:0;left:0;right:0;bottom:0;z-index:9999}
|