1import{u as m,j as e}from"./vendor-query-DPZO-Gta.js";import{b as v,u as N,j as f,r as k,L as i}from"./vendor-react-BomFe3BT.js";import{u as w,b as _,i as b,f as L,A as $}from"./index-BLzMsaFd.js";import{u as C}from"./useChatbotTabs-TDDcKjl5.js";import"./vendor-charts-DodUWJ0z.js";function B(){var u;const{id:s,botId:d}=v(),x=N(),{isClient:g}=w();let a=null;try{a=f()}catch{}const p=!!(a!=null&&a.business)||!!d,{data:h}=m({queryKey:["business-bots",s],queryFn:async()=>(await _.getBots(s)).data,enabled:!!s&&!!(a!=null&&a.business)&&!d}),t=d||(a!=null&&a.business?(u=h==null?void 0:h[0])==null?void 0:u.id:s),y=C(t||s,"Overview"),{data:r,isLoading:j}=m({queryKey:["chatbot",t],queryFn:async()=>(await b.get(t)).data,enabled:!!t}),{data:c}=m({queryKey:["document-stats",t],queryFn:async()=>(await L.getStats(t)).data,enabled:!!t}),{data:n}=m({queryKey:["chatbot-analytics",t],queryFn:async()=>(await $.getOverview(t,{days:7})).data,enabled:!!t}),{data:l}=m({queryKey:["embed-code",t],queryFn:async()=>(await b.getEmbed(t)).data,enabled:!!t});return k.useEffect(()=>{g()&&s&&x(`/chatbots/${s}/unibox`,{replace:!0})},[g,s,x]),j?e.jsx("div",{className:"text-center py-12 text-gray-500",children:"Loading..."}):r?e.jsxs("div",{children:[!p&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>x("/chatbots"),className:"text-gray-500 hover:text-gray-700",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 19l-7-7m0 0l7-7m-7 7h18"})})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:r.name}),r.title&&e.jsxs("p",{className:"text-sm text-primary-600",children:['Widget title: "',r.title,'"']}),e.jsx("p",{className:"text-gray-600",children:r.description||"No description"})]})]}),e.jsx("span",{className:`px-3 py-1 text-sm font-medium rounded-full ${r.status==="active"?"bg-green-100 text-green-700":"bg-gray-100 text-gray-700"}`,children:r.status})]}),e.jsx("div",{className:"border-b border-gray-200 mb-6",children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:y.map(o=>e.jsx(i,{to:o.href,className:`py-4 px-1 border-b-2 font-medium text-sm ${o.current?"border-primary-500 text-primary-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:o.name},o.name))})})]}),p&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Chatbot Configuration"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"View chatbot stats and get embed code"}),e.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-200",children:[e.jsx(i,{to:`/business/${s}/bots/chatbot/${d}`,className:"px-4 py-2 text-sm font-medium text-primary-600 border-b-2 border-primary-500",children:"Overview"}),e.jsx(i,{to:`/business/${s}/bots/chatbot/${d}/settings`,className:"px-4 py-2 text-sm font-medium text-gray-600 hover:text-gray-900 border-b-2 border-transparent hover:border-gray-300",children:"Widget"}),e.jsx(i,{to:`/business/${s}/bots/chatbot/${d}/documents`,className:"px-4 py-2 text-sm font-medium text-gray-600 hover:text-gray-900 border-b-2 border-transparent hover:border-gray-300",children:"Knowledge Base"}),e.jsx(i,{to:`/business/${s}/bots/chatbot/${d}/ai-settings`,className:"px-4 py-2 text-sm font-medium text-gray-600 hover:text-gray-900 border-b-2 border-transparent hover:border-gray-300",children:"AI Settings"}),e.jsx(i,{to:`/business/${s}/bots/chatbot/${d}/playground`,className:"px-4 py-2 text-sm font-medium text-gray-600 hover:text-gray-900 border-b-2 border-transparent hover:border-gray-300",children:"Playground"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6 mb-8",children:[e.jsxs("div",{className:"card p-6",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Documents"}),e.jsx("p",{className:"text-3xl font-bold text-gray-900 mt-2",children:(c==null?void 0:c.total_documents)||0}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:[(c==null?void 0:c.total_chunks)||0," chunks"]})]}),e.jsxs("div",{className:"card p-6",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Conversations (7d)"}),e.jsx("p",{className:"text-3xl font-bold text-gray-900 mt-2",children:(n==null?void 0:n.total_conversations)||0})]}),e.jsxs("div",{className:"card p-6",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Messages (7d)"}),e.jsx("p",{className:"text-3xl font-bold text-gray-900 mt-2",children:(n==null?void 0:n.total_messages)||0})]}),e.jsxs("div",{className:"card p-6",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Avg Response"}),e.jsx("p",{className:"text-3xl font-bold text-gray-900 mt-2",children:n!=null&&n.avg_response_time_ms?`${(n.avg_response_time_ms/1e3).toFixed(1)}s`:"N/A"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"card p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Qu
1ick Actions"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(i,{to:`/chatbots/${s}/documents`,className:"flex items-center gap-3 p-3 rounded-lg border border-gray-200 hover:bg-gray-50",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"Add Documents"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Upload files or add URLs to train your chatbot"})]})]}),e.jsxs(i,{to:`/chatbots/${s}/settings`,className:"flex items-center gap-3 p-3 rounded-lg border border-gray-200 hover:bg-gray-50",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-100 rounded-lg flex items-center justify-center",children:e.jsxs("svg",{className:"w-5 h-5 text-purple-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"Customize Widget"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Change appearance and behavior"})]})]})]})]}),e.jsxs("div",{className:"card p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Embed Code"}),e.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Copy and paste this code into your website to add the chat widget."}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"bg-gray-900 text-gray-100 p-4 rounded-lg text-sm overflow-x-auto",children:e.jsx("code",{children:(l==null?void 0:l.embed_code)||"Loading..."})}),e.jsx("button",{onClick:()=>{navigator.clipboard.writeText((l==null?void 0:l.embed_code)||"")},className:"absolute top-2 right-2 p-2 bg-gray-700 hover:bg-gray-600 rounded text-white",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})]}),e.jsxs("div",{className:"card p-6 mt-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Model Configuration"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Provider"}),e.jsx("p",{className:"font-medium text-gray-900",children:r.llm_provider})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Model"}),e.jsx("p",{className:"font-medium text-gray-900",children:r.llm_model})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Temperature"}),e.jsx("p",{className:"font-medium text-gray-900",children:r.temperature})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Max Tokens"}),e.jsx("p",{className:"font-medium text-gray-900",children:r.max_tokens})]})]}),r.system_prompt&&e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-sm text-gray-500 mb-2",children:"System Prompt"}),e.jsx("p",{className:"text-sm text-gray-700 bg-gray-50 p-3 rounded-lg",children:r.system_prompt})]})]})]}):e.jsx("div",{className:"text-center py-12 text-gray-500",children:"Chatbot not found"})}export{B as default};
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.