1import{r as d,j as e,au as ut,G as xt,e as pt}from"./vendor-BUs1goKk.js";import{d as it,x as I,r as Be,B as f,a7 as Ve,L as Ie,C as g,i as b,f as j,h as A,e as v,O as T,b1 as gt,ad as ze,ar as jt,aD as Je,aE as Re,aF as Ae,aG as C,aH as Ge,aI as S,a4 as Ee,bX as Ke,X as bt,aj as vt,ak as ft,al as Nt,am as yt,an as Ct,aK as p,b4 as q,aL as St,aq as He,bk as wt,y as Te,z as De,F as _e,H as Fe,J as w,S as kt,N as It,ao as At,be as Tt,n as Ue,bU as Ye,D as Dt,ae as _t,aZ as Ft,cl as Xe,ck as Mt,V as Pt,cM as Ot,bl as $t,cN as Lt,K as Ze,b$ as qt}from"./index-wZ_62MVS.js";import{S as et}from"./separator-BTb4Odbm.js";import{T as Qe,a as We,b as N,c as y}from"./tabs-DaYz4TJJ.js";import{A as rt,a as nt,b as lt,c as ot,d as ct,e as dt,f as mt,g as ht}from"./alert-dialog-Bu1KEduB.js";import{C as Vt,a as Et,b as Ht,c as Ut,d as zt}from"./ChatbotOrganizationManager-B0aysdDH.js";import{C as Qt,D as Wt,a as Bt}from"./DeploymentManager-B5jB_6IU.js";import{C as Me}from"./clipboard-list-DXFWi6qC.js";import{ChatbotTestPage as Jt}from"./ChatbotTestPage-BNoyVpaF.js";import{C as Rt}from"./DeploymentThemeEditor-lGCEh1O-.js";import{TestScenariosPage as Gt}from"./TestScenariosPage-DuZASYoI.js";import{O as Kt}from"./OpenInStudioButton-xElXQNr5.js";import{O as Yt}from"./OrganizationApiKeysTab-X3EpTpgg.js";import{C as Xt}from"./CanonicalContentControl-CV4hLDIH.js";import{C as Zt}from"./ChatbotGuardrailAssignments-Cq0IT2Mb.js";import{S as tt}from"./settings-2-X55kZHQ_.js";import{R as es}from"./rocket-BjILTYkp.js";import{L as st}from"./layers-DTKkFk_l.js";import{H as ts}from"./hash-DwMlNs4c.js";import"./CategorySelector-kbOGnORE.js";import"./tag-Jtvtx_3H.js";import"./PromptSelector-Cq99XzG9.js";import"./checkbox-A2WHvVLy.js";import"./collapsible-Bqv7qzAa.js";import"./link-2-CJX2X3od.js";import"./arrow-up-down-dZswXhIf.js";import"./link-2-off-BDgRI-w4.js";import"./ellipsis-vertical-DqJpL626.js";import"./list-checks-FoLCMxmb.js";import"./useChatbotWidgetInstance-CmQfY1br.js";import"./printer-U_4sU53_.js";import"./panel-top-open-DmpObY7R.js";import"./list-ordered-DmRcTeqv.js";import"./pen-Dzna2-DU.js";import"./formatDistanceToNow-Dl5dB-Zg.js";import"./en-US-Dt1WEXcU.js";import"./endOfMonth-BddS4jiw.js";import"./ellipsis-DXzndc8H.js";import"./file-clock-CMDSU5bN.js";import"./ban-CZ9pLWW5.js";const ss=[{value:"string",label:"Text"},{value:"number",label:"Number"},{value:"boolean",label:"Yes/No"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"date",label:"Date"},{value:"select",label:"Select (dropdown)"},{value:"url",label:"URL"},{value:"text",label:"Long Text"}];function as({chatbotId:a}){var ie,Se,we,ke;const{toast:c}=it(),[h,E]=d.useState("forms"),[xe,M]=d.useState(!1),[G,K]=d.useState(null),[re,Y]=d.useState(null),[H,pe]=d.useState(null),[U,ne]=d.useState(!1),[le,P]=d.useState(""),[s,oe]=d.useState(""),[u,z]=d.useState([]),[n,X]=d.useState("hybrid"),[Q,W]=d.useState({}),[B,ce]=d.useState(""),[ge,Z]=d.useState(""),[ee,de]=d.useState("POST"),[me,te]=d.useState(""),[i,r]=d.useState("none"),[D,O]=d.useState(""),[J,_]=d.useState(!0),k=I.chatbot.dataCapture.listForms.useQuery({chatbotId:a}),R=I.chatbot.dataCapture.listSessions.useQuery({chatbotId:a,limit:50},{enabled:h==="sessions"}),Pe=I.chatbot.dataCapture.getSession.useQuery({id:H??""},{enabled:!!H}),se=I.chatbot.dataCapture.createForm.useMutation({onSuccess:()=>{c({title:"Form created",description:"Data capture form created successfully."}),k.refetch(),ae()},onError:t=>{c({title:"Error",description:t.message,variant:"destructive"})}}),he=I.chatbot.dataCapture.updateForm.useMutation({onSuccess:()=>{c({title:"Form updated",description:"Data capture form updated successfully."}),k.refetch(),ae()},onError:t=>{c({title:"Error",description:t.message,variant:"destructive"})}}),Oe=I.chatbot.dataCapture.deleteForm.useMutation({onSuccess:()=>{c({title:"Form deleted",description:"Data capture form deleted."}),k.refetch(),Y(null)},onError:t=>{c({title:"Error",description:t.message,variant:"destructive"})}}),je=I.chatbot.dataCapture.generateQuestions.useMutation({onSuccess:t=>{W(t.questions),c({title:t.source==="ai"?"AI Questions Generated":"Default Questions Generated",description:`Generated ${Ob
1ject.keys(t.questions).length} questions.`}),ne(!1)},onError:t=>{c({title:"Error generating questions",description:t.message,variant:"destructive"}),ne(!1)}}),be=()=>{P(""),oe(""),z([]),X("hybrid"),W({}),ce(""),Z(""),de("POST"),te(""),r("none"),O(""),_(!0)},ae=()=>{M(!1),K(null),be()},ve=()=>{be(),K(null),M(!0)},fe=t=>{var l;K(t),P(t.name),oe(t.description||""),z(((l=t.jsonSchema)==null?void 0:l.fields)||[]),X(t.questionMode),W(t.questionMappings||{}),ce(t.aiQuestionPrompt||""),Z(t.targetApiUrl||""),de(t.targetApiMethod||"POST"),te(t.targetApiHeaders?JSON.stringify(t.targetApiHeaders,null,2):""),r(t.targetApiAuthStrategy||"none"),O(""),_(t.isActive),M(!0)},$e=()=>{z([...u,{key:`field_${u.length+1}`,type:"string",label:"",required:!0}])},$=(t,l)=>{z(u.map((x,o)=>o===t?{...x,...l}:x))},Ne=t=>{const l=u[t];if(z(u.filter((x,o)=>o!==t)),l){const x={...Q};delete x[l.key],W(x)}},Le=()=>{if(u.length===0){c({title:"No fields",description:"Add fields first before generating questions.",variant:"destructive"});return}ne(!0),je.mutate({chatbotId:a,jsonSchema:{fields:u},aiPrompt:B||void 0})},qe=()=>{if(!le.trim()){c({title:"Name required",description:"Please enter a form name.",variant:"destructive"});return}if(u.length===0){c({title:"Fields required",description:"Add at least one field.",variant:"destructive"});return}const t=u.map(o=>o.key);if(new Set(t).size!==t.length){c({title:"Duplicate keys",description:"Each field must have a unique key.",variant:"destructive"});return}let l;if(me.trim())try{l=JSON.parse(me)}catch{c({title:"Invalid headers",description:"API headers must be valid JSON.",variant:"destructive"});return}const x={chatbotId:a,name:le.trim(),description:s.trim()||void 0,jsonSchema:{fields:u},questionMode:n,questionMappings:Object.keys(Q).length>0?Q:void 0,aiQuestionPrompt:B.trim()||void 0,targetApiUrl:ge.trim()||void 0,targetApiMethod:ee,targetApiHeaders:l,targetApiAuthStrategy:i,targetApiCredential:D.trim()||void 0,isActive:J};G?he.mutate({id:G.id,...x}):se.mutate(x)},L=t=>t?new Date(t).toLocaleString():"â",ye=k.data||[],Ce=((ie=R.data)==null?void 0:ie.sessions)||[],m=Pe.data;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Qe,{value:h,onValueChange:E,children:[e.jsxs(We,{children:[e.jsxs(N,{value:"forms",children:[e.jsx(Me,{className:"mr-2 h-4 w-4"}),"Forms"]}),e.jsxs(N,{value:"sessions",children:[e.jsx(Be,{className:"mr-2 h-4 w-4"}),"Captured Data"]})]}),e.jsxs(y,{value:"forms",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Define JSON schemas for structured data collection. The chatbot will ask questions to fill each field."}),e.jsxs(f,{onClick:ve,size:"sm",children:[e.jsx(Ve,{className:"mr-2 h-4 w-4"}),"New Form"]})]}),k.isLoading?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ie,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ye.length===0?e.jsx(g,{children:e.jsxs(b,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Me,{className:"mb-4 h-12 w-12 text-muted-foreground"}),e.jsx(j,{className:"mb-2",children:"No Data Capture Forms"}),e.jsx(A,{className:"mb-4",children:"Create a form to collect structured data from users during chat conversations."}),e.jsxs(f,{onClick:ve,children:[e.jsx(Ve,{className:"mr-2 h-4 w-4"}),"Create First Form"]})]})}):e.jsx("div",{className:"grid gap-4",children:ye.map(t=>{var l,x,o,F;return e.jsxs(g,{children:[e.jsxs(v,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(j,{className:"text-base",children:t.name}),e.jsx(T,{variant:t.isActive?"default":"secondary",children:t.isActive?"Active":"Inactive"}),e.jsx(T,{variant:"outline",children:t.questionMode.replace("_"," ")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"ghost",size:"icon",onClick:()=>fe(t),children:e.jsx(gt,{className:"h-4 w-4"})}),e.jsx(f,{variant:"ghost",size:"icon",onClick:()=>Y(t.id),children:e.jsx(ze,{className:"h-4 w-4 text-destructive"})})]})]}),t.description&&e.jsx(A,{children:t.description})]}),e.jsxs(b,{children:[e.jsxs("div",{className:"flex flex-wrap gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{children:[((x=(l=t.jsonSchema)==null?void 0:l.fields)==null?void 0:x.length)||0," fields"]}),t.targetApiUrl&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(jt,{className:"h-3 w-3"}),t.targetApiMethod," â ",new URL(t.targetApiUrl).hostname]}),e.jsxs("span",{children:["Created ",L(t.createdAt)]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:(F=(o=t.jsonSchema)==null?void 0:o.fields)==null?void 0:F.map(ue=>e.jsxs(T,{variant:"outline",className:"text-xs",children:[ue.label||ue.key,e.jsxs("span",{className:"ml-1 text-muted-foreground",children:["(",ue.type,")"]}),ue.required&&e.jsx("span",{className:"ml-1 text-red-400",children:"*"})]},ue.key))})]})]},t.id)})})]}),e.jsxs(y,{value:"sessions",className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"View captured data from user interactions with data capture forms."}),H&&m?e.jsxs("div",{className:"space-y-4",children:[e.jsx(f,{variant:"ghost",size:"sm",onClick:()=>pe(null),children:"â Back to sessions"}),e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(j,{className:"text-base",children:["Session Detail â ",((Se=m.form)==null?void 0:Se.name)||"Unknown Form"]}),e.jsx(T,{variant:m.status==="completed"?"default":m.status==="in_progress"?"secondary":m.status==="error"?"destructive":"outline",children:m.status})]}),e.jsxs(A,{children:["Started ",L(m.createdAt),m.completedAt&&` ⢠C
1ompleted ${L(m.completedAt)}`]})]}),e.jsxs(b,{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2",children:"Captured Data"}),e.jsx("div",{className:"rounded-md border p-4 bg-muted/50",children:e.jsx("pre",{className:"text-sm whitespace-pre-wrap",children:JSON.stringify(m.capturedData,null,2)})})]}),((we=m.questionsAsked)==null?void 0:we.length)>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2",children:"Question & Answer Log"}),e.jsx("div",{className:"space-y-3",children:m.questionsAsked.map((t,l)=>e.jsxs("div",{className:"rounded-md border p-3 space-y-1",children:[e.jsxs("div",{className:"text-sm font-medium text-blue-600 dark:text-blue-400",children:["Q: ",t.question]}),e.jsxs("div",{className:"text-sm",children:["A: ",t.answer||e.jsx("span",{className:"text-muted-foreground italic",children:"No answer"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Field: ",t.fieldKey," ",t.timestamp&&`⢠${L(t.timestamp)}`]})]},l))})]}),((ke=m.entries)==null?void 0:ke.length)>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2",children:"Entry Log"}),e.jsxs(Je,{children:[e.jsx(Re,{children:e.jsxs(Ae,{children:[e.jsx(C,{children:"Field"}),e.jsx(C,{children:"Question"}),e.jsx(C,{children:"Response"}),e.jsx(C,{children:"Valid"}),e.jsx(C,{children:"Attempt"})]})}),e.jsx(Ge,{children:m.entries.map(t=>e.jsxs(Ae,{children:[e.jsxs(S,{children:[e.jsx("span",{className:"font-mono text-xs",children:t.fieldKey}),e.jsx("br",{}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.fieldLabel})]}),e.jsx(S,{className:"text-sm",children:t.questionAsked}),e.jsx(S,{className:"text-sm",children:t.userResponse}),e.jsx(S,{children:t.isValid?e.jsx(Ee,{className:"h-4 w-4 text-green-500"}):e.jsx(Ke,{className:"h-4 w-4 text-red-500"})}),e.jsx(S,{className:"text-sm",children:t.attemptNumber})]},t.id))})]})]}),m.apiSubmitted&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2",children:"API Submission"}),e.jsxs("div",{className:"rounded-md border p-3 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[m.apiResponseStatus&&m.apiResponseStatus<400?e.jsx(Ee,{className:"h-4 w-4 text-green-500"}):e.jsx(Ke,{className:"h-4 w-4 text-red-500"}),e.jsxs("span",{className:"text-sm font-medium",children:["Status: ",m.apiResponseStatus||"Unknown"]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Submitted ",L(m.apiSubmittedAt)]})]}),m.apiError&&e.jsx("div",{className:"text-sm text-destructive",children:m.apiError})]})]})]})]})]}):R.isLoading?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ie,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):Ce.length===0?e.jsx(g,{children:e.jsxs(b,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Be,{className:"mb-4 h-12 w-12 text-muted-foreground"}),e.jsx(j,{className:"mb-2",children:"No Captured Data Yet"}),e.jsx(A,{children:"Data will appear here when users complete data capture forms via the chatbot."})]})}):e.jsxs(Je,{children:[e.jsx(Re,{children:e.jsxs(Ae,{children:[e.jsx(C,{children:"Form"}),e.jsx(C,{children:"Status"}),e.jsx(C,{children:"Fields Captured"}),e.jsx(C,{children:"API Sent"}),e.jsx(C,{children:"Created"}),e.jsx(C,{})]})}),e.jsx(Ge,{children:Ce.map(t=>{var l,x,o,F;return e.jsxs(Ae,{className:"cursor-pointer",onClick:()=>pe(t.id),children:[e.jsx(S,{className:"font-medium",children:((l=t.form)==null?void 0:l.name)||t.formId.substring(0,8)}),e.jsx(S,{children:e.jsx(T,{variant:t.status==="completed"?"default":t.status==="in_progress"?"secondary":t.status==="error"?"destructive":"outline",children:t.status})}),e.jsxs(S,{children:[Object.keys(t.capturedData||{}).length," / ",((F=(o=(x=t.form)==null?void 0:x.jsonSchema)==null?void 0:o.fields)==null?void 0:F.length)||"?"]}),e.jsx(S,{children:t.apiSubmitted?e.jsx(Ee,{className:"h-4 w-4 text-green-500"}):e.jsx("span",{className:"text-muted-foreground",children:"â"})}),e.jsx(S,{className:"text-sm text-muted-foreground",children:L(t.createdAt)}),e.jsx(S,{children:e.jsx(bt,{className:"h-4 w-4 text-muted-foreground"})})]},t.id)})})]})]})]}),e.jsx(rt,{open:!!re,onOpenChange:()=>Y(null),children:e.jsxs(nt,{children:[e.jsxs(lt,{children:[e.jsx(ot,{children:"Delete Data Capture Form"}),e.jsx(ct,{children:"This will permanently delete this form and all associated captured data. This action cannot be undone."})]}),e.jsxs(dt,{children:[e.jsx(mt,{children:"Cancel"}),e.jsx(ht,{onClick:()=>re&&Oe.mutate({id:re}),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(vt,{open:xe,onOpenChange:t=>{t||ae()},children:e.jsxs(ft,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Nt,{children:[e.jsx(yt,{children:G?"Edit Data Capture Form":"Create Data Capture Form"}),e.jsx(Ct,{children:"Define the fields to capture, how questions are generated, and optionally configure an API target."})]}),e.jsxs(Qe,{defaultValue:"schema",className:"mt-4",children:[e.jsxs(We,{className:"grid w-full grid-cols-3",children:[e.jsx(N,{value:"schema",children:"Schema & Fields"}),e.jsx(N,{value:"questions",children:"Questions"}),e.jsx(N,{value:"api",children:"API Target"})]}
1),e.jsxs(y,{value:"schema",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Form Name *"}),e.jsx(q,{value:le,onChange:t=>P(t.target.value),placeholder:"e.g., Lead Capture, Support Ticket"})]}),e.jsx("div",{className:"space-y-2",children:e.jsxs(p,{className:"flex items-center gap-2",children:["Active",e.jsx(St,{checked:J,onCheckedChange:_})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Description"}),e.jsx(He,{value:s,onChange:t=>oe(t.target.value),placeholder:"Describe what this form captures...",rows:2})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{className:"text-sm font-semibold",children:"Fields"}),e.jsxs(f,{variant:"outline",size:"sm",onClick:$e,children:[e.jsx(Ve,{className:"mr-1 h-3 w-3"}),"Add Field"]})]}),u.length===0?e.jsx("div",{className:"rounded-md border-2 border-dashed p-6 text-center text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:'No fields defined yet. Click "Add Field" to start.'})}):e.jsx("div",{className:"space-y-3",children:u.map((t,l)=>{var x;return e.jsxs("div",{className:"flex items-start gap-2 rounded-md border p-3 bg-muted/30",children:[e.jsx(wt,{className:"h-5 w-5 mt-1 text-muted-foreground flex-shrink-0 cursor-grab"}),e.jsxs("div",{className:"flex-1 grid grid-cols-4 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(p,{className:"text-xs",children:"Key"}),e.jsx(q,{value:t.key,onChange:o=>$(l,{key:o.target.value.replace(/\s/g,"_")}),placeholder:"field_key",className:"h-8 text-sm font-mono"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(p,{className:"text-xs",children:"Label"}),e.jsx(q,{value:t.label,onChange:o=>$(l,{label:o.target.value}),placeholder:"Display label",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(p,{className:"text-xs",children:"Type"}),e.jsxs(Te,{value:t.type,onValueChange:o=>$(l,{type:o}),children:[e.jsx(De,{className:"h-8 text-sm",children:e.jsx(_e,{})}),e.jsx(Fe,{children:ss.map(o=>e.jsx(w,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("label",{className:"flex items-center gap-1 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.required,onChange:o=>$(l,{required:o.target.checked}),className:"h-3 w-3"}),"Required"]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8 ml-auto",onClick:()=>Ne(l),children:e.jsx(ze,{className:"h-3 w-3 text-destructive"})})]}),t.type==="select"&&e.jsxs("div",{className:"col-span-4 space-y-1",children:[e.jsx(p,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(q,{value:((x=t.options)==null?void 0:x.join(", "))||"",onChange:o=>$(l,{options:o.target.value.split(",").map(F=>F.trim()).filter(Boolean)}),placeholder:"Option 1, Option 2, Option 3",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"col-span-4 space-y-1",children:[e.jsx(p,{className:"text-xs",children:"Description (optional)"}),e.jsx(q,{value:t.description||"",onChange:o=>$(l,{description:o.target.value||void 0}),placeholder:"Help text for this field",className:"h-8 text-sm"})]})]})]},l)})})]})]}),e.jsxs(y,{value:"questions",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Question Mode"}),e.jsxs(Te,{value:n,onValueChange:t=>X(t),children:[e.jsx(De,{children:e.jsx(_e,{})}),e.jsxs(Fe,{children:[e.jsx(w,{value:"ai_generated",children:"AI Generated â Let AI create conversational questions"}),e.jsx(w,{value:"user_mapped",children:"User Mapped â Define exact questions for each field"}),e.jsx(w,{value:"hybrid",children:"Hybrid â AI generates, you can override individual questions"})]})]})]}),(n==="ai_generated"||n==="hybrid")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"AI Instruction (optional)"}),e.jsx(He,{value:B,onChange:t=>ce(t.target.value),placeholder:"e.g., Be friendly and casual. Ask one question at a time. Use the user's name after they provide it.",rows:3}),e.jsxs(f,{variant:"outline",size:"sm",onClick:Le,disabled:U||u.length===0,children:[U?e.jsx(Ie,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(kt,{className:"mr-2 h-4 w-4"}),"Generate Questions from Schema"]})]}),u.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(p,{className:"text-sm font-semibold",children:"Question Mappings"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n==="ai_generated"?"Preview AI-generated questions (click Generate above first).":"Define the exact question the chatbot asks for each field."}),e.jsx("div",{className:"space-y-2",children:u.map(t=>e.jsxs("div",{className:"flex gap-3 items-start",children:[e.jsx(T,{variant:"outline",className:"mt-2 min-w-[100px] text-xs font-mono flex-shrink-0",children:t.key}),e.jsx(q,{value:Q[t.key]||"",onChange:l=>W({...Q,[t.key]:l.target.value}),placeholder:`Question for ${t.label||t.key}...`,disabled:n==="ai_generated",className:"text-sm"})]},t.key))})]})]}
1),e.jsxs(y,{value:"api",className:"space-y-4 mt-4",children:[e.jsx("div",{className:"rounded-md border p-3 bg-muted/30",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(It,{className:"h-4 w-4 mt-0.5 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Optionally forward captured data to an external API when the form is completed. Leave empty to only log data in the platform."})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(p,{children:"Target API URL"}),e.jsx(q,{value:ge,onChange:t=>Z(t.target.value),placeholder:"https://api.example.com/leads"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"HTTP Method"}),e.jsxs(Te,{value:ee,onValueChange:t=>de(t),children:[e.jsx(De,{children:e.jsx(_e,{})}),e.jsxs(Fe,{children:[e.jsx(w,{value:"POST",children:"POST"}),e.jsx(w,{value:"PUT",children:"PUT"}),e.jsx(w,{value:"PATCH",children:"PATCH"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Auth Strategy"}),e.jsxs(Te,{value:i,onValueChange:t=>r(t),children:[e.jsx(De,{children:e.jsx(_e,{})}),e.jsxs(Fe,{children:[e.jsx(w,{value:"none",children:"None"}),e.jsx(w,{value:"bearer",children:"Bearer Token"}),e.jsx(w,{value:"basic",children:"Basic Auth"}),e.jsx(w,{value:"api_key",children:"API Key"})]})]})]}),i!=="none"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Credential / Token"}),e.jsx(q,{type:"password",value:D,onChange:t=>O(t.target.value),placeholder:i==="bearer"?"Bearer token":i==="basic"?"user:password":"API key value"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Headers (JSON)"}),e.jsx(He,{value:me,onChange:t=>te(t.target.value),placeholder:'{"Content-Type": "application/json"}',rows:3,className:"font-mono text-sm"})]})]})]}),e.jsxs(At,{className:"mt-4",children:[e.jsx(f,{variant:"outline",onClick:ae,children:"Cancel"}),e.jsxs(f,{onClick:qe,disabled:se.isPending||he.isPending,children:[(se.isPending||he.isPending)&&e.jsx(Ie,{className:"mr-2 h-4 w-4 animate-spin"}),G?"Save Changes":"Create Form"]})]})]})})]})}const is={active:"default",inactive:"secondary",suspended:"destructive",archived:"outline"},rs={private:"Private",shared:"Organization",public:"Public"},at=a=>{if(!a)return"â";const c=new Date(a);return Number.isNaN(c.getTime())?a:c.toLocaleString()};function Bs(){var te;const{chatbotId:a}=ut(),c=xt(),h=pt(),{currentOrgId:E,currentOrganization:xe}=Tt(),{toast:M}=it(),G=()=>{var i,r,D,O,J,_,k,R;return h.pathname.endsWith("/manage")?"manage":h.pathname.endsWith("/knowledge")?"knowledge":h.pathname.endsWith("/test")?"test":h.pathname.endsWith("/logs")?"logs":h.pathname.endsWith("/api-sources")?"api-sources":h.pathname.endsWith("/deployment")?"deployment":h.pathname.endsWith("/test-scenarios")?"test-scenarios":h.pathname.endsWith("/data-capture")?"data-capture":h.pathname.endsWith("/api")?"api":((i=h.state)==null?void 0:i.tab)==="test"?"test":((r=h.state)==null?void 0:r.tab)==="knowledge"?"knowledge":((D=h.state)==null?void 0:D.tab)==="logs"?"logs":((O=h.state)==null?void 0:O.tab)==="api-sources"?"api-sources":((J=h.state)==null?void 0:J.tab)==="deployment"?"deployment":((_=h.state)==null?void 0:_.tab)==="test-scenarios"?"test-scenarios":((k=h.state)==null?void 0:k.tab)==="data-capture"?"data-capture":((R=h.state)==null?void 0:R.tab)==="api"?"api":"overview"},[K,re]=d.useState(G()),[Y,H]=d.useState(!1),[pe,U]=d.useState(!1),[ne,le]=d.useState(0),P=I.chatbot.get.useQuery({id:a??""},{enabled:!!a}),{data:s,isLoading:oe,error:u}=P,z=()=>{const i={displayMode:"inline",chatTitle:"iBlueprint Chat",useStreaming:!1,metadata:`{ 2 "user_id": "1" 3}`,theme:void 0,legalMessage:"",initialMessage:"",dimensions:void 0,enableExportTools:!1,exportOptions:{includeTitle:!0,includeTimestamp:!0},enableDownloads:!1,enableConversationHistory:!1,conversationHistoryOptions:{allowSummary:!0,maxConversations:20},enableVoice:!1,voiceOptions:{language:"",autoSend:!0,autoSpeak:!1},requirePrivacyAgreement:!1,privacyPolicyUrl:"",enableFileUpload:!1,acceptedFileTypes:".pdf,.txt,.doc,.docx,.csv,.json",maxFileSize:10485760,openLinksInNewWindow:!1,newWindowDomains:"",sameWindowDomains:"",authToken:""};if(!a)return i;try{const r=localStorage.getItem(`chatbot_displayMode_${a}`)||"inline",D=localStorage.getItem(`chatbot_title_${a}`)||"iBlueprint Chat",O=localStorage.getItem(`chatbot_streaming_${a}`)==="true",J=localStorage.getItem(`chatbot_metadata_${a}`)||`{ 4 "user_id": "1" 5}`,_=localStorage.getItem(`chatbot_theme_${a}`),k=_?JSON.parse(_):void 0,R=localStorage.getItem(`chatbot_legalMessage_${a}`)||"",Pe=localStorage.getItem(`chatbot_initialMessage_${a}`)||"",se=localStorage.getItem(`chatbot_dimensions_${a}`),he=se?JSON.parse(se):void 0,Oe=localStorage.getItem(`chatbot_enableExportTools_${a}`)==="true",je=localStorage.getItem(`chatbot_exportOptions_${a}`),be=je?JSON.parse(je):{includeTitle:!0,includeTimestamp:!0},ae=localStorage.getItem(`chatbot_enableDownloads_${a}`)==="true",ve=localStorage.getItem(`chatbot_enableConversationHistory_${a}`)==="true",fe=localStorage.getItem(`chatbot_conversationHistoryOptions_${a}`),$e=fe?JSON.parse(fe):i.conversationHistoryOptions,$=localStorage.getItem(`chatbot_enableVoice_${a}`)==="true",Ne=localStorage.getItem(`chatbot_voiceOptions_${a}`),Le=Ne?JSON.parse(Ne):i.voiceOptions,qe=localStorage.getItem(`chatbot_requirePrivacyAgreement_${a}`)==="true",L=localStorage.getItem(`chatbot_privacyPolicyUrl_${a}`)||"",ye=localStorage.getItem(`chatbot_enableFileUpload_${a}`)==="true",Ce=localStorage.getItem(`chatbot_acceptedFileTypes_${a}`)||".pdf,.txt,.doc,.docx,.csv,.json",m=localStorage.getItem(`chatbot_maxFileSize_${a}`),ie=m?parseInt(m,10):NaN,Se=Number.isFinite(ie)&&ie>0?ie:10485760,we=localStorage.getItem(`chatbot_openLinksInNewWindow_${a}`)==="true",ke=localStorage.getItem(`chatbot_newWindowDomains_${a}`)||"",t=localStorage.getItem(`chatbot_sameWindowDomains_${a}`)||"",l=localStorage.getItem(`chatbot_authToken_${a}`)||"",x=localStorage.getItem(`chatbot_deploymentId_${a}`)||void 0,o=localStorage.getItem(`chatbot_starterPrompts_${a}`),F=o?JSON.parse(o):void 0;return{displayMode:r,chatTitle:D,useStreaming:O,metadata:J,theme:k,legalMessage:R,initialMessage:Pe,dimensions:he,enableExportTools:Oe,exportOptions:be,enableDownloads:ae,enableConversationHistory:ve,conversationHistoryOptions:$e,enableVoice:$,voiceOptions:Le,requirePrivacyAgreement:qe,privacyPolicyUrl:L,enableFileUpload:ye,acceptedFileTypes:Ce,maxFileSize:Se,openLinksInNewWindow:we,newWindowDomains:ke,sameWindowDomains:t,authToken:l,deploymentId:x,starterPrompts:F}}catch{return i}},n=d.useMemo(()=>z(),[a,ne]),X=d.useMemo(()=>typeof window>"u"?"http://localhost:3001":"https://api.iblueprint.ai",[]),Q=d.useMemo(()=>a?`${X}/api/chat/${a}`:"",[a,X]),W=I.chatbot.createVersion.useMutation({onSuccess:()=>{P.refetch(),H(!1),M({title:"Initial version created",description:"Version 1.0.0 has been created and set as the current version."})},onError:i=>{H(!1),M({title:"Failed to create version",description:i.message,variant:"destructive"})}}),B=I.chatbot.delete.useMutation({onSuccess:i=>{U(!1),M({title:"Chatbot deleted",description:`"${i.name}" has been permanently deleted.`}),c("/my-org/chatbots")},onError:i=>{U(!1),M({title:"Failed to delete chatbot",description:i.message,variant:"destructive"})}}),ce=()=>{a&&B.mutate({id:a})},ge=()=>{a&&(H(!0),W.mutate({chatbotId:a,versionNumber:1,seedPrompt:"You are a helpful AI assistant.",setAsCurrent:!0}))},Z=i=>{if(!a)return;re(i),(i==="test"||i==="logs"||i==="knowledge")&&P.refetch();const r=`/my-org/chatbots/${a}`;i==="manage"?c(`${r}/manage`,{replace:!0}):i==="test"?c(r,{replace:!0,state:{tab:"test"}}):i==="logs"?c(r,{replace:!0,state:{tab:"logs"}}):i==="api-sources"?c(r,{replace:!0,state:{tab:"api-sources"}}):i==="deployment"?c(r,{replace:!0,state:{tab:"deployment"}}):i==="test-scenarios"?c(r,{replace:!0,state:{tab:"test-scenarios"}}):i==="api"?c(r,{replace:!0,state:{tab:"api"}}):c(r,{replace:!0})},ee=()=>{c(`/myorg/${E}/chatbots`)};if(!a)return e.jsx("div",{className:"space-y-6",children:e.jsxs(g,{children:[e.jsx(v,{children:e.jsx(j,{children:"Chatbot not specified"})}),e.jsxs(b,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"We could not determine which chatbot to display. Use the button below to return to the directory."}),e.jsxs(f,{variant:"outline",onClick:ee,children:[e.jsx(Ue,{className:"mr-2 h-4 w-4"}),"Back to Organization Chatbots"]})]})]})});if(oe)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"h-10 w-32 rounded bg-muted animate-pulse"}),e.jsx("div",{className:"h-10 w-40 rounded bg-muted animate-pulse"})]}),e.jsx("div",{className:"h-24 rounded-lg bg-muted animate-pulse"}),e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:Array.from({length:4}).map((i,r)=>e.jsx("div",{className:"h-36 rounded-lg bg-muted animate-pulse"},r))})]});if(u||!s)return e.jsx("div",{className:"space-y-6",children:e.jsxs(g,{children:[e.jsx(v,{children:e.jsx(j,{children:u?"Unable to load chatbot":"Chatbot not found"})}),e.jsxs(b,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:(u==null?void 0:u.message)??"This chatbot may have been removed or you may
5not have permission to view it."}),e.jsxs(f,{variant:"outline",onClick:ee,children:[e.jsx(Ue,{className:"mr-2 h-4 w-4"}),"Back to Organization Chatbots"]})]})]})});const de=is[s.status],me=rs[s.visibility];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:ee,children:[e.jsx(Ue,{className:"mr-2 h-4 w-4"}),"Back to Organization Chatbots"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[E&&e.jsx(Xt,{organizationId:E,contentType:"chatbot",contentId:s.id,label:"Chatbot"}),e.jsx(Kt,{studio:"chat",resourceId:s.id}),e.jsx(T,{variant:de,className:"capitalize",children:s.status}),e.jsx(T,{variant:"outline",className:"uppercase tracking-wide text-xs",children:me}),xe&&e.jsxs(e.Fragment,{children:[e.jsx(T,{variant:"secondary",children:"Organization"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:xe.name})]}),s.canManage&&e.jsxs(f,{variant:"destructive",size:"sm",onClick:()=>U(!0),children:[e.jsx(ze,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:s.name}),s.description?e.jsx("p",{className:"text-muted-foreground",children:s.description}):e.jsx("p",{className:"text-muted-foreground",children:"No description recorded for this chatbot."})]}),s.canManage&&e.jsx(rt,{open:pe,onOpenChange:U,children:e.jsxs(nt,{children:[e.jsxs(lt,{children:[e.jsx(ot,{children:"Delete Chatbot?"}),e.jsxs(ct,{children:['This will permanently delete "',s.name,'" and all its associated data including versions, conversations, CORS rules, and deployments. This action cannot be undone.']})]}),e.jsxs(dt,{children:[e.jsx(mt,{children:"Cancel"}),e.jsx(ht,{onClick:ce,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:B.isPending,children:B.isPending?"Deleting...":"Delete"})]})]})}),e.jsxs(Qe,{value:K,onValueChange:Z,children:[e.jsxs(We,{className:"h-auto flex-wrap justify-start gap-1 p-1",children:[e.jsxs(N,{value:"overview",className:"data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-blue-900 dark:data-[state=active]:text-blue-300",children:[e.jsx(Ye,{className:"mr-2 h-4 w-4"}),"Overview"]}),s.canManage&&e.jsxs(e.Fragment,{children:[e.jsxs(N,{value:"manage",className:"data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-blue-900 dark:data-[state=active]:text-blue-300",children:[e.jsx(tt,{className:"mr-2 h-4 w-4"}),"Manage"]}),e.jsxs(N,{value:"knowledge",className:"data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-blue-900 dark:data-[state=active]:text-blue-300",children:[e.jsx(Dt,{className:"mr-2 h-4 w-4"}),"Knowledge"]}),e.jsxs(N,{value:"api-sources",className:"data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-blue-900 dark:data-[state=active]:text-blue-300",children:[e.jsx(_t,{className:"mr-2 h-4 w-4"}),"API Sources"]}),e.jsxs(N,{value:"data-capture",className:"data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-blue-900 dark:data-[state=active]:text-blue-300",children:[e.jsx(Me,{className:"mr-2 h-4 w-4"}),"Forms"]})]}),e.jsx("div",{className:"mx-1 h-6 w-px bg-border"}),e.jsxs(N,{value:"test",className:"data-[state=active]:bg-green-100 data-[state=active]:text-green-700 dark:data-[state=active]:bg-green-900 dark:data-[state=active]:text-green-300",children:[e.jsx(Ft,{className:"mr-2 h-4 w-4"}),"Configure"]}),s.canManage&&e.jsxs(e.Fragment,{children:[e.jsxs(N,{value:"deployment",className:"data-[state=active]:bg-green-100 data-[state=active]:text-green-700 dark:data-[state=active]:bg-green-900 dark:data-[state=active]:text-green-300",children:[e.jsx(es,{className:"mr-2 h-4 w-4"}),"Deployments"]}),e.jsxs(N,{value:"test-scenarios",className:"data-[state=active]:bg-green-100 data-[state=active]:text-green-700 dark:data-[state=active]:bg-green-900 dark:data-[state=active]:text-green-300",children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),"Tests"]})]}),e.jsx("div",{className:"mx-1 h-6 w-px bg-border"}),e.jsxs(N,{value:"logs",className:"data-[state=active]:bg-purple-100 data-[state=active]:text-purple-700 dark:data-[state=active]:bg-purple-900 dark:data-[state=active]:text-purple-300",children:[e.jsx(Mt,{className:"mr-2 h-4 w-4"}),"Logs"]}),s.canManage&&e.jsxs(N,{value:"api",className:"data-[state=active]:bg-purple-100 data-[state=active]:text-purple-700 dark:data-[state=active]:bg-purple-900 dark:data-[state=active]:text-purple-300",children:[e.jsx(Pt,{className:"mr-2 h-4 w-4"}),"API"]})]}),["overview","manage","knowledge","api-sources","data-capture"].includes(K)&&e.jsxs(Ot,{className:"mt-4 border-blue-200 bg-blue-50 dark:border-blue-800 dark:bg-blue-950",children:[e.jsx($t,{className:"h-4 w-4 text-blue-600 dar
5k:text-blue-400"}),e.jsxs(Lt,{className:"text-blue-800 dark:text-blue-200",children:[e.jsx("strong",{children:"Global Setting:"})," Changes made here will affect"," ",e.jsx("strong",{children:"all deployments"})," of this chatbot."]})]}),e.jsxs(y,{value:"overview",className:"space-y-6",children:[e.jsxs(g,{id:"overview-summary",children:[e.jsx(v,{children:e.jsx(j,{children:"Summary"})}),e.jsxs(b,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx(V,{label:"Slug",value:s.slug??"â",icon:e.jsx(st,{className:"h-4 w-4"})}),e.jsx(V,{label:"Default AI Connection",value:s.defaultLlmConnectionId?"Configured":"Not set",icon:e.jsx(tt,{className:"h-4 w-4"})}),e.jsx(V,{label:"Current Version",value:s.currentVersionId?"Active":"None",icon:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsx(et,{}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",id:"overview-metrics",children:[e.jsx(V,{label:"Versions",value:String(s.versionCount),icon:e.jsx(st,{className:"h-4 w-4"})}),e.jsx(V,{label:"Document Sets",value:String(s.documentSetCount),icon:e.jsx(Ze,{className:"h-4 w-4"})}),e.jsx(V,{label:"Endpoints",value:String(s.endpointCount),icon:e.jsx(qt,{className:"h-4 w-4"})}),e.jsx(V,{label:"Sessions",value:String(s.sessionCount),icon:e.jsx(Ye,{className:"h-4 w-4"})})]}),e.jsx(et,{}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-1",children:e.jsx(V,{label:"Total Token Usage",value:((te=s.totalTokens)==null?void 0:te.toLocaleString())||"0",icon:e.jsx(ts,{className:"h-4 w-4"})})})]})]}),e.jsxs(g,{children:[e.jsx(v,{children:e.jsx(j,{children:"Lifecycle"})}),e.jsxs(b,{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Created"}),e.jsx("p",{className:"text-sm font-semibold",children:at(s.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Last Updated"}),e.jsx("p",{className:"text-sm font-semibold",children:at(s.updatedAt)})]})]})]}),s.tags.length>0&&e.jsxs(g,{children:[e.jsx(v,{children:e.jsx(j,{children:"Tags"})}),e.jsx(b,{children:e.jsx("div",{className:"flex flex-wrap gap-2",children:s.tags.map(i=>e.jsx(T,{variant:"secondary",children:i},i))})})]}),s.canManageSharing&&e.jsx(Vt,{chatbotId:s.id,canManage:!0})]}),e.jsxs(y,{value:"manage",className:"space-y-6",children:[e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(j,{children:"Chatbot Settings"}),e.jsx(A,{children:"Configure core chatbot settings including name, description, AI connection, and visibility. Changes apply to all deployments."})]}),e.jsx(b,{children:e.jsx(Et,{chatbot:s,onUpdated:()=>P.refetch()})})]}),e.jsx(Zt,{chatbotId:s.id,organizationId:E}),s.currentVersionId?e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(j,{children:"System Prompt Configuration"}),e.jsx(A,{children:"Define the base system prompt and prompt blocks that shape your chatbot's behavior across all deployments."})]}),e.jsx(b,{children:e.jsx(Ht,{chatbotId:s.id,versionId:s.currentVersionId})})]}):e.jsxs(g,{children:[e.jsx(v,{children:e.jsx(j,{children:"System Prompt Configuration"})}),e.jsxs(b,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active version found. Create an initial version to configure the system prompt and enable prompt blocks."}),e.jsx(f,{onClick:ge,disabled:Y,children:Y?"Creating...":"Create Initial Version"})]})]})]}),e.jsx(y,{value:"knowledge",className:"space-y-6",children:e.jsx(Qt,{chatbot:s})}),e.jsxs(y,{value:"deployment",className:"space-y-6",children:[e.jsx(Wt,{chatbotId:s.id,onLoadDeployment:i=>{localStorage.setItem(`chatbot_deploymentId_${s.id}`,i.id);const r=i.config;r&&(localStorage.setItem(`chatbot_displayMode_${s.id}`,r.displayMode),localStorage.setItem(`chatbot_title_${s.id}`,r.chatTitle),localStorage.setItem(`chatbot_streaming_${s.id}`,r.useStreaming.toString()),localStorage.setItem(`chatbot_metadata_${s.id}`,JSON.stringify(r.metadata)),r.theme&&localStorage.setItem(`chatbot_theme_${s.id}`,JSON.stringify(r.theme)),r.legalMessage&&localStorage.setItem(`chatbot_legalMessage_${s.id}`,r.legalMessage),r.initialMessage!==void 0&&localStorage.setItem(`chatbot_initialMessage_${s.id}`,r.initialMessage),r.dimensions&&localStorage.setItem(`chatbot_dimensions_${s.id}`,JSON.stringify(r.dimensions)),r.starterPrompts&&localStorage.setItem(`chatbot_starterPrompts_${s.id}`,JSON.stringify(r.starterPrompts))),le(D=>D+1),Z("test")}}),e.jsx(Ut,{chatbotId:s.id}),e.jsx(Rt,{chatbotId:s.id,chatEndpoint:Q,displayMode:n.displayMode,chatTitle:n.chatTitle,useStreaming:n.useStreaming,metadata:n.metadata,initialMessage:n.initialMessage,starterPrompts:n.starterPrompts,deploymentId:n.deploymentId,legalMessage:n.legalMessage,dimensions:n.dimensions,enableExportTools:n.enableExportTools,exportOptions:n.exportOptions,enableDownloads:n.enableDownloads,enableConversationHistory:n.enableConversationHistory,conversationHistoryOptions:n.conversationHistoryOptions,enableVoice:n.enableVoice,voiceOptions:n.voiceOptions,requirePrivacyAgreement:n.requirePrivacyAgreement,privacyPolicyUrl:n.privacyPolicyUrl||void 0,enableFileUpload:n.enableFileUpload,acceptedFileTypes:n.acceptedFileTypes,openLinksInNewWindow:n.openLinksInNewWindow,newWindowDomains:n.newWindowDomains,sameWindowDomains:n.sameWindowDomains,maxFileSize:n.maxFileSize,authToken:n.authToken||void 0,theme:n.theme,compact:!1}),e.jsxs(g,{children:[e.jsx(v,{children:e.jsx(j,{children:"How to Use"})}),e.jsx(b,{className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary text-primary-foreground text-xs",children:"1"}),"Load the Chat Widget Script"]}),e.jsxs("p",{className:"text-sm text-muted-foreground ml-8",children:["Include the"," ",e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs",children:"iblueprintChat.js"})," ","script in your HTML page. This script provides the global"," ",e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs",children:"IBlueprintChat"})," ","class."]}),e.jsx("pre",{className:"ml-8 mt-2 overflow-x-auto rounded-md bg-muted p-3 text-xs",children:'<script src="https://your-domain.com/iblueprintChat.js"><\/script>'})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary text-primary-foreground text-xs",children:"2"}),"Initialize the Chat"]}),e.jsxs("p",{className:"text-sm text-muted-foreground ml-8",children:["Create a new instance of"," ",e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs",children:"IBlueprintChat"})," ","with your chatbot ID and API endpoint. The code snippet above includes the correct configuration for this chatbot."]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary text-primary-foreground text-xs",children:"3"}),"Configure Permissions"]}),e.jsx("p",{className:"text-sm text-muted-foreground ml-8",children:"Make sure to add your website's domain to the Permissions settings above. The chatbot will only work on domains that are explicitly allowed."})]})]})})]})]}),e.jsx(y,{value:"test",className:"space-y-6",children:e.jsx(Jt,{chatId:s.id})}),e.jsx(y,{value:"logs",className:"space-y-6",children:e.jsx(Bt,{chatbotId:s.id})}),e.jsx(y,{value:"api-sources",className:"space-y-6",children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(j,{children:"Exter
5nal API Sources"}),e.jsx(A,{children:"Configure external APIs that provide dynamic data to your chatbot. These sources apply to all deployments."})]}),e.jsx(b,{children:e.jsx(zt,{chatbotId:s.id})})]})}),e.jsx(y,{value:"data-capture",className:"space-y-6",children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsxs(j,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-5 w-5"}),"Data Capture Forms"]}),e.jsx(A,{children:"Define structured data collection forms. The chatbot will ask users questions to fill each field, then optionally forward the captured data to a target API."})]}),e.jsx(b,{children:e.jsx(as,{chatbotId:s.id})})]})}),e.jsx(y,{value:"test-scenarios",className:"space-y-6",children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsxs(j,{className:"flex items-center gap-2",children:[e.jsx(Xe,{className:"h-5 w-5"}),"Test Scenarios"]}),e.jsx(A,{children:"Create and manage test scenarios for this chatbot. Test scenarios can be linked to specific deployments for targeted testing."})]}),e.jsx(b,{children:e.jsx(Gt,{chatbotId:s.id,embedded:!0})})]})}),e.jsx(y,{value:"api",className:"space-y-6",children:s.canManage?e.jsx(Yt,{organizationId:E,chatbotId:s.id}):e.jsx(g,{children:e.jsxs(v,{children:[e.jsx(j,{children:"Restricted"}),e.jsx(A,{children:"Only organization owners and admins can manage iBlueprint API keys."})]})})})]})]})}function V({label:a,value:c,icon:h}){return e.jsxs("div",{className:"flex items-center justify-between rounded-md border bg-muted/40 p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:a}),e.jsx("p",{className:"text-lg font-semibold",children:c})]}),h&&e.jsx("span",{className:"text-muted-foreground",children:h})]})}export{Bs 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.