@blotoutio/providers-shop-gpt-sdk 1.8.0 → 1.9.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.
Files changed (4) hide show
  1. package/index.cjs.js +279 -77
  2. package/index.js +279 -77
  3. package/index.mjs +279 -77
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -472,7 +472,6 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
472
472
  return url;
473
473
  };
474
474
  const processQuery = async (query, threadId, productHandle) => {
475
- var _a;
476
475
  const response = await fetchImpl(getURL('/query'), {
477
476
  method: 'POST',
478
477
  headers: getHeaders(),
@@ -487,14 +486,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
487
486
  if (!response.ok) {
488
487
  throw new Error(`Failed to process the query - ${response.status}: ${await response.text()}`);
489
488
  }
490
- const data = (await response.json());
491
- return {
492
- messageId: data.messageId,
493
- message: data.message,
494
- products: (_a = data.products) === null || _a === void 0 ? void 0 : _a.filter((item) => !!item).map((item) => ({ ...item, quantity: 1 })),
495
- chatTitle: data.chatTitle,
496
- welcomePrompts: data.welcomePrompts,
497
- };
489
+ return response;
498
490
  };
499
491
  const fetchChatHistory = async (threadId) => {
500
492
  if (!threadId) {
@@ -628,7 +620,7 @@ const init = (params) => {
628
620
  // exit if not in top window
629
621
  return;
630
622
  }
631
- const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
623
+ const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, botIconUrl, css, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
632
624
  const experiment = createExperiment({
633
625
  name: getExperimentName(mode),
634
626
  userId: params.userId,
@@ -662,6 +654,8 @@ const init = (params) => {
662
654
  quickPrompts,
663
655
  merchantImage,
664
656
  latestThreadLoad: latestThreadLoad !== null && latestThreadLoad !== void 0 ? latestThreadLoad : DEFAULT_MAX_THREAD_AGE,
657
+ botIconUrl,
658
+ css,
665
659
  });
666
660
  }
667
661
  };
@@ -788,6 +782,14 @@ const scrollBarStyles = i$4 `
788
782
  const shopGPTStyles = i$4 `
789
783
  ${scrollBarStyles}
790
784
 
785
+ :host {
786
+ --shopgpt-primary: #001531;
787
+ --shopgpt-secondary: #172a41;
788
+ --shopgpt-white: #ffffff;
789
+ --shopgpt-border: #dbe2eb;
790
+ --shopgpt-warning: #ffcc81;
791
+ }
792
+
791
793
  * {
792
794
  box-sizing: border-box;
793
795
  }
@@ -820,6 +822,7 @@ const shopGPTStyles = i$4 `
820
822
  0px 20px 20px 0px rgba(0, 0, 0, 0.08);
821
823
  position: fixed;
822
824
  z-index: 2000;
825
+ background: var(--shopgpt-white);
823
826
 
824
827
  @media screen and (max-width: 768px) {
825
828
  min-height: unset;
@@ -838,21 +841,21 @@ const shopGPTStyles = i$4 `
838
841
  z-index: 1000;
839
842
 
840
843
  button {
841
- color: #ffffff;
844
+ color: var(--shopgpt-white);
842
845
  border: none;
843
846
  cursor: pointer;
844
847
  width: 56px;
845
848
  height: 56px;
846
- background-color: #001531;
849
+ background-color: var(--shopgpt-primary);
847
850
  border-radius: 50%;
848
851
  justify-content: center;
849
852
  align-items: center;
850
- box-shadow: 0 0 4px 1px #ffffff;
853
+ box-shadow: 0 0 4px 1px var(--shopgpt-white);
851
854
  }
852
855
 
853
856
  .chatbot-hover-text {
854
857
  position: absolute;
855
- color: #172a41;
858
+ color: var(--shopgpt-secondary);
856
859
  padding: 8px;
857
860
  white-space: nowrap;
858
861
  font-size: 16px;
@@ -865,7 +868,7 @@ const shopGPTStyles = i$4 `
865
868
  right: calc(100% + 5px);
866
869
 
867
870
  border-radius: 5px 5px 0px;
868
- background: #ffcc81;
871
+ background: var(--shopgpt-warning);
869
872
  box-shadow: 0px 4px 6px -1px rgba(0, 0, 0, 0.1),
870
873
  0px 2px 4px -1px rgba(0, 0, 0, 0.06);
871
874
 
@@ -887,7 +890,7 @@ const shopGPTStyles = i$4 `
887
890
  display: flex;
888
891
  overflow: hidden;
889
892
  height: 100%;
890
- background: #ffffff;
893
+ background: var(--shopgpt-white);
891
894
  justify-content: center;
892
895
  align-items: center;
893
896
  padding: 25px;
@@ -898,7 +901,7 @@ const shopGPTStyles = i$4 `
898
901
  .shopgpt-container {
899
902
  display: flex;
900
903
  gap: 1px;
901
- background: #dbe2eb;
904
+ background: var(--shopgpt-border);
902
905
  height: 100%;
903
906
  width: 100%;
904
907
 
@@ -1225,6 +1228,16 @@ class ChatThreads extends r$2 {
1225
1228
  constructor() {
1226
1229
  super(...arguments);
1227
1230
  this.deleteAllThreads = false;
1231
+ this.isStylesheetInjected = false;
1232
+ }
1233
+ connectedCallback() {
1234
+ super.connectedCallback();
1235
+ if (!this.isStylesheetInjected && this.css) {
1236
+ const sheet = new CSSStyleSheet();
1237
+ sheet.replaceSync(this.css);
1238
+ this.shadowRoot.adoptedStyleSheets.push(sheet);
1239
+ this.isStylesheetInjected = true;
1240
+ }
1228
1241
  }
1229
1242
  getDomain() {
1230
1243
  var _a;
@@ -1393,6 +1406,10 @@ __decorate([
1393
1406
  r(),
1394
1407
  __metadata("design:type", Object)
1395
1408
  ], ChatThreads.prototype, "deleteAllThreads", void 0);
1409
+ __decorate([
1410
+ n({ type: String }),
1411
+ __metadata("design:type", String)
1412
+ ], ChatThreads.prototype, "css", void 0);
1396
1413
  if (!customElements.get('chat-threads')) {
1397
1414
  customElements.define('chat-threads', ChatThreads);
1398
1415
  }
@@ -1831,8 +1848,18 @@ if (!customElements.get('products-list')) {
1831
1848
  }
1832
1849
 
1833
1850
  class ProductsSection extends r$2 {
1851
+ constructor() {
1852
+ super(...arguments);
1853
+ this.isStylesheetInjected = false;
1854
+ }
1834
1855
  connectedCallback() {
1835
1856
  super.connectedCallback();
1857
+ if (!this.isStylesheetInjected && this.css) {
1858
+ const sheet = new CSSStyleSheet();
1859
+ sheet.replaceSync(this.css);
1860
+ this.shadowRoot.adoptedStyleSheets.push(sheet);
1861
+ this.isStylesheetInjected = true;
1862
+ }
1836
1863
  }
1837
1864
  renderMerchantImage() {
1838
1865
  if (this.merchantImage) {
@@ -1909,6 +1936,10 @@ __decorate([
1909
1936
  e$3('.products'),
1910
1937
  __metadata("design:type", Object)
1911
1938
  ], ProductsSection.prototype, "productsEle", void 0);
1939
+ __decorate([
1940
+ n({ type: String }),
1941
+ __metadata("design:type", String)
1942
+ ], ProductsSection.prototype, "css", void 0);
1912
1943
  if (!customElements.get('products-section')) {
1913
1944
  customElements.define('products-section', ProductsSection);
1914
1945
  }
@@ -2025,8 +2056,8 @@ const chatSectionStyles = i$4 `
2025
2056
  }
2026
2057
 
2027
2058
  .chatbot-section.modal-view {
2028
- height: calc(100% - 121px);
2029
- padding: 0px 16px 44px;
2059
+ height: calc(100% - 93px);
2060
+ padding: 0px 16px 16px;
2030
2061
  gap: 16px;
2031
2062
  }
2032
2063
 
@@ -2175,6 +2206,9 @@ const chatSectionStyles = i$4 `
2175
2206
  border-radius: 5px;
2176
2207
  border: 1px solid #dbe2eb;
2177
2208
  background: #fff;
2209
+ width: 36px;
2210
+ height: 36px;
2211
+ box-sizing: border-box;
2178
2212
  }
2179
2213
 
2180
2214
  .line {
@@ -2411,6 +2445,17 @@ const chatSectionStyles = i$4 `
2411
2445
  }
2412
2446
  }
2413
2447
 
2448
+ footer {
2449
+ text-align: center;
2450
+ font-size: 10px;
2451
+ color: #4e647f;
2452
+ font-weight: 500;
2453
+
2454
+ a {
2455
+ text-decoration: none;
2456
+ }
2457
+ }
2458
+
2414
2459
  ${scrollBarStyles}
2415
2460
  `;
2416
2461
 
@@ -3080,12 +3125,12 @@ const markdown = (text) => {
3080
3125
  };
3081
3126
 
3082
3127
  class MarkdownRenderer extends r$2 {
3128
+ constructor() {
3129
+ super(...arguments);
3130
+ this.content = '';
3131
+ }
3083
3132
  render() {
3084
- // Remove lit markers from slot content
3085
- const slotContent = this.innerHTML
3086
- .trim()
3087
- .replace(/<!--\?lit\$[\d$]+-->/g, '');
3088
- return o(markdown(slotContent));
3133
+ return o(markdown(this.content));
3089
3134
  }
3090
3135
  }
3091
3136
  MarkdownRenderer.styles = i$4 `
@@ -3099,6 +3144,10 @@ MarkdownRenderer.styles = i$4 `
3099
3144
  }
3100
3145
  }
3101
3146
  `;
3147
+ __decorate([
3148
+ n({ type: String }),
3149
+ __metadata("design:type", Object)
3150
+ ], MarkdownRenderer.prototype, "content", void 0);
3102
3151
  if (!customElements.get('markdown-renderer')) {
3103
3152
  customElements.define('markdown-renderer', MarkdownRenderer);
3104
3153
  }
@@ -3554,6 +3603,16 @@ class ChatSection extends r$2 {
3554
3603
  this.showChatThreads = false;
3555
3604
  this.deleteAllThreads = false;
3556
3605
  this.userQuery = '';
3606
+ this.isStylesheetInjected = false;
3607
+ }
3608
+ connectedCallback() {
3609
+ super.connectedCallback();
3610
+ if (!this.isStylesheetInjected && this.css) {
3611
+ const sheet = new CSSStyleSheet();
3612
+ sheet.replaceSync(this.css);
3613
+ this.shadowRoot.adoptedStyleSheets.push(sheet);
3614
+ this.isStylesheetInjected = true;
3615
+ }
3557
3616
  }
3558
3617
  scrollToBottom() {
3559
3618
  var _a;
@@ -3624,12 +3683,12 @@ class ChatSection extends r$2 {
3624
3683
  return x `
3625
3684
  <div class="message-wrapper">
3626
3685
  <div class="message bot">
3627
- <div>
3628
- <div class="bot-icon">${botIcon}</div>
3629
- </div>
3686
+ <div>${this.renderBotIcon()}</div>
3630
3687
  <div>
3631
3688
  ${message.message
3632
- ? x ` <markdown-renderer>${message.message}</markdown-renderer>`
3689
+ ? x ` <markdown-renderer
3690
+ .content=${message.message}
3691
+ ></markdown-renderer>`
3633
3692
  : E}
3634
3693
  ${this.viewType !== 'modal' && ((_a = message.products) === null || _a === void 0 ? void 0 : _a[0])
3635
3694
  ? x `
@@ -3674,6 +3733,14 @@ class ChatSection extends r$2 {
3674
3733
  </div>
3675
3734
  `;
3676
3735
  }
3736
+ renderBotIcon() {
3737
+ if (this.botIconUrl) {
3738
+ return x `<div class="bot-icon">
3739
+ <img src=${this.botIconUrl} width="30" height="30" />
3740
+ </div>`;
3741
+ }
3742
+ return x ` <div class="bot-icon">${botIcon}</div> `;
3743
+ }
3677
3744
  chatWindow() {
3678
3745
  if (this.isLoadingHistory || this.isLoadingThreads) {
3679
3746
  return x `<div class="messages loading">
@@ -3684,17 +3751,13 @@ class ChatSection extends r$2 {
3684
3751
  <div class="messages">
3685
3752
  ${this.isTyping
3686
3753
  ? x ` <div class="message bot">
3687
- <div>
3688
- <div class="bot-icon">${botIcon}</div>
3689
- </div>
3754
+ <div>${this.renderBotIcon()}</div>
3690
3755
  ${this.typingIndicator()}
3691
3756
  </div>`
3692
3757
  : ''}
3693
3758
  ${this.isFailed
3694
3759
  ? x `<div class="message bot">
3695
- <div>
3696
- <div class="bot-icon">${botIcon}</div>
3697
- </div>
3760
+ <div>${this.renderBotIcon()}</div>
3698
3761
  <div>
3699
3762
  <p>
3700
3763
  Uh-oh! Looks like I tripped over some alpha-stage wires.
@@ -3712,9 +3775,7 @@ class ChatSection extends r$2 {
3712
3775
  return x ` <div class="message user">${message.message}</div> `;
3713
3776
  })}
3714
3777
  <div class="message bot">
3715
- <div>
3716
- <div class="bot-icon">${botIcon}</div>
3717
- </div>
3778
+ <div>${this.renderBotIcon()}</div>
3718
3779
  <div>
3719
3780
  <p>
3720
3781
  Hi,
@@ -3839,7 +3900,11 @@ class ChatSection extends r$2 {
3839
3900
  modalViewHeader() {
3840
3901
  var _a;
3841
3902
  return x `
3842
- <div>${botIcon}</div>
3903
+ <div>
3904
+ ${this.botIconUrl
3905
+ ? x `<img src=${this.botIconUrl} width="30" height="30" />`
3906
+ : botIcon}
3907
+ </div>
3843
3908
  <h2>${((_a = this.thread) === null || _a === void 0 ? void 0 : _a.title) || 'New Search'}</h2>
3844
3909
  <div class="btns-wrapper">
3845
3910
  <tooltip-component .position=${'bottom-right'} .text=${'New Chat'}>
@@ -4025,6 +4090,11 @@ class ChatSection extends r$2 {
4025
4090
  ${sendFilledIcon}
4026
4091
  </button>
4027
4092
  </form>
4093
+ ${this.viewType === 'modal'
4094
+ ? x ` <footer>
4095
+ Powered by <a href="https://blotout.io">Blotout</a>
4096
+ </footer>`
4097
+ : E}
4028
4098
  </div>
4029
4099
  <personalize-dialog
4030
4100
  .createChatThread=${this.createChatThread.bind(this)}
@@ -4081,6 +4151,10 @@ __decorate([
4081
4151
  n({ type: String }),
4082
4152
  __metadata("design:type", Object)
4083
4153
  ], ChatSection.prototype, "merchantImage", void 0);
4154
+ __decorate([
4155
+ n({ type: String }),
4156
+ __metadata("design:type", Object)
4157
+ ], ChatSection.prototype, "botIconUrl", void 0);
4084
4158
  __decorate([
4085
4159
  n({ type: String }),
4086
4160
  __metadata("design:type", Object)
@@ -4169,15 +4243,78 @@ __decorate([
4169
4243
  n({ type: String }),
4170
4244
  __metadata("design:type", Object)
4171
4245
  ], ChatSection.prototype, "userQuery", void 0);
4246
+ __decorate([
4247
+ n({ type: String }),
4248
+ __metadata("design:type", String)
4249
+ ], ChatSection.prototype, "css", void 0);
4172
4250
  if (!customElements.get('chat-section')) {
4173
4251
  customElements.define('chat-section', ChatSection);
4174
4252
  }
4175
4253
 
4254
+ async function* streamToIterable(stream) {
4255
+ const reader = stream.getReader();
4256
+ while (true) {
4257
+ const { done, value } = await reader.read();
4258
+ if (done)
4259
+ return;
4260
+ yield value;
4261
+ }
4262
+ }
4263
+ const handleEventSource = async (response, onEvent) => {
4264
+ var _a, _b;
4265
+ if (!response.body) {
4266
+ throw new Error('No body found in response');
4267
+ }
4268
+ let buffer = '';
4269
+ for await (const chunk of streamToIterable(response.body.pipeThrough(new TextDecoderStream()))) {
4270
+ buffer += chunk;
4271
+ const sections = buffer.split('\n\n');
4272
+ buffer = sections.pop() || '';
4273
+ for (const section of sections) {
4274
+ const event = parseMessage(section, true);
4275
+ onEvent((_a = event.event) !== null && _a !== void 0 ? _a : '', event.data);
4276
+ }
4277
+ }
4278
+ if (buffer) {
4279
+ const event = parseMessage(buffer, true);
4280
+ onEvent((_b = event.event) !== null && _b !== void 0 ? _b : '', event.data);
4281
+ }
4282
+ };
4283
+ const parseMessage = (message, parseDataAsJSON) => {
4284
+ const fields = message.split('\n');
4285
+ const result = {};
4286
+ for (const field of fields) {
4287
+ if (field.startsWith(':')) {
4288
+ continue;
4289
+ }
4290
+ if (field.startsWith('event: ')) {
4291
+ result.event = field.slice(7);
4292
+ }
4293
+ else if (field.startsWith('data: ')) {
4294
+ if (result.data) {
4295
+ result.data += '\n';
4296
+ }
4297
+ else {
4298
+ result.data = '';
4299
+ }
4300
+ result.data += field.slice(6);
4301
+ }
4302
+ else if (field.startsWith('retry: ')) {
4303
+ result.retry = field.slice(7);
4304
+ }
4305
+ }
4306
+ if (result.data && parseDataAsJSON) {
4307
+ result.data = JSON.parse(result.data);
4308
+ }
4309
+ return result;
4310
+ };
4311
+
4176
4312
  const DIALOG_DELAY = 1000;
4177
4313
  const normalizePath = (path) => path.replace(/\/$/, '');
4178
4314
  class ShopGPT extends r$2 {
4179
4315
  constructor() {
4180
4316
  super(...arguments);
4317
+ this.isStylesheetInjected = false;
4181
4318
  this.latestThreadLoad = DEFAULT_MAX_THREAD_AGE;
4182
4319
  this.modalState = 'close';
4183
4320
  this.isLoadingHistory = false;
@@ -4211,6 +4348,12 @@ class ShopGPT extends r$2 {
4211
4348
  }
4212
4349
  connectedCallback() {
4213
4350
  super.connectedCallback();
4351
+ if (!this.isStylesheetInjected && this.css) {
4352
+ const sheet = new CSSStyleSheet();
4353
+ sheet.replaceSync(this.css);
4354
+ this.shadowRoot.adoptedStyleSheets.push(sheet);
4355
+ this.isStylesheetInjected = true;
4356
+ }
4214
4357
  if (!this.view || this.view === 'overlay') {
4215
4358
  if (!this.path) {
4216
4359
  return;
@@ -4280,27 +4423,12 @@ class ShopGPT extends r$2 {
4280
4423
  : undefined;
4281
4424
  try {
4282
4425
  this.isTyping = true;
4283
- const reply = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
4284
- if (reply.chatTitle) {
4285
- this.setChatTitle(this.selectedThreadId, reply.chatTitle);
4286
- }
4287
- this.messages = [
4288
- {
4289
- messageId: reply.messageId,
4290
- sender: 'bot',
4291
- message: reply.message,
4292
- products: reply.products,
4293
- welcomePrompts: reply.welcomePrompts,
4294
- },
4295
- ...this.messages,
4296
- ];
4297
- this.products = reply.products || [];
4426
+ const response = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
4427
+ this.processMessageResponse(response);
4298
4428
  }
4299
4429
  catch (error) {
4300
4430
  logger.error(error);
4301
4431
  this.isFailed = true;
4302
- }
4303
- finally {
4304
4432
  this.isTyping = false;
4305
4433
  }
4306
4434
  }
@@ -4438,6 +4566,92 @@ class ShopGPT extends r$2 {
4438
4566
  .catch(logger.error)
4439
4567
  .finally(() => (this.isLoadingThreads = false));
4440
4568
  }
4569
+ handleMessageChunks(messageData) {
4570
+ if (!messageData.message) {
4571
+ return;
4572
+ }
4573
+ const latestMessage = this.messages[0];
4574
+ this.isTyping = false;
4575
+ if (latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.isChunk) {
4576
+ this.messages = [
4577
+ {
4578
+ ...latestMessage,
4579
+ message: latestMessage.message + messageData.message,
4580
+ isChunk: messageData.isChunk,
4581
+ sender: 'bot',
4582
+ },
4583
+ ...this.messages.slice(1),
4584
+ ];
4585
+ }
4586
+ else {
4587
+ this.messages = [
4588
+ {
4589
+ sender: 'bot',
4590
+ message: messageData.message || '',
4591
+ isChunk: messageData.isChunk,
4592
+ },
4593
+ ...this.messages,
4594
+ ];
4595
+ }
4596
+ }
4597
+ handleCompleteMessage(messageData) {
4598
+ const latestMessage = this.messages[0];
4599
+ this.messages = [
4600
+ {
4601
+ ...latestMessage,
4602
+ message: messageData.message || '',
4603
+ messageId: messageData.messageId,
4604
+ welcomePrompts: messageData.welcomePrompts,
4605
+ sender: 'bot',
4606
+ isChunk: false,
4607
+ },
4608
+ ...this.messages.slice(1),
4609
+ ];
4610
+ }
4611
+ handleProductsComplete(products, isMessageCompleted) {
4612
+ if (!products || !isMessageCompleted) {
4613
+ return;
4614
+ }
4615
+ const latestMessage = this.messages[0];
4616
+ this.messages = [
4617
+ {
4618
+ ...latestMessage,
4619
+ products,
4620
+ },
4621
+ ...this.messages.slice(1),
4622
+ ];
4623
+ if (products.length) {
4624
+ this.products = products;
4625
+ }
4626
+ }
4627
+ processMessageResponse(response) {
4628
+ let isMessageCompleted = false;
4629
+ let products;
4630
+ handleEventSource(response, (eventName, data) => {
4631
+ if (eventName === 'ChatTitle') {
4632
+ this.setChatTitle(this.selectedThreadId, data.chatTitle || '');
4633
+ }
4634
+ else if (eventName === 'Message') {
4635
+ this.handleMessageChunks(data);
4636
+ }
4637
+ else if (eventName === 'MessageComplete') {
4638
+ isMessageCompleted = true;
4639
+ this.handleProductsComplete(products, isMessageCompleted);
4640
+ this.handleCompleteMessage(data);
4641
+ }
4642
+ else if (eventName === 'ProductsComplete') {
4643
+ this.handleProductsComplete(data.products, isMessageCompleted);
4644
+ products = data.products;
4645
+ }
4646
+ else if (eventName === 'error') {
4647
+ if (this.messages[0].isChunk) {
4648
+ this.messages = this.messages.slice(1);
4649
+ }
4650
+ this.isFailed = true;
4651
+ throw new Error(data);
4652
+ }
4653
+ });
4654
+ }
4441
4655
  async sendMessageToServer(e, message) {
4442
4656
  e.preventDefault();
4443
4657
  e.stopPropagation();
@@ -4448,32 +4662,12 @@ class ShopGPT extends r$2 {
4448
4662
  try {
4449
4663
  this.messages = [{ sender: 'user', message }, ...this.messages];
4450
4664
  this.isTyping = true;
4451
- const reply = await this.submitQuery(message);
4452
- if (!reply) {
4453
- return;
4454
- }
4455
- if (reply.chatTitle) {
4456
- this.setChatTitle(this.selectedThreadId, reply.chatTitle);
4457
- }
4458
- this.messages = [
4459
- {
4460
- messageId: reply.messageId,
4461
- sender: 'bot',
4462
- message: reply.message,
4463
- products: reply.products,
4464
- welcomePrompts: reply.welcomePrompts,
4465
- },
4466
- ...this.messages,
4467
- ];
4468
- if (reply.products && reply.products.length > 0) {
4469
- this.products = reply.products;
4470
- }
4665
+ const response = await this.submitQuery(message);
4666
+ this.processMessageResponse(response);
4471
4667
  }
4472
4668
  catch (err) {
4473
4669
  logger.error(err);
4474
4670
  this.isFailed = true;
4475
- }
4476
- finally {
4477
4671
  this.isTyping = false;
4478
4672
  }
4479
4673
  }
@@ -4520,6 +4714,7 @@ class ShopGPT extends r$2 {
4520
4714
  .isLoading=${this.isLoadingThreads}
4521
4715
  .isTyping=${this.isTyping}
4522
4716
  .merchantUrl=${this.merchantUrl}
4717
+ .css=${this.css}
4523
4718
  ></chat-threads>
4524
4719
  <products-section
4525
4720
  .merchantImage=${this.merchantImage}
@@ -4527,6 +4722,7 @@ class ShopGPT extends r$2 {
4527
4722
  .isLoadingHistory=${this.isLoadingHistory}
4528
4723
  .siteCurrency=${this.getSiteCurrency()}
4529
4724
  .isLoadingThreads=${this.isLoadingThreads}
4725
+ .css=${this.css}
4530
4726
  ></products-section>
4531
4727
  <chat-section
4532
4728
  .prompts=${this.quickPrompts}
@@ -4545,6 +4741,8 @@ class ShopGPT extends r$2 {
4545
4741
  .viewType=${'overlay'}
4546
4742
  .isLoadingThreads=${this.isLoadingThreads}
4547
4743
  .customPrompts=${this.customPrompts}
4744
+ .botIconUrl=${this.botIconUrl}
4745
+ .css=${this.css}
4548
4746
  ></chat-section>
4549
4747
  </div>
4550
4748
  </dialog>
@@ -4596,6 +4794,8 @@ class ShopGPT extends r$2 {
4596
4794
  .isLoadingThreads=${this.isLoadingThreads}
4597
4795
  .merchantImage=${this.merchantImage}
4598
4796
  .customPrompts=${this.customPrompts}
4797
+ .botIconUrl=${this.botIconUrl}
4798
+ .css=${this.css}
4599
4799
  ></chat-section>
4600
4800
  </div>
4601
4801
  `;
@@ -4677,6 +4877,8 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
4677
4877
  shopGPT.quickPrompts = params.quickPrompts;
4678
4878
  shopGPT.merchantImage = params.merchantImage;
4679
4879
  shopGPT.latestThreadLoad = params.latestThreadLoad;
4880
+ shopGPT.botIconUrl = params.botIconUrl;
4881
+ shopGPT.css = params.css;
4680
4882
  document.body.append(shopGPT);
4681
4883
  },
4682
4884
  destroy() {