@blotoutio/providers-shop-gpt-sdk 1.3.0 → 1.4.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 +562 -257
  2. package/index.js +562 -257
  3. package/index.mjs +562 -257
  4. package/package.json +1 -1
package/index.mjs CHANGED
@@ -382,6 +382,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
382
382
  message: data.message,
383
383
  products: (_a = data.products) === null || _a === void 0 ? void 0 : _a.filter((item) => !!item).map((item) => ({ ...item, quantity: 1 })),
384
384
  chatTitle: data.chatTitle,
385
+ welcomePrompts: data.welcomePrompts,
385
386
  };
386
387
  };
387
388
  const fetchChatHistory = async (threadId) => {
@@ -574,58 +575,51 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
574
575
  * Copyright 2019 Google LLC
575
576
  * SPDX-License-Identifier: BSD-3-Clause
576
577
  */
577
- const t$4=globalThis,e$8=t$4.ShadowRoot&&(void 0===t$4.ShadyCSS||t$4.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$1=Symbol(),o$5=new WeakMap;let n$4 = class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s$1)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$8&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$6=t=>new n$4("string"==typeof t?t:t+"",void 0,s$1),i$4=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$4(o,t,s$1)},S$1=(s,o)=>{if(e$8)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$4.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$8?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$6(e)})(t):t;
578
+ const t$2=globalThis,e$7=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$1=Symbol(),o$5=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s$1)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$7&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$5=t=>new n$3("string"==typeof t?t:t+"",void 0,s$1),i$4=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$3(o,t,s$1)},S$1=(s,o)=>{if(e$7)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$2.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$7?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$5(e)})(t):t;
578
579
 
579
580
  /**
580
581
  * @license
581
582
  * Copyright 2017 Google LLC
582
583
  * SPDX-License-Identifier: BSD-3-Clause
583
- */const{is:i$3,defineProperty:e$7,getOwnPropertyDescriptor:r$5,getOwnPropertyNames:h$1,getOwnPropertySymbols:o$4,getPrototypeOf:n$3}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$3(t,s),y$1={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let b$1 = class b extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=y$1){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,s);void 0!==r&&e$7(this.prototype,t,r);}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r$5(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get(){return e?.call(this)},set(s){const r=e?.call(this);h.call(this,s),this.requestUpdate(t,r,i);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y$1}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$3(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...h$1(t),...o$4(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return !1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$EC(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==r?this.removeAttribute(e):this.setAttribute(e,r),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e,this[e]=r.fromAttribute(s,t.type),this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??f$1)(this[t],s))return;this.P(t,s,i);}!1===this.isUpdatePending&&(this._$ES=this._$ET());}P(t,s,i){this._$AL.has(t)||this._$AL.set(t,s),!0===i.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t);}async _$ET(){this.isUpdatePending=!0;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t)!0!==i.wrapped||this._$AL.has(s)||void 0===this[s]||this.P(s,this[s],i);}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EU();}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t);}_$EU(){this._$AL=new Map,this.isUpdatePending=!1;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return !0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU();}updated(t){}firstUpdated(t){}};b$1.elementStyles=[],b$1.shadowRootOptions={mode:"open"},b$1[d$1("elementProperties")]=new Map,b$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:b$1}),(a$1.reactiveElementVersions??=[]).push("2.0.4");
584
+ */const{is:i$3,defineProperty:e$6,getOwnPropertyDescriptor:r$4,getOwnPropertyNames:h$1,getOwnPropertySymbols:o$4,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$3(t,s),y$1={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let b$1 = class b extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=y$1){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,s);void 0!==r&&e$6(this.prototype,t,r);}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r$4(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get(){return e?.call(this)},set(s){const r=e?.call(this);h.call(this,s),this.requestUpdate(t,r,i);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y$1}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...h$1(t),...o$4(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return !1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$EC(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==r?this.removeAttribute(e):this.setAttribute(e,r),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e,this[e]=r.fromAttribute(s,t.type),this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??f$1)(this[t],s))return;this.P(t,s,i);}!1===this.isUpdatePending&&(this._$ES=this._$ET());}P(t,s,i){this._$AL.has(t)||this._$AL.set(t,s),!0===i.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t);}async _$ET(){this.isUpdatePending=!0;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t)!0!==i.wrapped||this._$AL.has(s)||void 0===this[s]||this.P(s,this[s],i);}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EU();}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t);}_$EU(){this._$AL=new Map,this.isUpdatePending=!1;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return !0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU();}updated(t){}firstUpdated(t){}};b$1.elementStyles=[],b$1.shadowRootOptions={mode:"open"},b$1[d$1("elementProperties")]=new Map,b$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:b$1}),(a$1.reactiveElementVersions??=[]).push("2.0.4");
584
585
 
585
586
  /**
586
587
  * @license
587
588
  * Copyright 2017 Google LLC
588
589
  * SPDX-License-Identifier: BSD-3-Clause
589
590
  */
590
- const t$3=globalThis,i$2=t$3.trustedTypes,s=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$6="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$2=`<${o$3}>`,r$4=document,l=()=>r$4.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),b=y(2),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r$4.createTreeWalker(r$4,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n$2:d>=0?(o.push(a),s.slice(0,d)+e$6+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$6)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$2?i$2.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$3)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r$4.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r$4).importNode(i,!0);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r$4,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$4.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t$3.litHtmlPolyfillSupport;j?.(N,R),(t$3.litHtmlVersions??=[]).push("3.2.1");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l(),t),t,void 0,s??{});}return h._$AI(t),h};
591
+ const t$1=globalThis,i$2=t$1.trustedTypes,s=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$5="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$1=`<${o$3}>`,r$3=document,l=()=>r$3.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),b=y(2),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r$3.createTreeWalker(r$3,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n$1:d>=0?(o.push(a),s.slice(0,d)+e$5+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$5)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$2?i$2.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$3)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r$3.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r$3).importNode(i,!0);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r$3,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$3.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t$1.litHtmlPolyfillSupport;j?.(N,R),(t$1.litHtmlVersions??=[]).push("3.2.1");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l(),t),t,void 0,s??{});}return h._$AI(t),h};
591
592
 
592
593
  /**
593
594
  * @license
594
595
  * Copyright 2017 Google LLC
595
596
  * SPDX-License-Identifier: BSD-3-Clause
596
- */let r$3 = class r extends b$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(s,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return T}};r$3._$litElement$=!0,r$3["finalized"]=!0,globalThis.litElementHydrateSupport?.({LitElement:r$3});const i$1=globalThis.litElementPolyfillSupport;i$1?.({LitElement:r$3});(globalThis.litElementVersions??=[]).push("4.1.1");
597
+ */let r$2 = class r extends b$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(s,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return T}};r$2._$litElement$=!0,r$2["finalized"]=!0,globalThis.litElementHydrateSupport?.({LitElement:r$2});const i$1=globalThis.litElementPolyfillSupport;i$1?.({LitElement:r$2});(globalThis.litElementVersions??=[]).push("4.1.1");
597
598
 
598
599
  /**
599
600
  * @license
600
601
  * Copyright 2017 Google LLC
601
602
  * SPDX-License-Identifier: BSD-3-Clause
602
- */
603
- const t$2=t=>(e,o)=>{void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
603
+ */const o$2={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1},r$1=(t=o$2,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.P(o,void 0,t),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,r?{...t,wrapped:!0}:t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
604
604
 
605
605
  /**
606
606
  * @license
607
607
  * Copyright 2017 Google LLC
608
608
  * SPDX-License-Identifier: BSD-3-Clause
609
- */const o$2={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1},r$2=(t=o$2,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.P(o,void 0,t),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n$1(t){return (e,o)=>"object"==typeof o?r$2(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,r?{...t,wrapped:!0}:t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
610
-
611
- /**
612
- * @license
613
- * Copyright 2017 Google LLC
614
- * SPDX-License-Identifier: BSD-3-Clause
615
- */function r$1(r){return n$1({...r,state:!0,attribute:!1})}
609
+ */function r(r){return n({...r,state:!0,attribute:!1})}
616
610
 
617
611
  /**
618
612
  * @license
619
613
  * Copyright 2017 Google LLC
620
614
  * SPDX-License-Identifier: BSD-3-Clause
621
615
  */
622
- const e$5=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
616
+ const e$4=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
623
617
 
624
618
  /**
625
619
  * @license
626
620
  * Copyright 2017 Google LLC
627
621
  * SPDX-License-Identifier: BSD-3-Clause
628
- */function e$4(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;if(r){const{get:e,set:r}="object"==typeof s?n:i??(()=>{const t=Symbol();return {get(){return this[t]},set(e){this[t]=e;}}})();return e$5(n,s,{get(){let t=e.call(this);return void 0===t&&(t=o(this),(null!==t||this.hasUpdated)&&r.call(this,t)),t}})}return e$5(n,s,{get(){return o(this)}})}}
622
+ */function e$3(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;if(r){const{get:e,set:r}="object"==typeof s?n:i??(()=>{const t=Symbol();return {get(){return this[t]},set(e){this[t]=e;}}})();return e$4(n,s,{get(){let t=e.call(this);return void 0===t&&(t=o(this),(null!==t||this.hasUpdated)&&r.call(this,t)),t}})}return e$4(n,s,{get(){return o(this)}})}}
629
623
 
630
624
  const scrollBarStyles = i$4 `
631
625
  ::-webkit-scrollbar {
@@ -711,6 +705,35 @@ const shopGPTStyles = i$4 `
711
705
  align-items: center;
712
706
  box-shadow: 0 0 4px 1px #ffffff;
713
707
  }
708
+
709
+ .chatbot-hover-text {
710
+ position: absolute;
711
+ color: #172a41;
712
+ padding: 8px;
713
+ white-space: nowrap;
714
+ font-size: 16px;
715
+ line-height: 21px;
716
+ opacity: 0;
717
+ transition: opacity 0.2s;
718
+ pointer-events: none;
719
+
720
+ top: calc(0% - 30%);
721
+ right: calc(100% + 5px);
722
+
723
+ border-radius: 5px 5px 0px;
724
+ background: #ffcc81;
725
+ box-shadow: 0px 4px 6px -1px rgba(0, 0, 0, 0.1),
726
+ 0px 2px 4px -1px rgba(0, 0, 0, 0.06);
727
+
728
+ font-weight: 400;
729
+ line-height: 150%;
730
+ }
731
+
732
+ &:hover {
733
+ .chatbot-hover-text {
734
+ opacity: 1;
735
+ }
736
+ }
714
737
  }
715
738
 
716
739
  .mobile-version {
@@ -758,13 +781,13 @@ const shopGPTStyles = i$4 `
758
781
  * Copyright 2017 Google LLC
759
782
  * SPDX-License-Identifier: BSD-3-Clause
760
783
  */
761
- const t$1={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e$3=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
784
+ const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e$2=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
762
785
 
763
786
  /**
764
787
  * @license
765
788
  * Copyright 2018 Google LLC
766
789
  * SPDX-License-Identifier: BSD-3-Clause
767
- */const e$2=e$3(class extends i{constructor(t){if(super(t),t.type!==t$1.ATTRIBUTE||"class"!==t.name||t.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter((s=>t[s])).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return T}});
790
+ */const e$1=e$2(class extends i{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter((s=>t[s])).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return T}});
768
791
 
769
792
  /**
770
793
  * @license
@@ -919,11 +942,35 @@ const chatThreadsStyles = i$4 `
919
942
  color: #677c95;
920
943
  font-weight: 500;
921
944
  text-transform: uppercase;
922
- margin: 0 0 12px;
945
+ margin: 0;
923
946
  max-height: 18px;
924
947
  padding-left: 12px;
925
948
  }
926
949
 
950
+ .trash-icon {
951
+ display: flex;
952
+ padding: 2px;
953
+ border-radius: 5px;
954
+ cursor: pointer;
955
+ align-items: center;
956
+ justify-content: center;
957
+
958
+ &:hover {
959
+ background: #dc3545;
960
+
961
+ path {
962
+ fill: white;
963
+ }
964
+ }
965
+ }
966
+
967
+ .title-wrapper {
968
+ display: flex;
969
+ justify-content: space-between;
970
+ align-items: center;
971
+ margin: 0 0 12px;
972
+ }
973
+
927
974
  .threads {
928
975
  flex: 1;
929
976
  overflow-y: auto;
@@ -936,17 +983,6 @@ const chatThreadsStyles = i$4 `
936
983
 
937
984
  .trash-icon {
938
985
  display: none;
939
- padding: 2px;
940
- cursor: pointer;
941
-
942
- &:hover {
943
- border-radius: 5px;
944
- background: #dc3545;
945
-
946
- path {
947
- fill: white;
948
- }
949
- }
950
986
  }
951
987
 
952
988
  &:hover {
@@ -995,13 +1031,11 @@ const chatThreadsStyles = i$4 `
995
1031
  }
996
1032
  `;
997
1033
 
998
- let LoadSpinner =
999
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1000
- class LoadSpinner extends r$3 {
1034
+ class LoadSpinner extends r$2 {
1001
1035
  render() {
1002
1036
  return x ` <div class="loader"><div class="spinner"></div></div> `;
1003
1037
  }
1004
- };
1038
+ }
1005
1039
  LoadSpinner.styles = [
1006
1040
  i$4 `
1007
1041
  .loader {
@@ -1035,14 +1069,15 @@ LoadSpinner.styles = [
1035
1069
  }
1036
1070
  `,
1037
1071
  ];
1038
- LoadSpinner = __decorate([
1039
- t$2('load-spinner')
1040
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1041
- ], LoadSpinner);
1042
-
1043
- let ChatThreads =
1044
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1045
- class ChatThreads extends r$3 {
1072
+ if (!customElements.get('load-spinner')) {
1073
+ customElements.define('load-spinner', LoadSpinner);
1074
+ }
1075
+
1076
+ class ChatThreads extends r$2 {
1077
+ constructor() {
1078
+ super(...arguments);
1079
+ this.deleteAllThreads = false;
1080
+ }
1046
1081
  getDomain() {
1047
1082
  var _a;
1048
1083
  if ((_a = this.merchantUrl) === null || _a === void 0 ? void 0 : _a.startsWith('https://')) {
@@ -1051,6 +1086,14 @@ class ChatThreads extends r$3 {
1051
1086
  return `https://${this.merchantUrl}`;
1052
1087
  }
1053
1088
  handleThreadDelete() {
1089
+ if (this.deleteAllThreads) {
1090
+ this.dispatchEvent(new CustomEvent('delete-all-threads', {
1091
+ composed: true,
1092
+ bubbles: true,
1093
+ }));
1094
+ this.deleteAllThreads = false;
1095
+ return;
1096
+ }
1054
1097
  if (!this.deleteThreadId) {
1055
1098
  return;
1056
1099
  }
@@ -1070,12 +1113,27 @@ class ChatThreads extends r$3 {
1070
1113
  }
1071
1114
  return x `
1072
1115
  <div class="history">
1073
- <p class="title">History</p>
1116
+ <div class="title-wrapper">
1117
+ <p class="title">History</p>
1118
+ ${this.chatThreads.size
1119
+ ? x `<div
1120
+ class="trash-icon"
1121
+ @click=${() => {
1122
+ if (this.isLoading || this.isTyping) {
1123
+ return;
1124
+ }
1125
+ this.deleteAllThreads = true;
1126
+ }}
1127
+ >
1128
+ ${trashIcon}
1129
+ </div>`
1130
+ : E}
1131
+ </div>
1074
1132
  ${this.chatThreads.size
1075
1133
  ? x `<div class="threads">
1076
1134
  ${o$1(this.chatThreads.values(), (thread) => x `
1077
1135
  <div
1078
- class=${e$2({
1136
+ class=${e$1({
1079
1137
  'thread-wrapper': true,
1080
1138
  active: this.selectedThreadId === thread.threadId,
1081
1139
  disabled: this.isTyping,
@@ -1129,52 +1187,66 @@ class ChatThreads extends r$3 {
1129
1187
  </a>
1130
1188
  </div>`
1131
1189
  : E}
1132
- ${this.deleteThreadId
1190
+ ${this.deleteThreadId || this.deleteAllThreads
1133
1191
  ? x `
1134
1192
  <confirm-dialog
1135
1193
  @accept=${this.handleThreadDelete}
1136
- @decline=${() => (this.deleteThreadId = '')}
1194
+ @decline=${() => {
1195
+ this.deleteThreadId = '';
1196
+ this.deleteAllThreads = false;
1197
+ }}
1137
1198
  >
1138
- <h2 slot="title">Delete Chat?</h2>
1199
+ <h2 slot="title">
1200
+ ${this.deleteAllThreads
1201
+ ? 'Delete Entire Chat History?'
1202
+ : 'Delete Chat?'}
1203
+ </h2>
1139
1204
  <p slot="content">
1140
1205
  This action cannot be undone. Are you sure you want to delete
1141
- <b>"${this.chatThreads.get(this.deleteThreadId).title}"</b>?
1206
+ ${this.deleteAllThreads
1207
+ ? ' the entire chat history'
1208
+ : x `<b
1209
+ >"${this.chatThreads.get(this.deleteThreadId).title}"</b
1210
+ >`}?
1142
1211
  </p>
1143
1212
  </confirm-dialog>
1144
1213
  `
1145
1214
  : E}
1146
1215
  `;
1147
1216
  }
1148
- };
1217
+ }
1149
1218
  ChatThreads.styles = [chatThreadsStyles];
1150
1219
  __decorate([
1151
- n$1({ type: Object }),
1220
+ n({ type: Object }),
1152
1221
  __metadata("design:type", Map)
1153
1222
  ], ChatThreads.prototype, "chatThreads", void 0);
1154
1223
  __decorate([
1155
- n$1({ type: String }),
1224
+ n({ type: String }),
1156
1225
  __metadata("design:type", Object)
1157
1226
  ], ChatThreads.prototype, "merchantUrl", void 0);
1158
1227
  __decorate([
1159
- n$1({ type: Boolean }),
1228
+ n({ type: Boolean }),
1160
1229
  __metadata("design:type", Boolean)
1161
1230
  ], ChatThreads.prototype, "isLoading", void 0);
1162
1231
  __decorate([
1163
- n$1({ type: Boolean }),
1232
+ n({ type: Boolean }),
1164
1233
  __metadata("design:type", Boolean)
1165
1234
  ], ChatThreads.prototype, "isTyping", void 0);
1166
1235
  __decorate([
1167
- n$1({ type: String }),
1236
+ n({ type: String }),
1168
1237
  __metadata("design:type", String)
1169
1238
  ], ChatThreads.prototype, "selectedThreadId", void 0);
1170
1239
  __decorate([
1171
- r$1(),
1240
+ r(),
1172
1241
  __metadata("design:type", String)
1173
1242
  ], ChatThreads.prototype, "deleteThreadId", void 0);
1174
- ChatThreads = __decorate([
1175
- t$2('chat-threads')
1176
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1177
- ], ChatThreads);
1243
+ __decorate([
1244
+ r(),
1245
+ __metadata("design:type", Object)
1246
+ ], ChatThreads.prototype, "deleteAllThreads", void 0);
1247
+ if (!customElements.get('chat-threads')) {
1248
+ customElements.define('chat-threads', ChatThreads);
1249
+ }
1178
1250
 
1179
1251
  const productsSectionStyles = i$4 `
1180
1252
  :host {
@@ -1362,9 +1434,7 @@ const productItemStyles = i$4 `
1362
1434
  }
1363
1435
  `;
1364
1436
 
1365
- let ProductItem =
1366
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1367
- class ProductItem extends r$3 {
1437
+ class ProductItem extends r$2 {
1368
1438
  getLocalPrice(price) {
1369
1439
  if (!this.siteCurrency) {
1370
1440
  return price;
@@ -1372,6 +1442,16 @@ class ProductItem extends r$3 {
1372
1442
  const localPrice = parseFloat(price) * this.siteCurrency.rate;
1373
1443
  return formatMoney(localPrice, this.siteCurrency.currency);
1374
1444
  }
1445
+ getComparedAtPrice(comparedAtPrice, price) {
1446
+ if (!comparedAtPrice ||
1447
+ comparedAtPrice === price ||
1448
+ parseFloat(comparedAtPrice) <= parseFloat(price)) {
1449
+ return E;
1450
+ }
1451
+ return x `<p class="price-compared">
1452
+ ${this.getLocalPrice(comparedAtPrice)}
1453
+ </p>`;
1454
+ }
1375
1455
  redirect(url) {
1376
1456
  var _a;
1377
1457
  if (!url) {
@@ -1405,13 +1485,7 @@ class ProductItem extends r$3 {
1405
1485
  </p>
1406
1486
  ${this.renderVariantTitles()}
1407
1487
  <div class="prices">
1408
- ${this.product.variants[0].comparedAtPrice &&
1409
- this.product.variants[0].comparedAtPrice !==
1410
- this.product.variants[0].price
1411
- ? x `<p class="price-compared">
1412
- ${this.getLocalPrice(this.product.variants[0].comparedAtPrice)}
1413
- </p>`
1414
- : E}
1488
+ ${this.getComparedAtPrice(this.product.variants[0].comparedAtPrice, this.product.variants[0].price)}
1415
1489
  <p>${this.getLocalPrice(this.product.variants[0].price)}</p>
1416
1490
  </div>
1417
1491
  <button
@@ -1424,20 +1498,19 @@ class ProductItem extends r$3 {
1424
1498
  </div>
1425
1499
  `;
1426
1500
  }
1427
- };
1501
+ }
1428
1502
  ProductItem.styles = [productItemStyles];
1429
1503
  __decorate([
1430
- n$1({ type: Object }),
1504
+ n({ type: Object }),
1431
1505
  __metadata("design:type", Object)
1432
1506
  ], ProductItem.prototype, "product", void 0);
1433
1507
  __decorate([
1434
- n$1({ type: Object }),
1508
+ n({ type: Object }),
1435
1509
  __metadata("design:type", Object)
1436
1510
  ], ProductItem.prototype, "siteCurrency", void 0);
1437
- ProductItem = __decorate([
1438
- t$2('product-item')
1439
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1440
- ], ProductItem);
1511
+ if (!customElements.get('product-item')) {
1512
+ customElements.define('product-item', ProductItem);
1513
+ }
1441
1514
 
1442
1515
  const productsListStyles = i$4 `
1443
1516
  .products::-webkit-scrollbar {
@@ -1465,6 +1538,8 @@ const productsListStyles = i$4 `
1465
1538
  gap: 24px;
1466
1539
  overflow-x: auto;
1467
1540
  scrollbar-width: none;
1541
+ margin-left: -10px;
1542
+ padding-left: 10px;
1468
1543
  }
1469
1544
 
1470
1545
  .scroll-btns {
@@ -1499,9 +1574,7 @@ const productsListStyles = i$4 `
1499
1574
  }
1500
1575
  `;
1501
1576
 
1502
- let ProductsList =
1503
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1504
- class ProductsList extends r$3 {
1577
+ class ProductsList extends r$2 {
1505
1578
  constructor() {
1506
1579
  super(...arguments);
1507
1580
  this.showButtons = true;
@@ -1549,7 +1622,7 @@ class ProductsList extends r$3 {
1549
1622
  <div class="products" @scroll=${this.updateButtonsState}>
1550
1623
  ${o$1(this.products, (product) => x `
1551
1624
  <div
1552
- class=${e$2({
1625
+ class=${e$1({
1553
1626
  'product-container': true,
1554
1627
  modal: this.viewType === 'modal',
1555
1628
  })}
@@ -1574,40 +1647,37 @@ class ProductsList extends r$3 {
1574
1647
  </div>
1575
1648
  `;
1576
1649
  }
1577
- };
1650
+ }
1578
1651
  ProductsList.styles = [productsListStyles];
1579
1652
  __decorate([
1580
- n$1({ type: Array }),
1653
+ n({ type: Array }),
1581
1654
  __metadata("design:type", Array)
1582
1655
  ], ProductsList.prototype, "products", void 0);
1583
1656
  __decorate([
1584
- n$1({ type: Object }),
1657
+ n({ type: Object }),
1585
1658
  __metadata("design:type", Object)
1586
1659
  ], ProductsList.prototype, "siteCurrency", void 0);
1587
1660
  __decorate([
1588
- r$1(),
1661
+ r(),
1589
1662
  __metadata("design:type", Object)
1590
1663
  ], ProductsList.prototype, "showButtons", void 0);
1591
1664
  __decorate([
1592
- e$4('.left-btn'),
1665
+ e$3('.left-btn'),
1593
1666
  __metadata("design:type", Object)
1594
1667
  ], ProductsList.prototype, "leftBtnEle", void 0);
1595
1668
  __decorate([
1596
- e$4('.right-btn'),
1669
+ e$3('.right-btn'),
1597
1670
  __metadata("design:type", Object)
1598
1671
  ], ProductsList.prototype, "rightBtnEle", void 0);
1599
1672
  __decorate([
1600
- e$4('.products'),
1673
+ e$3('.products'),
1601
1674
  __metadata("design:type", Object)
1602
1675
  ], ProductsList.prototype, "productsEle", void 0);
1603
- ProductsList = __decorate([
1604
- t$2('products-list')
1605
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1606
- ], ProductsList);
1607
-
1608
- let ProductsSection =
1609
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1610
- class ProductsSection extends r$3 {
1676
+ if (!customElements.get('products-list')) {
1677
+ customElements.define('products-list', ProductsList);
1678
+ }
1679
+
1680
+ class ProductsSection extends r$2 {
1611
1681
  connectedCallback() {
1612
1682
  super.connectedCallback();
1613
1683
  }
@@ -1623,7 +1693,7 @@ class ProductsSection extends r$3 {
1623
1693
  `;
1624
1694
  }
1625
1695
  render() {
1626
- if (this.isLoadingHistory) {
1696
+ if (this.isLoadingHistory || this.isLoadingThreads) {
1627
1697
  return x ` <load-spinner></load-spinner> `;
1628
1698
  }
1629
1699
  if (!this.products.length) {
@@ -1652,40 +1722,43 @@ class ProductsSection extends r$3 {
1652
1722
  </div>
1653
1723
  `;
1654
1724
  }
1655
- };
1725
+ }
1656
1726
  ProductsSection.styles = [productsSectionStyles];
1657
1727
  __decorate([
1658
- n$1({ type: String }),
1728
+ n({ type: String }),
1659
1729
  __metadata("design:type", Object)
1660
1730
  ], ProductsSection.prototype, "merchantImage", void 0);
1661
1731
  __decorate([
1662
- n$1({ type: Array }),
1732
+ n({ type: Array }),
1663
1733
  __metadata("design:type", Array)
1664
1734
  ], ProductsSection.prototype, "products", void 0);
1665
1735
  __decorate([
1666
- n$1({ type: Boolean }),
1736
+ n({ type: Boolean }),
1667
1737
  __metadata("design:type", Boolean)
1668
1738
  ], ProductsSection.prototype, "isLoadingHistory", void 0);
1669
1739
  __decorate([
1670
- n$1({ type: Object }),
1740
+ n({ type: Object }),
1671
1741
  __metadata("design:type", Object)
1672
1742
  ], ProductsSection.prototype, "siteCurrency", void 0);
1673
1743
  __decorate([
1674
- e$4('.left-btn'),
1744
+ n({ type: Boolean }),
1745
+ __metadata("design:type", Boolean)
1746
+ ], ProductsSection.prototype, "isLoadingThreads", void 0);
1747
+ __decorate([
1748
+ e$3('.left-btn'),
1675
1749
  __metadata("design:type", Object)
1676
1750
  ], ProductsSection.prototype, "leftBtnEle", void 0);
1677
1751
  __decorate([
1678
- e$4('.right-btn'),
1752
+ e$3('.right-btn'),
1679
1753
  __metadata("design:type", Object)
1680
1754
  ], ProductsSection.prototype, "rightBtnEle", void 0);
1681
1755
  __decorate([
1682
- e$4('.products'),
1756
+ e$3('.products'),
1683
1757
  __metadata("design:type", Object)
1684
1758
  ], ProductsSection.prototype, "productsEle", void 0);
1685
- ProductsSection = __decorate([
1686
- t$2('products-section')
1687
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1688
- ], ProductsSection);
1759
+ if (!customElements.get('products-section')) {
1760
+ customElements.define('products-section', ProductsSection);
1761
+ }
1689
1762
 
1690
1763
  const chatSectionStyles = i$4 `
1691
1764
  :host {
@@ -1865,6 +1938,20 @@ const chatSectionStyles = i$4 `
1865
1938
  gap: 28px;
1866
1939
  padding-bottom: 10px;
1867
1940
  margin-bottom: -10px;
1941
+ margin-right: -10px;
1942
+ padding-right: 10px;
1943
+ margin-left: -10px;
1944
+ padding-left: 10px;
1945
+ background: linear-gradient(#f7f8fa80, #f7f8fa80),
1946
+ var(--shopgpt-merchant-img-url);
1947
+ background-position: center;
1948
+ background-repeat: no-repeat;
1949
+ background-size: contain;
1950
+
1951
+ &.loading {
1952
+ justify-content: center;
1953
+ align-items: center;
1954
+ }
1868
1955
 
1869
1956
  .message:last-child {
1870
1957
  margin-top: 10px;
@@ -2035,7 +2122,7 @@ const chatSectionStyles = i$4 `
2035
2122
  .prompts {
2036
2123
  display: flex;
2037
2124
  justify-content: center;
2038
- gap: 23px 10px;
2125
+ gap: 10px;
2039
2126
  flex-wrap: wrap;
2040
2127
 
2041
2128
  .prompt {
@@ -2071,13 +2158,19 @@ const chatSectionStyles = i$4 `
2071
2158
  0px 20px 20px 0px rgba(0, 0, 0, 0.08);
2072
2159
  border-radius: 0px 0px 10px 10px;
2073
2160
 
2074
- h2 {
2075
- padding: 10px 16px;
2076
- color: #172a41;
2077
- font-size: 16px;
2078
- font-weight: 700;
2079
- line-height: 20px;
2161
+ .title-wrapper {
2162
+ display: flex;
2163
+ justify-content: space-between;
2164
+ align-items: center;
2080
2165
  border-bottom: 1px solid #dbe2eb;
2166
+ padding: 10px 16px;
2167
+
2168
+ h2 {
2169
+ color: #172a41;
2170
+ font-size: 16px;
2171
+ font-weight: 700;
2172
+ line-height: 20px;
2173
+ }
2081
2174
  }
2082
2175
 
2083
2176
  .thread-titles-wrapper {
@@ -2399,9 +2492,7 @@ const profilePlusIcon = b `<svg xmlns="http://www.w3.org/2000/svg" width="56" he
2399
2492
  <path fill-rule="evenodd" clip-rule="evenodd" d="M21 7C22.7306 7 24.4223 7.51318 25.8612 8.47464C27.3002 9.4361 28.4217 10.8027 29.084 12.4015C29.7462 14.0004 29.9195 15.7597 29.5819 17.457C29.2443 19.1544 28.4109 20.7135 27.1872 21.9372C25.9635 23.1609 24.4044 23.9942 22.707 24.3319C21.0097 24.6695 19.2504 24.4962 17.6515 23.8339C16.0527 23.1717 14.6861 22.0502 13.7246 20.6112C12.7632 19.1723 12.25 17.4806 12.25 15.75C12.25 13.4294 13.1719 11.2038 14.8128 9.56282C16.4538 7.92187 18.6794 7 21 7ZM21 3.5C18.5772 3.5 16.2088 4.21845 14.1943 5.5645C12.1798 6.91054 10.6097 8.82373 9.68248 11.0621C8.75531 13.3005 8.51272 15.7636 8.98539 18.1399C9.45805 20.5161 10.6248 22.6989 12.3379 24.4121C14.0511 26.1252 16.2339 27.2919 18.6101 27.7646C20.9864 28.2373 23.4495 27.9947 25.6879 27.0675C27.9263 26.1403 29.8395 24.5702 31.1855 22.5557C32.5316 20.5412 33.25 18.1728 33.25 15.75C33.25 12.5011 31.9594 9.38526 29.6621 7.08794C27.3647 4.79062 24.2489 3.5 21 3.5ZM56 24.5H49V17.5H45.5V24.5H38.5V28H45.5V35H49V28H56V24.5ZM35 52.5H38.5V43.75C38.5 40.5011 37.2094 37.3853 34.9121 35.0879C32.6147 32.7906 29.4989 31.5 26.25 31.5H15.75C12.5011 31.5 9.38526 32.7906 7.08794 35.0879C4.79062 37.3853 3.5 40.5011 3.5 43.75V52.5H7V43.75C7 41.4294 7.92187 39.2038 9.56282 37.5628C11.2038 35.9219 13.4294 35 15.75 35H26.25C28.5706 35 30.7962 35.9219 32.4372 37.5628C34.0781 39.2038 35 41.4294 35 43.75V52.5Z" fill="#172A41"/>
2400
2493
  </svg>`;
2401
2494
 
2402
- let PersonalizeDialog =
2403
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2404
- class PersonalizeDialog extends r$3 {
2495
+ class PersonalizeDialog extends r$2 {
2405
2496
  constructor() {
2406
2497
  super(...arguments);
2407
2498
  this.isLoading = false;
@@ -2644,74 +2735,173 @@ class PersonalizeDialog extends r$3 {
2644
2735
  </dialog>
2645
2736
  `;
2646
2737
  }
2647
- };
2738
+ }
2648
2739
  PersonalizeDialog.styles = [personalizeDialogStyles];
2649
2740
  __decorate([
2650
- e$4('dialog'),
2741
+ e$3('dialog'),
2651
2742
  __metadata("design:type", HTMLDialogElement)
2652
2743
  ], PersonalizeDialog.prototype, "dialogModal", void 0);
2653
2744
  __decorate([
2654
- e$4('.dropdown-list'),
2745
+ e$3('.dropdown-list'),
2655
2746
  __metadata("design:type", HTMLUListElement)
2656
2747
  ], PersonalizeDialog.prototype, "dropdownList", void 0);
2657
2748
  __decorate([
2658
- e$4('.dropdown-trigger'),
2749
+ e$3('.dropdown-trigger'),
2659
2750
  __metadata("design:type", HTMLDivElement)
2660
2751
  ], PersonalizeDialog.prototype, "dropdownTrigger", void 0);
2661
2752
  __decorate([
2662
- n$1({ type: Array }),
2753
+ n({ type: Array }),
2663
2754
  __metadata("design:type", Array)
2664
2755
  ], PersonalizeDialog.prototype, "defaultProductHandles", void 0);
2665
2756
  __decorate([
2666
- n$1({ type: Array }),
2757
+ n({ type: Array }),
2667
2758
  __metadata("design:type", Array)
2668
2759
  ], PersonalizeDialog.prototype, "defaultProfiles", void 0);
2669
2760
  __decorate([
2670
- n$1({ type: Boolean }),
2761
+ n({ type: Boolean }),
2671
2762
  __metadata("design:type", Object)
2672
2763
  ], PersonalizeDialog.prototype, "isLoading", void 0);
2673
2764
  __decorate([
2674
- n$1({ type: String }),
2765
+ n({ type: String }),
2675
2766
  __metadata("design:type", Object)
2676
2767
  ], PersonalizeDialog.prototype, "state", void 0);
2677
2768
  __decorate([
2678
- n$1({ type: String }),
2769
+ n({ type: String }),
2679
2770
  __metadata("design:type", Object)
2680
2771
  ], PersonalizeDialog.prototype, "profileType", void 0);
2681
2772
  __decorate([
2682
- n$1({ type: String }),
2773
+ n({ type: String }),
2683
2774
  __metadata("design:type", Object)
2684
2775
  ], PersonalizeDialog.prototype, "selectedProfile", void 0);
2685
2776
  __decorate([
2686
- n$1({ type: String }),
2777
+ n({ type: String }),
2687
2778
  __metadata("design:type", Object)
2688
2779
  ], PersonalizeDialog.prototype, "visitorType", void 0);
2689
2780
  __decorate([
2690
- n$1({ type: String }),
2781
+ n({ type: String }),
2691
2782
  __metadata("design:type", Object)
2692
2783
  ], PersonalizeDialog.prototype, "productHandle", void 0);
2693
- PersonalizeDialog = __decorate([
2694
- t$2('personalize-dialog')
2695
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2696
- ], PersonalizeDialog);
2784
+ if (!customElements.get('personalize-dialog')) {
2785
+ customElements.define('personalize-dialog', PersonalizeDialog);
2786
+ }
2697
2787
 
2698
2788
  /**
2699
2789
  * @license
2700
2790
  * Copyright 2017 Google LLC
2701
2791
  * SPDX-License-Identifier: BSD-3-Clause
2702
- */let e$1 = class e extends i{constructor(i){if(super(i),this.it=E,i.type!==t$1.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===E||null==r)return this._t=void 0,this.it=r;if(r===T)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}};e$1.directiveName="unsafeHTML",e$1.resultType=1;const o=e$3(e$1);
2703
-
2704
- var e={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function n(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function r(e){return (e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function t(a,c){var o,l,g,s,p,u=/((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,m=[],h="",i=c||{},d=0;function f(n){var r=e[n[1]||""],t=m[m.length-1]==n;return r?r[1]?(t?m.pop():m.push(n),r[0|t]):r[0]:n}function $(){for(var e="";m.length;)e+=f(m[m.length-1]);return e}for(a=a.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(e,n,r){return i[n.toLowerCase()]=r,""}).replace(/^\n+|\n+$/g,"");g=u.exec(a);)l=a.substring(d,g.index),d=u.lastIndex,o=g[0],l.match(/[^\\](\\\\)*\\$/)||((p=g[3]||g[4])?o='<pre class="code '+(g[4]?"poetry":g[2].toLowerCase())+'"><code'+(g[2]?' class="language-'+g[2].toLowerCase()+'"':"")+">"+n(r(p).replace(/^\n+|\n+$/g,""))+"</code></pre>":(p=g[6])?(p.match(/\./)&&(g[5]=g[5].replace(/^\d+/gm,"")),s=t(n(g[5].replace(/^\s*[>*+.-]/gm,""))),">"==p?p="blockquote":(p=p.match(/\./)?"ol":"ul",s=s.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),o="<"+p+">"+s+"</"+p+">"):g[8]?o='<img src="'+r(g[8])+'" alt="'+r(g[7])+'">':g[10]?(h=h.replace("<a>",'<a href="'+r(g[11]||i[l.toLowerCase()])+'">'),o=$()+"</a>"):g[9]?o="<a>":g[12]||g[14]?o="<"+(p="h"+(g[14]?g[14].length:g[13]>"="?1:2))+">"+t(g[12]||g[15],i)+"</"+p+">":g[16]?o="<code>"+r(g[16])+"</code>":(g[17]||g[1])&&(o=f(g[17]||"--"))),h+=l,h+=o;return (h+a.substring(d)+$()).replace(/^\n+|\n+$/g,"")}
2792
+ */class e extends i{constructor(i){if(super(i),this.it=E,i.type!==t.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===E||null==r)return this._t=void 0,this.it=r;if(r===T)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName="unsafeHTML",e.resultType=1;const o=e$2(e);
2793
+
2794
+ const markdown = (text) => {
2795
+ let src = text;
2796
+ const rx_space = /\t|\r|\uf8ff/g;
2797
+ const rx_hr = /^([*\-=_] *){3,}$/gm;
2798
+ const rx_blockquote = /\n *> *([^]*?)(?=(\n|$){2})/g;
2799
+ const rx_list = /\n( *)(?:[*\-+]|((\d+)|([a-z])|[A-Z])[.)]) +([^]*?)(?=(\n|$){2})/g;
2800
+ const rx_listjoin = /<\/(ol|ul)>\n\n<\1>/g;
2801
+ const rx_highlight = /(^|[^A-Za-z\d\\])(([*_])|(~)|(\^)|(--)|(\+\+)|`)(\2?)([^<]*?)\2\8(?!\2)(?=\W|_|$)/g;
2802
+ const rx_code = /\n((```|~~~).*\n?([^]*?)\n?\2|(( {4}.*?\n)+))/g;
2803
+ const rx_link = /((!?)\[(.*?)\]\((.*?)( ".*")?\)|\\([\\`*_{}[\]()#+\-.!~]))/g;
2804
+ const rx_table = /\n(( *\|.*?\| *\n)+)/g;
2805
+ const rx_thead = /^.*\n( *\|( *:?-+:?-+:? *\|)* *\n|)/;
2806
+ const rx_row = /.*\n/g;
2807
+ const rx_cell = /\|(.*?[^\\])\|/g;
2808
+ const rx_heading = /(?=^|>|\n)([>\s]*?)(#{1,6}) (.*?)( #*)? *(?=\n|$)/g;
2809
+ const rx_para = /(?=^|>|\n)\s*\n+([^<]+?)\n+\s*(?=\n|<|$)/g;
2810
+ const rx_stash = /-\d+\uf8ff/g;
2811
+ const stash = {};
2812
+ let si = 0;
2813
+ function replace(rex, fn) {
2814
+ src = src.replace(rex, fn);
2815
+ }
2816
+ function element(tag, content) {
2817
+ return `<${tag}>${content}</${tag}>`;
2818
+ }
2819
+ function blockquote(src) {
2820
+ return src.replace(rx_blockquote, (_, content) => {
2821
+ return element('blockquote', blockquote(highlight(content.replace(/^ *> */gm, ''))));
2822
+ });
2823
+ }
2824
+ function list(src) {
2825
+ return src.replace(rx_list, (all, ind, ol, num, low, content) => {
2826
+ const entry = element('li', highlight(content
2827
+ .split(new RegExp(`\n ?${ind}(?:(?:\\d+|[a-zA-Z])[.)]|[*\\-+]) +`, 'g'))
2828
+ .map(list)
2829
+ .join('</li><li>')));
2830
+ return `\n${ol
2831
+ ? `<ol start="${num
2832
+ ? ol + '">'
2833
+ : `${parseInt(ol, 36) - 9}" style="list-style-type:${low ? 'low' : 'upp'}er-alpha">`}${entry}</ol>`
2834
+ : element('ul', entry)}`;
2835
+ });
2836
+ }
2837
+ function highlight(src) {
2838
+ return src.replace(rx_highlight, function (all, _, p1, emp, sub, sup, small, big, p2, content) {
2839
+ return (_ +
2840
+ element(emp
2841
+ ? p2
2842
+ ? 'strong'
2843
+ : 'em'
2844
+ : sub
2845
+ ? p2
2846
+ ? 's'
2847
+ : 'sub'
2848
+ : sup
2849
+ ? 'sup'
2850
+ : small
2851
+ ? 'small'
2852
+ : big
2853
+ ? 'big'
2854
+ : 'code', highlight(content)));
2855
+ });
2856
+ }
2857
+ src = `\n${src}\n`;
2858
+ replace(rx_space, ' ');
2859
+ src = blockquote(src);
2860
+ replace(rx_hr, '<hr/>');
2861
+ src = list(src);
2862
+ replace(rx_listjoin, '');
2863
+ replace(rx_code, (_, p1, p2, p3, p4) => {
2864
+ stash[--si] = element('pre', element('code', p3 || p4.replace(/^ {4}/gm, '')));
2865
+ return `${si}\uf8ff`;
2866
+ });
2867
+ replace(rx_link, (_, p1, p2, p3, p4, p5, p6) => {
2868
+ stash[--si] = p4
2869
+ ? p2
2870
+ ? `<img src="${p4}" alt="${p3}"/>`
2871
+ : `<a href="${p4}">${highlight(p3)}</a>`
2872
+ : p6;
2873
+ return `${si}\uf8ff`;
2874
+ });
2875
+ replace(rx_table, (_, table) => {
2876
+ var _a;
2877
+ const sep = ((_a = table.match(rx_thead)) === null || _a === void 0 ? void 0 : _a[1]) || '';
2878
+ return `\n${element('table', table.replace(rx_row, (row, ri) => {
2879
+ return row === sep
2880
+ ? ''
2881
+ : element('tr', row.replace(rx_cell, (_, cell, ci) => ci
2882
+ ? element(sep && !ri ? 'th' : 'td', highlight(cell || ''))
2883
+ : ''));
2884
+ }))}`;
2885
+ });
2886
+ replace(rx_heading, (_, prefix, p1, p2) => {
2887
+ return prefix + element(`h${p1.length}`, highlight(p2));
2888
+ });
2889
+ replace(rx_para, (_, content) => {
2890
+ return element('p', highlight(content));
2891
+ });
2892
+ replace(rx_stash, (all) => stash[parseInt(all)]);
2893
+ return src.trim();
2894
+ };
2705
2895
 
2706
- let MarkdownRenderer =
2707
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2708
- class MarkdownRenderer extends r$3 {
2896
+ class MarkdownRenderer extends r$2 {
2709
2897
  render() {
2710
- const slotContent = this.innerHTML.trim();
2711
- const parsedContent = t(slotContent);
2712
- return o(parsedContent);
2898
+ // Remove lit markers from slot content
2899
+ const slotContent = this.innerHTML
2900
+ .trim()
2901
+ .replace(/<!--\?lit\$[\d$]+-->/g, '');
2902
+ return o(markdown(slotContent));
2713
2903
  }
2714
- };
2904
+ }
2715
2905
  MarkdownRenderer.styles = i$4 `
2716
2906
  :host {
2717
2907
  font-family: 'Inter', sans-serif;
@@ -2723,14 +2913,11 @@ MarkdownRenderer.styles = i$4 `
2723
2913
  }
2724
2914
  }
2725
2915
  `;
2726
- MarkdownRenderer = __decorate([
2727
- t$2('markdown-renderer')
2728
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2729
- ], MarkdownRenderer);
2730
-
2731
- let TooltipComponent =
2732
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2733
- class TooltipComponent extends r$3 {
2916
+ if (!customElements.get('markdown-renderer')) {
2917
+ customElements.define('markdown-renderer', MarkdownRenderer);
2918
+ }
2919
+
2920
+ class TooltipComponent extends r$2 {
2734
2921
  constructor() {
2735
2922
  super(...arguments);
2736
2923
  this.position = 'bottom-left';
@@ -2742,7 +2929,7 @@ class TooltipComponent extends r$3 {
2742
2929
  <div class="tooltip ${this.position}">${this.text}</div>
2743
2930
  `;
2744
2931
  }
2745
- };
2932
+ }
2746
2933
  TooltipComponent.styles = [
2747
2934
  i$4 `
2748
2935
  :host {
@@ -2754,7 +2941,6 @@ TooltipComponent.styles = [
2754
2941
  position: absolute;
2755
2942
  color: #172a41;
2756
2943
  padding: 4px 8px;
2757
- border-radius: 4px;
2758
2944
  white-space: nowrap;
2759
2945
  font-size: 12px;
2760
2946
  opacity: 0;
@@ -2841,17 +3027,16 @@ TooltipComponent.styles = [
2841
3027
  `,
2842
3028
  ];
2843
3029
  __decorate([
2844
- n$1({ type: String }),
3030
+ n({ type: String }),
2845
3031
  __metadata("design:type", String)
2846
3032
  ], TooltipComponent.prototype, "position", void 0);
2847
3033
  __decorate([
2848
- n$1({ type: String }),
3034
+ n({ type: String }),
2849
3035
  __metadata("design:type", Object)
2850
3036
  ], TooltipComponent.prototype, "text", void 0);
2851
- TooltipComponent = __decorate([
2852
- t$2('tooltip-component')
2853
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2854
- ], TooltipComponent);
3037
+ if (!customElements.get('tooltip-component')) {
3038
+ customElements.define('tooltip-component', TooltipComponent);
3039
+ }
2855
3040
 
2856
3041
  const confirmDialogStyles = i$4 `
2857
3042
  :host {
@@ -2932,9 +3117,7 @@ const confirmDialogStyles = i$4 `
2932
3117
  }
2933
3118
  `;
2934
3119
 
2935
- let ConfirmDialog =
2936
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2937
- class ConfirmDialog extends r$3 {
3120
+ class ConfirmDialog extends r$2 {
2938
3121
  onAcceptClick(e) {
2939
3122
  e.preventDefault();
2940
3123
  this.dispatchEvent(new CustomEvent('accept', {
@@ -2967,19 +3150,17 @@ class ConfirmDialog extends r$3 {
2967
3150
  </div>
2968
3151
  `;
2969
3152
  }
2970
- };
3153
+ }
2971
3154
  ConfirmDialog.styles = [confirmDialogStyles];
2972
- ConfirmDialog = __decorate([
2973
- t$2('confirm-dialog')
2974
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2975
- ], ConfirmDialog);
2976
-
2977
- let ChatSection =
2978
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2979
- class ChatSection extends r$3 {
3155
+ if (!customElements.get('confirm-dialog')) {
3156
+ customElements.define('confirm-dialog', ConfirmDialog);
3157
+ }
3158
+
3159
+ class ChatSection extends r$2 {
2980
3160
  constructor() {
2981
3161
  super(...arguments);
2982
3162
  this.showChatThreads = false;
3163
+ this.deleteAllThreads = false;
2983
3164
  this.userQuery = '';
2984
3165
  }
2985
3166
  scrollToBottom() {
@@ -3004,6 +3185,14 @@ class ChatSection extends r$3 {
3004
3185
  await this.processMessage(e, message);
3005
3186
  }
3006
3187
  handleThreadDelete() {
3188
+ if (this.deleteAllThreads) {
3189
+ this.dispatchEvent(new CustomEvent('delete-all-threads', {
3190
+ composed: true,
3191
+ bubbles: true,
3192
+ }));
3193
+ this.deleteAllThreads = false;
3194
+ return;
3195
+ }
3007
3196
  if (!this.deleteThreadId) {
3008
3197
  return;
3009
3198
  }
@@ -3057,8 +3246,10 @@ class ChatSection extends r$3 {
3057
3246
  `;
3058
3247
  }
3059
3248
  chatWindow() {
3060
- if (this.isLoadingHistory) {
3061
- return x ` <load-spinner></load-spinner> `;
3249
+ if (this.isLoadingHistory || this.isLoadingThreads) {
3250
+ return x `<div class="messages loading">
3251
+ <load-spinner></load-spinner>
3252
+ </div>`;
3062
3253
  }
3063
3254
  return x `
3064
3255
  <div class="messages">
@@ -3099,16 +3290,20 @@ class ChatSection extends r$3 {
3099
3290
  `;
3100
3291
  }
3101
3292
  quickPrompts() {
3102
- var _a;
3103
- if (((_a = this.thread) === null || _a === void 0 ? void 0 : _a.threadId) || this.messages.length) {
3293
+ if (this.isLoadingHistory || this.isTyping || this.isLoadingThreads) {
3294
+ return E;
3295
+ }
3296
+ const prompts = this.messages.length
3297
+ ? this.messages[0].welcomePrompts
3298
+ : this.prompts
3299
+ ? this.prompts.split(',').map((prompt) => prompt.trim())
3300
+ : ['Best Selling Items', 'Hot Sales'];
3301
+ if (!prompts) {
3104
3302
  return E;
3105
3303
  }
3106
- const defaultPrompts = this.prompts
3107
- ? this.prompts.split(',').map((prompt) => prompt.trim())
3108
- : ['Best Selling Items', 'Hot Sales'];
3109
3304
  return x `
3110
3305
  <div class="prompts btn">
3111
- ${defaultPrompts.map((prompt) => x `
3306
+ ${prompts.map((prompt) => x `
3112
3307
  <div
3113
3308
  class="prompt"
3114
3309
  @click=${(e) => this.processMessage(e, prompt)}
@@ -3212,10 +3407,10 @@ class ChatSection extends r$3 {
3212
3407
  </tooltip-component>
3213
3408
  <tooltip-component
3214
3409
  .position=${'bottom-right'}
3215
- .text=${'Your Search History'}
3410
+ .text=${'Search History'}
3216
3411
  >
3217
3412
  <button
3218
- class=${e$2({
3413
+ class=${e$1({
3219
3414
  btn: true,
3220
3415
  'btn-icon': true,
3221
3416
  'threads-btn': true,
@@ -3287,11 +3482,27 @@ class ChatSection extends r$3 {
3287
3482
  }
3288
3483
  return x ` <div id="modal-chat-threads">
3289
3484
  <div class="chat-threads">
3290
- <h2>Your Search History</h2>
3485
+ <div class="title-wrapper">
3486
+ <h2>Search History</h2>
3487
+ ${this.chatThreads.size
3488
+ ? x `<div
3489
+ class="trash-icon"
3490
+ @click=${() => {
3491
+ if (this.isTyping) {
3492
+ return;
3493
+ }
3494
+ this.deleteAllThreads = true;
3495
+ this.showChatThreads = false;
3496
+ }}
3497
+ >
3498
+ ${trashIcon}
3499
+ </div>`
3500
+ : E}
3501
+ </div>
3291
3502
  <div class="thread-titles-wrapper">
3292
3503
  ${o$1(this.chatThreads.values(), (thread) => x `
3293
3504
  <div
3294
- class=${e$2({
3505
+ class=${e$1({
3295
3506
  'thread-title': true,
3296
3507
  disabled: this.isTyping,
3297
3508
  })}
@@ -3331,10 +3542,17 @@ class ChatSection extends r$3 {
3331
3542
  </div>`;
3332
3543
  }
3333
3544
  render() {
3545
+ if (this.merchantImage) {
3546
+ // set the merchant image as a css variable
3547
+ this.style.setProperty('--shopgpt-merchant-img-url', `url('${this.merchantImage}')`);
3548
+ }
3549
+ else {
3550
+ this.style.removeProperty('--shopgpt-merchant-img-url');
3551
+ }
3334
3552
  return x `
3335
3553
  <div class="chat-header">${this.contextButton()}</div>
3336
3554
  <div
3337
- class=${e$2({
3555
+ class=${e$1({
3338
3556
  'chatbot-section': true,
3339
3557
  'modal-view': this.viewType === 'modal',
3340
3558
  })}
@@ -3348,7 +3566,7 @@ class ChatSection extends r$3 {
3348
3566
  placeholder="Type your search here..."
3349
3567
  />
3350
3568
  <button
3351
- class=${e$2({
3569
+ class=${e$1({
3352
3570
  btn: true,
3353
3571
  modal: this.viewType === 'modal',
3354
3572
  })}
@@ -3365,105 +3583,128 @@ class ChatSection extends r$3 {
3365
3583
  .defaultProfiles=${this.profiles}
3366
3584
  ></personalize-dialog>
3367
3585
  ${this.renderChatThreads()}
3368
- ${this.deleteThreadId
3586
+ ${this.deleteThreadId || this.deleteAllThreads
3369
3587
  ? x `
3370
3588
  <confirm-dialog
3371
3589
  @accept=${this.handleThreadDelete}
3372
- @decline=${() => (this.deleteThreadId = '')}
3590
+ @decline=${() => {
3591
+ this.deleteThreadId = '';
3592
+ this.deleteAllThreads = false;
3593
+ }}
3373
3594
  >
3374
- <h2 slot="title">Delete Chat?</h2>
3595
+ <h2 slot="title">
3596
+ ${this.deleteAllThreads
3597
+ ? 'Delete Entire Chat History?'
3598
+ : 'Delete Chat?'}
3599
+ </h2>
3375
3600
  <p slot="content">
3376
3601
  This action cannot be undone. Are you sure you want to delete
3377
- <b>"${this.chatThreads.get(this.deleteThreadId).title}"</b>?
3602
+ ${this.deleteAllThreads
3603
+ ? ' the entire chat history'
3604
+ : x `<b
3605
+ >"${this.chatThreads.get(this.deleteThreadId)
3606
+ .title}"</b
3607
+ >`}?
3378
3608
  </p>
3379
3609
  </confirm-dialog>
3380
3610
  `
3381
3611
  : E}
3382
3612
  `;
3383
3613
  }
3384
- };
3614
+ }
3385
3615
  ChatSection.styles = [chatSectionStyles];
3386
3616
  __decorate([
3387
- n$1({ type: String }),
3617
+ n({ type: String }),
3618
+ __metadata("design:type", Object)
3619
+ ], ChatSection.prototype, "merchantImage", void 0);
3620
+ __decorate([
3621
+ n({ type: String }),
3388
3622
  __metadata("design:type", Object)
3389
3623
  ], ChatSection.prototype, "brandName", void 0);
3390
3624
  __decorate([
3391
- n$1({ type: String }),
3625
+ n({ type: String }),
3392
3626
  __metadata("design:type", Object)
3393
3627
  ], ChatSection.prototype, "prompts", void 0);
3394
3628
  __decorate([
3395
- n$1({ type: Object }),
3629
+ n({ type: Boolean }),
3630
+ __metadata("design:type", Boolean)
3631
+ ], ChatSection.prototype, "isLoadingThreads", void 0);
3632
+ __decorate([
3633
+ n({ type: Object }),
3396
3634
  __metadata("design:type", Map)
3397
3635
  ], ChatSection.prototype, "chatThreads", void 0);
3398
3636
  __decorate([
3399
- r$1(),
3637
+ r(),
3400
3638
  __metadata("design:type", String)
3401
3639
  ], ChatSection.prototype, "deleteThreadId", void 0);
3402
3640
  __decorate([
3403
- n$1({ type: Boolean }),
3641
+ n({ type: Boolean }),
3404
3642
  __metadata("design:type", Object)
3405
3643
  ], ChatSection.prototype, "showChatThreads", void 0);
3406
3644
  __decorate([
3407
- n$1({ type: Boolean }),
3645
+ n({ type: Boolean }),
3408
3646
  __metadata("design:type", Boolean)
3409
3647
  ], ChatSection.prototype, "isLoadingHistory", void 0);
3410
3648
  __decorate([
3411
- n$1({ type: Boolean }),
3649
+ n({ type: Boolean }),
3412
3650
  __metadata("design:type", Object)
3413
3651
  ], ChatSection.prototype, "devMode", void 0);
3414
3652
  __decorate([
3415
- n$1({ type: Boolean }),
3653
+ n({ type: Boolean }),
3416
3654
  __metadata("design:type", Boolean)
3417
3655
  ], ChatSection.prototype, "isTyping", void 0);
3418
3656
  __decorate([
3419
- n$1({ type: Boolean }),
3657
+ n({ type: Boolean }),
3420
3658
  __metadata("design:type", Boolean)
3421
3659
  ], ChatSection.prototype, "isFailed", void 0);
3422
3660
  __decorate([
3423
- n$1({ type: Array }),
3661
+ n({ type: Array }),
3424
3662
  __metadata("design:type", Array)
3425
3663
  ], ChatSection.prototype, "messages", void 0);
3426
3664
  __decorate([
3427
- n$1({ type: Array }),
3665
+ n({ type: Array }),
3428
3666
  __metadata("design:type", Array)
3429
3667
  ], ChatSection.prototype, "profiles", void 0);
3430
3668
  __decorate([
3431
- n$1({ type: Array }),
3669
+ n({ type: Array }),
3432
3670
  __metadata("design:type", Array)
3433
3671
  ], ChatSection.prototype, "productHandles", void 0);
3434
3672
  __decorate([
3435
- n$1({ type: Object }),
3673
+ n({ type: Object }),
3436
3674
  __metadata("design:type", Object)
3437
3675
  ], ChatSection.prototype, "thread", void 0);
3438
3676
  __decorate([
3439
- n$1({ type: Object }),
3677
+ n({ type: Object }),
3440
3678
  __metadata("design:type", Object)
3441
3679
  ], ChatSection.prototype, "siteCurrency", void 0);
3442
3680
  __decorate([
3443
- e$4('.context-container'),
3681
+ r(),
3682
+ __metadata("design:type", Object)
3683
+ ], ChatSection.prototype, "deleteAllThreads", void 0);
3684
+ __decorate([
3685
+ e$3('.context-container'),
3444
3686
  __metadata("design:type", Object)
3445
3687
  ], ChatSection.prototype, "contextContainerElement", void 0);
3446
3688
  __decorate([
3447
- e$4('.chat-window'),
3689
+ e$3('.chat-window'),
3448
3690
  __metadata("design:type", Object)
3449
3691
  ], ChatSection.prototype, "chatWindowElement", void 0);
3450
3692
  __decorate([
3451
- e$4('personalize-dialog'),
3693
+ e$3('personalize-dialog'),
3452
3694
  __metadata("design:type", Object)
3453
3695
  ], ChatSection.prototype, "personalizeDialogElement", void 0);
3454
3696
  __decorate([
3455
- n$1({ type: String }),
3697
+ n({ type: String }),
3456
3698
  __metadata("design:type", Object)
3457
3699
  ], ChatSection.prototype, "userQuery", void 0);
3458
- ChatSection = __decorate([
3459
- t$2('chat-section')
3460
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3461
- ], ChatSection);
3700
+ if (!customElements.get('chat-section')) {
3701
+ customElements.define('chat-section', ChatSection);
3702
+ }
3462
3703
 
3463
3704
  const DIALOG_DELAY = 1000;
3464
3705
  const LATEST_THREAD_LOAD_DAYS = 14;
3465
3706
  const normalizePath = (path) => path.replace(/\/$/, '');
3466
- let ShopGPT = class ShopGPT extends r$3 {
3707
+ class ShopGPT extends r$2 {
3467
3708
  constructor() {
3468
3709
  super(...arguments);
3469
3710
  this.modalState = 'close';
@@ -3480,9 +3721,13 @@ let ShopGPT = class ShopGPT extends r$3 {
3480
3721
  return;
3481
3722
  }
3482
3723
  await this.loadChatThreads();
3483
- await this.loadInitialQuery();
3484
3724
  this.selectLatestThread();
3485
3725
  };
3726
+ this.onPopState = () => {
3727
+ var _a;
3728
+ this.modalState = 'close';
3729
+ (_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
3730
+ };
3486
3731
  this.submitQuery = (message) => {
3487
3732
  if (!message) {
3488
3733
  return;
@@ -3508,10 +3753,12 @@ let ShopGPT = class ShopGPT extends r$3 {
3508
3753
  }
3509
3754
  disconnectedCallback() {
3510
3755
  window.removeEventListener('edgetag-initialized', this.loadData);
3756
+ window.removeEventListener('popstate', this.onPopState);
3511
3757
  super.disconnectedCallback();
3512
3758
  }
3513
3759
  init() {
3514
3760
  window.addEventListener('edgetag-initialized', this.loadData);
3761
+ window.addEventListener('popstate', this.onPopState);
3515
3762
  if (!this.uiMode || this.uiMode === 'overlay') {
3516
3763
  delay(DIALOG_DELAY).then(() => {
3517
3764
  var _a;
@@ -3526,6 +3773,19 @@ let ShopGPT = class ShopGPT extends r$3 {
3526
3773
  });
3527
3774
  }
3528
3775
  }
3776
+ setChatTitle(threadId, title) {
3777
+ if (!title || !threadId) {
3778
+ return;
3779
+ }
3780
+ const thread = this.chatThreads.get(threadId);
3781
+ if (thread) {
3782
+ this.chatThreads.set(thread.threadId, {
3783
+ ...thread,
3784
+ title,
3785
+ });
3786
+ this.chatThreads = new Map(this.chatThreads);
3787
+ }
3788
+ }
3529
3789
  async loadInitialQuery() {
3530
3790
  var _a;
3531
3791
  if (!this.selectedThreadId) {
@@ -3538,14 +3798,26 @@ let ShopGPT = class ShopGPT extends r$3 {
3538
3798
  if (!thread) {
3539
3799
  return;
3540
3800
  }
3801
+ const searchParam = new URLSearchParams(window.location.search);
3802
+ const fromAd = searchParam.get('shopGPT') === '1';
3541
3803
  const productHandle = this.devMode
3542
3804
  ? (_a = thread === null || thread === void 0 ? void 0 : thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle
3543
- : this.storeAPI.getCurrentProductHandle();
3805
+ : fromAd
3806
+ ? this.storeAPI.getCurrentProductHandle()
3807
+ : undefined;
3544
3808
  try {
3545
3809
  this.isTyping = true;
3546
3810
  const reply = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
3811
+ if (reply.chatTitle) {
3812
+ this.setChatTitle(this.selectedThreadId, reply.chatTitle);
3813
+ }
3547
3814
  this.messages = [
3548
- { sender: 'bot', message: reply.message, products: reply.products },
3815
+ {
3816
+ sender: 'bot',
3817
+ message: reply.message,
3818
+ products: reply.products,
3819
+ welcomePrompts: reply.welcomePrompts,
3820
+ },
3549
3821
  ...this.messages,
3550
3822
  ];
3551
3823
  this.products = reply.products || [];
@@ -3572,9 +3844,6 @@ let ShopGPT = class ShopGPT extends r$3 {
3572
3844
  }
3573
3845
  }
3574
3846
  selectLatestThread() {
3575
- if (!this.devMode) {
3576
- return;
3577
- }
3578
3847
  const cutoffTime = Date.now() - LATEST_THREAD_LOAD_DAYS * 24 * 60 * 60 * 1000;
3579
3848
  // If the latest thread is not older than cutoff we should load the thread
3580
3849
  let latestThread;
@@ -3587,9 +3856,11 @@ let ShopGPT = class ShopGPT extends r$3 {
3587
3856
  if (latestThread) {
3588
3857
  this.setSelectedThreadId(latestThread.threadId);
3589
3858
  }
3859
+ else if (!this.devMode) {
3860
+ this.createChatThread({ title: '' }, true);
3861
+ }
3590
3862
  }
3591
3863
  async loadHistory(threadId) {
3592
- var _a, _b, _c;
3593
3864
  try {
3594
3865
  if (!threadId) {
3595
3866
  this.messages = [];
@@ -3598,22 +3869,24 @@ let ShopGPT = class ShopGPT extends r$3 {
3598
3869
  }
3599
3870
  this.isLoadingHistory = true;
3600
3871
  const data = await this.shopGPTAPI.fetchChatHistory(threadId);
3872
+ let latestAvailableProducts = [];
3601
3873
  this.messages = data.map((message) => {
3602
3874
  var _a;
3603
- return ({
3875
+ const products = (_a = message.products) === null || _a === void 0 ? void 0 : _a.map((product) => ({
3876
+ ...product,
3877
+ quantity: 1,
3878
+ }));
3879
+ if (!latestAvailableProducts.length && (products === null || products === void 0 ? void 0 : products.length)) {
3880
+ latestAvailableProducts = products;
3881
+ }
3882
+ return {
3604
3883
  message: message.message,
3605
3884
  sender: message.sender,
3606
- products: (_a = message.products) === null || _a === void 0 ? void 0 : _a.map((product) => ({
3607
- ...product,
3608
- quantity: 1,
3609
- })),
3610
- });
3885
+ products,
3886
+ welcomePrompts: message.welcomePrompts,
3887
+ };
3611
3888
  });
3612
- this.products =
3613
- (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.products) === null || _b === void 0 ? void 0 : _b.map((product) => ({
3614
- ...product,
3615
- quantity: 1,
3616
- }))) !== null && _c !== void 0 ? _c : [];
3889
+ this.products = latestAvailableProducts;
3617
3890
  }
3618
3891
  catch (e) {
3619
3892
  logger.error(e);
@@ -3654,6 +3927,21 @@ let ShopGPT = class ShopGPT extends r$3 {
3654
3927
  this.shopGPTAPI
3655
3928
  .deleteSingleThread(threadId)
3656
3929
  .then(this.loadChatThreads.bind(this))
3930
+ .then(() => {
3931
+ if (this.selectedThreadId === threadId) {
3932
+ this.setSelectedThreadId('');
3933
+ }
3934
+ })
3935
+ .catch(logger.error)
3936
+ .finally(() => (this.isLoadingThreads = false));
3937
+ }
3938
+ handleAllThreadsDelete(e) {
3939
+ e.stopPropagation();
3940
+ this.isLoadingThreads = true;
3941
+ this.shopGPTAPI
3942
+ .deleteAllThreads()
3943
+ .then(this.loadChatThreads.bind(this))
3944
+ .then(() => this.setSelectedThreadId(''))
3657
3945
  .catch(logger.error)
3658
3946
  .finally(() => (this.isLoadingThreads = false));
3659
3947
  }
@@ -3672,21 +3960,20 @@ let ShopGPT = class ShopGPT extends r$3 {
3672
3960
  return;
3673
3961
  }
3674
3962
  if (reply.chatTitle) {
3675
- // Alternatively we can fetch the chatThreads once again which would cost another network request
3676
- const thread = this.chatThreads.get(this.selectedThreadId);
3677
- if (thread) {
3678
- this.chatThreads.set(thread.threadId, {
3679
- ...thread,
3680
- title: reply.chatTitle,
3681
- });
3682
- this.chatThreads = new Map(this.chatThreads);
3683
- }
3963
+ this.setChatTitle(this.selectedThreadId, reply.chatTitle);
3684
3964
  }
3685
3965
  this.messages = [
3686
- { sender: 'bot', message: reply.message, products: reply.products },
3966
+ {
3967
+ sender: 'bot',
3968
+ message: reply.message,
3969
+ products: reply.products,
3970
+ welcomePrompts: reply.welcomePrompts,
3971
+ },
3687
3972
  ...this.messages,
3688
3973
  ];
3689
- this.products = reply.products || [];
3974
+ if (reply.products && reply.products.length > 0) {
3975
+ this.products = reply.products;
3976
+ }
3690
3977
  }
3691
3978
  catch (err) {
3692
3979
  logger.error(err);
@@ -3711,6 +3998,7 @@ let ShopGPT = class ShopGPT extends r$3 {
3711
3998
  <dialog
3712
3999
  id="shop-gpt-dialog-overlay"
3713
4000
  @delete-thread=${this.handleThreadDelete}
4001
+ @delete-all-threads=${this.handleAllThreadsDelete}
3714
4002
  >
3715
4003
  <div class="mobile-version">
3716
4004
  Please switch to the desktop version for the best experience.
@@ -3729,6 +4017,7 @@ let ShopGPT = class ShopGPT extends r$3 {
3729
4017
  .products=${this.products}
3730
4018
  .isLoadingHistory=${this.isLoadingHistory}
3731
4019
  .siteCurrency=${this.getSiteCurrency()}
4020
+ .isLoadingThreads=${this.isLoadingThreads}
3732
4021
  ></products-section>
3733
4022
  <chat-section
3734
4023
  .prompts=${this.quickPrompts}
@@ -3745,6 +4034,7 @@ let ShopGPT = class ShopGPT extends r$3 {
3745
4034
  .productHandles=${this.productHandles}
3746
4035
  .profiles=${this.profiles}
3747
4036
  .viewType=${'overlay'}
4037
+ .isLoadingThreads=${this.isLoadingThreads}
3748
4038
  ></chat-section>
3749
4039
  </div>
3750
4040
  </dialog>
@@ -3765,10 +4055,15 @@ let ShopGPT = class ShopGPT extends r$3 {
3765
4055
  >
3766
4056
  ${chatIcon}
3767
4057
  </button>
4058
+ <div class="chatbot-hover-text">What are you looking for today?</div>
3768
4059
  </div>`;
3769
4060
  }
3770
4061
  return x `
3771
- <div id="shop-gpt-modal" @delete-thread=${this.handleThreadDelete}>
4062
+ <div
4063
+ id="shop-gpt-modal"
4064
+ @delete-thread=${this.handleThreadDelete}
4065
+ @delete-all-threads=${this.handleAllThreadsDelete}
4066
+ >
3772
4067
  <chat-section
3773
4068
  .prompts=${this.quickPrompts}
3774
4069
  .brandName=${this.brandName}
@@ -3787,55 +4082,57 @@ let ShopGPT = class ShopGPT extends r$3 {
3787
4082
  .closeModal=${closeModal}
3788
4083
  .setSelectedThreadId=${this.setSelectedThreadId.bind(this)}
3789
4084
  .chatThreads=${this.chatThreads}
4085
+ .isLoadingThreads=${this.isLoadingThreads}
4086
+ .merchantImage=${this.merchantImage}
3790
4087
  ></chat-section>
3791
4088
  </div>
3792
4089
  `;
3793
4090
  }
3794
- };
4091
+ }
3795
4092
  ShopGPT.styles = [shopGPTStyles];
3796
4093
  __decorate([
3797
- e$4('#shop-gpt-dialog-overlay'),
4094
+ e$3('#shop-gpt-dialog-overlay'),
3798
4095
  __metadata("design:type", Object)
3799
4096
  ], ShopGPT.prototype, "shopGPTDialog", void 0);
3800
4097
  __decorate([
3801
- n$1({ type: String }),
4098
+ n({ type: String }),
3802
4099
  __metadata("design:type", String)
3803
4100
  ], ShopGPT.prototype, "modalState", void 0);
3804
4101
  __decorate([
3805
- n$1({ type: Boolean }),
4102
+ n({ type: Boolean }),
3806
4103
  __metadata("design:type", Object)
3807
4104
  ], ShopGPT.prototype, "isLoadingHistory", void 0);
3808
4105
  __decorate([
3809
- n$1({ type: Boolean }),
4106
+ n({ type: Boolean }),
3810
4107
  __metadata("design:type", Object)
3811
4108
  ], ShopGPT.prototype, "isLoadingThreads", void 0);
3812
4109
  __decorate([
3813
- n$1({ type: Boolean }),
4110
+ n({ type: Boolean }),
3814
4111
  __metadata("design:type", Object)
3815
4112
  ], ShopGPT.prototype, "isTyping", void 0);
3816
4113
  __decorate([
3817
- n$1({ type: Boolean }),
4114
+ n({ type: Boolean }),
3818
4115
  __metadata("design:type", Object)
3819
4116
  ], ShopGPT.prototype, "isFailed", void 0);
3820
4117
  __decorate([
3821
- n$1({ type: String }),
4118
+ n({ type: String }),
3822
4119
  __metadata("design:type", Object)
3823
4120
  ], ShopGPT.prototype, "selectedThreadId", void 0);
3824
4121
  __decorate([
3825
- n$1({ type: Array }),
4122
+ n({ type: Array }),
3826
4123
  __metadata("design:type", Array)
3827
4124
  ], ShopGPT.prototype, "products", void 0);
3828
4125
  __decorate([
3829
- n$1({ type: Array }),
4126
+ n({ type: Array }),
3830
4127
  __metadata("design:type", Array)
3831
4128
  ], ShopGPT.prototype, "messages", void 0);
3832
4129
  __decorate([
3833
- n$1({ type: Object }),
4130
+ n({ type: Object }),
3834
4131
  __metadata("design:type", Map)
3835
4132
  ], ShopGPT.prototype, "chatThreads", void 0);
3836
- ShopGPT = __decorate([
3837
- t$2('shop-gpt')
3838
- ], ShopGPT);
4133
+ if (!customElements.get('shop-gpt')) {
4134
+ customElements.define('shop-gpt', ShopGPT);
4135
+ }
3839
4136
 
3840
4137
  var _a, _b;
3841
4138
  var _c;
@@ -3861,6 +4158,14 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
3861
4158
  shopGPT.merchantImage = params.merchantImage;
3862
4159
  document.body.append(shopGPT);
3863
4160
  },
4161
+ destroy() {
4162
+ if (!shopGPT) {
4163
+ return;
4164
+ }
4165
+ shopGPT.remove();
4166
+ shopGPT = undefined;
4167
+ delete window[registryKey];
4168
+ },
3864
4169
  });
3865
4170
  }
3866
4171