@molin.ai/shop-ai 0.7.12 → 0.7.14

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.
@@ -180,7 +180,7 @@ var Bp=Object.defineProperty;var Pl=i=>{throw TypeError(i)};var Hp=(i,e,t)=>e in
180
180
  </div>
181
181
  </div>
182
182
  </div>
183
- `;default:throw new Error(`Unknown side: ${this.side}`)}}};R(Cn,"properties",{side:{type:String},status:{type:String},color:{type:String},logoUrl:{type:String,attribute:"logo"},position:{type:String}});customElements.get("mw-chat-message")||customElements.define("mw-chat-message",Cn);var pr,je,ut,hr,wo,In=class{constructor(e,t){b(this,hr);b(this,pr);b(this,je);b(this,ut);if(!e)throw new Error("host is required");if(!t)throw new Error("config is required");$(this,pr,e),f(this,pr).addController(this),$(this,je,t)}connect(e){$(this,je,e),$(this,ut,I(this,hr,wo).call(this))}hostConnected(){setTimeout(()=>{$(this,ut,I(this,hr,wo).call(this))},0)}hostDisconnected(){f(this,ut)?.close(1e3,"lit_host_disconnected"),$(this,ut,void 0)}send(e){f(this,ut)?.send(e)}close(e,t){f(this,ut)?.close(e,t)}get isConnected(){return f(this,ut)?.readyState===WebSocket.OPEN}};pr=new WeakMap,je=new WeakMap,ut=new WeakMap,hr=new WeakSet,wo=function(){let e=new WebSocket(f(this,je).url());return f(this,je).onClose&&(e.onclose=f(this,je).onClose),f(this,je).onOpen&&(e.onopen=f(this,je).onOpen),f(this,je).onError&&(e.onerror=f(this,je).onError),f(this,je).onMessage&&(e.onmessage=f(this,je).onMessage),e};var Xu="664df22d-d461-42d6-801e-f70247e2cd7c",be,we,rt,Ei,$i,Se,Qt,Ju,Yu,Ku,Zu,An=class{constructor(e,t){b(this,Se);b(this,be);b(this,we);b(this,rt);R(this,"isStreaming",!1);R(this,"typingIndicator");R(this,"ranOutOfCredits",!1);R(this,"messages",[]);R(this,"conversationId","");b(this,Ei,0);b(this,$i);R(this,"isLiveMode",!1);$(this,be,e),$(this,we,t),$(this,rt,this.initWS()),e.addController(this)}sendUserInput(e,{xUserData:t,xPromptExt:r,role:n="user",expectStreaming:s=!1}={}){return I(this,Se,Qt).call(this,{type:"USER_INPUT",value:e,role:n,xUserData:t,xPromptExt:r},{expectStreaming:s})}sendUserCancel(){return I(this,Se,Qt).call(this,{type:"USER_CANCEL"})}sendUserTypingStart(){return I(this,Se,Qt).call(this,{type:"USER_TYPING_START"})}sendUserTypingStop(){return I(this,Se,Qt).call(this,{type:"USER_TYPING_STOP"})}reloadConfig(){I(this,Se,Qt).call(this,{type:"RELOAD_CONFIG"})}close(){f(this,rt).close(1e3,"closed by user")}retry(){clearTimeout(f(this,$i)),$(this,$i,setTimeout(()=>{f(this,we).onReconnect?.(),$(this,rt,this.initWS())},1e3*f(this,Ei))),Rl(this,Ei)._++}initWS(){return new In(f(this,be),{url:()=>f(this,we).url(this.conversationId,{}),onOpen:e=>I(this,Se,Ju).call(this,e),onMessage:e=>I(this,Se,Yu).call(this,JSON.parse(e.data)),onError:e=>I(this,Se,Ku).call(this,e),onClose:e=>I(this,Se,Zu).call(this,e)})}hostConnected(){this.conversationId=f(this,we).restoreConversationState?.()?.conversationId||"",this.messages=f(this,we).restoreConversationState?.()?.messages||[]}reset(){I(this,Se,Qt).call(this,{type:"NEW_CHAT"}),f(this,we).onReset?.(),this.isStreaming=!1,this.typingIndicator=void 0,this.ranOutOfCredits=!1,this.messages=[],this.conversationId="",this.isLiveMode=!1,f(this,be).requestUpdate()}hostDisconnected(){clearTimeout(f(this,$i))}reconnectSocket(){f(this,rt).close(1e3,"destroy"),$(this,rt,this.initWS())}get lastMsg(){if(this.messages.length>0)return this.messages[this.messages.length-1]}};be=new WeakMap,we=new WeakMap,rt=new WeakMap,Ei=new WeakMap,$i=new WeakMap,Se=new WeakSet,Qt=function(e,{expectStreaming:t=!1}={}){return f(this,rt).isConnected?(t&&!this.isLiveMode&&(this.isStreaming=!0,f(this,be).requestUpdate()),f(this,rt).send(JSON.stringify(e)),!0):(console.warn("WebSocket is not connected, message not sent - reconnecting now",e),this.retry(),!1)},Ju=function(e){$(this,Ei,0)},Yu=function(e){switch(e.type){case"NEW_MESSAGE":{this.messages=[...this.messages,e.message].filter((t,r,n)=>r===n.findIndex(s=>s.id===t.id)),this.typingIndicator=void 0,f(this,be).requestUpdate(),f(this,we).onNewMessage?.(e.message);break}case"UPDATE_MESSAGE":{let t=this.messages.find(r=>r.id===e.message.id);if(t)Object.assign(t,e.message),f(this,be).requestUpdate(),f(this,we).onUpdateMessage?.(e);else throw new Error(`Message with id ${e.message.id} not found`);break}case"MESSAGE_DONE":{let t=this.messages.find(r=>r.id===e.message.id);if(t)Object.assign(t,e.message);else throw new Error(`Message with id ${e.message.id} not found`);this.isStreaming=!1,f(this,be).requestUpdate(),f(this,we).onMessageDone?.(e,t),f(this,we).persistConversationState?.(this.conversationId,this.messages);break}case"MESSAGE_CANCEL":{this.isStreaming=!1,this.typingIndicator=void 0,f(this,be).requestUpdate();break}case"ERROR":{f(this,we).onMessageError?.(e);break}case"CONNECTED":{this.conversationId=e.conversationId,this.messages=e.messages,f(this,we).onConnect?.(e.conversationId),f(this,we).persistConversationState?.(this.conversationId,this.messages),this.isLiveMode=e.metadata?.isLiveMode,f(this,be).requestUpdate();break}case"TYPING_START":{e.role==="assistant"&&(this.isStreaming=!0),this.typingIndicator={role:e.role,metadata:e.metadata},f(this,be).requestUpdate();break}case"TYPING_STOP":{this.typingIndicator=void 0,f(this,be).requestUpdate();break}case"RAN_OUT_OF_CREDITS":{this.messages.some(t=>t.id===Xu)||this.messages.push({id:Xu,role:"assistant",content:"Sorry, I've run out of credits. Please contact the shop directly.",timestamp:Date.now()}),this.ranOutOfCredits=!0,f(this,be).requestUpdate();break}case"RECONNECT":{this.reconnectSocket(),f(this,be).requestUpdate();break}default:console.warn(`Unknown message type: ${JSON.stringify(e)}`)}},Ku=function(e){console.error("onError",e),f(this,we).onError?.(e)},Zu=function(e){f(this,be).isConnected&&!f(this,rt).isConnected&&e.reason==="reconnect"&&this.retry(),this.isStreaming=!1,this.typingIndicator=void 0,f(this,be).requestUpdate(),f(this,we).onClose?.()};var fr,Ci,Pt,ei,Pn,Qu,Tn=class{constructor(e,t,{timeoutMs:r=2e3}={}){b(this,Pn);b(this,fr);b(this,Ci);b(this,Pt);b(this,ei,!1);R(this,"timeoutMs");$(this,fr,e),$(this,Ci,t),this.timeoutMs=r,e.addController(this)}get isTyping(){return f(this,ei)}hostDisconnected(){clearTimeout(f(this,Pt)),$(this,Pt,void 0)}onInput(e){if(f(this,fr).isConnected){if(!e.trim()){this.typingStopped();return}clearTimeout(f(this,Pt)),$(this,Pt,setTimeout(()=>this.typingStopped(),this.timeoutMs)),f(this,ei)||I(this,Pn,Qu).call(this)}}typingStopped(){clearTimeout(f(this,Pt)),$(this,ei,!1),f(this,Ci).typingStopped()}};fr=new WeakMap,Ci=new WeakMap,Pt=new WeakMap,ei=new WeakMap,Pn=new WeakSet,Qu=function(){$(this,ei,!0),f(this,Ci).typingStarted()};function ec(i,e){let t=new Map;for(let r of i){let n=e(r);t.has(n)||t.set(n,[]),(t.get(n)||[]).push(r)}return t}function tc(i,e="en-US"){let t=new Intl.DateTimeFormat(e,{hour:"numeric",minute:"numeric"}).format(i);return`${i.toLocaleDateString(e,{year:"numeric",month:"short",day:"numeric"})}, ${t}`}var xo;function ko(i){return{lang:i?.lang??xo?.lang,message:i?.message,abortEarly:i?.abortEarly??xo?.abortEarly,abortPipeEarly:i?.abortPipeEarly??xo?.abortPipeEarly}}var jh;function qh(i){return jh?.get(i)}var Bh;function Hh(i){return Bh?.get(i)}var zh;function Wh(i,e){return zh?.get(i)?.get(e)}function Ii(i){let e=typeof i;return e==="string"?`"${i}"`:e==="number"||e==="bigint"||e==="boolean"?`${i}`:e==="object"||e==="function"?(i&&Object.getPrototypeOf(i)?.constructor?.name)??"null":e}function qe(i,e,t,r,n){let s=n&&"input"in n?n.input:t.value,o=n?.expected??i.expects??null,l=n?.received??Ii(s),a={kind:i.kind,type:i.type,input:s,expected:o,received:l,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${l}`,requirement:i.requirement,path:n?.path,issues:n?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=i.kind==="schema",d=n?.message??i.message??Wh(i.reference,a.lang)??(c?Hh(a.lang):null)??r.message??qh(a.lang);d&&(a.message=typeof d=="function"?d(a):d),c&&(t.typed=!1),t.issues?t.issues.push(a):t.issues=[a]}function nt(i){return{version:1,vendor:"valibot",validate(e){return i["~run"]({value:e},ko())}}}function Vh(i,e){return Object.hasOwn(i,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function rc(i,e){let t=[...new Set(i)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}var Gh=class extends Error{constructor(e){super(e[0].message);R(this,"issues");this.name="ValiError",this.issues=e}};function So(i,e){return{kind:"validation",type:"max_length",reference:So,async:!1,expects:`<=${i}`,requirement:i,message:e,"~run"(t,r){return t.typed&&t.value.length>this.requirement&&qe(this,"length",t,r,{received:`${t.value.length}`}),t}}}function Eo(i,e){return{kind:"validation",type:"max_value",reference:Eo,async:!1,expects:`<=${i instanceof Date?i.toJSON():Ii(i)}`,requirement:i,message:e,"~run"(t,r){return t.typed&&!(t.value<=this.requirement)&&qe(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():Ii(t.value)}),t}}}function $o(i,e){return{kind:"validation",type:"min_length",reference:$o,async:!1,expects:`>=${i}`,requirement:i,message:e,"~run"(t,r){return t.typed&&t.value.length<this.requirement&&qe(this,"length",t,r,{received:`${t.value.length}`}),t}}}function Co(i,e){return{kind:"validation",type:"min_value",reference:Co,async:!1,expects:`>=${i instanceof Date?i.toJSON():Ii(i)}`,requirement:i,message:e,"~run"(t,r){return t.typed&&!(t.value>=this.requirement)&&qe(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():Ii(t.value)}),t}}}function Xh(i,e,t){return typeof i.default=="function"?i.default(e,t):i.default}function _t(i,e){return{kind:"schema",type:"array",reference:_t,expects:"Array",async:!1,item:i,message:e,get"~standard"(){return nt(this)},"~run"(t,r){let n=t.value;if(Array.isArray(n)){t.typed=!0,t.value=[];for(let s=0;s<n.length;s++){let o=n[s],l=this.item["~run"]({value:o},r);if(l.issues){let a={type:"array",origin:"value",input:n,key:s,value:o};for(let c of l.issues)c.path?c.path.unshift(a):c.path=[a],t.issues?.push(c);if(t.issues||(t.issues=l.issues),r.abortEarly){t.typed=!1;break}}l.typed||(t.typed=!1),t.value.push(l.value)}}else qe(this,"type",t,r);return t}}}function xe(i){return{kind:"schema",type:"boolean",reference:xe,expects:"boolean",async:!1,message:i,get"~standard"(){return nt(this)},"~run"(e,t){return typeof e.value=="boolean"?e.typed=!0:qe(this,"type",e,t),e}}}function Io(i){return{kind:"schema",type:"null",reference:Io,expects:"null",async:!1,message:i,get"~standard"(){return nt(this)},"~run"(e,t){return e.value===null?e.typed=!0:qe(this,"type",e,t),e}}}function Te(i){return{kind:"schema",type:"number",reference:Te,expects:"number",async:!1,message:i,get"~standard"(){return nt(this)},"~run"(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:qe(this,"type",e,t),e}}}function re(i,e){return{kind:"schema",type:"object",reference:re,expects:"Object",async:!1,entries:i,message:e,get"~standard"(){return nt(this)},"~run"(t,r){let n=t.value;if(n&&typeof n=="object"){t.typed=!0,t.value={};for(let s in this.entries){let o=n[s],l=this.entries[s]["~run"]({value:o},r);if(l.issues){let a={type:"object",origin:"value",input:n,key:s,value:o};for(let c of l.issues)c.path?c.path.unshift(a):c.path=[a],t.issues?.push(c);if(t.issues||(t.issues=l.issues),r.abortEarly){t.typed=!1;break}}l.typed||(t.typed=!1),(l.value!==void 0||s in n)&&(t.value[s]=l.value)}}else qe(this,"type",t,r);return t}}}function A(i,e){return{kind:"schema",type:"optional",reference:A,expects:`(${i.expects} | undefined)`,async:!1,wrapped:i,default:e,get"~standard"(){return nt(this)},"~run"(t,r){return t.value===void 0&&(this.default!==void 0&&(t.value=Xh(this,t,r)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,r)}}}function Ai(i,e){return{kind:"schema",type:"picklist",reference:Ai,expects:rc(i.map(Ii),"|"),async:!1,options:i,message:e,get"~standard"(){return nt(this)},"~run"(t,r){return this.options.includes(t.value)?t.typed=!0:qe(this,"type",t,r),t}}}function Ao(i,e,t){return{kind:"schema",type:"record",reference:Ao,expects:"Object",async:!1,key:i,value:e,message:t,get"~standard"(){return nt(this)},"~run"(r,n){let s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(let o in s)if(Vh(s,o)){let l=s[o],a=this.key["~run"]({value:o},n);if(a.issues){let d={type:"object",origin:"key",input:s,key:o,value:l};for(let u of a.issues)u.path=[d],r.issues?.push(u);if(r.issues||(r.issues=a.issues),n.abortEarly){r.typed=!1;break}}let c=this.value["~run"]({value:l},n);if(c.issues){let d={type:"object",origin:"value",input:s,key:o,value:l};for(let u of c.issues)u.path?u.path.unshift(d):u.path=[d],r.issues?.push(u);if(r.issues||(r.issues=c.issues),n.abortEarly){r.typed=!1;break}}(!a.typed||!c.typed)&&(r.typed=!1),a.typed&&(r.value[a.value]=c.value)}}else qe(this,"type",r,n);return r}}}function N(i){return{kind:"schema",type:"string",reference:N,expects:"string",async:!1,message:i,get"~standard"(){return nt(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:qe(this,"type",e,t),e}}}function ic(i){let e;if(i)for(let t of i)e?e.push(...t.issues):e=t.issues;return e}function To(i,e){return{kind:"schema",type:"union",reference:To,expects:rc(i.map(t=>t.expects),"|"),async:!1,options:i,message:e,get"~standard"(){return nt(this)},"~run"(t,r){let n,s,o;for(let l of this.options){let a=l["~run"]({value:t.value},r);if(a.typed)if(a.issues)s?s.push(a):s=[a];else{n=a;break}else o?o.push(a):o=[a]}if(n)return n;if(s){if(s.length===1)return s[0];qe(this,"type",t,r,{issues:ic(s)}),t.typed=!0}else{if(o?.length===1)return o[0];qe(this,"type",t,r,{issues:ic(o)})}return t}}}function nc(i,e,t){let r=i["~run"]({value:e},ko(t));if(r.issues)throw new Gh(r.issues);return r.value}function Rn(...i){return{...i[0],pipe:i,get"~standard"(){return nt(this)},"~run"(e,t){for(let r of i)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r["~run"](e,t))}return e}}}function Po(i,e,t){let r=i["~run"]({value:e},ko(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var gr={SCRAPER:"scraper",UNAS:"unas",SHOPRENTER:"shoprenter",SHOPIFY:"shopify",SHOPER:"shoper"},Jh=Object.freeze([gr.UNAS,gr.SHOPRENTER,gr.SHOPIFY,gr.SHOPER]),oc=Object.freeze([...Jh,gr.SCRAPER]);var Am=re({wsApiUrl:N(),url:N(),logoUrl:A(N()),title:N(),status:N(),color:N(),showStillLearningBanner:A(xe()),allowedOrigins:A(_t(N())),input:re({placeholder:N()}),bubble:re({imageUrl:A(N()),position:re({bottom:A(N()),right:A(N()),left:A(N())}),mobilePosition:A(re({bottom:A(N()),right:A(N()),left:A(N())})),zIndex:A(Te())}),examples:re({title:N(),items:_t(N())}),instructions:re({items:_t(N()),limit:A(Te())}),popup:A(re({mobileEnabled:A(xe()),desktopEnabled:A(xe()),delayMs:A(Te()),text:A(N()),mobileTitleText:A(N()),mobileButtonText:A(N())})),tryItOut:A(re({mobileEnabled:A(xe()),desktopEnabled:A(xe()),text:A(N())})),contactDetails:A(re({email:A(N()),phone:A(N()),socialMedia:A(re({facebook:A(N()),instagram:A(N()),twitter:A(N())}))})),notifications:A(re({email:A(N())})),neverShowStillLearningBanner:A(xe()),hidden:A(xe()),newChatTitle:A(N()),webhookURL:A(N()),automatedResponse:A(re({enabled:A(xe()),text:A(N()),latencyThresholdMs:A(Te())})),removePoweredBy:A(xe()),claimable:A(xe()),feed:A(N()),scraper:A(Ai(["netkazan","jateknet","json-schema-org","arukereso-xml","partocean","google-rev1"])),scraperAuthorization:A(N()),platform:A(Ai(oc)),workingHours:A(re({dailyAvailability:_t(re({dayOfWeek:Rn(Te(),Co(0),Eo(6)),startTime:N(),endTime:N(),isActive:xe()})),userTimeZone:A(N())})),planOverrides:A(re({maxProducts:A(Te()),conversations:A(Te()),faqs:A(re({max:A(Te()),questionLength:A(Te()),answerLength:A(Te())}))})),omitGeneralGuidelines:A(xe()),forceStripe:A(xe()),products:A(re({blocklistUrls:A(_t(N()))})),autoRefresh:A(re({enabled:A(xe()),intervalMins:A(Te())})),lang:A(N())});var vr=class extends bi{constructor(e){if(super(e),this.it=U,e.type!==xn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===U||e==null)return this._t=void 0,this.it=e;if(e===tt)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 t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};vr.directiveName="unsafeHTML",vr.resultType=1;var ac=kn(vr);var Yh=process.env.NODE_ENV==="production",Ro="Invariant failed";function lc(i,e){if(!i){if(Yh)throw new Error(Ro);var t=typeof e=="function"?e():e,r=t?"".concat(Ro,": ").concat(t):Ro;throw new Error(r)}}var Kh="\xB7 \xB7 \xB7",Zh=re({conversationId:A(N()),messages:A(_t(re({id:N(),timestamp:Te(),role:Ai(["user","assistant","support"]),content:N(),content_html:A(N())})))}),Qh=Ao(N(),To([N(),Te(),xe(),Io()])),ef=Rn(N(),$o(1),So(1e3)),Ti,Pi,Q,Do,On,_r,ue,yr,uc,cc,dc,pc,hc,fc,gc,Fo,Dn=class Dn extends X(H){constructor(){super();b(this,Q);b(this,Ti);b(this,Pi);b(this,_r,new Tn(this,{typingStarted:()=>f(this,ue).sendUserTypingStart(),typingStopped:()=>f(this,ue).sendUserTypingStop()}));b(this,ue,new An(this,{url:t=>{let r=new URL(this.config.wsApiUrl);return r.searchParams.set("widgetId",this.widgetId),r.searchParams.set("conversationId",t),r.searchParams.set("pageUrl",window.location.href),r},onReconnect:()=>{},onError:t=>{console.error("ws error",t)},onClose:()=>{},onNewMessage:t=>{t.role==="user"&&f(this,Q,Fo)?.scrollTo(0,f(this,Q,Fo).scrollHeight),t.role==="assistant"&&this.callbacks.onNewMessageStartedStreaming?.({widgetId:this.widgetId,message:t,conversationId:this.conversationId})},onMessageDone:(t,r)=>{r.role==="assistant"&&this.callbacks.onMessageEndedStreaming?.({widgetId:this.widgetId,text:r.content??"",message:r,usage_TOKENS_COMPLETION:t.message.usage.TOKENS_COMPLETION,conversationId:this.conversationId})},onMessageError:t=>{console.error("ws message error",t),t.message&&this.callbacks.onError?.({widgetId:this.widgetId,error:"WS: "+t.message})},onReset:()=>{localStorage.removeItem(f(this,Q,On))},onConnect:t=>{},persistConversationState:(t,r)=>{localStorage.setItem(f(this,Q,On),JSON.stringify({conversationId:t,messages:r}))},restoreConversationState:()=>{try{let t=JSON.parse(localStorage.getItem(f(this,Q,On))||"{}"),r=nc(Zh,t);return{conversationId:r.conversationId||"",messages:r.messages||[]}}catch(t){return console.error(t),{conversationId:"",messages:[]}}}}));b(this,yr,"single");this.config={},this.callbacks={},this.showClose=!1,this.xUserData="",this.xPromptExt=""}get widgetId(){return this.config.widgetId}get conversationId(){return f(this,ue).conversationId}get messages(){return f(this,ue).messages}firstUpdated(){I(this,Q,Do).call(this)}updated(){I(this,Q,Do).call(this)}render(){lc(this.config,"config is required");let t=ec(this.messages,r=>{try{let n=new Date(r.timestamp),s=Math.floor(n.getUTCMinutes()/5)*5;return n.setUTCMinutes(s,0,0),n.valueOf().toString()}catch(n){console.error(n)}});return L`
183
+ `;default:throw new Error(`Unknown side: ${this.side}`)}}};R(Cn,"properties",{side:{type:String},status:{type:String},color:{type:String},logoUrl:{type:String,attribute:"logo"},position:{type:String}});customElements.get("mw-chat-message")||customElements.define("mw-chat-message",Cn);var pr,je,ut,hr,wo,In=class{constructor(e,t){b(this,hr);b(this,pr);b(this,je);b(this,ut);if(!e)throw new Error("host is required");if(!t)throw new Error("config is required");$(this,pr,e),f(this,pr).addController(this),$(this,je,t)}connect(e){$(this,je,e),$(this,ut,I(this,hr,wo).call(this))}hostConnected(){setTimeout(()=>{$(this,ut,I(this,hr,wo).call(this))},0)}hostDisconnected(){f(this,ut)?.close(1e3,"lit_host_disconnected"),$(this,ut,void 0)}send(e){f(this,ut)?.send(e)}close(e,t){f(this,ut)?.close(e,t)}get isConnected(){return f(this,ut)?.readyState===WebSocket.OPEN}};pr=new WeakMap,je=new WeakMap,ut=new WeakMap,hr=new WeakSet,wo=function(){let e=new WebSocket(f(this,je).url());return f(this,je).onClose&&(e.onclose=f(this,je).onClose),f(this,je).onOpen&&(e.onopen=f(this,je).onOpen),f(this,je).onError&&(e.onerror=f(this,je).onError),f(this,je).onMessage&&(e.onmessage=f(this,je).onMessage),e};var Xu="664df22d-d461-42d6-801e-f70247e2cd7c",be,we,rt,Ei,$i,Se,Qt,Ju,Yu,Ku,Zu,An=class{constructor(e,t){b(this,Se);b(this,be);b(this,we);b(this,rt);R(this,"isStreaming",!1);R(this,"typingIndicator");R(this,"ranOutOfCredits",!1);R(this,"messages",[]);R(this,"conversationId","");b(this,Ei,0);b(this,$i);R(this,"isLiveMode",!1);$(this,be,e),$(this,we,t),$(this,rt,this.initWS()),e.addController(this)}sendUserInput(e,{xUserData:t,xPromptExt:r,role:n="user",expectStreaming:s=!1}={}){return I(this,Se,Qt).call(this,{type:"USER_INPUT",value:e,role:n,xUserData:t,xPromptExt:r},{expectStreaming:s})}sendUserCancel(){return I(this,Se,Qt).call(this,{type:"USER_CANCEL"})}sendUserTypingStart(){return I(this,Se,Qt).call(this,{type:"USER_TYPING_START"})}sendUserTypingStop(){return I(this,Se,Qt).call(this,{type:"USER_TYPING_STOP"})}reloadConfig(){I(this,Se,Qt).call(this,{type:"RELOAD_CONFIG"})}close(){f(this,rt).close(1e3,"closed by user")}retry(){clearTimeout(f(this,$i)),$(this,$i,setTimeout(()=>{f(this,we).onReconnect?.(),$(this,rt,this.initWS())},1e3*f(this,Ei))),Rl(this,Ei)._++}initWS(){return new In(f(this,be),{url:()=>f(this,we).url(this.conversationId,{}),onOpen:e=>I(this,Se,Ju).call(this,e),onMessage:e=>I(this,Se,Yu).call(this,JSON.parse(e.data)),onError:e=>I(this,Se,Ku).call(this,e),onClose:e=>I(this,Se,Zu).call(this,e)})}hostConnected(){this.conversationId=f(this,we).restoreConversationState?.()?.conversationId||"",this.messages=f(this,we).restoreConversationState?.()?.messages||[]}reset(){I(this,Se,Qt).call(this,{type:"NEW_CHAT"}),f(this,we).onReset?.(),this.isStreaming=!1,this.typingIndicator=void 0,this.ranOutOfCredits=!1,this.messages=[],this.conversationId="",this.isLiveMode=!1,f(this,be).requestUpdate()}hostDisconnected(){clearTimeout(f(this,$i))}reconnectSocket(){f(this,rt).close(1e3,"destroy"),$(this,rt,this.initWS())}get lastMsg(){if(this.messages.length>0)return this.messages[this.messages.length-1]}};be=new WeakMap,we=new WeakMap,rt=new WeakMap,Ei=new WeakMap,$i=new WeakMap,Se=new WeakSet,Qt=function(e,{expectStreaming:t=!1}={}){return f(this,rt).isConnected?(t&&!this.isLiveMode&&(this.isStreaming=!0,f(this,be).requestUpdate()),f(this,rt).send(JSON.stringify(e)),!0):(console.warn("WebSocket is not connected, message not sent - reconnecting now",e),this.retry(),!1)},Ju=function(e){$(this,Ei,0)},Yu=function(e){switch(e.type){case"NEW_MESSAGE":{this.messages=[...this.messages,e.message].filter((t,r,n)=>r===n.findIndex(s=>s.id===t.id)),this.typingIndicator=void 0,f(this,be).requestUpdate(),f(this,we).onNewMessage?.(e.message);break}case"UPDATE_MESSAGE":{let t=this.messages.find(r=>r.id===e.message.id);if(t)Object.assign(t,e.message),f(this,be).requestUpdate(),f(this,we).onUpdateMessage?.(e);else throw new Error(`Message with id ${e.message.id} not found`);break}case"MESSAGE_DONE":{let t=this.messages.find(r=>r.id===e.message.id);if(t)Object.assign(t,e.message);else throw new Error(`Message with id ${e.message.id} not found`);this.isStreaming=!1,f(this,be).requestUpdate(),f(this,we).onMessageDone?.(e,t),f(this,we).persistConversationState?.(this.conversationId,this.messages);break}case"MESSAGE_CANCEL":{this.isStreaming=!1,this.typingIndicator=void 0,f(this,be).requestUpdate();break}case"ERROR":{f(this,we).onMessageError?.(e);break}case"CONNECTED":{this.conversationId=e.conversationId,this.messages=e.messages,f(this,we).onConnect?.(e.conversationId),f(this,we).persistConversationState?.(this.conversationId,this.messages),this.isLiveMode=e.metadata?.isLiveMode,f(this,be).requestUpdate();break}case"TYPING_START":{e.role==="assistant"&&(this.isStreaming=!0),this.typingIndicator={role:e.role,metadata:e.metadata},f(this,be).requestUpdate();break}case"TYPING_STOP":{this.typingIndicator=void 0,f(this,be).requestUpdate();break}case"RAN_OUT_OF_CREDITS":{this.messages.some(t=>t.id===Xu)||this.messages.push({id:Xu,role:"assistant",content:"Sorry, I've run out of credits. Please contact the shop directly.",timestamp:Date.now()}),this.ranOutOfCredits=!0,f(this,be).requestUpdate();break}case"RECONNECT":{this.reconnectSocket(),f(this,be).requestUpdate();break}default:console.warn(`Unknown message type: ${JSON.stringify(e)}`)}},Ku=function(e){console.error("onError",e),f(this,we).onError?.(e)},Zu=function(e){f(this,be).isConnected&&!f(this,rt).isConnected&&e.reason==="reconnect"&&this.retry(),this.isStreaming=!1,this.typingIndicator=void 0,f(this,be).requestUpdate(),f(this,we).onClose?.()};var fr,Ci,Pt,ei,Pn,Qu,Tn=class{constructor(e,t,{timeoutMs:r=2e3}={}){b(this,Pn);b(this,fr);b(this,Ci);b(this,Pt);b(this,ei,!1);R(this,"timeoutMs");$(this,fr,e),$(this,Ci,t),this.timeoutMs=r,e.addController(this)}get isTyping(){return f(this,ei)}hostDisconnected(){clearTimeout(f(this,Pt)),$(this,Pt,void 0)}onInput(e){if(f(this,fr).isConnected){if(!e.trim()){this.typingStopped();return}clearTimeout(f(this,Pt)),$(this,Pt,setTimeout(()=>this.typingStopped(),this.timeoutMs)),f(this,ei)||I(this,Pn,Qu).call(this)}}typingStopped(){clearTimeout(f(this,Pt)),$(this,ei,!1),f(this,Ci).typingStopped()}};fr=new WeakMap,Ci=new WeakMap,Pt=new WeakMap,ei=new WeakMap,Pn=new WeakSet,Qu=function(){$(this,ei,!0),f(this,Ci).typingStarted()};function ec(i,e){let t=new Map;for(let r of i){let n=e(r);t.has(n)||t.set(n,[]),(t.get(n)||[]).push(r)}return t}function tc(i,e="en-US"){let t=new Intl.DateTimeFormat(e,{hour:"numeric",minute:"numeric"}).format(i);return`${i.toLocaleDateString(e,{year:"numeric",month:"short",day:"numeric"})}, ${t}`}var xo;function ko(i){return{lang:i?.lang??xo?.lang,message:i?.message,abortEarly:i?.abortEarly??xo?.abortEarly,abortPipeEarly:i?.abortPipeEarly??xo?.abortPipeEarly}}var jh;function qh(i){return jh?.get(i)}var Bh;function Hh(i){return Bh?.get(i)}var zh;function Wh(i,e){return zh?.get(i)?.get(e)}function Ii(i){let e=typeof i;return e==="string"?`"${i}"`:e==="number"||e==="bigint"||e==="boolean"?`${i}`:e==="object"||e==="function"?(i&&Object.getPrototypeOf(i)?.constructor?.name)??"null":e}function qe(i,e,t,r,n){let s=n&&"input"in n?n.input:t.value,o=n?.expected??i.expects??null,l=n?.received??Ii(s),a={kind:i.kind,type:i.type,input:s,expected:o,received:l,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${l}`,requirement:i.requirement,path:n?.path,issues:n?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=i.kind==="schema",d=n?.message??i.message??Wh(i.reference,a.lang)??(c?Hh(a.lang):null)??r.message??qh(a.lang);d&&(a.message=typeof d=="function"?d(a):d),c&&(t.typed=!1),t.issues?t.issues.push(a):t.issues=[a]}function nt(i){return{version:1,vendor:"valibot",validate(e){return i["~run"]({value:e},ko())}}}function Vh(i,e){return Object.hasOwn(i,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function rc(i,e){let t=[...new Set(i)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}var Gh=class extends Error{constructor(e){super(e[0].message);R(this,"issues");this.name="ValiError",this.issues=e}};function So(i,e){return{kind:"validation",type:"max_length",reference:So,async:!1,expects:`<=${i}`,requirement:i,message:e,"~run"(t,r){return t.typed&&t.value.length>this.requirement&&qe(this,"length",t,r,{received:`${t.value.length}`}),t}}}function Eo(i,e){return{kind:"validation",type:"max_value",reference:Eo,async:!1,expects:`<=${i instanceof Date?i.toJSON():Ii(i)}`,requirement:i,message:e,"~run"(t,r){return t.typed&&!(t.value<=this.requirement)&&qe(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():Ii(t.value)}),t}}}function $o(i,e){return{kind:"validation",type:"min_length",reference:$o,async:!1,expects:`>=${i}`,requirement:i,message:e,"~run"(t,r){return t.typed&&t.value.length<this.requirement&&qe(this,"length",t,r,{received:`${t.value.length}`}),t}}}function Co(i,e){return{kind:"validation",type:"min_value",reference:Co,async:!1,expects:`>=${i instanceof Date?i.toJSON():Ii(i)}`,requirement:i,message:e,"~run"(t,r){return t.typed&&!(t.value>=this.requirement)&&qe(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():Ii(t.value)}),t}}}function Xh(i,e,t){return typeof i.default=="function"?i.default(e,t):i.default}function _t(i,e){return{kind:"schema",type:"array",reference:_t,expects:"Array",async:!1,item:i,message:e,get"~standard"(){return nt(this)},"~run"(t,r){let n=t.value;if(Array.isArray(n)){t.typed=!0,t.value=[];for(let s=0;s<n.length;s++){let o=n[s],l=this.item["~run"]({value:o},r);if(l.issues){let a={type:"array",origin:"value",input:n,key:s,value:o};for(let c of l.issues)c.path?c.path.unshift(a):c.path=[a],t.issues?.push(c);if(t.issues||(t.issues=l.issues),r.abortEarly){t.typed=!1;break}}l.typed||(t.typed=!1),t.value.push(l.value)}}else qe(this,"type",t,r);return t}}}function xe(i){return{kind:"schema",type:"boolean",reference:xe,expects:"boolean",async:!1,message:i,get"~standard"(){return nt(this)},"~run"(e,t){return typeof e.value=="boolean"?e.typed=!0:qe(this,"type",e,t),e}}}function Io(i){return{kind:"schema",type:"null",reference:Io,expects:"null",async:!1,message:i,get"~standard"(){return nt(this)},"~run"(e,t){return e.value===null?e.typed=!0:qe(this,"type",e,t),e}}}function Te(i){return{kind:"schema",type:"number",reference:Te,expects:"number",async:!1,message:i,get"~standard"(){return nt(this)},"~run"(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:qe(this,"type",e,t),e}}}function re(i,e){return{kind:"schema",type:"object",reference:re,expects:"Object",async:!1,entries:i,message:e,get"~standard"(){return nt(this)},"~run"(t,r){let n=t.value;if(n&&typeof n=="object"){t.typed=!0,t.value={};for(let s in this.entries){let o=n[s],l=this.entries[s]["~run"]({value:o},r);if(l.issues){let a={type:"object",origin:"value",input:n,key:s,value:o};for(let c of l.issues)c.path?c.path.unshift(a):c.path=[a],t.issues?.push(c);if(t.issues||(t.issues=l.issues),r.abortEarly){t.typed=!1;break}}l.typed||(t.typed=!1),(l.value!==void 0||s in n)&&(t.value[s]=l.value)}}else qe(this,"type",t,r);return t}}}function A(i,e){return{kind:"schema",type:"optional",reference:A,expects:`(${i.expects} | undefined)`,async:!1,wrapped:i,default:e,get"~standard"(){return nt(this)},"~run"(t,r){return t.value===void 0&&(this.default!==void 0&&(t.value=Xh(this,t,r)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,r)}}}function Ai(i,e){return{kind:"schema",type:"picklist",reference:Ai,expects:rc(i.map(Ii),"|"),async:!1,options:i,message:e,get"~standard"(){return nt(this)},"~run"(t,r){return this.options.includes(t.value)?t.typed=!0:qe(this,"type",t,r),t}}}function Ao(i,e,t){return{kind:"schema",type:"record",reference:Ao,expects:"Object",async:!1,key:i,value:e,message:t,get"~standard"(){return nt(this)},"~run"(r,n){let s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(let o in s)if(Vh(s,o)){let l=s[o],a=this.key["~run"]({value:o},n);if(a.issues){let d={type:"object",origin:"key",input:s,key:o,value:l};for(let u of a.issues)u.path=[d],r.issues?.push(u);if(r.issues||(r.issues=a.issues),n.abortEarly){r.typed=!1;break}}let c=this.value["~run"]({value:l},n);if(c.issues){let d={type:"object",origin:"value",input:s,key:o,value:l};for(let u of c.issues)u.path?u.path.unshift(d):u.path=[d],r.issues?.push(u);if(r.issues||(r.issues=c.issues),n.abortEarly){r.typed=!1;break}}(!a.typed||!c.typed)&&(r.typed=!1),a.typed&&(r.value[a.value]=c.value)}}else qe(this,"type",r,n);return r}}}function N(i){return{kind:"schema",type:"string",reference:N,expects:"string",async:!1,message:i,get"~standard"(){return nt(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:qe(this,"type",e,t),e}}}function ic(i){let e;if(i)for(let t of i)e?e.push(...t.issues):e=t.issues;return e}function To(i,e){return{kind:"schema",type:"union",reference:To,expects:rc(i.map(t=>t.expects),"|"),async:!1,options:i,message:e,get"~standard"(){return nt(this)},"~run"(t,r){let n,s,o;for(let l of this.options){let a=l["~run"]({value:t.value},r);if(a.typed)if(a.issues)s?s.push(a):s=[a];else{n=a;break}else o?o.push(a):o=[a]}if(n)return n;if(s){if(s.length===1)return s[0];qe(this,"type",t,r,{issues:ic(s)}),t.typed=!0}else{if(o?.length===1)return o[0];qe(this,"type",t,r,{issues:ic(o)})}return t}}}function nc(i,e,t){let r=i["~run"]({value:e},ko(t));if(r.issues)throw new Gh(r.issues);return r.value}function Rn(...i){return{...i[0],pipe:i,get"~standard"(){return nt(this)},"~run"(e,t){for(let r of i)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r["~run"](e,t))}return e}}}function Po(i,e,t){let r=i["~run"]({value:e},ko(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var gr={SCRAPER:"scraper",UNAS:"unas",SHOPRENTER:"shoprenter",SHOPIFY:"shopify",SHOPER:"shoper"},Jh=Object.freeze([gr.UNAS,gr.SHOPRENTER,gr.SHOPIFY,gr.SHOPER]),oc=Object.freeze([...Jh,gr.SCRAPER]);var Am=re({wsApiUrl:N(),url:N(),logoUrl:A(N()),title:N(),status:N(),color:N(),showStillLearningBanner:A(xe()),allowedOrigins:A(_t(N())),input:re({placeholder:N()}),bubble:re({imageUrl:A(N()),position:re({bottom:A(N()),right:A(N()),left:A(N())}),mobilePosition:A(re({bottom:A(N()),right:A(N()),left:A(N())})),zIndex:A(Te())}),examples:re({title:N(),items:_t(N())}),instructions:re({items:_t(N()),limit:A(Te())}),popup:A(re({mobileEnabled:A(xe()),desktopEnabled:A(xe()),delayMs:A(Te()),text:A(N()),mobileTitleText:A(N()),mobileButtonText:A(N())})),tryItOut:A(re({mobileEnabled:A(xe()),desktopEnabled:A(xe()),text:A(N())})),contactDetails:A(re({email:A(N()),phone:A(N()),socialMedia:A(re({facebook:A(N()),instagram:A(N()),twitter:A(N())}))})),notifications:A(re({email:A(N())})),neverShowStillLearningBanner:A(xe()),hidden:A(xe()),newChatTitle:A(N()),webhookURL:A(N()),automatedResponse:A(re({enabled:A(xe()),text:A(N()),latencyThresholdMs:A(Te())})),removePoweredBy:A(xe()),claimable:A(xe()),feed:A(N()),scraper:A(Ai(["netkazan","jateknet","json-schema-org","arukereso-xml","partocean","google-rev1"])),scraperAuthorization:A(N()),platform:A(Ai(oc)),workingHours:A(re({dailyAvailability:_t(re({dayOfWeek:Rn(Te(),Co(0),Eo(6)),startTime:N(),endTime:N(),isActive:xe()})),userTimeZone:A(N())})),planOverrides:A(re({maxProducts:A(Te()),conversations:A(Te()),faqs:A(re({max:A(Te()),questionLength:A(Te()),answerLength:A(Te())}))})),omitGeneralGuidelines:A(xe()),forceStripe:A(xe()),products:A(re({blocklistUrls:A(_t(N()))})),autoRefresh:A(re({enabled:A(xe()),intervalMins:A(Te())})),lang:A(N())});var vr=class extends bi{constructor(e){if(super(e),this.it=U,e.type!==xn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===U||e==null)return this._t=void 0,this.it=e;if(e===tt)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 t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};vr.directiveName="unsafeHTML",vr.resultType=1;var ac=kn(vr);var Yh=!0,Ro="Invariant failed";function lc(i,e){if(!i){if(Yh)throw new Error(Ro);var t=typeof e=="function"?e():e,r=t?"".concat(Ro,": ").concat(t):Ro;throw new Error(r)}}var Kh="\xB7 \xB7 \xB7",Zh=re({conversationId:A(N()),messages:A(_t(re({id:N(),timestamp:Te(),role:Ai(["user","assistant","support"]),content:N(),content_html:A(N())})))}),Qh=Ao(N(),To([N(),Te(),xe(),Io()])),ef=Rn(N(),$o(1),So(1e3)),Ti,Pi,Q,Do,On,_r,ue,yr,uc,cc,dc,pc,hc,fc,gc,Fo,Dn=class Dn extends X(H){constructor(){super();b(this,Q);b(this,Ti);b(this,Pi);b(this,_r,new Tn(this,{typingStarted:()=>f(this,ue).sendUserTypingStart(),typingStopped:()=>f(this,ue).sendUserTypingStop()}));b(this,ue,new An(this,{url:t=>{let r=new URL(this.config.wsApiUrl);return r.searchParams.set("widgetId",this.widgetId),r.searchParams.set("conversationId",t),r.searchParams.set("pageUrl",window.location.href),r},onReconnect:()=>{},onError:t=>{console.error("ws error",t)},onClose:()=>{},onNewMessage:t=>{t.role==="user"&&f(this,Q,Fo)?.scrollTo(0,f(this,Q,Fo).scrollHeight),t.role==="assistant"&&this.callbacks.onNewMessageStartedStreaming?.({widgetId:this.widgetId,message:t,conversationId:this.conversationId})},onMessageDone:(t,r)=>{r.role==="assistant"&&this.callbacks.onMessageEndedStreaming?.({widgetId:this.widgetId,text:r.content??"",message:r,usage_TOKENS_COMPLETION:t.message.usage.TOKENS_COMPLETION,conversationId:this.conversationId})},onMessageError:t=>{console.error("ws message error",t),t.message&&this.callbacks.onError?.({widgetId:this.widgetId,error:"WS: "+t.message})},onReset:()=>{localStorage.removeItem(f(this,Q,On))},onConnect:t=>{},persistConversationState:(t,r)=>{localStorage.setItem(f(this,Q,On),JSON.stringify({conversationId:t,messages:r}))},restoreConversationState:()=>{try{let t=JSON.parse(localStorage.getItem(f(this,Q,On))||"{}"),r=nc(Zh,t);return{conversationId:r.conversationId||"",messages:r.messages||[]}}catch(t){return console.error(t),{conversationId:"",messages:[]}}}}));b(this,yr,"single");this.config={},this.callbacks={},this.showClose=!1,this.xUserData="",this.xPromptExt=""}get widgetId(){return this.config.widgetId}get conversationId(){return f(this,ue).conversationId}get messages(){return f(this,ue).messages}firstUpdated(){I(this,Q,Do).call(this)}updated(){I(this,Q,Do).call(this)}render(){lc(this.config,"config is required");let t=ec(this.messages,r=>{try{let n=new Date(r.timestamp),s=Math.floor(n.getUTCMinutes()/5)*5;return n.setUTCMinutes(s,0,0),n.valueOf().toString()}catch(n){console.error(n)}});return L`
184
184
  <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]">
185
185
  <div
186
186
  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]">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molin.ai/shop-ai",
3
- "version": "0.7.12",
3
+ "version": "0.7.14",
4
4
  "description": "Molin Shop AI",
5
5
  "keywords": [
6
6
  "molin",
@@ -21,8 +21,8 @@
21
21
  "type": "module",
22
22
  "browser": "dist/molin-shop-ai.min.js",
23
23
  "scripts": {
24
- "start": "esbuild molin-shop-ai=./src/molin-shop-ai.js --bundle --watch --target=es2021 --platform=neutral --sourcemap=inline --main-fields=es2015,browser,module,main --conditions=browser,module,import --outdir=demo/dist --servedir=demo",
25
- "build": "esbuild molin-shop-ai.min=./src/molin-shop-ai.js --bundle --minify --analyze --target=es2021 --platform=neutral --main-fields=es2015,browser,module,main --conditions=browser,module,import --outdir=dist",
24
+ "start": "esbuild molin-shop-ai=./src/molin-shop-ai.js --bundle --watch --target=es2021 --platform=neutral --sourcemap=inline --main-fields=es2015,browser,module,main --define:process.env.NODE_ENV=\\\"development\\\" --conditions=browser,module,import --outdir=demo/dist --servedir=demo",
25
+ "build": "esbuild molin-shop-ai.min=./src/molin-shop-ai.js --bundle --minify --analyze --target=es2021 --platform=neutral --main-fields=es2015,browser,module,main --define:process.env.NODE_ENV=\\\"production\\\" --conditions=browser,module,import --outdir=dist",
26
26
  "prepublishOnly": "npm run build",
27
27
  "publish:latest": "npm publish --access public --tag latest",
28
28
  "publish:beta": "npm publish --access public --tag beta"