ai12z 3.3.2 → 3.3.4
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/cjs/ai12z-bot-f357d89d.js +2613 -0
- package/dist/cjs/ai12z-bot-f357d89d.js.map +1 -0
- package/dist/cjs/ai12z-bot.cjs.entry.js +1 -1
- package/dist/cjs/ai12z-chat_3.cjs.entry.js +46 -36
- package/dist/cjs/ai12z-chat_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ai12z-knowledge-box-005b5b85.js +384 -0
- package/dist/cjs/ai12z-knowledge-box-005b5b85.js.map +1 -0
- package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +1 -1
- package/dist/cjs/dynamic-form.cjs.entry.js +35 -31
- package/dist/cjs/dynamic-form.cjs.entry.js.map +1 -1
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/collection/components/ai12z-bot/ai12z-bot.js +51 -30
- package/dist/collection/components/ai12z-bot/ai12z-bot.js.map +1 -1
- package/dist/collection/components/ai12z-cta/components/Chat.js +46 -36
- package/dist/collection/components/ai12z-cta/components/Chat.js.map +1 -1
- package/dist/collection/components/ai12z-cta/components/DynamicForm.js +35 -31
- package/dist/collection/components/ai12z-cta/components/DynamicForm.js.map +1 -1
- package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +45 -30
- package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js.map +1 -1
- package/dist/collection/global/survey-core.min.css +6 -0
- package/dist/esm/ai12z-bot-77e7fbec.js +2611 -0
- package/dist/esm/ai12z-bot-77e7fbec.js.map +1 -0
- package/dist/esm/ai12z-bot.entry.js +1 -1
- package/dist/esm/ai12z-chat_3.entry.js +46 -36
- package/dist/esm/ai12z-chat_3.entry.js.map +1 -1
- package/dist/esm/ai12z-knowledge-box-71a10937.js +382 -0
- package/dist/esm/ai12z-knowledge-box-71a10937.js.map +1 -0
- package/dist/esm/ai12z-knowledge-box.entry.js +1 -1
- package/dist/esm/dynamic-form.entry.js +35 -31
- package/dist/esm/dynamic-form.entry.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/library/index.esm.js +1 -1
- package/dist/library/library.esm.js +1 -1
- package/dist/library/{p-3e968bf1.entry.js → p-03269530.entry.js} +2 -2
- package/dist/library/p-08bbb4b8.entry.js +2 -0
- package/dist/library/p-08bbb4b8.entry.js.map +1 -0
- package/dist/library/{p-af76a7c6.entry.js → p-32558909.entry.js} +2 -2
- package/dist/library/{p-d567093b.entry.js → p-706e3933.entry.js} +2 -2
- package/dist/library/p-706e3933.entry.js.map +1 -0
- package/dist/library/p-a8e4dffd.js +2 -0
- package/dist/library/p-a8e4dffd.js.map +1 -0
- package/dist/library/p-c5f0d025.js +2 -0
- package/dist/library/p-c5f0d025.js.map +1 -0
- package/dist/types/components/ai12z-bot/ai12z-bot.d.ts +4 -0
- package/dist/types/components/ai12z-cta/components/Chat.d.ts +3 -0
- package/dist/types/components/ai12z-cta/components/DynamicForm.d.ts +3 -5
- package/dist/types/components/ai12z-knowledge-box/ai12z-knowledge-box.d.ts +3 -1
- package/package.json +6 -6
- package/dist/cjs/ai12z-bot-74f5836f.js +0 -2592
- package/dist/cjs/ai12z-bot-74f5836f.js.map +0 -1
- package/dist/cjs/ai12z-knowledge-box-30117a83.js +0 -369
- package/dist/cjs/ai12z-knowledge-box-30117a83.js.map +0 -1
- package/dist/collection/global/survey.min.css +0 -6
- package/dist/esm/ai12z-bot-6f64c1b4.js +0 -2590
- package/dist/esm/ai12z-bot-6f64c1b4.js.map +0 -1
- package/dist/esm/ai12z-knowledge-box-f0962b9a.js +0 -367
- package/dist/esm/ai12z-knowledge-box-f0962b9a.js.map +0 -1
- package/dist/library/p-03ec5034.js +0 -2
- package/dist/library/p-03ec5034.js.map +0 -1
- package/dist/library/p-28892eb0.entry.js +0 -2
- package/dist/library/p-28892eb0.entry.js.map +0 -1
- package/dist/library/p-a6392d09.js +0 -2
- package/dist/library/p-a6392d09.js.map +0 -1
- package/dist/library/p-d567093b.entry.js.map +0 -1
- /package/dist/library/{p-3e968bf1.entry.js.map → p-03269530.entry.js.map} +0 -0
- /package/dist/library/{p-af76a7c6.entry.js.map → p-32558909.entry.js.map} +0 -0
|
@@ -10,7 +10,7 @@ import { SocketService } from "../../../utils/socket-service";
|
|
|
10
10
|
export class MyChat {
|
|
11
11
|
constructor() {
|
|
12
12
|
this.cdnPath = "https://cdn.ai12z.net/assets/bot";
|
|
13
|
-
|
|
13
|
+
this.surveyCDNPath = "https://cdn.ai12z.net/pkg/surveyjs";
|
|
14
14
|
this.styles = [
|
|
15
15
|
`${this.cdnPath}/v1/survey.min.css`,
|
|
16
16
|
// `https://unpkg.com/survey-core/defaultV2.min.css`,
|
|
@@ -18,13 +18,14 @@ export class MyChat {
|
|
|
18
18
|
`https://unpkg.com/@highlightjs/cdn-assets@11.9.0/styles/default.min.css`,
|
|
19
19
|
];
|
|
20
20
|
this.alertResults = sender => {
|
|
21
|
-
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
// console.log("alertResults", sender.keyName)
|
|
22
23
|
const results = JSON.parse(JSON.stringify(sender.data));
|
|
23
24
|
results.description = this.resolveLocalized(sender.jsonObj.description, "");
|
|
24
25
|
const submitRes = {
|
|
25
26
|
results: results,
|
|
26
27
|
type: "survey",
|
|
27
|
-
domId: sender.implementor.renderedElement.id,
|
|
28
|
+
domId: (_c = (_b = (_a = sender.implementor) === null || _a === void 0 ? void 0 : _a.renderedElement) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : sender.domId,
|
|
28
29
|
conversationId: this.conversationId,
|
|
29
30
|
completeText: this.resolveLocalized(sender.jsonObj.completeText, "Submit"),
|
|
30
31
|
keyName: sender.keyName,
|
|
@@ -71,7 +72,9 @@ export class MyChat {
|
|
|
71
72
|
window["Survey"].surveyLocalization.currentLocale = locale;
|
|
72
73
|
const survey = new window["Survey"].Model(chat.formModel);
|
|
73
74
|
const domELe = this.element.shadowRoot.querySelector(`#surveyContainer-${chat.id}`);
|
|
74
|
-
|
|
75
|
+
survey.domId = `surveyContainer-${chat.id}`;
|
|
76
|
+
survey.render(domELe);
|
|
77
|
+
// window["jQuery"](domELe).Survey({ model: survey })
|
|
75
78
|
// console.log("chat.formModel", typeof chat.formModel)
|
|
76
79
|
if (typeof chat.formModel === "object") {
|
|
77
80
|
this.hideCompleteButton(chat.formModel, survey);
|
|
@@ -205,33 +208,6 @@ export class MyChat {
|
|
|
205
208
|
this.isProse = true;
|
|
206
209
|
}
|
|
207
210
|
componentDidLoad() {
|
|
208
|
-
// Load jQuery first
|
|
209
|
-
// console.log("componentDidLoad chat.tsx")
|
|
210
|
-
const jQueryScript = document.createElement("script");
|
|
211
|
-
jQueryScript.src = this.cdnPath + "/v1/jquery.min.js"; // Path relative to the www root
|
|
212
|
-
jQueryScript.onload = () => {
|
|
213
|
-
// console.log("jQuery loaded")
|
|
214
|
-
// Load the script that loads and exposes SurveyJS
|
|
215
|
-
const loadSurveyScript = document.createElement("script");
|
|
216
|
-
loadSurveyScript.src = this.cdnPath + "/v1/survey.jquery.min.js"; // Path relative to the www root
|
|
217
|
-
loadSurveyScript.onload = () => {
|
|
218
|
-
// console.log("SurveyJS loaded and SurveyModel exposed")
|
|
219
|
-
};
|
|
220
|
-
loadSurveyScript.onerror = err => {
|
|
221
|
-
console.error("Failed to load SurveyJS:", err);
|
|
222
|
-
};
|
|
223
|
-
document.head.appendChild(loadSurveyScript);
|
|
224
|
-
this.element.shadowRoot.appendChild(loadSurveyScript);
|
|
225
|
-
};
|
|
226
|
-
jQueryScript.onerror = err => {
|
|
227
|
-
console.error("Failed to load jQuery:", err);
|
|
228
|
-
};
|
|
229
|
-
document.head.appendChild(jQueryScript);
|
|
230
|
-
this.element.shadowRoot.appendChild(jQueryScript);
|
|
231
|
-
// const link2 = document.createElement("link")
|
|
232
|
-
// link2.rel = "stylesheet"
|
|
233
|
-
// link2.href = "https://unpkg.com/@highlightjs/cdn-assets@11.9.0/styles/default.min.css"
|
|
234
|
-
// this.element.shadowRoot.appendChild(link2)
|
|
235
211
|
const ai12zHeading = document.createElement("script");
|
|
236
212
|
ai12zHeading.text = `
|
|
237
213
|
var ai12zChat = window["ai12z"] = {}
|
|
@@ -255,7 +231,41 @@ export class MyChat {
|
|
|
255
231
|
(_b = this.element.shadowRoot) === null || _b === void 0 ? void 0 : _b.appendChild(scriptEl);
|
|
256
232
|
}
|
|
257
233
|
}, 500);
|
|
258
|
-
this.loadStyles()
|
|
234
|
+
// this.loadStyles()
|
|
235
|
+
this.loadScriptsSequentially();
|
|
236
|
+
}
|
|
237
|
+
async loadScriptsSequentially() {
|
|
238
|
+
try {
|
|
239
|
+
// 2. Load Survey Core
|
|
240
|
+
await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/survey.core.min.js`);
|
|
241
|
+
// 3. Load Survey i18n
|
|
242
|
+
await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/survey.i18n.min.js`);
|
|
243
|
+
// 4. Load Survey themes
|
|
244
|
+
await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/themes/index.min.js`);
|
|
245
|
+
// 6. Load Survey UI
|
|
246
|
+
await this.loadScript(`${this.surveyCDNPath}/survey-js-ui@2.3.4/survey-js-ui.min.js`);
|
|
247
|
+
console.log("All Survey.js scripts loaded successfully");
|
|
248
|
+
this.loadStyles();
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
console.error("Failed to load Survey.js scripts:", error);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
loadScript(src) {
|
|
255
|
+
return new Promise((resolve, reject) => {
|
|
256
|
+
if (document.querySelector(`script[src="${src}"]`)) {
|
|
257
|
+
resolve();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const script = document.createElement("script");
|
|
261
|
+
script.src = src;
|
|
262
|
+
script.async = false;
|
|
263
|
+
script.onload = () => resolve();
|
|
264
|
+
script.onerror = () => reject(new Error(`Failed to load script: ${src}`));
|
|
265
|
+
// Load in document head for global access
|
|
266
|
+
// document.head.appendChild(script)
|
|
267
|
+
this.element.shadowRoot.appendChild(script);
|
|
268
|
+
});
|
|
259
269
|
}
|
|
260
270
|
loadStyles() {
|
|
261
271
|
for (const style of this.styles) {
|
|
@@ -1061,7 +1071,7 @@ export class MyChat {
|
|
|
1061
1071
|
render() {
|
|
1062
1072
|
var _a;
|
|
1063
1073
|
const email = "";
|
|
1064
|
-
return (h("ul", { key: '
|
|
1074
|
+
return (h("ul", { key: '5849d0c01526716e2fc8ef9794eeac66b6b7d58d', class: {
|
|
1065
1075
|
"chat-list": true,
|
|
1066
1076
|
"custom-list": this.componentType === "search",
|
|
1067
1077
|
// "custom-chat-top-height": this.componentType === "search",
|
|
@@ -1112,18 +1122,18 @@ export class MyChat {
|
|
|
1112
1122
|
}
|
|
1113
1123
|
// this.isPlayed = false
|
|
1114
1124
|
} }, h("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", class: "icon-md-heavy" }, h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12ZM9.5 8.5C8.94772 8.5 8.5 8.94772 8.5 9.5V14.5C8.5 15.0523 8.94772 15.5 9.5 15.5H14.5C15.0523 15.5 15.5 15.0523 15.5 14.5V9.5C15.5 8.94772 15.0523 8.5 14.5 8.5H9.5Z", fill: "currentColor" })))), !this.isPlayed && (h("button", { class: "copy-btn", onClick: () => this.speakText(this.removeHtmlTags(chat.clipboard)) }, h("svg", { class: "w-6 h-6", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M11 4.9099C11 4.47485 10.4828 4.24734 10.1621 4.54132L6.67572 7.7372C6.49129 7.90626 6.25019 8.00005 6 8.00005H4C3.44772 8.00005 3 8.44776 3 9.00005V15C3 15.5523 3.44772 16 4 16H6C6.25019 16 6.49129 16.0938 6.67572 16.2629L10.1621 19.4588C10.4828 19.7527 11 19.5252 11 19.0902V4.9099ZM8.81069 3.06701C10.4142 1.59714 13 2.73463 13 4.9099V19.0902C13 21.2655 10.4142 22.403 8.81069 20.9331L5.61102 18H4C2.34315 18 1 16.6569 1 15V9.00005C1 7.34319 2.34315 6.00005 4 6.00005H5.61102L8.81069 3.06701ZM20.3166 6.35665C20.8019 6.09313 21.409 6.27296 21.6725 6.75833C22.5191 8.3176 22.9996 10.1042 22.9996 12.0001C22.9996 13.8507 22.5418 15.5974 21.7323 17.1302C21.4744 17.6185 20.8695 17.8054 20.3811 17.5475C19.8927 17.2896 19.7059 16.6846 19.9638 16.1962C20.6249 14.9444 20.9996 13.5175 20.9996 12.0001C20.9996 10.4458 20.6064 8.98627 19.9149 7.71262C19.6514 7.22726 19.8312 6.62017 20.3166 6.35665ZM15.7994 7.90049C16.241 7.5688 16.8679 7.65789 17.1995 8.09947C18.0156 9.18593 18.4996 10.5379 18.4996 12.0001C18.4996 13.3127 18.1094 14.5372 17.4385 15.5604C17.1357 16.0222 16.5158 16.1511 16.0539 15.8483C15.5921 15.5455 15.4632 14.9255 15.766 14.4637C16.2298 13.7564 16.4996 12.9113 16.4996 12.0001C16.4996 10.9859 16.1653 10.0526 15.6004 9.30063C15.2687 8.85905 15.3578 8.23218 15.7994 7.90049Z", fill: "currentColor" })))), h("button", { class: "copy-btn", onClick: () => this.copyToClipboard(chat.clipboard) }, !this.copied && (h("svg", { class: "w-6 h-6", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M7 5C7 3.34315 8.34315 2 10 2H19C20.6569 2 22 3.34315 22 5V14C22 15.6569 20.6569 17 19 17H17V19C17 20.6569 15.6569 22 14 22H5C3.34315 22 2 20.6569 2 19V10C2 8.34315 3.34315 7 5 7H7V5ZM9 7H14C15.6569 7 17 8.34315 17 10V15H19C19.5523 15 20 14.5523 20 14V5C20 4.44772 19.5523 4 19 4H10C9.44772 4 9 4.44772 9 5V7ZM5 9C4.44772 9 4 9.44772 4 10V19C4 19.5523 4.44772 20 5 20H14C14.5523 20 15 19.5523 15 19V10C15 9.44772 14.5523 9 14 9H5Z", fill: "currentColor" }))), this.copied && (h("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", class: "w-6 h-6" }, h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M19.8198 6.19526C20.0601 6.45561 20.0601 6.87772 19.8198 7.13807L9.9736 17.8047C9.73328 18.0651 9.34364 18.0651 9.10332 17.8047L4.18024 12.4714C3.93992 12.2111 3.93992 11.7889 4.18024 11.5286C4.42056 11.2682 4.8102 11.2682 5.05053 11.5286L9.53846 16.3905L18.9495 6.19526C19.1898 5.93491 19.5794 5.93491 19.8198 6.19526Z", fill: "currentColor" })))), h("button", { id: `thumbsUp_${chat.thumbsId}`, onClick: () => this.thumbsUp(chat.thumbsId, chat.insightId), class: "chat-thumbs-up" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", class: "w-6 h-6" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6.633 10.25c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 0 1 2.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 0 0 .322-1.672V2.75a.75.75 0 0 1 .75-.75 2.25 2.25 0 0 1 2.25 2.25c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282m0 0h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 0 1-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 0 0-1.423-.23H5.904m10.598-9.75H14.25M5.904 18.5c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 0 1-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 9.953 4.167 9.5 5 9.5h1.053c.472 0 .745.556.5.96a8.958 8.958 0 0 0-1.302 4.665c0 1.194.232 2.333.654 3.375Z" }))), h("button", { id: `thumbsDown_${chat.thumbsId}`, onClick: () => this.thumbsDown(chat.thumbsId, chat.insightId), class: "chat-thumbs-up" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", class: "w-6 h-6" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M7.498 15.25H4.372c-1.026 0-1.945-.694-2.054-1.715a12.137 12.137 0 0 1-.068-1.285c0-2.848.992-5.464 2.649-7.521C5.287 4.247 5.886 4 6.504 4h4.016a4.5 4.5 0 0 1 1.423.23l3.114 1.04a4.5 4.5 0 0 0 1.423.23h1.294M7.498 15.25c.618 0 .991.724.725 1.282A7.471 7.471 0 0 0 7.5 19.75 2.25 2.25 0 0 0 9.75 22a.75.75 0 0 0 .75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 0 0 2.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384m-10.253 1.5H9.7m8.075-9.75c.01.05.027.1.05.148.593 1.2.925 2.55.925 3.977 0 1.487-.36 2.89-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398-.306.774-1.086 1.227-1.918 1.227h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 0 0 .303-.54" }))), h("button", { class: "copy-btn" }, h("a", { href: `mailto:${email}?subject=${encodeURIComponent((_d = this.chats[idx - 1]) === null || _d === void 0 ? void 0 : _d.message)}&body=${encodeURIComponent(this.removeHtmlTags(chat.clipboard))}`, target: "_blank" }, h("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", stroke: "currentColor", "stroke-width": "0.3", class: "w-6 h-6" }, h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M3.75 5.25L3 6V18L3.75 18.75H20.25L21 18V6L20.25 5.25H3.75ZM4.5 7.6955V17.25H19.5V7.69525L11.9999 14.5136L4.5 7.6955ZM18.3099 6.75H5.68986L11.9999 12.4864L18.3099 6.75Z", fill: "currentColor" }), " "))))))));
|
|
1115
|
-
}), h("div", { key: '
|
|
1125
|
+
}), h("div", { key: '56bb1ad8a9b585fdd8e745255c1b7d1bd9855841', class: "scroll-bottom" })));
|
|
1116
1126
|
}
|
|
1117
1127
|
static get is() { return "ai12z-chat"; }
|
|
1118
1128
|
static get encapsulation() { return "shadow"; }
|
|
1119
1129
|
static get originalStyleUrls() {
|
|
1120
1130
|
return {
|
|
1121
|
-
"$": ["ai12z-chat.css", "../../../global/tailwind.min.css", "../../../global/survey.min.css"]
|
|
1131
|
+
"$": ["ai12z-chat.css", "../../../global/tailwind.min.css", "../../../global/survey-core.min.css"]
|
|
1122
1132
|
};
|
|
1123
1133
|
}
|
|
1124
1134
|
static get styleUrls() {
|
|
1125
1135
|
return {
|
|
1126
|
-
"$": ["ai12z-chat.css", "../../../global/tailwind.min.css", "../../../global/survey.min.css"]
|
|
1136
|
+
"$": ["ai12z-chat.css", "../../../global/tailwind.min.css", "../../../global/survey-core.min.css"]
|
|
1127
1137
|
};
|
|
1128
1138
|
}
|
|
1129
1139
|
static get properties() {
|