1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7130],{37130:(e,t,s)=>{s.r(t),s.d(t,{default:()=>g});var a=s(1087),l=s(44542),r=s(54133),n=s(4983),i=s(86606),o=s(86347),d=s(54744),c=s(58804),m=s(35623),x=s(12688),u=s.n(x);function h(e){return e.parts.filter(e=>"text"===e.type).map(e=>e.text).join("")}function p({text:e}){let t=e.split("\n"),s=[];return t.forEach((e,t)=>{let l=function(e){let t=[],s=e,l=0;for(;s.length>0;){let e=s.match(/\[([^\]]+)\]\(([^)]+)\)/),r=s.match(/\*\*([^*]+)\*\*/),n=s.match(/`([^`]+)`/),i=[e?{type:"link",match:e,index:e.index}:null,r?{type:"bold",match:r,index:r.index}:null,n?{type:"code",match:n,index:n.index}:null].filter(Boolean).sort((e,t)=>e.index-t.index);if(0===i.length){t.push(s);break}let o=i[0];o.index>0&&t.push(s.slice(0,o.index)),"link"===o.type?t.push((0,a.jsx)("a",{href:o.match[2],target:"_blank",rel:"noopener noreferrer",className:"text-teal-400 underline underline-offset-2 hover:text-teal-300",children:o.match[1]},l++)):"bold"===o.type?t.push((0,a.jsx)("strong",{children:o.match[1]},l++)):"code"===o.type&&t.push((0,a.jsx)("code",{className:"bg-slate-700 px-1 rounded text-xs",children:o.match[1]},l++)),s=s.slice(o.index+o.match[0].length)}return 1===t.length?t[0]:(0,a.jsx)(a.Fragment,{children:t})}(e);e.match(/^[-*]\s/)?s.push((0,a.jsx)("li",{className:"ml-4 list-disc",children:l},t)):e.match(/^\d+\.\s/)?s.push((0,a.jsx)("li",{className:"ml-4 list-decimal",children:l},t)):""===e.trim()?s.push((0,a.jsx)("br",{},t)):s.push((0,a.jsx)("p",{className:"my-1",children:l},t))}),(0,a.jsx)("div",{className:"space-y-0.5",children:s})}function g({isAuthenticated:e=!1,userName:t}){let[s,x]=(0,n.useState)(!1),[g,b]=(0,n.useState)(""),[f,y]=(0,n.useState)(!1),[j,v]=(0,n.use
1State)({name:t||"",email:"",message:""}),[w,N]=(0,n.useState)("idle"),k=(0,n.useRef)(null),C=(0,n.useMemo)(()=>new r.rL({api:"/api/chat"}),[]),{messages:_,sendMessage:S,status:E,error:$,setMessages:A}=(0,l.Y_)({transport:C,id:"webevo-chat",onError:e=>{}}),D="streaming"===E||"submitted"===E;(0,n.useEffect)(()=>{0===_.length&&A([{id:"welcome",role:"assistant",parts:[{type:"text",text:e?`Hi${t?` ${t}`:""}! ð I can help you understand your scan results and give you actionable advice to improve your website. What would you like to know?`:`Hi! ð I'm WebEvo.ai's assistant. I can help you learn about our platform, features, pricing, and guide you to start a free scan. What would you like to know?`}]}])},[]),(0,n.useEffect)(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)},[_,E]);let L=$?.message?.includes("conversation_limit"),W=_.filter(e=>"user"===e.role).length,H=e?25:15,F=W>=Math.floor(.8*H),T=(0,n.useCallback)(async e=>{e?.preventDefault?.();let t=g.trim();!t||D||L||(b(""),await S({text:t}))},[g,D,L,S]),z=(0,n.useCallback)(async e=>{if(e.preventDefault(),j.message.trim()){N("sending");try{let e=_.slice(-6).map(e=>`${"user"===e.role?"User":"Assistant"}: ${h(e).slice(0,200)}`).join("\n");if(!(await fetch("/api/chat/live-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j.name,email:j.email,message:j.message,conversationSummary:e})})).ok)throw Error("Failed to send");N("sent")}catch{N("error")}}},[j,_]),M=(0,n.useCallback)(()=>{let s=e?`Hi${t?` ${t}`:""}! ð Ready for a fresh start. What would you like to know?`:`Hi! ð Let's start over. What would you like to know about WebEvo.ai?`;A([{id:"welcome-"+Date.now(),role:"assistant",parts:[{type:"text",text:s}]}]),y(!1),N("idle"),v(e=>({...e,message:""}))},[e,t,A]);return s?(0,a.jsx)("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-5 duration-300",children:(0,a.jsxs)("div",{className:"bg-slate-900 border border-slate-700 rounded-xl shadow-2xl w-[92vw] sm:w-[420px] h-[min(600px,85vh)] flex flex-col overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-700 bg-slate-800/60 backdrop-blur-sm shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,a.jsx)("div",{className:"p-2 bg-purple-500/10 rounded-lg shrink-0",children:(0,a.jsx)(o.l,{className:"w-5 h-5 text-purple-400",weight:"fill"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-white truncate",children:"WebEvo.ai Assistant"}),(0,a.jsx)("p",{className:"text-[11px] text-gray-400 truncate",children:e?"Scan insights & advice":"Learn about our platform"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,a.jsx)("button",{onClick:M,className:"p-1.5 hover:bg-slate-700 rounded-lg transition-colors",title:"New conversation","aria-label":"Reset chat",children:(0,a.jsx)(i.L,{className:"w-4 h-4 text-gray-400"})}),(0,a.jsx)("button",{onClick:()=>x(!1),className:"p-1.5 hover:bg-slate-700 rounded-lg transition-colors",title:"Close","aria-label":"Close chat",children:(0,a.jsx)(m.X,{className:"w-4 h-4 text-gray-400"})})]})]}),(0,a.jsxs)("div",{ref:k,className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:[_.map(e=>{let t=h(e);return t?(0,a.jsx)("div",{className:`flex ${"user"===e.role?"justify-end":"justify-start"}`,children:(0,a.jsx)("div",{className:`max-w-[85%] rounded-2xl px-3.5 py-2.5 text-sm leading-relaxed ${"user"===e.role?"bg-purple-600 text-white rounded-br-md":"bg-slate-800 text-gray-100 rounded-bl-md"}`,children:"assistant"===e.role?(0,a.jsx)("div",{className:"prose prose-invert prose-sm max-w-none [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_a]:text-teal-400 [&_a]:underline [&_a]:underline-offset-2 [&_code]:bg-slate-700 [&_code]:px-1 [&_code]:rounded [&_code]:text-xs",children:(0,a.jsx)(p,{text:t})}):(0,a.jsx)("p",{className:"whitespace-pre-wrap",children:t})})},e.id):null}),D&&(0,a.jsx)("div",{className:"flex justify-start",children:(0,a.jsx)("div",{className:"bg-slate-800 rounded-2xl rounded-bl-md px-4 py-3",children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"w-2 h-2 bg-teal-400 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),(0,a.jsx)("span",{className:"w-2 h-2 bg-teal-400 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),(0,a.jsx)("span",{className:"w-2 h-2 bg-teal-400 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})})}),(L||F)&&(0,a.jsxs)("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-lg p-3 text-center",children:[(0,a.jsx)("p",{className:"text-amber-400 text-xs mb-2",children:L?"You've reached the conversation limit.":`${W}/${H} messages used.`}),(0,a.jsxs)("div",{className:"flex gap-2 justify-center",children:[(0,a.jsx)("button",{onClick:()=>y(!0),className:"px-3 py-1.5 text-xs bg-teal-600 hover:bg-teal-700 text-white rounded-lg transition-colors",children:"Talk to Live Agent"}),(0,a.jsx)("button",{onClick:M,className:"px-3 py-1.5 text-xs bg-slate-700 hover:bg-slate-600 text-white rounded-lg transition-colors",children:"New Chat"})]})]})]}),f&&(0,a.jsxs)("div",{className:"absolute inset-0 top-12 bg-slate-900/95 backdrop-blur-sm z-10 flex flex-col p-4 overflow-y-auto",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h4",{className:"text-white font-semibold text-sm flex items-center gap-2",children:[(0,a.jsx)(c.G,{className:"w-5 h-5 text-teal-400"}),"Talk to a Live Agent"]}),(0,a.jsx)("button",{onClick:()=>y(!1),className:"p-1 hover:bg-slate-800 rounded transition-colors",children:(0,a.jsx)(m.X,{className:"w-4 h-4 text-gray-400"})})]}),"sent"===w?(0,a.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-center",children:[(0,a.jsx)("div",{className:"w-12 h-12 bg-teal-500/10 rounded-full flex items-center justify-center mb-3",children:(0,a.jsx)(o.l,{className:"w-6 h-6 text-teal-400",weight:"fill"})}),(0,a.jsx)("p",{className:"text-white font-medium mb-1",children:"Message sent!"}),(0,a.jsx)("p",{className:"text-gray-400 text-sm mb-4",children:"Our team will get back to you shortly."}),(0,a.jsx)("button",{onClick:()=>{y(!1),N("idle")},className:"text-teal-400 text-sm hover:underline",children:"Back to chat"})]}):(0,a.jsxs)("form",{onSubmit:z,className:"flex flex-col gap-3 flex-1",children:[!e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{type:"text",placeholder:"Your name",value:j.name,onChange:e=>v(t=>({...t,name:e.target.value})),className:"w-full px-3 py-2 bg-slate-800 text-white text-sm rounded-lg border border-slate-700 focus:outline-none focus:ring-1 focus:ring-teal-500"}),(0,a.jsx)("input",{type:"email",placeholder:"Your email",value:j.email,onChange:e=>v(t=>({...t,email:e.target.value})),className:"w-full px-3 py-2 bg-slate-800 text-white text-sm rounded-lg border border-slate-700 focus:outline-none focus:ring-1 focus:ring-teal-500"})]}),(0,a.jsx)("textarea",{placeholder:"How can we help you?",value:j.message,onChange:e=>v(t=>({...t,message:e.target.value})),rows:4,className:"w-full px-3 py-2 bg-slate-800 text-white text-sm rounded-lg border border-slate-700 focus:outline-none focus:ring-1 focus:ring-teal-500 resize-none flex-1",required:!0}),"error"===w&&(0,a.jsx)("p",{className:"text-red-400 text-xs",children:"Failed to send. Please try again or email [email protected]."}),(0,a.jsx)("button",{type:"submit",disabled:"sending"===w||!j.message.trim(),className:"w-full py-2.5 bg-teal-600 hover:bg-teal-700 disabled:opacity-50 text-white text-sm font-medium rounded-lg transition-colors",children:"sending"===w?"Sending...":"Send to Live Agent"})]})]}),(0,a.jsx)("form",{onSubmit:T,className:"px-3 py-2.5 border-t border-slate-700 shrink-0",children:(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:g,onChange:e=>b(e.target.value),placeholder:L?"Conversation limit reached":"Ask anything...",disabled:D||L,className:"flex-1 px-3 py-2 bg-slate-800 text-white text-sm rounded-lg border border-slate-700 focus:outline-none focus:ring-1 focus:ring-teal-500 focus:border-transparent disabled:opacity-50 placeholder:text-gray-500"}),(0,a.jsx)("button",{type:"submit",disabled:!g.trim()||D||L,className:"px-3 py-2 bg-gradient-to-r from-purple-600 to-teal-600 hover:from-purple-700 hover:to-teal-700 disabled:opacity-40 disabled:cursor-not-allowed text-white rounded-lg transition-all","aria-label":"Send message",children:(0,a.jsx)(d.M,{className:"w-4 h-4",weight:"fill"})})]})}),(0,a.jsx)("div",{className:"px-3 pb-2.5 shrink-0",children:(0,a.jsxs)("div",{className:"flex gap-2",children:[e?(0,a.jsx)(u(),{href:"/pricing",className:"flex-1 text-center px-3 py-1.5 bg-gradient-to-r from-purple-600 to-teal-600 hover:from-purple-700 hover:to-teal-700 text-white rounded-lg transition-colors text-xs font-medium",children:"Upgrade to Pro â"}):(0,a.jsx)(u(),{href:"/scan",className:"flex-1 text-center px-3 py-1.5 bg-gradient-to-r from-teal-600 to-blue-600 hover:from-teal-700 hover:to-blue-700 text-white rounded-lg transition-colors text-xs font-medium",children:"Start Free Scan â"}),(0,a.jsx)("button",{onClick:()=>y(!0),className:"px-3 py-1.5 text-xs font-medium text-gray-300 hover:text-white bg-slate-800 hover:bg-slate-700 rounded-lg transition-colors border border-slate-700",children:"\uD83D\uDCAC Live Agent"})]})})]})}):(0,a.jsx)("div",{className:"fixed bottom-4 right-4 z-50",children:(0,a.jsxs)("button",{onClick:()=>x(!0),className:"w-14 h-14 bg-gradient-to-r from-purple-600 to-teal-600 rounded-full shadow-2xl transition-all duration-300 transform hover:scale-110 flex items-center justify-center group",title:"Chat with WebEvo.ai Assistant","aria-label":"Open chat",children:[(0,a.jsx)(o.l,{className:"w-6 h-6 text-white group-hover:scale-110 transition-transform",weight:"fill"}),(0,a.jsx)("span",{className:"absolute inset-0 rounded-full bg-gradient-to-r from-purple-600 to-teal-600 animate-ping opacity-20"})]})})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.