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