@blotoutio/providers-shop-gpt-sdk 1.8.0 → 1.9.0

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 +270 -77
  2. package/index.js +270 -77
  3. package/index.mjs +270 -77
  4. package/package.json +1 -1
package/index.mjs CHANGED
@@ -470,7 +470,6 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
470
470
  return url;
471
471
  };
472
472
  const processQuery = async (query, threadId, productHandle) => {
473
- var _a;
474
473
  const response = await fetchImpl(getURL('/query'), {
475
474
  method: 'POST',
476
475
  headers: getHeaders(),
@@ -485,14 +484,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
485
484
  if (!response.ok) {
486
485
  throw new Error(`Failed to process the query - ${response.status}: ${await response.text()}`);
487
486
  }
488
- const data = (await response.json());
489
- return {
490
- messageId: data.messageId,
491
- message: data.message,
492
- products: (_a = data.products) === null || _a === void 0 ? void 0 : _a.filter((item) => !!item).map((item) => ({ ...item, quantity: 1 })),
493
- chatTitle: data.chatTitle,
494
- welcomePrompts: data.welcomePrompts,
495
- };
487
+ return response;
496
488
  };
497
489
  const fetchChatHistory = async (threadId) => {
498
490
  if (!threadId) {
@@ -626,7 +618,7 @@ const init = (params) => {
626
618
  // exit if not in top window
627
619
  return;
628
620
  }
629
- const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
621
+ const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, botIconUrl, css, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
630
622
  const experiment = createExperiment({
631
623
  name: getExperimentName(mode),
632
624
  userId: params.userId,
@@ -660,6 +652,8 @@ const init = (params) => {
660
652
  quickPrompts,
661
653
  merchantImage,
662
654
  latestThreadLoad: latestThreadLoad !== null && latestThreadLoad !== void 0 ? latestThreadLoad : DEFAULT_MAX_THREAD_AGE,
655
+ botIconUrl,
656
+ css,
663
657
  });
664
658
  }
665
659
  };
@@ -786,6 +780,14 @@ const scrollBarStyles = i$4 `
786
780
  const shopGPTStyles = i$4 `
787
781
  ${scrollBarStyles}
788
782
 
783
+ :host {
784
+ --shopgpt-primary: #001531;
785
+ --shopgpt-secondary: #172a41;
786
+ --shopgpt-white: #ffffff;
787
+ --shopgpt-border: #dbe2eb;
788
+ --shopgpt-warning: #ffcc81;
789
+ }
790
+
789
791
  * {
790
792
  box-sizing: border-box;
791
793
  }
@@ -818,6 +820,7 @@ const shopGPTStyles = i$4 `
818
820
  0px 20px 20px 0px rgba(0, 0, 0, 0.08);
819
821
  position: fixed;
820
822
  z-index: 2000;
823
+ background: var(--shopgpt-white);
821
824
 
822
825
  @media screen and (max-width: 768px) {
823
826
  min-height: unset;
@@ -836,21 +839,21 @@ const shopGPTStyles = i$4 `
836
839
  z-index: 1000;
837
840
 
838
841
  button {
839
- color: #ffffff;
842
+ color: var(--shopgpt-white);
840
843
  border: none;
841
844
  cursor: pointer;
842
845
  width: 56px;
843
846
  height: 56px;
844
- background-color: #001531;
847
+ background-color: var(--shopgpt-primary);
845
848
  border-radius: 50%;
846
849
  justify-content: center;
847
850
  align-items: center;
848
- box-shadow: 0 0 4px 1px #ffffff;
851
+ box-shadow: 0 0 4px 1px var(--shopgpt-white);
849
852
  }
850
853
 
851
854
  .chatbot-hover-text {
852
855
  position: absolute;
853
- color: #172a41;
856
+ color: var(--shopgpt-secondary);
854
857
  padding: 8px;
855
858
  white-space: nowrap;
856
859
  font-size: 16px;
@@ -863,7 +866,7 @@ const shopGPTStyles = i$4 `
863
866
  right: calc(100% + 5px);
864
867
 
865
868
  border-radius: 5px 5px 0px;
866
- background: #ffcc81;
869
+ background: var(--shopgpt-warning);
867
870
  box-shadow: 0px 4px 6px -1px rgba(0, 0, 0, 0.1),
868
871
  0px 2px 4px -1px rgba(0, 0, 0, 0.06);
869
872
 
@@ -885,7 +888,7 @@ const shopGPTStyles = i$4 `
885
888
  display: flex;
886
889
  overflow: hidden;
887
890
  height: 100%;
888
- background: #ffffff;
891
+ background: var(--shopgpt-white);
889
892
  justify-content: center;
890
893
  align-items: center;
891
894
  padding: 25px;
@@ -896,7 +899,7 @@ const shopGPTStyles = i$4 `
896
899
  .shopgpt-container {
897
900
  display: flex;
898
901
  gap: 1px;
899
- background: #dbe2eb;
902
+ background: var(--shopgpt-border);
900
903
  height: 100%;
901
904
  width: 100%;
902
905
 
@@ -1223,6 +1226,16 @@ class ChatThreads extends r$2 {
1223
1226
  constructor() {
1224
1227
  super(...arguments);
1225
1228
  this.deleteAllThreads = false;
1229
+ this.isStylesheetInjected = false;
1230
+ }
1231
+ connectedCallback() {
1232
+ super.connectedCallback();
1233
+ if (!this.isStylesheetInjected && this.css) {
1234
+ const sheet = new CSSStyleSheet();
1235
+ sheet.replaceSync(this.css);
1236
+ this.shadowRoot.adoptedStyleSheets.push(sheet);
1237
+ this.isStylesheetInjected = true;
1238
+ }
1226
1239
  }
1227
1240
  getDomain() {
1228
1241
  var _a;
@@ -1391,6 +1404,10 @@ __decorate([
1391
1404
  r(),
1392
1405
  __metadata("design:type", Object)
1393
1406
  ], ChatThreads.prototype, "deleteAllThreads", void 0);
1407
+ __decorate([
1408
+ n({ type: String }),
1409
+ __metadata("design:type", String)
1410
+ ], ChatThreads.prototype, "css", void 0);
1394
1411
  if (!customElements.get('chat-threads')) {
1395
1412
  customElements.define('chat-threads', ChatThreads);
1396
1413
  }
@@ -1829,8 +1846,18 @@ if (!customElements.get('products-list')) {
1829
1846
  }
1830
1847
 
1831
1848
  class ProductsSection extends r$2 {
1849
+ constructor() {
1850
+ super(...arguments);
1851
+ this.isStylesheetInjected = false;
1852
+ }
1832
1853
  connectedCallback() {
1833
1854
  super.connectedCallback();
1855
+ if (!this.isStylesheetInjected && this.css) {
1856
+ const sheet = new CSSStyleSheet();
1857
+ sheet.replaceSync(this.css);
1858
+ this.shadowRoot.adoptedStyleSheets.push(sheet);
1859
+ this.isStylesheetInjected = true;
1860
+ }
1834
1861
  }
1835
1862
  renderMerchantImage() {
1836
1863
  if (this.merchantImage) {
@@ -1907,6 +1934,10 @@ __decorate([
1907
1934
  e$3('.products'),
1908
1935
  __metadata("design:type", Object)
1909
1936
  ], ProductsSection.prototype, "productsEle", void 0);
1937
+ __decorate([
1938
+ n({ type: String }),
1939
+ __metadata("design:type", String)
1940
+ ], ProductsSection.prototype, "css", void 0);
1910
1941
  if (!customElements.get('products-section')) {
1911
1942
  customElements.define('products-section', ProductsSection);
1912
1943
  }
@@ -2023,8 +2054,8 @@ const chatSectionStyles = i$4 `
2023
2054
  }
2024
2055
 
2025
2056
  .chatbot-section.modal-view {
2026
- height: calc(100% - 121px);
2027
- padding: 0px 16px 44px;
2057
+ height: calc(100% - 93px);
2058
+ padding: 0px 16px 16px;
2028
2059
  gap: 16px;
2029
2060
  }
2030
2061
 
@@ -2173,6 +2204,9 @@ const chatSectionStyles = i$4 `
2173
2204
  border-radius: 5px;
2174
2205
  border: 1px solid #dbe2eb;
2175
2206
  background: #fff;
2207
+ width: 36px;
2208
+ height: 36px;
2209
+ box-sizing: border-box;
2176
2210
  }
2177
2211
 
2178
2212
  .line {
@@ -2409,6 +2443,17 @@ const chatSectionStyles = i$4 `
2409
2443
  }
2410
2444
  }
2411
2445
 
2446
+ footer {
2447
+ text-align: center;
2448
+ font-size: 10px;
2449
+ color: #4e647f;
2450
+ font-weight: 500;
2451
+
2452
+ a {
2453
+ text-decoration: none;
2454
+ }
2455
+ }
2456
+
2412
2457
  ${scrollBarStyles}
2413
2458
  `;
2414
2459
 
@@ -3078,12 +3123,12 @@ const markdown = (text) => {
3078
3123
  };
3079
3124
 
3080
3125
  class MarkdownRenderer extends r$2 {
3126
+ constructor() {
3127
+ super(...arguments);
3128
+ this.content = '';
3129
+ }
3081
3130
  render() {
3082
- // Remove lit markers from slot content
3083
- const slotContent = this.innerHTML
3084
- .trim()
3085
- .replace(/<!--\?lit\$[\d$]+-->/g, '');
3086
- return o(markdown(slotContent));
3131
+ return o(markdown(this.content));
3087
3132
  }
3088
3133
  }
3089
3134
  MarkdownRenderer.styles = i$4 `
@@ -3097,6 +3142,10 @@ MarkdownRenderer.styles = i$4 `
3097
3142
  }
3098
3143
  }
3099
3144
  `;
3145
+ __decorate([
3146
+ n({ type: String }),
3147
+ __metadata("design:type", Object)
3148
+ ], MarkdownRenderer.prototype, "content", void 0);
3100
3149
  if (!customElements.get('markdown-renderer')) {
3101
3150
  customElements.define('markdown-renderer', MarkdownRenderer);
3102
3151
  }
@@ -3552,6 +3601,16 @@ class ChatSection extends r$2 {
3552
3601
  this.showChatThreads = false;
3553
3602
  this.deleteAllThreads = false;
3554
3603
  this.userQuery = '';
3604
+ this.isStylesheetInjected = false;
3605
+ }
3606
+ connectedCallback() {
3607
+ super.connectedCallback();
3608
+ if (!this.isStylesheetInjected && this.css) {
3609
+ const sheet = new CSSStyleSheet();
3610
+ sheet.replaceSync(this.css);
3611
+ this.shadowRoot.adoptedStyleSheets.push(sheet);
3612
+ this.isStylesheetInjected = true;
3613
+ }
3555
3614
  }
3556
3615
  scrollToBottom() {
3557
3616
  var _a;
@@ -3622,12 +3681,12 @@ class ChatSection extends r$2 {
3622
3681
  return x `
3623
3682
  <div class="message-wrapper">
3624
3683
  <div class="message bot">
3625
- <div>
3626
- <div class="bot-icon">${botIcon}</div>
3627
- </div>
3684
+ <div>${this.renderBotIcon()}</div>
3628
3685
  <div>
3629
3686
  ${message.message
3630
- ? x ` <markdown-renderer>${message.message}</markdown-renderer>`
3687
+ ? x ` <markdown-renderer
3688
+ .content=${message.message}
3689
+ ></markdown-renderer>`
3631
3690
  : E}
3632
3691
  ${this.viewType !== 'modal' && ((_a = message.products) === null || _a === void 0 ? void 0 : _a[0])
3633
3692
  ? x `
@@ -3672,6 +3731,14 @@ class ChatSection extends r$2 {
3672
3731
  </div>
3673
3732
  `;
3674
3733
  }
3734
+ renderBotIcon() {
3735
+ if (this.botIconUrl) {
3736
+ return x `<div class="bot-icon">
3737
+ <img src=${this.botIconUrl} width="30" height="30" />
3738
+ </div>`;
3739
+ }
3740
+ return x ` <div class="bot-icon">${botIcon}</div> `;
3741
+ }
3675
3742
  chatWindow() {
3676
3743
  if (this.isLoadingHistory || this.isLoadingThreads) {
3677
3744
  return x `<div class="messages loading">
@@ -3682,17 +3749,13 @@ class ChatSection extends r$2 {
3682
3749
  <div class="messages">
3683
3750
  ${this.isTyping
3684
3751
  ? x ` <div class="message bot">
3685
- <div>
3686
- <div class="bot-icon">${botIcon}</div>
3687
- </div>
3752
+ <div>${this.renderBotIcon()}</div>
3688
3753
  ${this.typingIndicator()}
3689
3754
  </div>`
3690
3755
  : ''}
3691
3756
  ${this.isFailed
3692
3757
  ? x `<div class="message bot">
3693
- <div>
3694
- <div class="bot-icon">${botIcon}</div>
3695
- </div>
3758
+ <div>${this.renderBotIcon()}</div>
3696
3759
  <div>
3697
3760
  <p>
3698
3761
  Uh-oh! Looks like I tripped over some alpha-stage wires.
@@ -3710,9 +3773,7 @@ class ChatSection extends r$2 {
3710
3773
  return x ` <div class="message user">${message.message}</div> `;
3711
3774
  })}
3712
3775
  <div class="message bot">
3713
- <div>
3714
- <div class="bot-icon">${botIcon}</div>
3715
- </div>
3776
+ <div>${this.renderBotIcon()}</div>
3716
3777
  <div>
3717
3778
  <p>
3718
3779
  Hi,
@@ -3837,7 +3898,11 @@ class ChatSection extends r$2 {
3837
3898
  modalViewHeader() {
3838
3899
  var _a;
3839
3900
  return x `
3840
- <div>${botIcon}</div>
3901
+ <div>
3902
+ ${this.botIconUrl
3903
+ ? x `<img src=${this.botIconUrl} width="30" height="30" />`
3904
+ : botIcon}
3905
+ </div>
3841
3906
  <h2>${((_a = this.thread) === null || _a === void 0 ? void 0 : _a.title) || 'New Search'}</h2>
3842
3907
  <div class="btns-wrapper">
3843
3908
  <tooltip-component .position=${'bottom-right'} .text=${'New Chat'}>
@@ -4023,6 +4088,11 @@ class ChatSection extends r$2 {
4023
4088
  ${sendFilledIcon}
4024
4089
  </button>
4025
4090
  </form>
4091
+ ${this.viewType === 'modal'
4092
+ ? x ` <footer>
4093
+ Powered by <a href="https://blotout.io">Blotout</a>
4094
+ </footer>`
4095
+ : E}
4026
4096
  </div>
4027
4097
  <personalize-dialog
4028
4098
  .createChatThread=${this.createChatThread.bind(this)}
@@ -4079,6 +4149,10 @@ __decorate([
4079
4149
  n({ type: String }),
4080
4150
  __metadata("design:type", Object)
4081
4151
  ], ChatSection.prototype, "merchantImage", void 0);
4152
+ __decorate([
4153
+ n({ type: String }),
4154
+ __metadata("design:type", Object)
4155
+ ], ChatSection.prototype, "botIconUrl", void 0);
4082
4156
  __decorate([
4083
4157
  n({ type: String }),
4084
4158
  __metadata("design:type", Object)
@@ -4167,15 +4241,69 @@ __decorate([
4167
4241
  n({ type: String }),
4168
4242
  __metadata("design:type", Object)
4169
4243
  ], ChatSection.prototype, "userQuery", void 0);
4244
+ __decorate([
4245
+ n({ type: String }),
4246
+ __metadata("design:type", String)
4247
+ ], ChatSection.prototype, "css", void 0);
4170
4248
  if (!customElements.get('chat-section')) {
4171
4249
  customElements.define('chat-section', ChatSection);
4172
4250
  }
4173
4251
 
4252
+ const handleEventSource = async (response, onEvent) => {
4253
+ var _a, _b;
4254
+ if (!response.body) {
4255
+ throw new Error('No body found in response');
4256
+ }
4257
+ let buffer = '';
4258
+ for await (const chunk of response.body.pipeThrough(new TextDecoderStream())) {
4259
+ buffer += chunk;
4260
+ const sections = buffer.split('\n\n');
4261
+ buffer = sections.pop() || '';
4262
+ for (const section of sections) {
4263
+ const event = parseMessage(section, true);
4264
+ onEvent((_a = event.event) !== null && _a !== void 0 ? _a : '', event.data);
4265
+ }
4266
+ }
4267
+ if (buffer) {
4268
+ const event = parseMessage(buffer, true);
4269
+ onEvent((_b = event.event) !== null && _b !== void 0 ? _b : '', event.data);
4270
+ }
4271
+ };
4272
+ const parseMessage = (message, parseDataAsJSON) => {
4273
+ const fields = message.split('\n');
4274
+ const result = {};
4275
+ for (const field of fields) {
4276
+ if (field.startsWith(':')) {
4277
+ continue;
4278
+ }
4279
+ if (field.startsWith('event: ')) {
4280
+ result.event = field.slice(7);
4281
+ }
4282
+ else if (field.startsWith('data: ')) {
4283
+ if (result.data) {
4284
+ result.data += '\n';
4285
+ }
4286
+ else {
4287
+ result.data = '';
4288
+ }
4289
+ result.data += field.slice(6);
4290
+ }
4291
+ else if (field.startsWith('retry: ')) {
4292
+ result.retry = field.slice(7);
4293
+ }
4294
+ }
4295
+ if (result.data && parseDataAsJSON) {
4296
+ result.data = JSON.parse(result.data);
4297
+ }
4298
+ return result;
4299
+ };
4300
+
4174
4301
  const DIALOG_DELAY = 1000;
4175
4302
  const normalizePath = (path) => path.replace(/\/$/, '');
4176
4303
  class ShopGPT extends r$2 {
4177
4304
  constructor() {
4178
4305
  super(...arguments);
4306
+ this.isStylesheetInjected = false;
4179
4307
  this.latestThreadLoad = DEFAULT_MAX_THREAD_AGE;
4180
4308
  this.modalState = 'close';
4181
4309
  this.isLoadingHistory = false;
@@ -4209,6 +4337,12 @@ class ShopGPT extends r$2 {
4209
4337
  }
4210
4338
  connectedCallback() {
4211
4339
  super.connectedCallback();
4340
+ if (!this.isStylesheetInjected && this.css) {
4341
+ const sheet = new CSSStyleSheet();
4342
+ sheet.replaceSync(this.css);
4343
+ this.shadowRoot.adoptedStyleSheets.push(sheet);
4344
+ this.isStylesheetInjected = true;
4345
+ }
4212
4346
  if (!this.view || this.view === 'overlay') {
4213
4347
  if (!this.path) {
4214
4348
  return;
@@ -4278,27 +4412,12 @@ class ShopGPT extends r$2 {
4278
4412
  : undefined;
4279
4413
  try {
4280
4414
  this.isTyping = true;
4281
- const reply = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
4282
- if (reply.chatTitle) {
4283
- this.setChatTitle(this.selectedThreadId, reply.chatTitle);
4284
- }
4285
- this.messages = [
4286
- {
4287
- messageId: reply.messageId,
4288
- sender: 'bot',
4289
- message: reply.message,
4290
- products: reply.products,
4291
- welcomePrompts: reply.welcomePrompts,
4292
- },
4293
- ...this.messages,
4294
- ];
4295
- this.products = reply.products || [];
4415
+ const response = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
4416
+ this.processMessageResponse(response);
4296
4417
  }
4297
4418
  catch (error) {
4298
4419
  logger.error(error);
4299
4420
  this.isFailed = true;
4300
- }
4301
- finally {
4302
4421
  this.isTyping = false;
4303
4422
  }
4304
4423
  }
@@ -4436,6 +4555,92 @@ class ShopGPT extends r$2 {
4436
4555
  .catch(logger.error)
4437
4556
  .finally(() => (this.isLoadingThreads = false));
4438
4557
  }
4558
+ handleMessageChunks(messageData) {
4559
+ if (!messageData.message) {
4560
+ return;
4561
+ }
4562
+ const latestMessage = this.messages[0];
4563
+ this.isTyping = false;
4564
+ if (latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.isChunk) {
4565
+ this.messages = [
4566
+ {
4567
+ ...latestMessage,
4568
+ message: latestMessage.message + messageData.message,
4569
+ isChunk: messageData.isChunk,
4570
+ sender: 'bot',
4571
+ },
4572
+ ...this.messages.slice(1),
4573
+ ];
4574
+ }
4575
+ else {
4576
+ this.messages = [
4577
+ {
4578
+ sender: 'bot',
4579
+ message: messageData.message || '',
4580
+ isChunk: messageData.isChunk,
4581
+ },
4582
+ ...this.messages,
4583
+ ];
4584
+ }
4585
+ }
4586
+ handleCompleteMessage(messageData) {
4587
+ const latestMessage = this.messages[0];
4588
+ this.messages = [
4589
+ {
4590
+ ...latestMessage,
4591
+ message: messageData.message || '',
4592
+ messageId: messageData.messageId,
4593
+ welcomePrompts: messageData.welcomePrompts,
4594
+ sender: 'bot',
4595
+ isChunk: false,
4596
+ },
4597
+ ...this.messages.slice(1),
4598
+ ];
4599
+ }
4600
+ handleProductsComplete(products, isMessageCompleted) {
4601
+ if (!products || !isMessageCompleted) {
4602
+ return;
4603
+ }
4604
+ const latestMessage = this.messages[0];
4605
+ this.messages = [
4606
+ {
4607
+ ...latestMessage,
4608
+ products,
4609
+ },
4610
+ ...this.messages.slice(1),
4611
+ ];
4612
+ if (products.length) {
4613
+ this.products = products;
4614
+ }
4615
+ }
4616
+ processMessageResponse(response) {
4617
+ let isMessageCompleted = false;
4618
+ let products;
4619
+ handleEventSource(response, (eventName, data) => {
4620
+ if (eventName === 'ChatTitle') {
4621
+ this.setChatTitle(this.selectedThreadId, data.chatTitle || '');
4622
+ }
4623
+ else if (eventName === 'Message') {
4624
+ this.handleMessageChunks(data);
4625
+ }
4626
+ else if (eventName === 'MessageComplete') {
4627
+ isMessageCompleted = true;
4628
+ this.handleProductsComplete(products, isMessageCompleted);
4629
+ this.handleCompleteMessage(data);
4630
+ }
4631
+ else if (eventName === 'ProductsComplete') {
4632
+ this.handleProductsComplete(data.products, isMessageCompleted);
4633
+ products = data.products;
4634
+ }
4635
+ else if (eventName === 'error') {
4636
+ if (this.messages[0].isChunk) {
4637
+ this.messages = this.messages.slice(1);
4638
+ }
4639
+ this.isFailed = true;
4640
+ throw new Error(data);
4641
+ }
4642
+ });
4643
+ }
4439
4644
  async sendMessageToServer(e, message) {
4440
4645
  e.preventDefault();
4441
4646
  e.stopPropagation();
@@ -4446,32 +4651,12 @@ class ShopGPT extends r$2 {
4446
4651
  try {
4447
4652
  this.messages = [{ sender: 'user', message }, ...this.messages];
4448
4653
  this.isTyping = true;
4449
- const reply = await this.submitQuery(message);
4450
- if (!reply) {
4451
- return;
4452
- }
4453
- if (reply.chatTitle) {
4454
- this.setChatTitle(this.selectedThreadId, reply.chatTitle);
4455
- }
4456
- this.messages = [
4457
- {
4458
- messageId: reply.messageId,
4459
- sender: 'bot',
4460
- message: reply.message,
4461
- products: reply.products,
4462
- welcomePrompts: reply.welcomePrompts,
4463
- },
4464
- ...this.messages,
4465
- ];
4466
- if (reply.products && reply.products.length > 0) {
4467
- this.products = reply.products;
4468
- }
4654
+ const response = await this.submitQuery(message);
4655
+ this.processMessageResponse(response);
4469
4656
  }
4470
4657
  catch (err) {
4471
4658
  logger.error(err);
4472
4659
  this.isFailed = true;
4473
- }
4474
- finally {
4475
4660
  this.isTyping = false;
4476
4661
  }
4477
4662
  }
@@ -4518,6 +4703,7 @@ class ShopGPT extends r$2 {
4518
4703
  .isLoading=${this.isLoadingThreads}
4519
4704
  .isTyping=${this.isTyping}
4520
4705
  .merchantUrl=${this.merchantUrl}
4706
+ .css=${this.css}
4521
4707
  ></chat-threads>
4522
4708
  <products-section
4523
4709
  .merchantImage=${this.merchantImage}
@@ -4525,6 +4711,7 @@ class ShopGPT extends r$2 {
4525
4711
  .isLoadingHistory=${this.isLoadingHistory}
4526
4712
  .siteCurrency=${this.getSiteCurrency()}
4527
4713
  .isLoadingThreads=${this.isLoadingThreads}
4714
+ .css=${this.css}
4528
4715
  ></products-section>
4529
4716
  <chat-section
4530
4717
  .prompts=${this.quickPrompts}
@@ -4543,6 +4730,8 @@ class ShopGPT extends r$2 {
4543
4730
  .viewType=${'overlay'}
4544
4731
  .isLoadingThreads=${this.isLoadingThreads}
4545
4732
  .customPrompts=${this.customPrompts}
4733
+ .botIconUrl=${this.botIconUrl}
4734
+ .css=${this.css}
4546
4735
  ></chat-section>
4547
4736
  </div>
4548
4737
  </dialog>
@@ -4594,6 +4783,8 @@ class ShopGPT extends r$2 {
4594
4783
  .isLoadingThreads=${this.isLoadingThreads}
4595
4784
  .merchantImage=${this.merchantImage}
4596
4785
  .customPrompts=${this.customPrompts}
4786
+ .botIconUrl=${this.botIconUrl}
4787
+ .css=${this.css}
4597
4788
  ></chat-section>
4598
4789
  </div>
4599
4790
  `;
@@ -4675,6 +4866,8 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
4675
4866
  shopGPT.quickPrompts = params.quickPrompts;
4676
4867
  shopGPT.merchantImage = params.merchantImage;
4677
4868
  shopGPT.latestThreadLoad = params.latestThreadLoad;
4869
+ shopGPT.botIconUrl = params.botIconUrl;
4870
+ shopGPT.css = params.css;
4678
4871
  document.body.append(shopGPT);
4679
4872
  },
4680
4873
  destroy() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-shop-gpt-sdk",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Shop GPT SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",