@blotoutio/providers-shop-gpt-sdk 1.3.0 → 1.5.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.
- package/index.cjs.js +579 -263
- package/index.js +579 -263
- package/index.mjs +579 -263
- package/package.json +1 -1
package/index.cjs.js
CHANGED
@@ -302,6 +302,7 @@ const isoCountries = new Map([
|
|
302
302
|
new Set(isoCountries.keys());
|
303
303
|
|
304
304
|
const packageName = 'shopGPT';
|
305
|
+
const DEFAULT_MAX_THREAD_AGE = 14;
|
305
306
|
const previewKeyName = 'previewShopGPT';
|
306
307
|
|
307
308
|
const canLog = () => {
|
@@ -384,6 +385,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
|
|
384
385
|
message: data.message,
|
385
386
|
products: (_a = data.products) === null || _a === void 0 ? void 0 : _a.filter((item) => !!item).map((item) => ({ ...item, quantity: 1 })),
|
386
387
|
chatTitle: data.chatTitle,
|
388
|
+
welcomePrompts: data.welcomePrompts,
|
387
389
|
};
|
388
390
|
};
|
389
391
|
const fetchChatHistory = async (threadId) => {
|
@@ -490,7 +492,7 @@ const init = (params) => {
|
|
490
492
|
// exit if not in top window
|
491
493
|
return;
|
492
494
|
}
|
493
|
-
const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
|
495
|
+
const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, latestThreadLoad, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
|
494
496
|
let shouldShowUI = enabled;
|
495
497
|
if (!enabled && hasPreviewKey()) {
|
496
498
|
logger.log('Enabling UI in preview mode');
|
@@ -519,6 +521,7 @@ const init = (params) => {
|
|
519
521
|
brandName,
|
520
522
|
quickPrompts,
|
521
523
|
merchantImage,
|
524
|
+
latestThreadLoad: latestThreadLoad !== null && latestThreadLoad !== void 0 ? latestThreadLoad : DEFAULT_MAX_THREAD_AGE,
|
522
525
|
});
|
523
526
|
}
|
524
527
|
};
|
@@ -576,58 +579,51 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
576
579
|
* Copyright 2019 Google LLC
|
577
580
|
* SPDX-License-Identifier: BSD-3-Clause
|
578
581
|
*/
|
579
|
-
const t$
|
582
|
+
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;
|
580
583
|
|
581
584
|
/**
|
582
585
|
* @license
|
583
586
|
* Copyright 2017 Google LLC
|
584
587
|
* SPDX-License-Identifier: BSD-3-Clause
|
585
|
-
*/const{is:i$3,defineProperty:e$
|
588
|
+
*/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");
|
586
589
|
|
587
590
|
/**
|
588
591
|
* @license
|
589
592
|
* Copyright 2017 Google LLC
|
590
593
|
* SPDX-License-Identifier: BSD-3-Clause
|
591
594
|
*/
|
592
|
-
const t$
|
595
|
+
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};
|
593
596
|
|
594
597
|
/**
|
595
598
|
* @license
|
596
599
|
* Copyright 2017 Google LLC
|
597
600
|
* SPDX-License-Identifier: BSD-3-Clause
|
598
|
-
*/let r$
|
601
|
+
*/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");
|
599
602
|
|
600
603
|
/**
|
601
604
|
* @license
|
602
605
|
* Copyright 2017 Google LLC
|
603
606
|
* SPDX-License-Identifier: BSD-3-Clause
|
604
|
-
*/
|
605
|
-
const t$2=t=>(e,o)=>{void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
|
607
|
+
*/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)}
|
606
608
|
|
607
609
|
/**
|
608
610
|
* @license
|
609
611
|
* Copyright 2017 Google LLC
|
610
612
|
* SPDX-License-Identifier: BSD-3-Clause
|
611
|
-
*/
|
612
|
-
|
613
|
-
/**
|
614
|
-
* @license
|
615
|
-
* Copyright 2017 Google LLC
|
616
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
617
|
-
*/function r$1(r){return n$1({...r,state:!0,attribute:!1})}
|
613
|
+
*/function r(r){return n({...r,state:!0,attribute:!1})}
|
618
614
|
|
619
615
|
/**
|
620
616
|
* @license
|
621
617
|
* Copyright 2017 Google LLC
|
622
618
|
* SPDX-License-Identifier: BSD-3-Clause
|
623
619
|
*/
|
624
|
-
const e$
|
620
|
+
const e$4=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
625
621
|
|
626
622
|
/**
|
627
623
|
* @license
|
628
624
|
* Copyright 2017 Google LLC
|
629
625
|
* SPDX-License-Identifier: BSD-3-Clause
|
630
|
-
*/function e$
|
626
|
+
*/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)}})}}
|
631
627
|
|
632
628
|
const scrollBarStyles = i$4 `
|
633
629
|
::-webkit-scrollbar {
|
@@ -713,6 +709,35 @@ const shopGPTStyles = i$4 `
|
|
713
709
|
align-items: center;
|
714
710
|
box-shadow: 0 0 4px 1px #ffffff;
|
715
711
|
}
|
712
|
+
|
713
|
+
.chatbot-hover-text {
|
714
|
+
position: absolute;
|
715
|
+
color: #172a41;
|
716
|
+
padding: 8px;
|
717
|
+
white-space: nowrap;
|
718
|
+
font-size: 16px;
|
719
|
+
line-height: 21px;
|
720
|
+
opacity: 0;
|
721
|
+
transition: opacity 0.2s;
|
722
|
+
pointer-events: none;
|
723
|
+
|
724
|
+
top: calc(0% - 30%);
|
725
|
+
right: calc(100% + 5px);
|
726
|
+
|
727
|
+
border-radius: 5px 5px 0px;
|
728
|
+
background: #ffcc81;
|
729
|
+
box-shadow: 0px 4px 6px -1px rgba(0, 0, 0, 0.1),
|
730
|
+
0px 2px 4px -1px rgba(0, 0, 0, 0.06);
|
731
|
+
|
732
|
+
font-weight: 400;
|
733
|
+
line-height: 150%;
|
734
|
+
}
|
735
|
+
|
736
|
+
&:hover {
|
737
|
+
.chatbot-hover-text {
|
738
|
+
opacity: 1;
|
739
|
+
}
|
740
|
+
}
|
716
741
|
}
|
717
742
|
|
718
743
|
.mobile-version {
|
@@ -760,13 +785,13 @@ const shopGPTStyles = i$4 `
|
|
760
785
|
* Copyright 2017 Google LLC
|
761
786
|
* SPDX-License-Identifier: BSD-3-Clause
|
762
787
|
*/
|
763
|
-
const t
|
788
|
+
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)}}
|
764
789
|
|
765
790
|
/**
|
766
791
|
* @license
|
767
792
|
* Copyright 2018 Google LLC
|
768
793
|
* SPDX-License-Identifier: BSD-3-Clause
|
769
|
-
*/const e$
|
794
|
+
*/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}});
|
770
795
|
|
771
796
|
/**
|
772
797
|
* @license
|
@@ -921,11 +946,35 @@ const chatThreadsStyles = i$4 `
|
|
921
946
|
color: #677c95;
|
922
947
|
font-weight: 500;
|
923
948
|
text-transform: uppercase;
|
924
|
-
margin: 0
|
949
|
+
margin: 0;
|
925
950
|
max-height: 18px;
|
926
951
|
padding-left: 12px;
|
927
952
|
}
|
928
953
|
|
954
|
+
.trash-icon {
|
955
|
+
display: flex;
|
956
|
+
padding: 2px;
|
957
|
+
border-radius: 5px;
|
958
|
+
cursor: pointer;
|
959
|
+
align-items: center;
|
960
|
+
justify-content: center;
|
961
|
+
|
962
|
+
&:hover {
|
963
|
+
background: #dc3545;
|
964
|
+
|
965
|
+
path {
|
966
|
+
fill: white;
|
967
|
+
}
|
968
|
+
}
|
969
|
+
}
|
970
|
+
|
971
|
+
.title-wrapper {
|
972
|
+
display: flex;
|
973
|
+
justify-content: space-between;
|
974
|
+
align-items: center;
|
975
|
+
margin: 0 0 12px;
|
976
|
+
}
|
977
|
+
|
929
978
|
.threads {
|
930
979
|
flex: 1;
|
931
980
|
overflow-y: auto;
|
@@ -938,17 +987,6 @@ const chatThreadsStyles = i$4 `
|
|
938
987
|
|
939
988
|
.trash-icon {
|
940
989
|
display: none;
|
941
|
-
padding: 2px;
|
942
|
-
cursor: pointer;
|
943
|
-
|
944
|
-
&:hover {
|
945
|
-
border-radius: 5px;
|
946
|
-
background: #dc3545;
|
947
|
-
|
948
|
-
path {
|
949
|
-
fill: white;
|
950
|
-
}
|
951
|
-
}
|
952
990
|
}
|
953
991
|
|
954
992
|
&:hover {
|
@@ -997,13 +1035,11 @@ const chatThreadsStyles = i$4 `
|
|
997
1035
|
}
|
998
1036
|
`;
|
999
1037
|
|
1000
|
-
|
1001
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1002
|
-
class LoadSpinner extends r$3 {
|
1038
|
+
class LoadSpinner extends r$2 {
|
1003
1039
|
render() {
|
1004
1040
|
return x ` <div class="loader"><div class="spinner"></div></div> `;
|
1005
1041
|
}
|
1006
|
-
}
|
1042
|
+
}
|
1007
1043
|
LoadSpinner.styles = [
|
1008
1044
|
i$4 `
|
1009
1045
|
.loader {
|
@@ -1037,14 +1073,15 @@ LoadSpinner.styles = [
|
|
1037
1073
|
}
|
1038
1074
|
`,
|
1039
1075
|
];
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1076
|
+
if (!customElements.get('load-spinner')) {
|
1077
|
+
customElements.define('load-spinner', LoadSpinner);
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
class ChatThreads extends r$2 {
|
1081
|
+
constructor() {
|
1082
|
+
super(...arguments);
|
1083
|
+
this.deleteAllThreads = false;
|
1084
|
+
}
|
1048
1085
|
getDomain() {
|
1049
1086
|
var _a;
|
1050
1087
|
if ((_a = this.merchantUrl) === null || _a === void 0 ? void 0 : _a.startsWith('https://')) {
|
@@ -1053,6 +1090,14 @@ class ChatThreads extends r$3 {
|
|
1053
1090
|
return `https://${this.merchantUrl}`;
|
1054
1091
|
}
|
1055
1092
|
handleThreadDelete() {
|
1093
|
+
if (this.deleteAllThreads) {
|
1094
|
+
this.dispatchEvent(new CustomEvent('delete-all-threads', {
|
1095
|
+
composed: true,
|
1096
|
+
bubbles: true,
|
1097
|
+
}));
|
1098
|
+
this.deleteAllThreads = false;
|
1099
|
+
return;
|
1100
|
+
}
|
1056
1101
|
if (!this.deleteThreadId) {
|
1057
1102
|
return;
|
1058
1103
|
}
|
@@ -1072,12 +1117,27 @@ class ChatThreads extends r$3 {
|
|
1072
1117
|
}
|
1073
1118
|
return x `
|
1074
1119
|
<div class="history">
|
1075
|
-
<
|
1120
|
+
<div class="title-wrapper">
|
1121
|
+
<p class="title">History</p>
|
1122
|
+
${this.chatThreads.size
|
1123
|
+
? x `<div
|
1124
|
+
class="trash-icon"
|
1125
|
+
@click=${() => {
|
1126
|
+
if (this.isLoading || this.isTyping) {
|
1127
|
+
return;
|
1128
|
+
}
|
1129
|
+
this.deleteAllThreads = true;
|
1130
|
+
}}
|
1131
|
+
>
|
1132
|
+
${trashIcon}
|
1133
|
+
</div>`
|
1134
|
+
: E}
|
1135
|
+
</div>
|
1076
1136
|
${this.chatThreads.size
|
1077
1137
|
? x `<div class="threads">
|
1078
1138
|
${o$1(this.chatThreads.values(), (thread) => x `
|
1079
1139
|
<div
|
1080
|
-
class=${e$
|
1140
|
+
class=${e$1({
|
1081
1141
|
'thread-wrapper': true,
|
1082
1142
|
active: this.selectedThreadId === thread.threadId,
|
1083
1143
|
disabled: this.isTyping,
|
@@ -1131,52 +1191,66 @@ class ChatThreads extends r$3 {
|
|
1131
1191
|
</a>
|
1132
1192
|
</div>`
|
1133
1193
|
: E}
|
1134
|
-
${this.deleteThreadId
|
1194
|
+
${this.deleteThreadId || this.deleteAllThreads
|
1135
1195
|
? x `
|
1136
1196
|
<confirm-dialog
|
1137
1197
|
@accept=${this.handleThreadDelete}
|
1138
|
-
@decline=${() =>
|
1198
|
+
@decline=${() => {
|
1199
|
+
this.deleteThreadId = '';
|
1200
|
+
this.deleteAllThreads = false;
|
1201
|
+
}}
|
1139
1202
|
>
|
1140
|
-
<h2 slot="title">
|
1203
|
+
<h2 slot="title">
|
1204
|
+
${this.deleteAllThreads
|
1205
|
+
? 'Delete Entire Chat History?'
|
1206
|
+
: 'Delete Chat?'}
|
1207
|
+
</h2>
|
1141
1208
|
<p slot="content">
|
1142
1209
|
This action cannot be undone. Are you sure you want to delete
|
1143
|
-
|
1210
|
+
${this.deleteAllThreads
|
1211
|
+
? ' the entire chat history'
|
1212
|
+
: x `<b
|
1213
|
+
>"${this.chatThreads.get(this.deleteThreadId).title}"</b
|
1214
|
+
>`}?
|
1144
1215
|
</p>
|
1145
1216
|
</confirm-dialog>
|
1146
1217
|
`
|
1147
1218
|
: E}
|
1148
1219
|
`;
|
1149
1220
|
}
|
1150
|
-
}
|
1221
|
+
}
|
1151
1222
|
ChatThreads.styles = [chatThreadsStyles];
|
1152
1223
|
__decorate([
|
1153
|
-
n
|
1224
|
+
n({ type: Object }),
|
1154
1225
|
__metadata("design:type", Map)
|
1155
1226
|
], ChatThreads.prototype, "chatThreads", void 0);
|
1156
1227
|
__decorate([
|
1157
|
-
n
|
1228
|
+
n({ type: String }),
|
1158
1229
|
__metadata("design:type", Object)
|
1159
1230
|
], ChatThreads.prototype, "merchantUrl", void 0);
|
1160
1231
|
__decorate([
|
1161
|
-
n
|
1232
|
+
n({ type: Boolean }),
|
1162
1233
|
__metadata("design:type", Boolean)
|
1163
1234
|
], ChatThreads.prototype, "isLoading", void 0);
|
1164
1235
|
__decorate([
|
1165
|
-
n
|
1236
|
+
n({ type: Boolean }),
|
1166
1237
|
__metadata("design:type", Boolean)
|
1167
1238
|
], ChatThreads.prototype, "isTyping", void 0);
|
1168
1239
|
__decorate([
|
1169
|
-
n
|
1240
|
+
n({ type: String }),
|
1170
1241
|
__metadata("design:type", String)
|
1171
1242
|
], ChatThreads.prototype, "selectedThreadId", void 0);
|
1172
1243
|
__decorate([
|
1173
|
-
r
|
1244
|
+
r(),
|
1174
1245
|
__metadata("design:type", String)
|
1175
1246
|
], ChatThreads.prototype, "deleteThreadId", void 0);
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
], ChatThreads);
|
1247
|
+
__decorate([
|
1248
|
+
r(),
|
1249
|
+
__metadata("design:type", Object)
|
1250
|
+
], ChatThreads.prototype, "deleteAllThreads", void 0);
|
1251
|
+
if (!customElements.get('chat-threads')) {
|
1252
|
+
customElements.define('chat-threads', ChatThreads);
|
1253
|
+
}
|
1180
1254
|
|
1181
1255
|
const productsSectionStyles = i$4 `
|
1182
1256
|
:host {
|
@@ -1364,9 +1438,7 @@ const productItemStyles = i$4 `
|
|
1364
1438
|
}
|
1365
1439
|
`;
|
1366
1440
|
|
1367
|
-
|
1368
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1369
|
-
class ProductItem extends r$3 {
|
1441
|
+
class ProductItem extends r$2 {
|
1370
1442
|
getLocalPrice(price) {
|
1371
1443
|
if (!this.siteCurrency) {
|
1372
1444
|
return price;
|
@@ -1374,6 +1446,16 @@ class ProductItem extends r$3 {
|
|
1374
1446
|
const localPrice = parseFloat(price) * this.siteCurrency.rate;
|
1375
1447
|
return formatMoney(localPrice, this.siteCurrency.currency);
|
1376
1448
|
}
|
1449
|
+
getComparedAtPrice(comparedAtPrice, price) {
|
1450
|
+
if (!comparedAtPrice ||
|
1451
|
+
comparedAtPrice === price ||
|
1452
|
+
parseFloat(comparedAtPrice) <= parseFloat(price)) {
|
1453
|
+
return E;
|
1454
|
+
}
|
1455
|
+
return x `<p class="price-compared">
|
1456
|
+
${this.getLocalPrice(comparedAtPrice)}
|
1457
|
+
</p>`;
|
1458
|
+
}
|
1377
1459
|
redirect(url) {
|
1378
1460
|
var _a;
|
1379
1461
|
if (!url) {
|
@@ -1407,13 +1489,7 @@ class ProductItem extends r$3 {
|
|
1407
1489
|
</p>
|
1408
1490
|
${this.renderVariantTitles()}
|
1409
1491
|
<div class="prices">
|
1410
|
-
${this.product.variants[0].comparedAtPrice
|
1411
|
-
this.product.variants[0].comparedAtPrice !==
|
1412
|
-
this.product.variants[0].price
|
1413
|
-
? x `<p class="price-compared">
|
1414
|
-
${this.getLocalPrice(this.product.variants[0].comparedAtPrice)}
|
1415
|
-
</p>`
|
1416
|
-
: E}
|
1492
|
+
${this.getComparedAtPrice(this.product.variants[0].comparedAtPrice, this.product.variants[0].price)}
|
1417
1493
|
<p>${this.getLocalPrice(this.product.variants[0].price)}</p>
|
1418
1494
|
</div>
|
1419
1495
|
<button
|
@@ -1426,20 +1502,19 @@ class ProductItem extends r$3 {
|
|
1426
1502
|
</div>
|
1427
1503
|
`;
|
1428
1504
|
}
|
1429
|
-
}
|
1505
|
+
}
|
1430
1506
|
ProductItem.styles = [productItemStyles];
|
1431
1507
|
__decorate([
|
1432
|
-
n
|
1508
|
+
n({ type: Object }),
|
1433
1509
|
__metadata("design:type", Object)
|
1434
1510
|
], ProductItem.prototype, "product", void 0);
|
1435
1511
|
__decorate([
|
1436
|
-
n
|
1512
|
+
n({ type: Object }),
|
1437
1513
|
__metadata("design:type", Object)
|
1438
1514
|
], ProductItem.prototype, "siteCurrency", void 0);
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
], ProductItem);
|
1515
|
+
if (!customElements.get('product-item')) {
|
1516
|
+
customElements.define('product-item', ProductItem);
|
1517
|
+
}
|
1443
1518
|
|
1444
1519
|
const productsListStyles = i$4 `
|
1445
1520
|
.products::-webkit-scrollbar {
|
@@ -1467,6 +1542,8 @@ const productsListStyles = i$4 `
|
|
1467
1542
|
gap: 24px;
|
1468
1543
|
overflow-x: auto;
|
1469
1544
|
scrollbar-width: none;
|
1545
|
+
margin-left: -10px;
|
1546
|
+
padding-left: 10px;
|
1470
1547
|
}
|
1471
1548
|
|
1472
1549
|
.scroll-btns {
|
@@ -1501,21 +1578,23 @@ const productsListStyles = i$4 `
|
|
1501
1578
|
}
|
1502
1579
|
`;
|
1503
1580
|
|
1504
|
-
|
1505
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1506
|
-
class ProductsList extends r$3 {
|
1581
|
+
class ProductsList extends r$2 {
|
1507
1582
|
constructor() {
|
1508
1583
|
super(...arguments);
|
1509
1584
|
this.showButtons = true;
|
1510
1585
|
this.updateButtonsState = () => {
|
1511
|
-
if (!this.
|
1586
|
+
if (!this.productsEle) {
|
1512
1587
|
return;
|
1513
1588
|
}
|
1514
1589
|
const { scrollWidth, clientWidth } = this.productsEle;
|
1515
1590
|
this.showButtons = scrollWidth > clientWidth;
|
1516
|
-
this.leftBtnEle
|
1591
|
+
if (this.leftBtnEle) {
|
1592
|
+
this.leftBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft === 0);
|
1593
|
+
}
|
1517
1594
|
const maxScroll = this.productsEle.scrollWidth - this.productsEle.clientWidth;
|
1518
|
-
this.rightBtnEle
|
1595
|
+
if (this.rightBtnEle) {
|
1596
|
+
this.rightBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft >= maxScroll - 1);
|
1597
|
+
}
|
1519
1598
|
};
|
1520
1599
|
}
|
1521
1600
|
connectedCallback() {
|
@@ -1551,7 +1630,7 @@ class ProductsList extends r$3 {
|
|
1551
1630
|
<div class="products" @scroll=${this.updateButtonsState}>
|
1552
1631
|
${o$1(this.products, (product) => x `
|
1553
1632
|
<div
|
1554
|
-
class=${e$
|
1633
|
+
class=${e$1({
|
1555
1634
|
'product-container': true,
|
1556
1635
|
modal: this.viewType === 'modal',
|
1557
1636
|
})}
|
@@ -1576,40 +1655,37 @@ class ProductsList extends r$3 {
|
|
1576
1655
|
</div>
|
1577
1656
|
`;
|
1578
1657
|
}
|
1579
|
-
}
|
1658
|
+
}
|
1580
1659
|
ProductsList.styles = [productsListStyles];
|
1581
1660
|
__decorate([
|
1582
|
-
n
|
1661
|
+
n({ type: Array }),
|
1583
1662
|
__metadata("design:type", Array)
|
1584
1663
|
], ProductsList.prototype, "products", void 0);
|
1585
1664
|
__decorate([
|
1586
|
-
n
|
1665
|
+
n({ type: Object }),
|
1587
1666
|
__metadata("design:type", Object)
|
1588
1667
|
], ProductsList.prototype, "siteCurrency", void 0);
|
1589
1668
|
__decorate([
|
1590
|
-
r
|
1669
|
+
r(),
|
1591
1670
|
__metadata("design:type", Object)
|
1592
1671
|
], ProductsList.prototype, "showButtons", void 0);
|
1593
1672
|
__decorate([
|
1594
|
-
e$
|
1673
|
+
e$3('.left-btn'),
|
1595
1674
|
__metadata("design:type", Object)
|
1596
1675
|
], ProductsList.prototype, "leftBtnEle", void 0);
|
1597
1676
|
__decorate([
|
1598
|
-
e$
|
1677
|
+
e$3('.right-btn'),
|
1599
1678
|
__metadata("design:type", Object)
|
1600
1679
|
], ProductsList.prototype, "rightBtnEle", void 0);
|
1601
1680
|
__decorate([
|
1602
|
-
e$
|
1681
|
+
e$3('.products'),
|
1603
1682
|
__metadata("design:type", Object)
|
1604
1683
|
], ProductsList.prototype, "productsEle", void 0);
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
let ProductsSection =
|
1611
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1612
|
-
class ProductsSection extends r$3 {
|
1684
|
+
if (!customElements.get('products-list')) {
|
1685
|
+
customElements.define('products-list', ProductsList);
|
1686
|
+
}
|
1687
|
+
|
1688
|
+
class ProductsSection extends r$2 {
|
1613
1689
|
connectedCallback() {
|
1614
1690
|
super.connectedCallback();
|
1615
1691
|
}
|
@@ -1625,7 +1701,7 @@ class ProductsSection extends r$3 {
|
|
1625
1701
|
`;
|
1626
1702
|
}
|
1627
1703
|
render() {
|
1628
|
-
if (this.isLoadingHistory) {
|
1704
|
+
if (this.isLoadingHistory || this.isLoadingThreads) {
|
1629
1705
|
return x ` <load-spinner></load-spinner> `;
|
1630
1706
|
}
|
1631
1707
|
if (!this.products.length) {
|
@@ -1654,40 +1730,43 @@ class ProductsSection extends r$3 {
|
|
1654
1730
|
</div>
|
1655
1731
|
`;
|
1656
1732
|
}
|
1657
|
-
}
|
1733
|
+
}
|
1658
1734
|
ProductsSection.styles = [productsSectionStyles];
|
1659
1735
|
__decorate([
|
1660
|
-
n
|
1736
|
+
n({ type: String }),
|
1661
1737
|
__metadata("design:type", Object)
|
1662
1738
|
], ProductsSection.prototype, "merchantImage", void 0);
|
1663
1739
|
__decorate([
|
1664
|
-
n
|
1740
|
+
n({ type: Array }),
|
1665
1741
|
__metadata("design:type", Array)
|
1666
1742
|
], ProductsSection.prototype, "products", void 0);
|
1667
1743
|
__decorate([
|
1668
|
-
n
|
1744
|
+
n({ type: Boolean }),
|
1669
1745
|
__metadata("design:type", Boolean)
|
1670
1746
|
], ProductsSection.prototype, "isLoadingHistory", void 0);
|
1671
1747
|
__decorate([
|
1672
|
-
n
|
1748
|
+
n({ type: Object }),
|
1673
1749
|
__metadata("design:type", Object)
|
1674
1750
|
], ProductsSection.prototype, "siteCurrency", void 0);
|
1675
1751
|
__decorate([
|
1676
|
-
|
1752
|
+
n({ type: Boolean }),
|
1753
|
+
__metadata("design:type", Boolean)
|
1754
|
+
], ProductsSection.prototype, "isLoadingThreads", void 0);
|
1755
|
+
__decorate([
|
1756
|
+
e$3('.left-btn'),
|
1677
1757
|
__metadata("design:type", Object)
|
1678
1758
|
], ProductsSection.prototype, "leftBtnEle", void 0);
|
1679
1759
|
__decorate([
|
1680
|
-
e$
|
1760
|
+
e$3('.right-btn'),
|
1681
1761
|
__metadata("design:type", Object)
|
1682
1762
|
], ProductsSection.prototype, "rightBtnEle", void 0);
|
1683
1763
|
__decorate([
|
1684
|
-
e$
|
1764
|
+
e$3('.products'),
|
1685
1765
|
__metadata("design:type", Object)
|
1686
1766
|
], ProductsSection.prototype, "productsEle", void 0);
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
], ProductsSection);
|
1767
|
+
if (!customElements.get('products-section')) {
|
1768
|
+
customElements.define('products-section', ProductsSection);
|
1769
|
+
}
|
1691
1770
|
|
1692
1771
|
const chatSectionStyles = i$4 `
|
1693
1772
|
:host {
|
@@ -1867,6 +1946,20 @@ const chatSectionStyles = i$4 `
|
|
1867
1946
|
gap: 28px;
|
1868
1947
|
padding-bottom: 10px;
|
1869
1948
|
margin-bottom: -10px;
|
1949
|
+
margin-right: -10px;
|
1950
|
+
padding-right: 10px;
|
1951
|
+
margin-left: -10px;
|
1952
|
+
padding-left: 10px;
|
1953
|
+
background: linear-gradient(#f7f8fa80, #f7f8fa80),
|
1954
|
+
var(--shopgpt-merchant-img-url);
|
1955
|
+
background-position: center;
|
1956
|
+
background-repeat: no-repeat;
|
1957
|
+
background-size: contain;
|
1958
|
+
|
1959
|
+
&.loading {
|
1960
|
+
justify-content: center;
|
1961
|
+
align-items: center;
|
1962
|
+
}
|
1870
1963
|
|
1871
1964
|
.message:last-child {
|
1872
1965
|
margin-top: 10px;
|
@@ -2037,7 +2130,7 @@ const chatSectionStyles = i$4 `
|
|
2037
2130
|
.prompts {
|
2038
2131
|
display: flex;
|
2039
2132
|
justify-content: center;
|
2040
|
-
gap:
|
2133
|
+
gap: 10px;
|
2041
2134
|
flex-wrap: wrap;
|
2042
2135
|
|
2043
2136
|
.prompt {
|
@@ -2073,13 +2166,19 @@ const chatSectionStyles = i$4 `
|
|
2073
2166
|
0px 20px 20px 0px rgba(0, 0, 0, 0.08);
|
2074
2167
|
border-radius: 0px 0px 10px 10px;
|
2075
2168
|
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
font-weight: 700;
|
2081
|
-
line-height: 20px;
|
2169
|
+
.title-wrapper {
|
2170
|
+
display: flex;
|
2171
|
+
justify-content: space-between;
|
2172
|
+
align-items: center;
|
2082
2173
|
border-bottom: 1px solid #dbe2eb;
|
2174
|
+
padding: 10px 16px;
|
2175
|
+
|
2176
|
+
h2 {
|
2177
|
+
color: #172a41;
|
2178
|
+
font-size: 16px;
|
2179
|
+
font-weight: 700;
|
2180
|
+
line-height: 20px;
|
2181
|
+
}
|
2083
2182
|
}
|
2084
2183
|
|
2085
2184
|
.thread-titles-wrapper {
|
@@ -2401,9 +2500,7 @@ const profilePlusIcon = b `<svg xmlns="http://www.w3.org/2000/svg" width="56" he
|
|
2401
2500
|
<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"/>
|
2402
2501
|
</svg>`;
|
2403
2502
|
|
2404
|
-
|
2405
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2406
|
-
class PersonalizeDialog extends r$3 {
|
2503
|
+
class PersonalizeDialog extends r$2 {
|
2407
2504
|
constructor() {
|
2408
2505
|
super(...arguments);
|
2409
2506
|
this.isLoading = false;
|
@@ -2646,74 +2743,173 @@ class PersonalizeDialog extends r$3 {
|
|
2646
2743
|
</dialog>
|
2647
2744
|
`;
|
2648
2745
|
}
|
2649
|
-
}
|
2746
|
+
}
|
2650
2747
|
PersonalizeDialog.styles = [personalizeDialogStyles];
|
2651
2748
|
__decorate([
|
2652
|
-
e$
|
2749
|
+
e$3('dialog'),
|
2653
2750
|
__metadata("design:type", HTMLDialogElement)
|
2654
2751
|
], PersonalizeDialog.prototype, "dialogModal", void 0);
|
2655
2752
|
__decorate([
|
2656
|
-
e$
|
2753
|
+
e$3('.dropdown-list'),
|
2657
2754
|
__metadata("design:type", HTMLUListElement)
|
2658
2755
|
], PersonalizeDialog.prototype, "dropdownList", void 0);
|
2659
2756
|
__decorate([
|
2660
|
-
e$
|
2757
|
+
e$3('.dropdown-trigger'),
|
2661
2758
|
__metadata("design:type", HTMLDivElement)
|
2662
2759
|
], PersonalizeDialog.prototype, "dropdownTrigger", void 0);
|
2663
2760
|
__decorate([
|
2664
|
-
n
|
2761
|
+
n({ type: Array }),
|
2665
2762
|
__metadata("design:type", Array)
|
2666
2763
|
], PersonalizeDialog.prototype, "defaultProductHandles", void 0);
|
2667
2764
|
__decorate([
|
2668
|
-
n
|
2765
|
+
n({ type: Array }),
|
2669
2766
|
__metadata("design:type", Array)
|
2670
2767
|
], PersonalizeDialog.prototype, "defaultProfiles", void 0);
|
2671
2768
|
__decorate([
|
2672
|
-
n
|
2769
|
+
n({ type: Boolean }),
|
2673
2770
|
__metadata("design:type", Object)
|
2674
2771
|
], PersonalizeDialog.prototype, "isLoading", void 0);
|
2675
2772
|
__decorate([
|
2676
|
-
n
|
2773
|
+
n({ type: String }),
|
2677
2774
|
__metadata("design:type", Object)
|
2678
2775
|
], PersonalizeDialog.prototype, "state", void 0);
|
2679
2776
|
__decorate([
|
2680
|
-
n
|
2777
|
+
n({ type: String }),
|
2681
2778
|
__metadata("design:type", Object)
|
2682
2779
|
], PersonalizeDialog.prototype, "profileType", void 0);
|
2683
2780
|
__decorate([
|
2684
|
-
n
|
2781
|
+
n({ type: String }),
|
2685
2782
|
__metadata("design:type", Object)
|
2686
2783
|
], PersonalizeDialog.prototype, "selectedProfile", void 0);
|
2687
2784
|
__decorate([
|
2688
|
-
n
|
2785
|
+
n({ type: String }),
|
2689
2786
|
__metadata("design:type", Object)
|
2690
2787
|
], PersonalizeDialog.prototype, "visitorType", void 0);
|
2691
2788
|
__decorate([
|
2692
|
-
n
|
2789
|
+
n({ type: String }),
|
2693
2790
|
__metadata("design:type", Object)
|
2694
2791
|
], PersonalizeDialog.prototype, "productHandle", void 0);
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2698
|
-
], PersonalizeDialog);
|
2792
|
+
if (!customElements.get('personalize-dialog')) {
|
2793
|
+
customElements.define('personalize-dialog', PersonalizeDialog);
|
2794
|
+
}
|
2699
2795
|
|
2700
2796
|
/**
|
2701
2797
|
* @license
|
2702
2798
|
* Copyright 2017 Google LLC
|
2703
2799
|
* SPDX-License-Identifier: BSD-3-Clause
|
2704
|
-
*/
|
2705
|
-
|
2706
|
-
|
2800
|
+
*/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);
|
2801
|
+
|
2802
|
+
const markdown = (text) => {
|
2803
|
+
let src = text;
|
2804
|
+
const rx_space = /\t|\r|\uf8ff/g;
|
2805
|
+
const rx_hr = /^([*\-=_] *){3,}$/gm;
|
2806
|
+
const rx_blockquote = /\n *> *([^]*?)(?=(\n|$){2})/g;
|
2807
|
+
const rx_list = /\n( *)(?:[*\-+]|((\d+)|([a-z])|[A-Z])[.)]) +([^]*?)(?=(\n|$){2})/g;
|
2808
|
+
const rx_listjoin = /<\/(ol|ul)>\n\n<\1>/g;
|
2809
|
+
const rx_highlight = /(^|[^A-Za-z\d\\])(([*_])|(~)|(\^)|(--)|(\+\+)|`)(\2?)([^<]*?)\2\8(?!\2)(?=\W|_|$)/g;
|
2810
|
+
const rx_code = /\n((```|~~~).*\n?([^]*?)\n?\2|(( {4}.*?\n)+))/g;
|
2811
|
+
const rx_link = /((!?)\[(.*?)\]\((.*?)( ".*")?\)|\\([\\`*_{}[\]()#+\-.!~]))/g;
|
2812
|
+
const rx_table = /\n(( *\|.*?\| *\n)+)/g;
|
2813
|
+
const rx_thead = /^.*\n( *\|( *:?-+:?-+:? *\|)* *\n|)/;
|
2814
|
+
const rx_row = /.*\n/g;
|
2815
|
+
const rx_cell = /\|(.*?[^\\])\|/g;
|
2816
|
+
const rx_heading = /(?=^|>|\n)([>\s]*?)(#{1,6}) (.*?)( #*)? *(?=\n|$)/g;
|
2817
|
+
const rx_para = /(?=^|>|\n)\s*\n+([^<]+?)\n+\s*(?=\n|<|$)/g;
|
2818
|
+
const rx_stash = /-\d+\uf8ff/g;
|
2819
|
+
const stash = {};
|
2820
|
+
let si = 0;
|
2821
|
+
function replace(rex, fn) {
|
2822
|
+
src = src.replace(rex, fn);
|
2823
|
+
}
|
2824
|
+
function element(tag, content) {
|
2825
|
+
return `<${tag}>${content}</${tag}>`;
|
2826
|
+
}
|
2827
|
+
function blockquote(src) {
|
2828
|
+
return src.replace(rx_blockquote, (_, content) => {
|
2829
|
+
return element('blockquote', blockquote(highlight(content.replace(/^ *> */gm, ''))));
|
2830
|
+
});
|
2831
|
+
}
|
2832
|
+
function list(src) {
|
2833
|
+
return src.replace(rx_list, (all, ind, ol, num, low, content) => {
|
2834
|
+
const entry = element('li', highlight(content
|
2835
|
+
.split(new RegExp(`\n ?${ind}(?:(?:\\d+|[a-zA-Z])[.)]|[*\\-+]) +`, 'g'))
|
2836
|
+
.map(list)
|
2837
|
+
.join('</li><li>')));
|
2838
|
+
return `\n${ol
|
2839
|
+
? `<ol start="${num
|
2840
|
+
? ol + '">'
|
2841
|
+
: `${parseInt(ol, 36) - 9}" style="list-style-type:${low ? 'low' : 'upp'}er-alpha">`}${entry}</ol>`
|
2842
|
+
: element('ul', entry)}`;
|
2843
|
+
});
|
2844
|
+
}
|
2845
|
+
function highlight(src) {
|
2846
|
+
return src.replace(rx_highlight, function (all, _, p1, emp, sub, sup, small, big, p2, content) {
|
2847
|
+
return (_ +
|
2848
|
+
element(emp
|
2849
|
+
? p2
|
2850
|
+
? 'strong'
|
2851
|
+
: 'em'
|
2852
|
+
: sub
|
2853
|
+
? p2
|
2854
|
+
? 's'
|
2855
|
+
: 'sub'
|
2856
|
+
: sup
|
2857
|
+
? 'sup'
|
2858
|
+
: small
|
2859
|
+
? 'small'
|
2860
|
+
: big
|
2861
|
+
? 'big'
|
2862
|
+
: 'code', highlight(content)));
|
2863
|
+
});
|
2864
|
+
}
|
2865
|
+
src = `\n${src}\n`;
|
2866
|
+
replace(rx_space, ' ');
|
2867
|
+
src = blockquote(src);
|
2868
|
+
replace(rx_hr, '<hr/>');
|
2869
|
+
src = list(src);
|
2870
|
+
replace(rx_listjoin, '');
|
2871
|
+
replace(rx_code, (_, p1, p2, p3, p4) => {
|
2872
|
+
stash[--si] = element('pre', element('code', p3 || p4.replace(/^ {4}/gm, '')));
|
2873
|
+
return `${si}\uf8ff`;
|
2874
|
+
});
|
2875
|
+
replace(rx_link, (_, p1, p2, p3, p4, p5, p6) => {
|
2876
|
+
stash[--si] = p4
|
2877
|
+
? p2
|
2878
|
+
? `<img src="${p4}" alt="${p3}"/>`
|
2879
|
+
: `<a href="${p4}">${highlight(p3)}</a>`
|
2880
|
+
: p6;
|
2881
|
+
return `${si}\uf8ff`;
|
2882
|
+
});
|
2883
|
+
replace(rx_table, (_, table) => {
|
2884
|
+
var _a;
|
2885
|
+
const sep = ((_a = table.match(rx_thead)) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
2886
|
+
return `\n${element('table', table.replace(rx_row, (row, ri) => {
|
2887
|
+
return row === sep
|
2888
|
+
? ''
|
2889
|
+
: element('tr', row.replace(rx_cell, (_, cell, ci) => ci
|
2890
|
+
? element(sep && !ri ? 'th' : 'td', highlight(cell || ''))
|
2891
|
+
: ''));
|
2892
|
+
}))}`;
|
2893
|
+
});
|
2894
|
+
replace(rx_heading, (_, prefix, p1, p2) => {
|
2895
|
+
return prefix + element(`h${p1.length}`, highlight(p2));
|
2896
|
+
});
|
2897
|
+
replace(rx_para, (_, content) => {
|
2898
|
+
return element('p', highlight(content));
|
2899
|
+
});
|
2900
|
+
replace(rx_stash, (all) => stash[parseInt(all)]);
|
2901
|
+
return src.trim();
|
2902
|
+
};
|
2707
2903
|
|
2708
|
-
|
2709
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2710
|
-
class MarkdownRenderer extends r$3 {
|
2904
|
+
class MarkdownRenderer extends r$2 {
|
2711
2905
|
render() {
|
2712
|
-
|
2713
|
-
const
|
2714
|
-
|
2906
|
+
// Remove lit markers from slot content
|
2907
|
+
const slotContent = this.innerHTML
|
2908
|
+
.trim()
|
2909
|
+
.replace(/<!--\?lit\$[\d$]+-->/g, '');
|
2910
|
+
return o(markdown(slotContent));
|
2715
2911
|
}
|
2716
|
-
}
|
2912
|
+
}
|
2717
2913
|
MarkdownRenderer.styles = i$4 `
|
2718
2914
|
:host {
|
2719
2915
|
font-family: 'Inter', sans-serif;
|
@@ -2725,14 +2921,11 @@ MarkdownRenderer.styles = i$4 `
|
|
2725
2921
|
}
|
2726
2922
|
}
|
2727
2923
|
`;
|
2728
|
-
|
2729
|
-
|
2730
|
-
|
2731
|
-
|
2732
|
-
|
2733
|
-
let TooltipComponent =
|
2734
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2735
|
-
class TooltipComponent extends r$3 {
|
2924
|
+
if (!customElements.get('markdown-renderer')) {
|
2925
|
+
customElements.define('markdown-renderer', MarkdownRenderer);
|
2926
|
+
}
|
2927
|
+
|
2928
|
+
class TooltipComponent extends r$2 {
|
2736
2929
|
constructor() {
|
2737
2930
|
super(...arguments);
|
2738
2931
|
this.position = 'bottom-left';
|
@@ -2744,7 +2937,7 @@ class TooltipComponent extends r$3 {
|
|
2744
2937
|
<div class="tooltip ${this.position}">${this.text}</div>
|
2745
2938
|
`;
|
2746
2939
|
}
|
2747
|
-
}
|
2940
|
+
}
|
2748
2941
|
TooltipComponent.styles = [
|
2749
2942
|
i$4 `
|
2750
2943
|
:host {
|
@@ -2756,7 +2949,6 @@ TooltipComponent.styles = [
|
|
2756
2949
|
position: absolute;
|
2757
2950
|
color: #172a41;
|
2758
2951
|
padding: 4px 8px;
|
2759
|
-
border-radius: 4px;
|
2760
2952
|
white-space: nowrap;
|
2761
2953
|
font-size: 12px;
|
2762
2954
|
opacity: 0;
|
@@ -2843,17 +3035,16 @@ TooltipComponent.styles = [
|
|
2843
3035
|
`,
|
2844
3036
|
];
|
2845
3037
|
__decorate([
|
2846
|
-
n
|
3038
|
+
n({ type: String }),
|
2847
3039
|
__metadata("design:type", String)
|
2848
3040
|
], TooltipComponent.prototype, "position", void 0);
|
2849
3041
|
__decorate([
|
2850
|
-
n
|
3042
|
+
n({ type: String }),
|
2851
3043
|
__metadata("design:type", Object)
|
2852
3044
|
], TooltipComponent.prototype, "text", void 0);
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
], TooltipComponent);
|
3045
|
+
if (!customElements.get('tooltip-component')) {
|
3046
|
+
customElements.define('tooltip-component', TooltipComponent);
|
3047
|
+
}
|
2857
3048
|
|
2858
3049
|
const confirmDialogStyles = i$4 `
|
2859
3050
|
:host {
|
@@ -2934,9 +3125,7 @@ const confirmDialogStyles = i$4 `
|
|
2934
3125
|
}
|
2935
3126
|
`;
|
2936
3127
|
|
2937
|
-
|
2938
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2939
|
-
class ConfirmDialog extends r$3 {
|
3128
|
+
class ConfirmDialog extends r$2 {
|
2940
3129
|
onAcceptClick(e) {
|
2941
3130
|
e.preventDefault();
|
2942
3131
|
this.dispatchEvent(new CustomEvent('accept', {
|
@@ -2969,19 +3158,17 @@ class ConfirmDialog extends r$3 {
|
|
2969
3158
|
</div>
|
2970
3159
|
`;
|
2971
3160
|
}
|
2972
|
-
}
|
3161
|
+
}
|
2973
3162
|
ConfirmDialog.styles = [confirmDialogStyles];
|
2974
|
-
|
2975
|
-
|
2976
|
-
|
2977
|
-
|
2978
|
-
|
2979
|
-
let ChatSection =
|
2980
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2981
|
-
class ChatSection extends r$3 {
|
3163
|
+
if (!customElements.get('confirm-dialog')) {
|
3164
|
+
customElements.define('confirm-dialog', ConfirmDialog);
|
3165
|
+
}
|
3166
|
+
|
3167
|
+
class ChatSection extends r$2 {
|
2982
3168
|
constructor() {
|
2983
3169
|
super(...arguments);
|
2984
3170
|
this.showChatThreads = false;
|
3171
|
+
this.deleteAllThreads = false;
|
2985
3172
|
this.userQuery = '';
|
2986
3173
|
}
|
2987
3174
|
scrollToBottom() {
|
@@ -3006,6 +3193,14 @@ class ChatSection extends r$3 {
|
|
3006
3193
|
await this.processMessage(e, message);
|
3007
3194
|
}
|
3008
3195
|
handleThreadDelete() {
|
3196
|
+
if (this.deleteAllThreads) {
|
3197
|
+
this.dispatchEvent(new CustomEvent('delete-all-threads', {
|
3198
|
+
composed: true,
|
3199
|
+
bubbles: true,
|
3200
|
+
}));
|
3201
|
+
this.deleteAllThreads = false;
|
3202
|
+
return;
|
3203
|
+
}
|
3009
3204
|
if (!this.deleteThreadId) {
|
3010
3205
|
return;
|
3011
3206
|
}
|
@@ -3059,8 +3254,10 @@ class ChatSection extends r$3 {
|
|
3059
3254
|
`;
|
3060
3255
|
}
|
3061
3256
|
chatWindow() {
|
3062
|
-
if (this.isLoadingHistory) {
|
3063
|
-
return x
|
3257
|
+
if (this.isLoadingHistory || this.isLoadingThreads) {
|
3258
|
+
return x `<div class="messages loading">
|
3259
|
+
<load-spinner></load-spinner>
|
3260
|
+
</div>`;
|
3064
3261
|
}
|
3065
3262
|
return x `
|
3066
3263
|
<div class="messages">
|
@@ -3101,16 +3298,20 @@ class ChatSection extends r$3 {
|
|
3101
3298
|
`;
|
3102
3299
|
}
|
3103
3300
|
quickPrompts() {
|
3104
|
-
|
3105
|
-
|
3301
|
+
if (this.isLoadingHistory || this.isTyping || this.isLoadingThreads) {
|
3302
|
+
return E;
|
3303
|
+
}
|
3304
|
+
const prompts = this.messages.length
|
3305
|
+
? this.messages[0].welcomePrompts
|
3306
|
+
: this.prompts
|
3307
|
+
? this.prompts.split(',').map((prompt) => prompt.trim())
|
3308
|
+
: ['Best Sellers'];
|
3309
|
+
if (!prompts) {
|
3106
3310
|
return E;
|
3107
3311
|
}
|
3108
|
-
const defaultPrompts = this.prompts
|
3109
|
-
? this.prompts.split(',').map((prompt) => prompt.trim())
|
3110
|
-
: ['Best Selling Items', 'Hot Sales'];
|
3111
3312
|
return x `
|
3112
3313
|
<div class="prompts btn">
|
3113
|
-
${
|
3314
|
+
${prompts.map((prompt) => x `
|
3114
3315
|
<div
|
3115
3316
|
class="prompt"
|
3116
3317
|
@click=${(e) => this.processMessage(e, prompt)}
|
@@ -3214,10 +3415,10 @@ class ChatSection extends r$3 {
|
|
3214
3415
|
</tooltip-component>
|
3215
3416
|
<tooltip-component
|
3216
3417
|
.position=${'bottom-right'}
|
3217
|
-
.text=${'
|
3418
|
+
.text=${'Search History'}
|
3218
3419
|
>
|
3219
3420
|
<button
|
3220
|
-
class=${e$
|
3421
|
+
class=${e$1({
|
3221
3422
|
btn: true,
|
3222
3423
|
'btn-icon': true,
|
3223
3424
|
'threads-btn': true,
|
@@ -3289,11 +3490,27 @@ class ChatSection extends r$3 {
|
|
3289
3490
|
}
|
3290
3491
|
return x ` <div id="modal-chat-threads">
|
3291
3492
|
<div class="chat-threads">
|
3292
|
-
<
|
3493
|
+
<div class="title-wrapper">
|
3494
|
+
<h2>Search History</h2>
|
3495
|
+
${this.chatThreads.size
|
3496
|
+
? x `<div
|
3497
|
+
class="trash-icon"
|
3498
|
+
@click=${() => {
|
3499
|
+
if (this.isTyping) {
|
3500
|
+
return;
|
3501
|
+
}
|
3502
|
+
this.deleteAllThreads = true;
|
3503
|
+
this.showChatThreads = false;
|
3504
|
+
}}
|
3505
|
+
>
|
3506
|
+
${trashIcon}
|
3507
|
+
</div>`
|
3508
|
+
: E}
|
3509
|
+
</div>
|
3293
3510
|
<div class="thread-titles-wrapper">
|
3294
3511
|
${o$1(this.chatThreads.values(), (thread) => x `
|
3295
3512
|
<div
|
3296
|
-
class=${e$
|
3513
|
+
class=${e$1({
|
3297
3514
|
'thread-title': true,
|
3298
3515
|
disabled: this.isTyping,
|
3299
3516
|
})}
|
@@ -3333,10 +3550,17 @@ class ChatSection extends r$3 {
|
|
3333
3550
|
</div>`;
|
3334
3551
|
}
|
3335
3552
|
render() {
|
3553
|
+
if (this.merchantImage) {
|
3554
|
+
// set the merchant image as a css variable
|
3555
|
+
this.style.setProperty('--shopgpt-merchant-img-url', `url('${this.merchantImage}')`);
|
3556
|
+
}
|
3557
|
+
else {
|
3558
|
+
this.style.removeProperty('--shopgpt-merchant-img-url');
|
3559
|
+
}
|
3336
3560
|
return x `
|
3337
3561
|
<div class="chat-header">${this.contextButton()}</div>
|
3338
3562
|
<div
|
3339
|
-
class=${e$
|
3563
|
+
class=${e$1({
|
3340
3564
|
'chatbot-section': true,
|
3341
3565
|
'modal-view': this.viewType === 'modal',
|
3342
3566
|
})}
|
@@ -3350,7 +3574,7 @@ class ChatSection extends r$3 {
|
|
3350
3574
|
placeholder="Type your search here..."
|
3351
3575
|
/>
|
3352
3576
|
<button
|
3353
|
-
class=${e$
|
3577
|
+
class=${e$1({
|
3354
3578
|
btn: true,
|
3355
3579
|
modal: this.viewType === 'modal',
|
3356
3580
|
})}
|
@@ -3367,107 +3591,130 @@ class ChatSection extends r$3 {
|
|
3367
3591
|
.defaultProfiles=${this.profiles}
|
3368
3592
|
></personalize-dialog>
|
3369
3593
|
${this.renderChatThreads()}
|
3370
|
-
${this.deleteThreadId
|
3594
|
+
${this.deleteThreadId || this.deleteAllThreads
|
3371
3595
|
? x `
|
3372
3596
|
<confirm-dialog
|
3373
3597
|
@accept=${this.handleThreadDelete}
|
3374
|
-
@decline=${() =>
|
3598
|
+
@decline=${() => {
|
3599
|
+
this.deleteThreadId = '';
|
3600
|
+
this.deleteAllThreads = false;
|
3601
|
+
}}
|
3375
3602
|
>
|
3376
|
-
<h2 slot="title">
|
3603
|
+
<h2 slot="title">
|
3604
|
+
${this.deleteAllThreads
|
3605
|
+
? 'Delete Entire Chat History?'
|
3606
|
+
: 'Delete Chat?'}
|
3607
|
+
</h2>
|
3377
3608
|
<p slot="content">
|
3378
3609
|
This action cannot be undone. Are you sure you want to delete
|
3379
|
-
|
3610
|
+
${this.deleteAllThreads
|
3611
|
+
? ' the entire chat history'
|
3612
|
+
: x `<b
|
3613
|
+
>"${this.chatThreads.get(this.deleteThreadId)
|
3614
|
+
.title}"</b
|
3615
|
+
>`}?
|
3380
3616
|
</p>
|
3381
3617
|
</confirm-dialog>
|
3382
3618
|
`
|
3383
3619
|
: E}
|
3384
3620
|
`;
|
3385
3621
|
}
|
3386
|
-
}
|
3622
|
+
}
|
3387
3623
|
ChatSection.styles = [chatSectionStyles];
|
3388
3624
|
__decorate([
|
3389
|
-
n
|
3625
|
+
n({ type: String }),
|
3626
|
+
__metadata("design:type", Object)
|
3627
|
+
], ChatSection.prototype, "merchantImage", void 0);
|
3628
|
+
__decorate([
|
3629
|
+
n({ type: String }),
|
3390
3630
|
__metadata("design:type", Object)
|
3391
3631
|
], ChatSection.prototype, "brandName", void 0);
|
3392
3632
|
__decorate([
|
3393
|
-
n
|
3633
|
+
n({ type: String }),
|
3394
3634
|
__metadata("design:type", Object)
|
3395
3635
|
], ChatSection.prototype, "prompts", void 0);
|
3396
3636
|
__decorate([
|
3397
|
-
n
|
3637
|
+
n({ type: Boolean }),
|
3638
|
+
__metadata("design:type", Boolean)
|
3639
|
+
], ChatSection.prototype, "isLoadingThreads", void 0);
|
3640
|
+
__decorate([
|
3641
|
+
n({ type: Object }),
|
3398
3642
|
__metadata("design:type", Map)
|
3399
3643
|
], ChatSection.prototype, "chatThreads", void 0);
|
3400
3644
|
__decorate([
|
3401
|
-
r
|
3645
|
+
r(),
|
3402
3646
|
__metadata("design:type", String)
|
3403
3647
|
], ChatSection.prototype, "deleteThreadId", void 0);
|
3404
3648
|
__decorate([
|
3405
|
-
n
|
3649
|
+
n({ type: Boolean }),
|
3406
3650
|
__metadata("design:type", Object)
|
3407
3651
|
], ChatSection.prototype, "showChatThreads", void 0);
|
3408
3652
|
__decorate([
|
3409
|
-
n
|
3653
|
+
n({ type: Boolean }),
|
3410
3654
|
__metadata("design:type", Boolean)
|
3411
3655
|
], ChatSection.prototype, "isLoadingHistory", void 0);
|
3412
3656
|
__decorate([
|
3413
|
-
n
|
3657
|
+
n({ type: Boolean }),
|
3414
3658
|
__metadata("design:type", Object)
|
3415
3659
|
], ChatSection.prototype, "devMode", void 0);
|
3416
3660
|
__decorate([
|
3417
|
-
n
|
3661
|
+
n({ type: Boolean }),
|
3418
3662
|
__metadata("design:type", Boolean)
|
3419
3663
|
], ChatSection.prototype, "isTyping", void 0);
|
3420
3664
|
__decorate([
|
3421
|
-
n
|
3665
|
+
n({ type: Boolean }),
|
3422
3666
|
__metadata("design:type", Boolean)
|
3423
3667
|
], ChatSection.prototype, "isFailed", void 0);
|
3424
3668
|
__decorate([
|
3425
|
-
n
|
3669
|
+
n({ type: Array }),
|
3426
3670
|
__metadata("design:type", Array)
|
3427
3671
|
], ChatSection.prototype, "messages", void 0);
|
3428
3672
|
__decorate([
|
3429
|
-
n
|
3673
|
+
n({ type: Array }),
|
3430
3674
|
__metadata("design:type", Array)
|
3431
3675
|
], ChatSection.prototype, "profiles", void 0);
|
3432
3676
|
__decorate([
|
3433
|
-
n
|
3677
|
+
n({ type: Array }),
|
3434
3678
|
__metadata("design:type", Array)
|
3435
3679
|
], ChatSection.prototype, "productHandles", void 0);
|
3436
3680
|
__decorate([
|
3437
|
-
n
|
3681
|
+
n({ type: Object }),
|
3438
3682
|
__metadata("design:type", Object)
|
3439
3683
|
], ChatSection.prototype, "thread", void 0);
|
3440
3684
|
__decorate([
|
3441
|
-
n
|
3685
|
+
n({ type: Object }),
|
3442
3686
|
__metadata("design:type", Object)
|
3443
3687
|
], ChatSection.prototype, "siteCurrency", void 0);
|
3444
3688
|
__decorate([
|
3445
|
-
|
3689
|
+
r(),
|
3690
|
+
__metadata("design:type", Object)
|
3691
|
+
], ChatSection.prototype, "deleteAllThreads", void 0);
|
3692
|
+
__decorate([
|
3693
|
+
e$3('.context-container'),
|
3446
3694
|
__metadata("design:type", Object)
|
3447
3695
|
], ChatSection.prototype, "contextContainerElement", void 0);
|
3448
3696
|
__decorate([
|
3449
|
-
e$
|
3697
|
+
e$3('.chat-window'),
|
3450
3698
|
__metadata("design:type", Object)
|
3451
3699
|
], ChatSection.prototype, "chatWindowElement", void 0);
|
3452
3700
|
__decorate([
|
3453
|
-
e$
|
3701
|
+
e$3('personalize-dialog'),
|
3454
3702
|
__metadata("design:type", Object)
|
3455
3703
|
], ChatSection.prototype, "personalizeDialogElement", void 0);
|
3456
3704
|
__decorate([
|
3457
|
-
n
|
3705
|
+
n({ type: String }),
|
3458
3706
|
__metadata("design:type", Object)
|
3459
3707
|
], ChatSection.prototype, "userQuery", void 0);
|
3460
|
-
|
3461
|
-
|
3462
|
-
|
3463
|
-
], ChatSection);
|
3708
|
+
if (!customElements.get('chat-section')) {
|
3709
|
+
customElements.define('chat-section', ChatSection);
|
3710
|
+
}
|
3464
3711
|
|
3465
3712
|
const DIALOG_DELAY = 1000;
|
3466
|
-
const LATEST_THREAD_LOAD_DAYS = 14;
|
3467
3713
|
const normalizePath = (path) => path.replace(/\/$/, '');
|
3468
|
-
|
3714
|
+
class ShopGPT extends r$2 {
|
3469
3715
|
constructor() {
|
3470
3716
|
super(...arguments);
|
3717
|
+
this.latestThreadLoad = DEFAULT_MAX_THREAD_AGE;
|
3471
3718
|
this.modalState = 'close';
|
3472
3719
|
this.isLoadingHistory = false;
|
3473
3720
|
this.isLoadingThreads = false;
|
@@ -3482,9 +3729,13 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3482
3729
|
return;
|
3483
3730
|
}
|
3484
3731
|
await this.loadChatThreads();
|
3485
|
-
await this.loadInitialQuery();
|
3486
3732
|
this.selectLatestThread();
|
3487
3733
|
};
|
3734
|
+
this.onPopState = () => {
|
3735
|
+
var _a;
|
3736
|
+
this.modalState = 'close';
|
3737
|
+
(_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
|
3738
|
+
};
|
3488
3739
|
this.submitQuery = (message) => {
|
3489
3740
|
if (!message) {
|
3490
3741
|
return;
|
@@ -3510,10 +3761,12 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3510
3761
|
}
|
3511
3762
|
disconnectedCallback() {
|
3512
3763
|
window.removeEventListener('edgetag-initialized', this.loadData);
|
3764
|
+
window.removeEventListener('popstate', this.onPopState);
|
3513
3765
|
super.disconnectedCallback();
|
3514
3766
|
}
|
3515
3767
|
init() {
|
3516
3768
|
window.addEventListener('edgetag-initialized', this.loadData);
|
3769
|
+
window.addEventListener('popstate', this.onPopState);
|
3517
3770
|
if (!this.uiMode || this.uiMode === 'overlay') {
|
3518
3771
|
delay(DIALOG_DELAY).then(() => {
|
3519
3772
|
var _a;
|
@@ -3528,6 +3781,19 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3528
3781
|
});
|
3529
3782
|
}
|
3530
3783
|
}
|
3784
|
+
setChatTitle(threadId, title) {
|
3785
|
+
if (!title || !threadId) {
|
3786
|
+
return;
|
3787
|
+
}
|
3788
|
+
const thread = this.chatThreads.get(threadId);
|
3789
|
+
if (thread) {
|
3790
|
+
this.chatThreads.set(thread.threadId, {
|
3791
|
+
...thread,
|
3792
|
+
title,
|
3793
|
+
});
|
3794
|
+
this.chatThreads = new Map(this.chatThreads);
|
3795
|
+
}
|
3796
|
+
}
|
3531
3797
|
async loadInitialQuery() {
|
3532
3798
|
var _a;
|
3533
3799
|
if (!this.selectedThreadId) {
|
@@ -3540,14 +3806,26 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3540
3806
|
if (!thread) {
|
3541
3807
|
return;
|
3542
3808
|
}
|
3809
|
+
const searchParam = new URLSearchParams(window.location.search);
|
3810
|
+
const fromAd = searchParam.get('shopGPT') === '1';
|
3543
3811
|
const productHandle = this.devMode
|
3544
3812
|
? (_a = thread === null || thread === void 0 ? void 0 : thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle
|
3545
|
-
:
|
3813
|
+
: fromAd
|
3814
|
+
? this.storeAPI.getCurrentProductHandle()
|
3815
|
+
: undefined;
|
3546
3816
|
try {
|
3547
3817
|
this.isTyping = true;
|
3548
3818
|
const reply = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
|
3819
|
+
if (reply.chatTitle) {
|
3820
|
+
this.setChatTitle(this.selectedThreadId, reply.chatTitle);
|
3821
|
+
}
|
3549
3822
|
this.messages = [
|
3550
|
-
{
|
3823
|
+
{
|
3824
|
+
sender: 'bot',
|
3825
|
+
message: reply.message,
|
3826
|
+
products: reply.products,
|
3827
|
+
welcomePrompts: reply.welcomePrompts,
|
3828
|
+
},
|
3551
3829
|
...this.messages,
|
3552
3830
|
];
|
3553
3831
|
this.products = reply.products || [];
|
@@ -3574,10 +3852,7 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3574
3852
|
}
|
3575
3853
|
}
|
3576
3854
|
selectLatestThread() {
|
3577
|
-
|
3578
|
-
return;
|
3579
|
-
}
|
3580
|
-
const cutoffTime = Date.now() - LATEST_THREAD_LOAD_DAYS * 24 * 60 * 60 * 1000;
|
3855
|
+
const cutoffTime = Date.now() - this.latestThreadLoad * 24 * 60 * 60 * 1000;
|
3581
3856
|
// If the latest thread is not older than cutoff we should load the thread
|
3582
3857
|
let latestThread;
|
3583
3858
|
for (const thread of this.chatThreads.values()) {
|
@@ -3589,9 +3864,11 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3589
3864
|
if (latestThread) {
|
3590
3865
|
this.setSelectedThreadId(latestThread.threadId);
|
3591
3866
|
}
|
3867
|
+
else if (!this.devMode) {
|
3868
|
+
this.createChatThread({ title: '' }, true);
|
3869
|
+
}
|
3592
3870
|
}
|
3593
3871
|
async loadHistory(threadId) {
|
3594
|
-
var _a, _b, _c;
|
3595
3872
|
try {
|
3596
3873
|
if (!threadId) {
|
3597
3874
|
this.messages = [];
|
@@ -3600,22 +3877,24 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3600
3877
|
}
|
3601
3878
|
this.isLoadingHistory = true;
|
3602
3879
|
const data = await this.shopGPTAPI.fetchChatHistory(threadId);
|
3880
|
+
let latestAvailableProducts = [];
|
3603
3881
|
this.messages = data.map((message) => {
|
3604
3882
|
var _a;
|
3605
|
-
|
3883
|
+
const products = (_a = message.products) === null || _a === void 0 ? void 0 : _a.map((product) => ({
|
3884
|
+
...product,
|
3885
|
+
quantity: 1,
|
3886
|
+
}));
|
3887
|
+
if (!latestAvailableProducts.length && (products === null || products === void 0 ? void 0 : products.length)) {
|
3888
|
+
latestAvailableProducts = products;
|
3889
|
+
}
|
3890
|
+
return {
|
3606
3891
|
message: message.message,
|
3607
3892
|
sender: message.sender,
|
3608
|
-
products
|
3609
|
-
|
3610
|
-
|
3611
|
-
})),
|
3612
|
-
});
|
3893
|
+
products,
|
3894
|
+
welcomePrompts: message.welcomePrompts,
|
3895
|
+
};
|
3613
3896
|
});
|
3614
|
-
this.products =
|
3615
|
-
(_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) => ({
|
3616
|
-
...product,
|
3617
|
-
quantity: 1,
|
3618
|
-
}))) !== null && _c !== void 0 ? _c : [];
|
3897
|
+
this.products = latestAvailableProducts;
|
3619
3898
|
}
|
3620
3899
|
catch (e) {
|
3621
3900
|
logger.error(e);
|
@@ -3656,6 +3935,21 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3656
3935
|
this.shopGPTAPI
|
3657
3936
|
.deleteSingleThread(threadId)
|
3658
3937
|
.then(this.loadChatThreads.bind(this))
|
3938
|
+
.then(() => {
|
3939
|
+
if (this.selectedThreadId === threadId) {
|
3940
|
+
this.setSelectedThreadId('');
|
3941
|
+
}
|
3942
|
+
})
|
3943
|
+
.catch(logger.error)
|
3944
|
+
.finally(() => (this.isLoadingThreads = false));
|
3945
|
+
}
|
3946
|
+
handleAllThreadsDelete(e) {
|
3947
|
+
e.stopPropagation();
|
3948
|
+
this.isLoadingThreads = true;
|
3949
|
+
this.shopGPTAPI
|
3950
|
+
.deleteAllThreads()
|
3951
|
+
.then(this.loadChatThreads.bind(this))
|
3952
|
+
.then(() => this.setSelectedThreadId(''))
|
3659
3953
|
.catch(logger.error)
|
3660
3954
|
.finally(() => (this.isLoadingThreads = false));
|
3661
3955
|
}
|
@@ -3674,21 +3968,20 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3674
3968
|
return;
|
3675
3969
|
}
|
3676
3970
|
if (reply.chatTitle) {
|
3677
|
-
|
3678
|
-
const thread = this.chatThreads.get(this.selectedThreadId);
|
3679
|
-
if (thread) {
|
3680
|
-
this.chatThreads.set(thread.threadId, {
|
3681
|
-
...thread,
|
3682
|
-
title: reply.chatTitle,
|
3683
|
-
});
|
3684
|
-
this.chatThreads = new Map(this.chatThreads);
|
3685
|
-
}
|
3971
|
+
this.setChatTitle(this.selectedThreadId, reply.chatTitle);
|
3686
3972
|
}
|
3687
3973
|
this.messages = [
|
3688
|
-
{
|
3974
|
+
{
|
3975
|
+
sender: 'bot',
|
3976
|
+
message: reply.message,
|
3977
|
+
products: reply.products,
|
3978
|
+
welcomePrompts: reply.welcomePrompts,
|
3979
|
+
},
|
3689
3980
|
...this.messages,
|
3690
3981
|
];
|
3691
|
-
|
3982
|
+
if (reply.products && reply.products.length > 0) {
|
3983
|
+
this.products = reply.products;
|
3984
|
+
}
|
3692
3985
|
}
|
3693
3986
|
catch (err) {
|
3694
3987
|
logger.error(err);
|
@@ -3713,6 +4006,7 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3713
4006
|
<dialog
|
3714
4007
|
id="shop-gpt-dialog-overlay"
|
3715
4008
|
@delete-thread=${this.handleThreadDelete}
|
4009
|
+
@delete-all-threads=${this.handleAllThreadsDelete}
|
3716
4010
|
>
|
3717
4011
|
<div class="mobile-version">
|
3718
4012
|
Please switch to the desktop version for the best experience.
|
@@ -3731,6 +4025,7 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3731
4025
|
.products=${this.products}
|
3732
4026
|
.isLoadingHistory=${this.isLoadingHistory}
|
3733
4027
|
.siteCurrency=${this.getSiteCurrency()}
|
4028
|
+
.isLoadingThreads=${this.isLoadingThreads}
|
3734
4029
|
></products-section>
|
3735
4030
|
<chat-section
|
3736
4031
|
.prompts=${this.quickPrompts}
|
@@ -3747,6 +4042,7 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3747
4042
|
.productHandles=${this.productHandles}
|
3748
4043
|
.profiles=${this.profiles}
|
3749
4044
|
.viewType=${'overlay'}
|
4045
|
+
.isLoadingThreads=${this.isLoadingThreads}
|
3750
4046
|
></chat-section>
|
3751
4047
|
</div>
|
3752
4048
|
</dialog>
|
@@ -3767,10 +4063,15 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3767
4063
|
>
|
3768
4064
|
${chatIcon}
|
3769
4065
|
</button>
|
4066
|
+
<div class="chatbot-hover-text">What are you looking for today?</div>
|
3770
4067
|
</div>`;
|
3771
4068
|
}
|
3772
4069
|
return x `
|
3773
|
-
<div
|
4070
|
+
<div
|
4071
|
+
id="shop-gpt-modal"
|
4072
|
+
@delete-thread=${this.handleThreadDelete}
|
4073
|
+
@delete-all-threads=${this.handleAllThreadsDelete}
|
4074
|
+
>
|
3774
4075
|
<chat-section
|
3775
4076
|
.prompts=${this.quickPrompts}
|
3776
4077
|
.brandName=${this.brandName}
|
@@ -3789,55 +4090,61 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3789
4090
|
.closeModal=${closeModal}
|
3790
4091
|
.setSelectedThreadId=${this.setSelectedThreadId.bind(this)}
|
3791
4092
|
.chatThreads=${this.chatThreads}
|
4093
|
+
.isLoadingThreads=${this.isLoadingThreads}
|
4094
|
+
.merchantImage=${this.merchantImage}
|
3792
4095
|
></chat-section>
|
3793
4096
|
</div>
|
3794
4097
|
`;
|
3795
4098
|
}
|
3796
|
-
}
|
4099
|
+
}
|
3797
4100
|
ShopGPT.styles = [shopGPTStyles];
|
3798
4101
|
__decorate([
|
3799
|
-
|
4102
|
+
n({ type: Number }),
|
4103
|
+
__metadata("design:type", Number)
|
4104
|
+
], ShopGPT.prototype, "latestThreadLoad", void 0);
|
4105
|
+
__decorate([
|
4106
|
+
e$3('#shop-gpt-dialog-overlay'),
|
3800
4107
|
__metadata("design:type", Object)
|
3801
4108
|
], ShopGPT.prototype, "shopGPTDialog", void 0);
|
3802
4109
|
__decorate([
|
3803
|
-
n
|
4110
|
+
n({ type: String }),
|
3804
4111
|
__metadata("design:type", String)
|
3805
4112
|
], ShopGPT.prototype, "modalState", void 0);
|
3806
4113
|
__decorate([
|
3807
|
-
n
|
4114
|
+
n({ type: Boolean }),
|
3808
4115
|
__metadata("design:type", Object)
|
3809
4116
|
], ShopGPT.prototype, "isLoadingHistory", void 0);
|
3810
4117
|
__decorate([
|
3811
|
-
n
|
4118
|
+
n({ type: Boolean }),
|
3812
4119
|
__metadata("design:type", Object)
|
3813
4120
|
], ShopGPT.prototype, "isLoadingThreads", void 0);
|
3814
4121
|
__decorate([
|
3815
|
-
n
|
4122
|
+
n({ type: Boolean }),
|
3816
4123
|
__metadata("design:type", Object)
|
3817
4124
|
], ShopGPT.prototype, "isTyping", void 0);
|
3818
4125
|
__decorate([
|
3819
|
-
n
|
4126
|
+
n({ type: Boolean }),
|
3820
4127
|
__metadata("design:type", Object)
|
3821
4128
|
], ShopGPT.prototype, "isFailed", void 0);
|
3822
4129
|
__decorate([
|
3823
|
-
n
|
4130
|
+
n({ type: String }),
|
3824
4131
|
__metadata("design:type", Object)
|
3825
4132
|
], ShopGPT.prototype, "selectedThreadId", void 0);
|
3826
4133
|
__decorate([
|
3827
|
-
n
|
4134
|
+
n({ type: Array }),
|
3828
4135
|
__metadata("design:type", Array)
|
3829
4136
|
], ShopGPT.prototype, "products", void 0);
|
3830
4137
|
__decorate([
|
3831
|
-
n
|
4138
|
+
n({ type: Array }),
|
3832
4139
|
__metadata("design:type", Array)
|
3833
4140
|
], ShopGPT.prototype, "messages", void 0);
|
3834
4141
|
__decorate([
|
3835
|
-
n
|
4142
|
+
n({ type: Object }),
|
3836
4143
|
__metadata("design:type", Map)
|
3837
4144
|
], ShopGPT.prototype, "chatThreads", void 0);
|
3838
|
-
|
3839
|
-
|
3840
|
-
|
4145
|
+
if (!customElements.get('shop-gpt')) {
|
4146
|
+
customElements.define('shop-gpt', ShopGPT);
|
4147
|
+
}
|
3841
4148
|
|
3842
4149
|
var _a, _b;
|
3843
4150
|
var _c;
|
@@ -3861,8 +4168,17 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
|
|
3861
4168
|
shopGPT.brandName = params.brandName;
|
3862
4169
|
shopGPT.quickPrompts = params.quickPrompts;
|
3863
4170
|
shopGPT.merchantImage = params.merchantImage;
|
4171
|
+
shopGPT.latestThreadLoad = params.latestThreadLoad;
|
3864
4172
|
document.body.append(shopGPT);
|
3865
4173
|
},
|
4174
|
+
destroy() {
|
4175
|
+
if (!shopGPT) {
|
4176
|
+
return;
|
4177
|
+
}
|
4178
|
+
shopGPT.remove();
|
4179
|
+
shopGPT = undefined;
|
4180
|
+
delete window[registryKey];
|
4181
|
+
},
|
3866
4182
|
});
|
3867
4183
|
}
|
3868
4184
|
|