PageSourceSearch

https://www.clinicadamente.com/assets/SofiaChat-uNkBrUr4.js

js clinicadamente.com collected 2026-10-04 23:40:29 UTC 8,703 bytes, 50 lines download raw bytes

1import{r as a,u as z,j as e,B as c,X as m,C as L,L as W,S as B,M as O}from"./vendor-D7X22TEy.js";import{t as y,g as w,a as _,b as A,c as N,d as P}from"./index-B1RviW89.js";function Y(){const n="sofia_session_id";if(typeof sessionStorage>"u")return"";let s=sessionStorage.getItem(n);return s||(s=crypto.randomUUID(),sessionStorage.setItem(n,s)),s}const H={role:"assistant",content:`Olá! 👋 Sou a Sofia, assistente virtual da Clínica da Mente.
2
3Estou aqui para ajudá-lo(a) a perceber como podemos apoiar a sua saúde emocional. Como se sente hoje? Em que posso ajudar?`},K=`
4  @keyframes sofia-enter {
5    0%   { opacity: 0; transform: scale(0.3) translateY(24px); }
6    65%  { transform: scale(1.1) translateY(-4px); }
7    85%  { transform: scale(0.96) translateY(2px); }
8    100% { opacity: 1; transform: scale(1) translateY(0); }
9  }
10  @keyframes sofia-wiggle {
11    0%,100% { transform: rotate(0deg) scale(1); }
12    20%     { transform: rotate(-14deg) scale(1.1); }
13    40%     { transform: rotate(14deg) scale(1.1); }
14    60%     { transform: rotate(-8deg) scale(1.05); }
15    80%     { transform: rotate(6deg) scale(1.05); }
16  }
17  @keyframes sofia-ring {
18    0%   { box-shadow: 0 0 0 0 rgba(201,168,76,0.55); }
19    70%  { box-shadow: 0 0 0 14px rgba(201,168,76,0); }
20    100% { box-shadow: 0 0 0 0 rgba(201,168,76,0); }
21  }
22  .sofia-btn-enter  { animation: sofia-enter 0.75s cubic-bezier(0.34,1.56,0.64,1) both; }
23  .sofia-btn-wiggle { animation: sofia-wiggle 0.65s ease-in-out; }
24  .sofia-btn-ring   { animation: sofia-ring 2s ease-out infinite; }
25`;function F(){const{data:n}=y.sofia.getStatus.useQuery(void 0,{staleTime:6e4}),[s,f]=a.useState(!1),[p,d]=a.useState([H]),[r,h]=a.useState(""),[j]=a.useState(Y),[S,v]=a.useState(!1),[k,x]=a.useState(!1),[C,I]=a.useState(!1),u=a.useRef(null),g=a.useRef(null);a.useEffect(()=>{const t=setTimeout(()=>v(!0),1500),i=()=>{s||(x(!0),setTimeout(()=>x(!1),700))},o=setTimeout(i,5e3),D=setInterval(i,2e4);return()=>{clearTimeout(t),clearTimeout(o),clearInterval(D)}},[s]);const l=y.sofia.sendMessage.useMutation({onSuccess:t=>{!!(t.leadData?.name&&t.leadData?.email&&t.leadData?.phone)&&!C?(I(!0),w.chatbotComplete("lead_captured"),_("sofia","lead_captured"),A("sofia","lead_captured"),d(o=>[...o,{role:"assistant",content:t.reply,showBookingButton:!0}])):d(o=>[...o,{role:"assistant",content:t.reply}])},onError:()=>{d(t=>[...t,{role:"assistant",content:"Desculpe, ocorreu um erro. Por favor tente novamente."}])}});a.useEffect(()=>{u.current?.scrollIntoView({behavior:"smooth"})},[p]),a.useEffect(()=>{s&&setTimeout(()=>g.current?.focus(),100)},[s]);const b=()=>{const t=r.trim();!t||l.isPending||(d(i=>[...i,{role:"user",content:t}]),h(""),l.mutate({sessionId:j,message:t,pageOrigin:window.location.pathname}))},E=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),b())},[R]=z(),T=R.startsWith("/testemunhos/"),M=["sofia-btn",S?"sofia-btn-enter":"sofia-btn-hidden",k&&!s?"sofia-btn-wiggle":"",s?"":"sofia-btn-ring",T?"sofia-btn-testemunho":""].filter(Boolean).join(" ");return n!==void 0&&!n.isActive?null:e.jsxs(e.Fragment,{children:[e.jsx("style",{children:K}),e.jsx("style",{children:`
26        .sofia-btn-hidden { opacity: 0; pointer-events: none; }
27        .sofia-btn {
28          position: fixed;
29          bottom: 24px;
30          right: 24px;
31          z-index: 9999;
32          width: 56px;
33          height: 56px;
34          border-radius: 9999px;
35          background: linear-gradient(135deg, #0d1b2a 0%, #1a2d42 100%);
36          box-shadow: 0 4px 20px rgba(0,0,0,0.25);
37          display: flex;
38          align-items: center;
39          justify-content: center;
40          cursor: pointer;
41          border: none;
42          outline: none;
43          transition: transform 0.15s ease;
44        }
45        .sofia-btn:hover  { transform: scale(1.08); }
46        .sofia-btn:active { transform: scale(0.94); }
47        @media (max-width: 767px) {
48          .sofia-btn-testemunho { display: none !important; }
49        }
50      `}),s&&e.jsxs("div",{style:{position:"fixed",bottom:"92px",right:"16px",zIndex:9998,width:"min(384px, calc(100vw - 32px))",maxHeight:"min(600px, calc(100vh - 120px))",display:"flex",flexDirection:"column",borderRadius:"16px",boxShadow:"0 8px 40px rgba(0,0,0,0.18)",overflow:"hidden"},children:[e.jsxs("div",{style:{background:"#0d1b2a",padding:"12px 16px",display:"flex",alignItems:"center",gap:"12px",flexShrink:0},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:"50%",background:"#c9a84c",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(c,{style:{width:18,height:18,color:"white"}})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{color:"white",fontWeight:600,fontSize:14,margin:0,lineHeight:1.3},children:"Sofia"}),e.jsx("p",{style:{color:"#c9a84c",fontSize:11,margin:0},children:"Assistente Virtual · Clínica da Mente"})]}),e.jsx("button",{onClick:()=>f(!1),style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",padding:4,display:"flex"},"aria-label":"Fechar",children:e.jsx(m,{style:{width:16,height:16}})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",background:"#f9fafb",padding:"16px",display:"flex",flexDirection:"column",gap:"12px"},children:[p.map((t,i)=>e.jsxs("div",{style:{display:"flex",justifyContent:t.role==="user"?"flex-end":"flex-start",ga
50p:8},children:[t.role==="assistant"&&e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#0d1b2a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:2},children:e.jsx(c,{style:{width:13,height:13,color:"#c9a84c"}})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,maxWidth:"78%"},children:[e.jsx("div",{style:{padding:"8px 12px",borderRadius:t.role==="user"?"16px 16px 4px 16px":"16px 16px 16px 4px",background:t.role==="user"?"#0d1b2a":"white",color:t.role==="user"?"white":"#1f2937",fontSize:13,lineHeight:1.55,whiteSpace:"pre-wrap",boxShadow:t.role==="assistant"?"0 1px 4px rgba(0,0,0,0.07)":"none"},children:t.content}),t.showBookingButton&&e.jsxs("a",{href:"/contactos","data-track-cta":"sofia-chat-chatbot","data-track-page":"sofia-chat",onClick:()=>N("sofia-chat-chatbot","sofia-chat","chatbot"),style:{display:"inline-flex",alignItems:"center",gap:8,background:"linear-gradient(135deg, #c9a84c 0%, #b8922e 100%)",color:"white",fontWeight:700,fontSize:13,padding:"10px 18px",borderRadius:10,textDecoration:"none",boxShadow:"0 2px 8px rgba(201,168,76,0.4)",transition:"transform 0.15s, box-shadow 0.15s",cursor:"pointer"},onMouseEnter:o=>{o.currentTarget.style.transform="scale(1.03)"},onMouseLeave:o=>{o.currentTarget.style.transform="scale(1)"},children:[e.jsx(L,{style:{width:15,height:15}}),"Marcar Consulta"]})]})]},i)),l.isPending&&e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#0d1b2a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:2},children:e.jsx(c,{style:{width:13,height:13,color:"#c9a84c"}})}),e.jsxs("div",{style:{background:"white",borderRadius:"16px 16px 16px 4px",padding:"8px 12px",display:"flex",alignItems:"center",gap:6,boxShadow:"0 1px 4px rgba(0,0,0,0.07)"},children:[e.jsx(W,{style:{width:13,height:13,color:"#9ca3af"},className:"animate-spin"}),e.jsx("span",{style:{fontSize:12,color:"#9ca3af"},children:"Sofia está a escrever..."})]})]}),e.jsx("div",{ref:u})]}),e.jsxs("div",{style:{background:"white",borderTop:"1px solid #f1f5f9",padding:"12px",display:"flex",gap:8,flexShrink:0},children:[e.jsx("input",{ref:g,type:"text",value:r,onChange:t=>h(t.target.value),onKeyDown:E,placeholder:"Escreva a sua mensagem...",disabled:l.isPending,style:{flex:1,fontSize:13,background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:12,padding:"8px 12px",outline:"none",color:"#1f2937"}}),e.jsx("button",{onClick:b,disabled:!r.trim()||l.isPending,style:{width:36,height:36,borderRadius:10,background:r.trim()?"#c9a84c":"#e5e7eb",border:"none",cursor:r.trim()?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"background 0.15s"},"aria-label":"Enviar",children:e.jsx(B,{style:{width:15,height:15,color:"white"}})})]})]}),e.jsx("button",{className:M,onClick:()=>{const t=!s;f(t),t&&(w.chatbotOpen(),P())},"aria-label":"Abrir chat com Sofia",children:s?e.jsx(m,{style:{width:22,height:22,color:"white"}}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(O,{style:{width:24,height:24,color:"#c9a84c"}}),e.jsx("span",{style:{position:"absolute",top:-3,right:-3,width:11,height:11,background:"#4ade80",borderRadius:"50%",border:"2px solid #0d1b2a"},className:"animate-pulse"})]})})]})}export{F 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.