@superwise.ai/superwise-chatbot-package 1.0.1 → 1.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.
@@ -1259,7 +1259,7 @@ function Je({ title: r = "", agentId: n = "", discoveryAgentId: s = "", primaryC
1259
1259
  } catch {
1260
1260
  }
1261
1261
  return [];
1262
- }), [g, w] = L(""), [v, j] = L(!1), [E, h] = L(!1), [f, I] = L(!1), [H, V] = L(!1), [W, z] = L(/* @__PURE__ */ new Set()), [oe, se] = L(!1), [ae, ie] = L(!1), [Y, A] = L(!1), [R, q] = L(!1), [de, le] = L(""), [T, $] = L(""), K = 9e4, ce = "https://superwise.ai/contact/", D = B(null), O = B(null), c = (() => {
1262
+ }), [g, w] = L(""), [v, j] = L(!1), [E, h] = L(!1), [f, I] = L(!1), [H, V] = L(!1), [W, z] = L(/* @__PURE__ */ new Set()), [oe, se] = L(!1), [ae, ie] = L(!1), [Y, A] = L(!1), [R, q] = L(!1), [de, le] = L(""), [T, $] = L(""), K = 12e4, ce = "https://superwise.ai/contact/", D = B(null), O = B(null), c = (() => {
1263
1263
  if (p) return p;
1264
1264
  if (typeof document < "u" && typeof window < "u") {
1265
1265
  const o = document.querySelector("[data-chatbot-color]");
@@ -428,4 +428,4 @@ React keys must be passed directly to JSX without using spread:
428
428
  `).trim(),y=ce(b);n.push({placeholder:`\0CODE_RAW_${l}\0`,html:`<pre class="sw-ttyw-code-block"><code>${y}</code></pre>`}),m.push(`\0CODE_RAW_${l}\0`)}else p.length===1&&m.push(p[0])}return{html:m.join(`
429
429
  `),codeBlocks:n}}function ge(r){if(!r)return"";let n=String(r);const s=[];n=n.replace(/```\s*(\w*)\s*\n?([\s\S]*?)```/g,(a,p,l)=>{const b=s.length,y=ce(l.trim());return s.push(`<pre class="sw-ttyw-code-block"><code class="${p?`language-${p}`:""}">${y}</code></pre>`),`\0CODE_FENCED_${b}\0`}),n=n.replace(/\[code\]([\s\S]*?)\[\/code\]/gi,(a,p)=>{const l=s.length,b=ce(p.trim());return s.push(`<pre class="sw-ttyw-code-block"><code>${b}</code></pre>`),`\0CODE_FENCED_${l}\0`});const{html:m,codeBlocks:c}=Ve(n);return n=m,n=n.replace(/\[text\]([\s\S]*?)(?:\[\/text\]|\]\[text\])/gi,'<span class="sw-ttyw-text-block">$1</span>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>').replace(/(https?:\/\/[^\s<]+)/g,'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>').replace(/\[([^[\]]+)\]/g,'<span class="sw-ttyw-bracket-label">$1</span>').replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`([^`]+)`/g,"<code>$1</code>").replace(/^\s*\* (.*$)/gim,"<li>$1</li>").replace(/^\s*- (.*$)/gim,"<li>$1</li>").replace(/^\s*\d+\. (.*$)/gim,"<li>$1</li>").replace(/\n/g,"<br>"),n=n.replace(/((?:<li>.*?<\/li>(?:<br>)?)+)/g,"<ul>$1</ul>"),s.forEach((a,p)=>{n=n.replace(`\0CODE_FENCED_${p}\0`,a)}),c.forEach(({placeholder:a,html:p})=>{n=n.replace(a,p)}),n}const We=30,Ae=300,Te=i.memo(function({text:n,speed:s=20,onComplete:m}){const[c,a]=i.useState(""),[p,l]=i.useState(!1),b=i.useRef(m);i.useEffect(()=>{b.current=m},[m]),i.useEffect(()=>{if(!n)return;a(""),l(!1);const w=n.trim().split(/\s+/),E=Math.min(We,w.length),L=w.slice(0,E).join(" "),S=Math.min(L.length,Ae,n.length);let u=0;const g=setInterval(()=>{u<S?(a(n.slice(0,u+1)),u++):(a(n),l(!0),clearInterval(g),b.current&&b.current())},s);return()=>clearInterval(g)},[n,s]);const y=w=>w.replace(/(https?:\/\/[^\s<]+)/g,'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>').replace(/\[([^[\]]+)\]/g,"$1").replace(/\[bold\](.*?)\[\/bold\]/g,"<strong>$1</strong>").replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/(?:^|\n)-\s+/g,`
430
430
  • `).replace(/\n/g,"<br/>").replace(/(\d+\.\s)/g,"<br/>$1").replace(/(\*\s)/g,"<br/>$1");return e.jsx("div",{style:{whiteSpace:"pre-wrap",lineHeight:"1.5",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:p?ge(c):y(c)+'<span class="typing-cursor">|</span>'}})}),Fe=i.memo(function({msg:n,isTyping:s=!1,onTypingComplete:m}){const c=n.from==="human"?"sw-ttyw-message self":"sw-ttyw-message other";return e.jsxs("div",{className:c,style:Pe(n.from),children:[e.jsx("div",{className:"message-avatar",style:h.messageAvatar,children:n.from==="human"?e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"black",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M20 21V19C20 17.9391 19.5786 16.9217 18.8284 16.1716C18.0783 15.4214 17.0609 15 16 15H8C6.93913 15 5.92172 15.4214 5.17157 16.1716C4.42143 16.9217 4 17.9391 4 19V21",fill:"black"}),e.jsx("circle",{cx:"12",cy:"7",r:"4",fill:"black"})]}):e.jsx(fe,{width:20,height:20})}),e.jsx("div",{className:"message-content sw-ttyw-markdown",style:h.messageContent,children:n.from==="ai"&&s?e.jsx(Te,{text:n.text,speed:20,onComplete:m}):n.from==="ai"?e.jsx("div",{style:{whiteSpace:"pre-wrap",lineHeight:"1.5",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:ge(n.text)}}):e.jsx("div",{style:{whiteSpace:"pre-wrap",lineHeight:"1.5",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:n.text.replace(/\[([^[\]]+)\]/g,"$1").replace(/\[bold\](.*?)\[\/bold\]/g,"<strong>$1</strong>").replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/(?:^|\n)-\s+/g,`
431
- • `).replace(/\n/g,"<br/>").replace(/(\d+\.\s)/g,"<br/>$1").replace(/(\*\s)/g,"<br/>$1")}})})]})}),ze=(r="")=>{const n=new Date().getHours();let s=[];return n>=5&&n<12?r?s=[`🌅 Good morning ${r}! I'm an expert on SUPERWISE. Ready to explore the platform together and uncover what's possible?`,`☀️ Morning ${r}! I'm an expert on SUPERWISE. What would you like to discover or optimize today?`,`🌞 Good morning ${r}! I'm an expert on SUPERWISE. Curious about a feature or looking to dive deeper into the platform?`,`👋 Rise and shine ${r}! I'm an expert on SUPERWISE. Let's jump into anything you want to explore.`,`👋 Morning ${r}! I'm an expert on SUPERWISE. How can I guide you through the platform today?`]:s=["🌅 Good morning! I'm an expert on SUPERWISE. Ready to explore the platform together and uncover what's possible?","☀️ Morning! I'm an expert on SUPERWISE. What would you like to discover or optimize today?","🌞 Good morning! I'm an expert on SUPERWISE. Curious about a feature or looking to dive deeper into the platform?","👋 Rise and shine! I'm an expert on SUPERWISE. Let's jump into anything you want to explore.","👋 Morning! I'm an expert on SUPERWISE. How can I guide you through the platform today?"]:n>=12&&n<17?r?s=[`🌞 Good afternoon ${r}! I'm an expert on SUPERWISE. Ready to explore insights, features, or workflows together?`,`☀️ Afternoon ${r}! I'm an expert on SUPERWISE. How may I help you today?`,`👋 Good afternoon ${r}! I'm an expert on SUPERWISE. Looking to learn, optimize, or explore something specific?`,`🌅 Hey there ${r}! SUPERWISE expert here. Ready to help you unlock the capabilities you're curious about.`,`🌅 Afternoon ${r}! I'm an expert on SUPERWISE. How can I support your exploration today?`]:s=["🌞 Good afternoon! I'm an expert on SUPERWISE. Ready to explore insights, features, or workflows together?","☀️ Afternoon! I'm an expert on SUPERWISE. How may I help you today?","👋 Good afternoon! I'm an expert on SUPERWISE. Looking to learn, optimize, or explore something specific?","🌅 Hey there! SUPERWISE expert here. Ready to help you unlock the capabilities you're curious about.","🌅 Afternoon! I'm an expert on SUPERWISE. How can I support your exploration today?"]:n>=17&&n<21?r?s=[`🌆 Good evening ${r}! I'm a SUPERWISE expert. Ready to explore features or clarify anything you're evaluating?`,`🌅 Evening ${r}! I'm your SUPERWISE expert. What can I help you discover or fine-tune tonight?`,`👋 Good evening ${r}! I'm an expert on SUPERWISE. Interested in exploring capabilities or reviewing how something works?`,`🌇 Hey there ${r}! SUPERWISE expert here. Want to dive into the platform together?`,`🌇 Evening ${r}! I'm an expert on SUPERWISE. How can I assist your learning or discovery today?`]:s=["🌆 Good evening! I'm a SUPERWISE expert. Ready to explore features or clarify anything you're evaluating?","🌅 Evening! I'm your SUPERWISE expert. What can I help you discover or fine-tune tonight?","👋 Good evening! I'm an expert on SUPERWISE. Interested in exploring capabilities or reviewing how something works?","🌇 Hey there! SUPERWISE expert here. Want to dive into the platform together?","🌇 Evening! I'm an expert on SUPERWISE. How can I assist your learning or discovery today?"]:r?s=[`🌙 Good evening ${r}! I'm a SUPERWISE expert. Ready to guide you through the platform anytime.`,`⭐ Evening ${r}! I'm your SUPERWISE expert. What brings you to Superwise tonight - exploration, questions, or clarity?`,`👋 Good evening ${r}! I'm a SUPERWISE expert. Looking to discover features or understand how something works?`,`🌃 Hey there ${r}! I'm a SUPERWISE expert. Want to explore what the platform offers?`,`🌃 Evening ${r}! SUPERWISE expert here. How can I help simplify or explain things for you today?`]:s=["🌙 Good evening! I'm a SUPERWISE expert. Ready to guide you through the platform anytime.","⭐ Evening! I'm your SUPERWISE expert. What brings you to Superwise tonight - exploration, questions, or clarity?","👋 Good evening! I'm a SUPERWISE expert. Looking to discover features or understand how something works?","🌃 Hey there! I'm a SUPERWISE expert. Want to explore what the platform offers?","🌃 Evening! SUPERWISE expert here. How can I help simplify or explain things for you today?"],s[Math.floor(Math.random()*s.length)]};function De({title:r="",agentId:n="",discoveryAgentId:s="",primaryColor:m="",apiUrl:c=""}){const[a,p]=i.useState(()=>{try{if(typeof window<"u"&&window.localStorage){const o=window.localStorage.getItem("chatbot-messages");return o?JSON.parse(o):[]}}catch{}return[]}),[l,b]=i.useState(()=>{try{if(typeof window<"u"&&window.localStorage){const o=window.localStorage.getItem("chatbot-mql_df");return o?JSON.parse(o):[]}}catch{}return[]}),[y,w]=i.useState(""),[E,L]=i.useState(!1),[S,u]=i.useState(!1),[g,I]=i.useState(!1),[R,P]=i.useState(!1),[V,D]=i.useState(new Set),[re,ne]=i.useState(!1),[oe,se]=i.useState(!1),[Y,W]=i.useState(!1),[H,G]=i.useState(!1),[pe,ae]=i.useState(""),[A,T]=i.useState(""),Q=9e4,ie="https://superwise.ai/contact/",O=i.useRef(null),N=i.useRef(null),d=(()=>{if(m)return m;if(typeof document<"u"&&typeof window<"u"){const o=document.querySelector("[data-chatbot-color]");if(o)return o.getAttribute("data-chatbot-color")||"#000";const j=getComputedStyle(document.documentElement).getPropertyValue("--swttyw-primary-color").trim();if(j)return j}return"#000"})(),x=i.useMemo(()=>{if(!l||l.length===0)return"";const o=l.find(v=>v.name&&v.email);return o?`${o.name} (${o.email})`:""},[l]),k=i.useRef(null),U=i.useRef(null),$=i.useRef(a),f=i.useCallback(()=>{O.current&&(clearTimeout(O.current),O.current=null)},[]),_=i.useCallback(o=>{f(),O.current=setTimeout(o,Q)},[Q,f]),Z=i.useMemo(()=>a.map(o=>({role:o.from,content:o.text})),[a]),J=o=>{T(o),setTimeout(()=>{T("")},4e3)},Oe=o=>{const v=o.length,j=o.trim();return ae(""),T(""),!j||v===0?(J("Please enter a message before sending."),!1):new RegExp(/(<([^>]+)>)/gi).test(j)?(J("Please avoid using HTML tags or scripts in your message."),!1):j.length<2?(J("Please enter a meaningful question (at least 2 characters)."),!1):j.length>1e3?(J("Message is too long. Please keep it under 1000 characters."),!1):(ae(""),T(""),!0)},q=i.useCallback((o="auto")=>{var j;const v=U.current;v&&(v.scrollTop=v.scrollHeight),(j=k.current)==null||j.scrollIntoView({behavior:o})},[]);i.useEffect(()=>{requestAnimationFrame(()=>q("auto"))},[a,A,Y,H,q]),i.useEffect(()=>{if(!E&&V.size===0)return;const o=setInterval(()=>q("auto"),120);return()=>clearInterval(o)},[E,V,q]),i.useEffect(()=>{try{typeof window<"u"&&window.localStorage&&window.localStorage.setItem("chatbot-messages",JSON.stringify(a))}catch{}},[a]),i.useEffect(()=>{try{typeof window<"u"&&window.localStorage&&window.localStorage.setItem("chatbot-mql_df",JSON.stringify(l))}catch{}},[l]),i.useEffect(()=>{$.current=a},[a]),i.useEffect(()=>{if(a.length===0&&!re){const v={from:"ai",text:ze(x)};p([v]),ne(!0),D(new Set([0]))}},[a.length,re,x]),i.useEffect(()=>()=>f(),[f]);const ye=i.useCallback(async()=>{var be;if(E||H)return;const o=y.trim();if(!o||!Oe(y))return;W(!1),f(),(be=N.current)==null||be.abort();const v=new AbortController;N.current=v;const j=v.signal,M={from:"human",text:o},F=$.current,Ue=[...F,M];p(Ue),w(""),L(!0);let Ce=o;if(l&&l.length>0&&!oe){const C=F.filter(B=>B.from==="ai").pop();C&&C.text&&C.text.trim()!==""&&(Ce=o+"."+C.text,se(!0))}const Ze=[...Z,{role:"human",content:o}];_(()=>{var C;W(!0),(C=N.current)==null||C.abort(),L(!1)});try{const C=await je(Ce,Ze,l,n,s,c,j);if(f(),typeof C=="string"){const B={from:"ai",text:C};p(ee=>{const te=[...ee,B];return D(me=>new Set([...me,te.length-1])),te}),(C.startsWith("⚠️")||C.startsWith("❌"))&&W(!0)}else{const B={from:"ai",text:C.reply};p(ee=>{const te=[...ee,B];return D(me=>new Set([...me,te.length-1])),te}),C.mqlDf&&Array.isArray(C.mqlDf)&&b(C.mqlDf),C.reply&&(C.reply.startsWith("⚠️")||C.reply.startsWith("❌"))&&W(!0),C.chatHistoryLimitExceeded&&G(!0)}}catch(C){if(f(),C.name==="AbortError")return;W(!0);const B=C.message||"Something went wrong. Please try again.";p(ee=>[...ee,{from:"ai",text:`⚠️ ${B}`}])}finally{L(!1)}},[y,n,s,l,oe,Z,H,f,_]),Ne=i.useCallback(()=>{var o;f(),(o=N.current)==null||o.abort(),W(!1),G(!1),p([]),D(new Set),ne(!1),se(!1);try{typeof window<"u"&&window.localStorage&&window.localStorage.removeItem("chatbot-messages")}catch{}u(!1)},[f]),xe=i.useCallback(async()=>{var o,v,j;if(!l||l.length===0){console.warn("No mql_df data available for PDF download");return}try{L(!0),console.log("mql_df data for lead extraction:",l);const M={name:((o=l.find(F=>F.name))==null?void 0:o.name)||"Chat User",email:((v=l.find(F=>F.email))==null?void 0:v.email)||"user@example.com",summary:`Chat conversation with ${a.length} messages. User asked: "${((j=a.find(F=>F.from==="human"))==null?void 0:j.text)||"No user messages"}"`};console.log("Extracted lead row:",M),await Le(l,M,Z,c),console.log("PDF downloaded successfully")}catch(M){console.error("Failed to download PDF:",M)}finally{L(!1)}},[l,a]);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"sw-ttyw-chatbot",style:{...g?h.containerMinimized:R?h.containerExpanded:h.container,"--swttyw-primary-color":d,"--swttyw-avatar-image":"url('')","--swttyw-user-avatar-image":"url('')","--swttyw-background-color":"#F7F7F7","--swttyw-header-font-size":"16px","--swttyw-body-font-size":"15px","--swttyw-footer-font-size":"16px","--swttyw-user-background-image":"url('')"},onClick:g?()=>I(!1):void 0,children:[g?e.jsxs("div",{style:h.minimizedContent,children:[e.jsxs("svg",{style:h.chatIcon,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M21 15C21 15.5304 20.7893 16.0391 20.4142 16.4142C20.0391 16.7893 19.5304 17 19 17H7L3 21V5C3 4.46957 3.21071 3.96086 3.58579 3.58579C3.96086 3.21071 4.46957 3 5 3H19C19.5304 3 20.0391 3.21071 20.4142 3.58579C20.7893 3.96086 21 4.46957 21 5V15Z",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 9H16",stroke:"white",strokeWidth:"2",strokeLinecap:"round"}),e.jsx("path",{d:"M8 13H12",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("div",{style:h.minimizedTitle,children:r})]}):e.jsxs("div",{className:"sw-ttyw-chat-header",style:h.header,children:[e.jsx("div",{className:"sw-ttyw-name",style:h.name,children:r}),e.jsxs("div",{style:h.headerActions,children:[e.jsx("button",{onClick:()=>P(o=>!o),style:h.headerButton,title:R?"Shrink chat":"Expand chat",children:R?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M9 4V9H4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M15 4V9H20",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9 20V15H4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M15 20V15H20",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M4 9V4H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M20 9V4H15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M4 15V20H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M20 15V20H15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsx("button",{onClick:()=>{g||P(!1),I(!g)},style:h.headerButton,title:g?"Maximize chat":"Minimize chat",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 9H18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}),l&&l.length>0&&e.jsx("button",{onClick:xe,style:h.headerButton,title:"Download PDF Report",disabled:E,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 10L12 15L17 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15V3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsx("button",{onClick:()=>u(!0),style:h.headerButton,title:"Clear chat",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M3 6H5H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10 11V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M14 11V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),!g&&e.jsxs("div",{className:"sw-ttyw-chat-section",style:{flexGrow:1,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{className:"sw-ttyw-messages",style:h.chatSection,ref:U,children:[a.length===0&&!E&&e.jsx("div",{className:"sw-ttyw-empty-state",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",position:"relative"},children:e.jsx("img",{src:Re,alt:"Superwise Logo",style:{width:"350px",height:"200px",opacity:.8,objectFit:"contain"},onError:o=>{console.log("Logo failed to load, using fallback"),o.target.style.display="none"}})}),a.map((o,v)=>e.jsx(Fe,{msg:o,isTyping:V.has(v),onTypingComplete:()=>{D(j=>{const M=new Set(j);return M.delete(v),M}),requestAnimationFrame(()=>q("auto"))}},v)),A&&e.jsxs("div",{className:"sw-ttyw-validation-message",children:[e.jsx("span",{className:"error-icon",children:"⚠️"}),e.jsx("span",{children:A})]}),Y&&e.jsx("div",{className:"sw-ttyw-contact-cta",children:e.jsxs("a",{href:ie,target:"_blank",rel:"noopener noreferrer",className:"sw-ttyw-cta-button",children:[e.jsx("span",{className:"sw-ttyw-cta-icon","aria-hidden":!0,children:"✉"}),"Contact Sales"]})}),H&&e.jsxs("div",{className:"sw-ttyw-limit-exceeded",children:[e.jsx("div",{className:"sw-ttyw-limit-exceeded-message",children:"Chat history limit reached. Please download your conversation as PDF and clear chat history to continue."}),e.jsxs("div",{className:"sw-ttyw-limit-action-buttons",children:[e.jsxs("button",{type:"button",className:"sw-ttyw-limit-download-pdf",onClick:xe,disabled:E,children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,children:[e.jsx("path",{d:"M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 10L12 15L17 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15V3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Download Chat"]}),e.jsxs("button",{type:"button",className:"sw-ttyw-limit-clear-history",onClick:()=>u(!0),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,children:[e.jsx("path",{d:"M3 6H5H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10 11V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M14 11V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Clear History"]})]})]}),E&&e.jsxs("div",{className:"sw-ttyw-message other message-loading",style:{...h.message,...h.messageOther},children:[e.jsx("div",{className:"message-avatar",style:h.messageAvatar,children:e.jsx(fe,{width:20,height:20})}),e.jsxs("div",{className:"message-content",style:h.messageContent,children:[e.jsx("div",{className:"typing typing-1"}),e.jsx("div",{className:"typing typing-2"}),e.jsx("div",{className:"typing typing-3"})]})]}),e.jsx("div",{ref:k})]}),e.jsxs("div",{className:"sw-ttyw-chat-input-section",style:h.inputSection,children:[e.jsx("textarea",{className:"sw-ttyw-input",placeholder:H?"Chat limit reached.":"Please ask question here",value:y,onChange:o=>{w(o.target.value),A&&T("")},maxLength:1e3,disabled:E||H,style:h.textarea,onKeyDown:o=>o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),ye())}),e.jsxs("div",{className:"sw-ttyw-chat-input-content",style:h.inputFooter,children:[e.jsxs("small",{id:"sw-ttyw-chat-textbox-status",style:h.characterCount,children:[e.jsx("span",{children:y.length}),"/1000"]}),e.jsx("button",{id:"sw-ttyw-chat-send-message",onClick:ye,"aria-label":"Send message",disabled:E||H,style:h.sendButton,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000",className:"cwv replaced-svg",children:[e.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"})]})})]})]})]}),S&&e.jsxs("div",{className:"swttyw-modal swttyw-modal-clear-history",style:h.modalOverlay,children:[e.jsx("div",{className:"swtty-modal-header"}),e.jsxs("div",{className:"swtty-modal-body",style:h.modalBody,children:[e.jsx("div",{className:"swtty-content",children:"Are you sure you want to delete the chat history?"}),e.jsxs("div",{className:"swtty-action",style:h.modalActions,children:[e.jsx("input",{type:"button",className:"swttyw-btn swttyw-btn-primary",id:"swttyw-btn-clear-history-yes",onClick:Ne,value:"Yes",style:{background:"var(--swttyw-primary-color)",color:"white",border:"none",padding:"10px 20px",cursor:"pointer",borderRadius:"8px",margin:"10px 5px"}}),e.jsx("input",{type:"button",className:"swttyw-btn swttyw-btn-primary-inverse",id:"swttyw-btn-clear-history-no",onClick:()=>u(!1),value:"No",style:{background:"transparent",color:"var(--swttyw-primary-color)",border:"1px solid var(--swttyw-primary-color)",padding:"10px 20px",cursor:"pointer",borderRadius:"8px",margin:"10px 5px"}})]})]}),e.jsx("div",{className:"swtty-modal-footer"})]}),!g&&e.jsxs("div",{className:"sw-ttyw-chat-footer",style:h.footer,children:["Powered by ",e.jsx("a",{href:"https://superwise.ai/",className:"ml-1",target:"_new",rel:"noopener noreferrer",style:{marginLeft:"0.25rem",lineHeight:0},"aria-label":"SUPERWISE®",children:e.jsx(_e,{height:20})})]})]})})}z.Chatbot=De,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
431
+ • `).replace(/\n/g,"<br/>").replace(/(\d+\.\s)/g,"<br/>$1").replace(/(\*\s)/g,"<br/>$1")}})})]})}),ze=(r="")=>{const n=new Date().getHours();let s=[];return n>=5&&n<12?r?s=[`🌅 Good morning ${r}! I'm an expert on SUPERWISE. Ready to explore the platform together and uncover what's possible?`,`☀️ Morning ${r}! I'm an expert on SUPERWISE. What would you like to discover or optimize today?`,`🌞 Good morning ${r}! I'm an expert on SUPERWISE. Curious about a feature or looking to dive deeper into the platform?`,`👋 Rise and shine ${r}! I'm an expert on SUPERWISE. Let's jump into anything you want to explore.`,`👋 Morning ${r}! I'm an expert on SUPERWISE. How can I guide you through the platform today?`]:s=["🌅 Good morning! I'm an expert on SUPERWISE. Ready to explore the platform together and uncover what's possible?","☀️ Morning! I'm an expert on SUPERWISE. What would you like to discover or optimize today?","🌞 Good morning! I'm an expert on SUPERWISE. Curious about a feature or looking to dive deeper into the platform?","👋 Rise and shine! I'm an expert on SUPERWISE. Let's jump into anything you want to explore.","👋 Morning! I'm an expert on SUPERWISE. How can I guide you through the platform today?"]:n>=12&&n<17?r?s=[`🌞 Good afternoon ${r}! I'm an expert on SUPERWISE. Ready to explore insights, features, or workflows together?`,`☀️ Afternoon ${r}! I'm an expert on SUPERWISE. How may I help you today?`,`👋 Good afternoon ${r}! I'm an expert on SUPERWISE. Looking to learn, optimize, or explore something specific?`,`🌅 Hey there ${r}! SUPERWISE expert here. Ready to help you unlock the capabilities you're curious about.`,`🌅 Afternoon ${r}! I'm an expert on SUPERWISE. How can I support your exploration today?`]:s=["🌞 Good afternoon! I'm an expert on SUPERWISE. Ready to explore insights, features, or workflows together?","☀️ Afternoon! I'm an expert on SUPERWISE. How may I help you today?","👋 Good afternoon! I'm an expert on SUPERWISE. Looking to learn, optimize, or explore something specific?","🌅 Hey there! SUPERWISE expert here. Ready to help you unlock the capabilities you're curious about.","🌅 Afternoon! I'm an expert on SUPERWISE. How can I support your exploration today?"]:n>=17&&n<21?r?s=[`🌆 Good evening ${r}! I'm a SUPERWISE expert. Ready to explore features or clarify anything you're evaluating?`,`🌅 Evening ${r}! I'm your SUPERWISE expert. What can I help you discover or fine-tune tonight?`,`👋 Good evening ${r}! I'm an expert on SUPERWISE. Interested in exploring capabilities or reviewing how something works?`,`🌇 Hey there ${r}! SUPERWISE expert here. Want to dive into the platform together?`,`🌇 Evening ${r}! I'm an expert on SUPERWISE. How can I assist your learning or discovery today?`]:s=["🌆 Good evening! I'm a SUPERWISE expert. Ready to explore features or clarify anything you're evaluating?","🌅 Evening! I'm your SUPERWISE expert. What can I help you discover or fine-tune tonight?","👋 Good evening! I'm an expert on SUPERWISE. Interested in exploring capabilities or reviewing how something works?","🌇 Hey there! SUPERWISE expert here. Want to dive into the platform together?","🌇 Evening! I'm an expert on SUPERWISE. How can I assist your learning or discovery today?"]:r?s=[`🌙 Good evening ${r}! I'm a SUPERWISE expert. Ready to guide you through the platform anytime.`,`⭐ Evening ${r}! I'm your SUPERWISE expert. What brings you to Superwise tonight - exploration, questions, or clarity?`,`👋 Good evening ${r}! I'm a SUPERWISE expert. Looking to discover features or understand how something works?`,`🌃 Hey there ${r}! I'm a SUPERWISE expert. Want to explore what the platform offers?`,`🌃 Evening ${r}! SUPERWISE expert here. How can I help simplify or explain things for you today?`]:s=["🌙 Good evening! I'm a SUPERWISE expert. Ready to guide you through the platform anytime.","⭐ Evening! I'm your SUPERWISE expert. What brings you to Superwise tonight - exploration, questions, or clarity?","👋 Good evening! I'm a SUPERWISE expert. Looking to discover features or understand how something works?","🌃 Hey there! I'm a SUPERWISE expert. Want to explore what the platform offers?","🌃 Evening! SUPERWISE expert here. How can I help simplify or explain things for you today?"],s[Math.floor(Math.random()*s.length)]};function De({title:r="",agentId:n="",discoveryAgentId:s="",primaryColor:m="",apiUrl:c=""}){const[a,p]=i.useState(()=>{try{if(typeof window<"u"&&window.localStorage){const o=window.localStorage.getItem("chatbot-messages");return o?JSON.parse(o):[]}}catch{}return[]}),[l,b]=i.useState(()=>{try{if(typeof window<"u"&&window.localStorage){const o=window.localStorage.getItem("chatbot-mql_df");return o?JSON.parse(o):[]}}catch{}return[]}),[y,w]=i.useState(""),[E,L]=i.useState(!1),[S,u]=i.useState(!1),[g,I]=i.useState(!1),[R,P]=i.useState(!1),[V,D]=i.useState(new Set),[re,ne]=i.useState(!1),[oe,se]=i.useState(!1),[Y,W]=i.useState(!1),[H,G]=i.useState(!1),[pe,ae]=i.useState(""),[A,T]=i.useState(""),Q=12e4,ie="https://superwise.ai/contact/",O=i.useRef(null),N=i.useRef(null),d=(()=>{if(m)return m;if(typeof document<"u"&&typeof window<"u"){const o=document.querySelector("[data-chatbot-color]");if(o)return o.getAttribute("data-chatbot-color")||"#000";const j=getComputedStyle(document.documentElement).getPropertyValue("--swttyw-primary-color").trim();if(j)return j}return"#000"})(),x=i.useMemo(()=>{if(!l||l.length===0)return"";const o=l.find(v=>v.name&&v.email);return o?`${o.name} (${o.email})`:""},[l]),k=i.useRef(null),U=i.useRef(null),$=i.useRef(a),f=i.useCallback(()=>{O.current&&(clearTimeout(O.current),O.current=null)},[]),_=i.useCallback(o=>{f(),O.current=setTimeout(o,Q)},[Q,f]),Z=i.useMemo(()=>a.map(o=>({role:o.from,content:o.text})),[a]),J=o=>{T(o),setTimeout(()=>{T("")},4e3)},Oe=o=>{const v=o.length,j=o.trim();return ae(""),T(""),!j||v===0?(J("Please enter a message before sending."),!1):new RegExp(/(<([^>]+)>)/gi).test(j)?(J("Please avoid using HTML tags or scripts in your message."),!1):j.length<2?(J("Please enter a meaningful question (at least 2 characters)."),!1):j.length>1e3?(J("Message is too long. Please keep it under 1000 characters."),!1):(ae(""),T(""),!0)},q=i.useCallback((o="auto")=>{var j;const v=U.current;v&&(v.scrollTop=v.scrollHeight),(j=k.current)==null||j.scrollIntoView({behavior:o})},[]);i.useEffect(()=>{requestAnimationFrame(()=>q("auto"))},[a,A,Y,H,q]),i.useEffect(()=>{if(!E&&V.size===0)return;const o=setInterval(()=>q("auto"),120);return()=>clearInterval(o)},[E,V,q]),i.useEffect(()=>{try{typeof window<"u"&&window.localStorage&&window.localStorage.setItem("chatbot-messages",JSON.stringify(a))}catch{}},[a]),i.useEffect(()=>{try{typeof window<"u"&&window.localStorage&&window.localStorage.setItem("chatbot-mql_df",JSON.stringify(l))}catch{}},[l]),i.useEffect(()=>{$.current=a},[a]),i.useEffect(()=>{if(a.length===0&&!re){const v={from:"ai",text:ze(x)};p([v]),ne(!0),D(new Set([0]))}},[a.length,re,x]),i.useEffect(()=>()=>f(),[f]);const ye=i.useCallback(async()=>{var be;if(E||H)return;const o=y.trim();if(!o||!Oe(y))return;W(!1),f(),(be=N.current)==null||be.abort();const v=new AbortController;N.current=v;const j=v.signal,M={from:"human",text:o},F=$.current,Ue=[...F,M];p(Ue),w(""),L(!0);let Ce=o;if(l&&l.length>0&&!oe){const C=F.filter(B=>B.from==="ai").pop();C&&C.text&&C.text.trim()!==""&&(Ce=o+"."+C.text,se(!0))}const Ze=[...Z,{role:"human",content:o}];_(()=>{var C;W(!0),(C=N.current)==null||C.abort(),L(!1)});try{const C=await je(Ce,Ze,l,n,s,c,j);if(f(),typeof C=="string"){const B={from:"ai",text:C};p(ee=>{const te=[...ee,B];return D(me=>new Set([...me,te.length-1])),te}),(C.startsWith("⚠️")||C.startsWith("❌"))&&W(!0)}else{const B={from:"ai",text:C.reply};p(ee=>{const te=[...ee,B];return D(me=>new Set([...me,te.length-1])),te}),C.mqlDf&&Array.isArray(C.mqlDf)&&b(C.mqlDf),C.reply&&(C.reply.startsWith("⚠️")||C.reply.startsWith("❌"))&&W(!0),C.chatHistoryLimitExceeded&&G(!0)}}catch(C){if(f(),C.name==="AbortError")return;W(!0);const B=C.message||"Something went wrong. Please try again.";p(ee=>[...ee,{from:"ai",text:`⚠️ ${B}`}])}finally{L(!1)}},[y,n,s,l,oe,Z,H,f,_]),Ne=i.useCallback(()=>{var o;f(),(o=N.current)==null||o.abort(),W(!1),G(!1),p([]),D(new Set),ne(!1),se(!1);try{typeof window<"u"&&window.localStorage&&window.localStorage.removeItem("chatbot-messages")}catch{}u(!1)},[f]),xe=i.useCallback(async()=>{var o,v,j;if(!l||l.length===0){console.warn("No mql_df data available for PDF download");return}try{L(!0),console.log("mql_df data for lead extraction:",l);const M={name:((o=l.find(F=>F.name))==null?void 0:o.name)||"Chat User",email:((v=l.find(F=>F.email))==null?void 0:v.email)||"user@example.com",summary:`Chat conversation with ${a.length} messages. User asked: "${((j=a.find(F=>F.from==="human"))==null?void 0:j.text)||"No user messages"}"`};console.log("Extracted lead row:",M),await Le(l,M,Z,c),console.log("PDF downloaded successfully")}catch(M){console.error("Failed to download PDF:",M)}finally{L(!1)}},[l,a]);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"sw-ttyw-chatbot",style:{...g?h.containerMinimized:R?h.containerExpanded:h.container,"--swttyw-primary-color":d,"--swttyw-avatar-image":"url('')","--swttyw-user-avatar-image":"url('')","--swttyw-background-color":"#F7F7F7","--swttyw-header-font-size":"16px","--swttyw-body-font-size":"15px","--swttyw-footer-font-size":"16px","--swttyw-user-background-image":"url('')"},onClick:g?()=>I(!1):void 0,children:[g?e.jsxs("div",{style:h.minimizedContent,children:[e.jsxs("svg",{style:h.chatIcon,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M21 15C21 15.5304 20.7893 16.0391 20.4142 16.4142C20.0391 16.7893 19.5304 17 19 17H7L3 21V5C3 4.46957 3.21071 3.96086 3.58579 3.58579C3.96086 3.21071 4.46957 3 5 3H19C19.5304 3 20.0391 3.21071 20.4142 3.58579C20.7893 3.96086 21 4.46957 21 5V15Z",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 9H16",stroke:"white",strokeWidth:"2",strokeLinecap:"round"}),e.jsx("path",{d:"M8 13H12",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("div",{style:h.minimizedTitle,children:r})]}):e.jsxs("div",{className:"sw-ttyw-chat-header",style:h.header,children:[e.jsx("div",{className:"sw-ttyw-name",style:h.name,children:r}),e.jsxs("div",{style:h.headerActions,children:[e.jsx("button",{onClick:()=>P(o=>!o),style:h.headerButton,title:R?"Shrink chat":"Expand chat",children:R?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M9 4V9H4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M15 4V9H20",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9 20V15H4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M15 20V15H20",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M4 9V4H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M20 9V4H15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M4 15V20H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M20 15V20H15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsx("button",{onClick:()=>{g||P(!1),I(!g)},style:h.headerButton,title:g?"Maximize chat":"Minimize chat",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 9H18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}),l&&l.length>0&&e.jsx("button",{onClick:xe,style:h.headerButton,title:"Download PDF Report",disabled:E,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 10L12 15L17 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15V3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsx("button",{onClick:()=>u(!0),style:h.headerButton,title:"Clear chat",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M3 6H5H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10 11V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M14 11V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),!g&&e.jsxs("div",{className:"sw-ttyw-chat-section",style:{flexGrow:1,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{className:"sw-ttyw-messages",style:h.chatSection,ref:U,children:[a.length===0&&!E&&e.jsx("div",{className:"sw-ttyw-empty-state",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",position:"relative"},children:e.jsx("img",{src:Re,alt:"Superwise Logo",style:{width:"350px",height:"200px",opacity:.8,objectFit:"contain"},onError:o=>{console.log("Logo failed to load, using fallback"),o.target.style.display="none"}})}),a.map((o,v)=>e.jsx(Fe,{msg:o,isTyping:V.has(v),onTypingComplete:()=>{D(j=>{const M=new Set(j);return M.delete(v),M}),requestAnimationFrame(()=>q("auto"))}},v)),A&&e.jsxs("div",{className:"sw-ttyw-validation-message",children:[e.jsx("span",{className:"error-icon",children:"⚠️"}),e.jsx("span",{children:A})]}),Y&&e.jsx("div",{className:"sw-ttyw-contact-cta",children:e.jsxs("a",{href:ie,target:"_blank",rel:"noopener noreferrer",className:"sw-ttyw-cta-button",children:[e.jsx("span",{className:"sw-ttyw-cta-icon","aria-hidden":!0,children:"✉"}),"Contact Sales"]})}),H&&e.jsxs("div",{className:"sw-ttyw-limit-exceeded",children:[e.jsx("div",{className:"sw-ttyw-limit-exceeded-message",children:"Chat history limit reached. Please download your conversation as PDF and clear chat history to continue."}),e.jsxs("div",{className:"sw-ttyw-limit-action-buttons",children:[e.jsxs("button",{type:"button",className:"sw-ttyw-limit-download-pdf",onClick:xe,disabled:E,children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,children:[e.jsx("path",{d:"M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 10L12 15L17 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15V3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Download Chat"]}),e.jsxs("button",{type:"button",className:"sw-ttyw-limit-clear-history",onClick:()=>u(!0),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,children:[e.jsx("path",{d:"M3 6H5H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10 11V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M14 11V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Clear History"]})]})]}),E&&e.jsxs("div",{className:"sw-ttyw-message other message-loading",style:{...h.message,...h.messageOther},children:[e.jsx("div",{className:"message-avatar",style:h.messageAvatar,children:e.jsx(fe,{width:20,height:20})}),e.jsxs("div",{className:"message-content",style:h.messageContent,children:[e.jsx("div",{className:"typing typing-1"}),e.jsx("div",{className:"typing typing-2"}),e.jsx("div",{className:"typing typing-3"})]})]}),e.jsx("div",{ref:k})]}),e.jsxs("div",{className:"sw-ttyw-chat-input-section",style:h.inputSection,children:[e.jsx("textarea",{className:"sw-ttyw-input",placeholder:H?"Chat limit reached.":"Please ask question here",value:y,onChange:o=>{w(o.target.value),A&&T("")},maxLength:1e3,disabled:E||H,style:h.textarea,onKeyDown:o=>o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),ye())}),e.jsxs("div",{className:"sw-ttyw-chat-input-content",style:h.inputFooter,children:[e.jsxs("small",{id:"sw-ttyw-chat-textbox-status",style:h.characterCount,children:[e.jsx("span",{children:y.length}),"/1000"]}),e.jsx("button",{id:"sw-ttyw-chat-send-message",onClick:ye,"aria-label":"Send message",disabled:E||H,style:h.sendButton,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000",className:"cwv replaced-svg",children:[e.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"})]})})]})]})]}),S&&e.jsxs("div",{className:"swttyw-modal swttyw-modal-clear-history",style:h.modalOverlay,children:[e.jsx("div",{className:"swtty-modal-header"}),e.jsxs("div",{className:"swtty-modal-body",style:h.modalBody,children:[e.jsx("div",{className:"swtty-content",children:"Are you sure you want to delete the chat history?"}),e.jsxs("div",{className:"swtty-action",style:h.modalActions,children:[e.jsx("input",{type:"button",className:"swttyw-btn swttyw-btn-primary",id:"swttyw-btn-clear-history-yes",onClick:Ne,value:"Yes",style:{background:"var(--swttyw-primary-color)",color:"white",border:"none",padding:"10px 20px",cursor:"pointer",borderRadius:"8px",margin:"10px 5px"}}),e.jsx("input",{type:"button",className:"swttyw-btn swttyw-btn-primary-inverse",id:"swttyw-btn-clear-history-no",onClick:()=>u(!1),value:"No",style:{background:"transparent",color:"var(--swttyw-primary-color)",border:"1px solid var(--swttyw-primary-color)",padding:"10px 20px",cursor:"pointer",borderRadius:"8px",margin:"10px 5px"}})]})]}),e.jsx("div",{className:"swtty-modal-footer"})]}),!g&&e.jsxs("div",{className:"sw-ttyw-chat-footer",style:h.footer,children:["Powered by ",e.jsx("a",{href:"https://superwise.ai/",className:"ml-1",target:"_new",rel:"noopener noreferrer",style:{marginLeft:"0.25rem",lineHeight:0},"aria-label":"SUPERWISE®",children:e.jsx(_e,{height:20})})]})]})})}z.Chatbot=De,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superwise.ai/superwise-chatbot-package",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A reusable React chatbot component package",
5
5
  "author": "Superwise",
6
6
  "license": "MIT",