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