@molin.ai/shop-ai 0.4.47 → 0.4.48

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.
@@ -990,14 +990,14 @@ CHAT`}</span>
990
990
  <span>Molin AI</span>
991
991
  </a>
992
992
  </p>
993
- `)}};var Na,mo,cp=class{constructor(e){Le(this,Na,[]);Le(this,mo,new AbortController);e.addController(this),this.hostConnected()}deferCleanup(e){fe(this,Na).push(e)}get signal(){return fe(this,mo).signal}hostConnected(){ci(this,Na,fe(this,Na)||[]),ci(this,mo,fe(this,mo)||new AbortController)}hostDisconnected(){for(;fe(this,Na).length>0;)fe(this,Na).pop()?.();ci(this,Na,[]),fe(this,mo).abort(),ci(this,mo,new AbortController)}};Na=new WeakMap,mo=new WeakMap;var fp,_f=class{constructor(e,i,r){Le(this,fp,void 0);le(this,"delay");le(this,"callback");this.delay=i,this.callback=r,e.addController(this)}hostConnected(){ci(this,fp,setTimeout(()=>this.callback(),this.delay))}hostDisconnected(){clearTimeout(fe(this,fp))}};fp=new WeakMap;var xf,Ga,dp,mp,Sf,Nv,wf,Gv,Pf,$v,kf,jv,Cf,qv,up=class extends br(zi){constructor(){super();Le(this,Sf);Le(this,wf);Le(this,Pf);Le(this,kf);Le(this,Cf);Le(this,xf,void 0);Le(this,Ga,!1);Le(this,dp,!1);Le(this,mp,new cp(this));le(this,"_handleInteraction",()=>{fe(this,dp)||(ci(this,dp,!0),window.removeEventListener("click",this._handleInteraction),window.removeEventListener("keydown",this._handleInteraction),ri(this,Cf,qv).call(this))});this.position={},this.aiName="Molin AI",this.aiColor="#601feb",this.dialogShown=!1,this.popupDelayMs=5e3,this.popupText="Hello there. How can we help?",this.designMode=!1,this.mobileMode=!1}renderPopup(i,r){return di`
993
+ `)}};var Na,mo,cp=class{constructor(e){Le(this,Na,[]);Le(this,mo,new AbortController);e.addController(this),this.hostConnected()}deferCleanup(e){fe(this,Na).push(e)}get signal(){return fe(this,mo).signal}hostConnected(){ci(this,Na,fe(this,Na)||[]),ci(this,mo,fe(this,mo)||new AbortController)}hostDisconnected(){for(;fe(this,Na).length>0;)fe(this,Na).pop()?.();ci(this,Na,[]),fe(this,mo).abort(),ci(this,mo,new AbortController)}};Na=new WeakMap,mo=new WeakMap;var fp,_f=class{constructor(e,i,r){Le(this,fp,void 0);le(this,"delay");le(this,"callback");this.delay=i,this.callback=r,e.addController(this)}hostConnected(){ci(this,fp,setTimeout(()=>this.callback(),this.delay))}hostDisconnected(){clearTimeout(fe(this,fp))}};fp=new WeakMap;var xf,Ga,dp,mp,Sf,Nv,wf,Gv,Pf,$v,kf,jv,Cf,qv,up=class extends br(zi){constructor(){super();Le(this,Sf);Le(this,wf);Le(this,Pf);Le(this,kf);Le(this,Cf);Le(this,xf,void 0);Le(this,Ga,!1);Le(this,dp,!1);Le(this,mp,new cp(this));le(this,"_handleInteraction",()=>{fe(this,dp)||(ci(this,dp,!0),window.removeEventListener("click",this._handleInteraction),window.removeEventListener("keydown",this._handleInteraction),ri(this,Cf,qv).call(this))});this.position={},this.aiName="Molin AI",this.aiColor="#601feb",this.dialogShown=!1,this.popupDelayMs=5e3,this.popupText="Hello there. How can we help?",this.designMode=!1,this.mobileMode=!1,this.desktopEnabled=!1,this.mobileEnabled=!1}renderPopup(i,r){let s=`${this.designMode?"visible":`${this.mobileEnabled?"visible":"invisible"} ${this.desktopEnabled?"sm:visible":"sm:invisible"}`}`;return di`
994
994
  <!-- shadow backdrop -->
995
- <div class="${i?"visible opacity-100":"invisible opacity-0"} ${r?"fixed":""} inset-0 z-[2147483647] bg-black bg-opacity-50 transition-[opacity,visibility] sm:hidden"></div>
995
+ <div class="${i?`${s} opacity-100`:"invisible opacity-0"} ${r?"fixed":""} inset-0 z-[2147483647] bg-black bg-opacity-50 transition-[opacity,visibility] sm:hidden"></div>
996
996
 
997
997
  <!-- based on desktop or mobile mode apply the styling and override default classes -->
998
998
 
999
999
  <!-- popup itself -->
1000
- <div class="${i?"visible opacity-100 translate-y-0":"invisible opacity-0 translate-y-3"} ${Object.keys(this.position).join(" ")} ${r?"fixed":""} ${this.mobileMode?"":"sm:left-auto sm:top-auto sm:h-auto sm:w-[300px] sm:rounded-2xl"} group bottom-0 left-0 right-0 z-[2147483647] overflow-visible rounded-t-2xl bg-white p-4 text-left font-sans text-[16px] leading-normal text-gray-800 shadow-2xl transition-all" @click="${ri(this,Pf,$v)}">
1000
+ <div class="${i?`${s} opacity-100 translate-y-0`:"invisible opacity-0 translate-y-3"} ${Object.keys(this.position).join(" ")} ${r?"fixed":""} ${this.mobileMode?"":"sm:left-auto sm:top-auto sm:h-auto sm:w-[300px] sm:rounded-2xl"} group bottom-0 left-0 right-0 z-[2147483647] overflow-visible rounded-t-2xl bg-white p-4 text-left font-sans text-[16px] leading-normal text-gray-800 shadow-2xl transition-all" @click="${ri(this,Pf,$v)}">
1001
1001
  <!-- close button -->
1002
1002
  <button class="${this.mobileMode?"":"sm:-top-2 sm:opacity-0 sm:shadow sm:transition-opacity sm:group-hover:opacity-100"} absolute right-2 inline-flex h-6 w-6 items-center justify-center rounded-full bg-gray-300 bg-opacity-50 text-center font-sans shadow-none duration-300 ease-in-out hover:scale-105 hover:text-gray-700 focus:outline-none" @click="${ri(this,wf,Gv)}" aria-label="Close dialog">×</button>
1003
1003
 
@@ -1012,7 +1012,7 @@ CHAT`}</span>
1012
1012
  <mw-powered-by class="sm:hidden"></mw-powered-by>
1013
1013
  </slot>
1014
1014
  </div>
1015
- `}render(){switch(this.designMode){case!0:return this.renderPopup(this.designMode,!1);default:return this.renderPopup(fe(this,Ga),!0)}}updated(i){let r=i.has("dialogShown"),s=this.dialogShown;r&&s===!0&&fe(this,Ga)&&(ci(this,Ga,!1),this.requestUpdate())}firstUpdated(){this.designMode||ri(this,kf,jv).call(this)}};xf=new WeakMap,Ga=new WeakMap,dp=new WeakMap,mp=new WeakMap,Sf=new WeakSet,Nv=function(){new Audio("https://molin.ai/sounds/widget/popup.aac").play().then(()=>{}).catch(r=>{console.error("Error playing audio:",r)}),ci(this,Ga,!0),this.requestUpdate()},wf=new WeakSet,Gv=function(i){i.preventDefault(),i.stopPropagation(),ci(this,Ga,!1),sessionStorage.setItem("_molin_popup","user_dismissed"),this.requestUpdate()},Pf=new WeakSet,$v=function(){ci(this,Ga,!1),this.dispatchEvent(new CustomEvent("popup-chat-open",{})),this.requestUpdate()},kf=new WeakSet,jv=function(){window.addEventListener("click",this._handleInteraction,{signal:fe(this,mp).signal}),window.addEventListener("keydown",this._handleInteraction,{signal:fe(this,mp).signal})},Cf=new WeakSet,qv=function(){ci(this,xf,new _f(this,this.popupDelayMs,()=>{let i=!this.dialogShown,r=sessionStorage.getItem("_molin_popup")!=="user_dismissed";i&&r&&ri(this,Sf,Nv).call(this)}))},le(up,"properties",{position:{type:Object},aiName:{type:String,attribute:"ai-name"},aiColor:{type:String,attribute:"ai-color"},dialogShown:{type:Boolean,attribute:"dialog-shown"},popupDelayMs:{type:Number,attribute:"popup-delay-ms"},popupText:{type:String,attribute:"popup-text"},designMode:{type:Boolean,attribute:"design-mode"},mobileMode:{type:Boolean,attribute:"mobile-mode"}});var Af,Hv,gp=class extends br(zi){constructor(){super();Le(this,Af);this.color="sky-500",this.animated=!1,this.position="top-right"}render(){return di`
1015
+ `}render(){switch(this.designMode){case!0:return this.renderPopup(this.designMode,!1);default:return this.renderPopup(fe(this,Ga),!0)}}updated(i){let r=i.has("dialogShown"),s=this.dialogShown;r&&s===!0&&fe(this,Ga)&&(ci(this,Ga,!1),this.requestUpdate())}firstUpdated(){this.designMode||ri(this,kf,jv).call(this)}};xf=new WeakMap,Ga=new WeakMap,dp=new WeakMap,mp=new WeakMap,Sf=new WeakSet,Nv=function(){new Audio("https://molin.ai/sounds/widget/popup.aac").play().then(()=>{}).catch(r=>{console.error("Error playing audio:",r)}),ci(this,Ga,!0),this.requestUpdate()},wf=new WeakSet,Gv=function(i){i.preventDefault(),i.stopPropagation(),ci(this,Ga,!1),sessionStorage.setItem("_molin_popup","user_dismissed"),this.requestUpdate()},Pf=new WeakSet,$v=function(){ci(this,Ga,!1),this.dispatchEvent(new CustomEvent("popup-chat-open",{})),this.requestUpdate()},kf=new WeakSet,jv=function(){window.addEventListener("click",this._handleInteraction,{signal:fe(this,mp).signal}),window.addEventListener("keydown",this._handleInteraction,{signal:fe(this,mp).signal})},Cf=new WeakSet,qv=function(){ci(this,xf,new _f(this,this.popupDelayMs,()=>{let i=!this.dialogShown,r=sessionStorage.getItem("_molin_popup")!=="user_dismissed";i&&r&&ri(this,Sf,Nv).call(this)}))},le(up,"properties",{position:{type:Object},aiName:{type:String,attribute:"ai-name"},aiColor:{type:String,attribute:"ai-color"},dialogShown:{type:Boolean,attribute:"dialog-shown"},popupDelayMs:{type:Number,attribute:"popup-delay-ms"},popupText:{type:String,attribute:"popup-text"},desktopEnabled:{type:Boolean,attribute:"desktop-enabled"},mobileEnabled:{type:Boolean,attribute:"mobile-enabled"},designMode:{type:Boolean,attribute:"design-mode"},mobileMode:{type:Boolean,attribute:"mobile-mode"}});var Af,Hv,gp=class extends br(zi){constructor(){super();Le(this,Af);this.color="sky-500",this.animated=!1,this.position="top-right"}render(){return di`
1016
1016
  <span class="relative inline-flex">
1017
1017
  <slot></slot>
1018
1018
  <span class="${fe(this,Af,Hv)} pointer-events-none absolute flex h-3 w-3">
@@ -1038,7 +1038,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1038
1038
 
1039
1039
  ${this.config?.popup?.mobileEnabled||this.config?.popup?.desktopEnabled?di`
1040
1040
  <!-- -->
1041
- <mw-popup class="${this.config?.popup?.mobileEnabled?"visible":"invisible"} ${this.config?.popup?.desktopEnabled?"sm:visible":"sm:invisible"}" .position="${a}" ai-name="${this.config.title}" ai-color="${this.config.color}" ?dialog-shown="${fe(this,yr)}" popup-delay-ms="${Ef(this.config.popup?.delayMs)}" popup-text="${Ef(this.config.popup?.text)}" @popup-chat-open="${ri(this,hu,l_)}"></mw-popup>
1041
+ <mw-popup ?mobile-enabled=${this.config?.popup?.mobileEnabled} ?desktop-enabled=${this.config?.popup?.desktopEnabled} .position="${a}" ai-name="${this.config.title}" ai-color="${this.config.color}" ?dialog-shown="${fe(this,yr)}" popup-delay-ms="${Ef(this.config.popup?.delayMs)}" popup-text="${Ef(this.config.popup?.text)}" @popup-chat-open="${ri(this,hu,l_)}"></mw-popup>
1042
1042
  `:""}
1043
1043
  ${this.config?.tryItOut?.mobileEnabled||this.config?.tryItOut?.desktopEnabled?di`
1044
1044
  <!-- -->
@@ -1070,9 +1070,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1070
1070
 
1071
1071
  <div class="">
1072
1072
  ${Al(Array.from(h),([o])=>o,([o,c])=>di`
1073
- <div class="mb-3 text-center text-xs text-gray-500">${Yv(new Date(Number(o)),window?.navigator?.language)}</div>
1074
- ${Al(c??[],g=>g.id,g=>di`
1075
- <div class="mx-4 mb-4 flex-row">
1073
+ <div class="my-2 text-center text-xs text-gray-500">${Yv(new Date(Number(o)),window?.navigator?.language)}</div>
1074
+ ${Al(c??[],g=>g.id,(g,l)=>{let v=c[l+1]?.role===g.role;return di`
1075
+ <div class="${v?"mb-[2px]":"mb-3"} mx-4 flex-row">
1076
1076
  <mw-chat-message .config="${this.config}" side="${g.role}" @click="${ri(this,ou,h_)}">
1077
1077
  <div class="prose break-words text-inherit">
1078
1078
  ${g.content==="\xB7 \xB7 \xB7"?di`<mw-loading class="-mx-2 block h-8 max-h-[24px] w-8 fill-[${this.config.color}]"></mw-loading>`:g.content_html?il(g.content_html):di`<p>${g.content}</p>`}
@@ -1084,7 +1084,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1084
1084
  <path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5" />
1085
1085
  </svg> `:Ki}
1086
1086
  </div>
1087
- `)}
1087
+ `})}
1088
1088
  `)}
1089
1089
  ${fe(this,Wr)?.typingIndicator?di`<mw-chat-message class="mx-4 mb-4 block" .config="${this.config}" side="${fe(this,Wr)?.typingIndicator.role}">
1090
1090
  <div class="prose break-words text-inherit">
@@ -1103,7 +1103,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1103
1103
  </div>
1104
1104
  </div>
1105
1105
  </div>
1106
- `}updated(i){i.has("config")&&this.config.kioskMode&&(ci(this,yr,this.config.kioskMode),this.requestUpdate()),console.assert(this.widgetId,"widget id is required"),console.assert(this.config,"config is required")}firstUpdated(){}disconnectedCallback(){fe(this,ia)&&clearTimeout(fe(this,ia))}openChat(){fe(this,yr)||(ci(this,yr,!0),this.requestUpdate(),bn("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"programmatic-method",state:fe(this,yr)?"open":"close"}))}closeChat(){fe(this,yr)&&(ci(this,yr,!1),this.requestUpdate(),bn("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"programmatic-method",state:fe(this,yr)?"open":"close"}))}async injectConfig(i){i.kioskMode=this.config.kioskMode,this.config=i,this.requestUpdate()}};bh=new WeakSet,Lp=function(){if(!this.widgetId)throw new Error("widgetId is required");return`_molin_${this.widgetId}`},au=new WeakSet,o_=function(){return window.location.hostname==="molin.ai"},Wr=new WeakMap,yr=new WeakMap,ia=new WeakMap,ou=new WeakSet,h_=function(i){let r=i.target;r&&r instanceof HTMLAnchorElement&&r.tagName==="A"&&bn("ShopAssistant: user clicked link",{widgetId:this.widgetId,url:r.href})},hu=new WeakSet,l_=function(){ci(this,yr,!0),ri(this,cl,nu).call(this,fe(this,yr)),this.requestUpdate(),bn("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"popup-click",state:fe(this,yr)?"open":"close"})},lu=new WeakSet,p_=function(i){let r=i.detail.example;fe(this,Wr)?.sendUserInput(r,{expectStreaming:!this.config.liveChatEnabled}),bn("ShopAssistant: user sent input",{widgetId:this.widgetId,text:r,example:!0})},pu=new WeakSet,c_=function(){ci(this,yr,!fe(this,yr)),ri(this,cl,nu).call(this,fe(this,yr)),this.requestUpdate(),bn("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"bubble-toggle",state:fe(this,yr)?"open":"close"})},cu=new WeakSet,f_=function(i){ci(this,yr,!1),ri(this,cl,nu).call(this,fe(this,yr)),this.requestUpdate(),bn("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"top-right-close-button",state:fe(this,yr)?"open":"close"})},fu=new WeakSet,u_=function(i){fe(this,Wr)?.reset()},uu=new WeakSet,d_=function(i){let r=i.detail.value;fe(this,Wr)?.sendUserInput(r,{expectStreaming:!this.config.liveChatEnabled}),bn("ShopAssistant: user sent input",{widgetId:this.widgetId,text:r,example:!1})},du=new WeakSet,m_=function(i){fe(this,Wr)?.sendUserCancel(),bn("ShopAssistant: user canceled streaming",{widgetId:this.widgetId})},mu=new WeakSet,g_=function(){fe(this,ia)?(clearTimeout(fe(this,ia)),ci(this,ia,setTimeout(()=>{fe(this,Wr)?.sendUserTypingStop(),ci(this,ia,void 0)},2e3))):(fe(this,Wr)?.sendUserTypingStart(),ci(this,ia,setTimeout(()=>{fe(this,Wr)?.sendUserTypingStop(),ci(this,ia,void 0)},2e3)))},cl=new WeakSet,nu=function(i=!0){window.matchMedia("(min-width: 640px)").matches||(document.body.style.overflow=i?"hidden":"")},le(su,"properties",{widgetId:{type:String,attribute:"widget"},config:{type:Object,attribute:!1}});customElements.define("molin-shop-ai",su);
1106
+ `}updated(i){i.has("config")&&this.config.kioskMode&&(ci(this,yr,this.config.kioskMode),this.requestUpdate()),console.assert(this.widgetId,"widget id is required"),console.assert(this.config,"config is required")}disconnectedCallback(){fe(this,ia)&&clearTimeout(fe(this,ia))}openChat(){fe(this,yr)||(ci(this,yr,!0),this.requestUpdate(),bn("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"programmatic-method",state:fe(this,yr)?"open":"close"}))}closeChat(){fe(this,yr)&&(ci(this,yr,!1),this.requestUpdate(),bn("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"programmatic-method",state:fe(this,yr)?"open":"close"}))}async injectConfig(i){i.kioskMode=this.config.kioskMode,this.config=i,this.requestUpdate()}};bh=new WeakSet,Lp=function(){if(!this.widgetId)throw new Error("widgetId is required");return`_molin_${this.widgetId}`},au=new WeakSet,o_=function(){return window.location.hostname==="molin.ai"},Wr=new WeakMap,yr=new WeakMap,ia=new WeakMap,ou=new WeakSet,h_=function(i){let r=i.target;r&&r instanceof HTMLAnchorElement&&r.tagName==="A"&&bn("ShopAssistant: user clicked link",{widgetId:this.widgetId,url:r.href})},hu=new WeakSet,l_=function(){ci(this,yr,!0),ri(this,cl,nu).call(this,fe(this,yr)),this.requestUpdate(),bn("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"popup-click",state:fe(this,yr)?"open":"close"})},lu=new WeakSet,p_=function(i){let r=i.detail.example;fe(this,Wr)?.sendUserInput(r,{expectStreaming:!this.config.liveChatEnabled}),bn("ShopAssistant: user sent input",{widgetId:this.widgetId,text:r,example:!0})},pu=new WeakSet,c_=function(){ci(this,yr,!fe(this,yr)),ri(this,cl,nu).call(this,fe(this,yr)),this.requestUpdate(),bn("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"bubble-toggle",state:fe(this,yr)?"open":"close"})},cu=new WeakSet,f_=function(i){ci(this,yr,!1),ri(this,cl,nu).call(this,fe(this,yr)),this.requestUpdate(),bn("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"top-right-close-button",state:fe(this,yr)?"open":"close"})},fu=new WeakSet,u_=function(i){fe(this,Wr)?.reset()},uu=new WeakSet,d_=function(i){let r=i.detail.value;fe(this,Wr)?.sendUserInput(r,{expectStreaming:!this.config.liveChatEnabled}),bn("ShopAssistant: user sent input",{widgetId:this.widgetId,text:r,example:!1})},du=new WeakSet,m_=function(i){fe(this,Wr)?.sendUserCancel(),bn("ShopAssistant: user canceled streaming",{widgetId:this.widgetId})},mu=new WeakSet,g_=function(){fe(this,ia)?(clearTimeout(fe(this,ia)),ci(this,ia,setTimeout(()=>{fe(this,Wr)?.sendUserTypingStop(),ci(this,ia,void 0)},2e3))):(fe(this,Wr)?.sendUserTypingStart(),ci(this,ia,setTimeout(()=>{fe(this,Wr)?.sendUserTypingStop(),ci(this,ia,void 0)},2e3)))},cl=new WeakSet,nu=function(i=!0){window.matchMedia("(min-width: 640px)").matches||(document.body.style.overflow=i?"hidden":"")},le(su,"properties",{widgetId:{type:String,attribute:"widget"},config:{type:Object,attribute:!1}});customElements.define("molin-shop-ai",su);
1107
1107
  /*! Bundled license information:
1108
1108
 
1109
1109
  @dotlottie/player-component/dist/dist-AIQGIF54-ZRQFFVOU.mjs:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molin.ai/shop-ai",
3
- "version": "0.4.47",
3
+ "version": "0.4.48",
4
4
  "description": "Molin Shop AI",
5
5
  "keywords": [
6
6
  "molin",