1import{a,j as e}from"./vendor-query-B-_nDQQY.js";import{S as k,B as x,W as M,I as C,b as z}from"./index-D8ww6b7J.js";import{C as I}from"./ChatMarkdown-CsletxwS.js";import{M as E}from"./maximize-2-Cv_O9ZWc.js";import{M as A}from"./minimize-2-BBHD90rz.js";import{S as D}from"./send-DJBvsBZ5.js";import"./vendor-three-1K-S22da.js";import"./vendor-charts-i-522T5A.js";import"./vendor-react-BUIlT3ms.js";import"./vendor-pdf-Bwkk3Ew0.js";import"./vendor-radix-X0WMATEu.js";import"./vendor-editor-DQgOI56I.js";function Y({headerExtra:j=null,showMinimize:v=!0}){const[c,u]=a.useState([]),[d,h]=a.useState(""),[n,f]=a.useState(!1),[b,N]=a.useState(null),[p,o]=a.useState(""),[l,y]=a.useState(!1),g=a.useRef(null);a.useEffect(()=>{var s;l||(s=g.current)==null||s.scrollIntoView({behavior:"smooth"})},[c,l]);const m=async s=>{const r=(typeof s=="string"?s:d).trim();if(!(!r||n)){h(""),o(""),u(i=>[...i,{role:"user",content:r}]),f(!0);try{const i=await z.functions.invoke("milliChat",{conversation_id:b,message:r}),t=(i==null?void 0:i.data)||{};t.conversation_id&&N(t.conversation_id),Array.isArray(t.messages)&&t.messages.length>0&&u(t.messages),t.error?o(t.error):t.timed_out&&o("Milli is taking longer than usual â please try again or call us.")}catch{o("Sorry, the chat is unavailable right now. Please call or email us.")}finally{f(!1)}}},w=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),m())},S=["Quartz vs granite?","Kitchen pricing?","Available colors?","Schedule measurement"];return e.jsxs("div",{className:"flex flex-col h-full bg-card rounded-lg shadow-xl overflow-hidden border border-border",children:[e.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary/80 p-3 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"w-8 h-8 shrink-0 rounded-full bg-white/20 flex items-center justify-center",children:e.jsx(k,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-sm font-semibold text-white truncate",children:"Milli â Sales"}),e.jsx("p",{className:"text-xs text-white/80 truncate",children:"Your countertop specialist"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[j,v&&e.jsx(x,{variant:"ghost",size:"icon",onClick:()=>y(!l),className:"h-8 w-8 text-white hover:bg-white/20",children:l?e.jsx(E,{className:"w-4 h-4"}):e.jsx(A,{className:"w-4 h-4"})})]})]}),!l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-y-auto min-h-[400px] max-h-[500px]",children:e.jsxs("div",{className:"p-3 space-y-3",children:[c.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(M,{className:"w-6 h-6 text-primary"})}),e.jsx("h2",{className:"text-sm font-semibold text-foreground mb-2",children:"Welcome! ð"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 px-4",children:"Ask me about countertop materials, pricing, or schedule a free measurement."}),e.jsx("div",{className:"flex flex-wrap gap-1 justify-center px-2",children:S.map((s,r)=>e.jsx(x,{variant:"outline",size:"sm",onClick:()=>m(s),className:"text-xs h-7",children:s},r))})]}):c.map((s,r)=>e.jsx("div",{className:`flex ${s.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`rounded-xl px-3 py-2.5 ${s.role==="user"?"max-w-[85%] bg-primary text-primary-foreground":"w-full bg-muted text-foreground"}`,children:s.role==="assistant"?e.jsx(I,{content:s.content}):e.jsx("p",{className:"text-xs leading-relaxed whitespace-pre-wrap",children:s.content})})},r)),n&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-muted rounded-xl px-3 py-2",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground rounded-full animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground rounded-full animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})})}),e.jsx("div",{ref:g})]})}),e.jsxs("div",{className:"border-t border-border p-3",children:[p&&e.jsx("p",{className:"text-[11px] text-muted-foreground mb-2",children:p}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{value:d,onChange:s=>h(s.target.value),onKeyDown:w,placeholder:"Ask about countertops...",className:"flex-1 text-xs",disabled:n}),e.jsx(x,{onClick:()=>m(),disabled:!d.trim()||n,size:"sm",className:"px-3",children:e.jsx(D,{className:"w-4 h-4"})})]})]})]})]})}export{Y 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.