shopify-chatbot-widget 0.6.1 → 0.6.2

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.
@@ -681,4 +681,4 @@ html body {
681
681
  userAgent: `).concat(navigator.userAgent,`
682
682
  timeBetweenLoadAndGet: `).concat(o-a,`
683
683
  visitorId: `).concat(f.visitorId,`
684
- components: `).concat(sL(c),"\n```")),[2,f]}})})}}}function wre(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open("get","https://m1.openfpcdn.io/fingerprintjs/v".concat(V5,"/npm-monitoring"),!0),e.send()}catch(t){console.error(t)}}function Tre(e){var t;return e===void 0&&(e={}),eu(this,void 0,void 0,function(){var a,r,o;return tu(this,function(c){switch(c.label){case 0:return(!((t=e.monitoring)!==null&&t!==void 0)||t)&&wre(),a=e.delayFallback,r=e.debug,[4,Cre(a)];case 1:return c.sent(),o=pre({cache:{},debug:r}),[2,Ere(o,r)]}})})}var Ore={load:Tre,hashComponents:uL,componentsToDebugString:sL};const Rre=()=>{const[e,t]=x.useState(!1),[a,r]=x.useState("sessions"),[o,c]=x.useState(null),[f,m]=x.useState(!1),[g,p]=x.useState(""),[y,S]=x.useState(""),[E,T]=x.useState(!1),{chatbotLogo:O,colorCode:M,messagesSuggestions:A,disableForm:D,merchantPhone:_,userType:j,calendly:V,disbleCheckout:N}=DH(),[L,H]=x.useState(null),z=()=>{if(!D&&!f){r("create");return}else{const X=crypto.randomUUID();c(X),S(O),p("Ai Agent"),console.log(X),T(!0),r("messenger")}};x.useEffect(()=>{(async()=>{try{let W=localStorage.getItem("visitor_id"),Z=localStorage.getItem("ip_address"),ie=localStorage.getItem("country");if(W||(W=(await(await Ore.load()).get()).visitorId,localStorage.setItem("visitor_id",W)),!Z||!ie){const F=await(await fetch("https://ipapi.co/json")).json();Z=F.ip,ie=F.country_name,Z&&localStorage.setItem("ip_address",Z),ie&&localStorage.setItem("country",ie)}if(W&&Z&&ie){H({visitorId:W,country:ie});const F=await(await fetch(`${bi.apiUrl}register-ip/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ip_address:Z,country:ie,visitor_id:W})})).json();m(F.has_user_info||!1)}else console.warn("Missing IP or country info after fetch")}catch(W){console.error("Failed to fetch or send visitor info",W)}})()},[]);const U=(X,W,Z)=>{c(X),p(W),S(Z),T(!1),r("messenger")};x.useEffect(()=>{const X=W=>{const Z=W.data||{};Z.type==="JAWEB_CHAT"&&(Z.action==="open-ready"?(console.log("OPENING"),t(!0)):Z.action==="closed"&&t(!1))};return window.addEventListener("message",X),()=>window.removeEventListener("message",X)},[]);const B=()=>{window.parent?.postMessage({type:"JAWEB_CHAT",action:"open"},"*")},ee=()=>{window.parent?.postMessage({type:"JAWEB_CHAT",action:"close"},"*")};return ae.jsx("div",{children:e&&ae.jsxs("div",{className:"chatbot-box",children:[a==="sessions"&&ae.jsx(IZ,{chatbotLogo:O,Phone:_||"",colorCode:M,visitorId:L?.visitorId||"",Opened:e,setOpen:X=>X?B():ee(),onNewSession:z,onSessionSelect:U}),a==="create"&&ae.jsx(FZ,{colorCode:M,visitorId:L?.visitorId||"",country:L?.country||"",onBack:()=>r("sessions"),onCreate:X=>{c(X.session_id),m(X.hasInfo),r("messenger")}}),a==="messenger"&&o&&ae.jsx(pne,{sessionId:o,chatbotLogo:y||O,agentName:g||"Ai Assistant",colorCode:M,messagesSuggestions:A,newSession:E,disableForm:D,calendly:V??"",setOpen:X=>X?B():ee(),setNewSession:T,Opened:e,setView:()=>r("sessions"),userType:j,disbleCheckout:N})]})})},cL="jaweb-chatbot-container";if(!document.getElementById(cL)){const e=document.createElement("div");e.id=cL,document.body.appendChild(e),E8.createRoot(e).render(ae.jsx(Rre,{}))}})();
684
+ components: `).concat(sL(c),"\n```")),[2,f]}})})}}}function wre(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open("get","https://m1.openfpcdn.io/fingerprintjs/v".concat(V5,"/npm-monitoring"),!0),e.send()}catch(t){console.error(t)}}function Tre(e){var t;return e===void 0&&(e={}),eu(this,void 0,void 0,function(){var a,r,o;return tu(this,function(c){switch(c.label){case 0:return(!((t=e.monitoring)!==null&&t!==void 0)||t)&&wre(),a=e.delayFallback,r=e.debug,[4,Cre(a)];case 1:return c.sent(),o=pre({cache:{},debug:r}),[2,Ere(o,r)]}})})}var Ore={load:Tre,hashComponents:uL,componentsToDebugString:sL};const Rre=()=>{const[e,t]=x.useState(!1),[a,r]=x.useState("sessions"),[o,c]=x.useState(null),[f,m]=x.useState(!1),[g,p]=x.useState(""),[y,S]=x.useState(""),[E,T]=x.useState(!1),{chatbotLogo:O,colorCode:M,messagesSuggestions:A,disableForm:D,merchantPhone:_,userType:j,calendly:V,disbleCheckout:N}=DH(),[L,H]=x.useState(null),z=()=>{if(!D&&!f){r("create");return}else{const X=crypto.randomUUID();c(X),S(O),p("Ai Agent"),console.log(X),T(!0),r("messenger")}};x.useEffect(()=>{(async()=>{try{let W=localStorage.getItem("visitor_id"),Z=localStorage.getItem("ip_address"),ie=localStorage.getItem("country");if(W||(W=(await(await Ore.load()).get()).visitorId,localStorage.setItem("visitor_id",W)),!Z||!ie){const F=await(await fetch("https://ipapi.co/json")).json();Z=F.ip,ie=F.country_name,Z&&localStorage.setItem("ip_address",Z),ie&&localStorage.setItem("country",ie)}if(W&&Z&&ie){H({visitorId:W,country:ie});const F=await(await fetch(`${bi.apiUrl}register-ip/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ip_address:Z,country:ie,visitor_id:W})})).json();m(F.has_user_info||!1)}else console.warn("Missing IP or country info after fetch")}catch(W){console.error("Failed to fetch or send visitor info",W)}})()},[]);const U=(X,W,Z)=>{c(X),p(W),S(Z),T(!1),r("messenger")};x.useEffect(()=>{const X=W=>{const Z=W.data||{};if(Z.type!=="JAWEB_CHAT")return"NOT VALID TYPE";if(Z.action==="open-ready")console.log("OPENING"),t(!0);else if(Z.action==="closed")t(!1);else return"NOT VALUD"};return window.addEventListener("message",X),()=>window.removeEventListener("message",X)},[]);const B=()=>{window.parent?.postMessage({type:"JAWEB_CHAT",action:"open"},"*")},ee=()=>{window.parent?.postMessage({type:"JAWEB_CHAT",action:"close"},"*")};return ae.jsx("div",{children:e&&ae.jsxs("div",{className:"chatbot-box",children:[a==="sessions"&&ae.jsx(IZ,{chatbotLogo:O,Phone:_||"",colorCode:M,visitorId:L?.visitorId||"",Opened:e,setOpen:X=>X?B():ee(),onNewSession:z,onSessionSelect:U}),a==="create"&&ae.jsx(FZ,{colorCode:M,visitorId:L?.visitorId||"",country:L?.country||"",onBack:()=>r("sessions"),onCreate:X=>{c(X.session_id),m(X.hasInfo),r("messenger")}}),a==="messenger"&&o&&ae.jsx(pne,{sessionId:o,chatbotLogo:y||O,agentName:g||"Ai Assistant",colorCode:M,messagesSuggestions:A,newSession:E,disableForm:D,calendly:V??"",setOpen:X=>X?B():ee(),setNewSession:T,Opened:e,setView:()=>r("sessions"),userType:j,disbleCheckout:N})]})})},cL="jaweb-chatbot-container";if(!document.getElementById(cL)){const e=document.createElement("div");e.id=cL,document.body.appendChild(e),E8.createRoot(e).render(ae.jsx(Rre,{}))}})();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shopify-chatbot-widget",
3
3
  "private": false,
4
- "version": "0.6.1",
4
+ "version": "0.6.2",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",