athena-xai-chat 1.0.75 → 1.0.77

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.
@@ -2554,7 +2554,7 @@ class J7 {
2554
2554
  })
2555
2555
  ));
2556
2556
  const v = this._extractTopTags(this._answers), r = this._answers.findIndex((l) => l.love_language);
2557
- r !== -1 ? this._answers[r].love_language = v : this._answers.push(v);
2557
+ r !== -1 ? this._answers[r].love_language = v.love_language : this._answers.push(v);
2558
2558
  const z = C9(
2559
2559
  this._userId,
2560
2560
  JSON.stringify(this._answers),
@@ -6832,7 +6832,10 @@ let NA = class extends k {
6832
6832
  if (t) return p`<athena-xai-select-chat-error></athena-xai-select-chat-error>`;
6833
6833
  const n = e.some((v) => v?.results?.length);
6834
6834
  return p`
6835
- <section class="athena-xai-select-chat__chat-outer-container">
6835
+ <section
6836
+ class="athena-xai-select-chat__chat-outer-container"
6837
+ ${n ? 'style="min-height: 850px;"' : 'style="min-height: 650px;"'}
6838
+ >
6836
6839
  <h1 class="athena-xai-select-chat__initial-heading">
6837
6840
  ${J.selectChatTranslations[this._lang].title}
6838
6841
  </h1>
@@ -6846,10 +6849,12 @@ let NA = class extends k {
6846
6849
  </div>
6847
6850
 
6848
6851
  <section
6849
- class=${n ? "athena-xai-select-chat__chat-inner-container" : "athena-xai-select-chat__chat-inner-container athena-xai-select-chat__max-width"}
6852
+ class=${n ? "athena-xai-select-chat__chat-inner-container-results" : "athena-xai-select-chat__chat-inner-container athena-xai-select-chat__max-width"}
6850
6853
  >
6851
6854
  ${e.map((v, r) => p`
6852
- <div class="athena-xai-select-chat__message-wrapper">
6855
+ <div
6856
+ class=${n ? "athena-xai-select-chat__message-wrapper-results" : "athena-xai-select-chat__message-wrapper"}
6857
+ >
6853
6858
  ${v?.text !== "" ? p`
6854
6859
  <div class="athena-xai-select-chat__bubble-container">
6855
6860
  <div class="athena-xai-select-chat__bubble-image-container">
@@ -6919,7 +6924,6 @@ NA.styles = [dA`
6919
6924
  align-items: flex-end;
6920
6925
  flex: 1;
6921
6926
  background: #FFFFFF;
6922
- min-height: 850px;
6923
6927
  position: relative;
6924
6928
  overflow: auto;
6925
6929
  scrollbar-width: none;
@@ -6941,6 +6945,16 @@ NA.styles = [dA`
6941
6945
  padding: 20px 0;
6942
6946
  margin: 0 auto;
6943
6947
  }
6948
+
6949
+ .athena-xai-select-chat__chat-inner-container-results {
6950
+ display: flex;
6951
+ flex-direction: column;
6952
+ gap: 8px;
6953
+
6954
+ width: 100%;
6955
+ padding: 20px 0;
6956
+ margin: 0 auto;
6957
+ }
6944
6958
 
6945
6959
  .athena-xai-select-chat__max-width {
6946
6960
  max-width: 500px;
@@ -7080,6 +7094,13 @@ NA.styles = [dA`
7080
7094
  justify-content: flex-end;
7081
7095
  }
7082
7096
 
7097
+ .athena-xai-select-chat__message-wrapper-results {
7098
+ display: flex;
7099
+ flex-direction: column;
7100
+ gap: 8px;
7101
+ justify-content: flex-end;
7102
+ }
7103
+
7083
7104
  .athena-xai-select-chat__message-wrapper:last-of-type {
7084
7105
  padding-bottom: 160px !important;
7085
7106
  }
@@ -7134,7 +7155,7 @@ NA.styles = [dA`
7134
7155
 
7135
7156
  @media(max-width: 768px) {
7136
7157
  .athena-xai-select-chat__chat-outer-container {
7137
- min-height: auto;
7158
+ min-height: auto !important;
7138
7159
  }
7139
7160
 
7140
7161
  .athena-xai-select-chat__initial-image {
@@ -737,7 +737,7 @@ Ces cadeaux viennent du cœur:`}}}},$t=A=>`${I.api.baseUrl}${I.api.endpoints[A]}
737
737
  </div>
738
738
  </div>
739
739
  `}};ae.styles=Cf,Pt([Y()],ae.prototype,"message",2),Pt([Y()],ae.prototype,"messageRole",2),ae=Pt([eA("athena-xai-chat-message")],ae);class Vr{constructor(e){this._messages=[],this._isLoading=!1,this._image="",this._previewImage="",this._isGuardrailsOn=I.features.guardrails.defaultState,this.lastAssistantIndex=null,this.userId=et(),this.host=e,e.addController(this)}get messages(){return this._messages}set messages(e){this._messages=e,this.host.requestUpdate()}get isLoading(){return this._isLoading}set isLoading(e){this._isLoading=e,this.host.requestUpdate()}get image(){return this._image}set image(e){this._image=e,this.host.requestUpdate()}get previewImage(){return this._previewImage}set previewImage(e){this._previewImage=e,this.host.requestUpdate()}get isGuardrailsOn(){return this._isGuardrailsOn}set isGuardrailsOn(e){this._isGuardrailsOn=e,this.host.requestUpdate()}hostConnected(){}hostDisconnected(){}hostUpdate(){}addMessage(e,t,n=""){this.messages=[...this._messages,{role:e,content:t,productName:n}],e==="assistant"&&(this.lastAssistantIndex===null||this.lastAssistantIndex<this._messages.length-1)&&(this.lastAssistantIndex=this._messages.length-1)}updateLastMessage(e,t,n){if(!this._messages.length)return;const f=this._messages.length-1,r={...this._messages[f]};t&&(r.role=t),r.content=typeof e=="string"&&n?r.content+e:e,this.messages=[...this._messages.slice(0,f),r]}async handleImageUpload(e){try{const{base64:t,previewUrl:n}=await Ar(e);this.image=t,this.previewImage=n}catch(t){console.error(`Image upload failed: ${t}`)}}clearImage(){this.image="",this.previewImage=""}async sendMessage(e,t){if(window.dispatchEvent(new Event("clear-picture")),!this.isLoading&&!(!e.trim()&&!t)){this.isLoading=!0;try{e&&this.addMessage("user",e),t&&this.addMessage("user_image",this.previewImage),this.addMessage("assistant","loader");const n=en(this.userId,e,t||this.image,this.isGuardrailsOn,"cB4SWF0BK8Ers0lxoGnx"),f=$t("stream"),r=await fetch(f,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){let i=`HTTP error! status: ${r.status}`;try{const o=await r.json();i=o.detail||o.message||i}catch{}throw new Error(i)}if(!r.body)throw new Error("No response body received");const v=r.body.getReader(),a=new TextDecoder("utf-8");let s="";for(;;){const{value:i,done:o}=await v.read();if(o)break;const g=a.decode(i,{stream:!0}).split(`
740
- `).filter(z=>z.startsWith("data:"));for(let z of g){const c=z.replace(/^data:\s*/,""),X=An(c);if(!X)continue;if(X.type==="content")s+=X.payload;else if(X.type==="images"){const P=Object.entries(X.payload).map(([b,x])=>({productUrl:x,productName:b})),l=this._messages.length-1;this._messages[l]={...this._messages[l],role:"image_row",content:P},this.messages=[...this._messages]}else if(X.type==="error")throw new Error(X.payload);const w=this._messages.length-1;this._messages[w]?.role==="assistant"?(this._messages[w]={...this._messages[w],content:s},this.messages=[...this._messages]):this.addMessage("assistant",s)}}this.clearImage()}catch(n){console.error(`Error sending message: ${n}`);const f=n.message||"Failed to send message. Please try again.",r=this._messages.filter(v=>v.content!=="loader");this.messages=[...r,{role:"assistant",content:`❌ Error: ${f}`,productName:""}]}finally{this.isLoading=!1}}}async resetChat(){if(this.isLoading)return;this.isLoading=!0,this.messages=[],this.clearImage(),$f(),this.userId=et(),this.addMessage("system","You are an advanced AI assistant helps customers on a Retail e-commerce website. You help answer questions for customers about products. Start the conversation by asking a couple of questions to clarify what the user is looking for. Use emojis but do not use too many. Structure your output using Markdown but do not use nested indentations.",""),await F(250),this.addMessage("assistant",""),await F(250);const e="Hi, I'm your Gift Concierge - I'm here to help you find the perfect gift for your friends and family. 🙂";for(const t of e.split(" "))await F(40),this.updateLastMessage(t+" ",void 0,!0);this.isLoading=!1}}const Gr=(A,e,t)=>{const n=A[e];return n?typeof n=="function"?n():Promise.resolve(n):new Promise((f,r)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(r.bind(null,new Error("Unknown variable dynamic import: "+e+(e.split("/").length!==t?". Note that variables only represent file names one level deep.":""))))})};class Lr{constructor(e,t){this._messages=[],this._isLoading=!1,this._isError=!1,this._resetLoading=!1,this._stateData={},this._answers=[],this._userId=et(),this._questions=[],this.websiteToken="",this._getRandomTextVariant=n=>n[Math.floor(Math.random()*n.length)],this.host=e,e.addController(this),this.websiteToken=t,this.loadQuestions().then(()=>{this._flow=this._questions.find(n=>n?.id==="general"),this._currentNode=this._flow?.nodes.find(n=>n?.id===this._flow?.start_node)})}get messages(){return this._messages}get isLoading(){return this._isLoading}set isLoading(e){this._isLoading=e,this.host.requestUpdate()}get isError(){return this._isError}set isError(e){this._isError=e,this.host.requestUpdate()}get isResetLoading(){return this._resetLoading}set isResetLoading(e){this._resetLoading=e,this.host.requestUpdate()}async loadQuestions(){const e=document.documentElement.lang||"en";try{const t=await Gr(Object.assign({"../config/questions.de.backup.json":()=>Promise.resolve().then(()=>Zv),"../config/questions.de.json":()=>Promise.resolve().then(()=>qv),"../config/questions.en.backup.json":()=>Promise.resolve().then(()=>Nv),"../config/questions.en.json":()=>Promise.resolve().then(()=>Cn),"../config/questions.fr.backup.json":()=>Promise.resolve().then(()=>Wv),"../config/questions.fr.json":()=>Promise.resolve().then(()=>yv),"../config/questions.it.backup.json":()=>Promise.resolve().then(()=>Qv),"../config/questions.it.json":()=>Promise.resolve().then(()=>Vv)}),`../config/questions.${e}.json`,3);this._questions=t.default}catch{console.warn(`Falling back to English questions because "${e}" not found.`);const n=await Promise.resolve().then(()=>Cn);this._questions=n.default}}_initializeFlow(){this._flow=this._questions.find(e=>e?.id==="general"),this._currentNode=this._flow?.nodes.find(e=>e?.id===this._flow?.start_node)}requestUpdate(){this.host.requestUpdate()}async addMessage(e,t="bot",n,f,r=!0){if(this._messages=[...r?this._messages:[],{text:"",from:t,options:[],results:f}],this.requestUpdate(),e==="end")return;const v=e.split(" ");for(const a of v)this._messages[this._messages.length-1].text+=a+" ",await F(75),this.requestUpdate();n&&n.length>0&&(await F(75),this._messages[this._messages.length-1].options=n,this.requestUpdate())}checkVisible(e){return e?.any?e.any.some(t=>t.eq?this._stateData[t.eq[0]]===t.eq[1]:t.in?t.in[1].includes(this._stateData[t.in[0]]):!1):!0}_extractTopTags(e){const t={};e.forEach(a=>{a.tag?.forEach(s=>{t[s]=(t[s]??0)+1})});const n=Object.entries(t).reduce((a,[s,i])=>(a[i]=a[i]?[...a[i],s]:[s],a),{}),f=Object.keys(n).map(Number).sort((a,s)=>s-a),r=n[f[0]]??[];return{love_language:r.length>0?r[Math.floor(Math.random()*r.length)]:null}}async fetchRecommendedProducts(e=[],t=!1){const n=new AbortController,f=n.signal;try{if(this.isLoading)return;t||(this.isLoading=!0,await F(400),window.dispatchEvent(new CustomEvent("loading-text-variant-trigger",{detail:{loadingTextVariant:this._getRandomTextVariant(this._currentNode.text_variants)},composed:!0,bubbles:!0})));const r=this._extractTopTags(this._answers),v=this._answers.findIndex(c=>c.love_language);v!==-1?this._answers[v].love_language=r:this._answers.push(r);const a=en(this._userId,JSON.stringify(this._answers),"",!1,this.websiteToken,e),s=$t("stream"),i=fetch(s,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:f});t&&(await F(2100),this.isLoading=!0,await F(400),window.dispatchEvent(new CustomEvent("loading-text-variant-trigger",{detail:{loadingTextVariant:this._getRandomTextVariant(this._currentNode.text_variants)},composed:!0,bubbles:!0})));const o=await i;if(!o.ok){let c=`HTTP error! status: ${o.status}`;try{const X=await o.json();c=X.detail||X.message||c}catch{}throw this.isError=!0,new Error(c)}if(!o.body)throw new Error("No response body received");const u=o.body.getReader(),g=new TextDecoder("utf-8");let z="";for(;;){const{value:c,done:X}=await u.read();if(X)break;z+=g.decode(c,{stream:!0});let w=z.lastIndexOf(`
740
+ `).filter(z=>z.startsWith("data:"));for(let z of g){const c=z.replace(/^data:\s*/,""),X=An(c);if(!X)continue;if(X.type==="content")s+=X.payload;else if(X.type==="images"){const P=Object.entries(X.payload).map(([b,x])=>({productUrl:x,productName:b})),l=this._messages.length-1;this._messages[l]={...this._messages[l],role:"image_row",content:P},this.messages=[...this._messages]}else if(X.type==="error")throw new Error(X.payload);const w=this._messages.length-1;this._messages[w]?.role==="assistant"?(this._messages[w]={...this._messages[w],content:s},this.messages=[...this._messages]):this.addMessage("assistant",s)}}this.clearImage()}catch(n){console.error(`Error sending message: ${n}`);const f=n.message||"Failed to send message. Please try again.",r=this._messages.filter(v=>v.content!=="loader");this.messages=[...r,{role:"assistant",content:`❌ Error: ${f}`,productName:""}]}finally{this.isLoading=!1}}}async resetChat(){if(this.isLoading)return;this.isLoading=!0,this.messages=[],this.clearImage(),$f(),this.userId=et(),this.addMessage("system","You are an advanced AI assistant helps customers on a Retail e-commerce website. You help answer questions for customers about products. Start the conversation by asking a couple of questions to clarify what the user is looking for. Use emojis but do not use too many. Structure your output using Markdown but do not use nested indentations.",""),await F(250),this.addMessage("assistant",""),await F(250);const e="Hi, I'm your Gift Concierge - I'm here to help you find the perfect gift for your friends and family. 🙂";for(const t of e.split(" "))await F(40),this.updateLastMessage(t+" ",void 0,!0);this.isLoading=!1}}const Gr=(A,e,t)=>{const n=A[e];return n?typeof n=="function"?n():Promise.resolve(n):new Promise((f,r)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(r.bind(null,new Error("Unknown variable dynamic import: "+e+(e.split("/").length!==t?". Note that variables only represent file names one level deep.":""))))})};class Lr{constructor(e,t){this._messages=[],this._isLoading=!1,this._isError=!1,this._resetLoading=!1,this._stateData={},this._answers=[],this._userId=et(),this._questions=[],this.websiteToken="",this._getRandomTextVariant=n=>n[Math.floor(Math.random()*n.length)],this.host=e,e.addController(this),this.websiteToken=t,this.loadQuestions().then(()=>{this._flow=this._questions.find(n=>n?.id==="general"),this._currentNode=this._flow?.nodes.find(n=>n?.id===this._flow?.start_node)})}get messages(){return this._messages}get isLoading(){return this._isLoading}set isLoading(e){this._isLoading=e,this.host.requestUpdate()}get isError(){return this._isError}set isError(e){this._isError=e,this.host.requestUpdate()}get isResetLoading(){return this._resetLoading}set isResetLoading(e){this._resetLoading=e,this.host.requestUpdate()}async loadQuestions(){const e=document.documentElement.lang||"en";try{const t=await Gr(Object.assign({"../config/questions.de.backup.json":()=>Promise.resolve().then(()=>Zv),"../config/questions.de.json":()=>Promise.resolve().then(()=>qv),"../config/questions.en.backup.json":()=>Promise.resolve().then(()=>Nv),"../config/questions.en.json":()=>Promise.resolve().then(()=>Cn),"../config/questions.fr.backup.json":()=>Promise.resolve().then(()=>Wv),"../config/questions.fr.json":()=>Promise.resolve().then(()=>yv),"../config/questions.it.backup.json":()=>Promise.resolve().then(()=>Qv),"../config/questions.it.json":()=>Promise.resolve().then(()=>Vv)}),`../config/questions.${e}.json`,3);this._questions=t.default}catch{console.warn(`Falling back to English questions because "${e}" not found.`);const n=await Promise.resolve().then(()=>Cn);this._questions=n.default}}_initializeFlow(){this._flow=this._questions.find(e=>e?.id==="general"),this._currentNode=this._flow?.nodes.find(e=>e?.id===this._flow?.start_node)}requestUpdate(){this.host.requestUpdate()}async addMessage(e,t="bot",n,f,r=!0){if(this._messages=[...r?this._messages:[],{text:"",from:t,options:[],results:f}],this.requestUpdate(),e==="end")return;const v=e.split(" ");for(const a of v)this._messages[this._messages.length-1].text+=a+" ",await F(75),this.requestUpdate();n&&n.length>0&&(await F(75),this._messages[this._messages.length-1].options=n,this.requestUpdate())}checkVisible(e){return e?.any?e.any.some(t=>t.eq?this._stateData[t.eq[0]]===t.eq[1]:t.in?t.in[1].includes(this._stateData[t.in[0]]):!1):!0}_extractTopTags(e){const t={};e.forEach(a=>{a.tag?.forEach(s=>{t[s]=(t[s]??0)+1})});const n=Object.entries(t).reduce((a,[s,i])=>(a[i]=a[i]?[...a[i],s]:[s],a),{}),f=Object.keys(n).map(Number).sort((a,s)=>s-a),r=n[f[0]]??[];return{love_language:r.length>0?r[Math.floor(Math.random()*r.length)]:null}}async fetchRecommendedProducts(e=[],t=!1){const n=new AbortController,f=n.signal;try{if(this.isLoading)return;t||(this.isLoading=!0,await F(400),window.dispatchEvent(new CustomEvent("loading-text-variant-trigger",{detail:{loadingTextVariant:this._getRandomTextVariant(this._currentNode.text_variants)},composed:!0,bubbles:!0})));const r=this._extractTopTags(this._answers),v=this._answers.findIndex(c=>c.love_language);v!==-1?this._answers[v].love_language=r.love_language:this._answers.push(r);const a=en(this._userId,JSON.stringify(this._answers),"",!1,this.websiteToken,e),s=$t("stream"),i=fetch(s,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:f});t&&(await F(2100),this.isLoading=!0,await F(400),window.dispatchEvent(new CustomEvent("loading-text-variant-trigger",{detail:{loadingTextVariant:this._getRandomTextVariant(this._currentNode.text_variants)},composed:!0,bubbles:!0})));const o=await i;if(!o.ok){let c=`HTTP error! status: ${o.status}`;try{const X=await o.json();c=X.detail||X.message||c}catch{}throw this.isError=!0,new Error(c)}if(!o.body)throw new Error("No response body received");const u=o.body.getReader(),g=new TextDecoder("utf-8");let z="";for(;;){const{value:c,done:X}=await u.read();if(X)break;z+=g.decode(c,{stream:!0});let w=z.lastIndexOf(`
741
741
  `);if(w===-1)continue;const P=z.slice(0,w);z=z.slice(w+1);const l=P.split(`
742
742
  `).filter(b=>b.startsWith("data:"));for(const b of l){const x=b.replace(/^data:\s*/,"").trim();if(!x)continue;const H=An(x);H&&H.type!=="content"&&H.type==="images"&&(await this.addMessage("end","bot",[],H.results??[],!1),n.abort(),setTimeout(()=>{window.dispatchEvent(new CustomEvent("relaxed-call",{detail:{isRelaxed:H.relaxed},composed:!0,bubbles:!0})),window.dispatchEvent(new CustomEvent("love-language",{detail:{loveLanguage:r?.love_language},composed:!0,bubbles:!0}))},200))}}}catch(r){r.name!=="AbortError"&&(console.error(`Error sending message: ${r}`),this.isError=!0)}finally{this.isLoading=!1}}async handleAnswer(e,t){const n=this._messages[e],f=n.options?.[t];if(!f)return;n.options=n.options?.map((g,z)=>({...g,selected:z===t})),this.requestUpdate();const r=this._currentNode,v={question:r._shownText,answer:f.label};f?.tag&&(v.tag=[f?.tag]),this._answers.push(v),Object.entries(f.set||{}).forEach(([g,z])=>this._stateData[g]=z);const a=f.next||r.default_next;this._currentNode=this._flow?.nodes.find(g=>g?.id===a);const s=f.follow_ups?this._getRandomTextVariant(f.follow_ups):"";if(await F(400),!this._currentNode)return;if(this._currentNode.type==="end"){const g=this._currentNode.text_variants?this._getRandomTextVariant(this._currentNode.text_variants):"";g&&await this.addMessage(g,"bot"),await this.addMessage("end","bot"),await this.fetchRecommendedProducts([],!0);return}const i=this._getRandomTextVariant(this._currentNode.text_variants);this._messages=[...this._messages,{text:"",from:"bot",options:[]}],this.requestUpdate();const o=this._messages.length-1;if(s){const g=s.split(" ");for(const z of g)this._messages[o].text+=z+" ",await F(75),this.requestUpdate();await F(800),this._messages[o].text+="<br /><br />",this.requestUpdate()}const u=i.split(" ");for(const g of u)this._messages[o].text+=g+" ",await F(75),this.requestUpdate();this._messages[o].options=(this._currentNode.options||[]).filter(g=>!g.visible_when||this.checkVisible(g.visible_when)),this._currentNode._shownText=i}async reset(){this._messages=[],this._stateData={},this._answers=[],this.isError=!1,sessionStorage.removeItem("athena_seen_results"),this._initializeFlow(),this.requestUpdate(),await this.startConversation()}async showQuestion(e){const t=(e.options||[]).filter(f=>!f.visible_when||this.checkVisible(f.visible_when)),n=this._getRandomTextVariant(e.text_variants);await this.addMessage(n,"bot",t),e._shownText=n}async startConversation(){this.isResetLoading=!0,this.isError=!1,await F(600),await this.showQuestion(this._currentNode),this.isResetLoading=!1}hostConnected(){}}var Yr=Object.defineProperty,Er=Object.getOwnPropertyDescriptor,lt=(A,e,t,n)=>{for(var f=n>1?void 0:n?Er(e,t):e,r=A.length-1,v;r>=0;r--)(v=A[r])&&(f=(n?v(e,t,f):v(f))||f);return n&&f&&Yr(e,t,f),f};let ie=class extends h{constructor(){super(...arguments),this._chatController=new Vr(this),this._inputValue="",this._imageValue=""}_submitEventHandler(){this.addEventListener("input-value-submit",async A=>{this._updateScrollPosition();const e=A.detail?.imageValue;if(this._inputValue=bn.sanitize(A.detail?.value)??"",e){const{imageData:t,imageFile:n}=A.detail?.imageValue;this._imageValue=t??"",await this._chatController.handleImageUpload(n??"")}if(this._imageValue){await this._chatController.sendMessage(this._inputValue,this._imageValue);return}await this._chatController.sendMessage(this._inputValue)})}_resetChatEventHandler(){this.addEventListener("reset-chat",async()=>{await this._chatController.resetChat()})}_updateScrollPosition(){const A=this.renderRoot.querySelector(".athena-xai-chat__message-container");A&&(A.scrollTo({top:A.scrollHeight,behavior:"smooth"}),this.requestUpdate())}async connectedCallback(){super.connectedCallback(),await er(),await this._chatController.resetChat(),this._submitEventHandler(),this._resetChatEventHandler()}willUpdate(){this._updateScrollPosition()}render(){return Z`
743
743
  <div class="athena-xai-chat__container">
@@ -1713,7 +1713,10 @@ Ces cadeaux viennent du cœur:`}}}},$t=A=>`${I.api.baseUrl}${I.api.endpoints[A]}
1713
1713
  }
1714
1714
  }
1715
1715
  `],lA([Y()],zA.prototype,"_selectedResult",2),lA([Y()],zA.prototype,"_isMobile",2),lA([Y()],zA.prototype,"_isSwiperInitialized",2),lA([OA({type:Array})],zA.prototype,"results",2),lA([Y()],zA.prototype,"_activeTextMessage",2),lA([Y()],zA.prototype,"_seenResults",2),lA([Y()],zA.prototype,"_isRelaxed",2),lA([Y()],zA.prototype,"_loveLanguage",2),lA([Y()],zA.prototype,"_lang",2),zA=lA([eA("athena-xai-select-chat-results")],zA);var Dv=Object.defineProperty,Mv=Object.getOwnPropertyDescriptor,Pe=(A,e,t,n)=>{for(var f=n>1?void 0:n?Mv(e,t):e,r=A.length-1,v;r>=0;r--)(v=A[r])&&(f=(n?v(e,t,f):v(f))||f);return n&&f&&Dv(e,t,f),f};let WA=class extends h{constructor(){super(...arguments),this._isVisible=!0,this._shouldShowFirstPage=!0,this._lang="en",this.websiteToken=""}_scrollDownObserver(){const A=this.renderRoot.querySelector(".athena-xai-select-chat__chat-outer-container");if(!A||A._observerAttached)return;A._observerAttached=!0,new MutationObserver(()=>{A.scrollTo({top:A.scrollHeight,behavior:"smooth"})}).observe(A,{childList:!0,subtree:!0})}_resetChat(){this.addEventListener("select-chat-reset",async()=>{this._isVisible=!0,await this.selectChatController?.reset(),window.innerWidth<=768&&this._isVisible&&window.scrollTo({top:60,behavior:"smooth"})})}_makeNewRecommendation(){this.addEventListener("make-new-recommendation",async A=>{await this.selectChatController?.fetchRecommendedProducts(A?.detail?.seen_results)})}async connectedCallback(){super.connectedCallback(),this._lang=document.documentElement.lang||"en",window.innerWidth<=768&&this._isVisible&&window.scrollTo({top:60,behavior:"smooth"}),await tr(),this.selectChatController=new Lr(this,this.websiteToken),this.addEventListener("initialize-select-chat",async()=>{this._shouldShowFirstPage=!1,await this.selectChatController?.startConversation()}),this._resetChat(),this._makeNewRecommendation()}updated(){this._scrollDownObserver()}render(){if(this._shouldShowFirstPage)return Z`<athena-xai-select-chat-initial></athena-xai-select-chat-initial>`;if(!this.selectChatController)return;const{messages:A,isLoading:e,isResetLoading:t,isError:n}=this.selectChatController;if(e)return Z`<athena-xai-select-chat-loader></athena-xai-select-chat-loader>`;if(n)return Z`<athena-xai-select-chat-error></athena-xai-select-chat-error>`;const f=A.some(r=>r?.results?.length);return Z`
1716
- <section class="athena-xai-select-chat__chat-outer-container">
1716
+ <section
1717
+ class="athena-xai-select-chat__chat-outer-container"
1718
+ ${f?'style="min-height: 850px;"':'style="min-height: 650px;"'}
1719
+ >
1717
1720
  <h1 class="athena-xai-select-chat__initial-heading">
1718
1721
  ${I.selectChatTranslations[this._lang].title}
1719
1722
  </h1>
@@ -1727,10 +1730,12 @@ Ces cadeaux viennent du cœur:`}}}},$t=A=>`${I.api.baseUrl}${I.api.endpoints[A]}
1727
1730
  </div>
1728
1731
 
1729
1732
  <section
1730
- class=${f?"athena-xai-select-chat__chat-inner-container":"athena-xai-select-chat__chat-inner-container athena-xai-select-chat__max-width"}
1733
+ class=${f?"athena-xai-select-chat__chat-inner-container-results":"athena-xai-select-chat__chat-inner-container athena-xai-select-chat__max-width"}
1731
1734
  >
1732
1735
  ${A.map((r,v)=>Z`
1733
- <div class="athena-xai-select-chat__message-wrapper">
1736
+ <div
1737
+ class=${f?"athena-xai-select-chat__message-wrapper-results":"athena-xai-select-chat__message-wrapper"}
1738
+ >
1734
1739
  ${r?.text!==""?Z`
1735
1740
  <div class="athena-xai-select-chat__bubble-container">
1736
1741
  <div class="athena-xai-select-chat__bubble-image-container">
@@ -1795,7 +1800,6 @@ Ces cadeaux viennent du cœur:`}}}},$t=A=>`${I.api.baseUrl}${I.api.endpoints[A]}
1795
1800
  align-items: flex-end;
1796
1801
  flex: 1;
1797
1802
  background: #FFFFFF;
1798
- min-height: 850px;
1799
1803
  position: relative;
1800
1804
  overflow: auto;
1801
1805
  scrollbar-width: none;
@@ -1817,6 +1821,16 @@ Ces cadeaux viennent du cœur:`}}}},$t=A=>`${I.api.baseUrl}${I.api.endpoints[A]}
1817
1821
  padding: 20px 0;
1818
1822
  margin: 0 auto;
1819
1823
  }
1824
+
1825
+ .athena-xai-select-chat__chat-inner-container-results {
1826
+ display: flex;
1827
+ flex-direction: column;
1828
+ gap: 8px;
1829
+
1830
+ width: 100%;
1831
+ padding: 20px 0;
1832
+ margin: 0 auto;
1833
+ }
1820
1834
 
1821
1835
  .athena-xai-select-chat__max-width {
1822
1836
  max-width: 500px;
@@ -1956,6 +1970,13 @@ Ces cadeaux viennent du cœur:`}}}},$t=A=>`${I.api.baseUrl}${I.api.endpoints[A]}
1956
1970
  justify-content: flex-end;
1957
1971
  }
1958
1972
 
1973
+ .athena-xai-select-chat__message-wrapper-results {
1974
+ display: flex;
1975
+ flex-direction: column;
1976
+ gap: 8px;
1977
+ justify-content: flex-end;
1978
+ }
1979
+
1959
1980
  .athena-xai-select-chat__message-wrapper:last-of-type {
1960
1981
  padding-bottom: 160px !important;
1961
1982
  }
@@ -2010,7 +2031,7 @@ Ces cadeaux viennent du cœur:`}}}},$t=A=>`${I.api.baseUrl}${I.api.endpoints[A]}
2010
2031
 
2011
2032
  @media(max-width: 768px) {
2012
2033
  .athena-xai-select-chat__chat-outer-container {
2013
- min-height: auto;
2034
+ min-height: auto !important;
2014
2035
  }
2015
2036
 
2016
2037
  .athena-xai-select-chat__initial-image {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "files": [
5
5
  "dist"
6
6
  ],
7
- "version": "1.0.75",
7
+ "version": "1.0.77",
8
8
  "type": "module",
9
9
  "scripts": {
10
10
  "dev": "vite",