@arcai/chatbot 1.0.0-beta.1 → 1.0.1
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/WalletBot.d.ts +14 -0
- package/dist/WalletBot.js +60 -0
- package/dist/chatbot.min.js +6126 -8
- package/dist/index.d.ts +8 -24
- package/dist/index.js +108 -96
- package/dist/styles.d.ts +1 -1
- package/dist/styles.js +1 -0
- package/dist/types.d.ts +14 -0
- package/package.json +7 -4
package/dist/index.d.ts
CHANGED
@@ -1,25 +1,9 @@
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
2
|
-
import type { ChatbotConfig
|
3
|
-
export declare
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
constructor(config: ChatbotConfig);
|
11
|
-
private injectStyles;
|
12
|
-
private createContainer;
|
13
|
-
private createChat;
|
14
|
-
private sendMessage;
|
15
|
-
private renderMessage;
|
16
|
-
private showThought;
|
17
|
-
private startThoughtCycle;
|
18
|
-
private adjustColor;
|
19
|
-
private defaultMessageHandler;
|
20
|
-
open(): void;
|
21
|
-
close(): void;
|
22
|
-
toggle(): void;
|
23
|
-
destroy(): void;
|
24
|
-
}
|
25
|
-
export type { ChatbotConfig, Message };
|
2
|
+
import type { ChatbotConfig } from './types';
|
3
|
+
export declare function Chatbot(config: ChatbotConfig): {
|
4
|
+
open: () => void;
|
5
|
+
close: () => void;
|
6
|
+
toggle: () => void;
|
7
|
+
destroy: () => void;
|
8
|
+
on: <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
9
|
+
};
|
package/dist/index.js
CHANGED
@@ -1,87 +1,90 @@
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
2
2
|
import { defaultStyles } from './styles';
|
3
3
|
import { botIcon, sendIcon, closeIcon } from './icons';
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
4
|
+
import { WalletBot } from './WalletBot'; // Import the WalletBot class
|
5
|
+
export function Chatbot(config) {
|
6
|
+
const emitter = new EventEmitter();
|
7
|
+
const chatbotConfig = {
|
8
|
+
...config,
|
9
|
+
botIcon: config.botIcon || botIcon,
|
10
|
+
position: config.position || 'bottom-right',
|
11
|
+
primaryColor: config.primaryColor || '#2563eb',
|
12
|
+
textColor: config.textColor || '#1e293b',
|
13
|
+
bgImage: config.bgImage || '',
|
14
|
+
opacity: config.opacity || 100,
|
15
|
+
glassmorphism: config.glassmorphism || false,
|
16
|
+
floatAnimation: config.floatAnimation || 'float-up-down',
|
17
|
+
showAvatar: config.showAvatar ?? true,
|
18
|
+
showThoughts: config.showThoughts ?? true,
|
19
|
+
thoughtInterval: config.thoughtInterval || 8,
|
20
|
+
customThoughts: config.customThoughts || [
|
21
|
+
"I'm here to help!",
|
22
|
+
"Have any questions?",
|
23
|
+
"Need assistance?",
|
24
|
+
],
|
25
|
+
onMessage: config.onMessage || defaultMessageHandler,
|
26
|
+
};
|
27
|
+
let isOpen = false;
|
28
|
+
let thoughtTimeout;
|
29
|
+
let messages = [];
|
30
|
+
injectStyles(chatbotConfig);
|
31
|
+
const container = createContainer();
|
32
|
+
const chat = createChat();
|
33
|
+
document.body.appendChild(container);
|
34
|
+
if (chatbotConfig.showThoughts) {
|
35
|
+
startThoughtCycle();
|
35
36
|
}
|
36
|
-
|
37
|
+
// Initialize WalletBot
|
38
|
+
const walletBot = WalletBot.getInstance('c43a2662a817d481c4fdb60e602950ba');
|
39
|
+
function injectStyles(config) {
|
37
40
|
const style = document.createElement('style');
|
38
41
|
style.textContent = defaultStyles;
|
39
42
|
document.head.appendChild(style);
|
40
|
-
// Inject custom CSS variables
|
41
43
|
const customStyles = document.createElement('style');
|
42
44
|
customStyles.textContent = `
|
43
45
|
:root {
|
44
|
-
--arcai-primary-color: ${
|
45
|
-
--arcai-primary-color-dark: ${
|
46
|
+
--arcai-primary-color: ${config.primaryColor};
|
47
|
+
--arcai-primary-color-dark: ${adjustColor(config.primaryColor, -20)};
|
46
48
|
}
|
47
49
|
`;
|
48
50
|
document.head.appendChild(customStyles);
|
49
51
|
}
|
50
|
-
createContainer() {
|
52
|
+
function createContainer() {
|
51
53
|
const container = document.createElement('div');
|
52
|
-
container.className = `arcai-widget ${
|
54
|
+
container.className = `arcai-widget ${chatbotConfig.position}`;
|
53
55
|
const launcher = document.createElement('button');
|
54
|
-
launcher.className = `arcai-launcher ${
|
55
|
-
launcher.
|
56
|
-
|
56
|
+
launcher.className = `arcai-launcher ${chatbotConfig.floatAnimation}`;
|
57
|
+
launcher.onclick = toggle;
|
58
|
+
const launcherIcon = document.createElement('img');
|
59
|
+
launcherIcon.src = chatbotConfig.botIcon;
|
60
|
+
launcherIcon.alt = 'Chatbot Icon';
|
61
|
+
launcherIcon.className = 'arcai-launcher-icon';
|
62
|
+
launcher.appendChild(launcherIcon);
|
57
63
|
container.appendChild(launcher);
|
58
64
|
return container;
|
59
65
|
}
|
60
|
-
createChat() {
|
66
|
+
function createChat() {
|
61
67
|
const chat = document.createElement('div');
|
62
68
|
chat.className = 'arcai-chat';
|
63
|
-
// Header
|
64
69
|
const header = document.createElement('div');
|
65
|
-
header.className = `arcai-header ${
|
66
|
-
if (
|
67
|
-
header.style.backgroundImage = `url(${
|
70
|
+
header.className = `arcai-header ${chatbotConfig.glassmorphism ? 'glassmorphism' : ''}`;
|
71
|
+
if (chatbotConfig.bgImage) {
|
72
|
+
header.style.backgroundImage = `url(${chatbotConfig.bgImage})`;
|
68
73
|
header.style.backgroundSize = 'cover';
|
69
74
|
header.style.backgroundPosition = 'center';
|
70
|
-
header.style.backgroundColor = `rgba(37, 99, 235, ${
|
75
|
+
header.style.backgroundColor = `rgba(37, 99, 235, ${chatbotConfig.opacity / 100})`;
|
71
76
|
}
|
72
|
-
const title = document.createElement('
|
77
|
+
const title = document.createElement('img');
|
73
78
|
title.className = 'arcai-title';
|
74
|
-
title.
|
79
|
+
title.src = chatbotConfig.botIcon;
|
75
80
|
const closeBtn = document.createElement('button');
|
76
81
|
closeBtn.className = 'arcai-close';
|
77
82
|
closeBtn.innerHTML = closeIcon;
|
78
|
-
closeBtn.onclick =
|
83
|
+
closeBtn.onclick = close;
|
79
84
|
header.appendChild(title);
|
80
85
|
header.appendChild(closeBtn);
|
81
|
-
|
82
|
-
|
83
|
-
messages.className = 'arcai-messages';
|
84
|
-
// Input
|
86
|
+
const messagesContainer = document.createElement('div');
|
87
|
+
messagesContainer.className = 'arcai-messages';
|
85
88
|
const input = document.createElement('div');
|
86
89
|
input.className = 'arcai-input';
|
87
90
|
const form = document.createElement('form');
|
@@ -90,7 +93,7 @@ export class Chatbot extends EventEmitter {
|
|
90
93
|
e.preventDefault();
|
91
94
|
const inputField = form.querySelector('input');
|
92
95
|
if (inputField?.value.trim()) {
|
93
|
-
|
96
|
+
sendMessage(inputField.value);
|
94
97
|
inputField.value = '';
|
95
98
|
}
|
96
99
|
};
|
@@ -105,45 +108,49 @@ export class Chatbot extends EventEmitter {
|
|
105
108
|
form.appendChild(sendBtn);
|
106
109
|
input.appendChild(form);
|
107
110
|
chat.appendChild(header);
|
108
|
-
chat.appendChild(
|
111
|
+
chat.appendChild(messagesContainer);
|
109
112
|
chat.appendChild(input);
|
110
|
-
|
113
|
+
container.appendChild(chat);
|
111
114
|
return chat;
|
112
115
|
}
|
113
|
-
async sendMessage(content) {
|
116
|
+
async function sendMessage(content) {
|
114
117
|
const message = {
|
115
118
|
id: Math.random().toString(36).substr(2, 9),
|
116
119
|
role: 'user',
|
117
120
|
content,
|
118
121
|
timestamp: new Date(),
|
119
122
|
};
|
120
|
-
|
121
|
-
|
123
|
+
if (!walletBot.walletState.isConnected) {
|
124
|
+
walletBot.web3Modal.open();
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
messages.push(message);
|
128
|
+
renderMessage(message);
|
122
129
|
try {
|
123
|
-
const response = await
|
130
|
+
const response = await chatbotConfig.onMessage(content);
|
124
131
|
const botMessage = {
|
125
132
|
id: Math.random().toString(36).substr(2, 9),
|
126
133
|
role: 'bot',
|
127
134
|
content: response,
|
128
135
|
timestamp: new Date(),
|
129
136
|
};
|
130
|
-
|
131
|
-
|
137
|
+
messages.push(botMessage);
|
138
|
+
renderMessage(botMessage);
|
132
139
|
}
|
133
140
|
catch (error) {
|
134
141
|
console.error('Error sending message:', error);
|
135
142
|
}
|
136
143
|
}
|
137
|
-
renderMessage(message) {
|
138
|
-
const messagesContainer =
|
144
|
+
function renderMessage(message) {
|
145
|
+
const messagesContainer = chat.querySelector('.arcai-messages');
|
139
146
|
if (!messagesContainer)
|
140
147
|
return;
|
141
148
|
const messageEl = document.createElement('div');
|
142
149
|
messageEl.className = `arcai-message ${message.role}`;
|
143
|
-
if (
|
144
|
-
const avatar = document.createElement('
|
150
|
+
if (chatbotConfig.showAvatar) {
|
151
|
+
const avatar = document.createElement('img');
|
145
152
|
avatar.className = 'arcai-avatar';
|
146
|
-
avatar.
|
153
|
+
avatar.src = chatbotConfig.botIcon;
|
147
154
|
messageEl.appendChild(avatar);
|
148
155
|
}
|
149
156
|
const bubble = document.createElement('div');
|
@@ -153,12 +160,12 @@ export class Chatbot extends EventEmitter {
|
|
153
160
|
messagesContainer.appendChild(messageEl);
|
154
161
|
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
155
162
|
}
|
156
|
-
showThought() {
|
157
|
-
const thought =
|
163
|
+
function showThought() {
|
164
|
+
const thought = chatbotConfig.customThoughts[Math.floor(Math.random() * chatbotConfig.customThoughts.length)];
|
158
165
|
const thoughtEl = document.createElement('div');
|
159
166
|
thoughtEl.className = 'arcai-thought';
|
160
167
|
thoughtEl.textContent = thought;
|
161
|
-
const launcher =
|
168
|
+
const launcher = container.querySelector('.arcai-launcher');
|
162
169
|
if (launcher) {
|
163
170
|
launcher.appendChild(thoughtEl);
|
164
171
|
setTimeout(() => {
|
@@ -166,19 +173,19 @@ export class Chatbot extends EventEmitter {
|
|
166
173
|
}, 4000);
|
167
174
|
}
|
168
175
|
}
|
169
|
-
startThoughtCycle() {
|
170
|
-
if (
|
171
|
-
clearTimeout(
|
176
|
+
function startThoughtCycle() {
|
177
|
+
if (thoughtTimeout) {
|
178
|
+
clearTimeout(thoughtTimeout);
|
172
179
|
}
|
173
180
|
const showNextThought = () => {
|
174
|
-
if (!
|
175
|
-
|
181
|
+
if (!isOpen) {
|
182
|
+
showThought();
|
176
183
|
}
|
177
|
-
|
184
|
+
thoughtTimeout = setTimeout(showNextThought, chatbotConfig.thoughtInterval * 1000);
|
178
185
|
};
|
179
186
|
setTimeout(showNextThought, 2000);
|
180
187
|
}
|
181
|
-
adjustColor(color, amount) {
|
188
|
+
function adjustColor(color, amount) {
|
182
189
|
const hex = color.replace('#', '');
|
183
190
|
const num = parseInt(hex, 16);
|
184
191
|
const r = Math.min(255, Math.max(0, (num >> 16) + amount));
|
@@ -186,29 +193,34 @@ export class Chatbot extends EventEmitter {
|
|
186
193
|
const b = Math.min(255, Math.max(0, (num & 0x0000ff) + amount));
|
187
194
|
return `#${((r << 16) | (g << 8) | b).toString(16).padStart(6, '0')}`;
|
188
195
|
}
|
189
|
-
async defaultMessageHandler(message) {
|
190
|
-
return
|
196
|
+
async function defaultMessageHandler(message) {
|
197
|
+
return message;
|
191
198
|
}
|
192
|
-
open() {
|
193
|
-
|
194
|
-
|
199
|
+
function open() {
|
200
|
+
isOpen = true;
|
201
|
+
chat.classList.add('open');
|
195
202
|
}
|
196
|
-
close() {
|
197
|
-
|
198
|
-
|
203
|
+
function close() {
|
204
|
+
isOpen = false;
|
205
|
+
chat.classList.remove('open');
|
199
206
|
}
|
200
|
-
toggle() {
|
201
|
-
|
202
|
-
this.close();
|
203
|
-
}
|
204
|
-
else {
|
205
|
-
this.open();
|
206
|
-
}
|
207
|
+
function toggle() {
|
208
|
+
isOpen ? close() : open();
|
207
209
|
}
|
208
|
-
destroy() {
|
209
|
-
if (
|
210
|
-
clearTimeout(
|
210
|
+
function destroy() {
|
211
|
+
if (thoughtTimeout) {
|
212
|
+
clearTimeout(thoughtTimeout);
|
211
213
|
}
|
212
|
-
|
214
|
+
container.remove();
|
213
215
|
}
|
216
|
+
return { open, close, toggle, destroy, on: emitter.on.bind(emitter) };
|
217
|
+
}
|
218
|
+
function sendTransactionFunction(to, amount) {
|
219
|
+
throw new Error('Function not implemented.');
|
220
|
+
}
|
221
|
+
function getBalanceFunction() {
|
222
|
+
throw new Error('Function not implemented.');
|
223
|
+
}
|
224
|
+
function disconnectWalletFunction() {
|
225
|
+
throw new Error('Function not implemented.');
|
214
226
|
}
|
package/dist/styles.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const defaultStyles = "\n/* Dark mode support */\n.arcai-widget[data-theme=\"dark\"] {\n --arcai-bg: #1a1a1a;\n --arcai-text: #ffffff;\n --arcai-border: #333333;\n}\n\n.arcai-widget[data-theme=\"light\"] {\n --arcai-bg: #ffffff;\n --arcai-text: #1a1a1a;\n --arcai-border: #e5e5e5;\n}\n\n.arcai-widget {\n position: fixed;\n z-index: 9999;\n transform: none;\n font-family: system-ui, -apple-system, sans-serif;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.arcai-widget.bottom-right {\n bottom: 20px;\n right: 20px;\n transform-origin: bottom right;\n}\n\n.arcai-widget.bottom-left {\n bottom: 20px;\n left: 20px;\n transform-origin: bottom left;\n}\n\n.arcai-widget.top-right {\n top: 20px;\n right: 20px;\n transform-origin: top right;\n}\n\n.arcai-widget.top-left {\n top: 20px;\n left: 20px;\n transform-origin: top left;\n}\n\n.arcai-widget.outside-left {\n left: -28px; /* Half of launcher width */\n top: 50%;\n transform: translateY(-50%);\n transform-origin: center left;\n}\n\n.arcai-widget.outside-left:hover {\n left: 20px;\n}\n\n.arcai-widget.outside-left .arcai-chat {\n left: 80px;\n bottom: auto;\n top: 50%;\n transform: translateY(-50%);\n}\n\n.arcai-widget.outside-right {\n right: -28px;\n top: 50%;\n transform: translateY(-50%);\n transform-origin: center right;\n}\n\n.arcai-widget.outside-right:hover {\n right: 20px;\n}\n\n.arcai-widget.outside-right .arcai-chat {\n right: 80px;\n bottom: auto;\n top: 50%;\n transform: translateY(-50%);\n}\n\n.arcai-launcher {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background: var(--arcai-primary-color, #2563eb);\n color: white;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: transform 0.2s, box-shadow 0.2s;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\n position: relative;\n z-index: 2;\n}\n\n.arcai-launcher:hover {\n transform: translateY(-2px);\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);\n}\n\n.arcai-launcher.float-up-down {\n animation: arcaiFloatUpDown 3s ease-in-out infinite;\n}\n\n.arcai-launcher.float-left-right {\n animation: arcaiFloatLeftRight 3s ease-in-out infinite;\n}\n\n.arcai-launcher.float-diagonal {\n animation: arcaiFloatDiagonal 4s ease-in-out infinite;\n}\n\n.arcai-launcher.float-circle {\n animation: arcaiFloatCircle 5s ease-in-out infinite;\n}\n\n/* Sound effect animations */\n@keyframes arcaiSoundWave {\n 0% { transform: scale(1); opacity: 0.8; }\n 100% { transform: scale(2); opacity: 0; }\n}\n\n.arcai-sound-wave {\n position: absolute;\n border: 2px solid var(--arcai-primary-color);\n width: 100%;\n height: 100%;\n border-radius: 50%;\n animation: arcaiSoundWave 1s ease-out infinite;\n}\n\n/* Typing indicator */\n.arcai-typing {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 8px;\n background: var(--arcai-bg);\n border-radius: 12px;\n margin-bottom: 8px;\n}\n\n.arcai-typing-dot {\n width: 6px;\n height: 6px;\n background: var(--arcai-primary-color);\n border-radius: 50%;\n animation: arcaiDotPulse 1.4s infinite;\n}\n\n.arcai-typing-dot:nth-child(2) { animation-delay: 0.2s; }\n.arcai-typing-dot:nth-child(3) { animation-delay: 0.4s; }\n\n@keyframes arcaiDotPulse {\n 0%, 60%, 100% { transform: scale(1); opacity: 1; }\n 30% { transform: scale(1.2); opacity: 0.4; }\n}\n\n/* Suggested messages */\n.arcai-suggestions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n.arcai-suggestion {\n padding: 6px 12px;\n background: var(--arcai-primary-color);\n color: white;\n border-radius: 16px;\n font-size: 14px;\n cursor: pointer;\n transition: all 0.2s;\n border: none;\n}\n\n.arcai-suggestion:hover {\n transform: translateY(-1px);\n filter: brightness(1.1);\n}\n\n/* Attachment handling */\n.arcai-attachments {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 8px;\n}\n\n.arcai-attachment {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 4px 8px;\n background: var(--arcai-bg);\n border-radius: 4px;\n font-size: 12px;\n}\n\n.arcai-attachment-remove {\n cursor: pointer;\n opacity: 0.6;\n transition: opacity 0.2s;\n}\n\n.arcai-attachment-remove:hover {\n opacity: 1;\n}\n\n.arcai-chat {\n position: fixed;\n width: 380px;\n height: 600px;\n background: white;\n border-radius: 12px;\n box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n opacity: 0;\n transform: translateY(20px);\n transition: opacity 0.3s, transform 0.3s;\n z-index: 1;\n}\n\n.arcai-chat.open {\n opacity: 1;\n transform: translateY(0);\n}\n\n.arcai-header {\n padding: 16px;\n background: var(--arcai-primary-color, #2563eb);\n color: white;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n.arcai-header.glassmorphism {\n backdrop-filter: blur(8px);\n background: rgba(37, 99, 235, 0.8);\n}\n\n.arcai-title {\n display: flex;\n align-items: center;\n gap: 8px;\n font-weight: 500;\n}\n\n.arcai-close {\n background: none;\n border: none;\n color: white;\n cursor: pointer;\n padding: 4px;\n border-radius: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.arcai-close:hover {\n background: rgba(255, 255, 255, 0.1);\n}\n\n.arcai-messages {\n flex: 1;\n overflow-y: auto;\n padding: 16px;\n background: #f8fafc;\n}\n\n.arcai-message {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n margin-bottom: 16px;\n opacity: 0;\n transform: translateY(10px);\n animation: arcaiMessageSlideUp 0.3s forwards;\n}\n\n.arcai-message.user {\n flex-direction: row-reverse;\n}\n\n.arcai-avatar {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n background: #e2e8f0;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.arcai-bubble {\n background: white;\n padding: 12px 16px;\n border-radius: 12px;\n max-width: 70%;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);\n}\n\n.arcai-message.user .arcai-bubble {\n background: var(--arcai-primary-color, #2563eb);\n color: white;\n}\n\n.arcai-input {\n padding: 16px;\n background: white;\n border-top: 1px solid #e2e8f0;\n}\n\n.arcai-input-form {\n display: flex;\n gap: 8px;\n}\n\n.arcai-input-field {\n flex: 1;\n padding: 8px 16px;\n border: 1px solid #e2e8f0;\n border-radius: 24px;\n outline: none;\n font-size: 14px;\n}\n\n.arcai-input-field:focus {\n border-color: var(--arcai-primary-color, #2563eb);\n box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);\n}\n\n.arcai-send {\n width: 36px;\n height: 36px;\n border-radius: 50%;\n background: var(--arcai-primary-color, #2563eb);\n color: white;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background-color 0.2s;\n}\n\n.arcai-send:hover {\n background: var(--arcai-primary-color-dark, #1d4ed8);\n}\n\n.arcai-thought {\n position: absolute;\n bottom: 100%;\n right: 0;\n margin-bottom: 12px;\n background: white;\n padding: 12px 16px;\n border-radius: 12px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\n max-width: 240px;\n opacity: 0;\n transform: translateY(10px);\n animation: arcaiThoughtBubble 4s ease-in-out forwards;\n}\n\n.arcai-thought::after {\n content: '';\n position: absolute;\n bottom: -6px;\n right: 24px;\n width: 12px;\n height: 12px;\n background: white;\n transform: rotate(45deg);\n}\n\n@keyframes arcaiFloatUpDown {\n 0%, 100% { transform: translateY(0); }\n 50% { transform: translateY(-10px); }\n}\n\n@keyframes arcaiFloatLeftRight {\n 0%, 100% { transform: translateX(0); }\n 50% { transform: translateX(10px); }\n}\n\n@keyframes arcaiFloatDiagonal {\n 0%, 100% { transform: translate(0, 0); }\n 50% { transform: translate(5px, -5px); }\n}\n\n@keyframes arcaiFloatCircle {\n 0% { transform: translate(0, 0); }\n 25% { transform: translate(5px, -5px); }\n 50% { transform: translate(10px, 0); }\n 75% { transform: translate(5px, 5px); }\n 100% { transform: translate(0, 0); }\n}\n\n@keyframes arcaiMessageSlideUp {\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes arcaiThoughtBubble {\n 0% {\n opacity: 0;\n transform: scale(0.8) translateY(10px);\n }\n 10% {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n 90% {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n 100% {\n opacity: 0;\n transform: scale(0.8) translateY(-10px);\n }\n}";
|
1
|
+
export declare const defaultStyles = "\n/* Dark mode support */\n.arcai-widget[data-theme=\"dark\"] {\n --arcai-bg: #1a1a1a;\n --arcai-text: #ffffff;\n --arcai-border: #333333;\n}\n\n.arcai-widget[data-theme=\"light\"] {\n --arcai-bg: #ffffff;\n --arcai-text: #1a1a1a;\n --arcai-border: #e5e5e5;\n}\n\n.arcai-widget {\n position: fixed;\n z-index: 9999;\n transform: none;\n font-family: system-ui, -apple-system, sans-serif;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.arcai-widget.bottom-right {\n bottom: 20px;\n right: 20px;\n transform-origin: bottom right;\n}\n\n.arcai-widget.bottom-left {\n bottom: 20px;\n left: 20px;\n transform-origin: bottom left;\n}\n\n.arcai-widget.top-right {\n top: 20px;\n right: 20px;\n transform-origin: top right;\n}\n\n.arcai-widget.top-left {\n top: 20px;\n left: 20px;\n transform-origin: top left;\n}\n\n.arcai-widget.outside-left {\n left: -28px; /* Half of launcher width */\n top: 50%;\n transform: translateY(-50%);\n transform-origin: center left;\n}\n\n.arcai-widget.outside-left:hover {\n left: 20px;\n}\n\n.arcai-widget.outside-left .arcai-chat {\n left: 80px;\n bottom: auto;\n top: 50%;\n transform: translateY(-50%);\n}\n\n.arcai-widget.outside-right {\n right: -28px;\n top: 50%;\n transform: translateY(-50%);\n transform-origin: center right;\n}\n\n.arcai-widget.outside-right:hover {\n right: 20px;\n}\n\n.arcai-widget.outside-right .arcai-chat {\n right: 80px;\n bottom: auto;\n top: 50%;\n transform: translateY(-50%);\n}\n\n.arcai-launcher {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background: var(--arcai-primary-color, #2563eb);\n color: white;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: transform 0.2s, box-shadow 0.2s;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\n position: relative;\n z-index: 2;\n}\n\n.arcai-launcher:hover {\n transform: translateY(-2px);\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);\n}\n\n.arcai-launcher.float-up-down {\n animation: arcaiFloatUpDown 3s ease-in-out infinite;\n}\n\n.arcai-launcher.float-left-right {\n animation: arcaiFloatLeftRight 3s ease-in-out infinite;\n}\n\n.arcai-launcher.float-diagonal {\n animation: arcaiFloatDiagonal 4s ease-in-out infinite;\n}\n\n.arcai-launcher.float-circle {\n animation: arcaiFloatCircle 5s ease-in-out infinite;\n}\n\n/* Sound effect animations */\n@keyframes arcaiSoundWave {\n 0% { transform: scale(1); opacity: 0.8; }\n 100% { transform: scale(2); opacity: 0; }\n}\n\n.arcai-sound-wave {\n position: absolute;\n border: 2px solid var(--arcai-primary-color);\n width: 100%;\n height: 100%;\n border-radius: 50%;\n animation: arcaiSoundWave 1s ease-out infinite;\n}\n\n/* Typing indicator */\n.arcai-typing {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 8px;\n background: var(--arcai-bg);\n border-radius: 12px;\n margin-bottom: 8px;\n}\n\n.arcai-typing-dot {\n width: 6px;\n height: 6px;\n background: var(--arcai-primary-color);\n border-radius: 50%;\n animation: arcaiDotPulse 1.4s infinite;\n}\n\n.arcai-typing-dot:nth-child(2) { animation-delay: 0.2s; }\n.arcai-typing-dot:nth-child(3) { animation-delay: 0.4s; }\n\n@keyframes arcaiDotPulse {\n 0%, 60%, 100% { transform: scale(1); opacity: 1; }\n 30% { transform: scale(1.2); opacity: 0.4; }\n}\n\n/* Suggested messages */\n.arcai-suggestions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n.arcai-suggestion {\n padding: 6px 12px;\n background: var(--arcai-primary-color);\n color: white;\n border-radius: 16px;\n font-size: 14px;\n cursor: pointer;\n transition: all 0.2s;\n border: none;\n}\n\n.arcai-suggestion:hover {\n transform: translateY(-1px);\n filter: brightness(1.1);\n}\n\n/* Attachment handling */\n.arcai-attachments {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 8px;\n}\n\n.arcai-attachment {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 4px 8px;\n background: var(--arcai-bg);\n border-radius: 4px;\n font-size: 12px;\n}\n\n.arcai-attachment-remove {\n cursor: pointer;\n opacity: 0.6;\n transition: opacity 0.2s;\n}\n\n.arcai-attachment-remove:hover {\n opacity: 1;\n}\n\n.arcai-chat {\n position: fixed;\n width: 380px;\n height: 600px;\n background: white;\n border-radius: 12px;\n box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n opacity: 0;\n transform: translateY(20px);\n transition: opacity 0.3s, transform 0.3s;\n z-index: 1;\n}\n\n.arcai-chat.open {\n opacity: 1;\n transform: translateY(0);\n}\n\n.arcai-header {\n padding: 16px;\n background: var(--arcai-primary-color, #2563eb);\n color: white;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n.arcai-header.glassmorphism {\n backdrop-filter: blur(8px);\n background: rgba(37, 99, 235, 0.8);\n}\n\n.arcai-title {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 22px;\n font-weight: 500;\n}\n\n.arcai-close {\n background: none;\n border: none;\n color: white;\n cursor: pointer;\n padding: 4px;\n border-radius: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.arcai-close:hover {\n background: rgba(255, 255, 255, 0.1);\n}\n\n.arcai-messages {\n flex: 1;\n overflow-y: auto;\n padding: 16px;\n background: #f8fafc;\n}\n\n.arcai-message {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n margin-bottom: 16px;\n opacity: 0;\n transform: translateY(10px);\n animation: arcaiMessageSlideUp 0.3s forwards;\n}\n\n.arcai-message.user {\n flex-direction: row-reverse;\n}\n\n.arcai-avatar {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n background: #e2e8f0;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.arcai-bubble {\n background: white;\n padding: 12px 16px;\n border-radius: 12px;\n max-width: 70%;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);\n}\n\n.arcai-message.user .arcai-bubble {\n background: var(--arcai-primary-color, #2563eb);\n color: white;\n}\n\n.arcai-input {\n padding: 16px;\n background: white;\n border-top: 1px solid #e2e8f0;\n}\n\n.arcai-input-form {\n display: flex;\n gap: 8px;\n}\n\n.arcai-input-field {\n flex: 1;\n padding: 8px 16px;\n border: 1px solid #e2e8f0;\n border-radius: 24px;\n outline: none;\n font-size: 14px;\n}\n\n.arcai-input-field:focus {\n border-color: var(--arcai-primary-color, #2563eb);\n box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);\n}\n\n.arcai-send {\n width: 36px;\n height: 36px;\n border-radius: 50%;\n background: var(--arcai-primary-color, #2563eb);\n color: white;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background-color 0.2s;\n}\n\n.arcai-send:hover {\n background: var(--arcai-primary-color-dark, #1d4ed8);\n}\n\n.arcai-thought {\n position: absolute;\n bottom: 100%;\n right: 0;\n margin-bottom: 12px;\n background: white;\n padding: 12px 16px;\n border-radius: 12px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\n max-width: 240px;\n opacity: 0;\n transform: translateY(10px);\n animation: arcaiThoughtBubble 4s ease-in-out forwards;\n}\n\n.arcai-thought::after {\n content: '';\n position: absolute;\n bottom: -6px;\n right: 24px;\n width: 12px;\n height: 12px;\n background: white;\n transform: rotate(45deg);\n}\n\n@keyframes arcaiFloatUpDown {\n 0%, 100% { transform: translateY(0); }\n 50% { transform: translateY(-10px); }\n}\n\n@keyframes arcaiFloatLeftRight {\n 0%, 100% { transform: translateX(0); }\n 50% { transform: translateX(10px); }\n}\n\n@keyframes arcaiFloatDiagonal {\n 0%, 100% { transform: translate(0, 0); }\n 50% { transform: translate(5px, -5px); }\n}\n\n@keyframes arcaiFloatCircle {\n 0% { transform: translate(0, 0); }\n 25% { transform: translate(5px, -5px); }\n 50% { transform: translate(10px, 0); }\n 75% { transform: translate(5px, 5px); }\n 100% { transform: translate(0, 0); }\n}\n\n@keyframes arcaiMessageSlideUp {\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes arcaiThoughtBubble {\n 0% {\n opacity: 0;\n transform: scale(0.8) translateY(10px);\n }\n 10% {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n 90% {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n 100% {\n opacity: 0;\n transform: scale(0.8) translateY(-10px);\n }\n}";
|
package/dist/styles.js
CHANGED
package/dist/types.d.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
export interface ChatbotConfig {
|
2
|
+
botIcon: string;
|
2
3
|
apiKey: string;
|
4
|
+
icon: string;
|
3
5
|
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'outside-left' | 'outside-right';
|
4
6
|
theme?: Partial<{
|
5
7
|
mode: 'light' | 'dark';
|
@@ -43,6 +45,18 @@ export interface ChatbotConfig {
|
|
43
45
|
onAttachment?: (file: File) => Promise<string>;
|
44
46
|
onError?: (error: Error) => void;
|
45
47
|
}
|
48
|
+
export interface WalletState {
|
49
|
+
address: string | null;
|
50
|
+
isConnecting: boolean;
|
51
|
+
isConnected: boolean;
|
52
|
+
error: Error | null;
|
53
|
+
}
|
54
|
+
export interface WalletHandlers {
|
55
|
+
connect: () => Promise<void>;
|
56
|
+
disconnect: () => Promise<void>;
|
57
|
+
getBalance: () => Promise<string>;
|
58
|
+
sendTransaction: (to: string, amount: string) => Promise<string>;
|
59
|
+
}
|
46
60
|
export interface Message {
|
47
61
|
id: string;
|
48
62
|
role: 'user' | 'bot';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcai/chatbot",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1",
|
4
4
|
"description": "A customizable chatbot widget for websites",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -24,12 +24,12 @@
|
|
24
24
|
"license": "MIT",
|
25
25
|
"repository": {
|
26
26
|
"type": "git",
|
27
|
-
"url": "https://github.com/
|
27
|
+
"url": "https://github.com/arcai_io/chatbot.git"
|
28
28
|
},
|
29
29
|
"bugs": {
|
30
30
|
"url": "https://github.com/arcai/chatbot/issues"
|
31
31
|
},
|
32
|
-
"homepage": "https://arcai.
|
32
|
+
"homepage": "https://arcai.io",
|
33
33
|
"scripts": {
|
34
34
|
"build": "tsc && npm run bundle",
|
35
35
|
"dev": "tsc -w",
|
@@ -37,7 +37,10 @@
|
|
37
37
|
"prepublishOnly": "npm run build"
|
38
38
|
},
|
39
39
|
"dependencies": {
|
40
|
-
"eventemitter3": "^5.0.1"
|
40
|
+
"eventemitter3": "^5.0.1",
|
41
|
+
"viem": "^1.21.4",
|
42
|
+
"wagmi": "^1.4.13",
|
43
|
+
"@web3modal/wagmi": "^3.5.6"
|
41
44
|
},
|
42
45
|
"devDependencies": {
|
43
46
|
"esbuild": "^0.20.1",
|