PageSourceSearch

https://maiwerk-finanzpartner.de/assets/ChatWidget-COD8BVAG.js

js maiwerk-finanzpartner.de collected 2026-10-06 15:17:23 UTC 24,058 bytes, 3 lines download raw bytes

1import{r,u as Se,j as e,L as Je}from"./vendor-react-DA_uB1oQ.js";import{B as te}from"./button-D5pzxbgC.js";import{u as _e,b as V}from"./index-gltKyd8N.js";import{b as ge}from"./bookingLinks-C67UWCQz.js";import{C as Te}from"./ChatMessageContent-Cv5-GNvE.js";import{V as Ae}from"./VoiceDictateButton-Dfcl0q4i.js";import{X as q,a3 as Oe,aw as Ee,C as G,av as ee}from"./vendor-icons-avKxPNTP.js";import"./vendor-radix-D6iRu3ao.js";import"./vendor-ui-C834t01q.js";import"./vendor-query-DOj2nc8G.js";import"./vendor-supabase-CyYs4BP5.js";const Me="https://ssxlrczpnpbqacaetpzg.supabase.co/functions/v1/chat",ae="https://ssxlrczpnpbqacaetpzg.supabase.co/functions/v1/chat-events";function $(){return 300+Math.random()*400}const Be={de:"de-DE",en:"en-US",fr:"fr-FR",es:"es-ES"};function _(a="de"){return new Date().toLocaleTimeString(Be[a]||"de-DE",{hour:"2-digit",minute:"2-digit"})}const se={};async function Q(a,i,o={}){if(a)try{await fetch(ae,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNzeGxyY3pwbnBicWFjYWV0cHpnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjY5NzcxOTAsImV4cCI6MjA4MjU1MzE5MH0.A5uRzswHhetMJr5JKxQ3HUsPzHI39f5KWkBqJ_zDCU8"},body:JSON.stringify({action:"track",chatLeadId:a,leadToken:se[a],eventType:i,eventData:o})})}catch(d){console.error("Track event failed:",d)}}async function xe(a,i){if(a)try{await fetch(ae,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNzeGxyY3pwbnBicWFjYWV0cHpnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjY5NzcxOTAsImV4cCI6MjA4MjU1MzE5MH0.A5uRzswHhetMJr5JKxQ3HUsPzHI39f5KWkBqJ_zDCU8"},body:JSON.stringify({action:"update",chatLeadId:a,leadToken:se[a],updates:i})})}catch(o){console.error("Update lead failed:",o)}}async function Le(a){try{const o=await(await fetch(ae,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNzeGxyY3pwbnBicWFjYWV0cHpnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjY5NzcxOTAsImV4cCI6MjA4MjU1MzE5MH0.A5uRzswHhetMJr5JKxQ3HUsPzHI39f5KWkBqJ_zDCU8"},body:JSON.stringify({action:"create",updates:{source_page:a}})})).json();return o.id&&o.token&&(se[o.id]=o.token),o.id||null}catch(i){return console.error("Create lead failed:",i),null}}function be(a){const i=a.match(/\[CTA:(termin|rueckruf|webinar|service)\]/);return i?i[1]:null}function U({size:a="sm"}){const i=a==="lg"?"w-10 h-10 text-base":"w-7 h-7 text-xs";return e.jsx("div",{className:V(i,"rounded-full bg-maiwerk-dark flex items-center justify-center text-white font-bold flex-shrink-0 select-none"),children:"M"})}function ke(){return e.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-green-500"})]})}const Ue={aufbauen:"aufbauen",nutzen:"nutzen",geldanlage:"geldanlage",vermoegensverwaltung:"vermoegensverwaltung",altersvorsorge:"altersvorsorge",bu:"bu",pkv:"pkv",immobilie:"immobilie",finanzplanung:"finanzplanung",finanzcoaching:"finanzcoaching",produktcheck:"produktcheck",honorarberatung:"general",allgemein:"general"},He=[["/vermoegen-aufbauen","aufbauen"],["/vermoegen-nutzen","nutzen"],["/vermoegensverwaltung","vermoegensverwaltung"],["/finanzcoaching","finanzcoaching"],["/berufsunfaehigkeits-versicherung","bu"],["/private-krankenversicherung","pkv"],["/baufinanzierung","immobilie"],["/produktanalyse","produktcheck"],["/altersvorsorge","altersvorsorge"],["/finanzplanung","finanzplanung"],["/geldanlage","geldanlage"]];function Fe(a,i=""){for(const[d,c]of He)if(i.includes(`(${d})`))return ge[c];const o=Ue[a]||"general";return ge[o]}function Pe({type:a,onCtaClick:i,topicCategory:o,messageContent:d="",t:c}){if(a==="termin"){const x=Fe(o,d);return e.jsxs("div",{className:"bg-maiwerk-orange/10 border border-maiwerk-orange/20 rounded-xl p-3 mt-2",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground mb-2 flex items-center gap-2",children:[e.jsx(G,{className:"w-4 h-4 text-maiwerk-orange"}),c("chat.cta.freeCall")]}),e.jsxs("a",{href:x,target:"_blank",rel:"noopener noreferrer",onClick:()=>i("termin"),className:"inline-flex items-center gap-2 bg-maiwerk-orange hover:bg-maiwerk-orange/90 text-white text-sm font-medium px-4 py-2 rounded-lg transition-colors",children:[e.jsx(G,{className:"w-4 h-4"}),c("chat.cta.bookAppointment")]})]})}return a==="rueckruf"?e.jsxs("div",{className:"bg-maiwerk-dark/5 border border-maiwerk-dark/10 rounded-xl p-3 mt-2",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground mb-2 flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4 text-maiwerk-dark"}),c("chat.cta.callbackTitle")]}),e.jsxs("button",{onClick:()=>i("rueckruf"),className:"inline-flex items-center gap-2 bg-maiwerk-dark hover:bg-maiwerk-dark/90 text-white text-sm font-medium px-4 py-2 rounded-lg transition-colors",children:[e.jsx(ee,{className:"w-4 h-4"}),c("chat.cta.callbackBtn")]})]}):a==="webinar"?e.jsxs("div",{className:"bg-maiwerk-orange/10 border border-maiwerk-orange/20 rounded-xl p-3 mt-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground mb-2",children:c("chat.cta.webinarTitle")}),e.jsx(Je,{to:"/kostenlose-infotermine",onClick:()=>i("webinar"),className:"inline-flex items-center gap-2 bg-maiwerk-orange hover:bg-maiwerk-orange/90 text-white text-sm font-medium px-4 py-2 rounded-lg transition-colors",children:c("chat.cta.webinarBtn")})]}):a==="service"?e.jsxs("div",{className:"bg-maiwerk-dark/5 border border-maiwerk-dark/10 rounded-xl p-3 mt-2",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground mb-2 flex items-center gap-2",children:[e.jsx(G,{className:"w-4 h-4 text-maiwerk-dark"}),c("chat.cta.serviceTitle")]}),e.jsx("button",{onClick:()=>i("service"),className:"inline-flex items-center gap-2 bg-maiwerk-dark hover:bg-maiwerk-dark/90 text-white text-sm font-medium px-4 py-2 rounded-lg transition-colors",children:c("chat.cta.serviceBtn")})]}):null}
1const we=[{value:"termin_verschieben",key:"chat.service.optionTerminVerschieben"},{value:"termin_absagen",key:"chat.service.optionTerminAbsagen"},{value:"doppelbuchung",key:"chat.service.optionDoppelbuchung"},{value:"buchung_klemmt",key:"chat.service.optionBuchungKlemmt"},{value:"bestandskunde",key:"chat.service.optionBestandskunde"},{value:"sonstiges",key:"chat.service.optionSonstiges"}];function Re({defaultName:a,defaultEmail:i,onSubmit:o,t:d}){const[c,x]=r.useState(we[0].value),[y,I]=r.useState(a||""),[b,j]=r.useState(i||""),[v,k]=r.useState(""),[s,w]=r.useState(""),[M,B]=r.useState(!1),H=async f=>{if(f.preventDefault(),!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b.trim())){w(d("chat.service.errorEmail"));return}if(v.trim().length<5){w(d("chat.service.errorText"));return}w(""),B(!0),await o({anliegen:c,vorname:y.trim(),email:b.trim(),beschreibung:v.trim()})||(B(!1),w(d("chat.service.errorSend")))},T="w-full px-3 py-2 text-sm bg-secondary rounded-lg border-0 focus:outline-none focus:ring-2 focus:ring-maiwerk-dark/20 placeholder:text-muted-foreground";return e.jsxs("form",{onSubmit:H,className:"bg-maiwerk-dark/5 border border-maiwerk-dark/10 rounded-xl p-3 mt-2 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:d("chat.service.anliegenLabel")}),e.jsx("select",{value:c,onChange:f=>x(f.target.value),className:T,children:we.map(f=>e.jsx("option",{value:f.value,children:d(f.key)},f.value))}),e.jsx("input",{type:"text",value:y,onChange:f=>I(f.target.value),placeholder:d("chat.service.namePlaceholder"),className:T}),e.jsx("input",{type:"email",value:b,onChange:f=>j(f.target.value),placeholder:d("chat.service.emailPlaceholder"),className:T}),e.jsx("textarea",{value:v,onChange:f=>k(f.target.value),rows:3,placeholder:d("chat.service.textPlaceholder"),className:V(T,"resize-none")}),s&&e.jsx("p",{className:"text-xs text-destructive",children:s}),e.jsx(te,{type:"submit",size:"sm",disabled:M,className:"w-full rounded-lg bg-maiwerk-dark hover:bg-maiwerk-dark/90 text-white text-sm",children:d(M?"chat.service.sending":"chat.service.submit")})]})}function Ye({onSubmit:a,t:i}){const[o,d]=r.useState(""),[c,x]=r.useState(""),[y,I]=r.useState(""),b=j=>{if(j.preventDefault(),!o.trim()&&!c.trim()){I(i("chat.callback.errorEmpty"));return}if(c&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c)){I(i("chat.callback.errorEmail"));return}a({phone:o.trim(),email:c.trim()})};return e.jsxs("form",{onSubmit:b,className:"bg-maiwerk-dark/5 border border-maiwerk-dark/10 rounded-xl p-3 mt-2 space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4 text-maiwerk-dark"}),i("chat.cta.callbackBtn")]}),e.jsx("input",{type:"tel",value:o,onChange:j=>d(j.target.value),placeholder:i("chat.callback.phonePlaceholder"),className:"w-full px-3 py-2 text-sm bg-secondary rounded-lg border-0 focus:outline-none focus:ring-2 focus:ring-maiwerk-dark/20 placeholder:text-muted-foreground"}),e.jsx("input",{type:"email",value:c,onChange:j=>x(j.target.value),placeholder:i("chat.callback.emailPlaceholder"),className:"w-full px-3 py-2 text-sm bg-secondary rounded-lg border-0 focus:outline-none focus:ring-2 focus:ring-maiwerk-dark/20 placeholder:text-muted-foreground"}),y&&e.jsx("p",{className:"text-xs text-destructive",children:y}),e.jsx(te,{type:"submit",size:"sm",className:"w-full rounded-lg bg-maiwerk-dark hover:bg-maiwerk-dark/90 text-white text-sm",children:i("chat.cta.callbackRequest")})]})}function De(){return e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(U,{}),e.jsx("div",{className:"bg-secondary rounded-2xl rounded-bl-sm px-4 py-3",children:e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-muted-foreground/40 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 bg-muted-foreground/40 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 bg-muted-foreground/40 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})})]})}function st(){var ue;const{t:a,language:i}=_e(),[o,d]=r.useState(!1),[c,x]=r.useState([{role:"assistant",content:"Hey! 👋 Ich bin maiKI, der digitale Assistent von maiwerk. Was kann ich für dich tun?",timestamp:_(i)}]),[y,I]=r.useState(""),[b,j]=r.useState(!1),[v,k]=r.useState(!1),[s,w]=r.useState({leadId:null,userName:null,userEmail:null,messageCount:0,nameAsked:!1,emailAsked:!1,topicCategory:"allgemein"}),[M,B]=r.useState(!1),[H,T]=r.useState(!1),[f,O]=r.useState(!1),ne=r.useRef(null),F=r.useRef(null),P=Se(),re=r.useRef(!1),W=r.useRef(!1),ie=r.useRef(Date.now()),X=r.useRef(null),K=r.useRef(!1),J=r.useCallback(async()=>s.leadId?s.leadId:(X.current||(X.current=Le(P.pathname).then(t=>(t&&w(n=>n.leadId?n:{...n,leadId:t}),t))),X.current),[s.leadId,P.pathname]),m=r.useCallback(async(t,n={})=>{const u=await J();
1return Q(u,t,n)},[J]),p=r.useCallback(async t=>{const n=await J();return xe(n,t)},[J]),ve=()=>{var t;(t=ne.current)==null||t.scrollIntoView({behavior:"smooth"})};r.useEffect(()=>{ve()},[c,v,M,H]),r.useEffect(()=>{o&&F.current&&(/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)||F.current.focus())},[o]),r.useEffect(()=>{if(o||W.current||sessionStorage.getItem("maiki_teaser_shown"))return;const n=setTimeout(()=>{W.current||(W.current=!0,sessionStorage.setItem("maiki_teaser_shown","1"),O(!0),setTimeout(()=>O(!1),12e3))},1e4);return()=>clearTimeout(n)},[o]),r.useEffect(()=>{o&&!s.leadId&&!re.current&&(re.current=!0,J().then(t=>{t&&Q(t,"chat_started",{page:P.pathname})}))},[o,s.leadId,P.pathname,J]),r.useEffect(()=>{const t=()=>{s.leadId&&s.messageCount>0&&(xe(s.leadId,{dropped_off:!0}),Q(s.leadId,"dropped_off",{messages_count:s.messageCount}))};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[s.leadId,s.messageCount]);const oe=r.useCallback(t=>{if(!s.nameAsked||s.userName)return;const n=t.trim().split(/\s+/);if(n.length<=3&&n.length>=1&&n[0].length>=2&&/^[A-Za-zÄÖÜäöüß]/.test(n[0])){const u=n[0].charAt(0).toUpperCase()+n[0].slice(1);w(l=>({...l,userName:u})),p({first_name:u}),m("name_provided",{name:u})}},[s.nameAsked,s.userName,m,p]),ce=r.useCallback(t=>{if(!s.emailAsked||s.userEmail)return;const n=t.match(/[^\s@]+@[^\s@]+\.[^\s@]+/);if(n){const u=n[0];w(l=>({...l,userEmail:u})),p({email:u}),m("email_provided",{email:u}),typeof window.fbq=="function"&&window.fbq("track","Lead",{content_name:"chat_widget"}),typeof window.gtag=="function"&&window.gtag("event","conversion",{send_to:"AW-816916612/lead",event_category:"lead",event_label:"chat_widget"}),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"generate_lead",lead_source:"chat_widget"})}},[s.emailAsked,s.userEmail,m,p]),le=r.useCallback(t=>{t.includes("[ASK:name]")&&!s.nameAsked&&(w(n=>({...n,nameAsked:!0})),m("name_asked",{})),t.includes("[ASK:email]")&&!s.emailAsked&&(w(n=>({...n,emailAsked:!0})),m("email_asked",{}))},[s.nameAsked,s.emailAsked,m]),ye=r.useCallback(t=>{t==="rueckruf"&&B(!0),t==="service"&&(ie.current=Date.now(),T(!0),m("service_started",{})),m("cta_clicked",{cta_type:t}),p({conversion_type:t})},[m,p]),je=r.useCallback(async({anliegen:t,vorname:n,email:u,beschreibung:l})=>{try{return(await fetch("https://ssxlrczpnpbqacaetpzg.supabase.co/functions/v1/chat-service-anfrage",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNzeGxyY3pwbnBicWFjYWV0cHpnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjY5NzcxOTAsImV4cCI6MjA4MjU1MzE5MH0.A5uRzswHhetMJr5JKxQ3HUsPzHI39f5KWkBqJ_zDCU8"},body:JSON.stringify({anliegen:t,vorname:n,email:u,beschreibung:l,quelleSeite:window.location.pathname,chatLeadId:await J(),ausfuellzeitMs:Date.now()-ie.current})})).ok?(T(!1),p({email:u,...n?{first_name:n}:{},conversion_type:"service",anliegen_typ:t}),m("service_submitted",{anliegen:t}),k(!0),setTimeout(()=>{k(!1),x(R=>[...R,{role:"assistant",content:a("chat.service.success"),timestamp:_(i)}])},$()),!0):!1}catch(E){return console.error("Service request failed:",E),!1}},[p,m,a,i,J]),Ne=r.useCallback(({phone:t,email:n})=>{B(!1),p({phone:t,email:n,conversion_type:"rueckruf"}),m("callback_requested",{phone:!!t,email:!!n}),fetch("https://ssxlrczpnpbqacaetpzg.supabase.co/functions/v1/notify-callback-request",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNzeGxyY3pwbnBicWFjYWV0cHpnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjY5NzcxOTAsImV4cCI6MjA4MjU1MzE5MH0.A5uRzswHhetMJr5JKxQ3HUsPzHI39f5KWkBqJ_zDCU8"},body:JSON.stringify({firstName:s.userName,phone:t,email:n,topicCategory:s.topicCategory,chatMessages:c.map(l=>({role:l.role,content:l.content}))})}).catch(l=>console.error("Notify callback failed:",l)),k(!0),setTimeout(()=>{k(!1),x(l=>[...l,{role:"assistant",content:a("chat.callback.success"),timestamp:_(i)}])},$())},[s.userName,s.topicCategory,c,m,p,a,i]);r.useCallback((t,n)=>{const u=n??$();return k(!0),new Promise(l=>{setTimeout(()=>{k(!1),x(E=>[...E,{role:"assistant",content:t,timestamp:_(i)}]),l()},u)})},[]);const de=r.useCallback(async t=>{var Z,R,me;const n=[...c,{role:"user",content:t,timestamp:_(i)}];x(n),j(!0);const u=s.messageCount+1;w(h=>({...h,messageCount:u})),s.nameAsked&&!s.userName&&oe(t),s.emailAsked&&!s.userEmail&&ce(t),m("message_sent",{message_number:u}),m("user_message",{content:t}),p({messages_count:u,last_message_at:new Date().toISOString()}),await new Promise(h=>setTimeout(h,150+Math.random()*250)),k(!0),await new Promise(h=>setTimeout(h,300+Math.random()*400));let l="";const E=h=>{v&&k(!1),l+=h;const C=be(l);x(z=>{const L=z[z.length-1];return(L==null?void 0:L.role)==="assistant"&&z.length>n.length?z.map((Y,S)=>S===z.length-1?{...Y,content:l,ctaType:C||void 0,timestamp:_(i)}:Y):[...z.slice(0,n.length),{role:"assistant",content:l,ctaType:C||void 0,timestamp:_(i)}]})};try{const h=await fetch(Me,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNzeGxyY3pwbnBicWFjYWV0cHpnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjY5NzcxOTAsImV4cCI6MjA4MjU1MzE5MH0.A5uRzswHhetMJr5JKxQ3HUsPzHI39f5KWkBqJ_zDCU8"},body:JSON.stringify({messages:n.map(g=>({role:g.role,content:g.content})),userInfo:{...s.userName?{firstName:s.userName}:{},...s.userEmail?{email:s.userEmail}:{}},language:i})});if(!h.ok){const g=await h.json().catch(()=>({}));throw new Error(g.error||"Verbindungsfehler")}const C=h.headers.get("X-Chat-Topic");C&&C!==s.topicCategory&&(w(g=>({...g,topicCategory:C})),p({topic_category:C}));const z=h.headers.get("X-Chat-Anliegen");if(z&&p({anliegen_typ:z}),!h.body)throw new Error("Keine Antwort erhalten");k(!1);const L=h.body.getReader(),Y=new TextDecoder;let S="";for(;;){const{done:g,value:D}=await L.read();if(g)break;S+=Y.decode(D,{stream:!0});let A;for(;(A=S.indexOf(`
2`))!==-1;){let N=S.slice(0,A);if(S=S.slice(A+1),N.endsWith("\r")&&(N=N.slice(0,-1)),N.startsWith(":")||N.trim()===""||!N.startsWith("data: "))continue;const fe=N.slice(6).trim();if(fe==="[DONE]")break;try{const pe=(me=(R=(Z=JSON.parse(fe).choices)==null?void 0:Z[0])==null?void 0:R.delta)==null?void 0:me.content;pe&&E(pe)}catch{S=N+`
3`+S;break}}}le(l);const he=be(l);if(he)m("cta_shown",{cta_type:he}),K.current=!0;else if(!K.current&&u>=2&&l.trim().length>0){const g="webinar";K.current=!0,x(D=>D.map((A,N)=>N===D.length-1&&A.role==="assistant"?{...A,ctaType:g}:A)),m("cta_shown",{cta_type:g,fallback:!0})}const Ce=[...n,{role:"assistant",content:l}],ze=/(kann ich (dir )?(leider )?nicht|weiß ich nicht|weiss ich nicht|habe ich keine information|dazu habe ich nichts|keine auskunft)/i.test(l);p({chat_messages:Ce.map(g=>({role:g.role,content:g.content})),...ze?{unbeantwortet:!0}:{}})}catch(h){console.error("Chat error:",h),k(!1),x(C=>[...C,{role:"assistant",content:h instanceof Error?h.message:a("chat.errorFallback"),timestamp:_(i)}])}finally{j(!1)}},[c,s,oe,ce,le,v]),Ie=t=>{if(t.preventDefault(),!y.trim()||b)return;const n=y.trim();I(""),de(n)};return e.jsxs(e.Fragment,{children:[f&&!o&&e.jsx("div",{className:"fixed bottom-20 right-4 sm:bottom-[5.5rem] sm:right-6 z-50 animate-in slide-in-from-bottom-2 fade-in duration-300",children:e.jsxs("div",{className:"bg-background border border-border rounded-2xl shadow-xl px-4 py-3 max-w-[240px] cursor-pointer relative",onClick:()=>{O(!1),d(!0)},children:[e.jsx("button",{onClick:t=>{t.stopPropagation(),O(!1)},className:"absolute -top-2 -right-2 w-5 h-5 bg-muted rounded-full flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors","aria-label":"Schließen",children:e.jsx(q,{className:"w-3 h-3"})}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(U,{}),e.jsx("p",{className:"text-[13px] text-foreground leading-snug",children:a("chat.teaser")})]}),e.jsx("div",{className:"absolute -bottom-1.5 right-6 w-3 h-3 bg-background border-r border-b border-border rotate-45"})]})}),e.jsx("button",{onClick:()=>{O(!1),d(!o)},className:V("fixed bottom-4 right-4 sm:bottom-6 sm:right-6 z-50 w-14 h-14 roun
3ded-full shadow-lg transition-all duration-300 flex items-center justify-center group",o?"bg-muted hover:bg-muted/80":"bg-maiwerk-orange hover:bg-maiwerk-orange/90 hover:scale-105 hover:shadow-xl"),"aria-label":a(o?"chat.closeLabel":"chat.openLabel"),children:o?e.jsx(q,{className:"w-6 h-6 text-foreground"}):e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"text-white font-bold text-lg",children:"M"}),e.jsx("span",{className:"absolute -top-1 -right-1",children:e.jsx(ke,{})})]})}),e.jsxs("div",{className:V("fixed z-50 bg-background border border-border rounded-2xl shadow-2xl overflow-hidden transition-all duration-300 flex flex-col","bottom-20 right-4 sm:bottom-24 sm:right-6","w-[calc(100vw-2rem)] sm:w-[380px] sm:max-w-[calc(100vw-3rem)]",o?"opacity-100 translate-y-0 pointer-events-auto":"opacity-0 translate-y-4 pointer-events-none"),style:{height:"min(520px, calc(100vh - 7rem))"},children:[e.jsxs("div",{className:"bg-maiwerk-dark px-4 py-3 flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(U,{size:"lg"}),e.jsx("span",{className:"absolute -bottom-0.5 -right-0.5",children:e.jsx(ke,{})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold text-white text-sm",children:"maiKI"}),e.jsx("p",{className:"text-xs text-white/60",children:v?a("chat.typing"):s.userName?`${a("chat.chatWith")} ${s.userName}`:a("chat.online")})]}),e.jsx("button",{onClick:()=>d(!1),className:"text-white/60 hover:text-white transition-colors","aria-label":a("chat.closeLabel"),children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:[c.map((t,n)=>e.jsx("div",{children:t.role==="assistant"?e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(U,{}),e.jsxs("div",{className:"flex flex-col max-w-[80%]",children:[e.jsx("div",{className:"bg-secondary text-foreground rounded-2xl rounded-bl-sm px-3.5 py-2.5 text-[13px] leading-relaxed",children:e.jsx(Te,{content:t.content,paragraphClassName:"text-[13px] leading-relaxed",linkClassName:"link-inline"})}),t.timestamp&&e.jsx("span",{className:"text-[10px] text-muted-foreground/60 mt-0.5 ml-1",children:t.timestamp}),t.ctaType&&e.jsx("div",{className:"mt-1",children:M&&t.ctaType==="rueckruf"?e.jsx(Ye,{onSubmit:Ne,t:a}):H&&t.ctaType==="service"?e.jsx(Re,{defaultName:s.userName,defaultEmail:s.userEmail,onSubmit:je,t:a}):e.jsx(Pe,{type:t.ctaType,onCtaClick:ye,topicCategory:s.topicCategory,messageContent:t.content,t:a})})]})]}):e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("div",{className:"max-w-[80%] bg-maiwerk-dark text-white rounded-2xl rounded-br-sm px-3.5 py-2.5 text-[13px] leading-relaxed",children:t.content}),t.timestamp&&e.jsx("span",{className:"text-[10px] text-muted-foreground/60 mt-0.5 mr-1",children:t.timestamp})]})},n)),c.length===1&&!b&&!v&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-1 pl-9",children:[a("chat.chip1"),a("chat.chip2"),a("chat.chip3"),a("chat.chip4")].map(t=>e.jsx("button",{type:"button",onClick:()=>{m("starter_chip_clicked",{chip:t}),de(t)},className:"rounded-full border border-border bg-background px-3 py-1.5 text-[12px] text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-maiwerk-dark/20",children:t},t))}),v&&e.jsx(De,{}),b&&!v&&((ue=c[c.length-1])==null?void 0:ue.role)==="user"&&e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(U,{}),e.jsx("div",{className:"bg-secondary rounded-2xl rounded-bl-sm px-4 py-2.5",children:e.jsx(Oe,{className:"w-4 h-4 animate-spin text-muted-foreground"})})]}),e.jsx("div",{ref:ne})]}),e.jsxs("form",{onSubmit:Ie,className:"p-3 border-t border-border bg-background/95 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:F,type:"text",value:y,onChange:t=>I(t.target.value),placeholder:a("chat.placeholder"),className:"flex-1 px-4 py-2.5 text-sm bg-secondary rounded-full border-0 focus:outline-none focus:ring-2 focus:ring-maiwerk-dark/20 placeholder:text-muted-foreground",disabled:b}),e.jsx(Ae,{language:i,disabled:b,onPartial:t=>I(t),onTranscript:t=>{var n;I(t),(n=F.current)==null||n.focus()}}),e.jsx(te,{type:"submit",size:"icon",disabled:!y.trim()||b,className:"rounded-full w-10 h-10 flex-shrink-0 bg-maiwerk-orange hover:bg-maiwerk-orange/90 text-white disabled:opacity-40",children:e.jsx(Ee,{className:"w-4 h-4"})})]}
3),e.jsxs("p",{className:"text-[10px] text-muted-foreground/50 text-center mt-1.5",children:["maiwerk Finanzpartner • ",e.jsx("a",{href:"/datenschutz",className:"underline hover:text-muted-foreground",children:a("chat.privacy")})]})]})]})]})}export{st as ChatWidget};

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.