@molin.ai/shop-ai 0.8.42 → 0.8.43

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.
@@ -572,7 +572,192 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
572
572
  </button> -->
573
573
  </div>
574
574
  </div>
575
- `}};V=new WeakSet,tl=function(){if(!this.product?.url){this._isValidUrl=!1;return}try{let r=new URL(this.product.url);this._isValidUrl=r.protocol==="http:"||r.protocol==="https:"}catch{this._isValidUrl=!1}},Hn=function(r){r.preventDefault(),!(!this.product?.url||!this._isValidUrl)&&window.open(this.product.url,"_blank")},rl=function(r){!this.product?.url||!this._isValidUrl||(window.open(this.product.url,"_blank"),this.dispatchEvent(new zn.AddToCartEvent(this.product)))},qn=function(r,n){a(this,V,Bn)&&ks({from:r,to:n,duration:300,onUpdate:i=>{a(this,V,Bn)&&(a(this,V,Bn).style.transform=`translateX(${i}%)`)}})},nl=function(){if(!this.product?.images?.length)return;let r=this._currentImageIndex,n=(r+1)%this.product.images.length,i=-(r*100),s=-(n*100);g(this,V,qn).call(this,i,s),this._currentImageIndex=n},il=function(){if(!this.product?.images?.length)return;let r=this._currentImageIndex,n=(r-1+this.product.images.length)%this.product.images.length,i=-(r*100),s=-(n*100);g(this,V,qn).call(this,i,s),this._currentImageIndex=n},sl=function(r){if(!this.product?.images?.length)return;let n=this._currentImageIndex,i=Math.max(0,Math.min(r,this.product.images.length-1)),s=-(n*100),o=-(i*100);g(this,V,qn).call(this,s,o),this._currentImageIndex=i},Bn=function(){return this.renderRoot.querySelector(".image-slider")},y(zn,"properties",{product:{type:Object},labels:{type:Object},_currentImageIndex:{type:Number,state:!0},_isValidUrl:{type:Boolean,state:!0}});var Sr=zn,Cs;Sr.AddToCartEvent=(Cs=class extends CustomEvent{constructor(e,r={}){super(Sr.AddToCartEvent.type,{detail:{product:e},...r})}},y(Cs,"type","mw-product-card:add-to-cart"),Cs);customElements.get("mw-product-card")||customElements.define("mw-product-card",Sr);var Er,se,be,_r,$s,Wn=class{constructor(e,r){d(this,_r);d(this,Er);d(this,se);d(this,be);if(!e)throw new Error("host is required");if(!r)throw new Error("config is required");m(this,Er,e),a(this,Er).addController(this),m(this,se,r)}connect(e){m(this,se,e),m(this,be,g(this,_r,$s).call(this))}hostConnected(){setTimeout(()=>{m(this,be,g(this,_r,$s).call(this))},0)}hostDisconnected(){a(this,be)?.close(1e3,"lit_host_disconnected"),m(this,be,void 0)}send(e){a(this,be)?.send(e)}close(e,r){a(this,be)?.close(e,r)}get isConnected(){return a(this,be)?.readyState===WebSocket.OPEN}get isConnecting(){return a(this,be)?.readyState===WebSocket.CONNECTING}};Er=new WeakMap,se=new WeakMap,be=new WeakMap,_r=new WeakSet,$s=function(){let e=new WebSocket(a(this,se).url());return a(this,se).onClose&&(e.onclose=a(this,se).onClose),a(this,se).onOpen&&(e.onopen=a(this,se).onOpen),a(this,se).onError&&(e.onerror=a(this,se).onError),a(this,se).onMessage&&(e.onmessage=a(this,se).onMessage),e};var ol=Array.isArray;var Ss=t=>!!(t&&t.constructor&&t.call&&t.apply);var al=t=>!(!t||!t.then||!Ss(t.then));function*ll(t,e,r=i=>i,n=1){let i=Ss(r)?r:()=>r,s=e?t:0,o=e??t;for(let u=s;u<=o&&(yield i(u),!(u+n>o));u+=n);}var _s=async(t,e)=>{let r=t?.times??3,n=t?.delay,i=t?.backoff??null;for(let s of ll(1,r)){let[o,u]=await As(e)(l=>{throw{_exited:l}});if(!o)return u;if(o._exited)throw o._exited;if(s===r)throw o;n&&await Es(n),i&&await Es(i(s))}},Es=t=>new Promise(e=>setTimeout(e,t)),As=t=>(...e)=>{try{let r=t(...e);return al(r)?r.then(n=>[void 0,n]).catch(n=>[n,void 0]):[void 0,r]}catch(r){return[r,void 0]}};var ul="664df22d-d461-42d6-801e-f70247e2cd7c",B,K,te,jt,Dt,me,z,Ee,cl,pl,fl,hl,Zn=class{constructor(e,r){d(this,z);d(this,B);d(this,K);d(this,te);y(this,"isStreaming",!1);y(this,"typingIndicator");y(this,"ranOutOfCredits",!1);y(this,"messages",[]);y(this,"conversationId","");d(this,jt,0);d(this,Dt);y(this,"isLiveMode",!1);d(this,me,[]);m(this,B,e),m(this,K,r),m(this,te,this.initWS()),e.addController(this)}get hasQueuedMessages(){return a(this,me).length>0}async enqueueMessage(e,{expectStreaming:r=!1}={}){if(a(this,me).length>0){let n=a(this,me)[a(this,me).length-1];if(e.type==="USER_INPUT"&&n.message.type==="USER_INPUT"&&e.value===n.message.value)return!0}return a(this,te).isConnected?g(this,z,Ee).call(this,e,{expectStreaming:r}):(a(this,me).push({message:e,options:{expectStreaming:r}}),a(this,B).requestUpdate(),!a(this,te).isConnecting&&!a(this,te).isConnected&&this.retry(),await _s({times:5,delay:2e3},async()=>{if(a(this,te).isConnected){let n=[...a(this,me)];m(this,me,[]),a(this,B).requestUpdate();let i=!1;for(let{message:s,options:o}of n){let u=g(this,z,Ee).call(this,s,o);s===e&&(i=u)}return i}else throw new Error("WebSocket not connected yet")}).catch(()=>(console.warn("Failed to send message after retries",e),m(this,me,[]),a(this,B).requestUpdate(),!1)))}sendUserInput(e,{xUserData:r,xCustomInstructions:n,role:i="user",expectStreaming:s=!1}={}){return g(this,z,Ee).call(this,{type:"USER_INPUT",value:e,role:i,xUserData:r,xCustomInstructions:n},{expectStreaming:s})}async enqueueUserInput(e,{xUserData:r,xCustomInstructions:n,role:i="user",expectStreaming:s=!1}={}){return this.enqueueMessage({type:"USER_INPUT",value:e,role:i,xUserData:r,xCustomInstructions:n},{expectStreaming:s})}sendUserCancel(){return g(this,z,Ee).call(this,{type:"USER_CANCEL"})}sendUserTypingStart(){return g(this,z,Ee).call(this,{type:"USER_TYPING_START"})}sendUserTypingStop(){return g(this,z,Ee).call(this,{type:"USER_TYPING_STOP"})}sendUserMeta(e){return g(this,z,Ee).call(this,{type:"USER_META",metadata:e})}reloadConfig(){g(this,z,Ee).call(this,{type:"RELOAD_CONFIG"})}close(){a(this,te).close(1e3,"closed by user")}retry(){clearTimeout(a(this,Dt)),m(this,Dt,setTimeout(()=>{a(this,K).onReconnect?.(),m(this,te,this.initWS())},1e3*a(this,jt))),io(this,jt)._++}initWS(){return new Wn(a(this,B),{url:()=>a(this,K).url(this.conversationId,{}),onOpen:e=>g(this,z,cl).call(this,e),onMessage:e=>g(this,z,pl).call(this,JSON.parse(e.data)),onError:e=>g(this,z,fl).call(this,e),onClose:e=>g(this,z,hl).call(this,e)})}hostConnected(){this.conversationId=a(this,K).restoreConversationState?.()?.conversationId||"",this.messages=a(this,K).restoreConversationState?.()?.messages||[]}reset(){g(this,z,Ee).call(this,{type:"NEW_CHAT"}),a(this,K).onReset?.(),this.isStreaming=!1,this.typingIndicator=void 0,this.ranOutOfCredits=!1,this.messages=[],this.conversationId="",this.isLiveMode=!1,m(this,me,[]),a(this,B).requestUpdate()}hostDisconnected(){clearTimeout(a(this,Dt))}reconnectSocket(){a(this,te).close(1e3,"destroy"),m(this,te,this.initWS())}get lastMsg(){if(this.messages.length>0)return this.messages[this.messages.length-1]}};B=new WeakMap,K=new WeakMap,te=new WeakMap,jt=new WeakMap,Dt=new WeakMap,me=new WeakMap,z=new WeakSet,Ee=function(e,{expectStreaming:r=!1}={}){return a(this,te).isConnecting?(console.warn("WebSocket is connecting, message not sent",e),!1):a(this,te).isConnected?(r&&!this.isLiveMode&&(this.isStreaming=!0,a(this,B).requestUpdate()),a(this,te).send(JSON.stringify(e)),!0):(console.warn("WebSocket is not connected, message not sent",e),this.retry(),!1)},cl=function(e){m(this,jt,0)},pl=function(e){switch(e.type){case"NEW_MESSAGE":{this.messages=[...this.messages,{...e.message,streaming:!0}].filter((r,n,i)=>n===i.findIndex(s=>s.id===r.id)),this.typingIndicator=void 0,a(this,B).requestUpdate(),a(this,K).onNewMessage?.(e.message);break}case"APPEND_MESSAGE":{let r=this.messages.find(n=>n.id===e.message.id);if(r){switch(e.message.content_type){case"text":{let{part:n,delta:i,position:s}=e.message;r.content=r.content.slice(0,s)+i,r.parts||=[],r.parts[n]={text:r.parts[n]&&"text"in r.parts[n]?(r.parts[n].text||"").slice(0,s)+i:i};break}case"html":{let{part:n,delta:i,position:s}=e.message;r.parts||=[],r.parts[n]={html:r.parts[n]&&"html"in r.parts[n]?(r.parts[n].html||"").slice(0,s)+i:i};break}case"data":{let{part:n}=e.message;r.parts||=[],r.parts[n]={tag:e.message.tag,data:r.parts[n]&&"data"in r.parts[n]?Object.assign(r.parts[n].data||{},e.message.data):e.message.data};break}}e.metadata&&(r.metadata=e.metadata),a(this,K).onMessageAppend?.(e),a(this,B).requestUpdate()}else throw new Error(`Message with id ${e.message.id} not found`);break}case"MESSAGE_DONE":{let r=this.messages.find(n=>n.id===e.message.id);if(r)Object.assign(r,e.message),r.streaming=!1;else throw new Error(`Message with id ${e.message.id} not found`);this.isStreaming=!1,a(this,B).requestUpdate(),a(this,K).onMessageDone?.(e,r),a(this,K).persistConversationState?.(this.conversationId,this.messages);break}case"MESSAGE_CANCEL":{this.isStreaming=!1,this.typingIndicator=void 0,a(this,B).requestUpdate();break}case"ERROR":{a(this,K).onMessageError?.(e);break}case"CONNECTED":{this.conversationId=e.conversationId,this.messages=e.messages,a(this,K).onConnect?.(e.conversationId),a(this,K).persistConversationState?.(e.conversationId,e.messages),this.isLiveMode=e.metadata?.isLiveMode,a(this,B).requestUpdate();break}case"TYPING_START":{e.role==="assistant"&&(this.isStreaming=!0),this.typingIndicator={role:e.role,metadata:e.metadata},a(this,B).requestUpdate();break}case"TYPING_STOP":{this.typingIndicator=void 0,a(this,B).requestUpdate();break}case"RAN_OUT_OF_CREDITS":{this.messages.some(r=>r.id===ul)||this.messages.push({id:ul,role:"assistant",content:"Sorry, I've run out of credits. Please contact the shop directly.",timestamp:Date.now()}),this.ranOutOfCredits=!0,a(this,B).requestUpdate();break}case"RECONNECT":{this.reconnectSocket(),a(this,B).requestUpdate();break}default:console.warn(`Unknown message type: ${JSON.stringify(e)}`)}},fl=function(e){console.error("onError",e),a(this,K).onError?.(e)},hl=function(e){a(this,B).isConnected&&!a(this,te).isConnected&&e.reason==="reconnect"&&this.retry(),this.isStreaming=!1,this.typingIndicator=void 0,a(this,B).requestUpdate(),a(this,K).onClose?.()};function Rt(t){return Array.isArray(t)?t:t?[t]:[]}function dl(t,e){let r=new Map;for(let n of t){let i=e(n);r.has(i)||r.set(i,[]),(r.get(i)||[]).push(n)}return r}var Ar=class extends Ct{constructor(e){if(super(e),this.it=E,e.type!==yn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===E||e==null)return this._t=void 0,this.it=e;if(e===ye)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let r=[e];return r.raw=r,this._t={_$litType$:this.constructor.resultType,strings:r,values:[]}}};Ar.directiveName="unsafeHTML",Ar.resultType=1;var ml=vn(Ar);var Ms;function Is(t){return{lang:t?.lang??Ms?.lang,message:t?.message,abortEarly:t?.abortEarly??Ms?.abortEarly,abortPipeEarly:t?.abortPipeEarly??Ms?.abortPipeEarly}}var ip;function sp(t){return ip?.get(t)}var op;function ap(t){return op?.get(t)}var lp;function up(t,e){return lp?.get(t)?.get(e)}function yl(t){let e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&Object.getPrototypeOf(t)?.constructor?.name)??"null":e}function le(t,e,r,n,i){let s=i&&"input"in i?i.input:r.value,o=i?.expected??t.expects??null,u=i?.received??yl(s),l={kind:t.kind,type:t.type,input:s,expected:o,received:u,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${u}`,requirement:t.requirement,path:i?.path,issues:i?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},c=t.kind==="schema",f=i?.message??t.message??up(t.reference,l.lang)??(c?ap(l.lang):null)??n.message??sp(l.lang);f!==void 0&&(l.message=typeof f=="function"?f(l):f),c&&(r.typed=!1),r.issues?r.issues.push(l):r.issues=[l]}function ue(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},Is())}}}function cp(t,e){return Object.hasOwn(t,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function vl(t,e){let r=[...new Set(t)];return r.length>1?`(${r.join(` ${e} `)})`:r[0]??"never"}var pp=class extends Error{constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function Ls(t,e){return{kind:"validation",type:"max_length",reference:Ls,async:!1,expects:`<=${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&r.value.length>this.requirement&&le(this,"length",r,n,{received:`${r.value.length}`}),r}}}function Ts(t,e){return{kind:"validation",type:"min_length",reference:Ts,async:!1,expects:`>=${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&r.value.length<this.requirement&&le(this,"length",r,n,{received:`${r.value.length}`}),r}}}function fp(t,e,r){return typeof t.fallback=="function"?t.fallback(e,r):t.fallback}function wl(t,e,r){return typeof t.default=="function"?t.default(e,r):t.default}function Os(){return{kind:"schema",type:"any",reference:Os,expects:"any",async:!1,get"~standard"(){return ue(this)},"~run"(t){return t.typed=!0,t}}}function Pt(t,e){return{kind:"schema",type:"array",reference:Pt,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return ue(this)},"~run"(r,n){let i=r.value;if(Array.isArray(i)){r.typed=!0,r.value=[];for(let s=0;s<i.length;s++){let o=i[s],u=this.item["~run"]({value:o},n);if(u.issues){let l={type:"array",origin:"value",input:i,key:s,value:o};for(let c of u.issues)c.path?c.path.unshift(l):c.path=[l],r.issues?.push(c);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else le(this,"type",r,n);return r}}}function js(t){return{kind:"schema",type:"boolean",reference:js,expects:"boolean",async:!1,message:t,get"~standard"(){return ue(this)},"~run"(e,r){return typeof e.value=="boolean"?e.typed=!0:le(this,"type",e,r),e}}}function Ds(t){return{kind:"schema",type:"null",reference:Ds,expects:"null",async:!1,message:t,get"~standard"(){return ue(this)},"~run"(e,r){return e.value===null?e.typed=!0:le(this,"type",e,r),e}}}function Gn(t){return{kind:"schema",type:"number",reference:Gn,expects:"number",async:!1,message:t,get"~standard"(){return ue(this)},"~run"(e,r){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:le(this,"type",e,r),e}}}function Oe(t,e){return{kind:"schema",type:"object",reference:Oe,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return ue(this)},"~run"(r,n){let i=r.value;if(i&&typeof i=="object"){r.typed=!0,r.value={};for(let s in this.entries){let o=this.entries[s];if(s in i||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let u=s in i?i[s]:wl(o),l=o["~run"]({value:u},n);if(l.issues){let c={type:"object",origin:"value",input:i,key:s,value:u};for(let f of l.issues)f.path?f.path.unshift(c):f.path=[c],r.issues?.push(f);if(r.issues||(r.issues=l.issues),n.abortEarly){r.typed=!1;break}}l.typed||(r.typed=!1),r.value[s]=l.value}else if(o.fallback!==void 0)r.value[s]=fp(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(le(this,"key",r,n,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:i,key:s,value:i[s]}]}),n.abortEarly))break}}else le(this,"type",r,n);return r}}}function Ut(t,e){return{kind:"schema",type:"optional",reference:Ut,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return ue(this)},"~run"(r,n){return r.value===void 0&&(this.default!==void 0&&(r.value=wl(this,r,n)),r.value===void 0)?(r.typed=!0,r):this.wrapped["~run"](r,n)}}}function Rs(t,e){return{kind:"schema",type:"picklist",reference:Rs,expects:vl(t.map(yl),"|"),async:!1,options:t,message:e,get"~standard"(){return ue(this)},"~run"(r,n){return this.options.includes(r.value)?r.typed=!0:le(this,"type",r,n),r}}}function Jn(t,e,r){return{kind:"schema",type:"record",reference:Jn,expects:"Object",async:!1,key:t,value:e,message:r,get"~standard"(){return ue(this)},"~run"(n,i){let s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(let o in s)if(cp(s,o)){let u=s[o],l=this.key["~run"]({value:o},i);if(l.issues){let f={type:"object",origin:"key",input:s,key:o,value:u};for(let p of l.issues)p.path=[f],n.issues?.push(p);if(n.issues||(n.issues=l.issues),i.abortEarly){n.typed=!1;break}}let c=this.value["~run"]({value:u},i);if(c.issues){let f={type:"object",origin:"value",input:s,key:o,value:u};for(let p of c.issues)p.path?p.path.unshift(f):p.path=[f],n.issues?.push(p);if(n.issues||(n.issues=c.issues),i.abortEarly){n.typed=!1;break}}(!l.typed||!c.typed)&&(n.typed=!1),l.typed&&(n.value[l.value]=c.value)}}else le(this,"type",n,i);return n}}}function W(t){return{kind:"schema",type:"string",reference:W,expects:"string",async:!1,message:t,get"~standard"(){return ue(this)},"~run"(e,r){return typeof e.value=="string"?e.typed=!0:le(this,"type",e,r),e}}}function gl(t){let e;if(t)for(let r of t)e?e.push(...r.issues):e=r.issues;return e}function Vt(t,e){return{kind:"schema",type:"union",reference:Vt,expects:vl(t.map(r=>r.expects),"|"),async:!1,options:t,message:e,get"~standard"(){return ue(this)},"~run"(r,n){let i,s,o;for(let u of this.options){let l=u["~run"]({value:r.value},n);if(l.typed)if(l.issues)s?s.push(l):s=[l];else{i=l;break}else o?o.push(l):o=[l]}if(i)return i;if(s){if(s.length===1)return s[0];le(this,"type",r,n,{issues:gl(s)}),r.typed=!0}else{if(o?.length===1)return o[0];le(this,"type",r,n,{issues:gl(o)})}return r}}}function bl(t,e,r){let n=t["~run"]({value:e},Is(r));if(n.issues)throw new pp(n.issues);return n.value}function xl(t,e){let r={};for(let n in t.entries)r[n]=!e||e.includes(n)?Ut(t.entries[n]):t.entries[n];return{...t,entries:r,get"~standard"(){return ue(this)}}}function kl(...t){return{...t[0],pipe:t,get"~standard"(){return ue(this)},"~run"(e,r){for(let n of t)if(n.kind!=="metadata"){if(e.issues&&(n.kind==="schema"||n.kind==="transformation")){e.typed=!1;break}(!e.issues||!r.abortEarly&&!r.abortPipeEarly)&&(e=n["~run"](e,r))}return e}}}function Mr(t,e,r){let n=t["~run"]({value:e},Is(r));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}var Cl=xl(Oe({name:W(),description:W(),price:W(),image_url:Vt([W(),Pt(W())]),category:W(),url:W()}));function $l(t,e,r,{imagesByProductUrl:n,linksNewTab:i=!0,searchParams:s,messageIsStreaming:o=!1}){if(!t)return h``;let u=e>0&&r[e-1]&&"data"in r[e-1],l=e<r.length-1||!o;if("text"in t)return h`<p>${t.text}</p>`;if("html"in t)return h`${ml(t.html)}`;if("data"in t)switch(t.tag){case"product-card":case"product-card-v1":case"product-card-horizontal":{let c=Mr(Cl,t.data);if(c.success){let f={...c.output,images:[]};return f.images=Rt(f.image_url),h`
575
+ `}};V=new WeakSet,tl=function(){if(!this.product?.url){this._isValidUrl=!1;return}try{let r=new URL(this.product.url);this._isValidUrl=r.protocol==="http:"||r.protocol==="https:"}catch{this._isValidUrl=!1}},Hn=function(r){r.preventDefault(),!(!this.product?.url||!this._isValidUrl)&&window.open(this.product.url,"_blank")},rl=function(r){!this.product?.url||!this._isValidUrl||(window.open(this.product.url,"_blank"),this.dispatchEvent(new zn.AddToCartEvent(this.product)))},qn=function(r,n){a(this,V,Bn)&&ks({from:r,to:n,duration:300,onUpdate:i=>{a(this,V,Bn)&&(a(this,V,Bn).style.transform=`translateX(${i}%)`)}})},nl=function(){if(!this.product?.images?.length)return;let r=this._currentImageIndex,n=(r+1)%this.product.images.length,i=-(r*100),s=-(n*100);g(this,V,qn).call(this,i,s),this._currentImageIndex=n},il=function(){if(!this.product?.images?.length)return;let r=this._currentImageIndex,n=(r-1+this.product.images.length)%this.product.images.length,i=-(r*100),s=-(n*100);g(this,V,qn).call(this,i,s),this._currentImageIndex=n},sl=function(r){if(!this.product?.images?.length)return;let n=this._currentImageIndex,i=Math.max(0,Math.min(r,this.product.images.length-1)),s=-(n*100),o=-(i*100);g(this,V,qn).call(this,s,o),this._currentImageIndex=i},Bn=function(){return this.renderRoot.querySelector(".image-slider")},y(zn,"properties",{product:{type:Object},labels:{type:Object},_currentImageIndex:{type:Number,state:!0},_isValidUrl:{type:Boolean,state:!0}});var Sr=zn,Cs;Sr.AddToCartEvent=(Cs=class extends CustomEvent{constructor(e,r={}){super(Sr.AddToCartEvent.type,{detail:{product:e},...r})}},y(Cs,"type","mw-product-card:add-to-cart"),Cs);customElements.get("mw-product-card")||customElements.define("mw-product-card",Sr);function jt(t){return Array.isArray(t)?t:t?[t]:[]}function ol(t,e){let r=new Map;for(let n of t){let i=e(n);r.has(i)||r.set(i,[]),(r.get(i)||[]).push(n)}return r}var al=(t,e,r)=>{for(let n of e)if(n[0]===t)return(0,n[1])();return r?.()};var Wn=class extends _(S){constructor(){super(),this.orderDetails=null,this.streaming=!1,this.linksNewTab=!1}render(){let e=jt(this.orderDetails?.order_status?.step||[]),r=jt(this.orderDetails?.items?.item||[]),n=jt(this.orderDetails?.actions||[]);return h`
576
+ <div class="flex w-full max-w-md flex-col rounded-3xl border bg-white p-4">
577
+ <!-- Header with order ID -->
578
+ <div class="mb-2">
579
+ ${this.orderDetails?.order_id?.label||!this.streaming?h`<h2 class="text-lg font-semibold">${this.orderDetails?.order_id?.label} ${this.orderDetails?.order_id?.value}</h2>`:h`<div class="h-7 w-full animate-pulse rounded bg-gray-200"></div>`}
580
+ </div>
581
+
582
+ <!-- Progress Timeline -->
583
+ <div>
584
+ <ol role="list" class="w-full overflow-hidden">
585
+ ${this.streaming&&!this.orderDetails?h`
586
+ <!-- Loading for status timeline -->
587
+ ${[1,2,3].map((i,s)=>h`
588
+ <li class="w-full pb-8">
589
+ ${s<2?h`<div class="absolute left-2 top-2 -ml-px mt-0.5 h-full w-0.5 animate-pulse bg-gray-200" aria-hidden="true"></div>`:""}
590
+ <div class="group relative flex items-start">
591
+ <span class="flex h-6 items-center">
592
+ <span class="h-4 w-4 animate-pulse rounded-full bg-gray-200"></span>
593
+ </span>
594
+ <span class="ml-3 flex min-w-0 flex-col">
595
+ <span class="h-5 w-24 animate-pulse rounded bg-gray-200"></span>
596
+ </span>
597
+ </div>
598
+ </li>
599
+ `)}
600
+ `:we(e,i=>i.label,(i,s)=>{let o=i.status==="completed",u=i.status==="in_progress",l=s===e.length-1;return h`<li class="relative pb-4">
601
+ ${l?"":h`<div class="${`absolute left-2 top-2 -ml-px mt-0.5 h-full w-0.5 ${o?"bg-[#601feb]":"bg-gray-300"}`}" aria-hidden="true"></div>`}
602
+
603
+ <div class="group relative flex items-start">
604
+ ${al(i.status,[["pending",()=>h` <span class="flex h-6 items-center">
605
+ <span class="flex h-4 w-4 items-center justify-center rounded-full border-2 border-gray-300 bg-white">
606
+ <span class="h-1.5 w-1.5 rounded-full bg-transparent"></span>
607
+ </span>
608
+ </span>`],["in_progress",()=>h`<span class="flex h-6 items-center">
609
+ <span class="flex h-4 w-4 items-center justify-center rounded-full border-2 border-[#601feb] bg-white">
610
+ <span class="h-1.5 w-1.5 rounded-full bg-[#601feb]"></span>
611
+ </span>
612
+ </span>`],["completed",()=>h`
613
+ <span class="flex h-6 items-center">
614
+ <span class="flex h-4 w-4 items-center justify-center rounded-full bg-[#601feb]">
615
+ <hi-outline class="mb-3 block h-3 w-3 text-white" name="check"></hi-outline>
616
+ </span>
617
+ </span>
618
+ `]],()=>h`<span class="flex h-6 items-center">
619
+ <span class="flex h-4 w-4 items-center justify-center rounded-full border-2 border-[#601feb] bg-white">
620
+ <span class="h-1.5 w-1.5 rounded-full bg-[#601feb]"></span>
621
+ </span>
622
+ </span>`)}
623
+
624
+ <span class="ml-3 flex min-w-0 flex-col">
625
+ <span class="${`text-sm font-medium ${u?"text-[#601feb]":o?"text-gray-900":"text-gray-500"}`}"> ${i.label} </span>
626
+ </span>
627
+ </div>
628
+ </li>`})}
629
+ </ol>
630
+ </div>
631
+
632
+ <!-- Products list with order items -->
633
+ <div class="mb-2 w-full">
634
+ ${r.length===0&&!this.orderDetails?.total?.amount&&this.streaming?h`
635
+ <!-- Loading shimmer for products -->
636
+ <div class="w-full space-y-4">
637
+ <div class="flex items-center gap-2">
638
+ <div class="h-12 w-12 animate-pulse rounded-lg bg-gray-200"></div>
639
+ <div class="flex-1 space-y-2">
640
+ <div class="h-4 w-32 animate-pulse rounded bg-gray-200"></div>
641
+ <div class="h-4 w-24 animate-pulse rounded bg-gray-200"></div>
642
+ </div>
643
+ </div>
644
+ <div class="flex items-center justify-between">
645
+ <div class="h-4 w-12 animate-pulse rounded bg-gray-200"></div>
646
+ <div class="h-4 w-10 animate-pulse rounded bg-gray-200"></div>
647
+ </div>
648
+ </div>
649
+ `:h`
650
+ <div class="divide-y divide-gray-100">
651
+ ${this.streaming&&!r.length?h`
652
+ <!-- Loading shimmer for individual products -->
653
+ ${[1,2].map(()=>h`
654
+ <div class="flex items-center gap-2 py-1.5">
655
+ <div class="h-12 w-12 animate-pulse rounded-lg bg-gray-200"></div>
656
+ <div class="min-w-0 flex-1">
657
+ <div class="h-4 w-32 animate-pulse rounded bg-gray-200"></div>
658
+ </div>
659
+ <div class="h-4 w-24 animate-pulse rounded bg-gray-200"></div>
660
+ </div>
661
+ `)}
662
+ `:r?.map(i=>{let s=i?.image_url;return h`
663
+ <div class="flex items-center gap-2 py-1.5">
664
+ <mw-product-thumbnail class="block h-12 w-12" src="${$e(s)}"></mw-product-thumbnail>
665
+
666
+ <div class="min-w-0 flex-1">
667
+ ${!i?.name&&this.streaming?h`<div class="h-4 w-32 animate-pulse rounded bg-gray-200"></div>`:h`<h3 class="truncate text-sm font-medium">${i?.name}</h3>`}
668
+ </div>
669
+ ${!i?.price&&this.streaming?h`<div class="h-4 w-24 animate-pulse rounded bg-gray-200"></div>`:h`<span class="text-sm text-gray-500">${i?.quantity&&Number(i.quantity)>1?"x":""} ${i?.price}</span>`}
670
+ </div>
671
+ `})}
672
+ </div>
673
+ <!-- Order total -->
674
+ <div class="mt-1 border-t border-gray-200 pt-1">
675
+ <div class="flex justify-between font-medium">
676
+ <span>${this.orderDetails?.total?.label}</span>
677
+ <span>${this.orderDetails?.total?.amount}</span>
678
+ </div>
679
+ </div>
680
+ `}
681
+ </div>
682
+
683
+ <!-- Shipping and payment information -->
684
+ <div class="mb-2 flex w-full flex-col gap-2 overflow-hidden">
685
+ ${this.streaming&&!this.orderDetails?h`
686
+ <!-- Loading shimmer template -->
687
+ ${[1,2].map(()=>h`
688
+ <div>
689
+ <div class="mb-2 h-5 w-32 animate-pulse rounded bg-gray-200"></div>
690
+ <div class="space-y-2 overflow-hidden">
691
+ <div class="h-4 w-40 animate-pulse rounded bg-gray-200"></div>
692
+ <div class="h-4 w-36 animate-pulse rounded bg-gray-200"></div>
693
+ </div>
694
+ </div>
695
+ `)}
696
+ `:h`
697
+ <!-- Shipping Section -->
698
+ <div>
699
+ ${this.streaming&&!this.orderDetails?.shipping?h`
700
+ <div>
701
+ <div class="mb-2 h-5 w-32 animate-pulse rounded bg-gray-200"></div>
702
+ <div class="space-y-2 overflow-hidden">
703
+ <div class="h-4 w-40 animate-pulse rounded bg-gray-200"></div>
704
+ <div class="h-4 w-36 animate-pulse rounded bg-gray-200"></div>
705
+ </div>
706
+ </div>
707
+ `:this.orderDetails?.shipping?.method||this.orderDetails?.customer?.name?h`
708
+ <h3 class="mb-1 text-sm font-medium">${this.orderDetails?.shipping?.label}</h3>
709
+ <div class="space-y-1">
710
+ ${this.orderDetails.customer?.name?h`<p class="text-xs text-gray-600">${this.orderDetails.customer.name}</p>`:""}
711
+ ${this.orderDetails.shipping?.method?h`<p class="text-xs text-gray-600">${this.orderDetails.shipping.method}</p>`:""}
712
+ </div>
713
+ `:""}
714
+ </div>
715
+
716
+ <!-- Payment Section -->
717
+ <div>
718
+ ${this.streaming&&!this.orderDetails?.payment?h`
719
+ <div>
720
+ <div class="mb-2 h-5 w-32 animate-pulse rounded bg-gray-200"></div>
721
+ <div class="space-y-2 overflow-hidden">
722
+ <div class="h-4 w-40 animate-pulse rounded bg-gray-200"></div>
723
+ <div class="h-4 w-36 animate-pulse rounded bg-gray-200"></div>
724
+ </div>
725
+ </div>
726
+ `:this.orderDetails?.payment?h`
727
+ <h3 class="mb-1 text-sm font-medium">${this.orderDetails.payment.label}</h3>
728
+ ${this.orderDetails.payment?.method?.value?h`
729
+ <p class="text-xs text-gray-600">
730
+ <span class="font-medium">${this.orderDetails.payment.method.label}:</span>
731
+ ${this.orderDetails.payment.method.value}
732
+ </p>
733
+ `:""}
734
+ ${this.orderDetails.payment.status?.value?h`
735
+ <p class="text-xs text-gray-600">
736
+ <span class="font-medium">${this.orderDetails.payment.status.label}:</span>
737
+ <span>${this.orderDetails.payment.status.value}</span>
738
+ </p>
739
+ `:""}
740
+ `:""}
741
+ </div>
742
+ `}
743
+ </div>
744
+
745
+ <!-- Action buttons section -->
746
+ <div class="flex w-full flex-col gap-2 overflow-hidden">
747
+ ${this.streaming&&!n[0]?.track_order?.label&&!us(n[0]?.track_order?.tracking_url||"")?h`
748
+ <!-- Loading shimmer for buttons -->
749
+ <div class="h-10 w-full min-w-[250px] animate-pulse overflow-hidden rounded-xl bg-gray-200"></div>
750
+ `:we(n,(i,s)=>`action-${s}`,i=>{if(i?.track_order?.label)return h`
751
+ ${us(i.track_order?.tracking_url||"")?h` <a
752
+ target="${this.linksNewTab?"_blank":"_self"}"
753
+ href="${i.track_order?.tracking_url}"
754
+ class="mt-1 w-full rounded-xl bg-[#601feb] px-4 py-2 text-center text-sm font-medium text-white hover:opacity-90"
755
+ >${i.track_order.label}</a
756
+ >`:null}
757
+ `})}
758
+ </div>
759
+ </div>
760
+ `}};y(Wn,"properties",{orderDetails:{type:Object,attribute:"order-details"},streaming:{type:Boolean},linksNewTab:{type:Boolean,attribute:"links-new-tab"}});customElements.get("mw-product-order-status-card")||customElements.define("mw-product-order-status-card",Wn);var Er,se,be,_r,$s,Zn=class{constructor(e,r){d(this,_r);d(this,Er);d(this,se);d(this,be);if(!e)throw new Error("host is required");if(!r)throw new Error("config is required");m(this,Er,e),a(this,Er).addController(this),m(this,se,r)}connect(e){m(this,se,e),m(this,be,g(this,_r,$s).call(this))}hostConnected(){setTimeout(()=>{m(this,be,g(this,_r,$s).call(this))},0)}hostDisconnected(){a(this,be)?.close(1e3,"lit_host_disconnected"),m(this,be,void 0)}send(e){a(this,be)?.send(e)}close(e,r){a(this,be)?.close(e,r)}get isConnected(){return a(this,be)?.readyState===WebSocket.OPEN}get isConnecting(){return a(this,be)?.readyState===WebSocket.CONNECTING}};Er=new WeakMap,se=new WeakMap,be=new WeakMap,_r=new WeakSet,$s=function(){let e=new WebSocket(a(this,se).url());return a(this,se).onClose&&(e.onclose=a(this,se).onClose),a(this,se).onOpen&&(e.onopen=a(this,se).onOpen),a(this,se).onError&&(e.onerror=a(this,se).onError),a(this,se).onMessage&&(e.onmessage=a(this,se).onMessage),e};var ll=Array.isArray;var Ss=t=>!!(t&&t.constructor&&t.call&&t.apply);var ul=t=>!(!t||!t.then||!Ss(t.then));function*cl(t,e,r=i=>i,n=1){let i=Ss(r)?r:()=>r,s=e?t:0,o=e??t;for(let u=s;u<=o&&(yield i(u),!(u+n>o));u+=n);}var _s=async(t,e)=>{let r=t?.times??3,n=t?.delay,i=t?.backoff??null;for(let s of cl(1,r)){let[o,u]=await As(e)(l=>{throw{_exited:l}});if(!o)return u;if(o._exited)throw o._exited;if(s===r)throw o;n&&await Es(n),i&&await Es(i(s))}},Es=t=>new Promise(e=>setTimeout(e,t)),As=t=>(...e)=>{try{let r=t(...e);return ul(r)?r.then(n=>[void 0,n]).catch(n=>[n,void 0]):[void 0,r]}catch(r){return[r,void 0]}};var pl="664df22d-d461-42d6-801e-f70247e2cd7c",B,K,te,Dt,Rt,me,z,Ee,fl,hl,dl,ml,Gn=class{constructor(e,r){d(this,z);d(this,B);d(this,K);d(this,te);y(this,"isStreaming",!1);y(this,"typingIndicator");y(this,"ranOutOfCredits",!1);y(this,"messages",[]);y(this,"conversationId","");d(this,Dt,0);d(this,Rt);y(this,"isLiveMode",!1);d(this,me,[]);m(this,B,e),m(this,K,r),m(this,te,this.initWS()),e.addController(this)}get hasQueuedMessages(){return a(this,me).length>0}async enqueueMessage(e,{expectStreaming:r=!1}={}){if(a(this,me).length>0){let n=a(this,me)[a(this,me).length-1];if(e.type==="USER_INPUT"&&n.message.type==="USER_INPUT"&&e.value===n.message.value)return!0}return a(this,te).isConnected?g(this,z,Ee).call(this,e,{expectStreaming:r}):(a(this,me).push({message:e,options:{expectStreaming:r}}),a(this,B).requestUpdate(),!a(this,te).isConnecting&&!a(this,te).isConnected&&this.retry(),await _s({times:5,delay:2e3},async()=>{if(a(this,te).isConnected){let n=[...a(this,me)];m(this,me,[]),a(this,B).requestUpdate();let i=!1;for(let{message:s,options:o}of n){let u=g(this,z,Ee).call(this,s,o);s===e&&(i=u)}return i}else throw new Error("WebSocket not connected yet")}).catch(()=>(console.warn("Failed to send message after retries",e),m(this,me,[]),a(this,B).requestUpdate(),!1)))}sendUserInput(e,{xUserData:r,xCustomInstructions:n,role:i="user",expectStreaming:s=!1}={}){return g(this,z,Ee).call(this,{type:"USER_INPUT",value:e,role:i,xUserData:r,xCustomInstructions:n},{expectStreaming:s})}async enqueueUserInput(e,{xUserData:r,xCustomInstructions:n,role:i="user",expectStreaming:s=!1}={}){return this.enqueueMessage({type:"USER_INPUT",value:e,role:i,xUserData:r,xCustomInstructions:n},{expectStreaming:s})}sendUserCancel(){return g(this,z,Ee).call(this,{type:"USER_CANCEL"})}sendUserTypingStart(){return g(this,z,Ee).call(this,{type:"USER_TYPING_START"})}sendUserTypingStop(){return g(this,z,Ee).call(this,{type:"USER_TYPING_STOP"})}sendUserMeta(e){return g(this,z,Ee).call(this,{type:"USER_META",metadata:e})}reloadConfig(){g(this,z,Ee).call(this,{type:"RELOAD_CONFIG"})}close(){a(this,te).close(1e3,"closed by user")}retry(){clearTimeout(a(this,Rt)),m(this,Rt,setTimeout(()=>{a(this,K).onReconnect?.(),m(this,te,this.initWS())},1e3*a(this,Dt))),io(this,Dt)._++}initWS(){return new Zn(a(this,B),{url:()=>a(this,K).url(this.conversationId,{}),onOpen:e=>g(this,z,fl).call(this,e),onMessage:e=>g(this,z,hl).call(this,JSON.parse(e.data)),onError:e=>g(this,z,dl).call(this,e),onClose:e=>g(this,z,ml).call(this,e)})}hostConnected(){this.conversationId=a(this,K).restoreConversationState?.()?.conversationId||"",this.messages=a(this,K).restoreConversationState?.()?.messages||[]}reset(){g(this,z,Ee).call(this,{type:"NEW_CHAT"}),a(this,K).onReset?.(),this.isStreaming=!1,this.typingIndicator=void 0,this.ranOutOfCredits=!1,this.messages=[],this.conversationId="",this.isLiveMode=!1,m(this,me,[]),a(this,B).requestUpdate()}hostDisconnected(){clearTimeout(a(this,Rt))}reconnectSocket(){a(this,te).close(1e3,"destroy"),m(this,te,this.initWS())}get lastMsg(){if(this.messages.length>0)return this.messages[this.messages.length-1]}};B=new WeakMap,K=new WeakMap,te=new WeakMap,Dt=new WeakMap,Rt=new WeakMap,me=new WeakMap,z=new WeakSet,Ee=function(e,{expectStreaming:r=!1}={}){return a(this,te).isConnecting?(console.warn("WebSocket is connecting, message not sent",e),!1):a(this,te).isConnected?(r&&!this.isLiveMode&&(this.isStreaming=!0,a(this,B).requestUpdate()),a(this,te).send(JSON.stringify(e)),!0):(console.warn("WebSocket is not connected, message not sent",e),this.retry(),!1)},fl=function(e){m(this,Dt,0)},hl=function(e){switch(e.type){case"NEW_MESSAGE":{this.messages=[...this.messages,{...e.message,streaming:!0}].filter((r,n,i)=>n===i.findIndex(s=>s.id===r.id)),this.typingIndicator=void 0,a(this,B).requestUpdate(),a(this,K).onNewMessage?.(e.message);break}case"APPEND_MESSAGE":{let r=this.messages.find(n=>n.id===e.message.id);if(r){switch(e.message.content_type){case"text":{let{part:n,delta:i,position:s}=e.message;r.content=r.content.slice(0,s)+i,r.parts||=[],r.parts[n]={text:r.parts[n]&&"text"in r.parts[n]?(r.parts[n].text||"").slice(0,s)+i:i};break}case"html":{let{part:n,delta:i,position:s}=e.message;r.parts||=[],r.parts[n]={html:r.parts[n]&&"html"in r.parts[n]?(r.parts[n].html||"").slice(0,s)+i:i};break}case"data":{let{part:n}=e.message;r.parts||=[],r.parts[n]={tag:e.message.tag,data:r.parts[n]&&"data"in r.parts[n]?Object.assign(r.parts[n].data||{},e.message.data):e.message.data};break}}e.metadata&&(r.metadata=e.metadata),a(this,K).onMessageAppend?.(e),a(this,B).requestUpdate()}else throw new Error(`Message with id ${e.message.id} not found`);break}case"MESSAGE_DONE":{let r=this.messages.find(n=>n.id===e.message.id);if(r)Object.assign(r,e.message),r.streaming=!1;else throw new Error(`Message with id ${e.message.id} not found`);this.isStreaming=!1,a(this,B).requestUpdate(),a(this,K).onMessageDone?.(e,r),a(this,K).persistConversationState?.(this.conversationId,this.messages);break}case"MESSAGE_CANCEL":{this.isStreaming=!1,this.typingIndicator=void 0,a(this,B).requestUpdate();break}case"ERROR":{a(this,K).onMessageError?.(e);break}case"CONNECTED":{this.conversationId=e.conversationId,this.messages=e.messages,a(this,K).onConnect?.(e.conversationId),a(this,K).persistConversationState?.(e.conversationId,e.messages),this.isLiveMode=e.metadata?.isLiveMode,a(this,B).requestUpdate();break}case"TYPING_START":{e.role==="assistant"&&(this.isStreaming=!0),this.typingIndicator={role:e.role,metadata:e.metadata},a(this,B).requestUpdate();break}case"TYPING_STOP":{this.typingIndicator=void 0,a(this,B).requestUpdate();break}case"RAN_OUT_OF_CREDITS":{this.messages.some(r=>r.id===pl)||this.messages.push({id:pl,role:"assistant",content:"Sorry, I've run out of credits. Please contact the shop directly.",timestamp:Date.now()}),this.ranOutOfCredits=!0,a(this,B).requestUpdate();break}case"RECONNECT":{this.reconnectSocket(),a(this,B).requestUpdate();break}default:console.warn(`Unknown message type: ${JSON.stringify(e)}`)}},dl=function(e){console.error("onError",e),a(this,K).onError?.(e)},ml=function(e){a(this,B).isConnected&&!a(this,te).isConnected&&e.reason==="reconnect"&&this.retry(),this.isStreaming=!1,this.typingIndicator=void 0,a(this,B).requestUpdate(),a(this,K).onClose?.()};var Ar=class extends Ct{constructor(e){if(super(e),this.it=E,e.type!==yn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===E||e==null)return this._t=void 0,this.it=e;if(e===ye)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let r=[e];return r.raw=r,this._t={_$litType$:this.constructor.resultType,strings:r,values:[]}}};Ar.directiveName="unsafeHTML",Ar.resultType=1;var gl=vn(Ar);var Ms;function Is(t){return{lang:t?.lang??Ms?.lang,message:t?.message,abortEarly:t?.abortEarly??Ms?.abortEarly,abortPipeEarly:t?.abortPipeEarly??Ms?.abortPipeEarly}}var ip;function sp(t){return ip?.get(t)}var op;function ap(t){return op?.get(t)}var lp;function up(t,e){return lp?.get(t)?.get(e)}function vl(t){let e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&Object.getPrototypeOf(t)?.constructor?.name)??"null":e}function le(t,e,r,n,i){let s=i&&"input"in i?i.input:r.value,o=i?.expected??t.expects??null,u=i?.received??vl(s),l={kind:t.kind,type:t.type,input:s,expected:o,received:u,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${u}`,requirement:t.requirement,path:i?.path,issues:i?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},c=t.kind==="schema",f=i?.message??t.message??up(t.reference,l.lang)??(c?ap(l.lang):null)??n.message??sp(l.lang);f!==void 0&&(l.message=typeof f=="function"?f(l):f),c&&(r.typed=!1),r.issues?r.issues.push(l):r.issues=[l]}function ue(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},Is())}}}function cp(t,e){return Object.hasOwn(t,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function wl(t,e){let r=[...new Set(t)];return r.length>1?`(${r.join(` ${e} `)})`:r[0]??"never"}var pp=class extends Error{constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function Ls(t,e){return{kind:"validation",type:"max_length",reference:Ls,async:!1,expects:`<=${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&r.value.length>this.requirement&&le(this,"length",r,n,{received:`${r.value.length}`}),r}}}function Ts(t,e){return{kind:"validation",type:"min_length",reference:Ts,async:!1,expects:`>=${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&r.value.length<this.requirement&&le(this,"length",r,n,{received:`${r.value.length}`}),r}}}function fp(t,e,r){return typeof t.fallback=="function"?t.fallback(e,r):t.fallback}function bl(t,e,r){return typeof t.default=="function"?t.default(e,r):t.default}function Os(){return{kind:"schema",type:"any",reference:Os,expects:"any",async:!1,get"~standard"(){return ue(this)},"~run"(t){return t.typed=!0,t}}}function Pt(t,e){return{kind:"schema",type:"array",reference:Pt,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return ue(this)},"~run"(r,n){let i=r.value;if(Array.isArray(i)){r.typed=!0,r.value=[];for(let s=0;s<i.length;s++){let o=i[s],u=this.item["~run"]({value:o},n);if(u.issues){let l={type:"array",origin:"value",input:i,key:s,value:o};for(let c of u.issues)c.path?c.path.unshift(l):c.path=[l],r.issues?.push(c);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else le(this,"type",r,n);return r}}}function js(t){return{kind:"schema",type:"boolean",reference:js,expects:"boolean",async:!1,message:t,get"~standard"(){return ue(this)},"~run"(e,r){return typeof e.value=="boolean"?e.typed=!0:le(this,"type",e,r),e}}}function Ds(t){return{kind:"schema",type:"null",reference:Ds,expects:"null",async:!1,message:t,get"~standard"(){return ue(this)},"~run"(e,r){return e.value===null?e.typed=!0:le(this,"type",e,r),e}}}function Jn(t){return{kind:"schema",type:"number",reference:Jn,expects:"number",async:!1,message:t,get"~standard"(){return ue(this)},"~run"(e,r){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:le(this,"type",e,r),e}}}function Oe(t,e){return{kind:"schema",type:"object",reference:Oe,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return ue(this)},"~run"(r,n){let i=r.value;if(i&&typeof i=="object"){r.typed=!0,r.value={};for(let s in this.entries){let o=this.entries[s];if(s in i||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let u=s in i?i[s]:bl(o),l=o["~run"]({value:u},n);if(l.issues){let c={type:"object",origin:"value",input:i,key:s,value:u};for(let f of l.issues)f.path?f.path.unshift(c):f.path=[c],r.issues?.push(f);if(r.issues||(r.issues=l.issues),n.abortEarly){r.typed=!1;break}}l.typed||(r.typed=!1),r.value[s]=l.value}else if(o.fallback!==void 0)r.value[s]=fp(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(le(this,"key",r,n,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:i,key:s,value:i[s]}]}),n.abortEarly))break}}else le(this,"type",r,n);return r}}}function Ut(t,e){return{kind:"schema",type:"optional",reference:Ut,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return ue(this)},"~run"(r,n){return r.value===void 0&&(this.default!==void 0&&(r.value=bl(this,r,n)),r.value===void 0)?(r.typed=!0,r):this.wrapped["~run"](r,n)}}}function Rs(t,e){return{kind:"schema",type:"picklist",reference:Rs,expects:wl(t.map(vl),"|"),async:!1,options:t,message:e,get"~standard"(){return ue(this)},"~run"(r,n){return this.options.includes(r.value)?r.typed=!0:le(this,"type",r,n),r}}}function Xn(t,e,r){return{kind:"schema",type:"record",reference:Xn,expects:"Object",async:!1,key:t,value:e,message:r,get"~standard"(){return ue(this)},"~run"(n,i){let s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(let o in s)if(cp(s,o)){let u=s[o],l=this.key["~run"]({value:o},i);if(l.issues){let f={type:"object",origin:"key",input:s,key:o,value:u};for(let p of l.issues)p.path=[f],n.issues?.push(p);if(n.issues||(n.issues=l.issues),i.abortEarly){n.typed=!1;break}}let c=this.value["~run"]({value:u},i);if(c.issues){let f={type:"object",origin:"value",input:s,key:o,value:u};for(let p of c.issues)p.path?p.path.unshift(f):p.path=[f],n.issues?.push(p);if(n.issues||(n.issues=c.issues),i.abortEarly){n.typed=!1;break}}(!l.typed||!c.typed)&&(n.typed=!1),l.typed&&(n.value[l.value]=c.value)}}else le(this,"type",n,i);return n}}}function W(t){return{kind:"schema",type:"string",reference:W,expects:"string",async:!1,message:t,get"~standard"(){return ue(this)},"~run"(e,r){return typeof e.value=="string"?e.typed=!0:le(this,"type",e,r),e}}}function yl(t){let e;if(t)for(let r of t)e?e.push(...r.issues):e=r.issues;return e}function Vt(t,e){return{kind:"schema",type:"union",reference:Vt,expects:wl(t.map(r=>r.expects),"|"),async:!1,options:t,message:e,get"~standard"(){return ue(this)},"~run"(r,n){let i,s,o;for(let u of this.options){let l=u["~run"]({value:r.value},n);if(l.typed)if(l.issues)s?s.push(l):s=[l];else{i=l;break}else o?o.push(l):o=[l]}if(i)return i;if(s){if(s.length===1)return s[0];le(this,"type",r,n,{issues:yl(s)}),r.typed=!0}else{if(o?.length===1)return o[0];le(this,"type",r,n,{issues:yl(o)})}return r}}}function xl(t,e,r){let n=t["~run"]({value:e},Is(r));if(n.issues)throw new pp(n.issues);return n.value}function kl(t,e){let r={};for(let n in t.entries)r[n]=!e||e.includes(n)?Ut(t.entries[n]):t.entries[n];return{...t,entries:r,get"~standard"(){return ue(this)}}}function Cl(...t){return{...t[0],pipe:t,get"~standard"(){return ue(this)},"~run"(e,r){for(let n of t)if(n.kind!=="metadata"){if(e.issues&&(n.kind==="schema"||n.kind==="transformation")){e.typed=!1;break}(!e.issues||!r.abortEarly&&!r.abortPipeEarly)&&(e=n["~run"](e,r))}return e}}}function Mr(t,e,r){let n=t["~run"]({value:e},Is(r));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}var $l=kl(Oe({name:W(),description:W(),price:W(),image_url:Vt([W(),Pt(W())]),category:W(),url:W()}));function Sl(t,e,r,{imagesByProductUrl:n,linksNewTab:i=!0,searchParams:s,messageIsStreaming:o=!1}){if(!t)return h``;let u=e>0&&r[e-1]&&"data"in r[e-1],l=e<r.length-1||!o;if("text"in t)return h`<p>${t.text}</p>`;if("html"in t)return h`${gl(t.html)}`;if("data"in t)switch(t.tag){case"product-card":case"product-card-v1":case"product-card-horizontal":{let c=Mr($l,t.data);if(c.success){let f={...c.output,images:[]};return f.images=jt(f.image_url),h`
576
761
  ${u?h`<div class="my-3 w-full border-t border-gray-200/50"></div>`:null}
577
762
  <mw-product-card-horizontal
578
763
  product="${JSON.stringify(f)}"
@@ -580,7 +765,7 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
580
765
  ?links-new-tab="${i}"
581
766
  .searchParams="${s}"
582
767
  .imagesByProductUrl="${n}"></mw-product-card-horizontal>
583
- `}console.warn(c.issues);break}case"order-status-card-v1":return h`<mw-product-order-status-card order-details="${JSON.stringify(t.data)}" ?streaming="${!l}" ?links-new-tab="${i}"></mw-product-order-status-card> `}return console.warn("could not render part:",t),h`<p><i>data type not supported</i></p>`}var Ir,Nt,qe,ut,Yn,Sl,Kn=class{constructor(e,r,{timeoutMs:n=2e3}={}){d(this,Yn);d(this,Ir);d(this,Nt);d(this,qe);d(this,ut,!1);y(this,"timeoutMs");m(this,Ir,e),m(this,Nt,r),this.timeoutMs=n,e.addController(this)}get isTyping(){return a(this,ut)}hostDisconnected(){clearTimeout(a(this,qe)),m(this,qe,void 0)}onInput(e){if(a(this,Ir).isConnected){if(!e.trim()){this.typingStopped();return}clearTimeout(a(this,qe)),m(this,qe,setTimeout(()=>this.typingStopped(),this.timeoutMs)),a(this,ut)||g(this,Yn,Sl).call(this)}}typingStopped(){clearTimeout(a(this,qe)),m(this,ut,!1),a(this,Nt).typingStopped()}};Ir=new WeakMap,Nt=new WeakMap,qe=new WeakMap,ut=new WeakMap,Yn=new WeakSet,Sl=function(){m(this,ut,!0),a(this,Nt).typingStarted()};function El(t,e="en-US"){let r=new Intl.DateTimeFormat(e,{hour:"numeric",minute:"numeric"}).format(t);return`${t.toLocaleDateString(e,{year:"numeric",month:"short",day:"numeric"})}, ${r}`}var _l=()=>{if(window.Shopify)try{return{customerId:hp()}}catch{return null}return null},hp=()=>{try{let t=[()=>window.ShopifyAnalytics?.meta?.page?.customerId,()=>window.meta?.page?.customerId,()=>window._st?.cid,()=>window.ShopifyAnalytics?.lib?.user()?.traits()?.uniqToken];for(let e of t)try{let r=e();if(/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i.test(r))continue;if(r)return r}catch{}}catch{return null}return null},Al=async()=>{try{return(await(await fetch(window.Shopify.routes.root+"cart.js")).json()).items.map(n=>({id:n.id,name:n.title,quantity:n.quantity,price:n.price,variantId:n.variant_id,sku:n.sku,url:n.url,description:n.product_description,image:n.featured_image?.url}))}catch{return[]}};var Ml=()=>{if(window.ShopRenter)try{let t=mp();return{customerEmail:t?.customerEmail,customerId:t?.customerId,customerName:t?.customerName}}catch{return null}return null},mp=()=>{try{if(window.ShopRenter){let t=window.ShopRenter.customer;return{customerEmail:t?.email,customerId:t?.userId,customerName:[t?.name?.firstName,t?.name?.lastName].filter(Boolean).join(" ")}}return{customerEmail:null,customerId:null,customerName:null}}catch{return{customerEmail:null,customerId:null,customerName:null}}},Il=async()=>{try{let t=window.ShopRenter.shop?.domain;if(!t)return[];let e=ka(t,"https")+"/cart.json";return(await(await fetch(e)).json()).items.map(s=>({id:s.id,name:s.name,quantity:s.quantity,price:s.price,sku:s.sku,image:s.image,url:s.href}))}catch{return[]}};var Ll=()=>{if(window.UNAS)try{let t=window.UNAS.customer;return{customerEmail:t?.email,customerId:t?.id}}catch(t){return console.error("Error fetching customer information:",t),null}return null},Tl=async()=>new Promise((t,e)=>{try{window.UNAS.getCart(r=>{let i=r.items.map(s=>({id:s.id,name:s.name,quantity:s.quantity,price:s.price,sku:s.sku}));t(i)})}catch(r){console.error("Error fetching cart information:",r),e(r)}});var Ol=Jn(W(),Vt([W(),Gn(),js(),Ds()])),jl=kl(W(),Ts(1),Ls(5e3)),Dl=()=>{try{return window.UNAS?Ll():window.Shopify?_l():window.ShopRenter?Ml():null}catch{return null}},Rl=async()=>{try{return window.UNAS?await Tl():window.Shopify?await Al():window.ShopRenter?await Il():[]}catch{return[]}},Ft={schema:Oe({conversationId:Ut(W()),messages:Ut(Pt(Oe({id:W(),timestamp:Gn(),role:Rs(["user","assistant","support"]),content:W(),parts:Ut(Pt(Vt([Oe({text:W()}),Oe({html:W()}),Oe({tag:W(),data:Jn(W(),Os())})])))})))}),getStorageKey(t){if(!t)throw new Error("widgetId is not set");return`_molin_${t}`},persist(t,e,r){let n=this.getStorageKey(t);localStorage.setItem(n,JSON.stringify({conversationId:e,messages:r}))},restore(t){try{let e=this.getStorageKey(t),r=JSON.parse(localStorage.getItem(e)||"{}"),n=bl(this.schema,r);return{conversationId:n.conversationId||"",messages:n.messages||[]}}catch(e){return console.error("Failed to restore conversation state:",e),{conversationId:"",messages:[]}}},reset(t){let e=this.getStorageKey(t);localStorage.removeItem(e)}};var vp=!0,Ps="Invariant failed";function Pl(t,e){if(!t){if(vp)throw new Error(Ps);var r=typeof e=="function"?e():e,n=r?"".concat(Ps,": ").concat(r):Ps;throw new Error(n)}}var wp="\xB7 \xB7 \xB7",je,De,D,Vs,Or,ct,P,jr,Ul,Vl,Nl,Fl,Hl,ql,Bl,zl,Qn,Lr,ei=class ei extends _(S){constructor(){super();d(this,D);d(this,je);d(this,De);d(this,Or,new Kn(this,{typingStarted:()=>a(this,P).sendUserTypingStart(),typingStopped:()=>a(this,P).sendUserTypingStop()}));d(this,ct,!1);d(this,P,new Zn(this,{url:r=>{let n=new URL(this.config.wsApiUrl);return n.searchParams.set("widgetId",this.widgetId),n.searchParams.set("conversationId",r),n.searchParams.set("pageUrl",window.location.href),n},onReconnect:()=>{},onError:r=>{console.error("ws error",r)},onClose:()=>{},onNewMessage:r=>{m(this,ct,!1),r.role==="user"&&a(this,D,Qn)?.scrollTo(0,a(this,D,Qn).scrollHeight),r.role==="assistant"&&this.callbacks.onNewMessageStartedStreaming?.({widgetId:this.widgetId,message:r,conversationId:this.conversationId})},onMessageAppend:r=>{let n=a(this,D,Qn);if(!n)return;let i=a(this,P).lastMsg;!i||i.role!=="assistant"||requestAnimationFrame(()=>{let s=n.querySelector(`[data-id="${i.id}"]`);if(!s)return;let o=s.offsetHeight,u=n.getClientRects()[0].height-70;o>u&&!a(this,ct)&&(n.scrollTop=s.offsetTop-80)})},onMessageDone:(r,n)=>{m(this,ct,!1),n.role==="assistant"&&this.callbacks.onMessageEndedStreaming?.({widgetId:this.widgetId,text:n.content??"",message:n,usage_TOKENS_COMPLETION:r.message.usage.TOKENS_COMPLETION,conversationId:this.conversationId})},onMessageError:r=>{console.error("ws message error",r),r.message&&this.callbacks.onError?.({widgetId:this.widgetId,error:"WS: "+r.message})},onReset:()=>{Ft.reset(this.widgetId)},onConnect:r=>{let n=Dl();a(this,P).sendUserMeta({xUserData:a(this,je),xCustomInstructions:a(this,De),customerInformation:n,language:window.navigator.language,cart:[]}),Rl().then(i=>{i?.length>0&&a(this,P).sendUserMeta({xUserData:a(this,je),xCustomInstructions:a(this,De),customerInformation:n,cart:i,language:window.navigator.language})}).catch(i=>{console.error(i)})},persistConversationState:(r,n)=>{Ft.persist(this.widgetId,r,n)},restoreConversationState:()=>Ft.restore(this.widgetId)}));d(this,jr,"single");this.widgetId="",this.config={},this.callbacks={},this.showClose=!1,this.xUserData={},this.xCustomInstructions=""}get conversationId(){return a(this,P).conversationId}get messages(){return a(this,P).messages}firstUpdated(){g(this,D,Vs).call(this)}updated(){g(this,D,Vs).call(this)}get isLiveChatMode(){return a(this,P).isLiveMode}render(){Pl(this.config,"config is required");let r=dl(this.messages,n=>{try{let i=new Date(n.timestamp),s=Math.floor(i.getUTCMinutes()/5)*5;return i.setUTCMinutes(s,0,0),i.valueOf().toString()}catch(i){console.error(i)}});return h`
768
+ `}console.warn(c.issues);break}case"order-status-card-v1":return h`<mw-product-order-status-card order-details="${JSON.stringify(t.data)}" ?streaming="${!l}" ?links-new-tab="${i}"></mw-product-order-status-card> `}return console.warn("could not render part:",t),h`<p><i>data type not supported</i></p>`}var Ir,Nt,qe,ut,Qn,El,Yn=class{constructor(e,r,{timeoutMs:n=2e3}={}){d(this,Qn);d(this,Ir);d(this,Nt);d(this,qe);d(this,ut,!1);y(this,"timeoutMs");m(this,Ir,e),m(this,Nt,r),this.timeoutMs=n,e.addController(this)}get isTyping(){return a(this,ut)}hostDisconnected(){clearTimeout(a(this,qe)),m(this,qe,void 0)}onInput(e){if(a(this,Ir).isConnected){if(!e.trim()){this.typingStopped();return}clearTimeout(a(this,qe)),m(this,qe,setTimeout(()=>this.typingStopped(),this.timeoutMs)),a(this,ut)||g(this,Qn,El).call(this)}}typingStopped(){clearTimeout(a(this,qe)),m(this,ut,!1),a(this,Nt).typingStopped()}};Ir=new WeakMap,Nt=new WeakMap,qe=new WeakMap,ut=new WeakMap,Qn=new WeakSet,El=function(){m(this,ut,!0),a(this,Nt).typingStarted()};function _l(t,e="en-US"){let r=new Intl.DateTimeFormat(e,{hour:"numeric",minute:"numeric"}).format(t);return`${t.toLocaleDateString(e,{year:"numeric",month:"short",day:"numeric"})}, ${r}`}var Al=()=>{if(window.Shopify)try{return{customerId:hp()}}catch{return null}return null},hp=()=>{try{let t=[()=>window.ShopifyAnalytics?.meta?.page?.customerId,()=>window.meta?.page?.customerId,()=>window._st?.cid,()=>window.ShopifyAnalytics?.lib?.user()?.traits()?.uniqToken];for(let e of t)try{let r=e();if(/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i.test(r))continue;if(r)return r}catch{}}catch{return null}return null},Ml=async()=>{try{return(await(await fetch(window.Shopify.routes.root+"cart.js")).json()).items.map(n=>({id:n.id,name:n.title,quantity:n.quantity,price:n.price,variantId:n.variant_id,sku:n.sku,url:n.url,description:n.product_description,image:n.featured_image?.url}))}catch{return[]}};var Il=()=>{if(window.ShopRenter)try{let t=mp();return{customerEmail:t?.customerEmail,customerId:t?.customerId,customerName:t?.customerName}}catch{return null}return null},mp=()=>{try{if(window.ShopRenter){let t=window.ShopRenter.customer;return{customerEmail:t?.email,customerId:t?.userId,customerName:[t?.name?.firstName,t?.name?.lastName].filter(Boolean).join(" ")}}return{customerEmail:null,customerId:null,customerName:null}}catch{return{customerEmail:null,customerId:null,customerName:null}}},Ll=async()=>{try{let t=window.ShopRenter.shop?.domain;if(!t)return[];let e=ka(t,"https")+"/cart.json";return(await(await fetch(e)).json()).items.map(s=>({id:s.id,name:s.name,quantity:s.quantity,price:s.price,sku:s.sku,image:s.image,url:s.href}))}catch{return[]}};var Tl=()=>{if(window.UNAS)try{let t=window.UNAS.customer;return{customerEmail:t?.email,customerId:t?.id}}catch(t){return console.error("Error fetching customer information:",t),null}return null},Ol=async()=>new Promise((t,e)=>{try{window.UNAS.getCart(r=>{let i=r.items.map(s=>({id:s.id,name:s.name,quantity:s.quantity,price:s.price,sku:s.sku}));t(i)})}catch(r){console.error("Error fetching cart information:",r),e(r)}});var jl=Xn(W(),Vt([W(),Jn(),js(),Ds()])),Dl=Cl(W(),Ts(1),Ls(5e3)),Rl=()=>{try{return window.UNAS?Tl():window.Shopify?Al():window.ShopRenter?Il():null}catch{return null}},Pl=async()=>{try{return window.UNAS?await Ol():window.Shopify?await Ml():window.ShopRenter?await Ll():[]}catch{return[]}},Ft={schema:Oe({conversationId:Ut(W()),messages:Ut(Pt(Oe({id:W(),timestamp:Jn(),role:Rs(["user","assistant","support"]),content:W(),parts:Ut(Pt(Vt([Oe({text:W()}),Oe({html:W()}),Oe({tag:W(),data:Xn(W(),Os())})])))})))}),getStorageKey(t){if(!t)throw new Error("widgetId is not set");return`_molin_${t}`},persist(t,e,r){let n=this.getStorageKey(t);localStorage.setItem(n,JSON.stringify({conversationId:e,messages:r}))},restore(t){try{let e=this.getStorageKey(t),r=JSON.parse(localStorage.getItem(e)||"{}"),n=xl(this.schema,r);return{conversationId:n.conversationId||"",messages:n.messages||[]}}catch(e){return console.error("Failed to restore conversation state:",e),{conversationId:"",messages:[]}}},reset(t){let e=this.getStorageKey(t);localStorage.removeItem(e)}};var vp=!0,Ps="Invariant failed";function Ul(t,e){if(!t){if(vp)throw new Error(Ps);var r=typeof e=="function"?e():e,n=r?"".concat(Ps,": ").concat(r):Ps;throw new Error(n)}}var wp="\xB7 \xB7 \xB7",je,De,D,Vs,Or,ct,P,jr,Vl,Nl,Fl,Hl,ql,Bl,zl,Wl,ei,Lr,ti=class ti extends _(S){constructor(){super();d(this,D);d(this,je);d(this,De);d(this,Or,new Yn(this,{typingStarted:()=>a(this,P).sendUserTypingStart(),typingStopped:()=>a(this,P).sendUserTypingStop()}));d(this,ct,!1);d(this,P,new Gn(this,{url:r=>{let n=new URL(this.config.wsApiUrl);return n.searchParams.set("widgetId",this.widgetId),n.searchParams.set("conversationId",r),n.searchParams.set("pageUrl",window.location.href),n},onReconnect:()=>{},onError:r=>{console.error("ws error",r)},onClose:()=>{},onNewMessage:r=>{m(this,ct,!1),r.role==="user"&&a(this,D,ei)?.scrollTo(0,a(this,D,ei).scrollHeight),r.role==="assistant"&&this.callbacks.onNewMessageStartedStreaming?.({widgetId:this.widgetId,message:r,conversationId:this.conversationId})},onMessageAppend:r=>{let n=a(this,D,ei);if(!n)return;let i=a(this,P).lastMsg;!i||i.role!=="assistant"||requestAnimationFrame(()=>{let s=n.querySelector(`[data-id="${i.id}"]`);if(!s)return;let o=s.offsetHeight,u=n.getClientRects()[0].height-70;o>u&&!a(this,ct)&&(n.scrollTop=s.offsetTop-80)})},onMessageDone:(r,n)=>{m(this,ct,!1),n.role==="assistant"&&this.callbacks.onMessageEndedStreaming?.({widgetId:this.widgetId,text:n.content??"",message:n,usage_TOKENS_COMPLETION:r.message.usage.TOKENS_COMPLETION,conversationId:this.conversationId})},onMessageError:r=>{console.error("ws message error",r),r.message&&this.callbacks.onError?.({widgetId:this.widgetId,error:"WS: "+r.message})},onReset:()=>{Ft.reset(this.widgetId)},onConnect:r=>{let n=Rl();a(this,P).sendUserMeta({xUserData:a(this,je),xCustomInstructions:a(this,De),customerInformation:n,language:window.navigator.language,cart:[]}),Pl().then(i=>{i?.length>0&&a(this,P).sendUserMeta({xUserData:a(this,je),xCustomInstructions:a(this,De),customerInformation:n,cart:i,language:window.navigator.language})}).catch(i=>{console.error(i)})},persistConversationState:(r,n)=>{Ft.persist(this.widgetId,r,n)},restoreConversationState:()=>Ft.restore(this.widgetId)}));d(this,jr,"single");this.widgetId="",this.config={},this.callbacks={},this.showClose=!1,this.xUserData={},this.xCustomInstructions=""}get conversationId(){return a(this,P).conversationId}get messages(){return a(this,P).messages}firstUpdated(){g(this,D,Vs).call(this)}updated(){g(this,D,Vs).call(this)}get isLiveChatMode(){return a(this,P).isLiveMode}render(){Ul(this.config,"config is required");let r=ol(this.messages,n=>{try{let i=new Date(n.timestamp),s=Math.floor(i.getUTCMinutes()/5)*5;return i.setUTCMinutes(s,0,0),i.valueOf().toString()}catch(i){console.error(i)}});return h`
584
769
  <div class="relative mx-auto h-full bg-[#FDFDFD] font-sans text-base before:absolute before:inset-0 before:bg-[#8d8d8d] before:opacity-10 sm:rounded-[36px] sm:p-1.5 sm:before:rounded-[36px]">
585
770
  <div
586
771
  class="relative flex h-full flex-col bg-white shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25),-116px_177px_59px_0px_rgba(0,0,0,0.00),-74px_113px_54px_0px_rgba(0,0,0,0.01),-42px_64px_46px_0px_rgba(0,0,0,0.03),-19px_28px_34px_0px_rgba(0,0,0,0.06)] sm:rounded-[30px]">
@@ -589,8 +774,8 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
589
774
  .content="${{logoUrl:this.config.logoUrl,title:this.config.title,color:this.config.color}}"
590
775
  ?show-new-chat="${!a(this,P).isLiveMode&&this.messages.length>0}"
591
776
  ?show-close="${this.showClose}"
592
- @mw:new-chat-click="${g(this,D,Bl)}"
593
- @mw:close-click="${g(this,D,zl)}">
777
+ @mw:new-chat-click="${g(this,D,zl)}"
778
+ @mw:close-click="${g(this,D,Wl)}">
594
779
  </mw-chat-header>
595
780
 
596
781
  <!-- used by the dashboard to inject content -->
@@ -599,7 +784,7 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
599
784
  </div>
600
785
 
601
786
  <!-- this structure of 2 divs is required for the browser native stick/scroll to bottom -->
602
- <div id="scrollable-content" class="mt-6 flex h-full flex-shrink flex-grow flex-col-reverse overflow-auto" @scroll="${g(this,D,Ul)}">
787
+ <div id="scrollable-content" class="mt-6 flex h-full flex-shrink flex-grow flex-col-reverse overflow-auto" @scroll="${g(this,D,Vl)}">
603
788
  ${this.config?.showStillLearningBanner?h`
604
789
  <div class="flex justify-center">
605
790
  <div class="mb-2 flex max-w-[70%] select-none items-center justify-center rounded-full bg-black px-3 py-2">
@@ -624,7 +809,7 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
624
809
  <!-- this is the 2nd (inner) div that will natively stick/scroll to bottom -->
625
810
  <div class="${this.messages.length>0?"pt-20":""}">
626
811
  ${we(Array.from(r),([n])=>n,([n,i])=>h`
627
- <div class="my-2 text-center text-xs text-gray-500">${El(new Date(Number(n)),window.navigator.language)}</div>
812
+ <div class="my-2 text-center text-xs text-gray-500">${_l(new Date(Number(n)),window.navigator.language)}</div>
628
813
  ${we(i??[],s=>s.id,(s,o)=>{let l=i[o+1]?.role===s.role,f=(o>0?i[o-1]:void 0)?.role===s.role,b=(i.length>0?i[i.length-1]:void 0)?.id===s.id;m(this,jr,b&&!f&&!l?"single-current":!f&&!l?"single":!f&&l?"first":b&&f&&!l?"last-current":f&&!l?"last":f&&l?"middle":"single");let k=a(this,P).isLiveMode&&s.role==="user"&&s.id===a(this,P).lastMsg?.id?"sent":"";return h`
629
814
  <div data-id="${s.id}" class="${l?"mb-[2px]":"mb-3"} mx-2 flex-row">
630
815
  <mw-chat-message
@@ -633,10 +818,10 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
633
818
  logo="${s.metadata?.avatar||this.config.logoUrl}"
634
819
  side="${s.role}"
635
820
  position=${a(this,jr)}
636
- @click="${g(this,D,Vl)}">
821
+ @click="${g(this,D,Nl)}">
637
822
  <div
638
823
  class="prose prose-h1:first:mt-0 prose-h2:first:mt-0 prose-h3:first:mt-0 prose-h4:first:mt-0 prose-h1:last:mb-0 prose-h2:last:mb-0 prose-h3:last:mb-0 prose-h4:last:mb-0 prose-h1:mt-5 prose-h2:mt-5 prose-h3:mt-5 prose-h4:mt-5 prose-h1:mb-2 prose-h2:mb-2 prose-h3:mb-2 prose-h4:mb-2 prose-h1:text-xl prose-h1:text-bold prose-h2:text-lg prose-h2:text-bold prose-h3:text-base prose-h3:text-bold prose-h4:text-sm prose-h4:text-bold break-words text-inherit">
639
- ${s.content===wp?h`<mw-loading class="-mx-2 block h-8 max-h-[24px] w-8 fill-[${this.config.color}]"></mw-loading>`:s.parts?we(s.parts,(A,I)=>I,(A,I)=>$l(A,I,s.parts??[],{imagesByProductUrl:s.metadata?.imagesByProductUrl,linksNewTab:this.config.linksNewTab??!0,searchParams:this.config.disableUtmInjection?void 0:new URLSearchParams({utm_source:"molin.ai",utm_medium:"chat",utm_campaign:"general"}),messageIsStreaming:s.streaming})):h`<p>${s.content}</p>`}
824
+ ${s.content===wp?h`<mw-loading class="-mx-2 block h-8 max-h-[24px] w-8 fill-[${this.config.color}]"></mw-loading>`:s.parts?we(s.parts,(A,I)=>I,(A,I)=>Sl(A,I,s.parts??[],{imagesByProductUrl:s.metadata?.imagesByProductUrl,linksNewTab:this.config.linksNewTab??!0,searchParams:this.config.disableUtmInjection?void 0:new URLSearchParams({utm_source:"molin.ai",utm_medium:"chat",utm_campaign:"general"}),messageIsStreaming:s.streaming})):h`<p>${s.content}</p>`}
640
825
  </div>
641
826
  </mw-chat-message>
642
827
  </div>
@@ -662,14 +847,14 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
662
847
  class="flex-grow"
663
848
  .examples="${this.messages.length>0?[]:this.config.examples}"
664
849
  color="${this.config.color}"
665
- @mw:example-click="${g(this,D,Nl)}"></mw-chat-background>
850
+ @mw:example-click="${g(this,D,Fl)}"></mw-chat-background>
666
851
  </div>
667
852
 
668
853
  <div class="m-1.5 flex-shrink-0 flex-grow-0 space-y-2 rounded-3xl bg-[#eeedf1] p-1.5">
669
854
  <mw-chat-input
670
- @mw:change="${g(this,D,Hl)}"
671
- @mw:submit="${g(this,D,Fl)}"
672
- @mw:cancel="${g(this,D,ql)}"
855
+ @mw:change="${g(this,D,ql)}"
856
+ @mw:submit="${g(this,D,Hl)}"
857
+ @mw:cancel="${g(this,D,Bl)}"
673
858
  placeholder="${this.config.input?.placeholder}"
674
859
  ?disabled="${a(this,P).ranOutOfCredits||a(this,P)?.hasQueuedMessages}"
675
860
  ?streaming="${a(this,P)?.isStreaming??!0}"
@@ -685,7 +870,7 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
685
870
  </div>
686
871
  </div>
687
872
  </div>
688
- `}reloadConfig(){a(this,P).reloadConfig(),this.requestUpdate()}async sendMessage(r){if(!r||typeof r!="string")return console.warn("sendMessage requires a valid string message"),!1;let n=await a(this,P).enqueueUserInput(r,{xUserData:a(this,je),xCustomInstructions:a(this,De),role:"user",expectStreaming:!0});return n&&a(this,D,Lr)?.setValue(""),n}setInputValue(r){if(!r||typeof r!="string"){console.warn("setInputValue requires a valid string value");return}let n=a(this,D,Lr);if(!n){console.warn("input element not found, cannot set value");return}n.setValue?n.setValue(r):console.warn("input element does not have setValue method")}reset(){a(this,P).reset()}};je=new WeakMap,De=new WeakMap,D=new WeakSet,Vs=function(){function r(i){if(!i)return;let s;try{s=typeof i=="object"?i:JSON.parse(i)}catch(u){console.error("Molin: user-data is not valid JSON",u);return}if(!s||typeof s!="object"||Object.keys(s).length===0)return;let o=Mr(Ol,s);if(!o.success){console.error("Molin: user-data does not pass schema validation",o.issues);return}return o.output}function n(i){if(!i)return;let s=Mr(jl,i);if(!s.success){console.error("Molin: custom-instructions does not pass schema validation",s.issues);return}return s.output}m(this,je,r(this.xUserData)),m(this,De,n(this.xCustomInstructions))},Or=new WeakMap,ct=new WeakMap,P=new WeakMap,jr=new WeakMap,Ul=function(){m(this,ct,!0)},Vl=function(r){let n=r.target;if(n instanceof HTMLAnchorElement){if(r.preventDefault(),this.callbacks.onUserClickedLink?.({widgetId:this.widgetId,url:n.href,conversationId:this.conversationId}),window.self!==window.top){window.open(n.href,"_blank");return}let s=this.config.linksNewTab?"_blank":"_self";window.open(n.href,n.target||s)}},Nl=function(r){r.preventDefault();let n=r.detail.example;a(this,P).enqueueUserInput(n,{xUserData:a(this,je),xCustomInstructions:a(this,De)}).then(i=>{i&&(a(this,D,Lr)?.setValue(""),this.callbacks.onUserSentInput?.({widgetId:this.widgetId,text:n,example:!0,conversationId:this.conversationId}))}).catch(console.warn)},Fl=function(r){r.preventDefault();let n=r.detail;a(this,P).enqueueUserInput(n,{xUserData:a(this,je),xCustomInstructions:a(this,De)}).then(i=>{i&&(a(this,D,Lr)?.setValue(""),a(this,Or).typingStopped(),this.callbacks.onUserSentInput?.({widgetId:this.widgetId,text:n,example:!1,conversationId:this.conversationId}))}).catch(console.warn)},Hl=function(r){a(this,Or).onInput(r.detail.full)},ql=function(){a(this,P)?.sendUserCancel(),this.callbacks.onUserCanceledStreaming?.({widgetId:this.widgetId})},Bl=function(){a(this,P).reset()},zl=function(){this.dispatchEvent(new ei.CloseClickEvent)},Qn=function(){return this.renderRoot.querySelector("#scrollable-content")},Lr=function(){return this.renderRoot.querySelector("mw-chat-input")},y(ei,"properties",{widgetId:{type:String,attribute:"widget"},config:{type:Object,attribute:!1},callbacks:{type:Object,attribute:!1},showClose:{type:Boolean,attribute:"show-close"},xUserData:{type:Object,attribute:!1},xCustomInstructions:{type:String,attribute:!1}});var Tr=ei,Us;Tr.CloseClickEvent=(Us=class extends CustomEvent{constructor(e={}){super(Tr.CloseClickEvent.type,{...e})}},y(Us,"type","mw:close-click"),Us);customElements.get("mw-chat")||customElements.define("mw-chat",Tr);var Dr=class extends _(S){constructor(){super(),this.color="#601feb",this.radius="16.8576px",this.size="320px",this.border="#d1d5db"}render(){return h`
873
+ `}reloadConfig(){a(this,P).reloadConfig(),this.requestUpdate()}async sendMessage(r){if(!r||typeof r!="string")return console.warn("sendMessage requires a valid string message"),!1;let n=await a(this,P).enqueueUserInput(r,{xUserData:a(this,je),xCustomInstructions:a(this,De),role:"user",expectStreaming:!0});return n&&a(this,D,Lr)?.setValue(""),n}setInputValue(r){if(!r||typeof r!="string"){console.warn("setInputValue requires a valid string value");return}let n=a(this,D,Lr);if(!n){console.warn("input element not found, cannot set value");return}n.setValue?n.setValue(r):console.warn("input element does not have setValue method")}reset(){a(this,P).reset()}};je=new WeakMap,De=new WeakMap,D=new WeakSet,Vs=function(){function r(i){if(!i)return;let s;try{s=typeof i=="object"?i:JSON.parse(i)}catch(u){console.error("Molin: user-data is not valid JSON",u);return}if(!s||typeof s!="object"||Object.keys(s).length===0)return;let o=Mr(jl,s);if(!o.success){console.error("Molin: user-data does not pass schema validation",o.issues);return}return o.output}function n(i){if(!i)return;let s=Mr(Dl,i);if(!s.success){console.error("Molin: custom-instructions does not pass schema validation",s.issues);return}return s.output}m(this,je,r(this.xUserData)),m(this,De,n(this.xCustomInstructions))},Or=new WeakMap,ct=new WeakMap,P=new WeakMap,jr=new WeakMap,Vl=function(){m(this,ct,!0)},Nl=function(r){let n=r.target;if(n instanceof HTMLAnchorElement){if(r.preventDefault(),this.callbacks.onUserClickedLink?.({widgetId:this.widgetId,url:n.href,conversationId:this.conversationId}),window.self!==window.top){window.open(n.href,"_blank");return}let s=this.config.linksNewTab?"_blank":"_self";window.open(n.href,n.target||s)}},Fl=function(r){r.preventDefault();let n=r.detail.example;a(this,P).enqueueUserInput(n,{xUserData:a(this,je),xCustomInstructions:a(this,De)}).then(i=>{i&&(a(this,D,Lr)?.setValue(""),this.callbacks.onUserSentInput?.({widgetId:this.widgetId,text:n,example:!0,conversationId:this.conversationId}))}).catch(console.warn)},Hl=function(r){r.preventDefault();let n=r.detail;a(this,P).enqueueUserInput(n,{xUserData:a(this,je),xCustomInstructions:a(this,De)}).then(i=>{i&&(a(this,D,Lr)?.setValue(""),a(this,Or).typingStopped(),this.callbacks.onUserSentInput?.({widgetId:this.widgetId,text:n,example:!1,conversationId:this.conversationId}))}).catch(console.warn)},ql=function(r){a(this,Or).onInput(r.detail.full)},Bl=function(){a(this,P)?.sendUserCancel(),this.callbacks.onUserCanceledStreaming?.({widgetId:this.widgetId})},zl=function(){a(this,P).reset()},Wl=function(){this.dispatchEvent(new ti.CloseClickEvent)},ei=function(){return this.renderRoot.querySelector("#scrollable-content")},Lr=function(){return this.renderRoot.querySelector("mw-chat-input")},y(ti,"properties",{widgetId:{type:String,attribute:"widget"},config:{type:Object,attribute:!1},callbacks:{type:Object,attribute:!1},showClose:{type:Boolean,attribute:"show-close"},xUserData:{type:Object,attribute:!1},xCustomInstructions:{type:String,attribute:!1}});var Tr=ti,Us;Tr.CloseClickEvent=(Us=class extends CustomEvent{constructor(e={}){super(Tr.CloseClickEvent.type,{...e})}},y(Us,"type","mw:close-click"),Us);customElements.get("mw-chat")||customElements.define("mw-chat",Tr);var Dr=class extends _(S){constructor(){super(),this.color="#601feb",this.radius="16.8576px",this.size="320px",this.border="#d1d5db"}render(){return h`
689
874
  <div class="flex flex-row flex-wrap gap-0">
690
875
  <div class="relative z-0 flex min-h-9 items-center justify-center overflow-hidden rounded-[${this.radius}]">
691
876
  <!-- Spinning gradient background -->
@@ -712,13 +897,13 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
712
897
  transform: rotate(360deg);
713
898
  }
714
899
  }
715
- `);customElements.get("mw-spinning-border")||customElements.define("mw-spinning-border",Dr);var qt,Wl,Zl,Ht=class Ht extends _(S){constructor(){super();d(this,qt);y(this,"render",()=>h`
900
+ `);customElements.get("mw-spinning-border")||customElements.define("mw-spinning-border",Dr);var qt,Zl,Gl,Ht=class Ht extends _(S){constructor(){super();d(this,qt);y(this,"render",()=>h`
716
901
  <div class="popup-desktop group relative w-[300px] cursor-pointer select-none rounded-[17px] shadow-2xl">
717
902
  <mw-spinning-border .color="${this.color}" .border="${"transparent"}" .radius="${"17px"}">
718
903
  <!-- wrapper -->
719
904
  <div class="relative z-[2147483647] m-[1px] w-[300px] rounded-2xl bg-white font-sans text-base leading-normal">
720
905
  <!-- content -->
721
- <div class="p-4 text-left text-gray-800" @click="${g(this,qt,Zl)}">
906
+ <div class="p-4 text-left text-gray-800" @click="${g(this,qt,Gl)}">
722
907
  <p>${this.text}</p>
723
908
  </div>
724
909
  </div>
@@ -727,12 +912,12 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
727
912
  <!-- close button -->
728
913
  <button
729
914
  class="absolute -top-8 right-0 inline-flex h-6 w-6 items-center justify-center rounded-full bg-gray-300 bg-opacity-50 pb-[2px] text-center text-gray-700 opacity-0 shadow transition-opacity duration-300 ease-in-out group-hover:opacity-100"
730
- @click="${g(this,qt,Wl)}"
915
+ @click="${g(this,qt,Zl)}"
731
916
  aria-label="Close">
732
917
  ×
733
918
  </button>
734
919
  </div>
735
- `);this.text="Hello there. How can we help?",this.color="#601feb"}};qt=new WeakSet,Wl=function(){this.dispatchEvent(new Ht.CloseEvent)},Zl=function(){this.dispatchEvent(new Ht.ClickEvent)},y(Ht,"properties",{text:{type:String},color:{type:String}}),y(Ht,"styles",re`
920
+ `);this.text="Hello there. How can we help?",this.color="#601feb"}};qt=new WeakSet,Zl=function(){this.dispatchEvent(new Ht.CloseEvent)},Gl=function(){this.dispatchEvent(new Ht.ClickEvent)},y(Ht,"properties",{text:{type:String},color:{type:String}}),y(Ht,"styles",re`
736
921
  .popup-desktop:hover button {
737
922
  transition-delay: 0s !important;
738
923
  }
@@ -740,19 +925,19 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
740
925
  .popup-desktop button {
741
926
  transition-delay: 1s;
742
927
  }
743
- `);var pt=Ht,Ns;pt.CloseEvent=(Ns=class extends CustomEvent{constructor(e={}){super(pt.CloseEvent.type,{...e})}},y(Ns,"type","mw:close"),Ns);var Fs;pt.ClickEvent=(Fs=class extends CustomEvent{constructor(e={}){super(pt.ClickEvent.type,{...e})}},y(Fs,"type","mw:click"),Fs);customElements.get("mw-popup-desktop")||customElements.define("mw-popup-desktop",pt);var Bt,Gl,Jl,Rr=class Rr extends _(S){constructor(){super();d(this,Bt);y(this,"render",()=>h`
928
+ `);var pt=Ht,Ns;pt.CloseEvent=(Ns=class extends CustomEvent{constructor(e={}){super(pt.CloseEvent.type,{...e})}},y(Ns,"type","mw:close"),Ns);var Fs;pt.ClickEvent=(Fs=class extends CustomEvent{constructor(e={}){super(pt.ClickEvent.type,{...e})}},y(Fs,"type","mw:click"),Fs);customElements.get("mw-popup-desktop")||customElements.define("mw-popup-desktop",pt);var Bt,Jl,Xl,Rr=class Rr extends _(S){constructor(){super();d(this,Bt);y(this,"render",()=>h`
744
929
  <!-- wrapper -->
745
930
  <div class="group relative z-[2147483647] select-none rounded-t-2xl bg-white text-left font-sans text-[16px] text-base leading-normal text-gray-800 shadow-2xl transition-all">
746
931
  <!-- close button -->
747
932
  <button
748
933
  class="absolute right-4 top-[28px] inline-flex h-7 w-7 items-center justify-center rounded-full bg-gray-300 bg-opacity-50 pb-[2px] text-center text-xl shadow-none duration-300 ease-in-out focus:outline-none"
749
- @click="${g(this,Bt,Gl)}"
934
+ @click="${g(this,Bt,Jl)}"
750
935
  aria-label="Close">
751
936
  ×
752
937
  </button>
753
938
 
754
939
  <!-- content -->
755
- <div class="p-4 text-gray-800" @click="${g(this,Bt,Jl)}">
940
+ <div class="p-4 text-gray-800" @click="${g(this,Bt,Xl)}">
756
941
  <h1 class="mr-8 py-2.5 text-left font-display text-lg font-bold">${this.title}</h1>
757
942
  <p class="py-2.5 text-left">${this.text}</p>
758
943
  <div class="h-4"></div>
@@ -765,30 +950,30 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
765
950
  <!-- can append any other content -->
766
951
  <slot name="footer"></slot>
767
952
  </div>
768
- `);this.title="Chat with Molin AI",this.text="Hello there. How can we help?",this.button="Chat now",this.color="#601feb"}};Bt=new WeakSet,Gl=function(){this.dispatchEvent(new Rr.CloseEvent)},Jl=function(){this.dispatchEvent(new Rr.ClickEvent)},y(Rr,"properties",{title:{type:String},text:{type:String},button:{type:String},color:{type:String}});var ft=Rr,Hs;ft.CloseEvent=(Hs=class extends CustomEvent{constructor(e={}){super(ft.CloseEvent.type,{...e})}},y(Hs,"type","mw:close"),Hs);var qs;ft.ClickEvent=(qs=class extends CustomEvent{constructor(e={}){super(ft.ClickEvent.type,{...e})}},y(qs,"type","mw:click"),qs);customElements.get("mw-popup-mobile")||customElements.define("mw-popup-mobile",ft);var zt,Pr,ht,ti=class{constructor(e,r){d(this,zt);d(this,Pr,!1);d(this,ht,()=>{a(this,Pr)||(a(this,zt).userFirstInteracted?.(),m(this,Pr,!0)),a(this,zt).userInteracted?.()});m(this,zt,r),e.addController(this)}hostConnected(){this.startListening()}hostDisconnected(){this.stopListening()}startListening(){window.addEventListener("click",a(this,ht)),window.addEventListener("keydown",a(this,ht))}stopListening(){window.removeEventListener("click",a(this,ht)),window.removeEventListener("keydown",a(this,ht))}};zt=new WeakMap,Pr=new WeakMap,ht=new WeakMap;var bp=24*60*60*1e3,Wt,ce,dt,Ur,mt,Vr,ni,Xl,ri=class{constructor(e,r,n=Date){d(this,ni);d(this,Wt);d(this,ce);d(this,dt);d(this,Ur);d(this,mt,!1);d(this,Vr,!1);m(this,Wt,e),m(this,ce,r),m(this,dt,n),e.addController(this)}get showing(){return a(this,mt)}hostDisconnected(){this.abortAutoShowTimer()}show({sound:e}={}){if(this.abortAutoShowTimer(),!a(this,mt)&&(m(this,mt,!0),a(this,Wt).requestUpdate(),e)){a(this,ce).playPopupSound();let r=a(this,ce).getPersistedState();a(this,ce).setPersistedState({...r,playedSoundOnce:!0})}}hide(){m(this,Vr,!0),this.abortAutoShowTimer(),m(this,mt,!1),a(this,Wt).requestUpdate()}abortAutoShowTimer(){clearTimeout(a(this,Ur))}onCloseClick(){let e=a(this,ce).getPersistedState();a(this,ce).setPersistedState({...e,userDismissedAt:a(this,dt).now()}),this.hide()}onContentClick(){let e=a(this,ce).getPersistedState();a(this,ce).setPersistedState({...e,userDismissedAt:a(this,dt).now()}),this.hide()}userFirstInteracted(){this.abortAutoShowTimer(),a(this,Vr)||m(this,Ur,setTimeout(()=>g(this,ni,Xl).call(this),a(this,ce).getDelayMs()))}};Wt=new WeakMap,ce=new WeakMap,dt=new WeakMap,Ur=new WeakMap,mt=new WeakMap,Vr=new WeakMap,ni=new WeakSet,Xl=function(){let e=a(this,ce).getPersistedState(),r=!!e?.playedSoundOnce;e?.userDismissedAt&&a(this,dt).now()-e.userDismissedAt<bp||this.show({sound:!r})};var Be,Ws,Re,ii,zs,si=class si extends _(S){constructor(){super();d(this,Re);d(this,Be,new ri(this,{getDelayMs:()=>this.delayMs,playPopupSound:()=>{this.soundUrl&&new Audio(this.soundUrl).play().then(()=>{}).catch(r=>{console.error("Error playing audio:",r,{})})},setPersistedState:r=>{r?localStorage.setItem("_molin_popup",JSON.stringify(r)):localStorage.removeItem("_molin_popup")},getPersistedState:()=>{let r=localStorage.getItem("_molin_popup");try{return r?JSON.parse(r):null}catch{return null}}}));d(this,Ws,new ti(this,a(this,Be)));this.positionClasses="",this.delayMs=0,this.soundUrl="",this.content={desktop:{text:"",color:""},mobile:{title:"",text:"",button:"",color:"",poweredBy:!0}}}render(){let r=a(this,Be).showing?"visible opacity-100 translate-y-0":"invisible opacity-0 translate-y-3",n=this.content;return h`
953
+ `);this.title="Chat with Molin AI",this.text="Hello there. How can we help?",this.button="Chat now",this.color="#601feb"}};Bt=new WeakSet,Jl=function(){this.dispatchEvent(new Rr.CloseEvent)},Xl=function(){this.dispatchEvent(new Rr.ClickEvent)},y(Rr,"properties",{title:{type:String},text:{type:String},button:{type:String},color:{type:String}});var ft=Rr,Hs;ft.CloseEvent=(Hs=class extends CustomEvent{constructor(e={}){super(ft.CloseEvent.type,{...e})}},y(Hs,"type","mw:close"),Hs);var qs;ft.ClickEvent=(qs=class extends CustomEvent{constructor(e={}){super(ft.ClickEvent.type,{...e})}},y(qs,"type","mw:click"),qs);customElements.get("mw-popup-mobile")||customElements.define("mw-popup-mobile",ft);var zt,Pr,ht,ri=class{constructor(e,r){d(this,zt);d(this,Pr,!1);d(this,ht,()=>{a(this,Pr)||(a(this,zt).userFirstInteracted?.(),m(this,Pr,!0)),a(this,zt).userInteracted?.()});m(this,zt,r),e.addController(this)}hostConnected(){this.startListening()}hostDisconnected(){this.stopListening()}startListening(){window.addEventListener("click",a(this,ht)),window.addEventListener("keydown",a(this,ht))}stopListening(){window.removeEventListener("click",a(this,ht)),window.removeEventListener("keydown",a(this,ht))}};zt=new WeakMap,Pr=new WeakMap,ht=new WeakMap;var bp=24*60*60*1e3,Wt,ce,dt,Ur,mt,Vr,ii,Kl,ni=class{constructor(e,r,n=Date){d(this,ii);d(this,Wt);d(this,ce);d(this,dt);d(this,Ur);d(this,mt,!1);d(this,Vr,!1);m(this,Wt,e),m(this,ce,r),m(this,dt,n),e.addController(this)}get showing(){return a(this,mt)}hostDisconnected(){this.abortAutoShowTimer()}show({sound:e}={}){if(this.abortAutoShowTimer(),!a(this,mt)&&(m(this,mt,!0),a(this,Wt).requestUpdate(),e)){a(this,ce).playPopupSound();let r=a(this,ce).getPersistedState();a(this,ce).setPersistedState({...r,playedSoundOnce:!0})}}hide(){m(this,Vr,!0),this.abortAutoShowTimer(),m(this,mt,!1),a(this,Wt).requestUpdate()}abortAutoShowTimer(){clearTimeout(a(this,Ur))}onCloseClick(){let e=a(this,ce).getPersistedState();a(this,ce).setPersistedState({...e,userDismissedAt:a(this,dt).now()}),this.hide()}onContentClick(){let e=a(this,ce).getPersistedState();a(this,ce).setPersistedState({...e,userDismissedAt:a(this,dt).now()}),this.hide()}userFirstInteracted(){this.abortAutoShowTimer(),a(this,Vr)||m(this,Ur,setTimeout(()=>g(this,ii,Kl).call(this),a(this,ce).getDelayMs()))}};Wt=new WeakMap,ce=new WeakMap,dt=new WeakMap,Ur=new WeakMap,mt=new WeakMap,Vr=new WeakMap,ii=new WeakSet,Kl=function(){let e=a(this,ce).getPersistedState(),r=!!e?.playedSoundOnce;e?.userDismissedAt&&a(this,dt).now()-e.userDismissedAt<bp||this.show({sound:!r})};var Be,Ws,Re,si,zs,oi=class oi extends _(S){constructor(){super();d(this,Re);d(this,Be,new ni(this,{getDelayMs:()=>this.delayMs,playPopupSound:()=>{this.soundUrl&&new Audio(this.soundUrl).play().then(()=>{}).catch(r=>{console.error("Error playing audio:",r,{})})},setPersistedState:r=>{r?localStorage.setItem("_molin_popup",JSON.stringify(r)):localStorage.removeItem("_molin_popup")},getPersistedState:()=>{let r=localStorage.getItem("_molin_popup");try{return r?JSON.parse(r):null}catch{return null}}}));d(this,Ws,new ri(this,a(this,Be)));this.positionClasses="",this.delayMs=0,this.soundUrl="",this.content={desktop:{text:"",color:""},mobile:{title:"",text:"",button:"",color:"",poweredBy:!0}}}render(){let r=a(this,Be).showing?"visible opacity-100 translate-y-0":"invisible opacity-0 translate-y-3",n=this.content;return h`
769
954
  <!-- mobile shadow backdrop -->
770
- <div @click="${g(this,Re,ii)}" class="${r} fixed inset-0 z-[2147483647] bg-black/50 transition-[opacity,visibility] sm:hidden"></div>
955
+ <div @click="${g(this,Re,si)}" class="${r} fixed inset-0 z-[2147483647] bg-black/50 transition-[opacity,visibility] sm:hidden"></div>
771
956
 
772
957
  <!-- mobile overlay -->
773
958
  <div class="${r} fixed bottom-0 left-0 right-0 z-[2147483647] sm:hidden">
774
- <mw-popup-mobile title="${n.mobile.title}" text="${n.mobile.text}" button="${n.mobile.button}" color="${n.mobile.color}" @mw:click="${g(this,Re,zs)}" @mw:close="${g(this,Re,ii)}">
959
+ <mw-popup-mobile title="${n.mobile.title}" text="${n.mobile.text}" button="${n.mobile.button}" color="${n.mobile.color}" @mw:click="${g(this,Re,zs)}" @mw:close="${g(this,Re,si)}">
775
960
  ${n.mobile.poweredBy?h`<mw-powered-by class="block p-4" slot="footer"></mw-powered-by>`:E}
776
961
  </mw-popup-mobile>
777
962
  </div>
778
963
 
779
964
  <!-- desktop -->
780
965
  <div class="${r} ${this.positionClasses} fixed z-[2147483647] transition-[opacity,translate,visibility] max-sm:hidden">
781
- <mw-popup-desktop color="${n.desktop.color}" text="${n.desktop.text}" @mw:click="${g(this,Re,zs)}" @mw:close="${g(this,Re,ii)}"></mw-popup-desktop>
966
+ <mw-popup-desktop color="${n.desktop.color}" text="${n.desktop.text}" @mw:click="${g(this,Re,zs)}" @mw:close="${g(this,Re,si)}"></mw-popup-desktop>
782
967
  </div>
783
- `}hide(){a(this,Be).hide()}};Be=new WeakMap,Ws=new WeakMap,Re=new WeakSet,ii=function(){a(this,Be).onCloseClick()},zs=function(){this.dispatchEvent(new si.ClickEvent),a(this,Be).onContentClick()},y(si,"properties",{positionClasses:{type:String,attribute:"position"},delayMs:{type:Number,attribute:"delay"},soundUrl:{type:String,attribute:"sound"},content:{type:Object}});var Nr=si,Bs;Nr.ClickEvent=(Bs=class extends CustomEvent{constructor(e={}){super(Nr.ClickEvent.type,{...e})}},y(Bs,"type","mw:click"),Bs);customElements.get("mw-popup")||customElements.define("mw-popup",Nr);var ai,Kl,oi=class extends _(S){constructor(){super();d(this,ai);y(this,"render",()=>h`
968
+ `}hide(){a(this,Be).hide()}};Be=new WeakMap,Ws=new WeakMap,Re=new WeakSet,si=function(){a(this,Be).onCloseClick()},zs=function(){this.dispatchEvent(new oi.ClickEvent),a(this,Be).onContentClick()},y(oi,"properties",{positionClasses:{type:String,attribute:"position"},delayMs:{type:Number,attribute:"delay"},soundUrl:{type:String,attribute:"sound"},content:{type:Object}});var Nr=oi,Bs;Nr.ClickEvent=(Bs=class extends CustomEvent{constructor(e={}){super(Nr.ClickEvent.type,{...e})}},y(Bs,"type","mw:click"),Bs);customElements.get("mw-popup")||customElements.define("mw-popup",Nr);var li,Yl,ai=class extends _(S){constructor(){super();d(this,li);y(this,"render",()=>h`
784
969
  <span class="relative inline-flex">
785
970
  <slot></slot>
786
- <span class="${a(this,ai,Kl)} pointer-events-none absolute z-10 flex h-3 w-3">
971
+ <span class="${a(this,li,Yl)} pointer-events-none absolute z-10 flex h-3 w-3">
787
972
  <span class="bg-${this.color} absolute inline-flex h-3 w-3 animate-ping rounded-full opacity-75"></span>
788
973
  <span class="bg-${this.color} relative inline-flex h-3 w-3 rounded-full"></span>
789
974
  </span>
790
975
  </span>
791
- `);this.color="sky-500",this.position="top-right"}};ai=new WeakSet,Kl=function(){switch(this.position){case"top-left":return"top-0 left-0 -mt-1 -ml-1";case"top-right":return"top-0 right-0 -mt-1 -mr-1";case"bottom-left":return"bottom-0 left-0 -mb-1 -ml-1";case"bottom-right":return"bottom-0 right-0 -mb-1 -mr-1";default:throw new Error(`Invalid position: ${this.position}`)}},y(oi,"properties",{color:{type:String,attribute:"color"},position:{type:String,attribute:"position"}});customElements.get("mw-pulse-dot")||customElements.define("mw-pulse-dot",oi);var li=class extends _(S){constructor(){super();y(this,"render",()=>h`
976
+ `);this.color="sky-500",this.position="top-right"}};li=new WeakSet,Yl=function(){switch(this.position){case"top-left":return"top-0 left-0 -mt-1 -ml-1";case"top-right":return"top-0 right-0 -mt-1 -mr-1";case"bottom-left":return"bottom-0 left-0 -mb-1 -ml-1";case"bottom-right":return"bottom-0 right-0 -mb-1 -mr-1";default:throw new Error(`Invalid position: ${this.position}`)}},y(ai,"properties",{color:{type:String,attribute:"color"},position:{type:String,attribute:"position"}});customElements.get("mw-pulse-dot")||customElements.define("mw-pulse-dot",ai);var ui=class extends _(S){constructor(){super();y(this,"render",()=>h`
792
977
  <div class="${this.positionClasses} fixed bottom-24 right-6 z-10 flex animate-bounce flex-col items-center justify-center font-sans text-base">
793
978
  <p class="mb-2 -translate-x-4 -rotate-12 transform text-lg font-bold leading-normal text-gray-800">${this.text}</p>
794
979
 
@@ -801,192 +986,7 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
801
986
  stroke-linecap="round"></path>
802
987
  </svg>
803
988
  </div>
804
- `);this.positionClasses="",this.text="Try it out"}};y(li,"properties",{positionClasses:{type:String,attribute:"position"},text:{type:String}});customElements.get("mw-try-it-out")||customElements.define("mw-try-it-out",li);var Yl=(t,e,r)=>{for(let n of e)if(n[0]===t)return(0,n[1])();return r?.()};var ui=class extends _(S){constructor(){super(),this.orderDetails=null,this.streaming=!1,this.linksNewTab=!1}render(){let e=Rt(this.orderDetails?.order_status?.step||[]),r=Rt(this.orderDetails?.items?.item||[]),n=Rt(this.orderDetails?.actions||[]);return h`
805
- <div class="flex w-full max-w-md flex-col rounded-3xl border bg-white p-4">
806
- <!-- Header with order ID -->
807
- <div class="mb-2">
808
- ${this.orderDetails?.order_id?.label||!this.streaming?h`<h2 class="text-lg font-semibold">${this.orderDetails?.order_id?.label} ${this.orderDetails?.order_id?.value}</h2>`:h`<div class="h-7 w-full animate-pulse rounded bg-gray-200"></div>`}
809
- </div>
810
-
811
- <!-- Progress Timeline -->
812
- <div>
813
- <ol role="list" class="w-full overflow-hidden">
814
- ${this.streaming&&!this.orderDetails?h`
815
- <!-- Loading for status timeline -->
816
- ${[1,2,3].map((i,s)=>h`
817
- <li class="w-full pb-8">
818
- ${s<2?h`<div class="absolute left-2 top-2 -ml-px mt-0.5 h-full w-0.5 animate-pulse bg-gray-200" aria-hidden="true"></div>`:""}
819
- <div class="group relative flex items-start">
820
- <span class="flex h-6 items-center">
821
- <span class="h-4 w-4 animate-pulse rounded-full bg-gray-200"></span>
822
- </span>
823
- <span class="ml-3 flex min-w-0 flex-col">
824
- <span class="h-5 w-24 animate-pulse rounded bg-gray-200"></span>
825
- </span>
826
- </div>
827
- </li>
828
- `)}
829
- `:we(e,i=>i.label,(i,s)=>{let o=i.status==="completed",u=i.status==="in_progress",l=s===e.length-1;return h`<li class="relative pb-4">
830
- ${l?"":h`<div class="${`absolute left-2 top-2 -ml-px mt-0.5 h-full w-0.5 ${o?"bg-[#601feb]":"bg-gray-300"}`}" aria-hidden="true"></div>`}
831
-
832
- <div class="group relative flex items-start">
833
- ${Yl(i.status,[["pending",()=>h` <span class="flex h-6 items-center">
834
- <span class="flex h-4 w-4 items-center justify-center rounded-full border-2 border-gray-300 bg-white">
835
- <span class="h-1.5 w-1.5 rounded-full bg-transparent"></span>
836
- </span>
837
- </span>`],["in_progress",()=>h`<span class="flex h-6 items-center">
838
- <span class="flex h-4 w-4 items-center justify-center rounded-full border-2 border-[#601feb] bg-white">
839
- <span class="h-1.5 w-1.5 rounded-full bg-[#601feb]"></span>
840
- </span>
841
- </span>`],["completed",()=>h`
842
- <span class="flex h-6 items-center">
843
- <span class="flex h-4 w-4 items-center justify-center rounded-full bg-[#601feb]">
844
- <hi-outline class="mb-3 block h-3 w-3 text-white" name="check"></hi-outline>
845
- </span>
846
- </span>
847
- `]],()=>h`<span class="flex h-6 items-center">
848
- <span class="flex h-4 w-4 items-center justify-center rounded-full border-2 border-[#601feb] bg-white">
849
- <span class="h-1.5 w-1.5 rounded-full bg-[#601feb]"></span>
850
- </span>
851
- </span>`)}
852
-
853
- <span class="ml-3 flex min-w-0 flex-col">
854
- <span class="${`text-sm font-medium ${u?"text-[#601feb]":o?"text-gray-900":"text-gray-500"}`}"> ${i.label} </span>
855
- </span>
856
- </div>
857
- </li>`})}
858
- </ol>
859
- </div>
860
-
861
- <!-- Products list with order items -->
862
- <div class="mb-2 w-full">
863
- ${r.length===0&&!this.orderDetails?.total?.amount&&this.streaming?h`
864
- <!-- Loading shimmer for products -->
865
- <div class="w-full space-y-4">
866
- <div class="flex items-center gap-2">
867
- <div class="h-12 w-12 animate-pulse rounded-lg bg-gray-200"></div>
868
- <div class="flex-1 space-y-2">
869
- <div class="h-4 w-32 animate-pulse rounded bg-gray-200"></div>
870
- <div class="h-4 w-24 animate-pulse rounded bg-gray-200"></div>
871
- </div>
872
- </div>
873
- <div class="flex items-center justify-between">
874
- <div class="h-4 w-12 animate-pulse rounded bg-gray-200"></div>
875
- <div class="h-4 w-10 animate-pulse rounded bg-gray-200"></div>
876
- </div>
877
- </div>
878
- `:h`
879
- <div class="divide-y divide-gray-100">
880
- ${this.streaming&&!r.length?h`
881
- <!-- Loading shimmer for individual products -->
882
- ${[1,2].map(()=>h`
883
- <div class="flex items-center gap-2 py-1.5">
884
- <div class="h-12 w-12 animate-pulse rounded-lg bg-gray-200"></div>
885
- <div class="min-w-0 flex-1">
886
- <div class="h-4 w-32 animate-pulse rounded bg-gray-200"></div>
887
- </div>
888
- <div class="h-4 w-24 animate-pulse rounded bg-gray-200"></div>
889
- </div>
890
- `)}
891
- `:r?.map(i=>{let s=i?.image_url;return h`
892
- <div class="flex items-center gap-2 py-1.5">
893
- <mw-product-thumbnail class="block h-12 w-12" src="${$e(s)}"></mw-product-thumbnail>
894
-
895
- <div class="min-w-0 flex-1">
896
- ${!i?.name&&this.streaming?h`<div class="h-4 w-32 animate-pulse rounded bg-gray-200"></div>`:h`<h3 class="truncate text-sm font-medium">${i?.name}</h3>`}
897
- </div>
898
- ${!i?.price&&this.streaming?h`<div class="h-4 w-24 animate-pulse rounded bg-gray-200"></div>`:h`<span class="text-sm text-gray-500">${i?.quantity&&Number(i.quantity)>1?"x":""} ${i?.price}</span>`}
899
- </div>
900
- `})}
901
- </div>
902
- <!-- Order total -->
903
- <div class="mt-1 border-t border-gray-200 pt-1">
904
- <div class="flex justify-between font-medium">
905
- <span>${this.orderDetails?.total?.label}</span>
906
- <span>${this.orderDetails?.total?.amount}</span>
907
- </div>
908
- </div>
909
- `}
910
- </div>
911
-
912
- <!-- Shipping and payment information -->
913
- <div class="mb-2 flex w-full flex-col gap-2 overflow-hidden">
914
- ${this.streaming&&!this.orderDetails?h`
915
- <!-- Loading shimmer template -->
916
- ${[1,2].map(()=>h`
917
- <div>
918
- <div class="mb-2 h-5 w-32 animate-pulse rounded bg-gray-200"></div>
919
- <div class="space-y-2 overflow-hidden">
920
- <div class="h-4 w-40 animate-pulse rounded bg-gray-200"></div>
921
- <div class="h-4 w-36 animate-pulse rounded bg-gray-200"></div>
922
- </div>
923
- </div>
924
- `)}
925
- `:h`
926
- <!-- Shipping Section -->
927
- <div>
928
- ${this.streaming&&!this.orderDetails?.shipping?h`
929
- <div>
930
- <div class="mb-2 h-5 w-32 animate-pulse rounded bg-gray-200"></div>
931
- <div class="space-y-2 overflow-hidden">
932
- <div class="h-4 w-40 animate-pulse rounded bg-gray-200"></div>
933
- <div class="h-4 w-36 animate-pulse rounded bg-gray-200"></div>
934
- </div>
935
- </div>
936
- `:this.orderDetails?.shipping?.method||this.orderDetails?.customer?.name?h`
937
- <h3 class="mb-1 text-sm font-medium">${this.orderDetails?.shipping?.label}</h3>
938
- <div class="space-y-1">
939
- ${this.orderDetails.customer?.name?h`<p class="text-xs text-gray-600">${this.orderDetails.customer.name}</p>`:""}
940
- ${this.orderDetails.shipping?.method?h`<p class="text-xs text-gray-600">${this.orderDetails.shipping.method}</p>`:""}
941
- </div>
942
- `:""}
943
- </div>
944
-
945
- <!-- Payment Section -->
946
- <div>
947
- ${this.streaming&&!this.orderDetails?.payment?h`
948
- <div>
949
- <div class="mb-2 h-5 w-32 animate-pulse rounded bg-gray-200"></div>
950
- <div class="space-y-2 overflow-hidden">
951
- <div class="h-4 w-40 animate-pulse rounded bg-gray-200"></div>
952
- <div class="h-4 w-36 animate-pulse rounded bg-gray-200"></div>
953
- </div>
954
- </div>
955
- `:this.orderDetails?.payment?h`
956
- <h3 class="mb-1 text-sm font-medium">${this.orderDetails.payment.label}</h3>
957
- ${this.orderDetails.payment?.method?.value?h`
958
- <p class="text-xs text-gray-600">
959
- <span class="font-medium">${this.orderDetails.payment.method.label}:</span>
960
- ${this.orderDetails.payment.method.value}
961
- </p>
962
- `:""}
963
- ${this.orderDetails.payment.status?.value?h`
964
- <p class="text-xs text-gray-600">
965
- <span class="font-medium">${this.orderDetails.payment.status.label}:</span>
966
- <span>${this.orderDetails.payment.status.value}</span>
967
- </p>
968
- `:""}
969
- `:""}
970
- </div>
971
- `}
972
- </div>
973
-
974
- <!-- Action buttons section -->
975
- <div class="flex w-full flex-col gap-2 overflow-hidden">
976
- ${this.streaming&&!n[0]?.track_order?.label&&!us(n[0]?.track_order?.tracking_url||"")?h`
977
- <!-- Loading shimmer for buttons -->
978
- <div class="h-10 w-full min-w-[250px] animate-pulse overflow-hidden rounded-xl bg-gray-200"></div>
979
- `:we(n,(i,s)=>`action-${s}`,i=>{if(i?.track_order?.label)return h`
980
- ${us(i.track_order?.tracking_url||"")?h` <a
981
- target="${this.linksNewTab?"_blank":"_self"}"
982
- href="${i.track_order?.tracking_url}"
983
- class="mt-1 w-full rounded-xl bg-[#601feb] px-4 py-2 text-center text-sm font-medium text-white hover:opacity-90"
984
- >${i.track_order.label}</a
985
- >`:null}
986
- `})}
987
- </div>
988
- </div>
989
- `}};y(ui,"properties",{orderDetails:{type:Object,attribute:"order-details"},streaming:{type:Boolean},linksNewTab:{type:Boolean,attribute:"links-new-tab"}});customElements.get("mw-product-order-status-card")||customElements.define("mw-product-order-status-card",ui);var ze,_e,Gs,Fr,Zs=class{constructor(e=window.localStorage){d(this,_e);d(this,ze);m(this,ze,e)}setex(e,r,n){return a(this,ze).setItem(e,g(this,_e,Fr).call(this,{value:g(this,_e,Fr).call(this,r),expiresAt:Date.now()+n*1e3})||"")}set(e,r){return a(this,ze).setItem(e,g(this,_e,Fr).call(this,{value:g(this,_e,Fr).call(this,r)})||"")}get(e){let r=a(this,ze).getItem(e);if(!r)return;let n=g(this,_e,Gs).call(this,r);if(n){if(n.expiresAt&&n.expiresAt<Date.now()){a(this,ze).removeItem(e);return}return g(this,_e,Gs).call(this,n.value)}}get molin_shop_assistant_distinct_id(){return localStorage.getItem("molin_shop_assistant_distinct_id")}set molin_shop_assistant_distinct_id(e){e===null?localStorage.removeItem("molin_shop_assistant_distinct_id"):localStorage.setItem("molin_shop_assistant_distinct_id",e)}get molin_widget_open_state(){return pe.get("molin-shop-ai-widget-open")??null}set molin_widget_open_state(e){pe.set("molin-shop-ai-widget-open",e)}resetWidgetData(){pe.molin_shop_assistant_distinct_id=null,pe.molin_widget_open_state=null}};ze=new WeakMap,_e=new WeakSet,Gs=function(e){if(!(typeof e!="string"||e===""))try{return JSON.parse(e)}catch{return}},Fr=function(e){if(e!==void 0)try{return JSON.stringify(e)}catch{return}};var pe=new Zs;var ne,Pe,ci,Hr,Zt,Js=class{constructor(){d(this,ne,[]);d(this,Pe);d(this,ci,10);d(this,Hr,5e3);d(this,Zt,!1)}async add(e,r){if(a(this,ne).push(tu(e,r)),a(this,ne).length>=a(this,ci))return this.flush();a(this,Pe)||m(this,Pe,setTimeout(()=>{this.flush().catch(console.error)},a(this,Hr)))}async flush(){if(a(this,Zt)||a(this,ne).length===0)return;let e=[...a(this,ne)];try{m(this,Zt,!0),clearTimeout(a(this,Pe)),m(this,Pe,void 0),m(this,ne,[]);let r=new AbortController,n=setTimeout(()=>r.abort(),5e3);await eu(e,{signal:r.signal}),clearTimeout(n)}catch(r){if(r.name==="AbortError")console.error("Request timed out, retrying events"),m(this,ne,[...e,...a(this,ne)]);else{console.error("Failed to send events to backend:",r);let n=e.filter(i=>i.event.includes("error"));m(this,ne,[...n,...a(this,ne)])}}finally{m(this,Zt,!1),a(this,ne).length>0&&!a(this,Pe)&&m(this,Pe,setTimeout(()=>{this.flush().catch(console.error)},a(this,Hr)))}}async flushBeforeUnload(){if(a(this,ne).length>0)try{let e=new FormData;e.set("events",JSON.stringify(a(this,ne))),navigator.sendBeacon(new URL("/widgets/data/collect",ru()).href,e)}catch(e){console.error("Failed to send final events:",e)}}};ne=new WeakMap,Pe=new WeakMap,ci=new WeakMap,Hr=new WeakMap,Zt=new WeakMap;var Ql=new Js;window.addEventListener("beforeunload",()=>{Ql.flushBeforeUnload().catch(console.error)});async function F(t,e,r){if(typeof t!="string")throw new TypeError("Event name must be a string");if(typeof e!="object"||e===null)throw new TypeError("Properties must be an object");try{if(r?.immediate){await eu([tu(t,e)]);return}else return Ql.add(t,e)}catch(n){console.error("Failed to send event:",n)}}async function eu(t,{signal:e}={}){let r=new FormData;r.set("events",JSON.stringify(t));let n=await fetch(new URL("/widgets/data/collect",ru()),{method:"POST",body:r,signal:e});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);n.body?.cancel().catch(console.warn)}function tu(t,e){return{event:t,widget_id:e.widgetId,properties:Object.assign({},e,kp()),distinct_id:xp(),timestamp:new Date().toISOString()}}function xp(){try{let t=pe.molin_shop_assistant_distinct_id;return t||(t=crypto.randomUUID(),pe.molin_shop_assistant_distinct_id=t),t}catch(t){console.error("Failed to deserialize distinct_id:",t);let e=crypto.randomUUID();try{pe.molin_shop_assistant_distinct_id=e}catch(r){console.error("Failed to store new distinct_id:",r)}return e}}function kp(){return{referrer:document.referrer,userAgent:navigator.userAgent,language:navigator.language,screenWidth:window.innerWidth,screenHeight:window.innerHeight,timestamp:new Date().toISOString(),timezoneOffset:new Date().getTimezoneOffset(),doNotTrack:navigator.doNotTrack??void 0}}function ru(){let t=new URL(import.meta.url).hostname;return{localhost:"http://localhost:8787","molin.localhost":"http://molin.localhost:8787","widget.molin.foo":"https://molin.foo","widget.molin.ai":"https://molin.ai","molin.ai":"https://molin.ai","molin.foo":"https://molin.foo"}[t]||"https://molin.ai"}var gt,qr,We,yt,fi,iu,pi=class{constructor(e,r,n){d(this,fi);d(this,gt);d(this,qr);d(this,We);d(this,yt);y(this,"isLoading",!1);y(this,"data");m(this,gt,e),m(this,qr,r),m(this,We,n),e.addController(this)}fetch(){if(this.isLoading)return;a(this,yt)?.abort();let e=new AbortController;m(this,yt,e),this.isLoading=!0,this.data=void 0,a(this,gt).requestUpdate(),(async()=>{let r=g(this,fi,iu).call(this);return r.signal?.addEventListener("abort",()=>e.abort(),{signal:e.signal}),fetch(r,{signal:e.signal})})().then(async r=>{if(!r.ok)throw new Error(`${r.statusText}: ${await r.text()}`);this.isLoading=!1,this.data=typeof a(this,We)?.transform=="function"?await a(this,We).transform(r):r,a(this,gt).requestUpdate()}).catch(r=>{a(this,We)?.onError?.(r),this.isLoading=!1,this.data=void 0,a(this,gt).requestUpdate()}).finally(()=>{e.abort()})}hostConnected(){this.isLoading||a(this,We)?.fetchWhenConnected&&this.fetch()}hostDisconnected(){a(this,yt)?.abort(),m(this,yt,void 0)}};gt=new WeakMap,qr=new WeakMap,We=new WeakMap,yt=new WeakMap,fi=new WeakSet,iu=function(){let e=a(this,qr);if(typeof e=="function"&&(e=e()),!e)throw new Error("missing request");return new Request(e)};var ge,Br,Gt,Jt,Ze=class{constructor(e,r){d(this,ge);d(this,Br);d(this,Gt);d(this,Jt);m(this,ge,e),m(this,Br,r),e.addController(this)}get data(){return a(this,Jt)||a(this,Gt)?.data}hostConnected(){if(a(this,Gt)||a(this,Jt))return;let e=su();e&&e.widgetId===a(this,ge).widgetId?m(this,Jt,e.config):m(this,Gt,new pi(a(this,ge),()=>{if(a(this,ge).cdn&&a(this,ge).widgetId)return`${a(this,ge).cdn}/config?w=${a(this,ge).widgetId}`;throw new Error("missing cdn or widgetId")},{fetchWhenConnected:!0,transform:async r=>{let n=await r.json();return n&&!e&&window.__INIT_MOLIN_SHOP_AI({cdn:a(this,ge).cdn,widgetId:a(this,ge).widgetId,config:n}),n},onError:a(this,Br)?.onError}))}};ge=new WeakMap,Br=new WeakMap,Gt=new WeakMap,Jt=new WeakMap;function Ge(){return window.molinSettings&&typeof window.molinSettings=="object"?window.molinSettings:null}var hi,Zr,di,Ue,ou,zr,Wr=class Wr extends _(S){constructor(){super();d(this,Ue);d(this,hi,new Ze(this,{onError:console.error}));d(this,Zr);d(this,di,{onError:r=>{alert(r.error),console.error(r.widgetId,r.error),F("ShopAssistant: error",{...r},{immediate:!0})},onNewMessageStartedStreaming:r=>{F("ShopAssistant: user received bot message (streaming started)",r)},onMessageEndedStreaming:r=>{F("ShopAssistant: user received bot message (streaming ended)",r)},onUserCanceledStreaming:r=>{F("ShopAssistant: user canceled streaming",r)},onUserClickedLink:r=>{F("ShopAssistant: user clicked link",r)},onUserSentInput:r=>{F("ShopAssistant: user sent input",r)}});this.cdn="https://widget.molin.ai",this.widgetId="",this.showClose=!1,this.xUserData=Ge()?.userData,this.xCustomInstructions=Ge()?.customInstructions}get config(){return a(this,Zr)||a(this,hi).data}render(){return this.config?h`
989
+ `);this.positionClasses="",this.text="Try it out"}};y(ui,"properties",{positionClasses:{type:String,attribute:"position"},text:{type:String}});customElements.get("mw-try-it-out")||customElements.define("mw-try-it-out",ui);var ze,_e,Gs,Fr,Zs=class{constructor(e=window.localStorage){d(this,_e);d(this,ze);m(this,ze,e)}setex(e,r,n){return a(this,ze).setItem(e,g(this,_e,Fr).call(this,{value:g(this,_e,Fr).call(this,r),expiresAt:Date.now()+n*1e3})||"")}set(e,r){return a(this,ze).setItem(e,g(this,_e,Fr).call(this,{value:g(this,_e,Fr).call(this,r)})||"")}get(e){let r=a(this,ze).getItem(e);if(!r)return;let n=g(this,_e,Gs).call(this,r);if(n){if(n.expiresAt&&n.expiresAt<Date.now()){a(this,ze).removeItem(e);return}return g(this,_e,Gs).call(this,n.value)}}get molin_shop_assistant_distinct_id(){return localStorage.getItem("molin_shop_assistant_distinct_id")}set molin_shop_assistant_distinct_id(e){e===null?localStorage.removeItem("molin_shop_assistant_distinct_id"):localStorage.setItem("molin_shop_assistant_distinct_id",e)}get molin_widget_open_state(){return pe.get("molin-shop-ai-widget-open")??null}set molin_widget_open_state(e){pe.set("molin-shop-ai-widget-open",e)}resetWidgetData(){pe.molin_shop_assistant_distinct_id=null,pe.molin_widget_open_state=null}};ze=new WeakMap,_e=new WeakSet,Gs=function(e){if(!(typeof e!="string"||e===""))try{return JSON.parse(e)}catch{return}},Fr=function(e){if(e!==void 0)try{return JSON.stringify(e)}catch{return}};var pe=new Zs;var ne,Pe,ci,Hr,Zt,Js=class{constructor(){d(this,ne,[]);d(this,Pe);d(this,ci,10);d(this,Hr,5e3);d(this,Zt,!1)}async add(e,r){if(a(this,ne).push(tu(e,r)),a(this,ne).length>=a(this,ci))return this.flush();a(this,Pe)||m(this,Pe,setTimeout(()=>{this.flush().catch(console.error)},a(this,Hr)))}async flush(){if(a(this,Zt)||a(this,ne).length===0)return;let e=[...a(this,ne)];try{m(this,Zt,!0),clearTimeout(a(this,Pe)),m(this,Pe,void 0),m(this,ne,[]);let r=new AbortController,n=setTimeout(()=>r.abort(),5e3);await eu(e,{signal:r.signal}),clearTimeout(n)}catch(r){if(r.name==="AbortError")console.error("Request timed out, retrying events"),m(this,ne,[...e,...a(this,ne)]);else{console.error("Failed to send events to backend:",r);let n=e.filter(i=>i.event.includes("error"));m(this,ne,[...n,...a(this,ne)])}}finally{m(this,Zt,!1),a(this,ne).length>0&&!a(this,Pe)&&m(this,Pe,setTimeout(()=>{this.flush().catch(console.error)},a(this,Hr)))}}async flushBeforeUnload(){if(a(this,ne).length>0)try{let e=new FormData;e.set("events",JSON.stringify(a(this,ne))),navigator.sendBeacon(new URL("/widgets/data/collect",ru()).href,e)}catch(e){console.error("Failed to send final events:",e)}}};ne=new WeakMap,Pe=new WeakMap,ci=new WeakMap,Hr=new WeakMap,Zt=new WeakMap;var Ql=new Js;window.addEventListener("beforeunload",()=>{Ql.flushBeforeUnload().catch(console.error)});async function F(t,e,r){if(typeof t!="string")throw new TypeError("Event name must be a string");if(typeof e!="object"||e===null)throw new TypeError("Properties must be an object");try{if(r?.immediate){await eu([tu(t,e)]);return}else return Ql.add(t,e)}catch(n){console.error("Failed to send event:",n)}}async function eu(t,{signal:e}={}){let r=new FormData;r.set("events",JSON.stringify(t));let n=await fetch(new URL("/widgets/data/collect",ru()),{method:"POST",body:r,signal:e});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);n.body?.cancel().catch(console.warn)}function tu(t,e){return{event:t,widget_id:e.widgetId,properties:Object.assign({},e,kp()),distinct_id:xp(),timestamp:new Date().toISOString()}}function xp(){try{let t=pe.molin_shop_assistant_distinct_id;return t||(t=crypto.randomUUID(),pe.molin_shop_assistant_distinct_id=t),t}catch(t){console.error("Failed to deserialize distinct_id:",t);let e=crypto.randomUUID();try{pe.molin_shop_assistant_distinct_id=e}catch(r){console.error("Failed to store new distinct_id:",r)}return e}}function kp(){return{referrer:document.referrer,userAgent:navigator.userAgent,language:navigator.language,screenWidth:window.innerWidth,screenHeight:window.innerHeight,timestamp:new Date().toISOString(),timezoneOffset:new Date().getTimezoneOffset(),doNotTrack:navigator.doNotTrack??void 0}}function ru(){let t=new URL(import.meta.url).hostname;return{localhost:"http://localhost:8787","molin.localhost":"http://molin.localhost:8787","widget.molin.foo":"https://molin.foo","widget.molin.ai":"https://molin.ai","molin.ai":"https://molin.ai","molin.foo":"https://molin.foo"}[t]||"https://molin.ai"}var gt,qr,We,yt,fi,iu,pi=class{constructor(e,r,n){d(this,fi);d(this,gt);d(this,qr);d(this,We);d(this,yt);y(this,"isLoading",!1);y(this,"data");m(this,gt,e),m(this,qr,r),m(this,We,n),e.addController(this)}fetch(){if(this.isLoading)return;a(this,yt)?.abort();let e=new AbortController;m(this,yt,e),this.isLoading=!0,this.data=void 0,a(this,gt).requestUpdate(),(async()=>{let r=g(this,fi,iu).call(this);return r.signal?.addEventListener("abort",()=>e.abort(),{signal:e.signal}),fetch(r,{signal:e.signal})})().then(async r=>{if(!r.ok)throw new Error(`${r.statusText}: ${await r.text()}`);this.isLoading=!1,this.data=typeof a(this,We)?.transform=="function"?await a(this,We).transform(r):r,a(this,gt).requestUpdate()}).catch(r=>{a(this,We)?.onError?.(r),this.isLoading=!1,this.data=void 0,a(this,gt).requestUpdate()}).finally(()=>{e.abort()})}hostConnected(){this.isLoading||a(this,We)?.fetchWhenConnected&&this.fetch()}hostDisconnected(){a(this,yt)?.abort(),m(this,yt,void 0)}};gt=new WeakMap,qr=new WeakMap,We=new WeakMap,yt=new WeakMap,fi=new WeakSet,iu=function(){let e=a(this,qr);if(typeof e=="function"&&(e=e()),!e)throw new Error("missing request");return new Request(e)};var ge,Br,Gt,Jt,Ze=class{constructor(e,r){d(this,ge);d(this,Br);d(this,Gt);d(this,Jt);m(this,ge,e),m(this,Br,r),e.addController(this)}get data(){return a(this,Jt)||a(this,Gt)?.data}hostConnected(){if(a(this,Gt)||a(this,Jt))return;let e=su();e&&e.widgetId===a(this,ge).widgetId?m(this,Jt,e.config):m(this,Gt,new pi(a(this,ge),()=>{if(a(this,ge).cdn&&a(this,ge).widgetId)return`${a(this,ge).cdn}/config?w=${a(this,ge).widgetId}`;throw new Error("missing cdn or widgetId")},{fetchWhenConnected:!0,transform:async r=>{let n=await r.json();return n&&!e&&window.__INIT_MOLIN_SHOP_AI({cdn:a(this,ge).cdn,widgetId:a(this,ge).widgetId,config:n}),n},onError:a(this,Br)?.onError}))}};ge=new WeakMap,Br=new WeakMap,Gt=new WeakMap,Jt=new WeakMap;function Ge(){return window.molinSettings&&typeof window.molinSettings=="object"?window.molinSettings:null}var hi,Zr,di,Ue,ou,zr,Wr=class Wr extends _(S){constructor(){super();d(this,Ue);d(this,hi,new Ze(this,{onError:console.error}));d(this,Zr);d(this,di,{onError:r=>{alert(r.error),console.error(r.widgetId,r.error),F("ShopAssistant: error",{...r},{immediate:!0})},onNewMessageStartedStreaming:r=>{F("ShopAssistant: user received bot message (streaming started)",r)},onMessageEndedStreaming:r=>{F("ShopAssistant: user received bot message (streaming ended)",r)},onUserCanceledStreaming:r=>{F("ShopAssistant: user canceled streaming",r)},onUserClickedLink:r=>{F("ShopAssistant: user clicked link",r)},onUserSentInput:r=>{F("ShopAssistant: user sent input",r)}});this.cdn="https://widget.molin.ai",this.widgetId="",this.showClose=!1,this.xUserData=Ge()?.userData,this.xCustomInstructions=Ge()?.customInstructions}get config(){return a(this,Zr)||a(this,hi).data}render(){return this.config?h`
990
990
  <!-- embed our chat component forwarding props -->
991
991
  <mw-chat
992
992
  widget="${this.widgetId}"
@@ -1014,7 +1014,7 @@ var wu=Object.defineProperty;var no=t=>{throw TypeError(t)};var bu=(t,e,r)=>e in
1014
1014
  :host {
1015
1015
  all: initial; /* reset all properties that can pierce the shadow DOM */
1016
1016
  }
1017
- `),y(Gr,"properties",{cdn:{type:String},widgetId:{type:String,attribute:"widget"},state:{type:String}});customElements.define("molin-shop-ai-launcher",Gr);var _5="navigator"in globalThis&&/Mobi|Android|iPhone/i.test(navigator.userAgent),A5="navigator"in globalThis&&"share"in navigator,$p=Object.freeze({sm:640,md:768,lg:1024,xl:1280,"2xl":1536});function Sp(t){if(typeof window>"u")return!1;let e=$p[t];return typeof e!="number"?(console.warn(`Invalid breakpoint: ${t}`),!1):window.matchMedia(`(min-width: ${e}px)`).matches}function Ys(){return Sp("sm")}var vi,Xt,Kt,wt,Jr,wi,yi=class{constructor(e,r,n,i=window.history){d(this,vi);d(this,Xt);d(this,Kt);d(this,wt);d(this,Jr,!1);d(this,wi,()=>{a(this,Xt).test(window.location.pathname)&&a(this,Kt).navigated()});m(this,vi,e),m(this,Xt,r),m(this,Kt,n),m(this,wt,i),e.addController(this)}hostConnected(){a(this,wi).call(this);let e=a(this,wt).pushState;a(this,wt).pushState=(...r)=>{if(e.call(a(this,wt),...r),!a(this,Jr))try{let n=new URL(r[2],window.location.origin);a(this,Xt).test(n.pathname)&&a(this,Kt).navigated()}catch{}}}hostDisconnected(){m(this,Jr,!0)}};vi=new WeakMap,Xt=new WeakMap,Kt=new WeakMap,wt=new WeakMap,Jr=new WeakMap,wi=new WeakMap;function lu({minMs:t,maxMs:e}){return Math.random()*(e-t)+t}function Qs(t,e=""){return Object.entries(t).filter(([r,n])=>n).map(([r,n])=>`${e}${r}-[${n}]`).join(" ")}function uu(t,e={}){return[Qs(t),Qs(e,"max-sm:")].join(" ")}function cu(t){return Qs(t)}function eo(t){return Object.entries(t).filter(([e,r])=>r).filter(([e])=>e==="left"||e==="right").map(([e,r])=>{let n=`sm:${e}-[${r}]`;return e==="left"&&(n+=" sm:right-auto"),e==="right"&&(n+=" sm:left-auto"),n}).join(" ")}function pu(t){let e=eo(t),n=`sm:bottom-[${t.bottom?`calc(${t.bottom}+72px)`:"72px"}]`;return[e,n].filter(Boolean).join(" ")}var bi,Kr,ro,N,Je,xi,T,fu,Xr,Yt,hu,du,mu,to,gu,yu,Qt,xe=class extends _(S){constructor(){super();d(this,T);d(this,bi,new Ze(this,{onError:console.error}));d(this,Kr);d(this,ro,new yi(this,/.*/i,{navigated:()=>{if(!this.widgetId){console.warn("No widgetId set, cannot track page view");return}let r=a(this,T,Yt)?.conversationId,n=Ft.restore(this.widgetId)?.conversationId,i=r||n;i&&F("ShopAssistant: pageview",{widgetId:this.widgetId,conversationId:i,url:document.location.href,title:document.title,hidden:this.config?this.config.hidden||!1:void 0})}}));d(this,N,!1);d(this,Je,!1);d(this,xi,{onError:r=>{alert(r.error),console.error(r.widgetId,r.error),F("ShopAssistant: error",{...r},{immediate:!0})},onNewMessageStartedStreaming:r=>{F("ShopAssistant: user received bot message (streaming started)",r)},onMessageEndedStreaming:r=>{F("ShopAssistant: user received bot message (streaming ended)",r)},onUserCanceledStreaming:r=>{F("ShopAssistant: user canceled streaming",r)},onUserClickedLink:r=>{F("ShopAssistant: user clicked link",r)},onUserSentInput:r=>{F("ShopAssistant: user sent input",r)}});this.cdn="https://widget.molin.ai",this.widgetId="",this.xUserData=Ge()?.userData,this.xCustomInstructions=Ge()?.customInstructions}get config(){return a(this,Kr)||a(this,bi).data}render(){if(!this.config)return E;let r=uu(this.config.bubble.position,this.config.bubble.mobilePosition),n=cu(this.config.bubble.position),i=eo(this.config.bubble.position),s=pu(this.config.bubble.position);return this.config.hidden?E:mi().hidden?E:h`
1017
+ `),y(Gr,"properties",{cdn:{type:String},widgetId:{type:String,attribute:"widget"},state:{type:String}});customElements.define("molin-shop-ai-launcher",Gr);var A5="navigator"in globalThis&&/Mobi|Android|iPhone/i.test(navigator.userAgent),M5="navigator"in globalThis&&"share"in navigator,$p=Object.freeze({sm:640,md:768,lg:1024,xl:1280,"2xl":1536});function Sp(t){if(typeof window>"u")return!1;let e=$p[t];return typeof e!="number"?(console.warn(`Invalid breakpoint: ${t}`),!1):window.matchMedia(`(min-width: ${e}px)`).matches}function Ys(){return Sp("sm")}var vi,Xt,Kt,wt,Jr,wi,yi=class{constructor(e,r,n,i=window.history){d(this,vi);d(this,Xt);d(this,Kt);d(this,wt);d(this,Jr,!1);d(this,wi,()=>{a(this,Xt).test(window.location.pathname)&&a(this,Kt).navigated()});m(this,vi,e),m(this,Xt,r),m(this,Kt,n),m(this,wt,i),e.addController(this)}hostConnected(){a(this,wi).call(this);let e=a(this,wt).pushState;a(this,wt).pushState=(...r)=>{if(e.call(a(this,wt),...r),!a(this,Jr))try{let n=new URL(r[2],window.location.origin);a(this,Xt).test(n.pathname)&&a(this,Kt).navigated()}catch{}}}hostDisconnected(){m(this,Jr,!0)}};vi=new WeakMap,Xt=new WeakMap,Kt=new WeakMap,wt=new WeakMap,Jr=new WeakMap,wi=new WeakMap;function lu({minMs:t,maxMs:e}){return Math.random()*(e-t)+t}function Qs(t,e=""){return Object.entries(t).filter(([r,n])=>n).map(([r,n])=>`${e}${r}-[${n}]`).join(" ")}function uu(t,e={}){return[Qs(t),Qs(e,"max-sm:")].join(" ")}function cu(t){return Qs(t)}function eo(t){return Object.entries(t).filter(([e,r])=>r).filter(([e])=>e==="left"||e==="right").map(([e,r])=>{let n=`sm:${e}-[${r}]`;return e==="left"&&(n+=" sm:right-auto"),e==="right"&&(n+=" sm:left-auto"),n}).join(" ")}function pu(t){let e=eo(t),n=`sm:bottom-[${t.bottom?`calc(${t.bottom}+72px)`:"72px"}]`;return[e,n].filter(Boolean).join(" ")}var bi,Kr,ro,N,Je,xi,T,fu,Xr,Yt,hu,du,mu,to,gu,yu,Qt,xe=class extends _(S){constructor(){super();d(this,T);d(this,bi,new Ze(this,{onError:console.error}));d(this,Kr);d(this,ro,new yi(this,/.*/i,{navigated:()=>{if(!this.widgetId){console.warn("No widgetId set, cannot track page view");return}let r=a(this,T,Yt)?.conversationId,n=Ft.restore(this.widgetId)?.conversationId,i=r||n;i&&F("ShopAssistant: pageview",{widgetId:this.widgetId,conversationId:i,url:document.location.href,title:document.title,hidden:this.config?this.config.hidden||!1:void 0})}}));d(this,N,!1);d(this,Je,!1);d(this,xi,{onError:r=>{alert(r.error),console.error(r.widgetId,r.error),F("ShopAssistant: error",{...r},{immediate:!0})},onNewMessageStartedStreaming:r=>{F("ShopAssistant: user received bot message (streaming started)",r)},onMessageEndedStreaming:r=>{F("ShopAssistant: user received bot message (streaming ended)",r)},onUserCanceledStreaming:r=>{F("ShopAssistant: user canceled streaming",r)},onUserClickedLink:r=>{F("ShopAssistant: user clicked link",r)},onUserSentInput:r=>{F("ShopAssistant: user sent input",r)}});this.cdn="https://widget.molin.ai",this.widgetId="",this.xUserData=Ge()?.userData,this.xCustomInstructions=Ge()?.customInstructions}get config(){return a(this,Kr)||a(this,bi).data}render(){if(!this.config)return E;let r=uu(this.config.bubble.position,this.config.bubble.mobilePosition),n=cu(this.config.bubble.position),i=eo(this.config.bubble.position),s=pu(this.config.bubble.position);return this.config.hidden?E:mi().hidden?E:h`
1018
1018
  <mw-bubble
1019
1019
  class="${r} ${a(this,N)?"opacity-0":"opacity-100"} fixed z-[${a(this,T,fu)}] transition-opacity"
1020
1020
  @click="${g(this,T,du)}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molin.ai/shop-ai",
3
- "version": "0.8.42",
3
+ "version": "0.8.43",
4
4
  "description": "Molin Shop AI",
5
5
  "keywords": [
6
6
  "molin",