@blotoutio/providers-shop-gpt-sdk 1.21.0 → 1.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +341 -76
- package/index.js +341 -76
- package/index.mjs +341 -76
- package/package.json +1 -1
package/index.cjs.js
CHANGED
@@ -364,6 +364,23 @@ const usStates = new Map([
|
|
364
364
|
]);
|
365
365
|
new Set([...isoCountries.keys(), ...usStates.keys()]);
|
366
366
|
|
367
|
+
const createGradualRelease = ({ userId, rolloutPercentage = 10, }) => {
|
368
|
+
// Extract first 8 hex characters from UUID (32 bits)
|
369
|
+
const sample = userId.replace(/-/g, '').slice(0, 8);
|
370
|
+
const intVal = parseInt(sample, 16);
|
371
|
+
const maxVal = 0xffffffff; // 2^32 - 1
|
372
|
+
const normalized = intVal / maxVal;
|
373
|
+
// Explicitly enable all users for 100% rollout
|
374
|
+
const isInRollout = rolloutPercentage >= 100 ? true : normalized < rolloutPercentage / 100;
|
375
|
+
return {
|
376
|
+
name: 'gradual-release',
|
377
|
+
groupNames: new Set(['enabled', 'control']),
|
378
|
+
groupName: isInRollout ? 'enabled' : 'control',
|
379
|
+
isEnabled: isInRollout,
|
380
|
+
rolloutPercentage,
|
381
|
+
};
|
382
|
+
};
|
383
|
+
|
367
384
|
const createEnabled = () => ({
|
368
385
|
name: 'enabled',
|
369
386
|
groupNames: new Set(),
|
@@ -405,6 +422,11 @@ const createExperiment = (props) => {
|
|
405
422
|
return createDisabled();
|
406
423
|
case 'ab-test':
|
407
424
|
return createABTest(props);
|
425
|
+
case 'gradual-release':
|
426
|
+
return createGradualRelease({
|
427
|
+
userId: props.userId,
|
428
|
+
rolloutPercentage: props.rolloutPercentage || 10,
|
429
|
+
});
|
408
430
|
case 'preview':
|
409
431
|
return createPreview(props);
|
410
432
|
}
|
@@ -910,7 +932,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
|
|
910
932
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
911
933
|
const error = (message) => console.error(message);
|
912
934
|
const init = (params) => {
|
913
|
-
var _a, _b, _c;
|
935
|
+
var _a, _b, _c, _d;
|
914
936
|
if (typeof window == 'undefined' || typeof document == 'undefined') {
|
915
937
|
// if loaded in non-browser SDKs, return early
|
916
938
|
return;
|
@@ -933,6 +955,9 @@ const init = (params) => {
|
|
933
955
|
name: getExperimentName(mode),
|
934
956
|
userId: params.userId,
|
935
957
|
preview: hasPreviewKey(),
|
958
|
+
rolloutPercentage: mode === 'gradual-release'
|
959
|
+
? (_d = params.manifest.variables) === null || _d === void 0 ? void 0 : _d.rolloutPercentage
|
960
|
+
: undefined,
|
936
961
|
});
|
937
962
|
const shouldShowUI = enabled || experiment.isEnabled;
|
938
963
|
if (experiment.name === 'preview' && shouldShowUI) {
|
@@ -1087,32 +1112,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
1087
1112
|
* Copyright 2019 Google LLC
|
1088
1113
|
* SPDX-License-Identifier: BSD-3-Clause
|
1089
1114
|
*/
|
1090
|
-
const t$2=globalThis,e$
|
1115
|
+
const t$2=globalThis,e$6=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$5=new WeakMap;let n$4 = class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s$2)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$6&&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$4("string"==typeof t?t:t+"",void 0,s$2),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$2)},S$1=(s,o)=>{if(e$6)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$6?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$5(e)})(t):t;
|
1091
1116
|
|
1092
1117
|
/**
|
1093
1118
|
* @license
|
1094
1119
|
* Copyright 2017 Google LLC
|
1095
1120
|
* SPDX-License-Identifier: BSD-3-Clause
|
1096
|
-
*/const{is:i$3,defineProperty:e$
|
1121
|
+
*/const{is:i$3,defineProperty:e$5,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$4,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),b$1={attribute:!0,type:String,converter:u$1,reflect:!1,useDefault:!1,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let y$1 = class y 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=b$1){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$5(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??b$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=[...r$4(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);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),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),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e,this[e]=h.fromAttribute(s,t.type)??this._$Ej?.get(e)??null,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f$1)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);}!1===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),!0!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),!0===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){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){const{wrapped:t}=i,e=this[s];!0!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}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._$EM();}catch(s){throw t=!1,this._$EM(),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);}_$EM(){this._$AL=new Map,this.isUpdatePending=!1;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return !0}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}};y$1.elementStyles=[],y$1.shadowRootOptions={mode:"open"},y$1[d$1("elementProperties")]=new Map,y$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y$1}),(a$1.reactiveElementVersions??=[]).push("2.1.0");
|
1097
1122
|
|
1098
1123
|
/**
|
1099
1124
|
* @license
|
1100
1125
|
* Copyright 2017 Google LLC
|
1101
1126
|
* SPDX-License-Identifier: BSD-3-Clause
|
1102
1127
|
*/
|
1103
|
-
const t$1=globalThis,i$2=t$1.trustedTypes,s$1=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$
|
1128
|
+
const t$1=globalThis,i$2=t$1.trustedTypes,s$1=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$4="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$2=`<${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$1?s$1.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$4+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$4)){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.3.0");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};
|
1104
1129
|
|
1105
1130
|
/**
|
1106
1131
|
* @license
|
1107
1132
|
* Copyright 2017 Google LLC
|
1108
1133
|
* SPDX-License-Identifier: BSD-3-Clause
|
1109
|
-
*/const s=globalThis;let i$1 = class i extends y$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 r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(r,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return T}};i$1._$litElement$=!0,i$1["finalized"]=!0,s.litElementHydrateSupport?.({LitElement:i$1});const o$
|
1134
|
+
*/const s=globalThis;let i$1 = class i extends y$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 r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(r,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return T}};i$1._$litElement$=!0,i$1["finalized"]=!0,s.litElementHydrateSupport?.({LitElement:i$1});const o$2=s.litElementPolyfillSupport;o$2?.({LitElement:i$1});(s.litElementVersions??=[]).push("4.2.0");
|
1110
1135
|
|
1111
1136
|
/**
|
1112
1137
|
* @license
|
1113
1138
|
* Copyright 2017 Google LLC
|
1114
1139
|
* SPDX-License-Identifier: BSD-3-Clause
|
1115
|
-
*/const o$
|
1140
|
+
*/const o$1={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1},r$2=(t=o$1,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),"setter"===n&&((t=Object.create(t)).wrapped=!0),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.C(o,void 0,t,e),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,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
|
1116
1141
|
|
1117
1142
|
/**
|
1118
1143
|
* @license
|
@@ -1125,13 +1150,13 @@ const t$1=globalThis,i$2=t$1.trustedTypes,s$1=i$2?i$2.createPolicy("lit-html",{c
|
|
1125
1150
|
* Copyright 2017 Google LLC
|
1126
1151
|
* SPDX-License-Identifier: BSD-3-Clause
|
1127
1152
|
*/
|
1128
|
-
const e$
|
1153
|
+
const e$3=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
1129
1154
|
|
1130
1155
|
/**
|
1131
1156
|
* @license
|
1132
1157
|
* Copyright 2017 Google LLC
|
1133
1158
|
* SPDX-License-Identifier: BSD-3-Clause
|
1134
|
-
*/function e$
|
1159
|
+
*/function e$2(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$3(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$3(n,s,{get(){return o(this)}})}}
|
1135
1160
|
|
1136
1161
|
const scrollBarStyles = i$4 `
|
1137
1162
|
::-webkit-scrollbar {
|
@@ -1320,20 +1345,20 @@ const shopGPTStyles = i$4 `
|
|
1320
1345
|
* Copyright 2017 Google LLC
|
1321
1346
|
* SPDX-License-Identifier: BSD-3-Clause
|
1322
1347
|
*/
|
1323
|
-
const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e$
|
1348
|
+
const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e$1=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)}}
|
1324
1349
|
|
1325
1350
|
/**
|
1326
1351
|
* @license
|
1327
1352
|
* Copyright 2018 Google LLC
|
1328
1353
|
* SPDX-License-Identifier: BSD-3-Clause
|
1329
|
-
*/const e
|
1354
|
+
*/const e=e$1(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}});
|
1330
1355
|
|
1331
1356
|
/**
|
1332
1357
|
* @license
|
1333
1358
|
* Copyright 2021 Google LLC
|
1334
1359
|
* SPDX-License-Identifier: BSD-3-Clause
|
1335
1360
|
*/
|
1336
|
-
function*o
|
1361
|
+
function*o(o,f){if(void 0!==o){let i=0;for(const t of o)yield f(t,i++);}}
|
1337
1362
|
|
1338
1363
|
const sendFilledIcon = b `
|
1339
1364
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
@@ -1730,9 +1755,9 @@ class ChatThreads extends i$1 {
|
|
1730
1755
|
</div>
|
1731
1756
|
${this.chatThreads.size
|
1732
1757
|
? x `<div class="threads">
|
1733
|
-
${o
|
1758
|
+
${o(this.chatThreads.values(), (thread) => x `
|
1734
1759
|
<div
|
1735
|
-
class=${e
|
1760
|
+
class=${e({
|
1736
1761
|
'thread-wrapper': true,
|
1737
1762
|
active: this.selectedThreadId === thread.threadId,
|
1738
1763
|
disabled: this.isStreaming,
|
@@ -2663,7 +2688,7 @@ __decorate([
|
|
2663
2688
|
__metadata("design:type", Object)
|
2664
2689
|
], BTCarousel.prototype, "disableButtons", void 0);
|
2665
2690
|
__decorate([
|
2666
|
-
e$
|
2691
|
+
e$2('.carousel-content'),
|
2667
2692
|
__metadata("design:type", HTMLElement)
|
2668
2693
|
], BTCarousel.prototype, "scrollContainer", void 0);
|
2669
2694
|
__decorate([
|
@@ -5921,10 +5946,18 @@ class ProductItem extends TWLitElement$3 {
|
|
5921
5946
|
}));
|
5922
5947
|
}
|
5923
5948
|
}
|
5949
|
+
firstUpdated(changedProperties) {
|
5950
|
+
super.firstUpdated(changedProperties);
|
5951
|
+
this.dispatchEvent(new CustomEvent('product-rendered', {
|
5952
|
+
detail: { product: this.product },
|
5953
|
+
composed: true,
|
5954
|
+
bubbles: true,
|
5955
|
+
}));
|
5956
|
+
}
|
5924
5957
|
render() {
|
5925
5958
|
return x `
|
5926
5959
|
<a
|
5927
|
-
class=${e
|
5960
|
+
class=${e({ product: true, modal: this.viewType === 'modal' })}
|
5928
5961
|
href=${this.getProductUrl(this.product.url)}
|
5929
5962
|
@click=${() => this.productClicked(this.product)}
|
5930
5963
|
>
|
@@ -6077,12 +6110,19 @@ const productsListStyles = i$4 `
|
|
6077
6110
|
gap: 24px;
|
6078
6111
|
position: relative;
|
6079
6112
|
}
|
6113
|
+
|
6114
|
+
@media (max-width: 768px) {
|
6115
|
+
.scroll-btns {
|
6116
|
+
display: none !important;
|
6117
|
+
}
|
6118
|
+
}
|
6080
6119
|
`;
|
6081
6120
|
|
6082
6121
|
class ProductsList extends i$1 {
|
6083
6122
|
constructor() {
|
6084
6123
|
super(...arguments);
|
6085
6124
|
this.showButtons = true;
|
6125
|
+
this.hasPeeked = false;
|
6086
6126
|
this.updateButtonsState = () => {
|
6087
6127
|
if (!this.productsEle) {
|
6088
6128
|
return;
|
@@ -6126,6 +6166,28 @@ class ProductsList extends i$1 {
|
|
6126
6166
|
this.resizeObserver.observe(child);
|
6127
6167
|
});
|
6128
6168
|
this.updateButtonsState();
|
6169
|
+
this.dispatchEvent(new CustomEvent('products-rendered', {
|
6170
|
+
detail: { products: this.products },
|
6171
|
+
composed: true,
|
6172
|
+
bubbles: true,
|
6173
|
+
}));
|
6174
|
+
}
|
6175
|
+
updated(changedProperties) {
|
6176
|
+
super.updated(changedProperties);
|
6177
|
+
if (changedProperties.has('products') &&
|
6178
|
+
!this.hasPeeked &&
|
6179
|
+
this.productsEle &&
|
6180
|
+
window.matchMedia('(max-width: 768px)').matches &&
|
6181
|
+
this.productsEle.scrollWidth > this.productsEle.clientWidth) {
|
6182
|
+
this.hasPeeked = true;
|
6183
|
+
setTimeout(() => {
|
6184
|
+
this.productsEle.scrollTo({ left: 60, behavior: 'smooth' });
|
6185
|
+
setTimeout(() => {
|
6186
|
+
this.productsEle.scrollTo({ left: 0, behavior: 'smooth' });
|
6187
|
+
}, 600);
|
6188
|
+
}, 500);
|
6189
|
+
}
|
6190
|
+
this.updateButtonsState();
|
6129
6191
|
}
|
6130
6192
|
render() {
|
6131
6193
|
if (!this.products.length) {
|
@@ -6135,7 +6197,7 @@ class ProductsList extends i$1 {
|
|
6135
6197
|
return x `
|
6136
6198
|
<div class="products-wrapper">
|
6137
6199
|
<div class="products" @scroll=${this.updateButtonsState}>
|
6138
|
-
${o
|
6200
|
+
${o(this.products, (product, index) => x `
|
6139
6201
|
<div class=${'product-container'}>
|
6140
6202
|
<product-item
|
6141
6203
|
.query=${this.query}
|
@@ -6153,7 +6215,7 @@ class ProductsList extends i$1 {
|
|
6153
6215
|
${this.showButtons
|
6154
6216
|
? x `<div
|
6155
6217
|
class="scroll-btns"
|
6156
|
-
class=${e
|
6218
|
+
class=${e({
|
6157
6219
|
'scroll-btns': true,
|
6158
6220
|
modal: isPopupView,
|
6159
6221
|
})}
|
@@ -6200,15 +6262,15 @@ __decorate([
|
|
6200
6262
|
__metadata("design:type", Object)
|
6201
6263
|
], ProductsList.prototype, "showButtons", void 0);
|
6202
6264
|
__decorate([
|
6203
|
-
e$
|
6265
|
+
e$2('.left-btn'),
|
6204
6266
|
__metadata("design:type", Object)
|
6205
6267
|
], ProductsList.prototype, "leftBtnEle", void 0);
|
6206
6268
|
__decorate([
|
6207
|
-
e$
|
6269
|
+
e$2('.right-btn'),
|
6208
6270
|
__metadata("design:type", Object)
|
6209
6271
|
], ProductsList.prototype, "rightBtnEle", void 0);
|
6210
6272
|
__decorate([
|
6211
|
-
e$
|
6273
|
+
e$2('.products'),
|
6212
6274
|
__metadata("design:type", HTMLDivElement)
|
6213
6275
|
], ProductsList.prototype, "productsEle", void 0);
|
6214
6276
|
if (!customElements.get('products-list')) {
|
@@ -6305,15 +6367,15 @@ __decorate([
|
|
6305
6367
|
__metadata("design:type", Boolean)
|
6306
6368
|
], ProductsSection.prototype, "isLoadingThreads", void 0);
|
6307
6369
|
__decorate([
|
6308
|
-
e$
|
6370
|
+
e$2('.left-btn'),
|
6309
6371
|
__metadata("design:type", Object)
|
6310
6372
|
], ProductsSection.prototype, "leftBtnEle", void 0);
|
6311
6373
|
__decorate([
|
6312
|
-
e$
|
6374
|
+
e$2('.right-btn'),
|
6313
6375
|
__metadata("design:type", Object)
|
6314
6376
|
], ProductsSection.prototype, "rightBtnEle", void 0);
|
6315
6377
|
__decorate([
|
6316
|
-
e$
|
6378
|
+
e$2('.products'),
|
6317
6379
|
__metadata("design:type", Object)
|
6318
6380
|
], ProductsSection.prototype, "productsEle", void 0);
|
6319
6381
|
__decorate([
|
@@ -7189,15 +7251,15 @@ class PersonalizeDialog extends i$1 {
|
|
7189
7251
|
}
|
7190
7252
|
PersonalizeDialog.styles = [personalizeDialogStyles];
|
7191
7253
|
__decorate([
|
7192
|
-
e$
|
7254
|
+
e$2('dialog'),
|
7193
7255
|
__metadata("design:type", HTMLDialogElement)
|
7194
7256
|
], PersonalizeDialog.prototype, "dialogModal", void 0);
|
7195
7257
|
__decorate([
|
7196
|
-
e$
|
7258
|
+
e$2('.dropdown-list'),
|
7197
7259
|
__metadata("design:type", HTMLUListElement)
|
7198
7260
|
], PersonalizeDialog.prototype, "dropdownList", void 0);
|
7199
7261
|
__decorate([
|
7200
|
-
e$
|
7262
|
+
e$2('.dropdown-trigger'),
|
7201
7263
|
__metadata("design:type", HTMLDivElement)
|
7202
7264
|
], PersonalizeDialog.prototype, "dropdownTrigger", void 0);
|
7203
7265
|
__decorate([
|
@@ -7236,12 +7298,6 @@ if (!customElements.get('personalize-dialog')) {
|
|
7236
7298
|
customElements.define('personalize-dialog', PersonalizeDialog);
|
7237
7299
|
}
|
7238
7300
|
|
7239
|
-
/**
|
7240
|
-
* @license
|
7241
|
-
* Copyright 2017 Google LLC
|
7242
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
7243
|
-
*/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);
|
7244
|
-
|
7245
7301
|
const markdown = (text) => {
|
7246
7302
|
let src = text;
|
7247
7303
|
const rx_space = /\t|\r|\uf8ff/g;
|
@@ -7348,9 +7404,103 @@ class MarkdownRenderer extends i$1 {
|
|
7348
7404
|
constructor() {
|
7349
7405
|
super(...arguments);
|
7350
7406
|
this.content = '';
|
7407
|
+
this.streaming = false;
|
7408
|
+
this.intervalId = null;
|
7409
|
+
this.displayedContent = '';
|
7410
|
+
this.container = null;
|
7411
|
+
this.INTERVAL = 3;
|
7412
|
+
}
|
7413
|
+
updated(changedProps) {
|
7414
|
+
if (changedProps.has('content')) {
|
7415
|
+
if (this.streaming) {
|
7416
|
+
this.handleStreamingUpdate();
|
7417
|
+
}
|
7418
|
+
else {
|
7419
|
+
this.renderDirectly();
|
7420
|
+
}
|
7421
|
+
}
|
7422
|
+
}
|
7423
|
+
getContainer() {
|
7424
|
+
if (!this.container) {
|
7425
|
+
this.container = this.shadowRoot.querySelector('.markdown-content');
|
7426
|
+
}
|
7427
|
+
return this.container;
|
7428
|
+
}
|
7429
|
+
handleStreamingUpdate() {
|
7430
|
+
// Check if new content extends current displayed content (compare raw strings)
|
7431
|
+
if (this.content.startsWith(this.displayedContent)) {
|
7432
|
+
// New content is an extension - continue streaming
|
7433
|
+
const newPortion = this.content.substring(this.displayedContent.length);
|
7434
|
+
this.continueStreaming(newPortion);
|
7435
|
+
}
|
7436
|
+
else {
|
7437
|
+
// Completely new content - restart
|
7438
|
+
this.displayedContent = '';
|
7439
|
+
this.startStreaming(this.content);
|
7440
|
+
}
|
7441
|
+
}
|
7442
|
+
continueStreaming(newPortion) {
|
7443
|
+
if (!newPortion) {
|
7444
|
+
return;
|
7445
|
+
}
|
7446
|
+
this.startStreamingInterval(newPortion);
|
7447
|
+
}
|
7448
|
+
startStreaming(newContent) {
|
7449
|
+
if (this.intervalId) {
|
7450
|
+
clearInterval(this.intervalId);
|
7451
|
+
}
|
7452
|
+
if (!this.displayedContent) {
|
7453
|
+
const container = this.getContainer();
|
7454
|
+
container.innerHTML = '';
|
7455
|
+
}
|
7456
|
+
this.startStreamingInterval(newContent);
|
7457
|
+
}
|
7458
|
+
startStreamingInterval(newPortion) {
|
7459
|
+
const container = this.getContainer();
|
7460
|
+
let currentIndex = 0;
|
7461
|
+
const baseContent = this.displayedContent;
|
7462
|
+
// Streaming is in progress when intervalId is not null
|
7463
|
+
if (this.intervalId) {
|
7464
|
+
clearInterval(this.intervalId);
|
7465
|
+
}
|
7466
|
+
this.intervalId = window.setInterval(() => {
|
7467
|
+
if (currentIndex >= newPortion.length) {
|
7468
|
+
// Update displayedContent with the complete new portion
|
7469
|
+
this.displayedContent = baseContent + newPortion;
|
7470
|
+
clearInterval(this.intervalId);
|
7471
|
+
this.intervalId = null;
|
7472
|
+
if (!this.streaming) {
|
7473
|
+
this.dispatchEvent(new CustomEvent('streaming-complete', {
|
7474
|
+
detail: { content: this.displayedContent },
|
7475
|
+
}));
|
7476
|
+
}
|
7477
|
+
return;
|
7478
|
+
}
|
7479
|
+
// Stream the new portion character by character
|
7480
|
+
const streamedText = newPortion.substring(0, currentIndex + 1);
|
7481
|
+
const currentContent = baseContent + streamedText;
|
7482
|
+
const htmlContent = markdown(currentContent);
|
7483
|
+
container.innerHTML = htmlContent;
|
7484
|
+
// Update displayedContent incrementally during streaming
|
7485
|
+
this.displayedContent = currentContent;
|
7486
|
+
currentIndex++;
|
7487
|
+
}, this.INTERVAL);
|
7488
|
+
}
|
7489
|
+
renderDirectly() {
|
7490
|
+
if (this.intervalId) {
|
7491
|
+
clearInterval(this.intervalId);
|
7492
|
+
}
|
7493
|
+
const container = this.getContainer();
|
7494
|
+
container.innerHTML = markdown(this.content);
|
7495
|
+
this.displayedContent = this.content;
|
7496
|
+
}
|
7497
|
+
// Public method to check if streaming is in progress
|
7498
|
+
isStreaming() {
|
7499
|
+
const isStreaming = this.intervalId !== null;
|
7500
|
+
return isStreaming;
|
7351
7501
|
}
|
7352
7502
|
render() {
|
7353
|
-
return
|
7503
|
+
return x `<div class="markdown-content"></div>`;
|
7354
7504
|
}
|
7355
7505
|
}
|
7356
7506
|
MarkdownRenderer.styles = i$4 `
|
@@ -7363,11 +7513,42 @@ MarkdownRenderer.styles = i$4 `
|
|
7363
7513
|
margin: 0;
|
7364
7514
|
}
|
7365
7515
|
}
|
7516
|
+
|
7517
|
+
.markdown-content {
|
7518
|
+
opacity: 1;
|
7519
|
+
transition: opacity 0.3s ease;
|
7520
|
+
}
|
7521
|
+
|
7522
|
+
.markdown-content p {
|
7523
|
+
margin: 0 0 8px 0;
|
7524
|
+
}
|
7525
|
+
|
7526
|
+
.markdown-content p:last-child {
|
7527
|
+
margin-bottom: 0;
|
7528
|
+
}
|
7529
|
+
|
7530
|
+
.markdown-content ol,
|
7531
|
+
.markdown-content ul {
|
7532
|
+
margin: 8px 0;
|
7533
|
+
padding-left: 20px;
|
7534
|
+
}
|
7535
|
+
|
7536
|
+
.markdown-content li {
|
7537
|
+
margin: 4px 0;
|
7538
|
+
}
|
7539
|
+
|
7540
|
+
.markdown-content li:last-child {
|
7541
|
+
margin-bottom: 0;
|
7542
|
+
}
|
7366
7543
|
`;
|
7367
7544
|
__decorate([
|
7368
7545
|
n$1({ type: String }),
|
7369
7546
|
__metadata("design:type", Object)
|
7370
7547
|
], MarkdownRenderer.prototype, "content", void 0);
|
7548
|
+
__decorate([
|
7549
|
+
n$1({ type: Boolean }),
|
7550
|
+
__metadata("design:type", Object)
|
7551
|
+
], MarkdownRenderer.prototype, "streaming", void 0);
|
7371
7552
|
if (!customElements.get('markdown-renderer')) {
|
7372
7553
|
customElements.define('markdown-renderer', MarkdownRenderer);
|
7373
7554
|
}
|
@@ -7649,6 +7830,7 @@ if (!customElements.get('typing-indicator')) {
|
|
7649
7830
|
class ChatSection extends i$1 {
|
7650
7831
|
constructor() {
|
7651
7832
|
super(...arguments);
|
7833
|
+
this.streamingComplete = false;
|
7652
7834
|
this.userQuery = '';
|
7653
7835
|
this.isStylesheetInjected = false;
|
7654
7836
|
}
|
@@ -7661,11 +7843,24 @@ class ChatSection extends i$1 {
|
|
7661
7843
|
this.isStylesheetInjected = true;
|
7662
7844
|
}
|
7663
7845
|
}
|
7846
|
+
updated(changedProps) {
|
7847
|
+
// Reset streamingComplete when streaming starts
|
7848
|
+
if (changedProps.has('isStreaming') && this.isStreaming) {
|
7849
|
+
this.streamingComplete = false;
|
7850
|
+
}
|
7851
|
+
// Scroll to bottom when new messages are added
|
7852
|
+
if (changedProps.has('messages')) {
|
7853
|
+
this.scrollToBottom();
|
7854
|
+
}
|
7855
|
+
}
|
7664
7856
|
scrollToBottom() {
|
7665
|
-
|
7666
|
-
(
|
7667
|
-
|
7668
|
-
|
7857
|
+
// Use requestAnimationFrame to ensure DOM has updated before scrolling
|
7858
|
+
requestAnimationFrame(() => {
|
7859
|
+
var _a;
|
7860
|
+
(_a = this.chatWindowElement) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
7861
|
+
top: this.chatWindowElement.scrollHeight,
|
7862
|
+
behavior: 'smooth',
|
7863
|
+
});
|
7669
7864
|
});
|
7670
7865
|
}
|
7671
7866
|
async processMessage(e, message, isPrompt = false) {
|
@@ -7741,9 +7936,16 @@ class ChatSection extends i$1 {
|
|
7741
7936
|
${message.message
|
7742
7937
|
? x ` <markdown-renderer
|
7743
7938
|
.content=${message.message}
|
7939
|
+
.streaming=${!!(message.isChunk && this.isStreaming)}
|
7940
|
+
@streaming-complete=${() => {
|
7941
|
+
this.streamingComplete = true;
|
7942
|
+
// Scroll to show the complete message
|
7943
|
+
this.scrollToBottom();
|
7944
|
+
}}
|
7744
7945
|
></markdown-renderer>`
|
7745
7946
|
: E}
|
7746
|
-
${((_a = message.products) === null || _a === void 0 ? void 0 : _a[0])
|
7947
|
+
${((_a = message.products) === null || _a === void 0 ? void 0 : _a[0]) &&
|
7948
|
+
(!message.isChunk || this.streamingComplete)
|
7747
7949
|
? x `
|
7748
7950
|
<span class="line"></span>
|
7749
7951
|
<div class="product-container">
|
@@ -7755,6 +7957,10 @@ class ChatSection extends i$1 {
|
|
7755
7957
|
.rank=${1}
|
7756
7958
|
.userId=${this.userId}
|
7757
7959
|
.metafieldDisplayName=${this.metafieldDisplayName}
|
7960
|
+
@product-rendered=${() => {
|
7961
|
+
// Scroll to show the product
|
7962
|
+
this.scrollToBottom();
|
7963
|
+
}}
|
7758
7964
|
></product-item>
|
7759
7965
|
</div>
|
7760
7966
|
`
|
@@ -7819,11 +8025,13 @@ class ChatSection extends i$1 {
|
|
7819
8025
|
</div>
|
7820
8026
|
</div>`
|
7821
8027
|
: E}
|
7822
|
-
${o
|
8028
|
+
${o(this.messages, (message, index) => {
|
7823
8029
|
if (message.sender === 'bot') {
|
7824
8030
|
return this.botMessage(message, index);
|
7825
8031
|
}
|
7826
|
-
return
|
8032
|
+
return message.message.trim().length > 0
|
8033
|
+
? x ` <div class="message user">${message.message}</div> `
|
8034
|
+
: E;
|
7827
8035
|
})}
|
7828
8036
|
${!this.welcomeFlowTriggered || !this.thread
|
7829
8037
|
? x `
|
@@ -7846,13 +8054,18 @@ class ChatSection extends i$1 {
|
|
7846
8054
|
`;
|
7847
8055
|
}
|
7848
8056
|
renderPrompts() {
|
7849
|
-
var _a;
|
7850
|
-
if (this.isLoadingHistory ||
|
8057
|
+
var _a, _b;
|
8058
|
+
if (this.isLoadingHistory ||
|
8059
|
+
this.isStreaming ||
|
8060
|
+
this.isLoadingThreads ||
|
8061
|
+
(!this.streamingComplete &&
|
8062
|
+
this.messages.length > 0 &&
|
8063
|
+
((_a = this.messages[0]) === null || _a === void 0 ? void 0 : _a.isChunk))) {
|
7851
8064
|
return E;
|
7852
8065
|
}
|
7853
8066
|
const latestMessage = this.messages[0];
|
7854
8067
|
const isWelcomeMessage = this.messages.length === 1 && (latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.sender) === 'bot';
|
7855
|
-
const isLLMPrompt = !!((
|
8068
|
+
const isLLMPrompt = !!((_b = latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.prompts) === null || _b === void 0 ? void 0 : _b.length);
|
7856
8069
|
const prompts = this.messages.length
|
7857
8070
|
? this.messages[0].prompts
|
7858
8071
|
: this.prompts
|
@@ -7864,7 +8077,7 @@ class ChatSection extends i$1 {
|
|
7864
8077
|
}
|
7865
8078
|
return x `
|
7866
8079
|
<div class="prompts btn">
|
7867
|
-
${o
|
8080
|
+
${o(prompts, (prompt) => {
|
7868
8081
|
return x `
|
7869
8082
|
<div
|
7870
8083
|
class="prompt"
|
@@ -7882,7 +8095,7 @@ class ChatSection extends i$1 {
|
|
7882
8095
|
</div>
|
7883
8096
|
`;
|
7884
8097
|
})}
|
7885
|
-
${o
|
8098
|
+
${o(customPrompts, ({ prompt, link }) => {
|
7886
8099
|
return x `
|
7887
8100
|
<a
|
7888
8101
|
class="prompt"
|
@@ -8130,21 +8343,25 @@ __decorate([
|
|
8130
8343
|
__metadata("design:type", Object)
|
8131
8344
|
], ChatSection.prototype, "metafieldDisplayName", void 0);
|
8132
8345
|
__decorate([
|
8133
|
-
e$
|
8346
|
+
e$2('.context-container'),
|
8134
8347
|
__metadata("design:type", Object)
|
8135
8348
|
], ChatSection.prototype, "contextContainerElement", void 0);
|
8136
8349
|
__decorate([
|
8137
|
-
e$
|
8350
|
+
e$2('.chat-window'),
|
8138
8351
|
__metadata("design:type", Object)
|
8139
8352
|
], ChatSection.prototype, "chatWindowElement", void 0);
|
8140
8353
|
__decorate([
|
8141
|
-
e$
|
8354
|
+
e$2('personalize-dialog'),
|
8142
8355
|
__metadata("design:type", Object)
|
8143
8356
|
], ChatSection.prototype, "personalizeDialogElement", void 0);
|
8144
8357
|
__decorate([
|
8145
8358
|
r$1(),
|
8146
8359
|
__metadata("design:type", Object)
|
8147
8360
|
], ChatSection.prototype, "feedbackDetails", void 0);
|
8361
|
+
__decorate([
|
8362
|
+
r$1(),
|
8363
|
+
__metadata("design:type", Object)
|
8364
|
+
], ChatSection.prototype, "streamingComplete", void 0);
|
8148
8365
|
__decorate([
|
8149
8366
|
n$1({ type: String }),
|
8150
8367
|
__metadata("design:type", Object)
|
@@ -8255,6 +8472,12 @@ const chatSectionStyles = i$4 `
|
|
8255
8472
|
gap: 11px;
|
8256
8473
|
}
|
8257
8474
|
|
8475
|
+
@media (max-width: 768px) {
|
8476
|
+
.chatbot-section {
|
8477
|
+
padding-top: 10px !important;
|
8478
|
+
}
|
8479
|
+
}
|
8480
|
+
|
8258
8481
|
.chat-form {
|
8259
8482
|
display: flex;
|
8260
8483
|
align-items: center;
|
@@ -9000,6 +9223,7 @@ class PopupView extends TWLitElement$1 {
|
|
9000
9223
|
super(...arguments);
|
9001
9224
|
this.showChatThreads = false;
|
9002
9225
|
this.deleteAllThreads = false;
|
9226
|
+
this.streamingComplete = false;
|
9003
9227
|
this.userQuery = '';
|
9004
9228
|
this.isStylesheetInjected = false;
|
9005
9229
|
}
|
@@ -9007,6 +9231,16 @@ class PopupView extends TWLitElement$1 {
|
|
9007
9231
|
super.connectedCallback();
|
9008
9232
|
this.injectCustomCSS();
|
9009
9233
|
}
|
9234
|
+
updated(changedProps) {
|
9235
|
+
// Reset streamingComplete when streaming starts
|
9236
|
+
if (changedProps.has('isStreaming') && this.isStreaming) {
|
9237
|
+
this.streamingComplete = false;
|
9238
|
+
}
|
9239
|
+
// Scroll to bottom when new messages are added
|
9240
|
+
if (changedProps.has('messages')) {
|
9241
|
+
this.scrollToBottom();
|
9242
|
+
}
|
9243
|
+
}
|
9010
9244
|
injectCustomCSS() {
|
9011
9245
|
if (!this.isStylesheetInjected && this.css) {
|
9012
9246
|
const sheet = new CSSStyleSheet();
|
@@ -9016,10 +9250,12 @@ class PopupView extends TWLitElement$1 {
|
|
9016
9250
|
}
|
9017
9251
|
}
|
9018
9252
|
scrollToBottom() {
|
9019
|
-
|
9020
|
-
|
9021
|
-
|
9022
|
-
|
9253
|
+
requestAnimationFrame(() => {
|
9254
|
+
var _a;
|
9255
|
+
(_a = this.chatWindowElement) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
9256
|
+
top: this.chatWindowElement.scrollHeight,
|
9257
|
+
behavior: 'smooth',
|
9258
|
+
});
|
9023
9259
|
});
|
9024
9260
|
}
|
9025
9261
|
async processMessage(e, message, isPrompt = false) {
|
@@ -9039,7 +9275,7 @@ class PopupView extends TWLitElement$1 {
|
|
9039
9275
|
async onSubmit(e) {
|
9040
9276
|
e.preventDefault();
|
9041
9277
|
const message = this.userQuery;
|
9042
|
-
if (!message) {
|
9278
|
+
if (!(message === null || message === void 0 ? void 0 : message.trim())) {
|
9043
9279
|
return;
|
9044
9280
|
}
|
9045
9281
|
if (this.chatTextareaElement) {
|
@@ -9119,11 +9355,16 @@ class PopupView extends TWLitElement$1 {
|
|
9119
9355
|
${message.message
|
9120
9356
|
? x ` <markdown-renderer
|
9121
9357
|
.content=${message.message}
|
9358
|
+
.streaming=${!!(message.isChunk && this.isStreaming)}
|
9359
|
+
@streaming-complete=${() => {
|
9360
|
+
this.streamingComplete = true;
|
9361
|
+
this.scrollToBottom();
|
9362
|
+
}}
|
9122
9363
|
></markdown-renderer>`
|
9123
9364
|
: E}
|
9124
9365
|
</div>
|
9125
9366
|
</div>
|
9126
|
-
${message.products
|
9367
|
+
${message.products && (!message.isChunk || this.streamingComplete)
|
9127
9368
|
? x ` <products-list
|
9128
9369
|
.query=${queryMessage === null || queryMessage === void 0 ? void 0 : queryMessage.message}
|
9129
9370
|
.response=${message.message}
|
@@ -9132,6 +9373,9 @@ class PopupView extends TWLitElement$1 {
|
|
9132
9373
|
.viewType=${this.viewType}
|
9133
9374
|
.userId=${this.userId}
|
9134
9375
|
.metafieldDisplayName=${this.metafieldDisplayName}
|
9376
|
+
@products-rendered=${() => {
|
9377
|
+
this.scrollToBottom();
|
9378
|
+
}}
|
9135
9379
|
></products-list>`
|
9136
9380
|
: E}
|
9137
9381
|
${message.messageId && (queryMessage === null || queryMessage === void 0 ? void 0 : queryMessage.messageId)
|
@@ -9221,29 +9465,38 @@ class PopupView extends TWLitElement$1 {
|
|
9221
9465
|
</div>
|
9222
9466
|
</div>`
|
9223
9467
|
: E}
|
9224
|
-
${o
|
9468
|
+
${o(this.messages, (message, index) => {
|
9225
9469
|
if (message.sender === 'bot') {
|
9226
9470
|
return this.botMessage(message, index);
|
9227
9471
|
}
|
9228
|
-
return
|
9229
|
-
|
9230
|
-
|
9231
|
-
|
9232
|
-
|
9233
|
-
|
9234
|
-
|
9472
|
+
return message.message.trim().length > 0
|
9473
|
+
? x `
|
9474
|
+
<div class="message user">
|
9475
|
+
${message.message
|
9476
|
+
.split('\n')
|
9477
|
+
.map((line) => x `<div>
|
9478
|
+
${line.trim() === '' ? x `<br />` : line}
|
9479
|
+
</div>`)}
|
9480
|
+
</div>
|
9481
|
+
`
|
9482
|
+
: E;
|
9235
9483
|
})}
|
9236
9484
|
</div>
|
9237
9485
|
`;
|
9238
9486
|
}
|
9239
9487
|
renderPrompts() {
|
9240
|
-
var _a, _b;
|
9241
|
-
if (this.isLoadingHistory ||
|
9488
|
+
var _a, _b, _c;
|
9489
|
+
if (this.isLoadingHistory ||
|
9490
|
+
this.isStreaming ||
|
9491
|
+
this.isLoadingThreads ||
|
9492
|
+
(!this.streamingComplete &&
|
9493
|
+
this.messages.length > 0 &&
|
9494
|
+
((_a = this.messages[0]) === null || _a === void 0 ? void 0 : _a.isChunk))) {
|
9242
9495
|
return E;
|
9243
9496
|
}
|
9244
9497
|
const latestMessage = this.messages[0];
|
9245
9498
|
const isWelcomeMessage = this.messages.length === 1 && (latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.sender) === 'bot';
|
9246
|
-
const isLLMPrompt = !!((
|
9499
|
+
const isLLMPrompt = !!((_b = latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.prompts) === null || _b === void 0 ? void 0 : _b.length);
|
9247
9500
|
let prompts = this.messages.length
|
9248
9501
|
? this.messages[0].prompts
|
9249
9502
|
: this.prompts
|
@@ -9257,13 +9510,13 @@ class PopupView extends TWLitElement$1 {
|
|
9257
9510
|
prompts = prompts === null || prompts === void 0 ? void 0 : prompts.slice(0, 5);
|
9258
9511
|
return x `
|
9259
9512
|
<div
|
9260
|
-
class=${e
|
9513
|
+
class=${e({
|
9261
9514
|
prompts: true,
|
9262
9515
|
btn: true,
|
9263
|
-
'left-align': ((
|
9516
|
+
'left-align': ((_c = this.messages) === null || _c === void 0 ? void 0 : _c.length) > 0,
|
9264
9517
|
})}
|
9265
9518
|
>
|
9266
|
-
${o
|
9519
|
+
${o(prompts, (prompt) => {
|
9267
9520
|
return x `
|
9268
9521
|
<div
|
9269
9522
|
class="prompt"
|
@@ -9281,7 +9534,7 @@ class PopupView extends TWLitElement$1 {
|
|
9281
9534
|
</div>
|
9282
9535
|
`;
|
9283
9536
|
})}
|
9284
|
-
${o
|
9537
|
+
${o(customPrompts, ({ prompt, link }) => {
|
9285
9538
|
return x `
|
9286
9539
|
<a
|
9287
9540
|
class="prompt"
|
@@ -9330,7 +9583,7 @@ class PopupView extends TWLitElement$1 {
|
|
9330
9583
|
.text=${'Search History'}
|
9331
9584
|
>
|
9332
9585
|
<button
|
9333
|
-
class=${e
|
9586
|
+
class=${e({
|
9334
9587
|
btn: true,
|
9335
9588
|
'btn-icon': true,
|
9336
9589
|
'threads-btn': true,
|
@@ -9387,9 +9640,9 @@ class PopupView extends TWLitElement$1 {
|
|
9387
9640
|
: E}
|
9388
9641
|
</div>
|
9389
9642
|
<div class="thread-titles-wrapper">
|
9390
|
-
${o
|
9643
|
+
${o(this.chatThreads.values(), (thread) => x `
|
9391
9644
|
<div
|
9392
|
-
class=${e
|
9645
|
+
class=${e({
|
9393
9646
|
'thread-title': true,
|
9394
9647
|
disabled: this.isStreaming,
|
9395
9648
|
})}
|
@@ -9607,17 +9860,21 @@ __decorate([
|
|
9607
9860
|
__metadata("design:type", Object)
|
9608
9861
|
], PopupView.prototype, "deleteAllThreads", void 0);
|
9609
9862
|
__decorate([
|
9610
|
-
e$
|
9863
|
+
e$2('.chat-window'),
|
9611
9864
|
__metadata("design:type", Object)
|
9612
9865
|
], PopupView.prototype, "chatWindowElement", void 0);
|
9613
9866
|
__decorate([
|
9614
|
-
e$
|
9867
|
+
e$2('.chat-textarea'),
|
9615
9868
|
__metadata("design:type", Object)
|
9616
9869
|
], PopupView.prototype, "chatTextareaElement", void 0);
|
9617
9870
|
__decorate([
|
9618
9871
|
r$1(),
|
9619
9872
|
__metadata("design:type", Object)
|
9620
9873
|
], PopupView.prototype, "feedbackDetails", void 0);
|
9874
|
+
__decorate([
|
9875
|
+
r$1(),
|
9876
|
+
__metadata("design:type", Object)
|
9877
|
+
], PopupView.prototype, "streamingComplete", void 0);
|
9621
9878
|
__decorate([
|
9622
9879
|
n$1({ type: String }),
|
9623
9880
|
__metadata("design:type", Object)
|
@@ -9670,7 +9927,7 @@ class ChatNudge extends TWLitElement {
|
|
9670
9927
|
},
|
9671
9928
|
];
|
9672
9929
|
return x `
|
9673
|
-
${o
|
9930
|
+
${o(prompts, (prompt) => x `
|
9674
9931
|
<button
|
9675
9932
|
class="cursor-pointer flex items-center justify-center gap-2 px-4 py-2 bg-[#ffffff] border border-[#e4e4e7] rounded-[6px] w-fit hover:bg-[#F4F4F5] disabled:bg-[#FFFFFF] disabled:opacity-50"
|
9676
9933
|
@click=${(e) => this.handlePromptClick(e, prompt.id, prompt.text)}
|
@@ -10170,6 +10427,14 @@ class ShopGPT extends i$1 {
|
|
10170
10427
|
messageId: messageData.queryMessageId,
|
10171
10428
|
});
|
10172
10429
|
}
|
10430
|
+
else if (messageData.queryMessageId) {
|
10431
|
+
// Create a user message for the empty query from loadInitialQuery
|
10432
|
+
messages.push({
|
10433
|
+
sender: 'user',
|
10434
|
+
message: '',
|
10435
|
+
messageId: messageData.queryMessageId,
|
10436
|
+
});
|
10437
|
+
}
|
10173
10438
|
const messagesToBeSliced = Number(!!latestQuery) + Number(!!latestMessage);
|
10174
10439
|
this.messages = [...messages, ...this.messages.slice(messagesToBeSliced)];
|
10175
10440
|
}
|
@@ -10519,7 +10784,7 @@ __decorate([
|
|
10519
10784
|
__metadata("design:type", Number)
|
10520
10785
|
], ShopGPT.prototype, "latestThreadLoad", void 0);
|
10521
10786
|
__decorate([
|
10522
|
-
e$
|
10787
|
+
e$2('#shop-gpt-dialog-overlay'),
|
10523
10788
|
__metadata("design:type", Object)
|
10524
10789
|
], ShopGPT.prototype, "shopGPTDialog", void 0);
|
10525
10790
|
__decorate([
|