1import{r as l,j as e,B as Pa,t as ks,u as sl,i as Fr,A as ln,a as Cs,f as Ql}from"./app-h2-CaMDwLtx.js";import{a as il,b as eo,c as to,d as no,q as al}from"./chunk-h2-C_HEmSgO.js";import{s as _r,S as so,a as io}from"./chunk-h2-p6G5lL8P.js";import{c as ao}from"./chunk-h2-DFANrooV.js";import{R as ro}from"./chunk-h2-BUFQVpEH.js";import{A as lo}from"./chunk-h2-B7hveERD.js";/** 2 * @license lucide-react v1.17.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const oo=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],co=ao("calendar-clock",oo),bi="crm_templates",ba=al.select({name:"name",subject:"subject",body:"body",type:"type",sharing:"sharing",closeId:"close_id"}),Or={name:"",subject:"",body:"",type:"email",sharing:"everyone"};function po(){const{records:t,isLoading:r,refetch:a}=il({table:bi,select:ba,count:300}),n=eo({table:bi,select:ba}),h=to({table:bi,select:ba}),p=no({table:bi}),[k,f]=l.useState("email"),[C,m]=l.useState(""),[v,g]=l.useState(null),[x,N]=l.useState(Or),[ee,le]=l.useState(!1),Z=l.useMemo(()=>{const $=C.trim().toLowerCase();return(t||[]).filter(_=>{var ue;return(((ue=_.fields)==null?void 0:ue.type)||"email")===k}).filter(_=>{var ue,be;return!$||(((ue=_.fields)==null?void 0:ue.name)||"").toLowerCase().includes($)||(((be=_.fields)==null?void 0:be.subject)||"").toLowerCase().includes($)}).sort((_,ue)=>{var be,ie;return(((be=_.fields)==null?void 0:be.name)||"").localeCompare(((ie=ue.fields)==null?void 0:ie.name)||"")})},[t,C,k]);function I(){N({...Or,type:k}),g({})}function B($){var _,ue,be,ie,H;N({name:((_=$.fields)==null?void 0:_.name)||"",subject:((ue=$.fields)==null?void 0:ue.subject)||"",body:((be=$.fields)==null?void 0:be.body)||"",type:((ie=$.fields)==null?void 0:ie.type)||"email",sharing:((H=$.fields)==null?void 0:H.sharing)||"everyone"}),g($)}function j(){g(null)}async function P(){if(!x.name.trim()){ks.error("Name fehlt");return}le(!0);try{const $={name:x.name,subject:x.subject,body:x.body,type:x.type,sharing:x.sharing};v&&v.id?(await h.mutateAsync({recordId:v.id,...$}),ks.success("Template aktualisiert")):(await n.mutateAsync($),ks.success("Template angelegt")),j(),a()}catch($){ks.error("Speichern fehlgeschlagen",{description:$==null?void 0:$.message})}finally{le(!1)}}async function ve($){var _;if(window.confirm(`Template â${((_=$.fields)==null?void 0:_.name)||""}" löschen?`))try{await p.mutateAsync({recordId:$.id}),ks.success("Gelöscht"),a()}catch(ue){ks.error("Löschen fehlgeschlagen",{description:ue==null?void 0:ue.message})}}return e.jsxs("div",{className:"tpl-wrap",children:[e.jsx(Pa,{block:"templates"}),e.jsx("style",{children:ho}),e.jsxs("div",{className:"tpl-head",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"tpl-title",children:"Templates & Snippets"}),e.jsxs("p",{className:"tpl-sub",children:[Z.length," ",k==="email"?"E-Mail":"SMS","-Vorlagen · aus Close übernommen"]})]}),e.jsx("button",{className:"tpl-btn-primary",onClick:I,children:"+ Neues Template"})]}),e.jsxs("div",{className:"tpl-tabs",children:[e.jsx("button",{className:k==="email"?"tpl-tab on":"tpl-tab",onClick:()=>f("email"),children:"E-Mail"}),e.jsx("button",{className:k==="sms"?"tpl-tab on":"tpl-tab",onClick:()=>f("sms"),children:"SMS"})]}),e.jsx("input",{className:"tpl-search",placeholder:"Vorlagen durchsuchenâ¦",value:C,onChange:$=>m($.target.value)}),r?e.jsx("div",{className:"tpl-empty",children:"Lädtâ¦"}):Z.length===0?e.jsxs("div",{className:"tpl-empty",children:["Keine ",k==="email"?"E-Mail":"SMS","-Vorlagen."]}):e.jsx("div",{className:"tpl-list",children:Z.map($=>{var _,ue,be,ie;return e.jsxs("div",{className:"tpl-row",onClick:()=>B($),children:[e.jsxs("div",{className:"tpl-row-main",children:[e.jsxs("div",{className:"tpl-row-name",children:[((_=$.fields)==null?void 0:_.name)||"(ohne Name)",(ue=$.fields)!=null&&ue.closeId?e.jsx("span",{className:"tpl-badge",children:"Close"}):null]}),e.jsx("div",{className:"tpl-row-subj",children:((be=$.fields)==null?void 0:be.subject)||e.jsx("em",{children:"kein Betreff"})})]}),e.jsx("div",{className:"tpl-row-share",children:((ie=$.fields)==null?void 0:ie.sharing)==="private"?"Privat":"Alle"}),e.jsx("button",{className:"tpl-del",title:"Löschen",onClick:H=>{H.stopPropagation(),ve($)},children:"ð"})]},$.id)})}),v!==null&&e.jsx("div",{className:"tpl-modal-bg",onClick:j,children:e.jsxs("div",{className:"tpl-modal",onClick:$=>$.stopPropagation(),children:[e.jsx("h2",{className:"tpl-modal-title",children:v.id?"Template bearbeiten":"Neues Template"}),e.jsx("label",{className:"tpl-label",children:"Template-Name"}),e.jsx("input",{className:"tpl-input",value:x.name,onChange:$=>N({...x,name:$.target.value}),placeholder:"z. B. Follow-up #1"}),e.jsx("label",{className:"tpl-label",children:"Betreff"}),e.jsx("input",{className:"tpl-input",value:x.subject,onChange:$=>N({...x,subject:$.target.value}),placeholder:"z. B. {{ contact.first_name }}, kurze Rückfrage"}),e.jsxs("label",{className:"tpl-label",children:["Inhalt (HTML / Text · Platzhalter wie ","{{ contact.first_name }}",")"]}),e.jsx("textarea",{className:"tpl-textarea",rows:14,value:x.body,onChange:$=>N({...x,body:$.target.value})}),e.jsxs("div",{className:"tpl-row2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"tpl-label",children:"Typ"}
6),e.jsxs("select",{className:"tpl-input",value:x.type,onChange:$=>N({...x,type:$.target.value}),children:[e.jsx("option",{value:"email",children:"E-Mail"}),e.jsx("option",{value:"sms",children:"SMS"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"tpl-label",children:"Sichtbarkeit"}),e.jsxs("select",{className:"tpl-input",value:x.sharing,onChange:$=>N({...x,sharing:$.target.value}),children:[e.jsx("option",{value:"everyone",children:"Alle im Team"}),e.jsx("option",{value:"private",children:"Privat"})]})]})]}),x.body&&x.type==="email"?e.jsxs("div",{className:"tpl-preview",children:[e.jsx("div",{className:"tpl-preview-label",children:"Vorschau"}),e.jsx("div",{className:"tpl-preview-body",dangerouslySetInnerHTML:{__html:x.body}})]}):null,e.jsxs("div",{className:"tpl-modal-foot",children:[e.jsx("button",{className:"tpl-btn-ghost",onClick:j,children:"Abbrechen"}),e.jsx("button",{className:"tpl-btn-primary",onClick:P,disabled:ee,children:ee?"Speichertâ¦":"Speichern"})]})]})})]})}const ho=` 7.tpl-wrap{max-width:1080px;margin:0 auto;padding:26px 26px 40px;color:#0f172a;font-family:Inter,system-ui,sans-serif} 8.tpl-head{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;margin-bottom:20px;flex-wrap:wrap;padding-right:44px} 9.tpl-title{font-size:24px;font-weight:700;margin:0;letter-spacing:-.02em;color:#0f172a} 10.tpl-sub{margin:4px 0 0;color:#64748b;font-size:13px} 11.tpl-btn-primary{background:#16a34a;color:#fff;border:0;border-radius:10px;padding:10px 18px;font-weight:600;font-size:14px;cursor:pointer;transition:filter .15s} 12.tpl-btn-primary:hover{filter:brightness(1.06)} 13.tpl-btn-primary:disabled{opacity:.6;cursor:default} 14.tpl-tabs{display:flex;gap:6px;margin-bottom:14px;border-bottom:1px solid #e5e7eb} 15.tpl-tab{background:none;border:0;color:#64748b;padding:9px 14px;font-size:14px;font-weight:600;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px} 16.tpl-tab.on{color:#16a34a;border-bottom-color:#16a34a} 17.tpl-search{width:100%;box-sizing:border-box;background:#f8fafc;border:1px solid #e5e7eb;border-radius:10px;padding:11px 14px;color:#0f172a;font-size:14px;margin-bottom:16px;outline:none} 18.tpl-search:focus{border-color:#16a34a;background:#fff} 19.tpl-list{display:flex;flex-direction:column;gap:8px} 20.tpl-row{display:flex;align-items:center;gap:14px;background:#fff;border:1px solid #eef0f2;border-radius:12px;padding:13px 16px;cursor:pointer;transition:background .15s,border-color .15s} 21.tpl-row:hover{background:#fafbfc;border-color:#bbf7d0} 22.tpl-row-main{flex:1;min-width:0} 23.tpl-row-name{font-weight:600;font-size:14.5px;display:flex;align-items:center;gap:8px;color:#0f172a} 24.tpl-badge{font-size:10px;font-weight:700;color:#1d4ed8;background:#dbeafe;border:1px solid #bfdbfe;border-radius:6px;padding:1px 6px;letter-spacing:.03em} 25.tpl-row-subj{font-size:12.5px;color:#64748b;margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} 26.tpl-row-subj em{color:#94a3b8} 27.tpl-row-share{font-size:12px;color:#94a3b8;flex-shrink:0} 28.tpl-del{background:none;border:0;cursor:pointer;font-size:15px;opacity:.5;flex-shrink:0;padding:4px} 29.tpl-del:hover{opacity:1} 30.tpl-empty{text-align:center;color:#94a3b8;padding:50px 0;font-size:14px} 31.tpl-modal-bg{position:fixed;inset:0;background:rgba(15,23,42,.5);backdrop-filter:blur(4px);display:flex;align-items:flex-start;justify-content:center;padding:40px 16px;z-index:3100;overflow-y:auto} 32.tpl-modal{width:100%;max-width:640px;background:#fff;border:1px solid #e5e7eb;border-radius:18px;padding:26px;box-shadow:0 24px 60px rgba(0,0,0,.25)} 33.tpl-modal-title{font-size:20px;font-weight:700;margin:0 0 18px;color:#0f172a} 34.tpl-label{display:block;font-size:12px;font-weight:600;color:#64748b;margin:14px 0 6px} 35.tpl-input,.tpl-textarea{width:100%;box-sizing:border-box;background:#fff;border:1px solid #e5e7eb;border-radius:9px;padding:10px 12px;color:#0f172a;font-size:14px;outline:none;font-family:inherit} 36.tpl-input:focus,.tpl-textarea:focus{border-color:#16a34a} 37.tpl-textarea{resize:vertical;line-height:1.5;font-family:ui-monospace,Menlo,monospace;font-size:12.5px} 38.tpl-row2{display:grid;grid-template-columns:1fr 1fr;gap:14px} 39.tpl-preview{margin-top:16px;border:1px solid #e5e7eb;border-radius:10px;overflow:hidden} 40.tpl-preview-label{font-size:11px;font-weight:700;color:#64748b;background:#f8fafc;padding:7px 12px;letter-spacing:.04em} 41.tpl-preview-body{background:#fff;color:#18181b;padding:16px;font-size:13px;max-height:280px;overflow-y:auto;border-top:1px solid #e5e7eb} 42.tpl-modal-foot{display:flex;justify-content:flex-end;
42gap:10px;margin-top:22px} 43.tpl-btn-ghost{background:#f1f5f9;color:#475569;border:1px solid #e5e7eb;border-radius:10px;padding:10px 18px;font-weight:600;font-size:14px;cursor:pointer} 44.tpl-btn-ghost:hover{background:#e2e8f0} 45@media(max-width:560px){.tpl-row2{grid-template-columns:1fr}} 46`,go=[{group:"Vertrieb",items:[{key:"pipeline",label:"Pipeline & Status"}]},{group:"Kommunikation",items:[{key:"templates",label:"Templates & Snippets"},{key:"fusszeile",label:"FuÃzeile"}]},{group:"Anpassung",items:[{key:"fields",label:"Custom Fields"}]},{group:"Organisation",items:[{key:"team",label:"Team & Rollen"}]}],va={name:"Sales",stages:[{label:"Neue Chance",kind:"active",emoji:"ð°"},{label:"Angebot/AB erstellen",kind:"active"},{label:"Angebot erstellt",kind:"active"},{label:"Angebot versendet",kind:"active"},{label:"Follow Up Folgejahr",kind:"active"},{label:"unklar",kind:"active"},{label:"(sonstiges)",kind:"active"},{label:"Retainer Kunden",kind:"won"},{label:"Sale abgeschlossen",kind:"won"},{label:"Sale nicht abgeschlossen",kind:"lost"},{label:"Unqualifiziert",kind:"lost"}]},uo={Lead:[{name:"Aktueller Retainer",type:"Auswahl",opts:"MINI / START / PRO / MAX / Individuell"},{name:"TIER",type:"Auswahl",opts:"A / B / C"},{name:"ð¤ Qualifiziert",type:"Auswahl",opts:"JA â / UNGEEIGNET â"},{name:"Kategorie / Branche",type:"Auswahl (mehrfach)",opts:"~30 Branchen"},{name:"Messen",type:"Auswahl (mehrfach)",opts:"~40 Messen"},{name:"Kundennummer",type:"Zahl",opts:""},{name:"Aktuelles Guthaben",type:"Text",opts:""},{name:"Social Media Link / Instagram",type:"Text",opts:""},{name:"Lead Name ohne Firmierung",type:"Text",opts:""},{name:"Interner Ansprechpartner",type:"User",opts:""},{name:"Standnummer",type:"Text",opts:""},{name:"Abrechnungs-Ãbersicht",type:"Text",opts:""},{name:"Videokarte",type:"Auswahl",opts:""},{name:"Updateintervall",type:"Auswahl",opts:""},{name:"Analyse generieren",type:"Auswahl",opts:""},{name:"Humorskala",type:"Auswahl",opts:"1â10"}],Kontakt:[{name:"Telefonnummer",type:"Zahl",opts:""},{name:"Wichtige Infos",type:"Text",opts:""},{name:"Geburtstag",type:"Datum",opts:""},{name:"Google Bewertung abgegeben?",type:"Auswahl",opts:""}],Opportunity:[{name:"Standnummer (alt)",type:"Text",opts:""}]},mo="x91ODsiBx3bzdH",fo=al.select({name:"cof0b",email:"WM2dx",avatar:"9bNGB",company:"OMBQo",role:"__role",perms:"__perms"});function Oi({title:t,sub:r,children:a}){return e.jsxs("div",{className:"crmset-section",children:[e.jsxs("div",{className:"crmset-section-head",children:[e.jsx("h2",{className:"crmset-h2",children:t}),r&&e.jsx("p",{className:"crmset-sub",children:r})]}),a]})}function xo(){const t=a=>a==="won"?"#16a34a":a==="lost"?"#dc2626":"#3b82f6",r=a=>a==="won"?"#dcfce7":a==="lost"?"#fee2e2":"#dbeafe";return e.jsxs(Oi,{title:"Pipeline & Status",sub:`Vertriebs-Pipeline â${va.name}" · ${va.stages.length} Stufen`,children:[e.jsx("div",{className:"crmset-pipe",children:va.stages.map((a,n)=>e.jsxs("div",{className:"crmset-pipe-stage",children:[e.jsx("span",{className:"crmset-pipe-num",children:n+1}),e.jsxs("span",{className:"crmset-pipe-label",children:[a.emoji?a.emoji+" ":"",a.label]}),e.jsx("span",{className:"crmset-pipe-badge",style:{color:t(a.kind),background:r(a.kind)},children:a.kind==="won"?"Gewonnen":a.kind==="lost"?"Verloren":"Aktiv"})]},n))}),e.jsx("p",{className:"crmset-note",children:"Aus Close übernommen. Bearbeitung der Stufen folgt â sag Bescheid, wenn du sie hier pflegen willst."})]})}function yo(){return e.jsxs(Oi,{title:"Custom Fields",sub:"Benutzerdefinierte Felder aus dem CRM, nach Objekt gruppiert",children:[Object.entries(uo).map(([t,r])=>e.jsxs("div",{className:"crmset-fgroup",children:[e.jsxs("div",{className:"crmset-fgroup-title",children:[t," ",e.jsx("span",{className:"crmset-fgroup-count",children:r.length})]}),e.jsx("div",{className:"crmset-ftable",children:r.map((a,n)=>e.jsxs("div",{className:"crmset-frow",children:[e.jsx("span",{className:"crmset-fname",children:a.name}),e.jsx("span",{className:"crmset-ftype",children:a.type}),e.jsx("span",{className:"crmset-fopts",children:a.opts})]},n))})]},t)),e.jsx("p",{className:"crmset-note",children:"Referenz der aktiven Felder. Bearbeiten/Neu-Anlegen kann ich als nächsten Schritt ergänzen."})]})}function bo(){const{records:t,isLoading:r}=il({table:mo,select:fo,count:200}),a=l.useMemo(()=>(t||[]).filter(f=>{var C;return(((C=f.fields)==null?void 0:C.email)||"").toLowerCase().includes("@liberdamedia.de")}).sort((f,C)=>{var m,v;return(((m=f.fields)==null?void 0:m.name)||"").localeCompare(((v=C.fields)==null?void 0:v.name)||"")}),[t]),n=f=>{var m;const C=f==null?void 0:f.avatar;return typeof C=="string"?C:(C==null?void 0:C.url)||(Array.isArray(C)?(m=C[0])==null?void 0:m.url:"")||""},h=f=>{const C=(f||"").toLowerCase();return C.includes("admin")?"Admin":C.includes("team")?"Team":f||"Mitglied"},p={admin:"Hub-Admin",crm:"CRM / Vertrieb",buchhaltung:"Buchhaltung",produktion:"Produktion",konzeption:"Konzeption"},k=f=>{let C=f==null?void 0:f.perms,m=[];
46if(Array.isArray(C))m=C.map(String);else if(typeof C=="string"&&C.trim())try{const v=JSON.parse(C);m=Array.isArray(v)?v.map(String):[]}catch{m=C.split(",").map(v=>v.trim()).filter(Boolean)}return m.length?m.map(v=>p[v]||v).join(" · "):null};return e.jsxs(Oi,{title:"Team & Rollen",sub:`${a.length} Teammitglieder mit Zugang`,children:[r?e.jsx("div",{className:"crmset-empty",children:"Lädtâ¦"}):e.jsx("div",{className:"crmset-team",children:a.map(f=>{var v,g,x,N;const C=n(f.fields),m=((v=f.fields)==null?void 0:v.name)||((g=f.fields)==null?void 0:g.email)||"â";return e.jsxs("div",{className:"crmset-member",children:[C?e.jsx("img",{src:C,alt:m,className:"crmset-avatar"}):e.jsx("div",{className:"crmset-avatar crmset-avatar-ph",children:(m[0]||"?").toUpperCase()}),e.jsxs("div",{className:"crmset-member-main",children:[e.jsx("div",{className:"crmset-member-name",children:m}),e.jsx("div",{className:"crmset-member-email",children:(x=f.fields)==null?void 0:x.email})]}),e.jsx("span",{className:"crmset-role",children:k(f.fields)||h((N=f.fields)==null?void 0:N.role)})]},f.id)})}),e.jsx("p",{className:"crmset-note",children:'Detaillierte Rechtevergabe pro Kunde läuft weiter über âKonfiguration â Zugang & Rolle".'})]})}function vo(){const t=sl(),r=(t==null?void 0:t.email)||"",[a,n]=l.useState(""),[h,p]=l.useState(""),[k,f]=l.useState(!0),[C,m]=l.useState(!1),[v,g]=l.useState("");l.useEffect(()=>{Fr("/api/mail/me/signatur").then(ee=>{ee!=null&&ee.ok&&(n(ee.html||""),p(ee.text||""),f(ee.aktiv!==!1&&ee.aktiv!==0))}).catch(()=>{}).finally(()=>m(!0))},[]);const x=async()=>{g("");try{const ee=await Fr("/api/mail/me/signatur",{method:"POST",body:JSON.stringify({html:a,text:h,aktiv:k})});g(ee!=null&&ee.ok?"Gespeichert â":"Speichern fehlgeschlagen")}catch{g("Speichern fehlgeschlagen")}},N=()=>{const ee=(t==null?void 0:t.fullName)||(r.split("@")[0]||"").replace(/^./,le=>le.toUpperCase());n(_r(so,ee,r)),p(_r(io,ee,r))};return e.jsxs(Oi,{title:"FuÃzeile",sub:"Deine persönliche Mail-FuÃzeile â wird an jede Mail aus Postfach und CRM angehängt",children:[C?e.jsxs("div",{className:"crmset-sig",children:[e.jsxs("label",{className:"crmset-sig-an",children:[e.jsx("input",{type:"checkbox",checked:k,onChange:ee=>f(ee.target.checked)}),e.jsx("span",{children:"FuÃzeile anhängen"})]}),!a.trim()&&e.jsx("button",{className:"crmset-sig-btn",onClick:N,children:"LIBERDA-Vorlage einsetzen"}),e.jsxs("div",{className:"crmset-sig-feld",children:[e.jsx("span",{className:"crmset-sig-label",children:"HTML-Fassung"}),e.jsx("textarea",{className:"crmset-sig-code",value:a,onChange:ee=>n(ee.target.value)})]}),e.jsxs("div",{className:"crmset-sig-feld",children:[e.jsx("span",{className:"crmset-sig-label",children:"Nur-Text-Fassung"}),e.jsx("textarea",{className:"crmset-sig-code crmset-sig-kurz",value:h,onChange:ee=>p(ee.target.value)})]}),!!a.trim()&&e.jsxs("div",{className:"crmset-sig-feld",children:[e.jsx("span",{className:"crmset-sig-label",children:"Vorschau"}),e.jsx("div",{className:"crmset-sig-preview",dangerouslySetInnerHTML:{__html:a}})]}),e.jsxs("div",{className:"crmset-sig-foot",children:[e.jsx("button",{className:"crmset-sig-btn",onClick:x,children:"Speichern"}),v&&e.jsx("span",{className:"crmset-sig-status",children:v})]})]}):e.jsx("div",{className:"crmset-empty",children:"Lädtâ¦"}),e.jsxs("p",{className:"crmset-note",children:["Jede Person pflegt nur die eigene FuÃzeile (",r||"â¦","). Der Versand hängt sie serverseitig an â Postfach und CRM nutzen die
46selbe Ablage."]})]})}function ko(){const[t,r]=l.useState("templates");return e.jsxs("div",{className:"crmset-wrap",children:[e.jsx(Pa,{block:"crmsettings"}),e.jsx("style",{children:jo}),e.jsxs("aside",{className:"crmset-nav",children:[e.jsx("div",{className:"crmset-nav-title",children:"CRM-Einstellungen"}),go.map(a=>e.jsxs("div",{className:"crmset-nav-group",children:[e.jsx("div",{className:"crmset-nav-grouplabel",children:a.group}),a.items.map(n=>e.jsx("button",{className:t===n.key?"crmset-nav-item on":"crmset-nav-item",onClick:()=>r(n.key),children:n.label},n.key))]},a.group))]}),e.jsxs("div",{className:"crmset-content",children:[t==="templates"&&e.jsx(po,{}),t==="fusszeile"&&e.jsx(vo,{}),t==="pipeline"&&e.jsx(xo,{}),t==="fields"&&e.jsx(yo,{}),t==="team"&&e.jsx(bo,{})]})]})}const jo=` 47.crmset-wrap{display:flex;min-height:520px;font-family:Inter,system-ui,sans-serif;color:#0f172a} 48.crmset-nav{width:210px;flex-shrink:0;border-right:1px solid #eef0f2;padding:22px 12px;background:#fafbfc;border-radius:18px 0 0 18px} 49.crmset-nav-title{font-size:15px;font-weight:700;padding:0 8px 14px;color:#0f172a} 50.crmset-nav-group{margin-bottom:14px} 51.crmset-nav-grouplabel{font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:#94a3b8;padding:0 8px 5px} 52.crmset-nav-item{display:block;width:100%;text-align:left;background:none;border:0;border-radius:8px;padding:8px 10px;font-size:13px;font-weight:500;color:#475569;cursor:pointer;transition:background .12s,color .12s} 53.crmset-nav-item:hover{background:#f1f5f9} 54.crmset-nav-item.on{background:#dcfce7;color:#15803d;font-weight:600} 55.crmset-content{flex:1;min-width:0;max-height:78vh;overflow-y:auto} 56.crmset-section{padding:26px 28px 36px} 57.crmset-section-head{margin-bottom:18px;padding-right:44px} 58.crmset-h2{font-size:22px;font-weight:700;margin:0;color:#0f172a} 59.crmset-sub{margin:4px 0 0;font-size:13px;color:#64748b} 60.crmset-note{margin-top:18px;font-size:12px;color:#94a3b8;background:#f8fafc;border:1px solid #eef0f2;border-radius:10px;padding:10px 12px} 61.crmset-empty{text-align:center;color:#94a3b8;padding:40px 0;font-size:14px} 62.crmset-pipe{display:flex;flex-direction:column;gap:6px} 63.crmset-pipe-stage{display:flex;align-items:center;gap:12px;background:#fff;border:1px solid #eef0f2;border-radius:10px;padding:11px 14px} 64.crmset-pipe-num{width:22px;height:22px;border-radius:6px;background:#f1f5f9;color:#64748b;font-size:11px;font-weight:700;display:flex;align-items:center;justify-content:center;flex-shrink:0} 65.crmset-pipe-label{flex:1;font-size:13.5px;font-weight:600;color:#0f172a} 66.crmset-pipe-badge{font-size:10px;font-weight:700;padding:2px 9px;border-radius:8px} 67.crmset-fgroup{margin-bottom:22px} 68.crmset-fgroup-title{font-size:13px;font-weight:700;color:#0f172a;margin-bottom:8px;display:flex;align-items:center;gap:8px} 69.crmset-fgroup-count{font-size:11px;font-weight:700;color:#15803d;background:#dcfce7;border-radius:20px;padding:1px 9px} 70.crmset-ftable{display:flex;flex-direction:column;gap:3px} 71.crmset-frow{display:grid;grid-template-columns:1.4fr .8fr 1.3fr;gap:12px;align-items:center;background:#fff;border:1px solid #eef0f2;border-radius:8px;padding:9px 13px} 72.crmset-fname{font-size:13px;font-weight:600;color:#0f172a} 73.crmset-ftype{font-size:11px;color:#64748b;background:#f1f5f9;border-radius:6px;padding:2px 8px;justify-self:start} 74.crmset-fopts{font-size:11.5px;color:#94a3b8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} 75.crmset-team{display:flex;flex-direction:column;gap:8px} 76.crmset-member{display:flex;align-items:center;gap:12px;background:#fff;border:1px solid #eef0f2;border-radius:12px;padding:11px 14px} 77.crmset-avatar{width:38px;height:38px;border-radius:50%;object-fit:cover;flex-shrink:0;border:1px solid #e5e7eb} 78.crmset-avatar-ph{display:flex;align-items:center;justify-content:center;background:#dcfce7;color:#15803d;font-weight:700;font-size:15px} 79.crmset-member-main{flex:1;min-width:0} 80.crmset-member-name{font-size:14px;font-weight:600;color:#0f172a} 81.crmset-member-email{font-size:12px;color:#94a3b8} 82.crmset-role{font-size:11px;font-weight:700;color:#15803d;background:#dcfce7;border-radius:8px;padding:3px 11px;flex-shrink:0} 83.crmset-sig{display:flex;flex-direction:column;gap:14px}
84.crmset-sig-an{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:600;color:#0f172a;cursor:pointer} 85.crmset-sig-an input{accent-color:#15803d;width:15px;height:15px} 86.crmset-sig-btn{align-self:flex-start;background:#dcfce7;color:#15803d;border:0;border-radius:9px;padding:8px 16px;font-size:12.5px;font-weight:700;cursor:pointer;font-family:inherit} 87.crmset-sig-btn:hover{background:#bbf7d0} 88.crmset-sig-feld{display:flex;flex-direction:column;gap:6px} 89.crmset-sig-label{font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:#94a3b8} 90.crmset-sig-code{width:100%;min-height:150px;border:1px solid #eef0f2;border-radius:10px;padding:11px 13px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;line-height:1.55;color:#0f172a;background:#f8fafc;resize:vertical;box-sizing:border-box} 91.crmset-sig-kurz{min-height:96px} 92.crmset-sig-preview{border:1px solid #eef0f2;border-radius:10px;padding:16px;background:#fff;overflow-x:auto} 93.crmset-sig-foot{display:flex;align-items:center;gap:12px} 94.crmset-sig-status{font-size:12px;font-weight:600;color:#15803d} 95@media(max-width:720px){.crmset-wrap{flex-direction:column}.crmset-nav{width:auto;border-right:0;border-bottom:1px solid #eef0f2;border-radius:18px 18px 0 0}.crmset-frow{grid-template-columns:1fr}} 96`,ka=["planned","existing","unresolved","completed"],wo=new Intl.DateTimeFormat("de-DE",{timeZone:"Europe/Berlin",weekday:"short",day:"2-digit",month:"2-digit"}),Pr=new Intl.DateTimeFormat("de-DE",{timeZone:"Europe/Berlin",hour:"2-digit",minute:"2-digit"});function $r(t){return Number.isFinite(t.start_ts)&&Number.isFinite(t.ende_ts)?`${wo.format(t.start_ts)} · ${Pr.format(t.start_ts)}â${Pr.format(t.ende_ts)}`:"Zeitpunkt wird geprüft"}function Kr(){try{return JSON.parse(localStorage.getItem("lm_followup_dates")||"[]").filter(t=>Array.isArray(t)&&typeof t[0]=="string"&&typeof t[1]=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t[1])).map(t=>({leadId:t[0],date:t[1]}))}catch{return[]}}async function Os(t,r,a){const n=await fetch(ln+"/api/crm/followups/"+t,{method:r===void 0?"GET":"POST",headers:{...Cs(),"Content-Type":"application/json"},...r===void 0?{}:{body:JSON.stringify(r)},signal:a}),h=await n.json();if(!n.ok||h.ok!==!0)throw new Error(h.error||"Die Anfrage konnte nicht abgeschlossen werden.");return h}function So({filter:t,accountKey:r,onOpenLead:a}){const[n,h]=l.useState(null),[p,k]=l.useState(""),[f,C]=l.useState(""),[m,v]=l.useState(!0),[g,x]=l.useState(""),[N,ee]=l.useState(0),[le,Z]=l.useState(!1),[I,B]=l.useState({}),[j,P]=l.useState(Kr),ve=l.useRef(0),$=l.useRef(!1);l.useEffect(()=>{const ie=++ve.current,H=new AbortController;return $.current=!1,v(!0),k(""),h(null),Z(!1),B({}),x(""),P(Kr()),Os("preview?filter="+encodeURIComponent(t),void 0,H.signal).then(U=>{if(U.mode!=="preview"||!ka.every(F=>Array.isArray(U[F]))||!Array.isArray(U.assignees))throw new Error("Die Planung ist unvollständig.");ie===ve.current&&h(U)}).catch(U=>{H.signal.aborted||k(U.message)}).finally(()=>{H.signal.aborted||v(!1)}),()=>{H.abort(),ve.current++}},[t,r,N]);async function _(ie,H){if($.current)return;$.current=!0;const U=ve.current;x(ie),k(""),C("");try{const F=await H();U===ve.current&&(C(F),ee(K=>K+1),window.dispatchEvent(new Event("crm-followups-changed")))}catch(F){U===ve.current&&k(F instanceof Error?F.message:"Die Aktion ist fehlgeschlagen.")}finally{U===ve.current&&($.current=!1,x(""))}}async function ue(){if(!(n!=null&&n.nextCursor)||$.current)return;$.current=!0,x("more");const ie=ve.current,H=n.nextCursor;try{const U=await Os("preview?filter="+encodeURIComponent(t)+"&cursor="+encodeURIComponent(H));if(U.mode!=="preview"||!ka.every(F=>Array.isArray(U[F]))||U.nextCursor===H)throw new Error("Weitere Leads konnten nicht vollständig geladen werden.");ie===ve.current&&h(F=>{if(!F)return U;const K={...U,scanned:(F.scanned||0)+(U.scanned||0)};for(const A of ka)K[A]=[...new Map([...F[A],...U[A]].map(ce=>[ce.leadId,ce])).values()];return K})}catch(U){ie===ve.current&&k(U instanceof Error?U.message:"Nachladen fehlgeschlagen.")}finally{ie===ve.current&&($.current=!1,x(""))}}const be=n?[...n.unresolved.map(ie=>({row:ie,unresolved:!0})),...n.planned.map(ie=>({row:ie,unresolved:!1}))]:[];return e.jsxs("section",{className:"crm-followups","aria-label":"Wiedervorlagen planen","aria-busy":m||!!g,children:[e.jsxs("div",{className:"crm-followups__header",children:[e.jsxs("div",{children:[e.jsxs("h2",{children:[e.jsx(co,{size:19,"aria-hidden":"true"})," Wiedervorlagen planen"]}
96),e.jsx("p",{children:"Letzter Mitarbeiterkontakt · freie Zeiten von 08:30 bis 16:30 Uhr"})]}),e.jsxs("button",{type:"button",disabled:m||!!g,className:"crm-followups__refresh",onClick:()=>ee(ie=>ie+1),children:[e.jsx(ro,{size:15})," Neu prüfen"]})]}),!!j.length&&e.jsxs("div",{className:"crm-followups__status",children:[e.jsxs("p",{children:[j.length," bisherige Wiedervorlagen sind noch im Browser gespeichert. Die Ãbernahme ergänzt fehlende Daten und legt keine Termine an."]}),e.jsx("button",{type:"button",disabled:!!g||m,className:"crm-followups__more",onClick:()=>{confirm("Bisherige Wiedervorlagen übernehmen? Vorhandene Serverdaten bleiben erhalten. Es werden keine Termine angelegt.")&&_("import",async()=>{let ie=0;for(let H=0;H<j.length;H+=100){const U=await Os("import",{confirm:!0,dates:j.slice(H,H+100)});ie+=U.imported||0}return`${ie} Wiedervorlagen übernommen. Die lokale Sicherung bleibt erhalten.`})},children:"Bisherige Wiedervorlagen übernehmen"})]}),m&&e.jsx("p",{role:"status",children:"Zuständigkeiten und freie Zeiten werden geprüft â¦"}),p&&e.jsx("p",{role:"alert",className:"crm-followups__status",children:p}),f&&e.jsx("p",{role:"status",className:"crm-followups__status",children:f}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{role:"status",className:"crm-followups__status",children:[n.planned.length," Vorschläge · ",n.existing.length," bereits vorhanden · ",n.unresolved.length," zu prüfen. ",n.scanned," Leads geprüft."]}),e.jsx("div",{className:"crm-followups__list",children:(le?be:be.slice(0,3)).map(({row:ie,unresolved:H})=>e.jsxs("div",{className:"crm-followups__row",children:[e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:"crm-followups__lead",onClick:()=>a(ie.leadId),children:[ie.leadName,e.jsx(lo,{size:15})]}),e.jsx("p",{children:ie.reason})]}),e.jsx("div",{className:"crm-followups__assignment",children:H?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Zuordnung prüfen"}),e.jsx("p",{children:ie.issue}),ie.contactId&&ie.contactSource&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{"aria-label":"Kontaktperson für "+ie.leadName,value:I[ie.leadId]||"",disabled:!!g,onChange:U=>B(F=>({...F,[ie.leadId]:U.target.value})),children:[e.jsx("option",{value:"",children:"Person auswählen"}),n.assignees.map(U=>e.jsx("option",{value:U.id,children:U.name||U.email},U.id))]}),e.jsx("button",{type:"button",disabled:!!g||!I[ie.leadId],className:"crm-followups__more",onClick:()=>void _(ie.leadId,async()=>(await Os("assign",{leadId:ie.leadId,contactId:ie.contactId,contactSource:ie.contactSource,userId:I[ie.leadId]}),"Kontaktperson zugeordnet. Es wurde kein Termin angelegt.")),children:"Kontaktperson bestätigen"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:ie.personName||ie.person}),e.jsx("p",{children:$r(ie)}),e.jsx("button",{type:"button",className:"crm-followups__more",disabled:!!g,onClick:()=>{confirm(`Wiedervorlage für ${ie.leadName} im nächsten freien Block eintragen? Die aktuelle Belegung wird erneut geprüft.`)&&_(ie.leadId,async()=>{const U=await Os("book",{leadId:ie.leadId,confirm:!0});if(U.needsReview)throw new Error(U.issue);return U.existing?"Für diesen Lead ist bereits ein Termin vorhanden.":`Termin eingetragen: ${$r(U)}.`})},children:"Termin eintragen"})]})})]},ie.leadId))}),be.length>3&&e.jsx("button",{type:"button",className:"crm-followups__more","aria-expanded":le,onClick:()=>Z(ie=>!ie),children:le?"Weniger anzeigen":`Alle ${be.length} anzeigen`}),n.nextCursor&&e.jsx("button",{type:"button",className:"crm-followups__more",disabled:!!g,onClick:()=>void ue(),children:"Weitere Leads prüfen"})]})]})}const vi={website:"Webseite",email:"E-Mail",phone:"Telefon",contact:"Ansprechpartner",city:"Ort",industry:"Branche",booth:"Stand",fair:"Messe"},No={pending:"Wartet auf den Mac mini",claimed:"Wird ausgewertet",processing:"Wird ausgewertet","done-needs-review":"Vorschau bereit",error:"Auswertung fehlgeschlagen",cancelled:"Abgebrochen"},Co={existing_domain:"Firma bereits im CRM",duplicate_in_source:"Doppelt in der Quelle",already_imported:"Bereits importiert",needs_review:"Firmen-Webseite noch ungeklärt",new_candidate:"Neue Firma"},zo={auth:"Bitte erneut anmelden.",forbidden:"Der Messeimport ist für diesen Zugang nicht freigegeben.",crm_changed_retry_preview:"Das CRM wurde zwischenzeitlich geändert. Bitte die Vorschau neu laden.",preview_changed:"Die Vorschau hat sich geändert. Bitte neu laden.",request_conflict:"Dieser Vorgang wurde bereits mit anderen Angaben verwendet.",company_identity_required:"Für neue Firmen mit bekannter Domain muss die Webseite übernommen werden.",duplicate_check_limit:"Der Firmenabgleich konnte nicht vollständig durchgeführt werden."};async function Ao(t,r,a){var k;const n=new AbortController,h=setTimeout(()=>n.abort(),25e3),p=()=>n.abort();a==null||a.addEventListener("abort",p,{once:!0}),a!=null&&a.aborted&&p();try{const f=await fetch(ln+t,{method:r===void 0?"GET":"POST",headers:Cs(),body:r===void 0?void 0:JSON.stringify(r),signal:n.signal}),C=(k=f.body)==null?void 0:k.getReader();if(!C)throw new Error("Leere Serverantwort.");let m=0,v="";const g=new TextDecoder;try{for(;;){const{done:N,value:ee}=await C.read();if(N)break;if(m+=ee.byteLength,m>2*1024*1024)throw new Error("Die Vorschau ist zu groÃ.");v+=g.decode(ee,{stream:!0})}v+=g.decode()}
96finally{await C.cancel().catch(()=>{})}let x;try{x=JSON.parse(v)}catch{throw new Error("Ungültige Serverantwort. Bitte erneut versuchen.")}if(!f.ok)throw new Error(zo[x.error]||"Der Vorgang konnte nicht abgeschlossen werden. Bitte erneut versuchen.");return x}catch(f){throw n.signal.aborted?new Error("Die Anfrage wurde unterbrochen. Bitte den Status prüfen und bei Bedarf erneut versuchen."):f}finally{clearTimeout(h),a==null||a.removeEventListener("abort",p)}}function Eo({onClose:t,onImported:r,api:a=Ao}){const n=l.useRef(null),h=l.useRef(new AbortController),[p,k]=l.useState(""),[f,C]=l.useState(""),[m,v]=l.useState([]),[g,x]=l.useState(""),[N,ee]=l.useState(null),[le,Z]=l.useState({}),[I,B]=l.useState(null),[j,P]=l.useState(""),[ve,$]=l.useState(""),[_,ue]=l.useState(!1),be=l.useRef({key:"",id:""}),ie=l.useRef({key:"",id:""}),H=async()=>{const ne=await a("/api/crm/messe/jobs",void 0,h.current.signal);v(ne.jobs||[])};l.useEffect(()=>{var Le,Ue;const ne=new AbortController;return h.current=ne,(Le=n.current)!=null&&Le.open||(Ue=n.current)==null||Ue.showModal(),a("/api/crm/messe/jobs",void 0,ne.signal).then(ct=>{ne.signal.aborted||v(ct.jobs||[])}).catch(ct=>{ne.signal.aborted||$(ct.message)}),()=>{ne.abort()}},[]),l.useEffect(()=>{if(!m.some(Le=>["pending","claimed","processing"].includes(Le.status))||j)return;const ne=setInterval(()=>{H().catch(Le=>$(Le.message))},5e3);return()=>clearInterval(ne)},[m,j]);const U=async(ne,Le)=>{P(ne),$("");try{await Le()}catch(Ue){h.current.signal.aborted||$(Ue instanceof Error?Ue.message:"Vorgang fehlgeschlagen.")}finally{h.current.signal.aborted||P("")}},F=ne=>U("preview",async()=>{const Le=await a("/api/crm/messe/preview?jobId="+encodeURIComponent(ne),void 0,h.current.signal);x(ne),Z({}),ue(!1),B(null),Le.ready?ee(Le):(ee(null),await H())}),K=l.useMemo(()=>Object.entries(le).map(([ne,Le])=>({sourceKey:ne,...Le})),[le]),A=(ne,Le)=>{ue(!1),Z(Ue=>{const ct={...Ue};return Le?ct[ne.source_key]={action:ne.existingIds.length?"supplement":"create",fields:ne.existingIds.length?[]:Object.keys(vi).filter(yt=>yt==="fair"||ne.fields[yt]&&(yt!=="website"||ne.domain)),leadId:ne.existingIds.length===1?ne.existingIds[0]:void 0}:delete ct[ne.source_key],ct})},ce=(ne,Le)=>U(Le,async()=>{await a("/api/crm/messe/"+Le,{jobId:ne,confirm:!0},h.current.signal),g===ne&&(ee(null),Z({}),ue(!1)),await H()}),Ve=()=>U("scan",async()=>{const ne={fair:p.trim(),url:f.trim(),confirmScan:!0},Le=JSON.stringify(ne);be.current.key!==Le&&(be.current={key:Le,id:crypto.randomUUID()});const Ue=await a("/api/crm/messe/jobs",{...ne,requestId:be.current.id},h.current.signal);x(Ue.jobId),ee(null),B(null),await H()}),Xe=()=>U("import",async()=>{if(!N||!_||!K.length)return;const ne={jobId:N.jobId,resultHash:N.resultHash,selections:K,confirm:!0},Le=JSON.stringify(ne);ie.current.key!==Le&&(ie.current={key:Le,id:crypto.randomUUID()});const Ue=await a("/api/crm/messe/import",{...ne,requestId:ie.current.id},h.current.signal);B(Ue.report),Z({}),ue(!1),r(),await H()}),it=()=>{if(!I)return;const ne=URL.createObjectURL(new Blob([JSON.stringify(I,null,2)],{type:"application/json"})),Le=document.createElement("a");Le.href=ne,Le.download="Messe-Importbericht.json",Le.click(),setTimeout(()=>URL.revokeObjectURL(ne),1e3)};return e.jsxs("dialog",{className:"lm-messe",ref:n,"aria-labelledby":"messe-title",onCancel:ne=>{ne.preventDefault(),j!=="import"&&t()},children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsx("h2",{id:"messe-title",children:"Aussteller importieren"}),e.jsx("p",{children:"Ãffentliche Liste prüfen und Firmen gezielt übernehmen."})]}),e.jsx("button",{"aria-label":"SchlieÃen",disabled:j==="import",onClick:t,children:"Ã"})]}),e.jsxs("div",{className:"lm-messe-body",children:[e.jsxs("form",{onSubmit:ne=>{ne.preventDefault(),Ve()},children:[e.jsxs("label",{children:["Messe",e.jsx("input",{required:!0,maxLength:160,value:p,onChange:ne=>k(ne.target.value),disabled:!!j})]}),e.jsxs("label",{children:["Ausstellerliste",e.jsx("input",{type:"url",required:!0,placeholder:"https://â¦",maxLength:2048,value:f,onChange:ne=>C(ne.target.value),disabled:!!j})]}),e.jsx("button",{className:"lm-messe-primary",disabled:!!j||!p.trim()||!f.trim(),children:j==="scan"?"Wird gestartetâ¦":"Liste auswerten"})]}),ve&&e.jsx("p",{role:"alert",className:"lm-messe-error",children:ve}),e.jsxs("section",{"aria-label":"Auswertungen",children:[e.jsxs("div",{className:"lm-messe-heading",children:[e.jsx("h3",{children:"Auswertungen"}),e.jsx("button",{disabled:!!j,onClick:()=>U("refresh",H),children:"Aktualisieren"})]}),m.length?m.map(ne=>e.jsxs("div",{children:[e.jsxs("button",{className:"lm-messe-job",disabled:!!j,"aria-pressed":g===ne.jobId,onClick:()=>F(ne.jobId),children:[e.jsx("strong",{children:ne.fair}),e.jsx("span",{children:No[ne.status]||"Status wird geprüft"})]}),ne.status==="error"&&e.jsx("button",{disabled:!!j,onClick:()=>ce(ne.jobId,"retry"),children:"Erneut versuchen"}),["pending","claimed","processing","error"].includes(ne.status)&&e.jsx("button",{disabled:!!j,onClick:()=>ce(ne.jobId,"cancel"),children:"Auswertung abbrechen"})]},ne.jobId)):e.jsx("p",{children:"Noch keine Auswertung."})]}),N&&e.jsxs("section",{"aria-label":"Importvorschau",children:[e.jsxs("h3",{children:[N.preview.rows.length," Firmen in der Vorschau"]}),N.preview.warnings.length>0&&e.jsx("p",{className:"lm-messe-warning",children:"Die Auswertung ist teilweise unvollständig. Bitte Quellen und Angaben prüfen."}),N.preview.rows.length===0&&e.jsx("p",{children:"Keine unterstützten Ausstellerdaten gefunden. Die Liste wurde nicht importiert."}),N.preview.rows.map((ne,Le)=>{var yt,rt,De;const Ue=le[ne.source_key],ct=["duplicate_in_source","already_imported"].includes(ne.duplicateStatus);return e.jsxs("article",{className:"lm-messe-row",children:[e.jsxs("label",{className:"lm-messe-select",children:[e.jsx("input",{type:"checkbox",checked:!!Ue,disabled:!!j||ct||!Ue&&K.length>=50,onChange:je=>A(ne,je.target.checked)}),e.jsx("strong",{children:ne.fields.name})]}),e.jsx("p",{children:Co[ne.duplicateStatus]||"Bitte prüfen"}),e.jsxs("p",{children:[((yt=ne.relevance)==null?void 0:yt.reason)||"Relevanz noch ungeprüft.",((rt=ne.relevance)==null?void 0:rt.basis)&&e.jsxs(e.Fragment,{children:[" Grundlage: â",ne.relevance.basis.value,"â."]})]}),((De=ne.relevance)==null?void 0:De.caveat)&&e.jsx("p",{className:"lm-messe-meta",children:ne.relevance.caveat}),e.jsx("a",{href:/^https:\/\//.test(ne.source_url)?ne.source_url:void 0,target:"_blank",rel:"noopener noreferrer",children:"Quelle öffnen"}),e.jsxs("span",{className:"lm-messe-meta",children:[" · Abgerufen ",new Date(ne.retrieved_at).toLocaleDateString("de-DE")]}),e.jsxs("details",{children:[e.jsx("summary",{children:"Angaben prüfen"}),e.jsx("dl",{children:Object.entries(vi).map(([je,nt])=>e.jsxs("div",{children:[e.jsx("dt",{children:nt}
96),e.jsx("dd",{children:je==="fair"?ne.fair:ne.fields[je]||"Nicht angegeben"})]},je))})]}),Ue&&e.jsxs("fieldset",{disabled:!!j,children:[e.jsx("legend",{children:Ue.action==="supplement"?"Nur ausgewählte leere Felder ergänzen":"Angaben übernehmen"}),ne.existingIds.length>1&&e.jsxs("label",{children:["Vorhandene Firma",e.jsxs("select",{value:Ue.leadId||"",onChange:je=>{ue(!1),Z({...le,[ne.source_key]:{...Ue,leadId:je.target.value}})},children:[e.jsx("option",{value:"",disabled:!0,children:"Firma auswählen"}),ne.existingIds.map(je=>{var nt,qe;return e.jsx("option",{value:je,children:((qe=(nt=ne.existingCompanies)==null?void 0:nt.find(lt=>lt.id===je))==null?void 0:qe.name)||"Vorhandene Firma "+je},je)})]})]}),Object.keys(vi).filter(je=>je==="fair"||ne.fields[je]).map(je=>e.jsxs("label",{className:"lm-messe-field",children:[e.jsx("input",{type:"checkbox",checked:Ue.fields.includes(je),disabled:je==="website"&&Ue.action==="create"&&!!ne.domain||je==="website"&&!ne.domain,onChange:nt=>{ue(!1),Z({...le,[ne.source_key]:{...Ue,fields:nt.target.checked?[...Ue.fields,je]:Ue.fields.filter(qe=>qe!==je)}})}}),vi[je]]},je))]})]},ne.source_key+"-"+Le)}),!!K.length&&e.jsxs("div",{className:"lm-messe-confirm",children:[e.jsxs("p",{children:[K.length," ausgewählt · Bestehende Werte bleiben erhalten."]}),e.jsxs("label",{className:"lm-messe-field",children:[e.jsx("input",{type:"checkbox",checked:_,disabled:!!j,onChange:ne=>ue(ne.target.checked)}),"Auswahl und Angaben geprüft"]}),e.jsx("button",{className:"lm-messe-primary",disabled:!!j||!_||K.some(ne=>ne.action==="supplement"&&(!ne.fields.length||!ne.leadId)),onClick:Xe,children:j==="import"?"Wird übernommenâ¦":"Auswahl übernehmen"})]})]}),I&&e.jsxs("section",{"aria-label":"Importbericht",role:"status",children:[e.jsx("h3",{children:"Import abgeschlossen"}),e.jsxs("p",{children:[I.created," neu · ",I.supplemented," ergänzt · ",I.skipped," übersprungen"]}),e.jsx("button",{onClick:it,children:"Bericht herunterladen"}),e.jsx("button",{disabled:!!j,onClick:()=>F(g),children:"Vorschau aktualisieren"})]})]})]})}const Nn={background:"var(--panel)",border:"1px solid var(--line)",borderRadius:13,padding:15},Tt={border:"1px solid var(--line)",borderRadius:13,overflow:"hidden",background:"var(--panel)"},ki={borderTop:"1px solid var(--line)",paddingTop:12},fe={fontSize:10,fontWeight:700,letterSpacing:".13em",textTransform:"uppercase",color:"var(--ink-3)"},ye={fontSize:11.5,color:"var(--ink-3)",fontWeight:600},xe={fontVariantNumeric:"tabular-nums"},Ct={width:"100%",background:"var(--panel)",border:"1px solid var(--line-2)",borderRadius:10,padding:"9px 12px",fontSize:12.5,color:"var(--ink)",fontFamily:"inherit",outline:"none"},Pi={display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,borderRadius:10,padding:"8px 14px",fontSize:12.5,fontFamily:"inherit",cursor:"pointer",lineHeight:1.2},Pn={...Pi,background:"linear-gradient(135deg,#ffe14d,var(--gold-2))",color:"#241C00",border:"none",fontWeight:800},Ei={...Pi,background:"var(--green-soft)",color:"var(--green)",border:"1px solid var(--green-bd)",fontWeight:700},as={...Pi,background:"transparent",color:"var(--ink-2)",border:"1px solid var(--line)",fontWeight:600},zn={display:"inline-flex",alignItems:"center",justifyContent:"center",width:26,height:26,flexShrink:0,borderRadius:8,border:"1px solid var(--line)",background:"transparent",color:"var(--ink-2)",cursor:"pointer",fontSize:12.5,lineHeight:1,padding:0,fontFamily:"inherit"},Qe={width:7,height:7,borderRadius:"50%",flexShrink:0,display:"inline-block"},rn={display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:"var(--ink-2)",fontWeight:600},bn="rgba(255,212,0,.055)",an={fontSize:10,fontWeight:700,letterSpacing:".13em",textTransform:"uppercase",color:"var(--ink-3)",background:"transparent",border:"none",padding:0},tt="9L0jWrpKraF8gT",Cn="Yl21rZieG5z4Vw",He={task:"hRCvN",subline:"MWLHC",date:"LjbiU",deadline:"GHoWP",completed:"cJUTt",urgent:"urllA",assignee:"8rb6F",assigneeLink:"PiEN9",leadLink:"VtTEA",closeId:"L71pO",leadIdText:"bAgUL"},ws="uGIvCBsp1Vh1E8",$a="RrzJemBbWMk61J",Io="6KttmPlijb0Bo1",ja="B2xjIZOP9menlP",zs=()=>Cs(),Ea="crm-entwurf",Di="lm-crm-entwurf",To=10*60*1e3;function Wi(){try{const t=sessionStorage.getItem(Ea);if(!t)return null;const r=JSON.parse(t);return!r||!r.betreff&&!r.text?null:r.ts&&Date.now()-r.ts>To?(sessionStorage.removeItem(Ea),null):r}catch{return null}}function Lo(){try{sessionStorage.removeItem(Ea)}catch{}}const vt=new Map,rl=6e4;async function Ge(t,r){const a=!(r!=null&&r.method)||r.method==="GET",n=t;if(a){const k=vt.get(n);if(k&&Date.now()-k.ts<rl)return k.data}const p=await(await fetch(`${ln}${t}`,{...r,headers:{...zs(),...r==null?void 0:r.headers}})).json();return a&&!(p!=null&&p.error)&&vt.set(n,{data:p,ts:Date.now()}),p}async function Bo(t,r=200,a=0){const n=`POST:/api/db/query:${t}:${r}:${a}`,h=vt.get(n);if(h&&Date.now()-h.ts<rl)return h.data;const p=await Ge("/api/db/query",{method:"POST",body:JSON.stringify({table:t,count:r,offset:a})});if(p!=null&&p.error)return{data:[],error:p.error};const k={data:(p==null?void 0:p.items)||(p==null?void 0:p.data)||(p==null?void 0:p.records)||[]};return p&&!p.error&&vt.set(n,{data:k,ts:Date.now()}),k}function Zt(t,r=50,a=0){return Bo(t,r,a)}async function et(t,r,a){const n=await Ge("/api/db/mutate",{method:"POST",body:JSON.stringify({method:"update",table:t,recordId:r,fields:a})});return vt.clear(),n}async function Gn(t,r){return vt.clear(),Ge("/api/db/mutate",{method:"POST",body:JSON.stringify({method:"create",table:t,fields:r})})}function Ka(t){const r=String(t||"").trim();return!r||r.includes("/api/proxy-image")||!/^https?:\/\//i.test(r)?r:/(tables-api\.softr\.io|softr-files|\.softr\.io|dropbox\.com|dropboxusercontent\.com)/i.test(r)?`${ln}/api/proxy-image?url=${encodeURIComponent(r)}`:r}function ll(t){return Ka(t)}const Do="lm_crm_cache",qn="kv";let ji=null;function Ha(){return ji||(ji=new Promise(t=>{try{const r=indexedDB.open(Do,1);r.onupgradeneeded=()=>{const a=r.result;a.objectStoreNames.contains(qn)||a.createObjectStore(qn)},r.onsuccess=()=>t(r.result),r.onerror=()=>t(null)}catch{t(null)}}),ji)}async function $i(t){const r=await Ha();return r?new Promise(a=>{try{const h=r.transaction(qn,"readonly").objectStore(qn).get(t);h.onsuccess=()=>a(h.result??null),h.onerror=()=>a(null)}catch{a(null)}}):null}async function Ki(t,r){const a=await Ha();if(a)return new Promise(n=>{try{const h=a.transaction(qn,"readwrite");h.objectStore(qn).put(r,t),h.oncomplete=()=>n(),h.onerror=()=>n()}catch{n()}})}async function Wo(t){const r=await Ha();if(r)return new Promise(a=>{try{const n=r.transaction(qn,"readwrite");n.objectStore(qn).delete(t),n.oncomplete=()=>a(),n.onerror=()=>a()}catch{a()}})}const Gs="leads_records_v1",Mi="contacts_records_v4";function Hs(t){if(!t)return"";let r=t.trim().replace(/[\s()\-./]/g,"");return r.startsWith("00")&&(r="+"+r.slice(2)),r.startsWith("0")&&(r="+49"+r.slice(1)),!r.startsWith("+")&&/^\d+$/.test(r)&&(r="+49"+r),r}function Hr(t){const r=Hs(t);return/^\+\d{8,15}$/.test(r)}function Mo(t){let r=Hs(t).replace(/^\+/,"");return/^490/.test(r)&&(r="49"+r.slice(3)),r}function Ro(t,r=48){var h,p,k;const a=((h=t==null?void 0:t.fields)==null?void 0:h.s0ou0)||((p=t==null?void 0:t.fields)==null?void 0:p.eTZ32)||((k=t==null?void 0:t.fields)==null?void 0:k.hOR69);if(!a)return!1;const n=new Date(a).getTime();return Number.isFinite(n)?(Date.now()-n)/36e5>=r:!1}function Fo(t){const r=Date.now()-6048e5,a=t.filter(C=>{var v,g;const m=new Date(((v=C==null?void 0:C.fields)==null?void 0:v.hOR69)||((g=C==null?void 0:C.fields)==null?void 0:g.bcW3A)||0).getTime();return Number.isFinite(m)&&m>=r}).map(C=>{const m=C.fields||{};return{id:C.id,firma:m.LMbdt||m.EdG6x||"",kontakt:m.iMMJT||"",email:m.zH3Px||"",telefon:m.azRhM||m.ev2R7||"",status:m["2LiYP"]||"",angelegt:m.hOR69||""}});if(a.length===0){alert("Keine Leads in den letzten 7 Tagen.");return}const n=Object.keys(a[0]).join(";"),h=a.map(C=>Object.values(C).map(m=>`"${String(m).replace(/"/g,'""')}"`).join(";")).join(` 97`),p=new Blob(["\uFEFF"+n+` 98`+h],{type:"text/csv;charset=utf-8"}),k=URL.createObjectURL(p),f=document.createElement("a");f.href=k,f.download=`liberda-leads-woche-${new Date().toISOString().slice(0,10)}.csv`,f.click(),URL.revokeObjectURL(k)}const i={displayName:"LMbdt",leadName:"EdG6x",description:"JUg3O",url:"DBTs0",statusLabel:"2LiYP",contactName:"iMMJT",contactFirst:"XIIE7",contactLast:"9UT5K",contactTitle:"LpUSp",contactPhone:"azRhM",contactEmail:"zH3Px",telefon:"ev2R7",social:"r8uUr",kategorie:"vJWtq",kundennr:"0gSQ9",ownerName:"c8xQL",notiz:"Jf5fV",wichtig:"hGEgA",jahresumsatz:"sRMZF",groesse:"6urMz",tier:"Lp65k",geschlecht:"IsqJz",leadScore:"UM4gK",leadNameOhneFirma:"h3WWi",dateCreated:"hOR69",dateUpdated:"bcW3A",addr1:"qRRNI",addrCity:"8g9dW",addrState:"7wGIT",addrZip:"o8tSe",oppStatus:"Ck294",oppValue:"akmdi",confidence:"2eTXE",closeDate:"JZbCJ",lastActivityDate:"s0ou0",lastCommDate:"eTZ32",lastCommSummary:"H5MBH",lastCommType:"Lz3yE",lastEmailDate:"eurDR",lastEmailSubject:"4RVPQ",lastEmailFrom:"p3RiD",numEmails:"4hJTW",numCalls:"A4Gk6",numContacts:"Rlbij",numOpps:"IT3v9",numActivities:"s4Yx6",numOutgoingEmails:"Ovvrf",numReceivedEmails:"5S3B2",numTasks:"QDMc5",numMeetings:"fw2f2",closeLeadId:"gaEYh",messen:"Io4A1",standnummer:"jYXJ1",humorskala:"YkKBs",videokarte:"ABzfq",leadImporteur:"BvYTN",brancheField:"Y4deL",tierAnalyse:"JFjS6",guthaben:"i7D73",abrechnungUebersicht:"B2qKh",updateintervall:"jKHZ3",qualifiziert:"oANpu",instagram:"J12YH",analyseGenerieren:"7gIr6",retainer:"aJgZz",svcWebdesign:"Fzy3k",svcSEO:"DdD9v",svcAds:"8KNJh",svcSocial:"bnQEM",svcVideo:"sZoDJ",svcFoto:"5iq8R",svcBranding:"AGfK2",svcContent:"fqzhg",svcConsulting:"r9cCc",svcHosting:"rbwks",svcMaintenance:"gG2Vm",svcEmail:"WF11V",svcPrint:"2U97N",svcEvents:"y5vaM",svcInfluencer:"2IXZH",svcPR:"peBNe",svcSonstiges:"nfKQ3",aHandle:"uR8AZ",aFollower:"M3csM",aBeitraege:"rg4hb",aPostsProWoche:"JR9IR",aEngagement:"zL94h",aDatum:"t5rza",aReelsAnteil:"5h7Qy",aFotosAnteil:"IgV9K",aKarussellsAnteil:"9L6cL",aReelViews:"C1HWp",aDurchschnittViews:"hWYmb",aTo
98pViews:"8f0l2",aStaerken:"YKhV4",aSchwaechen:"jpEY6",aBranche:"r5FWZ",aBvPostsKunde:"iWdDe",aBvPostsSchnitt:"JsRmy",aBvReelsKunde:"Gyuxy",aBvReelsSchnitt:"qxI6a",aBvFollowerKunde:"7m9VZ",aBvFollowerSchnitt:"Q3eEv",aBvEngagementKunde:"K4hyN",aBvEngagementSchnitt:"tOz0Q",aEmpfohlenPaket:"qzyNr",aPaketGrund:"uyxjl",aServices:"9DLEc",aAktiv:"ifLxw",aCalendly:"SJuga",aHeroImage:"Svo8P",closeNotes:"1YEB0",closeCallDesc:"86biU",closeTaskDesc:"TFdTD",kontaktReihenfolge:"TmvV2"};function Vr(t){const r=(t==null?void 0:t.fields)||{};for(const a in r){const n=r[a];if(typeof n=="string"&&n.toLowerCase().includes("impressum"))return!0}return!1}function _o(t,r){const a=[...t].sort((p,k)=>(Vr(p)?1:0)-(Vr(k)?1:0));let n=[];try{const p=JSON.parse(r||"[]");Array.isArray(p)&&(n=p.filter(k=>typeof k=="string"))}catch{}if(!n.length)return a;const h=new Map(n.map((p,k)=>[p,k]));return a.map((p,k)=>({c:p,i:k,p:h.has(p.id)?h.get(p.id):Number.MAX_SAFE_INTEGER})).sort((p,k)=>p.p-k.p||p.i-k.i).map(p=>p.c)}const Bn={tier:["A","B","C"],leadImporteur:["Claude","Irfan","Jahangir"],videokarte:["JA"],updateintervall:["6 Monate","Monatlich","Quartalsweise"],qualifiziert:["JA â ","UNGEEIGNET â"],analyseGenerieren:["JETZT STARTEN"],retainer:["Individuell","MAX","MINI","PRO","START"],humorskala:["1","2","3","4","5","6","7","8","9","10"],messen:["Abenteuer & Allrad 2024","Abenteuer & Allrad 2025","Abenteuer & Allrad 2026","ABF 2025","ABF 2026","Adventure Southside 2024","Adventure Southside 2025","AERO Friedrichshafen 2025","Aerospace 2024","AGRITECHNICA 2025","Automechanika 2024","Caravan Salon 2024","Customz and Cruiserz 2024","Demopark 2025","DLG Waldtage 2025","Eurobike 2024","Eurobike 2025","Fire Rescue Mittelrhein 24","FMB 2024","FORMNEXT 2024","FORST live 2026","GaLaBau 2024","Holz-Handwerk 2026","INTERGEO 2025","ISH in Frankfurt 2025","KWF 2024","Leben und Tod 2025","Messe München 2025","My Job OWL 2025","My Job OWL 2026","NECKAR-ALB REGENERATIV 2025","NordBau 2024","Nordbau 2025","NUFAM 2025","PARKEN 2025","Pestprotect 2024","Ps Days 2024","Retro Classics 2025","Season Opening 2024","TEXCARE 2024","The Tire Cologne 2026"],branche:["Agrartechnik","Aston Martin","Autohändler","Beauty","Bentley","Bestatter","BMW","Fahrrad","Fahrschule","Ferrari","Fitness Studios","Folierer","Golf","Helikopter","Hochzeitslocations","Holtkämper Dressurtage 25","Immobilien","Lokal","Luxus Autohäuser","Luxus Reisen","Messebegleitung","Motorrad","Physio","Porsche","Privatjet","ROLLS-ROYCE","Sportstätten","Tennis","Yacht","Zahnarztpraxen"]};function Jr(t){try{const r=t.replace(/\s/g,"");if(!r)return"";const a=Uint8Array.from(atob(r),n=>n.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!1}).decode(a)}catch{return t}}function ol(t){return t.replace(/=\r?\n/g,"").replace(/=([0-9A-Fa-f]{2})/g,(r,a)=>String.fromCharCode(parseInt(a,16)))}function Oo(t,r){const a=r.toLowerCase().replace(/[^a-z0-9]/g,"");if(a==="utf8"||a==="utf-8"||!r)return t;try{const n=new Uint8Array(t.length);for(let h=0;h<t.length;h++)n[h]=t.charCodeAt(h)&255;return new TextDecoder(r,{fatal:!1}).decode(n)}catch{return t}}function Gr(t,r){try{const a=new Uint8Array(t.length);for(let p=0;p<t.length;p++)a[p]=t.charCodeAt(p)&255;const n=(r||"utf-8").toLowerCase().replace(/[^a-z0-9]/g,""),h=n==="utf8"||n==="utf-8"||!r?"utf-8":r;return new TextDecoder(h,{fatal:!1}).decode(a)}catch{return t}}function Po(t){try{const r=t.replace(/\s/g,"");return r?atob(r):""}catch{return t}}function $o(t){try{if(t.includes("â")||t.includes("Ã")||t.includes("Ã")||t.includes("ä")||t.includes("ü")){const r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n)&255;const a=new TextDecoder("utf-8",{fatal:!1}).decode(r);if(!a.includes("")&&a.length>0)return a}}catch{}return t}function wi(t){return t.replace(/<img\b[^>]*\bsrc\s*=\s*["']cid:[^"']*["'][^>]*>/gi,'<span style="display:inline-block;padding:2px 8px;margin:2px 0;border:1px dashed #C4CFCA;border-radius:6px;background:#F2F6F4;color:#616E68;font-size:12px">ð eingebettetes Bild</span>').replace(/<img\b(?![^>]*\bsrc\s*=\s*["']?\s*\S)[^>]*>/gi,"").replace(/<img\b[^>]*\bsrc\s*=\s*["']\s*["'][^>]*>/gi,"").replace(/<script[\s\S]*?<\/script>/gi,"").replace(/\son\w+\s*=\s*"[^"]*"/gi,"").replace(/\son\w+\s*=\s*'[^']*'/gi,"").replace(/javascript\s*:/gi,"void:").replace(/<\/?html[^>]*>/gi,"").replace(/<head[\s\S]*?<\/head>/gi,r=>(r.match(/<style[\s\S]*?<\/style>/gi)||[]).join(` 99`)).replace(/<\/?body[^>]*>/gi,"").replace(/<meta[^>]*>/gi,"").replace(/<title[\s\S]*?<\/title>/gi,"").replace(/<link[^>
99]*>/gi,"")}function cl(t,r=!0,a=0){var v,g,x,N,ee,le,Z;if(a>8)return t;const n=t.match(/boundary="?([^"\r\n;]+)"?/i);if(!n)return t;const h=n[1].trim(),p=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),k=new RegExp("--"+p+`(?:--)?(?:\r? 100|$)`),f=t.split(k);let C="",m="";for(const I of f){const B=I.trim();if(!B||B==="--")continue;const j=((g=(v=I.match(/Content-Type:\s*([^\r\n;]+)/i))==null?void 0:v[1])==null?void 0:g.trim().toLowerCase())||"",P=I.match(/(?:Content-Type:[^\r\n]*)?charset="?([^"\r\n;> ]+)"?/i),ve=((x=P==null?void 0:P[1])==null?void 0:x.trim())||"utf-8",$=((ee=(N=I.match(/Content-Transfer-Encoding:\s*([^\r\n]+)/i))==null?void 0:N[1])==null?void 0:ee.trim().toLowerCase())||"",_=I.match(/\r?\n\r?\n/);if(!_)continue;let ue=I.substring(_.index+_[0].length);if(ue=ue.replace(/\r?\n--[^\r\n]*(?:--)?[\s]*$/,"").trim(),j.includes("multipart/")){const be=(Z=(le=I.match(/boundary="?([^"\r\n;]+)"?/i))==null?void 0:le[1])==null?void 0:Z.trim();if(!be||be===h)continue;const ie=cl(I,r,a+1);ie&&ie!==I&&(!C&&(ie.includes("<html")||ie.includes("<div")||ie.includes("<table"))?C=ie:m||(m=ie));continue}$==="base64"?ue=Gr(Po(ue),ve):$==="quoted-printable"?ue=Gr(ol(ue),ve):ue=Oo(ue,ve),j.includes("text/html")&&!C?C=ue:j.includes("text/plain")&&!m&&(m=ue)}return r&&C?C:m?`<div class="cs-email-text">${m.replace(/</g,"<").replace(/>/g,">")}</div>`:C||t}function Ko(t){if(!t)return"";let r=t;const a=t.match(/BODY(?:\.PEEK)?\[(?:TEXT|\d+(?:\.\d+)?)\]\s*\{(\d+)\}\r?\n([\s\S]*)/i);if(a)r=a[2].substring(0,parseInt(a[1]));else{const g=t.match(/BODY(?:\.PEEK)?\[HEADER(?:\.FIELDS[^\]]*)?]\][\s\S]*?\r?\n\r?\n/i);g&&(r=t.substring(g.index+g[0].length))}if(r=r.replace(/\)\r?\nT\d+ OK.*$/s,"").replace(/\)\s*$/,"").trim(),r.includes("Content-Type:")&&/boundary=/i.test(r)){const g=cl(r);g&&g!==r&&(r=g)}let h=(r.match(/=[0-9A-F]{2}/gi)||[]).length>3?ol(r):r;const p=h.trim().split(/\r?\n/),k=p.filter(g=>/^[A-Za-z0-9+/=]{30,}$/.test(g.trim()));if(k.length>=4&&k.length>p.length*.8){const g=Jr(k.join(""));g.length>20&&g!==k.join("")&&(h=g)}h=$o(h);const f=h.match(/<html[\s\S]*?<\/html>/i);if(f)return wi(f[0]);if(/<(?:div|table|td|p|span|a|img|br)\b/i.test(h))return wi(h);const C=h.split(/\r?\n\r?\n/);let m=-1;for(let g=0;g<C.length;g++){const x=C[g].trim();if(!x.match(/^[\w-]+:\s/)&&!x.match(/^\* \d+ FETCH/)&&!x.match(/^T\d+ /)&&x.length>0){m=g;break}}if(m>=0){const g=C.slice(m).join(` 101 102`);if(/^[A-Za-z0-9+/=\s]{80,}$/.test(g))try{const x=Jr(g.replace(/\s/g,""));if(x.length>10)return/<[a-z]/i.test(x)?wi(x):`<div class="cs-email-text">${x.replace(/</g,"<").replace(/>/g,">")}</div>`}catch{}return/<(?:html|div|table|p)\b/i.test(g)?wi(g):`<div class="cs-email-text">${g.replace(/</g,"<").replace(/>/g,">")}</div>`}const v=h.split(/\r?\n/).filter(g=>!g.match(/^\* \d+ FETCH/)&&!g.match(/^T\d+ /)&&!g.match(/^BODY(?:\.PEEK)?\[/)&&!g.match(/^\s*\)\s*$/)&&g.trim()).join(` 103`).trim();return v?`<div class="cs-email-text">${v.replace(/</g,"<").replace(/>/g,">")}</div>`:""}function Ia({rawBody:t,attCtx:r}){const a=l.useRef(null),[n,h]=l.useState(200),[p,k]=l.useState({}),f=l.useMemo(()=>{try{const g=Ko(t);if(g&&g.trim())return g}catch{}const v=String(t||"").replace(/^\*\s+\d+\s+FETCH[\s\S]*?\r?\n/i,"").replace(/BODY(?:\.PEEK)?\[[^\]]*\]\s*\{\d+\}\r?\n/gi,"").replace(/\)\r?\n[A-Z]\d+ OK[\s\S]*$/i,"").replace(/</g,"<").replace(/>/g,">").trim();return v&&v!=="(leer)"&&v!=="Fehler beim Laden."?`<div class="cs-email-text">${v}</div>`:"<p style='color:#616E68;padding:16px;font-size:12.5px'>Diese E-Mail enthält keinen darstellbaren Text.</p>"},[t]);l.useEffect(()=>{let v=!1;k({});const g=((r==null?void 0:r.atts)||[]).filter(x=>x&&x.inline&&x.cid);if(!(!g.length||!/cid:/i.test(f)))return(async()=>{const x={};for(const N of g)try{const ee=await qs({user:r.user,folder:r.folder||"INBOX",uid:r.uid,part:N.path||"1",encoding:N.encoding||"",contentType:N.contentType||"image/png",name:N.name||"bild",disp:"inline"});ee&&(x[String(N.cid)]=ee)}catch{}!v&&Object.keys(x).length&&k(x)})(),()=>{v=!0}},[f,r==null?void 0:r.uid,r==null?void 0:r.user,((r==null?void 0:r.atts)||[]).length]);const C=l.useMemo(()=>{let v=f;for(const[g,x]of Object.entries(p)){const N=g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");
103v=v.replace(new RegExp(`(src\\s*=\\s*["']?)cid:${N}`,"gi"),`$1${x}`)}return v},[f,p]),m=l.useMemo(()=>`<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style>${["body{margin:0;padding:16px;font-family:-apple-system,system-ui,Segoe UI,sans-serif;font-size:14px;color:#46574F;line-height:1.65;background:#FFFFFF;overflow-x:hidden;word-wrap:break-word;word-break:break-word}","img{max-width:100%!important;height:auto!important}","table{max-width:100%!important;border-collapse:collapse}","td,th{word-break:break-word}","a{color:#0F7A57}","*{box-sizing:border-box}","pre,code{white-space:pre-wrap;word-break:break-word}",".cs-email-text{white-space:pre-wrap;font-family:inherit;font-size:14px;line-height:1.65}"].join("")}</style></head><body>${C}</body></html>`,[C]);return l.useEffect(()=>{const v=a.current;if(!v)return;const g=()=>{try{const N=v.contentDocument;if(N!=null&&N.body){const ee=Math.max(N.documentElement.scrollHeight,N.body.scrollHeight);h(Math.max(ee+32,80))}}catch{}};v.onload=g;const x=[150,500,1500,3e3].map(N=>setTimeout(g,N));return()=>x.forEach(clearTimeout)},[m]),e.jsx("iframe",{ref:a,srcDoc:m,sandbox:"allow-same-origin",style:{width:"100%",height:n,border:"none",background:"var(--panel)",borderRadius:6,display:"block"},title:"E-Mail Vorschau"})}function Ho({senderEmail:t,senderName:r,onClose:a,onCreate:n}){const h=t.split("@")[1]||"",p=h.replace(/\.(de|com|net|org|io|co|eu|at|ch)$/i,"").replace(/\./g," "),k=p?p.charAt(0).toUpperCase()+p.slice(1):"",f=h?`https://${h}`:"",[C,m]=l.useState(k),[v,g]=l.useState(r.replace(/<[^>]+>/g,"").trim()),[x,N]=l.useState(t),[ee,le]=l.useState(f),[Z,I]=l.useState(""),[B,j]=l.useState(""),[P,ve]=l.useState(!1),[$,_]=l.useState(null),[ue,be]=l.useState(!1),ie=Hs(Z),H=!Z.trim()||Hr(Z);l.useEffect(()=>{h&&(be(!0),fetch(`https://api.microlink.io/?url=https://${h}`).then(F=>F.json()).then(F=>{if(F.status==="success"&&F.data){const K=F.data.title||"",A=F.data.description||"";K&&!C&&m(K),A&&_(A),F.data.url&&le(F.data.url)}}).catch(()=>{}).finally(()=>be(!1)))},[]);const U=async()=>{var F;if(C.trim()){if(Z.trim()&&!Hr(Z)){alert("Telefonnummer ist ungültig. Erwartet z. B. 0176⦠oder +49176â¦");return}ve(!0);try{const K={[i.displayName]:C.trim()};v.trim()&&(K[i.contactName]=v.trim()),x.trim()&&(K[i.contactEmail]=x.trim()),ee.trim()&&(K[i.url]=ee.trim()),Z.trim()&&(K[i.telefon]=Hs(Z)),B.trim()&&(K[i.description]=B.trim());const A=await Gn(tt,K),ce=((F=A==null?void 0:A.data)==null?void 0:F.id)||(A==null?void 0:A.id);ce&&n(ce),a()}catch(K){alert("Fehler: "+K.message)}finally{ve(!1)}}};return e.jsx("div",{className:"cs-modal-overlay",onClick:a,children:e.jsxs("div",{className:"cs-modal",style:{maxWidth:520},onClick:F=>F.stopPropagation(),children:[e.jsxs("div",{className:"cs-modal-header",children:[e.jsx("div",{className:"cs-modal-title",children:"Neuen Lead anlegen"}),e.jsx("button",{className:"cs-modal-close",onClick:a,children:"â"})]}),e.jsxs("div",{className:"cs-modal-body",style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:12,background:"var(--panel-2)",borderRadius:10,border:"1px solid var(--line)"},children:[h&&e.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${h}&sz=32`,alt:"",loading:"lazy",decoding:"async",style:{width:32,height:32,borderRadius:6,border:"1px solid var(--line)"},onError:F=>{F.target.style.display="none"}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:t}),e.jsxs("div",{style:{...ye},children:[h,ue?" · Lade Infos...":$?` · ${$.substring(0,60)}...`:""]})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Firmenname *"}),e.jsx("input",{className:"cs-input",value:C,onChange:F=>m(F.target.value),placeholder:"z.B. RAVENOL GmbH",autoFocus:!0})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Kontaktperson"}
103),e.jsx("input",{className:"cs-input",value:v,onChange:F=>g(F.target.value),placeholder:"Vor- und Nachname"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Telefon"}),e.jsx("input",{className:"cs-input",value:Z,onChange:F=>I(F.target.value),onBlur:()=>Z&&I(Hs(Z)),placeholder:"0176⦠oder +49â¦",style:H?void 0:{borderColor:"var(--red)"}}),Z.trim()&&e.jsx("div",{style:{fontSize:11,color:H?"var(--ink-3)":"var(--red)",marginTop:4},children:H?`â speichert als ${ie}`:"Ungültiges Format"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"E-Mail"}),e.jsx("input",{className:"cs-input",value:x,onChange:F=>N(F.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Webseite"}),e.jsx("input",{className:"cs-input",value:ee,onChange:F=>le(F.target.value)})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Beschreibung"}),e.jsx("textarea",{className:"cs-textarea",rows:2,value:B,onChange:F=>j(F.target.value),placeholder:"Branche, Notizen..."})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:[e.jsx("button",{className:"cs-btn-outline",onClick:a,children:"Abbrechen"}),e.jsx("button",{className:"cs-btn-primary",onClick:U,disabled:P||!C.trim()||!H,children:P?"Wird erstellt...":"Lead anlegen"})]})]})]})})}function Ns(t){if(!t)return null;try{let r=t.replace(/^https?:\/\//,"").replace(/\/.*$/,"").replace(/^www\./,"");return!r||r.length<3?null:`https://www.google.com/s2/favicons?domain=${r}&sz=32`}catch{return null}}const wt=[{key:"dima",name:"Dima Liberda",email:"[email protected]",initials:"DL",color:"#2d5a27",avatar:"",recordId:""},{key:"luca",name:"Luca Freiberger",email:"[email protected]",initials:"LF",color:"#1e40af",avatar:"",recordId:""},{key:"laura",name:"Laura Banys",email:"[email protected]",initials:"LB",color:"#7c3aed",avatar:"",recordId:""},{key:"mario",name:"Mario Westerwelle",email:"[email protected]",initials:"MW",color:"#b45309",avatar:"",recordId:""}],Ri="x91ODsiBx3bzdH",Vo="cof0b",Fi="WM2dx",dl="9bNGB";function Jo(){const t=sl();return l.useMemo(()=>{if(!t||!t.email)return null;const r=String(t.email).toLowerCase(),a=r.split("@")[0],n=wt.find(h=>r===h.email.toLowerCase()||a===h.key);return{name:t.fullName||r,email:r,avatar:t.avatarUrl||"",key:n?n.key:"",verified:t.ungeprueft!==!0,role:t.role||""}},[t])}let qr=!1;async function Va(){if(!qr){qr=!0;try{let t=[],r=0;const a=100;for(;;){const h=(await Zt(Ri,a,r)).data||[];if(t=t.concat(h),h.length<a||(r+=a,r>2e3))break}t.forEach(n=>{var m,v,g,x,N,ee,le,Z,I;const h=(((m=n.fields)==null?void 0:m[Fi])||((v=n.fields)==null?void 0:v.Email)||"").toLowerCase(),p=(((g=n.fields)==null?void 0:g.Name)||((x=n.fields)==null?void 0:x.softr_user_full_name)||((N=n.fields)==null?void 0:N["5OGPi"])||"").toLowerCase(),k=wt.find(B=>h&&h.includes(B.key)||p&&p.includes(B.key)||h&&B.email&&h===B.email.toLowerCase());if(!k)return;!k.recordId&&n.id&&(k.recordId=n.id);const f=((ee=n.fields)==null?void 0:ee[dl])||((le=n.fields)==null?void 0:le.Avatar)||((Z=n.fields)==null?void 0:Z.softr_user_default_avatar),C=typeof f=="string"?f:(f==null?void 0:f.url)||(Array.isArray(f)?(I=f[0])==null?void 0:I.url:null)||"";C&&!k.avatar&&(k.avatar=ll(C))}),console.log("[CRM] Avatars loaded:",wt.map(n=>`${n.key}: ${n.avatar?"â":"â"}`).join(", "))}catch(t){console.error("Failed to load avatars:",t)}}}const Ss=new Map,wa=new Map,Sa=new Map,pl=new Set(["gmail.com","googlemail.com","web.de","gmx.de","gmx.net","gmx.at","gmx.ch","t-online.de","hotmail.com","hotmail.de","outlook.com","outlook.de","live.de","live.com","yahoo.com","yahoo.de","icloud.com","me.com","mac.com","aol.com","freenet.de","mail.de","posteo.de","protonmail.com","proton.me","arcor.de","1und1.de","online.de"]);function Go(t){if(!t)return"";if(Array.isArray(t)){const r=t[0];return String((r==null?void 0:r.label)||(r==null?void 0:r.title)||r||"").trim()}return typeof t=="object"?String(t.label||t.title||t.name||"").trim():String(t).trim()}function qo(t){return String(t||"").toLowerCase().replace(/\b(gmbh|mbh|ag|kg|ohg|ug|e\.?k\.?|se|gbr|co|kgaa|ltd|inc|llc)\b/g,"").replace(/[^a-z0-9äöüÃ]+/g,"").trim()}function _i(t){const r=String(t||"").toLowerCase().trim(),a=r.lastIndexOf("@");return a>0?r.slice(a+1).replace(/^www\./,""):""}function Zo(t){return String(t||"").trim().replace(/^https?:\/\//i,"").replace(/\/.*$/,"").replace(/^www\./,"").toLowerCase()}let Si=null;async function hl(){return Ss.size>0?Ss:Si||(Si=(async()=>{try{let r=0,a=!0;for(;a;){const h=(await Zt(Ri,100,r)).data||[];h.forEach(p=>{var x,N,ee,le,Z,I,B,j;const k=(((x=p.fields)==null?void 0:x[Fi])||((N=p.fields)==null?void 0:N.Email)||"").toLowerCase().trim();if(!k)return;const f=((ee=p.fields)==null?void 0:ee[dl])||((le=p.fields)==null?void 0:le.Avatar)||((Z=p.fields)==null?void 0:Z.softr_user_default_avatar),C=typeof f=="string"?f:(f==null?void 0:f.url)||(Array.isArray(f)?(I=f[0])==null?void 0:I.url:null)||"";if(!C)return;const m=Ka(C);Ss.set(k,m);const v=_i(k);v&&v!=="liberdamedia.de"&&!pl.has(v)&&!wa.has(v)&&wa.set(v,m);const g=qo(Go(((B=p.fields)==null?void 0:B.OMBQo)||((j=p.fields)==null?void 0:j.Unternehmen)));g&&!Sa.has(g)&&Sa.set(g,m)}),a=h.length===100,r+=100}console.log("[CRM] Dashboard-Avatare geladen:",Ss.size,"· Firmen:",Sa.size,"· Domains:",wa.size)}catch(t){console.error("Failed to load dashboard avatars:",t)}return Ss}
103)(),Si)}let $s=null,gn=null,Na=!1;const Ta=new Set;function Ja(t,r){if(Ta.add(t),r!=null&&r.immediate&&gn)try{t(gn)}catch{}return()=>{Ta.delete(t)}}function La(){if(gn)for(const t of Ta)try{t(gn)}catch{}}function Ba(t){var n,h,p,k;const r=new Map,a=new Map;for(const f of t){const C=((n=f.fields)==null?void 0:n.uH2Ib)||((h=f.fields)==null?void 0:h.Q6zIb)||"",m=(((p=f.fields)==null?void 0:p["4Fk6j"])||((k=f.fields)==null?void 0:k.GQdSH)||"").trim().toLowerCase();C&&(r.has(C)||r.set(C,[]),r.get(C).push(f)),m&&(a.has(m)||a.set(m,[]),a.get(m).push(f))}return{byLeadId:r,byCompany:a}}async function gl(){const t=[],n=async k=>{for(let f=0;f<4;f++){try{const C=await Zt(ws,200,k);if(C&&Array.isArray(C.data)&&!C.error)return C.data}catch{}await new Promise(C=>setTimeout(C,400*(f+1)))}return null};let h=0;const p=8e4;for(;h<p;){const k=Array.from({length:5},(m,v)=>h+v*200),f=await Promise.all(k.map(n));let C=!1;for(let m=0;m<f.length;m++){let v=f[m];v===null&&(v=await n(k[m])||[]),v.length&&(C=!0);for(const g of v)t.push(g)}if(!C)break;h+=5*200}return t}async function Uo(){if(!Na){Na=!0;try{const t=await gl();gn=Ba(t),Ki(Mi,{records:t,ts:Date.now()}),La()}catch(t){console.error("[CRM] Kontakte-Hintergrund-Refresh fehlgeschlagen:",t)}finally{Na=!1}}}async function Hi(){return gn||$s||($s=(async()=>{var r;try{const a=await $i(Mi);if((r=a==null?void 0:a.records)!=null&&r.length)return gn=Ba(a.records),La(),Uo(),gn}catch{}const t=await gl();return gn=Ba(t),Ki(Mi,{records:t,ts:Date.now()}),La(),console.log(`[CRM] Kontakte-Index: ${gn.byLeadId.size} Leads (by ID), ${gn.byCompany.size} Firmen, ${t.length} Kontakte`),gn})(),$s)}async function Zr(){gn=null,$s=null;try{await Wo(Mi)}catch{}}function It({userKey:t,size:r=24,className:a=""}){const n=wt.find(h=>h.key===t);return n?n.avatar?e.jsx("img",{src:n.avatar,alt:n.name,className:`cs-avatar-img ${a}`,style:{width:r,height:r}}):e.jsx("span",{className:`cs-avatar-mini ${a}`,style:{width:r,height:r,background:n.color},children:n.initials}):e.jsx("span",{className:`cs-avatar-mini ${a}`,style:{width:r,height:r,background:"var(--ink-3)"},children:"?"})}function js(t){const r=(t||"").toLowerCase().trim();return r&&wt.find(a=>r===a.name.toLowerCase()||r.includes(a.key)||r.includes(a.name.toLowerCase())||r.includes(a.name.toLowerCase().split(" ")[0])||r.replace(/\s+/g,"")===a.initials.toLowerCase())||null}function _n(t){const r=String(t||"").trim();if(!r)return"";const a=r.toLowerCase(),n=wt.find(h=>h.key===a||h.name.toLowerCase()===a||h.name.toLowerCase().split(" ")[0]===a||h.email.toLowerCase()===a);return n?n.name:r}function Ni({on:t,size:r=13}){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",style:{width:r,height:r},children:[e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),e.jsx("path",{d:"M9 10.8a2 2 0 01-1.1 1.8l-1.8.9A2 2 0 005 15.3v.7a1 1 0 001 1h12a1 1 0 001-1v-.7a2 2 0 00-1.1-1.8l-1.8-.9a2 2 0 01-1.1-1.8V7a1 1 0 011-1 2 2 0 000-4H8a2 2 0 000 4 1 1 0 011 1z"})]})}function Yo(t){let r=0;for(let a=0;a<(t||"").length;a++)r=(t.charCodeAt(a)||0)+((r<<5)-r);return`hsl(${Math.abs(r)%360},42%,52%)`}function Ii({name:t,size:r=22,fontSize:a}){const n=String(t||"").trim().split(/\s+/).map(h=>h[0]).slice(0,2).join("")||"?";return e.jsx("span",{title:t,style:{width:r,height:r,borderRadius:"50%",background:Yo(t),color:"#fff",fontSize:a??Math.max(8,Math.round(r*.4)),fontWeight:700,display:"inline-flex",alignItems:"center",justifyContent:"center",textTransform:"uppercase",flexShrink:0},children:n})}function Xo(t){function r(De,je){return De<<je|De>>>32-je}function a(De,je){let nt,qe,lt,gt,Nt;return lt=De&2147483648,gt=je&2147483648,nt=De&1073741824,qe=je&1073741824,Nt=(De&1073741823)+(je&1073741823),nt&qe?Nt^2147483648^lt^gt:nt|qe?Nt&1073741824?Nt^3221225472^lt^gt:Nt^1073741824^lt^gt:Nt^lt^gt}function n(De,je,nt){return De&je|~De&nt}function h(De,je,nt){return De&nt|je&~nt}function p(De,je,nt){return De^je^nt}function k(De,je,nt){return je^(De|~nt)}function f(De,je,nt,qe,lt,gt,Nt){return De=a(De,a(a(n(je,nt,qe),lt),Nt)),a(r(De,gt),je)}function C(De,je,nt,qe,lt,gt,Nt){return De=a(De,a(a(h(je,nt,qe),lt),Nt)),a(r(De,gt),je)}function m(De,je,nt,qe,lt,gt,Nt){return De=a(De,a(a(p(je,nt,qe),lt),Nt)),a(r(De,gt),je)}function v(De,je,nt,qe,lt,gt,Nt){return De=a(De,a(a(k(je,nt,qe),lt),Nt)),a(r(De,gt),je)}function g(De){let je,nt="",qe="",lt;for(lt=0;lt<=3;lt++)je=De>>>lt*8&255,qe="0"+je.toString(16),nt=nt+qe.substr(qe.length-2,2);return nt}const x=[];let N,ee,le,Z,I,B,j,P;const ve=7,$=12,_=17,ue=22,be=5,ie=9,H=14,U=20,F=4,K=11,A=23,ce=6,Ve=10,Xe=15,it=21,Le=new TextEncoder().encode(t),Ue=Le.length,ct=Ue*8,yt=new Uint8Array((Ue+72>>>6)*64);yt.set(Le),yt[Ue]=128;const rt=new DataView(yt.buffer);rt.setUint32(yt.length-8,ct&4294967295,!0),rt.setUint32(yt.length-4,Math.floor(ct/4294967296),!0);for(let De=0;De<yt.length;De+=4)x.push(rt.getUint32(De,!0));for(I=1732584193,B=4023233417,j=2562383102,P=271733878,N=0;N<x.length;N+=16){ee=I,le=B,Z=j;const De=P;I=f(I,B,j,P,x[N],ve,3614090360),P=f(P,I,B,j,x[N+1],$,3905402710),j=f(j,P,I,B,x[N+2],_,606105819),B=f(B,j,P,I,x[N+3],ue,3250441966),I=f(I,B,j,P,x[N+4],ve,4118548399),P=f(P,I,B,j,x[N+5],$,1200080426),j=f(j,P,I,B,x[N+6],_,2821735955),B=f(B,j,P,I,x[N+7],ue,4249261313),I=f(I,B,j,P,x[N+8],ve,1770035416),P=f(P,I,B,j,x[N+9],$,2336552879),j=f(j,P,I,B,x[N+10],_,4294925233),B=f(B,j,P,I,x[N+11],ue,2304563134),I=f(I,B,j,P,x[N+12],ve,1804603682),P=f(P,I,B,j,x[N+13],$,4254626195),j=f(j,P,I,B,x[N+14],_,2792965006),B=f(B,j,P,I,x[N+15],ue,1236535329),I=C(I,B,j,P,x[N+1],be,4129170786),P=C(P,I,B,j,x[N+6],ie,3225465664),j=C(j,P,I,B,x[N+11],H,643717713),B=C(B,j,P,I,x[N],U,3921069994),I=C(I,B,j,P,x[N+5],be,3593408605),P=C(P,I,B,j,x[N+10],ie,38016083),j=C(j,P,I,B,x[N+15],H,3634488961),B=C(B,j,P,I,x[N+4],U,3889429448),I=C(I,B,j,P,x[N+9],be,568446438),P=C(P,I,B,j,x[N+14],ie,3275163606),j=C(j,P,I,B,x[N+3],H,4107603335),B=C(B,j,P,I,x[N+8],U,1163531501),I=C(I,B,j,P,x[N+13],be,2850285829),P=C(P,I,B,j,x[N+2],ie,4243563512),j=C(j,P,I,B,x[N+7],H,1735328473),B=C(B,j,P,I,x[N+12],U,2368359562),I=m(I,B,j,P,x[N+5],F,4294588738),P=m(P,I,B,j,x[N+8],K,2272392833),j=m(j,P,I,B,x[N+11],16,1839030562),B=m(B,j,P,I,x[N+14],A,4259657740),I=m(I,B,j,P,x[N+1],F,2763975236),P=m(P,I,B,j,x[N+4],K,1272893353),j=m(j,P,I,B,x[N+7],16,4139469664),B=m(B,j,P,I,x[N+10],A,3200236656),I=m(I,B,j,P,x[N+13],F,
103681279174),P=m(P,I,B,j,x[N+0],K,3936430074),j=m(j,P,I,B,x[N+3],16,3572445317),B=m(B,j,P,I,x[N+6],A,76029189),I=m(I,B,j,P,x[N+9],F,3654602809),P=m(P,I,B,j,x[N+12],K,3873151461),j=m(j,P,I,B,x[N+15],16,530742520),B=m(B,j,P,I,x[N+2],A,3299628645),I=v(I,B,j,P,x[N],ce,4096336452),P=v(P,I,B,j,x[N+7],Ve,1126891415),j=v(j,P,I,B,x[N+14],Xe,2878612391),B=v(B,j,P,I,x[N+5],it,4237533241),I=v(I,B,j,P,x[N+12],ce,1700485571),P=v(P,I,B,j,x[N+3],Ve,2399980690),j=v(j,P,I,B,x[N+14-12],Xe,4293915773),B=v(B,j,P,I,x[N+1],it,2240044497),I=v(I,B,j,P,x[N+8],ce,1873313359),P=v(P,I,B,j,x[N+15],Ve,4264355552),j=v(j,P,I,B,x[N+6],Xe,2734768916),B=v(B,j,P,I,x[N+13],it,1309151649),I=v(I,B,j,P,x[N+4],ce,4149444226),P=v(P,I,B,j,x[N+11],Ve,3174756917),j=v(j,P,I,B,x[N+2],Xe,718787259),B=v(B,j,P,I,x[N+9],it,3951481745),I=a(I,ee),B=a(B,le),j=a(j,Z),P=a(P,De)}return g(I)+g(B)+g(j)+g(P)}const Ps=new Map,ul="https://media.istockphoto.com/id/1451587807/vector/user-profile-icon-vector-avatar-or-person-icon-profile-picture-portrait-symbol-vector.jpg?s=612x612&w=0&k=20&c=yDJ4ITX1cHMh25Lt1vI1zBn2cAKKAlByHBvPJ8gEiIg=";function Ga({email:t,name:r,size:a=26,className:n="",dashboardOnly:h=!1,placeholder:p}){const[k,f]=l.useState(null),[C,m]=l.useState(0),[v,g]=l.useState(!1),x=((r||t||"?")[0]||"?").toUpperCase(),N=t?t.split("@")[1]:"",ee=t||r||"?",le=["#0F7A57","#5B21B6","#A61E4D","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],Z=(r||t||"").split("").reduce((P,ve)=>P+ve.charCodeAt(0),0)%le.length,I=le[Z];l.useEffect(()=>{let P=!1;g(!1);const ve=(t||"").toLowerCase().trim(),$=()=>{const _=ve?Ss.get(ve):null;return _?(f(_),m(0),!0):!1};if(!$()){if(ve&&hl().then(()=>{P||$()}),h)return f(null),m(99),()=>{P=!0};if(Ps.has(ee))return f(Ps.get(ee)||null),m(Ps.get(ee)?0:99),()=>{P=!0};if(t){const _=Xo(t.trim().toLowerCase());f(`https://www.gravatar.com/avatar/${_}?s=${a*2}&d=404`),m(0)}else N?(f(`https://logo.clearbit.com/${N}`),m(2)):m(99);return()=>{P=!0}}},[ee]);const B=()=>{if(h){f(null),m(99);return}C===0&&t?(f(`https://person.clearbit.com/v1/people/email/${encodeURIComponent(t)}/avatar`),m(1)):C<=1&&N?(f(`https://logo.clearbit.com/${N}`),m(2)):C<=2&&N?(f(`https://www.google.com/s2/favicons?domain=${N}&sz=64`),m(3)):(Ps.set(ee,null),f(null),m(99))},j=()=>{k&&Ps.set(ee,k)};return!k||C>=99?p&&!v?e.jsx("img",{src:p,alt:r||t||"",onError:()=>g(!0),style:{width:a,height:a,borderRadius:"50%",objectFit:"cover",flexShrink:0,background:"var(--bg-2)"},className:n}):e.jsx("span",{className:`cs-avatar-mini ${n}`,style:{width:a,height:a,borderRadius:"50%",background:I,color:"#fff",fontSize:Math.max(9,a*.4),fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,letterSpacing:"-0.02em"},children:x}):e.jsxs("div",{style:{width:a,height:a,borderRadius:"50%",overflow:"hidden",flexShrink:0,position:"relative"},className:n,children:[e.jsx("img",{src:k,alt:r||t||"",style:{width:a,height:a,borderRadius:"50%",objectFit:"cover"},onError:B,onLoad:j}),e.jsx("span",{style:{width:a,height:a,borderRadius:"50%",background:I,color:"#fff",fontSize:Math.max(9,a*.4),fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",inset:0,zIndex:-1},children:x})]})}function En({contactId:t,name:r,email:a,company:n,leadUrl:h,storedAvatar:p,size:k=24,radius:f="50%"}){const C=p||"",[m,v]=l.useState(null),[g,x]=l.useState(!1),[N,ee]=l.useState(null),[le,Z]=l.useState(!1),I=a&&a.includes("@")?a.split("@")[1]:(h||"").replace(/^https?:\/\//,"").replace(/\/.*$/,"").replace(/^www\./,""),B=async ve=>{if(ve.stopPropagation(),!g){if(!r&&!a){ee("kein Name");return}x(!0),ee(null);try{const $=new URLSearchParams;r&&$.set("name",r),n&&$.set("company",n),I&&$.set("domain",I);const _=await Ge(`/api/apify/contact-linkedin-avatar?${$.toString()}`);_&&_.found&&_.url?(v(_.url),ee(null)):ee((_==null?void 0:_.reason)||"kein Treffer")}catch{ee("Fehler")}x(!1)}},j=!!I&&!le,P=m||(j?"":C);return e.jsxs("span",{style:{position:"relative",display:"inline-flex",flexShrink:0,cursor:"pointer"},onClick:B,title:m?"LinkedIn-Foto · Klick: neu holen":"Klick: LinkedIn-Foto holen",children:[P?e.jsx("img",{src:P,alt:r||"",style:{width:k,height:k,borderRadius:f,objectFit:"cover",display:"block"},onError:()=>v(null)}):j?e.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${I}&sz=128`,alt:r||"",loading:"lazy",decoding:"async",style:{width:k,height:k,borderRadius:f,objectFit:"cover",display:"block",background:"var(--panel)"},onError:()=>Z(!0)}):e.jsx(Ga,{email:a,name:r,size:k,dashboardOnly:!0,placeholder:ul}),g&&e.jsx("span",{style:{position:"absolute",inset:0,borderRadius:f,background:"rgba(0,0,0,.45)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{style:{width:k*.45,height:k*.45,border:"2px s
103olid rgba(255,255,255,.4)",borderTopColor:"#fff",borderRadius:"50%",animation:"lm-spin .7s linear infinite"}})}),N&&e.jsx("span",{style:{position:"absolute",top:k+2,left:"50%",transform:"translateX(-50%)",whiteSpace:"nowrap",fontSize:8,color:"var(--red)",background:"var(--panel)",padding:"1px 4px",borderRadius:4,boxShadow:"var(--shadow-pop)",zIndex:5},children:N})]})}function qa(t,r){var a;return((a=t==null?void 0:t.fields)==null?void 0:a[r])??null}function o(t,r){const a=qa(t,r);return a?typeof a=="string"?a:typeof a=="number"?String(a):a!=null&&a.label?a.label:String(a):""}function ut(t,r){const a=qa(t,r);return a?a!=null&&a.label?a.label:Array.isArray(a)?a.map(n=>(n==null?void 0:n.label)||n).join(", "):String(a):""}const ml=[{label:"NEUER LEAD",emoji:"ð§",color:"var(--ink-3)"},{label:"ð¡ Bisher kein Kontakt",emoji:"ð¡",color:"#eab308"},{label:"ð¥ Potenzial",emoji:"ð¥",color:"#ef4444"},{label:"â³ In Arbeit",emoji:"â³",color:"#3b82f6"},{label:"ð¤ Individuell kontaktieren",emoji:"ð¤",color:"#5B21B6"},{label:"ð¸ kostenlose Probefahrt",emoji:"ð¸",color:"#10b981"},{label:"ð¨ 50$ Client",emoji:"ð¨",color:"#f97316"},{label:"ð¤ Videokartenkunde",emoji:"ð¤",color:"#A61E4D"},{label:"â
Neukunde",emoji:"â
",color:"#22c55e"},{label:"â¤ï¸ Bestandskunde",emoji:"â¤ï¸",color:"#ec4899"},{label:"â¤ï¸âð¥ Tier 1 Kunde",emoji:"â¤ï¸âð¥",color:"#ec4899"},{label:"ð GOLDKUNDE",emoji:"ð",color:"#f59e0b"},{label:"WATCHLIST ð¤£ð¿",emoji:"ð¤£",color:"#a855f7"},{label:"â° pausiert",emoji:"â°",color:"var(--ink-3)"},{label:"Keine Bulk Mail senden ð§",emoji:"ð§",color:"var(--ink-3)"},{label:"â nicht abgeschlossen",emoji:"â",color:"#991b1b"},{label:"â«ï¸ Blacklist",emoji:"â«",color:"#1f2937"},{label:"(Sonstiges)",emoji:"â¢",color:"#4b5563"}],Da={};ml.forEach(t=>{Da[t.label]=t.color;const r=t.label.replace(/[^\w\sÃÃÃäöüÃ.$()-]/g,"").trim();r&&r!==t.label&&(Da[r]=t.color)});function $n(t){for(const[r,a]of Object.entries(Da))if(t.includes(r))return a;return"#4b5563"}function Za(t){return t.replace(/[^\w\sÃÃÃäöüÃ.-]/g,"").trim()}function St(t){if(!t)return"";try{const r=new Date(t),a=new Date;return r.toDateString()===a.toDateString()?r.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):a.getTime()-r.getTime()<7*864e5?r.toLocaleDateString("de-DE",{weekday:"short"}):r.toLocaleDateString("de-DE",{day:"numeric",month:"short",year:r.getFullYear()!==a.getFullYear()?"numeric":void 0})}catch{return t.slice(0,10)}}let Vs="",Wa=!1,Ma=0;function Ra(){try{return new Map(JSON.parse(localStorage.getItem("lm_followup_dates")||"[]"))}catch{return new Map}}let As=new Map;function Ua(){return new Map(As)}async function fl(t){const r=++Ma;if(Vs!==t&&(As=Ra()),Vs=t,Wa=t.trim().toLowerCase()==="[email protected]",!Wa)return Ua();const a=await fetch(ln+"/api/crm/followups/dates",{headers:zs()}),n=await a.json();if(!a.ok||n.ok!==!0||!Array.isArray(n.dates))throw new Error(n.error||"Wiedervorlagen konnten nicht geladen werden.");const h=new Map(n.dates.filter(k=>k.enabled===1&&/^\d{4}-\d{2}-\d{2}$/.test(k.due_date)).map(k=>[k.lead_id,k.due_date])),p=Ra();for(const k of n.dates)k.enabled===1&&h.has(k.lead_id)?p.set(k.lead_id,h.get(k.lead_id)):p.delete(k.lead_id);return Vs===t&&r===Ma&&(As=p),p}async function Fa(t,r,a=""){const n=Vs;if(!Wa){const k=Ra();return r?k.set(t,r):k.delete(t),localStorage.setItem("lm_followup_dates",JSON.stringify([...k])),As=k,{ok:!0,legacy:!0}}const h=await fetch(ln+"/api/crm/followups/dates",{method:"POST",headers:zs(),body:JSON.stringify({leadId:t,date:r,note:a})}),p=await h.json();if(!h.ok||p.ok!==!0)throw new Error(p.error||"Wiedervorlage konnte nicht gespeichert werden.");return n===Vs&&(++Ma,r?As.set(t,r):As.delete(t),window.dispatchEvent(new Event("crm-followups-changed"))),p}function is(t){if(!t)return null;const r=new Date(t);if(!Number.isFinite(r.getTime()))return null;const a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),n=new Date,h=new Date(n.getFullYear(),n.getMonth(),n.getDate());return Math.round((h.getTime()-a.getTime())/864e5)}function xl(t){return t===null?"":t<0?"in "+Math.abs(t)+" T":t===0?"Heute":t===1?"Gestern":`${t}T`}function yl(t){return t===null||t<0?"var(--ink-3)":t<=1?"var(--green)":t<=7?"#7A5B00":t<=14?"#92610A"
103:"var(--red)"}const Qo="https://app.liberdamedia.de/api/lead-scan",bl="lm_scan_results";function Ti(){try{return new Map(JSON.parse(localStorage.getItem(bl)||"[]"))}catch{return new Map}}function Ca(t,r){const a=Ti();a.set(t,r);try{localStorage.setItem(bl,JSON.stringify([...a]))}catch{}}function ec(t){return t==="hoch"?{bg:"var(--green-soft)",color:"var(--green)",border:"var(--green-bd)"}:t==="mittel"?{bg:"#FBF3DA",color:"#7A5B00",border:"#E6D08F"}:{bg:"var(--red-soft)",color:"var(--red)",border:"#E3B7B3"}}function tc(t){return t==="hoch"?{bg:"var(--green-soft)",border:"var(--green-bd)",hdr:"var(--green-soft)"}:t==="mittel"?{bg:"#FDF8E9",border:"#E6D08F",hdr:"#FBF3DA"}:{bg:"var(--red-soft)",border:"#E3B7B3",hdr:"var(--red-soft)"}}function nc(t){return t==="hoch"?{background:"var(--green)",color:"#fff"}:t==="mittel"?{background:"var(--gold-2)",color:"#241C00"}:{background:"var(--red)",color:"#fff"}}const Li=[{title:"KUNDENSTATUS",key:"status",views:[{name:"Bisher kein Kontakt",emoji:"ð¡",filter:{field:"status",match:"Bisher kein Kontakt"}},{name:"Potenzial",emoji:"ð¥",filter:{field:"status",match:"Potenzial"}},{name:"GOLDKUNDE",emoji:"ð",filter:{field:"status",match:"GOLDKUNDE"},desc:"Goldkunden â Umsatz oder Netzwerk"},{name:"Bestandskunde",emoji:"â¤ï¸",filter:{field:"status",match:"Bestandskunde"}},{name:"Tier 1 Kunde",emoji:"â¤ï¸âð¥",filter:{field:"status",match:"Tier 1 Kunde"}},{name:"Neukunde",emoji:"â
",filter:{field:"status",match:"Neukunde"}},{name:"Videokartenkunde",emoji:"ð¤",filter:{field:"status",match:"Videokartenkunde"}},{name:"In Arbeit",emoji:"â³",filter:{field:"status",match:"In Arbeit"}},{name:"Individuell kontaktieren",emoji:"ð¤",filter:{field:"status",match:"Individuell kontaktieren"}}
103,{name:"kostenlose Probefahrt",emoji:"ð¸",filter:{field:"status",match:"kostenlose Probefahrt"}},{name:"50$ Client",emoji:"ð¨",filter:{field:"status",match:"50$ Client"}},{name:"WATCHLIST",emoji:"ð¤£",filter:{field:"status",match:"WATCHLIST"}},{name:"pausiert",emoji:"â°",filter:{field:"status",match:"pausiert"}},{name:"Blacklist",emoji:"â«",filter:{field:"status",match:"Blacklist"}},{name:"nicht abgeschlossen",emoji:"â",filter:{field:"status",match:"nicht abgeschlossen"}},{name:"Eingang",emoji:"ð§",filter:{field:"status",match:"NEUER LEAD"}}]},{title:"WIEDERVORLAGE",key:"followup",views:[{name:"Wiedervorlage heute",emoji:"ð
",filter:{field:"followup-today",match:""},desc:"Leads mit Wiedervorlage für heute oder früher"},{name:"Ãberfällig",emoji:"ð´",filter:{field:"overdue",match:""},desc:"Leads ohne Kontakt seit über 14 Tagen"},{name:"Kein Kontakt 7+ Tage",emoji:"ð",filter:{field:"no-contact-days",match:"",days:7},desc:"Kein Kontakt in den letzten 7 Tagen"},{name:"Kein Kontakt 30+ Tage",emoji:"â ï¸",filter:{field:"no-contact-days",match:"",days:30},desc:"Kein Kontakt in den letzten 30 Tagen"},{name:"Neu (letzte 7 Tage)",emoji:"ð",filter:{field:"status-days",match:"new",days:7},desc:"Leads angelegt in den letzten 7 Tagen"}]},{title:"MESSEN",key:"messen",views:[{name:"Holz-Handwerk 26",emoji:"ðªµ",filter:{field:"messen",match:"Holz-Handwerk 2026"}},{name:"ABF 26",emoji:"ðï¸",filter:{field:"messen",match:"ABF 2026"}},{name:"My Job OWL 26",emoji:"ð¼",filter:{field:"messen",match:"My Job OWL 2026"}},{name:"My Job OWL 25",emoji:"ð¼",filter:{field:"messen",match:"My Job OWL 2025"}},{name:"FORST live 26",emoji:"ð²",filter:{field:"messen",match:"FORST live 2026"}},{name:"Abenteuer & Allrad 26",emoji:"ð",filter:{field:"messen",match:"Abenteuer & Allrad 2026"}},{name:"Abenteuer & Allrad 25",emoji:"ð",filter:{field:"messen",match:"Abenteuer & Allrad 2025"}},{name:"NUFAM 25",emoji:"ð",filter:{field:"messen",match:"NUFAM 2025"}},{name:"DLG Waldtage 25",emoji:"ð³",filter:{field:"messen",match:"DLG Waldtage 2025"}},{name:"Messe München 25",emoji:"ðï¸",filter:{field:"messen",match:"Messe München 2025"}},{name:"Eurobike 25",emoji:"ð´",filter:{field:"messen",match:"Eurobike 2024"}},{name:"Automechanika 24",emoji:"ð§",filter:{field:"messen",match:"Automechanika 2024"}},{name:"NordBau 24",emoji:"ðï¸",filter:{field:"messen",match:"NordBau 2024"}},{name:"GaLaBau 24",emoji:"ð¿",filter:{field:"messen",match:"GaLaBau 2024"}}]}],On=Li.flatMap(t=>t.views);function _a({url:t,name:r,logo:a,size:n=26,radius:h=7,fit:p="cover",border:k}){const f=Ns(t||""),C=Ka(String(a||"").trim()),[m,v]=l.useState(!1),[g,x]=l.useState(!1);l.useEffect(()=>{x(!1)},[C]);const N=((r||"?").trim().charAt(0)||"?").toUpperCase(),ee={width:n,height:n,borderRadius:h,objectFit:p,display:"block",background:"var(--bg-2)",flexShrink:0,border:k};return C&&!g?e.jsx("img",{src:C,alt:"",title:r||"",loading:"lazy",decoding:"async",style:ee,onError:()=>x(!0)}):f&&!m?e.jsx("img",{src:f,alt:"",loading:"lazy",decoding:"async",style:ee,onError:()=>v(!0)}):e.jsx("span",{style:{width:n,height:n,borderRadius:h,background:"var(--green)",color:"#fff",fontSize:Math.round(n*.46),fontWeight:700,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:k},children:N})}function vl(t){const r=String(t||"").match(/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}/i);return r?r[0].toLowerCase():""}function kl(t){const r=String((t==null?void 0:t.fromEmail)||(t==null?void 0:t.from)||"").toLowerCase();return wt.find(a=>r.includes(a.key)||r.includes(a.email))||wt.find(a=>a.key===(t==null?void 0:t._via))||null}function jl(t,r,a){const n=r?[t==null?void 0:t.toEmail,t==null?void 0:t.to,t==null?void 0:t.toName]:[t==null?void 0:t.fromEmail,t==null?void 0:t.from,t==null?void 0:t.fromName];for(const h of n){const p=vl(h);if(p&&a.kontaktByEmail.has(p))return a.kontaktByEmail.get(p)}return null}function Ks(t,r,a,n=!1){var f,C,m;if(r&&!n)return((f=kl(t))==null?void 0:f.name)||"LIBERDA Media";const h=r&&n,p=String(h?(t==null?void 0:t.toName)||(t==null?void 0:t.toEmail)||(t==null?void 0:t.to)||"?":(t==null?void 0:t.fromName)||(t==null?void 0:t.fromEmail)||(t==null?void 0:t.from)||"?"),k=jl(t,h,a);return k?String(((C=k.fields)==null?void 0:C["707oq"])||((m=k.fields)==null?void 0:m["5OGPi"])||p):p}function sc({em:t,isOut:r,size:a=22,ctx:n,gegenseite:h=!1}){var le,Z,I,B,j;const p=r&&h,k=r&&!h,f=k?null:jl(t,p,n),C=k?"":vl(p?(t==null?void 0:t.toEmail)||(t==null?void 0:t.to):(t==null?void 0:t.fromEmail)||(t==null?void 0:t.from)),m=_i(C),g=!!m&&!f&&n.leadDomains.has(m)&&m?Ns("https://"+m):"",[x,N]=l.useState(!1);l.useEffect(()=>{N(!1)},[g]);const ee=Ks(t,r,n,h);return k?e.jsx(It,{userKey:((le=kl(t))==null?void 0:le.key)||(t==null?void 0:t._via)||"dima",size:a}):f?e.jsx(En,{contactId:f.id,name:ee,email:((Z=f.fields)==null?void 0:Z.CIy6k)||((I=f.fields)==null?void 0:I.z0xSB),company:(B=f.fields)==null?void 0:B["4Fk6j"],leadUrl:n.leadUrl,storedAvatar:(j=f.fields)==null?void 0:j.Hb2om,size:a}):g&&!x?e.jsx("img",{src:g,alt:ee,title:ee,loading:"lazy",decoding:"async",onError:()=>N(!0),style:{width:a,height:a,borderRadius:"50%",objectFit:"cover",display:"block",flexShrink:0,background:"var(--bg-2)"}}):e.jsx(Ii,{name:String(ee||C||"?"),size:a,fontSize:Math.max(8,Math.round(a*.4))})}const wl=8,Sl=t=>`crm:zuletzt:${t||"dima"}`;function Nl(t){try{const r=JSON.parse(localStorage.getItem(Sl(t))||"[]");return Array.isArray(r)?r.filter(a=>a&&a.id).slice(0,wl):[]}catch{return[]}}function ic(t,r){const a=r==null?void 0:r.id;if(!a)return;const n=(o(r,i.displayName)||o(r,i.leadName)||"").trim();if(!n)return;const h={id:a,name:n,url:o(r,i.url)||"",status:ut(r,i.statusLabel)||"",kontakt:o(r,i.contactName)||o(r,i.contactEmail)||"",ts:Date.now()};try{const p=[h,...Nl(t).filter(k=>k.id!==a)].slice(0,wl);localStorage.setItem(Sl(t),JSON.stringify(p))}catch{}}function ac({leads:t,setLeadId:r,setView:a,currentUser:n}){const[h,p]=l.useState(""),[k,f]=l.useState(!1),C=l.useRef(null),m=l.useRef(null),[v,g]=l.useState({left:72,top:60,width:640}),[x,N]=l.useState([]),[ee,le]=l.useState([]),Z=()=>{const F=C.current;if(!F)return;const K=F.getBoundingClientRect(),A=Math.max(320,window.innerWidth-K.left-16);g({left:K.left,top:K.bottom+6,width:Math.min(640,A)})};l.useEffect(()=>{if(!k)return;Z(),le(Nl(n==null?void 0:n.key));const F=K=>{var A;if(K.key==="Escape"){f(!1);try{(A=m.current)==null||A.blur()}catch{}}};return window.addEventListener("keydown",F),window.addEventListener("resize",Z),window.addEventListener("scroll",Z,!0),()=>{window.removeEventListener("keydown",F),window.removeEventListener("resize",Z),window.removeEventListener("scroll",Z,!0)}},[k,n==null?void 0:n.key]),l.useEffect(()=>{const K=Ja(A=>{var it,ne;const ce=[],Ve=new Set,Xe=Le=>{for(const Ue of Le){const ct=Ue==null?void 0:Ue.id;if(ct){if(Ve.has(ct))continue;Ve.add(ct)}ce.push(Ue)}};try{(it=A==null?void 0:A.byLeadId)==null||it.forEach(Le=>Xe(Le))}catch{}try{(ne=A==null?void 0:A.byCompany)==null||ne.forEach(Le=>Xe(Le))}catch{}N(ce)},{immediate:!0});return Hi(),K},[]);const I=l.useMemo(()=>{const F=new Map;for(const K of t||[]){const A=o(K,i.closeLeadId);A&&F.set(A,K)}return F},[t]),B=l.useMemo(()=>{const F=new Map;for(const K of t||[]){const A=(o(K,i.displayName)||o(K,i.leadName)||"").trim().toLowerCase();A&&!F.has(A)&&F.set(A,K)}return F},[t]),j=h.toLowerCase().trim(),P=j.length>=2?(t||[]).filter(F=>(o(F,i.displayName)+" "+o(F,i.leadName)+" "+o(F,i.contactName)+" "+o(F,i.contactEmail)+" "+o(F,i.kategorie)).toLowerCase().includes(j)).slice(0,8):[],ve=j.length>=2?x.filter(F=>{const K=F.fields||{};return((K["707oq"]||"")+" "+(K.CIy6k||"")+" "+(K.ZPNw4||"")+" "+(K["4Fk6j"]||"")).toLowerCase().includes(j)}).slice(0,6):[],$=P.length>0||ve.length>0,_=j.length<2&&ee.length>0,ue=k&&(j.length>=2||_),be=()=>{var F;f(!1);try{(F=m.current)==null||F.blur()}catch{}},ie=F=>{r(F),a("lead-detail"),p(""),be()},H={display:"flex",alignItems:"center",gap:12,padding:"10px 15px",borderBottom:"1px solid var(--line)",transition:"background .15s"},U={fontSize:11.5,color:"var(--ink-2)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};return e.jsxs("div",{style:{position:"relative"},ref:C,children:[e.jsxs("div",{className:"cs-sidebar-search",style:k?{position:"relative",zIndex:4002}:void 0,children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:14,height:14,opacity:.35,flexShrink:0},children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:m,className:"cs-sidebar-search-input",placeholder:"Lead oder Kontakt suchen...",value:h,onChange:F=>{p(F.target.value),f(!0)},onFocus:()=>f(!0)}),h&&e.jsx("span",{style:{cursor:"pointer",opacity:.4,fontSize:11},onClick:()=>{p(""),be()},children:"â"})]}),ue&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onMouseDown:be,style:{position:"fixed",inset:0,background:"rgba(16,32,23,.32)",backdropFilter:"blur(3px)",WebkitBackdropFilter:"blur(3px)",zIndex:4e3}}),e.jsxs("div",{style:{position:"fixed",left:v.left,top:v.top,width:v.width,background:"var(--panel)",border:"1px solid var(--line)",borderRadius:16,zIndex:4001,maxHeight:"70vh",overflowY:"auto",boxShadow:"var(--shadow-pop)"},children:[_&&e.jsx("div",{style:{...fe,padding:"12px 15px 6px"},children:"Zuletzt geöffnet"}),_&&ee.map((F,K)=>{const A=(t||[]).find(ne=>ne.id===F.id),ce=(A?o(A,i.displayName)||o(A,i.leadName):"")||F.name||"â",Ve=(A?ut(A,i.statusLabel):"")||F.status||"",Xe=(A?o(A,i.contactName)||o(A,i.contactEmail):"")||F.kontakt||"",it=(A?o(A,i.url):"")||F.url||"";return e.jsxs("div",{style:{...H,cursor:"pointer",borderBottom:K===ee.length-1?"none":H.borderBottom},onMouseEnter:ne=>ne.currentTarget.style.background="var(--panel-2)",onMouseLeave:ne=>ne.currentTarget.style.background="transparent",onClick:()=>ie(F.id),children:[e.jsx(_a,{url:it,name:ce,size:28}),e.jsx("div",{style:{minWidth:0,flex:"1 1 46%",fontSize:13,fontWeight:700,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ce}),e.jsx("div",{style:{...U,flex:"0 0 26%",display:"flex",alignItems:"center",gap:6},children:Ve&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{...Qe,background:$n(Ve)}}),Ve]})}),e.jsx("div",{style:{...U,flex:"0 0 26%",color:"var(--ink-3)"},children:Xe})]},F.id)}),!_&&!$&&e.jsxs("div",{style:{padding:"18px 15px",fontSize:12.5,color:"var(--ink-3)"},children:["Keine Treffer für â",h.trim(),'".']}),P.length>0&&e.jsx("div",{style:{...fe,padding:"12px 15px 6px"},children:"Leads"}),P.map(F=>{const K=o(F,i.displayName)||o(F,i.leadName)||"â",A=ut(F,i.statusLabel)||"",ce=o(F,i.contactName)||o(F,i.contactEmail)||"";return e.jsxs("div",{style:{...H,cursor:"pointer"}
103,onMouseEnter:Ve=>Ve.currentTarget.style.background="var(--panel-2)",onMouseLeave:Ve=>Ve.currentTarget.style.background="transparent",onClick:()=>{r(F.id),a("lead-detail"),p(""),be()},children:[e.jsx(_a,{url:o(F,i.url),name:K,logo:o(F,i.aHeroImage),size:28}),e.jsx("div",{style:{minWidth:0,flex:"1 1 46%",fontSize:13,fontWeight:700,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K}),e.jsx("div",{style:{...U,flex:"0 0 26%",display:"flex",alignItems:"center",gap:6},children:A&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{...Qe,background:$n(A)}}),A]})}),e.jsx("div",{style:{...U,flex:"0 0 26%",color:"var(--ink-3)"},children:ce})]},F.id)}),ve.length>0&&e.jsx("div",{style:{...fe,padding:"12px 15px 6px",borderTop:"1px solid var(--line)",marginTop:-1},children:"Kontakte"}),ve.map((F,K)=>{const A=F.fields||{},ce=A["707oq"]||A.CIy6k||"Kontakt",Ve=A["4Fk6j"]||A.GQdSH||"",Xe=A.CIy6k||A.z0xSB||"",it=A.uH2Ib||A.Q6zIb||"",ne=(A["4Fk6j"]||A.GQdSH||"").trim().toLowerCase(),Le=(it?I.get(it):null)||(ne?B.get(ne):null);return e.jsxs("div",{style:{...H,cursor:Le?"pointer":"default",opacity:Le?1:.55},onMouseEnter:Ue=>{Le&&(Ue.currentTarget.style.background="var(--panel-2)")},onMouseLeave:Ue=>Ue.currentTarget.style.background="transparent",onClick:()=>{Le&&(r(Le.id),a("lead-detail"),p(""),be())},children:[e.jsx(En,{contactId:F.id,name:ce,email:A.CIy6k,company:A["4Fk6j"],leadUrl:Le?o(Le,i.url):"",storedAvatar:A.Hb2om,size:28}),e.jsx("div",{style:{minWidth:0,flex:"1 1 34%",fontSize:13,fontWeight:700,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ce}),e.jsx("div",{style:{...U,flex:"0 0 30%"},children:Ve}),e.jsx("div",{style:{...U,flex:"0 0 30%",color:"var(--ink-3)"},children:Le?Xe:Xe?Xe+" · kein Lead verknüpft":"kein Lead verknüpft"})]},F.id||K)})]})]})]})}function rc({view:t,setView:r,smartView:a,setSmartView:n,collapsed:h,setEinklappend:p,currentUser:k,leads:f,setLeadId:C,onSettings:m,onMesseImport:v}){const g=Ql(),x=`lm_sv_collapsed_${(k==null?void 0:k.key)||"dima"}`,[N,ee]=l.useState(()=>{try{const _=localStorage.getItem(x);if(_)return JSON.parse(_)}catch{}return{messen:!0}});l.useEffect(()=>{try{const _=localStorage.getItem(x);_&&ee(JSON.parse(_))}catch{}},[x]);const le=_=>{ee(ue=>{const be=_(ue);try{localStorage.setItem(x,JSON.stringify(be))}catch{}return be})},[Z,I]=l.useState(""),B=[{key:"inbox",label:"Inbox",svg:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 12h-6l-2 3h-4l-2-3H2"}),e.jsx("path",{d:"M5.45 5.11L2 12v6a2 2 0 002 2h16a2 2 0 002-2v-6l-3.45-6.89A2 2 0 0016.76 4H7.24a2 2 0 00-1.79 1.11z"})]})},{key:"leads",label:"Leads",svg:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M23 21v-2a4 4 0 00-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 010 7.75"})]})},{key:"tasks",label:"Aufgaben",svg:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]})},{key:"workflows",label:"Workflows",svg:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})})}],j=[],P=[],ve=_=>t===_||t==="lead-detail"&&_==="leads",$=()=>{try{g("/dashboard")}catch{window.location.href="/dashboard"}};return e.jsxs("aside",{className:"cs-sidebar","data-collapsed":h||void 0,children:[e.jsxs("div",{className:"cs-sidebar-header",children:[e.jsx("button",{className:"cs-home-btn",onClick:$,title:"Zum Dashboard",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{width:18,height:18},children:[e.jsx("path",{d:"M3 10.5 12 3l9 7.5"}),e.jsx("path",{d:"M5 9.5V20a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9.5"}),e.jsx("path",{d:"M9.5 21v-6h5v6"})]})}),!h&&e.jsx(ac,{leads:f,setLeadId:C,setView:r,currentUser:k})]}),e.jsx("nav",{className:"cs-nav",children:B.map(_=>e.jsxs("button",{className:`cs-nav-item ${ve(_.key)?"cs-active":""}`,"aria-current":ve(_.key)?"page":void 0,title:h?_.label:void 0,onClick:()=>{r(_.key),n(-1)},children:[e.jsx("span",{className:"cs-nav-icon",children:_.svg}),!h&&e.jsx("span",{className:"cs-nav-text",children:_.label}),!h&&_.extra]},_.key))}),!h&&j.length>0&&e.jsx("nav",{className:"cs-nav cs-nav-secondary",children:j.map(_=>e.jsxs("button",{className:`cs-nav-item ${ve(_.key)?"cs-active":""}`,onClick:()=>{r(_.key),n(-1)},children:[e.jsx("span",{className:"cs-nav-icon",children:_.svg}),e.jsx("span",{className:"cs-nav-text",children:_.label})]},_.key))}),!h&&e.jsxs("div",{className:"cs-sv-section",children:[e.jsxs("div",{className:"cs-sv-search-wrap",children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"cs-sv-search-ic",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{className:"cs-sv-search",placeholder:"Smart View suchen...",value:Z,onChange:_=>I(_.target.value)}),Z&&e.jsx("button",{className:"cs-sv-search-clear",onClick:()=>I(""),children:"â"})]}),(()=>{const _=Z.toLowerCase().trim();let ue=0;return Li.map(be=>{const ie=_?be.views.filter(F=>F.name.toLowerCase().includes(_)):be.views;if(ie.length===0)return ue+=be.views.length,null;const H=N[be.key]&&!_,U=Li.slice(0,Li.indexOf(be)).reduce((F,K)=>F+K.views.length,0);return e.jsxs("div",{className:"cs-sv-group",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsxs("button",{style:{flex:1,minWidth:0},className:"cs-sv-group-header",onClick:()=>le(F=>({...F,[be.key]:!F[be.key]})),children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"cs-sv-chevron","data-open":!H||void 0,children:e.jsx("polyline",{points:"9 18 15 12 9 6"})}),e.jsx("span",{className:"cs-sv-title",children:be.title}),e.jsx("span",{className:"cs-sv-count",children:ie.length})]}),be.key==="messen"&&(k==null?void 0:k.verified)&&(k==null?void 0:k.email)==="[email protected]"&&e.jsx("button",{"aria-label":"Ausstellerliste importieren",title:"Ausstellerliste importieren",onClick:v,style:{...zn,width:36,height:36,fontSize:20},children:"+"})]}),!H&&ie.map(F=>{const K=U+be.views.indexOf(F);return e.jsxs("button",{className:`cs-nav-item cs-sv-item ${a===K?"cs-active":""}`,onClick:()=>{n(K),r("leads")},title:F.desc||F.name,children:[e.jsx("span",{className:"cs-sv-emoji",children:F.emoji}),e.jsx("span",{className:"cs-nav-text",children:F.name})]},K)})]},be.key)})})()]}),e.jsxs("div",{className:"cs-sidebar-bottom",children:[!h&&P.map(_=>e.jsxs("button",{className:`cs-nav-item cs-nav-item-dim ${ve(_.key)?"cs-active":""}`,onClick:()=>{r(_.key),n(-1)},children:[e.jsx("span",{className:"cs-nav-icon",children:_.svg}),e.jsx("span",{className:"cs-nav-text",children:_.label})]},_.key)),e.jsxs("button",{className:"cs-nav-item",title:"Einstellungen â CRM-Einstellungen & Templates",onClick:()=>{m&&m()},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"cs-nav-icon",style:{width:16,height:16},children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-4 0v-.09A1.65 1.65 0 009
10319.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83-2.83l.06-.06A1.65 1.65 0 004.68 15a1.65 1.65 0 00-1.51-1H3a2 2 0 010-4h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 012.83-2.83l.06.06A1.65 1.65 0 009 4.68a1.65 1.65 0 001-1.51V3a2 2 0 014 0v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 2.83l-.06.06A1.65 1.65 0 0019.4 9a1.65 1.65 0 001.51 1H21a2 2 0 010 4h-.09a1.65 1.65 0 00-1.51 1z"})]}),e.jsx("span",{className:"cs-nav-text",children:"Einstellungen"})]})]}),e.jsxs("button",{className:"cs-collapse-btn",onClick:()=>p(!h),children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:14,height:14},children:e.jsx("polyline",{points:h?"9 18 15 12 9 6":"15 18 9 12 15 6"})}),!h&&e.jsx("span",{className:"cs-collapse-label",children:"Einklappen"})]})]})}function Ur({setView:t,setLeadId:r,smartView:a,setSmartView:n,currentUser:h}){var Te,Ae;const[p,k]=l.useState([]),[f,C]=l.useState(!0),[m,v]=l.useState({}),[g,x]=l.useState({}),[N,ee]=l.useState({byLeadId:{},byClient:{}}),[le,Z]=l.useState(""),[I,B]=l.useState(0),[j,P]=l.useState("date"),[ve,$]=l.useState("desc"),[_,ue]=l.useState(!1),[be,ie]=l.useState(""),[H,U]=l.useState(""),[F,K]=l.useState(""),[A,ce]=l.useState(!1),[Ve,Xe]=l.useState(new Set),[it,ne]=l.useState(!1),[Le,Ue]=l.useState("dima"),[ct,yt]=l.useState(""),[rt,De]=l.useState(""),[je,nt]=l.useState(!1),[qe,lt]=l.useState(null),[gt,Nt]=l.useState(()=>{try{return new Map(JSON.parse(localStorage.getItem("lm_bulk_tracking")||"[]"))}catch{return new Map}}),[Ut,Mt]=l.useState(()=>{try{return JSON.parse(localStorage.getItem("lm_tracking_campaigns")||"[]")}catch{return[]}}),[$t,un]=l.useState(()=>{try{return JSON.parse(localStorage.getItem("lm_bulk_templates")||"[]")}catch{return[]}}),[Xt,kn]=l.useState(!1),sn=u=>{Nt(new Map(u));try{localStorage.setItem("lm_bulk_tracking",JSON.stringify([...u]))}catch{}},jn=async u=>{const J=new Map(gt);let O=!1;for(const oe of u){const q=J.get(oe);if(!(!q||q.opened))try{const se=await Ge(`/api/tracking?id=${q.trackingId}`);se!=null&&se.opened&&(J.set(oe,{...q,opened:!0,openedAt:se.openedAt||new Date().toISOString()}),O=!0)}catch{}}O&&sn(J)},on=()=>{if(!ct.trim()||!rt.trim())return;const u=prompt("Template-Name:");if(!u)return;const J=[...$t,{name:u,subject:ct,body:rt}];un(J);try{localStorage.setItem("lm_bulk_templates",JSON.stringify(J))}catch{}},Jt=u=>{const J=$t.filter((O,oe)=>oe!==u);un(J);try{localStorage.setItem("lm_bulk_templates",JSON.stringify(J))}catch{}},mn=u=>{j===u?$(J=>J==="asc"?"desc":"asc"):(P(u),$(u==="date"||u==="projekte"?"desc":"asc"))},cn=u=>{const J=o(u,i.closeLeadId);if(J&&N.byLeadId[J]!=null)return N.byLeadId[J];if(N.byLeadId[u.id]!=null)return N.byLeadId[u.id];const O=(o(u,i.displayName)||o(u,i.leadName)).toLowerCase().trim();return O&&N.byClient[O]||0},Qt=["name","contact","status","comm","emails","projekte","days","fu"],Gt="crmCols:"+((h==null?void 0:h.key)||"x"),[dt,Rt]=l.useState(Qt),[ft,dn]=l.useState({}),pn=l.useRef({});l.useEffect(()=>{pn.current=ft},[ft]),l.useEffect(()=>{try{const u=JSON.parse(localStorage.getItem(Gt)||"null");if(u&&Array.isArray(u.order)){const J=u.order.filter(O=>Qt.includes(O));Rt([...J,...Qt.filter(O=>!J.includes(O))])}else Rt(Qt);dn(u&&u.widths&&typeof u.widths=="object"?u.widths:{})}catch{Rt(Qt),dn({})}},[Gt]);const V=(u,J)=>{try{localStorage.setItem(Gt,JSON.stringify({order:u,widths:J}))}catch{}},Fe=l.useRef(null),Ne=(u,J)=>{u.preventDefault(),u.stopPropagation();const O=u.currentTarget.closest("th");Fe.current={key:J,startX:u.clientX,startW:O?O.getBoundingClientRect().width:pn.current[J]||120};const oe=se=>{const Ee=Fe.current;if(!Ee)return;const Me=Math.max(60,Math.round(Ee.startW+(se.clientX-Ee.startX)));dn(pt=>({...pt,[Ee.key]:Me}))},q=()=>{document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",q),Fe.current&&V(dt,pn.current),Fe.current=null};document.addEventListener("mousemove",oe),document.addEventListener("mouseup",q)},mt=l.useRef(null),[Ie,Lt]=l.useState(null),wn=u=>J=>{if(Fe.current){J.preventDefault();return}mt.current=u;try{J.dataTransfer.effectAllowed="move",J.dataTransfer.setData("text/plain",u)}catch{}},Zn=u=>J=>{J.preventDefault(),Lt(null);let O=mt.current;if(mt.current=null,!O)try{O=J.dataTransfer.getData("text/plain")}catch{}!O||O===u||Rt(oe=>{const q=[...oe],se=q.indexOf(O),Ee=q.indexOf(u);return se<0||Ee<0?oe:([q[se],q[Ee]]=[q[Ee],q[se]],V(q,pn.current),q)})},In={name:{label:"Name",sort:"name"},contact:{label:"Kontakt",sort:"contact"},status:{label:"Status",sort:"status"},comm:{label:"Letzte Kommunikation",sort:"date"},emails:{label:"Mails",sort:"emails"},projekte:{label:"Projekte",sort:"projekte",title:"Anzahl Projekte mit diesem Kunden"},days:{label:"Tage",sort:"days",title:"Tage seit letztem Kontakt"},fu:{label:"ð
",title:"Wiedervorlage"}};l.useEffect(()=>{en()},[]);const en=async()=>{var J;let u=!1;try{const O=await $i(Gs);
103(J=O==null?void 0:O.records)!=null&&J.length&&(k(O.records),C(!1),u=!0)}catch{}u||C(!0);try{let O=[],oe=0;for(;;){const se=(await Zt(tt,100,oe)).data||[];if(O=[...O,...se],se.length<100)break;oe+=100}k(O),Ki(Gs,{records:O,ts:Date.now()})}catch(O){console.error(O)}finally{C(!1)}};l.useEffect(()=>{const J=Ja(O=>{var q,se;const oe={};for(const[Ee,Me]of O.byLeadId.entries()){const pt=Me[0],Bt=((q=pt==null?void 0:pt.fields)==null?void 0:q["707oq"])||((se=pt==null?void 0:pt.fields)==null?void 0:se["5OGPi"])||"";oe[Ee]={name:Bt,count:Me.length}}v(oe)},{immediate:!0});return Hi(),J},[]),l.useEffect(()=>{Ge("/api/lead-touch-map").then(u=>{u!=null&&u.touch&&typeof u.touch=="object"&&x(u.touch)}).catch(()=>{})},[]),l.useEffect(()=>{Ge("/api/lead-project-counts").then(u=>{u!=null&&u.ok&&ee({byLeadId:u.byLeadId||{},byClient:u.byClient||{}})}).catch(()=>{})},[]);const S=async()=>{if(be.trim()){ce(!0);try{await Gn(tt,{[i.displayName]:be.trim(),[i.contactEmail]:H.trim(),[i.url]:F.trim()}),ue(!1),ie(""),U(""),K(""),en()}catch(u){console.error(u),alert("Fehler beim Erstellen: "+u.message)}finally{ce(!1)}}},X=async()=>{if(!ct.trim()||Ve.size===0)return;const J=ge.filter(se=>Ve.has(se.id)).filter(se=>o(se,i.contactEmail));if(J.length===0){alert("Keine der ausgewählten Leads hat eine E-Mail-Adresse.");return}if(!confirm(`E-Mail an ${J.length} Leads senden?`))return;nt(!0),lt({total:J.length,sent:0,failed:[]});const O=[];for(let se=0;se<J.length;se++){const Ee=J[se],Me=o(Ee,i.contactEmail),pt=o(Ee,i.displayName)||o(Ee,i.leadName),Bt=o(Ee,i.contactName),ht=ct.replace(/\{firma\}/gi,pt).replace(/\{kontakt\}/gi,Bt).replace(/\{email\}/gi,Me),jt=rt.replace(/\{firma\}/gi,pt).replace(/\{kontakt\}/gi,Bt).replace(/\{email\}/gi,Me).replace(/\n/g,"<br>");try{const Dt=await Ge("/api/send",{method:"POST",body:JSON.stringify({user:Le,to:Me,subject:ht,body:jt})});if(Dt!=null&&Dt.trackingId){const tn=new Map(gt);tn.set(Ee.id,{trackingId:Dt.trackingId,opened:!1,email:Me}),sn(tn)}lt(tn=>tn&&{...tn,sent:tn.sent+1})}catch{O.push(pt+" ("+Me+")")}se<J.length-1&&await new Promise(Dt=>setTimeout(Dt,1e3))}lt(se=>se&&{...se,sent:J.length-O.length,failed:O}),nt(!1);const q=[{subject:ct,date:new Date().toISOString(),ids:J.map(se=>se.id)},...Ut].slice(0,20);Mt(q);try{localStorage.setItem("lm_tracking_campaigns",JSON.stringify(q))}catch{}setTimeout(()=>jn(J.map(se=>se.id)),5e3)},[we,Be]=l.useState(()=>new Map),[pe,_e]=l.useState("");l.useEffect(()=>{let u=!0,J=0;Be(new Map);const O=(h==null?void 0:h.email)||(h==null?void 0:h.id)||"",oe=()=>{if(!O)return;const q=++J;fl(O).then(se=>{u&&q===J&&(Be(se),_e(""))}).catch(se=>{u&&q===J&&_e(se.message)})};return oe(),window.addEventListener("crm-followups-changed",oe),()=>{u=!1,window.removeEventListener("crm-followups-changed",oe)}},[h==null?void 0:h.id,h==null?void 0:h.email]);const[Oe,zt]=l.useState(""),[Yt,fn]=l.useState(!1),Dn=async(u,J)=>{if(!(J===null&&!confirm("Diese Wiedervorlage und ihren automatisch geplanten Termin entfernen?")))try{await Fa(u,J),Be(Ua()),_e("")}catch(O){_e(O.message)}},b=async()=>{if(!Oe||Ve.size===0||!confirm(`Status für ${Ve.size} Leads auf "${Oe}" setzen?`))return;fn(!0);const u=[...Ve];for(const J of u)try{await et(tt,J,{[i.statusLabel]:Oe})}catch{}fn(!1),zt(""),Xe(new Set),en()},re=["Bisher kein Kontakt","Potenzial","GOLDKUNDE","Bestandskunde","Tier 1 Kunde","Neukunde","Videokartenkunde","In Arbeit","Individuell kontaktieren","kostenlose Probefahrt","50$ Client","WATCHLIST","pausiert","Blacklist","nicht abgeschlossen","NEUER LEAD"],he=l.useMemo(()=>{const u={},J=Date.now(),O=oe=>{if(!oe)return 0;const q=Date.parse(oe);return Number.isFinite(q)&&q<=J?q:0};for(const oe of p){let q=Math.max(O(o(oe,i.lastCommDate)),O(o(oe,i.lastActivityDate)),O(o(oe,i.lastEmailDate)),O(o(oe,i.dateUpdated)));const se=o(oe,i.closeLeadId);se&&g[se]&&(q=Math.max(q,O(g[se]))),g[oe.id]&&(q=Math.max(q,O(g[oe.id])));const Ee=gt.get(oe.id);Ee!=null&&Ee.openedAt&&(q=Math.max(q,O(Ee.openedAt)));try{for(const Me of JSON.parse(localStorage.getItem(`lm_notes_${oe.id}`)||"[]"))q=Math.max(q,O(Me==null?void 0:Me.date));for(const Me of JSON.parse(localStorage.getItem(`lm_calls_${oe.id}`)||"[]"))q=Math.max(q,O((Me==null?void 0:Me.date)||(Me==null?void 0:Me.at)))}catch{}
103q||(q=Math.max(O(o(oe,i.dateCreated)),O(oe.createdAt))),q&&(u[oe.id]=q)}return u},[p,g,gt]),ge=l.useMemo(()=>{const u=we,J=new Date;J.setHours(0,0,0,0);let O=p;if(a>=0&&a<On.length){const q=On[a];O=O.filter(se=>{if(q.filter.field==="status")return ut(se,i.statusLabel).includes(q.filter.match);if(q.filter.field==="messen"){const Ee=ut(se,i.messen),Me=o(se,i.kategorie);return Ee.includes(q.filter.match)||Me.toLowerCase().includes(q.filter.match.toLowerCase())}else{if(q.filter.field==="tier")return o(se,i.tier).includes(q.filter.match);if(q.filter.field==="kategorie")return o(se,i.kategorie).toLowerCase().includes(q.filter.match.toLowerCase());if(q.filter.field==="followup-today"){const Ee=u.get(se.id);if(!Ee)return!1;const Me=new Date(Ee);return Me.setHours(0,0,0,0),Me<=J}else if(q.filter.field==="overdue"){const Ee=o(se,i.lastCommDate)||o(se,i.lastActivityDate)||o(se,i.dateCreated),Me=is(Ee);return Me!==null&&Me>14}else if(q.filter.field==="no-contact-days"){const Ee=o(se,i.lastCommDate)||o(se,i.lastActivityDate)||o(se,i.dateCreated),Me=is(Ee);return Me!==null&&Me>=(q.filter.days??7)}else if(q.filter.field==="status-days"){if(q.filter.match==="new"){const Ee=is(o(se,i.dateCreated));return Ee!==null&&Ee<=(q.filter.days??7)}return!0}}return!0})}if(le.trim()){const q=le.toLowerCase().trim();O=O.filter(se=>[o(se,i.displayName),o(se,i.leadName),o(se,i.contactName),o(se,i.contactEmail),o(se,i.kategorie)].join(" ").toLowerCase().includes(q))}const oe=q=>{switch(j){case"name":return(o(q,i.displayName)||o(q,i.leadName)).toLowerCase();case"contact":return o(q,i.contactName).toLowerCase();case"status":return ut(q,i.statusLabel).toLowerCase();case"opp":return(ut(q,i.oppStatus)||o(q,i.oppStatus)).toLowerCase();case"comm":return o(q,i.lastEmailSubject).toLowerCase();case"emails":return Number(o(q,i.numEmails))||0;case"projekte":return cn(q);case"created":return o(q,i.dateCreated)||q.createdAt||"";case"date":return he[q.id]||0;case"days":{const se=he[q.id];if(se)return Math.floor((Date.now()-se)/864e5);const Ee=is(o(q,i.lastCommDate)||o(q,i.lastActivityDate));return Ee===null?9999:Ee}default:return""}};return O=[...O].sort((q,se)=>{const Ee=oe(q),Me=oe(se),pt=typeof Ee=="number"?Ee-Me:String(Ee).localeCompare(String(Me),"de");return ve==="asc"?pt:-pt}),O},[p,a,le,j,ve,we,he,N]);return e.jsxs("div",{className:"cs-main",children:[e.jsxs("div",{className:"cs-page-header",children:[e.jsx("h1",{className:"cs-page-title",children:a>=0&&a<On.length?`${On[a].emoji} ${On[a].name}`:"Leads"}),e.jsxs("div",{className:"cs-page-actions",children:[a>=0&&n&&e.jsx("button",{className:"cs-btn-ghost",style:{fontSize:11.5,padding:"5px 10px",marginRight:6},onClick:()=>n(-1),children:"Filter löschen"}),e.jsxs("span",{className:"cs-count",children:[ge.length," Leads"]}),(()=>{const u=ge.filter(Ro).length;return u>0?e.jsxs("span",{title:"Leads ohne Aktivität in den letzten 48h",style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:"#92610A",fontWeight:700,marginRight:6,...xe},children:[e.jsx("span",{style:{...Qe,background:"#92610A"}}),u," Follow-Up"]}):null})(),e.jsx("button",{className:"cs-btn-outline",style:{fontSize:11.5,padding:"5px 10px",marginRight:6},onClick:()=>Fo(p),title:"Leads der letzten 7 Tage als CSV herunterladen",children:"Wochen-Report"}),e.jsx("button",{className:"cs-btn-primary",onClick:()=>ue(!0),children:"Neuer Lead"})]})]}),((Te=h==null?void 0:h.email)==null?void 0:Te.toLowerCase())==="[email protected]"&&a>=0&&["followup-today","overdue","no-contact-days"].includes((Ae=On[a])==null?void 0:Ae.filter.field)&&e.jsx(So,{filter:On[a].filter.field==="no-contact-days"?`no-contact-${On[a].filter.days||7}`:On[a].filter.field,accountKey:(h==null?void 0:h.email)||(h==null?void 0:h.id)||"",onOpenLead:u=>{r(u),t("lead-detail")}}),pe&&e.jsx("p",{role:"status",style:{margin:"0 20px 16px",color:"var(--ink-2)",fontSize:13},children:pe}),Ve.size>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 20px",background:"var(--sel)",borderTop:"1px solid var(--line)",borderBottom:"1px solid var(--line)",flexWrap:"wrap"},children:[e.jsxs("span",{style:{fontSize:12.5,fontWeight:700,color:"var(--ink)",...xe},children:[Ve.size," ausgewählt"]}),e.jsx("button",{className:"cs-btn-primary",style:{padding:"5px 14px",fontSize:11.5},onClick:()=>ne(!0),children:"Bulk-Mail"}),e.jsxs("select",{className:"cs-select",style:{fontSize:11,padding:"4px 8px",height:28,minWidth:160},value:Oe,onChange:u=>zt(u.target.value),children:[e.jsx("option",{value:"",children:"Status ändernâ¦"}),re.map(u=>e.jsx("option",{value:u,children:u},u))]}),Oe&&e.jsx("button",{className:"cs-btn-green",style:{padding:"5px 14px",fontSize:11.5},onClick:b,disabled:Yt,children:Yt?"Speichernâ¦":"Anwenden"}),e.jsx("button",{className:"cs-btn-outline",style:{padding:"5px 14px",fontSize:11.5},onClick:()=>Xe(new Set),children:"Aufheben"}),e.jsx("button",{className:"cs-btn-outline",style:{padding:"5px 14px",fontSize:11.5},onClick:()=>Xe(new Set(ge.map(u=>u.id))),children:"Alle"})]}),_&&e.jsxs("div",{className:"cs-compose-bar",children:[e.jsx("div",{style:{...fe,marginBottom:8},children:"Neuen Lead anlegen"}),e.jsx("input",{className:"cs-input",placeholder:"Firmenname *",value:be,onChange:u=>ie(u.target.value),autoFocus:!0}),e.jsx("input",{className:"cs-input",placeholder:"E-Mail (optional)",value:H,onChange:u=>U(u.target.value)}),e.jsx("input",{className:"cs-input",placeholder:"Webseite (optional)",value:F,onChange:u=>K(u.target.value)}),e.jsxs("div",{className:"cs-compose-footer",children:[e.jsx("button",{className:"cs-btn-primary",onClick:S,disabled:A||!be.trim(),children:A?"Wird erstellt...":"Lead anlegen"}),e.jsx("button",{className:"cs-btn-outline",onClick:()=>ue(!1),children:"Abbrechen"})]})]}),e.jsxs("div",{className:"cs-search-bar",children:[e.jsxs("svg",{className:"cs-search-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{className:"cs-search-input",placeholder:"Suchen...",value:le,onChange:u=>Z(u.target.value)})]}),f?e.jsx("div",{className:"cs-empty",children:"Lädt..."}):e.jsx("div",{className:"cs-table-wrap",children:e.jsxs("table",{className:"cs-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:36}}),dt.map(u=>e.jsx("col",{style:ft[u]?{width:ft[u]}:void 0},u))]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"cs-th-w40",children:e.jsx("input",{type:"checkbox",className:"cs-inbox-check",checked:Ve.size>0&&Ve.size===ge.length,onChange:()=>{Ve.size===ge.length?Xe(new Set):Xe(new Set(ge.map(u=>u.id)))}})}),dt.map(u=>{const J=In[u];return J?e.jsxs("th",{className:(J.sort?"cs-th-sort":"cs-th-w40")+(Ie===u?" cs-th-dragover":""),style:ft[u]?{width:ft[u]}:void 0,title:J.title,draggable:!0,onDragStart:wn(u),onDragOver:O=>{O.preventDefault(),Ie!==u&&Lt(u)},onDragLeave:()=>{Ie===u&&Lt(null)},onDrop:Zn(u),onDragEnd:()=>{mt.current=null,Lt(null)},onClick:J.sort?()=>mn(J.sort):void 0,children:[J.label,J.sort&&j===J.sort&&e.jsxs("span",{className:"cs-sort-arrow",children:[" ",ve==="asc"?"â²":"â¼"]}),e.jsx("span",{className:"cs-col-grip",title:"Spaltenbreite ziehen",onMouseDown:O=>Ne(O,u),onClick:O=>O.stopPropagation(),draggable:!1})]},u):null})]})}),e.jsx("tbody",{children:ge.map(u=>{const J=o(u,i.displayName)||o(u,i.leadName),O=m[o(u,i.closeLeadId)],oe=o(u,i.contactName)||(O==null?void 0:O.name)||"",q=ut(u,i.statusLabel),se=(ut(u,i.oppStatus)||o(u,i.oppStatus)||"").replace(/^Sales:\s*/i,"").trim(),Ee=o(u,i.contactPhone),Me=o(u,i.contactEmail),pt=Number(o(u,i.numContacts))||(O==null?void 0:O.count)||0,Bt=Number(o(u,i.numEmails))||0,ht=o(u,i.lastCommDate),jt=o(u,i.lastCommSummary),Dt=o(u,i.lastEmailSubject),tn=Ft=>{switch(Ft){case"name":return e.jsx("td",{className:"cs-td-name",children:e.jsxs("span",{className:"cs-lead-row-name",children:[e.jsx(_a,{url:o(u,i.url),name:J,logo:o(u,i.aHeroImage),size:20,radius:6,fit:"contain",border:"1px solid var(--line)"}),e.jsx("span",{className:"cs-lead-link",children:J||"â"})]})},Ft);case"phone":return e.jsx("td",{className:"cs-td-icon",children:Ee&&e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"cs-ic",children:e.jsx("path",{d:"M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.5 19.5 0 01-6-6 19.79 19.79 0 01-3.07-8.67A2 2 0 014.11 2h3a2 2 0 012 1.72 11.04 11.04 0 00.7 2.81 2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45 11.04 11.04 0 002.81.7A2 2 0 0122 16.92z"})})},Ft);case"mail":return e.jsxs("td",{className:"cs-td-icon",children:[Me&>.has(u.id)&>.get(u.id).opened&&e.jsx("svg",{title:`Geöffnet: ${new Date(gt.get(u.id).openedAt).toLocaleStr
103ing("de")}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"cs-ic",children:e.jsx("path",{d:"M21.75 9v.906a2.25 2.25 0 01-1.183 1.981l-6.478 3.488M2.25 9v.906a2.25 2.25 0 001.183 1.981l6.478 3.488m8.839 2.51l-4.66-2.51m0 0l-1.023-.55a2.25 2.25 0 00-2.134 0l-1.022.55m0 0l-4.661 2.51m16.5 1.615a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V8.844a2.25 2.25 0 011.183-1.98l7.5-4.04a2.25 2.25 0 012.134 0l7.5 4.04a2.25 2.25 0 011.183 1.98V19.5z"})}),Me&&!gt.has(u.id)&&e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"cs-ic",children:[e.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),e.jsx("polyline",{points:"22,6 12,13 2,6"})]})]},Ft);case"contact":return e.jsx("td",{children:e.jsxs("span",{className:"cs-td-contact",children:[oe||"â",pt>1&&e.jsxs("span",{className:"cs-td-more",children:[" +",pt-1]})]})},Ft);case"status":return e.jsx("td",{children:q&&e.jsxs("span",{className:"cs-status",style:{color:$n(q)},children:[e.jsx("span",{className:"cs-dot",style:{background:$n(q)}}),Za(q)]})},Ft);case"opp":return e.jsx("td",{children:se?e.jsx("span",{className:"cs-opp-pill",title:se,children:se}):e.jsx("span",{className:"cs-td-dim",children:"â"})},Ft);case"comm":return e.jsx("td",{className:"cs-td-comm",children:Dt?e.jsx("div",{className:"cs-td-comm-text",title:Dt,children:Dt}):jt?e.jsx("div",{className:"cs-td-comm-text",title:jt,children:jt}):e.jsx("span",{className:"cs-td-dim",children:"â"})},Ft);case"emails":return e.jsx("td",{className:"cs-td-center",children:Bt>0?e.jsx("span",{className:"cs-td-num",children:Bt}):e.jsx("span",{className:"cs-td-dim",children:"â"})},Ft);case"projekte":{const At=cn(u);return e.jsx("td",{className:"cs-td-center",children:At>0?e.jsx("span",{className:"cs-td-num",children:At}):e.jsx("span",{className:"cs-td-dim",children:"â"})},Ft)}case"days":return e.jsx("td",{className:"cs-td-center",title:he[u.id]?St(new Date(he[u.id]).toISOString()):ht?St(ht):"Kein Kontakt",children:(()=>{const At=he[u.id],Et=At?Math.floor((Date.now()-At)/864e5):is(ht||o(u,i.lastActivityDate));return Et===null?e.jsx("span",{className:"cs-td-dim",children:"â"}):e.jsx("span",{style:{fontSize:11.5,fontWeight:700,color:yl(Et),...xe},children:xl(Et)})})()},Ft);case"fu":return e.jsx("td",{className:"cs-td-center",onClick:At=>At.stopPropagation(),children:(()=>{const At=we.get(u.id);if(At){const Et=new Date(At),_t=new Date;_t.setHours(0,0,0,0),Et.setHours(0,0,0,0);const Un=Et<_t,Wn=Et.getTime()===_t.getTime();return e.jsxs("span",{title:`Wiedervorlage: ${Et.toLocaleDateString("de")} 104Klick zum Entfernen`,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11.5,fontWeight:700,cursor:"pointer",color:Un?"var(--red)":Wn?"#92610A":"var(--green)",...xe},onClick:()=>Dn(u.id,null),children:[e.jsx("span",{style:{...Qe,width:6,height:6,background:Un?"var(--red)":Wn?"#92610A":"var(--green)"}}),Et.toLocaleDateString("de",{day:"2-digit",month:"2-digit"})]})}return e.jsx("span",{style:{fontSize:13,color:"var(--ink-3)",cursor:"pointer"},title:"Wiedervorlage setzen",onClick:Et=>{Et.stopPropagation();const _t=document.createElement("input");_t.type="date",_t.min=new Date().toISOString().slice(0,10),_t.style.cssText="position:fixed;opacity:0;pointer-events:none",document.body.appendChild(_t),_t.addEventListener("change",()=>{_t.value&&Dn(u.id,_t.value),document.body.removeChild(_t)}),_t.addEventListener("blur",()=>{setTimeout(()=>{document.body.contains(_t)&&document.body.removeChild(_t)},200)}),_t.click()},children:"+"})})()},Ft);default:return null}};return e.jsxs("tr",{onClick:()=>{r(u.id),t("lead-detail")},children:[e.jsx("td",{className:"cs-td-icon",children:e.jsx("input",{type:"checkbox",className:"cs-inbox-check",checked:Ve.has(u.id),onClick:Ft=>Ft.stopPropagation(),onChange:()=>{Xe(Ft=>{const At=new Set(Ft);return At.has(u.id)?At.delete(u.id):At.add(u.id),At})}})}),dt.map(tn)]},u.id)})})]})}),!f&&ge.length>0&&(()=>{const u=ge.reduce((se,Ee)=>se+(Number(o(Ee,i.oppValue))||0),0),J=ge.reduce((se,Ee)=>se+(Number(o(Ee,i.numEmails))||0),0),O=ge.reduce((se,Ee)=>se+(Number(o(Ee,i.numCalls))||0),0),oe=ge.filter(se=>{var Ee;return(((Ee=o(se,i.statusLabel))==null?void 0:Ee.label)||o(se,i.statusLabel)||"").includes("GOLD")}).length,q=se=>se>=1e3?`${(se/1e3).toFixed(1)}
104k â¬`:`${Math.round(se)} â¬`;return e.jsxs("div",{style:{display:"flex",gap:20,padding:"10px 26px",background:"transparent",borderTop:"1px solid var(--line)",borderBottom:"1px solid var(--line)",fontSize:11.5,color:"var(--ink-3)",fontWeight:600,flexWrap:"wrap",alignItems:"center",fontVariantNumeric:"tabular-nums"},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--ink)"},children:ge.length})," Leads gefiltert"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:["Opp-Wert ",e.jsx("strong",{style:{color:"var(--gold-text)"},children:q(u)})]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--ink)"},children:J})," Emails"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--ink)"},children:O})," Calls"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--green)"},children:oe})," Goldkunden"]})]})})(),!f&&e.jsx("div",{className:"cs-pagination",children:e.jsxs("span",{className:"cs-count",children:[ge.length," von ",p.length," Leads"]})}),it&&e.jsx("div",{className:"cs-modal-overlay",onClick:()=>!je&&ne(!1),children:e.jsxs("div",{className:"cs-modal",style:{maxWidth:600},onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"cs-modal-header",children:[e.jsxs("div",{className:"cs-modal-title",children:["Bulk E-Mail an ",Ve.size," Leads"]}),e.jsx("button",{className:"cs-modal-close",onClick:()=>!je&&ne(!1),children:"â"})]}),e.jsxs("div",{className:"cs-modal-body",style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{padding:12,background:"var(--panel-2)",borderRadius:10,border:"1px solid var(--line)",maxHeight:120,overflowY:"auto"},children:[e.jsxs("div",{style:{...fe,marginBottom:7},children:["Empfänger (",ge.filter(u=>Ve.has(u.id)&&o(u,i.contactEmail)).length," mit E-Mail)"]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:10},children:[ge.filter(u=>Ve.has(u.id)).slice(0,20).map(u=>{const J=!!o(u,i.contactEmail);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,fontWeight:600,color:J?"var(--ink-2)":"var(--red)"},children:[e.jsx("span",{style:{...Qe,width:6,height:6,background:J?"var(--green)":"var(--red)"}}),o(u,i.displayName)||o(u,i.leadName),!J&&" (keine E-Mail)"]},u.id)}),Ve.size>20&&e.jsxs("span",{style:{...ye,...xe},children:["+",Ve.size-20," weitere"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("button",{className:"cs-btn-outline",style:{fontSize:11.5,padding:"5px 10px"},onClick:()=>kn(!Xt),children:["Templates ",$t.length>0?`(${$t.length})`:""]}),ct.trim()&&rt.trim()&&e.jsx("button",{className:"cs-btn-outline",style:{fontSize:11.5,padding:"5px 10px"},onClick:on,children:"Speichern"})]}),Xt&&$t.length>0&&e.jsx("div",{style:{padding:10,background:"var(--panel-2)",borderRadius:10,border:"1px solid var(--line)",display:"flex",flexDirection:"column",gap:6},children:$t.map((u,J)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("button",{style:{flex:1,textAlign:"left",background:"none",border:"none",cursor:"pointer",fontSize:12.5,color:"var(--ink)",padding:"3px 6px",borderRadius:6,fontFamily:"inherit"},onClick:()=>{yt(u.subject),De(u.body),kn(!1)},children:[e.jsx("strong",{children:u.name})," ",e.jsxs("span",{style:{color:"var(--ink-3)"},children:["â ",u.subject]})]}),e.jsx("button",{style:{...zn,width:24,height:24,borderRadius:7,borderColor:"transparent",color:"var(--red)",fontSize:13},onClick:()=>Jt(J),children:"â"})]},J))}),e.jsxs("div",{style:{padding:10,background:"#FDF8E9",borderRadius:10,border:"1px solid #E6D08F",fontSize:11.5,color:"var(--gold-text)",lineHeight:1.5},children:["Verfügbare Platzhalter: ",e.jsx("code",{style:{background:"#FBF3DA",padding:"1px 4px",borderRadius:6},children:"{firma}"})," ",e.jsx("code",{style:{background:"#FBF3DA",padding:"1px 4px",borderRadius:6},children:"{kontakt}"})," ",e.jsx("code",{style:{background:"#FBF3DA",padding:"1px 4px",borderRadius:6},children:"{email}"})," â werden pro Lead automatisch ersetzt."]}),e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Von"}),e.jsx("select",{className:"cs-select",style:{width:"100%"},value:Le,onChange:u=>Ue(u.target.value),children:wt.map(u=>e.jsxs("option",{value:u.key,children:[u.name," (",u.email,")"]},u.key))})]}),e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Betreff"}),e.jsx("input",{className:"cs-input",value:ct,onChange:u=>yt(u.target.value),placeholder:"z.B. Angebot für {firma}"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Nachricht"}),e.jsx("textarea",{className:"cs-textarea",rows:8,value:rt,onChange:u=>De(u.target.value),placeholder:`Hallo {kontakt}, 105 106ich wollte mich bei Ihnen melden bezüglich... 107 108Mit freundlichen GrüÃen`})]}),qe&&e.jsxs("div",{style:{padding:12,background:"var(--panel-2)",borderRadius:10,border:"1px solid var(--line)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12.5,marginBottom:6,...xe},children:[e.jsxs("span",{style:{fontWeight:700,color:"var(--ink)"},children:[qe.sent," / ",qe.total," gesendet"]}),qe.failed.length>0&&e.jsxs("span",{style:{color:"var(--red)",fontWeight:700},children:[qe.failed.length," fehlgeschlagen"]})]}),e.jsx("div",{style:{height:6,borderRadius:6,background:"var(--bg-2)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:6,background:"var(--green)",width:`${qe.sent/qe.total*100}%`,transition:"width .3s"}})}),qe.failed.length>0&&e.jsx("div",{style:{marginTop:8,fontSize:11.5,color:"var(--red)"},children:qe.failed.join(", ")}),!je&&qe.sent>0&&e.jsxs("div",{style:{marginTop:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12.5,color:"var(--green)",fontWeight:700,marginBottom:6,...xe},children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),qe.sent," E-Mails gesendet â Tracking aktiv"]}),(()=>{const u=[...Ve].filter(O=>gt.has(O)),J=u.filter(O=>{var oe;return(oe=gt.get(O))==null?void 0:oe.opened}).length;return u.length>0?e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",fontSize:11.5,color:"var(--ink-2)",fontWeight:600,...xe},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--green)"},children:J})," geöffnet"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--ink)"},children:u.length-J})," noch nicht geöffnet"]}),e.jsx("button",{style:{background:"none",border:"none",cursor:"pointer",color:"var(--green)",fontSize:11.5,fontWeight:700,padding:0,fontFamily:"inherit"},onClick:()=>jn([...Ve]),children:"Aktualisieren"})]}):null})()]})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:[e.jsx("button",{className:"cs-btn-outline",onClick:()=>{je||(ne(!1),lt(null))},children:qe&&!je?"SchlieÃen":"Abbrechen"}),(!qe||je)&&e.jsx("button",{className:"cs-btn-primary",onClick:X,disabled:je||!ct.trim(),children:je?`Sende... (${(qe==null?void 0:qe.sent)||0}/${(qe==null?void 0:qe.total)||0})`:`An ${ge.filter(u=>Ve.has(u.id)&&o(u,i.contactEmail)).length} Leads senden`})]})]})]})})]})}function Vt({value:t,onSave:r,placeholder:a="Klicken zum Bearbeiten...",multiline:n=!1,className:h=""}){const[p,k]=l.useState(!1),[f,C]=l.useState(t||""),m=l.useRef(null),v=l.useRef(null),g=l.useRef(r),x=l.useRef(t||"");l.useEffect(()=>{g.current=r},[r]),l.useEffect(()=>{p&&m.current&&m.current.focus()},[p]),l.useEffect(()=>{C(t||""),x.current=t||""},[t]),l.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const N=I=>{v.current&&(clearTimeout(v.current),v.current=null),I!==x.current&&(x.current=I,g.current(I))},ee=I=>{C(I),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=null,N(I)},800)},le=()=>{k(!1),N(f)},Z=()=>{v.current&&(clearTimeout(v.current),v.current=null),C(x.current),k(!1)};return p?n?e.jsx("textarea",{ref:m,className:`cs-editable-input cs-editable-textarea ${h}`,value:f,onChange:I=>ee(I.target.value),onBlur:le,onKeyDown:I=>{I.key==="Escape"&&Z()},rows:3}):e.jsx("input",{ref:m,className:`cs-editable-input ${h}`,value:f,onChange:I=>ee(I.target.value),onBlur:le,onKeyDown:I=>{I.key==="Enter"&&le(),I.key==="Escape"&&Z()}}):e.jsx("span",{className:`cs-editable ${h} ${f?"":"cs-editable-empty"}`,onClick:()=>k(!0),title:"Klicken zum Bearbeiten",children:f||a})}function Jn({value:t,choices:r,onSave:a}){return e.jsxs("select",{className:"cs-select",style:{border:"none",background:"none",padding:"2px 4px",fontSize:12,fontWeight:600,color:t?"var(--ink-2)":"var(--ink-3)",cursor:"pointer",maxWidth:180},value:t||"",onChange:n=>a(n.target.value),children:[e.jsx("option",{value:"",children:"â"}),r.map(n=>e.jsx("option",{value:n,children:n},n))]})}function Yr({value:t,choices:r,onSave:a}){const n=(t||"").split(", ").map(p=>
108p.trim()).filter(Boolean),h=r.filter(p=>!n.includes(p));return e.jsxs("span",{className:"cs-cf-value",style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center"},children:[n.map(p=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",color:"var(--green)",border:"1px solid var(--green-bd)",borderRadius:6,padding:"1px 6px",fontSize:11,fontWeight:700},children:[p,e.jsx("span",{style:{cursor:"pointer",opacity:.6},onClick:()=>a(n.filter(k=>k!==p)),children:"Ã"})]},p)),h.length>0&&e.jsxs("select",{className:"cs-select",style:{border:"1px dashed var(--line-2)",background:"none",borderRadius:6,padding:"1px 4px",fontSize:11,color:"var(--ink-3)",cursor:"pointer"},value:"",onChange:p=>{p.target.value&&a([...n,p.target.value])},children:[e.jsx("option",{value:"",children:"+ hinzufügen"}),h.map(p=>e.jsx("option",{value:p,children:p},p))]})]})}function Ci({icon:t,title:r,count:a,extra:n,defaultOpen:h=!1,open:p,onOpenChange:k,children:f}){const[C,m]=l.useState(h),v=p!==void 0?p:C,g=x=>{p===void 0&&m(x),k==null||k(x)};return e.jsxs("div",{className:"cs-section",children:[e.jsxs("div",{className:"cs-section-head",onClick:()=>g(!v),children:[e.jsx("span",{className:"cs-chevron",children:v?"â¾":"â¸"}),e.jsx("span",{className:"cs-section-icon",children:t}),e.jsx("span",{className:"cs-section-title-text",children:r}),typeof a=="number"&&e.jsx("span",{className:"cs-section-count",children:a}),e.jsx("span",{className:"cs-section-spacer"}),n&&e.jsx("span",{className:"cs-section-extra",onClick:x=>x.stopPropagation(),children:n})]}),v&&e.jsx("div",{className:"cs-section-body",children:f})]})}function lc({firma:t}){const[r,a]=l.useState({loading:!0,ads:[],firma:""}),[n,h]=l.useState("link_clicks"),[p,k]=l.useState("vergleich"),[f,C]=l.useState("spend"),[m,v]=l.useState("desc"),[g,x]=l.useState("kampagnen"),[N,ee]=l.useState({}),[le,Z]=l.useState(!1),[I,B]=l.useState("aktiv");l.useEffect(()=>{let S=!0;if(a({loading:!0,ads:[],firma:""}),!t||!t.trim()){a({loading:!1,ads:[],firma:""});return}return Ge(`/api/ads/customer-list?firma=${encodeURIComponent(t.trim())}`).then(X=>{S&&a({loading:!1,ads:Array.isArray(X==null?void 0:X.ads)?X.ads:[],firma:(X==null?void 0:X.firma)||t,totals:(X==null?void 0:X.totals)||null,totalsSeries:Array.isArray(X==null?void 0:X.totals_series)?X.totals_series:[],metricsAvailable:!!(X!=null&&X.metrics_available),timeseriesAvailable:!!(X!=null&&X.timeseries_available)})}).catch(()=>{S&&a({loading:!1,ads:[],firma:t,error:!0})}),()=>{S=!1}},[t]);const j="var(--green)",P="var(--green-soft)",ve="var(--green-bd)",$="var(--green)",_=S=>{if(!S)return"";const X=new Date(S);return isNaN(X.getTime())?"":X.toLocaleDateString("de-DE",{day:"2-digit",month:"short",year:"numeric"})},ue=S=>{if(!S)return"";const X=new Date(S);return isNaN(X.getTime())?"":X.toLocaleDateString("de-DE",{day:"2-digit",month:"short"})},be=S=>S==null||isNaN(Number(S))?"â":new Intl.NumberFormat("de-DE",{style:"currency",currency:"EUR",maximumFractionDigits:0}).format(Number(S)),ie=S=>S==null||isNaN(Number(S))?"â":new Intl.NumberFormat("de-DE").format(Math.round(Number(S))),H=S=>S==null||isNaN(Number(S))?"â":Number(S).toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:2})+" %",U=S=>S==null||isNaN(Number(S))?"â":new Intl.NumberFormat("de-DE",{style:"currency",currency:"EUR",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(S)),F=S=>S==null||isNaN(Number(S))?"â":Number(S).toLocaleString("de-DE",{minimumFractionDigits:1,maximumFractionDigits:2}),K=S=>{const X=_(S.start_time),we=_(S.stop_time);return X&&we?`${X} â ${we}`:X?`seit ${X}`:we?`bis ${we}`:""},A=({size:S=14,color:X=j})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:X,strokeWidth:"1.8",style:{width:S,height:S},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"6"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),ce=S=>({OUTCOME_TRAFFIC:"Traffic",OUTCOME_AWARENESS:"Reichweite",OUTCOME_ENGAGEMENT:"Interaktion",OUTCOME_LEADS:"Leads",OUTCOME_SALES:"Verkäufe",OUTCOME_APP_PROMOTION:"App",LINK_CLICKS:"Traffic",REACH:"Reichweite",BRAND_AWARENESS:"Bekanntheit",POST_ENGAGEMENT:"Interaktion",VIDEO_VIEWS:"Video",PAGE_LIKES:"Seitenlikes",LEAD_GENERATION:"Leads",MESSAGES:"Nachrichten",CONVERSIONS:"Conversions",STORE_VISITS:"Filialbesuche",APP_INSTALLS:"App-Installs"})[String(S||"").toUpperCase()]||"",Ve=S=>{const X=String(S||"").toUpperCase();return X==="ACTIVE"?{label:"Aktiv",color:$,bg:"var(--green-soft)"}:X.includes("PAUSED")?{label:"Pausiert",color:"#92610A",bg:"#FBF3DA"}:X==="PENDING_REVIEW"||X==="IN_PROCESS"?{label:"In Prüfung",color:"var(--ink-3)",bg:"var(--panel-2)"}:X==="DISAPPROVED"||X==="WITH_ISSUES"?{label:"Hinweis",color:"var(--red)",bg:"var(--red-soft)"}:X?{label:X.charAt(0)+X.slice(1).toLowerCase().replace(/_/g," "),color:"var(--ink-3)",bg:"var(--panel-2)"}:{label:"â",color:"var(--ink-3)",bg:"var(--panel-2)"}},Xe=S=>{const X=Date.now(),we=S.start_time?new Date(S.start_time).getTime():NaN,Be=S.stop_time?new Date(S.stop_time).getTime():NaN,pe=String(S.effective_status||"").toUpperCase(),_e={live:{color:$,bg:"var(--green-soft)"},warn:{color:"#92610A",bg:"#FBF3DA"},off:{color:"var(--ink-3)",bg:"var(--panel-2)"},soon:{color:j,bg:P}};if(!isNaN(Be)&&Be<X)return{txt:"beendet",..._e.off};if(pe.includes("PAUSED"))return{txt:"pausiert",..._e.warn};if(!isNaN(Be)&&Be>=X){const Oe=Math.ceil((Be-X)/864e5);return{txt:Oe<=1?"endet heute":`noch ${Oe} Tage`,...Oe<=3?_e.warn:_e.live}}if(!isNaN(we)&&we<=X){const Oe=Math.floor((X-we)/864e5);return{txt:Oe>=14?`seit ${Math.floor(Oe/7)} Wo.`:Oe>=1?`seit ${Oe} Tg.`:"frisch gestartet",..._e.live}}return!isNaN(we)&&we>X?{txt:`startet in ${Math.ceil((we-X)/864e5)} Tg.`,..._e.soon}:null};if(r.loading)return e.jsx("div",{className:"cs-timeline",style:{padding:"16px 20px 20px"},children:e.jsx("div",{style:{height:200,borderRadius:13,background:"var(--panel-2)",border:"1px solid var(--line)"}})});const it=r.ads||[],Le=(S=>{const X=new Map,we=pe=>
108typeof pe=="number"&&!isNaN(pe)?pe:0;S.forEach(pe=>{const _e=String(pe.campaign_name||pe.ad_name||"Ohne Kampagne");let Oe=X.get(_e);Oe||(Oe={campaign_name:_e,ad_name:_e,objective:"",thumbnail_url:"",ads:[],_isCampaign:!0,_metric:!1,_active:0,_start:null,_stop:null,_open:!1,spend:0,clicks:0,link_clicks:0,impressions:0,reach:0,leads:0,messaging:0,landing_page_views:0},X.set(_e,Oe)),Oe.ads.push(pe),!Oe.objective&&pe.objective&&(Oe.objective=pe.objective),!Oe.thumbnail_url&&pe.thumbnail_url&&(Oe.thumbnail_url=pe.thumbnail_url),(typeof pe.impressions=="number"||typeof pe.spend=="number")&&(Oe._metric=!0),Oe.spend+=we(pe.spend),Oe.clicks+=we(pe.clicks),Oe.link_clicks+=we(pe.link_clicks),Oe.impressions+=we(pe.impressions),Oe.reach+=we(pe.reach),Oe.leads+=we(pe.leads),Oe.messaging+=we(pe.messaging),Oe.landing_page_views+=we(pe.landing_page_views);const zt=pe.start_time?new Date(pe.start_time).getTime():NaN,Yt=pe.stop_time?new Date(pe.stop_time).getTime():NaN;isNaN(zt)||(Oe._start=Oe._start==null?zt:Math.min(Oe._start,zt)),isNaN(Yt)?Oe._open=!0:Oe._stop=Oe._stop==null?Yt:Math.max(Oe._stop,Yt),String(pe.effective_status||"").toUpperCase()==="ACTIVE"&&(Oe._active+=1)});const Be=Array.from(X.values());return Be.forEach(pe=>{pe.adCount=pe.ads.length,pe.cost_per_link_click=pe.link_clicks>0?pe.spend/pe.link_clicks:void 0,pe.cpc=pe.clicks>0?pe.spend/pe.clicks:void 0,pe.cpm=pe.impressions>0?pe.spend/pe.impressions*1e3:void 0,pe.frequency=pe.reach>0?pe.impressions/pe.reach:void 0,pe.effective_status=pe._active>0?"ACTIVE":String(pe.ads[0]&&pe.ads[0].effective_status||""),pe.start_time=pe._start!=null?new Date(pe._start).toISOString():"",pe.stop_time=!pe._open&&pe._stop!=null?new Date(pe._stop).toISOString():"",pe._metric||(pe.spend=void 0,pe.link_clicks=void 0,pe.clicks=void 0,pe.impressions=void 0,pe.reach=void 0,pe.leads=void 0,pe.messaging=void 0,pe.cost_per_link_click=void 0,pe.frequency=void 0)}),Be})(it),Ue=r.totals||{spend:0,link_clicks:0,impressions:0,reach:0,leads:0,messaging:0},ct=Array.isArray(r.totalsSeries)?r.totalsSeries:[],yt=!!r.timeseriesAvailable&&ct.length>=2,rt=!!r.metricsAvailable&&it.length>0,De=it.some(S=>typeof S.leads=="number"&&S.leads>0),je=it.some(S=>typeof S.messaging=="number"&&S.messaging>0),nt=S=>{const X=String(S.effective_status||"").toUpperCase(),we=S.stop_time?new Date(S.stop_time).getTime():NaN;return!!(!isNaN(we)&&we<Date.now()||X.includes("PAUSED")||X==="ARCHIVED"||X==="ADSET_PAUSED"||X==="CAMPAIGN_PAUSED")},qe=it.filter(S=>!nt(S)),lt=qe.length>0,Nt=(S=>{const X=we=>typeof we=="number"&&!isNaN(we)?we:0;return S.reduce((we,Be)=>({spend:we.spend+X(Be.spend),clicks:we.clicks+X(Be.clicks),link_clicks:we.link_clicks+X(Be.link_clicks),impressions:we.impressions+X(Be.impressions),reach:we.reach+X(Be.reach),leads:we.leads+X(Be.leads),messaging:we.messaging+X(Be.messaging)}),{spend:0,clicks:0,link_clicks:0,impressions:0,reach:0,leads:0,messaging:0})})(qe),Ut=I==="aktiv"&<?"aktiv":"90d",Mt=Ut==="aktiv"?Nt:Ue,$t=Mt.impressions>0?Mt.link_clicks/Mt.impressions*100:0,un=Ut==="aktiv"?qe:it,Xt=(()=>{if(!rt)return[];const S=un.length?un:it,X=[],we=S.filter(_e=>_e.spend>0&&_e.reach>0);if(we.length){const _e=we.reduce((Oe,zt)=>zt.reach/zt.spend>Oe.reach/Oe.spend?zt:Oe);X.push(`Beste Reichweite pro Euro: »${_e.ad_name||"Anzeige"}« erreicht ${ie(_e.reach/_e.spend)} Menschen je â¬.`)}const Be=S.filter(_e=>typeof _e.impressions=="number"&&_e.impressions>500);if(Be.length){const _e=Be.reduce((zt,Yt)=>Yt.link_clicks/Yt.impressions>zt.link_clicks/zt.impressions?Yt:zt),Oe=_e.link_clicks/_e.impressions*100;Oe>0&&X.push(`Höchste Klickrate: »${_e.ad_name||"Anzeige"}« mit ${H(Oe)}.`)}const pe=S.filter(_e=>typeof _e.frequency=="number"&&_e.frequency>=3.5).sort((_e,Oe)=>Oe.frequency-_e.frequency)[0];return pe&&X.push(`»${pe.ad_name||"Anzeige"}« wird im Schnitt ${F(pe.frequency)}à pro Person gezeigt â Zeit für frisches Creative.`),De&&Mt.leads>0&&X.push(`Insgesamt ${ie(Mt.leads)} Leads aus ${Ut==="aktiv"?"laufenden Anzeigen":"Anzeigen der letzten 90 Tage"}.`),X.slice(0,3)})(),kn=[{l:"Ausgaben",v:be(Mt.spend),c:j},{l:"Webseiten-Klicks",v:ie(Mt.link_clicks),c:j},...De?[{l:"Leads",v:ie(Mt.leads),c:$}]:[],...je?[{l:"Nachrichten",v:ie(Mt.messaging),c:$}]:[],{l:"Impressionen",v:ie(Mt.impressions),c:"var(--ink)"},{l:"Reichweite",v:ie(Mt.reach),c:"var(--ink)"},{l:"à Klickrate",v:H($t),c:$}],sn={spend:{label:"Ausgaben",fmt:be},link_clicks:{label:"Web-Klicks",fmt:ie},leads:{label:"Leads",fmt:ie},impressions:{label:"Impressionen",fmt:ie},reach:{label:"Reichweite",fmt:ie}},jn=["spend","link_clicks",...De?["leads"]:[],"impressions","reach"],Jt=(g==="kampagnen"?Le:it).filter(S=>typeof S[n]=="number").sort((S,X)=>(X[n]||0)-(S[n]||0)).slice(0,8),mn=Jt.reduce((S,X)=>Math.max(S,X[n]||0),0)||1,cn=["spend","link_clicks","impressions","reach"],Qt=n==="leads"?"link_clicks":n,Gt=(p==="verlauf"||Jt.length===0)&&yt?"verlauf":"vergleich",dt=[{k:"spend",label:"Ausgaben",get:S=>S.spend,fmt:be,gold:!0},{k:"link_clicks",label:"Web-Klicks",get:S=>S.link_clicks,fmt:ie},...De?[{k:"leads",label:"Leads",get:S=>S.leads,fmt:ie,green:!0}]:[],...je?[{k:"messaging",label:"Nachrichten",get:S=>S.messaging,fmt:ie,green:!0}]:[],{k:"impressions",label:"Impressionen",get:S=>S.impressions,fmt:ie},{k:"reach",label:"Reichweite",get:S=>S.reach,fmt:ie},{k:"ctr",label:"Klickrate",get:S=>typeof S.impressions=="number"&&S.impressions>0?S.link_clicks/S.impressions*100:void 0,fmt:H},{k:"cost_per_link_click",label:"â¬/Klick",get:S=>S.cost_per_link_click,fmt:U},{k:"frequency",label:"Frequenz",get:S=>S.frequency,fmt:F,colorFn:S=>typeof S.frequency=="number"?S.frequency>=3.5?"var(--red)":S.frequency>
108=2.5?"#92610A":$:void 0}],Rt=470+dt.length*96,ft=dt.find(S=>S.k===f)||dt[0],dn=[...it].sort((S,X)=>{const we=typeof ft.get(S)=="number"?ft.get(S):-1,Be=typeof ft.get(X)=="number"?ft.get(X):-1;return m==="desc"?Be-we:we-Be}),pn=S=>{Z(!0),f===S?v(X=>X==="desc"?"asc":"desc"):(C(S),v("desc"))},V=g==="kampagnen"&&!le,Fe=[...Le].sort((S,X)=>{if(!le){const pe=S._start||0,_e=X._start||0;return _e!==pe?_e-pe:(X._active>0?1:0)-(S._active>0?1:0)}const we=typeof ft.get(S)=="number"?ft.get(S):-1,Be=typeof ft.get(X)=="number"?ft.get(X):-1;return m==="desc"?Be-we:we-Be}),Ne=g==="einzel"||le,mt=g==="kampagnen"?Fe:dn,Ie={padding:"11px 14px",fontSize:11,fontWeight:600,letterSpacing:".04em",textTransform:"uppercase",color:"var(--ink-3)",whiteSpace:"nowrap"},Lt=({active:S})=>e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",style:{transform:m==="asc"?"rotate(180deg)":"none",transition:"transform .15s",flexShrink:0},"aria-hidden":"true",children:e.jsx("path",{d:"M6 9l6 6 6-6",stroke:S?j:"var(--line-2)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),wn=(S,X,we)=>{const Be=X==="campaign",pe=X==="sub",_e=Be?S.campaign_name:S.ad_name||"Anzeige",Oe=Xe(S);return e.jsx("td",{style:{padding:pe?"8px 14px 8px 32px":"10px 14px",position:"sticky",left:0,background:pe?"var(--panel-2)":"var(--panel)",zIndex:1},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[pe&&e.jsx("span",{style:{color:j,fontSize:13,flexShrink:0,lineHeight:1},children:"â³"}),e.jsx("div",{style:{width:pe?32:42,height:pe?32:42,borderRadius:8,background:"var(--panel-2)",flexShrink:0,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},children:S.thumbnail_url?e.jsx("img",{src:S.thumbnail_url,alt:"",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover"}}):e.jsx(A,{size:pe?13:16})}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{title:_e,style:{fontSize:pe?12.5:13,fontWeight:600,color:pe?"var(--ink-2)":"var(--ink)",maxWidth:240,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_e}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",marginTop:3},children:[e.jsx("span",{style:{fontSize:11,color:"var(--ink-3)",whiteSpace:"nowrap"},children:K(S)||_(S.created_time)}),!pe&&ce(S.objective)&&e.jsx("span",{style:{fontSize:9,fontWeight:700,letterSpacing:".04em",textTransform:"uppercase",color:j,background:P,border:`1px solid ${ve}`,borderRadius:5,padding:"1px 6px",whiteSpace:"nowrap"},children:ce(S.objective)}),Be&&e.jsxs("span",{style:{fontSize:9,fontWeight:700,letterSpacing:".04em",textTransform:"uppercase",color:"var(--ink-3)",background:"var(--panel-2)",border:"1px solid var(--line)",borderRadius:5,padding:"1px 6px",whiteSpace:"nowrap"},children:[S.adCount," ",S.adCount===1?"Anzeige":"Anzeigen"]}),Oe&&e.jsx("span",{style:{fontSize:9,fontWeight:700,color:Oe.color,background:Oe.bg,borderRadius:5,padding:"1px 6px",whiteSpace:"nowrap"},children:Oe.txt}),!Be&&S.post_link&&e.jsxs("a",{href:S.post_link,target:"_blank",rel:"noopener noreferrer",title:"Veröffentlichten Beitrag ansehen",onClick:zt=>zt.stopPropagation(),style:{fontSize:9,fontWeight:700,letterSpacing:".04em",textTransform:"uppercase",color:j,background:P,border:`1px solid ${ve}`,borderRadius:5,padding:"1px 7px",whiteSpace:"nowrap",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:3},children:["Beitrag",e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M7 17 17 7M9 7h8v8",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]}),Be&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{transform:we?"rotate(180deg)":"none",transition:"transform .15s",flexShrink:0},"aria-hidden":"true",children:e.jsx("path",{d:"M6 9l6 6 6-6",stroke:j,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})})},Zn=(S,X)=>{if(S._isCampaign&&S.adCount>1){const Be=S._active>0;return e.jsx("td",{style:{padding:"10px 14px"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,fontWeight:700,color:Be?$:"var(--ink-2)",whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[e.jsx("span",{style:{...Qe,width:6,height:6,background:Be?$:"var(--ink-3)"}}),S._active,"/",S.adCount," aktiv"]})})}const we=Ve(S.effective_status);return e.jsx("td",{style:{padding:X?"8px 14px":"10px 14px"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,fontWeight:700,color:we.color,whiteSpace:"nowrap"},children:[e.jsx("span",{style:{...Qe,width:6,height:6,background:we.color}}),we.label]})})},In=(S,X)=>{const we=typeof S.impressions=="number";return dt.map(Be=>
108{const pe=Be.get(S),_e=we&&typeof pe=="number";return e.jsx("td",{style:{padding:X?"8px 14px":"10px 14px",textAlign:"right",fontSize:X?12:13,fontWeight:Be.gold?700:600,color:_e?Be.colorFn&&Be.colorFn(S)||(Be.gold?j:Be.green?$:"var(--ink-2)"):"var(--line-2)",whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:_e?Be.fmt(pe):"â"},Be.k)})},en=(S,X)=>e.jsx("td",{style:{padding:X?"8px 14px":"10px 14px",textAlign:"right"},children:S.preview_url&&e.jsx("a",{href:S.preview_url,target:"_blank",rel:"noopener noreferrer",title:"Anzeige ansehen",onClick:we=>we.stopPropagation(),style:{color:j,display:"inline-flex"},children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M7 17 17 7M9 7h8v8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})});return e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:16},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{...fe,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(A,{size:12})," Anzeigen"]}),e.jsxs("div",{style:{fontSize:15,fontWeight:800,color:"var(--ink)",marginTop:4,letterSpacing:"-.02em"},children:["Meta Ads · ",r.firma||t||"â"]}),e.jsx("div",{style:{fontSize:12,color:"var(--ink-3)",marginTop:2},children:"Performance der für diesen Lead freigegebenen Anzeigen â live aus Meta."})]}),rt&&e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,fontWeight:700,color:$,whiteSpace:"nowrap"},children:[e.jsx("span",{style:{...Qe,background:$}})," Live aus Meta"]})]}),it.length===0?e.jsx("div",{style:{padding:"18px 16px",background:"var(--panel)",border:`1px dashed ${ve}`,borderRadius:13,lineHeight:1.6,color:"var(--ink-2)",fontSize:13,fontWeight:600},children:t?e.jsxs(e.Fragment,{children:["Für ",e.jsx("strong",{children:t})," sind aktuell keine Anzeigen freigegeben. Sobald das Team Anzeigen dieser Firma im gemischten Meta-Konto freigibt, erscheinen sie hier."]}):"Diesem Lead ist kein Firmenname zugeordnet â ohne Firma kann keine Anzeige zugeordnet werden."}):e.jsxs(e.Fragment,{children:[rt&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,flexWrap:"wrap",marginBottom:13},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--ink)"},children:Ut==="aktiv"?"Aktuell laufende Anzeigen":"Quartal in Zahlen"}),Ut==="aktiv"&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,fontWeight:700,color:$,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[e.jsx("span",{style:{...Qe,width:6,height:6,background:$}}),qe.length," ",qe.length===1?"Anzeige live":"Anzeigen live"]})]}),lt?e.jsx("div",{style:{display:"inline-flex",gap:2,background:"transparent",border:"1px solid var(--line)",borderRadius:10,padding:2},children:[["aktiv","Aktiv"],["90d","90 Tage"]].map(([S,X])=>{const we=Ut===S;return e.jsx("button",{onClick:()=>B(S),style:{border:0,cursor:"pointer",fontFamily:"inherit",fontSize:11.5,fontWeight:700,padding:"5px 12px",borderRadius:8,whiteSpace:"nowrap",color:we?"#fff":"var(--ink-2)",background:we?"var(--ink)":"transparent",transition:"all .15s"},children:X},S)})}):e.jsx("div",{style:{fontSize:11.5,color:"var(--ink-3)",fontWeight:500},children:"rollierende 90 Tage"})]}),rt&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:0,marginBottom:12,background:"var(--panel)",border:"1px solid var(--line)",borderRadius:13,overflow:"hidden"},children:kn.map((S,X)=>e.jsxs("div",{style:{position:"relative",padding:"14px 15px",borderRight:X===kn.length-1?"none":"1px solid var(--line)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:9},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:S.c,flexShrink:0}}),e.jsx("span",{style:fe,children:S.l})]}),e.jsx("div",{style:{fontSize:23,fontWeight:800,color:S.c,lineHeight:1,letterSpacing:"-.02em",fontVariantNumeric:"tabular-nums"},children:S.v})]},X))}),Xt.length>0&&e.jsxs("div",{style:{background:"var(--green-soft)",border:`1px solid ${ve}`,borderRadius:13,padding:"13px 16px 14px",marginBottom:12},children:[e.jsxs("div",{style:{...fe,color:"var(--green)",marginBottom:9},children:["Erkenntnisse ",e.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--ink-3)",textTransform:"none",letterSpacing:0},children:["· ",Ut==="aktiv"?"aktuell laufende":"90 Tage"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Xt.map((S,X)=>
108e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:9,fontSize:13,color:"var(--ink-2)",lineHeight:1.5},children:[e.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:j,marginTop:7,flexShrink:0}}),e.jsx("span",{children:S})]},X))})]}),(rt&&Jt.length>0||yt)&&e.jsxs("div",{style:{background:"var(--panel)",border:"1px solid var(--line)",borderRadius:13,padding:"15px 16px 17px",marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,flexWrap:"wrap",marginBottom:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:Gt==="verlauf"?"Verlauf über die Zeit":g==="kampagnen"?"Kampagnen im Vergleich":"Anzeigen im Vergleich"}),yt&&Jt.length>0&&e.jsx("div",{style:{display:"inline-flex",gap:2,background:"transparent",border:"1px solid var(--line)",borderRadius:10,padding:2},children:[["vergleich","Vergleich"],["verlauf","Verlauf"]].map(([S,X])=>e.jsx("button",{onClick:()=>k(S),style:{border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:11.5,fontWeight:700,padding:"5px 12px",borderRadius:8,background:Gt===S?"var(--ink)":"transparent",color:Gt===S?"#fff":"var(--ink-2)",transition:"all .15s"},children:X},S))})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:(Gt==="verlauf"?cn:jn).map(S=>{const X=Gt==="verlauf"?Qt===S:n===S;return e.jsx("button",{onClick:()=>h(S),style:{border:"1px solid "+(X?"var(--ink)":"var(--line)"),cursor:"pointer",fontFamily:"inherit",fontSize:11.5,fontWeight:700,padding:"5px 11px",borderRadius:8,background:X?"var(--ink)":"transparent",color:X?"#fff":"var(--ink-2)",transition:"all .15s"},children:sn[S].label},S)})})]}),Gt==="verlauf"?(()=>{const S=ct.map(O=>({period:String(O.period||""),v:Number(O[Qt]||0)})),X=720,we=188,Be={t:16,r:18,b:26,l:50},pe=X-Be.l-Be.r,_e=we-Be.t-Be.b,Oe=S.map(O=>O.v),zt=Math.max(...Oe,0),Yt=zt>0?zt*1.12:1,fn=0,Dn=Yt-fn||1,b=S.length>1?pe/(S.length-1):0,re=S.map((O,oe)=>({x:Be.l+oe*b,y:Be.t+_e-(O.v-fn)/Dn*_e,period:O.period,v:O.v})),he=re.map(O=>`${O.x.toFixed(1)},${O.y.toFixed(1)}`).join(" "),ge=`${re[0].x.toFixed(1)},${(Be.t+_e).toFixed(1)} `+he+` ${re[re.length-1].x.toFixed(1)},${(Be.t+_e).toFixed(1)}`,Te=sn[Qt].fmt,Ae=[0,.5,1].map(O=>({y:Be.t+_e*O,label:Te(fn+Dn*(1-O))})),u=S.length>1?[0,Math.floor((S.length-1)/2),S.length-1].map(O=>({x:Be.l+O*b,label:ue(S[O].period)})):[],J="lead-adseries-"+Qt;return e.jsxs("div",{children:[e.jsxs("svg",{viewBox:`0 0 ${X} ${we}`,width:"100%",preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},role:"img","aria-label":`Verlauf ${sn[Qt].label}`,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:J,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:j,stopOpacity:"0.28"}),e.jsx("stop",{offset:"100%",stopColor:j,stopOpacity:"0"})]})}),Ae.map((O,oe)=>e.jsxs("g",{children:[e.jsx("line",{x1:Be.l,y1:O.y,x2:X-Be.r,y2:O.y,stroke:"var(--line)",strokeWidth:"1"}),e.jsx("text",{x:Be.l-8,y:O.y+3.5,textAnchor:"end",fontSize:"10",fill:"var(--ink-3)",children:O.label})]},oe)),e.jsx("polygon",{points:ge,fill:`url(#${J})`}),e.jsx("polyline",{points:he,fill:"none",stroke:j,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),re.map((O,oe)=>e.jsx("circle",{cx:O.x,cy:O.y,r:re.length<=16?3.2:0,fill:"#fff",stroke:j,strokeWidth:"2"},oe)),u.map((O,oe)=>e.jsx("text",{x:O.x,y:we-7,textAnchor:oe===0?"start":oe===u.length-1?"end":"middle",fontSize:"10",fill:"var(--ink-3)",children:O.label},oe))]}),e.jsxs("div",{style:{fontSize:11.5,color:"var(--ink-3)",marginTop:6,textAlign:"center"},children:[sn[Qt].label," je Woche · ",S.length," Wochen mit Auslieferung"]})]})})():e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:9},children:Jt.map((S,X)=>{const we=S[n]||0,Be=Math.max(2,we/mn*100);return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(80px, 150px) 1fr auto",alignItems:"center",gap:10},children:[e.jsx("div",{title:S.ad_name,style:{fontSize:12,color:"var(--ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:S.ad_name||"Anzeige"}),e.jsx("div",{style:{height:22,background:"var(--panel-2)",borderRadius:6,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:Be+"%",background:j,borderRadius:6,transition:"width .55s cubic-bezier(.4,0,.2,1)"}})}),e.jsx("div",{style:{fontSize:12.5,fontWeight:700,color:j,minWidth:66,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:sn[n].fmt(we)})]},S.meta_ad_id||X)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,flexWrap:"wrap",marginBottom:10},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",display:"flex",alignItems:"center",gap:8},children:[g==="kampagnen"?"Kampagnen":"Alle Anzeigen"," ",e.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--ink-3)"},children:g==="kampagnen"?Le.length:it.length}),V&&e.jsx("span",{style:{...an},children:"neueste zuerst"})]}),e.jsx("div",{style:{display:"inline-flex",gap:2,background:"transparent",border:"1px solid var(--line)",borderRadius:10,padding:2},children:[["kampagnen","Kampagnen"],["einzel","Einzelanzeigen"]].map(([S,X])=>e.jsx("button",{onClick:()=>{x(S),Z(!1)},style:{border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:11.5,fontWeight:700,padding:"5px 12px",borderRadius:8,background:g===S?"var(--ink)":"transparent",color:g===S?"#fff":"var(--ink-2)",transition:"all .15s"},children:X},S))})]}),e.jsx("div",{style:{overflowX:"auto",background:"var(--panel)",border:"1px solid var(--line)",borderRadius:13,WebkitOverflowScrolling:"touch"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:Rt},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{...Ie,textAlign:"left",position:"sticky",left:0,background:"var(--panel-2)",zIndex:2},children:g==="kampagnen"?"Kampagne":"Anzeige"}),e.jsx("th",{style:{...Ie,textAlign:"left"},children:"Status"}),dt.map(S=>e.jsx("th",{onClick:()=>rt&&pn(S.k),style:{...Ie,textAlign:"right",color:Ne&&f===S.k?j:"var(--ink-3)",cursor:rt?"pointer":"default",userSelect:"none"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,justifyContent:"flex-end"},children:[S.label,rt&&e.jsx(Lt,{active:Ne&&f===S.k})]})},S.k)),e.jsx("th",{style:{...Ie,textAlign:"right"},"aria-label":"Link"})]})}),e.jsx("tbody",{children:mt.flatMap((S,X)=>{const we=!!S._isCampaign,Be=we&&!!N[S.campaign_name],pe=e.jsxs("tr",{onClick:we?()=>ee(_e=>({..._e,[S.campaign_name]:!_e[S.campaign_name]})):void 0,style:{borderTop:"1px solid var(--panel-2)",cursor:we?"pointer":"default",background:Be?"var(--sel)":"transparent",opacity:nt(S)?.5:1,transition:"opacity .15s"},children:[wn(S,we?"campaign":"ad",Be),Zn(S),In(S),en(S)]},(we?"c:":"a:")+(S.meta_ad_id||S.campaign_name||X));return!we||!Be?[pe]:[pe,...S.ads.map((_e,Oe)=>e.jsxs("tr",{style:{borderTop:"1px solid var(--panel-2)",background:"var(--panel-2)"},children:[wn(_e,"sub"),Zn(_e,!0),In(_e,!0),en(_e,!0)]},"s:"+S.campaign_name+":"+(_e.meta_ad_id||Oe)))]})})]})}),!rt&&e.jsx("div",{style:{fontSize:12,color:"var(--ink-3)",marginTop:10},children:"Die Kennzahlen erscheinen, sobald Meta erste Auslieferungsdaten liefert."})]})]})}function za(t){return!t||t<1?"":t<1024?t+" B":t<1048576?(t/1024).toFixed(0)+" KB":(t/1048576).toFixed(1)+" MB"}function oc(t,r){const a=(r||"").toLowerCase(),n=(t||"").toLowerCase();return n.includes("pdf")||a.endsWith(".pdf")?{bg:"var(--panel-2)",fg:"var(--red)",label:"PDF"}:n.includes("image")||/\.(png|jpe?g|gif|webp|svg)$/.test(a)?{bg:"var(--panel-2)",fg:"#5B21B6",label:"IMG"}:/\.(docx?|rtf|odt)$/.test(a)||n.includes("word")?{bg:"var(--panel-2)",fg:"#1D4ED8",label:"DOC"}:/\.(xlsx?|csv|ods)$/.test(a)||n.includes("sheet")||n.includes("excel")?{bg:"var(--panel-2)",fg:"var(--green)",label:"XLS"}:/\.(zip|rar|7z|tar|gz)$/.test(a)?{bg:"var(--panel-2)",fg:"#92610A",label:"ZIP"}:{bg:"var(--panel-2)",fg:"var(--ink-3)",label:"FILE"}}const Xr=new Map;async function qs(t){if(!t)return"";const r=`user=${encodeURIComponent(t.user||t._via||"dima")}&folder=${encodeURIComponent(t.folder||t._folder||"INBOX")}&uid=${t.uid||t.seq||0}&part=${encodeURIComponent(t.part||"1")}&enc=${encodeURIComponent(t.encoding||"")}&ct=${encodeURIComponent(t.contentType||"")}&name=${encodeURIComponent(t.name||"anhang")}${t.disp==="inline"?"&disp=inline":""}`,a=Xr.get(r);if(a&&a.exp-120>
108Date.now()/1e3)return a.url;const n=await Ge(`/api/attachment/sign?${r}`).catch(()=>null);if(n&&n.url){const h=`${ln}${n.url}`;return Xr.set(r,{url:h,exp:n.exp||0}),h}return""}function Js({f:t,kind:r,style:a,title:n}){const[h,p]=l.useState("");return l.useEffect(()=>{let k=!1;return qs(t).then(f=>{k||p(f)}),()=>{k=!0}},[t==null?void 0:t.uid,t==null?void 0:t.seq,t==null?void 0:t.part,t==null?void 0:t.user,t==null?void 0:t._via,t==null?void 0:t.folder,t==null?void 0:t._folder]),h?r==="img"?e.jsx("img",{src:h,alt:(t==null?void 0:t.name)||"",loading:"lazy",style:a,title:n,onError:k=>{k.target.style.display="none"}}):e.jsx("iframe",{src:h+"#toolbar=0&view=FitH",style:a,title:(t==null?void 0:t.name)||"PDF",loading:"lazy"}):e.jsx("div",{className:"cs-skel",style:a})}function Oa({user:t,folder:r,uid:a,atts:n}){if(n=(n||[]).filter(p=>!p.inline),!n||!n.length)return null;const h=p=>{const k=Number(p)||0;return k>=1048576?(k/1048576).toFixed(1)+" MB":k>=1024?Math.round(k/1024)+" KB":k>0?k+" B":""};return e.jsx("div",{className:"cs-mail-atts",children:n.map((p,k)=>e.jsxs("button",{type:"button",className:"cs-mail-att",title:p.name||"Anhang",onClick:async f=>{f.stopPropagation();const C=await qs({user:t,folder:r,uid:a,part:p.path||p.part||"1",encoding:p.encoding||"",contentType:p.contentType||"",name:p.name||"anhang"});C&&window.open(C,"_blank")},children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",style:{width:13,height:13,flexShrink:0},children:e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),e.jsx("span",{className:"cs-mail-att-name",children:p.name||"Anhang"}),!!h(p.size)&&e.jsx("span",{className:"cs-mail-att-size",children:h(p.size)})]},k))})}function cc({a:t,mailFiles:r}){const[a,n]=l.useState(!1),h=oc(t.content_type,t.name),p=t.url||"",k=p?`${ln}/api/close-file?url=${encodeURIComponent(p)}&name=${encodeURIComponent(t.name||"anhang")}`:"",C=/amazonaws\.com|cloudfront\.net/.test(p)?k:p,m=/app\.close\.com/.test(p),v=m?(r||[]).find(Z=>Z&&Z.name===t.name):null,g=v?async Z=>{Z.preventDefault();const I=await qs(v);I?window.open(I,"_blank"):window.open(C,"_blank")}:void 0,x=`${t.name}${t.size?" · "+za(t.size):""} â öffnen`,N=e.jsxs("a",{href:C,target:"_blank",rel:"noopener noreferrer",onClick:g,title:x,style:{display:"flex",alignItems:"center",gap:9,padding:"9px 12px",background:"var(--panel)",border:"1px solid var(--line)",borderRadius:10,textDecoration:"none",maxWidth:280,transition:"border-color .15s, background .15s"},onMouseEnter:Z=>{Z.currentTarget.style.borderColor="var(--line-2)",Z.currentTarget.style.background="var(--panel-2)"},onMouseLeave:Z=>{Z.currentTarget.style.borderColor="var(--line)",Z.currentTarget.style.background="var(--panel)"},children:[e.jsx("span",{style:{width:30,height:30,flexShrink:0,borderRadius:8,background:h.bg,border:"1px solid var(--line)",color:h.fg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:8.5,fontWeight:800,letterSpacing:".13em"},children:h.label}),e.jsxs("span",{style:{minWidth:0,flex:1},children:[e.jsx("span",{style:{display:"block",fontSize:12.5,fontWeight:700,color:"var(--ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name||"Anhang"}),e.jsxs("span",{style:{display:"block",fontSize:11.5,fontWeight:600,color:"var(--ink-3)",fontVariantNumeric:"tabular-nums"},children:[za(t.size),t.size?" · ":"","öffnen"]})]}),e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:h.fg,strokeWidth:"2",style:{width:14,height:14,flexShrink:0},children:[e.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})]});if(((t.content_type||"").includes("image")||/\.(png|jpe?g|gif|webp|svg)$/i.test(t.name||""))&&C){const Z={display:"block",width:92,height:92,borderRadius:9,overflow:"hidden",border:"1px solid var(--line)",flexShrink:0,background:"var(--panel-2)"},I={onMouseEnter:B=>{B.currentTarget.style.borderColor="var(--line-2)"},onMouseLeave:B=>
108{B.currentTarget.style.borderColor="var(--line)"}};return v?e.jsx("a",{href:C,target:"_blank",rel:"noopener noreferrer",onClick:g,title:x,style:Z,...I,children:e.jsx(Js,{f:v,kind:"img",title:t.name||"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})}):a?N:e.jsx("a",{href:C,target:"_blank",rel:"noopener noreferrer",title:x,style:Z,...I,children:e.jsx("img",{src:C,alt:t.name||"",loading:"lazy",onError:()=>n(!0),style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})}return((t.content_type||"").includes("pdf")||/\.pdf$/i.test(t.name||""))&&C?e.jsxs("span",{style:{display:"block",width:"100%"},children:[e.jsxs("a",{href:C,target:"_blank",rel:"noopener noreferrer",onClick:g,title:x,style:{display:"inline-flex",alignItems:"center",gap:9,padding:"9px 12px",background:"var(--panel)",border:"1px solid var(--line)",borderRadius:10,textDecoration:"none",maxWidth:280,transition:"border-color .15s"},onMouseEnter:Z=>{Z.currentTarget.style.borderColor="var(--line-2)"},onMouseLeave:Z=>{Z.currentTarget.style.borderColor="var(--line)"},children:[e.jsx("span",{style:{width:30,height:30,flexShrink:0,borderRadius:8,background:"var(--panel-2)",border:"1px solid var(--line)",color:"var(--red)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:8.5,fontWeight:800,letterSpacing:".13em"},children:"PDF"}),e.jsxs("span",{style:{minWidth:0,flex:1},children:[e.jsx("span",{style:{display:"block",fontSize:12.5,fontWeight:700,color:"var(--ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name||"Anhang"}),e.jsxs("span",{style:{display:"block",fontSize:11.5,fontWeight:600,color:"var(--ink-3)",fontVariantNumeric:"tabular-nums"},children:[za(t.size),t.size?" · ":"","öffnen"]})]})]}),v?e.jsx(Js,{f:v,kind:"frame",title:t.name||"PDF",style:{width:"100%",height:250,border:"1px solid var(--line)",borderRadius:10,marginTop:6,background:"var(--panel-2)",display:"block"}}):!m&&e.jsx("iframe",{src:C+"#toolbar=0&view=FitH",title:t.name||"PDF",loading:"lazy",style:{width:"100%",height:250,border:"1px solid var(--line)",borderRadius:10,marginTop:6,background:"var(--panel-2)",display:"block"}})]}):N}function zi({atts:t,mailFiles:r}){return!t||!t.length?null:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:10},children:t.map((a,n)=>e.jsx(cc,{a,mailFiles:r},(a==null?void 0:a.id)||`${(a==null?void 0:a.name)||"anhang"}-${n}`))})}const dc={rot:"#dc2626",gruen:"#16a34a",grün:"#16a34a",blau:"#2563eb",lila:"#7c3aed",orange:"#ea580c",schwarz:"#0f172a",grau:"#64748b"},pc={gelb:"#fef08a",gruen:"#bbf7d0",grün:"#bbf7d0",blau:"#bfdbfe",rosa:"#fbcfe8",pink:"#fbcfe8",orange:"#fed7aa",lila:"#e9d5ff"};function hc(t){return t=(t||"").toLowerCase().trim(),t[0]==="#"?t:dc[t]||"#0f172a"}function gc(t){return t=(t||"").toLowerCase().trim(),t[0]==="#"?t:pc[t]||"#fef08a"}function uc(t,r){const a=[],n=/\*\*([^*]+?)\*\*|==([^=\n]+?)==|\{c:([#\wäöü]+)\|([^}]*)\}|\{h:([#\wäöü]+)\|([^}]*)\}|\*(\S[^*\n]*?)\*/g;let h=0,p,k=0;for(;p=n.exec(t);){p.index>h&&a.push(t.slice(h,p.index));const f=r+"-"+k++;p[1]!=null?a.push(e.jsx("strong",{style:{fontWeight:700},children:p[1]},f)):p[2]!=null?a.push(e.jsx("mark",{style:{background:"#fef08a",color:"inherit",padding:"0 2px",borderRadius:2},children:p[2]},f)):p[3]!=null?a.push(e.jsx("span",{style:{color:hc(p[3])},children:p[4]},f)):p[5]!=null?a.push(e.jsx("mark",{style:{background:gc(p[5]),color:"inherit",padding:"0 2px",borderRadius:2},children:p[6]},f)):p[7]!=null&&a.push(e.jsx("em",{style:{fontStyle:"italic"},children:p[7]},f)),h=n.lastIndex}return h<t.length&&a.push(t.slice(h)),a}function mc(t){const a=(t||"").split(` 109`),n=[];return a.forEach((h,p)=>{p>0&&n.push(` 110`);let k=h,f=0;/^#\s+/.test(h)?(k=h.replace(/^#\s+/,""),f=2):/^##\s+/.test(h)&&(k=h.replace(/^##\s+/,""),f=1);const C=uc(k,"L"+p),m=f===2?{fontSize:15.5,fontWeight:700}:f===1?{fontSize:14,fontWeight:600}:{};n.push(e.jsx("span",{style:m,children:C},"l"+p))}),n}const ss={display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:28,height:28,padding:"0 7px",borderRadius:7,border:"1px solid var(--line)",background:"transparent",curs
110or:"pointer",fontSize:12.5,color:"var(--ink-2)",lineHeight:1,fontFamily:"inherit"};function Qr(t){const r=String(t||"").match(/rgba?\((\d+)[,\s]+(\d+)[,\s]+(\d+)/);return r?"#"+[r[1],r[2],r[3]].map(a=>parseInt(a).toString(16).padStart(2,"0")).join(""):/^#[0-9a-f]{3,8}$/i.test(t)?t:""}function fc(t){const r=a=>{if(a.nodeType===3)return a.textContent||"";if(!a.tagName)return"";const n=a,h=n.tagName;if(h==="BR")return` 111`;let p=Array.from(n.childNodes).map(r).join("");if(!p)return h==="DIV"||h==="P"?` 112`:"";const k=n.style||{},f=h==="B"||h==="STRONG"||k.fontWeight==="bold"||parseInt(k.fontWeight||"0")>=600,C=h==="I"||h==="EM"||k.fontStyle==="italic";f&&p.trim()&&(p="**"+p+"**"),C&&p.trim()&&(p="*"+p+"*");const m=Qr(k.color||n.getAttribute("color")||"");m&&!["#0f172a","#000000","#374151","#1e293b"].includes(m.toLowerCase())&&p.trim()&&(p=`{c:${m}|${p}}`);const v=Qr(k.backgroundColor||"");if((h==="MARK"||v)&&p.trim()){const g=v||"#fef08a";g.toLowerCase()!=="#ffffff"&&(p=`{h:${g}|${p}}`)}return h==="H1"||h==="H2"?` 113# `+p:h==="H3"||h==="H4"?` 114## `+p:h==="DIV"||h==="P"?` 115`+p:p};return Array.from(t.childNodes).map(r).join("").replace(/^\n/,"").replace(/ /g," ")}function xc({value:t,onChange:r,onSubmit:a,editorApi:n,onFiles:h}){const p=l.useRef(null),[k,f]=l.useState(!0),[C,m]=l.useState(!1);l.useEffect(()=>{!t&&p.current&&p.current.innerHTML!==""&&(p.current.innerHTML="",f(!0))},[t]);const v=()=>{const g=p.current;g&&(f(!(g.textContent||"").trim()),r(fc(g)))};return l.useEffect(()=>{n.current={exec:(g,x)=>{const N=p.current;if(N){N.focus();try{document.execCommand("styleWithCSS",!1,"true")}catch{}try{document.execCommand(g,!1,x)}catch{}v()}}}},[]),e.jsxs("div",{style:{position:"relative"},onDragOver:g=>{h&&(g.preventDefault(),C||m(!0))},onDragLeave:g=>{h&&(g.currentTarget.contains(g.relatedTarget)||m(!1))},onDrop:g=>{var N;if(!h)return;g.preventDefault(),m(!1);const x=Array.prototype.slice.call(((N=g.dataTransfer)==null?void 0:N.files)||[]);x.length&&h(x)},children:[k&&!C&&e.jsx("span",{style:{position:"absolute",top:10,left:13,fontSize:12.5,color:"var(--ink-3)",pointerEvents:"none"},children:"Neue Notiz schreibenâ¦"}),C&&e.jsxs("div",{style:{position:"absolute",inset:0,borderRadius:10,background:"rgba(231,243,238,.9)",display:"flex",alignItems:"center",justifyContent:"center",gap:8,pointerEvents:"none",zIndex:2,fontSize:12.5,fontWeight:700,color:"var(--green)"},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:16,height:16},children:[e.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Dateien hier ablegen"]}),e.jsx("div",{ref:p,contentEditable:!0,suppressContentEditableWarning:!0,onInput:v,onBlur:v,onPaste:g=>{var ee;if(!h)return;const N=Array.prototype.slice.call(((ee=g.clipboardData)==null?void 0:ee.items)||[]).filter(le=>le&&le.kind==="file").map(le=>le.getAsFile()).filter(Boolean);N.length&&(g.preventDefault(),h(N))},onKeyDown:g=>{g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&(g.preventDefault(),a())},style:{width:"100%",padding:"10px 12px",borderRadius:10,border:C?"1.5px dashed var(--green)":"1px solid var(--line-2)",fontSize:12.5,fontFamily:"inherit",minHeight:140,boxSizing:"border-box",background:"var(--panel)",color:"var(--ink)",lineHeight:1.6,outline:"none",overflowY:"auto",maxHeight:440,transition:"border-color .12s"}})]})}function yc(t){const r=(t||"").split(` 116`),a=/^\s*(\\?[-*â¢ââ]|\d+[.)]|#{1,2}\s|â|â |â|â|\|)/,n=[];for(const h of r){if(n.length===0){n.push(h);continue}const p=n[n.length-1],k=p.trim(),f=h.trim();f&&k&&!a.test(h)&&!a.test(p)&&!/[.!?:ï¼]$/.test(k)&&k.length>25?n[n.length-1]=p.replace(/\s+$/,"")+" "+f:n.push(h)}return n.join(` 117`)}function vn({text:t,muted:r=!1,bg:a="var(--panel-2)",border:n,padding:h="10px 14px",clampLines:p=5,marginTop:k=0}){const[f,C]=l.useState(!1),m=yc(t||""),v=(m.match(/\n/g)||[]).length+1,g=m.length>320||v>6;return e.jsxs("div",{style:{width:"100%",boxSizing:"border-box",marginTop:k},children:[e.jsx("div",{style:{fontSize:12.5,color:r?"var(--ink-3)":"var(--ink-2)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",background:a,borderRadius:8,padding:h,...n?{border:n}:{},...g&&!f?{display:"-webkit-box",WebkitLineClamp:p,WebkitBoxOrient:"vertical",overflow:"hidden"}:{}},children:mc(m)}),g&&e.jsxs("button",{onClick:()=>C(x=>!x),style:{marginTop:6,background:"none",border:"none",cursor:"pointer",color:"var(--green)",fontSize:11.5,fontWeight:600,padding:"2px 0",display:"inline-flex",alignItems:"center",gap:6},children:[f?"Weniger anzeigen":"Mehr anzeigen",e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{width:12,height:12,transform:f?"rotate(180deg)":"none",transition:"transform .15s"},children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]})}const Bi=["instagram","tiktok","linkedin","facebook","youtube"],Ai={instagram:"Instagram",tiktok:"TikTok",linkedin:"LinkedIn",facebook:"Facebook",youtube:"YouTube"};function bc(t){return t==null?"":typeof t=="string"?t.trim():String(t.handle||t.url||"").trim()}function el(t){const r={};for(const a of Bi){const n=bc(t[a]);n&&(r[a]=n)}return r}function vc(t,r){const a=(r||"").trim();if(!a)return"";if(/^https?:\/\//i.test(a))return a;const n=a.replace(/^@/,"").replace(/^\/+/,"");switch(t){case"instagram":return"https://instagram.com/"+n;case"tiktok":return"https://tiktok.com/@"+n;case"linkedin":return"https://linkedin.com/"+(/^(company|school|in)\//i.test(n)?n:"company/"+n);case"facebook":return"https://facebook.com/"+n;case"youtube":return"https://youtube.com/"+(/^(channel|user|c)\//i.test(n)||n.startsWith("@")?n:"@"+n)}return""}function kc({k:t}){const r={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",style:{width:14,height:14}};switch(t){case"instagram":return e.jsxs("svg",{...r,children:[e.jsx("rect",{x:"2.5",y:"2.5",width:"19",height:"19",rx:"5"}),e.jsx("circle",{cx:"12",cy:"12",r:"4.2"}),e.jsx("circle",{cx:"17.4",cy:"6.6",r:"1.1",fill:"currentColor",stroke:"none"})]});case"tiktok":return e.jsx("svg",{...r,children:e.jsx("path",{d:"M9.5 12.6a3.9 3.9 0 103.9 3.9V3.5c.6 2.6 2.5 4.5 5.1 4.8"})});case"linkedin":return e.jsxs("svg",{...r,children:[e.jsx("rect",{x:"2.5",y:"2.5",width:"19",height:"19",rx:"3"}),e.jsx("line",{x1:"7.2",y1:"10.5",x2:"7.2",y2:"17"}
117),e.jsx("circle",{cx:"7.2",cy:"7.4",r:"0.4",fill:"currentColor"}),e.jsx("path",{d:"M11.2 17v-6.5M11.2 13a2.7 2.7 0 015.4 0v4"})]});case"facebook":return e.jsx("svg",{...r,children:e.jsx("path",{d:"M18 2h-3a5 5 0 00-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 011-1h3z"})});case"youtube":return e.jsxs("svg",{...r,children:[e.jsx("rect",{x:"2.5",y:"5.5",width:"19",height:"13",rx:"3.5"}),e.jsx("path",{d:"M10.5 9.5l4.5 2.5-4.5 2.5z"})]});default:return null}}function jc({leadId:t,goBack:r,currentUser:a}){const[n,h]=l.useState(null),[p,k]=l.useState(!0),[f,C]=l.useState([]),[m,v]=l.useState(!1),[g,x]=l.useState(null),[N,ee]=l.useState(!1),[le,Z]=l.useState(null),[I,B]=l.useState(!1),[j,P]=l.useState(null),[ve,$]=l.useState("alle"),_=l.useRef(new Map),ue=l.useRef(new Map),be=s=>ue.current.get(`${s._via||"dima"}|${s._folder||"INBOX"}|${s.seq}`)||null,ie=s=>{const c=`${s._via||"dima"}|${s._folder||"INBOX"}|${s.seq}`,d=_.current.get(c);if(d)return d;const y=s._folder||"INBOX",D=y==="Sent"?["Sent","INBOX.Sent"]:y==="INBOX"?["INBOX"]:[y,"INBOX","INBOX.Archive","Archive"],w=new Promise(M=>{let te=D.length,L=!1;const Y=ae=>!!ae&&/\*\s*\d+\s+FETCH|BODY\[/i.test(ae)&&!/^\s*T\d+\s+(NO|BAD)\b/.test(ae.trim());D.forEach(ae=>{Ge(`/api/email?user=${s._via||"dima"}&seq=${s.seq}&folder=${encodeURIComponent(ae)}`).then(de=>{!L&&de&&de.raw&&Y(de.raw)&&(L=!0,Array.isArray(de.attachments)&&de.attachments.length&&ue.current.set(c,{user:s._via||"dima",folder:ae,uid:s.seq,atts:de.attachments}),M(de.raw))}).catch(()=>{}).finally(()=>{te--,te===0&&!L&&(L=!0,M("(leer)"))})})});return w.then(M=>{M==="(leer)"&&_.current.delete(c)}),_.current.set(c,w),w},H=(s,c)=>{if(!c||!c.seq)return;const d=setTimeout(()=>{try{ie(c)}catch{}},150);s.currentTarget._pfTimer=d},U=s=>{const c=s.currentTarget._pfTimer;c&&clearTimeout(c)},[F,K]=l.useState(null),[A,ce]=l.useState(!1),[Ve,Xe]=l.useState(!1),[it,ne]=l.useState(!1),[Le,Ue]=l.useState(""),[ct,yt]=l.useState(!1),[rt,De]=l.useState(""),[je,nt]=l.useState(!0),[qe,lt]=l.useState((a==null?void 0:a.key)||""),[gt,Nt]=l.useState(!1),[Ut,Mt]=l.useState(null),[$t,un]=l.useState(""),[Xt,kn]=l.useState(""),[sn,jn]=l.useState(!1),[on,Jt]=l.useState(""),[mn,cn]=l.useState(!1);l.useEffect(()=>{Va()},[]);const[Qt,Gt]=l.useState(new Set),[dt,Rt]=l.useState("verlauf"),[ft,dn]=l.useState(null),[pn,V]=l.useState(!1),[Fe,Ne]=l.useState(null),[mt,Ie]=l.useState(null),[Lt,wn]=l.useState(null),[Zn,In]=l.useState([]),[en,S]=l.useState(!1),[X,we]=l.useState(!1),[Be,pe]=l.useState({}),[_e,Oe]=l.useState([]),[zt,Yt]=l.useState(10),[fn,Dn]=l.useState("alle"),[b,re]=l.useState(""),[he,ge]=l.useState(null),[Te,Ae]=l.useState(!1),[u,J]=l.useState([]),[O,oe]=l.useState(null),[q,se]=l.useState(""),[Ee,Me]=l.useState(""),[pt,Bt]=l.useState(!1);l.useRef(null);const ht=l.useRef({}),[jt,Dt]=l.useState({}),[tn,Ft]=l.useState(!1),[At,Et]=l.useState(null),_t=(s,c)=>{const d=(c||"").trim();Dt(y=>{const D={...y};return d?D[s]=d:delete D[s],D});for(const y of vt.keys())y.includes("/api/crm/social-links")&&vt.delete(y);Ge("/api/crm/social-links",{method:"POST",body:JSON.stringify({leadId:t,overrides:{[s]:d}})}).catch(()=>{})},Un=async()=>{if(tn)return;const s=o(n,i.url);if(!s){Et({art:"fehler",text:"Keine Website hinterlegt â bitte oben eine Website eintragen."});return}Ft(!0),Et({art:"laeuft",text:`Lese ${s.replace(/^https?:\/\/(www\.)?/,"").replace(/\/.*$/,"")} â¦`});try{for(const M of Array.from(vt.keys()))M.includes("/api/crm/social-links")&&vt.delete(M);const c=await Ge(`/api/crm/social-links?url=${encodeURIComponent(s)}&fresh=1&leadId=${encodeURIComponent(t)}`);if(!c||c.error||!c.ok){Et({art:"fehler",text:"Scan fehlgeschlagen: "+(c&&c.error||"keine Antwort vom Server")});return}const d=el(c),y={...jt},D=[];for(const M of Bi)!y[M]&&d[M]&&(y[M]=d[M],D.push(Ai[M]));Dt(y);const w=Bi.filter(M=>d[M]).length;D.length?Et({art:"ok",text:"Gefunden: "+D.join(", ")}):Et(w?{art:"leer",text:"Nichts Neues â die gefundenen Profile stehen schon hier."}:{art:"leer",text:"Auf der Website standen keine Social-Profile."})}catch(c){Et({art:"fehler",text:"Scan fehlgeschlagen: "+((c==null?void 0:c.message)||"Netzwerkfehler")})}finally{Ft(!1)}},Wn=l.useRef(null),[Tn,rs]=l.useState([]),[nn,Kn]=l.useState(!1),[An,Zs]=l.useState([]),[ot,Sn]=l.useState({typ:"ausgehend",dauer:0,ergebnis:"",notiz:"",kontakte:[]}),[Ya,Cl]=l.useState(!1),[Us,Vi]=l.useState(!1),[Ys,Xa]=l.useState(!1),[hn,Ji]=l.useState([]),[Qa,zl]=l.useState(!1),[er,Tc]=l.useState("all"),[Es,Gi]=l.useState(new Set),[Mn,Is]=l.useState(new Set),[Xs,qi]=l.useState(new Set),[tr,nr]=l.useState(!1),[Qs,Zi]=l.useState(null),[Al,El]=l.useState(new Set),[Lc,Il]=l.useState(null),[Bc,Dc]=l.useState(!1),[Wc,Tl]=l.useState(null),[ke,ei]=l.useState(()=>Ti().get(t)||null),[Rn,sr]=l.useState(!1),[ti,Ui]=l.useState(null),[Ll,Yi]=l.useState(!1),[Ts,ni]=l.useState(!1),[ir,ls]=l.useState(!!Ti().get(t)),[si,ii]=l.useState(0);l.useEffect(()=>{Zt(ja,100,0).then(s=>{var D,w,M,te,L;const c=(s.data||[]).filter(Y=>{var ae;return((ae=Y.fields)==null?void 0:ae.rSyAv)===t});c.sort((Y,ae)=>{var de,Pe;return(((de=ae.fields)==null?void 0:de.AflDS)||"").localeCompare(((Pe=Y.fields)==null?void 0:Pe.AflDS)||"")});const d=c.filter(Y=>{var ae;return(((ae=Y.fields)==null?void 0:ae.tfQUn)||"").startsWith("[Upsell]")}),y=c.filter(Y=>{var ae;return!(((ae=Y.fields)==null?void 0:ae.tfQUn)||"").startsWith("[Upsell]")});In(y),y.length>0&&(Ne(((D=y[0].fields)==null?void 0:D.QQR8x)||null),Ie(((w=y[0].fields)==null?void 0:w.AflDS)||null),wn(((M=y[0].fields)==null?void 0:M["4pHjM"])||null)),d.length>0&&(Il(((te=d[0].fields)==null?void 0:te.QQR8x)||null),Tl(((L=d[0].fields)==null?void 0:L.AflDS)||null))}).catch(()=>{})},[t]);const Bl=(s,c)=>{Ne(s),Ie(new Date().toISOString()),wn(c),Gn(ja,{rSyAv:t,tfQUn:o(n,i.displayName)||o(n,i.leadName),QQR8x:s,"4pHjM":c,AflDS:new Date().toISOString()}).then(()=>{Zt(ja,100,0).then(d=>{const y=(d.data||[]).filter(D=>{var w;return((w=D.fields)==null?void 0:w.rSyAv)===t});y.sort((D,w)=>{var M,te;return(((M=w.fields)==null?void 0:M.AflDS)||"").localeCompare(((te=D.fields)==null?void 0:te.AflDS)||"")}),In(y)})}).catch(()=>{})},[Fn,ar]=l.useState([]),[Dl,rr]=l.useState(!1),[os,Xi]=l.useState([]),[Wl,Qi]=l.useState(!1),[xn,ea]=l.useState(null),[Ot,cs]=l.useState([]),[Ml,ta]=l.useState(!1),[lr,or]=l.useState([]),[Rl,cr]=l.useState(!1),[na,Mc]=l.useState("details"),[Rc,Fc]=l.useState(!1),[sa,dr]=l.useState(!1),[Yn,ai]=l.useState(()=>Ua().get(t)||""),[Fl,ds]=l.useState(!1),[Xn,pr]=l.useState(""),[ia,hr]=l.useState(""),[gr,ri]=l.useState(!1);l.useEffect(()=>{let s=!0;ai(""),ds(!1);const c=(a==null?void 0:a.email)||(a==null?void 0:a.id)||"";return c&&fl(c).then(d=>{s&&ai(d.get(t)||"")}).catch(()=>{}),()=>{s=!1}},[t,a==null?void 0:a.id,a==null?void 0:a.email]);const _l=async()=>
117{if(Xn){ri(!0);try{if((await Fa(t,Xn,ia)).legacy){const c=o(n,i.displayName)||o(n,i.leadName)||"Lead",d=String((a==null?void 0:a.email)||"").toLowerCase();await Ge("/api/kalender/event",{method:"POST",body:JSON.stringify({event:{titel:"Wiedervorlage: "+c,typ:"termin",start_ts:Xn+"T09:00:00",ende_ts:Xn+"T09:30:00",user_email:d,personen:d?[d]:[],notiz:ia||"Wiedervorlage aus dem CRM"}})})}else{const c=await fetch(ln+"/api/crm/followups/book",{method:"POST",headers:zs(),body:JSON.stringify({leadId:t,confirm:!0})}),d=await c.json();if(!c.ok||!d.ok)throw new Error(d.error||"Datum gespeichert, Termin konnte noch nicht geplant werden.");if(d.needsReview)throw new Error("Datum gespeichert. "+d.issue)}ai(Xn),ds(!1)}catch(s){alert(s.message||"Wiedervorlage konnte nicht gespeichert werden. Bitte erneut versuchen.")}finally{ri(!1)}}},Ol=async()=>{if(confirm("Diese Wiedervorlage und ihren automatisch geplanten Termin entfernen?")){ri(!0);try{await Fa(t,null),ai(""),ds(!1)}catch(s){alert(s.message||"Wiedervorlage konnte nicht entfernt werden.")}finally{ri(!1)}}},[li,Qn]=l.useState(!1),[ur,aa]=l.useState("dima"),[oi,ps]=l.useState(""),[mr,hs]=l.useState(""),[fr,xr]=l.useState(!1),[ra,Ls]=l.useState(""),[Hn,gs]=l.useState([]),[us,es]=l.useState([]),[yr,ci]=l.useState(!1),[la,Bs]=l.useState(""),[br,Ds]=l.useState(""),[di,pi]=l.useState([]),[hi,vr]=l.useState(!1),[oa,ca]=l.useState(!1),da=l.useRef(null),[kr,jr]=l.useState(!1),Ws=l.useMemo(()=>{const s=new Map;(Ot||[]).forEach(y=>{var w,M;const D=String(((w=y==null?void 0:y.fields)==null?void 0:w.CIy6k)||((M=y==null?void 0:y.fields)==null?void 0:M.z0xSB)||"").toLowerCase().trim();D&&s.set(D,y)});const c=new Set,d=y=>{y&&y!=="liberdamedia.de"&&!pl.has(y)&&c.add(y)};return d(Zo(n?o(n,i.url):"")),d(_i(n?o(n,i.contactEmail):"")),s.forEac
117h((y,D)=>d(_i(D))),{kontaktByEmail:s,leadDomains:c,leadUrl:n?o(n,i.url):"",leadFirma:n?o(n,i.displayName)||o(n,i.leadName):""}},[Ot,n]),ms=(s,c,d=22,y=!1)=>e.jsx(sc,{em:s,isOut:c,size:d,ctx:Ws,gegenseite:y});l.useEffect(()=>{Kt()},[t]);const Kt=async()=>{k(!0);try{const s=await Ge("/api/db/query",{method:"POST",body:JSON.stringify({table:tt,recordId:t,count:1})}),c=((s==null?void 0:s.items)||(s==null?void 0:s.data)||(s==null?void 0:s.records)||[])[0];c&&h(c)}catch(s){console.error(s)}finally{k(!1)}};l.useEffect(()=>{const s=n?o(n,i.closeLeadId):"";if(!s){Ji([]);return}let c=!1;return Ge(`/api/lead-activities?closeLeadId=${encodeURIComponent(s)}`).then(d=>{c||Ji(Array.isArray(d==null?void 0:d.activities)?d.activities:[])}).catch(()=>{c||Ji([])}),()=>{c=!0}},[n&&o(n,i.closeLeadId)]);const[pa,ha]=l.useState({});l.useEffect(()=>{const s=n?o(n,i.closeLeadId):"";if(!s){ha({});return}let c=!1;return Ge(`/api/lead-note-attachments?closeLeadId=${encodeURIComponent(s)}`).then(d=>{c||ha(d!=null&&d.byCaid&&typeof d.byCaid=="object"?d.byCaid:{})}).catch(()=>{c||ha({})}),()=>{c=!0}},[n&&o(n,i.closeLeadId)]);const fs=[{label:"Lead-Daten geladen",icon:"ð"},{label:"Website & Social Media gesucht",icon:"ð"},{label:"Instagram-Auftritt analysiert",icon:"ð¸"},{label:"Branche & Produkte eingestuft",icon:"ð·ï¸"},{label:"Ansprechpartner geprüft",icon:"ð¤"},{label:"Potenzial bewertet",icon:"â¡"},{label:"E-Mail Draft erstellt",icon:"âï¸"}],Pl=async()=>{var D,w,M;if(!n)return;sr(!0),Ui(null),ii(0),ls(!0);let s=0;const c=fs.length-1,y=setInterval(()=>{s+=1,ii(s),s>=c&&clearInterval(y)},550);try{const L=(o(n,i.social)||"").replace(/^https?:\/\/(www\.)?instagram\.com\/?/,"").replace(/^@/,"").split("/")[0],Y={leadId:t,leadName:o(n,i.displayName)||o(n,i.leadName)||"",industry:o(n,i.kategorie)||"",instagramHandle:L,website:o(n,i.url)||"",notes:[o(n,i.wichtig),o(n,i.notiz),o(n,i.description)].filter(Boolean).join(" | "),kategorie:o(n,i.kategorie)||"",kontakt:o(n,i.contactName)||""},ae=await fetch(Qo,{method:"POST",headers:Cs(),body:JSON.stringify(Y)});if(!ae.ok){const Se=await ae.text().catch(()=>"");throw new Error(`Worker error ${ae.status}${Se?": "+Se:""}`)}const de=await ae.json();clearInterval(y),ii(fs.length);const Pe={},st=(o(n,i.social)||"").trim();de.discoveredInstagram&&!st&&(Pe[i.social]=`https://www.instagram.com/${de.discoveredInstagram}/`,Pe[i.aHandle]=de.discoveredInstagram);const R=de.recommendedContact;R&&(R.name&&!o(n,i.contactName)&&(Pe[i.contactName]=R.name),R.firstName&&!o(n,i.contactFirst)&&(Pe[i.contactFirst]=R.firstName),R.lastName&&!o(n,i.contactLast)&&(Pe[i.contactLast]=R.lastName),R.role&&!o(n,i.contactTitle)&&(Pe[i.contactTitle]=R.role),R.email&&!o(n,i.contactEmail)&&(Pe[i.contactEmail]=R.email),R.phone&&!o(n,i.contactPhone)&&(Pe[i.contactPhone]=R.phone));const Ce=de.companyData;Ce&&(Ce.phone&&!o(n,i.telefon)&&(Pe[i.telefon]=Ce.phone),Ce.addressFull&&!o(n,i.addr1)&&(Pe[i.addr1]=Ce.addressFull),Ce.city&&!o(n,i.addrCity)&&(Pe[i.addrCity]=Ce.city),Ce.zip&&!o(n,i.addrZip)&&(Pe[i.addrZip]=Ce.zip));try{const Se=o(n,i.notiz)||"",xt="<!-- LIBERDA-SCAN-START -->",bt="<!-- LIBERDA-SCAN-END -->",Je=[xt,`[Lead-Scan ${new Date(de.scannedAt).toLocaleString("de-DE")}]`,`Score: ${de.score}/100 (${de.potential.toUpperCase()})`,de.discoveredInstagram?`Instagram: @${de.discoveredInstagram}${de.discoveredInstagramSource?` (Quelle: ${de.discoveredInstagramSource})`:""}`:"",de.discoveredYouTube?`YouTube: ${de.discoveredYouTube}`:"",R!=null&&R.name?`Empf. Ansprechpartner: ${R.name}${R.role?` â ${R.role}`:""}${R.email?` <${R.email}>`:""}${R.phone?` Tel: ${R.phone}`:""}`:"",de.discoveredContacts&&de.discoveredContacts.length>0?`Weitere Kontakte (${de.discoveredContacts.length}): ${de.discoveredContacts.map(Ze=>`${Ze.name}${Ze.email?` <${Ze.email}>`:""}${Ze.phone?` ${Ze.phone}`:""}`).join("; ")}`:"",(D=de.outreachStrategy)!=null&&D.bestChannel?`Outreach: ${de.outreachStrategy.bestChannel}${de.outreachStrategy.bestTiming?` (${de.outreachStrategy.bestTiming})`:""}`:"",(w=de.outreachStrategy)!=null&&w.painPoints&&de.outreachStrategy.painPoints.length>0?`Pain Points: ${de.outreachStrategy.painPoints.join("; ")}`:"",(M=de.competitiveContext)!=null&&M.marketPosition?`Marktposition: ${de.competitiveContext.marketPosition}
117`:"",bt].filter(Boolean).join(` 118`),at=Se.replace(new RegExp(`${xt}[\\s\\S]*?${bt}`,"g"),"").trim(),Ke=at?`${at} 119 120${Je}`:Je;Ke!==Se&&(Pe[i.notiz]=Ke)}catch{}if(Object.keys(Pe).length>0)try{await et(tt,t,Pe),Kt()}catch(Se){console.warn("Auto-Persist nach Scan fehlgeschlagen:",Se)}Ca(t,de),ei(de)}catch(te){clearInterval(y),Ui(te.message||"Scan fehlgeschlagen")}finally{sr(!1)}};l.useEffect(()=>{if(!n)return;ic(a==null?void 0:a.key,n),Ms().then(c=>ua(c||[])),Dt({}),Et(null);{const c=o(n,i.url);Ge(`/api/crm/social-links?leadId=${encodeURIComponent(t)}${c?`&url=${encodeURIComponent(c)}`:""}`).then(d=>{if(d&&d.ok){Dt(el(d));return}Et({art:"fehler",text:"Social-Profile nicht ladbar: "+(d&&d.error||"keine Antwort vom Server")})}).catch(d=>Et({art:"fehler",text:"Social-Profile nicht ladbar: "+((d==null?void 0:d.message)||"Netzwerkfehler")}))}Hl(),Rs();const s=setInterval(()=>{if(!(typeof document<"u"&&document.visibilityState!=="visible")){for(const c of vt.keys())(c.includes("/api/inbox?")||c.includes("/api/sent?"))&&vt.delete(c);Ms().then(c=>ua(c||[],!0))}},3e4);return()=>clearInterval(s)},[n]),l.useEffect(()=>{if(dt!=="ki"&&dt!=="analytics")return;const s=(o(n,i.displayName)||o(n,i.leadName)||"").trim();if(!s){ge(null);return}if(he&&he._company===s)return;let c=!1;return Ae(!0),Ge(`/api/sevdesk/lead-revenue?name=${encodeURIComponent(s)}`).then(d=>{c||ge({...d,_company:s})}).catch(()=>{c||ge({found:!1,_company:s,_error:!0})}).finally(()=>{c||Ae(!1)}),()=>{c=!0}},[dt,na,t,n]),l.useEffect(()=>{C([]),cs([]),ar([]),or([]),x(null),Z(null),Qn(!1),Ne(null),ge(null),J([]),Zs([]),Me(""),Vi(!1),Sn({typ:"ausgehend",dauer:0,ergebnis:"",notiz:""}),dn(null),Gi(new Set),qi(new Set),nr(!1);const s=Ti().get(t)||null;ei(s),ls(!!s),Ui(null),ii(0),Yi(!1);try{const c=localStorage.getItem(`lm_notes_${t}`);c&&J(JSON.parse(c));const d=localStorage.getItem(`lm_calls_${t}`);d&&Zs(JSON.parse(d));const y=localStorage.getItem(`lm_score_${t}`);y&&dn(JSON.parse(y));const D=localStorage.getItem(`lm_done_threads_${t}`);D&&Gi(new Set(JSON.parse(D)));const w=localStorage.getItem(`lm_opened_threads_${t}`);w&&qi(new Set(JSON.parse(w)))}catch{}(async()=>{try{const c=await Ge(`/api/crm/lead-log?leadId=${encodeURIComponent(t)}`);if(!c||!c.ok)return;const d=JSON.parse(localStorage.getItem(`lm_notes_${t}`)||"[]"),y=JSON.parse(localStorage.getItem(`lm_calls_${t}`)||"[]"),D=(L,Y)=>{const ae=new Set(L.map(st=>String(st.id))),de=Y.filter(st=>st&&st.id&&!ae.has(String(st.id)));return{list:[...L,...de].sort((st,R)=>new Date(R.date||0).getTime()-new Date(st.date||0).getTime()),missing:de}},w=D(c.notes||[],d),M=D(c.calls||[],y);J(w.list),Zs(M.list);try{localStorage.setItem(`lm_notes_${t}`,JSON.stringify(w.list)),localStorage.setItem(`lm_calls_${t}`,JSON.stringify(M.list))}catch{}const te=[...w.missing,...M.missing.map(L=>({...L,typ:"call"}))];te.length&&Ge("/api/crm/lead-log",{method:"POST",body:JSON.stringify({leadId:t,eintraege:te})}).catch(()=>{})}catch{}})()},[t]);const wr=async()=>{const s=Ee.trim();if(!s&&Tn.length===0)return;Bt(!0);const c={id:Date.now().toString(),text:s,author:_n((a==null?void 0:a.name)||(a==null?void 0:a.key)||"dima"),userKey:(a==null?void 0:a.key)||"dima",date:new Date().toISOString(),atts:Tn},d=[c,...u];J(d);try{localStorage.setItem(`lm_notes_${t}`,JSON.stringify(d))}catch{}if(Ge("/api/crm/lead-log",{method:"POST",body:JSON.stringify({leadId:t,eintrag:c,newContact:!0})}).catch(()=>{}),s){const y=o(n,i.notiz)||"",w=`[${new Date().toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})} â ${c.author}] 121${c.text} 122 123${y}`.trim();try{await et(tt,t,{[i.notiz]:w})}catch{}const M=o(n,i.closeLeadId);if(M)try{await Ge("/api/close/push-note",{method:"POST",body:JSON.stringify({closeLeadId:M,text:c.text,userKey:c.userKey})})}catch(te){console.warn("Close push-note failed (silent):",te)}}Me(""),rs([]),Bt(!1)},Sr=async s=>{const c=(s||[]).filter(Boolean);if(!c.length)return;Kn(!0);const d=[];for(const y of c){if(y.size>25*1024*1024){alert(`"${y.name}" ist zu groà (max. 25 MB).`);continue}try{const D=new FormData;D.append("file",y),D.append("leadId",t||"");const{"Content-Type":w,...M}=Cs(),L=await(await fetch(`${ln}/api/note-file`,{method:"POST",headers:M,body:D})).json();L&&L.ok&&L.url?d.push({name:L.name,content_type:L.content_type,size:L.size,url:L.url}):alert(`Upload fehlgeschlagen: ${L&&L.error||"unbekannt"}`)}catch(D){alert("Upload-Fehler: "+D.message)}}d.length&&rs(y=>[...y,...d]),Kn(!1)},$l=async s=>{const c=Array.prototype.slice.call(s.target.files||[]);await Sr(c);try{s.target.value=""}catch{}},Nr=s=>!s||!s.id||s.caid||/close/i.test(String(s.author||s.autor||""))?!1:!!(s.userKey||s._local),Cr=async(s,c)=>{const d=(c||"").trim();if(!d)return;const y=u.map(w=>w.id===s?{...w,text:d,editedAt:new Date().toISOString()}:w);J(y);try{localStorage.setItem(`lm_notes_${t}`,JSON.stringify(y))}catch{}const D=y.find(w=>w.id===s);D&&Ge("/api/crm/lead-log",{method:"POST",body:JSON.stringify({leadId:t,eintrag:D})}).catch(()=>{}),oe(null),se("")},zr=s=>{if(!window.confirm("Diese Notiz wirklich löschen?"))return;const c=u.filter(d=>d.id!==s);J(c);try{localStorage.setItem(`lm_notes_${t}`,JSON.stringify(c))}catch{}Ge("/api/crm/lead-log",{method:"POST",body:JSON.stringify({leadId:t,id:s,loeschen:!0})}).catch(()=>{}),O===s&&(oe(null),se(""))},Ar=s=>{const c=u.map(y=>y.id===s?{...y,gepinnt:!y.gepinnt}:y);J(c);try{localStorage.setItem(`lm_notes_${t}`,JSON.stringify(c))}catch{}const d=c.find(y=>y.id===s);d&&Ge("/api/crm/lead-log",{method:"POST",body:JSON.stringify({leadId:t,eintrag:d})}).catch(()=>{})},Er=async()=>{Xa(!0);const s={id:Date.now().toString(),typ:ot.typ,dauer:ot.dauer,ergebnis:ot.ergebnis||"Anruf",notiz:ot.notiz,kontakte:ot.kontakte,autor:_n((a==null?void 0:a.name)||(a==null?void 0:a.key)||"dima"),userKey:(a==null?void 0:a.key)||"dima",date:new Date().toISOString()},c=[s,...An];Zs(c),localStorage.setItem(`lm_calls_${t}`,JSON.stringify(c)),Ge("/api/crm/lead-log",{method:"POST",body:JSON.stringify({leadId:t,eintrag:{...s,typ:"call"},newContact:!0})}).catch(()=>{}),Sn({typ:"ausgehend",dauer:0,ergebnis:"",notiz:"",kontakte:[]}),Vi(!1),Xa(!1)};l.useEffect(()=>{var y;if(!n)return;if(Number(o(n,i.aFollower))>0){if(_e.length===0){const D=(o(n,i.aHandle)||((y=o(n,i.social))==null?void 0:y.replace(/.*instagram\.com\//,"").replace(/\/.*$/,""))||"").replace(/^@+/,"").trim();D&&Ge(`/api/social-analyze?handle=${encodeURIComponent(D)}`).then(w=>
123{var M;(M=w.recentPosts)!=null&&M.length&&Oe(w.recentPosts)}).catch(()=>{})}return}const c=o(n,i.social)||"";if(!c.includes("instagram.com"))return;const d=c.replace(/.*instagram\.com\//,"").replace(/\/.*$/,"").replace("@","").trim();d&&(async()=>{var D,w;try{const M=await Ge(`/api/social-analyze?handle=${encodeURIComponent(d)}`);if(M.success&&M.follower>0){const te={[i.aHandle]:`@${d}`,[i.aFollower]:M.follower,[i.aBeitraege]:M.beitraege,[i.aPostsProWoche]:M.postsProWoche,[i.aEngagement]:M.engagementRate,[i.aReelsAnteil]:M.reelsAnteil,[i.aFotosAnteil]:M.fotosAnteil,[i.aKarussellsAnteil]:M.karussellsAnteil,[i.aDurchschnittViews]:M.avgViews,[i.aTopViews]:M.topViews,[i.aDatum]:new Date().toISOString().split("T")[0],[i.aAktiv]:!0};(D=M.reelViews)!=null&&D.length&&(te[i.aReelViews]=JSON.stringify(M.reelViews)),M.profilePic&&(te[i.aHeroImage]=M.profilePic),(w=M.recentPosts)!=null&&w.length&&Oe(M.recentPosts),await et(tt,t,te),vt.clear(),await Kt()}}catch{}})()},[n==null?void 0:n.id]);const Ms=async()=>{var s,c;ta(!0);try{const d=o(n,i.closeLeadId),y=(o(n,i.displayName)||o(n,i.leadName)||"").trim().toLowerCase();if(!d&&!y)return cs([]),ta(!1),[];const D=await Hi(),w=d?D.byLeadId.get(d)||[]:[],M=y?D.byCompany.get(y)||[]:[],te=new Set(w.map(ae=>ae.id)),L=[...w];for(const ae of M)te.has(ae.id)||(te.add(ae.id),L.push(ae));try{const ae=await Zt(Ri,100,0),de=new Set((ae.data||[]).map(Pe=>{var st;return(((st=Pe.fields)==null?void 0:st[Fi])||"").toLowerCase()}).filter(Boolean));for(const Pe of L){const st=(((s=Pe.fields)==null?void 0:s.CIy6k)||((c=Pe.fields)==null?void 0:c.z0xSB)||"").toLowerCase();st&&de.has(st)&&(Pe._hasDashboard=!0)}}catch{}const Y=_o(L.reverse(),o(n,i.kontaktReihenfolge));return cs(Y),Y}catch(d){return console.error("[CRM] Fehler beim Laden der Kontakte:",d),cs([]),[]}finally{ta(!1)}};l.useEffect(()=>n?Ja(()=>{Ms()},{immediate:!1}):void 0,[n]);const Rs=async()=>{cr(!0);try{const s=[];for(let M=0;M<1500;M+=200){const te=await Zt(Cn,200,M),L=(te==null?void 0:te.data)||[];if(s.push(...L),L.length<200)break}const c=(o(n,i.closeLeadId)||"").trim(),d=n==null?void 0:n.id,y=(o(n,i.displayName)||o(n,i.leadName)||"").toLowerCase().trim(),w=s.filter(M=>{const te=M.fields||{},L=te[He.leadLink];if(Array.isArray(L)&&d&&L.some(ae=>((ae==null?void 0:ae.id)||ae)===d))return!0;if(c){const ae=te[He.closeId];if(Array.isArray(ae)&&ae.some(de=>String(de).includes(c))||typeof te[He.leadIdText]=="string"&&te[He.leadIdText].includes(c))return!0}const Y=(te.fUJ5C||"").toLowerCase().trim();return y.length>=4&&Y===y}).map((M,te)=>{const L=M.fields||{};return{id:M.id||`todo-${te}`,text:L[He.task]||"Aufgabe",subline:L[He.subline]||"",done:L[He.completed]===!0,urgent:L[He.urgent]===!0,date:L[He.deadline]||L[He.date]||"",assignee:Array.isArray(L[He.assignee])?L[He.assignee][0]||"":L[He.assignee]||""}}).sort((M,te)=>(te.date||"").localeCompare(M.date||""));or(w)}catch(s){console.error(s)}finally{cr(!1)}};l.useEffect(()=>{n&&dt==="files"&&Kl()},[n,na,Ot.length]);const Kl=async()=>{var s,c,d;Qi(!0);try{const y=["gmail.com","googlemail.com","yahoo.com","hotmail.com","outlook.com","web.de","gmx.de","gmx.net","t-online.de","icloud.com"],D=new Set,w=(s=o(n,i.contactEmail))==null?void 0:s.toLowerCase();w&&D.add(w);for(const Y of Ot||[]){const ae=(((c=Y.fields)==null?void 0:c.CIy6k)||((d=Y.fields)==null?void 0:d.z0xSB)||"").toLowerCase();ae&&D.add(ae)}const M=new Set;for(const Y of D){const ae=(Y.split("@")[1]||"").toLowerCase();ae&&!y.includes(ae)&&M.add(ae)}if(D.size===0&&M.size===0){Xi([]),Qi(!1);return}const te=new URLSearchParams;M.size&&te.set("domains",[...M].join(",")),D.size&&te.set("addrs",[...D].join(","));const L=await Ge(`/api/lead-files?${te.toString()}`);Xi(Array.isArray(L.files)?L.files:[])}catch(y){console.error(y),Xi([])}finally{Qi(!1)}},Hl=async()=>{const s=o(n,i.displayName)||o(n,i.leadName);if(s){rr(!0);try{let c=[],d=0;for(;;){const L=(await Zt($a,100,d)).data||[];if(c=[...c,...L],L.length<100||(d+=100,d>500))break}const y=s.toLowerCase().replace(/gmbh|kg|e\.k\.|co\.|&|\.|ag|ohg|gbr|mbh|inc|ltd|ug/gi,"").trim(),D=o(n,i.closeLeadId),w=c.filter(te=>{var Pe,st,R;const L=((Pe=te.fields)==null?void 0:Pe.PnwQt)||"";if(D&&L&&L===D)return!0;const Y=(st=te.fields)==null?void 0:st.aUyUZ,ae=((Y==null?void 0:Y.label)||(Array.isArray(Y)?(R=Y[0])==null?void 0:R.label:"")||"").toLowerCase().replace(/gmbh|kg|e\.k\.|co\.|&|\.|ag|ohg|gbr|mbh|inc|ltd|ug/gi,"").trim();if(!ae||!y)return!1;const de=Math.min(y.length,ae.length,12);return ae.substring(0,de)===y.substring(0,de)||ae.includes(y.substring(0,10))||y.includes(ae.substring(0,10))}),M=te=>{var L;return new Date(((L=te.fields)==null?void 0:L.sJWgj)||te.createdAt||0).getTime()||0};w.sort((te,L)=>M(L)-M(te)),ar(w)}catch(c){console.error(c)}finally{rr(!1)}}},Vl=s=>({messageId:s.messageId,subject:s.subject,date:s.date,from:s.from,fromName:s.fromName,from
123Email:s.fromEmail,to:s.to,toEmail:s.toEmail,toName:s.toName,read:s.read,opened:s.opened,_opened:s._opened,seq:s.seq,uid:s.uid,_via:s._via,_folder:s._folder,_sent:s._sent,direction:s.direction,snippet:(s.snippet||s.preview||s.bodyPreview||"").slice(0,200)}),ga=(s,c)=>{const d=JSON.stringify({t:Date.now(),m:c.slice(0,250).map(Vl)});try{localStorage.setItem(s,d)}catch{try{Object.keys(localStorage).filter(y=>y.startsWith("crmMails:")).forEach(y=>localStorage.removeItem(y)),localStorage.setItem(s,d)}catch{}}},ua=async(s=[],c=!1)=>{var xt,bt,Je,at;const d=(xt=o(n,i.contactEmail))==null?void 0:xt.toLowerCase(),y=(bt=o(n,i.displayName)||o(n,i.leadName))==null?void 0:bt.toLowerCase();if(!d&&!y){C([]),v(!1);return}const D="crmMails:"+((n==null?void 0:n.id)||d||y);let w=!1;if(!c)try{const Ke=JSON.parse(localStorage.getItem(D)||"null");Ke&&Array.isArray(Ke.m)&&Ke.m.length&&(C(Ke.m),v(!1),w=!0)}catch{}!c&&!w&&v(!0);const M=[],te=new Set,L=d?d.split("@")[0]:"",Y=d?d.split("@")[1]:"",ae=["gmail.com","googlemail.com","yahoo.com","hotmail.com","outlook.com","web.de","gmx.de","gmx.net","t-online.de","icloud.com"],de=Ke=>{const Ze=(Ke.messageId||"")+"|"+(Ke.subject||"").substring(0,40)+"|"+(Ke.date||"");te.has(Ze)||(te.add(Ze),M.push(Ke))},Pe=new Set;d&&Pe.add(d);for(const Ke of s){const Ze=(((Je=Ke.fields)==null?void 0:Je.CIy6k)||((at=Ke.fields)==null?void 0:at.z0xSB)||"").toLowerCase();Ze&&Pe.add(Ze)}const R=["info","kontakt","office","mail","team","hallo","hello","support","service","contact","post","noreply","no-reply","admin","empfang","zentrale","anfrage","bewerbung","jobs","career","marketing","sales","presse","press","media","buchhaltung","invoice","rechnung"].includes(L),Ce=Ke=>{const Ze=(Ke.fromEmail||Ke.from||"").toLowerCase(),T=(Ke.to||Ke.toEmail||"").toLowerCase();for(const me of Pe)if(Ze.includes(me)||T.includes(me))return!0;return!!(Y&&!ae.includes(Y)&&(Ze.split("@")[1]||"")===Y||!R&&L&&L.length>5&&Ze.includes(L+"@"))};try{const Ke=new Set;Y&&!ae.includes(Y)&&Ke.add(Y);for(const me of Pe){const E=(me.split("@")[1]||"").toLowerCase();E&&!ae.includes(E)&&Ke.add(E)}const Ze=[...Ke].join(","),T=[...Pe].join(",");if(Ze||T){const me=new URLSearchParams;Ze&&me.set("domains",Ze),T&&me.set("addrs",T),c&&me.set("fresh","1");const E=await Ge(`/api/mail/company-search?${me.toString()}`);if(E&&E.success&&Array.isArray(E.messages)){const Ye=z=>{const W=z.map(G=>({...G,_sent:/sent|gesendet/i.test(G._folder||"")}));return W.sort((G,ze)=>new Date(ze.date).getTime()-new Date(G.date).getTime()),W},Re=Ye(E.messages);C(Re),v(!1),ga(D,Re),E.cached&&!c&&(async()=>{try{me.set("fresh","1");const z=await Ge(`/api/mail/company-search?${me.toString()}`);if(z&&z.success&&Array.isArray(z.messages)){const W=Ye(z.messages);C(W),ga(D,W)}}catch{}})();return}}}catch{}const Se=wt.map(Ke=>{const Ze=["INBOX"],T=["INBOX.Archive","Archive"],E=[...Ze,...T].map(Re=>Ge(`/api/inbox?user=${Ke.key}&limit=200&folder=${encodeURIComponent(Re)}`).then(z=>{(z.messages||[]).forEach(W=>{Ce(W)&&(W._via=Ke.key,W._folder=Re,de(W))})}).catch(()=>{})),Ye=Ge(`/api/sent?user=${Ke.key}&limit=200`).then(Re=>{(Re.messages||[]).forEach(z=>{Ce(z)&&(z._via=Ke.key,z._sent=!0,z._folder="Sent",de(z))})}).catch(()=>{});return Promise.all([...E,Ye])});await Promise.all(Se),M.sort((Ke,Ze)=>new Date(Ze.date).getTime()-new Date(Ke.date).getTime()),C(M),v(!1),ga(D,M)},Ir=async s=>{const c=(s||[]).filter(Boolean);if(!c.length)return;vr(!0);const d=[];for(const y of c){if(y.size>15*1024*1024){alert(`"${y.name}" ist zu groà (max. 15 MB pro Anhang).`);continue}try{const D=new FormData;D.append("file",y),D.append("leadId",t||"");const{"Content-Type":w,...M}=Cs(),L=await(await fetch(`${ln}/api/note-file`,{method:"POST",headers:M,body:D})).json();L&&L.ok&&L.url?d.push({name:L.name,content_type:L.content_type,size:L.size,url:L.url}):alert(`Upload fehlgeschlagen: ${L&&L.error||"unbekannt"}`)}catch(D){alert("Upload-Fehler: "+D.message)}}d.length&&pi(y=>[...y,...d]),vr(!1)},Jl=async s=>{const c=Array.prototype.slice.call(s.target.files||[]);await Ir(c);try{s.target.value=""}catch{}},ma=(s,c)=>{const d=String(s||"").split(/[,;\s]+/).map(D=>D.trim()).filter(D=>/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(D));return d.length?((c==="to"?gs:es)(D=>Array.from(new Set([...D,...d.map(w=>w.toLowerCase())]))),!0):!1},Gl=async()=>
123{const s=Hn.filter(Boolean);if(!(!s.length||!oi)){xr(!0),Ls("");try{const c=await Ge("/api/send",{method:"POST",body:JSON.stringify({user:ur,leadId:t,to:s,cc:us.length?us:void 0,subject:oi,body:mr.replace(/\n/g,"<br>"),attachments:di.length?di.map(d=>({url:d.url,name:d.name,content_type:d.content_type})):void 0})});c.success?(Ls("Gesendet!"),Qn(!1),ps(""),hs(""),pi([]),es([]),Bs(""),Ds(""),ua()):Ls("Fehler: "+(c.error||"?"))}catch(c){Ls("Fehler: "+c.message)}finally{xr(!1)}}};if(l.useEffect(()=>{li&&gs(s=>{if(s.length)return s;const c=String(o(n,i.contactEmail)||"").trim().toLowerCase();return c?[c]:[]})},[li,n]),l.useEffect(()=>{gs([]),es([]),pi([]),Bs(""),Ds(""),ci(!1)},[t]),l.useEffect(()=>{const s=d=>{d&&(d.leadId&&String(d.leadId)!==String(t)||(Lo(),Qn(!0),Array.isArray(d.an)&&d.an.length&&gs(d.an.map(y=>String(y).toLowerCase())),Array.isArray(d.cc)&&d.cc.length&&(es(d.cc.map(y=>String(y).toLowerCase())),ci(!0)),ps(d.betreff||""),hs(d.text||""),Ls("Entwurf von Conny â bitte prüfen, Absender wählen und selbst senden.")))};s(Wi());const c=d=>s(d&&d.detail||Wi());return window.addEventListener(Di,c),()=>window.removeEventListener(Di,c)},[t]),p)return e.jsx("div",{className:"cs-main",children:e.jsxs("div",{className:"cs-detail",children:[e.jsxs("div",{className:"cs-detail-header",style:{padding:"20px 24px",display:"flex",alignItems:"center",gap:16},children:[e.jsx("div",{onClick:r,style:{cursor:"pointer",fontSize:18,color:"var(--ink-3)"},children:"â"}
123),e.jsx("div",{className:"cs-skel",style:{width:42,height:42,borderRadius:"50%"}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{className:"cs-skel",style:{width:200,height:18,marginBottom:6}}),e.jsx("div",{className:"cs-skel",style:{width:140,height:12}})]}),e.jsx("div",{className:"cs-skel",style:{width:80,height:28,borderRadius:8}})]}),e.jsxs("div",{className:"cs-detail-body",style:{display:"grid",gridTemplateColumns:"320px 1fr",gap:0},children:[e.jsx("div",{style:{padding:20,borderRight:"1px solid var(--line)"},children:[1,2,3].map(s=>e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{className:"cs-skel",style:{width:80,height:10,marginBottom:10}}),e.jsx("div",{className:"cs-skel",style:{width:"100%",height:14,marginBottom:6}}),e.jsx("div",{className:"cs-skel",style:{width:"70%",height:14,marginBottom:6}}),e.jsx("div",{className:"cs-skel",style:{width:"85%",height:14}})]},s))}),e.jsxs("div",{style:{padding:20},children:[e.jsx("div",{style:{display:"flex",gap:8,marginBottom:20},children:[1,2,3,4,5].map(s=>e.jsx("div",{className:"cs-skel",style:{width:70,height:28,borderRadius:8}},s))}),[1,2,3,4,5].map(s=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 0",borderBottom:"1px solid var(--line)"},children:[e.jsx("div",{className:"cs-skel",style:{width:26,height:26,borderRadius:"50%"}}),e.jsx("div",{className:"cs-skel",style:{width:60,height:12}}),e.jsx("div",{className:"cs-skel",style:{flex:1,height:12}}),e.jsx("div",{className:"cs-skel",style:{width:50,height:10}})]},s))]})]})]})});if(!n)return e.jsx("div",{className:"cs-main",children:e.jsx("div",{className:"cs-empty",children:"Nicht gefunden."})});const qt=o(n,i.displayName)||o(n,i.leadName),gi=ut(n,i.statusLabel),Fs=o(n,i.contactName),Tr=o(n,i.contactTitle),Vn=o(n,i.contactEmail),_s=o(n,i.contactPhone)||o(n,i.telefon),ts=o(n,i.url);[o(n,i.addr1),[o(n,i.addrZip),o(n,i.addrCity)].filter(Boolean).join(" ")].filter(Boolean).join(", ");const ql=o(n,i.description),Lr=o(n,i.kategorie),Br=o(n,i.kundennr),ui=ut(n,i.ownerName),fa=o(n,i.wichtig),xa=o(n,i.notiz);return e.jsxs("div",{className:"cs-main cs-detail",children:[e.jsxs("div",{className:"cs-detail-topbar",children:[e.jsx("button",{className:"cs-btn-icon-only cs-back",onClick:r,children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"19",y1:"12",x2:"5",y2:"12"}),e.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),e.jsxs("div",{className:"cs-detail-identity",children:[e.jsx("div",{className:"cs-detail-logo",children:o(n,i.url)?e.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${o(n,i.url).replace(/^https?:\/\//,"").replace(/\/.*$/,"")}&sz=128`,alt:"",loading:"lazy",decoding:"async",style:{width:"100%",height:"100%",objectFit:"contain"},onError:s=>{s.target.style.display="none",s.target.parentElement.textContent=(qt==null?void 0:qt.charAt(0))||"?"}}):(qt==null?void 0:qt.charAt(0))||"?"}),e.jsxs("div",{children:[e.jsx("h1",{className:"cs-detail-name",children:qt}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[gi&&e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("span",{className:"cs-status cs-status-pill cs-status-clickable",style:{color:"var(--ink)"},onClick:()=>jr(!kr),children:[e.jsx("span",{className:"cs-dot",style:{background:$n(gi)}}),Za(gi)," â¾"]}),kr&&e.jsx("div",{className:"cs-status-dropdown",children:ml.map(s=>e.jsxs("button",{className:"cs-status-option",onClick:async()=>{jr(!1),await et(tt,t,{[i.statusLabel]:s.label});const c=o(n,i.closeLeadId);if(c)try{await Ge("/api/close/push-status",{method:"POST",body:JSON.stringify({closeLeadId:c,statusLabel:s.label})})}catch(d){console.warn("Close push-status failed (silent):",d)}Kt()},children:[e.jsx("span",{className:"cs-dot",style:{background:s.color}}),s.label]},s.label))})]}),o(n,i.dateUpdated)&&(()=>{const s=is(o(n,i.dateUpdated));return s===null||s<1?null:e.jsxs("span",{title:`Status zuletzt geändert: ${new Date(o(n,i.dateUpdated)).toLocaleDateString("de")}`,style:{...ye,...xe,fontSize:11.5},children:[s,"T im Status"]})})(),o(n,i.lastCommDate)&&(()=>{const s=is(o(n,i.lastCommDate));return s===null?null:e.jsxs("span",{title:`Letzter Kontakt: ${new Date(o(n,i.lastCommDate)).toLocaleDateString("de")}`,style:{...rn,...xe},children:[e.jsx("span",{style:{...Qe,background:yl(s)}}),xl(s)," seit Kontakt"]})})()]})]})]}),e.jsx("button",{onClick:()=>
123{hr(""),pr(Yn||new Date(Date.now()+2*864e5).toISOString().slice(0,10)),ds(!0)},title:Yn?"Wiedervorlage am "+St(Yn):"Wiedervorlage setzen",style:{width:34,height:34,borderRadius:"50%",border:"1px solid "+(Yn?"var(--green)":"var(--line)"),background:Yn?"var(--sel)":"var(--panel)",color:Yn?"var(--green)":"var(--ink-2)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0,padding:0},children:e.jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),e.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"}),e.jsx("path",{d:"M9 16l2 2 4-4"})]})}),Fl&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(15,23,42,.45)",zIndex:300,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>ds(!1),children:e.jsxs("div",{style:{background:"var(--panel)",borderRadius:16,border:"1px solid var(--line)",padding:22,width:340,maxWidth:"92vw",boxShadow:"0 18px 50px rgba(15,23,42,.18)"},onClick:s=>s.stopPropagation(),children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,color:"var(--ink)",marginBottom:12},children:"Wiedervorlage"}),e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Datum"}),e.jsx("input",{type:"date",className:"cs-input",min:new Date().toISOString().slice(0,10),value:Xn,onChange:s=>pr(s.target.value),style:{width:"100%",marginBottom:12,boxSizing:"border-box"}}),e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Notiz (optional)"}),e.jsx("input",{className:"cs-input",placeholder:"Worum geht es?",value:ia,onChange:s=>hr(s.target.value),style:{width:"100%",marginBottom:16,boxSizing:"border-box"}}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("button",{className:"cs-btn-primary",onClick:_l,disabled:gr||!Xn,children:gr?"Speichertâ¦":"Speichern + Kalender"}),Yn&&e.jsx("button",{className:"cs-btn-outline",onClick:Ol,children:"Entfernen"}),e.jsx("button",{className:"cs-btn-outline",style:{marginLeft:"auto"},onClick:()=>ds(!1),children:"Abbrechen"})]}),e.jsx("p",{style:{fontSize:11,color:"var(--ink-3)",margin:"12px 0 0",lineHeight:1.5},children:"Setzt die Wiedervorlage in der Leads-Tabelle und legt dir einen Termin (9:00 Uhr) im Dashboard-Kalender an."})]})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[ke&&!Rn&&e.jsxs("span",{style:{...rn,...xe,cursor:"pointer"},onClick:()=>ls(!ir),title:"Scan-Ergebnis anzeigen",children:[e.jsx("span",{style:{...Qe,background:ke.potential==="hoch"?"var(--green)":ke.potential==="mittel"?"#92610A":"var(--red)"}}),ke.score,"/100"]}),e.jsx("button",{onClick:Rn?void 0:Pl,style:{...Ei,padding:"7px 13px",cursor:Rn?"default":"pointer",opacity:Rn?.6:1},children:Rn?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{width:12,height:12,border:"2px solid var(--green-bd)",borderTopColor:"var(--green)",borderRadius:"50%",display:"inline-block",animation:"lm-spin 0.7s linear infinite"}}),"Analysiereâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.35-4.35M11 8v6M8 11h6"})]}),ke?"Neu scannen":"Lead scannen"]})})]})]}),(()=>{const s=(o(n,i.contactPhone)||o(n,i.telefon)||"").trim();return s?e.jsx("div",{style:{display:"flex",gap:8,padding:"0 26px 12px",flexWrap:"wrap"},children:e.jsxs("a",{href:`tel:${s}`,style:{...as,textDecoration:"none"},children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",style:{width:13,height:13},children:e.jsx("path",{d:"M22 16.9v3a2 2 0 01-2.2 2 19.8 19.8 0 01-8.6-3.1 19.5 19.5 0 01-6-6A19.8 19.8 0 012.1 4.2 2 2 0 014.1 2h3a2 2 0 012 1.7c.1 1 .4 1.9.7 2.8a2 2 0 01-.5 2.1L8.1 9.9a16 16 0 006 6l1.3-1.2a2 2 0 012.1-.5c.9.3 1.8.6 2.8.7a2 2 0 011.7 2z"})}),"Anrufen"]})}):null})(),ir&&(Rn||ke||ti)&&(()=>{var d,y,D,w,M,te;const s=tc((ke==null?void 0:ke.potential)||"niedrig"),c=ec((ke==null?void 0:ke.potential)||"niedrig");return e.jsxs("div",{style:{margin:"0 26px 16px",borderRadius:13,border:`1px solid ${s.border}`,background:s.bg,overflow:"hidden auto",maxHeight:"calc(100vh - 220p
123x)"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 15px",borderBottom:`1px solid ${s.border}`},children:Rn?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{width:20,height:20,border:"2px solid var(--line-2)",borderTopColor:"var(--green)",borderRadius:"50%",display:"inline-block",animation:"lm-spin 0.7s linear infinite",flexShrink:0}}),e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--green)"},children:si<fs.length?((d=fs[si])==null?void 0:d.label)||"Analysiereâ¦":"Abgeschlossen"}),e.jsx("button",{onClick:()=>ls(!1),style:{...zn,marginLeft:"auto"},children:"â"})]}):ti?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{...Qe,background:"var(--red)"}}),e.jsx("span",{style:{fontSize:13,color:"var(--red)",fontWeight:600},children:ti}),e.jsx("button",{onClick:()=>ls(!1),style:{...zn,marginLeft:"auto"},children:"â"})]}):ke?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{width:64,height:64,borderRadius:"50%",background:"var(--panel)",border:`1px solid ${c.border}`,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexShrink:0},children:[e.jsx("span",{style:{...xe,fontSize:22,fontWeight:800,color:c.color,lineHeight:1,letterSpacing:"-.024em"},children:ke.score}),e.jsx("span",{style:{...fe,fontSize:10,color:c.color,marginTop:2},children:"Score"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--ink)",letterSpacing:"-.012em"},children:ke.potential==="hoch"?"Sehr gute Eignung für uns":ke.potential==="mittel"?"Mittlere Eignung":"Kein Potenzial"}),e.jsxs("div",{style:ye,children:["Gescannt ",new Date(ke.scannedAt).toLocaleDateString("de",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"})]})]}),e.jsx("span",{style:{marginLeft:"auto",...an,fontWeight:800,color:String(nc(ke.potential).background||"var(--ink)")},children:ke.potential.toUpperCase()}),e.jsx("button",{onClick:()=>ls(!1),style:{...zn,marginLeft:4},children:"â"})]}):null}),Rn&&e.jsx("div",{style:{padding:"14px 16px"},children:fs.map((L,Y)=>{const ae=Y<si,de=Y===si;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"7px 0",borderBottom:Y<fs.length-1?"1px solid var(--line)":"none",opacity:ae||de?1:.4,transition:"opacity 0.4s ease"},children:[e.jsx("div",{style:{width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:ae?"var(--green-soft)":"var(--panel)",border:`1px solid ${ae||de?"var(--green-bd)":"var(--line)"}`,transition:"all 0.3s ease"},children:ae?e.jsx("svg",{viewBox:"0 0 12 12",width:"10",height:"10",fill:"none",stroke:"var(--green)",strokeWidth:"2",children:e.jsx("polyline",{points:"2,6 5,9 10,3"})}):de?e.jsx("span",{style:{width:8,height:8,border:"1.5px solid var(--green-bd)",borderTopColor:"var(--green)",borderRadius:"50%",display:"inline-block",animation:"lm-spin 0.7s linear infinite"}}):e.jsx("span",{style:{...xe,fontSize:9.5,fontWeight:700,color:"var(--ink-3)"},children:Y+1})}),e.jsx("span",{style:{fontSize:12.5,fontWeight:de||ae?700:600,color:ae?"var(--green)":de?"var(--ink)":"var(--ink-3)",transition:"color 0.3s ease"},children:L.label}),de&&e.jsx("span",{style:{...ye,marginLeft:"auto",color:"var(--green)",animation:"lm-pulse 1.5s ease infinite"},children:"läuftâ¦"})]},Y)})}),!Rn&&!ti&&ke&&e.jsxs("div",{style:{padding:"14px 16px"},children:[ke.discoveredInstagram&&(o(n,i.social)||"").includes(ke.discoveredInstagram)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 14px",borderRadius:10,background:"var(--panel)",border:"1px solid var(--line)",marginBottom:12,fontSize:12.5,color:"var(--ink-2)"},children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),e.jsxs("span",{children:["Instagram gefunden & gespeichert: ",e.jsxs("strong",{style:{color:"var(--ink)"},children:["@",ke.discoveredInstagram]})]})]}),ke.discoveredInstagram&&!(o(n,i.social)||"").includes(ke.discoveredInstagram)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 14px",borderRadius:10,background:"var(--panel)",border:"1px solid var(--line)",marginBottom:12,fontSize:12.5,color:"var(--ink-2)"},children:[e.jsx("span",{style:{...Qe,background:"#1D4ED8"}}),e.jsxs("span",{children:["Instagram entdeckt: ",e.jsxs("strong",{style:{color:"var(--ink)"},children:["@",ke.discoveredInstagram]})," â wird beim nächsten Laden gespeichert."]})]}),!ke.discoveredInstagram&&!(o(n,i.social)||"").includes("instagram")&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 14px",borderRadius:10,background:"var(--panel)",border:"1px solid var(--line)",marginBottom:12,fontSize:12.5,color:"var(--ink-2)"},children:[e.jsx("span",{style:{...Qe,background:"#92610A"}}),e.jsx("span",{children:'Kein Instagram gefunden â bitte manuell im Feld âSocial Media" ergänzen für bessere Analyse.'})]}),e.jsx("div",{style:{...fe,marginBottom:8},children:"Warum passt dieser Lead?"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:14},children:ke.reasoning.map((L,Y)=>e.jsxs("div",{style:{display:"flex",gap:8,fontSize:12.5,color:"var(--ink-2)",lineHeight:1.5},children:[e.jsx("span",{style:{...Qe,background:c.color,marginTop:6}}),e.jsx("span",{children:L})]},Y))}),ke.onlinePresence&&e.jsxs("div",{style:{background:"var(--panel)",borderRadius:13,padding:"12px 15px",marginBottom:12,border:"1px solid var(--line)"},children:[e.jsx("div",{style:{...fe,marginBottom:8},children:"Online-Präsenz"}),e.jsx("div",{style:{display:"flex",gap:14,flexWrap:"wrap",marginBottom:8},children:[{key:"instagram",label:"Instagram"},{key:"youtube",label:"YouTube"},{key:"website",label:"Website"}].map(({key:L,label:Y})=>{const ae=ke.onlinePresence[L];return e.jsxs("span",{style:rn,children:[e.jsx("span",{style:{...Qe,background:ae?"var(--green)":"var(--red)"}}),Y]},L)})}),ke.onlinePresence.summary&&e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",lineHeight:1.55},children:ke.onlinePresence.summary}),ke.discoveredYouTube&&e.jsx("div",{style:{fontSize:11.5,color:"var(--ink-2)",marginTop:6},children:e.jsx("a",{href:ke.discoveredYouTube,target:"_blank",rel:"noreferrer",style:{color:"var(--green)",fontWeight:600},children:ke.discoveredYouTube.replace("https://www.youtube.com/","youtube.com/")})}),ke.serviceGaps&&ke.serviceGaps.length>0&&e.jsxs("div",{style:{...ki,marginTop:12},children:[e.jsx("div",{style:{...fe,marginBottom:7},children:"Lücken / Potenzial"}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column"},children:ke.serviceGaps.map((L,Y,ae)=>e.jsxs("li",{style:{display:"flex",gap:8,fontSize:12.5,color:"var(--ink-2)",lineHeight:1.45,padding:"7px 0",borderBottom:Y<ae.length-1?"1px solid var(--line)":"none"},children:[e.jsx("span",{style:{flexShrink:0,fontWeight:700,color:"#92610A"},children:"+"}),e.jsx("span",{children:L})]},Y))})]})]}),(((y=ke.recommendedContact)==null?void 0:y.name)||((D=ke.discoveredContacts)==null?void 0:D.length))&&e.jsxs("div",{style:{background:"var(--panel)",borderRadius:13,padding:"12px 15px",marginBottom:12,border:"1px solid var(--line)"},children:[e.jsx("div",{style:{...fe,marginBottom:8},children:"Gefundene Kontakte"}),((w=ke.recommendedContact)==null?void 0:w.name)&&e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",ga
123p:9,padding:"9px 0",borderBottom:"1px solid var(--line)"},children:[e.jsx("span",{style:{...Qe,background:"#5B21B6",marginTop:6}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:[ke.recommendedContact.name," ",e.jsxs("span",{style:{color:"var(--ink-3)",fontWeight:600},children:["· ",ke.recommendedContact.role]})]}),ke.recommendedContact.email&&e.jsx("div",{style:{fontSize:11.5,color:"var(--green)",fontWeight:600},children:ke.recommendedContact.email}),ke.recommendedContact.reason&&e.jsx("div",{style:{...ye,marginTop:3},children:ke.recommendedContact.reason})]}),e.jsx("span",{style:{...an,flexShrink:0,marginTop:3,color:"#5B21B6"},children:"Empfohlen"})]}),(M=ke.discoveredContacts)==null?void 0:M.filter(L=>{var Y;return L.name!==((Y=ke.recommendedContact)==null?void 0:Y.name)}).map((L,Y,ae)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"8px 0",borderBottom:Y<ae.length-1?"1px solid var(--line)":"none"},children:[e.jsx("span",{style:{...Qe,background:"var(--ink-3)"}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:12.5,fontWeight:700,color:"var(--ink)"},children:L.name}),e.jsxs("span",{style:{fontSize:11.5,color:"var(--ink-3)",fontWeight:600},children:[" · ",L.role]}),L.email&&e.jsxs("span",{style:{fontSize:11.5,color:"var(--green)",fontWeight:600},children:[" · ",L.email]})]})]},Y)),ke.recommendedSenderUs&&e.jsxs("div",{style:{...ki,marginTop:10,fontSize:12.5,color:"var(--ink-2)"},children:[e.jsx("strong",{style:{color:"var(--ink)"},children:"Von uns:"})," Diese E-Mail sollte unser ",e.jsx("strong",{style:{color:"var(--ink)"},children:ke.recommendedSenderUs})," senden."]})]}),ke.entryPackage&&e.jsxs("div",{style:{background:"var(--panel)",borderRadius:13,padding:"12px 15px",marginBottom:12,border:"1px solid var(--line)"},children:[e.jsx("div",{style:{...fe,marginBottom:7},children:"Einsteiger-Paket Idee"}),e.jsxs("div",{style:{fontSize:14,fontWeight:700,color:"var(--ink)",marginBottom:5,letterSpacing:"-.012em"},children:[ke.entryPackage.name," · ",e.jsxs("span",{style:{...xe,color:"var(--gold-text)",fontWeight:800},children:[ke.entryPackage.price,"â¬"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:12,marginBottom:8},children:ke.entryPackage.services.map((L,Y)=>e.jsxs("span",{style:rn,children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),L]},Y))}),e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",lineHeight:1.55},children:ke.entryPackage.pitch})]}),((te=ke.recommendedServices)==null?void 0:te.length)>0&&e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("div",{style:{...fe,marginBottom:8},children:"Empfohlene Services"}),e.jsx("ul",{style:{...Tt,listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column"},children:ke.recommendedServices.map((L,Y,ae)=>e.jsxs("li",{style:{display:"flex",gap:10,alignItems:"flex-start",fontSize:12.5,color:"var(--ink-2)",lineHeight:1.45,padding:"9px 14px",borderBottom:Y<ae.length-1?"1px solid var(--line)":"none"},children:[e.jsx("span",{style:{flexShrink:0,color:"var(--green)",fontWeight:700},children:"â"}),e.jsx("span",{style:{fontWeight:600},children:L})]},Y))})]}),ke.warning&&e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,padding:"9px 14px",background:"var(--panel)",border:"1px solid var(--line)",borderRadius:10,fontSize:12.5,color:"var(--ink-2)",marginBottom:12,lineHeight:1.5},children:[e.jsx("span",{style:{...Qe,background:"#92610A",marginTop:6}}),e.jsx("span",{children:ke.warning})]}),ke.potential!=="niedrig"&&e.jsxs("div",{style:{marginBottom:12},children:[!ke.emailBody&&!Ts&&e.jsx("button",{onClick:async()=>{var L,Y;ni(!0);try{const de=await(await fetch(`${ln}/api/lead-scan/email`,{method:"POST",headers:zs(),body:JSON.stringify({leadName:o(n,i.displayName)||o(n,i.leadName),industry:o(n,i.kategorie)||o(n,i.brancheField),instagramHandle:ke.discoveredInstagram||o(n,i.aHandle),website:o(n,i.url),youtube:ke.discoveredYouTube,recommendedContact:ke.recommendedContact,painPoints:((L=ke.outreachStrategy)==null?void 0:L.painPoints)||[],recommendedServices:ke.recommendedServices||[],summary:((Y=ke.onlinePresence)==null?void 0:Y.summary)||""})})).json();if(de.subject&&de.body){const Pe={...ke,emailSubject:de.subject,emailBody:de.body};ei(Pe),Ca(t,Pe)}else alert("Email-Draft fehlgeschlagen: "+(de.error||"Unbekannt"))}catch(ae){alert("Email-Draft fehlgeschlagen: "+ae.message)}finally{ni(!1)}},style:{...Ei,padding:"9px 16px"},children:"Personalisierte Email generieren"}),Ts&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 15px",borderRadius:10,border:"1px solid var(--line)",background:"var(--panel)",color:"var(--ink-2)",fontSize:12.5,fontWeight:600},children:[e.jsx("span",{style:{width:12,height:12,border:"2px s
123olid var(--green-bd)",borderTopColor:"var(--green)",borderRadius:"50%",display:"inline-block",animation:"lm-spin 0.7s linear infinite"}}),e.jsx("span",{children:"Generiere Email-Draftâ¦"})]}),ke.emailBody&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{...fe,marginBottom:8},children:"Personalisierter E-Mail-Entwurf"}),e.jsxs("div",{style:{background:"var(--panel)",borderRadius:13,border:"1px solid var(--line)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 15px",borderBottom:"1px solid var(--line)"},children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),e.jsx("span",{style:fe,children:"Entwurf · bereit zum Anpassen"})]}),e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--ink)",padding:"11px 15px 4px",letterSpacing:"-.012em"},children:ke.emailSubject}),e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",lineHeight:1.7,padding:"4px 15px 13px",whiteSpace:"pre-wrap"},children:ke.emailBody}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 15px",borderTop:"1px solid var(--line)",flexWrap:"wrap"},children:[e.jsx("button",{onClick:async()=>{const L=`Betreff: ${ke.emailSubject} 124 125${ke.emailBody}`;try{await navigator.clipboard.writeText(L),Yi(!0),setTimeout(()=>Yi(!1),2e3)}catch{}},style:{...as,padding:"6px 12px",fontSize:11.5},children:Ll?"Kopiert":"Kopieren"}),e.jsx("button",{disabled:Ts,onClick:async()=>{var L,Y;ni(!0);try{const de=await(await fetch(`${ln}/api/lead-scan/email`,{method:"POST",headers:zs(),body:JSON.stringify({leadName:o(n,i.displayName)||o(n,i.leadName),industry:o(n,i.kategorie)||o(n,i.brancheField),instagramHandle:ke.discoveredInstagram||o(n,i.aHandle),website:o(n,i.url),youtube:ke.discoveredYouTube,recommendedContact:ke.recommendedContact,painPoints:((L=ke.outreachStrategy)==null?void 0:L.painPoints)||[],recommendedServices:ke.recommendedServices||[],summary:((Y=ke.onlinePresence)==null?void 0:Y.summary)||""})})).json();if(de.subject&&de.body){const Pe={...ke,emailSubject:de.subject,emailBody:de.body};ei(Pe),Ca(t,Pe)}else alert("Re-Generate fehlgeschlagen: "+(de.error||"Unbekannt"))}catch(ae){alert("Re-Generate fehlgeschlagen: "+ae.message)}finally{ni(!1)}},style:{...Ei,padding:"6px 12px",fontSize:11.5,cursor:Ts?"wait":"pointer"},children:Ts?"â¦":"Neu generieren"}),e.jsx("span",{style:{...ye,marginLeft:"auto"},children:"KI-generiert · claude-haiku"})]})]})]})]}),ke.potential==="niedrig"&&e.jsx("div",{style:{display:"flex",gap:8,marginTop:4},children:e.jsx("button",{onClick:()=>et(tt,t,{[i.statusLabel]:"nicht abgeschlossen"}).then(()=>Kt()),style:{...Pi,padding:"7px 13px",fontSize:11.5,fontWeight:700,border:"1px solid var(--line)",background:"var(--red-soft)",color:"var(--red)"},children:'Als âKein Potenzial" markieren'})})]})]})})(),e.jsxs("div",{className:"cs-detail-body",children:[e.jsx("div",{className:"cs-detail-left"+(sa?" cs-detail-left--collapsed":""),children:na==="details"&&e.jsxs(e.Fragment,{children:[e.jsxs(Ci,{icon:"",title:"ABOUT",defaultOpen:!0,children:[e.jsxs("div",{className:"cs-about-row",style:{alignItems:"flex-start"},children:[e.jsx("span",{className:"cs-about-ic",style:{marginTop:2},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:14,height:14},children:[e.jsx("path",{d:"M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0118 0z"}),e.jsx("circle",{cx:"12",cy:"10",r:"3"})]})}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx(Vt,{value:o(n,i.addr1),onSave:s=>et(tt,t,{[i.addr1]:s}),placeholder:"StraÃe & Hausnummer hinzufügen..."}),e.jsxs("div",{className:"cs-about-sub",style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("span",{style:{flex:"0 0 66px"},children:e.jsx(Vt,{value:o(n,i.addrZip),onSave:s=>et(tt,t,{[i.addrZip]:s}),placeholder:"PLZ"})}),e.jsx("span",{style:{minWidth:0,flex:1},children:e.jsx(Vt,{value:o(n,i.addrCity),onSave:s=>et(tt,t,{[i.addrCity]:s}),placeholder:"Ort"})})]})]})]}),e.jsxs("div",{className:"cs-about-row",children:[e.jsx("span",{className:"cs-about-ic",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:14,height:14},children:[e.jsx("path",{d:"M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"}),e.jsx("path",{d:"M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"})]})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[e.jsx(Vt,{value:ts,onSave:s=>et(tt,t,{[i.url]:(s||"").trim()}),placeholder:"Website hinzufügen..."}),ts&&e.jsx("a",{href:ts.startsWith("http")?ts:`https://${ts}`,target:"_blank",rel:"noopener noreferrer",className:"cs-link",title:"Website öffnen",style:{display:"inline-flex",flexShrink:0},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{width:11,height:11},children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})]}),e.jsx("button",{className:"cs-social-scan",title:ts?tn?"Scan läuft â¦":"Socials von der Website ziehen":"Erst eine Website eintragen",disabled:tn||!ts,onClick:Un,children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{width:12,height:12,animation:tn?"cs-spin 1s linear infinite":void 0},children:[e.jsx("path",{d:"M21 12a9 9 0 11-2.64-6.36"}),e.jsx("polyline",{points:"21 3 21 9 15 9"})]})})]}),At&&e.jsxs("div",{className:"cs-about-row",children:[e.jsx("span",{className:"cs-about-ic"}),e.jsxs("span",{style:{...rn,color:At.art==="fehler"?"var(--red)":At.art==="ok"?"var(--green)":"var(--ink-3)"},children:[e.jsx("span",{style:{...Qe,background:At.art==="fehler"?"var(--red)":At.art==="ok"?"var(--green)":"var(--ink-3)"}}),At.text]})]}),Bi.map(s=>{const c=vc(s,jt[s]||"");return e.jsxs("div",{className:"cs-about-row",children:[e.jsx("span",{className:"cs-about-ic",title:Ai[s],children:e.jsx(kc,{k:s})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[e.jsx(Vt,{value:jt[s]||"",onSave:d=>_t(s,d),placeholder:`${Ai[s]} hinzufügen...`}),jt[s]&&c&&e.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"cs-link",title:`${Ai[s]} öffnen`,style:{display:"inline-flex",flexShrink:0},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{width:11,height:11},children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})]})]},s)}),e.jsxs("div",{className:"cs-about-row",style:{alignItems:"flex-start"},children:[e.jsx("span",{className:"cs-about-ic",style:{marginTop:4},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:14,height:14},children:[e.jsx("line",{x1:"17",y1:"10",x2:"3",y2:"10"}),e.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),e.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"}),e.jsx("line",{x1:"17",y1:"18",x2:"3",y2:"18"})]})}),e.jsx(Vt,{value:ql,onSave:s=>et(tt,t,{[i.description]:s}),placeholder:"Beschreibung hinzufügen...",multiline:!0})]})]}),(()=>{const s=lr.map(E=>
125({id:E.id,text:E.text||"Aufgabe",subline:E.subline||"",done:!!E.done,urgent:!!E.urgent,date:E.date||"",assignee:E.assignee||"",editable:!0})),c=new Set(s.map(E=>(E.text||"").trim())),d=hn.filter(E=>E.type==="task").filter(E=>!c.has((E.body||E.title||"Aufgabe").substring(0,120).trim())).slice().sort((E,Ye)=>(Ye.date||"").localeCompare(E.date||"")).map(E=>({id:E.id,text:(E.body||E.title||"Aufgabe").substring(0,120),subline:"",done:E.disposition==="erledigt",urgent:!1,date:E.date||"",assignee:E.author||"",editable:!1})),y=[...s,...d],D=y.filter(E=>!E.done).length,w=y.filter(E=>!E.done),M=Date.now(),te=E=>{const Ye=E.date?new Date(E.date).getTime():0;return!!Ye&&M-Ye>30*864e5},L=w.filter(te).length,Y=A?w:w.filter(E=>!te(E)),ae=E=>{var Re;const Ye=(E||"").toLowerCase();return Ye&&((Re=wt.find(z=>Ye.includes(z.key)||Ye.includes(z.name.toLowerCase().split(" ")[0])))==null?void 0:Re.key)||""},de=E=>{const Ye=wt.find(Re=>Re.key===E);return Ye&&Ye.recordId?[{id:Ye.recordId}]:null},Pe=E=>{Mt(E.id),un(E.text||""),kn((E.date||"").slice(0,10)),jn(!!E.urgent),Jt(ae(E.assignee))},st=()=>{Mt(null),cn(!1)},R=async E=>{const Ye=$t.trim();if(!Ye||mn)return;cn(!0);const Re={[He.task]:Ye,[He.urgent]:!!sn,[He.deadline]:Xt?new Date(Xt).toISOString():null};if(on){const z=de(on);z&&(Re[He.assigneeLink]=z)}else Re[He.assigneeLink]=[];Mt(null);try{await et(Cn,E.id,Re),await Rs()}catch(z){console.error(z),alert("Ãnderung konnte nicht gespeichert werden.")}finally{cn(!1)}},Ce=(E,Ye)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[E&&e.jsx(It,{userKey:E,size:22}),e.jsxs("select",{value:E,onChange:Re=>Ye(Re.target.value),title:"Person zuweisen",style:{...Ct,width:"auto",padding:"6px 8px",fontSize:11.5,color:"var(--ink-2)"},children:[e.jsx("option",{value:"",children:"niemand"}),wt.map(Re=>e.jsx("option",{value:Re.key,children:Re.name},Re.key))]})]}),Se=async(E,Ye)=>{var ze,$e,Q;const Re=(o(n,i.closeLeadId)||"").trim(),z={[He.task]:E.text,[He.completed]:Ye};E.subline&&(z[He.subline]=E.subline),Re&&(z[He.leadIdText]=Re);const W=await Gn(Cn,z),G=(($e=(ze=W==null?void 0:W.data)==null?void 0:ze.data)==null?void 0:$e.id)||((Q=W==null?void 0:W.data)==null?void 0:Q.id)||(W==null?void 0:W.id);if(G&&(n!=null&&n.id))try{await et(Cn,G,{[He.leadLink]:[{id:n.id}]})}catch{}},xt=async E=>{try{E.editable?await et(Cn,E.id,{[He.completed]:!E.done}):await Se(E,!E.done),await Rs()}catch(Ye){console.error(Ye),alert("Konnte nicht gespeichert werden.")}},bt=async E=>{if(E.editable){Pe(E);return}try{await Se(E,E.done),await Rs()}catch(Ye){console.error(Ye),alert("Konnte nicht umgewandelt werden.")}},Je=E=>{if(E.editable&&Ut===E.id)return e.jsxs("div",{style:{padding:"11px 12px",margin:"2px 0",background:"var(--panel-2)",border:"1px solid var(--line)",borderRadius:10},children:[e.jsx("input",{autoFocus:!0,value:$t,onChange:z=>un(z.target.value),placeholder:"Was ist zu tun?",onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),R(E)),z.key==="Escape"&&st()},style:{...Ct,boxSizing:"border-box"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8,flexWrap:"wrap"},children:[e.jsx("input",{type:"date",value:Xt,onChange:z=>kn(z.target.value),title:"Fällig am (optional)",style:{...Ct,width:"auto",padding:"6px 9px",fontSize:11.5,color:"var(--ink-2)"}}),Ce(on,Jt),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11.5,fontWeight:600,color:"var(--ink-2)",cursor:"pointer",userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:sn,onChange:z=>jn(z.target.checked)})," dringlich"]}),e.jsx("span",{style:{flex:1}}),e.jsx("button",{onClick:st,disabled:mn,style:{border:"none",background:"none",color:"var(--ink-3)",fontSize:11.5,fontWeight:600,cursor:"pointer",padding:"6px 6px",fontFamily:"inherit"},children:"Abbrechen"}),e.jsx("button",{onClick:()=>R(E),disabled:mn||!$t.trim(),style:{...Pn,padding:"7px 14px",fontSize:11.5,cursor:$t.trim()?"pointer":"default",opacity:$t.trim()?1:.45},children:mn?"â¦":"Speichern"})]})]},E.id);const Ye=E.date?new Date(E.date):null,Re=Ye&&!isNaN(Ye.getTime())?Ye.toLocaleDateString("de",{day:"2-digit",month:"short",year:"2-digit"}):"";return e.jsxs("div",{className:"cs-task-inline",style:{alignItems:"flex-start",opacity:E.done?.45:1},children:[e.jsx("input",{type:"checkbox",checked:E.done,onChange:()=>xt(E),title:E.done?"Als offen markieren":"Als erledigt markieren",style:{marginTop:3,cursor:"pointer",flexShrink:0,width:14,height:14,accentColor:"var(--green)"}}),e.jsx("span",{className:"cs-task-inline-dot",style:{background:E.done?"var(--line-2)":E.urgent?"var(--red)":void 0,marginTop:5}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{className:"cs-task-inline-text",style:E.done?{textDecoration:"line-through",color:"var(--ink-3)"}:void 0,children:E.text}),E.subline&&e.jsx("div",{style:{fontSize:11.5,color:"var(--ink-3)",marginTop:2,lineHeight:1.35,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:E.subline}),(E.assignee||E.urgent)&&e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",marginTop:2},children:[E.urgent&&!E.done&&e.jsx("span",{style:{...an,color:"var(--red)"},children:"Dringend"}),E.assignee&&(()=>{const z=js(E.assignee);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,opacity:E.done?.55:1},title:`Zugewiesen: ${E.assignee}`,children:[z?e.jsx(It,{userKey:z.key,size:18}):e.jsx(Ii,{name:E.assignee,size:18,fontSize:8}),e.jsx("span",{style:{...ye,fontSize:11},children:E.assignee})]})})()]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0,marginTop:1},children:[Re&&e.jsx("span",{style:{...ye,...xe,fontSize:11,whiteSpace:"nowrap"},children:Re}),e.jsx("button",{onClick:()=>bt(E),title:E.editable?"Aufgabe bearbeiten":"In bearbeitbare Aufgabe umwandeln",className:"cs-task-edit-btn",style:{...zn,width:24,height:24,borderRadius:7,color:"var(--ink-3)"},children:"â"})]})]},E.id)},at=(o(n,i.closeLeadId)||"").trim(),Ke=async()=>{var Ye,Re,z,W;const E=Le.trim();if(!(!E||gt)){Nt(!0);try{const G={[He.task]:E,[He.completed]:!1,[He.urgent]:!!ct,[He.date]:new Date().toISOString(),fUJ5C:qt||""};if(at&&(G[He.leadIdText]=at),rt){const We=new Date(rt);isNaN(We.getTime())||(G[He.deadline]=We.toISOString())}const ze=qe?de(qe):null;ze&&(G[He.assigneeLink]=ze);const $e=await Gn(Cn,G),Q=($e==null?void 0:$e.id)||((Ye=$e==null?void 0:$e.record)==null?void 0:Ye.id)||((Re=$e==null?void 0:$e.data)==null?void 0:Re.id)||((W=(z=$e==null?void 0:$e.records)==null?void 0:z[0])==null?void 0:W.id);if(Q&&(n!=null&&n.id))try{await et(Cn,Q,{[He.leadLink]:[n.id]})}catch{}if(je&&rt)try{const We=rt.replace(/-/g,""),Pt=new Date(new Date(rt).getTime()+864e5).toISOString().slice(0,10).replace(/-/g,"");window.open(`https://calendar.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(E+(qt?" · "+qt:""))}&dates=${We}/${Pt}
125&details=${encodeURIComponent("Aufgabe aus dem LIBERDA CRM"+(n!=null&&n.id?` 126https://app.liberdamedia.de/crm?lead=`+n.id:""))}`,"_blank")}catch{}Ue(""),yt(!1),De(""),lt((a==null?void 0:a.key)||""),ne(!1),await Rs()}catch(G){console.error(G),alert("Aufgabe konnte nicht gespeichert werden.")}finally{Nt(!1)}}},Ze=()=>{ne(!1),Ue(""),yt(!1),De(""),lt((a==null?void 0:a.key)||"")},T=it?e.jsxs("div",{style:{padding:"11px 12px",margin:"2px 0 8px",background:"var(--panel-2)",border:"1px solid var(--line)",borderRadius:10},children:[e.jsx("input",{autoFocus:!0,value:Le,onChange:E=>Ue(E.target.value),placeholder:"Was ist zu tun?",onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),Ke()),E.key==="Escape"&&Ze()},style:{...Ct,boxSizing:"border-box"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8,flexWrap:"wrap"},children:[e.jsx("input",{type:"date",value:rt,onChange:E=>De(E.target.value),title:"Fällig am (optional)",style:{...Ct,width:"auto",padding:"6px 9px",fontSize:11.5,color:"var(--ink-2)"}}),Ce(qe,lt),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11.5,fontWeight:600,color:"var(--ink-2)",cursor:"pointer",userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:ct,onChange:E=>yt(E.target.checked)})," dringlich"]}),e.jsxs("label",{title:"Beim Speichern vorbefüllten Google-Kalender-Termin öffnen (braucht Fälligkeitsdatum)",style:{display:"flex",alignItems:"center",gap:6,fontSize:11.5,fontWeight:600,color:"var(--ink-2)",cursor:"pointer",userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:je,onChange:E=>nt(E.target.checked)})," Google Kalender"]}),e.jsx("span",{style:{flex:1}}),e.jsx("button",{onClick:Ze,disabled:gt,style:{border:"none",background:"none",color:"var(--ink-3)",fontSize:11.5,fontWeight:600,cursor:"pointer",padding:"6px 6px",fontFamily:"inherit"},children:"Abbrechen"}),e.jsx("button",{onClick:Ke,disabled:gt||!Le.trim(),style:{...Pn,padding:"7px 14px",fontSize:11.5,cursor:Le.trim()?"pointer":"default",opacity:Le.trim()?1:.45},children:gt?"â¦":"Speichern"})]})]}):null,me=it?null:e.jsx("button",{onClick:()=>{Xe(!0),lt((a==null?void 0:a.key)||""),ne(!0)},style:{display:"flex",alignItems:"center",gap:6,width:"100%",background:"none",border:"none",cursor:"pointer",padding:"8px 20px 4px 40px",color:"var(--green)",fontSize:11.5,fontWeight:700,fontFamily:"inherit"},children:"Aufgabe hinzufügen"});return e.jsxs(Ci,{icon:"",title:"Aufgaben",count:D||void 0,open:Ve,onOpenChange:Xe,extra:e.jsx("span",{className:"cs-section-plus",title:"Aufgabe hinzufügen",onClick:E=>{E.stopPropagation(),Xe(!0),lt((a==null?void 0:a.key)||""),ne(!0)},children:"+"}),children:[T,Rl&&y.length===0?e.jsx("div",{style:{padding:"6px 0"},children:[1,2].map(E=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 0"},children:[e.jsx("div",{className:"cs-skel",style:{width:14,height:14,borderRadius:6}}),e.jsx("div",{className:"cs-skel",style:{flex:1,height:11}})]},E))}):y.length>0?e.jsxs(e.Fragment,{children:[Y.length>0?Y.map(Je):e.jsx("div",{className:"cs-section-info cs-muted",children:"Keine offenen Aufgaben"}),L>0&&e.jsx("button",{onClick:()=>ce(E=>!E),style:{display:"block",width:"100%",textAlign:"left",padding:"7px 20px 7px 40px",background:"none",border:"none",cursor:"pointer",fontSize:11.5,fontWeight:700,color:"var(--green)",fontFamily:"inherit"},children:A?"â´ Ãltere ausblenden":`â¾ ${L} ältere ${L===1?"Aufgabe":"Aufgaben"} anzeigen`}),me]}):Number(o(n,i.numTasks))>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cs-section-info",children:[o(n,i.numTasks)," Aufgaben"]}),me]}):e.jsxs(e.Fragment,{children:[!it&&e.jsx("div",{className:"cs-section-info cs-muted",children:"Keine Aufgaben"}),me]})]})})(),e.jsx(Ci,{icon:"",title:"KONTAKTE",count:Ot.length||(Fs?1:0),defaultOpen:!0,extra:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cs-section-search",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",style:{width:12,height:12},children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),e.jsx("span",{className:"cs-section-plus",onClick:s=>{s.stopPropagation();const c=prompt("Name des neuen Kontakts:");if(!c)return;const d=prompt("E-Mail-Adresse (optional):")||"",y=prompt("Telefonnummer (optional):")||"";Gn(ws,{"707oq":c,CIy6k:d,ZPNw4:y,"4Fk6j":qt,uH2Ib:o(n,i.closeLeadId)}).then(async()=>{await Zr(),Ms()})},children:"+"})]}),children:Ml?e.jsx("div",{style:{padding:"6px 0"},children:[1,2].map(s=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 0"},children:[e.jsx("div",{className:"cs-skel",style:{width:28,height:28,borderRadius:"50%"}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{className:"cs-skel",style:{width:"60%",height:11,marginBottom:4}}),e.jsx("div",{className:"cs-skel",style:{width:"40%",height:9}})]})]},s))}):Ot.length>0?Ot.map((s,c)=>{var te,L,Y,ae,de,Pe,st,R,Ce,Se,xt,bt;const d=((te=s.fields)==null?void 0:te["707oq"])||((L=s.fields)==null?void 0:L["5OGPi"])||"",y=((Y=s.fields)==null?void 0:Y["6MXsn"])||((ae=s.fields)==null?void 0:ae.nm24F)||"",D=((de=s.fields)==null?void 0:de.CIy6k)||((Pe=s.fields)==null?void 0:Pe.z0xSB)||"",w=((st=s.fields)==null?void 0:st.ZPNw4)||((R=s.fields)==null?void 0:R["7wKMA"])||"",M=Al.has(c);return e.jsxs("div",{className:"cs-contact-card",draggable:!0,onDragStart:()=>Zi(c),onDragOver:Je=>{Je.preventDefault(),Je.currentTarget.style.borderTop="2px solid var(--green)"},onDragLeave:Je=>{Je.currentTarget.style.borderTop=""},onDrop:Je=>{if(Je.preventDefault(),Je.currentTarget.style.borderTop="",Qs===null||Qs===c)return;const at=[...Ot],[Ke]=at.splice(Qs,1);
126at.splice(c,0,Ke),cs(at),Zi(null),t&&et(tt,t,{[i.kontaktReihenfolge]:JSON.stringify(at.map(Ze=>Ze.id).filter(Boolean))}).catch(()=>{})},onDragEnd:()=>Zi(null),style:{cursor:"pointer",opacity:Qs===c?.4:1,transition:"opacity .15s"},children:[e.jsxs("div",{className:"cs-contact-row",onClick:()=>El(Je=>Je.has(c)?new Set:new Set([c])),children:[e.jsx("span",{style:{color:"var(--line-2)",fontSize:10,cursor:"grab",flexShrink:0,lineHeight:1,userSelect:"none"},children:"â ¿"}),e.jsx(En,{contactId:s.id,name:d,email:D,company:qt,leadUrl:o(n,i.url),storedAvatar:(Ce=s.fields)==null?void 0:Ce.Hb2om,size:24}),e.jsxs("div",{className:"cs-contact-left",style:{flex:1,minWidth:0},children:[e.jsx("span",{className:"cs-contact-name-link",children:d||"â"}),y&&e.jsx("span",{className:"cs-contact-role-edit",style:{...ye,display:"block"},children:y})]}),e.jsxs("div",{className:"cs-contact-actions",onClick:Je=>Je.stopPropagation(),children:[D&&e.jsx("a",{href:`/postfach?an=${encodeURIComponent(D)}`,className:"cs-contact-action",title:D,children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),e.jsx("polyline",{points:"22,6 12,13 2,6"})]})}),w&&e.jsx("a",{href:`tel:${w}`,className:"cs-contact-action",title:w,children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.5 19.5 0 01-6-6A19.79 19.79 0 014.11 2h3a2 2 0 012 1.72 11.04 11.04 0 00.7 2.81 2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45 11.04 11.04 0 002.81.7A2 2 0 0122 16.92z"})})}),w&&(()=>{const Je=Mo(w);return e.jsx("a",{href:`https://wa.me/${Je}`,target:"_blank",rel:"noopener noreferrer",className:"cs-contact-action",title:`WhatsApp (+${Je})`,children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:14,height:14},children:e.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})})})})()]})]}),M&&e.jsxs("div",{className:"cs-contact-details",style:{animation:"csSlideDown .18s ease"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"14px 0 16px",marginLeft:-36,borderTop:"1px solid var(--line)",marginTop:4},children:[e.jsx(En,{contactId:s.id,name:d,email:D,company:qt,leadUrl:o(n,i.url),storedAvatar:(Se=s.fields)==null?void 0:Se.Hb2om,size:200,radius:16}),e.jsx("span",{style:{fontSize:15,fontWeight:800,color:"var(--ink)",textAlign:"center",lineHeight:1.25,letterSpacing:"-.016em",marginTop:2},children:d||"â"}),y&&e.jsx("span",{style:{fontSize:12.5,color:"var(--ink-3)",fontWeight:600,textAlign:"center",lineHeight:1.4,maxWidth:260,padding:"0 8px"},children:y})]}),e.jsxs("div",{className:"cs-contact-detail",children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:12,height:12,flexShrink:0,color:"var(--ink-3)"},children:[e.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),e.jsx("polyline",{points:"22,6 12,13 2,6"})]}),e.jsx(Vt,{value:D,onSave:Je=>et(ws,s.id,{CIy6k:Je}),placeholder:"E-Mail...",className:"cs-contact-detail-edit"})]}),e.jsxs("div",{className:"cs-contact-detail",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:12,height:12,flexShrink:0,color:"var(--ink-3)"},children:e.jsx("path",{d:"M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.5 19.5 0 01-6-6A19.79 19.79 0 014.11 2h3a2 2 0 012 1.72 11.04 11.04 0 00.7 2.81 2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45 11.04 11.04 0 002.81.7A2 2 0 0122 16.92z"})}),e.jsx(Vt,{value:w,onSave:Je=>et(ws,s.id,{ZPNw4:Je}),placeholder:"Telefon...",className:"cs-contact-detail-edit"})]}),e.jsxs("div",{className:"cs-contact-detail",style:{alignItems:"flex-start"},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:12,height:12,flexShrink:0,color:"var(--ink-3)",marginTop:2},children:[e.jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx(Vt,{value:((xt=s.fields)==null?void 0:xt.LeBV9)||((bt=s.fields)==null?void 0:bt["3Xvbe"])||"",onSave:Je=>et(ws,s.id,{LeBV9:Je}),placeholder:"Notiz...",className:"cs-contact-detail-edit"})]}),e.jsx("div",{className:"cs-contact-detail",style:{marginTop:4},children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:12,fontWeight:600,color:"var(--ink-2)"},children:[e.jsx("input",{type:"checkbox",checked:!!s._hasDashboard,style:{accentColor:"var(--green)",width:14,height:14,cursor:"pointer"},onChange:async Je=>{if(Je.target.checked){if(!D){alert("Bitte zuerst eine E-Mail-Adresse hinterlegen.");return}if(!confirm(`Dashboard-Zugang für "${d}" (${D}) erstellen?`))return;try{await Gn(Ri,{[Vo]:d,[Fi]:D,iYILa:qt,OMBQo:qt});const at=[...Ot];at[c]={...s,_hasDashboard:!0},cs(at)}catch(at){alert("Fehler: "+at.message)}}else Je.target.checked=!0,alert("Dashboard-Zugang kann im Admin-Bereich deaktiviert werden.")}}),"Dashboard-Zugang"]})}),e.jsx("div",{className:"cs-contact-detail",style:{marginTop:4},children:e.jsxs("button",{style:{display:"flex",alignItems:"center",gap:5,background:"none",border:"none",cursor:"pointer",fontSize:11.5,fontWeight:600,color:"var(--ink-3)",padding:0,transition:"color .15s",fontFamily:"inherit"},onMouseEnter:Je=>{Je.currentTarget.style.color="var(--red)"},onMouseLeave:Je=>{Je.currentTarget.style.color="var(--ink-3)"},onClick:async()=>
126{if(confirm(`Kontakt "${d}" wirklich löschen?`))try{await Ge("/api/db/mutate",{method:"POST",body:JSON.stringify({method:"delete",table:ws,recordId:s.id})}),await Zr(),Ms()}catch(Je){alert("Fehler: "+Je.message)}},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:12,height:12},children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]}),"Kontakt löschen"]})})]})]},s.id||c)}):Fs?e.jsxs("div",{className:"cs-contact-card",children:[e.jsxs("div",{className:"cs-contact-row",children:[e.jsx(Ga,{email:Vn,name:Fs,size:28,dashboardOnly:!0,placeholder:ul}),e.jsxs("div",{className:"cs-contact-left",style:{flex:1,minWidth:0},children:[e.jsx("div",{className:"cs-contact-name-link",children:Fs}),Tr&&e.jsx("div",{className:"cs-contact-role",children:Tr})]}),e.jsxs("div",{className:"cs-contact-actions",children:[Vn&&e.jsx("a",{href:`/postfach?an=${encodeURIComponent(Vn)}`,className:"cs-contact-action",title:Vn,children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),e.jsx("polyline",{points:"22,6 12,13 2,6"})]})}),_s&&e.jsx("a",{href:`tel:${_s}`,className:"cs-contact-action",title:_s,children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.5 19.5 0 01-6-6A19.79 19.79 0 014.11 2h3a2 2 0 012 1.72 11.04 11.04 0 00.7 2.81 2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45 11.04 11.04 0 002.81.7A2 2 0 0122 16.92z"})})})]})]}),e.jsxs("div",{className:"cs-contact-details",children:[Vn&&e.jsxs("div",{className:"cs-contact-detail",children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:12,height:12,flexShrink:0,color:"var(--ink-3)"},children:[e.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),e.jsx("polyline",{points:"22,6 12,13 2,6"})]}),e.jsx("span",{style:{fontSize:12,color:"var(--ink-2)",fontWeight:600},children:Vn})]}),_s&&e.jsxs("div",{className:"cs-contact-detail",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:12,height:12,flexShrink:0,color:"var(--ink-3)"},children:e.jsx("path",{d:"M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.5 19.5 0 01-6-6A19.79 19.79 0 014.11 2h3a2 2 0 012 1.72 11.04 11.04 0 00.7 2.81 2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45 11.04 11.04 0 002.81.7A2 2 0 0122 16.92z"})}),e.jsx("span",{style:{...xe,fontSize:12,color:"var(--ink-2)",fontWeight:600},children:_s})]})]})]}):e.jsx("div",{className:"cs-section-info cs-muted",children:"Keine Kontakte"})}),e.jsxs(Ci,{icon:"",title:"CUSTOM FIELDS",count:[Br,ui,Lr,ut(n,i.tier),ut(n,i.retainer),ut(n,i.qualifiziert),ut(n,i.leadImporteur),ut(n,i.updateintervall),ut(n,i.videokarte),ut(n,i.messen),ut(n,i.brancheField),o(n,i.standnummer),o(n,i.instagram),o(n,i.guthaben),fa,xa].filter(Boolean).length,extra:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cs-section-dots",children:"···"}),e.jsx("span",{className:"cs-section-search",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",style:{width:12,height:12},children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),e.jsx("span",{className:"cs-section-plus",children:"+"})]}),children:[e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Kundennummer"}),e.jsx("span",{className:"cs-cf-value",children:e.jsx(Vt,{value:Br,onSave:s=>
126et(tt,t,{[i.kundennr]:s}),placeholder:"â"})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Interner AP"}),e.jsxs("span",{className:"cs-cf-value cs-cf-user",children:[e.jsxs("select",{className:"cs-select",style:{border:"none",background:"none",padding:"2px 4px",fontSize:12.5,fontWeight:600,color:"var(--ink)",cursor:"pointer",minWidth:100,fontFamily:"inherit"},value:ui||"",onChange:s=>et(tt,t,{[i.ownerName]:s.target.value}).then(()=>{vt.clear(),Kt()}),children:[e.jsx("option",{value:"",children:"â Nicht zugewiesen"}),wt.map(s=>e.jsx("option",{value:s.name,children:s.name},s.key))]}),ui&&e.jsx(It,{userKey:ui.toLowerCase().split(" ")[0],size:18})]})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Kategorie"}),e.jsx("span",{className:"cs-cf-value",children:e.jsx(Vt,{value:Lr,onSave:s=>et(tt,t,{[i.kategorie]:s}),placeholder:"â"})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"TIER"}),e.jsx(Jn,{value:ut(n,i.tier),choices:Bn.tier,onSave:s=>et(tt,t,{[i.tier]:s}).then(()=>{vt.clear(),Kt()})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Aktueller Retainer"}),e.jsx(Jn,{value:ut(n,i.retainer),choices:Bn.retainer,onSave:s=>et(tt,t,{[i.retainer]:s}).then(()=>{vt.clear(),Kt()})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Qualifiziert"}),e.jsx(Jn,{value:ut(n,i.qualifiziert),choices:Bn.qualifiziert,onSave:s=>et(tt,t,{[i.qualifiziert]:s}).then(()=>{vt.clear(),Kt()})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Lead Importeur"}),e.jsx(Jn,{value:ut(n,i.leadImporteur),choices:Bn.leadImporteur,onSave:s=>et(tt,t,{[i.leadImporteur]:s}).then(()=>{vt.clear(),Kt()})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Updateintervall"}),e.jsx(Jn,{value:ut(n,i.updateintervall),choices:Bn.updateintervall,onSave:s=>et(tt,t,{[i.updateintervall]:s}).then(()=>{vt.clear(),Kt()})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Videokarte"}),e.jsx(Jn,{value:ut(n,i.videokarte),choices:Bn.videokarte,onSave:s=>et(tt,t,{[i.videokarte]:s}).then(()=>{vt.clear(),Kt()})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Analyse generieren"}),e.jsx(Jn,{value:ut(n,i.analyseGenerieren),choices:Bn.analyseGenerieren,onSave:s=>et(tt,t,{[i.analyseGenerieren]:s}).then(()=>{vt.clear(),Kt()})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Humorskala"}),e.jsx(Jn,{value:o(n,i.humorskala),choices:Bn.humorskala,onSave:s=>et(tt,t,{[i.humorskala]:s?Number(s):null}).then(()=>{vt.clear(),Kt()})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Standnummer"}),e.jsx("span",{className:"cs-cf-value",children:e.jsx(Vt,{value:o(n,i.standnummer),onSave:s=>et(tt,t,{[i.standnummer]:s}),placeholder:"â"})})]}),e.jsxs("div",{className:"cs-cf-row cs-cf-full",children:[e.jsx("span",{className:"cs-cf-label",children:"Messen"}),e.jsx(Yr,{value:ut(n,i.messen),choices:Bn.messen,onSave:s=>et(tt,t,{[i.messen]:s}).then(()=>{vt.clear(),Kt()})})]}),e.jsxs("div",{className:"cs-cf-row cs-cf-full",children:[e.jsx("span",{className:"cs-cf-label",children:"Branche"}),e.jsx(Yr,{value:ut(n,i.brancheField),choices:Bn.branche,onSave:s=>et(tt,t,{[i.brancheField]:s}).then(()=>{vt.clear(),Kt()})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Instagram"}),e.jsx("span",{className:"cs-cf-value",children:e.jsx(Vt,{value:o(n,i.instagram),onSave:s=>et(tt,t,{[i.instagram]:s}),placeholder:"@handle..."})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Social Media"}),e.jsx("span",{className:"cs-cf-value",children:e.jsx(Vt,{value:o(n,i.social),onSave:s=>et(tt,t,{[i.social]:s}),placeholder:"Instagram/Social Link..."})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Aktuelles Guthaben"}),e.jsx("span",{className:"cs-cf-value",children:e.jsx(Vt,{value:o(n,i.guthaben),onSave:s=>et(tt,t,{[i.guthaben]:s}),placeholder:"â"})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Abrechnungs-Ãber
126sicht"}),e.jsx("span",{className:"cs-cf-value",children:e.jsx(Vt,{value:o(n,i.abrechnungUebersicht),onSave:s=>et(tt,t,{[i.abrechnungUebersicht]:s}),placeholder:"â"})})]}),e.jsxs("div",{className:"cs-cf-row",children:[e.jsx("span",{className:"cs-cf-label",children:"Lead-Name o. Firma"}),e.jsx("span",{className:"cs-cf-value",children:e.jsx(Vt,{value:o(n,i.leadNameOhneFirma),onSave:s=>et(tt,t,{[i.leadNameOhneFirma]:s}),placeholder:"â"})})]}),e.jsxs("div",{className:"cs-cf-row cs-cf-full",children:[e.jsx("span",{className:"cs-cf-label",children:"TIER Analyse"}),e.jsx(Vt,{value:o(n,i.tierAnalyse),onSave:s=>et(tt,t,{[i.tierAnalyse]:s}),placeholder:"TIER-Analyse hinzufügen...",multiline:!0})]}),e.jsxs("div",{className:"cs-cf-row cs-cf-full",children:[e.jsx("span",{className:"cs-cf-label",children:"Wichtige Infos"}),e.jsx(Vt,{value:fa,onSave:s=>et(tt,t,{[i.wichtig]:s}),placeholder:"Wichtige Infos hinzufügen...",multiline:!0})]}),e.jsxs("div",{className:"cs-cf-row cs-cf-full",children:[e.jsx("span",{className:"cs-cf-label",children:"Notiz"}),e.jsx(Vt,{value:xa,onSave:s=>et(tt,t,{[i.notiz]:s}),placeholder:"Notiz hinzufügen...",multiline:!0})]})]})]})}),e.jsx("div",{className:"cs-detail-divider",onClick:()=>dr(s=>!s),title:sa?"Details einblenden":"Details ausblenden",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:14,height:14},children:e.jsx("polyline",{points:sa?"9 18 15 12 9 6":"15 18 9 12 15 6"})})}),e.jsxs("div",{className:"cs-detail-right",children:[e.jsxs("div",{className:"cs-timeline-tabs",children:[[{key:"verlauf",label:"Verlauf",count:f.length+u.length+An.length+hn.length},{key:"conversations",label:"E-Mails",count:f.filter(s=>!(s.direction==="outgoing"||s._sent||(s.from||"").includes("liberdamedia.de"))&&!s.read).length},{key:"calls",label:"Calls"},{key:"notes",label:"Notizen"},{key:"tasks",label:"Aufgaben",count:hn.filter(s=>s.type==="task"&&s.disposition!=="erledigt").length},{key:"meetings",label:"Meetings",count:hn.filter(s=>{if(s.type!=="meeting")return!1;const c=String(s.disposition||"").toLowerCase();if(/complete|abgeschlossen|erledigt|cancel|abgesagt|declin|abgelehnt|past|done/.test(c))return!1;if(/upcoming|anstehend|scheduled|geplant|confirm|bestät/.test(c))return!0;const d=s.date?Date.parse(s.date):NaN;return isNaN(d)?!1:d>=Date.now()}).length},{key:"projects",label:"Projekte",count:Fn.filter(s=>{var c,d,y;return!((((d=(c=s.fields)==null?void 0:c.K4jmU)==null?void 0:d.label)||((y=s.fields)==null?void 0:y.K4jmU)||"")+"").toLowerCase().includes("abgeschlossen")}).length},{key:"files",label:"Dateien"},{key:"ads",label:"Ads"},{key:"upsells",label:"Upsells"},{key:"score",label:"Score"},{key:"ki",label:"Insights"},{key:"analytics",label:"Analytics"},{key:"termin",label:"Termin"}].filter(s=>["verlauf","conversations","tasks","files"].includes(s.key)).map(s=>e.jsxs("button",{className:`cs-tab ${dt===s.key?"cs-tab-active":""}`,"aria-pressed":dt===s.key,onClick:()=>Rt(s.key),children:[s.label,s.count>0&&e.jsx("span",{className:"cs-badge-sm",children:s.count>99?"99+":s.count})]},s.key)),e.jsxs("select",{className:"cs-more-sections","aria-label":"Weitere Kontaktbereiche",value:["verlauf","conversations","tasks","files"].includes(dt)?"":dt,onChange:s=>Rt(s.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:"Weitere Bereiche"}),e.jsxs("optgroup",{label:"Zusammenarbeit",children:[e.jsx("option",{value:"notes",children:"Notizen"}),e.jsx("option",{value:"calls",children:"Anrufe"}),e.jsx("option",{value:"meetings",children:"Meetings"}),e.jsx("option",{value:"projects",children:"Projekte"}),e.jsx("option",{value:"termin",children:"Termin"})]}),e.jsxs("optgroup",{label:"Entwicklung",children:[e.jsx("option",{value:"ads",children:"Werbeanzeigen"}),e.jsx("option",{value:"upsells",children:"Verkaufspotenzial"}),e.jsx("option",{value:"score",children:"Bewertung"}),e.jsx("option",{value:"ki",children:"Einblicke"}),e.jsx("option",{value:"analytics",children:"Auswertungen"})]})]})]}),dt==="verlauf"&&(()=>{const s=T=>
126(T||"").replace(/^(Re|Fwd|Aw|Wg|Fw):\s*/gi,"").trim().toLowerCase(),c=new Map;f.forEach(T=>{const me=s(T.subject||"(kein Betreff)");c.has(me)||c.set(me,[]),c.get(me).push(T)});const y=[...[...c.values()].map(T=>T.slice().sort((me,E)=>new Date(E.date).getTime()-new Date(me.date).getTime())).map(T=>({type:"email-thread",date:T[0].date||"",data:{newest:T[0],all:T,threadKey:s(T[0].subject||"")}})),...An.map(T=>({type:"call",date:T.date||"",data:T})),...u.map(T=>({type:"note",date:T.date||"",data:{...T,_local:!0}}))],D=[];hn.forEach(T=>{if(T.type==="note")y.push({type:"note",date:T.date||"",data:{id:T.id,caid:T.caid,text:T.body||T.title,author:T.author||"Close CRM",date:T.date}});else if(T.type==="call"){const me=T.duration?Math.round(Number(T.duration)/60):0;y.push({type:"call",date:T.date||"",data:{id:T.id,typ:T.direction==="inbound"?"eingehend":"ausgehend",dauer:me,ergebnis:T.disposition||"",notiz:T.body||"",autor:T.author||"Close CRM",date:T.date}})}else T.type==="task"?y.push({type:"task",date:T.date||"",data:{id:T.id,title:T.title||T.body,body:T.body,disposition:T.disposition||"",author:T.author||"",date:T.date}}):T.type==="meeting"?y.push({type:"meeting",date:T.date||"",data:{id:T.id,title:T.title||"Meeting",body:T.body||"",disposition:T.disposition||"",duration:T.duration,author:T.author||"",date:T.date}}):T.type==="email"&&D.push({id:T.id,date:T.date||"",direction:T.direction||"",subject:T.title||"",snippet:String(T.body||"").replace(/\s+/g," ").slice(0,200),attachments:Array.isArray(T.attachments)?T.attachments:[]})}),D.length&&(D.sort((T,me)=>new Date(me.date).getTime()-new Date(T.date).getTime()),y.push({type:"closemails",date:D[0].date||"",data:{mails:D}}));const w=T=>{var me;return T.type==="note"&&!!((me=T.data)!=null&&me.gepinnt)};y.sort((T,me)=>(w(me)?1:0)-(w(T)?1:0)||new Date(me.date).getTime()-new Date(T.date).getTime());const M=Date.now(),te=y.reduce((T,me)=>T+(me.date&&new Date(me.date).getTime()>M?1:0),0),L=T=>{var me,E;return(((me=T.fields)==null?void 0:me.CIy6k)||((E=T.fields)==null?void 0:E.z0xSB)||"").toLowerCase().trim()},Y=new Map;Ot.forEach(T=>{const me=L(T);me&&Y.set(me,T)});const ae=T=>{const me=String(T||"").match(/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}/i);return me?me[0].toLowerCase():""},de=(T,me)=>{const E=me?[T.toEmail,T.to,T.toName]:[T.fromEmail,T.from,T.fromName];for(const Ye of E){const Re=ae(Ye);if(Re&&Y.has(Re))return Y.get(Re)}return null},Pe=T=>{const me=(T||"").toLowerCase();return me?Ot.filter(E=>{var Re,z;const Ye=String(((Re=E.fields)==null?void 0:Re["707oq"])||((z=E.fields)==null?void 0:z["5OGPi"])||"").trim();return Ye.length>=5&&me.includes(Ye.toLowerCase())}).slice(0,3):[]},st=(T,me)=>{const E=(me||[]).map(Re=>Ot.find(z=>z.id===Re)).filter(Boolean),Ye=E.length?E.slice(0,3):Pe(T);return Ye.length?e.jsx("div",{style:{display:"flex",alignItems:"center",flexShrink:0},title:Ye.map(Re=>{var z,W;return((z=Re.fields)==null?void 0:z["707oq"])||((W=Re.fields)==null?void 0:W["5OGPi"])||""}).filter(Boolean).join(", "),children:Ye.map((Re,z)=>{var W,G,ze,$e,Q,We;return e.jsx("span",{style:{marginLeft:z?-7:0,display:"inline-flex",border:"2px solid var(--panel)",borderRadius:"50%"},children:e.jsx(En,{contactId:Re.id,name:((W=Re.fields)==null?void 0:W["707oq"])||((G=Re.fields)==null?void 0:G["5OGPi"])||"",email:((ze=Re.fields)==null?void 0:ze.CIy6k)||(($e=Re.fields)==null?void 0:$e.z0xSB),company:(Q=Re.fields)==null?void 0:Q["4Fk6j"],leadUrl:o(n,i.url),storedAvatar:(We=Re.fields)==null?void 0:We.Hb2om,size:20})},Re.id||z)})}):null};if(y.length===0)return e.jsxs("div",{className:"cs-tab-placeholder",children:[e.jsx("div",{className:"cs-tab-placeholder-icon",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:40,height:40,opacity:.3},children:e.jsx("path",{d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("div",{className:"cs-tab-placeholder-title",children:"Noch keine Aktivitäten"}),e.jsx("div",{className:"cs-tab-placeholder-desc",children:"E-Mails, Anrufe und Notizen werden hier chronologisch angezeigt"})]});const R=["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],Ce=T=>{const me=(T||"").toLowerCase().trim();return me&&wt.find(E=>me===E.name.toLowerCase()||me.includes(E.key)||me.includes(E.name.toLowerCase())||me.includes(E.name.toLowerCase().split(" ")[0])||me.replace(/\s+/g,"")===E.initials.toLowerCase())||null},Se=(T,me)=>{const E=Ce(T);return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,flexShrink:0,marginLeft:8},children:[e.jsx("span",{style:{...ye,...xe,whiteSpace:"nowrap"},children:me?`${me.getDate()} ${R[me.getMonth()]}`:""}),E?e.jsx(It,{userKey:E.key,size:22}):T?e.jsx(Ii,{name:T,size:22,fontSize:9}):null]})},xt=ve==="alle"?y:y.filter(T=>T.type===ve),bt=[{key:"alle",label:"Alle",n:y.length},{key:"email-thread",label:"E-Mails",n:y.filter(T=>T.type==="email-thread").length},{key:"call",label:"Anrufe",n:y.filter(T=>T.type==="call").length},{key:"note",label:"Notizen",n:y.filter(T=>T.type==="note").length},{key:"task",label:"Aufgaben",n:y.filter(T=>T.type==="task").length},{key:"meeting",label:"Meetings",n:y.filter(T=>T.type==="meeting").length}],Je=T=>{if(!T||isNaN(T.getTime()))return"Ãlter";const me=new Date,E=new Date(me.getFullYear(),me.getMonth(),me.getDate()).getTime(),Ye=new Date(T.getFullYear(),T.getMonth(),T.getDate()).getTime(),Re=Math.round((E-Ye)/864e5);return Re<=0?"Heute":Re===1?"Gestern":Re<7?"Diese Woche":["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"][T.getMonth()]+" "+T.getFullYear()};let at=null;const Ke={background:"var(--panel)",borderBottom:"1px solid var(--line)",margin:0,overflow:"hidden",transition:"background .12s"},Ze={onMouseEnter:T=>{T.currentTarget.style.background="var(--panel-2)"},onMouseLeave:T=>{T.currentTarget.style.background="var(--panel)"}};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",padding:"0 0 40px",background:"var(--bg)"},children:[e.jsx("div",{style:{display:"flex",gap:4,padding:"6px 26px 0",borderBottom:"1px solid var(--line)",background:"var(--panel)",overflowX:"auto"},children:bt.filter(T=>T.key==="alle"||T.n>0).map(T=>e.jsxs("button",{onClick:()=>$(T.key),type:"button",style:{border:"none",background:"transparent",curs
126or:"pointer",padding:"9px 14px",fontSize:13,fontWeight:700,color:ve===T.key?"var(--ink)":"var(--ink-2)",borderBottom:"2px solid "+(ve===T.key?"var(--green)":"transparent"),marginBottom:-1,whiteSpace:"nowrap",transition:"color .14s,border-color .14s",fontFamily:"inherit",fontVariantNumeric:"tabular-nums"},children:[T.label,T.key!=="alle"?` ${T.n}`:""]},T.key))}),te>0&&e.jsx("div",{style:{borderBottom:"1px solid var(--line)",background:"var(--panel)"},children:e.jsxs("div",{onClick:()=>ee(T=>!T),style:{display:"flex",alignItems:"center",gap:9,padding:"11px 20px",cursor:"pointer",userSelect:"none",transition:"background .12s"},onMouseEnter:T=>{T.currentTarget.style.background="var(--panel-2)"},onMouseLeave:T=>{T.currentTarget.style.background="transparent"},children:[e.jsx("span",{style:{width:28,height:28,flexShrink:0,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",style:{width:14,height:14},children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),e.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})}),e.jsxs("span",{style:{flex:1,fontSize:12.5,fontWeight:700,color:"var(--ink)",fontVariantNumeric:"tabular-nums"},children:[te," geplante ",te===1?"Aktivität":"Aktivitäten"]}),e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--ink-3)",strokeWidth:"2",style:{width:14,height:14,flexShrink:0,transform:N?"rotate(90deg)":"none",transition:"transform .15s"},children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})]})}),xt.map((T,me)=>{var W,G,ze,$e;const E=T.date?new Date(T.date):null,Ye=E?E.getTime()>M:!1;if(Ye&&!N)return null;let Re=null;if(!Ye){const Q=w(T)?"Angepinnt":Je(E);Q!==at&&(at=Q,Re=e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"18px 26px 7px"},children:[e.jsx("span",{style:{...fe,whiteSpace:"nowrap"},children:Q}),e.jsx("span",{style:{flex:1,height:1,background:"var(--line)"}})]},"grp"+me))}const z=Q=>Re?e.jsxs("div",{children:[Re,Q]},me):Q;if(T.type==="email-thread"){const{newest:Q,all:We,threadKey:Pt}=T.data,kt=Q.direction==="outgoing"||Q._sent||((W=Q.from)==null?void 0:W.includes("liberdamedia.de")),Wt=g===me,yn=(Q.subject||"(kein Betreff)").replace(/^(Re|Fwd|Aw|Wg|Fw):\s*/gi,""),xs=We.length>1,ys=kt?Q.to||Q.toEmail||"":Q.fromName||Q.fromEmail||Q.from||"",mi=E?E.toLocaleTimeString("de",{hour:"2-digit",minute:"2-digit"}):"",bs=E?E.toLocaleDateString("de",{day:"2-digit",month:"short",year:"2-digit"}):"",vs=kt?Q._opened||Q.opened?{txt:"Gelesen",col:"var(--green)",dot:!0}:{txt:"Gesendet",col:"var(--ink-3)",dot:!1}:Q.read?{txt:"Gelesen",col:"var(--ink-3)",dot:!1}:{txt:"Ungelesen",col:"var(--green)",dot:!0},fi=(We||[Q]).some(Ht=>{var ns;return!(Ht.direction==="outgoing"||Ht._sent||((ns=Ht.from)==null?void 0:ns.includes("liberdamedia.de")))&&!Ht.read}),Ln=de(Q,kt),xi=Ln?((G=Ln.fields)==null?void 0:G["707oq"])||((ze=Ln.fields)==null?void 0:ze["5OGPi"])||ys:"",yi=(Q.snippet||Q.preview||Q.bodyPreview||Q.intro||"").replace(/\s+/g," ").trim().slice(0,240);return z(e.jsxs("div",{style:Ke,...Ze,children:[e.jsxs("div",{onClick:async()=>{if(Wt){x(null),Z(null),K(null),P(null);return}x(me),Z(null),K(Q.seq),P(null),B(!0);try{Z(await ie(Q)),P(be(Q))}catch{Z("Fehler beim Laden.")}finally{B(!1)}},style:{display:"flex",gap:12,padding:"11px 26px",alignItems:"flex-start",cursor:"pointer"},onMouseEnter:Ht=>{H(Ht,Q)},onMouseLeave:Ht=>{U(Ht)},children:[e.jsxs("div",{style:{width:28,height:28,flexShrink:0,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",marginTop:1},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",style:{width:14,height:14},children:[e.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),e.jsx("polyline",{points:"22,6 12,13 2,6"})]}),xs&&e.jsx("span",{style:{position:"absolute",top:-5,right:-6,fontSize:10,fontWeight:800,color:"var(--ink)",background:"var(--panel)",lineHeight:1.2,padding:"0 2px",fontVariantNumeric:"tabular-nums"},children:We.length})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[e.jsx("span",{style:{fontSize:14,fontWeight:fi?700:500,color:fi?"var(--ink)":"var(--ink-2)",letterSpacing:"-.012em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:yn}),xs&&e.jsxs("span",{style:{...an,flexShrink:0},children:["Thread · ",We.length]}),e.jsxs("span",{style:{...ye,...xe,whiteSpace:"nowrap",flexShrink:0},children:[bs,mi?` · ${mi}`:""]}),e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--ink-3)",strokeWidth:"2",style:{width:12,height:12,flexShrink:0,transform:Wt?"rotate(90deg)":"none",transition:"transform .15s"},children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:3},children:[e.jsx("span",{style:{fontSize:11,fontWeight:700,color:kt?"var(--green)":"#1D4ED8",flexShrink:0},children:kt?"â An:":"â Von:"}),ms(Q,kt,18,!0),e.jsx("span",{style:{fontSize:11.5,color:Ln?"var(--ink-2)":"var(--ink-3)",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},title:Ln?`${xi}${($e=Ln.fields)!=null&&$e.CIy6k?" · "+Ln.fields.CIy6k:""}`:ys,children:Ln?xi:ys||"â"}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,fontSize:10.5,fontWeight:600,color:vs.col},title:kt?"Versand-/Lesestatus":"Lesestatus im Postfach",children:[vs.dot&&e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:vs.col}}),vs.txt]})]}),yi&&e.jsx("div",{style:{marginTop:5,fontSize:12,color:"var(--ink-3)",lineHeight:1.5,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:yi})]})]}),Wt&&e.jsxs("div",{style:{background:"var(--panel-2)",borderTop:"1px solid var(--line)",padding:"13px 26px 16px 66px"},children:[xs&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,overflowX:"auto",padding:"3px 2px 5px"},children:We.map((Ht,Dr)=>{var Rr;const ns=Ht.date?new Date(Ht.date):null,Zl=ns?ns.toLocaleDateString("de",{day:"2-digit",month:"short"}):"",Ul=ns?ns.toLocaleTimeString("de",{hour:"2-digit",minute:"2-digit"}):"",Wr=Ht._sent||((Rr=Ht.from)==null?void 0:Rr.includes("liberdamedia.de")),Mr=F===Ht.seq,Yl=Mr?30:26,Xl=Ks(Ht,Wr,Ws);return e.jsx("button",{type:"button",title:`${Xl} · ${Zl} ${Ul}`,onClick:async ya=>{ya.stopPropagation(),K(Ht.seq),Z(null),P(null),B(!0);try{Z(await ie(Ht)),P(be(Ht))}catch{Z("Fehler beim Laden.")}finally{B(!1)}},onMouseEnter:ya=>H(ya,Ht),onMouseLeave:U,style:{border:"none",background:"none",padding:0,cursor:"pointer",borderRadius:"50%",flexShrink:0,display:"inline-flex",boxShadow:Mr?"0 0 0 2px var(--green)":"none",transition:"box-shadow .12s"},children:ms(Ht,!!Wr,Yl)},Dr)})}),I?e.jsxs("div",{style:{background:"var(--panel)",borderRadius:13,padding:18,border:"1px solid var(--line)"},children:[e.jsx("div",{className:"cs-skel",style:{width:"38%",height:12,marginBottom:12}}),e.jsx("div",{className:"cs-skel",style:{width:"96%",height:9,marginBottom:7}}),e.jsx("div",{className:"cs-skel",style:{width:"88%",height:9,marginBottom:7}}),e.jsx("div",{className:"cs-skel",style:{width:"70%",height:9}})]}):le?e.jsxs("div",{style:{background:"var(--panel)",borderRadius:13,padding:18,border:"1px solid var(--line)"},children:[e.jsx(Ia,{rawBody:le,attCtx:j||void 0}),j&&e.jsx(Oa,{...j})]}):e.jsx("div",{className:"cs-empty",style:{padding:20},children:"Keine Inhalte."})]})]},me))}if(T.type==="call"){const Q=T.data;return z(e.jsxs("div",{style:{...Ke,padding:"11px 26px"},...Ze,children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center"},children:[e.jsx("div",{title:Q.typ==="eingehend"?"Eingehender Anruf":"Ausgehender Anruf",style:{width:28,height:28,flexShrink:0,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:Q.typ==="eingehend"?"#1D4ED8":"#5B21B6",strokeWidth:"1.5",style:{width:14,height:14},children:[e.jsx("path",{d:"M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.5 19.5 0 014.11 12.5 19.79 19.79 0 011.04 3.87 2 2 0 013 1.68h3a2 2 0 012 1.72c.128 1.02.37 2.024.72 2.99a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.965.35 1.969.593 2.99.72A2 2 0 0122 16.92z"}),Q.typ==="eingehend"?e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:"21",y1:"3",x2:"15.5",y2:"8.5",strokeWidth:"2"}),e.jsx("polyline",{points:"15.5 4.5 15.5 8.5 19.5 8.5",strokeWidth:"2"})]}):e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:"15.5",y1:"8.5",x2:"21",y2:"3",strokeWidth:"2"}),e.jsx("polyline",{points:"17 3 21 3 21 7",strokeWidth:"2"})]})]})}),e.jsxs("div",{style:{flex:1,minWidth:0,fontSize:13,fontWeight:700,color:"var(--ink)",fontVariantNumeric:"tabular-nums"},children:["Anruf ",Q.typ==="eingehend"?"eingehend":"ausgehend",Q.dauer?` · ${Q.dauer} Min.`:"",Q.ergebnis&&e.jsxs("span",{style:{fontWeight:600,color:"var(--ink-3)"},children:[" â ",Q.ergebnis]})]}),st(Q.notiz||"",Q.kontakte),Se(_n(Q.autor||Q.userKey),E)]}),Q.notiz&&e.jsx(vn,{text:Q.notiz,accent:"",bg:"var(--panel-2)",border:"1px solid var(--line)",padding:"12px 14px",marginTop:8})]},me))}if(T.type==="closemails"){const Q=T.data;return z(e.jsxs("div",{style:{...Ke,padding:"11px 26px"},...Ze,children:[e.jsxs("button",{onClick:()=>zl(We=>!We),style:{display:"flex",gap:12,alignItems:"center",width:"100%",background:"none",border:"none",cursor:"pointer",padding:0,fontFamily:"inherit",textAlign:"left"},children:[e.jsx("div",{style:{width:28,height:28,flexShrink:0,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--ink-3)",strokeWidth:"1.5",style:{width:14,height:14},children:[e.jsx("path",{d:"M21 8v13H3V8"}),e.jsx("path",{d:"M1 3h22v5H1z"}),e.jsx("path",{d:"M10 12h4"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0,fontSize:13,fontWeight:700,color:"var(--ink)"},children:["Ãltere Mails aus dem Close-Archiv ",e.jsxs("span",{style:{fontWeight:600,color:"var(--ink-3)"},children:["(",Q.mails.length,")"]})]}),e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--ink-3)",strokeWidth:"2",style:{width:14,height:14,flexShrink:0,transform:Qa?"rotate(180deg)":"none",transition:"transform .18s"},children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),Qa&&e.jsx("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:8},children:Q.mails.map((We,Pt)=>e.jsxs("div",{style:{background:"var(--panel-2)",border:"1px solid var(--line)",borderRadius:10,padding:"9px 12px"},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline",fontSize:12,minWidth:0},children:[e.jsx("span",{style:{color:We.direction==="inbound"?"#1D4ED8":"#5B21B6",fontWeight:700,flexShrink:0},children:We.direction==="inbound"?"Eingang":"Ausgang"}),e.jsx("span",{style:{fontWeight:700,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:We.subject||"(ohne Betreff)"}),e.jsx("span",{style:{marginLeft:"auto",color:"var(--ink-3)",flexShrink:0,fontVariantNumeric:"tabular-nums"},children:We.date?new Date(We.date).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"2-digit"}):""})]}),We.snippet&&e.jsx("div",{style:{fontSize:12,color:"var(--ink-2)",marginTop:3,overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:We.snippet}),We.attachments.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:10,marginTop:5},children:We.attachments.map((kt,Wt)=>{const yn=kt!=null&&kt.url?`${ln}/api/close-file?url=${encodeURIComponent(kt.url)}&name=${encodeURIComponent(kt.name||"anhang")}`:"";return yn?e.jsx("a",{href:yn,target:"_blank",rel:"noopener noreferrer",style:{fontSize:11.5,fontWeight:600,color:"var(--green)",textDecoration:"underline"},children:kt.name||"Anhang"},Wt):null})})]},We.id||Pt))})]},me))}if(T.type==="note"){const Q=T.data,We=O===Q.id,Pt=Nr(Q);return z(e.jsxs("div",{style:{...Ke,padding:"11px 26px",...Q.gepinnt?{background:bn,borderTop:"1px solid var(--gold-2)",borderBottom:"1px solid var(--gold-2)"}:null},...Ze,children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:6},children:[e.jsx("div",{style:{width:28,height:28,flexShrink:0,borderRadius:"50%",background:bn,border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--gold-text)",strokeWidth:"1.5",style:{width:14,height:14},children:[e.jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0,fontSize:13,fontWeight:700,color:"var(--ink)",display:"flex",alignItems:"center",gap:6},children:["Notiz",Q.gepinnt&&e.jsx("span",{title:"Angepinnt",style:{display:"inline-flex",color:"var(--gold-text)"},children:e.jsx(Ni,{on:!0,size:12})}),Q.editedAt?e.jsx("span",{style:ye,children:"· bearbeitet"}):null]}),Pt&&!We&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>Ar(Q.id),title:Q.gepinnt?"Nicht mehr anpinnen":"Notiz anpinnen",style:{display:"inline-flex",alignItems:"center",background:"none",border:"none",cursor:"pointer",color:Q.gepinnt?"var(--gold-text)":"var(--ink-3)",padding:"2px 4px",flexShrink:0},children:e.jsx(Ni,{on:Q.gepinnt})}),e.jsxs("button",{onClick:()=>{oe(Q.id),se(Q.text||"")},title:"Notiz bearbeiten",style:{display:"inline-flex",alignItems:"center",gap:5,background:"none",border:"none",cursor:"pointer",color:"var(--green)",fontSize:11.5,fontWeight:700,padding:"2px 4px",flexShrink:0,fontFamily:"inherit"},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:13,height:13},children:[e.jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Bearbeiten"]}),e.jsx("button",{onClick:()=>zr(Q.id),title:"Notiz löschen",style:{background:"none",border:"none",cursor:"pointer",fontSize:12,color:"var(--ink-3)",padding:"2px 4px",lineHeight:1,flexShrink:0,fontFamily:"inherit"},children:"â"})]}),st(Q.text||""),Se(_n(Q.author||Q.userKey),E)]}),We?e.jsxs("div",{style:{margin:0},children:[e.jsx("textarea",{value:q,onChange:kt=>se(kt.target.value),autoFocus:!0,rows:4,style:{...Ct,boxSizing:"border-box",padding:"12px 14px",background:bn,lineHeight:1.6,resize:"vertical"}}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[e.jsx("button",{onClick:()=>Cr(Q.id,q),disabled:!q.trim(),style:{...Pn,padding:"7px 14px",cursor:q.trim()?"pointer":"not-allowed",opacity:q.trim()?1:.45},children:"Speichern"}),e.jsx("button",{onClick:()=>{oe(null),se("")},style:{...as,padding:"7px 14px"},children:"Abbrechen"})]})]}):e.jsx(vn,{text:Q.text,accent:"",bg:bn,border:"1px solid var(--line)",padding:"12px 14px"}),Array.isArray(Q.atts)&&Q.atts.length>0&&e.jsx(zi,{atts:Q.atts,mailFiles:os}),Q.caid&&pa[Q.caid]&&e.jsx(zi,{atts:pa[Q.caid],mailFiles:os})]},me))}if(T.type==="task"){const Q=T.data,We=Q.disposition==="erledigt";return z(e.jsxs("div",{style:{...Ke,display:"flex",gap:12,padding:"11px 26px",alignItems:"center",opacity:We?.55:1},...Ze,children:[e.jsx("div",{style:{width:28,height:28,flexShrink:0,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:We?"var(--ink-3)":"var(--green)",strokeWidth:"1.5",style:{width:14,height:14},children:[e.jsx("polyline",{points:"9 11 12 14 22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0,fontSize:12.5,color:"var(--ink-2)"},children:[e.jsx("span",{style:{fontWeight:700,color:We?"var(--ink-3)":"var(--ink)"},children:We?"Aufgabe erledigt
126: ":"Aufgabe: "}),e.jsx("span",{style:We?{textDecoration:"line-through",color:"var(--ink-3)"}:void 0,children:Q.body||Q.title})]}),Se(_n(Q.author),E)]},me))}if(T.type==="meeting"){const Q=T.data,We=Q.duration?Math.round(Number(Q.duration)/60):0;return z(e.jsxs("div",{style:{...Ke,padding:"11px 26px"},...Ze,children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center"},children:[e.jsx("div",{style:{width:28,height:28,flexShrink:0,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"#1D4ED8",strokeWidth:"1.5",style:{width:14,height:14},children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),e.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0,fontSize:13,fontWeight:700,color:"var(--ink)",fontVariantNumeric:"tabular-nums"},children:[Q.title||"Meeting",We?` · ${We} Min.`:"",Q.disposition&&e.jsxs("span",{style:{fontWeight:600,color:"var(--ink-3)"},children:[" â ",Q.disposition]})]}),Se(_n(Q.author),E)]}),Q.body&&e.jsx(vn,{text:Q.body,accent:"",bg:"var(--panel-2)",border:"1px solid var(--line)",padding:"12px 14px",marginTop:8})]},me))}return null})]})})(),dt==="conversations"&&(()=>{const s=R=>R.replace(/^(Re|Fwd|Aw|Wg|Fw):\s*/gi,"").trim().toLowerCase(),c=new Map;f.forEach(R=>{const Se=s(R.subject||"")||"__single__"+(R.messageId||`${R._via}:${R._folder}:${R.seq}`||Math.random());c.has(Se)||c.set(Se,[]),c.get(Se).push(R)});const d=[...c.values()].sort((R,Ce)=>new Date(Ce[0].date).getTime()-new Date(R[0].date).getTime()),y=er==="all"?d:d.map(R=>{const Ce=R.filter(Se=>er==="in"?!Se._sent:Se._sent);return Ce.length>0?Ce:null}).filter(Boolean),D=R=>{if(Xs.has(R))return;const Ce=new Set(Xs);Ce.add(R),qi(Ce);try{localStorage.setItem(`lm_opened_threads_${t}`,JSON.stringify([...Ce]))}catch{}},w=d.filter(R=>Es.has(s(R[0].subject||""))).length,M=y.filter(R=>tr||!Es.has(s(R[0].subject||""))),te=d.filter(R=>{const Ce=s(R[0].subject||"");return!Xs.has(Ce)&&!Es.has(Ce)}).length,L=R=>{const Ce=new Set(Mn);Ce.has(R)?Ce.delete(R):Ce.add(R),Is(Ce)},Y=M.map(R=>s(R[0].subject||"")),ae=Y.length>0&&Y.every(R=>Mn.has(R)),de=Y.some(R=>Mn.has(R)),Pe=()=>{Is(ae?new Set:new Set(Y))},st=()=>{const R=new Set(Es);Mn.forEach(Ce=>R.add(Ce)),Gi(R);try{localStorage.setItem(`lm_done_threads_${t}`,JSON.stringify([...R]))}catch{}Is(new Set)};return e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[te>0&&e.jsxs("span",{style:{...rn,...xe},children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),te," ungelesen"]}),w>0&&e.jsx("button",{className:"cs-btn-outline",style:{fontSize:11.5,padding:"6px 12px",borderRadius:8},onClick:()=>nr(R=>!R),children:tr?"Erledigte ausblenden":`${w} erledigt`})]}),e.jsxs("button",{className:"cs-btn-primary",style:{fontSize:12.5,padding:"8px 14px",borderRadius:10,display:"inline-flex",alignItems:"center",gap:6,whiteSpace:"nowrap"},onClick:()=>{Qn(!li),ps(""),hs("")},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:12,height:12,flexShrink:0},children:[e.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),e.jsx("polyline",{points:"22,6 12,13 2,6"})]}),"Neue E-Mail"]})]}),li&&(()=>{var Ze,T,me,E,Ye,Re,z;const R=[],Ce=new Set;for(const W of Ot){const G=String(((Ze=W.fields)==null?void 0:Ze.CIy6k)||((T=W.fields)==null?void 0:T.z0xSB)||"").trim().toLowerCase();!G||Ce.has(G)||(Ce.add(G),R.push({id:W.id,adr:G,name:((me=W.fields)==null?void 0:me["707oq"])||((E=W.fields)==null?void 0:E["5OGPi"])||G,titel:((Ye=W.fields)==null?void 0:Ye["6MXsn"])||((Re=W.fields)==null?void 0:Re.nm24F)||"",avatar:(z=W.fields)==null?void 0:z.Hb2om}))}const Se=String(Vn||"").trim().toLowerCase();Se&&!Ce.has(Se)&&(Ce.add(Se),R.push({id:"",adr:Se,name:o(n,i.contactName)||Se,titel:"",avatar:""}));const xt="to",bt=new Map;for(const W of R)bt.set(W.adr,W);const Je=W=>gs(G=>G.includes(W)?G.filter(ze=>ze!==W):[...G,W]),at={display:"inline-flex",alignItems:"center",gap:7,padding:"4px 8px 4px 4px",background:"var(--panel)",border:"1px solid var(--line)",borderRadius:8,maxWidth:260},Ke=(W,G)=>W.map(ze=>{const $e=bt.get(ze);return e.jsxs("span",{style:at,children:[e.jsx(En,{contactId:$e==null?void 0:$e.id,name:($e==null?void 0:$e.name)||ze,email:ze,company:qt,leadUrl:o(n,i.url),storedAvatar:$e==null?void 0:$e.avatar,size:20}),e.jsx("span",{style:{fontSize:11.5,color:"var(--ink-2)",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:($e==null?void 0:$e.name)||ze}),e.jsx("button",{type:"button",title:"Entfernen",onClick:()=>G(ze),style:{background:"none",border:"none",cursor:"pointer",color:"var(--ink-3)",fontSize:13,lineHeight:1,padding:0,flexShrink:0,fontFamily:"inherit"},children:"â"})]},ze)}
126);return e.jsxs("div",{style:{position:"relative",background:"var(--panel)",border:oa?"1.5px dashed var(--green)":"1px solid var(--line)",borderRadius:13,padding:15,marginBottom:14,transition:"border-color .12s"},onDragOver:W=>{W.preventDefault(),oa||ca(!0)},onDragLeave:W=>{W.currentTarget.contains(W.relatedTarget)||ca(!1)},onDrop:W=>{var ze;W.preventDefault(),ca(!1);const G=Array.prototype.slice.call(((ze=W.dataTransfer)==null?void 0:ze.files)||[]);G.length&&Ir(G)},children:[oa&&e.jsxs("div",{style:{position:"absolute",inset:0,borderRadius:13,background:"rgba(231,243,238,.9)",display:"flex",alignItems:"center",justifyContent:"center",gap:8,pointerEvents:"none",zIndex:3,fontSize:12.5,fontWeight:700,color:"var(--green)"},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:16,height:16},children:[e.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Dateien hier ablegen"]}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("label",{style:fe,children:"Von"}),e.jsx("select",{className:"cs-select",style:{fontSize:12,padding:"5px 9px",flex:"0 0 auto"},value:ur,onChange:W=>aa(W.target.value),children:wt.map(W=>e.jsx("option",{value:W.key,children:W.email},W.key))}),!yr&&e.jsx("button",{type:"button",className:"cs-btn-outline",style:{fontSize:11.5,padding:"5px 11px",marginLeft:"auto"},onClick:()=>ci(!0),children:"CC hinzufügen"})]}),e.jsxs("div",{style:{border:"1px solid var(--line)",borderRadius:10,padding:"9px 11px",marginBottom:8,background:"var(--panel-2)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:Hn.length?7:0},children:[e.jsx("span",{style:fe,children:"An"}),!Hn.length&&e.jsx("span",{style:ye,children:"Noch niemand ausgewählt"})]}),Hn.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:7},children:Ke(Hn,W=>gs(G=>G.filter(ze=>ze!==W)))})]}),R.length>0&&e.jsx("div",{style:{...Tt,marginBottom:8,maxHeight:190,overflowY:"auto"},children:R.map(W=>{const G=Hn.includes(W.adr);return e.jsxs("div",{onClick:()=>Je(W.adr),style:{display:"flex",alignItems:"center",gap:9,padding:"9px 14px",cursor:"pointer",borderBottom:"1px solid var(--line)",background:G?"var(--sel)":"transparent",transition:"background .12s"},onMouseEnter:ze=>{G||(ze.currentTarget.style.background="var(--panel-2)")},onMouseLeave:ze=>{G||(ze.currentTarget.style.background="transparent")},children:[e.jsx("span",{style:{width:16,height:16,borderRadius:6,border:"1px solid "+(G?"var(--green)":"var(--line-2)"),background:G?"var(--green)":"var(--panel)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:G&&e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",style:{width:10,height:10},children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}),e.jsx(En,{contactId:W.id,name:W.name,email:W.adr,company:qt,leadUrl:o(n,i.url),storedAvatar:W.avatar,size:24}),e.jsxs("span",{style:{fontSize:12.5,fontWeight:700,color:"var(--ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:"0 1 auto"},children:[W.name,W.titel?" · "+W.titel:""]}),e.jsx("span",{style:{...ye,marginLeft:"auto",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"45%"},children:W.adr})]},W.adr)})}),e.jsxs("div",{style:{display:"flex",gap:7,marginBottom:8},children:[e.jsx("input",{className:"cs-input",style:{fontSize:12,flex:1},placeholder:"Weitere Adresse eingeben (Enter)",value:la,onChange:W=>Bs(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),ma(la,xt)&&Bs(""))}}),e.jsx("button",{type:"button",className:"cs-btn-outline",style:{fontSize:11,padding:"5px 12px",whiteSpace:"nowrap"},onClick:()=>{ma(la,xt)&&Bs("")},children:"Hinzufügen"})]}),yr&&e.jsxs("div",{style:{border:"1px solid var(--line)",borderRadius:10,padding:"9px 11px",marginBottom:8,background:"var(--panel-2)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:us.length?7:0},children:[e.jsx("span",{style:fe,children:"CC"}),e.jsx("button",{type:"button",onClick:()=>{ci(!1),es([]),Ds("")},style:{marginLeft:"auto",background:"none",border:"none",cursor:"pointer",color:"var(--ink-3)",fontSize:13,lineHeight:1,padding:0,fontFamily:"inherit"},title:"CC ausblenden",children:"â"})]}),us.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:7,marginBottom:7},children:Ke(us,W=>es(G=>G.filter(ze=>ze!==W)))}),e.jsxs("div",{style:{display:"flex",gap:7,flexWrap:"wrap"},children:[e.jsx("input",{className:"cs-input",style:{fontSize:12,flex:"1 1 200px"},placeholder:"CC-Adresse (Enter)",value:br,onChange:W=>Ds(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),ma(br,"cc")&&Ds(""))}}),R.filter(W=>!us.includes(W.adr)).slice(0,4).map(W=>e.jsx("button",{type:"button",className:"cs-btn-outline",style:{fontSize:11.5,padding:"5px 11px",whiteSpace:"nowrap"},onClick:()=>es(G=>Array.from(new Set([...G,W.adr]))),children:W.name},W.adr))]})]}),e.jsx("input",{className:"cs-input",style:{fontSize:12,marginBottom:8},placeholder:"Betreff",value:oi,onChange:W=>ps(W.target.value)}),e.jsx("textarea",{className:"cs-textarea",style:{fontSize:12.5,minHeight:260,resize:"vertical",lineHeight:1.55}
126,placeholder:"Nachricht...",value:mr,onChange:W=>hs(W.target.value)}),di.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:8},children:di.map((W,G)=>{const ze=(W.content_type||"").includes("image");return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:7,padding:"5px 8px 5px 5px",background:"var(--panel)",border:"1px solid var(--line)",borderRadius:8,maxWidth:220},children:[ze?e.jsx("img",{src:W.url,alt:"",style:{width:26,height:26,borderRadius:6,objectFit:"cover",display:"block",flexShrink:0}}):e.jsx("span",{style:{width:26,height:26,borderRadius:6,background:"var(--panel-2)",border:"1px solid var(--line)",color:"var(--ink-3)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:800,flexShrink:0},children:"FILE"}),e.jsx("span",{style:{fontSize:11.5,color:"var(--ink-2)",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:W.name}),e.jsx("button",{type:"button",onClick:()=>pi($e=>$e.filter((Q,We)=>We!==G)),title:"Entfernen",style:{background:"none",border:"none",cursor:"pointer",color:"var(--ink-3)",fontSize:13,lineHeight:1,padding:0,flexShrink:0,fontFamily:"inherit"},children:"â"})]},G)})}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:10,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("button",{className:"cs-btn-primary",style:{fontSize:12.5,padding:"8px 16px"},onClick:Gl,disabled:fr||!oi||!Hn.length||hi,children:fr?"Sende...":"Senden"}),e.jsx("button",{className:"cs-btn-outline",style:{fontSize:12.5,padding:"8px 12px"},onClick:()=>Qn(!1),children:"Abbrechen"}),e.jsxs("button",{type:"button",className:"cs-btn-outline",title:"Datei anhängen",disabled:hi,onClick:()=>{da.current&&da.current.click()},style:{fontSize:12.5,padding:"8px 11px",display:"inline-flex",alignItems:"center",gap:6,opacity:hi?.6:1},children:[hi?e.jsx("span",{style:{width:12,height:12,border:"2px solid var(--green-bd)",borderTopColor:"var(--green)",borderRadius:"50%",display:"inline-block",animation:"lm-spin .7s linear infinite"}}):e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:14,height:14},children:e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),"Anhang"]}),e.jsx("input",{ref:da,type:"file",multiple:!0,style:{display:"none"},onChange:Jl}),!Hn.length&&e.jsx("span",{style:ye,children:"Empfänger wählen"}),ra&&e.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:ra.startsWith("Fehler")?"var(--red)":"var(--green)"},children:ra})]})]})})(),m?e.jsx("div",{style:{padding:"8px 0"},children:[1,2,3,4,5].map(R=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 15px",borderBottom:"1px solid var(--line)"},children:[e.jsx("div",{className:"cs-skel",style:{width:18,height:18,borderRadius:6}}),e.jsx("div",{className:"cs-skel",style:{width:26,height:26,borderRadius:"50%"}}),e.jsx("div",{className:"cs-skel",style:{width:60,height:11}}),e.jsx("div",{className:"cs-skel",style:{flex:1,height:11}}),e.jsx("div",{className:"cs-skel",style:{width:40,height:9}})]},R))}):d.length===0?e.jsx("div",{className:"cs-empty",children:"Keine E-Mails gefunden."}):M.length===0?e.jsx("div",{className:"cs-empty",children:"Keine offenen E-Mails."}):e.jsxs("div",{className:"cs-listwrap",style:{...Tt,display:"flex",flexDirection:"column",gap:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 15px",borderBottom:"1px solid var(--line)",background:"var(--panel-2)"},children:[e.jsx("div",{onClick:Pe,title:ae?"Auswahl aufheben":"Alle auswählen",style:{width:18,height:18,borderRadius:6,border:"1px solid "+(ae||de?"var(--green)":"var(--line-2)"),background:ae||de?"var(--green)":"var(--panel)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,cursor:"pointer",transition:"all .15s"},children:ae?e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3",style:{width:12,height:12},children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):de?e.jsx("span",{style:{width:9,height:2,borderRadius:1,background:"#fff"}}):null}),e.jsx("span",{style:{fontSize:11.5,fontWeight:700,color:Mn.size>0?"var(--ink)":"var(--ink-3)",fontVariantNumeric:"tabular-nums"},children:Mn.size>0?`${Mn.size}
126 ausgewählt`:"Alle auswählen"}),Mn.size>0&&e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6},children:[e.jsxs("button",{className:"cs-btn-outline",style:{fontSize:11.5,padding:"5px 11px",borderRadius:8,display:"inline-flex",alignItems:"center",gap:5},onClick:st,children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",style:{width:11,height:11},children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Als erledigt markieren"]}),e.jsx("button",{className:"cs-btn-outline",style:{fontSize:11.5,padding:"5px 11px",borderRadius:8},onClick:()=>Is(new Set),children:"Abwählen"})]})]}),M.map((R,Ce)=>{const Se=R[0],xt=(Se.subject||"(kein Betreff)").replace(/^(Re|Fwd|Aw|Wg|Fw):\s*/gi,""),bt=s(Se.subject||""),Je=Es.has(bt),at=Mn.has(bt),Ke=Xs.has(bt),Ze=R.length>1,T=g===Ce,me=z=>{const W=(z.fromEmail||z.from||"").toLowerCase();return wt.find(G=>W.includes(G.key)||W.includes(G.email))||wt.find(G=>G.key===z._via)},E=me(Se),Ye=Se._sent?(E==null?void 0:E.name)||"Ich":Ks(Se,!1,Ws),Re=(Se.snippet||Se.preview||"").substring(0,80);return e.jsxs("div",{style:{background:T?"var(--panel-2)":at?"var(--sel)":"transparent",borderBottom:"1px solid var(--line)",overflow:"hidden",transition:"background .12s",opacity:Je?.5:1},children:[e.jsxs("div",{style:{padding:"10px 15px",cursor:"pointer",transition:"background .12s",display:"flex",alignItems:"center",gap:8},onMouseEnter:z=>{z.currentTarget.style.background="var(--panel-2)",H(z,Se)},onMouseLeave:z=>{T||(z.currentTarget.style.background=at?"var(--sel)":"transparent"),U(z)},onClick:async()=>{if(T){x(null),Z(null),K(null);return}D(bt),x(Ce),Z(null),K(Se.seq),B(!0);try{Z(await ie(Se))}catch{Z("Fehler beim Laden.")}finally{B(!1)}},children:[e.jsx("div",{onClick:z=>{z.stopPropagation(),L(bt)},style:{width:18,height:18,borderRadius:6,border:"1px solid "+(at?"var(--green)":"var(--line-2)"),background:at?"var(--green)":"var(--panel)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,cursor:"pointer",transition:"all .15s"},onMouseEnter:z=>{at||(z.currentTarget.style.borderColor="var(--green)")},onMouseLeave:z=>{at||(z.currentTarget.style.borderColor="var(--line-2)")},children:at&&e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3",style:{width:12,height:12},children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}),e.jsx("div",{style:{display:"flex",flexShrink:0,border:"2px solid var(--panel)",borderRadius:"50%"},children:ms(Se,!!Se._sent,26)}),e.jsx("span",{style:{fontSize:12.5,fontWeight:!Ke&&!Je?700:500,color:Je?"var(--ink-3)":Ke?"var(--ink-2)":"var(--ink)",width:120,flexShrink:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textDecoration:Je?"line-through":"none"},children:Ye}),e.jsx("span",{style:{fontSize:11,fontWeight:700,color:Se._sent?"var(--green)":"#1D4ED8",flexShrink:0},children:Se._sent?"â":"â"}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,overflow:"hidden"},children:[!Ke&&!Je&&e.jsx("span",{style:{...Qe,background:"var(--green)"}}),e.jsx("span",{style:{fontSize:12.5,fontWeight:!Ke&&!Je?700:500,color:Je?"var(--ink-3)":Ke?"var(--ink-2)":"var(--ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"55%",textDecoration:Je?"line-through":"none"},children:xt}),Ze&&e.jsx("span",{style:{...an,...xe,flexShrink:0},children:R.length}),Re&&e.jsxs("span",{style:{fontSize:12,color:"var(--ink-3)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1},children:["â ",Re]})]}),(()=>{const z=Q=>{if(Q._sent){const Wt=me(Q);return["u:"+((Wt==null?void 0:Wt.key)||Q._via||"dima")]}const We=(Q.fromEmail||"").toLowerCase().trim(),Pt=(Q.fromName||"").toLowerCase().replace(/\s+/g," ").trim(),kt=[];return We&&kt.push(We),Pt&&kt.push("n:"+Pt),kt.length||kt.push("?:"+(Q.messageId||Q.seq||Math.random())),kt},W=[],G=new Set;z(Se).forEach(Q=>G.add(Q));for(const Q of R){const We=z(Q);We.some(Pt=>G.has(Pt))||(We.forEach(Pt=>G.add(Pt)),W.push({em:Q,isOut:!!Q._sent,name:Ks(Q,!!Q._sent,Ws)}))}const ze=W.slice(0,4),$e=W.length-ze.length;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",flexShrink:0,width:92},children:[ze.map((Q,We)=>e.jsx("div",{title:Q.name||"",style:{marginLeft:We===0?0:-8,border:"2px s
126olid var(--panel)",borderRadius:"50%",display:"flex",zIndex:ze.length-We},children:ms(Q.em,Q.isOut,22)},We)),$e>0&&e.jsxs("span",{style:{marginLeft:-8,width:22,height:22,borderRadius:"50%",border:"2px solid var(--panel)",background:"var(--panel-2)",color:"var(--ink-2)",fontSize:9.5,fontWeight:700,fontVariantNumeric:"tabular-nums",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,zIndex:0},children:["+",$e]})]})})(),e.jsx("span",{style:{...ye,...xe,flexShrink:0,whiteSpace:"nowrap",width:78,textAlign:"right"},children:St(Se.date)})]}),T&&e.jsxs("div",{style:{background:"var(--panel)",borderTop:"1px solid var(--line)",display:"flex",flexDirection:"column",minHeight:"calc(100vh - 320px)"},children:[R.length>1&&e.jsx("div",{style:{padding:"9px 18px",background:"var(--panel-2)",borderBottom:"1px solid var(--line)",display:"flex",alignItems:"center",gap:8,overflowX:"auto"},children:R.map((z,W)=>{const G=z.date?new Date(z.date):null,ze=G?G.toLocaleDateString("de",{day:"2-digit",month:"short"}):"",$e=G?G.toLocaleTimeString("de",{hour:"2-digit",minute:"2-digit"}):"",Q=Ks(z,!!z._sent,Ws),We=F===z.seq,Pt=We?30:26;return e.jsx("button",{type:"button",title:`${Q} · ${ze} ${$e}`,style:{border:"none",background:"none",padding:0,cursor:"pointer",borderRadius:"50%",flexShrink:0,display:"inline-flex",boxShadow:We?"0 0 0 2px var(--green)":"none",transition:"box-shadow .12s"},onClick:async kt=>
126{kt.stopPropagation(),K(z.seq),Z(null),B(!0);try{Z(await ie(z))}catch{Z("Fehler beim Laden.")}finally{B(!1)}},onMouseEnter:kt=>H(kt,z),onMouseLeave:U,children:ms(z,!!z._sent,Pt)},W)})}),e.jsx("div",{style:{padding:"14px 18px",borderBottom:"1px solid var(--line)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{paddingTop:2},children:ms(Se,!!Se._sent,32)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:15,fontWeight:800,color:"var(--ink)",letterSpacing:"-.016em",marginBottom:5},children:xt}),e.jsxs("div",{style:{fontSize:11.5,color:"var(--ink-3)",fontWeight:600,lineHeight:1.6},children:[e.jsxs("span",{children:["Von: ",e.jsx("span",{style:{color:"var(--ink-2)"},children:Se._sent?((E==null?void 0:E.name)||"LIBERDA Media")+" <"+((E==null?void 0:E.email)||"")+">":(Se.fromName||"")+" <"+(Se.fromEmail||"")+">"})]}),e.jsx("br",{}),e.jsxs("span",{children:["An: ",e.jsx("span",{style:{color:"var(--ink-2)"},children:Se._sent?o(n,i.contactEmail):(E==null?void 0:E.email)||Se.to||""})]})]})]}),e.jsxs("div",{style:{textAlign:"right",flexShrink:0},children:[e.jsx("div",{style:{...ye,...xe,marginBottom:7},children:St(Se.date)}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{title:"Antworten",style:{...zn,width:28,height:28,fontSize:14},onMouseEnter:z=>{z.currentTarget.style.borderColor="var(--green)",z.currentTarget.style.color="var(--green)"},onMouseLeave:z=>{z.currentTarget.style.borderColor="var(--line)",z.currentTarget.style.color="var(--ink-2)"},onClick:z=>{z.stopPropagation(),Qn(!0),aa(Se._via||"dima"),ps("Re: "+(Se.subject||"")),hs("")},children:"â©"}),e.jsx("button",{title:"Weiterleiten",style:{...zn,width:28,height:28,fontSize:14},onMouseEnter:z=>{z.currentTarget.style.borderColor="var(--green)",z.currentTarget.style.color="var(--green)"},onMouseLeave:z=>{z.currentTarget.style.borderColor="var(--line)",z.currentTarget.style.color="var(--ink-2)"},onClick:z=>{z.stopPropagation(),Qn(!0),aa(Se._via||"dima"),ps("Fwd: "+(Se.subject||"")),hs("")},children:"â"})]})]})]})}),e.jsx("div",{style:{padding:0,background:"var(--panel-2)",flex:1,minHeight:"calc(100vh - 450px)"},children:I?e.jsxs("div",{style:{padding:18},children:[e.jsx("div",{className:"cs-skel",style:{width:"38%",height:12,marginBottom:12}}),e.jsx("div",{className:"cs-skel",style:{width:"96%",height:9,marginBottom:7}}),e.jsx("div",{className:"cs-skel",style:{width:"88%",height:9,marginBottom:7}}),e.jsx("div",{className:"cs-skel",style:{width:"70%",height:9}})]}):le?e.jsxs("div",{style:{margin:"16px",background:"var(--panel)",border:"1px solid var(--line)",borderRadius:13,padding:24},children:[e.jsx(Ia,{rawBody:le,attCtx:j||void 0}),j&&e.jsx(Oa,{...j})]}):null})]})]},Ce)})]})]})})(),dt==="ads"&&e.jsx("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:e.jsx(lc,{firma:o(n,i.displayName)||o(n,i.leadName)})}),dt==="projects"&&e.jsx("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:Dl?e.jsx("div",{style:{padding:20},children:[1,2,3].map(s=>e.jsxs("div",{style:{...Nn,marginBottom:8},children:[e.jsx("div",{className:"cs-skel",style:{width:"50%",height:14,marginBottom:8}}),e.jsx("div",{className:"cs-skel",style:{width:"30%",height:10}})]},s))}):Fn.length===0?e.jsx("div",{className:"cs-empty",children:"Keine Projekte mit diesem Kunden gefunden."}):(()=>{const s={"In Bearbeitung":{bg:"transparent",color:"var(--ink-2)",border:"var(--line)",dot:"#1D4ED8"},Abgeschlossen:{bg:"transparent",color:"var(--ink-2)",border:"var(--line)",dot:"var(--green)"},Planung:{bg:"transparent",color:"var(--ink-2)",border:"var(--line)",dot:"#92610A"},Pausiert:{bg:"transparent",color:"var(--ink-2)",border:"var(--line)",dot:"var(--ink-3)"}},c=Fn.filter(w=>{var te,L,Y;return!(((L=(te=w.fields)==null?void 0:te.K4jmU)==null?void 0:L.label)||((Y=w.fields)==null?void 0:Y.K4jmU)||"").toLowerCase().includes("abgeschlossen")}),d=Fn.filter(w=>{var te,L,Y;return(((L=(te=w.fields)==null?void 0:te.K4jmU)==null?void 0:L.label)||((Y=w.fields)==null?void 0:Y.K4jmU)||"").toLowerCase().includes("abgeschlossen")}),y=b.trim().toLowerCase(),D=Fn.filter(w=>{var L,Y,ae,de,Pe;const M=(((Y=(L=w.fields)==null?void 0:L.K4jmU)==null?void 0:Y.label)||((ae=w.fields)==null?void 0:ae.K4jmU)||"").toLowerCase(),te=M.includes("abgeschlossen");if(fn==="aktiv"&&te||fn==="abgeschlossen"&&!te)return!1;if(y){const st=((((de=w.fields)==null?void 0:de.MRsFW)||"")+"").toLowerCase(),R=((((Pe=w.fields)==null?void 0:Pe.VECkn)||"")+"").toLowerCase();if(!st.includes(y)&&!R.includes(y)&&!M.includes(y))return!1}return!0});return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{...Tt,display:"grid",gridTemplateColumns:"repeat(3,1fr)",marginBottom:12},children:[{key:"alle",val:Fn.length,label:"Gesamt"},{key:"aktiv",val:c.length,label:"Aktiv"},{key:"abgeschlossen",val:d.length,label:"Abgeschlossen"}].map((w,M)=>{const te=fn===w.key;return e.jsxs("button",{onClick:()=>{Dn(w.key),Yt(10)},style:{padding:"15px 16px",background:te?"var(--sel)":"transparent",border:"none",borderRight:M<2?"1px solid var(--line)":"none",cursor:"pointer",fontFamily:"inherit",textAlign:"left",transition:"background .14s"},children:[e.jsx("div",{style:{...xe,fontSize:22,fontWeight:800,color:te?"var(--green)":"var(--ink)",letterSpacing:"-.032em",lineHeight:1},children:w.val}),e.jsx("div",{style:{...fe,color:te?"var(--green)":"var(--ink-3)",marginTop:6},children:w.label})]},w.key)})}),e.jsxs("div",{style:{position:"relative",marginBottom:20},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--ink-3)",strokeWidth:"2",style:{width:15,height:15,position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{value:b,onChange:w=>{re(w.target.value),Yt(10)},placeholder:"Projekte durchsuchenâ¦",style:{...Ct,padding:"9px 32px 9px 34px",boxSizing:"border-box"},onFocus:w=>w.currentTarget.style.borderColor="var(--green)",onBlur:w=>w.currentTarget.style.borderColor="var(--line-2)"}),b&&e.jsx("button",{onClick:()=>re(""),style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:13,color:"var(--ink-3)",padding:4,lineHeight:1,fontFamily:"inherit"},title:"Suche löschen",children:"â"})]}),D.length===0?e.jsx("div",{className:"cs-empty",children:y?`Keine Projekte für â${b}".`:"Keine Projekte für diesen Filter."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5,1fr)",gap:10},children:D.slice(0,zt).map((w,M)=>{var R,Ce,Se,xt,bt,Je,at,Ke,Ze,T;const te=((R=w.fields)==null?void 0:R.MRsFW)||"Projekt",L=((Se=(Ce=w.fields)==null?void 0:Ce.K4jmU)==null?void 0:Se.label)||((xt=w.fields)==null?void 0:xt.K4jmU)||"",Y=((bt=w.fields)==null?void 0:bt.sJWgj)||"",ae=ll(((at=(Je=w.fields)==null?void 0:Je.eIre3)==null?void 0:at.url)||(Array.isArray((Ke=w.fields)==null?void 0:Ke.eIre3)?(Ze=w.fields.eIre3[0])==null?void 0:Ze.url:null)||"")||null;(T=w.fields)!=null&&T.VECkn;const de=s[L]||s.Pausiert,st=L.toLowerCase().includes("abgeschlossen")?100:L.toLowerCase().includes("bearbeitung")?60:L.toLowerCase().includes("planung")?20:0;return e.jsxs("a",{href:`/projektdetails-intern?recordId=${encodeURIComponent(w.id)}`,style:{textDecoration:"none",color:"inherit",display:"block",background:"var(--panel)",borderRadius:13,border:"1px solid var(--line)",overflow:"hidden",transition:"border-color .15s,background .15s"},onMouseEnter:me=>{me.currentTarget.style.borderColor="var(--line-2)",me.currentTarget.style.background="var(--panel-2)"},onMouseLeave:me=>{me.currentTarget.style.borderColor="var(--line)",me.currentTarget.style.background="var(--panel)"},children:[ae&&e.jsx("img",{src:ae,alt:"",style:{width:"100%",height:120,objectFit:"cover",borderBottom:"1px solid var(--line)"}}),e.jsxs("div",{style:{padding:"12px 14px"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",letterSpacing:"-.012em",marginBottom:5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:te}),L&&e.jsxs("span",{style:{...rn,fontSize:11,marginBottom:6},children:[e.jsx("span",{style:{...Qe,width:6,height:6,background:de.dot}}),L]}),Y&&e.jsx("div",{style:{...ye,...xe,marginBottom:7},children:St(Y)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{flex:1,height:4,borderRadius:6,background:"var(--panel-2)",border:"1px solid var(--line)",overflow:"hidden"},children:e.jsx("div",{style:{width:`${st}%`,height:"100%",background:de.dot,transition:"width 1s cubic-bezier(.22,1,.36,1)"}})}),e.jsxs("span",{style:{...xe,fontSize:10,fontWeight:700,color:"var(--ink-3)"},children:[st,"%"]})]})]})]},w.id)})}),D.length>zt&&e.jsx("div",{style:{textAlign:"center",marginTop:12},children:e.jsxs("button",{className:"cs-btn-outline",style:{fontSize:12.5},onClick:()=>Yt(w=>w+10),children:["Mehr laden (",D.length-zt," weitere)"]})})]})]})})()}),dt==="files"&&(()=>{const s=hn.flatMap(d=>(d.attachments||[]).filter(y=>y&&y.url).map(y=>({name:y.name||"anhang",url:y.url,content_type:y.content_type||"",size:y.size||0,emailDate:d.date||"",emailFrom:d.author?`${d.author} · Close-Archiv`:"Close-Archiv",_close:!0}))).filter(d=>!os.some(y=>String(y.name)===String(d.name)&&(Number(y.size)||0)===(Number(d.size)||0))),c=[...os,...s];return e.jsx("div",{className:"cs-files-list",children:Wl?e.jsx("div",{className:"cs-empty",children:"Lade Dateien..."}):c.length===0?e.jsx("div",{className:"cs-empty",children:"Keine Dateien/Anhänge mit diesem Lead gefunden."}):c.map((d,y)=>{var Y,ae;const D=((ae=(Y=d.name)==null?void 0:Y.split(".").pop())==null?void 0:ae.toLowerCase())||"",w=["jpg","jpeg","png","gif","webp","svg","bmp","heic","avif"].includes(D),M=D==="pdf",te=w?"#5B21B6":M?"var(--red)":"#1D4ED8",L=d._close?`${ln}/api/close-file?url=${encodeURIComponent(d.url)}&name=${encodeURIComponent(d.name||"anhang")}`:"";return e.jsxs("div",{className:"cs-file-item",onClick:()=>d._close?window.open(L,"_blank"):ea(d),children:[e.jsxs("div",{style:{position:"relative",width:56,height:56,flexShrink:0,borderRadius:10,overflow:"hidden",border:"1px solid var(--line)",background:"var(--panel-2)",color:te,display:"flex",alignItems:"center",justifyContent:"center"},children:[w?e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:18,height:18},children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("path",{d:"M21 15l-5-5L5 21"})]}):M?e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:18,height:18},children:[e.jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}):e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:18,height:18},children:[e.jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),w&&(d._close?e.jsx("img",{src:L,alt:"",loading:"lazy",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",display:"block"},onError:de=>{de.target.style.display="none"}}):e.jsx(Js,{f:d,kind:"img",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",display:"block"}}))]}),e.jsxs("div",{className:"cs-file-info",children:[e.jsx("div",{className:"cs-file-name",children:d.name}),e.jsxs("div",{className:"cs-file-meta",children:[e.jsxs("span",{className:"cs-file-ext",children:[".",D]}),d.emailFrom&&e.jsxs("span",{children:[" · ",d.emailFrom]}),d.emailDate&&e.jsxs("span",{children:[" · ",St(d.emailDate)]})]})]}),e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:14,height:14,color:"var(--ink-3)",flexShrink:0},children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})]},y)})})})(),dt==="analytics"&&(()=>{const s=(o(n,i.displayName)||o(n,i.leadName)||"").trim(),c=he&&he._company===s?he:null,d=w=>
126(Number(w)||0).toLocaleString("de-DE",{style:"currency",currency:"EUR",maximumFractionDigits:0}),y=Fn.map(w=>{var M;return(M=w.fields)==null?void 0:M.sJWgj}).filter(Boolean),D=y.length?y.reduce((w,M)=>new Date(w)<=new Date(M)?w:M):"";return e.jsxs("div",{style:{padding:"16px 16px 20px"},children:[e.jsxs("div",{style:{...Nn,marginBottom:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Gesamtumsatz"}),e.jsx("div",{style:{...ye,marginTop:3},children:"sevDesk · netto"})]}),e.jsx("div",{style:{textAlign:"right"},children:Te&&!c?e.jsx("div",{style:ye,children:"lädtâ¦"}):c&&c._error?e.jsx("div",{style:{...ye,color:"var(--red)"},children:"nicht verfügbar"}):c&&!c.found?e.jsx("div",{style:ye,children:"keine Rechnungen"}):c?e.jsx("div",{style:{...xe,fontSize:22,fontWeight:800,color:"var(--gold-text)",letterSpacing:"-.032em",lineHeight:1},title:`netto ${c.totalNet} ⬠· brutto ${c.totalGross} â¬`,children:d(c.totalNet)}):e.jsx("div",{style:ye,children:"â"})})]}),c&&c.found&&e.jsxs("div",{style:{...ki,display:"flex",gap:20,marginTop:12,flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Bezahlt"}),e.jsx("div",{style:{...xe,fontSize:13,fontWeight:700,color:"var(--green)",marginTop:3},children:d(c.paidNet)})]}),e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Offen"}),e.jsx("div",{style:{...xe,fontSize:13,fontWeight:700,color:c.openNet>0?"#92610A":"var(--ink-2)",marginTop:3},children:d(c.openNet)})]}),e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Rechnungen"}),e.jsx("div",{style:{...xe,fontSize:13,fontWeight:700,color:"var(--ink)",marginTop:3},children:c.invoiceCount})]})]})]}),e.jsxs("div",{className:"cs-analytics-grid cs-analytics-grid--2",children:[e.jsxs("div",{className:"cs-analytics-card",children:[e.jsx("div",{className:"cs-analytics-num",children:o(n,i.numEmails)||"0"}),e.jsx("div",{className:"cs-analytics-label",children:"E-Mails"})]}),e.jsxs("div",{className:"cs-analytics-card",children:[e.jsx("div",{className:"cs-analytics-num",children:o(n,i.numCalls)||"0"}),e.jsx("div",{className:"cs-analytics-label",children:"Anrufe"})]}),e.jsxs("div",{className:"cs-analytics-card",children:[e.jsx("div",{className:"cs-analytics-num",children:o(n,i.numMeetings)||"0"}),e.jsx("div",{className:"cs-analytics-label",children:"Meetings"})]}),e.jsxs("div",{className:"cs-analytics-card",children:[e.jsx("div",{className:"cs-analytics-num",children:Fn.length}),e.jsx("div",{className:"cs-analytics-label",children:"Projekte"})]}),e.jsxs("div",{className:"cs-analytics-card",children:[e.jsx("div",{className:"cs-analytics-num",children:Ot.length}),e.jsx("div",{className:"cs-analytics-label",children:"Kontakte"})]})]}),e.jsx("div",{style:{...fe,margin:"18px 0 8px"},children:"Verlauf in Zahlen"}),e.jsxs("div",{className:"cs-analytics-rows",style:{...Tt,padding:"0 15px"},children:[e.jsxs("div",{className:"cs-analytics-row",children:[e.jsx("span",{children:"Kunde seit"}),e.jsx("span",{className:"cs-analytics-val",children:D?St(D):"â"})]}),e.jsxs("div",{className:"cs-analytics-row",children:[e.jsx("span",{children:"Letzte Aktivität"}),e.jsx("span",{className:"cs-analytics-val",children:o(n,i.lastActivityDate)?St(o(n,i.lastActivityDate)):"â"})]}),e.jsxs("div",{className:"cs-analytics-row",children:[e.jsx("span",{children:"Letzte E-Mail"}),e.jsx("span",{className:"cs-analytics-val",children:o(n,i.lastEmailDate)?St(o(n,i.lastEmailDate)):"â"})]}),e.jsxs("div",{className:"cs-analytics-row",children:[e.jsx("span",{children:"Ausgehende E-Mails"}),e.jsx("span",{className:"cs-analytics-val",children:o(n,"Ovvrf")||"0"})]}),e.jsxs("div",{className:"cs-analytics-row",children:[e.jsx("span",{children:"Eingehende E-Mails"}),e.jsx("span",{className:"cs-analytics-val",children:o(n,"5S3B2")||"0"})]}),e.jsxs("div",{className:"cs-analytics-row",children:[e.jsx("span",{children:"Erstellt am"}),e.jsx("span",{className:"cs-analytics-val",children:o(n,i.dateCreated)?St(o(n,i.dateCreated)):"â"})]})]})]})})(),dt==="termin"&&e.jsx("div",{style:{padding:"14px 20px 20px"},children:e.jsx("div",{style:{background:"var(--panel)",border:"1px solid var(--line)",borderRadius:13,overflow:"hidden"},children:e.jsx("iframe",{title:"Termin buchen",src:"https://calendly.com/liberdamedia/qc",style:{width:"100%",height:720,border:"none",display:"block",background:"var(--panel-2)"}})})}),dt==="calls"&&e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Lead"}),e.jsx("h3",{style:{fontSize:22,fontWeight:800,color:"var(--ink)",letterSpacing:"-.024em",marginTop:4},children:"Anrufe"})]}),e.jsx("button",{className:"cs-btn-outline",style:{fontSize:12.5,display:"flex",alignItems:"center",gap:6},onClick:()=>Vi(!Us),children:Us?"Abbrechen":"Anruf loggen"})]}),Us&&e.jsxs("div",{style:{background:"var(--panel)",border:"1px solid var(--line)",borderRadius:13,padding:16,marginBottom:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",ga
126p:12,marginBottom:12},children:[e.jsx(It,{userKey:(a==null?void 0:a.key)||"dima",size:34}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--ink)",letterSpacing:"-.012em"},children:(a==null?void 0:a.name)||"Dima Liberda"}),e.jsx("div",{style:{...ye,marginTop:2},children:"loggt einen Anruf"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginBottom:10,paddingLeft:46},children:[e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:6},children:"Typ"}),e.jsxs("select",{value:ot.typ,onChange:s=>Sn({...ot,typ:s.target.value}),style:Ct,children:[e.jsx("option",{value:"ausgehend",children:"Ausgehend"}),e.jsx("option",{value:"eingehend",children:"Eingehend"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:6},children:"Dauer (Min.)"}),e.jsx("input",{type:"number",min:0,value:ot.dauer,onChange:s=>Sn({...ot,dauer:+s.target.value}),style:{...Ct,...xe,boxSizing:"border-box"},placeholder:"z.B. 15"})]})]}),e.jsxs("div",{style:{marginBottom:10,paddingLeft:46},children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:6},children:"Ergebnis"}),e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:["Erreicht","Nicht erreicht","Termin vereinbart","Angebot besprochen","Projekt besprochen"].map(s=>e.jsx("button",{onClick:()=>Sn({...ot,ergebnis:s}),style:{padding:"6px 12px",borderRadius:8,border:"1px solid "+(ot.ergebnis===s?"var(--ink)":"var(--line)"),background:ot.ergebnis===s?"var(--ink)":"transparent",fontSize:12,fontWeight:ot.ergebnis===s?700:600,color:ot.ergebnis===s?"#fff":"var(--ink-2)",cursor:"pointer",fontFamily:"inherit",transition:"all .14s"},children:s},s))})]}),e.jsxs("div",{style:{marginBottom:10,paddingLeft:46},children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:6},children:"Ansprechpartner (optional, mehrere möglich)"}),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[Ot.slice(0,12).map(s=>{var y,D,w,M,te,L;const c=((y=s.fields)==null?void 0:y["707oq"])||((D=s.fields)==null?void 0:D["5OGPi"])||"?",d=ot.kontakte.includes(s.id);return e.jsxs("button",{type:"button",onClick:()=>Sn({...ot,kontakte:d?ot.kontakte.filter(Y=>Y!==s.id):[...ot.kontakte,s.id]}),style:{display:"inline-flex",alignItems:"center",gap:7,padding:"5px 11px 5px 6px",borderRadius:8,border:"1px solid "+(d?"var(--green-bd)":"var(--line)"),background:d?"var(--green-soft)":"transparent",cursor:"pointer",fontSize:11.5,fontWeight:d?700:600,color:d?"var(--green)":"var(--ink-2)",fontFamily:"inherit",transition:"all .12s"},children:[e.jsx(En,{contactId:s.id,name:c,email:((w=s.fields)==null?void 0:w.CIy6k)||((M=s.fields)==null?void 0:M.z0xSB),company:(te=s.fields)==null?void 0:te["4Fk6j"],leadUrl:o(n,i.url),storedAvatar:(L=s.fields)==null?void 0:L.Hb2om,size:20}),c]},s.id)}),Ot.length===0&&e.jsx("span",{style:ye,children:"Keine Kontakte hinterlegt."})]})]}),e.jsxs("div",{style:{marginBottom:12,paddingLeft:46},children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:6},children:"Notiz"}),e.jsx("textarea",{value:ot.notiz,onChange:s=>Sn({...ot,notiz:s.target.value}),placeholder:"Was wurde besprochen?",style:{...Ct,minHeight:60,resize:"vertical",boxSizing:"border-box",lineHeight:1.6}})]}),e.jsx("div",{style:{paddingLeft:46},children:e.jsx("button",{onClick:Er,disabled:Ys||!ot.ergebnis,style:{...Pn,padding:"8px 18px",cursor:ot.ergebnis?"pointer":"not-allowed",opacity:ot.ergebnis?1:.45},children:Ys?"Speichert...":"Anruf speichern"})})]}),e.jsxs("div",{style:{...Tt,display:"grid",gridTemplateColumns:"repeat(3,1fr)",marginBottom:16},children:[e.jsxs("div",{style:{padding:"14px 16px",borderRight:"1px solid var(--line)",textAlign:"center"},children:[e.jsx("div",{style:{...xe,fontSize:22,fontWeight:800,color:"var(--ink)",letterSpacing:"-.032em"},children:(Number(o(n,i.numCalls))||0)+An.length}),e.jsx("div",{style:{...fe,marginTop:6},children:"Gesamt"})]}),e.jsxs("div",{style:{padding:"14px 16px",borderRight:"1px solid var(--line)",textAlign:"center"},children:[e.jsx("div",{style:{...xe,fontSize:22,fontWeight:800,color:"var(--green)",letterSpacing:"-.032em"},children:(Number(o(n,"Te0CV"))||0)+An.filter(s=>s.typ==="ausgehend").length}),e.jsx("div",{style:{...fe,marginTop:6},children:"Ausgehend"})]}),e.jsxs("div",{style:{padding:"14px 16px",textAlign:"center"},children:[e.jsx("div",{style:{...xe,fontSize:22,fontWeight:800,color:"#1D4ED8",letterSpacing:"-.032em"},children:(Number(o(n,"wKc7y"))||0)+An.filter(s=>s.typ==="eingehend").length}),e.jsx("div",{style:{...fe,marginTop:6},children:"Eingehend"})]})]}),An.length===0&&hn.filter(s=>s.type==="call").length===0&&!o(n,"Ctbik")?e.jsx("div",{className:"cs-empty",children:'Noch keine Anrufe dokumentiert. Klicke oben auf "Anruf loggen".'}):e.jsxs("div",{className:"cs-listwrap",style:{...Tt,display:"flex",flexDirection:"column"},children:[An.map(s=>e.jsx("div",{style:{background:"transparent",borderBottom:"1px solid var(--line)",padding:"13px 15px",transition:"background .12s"},onMouseEnter:c=>c.currentTarget.style.background="var(--panel-2)",onMouseLeave:c=>c.currentTarget.style.background="transparent",children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",ga
126p:12},children:[e.jsx(It,{userKey:s.userKey||"dima",size:34}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:s.autor}),e.jsxs("span",{style:{...rn},children:[e.jsx("span",{style:{...Qe,background:s.typ==="ausgehend"?"#5B21B6":"#1D4ED8"}}),s.typ==="ausgehend"?"ausgehend":"eingehend"," · ",s.ergebnis]}),s.dauer>0&&e.jsxs("span",{style:{...ye,...xe,display:"inline-flex",alignItems:"center",gap:4},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:10,height:10},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),s.dauer," Min."]})]}),e.jsx("span",{style:{...ye,...xe,flexShrink:0,marginLeft:8},children:St(s.date)})]}),Array.isArray(s.kontakte)&&s.kontakte.length>0&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:5,marginTop:2,marginBottom:2},children:s.kontakte.map(c=>{var D,w,M,te,L,Y;const d=Ot.find(ae=>ae.id===c);if(!d)return null;const y=((D=d.fields)==null?void 0:D["707oq"])||((w=d.fields)==null?void 0:w["5OGPi"])||"";return e.jsx("span",{title:y,style:{display:"inline-flex"},children:e.jsx(En,{contactId:d.id,name:y,email:((M=d.fields)==null?void 0:M.CIy6k)||((te=d.fields)==null?void 0:te.z0xSB),company:(L=d.fields)==null?void 0:L["4Fk6j"],leadUrl:o(n,i.url),storedAvatar:(Y=d.fields)==null?void 0:Y.Hb2om,size:20})},c)})}),s.notiz&&e.jsx(vn,{text:s.notiz,accent:"",bg:"var(--panel-2)",border:"1px solid var(--line)",padding:"10px 14px",marginTop:6,clampLines:8})]})]})},s.id)),hn.filter(s=>s.type==="call").slice().sort((s,c)=>(c.date||"").localeCompare(s.date||"")).map(s=>e.jsx("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[(()=>{const c=js(s.author);return c?e.jsx(It,{userKey:c.key,size:34}):e.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"#1D4ED8",strokeWidth:"1.6",style:{width:15,height:15},children:e.jsx("path",{d:"M22 16.9v3a2 2 0 01-2.2 2 19.8 19.8 0 01-8.6-3.1 19.5 19.5 0 01-6-6A19.8 19.8 0 012.1 4.2 2 2 0 014.1 2h3a2 2 0 012 1.7c.1 1 .4 1.9.7 2.8a2 2 0 01-.5 2.1L8.1 9.9a16 16 0 006 6l1.3-1.2a2 2 0 012.1-.5c.9.3 1.8.6 2.8.7a2 2 0 011.7 2z"})})})})(),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:s.author||"Anruf"}),e.jsxs("span",{style:rn,children:[s.direction?e.jsx("span",{style:{...Qe,background:s.direction==="outbound"?"#5B21B6":"#1D4ED8"}}):null,s.direction==="outbound"?"ausgehend":s.direction==="inbound"?"eingehend":""," ",s.disposition||""]}),Number(s.duration)>0&&e.jsxs("span",{style:{...ye,...xe},children:[Math.round(Number(s.duration)),"s"]}),e.jsx("span",{style:an,children:"Close CRM"})]}),e.jsx("span",{style:{...ye,...xe,flexShrink:0,marginLeft:8},children:St(s.date)})]}),s.body&&e.jsx(vn,{text:s.body,accent:"",bg:"var(--panel-2)",border:"1px solid var(--line)",padding:"10px 14px",marginTop:6,clampLines:8})]})]})},s.id)),o(n,"Ctbik")&&e.jsx("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px",opacity:.6},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx(It,{userKey:"dima",size:34}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:"Dima Liberda"}),e.jsx("span",{style:{fontSize:11.5,color:"var(--ink-2)",fontWeight:600},children:o(n,i.closeNotes)||"Anruf"}),o(n,"6rH5w")&&e.jsxs("span",{style:{...ye,...xe},children:[o(n,"6rH5w"),"s"]})]}),e.jsx("span",{style:{...ye,...xe},children:St(o(n,"Ctbik"))})]}),e.jsx("div",{style:{...ye,marginTop:5},children:"Importiert aus Close CRM"})]})]})}),o(n,i.closeCallDesc)&&e.jsx("div",{style:{padding:"13px 15px",opacity:.85},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",ga
126p:12},children:[e.jsx(It,{userKey:"dima",size:34}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:"Anruf-Protokoll"}),e.jsx("span",{style:an,children:"Close CRM"})]}),e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",lineHeight:1.6,whiteSpace:"pre-wrap",background:"var(--panel-2)",borderRadius:8,padding:"10px 14px",border:"1px solid var(--line)"},children:o(n,i.closeCallDesc)})]})]})})]})]}),dt==="notes"&&e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Lead"}),e.jsx("h3",{style:{fontSize:22,fontWeight:800,color:"var(--ink)",letterSpacing:"-.024em",marginTop:4},children:"Notizen"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsxs("span",{style:{...ye,...xe},children:[u.length+hn.filter(s=>s.type==="note").length+(o(n,i.wichtig)?1:0)+(o(n,i.lastCommSummary)?1:0)+(o(n,i.closeNotes)?1:0)," Einträge"]}),e.jsx("button",{className:"cs-btn-outline",style:{fontSize:12.5,display:"flex",alignItems:"center",gap:6},onClick:()=>Cl(s=>!s),children:Ya?"Abbrechen":"Notiz erstellen"})]})]}),Ya&&e.jsx("div",{style:{background:"var(--panel)",border:"1px solid var(--line)",borderRadius:13,padding:20,marginBottom:16},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx(It,{userKey:(a==null?void 0:a.key)||"dima",size:34}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,flexWrap:"wrap",marginBottom:7},children:[e.jsx("button",{type:"button",title:"Fett",onMouseDown:s=>s.preventDefault(),onClick:()=>{var s,c;return(c=(s=ht.current).exec)==null?void 0:c.call(s,"bold")},style:{...ss,fontWeight:800},children:"F"}),e.jsx("button",{type:"button",title:"Kursiv",onMouseDown:s=>s.preventDefault(),onClick:()=>{var s,c;return(c=(s=ht.current).exec)==null?void 0:c.call(s,"italic")},style:{...ss,fontStyle:"italic",fontWeight:700},children:"K"}),e.jsx("button",{type:"button",title:"Textmarker (gelb)",onMouseDown:s=>s.preventDefault(),onClick:()=>{var s,c;return(c=(s=ht.current).exec)==null?void 0:c.call(s,"hiliteColor","#fef08a")},style:{...ss,background:bn,borderColor:"var(--gold-2)",color:"var(--gold-text)",fontWeight:800},children:"M"}),e.jsx("span",{style:{width:1,height:18,background:"var(--line)",margin:"0 2px"}}),[["rot","#B3261E"],["gruen","#0F7A57"],["blau","#1D4ED8"],["lila","#5B21B6"]].map(([s,c])=>e.jsx("button",{type:"button",title:`Textfarbe ${s}`,onMouseDown:d=>d.preventDefault(),onClick:()=>{var d,y;return(y=(d=ht.current).exec)==null?void 0:y.call(d,"foreColor",c)},style:{...ss,minWidth:24,width:24,padding:0},children:e.jsx("span",{style:{width:13,height:13,borderRadius:"50%",background:c,display:"block"}})},s)),e.jsx("span",{style:{width:1,height:18,background:"var(--line)",margin:"0 2px"}}),e.jsx("button",{type:"button",title:"Ãberschrift groÃ",onMouseDown:s=>s.preventDefault(),onClick:()=>{var s,c;return(c=(s=ht.current).exec)==null?void 0:c.call(s,"formatBlock","<h3>")},style:{...ss,fontWeight:700,fontSize:12},children:"A"}),e.jsx("button",{type:"button",title:"Ãberschrift sehr groÃ",onMouseDown:s=>s.preventDefault(),onClick:()=>{var s,c;return(c=(s=ht.current).exec)==null?void 0:c.call(s,"formatBlock","<h2>")},style:{...ss,fontWeight:800,fontSize:15},children:"A"}),e.jsx("span",{style:{width:1,height:18,background:"var(--line)",margin:"0 2px"}}),e.jsxs("button",{type:"button",title:"Bild oder PDF anhängen",onClick:()=>{Wn.current&&Wn.current.click()},disabled:nn,style:{...ss,color:"var(--green)",gap:5,padding:"0 9px",borderColor:"var(--green-bd)",opacity:nn?.6:1},children:[nn?e.jsx("span",{style:{width:12,height:12,border:"2px solid var(--green-bd)",borderTopColor:"var(--green)",borderRadius:"50%",display:"inline-block",animation:"lm-spin .7s linear infinite"}}):e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:14,height:14},children:e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),e.jsx("span",{style:{fontSize:11.5,fontWeight:600},children:"Anhang"})]}),e.jsx("input",{ref:Wn,type:"file",accept:"image/*,application/pdf,.pdf",multiple:!0,style:{display:"none"},onChange:$l})]}),e.jsx(xc,{value:Ee,onChange:Me,onSubmit:wr,editorApi:ht,onFiles:Sr}),Tn.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:8}
126,children:Tn.map((s,c)=>{const d=(s.content_type||"").includes("image");return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:7,padding:"5px 8px 5px 5px",background:"var(--panel)",border:"1px solid var(--line)",borderRadius:8,maxWidth:220},children:[d?e.jsx("img",{src:s.url,alt:"",style:{width:26,height:26,borderRadius:6,objectFit:"cover",display:"block",flexShrink:0}}):e.jsx("span",{style:{width:26,height:26,borderRadius:6,background:"var(--red-soft)",color:"var(--red)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:800,flexShrink:0},children:"PDF"}),e.jsx("span",{style:{fontSize:11.5,color:"var(--ink-2)",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.name}),e.jsx("button",{type:"button",onClick:()=>rs(y=>y.filter((D,w)=>w!==c)),title:"Entfernen",style:{background:"none",border:"none",cursor:"pointer",color:"var(--ink-3)",fontSize:13,lineHeight:1,padding:0,flexShrink:0,fontFamily:"inherit"},children:"â"})]},c)})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:8},children:[e.jsx("span",{style:ye,children:"â+Enter zum Speichern · Auswahl markieren, dann Format klicken"}),e.jsx("button",{onClick:wr,disabled:pt||!Ee.trim()&&Tn.length===0,style:{...Pn,padding:"8px 16px",cursor:!Ee.trim()&&Tn.length===0?"not-allowed":"pointer",opacity:!Ee.trim()&&Tn.length===0?.45:1},children:pt?"Speichertâ¦":"Notiz speichern"})]})]})]})}),Us&&e.jsxs("div",{style:{background:"var(--panel)",border:"1px solid var(--line)",borderRadius:13,padding:16,marginBottom:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12,marginBottom:12},children:[e.jsx(It,{userKey:(a==null?void 0:a.key)||"dima",size:34}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--ink)",letterSpacing:"-.012em"},children:(a==null?void 0:a.name)||"Dima Liberda"}),e.jsx("div",{style:{...ye,marginTop:2},children:"loggt einen Anruf"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginBottom:10,paddingLeft:46},children:[e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:6},children:"Typ"}),e.jsxs("select",{value:ot.typ,onChange:s=>Sn({...ot,typ:s.target.value}),style:Ct,children:[e.jsx("option",{value:"ausgehend",children:"Ausgehend"}),e.jsx("option",{value:"eingehend",children:"Eingehend"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:6},children:"Dauer (Min.)"}),e.jsx("input",{type:"number",min:0,value:ot.dauer,onChange:s=>Sn({...ot,dauer:+s.target.value}),style:{...Ct,...xe,boxSizing:"border-box"},placeholder:"z.B. 15"})]})]}),e.jsxs("div",{style:{marginBottom:10,paddingLeft:46},children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:6},children:"Ergebnis"}),e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:["Erreicht","Nicht erreicht","Termin vereinbart","Angebot besprochen","Projekt besprochen"].map(s=>e.jsx("button",{onClick:()=>Sn({...ot,ergebnis:s}),style:{padding:"6px 12px",borderRadius:8,border:"1px solid "+(ot.ergebnis===s?"var(--ink)":"var(--line)"),background:ot.ergebnis===s?"var(--ink)":"transparent",fontSize:12,fontWeight:ot.ergebnis===s?700:600,color:ot.ergebnis===s?"#fff":"var(--ink-2)",cursor:"pointer",fontFamily:"inherit",transition:"all .14s"},children:s},s))})]}),e.jsxs("div",{style:{marginBottom:10,paddingLeft:46},children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:6},children:"Ansprechpartner (optional, mehrere möglich)"}),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[Ot.slice(0,12).map(s=>{var y,D,w,M,te,L;const c=((y=s.fields)==null?void 0:y["707oq"])||((D=s.fields)==null?void 0:D["5OGPi"])||"?",d=ot.kontakte.includes(s.id);return e.jsxs("button",{type:"button",onClick:()=>Sn({...ot,kontakte:d?ot.kontakte.filter(Y=>Y!==s.id):[...ot.kontakte,s.id]}),style:{display:"inline-flex",alignItems:"center",gap:7,padding:"5px 11px 5px 6px",borderRadius:8,border:"1px solid "+(d?"var(--green-bd)":"var(--line)"),background:d?"var(--green-soft)":"transparent",curs
126or:"pointer",fontSize:11.5,fontWeight:d?700:600,color:d?"var(--green)":"var(--ink-2)",fontFamily:"inherit",transition:"all .12s"},children:[e.jsx(En,{contactId:s.id,name:c,email:((w=s.fields)==null?void 0:w.CIy6k)||((M=s.fields)==null?void 0:M.z0xSB),company:(te=s.fields)==null?void 0:te["4Fk6j"],leadUrl:o(n,i.url),storedAvatar:(L=s.fields)==null?void 0:L.Hb2om,size:20}),c]},s.id)}),Ot.length===0&&e.jsx("span",{style:ye,children:"Keine Kontakte hinterlegt."})]})]}),e.jsxs("div",{style:{marginBottom:12,paddingLeft:46},children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:6},children:"Notiz"}),e.jsx("textarea",{value:ot.notiz,onChange:s=>Sn({...ot,notiz:s.target.value}),placeholder:"Was wurde besprochen?",style:{...Ct,minHeight:60,resize:"vertical",boxSizing:"border-box",lineHeight:1.6}})]}),e.jsx("div",{style:{paddingLeft:46},children:e.jsx("button",{onClick:Er,disabled:Ys||!ot.ergebnis,style:{...Pn,padding:"8px 18px",cursor:ot.ergebnis?"pointer":"not-allowed",opacity:ot.ergebnis?1:.45},children:Ys?"Speichert...":"Anruf speichern"})})]}),e.jsxs("div",{className:"cs-listwrap",style:{...Tt,display:"flex",flexDirection:"column"},children:[(()=>{const s=[...u.map(y=>({kind:"note-local",date:y.date||"",data:y})),...hn.filter(y=>y.type==="note").map(y=>({kind:"note-hist",date:y.date||"",data:y})),...An.map(y=>({kind:"call-local",date:y.date||"",data:y})),...hn.filter(y=>y.type==="call").map(y=>({kind:"call-hist",date:y.date||"",data:y}))],c=y=>{var D;return y.kind==="note-local"&&((D=y.data)!=null&&D.gepinnt)?1:0};s.sort((y,D)=>c(D)-c(y)||new Date(D.date||0).getTime()-new Date(y.date||0).getTime());let d=null;return s.map(y=>{let D=null;const w=c(y)?"Angepinnt":"";w&&w!==d?(d=w,D=e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"6px 2px 8px"},children:[e.jsx("span",{style:{...fe,whiteSpace:"nowrap"},children:"Angepinnt"}),e.jsx("span",{style:{flex:1,height:1,background:"var(--line)"}})]})):!w&&d==="Angepinnt"&&(d="rest",D=e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 2px 8px"},children:[e.jsx("span",{style:{...fe,whiteSpace:"nowrap"},children:"Weitere Einträge"}),e.jsx("span",{style:{flex:1,height:1,background:"var(--line)"}})]}));const M=(R,Ce)=>D?e.jsxs("div",{children:[D,R]},Ce):R;if(y.kind==="note-local"){const R=y.data,Ce=Nr(R),Se=O===R.id;return M(e.jsxs("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px",background:R.gepinnt?bn:"transparent",transition:"background .12s"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:8},children:[e.jsx(It,{userKey:R.userKey||"dima",size:34}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{...Qe,background:"var(--gold-text)"}}),e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",whiteSpace:"nowrap"},children:_n(R.author||R.userKey)}),e.jsx("span",{style:{...ye,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:"hat eine Notiz erstellt"}),R.gepinnt&&e.jsx("span",{title:"Angepinnt",style:{display:"inline-flex",color:"var(--gold-text)",flexShrink:0},children:e.jsx(Ni,{on:!0,size:12})}),R.editedAt&&e.jsx("span",{style:{...ye,flexShrink:0},children:"· bearbeitet"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[e.jsx("span",{style:{...ye,...xe},children:St(R.date)}),Ce&&!Se&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>Ar(R.id),title:R.gepinnt?"Nicht mehr anpinnen":"Notiz anpinnen",style:{display:"inline-flex",alignItems:"center",background:"none",border:"none",cursor:"pointer",color:R.gepinnt?"var(--gold-text)":"var(--ink-3)",padding:"2px 4px"},children:e.jsx(Ni,{on:R.gepinnt})}),e.jsx("button",{onClick:()=>{oe(R.id),se(R.text||"")},title:"Notiz bearbeiten",style:{display:"inline-flex",alignItems:"center",background:"none",border:"none",cursor:"pointer",color:"var(--green)",padding:"2px 4px"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:13,height:13},children:[e.jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),e.jsx("button",{onClick:()=>zr(R.id),style:{background:"none",border:"none",cursor:"pointer",fontSize:11,color:"var(--ink-3)",padding:"2px 4px",borderRadius:6,lineHeight:1,opacity:.5,transition:"opacity .15s",fontFamily:"inherit"},onMouseEnter:xt=>xt.currentTarget.style.opacity="1",onMouseLeave:xt=>xt.currentTarget.style.opacity=".5",title:"Löschen",children:"â"})]})]})]}),Se?e.jsxs("div",{children:[e.jsx("textarea",{value:q,onChange:xt=>se(xt.target.value),autoFocus:!0,rows:4,style:{...Ct,boxSizing:"border-box",padding:"12px 14px",background:bn,lineHeight:1.6,resize:"vertical"}}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[e.jsx("button",{onClick:()=>Cr(R.id,q),disabled:!q.trim(),style:{...Pn,padding:"7px 14px",cursor:q.trim()?"pointer":"not-allowed",opacity:q.trim()?1:.45},children:"Speichern"}),e.jsx("button",{onClick:()=>{oe(null),se("")},style:{...as,padding:"7px 14px"},children:"Abbrechen"})]})]}):R.text&&e.jsx(vn,{text:R.text,accent:"",border:"1px solid var(--line)"}),Array.isArray(R.atts)&&R.atts.length>0&&e.jsx(zi,{atts:R.atts,mailFiles:os})]},"nl-"+R.id),"nl-"+R.id)}if(y.kind==="note-hist"){const R=y.data,Ce=R.caid?pa[R.caid]:null;return M(e.jsxs("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:8},children:[(()=>{const Se=js(R.author);return Se?e.jsx(It,{userKey:Se.key,size:34}
126):e.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:bn,border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--gold-text)",strokeWidth:"1.6",style:{width:15,height:15},children:[e.jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]})})})(),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",whiteSpace:"nowrap"},children:_n(R.author)||"Close CRM"}),e.jsx("span",{style:{...ye,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:"hat eine Notiz erstellt"}),Ce&&Ce.length>0&&e.jsxs("span",{style:{...ye,...xe,whiteSpace:"nowrap",flexShrink:0},children:["· ",Ce.length," ",Ce.length===1?"Anhang":"Anhänge"]})]}),e.jsx("span",{style:{...ye,...xe,flexShrink:0},children:St(R.date)})]}),e.jsx(vn,{text:R.body||R.title,accent:"",border:"1px solid var(--line)"}),Ce&&Ce.length>0&&e.jsx(zi,{atts:Ce,mailFiles:os})]},"nh-"+R.id),"nh-"+R.id)}const te=y.kind==="call-local",L=y.data,Y=_n(te?L.autor||L.userKey:L.author)||"Close CRM",ae=te?L.typ:L.direction==="inbound"?"eingehend":"ausgehend",de=te?L.ergebnis:L.disposition||"Anruf",Pe=te?L.dauer:L.duration?Math.round(Number(L.duration)/60):0,st=te?L.notiz:L.body||"";return M(e.jsxs("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px",transition:"background .12s"},onMouseEnter:R=>R.currentTarget.style.background="var(--panel-2)",onMouseLeave:R=>R.currentTarget.style.background="transparent",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:st?8:0},children:[(()=>{const R=js(Y);return R?e.jsx(It,{userKey:R.key,size:34}):e.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:ae==="ausgehend"?"#5B21B6":"#1D4ED8",strokeWidth:"1.8",style:{width:15,height:15},children:e.jsx("path",{d:"M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.5 19.5 0 01-6-6 19.79 19.79 0 01-3.07-8.67A2 2 0 014.11 2h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0122 16.92z"})})})})(),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",whiteSpace:"nowrap"},children:Y}),e.jsxs("span",{style:rn,children:[e.jsx("span",{style:{...Qe,background:ae==="ausgehend"?"#5B21B6":"#1D4ED8"}}),"Anruf ",ae," · ",de]}),Pe>0&&e.jsxs("span",{style:{...ye,...xe},children:[Pe," Min."]})]}),e.jsx("span",{style:{...ye,...xe,flexShrink:0},children:St(L.date)})]}),st&&e.jsx(vn,{text:st,accent:"",border:"1px solid var(--line)"})]},(te?"cl-":"ch-")+L.id),(te?"cl-":"ch-")+L.id)})})(),o(n,i.wichtig)&&e.jsx("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px",background:bn},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:bn,border:"1px solid var(--gold-2)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx("span",{style:{...Qe,background:"var(--gold-text)"}})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:"Wichtige Infos"}),e.jsx("span",{style:{...an,color:"var(--gold-text)"},children:"Gepinnt"})]}),e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",lineHeight:1.6,whiteSpace:"pre-wrap",background:bn,borderRadius:8,padding:"10px 14px",border:"1px solid var(--line)"},children:o(n,i.wichtig)})]})]})}),o(n,i.lastCommSummary)&&e.jsx("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px",opacity:.7},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",ga
126p:12},children:[e.jsx(It,{userKey:"dima",size:34}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:"Letzte Kommunikation"})}),e.jsx("span",{style:{...ye,...xe},children:o(n,i.lastCommDate)&&St(o(n,i.lastCommDate))})]}),e.jsx(vn,{text:o(n,i.lastCommSummary),accent:"",border:"1px solid var(--line)",muted:!0}),e.jsx("div",{style:{...ye,marginTop:6},children:"Importiert aus Close CRM"})]})]})}),o(n,i.closeNotes)&&e.jsx("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px",opacity:.8},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:bn,border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--gold-text)",strokeWidth:"1.6",style:{width:15,height:15},children:[e.jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:"Close CRM Notizen"}),e.jsx("span",{style:an,children:"Import"})]}),e.jsx(vn,{text:o(n,i.closeNotes),accent:"",border:"1px solid var(--line)"})]})]})}),o(n,i.closeCallDesc)&&e.jsx("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px",opacity:.8},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx(It,{userKey:"dima",size:34}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:"Anruf-Notizen"}),e.jsx("span",{style:an,children:"Close CRM"})]}),e.jsx(vn,{text:o(n,i.closeCallDesc),accent:"",border:"1px solid var(--line)"})]})]})}),o(n,i.closeTaskDesc)&&e.jsx("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px",opacity:.8},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.8",style:{width:15,height:15},children:[e.jsx("polyline",{points:"9 11 12 14 22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:"Aufgaben"}),e.jsx("span",{style:an,children:"Close CRM"})]}),e.jsx(vn,{text:o(n,i.closeTaskDesc),accent:"",border:"1px solid var(--line)"})]})]})}),u.length===0&&An.length===0&&hn.filter(s=>s.type==="note"||s.type==="call").length===0&&!o(n,i.wichtig)&&!o(n,i.lastCommSummary)&&!o(n,i.closeNotes)&&!o(n,i.closeCallDesc)&&!o(n,i.closeTaskDesc)&&e.jsx("div",{className:"cs-empty",style:{marginTop:8},children:"Schreibe oben deine erste Notiz oder logge einen Anruf zu diesem Lead."})]})]}),dt==="tasks"&&(()=>{const s=hn.filter(w=>w.type==="task").map(w=>({id:w.id,date:w.date||"",author:w.author||"",body:w.body||w.title||"Aufgabe",done:w.disposition==="erledigt",urgent:!1,source:"close"})),c=new Set(s.map(w=>w.id)),d=lr.filter(w=>!c.has(w.id)).map(w=>({id:w.id,date:w.date||"",author:w.assignee||"",body:(w.text||"Aufgabe")+(w.subline?` 127`+w.subline:""),done:!!w.done,urgent:!!w.urgent,source:"todo"})),y=new Set(d.map(w=>(w.body||"").split(` 128`)[0].substring(0,120).trim())),D=[...d,...s.filter(w=>!y.has((w.body||"").substring(0,120).trim()))].sort((w,M)=>(M.date||"").localeCompare(w.date||""));return D.length===0?e.jsx("div",{className:"cs-timeline",children:e.jsxs("div",{className:"cs-tab-placeholder",children:[e.jsx("div",{className:"cs-tab-placeholder-icon",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:32,height:32,color:"var(--ink-3)"},children:[e.jsx("polyline",{points:"9 11 12 14 22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]})}),e.jsx("div",{className:"cs-tab-placeholder-title",children:"Keine Aufgaben"}),e.jsx("div",{className:"cs-tab-placeholder-desc",children:"Für diesen Lead wurden noch keine Aufgaben angelegt oder aus Close importiert."})]})}):e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Lead"}),e.jsx("h3",{style:{fontSize:22,fontWeight:800,color:"var(--ink)",letterSpacing:"-.024em",marginTop:4},children:"Aufgaben"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsxs("span",{style:{...ye,...xe},children:[D.length," ",D.length===1?"Aufgabe":"Aufgaben"]}),e.jsx("button",{className:"cs-btn-outline",style:{fontSize:12.5,display:"flex",alignItems:"center",gap:6},onClick:()=>{dr(!1),Xe(!0),lt((a==null?void 0:a.key)||""),ne(!0)},children:"Aufgabe anlegen"})]})]}),e.jsx("div",{className:"cs-listwrap",style:{...Tt,display:"flex",flexDirection:"column"},children:D.map(w=>{const M=w.done,te=js(w.author);return e.jsxs("div",{style:{borderBottom:"1px solid var(--line)",padding:"13px 15px",opacity:M?.72:1,transition:"background .12s"},onMouseEnter:L=>L.currentTarget.style.background="var(--panel-2)",onMouseLeave:L=>L.currentTarget.style.background="transparent",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:8},children:[te?e.jsx(It,{userKey:te.key,size:34}
128):e.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:M?"var(--green-soft)":"var(--panel-2)",border:"1px solid "+(M?"var(--green-bd)":"var(--line)"),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:M?"var(--green)":"var(--ink-3)",strokeWidth:"1.8",style:{width:15,height:15},children:[e.jsx("polyline",{points:"9 11 12 14 22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",whiteSpace:"nowrap"},children:w.author||(w.source==="close"?"Close CRM":"Aufgabe")}),e.jsx("span",{style:ye,children:w.source==="close"?"hat eine Aufgabe erstellt":w.author?"ist zugewiesen":"im CRM angelegt"}),e.jsxs("span",{style:{...rn,flexShrink:0},children:[e.jsx("span",{style:{...Qe,background:M?"var(--green)":"var(--ink-3)"}}),M?"erledigt":"offen"]}),w.urgent&&!M&&e.jsxs("span",{style:{...rn,color:"var(--red)",flexShrink:0},children:[e.jsx("span",{style:{...Qe,background:"var(--red)"}}),"dringend"]})]}),e.jsx("span",{style:{...ye,...xe,flexShrink:0},children:St(w.date)})]}),e.jsx(vn,{text:w.body,accent:"",bg:"var(--panel-2)",border:"1px solid var(--line)"})]},(w.source==="todo"?"td-":"cl-")+w.id)})})]})})(),dt==="meetings"&&(()=>{const s=hn.filter(d=>d.type==="meeting").slice().sort((d,y)=>(y.date||"").localeCompare(d.date||"")),c=d=>{var D,w,M,te;const y=((d.title||"")+` 129 `+(d.body||"")).toLowerCase();if(!y.trim())return null;for(const L of Ot){const Y=String(((D=L.fields)==null?void 0:D.CIy6k)||((w=L.fields)==null?void 0:w.z0xSB)||"").trim().toLowerCase();if(Y&&Y.length>5&&y.includes(Y))return L}for(const L of Ot){const Y=String(((M=L.fields)==null?void 0:M["707oq"])||((te=L.fields)==null?void 0:te["5OGPi"])||"").trim().toLowerCase();if(Y&&Y.length>=5&&Y.includes(" ")&&y.includes(Y))return L}return null};return s.length===0?e.jsx("div",{className:"cs-timeline",children:e.jsxs("div",{className:"cs-tab-placeholder",children:[e.jsx("div",{className:"cs-tab-placeholder-icon",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{width:32,height:32,color:"var(--ink-3)"},children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),e.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})}),e.jsx("div",{className:"cs-tab-placeholder-title",children:"Keine Meetings"}),e.jsx("div",{className:"cs-tab-placeholder-desc",children:"Für diesen Lead wurden keine Meetings aus Close importiert."})]})}):e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Lead"}),e.jsx("h3",{style:{fontSize:22,fontWeight:800,color:"var(--ink)",letterSpacing:"-.024em",margin:"4px 0 4px"},children:"Meetings"}),e.jsxs("div",{style:{...ye,...xe,marginBottom:14},children:[s.length," Meetings · aus Close importiert"]})]}),e.jsx("div",{className:"cs-listwrap",style:Tt,children:s.map((d,y)=>{var xt,bt,Je,at,Ke;const D=d.duration?Math.round(Number(d.duration)/60):0,w=d.date?new Date(d.date):null,M=w?w.toLocaleDateString("de",{day:"2-digit",month:"short",year:"2-digit"}):"",te=w?w.toLocaleTimeString("de",{hour:"2-digit",minute:"2-digit"}):"",L=260,Y=d.body||"",ae=Y.length>L,de=Qt.has(d.id),Pe=ae&&!de?Y.slice(0,L).replace(/\s+\S*$/,"")+"â¦":Y,st=()=>Gt(Ze=>{const T=new Set(Ze);return T.has(d.id)?T.delete(d.id):T.add(d.id),T}),R=c(d),Ce=R&&(((xt=R.fields)==null?void 0:xt["707oq"])||((bt=R.fields)==null?void 0:bt["5OGPi"]))||"",Se=R&&(((Je=R.fields)==null?void 0:Je.CIy6k)||((at=R.fields)==null?void 0:at.z0xSB))||"";return e.jsxs("div",{style:{display:"flex",gap:10,padding:"13px 15px",borderTop:y===0?"none":"1px solid var(--line)",alignItems:"flex-start"},children:[e.jsxs("span",{style:{position:"relative",flexShrink:0,display:"inline-flex"},children:[R?e.jsx(En,{contactId:R.id,name:Ce,email:Se,company:qt,leadUrl:o(n,i.url),storedAvatar:(Ke=R.fields)==null?void 0:Ke.Hb2om,size:30}):e.jsx("span",{style:{width:30,height:30,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"#1D4ED8",strokeWidth:"1.8",style:{width:15,height:15},children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),e.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})}),e.jsx("span",{style:{position:"absolute",right:-3,bottom:-3,width:15,height:15,borderRadius:"50%",background:"#1D4ED8",border:"2px s
129olid var(--panel)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"2.4",style:{width:8,height:8},children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),e.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",fontVariantNumeric:"tabular-nums"},children:[d.title||"Meeting",D?` · ${D} Min.`:"",d.disposition&&e.jsxs("span",{style:{fontWeight:600,color:"var(--ink-3)"},children:[" â ",d.disposition]})]}),e.jsxs("span",{style:{...ye,...xe,flexShrink:0,marginLeft:8},children:[M," ",te]})]}),Ce&&e.jsxs("div",{style:{...ye,marginTop:3},children:["mit ",Ce]}),Y&&e.jsxs("div",{style:{marginTop:7,padding:"10px 14px",background:"var(--panel-2)",border:"1px solid var(--line)",borderRadius:8},children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",whiteSpace:"pre-wrap",lineHeight:1.55,wordBreak:"break-word"},children:Pe}),ae&&e.jsx("button",{onClick:st,style:{marginTop:8,border:"none",background:"none",padding:0,cursor:"pointer",fontSize:11.5,fontWeight:700,color:"var(--green)",fontFamily:"inherit"},children:de?"â´ Weniger anzeigen":"â¾ Mehr anzeigen"})]}),d.author&&(()=>{const Ze=js(d.author);return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:6},children:[Ze?e.jsx(It,{userKey:Ze.key,size:18}):e.jsx(Ii,{name:d.author,size:18,fontSize:8}),e.jsx("span",{style:ye,children:d.author})]})})()]})]},d.id)})})]})})(),dt==="upsells"&&(()=>{const s=[{key:"svcWebdesign",label:"Produktvorstellung",icon:"ð¤"},{key:"svcSEO",label:"Eventbegleitung",icon:"ð¥"},{key:"svcAds",label:"Social Media Content",icon:"ð±"},{key:"svcSocial",label:"Social Media Pflege",icon:"ð²"},{key:"svcVideo",label:"Imagefilm",icon:"ð¬"},{key:"svcFoto",label:"Drohnenaufnahmen",icon:"ð"},{key:"svcBranding",label:"Teamfotos",icon:"ð¸"},{key:"svcContent",label:"Fahrzeugfotografie",icon:"ð"},{key:"svcConsulting",label:"LIBERDA Studio",icon:"ð·"},{key:"svcHosting",label:"Recruiting",icon:"ð¥"},{key:"svcMaintenance",label:"Meta Ads",icon:"ð"},{key:"svcEmail",label:"Strategie",icon:"ð¡"},{key:"svcPrint",label:"Messe-Produktion",icon:"ðï¸"},{key:"svcEvents",label:"Jubiläumsaktion",icon:"ð"},{key:"svcInfluencer",label:"Saisonale Aktionen",icon:"ð
"},{key:"svcPR",label:"Gewinnspiele",icon:"ð"},{key:"svcSonstiges",label:"Werbegrafiken",icon:"ð¨"}],c=s.filter(y=>{const D=qa(n,i[y.key]);return D===!0||D==="true"||D===1||D==="1"}),d=s.filter(y=>!c.includes(y));return e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Lead"}),e.jsx("h3",{style:{fontSize:22,fontWeight:800,color:"var(--ink)",letterSpacing:"-.024em",marginTop:4},children:"Services & Upsell"}),e.jsxs("p",{style:{...ye,...xe,marginTop:5},children:[c.length," aktiv · ",d.length," offen"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("div",{style:{textAlign:"right"},children:[e.jsx("div",{style:fe,children:"Fortschritt"}),e.jsxs("div",{style:{...xe,fontSize:22,fontWeight:800,letterSpacing:"-.032em",marginTop:4,color:c.length>5?"var(--green)":c.length>2?"#92610A":"var(--ink-3)"},children:[Math.round(c.length/s.length*100),"%"]})]}),e.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{viewBox:"0 0 36 36",style:{width:32,height:32,transform:"rotate(-90deg)"},children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"var(--line)",strokeWidth:"3"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:c.length>5?"var(--green)":c.length>
1292?"#92610A":"var(--ink-3)",strokeWidth:"3",strokeDasharray:`${c.length/s.length*88} 88`,strokeLinecap:"round"})]})})]})]}),c.length>0&&e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{...fe,marginBottom:10},children:"Aktive Services"}),e.jsx("div",{style:{...Tt,display:"grid",gridTemplateColumns:"1fr 1fr"},children:c.map((y,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 15px",borderBottom:D<c.length-(c.length%2===0?2:1)?"1px solid var(--line)":"none",borderRight:D%2===0?"1px solid var(--line)":"none"},children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:y.label}),e.jsx("div",{style:{...ye,color:"var(--green)",marginTop:2},children:"Beansprucht"})]})]},y.key))})]}),d.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{...fe,marginBottom:10},children:"Upsell-Potenzial"}),e.jsx("div",{style:{...Tt,display:"grid",gridTemplateColumns:"1fr 1fr"},children:d.map((y,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 15px",borderBottom:D<d.length-(d.length%2===0?2:1)?"1px solid var(--line)":"none",borderRight:D%2===0?"1px solid var(--line)":"none",cursor:"pointer",transition:"background .12s"},onClick:async()=>{try{await et(tt,t,{[i[y.key]]:!0}),await new Promise(w=>setTimeout(w,500)),vt.clear(),await Kt()}catch(w){alert("Fehler: "+w.message)}},onMouseEnter:w=>{w.currentTarget.style.background="var(--panel-2)"},onMouseLeave:w=>{w.currentTarget.style.background="transparent"},children:[e.jsx("span",{style:{...Qe,background:"var(--line-2)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink-2)"},children:y.label}),e.jsx("div",{style:{...ye,marginTop:2},children:"Klicken zum Aktivieren"})]})]},y.key))})]}),c.length===0&&e.jsx("div",{className:"cs-empty",style:{padding:20},children:"Noch keine Services bei diesem Kunden aktiv."})]})})(),dt==="score"&&e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Lead"}),e.jsx("h3",{style:{fontSize:22,fontWeight:800,color:"var(--ink)",letterSpacing:"-.024em",marginTop:4},children:"Lead-Score"}),e.jsx("p",{style:{...ye,marginTop:5},children:"KI-basierte Kaufwahrscheinlichkeit"})]}),e.jsx("button",{className:"cs-btn-outline",style:{fontSize:12.5,display:"flex",alignItems:"center",gap:6},disabled:pn,onClick:async()=>{var s,c,d;V(!0);try{const y=o(n,i.contactName)||o(n,i.contactFirst),D=o(n,i.contactEmail),w=o(n,i.statusLabel),M=o(n,i.kategorie),te=o(n,i.numEmails)||"0",L=o(n,i.numCalls)||"0",Y=o(n,i.numOpps)||"0",ae=o(n,i.notiz)||"",de=o(n,i.wichtig)||"",Pe=o(n,i.lastCommSummary)||"",st=o(n,i.lastCommDate)||"",R=o(n,i.social)||"",Ce=o(n,i.url)||"",Se=o(n,i.aFollower)||"",xt=o(n,i.aEngagement)||"",bt=o(n,i.tier)||"",Je=u.map(E=>`[${E.date}] ${E.text}`).join(` 130`),at=An.map(E=>`[${E.date}] ${E.typ} - ${E.ergebnis} (${E.dauer}min) ${E.notiz}`).join(` 131`),Ke=`Du bist ein Sales-Scoring-Experte für LIBERDA Media (Social Media Content Agentur). Analysiere diesen Lead und gib einen Score von 0-100 (Kaufwahrscheinlichkeit). 132 133LEAD-DATEN: 134- Name: ${o(n,i.displayName)||o(n,i.leadName)} 135- Kontaktperson: ${y} 136- Status: ${w} 137- Kategorie/Branche: ${M} 138- Tier: ${bt} 139- Website: ${Ce} 140- Social Media: ${R} 141- Instagram Follower: ${Se} 142- Engagement Rate: ${xt}% 143- Emails gesamt: ${te} 144- Anrufe gesamt: ${L} 145- Opportunities: ${Y} 146- Letzte Kommunikation: ${Pe} (${st}) 147- Notizen: ${ae} 148- Wichtig: ${de} 149- Neueste Notizen: ${Je} 150- Anruf-Protokoll: ${at} 151 152Antworte NUR als valides JSON (kein Markdown, keine Erklärung): 153{ 154 "score": <0-100>, 155 "label": "<Eiskalt|Kalt|Warm|HeiÃ|Sehr HeiÃ>", 156 "reasoning": "<2-3 Sätze warum dieser Score>", 157 "signals": [ 158 {"signal": "<Signalname>", "weight": "<positiv|negativ|neutral>", "detail": "<kurze Erklärung>"} 159 ], 160 "empfehlung": "<Konkreter nächster Schritt, 1-2 Sätze>" 161} 162 163Berücksichtige: Kommunikationsfrequenz, Engagement, Branche, bestehende Opportunities, Aktivitätslevel, Notizen-Inhalt. Min. 4 Signals.`,Ze=await Ge("/api/ai",{method:"POST",body:JSON.stringify({prompt:Ke,model:"gpt-4o-mini"})}),me=(Ze.result||((d=(c=(s=Ze.choices)==null?void 0:s[0])==null?void 0:c.message)==null?void 0:d.content)||"").match(/\{[\s\S]*\}/);if(me){const E=JSON.parse(me[0]);E.generatedAt=new Date().toISOString(),dn(E),localStorage.setItem(`lm_score_${t}`,JSON.stringify(E))}}catch(y){console.error("Score error:",y)}finally{V(!1)}},children:pn?"Analysiertâ¦":"Score berechnen"})]}),ft?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:24,marginBottom:20},children:[e.jsxs("div",{style:{position:"relative",width:90,height:90},children:[e.jsxs("svg",{viewBox:"0 0 100 100",style:{width:90,height:90,transform:"rotate(-90deg)"},children:[e.jsx("circle",{cx:"50",cy:"50",r:"42",fill:"none",stroke:"var(--line)",strokeWidth:"8"}),e.jsx("circle",{cx:"50",cy:"50",r:"42",fill:"none",stroke:ft.score>=80?"var(--green)":ft.score>
163=60?"#92610A":ft.score>=40?"#7A5B00":"var(--red)",strokeWidth:"8",strokeLinecap:"round",strokeDasharray:`${ft.score*2.64} 264`,style:{transition:"stroke-dasharray 1s ease"}})]}),e.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[e.jsx("span",{style:{...xe,fontSize:22,fontWeight:800,color:"var(--ink)",lineHeight:1,letterSpacing:"-.032em"},children:ft.score}),e.jsx("span",{style:{...fe,marginTop:3},children:"/ 100"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:15,fontWeight:800,letterSpacing:"-.016em",color:ft.score>=80?"var(--green)":ft.score>=60?"#92610A":ft.score>=40?"#7A5B00":"var(--red)"},children:ft.label}),e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",lineHeight:1.55,marginTop:6,maxWidth:280},children:ft.reasoning})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{...fe,marginBottom:8},children:"Signale"}),e.jsx("div",{className:"cs-listwrap",style:{...Tt,display:"flex",flexDirection:"column"},children:ft.signals.map((s,c,d)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"11px 15px",borderBottom:c<d.length-1?"1px solid var(--line)":"none"},children:[e.jsx("span",{style:{...Qe,marginTop:6,background:s.weight==="positiv"?"var(--green)":s.weight==="negativ"?"var(--red)":"#92610A"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:s.signal}),e.jsx("div",{style:{...ye,marginTop:2},children:s.detail})]})]},c))})]}),e.jsxs("div",{style:{background:"var(--green-soft)",border:"1px solid var(--green-bd)",borderRadius:13,padding:"14px 16px"},children:[e.jsx("div",{style:{...fe,color:"var(--green)",marginBottom:6},children:"Empfohlener nächster Schritt"}),e.jsx("div",{style:{fontSize:13,color:"var(--ink)",lineHeight:1.55},children:ft.empfehlung})]}),e.jsxs("div",{style:{...ye,...xe,marginTop:12,textAlign:"right"},children:["Generiert: ",ft.generatedAt?St(ft.generatedAt):"â"]})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px 20px"},children:[e.jsx("div",{style:{fontSize:15,fontWeight:800,color:"var(--ink)",letterSpacing:"-.016em",marginBottom:8},children:"Lead noch nicht bewertet"}),e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-3)",maxWidth:340,margin:"0 auto",lineHeight:1.6},children:'Klicke oben auf "Score berechnen" â die KI analysiert alle verfügbaren Daten (Emails, Anrufe, Notizen, Social Media) und berechnet eine Kaufwahrscheinlichkeit.'})]})]}),dt==="ki"&&(()=>{var Re;const s=(o(n,i.aHandle)||((Re=o(n,i.social))==null?void 0:Re.replace(/.*instagram\.com\//,"").replace(/\/.*$/,""))||"").replace(/^@+/,""),c=Number(o(n,i.aFollower))>0,d=Number(o(n,i.aFollower))||0,y=Number(o(n,i.aBeitraege))||0,D=Number(o(n,i.aPostsProWoche))||0,w=Number(o(n,i.aEngagement))||0,M=Number(o(n,i.aReelsAnteil))||0,te=Number(o(n,i.aFotosAnteil))||0,L=Number(o(n,i.aKarussellsAnteil))||0,Y=Number(o(n,i.aDurchschnittViews))||0,ae=Number(o(n,i.aTopViews))||0,de=o(n,i.aBranche)||o(n,i.kategorie)||"",Pe=o(n,i.aEmpfohlenPaket)||"",st=o(n,i.aPaketGrund)||"";o(n,i.aDatum);let R=[];try{R=JSON.parse(o(n,i.aStaerken)||"[]")}catch{}let Ce=[];try{Ce=JSON.parse(o(n,i.aSchwaechen)||"[]")}catch{}let Se=[];try{Se=JSON.parse(o(n,i.aServices)||"[]")}catch{}const xt=Number(o(n,i.aBvPostsKunde))||D,bt=Number(o(n,i.aBvPostsSchnitt))||4,Je=Number(o(n,i.aBvReelsKunde))||M,at=Number(o(n,i.aBvReelsSchnitt))||40,Ke=Number(o(n,i.aBvFollowerKunde))||d,Ze=Number(o(n,i.aBvFollowerSchnitt))||4e3,T=Number(o(n,i.aBvEngagementKunde))||w,me=Number(o(n,i.aBvEngagementSchnitt))||2,E=async()=>{S(!0),Ne(null);const z={firma:qt,branche:de,instagram:s,follower:d,beitraege:y,postsWoche:D,engagement:w,reelsAnteil:M,fotosAnteil:te,karussells:L,avgViews:Y,topViews:ae,staerken:R,schwaechen:Ce,empfPaket:Pe,services:Se,branchenvergleich:{postsProWoche:{kunde:xt,schnitt:bt},reelsAnteil:{kunde:Je,schnitt:at},follower:{kunde:Ke,schnitt:Ze},engagement:{kunde:T,schnitt:me}},crm:{status:gi,kontakt:Fs,email:Vn,notiz:xa,wichtig:fa,anzahlEmails:o(n,i.numEmails),projekte:Fn.length}};try{const W=await Ge("/api/ai-analyze",{method:"POST",body:JSON.stringify({leadData:z,type:"instagram"})}),G=W.analysis||W.error||"Keine Analyse erhalten.";Bl(G,(a==null?void 0:a.name)||"CRM")}catch(W){Ne("Fehler: "+W.message)}finally{S(!1)}},Ye=async()=>{const z=Be,W={};z.handle&&(W[i.aHandle]=z.handle),z.follower&&(W[i.aFollower]=Number(z.follower)),z.beitraege&&(W[i.aBeitraege]=Number(z.beitraege)),z.postsWoche&&(W[i.aPostsProWoche]=Number(z.postsWoche)),z.engagement&&(W[i.aEngagement]=Number(z.engagement)),z.reelsAnteil&&(W[i.aReelsAnteil]=Number(z.reelsAnteil)),z.fotosAnteil&&(W[i.aFotosAnteil]=Number(z.fotosAnteil)),z.karussells&&(W[i.aKarussellsAnteil]=Number(z.karussells)),z.avgViews&&(W[i.aDurchschnittViews]=Number(z.avgVie
163ws)),z.topViews&&(W[i.aTopViews]=Number(z.topViews)),z.branche&&(W[i.aBranche]=z.branche),W[i.aDatum]=new Date().toISOString().split("T")[0],W[i.aAktiv]=!0,await et(tt,t,W),await new Promise(G=>setTimeout(G,500)),vt.clear(),await Kt(),we(!1)};return e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(()=>{const z=o(n,i.aHeroImage),W=typeof z=="string"?z:(z==null?void 0:z.url)||"";return W?e.jsx("img",{src:W,alt:s,style:{width:44,height:44,borderRadius:10,objectFit:"cover",border:"1px solid var(--line)",flexShrink:0},onError:G=>{G.target.style.display="none"}}):s?e.jsx("div",{style:{width:44,height:44,borderRadius:10,background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"var(--ink-3)",style:{width:22,height:22},children:e.jsx("path",{d:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"})})}):null})(),e.jsxs("div",{children:[e.jsx("div",{style:fe,children:"Lead"}),e.jsx("h3",{style:{fontSize:22,fontWeight:800,color:"var(--ink)",letterSpacing:"-.024em",marginTop:4},children:"Insights"}),e.jsxs("p",{style:{...ye,marginTop:5,display:"flex",alignItems:"center",gap:5},children:[s&&e.jsx("svg",{viewBox:"0 0 24 24",fill:"var(--ink-3)",style:{width:12,height:12,flexShrink:0},children:e.jsx("path",{d:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"})}),e.jsx("span",{children:s?`@${s}`:"Instagram-Analyse"})]})]})]}),e.jsx("div",{style:{display:"flex",gap:6},children:c&&e.jsx("button",{className:"cs-btn-primary",style:{padding:"8px 14px",fontSize:12.5},onClick:E,disabled:en,children:en?"Analysiert...":"Insights generieren"})})]}),X&&e.jsxs("div",{style:{padding:16,background:"var(--panel)",borderRadius:13,border:"1px solid var(--line)",marginBottom:20},children:[e.jsx("div",{style:{...fe,marginBottom:12},children:"Instagram-Daten eingeben"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[{key:"handle",label:"Instagram Handle",ph:"autohaus_xyz"},{key:"branche",label:"Branche",ph:"Autohäuser"},{key:"follower",label:"Follower",ph:"3200"},{key:"beitraege",label:"Beiträge",ph:"450"},{key:"postsWoche",label:"Posts/Woche",ph:"3.5"},{key:"engagement",label:"Engagement-Rate %",ph:"2.1"},{key:"reelsAnteil",label:"Reels-Anteil %",ph:"35"},{key:"fotosAnteil",label:"Fotos-Anteil %",ph:"50"},{key:"karussells",label:"Karussells %",ph:"15"},{key:"avgViews",label:"à Reel-Views",ph:"1200"},{key:"topViews",label:"Top Reel-Views",ph:"15000"}].map(z=>e.jsxs("div",{children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:z.label}),e.jsx("input",{className:"cs-input",style:{padding:"8px 11px",fontSize:12.5},placeholder:z.ph,value:Be[z.key]||"",onChange:W=>pe(G=>({...G,[z.key]:W.target.value}))})]},z.key))}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:12,justifyContent:"flex-end"},children:[e.jsx("button",{className:"cs-btn-outline",style:{fontSize:12.5},onClick:()=>we(!1),children:"Abbrechen"}),e.jsx("button",{className:"cs-btn-primary",style:{fontSize:12.5},onClick:Ye,children:"Speichern & Analyse starten"})]})]}),!c&&!X&&e.jsxs("div",{style:{padding:32,textAlign:"center",border:"1px dashed var(--line-2)",borderRadius:13},children:[e.jsx("div",{style:{fontSize:15,fontWeight:800,color:"var(--ink)",letterSpacing:"-.016em",marginBottom:6},children:"Keine Analyse-Daten vorhanden"}),e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-3)",maxWidth:380,margin:"8px auto 16px",lineHeight:1.6},children:s?`Instagram-Profil @${s}
163 automatisch analysieren.`:"Instagram-Handle eingeben um loszulegen."}),s?e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10},children:e.jsx("button",{className:"cs-btn-primary",disabled:en,onClick:async()=>{var z,W;S(!0);try{vt.delete(`/api/social-analyze?handle=${encodeURIComponent(s)}`);const G=await Ge(`/api/social-analyze?handle=${encodeURIComponent(s)}`);if(G.success){const ze={[i.aHandle]:`@${s}`,[i.aFollower]:G.follower,[i.aBeitraege]:G.beitraege,[i.aPostsProWoche]:G.postsProWoche,[i.aEngagement]:G.engagementRate,[i.aReelsAnteil]:G.reelsAnteil,[i.aFotosAnteil]:G.fotosAnteil,[i.aKarussellsAnteil]:G.karussellsAnteil,[i.aDurchschnittViews]:G.avgViews,[i.aTopViews]:G.topViews,[i.aDatum]:new Date().toISOString().split("T")[0],[i.aAktiv]:!0};(z=G.reelViews)!=null&&z.length&&(ze[i.aReelViews]=JSON.stringify(G.reelViews)),G.profilePic&&(ze[i.aHeroImage]=G.profilePic),(W=G.recentPosts)!=null&&W.length&&Oe(G.recentPosts),await et(tt,t,ze),await new Promise($e=>setTimeout($e,500)),vt.clear(),await Kt()}else alert(G.error||"Instagram konnte nicht geladen werden.")}catch(G){alert("Fehler: "+G.message)}finally{S(!1)}},children:en?"Lade Instagram-Daten...":`@${s} analysieren`})}):e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10},children:o(n,i.url)?e.jsx("button",{className:"cs-btn-primary",disabled:en,onClick:async()=>{S(!0);try{const z=await Ge(`/api/find-social?url=${encodeURIComponent(o(n,i.url))}`);if(z.success&&z.instagram){const W=z.instagramUrl||`https://www.instagram.com/${z.instagram}/`;await et(tt,t,{[i.social]:W,[i.aHandle]:`@${z.instagram}`}),vt.clear(),await Kt()}else alert("Kein Instagram-Profil auf der Website gefunden.")}catch(z){alert("Fehler: "+z.message)}finally{S(!1)}},children:en?"Durchsuche Website...":"Instagram von Website finden"}):e.jsx("div",{style:ye,children:"Website-URL hinterlegen um Instagram automatisch zu finden."})})]}),c&&!X&&(()=>{let z=[];try{z=JSON.parse(o(n,i.aReelViews)||"[]")}catch{}const W=(G,ze,$e)=>{const Q=G>=ze?"var(--green)":G>=$e?"#92610A":"var(--red)";return e.jsx("span",{style:{...Qe,background:Q,marginLeft:6}})};return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{...Tt,display:"grid",gridTemplateColumns:"repeat(2,1fr)",marginBottom:16},children:[{val:d.toLocaleString("de-DE"),label:"Follower",dot:W(d,5e3,3e3)},{val:String(y),label:"Beiträge",dot:W(y,200,100)},{val:M+"%",label:"Reels-Anteil",dot:W(M,50,30)},{val:"~"+D.toFixed(1),label:"Posts / Woche",dot:W(D,5,3)},{val:w.toFixed(1)+"%",label:"Engagement",dot:W(w,2,1.5)},{val:Y.toLocaleString("de-DE"),label:"à Reel-Views",dot:W(Y,3e3,1e3)}].map((G,ze,$e)=>e.jsxs("div",{style:{padding:"15px 16px",borderRight:ze%2===0?"1px solid var(--line)":"none",borderBottom:ze<$e.length-2?"1px solid var(--line)":"none"},children:[e.jsx("div",{style:{...xe,fontSize:22,fontWeight:800,color:"var(--ink)",letterSpacing:"-.032em",lineHeight:1},children:G.val}),e.jsxs("div",{style:{...fe,marginTop:6,display:"flex",alignItems:"center"},children:[G.label,G.dot]})]},ze))}),z.length>0&&(()=>{const G=Math.max(...z);return e.jsxs("div",{style:{...Nn,marginBottom:16},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[e.jsx("div",{style:fe,children:"Reel-Performance"}),e.jsxs("div",{style:{...ye,...xe},children:["à ",Y.toLocaleString("de-DE")," Views · Top: ",ae.toLocaleString("de-DE")]})]}),e.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:2,height:80},children:z.map((ze,$e)=>{const Q=ze/G*100,We=ze===G;return e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",height:"100%",justifyContent:"flex-end"},children:[We&&e.jsx("span",{style:{...xe,fontSize:9,color:"var(--green)",fontWeight:700,marginBottom:3},children:ze.toLocaleString("de-DE")}),e.jsx("div",{style:{width:"100%",height:`${Q}%`,minHeight:3,borderRadius:"3px 3px 0 0",background:We?"var(--green)":"var(--green-bd)",transition:"height .8s cubic-bezier(.22,1,.36,1)"},title:ze.toLocaleString("de-DE")+" Views"})]},$e)})}),e.jsx("div",{style:{...ye,textAlign:"center",marginTop:8},children:"Neueste â Ãlteste Reels"})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginBottom:16},children:[e.jsxs("div",{style:Nn,children:[e.jsx("div",{style:{...fe,marginBottom:12},children:"Content-Mix"}),(()=>{const G=[{label:"Reels",val:M,color:"#5B21B6"},{label:"Fotos",val:te,color:"#1D4ED8"},{label:"Karussells",val:L,color:"#92610A"}].filter(Wt=>Wt.val>0),ze=40,$e=50,Q=50,We=12;let Pt=0;const kt=G.map(Wt=>{const yn=Pt;Pt+=Wt.val;const xs=yn/100*360-90,ys=Pt/100*360-90,mi=Wt.val>50?1:0,bs=yi=>yi*Math.PI/180,vs=$e+ze*Math.cos(bs(xs)),fi=Q+ze*Math.sin(bs(xs)),Ln=$e+ze*Math.cos(bs(ys)),xi=Q+ze*Math.sin(bs(ys));return{...Wt,d:`M ${vs} ${fi} A ${ze} ${ze} 0 ${mi} 1 ${Ln} ${xi}`}});return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[e.jsxs("svg",{viewBox:"0 0 100 100",style:{width:100,height:100},children:[e.jsx("circle",{cx:$e,cy:Q,r:ze,fill:"none",stroke:"var(--line)",strokeWidth:We}),kt.map((Wt,yn)=>e.jsx("path",{d:Wt.d,fill:"none",stroke:Wt.color,strokeWidth:We,strokeLinecap:"round"},yn))]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,width:"100%"},children:G.map((Wt,yn)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{...Qe,background:Wt.color}}),e.jsx("span",{style:{color:"var(--ink-2)",fontWeight:600},children:Wt.label})]}),e.jsxs("span",{style:{...xe,fontWeight:700,color:"var(--ink)"},children:[Wt.val,"%"]})]},yn))})]})})()]}),e.jsxs("div",{style:Nn,children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:14},children:e.jsx("div",{style:fe,children:"Branchenvergleich"})}),de&&e.jsx("span",{style:{...an,display:"inline-block",marginBottom:10},children:de}),[{label:"Posts/Wo.",k:xt,s:bt,unit:"",dec:1},{label:"Reels",k:Je,s:at,unit:"%",dec:0},{label:"Follower",k:Ke,s:Ze,unit:"",dec:0},{label:"Engage.",k:T,s:me,unit:"%",dec:1}].map((G,ze)=>{const $e=Math.max(G.k,G.s)*1.2||1,Q=G.k>=G.s;return e.jsxs("div",{style:{marginBottom:10},children:[e.jsx("div",{style:{...fe,marginBottom:6},children:G.label}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2},children:[e.jsxs("span",{style:{...xe,fontSize:10,fontWeight:700,color:Q?"var(--green)":"var(--red)",minWidth:52},children:["Du: ",G.k.toFixed(G.dec),G.unit]}),e.jsx("div",{style:{flex:1,height:4,borderRadius:6,background:"var(--panel-2)",border:"1px solid var(--line)",overflow:"hidden"},children:e.jsx("div",{style:{width:`${G.k/$e*100}%`,height:"100%",background:Q?"var(--green)":"var(--red)",transition:"width 1s cubic-bezier(.22,1,.36,1)"}})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6}
163,children:[e.jsxs("span",{style:{...xe,fontSize:10,color:"var(--ink-3)",fontWeight:600,minWidth:52},children:["à ",G.s.toFixed(G.dec),G.unit]}),e.jsx("div",{style:{flex:1,height:4,borderRadius:6,background:"var(--panel-2)",border:"1px solid var(--line)",overflow:"hidden"},children:e.jsx("div",{style:{width:`${G.s/$e*100}%`,height:"100%",background:"var(--line-2)",transition:"width 1s cubic-bezier(.22,1,.36,1)"}})})]})]},ze)})]})]}),(R.length>0||Ce.length>0)&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginBottom:16},children:[R.length>0&&e.jsxs("div",{style:Nn,children:[e.jsx("div",{style:{...fe,color:"var(--green)",marginBottom:10},children:"Stärken"}),R.map((G,ze,$e)=>e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start",fontSize:12,color:"var(--ink-2)",padding:"7px 0",borderBottom:ze<$e.length-1?"1px solid var(--line)":"none",lineHeight:1.5},children:[e.jsx("span",{style:{...Qe,background:"var(--green)",marginTop:6}}),e.jsx("span",{children:G})]},ze))]}),Ce.length>0&&e.jsxs("div",{style:Nn,children:[e.jsx("div",{style:{...fe,color:"var(--red)",marginBottom:10},children:"Schwächen"}),Ce.map((G,ze,$e)=>e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start",fontSize:12,color:"var(--ink-2)",padding:"7px 0",borderBottom:ze<$e.length-1?"1px solid var(--line)":"none",lineHeight:1.5},children:[e.jsx("span",{style:{...Qe,background:"var(--red)",marginTop:6}}),e.jsx("span",{children:G})]},ze))]})]}),Pe&&e.jsxs("div",{style:{padding:18,background:bn,borderRadius:16,border:"1px solid var(--gold-2)",marginBottom:16},children:[e.jsx("div",{style:{...fe,color:"var(--gold-text)",marginBottom:8},children:"Empfohlen"}),e.jsx("div",{style:{fontSize:15,fontWeight:800,color:"var(--ink)",letterSpacing:"-.016em",marginBottom:6},children:Pe}),st&&e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",lineHeight:1.65},children:st})]}),Se.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{...fe,marginBottom:10},children:"Service-Empfehlungen"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Se.map((G,ze)=>{const $e=G.prioritaet==="hoch"?"var(--green)":"var(--orange)";return e.jsxs("div",{style:{padding:"12px 14px",background:"var(--panel)",borderRadius:13,border:"1px solid var(--line)",fontSize:12,position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:$e,flexShrink:0},title:G.prioritaet==="hoch"?"Hohe Priorität":"Normale Priorität"}),e.jsx("span",{style:{fontWeight:700,color:"var(--ink)",fontSize:13},children:G.name}),G.tag&&e.jsx("span",{style:an,children:G.tag}),G.anzahl&&e.jsx("span",{style:{...ye,...xe,marginLeft:"auto"},children:G.anzahl})]}),G.beschreibung&&e.jsx("div",{style:{color:"var(--ink-2)",lineHeight:1.6,fontSize:12},children:G.beschreibung})]},ze)})})]})]})})(),c&&!X&&(()=>{let z=50;D>=5?z+=15:D>=3?z+=5:D<1.5?z-=15:D<2.5&&(z-=5),w>=3?z+=15:w>=2?z+=5:w<1?z-=15:w<1.5&&(z-=5),d>=Ze*1.5?z+=10:d>=Ze?z+=5:d<Ze*.5&&(z-=10),M>=40?z+=5:M<15&&(z-=10),Y>3e3?z+=5:Y<500&&Y>0&&(z-=5),te>0&&M>0&&(z+=5),z=Math.max(0,Math.min(100,z));const W=z>=70?"A":z>=40?"B":"C",G=W==="A"?"var(--green)":W==="B"?"#92610A":"var(--red)",ze="var(--panel)",$e="var(--line)",Q=W==="A"?"Gut aufgestellt":W==="B"?"Ausbaufähig":"Handlungsbedarf",We=[];return D<3&&We.push("Social Media Content-Paket â mit nur ~"+D.toFixed(1)+" Posts/Woche liegt der Kunde unter dem Branchenschnitt ("+bt+"). RegelmäÃiger Content steigert Reichweite und Engagement."),M<25&&We.push("Mehr Reels / Video-Content â nur "+M+"% Reels-Anteil (Branche: "+at+"%). Video ist der stärkste Reichweiten-Hebel auf Instagram."),w<1.5&&We.push("Community Management & Pflege â "+w.toFixed(1)+"% Engagement ist unterdurchschnittlich. Aktives Community Management und strategische Captions können das deutlich steigern."),Y>0&&Y<1e3&&We.push("Reel-Optimierung & Strategie â à "+Y.toLocaleString("de-DE")+" Views pro Reel ist ausbaufähig. Trend-Audios, Hook-Texte und besseres Timing bringen mehr Reichweite."),d<Ze*.7&&We.push("Wachstumsstrategie & Meta Ads â mit "+d.toLocaleStr
163ing("de-DE")+" Followern unter dem Branchenschnitt ("+Ze.toLocaleString("de-DE")+"). Gezielte Ads und Kooperationen beschleunigen das Wachstum."),te>70&&We.push("Content-Mix diversifizieren â "+te+"% Fotos dominieren den Feed. Karussells und Reels bringen mehr Saves und Shares."),W==="A"&&We.length===0&&We.push("Skalierung & Eventbegleitung â der Kunde ist gut aufgestellt. Nächster Schritt: mehr Produktionstage, Event-Content oder Imagefilm für die Markenwahrnehmung."),e.jsxs("div",{style:{padding:16,background:ze,borderRadius:16,border:`1px solid ${$e}`,marginBottom:16,position:"relative",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",top:14,right:16},children:e.jsx("div",{style:{...xe,width:44,height:44,borderRadius:10,background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center",color:G,fontSize:22,fontWeight:800,letterSpacing:"-.032em"},children:W})}),e.jsx("div",{style:{...fe,marginBottom:6},children:"Social-Media-Status"}),e.jsx("div",{style:{fontSize:15,fontWeight:800,color:"var(--ink)",letterSpacing:"-.016em",marginBottom:8},children:Q}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx("div",{style:{flex:1,height:6,borderRadius:6,background:"var(--panel-2)",border:"1px solid var(--line)",overflow:"hidden",maxWidth:"60%"},children:e.jsx("div",{style:{width:`${z}%`,height:"100%",background:G,transition:"width 1s cubic-bezier(.22,1,.36,1)"}})}),e.jsxs("span",{style:{...xe,fontSize:11.5,fontWeight:700,color:G},children:[z,"/100"]})]}),We.length>0&&e.jsxs("div",{style:{...ki,marginTop:4},children:[e.jsx("div",{style:{...fe,marginBottom:8},children:"Empfohlene nächste Schritte"}),We.slice(0,3).map((Pt,kt)=>{const[Wt,...yn]=Pt.split(" â ");return e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:8,fontSize:11,lineHeight:1.5},children:[e.jsx("span",{style:{...xe,width:18,height:18,borderRadius:6,background:"var(--panel-2)",border:"1px solid var(--line)",color:"var(--ink-2)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:9.5,fontWeight:800,flexShrink:0,marginTop:1},children:kt+1}),e.jsxs("div",{children:[e.jsx("strong",{style:{color:"var(--ink)"},children:Wt}),yn.length>0&&e.jsxs("span",{style:{color:"var(--ink-2)"},children:[" â ",yn.join(" â ")]})]})]},kt)})]})]})})(),_e.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[e.jsx("div",{style:fe,children:"Neueste Beiträge"}),s&&e.jsxs("a",{href:`https://instagram.com/${s}`,target:"_blank",rel:"noopener noreferrer",style:{fontSize:11.5,color:"var(--green)",textDecoration:"none",fontWeight:700,display:"flex",alignItems:"center",gap:5},children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",style:{width:10,height:10},children:e.jsx("path",{d:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"})}),"Profil öffnen"]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6,1fr)",gap:4},children:_e.slice(0,6).map((z,W)=>e.jsxs("a",{href:z.shortcode?`https://instagram.com/p/${z.shortcode}/`:"#",target:"_blank",rel:"noopener noreferrer",style:{position:"relative",paddingBottom:"100%",borderRadius:8,overflow:"hidden",background:"var(--panel-2)",border:"1px solid var(--line)",display:"block"},children:[z.thumbnail&&e.jsx("img",{src:z.thumbnail,alt:"",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"},onError:G=>{G.target.style.display="none"}}),z.type==="reel"&&e.jsx("div",{style:{position:"absolute",top:3,right:3,background:"rgba(0,0,0,.5)",borderRadius:6,padding:"0px 4px",fontSize:8,color:"#fff",fontWeight:600},children:"â¶"})]},W))})]}),c&&_e.length===0&&!X&&e.jsx("div",{style:{textAlign:"center",marginBottom:16},children:e.jsx("button",{className:"cs-btn-outline",style:{fontSize:12.5},onClick:async()=>{var z;try{vt.delete(`/api/social-analyze?handle=${encodeURIComponent(s)}`);const W=await Ge(`/api/social-analyze?handle=${encodeURIComponent(s)}`);(z=W.recentPosts)!=null&&z.length?Oe(W.recentPosts):alert("Keine Beiträge gefunden.")}catch{}},children:"Neueste Beiträge laden"})}),en&&e.jsxs("div",{style:{padding:30,textAlign:"center"},children:[e.jsx("div",{style:{display:"inline-flex",gap:6},children:[0,1,2].map(z=>e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"var(--green)",animation:`csPulse 1.2s ease-in-out ${z*.15}s infinite`}},z))}),e.jsxs("div",{style:{...ye,marginTop:10},children:["Analysiere @",s,"â¦"]}),e.jsx("style",{children:"@keyframes csPulse{0%,100%{opacity:.25;transform:scale(.8)}50%{opacity:.8;transform:scale(1.1)}}"})]}),Fe&&!en&&e.jsxs("div",{style:{...Nn,marginTop:16},children:[e.jsx("div",{style:{...fe,marginBottom:10},children:"KI-Empfehlung"}),e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",lineHeight:1.7,whiteSpace:"pre-wrap"},children:Fe.split(/(\*\*[^*]+\*\*)/).map((z,W)=>z.startsWith("**")&&z.endsWith("**")?e.jsx("strong",{style:{color:"var(--ink)"},children:z.slice(2,-2)},W):e.jsx("span",{children:z},W))})]})]})})()]})]}),xn&&(()=>{var D,w;const s=((w=(D=xn.name)==null?void 0:D.split(".").pop())==null?void 0:w.toLowerCase())||"",c=["jpg","jpeg","png","gif","webp","svg"].includes(s),d=s==="pdf",y=async M=>{M.preventDefault();const te=await qs(xn);te?window.open(te,"_blank"):alert("Download gerade nicht möglich â bitte nochmal versuchen.")};return e.jsx("div",{className:"cs-modal-overlay",onClick:()=>ea(null),children:e.jsxs("div",{className:"cs-modal",style:{maxWidth:c||d?720:560},onClick:M=>M.stopPropagation(),children:[e.jsxs("div",{className:"cs-modal-header",children:[e.jsx("div",{className:"cs-modal-title",children:xn.name}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsxs("a",{href:"#",onClick:y,className:"cs-btn-outline",style:{fontSize:12.5,textDecoration:"none",display:"flex",alignItems:"center",gap:6},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:12,height:12},children:[e.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Download"]}),e.jsx("button",{className:"cs-modal-close",onClick:()=>ea(null),children:"â"})]})]}),e.jsxs("div",{className:"cs-modal-body",style:{padding:c||d?0:24},children:[c&&e.jsx("div",{style:{background:"var(--panel-2)",display:"flex",alignItems:"center",justifyContent:"center",minHeight:200,maxHeight:500,overflow:"hidden"},children:e.jsx(Js,{f:xn,kind:"img",style:{maxWidth:"100%",maxHeight:500,objectFit:"contain"}})}),d&&e.jsx("div",{style:{height:500,background:"var(--panel-2)"},children:e.jsx(Js,{f:xn,kind:"frame",style:{width:"100%",height:"100%",border:"none"}})}),e.jsxs("div",{style:{padding:c||d?"16px 24px":0},children:[e.jsxs("div",{className:"cs-modal-file-info",children:[e.jsxs("div",{className:"cs-modal-file-row",children:[e.jsx("span",{className:"cs-modal-file-label",children:"Dateiname:"}),e.jsx("span",{children:xn.name})]}),xn.emailSubject&&e.jsxs("div",{className:"cs-modal-file-row",children:[e.jsx("span",{className:"cs-modal-file-label",children:"Email-Betreff:"}),e.jsx("span",{children:xn.emailSubject})]}),xn.emailFrom&&e.jsxs("div",{className:"cs-modal-file-row",children:[e.jsx("span",{className:"cs-modal-file-label",children:"Von:"}),e.jsx("span",{children:xn.emailFrom})]}),xn.emailDate&&e.jsxs("div",{className:"cs-modal-file-row",children:[e.jsx("span",{className:"cs-modal-file-label",children:"Datum:"}),e.jsx("span",{children:St(xn.emailDate)})]})]}),!c&&!d&&e.jsx("div",{style:{...Nn,marginTop:16,textAlign:"center"},children:e.jsxs("a",{href:"#",onClick:y,className:"cs-btn-primary",style:{textDecoration:"none",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:14,height:14},children:[e.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Datei herunterladen"]})})]})]})]})})})()]})}function tl(t,r){if(!t||!r||!r.length)return null;const a=(" "+t+" ").toLowerCase(),n=[...r].sort((h,p)=>p.name.length-h.name.length);for(const h of n){const p=(h.name||"").trim().toLowerCase();if(p.length>=6&&a.includes(p))return h}return null}function Aa({id:t,name:r}){return e.jsxs("span",{role:"button",tabIndex:0,title:`Projekt öffnen: ${r}`,onClick:a=>{a.stopPropagation(),window.location.href=`/projektdetails-intern?recordId=${encodeURIComponent(t)}`},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.stopPropagation(),window.location.href=`/projektdetails-intern?recordId=${encodeURIComponent(t)}`)},style:{display:"inline-flex",alignItems:"center",gap:6,maxWidth:240,fontSize:11.5,fontWeight:700,color:"var(--green)",background:"transparent",border:"1px solid var(--green-bd)",borderRadius:8,padding:"3px 10px",textDecoration:"none",cursor:"pointer",transition:"background .15s",whiteSpace:"nowrap",overflow:"hidden"},onMouseEnter:a=>{a.currentTarget.style.background="var(--green-soft)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent"},children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:13,height:13,flexShrink:0},children:e.jsx("path",{d:"M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V7z"})}),e.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:["Projekt öffnen",r?`: ${r}`:""]})]})}function wc({currentUser:t,setView:r,setLeadId:a}){const[n,h]=l.useState((t==null?void 0:t.key)||"");l.useEffect(()=>{t!=null&&t.key&&h(t.key)},[t==null?void 0:t.key]);const[p,k]=l.useState([]),[f,C]=l.useState([]),[m,v]=l.useState([]),[g,x]=l.useState([]),[N,ee]=l.useState([]),[le,Z]=l.useState(!0),[I,B]=l.useState("emails"),[j,P]=l.useState([]),[ve,$]=l.useState(!0),[_,ue]=l.useState(null),[be,ie]=l.useState(null),[H,U]=l.useState([]),[F,K]=l.useState(!1),[A,ce]=l.useState(!1),[Ve,Xe]=l.useState(""),[it,ne]=l.useState(""),[Le,Ue]=l.useState(""),[ct,yt]=l.useState(!1),[rt,De]=l.useState(""),[je,nt]=l.useState(new Set),[qe,lt]=l.useState(!1),[gt,Nt]=l.useState(!1),[Ut,Mt]=l.useState(new Set),[$t,un]=l.useState(new Set),[Xt,kn]=l.useState(!1),[sn,jn]=l.useState(new Map);l.useEffect(()=>{let b=!1;return hl().then(re=>{b||jn(new Map(re))}),()=>{b=!0}},[]);const[on,Jt]=l.useState([]);l.useEffect(()=>{let b=!1;return Ge("/api/job-changes").then(re=>{!b&&re&&Array.isArray(re.events)&&Jt(re.events)}).catch(()=>{}),()=>{b=!0}},[]);const mn=b=>{Jt(re=>re.filter(he=>he.id!==b)),Ge("/api/job-changes/dismiss",{method:"POST",body:JSON.stringify({id:b})}).catch(()=>{})};l.useEffect(()=>{let b=!1;return(async()=>{var Ae,u,J,O;const re=["gmail.com","googlemail.com","yahoo.com","hotmail.com","outlook.com","web.de","gmx.de","gmx.net","t-online.de","icloud.com","aol.com","mail.de","freenet.de","posteo.de","protonmail.com","zoho.com","live.com","me.com"],he=new Set,ge=new Set,Te=oe=>{const q=String(oe||"").toLowerCase().match(/[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}/);if(!q)return;const se=q[0];he.add(se);const Ee=se.split("@")[1]||"";Ee&&!re.includes(Ee)&&ge.add(Ee)};for(const oe of N||[]){Te(o(oe,i.contactEmail));const q=(o(oe,i.url)||"").toLowerCase().replace(/^https?:\/\/(www\.)?/,"").replace(/\/.*$/,"").trim();q&&q.includes(".")&&!re.includes(q)&&ge.add(q)}try{const oe=await Hi();for(const q of oe.byLeadId.values())for(const se of q)Te(((Ae=se.fields)==null?void 0:Ae.CIy6k)||((u=se.fields)==null?void 0:u.z0
163xSB));for(const q of oe.byCompany.values())for(const se of q)Te(((J=se.fields)==null?void 0:J.CIy6k)||((O=se.fields)==null?void 0:O.z0xSB))}catch{}b||(Mt(he),un(ge),kn(!0))})(),()=>{b=!0}},[N]);const cn=l.useMemo(()=>{const b=["gmail.com","googlemail.com","yahoo.com","hotmail.com","outlook.com","web.de","gmx.de","gmx.net","t-online.de","icloud.com"],re=new Map,he=new Map;for(const ge of N){const Te=(o(ge,i.contactEmail)||"").toLowerCase().trim();Te&&!re.has(Te)&&re.set(Te,ge);const Ae=Te.split("@")[1]||"";Ae&&!b.includes(Ae)&&!he.has(Ae)&&he.set(Ae,ge);const u=(o(ge,i.url)||"").toLowerCase().replace(/^https?:\/\/(www\.)?/,"").replace(/\/.*$/,"").trim();u&&u.length>3&&!b.includes(u)&&!he.has(u)&&he.set(u,ge)}return{byMail:re,byDomain:he}},[N]),Qt=b=>{const he=(((b.fromEmail||b.from||"")+" "+(b.to||"")).toLowerCase().match(/[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}/g)||[]).filter(ge=>!ge.endsWith("@liberdamedia.de"));for(const ge of he){const Te=cn.byMail.get(ge);if(Te)return Te}for(const ge of he){const Te=ge.split("@")[1]||"",Ae=cn.byDomain.get(Te);if(Ae)return Ae}return null},[Gt,dt]=l.useState(null),Rt=l.useRef(null),ft=(b,re)=>{const he=b.currentTarget.getBoundingClientRect();Rt.current&&clearTimeout(Rt.current),Rt.current=setTimeout(()=>dt({lead:re,x:Math.max(8,Math.min(he.left,window.innerWidth-290)),y:he.bottom+6}),1e3)},dn=()=>{Rt.current&&clearTimeout(Rt.current),dt(null)},pn=b=>{const re=(b.fromEmail||b.from||"").toLowerCase().match(/[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}/);let he=re?re[0]:"";if(he.endsWith("@liberdamedia.de")){const Te=(String(b.to||"").toLowerCase().match(/[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}/g)||[]).find(Ae=>!Ae.endsWith("@liberdamedia.de"));Te&&(he=Te)}if(!he)return!1;if(Ut.has(he))return!0;const ge=he.split("@")[1]||"";return!!(ge&&$t.has(ge))},V=l.useMemo(()=>Xt?Ut.size===0?j:j.filter(pn):[],[j,Ut,$t,Xt]),Fe=b=>{const re=`${(b.date||"").substring(0,20)}|${(b.fromEmail||b.from||"").toLowerCase()}|${(b.subject||"").substring(0,60)}`;let he=0;for(let ge=0;ge<re.length;ge++)he=(he<<5)-he+re.charCodeAt(ge)|0;return String(Math.abs(he))},[Ne,mt]=l.useState(new Set),[Ie,Lt]=l.useState(new Set);l.useEffect(()=>{lt(!1),Ge(`/api/kv?key=read-${n}`).then(b=>{b.value&&Array.isArray(b.value)?mt(new Set(b.value)):mt(new Set)}).catch(()=>mt(new Set)),Ge(`/api/kv?key=opened-${n}`).then(b=>{b.value&&Array.isArray(b.value)?Lt(new Set(b.value)):Lt(new Set)}).catch(()=>Lt(new Set))},[n]);const wn=b=>{mt(re=>{const he=new Set(re);return b.forEach(ge=>he.add(ge)),Ge("/api/kv",{method:"POST",body:JSON.stringify({key:`read-${n}`,value:[...he]})}).catch(()=>{}),he})},Zn=b=>{Lt(re=>{if(b.every(ge=>re.has(ge)))return re;const he=new Set(re);return b.forEach(ge=>he.add(ge)),Ge("/api/kv",{method:"POST",body:JSON.stringify({key:`opened-${n}`,value:[...he]})}).catch(()=>{}),he})};l.useEffect(()=>{In();const b=setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||(vt.delete(`/api/inbox?user=${n}&limit=50`),(async()=>{try{const re=await Ge(`/api/inbox?user=${n}&limit=50`);re.messages&&P(re.messages)}catch{}})())},3e4);return()=>clearInterval(b)},[n]),l.useEffect(()=>{t&&(async()=>{Z(!0);try{const b=(t==null?void 0:t.name)||"Dima Liberda";let re=[];for(let Ae=0;Ae<3e3;Ae+=100){const u=await Zt($a,100,Ae),J=(u==null?void 0:u.data)||[];if(re.push(...J),J.length<100)break}C(re.map(Ae=>{var u,J,O,oe,q;return{id:Ae.id,name:((u=Ae.fields)==null?void 0:u.MRsFW)||"",cover:((O=(J=Ae.fields)==null?void 0:J.eIre3)==null?void 0:O.url)||(Array.isArray((oe=Ae.fields)==null?void 0:oe.eIre3)?(q=Ae.fields.eIre3[0])==null?void 0:q.url:"")||""}}).filter(Ae=>Ae.name));const he=re.filter(Ae=>{var oe,q;const u=(oe=Ae.fields)==null?void 0:oe.si6A8,J=(q=Ae.fields)==null?void 0:q.Rbf4P,O=se=>se?(Array.isArray(se)?se:[se]).some(Me=>((Me==null?void 0:Me.label)||"").toLowerCase().includes(b.toLowerCase().split(" ")[0])):!1;return O(u)||O(J)});k(he);const ge=[];for(let Ae=0;Ae<2e3;Ae+=200){const u=await Zt(Cn,200,Ae),J=(u==null?void 0:u.data)||[];if(ge.push(...J),J.length<200)break}const Te=ge.map((Ae,u)=>{const J=Ae.fields||{};return{id:Ae.id||`todo-${u}`,text:J[He.task]||"Aufgabe",subline:J[He.subline]||"",done:J[He.completed]===!0,urgent:J[He.urgent]===!0,date:(J[He.deadline]||J[He.date]||"").slice(0,10),assignee:Array.isArray(J[He.assignee])?J[He.assignee][0]||"":J[He.assignee]||"",leadName:J.fUJ5C||""}}).filter(Ae=>!Ae.done&&(Ae.assignee||"").toLowerCase().includes(b.toLowerCase().split(" ")[0])).sort((Ae,u)=>(u.urgent?1:0)-(Ae.urgent?1:0)||(u.date||"").localeCompare(Ae.date||""));v(Te);try{let Ae=[],u=0;for(;;){const O=(await Zt(tt,100,u)).data||[];if(Ae=[...Ae,...O],O.length<100)break;u+=100}ee(Ae)}catch{}try{let Ae=[],u=0;for(;;
163){const oe=(await Zt(Io,100,u)).data||[];if(Ae=Ae.concat(oe),oe.length<100)break;u+=100}const J=Ae.filter(O=>{var Ee,Me;const oe=(Ee=O.fields)==null?void 0:Ee.K3CXj;if(oe===!0||oe==="true"||oe===1)return!1;const q=(Me=O.fields)==null?void 0:Me.uE57G;return(Array.isArray(q)?q:q?[q]:[]).some(pt=>((pt==null?void 0:pt.label)||String(pt||"")).toLowerCase().includes(b.toLowerCase().split(" ")[0]))});x(J)}catch(Ae){console.error("Feedback laden fehlgeschlagen:",Ae)}}catch(b){console.error(b)}finally{Z(!1)}})()},[t]);const In=async(b=!1)=>{b||($(!0),ue(null),ie(null));try{const re=await Ge(`/api/inbox?user=${n}&limit=50`);P(re.messages||[])}catch(re){console.error(re),b||P([])}finally{b||$(!1)}},en=async b=>{Zn([Fe(b)]),ue(b),ie(null),U([]),K(!0);try{const he=await Ge(`/api/email?user=${n}&seq=${b.seq}&folder=INBOX`);ie(he.raw||"(leer)"),U(Array.isArray(he.attachments)?he.attachments:[])}catch{ie("Fehler beim Laden.")}finally{K(!1)}},S=b=>{ce(!0),Xe(b.fromEmail||""),ne("Re: "+(b.subject||"")),Ue(""),ue(null)},X=b=>{ce(!0),Xe(""),ne("Fwd: "+(b.subject||"")),Ue(` 164 165---------- Weitergeleitete Nachricht ---------- 166Von: ${b.from||b.fromEmail} 167Datum: ${b.date} 168Betreff: ${b.subject} 169`),ue(null)},we=async()=>{if(!(!Ve||!it)){yt(!0),De("");try{const b=await Ge("/api/send",{method:"POST",body:JSON.stringify({user:n,to:Ve,subject:it,body:Le.replace(/\n/g,"<br>")})});b.success?(De("Gesendet!"),ce(!1),Xe(""),ne(""),Ue(""),In()):De("Fehler: "+(b.error||"?"))}catch(b){De("Fehler: "+b.message)}finally{yt(!1)}}},Be=[{key:"emails",label:"E-Mails",count:ve?null:V.filter(b=>!Ne.has(Fe(b))).length||null},{key:"projects",label:"Projekte",count:le?null:p.filter(b=>{var he,ge;const re=(((ge=(he=b.fields)==null?void 0:he.K4jmU)==null?void 0:ge.label)||"").toLowerCase();return!re.includes("abgeschlossen")&&!re.includes("abgebrochen")}).length||null},{key:"tasks",label:"Aufgaben",count:le?null:m.length||null},{key:"feedback",label:"Feedback",count:le?null:g.length||null}],pe=wt.find(b=>b.key===n),_e=ve?0:V.filter(b=>!Ne.has(Fe(b))).length,Oe=le?0:p.filter(b=>{var he,ge;const re=(((ge=(he=b.fields)==null?void 0:he.K4jmU)==null?void 0:ge.label)||"").toLowerCase();return!re.includes("abgeschlossen")&&!re.includes("abgebrochen")}).length,zt=((t==null?void 0:t.name)||"Dima Liberda").toLowerCase().split(" ")[0],Yt=N.filter(b=>{const re=ut(b,i.statusLabel).toLowerCase();return re.includes("follow")||re.includes("potenzial")||re.includes("angebot")?(ut(b,i.ownerName)||o(b,i.ownerName)||"").toLowerCase().includes(zt):!1}).length,fn=N.filter(b=>{const re=ut(b,i.statusLabel).toLowerCase();return re.includes("follow")||re.includes("potenzial")||re.includes("angebot")?(ut(b,i.ownerName)||o(b,i.ownerName)||"").toLowerCase().includes(zt):!1}).map(b=>{const re=o(b,i.lastCommDate)||o(b,i.lastActivityDate)||"",he=re?Math.floor((Date.now()-new Date(re).getTime())/864e5):null;return{l:b,last:re,days:he}}).sort((b,re)=>new Date(re.last||0).getTime()-new Date(b.last||0).getTime()).slice(0,6),Dn=[{key:"emails",label:"Neue E-Mails",sub:"ungelesen",value:_e,color:"#1D4ED8",onClick:()=>B("emails")},{key:"followup",label:"Offene Follow-ups",sub:"Angebote / Potenzial",value:Yt,color:"#5B21B6",onClick:()=>r("leads")},{key:"tasks",label:"Offene Aufgaben",sub:"zu erledigen",value:le?0:m.length,color:"#92610A",onClick:()=>B("tasks")},{key:"projects",label:"Offene Projekte",sub:"in Arbeit",value:Oe,color:"var(--green)",onClick:()=>B("projects")}];return e.jsxs("div",{className:"cs-main cs-inbox",children:[e.jsxs("div",{className:"cs-page-header",style:{flexWrap:"nowrap"},children:[e.jsx("h1",{className:"cs-page-title",children:"Inbox"}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[e.jsx("button",{className:"cs-btn-primary",onClick:()=>{ce(!A),ue(null)},children:"+ Neue E-Mail"}),e.jsxs("div",{className:"cs-inbox-user-select",children:[e.jsx(It,{userKey:n,size:24}),e.jsx("select",{className:"cs-select",value:n,onChange:b=>h(b.target.value),style:{border:"none",background:"none",fontWeight:600},children:wt.map(b=>e.jsx("option",{value:b.key,children:b.name},b.key))})]})]})]}),e.jsxs("div",{className:"cs-inbox-scroll",children:[e.jsx("div",{className:"cs-inbox-tiles",children:Dn.map(b=>e.jsxs("button",{className:"cs-inbox-tile",onClick:b.onClick,style:{"--tile-accent":b.color},children:[e.jsx("span",{className:"cs-inbox-tile-num",style:{color:b.color},children:b.value}),e.jsx("span",{className:"cs-inbox-tile-label",children:b.label}),e.jsx("span",{className:"cs-inbox-tile-sub",children:b.sub})]},b.key))}),(on.length>0||fn.length>0)&&e.jsxs("div",{style:{padding:"0 26px 10px"},children:[e.jsx("h2",{style:{...fe,margin:"2px 0 8px"},children:"Wichtig"}),e.jsxs("div",{className:"cs-listwrap",style:Tt,children:[on.map(b=>{const re=String(b.newTitle||"").trim(),he=String(b.newCompany||"").trim(),ge=String(b.oldCompany||"").trim(),Te=String(b.oldTitle||"").trim();return e.jsxs("div",{style:{display:"flex",gap:12,padding:"11px 15px",borderBottom:"1px solid var(--line)"}
169,children:[e.jsxs("div",{style:{position:"relative",width:34,height:34,flexShrink:0,borderRadius:8,background:"var(--sel)",border:"1px solid var(--line)",color:"var(--green)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:700,overflow:"hidden"},children:[(String(b.name||"?").trim()[0]||"?").toUpperCase(),b.photoUrl&&e.jsx("img",{src:b.photoUrl,alt:"",loading:"lazy",onError:Ae=>{Ae.currentTarget.style.display="none"},style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[e.jsx("span",{style:{...Qe,background:"#5B21B6"},title:"Jobwechsel"}),e.jsxs("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:[b.name||"Kontakt"," hat den Job gewechselt"]})]}),e.jsxs("div",{style:{fontSize:12.5,color:"var(--ink-2)",lineHeight:1.5},children:["Jetzt ",re?e.jsx("b",{children:re}):"tätig"," bei ",e.jsx("b",{children:he||"â"}),"."]}),e.jsxs("div",{style:{fontSize:12.5,color:"var(--ink-3)",lineHeight:1.5,marginTop:1},children:["Bei ",e.jsx("b",{children:ge||"eurem Kunden"})," ist ",Te?e.jsxs(e.Fragment,{children:["â",Te,"â"]}):"die Position"," jetzt unbesetzt â jetzt handeln."]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:9},children:[b.leadId&&e.jsx("button",{onClick:()=>{a(b.leadId),r("lead-detail")},style:{...Ei,padding:"5px 11px",fontSize:11.5,borderRadius:8},children:"Lead öffnen"}),b.profileUrl&&e.jsx("a",{href:b.profileUrl,target:"_blank",rel:"noopener noreferrer",style:{...as,padding:"5px 11px",fontSize:11.5,borderRadius:8,textDecoration:"none"},children:"LinkedIn"}),e.jsx("button",{onClick:()=>mn(b.id),style:{fontSize:11.5,fontWeight:600,color:"var(--ink-3)",background:"none",border:"none",cursor:"pointer",marginLeft:"auto",fontFamily:"inherit"},children:"Erledigt"})]})]})]},b.id)}),fn.map(({l:b,days:re})=>{const he=o(b,i.displayName)||o(b,i.leadName)||"Lead",ge=ut(b,i.statusLabel);return e.jsxs("div",{onClick:()=>{a(b.id),r("lead-detail")},style:{display:"flex",alignItems:"center",gap:12,padding:"10px 15px",borderBottom:"1px solid var(--line)",cursor:"pointer",transition:"background .12s"},onMouseEnter:Te=>{Te.currentTarget.style.background="var(--panel-2)"},onMouseLeave:Te=>{Te.currentTarget.style.background="transparent"},children:[e.jsx("div",{style:{width:34,height:34,flexShrink:0,borderRadius:8,background:"var(--panel-2)",border:"1px solid var(--line)",color:"var(--ink-3)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",style:{width:15,height:15},children:[e.jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:he}),e.jsxs("div",{style:{...ye,...xe},children:[ge,re!==null?` · zuletzt vor ${re} ${re===1?"Tag":"Tagen"}`:""]})]}),e.jsx("span",{style:{fontSize:11.5,fontWeight:700,color:"var(--green)",flexShrink:0},children:"Nachfassen â"})]},b.id)})]})]}),e.jsx("div",{className:"cs-inbox-dock-anchor","aria-hidden":"true"}),e.jsx("div",{className:"cs-inbox-tabs",children:Be.map(b=>e.jsxs("button",{className:`cs-tab ${I===b.key?"cs-tab-active":""}`,onClick:()=>B(b.key),children:[b.label,b.count!==null&&b.count>0&&e.jsx("span",{className:"cs-badge-sm",children:b.count})]},b.key))}),rt&&e.jsx("div",{style:{padding:"8px 26px",fontSize:12.5,fontWeight:600,color:rt.startsWith("Fehler")?"var(--red)":"var(--green)"},children:rt}),A&&e.jsxs("div",{className:"cs-compose-bar",children:[e.jsxs("div",{className:"cs-compose-row",children:[e.jsx("span",{className:"cs-compose-label",children:"Von:"}),e.jsx("select",{className:"cs-select",value:n,onChange:b=>h(b.target.value),children:wt.map(b=>e.jsx("option",{value:b.key,children:b.email},b.key))})]}),e.jsx("input",{className:"cs-input",placeholder:"An (E-Mail-Adresse)",value:Ve,onChange:b=>Xe(b.target.value)}),e.jsx("input",{className:"cs-input",placeholder:"Betreff",value:it,onChange:b=>ne(b.target.value)}),e.jsx("textarea",{className:"cs-textarea",placeholder:"Nachricht...",rows:6,value:Le,onChange:b=>Ue(b.target.value)}),e.jsxs("div",{className:"cs-compose-footer",children:[e.jsx("button",{className:"cs-btn-primary",onClick:we,disabled:ct||!Ve||!it,children:ct?"Sende...":"Senden"}),e.jsx("button",{className:"cs-btn-outline",onClick:()=>ce(!1),children:"Abbrechen"})]})]}),je.size>0&&e.jsxs("div",{className:"cs-inbox-bulk",children:[e.jsxs("span",{className:"cs-inbox-bulk-count",children:[je.size," ausgewählt"]}),e.jsx("button",{className:"cs-btn-outline",onClick:()=>{const b=j.filter(re=>je.has(re.seq)).map(re=>Fe(re));wn(b),nt(new Set),ue(null)},children:"Archivieren"}),e.jsx("button",{className:"cs-btn-outline",onClick:()=>nt(new Set),children:"Auswahl aufheben"})]}),I==="projects"&&(()=>{const b=p.filter(re=>{var ge,Te;const he=(((Te=(ge=re.fields)==null?void 0:ge.K4jmU)==null?void 0:Te.label)||"").toLowerCase();return!he.includes("abgeschlossen")&&!he.includes("abgebrochen")});return e.jsx("div",{style:{flex:1,overflow:"auto",padding:"20px 26px 40px"},children:le?e.jsx("div",{className:"cs-empty",children:"Lade Projekte..."}):b.length===0?e.jsx("div",{className:"cs-empty",children:"Keine offenen Projekte zugewiesen."}):e.jsx("div",{className:"cs-pgrid",children:b.map(re=>{var O,oe,q,se,Ee,Me,pt,Bt,ht;const he=((O=re.fields)==null?void 0:O.MRsFW)||"Projekt",ge=((q=(oe=re.fields)==null?void 0:oe.K4jmU)==null?void 0:q.label)||"",Te=((Ee=(se
169=re.fields)==null?void 0:se.eIre3)==null?void 0:Ee.url)||(Array.isArray((Me=re.fields)==null?void 0:Me.eIre3)?(pt=re.fields.eIre3[0])==null?void 0:pt.url:null),Ae=((Bt=re.fields)==null?void 0:Bt.sJWgj)||"",u=((ht=re.fields)==null?void 0:ht.VECkn)||"",J=Ae?St(Ae):"";return e.jsxs("a",{className:"cs-pcard",href:`/projektdetails-intern?recordId=${encodeURIComponent(re.id)}`,children:[Te?e.jsx("img",{className:"cs-pcard-pic",src:Te,alt:"",loading:"lazy",onError:jt=>{jt.currentTarget.style.display="none"}}):e.jsx("div",{className:"cs-pcard-pic cs-pcard-fb",children:(String(he).trim().split(/\s+/).map(jt=>jt[0]).slice(0,2).join("")||"?").toUpperCase()}),e.jsx("div",{className:"cs-pcard-n",children:he}),(ge||J)&&e.jsxs("div",{className:"cs-pcard-i",children:[ge&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:$n(ge),flexShrink:0}}),ge]}),ge&&J&&e.jsx("span",{style:{opacity:.45,margin:"0 6px"},children:"·"}),J]}),u&&e.jsx("div",{className:"cs-pcard-d",children:u})]},re.id)})})})})(),I==="tasks"&&e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px",flex:1,overflowY:"auto"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:10},children:[e.jsx("h3",{style:fe,children:"Aufgaben"}),e.jsxs("span",{style:{...ye,...xe},children:[m.length," Einträge"]})]}),le?e.jsx("div",{className:"cs-empty",children:"Lade Aufgaben..."}):m.length===0?e.jsx("div",{className:"cs-empty",children:"Keine offenen Aufgaben."}):e.jsx("div",{className:"cs-listwrap",style:{...Tt,display:"flex",flexDirection:"column"},children:m.map((b,re)=>{const he=tl(`${b.text||""} ${b.subline||""}`,f);return e.jsx("button",{onClick:()=>r("tasks"),style:{background:"transparent",border:"none",borderBottom:"1px solid var(--line)",padding:"11px 15px",textAlign:"left",cursor:"pointer",transition:"background .12s",display:"block",width:"100%",fontFamily:"inherit"},onMouseEnter:ge=>ge.currentTarget.style.background="var(--panel-2)",onMouseLeave:ge=>ge.currentTarget.style.background="transparent",children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{width:30,height:30,borderRadius:"50%",background:"var(--panel-2)",border:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:b.urgent?"var(--red)":"var(--ink-3)",strokeWidth:"1.8",style:{width:15,height:15},children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:4},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:b.text}),b.date&&e.jsx("span",{style:{...ye,...xe,flexShrink:0},children:St(b.date)})]}),b.subline&&e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",marginBottom:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.subline}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[b.urgent&&e.jsx("span",{style:{...an,color:"var(--red)"},children:"Dringend"}),he&&e.jsx(Aa,{id:he.id,name:he.name}),b.leadName&&e.jsxs("span",{style:rn,children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),b.leadName]}),b.assignee&&e.jsx("span",{style:ye,children:b.assignee})]})]})]})},b.id||re)})})]}),I==="feedback"&&e.jsxs("div",{className:"cs-timeline",style:{padding:"20px 26px 40px",flex:1,overflowY:"auto"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:10},children:[e.jsx("h3",{style:fe,children:"Feedback"}),e.jsxs("span",{style:{...ye,...xe},children:[g.length," Einträge"]})]}),le?e.jsx("div",{className:"cs-empty",children:"Lade Feedback..."}):g.length===0?e.jsx("div",{className:"cs-empty",style:{padding:"60px 20px"},children:e.jsx("div",{children:"Kein offenes Feedback"})}):e.jsx("div",{className:"cs-listwrap",style:{...Tt,display:"flex",flexDirection:"column"},children:g.map((b,re)=>{var jt,Dt,tn,Ft,At,Et,_t,Un,Wn,Tn,rs;const he=((jt=b.fields)==null?void 0:jt.ubfeT)||"",ge=((Dt=b.fields)==null?void 0:Dt.hBKfT)||"",Te=(tn=b.fields)==null?void 0:tn.Pjg0N,Ae=Array.isArray(Te)?Te.map(nn=>
169nn==null?void 0:nn.label).filter(Boolean).join(", "):(Te==null?void 0:Te.label)||"Kein Projekt",u=Array.isArray(Te)&&Te.length>0?(Ft=Te[0])==null?void 0:Ft.id:Te==null?void 0:Te.id,J=((At=b.fields)==null?void 0:At.VTyOY)||"",O=(Et=b.fields)==null?void 0:Et.bADLb,oe=Array.isArray(O)?O:O?[O]:[],q=(_t=b.fields)==null?void 0:_t.JHj2i,se=Array.isArray(q)?q:q?[q]:[],Ee=((Un=oe[0])==null?void 0:Un.split(" ")[0])||"Jemand",Me=((Wn=se[0])==null?void 0:Wn.url)||null,pt=oe[0]?oe[0].split(" ").map(nn=>nn[0]).join("").toUpperCase().substring(0,2):"?",Bt=Array.isArray(Te)&&Te.length>0?((Tn=Te[0])==null?void 0:Tn.label)||Ae:(Te==null?void 0:Te.label)||Ae,ht=(f.find(nn=>nn.id===u)||{}).cover||"";return e.jsx("div",{onClick:()=>{u&&(window.location.href=`/projektdetails-intern?recordId=${encodeURIComponent(u)}`)},style:{background:"transparent",borderBottom:"1px solid var(--line)",padding:0,cursor:"pointer",transition:"background .12s",overflow:"hidden"},onMouseEnter:nn=>{nn.currentTarget.style.background="var(--panel-2)";const Kn=nn.currentTarget.querySelector("img[data-cov]");Kn&&(Kn.style.transform="scale(1.04)")},onMouseLeave:nn=>{nn.currentTarget.style.background="transparent";const Kn=nn.currentTarget.querySelector("img[data-cov]");Kn&&(Kn.style.transform="scale(1)")},children:e.jsxs("div",{style:{display:"flex",alignItems:"stretch",gap:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12,padding:"12px 15px",flex:1,minWidth:0},children:[Me?e.jsx("img",{src:Me,alt:oe[0]||"",style:{width:32,height:32,borderRadius:"50%",objectFit:"cover",border:"1px solid var(--line)",flexShrink:0}}):e.jsx("div",{style:{width:32,height:32,borderRadius:"50%",background:"var(--green-soft)",border:"1px solid var(--green-bd)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,color:"var(--green)",flexShrink:0},children:pt}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:Ee}),e.jsx("span",{style:ye,children:"hat Feedback gegeben"})]}),e.jsx("span",{style:{...ye,...xe,flexShrink:0},children:J?St(J):""})]}),e.jsxs("div",{style:{...ye,marginBottom:6,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[u?e.jsx(Aa,{id:u,name:Array.isArray(Te)&&Te.length>0?((rs=Te[0])==null?void 0:rs.label)||Ae:(Te==null?void 0:Te.label)||Ae}):e.jsx("span",{children:Ae}),he&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:he})]})]}),ge&&e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",lineHeight:1.6,whiteSpace:"pre-wrap",background:"var(--panel-2)",border:"1px solid var(--line)",borderRadius:10,padding:"10px 14px"},children:ge})]})]}),ht?e.jsxs("div",{title:Bt?`Projekt öffnen: ${Bt}`:"Projekt öffnen",style:{width:190,flexShrink:0,position:"relative",overflow:"hidden",background:"var(--panel-2)"},children:[e.jsx("img",{"data-cov":!0,src:ht.includes("softr")||ht.includes("dropbox")?`${ln}/api/proxy-image?url=${encodeURIComponent(ht)}`:ht,alt:Bt||"",loading:"lazy",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",display:"block",transition:"transform .25s ease"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(180deg, transparent 45%, rgba(15,23,42,.72))"}}),e.jsxs("div",{style:{position:"absolute",left:10,right:10,bottom:8,color:"#fff",fontSize:11,fontWeight:700,display:"flex",alignItems:"center",gap:5,textShadow:"0 1px 3px rgba(0,0,0,.4)"},children:[e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:Bt||"Projekt"}),e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{width:12,height:12,flexShrink:0},children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})]})]}):null]})},b.id||re)})})]}),I==="emails"&&e.jsxs("div",{className:"cs-inbox-split",children:[e.jsxs("div",{className:`cs-inbox-list ${_?"cs-inbox-list-sm":""}`,children:[!ve&&Xt&&Ne.size>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 20px",borderBottom:"1px solid var(--line)",background:"var(--panel-2)",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{style:{fontSize:11,color:"var(--ink-3)"},children:[V.filter(b=>!Ne.has(Fe(b))&&!Ie.has(Fe(b))).length," ungelesen · ",Ne.size," erledigt"]}),e.jsx("div",{style:{display:"flex",gap:6},children:Ne.size>0&&e.jsx("button",{className:"cs-btn-outline",style:{padding:"3px 10px",fontSize:11},onClick:()=>lt(!qe),children:qe?"Erledigte ausblenden":"Erledigte anzeigen"})})]}),ve||!Xt?e.jsxs("div",{className:"cs-empty",children:["Lade E-Mails für ",pe==null?void 0:pe.email,"..."]}
169):V.filter(b=>qe||!Ne.has(Fe(b))).length===0?e.jsx("div",{className:"cs-empty",children:"Keine E-Mails."}):V.filter(b=>qe||!Ne.has(Fe(b))).map((b,re)=>{const he=Ne.has(Fe(b)),ge=Ie.has(Fe(b)),Te=(b.fromEmail||"").split("@")[1]||"",Ae=(b.fromEmail||"").toLowerCase().trim(),u=Ae?sn.get(Ae):null,J=Te?`https://www.google.com/s2/favicons?domain=${Te}&sz=16`:null;return e.jsxs("div",{className:`cs-inbox-row ${ge?"":"cs-unread"} ${(_==null?void 0:_.seq)===b.seq?"cs-inbox-selected":""}`,style:he?{opacity:.55}:void 0,onClick:()=>en(b),children:[e.jsx("input",{type:"checkbox",className:"cs-inbox-check",checked:je.has(b.seq),onClick:O=>O.stopPropagation(),onChange:()=>{nt(O=>{const oe=new Set(O);return oe.has(b.seq)?oe.delete(b.seq):oe.add(b.seq),oe})}}),!ge&&e.jsx("span",{className:"cs-unread-dot",onClick:O=>O.stopPropagation()}),u?e.jsx("img",{src:u,alt:"",loading:"lazy",decoding:"async",className:"cs-inbox-favicon",style:{borderRadius:"50%",objectFit:"cover"},onError:O=>{O.target.style.display="none"}}):J&&e.jsx("img",{src:J,alt:"",loading:"lazy",decoding:"async",className:"cs-inbox-favicon",onError:O=>{O.target.style.display="none"}}),e.jsxs("div",{className:"cs-inbox-row-body",children:[e.jsxs("div",{className:"cs-inbox-row-top",children:[e.jsx("div",{className:"cs-inbox-from",children:b.fromName||b.fromEmail||b.from}),e.jsx("div",{className:"cs-inbox-subject",children:b.subject||"(kein Betreff)"}),(()=>{const O=Qt(b);if(!O)return null;const oe=o(O,i.displayName)||o(O,i.leadName)||"";if(!oe)return null;const q=Ns(o(O,i.url));return e.jsxs("span",{className:"cs-inbox-lead",title:oe,onClick:se=>{se.stopPropagation(),a(O.id),r("lead-detail")},onMouseEnter:se=>ft(se,O),onMouseLeave:dn,children:[q&&e.jsx("img",{src:q,alt:"",loading:"lazy",onError:se=>{se.target.style.display="none"}}),e.jsx("span",{className:"cs-inbox-lead-name",children:oe})]})})()]}),!!b.snippet&&e.jsx("div",{className:"cs-inbox-snippet",children:String(b.snippet).replace(/\s+/g," ").trim()})]}),e.jsx("div",{className:"cs-inbox-date",children:St(b.date)})]},`${b.seq}-${re}`)})]}),Gt&&(()=>{const b=Gt.lead,re=Ns(o(b,i.url)),he=ut(b,i.statusLabel),ge=o(b,i.lastActivityDate)||o(b,i.lastEmailDate)||"";return e.jsxs("div",{className:"cs-lead-hoverkarte",style:{left:Gt.x,top:Gt.y},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[re&&e.jsx("img",{src:re,alt:"",style:{width:16,height:16,borderRadius:4}}),e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:o(b,i.displayName)||o(b,i.leadName)})]}),!!o(b,i.contactName)&&e.jsxs("div",{className:"cs-lhk-zeile",children:["Kontakt: ",o(b,i.contactName)]}),!!he&&e.jsxs("div",{className:"cs-lhk-zeile",children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),he]}),!!ge&&e.jsxs("div",{className:"cs-lhk-zeile",children:["Letzte Aktivität: ",St(ge)]}),e.jsx("div",{className:"cs-lhk-hint",children:"Klick öffnet den Lead"})]})})(),_&&(()=>{const b=(_.fromEmail||"").toLowerCase().trim(),re=(String(_.to||"").toLowerCase().match(/[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}/g)||[]).filter(Me=>!Me.endsWith("@liberdamedia.de")),he=b.endsWith("@liberdamedia.de")&&re.length?re[0]:b,ge=he.split("@")[1]||"",Te=["gmail.com","googlemail.com","yahoo.com","hotmail.com","outlook.com","web.de","gmx.de","gmx.net","t-online.de","icloud.com","aol.com","mail.de","freenet.de","posteo.de","protonmail.com","zoho.com","live.com","me.com"],Ae=Te.includes(ge),u=ge.replace(/\.(de|com|net|org|io|co|eu|at|ch|info|biz|uk|co\.uk)$/i,"").replace(/^(mail|smtp|mx|www)\./i,"");let J=N.find(Me=>{var Bt,ht;const pt=(Bt=o(Me,i.contactEmail))==null?void 0:Bt.toLowerCase().trim();if(pt&&he&&pt===he)return!0;if(!Ae&&ge){const jt=(ht=o(Me,i.url))==null?void 0:ht.toLowerCase().replace(/^https?:\/\/(www\.)?/,"").replace(/\/.*$/,"").trim(),Dt=pt&&pt.split("@")[1]||"";if(jt&&jt.length>3&&(jt===ge||ge.endsWith("."+jt)||jt.endsWith("."+ge))||Dt&&!Te.includes(Dt)&&Dt===ge||u.length>=4&&jt&&jt.includes(u))return!0}return!1});if(!J){const Me=(_.from||_.fromName||"").toString(),pt=["ext","extern","external","intern","internal","gmbh","co","kg","kgaa","ag","ohg","mbh","deutschland","germany","group","team","info","no-reply","noreply"],Bt=(Me.match(/\(([^)]+)\)/g)||[]).map(ht=>ht.replace(/[()]/g,"").trim()).flatMap(ht=>ht.split(/[\s/|,]+/)).map(ht=>ht.trim().toLowerCase()).filter(ht=>ht.length>=3&&!pt.includes(ht)&&!Te.some(jt=>jt.startsWith(ht)));Bt.length&&(J=N.find(ht=>{const jt=(o(ht,i.displayName)||o(ht,i.leadName)||"").toLowerCase();return jt.length<3?!1:Bt.some(Dt=>jt.includes(Dt))}))}const O=J?o(J,i.displayName)||o(J,i.leadName):null,oe=(_.fromName||(_.from||"").replace(/<[^>]*>/,"").replace(/["']/g,"").trim()||he||"").trim(),q=(oe||he||"?").split(/[\s,]+/).filter(
169Boolean).slice(0,2).map(Me=>Me[0]).join("").toUpperCase()||"?";let se="";try{const Me=new Date(_.date);isNaN(Me.getTime())||(se=Me.toLocaleString("de-DE",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}))}catch{}const Ee=tl(`${_.subject||""} ${be||""}`,f);return e.jsxs("div",{className:"cs-inbox-detail",children:[e.jsx("div",{className:"cs-inbox-detail-head",children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{width:38,height:38,borderRadius:"50%",background:"var(--green-soft)",color:"var(--green)",fontWeight:700,fontSize:14,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:2},children:q}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{className:"cs-inbox-detail-subject",children:_.subject||"(kein Betreff)"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:5,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--ink)"},children:oe}),he&&e.jsxs("span",{style:{fontSize:12,color:"var(--ink-3)"},children:["<",he,">"]}),se&&e.jsx("span",{style:{fontSize:12,color:"var(--line-2)"},children:"·"}),se&&e.jsx("span",{style:{fontSize:12,color:"var(--ink-3)"},children:se})]}),(_.to||_.cc)&&e.jsxs("div",{style:{marginTop:3,fontSize:12,color:"var(--ink-3)",display:"flex",flexDirection:"column",gap:1},children:[_.to&&e.jsxs("span",{style:{overflowWrap:"anywhere"},children:[e.jsx("span",{style:{color:"var(--line-2)"},children:"An:"})," ",_.to]}),_.cc&&e.jsxs("span",{style:{overflowWrap:"anywhere"},children:[e.jsx("span",{style:{color:"var(--line-2)"},children:"Kopie:"})," ",_.cc]})]})]}),e.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0},children:[e.jsx("button",{className:"cs-btn-outline",onClick:()=>S(_),children:"Antworten"}),e.jsx("button",{className:"cs-btn-outline",onClick:()=>X(_),children:"Weiterleiten"}),e.jsx("button",{className:"cs-btn-primary",onClick:()=>{wn([Fe(_)]),ue(null)},children:"Archivieren"})]})]})}),e.jsxs("div",{style:{padding:"8px 24px",borderBottom:"1px solid var(--line)",background:"var(--panel-2)",display:"flex",alignItems:"center",gap:10,fontSize:12,flexShrink:0,flexWrap:"wrap"},children:[J?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--ink-3)"},children:"Lead:"}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",color:"var(--green)",fontWeight:600},onClick:()=>{a(J.id),r("lead-detail")},children:[Ns(o(J,i.url))&&e.jsx("img",{src:Ns(o(J,i.url)),alt:"",style:{width:16,height:16,borderRadius:3},onError:Me=>{Me.target.style.display="none"}}),O,e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:12,height:12},children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--ink-3)"},children:"Kein Lead zugeordnet"}),e.jsx("button",{className:"cs-btn-outline",style:{padding:"2px 10px",fontSize:11},onClick:()=>Nt(!0),children:"+ Lead anlegen"})]}),Ee&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--line)"},children:"|"}),e.jsx("span",{style:{color:"var(--ink-3)"},children:"Projekt:"}),e.jsx(Aa,{id:Ee.id,name:Ee.name})]})]}),e.jsx("div",{className:"cs-inbox-detail-body",children:F?e.jsx("div",{className:"cs-empty",children:"Lade E-Mail..."}):be?e.jsxs(e.Fragment,{children:[e.jsx(Ia,{rawBody:be,attCtx:{user:n,folder:"INBOX",uid:_.seq,atts:H}}),e.jsx(Oa,{user:n,folder:"INBOX",uid:_.seq,atts:H})]}):null})]})})()]})]}),gt&&_&&e.jsx(Ho,{senderEmail,senderName:_.fromName||_.from||"",onClose:()=>Nt(!1),onCreate:b=>{Nt(!1),(async()=>{let re=[],he=0;for(;;){const Te=(await Zt(tt,100,he)).data||[];if(re=[...re,...Te],Te.length<100)break;he+=100}ee(re)})(),a(b),r("lead-detail")}})]})}function Sc({setView:t,setLeadId:r,leads:a}){const[n,h]=l.useState("all"),[p,k]=l.useState(""),[f,C]=l.useState([]);l.useEffect(()=>{let g=!0;return Ge("/api/crm-aktivitaeten").then(x=>{g&&x&&x.ok&&C(x.items||[])}).catch(()=>{}),()=>{g=!1}},[]);const v=l.useMemo(()=>{var N,ee,le,Z,I,B,j,P,ve,$,_,ue,be,ie,H,U,F,K;const g=[],x=new Map((a||[]).map(A=>[A.id,A]));for(const A of f){const ce=x.get(A.leadId);g.push({leadId:A.leadId,leadName:ce&&(((N=ce.fields)==null?void 0:N[i.displayName])||((ee=ce.fields)==null?void 0:ee[i.leadName]))||"â",date:A.date,type:A.art==="call"?"Call":"Note",summary:(A.autor?A.autor+": ":"")+(A.text||""),status:ce&&(((Z=(le=ce.fields)==null?void 0:le[i.statusLabel])==null?void 0:Z.label)||((I=ce.fields)==null?void 0:I[i.statusLabel]))||""})}for(const A of a||[]){const ce=((B=A.fields)==null?void 0:B[i.lastCommDate])||((j=A.f
169ields)==null?void 0:j[i.lastActivityDate])||((P=A.fields)==null?void 0:P[i.dateUpdated]),Ve=(($=(ve=A.fields)==null?void 0:ve[i.lastCommType])==null?void 0:$.label)||((_=A.fields)==null?void 0:_[i.lastCommType])||"â",Xe=((ue=A.fields)==null?void 0:ue[i.lastCommSummary])||((be=A.fields)==null?void 0:be[i.lastEmailSubject])||"";ce&&g.push({leadId:A.id,leadName:((ie=A.fields)==null?void 0:ie[i.displayName])||((H=A.fields)==null?void 0:H[i.leadName])||"â",date:ce,type:Ve,summary:Xe,status:((F=(U=A.fields)==null?void 0:U[i.statusLabel])==null?void 0:F.label)||((K=A.fields)==null?void 0:K[i.statusLabel])||""})}return g.sort((A,ce)=>new Date(ce.date).getTime()-new Date(A.date).getTime()),g.slice(0,200)},[a,f]).filter(g=>!(n==="emails"&&!String(g.type).toLowerCase().includes("mail")||n==="calls"&&!String(g.type).toLowerCase().includes("call")||n==="notes"&&!String(g.type).toLowerCase().includes("note")||p&&!g.leadName.toLowerCase().includes(p.toLowerCase())&&!g.summary.toLowerCase().includes(p.toLowerCase())));return e.jsxs("div",{style:{padding:"20px 26px 40px",maxWidth:1100},children:[e.jsx("div",{style:{...fe,marginBottom:6},children:"Verlauf"}),e.jsx("h1",{style:{fontSize:22,fontWeight:800,letterSpacing:"-.024em",color:"var(--ink)",margin:0},children:"Activities"}),e.jsxs("p",{style:{...ye,...xe,margin:"4px 0 16px"},children:[v.length," Aktivitäten · neueste zuerst (max 200)"]}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12,flexWrap:"wrap",alignItems:"center"},children:[["all","emails","calls","notes"].map(g=>e.jsx("button",{onClick:()=>h(g),style:{padding:"6px 12px",fontSize:12,fontWeight:700,borderRadius:8,border:n===g?"1px solid var(--ink)":"1px solid var(--line)",background:n===g?"var(--ink)":"transparent",color:n===g?"#fff":"var(--ink-2)",cursor:"pointer",fontFamily:"inherit"},children:g==="all"?"Alle":g==="emails"?"E-Mails":g==="calls"?"Calls":"Notizen"},g)),e.jsx("input",{value:p,onChange:g=>k(g.target.value),placeholder:"Suchen...",style:{...Ct,marginLeft:"auto",width:"auto",minWidth:220,padding:"7px 12px",fontSize:12}})]}),e.jsxs("div",{style:{...Tt},children:[v.map((g,x)=>{const N=String(g.type).toLowerCase(),ee=N.includes("mail")?"#1D4ED8":N.includes("call")?"var(--green)":"var(--ink-3)";return e.jsxs("div",{onClick:()=>{r(g.leadId),t("lead-detail")},style:{display:"flex",alignItems:"center",gap:12,padding:"11px 15px",borderBottom:x<v.length-1?"1px solid var(--line)":"none",cursor:"pointer",transition:"background .15s"},onMouseEnter:le=>le.currentTarget.style.background="var(--panel-2)",onMouseLeave:le=>le.currentTarget.style.background="transparent",children:[e.jsx("span",{style:{...Qe,background:ee},title:String(g.type)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",letterSpacing:"-.006em",marginBottom:2},children:[g.leadName," ",e.jsxs("span",{style:{...ye,fontWeight:600},children:["· ",g.status]})]}),g.summary&&e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.summary})]}),e.jsx("div",{style:{...ye,...xe,flexShrink:0},children:St(g.date)})]},x)}),v.length===0&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--ink-3)",fontSize:12.5},children:"Keine Aktivitäten gefunden."})]})]})}function Nc({setView:t,setLeadId:r,currentUser:a}){const[n,h]=l.useState([]),[p,k]=l.useState(!0),[f,C]=l.useState("");l.useEffect(()=>{(async()=>{k(!0);const v=[],g=wt.map(le=>Ge(`/api/inbox?user=${le.key}&limit=100`).then(Z=>{(Z.messages||[]).forEach(I=>{I._via=le.key,v.push(I)})}).catch(()=>{}));await Promise.all(g);const x=le=>(le||"").replace(/^(re|fwd?|aw|wg):\s*/gi,"").trim(),N=new Map;for(const le of v){const Z=x(le.subject||"(no subject)").toLowerCase();N.has(Z)||N.set(Z,[]),N.get(Z).push(le)}const ee=Array.from(N.entries()).map(([le,Z])=>(Z.sort((I,B)=>new Date(B.date).getTime()-new Date(I.date).getTime()),{subject:Z[0].subject||le,count:Z.length,latest:Z[0],messages:Z}));ee.sort((le,Z)=>new Date(Z.latest.date).getTime()-new Date(le.latest.date).getTime()),h(ee.slice(0,100)),k(!1)})()},[]);const m=n.filter(v=>!f||(v.subject||"").toLowerCase().includes(f.toLowerCase())||(v.latest.fromName||v.latest.fromEmail||"").toLowerCase().includes(f.toLowerCase()));return e.jsxs("div",{style:{padding:"20px 26px 40px",maxWidth:1100},children:[e.jsx("div",{style:{...fe,marginBottom:6},children:"Postfach"}),e.jsx("h1",{style:{fontSize:22,fontWeight:800,letterSpacing:"-.024em",color:"var(--ink)",margin:0},children:"Conversations"}),e.jsxs("p",{style:{...ye,...xe,margin:"4px 0 12px"},children:[m.length," Email-Threads · neueste zuerst"]}),e.jsx("input",{value:f,onChange:v=>C(v.target.value),placeholder:"Suchen nach Betreff oder Absender...",style:{...Ct,marginBottom:12}}),p&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--ink-3)",fontSize:12.5},children:"Lade Email-Threads..."}),e.jsxs("div",{style:{...Tt},children:[m.map((v,g)=>e.jsx("div",{style:{padding:"11px 15px",borderBottom:g<m.length-1?"1px solid var(--line)":"none"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",letterSpacing:"-.006em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[v.subject,v.count>1&&e.jsx("span",{style:{marginLeft:8,fontSize:11.5,color:"var(--ink-3)",fontWeight:700,...xe},children:v.count})]}),e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v.latest.fromName||v.latest.fromEmail||"â"})]}),e.jsx("div",{style:{...ye,...xe,flexShrink:0},children:St(v.latest.date)})]})},g)),!p&&m.length===0&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--ink-3)",fontSize:12.5},children:"Keine Email-Threads gefunden."})]})]})}function Cc({setView:t,setLeadId:r,leads:a}){const[n,h]=l.useState(""),k=l.useMemo(()=>{var C,m,v,g,x,N,ee,le,Z,I,B;const f=[];for(const j of a||[]){const P=((C=j.fields)==null?void 0:C[i.contactName])||((m=j.fields)!=null&&m[i.contactFirst]&&((v=j.fields)!=null&&v[i.contactLast])?`${(g=j.fields)==null?void 0:g[i.contactFirst]} ${(x=j.fields)==null?void 0:x[i.contactLast]}`:null),ve=(N=j.fields)==null?void 0:N[i.contactEmail],$=((ee=j.fields)==null?void 0:ee[i.contactPhone])||((le=j.fields)==null?void 0:le[i.telefon]),_=(Z=j.fields)==null?void 0:Z[i.contactTitle],ue=((I=j.fields)==null?void 0:I[i.displayName])||((B=j.fields)==null?void 0:B[i.leadName]);!P&&!ve&&!$||f.push({leadId:j.id,leadName:ue,name:P,email:ve,phone:$,title:_})}return f.sort((j,P)=>(j.name||"").localeCompare(P.name||""))},[a]).filter(f=>!n||(f.name||"").toLowerCase().includes(n.toLowerCase())||(f.email||"").toLowerCase().includes(n.toLowerCase())||(f.leadName||"").toLowerCase().includes(n.toLowerCase()));return e.jsxs("div",{style:{padding:"20px 26px 40px",maxWidth:1100},children:[e.jsx("div",{style:{...fe,marginBottom:6},children:"Adressbuch"}),e.jsx("h1",{style:{fontSize:22,fontWeight:800,letterSpacing:"-.024em",color:"var(--ink)",margin:0},children:"Kontakte"}),e.jsxs("p",{style:{...ye,...xe,margin:"4px 0 12px"},children:[k.length," Kontakte gesamt"]}),e.jsx("input",{value:n,onChange:f=>h(f.target.value),placeholder:"Name, E-Mail oder Firma...",style:{...Ct,marginBottom:12}}),e.jsxs("div",{style:{...Tt},children:[k.slice(0,300).map((f,C)=>e.jsxs("div",{onClick:()=>{r(f.leadId),t("lead-detail")},style:{display:"flex",alignItems:"center",gap:12,padding:"10px 15px",borderBottom:C<Math.min(k.length,300)-1?"1px solid var(--line)":"none",cursor:"pointer",transition:"background .15s"},onMouseEnter:m=>m.currentTarget.style.background="var(--panel-2)",onMouseLeave:m=>m.currentTarget.style.background="transparent",children:[e.jsx(Ga,{name:f.name,size:32}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:700,color:"var(--ink)",letterSpacing:"-.006em"},children:[f.name||"â"," ",f.title&&e.jsxs("span",{style:{...ye},children:["· ",f.title]})]}),e.jsxs("div",{style:{fontSize:12.5,color:"var(--ink-2)"},children:[f.leadName," ",f.email&&`· ${f.email}`]})]}),f.phone&&e.jsx("a",{href:`tel:${f.phone}`,onClick:m=>m.stopPropagation(),title:"Anrufen",style:{...zn,color:"var(--green)",textDecoration:"none"},children:"â"}),f.email&&e.jsx("a",{href:`/postfach?an=${encodeURIComponent(f.email)}`,onClick:m=>m.stopPropagation(),title:"E-Mail schreiben",style:{...zn,color:"var(--ink-2)",textDecoration:"none"},children:"â"})]},C)),k.length===0&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--ink-3)",fontSize:12.5},children:"Keine Kontakte gefunden."}),k.length>300&&e.jsxs("div",{style:{padding:12,textAlign:"center",color:"var(--ink-3)",fontSize:11.5,borderTop:"1px solid var(--line)",background:"var(--panel-2)",...xe},children:["Erste 300 von ",k.length," angezeigt"]})]})]})}function zc(){const[t,r]=l.useState([]),[a,n]=l.useState([]),[h,p]=l.useState([]),[k,f]=l.useState(!0),[C,m]=l.useState(!1),[v,g]=l.useState(""),[x,N]=l.useState(!1),[ee,le]=l.useState(""),[Z,I]=l.useState(""),[B,j]=l.useState([{type:"send_email",subject:"",body:"",waitDays:0,fromUser:"dima"}
169]),P=H=>({id:H.id,name:H.name,description:H.notes||(H.typ?"Typ: "+H.typ:""),stepCount:(H.steps||[]).length,aktiv:H.active===1||H.active===!0,steps:(H.steps||[]).map(U=>({type:U.step_type==="task"?"create_task":"send_email",subject:U.subject_override||U.template_id||"",text:U.task_title||"",waitDays:U.delay_days||0}))}),ve=async()=>{f(!0);try{const[H,U]=await Promise.all([Ge("/api/crm/sequences"),Ge("/api/crm/sequences/enrollments")]);r((H.sequences||[]).map(P)),n(H.sequences||[]),p((U.enrollments||[]).map(F=>({...F,workflowId:F.sequence_id})))}catch(H){console.warn("[workflows] Laden fehlgeschlagen",H)}f(!1)};l.useEffect(()=>{ve()},[]);const $=()=>{m(!1),g(""),le(""),I(""),j([{type:"send_email",subject:"",body:"",waitDays:0,fromUser:"dima"}])},_=async()=>{if(!ee.trim()){alert("Name fehlt.");return}for(const H of B){if(H.type==="send_email"&&(!H.subject||!H.body)){alert("Email-Step: Betreff + Nachricht erforderlich.");return}if(H.type==="create_task"&&!H.text){alert("Task-Step: Text erforderlich.");return}}N(!0);try{const H=await Ge("/api/crm/sequences/save",{method:"POST",body:JSON.stringify({id:v||void 0,name:ee.trim(),notes:Z.trim()||void 0,steps:B.map(U=>U.type==="create_task"?{step_type:"task",delay_days:U.waitDays||0,task_title:U.text||"",task_assignee:U.assignedTo||null}:{step_type:"email",delay_days:U.waitDays||0,subject:U.subject||"",body:U.body||""})})});if(!(H!=null&&H.ok)){alert("Speichern fehlgeschlagen: "+((H==null?void 0:H.error)||"unbekannt"));return}$(),vt.clear(),ve()}catch(H){alert("Speichern fehlgeschlagen: "+H.message)}finally{N(!1)}},ue=async H=>{const U=a.find(K=>K.id===H);if(!U)return;let F={};try{const K=await Ge("/api/crm/templates");for(const A of(K==null?void 0:K.templates)||[])F[A.id]=A}catch{}le(U.name||""),I(U.notes||""),j(((U.steps||[]).length?U.steps:[{}]).map(K=>{if(K.step_type==="task")return{type:"create_task",text:K.task_title||"",waitDays:K.delay_days||0,assignedTo:K.task_assignee||""};const A=K.template_id?F[K.template_id]:null;return{type:"send_email",waitDays:K.delay_days||0,subject:K.subject_override||(A==null?void 0:A.subject)||"",body:(A==null?void 0:A.body)||"",fromUser:"dima"}})),g(H),m(!0)},be=async(H,U)=>{try{const F=await Ge("/api/crm/sequences/save",{method:"POST",body:JSON.stringify({nurAktiv:!0,id:H,active:U})});if(!(F!=null&&F.ok)){alert("Umschalten fehlgeschlagen: "+((F==null?void 0:F.error)||"?"));return}vt.clear(),ve()}catch(F){alert("Umschalten fehlgeschlagen: "+F.message)}},ie=[{value:"send_email",label:"E-Mail senden",color:"#1D4ED8"},{value:"create_task",label:"Task anlegen",color:"#92610A"}];return e.jsxs("div",{style:{padding:"20px 26px 40px",maxWidth:1100},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-end",justifyContent:"space-between",gap:12,marginBottom:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:{...fe,marginBottom:6},children:"Sequenzen"}),e.jsx("h1",{style:{fontSize:22,fontWeight:800,letterSpacing:"-.024em",color:"var(--ink)",margin:0},children:"Workflows"}),e.jsxs("p",{style:{...ye,...xe,margin:"4px 0 0"},children:[t.length," Workflows · ",h.length," Schritte in der Warteschlange"]})]}),e.jsx("button",{onClick:()=>{C?$():m(!0)},style:C?as:Pn,children:C?"Abbrechen":"Neuer Workflow"})]}),C&&e.jsxs("div",{style:{...Nn,padding:16,marginBottom:16},children:[e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Name"}),e.jsx("input",{value:ee,onChange:H=>le(H.target.value),placeholder:"z.B. Messe Follow-up 2026",style:{...Ct}})]}),e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("label",{style:{...fe,display:"block",marginBottom:5},children:"Beschreibung (optional)"}),e.jsx("input",{value:Z,onChange:H=>I(H.target.value),style:{...Ct}})]}),e.jsx("label",{style:{...fe,display:"block",marginBottom:8,paddingTop:12,borderTop:"1px solid var(--line)"},children:"Steps"}),B.map((H,U)=>{const F=ie.find(A=>A.value===H.type)||ie[0],K=H.type==="create_task"?e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:15,height:15},children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]}):H.type==="add_note"?e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:15,height:15},children:[e.jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]}):H.type==="change_status"?e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:15,height:15},children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("polyline",{points:"1 20 1 14 7 14"}),e.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}):e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:15,height:15},children:[e.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),e.jsx("polyline",{points:"22,6 12,13 2,6"})]});return e.jsxs("div",{children:[U>0&&e.jsxs("div",{style:{display:"flex",alignItems:"stretch",gap:12},children:[e.jsx("div",{style:{width:36,flexShrink:0,display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:2,background:"var(--line)"}})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,fontSize:11.5,color:"var(--ink-2)",padding:"7px 0"},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:13,height:13,color:"var(--ink-3)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"wartet",e.jsx("input",{type:"number",min:"0",value:H.waitDays||0,onChange:A=>{const ce=[...B];ce[U]={...ce[U],waitDays:parseInt(A.target.value)||0},j(ce)},style:{...Ct,width:48,padding:"3px 7px",fontSize:12,borderRadius:6,textAlign:"center",...xe}}),(H.waitDays||0)===1?"Tag":"Tage"]})]}),e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"stretch"},children:[e.jsxs("div",{style:{width:36,flexShrink:0,display:"flex",flexDirection:"column",alignItems:"center"}
169,children:[e.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"var(--panel)",border:`2px solid ${F.color}`,color:F.color,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:K}),U<B.length-1&&e.jsx("div",{style:{width:2,flex:1,background:"var(--line)",marginTop:4}})]}),e.jsxs("div",{style:{flex:1,background:"var(--panel)",border:"1px solid var(--line)",borderRadius:10,padding:"12px 14px",marginBottom:12,transition:"border-color .15s"},onMouseEnter:A=>{A.currentTarget.style.borderColor="var(--line-2)"},onMouseLeave:A=>{A.currentTarget.style.borderColor="var(--line)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[e.jsx("span",{style:{...fe,fontWeight:800,...xe},children:String(U+1).padStart(2,"0")}),e.jsx("select",{value:H.type||"send_email",onChange:A=>{const ce=[...B];ce[U]={...ce[U],type:A.target.value},j(ce)},style:{padding:"4px 8px",fontSize:13,fontWeight:700,color:"var(--ink)",borderRadius:6,border:"1px solid transparent",background:"transparent",flex:1,cursor:"pointer",fontFamily:"inherit"},onMouseEnter:A=>{A.target.style.borderColor="var(--line)"},onMouseLeave:A=>{A.target.style.borderColor="transparent"},children:ie.map(A=>e.jsx("option",{value:A.value,children:A.label},A.value))}),U>0&&e.jsx("button",{onClick:()=>j(B.filter((A,ce)=>ce!==U)),title:"Step entfernen",style:{...zn,width:24,height:24,borderRadius:7,borderColor:"transparent",color:"var(--ink-3)",fontSize:14},onMouseEnter:A=>{A.currentTarget.style.color="var(--red)",A.currentTarget.style.background="var(--red-soft)"},onMouseLeave:A=>{A.currentTarget.style.color="var(--ink-3)",A.currentTarget.style.background="transparent"},children:"â"})]}),H.type==="send_email"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{value:H.subject||"",onChange:A=>{const ce=[...B];ce[U].subject=A.target.value,j(ce)},placeholder:"Betreff",style:{...Ct,padding:"7px 10px",borderRadius:8,marginBottom:6,boxSizing:"border-box"}}),e.jsx("textarea",{value:H.body||"",onChange:A=>{const ce=[...B];ce[U].body=A.target.value,j(ce)},placeholder:"Nachricht â {firstName} und {leadName} als Variablen",rows:3,style:{...Ct,padding:"7px 10px",borderRadius:8,resize:"vertical",boxSizing:"border-box"}})]}),H.type==="create_task"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{value:H.text||"",onChange:A=>{const ce=[...B];ce[U].text=A.target.value,j(ce)},placeholder:"Task-Text (z.B. 'Follow-up Anruf {firstName}')",style:{...Ct,padding:"7px 10px",borderRadius:8,marginBottom:6,boxSizing:"border-box"}}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("input",{type:"number",min:"0",value:H.dueDays||0,onChange:A=>{const ce=[...B];ce[U].dueDays=parseInt(A.target.value)||0,j(ce)},placeholder:"Fällig in Tagen",style:{...Ct,flex:1,width:"auto",padding:"7px 10px",borderRadius:8,...xe}}),e.jsxs("select",{value:H.assignedTo||"",onChange:A=>{const ce=[...B];ce[U].assignedTo=A.target.value,j(ce)},style:{...Ct,width:"auto",padding:"7px 10px",borderRadius:8,cursor:"pointer"},children:[e.jsx("option",{value:"",children:"Zugewiesen an..."}),e.jsx("option",{value:"dima",children:"Dima"}),e.jsx("option",{value:"laura",children:"Laura"})]})]})]}),H.type==="add_note"&&e.jsx("textarea",{value:H.body||"",onChange:A=>{const ce=[...B];ce[U].body=A.target.value,j(ce)},placeholder:"Notiz-Inhalt (z.B. 'Lead hat geantwortet â Follow-up nötig')",rows:3,style:{...Ct,padding:"7px 10px",borderRadius:8,resize:"vertical",boxSizing:"border-box"}}),H.type==="change_status"&&e.jsx("input",{value:H.statusLabel||"",onChange:A=>{const ce=[...B];ce[U].statusLabel=A.target.value,j(ce)},placeholder:"Status-Label (z.B. 'Potenzial Follow up!' oder 'Bestandskunde')",style:{...Ct,padding:"7px 10px",borderRadius:8,boxSizing:"border-box"}})]})]})]},U)}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[e.jsx("button",{onClick:()=>j([...B,{type:"send_email",subject:"",body:"",waitDays:3,fromUser:"dima"}]),style:{...as,padding:"7px 12px",fontSize:12},children:"+ Step hinzufügen"}),e.jsx("button",{onClick:_,disabled:x,style:{...Pn,marginLeft:"auto",opacity:x?.6:1},children:x?"Speichertâ¦":v?"Ãnderungen speichern":"Workflow speichern"})]})]}),k&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--ink-3)",fontSize:12.5},children:"Lade Workflows..."}),!k&&t.length===0&&!C&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--ink-3)",fontSize:12.5,background:"var(--panel)",borderRadius:13,border:"1px dashed var(--line-2)"},children:'Noch keine Workflows. Klick âNeuer Workflow" um eine Email-Sequenz anzulegen.'}),t.length>0&&e.jsx("div",{style:{...Tt},children:t.map((H,U)=>{const F=h.filter(K=>K.workflowId===H.id).length;return e.jsxs("div",{style:{padding:"11px 15px",borderBottom:U<t.length-1?"1px solid var(--line)":"none",transition:"background .15s"},onMouseEnter:K=>K.currentTarget.style.background="var(--panel-2)",onMouseLeave:K=>K.currentTarget.style.background="transparent",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",ga
169p:12},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--ink)",letterSpacing:"-.008em"},children:H.name}),H.description&&e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",marginTop:2},children:H.description})]}),e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",...ye,...xe,whiteSpace:"nowrap"},children:[e.jsxs("span",{children:[H.stepCount," ",H.stepCount===1?"Schritt":"Schritte"]}),F>0&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--green)"},children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),F," laufend"]})]})]}),e.jsxs("div",{style:{...ye,marginTop:4,display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[e.jsxs("span",{children:["ID: ",H.id]}),e.jsxs("button",{onClick:()=>be(H.id,!H.aktiv),title:H.aktiv?"Pausieren":"Aktiv schalten",style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"none",cursor:"pointer",padding:0,font:"inherit",color:H.aktiv?"var(--green)":"var(--ink-3)"},children:[e.jsx("span",{style:{...Qe,background:H.aktiv?"var(--green)":"var(--ink-3)"}}),H.aktiv?"aktiv":"pausiert"]}),e.jsx("button",{onClick:()=>ue(H.id),style:{background:"transparent",border:"none",cursor:"pointer",padding:0,font:"inherit",color:"var(--ink-2)",textDecoration:"underline",textUnderlineOffset:3},children:"Bearbeiten"})]})]},H.id)})})]})}function Ac({currentUser:t}){var pn;const[r,a]=l.useState([]),[n,h]=l.useState(!0),[p,k]=l.useState("today"),[f,C]=l.useState((t==null?void 0:t.key)||"dima"),m=l.useRef(!1);l.useEffect(()=>{!m.current&&(t!=null&&t.key)&&C(t.key)},[t==null?void 0:t.key]);const v=`tasks-opened-${(t==null?void 0:t.key)||"dima"}`,[g,x]=l.useState(new Set);l.useEffect(()=>{Ge(`/api/kv?key=${v}`).then(V=>{x(V.value&&Array.isArray(V.value)?new Set(V.value):new Set)}).catch(()=>x(new Set))},[v]);const N=V=>{x(Fe=>{if(Fe.has(V))return Fe;const Ne=new Set(Fe);return Ne.add(V),Ge("/api/kv",{method:"POST",body:JSON.stringify({key:v,value:[...Ne]})}).catch(()=>{}),Ne})},[ee,le]=l.useState(!1),[Z,I]=l.useState(""),[B,j]=l.useState(""),[P,ve]=l.useState(!1),[$,_]=l.useState((t==null?void 0:t.key)||""),[ue,be]=l.useState(!1),[ie,H]=l.useState(null),[U,F]=l.useState(""),[K,A]=l.useState(""),[ce,Ve]=l.useState(!1),[Xe,it]=l.useState(""),[ne,Le]=l.useState(!1);l.useEffect(()=>{Va()},[]),l.useEffect(()=>{t!=null&&t.key&&_(V=>V||t.key)},[t==null?void 0:t.key]);const[Ue,ct]=l.useState([]),[yt,rt]=l.useState(""),[De,je]=l.useState(null),[nt,qe]=l.useState(!1),lt=new Date().toISOString().split("T")[0],gt=async()=>{h(!0);try{const V=[];for(let Ne=0;Ne<2e3;Ne+=200){const mt=await Zt(Cn,200,Ne),Ie=(mt==null?void 0:mt.data)||[];if(V.push(...Ie),Ie.length<200)break}const Fe=V.map((Ne,mt)=>{const Ie=Ne.fields||{},Lt=Ie[He.leadLink],wn=Array.isArray(Lt)&&Lt[0]?Lt[0].id||Lt[0]:"";return{id:Ne.id||`todo-${mt}`,text:Ie[He.task]||"Aufgabe",subline:Ie[He.subline]||"",done:Ie[He.completed]===!0,urgent:Ie[He.urgent]===!0,date:(Ie[He.deadline]||Ie[He.date]||"").slice(0,10),assignee:Array.isArray(Ie[He.assignee])?Ie[He.assignee][0]||"":Ie[He.assignee]||"",leadRecId:wn,leadName:Ie.fUJ5C||""}}).sort((Ne,mt)=>(mt.date||"").localeCompare(Ne.date||""));a(Fe)}catch(V){console.error(V)}finally{h(!1)}};l.useEffect(()=>{gt()},[]),l.useEffect(()=>{let V=!0;return(async()=>{var Fe;try{const Ne=await $i(Gs);V&&((Fe=Ne==null?void 0:Ne.records)!=null&&Fe.length)&&ct(Ne.records)}catch{}try{let Ne=[],mt=0;for(;;){const Lt=(await Zt(tt,100,mt)).data||[];if(Ne=[...Ne,...Lt],Lt.length<100)break;mt+=100}V&&Ne.length&&ct(Ne)}catch(Ne){console.error(Ne)}})(),()=>{V=!1}},[]);const Nt=(()=>{const V=yt.toLowerCase().trim();return V?Ue.filter(Fe=>(o(Fe,i.displayName)+" "+o(Fe,i.leadName)).toLowerCase().includes(V)).slice(0,8):[]})(),Ut=()=>{I(""),j(""),ve(!1),_((t==null?void 0:t.key)||""),je(null),rt(""),qe(!1),le(!1)},Mt=V=>{var Ne;const Fe=(V||"").toLowerCase();return Fe&&((Ne=wt.find(mt=>Fe.includes(mt.key)||Fe.includes(mt.name.toLowerCase().split(" ")[0])))==null?void 0:Ne.key)||""},$t=V=>{const Fe=wt.find(Ne=>Ne.key===V);return Fe&&Fe.recordId?[{id:Fe.recordId}]:null},un=V=>{var Fe;return((Fe=wt.find(Ne=>Ne.key===V))==null?void 0:Fe.name)||""},Xt=async()=>
169{if(!(!Z.trim()||ue)){be(!0);try{const V={[He.task]:Z.trim()};B&&(V[He.deadline]=B),P&&(V[He.urgent]=!0);const Fe=$?$t($):null;Fe&&(V[He.assigneeLink]=Fe),De&&(V[He.leadLink]=[{id:De.recId}],De.name&&(V.fUJ5C=De.name),De.closeId&&(V[He.leadIdText]=De.closeId)),await Gn(Cn,V),Ut(),await gt()}catch(V){console.error(V),alert("Aufgabe konnte nicht gespeichert werden.")}finally{be(!1)}}},kn=V=>{H(V.id),F(V.text||""),A(V.date||""),Ve(!!V.urgent),it(Mt(V.assignee))},sn=()=>{H(null),Le(!1)},jn=async V=>{const Fe=U.trim();if(!Fe||ne)return;Le(!0);const Ne={[He.task]:Fe,[He.urgent]:!!ce,[He.deadline]:K||null};if(Xe){const Ie=$t(Xe);Ie&&(Ne[He.assigneeLink]=Ie)}else Ne[He.assigneeLink]=[];const mt=Xe?un(Xe):"";a(Ie=>Ie.map(Lt=>Lt.id===V.id?{...Lt,text:Fe,date:K||"",urgent:!!ce,assignee:mt}:Lt)),H(null);try{await et(Cn,V.id,Ne)}catch(Ie){console.error(Ie),alert("Ãnderung konnte nicht gespeichert werden."),gt()}finally{Le(!1)}},[on,Jt]=l.useState(new Set),mn=V=>Jt(Fe=>{const Ne=new Set(Fe);return Ne.has(V)?Ne.delete(V):Ne.add(V),Ne});l.useEffect(()=>{Jt(new Set)},[p,f]);const cn=async V=>{const Fe=[...on];if(Fe.length){a(Ne=>Ne.map(mt=>Fe.includes(mt.id)?{...mt,done:V}:mt)),Jt(new Set);try{await Promise.all(Fe.map(Ne=>et(Cn,Ne,{[He.completed]:V})))}catch(Ne){console.error(Ne),gt()}}},Gt=(((pn=wt.find(V=>V.key===f))==null?void 0:pn.name)||"").toLowerCase().split(" ")[0],dt=V=>f==="all"||(V.assignee||"").toLowerCase().includes(Gt),Rt=(p==="done"?r.filter(V=>V.done):p==="future"?r.filter(V=>!V.done&&V.date>lt):r.filter(V=>!V.done&&(!V.date||V.date<=lt))).filter(dt).sort((V,Fe)=>(Fe.urgent?1:0)-(V.urgent?1:0)||(Fe.date||"").localeCompare(V.date||"")),ft=Rt.filter(V=>on.has(V.id)).length,dn=Rt.length>0&&ft===Rt.length;return e.jsxs("div",{className:"cs-main",children:[e.jsxs("div",{className:"cs-page-header",children:[e.jsx("h1",{className:"cs-page-title",children:"Aufgaben"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginLeft:"auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[f!=="all"&&e.jsx(It,{userKey:f,size:22}),e.jsxs("select",{className:"cs-select",value:f,onChange:V=>{m.current=!0,C(V.target.value)},style:{fontSize:12,fontWeight:600,padding:"5px 10px"},children:[wt.map(V=>e.jsxs("option",{value:V.key,children:[V.name,(t==null?void 0:t.key)===V.key?" (ich)":""]},V.key)),e.jsx("option",{value:"all",children:"Alle"})]})]}),e.jsx("button",{className:"cs-btn-primary",onClick:()=>le(V=>!V),children:"Neue Aufgabe"})]})]}),e.jsxs("div",{className:"cs-inbox-tabs",children:[e.jsx("button",{className:`cs-tab ${p==="today"?"cs-tab-active":""}`,onClick:()=>k("today"),children:"Heute"}),e.jsx("button",{className:`cs-tab ${p==="future"?"cs-tab-active":""}`,onClick:()=>k("future"),children:"Zukunft"}),e.jsx("button",{className:`cs-tab ${p==="done"?"cs-tab-active":""}`,onClick:()=>k("done"),children:"Erledigt"})]}),on.size>0&&e.jsxs("div",{className:"cs-task-actionbar",children:[e.jsx("button",{className:"cs-task-selectall",onClick:()=>Jt(dn?new Set:new Set(Rt.map(V=>V.id))),children:dn?"Alle abwählen":"Alle auswählen"}),e.jsxs("span",{className:"cs-task-selcount",children:[on.size," ausgewählt"]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:[p==="done"?e.jsx("button",{className:"cs-btn-outline",onClick:()=>cn(!1),children:"Wieder öffnen"}):e.jsx("button",{className:"cs-btn-primary",onClick:()=>cn(!0),children:"Als erledigt markieren"}),e.jsx("button",{className:"cs-btn-outline",onClick:()=>Jt(new Set),children:"Auswahl aufheben"})]})]}),ee&&e.jsxs("div",{className:"cs-add-task",style:{flexDirection:"column",alignItems:"stretch",gap:10},children:[e.jsx("input",{className:"cs-input",placeholder:"Aufgabe beschreiben...",value:Z,onChange:V=>I(V.target.value),autoFocus:!0,onKeyDown:V=>{V.key==="Enter"&&!nt&&Xt()}}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("input",{className:"cs-input",type:"date",style:{maxWidth:170},value:B,onChange:V=>j(V.target.value)}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12.5,color:"var(--ink-2)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:P,onChange:V=>ve(V.target.checked)})," Dringlich"]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[$&&e.jsx(It,{userKey:$,size:22}),e.jsxs("select",{className:"cs-input",style:{maxWidth:190},value:$,onChange:V=>_(V.target.value),title:"Person zuweisen",children:[e.jsx("option",{value:"",children:"Niemand zugewiesen"}),wt.map(V=>e.jsxs("option",{value:V.key,children:[V.name,(t==null?void 0:t.key)===V.key?" (ich)":""]},V.key))]})]}),e.jsx("div",{style:{position:"relative",flex:1,minWidth:200},children:De?e.jsxs("span",{className:"cs-lead-chip",style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",color:"var(--green)",border:"none",borderRadius:0,padding:"4px 0",fontSize:12,fontWeight:700},children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),De.name||"Lead",e.jsx("span",{style:{cursor:"pointer",fontWeight:700,color:"var(--ink-3)"},onClick:()=>{je(null),rt("")},children:"Ã"})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"cs-input",placeholder:"Lead verknüpfen (Suche)...",value:yt,onChange:V=>{rt(V.target.value),qe(!0)},onFocus:()=>qe(!0)}),nt&&Nt.length>0&&e.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:30,background:"var(--panel)",border:"1px solid var(--line)",borderRadius:10,marginTop:4,boxShadow:"var(--shadow-pop)",overflow:"hidden",maxHeight:260,overflowY:"auto"},children:Nt.map(V=>{const Fe=o(V,i.displayName)||o(V,i.leadName)||"(ohne Namen)";return e.jsx("div",{style:{padding:"9px 14px",fontSize:12.5,color:"var(--ink)",cursor:"pointer",borderBottom:"1px solid var(--line)"},onMouseEnter:Ne=>Ne.currentTarget.style.background="var(--panel-2)",onMouseLeave:Ne=>Ne.currentTarget.style.background="transparent",onMouseDown:Ne=>{Ne.preventDefault(),je({recId:V.id,name:Fe,closeId:o(V,i.closeLeadId)}),rt(""),qe(!1)},children:Fe},V.id)})})]})})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{className:"cs-btn-primary",onClick:Xt,disabled:ue||!Z.trim(),children:ue?"Speichert...":"Hinzufügen"}),e.jsx("button",{className:"cs-btn-outline",onClick:Ut,children:"Abbrechen"})]})]}),e.jsx("div",{className:"cs-task-list",children:n?e.jsx("div",{className:"cs-empty",children:"Lade Aufgaben..."}):Rt.length===0?e.jsx("div",{className:"cs-empty",children:"Keine Aufgaben."}):Rt.map(V=>{const Fe=on.has(V.id),Ne=!V.done&&!g.has(V.id),mt=Mt(V.assignee);return ie===V.id?e.jsxs("div",{className:"cs-task",style:{alignItems:"stretch",flexDirection:"column",gap:10,cursor:"default",background:"var(--sel)"},onClick:Ie=>Ie.stopPropagation(),children:[e.jsx("input",{className:"cs-input",value:U,autoFocus:!0,onChange:Ie=>F(Ie.target.value),onKeyDown:Ie=>{Ie.key==="Enter"&&(Ie.preventDefault(),jn(V)),Ie.key==="Escape"&&sn()},placeholder:"Aufgabe beschreiben..."}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("input",{className:"cs-input",type:"date",style:{maxWidth:160},value:K,onChange:Ie=>A(Ie.target.value)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[Xe&&e.jsx(It,{userKey:Xe,size:22}),e.jsxs("select",{className:"cs-input",style:{maxWidth:180},value:Xe,onChange:Ie=>it(Ie.target.value),title:"Person zuweisen",children:[e.jsx("option",{value:"",children:"Niemand zugewiesen"}),wt.map(Ie=>e.jsxs("option",{value:Ie.key,children:[Ie.name,(t==null?void 0:t.key)===Ie.key?" (ich)":""]},Ie.key))]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12.5,color:"var(--ink-2)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:ce,onChange:Ie=>Ve(Ie.target.checked)})," Dringlich"]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{className:"cs-btn-primary",onClick:()=>jn(V),disabled:ne||!U.trim(),children:ne?"Speichert...":"Speichern"}),e.jsx("button",{className:"cs-btn-outline",onClick:sn,children:"Abbrechen"})]})]},V.id):e.jsxs("div",{className:`cs-task ${V.done?"cs-task-done":""} ${Fe?"cs-task-selected":""}`,onClick:()=>{N(V.id),mn(V.id)},style:{cursor:"pointer"},children:[e.jsx("button",{className:`cs-check ${Fe?"cs-checked":""}`,onClick:Ie=>{Ie.stopPropagation(),N(V.id),mn(V.id)},children:Fe&&"â"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[Ne&&e.jsx("span",{className:"cs-unread-dot",onClick:Ie=>Ie.stopPropagation(),style:{flexShrink:0}}),e.jsx("span",{className:"cs-task-text",style:{fontWeight:Ne?700:void 0,...V.done?{textDecoration:"line-through",opacity:.6}:{}},children:V.text}),V.urgent&&!V.done&&e.jsx("span",{style:{...an,color:"var(--red)",flexShrink:0},children:"Dringend"})]}),V.subline&&e.jsx("div",{style:{fontSize:12.5,color:"var(--ink-2)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:V.subline})]}),mt&&e.jsx("span",{title:`Zugewiesen: ${un(mt)||V.assignee}`,onClick:Ie=>Ie.stopPropagation(),style:{flexShrink:0,display:"inline-flex"},children:e.jsx(It,{userKey:mt,size:24})}),V.leadName&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:"var(--green)",fontWeight:700,flexShrink:0},children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}}),V.leadName]}),V.date&&e.jsx("span",{style:{...ye,...xe,flexShrink:0},children:V.date}),e.jsx("button",{title:"Bearbeiten",onClick:Ie=>{Ie.stopPropagation(),kn(V)},style:{...zn,width:24,height:24,borderRadius:7,borderColor:"transparent",color:"var(--ink-3)",transition:"color .12s,background .12s,border-color .12s"},onMouseEnter:Ie=>{Ie.currentTarget.style.color="var(--green)",Ie.currentTarget.style.background="var(--green-soft)",Ie.currentTarget.style.borderColor="var(--green-bd)"},onMouseLeave:Ie=>{Ie.currentTarget.style.color="var(--ink-3)",Ie.currentTarget.style.background="transparent",Ie.currentTarget.style.borderColor="transparent"},children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",style:{width:15,height:15},children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})})]},V.id)})})]})}function nl(){var C;const[t,r]=l.useState({total:0,by:{},topOwners:[],topEmail:[],topCalls:[],recentLeads:[],funnel:[],activityWeeks:[],totalOppValue:0,conversionRate:0,avgEmailsPerLead:0}),[a,n]=l.useState([]),[h,p]=l.useState(!0);l.useEffect(()=>{(async()=>{try{let m=[],v=0;for(;;){const A=(await Zt(tt,100,v)).data||[];if(m=[...m,...A],A.length<100||(v+=100,v>300))break}const g={};m.forEach(K=>{const A=Za(ut(K,i.statusLabel))||"Unbekannt";g[A]=(g[A]||0)+1});const x={};m.forEach(K=>{const A=ut(K,i.ownerName);A&&(x[A]=(x[A]||0)+1)});const N=wt.map(K=>{const A=Object.entries(x).reduce((ce,[Ve,Xe])=>
169ce+(Ve.toLowerCase().includes(K.key)?Xe:0),0);return[K.name,A]}).sort((K,A)=>A[1]-K[1]),ee={};m.forEach(K=>{const A=o(K,i.displayName)||o(K,i.leadName),ce=Number(o(K,i.numEmails))||0;ce>0&&A&&(ee[A]={name:A,emails:ce})});const le=Object.values(ee).sort((K,A)=>A.emails-K.emails).slice(0,8),Z={};m.forEach(K=>{const A=o(K,i.displayName)||o(K,i.leadName),ce=Number(o(K,i.numCalls))||0;ce>0&&A&&(Z[A]={name:A,calls:ce})});const I=Object.values(Z).sort((K,A)=>A.calls-K.calls).slice(0,8),B=[...m].sort((K,A)=>{const ce=o(K,i.dateUpdated)||"";return(o(A,i.dateUpdated)||"").localeCompare(ce)}).slice(0,10),P=[{stageKey:"NEU",labels:["NEUER LEAD","neu"],display:"Neue Leads"},{stageKey:"ARBEIT",labels:["In Arbeit","arbeit"],display:"In Arbeit"},{stageKey:"POT",labels:["Potenzial","Follow up"],display:"Potenzial / Follow-up"},{stageKey:"BESTAND",labels:["Bestandskunde","Tier 1"],display:"Bestandskunde"},{stageKey:"GOLD",labels:["GOLDKUNDE"],display:"Goldkunde"}].map(K=>{const A=m.filter(ce=>{var Xe;const Ve=((Xe=o(ce,i.statusLabel))==null?void 0:Xe.label)||o(ce,i.statusLabel)||"";return K.labels.some(it=>Ve.toLowerCase().includes(it.toLowerCase()))}).length;return{...K,count:A}}),ve=new Date,$=[];for(let K=7;K>=0;K--){const A=new Date(ve);A.setDate(A.getDate()-K*7-ve.getDay()),A.setHours(0,0,0,0);const ce=new Date(A);ce.setDate(ce.getDate()+7);const Ve=A.toISOString(),Xe=ce.toISOString();let it=0,ne=0,Le=0;m.forEach(Ue=>{var je;const ct=o(Ue,i.dateCreated)||"",yt=o(Ue,i.lastEmailDate)||"",rt=o(Ue,i.lastCommDate)||"",De=(((je=o(Ue,i.lastCommType))==null?void 0:je.label)||o(Ue,i.lastCommType)||"").toLowerCase();ct>=Ve&&ct<Xe&&Le++,yt>=Ve&&yt<Xe&&it++,De.includes("call")&&rt>=Ve&&rt<Xe&&ne++}),$.push({weekStart:A.toISOString().slice(0,10),weekEnd:ce.toISOString().slice(0,10),emails:it,calls:ne,newLeads:Le})}const _=m.reduce((K,A)=>K+(Number(o(A,i.oppValue))||0),0),ue=m.reduce((K,A)=>K+(Number(o(A,i.numEmails))||0),0),be=m.length>0?ue/m.length:0,ie=g.GOLDKUNDE||g["ð GOLDKUNDE"]||0,H=g.Bestandskunde||g["â¤ï¸ Bestandskunde"]||0,U=m.length>0?(ie+H)/m.length*100:0;r({total:m.length,by:g,topOwners:N,topEmail:le,topCalls:I,recentLeads:B,funnel:P,activityWeeks:$,totalOppValue:_,conversionRate:U,avgEmailsPerLead:be});const F=await Zt($a,100,0);n(F.data||[])}catch(m){console.error(m)}finally{p(!1)}})()},[]);const k=Object.entries(t.by).sort((m,v)=>v[1]-m[1]),f=((C=k[0])==null?void 0:C[1])||1;return e.jsxs("div",{className:"cs-main",style:{padding:0},children:[e.jsxs("div",{className:"cs-page-header",style:{padding:"48px 28px 6px",border:"none",background:"transparent",maxWidth:1080,margin:"0 auto",width:"100%",flexDirection:"column",alignItems:"flex-start",gap:4},children:[e.jsx("h1",{className:"cs-page-title",children:"Reports"}),e.jsx("span",{style:{...ye},children:"Ãberblick über Leads, Pipeline und Aktivitäten"})]}),h?e.jsx("div",{className:"cs-empty",children:"Lade Reports..."}):e.jsxs("div",{style:{padding:"20px 28px 56px",maxWidth:1080,margin:"0 auto"},children:[e.jsxs("div",{className:"cs-stats-row",style:{padding:0,marginBottom:16},children:[e.jsxs("div",{className:"cs-stat",children:[e.jsx("div",{className:"cs-stat-num",children:t.total.toLocaleString()}),e.jsx("div",{className:"cs-stat-label",children:"Leads gesamt"})]}),e.jsxs("div",{className:"cs-stat",children:[e.jsx("div",{className:"cs-stat-num",children:t.by.GOLDKUNDE||t.by["ð GOLDKUNDE"]||0}),e.jsx("div",{className:"cs-stat-label",children:"Goldkunden"})]}),e.jsxs("div",{className:"cs-stat",children:[e.jsx("div",{className:"cs-stat-num",children:t.by.Bestandskunde||t.by["â¤ï¸ Bestandskunde"]||0}),e.jsx("div",{className:"cs-stat-label",children:"Bestandskunden"})]}),e.jsxs("div",{className:"cs-stat",children:[e.jsx("div",{className:"cs-stat-num",children:a.length}),e.jsx("div",{className:"cs-stat-label",children:"Projekte"})]})]}),e.jsxs("div",{style:{...Tt,display:"grid",gridTemplateColumns:"repeat(3, 1fr)",marginBottom:28},children:[e.jsxs("div",{style:{padding:15,borderRight:"1px solid var(--line)"},children:[e.jsx("div",{style:{...fe},children:"Pipeline-Wert"}),e.jsx("div",{style:{fontSize:22,fontWeight:800,color:"var(--gold-text)",marginTop:6,letterSpacing:"-.032em",...xe},children:t.totalOppValue?t.totalOppValue>=1e3?`${(t.totalOppValue/1e3).toFixed(1)}
169k â¬`:`${Math.round(t.totalOppValue)} â¬`:"0 â¬"}),e.jsx("div",{style:{...ye,marginTop:4},children:"Summe aller Opp-Werte"})]}),e.jsxs("div",{style:{padding:15,borderRight:"1px solid var(--line)"},children:[e.jsx("div",{style:{...fe},children:"Conversion-Rate"}),e.jsxs("div",{style:{fontSize:22,fontWeight:800,color:"var(--green)",marginTop:6,letterSpacing:"-.032em",...xe},children:[t.conversionRate.toFixed(1),"%"]}),e.jsx("div",{style:{...ye,marginTop:4},children:"Bestand+Gold / Total"})]}),e.jsxs("div",{style:{padding:15},children:[e.jsx("div",{style:{...fe},children:"à E-Mails / Lead"}),e.jsx("div",{style:{fontSize:22,fontWeight:800,color:"var(--ink)",marginTop:6,letterSpacing:"-.032em",...xe},children:t.avgEmailsPerLead.toFixed(1)}),e.jsx("div",{style:{...ye,marginTop:4},children:"Engagement-Indikator"})]})]}),e.jsxs("div",{style:{marginBottom:28},children:[e.jsx("h3",{className:"cs-sub-title",style:{padding:0,marginBottom:12},children:"Sales Funnel"}),e.jsx("div",{style:{...Nn,padding:16},children:(()=>{const m=Math.max(...t.funnel.map(g=>g.count),1),v=["#616E68","#1D4ED8","#92610A","#0F7A57","#7A5B00"];return t.funnel.map((g,x)=>{const N=g.count/m*100,ee=x>0?t.funnel[x-1].count-g.count:0,le=x>0&&t.funnel[x-1].count>0?ee/t.funnel[x-1].count*100:0;return e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[e.jsxs("span",{style:{fontSize:12.5,fontWeight:700,color:"var(--ink)"},children:[x+1,". ",g.display]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x>0&&ee>0&&e.jsxs("span",{style:{fontSize:11.5,color:"var(--red)",fontWeight:700,...xe},children:["â",ee," (â",le.toFixed(0),"%)"]}),e.jsx("span",{style:{fontSize:14,fontWeight:800,color:v[x],...xe},children:g.count})]})]}),e.jsx("div",{style:{width:"100%",background:"var(--bg-2)",borderRadius:8,overflow:"hidden",height:30,position:"relative"},children:e.jsx("div",{style:{width:`${N}%`,height:"100%",background:v[x],borderRadius:8,transition:"width 1s cubic-bezier(.22,1,.36,1)",display:"flex",alignItems:"center",paddingLeft:12},children:N>15&&e.jsxs("span",{style:{fontSize:11.5,fontWeight:700,color:"#fff",...xe},children:[g.count," Leads"]})})})]},g.stageKey)})})()})]}),e.jsxs("div",{style:{marginBottom:28},children:[e.jsx("h3",{className:"cs-sub-title",style:{padding:0,marginBottom:12},children:"Aktivitäts-Trends (letzte 8 Wochen)"}),e.jsx("div",{style:{...Nn,padding:16},children:(()=>{const m=Math.max(...t.activityWeeks.flatMap(v=>[v.emails,v.calls,v.newLeads]),1);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:16,marginBottom:12},children:[e.jsxs("span",{style:{...rn},children:[e.jsx("span",{style:{...Qe,background:"#1D4ED8"}})," E-Mails"]}),e.jsxs("span",{style:{...rn},children:[e.jsx("span",{style:{...Qe,background:"#92610A"}})," Calls"]}),e.jsxs("span",{style:{...rn},children:[e.jsx("span",{style:{...Qe,background:"var(--green)"}})," Neue Leads"]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${t.activityWeeks.length}, 1fr)`,gap:6,alignItems:"end",height:160},children:t.activityWeeks.map((v,g)=>{const x=v.emails/m*100,N=v.calls/m*100,ee=v.newLeads/m*100;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",height:"100%",gap:2},title:`${v.weekStart}: ${v.emails} E-Mails, ${v.calls} Calls, ${v.newLeads} neue Leads`,children:[e.jsxs("div",{style:{display:"flex",gap:1,alignItems:"flex-end",height:"calc(100% - 18px)",width:"100%",justifyContent:"center"},children:[e.jsx("div",{style:{width:"30%",height:`${x}%`,background:"#1D4ED8",borderRadius:"3px 3px 0 0",minHeight:v.emails>0?2:0}}),e.jsx("div",{style:{width:"30%",height:`${N}%`,background:"#92610A",borderRadius:"3px 3px 0 0",minHeight:v.calls>0?2:0}}),e.jsx("div",{style:{width:"30%",height:`${ee}%`,background:"var(--green)",borderRadius:"3px 3px 0 0",minHeight:v.newLeads>0?2:0}})]}),e.jsxs("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:"var(--ink-3)",marginTop:2,...xe}
169,children:["KW",Math.ceil(new Date(v.weekStart).getDate()/7)||1]})]},g)})})]})})()})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:24},children:[e.jsxs("div",{children:[e.jsx("h3",{className:"cs-sub-title",style:{padding:0,marginBottom:12},children:"Leads nach Status"}),e.jsx("div",{className:"cs-bars",style:{padding:0,marginBottom:24},children:k.map(([m,v])=>e.jsxs("div",{className:"cs-bar-row",children:[e.jsxs("div",{className:"cs-bar-label",children:[e.jsx("span",{className:"cs-dot",style:{background:$n(m)}}),m]}),e.jsx("div",{className:"cs-bar-track",children:e.jsx("div",{className:"cs-bar-fill",style:{width:`${v/f*100}%`,background:$n(m)}})}),e.jsx("span",{className:"cs-bar-num",children:v})]},m))}),e.jsx("h3",{className:"cs-sub-title",style:{padding:0,marginBottom:12},children:"Leads pro Mitarbeiter"}),e.jsx("div",{className:"cs-bars",style:{padding:0,marginBottom:24},children:t.topOwners.map(([m,v])=>{var N;const g=((N=t.topOwners[0])==null?void 0:N[1])||1,x=m.toLowerCase().split(" ")[0];return e.jsxs("div",{className:"cs-bar-row",children:[e.jsxs("div",{className:"cs-bar-label",style:{width:140,gap:8},children:[e.jsx(It,{userKey:x,size:20}),m]}),e.jsx("div",{className:"cs-bar-track",children:e.jsx("div",{className:"cs-bar-fill",style:{width:`${v/g*100}%`,background:"var(--green)"}})}),e.jsx("span",{className:"cs-bar-num",children:v})]},m)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"cs-sub-title",style:{padding:0,marginBottom:12},children:"Meiste E-Mail-Kontakte"}),e.jsx("div",{style:{...Tt,padding:"0 15px",marginBottom:24},children:t.topEmail.map((m,v)=>e.jsxs("div",{className:"cs-analytics-row",children:[e.jsxs("span",{style:{fontSize:12.5},children:[v+1,". ",m.name]}),e.jsxs("span",{className:"cs-analytics-val",children:[m.emails," E-Mails"]})]},v))}),e.jsx("h3",{className:"cs-sub-title",style:{padding:0,marginBottom:12},children:"Meiste Anrufe"}),e.jsx("div",{style:{...Tt,padding:"0 15px",marginBottom:24},children:t.topCalls.map((m,v)=>e.jsxs("div",{className:"cs-analytics-row",children:[e.jsxs("span",{style:{fontSize:12.5},children:[v+1,". ",m.name]}),e.jsxs("span",{className:"cs-analytics-val",children:[m.calls," Anrufe"]})]},v))}),e.jsx("h3",{className:"cs-sub-title",style:{padding:0,marginBottom:12},children:"Zuletzt aktualisiert"}),e.jsx("div",{style:{...Tt,padding:"0 15px"},children:t.recentLeads.map((m,v)=>{const g=o(m,i.displayName)||o(m,i.leadName),x=ut(m,i.statusLabel);return e.jsxs("div",{className:"cs-analytics-row",children:[e.jsxs("span",{style:{fontSize:12.5,display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{className:"cs-dot",style:{background:$n(x)}}),g]}),e.jsx("span",{className:"cs-analytics-val",children:o(m,i.dateUpdated)?St(o(m,i.dateUpdated)):"â"})]},v)})})]})]})]})]})}function Ec(){const t=Jo(),[r,a]=l.useState(!1),[n,h]=l.useState(0),p=l.useMemo(()=>{try{const $=new URLSearchParams(window.location.search),_=$.get("leadId")||$.get("recordId");return _?{view:"lead-detail",leadId:_}:null}catch{return null}},[]),k=l.useMemo(()=>{if(p)return p;try{const $=sessionStorage.getItem("crm-state");return $?JSON.parse($):null}catch{return null}},[]),[f,C]=l.useState((p==null?void 0:p.view)||"inbox"),[m,v]=l.useState((k==null?void 0:k.leadId)||null),[g,x]=l.useState((k==null?void 0:k.smartView)??-1),[N,ee]=l.useState(!1),[le,Z]=l.useState(!1),[I,B]=l.useState([]),j=l.useCallback($=>{if(C($),sessionStorage.setItem("crm-state",JSON.stringify({view:$,leadId:null,smartView:g})),$!=="lead-detail")try{const _=new URL(window.location.href);_.searchParams.delete("leadId"),_.searchParams.delete("recordId"),window.history.replaceState({},"",_.toString())}catch{}},[g]),P=l.useCallback($=>{if(v($),$){sessionStorage.setItem("crm-state",JSON.stringify({view:"lead-detail",leadId:$,smartView:g}));try{const _=new URL(window.location.href);_.searchParams.set("leadId",$),window.history.replaceState({},"",_.toString())}catch{}}},[g]);l.useEffect(()=>{Va()},[]),l.useEffect(()=>{const $=ue=>{if(!(!ue||!ue.leadId)){C("lead-detail"),v(String(ue.leadId));try{sessionStorage.setItem("crm-state",JSON.stringify({view:"lead-detail",leadId:String(ue.leadId),smartView:g}));const be=new URL(window.location.href);be.searchParams.set("leadId",String(ue.leadId)),window.history.replaceState({},"",be.toString())}catch{}}};$(Wi());const _=ue=>$(ue&&ue.detail||Wi());
169return window.addEventListener(Di,_),()=>window.removeEventListener(Di,_)},[g]),l.useEffect(()=>{let $=!0;return(async()=>{var H;try{const U=await $i(Gs);$&&((H=U==null?void 0:U.records)!=null&&H.length)&&B(U.records)}catch{}const _=async U=>{for(let F=0;F<3;F++){try{const K=await Zt(tt,100,U);if(K&&Array.isArray(K.data)&&!K.error)return K.data}catch{}await new Promise(K=>setTimeout(K,400*(F+1)))}return null};let ue=[],be=0,ie=!1;for(;$;){const U=await _(be);if(U===null)break;if(ue=[...ue,...U],U.length<100){ie=!0;break}if(be+=100,be>2e4)break}$&&ue.length&&(B(ue),ie&&Ki(Gs,{records:ue,ts:Date.now()}))})(),()=>{$=!1}},[n]);const ve=()=>{switch(f){case"dashboard":return e.jsx(nl,{});case"inbox":return e.jsx(wc,{currentUser:t,setView:j,setLeadId:P});case"leads":return e.jsx(Ur,{setView:j,setLeadId:P,smartView:g,setSmartView:x,currentUser:t},n);case"lead-detail":return m?e.jsx(jc,{leadId:m,goBack:()=>j("leads"),currentUser:t},m):e.jsx(Ur,{setView:j,setLeadId:P,smartView:g,setSmartView:x,currentUser:t},n);case"tasks":return e.jsx(Ac,{currentUser:t});case"activities":return e.jsx(Sc,{setView:j,setLeadId:P,leads:I});case"conversations":return e.jsx(Nc,{setView:j,setLeadId:P,currentUser:t});case"contacts":return e.jsx(Cc,{setView:j,setLeadId:P,leads:I});case"workflows":return e.jsx(zc,{});default:return e.jsx(nl,{})}};return e.jsxs("div",{className:"cs-root",children:[e.jsx(Pa,{block:"crm"}),e.jsx(Ic,{}),e.jsx(rc,{view:f,setView:$=>{j($),$!=="lead-detail"&&P(null)},smartView:g,setSmartView:x,collapsed:N,setEinklappend:ee,currentUser:t,leads:I,setLeadId:P,onSettings:()=>Z(!0),onMesseImport:()=>a(!0)}),e.jsx("div",{className:"cs-content",children:ve()}),r&&(t==null?void 0:t.verified)&&(t==null?void 0:t.email)==="[email protected]"&&e.jsx(Eo,{onClose:()=>a(!1),onImported:()=>h($=>$+1)}),le&&e.jsx("div",{onClick:()=>Z(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,.6)",zIndex:3e3,display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"28px 14px",overflowY:"auto"},children:e.jsxs("div",{onClick:$=>$.stopPropagation(),style:{width:"100%",maxWidth:1100,background:"var(--panel)",borderRadius:16,border:"1px solid var(--line)",position:"relative",minHeight:420,boxShadow:"var(--shadow-pop)"},children:[e.jsx("button",{onClick:()=>Z(!1),title:"SchlieÃen",style:{position:"absolute",top:14,right:16,zIndex:1,background:"var(--panel-2)",border:"1px solid var(--line)",borderRadius:8,color:"var(--ink-2)",width:30,height:30,cursor:"pointer",fontSize:15},children:"â"}),e.jsx(ko,{})]})})]})}Ec.displayName="LIBERDA CRM";function Ic(){return e.jsx("style",{children:` 170/* ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 171 â LIBERDA CRM â Reskin hell (Bauform: Content-Hub) â 172 â Unterstrich-Tabs · Haarlinien-Listen · Punkte statt â 173 â Pillen · keine Farbstriche · keine Karten-Schatten â 174 ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ */ 175 176 177/* ââ SKELETON LOADING ââ */ 178@keyframes csShimmer{0%{background-position:-400px 0}100%{background-position:400px 0}} 179@keyframes csSlideDown{from{opacity:0;max-height:0;overflow:hidden}to{opacity:1;max-height:680px;overflow:hidden}} 180@keyframes lm-spin{to{transform:rotate(360deg)}} 181@keyframes lm-pulse{0%,100%{opacity:0.4}50%{opacity:1}} 182.cs-skel{background:linear-gradient(90deg,var(--bg-2) 25%,var(--panel-2) 50%,var(--bg-2) 75%);background-size:800px 100%;animation:csShimmer 1.5s infinite ease-in-out;border-radius:6px} 183 184/* ââ RESET + ROOT ââ */ 185.cs-root *,.cs-root *::before,.cs-root *::after{box-sizing:border-box;margin:0;padding:0} 186.cs-root{ 187 /* ââ DESIGN TOKENS · LIBERDA Reskin hell (Content-Hub-Palette) ââ */ 188 --bg:#EAEFEC; --bg-2:#E1E8E4; --panel:#FFFFFF; --panel-2:#F2F6F4; --sel:#E7F1EC; 189 --card:#FFFFFF; --tile:#F2F6F4; --tile2:#F2F6F4; 190 --line:#DCE4E0; --line-2:#C4CFCA; --hair:#DCE4E0; --line-lead:#DCE4E0; 191 --ink:#0F1C17; --ink-2:#46574F;
191 --ink-3:#616E68; 192 --ink2:#0F1C17; --sub:#46574F; --faint:#616E68; --faint2:#616E68; --mute:#616E68; 193 --green:#0F7A57; --green-soft:#E7F3EE; --green-bd:#A8CFBE; --green2:#0F7A57; 194 --gold:#FFD400; --gold-2:#F2B705; --gold-text:#7A5B00; 195 --red:#B3261E; --red-soft:#FBEAE8; 196 /* Punktfarben (Status/Herkunft â nie als Fläche) */ 197 --blue:#1D4ED8; --green-fn:#0F7A57; --orange:#92610A; --purple:#5B21B6; --yellow:#FFD400; 198 --dot-kunde:#7A5B00; --dot-wettbewerb:#A61E4D; 199 /* Alias: die alten Indigo-Token zeigen jetzt auf LIBERDA-Grün */ 200 --pink:var(--green); --pink-grad:var(--green); --pink-soft:var(--green-soft); --scan-grad:var(--green); 201 --hover-lilac:var(--panel-2); 202 --r-card:13px; --r-card-lg:16px; --r-ctrl:10px; 203 --shadow-card:0 1px 2px rgba(16,32,23,.04), 0 1px 3px rgba(16,32,23,.03); 204 --shadow-pop:0 12px 32px -8px rgba(16,32,23,.16), 0 2px 6px rgba(16,32,23,.06); 205 --shadow:var(--shadow-card); 206 207 display:flex;height:100vh;width:100%; 208 font-family:'Inter',-apple-system,BlinkMacSystemFont,system-ui,sans-serif; 209 font-size:12.5px;color:var(--ink);background:var(--bg);overflow:hidden; 210 -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;letter-spacing:-0.006em;line-height:1.5; 211} 212.cs-root ::selection{background:var(--sel)} 213 214/* Eyebrow â typografische Signatur des Hubs */ 215.cs-lbl,.cs-eyebrow{font-size:10px;font-weight:700;letter-spacing:.13em;text-transform:uppercase;color:var(--ink-3)} 216 217/* âââââââââââââââââââââââââââââââ 218 SIDEBAR â hell, Haarlinien 219âââââââââââââââââââââââââââââââ */ 220.cs-sidebar{ 221 width:256px;min-width:256px;background:var(--panel); 222 border-right:1px solid var(--line); 223 display:flex;flex-direction:column;overflow-y:auto;overflow-x:hidden; 224 transition:width .25s cubic-bezier(.4,0,.2,1),min-width .25s cubic-bezier(.4,0,.2,1); 225} 226.cs-sidebar[data-collapsed]{width:56px;min-width:56px} 227.cs-sidebar[data-collapsed] span,.cs-sidebar[data-collapsed] .cs-sv-section, 228.cs-sidebar[data-collapsed] .cs-sidebar-org,.cs-sidebar[data-collapsed] .cs-sidebar-name, 229.cs-sidebar[data-collapsed] .cs-collapse-label,.cs-sidebar[data-collapsed] .cs-sidebar-search, 230.cs-sidebar[data-collapsed] .cs-nav-plus{display:none} 231/* Eingeklappt: Nav-Icons SICHTBAR lassen (analog Dashboard) â die span-Hide-Regel 232 oben würde sie sonst mit ausblenden. */ 233.cs-sidebar[data-collapsed] .cs-nav-icon{display:inline-flex !important;align-items:center;justify-content:center} 234/* #153: Ausklapp-Pfeil im eingeklappten Zustand mittig statt links (Padding raus) */ 235.cs-sidebar[data-collapsed] .cs-collapse-btn{justify-content:center;padding:12px 0} 236/* Eingeklappt bleibt der FuÃbereich (Einstellungen) sichtbar und rutscht nach unten â 237 die Smart-Views, die sonst mit margin-top:auto schieben, sind hier ausgeblendet. */ 238.cs-sidebar[data-collapsed] .cs-sidebar-bottom{margin-top:auto} 239/* Detail: Collapse-Divider zwischen Details-Panel (links) und Verlauf (rechts) */ 240.cs-detail-left.cs-detail-left--collapsed{display:none} 241.cs-detail-divider{flex-shrink:0;width:22px;display:flex;align-items:center;justify-content:center;cursor:pointer;background:var(--panel);color:var(--ink-3);transition:background .15s,color .15s} 242.cs-detail-divider:hover{background:var(--panel-2);color:var(--ink-2)} 243 244.cs-sidebar-header{display:flex;align-items:center;gap:8px;margin:10px 12px 6px} 245.cs-sidebar-header .cs-sidebar-search{flex:1;margin:0;min-width:0} 246/* Icon-Knopf (Rang d) */ 247.cs-home-btn{flex-shrink:0;width:26px;height:26px;border:1px solid var(--line);border-radius:8px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;color:var(--ink-2);background:transparent;transition:border-color .14s,color .14s} 248.cs-home-btn:hover{border-color:var(--line-2);color:var(--ink)} 249.cs-sidebar[data-collapsed] .cs-sidebar-header{margin:10px 0 6px;justify-content:center} 250.cs-sidebar-user{display:flex;align-items:center;gap:10px;padding:12px 15px;cursor:pointer;transition:background .12s} 251.cs-sidebar-user:hover{background:var(--panel-2)} 252.cs-avatar-ring{flex-shrink:0} 253.cs-avatar{width:32px;height:32px;border-radius:50%;font-size:11px;font-weight:700;color:#fff;display:flex;align-items:center;justify-content:center;flex-shrink:0} 254.cs-avatar-green{background:var(--green)} 255.cs-sidebar-name{font-size:13px;font-weight:700;color:var(--ink);line-height:1.3;letter-spacing:-.008em} 256.cs-sidebar-org{font-size:11.5px;color:var(--ink-3);line-height:1.3} 257 258/* Eingabefeld: Fokus NUR über Rahmenfarbe */ 259.cs-sidebar-search{ 260 display:flex;align-items:center;gap:8px;margin:6px 12px 8px;padding:8px 12px; 261 border-radius:var(--r-ctrl);background:var(--panel);border:1px solid var(--line-2); 262 cursor:pointer;color:var(--ink-3);transition:border-color .14s;font-size:12.5px; 263} 264.cs-sidebar-search:hover{border-color:var(--line-2);background:var(--panel-2)} 265.cs-sidebar-search:focus-within{border-color:var(--green)} 266.cs-sidebar-search-input{flex:1;background:none;border:none;color:var(--ink);font-size:12.5px;font-family:inherit;outline:none} 267.cs-sidebar-search-input::placeholder{color:var(--ink-3)} 268 269.cs-nav{padding:6px 8px;display:flex;flex-direction:column;gap:2px} 270.cs-nav-secondary{border-top:1px solid var(--line);margin-top:8px;padding-top:8px} 271.cs-nav-item{ 272 display:flex;align-items:center;gap:10px;width:100%;padding:8px 12px; 273 border:none;background:none;color:var(--ink-2);font-size:13px;font-weight:600; 274 font-family:inherit;border-radius:8px;
274cursor:pointer; 275 transition:background .14s,color .14s;text-align:left;position:relative; 276} 277.cs-nav-item:hover{background:var(--panel-2);color:var(--ink)} 278.cs-nav-item-dim{color:var(--ink-3)}.cs-nav-item-dim:hover{color:var(--ink-2)} 279.cs-active{background:var(--sel)!important;color:var(--ink)!important;font-weight:700;box-shadow:none} 280.cs-active .cs-sv-count{color:var(--ink);background:transparent} 281.cs-nav-icon{width:18px;height:18px;flex-shrink:0;display:flex;align-items:center;justify-content:center} 282.cs-nav-icon svg{width:18px;height:18px} 283.cs-nav-text{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} 284.cs-nav-plus{margin-left:auto;width:24px;height:24px;border-radius:7px;display:flex;align-items:center;justify-content:center;font-size:15px;color:var(--ink-3);cursor:pointer;transition:border-color .14s,color .14s;border:1px solid transparent} 285.cs-nav-plus:hover{border-color:var(--line);color:var(--ink)} 286 287.cs-sv-section{padding:6px 0 8px;border-top:1px solid var(--line);margin-top:auto;overflow-y:auto;max-height:42vh;scrollbar-width:thin;scrollbar-color:var(--line) transparent} 288.cs-sv-section::-webkit-scrollbar{width:6px}.cs-sv-section::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px} 289.cs-sv-search-wrap{position:relative;padding:6px 10px 6px;display:flex;align-items:center} 290.cs-sv-search-ic{width:13px;height:13px;position:absolute;left:18px;color:var(--ink-3);pointer-events:none} 291.cs-sv-search{width:100%;background:var(--panel);border:1px solid var(--line-2);border-radius:var(--r-ctrl);padding:7px 28px 7px 30px;font-size:11.5px;color:var(--ink);font-family:inherit;outline:none;transition:border-color .14s} 292.cs-sv-search:focus{border-color:var(--green);box-shadow:none} 293.cs-sv-search::placeholder{color:var(--ink-3)} 294.cs-sv-search-clear{position:absolute;right:16px;background:none;border:none;color:var(--ink-3);font-size:11px;cursor:pointer;padding:2px} 295.cs-sv-group{margin-top:2px} 296.cs-sv-group-header{display:flex;align-items:center;gap:6px;width:100%;padding:6px 12px;background:none;border:none;cursor:pointer;font-family:inherit;color:var(--ink-3);transition:color .14s} 297.cs-sv-group-header:hover{color:var(--ink)} 298.cs-sv-chevron{width:12px;height:12px;flex-shrink:0;transition:transform .2s;transform:rotate(0deg)} 299.cs-sv-chevron[data-open]{transform:rotate(90deg)} 300/* Eyebrow */ 301.cs-sv-title{font-size:10px;font-weight:700;letter-spacing:.13em;color:inherit;text-transform:uppercase} 302/* Zähler schlicht inline â keine Pille */ 303.cs-sv-count{font-size:10.5px;font-weight:700;color:var(--ink-3);background:transparent;border:none;padding:0;border-radius:0;margin-left:auto;font-variant-numeric:tabular-nums} 304.cs-sv-item{font-size:12.5px;padding:6px 12px 6px 18px;gap:8px} 305.cs-sv-emoji{width:18px;text-align:center;font-size:13px;flex-shrink:0} 306.cs-sidebar-bottom{margin-top:8px;padding:6px 8px;border-top:1px solid var(--line)} 307.cs-collapse-btn{display:flex;align-items:center;gap:8px;padding:12px 15px;border:none;background:none;color:var(--ink-3);cursor:pointer;border-top:1px solid var(--line);font-family:inherit;font-size:12.5px;width:100%;transition:color .14s} 308.cs-collapse-btn:hover{color:var(--ink-2)} 309/* 09.08.2026 (Dima): âbitte ganz unten links den pfeil im eingeklappten zustand 310 zentrieren". Der Knopf ist fuer den AUSGEKLAPPTEN Zustand gebaut â Symbol plus 311 Beschriftung âEinklappen", deshalb linksbuendig mit 15px Polster. Klappt man 312 ein, verschwindet die Beschriftung, das Polster bleibt, und der Pfeil steht 313 ausserhalb der Achse, auf der alle Symbole darueber sitzen. */ 314.cs-sidebar[data-collapsed] .cs-collapse-btn{justify-content:center;padding-left:0;padding-right:0;gap:0} 315.cs-collapse-label{font-size:12.5px} 316 317/* âââââââââââââââââââââââââââââââ 318 CONTENT AREA 319âââââââââââââââââââââââââââââââ */ 320.cs-content{flex:1;display:flex;flex-direction:column;overflow:hidden;background:var(--bg)} 321.cs-main{flex:1;overflow-y:auto;padding:0;background:var(--bg);min-height:0} 322 323/* ââ Page Header ââ */ 324.cs-page-header{display:flex;align-items:center;gap:12px;padding:20px 26px;border-bottom:1px solid var(--line);flex-wrap:wrap;background:var(--panel)} 325.cs-page-title{font-size:22px;font-weight:800;color:var(--ink);letter-spacing:-0.032em} 326.cs-page-actions{display:flex;align-items:center;gap:8px} 327.cs-page-right{margin-left:auto;display:flex;gap:6px} 328.cs-count{font-size:11.5px;color:var(--ink-3);font-weight:600;font-variant-numeric:tabular-nums} 329 330/* ââ Knöpfe · Rang a: Gold-CTA (Geld + Haupt-Handlung) ââ */ 331.cs-btn-primary{ 332 display:inline-flex;align-items:center;gap:7px; 333 padding:8px 15px;border-radius:var(--r-ctrl);border:none; 334 background:linear-gradient(135deg,#ffe14d,var(--gold-2));color:#241C00; 335 font-size:12.5px;font-weight:800;cursor:pointer;font-family:inherit; 336 transition:filter .14s;box-shadow:none; 337} 338.cs-btn-primary:hover{filter:brightness(1.04)} 339.cs-btn-primary:active{filter:brightness(.98)} 340.cs-btn-primary:disabled{opacity:.5;cursor:default;filter:none} 341/* ââ Rang b: Grün-Aktion ââ */ 342.cs-btn-green{ 343 display:inline-flex;align-items:center;gap:6px;padding:8px 14px;border-radius:var(--r-ctrl); 344 border:1px solid var(--green-bd);background:var(--green-soft);color:var(--green); 345 font-size:12.5px;font-weight:700;cursor:pointer;font-family:inherit;transition:background .14s; 346} 347.cs-btn-green:hover:not(:disabled){background:var(--sel)} 348.cs-btn-green:disabled{opacity:.6;cursor:default} 349/* ââ Rang c: Neutral ââ */ 350.cs-btn-outline{ 351 padding:7px 13px;border-radius:8px;border:1px solid var(--line); 352 background:transparent;color:var(--ink-2);font-size:12px;cursor:pointer;font-family:inherit; 353 transition:border-color .14s,color .14s;font-weight:600; 354} 355.cs-btn-outline:hover{background:var(--panel-2);border-color:var(--line-2);color:var(--ink);box-shadow:none} 356.cs-btn-outline:disabled{opacity:.35;cursor:default} 357.cs-btn-icon-only{padding:6px 9px} 358.cs-select{ 359 padding:7px 10px;border-radius:8px;border:1px solid var(--line-2); 360 background:var(--panel);color:var(--ink-2);font-size:12px;font-family:inherit;outline:none;cursor:pointer; 361 transition:border-color .14s; 362} 363.cs-select:focus{border-color:var(--green)} 364.cs-select option{background:var(--panel)} 365/* ââ Eingabefelder: Fokus NUR Rahmenfarbe, kein Ring, kein Schatten ââ */ 366.cs-input{ 367 width:100%;padding:9px 12px;border-radius:var(--r-ctrl);border:1px solid var(--line-2); 368 background:var(--panel);color:var(--ink);font-size:13px;font-family:inherit;outline:none; 369 transition:border-color .14s; 370} 371.cs-input::placeholder{color:var(--ink-3)} 372.cs-input:focus{border-color:var(--green);box-shadow:none} 373.cs-textarea{width:100%;padding:10px 12px;border-radius:var(--r-ctrl);border:1px solid var(--line-2);background:var(--panel);color:var(--ink);font-size:13px;font-family:inherit;outline:none;resize:vertical;transition:border-color .14s} 374.cs-textarea::placeholder{color:var(--ink-3)} 375.cs-textarea:focus{border-color:var(--green);box-shadow:none} 376 377/* ââ Search ââ */ 378.cs-search-bar{padding:10px 26px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:10px;background:var(--panel)} 379.cs-search-icon{width:16px;height:16px;color:var(--ink-3);flex-shrink:0} 380.cs-search-input{flex:1;background:none;border:none;color:var(--ink);font-size:13px;font-family:inherit;outline:none;font-weight:500} 381.cs-search-input::placeholder{color:var(--ink-3)} 382 383/* âââââââââââââââââââââââââââââââ 384 TABELLE â Haarlinien-Zeilen, keine Spaltengitter 385âââââââââââââââââââââââââââââââ */ 386.cs-table-wrap{overflow-x:auto;border-top:1px solid var(--line);background:var(--panel)} 387.cs-table{width:100%;border-collapse:separate;border-spacing:0} 388/* Kopf = Eyebrow */
389.cs-table th{ 390 text-align:left;padding:9px 15px;font-size:10px;font-weight:700; 391 color:var(--ink-3);border-bottom:1px solid var(--line);position:sticky;top:0; 392 background:var(--panel);text-transform:uppercase;letter-spacing:.13em; 393} 394.cs-th-w40{width:36px} 395.cs-th-sort{cursor:pointer;user-select:none;transition:color .14s} 396.cs-th-sort:hover{color:var(--ink)} 397/* Spalten-Resize-Griff am rechten th-Rand + Drop-Ziel-Markierung beim Spalten-Verschieben */ 398.cs-table th{position:relative} 399.cs-col-grip{position:absolute;top:0;right:-4px;width:9px;height:100%;cursor:col-resize;z-index:2} 400.cs-col-grip::after{content:"";position:absolute;top:22%;bottom:22%;right:4px;width:1px;background:transparent;transition:background .14s} 401.cs-col-grip:hover::after{background:var(--line-2)} 402.cs-th-dragover{background:var(--sel)} 403@keyframes cs-spin{to{transform:rotate(360deg)}} 404.cs-social-scan{display:inline-flex;align-items:center;background:none;border:none;padding:2px;margin-left:2px;cursor:pointer;color:var(--ink-3);transition:color .14s} 405.cs-social-scan:hover{color:var(--ink)} 406.cs-social-scan:disabled{cursor:wait} 407.cs-sort-arrow{font-size:8px;margin-left:3px;color:var(--ink-3)} 408.cs-table tr{border-bottom:1px solid var(--line);cursor:pointer;transition:background .12s} 409.cs-table tbody tr{background:var(--panel)} 410.cs-table tbody tr:hover{background:var(--panel-2)} 411.cs-table tbody tr:last-child{border-bottom:none} 412.cs-table td{padding:11px 15px;font-size:12.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:280px;border-bottom:1px solid var(--line)} 413.cs-table tbody tr:last-child td{border-bottom:none} 414.cs-td-name{font-weight:600} 415.cs-td-icon{width:36px;text-align:center} 416.cs-td-contact{font-size:12.5px;color:var(--ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} 417.cs-td-sub{font-size:11px;color:var(--ink-3);margin-top:2px} 418.cs-td-more{font-size:11px;color:var(--ink-3);font-weight:600} 419.cs-td-comm{max-width:220px} 420.cs-td-comm-text{font-size:12px;color:var(--ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:220px} 421.cs-td-center{text-align:center} 422/* Zähler schlicht inline â keine Pille */ 423.cs-td-num{font-size:12px;font-weight:700;color:var(--ink);background:transparent;border:none;padding:0;border-radius:0;font-variant-numeric:tabular-nums} 424.cs-td-date{font-size:12px;color:var(--ink-2);white-space:nowrap;font-variant-numeric:tabular-nums} 425.cs-td-dim{color:var(--ink-3);font-size:12px} 426/* Chance/Opportunity â schlichter Text, keine Pille */ 427.cs-opp-pill{display:inline-block;max-width:170px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:middle;font-size:11.5px;font-weight:600;color:var(--ink-2);background:transparent;border:none;padding:0;border-radius:0} 428.cs-lead-row-name{display:flex;align-items:center;gap:8px} 429.cs-favicon{width:20px;height:20px;border-radius:6px;flex-shrink:0;object-fit:contain;border:1px solid var(--line)} 430.cs-favicon-placeholder{width:20px;height:20px;border-radius:6px;background:var(--panel-2);flex-shrink:0;border:1px solid var(--line)} 431.cs-lead-link{color:var(--ink);font-weight:600;transition:color .14s} 432.cs-lead-link:hover{color:var(--green)} 433.cs-ic{width:15px;height:15px;display:inline-block;vertical-align:middle} 434.cs-ic-hover{cursor:pointer;color:var(--ink-3);transition:color .14s}.cs-ic-hover:hover{color:var(--ink)} 435 436/* ââ Status = Punkt + Klartext (nie eine Pille) ââ */ 437.cs-status{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:600;letter-spacing:0} 438.cs-status-pill{padding:0;border:none;border-radius:0;background:transparent;font-size:12px} 439.cs-status-clickable{cursor:pointer;transition:opacity .14s} 440.cs-status-clickable:hover{opacity:.75;box-shadow:none} 441.cs-status-dropdown{position:absolute;top:calc(100% + 6px);left:0;z-index:100;background:var(--panel);border:1px solid var(--line-2);border-radius:var(--r-ctrl);box-shadow:var(--shadow-pop);padding:6px;
441min-width:200px;max-height:320px;overflow-y:auto;animation:csModalIn .15s ease} 442.cs-status-option{display:flex;align-items:center;gap:8px;width:100%;padding:8px 12px;border:none;background:none;font-size:12.5px;color:var(--ink-2);cursor:pointer;border-radius:8px;font-family:inherit;text-align:left;transition:background .12s} 443.cs-status-option:hover{background:var(--panel-2);color:var(--ink)} 444.cs-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0;display:inline-block} 445 446/* ââ Pagination ââ */ 447.cs-pagination{display:flex;align-items:center;gap:12px;justify-content:center;padding:14px;border-top:1px solid var(--line);background:var(--panel);font-variant-numeric:tabular-nums} 448.cs-empty{padding:40px;text-align:center;color:var(--ink-3);font-size:12.5px} 449.cs-muted{color:var(--ink-3);font-size:12px;padding:6px 0} 450.cs-link{color:var(--green);text-decoration:none;font-size:12.5px;font-weight:600} 451.cs-link:hover{text-decoration:underline} 452.cs-err{color:var(--red);font-size:12px;margin-left:8px}.cs-ok{color:var(--green);font-size:12px;margin-left:8px} 453.cs-badge-count{font-size:11px;color:var(--ink-3);margin-left:6px;font-variant-numeric:tabular-nums} 454/* Zähler schlicht inline â keine Pille */ 455.cs-badge-sm{font-size:11px;background:transparent;color:var(--ink);padding:0;border:none;border-radius:0;margin-left:6px;font-weight:700;font-variant-numeric:tabular-nums} 456 457/* âââââââââââââââââââââââââââââââ 458 LEAD DETAIL 459âââââââââââââââââââââââââââââââ */ 460.cs-detail{padding:0;display:flex;flex-direction:column} 461.cs-detail-topbar{ 462 display:flex;align-items:center;gap:12px;padding:15px 24px; 463 border-bottom:1px solid var(--line);background:var(--panel);position:sticky;top:0;z-index:10; 464} 465.cs-back{background:none;border:1px solid transparent;color:var(--ink-3);cursor:pointer;padding:6px;border-radius:8px;transition:border-color .14s,color .14s} 466.cs-back:hover{color:var(--ink);border-color:var(--line)} 467.cs-back svg{width:18px;height:18px} 468.cs-detail-identity{display:flex;align-items:center;gap:12px;flex:1} 469.cs-detail-logo{ 470 width:44px;height:44px;border-radius:var(--r-ctrl);background:var(--panel-2); 471 display:flex;align-items:center;justify-content:center; 472 font-size:18px;font-weight:800;color:var(--ink-2);flex-shrink:0; 473 border:1px solid var(--line);overflow:hidden; 474} 475.cs-detail-name{font-size:22px;font-weight:800;color:var(--ink);letter-spacing:-0.032em} 476.cs-detail-actions{display:flex;gap:6px} 477/* Rang c: Neutral */ 478.cs-action-btn{ 479 display:flex;align-items:center;gap:6px;padding:7px 13px;border-radius:8px; 480 border:1px solid var(--line);background:transparent;color:var(--ink-2);font-size:12px; 481 cursor:pointer;font-family:inherit;transition:border-color .14s,color .14s,background .14s;font-weight:600; 482} 483.cs-action-btn:hover{background:var(--panel-2);border-color:var(--line-2);color:var(--ink);box-shadow:none} 484.cs-action-ic{width:14px;height:14px} 485 486/* ââ Compose Bar ââ */ 487.cs-compose-bar{padding:15px 24px;border-bottom:1px solid var(--line);background:var(--panel-2);display:flex;flex-direction:column;gap:10px} 488.cs-compose-row{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--ink-2)} 489.cs-compose-label{font-weight:700}.cs-compose-to{color:var(--ink);font-weight:700} 490.cs-compose-footer{display:flex;align-items:center;gap:8px} 491 492/* ââ Detail Body â 2 columns ââ */ 493.cs-detail-body{display:flex;flex:1;overflow:hidden} 494.cs-detail-left{flex-shrink:0;width:360px;min-width:360px;border-right:1px solid var(--line);overflow-y:auto;background:var(--panel)} 495.cs-detail-right{flex:1;overflow-y:auto;background:var(--bg)} 496 497/* ââ Left Tabs · Unterstrich-Form ââ */ 498.cs-left-tabs{display:flex;gap:6px;padding:0 20px;border-bottom:1px solid var(--line);background:var(--panel)} 499.cs-left-tab{padding:9px 14px;font-size:13px;font-weight:700;border:none;background:transparent;color:var(--ink-2);cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;font-family:inherit;transition:color .14s,border-color .14s;white-space:nowrap} 500.cs-left-tab:hover{color:var(--ink)} 501.cs-left-tab-active{color:var(--ink);border-bottom-color:var(--green);font-weight:700} 502 503/* ââ Sections â abgetrennt, nicht eingerahmt ââ */ 504.cs-section{border-bottom:1px solid var(--line)} 505.cs-section-head{ 506 display:flex;align-items:center;gap:8px;padding:12px 20px; 507 font-size:10px;font-weight:700;color:var(--ink-3);letter-spacing:.13em; 508 text-transform:uppercase;cursor:pointer;transition:background .12s;user-select:none; 509} 510.cs-section-head:hover{background:var(--panel-2)} 511.cs-chevron{font-size:10px;color:var(--ink-3);width:14px;flex-shrink:0;transition:transform .2s} 512.cs-section-icon{font-size:13px;flex-shrink:0} 513.cs-section-title-text{font-size:10px;font-weight:700;letter-spacing:.13em}
514/* Zähler schlicht inline â keine Pille */ 515.cs-section-count{font-size:11px;font-weight:700;color:var(--ink);background:transparent;padding:0;border:none;border-radius:0;min-width:0;text-align:left;font-variant-numeric:tabular-nums} 516.cs-section-spacer{flex:1} 517.cs-section-extra{display:flex;align-items:center;gap:8px} 518.cs-section-plus{color:var(--ink-3);cursor:pointer;font-size:17px;font-weight:400;transition:color .14s} 519.cs-section-plus:hover{color:var(--ink)} 520.cs-section-inbox{font-size:11px;color:var(--green);cursor:pointer;font-weight:700} 521.cs-section-search{font-size:12px;cursor:pointer;opacity:.45;transition:opacity .14s}.cs-section-search:hover{opacity:1} 522.cs-section-dots{font-size:16px;color:var(--ink-3);cursor:pointer;letter-spacing:2px} 523.cs-section-body{padding-bottom:8px} 524.cs-section-info{padding:6px 20px 6px 40px;font-size:12px;color:var(--ink-2)} 525 526/* ââ About rows ââ */ 527.cs-about-row{display:flex;align-items:flex-start;gap:10px;padding:6px 20px 6px 40px;font-size:12.5px;color:var(--ink-2)} 528.cs-about-ic{font-size:14px;flex-shrink:0;width:18px;text-align:center;margin-top:1px;color:var(--ink-3)} 529.cs-about-ic svg{color:var(--ink-3)} 530.cs-about-sub{font-size:11.5px;color:var(--ink-3);margin-top:2px} 531.cs-about-desc{font-size:12.5px;color:var(--ink-2);line-height:1.55} 532 533/* ââ Opportunities â Haarlinien-Zeilen ââ */ 534.cs-opp-item{padding:10px 20px 10px 40px;border-bottom:1px solid var(--line)} 535.cs-opp-item:last-child{border-bottom:none} 536.cs-opp-name{font-size:13px;font-weight:700;color:var(--ink);letter-spacing:-.008em} 537.cs-opp-meta{font-size:12px;color:var(--ink-2);margin-top:3px;font-variant-numeric:tabular-nums} 538 539/* ââ Contacts ââ */ 540.cs-contact-row{display:flex;align-items:center;gap:8px;padding:6px 0} 541.cs-contact-row:last-child{border-bottom:none} 542.cs-contact-left{flex:1;min-width:0} 543.cs-contact-name-link{font-size:13px;font-weight:700;color:var(--ink);cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block} 544.cs-contact-name-link:hover{text-decoration:none;color:var(--green)} 545.cs-contact-role{font-size:11px;color:var(--ink-3);margin-top:1px} 546.cs-contact-actions{display:flex;gap:2px;flex-shrink:0} 547/* Icon-Knopf (Rang d) */ 548.cs-contact-action{ 549 display:flex;align-items:center;justify-content:center;width:26px;height:26px; 550 border-radius:8px;border:1px solid transparent;color:var(--ink-3);transition:border-color .14s,color .14s;text-decoration:none; 551} 552.cs-contact-action:hover{color:var(--ink);border-color:var(--line);background:var(--panel-2)} 553.cs-contact-action svg{width:14px;height:14px} 554.cs-contact-card{padding:6px 12px 6px 20px;border-bottom:1px solid var(--line)} 555.cs-contact-card:last-of-type{border-bottom:none} 556.cs-contact-details{padding:2px 0 6px 36px;display:flex;flex-direction:column;gap:2px} 557.cs-contact-detail{display:flex;align-items:center;gap:6px} 558.cs-task-inline{display:flex;align-items:flex-start;gap:8px;padding:6px 20px 6px 40px;font-size:12px;color:var(--ink-2)} 559.cs-task-inline-dot{width:7px;height:7px;border-radius:50%;background:var(--orange);flex-shrink:0;margin-top:5px} 560.cs-task-inline-text{line-height:1.45} 561.cs-contact-role-edit{font-size:11px;color:var(--ink-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} 562.cs-contact-detail-edit{font-size:11px} 563.cs-show-more{padding:8px 20px 8px 40px;font-size:12px;color:var(--green);cursor:pointer;font-weight:600} 564.cs-show-more:hover{text-decoration:underline} 565 566/* Letzte Zeile eines Listen-Containers: keine Haarlinie (sonst Doppellinie am Rahmen) */ 567.cs-listwrap > *:last-child{border-bottom:none} 568 569/* ââ Custom Fields ââ */ 570/* Felderliste = Zeilen mit Haarlinie, kein Einzelkasten (Content-Hub-Form) */ 571.cs-cf-row{display:flex;justify-content:space-between;align-items:center;padding:9px 20px 9px 40px;font-size:12.5px;border-bottom:1px solid var(--line);transition:background .12s} 572.cs-cf-row:last-child{border-bottom:none} 573.cs-cf-row:hover{background:var(--panel-2)} 574.cs-cf-full{flex-direction:column;align-items:flex-start;gap:6px} 575.cs-cf-label{font-size:10px;font-weight:700;letter-spacing:.13em;text-transform:uppercase;color:var(--ink-3);flex-shrink:0} 576.cs-cf-value{color:var(--ink);text-align:right;max-width:55%;overflow:hidden;text-overflow:ellipsis;display:flex;align-items:center;gap:6px} 577.cs-cf-user{display:flex;align-items:center;gap:6px} 578.cs-cf-text{font-size:12px;color:var(--ink-2);line-height:1.55;padding:4px 0} 579 580/* âââââââââââââââââââââââââââââââ 581 TABS â Unterstrich, keine Kacheln 582âââââââââââââââââââââââââââââââ */ 583.cs-timeline-tabs{display:flex;align-items:center;gap:6px;padding:0 20px;border-bottom:1px solid var(--line);background:var(--panel);flex-wrap:wrap} 584.cs-tab{ 585 padding:9px 14px;font-size:13px;font-weight:700;border:none;background:transparent; 586 color:var(--ink-2);cursor:pointer;border-bottom:2px solid transparent; 587 font-family:inherit;transition:color .14s,border-color .14s;margin-bottom:-1px;white-space:nowrap; 588} 589.cs-tab:hover{color:var(--ink)} 590.cs-tab-active{color:var(--ink);border-bottom-color:var(--green);font-weight:700} 591.cs-timeline-search{margin-left:auto;padding:8px;
591cursor:pointer;color:var(--ink-3);transition:color .14s} 592.cs-timeline-search:hover{color:var(--ink)} 593 594/* âââââââââââââââââââââââââââââââ 595 TIMELINE â Haarlinien-Zeilen 596âââââââââââââââââââââââââââââââ */ 597.cs-timeline{padding:0} 598.cs-timeline-fallback{padding:0} 599 600.cs-tl-item{ 601 display:flex;gap:12px;padding:11px 20px;position:relative;cursor:pointer; 602 transition:background .12s;border-bottom:1px solid var(--line); 603} 604.cs-tl-item:last-child{border-bottom:none} 605.cs-tl-item:hover{background:var(--panel-2)} 606/* Markierung: nur Fläche, KEIN farbiger Strich links */ 607.cs-tl-item-active{background:var(--sel)!important} 608.cs-tl-item::before{content:"";position:absolute;left:33px;top:40px;bottom:-4px;width:1px;background:var(--line)} 609.cs-tl-item:last-child::before{display:none} 610 611.cs-tl-dot{ 612 width:28px;height:28px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center; 613 border:1px solid var(--line);position:relative;z-index:1;background:var(--panel);transition:border-color .14s; 614} 615.cs-tl-dot-blue{color:var(--blue)} 616.cs-tl-dot-yellow{color:var(--orange)} 617.cs-tl-dot-green{color:var(--green)} 618.cs-tl-dot-gray{color:var(--ink-3)} 619 620.cs-tl-content{flex:1;min-width:0} 621.cs-tl-title{font-size:13px;font-weight:700;color:var(--ink);letter-spacing:-.008em} 622.cs-tl-row{display:flex;align-items:center;gap:6px;margin-top:4px;font-size:12px;color:var(--ink-2)} 623.cs-tl-chevron{font-size:9px;color:var(--ink-3);width:10px} 624.cs-tl-from{font-weight:600;color:var(--ink-2)} 625.cs-tl-preview{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ink-3)} 626.cs-tl-date{font-size:11px;color:var(--ink-3);white-space:nowrap;flex-shrink:0;margin-left:auto;font-variant-numeric:tabular-nums} 627.cs-tl-avatar{flex-shrink:0} 628.cs-tl-desc{font-size:12.5px;color:var(--ink-2);margin-top:4px;line-height:1.55;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden} 629.cs-tl-meta{font-size:11px;color:var(--ink-3);margin-top:4px;display:flex;gap:6px} 630.cs-tl-showmore{font-size:12px;color:var(--green);cursor:pointer;margin-top:4px;font-weight:600} 631.cs-tl-showmore:hover{text-decoration:underline} 632 633/* ââ Email body expanded ââ */ 634.cs-tl-email-body{margin:0 0 8px 50px;border:1px solid var(--line);border-radius:var(--r-card);overflow:hidden;background:var(--panel);box-shadow:none} 635.cs-tl-email-meta{padding:12px 15px;background:var(--panel-2);border-bottom:1px solid var(--line);font-size:12px;color:var(--ink-2);display:flex;flex-direction:column;gap:2px} 636.cs-tl-email-actions{display:flex;gap:6px;padding:8px 15px;border-bottom:1px solid var(--line)} 637.cs-tl-email-content{padding:15px;max-height:500px;overflow-y:auto} 638 639/* ââ Avatar helpers ââ */ 640.cs-avatar-img{border-radius:50%;object-fit:cover;flex-shrink:0;box-shadow:none} 641.cs-avatar-mini{border-radius:50%;font-size:9px;font-weight:800;color:#fff;display:flex;align-items:center;justify-content:center;flex-shrink:0} 642 643/* ââ Email render (Fremd-HTML · all:initial â bewusst harte Hex) ââ */ 644.cs-email-render{font-size:13px;color:#46574F;line-height:1.7;overflow-x:auto;all:initial;font-family:'Inter',-apple-system,BlinkMacSystemFont,system-ui,sans-serif;font-size:13px;color:#46574F;line-height:1.7;display:block;background:#FFFFFF;isolation:isolate} 645.cs-email-render *{max-width:100%!important} 646.cs-email-render img{max-width:100%!important;height:auto} 647.cs-email-render table{max-width:100%!important;border-collapse:collapse} 648.cs-email-render a{color:#0F7A57} 649.cs-email-text{font-size:13px;color:var(--ink-2);line-height:1.7} 650 651/* ââ Projekt-Zeilen (Haarlinien statt Karten) ââ */ 652.cs-project-card{display:flex;gap:12px;padding:11px 20px;border-bottom:1px solid var(--line);text-decoration:none;color:inherit;transition:background .12s;border-radius:0} 653.cs-project-card:last-child{border-bottom:none} 654.cs-project-card:hover{background:var(--panel-2)} 655.cs-project-cover{width:72px;height:52px;border-radius:8px;object-fit:cover;flex-shrink:0;background:var(--panel-2);border:1px solid var(--line)} 656.cs-project-info{flex:1;min-width:0} 657.cs-project-name{font-size:13px;font-weight:700;color:var(--ink);letter-spacing:-.008em} 658.cs-project-meta{display:flex;gap:8px;font-size:11px;color:var(--ink-3);margin-top:4px;flex-wrap:wrap} 659/* Status = schlichter Uppercase-Text, keine Pille */ 660.cs-project-status{padding:0;border:none;border-radius:0;background:transparent;font-weight:700;font-size:10px;letter-spacing:.13em;text-transform:uppercase;color:var(--ink-3)} 661.cs-project-desc{font-size:12px;color:var(--ink-3);margin-top:4px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden} 662 663/* ââ Projekt-Kacheln (Bauform 1:1 vom Content-Hub: .ch2-pgrid/.ch2-proj) ââ 664 Reine Optik. Die Farben kommen aus den .cs-root-Token, deshalb hell statt
665 dunkel. Einziger bewusster Unterschied: der Bildplatzhalter ist im Hub hart 666 #101a15 (dunkel) â hier var(--panel-2), sonst sitzt ein schwarzes Rechteck 667 in der hellen Flaeche. Die Ersatzkachel bekommt zusaetzlich eine Haarlinie, 668 weil sie sich hell sonst nicht vom Karteninneren abhebt. */ 669.cs-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(212px,1fr));gap:12px} 670.cs-pcard{display:flex;flex-direction:column;gap:7px;border:1px solid var(--line);border-radius:13px;background:var(--panel);padding:9px;text-decoration:none;color:inherit;transition:border-color .15s,transform .15s,background .15s} 671.cs-pcard:hover{border-color:var(--line-2);background:var(--panel-2);transform:translateY(-2px)} 672.cs-pcard-pic{width:100%;aspect-ratio:16/10;border-radius:9px;object-fit:cover;background:var(--panel-2);display:block} 673.cs-pcard-fb{display:grid;place-items:center;color:var(--ink-3);font-weight:800;font-size:18px;border:1px solid var(--line)} 674.cs-pcard-n{font-size:13px;font-weight:700;line-height:1.3;letter-spacing:-.008em;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden} 675.cs-pcard-i{font-size:10.5px;color:var(--ink-3);font-weight:500;font-variant-numeric:tabular-nums} 676.cs-pcard-d{font-size:12.5px;color:var(--ink-2);line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden} 677@media(max-width:768px){.cs-pgrid{gap:10px}} 678 679/* âââââââââââââââââââââââââââââââ 680 INBOX 681âââââââââââââââââââââââââââââââ */ 682.cs-main.cs-inbox{overflow:hidden;display:flex;flex-direction:column} 683.cs-inbox>*:not(.cs-inbox-split){flex-shrink:0} 684.cs-inbox>.cs-inbox-scroll{flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;scroll-snap-type:y proximity;position:relative} 685/* EIN Container, Kacheln durch Haarlinien getrennt (kein Karten-Stapel mit Luft) */ 686.cs-inbox-tiles{display:grid;grid-template-columns:repeat(4,1fr);gap:0;margin:20px 26px 16px;border:1px solid var(--line);border-radius:var(--r-card);overflow:hidden;background:var(--panel);flex-shrink:0;scroll-snap-align:start;scroll-snap-stop:normal} 687/* Zero-Height-Anker direkt vor den Inbox-Tabs: erzeugt den zweiten Snap-Punkt (Inbox-Dock), OHNE an einem sticky-Element zu hängen (sonst dockt es schon beim Laden an) */ 688.cs-inbox-dock-anchor{height:0;margin:0;padding:0;flex-shrink:0;scroll-snap-align:start} 689.cs-inbox-tile{display:flex;flex-direction:column;align-items:flex-start;gap:0;padding:14px 15px;background:transparent;border:none;border-right:1px solid var(--line);border-radius:0;cursor:pointer;font-family:inherit;text-align:left;position:relative;overflow:hidden;transition:background .12s} 690.cs-inbox-tile:last-child{border-right:none} 691/* Zugehörigkeit = 7px-Punkt (kein Farbstrich links) */ 692.cs-inbox-tile::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--tile-accent,var(--green));flex:none;margin-bottom:8px} 693.cs-inbox-tile:hover{background:var(--panel-2);box-shadow:none} 694.cs-inbox-tile-num{font-size:22px;font-weight:800;letter-spacing:-.032em;line-height:1.1;font-variant-numeric:tabular-nums} 695.cs-inbox-tile-label{font-size:12.5px;font-weight:700;color:var(--ink);margin-top:3px} 696.cs-inbox-tile-sub{font-size:11px;color:var(--ink-3)} 697@media (max-width:900px){.cs-inbox-tiles{grid-template-columns:repeat(2,1fr)}.cs-inbox-tile:nth-child(2n){border-right:none}.cs-inbox-tile:nth-child(-n+2){border-bottom:1px solid var(--line)}} 698.cs-inbox-tabs{display:flex;gap:6px;padding:0 26px;border-bottom:1px solid var(--line);background:var(--panel);flex-shrink:0;position:sticky;top:0;z-index:5;box-shadow:none} 699.cs-inbox-split{display:flex;overflow:hidden;height:calc(100% - 44px);min-height:0} 700.cs-inbox-list{flex:1;overflow-y:auto;border-right:1px solid var(--line);background:var(--panel)} 701.cs-inbox-list-sm{max-width:420px;min-width:420px} 702.cs-inbox-lead{display:inline-flex;align-items:center;gap:5px;font-size:11.5px;font-weight:600;color:var(--green);white-space:nowrap;max-width:150px;flex-shrink:0;cursor:pointer} 703.cs-inbox-lead img{width:13px;height:13px;border-radius:3px;flex-shrink:0} 704.cs-inbox-lead:hover .cs-inbox-lead-name{text-decoration:underline} 705.cs-inbox-lead-name{overflow:hidden;text-overflow:ellipsis;min-width:0} 706.cs-lead-hoverkarte{position:fixed;z-index:320;width:270px;background:var(--panel);border:1px solid var(--line);border-radius:13px;padding:13px 15px;box-shadow:0 14px 40px rgba(15,23,42,.16)} 707.cs-lhk-zeile{font-size:12px;color:var(--ink-2);margin-top:3px;display:flex;align-items:center;gap:6px} 708.cs-lhk-hint{font-size:10.5px;color:var(--ink-3);margin-top:8px} 709.cs-mail-atts{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px;padding-top:12px;border-top:1px solid var(--line)} 710.cs-mail-att{display:inline-flex;align-items:center;gap:7px;background:var(--panel-2);border:1px solid var(--line);border-radius:9px;padding:6px 11px;font-size:12px;font-weight:600;color:var(--ink-2);cursor:pointer;font-family:inherit;max-width:280px} 711.cs-mail-att:hover{border-color:var(--green);color:var(--ink)} 712.cs-mail-att-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0} 713.cs-mail-att-size{color:var(--ink-3);font-weight:500;flex-shrink:0} 714.cs-inbox-bulk{display:flex;align-items:center;gap:10px;padding:8px 20px;background:var(--green-soft);border-bottom:1px solid var(--green-bd)} 715.cs-inbox-bulk-count{font-size:12px;font-weight:700;color:var(--green);font-variant-numeric:tabular-nums} 716.cs-inbox-user-select{display:flex;align-items:center;gap:6px;padding:5px 8px;border-radius:8px;border:1px solid var(--line);background:var(--panel)} 717.cs-inbox-check{width:14px;
717height:14px;border-radius:6px;cursor:pointer;accent-color:var(--green);flex-shrink:0} 718.cs-inbox-row{display:flex;align-items:center;gap:10px;padding:11px 20px;border-bottom:1px solid var(--line);cursor:pointer;transition:background .12s} 719.cs-inbox-row:last-child{border-bottom:none} 720.cs-inbox-row:hover{background:var(--panel-2)} 721.cs-inbox-selected{background:var(--sel)!important} 722.cs-unread .cs-inbox-from{font-weight:700;color:var(--ink)} 723.cs-unread .cs-inbox-subject{font-weight:600;color:var(--ink)} 724.cs-unread-dot{width:7px;height:7px;border-radius:50%;background:var(--green);flex-shrink:0;box-shadow:none} 725.cs-inbox-favicon{width:18px;height:18px;border-radius:6px;flex-shrink:0;object-fit:contain;border:1px solid var(--line)} 726.cs-inbox-row-body{flex:1;min-width:0;display:flex;flex-direction:column;align-items:stretch;gap:2px} 727.cs-inbox-row-top{display:flex;align-items:center;gap:8px;min-width:0} 728.cs-inbox-snippet{font-size:11.5px;color:var(--ink-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} 729.cs-inbox-from{font-size:12.5px;color:var(--ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:0;max-width:180px} 730.cs-inbox-subject{font-size:12px;color:var(--ink-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0} 731.cs-inbox-date{font-size:11px;color:var(--ink-3);flex-shrink:0;font-weight:600;font-variant-numeric:tabular-nums} 732.cs-inbox-detail{flex:1;display:flex;flex-direction:column;background:var(--bg);height:100%} 733.cs-inbox-detail-head{padding:15px 24px;border-bottom:1px solid var(--line);background:var(--panel);flex-shrink:0} 734.cs-inbox-detail-subject{font-size:15px;font-weight:800;color:var(--ink);letter-spacing:-0.016em} 735.cs-inbox-detail-meta{font-size:12px;color:var(--ink-3);margin-top:4px} 736.cs-inbox-detail-body{flex:1;padding:20px 24px;overflow-y:auto;min-height:0} 737 738/* âââââââââââââââââââââââââââââââ 739 KANBAN PIPELINE 740âââââââââââââââââââââââââââââââ */ 741.cs-pipeline{display:flex;flex-direction:column} 742.cs-kanban{display:flex;gap:12px;flex:1;overflow-x:auto;padding:20px 26px 40px} 743.cs-kanban-col{ 744 min-width:240px;width:240px;flex-shrink:0; 745 background:var(--panel);border:1px solid var(--line);border-radius:var(--r-card); 746 display:flex;flex-direction:column;max-height:calc(100vh - 140px);overflow:hidden; 747 box-shadow:none; 748} 749/* Eyebrow */ 750.cs-kanban-head{ 751 display:flex;align-items:center;gap:8px;padding:11px 14px; 752 font-size:10px;font-weight:700;color:var(--ink-3);text-transform:uppercase; 753 letter-spacing:.13em;border-bottom:1px solid var(--line); 754} 755.cs-kanban-body{flex:1;overflow-y:auto;padding:0;display:flex;flex-direction:column;gap:0} 756/* Zeilen statt Einzelkarten */ 757.cs-kanban-card{ 758 padding:10px 14px;border-radius:0;background:transparent;border:none;border-bottom:1px solid var(--line); 759 transition:background .12s;cursor:pointer; 760} 761.cs-kanban-card:last-child{border-bottom:none} 762.cs-kanban-card:hover{background:var(--panel-2);border-color:var(--line);box-shadow:none} 763.cs-kanban-card-name{font-size:13px;font-weight:700;color:var(--ink);letter-spacing:-.008em} 764.cs-kanban-card-val{font-size:12px;color:var(--gold-text);font-weight:700;margin-top:4px;font-variant-numeric:tabular-nums} 765.cs-kanban-card-conf{display:flex;align-items:center;gap:6px;font-size:10px;color:var(--ink-3);margin-top:4px;font-variant-numeric:tabular-nums} 766.cs-conf-bar{flex:1;height:3px;border-radius:6px;background:var(--bg-2);overflow:hidden} 767.cs-conf-fill{height:100%;border-radius:6px} 768 769/* âââââââââââââââââââââââââââââââ 770 TASKS â EIN Container, Haarlinien-Zeilen 771âââââââââââââââââââââââââââââââ */ 772.cs-task-list{margin:20px 26px 40px;padding:0;border:1px solid var(--line);border-radius:var(--r-card);overflow:hidden;background:var(--panel)}
773.cs-task{display:flex;align-items:center;gap:12px;padding:10px 15px;border-bottom:1px solid var(--line);border-radius:0;cursor:pointer;transition:background .12s} 774.cs-task:last-child{border-bottom:none} 775.cs-task-done{opacity:.45}.cs-task-done .cs-task-text{text-decoration:line-through} 776.cs-check{ 777 width:20px;height:20px;border-radius:50%;border:1px solid var(--line-2); 778 background:none;color:var(--green);font-size:12px;cursor:pointer; 779 display:flex;align-items:center;justify-content:center;flex-shrink:0; 780 transition:border-color .14s,background .14s; 781} 782.cs-check:hover{border-color:var(--green)} 783.cs-checked{background:var(--green-soft);border-color:var(--green-bd)} 784.cs-task:hover{background:var(--panel-2)} 785.cs-task-selected{background:var(--sel)} 786.cs-task-selected:hover{background:var(--sel)} 787.cs-task-text{font-size:12.5px;color:var(--ink)} 788.cs-task-actionbar{display:flex;align-items:center;gap:12px;padding:10px 26px;background:var(--green-soft);border-bottom:1px solid var(--green-bd);position:sticky;top:0;z-index:5} 789.cs-task-selcount{font-size:12.5px;font-weight:700;color:var(--green);font-variant-numeric:tabular-nums} 790/* Rang b: Grün-Aktion */ 791.cs-task-selectall{background:var(--green-soft);border:1px solid var(--green-bd);color:var(--green);font-size:12px;font-weight:700;padding:6px 12px;border-radius:8px;cursor:pointer;font-family:inherit;transition:background .14s} 792.cs-task-selectall:hover{background:var(--sel);color:var(--green)} 793.cs-add-task{display:flex;gap:8px;padding:14px 26px;border-bottom:1px solid var(--line);align-items:center;background:var(--panel)} 794.cs-add-task .cs-input{flex:1} 795 796/* âââââââââââââââââââââââââââââââ 797 DASHBOARD â Kennzahlenleiste statt Kartenstapel 798âââââââââââââââââââââââââââââââ */ 799.cs-stats-row{display:grid;grid-template-columns:repeat(4,1fr);gap:0;margin:20px 26px 0;border:1px solid var(--line);border-radius:var(--r-card);overflow:hidden;background:var(--panel);padding:0} 800.cs-stat{ 801 padding:15px 16px;border-radius:0;background:transparent;border:none;border-right:1px solid var(--line); 802 box-shadow:none;transition:background .12s; 803} 804.cs-stat:last-child{border-right:none} 805.cs-stat:hover{background:var(--panel-2);box-shadow:none} 806.cs-stat-num{font-size:22px;font-weight:800;color:var(--ink);letter-spacing:-0.032em;font-variant-numeric:tabular-nums} 807.cs-stat-label{font-size:10px;color:var(--ink-3);margin-top:6px;font-weight:700;letter-spacing:.13em;text-transform:uppercase} 808.cs-sub-title{font-size:15px;font-weight:800;color:var(--ink);padding:24px 26px 12px;letter-spacing:-0.016em} 809.cs-bars{padding:0 26px 40px} 810.cs-bar-row{display:flex;align-items:center;gap:12px;margin-bottom:8px} 811.cs-bar-label{width:170px;font-size:12px;color:var(--ink-2);display:flex;align-items:center;gap:6px;flex-shrink:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:600} 812.cs-bar-track{flex:1;height:8px;border-radius:6px;background:var(--bg-2);overflow:hidden} 813.cs-bar-fill{height:100%;border-radius:6px;min-width:3px;transition:width .6s cubic-bezier(.4,0,.2,1)} 814.cs-bar-num{width:32px;font-size:12px;color:var(--ink-2);text-align:right;font-weight:700;font-variant-numeric:tabular-nums} 815 816/* âââââââââââââââââââââââââââââââ 817 FILES â Haarlinien-Zeilen 818âââââââââââââââââââââââââââââââ */ 819.cs-files-list{padding:0} 820.cs-file-item{display:flex;align-items:center;gap:12px;padding:10px 20px;border-bottom:1px solid var(--line);transition:background .12s;cursor:pointer} 821.cs-file-item:last-child{border-bottom:none} 822.cs-file-item:hover{background:var(--panel-2)} 823.cs-file-icon{width:36px;height:36px;border-radius:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0;border:1px solid var(--line)} 824.cs-file-info{flex:1;min-width:0} 825.cs-file-name{font-size:13px;font-weight:700;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.008em} 826.cs-file-meta{font-size:11px;color:var(--ink-3);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:flex;align-items:center;gap:6px;font-variant-numeric:tabular-nums} 827/* EDITABLE FIELDS */ 828.cs-editable{cursor:pointer;padding:2px 4px;border-radius:6px;transition:background .14s;min-width:40px;
828display:inline-block} 829.cs-editable:hover{background:var(--panel-2)} 830.cs-editable-empty{color:var(--ink-3);font-style:italic} 831.cs-editable-input{width:100%;padding:4px 6px;border-radius:6px;border:1px solid var(--green);background:var(--panel);color:var(--ink);font-size:inherit;font-family:inherit;outline:none;box-shadow:none} 832.cs-editable-textarea{resize:vertical;min-height:60px} 833 834/* Datei-Endung = schlichter Uppercase-Text, keine Pille */ 835.cs-file-ext{padding:0;border:none;border-radius:0;background:transparent;font-size:10px;font-weight:700;letter-spacing:.13em;color:var(--ink-3);text-transform:uppercase} 836 837/* TAB PLACEHOLDERS */ 838.cs-tab-placeholder{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:60px 24px;text-align:center} 839.cs-tab-placeholder-icon{margin-bottom:16px;opacity:.5} 840.cs-tab-placeholder-title{font-size:15px;font-weight:800;color:var(--ink);margin-bottom:8px;letter-spacing:-.016em} 841.cs-tab-placeholder-desc{font-size:12.5px;color:var(--ink-3);max-width:400px;line-height:1.6} 842 843/* CI TAB */ 844.cs-ci-section{} 845.cs-ci-title{font-size:15px;font-weight:800;color:var(--ink);margin-bottom:12px;letter-spacing:-.016em} 846/* EIN Container, Zellen durch Haarlinien getrennt */ 847.cs-ci-grid{display:grid;grid-template-columns:1fr 1fr;gap:0;border:1px solid var(--line);border-radius:var(--r-card);overflow:hidden;background:var(--panel)} 848.cs-ci-card{padding:14px 15px;background:transparent;border:none;border-right:1px solid var(--line);border-bottom:1px solid var(--line);border-radius:0} 849.cs-ci-card:nth-child(2n){border-right:none} 850/* Eyebrow */ 851.cs-ci-card-title{font-size:10px;font-weight:700;color:var(--ink-3);text-transform:uppercase;letter-spacing:.13em;margin-bottom:6px} 852.cs-ci-card-value{font-size:12.5px;color:var(--ink)} 853.cs-ci-preview{margin-top:16px} 854.cs-ci-iframe-wrap{border:1px solid var(--line);border-radius:var(--r-card);overflow:hidden;background:var(--panel-2)} 855.cs-ci-screenshot{width:100%;height:auto;display:block} 856.cs-social-embed{border:1px solid var(--line);border-radius:var(--r-card);overflow:hidden;background:var(--panel)} 857 858/* ANALYTICS TAB */ 859.cs-analytics-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:0;border:1px solid var(--line);border-radius:var(--r-card);overflow:hidden;background:var(--panel)} 860.cs-analytics-card{padding:15px 16px;background:transparent;border:none;border-right:1px solid var(--line);border-radius:0;text-align:center} 861.cs-analytics-card:last-child{border-right:none} 862/* Zwei-Spalten-Variante (Lead-Analytics, schmales Panel): Haarlinien in beide Richtungen */ 863.cs-analytics-grid--2{grid-template-columns:1fr 1fr} 864.cs-analytics-grid--2 .cs-analytics-card{border-right:1px solid var(--line);border-bottom:1px solid var(--line)} 865.cs-analytics-grid--2 .cs-analytics-card:nth-child(2n){border-right:none} 866.cs-analytics-grid--2 .cs-analytics-card:last-child{border-bottom:none} 867.cs-analytics-grid--2 .cs-analytics-card:nth-last-child(2):nth-child(2n+1){border-bottom:none} 868.cs-analytics-grid--2 .cs-analytics-card:last-child:nth-child(odd){grid-column:1 / -1;border-right:none} 869.cs-analytics-num{font-size:22px;font-weight:800;color:var(--ink);letter-spacing:-.032em;font-variant-numeric:tabular-nums} 870.cs-analytics-label{font-size:10px;color:var(--ink-3);margin-top:6px;font-weight:700;letter-spacing:.13em;text-transform:uppercase} 871.cs-analytics-rows{display:flex;flex-direction:column} 872.cs-analytics-row{display:flex;justify-content:space-between;padding:9px 0;font-size:12.5px;color:var(--ink-2);border-bottom:1px solid var(--line)} 873.cs-analytics-row:last-child{border-bottom:none} 874.cs-analytics-val{color:var(--ink);font-weight:700;font-variant-numeric:tabular-nums} 875 876/* âââââââââââââââââââââââââââââââ 877 MODAL â Schatten nur hier (Popover) 878âââââââââââââââââââââââââââââââ */ 879.cs-modal-overlay{position:fixed;inset:0;z-index:1000;background:rgba(16,32,23,.28);display:flex;align-items:center;justify-content:center;backdrop-filter:blur(3px)} 880.cs-modal{background:var(--panel);border:1px solid var(--line);border-radius:var(--r-card-lg);width:90%;max-width:560px;box-shadow:var(--shadow-pop);overflow:hidden;animation:csModalIn .25s cubic-bezier(.4,0,.2,1)} 881@keyframes csModalIn{from{opacity:0;transform:scale(.98) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}} 882.cs-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 22px;border-bottom:1px solid var(--line)} 883.cs-modal-title{font-size:15px;font-weight:800;color:var(--ink);letter-spacing:-0.016em} 884/* Icon-Knopf (Rang d) */ 885.cs-modal-close{background:none;border:1px solid transparent;font-size:15px;color:var(--ink-3);cursor:pointer;width:26px;height:26px;border-radius:8px;transition:border-color .14s,color .14s;display:flex;align-items:center;justify-content:center}
886.cs-modal-close:hover{color:var(--ink);border-color:var(--line);background:var(--panel-2)} 887.cs-modal-body{padding:22px} 888.cs-modal-file-info{display:flex;flex-direction:column;gap:10px} 889.cs-modal-file-row{display:flex;gap:8px;font-size:12.5px} 890.cs-modal-file-label{color:var(--ink-3);min-width:110px;flex-shrink:0;font-weight:600} 891.cs-modal-file-note{margin-top:20px;padding:14px 16px;background:var(--panel-2);border-radius:var(--r-card);font-size:12px;color:var(--ink-2);line-height:1.6;border:1px solid var(--line)} 892 893/* âââââââââââââââââââââââââââââââ 894 MOBILE 895âââââââââââââââââââââââââââââââ */ 896@media(max-width:768px){ 897 .cs-sidebar{width:56px;min-width:56px} 898 .cs-sidebar span,.cs-sidebar .cs-sv-section,.cs-sidebar .cs-sidebar-org, 899 .cs-sidebar .cs-sidebar-name,.cs-sidebar .cs-collapse-label, 900 .cs-sidebar .cs-sidebar-search,.cs-sidebar .cs-nav-plus{display:none} 901 /* Einstellungen bleibt auch mobil erreichbar (nur das Zahnrad) */ 902 .cs-sidebar .cs-sidebar-bottom{margin-top:auto} 903 /* Mobil hat die span-Hide-Regel oben KEINE Ausnahme für die Nav-Icons (anders als im 904 eingeklappten Zustand) â die Icons stecken in <span class="cs-nav-icon">, waren also 905 schmal alle unsichtbar. Seit der FuÃbereich auch mobil steht, wäre âWorkflows" sonst 906 eine leere anklickbare Zeile. Gleiche Ausnahme wie bei [data-collapsed]. */ 907 .cs-sidebar .cs-nav-icon{display:inline-flex !important;align-items:center;justify-content:center} 908 .cs-detail-body{flex-direction:column} 909 .cs-detail-left{width:100%;min-width:100%;max-height:none;border-right:none;border-bottom:1px solid var(--line);overflow-y:visible} 910 .cs-detail-right{min-height:50vh} 911 .cs-inbox-list-sm{max-width:100%;min-width:100%} 912 .cs-inbox-split{flex-direction:column} 913 .cs-inbox-detail{min-height:60vh} 914 .cs-stats-row{grid-template-columns:repeat(2,1fr);margin:16px} 915 .cs-stat:nth-child(2n){border-right:none} 916 .cs-stat:nth-child(-n+2){border-bottom:1px solid var(--line)} 917 .cs-inbox-tiles{margin:16px} 918 .cs-page-header{padding:12px 16px;gap:8px} 919 .cs-page-title{font-size:18px} 920 .cs-detail-topbar{padding:10px 12px;gap:8px} 921 .cs-detail-name{font-size:16px} 922 .cs-detail-actions{flex-wrap:wrap;gap:6px} 923 .cs-action-btn{padding:6px 10px;font-size:11.5px} 924 .cs-detail-logo{width:36px;height:36px;border-radius:8px} 925 .cs-left-tabs{padding:0 12px} 926 .cs-left-tab{padding:9px 10px;font-size:12px} 927 .cs-timeline-tabs{padding:0 12px;overflow-x:auto;flex-wrap:nowrap} 928 .cs-tab{padding:9px 10px;font-size:12px;white-space:nowrap} 929 .cs-kanban{padding:16px 12px}
930 .cs-kanban-col{min-width:200px;width:200px} 931 .cs-task-list{margin:16px} 932 .cs-table td{padding:8px 10px;font-size:12px} 933 .cs-table th{padding:6px 10px;font-size:10px} 934 .cs-analytics-grid{grid-template-columns:1fr 1fr} 935 .cs-analytics-card:nth-child(2n){border-right:none} 936 .cs-analytics-num{font-size:20px} 937 .cs-ci-grid{grid-template-columns:1fr} 938 .cs-ci-card{border-right:none} 939 .cs-compose-bar{padding:12px 16px} 940 .cs-tl-email-body{margin-left:30px} 941 .cs-about-row{padding:6px 12px 6px 30px} 942 .cs-cf-row{padding:7px 12px 7px 30px} 943 .cs-section-head{padding:10px 12px} 944 .cs-section-info{padding:6px 12px 6px 30px} 945 .cs-contact-card{padding:6px 8px 6px 16px} 946 .cs-task-inline{padding:6px 12px 6px 30px} 947 .cs-opp-item{padding:8px 12px 8px 30px} 948} 949 `})}export{Ec 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.