@blotoutio/providers-shop-gpt-sdk 1.31.0 → 1.31.2

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 (4) hide show
  1. package/index.cjs.js +89 -32
  2. package/index.js +89 -32
  3. package/index.mjs +89 -32
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -1018,7 +1018,7 @@ const init = (params) => {
1018
1018
  error('Error in setting the sessionStorage for previewShopGPT');
1019
1019
  }
1020
1020
  }
1021
- const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, supportPrompts, searchSuggestions, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, metafieldDisplayName, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
1021
+ const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, supportPrompts, searchSuggestions, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, metafieldDisplayName, showClassicChatbot, chatbotIconType, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
1022
1022
  const experiment = createExperiment({
1023
1023
  name: getExperimentName(mode),
1024
1024
  userId: params.userId,
@@ -1088,6 +1088,8 @@ const init = (params) => {
1088
1088
  loadUIManually,
1089
1089
  userId: params.userId,
1090
1090
  metafieldDisplayName,
1091
+ showClassicChatbot,
1092
+ chatbotIconType,
1091
1093
  });
1092
1094
  const searchParams = new URLSearchParams(window.location.search);
1093
1095
  const hasSource = searchParams.get('utm_source') === 'shopgpt';
@@ -7442,6 +7444,7 @@ const markdown = (text) => {
7442
7444
  const rx_heading = /(?=^|>|\n)([>\s]*?)(#{1,6}) (.*?)( #*)? *(?=\n|$)/g;
7443
7445
  const rx_para = /(?=^|>|\n)\s*\n+([^<]+?)\n+\s*(?=\n|<|$)/g;
7444
7446
  const rx_stash = /-\d+\uf8ff/g;
7447
+ const rx_autolink = /(^|[^<\w])(https?:\/\/[^\s<>"']+)/g;
7445
7448
  const stash = {};
7446
7449
  let si = 0;
7447
7450
  function replace(rex, fn) {
@@ -7506,6 +7509,10 @@ const markdown = (text) => {
7506
7509
  : p6;
7507
7510
  return `${si}\uf8ff`;
7508
7511
  });
7512
+ replace(rx_autolink, (_, prefix, url) => {
7513
+ stash[--si] = `<a href="${url}" rel="noopener" target="_blank">${url}</a>`;
7514
+ return `${prefix}${si}\uf8ff`;
7515
+ });
7509
7516
  replace(rx_table, (_, table) => {
7510
7517
  var _a;
7511
7518
  const sep = ((_a = table.match(rx_thead)) === null || _a === void 0 ? void 0 : _a[1]) || '';
@@ -7667,6 +7674,23 @@ MarkdownRenderer.styles = i$4 `
7667
7674
  .markdown-content li:last-child {
7668
7675
  margin-bottom: 0;
7669
7676
  }
7677
+
7678
+ .markdown-content a {
7679
+ color: #0066cc;
7680
+ text-decoration: underline;
7681
+ word-break: break-all;
7682
+ overflow-wrap: break-word;
7683
+ hyphens: auto;
7684
+ }
7685
+
7686
+ .markdown-content a:hover {
7687
+ color: #0052a3;
7688
+ text-decoration: underline;
7689
+ }
7690
+
7691
+ .markdown-content a:visited {
7692
+ color: #551a8b;
7693
+ }
7670
7694
  `;
7671
7695
  __decorate([
7672
7696
  n$1({ type: String }),
@@ -9409,43 +9433,53 @@ if (!customElements.get('bt-user-form')) {
9409
9433
  customElements.define('bt-user-form', BTUserForm);
9410
9434
  }
9411
9435
 
9436
+ const chatIconStyles = i$4 `
9437
+ .chat-icon {
9438
+ border: none;
9439
+ cursor: pointer;
9440
+ width: 60px;
9441
+ height: 58px;
9442
+ background-color: #020617;
9443
+ border-radius: 50%;
9444
+ display: flex;
9445
+ justify-content: center;
9446
+ align-items: center;
9447
+ box-shadow: 0px 10px 10px -5px #0000000a;
9448
+ }
9449
+ `;
9450
+
9451
+ var _ChatIcon_sheet;
9412
9452
  const chatIcon = b `<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
9413
9453
  <path d="M13.9999 6.99999V2.33333H9.33325M2.33325 14H4.66659M10.4999 12.8333V15.1667M17.4999 12.8333V15.1667M23.3333 14H25.6666M9.33325 21L4.66659 25.6667V9.33333C4.66659 8.71449 4.91242 8.121 5.35 7.68341C5.78759 7.24583 6.38108 6.99999 6.99992 6.99999H20.9999C21.6188 6.99999 22.2122 7.24583 22.6498 7.68341C23.0874 8.121 23.3333 8.71449 23.3333 9.33333V18.6667C23.3333 19.2855 23.0874 19.879 22.6498 20.3166C22.2122 20.7542 21.6188 21 20.9999 21H9.33325Z" stroke="white" stroke-linecap="round" stroke-linejoin="round"/>
9414
9454
  </svg>`;
9415
9455
  class ChatIcon extends i$1 {
9416
9456
  constructor() {
9417
9457
  super(...arguments);
9418
- this.isStylesheetInjected = false;
9458
+ _ChatIcon_sheet.set(this, null);
9419
9459
  }
9420
9460
  connectedCallback() {
9421
9461
  super.connectedCallback();
9422
- if (!this.isStylesheetInjected && this.css) {
9423
- const sheet = new CSSStyleSheet();
9424
- sheet.replaceSync(this.css);
9425
- this.shadowRoot.adoptedStyleSheets.push(sheet);
9426
- this.isStylesheetInjected = true;
9462
+ this.updateAdoptedStylesheet();
9463
+ }
9464
+ updated(changedProperties) {
9465
+ if (changedProperties.has('css')) {
9466
+ this.updateAdoptedStylesheet();
9427
9467
  }
9428
9468
  }
9469
+ updateAdoptedStylesheet() {
9470
+ var _a;
9471
+ if (!__classPrivateFieldGet(this, _ChatIcon_sheet, "f")) {
9472
+ __classPrivateFieldSet(this, _ChatIcon_sheet, new CSSStyleSheet(), "f");
9473
+ this.shadowRoot.adoptedStyleSheets.push(__classPrivateFieldGet(this, _ChatIcon_sheet, "f"));
9474
+ }
9475
+ __classPrivateFieldGet(this, _ChatIcon_sheet, "f").replaceSync((_a = this.css) !== null && _a !== void 0 ? _a : '');
9476
+ }
9429
9477
  render() {
9430
9478
  return x ` <div class="chat-icon">${chatIcon}</div> `;
9431
9479
  }
9432
9480
  }
9433
- ChatIcon.styles = [
9434
- i$4 `
9435
- .chat-icon {
9436
- border: none;
9437
- cursor: pointer;
9438
- width: 60px;
9439
- height: 58px;
9440
- background-color: #020617;
9441
- border-radius: 50%;
9442
- display: flex;
9443
- justify-content: center;
9444
- align-items: center;
9445
- box-shadow: 0px 10px 10px -5px #0000000a;
9446
- }
9447
- `,
9448
- ];
9481
+ _ChatIcon_sheet = new WeakMap();
9482
+ ChatIcon.styles = [chatIconStyles];
9449
9483
  __decorate([
9450
9484
  n$1({ type: String }),
9451
9485
  __metadata("design:type", String)
@@ -11035,6 +11069,11 @@ class ShopGPT extends i$1 {
11035
11069
  if (changedProperties.has('css')) {
11036
11070
  this.updateAdoptedStylesheet();
11037
11071
  }
11072
+ if (this.showClassicChatbot &&
11073
+ this.shouldShowChatbotWidget() &&
11074
+ !this.nudgeTimer) {
11075
+ this.startNudgeTimer();
11076
+ }
11038
11077
  }
11039
11078
  updateAdoptedStylesheet() {
11040
11079
  var _a;
@@ -11592,6 +11631,28 @@ class ShopGPT extends i$1 {
11592
11631
  </dialog>
11593
11632
  `;
11594
11633
  }
11634
+ shouldShowPopupViewMini() {
11635
+ return (!this.showClassicChatbot &&
11636
+ !this.miniPopupSeen &&
11637
+ this.modalState !== 'open' &&
11638
+ !isPopupViewMiniMinimised(this.destination) &&
11639
+ !isUserInteracted(this.destination));
11640
+ }
11641
+ shouldShowChatbotWidget() {
11642
+ return (this.showClassicChatbot ||
11643
+ this.miniPopupSeen ||
11644
+ this.modalState === 'open' ||
11645
+ isPopupViewMiniMinimised(this.destination) ||
11646
+ isUserInteracted(this.destination));
11647
+ }
11648
+ renderChatbotIcon() {
11649
+ if (this.showClassicChatbot) {
11650
+ return this.chatbotIconType === 'chat-icon'
11651
+ ? x `<chat-icon .css=${this.css}></chat-icon>`
11652
+ : x `<chatbot-icon .css=${this.css}></chatbot-icon>`;
11653
+ }
11654
+ return x `<chatbot-icon .css=${this.css}></chatbot-icon>`;
11655
+ }
11595
11656
  modalMode() {
11596
11657
  var _a, _b, _c, _d;
11597
11658
  const thread = this.chatThreads.get(this.selectedThreadId);
@@ -11643,10 +11704,7 @@ class ShopGPT extends i$1 {
11643
11704
  ></popup-view>
11644
11705
  </div>`
11645
11706
  : E}
11646
- ${!this.miniPopupSeen &&
11647
- this.modalState !== 'open' &&
11648
- !isPopupViewMiniMinimised(this.destination) &&
11649
- !isUserInteracted(this.destination)
11707
+ ${this.shouldShowPopupViewMini()
11650
11708
  ? x ` <div
11651
11709
  id="shop-gpt-mini-modal"
11652
11710
  @minimize-mini=${this.handlePopUpViewMinimised}
@@ -11660,10 +11718,7 @@ class ShopGPT extends i$1 {
11660
11718
  ></popup-view-mini>
11661
11719
  </div>`
11662
11720
  : E}
11663
- ${this.miniPopupSeen ||
11664
- this.modalState === 'open' ||
11665
- isPopupViewMiniMinimised(this.destination) ||
11666
- isUserInteracted(this.destination)
11721
+ ${this.shouldShowChatbotWidget()
11667
11722
  ? x ` <div class="chatbot-widget">
11668
11723
  <button
11669
11724
  @click=${(e) => {
@@ -11676,7 +11731,7 @@ class ShopGPT extends i$1 {
11676
11731
  }
11677
11732
  }}
11678
11733
  >
11679
- <chatbot-icon .css=${this.css}></chatbot-icon>
11734
+ ${this.renderChatbotIcon()}
11680
11735
  </button>
11681
11736
  ${(hasNudgeOverride() || ((_b = this.nudge) === null || _b === void 0 ? void 0 : _b.show)) && this.showNudge
11682
11737
  ? x ` <div class="nudge">
@@ -11875,6 +11930,8 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
11875
11930
  shopGPT.loadUIManually = params.loadUIManually;
11876
11931
  shopGPT.userId = params.userId;
11877
11932
  shopGPT.metafieldDisplayName = params.metafieldDisplayName;
11933
+ shopGPT.showClassicChatbot = params.showClassicChatbot;
11934
+ shopGPT.chatbotIconType = params.chatbotIconType;
11878
11935
  },
11879
11936
  loadUI() {
11880
11937
  if (!shopGPT) {
package/index.js CHANGED
@@ -1019,7 +1019,7 @@ var ProvidersShopGptSdk = (function () {
1019
1019
  error('Error in setting the sessionStorage for previewShopGPT');
1020
1020
  }
1021
1021
  }
1022
- const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, supportPrompts, searchSuggestions, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, metafieldDisplayName, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
1022
+ const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, supportPrompts, searchSuggestions, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, metafieldDisplayName, showClassicChatbot, chatbotIconType, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
1023
1023
  const experiment = createExperiment({
1024
1024
  name: getExperimentName(mode),
1025
1025
  userId: params.userId,
@@ -1089,6 +1089,8 @@ var ProvidersShopGptSdk = (function () {
1089
1089
  loadUIManually,
1090
1090
  userId: params.userId,
1091
1091
  metafieldDisplayName,
1092
+ showClassicChatbot,
1093
+ chatbotIconType,
1092
1094
  });
1093
1095
  const searchParams = new URLSearchParams(window.location.search);
1094
1096
  const hasSource = searchParams.get('utm_source') === 'shopgpt';
@@ -7443,6 +7445,7 @@ var ProvidersShopGptSdk = (function () {
7443
7445
  const rx_heading = /(?=^|>|\n)([>\s]*?)(#{1,6}) (.*?)( #*)? *(?=\n|$)/g;
7444
7446
  const rx_para = /(?=^|>|\n)\s*\n+([^<]+?)\n+\s*(?=\n|<|$)/g;
7445
7447
  const rx_stash = /-\d+\uf8ff/g;
7448
+ const rx_autolink = /(^|[^<\w])(https?:\/\/[^\s<>"']+)/g;
7446
7449
  const stash = {};
7447
7450
  let si = 0;
7448
7451
  function replace(rex, fn) {
@@ -7507,6 +7510,10 @@ var ProvidersShopGptSdk = (function () {
7507
7510
  : p6;
7508
7511
  return `${si}\uf8ff`;
7509
7512
  });
7513
+ replace(rx_autolink, (_, prefix, url) => {
7514
+ stash[--si] = `<a href="${url}" rel="noopener" target="_blank">${url}</a>`;
7515
+ return `${prefix}${si}\uf8ff`;
7516
+ });
7510
7517
  replace(rx_table, (_, table) => {
7511
7518
  var _a;
7512
7519
  const sep = ((_a = table.match(rx_thead)) === null || _a === void 0 ? void 0 : _a[1]) || '';
@@ -7668,6 +7675,23 @@ var ProvidersShopGptSdk = (function () {
7668
7675
  .markdown-content li:last-child {
7669
7676
  margin-bottom: 0;
7670
7677
  }
7678
+
7679
+ .markdown-content a {
7680
+ color: #0066cc;
7681
+ text-decoration: underline;
7682
+ word-break: break-all;
7683
+ overflow-wrap: break-word;
7684
+ hyphens: auto;
7685
+ }
7686
+
7687
+ .markdown-content a:hover {
7688
+ color: #0052a3;
7689
+ text-decoration: underline;
7690
+ }
7691
+
7692
+ .markdown-content a:visited {
7693
+ color: #551a8b;
7694
+ }
7671
7695
  `;
7672
7696
  __decorate([
7673
7697
  n$1({ type: String }),
@@ -9410,43 +9434,53 @@ ${this.comment ? this.comment : E}</textarea
9410
9434
  customElements.define('bt-user-form', BTUserForm);
9411
9435
  }
9412
9436
 
9437
+ const chatIconStyles = i$4 `
9438
+ .chat-icon {
9439
+ border: none;
9440
+ cursor: pointer;
9441
+ width: 60px;
9442
+ height: 58px;
9443
+ background-color: #020617;
9444
+ border-radius: 50%;
9445
+ display: flex;
9446
+ justify-content: center;
9447
+ align-items: center;
9448
+ box-shadow: 0px 10px 10px -5px #0000000a;
9449
+ }
9450
+ `;
9451
+
9452
+ var _ChatIcon_sheet;
9413
9453
  const chatIcon = b `<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
9414
9454
  <path d="M13.9999 6.99999V2.33333H9.33325M2.33325 14H4.66659M10.4999 12.8333V15.1667M17.4999 12.8333V15.1667M23.3333 14H25.6666M9.33325 21L4.66659 25.6667V9.33333C4.66659 8.71449 4.91242 8.121 5.35 7.68341C5.78759 7.24583 6.38108 6.99999 6.99992 6.99999H20.9999C21.6188 6.99999 22.2122 7.24583 22.6498 7.68341C23.0874 8.121 23.3333 8.71449 23.3333 9.33333V18.6667C23.3333 19.2855 23.0874 19.879 22.6498 20.3166C22.2122 20.7542 21.6188 21 20.9999 21H9.33325Z" stroke="white" stroke-linecap="round" stroke-linejoin="round"/>
9415
9455
  </svg>`;
9416
9456
  class ChatIcon extends i$1 {
9417
9457
  constructor() {
9418
9458
  super(...arguments);
9419
- this.isStylesheetInjected = false;
9459
+ _ChatIcon_sheet.set(this, null);
9420
9460
  }
9421
9461
  connectedCallback() {
9422
9462
  super.connectedCallback();
9423
- if (!this.isStylesheetInjected && this.css) {
9424
- const sheet = new CSSStyleSheet();
9425
- sheet.replaceSync(this.css);
9426
- this.shadowRoot.adoptedStyleSheets.push(sheet);
9427
- this.isStylesheetInjected = true;
9463
+ this.updateAdoptedStylesheet();
9464
+ }
9465
+ updated(changedProperties) {
9466
+ if (changedProperties.has('css')) {
9467
+ this.updateAdoptedStylesheet();
9428
9468
  }
9429
9469
  }
9470
+ updateAdoptedStylesheet() {
9471
+ var _a;
9472
+ if (!__classPrivateFieldGet(this, _ChatIcon_sheet, "f")) {
9473
+ __classPrivateFieldSet(this, _ChatIcon_sheet, new CSSStyleSheet(), "f");
9474
+ this.shadowRoot.adoptedStyleSheets.push(__classPrivateFieldGet(this, _ChatIcon_sheet, "f"));
9475
+ }
9476
+ __classPrivateFieldGet(this, _ChatIcon_sheet, "f").replaceSync((_a = this.css) !== null && _a !== void 0 ? _a : '');
9477
+ }
9430
9478
  render() {
9431
9479
  return x ` <div class="chat-icon">${chatIcon}</div> `;
9432
9480
  }
9433
9481
  }
9434
- ChatIcon.styles = [
9435
- i$4 `
9436
- .chat-icon {
9437
- border: none;
9438
- cursor: pointer;
9439
- width: 60px;
9440
- height: 58px;
9441
- background-color: #020617;
9442
- border-radius: 50%;
9443
- display: flex;
9444
- justify-content: center;
9445
- align-items: center;
9446
- box-shadow: 0px 10px 10px -5px #0000000a;
9447
- }
9448
- `,
9449
- ];
9482
+ _ChatIcon_sheet = new WeakMap();
9483
+ ChatIcon.styles = [chatIconStyles];
9450
9484
  __decorate([
9451
9485
  n$1({ type: String }),
9452
9486
  __metadata("design:type", String)
@@ -11036,6 +11070,11 @@ ${this.comment ? this.comment : E}</textarea
11036
11070
  if (changedProperties.has('css')) {
11037
11071
  this.updateAdoptedStylesheet();
11038
11072
  }
11073
+ if (this.showClassicChatbot &&
11074
+ this.shouldShowChatbotWidget() &&
11075
+ !this.nudgeTimer) {
11076
+ this.startNudgeTimer();
11077
+ }
11039
11078
  }
11040
11079
  updateAdoptedStylesheet() {
11041
11080
  var _a;
@@ -11593,6 +11632,28 @@ ${this.comment ? this.comment : E}</textarea
11593
11632
  </dialog>
11594
11633
  `;
11595
11634
  }
11635
+ shouldShowPopupViewMini() {
11636
+ return (!this.showClassicChatbot &&
11637
+ !this.miniPopupSeen &&
11638
+ this.modalState !== 'open' &&
11639
+ !isPopupViewMiniMinimised(this.destination) &&
11640
+ !isUserInteracted(this.destination));
11641
+ }
11642
+ shouldShowChatbotWidget() {
11643
+ return (this.showClassicChatbot ||
11644
+ this.miniPopupSeen ||
11645
+ this.modalState === 'open' ||
11646
+ isPopupViewMiniMinimised(this.destination) ||
11647
+ isUserInteracted(this.destination));
11648
+ }
11649
+ renderChatbotIcon() {
11650
+ if (this.showClassicChatbot) {
11651
+ return this.chatbotIconType === 'chat-icon'
11652
+ ? x `<chat-icon .css=${this.css}></chat-icon>`
11653
+ : x `<chatbot-icon .css=${this.css}></chatbot-icon>`;
11654
+ }
11655
+ return x `<chatbot-icon .css=${this.css}></chatbot-icon>`;
11656
+ }
11596
11657
  modalMode() {
11597
11658
  var _a, _b, _c, _d;
11598
11659
  const thread = this.chatThreads.get(this.selectedThreadId);
@@ -11644,10 +11705,7 @@ ${this.comment ? this.comment : E}</textarea
11644
11705
  ></popup-view>
11645
11706
  </div>`
11646
11707
  : E}
11647
- ${!this.miniPopupSeen &&
11648
- this.modalState !== 'open' &&
11649
- !isPopupViewMiniMinimised(this.destination) &&
11650
- !isUserInteracted(this.destination)
11708
+ ${this.shouldShowPopupViewMini()
11651
11709
  ? x ` <div
11652
11710
  id="shop-gpt-mini-modal"
11653
11711
  @minimize-mini=${this.handlePopUpViewMinimised}
@@ -11661,10 +11719,7 @@ ${this.comment ? this.comment : E}</textarea
11661
11719
  ></popup-view-mini>
11662
11720
  </div>`
11663
11721
  : E}
11664
- ${this.miniPopupSeen ||
11665
- this.modalState === 'open' ||
11666
- isPopupViewMiniMinimised(this.destination) ||
11667
- isUserInteracted(this.destination)
11722
+ ${this.shouldShowChatbotWidget()
11668
11723
  ? x ` <div class="chatbot-widget">
11669
11724
  <button
11670
11725
  @click=${(e) => {
@@ -11677,7 +11732,7 @@ ${this.comment ? this.comment : E}</textarea
11677
11732
  }
11678
11733
  }}
11679
11734
  >
11680
- <chatbot-icon .css=${this.css}></chatbot-icon>
11735
+ ${this.renderChatbotIcon()}
11681
11736
  </button>
11682
11737
  ${(hasNudgeOverride() || ((_b = this.nudge) === null || _b === void 0 ? void 0 : _b.show)) && this.showNudge
11683
11738
  ? x ` <div class="nudge">
@@ -11876,6 +11931,8 @@ ${this.comment ? this.comment : E}</textarea
11876
11931
  shopGPT.loadUIManually = params.loadUIManually;
11877
11932
  shopGPT.userId = params.userId;
11878
11933
  shopGPT.metafieldDisplayName = params.metafieldDisplayName;
11934
+ shopGPT.showClassicChatbot = params.showClassicChatbot;
11935
+ shopGPT.chatbotIconType = params.chatbotIconType;
11879
11936
  },
11880
11937
  loadUI() {
11881
11938
  if (!shopGPT) {
package/index.mjs CHANGED
@@ -1016,7 +1016,7 @@ const init = (params) => {
1016
1016
  error('Error in setting the sessionStorage for previewShopGPT');
1017
1017
  }
1018
1018
  }
1019
- const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, supportPrompts, searchSuggestions, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, metafieldDisplayName, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
1019
+ const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, supportPrompts, searchSuggestions, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, metafieldDisplayName, showClassicChatbot, chatbotIconType, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
1020
1020
  const experiment = createExperiment({
1021
1021
  name: getExperimentName(mode),
1022
1022
  userId: params.userId,
@@ -1086,6 +1086,8 @@ const init = (params) => {
1086
1086
  loadUIManually,
1087
1087
  userId: params.userId,
1088
1088
  metafieldDisplayName,
1089
+ showClassicChatbot,
1090
+ chatbotIconType,
1089
1091
  });
1090
1092
  const searchParams = new URLSearchParams(window.location.search);
1091
1093
  const hasSource = searchParams.get('utm_source') === 'shopgpt';
@@ -7440,6 +7442,7 @@ const markdown = (text) => {
7440
7442
  const rx_heading = /(?=^|>|\n)([>\s]*?)(#{1,6}) (.*?)( #*)? *(?=\n|$)/g;
7441
7443
  const rx_para = /(?=^|>|\n)\s*\n+([^<]+?)\n+\s*(?=\n|<|$)/g;
7442
7444
  const rx_stash = /-\d+\uf8ff/g;
7445
+ const rx_autolink = /(^|[^<\w])(https?:\/\/[^\s<>"']+)/g;
7443
7446
  const stash = {};
7444
7447
  let si = 0;
7445
7448
  function replace(rex, fn) {
@@ -7504,6 +7507,10 @@ const markdown = (text) => {
7504
7507
  : p6;
7505
7508
  return `${si}\uf8ff`;
7506
7509
  });
7510
+ replace(rx_autolink, (_, prefix, url) => {
7511
+ stash[--si] = `<a href="${url}" rel="noopener" target="_blank">${url}</a>`;
7512
+ return `${prefix}${si}\uf8ff`;
7513
+ });
7507
7514
  replace(rx_table, (_, table) => {
7508
7515
  var _a;
7509
7516
  const sep = ((_a = table.match(rx_thead)) === null || _a === void 0 ? void 0 : _a[1]) || '';
@@ -7665,6 +7672,23 @@ MarkdownRenderer.styles = i$4 `
7665
7672
  .markdown-content li:last-child {
7666
7673
  margin-bottom: 0;
7667
7674
  }
7675
+
7676
+ .markdown-content a {
7677
+ color: #0066cc;
7678
+ text-decoration: underline;
7679
+ word-break: break-all;
7680
+ overflow-wrap: break-word;
7681
+ hyphens: auto;
7682
+ }
7683
+
7684
+ .markdown-content a:hover {
7685
+ color: #0052a3;
7686
+ text-decoration: underline;
7687
+ }
7688
+
7689
+ .markdown-content a:visited {
7690
+ color: #551a8b;
7691
+ }
7668
7692
  `;
7669
7693
  __decorate([
7670
7694
  n$1({ type: String }),
@@ -9407,43 +9431,53 @@ if (!customElements.get('bt-user-form')) {
9407
9431
  customElements.define('bt-user-form', BTUserForm);
9408
9432
  }
9409
9433
 
9434
+ const chatIconStyles = i$4 `
9435
+ .chat-icon {
9436
+ border: none;
9437
+ cursor: pointer;
9438
+ width: 60px;
9439
+ height: 58px;
9440
+ background-color: #020617;
9441
+ border-radius: 50%;
9442
+ display: flex;
9443
+ justify-content: center;
9444
+ align-items: center;
9445
+ box-shadow: 0px 10px 10px -5px #0000000a;
9446
+ }
9447
+ `;
9448
+
9449
+ var _ChatIcon_sheet;
9410
9450
  const chatIcon = b `<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
9411
9451
  <path d="M13.9999 6.99999V2.33333H9.33325M2.33325 14H4.66659M10.4999 12.8333V15.1667M17.4999 12.8333V15.1667M23.3333 14H25.6666M9.33325 21L4.66659 25.6667V9.33333C4.66659 8.71449 4.91242 8.121 5.35 7.68341C5.78759 7.24583 6.38108 6.99999 6.99992 6.99999H20.9999C21.6188 6.99999 22.2122 7.24583 22.6498 7.68341C23.0874 8.121 23.3333 8.71449 23.3333 9.33333V18.6667C23.3333 19.2855 23.0874 19.879 22.6498 20.3166C22.2122 20.7542 21.6188 21 20.9999 21H9.33325Z" stroke="white" stroke-linecap="round" stroke-linejoin="round"/>
9412
9452
  </svg>`;
9413
9453
  class ChatIcon extends i$1 {
9414
9454
  constructor() {
9415
9455
  super(...arguments);
9416
- this.isStylesheetInjected = false;
9456
+ _ChatIcon_sheet.set(this, null);
9417
9457
  }
9418
9458
  connectedCallback() {
9419
9459
  super.connectedCallback();
9420
- if (!this.isStylesheetInjected && this.css) {
9421
- const sheet = new CSSStyleSheet();
9422
- sheet.replaceSync(this.css);
9423
- this.shadowRoot.adoptedStyleSheets.push(sheet);
9424
- this.isStylesheetInjected = true;
9460
+ this.updateAdoptedStylesheet();
9461
+ }
9462
+ updated(changedProperties) {
9463
+ if (changedProperties.has('css')) {
9464
+ this.updateAdoptedStylesheet();
9425
9465
  }
9426
9466
  }
9467
+ updateAdoptedStylesheet() {
9468
+ var _a;
9469
+ if (!__classPrivateFieldGet(this, _ChatIcon_sheet, "f")) {
9470
+ __classPrivateFieldSet(this, _ChatIcon_sheet, new CSSStyleSheet(), "f");
9471
+ this.shadowRoot.adoptedStyleSheets.push(__classPrivateFieldGet(this, _ChatIcon_sheet, "f"));
9472
+ }
9473
+ __classPrivateFieldGet(this, _ChatIcon_sheet, "f").replaceSync((_a = this.css) !== null && _a !== void 0 ? _a : '');
9474
+ }
9427
9475
  render() {
9428
9476
  return x ` <div class="chat-icon">${chatIcon}</div> `;
9429
9477
  }
9430
9478
  }
9431
- ChatIcon.styles = [
9432
- i$4 `
9433
- .chat-icon {
9434
- border: none;
9435
- cursor: pointer;
9436
- width: 60px;
9437
- height: 58px;
9438
- background-color: #020617;
9439
- border-radius: 50%;
9440
- display: flex;
9441
- justify-content: center;
9442
- align-items: center;
9443
- box-shadow: 0px 10px 10px -5px #0000000a;
9444
- }
9445
- `,
9446
- ];
9479
+ _ChatIcon_sheet = new WeakMap();
9480
+ ChatIcon.styles = [chatIconStyles];
9447
9481
  __decorate([
9448
9482
  n$1({ type: String }),
9449
9483
  __metadata("design:type", String)
@@ -11033,6 +11067,11 @@ class ShopGPT extends i$1 {
11033
11067
  if (changedProperties.has('css')) {
11034
11068
  this.updateAdoptedStylesheet();
11035
11069
  }
11070
+ if (this.showClassicChatbot &&
11071
+ this.shouldShowChatbotWidget() &&
11072
+ !this.nudgeTimer) {
11073
+ this.startNudgeTimer();
11074
+ }
11036
11075
  }
11037
11076
  updateAdoptedStylesheet() {
11038
11077
  var _a;
@@ -11590,6 +11629,28 @@ class ShopGPT extends i$1 {
11590
11629
  </dialog>
11591
11630
  `;
11592
11631
  }
11632
+ shouldShowPopupViewMini() {
11633
+ return (!this.showClassicChatbot &&
11634
+ !this.miniPopupSeen &&
11635
+ this.modalState !== 'open' &&
11636
+ !isPopupViewMiniMinimised(this.destination) &&
11637
+ !isUserInteracted(this.destination));
11638
+ }
11639
+ shouldShowChatbotWidget() {
11640
+ return (this.showClassicChatbot ||
11641
+ this.miniPopupSeen ||
11642
+ this.modalState === 'open' ||
11643
+ isPopupViewMiniMinimised(this.destination) ||
11644
+ isUserInteracted(this.destination));
11645
+ }
11646
+ renderChatbotIcon() {
11647
+ if (this.showClassicChatbot) {
11648
+ return this.chatbotIconType === 'chat-icon'
11649
+ ? x `<chat-icon .css=${this.css}></chat-icon>`
11650
+ : x `<chatbot-icon .css=${this.css}></chatbot-icon>`;
11651
+ }
11652
+ return x `<chatbot-icon .css=${this.css}></chatbot-icon>`;
11653
+ }
11593
11654
  modalMode() {
11594
11655
  var _a, _b, _c, _d;
11595
11656
  const thread = this.chatThreads.get(this.selectedThreadId);
@@ -11641,10 +11702,7 @@ class ShopGPT extends i$1 {
11641
11702
  ></popup-view>
11642
11703
  </div>`
11643
11704
  : E}
11644
- ${!this.miniPopupSeen &&
11645
- this.modalState !== 'open' &&
11646
- !isPopupViewMiniMinimised(this.destination) &&
11647
- !isUserInteracted(this.destination)
11705
+ ${this.shouldShowPopupViewMini()
11648
11706
  ? x ` <div
11649
11707
  id="shop-gpt-mini-modal"
11650
11708
  @minimize-mini=${this.handlePopUpViewMinimised}
@@ -11658,10 +11716,7 @@ class ShopGPT extends i$1 {
11658
11716
  ></popup-view-mini>
11659
11717
  </div>`
11660
11718
  : E}
11661
- ${this.miniPopupSeen ||
11662
- this.modalState === 'open' ||
11663
- isPopupViewMiniMinimised(this.destination) ||
11664
- isUserInteracted(this.destination)
11719
+ ${this.shouldShowChatbotWidget()
11665
11720
  ? x ` <div class="chatbot-widget">
11666
11721
  <button
11667
11722
  @click=${(e) => {
@@ -11674,7 +11729,7 @@ class ShopGPT extends i$1 {
11674
11729
  }
11675
11730
  }}
11676
11731
  >
11677
- <chatbot-icon .css=${this.css}></chatbot-icon>
11732
+ ${this.renderChatbotIcon()}
11678
11733
  </button>
11679
11734
  ${(hasNudgeOverride() || ((_b = this.nudge) === null || _b === void 0 ? void 0 : _b.show)) && this.showNudge
11680
11735
  ? x ` <div class="nudge">
@@ -11873,6 +11928,8 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
11873
11928
  shopGPT.loadUIManually = params.loadUIManually;
11874
11929
  shopGPT.userId = params.userId;
11875
11930
  shopGPT.metafieldDisplayName = params.metafieldDisplayName;
11931
+ shopGPT.showClassicChatbot = params.showClassicChatbot;
11932
+ shopGPT.chatbotIconType = params.chatbotIconType;
11876
11933
  },
11877
11934
  loadUI() {
11878
11935
  if (!shopGPT) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-shop-gpt-sdk",
3
- "version": "1.31.0",
3
+ "version": "1.31.2",
4
4
  "description": "Shop GPT SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",