@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.
Files changed (4) hide show
  1. package/index.cjs.js +341 -76
  2. package/index.js +341 -76
  3. package/index.mjs +341 -76
  4. package/package.json +1 -1
package/index.mjs CHANGED
@@ -362,6 +362,23 @@ const usStates = new Map([
362
362
  ]);
363
363
  new Set([...isoCountries.keys(), ...usStates.keys()]);
364
364
 
365
+ const createGradualRelease = ({ userId, rolloutPercentage = 10, }) => {
366
+ // Extract first 8 hex characters from UUID (32 bits)
367
+ const sample = userId.replace(/-/g, '').slice(0, 8);
368
+ const intVal = parseInt(sample, 16);
369
+ const maxVal = 0xffffffff; // 2^32 - 1
370
+ const normalized = intVal / maxVal;
371
+ // Explicitly enable all users for 100% rollout
372
+ const isInRollout = rolloutPercentage >= 100 ? true : normalized < rolloutPercentage / 100;
373
+ return {
374
+ name: 'gradual-release',
375
+ groupNames: new Set(['enabled', 'control']),
376
+ groupName: isInRollout ? 'enabled' : 'control',
377
+ isEnabled: isInRollout,
378
+ rolloutPercentage,
379
+ };
380
+ };
381
+
365
382
  const createEnabled = () => ({
366
383
  name: 'enabled',
367
384
  groupNames: new Set(),
@@ -403,6 +420,11 @@ const createExperiment = (props) => {
403
420
  return createDisabled();
404
421
  case 'ab-test':
405
422
  return createABTest(props);
423
+ case 'gradual-release':
424
+ return createGradualRelease({
425
+ userId: props.userId,
426
+ rolloutPercentage: props.rolloutPercentage || 10,
427
+ });
406
428
  case 'preview':
407
429
  return createPreview(props);
408
430
  }
@@ -908,7 +930,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
908
930
  // eslint-disable-next-line @nx/enforce-module-boundaries
909
931
  const error = (message) => console.error(message);
910
932
  const init = (params) => {
911
- var _a, _b, _c;
933
+ var _a, _b, _c, _d;
912
934
  if (typeof window == 'undefined' || typeof document == 'undefined') {
913
935
  // if loaded in non-browser SDKs, return early
914
936
  return;
@@ -931,6 +953,9 @@ const init = (params) => {
931
953
  name: getExperimentName(mode),
932
954
  userId: params.userId,
933
955
  preview: hasPreviewKey(),
956
+ rolloutPercentage: mode === 'gradual-release'
957
+ ? (_d = params.manifest.variables) === null || _d === void 0 ? void 0 : _d.rolloutPercentage
958
+ : undefined,
934
959
  });
935
960
  const shouldShowUI = enabled || experiment.isEnabled;
936
961
  if (experiment.name === 'preview' && shouldShowUI) {
@@ -1085,32 +1110,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1085
1110
  * Copyright 2019 Google LLC
1086
1111
  * SPDX-License-Identifier: BSD-3-Clause
1087
1112
  */
1088
- const t$2=globalThis,e$7=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$6=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$7&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$6.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$6.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$7)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$2.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$7?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$5(e)})(t):t;
1113
+ 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;
1089
1114
 
1090
1115
  /**
1091
1116
  * @license
1092
1117
  * Copyright 2017 Google LLC
1093
1118
  * SPDX-License-Identifier: BSD-3-Clause
1094
- */const{is:i$3,defineProperty:e$6,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$4,getOwnPropertySymbols:o$5,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$6(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$5(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");
1119
+ */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");
1095
1120
 
1096
1121
  /**
1097
1122
  * @license
1098
1123
  * Copyright 2017 Google LLC
1099
1124
  * SPDX-License-Identifier: BSD-3-Clause
1100
1125
  */
1101
- const t$1=globalThis,i$2=t$1.trustedTypes,s$1=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$5="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$4="?"+h,n$2=`<${o$4}>`,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$5+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$5)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$2?i$2.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$4)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};
1126
+ 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};
1102
1127
 
1103
1128
  /**
1104
1129
  * @license
1105
1130
  * Copyright 2017 Google LLC
1106
1131
  * SPDX-License-Identifier: BSD-3-Clause
1107
- */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$3=s.litElementPolyfillSupport;o$3?.({LitElement:i$1});(s.litElementVersions??=[]).push("4.2.0");
1132
+ */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");
1108
1133
 
1109
1134
  /**
1110
1135
  * @license
1111
1136
  * Copyright 2017 Google LLC
1112
1137
  * SPDX-License-Identifier: BSD-3-Clause
1113
- */const o$2={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1},r$2=(t=o$2,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"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)}
1138
+ */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)}
1114
1139
 
1115
1140
  /**
1116
1141
  * @license
@@ -1123,13 +1148,13 @@ const t$1=globalThis,i$2=t$1.trustedTypes,s$1=i$2?i$2.createPolicy("lit-html",{c
1123
1148
  * Copyright 2017 Google LLC
1124
1149
  * SPDX-License-Identifier: BSD-3-Clause
1125
1150
  */
1126
- const e$4=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
1151
+ const e$3=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
1127
1152
 
1128
1153
  /**
1129
1154
  * @license
1130
1155
  * Copyright 2017 Google LLC
1131
1156
  * SPDX-License-Identifier: BSD-3-Clause
1132
- */function e$3(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;if(r){const{get:e,set:r}="object"==typeof s?n:i??(()=>{const t=Symbol();return {get(){return this[t]},set(e){this[t]=e;}}})();return e$4(n,s,{get(){let t=e.call(this);return void 0===t&&(t=o(this),(null!==t||this.hasUpdated)&&r.call(this,t)),t}})}return e$4(n,s,{get(){return o(this)}})}}
1157
+ */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)}})}}
1133
1158
 
1134
1159
  const scrollBarStyles = i$4 `
1135
1160
  ::-webkit-scrollbar {
@@ -1318,20 +1343,20 @@ const shopGPTStyles = i$4 `
1318
1343
  * Copyright 2017 Google LLC
1319
1344
  * SPDX-License-Identifier: BSD-3-Clause
1320
1345
  */
1321
- const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e$2=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
1346
+ 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)}}
1322
1347
 
1323
1348
  /**
1324
1349
  * @license
1325
1350
  * Copyright 2018 Google LLC
1326
1351
  * SPDX-License-Identifier: BSD-3-Clause
1327
- */const e$1=e$2(class extends i{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter((s=>t[s])).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return T}});
1352
+ */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}});
1328
1353
 
1329
1354
  /**
1330
1355
  * @license
1331
1356
  * Copyright 2021 Google LLC
1332
1357
  * SPDX-License-Identifier: BSD-3-Clause
1333
1358
  */
1334
- function*o$1(o,f){if(void 0!==o){let i=0;for(const t of o)yield f(t,i++);}}
1359
+ function*o(o,f){if(void 0!==o){let i=0;for(const t of o)yield f(t,i++);}}
1335
1360
 
1336
1361
  const sendFilledIcon = b `
1337
1362
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
@@ -1728,9 +1753,9 @@ class ChatThreads extends i$1 {
1728
1753
  </div>
1729
1754
  ${this.chatThreads.size
1730
1755
  ? x `<div class="threads">
1731
- ${o$1(this.chatThreads.values(), (thread) => x `
1756
+ ${o(this.chatThreads.values(), (thread) => x `
1732
1757
  <div
1733
- class=${e$1({
1758
+ class=${e({
1734
1759
  'thread-wrapper': true,
1735
1760
  active: this.selectedThreadId === thread.threadId,
1736
1761
  disabled: this.isStreaming,
@@ -2661,7 +2686,7 @@ __decorate([
2661
2686
  __metadata("design:type", Object)
2662
2687
  ], BTCarousel.prototype, "disableButtons", void 0);
2663
2688
  __decorate([
2664
- e$3('.carousel-content'),
2689
+ e$2('.carousel-content'),
2665
2690
  __metadata("design:type", HTMLElement)
2666
2691
  ], BTCarousel.prototype, "scrollContainer", void 0);
2667
2692
  __decorate([
@@ -5919,10 +5944,18 @@ class ProductItem extends TWLitElement$3 {
5919
5944
  }));
5920
5945
  }
5921
5946
  }
5947
+ firstUpdated(changedProperties) {
5948
+ super.firstUpdated(changedProperties);
5949
+ this.dispatchEvent(new CustomEvent('product-rendered', {
5950
+ detail: { product: this.product },
5951
+ composed: true,
5952
+ bubbles: true,
5953
+ }));
5954
+ }
5922
5955
  render() {
5923
5956
  return x `
5924
5957
  <a
5925
- class=${e$1({ product: true, modal: this.viewType === 'modal' })}
5958
+ class=${e({ product: true, modal: this.viewType === 'modal' })}
5926
5959
  href=${this.getProductUrl(this.product.url)}
5927
5960
  @click=${() => this.productClicked(this.product)}
5928
5961
  >
@@ -6075,12 +6108,19 @@ const productsListStyles = i$4 `
6075
6108
  gap: 24px;
6076
6109
  position: relative;
6077
6110
  }
6111
+
6112
+ @media (max-width: 768px) {
6113
+ .scroll-btns {
6114
+ display: none !important;
6115
+ }
6116
+ }
6078
6117
  `;
6079
6118
 
6080
6119
  class ProductsList extends i$1 {
6081
6120
  constructor() {
6082
6121
  super(...arguments);
6083
6122
  this.showButtons = true;
6123
+ this.hasPeeked = false;
6084
6124
  this.updateButtonsState = () => {
6085
6125
  if (!this.productsEle) {
6086
6126
  return;
@@ -6124,6 +6164,28 @@ class ProductsList extends i$1 {
6124
6164
  this.resizeObserver.observe(child);
6125
6165
  });
6126
6166
  this.updateButtonsState();
6167
+ this.dispatchEvent(new CustomEvent('products-rendered', {
6168
+ detail: { products: this.products },
6169
+ composed: true,
6170
+ bubbles: true,
6171
+ }));
6172
+ }
6173
+ updated(changedProperties) {
6174
+ super.updated(changedProperties);
6175
+ if (changedProperties.has('products') &&
6176
+ !this.hasPeeked &&
6177
+ this.productsEle &&
6178
+ window.matchMedia('(max-width: 768px)').matches &&
6179
+ this.productsEle.scrollWidth > this.productsEle.clientWidth) {
6180
+ this.hasPeeked = true;
6181
+ setTimeout(() => {
6182
+ this.productsEle.scrollTo({ left: 60, behavior: 'smooth' });
6183
+ setTimeout(() => {
6184
+ this.productsEle.scrollTo({ left: 0, behavior: 'smooth' });
6185
+ }, 600);
6186
+ }, 500);
6187
+ }
6188
+ this.updateButtonsState();
6127
6189
  }
6128
6190
  render() {
6129
6191
  if (!this.products.length) {
@@ -6133,7 +6195,7 @@ class ProductsList extends i$1 {
6133
6195
  return x `
6134
6196
  <div class="products-wrapper">
6135
6197
  <div class="products" @scroll=${this.updateButtonsState}>
6136
- ${o$1(this.products, (product, index) => x `
6198
+ ${o(this.products, (product, index) => x `
6137
6199
  <div class=${'product-container'}>
6138
6200
  <product-item
6139
6201
  .query=${this.query}
@@ -6151,7 +6213,7 @@ class ProductsList extends i$1 {
6151
6213
  ${this.showButtons
6152
6214
  ? x `<div
6153
6215
  class="scroll-btns"
6154
- class=${e$1({
6216
+ class=${e({
6155
6217
  'scroll-btns': true,
6156
6218
  modal: isPopupView,
6157
6219
  })}
@@ -6198,15 +6260,15 @@ __decorate([
6198
6260
  __metadata("design:type", Object)
6199
6261
  ], ProductsList.prototype, "showButtons", void 0);
6200
6262
  __decorate([
6201
- e$3('.left-btn'),
6263
+ e$2('.left-btn'),
6202
6264
  __metadata("design:type", Object)
6203
6265
  ], ProductsList.prototype, "leftBtnEle", void 0);
6204
6266
  __decorate([
6205
- e$3('.right-btn'),
6267
+ e$2('.right-btn'),
6206
6268
  __metadata("design:type", Object)
6207
6269
  ], ProductsList.prototype, "rightBtnEle", void 0);
6208
6270
  __decorate([
6209
- e$3('.products'),
6271
+ e$2('.products'),
6210
6272
  __metadata("design:type", HTMLDivElement)
6211
6273
  ], ProductsList.prototype, "productsEle", void 0);
6212
6274
  if (!customElements.get('products-list')) {
@@ -6303,15 +6365,15 @@ __decorate([
6303
6365
  __metadata("design:type", Boolean)
6304
6366
  ], ProductsSection.prototype, "isLoadingThreads", void 0);
6305
6367
  __decorate([
6306
- e$3('.left-btn'),
6368
+ e$2('.left-btn'),
6307
6369
  __metadata("design:type", Object)
6308
6370
  ], ProductsSection.prototype, "leftBtnEle", void 0);
6309
6371
  __decorate([
6310
- e$3('.right-btn'),
6372
+ e$2('.right-btn'),
6311
6373
  __metadata("design:type", Object)
6312
6374
  ], ProductsSection.prototype, "rightBtnEle", void 0);
6313
6375
  __decorate([
6314
- e$3('.products'),
6376
+ e$2('.products'),
6315
6377
  __metadata("design:type", Object)
6316
6378
  ], ProductsSection.prototype, "productsEle", void 0);
6317
6379
  __decorate([
@@ -7187,15 +7249,15 @@ class PersonalizeDialog extends i$1 {
7187
7249
  }
7188
7250
  PersonalizeDialog.styles = [personalizeDialogStyles];
7189
7251
  __decorate([
7190
- e$3('dialog'),
7252
+ e$2('dialog'),
7191
7253
  __metadata("design:type", HTMLDialogElement)
7192
7254
  ], PersonalizeDialog.prototype, "dialogModal", void 0);
7193
7255
  __decorate([
7194
- e$3('.dropdown-list'),
7256
+ e$2('.dropdown-list'),
7195
7257
  __metadata("design:type", HTMLUListElement)
7196
7258
  ], PersonalizeDialog.prototype, "dropdownList", void 0);
7197
7259
  __decorate([
7198
- e$3('.dropdown-trigger'),
7260
+ e$2('.dropdown-trigger'),
7199
7261
  __metadata("design:type", HTMLDivElement)
7200
7262
  ], PersonalizeDialog.prototype, "dropdownTrigger", void 0);
7201
7263
  __decorate([
@@ -7234,12 +7296,6 @@ if (!customElements.get('personalize-dialog')) {
7234
7296
  customElements.define('personalize-dialog', PersonalizeDialog);
7235
7297
  }
7236
7298
 
7237
- /**
7238
- * @license
7239
- * Copyright 2017 Google LLC
7240
- * SPDX-License-Identifier: BSD-3-Clause
7241
- */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);
7242
-
7243
7299
  const markdown = (text) => {
7244
7300
  let src = text;
7245
7301
  const rx_space = /\t|\r|\uf8ff/g;
@@ -7346,9 +7402,103 @@ class MarkdownRenderer extends i$1 {
7346
7402
  constructor() {
7347
7403
  super(...arguments);
7348
7404
  this.content = '';
7405
+ this.streaming = false;
7406
+ this.intervalId = null;
7407
+ this.displayedContent = '';
7408
+ this.container = null;
7409
+ this.INTERVAL = 3;
7410
+ }
7411
+ updated(changedProps) {
7412
+ if (changedProps.has('content')) {
7413
+ if (this.streaming) {
7414
+ this.handleStreamingUpdate();
7415
+ }
7416
+ else {
7417
+ this.renderDirectly();
7418
+ }
7419
+ }
7420
+ }
7421
+ getContainer() {
7422
+ if (!this.container) {
7423
+ this.container = this.shadowRoot.querySelector('.markdown-content');
7424
+ }
7425
+ return this.container;
7426
+ }
7427
+ handleStreamingUpdate() {
7428
+ // Check if new content extends current displayed content (compare raw strings)
7429
+ if (this.content.startsWith(this.displayedContent)) {
7430
+ // New content is an extension - continue streaming
7431
+ const newPortion = this.content.substring(this.displayedContent.length);
7432
+ this.continueStreaming(newPortion);
7433
+ }
7434
+ else {
7435
+ // Completely new content - restart
7436
+ this.displayedContent = '';
7437
+ this.startStreaming(this.content);
7438
+ }
7439
+ }
7440
+ continueStreaming(newPortion) {
7441
+ if (!newPortion) {
7442
+ return;
7443
+ }
7444
+ this.startStreamingInterval(newPortion);
7445
+ }
7446
+ startStreaming(newContent) {
7447
+ if (this.intervalId) {
7448
+ clearInterval(this.intervalId);
7449
+ }
7450
+ if (!this.displayedContent) {
7451
+ const container = this.getContainer();
7452
+ container.innerHTML = '';
7453
+ }
7454
+ this.startStreamingInterval(newContent);
7455
+ }
7456
+ startStreamingInterval(newPortion) {
7457
+ const container = this.getContainer();
7458
+ let currentIndex = 0;
7459
+ const baseContent = this.displayedContent;
7460
+ // Streaming is in progress when intervalId is not null
7461
+ if (this.intervalId) {
7462
+ clearInterval(this.intervalId);
7463
+ }
7464
+ this.intervalId = window.setInterval(() => {
7465
+ if (currentIndex >= newPortion.length) {
7466
+ // Update displayedContent with the complete new portion
7467
+ this.displayedContent = baseContent + newPortion;
7468
+ clearInterval(this.intervalId);
7469
+ this.intervalId = null;
7470
+ if (!this.streaming) {
7471
+ this.dispatchEvent(new CustomEvent('streaming-complete', {
7472
+ detail: { content: this.displayedContent },
7473
+ }));
7474
+ }
7475
+ return;
7476
+ }
7477
+ // Stream the new portion character by character
7478
+ const streamedText = newPortion.substring(0, currentIndex + 1);
7479
+ const currentContent = baseContent + streamedText;
7480
+ const htmlContent = markdown(currentContent);
7481
+ container.innerHTML = htmlContent;
7482
+ // Update displayedContent incrementally during streaming
7483
+ this.displayedContent = currentContent;
7484
+ currentIndex++;
7485
+ }, this.INTERVAL);
7486
+ }
7487
+ renderDirectly() {
7488
+ if (this.intervalId) {
7489
+ clearInterval(this.intervalId);
7490
+ }
7491
+ const container = this.getContainer();
7492
+ container.innerHTML = markdown(this.content);
7493
+ this.displayedContent = this.content;
7494
+ }
7495
+ // Public method to check if streaming is in progress
7496
+ isStreaming() {
7497
+ const isStreaming = this.intervalId !== null;
7498
+ return isStreaming;
7349
7499
  }
7350
7500
  render() {
7351
- return o(markdown(this.content));
7501
+ return x `<div class="markdown-content"></div>`;
7352
7502
  }
7353
7503
  }
7354
7504
  MarkdownRenderer.styles = i$4 `
@@ -7361,11 +7511,42 @@ MarkdownRenderer.styles = i$4 `
7361
7511
  margin: 0;
7362
7512
  }
7363
7513
  }
7514
+
7515
+ .markdown-content {
7516
+ opacity: 1;
7517
+ transition: opacity 0.3s ease;
7518
+ }
7519
+
7520
+ .markdown-content p {
7521
+ margin: 0 0 8px 0;
7522
+ }
7523
+
7524
+ .markdown-content p:last-child {
7525
+ margin-bottom: 0;
7526
+ }
7527
+
7528
+ .markdown-content ol,
7529
+ .markdown-content ul {
7530
+ margin: 8px 0;
7531
+ padding-left: 20px;
7532
+ }
7533
+
7534
+ .markdown-content li {
7535
+ margin: 4px 0;
7536
+ }
7537
+
7538
+ .markdown-content li:last-child {
7539
+ margin-bottom: 0;
7540
+ }
7364
7541
  `;
7365
7542
  __decorate([
7366
7543
  n$1({ type: String }),
7367
7544
  __metadata("design:type", Object)
7368
7545
  ], MarkdownRenderer.prototype, "content", void 0);
7546
+ __decorate([
7547
+ n$1({ type: Boolean }),
7548
+ __metadata("design:type", Object)
7549
+ ], MarkdownRenderer.prototype, "streaming", void 0);
7369
7550
  if (!customElements.get('markdown-renderer')) {
7370
7551
  customElements.define('markdown-renderer', MarkdownRenderer);
7371
7552
  }
@@ -7647,6 +7828,7 @@ if (!customElements.get('typing-indicator')) {
7647
7828
  class ChatSection extends i$1 {
7648
7829
  constructor() {
7649
7830
  super(...arguments);
7831
+ this.streamingComplete = false;
7650
7832
  this.userQuery = '';
7651
7833
  this.isStylesheetInjected = false;
7652
7834
  }
@@ -7659,11 +7841,24 @@ class ChatSection extends i$1 {
7659
7841
  this.isStylesheetInjected = true;
7660
7842
  }
7661
7843
  }
7844
+ updated(changedProps) {
7845
+ // Reset streamingComplete when streaming starts
7846
+ if (changedProps.has('isStreaming') && this.isStreaming) {
7847
+ this.streamingComplete = false;
7848
+ }
7849
+ // Scroll to bottom when new messages are added
7850
+ if (changedProps.has('messages')) {
7851
+ this.scrollToBottom();
7852
+ }
7853
+ }
7662
7854
  scrollToBottom() {
7663
- var _a;
7664
- (_a = this.chatWindowElement) === null || _a === void 0 ? void 0 : _a.scrollTo({
7665
- top: this.chatWindowElement.scrollHeight,
7666
- behavior: 'smooth',
7855
+ // Use requestAnimationFrame to ensure DOM has updated before scrolling
7856
+ requestAnimationFrame(() => {
7857
+ var _a;
7858
+ (_a = this.chatWindowElement) === null || _a === void 0 ? void 0 : _a.scrollTo({
7859
+ top: this.chatWindowElement.scrollHeight,
7860
+ behavior: 'smooth',
7861
+ });
7667
7862
  });
7668
7863
  }
7669
7864
  async processMessage(e, message, isPrompt = false) {
@@ -7739,9 +7934,16 @@ class ChatSection extends i$1 {
7739
7934
  ${message.message
7740
7935
  ? x ` <markdown-renderer
7741
7936
  .content=${message.message}
7937
+ .streaming=${!!(message.isChunk && this.isStreaming)}
7938
+ @streaming-complete=${() => {
7939
+ this.streamingComplete = true;
7940
+ // Scroll to show the complete message
7941
+ this.scrollToBottom();
7942
+ }}
7742
7943
  ></markdown-renderer>`
7743
7944
  : E}
7744
- ${((_a = message.products) === null || _a === void 0 ? void 0 : _a[0])
7945
+ ${((_a = message.products) === null || _a === void 0 ? void 0 : _a[0]) &&
7946
+ (!message.isChunk || this.streamingComplete)
7745
7947
  ? x `
7746
7948
  <span class="line"></span>
7747
7949
  <div class="product-container">
@@ -7753,6 +7955,10 @@ class ChatSection extends i$1 {
7753
7955
  .rank=${1}
7754
7956
  .userId=${this.userId}
7755
7957
  .metafieldDisplayName=${this.metafieldDisplayName}
7958
+ @product-rendered=${() => {
7959
+ // Scroll to show the product
7960
+ this.scrollToBottom();
7961
+ }}
7756
7962
  ></product-item>
7757
7963
  </div>
7758
7964
  `
@@ -7817,11 +8023,13 @@ class ChatSection extends i$1 {
7817
8023
  </div>
7818
8024
  </div>`
7819
8025
  : E}
7820
- ${o$1(this.messages, (message, index) => {
8026
+ ${o(this.messages, (message, index) => {
7821
8027
  if (message.sender === 'bot') {
7822
8028
  return this.botMessage(message, index);
7823
8029
  }
7824
- return x ` <div class="message user">${message.message}</div> `;
8030
+ return message.message.trim().length > 0
8031
+ ? x ` <div class="message user">${message.message}</div> `
8032
+ : E;
7825
8033
  })}
7826
8034
  ${!this.welcomeFlowTriggered || !this.thread
7827
8035
  ? x `
@@ -7844,13 +8052,18 @@ class ChatSection extends i$1 {
7844
8052
  `;
7845
8053
  }
7846
8054
  renderPrompts() {
7847
- var _a;
7848
- if (this.isLoadingHistory || this.isStreaming || this.isLoadingThreads) {
8055
+ var _a, _b;
8056
+ if (this.isLoadingHistory ||
8057
+ this.isStreaming ||
8058
+ this.isLoadingThreads ||
8059
+ (!this.streamingComplete &&
8060
+ this.messages.length > 0 &&
8061
+ ((_a = this.messages[0]) === null || _a === void 0 ? void 0 : _a.isChunk))) {
7849
8062
  return E;
7850
8063
  }
7851
8064
  const latestMessage = this.messages[0];
7852
8065
  const isWelcomeMessage = this.messages.length === 1 && (latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.sender) === 'bot';
7853
- const isLLMPrompt = !!((_a = latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.prompts) === null || _a === void 0 ? void 0 : _a.length);
8066
+ const isLLMPrompt = !!((_b = latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.prompts) === null || _b === void 0 ? void 0 : _b.length);
7854
8067
  const prompts = this.messages.length
7855
8068
  ? this.messages[0].prompts
7856
8069
  : this.prompts
@@ -7862,7 +8075,7 @@ class ChatSection extends i$1 {
7862
8075
  }
7863
8076
  return x `
7864
8077
  <div class="prompts btn">
7865
- ${o$1(prompts, (prompt) => {
8078
+ ${o(prompts, (prompt) => {
7866
8079
  return x `
7867
8080
  <div
7868
8081
  class="prompt"
@@ -7880,7 +8093,7 @@ class ChatSection extends i$1 {
7880
8093
  </div>
7881
8094
  `;
7882
8095
  })}
7883
- ${o$1(customPrompts, ({ prompt, link }) => {
8096
+ ${o(customPrompts, ({ prompt, link }) => {
7884
8097
  return x `
7885
8098
  <a
7886
8099
  class="prompt"
@@ -8128,21 +8341,25 @@ __decorate([
8128
8341
  __metadata("design:type", Object)
8129
8342
  ], ChatSection.prototype, "metafieldDisplayName", void 0);
8130
8343
  __decorate([
8131
- e$3('.context-container'),
8344
+ e$2('.context-container'),
8132
8345
  __metadata("design:type", Object)
8133
8346
  ], ChatSection.prototype, "contextContainerElement", void 0);
8134
8347
  __decorate([
8135
- e$3('.chat-window'),
8348
+ e$2('.chat-window'),
8136
8349
  __metadata("design:type", Object)
8137
8350
  ], ChatSection.prototype, "chatWindowElement", void 0);
8138
8351
  __decorate([
8139
- e$3('personalize-dialog'),
8352
+ e$2('personalize-dialog'),
8140
8353
  __metadata("design:type", Object)
8141
8354
  ], ChatSection.prototype, "personalizeDialogElement", void 0);
8142
8355
  __decorate([
8143
8356
  r$1(),
8144
8357
  __metadata("design:type", Object)
8145
8358
  ], ChatSection.prototype, "feedbackDetails", void 0);
8359
+ __decorate([
8360
+ r$1(),
8361
+ __metadata("design:type", Object)
8362
+ ], ChatSection.prototype, "streamingComplete", void 0);
8146
8363
  __decorate([
8147
8364
  n$1({ type: String }),
8148
8365
  __metadata("design:type", Object)
@@ -8253,6 +8470,12 @@ const chatSectionStyles = i$4 `
8253
8470
  gap: 11px;
8254
8471
  }
8255
8472
 
8473
+ @media (max-width: 768px) {
8474
+ .chatbot-section {
8475
+ padding-top: 10px !important;
8476
+ }
8477
+ }
8478
+
8256
8479
  .chat-form {
8257
8480
  display: flex;
8258
8481
  align-items: center;
@@ -8998,6 +9221,7 @@ class PopupView extends TWLitElement$1 {
8998
9221
  super(...arguments);
8999
9222
  this.showChatThreads = false;
9000
9223
  this.deleteAllThreads = false;
9224
+ this.streamingComplete = false;
9001
9225
  this.userQuery = '';
9002
9226
  this.isStylesheetInjected = false;
9003
9227
  }
@@ -9005,6 +9229,16 @@ class PopupView extends TWLitElement$1 {
9005
9229
  super.connectedCallback();
9006
9230
  this.injectCustomCSS();
9007
9231
  }
9232
+ updated(changedProps) {
9233
+ // Reset streamingComplete when streaming starts
9234
+ if (changedProps.has('isStreaming') && this.isStreaming) {
9235
+ this.streamingComplete = false;
9236
+ }
9237
+ // Scroll to bottom when new messages are added
9238
+ if (changedProps.has('messages')) {
9239
+ this.scrollToBottom();
9240
+ }
9241
+ }
9008
9242
  injectCustomCSS() {
9009
9243
  if (!this.isStylesheetInjected && this.css) {
9010
9244
  const sheet = new CSSStyleSheet();
@@ -9014,10 +9248,12 @@ class PopupView extends TWLitElement$1 {
9014
9248
  }
9015
9249
  }
9016
9250
  scrollToBottom() {
9017
- var _a;
9018
- (_a = this.chatWindowElement) === null || _a === void 0 ? void 0 : _a.scrollTo({
9019
- top: this.chatWindowElement.scrollHeight,
9020
- behavior: 'smooth',
9251
+ requestAnimationFrame(() => {
9252
+ var _a;
9253
+ (_a = this.chatWindowElement) === null || _a === void 0 ? void 0 : _a.scrollTo({
9254
+ top: this.chatWindowElement.scrollHeight,
9255
+ behavior: 'smooth',
9256
+ });
9021
9257
  });
9022
9258
  }
9023
9259
  async processMessage(e, message, isPrompt = false) {
@@ -9037,7 +9273,7 @@ class PopupView extends TWLitElement$1 {
9037
9273
  async onSubmit(e) {
9038
9274
  e.preventDefault();
9039
9275
  const message = this.userQuery;
9040
- if (!message) {
9276
+ if (!(message === null || message === void 0 ? void 0 : message.trim())) {
9041
9277
  return;
9042
9278
  }
9043
9279
  if (this.chatTextareaElement) {
@@ -9117,11 +9353,16 @@ class PopupView extends TWLitElement$1 {
9117
9353
  ${message.message
9118
9354
  ? x ` <markdown-renderer
9119
9355
  .content=${message.message}
9356
+ .streaming=${!!(message.isChunk && this.isStreaming)}
9357
+ @streaming-complete=${() => {
9358
+ this.streamingComplete = true;
9359
+ this.scrollToBottom();
9360
+ }}
9120
9361
  ></markdown-renderer>`
9121
9362
  : E}
9122
9363
  </div>
9123
9364
  </div>
9124
- ${message.products
9365
+ ${message.products && (!message.isChunk || this.streamingComplete)
9125
9366
  ? x ` <products-list
9126
9367
  .query=${queryMessage === null || queryMessage === void 0 ? void 0 : queryMessage.message}
9127
9368
  .response=${message.message}
@@ -9130,6 +9371,9 @@ class PopupView extends TWLitElement$1 {
9130
9371
  .viewType=${this.viewType}
9131
9372
  .userId=${this.userId}
9132
9373
  .metafieldDisplayName=${this.metafieldDisplayName}
9374
+ @products-rendered=${() => {
9375
+ this.scrollToBottom();
9376
+ }}
9133
9377
  ></products-list>`
9134
9378
  : E}
9135
9379
  ${message.messageId && (queryMessage === null || queryMessage === void 0 ? void 0 : queryMessage.messageId)
@@ -9219,29 +9463,38 @@ class PopupView extends TWLitElement$1 {
9219
9463
  </div>
9220
9464
  </div>`
9221
9465
  : E}
9222
- ${o$1(this.messages, (message, index) => {
9466
+ ${o(this.messages, (message, index) => {
9223
9467
  if (message.sender === 'bot') {
9224
9468
  return this.botMessage(message, index);
9225
9469
  }
9226
- return x `
9227
- <div class="message user">
9228
- ${message.message
9229
- .split('\n')
9230
- .map((line) => x `<div>${line.trim() === '' ? x `<br />` : line}</div>`)}
9231
- </div>
9232
- `;
9470
+ return message.message.trim().length > 0
9471
+ ? x `
9472
+ <div class="message user">
9473
+ ${message.message
9474
+ .split('\n')
9475
+ .map((line) => x `<div>
9476
+ ${line.trim() === '' ? x `<br />` : line}
9477
+ </div>`)}
9478
+ </div>
9479
+ `
9480
+ : E;
9233
9481
  })}
9234
9482
  </div>
9235
9483
  `;
9236
9484
  }
9237
9485
  renderPrompts() {
9238
- var _a, _b;
9239
- if (this.isLoadingHistory || this.isStreaming || this.isLoadingThreads) {
9486
+ var _a, _b, _c;
9487
+ if (this.isLoadingHistory ||
9488
+ this.isStreaming ||
9489
+ this.isLoadingThreads ||
9490
+ (!this.streamingComplete &&
9491
+ this.messages.length > 0 &&
9492
+ ((_a = this.messages[0]) === null || _a === void 0 ? void 0 : _a.isChunk))) {
9240
9493
  return E;
9241
9494
  }
9242
9495
  const latestMessage = this.messages[0];
9243
9496
  const isWelcomeMessage = this.messages.length === 1 && (latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.sender) === 'bot';
9244
- const isLLMPrompt = !!((_a = latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.prompts) === null || _a === void 0 ? void 0 : _a.length);
9497
+ const isLLMPrompt = !!((_b = latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.prompts) === null || _b === void 0 ? void 0 : _b.length);
9245
9498
  let prompts = this.messages.length
9246
9499
  ? this.messages[0].prompts
9247
9500
  : this.prompts
@@ -9255,13 +9508,13 @@ class PopupView extends TWLitElement$1 {
9255
9508
  prompts = prompts === null || prompts === void 0 ? void 0 : prompts.slice(0, 5);
9256
9509
  return x `
9257
9510
  <div
9258
- class=${e$1({
9511
+ class=${e({
9259
9512
  prompts: true,
9260
9513
  btn: true,
9261
- 'left-align': ((_b = this.messages) === null || _b === void 0 ? void 0 : _b.length) > 0,
9514
+ 'left-align': ((_c = this.messages) === null || _c === void 0 ? void 0 : _c.length) > 0,
9262
9515
  })}
9263
9516
  >
9264
- ${o$1(prompts, (prompt) => {
9517
+ ${o(prompts, (prompt) => {
9265
9518
  return x `
9266
9519
  <div
9267
9520
  class="prompt"
@@ -9279,7 +9532,7 @@ class PopupView extends TWLitElement$1 {
9279
9532
  </div>
9280
9533
  `;
9281
9534
  })}
9282
- ${o$1(customPrompts, ({ prompt, link }) => {
9535
+ ${o(customPrompts, ({ prompt, link }) => {
9283
9536
  return x `
9284
9537
  <a
9285
9538
  class="prompt"
@@ -9328,7 +9581,7 @@ class PopupView extends TWLitElement$1 {
9328
9581
  .text=${'Search History'}
9329
9582
  >
9330
9583
  <button
9331
- class=${e$1({
9584
+ class=${e({
9332
9585
  btn: true,
9333
9586
  'btn-icon': true,
9334
9587
  'threads-btn': true,
@@ -9385,9 +9638,9 @@ class PopupView extends TWLitElement$1 {
9385
9638
  : E}
9386
9639
  </div>
9387
9640
  <div class="thread-titles-wrapper">
9388
- ${o$1(this.chatThreads.values(), (thread) => x `
9641
+ ${o(this.chatThreads.values(), (thread) => x `
9389
9642
  <div
9390
- class=${e$1({
9643
+ class=${e({
9391
9644
  'thread-title': true,
9392
9645
  disabled: this.isStreaming,
9393
9646
  })}
@@ -9605,17 +9858,21 @@ __decorate([
9605
9858
  __metadata("design:type", Object)
9606
9859
  ], PopupView.prototype, "deleteAllThreads", void 0);
9607
9860
  __decorate([
9608
- e$3('.chat-window'),
9861
+ e$2('.chat-window'),
9609
9862
  __metadata("design:type", Object)
9610
9863
  ], PopupView.prototype, "chatWindowElement", void 0);
9611
9864
  __decorate([
9612
- e$3('.chat-textarea'),
9865
+ e$2('.chat-textarea'),
9613
9866
  __metadata("design:type", Object)
9614
9867
  ], PopupView.prototype, "chatTextareaElement", void 0);
9615
9868
  __decorate([
9616
9869
  r$1(),
9617
9870
  __metadata("design:type", Object)
9618
9871
  ], PopupView.prototype, "feedbackDetails", void 0);
9872
+ __decorate([
9873
+ r$1(),
9874
+ __metadata("design:type", Object)
9875
+ ], PopupView.prototype, "streamingComplete", void 0);
9619
9876
  __decorate([
9620
9877
  n$1({ type: String }),
9621
9878
  __metadata("design:type", Object)
@@ -9668,7 +9925,7 @@ class ChatNudge extends TWLitElement {
9668
9925
  },
9669
9926
  ];
9670
9927
  return x `
9671
- ${o$1(prompts, (prompt) => x `
9928
+ ${o(prompts, (prompt) => x `
9672
9929
  <button
9673
9930
  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"
9674
9931
  @click=${(e) => this.handlePromptClick(e, prompt.id, prompt.text)}
@@ -10168,6 +10425,14 @@ class ShopGPT extends i$1 {
10168
10425
  messageId: messageData.queryMessageId,
10169
10426
  });
10170
10427
  }
10428
+ else if (messageData.queryMessageId) {
10429
+ // Create a user message for the empty query from loadInitialQuery
10430
+ messages.push({
10431
+ sender: 'user',
10432
+ message: '',
10433
+ messageId: messageData.queryMessageId,
10434
+ });
10435
+ }
10171
10436
  const messagesToBeSliced = Number(!!latestQuery) + Number(!!latestMessage);
10172
10437
  this.messages = [...messages, ...this.messages.slice(messagesToBeSliced)];
10173
10438
  }
@@ -10517,7 +10782,7 @@ __decorate([
10517
10782
  __metadata("design:type", Number)
10518
10783
  ], ShopGPT.prototype, "latestThreadLoad", void 0);
10519
10784
  __decorate([
10520
- e$3('#shop-gpt-dialog-overlay'),
10785
+ e$2('#shop-gpt-dialog-overlay'),
10521
10786
  __metadata("design:type", Object)
10522
10787
  ], ShopGPT.prototype, "shopGPTDialog", void 0);
10523
10788
  __decorate([