ai12z 3.16.1-alpha.3 → 3.16.1-alpha.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.
Files changed (96) hide show
  1. package/dist/cjs/ai12z-beacon.cjs.entry.js +1 -1
  2. package/dist/cjs/ai12z-bot.cjs.entry.js +13 -7
  3. package/dist/cjs/ai12z-chat_2.cjs.entry.js +1 -1
  4. package/dist/cjs/ai12z-cta.cjs.entry.js +1 -1
  5. package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +22 -17
  6. package/dist/cjs/beacon-B9ZWQpG6.js +321 -0
  7. package/dist/cjs/index.cjs.js +1 -1
  8. package/dist/cjs/search-results-page.cjs.entry.js +12 -10
  9. package/dist/collection/components/ai12z-bot/ai12z-bot.js +12 -6
  10. package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +22 -17
  11. package/dist/collection/components/ai12z-search-panel/search-results-view.js +12 -10
  12. package/dist/collection/utils/beacon.js +146 -58
  13. package/dist/components/ai12z-beacon.js +1 -1
  14. package/dist/components/ai12z-bot.js +1 -1
  15. package/dist/components/ai12z-chat.js +1 -1
  16. package/dist/components/ai12z-cta.js +1 -1
  17. package/dist/components/ai12z-inline-search.js +1 -1
  18. package/dist/components/ai12z-knowledge-box.js +1 -1
  19. package/dist/components/index.js +1 -1
  20. package/dist/components/p-C-IKmqII.js +1 -0
  21. package/dist/components/{p-vww9WgTo.js → p-CX6EbMog.js} +1 -1
  22. package/dist/components/p-Cmj8wElU.js +1 -0
  23. package/dist/components/{p-DLOQS_dm.js → p-CvPbldU0.js} +1 -1
  24. package/dist/components/p-DVnjJHuQ.js +1 -0
  25. package/dist/components/p-Db3MSI1b.js +1 -0
  26. package/dist/components/{p-CuvuE2zX.js → p-Dy72Ri-1.js} +1 -1
  27. package/dist/components/{p-BxPHrPiR.js → p-OAsYsTgR.js} +1 -1
  28. package/dist/components/search-results-page.js +1 -1
  29. package/dist/esm/ai12z-beacon.entry.js +2 -2
  30. package/dist/esm/ai12z-bot.entry.js +21 -15
  31. package/dist/esm/ai12z-category_2.entry.js +3 -3
  32. package/dist/esm/ai12z-chat-message.entry.js +2 -2
  33. package/dist/esm/ai12z-chat_2.entry.js +9 -9
  34. package/dist/esm/ai12z-container.entry.js +3 -3
  35. package/dist/esm/ai12z-cta.entry.js +5 -5
  36. package/dist/esm/ai12z-form.entry.js +2 -2
  37. package/dist/esm/ai12z-inline-search.entry.js +2 -2
  38. package/dist/esm/ai12z-knowledge-box.entry.js +27 -22
  39. package/dist/esm/ai12z-search-panel.entry.js +1 -1
  40. package/dist/esm/beacon-CTeIOnFW.js +318 -0
  41. package/dist/esm/chat-avatar_6.entry.js +1 -1
  42. package/dist/esm/{ctaHelpers-DcnA0MVw.js → ctaHelpers-BxYDDl6j.js} +1 -1
  43. package/dist/esm/dynamic-form.entry.js +1 -1
  44. package/dist/esm/{index-CaCfv0ky.js → index-BSAVvAU7.js} +1 -1
  45. package/dist/esm/index.js +11 -11
  46. package/dist/esm/item-list.entry.js +2 -2
  47. package/dist/esm/{keyboard-shortcuts-BVIafjUQ.js → keyboard-shortcuts-Iro3156u.js} +2 -2
  48. package/dist/esm/{parseHelper-D4mtBh2Q.js → parseHelper-D_HyZ-hh.js} +1 -1
  49. package/dist/esm/{processCarouselData-BMYrhEs4.js → processCarouselData-MkXYTDY2.js} +1 -1
  50. package/dist/esm/{reCaptchaHelpers-YIcqZyYx.js → reCaptchaHelpers-M2SfYLz1.js} +1 -1
  51. package/dist/esm/search-results-page.entry.js +16 -14
  52. package/dist/esm/{socket-service-CRKef4T3.js → socket-service-DBZCOxQR.js} +1 -1
  53. package/dist/esm/{styleSheetRegistry-DdPFpNJm.js → styleSheetRegistry-CxLH9Q0z.js} +1 -1
  54. package/dist/esm/{surveyHelpers-D4TSNF8Y.js → surveyHelpers-B_IO8diu.js} +1 -1
  55. package/dist/esm/{utils-ChO9VTBD.js → utils-CgIk6Jbn.js} +1 -1
  56. package/dist/library/index.esm.js +1 -1
  57. package/dist/library/library.esm.js +1 -1
  58. package/dist/library/{p-90267282.entry.js → p-07ac3aeb.entry.js} +1 -1
  59. package/dist/library/p-324fbc31.entry.js +1 -0
  60. package/dist/library/{p-a7d3d165.entry.js → p-338a8f28.entry.js} +1 -1
  61. package/dist/library/{p-c86ab9a1.entry.js → p-4594fac4.entry.js} +1 -1
  62. package/dist/library/{p-2a0e8794.entry.js → p-5903cc93.entry.js} +1 -1
  63. package/dist/library/{p-e068fafd.entry.js → p-758ccdb5.entry.js} +1 -1
  64. package/dist/library/{p-e455d89a.entry.js → p-759e5580.entry.js} +1 -1
  65. package/dist/library/{p-d0537df4.entry.js → p-952d0734.entry.js} +1 -1
  66. package/dist/library/p-AtKfoKg4.js +1 -0
  67. package/dist/library/{p-C6mjQOfZ.js → p-BXxt773d.js} +1 -1
  68. package/dist/library/{p-DxK9sK4Q.js → p-BnkN4SP7.js} +1 -1
  69. package/dist/library/{p-CkHXycsT.js → p-BpnISGA6.js} +1 -1
  70. package/dist/library/{p-DSFLm9UF.js → p-C9xkKjGV.js} +1 -1
  71. package/dist/library/{p-D-02FHEk.js → p-CCEJFtl1.js} +3 -3
  72. package/dist/library/{p-BuRbL6gW.js → p-CGdgvo_b.js} +1 -1
  73. package/dist/library/{p-BioRZgoO.js → p-D85u0uEM.js} +1 -1
  74. package/dist/library/{p-BSPqAtmB.js → p-DCiuGcUL.js} +1 -1
  75. package/dist/library/{p-Xl3fPHSq.js → p-Dwtvt1Ju.js} +1 -1
  76. package/dist/library/{p-DjDuNItZ.js → p-Jb6LBYBH.js} +1 -1
  77. package/dist/library/{p-d4d66d5a.entry.js → p-aa6b173e.entry.js} +1 -1
  78. package/dist/library/{p-997e2c97.entry.js → p-ae810ce7.entry.js} +1 -1
  79. package/dist/library/p-b3d39c03.entry.js +1 -0
  80. package/dist/library/{p-556f02ab.entry.js → p-c60d1052.entry.js} +2 -2
  81. package/dist/library/p-da1f61b5.entry.js +1 -0
  82. package/dist/library/{p-959d6f61.entry.js → p-e18997fc.entry.js} +1 -1
  83. package/dist/library/{p-84a3e86b.entry.js → p-f922f9f3.entry.js} +1 -1
  84. package/dist/types/components/ai12z-knowledge-box/ai12z-knowledge-box.d.ts +1 -1
  85. package/dist/types/utils/beacon.d.ts +5 -3
  86. package/package.json +2 -2
  87. package/dist/cjs/beacon-BXbtC1CF.js +0 -233
  88. package/dist/components/p-BMfSdozn.js +0 -1
  89. package/dist/components/p-CxxCQyur.js +0 -1
  90. package/dist/components/p-D-0m820g.js +0 -1
  91. package/dist/components/p-FQgYAFAZ.js +0 -1
  92. package/dist/esm/beacon-BZXo_E7d.js +0 -230
  93. package/dist/library/p-8adc93e4.entry.js +0 -1
  94. package/dist/library/p-CQ3w1XSQ.js +0 -1
  95. package/dist/library/p-cca4ab89.entry.js +0 -1
  96. package/dist/library/p-d6e75352.entry.js +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-v8T1EJAJ.js');
4
- var beacon = require('./beacon-BXbtC1CF.js');
4
+ var beacon = require('./beacon-B9ZWQpG6.js');
5
5
  require('./utils-C2m26j54.js');
6
6
 
7
7
  const Ai12zBeacon = class {
@@ -15,7 +15,7 @@ var keyboardShortcuts = require('./keyboard-shortcuts-BpiAXzLW.js');
15
15
  var ctaHelpers = require('./ctaHelpers-CmoXzyRy.js');
16
16
  var appStore = require('./app-store-BtkiHvcw.js');
17
17
  var parseHelper = require('./parseHelper-CbA81TvP.js');
18
- var beacon = require('./beacon-BXbtC1CF.js');
18
+ var beacon = require('./beacon-B9ZWQpG6.js');
19
19
  var bodyScrollLock = require('./bodyScrollLock-C7gKTAfx.js');
20
20
  require('./_commonjsHelpers-MBWFX2dn.js');
21
21
 
@@ -1231,10 +1231,11 @@ const Ai12zBot = class {
1231
1231
  }
1232
1232
  };
1233
1233
  this.handleMessage = (data, aiMessageId) => {
1234
+ var _a;
1234
1235
  const converter = new processCarouselData.showdown.Converter();
1235
1236
  // const aiMessageBubble = document.getElementById(aiMessageId);
1236
1237
  // const aiMessageBubble = await waitForElement(`#${aiMessageId}`, this.el)
1237
- const aiMessageBubble = this.el.shadowRoot.querySelector(`#${aiMessageId}`);
1238
+ const aiMessageBubble = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${aiMessageId}`);
1238
1239
  if (!aiMessageBubble) {
1239
1240
  console.error(`Message bubble with ID ${aiMessageId} not found.`);
1240
1241
  return;
@@ -1258,6 +1259,7 @@ const Ai12zBot = class {
1258
1259
  }
1259
1260
  };
1260
1261
  this.handleSend = async (eleValue, options = {}) => {
1262
+ var _a;
1261
1263
  const { isHide = false, isLiveChatEnded = false } = options;
1262
1264
  this.emptyMessageError = false;
1263
1265
  this.surveyDomId = "";
@@ -1348,7 +1350,7 @@ const Ai12zBot = class {
1348
1350
  }
1349
1351
  }
1350
1352
  // this.invokeSocket()
1351
- const parent = this.el.shadowRoot.querySelector("#previewContainer");
1353
+ const parent = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("#previewContainer");
1352
1354
  if (parent) {
1353
1355
  parent.innerHTML = "";
1354
1356
  }
@@ -1405,6 +1407,7 @@ const Ai12zBot = class {
1405
1407
  this.scheduleAutoScroll();
1406
1408
  };
1407
1409
  this.addEventMessage = (_message) => {
1410
+ var _a;
1408
1411
  const agentEventMessages = this.liveAgentEventHandler.addAgentEventMessage([
1409
1412
  {
1410
1413
  text: _message,
@@ -1416,7 +1419,7 @@ const Ai12zBot = class {
1416
1419
  }
1417
1420
  }
1418
1421
  if (agentEventMessages && this.currentDomId) {
1419
- const currentDomElement = this.el.shadowRoot.querySelector(`#${this.currentDomId}`);
1422
+ const currentDomElement = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${this.currentDomId}`);
1420
1423
  if (currentDomElement) {
1421
1424
  // Append the agent event messages to the current message bubble
1422
1425
  currentDomElement.parentNode.appendChild(agentEventMessages);
@@ -1887,6 +1890,7 @@ const Ai12zBot = class {
1887
1890
  }
1888
1891
  }
1889
1892
  componentDidLoad() {
1893
+ var _a;
1890
1894
  globalStore.setBotElement(this.el); // register globally
1891
1895
  if (typeof window !== "undefined" && !window.Handlebars) {
1892
1896
  window.Handlebars = index$1.Handlebars;
@@ -1901,7 +1905,7 @@ const Ai12zBot = class {
1901
1905
  var ai12zChat = window["ai12z"] = {}
1902
1906
  `;
1903
1907
  document.head.appendChild(ai12zHeading);
1904
- this.el.shadowRoot.appendChild(ai12zHeading);
1908
+ (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(ai12zHeading);
1905
1909
  // ✅ Initialize asset loader if not already done (configBot may have initialized it)
1906
1910
  if (!this.assetLoader) {
1907
1911
  this.initializeAssetLoader();
@@ -2201,7 +2205,8 @@ const Ai12zBot = class {
2201
2205
  hideSpinner(chatData) {
2202
2206
  // Logic for hiding the spinner (assumed to return a Promise if async is needed)
2203
2207
  return new Promise(resolve => {
2204
- const renderedBubble = this.el.shadowRoot.querySelector(`#${chatData.id}`);
2208
+ var _a;
2209
+ const renderedBubble = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${chatData.id}`);
2205
2210
  if (renderedBubble) {
2206
2211
  const spinner = renderedBubble.querySelector("#spinner");
2207
2212
  if (spinner) {
@@ -2458,7 +2463,8 @@ const Ai12zBot = class {
2458
2463
  }
2459
2464
  }
2460
2465
  addEventListeners(msgId) {
2461
- const container = this.el.shadowRoot.querySelector(msgId);
2466
+ var _a;
2467
+ const container = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(msgId);
2462
2468
  if (container) {
2463
2469
  this.buttons.forEach(button => {
2464
2470
  const buttonElement = container.querySelector(`#${button.id}`);
@@ -11,7 +11,7 @@ var surveyHelpers = require('./surveyHelpers-DFh4q1hj.js');
11
11
  var keyboardShortcuts = require('./keyboard-shortcuts-BpiAXzLW.js');
12
12
  var analyticsService = require('./analyticsService-CkAva47S.js');
13
13
  var botHelpers = require('./botHelpers-D5Dj7TRA.js');
14
- var beacon = require('./beacon-BXbtC1CF.js');
14
+ var beacon = require('./beacon-B9ZWQpG6.js');
15
15
  require('./_commonjsHelpers-MBWFX2dn.js');
16
16
  require('./logger-2ZBZCKdM.js');
17
17
  require('./response-adapter-CKKyyhMj.js');
@@ -7,7 +7,7 @@ var socketService = require('./socket-service-Cx-4DSqu.js');
7
7
  var globalStore = require('./global-store-R6x06KvJ.js');
8
8
  var reCaptchaHelpers = require('./reCaptchaHelpers-mbTvATH6.js');
9
9
  var ctaHelpers = require('./ctaHelpers-CmoXzyRy.js');
10
- var beacon = require('./beacon-BXbtC1CF.js');
10
+ var beacon = require('./beacon-B9ZWQpG6.js');
11
11
  var appStore = require('./app-store-BtkiHvcw.js');
12
12
  var bodyScrollLock = require('./bodyScrollLock-C7gKTAfx.js');
13
13
  require('./response-adapter-CKKyyhMj.js');
@@ -10,6 +10,7 @@ var index$1 = require('./index-DbNk7qkZ.js');
10
10
  var surveyHelpers = require('./surveyHelpers-DFh4q1hj.js');
11
11
  var botHelpers = require('./botHelpers-D5Dj7TRA.js');
12
12
  var analyticsService = require('./analyticsService-CkAva47S.js');
13
+ var beacon = require('./beacon-B9ZWQpG6.js');
13
14
  require('./_commonjsHelpers-MBWFX2dn.js');
14
15
 
15
16
  const ai12zKnowledgeBoxCss = () => `:host{font-family:var(--ai12z-knowledge-box-font-family) !important;font-size:var(--ai12z-knowledge-box-font-size) !important;color:var(--ai12z-knowledge-box-font-color, black);text-align:var(--ai12z-knowledge-box-text-align, left)}.ai12z-kb-wrapper{background-color:var(--ai12z-knowledge-box-bg-color)}.ai12z-suggest-container{padding:32px 32px 32px 32px;flex:none}.ai12z-suggest-answer{font-size:var(--ai12z-knowledge-box-font-size)}.ai12z-suggest-title{font-weight:700}.ai12z-suggest-align{float:left}.ai12z-suggest-relevance{text-align:end}.ai12z-suggest-error-msg{color:rgb(239 68 68)}.ai12z-suggest-hide{display:none}.ai12z-suggest-thumbs{margin-left:90%}.ai12z-suggest-thumbs-up{fill:var(--ai12z-feedback-selected);width:24px}.ai12z-suggest-thumbs-down{fill:var(--ai12z-feedback-selected);width:24px}.not-allowed{cursor:not-allowed}.ai12zBtn{background-color:var(--ai12z-knowledge-box-button-bgcolor);color:var(--ai12z-knowledge-box-button-color) !important;padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none !important;margin:5px}.custom-privacy{color:var(--ai12z-knowledge-box-privacy-color);text-align:center;font-size:var(--ai12z-knowledge-box-privacy-font-size);margin-top:10px}button:focus-visible{outline:2px solid var(--ai12z-knowledge-box-focus-visible-color, #0A2A43);outline-offset:2px}button.kb-btn-primary:focus-visible{outline:2px solid var(--ai12z-knowledge-box-focus-visible-color-primary, --ai12z-knowledge-box-focus-visible-color);outline-offset:2px}button.kb-btn-secondary:focus-visible{outline:2px solid var(--ai12z-knowledge-box-focus-visible-color-secondary, --ai12z-knowledge-box-focus-visible-color)}.diamond-icon{color:var(--ai12z-knowledge-box-icon-color, #a5e6e6);width:28px;height:28px;transform-origin:center;}.diamond-icon.loading{animation:rotate 2s linear infinite}@keyframes rotate{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}`;
@@ -364,6 +365,7 @@ const Ai12zKnowledgeBox = class {
364
365
  this.handleMessage(messageData, `${this.domId}`); // Use the unique ID to handle messages
365
366
  });
366
367
  this.socket.on(endEvent, async (rawData) => {
368
+ var _a, _b;
367
369
  const data = protocol === "v2" ? responseAdapter.adaptCompleteToLegacy(rawData) : rawData;
368
370
  this.isStreaming = false;
369
371
  this.messageReceived.emit({ data, domId: this.domId });
@@ -374,6 +376,19 @@ const Ai12zKnowledgeBox = class {
374
376
  this.isLoading = false;
375
377
  this.searchResults = data;
376
378
  this.error = null;
379
+ // Save conversation id from response for later use
380
+ this.questionId = (_b = (_a = data.conversationId) !== null && _a !== void 0 ? _a : data.conversation_id) !== null && _b !== void 0 ? _b : this.questionId;
381
+ // If this is the very first conversation, inform the beacon util
382
+ if (this.questionId) {
383
+ // `setConversationId` is idempotent and will no-op if already stored
384
+ try {
385
+ // Call asynchronously, don't await to avoid blocking UI
386
+ void beacon.setConversationId(this.dataKey, this.questionId);
387
+ }
388
+ catch (e) {
389
+ console.error("Failed to set beacon conversation id:", e);
390
+ }
391
+ }
377
392
  const controlMatches = finalHtml.match(/\[control[^\]]*\]/g) || [];
378
393
  if (finalHtml.indexOf("[control") > -1 && controlMatches.length > 0) {
379
394
  this.showButton = false;
@@ -385,19 +400,6 @@ const Ai12zKnowledgeBox = class {
385
400
  }
386
401
  });
387
402
  }
388
- // invokeSurvey = chat => {
389
- // const formModel = chat.controlData.form_model
390
- // const survey = new window["Survey"].Model(formModel)
391
- // const domELe = this.element.shadowRoot.querySelector(`#${this.domId}`).shadowRoot.querySelector(`#${this.surveyDomId}`)
392
- // if (domELe) {
393
- // survey.render(domELe)
394
- // // window["jQuery"](domELe).Survey({ model: survey })
395
- // } else {
396
- // console.error("Survey Element not found")
397
- // }
398
- // survey.showCompletedPage = false
399
- // survey.onComplete.add(this.alertResults)
400
- // }
401
403
  addEventListeners(msgId) {
402
404
  const container = this.el.shadowRoot.querySelector(msgId);
403
405
  if (container) {
@@ -410,10 +412,13 @@ const Ai12zKnowledgeBox = class {
410
412
  });
411
413
  }
412
414
  }
413
- componentWillLoad() {
415
+ async componentWillLoad() {
414
416
  styleSheetRegistry.adoptStyleSheet(`https://cdn.ai12z.net/assets/bot/${index.Env.CDN_PATH}/tailwind.min.css`, this.el.shadowRoot);
415
417
  this.socketConnection();
416
- this.getConfig();
418
+ await this.getConfig();
419
+ // initialize beacon asynchronously so slow/blocked beacon endpoints
420
+ // don't delay component rendering
421
+ void beacon.initBeacon(this.dataKey);
417
422
  const w = window;
418
423
  if (!w.ai12z)
419
424
  w.ai12z = {};
@@ -607,7 +612,7 @@ const Ai12zKnowledgeBox = class {
607
612
  }
608
613
  render() {
609
614
  var _a, _b;
610
- return (index.h("div", { key: 'c31a4219d05067e80e11380affc8be5808d8d505', class: "ai12z-kb-wrapper" }, this.error ? index.h("p", { class: "ai12z-suggest-error-msg" }, "Error please try again!") : null, this.items.map(item => {
615
+ return (index.h("div", { key: 'b2671211acc966388e020bf7f8ef62dfdbab9193', class: "ai12z-kb-wrapper" }, this.error ? index.h("p", { class: "ai12z-suggest-error-msg" }, "Error please try again!") : null, this.items.map(item => {
611
616
  var _a, _b, _c, _d;
612
617
  return (index.h("div", { class: "prose max-w-none ai12z-suggest-container" }, index.h("div", null, index.h("div", null, index.h("div", { class: "flex flex-row gap-1" }, index.h("div", { class: "flex items-center gap-2 mb-3", style: { width: "90%" } }, ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.showTitle) && (index.h("svg", { width: "28", height: "28", viewBox: "0 0 48 48", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", class: "diamond-icon" + (this.isLoading && !this.finalResponse ? " loading" : "") }, index.h("path", { d: "M24 2c-3 8-8 13-16 16 8 3 13 8 16 16 3-8 8-13 16-16-8-3-13-8-16-16z" }))), ((_b = this.kbSettings) === null || _b === void 0 ? void 0 : _b.showTitle) && (index.h("h5", { class: "text-lg font-semibold text-gray-800 m-0" }, !this.finalResponse ? "Generating..." : (_c = this.kbSettings.title) !== null && _c !== void 0 ? _c : "AI Overview"))), item.thumbsUpDown && !this.isLoading && (index.h("div", null, index.h("button", { id: `thumbsUp_${item.insightId}`, onClick: () => {
613
618
  var _a;
@@ -628,7 +633,7 @@ const Ai12zKnowledgeBox = class {
628
633
  questionText: this.question,
629
634
  });
630
635
  }, class: "chat-thumbs-down", "aria-label": "Thumbs Down" }, index.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" }, index.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" }))))))), !this.isLoading && (index.h("div", null, ((_d = this.searchResults) === null || _d === void 0 ? void 0 : _d.controlType) !== "form" && (index.h("ai12z-chat-message", { id: item.id, text: this.currentStreamingText, kbSettings: this.kbSettings, "show-button": this.showButton, streaming: this.isStreaming && item.id === this.domId })), index.h("div", { class: { "ai12z-suggest-relevance": true, "ai12z-suggest-hide": !item["isRelevance"] } }, index.h("a", { href: "" }, item["relevanceScore"])), index.h("div", { class: "custom-privacy" }, index.h("slot", { name: "custom-privacy" })))), this.isLoading && (index.h("div", { class: "w-full rounded-md", id: "spinner" }, index.h("div", { class: "flex animate-pulse space-x-4" }, index.h("div", { class: "flex-1 space-y-3 py-1" }, index.h("div", { class: "h-4 rounded bg-gray-200" }), index.h("div", { class: "space-y-3" }, index.h("div", { class: "grid grid-cols-3 gap-4" }, index.h("div", { class: "col-span-2 h-4 rounded bg-gray-200" }), index.h("div", { class: "col-span-1 h-4 rounded bg-gray-200" })), index.h("div", { class: "h-4 rounded bg-gray-200" })))))))));
631
- }), ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.questionType) === "staticHtml" && this.items.length === 0 && this.welcomeReady && (index.h("div", { key: 'd893adcba892e17f3ed2d155d84faa2e2453178b', class: "ai12z-suggest-answer", innerHTML: (_b = this.kbSettings.welcome) === null || _b === void 0 ? void 0 : _b.message }))));
636
+ }), ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.questionType) === "staticHtml" && this.items.length === 0 && this.welcomeReady && (index.h("div", { key: '7ddf7c77ec816cb0029efc0978ea041bb8022a7b', class: "ai12z-suggest-answer", innerHTML: (_b = this.kbSettings.welcome) === null || _b === void 0 ? void 0 : _b.message }))));
632
637
  }
633
638
  static get assetsDirs() { return ["assets"]; }
634
639
  get el() { return index.getElement(this); }
@@ -0,0 +1,321 @@
1
+ 'use strict';
2
+
3
+ var utils = require('./utils-C2m26j54.js');
4
+
5
+ const SUPPORTED_ENGINES = [
6
+ "chatgpt",
7
+ "perplexity",
8
+ "gemini",
9
+ "claude",
10
+ "copilot",
11
+ "grok",
12
+ "meta_ai",
13
+ "you",
14
+ "google",
15
+ "bing",
16
+ ];
17
+ const ENGINE_TYPE_MAP = {
18
+ chatgpt: "ai_answer_engine",
19
+ perplexity: "ai_answer_engine",
20
+ gemini: "ai_answer_engine",
21
+ claude: "ai_answer_engine",
22
+ copilot: "ai_answer_engine",
23
+ grok: "ai_answer_engine",
24
+ meta_ai: "ai_answer_engine",
25
+ you: "ai_answer_engine",
26
+ google: "search_engine",
27
+ bing: "search_engine",
28
+ };
29
+ function detectDeviceCategory() {
30
+ const ua = navigator.userAgent;
31
+ if (/iPad|Tablet/i.test(ua)) {
32
+ return "tablet";
33
+ }
34
+ if (/Mobi|Android/i.test(ua)) {
35
+ return "mobile";
36
+ }
37
+ return "desktop";
38
+ }
39
+ function detectBrowser() {
40
+ const ua = navigator.userAgent;
41
+ if (/OPR\//i.test(ua))
42
+ return "Opera";
43
+ if (/Edg\//i.test(ua))
44
+ return "Edge";
45
+ if (/Firefox\//i.test(ua))
46
+ return "Firefox";
47
+ if (/Chrome\//i.test(ua))
48
+ return "Chrome";
49
+ if (/Safari\//i.test(ua))
50
+ return "Safari";
51
+ return "Unknown";
52
+ }
53
+ function detectOS() {
54
+ const ua = navigator.userAgent;
55
+ if (/Windows NT/i.test(ua))
56
+ return "Windows";
57
+ if (/Mac OS X/i.test(ua))
58
+ return "macOS";
59
+ if (/Android/i.test(ua))
60
+ return "Android";
61
+ if (/iPhone|iPad|iPod/i.test(ua))
62
+ return "iOS";
63
+ if (/Linux/i.test(ua))
64
+ return "Linux";
65
+ return "Unknown";
66
+ }
67
+ function getReferrerUrl() {
68
+ try {
69
+ return document.referrer ? new URL(document.referrer) : null;
70
+ }
71
+ catch (_a) {
72
+ return null;
73
+ }
74
+ }
75
+ const ENGINE_MAP = [
76
+ { engine: "chatgpt", hosts: ["chatgpt.com"] },
77
+ { engine: "google", hosts: ["google.com"] },
78
+ { engine: "bing", hosts: ["bing.com"] },
79
+ { engine: "perplexity", hosts: ["perplexity.ai"] },
80
+ { engine: "claude", hosts: ["claude.ai"] },
81
+ { engine: "gemini", hosts: ["gemini.google.com"] },
82
+ { engine: "copilot", hosts: ["copilot.microsoft.com"] },
83
+ { engine: "grok", hosts: ["grok.com", "x.com"] },
84
+ { engine: "meta_ai", hosts: ["meta.ai"] },
85
+ { engine: "you", hosts: ["you.com"] },
86
+ ];
87
+ function detectEngine() {
88
+ const referrerUrl = getReferrerUrl();
89
+ const hostname = referrerUrl === null || referrerUrl === void 0 ? void 0 : referrerUrl.hostname.toLowerCase();
90
+ const currentHostname = window.location.hostname.toLowerCase();
91
+ const isInternalReferrer = hostname === currentHostname;
92
+ if (hostname && !isInternalReferrer) {
93
+ for (const item of ENGINE_MAP) {
94
+ if (item.hosts.some(host => hostname === host || hostname.endsWith(`.${host}`))) {
95
+ return item.engine;
96
+ }
97
+ }
98
+ }
99
+ const rawUtmSource = new URL(window.location.href).searchParams.get("utm_source");
100
+ // Helper: sanitize utm when used as an engine candidate. Keep strict
101
+ // character set and short length to avoid unbounded or untrusted text
102
+ // entering the `engine` field (which is used as an enum-like value).
103
+ const sanitizeUtmForEngine = (v) => {
104
+ if (!v)
105
+ return null;
106
+ const s = v.toLowerCase().trim().slice(0, 64);
107
+ // allow only a conservative charset for engine classification
108
+ return /^[a-z0-9_.-]+$/.test(s) ? s : null;
109
+ };
110
+ const utmSource = sanitizeUtmForEngine(rawUtmSource);
111
+ if (utmSource) {
112
+ // If utm matches a supported engine, return that engine; otherwise
113
+ // return the sanitized utm_source string so non-engine sources
114
+ // (e.g. "linkedin") are preserved instead of being coerced to
115
+ // the sentinel "other".
116
+ return SUPPORTED_ENGINES.includes(utmSource) ? utmSource : utmSource;
117
+ }
118
+ return hostname && !isInternalReferrer ? hostname : "direct";
119
+ }
120
+ function inferEngineType(engine, explicitType) {
121
+ return ENGINE_TYPE_MAP[engine];
122
+ }
123
+ function hasSupportedEngine(value) {
124
+ return SUPPORTED_ENGINES.includes(value);
125
+ }
126
+ function getBeaconRequestState() {
127
+ var _a;
128
+ return ((_a = window).__ai12zBeaconRequestState || (_a.__ai12zBeaconRequestState = {}));
129
+ }
130
+ function getBeaconRequestSignature() {
131
+ const url = new URL(window.location.href);
132
+ return JSON.stringify({
133
+ origin: url.origin,
134
+ path: url.pathname,
135
+ search: url.search,
136
+ });
137
+ }
138
+ async function waitForPendingBeacon(timeoutMs = 10000) {
139
+ const start = Date.now();
140
+ // poll for beacon id or for pending status to change
141
+ while (Date.now() - start < timeoutMs) {
142
+ const beaconId = sessionStorage.getItem("ai12zBeaconId");
143
+ if (beaconId)
144
+ return beaconId;
145
+ const state = getBeaconRequestState();
146
+ // if there's no pending request any more, break and let caller proceed
147
+ if (state.status !== "pending")
148
+ break;
149
+ // sleep briefly
150
+ await new Promise(resolve => setTimeout(resolve, 200));
151
+ }
152
+ return sessionStorage.getItem("ai12zBeaconId");
153
+ }
154
+ // Hosts for which beacon creation and conversation setting should be disabled.
155
+ let excludedBeaconHosts = ["ai12z.net"];
156
+ function isHostExcluded() {
157
+ try {
158
+ const hostname = window.location.hostname.toLowerCase();
159
+ return excludedBeaconHosts.some(h => h && (hostname === h || hostname.endsWith(`.${h}`)));
160
+ }
161
+ catch (_a) {
162
+ return false;
163
+ }
164
+ }
165
+ function shouldCreateBeacon() {
166
+ const beaconId = sessionStorage.getItem("ai12zBeaconId");
167
+ if (beaconId) {
168
+ return false;
169
+ }
170
+ const state = getBeaconRequestState();
171
+ const signature = getBeaconRequestSignature();
172
+ if (state.signature === signature && (state.status === "pending" || state.status === "sent")) {
173
+ return false;
174
+ }
175
+ state.signature = signature;
176
+ state.status = "pending";
177
+ return true;
178
+ }
179
+ function markBeaconCreateResult(status) {
180
+ const state = getBeaconRequestState();
181
+ const signature = getBeaconRequestSignature();
182
+ if (state.signature !== signature)
183
+ return;
184
+ state.status = status;
185
+ if (!status) {
186
+ delete state.signature;
187
+ }
188
+ }
189
+ function hasUtmParams(params) {
190
+ return ["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term"].some(param => {
191
+ const value = params.get(param);
192
+ return value !== null && value.trim() !== "";
193
+ });
194
+ }
195
+ function shouldTrackVisit(detectedEngine) {
196
+ const params = new URL(window.location.href).searchParams;
197
+ const hasUtm = hasUtmParams(params);
198
+ const hasReferrer = detectedEngine !== "direct";
199
+ return hasUtm || hasReferrer;
200
+ }
201
+ function buildBeacon() {
202
+ var _a, _b, _c;
203
+ const detectedEngine = detectEngine();
204
+ const url = new URL(window.location.href);
205
+ const referrer = getReferrerUrl();
206
+ const params = url.searchParams;
207
+ return {
208
+ engine: detectedEngine === "direct" ? undefined : detectedEngine,
209
+ engineType: hasSupportedEngine(detectedEngine) ? inferEngineType(detectedEngine) : undefined,
210
+ referrerDomain: (_a = referrer === null || referrer === void 0 ? void 0 : referrer.hostname) !== null && _a !== void 0 ? _a : "",
211
+ landingPage: {
212
+ url: window.location.href,
213
+ path: window.location.pathname,
214
+ title: (_b = document.title) !== null && _b !== void 0 ? _b : "",
215
+ },
216
+ utm: (() => {
217
+ // keep raw utm fields for telemetry but cap lengths and strip control chars
218
+ const sanitizeForStorage = (v) => {
219
+ if (v === null || v === undefined)
220
+ return null;
221
+ // remove line breaks and control characters, trim, cap length
222
+ const cleaned = v.replace(/[\r\n\t]+/g, " ").trim();
223
+ return cleaned.length > 256 ? cleaned.slice(0, 256) : cleaned;
224
+ };
225
+ return {
226
+ source: sanitizeForStorage(params.get("utm_source")),
227
+ medium: sanitizeForStorage(params.get("utm_medium")),
228
+ campaign: sanitizeForStorage(params.get("utm_campaign")),
229
+ content: sanitizeForStorage(params.get("utm_content")),
230
+ term: sanitizeForStorage(params.get("utm_term")),
231
+ };
232
+ })(),
233
+ device: {
234
+ category: detectDeviceCategory(),
235
+ browser: detectBrowser(),
236
+ operatingSystem: detectOS(),
237
+ language: (_c = navigator.language) !== null && _c !== void 0 ? _c : "",
238
+ },
239
+ };
240
+ }
241
+ async function ensureBeacon(apiKey, force = false) {
242
+ const existingBeaconId = sessionStorage.getItem("ai12zBeaconId");
243
+ // If host is excluded, do not create or return a beacon id
244
+ if (isHostExcluded()) {
245
+ return null;
246
+ }
247
+ if (existingBeaconId) {
248
+ return existingBeaconId;
249
+ }
250
+ const detectedEngine = detectEngine();
251
+ if (!force && !shouldTrackVisit(detectedEngine)) {
252
+ return null;
253
+ }
254
+ // If caller requested force and there's already an in-flight create
255
+ // request, wait briefly for it to complete so we can reuse its beacon id
256
+ if (force) {
257
+ const state = getBeaconRequestState();
258
+ if (state.status === "pending") {
259
+ const waitedBeaconId = await waitForPendingBeacon();
260
+ if (waitedBeaconId)
261
+ return waitedBeaconId;
262
+ // if waiting didn't produce an id, fall through and attempt creation
263
+ }
264
+ }
265
+ if (!shouldCreateBeacon()) {
266
+ return sessionStorage.getItem("ai12zBeaconId");
267
+ }
268
+ try {
269
+ const response = await utils.createBeacon({
270
+ apiKey,
271
+ beacon: buildBeacon(),
272
+ });
273
+ sessionStorage.setItem("ai12zBeaconId", response.beaconId);
274
+ markBeaconCreateResult("sent");
275
+ return response.beaconId;
276
+ }
277
+ catch (e) {
278
+ markBeaconCreateResult(undefined);
279
+ throw e;
280
+ }
281
+ }
282
+ async function initBeacon(apiKey) {
283
+ try {
284
+ await ensureBeacon(apiKey);
285
+ }
286
+ catch (e) {
287
+ console.error("Failed to initialize beacon:", e);
288
+ }
289
+ }
290
+ async function setConversationId(apiKey, conversationId) {
291
+ if (!conversationId) {
292
+ return;
293
+ }
294
+ // Do not set conversation id on excluded hosts
295
+ if (isHostExcluded()) {
296
+ return;
297
+ }
298
+ const existingConversationId = sessionStorage.getItem("ai12zBeaconConversationId");
299
+ if (existingConversationId) {
300
+ return;
301
+ }
302
+ try {
303
+ // Force beacon creation if it doesn't already exist
304
+ const beaconId = await ensureBeacon(apiKey, true);
305
+ if (!beaconId) {
306
+ return;
307
+ }
308
+ await utils.setBeaconConversation({
309
+ apiKey,
310
+ beaconId,
311
+ conversationId,
312
+ });
313
+ sessionStorage.setItem("ai12zBeaconConversationId", conversationId);
314
+ }
315
+ catch (e) {
316
+ console.error("Failed to update beacon conversation:", e);
317
+ }
318
+ }
319
+
320
+ exports.initBeacon = initBeacon;
321
+ exports.setConversationId = setConversationId;
@@ -10,7 +10,7 @@ var ai12zInlineSearch_entry = require('./ai12z-inline-search.entry.cjs.js');
10
10
  var ai12zForm_entry = require('./ai12z-form.entry.cjs.js');
11
11
  var ai12zContainer_entry = require('./ai12z-container.entry.cjs.js');
12
12
  require('./index-v8T1EJAJ.js');
13
- require('./beacon-BXbtC1CF.js');
13
+ require('./beacon-B9ZWQpG6.js');
14
14
  require('./utils-C2m26j54.js');
15
15
  require('./response-adapter-CKKyyhMj.js');
16
16
  require('./processCarouselData-Dl_WYwVE.js');