@molin.ai/shop-ai 0.6.45 → 0.7.0

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.
@@ -28,7 +28,7 @@ var ep=Object.defineProperty;var ha=n=>{throw TypeError(n)};var tp=(n,e,t)=>e in
28
28
  `);this.state="open",this.src=""}};C(ar,"properties",{state:{type:String},src:{type:String}});customElements.get("mw-bubble")||customElements.define("mw-bubble",ar);var lr={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ur=n=>(...e)=>({_$litDirective$:n,values:e}),yn=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this.t=e,this._$AM=t,this.i=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var{I:Jp}=Ra;var _l=()=>document.createComment(""),_n=(n,e,t)=>{let i=n._$AA.parentNode,r=e===void 0?n._$AB:e._$AA;if(t===void 0){let s=i.insertBefore(_l(),r),o=i.insertBefore(_l(),r);t=new Jp(s,o,n,n.options)}else{let s=t._$AB.nextSibling,o=t._$AM,a=o!==n;if(a){let l;t._$AQ?.(n),t._$AM=n,t._$AP!==void 0&&(l=n._$AU)!==o._$AU&&t._$AP(l)}if(s!==r||a){let l=t._$AA;for(;l!==s;){let u=l.nextSibling;i.insertBefore(l,r),l=u}}}return t},Rt=(n,e,t=n)=>(n._$AI(e,t),n),Yp={},bl=(n,e=Yp)=>n._$AH=e,wl=n=>n._$AH,cr=n=>{n._$AP?.(!1,!0);let e=n._$AA,t=n._$AB.nextSibling;for(;e!==t;){let i=e.nextSibling;e.remove(),e=i}};var xl=(n,e,t)=>{let i=new Map;for(let r=e;r<=t;r++)i.set(n[r],r);return i},ti=ur(class extends yn{constructor(n){if(super(n),n.type!==lr.CHILD)throw Error("repeat() can only be used in text expressions")}dt(n,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);let r=[],s=[],o=0;for(let a of n)r[o]=i?i(a,o):o,s[o]=t(a,o),o++;return{values:s,keys:r}}render(n,e,t){return this.dt(n,e,t).values}update(n,[e,t,i]){let r=wl(n),{values:s,keys:o}=this.dt(e,t,i);if(!Array.isArray(r))return this.ut=o,s;let a=this.ut??=[],l=[],u,c,p=0,f=r.length-1,d=0,g=s.length-1;for(;p<=f&&d<=g;)if(r[p]===null)p++;else if(r[f]===null)f--;else if(a[p]===o[d])l[d]=Rt(r[p],s[d]),p++,d++;else if(a[f]===o[g])l[g]=Rt(r[f],s[g]),f--,g--;else if(a[p]===o[g])l[g]=Rt(r[p],s[g]),_n(n,l[g+1],r[p]),p++,g--;else if(a[f]===o[d])l[d]=Rt(r[f],s[d]),_n(n,r[p],r[f]),f--,d++;else if(u===void 0&&(u=xl(o,d,g),c=xl(a,p,f)),u.has(a[p]))if(u.has(a[f])){let m=c.get(o[d]),E=m!==void 0?r[m]:null;if(E===null){let L=_n(n,r[p]);Rt(L,s[d]),l[d]=L}else l[d]=Rt(E,s[d]),_n(n,r[p],E),r[m]=null;d++}else cr(r[f]),f--;else cr(r[p]),p++;for(;d<=g;){let m=_n(n,l[g+1]);Rt(m,s[d]),l[d++]=m}for(;p<=f;){let m=r[p++];m!==null&&cr(m)}return this.ut=o,bl(n,l),nt}});function kl(n,e,t){return n?e(n):t?.(n)}var pr,Sl,fr=class fr extends z(U){constructor(){super();b(this,pr);this.examples={title:"",items:[]},this.color=""}render(){return!this.examples?.title&&!this.examples?.items?.length?N:D`
29
29
  <div class="flex h-full w-full flex-1 flex-col overflow-y-auto px-4 pb-2 pt-6">
30
30
  ${kl(this.examples.title,()=>D`
31
- <h2 class="mt-14 px-2 pb-2 pt-9 text-left text-3xl font-bold leading-tight tracking-tight">
31
+ <h2 class="mt-14 max-w-[20rem] px-2 pb-2 pt-9 text-left text-3xl font-bold leading-tight tracking-tight">
32
32
  <span>${this.examples.title}</span>
33
33
  <svg class="inline-block h-9 w-9 align-middle" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 58 61">
34
34
  <path
@@ -371,7 +371,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
371
371
  :host {
372
372
  all: initial; /* reset all properties that can pierce the shadow DOM */
373
373
  }
374
- `),C(Li,"properties",{cdn:{type:String},widgetId:{type:String,attribute:"widget"},state:{type:String}});customElements.define("molin-shop-ai-launcher",Li);var us,Hn,zn,dn,Ni,ji,ls=class{constructor(e,t,i,r=window.history){b(this,us);b(this,Hn);b(this,zn);b(this,dn);b(this,Ni,!1);b(this,ji,()=>{h(this,Hn).test(window.location.pathname)&&h(this,zn).navigated()});S(this,us,e),S(this,Hn,t),S(this,zn,i),S(this,dn,r),e.addController(this)}hostConnected(){window.addEventListener("pageshow",h(this,ji));let e=h(this,dn).pushState;h(this,dn).pushState=(...t)=>{if(e.call(h(this,dn),...t),!h(this,Ni))try{let i=new URL(t[2],window.location.origin);h(this,Hn).test(i.pathname)&&h(this,zn).navigated()}catch{}}}hostDisconnected(){window.removeEventListener("pageshow",h(this,ji)),S(this,Ni,!0)}};us=new WeakMap,Hn=new WeakMap,zn=new WeakMap,dn=new WeakMap,Ni=new WeakMap,ji=new WeakMap;function zc({min:n,max:e}){return Math.floor(Math.random()*(e-n+1))+n*1e3}var zt,dt,aa,qi,oa=class{constructor(e=window.localStorage){b(this,dt);b(this,zt);S(this,zt,e)}setex(e,t,i){return h(this,zt).setItem(e,$(this,dt,qi).call(this,{value:$(this,dt,qi).call(this,t),expiresAt:Date.now()+i*1e3})||"")}set(e,t){return h(this,zt).setItem(e,$(this,dt,qi).call(this,{value:$(this,dt,qi).call(this,t)})||"")}get(e){let t=h(this,zt).getItem(e);if(!t)return;let i=$(this,dt,aa).call(this,t);if(i){if(i.expiresAt&&i.expiresAt<Date.now()){h(this,zt).removeItem(e);return}return $(this,dt,aa).call(this,i.value)}}};zt=new WeakMap,dt=new WeakSet,aa=function(e){if(!(typeof e!="string"||e===""))try{return JSON.parse(e)}catch{return}},qi=function(e){if(e!==void 0)try{return JSON.stringify(e)}catch{return}};var la=new oa;function cs(n,e=""){return Object.entries(n).filter(([t,i])=>i).map(([t,i])=>`${e}${t}-[${i}]`).join(" ")}var Wc="molin-shop-ai-widget-open",ps,Hi,ua,Ae,fs,le,Bi,Vc,Gc,Xc,Jc,Wn,Ui=class extends z(U){constructor(){super();b(this,le);b(this,ps,new Dt(this,{onError:console.error}));b(this,Hi);b(this,ua,new ls(this,/checkout|order|thank-you|thank_you/i,{navigated:()=>{let t=h(this,le,Vc);t&&De("ShopAssistant: user visited checkout page",{widgetId:this.widgetId,conversationId:t.conversationId,hasSentMessage:t.messages.length>0})}}));b(this,Ae,!1);b(this,fs,{onError:t=>{alert(t.error),console.error(t.widgetId,t.error),De("ShopAssistant: error",t)},onNewMessageStartedStreaming:t=>De("ShopAssistant: user received bot message (streaming started)",t),onMessageEndedStreaming:t=>De("ShopAssistant: user received bot message (streaming ended)",t),onUserCanceledStreaming:t=>De("ShopAssistant: user canceled streaming",t),onUserClickedLink:t=>De("ShopAssistant: user clicked link",t),onUserSentInput:t=>De("ShopAssistant: user sent input",t)});this.cdn="https://widget.molin.ai",this.widgetId="",this._dialogAlreadyShown=!1}get config(){return h(this,Hi)||h(this,ps).data}render(){if(!this.config)return N;let t=this.config.bubble.position;"left"in t&&"right"in t&&delete t.right;let i=[cs(this.config.bubble.position),cs(this.config.bubble.mobilePosition||{},"max-sm:")].join(" "),r=cs(this.config.bubble.position),s=Object.entries(this.config.bubble.position).filter(([a,l])=>l).map(([a,l])=>{let u=`sm:${a}-[${l}]`;return a==="left"&&(u+=" sm:right-auto"),a==="right"&&(u+=" sm:left-auto"),u}).join(" "),o=s;return this.config.hidden?N:D`
374
+ `),C(Li,"properties",{cdn:{type:String},widgetId:{type:String,attribute:"widget"},state:{type:String}});customElements.define("molin-shop-ai-launcher",Li);var us,Hn,zn,dn,Ni,ji,ls=class{constructor(e,t,i,r=window.history){b(this,us);b(this,Hn);b(this,zn);b(this,dn);b(this,Ni,!1);b(this,ji,()=>{h(this,Hn).test(window.location.pathname)&&h(this,zn).navigated()});S(this,us,e),S(this,Hn,t),S(this,zn,i),S(this,dn,r),e.addController(this)}hostConnected(){window.addEventListener("pageshow",h(this,ji));let e=h(this,dn).pushState;h(this,dn).pushState=(...t)=>{if(e.call(h(this,dn),...t),!h(this,Ni))try{let i=new URL(t[2],window.location.origin);h(this,Hn).test(i.pathname)&&h(this,zn).navigated()}catch{}}}hostDisconnected(){window.removeEventListener("pageshow",h(this,ji)),S(this,Ni,!0)}};us=new WeakMap,Hn=new WeakMap,zn=new WeakMap,dn=new WeakMap,Ni=new WeakMap,ji=new WeakMap;function zc({min:n,max:e}){return Math.floor(Math.random()*(e-n+1))+n*1e3}var zt,dt,aa,qi,oa=class{constructor(e=window.localStorage){b(this,dt);b(this,zt);S(this,zt,e)}setex(e,t,i){return h(this,zt).setItem(e,$(this,dt,qi).call(this,{value:$(this,dt,qi).call(this,t),expiresAt:Date.now()+i*1e3})||"")}set(e,t){return h(this,zt).setItem(e,$(this,dt,qi).call(this,{value:$(this,dt,qi).call(this,t)})||"")}get(e){let t=h(this,zt).getItem(e);if(!t)return;let i=$(this,dt,aa).call(this,t);if(i){if(i.expiresAt&&i.expiresAt<Date.now()){h(this,zt).removeItem(e);return}return $(this,dt,aa).call(this,i.value)}}};zt=new WeakMap,dt=new WeakSet,aa=function(e){if(!(typeof e!="string"||e===""))try{return JSON.parse(e)}catch{return}},qi=function(e){if(e!==void 0)try{return JSON.stringify(e)}catch{return}};var la=new oa;function cs(n,e=""){return Object.entries(n).filter(([t,i])=>i).map(([t,i])=>`${e}${t}-[${i}]`).join(" ")}var Wc="molin-shop-ai-widget-open",ps,Hi,ua,Ae,fs,le,Bi,Vc,Gc,Xc,Jc,Wn,Ui=class extends z(U){constructor(){super();b(this,le);b(this,ps,new Dt(this,{onError:console.error}));b(this,Hi);b(this,ua,new ls(this,/checkout|order|thank-you|thank_you/i,{navigated:()=>{let t=h(this,le,Vc);t&&De("ShopAssistant: user visited checkout page",{widgetId:this.widgetId,conversationId:t.conversationId,hasSentMessage:t.messages.length>0})}}));b(this,Ae,!1);b(this,fs,{onError:t=>{alert(t.error),console.error(t.widgetId,t.error),De("ShopAssistant: error",t)},onNewMessageStartedStreaming:t=>De("ShopAssistant: user received bot message (streaming started)",t),onMessageEndedStreaming:t=>De("ShopAssistant: user received bot message (streaming ended)",t),onUserCanceledStreaming:t=>De("ShopAssistant: user canceled streaming",t),onUserClickedLink:t=>De("ShopAssistant: user clicked link",t),onUserSentInput:t=>De("ShopAssistant: user sent input",t)});this.cdn="https://widget.molin.ai",this.widgetId="",this._dialogAlreadyShown=!1}get config(){return h(this,Hi)||h(this,ps).data}render(){if(!this.config)return N;let t=this.config.bubble.position;"left"in t&&"right"in t&&delete t.right;let i=[cs(this.config.bubble.position),cs(this.config.bubble.mobilePosition||{},"max-sm:")].join(" "),r=cs(this.config.bubble.position),s=Object.entries(this.config.bubble.position).filter(([a,l])=>l).filter(([a])=>a==="left"||a==="right").map(([a,l])=>{let u=`sm:${a}-[${l}]`;return a==="left"&&(u+=" sm:right-auto"),a==="right"&&(u+=" sm:left-auto"),u}).join(" "),o=s;return this.config.hidden?N:D`
375
375
  <mw-bubble class="${i} ${h(this,Ae)?"opacity-0":"opacity-100"} fixed z-[2147483647] transition-opacity" @click="${$(this,le,Xc)}" state="${h(this,Ae)?"close":"open"}" src="${this.config.bubble?.imageUrl||""}"></mw-bubble>
376
376
 
377
377
  <!-- only load the component if enabled on any platform -->
@@ -389,7 +389,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
389
389
 
390
390
  <!-- On first render, do not render the dialog, so it does not connect to backend. Once it's rendered once, it's never removed from the DOM. -->
391
391
  ${this._dialogAlreadyShown?D`
392
- <div class="${h(this,Ae)?"visible opacity-100 translate-y-0":"invisible opacity-0 translate-y-3"} ${s} fixed inset-0 z-[2147483647] bg-white font-sans text-[16px] leading-normal text-gray-800 shadow-2xl transition-all sm:top-auto sm:h-[92%] sm:max-h-[800px] sm:w-[calc(100dvh*0.50)] sm:min-w-[300px] sm:max-w-[400px] sm:rounded-[36px] 2xl:max-w-[420px]">
392
+ <div
393
+ class="${h(this,Ae)?"visible opacity-100 translate-y-0":"invisible opacity-0 translate-y-3"} ${s} fixed inset-0 z-[2147483647] bg-white font-sans text-[16px] leading-normal text-gray-800 shadow-2xl transition-all sm:bottom-[1.5rem] sm:top-auto sm:h-[92%] sm:max-h-[800px] sm:w-[calc(100dvh*0.50)] sm:min-w-[300px] sm:max-w-[400px] sm:rounded-[36px] 2xl:max-w-[420px]">
393
394
  <mw-chat .config="${{...this.config,widgetId:this.widgetId}}" .callbacks="${h(this,fs)}" ?show-close="${!0}" @mw:close-click="${$(this,le,Jc)}">
394
395
  <slot name="banner" slot="banner"></slot>
395
396
  </mw-chat>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molin.ai/shop-ai",
3
- "version": "0.6.45",
3
+ "version": "0.7.0",
4
4
  "description": "Molin Shop AI",
5
5
  "keywords": [
6
6
  "molin",