react-aichatbot-widget 2.0.0 → 2.0.1

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.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),x=require("react"),v=require("lucide-react"),E=({onMinimise:o,isOpen:t,theme:r,chatBotData:i})=>{const f=i.position==="left",d=f?"32px":"auto",p=f?"auto":"32px",u=localStorage.getItem("clone67ChatSessionId"),g={position:"fixed",bottom:"32px",left:d,right:p,background:`linear-gradient(135deg, ${r.primaryColor}, ${r.secondaryColor})`,color:r.fontColor,width:"64px",height:"64px",borderRadius:"50%",border:"none",boxShadow:"0 20px 25px -5px rgba(0,0,0,0.15), 0 10px 10px -5px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",pointerEvents:"auto",transition:"all 300ms ease",outline:"none"},h={position:"absolute",top:"-4px",right:"-4px",width:"16px",height:"16px",backgroundColor:"#34d399",borderRadius:"50%",border:"4px solid white",animation:"pulse 2s infinite"};return e.jsxs("button",{onClick:o,style:g,children:[t?e.jsx(v.Minus,{size:20,strokeWidth:2.5}):e.jsx(v.MessageCircle,{size:20,strokeWidth:2.5}),!t&&u&&e.jsx("span",{style:h})]})},a=[];for(let o=0;o<256;++o)a.push((o+256).toString(16).slice(1));function T(o,t=0){return(a[o[t+0]]+a[o[t+1]]+a[o[t+2]]+a[o[t+3]]+"-"+a[o[t+4]]+a[o[t+5]]+"-"+a[o[t+6]]+a[o[t+7]]+"-"+a[o[t+8]]+a[o[t+9]]+"-"+a[o[t+10]]+a[o[t+11]]+a[o[t+12]]+a[o[t+13]]+a[o[t+14]]+a[o[t+15]]).toLowerCase()}let W;const M=new Uint8Array(16);function D(){if(!W){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");W=crypto.getRandomValues.bind(crypto)}return W(M)}const L=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),R={randomUUID:L};function $(o,t,r){o=o||{};const i=o.random??o.rng?.()??D();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,T(i)}function U(o,t,r){return R.randomUUID&&!o?R.randomUUID():$(o)}const B=({messages:o,chatBotData:t,theme:r,isLoading:i})=>{const[f,d]=x.useState([]),p=x.useRef(null),u=s=>{if(s==="")return null;try{return JSON.parse(s)}catch(y){return console.error("Error parsing message string to JSON:",y),null}},g=s=>new Date(s).toLocaleString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0});x.useEffect(()=>{const s=u(o);s&&d(y=>[...y,s])},[o]),x.useEffect(()=>{p.current?.scrollIntoView({behavior:"smooth"})},[f]);const h=f.flat(),S={height:"290px",overflowY:"auto",padding:"20px",background:r.backgroundColor,color:r.fontColor,borderTop:"1px solid rgba(255, 255, 255, 0.2)",display:"flex",flexDirection:"column",gap:"16px"},c=s=>({display:"flex",justifyContent:s==="user"?"flex-end":"flex-start",width:"100%"}),m={display:"flex",flexDirection:"column",maxWidth:"80%"},b=s=>({padding:"12px 16px",borderRadius:s==="user"?"16px 0 16px 16px":"0 16px 16px 16px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",fontSize:"14px",lineHeight:"1.5",background:s==="user"?r.primaryColor:"#f5f5f5",color:r.fontColor,wordWrap:"break-word"}),C={...b("bot"),animation:"fadeIn 0.3s ease-in-out, pulse 1.5s ease-in-out infinite",animationDelay:"0s, 0.3s"};return e.jsxs("div",{style:S,children:[h.map((s,y)=>e.jsx("div",{style:c(s.sender_type),children:e.jsxs("div",{style:m,children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:s.sender_type==="user"?"flex-end":"flex-start",marginRight:"4px",marginBottom:"2px"},children:e.jsx("span",{style:{fontSize:"10px",opacity:.55,color:r.fontColor},children:s.sender_type==="user"?"You":`${t.name}`})}),e.jsx("div",{style:s.sender_type==="user"?b("user"):b("ai"),children:s.message}),e.jsx("span",{style:{fontSize:"10px",opacity:.55,color:r.fontColor,alignSelf:s.sender_type==="user"?"flex-end":"flex-start",marginTop:"4px"},children:`${g(s.created_at)}`})]})},y)),i&&e.jsx("div",{style:C,children:"Typing..."}),e.jsx("div",{ref:p})]})},O=(o,t)=>({socket:new WebSocket(`wss://handle-chat-session.clone67.com?chatbotNamespace=${t}&sessionId=${o}`)}),F=({chatBotData:o,theme:t,onlineStatus:r})=>{const[i,f]=x.useState(null),[d,p]=x.useState(""),[u,g]=x.useState("Connecting to server..."),[h,S]=x.useState(""),[c,m]=x.useState(!1);x.useEffect(()=>{var n=localStorage.getItem("clone67ChatSessionId");n===null&&(n=U(),localStorage.setItem("clone67ChatSessionId",n));const{socket:l}=O(n,o.pineconeNamespace);f(l),l.onopen=()=>{g("Server connected"),setTimeout(()=>{g("")},2e3),r("online")},l.onmessage=async I=>{m(!0);try{const z=await I.data;S(z)}catch(z){console.error("Error handling server message:",z)}finally{m(!1)}},l.onerror=I=>{g("Server error occurred"),console.error("WebSocket error:",I),r("offline")},l.onclose=()=>{g("Server disconnected"),r("offline")}},[]);const b=async()=>{i&&i.readyState===WebSocket.OPEN&&i.send(JSON.stringify(d));const n={created_at:Date.now(),sender_type:"user",message:d};S(JSON.stringify(n)),p("")},C=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),b())},s={flex:1,padding:"12px 16px",background:t.backgroundColor,color:t.fontColor,border:`1px solid ${t.fontColor}`,borderRadius:"12px",fontSize:"14px",outline:"none",transition:"all 0.2s ease",opacity:c?.5:1,cursor:c?"not-allowed":"text",boxShadow:"none"},y={padding:"12px 20px",borderRadius:"12px",background:`linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,color:t.fontColor,border:"none",cursor:c||!d.trim()?"not-allowed":"pointer",opacity:c||!d.trim()?.5:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",fontWeight:"600",fontSize:"14px",transition:"all 0.2s ease",minWidth:"48px"},k={padding:"16px",borderTop:"1px solid rgba(255, 255, 255, 0.2)",borderColor:t.fontColor,background:t.backgroundColor,flexShrink:0},w={display:"flex",gap:"12px",alignItems:"center"},j={textAlign:"center",padding:"2px",backgroundColor:u==="Server connected"||u==="online"?"#09BA00":u==="Connecting to server..."?"#DED000":"#FF3408",color:"#ffffff",fontSize:"10px"};return e.jsxs("div",{children:[u&&e.jsx("p",{style:j,children:u}),e.jsx(B,{messages:h,chatBotData:o,theme:t,isLoading:c}),e.jsx("div",{style:k,children:e.jsxs("form",{onSubmit:b,style:w,children:[e.jsx("input",{type:"text",placeholder:"Type a message...",value:d,onChange:n=>p(n.target.value),onKeyDown:C,disabled:c,style:s,onFocus:n=>{n.target.style.boxShadow="0 0 0 3px rgba(100, 150, 255, 0.3)",n.target.style.borderColor="#60a5fa"},onBlur:n=>{n.target.style.boxShadow="none",n.target.style.borderColor=t.fontColor}}),e.jsx("button",{onClick:b,disabled:c||!d.trim(),style:y,"aria-label":"Send message",onMouseEnter:n=>{!c&&d.trim()&&(n.currentTarget.style.transform="translateY(-2px)",n.currentTarget.style.boxShadow="0 8px 16px rgba(0,0,0,0.15)")},onMouseLeave:n=>{n.currentTarget.style.transform="translateY(0)",n.currentTarget.style.boxShadow="none"},children:e.jsx(v.Send,{size:18})})]})})]})},N=({onClose:o,theme:t,chatBotData:r})=>{const[i,f]=x.useState(!1),[d,p]=x.useState(!1),g={position:"fixed",bottom:"112px",[r.position==="left"?"left":"right"]:"32px",zIndex:50,width:i?"684px":"384px",height:i?"620px":"520px",background:`${t.backgroundColor}cc`,backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",borderRadius:"16px",border:"1px solid rgba(255, 255, 255, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif",boxShadow:"0 10px 25px -3px rgba(0,0,0,0.1)"},h={padding:"16px 20px",background:`linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,color:t.fontColor,borderRadius:"16px 16px 0 0",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1)"},S={position:"relative"},c={width:"44px",height:"44px",borderRadius:"50%",background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center"},m={position:"absolute",bottom:0,right:0,width:"14px",height:"14px",backgroundColor:d?"#00BF49":"#F54927",borderRadius:"50%",border:"3px solid white"},b={fontSize:"18px",fontWeight:"600",margin:0,lineHeight:"1.2"},C={fontSize:"12px",opacity:.9,margin:0,lineHeight:"1.3"},s={padding:"8px",borderRadius:"50%",background:"transparent",border:"none",cursor:"pointer",transition:"background 0.2s"},y={padding:"12px 20px",borderTop:"1px solid rgba(255,255,255,0.2)",background:t.backgroundColor,textAlign:"center"},k={fontSize:"11px",color:t.fontColor,letterSpacing:"0.5px"},w={fontWeight:"600"},j=(l,I)=>{l.currentTarget.style.background=I?"rgba(255,255,255,0.2)":"transparent"},n=l=>{p(l==="online")};return e.jsxs("div",{style:g,children:[e.jsxs("div",{style:h,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsxs("div",{style:S,children:[e.jsx("div",{style:c,children:e.jsx(v.MessageCircle,{size:22})}),e.jsx("span",{style:m})]}),e.jsxs("div",{children:[e.jsx("h3",{style:b,children:r.name}),e.jsx("p",{style:C,children:r.subTitle})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"left"},children:[e.jsx("button",{onClick:()=>f(l=>!l),"aria-label":"expand chat",style:s,onMouseEnter:l=>j(l,!0),onMouseLeave:l=>j(l,!1),children:i?e.jsx(v.Minimize2,{size:20}):e.jsx(v.Maximize2,{size:20})}),e.jsx("button",{onClick:o,"aria-label":"close chat",style:s,onMouseEnter:l=>j(l,!0),onMouseLeave:l=>j(l,!1),children:e.jsx(v.X,{size:20})})]})]}),e.jsx(F,{chatBotData:r,theme:t,onlineStatus:n}),e.jsx("div",{style:y,children:e.jsxs("p",{style:k,children:["powered by ",e.jsx("span",{style:w,children:"clone67.com"})]})})]})},_=({pineconeNamespace:o,primaryColor:t="#3b82f6",secondaryColor:r="#8b5cf6",backgroundColor:i="#ffffff",fontColor:f="#1f2937",placeholderColor:d="#9ca3af",position:p="right",name:u="Assistant",subTitle:g="Typically replies instantly",welcomeText:h="Hi! How can I help you today?"})=>{const[S,c]=x.useState(!1),m=()=>{c(n=>!n),localStorage.removeItem("clone67ChatSessionId")},b=()=>c(n=>!n),C={primaryColor:t,secondaryColor:r,backgroundColor:i,fontColor:f,placeholderColor:d,inputBackgroundColor:i},s={name:u,subTitle:g,welcomeText:h,pineconeNamespace:o,position:p},y=p==="left",k="32px",w={position:"fixed",bottom:"104px",[y?"left":"right"]:k,zIndex:9999,pointerEvents:"auto"},j={position:"fixed",bottom:"32px",[y?"left":"right"]:k,zIndex:1e4,pointerEvents:"auto"};return e.jsxs(e.Fragment,{children:[S&&e.jsx("div",{style:w,children:e.jsx(N,{onClose:m,theme:C,chatBotData:s})}),e.jsx("div",{style:j,children:e.jsx(E,{onMinimise:b,isOpen:S,theme:C,chatBotData:s})})]})};module.exports=_;
1
+ "use strict";const e=require("react/jsx-runtime"),a=require("react"),v=require("lucide-react"),T=({onMinimise:o,isOpen:t,theme:r,chatBotData:i})=>{const g=i.position==="left",d=g?"32px":"auto",c=g?"auto":"32px",p=localStorage.getItem("clone67ChatSessionId"),x={position:"fixed",bottom:"32px",left:d,right:c,background:`linear-gradient(135deg, ${r.primaryColor}, ${r.secondaryColor})`,color:r.fontColor,width:"64px",height:"64px",borderRadius:"50%",border:"none",boxShadow:"0 20px 25px -5px rgba(0,0,0,0.15), 0 10px 10px -5px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",pointerEvents:"auto",transition:"all 300ms ease",outline:"none"},y={position:"absolute",top:"-4px",right:"-4px",width:"16px",height:"16px",backgroundColor:"#34d399",borderRadius:"50%",border:"4px solid white",animation:"pulse 2s infinite"};return e.jsxs("button",{onClick:o,style:x,children:[t?e.jsx(v.Minus,{size:20,strokeWidth:2.5}):e.jsx(v.MessageCircle,{size:20,strokeWidth:2.5}),!t&&p&&e.jsx("span",{style:y})]})},l=[];for(let o=0;o<256;++o)l.push((o+256).toString(16).slice(1));function D(o,t=0){return(l[o[t+0]]+l[o[t+1]]+l[o[t+2]]+l[o[t+3]]+"-"+l[o[t+4]]+l[o[t+5]]+"-"+l[o[t+6]]+l[o[t+7]]+"-"+l[o[t+8]]+l[o[t+9]]+"-"+l[o[t+10]]+l[o[t+11]]+l[o[t+12]]+l[o[t+13]]+l[o[t+14]]+l[o[t+15]]).toLowerCase()}let R;const $=new Uint8Array(16);function M(){if(!R){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");R=crypto.getRandomValues.bind(crypto)}return R($)}const L=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),E={randomUUID:L};function U(o,t,r){o=o||{};const i=o.random??o.rng?.()??M();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,D(i)}function F(o,t,r){return E.randomUUID&&!o?E.randomUUID():U(o)}const O=({messages:o,chatBotData:t,theme:r})=>{const[i,g]=a.useState([]),d=a.useRef(null),c=s=>{if(s==="")return null;try{return JSON.parse(s)}catch(u){return console.error("Error parsing message string to JSON:",u),null}},p=s=>new Date(s).toLocaleString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0});a.useEffect(()=>{const s=c(o);s&&g(u=>[...u,s])},[o]),a.useEffect(()=>{d.current?.scrollIntoView({behavior:"smooth"})},[i]);const x=i.flat(),y={height:"310px",overflowY:"auto",padding:"20px",background:r.backgroundColor,color:r.fontColor,borderTop:"1px solid rgba(255, 255, 255, 0.2)",display:"flex",flexDirection:"column",gap:"16px"},f=s=>({display:"flex",justifyContent:s==="user"?"flex-end":"flex-start",width:"100%"}),S={display:"flex",flexDirection:"column",maxWidth:"80%"},b=s=>({padding:"12px",borderRadius:s==="user"?"16px 0 16px 16px":"0 16px 16px 16px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",fontSize:"14px",lineHeight:"1.5",background:s==="user"?r.primaryColor:"#f5f5f5",color:r.fontColor,wordWrap:"break-word"});return e.jsxs("div",{style:y,children:[x.map((s,u)=>e.jsx("div",{style:f(s.sender_type),children:e.jsxs("div",{style:S,children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:s.sender_type==="user"?"flex-end":"flex-start",marginRight:"4px",marginBottom:"2px"},children:e.jsx("span",{style:{fontSize:"10px",opacity:.55,color:r.fontColor},children:s.sender_type==="user"?"You":`${t.name}`})}),e.jsx("div",{style:s.sender_type==="user"?b("user"):b("ai"),children:s.message}),e.jsx("span",{style:{fontSize:"10px",opacity:.55,color:r.fontColor,alignSelf:s.sender_type==="user"?"flex-end":"flex-start",marginTop:"4px"},children:`${p(s.created_at)}`})]})},u)),e.jsx("div",{ref:d})]})},B=(o,t)=>({socket:new WebSocket(`wss://handle-chat-session.clone67.com?chatbotNamespace=${t}&sessionId=${o}`)}),N=({chatBotData:o,theme:t,onlineStatus:r})=>{const[i,g]=a.useState(null),[d,c]=a.useState(""),[p,x]=a.useState("Connecting to server..."),[y,f]=a.useState(""),[S,b]=a.useState(!1);a.useEffect(()=>{var n=localStorage.getItem("clone67ChatSessionId");n===null&&(n=F(),localStorage.setItem("clone67ChatSessionId",n));const{socket:h}=B(n,o.pineconeNamespace);g(h),h.onopen=()=>{x("Server connected"),setTimeout(()=>{x("")},2e3),r("online")},h.onmessage=async z=>{try{const W=await z.data;f(W),b(!1)}catch(W){console.error("Error handling server message:",W)}},h.onerror=z=>{x("Server error occurred"),console.error("WebSocket error:",z),r("offline")},h.onclose=()=>{x("Server disconnected"),r("offline")}},[]);const s=async n=>{n.preventDefault(),i&&i.readyState===WebSocket.OPEN&&i.send(JSON.stringify(d)),b(!0);const h={created_at:Date.now(),sender_type:"user",message:d};f(JSON.stringify(h)),c("")},u=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),s(n))},C={flex:1,padding:"12px 16px",background:t.backgroundColor,color:t.fontColor,border:`1px solid ${t.fontColor}`,borderRadius:"12px",fontSize:"14px",outline:"none",transition:"all 0.2s ease",boxShadow:"none"},k={padding:"12px 20px",borderRadius:"12px",background:`linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,color:t.fontColor,border:"none",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",fontWeight:"600",fontSize:"14px",transition:"all 0.2s ease",minWidth:"48px"},w={padding:"16px",borderTop:"1px solid rgba(255, 255, 255, 0.2)",borderColor:t.fontColor,background:t.backgroundColor,flexShrink:0},I={display:"flex",gap:"12px",alignItems:"center"},m={textAlign:"center",padding:"2px",backgroundColor:p==="Server connected"||p==="online"?"#09BA00":p==="Connecting to server..."?"#DED000":"#FF3408",color:"#ffffff",fontSize:"10px"},j={padding:"8px",animation:"fadeIn 0.3s ease-in-out, pulse 1.5s ease-in-out infinite",animationDelay:"0s, 0.3s",fontSize:"10px",color:t.fontColor};return e.jsxs(e.Fragment,{children:[p&&e.jsx("p",{style:m,children:p}),e.jsx(O,{messages:y,chatBotData:o,theme:t}),S&&e.jsx("div",{style:j,children:`${o.name} is typing...`}),e.jsx("div",{style:w,children:e.jsxs("form",{onSubmit:s,style:I,children:[e.jsx("input",{type:"text",placeholder:"Type a message...",value:d,onChange:n=>c(n.target.value),onKeyDown:u,style:C,onFocus:n=>{n.target.style.boxShadow="0 0 0 3px rgba(100, 150, 255, 0.3)",n.target.style.borderColor="#60a5fa"},onBlur:n=>{n.target.style.boxShadow="none",n.target.style.borderColor=t.fontColor}}),e.jsx("button",{onClick:s,style:k,"aria-label":"Send message",children:e.jsx(v.Send,{size:18})})]})})]})},_=({onClose:o,theme:t,chatBotData:r})=>{const[i,g]=a.useState(!1),[d,c]=a.useState(!1),x={position:"fixed",bottom:"112px",[r.position==="left"?"left":"right"]:"32px",zIndex:50,width:i?"684px":"384px",height:i?"620px":"520px",background:`${t.backgroundColor}cc`,backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",borderRadius:"16px",border:"1px solid rgba(255, 255, 255, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif",boxShadow:"0 10px 25px -3px rgba(0,0,0,0.1)"},y={padding:"16px 20px",background:`linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,color:t.fontColor,borderRadius:"16px 16px 0 0",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1)"},f={position:"relative"},S={width:"44px",height:"44px",borderRadius:"50%",background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center"},b={position:"absolute",bottom:0,right:0,width:"14px",height:"14px",backgroundColor:d?"#00BF49":"#F54927",borderRadius:"50%",border:"3px solid white"},s={fontSize:"18px",fontWeight:"600",margin:0,lineHeight:"1.2"},u={fontSize:"12px",opacity:.9,margin:0,lineHeight:"1.3"},C={padding:"8px",borderRadius:"50%",background:"transparent",border:"none",cursor:"pointer",transition:"background 0.2s"},k={padding:"12px 20px",borderTop:"1px solid rgba(255,255,255,0.2)",background:t.backgroundColor,textAlign:"center"},w={fontSize:"11px",color:t.fontColor,letterSpacing:"0.5px"},I={fontWeight:"600"},m=(n,h)=>{n.currentTarget.style.background=h?"rgba(255,255,255,0.2)":"transparent"},j=n=>{c(n==="online")};return e.jsxs("div",{style:x,children:[e.jsxs("div",{style:y,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsxs("div",{style:f,children:[e.jsx("div",{style:S,children:e.jsx(v.MessageCircle,{size:22})}),e.jsx("span",{style:b})]}),e.jsxs("div",{children:[e.jsx("h3",{style:s,children:r.name}),e.jsx("p",{style:u,children:r.subTitle})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"left"},children:[e.jsx("button",{onClick:()=>g(n=>!n),"aria-label":"expand chat",style:C,onMouseEnter:n=>m(n,!0),onMouseLeave:n=>m(n,!1),children:i?e.jsx(v.Minimize2,{size:20}):e.jsx(v.Maximize2,{size:20})}),e.jsx("button",{onClick:o,"aria-label":"close chat",style:C,onMouseEnter:n=>m(n,!0),onMouseLeave:n=>m(n,!1),children:e.jsx(v.X,{size:20})})]})]}),e.jsx(N,{chatBotData:r,theme:t,onlineStatus:j}),e.jsx("div",{style:k,children:e.jsxs("p",{style:w,children:["powered by ",e.jsx("span",{style:I,children:"clone67.com"})]})})]})},H=({pineconeNamespace:o,primaryColor:t="#3b82f6",secondaryColor:r="#8b5cf6",backgroundColor:i="#ffffff",fontColor:g="#1f2937",placeholderColor:d="#9ca3af",position:c="right",name:p="Assistant",subTitle:x="Typically replies instantly",welcomeText:y="Hi! How can I help you today?"})=>{const[f,S]=a.useState(!1),b=()=>{S(j=>!j),localStorage.removeItem("clone67ChatSessionId")},s=()=>S(j=>!j),u={primaryColor:t,secondaryColor:r,backgroundColor:i,fontColor:g,placeholderColor:d,inputBackgroundColor:i},C={name:p,subTitle:x,welcomeText:y,pineconeNamespace:o,position:c},k=c==="left",w="32px",I={position:"fixed",bottom:"104px",[k?"left":"right"]:w,zIndex:9999,pointerEvents:"auto"},m={position:"fixed",bottom:"32px",[k?"left":"right"]:w,zIndex:1e4,pointerEvents:"auto"};return e.jsxs(e.Fragment,{children:[f&&e.jsx("div",{style:I,children:e.jsx(_,{onClose:b,theme:u,chatBotData:C})}),e.jsx("div",{style:m,children:e.jsx(T,{onMinimise:s,isOpen:f,theme:u,chatBotData:C})})]})};module.exports=H;
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { jsxs as u, jsx as o, Fragment as M } from "react/jsx-runtime";
2
- import { useState as S, useRef as L, useEffect as T } from "react";
3
- import { Minus as $, MessageCircle as D, Send as U, Minimize2 as j, Maximize2 as B, X as O } from "lucide-react";
4
- const F = ({ onMinimise: t, isOpen: e, theme: s, chatBotData: i }) => {
5
- const f = i.position === "left", d = f ? "32px" : "auto", p = f ? "auto" : "32px", x = localStorage.getItem("clone67ChatSessionId"), g = {
1
+ import { jsxs as a, jsx as n, Fragment as $ } from "react/jsx-runtime";
2
+ import { useState as h, useRef as M, useEffect as T } from "react";
3
+ import { Minus as U, MessageCircle as L, Send as j, Minimize2 as O, Maximize2 as F, X as B } from "lucide-react";
4
+ const N = ({ onMinimise: t, isOpen: e, theme: s, chatBotData: i }) => {
5
+ const g = i.position === "left", d = g ? "32px" : "auto", c = g ? "auto" : "32px", p = localStorage.getItem("clone67ChatSessionId"), u = {
6
6
  position: "fixed",
7
7
  bottom: "32px",
8
8
  left: d,
9
- right: p,
9
+ right: c,
10
10
  background: `linear-gradient(135deg, ${s.primaryColor}, ${s.secondaryColor})`,
11
11
  color: s.fontColor,
12
12
  width: "64px",
@@ -22,14 +22,14 @@ const F = ({ onMinimise: t, isOpen: e, theme: s, chatBotData: i }) => {
22
22
  transition: "all 300ms ease",
23
23
  outline: "none"
24
24
  };
25
- return /* @__PURE__ */ u(
25
+ return /* @__PURE__ */ a(
26
26
  "button",
27
27
  {
28
28
  onClick: t,
29
- style: g,
29
+ style: u,
30
30
  children: [
31
- e ? /* @__PURE__ */ o($, { size: 20, strokeWidth: 2.5 }) : /* @__PURE__ */ o(D, { size: 20, strokeWidth: 2.5 }),
32
- !e && x && /* @__PURE__ */ o("span", { style: {
31
+ e ? /* @__PURE__ */ n(U, { size: 20, strokeWidth: 2.5 }) : /* @__PURE__ */ n(L, { size: 20, strokeWidth: 2.5 }),
32
+ !e && p && /* @__PURE__ */ n("span", { style: {
33
33
  position: "absolute",
34
34
  top: "-4px",
35
35
  right: "-4px",
@@ -43,54 +43,54 @@ const F = ({ onMinimise: t, isOpen: e, theme: s, chatBotData: i }) => {
43
43
  ]
44
44
  }
45
45
  );
46
- }, a = [];
46
+ }, l = [];
47
47
  for (let t = 0; t < 256; ++t)
48
- a.push((t + 256).toString(16).slice(1));
49
- function N(t, e = 0) {
50
- return (a[t[e + 0]] + a[t[e + 1]] + a[t[e + 2]] + a[t[e + 3]] + "-" + a[t[e + 4]] + a[t[e + 5]] + "-" + a[t[e + 6]] + a[t[e + 7]] + "-" + a[t[e + 8]] + a[t[e + 9]] + "-" + a[t[e + 10]] + a[t[e + 11]] + a[t[e + 12]] + a[t[e + 13]] + a[t[e + 14]] + a[t[e + 15]]).toLowerCase();
48
+ l.push((t + 256).toString(16).slice(1));
49
+ function _(t, e = 0) {
50
+ return (l[t[e + 0]] + l[t[e + 1]] + l[t[e + 2]] + l[t[e + 3]] + "-" + l[t[e + 4]] + l[t[e + 5]] + "-" + l[t[e + 6]] + l[t[e + 7]] + "-" + l[t[e + 8]] + l[t[e + 9]] + "-" + l[t[e + 10]] + l[t[e + 11]] + l[t[e + 12]] + l[t[e + 13]] + l[t[e + 14]] + l[t[e + 15]]).toLowerCase();
51
51
  }
52
- let R;
53
- const _ = new Uint8Array(16);
54
- function H() {
55
- if (!R) {
52
+ let E;
53
+ const H = new Uint8Array(16);
54
+ function V() {
55
+ if (!E) {
56
56
  if (typeof crypto > "u" || !crypto.getRandomValues)
57
57
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
58
- R = crypto.getRandomValues.bind(crypto);
58
+ E = crypto.getRandomValues.bind(crypto);
59
59
  }
60
- return R(_);
60
+ return E(H);
61
61
  }
62
- const V = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), E = { randomUUID: V };
63
- function A(t, e, s) {
62
+ const A = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), D = { randomUUID: A };
63
+ function J(t, e, s) {
64
64
  t = t || {};
65
- const i = t.random ?? t.rng?.() ?? H();
65
+ const i = t.random ?? t.rng?.() ?? V();
66
66
  if (i.length < 16)
67
67
  throw new Error("Random bytes length must be >= 16");
68
- return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, N(i);
68
+ return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, _(i);
69
69
  }
70
- function J(t, e, s) {
71
- return E.randomUUID && !t ? E.randomUUID() : A(t);
70
+ function P(t, e, s) {
71
+ return D.randomUUID && !t ? D.randomUUID() : J(t);
72
72
  }
73
- const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
74
- const [f, d] = S([]), p = L(null), x = (r) => {
73
+ const K = ({ messages: t, chatBotData: e, theme: s }) => {
74
+ const [i, g] = h([]), d = M(null), c = (r) => {
75
75
  if (r === "") return null;
76
76
  try {
77
77
  return JSON.parse(r);
78
- } catch (y) {
79
- return console.error("Error parsing message string to JSON:", y), null;
78
+ } catch (x) {
79
+ return console.error("Error parsing message string to JSON:", x), null;
80
80
  }
81
- }, g = (r) => new Date(r).toLocaleString(void 0, {
81
+ }, p = (r) => new Date(r).toLocaleString(void 0, {
82
82
  hour: "2-digit",
83
83
  minute: "2-digit",
84
84
  hour12: !0
85
85
  });
86
86
  T(() => {
87
- const r = x(t);
88
- r && d((y) => [...y, r]);
87
+ const r = c(t);
88
+ r && g((x) => [...x, r]);
89
89
  }, [t]), T(() => {
90
- p.current?.scrollIntoView({ behavior: "smooth" });
91
- }, [f]);
92
- const m = f.flat(), h = {
93
- height: "290px",
90
+ d.current?.scrollIntoView({ behavior: "smooth" });
91
+ }, [i]);
92
+ const u = i.flat(), S = {
93
+ height: "310px",
94
94
  overflowY: "auto",
95
95
  padding: "20px",
96
96
  background: s.backgroundColor,
@@ -99,16 +99,16 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
99
99
  display: "flex",
100
100
  flexDirection: "column",
101
101
  gap: "16px"
102
- }, c = (r) => ({
102
+ }, y = (r) => ({
103
103
  display: "flex",
104
104
  justifyContent: r === "user" ? "flex-end" : "flex-start",
105
105
  width: "100%"
106
- }), C = {
106
+ }), m = {
107
107
  display: "flex",
108
108
  flexDirection: "column",
109
109
  maxWidth: "80%"
110
- }, b = (r) => ({
111
- padding: "12px 16px",
110
+ }, f = (r) => ({
111
+ padding: "12px",
112
112
  borderRadius: r === "user" ? "16px 0 16px 16px" : "0 16px 16px 16px",
113
113
  boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)",
114
114
  fontSize: "14px",
@@ -116,64 +116,56 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
116
116
  background: r === "user" ? s.primaryColor : "#f5f5f5",
117
117
  color: s.fontColor,
118
118
  wordWrap: "break-word"
119
- }), v = {
120
- ...b("bot"),
121
- animation: "fadeIn 0.3s ease-in-out, pulse 1.5s ease-in-out infinite",
122
- animationDelay: "0s, 0.3s"
123
- };
124
- return /* @__PURE__ */ u("div", { style: h, children: [
125
- m.map((r, y) => /* @__PURE__ */ o("div", { style: c(r.sender_type), children: /* @__PURE__ */ u("div", { style: C, children: [
126
- /* @__PURE__ */ o("div", { style: {
119
+ });
120
+ return /* @__PURE__ */ a("div", { style: S, children: [
121
+ u.map((r, x) => /* @__PURE__ */ n("div", { style: y(r.sender_type), children: /* @__PURE__ */ a("div", { style: m, children: [
122
+ /* @__PURE__ */ n("div", { style: {
127
123
  display: "flex",
128
124
  alignItems: "center",
129
125
  gap: "4px",
130
126
  justifyContent: r.sender_type === "user" ? "flex-end" : "flex-start",
131
127
  marginRight: "4px",
132
128
  marginBottom: "2px"
133
- }, children: /* @__PURE__ */ o("span", { style: { fontSize: "10px", opacity: 0.55, color: s.fontColor }, children: r.sender_type === "user" ? "You" : `${e.name}` }) }),
134
- /* @__PURE__ */ o("div", { style: r.sender_type === "user" ? b("user") : b("ai"), children: r.message }),
135
- /* @__PURE__ */ o("span", { style: { fontSize: "10px", opacity: 0.55, color: s.fontColor, alignSelf: r.sender_type === "user" ? "flex-end" : "flex-start", marginTop: "4px" }, children: `${g(r.created_at)}` })
136
- ] }) }, y)),
137
- i && /* @__PURE__ */ o("div", { style: v, children: "Typing..." }),
138
- /* @__PURE__ */ o("div", { ref: p })
129
+ }, children: /* @__PURE__ */ n("span", { style: { fontSize: "10px", opacity: 0.55, color: s.fontColor }, children: r.sender_type === "user" ? "You" : `${e.name}` }) }),
130
+ /* @__PURE__ */ n("div", { style: r.sender_type === "user" ? f("user") : f("ai"), children: r.message }),
131
+ /* @__PURE__ */ n("span", { style: { fontSize: "10px", opacity: 0.55, color: s.fontColor, alignSelf: r.sender_type === "user" ? "flex-end" : "flex-start", marginTop: "4px" }, children: `${p(r.created_at)}` })
132
+ ] }) }, x)),
133
+ /* @__PURE__ */ n("div", { ref: d })
139
134
  ] });
140
- }, Y = (t, e) => ({ socket: new WebSocket(`wss://handle-chat-session.clone67.com?chatbotNamespace=${e}&sessionId=${t}`) }), K = ({ chatBotData: t, theme: e, onlineStatus: s }) => {
141
- const [i, f] = S(null), [d, p] = S(""), [x, g] = S("Connecting to server..."), [m, h] = S(""), [c, C] = S(!1);
135
+ }, Y = (t, e) => ({ socket: new WebSocket(`wss://handle-chat-session.clone67.com?chatbotNamespace=${e}&sessionId=${t}`) }), X = ({ chatBotData: t, theme: e, onlineStatus: s }) => {
136
+ const [i, g] = h(null), [d, c] = h(""), [p, u] = h("Connecting to server..."), [S, y] = h(""), [m, f] = h(!1);
142
137
  T(() => {
143
- var n = localStorage.getItem("clone67ChatSessionId");
144
- n === null && (n = J(), localStorage.setItem("clone67ChatSessionId", n));
145
- const { socket: l } = Y(n, t.pineconeNamespace);
146
- f(l), l.onopen = () => {
147
- g("Server connected"), setTimeout(() => {
148
- g("");
138
+ var o = localStorage.getItem("clone67ChatSessionId");
139
+ o === null && (o = P(), localStorage.setItem("clone67ChatSessionId", o));
140
+ const { socket: b } = Y(o, t.pineconeNamespace);
141
+ g(b), b.onopen = () => {
142
+ u("Server connected"), setTimeout(() => {
143
+ u("");
149
144
  }, 2e3), s("online");
150
- }, l.onmessage = async (I) => {
151
- C(!0);
145
+ }, b.onmessage = async (W) => {
152
146
  try {
153
- const W = await I.data;
154
- h(W);
155
- } catch (W) {
156
- console.error("Error handling server message:", W);
157
- } finally {
158
- C(!1);
147
+ const R = await W.data;
148
+ y(R), f(!1);
149
+ } catch (R) {
150
+ console.error("Error handling server message:", R);
159
151
  }
160
- }, l.onerror = (I) => {
161
- g("Server error occurred"), console.error("WebSocket error:", I), s("offline");
162
- }, l.onclose = () => {
163
- g("Server disconnected"), s("offline");
152
+ }, b.onerror = (W) => {
153
+ u("Server error occurred"), console.error("WebSocket error:", W), s("offline");
154
+ }, b.onclose = () => {
155
+ u("Server disconnected"), s("offline");
164
156
  };
165
157
  }, []);
166
- const b = async () => {
167
- i && i.readyState === WebSocket.OPEN && i.send(JSON.stringify(d));
168
- const n = {
158
+ const r = async (o) => {
159
+ o.preventDefault(), i && i.readyState === WebSocket.OPEN && i.send(JSON.stringify(d)), f(!0);
160
+ const b = {
169
161
  created_at: Date.now(),
170
162
  sender_type: "user",
171
163
  message: d
172
164
  };
173
- h(JSON.stringify(n)), p("");
174
- }, v = (n) => {
175
- n.key === "Enter" && !n.shiftKey && (n.preventDefault(), b());
176
- }, r = {
165
+ y(JSON.stringify(b)), c("");
166
+ }, x = (o) => {
167
+ o.key === "Enter" && !o.shiftKey && (o.preventDefault(), r(o));
168
+ }, v = {
177
169
  flex: 1,
178
170
  padding: "12px 16px",
179
171
  background: e.backgroundColor,
@@ -183,17 +175,13 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
183
175
  fontSize: "14px",
184
176
  outline: "none",
185
177
  transition: "all 0.2s ease",
186
- opacity: c ? 0.5 : 1,
187
- cursor: c ? "not-allowed" : "text",
188
178
  boxShadow: "none"
189
- }, y = {
179
+ }, w = {
190
180
  padding: "12px 20px",
191
181
  borderRadius: "12px",
192
182
  background: `linear-gradient(135deg, ${e.primaryColor}, ${e.secondaryColor})`,
193
183
  color: e.fontColor,
194
184
  border: "none",
195
- cursor: c || !d.trim() ? "not-allowed" : "pointer",
196
- opacity: c || !d.trim() ? 0.5 : 1,
197
185
  display: "flex",
198
186
  alignItems: "center",
199
187
  justifyContent: "center",
@@ -202,65 +190,64 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
202
190
  fontSize: "14px",
203
191
  transition: "all 0.2s ease",
204
192
  minWidth: "48px"
205
- }, k = {
193
+ }, I = {
206
194
  padding: "16px",
207
195
  borderTop: "1px solid rgba(255, 255, 255, 0.2)",
208
196
  borderColor: e.fontColor,
209
197
  background: e.backgroundColor,
210
198
  flexShrink: 0
199
+ }, z = {
200
+ display: "flex",
201
+ gap: "12px",
202
+ alignItems: "center"
203
+ }, C = {
204
+ textAlign: "center",
205
+ padding: "2px",
206
+ backgroundColor: p === "Server connected" || p === "online" ? "#09BA00" : p === "Connecting to server..." ? "#DED000" : "#FF3408",
207
+ color: "#ffffff",
208
+ fontSize: "10px"
209
+ }, k = {
210
+ padding: "8px",
211
+ animation: "fadeIn 0.3s ease-in-out, pulse 1.5s ease-in-out infinite",
212
+ animationDelay: "0s, 0.3s",
213
+ fontSize: "10px",
214
+ color: e.fontColor
211
215
  };
212
- return /* @__PURE__ */ u("div", { children: [
213
- x && /* @__PURE__ */ o("p", { style: {
214
- textAlign: "center",
215
- padding: "2px",
216
- backgroundColor: x === "Server connected" || x === "online" ? "#09BA00" : x === "Connecting to server..." ? "#DED000" : "#FF3408",
217
- color: "#ffffff",
218
- fontSize: "10px"
219
- }, children: x }),
220
- /* @__PURE__ */ o(P, { messages: m, chatBotData: t, theme: e, isLoading: c }),
221
- /* @__PURE__ */ o("div", { style: k, children: /* @__PURE__ */ u("form", { onSubmit: b, style: {
222
- display: "flex",
223
- gap: "12px",
224
- alignItems: "center"
225
- }, children: [
226
- /* @__PURE__ */ o(
216
+ return /* @__PURE__ */ a($, { children: [
217
+ p && /* @__PURE__ */ n("p", { style: C, children: p }),
218
+ /* @__PURE__ */ n(K, { messages: S, chatBotData: t, theme: e }),
219
+ m && /* @__PURE__ */ n("div", { style: k, children: `${t.name} is typing...` }),
220
+ /* @__PURE__ */ n("div", { style: I, children: /* @__PURE__ */ a("form", { onSubmit: r, style: z, children: [
221
+ /* @__PURE__ */ n(
227
222
  "input",
228
223
  {
229
224
  type: "text",
230
225
  placeholder: "Type a message...",
231
226
  value: d,
232
- onChange: (n) => p(n.target.value),
233
- onKeyDown: v,
234
- disabled: c,
235
- style: r,
236
- onFocus: (n) => {
237
- n.target.style.boxShadow = "0 0 0 3px rgba(100, 150, 255, 0.3)", n.target.style.borderColor = "#60a5fa";
227
+ onChange: (o) => c(o.target.value),
228
+ onKeyDown: x,
229
+ style: v,
230
+ onFocus: (o) => {
231
+ o.target.style.boxShadow = "0 0 0 3px rgba(100, 150, 255, 0.3)", o.target.style.borderColor = "#60a5fa";
238
232
  },
239
- onBlur: (n) => {
240
- n.target.style.boxShadow = "none", n.target.style.borderColor = e.fontColor;
233
+ onBlur: (o) => {
234
+ o.target.style.boxShadow = "none", o.target.style.borderColor = e.fontColor;
241
235
  }
242
236
  }
243
237
  ),
244
- /* @__PURE__ */ o(
238
+ /* @__PURE__ */ n(
245
239
  "button",
246
240
  {
247
- onClick: b,
248
- disabled: c || !d.trim(),
249
- style: y,
241
+ onClick: r,
242
+ style: w,
250
243
  "aria-label": "Send message",
251
- onMouseEnter: (n) => {
252
- !c && d.trim() && (n.currentTarget.style.transform = "translateY(-2px)", n.currentTarget.style.boxShadow = "0 8px 16px rgba(0,0,0,0.15)");
253
- },
254
- onMouseLeave: (n) => {
255
- n.currentTarget.style.transform = "translateY(0)", n.currentTarget.style.boxShadow = "none";
256
- },
257
- children: /* @__PURE__ */ o(U, { size: 18 })
244
+ children: /* @__PURE__ */ n(j, { size: 18 })
258
245
  }
259
246
  )
260
247
  ] }) })
261
248
  ] });
262
- }, X = ({ onClose: t, theme: e, chatBotData: s }) => {
263
- const [i, f] = S(!1), [d, p] = S(!1), g = {
249
+ }, q = ({ onClose: t, theme: e, chatBotData: s }) => {
250
+ const [i, g] = h(!1), [d, c] = h(!1), u = {
264
251
  position: "fixed",
265
252
  bottom: "112px",
266
253
  [s.position === "left" ? "left" : "right"]: "32px",
@@ -277,7 +264,7 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
277
264
  overflow: "hidden",
278
265
  fontFamily: "system-ui, -apple-system, sans-serif",
279
266
  boxShadow: "0 10px 25px -3px rgba(0,0,0,0.1)"
280
- }, m = {
267
+ }, S = {
281
268
  padding: "16px 20px",
282
269
  background: `linear-gradient(135deg, ${e.primaryColor}, ${e.secondaryColor})`,
283
270
  color: e.fontColor,
@@ -286,9 +273,9 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
286
273
  alignItems: "center",
287
274
  justifyContent: "space-between",
288
275
  boxShadow: "0 4px 6px -1px rgba(0,0,0,0.1)"
289
- }, h = {
276
+ }, y = {
290
277
  position: "relative"
291
- }, c = {
278
+ }, m = {
292
279
  width: "44px",
293
280
  height: "44px",
294
281
  borderRadius: "50%",
@@ -296,7 +283,7 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
296
283
  display: "flex",
297
284
  alignItems: "center",
298
285
  justifyContent: "center"
299
- }, C = {
286
+ }, f = {
300
287
  position: "absolute",
301
288
  bottom: 0,
302
289
  right: 0,
@@ -305,142 +292,142 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
305
292
  backgroundColor: d ? "#00BF49" : "#F54927",
306
293
  borderRadius: "50%",
307
294
  border: "3px solid white"
308
- }, b = {
295
+ }, r = {
309
296
  fontSize: "18px",
310
297
  fontWeight: "600",
311
298
  margin: 0,
312
299
  lineHeight: "1.2"
313
- }, v = {
300
+ }, x = {
314
301
  fontSize: "12px",
315
302
  opacity: 0.9,
316
303
  margin: 0,
317
304
  lineHeight: "1.3"
318
- }, r = {
305
+ }, v = {
319
306
  padding: "8px",
320
307
  borderRadius: "50%",
321
308
  background: "transparent",
322
309
  border: "none",
323
310
  cursor: "pointer",
324
311
  transition: "background 0.2s"
325
- }, y = {
312
+ }, w = {
326
313
  padding: "12px 20px",
327
314
  borderTop: "1px solid rgba(255,255,255,0.2)",
328
315
  background: e.backgroundColor,
329
316
  textAlign: "center"
330
- }, k = {
317
+ }, I = {
331
318
  fontSize: "11px",
332
319
  color: e.fontColor,
333
320
  letterSpacing: "0.5px"
334
321
  }, z = {
335
322
  fontWeight: "600"
336
- }, w = (l, I) => {
337
- l.currentTarget.style.background = I ? "rgba(255,255,255,0.2)" : "transparent";
338
- }, n = (l) => {
339
- p(l === "online");
323
+ }, C = (o, b) => {
324
+ o.currentTarget.style.background = b ? "rgba(255,255,255,0.2)" : "transparent";
325
+ }, k = (o) => {
326
+ c(o === "online");
340
327
  };
341
- return /* @__PURE__ */ u("div", { style: g, children: [
342
- /* @__PURE__ */ u("div", { style: m, children: [
343
- /* @__PURE__ */ u("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
344
- /* @__PURE__ */ u("div", { style: h, children: [
345
- /* @__PURE__ */ o("div", { style: c, children: /* @__PURE__ */ o(D, { size: 22 }) }),
346
- /* @__PURE__ */ o("span", { style: C })
328
+ return /* @__PURE__ */ a("div", { style: u, children: [
329
+ /* @__PURE__ */ a("div", { style: S, children: [
330
+ /* @__PURE__ */ a("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
331
+ /* @__PURE__ */ a("div", { style: y, children: [
332
+ /* @__PURE__ */ n("div", { style: m, children: /* @__PURE__ */ n(L, { size: 22 }) }),
333
+ /* @__PURE__ */ n("span", { style: f })
347
334
  ] }),
348
- /* @__PURE__ */ u("div", { children: [
349
- /* @__PURE__ */ o("h3", { style: b, children: s.name }),
350
- /* @__PURE__ */ o("p", { style: v, children: s.subTitle })
335
+ /* @__PURE__ */ a("div", { children: [
336
+ /* @__PURE__ */ n("h3", { style: r, children: s.name }),
337
+ /* @__PURE__ */ n("p", { style: x, children: s.subTitle })
351
338
  ] })
352
339
  ] }),
353
- /* @__PURE__ */ u("div", { style: { display: "flex", alignItems: "left" }, children: [
354
- /* @__PURE__ */ o(
340
+ /* @__PURE__ */ a("div", { style: { display: "flex", alignItems: "left" }, children: [
341
+ /* @__PURE__ */ n(
355
342
  "button",
356
343
  {
357
- onClick: () => f((l) => !l),
344
+ onClick: () => g((o) => !o),
358
345
  "aria-label": "expand chat",
359
- style: r,
360
- onMouseEnter: (l) => w(l, !0),
361
- onMouseLeave: (l) => w(l, !1),
362
- children: i ? /* @__PURE__ */ o(j, { size: 20 }) : /* @__PURE__ */ o(B, { size: 20 })
346
+ style: v,
347
+ onMouseEnter: (o) => C(o, !0),
348
+ onMouseLeave: (o) => C(o, !1),
349
+ children: i ? /* @__PURE__ */ n(O, { size: 20 }) : /* @__PURE__ */ n(F, { size: 20 })
363
350
  }
364
351
  ),
365
- /* @__PURE__ */ o(
352
+ /* @__PURE__ */ n(
366
353
  "button",
367
354
  {
368
355
  onClick: t,
369
356
  "aria-label": "close chat",
370
- style: r,
371
- onMouseEnter: (l) => w(l, !0),
372
- onMouseLeave: (l) => w(l, !1),
373
- children: /* @__PURE__ */ o(O, { size: 20 })
357
+ style: v,
358
+ onMouseEnter: (o) => C(o, !0),
359
+ onMouseLeave: (o) => C(o, !1),
360
+ children: /* @__PURE__ */ n(B, { size: 20 })
374
361
  }
375
362
  )
376
363
  ] })
377
364
  ] }),
378
- /* @__PURE__ */ o(K, { chatBotData: s, theme: e, onlineStatus: n }),
379
- /* @__PURE__ */ o("div", { style: y, children: /* @__PURE__ */ u("p", { style: k, children: [
365
+ /* @__PURE__ */ n(X, { chatBotData: s, theme: e, onlineStatus: k }),
366
+ /* @__PURE__ */ n("div", { style: w, children: /* @__PURE__ */ a("p", { style: I, children: [
380
367
  "powered by ",
381
- /* @__PURE__ */ o("span", { style: z, children: "clone67.com" })
368
+ /* @__PURE__ */ n("span", { style: z, children: "clone67.com" })
382
369
  ] }) })
383
370
  ] });
384
- }, Z = ({
371
+ }, ee = ({
385
372
  pineconeNamespace: t,
386
373
  primaryColor: e = "#3b82f6",
387
374
  secondaryColor: s = "#8b5cf6",
388
375
  backgroundColor: i = "#ffffff",
389
- fontColor: f = "#1f2937",
376
+ fontColor: g = "#1f2937",
390
377
  placeholderColor: d = "#9ca3af",
391
- position: p = "right",
392
- name: x = "Assistant",
393
- subTitle: g = "Typically replies instantly",
394
- welcomeText: m = "Hi! How can I help you today?"
378
+ position: c = "right",
379
+ name: p = "Assistant",
380
+ subTitle: u = "Typically replies instantly",
381
+ welcomeText: S = "Hi! How can I help you today?"
395
382
  }) => {
396
- const [h, c] = S(!1), C = () => {
397
- c((n) => !n), localStorage.removeItem("clone67ChatSessionId");
398
- }, b = () => c((n) => !n), v = {
383
+ const [y, m] = h(!1), f = () => {
384
+ m((k) => !k), localStorage.removeItem("clone67ChatSessionId");
385
+ }, r = () => m((k) => !k), x = {
399
386
  primaryColor: e,
400
387
  secondaryColor: s,
401
388
  backgroundColor: i,
402
- fontColor: f,
389
+ fontColor: g,
403
390
  placeholderColor: d,
404
391
  inputBackgroundColor: i
405
- }, r = {
406
- name: x,
407
- subTitle: g,
408
- welcomeText: m,
392
+ }, v = {
393
+ name: p,
394
+ subTitle: u,
395
+ welcomeText: S,
409
396
  pineconeNamespace: t,
410
- position: p
411
- }, y = p === "left", k = "32px", z = {
397
+ position: c
398
+ }, w = c === "left", I = "32px", z = {
412
399
  position: "fixed",
413
400
  bottom: "104px",
414
- [y ? "left" : "right"]: k,
401
+ [w ? "left" : "right"]: I,
415
402
  zIndex: 9999,
416
403
  pointerEvents: "auto"
417
- }, w = {
404
+ }, C = {
418
405
  position: "fixed",
419
406
  bottom: "32px",
420
- [y ? "left" : "right"]: k,
407
+ [w ? "left" : "right"]: I,
421
408
  zIndex: 1e4,
422
409
  pointerEvents: "auto"
423
410
  };
424
- return /* @__PURE__ */ u(M, { children: [
425
- h && /* @__PURE__ */ o("div", { style: z, children: /* @__PURE__ */ o(
426
- X,
411
+ return /* @__PURE__ */ a($, { children: [
412
+ y && /* @__PURE__ */ n("div", { style: z, children: /* @__PURE__ */ n(
413
+ q,
427
414
  {
428
- onClose: C,
429
- theme: v,
430
- chatBotData: r
415
+ onClose: f,
416
+ theme: x,
417
+ chatBotData: v
431
418
  }
432
419
  ) }),
433
- /* @__PURE__ */ o("div", { style: w, children: /* @__PURE__ */ o(
434
- F,
420
+ /* @__PURE__ */ n("div", { style: C, children: /* @__PURE__ */ n(
421
+ N,
435
422
  {
436
- onMinimise: b,
437
- isOpen: h,
438
- theme: v,
439
- chatBotData: r
423
+ onMinimise: r,
424
+ isOpen: y,
425
+ theme: x,
426
+ chatBotData: v
440
427
  }
441
428
  ) })
442
429
  ] });
443
430
  };
444
431
  export {
445
- Z as default
432
+ ee as default
446
433
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-aichatbot-widget",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A React ChatBot Widget",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",