PageSourceSearch

https://www.adspector.ai/assets/Advisor-BYlb32v3.js

js adspector.ai collected 2026-10-05 11:47:31 UTC 286,097 bytes, 42 lines download raw bytes

1import{c as pt,j as e,m as xe,S as lr,a4 as ks,r as o,w as Or,s as Je,X as Ee,A as vn,C as De,T as ur,L as Ss,a3 as Er,a9 as te,E as yn,y as na,W as fn,a5 as xr,n as ia,G as Mr,B as as,F as fa,Q as Sa,b as Cs,Z as ja,O as qt,aQ as ss,aB as kt,K as jn}from"./index-D9gYj5Lf.js";import{n as Xt,M as or}from"./normalize-markdown-q4BYfmND.js";import{l as cr}from"./_shared-wjF0Rqaq.js";import{Z as Nn}from"./react-to-print-BXTZ7cxm.js";import{c as An,o as wn,s as kn}from"./memory-completion-D4qfOMhv.js";import{A as Sn,r as Cn,a as ns,e as is,m as ls,p as Tr,P as Na}from"./ActionProposalCard-CbkApZ5-.js";import{y as En}from"./youtubeService-C42gldGZ.js";import{A as Tn}from"./AccountSelector-BqAkwMW2.js";import{C as la}from"./chevron-up-BzGbjIms.js";import{D as Ln}from"./download-D-3fxozS.js";import{A as Dn}from"./arrow-up-down-Ch8QDjl2.js";import{C as In}from"./chevron-left-DqtjIYev.js";import{T as Es}from"./trash-2-LjBJEonT.js";import{O as Pn}from"./OnboardingGoals-DVWXn2CK.js";import{c as oa}from"./crmService-Cj0ldV0V.js";import{S as zr}from"./search-pmMuQDrJ.js";import{L as Ae}from"./loader-circle-BpLFCn2t.js";import{R as St}from"./rocket-Ca5wFcf4.js";import{S as xt}from"./shopping-cart-CG7R3LYT.js";import{S as Ca}from"./square-CMep68bc.js";import{M as Qt,r as $t}from"./index-C8FoKt4n.js";import{L as Gn,a as On}from"./LanguageTargetPicker-kHq4xHcQ.js";import{l as Rn,f as Mn,s as _n,w as zn}from"./scale_landing_page_cro-CjHbt3M2.js";import{C as _r}from"./circle-x-p5bgWbUv.js";import{P as Ke}from"./plus-B9AwHGyc.js";import{U as ca}from"./upload-LTE5JDLg.js";import{S as Fn}from"./send-Dh3midDU.js";import{L as os}from"./languages-DJSfXaeL.js";import{E as Un}from"./ellipsis-BXqMTWJs.js";import{H as Bn}from"./history-hXGKeQ4H.js";import{P as Ts}from"./pen-line-C9swQa5Z.js";import{I as mt}from"./image-IooXcp3H.js";import{E as Hn}from"./eye-MY7gl6u9.js";import{S as Aa}from"./settings-2-Bzpa2xuR.js";import{L as Vn}from"./link-Ci-gCWvQ.js";import{M as wa}from"./message-square-B37JiD9Z.js";import{C as Ea}from"./copy-4FBuYf0p.js";import{C as cs}from"./chevron-right-CSzzwyOZ.js";import{M as ds}from"./map-pin-BdTsmcxe.js";import{E as Lr}from"./external-link-BpDbL5ln.js";import"./format-ChUrbpUI.js";import"./bell-Dz-BwfhV.js";import"./images-CWMfafpZ.js";import"./link-2-eZgICIOn.js";import"./shield-alert-JG1GmSBy.js";import"./package-x-D7Po33xC.js";import"./trending-down-0w8MyXch.js";import"./info-1MosHQAW.js";import"./pencil-uqFkwdiZ.js";import"./wand-sparkles-DRECaw4m.js";import"./building-2-DMnBgdFY.js";import"./BrandKeywordChips-YTcoFwyH.js";import"./form-kit-TE3OpAeQ.js";import"./loader-CvQIZ5gl.js";import"./store-hP5dqVQB.js";import"./scale-BZmrcBcq.js";const Yn=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],da=pt("cloud",Yn);const Kn=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Ta=pt("file-code",Kn);const Wn=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],Zn=pt("file-down",Wn);const Jn=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Dr=pt("library",Jn);const qn=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],Xn=pt("mic",qn);const Qn=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Ls=pt("star",Qn);const $n=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],ei=pt("table-2",$n);const ti=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ua=pt("video",ti);function xa({prompt:a,art:i,Icon:m=lr,onClick:h,dataTour:p}){return e.jsxs(xe.button,{whileHover:{y:-3},transition:{duration:.15},onClick:()=>h(a),...p?{"data-tour":p}:{},className:"group w-full text-left rounded-2xl border border-[var(--border-subtle)] bg-[var(--bg-elevated)] overflow-hidden shadow-[var(--shadow-card)] hover:shadow-[var(--shadow-elevated)] hover:border-[var(--border-medium)] transition-all",children:[e.jsx("div",{className:"aspect-[16/10] w-full overflow-hidden",style:{background:"#EAF4F9"},children:i?e.jsx("img",{src:i,alt:"",loading:"lazy",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(m,{size:40,className:"text-[#2E7A9C]/60"})})}),e.jsxs("div",{className:"p-4",children:[e.jsx("div",{className:"text-sm font-semibold text-[var(--text-primary)] mb-1",children:a.label}),e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] leading-relaxed line-clamp-2",children:a.description})]})]})}const us=50;function ri(a,i){const m={minimumFractionDigits:2,maximumFractionDigits:2},h=typeof i=="string"?i.toUpperCase():i;
1if(h===void 0||h==="EUR")return`€${Number(a).toLocaleString("de-DE",m)}`;if(h===null||!/^[A-Z]{3}$/.test(h))return Number(a).toLocaleString("de-DE",m);try{return new Intl.NumberFormat("de-DE",{style:"currency",currency:h,...m}).format(Number(a))}catch{return`${h} ${Number(a).toLocaleString("de-DE",m)}`}}function ai(a,i,m,h){if(a==null||a==="")return"—";const p=m?"≥":"";return i==="eur"?`${p}${ri(a,h)}`:i==="num"?`${p}${Number(a).toLocaleString("de-DE",{maximumFractionDigits:2})}`:String(a)}function si(a,i){const m=/^(?:spend|conv)_(\d+d)$/.exec(a);return m?!!i[`_incomplete_${m[1]}`]:!1}function ni(a,i){const m=A=>{const f=A==null?"":String(A);return/[",\n]/.test(f)?`"${f.replace(/"/g,'""')}"`:f},h=a.map(A=>m(A.label)).join(","),p=i.map(A=>a.map(f=>m(A[f.key])).join(",")).join(`
2`);return`${h}
3${p}`}function ii(a,i){const m=new Blob(["\uFEFF"+i],{type:"text/csv;charset=utf-8;"}),h=URL.createObjectURL(m),p=document.createElement("a");p.href=h,p.download=a,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(h)}function li({table:a}){const{theme:i}=ks(),m=i==="light",[h,p]=o.useState(!1),[A,f]=o.useState(!1),[n,M]=o.useState(null),[w,T]=o.useState("desc"),v=a.columns||[],U=a.rows||[],_=o.useMemo(()=>{if(!n)return U;const j=w==="asc"?1:-1;return[...U].sort((K,ce)=>{const Q=K[n],pe=ce[n];return Q==null&&pe==null?0:Q==null?1:pe==null?-1:typeof Q=="number"&&typeof pe
3=="number"?(Q-pe)*j:String(Q).localeCompare(String(pe))*j})},[U,n,w]),ne=A?_:_.slice(0,us),y=a.meta?.matchedRows??U.length,B=_.length>us,q=j=>{n===j?T(K=>K==="asc"?"desc":"asc"):(M(j),T("desc"))},F=()=>{const j=(a.title||"search-terms").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase().slice(0,60);ii(`${j||"export"}.csv`,ni(v,_))},R=m?"border-gray-200":"border-white/10",J=m?"bg-gray-50":"bg-white/5",$=m?"border-gray-100":"border-white/5",P=m?"text-gray-500":"text-white/50",G=m?"text-gray-800":"text-white/90";return e.jsxs("div",{className:`rounded-xl border ${R} overflow-hidden`,children:[e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>p(j=>!j),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),p(K=>!K))},className:`flex items-center justify-between gap-3 px-4 py-2.5 ${J} ${h?`border-b ${R}`:""} cursor-pointer select-none`,title:h?"Collapse table":"Expand table",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ei,{size:15,className:"text-[#3E9BC3] shrink-0"}),e.jsx("span",{className:`text-sm font-medium truncate ${G}`,children:a.title||"Results"}),e.jsxs("span",{className:`text-xs ${P} shrink-0`,children:[y.toLocaleString("de-DE")," rows",y>U.length?` (top ${U.length} shown)`:""]}),h?e.jsx(la,{size:14,className:`${P} shrink-0`}):e.jsx(Or,{size:14,className:`${P} shrink-0`})]}),e.jsxs("button",{onClick:j=>{j.stopPropagation(),F()},className:"flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-lg bg-[#3E9BC3] text-white hover:bg-[#2E7A9C] transition-colors shrink-0",title:"Export all rows as CSV",children:[e.jsx(Ln,{size:13})," CSV"]})]}),h&&e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs border-collapse",children:[e.jsx("thead",{children:e.jsx("tr",{className:`${J} ${P}`,children:v.map(j=>e.jsx("th",{onClick:()=>q(j.key),className:`text-left font-medium px-3 py-2 whitespace-nowrap cursor-pointer select-none ${j.type?"text-right":""}`,children:e.jsxs("span",{className:`inline-flex items-center gap-1 ${j.type?"flex-row-reverse":""}`,children:[j.label,n===j.key?w==="asc"?e.jsx(la,{size:11}):e.jsx(Or,{size:11}):e.jsx(Dn,{size:10,className:"opacity-30"})]})},j.key))})}),e.jsx("tbody",{children:ne.map((j,K)=>e.jsx("tr",{className:`border-t ${$}`,children:v.map(ce=>e.jsx("td",{className:`px-3 py-1.5 whitespace-nowrap ${ce.type?`text-right tabular-nums ${G}`:P}`,children:ce.type?ai(j[ce.key],ce.type,si(ce.key,j),a.currency):j[ce.key]||"—"},ce.key))},K))})]})}),h&&B&&e.jsx("button",{onClick:()=>f(j=>!j),className:`w-full text-xs font-medium py-2 border-t ${R} ${P} hover:${G} transition-colors flex items-center justify-center gap-1`,children:A?e.jsxs(e.Fragment,{children:["Show fewer ",e.jsx(la,{size:12})]}):e.jsxs(e.Fragment,{children:["Show all ",_.length.toLocaleString("de-DE")," rows ",e.jsx(Or,{size:12})]})})]})}function oi({tables:a}){return!Array.isArray(a)||a.length===0?null:e.jsx("div",{className:"mt-3 space-y-3",children:a.map((i,m)=>e.jsx(li,{table:i},m))})}function ci({tile:a,language:i,onSend:m,onClose:h}){const[p,A]=o.useState(0),[f,n]=o.useState({}),M=a?.params||[],w=M[p],T=p===M.length-1,v=i==="de",U=o.useRef(null);o.useEffect(()=>{const F=R=>{R.key==="Escape"&&h()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[h]);const _=F=>{U.current&&!U.current.contains(F.target)&&h()},ne=F=>{const R={...f,[w.key]:F};n(R),T?q(R):A(p+1)},y=()=>{const F=f[w.key]||w.default||"0",R={...f,[w.key]:F};n(R),T?q(R):A(p+1)},B=()=>{const F=`${w.key}_start`,R=`${w.key}_end`;!f[F]||!f[R]||(T?q(f):A(p+1))},q=F=>{let R=a.message;for(const[$,P]of Object.entries(F))R=R.replace(new RegExp(`\\{\\{${$}\\}\\}`,"g"),P);const J=parseFloat(F.min_spend||"0");if(J>0){const $=v?` Zeige nur Begriffe mit mindestens €${J.toFixed(2)} Ausgaben.`:` Only show terms with at least €${J.toFixed(2)} spend.`;R=R.replace(/\{\{min_spend_clause\}\}/g,$)}else R=R.replace(/\{\{min_spend_clause\}\}/g,"");R=R.replace(/\{\{[^}]+\}\}/g,"").trim(),m(R,a.id,F)};return!a||!w?null:e.jsx(Je,{children:e.jsx(xe.div,{initial:{opacity:0}
3,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center bg-[var(--bg-backdrop)] backdrop-blur-sm",onClick:_,children:e.jsxs(xe.div,{ref:U,"data-tour":"advisor-timeframe-modal",initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{duration:.2},className:"w-full max-w-md mx-4 bg-[var(--dropdown-bg)] border border-[var(--border-subtle)] rounded-2xl shadow-2xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[p>0&&e.jsx("button",{onClick:()=>A(p-1),className:"p-1 rounded-lg hover:bg-[var(--bg-overlay)] transition text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]",children:e.jsx(In,{size:18})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-[var(--text-primary)]",children:a.label}),M.length>1&&e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)] mt-0.5",children:v?`Schritt ${p+1} von ${M.length}`:`Step ${p+1} of ${M.length}`})]})]}),e.jsx("button",{onClick:h,className:"p-1.5 rounded-lg hover:bg-[var(--bg-overlay)] transition text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]",children:e.jsx(Ee,{size:16})})]}),e.jsxs("div",{className:"px-5 pb-5",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-4",children:w.label}),w.type==="select"&&e.jsx("div",{className:"space-y-2",children:w.options.map((F,R)=>e.jsxs("button",{onClick:()=>ne(F.value),className:"w-full flex items-center justify-between px-4 py-3 rounded-xl border border-[var(--border-subtle)] hover:border-[var(--border-medium)] hover:bg-[var(--bg-overlay)] text-left transition-all group",children:[e.jsx("span",{className:"text-sm text-[var(--text-secondary)] group-hover:text-[var(--text-primary)]",children:F.label}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)] font-mono",children:R+1}),e.jsx(vn,{size:14,className:"text-[var(--text-tertiary)] group-hover:text-[var(--text-tertiary)] transition"})]})]},F.value))}),w.type==="currency"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-[var(--text-tertiary)]",children:"€"}),e.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:w.placeholder||"0.00",value:f[w.key]||"",onChange:F=>n({...f,[w.key]:F.target.value}),onKeyDown:F=>{F.key==="Enter"&&y()},className:"w-full pl-8 pr-4 py-3 rounded-xl border border-[var(--border-subtle)] bg-[var(--bg-overlay)] text-sm text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:border-[var(--border-medium)] focus:outline-none transition",autoFocus:!0})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)]",children:v?"Leer lassen für alle":"Leave empty for all"}),e.jsx("button",{onClick:y,className:"px-4 py-2 rounded-xl bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay-heavy)] text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition",children:T?v?"Analyse starten":"Start Analysis":v?"Weiter":"Next"})]})]}),w.type==="number"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"number",step:w.step??"1",min:w.min??0,max:w.max??void 0,placeholder:w.placeholder||(w.default!=null?String(w.default):""),value:f[w.key]??"",onChange:F=>n({...f,[w.key]:F.target.value}),onKeyDown:F=>{if(F.key==="Enter"){const R=f[w.key],J=R===""||R==null?w.default!=null?String(w.default):"":String(R),$={...f,[w.key]:J};T?q($):(n($),A(p+1))}},className:"w-full px-4 py-3 rounded-xl border border-[var(--border-subtle)] bg-[var(--bg-overlay)] text-sm text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:border-[var(--border-medium)] focus:outline-none transition",autoFocus:!0}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)]",children:w.default!=null?v?`Leer = Standard (${w.default})`:`Empty = default (${w.default})`:""}),e.jsx("button",{onClick:()=>{const F=f[w.key],R=F===""||F==null?w.default!=null?String(w.default):"":String(F),J={...f,[w.key]:R};T?q(J):(n(J),A(p+1))},className:"px-4 py-2 rounded-xl bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay-heavy)] text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition",children:T?v?"Analyse starten":"Start Analysis":v?"Weiter":"Next"})]})]}),w.type==="text"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"text",placeholder:w.placeholder||"",value:f[w.key]||"",onChange:F=>n({...f,[w.key]:F.target.value}),onKeyDown:F=>{F.key==="Enter"&&f[w.key]?.trim()&&(T?q(f):A(p+1))},className:"w-full px-4 py-3 rounded-xl border border-[var(--border-subtle)] bg-[var(--bg-overlay)] text-sm text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:border-[var(--border-medium)] focu
3s:outline-none transition",autoFocus:!0}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:()=>{f[w.key]?.trim()&&(T?q(f):A(p+1))},disabled:!f[w.key]?.trim(),className:"px-4 py-2 rounded-xl bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay-heavy)] text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition disabled:opacity-40 disabled:cursor-not-allowed",children:T?v?"Analyse starten":"Start Analysis":v?"Weiter":"Next"})})]}),w.type==="daterange"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] text-[var(--text-tertiary)] mb-1",children:"Start"}),e.jsx("input",{type:"date",value:f[`${w.key}_start`]||"",onChange:F=>n({...f,[`${w.key}_start`]:F.target.value}),className:"w-full px-3 py-2.5 rounded-xl border border-[var(--border-subtle)] bg-[var(--bg-overlay)] text-sm text-[var(--text-primary)] focus:border-[var(--border-medium)] focus:outline-none transition"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] text-[var(--text-tertiary)] mb-1",children:v?"Ende":"End"}),e.jsx("input",{type:"date",value:f[`${w.key}_end`]||"",onChange:F=>n({...f,[`${w.key}_end`]:F.target.value}),className:"w-full px-3 py-2.5 rounded-xl border border-[var(--border-subtle)] bg-[var(--bg-overlay)] text-sm text-[var(--text-primary)] focus:border-[var(--border-medium)] focus:outline-none transition"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:B,disabled:!f[`${w.key}_start`]||!f[`${w.key}_end`],className:"px-4 py-2 rounded-xl bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay-heavy)] text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition disabled:opacity-30 disabled:cursor-not-allowed",children:T?v?"Analyse starten":"Start Analysis":v?"Weiter":"Next"})})]})]})]})})})}const ma=100,pa=5e3;function di({prompt:a,language:i,saving:m,onSave:h,onDelete:p,onClose:A}){const f=i==="de",n=!!a,[M,w]=o.useState(a?.title||""),[T,v]=o.useState(a?.prompt||""),[U,_]=o.useState(!1),[ne,y]=o.useState(null),B=o.useRef(null);o.useEffect(()=>{const P=G=>{G.key==="Escape"&&A()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[A]);const q=P=>{B.current&&!B.current.contains(P.target)&&A()},F=M.trim().length>0&&T.trim().length>0&&M.length<=ma&&T.length<=pa&&!m,R=async()=>{if(F){y(null);try{await h({title:M.trim(),prompt:T.trim()})}catch(P){y(P?.message||(f?"Speichern fehlgeschlagen":"Failed to save"))}}},J=async()=>{if(!U){_(!0);return}y(null);try{await p()}catch(P){y(P?.message||(f?"Löschen fehlgeschlagen":"Failed to delete"))}},$=(P,G)=>P>G?"text-red-400 font-bold":P>G*.9?"text-amber-400":"text-[var(--text-tertiary)]";return e.jsx(Je,{children:e.jsx(xe.div,{initial:{opacity:0}
3,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center bg-[var(--bg-backdrop)] backdrop-blur-sm",onClick:q,children:e.jsxs(xe.div,{ref:B,initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{duration:.2},className:"w-full max-w-lg mx-4 bg-[var(--dropdown-bg)] border border-[var(--border-subtle)] rounded-2xl shadow-2xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-[var(--text-primary)]",children:n?f?"Custom Prompt bearbeiten":"Edit custom prompt":f?"Neuer Custom Prompt":"New custom prompt"}),e.jsx("button",{onClick:A,className:"p-1.5 rounded-lg hover:bg-[var(--bg-overlay)] transition text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]",children:e.jsx(Ee,{size:16})})]}),e.jsxs("div",{className:"px-5 pb-5 space-y-4",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:f?"Einmal beschreiben, überall nutzen — auf allen Konten und für dein ganzes Team. Ein Klick auf den Prompt schreibt ihn in die Chatbox; dort kannst du ihn vor dem Senden noch anpassen.":"Describe it once, use it everywhere — on every account and for your whole team. Clicking the prompt writes it into the chatbox where you can still tweak it before sending."}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("label",{className:"text-[11px] text-[var(--text-secondary)]",children:f?"Titel":"Title"}),e.jsxs("span",{className:`text-[10px] font-mono ${$(M.length,ma)}`,children:[M.length,"/",ma]})]}),e.jsx("input",{type:"text",value:M,onChange:P=>w(P.target.value),placeholder:f?"z.B. Mein Search-Kampagnen-Aufbau":"e.g. My Search campaign build",className:"w-full px-4 py-2.5 rounded-xl border border-[var(--border-subtle)] bg-[var(--bg-overlay)] text-sm text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:border-[var(--border-medium)] focus:outline-none transition",autoFocus:!n})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("label",{className:"text-[11px] text-[var(--text-secondary)]",children:"Prompt"}),e.jsxs("span",{className:`text-[10px] font-mono ${$(T.length,pa)}`,children:[T.length,"/",pa]})]}),e.jsx("textarea",{value:T,onChange:P=>v(P.target.value),rows:8,placeholder:f?"Beschreibe genau, was der Advisor tun soll — z.B. wie deine Search-Kampagnen aufgebaut werden sollen...":"Describe exactly what the advisor should do — e.g. how your Search campaigns should be built...",className:"w-full px-4 py-3 rounded-xl border border-[var(--border-subtle)] bg-[var(--bg-overlay)] text-sm text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:border-[var(--border-medium)] focus:outline-none transition resize-y"})]}),ne&&e.jsx("p",{className:"text-xs text-red-400",children:ne}),e.jsxs("div",{className:"flex items-center justify-between pt-1",children:[n?e.jsxs("button",{onClick:J,disabled:m,className:`flex items-center gap-1.5 px-3 py-2 rounded-xl text-xs transition disabled:opacity-40 ${U?"bg-red-500/15 text-red-400 border border-red-500/40":"text-[var(--text-tertiary)] hover:text-red-400 hover:bg-red-400/10"}`,children:[e.jsx(Es,{size:13}),U?f?"Wirklich löschen?":"Really delete?":f?"Löschen":"Delete"]}):e.jsx("span",{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:A,className:"px-4 py-2 rounded-xl text-xs text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-overlay)] transition",children:f?"Abbrechen":"Cancel"}),e.jsx("button",{onClick:R,disabled:!F,className:"px-4 py-2 rounded-xl bg-[var(--accent-blue)] text-white text-xs font-medium hover:opacity-90 transition disabled:opacity-40 disabled:cursor-not-allowed",children:m?f?"Speichern…":"Saving…":f?"Speichern":"Save"})]})]})]})]})})})}function ui({account:a,onClose:i}){return e.jsx(Je,{children:e.jsx(xe.div,{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",initial:{opacity:0}
3,animate:{opacity:1},exit:{opacity:0},onClick:i,children:e.jsxs(xe.div,{className:"relative w-full max-w-2xl max-h-[90vh] overflow-y-auto bg-[var(--bg-elevated)] rounded-2xl shadow-xl p-6",initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},onClick:m=>m.stopPropagation(),children:[e.jsx("button",{onClick:i,className:"absolute top-4 right-4 text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition",children:e.jsx(Ee,{size:20})}),e.jsx(Pn,{accounts:[a],onComplete:m=>i(m),onSkip:()=>i(),isModal:!0})]})})})}function xi({accountId:a,conversationId:i,onClose:m}){const[h,p]=o.useState(!0),[A,f]=o.useState(!1),[n,M]=o.useState(null),[w,T]=o.useState(null),[v,U]=o.useState(""),[_,ne]=o.useState(""),[y,B]=o.useState([]),[q,F]=o.useState(!1),R=o.useRef(null),J=o.useRef(null),$=o.useRef(new Set);o.useEffect(()=>{oa.digestConversation(a,i).then(G=>{U(G.title||"Advisor chat digest"),ne(G.body||""),B((G.actionItems||[]).map(j=>typeof j=="string"?{text:j,owner:"agency",checked:!0}:{text:j.text,owner:j.owner==="client"?"client":"agency",checked:!0}))}).catch(()=>M("Could not summarize this conversation.")).finally(()=>p(!1))},[a,i]);const P=async()=>{f(!0),T(null);try{if(!R.current){const K=y.filter(ce=>ce.checked);J.current=K,R.current=await oa.createNote(a,{type:"digest",title:v,body:_,actionItems:K.map(ce=>({text:ce.text,owner:ce.owner}))}),F(!0)}const G=J.current,j=R.current.id;for(let K=0;K<G.length;K++)$.current.has(K)||(await oa.resolveActionItem(a,j,{index:K,action:"accept"}),$.current.add(K));m(!0)}catch{T(R.current?"Note saved, but some tasks failed — Save again to retry the rest.":"Saving failed."),f(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{className:"w-full max-w-lg rounded-xl bg-white p-5 shadow-xl dark:bg-gray-900",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold",children:"Save to client file"}),e.jsx("button",{onClick:()=>m(!1),children:e.jsx(Ee,{size:18})})]}),h&&e.jsx("p",{className:"text-sm text-gray-500",children:"Summarizing the conversation…"}),n&&e.jsx("p",{className:"text-sm text-red-500",children:n}),w&&e.jsx("p",{className:"text-sm text-red-500",children:w}),!h&&!n&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{value:v,onChange:G=>U(G.target.value),className:"w-full rounded-md border px-3 py-1.5 text-sm"}),e.jsx("textarea",{value:_,onChange:G=>ne(G.target.value),rows:8,className:"w-full rounded-md border px-3 py-1.5 text-sm font-mono"}),y.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-xs font-medium text-gray-500",children:"Add as tasks"}),y.map((G,j)=>e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:G.checked,disabled:q,onCh
3ange:()=>B(y.map((K,ce)=>ce===j?{...K,checked:!K.checked}:K))}),G.text]},j))]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>m(!1),className:"rounded-md border px-3 py-1.5 text-sm",children:"Cancel"}),e.jsx("button",{disabled:A||!_.trim(),onClick:P,className:"rounded-md bg-[#2E7A9C] px-3 py-1.5 text-sm font-medium text-white",children:A?"Saving…":"Save note"})]})]})]})})}const At=["product_type","brand","custom_label_0","custom_label_1","custom_label_2","custom_label_3","custom_label_4"],xs=new Set([...At,"item_id"]);function ms(a){if(a==null)return{};if(Array.isArray(a)){const i={};for(const m of a){if(!m||typeof m!="object"||Array.isArray(m)||typeof m.dimension=="string")return null;const h=Object.keys(m);if(h.length!==1)return null;const p=h[0];if(!xs.has(p)||i[p])return null;i[p]=(Array.isArray(m[p])?m[p]:[m[p]]).map(String)}return i}if(typeof a=="object"){const i={};for(const[m,h]of Object.entries(a)){if(!xs.has(m))return null;i[m]=(Array.isArray(h)?h:[h]).map(String)}return i}return null}const ps={product_type:"Product type",brand:"Brand",custom_label_0:"Custom label 0",custom_label_1:"Custom label 1",custom_label_2:"Custom label 2",custom_label_3:"Custom label 3",custom_label_4:"Custom label 4"};function mi({open:a,value:i,options:m,loading:h,error:p,onRetry:A,onClose:f,onSave:n,onServerSearch:M}){const[w,T]=o.useState({}),[v,U]=o.useState(new Set),[_,ne]=o.useState(""),[y,B]=o.useState(null),[q,F]=o.useState(!1),R=o.useRef(0);o.useEffect(()=>{if(!a)return;const E={};for(const re of At){const ie=Array.isArray(i?.[re])?i[re]:[];E[re]=new Set(ie)}T(E),U(new Set(Array.isArray(i?.item_id)?i.item_id:[])),ne("")},[a]);const J=o.useMemo(()=>{const E={};for(const re of At){const ie=m?.fields?.[re]||[],ae=Array.isArray(i?.[re])?i[re]:[],he=new Set(ie.map(Ue=>Ue.toLowerCase()));E[re]=[...ie,...ae.filter(Ue=>!he.has(Ue.toLowerCase()))]}return E},[m,i]),$=o.useMemo(()=>{const E=m?.items||[],re=new Set(E.map(ae=>ae.id)),ie=Array.isArray(i?.item_id)?i.item_id:[];return[...E,...ie.filter(ae=>!re.has(ae)).map(ae=>({id:ae,title:ae}))]},[m,i]),P=!!M&&!!m?.itemsTruncated,G=_.trim();if(o.useEffect(()=>{if(!a||!P||G.length<2){B(null),F(!1);return}const E=++R.current;F(!0);const re=setTimeout(async()=>{try{const ie=await M(G);R.current===E&&B(Array.isArray(ie)?ie:[])}catch{R.current===E&&B(null)}finally{R.current===E&&F(!1)}},400);return()=>clearTimeout(re)},[a,P,G]),!a)return null;const j=(E,re)=>{T(ie=>{const ae={...ie,[E]:new Set(ie[E]||[])};return ae[E].has(re)?ae[E].delete(re):ae[E].add(re),ae})},K=E=>{U(re=>{const ie=new Set(re);return ie.has(E)?ie.delete(E):ie.add(E),ie})},ce=()=>{T(Object.fromEntries(At.map(E=>[E,new Set]))),U(new Set)},Q=At.reduce((E,re)=>E+(w[re]?.size||0),0)+v.size,pe=_.trim().toLowerCase(),fe=()=>{const E=At.filter(ie=>w[ie]?.size>0).map(ie=>[ie,[...w[ie]]]);v.size>0&&E.push(["item_id",[...v]]);const re=E.length===0?null:E.length===1?{[E[0][0]]:E[0][1]}:E.map(([ie,ae])=>({[ie]:ae}));n(re),f()},ze=At.filter(E=>(J[E]||[]).length>0),Oe=$.filter(E=>!pe||E.title.toLowerCase().includes(pe)||String(E.id).toLowerCase().includes(pe));let L=Oe;if(y){const E=new Set(Oe.map(re=>re.id));L=[...Oe,...y.filter(re=>!E.has(re.id))]}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:f,children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl border border-[var(--border-medium)] bg-[var(--bg-elevated)] shadow-2xl",onClick:E=>E.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between px-5 py-4 border-b border-[var(--border-subtle)]",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)]",children:"Products for this ad group"}),e.jsx("p",{className:"text-[11px] text-[var(--text-tertiary)] mt-0.5",children:"Pick product types, labels or individual products from your feed. Nothing selected = all products. Within a field any value matches; across fields all must match."})]}),e.jsx("button",{onClick:f,className:"p-1.5 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-overlay)]",children:e.jsx(Ee,{size:16})})]}),e.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 border-b border-[var(--border-subtle)]",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(zr,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}
3),e.jsx("input",{value:_,onChange:E=>ne(E.target.value),placeholder:"Search values or products…",className:"w-full rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-primary)]/70 pl-8 pr-2.5 py-1.5 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)] focus:outline-none focus:border-sky-500/40"})]}),e.jsx("button",{onClick:ce,className:"text-xs text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] whitespace-nowrap",children:"Clear"}),e.jsx("span",{className:"text-[11px] text-[var(--text-tertiary)] whitespace-nowrap",children:Q===0?"All products":`${Q} value${Q===1?"":"s"}`})]}),e.jsxs("div",{className:"max-h-[52vh] overflow-y-auto px-3 py-2",children:[h?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-xs text-[var(--text-tertiary)]",children:[e.jsx(Ae,{size:14,className:"animate-spin"})," Loading feed values…"]}):p?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-10",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:"Couldn't load the feed values."}),e.jsx("button",{onClick:A,className:"px-3 py-1.5 rounded-lg text-xs font-medium border border-[var(--border-medium)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-overlay)]",children:"Try again"})]}):ze.length===0&&$.length===0?e.jsx("div",{className:"py-10 text-center text-xs text-[var(--text-tertiary)]",children:"No products found in this account's feed."}):e.jsxs(e.Fragment,{children:[ze.map(E=>{const re=(J[E]||[]).filter(ae=>!pe||ae.toLowerCase().includes(pe)),ie=w[E]?.size||0;return re.length===0&&!pe?null:e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-tertiary)]",children:ps[E]}),ie>0&&e.jsxs("span",{className:"text-[11px] text-sky-400",children:[ie," selected"]})]}),re.length===0?e.jsx("p",{className:"px-2 pb-1 text-[11px] text-[var(--text-tertiary)]",children:"No matches"}):e.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:re.map(ae=>{const he=w[E]?.has(ae)||!1;return e.jsxs("button",{type:"button",onClick:()=>j(E,ae),title:ae,className:`flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-left text-xs transition hover:bg-[var(--bg-overlay)] ${he?"text-[var(--text-primary)]":"text-[var(--text-tertiary)]"}`,children:[e.jsx("span",{className:`flex items-center justify-center w-4 h-4 rounded border shrink-0 ${he?"bg-sky-500 border-sky-500 text-white":"border-[var(--border-medium)]"}`,children:he&&e.jsx(De,{size:11})}),e.jsx("span",{className:"truncate",children:ae})]},ae)})})]},E)}),$.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[e.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-tertiary)] flex items-center gap-1.5",children:["Individual products",q&&e.jsx(Ae,{size:11,className:"animate-spin"})]}),v.size>0&&e.jsxs("span",{className:"text-[11px] text-sky-400",children:[v.size," selected"]})]}),L.length===0?e.jsx("p",{className:"px-2 pb-1 text-[11px] text-[var(--text-tertiary)]",children:q?"Searching your catalog…":"No matches"}):e.jsx("div",{className:"space-y-0.5",children:L.map(E=>{const re=v.has(E.id);return e.jsxs("button",{type:"button",onClick:()=>K(E.id),title:`${E.title} (${E.id})`,className:`flex items-center gap-2 w-full px-2.5 py-1.5 rounded-lg text-left text-xs transition hover:bg-[var(--bg-overlay)] ${re?"text-[var(--text-primary)]":"text-[var(--text-tertiary)]"}`,children:[e.jsx("span",{className:`flex items-center justify-center w-4 h-4 rounded border shrink-0 ${re?"bg-sky-500 border-sky-500 text-white":"border-[var(--border-medium)]"}`,children:re&&e.jsx(De,{size:11})}),e.jsx("span",{className:"truncate flex-1",children:E.title}),e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)] shrink-0",children:E.id})]},E.id)})})]})]}),m?.truncated?.length>0&&e.jsxs("p",{className:"px-2 pb-1 text-[11px] text-amber-400/80",children:["Some fields have more values than shown (",m.truncated.map(E=>ps[E]||E).join(", "),") — use search to narrow down."]}),m?.itemsTruncated&&e.jsxs("p",{className:"px-2 pb-1 text-[11px] text-amber-400/80",children:["Large catalog — the product list shows a first page only. Type in the search box to find any product in the full catalog",m?.partial?"; dimension values were scanned from the first 1,000 products":"","."]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-4 border-t border-[var(--border-subtle)]",children:[e.jsx("button",{onClick:f,className:"px-3 py-2 rounded-lg text-xs font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"Cancel"}),e.jsx("button",{onClick:fe,disabled:h,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-semibold bg-sky-500 text-white hover:bg-sky-600 disabled:opacity-50",children:"Apply"})]})]})})}const ga=[{key:"campaign",label:"Campaign",icon:ur},{key:"adgroup",label:"Ad Group",icon:Ss}],pi={SEARCH:zr,SHOPPING:xt,PERFORMANCE_MAX:St};function Rr({visible:a,campaigns:i,adGroups:m,filter:h,onSelect:p,onClose:A,direction:f="up"}
3){const[n,M]=o.useState("type"),[w,T]=o.useState(null),v=o.useRef(null),[U,_]=o.useState(0);if(o.useEffect(()=>{a&&(M("type"),T(null),_(0))},[a]),o.useEffect(()=>{_(0)},[h]),!a)return null;const ne=(h||"").toLowerCase(),y=ne.length>0,B=f==="down"?"top-full mt-2":"bottom-full mb-2",q=()=>(i||[]).filter(j=>j.status==="ENABLED").filter(j=>!ne||j.name.toLowerCase().includes(ne)).slice(0,8).map(j=>({...j,_entityType:"campaign"})),F=()=>(m||[]).filter(j=>j.status==="ENABLED").filter(j=>!ne||j.name.toLowerCase().includes(ne)).slice(0,8).map(j=>({...j,_entityType:"adgroup"}));let R=[],J="type";if(n==="entity"&&w)J="entity",R=w==="campaign"?q():F();else if(y){J="search";const j=q().slice(0,4),K=F().slice(0,4);R=[...j,...K]}else J="type";const $=j=>{M("entity"),T(j),_(0)},P=j=>a?J==="type"?j.key==="ArrowDown"?(j.preventDefault(),_(K=>Math.min(K+1,ga.length-1)),!0):j.key==="ArrowUp"?(j.preventDefault(),_(K=>Math.max(K-1,0)),!0):j.key==="Enter"||j.key==="Tab"?(j.preventDefault(),$(ga[U].key),!0):(j.key==="Escape"&&(j.preventDefault(),A()),!0):j.key==="ArrowDown"?(j.preventDefault(),_(K=>Math.min(K+1,R.length-1)),!0):j.key==="ArrowUp"?(j.preventDefault(),_(K=>Math.max(K-1,0)),!0):(j.key==="Enter"||j.key==="Tab")&&R[U]?(j.preventDefault(),p(R[U]),!0):j.key==="Escape"?(j.preventDefault(),J==="entity"?(M("type"),T(null),_(0)):A(),!0):!1:!1;Rr.handleKeyDown=P;const G=J==="type"?"Mention":J==="search"?"Search results":w==="campaign"?"Select campaign":"Select ad group";return(J==="entity"||J==="search")&&R.length===0?e.jsx("div",{ref:v,className:`absolute ${B} left-0 w-80 max-w-[calc(100vw-2rem)] bg-[var(--dropdown-bg)] border border-[var(--border-medium)] rounded-xl shadow-2xl overflow-hidden z-50`,children:e.jsx("div",{className:"px-3 py-2 text-xs text-[var(--text-tertiary)]",children:h?"No matches found":"Nothing available"})}):e.jsxs("div",{ref:v,className:`absolute ${B} left-0 w-80 max-w-[calc(100vw-2rem)] bg-[var(--dropdown-bg)] border border-[var(--border-medium)] rounded-xl shadow-2xl overflow-hidden z-50`,children:[e.jsx("div",{className:"px-3 py-2 border-b border-[var(--border-subtle)]",children:e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)] uppercase tracking-wider",children:G})}),J==="type"&&e.jsx("div",{className:"py-1",children:ga.map((j,K)=>{const ce=j.icon;return e.jsxs("button",{onClick:()=>$(j.key),onMouseEnter:()=>_(K),className:`w-full flex items-center gap-2.5 px-3 py-2.5 text-left transition ${K===U?"bg-[var(--bg-overlay)]":"hover:bg-[var(--bg-overlay)]"}`,children:[e.jsx(ce,{size:15,className:"text-[var(--text-tertiary)] flex-shrink-0"}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-medium",children:j.label})]},j.key)})}),J==="entity"&&e.jsx("div",{className:"max-h-52 overflow-y-auto py-1",children:R.map((j,K)=>e.jsx(gs,{entity:j,highlighted:K===U,onSelect:()=>p(j),onHover:()=>_(K)},j.id))}),J==="search"&&e.jsx("div",{className:"max-h-52 overflow-y-auto py-1",children:R.map((j,K)=>e.jsx(gs,{entity:j,highlighted:K===U,onSelect:()=>p(j),onHover:()=>_(K),showTypeBadge:!0},`${j._entityType}-${j.id}`))})]})}function gs({entity:a,highlighted:i,onSelect:m,onHover:h,showTypeBadge:p}){const A=a._entityType==="campaign",f=A?pi[a.type]||ur:Ss,n=A?`${a.type||""}${a.status==="PAUSED"?" · paused":""}`:`in ${a.campaignName||"Unknown"}${a.status==="PAUSED"?" · paused":""}`;return e.jsxs("button",{onClick:m,onMouseEnter:h,className:`w-full flex items-center gap-2.5 px-3 py-2 text-left transition ${i?"bg-[var(--bg-overlay)]":"hover:bg-[var(--bg-overlay)]"}`,children:[e.jsx(f,{size:14,className:"text-[var(--text-tertiary)] flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:a.name}),e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)] truncate",children:n})]}),p&&e.jsx("span",{className:`shrink-0 text-[9px] px-1.5 py-0.5 rounded-full border ${A?"text-blue-400/70 border-blue-400/20 bg-blue-400/5":"text-purple-400/70 border-purple-400/20 bg-purple-400/5"}`,children:A?"Campaign":"Ad Group"})]})}const gi=32e3,hi=25*1024*1024,bi=hi-512*1024,vi=1e3;function yi(a){const i=Math.floor(a/60),m=a%60;return`${i}:${String(m).padStart(2,"0")}`}function fi({onTranscript:a,disabled:i,className:m=""}
3){const[h,p]=o.useState("idle"),[A,f]=o.useState(0),n=o.useRef(null),M=o.useRef([]),w=o.useRef(0),T=o.useRef(null),v=o.useRef(null),U=o.useRef(0),_=o.useCallback(()=>{v.current&&(clearInterval(v.current),v.current=null),T.current&&(T.current.getTracks().forEach($=>$.stop()),T.current=null),n.current=null,M.current=[],w.current=0},[]);o.useEffect(()=>()=>_(),[_]);const ne=o.useCallback(()=>{n.current&&n.current.state!=="inactive"&&n.current.stop()},[]),y=o.useCallback(async()=>{try{const $=await navigator.mediaDevices.getUserMedia({audio:!0});T.current=$;const P=new MediaRecorder($,{audioBitsPerSecond:gi});n.current=P,M.current=[],w.current=0,P.ondataavailable=G=>{!G.data||G.data.size===0||(M.current.push(G.data),w.current+=G.data.size,w.current>=bi&&P.state==="recording"&&(Er("Maximum length for one voice message reached — transcribing what you recorded."),P.stop()))},P.onstop=async()=>{p("processing");try{const G=new Blob(M.current,{type:P.mimeType||"audio/webm"});if(_(),G.size===0){p("idle");return}const{text:j,empty:K}=await te.transcribeVoice(G);K||!j?Er("No speech detected."):a(j)}catch(G){Er.error(G.message||"Couldn't transcribe — try again.")}finally{p("idle"),f(0)}},U.current=Date.now(),f(0),P.start(vi),p("recording"),v.current=setInterval(()=>{f(Math.floor((Date.now()-U.current)/1e3))},250)}catch($){_();const P=$?.name==="NotAllowedError"||$?.name==="SecurityError"?"Mic access blocked — enable it in browser settings.":"Could not access the microphone.";Er.error(P),p("idle")}},[_,a]),B=()=>{h==="idle"?y():h==="recording"&&ne()},q=h==="recording",F=h==="processing",R=yi(A),J=q?`Stop recording (${R})`:F?"Transcribing…":"Voice input";return e.jsx("button",{type:"button",onClick:B,disabled:i||F,title:J,"aria-label":J,className:`rounded-xl transition disabled:opacity-30 disabled:cursor-not-allowed ${q?"px-3 py-2 bg-red-500/25 text-red-300 ring-2 ring-red-500/60 hover:bg-red-500/35":"p-2 bg-[var(--bg-overlay)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-overlay-hover)] border border-[var(--border-subtle)]"} ${m}`,children:F?e.jsx(Ae,{size:18,className:"animate-spin"}):q?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),e.jsx(Ca,{size:14,fill:"currentColor"}),e.jsx("span",{className:"text-xs font-semibold tabular-nums",children:R})]}):e.jsx(Xn,{size:18})})}const dr="#1a1a1a",ka="#4b5563",Kt="#e5e7eb",ji="#2563eb",Ni={p:({children:a})=>e.jsx("p",{style:{margin:"0 0 10px 0",color:dr},children:a}),strong:({children:a})=>e.jsx("strong",{style:{color:"#111827",fontWeight:700},children:a}),em:({children:a})=>e.jsx("em",{style:{color:ka,fontStyle:"italic"},children:a}),ul:({children:a})=>e.jsx("ul",{style:{margin:"0 0 10px 0",paddingLeft:24,color:dr},children:a}),ol:({children:a})=>e.jsx("ol",{style:{margin:"0 0 10px 0",paddingLeft:24,color:dr},children:a}),li:({children:a})=>e.jsx("li",{style:{margin:"2px 0",color:dr},children:a}),h1:({children:a})=>e.jsx("h1",{style:{fontSize:22,fontWeight:700,color:"#111827",margin:"18px 0 8px"},children:a}),h2:({children:a})=>e.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"#111827",margin:"16px 0 6px",borderBottom:`1px solid ${Kt}`,paddingBottom:4},children:a}),h3:({children:a})=>e.jsx("h3",{style:{fontSize:15,fontWeight:600,color:"#111827",margin:"14px 0 4px"},children:a}),code:({children:a})=>e.jsx("code",{style:{background:"#f3f4f6",padding:"2px 5px",borderRadius:3,fontFamily:"monospace",fontSize:12,color:"#6366f1"},children:a}),pre:({children:a})=>e.jsx("pre",{style:{background:"#f3f4f6",border:`1px solid ${Kt}`,borderRadius:6,padding:12,fontFamily:"monospace",fontSize:12,overflowX:"auto",margin:"10px 0",whiteSpace:"pre-wrap"},children:a}),table:({children:a})=>e.jsx("table",{style:{borderCollapse:"collapse",width:"100%",margin:"10px 0",fontSize:13},children:a}),thead:({children:a})=>e.jsx("thead",{children:a}),tbody:({children:a})=>e.jsx("tbody",{children:a}),th:({children:a})=>e.jsx("th",{style:{border:`1px solid ${Kt}`,padding:"8px 12px",textAlign:"left",fontWeight:600,background:"#f9fafb",color:"#374151"},children:a}),td:({children:a})=>e.jsx("td",{style:{border:`1px solid ${Kt}`,padding:"6px 12px",color:ka},children:a}),tr:({children:a})=>e.jsx("tr",{style:{breakInside:"avoid"},children:a}),a:({href:a,children:i})=>e.jsx("a",{href:a,style:{color:ji,textDecoration:"none"},children:i}),hr:()=>e.jsx("hr",{style:{border:"none",borderTop:`1px solid ${Kt}`,margin:"16px 0"}}),blockquote:({children:a})=>e.jsx("blockquote",{style:{borderLeft:"3px solid #d1d5db",paddingLeft:12,margin:"10px 0",color:"#6b7280",fontStyle:"italic"},children:a}),img:({src:a,alt:i})=>e.jsx("img",{src:a,alt:i||"",style:{maxWidth:"100%",borderRadius:8,border:`1px solid ${Kt}`,margin:"12px 0"}})},hs="16mm",Ai="16mm",wi=o.forwardRef(function({content:i,accountName:m,date:h},p){return e.jsx("div",{ref:p,style:{fontFamily:"Arial, Helvetica, sans-serif",fontSize:14,lineHeight:1.6,color:dr,background:"#ffffff"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsx("tr",{children:e.jsx("td",{style:{height:hs,border:"none"}})})}),e.jsx("tbody",{children:e.jsx("tr",{children:e.jsxs("td",{style:{padding:`0 ${Ai}`,border:"none",verticalAlign:"top"}
3,children:[e.jsxs("div",{style:{borderBottom:"2px solid #111827",paddingBottom:10,marginBottom:18},children:[m&&e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"#111827"},children:m}),e.jsx("div",{style:{fontSize:12,color:ka,marginTop:m?2:0},children:h})]}),e.jsx(Qt,{remarkPlugins:[$t],components:Ni,children:Xt(i)})]})})}),e.jsx("tfoot",{children:e.jsx("tr",{children:e.jsx("td",{style:{height:hs,border:"none"}})})})]})})}),ki=["title","campaignType","campaignSubType","status","structure","deployError","deployedCampaignId"];function bs(a){const i=[];if(a&&a.campaignDraft&&a.campaignDraft.id!=null&&i.push(String(a.campaignDraft.id)),a&&Array.isArray(a.campaignDrafts))for(const m of a.campaignDrafts)m&&m.id!=null&&i.push(String(m.id));return i}function Si(a){const i=Array.isArray(a)?a:[],m=new Map;return i.forEach((h,p)=>{for(const A of bs(h))m.set(A,p)}),i.map((h,p)=>bs(h).filter(A=>m.get(A)>p).join(","))}function Ci(a,i){if(!Array.isArray(a)||!Array.isArray(i)||i.length===0)return a;const m=new Map(i.filter(p=>p&&p.id!=null).map(p=>[String(p.id),p])),h=p=>{const A=p&&p.id!=null?m.get(String(p.id)):null;if(!A)return p;const f={...p};for(const n of ki)A[n]!==void 0&&(f[n]=A[n]);return f};return a.map(p=>{if(!p||!p.campaignDraft&&!Array.isArray(p.campaignDrafts))return p;const A={...p};return p.campaignDraft&&(A.campaignDraft=h(p.campaignDraft)),Array.isArray(p.campaignDrafts)&&(A.campaignDrafts=p.campaignDrafts.map(h)),A})}const Ei="data:image/webp;base64,UklGRqQNAABXRUJQVlA4IJgNAACQcgCdASqAApABPmEwl0gkIyIhIbMoUIAMCWlu4XJ0Nlq85oEM1/R0yDbif+f0AefZp2FPvfGbxLeoCMMjVVZPFf53kYfPBGfI/wpJCR9ZFRw+v7U0+TQ2v7duvatk05kISBsFuqRSCSltEMmYmZUHPdlHckLXiYJnJjiTIJoOsSL6ney0eIDIfaQfCvpNPkTPgdgpJBMIJduqI21p/NljOHgddA7/kf5FU9ljEv8aLCaThVgotA7vG+v7M53EKKKTVMKd3jsZEaC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3jTaBsDv++s674h1+nZfHyTMfTKyQN70O2OmRNw2mxfc3x1Wy90q1juLUCY/srpEZV4rwt9V9r6jPeRESbqrDXl/DyCiiM2aY0YgEPHUAuJRRXZR5Z76lBuVjtWXQmqPCrlIMZ01QZd1vZW/eKD9bLGrlxcHarggRL672CBNZ/CBQ2vKiATrMSryiqXsHPEdnC9Lr88iANal4eTK53oapOhsQCm3ngfiifisRnttlD//9q6uB5TcfV9pD/SjyZ2bofDr3PH/bYyX1fyrtXpgMHV12nFX9j44IAnnKNWk+AZK55ZKu1BUcOSCli59UmRvCMSXU7wFt8nD
3RzBqaGRUmOT7h6wRkKf5fGjh0LBKudjjVA9bOwnJbpuhSbinGtfZeBh0eHergCYWYoZ9D4F1uDX67A4BW1kETNOIclwdEhpuFlIAMZSUQruKgmS2R/kdUNPgB0G0uDv+p1B2GmlxN9lIGn0iA2ZqVLFA5aWGE/+l+FdoWuaJwlHR+zPmG8PgZC2Y/cHie8A61GhJOJ+l4wVtRGtiV4pdPLlY2lz+k2uWckXx8EsPWhLh8pbJgcLFZha/0VsRLl/BhnjKHNQ+wnN8SIczr4G9u3DyvqBQLgatoTTc8npUborvljA95JmC9bNrltoWbDAwl0rqrqda7OqDZJRsL5ysEpFIWe8HzUeUZVXcgjdkEob4MrtfONYIfJnPU7WarDTs/L5oFJYZqsB9YmD04vwQusfsTF7nrp9iBwAUpcPIguIJ2FPa/f07GfqQue6h+QWXiAmcAcgrA/Bp6f2MN4oS0+6Un3Sk+6RiDIAAAA=",Ii="/assets/recent_changes_impact-C1coUHXT.webp",Pi="/assets/budget_bidding_review-CyYYWYMS.webp",Gi="data:image/webp;base64,UklGRmoPAABXRUJQVlA4IF4PAACQiQCdASqAApABPmEwlkgkIyIhoXL4cIAMCWluvVBthQyVIDyT5mBf+a8qN8//Retzyg/QR6cvOH5sunk0/ihl7eZsEQHkrK0h4//d8uT7wJlpf8NNBrPqj3Y7iO4juI7iO4juI7iO4juI7iO4kugi0AMdb0CGo88rP+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3oedap5ktez0uCCtS2xUh8zwtj60qZyjl0sRRdOKH5FauaTAnrX309w4N74AAelHmIv2ITjdmto1uY2YPKIeOkpFM5XwSIhMidPolWX5roptJYuLyjkNtB56iKnJ3k2ZpcTe9ZFRwVyT4AAAVSYG3UyIhAYMPEMMrTlY2AcSIPg3tAAAAAAAAAAAAAAAAAAAAAAA==",Ri="/assets/geo_optimization-DpoEfYhn.webp",Mi="/assets/product_performance-ILpUHgf9.webp",_i="/assets/conversion_tracking_check-CCjkL5J_.webp",zi="/assets/account_explainer-Bh7QW4yK.webp",Fi="data:image/webp;base64,UklGRrQPAABXRUJQVlA4IKgPAACwdwCdASqAApABPj0eikUiJQkEmCgB4lpbuFq7kPvnGdCJA2zC+WhRUk0DEgq87uufOyfI/436ue/PxSOpT5hf2Z9Vz/mdP/1WHojVUlN+f671xbLL/NcLJmLz3vkvO3TQzPf2R9Ov1j6NfpHdDMF14SHIBJtRxiTajjEm1HGJNqOMb+hAc3m0JjEm1HGJNvAtHY5wQweoAJNqOMSbUlFxm1HK9T2dUwKUKTajjEm1HGJNx+OVH4Ak2o4xaEFocbD0ESoHEw0c7NqOSK+fQ6fAcDwK4ALCa4JDkAn7OkanBc+kvnB2HPXqezsLOW0pTkbPb7Xup6ueR+ETNlupfkblJGo5AVLD2jsc3m0Loj+HymqJWb5lvpEEMGj+x+8KlgSDVKuOJiybLsjEAdrsJDkAIUSXIBJtRxlJY+oSpWQt5o0fZMBpFDTplppOh4t/d9wC1HEeTc7hCol3RfsfMraEro4PdPSwmuCQ5AJNqOMblVu6gbIAIdScKzcl/tqoHxS3t1Ot6AZKX6TIaLkC6Bxr+8KdMeBiitejX5pvnV2yoRaBvEQ275gbjqyKqMdOMno0+5rWXwG8gNb0YWyerOuqc2PRuYC9PO7ojWIE/Z0rbpuMmSBkNUGA8e37Ce5afZ24reA38HihfIVmdpswjSS48XajH+EIBbjDXZElYzTbLq2hrbCslY/lj+AJJLSqlDIwSlD4aL0oxhNtB+22jGJ0edF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d1SxW9A5bGKlZWgD5r7SuiToA8VRYhIv1UzH9j3l5NTRWNrNg0My1jcgm5808UQAtUDa5kil06JOpkERUFpUaH4dR4KWrq44mshondzeGR/NDoVG0HQJxUWagILxDDHVcXx+KMCAgoO/ke2BjpawmW2uaztaE38/UnAKnfr8GC+EYWNCQGmonM8fdSXy+4ePOIZm+BVbNitR5bgwGJFE4RJDpZk2ZfEm49Wn4rWhL5p9ZgaAvIABzSF8I0eyA1JqMojA+b0eySgtWrNtG8QaX1rRA7dwJjCh5MAw5aDsMAAA=",Ui="/assets/compare_periods-DlMhhPXK.webp",Bi="/assets/build_search_campaign-DCKt8VZj.webp",Hi="/assets/add_search_ad_group-EwcjGksp.webp",Vi="/assets/add_search_rsa-C9-m9ybw.webp",Yi="/assets/build_pmax_assets_campaign-BaiWnDvI.webp",Ki="/assets/build_pmax_shopping_campaign-DOmIAGcp.webp",Wi="/assets/top_products_campaign-6QPZhvlR.webp",Zi="/assets/add_pmax_asset_group-cRdb_air.webp",Ji="/assets/build_pmax_segmented_campaign-DUWUPhbu.webp",qi="/assets/scale_budget_reach-JsF22cUm.webp",Xi="/assets/scale_keyword_expansion-CquyC9Vc.webp",Qi="/assets/scale_product_structure-D_uuzNLL.webp",$i="/assets/build_shopping_campaign-TpcMSLNJ.webp",el="/assets/create_shopping_brand-Cf11HZtB.webp",tl="/assets/build_demand_gen_campaign-cK-NDx-S.webp",rl="/assets/add_dg_ad_group-DC01IGig.webp",ha={waste_check:zn,performance_review:Ei,visual_cro_audit:Ti,account_structure_check:Li,client_report:Di,recent_changes_impact:Ii,budget_bidding_review:Pi,search_term_analysis:_n,ad_keyword_health_check:Gi,device_schedule_optimization:Oi,geo_optimization:Ri,product_performance:Mi,conversion_tracking_check:_i,account_explainer:zi,demand_gen_check:Fi,compare_periods:Ui,build_search_campaign:Bi,add_search_ad_group:Hi,add_search_rsa:Vi,build_pmax_assets_campaign:Yi,build_pmax_shopping_campaign:Ki,top_products_campaign:Wi,add_pmax_asset_group:Zi,build_pmax_segmented_campaign:Ji,growth_opportunities:Mn,scale_budget_reach:qi,scale_keyword_expansion:Xi,scale_product_structure:Qi,scale_landing_page_cro:Rn,build_shopping_campaign:$i,create_shopping_brand:el,build_demand_gen_campaign:tl,add_dg_ad_group:rl},Wt=a=>Array.isArray(a),Zt=a=>a!=null&&(Array.isArray(a)?a.length>0:typeof a=="object"&&Object.keys(a).length>0);function rt(a){return a==null?"All products":Array.isArray(a)?a.map(i=>{if(!i||typeof i!="object")return String(i);if(typeof i.dimension=="string"){const p=Array.isArray(i.exclude)&&i.exclude.length,A=p?i.exclude:i.include||i.values||[];return`${i.dimension} ${p?"≠":"="} ${Array.isArray(A)?A.join("/"):A}`}const m=Object.keys(i)[0],h=i[m];return`${m} = ${Array.isArray(h)?h.join("/"):h}`}).join("  →  "):typeof a=="object"?Object.entries(a).map(([i,m])=>`${i}: ${Array.isArray(m)?m.join(", "):m}`).join(", "):String(a)}class al extends o.Component{constructor(i){super(i),this.state={error:null}}static getDerivedStateFromError(i){return{error:i}}componentDidCatch(i,m){console.error("ActionProposalCard crash:",i,m)}render(){return this.state.error?e.jsxs("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30 text-xs text-red-300",children:[e.jsx("div",{className:"font-semibold mb-1",children:"Action card crashed"}),e.jsxs("pre",{className:"whitespace-pre-wrap text-red-400/70",children:[this.state.error.message,`
4`,this.state.error.stack]})]}):this.props.children}}const sl={DEFAULT:"Other",PAGE_VIEW:"Page view",PURCHASE:"Purchase",SIGNUP:"Sign-up",LEAD:"Lead",DOWNLOAD:"Download",ADD_TO_CART:"Add to cart",BEGIN_CHECKOUT:"Begin checkout",SUBSCRIBE_PAID:"Subscribe (paid)",PHONE_CALL_LEAD:"Phone call lead",IMPORTED_LEAD:"Imported lead",SUBMIT_LEAD_FORM:"Submit lead form",BOOK_APPOINTMENT:"Book appointment",REQUEST_QUOTE:"Request a quote",GET_DIRECTIONS:"Get directions",OUTBOUND_CLICK:"Outbound click",CONTACT:"Contact",ENGAGEMENT:"Engagement",STORE_VISIT:"Store visit",STORE_SALE:"Store sale",QUALIFIED_LEAD:"Qualified lead",CONVERTED_LEAD:"Converted lead"};function ba(a){return a?sl[a]||String(a).replace(/_/g," ").toLowerCase().replace(/\b\w/g,i=>i.toUpperCase()):"Other"}const vs={de:{button:"Gedächtnis",info:"Was der Agent bei jeder Nachricht liest: deine Ziele, Business-Infos, Kampagnen-Einstellungen und Attributionsdaten. Klicken zum Verwalten."},en:{button:"Memory",info:"What the agent reads before every reply: your goals, business info, campaign settings and attribution data. Click to manage."}},va={search:zr,shopping_cart:xt,campaign:St,ads_click:ur,analytics:Sa,find_replace:xr,warning:qt,tune:Aa,visibility:Hn,star:Ls,trending_up:Cs,account_tree:ja,image:mt},Ir=["waste_check","performance_review","account_structure_check","growth_opportunities","visual_cro_audit","recent_changes_impact"],nl={cyan:{border:"border-cyan-500/20 hover:border-cyan-500/35",icon:"text-cyan-400/50 group-hover:text-cyan-400/80",glow:"hover:shadow-[0_0_12px_rgba(6,182,212,0.08)]"}},il={cyan:{border:"border-cyan-500/30 hover:border-cyan-500/50 bg-cyan-50 hover:bg-cyan-100/60",icon:"text-cyan-600 group-hover:text-cyan-700",glow:"hover:shadow-md hover:shadow-cyan-500/10"}};function ut({items:a,onChange:i,maxLen:m,placeholder:h,addLabel:p,maxItems:A,pins:f,onPinChange:n,pinOptions:M,effectiveLen:w}){const T=A!=null&&a.length>=A,v=_=>w?w(_||""):(_||"").length,U=(_,ne)=>{const y=(_||"").trim();if(!f||!n||f[y]===void 0)return;const B={...f},q=B[y];delete B[y],ne&&ne.trim()&&(B[ne.trim()]=q),n(B)};return e.jsxs("div",{className:"space-y-1.5",children:[a.map((_,ne)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx("input",{value:_,onCh
4ange:y=>{const B=[...a];B[ne]=y.target.value,i(B),U(_,y.target.value)},placeholder:h,maxLength:m!=null?String(_).includes("{")?m+40:m:void 0,className:"w-full pl-3 pr-14 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"}),m!=null&&e.jsxs("span",{className:`absolute right-2 top-1/2 -translate-y-1/2 text-[10px] font-mono ${v(_)>m?"text-red-400 font-bold":v(_)>m*.9?"text-amber-400":"text-[var(--text-tertiary)]"}`,children:[v(_),"/",m]})]}),M&&n&&e.jsxs("select",{value:f&&f[(_||"").trim()]||"",onChange:y=>{const B={...f||{}},q=(_||"").trim();y.target.value?B[q]=y.target.value:delete B[q],n(B)},title:"Pin to position (pinning lowers Ad Strength)",className:`shrink-0 text-[10px] rounded-md px-1 py-1 border transition ${f&&f[(_||"").trim()]?"bg-[var(--accent-blue)] text-white border-[var(--accent-blue)]":"bg-[var(--bg-overlay)] text-[var(--text-tertiary)] border-[var(--border-subtle)]"}`,children:[e.jsx("option",{value:"",children:"—"}),M.map(y=>e.jsx("option",{value:y,children:Na[y]},y))]}),a.length>1&&e.jsx("button",{onClick:()=>{i(a.filter((y,B)=>B!==ne)),U(_,null)},className:"p-1 rounded text-[var(--text-tertiary)] hover:text-red-400 hover:bg-red-400/10 transition shrink-0",children:e.jsx(Ee,{size:13})})]},ne)),!T&&e.jsxs("button",{onClick:()=>i([...a,""]),className:"flex items-center gap-1 text-[11px] text-[var(--accent-blue-bright)]/70 hover:text-[var(--accent-blue-bright)] transition px-1 py-0.5",children:[e.jsx(Ke,{size:11})," ",p||"Add"]})]})}function nr({tags:a,onChange:i,placeholder:m,suggestions:h}){const[p,A]=o.useState(""),f=n=>{const M=n.trim();M&&!a.includes(M)&&i([...a,M]),A("")};return e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:a.map((n,M)=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-secondary)]",children:[n,e.jsx("button",{onClick:()=>i(a.filter((w,T)=>T!==M)),className:"text-[var(--text-tertiary)] hover:text-red-400 transition",children:e.jsx(Ee,{size:11})})]},M))}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{value:p,onChange:n=>A(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),f(p))},placeholder:m,className:"flex-1 px-2.5 py-1 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-secondary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:border-[var(--accent-blue)]/30 transition"}),e.jsx("button",{onClick:()=>f(p),disabled:!p.trim(),className:"px-2 py-1 rounded-lg text-[11px] text-[var(--accent-blue-bright)]/70 hover:text-[var(--accent-blue-bright)] hover:bg-[var(--accent-blue)]/10 transition disabled:opacity-30",children:e.jsx(Ke,{size:12})})]}),h?.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:h.filter(n=>!a.includes(n)).slice(0,8).map(n=>e.jsxs("button",{onClick:()=>f(n),className:"px-1.5 py-0.5 rounded text-[10px] text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay)] border border-[var(--border-subtle)] transition",children:["+ ",n]},n))})]})}function at({label:a,checked:i,onChange:m}){return e.jsxs("label",{className:"flex items-center justify-between py-1 cursor-pointer group",children:[e.jsx("span",{className:"text-xs text-[var(--text-secondary)] group-hover:text-[var(--text-secondary)] transition",children:a}),e.jsx("button",{type:"button",onClick:()=>m(!i),className:`relative w-9 h-5 rounded-full transition-colors ${i?"bg-[var(--accent-blue)]":"bg-[var(--bg-overlay-heavy)]"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${i?"translate-x-4":""}`})})]})}function ll({googleAdsAccountId:a,selected:i,onAdd:m,onClose:h,userListsOnly:p,allowCombined:A=!0,allowCustom:f=!0,allowSavedAudiences:n=!1,showSavedAudiences:M=!1,title:w}){const[T,v]=o.useState(null),[U,_]=o.useState(!0),[ne,y]=o.useState(null),[B,q]=o.useState(""),[F,R]=o.use
4State(!1),[J,$]=o.useState(null),[P,G]=o.useState("userLists");o.useEffect(()=>{let L=!0;return te.getAccountAudiences(a).then(E=>{L&&(v(E),_(!1))}).catch(E=>{L&&(y(E.message||"Laden fehlgeschlagen"),_(!1))}),()=>{L=!1}},[a]);const j=async()=>{if(B.trim()){R(!0);try{const L=await te.getAccountAudiences(a,B.trim());$(L.interestMatches||[])}catch{$([])}finally{R(!1)}}},K=L=>L?String(L).toLowerCase().replace(/_/g," ").replace(/\b\w/g,E=>E.toUpperCase()):"",ce=L=>i.some(E=>E.resource_name===L),Q=({rn:L,name:E,sub:re,type:ie,warn:ae})=>e.jsxs("button",{type:"button",disabled:ce(L),onClick:()=>m({type:ie,resource_name:L,name:E}),className:`w-full flex items-center justify-between gap-2 px-3 py-2 rounded-lg text-left text-xs border transition
5        ${ce(L)?"border-[var(--accent-blue)]/40 bg-[var(--accent-blue)]/10 opacity-60 cursor-default":"border-[var(--border-subtle)] hover:bg-[var(--bg-overlay)]"}`,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[var(--text-primary)] truncate",children:E}),e.jsx("span",{className:`block text-[10px] ${ae?"text-amber-500":"text-[var(--text-tertiary)]"}`,children:re})]}),ce(L)?e.jsx(De,{size:12,className:"shrink-0 text-[var(--accent-blue-bright)]"}):e.jsx(Ke,{size:12,className:"shrink-0 text-[var(--text-tertiary)]"})]}),pe=({name:L,sub:E})=>e.jsx("div",{className:"w-full flex items-start justify-between gap-2 px-3 py-2 rounded-lg text-left text-xs border border-[var(--border-subtle)]/60",children:e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[var(--text-secondary)] truncate",children:L}),E&&e.jsx("span",{className:"block text-[10px] text-[var(--text-tertiary)]",children:E})]})}),fe=({children:L})=>e.jsx("div",{className:"text-[11px] text-[var(--text-tertiary)] py-4 text-center",children:L}),ze=p?[{key:"userLists",label:"Ihre Daten-Segmente",totalKey:"totalUserLists"}]:[{key:"userLists",label:"Ihre Daten-Segmente",totalKey:"totalUserLists"},...n||M?[{key:"audiences",label:"Zielgruppen",totalKey:"totalAudiences"}]:[],...f?[{key:"customSegments",label:"Benutzerdef.",totalKey:"totalCustomSegments"}]:[],...A?[{key:"combinedSegments",label:"Kombiniert",totalKey:"totalCombinedSegments"}]:[],{key:"interests",label:"In-Market / Interessen"}],Oe=ze.some(L=>L.key===P)?P:"userLists";return e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center p-4",onClick:h,children:[e.jsx("div",{className:"absolute inset-0 bg-black/50"}),e.jsxs("div",{onClick:L=>L.stopPropagation(),className:"relative w-full max-w-lg max-h-[80vh] overflow-y-auto rounded-2xl border border-[var(--border-subtle)] p-4 space-y-3",style:{background:"var(--bg-primary)"},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"font-medium text-sm text-[var(--text-primary)] flex items-center gap-1.5",children:[e.jsx(kt,{size:14})," ",w||"Zielgruppen aus dem Konto"]}),e.jsx("button",{type:"button",onClick:h,className:"p-1 rounded-lg hover:bg-[var(--bg-overlay)] transition",children:e.jsx(Ee,{size:14,className:"text-[var(--text-tertiary)]"})})]}),U&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-tertiary)] py-6 justify-center",children:[e.jsx(Ae,{size:14,className:"animate-spin"})," Lade Zielgruppen…"]}),ne&&e.jsx("div",{className:"text-xs text-red-400 py-4",children:ne}),T&&e.jsxs(e.Fragment,{children:[ze.length>1&&e.jsx("div",{className:"flex flex-wrap gap-0.5 border-b border-[var(--border-subtle)]",children:ze.map(L=>{const E=L.totalKey?T[L.totalKey]:null,re=L.key===Oe;return e.jsxs("button",{type:"button",onClick:()=>G(L.key),className:`px-2.5 py-1.5 text-[11px] font-medium border-b-2 -mb-px transition
6                        ${re?"border-[var(--accent-blue)] text-[var(--text-primary)]":"border-transparent text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]"}`,children:[L.label,typeof E=="number"?` (${E})`:""]},L.key)})}),e.jsxs("div",{className:"space-y-1",children:[Oe==="userLists"&&((T.userLists||[]).length===0?e.jsx(fe,{children:"Keine Daten-Segmente (Remarketing / Kundenlisten) im Konto."}):(T.userLists||[]).map(L=>e.jsx(Q,{rn:L.resourceName,name:L.name,type:"USER_LIST",warn:!L.searchReady,sub:L.searchReady?`${K(L.type)}
6 · ${(L.sizeForSearch||0).toLocaleString()} aktive Search-Nutzer`:`${K(L.type)} · ${(L.sizeForSearch||0).toLocaleString()} Search-Nutzer — unter ~1.000: Liste wirkt erst, wenn sie wächst`},L.resourceName))),Oe==="audiences"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] mb-1",children:n?"Gespeicherte Zielgruppen — wiederverwendbar. Angehängt wird die GESAMTE Zielgruppe; sie wird zur einzigen Zielgruppe der Anzeigen- bzw. Asset-Gruppe (ersetzt einzelne Signale).":"In Google Ads gespeicherte Zielgruppen — zur Übersicht (im Builder werden Zielgruppen aus ihren Bestandteilen zusammengesetzt)."}),(T.audiences||[]).length===0?e.jsx(fe,{children:"Keine gespeicherten Zielgruppen."}):(T.audiences||[]).map(L=>{const E=[L.builtFrom,L.addedTo&&L.addedTo!=="Not in use"?`Verwendet: ${L.addedTo}`:null].filter(Boolean).join(" · ");return n&&L.scope==="CUSTOMER"?e.jsx(Q,{rn:L.resourceName,name:L.name,type:"AUDIENCE",sub:E},L.resourceName):e.jsx(pe,{name:L.name,sub:[E,n&&L.scope==="ASSET_GROUP"?"an eine Asset-Gruppe gebunden — nicht wiederverwendbar":null].filter(Boolean).join(" · ")},L.resourceName)})]}),Oe==="customSegments"&&((T.customSegments||[]).length===0?e.jsx(fe,{children:"Keine benutzerdefinierten Segmente im Konto."}):(T.customSegments||[]).map(L=>e.jsx(Q,{rn:L.resourceName,name:L.name,type:"CUSTOM_AUDIENCE",sub:[K(L.type),L.addedTo&&L.addedTo!=="Not in use"?L.addedTo:null].filter(Boolean).join(" · ")},L.resourceName))),Oe==="combinedSegments"&&((T.combinedSegments||[]).length===0?e.jsx(fe,{children:"Keine kombinierten Segmente im Konto."}):(T.combinedSegments||[]).map(L=>e.jsx(Q,{rn:L.resourceName,name:L.name,type:"COMBINED_AUDIENCE",sub:L.addedTo&&L.addedTo!=="Not in use"?L.addedTo:""},L.resourceName))),Oe==="interests"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-1.5 mb-1.5",children:[e.jsx("input",{value:B,onChange:L=>q(L.target.value),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),j())},placeholder:'Auf Englisch suchen, z.B. "swimwear"',className:"flex-1 px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition placeholder:text-[var(--text-tertiary)]"}),e.jsx("button",{type:"button",onClick:j,disabled:F||!B.trim(),className:"px-3 py-1.5 rounded-lg text-xs border border-[var(--border-subtle)] text-[var(--text-secondary)] hover:bg-[var(--bg-overlay)] transition disabled:opacity-50",children:F?e.jsx(Ae,{size:12,className:"animate-spin"}):"Suchen"})]}),J!==null&&(J.length===0?e.jsx(fe,{children:"Keine Treffer — Segmentnamen sind englisch."}):e.jsx("div",{className:"space-y-1",children:J.map(L=>e.jsx(Q,{rn:L.resourceName,name:L.name,type:"USER_INTEREST",sub:L.taxonomyType==="IN_MARKET"?"In-Market (Kaufabsicht)":"Interesse (Affinity)"},L.resourceName))}))]})]}),e.jsx("button",{type:"button",onClick:h,className:"w-full py-1.5 rounded-lg text-xs border border-[var(--border-subtle)] text-[var(--text-secondary)] hover:bg-[var(--bg-overlay)] transition",children:"Fertig"})]})]})]})}function ys({audiences:a,servingMode:i,className:m=""}
6){const h=Array.isArray(a)?a.filter(Boolean):[];if(!h.length)return null;const p=n=>n.map(M=>M.name||M.resource_name).join(", "),A=h.filter(n=>!n.negative),f=h.filter(n=>n.negative);return e.jsxs("div",{className:`text-[var(--text-tertiary)] flex items-start gap-1 ${m}`,children:[e.jsx(kt,{size:12,className:"mt-0.5 shrink-0"}),e.jsxs("span",{children:[A.length>0&&e.jsxs(e.Fragment,{children:["Zielgruppen (",i==="TARGETING"?"Ausrichtung":"Beobachtung","): ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:p(A)})]}),A.length>0&&f.length>0&&" · ",f.length>0&&e.jsxs(e.Fragment,{children:["Ausgeschlossen: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:p(f)})]})]})]})}function ir({items:a,onChange:i,googleAdsAccountId:m,showMode:h,servingMode:p,onModeChange:A,allowNegative:f,userListsOnly:n,allowCombined:M=!0,allowCustom:w=!0,allowSavedAudiences:T=!1,showSavedAudiences:v=!1,addLabel:U,pickerTitle:_,hideNegativePrefix:ne,targetingScope:y="Die Kampagne wird"}){const[B,q]=o.useState(!1),F=Array.isArray(a)?a:[],R=G=>G.resource_name||G.enum_value,J=G=>i(F.filter(j=>R(j)!==G)),$=G=>i(F.map(j=>R(j)===G?{...j,negative:!j.negative}:j)),P=G=>G.type==="AUDIENCE"?i([G]):i([...F.filter(j=>j.type!=="AUDIENCE"),G]);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[F.map(G=>e.jsxs("span",{className:`inline-flex items-center gap-1.5 pl-2.5 pr-1.5 py-1 rounded-full text-[11px] border
7              ${G.negative?"border-red-500/30 bg-red-500/10 text-red-400":"border-[var(--accent-blue)]/30 bg-[var(--accent-blue)]/10 text-[var(--text-secondary)]"}`,children:[G.negative&&!ne?"Ausschluss: ":"",G.name||G.resource_name||G.enum_value,f&&e.jsx("button",{type:"button",title:G.negative?"Als Zielgruppe verwenden":"Als Ausschluss verwenden",onClick:()=>$(R(G)),className:"opacity-60 hover:opacity-100 transition text-[10px] font-medium",children:"±"}),e.jsx("button",{type:"button",onClick:()=>J(R(G)),className:"opacity-60 hover:opacity-100 transition",children:e.jsx(Ee,{size:10})})]},R(G))),e.jsxs("button",{type:"button",onClick:()=>q(!0),className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] border border-dashed border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-overlay)] transition",children:[e.jsx(Ke,{size:10})," ",U||"Aus Konto wählen"]})]}),h&&F.some(G=>!G.negative)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex gap-1",children:[["OBSERVATION","Beobachtung (empfohlen)"],["TARGETING","Ausrichtung"]].map(([G,j])=>e.jsx("button",{type:"button",onClick:()=>A(G),className:`px-2.5 py-1 rounded-lg text-[11px] border transition
8                  ${(p||"OBSERVATION")===G?"bg-[var(--accent-blue)] text-white border-transparent":"border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:bg-[var(--bg-overlay)]"}`,children:j},G))}),p==="TARGETING"&&e.jsxs("div",{className:"text-[10px] text-amber-500 flex items-start gap-1",children:[e.jsx(qt,{size:10,className:"mt-0.5 shrink-0"}),"Ausrichtung: ",y," NUR an diese Zielgruppen ausgeliefert — das schränkt die Reichweite stark ein."]})]}),B&&e.jsx(ll,{googleAdsAccountId:m,selected:F,userListsOnly:n,allowCombined:M,allowCustom:w,allowSavedAudiences:T,showSavedAudiences:v,title:_,onAdd:P,onClose:()=>q(!1)})]})}function wt({options:a,value:i,onChange:m,placeholder:h}){const[p,A]=o.useState(!1),f=o.useRef(null),n=a.find(M=>M.value===i);return o.useEffect(()=>{const M=w=>{f.current&&!f.current.contains(w.target)&&A(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]),e.jsxs("div",{ref:f,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>A(!p),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay-heavy)] border border-[var(--border-subtle)] transition text-xs text-left",children:[e.jsx("span",{className:"text-[var(--text-primary)] truncate",children:n?.label||h||"Select..."}),e.jsx(Or,{size:12,className:`text-[var(--text-tertiary)] transition-transform shrink-0 ${p?"rotate-180":""}`})]}),e.jsx(Je,{children:p&&e.jsx(xe.div,{initial:{opacity:0,y:-4}
8,animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:"absolute top-full left-0 right-0 mt-1 rounded-lg border border-[var(--border-subtle)] overflow-hidden z-50",style:{background:"var(--bg-primary)",backdropFilter:"blur(16px)"},children:a.map(M=>e.jsx("button",{type:"button",onClick:()=>{m(M.value),A(!1)},className:`w-full flex items-center px-3 py-2 text-left text-xs transition hover:bg-[var(--bg-overlay)]
9                  ${M.value===i?"text-[var(--accent-blue-bright)] bg-[var(--accent-blue)]/10":"text-[var(--text-secondary)]"}`,children:M.label},M.value))})})]})}function ol({keywords:a,onChange:i}){const m=[{value:"PHRASE",label:"PHRASE"},{value:"EXACT",label:"EXACT"},{value:"BROAD",label:"BROAD"}];return e.jsxs("div",{className:"space-y-1.5",children:[a.map((h,p)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-24 shrink-0",children:e.jsx(wt,{options:m,value:h.matchType,onChange:A=>{const f=[...a];f[p]={...f[p],matchType:A},i(f)}})}),e.jsx("input",{value:h.text,onChange:A=>{const f=[...a];f[p]={...f[p],text:A.target.value},i(f)},className:"flex-1 px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition",placeholder:"keyword"}),a.length>1&&e.jsx("button",{onClick:()=>i(a.filter((A,f)=>f!==p)),className:"p-1 text-[var(--text-tertiary)] hover:text-red-400 transition",children:e.jsx(Ee,{size:13})})]},p)),e.jsxs("button",{onClick:()=>i([...a,{text:"",matchType:"PHRASE"}]),className:"flex items-center gap-1 text-[11px] text-[var(--accent-blue-bright)]/70 hover:text-[var(--accent-blue-bright)] transition px-1 py-0.5",children:[e.jsx(Ke,{size:11})," Add Keyword"]})]})}const ya=[{key:"youtube_in_stream",label:"YouTube In-Stream"},{key:"youtube_in_feed",label:"YouTube In-Feed"},{key:"youtube_shorts",label:"YouTube Shorts"},{key:"discover",label:"Discover"},{key:"gmail",label:"Gmail"},{key:"display",label:"Display"},{key:"maps",label:"Maps"}],Ds="ALL_OWNED_AND_OPERATED_CHANNELS",Is=[{value:"ALL_OWNED_AND_OPERATED_CHANNELS",label:"Google channels only (YouTube, Discover, Gmail — no Display)"},{value:"ALL_CHANNELS",label:"All channels incl. Display"}],cl=a=>(Is.find(i=>i.value===(a||Ds))||{label:a}).label,Pr={VIDEO:[{key:"verticalVideos",label:"Vertical & square versions of videos"},{key:"shorterVideos",label:"Shorter versions of videos"},{key:"landingPageText",label:"Text from landing page"},{key:"landingPagePreview",label:"Landing page screenshot"}],IMAGE:[{key:"imageDesignVersions",label:"Design versions of images"},{key:"videosFromImages",label:"Videos made from images"}]};function dl(a){const i=String(a||"").trim();if(!i||/^[\w-]{11}$/.test(i))return i;const m=i.match(/(?:youtu\.be\/|[?&]v=|\/embed\/|\/shorts\/|\/v\/)([\w-]{11})/);return m?m[1]:i}const ul=["LEARN_MORE","SHOP_NOW","BUY_NOW","ORDER_NOW","SIGN_UP","SUBSCRIBE","DOWNLOAD","BOOK_NOW","GET_QUOTE","APPLY_NOW","CONTACT_US","GET_OFFER","VISIT_SITE","SEE_MORE","WATCH_NOW","DONATE_NOW"].map(a=>({value:a,label:a.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())})),fs={account_brand:"Markenlogo des Kontos (von dir bestätigt)",account:"Aktuelles Logo des Kontos (automatisch gewählt)",target_campaign:"Logo der Kampagne (automatisch gewählt)",operator:"Von dir gewählt"};let Gr=null;function xl(a){const[i,m]=o.useState(null);return o.useEffect(()=>{if(!a)return;let h=!1;return Gr||(Gr=jn.getTargetableLanguages(a).then(p=>p?.languages||[]).catch(p=>{throw Gr=null,p})),Gr.then(p=>{h||m(p)}).catch(()=>{h||m([])}),()=>{h=!0}},[a]),{languages:i||[],loading:!!a&&i===null}}function js({draft:a,onApprove:i,onReject:m,onDeploy:h,onSave:p,onPickLogo:A,googleAdsAccountId:f}){const n=a.structure||{},[M,w]=o.useState(!1),[T,v]=o.useState(!1),U=xl(T?f||a.googleAdsAccountId:null),[_,ne]=o.useState(!1),[y,B]=o.useState(null),[q,F]=o.useState(()=>!!(a.structure&&a.structure._clone)),[R,J]=o.useState(null),$=Array.isArray(a.structure?.objections)?a.structure.objections:[],[P,G]=o.useState(null),[j,K]=o.useState(!1),[ce,Q]=o.use
9State(!1),[pe,fe]=o.useState(null),[ze,Oe]=o.useState(null),[L,E]=o.useState(!1),[re,ie]=o.useState(!1),ae=n.campaignSubType==="SHOPPING_ONLY",he=n.campaignType==="SHOPPING",Ue=!!n.isAssetGroupOnly,Re=!!n.isAdGroupOnly,Ie=!!n.isRsaOnly,we=!!n.isDgAdOnly,le=Ue||Re||Ie||we,z=n.campaignType==="PERFORMANCE_MAX",je=n.campaignType==="DEMAND_GEN",be=!!n._clone,mr={VIDEO_RESPONSIVE:"VIDEO",MULTI_ASSET:n.adFormat==="PRODUCT"?"PRODUCT":"IMAGE",CAROUSEL:"CAROUSEL"},st=je?Array.isArray(n.adGroups)&&n.adGroups.length?n.adGroups:n.ad?[{name:n.adGroup?.name||"Ad Group",format:mr[n.adSubtype]||"IMAGE",ad:n.ad,...n.adGroup}]:[]:[],Qe=n.productFeed||(n.retailMode===!0&&n.merchantId?{merchantId:n.merchantId,feedLabel:n.feedLabel||null}:null),pr=ae||he||z,Fr=he||ae||z&&n.campaignSubType==="FULL",ke=he?n.shoppingProductFilters:n.pmaxListingGroupFilters,Ct=ke&&Object.keys(ke).length>0,gr=z&&!ae&&n.pmaxAssetGroups?.length>0,Et=Array.isArray(n.brandAssetsMissing)?n.brandAssetsMissing:[],nt=Et.includes("logo")&&!n.logoUrl,Tt=Et.includes("business_name")&&!(n.businessName&&n.businessName.trim()),Pe=nt||Tt,Lt=nt?"Logo erforderlich — bitte im Logo-Feld wählen":"Business Name erforderlich — bitte im Editor (Edit) setzen",hr=gr&&!!A&&(n.logoUrl||nt)&&["draft","modified","approved","failed"].includes(a.status),Be=(()=>{if(!je)return null;for(const t of n.adGroups||[])if(!(!t||typeof t!="object"))for(const x of[t.ad,...Array.isArray(t.ads)?t.ads:[]]){if(!x||typeof x!="object")continue;const u=t.format==="CAROUSEL"?x.logo_image_url:x.logo_image_urls?.[0];if(u)return u}return null})(),Dt=je&&(n.adGroups||[]).some(t=>t&&(t.ad||Array.isArray(t.ads)&&t.ads.length))&&!!A&&["draft","modified","approved","failed"].includes(a.status),gt=o.useCallback(async()=>{if(!(!a.id||j||P)){K(!0);try{const t=await te.getDraftMatchingProducts(a.id);G(t)}catch{G({products:[],message:"Failed to load products."})}finally{K(!1)}}},[a.id,j,P]);o.useEffect(()=>{M&&pr&&Ct&&!P&&!j&&gt()},[M,pr,Ct,P,j,gt]);const it=o.useCallback(async()=>{if(a.id){E(!0),ie(!1);try{const t=await te.getDraftProductFilterValues(a.id);Oe(t)}catch{ie(!0)}finally{E(!1)}}},[a.id]),Br=t=>{fe(t),!ze&&!L&&it()},It=()=>{const t=JSON.parse(JSON.stringify(n));if(je&&(Array.isArray(t.adGroups)&&t.adGroups.length||(t.adGroups=JSON.parse(JSON.stringify(st))),t.adGroups=t.adGroups.map(x=>({...x,__originalName:x.name})),!t.productFeed&&Qe&&(t.productFeed=JSON.parse(JSON.stringify(Qe))),delete t.ad,delete t.adGroup,delete t.adSubtype,delete t.adFormat,delete t.listingGroups,delete t.retailMode,delete t.merchantId,delete t.feedLabel),!je&&Array.isArray(t.adGroups)&&(t.adGroups=t.adGroups.map(x=>({...x,__originalName:x.name}))),Array.isArray(t.pmaxAssetGroups)&&(t.pmaxAssetGroups=t.pmaxAssetGroups.map(x=>({...x,__originalName:x.name}))),!Array.isArray(t.conversionGoalCategories)&&a.availableConversionActions?.length>0){const u=["PERFORMANCE_MAX","SHOPPING"].includes(n.campaignType)?["PURCHASE","ADD_TO_CART","BEGIN_CHECKOUT"]:["PURCHASE","SUBMIT_LEAD_FORM","PHONE_CALL_LEAD","BOOK_APPOINTMENT","CONTACT","SIGNUP"],D=g=>a.availableConversionActions.some(O=>O.isPrimary&&O.category===g);let b=[];if(t.conversionActionId){const g=a.availableConversionActions.find(O=>String(O.id)===String(t.conversionActionId));g?.category&&b.push(g.category)}if(b.length===0){for(const g of u)if(D(g)){b.push(g);break}}if(b.length===0){const g=a.availableConversionActions.find(O=>O.isPrimary);g?.category&&b.push(g.category)}t.conversionGoalCategories=b}n.isAssetGroupOnly?delete t.autoAssetSettings:n.campaignType==="PERFORMANCE_MAX"&&!t.autoAssetSettings&&(t.autoAssetSettings={textAutoGeneration:!1,imageAutoGeneration:!1,videoAutoGeneration:!1,finalUrlExpansion:!1}),B(t),v(!0),w(!0),J(null)},br=()=>{v(!1),B(null),J(null),fe(null)},vr=async()=>{ne(!0),J(null);try{const t=b=>b?.filter(g=>g&&g.trim()).map(g=>g.trim())||[],x=b=>b.filter(g=>g&&g.type&&(g.resource_name||g.enum_value)).map(g=>({type:g.type,...g.resource_name?{resource_name:g.resource_name}:{},...g.enum_value?{enum_value:g.enum_value}:{},...g.name?{name:g.name}:{},...g.negative===!0?{negative:!0}:{}})),u={...y};if(u.campaignName&&(u.campaignName=u.campaignName.trim()),u.geoTargets&&(u.geoTargets=u.geoTargets.filter(b=>b.trim())),u.languageTargets&&(u.languageTargets=u.languageTargets.filter(b=>b.trim())),u.pmaxAssetGroups&&(u.pmaxAssetGroups=u.pmaxAssetGroups.map(b=>{const g={...b};g.headlines&&(g.headlines=t(g.headlines)),g.longHeadlines&&(g.longHeadlines=t(g.longHeadlines)),g.descriptions&&(g.descriptions=t(g.descriptions)),g.searchThemes&&(g.searchThemes=g.searchThemes.filter(k=>
9k&&k.trim())),Array.isArray(g.audiences)&&(g.audiences=x(g.audiences));const O=b.__originalName||b.name,I=(g.name||"").trim();return delete g.__originalName,g.name=O,I&&I!==O&&(g.new_name=I),g})),je&&Array.isArray(u.adGroups)){const b=g=>{const O={...g||{}};return Array.isArray(O.headlines)&&(O.headlines=t(O.headlines)),Array.isArray(O.long_headlines)&&(O.long_headlines=t(O.long_headlines)),Array.isArray(O.descriptions)&&(O.descriptions=t(O.descriptions)),Array.isArray(O.videos)&&(O.videos=O.videos.filter(I=>I&&I.trim()).map(I=>I.trim())),Array.isArray(O.cards)&&(O.cards=O.cards.map(I=>({...I,headline:(I.headline||"").trim()}))),typeof O.name=="string"&&(O.name=O.name.trim(),O.name||delete O.name),O};u.adGroups=u.adGroups.map(g=>{const O=b(g.ad),I=Array.isArray(g.additionalAds)&&g.additionalAds.length?g.additionalAds.map(b):null,k=I?{ad:O,additionalAds:I}:{ad:O},H=g.__originalName||g.name,ye=(g.name||"").trim(),ue=g.assetAutomation?{assetAutomation:g.assetAutomation}:{};return we?{name:H,...k,...ue}:{name:H,...ye&&ye!==H?{new_name:ye}:{},...k,...ue,...g.channel_controls?{channel_controls:g.channel_controls}:{},...typeof g.optimized_targeting_enabled=="boolean"?{optimized_targeting_enabled:g.optimized_targeting_enabled}:{},...Array.isArray(g.audiences)?{audiences:g.audiences}:{},...Object.prototype.hasOwnProperty.call(g,"listingGroupFilter")?{listing_group_filter:g.listingGroupFilter??null}:{}}}),delete u.ad,delete u.adGroup}else u.adGroups&&(u.adGroups=u.adGroups.map(b=>{const g={...b};g.keywords&&(g.keywords=g.keywords.filter(k=>k.text?.trim())),g.ads&&(g.ads=g.ads.map(k=>{const H={...k,headlines:t(k.headlines),descriptions:t(k.descriptions)},ye=(Te,Fe)=>Array.isArray(Te)?Te.filter(ge=>ge&&typeof ge.text=="string"&&(Fe||[]).includes(ge.text.trim())).map(ge=>({...ge,text:ge.text.trim()})):void 0,ue=ye(H.pinnedHeadlines,H.headlines);ue!==void 0&&(H.pinnedHeadlines=ue);const X=ye(H.pinnedDescriptions,H.descriptions);return X!==void 0&&(H.pinnedDescriptions=X),H})),g.listingGroupFilter?.item_id&&(g.listingGroupFilter={...g.listingGroupFilter,item_id:g.listingGroupFilter.item_id.filter(k=>k&&k.trim()).map(k=>k.trim())});const O=b.__originalName||b.name,I=(g.name||"").trim();return delete g.__originalName,g.name=O,I&&I!==O&&(g.new_name=I),g}));u.sitelinks&&u.sitelinks.length>0&&(u.sitelinks=u.sitelinks.map(b=>({linkText:(b.linkText||"").trim(),finalUrl:(b.finalUrl||"").trim(),description1:(b.description1||"").trim(),description2:(b.description2||"").trim()})).filter(b=>b.linkText||b.finalUrl)),Array.isArray(u.callouts)&&(u.callouts=u.callouts.map(b=>String(b||"").trim()).filter(Boolean)),u.pmaxListingGroupFilters?.item_id&&(u.pmaxListingGroupFilters={...u.pmaxListingGroupFilters,item_id:u.pmaxListingGroupFilters.item_id.filter(b=>b&&b.trim()).map(b=>b.trim())}),u.shoppingProductFilters?.item_id&&(u.shoppingProductFilters={...u.shoppingProductFilters,item_id:u.shoppingProductFilters.item_id.filter(b=>b&&b.trim()).map(b=>b.trim())}),Array.isArray(u.audiences)&&(u.audiences=x(u.audiences)),Array.isArray(u.adGroups)&&(u.adGroups=u.adGroups.map(b=>Array.isArray(b.audiences)?{...b,audiences:x(b.audiences)}:b)),await p(a.id,u)&&(v(!1),B(null))}catch(t){J(t.errors||[t.message||"Failed to save changes"])}finally{ne(!1)}},oe=(t,x)=>B(u=>({...u,[t]:x})),ht=(t,x,u)=>B(D=>({...D,sitelinks:(D.sitelinks||[]).map((b,g)=>g===t?{...b,[x]:u}:b)})),Hr=()=>B(t=>({...t,sitelinks:[...t.sitelinks||[],{linkText:"",finalUrl:"",description1:"",description2:""}]})),Vr=t=>B(x=>({...x,sitelinks:(x.sitelinks||[]).filter((u,D)=>D!==t)})),yr=(t,x)=>oe("callouts",(y.callouts||[]).map((u,D)=>D===t?x:u)),bt=()=>oe("callouts",[...y.callouts||[],""]),fr=t=>oe("callouts",(y.callouts||[]).filter((x,u)=>u!==t)),He=(t,x,u)=>B(D=>{const b=(D.pmaxAssetGroups||[]).map((g,O)=>O===t?{...g,[x]:u}:g);return{...D,pmaxAssetGroups:b}}),vt=(t,x)=>B(u=>({...u,autoAssetSettings:{...u.autoAssetSettings,[t]:x}})),yt=(t,x,u)=>B(D=>{const b=D.adGroups.map((g,O)=>O===t?{...g,[x]:u}:g);return{...D,adGroups:b}}),We=(t,x,u,D)=>B(b=>{const g=b.adGroups.map((O,I)=>{if(I!==t)return O;const k=O.ads.map((H,ye)=>ye===x?{...H,[u]:D}:H);return{...O,ads:k}});return{...b,adGroups:g}}),Me=(t,x,u)=>B(D=>{const b=D.adGroups.map((g,O)=>O===t?{...g,[x]:u}:g);return{...D,adGroups:b}}),Ge=(t,x,u)=>{if(x===0)return{...t,ad:u(t.ad||{})};const D=Array.isArray(t.additionalAds)?t.additionalAds.slice():[];return D[x-1]=u(D[x-1]||{}),{...t,additionalAds:D}},Se=(t,x,u,D)=>B(b=>{const g=b.adGroups.map((O,I)=>I===t?Ge(O,x,k=>({...k,[u]:D})):O);return{...b,adGroups:g}}),Pt=(t,x,u,D,b)=>B(g=>{const O=g.adGroups.map((I,k)=>k===t?Ge(I,x,H=>({...H,cards:(H.cards||[]).map((ye,ue)=>ue===u?{...ye,[D]:b}:ye)})):I);return{...g,adGroups:O}}),$e=(t,x,u)=>B(D=>{const b=D.adGroups.map((g,O)=>{if(O!==t)return g;
9const k={...(g.channel_controls||{}).selected_channels||{}};return k[x]=u,{...g,channel_controls:{selected_channels:k}}});return{...D,adGroups:b}}),Gt=he?[{value:"MAXIMIZE_CLICKS",label:"Max. Clicks"},{value:"MANUAL_CPC",label:"Manual CPC"},{value:"TARGET_ROAS",label:"Target ROAS"}]:z?[{value:"MAXIMIZE_CONVERSIONS",label:"Max. Conversions"},{value:"MAXIMIZE_CONVERSION_VALUE",label:"Max. Conv. Value"},{value:"TARGET_CPA",label:"Target CPA"},{value:"TARGET_ROAS",label:"Target ROAS"}]:je?[{value:"MAXIMIZE_CONVERSIONS",label:"Max. Conversions"},{value:"MAXIMIZE_CONVERSION_VALUE",label:"Max. Conv. Value"},{value:"TARGET_CPA",label:"Target CPA"},{value:"TARGET_ROAS",label:"Target ROAS"},{value:"MAXIMIZE_CLICKS",label:"Max. Clicks"},{value:"TARGET_CPC",label:"Target CPC"}]:[{value:"MAXIMIZE_CONVERSIONS",label:"Max. Conversions"},{value:"MAXIMIZE_CONVERSION_VALUE",label:"Max. Conv. Value"},{value:"MAXIMIZE_CLICKS",label:"Max. Clicks"},{value:"TARGET_CPA",label:"Target CPA"},{value:"TARGET_ROAS",label:"Target ROAS"},{value:"MANUAL_CPC",label:"Manual CPC"}],qe=be&&n._clone?.biddingLabel?[{value:n.biddingStrategy,label:n._clone.biddingLabel},...Gt.filter(t=>t.value!==n.biddingStrategy)]:Gt,lt={draft:{color:"text-amber-400 bg-amber-400/10 border-amber-400/20",label:"Draft"}
9,modified:{color:"text-sky-400 bg-sky-400/10 border-sky-400/20",label:"Modified"},approved:{color:"text-emerald-400 bg-emerald-400/10 border-emerald-400/20",label:"Approved"},deploying:{color:"text-purple-400 bg-purple-400/10 border-purple-400/20",label:"Deploying..."},deployed:{color:"text-emerald-400 bg-emerald-400/10 border-emerald-400/20",label:"Deployed"},failed:{color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},rejected:{color:"text-[var(--text-tertiary)] bg-[var(--bg-overlay)] border-[var(--border-medium)]",label:"Rejected"}},Ve=lt[a.status]||lt.draft,ot=n._deployed?._cloneDeploy||null,Ot=n._deployed?._biddingFallback||null,jr=ot&&e.jsxs("div",{className:"mt-1.5 p-2 rounded-lg bg-sky-500/5 border border-sky-500/15 text-[11px] space-y-1.5",children:[e.jsx("div",{className:"text-sky-300 font-medium uppercase tracking-wide text-[10px]",children:"Clone outcome"}),ot.warnings?.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[var(--text-tertiary)] font-medium uppercase tracking-wide text-[10px] mb-0.5",children:"Warnings"}),e.jsx("ul",{className:"space-y-0.5 text-amber-400/90",children:ot.warnings.map((t,x)=>e.jsx("li",{children:t},x))})]}),ot.notCopied?.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[var(--text-tertiary)] font-medium uppercase tracking-wide text-[10px] mb-0.5",children:"Not copied"}),e.jsx("ul",{className:"space-y-0.5 text-amber-400/90",children:ot.notCopied.map((t,x)=>e.jsx("li",{children:t},x))})]}),ot.relinkErrors?.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[var(--text-tertiary)] font-medium uppercase tracking-wide text-[10px] mb-0.5",children:"Relink errors"}),e.jsx("ul",{className:"space-y-0.5 text-red-400/90",children:ot.relinkErrors.map((t,x)=>e.jsx("li",{children:t?.category?`${t.category}: ${t.error}`:t?.error||String(t)},x))})]}),Ot?.to&&e.jsxs("div",{className:"text-amber-400/90",children:["Bidding differs from the source: ",Ot.from?`${Ot.from} → `:"",Ot.to]})]});return e.jsx(xe.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"rounded-2xl border border-[var(--border-subtle)] overflow-hidden bg-[var(--bg-elevated)]",style:{boxShadow:"0 8px 32px var(--shadow-color)"},children:e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(St,{size:16,className:"text-[var(--accent-blue-bright)] shrink-0"}),e.jsx("span",{className:"font-medium text-[var(--text-primary)] truncate",children:le?`${Ie?"RSA":we?"New Ad":Re?"Ad Group":"Asset Group"} → ${n.targetAdGroupName||n.targetCampaignName||"Existing Campaign"}`:a.title||n.campaignName})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-xs text-[var(--text-tertiary)]",children:[le&&e.jsx("span",{className:"px-2 py-0.5 rounded bg-purple-500/15 text-purple-400 border border-purple-500/20",children:"ADD TO EXISTING"}),e.jsx("span",{className:"px-2 py-0.5 rounded bg-[var(--bg-overlay)]",children:n.campaignType}),n.campaignSubType!=="STANDARD"&&e.jsx("span",{className:"px-2 py-0.5 rounded bg-[var(--bg-overlay)]",children:n.campaignSubType?.replace("_"," ")}),be&&e.jsxs("span",{className:"px-2 py-0.5 rounded bg-sky-500/15 text-sky-400 border border-sky-500/20",children:["COPY OF ",n._clone.sourceCampaignName]}),!le&&e.jsx("span",{children:n.dailyBudget?`${n.dailyBudget}/day`:""})]})]}),e.jsx("span",{className:`shrink-0 px-2.5 py-1 rounded-full text-xs font-medium border ${Ve.color}`,children:Ve.label})]}),he&&n.includesScript&&n.scriptCode&&e.jsx(Ps,{script:n.scriptCode}),hr&&e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg border mb-3 text-xs ${nt?"bg-amber-400/5 border-amber-400/25":"bg-[var(--bg-overlay)] border-[var(--border-subtle)]"}`,children:[n.logoUrl?e.jsx("img",{src:n.logoUrl,alt:"Logo",className:"w-10 h-10 rounded-lg object-cover border border-[var(--border-subtle)] shrink-0 bg-[var(--bg-overlay)]"}):e.jsx("div",{className:"w-10 h-10 rounded-lg border border-dashed border-amber-400/40 flex items-center justify-center shrink-0",children:e.jsx(mt,{size:16,className:"text-amber-400/70"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-[var(--text-secondary)]",children:"Logo"}),n.logoUrl&&n.logoKeptByCampaign?e.jsx("div",{className:"text-amber-400/90",title:n.logoUrl,children:"Wird nicht hinzugefügt — die Kampagne hat eigene Logos auf Kampagnenebene, die jede Asset Group zeigt."}):n.logoUrl?e.jsx("div",{className:"text-[var(--text-tertiary)] truncate",title:n.logoUrl,children:fs[n.logoSource]||n.logoUrl}):e.jsx("div",{className:"text-amber-400/90",children:"Logo fehlt — für PMax erforderlich (1:1, min. 128×128)"})]}),e.jsxs("button",{onClick:()=>A(a.id),className:`shrink-0 flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition border ${nt?"bg-amber-400/10 text-amber-400 hover:bg-amber-400/20 border-amber-400/25":"bg-[var(--accent-blue)]/10 text-[var(--accent-blue-bright)] hover:bg-[var(--accent-blue)]/20 border-[var(--accent-blue)]/20"}`,children:[e.jsx(mt,{size:13})," ",n.logoUrl?"Logo ändern":"Logo wählen"]})]}),Dt&&e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg border mb-3 text-xs ${Be?"bg-[var(--bg-overlay)] border-[var(--border-subtle)]":"bg-
9amber-400/5 border-amber-400/25"}`,children:[Be?e.jsx("img",{src:Be,alt:"Logo",className:"w-10 h-10 rounded-lg object-cover border border-[var(--border-subtle)] shrink-0 bg-[var(--bg-overlay)]"}):e.jsx("div",{className:"w-10 h-10 rounded-lg border border-dashed border-amber-400/40 flex items-center justify-center shrink-0",children:e.jsx(mt,{size:16,className:"text-amber-400/70"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-[var(--text-secondary)]",children:"Logo"}),Be?e.jsx("div",{className:"text-[var(--text-tertiary)] truncate",title:Be,children:fs[n.logoSource]||Be}):e.jsx("div",{className:"text-amber-400/90",children:"Logo fehlt — für Demand Gen erforderlich (1:1, min. 128×128)"})]}),e.jsxs("button",{onClick:()=>A(a.id,"dg"),className:`shrink-0 flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition border ${Be?"bg-[var(--accent-blue)]/10 text-[var(--accent-blue-bright)] hover:bg-[var(--accent-blue)]/20 border-[var(--accent-blue)]/20":"bg-amber-400/10 text-amber-400 hover:bg-amber-400/20 border-amber-400/25"}`,children:[e.jsx(mt,{size:13})," ",Be?"Logo ändern":"Logo wählen"]})]}),gr&&Tt&&["draft","modified","approved","failed"].includes(a.status)&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-lg bg-amber-400/5 border border-amber-400/25 mb-3 text-xs",children:[e.jsx(qt,{size:14,className:"text-amber-400 shrink-0 mt-0.5"}),e.jsx("div",{className:"text-amber-400/90",children:"Business Name fehlt — bitte im Editor (Edit) setzen (max. 25 Zeichen)."})]}),e.jsxs("button",{onClick:()=>{T||w(!M)},className:"text-xs text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] flex items-center gap-1 transition mb-2",children:[e.jsx(cs,{size:12,className:`transition-transform ${M?"rotate-90":""}`}),T?le?Ie?"Editing RSA ad...":we?"Editing ad...":Re?"Editing ad group...":"Editing asset group...":"Editing campaign...":M?"Hide details":"Show details"]}),e.jsx(Je,{children:M&&e.jsx(xe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:T&&y?e.jsxs("div",{className:"space-y-4 text-xs pb-3",children:[le?e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(Aa,{size:12})," ",Ie?"RSA Settings":we?"Ad Settings":Re?"Ad Group Settings":"Asset Group Settings"]}),n.targetCampaignName&&e.jsxs("div",{className:"text-[var(--text-tertiary)] text-[11px]",children:["Target campaign: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:n.targetCampaignName})," ",e.jsxs("span",{className:"text-[var(--text-tertiary)]",children:["(ID: ",n.targetCampaignId,")"]})]}),we&&n.targetAdGroupName&&e.jsxs("div",{className:"text-[var(--text-tertiary)] text-[11px]",children:["Target ad group: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:n.targetAdGroupName})," ",e.jsxs("span",{className:"text-[var(--text-tertiary)]",children:["(ID: ",n.targetAdGroupId,")"]})]})]}):e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(Aa,{size:12})," Campaign Settings"]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Campaign Name"}),e.jsx("input",{value:y.campaignName||"",onChange:t=>oe("campaignName",t.target.value),className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Daily Budget (€)"}),e.jsx("input",{type:"number",min:"1",step:"1",value:y.dailyBudget||"",onChange:t=>oe("dailyBudget",parseFloat(t.target.value)||0),className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Bidding Strategy"}),e.jsx(wt,{options:qe,value:y.biddingStrategy||"",onChange:t=>oe("biddingStrategy",t)})]})]}),(y.biddingStrategy==="TARGET_CPA"||y.biddingStrategy==="TARGET_ROAS"||y.biddingStrategy==="TARGET_CPC")&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:y.bid
9dingStrategy==="TARGET_CPA"?"Target CPA (€)":y.biddingStrategy==="TARGET_CPC"?"Target CPC (€)":"Target ROAS (%)"}),e.jsx("input",{type:"number",min:"0",step:y.biddingStrategy==="TARGET_ROAS"?"1":"0.1",value:y.biddingStrategy==="TARGET_ROAS"?ns(y.biddingTarget):y.biddingTarget||"",onChange:t=>oe("biddingTarget",y.biddingStrategy==="TARGET_ROAS"?Cn(t.target.value):parseFloat(t.target.value)||0),className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]}),y.biddingStrategy==="MANUAL_CPC"&&e.jsxs(e.Fragment,{children:[!he&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Default CPC (€)"}),e.jsx("input",{type:"number",min:"0.01",step:"0.1",value:y.defaultCpc??1,onChange:t=>oe("defaultCpc",parseFloat(t.target.value)||1),className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"enhancedCpc",checked:y.enhancedCpc??!1,onChange:t=>oe("enhancedCpc",t.target.checked),className:"rounded border-[var(--border-medium)] bg-[var(--bg-overlay)]"}),e.jsx("label",{htmlFor:"enhancedCpc",className:"text-[var(--text-secondary)] text-xs",children:"Enhanced CPC"})]})]}),y.biddingStrategy==="MAXIMIZE_CLICKS"&&!he&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Max CPC Limit (€, optional)"}),e.jsx("input",{type:"number",min:"0",step:"0.1",value:y.maxCpcLimit||"",onChange:t=>oe("maxCpcLimit",parseFloat(t.target.value)||0),placeholder:"No limit",className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition placeholder:text-[var(--text-tertiary)]"})]}),he&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Default CPC (€)"}),e.jsx("input",{type:"number",min:"0.01",step:"0.1",value:y.defaultCpc??1,onChange:t=>oe("defaultCpc",parseFloat(t.target.value)||1),className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Campaign Priority"}),e.jsx(wt,{options:[{value:0,label:"Low (0)"},{value:1,label:"Medium (1)"},{value:2,label:"High (2)"}],value:y.campaignPriority??0,onChange:t=>oe("campaignPriority",Number(t))})]})]}),y.biddingStrategy==="MAXIMIZE_CLICKS"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Max CPC Limit (€, optional)"}),e.jsx("input",{type:"number",min:"0",step:"0.1",value:y.maxCpcLimit||"",onChange:t=>oe("maxCpcLimit",parseFloat(t.target.value)||0),placeholder:"No limit",className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition placeholder:text-[var(--text-tertiary)]"})]})]}),Fr&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Feed Label (optional)"}),e.jsx("input",{type:"text",value:y.feedLabel||"",onChange:t=>oe("feedLabel",t.target.value.toUpperCase().replace(/[^A-Z0-9_-]/g,"").slice(0,20)),placeholder:`Default: ${(y.geoTargets?.[0]||"DE").toString().toUpperCase()}`,maxLength:20,className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition placeholder:text-[var(--text-tertiary)] uppercase"}),e.jsx("div",{className:"text-[var(--text-tertiary)] text-[10px] mt-0.5",children:"Targets a specific Merchant Center feed. Leave blank to derive from the first geo target. Max 20 chars: A-Z / 0-9 / hyphen / underscore."})]}),a.availableConversionActions?.length>0&&(()=>{const t=new Map;for(const b of a.availableConversionActions){if(!b||!b.category)continue;const g=b.category;t.has(g)||t.set(g,{primary:0,total:0});const O=t.get(g);O.total++,b.isPrimary&&O.primary++}const x=[...t.entries()].filter(([,b])=>b.primary>0).sort((b,g)=>g[1].primary-b[1].primary||b[0].localeCompare(g[0]));if(x.length===0)return null;const u=new Set(Array.isArray(y.conversionGoalCategories)?y.conversionGoalCategories:[]),D=b=>{const g=new Set(u);g.has(b)?g.delete(b):g.add(b),oe("conversionGoalCategories",[...g]),y.conversionActionId&&oe("conversionActionId",null)};return e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Conversion Goals (categories)"}),e.jsx("div",{className:"space-y-1 max-h-[280px] overflow-y-auto pr-1",children:x.map(([b,g])=>{const O=u.has(b);return e.jsxs("label",{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 rounded-lg border cursor-pointer transition ${O?"bg-[var(--accent-blue)]/10 border-[var(--accent-blue)]/30":"bg-[var(--bg-overlay)] border-[var(--border-subtle)] hover:border-[var(--border-medium)]"}`,children:[e.jsxs("span",{className:"flex items-center gap-2 text-xs text-[var(--text-primary)]",children:[e.jsx("input",{type:"checkbox",checked:O,onChange:()=>D(b),className:"rounded border-[var(--border-medium)] bg-[var(--bg-overlay)]"}),e.jsx("span",{children:ba(b)})]}),e.jsxs("span",{className:"text-[10px] text-[var(--text-tertiary)]",children:[g.primary," primary",g.total>g.primary?` · ${g.total-g.primary} secondary`:""]})]},b)})}),e.jsx("div",{className:"text-[var(--text-tertiary)] text-[10px] mt-1",children:"Google Ads optimizes at the category level — every primary action in a selected category counts. Pick multiple categories if you want the campaign to bid on more than one goal type."})]})})()]}),he&&n.includesScript&&n.scriptCode&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(Ta,{size:12})," Exclusion Script"]}),e.jsx(Ns,{text:n.scriptCode,label:"Copy"})]}),e.jsx("pre",{className:"max-h-64 overflow-auto text-[10px] font-mono leading-snug p-2 rounded bg-[var(--bg-overlay-heavy)] border border-[var(--border-subtle)] whitespace-pre-wrap text-[var(--text-secondary)]",children:n.scriptCode}),Array.isArray(n.scriptAllowlist)&&n.scriptAllowlist.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-[var(--text-tertiary)] text-[11px] mb-1.5 flex items-center justify-between gap-2",children:[e.jsx("span",{children:"Brand-Allowlist — already included in the script's OK_TERMS array (edit the script to add typos/sub-brands):"}),e.jsx(Ns,{text:n.scriptAllowlist.join(`
10`),label:"Copy list"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.scriptAllowlist.map((t,x)=>e.jsx("span",{className:"px-2 py-0.5 rounded bg-[var(--bg-overlay-heavy)] border border-[var(--border-subtle)] text-[10px] font-mono text-[var(--text-secondary)]",children:t},x))})]})]}),!le&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(ds,{size:12})," Targeting"]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Locations"}),e.jsx(nr,{tags:y.geoTargets||[],onChange:t=>oe("geoTargets",t),placeholder:"Add location..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Languages"}),e.jsx(Gn,{languages:U.languages,loading:U.loading,selected:y.languageTargets||[],onChange:t=>oe("languageTargets",t),valueKey:"code"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Location matching"}),e.jsx(wt,{options:[{value:"PRESENCE",label:"Presence (in location only)"},{value:"PRESENCE_OR_INTEREST",label:"Presence or interest"}],value:y.positiveGeoTargetType||"PRESENCE",onChange:t=>oe("positiveGeoTargetType",t)})]})]}),!le&&(n.campaignType==="SEARCH"||he)&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-2",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(Mr,{size:12})," Network"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"searchPartners",checked:y.networkSettings?.searchNetwork===!0,onChange:t=>oe("networkSettings",{...y.networkSettings||{},searchNetwork:t.target.checked}),className:"rounded border-[var(--border-medium)] bg-[var(--bg-overlay)]"}),e.jsx("label",{htmlFor:"searchPartners",className:"text-[var(--text-secondary)] text-xs",children:"Include Google Search Partners"})]}),n.campaignType==="SEARCH"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"displayNetwork",checked:y.networkSettings?.displayNetwork===!0,onChange:t=>oe("networkSettings",{...y.networkSettings||{},displayNetwork:t.target.checked}),className:"rounded border-[var(--border-medium)] bg-[var(--bg-overlay)]"}),e.jsx("label",{htmlFor:"displayNetwork",className:"text-[var(--text-secondary)] text-xs",children:"Include Display Network"})]}),e.jsx("div",{className:"text-[var(--text-tertiary)] text-[10px] mt-0.5",children:"Defaults off (audit rule N — partners/display often waste budget on Search campaigns). Turn on only after testing."})]}),(()=>{const t=ae||z?"pmaxListingGroupFilters":he?"shoppingProductFilters":null,x=t?y[t]:null;return!t||!Zt(x)?null:e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(xt,{size:12,className:"text-[var(--accent-blue-bright)]"})," Product Filters"]}),Wt(x)?e.jsxs("div",{className:"text-xs text-[var(--text-secondary)]",children:[rt(x),e.jsx("div",{className:"text-[11px] text-[var(--text-tertiary)] mt-1",children:"Nested filter — edit via chat (multi-level trees aren't inline-editable here)."})]}):Object.entries(x).map(([u,D])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[var(--text-tertiary)]",children:u}),Array.isArray(D)?e.jsx(nr,{tags:D,onChange:b=>oe(t,{...x,[u]:b}),placeholder:`Add ${u}...`}):e.jsx("input",{className:"w-full bg-[var(--bg-overlay)] border border-[var(--border-subtle)] rounded-lg px-3 py-1.5 text-sm text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]",value:D||"",onChange:b=>oe(t,{...x,[u]:b.target.value})})]},u))]})})(),!je&&!z&&!le&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-2",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(kt,{size:12})," Zielgruppen ",z?"(Signale)":""]}),e.jsx(ir,{items:y.audiences,onChange:t=>oe("audiences",t),googleAdsAccountId:f||a.googleAdsAccountId,showMode:!z,servingMode:y.audienceServingMode,onModeChange:t=>oe("audienceServingMode",t),allowNegative:!z,allowSavedAudiences:z,showSavedAudiences:z,allowCombined:!1,allowCustom:z}),z&&y.audiences?.length>0&&e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)]",children:"PMax-Zielgruppen sind Signale (Startempfehlung für Google) — keine Einschränkung der Auslieferung."})]}),y.adGroups?.map((t,x)=>e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] mb-1",children:["Ad Group: ",t.name]}),!je&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Ad Group Name"}),e.jsx("input",{value:t.name||"",onChange:u=>yt(x,"name",u.target.value),className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]}),t.keywords?.length>0&&e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Keywords (",t.keywords.length,")"]}),e.jsx(ol,{keywords:t.keywords,onChange:u=>yt(x,"keywords",u)})]}),n.campaignType==="SEARCH"&&e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] flex items-center gap-1 mb-1",children:[e.jsx(kt,{size:11})," Zielgruppen dieser Anzeigengruppe"]}),e.jsx(ir,{items:t.audiences,onChange:u=>yt(x,"audiences",u),googleAdsAccountId:f||a.googleAdsAccountId,showMode:!0,servingMode:t.audie
10nceServingMode,onModeChange:u=>yt(x,"audienceServingMode",u),allowNegative:!0,allowCombined:!1,allowCustom:!1,targetingScope:"Diese Anzeigengruppe wird"}),(y.audiences||[]).some(u=>u&&!u.negative)&&(t.audiences||[]).some(u=>u&&!u.negative)&&e.jsxs("div",{className:"text-[10px] text-amber-500 flex items-start gap-1 mt-1",children:[e.jsx(qt,{size:10,className:"mt-0.5 shrink-0"}),"Google erlaubt eingeschlossene Zielgruppen nur auf einer Ebene — Kampagne oder Anzeigengruppen. Ausschlüsse gehen auf beiden."]})]}),t.ads?.map((u,D)=>e.jsxs("div",{className:"space-y-3 pt-2 border-t border-[var(--border-subtle)]",children:[e.jsxs("div",{className:"text-[var(--text-tertiary)] text-[11px]",children:["RSA Ad ",D+1]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Final URL — where this ad sends people"}),e.jsx("input",{value:u.finalUrl||"",onChange:b=>We(x,D,"finalUrl",b.target.value),placeholder:"https://...",className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Headlines (",u.headlines?.length||0,") — max 30 chars · pin = fixed position"]}),e.jsx(ut,{items:u.headlines||[],onChange:b=>We(x,D,"headlines",b),maxLen:30,placeholder:"Headline...",addLabel:"Add Headline",effectiveLen:is,pins:Tr(u.pinnedHeadlines),pinOptions:["HEADLINE_1","HEADLINE_2","HEADLINE_3"],onPinChange:b=>We(x,D,"pinnedHeadlines",ls(b))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Descriptions (",u.descriptions?.length||0,") — max 90 chars"]}),e.jsx(ut,{items:u.descriptions||[],onChange:b=>We(x,D,"descriptions",b),maxLen:90,placeholder:"Description...",addLabel:"Add Description",effectiveLen:is,pins:Tr(u.pinnedDescriptions),pinOptions:["DESCRIPTION_1","DESCRIPTION_2"],onPinChange:b=>We(x,D,"pinnedDescriptions",ls(b))})]})]},D))]},x)),y.pmaxAssetGroups?.length>0&&n.campaignType==="PERFORMANCE_MAX"&&!ae&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsx("div",{className:"font-medium text-[var(--text-secondary)] mb-1",children:"Brand Settings"}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Business Name"}),e.jsx("input",{value:y.businessName||"",onChange:t=>oe("businessName",t.target.value),className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]})]}),y.pmaxAssetGroups?.map((t,x)=>e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] mb-1",children:["Asset Group ",y.pmaxAssetGroups.length>1?`${x+1}: `:"",t.name||""]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Asset Group Name"}),e.jsx("input",{value:t.name||"",onChange:u=>He(x,"name",u.target.value),className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]}),z&&t._cloneTreeSummary&&e.jsxs("div",{className:"text-[11px] text-sky-300/90",children:["Product filter: ",t._cloneTreeSummary]}),z&&!t._cloneTreeSummary&&Wt(t.pmaxListingGroupFilters)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block",children:"Products (listing group filter)"}),e.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:rt(t.pmaxListingGroupFilters)}),e.jsx("div",{className:"text-[11px] text-[var(--text-tertiary)]",children:"Nested filter — edit via chat (multi-level trees aren't inline-editable here)."})]}),z&&!t._cloneTreeSummary&&!Wt(t.pmaxListingGroupFilters)&&t.pmaxListingGroupFilters&&Object.keys(t.pmaxListingGroupFilters).length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block",children:"Products (listing group filter)"}),Object.entries(t.pmaxListingGroupFilters).map(([u,D])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[var(--text-tertiary)]",children:u}),Array.isArray(D)?e.jsx(nr,{tags:D,onChange:b=>He(x,"pmaxListingGroupFilters",{...t.pmaxListingGroupFilters,[u]:b}),placeholder:`Add ${u}...`}):e.jsx("input",{className:"w-full bg-[var(--bg-overlay)] border border-[var(--border-subtle)] rounded-lg px-3 py-1.5 text-sm text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]",value:D||"",onChange:b=>He(x,"pmaxListingGroupFilters",{...t.pmaxListingGroupFilters,[u]:b.target.value})})]},u))]}),z&&!t._cloneTreeSummary&&t.pmaxListingGroupFilters===null&&y.pmaxAssetGroups?.length>1&&e.jsxs("div",{className:"text-[var(--text-tertiary)] text-xs",children:["Products: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:"All products (catch-all)"})]}),!ae&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Final URL"}),e.jsx("input",{value:t.finalUrl||"",onChange:u=>He(x,"finalUrl",u.target.value),className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Headlines (",t.headlines?.length||0,") — max 30 chars"]}),e.jsx(ut,{items:t.headlines||[],onChange:u=>He(x,"headlines",u),maxLen:30,placeholder:"Headline...",addLabel:"Add Headline"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Long Headlines (",t.longHeadlines?.length||0,") — max 90 chars"]}),e.jsx(ut,{items:t.longHeadlines||[],onChange:u=>He(x,"longHeadlines",u),maxLen:90,placeholder:"Long headline...",addLabel:"Add Long Headline"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Descriptions (",t.descriptions?.length||0,") — max 90 chars"]}),e.jsx(ut,{items:t.descriptions||[],onChange:u=>He(x,"descriptions",u),maxLen:90,placeholder:"Description...",addLabel:"Add Description"})]}),t.imageUrls?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Images: ",e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[t.imageUrls.length," attached"]})]}),t.videoUrls?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Videos: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:t.videoUrls.length})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Search Themes (",t.searchThemes?.length||0,"/25)"]}),e.jsx(nr,{tags:t.searchThemes||[],onChange:u=>He(x,"searchThemes",u),placeholder:"Add search theme..."})]}),z&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] flex items-center gap-1",children:[e.jsx(kt,{size:11})," Zielgruppen-Signal"]}),e.jsx(ir,{items:Array.isArray(t.audiences)?t.audiences:y.audiences||[],onChange:u=>He(x,"audiences",u),googleAdsAccountId:f||a.googleAdsAccountId,showMode:!1,allowNegative:!1,allowSavedAudiences:!0,showSavedAudiences:!0,allowCombined:!1,allowCustom:!0,addLabel:"Zielgruppe wählen"}
10),!Array.isArray(t.audiences)&&(y.audiences||[]).length>0&&e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)]",children:"Gilt für alle Asset Groups dieses Entwurfs ohne eigenes Signal."})]})]},x)),!le&&(n.campaignType==="SEARCH"||n.campaignType==="PERFORMANCE_MAX"&&n.campaignSubType!=="SHOPPING_ONLY")&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(Lr,{size:12,className:"text-[var(--accent-blue-bright)]"}),"Sitelinks (",(y.sitelinks||[]).length,")"]}),(y.sitelinks||[]).map((t,x)=>{const u=!!(t.assetId||t.asset_id);return e.jsxs("div",{className:"p-2 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-[11px] text-[var(--text-tertiary)]",children:["Sitelink ",x+1]}),u&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--accent-blue)]/10 text-[var(--accent-blue-bright)] border border-[var(--accent-blue)]/20",title:`Reused account asset (asset_id: ${t.assetId||t.asset_id})`,children:"Already in your account"})]}),e.jsx("button",{type:"button",onClick:()=>Vr(x),className:"text-[var(--text-tertiary)] hover:text-red-400 transition",children:e.jsx(Ee,{size:12})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-0.5",children:"Link text (max 25)"}),e.jsx("input",{value:t.linkText||"",onChange:D=>ht(x,"linkText",D.target.value),className:"w-full px-2.5 py-1 rounded bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40",placeholder:"e.g. Prices"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-0.5",children:"URL"}),e.jsx("input",{value:t.finalUrl||"",onChange:D=>ht(x,"finalUrl",D.target.value),className:"w-full px-2.5 py-1 rounded bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40",placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-0.5",children:"Description 1 (max 35)"}),e.jsx("input",{value:t.description1||"",onChange:D=>ht(x,"description1",D.target.value),className:"w-full px-2.5 py-1 rounded bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-0.5",children:"Description 2 (max 35)"}),e.jsx("input",{value:t.description2||"",onChange:D=>ht(x,"description2",D.target.value),className:"w-full px-2.5 py-1 rounded bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40"})]})]},x)}),e.jsxs("button",{type:"button",onClick:Hr,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] text-[var(--accent-blue-bright)]/80 hover:bg-[var(--accent-blue)]/10 border border-[var(--accent-blue)]/20 transition",children:[e.jsx(Ke,{size:12})," Add Sitelink"]})]}),!le&&n.campaignType==="SEARCH"&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(wa,{size:12,className:"text-[var(--accent-blue-bright)]"}),"Callouts (",(y.callouts||[]).length,")"]}),(y.callouts||[]).length===1&&e.jsx("div",{className:"text-[11px] text-amber-400/90",children:"Google needs at least 2 callouts to show them — add one more."}),(y.callouts||[]).map((t,x)=>{const u=(t||"").length,D=u>25;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:t||"",onChange:b=>yr(x,b.target.value),placeholder:"e.g. Free shipping",className:`flex-1 px-2.5 py-1 rounded bg-[var(--bg-overlay)] border text-xs text-[var(--text-primary)] focus:outline-none ${D?"border-red-400/50 focus:border-red-400/60":"border-[var(--border-subtle)] focu
10s:border-[var(--accent-blue)]/40"}`}),e.jsxs("span",{className:`text-[11px] tabular-nums w-10 text-right ${D?"text-red-400":"text-[var(--text-tertiary)]"}`,children:[u,"/25"]}),e.jsx("button",{type:"button",onClick:()=>fr(x),className:"text-[var(--text-tertiary)] hover:text-red-400 transition",children:e.jsx(Ee,{size:12})})]},x)}),e.jsxs("button",{type:"button",onClick:bt,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] text-[var(--accent-blue-bright)]/80 hover:bg-[var(--accent-blue)]/10 border border-[var(--accent-blue)]/20 transition",children:[e.jsx(Ke,{size:12})," Add Callout"]})]}),!le&&y.autoAssetSettings&&n.campaignType==="PERFORMANCE_MAX"&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)]",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5 mb-2",children:[e.jsx(xr,{size:12})," Asset Optimization"]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(at,{label:"Text Optimization",checked:!!y.autoAssetSettings.textAutoGeneration,onChange:t=>vt("textAutoGeneration",t)}),e.jsx(at,{label:"Image Enhancement",checked:!!y.autoAssetSettings.imageAutoGeneration,onChange:t=>vt("imageAutoGeneration",t)}),e.jsx(at,{label:"Video Auto-Generation",checked:!!y.autoAssetSettings.videoAutoGeneration,onChange:t=>vt("videoAutoGeneration",t)}),e.jsx(at,{label:"Final URL Expansion",checked:!!y.autoAssetSettings.finalUrlExpansion,onChange:t=>vt("finalUrlExpansion",t)})]})]}),je&&y.adGroups?.map((t,x)=>{const u=t.format==="VIDEO",D=t.format==="CAROUSEL",g=t.format==="PRODUCT"?1:5,O=[t.ad||{},...Array.isArray(t.additionalAds)?t.additionalAds:[]],I="w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition placeholder:text-[var(--text-tertiary)]";return e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(mt,{size:12})," ",we?"New Ad":`Ad Group${y.adGroups.length>1?` ${x+1}`:""}`]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[O.length>1&&e.jsxs("span",{className:"text-[10px] text-[var(--text-tertiary)]",children:[O.length," ads"]}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--accent-blue)]/10 text-[var(--accent-blue-bright)] border border-[var(--accent-blue)]/20",children:t.format})]})]}),!we&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Ad Group Name"}),e.jsx("input",{value:t.name||"",onChange:k=>Me(x,"name",k.target.value),className:I})]}),O.map((k,H)=>{const ye=D?k.logo_image_url?1:0:k.logo_image_urls?.length||0,ue=[["Landscape",k.marketing_image_urls?.length||0],["Square",k.square_marketing_image_urls?.length||0],["Portrait",k.portrait_marketing_image_urls?.length||0],["Tall portrait",k.tall_portrait_marketing_image_urls?.length||0]].filter(([,X])=>X>0);return e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-3",children:[e.jsx("div",{className:"text-[11px] font-medium text-[var(--text-secondary)]",children:O.length>1?`Ad ${H+1} of ${O.length}`:"Ad"}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Ad name — Google can't rename an ad once it's live"}),e.jsx("input",{value:k.name||"",maxLength:255,onChange:X=>Se(x,H,"name",X.target.value),placeholder:"Name of the ad in Google Ads",className:I})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Business Name (max 25)"}),e.jsx("input",{value:k.business_name||"",maxLength:25,onChange:X=>Se(x,H,"business_name",X.target.value),className:I})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Final URL"}),e.jsx("input",{value:k.final_url||"",onChange:X=>Se(x,H,"final_url",X.target.value),className:I})]}),D?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Ad Headline (max 40) — shown on every card"}),e.jsx("input",{value:k.ad_headline||"",maxLength:40,onChange:X=>Se(x,H,"ad_headline",X.target.value),className:I})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Ad Description (max 90)"}),e.jsx("input",{value:k.ad_description||"",maxLength:90,onChange:X=>Se(x,H,"ad_description",X.target.value),className:I})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"CTA text"}),e.jsx("input",{value:k.ad_call_to_action_text||"",onChange:X=>Se(x,H,"ad_call_to_action_text",X.target.value),placeholder:"e.g. Shop now",className:I})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Card aspect ratio"}),e.jsx(wt,{options:[{value:"SQUARE_1_1",label:"Square 1:1"}
10,{value:"LANDSCAPE_1_91_1",label:"Landscape 1.91:1"}],value:k.card_aspect_ratio||"SQUARE_1_1",onChange:X=>Se(x,H,"card_aspect_ratio",X)})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Cards (",(k.cards||[]).length,") — 2–10, each needs a unique image"]}),e.jsx("div",{className:"space-y-2",children:(k.cards||[]).map((X,Te)=>e.jsxs("div",{className:"p-2 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-1.5",children:[e.jsxs("div",{className:"text-[10px] text-[var(--text-tertiary)]",children:["Card ",Te+1," ",X.marketing_image_url?"· image ✓":"· image missing"]}),e.jsx("input",{value:X.headline||"",maxLength:40,onChange:Fe=>Pt(x,H,Te,"headline",Fe.target.value),placeholder:"Card headline (max 40)",className:"w-full px-2.5 py-1 rounded bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40"}),e.jsx("input",{value:X.call_to_action_text||"",onChange:Fe=>Pt(x,H,Te,"call_to_action_text",Fe.target.value),placeholder:"Card CTA (optional)",className:"w-full px-2.5 py-1 rounded bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 placeholder:text-[var(--text-tertiary)]"})]},Te))}),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] mt-1",children:"Card images are managed via chat or the image picker."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Headlines (",(k.headlines||[]).length,"/",g,") — max 40 chars"]}),e.jsx(ut,{items:k.headlines||[],onChange:X=>Se(x,H,"headlines",X),maxLen:40,maxItems:g,placeholder:"Headline...",addLabel:"Add Headline"})]}),u&&e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Long Headlines (",(k.long_headlines||[]).length,"/5) — max 90 chars"]}),e.jsx(ut,{items:k.long_headlines||[],onChange:X=>Se(x,H,"long_headlines",X),maxLen:90,maxItems:5,placeholder:"Long headline...",addLabel:"Add Long Headline"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Descriptions (",(k.descriptions||[]).length,"/",g,") — max 90 chars"]}),e.jsx(ut,{items:k.descriptions||[],onChange:X=>Se(x,H,"descriptions",X),maxLen:90,maxItems:g,placeholder:"Description...",addLabel:"Add Description"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:"Call to Action"}),u?e.jsx(wt,{options:ul,value:k.call_to_action||"",onChange:X=>Se(x,H,"call_to_action",X),placeholder:"Select CTA"}):e.jsx("input",{value:k.call_to_action||"",onChange:X=>Se(x,H,"call_to_action",X.target.value),placeholder:"e.g. Shop now",className:I})]}),u&&e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["YouTube Videos (",(k.videos||[]).length,"/5) — paste a link"]}),e.jsx(nr,{tags:k.videos||[],onChange:X=>Se(x,H,"videos",(X||[]).map(dl)),placeholder:"Paste a YouTube link…"}),(k.videos||[]).length>0&&e.jsx("div",{className:"mt-1 space-y-0.5",children:(k.videos||[]).map((X,Te)=>e.jsxs("a",{href:`https://youtu.be/${X}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-[10px] text-[var(--accent-blue-bright)] hover:underline truncate",children:[e.jsx(Lr,{size:9,className:"flex-shrink-0"})," youtu.be/",X]},Te))})]})]}),e.jsxs("div",{className:"text-[11px] text-[var(--text-tertiary)] pt-1 border-t border-[var(--border-subtle)] space-y-0.5",children:[e.jsxs("div",{children:["Logo",ye===1?"":"s",": ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:ye})]}),ue.length>0&&e.jsxs("div",{children:["Marketing images: ",ue.map(([X,Te])=>`${X} ${Te}`).join(" · ")]})]})]},H)}),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] opacity-80",children:"Images & logos are managed via chat or the image picker."}),Pr[t.format]&&e.jsxs("div",{className:"pt-2 border-t border-[var(--border-subtle)] space-y-1",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(xr,{size:12})," Asset optimization"]}),e.jsx("div",{className:"space-y-0.5",children:Pr[t.format].map(k=>e.jsx(at,{label:k.label,checked:t.assetAutomation?.[k.key]===!0,onChange:H=>Me(x,"assetAutomation",{...t.assetAutomation||{},[k.key]:H})},k.key))})]}),!we&&(()=>
10{const k=t.channel_controls||{},H=k.selected_channels||{},ye=!!k.selected_channels;return e.jsxs("div",{className:"pt-2 border-t border-[var(--border-subtle)] space-y-2",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(ur,{size:12})," Channels & Targeting"]}),ye?e.jsx("div",{className:"space-y-0.5",children:ya.map(ue=>e.jsx(at,{label:ue.label,checked:!!H[ue.key],onChange:X=>$e(x,ue.key,X)},ue.key))}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(wt,{options:Is,value:k.strategy||Ds,onChange:ue=>Me(x,"channel_controls",{strategy:ue})})}),e.jsx("button",{type:"button",onClick:()=>Me(x,"channel_controls",{selected_channels:ya.reduce((ue,X)=>({...ue,[X.key]:!0}),{})}),className:"px-2.5 py-1 rounded-lg text-[11px] text-[var(--accent-blue-bright)]/80 hover:bg-[var(--accent-blue)]/10 border border-[var(--accent-blue)]/20 transition",children:"Customize channels"})]}),e.jsx(at,{label:"Optimized targeting (Google expands audience)",checked:(t.optimized_targeting_enabled??t.optimizedTargetingEnabled)!==!1,onChange:ue=>Me(x,"optimized_targeting_enabled",ue)}),(()=>{const ue=Array.isArray(t.audiences)?t.audiences:[],X=ue.filter(ge=>ge&&!ge.negative),Te=ue.filter(ge=>ge&&ge.negative),Fe=f||a.googleAdsAccountId;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsxs("div",{className:"text-[11px] font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(kt,{size:11})," Zielgruppen"]}),e.jsx(ir,{items:X,onChange:ge=>Me(x,"audiences",[...ge.map(ft=>{const{negative:Yr,...er}=ft;return er}),...Te]),googleAdsAccountId:Fe,allowCombined:!1,allowSavedAudiences:!0,addLabel:"Zielgruppe hinzufügen"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-[11px] font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(kt,{size:11,className:"text-red-400"})," Ausschlüsse ",e.jsx("span",{className:"text-[10px] font-normal text-[var(--text-tertiary)]",children:"(nur Listen)"})]}),e.jsx(ir,{items:Te,onChange:ge=>Me(x,"audiences",[...X,...ge.map(ft=>({...ft,negative:!0}))]),googleAdsAccountId:Fe,userListsOnly:!0,hideNegativePrefix:!0,addLabel:"Ausschluss hinzufügen",pickerTitle:"Listen zum Ausschließen"})]})]})})()]})})(),!we&&(y.productFeed||t.format==="PRODUCT"||Re)&&e.jsxs("div",{className:"pt-2 border-t border-[var(--border-subtle)] space-y-1.5",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(xt,{size:12})," Products"]}),Re&&!y.productFeed&&!n.targetCampaignHasProductFeed&&e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)]",children:"Only applies if the target campaign has a Merchant Center product feed attached."}),t._cloneTreeSummary?e.jsxs("div",{className:"text-[11px] text-sky-300/90",children:["Product filter: ",t._cloneTreeSummary]}):ms(t.listingGroupFilter)===null?e.jsxs("div",{className:"text-[11px] text-[var(--text-secondary)]",children:[rt(t.listingGroupFilter),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] mt-0.5",children:"Advanced filter (exclusions / uncommon dimensions) — edit via chat."})]}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-tertiary)] min-w-0 truncate",title:rt(t.listingGroupFilter),children:Zt(t.listingGroupFilter)?e.jsx("span",{className:"text-[var(--text-secondary)]",children:rt(t.listingGroupFilter)}):"All products"}),e.jsx("button",{type:"button",onClick:()=>Br(x),className:"px-2.5 py-1 rounded-lg text-[11px] text-[var(--accent-blue-bright)]/80 hover:bg-[var(--accent-blue)]/10 border border-[var(--accent-blue)]/20 transition whitespace-nowrap",children:"Choose products"})]})]})]},x)}),je&&pe!=null&&y?.adGroups?.[pe]&&e.jsx(mi,{open:!0,value:ms(y.adGroups[pe].listingGroupFilter)||{},options:ze,loading:L,error:re,onRetry:it,onClose:()=>fe(null),onSave:t=>Me(pe,"listingGroupFilter",t),onServerSearch:async t=>(await te.getDraftProductFilterValues(a.id,t)).items||[]}),je&&!le&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-2",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(ur,{size:12})," Targeting"]}),e.jsx(at,{label:"View-through conversion optimization (beta)",checked:y.viewThroughOptimization!==!1,onChange:t=>oe("viewThroughOptimization",t)})]}),je&&!le&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-2",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5",children:[e.jsx(xt,{size:12})," Retail (Merchant Center feed)"]}),e.jsx(at,{label:"Attach product feed",checked:!!y.productFeed,onChange:t=>oe("productFeed",t?{merchantId:y.productFeed?.merchantId||"",feedLabel:y.productFeed?.feedLabel||""}:null)}),y.productFeed&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[11px] text-[var(--text-tertiary)]",children:"Merchant Center is resolved automatically from Google Ads at deploy — leave both blank. Only fill them to pin a 
10specific MC (multi-MC account) or a custom feed-label split."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Merchant ID ",e.jsx("span",{className:"opacity-70",children:"(optional)"})]}),e.jsx("input",{value:y.productFeed.merchantId||"",onChange:t=>oe("productFeed",{...y.productFeed,merchantId:t.target.value.replace(/[^0-9]/g,"")}),placeholder:"auto",className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition placeholder:text-[var(--text-tertiary)]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[var(--text-tertiary)] text-[11px] block mb-1",children:["Feed Label ",e.jsx("span",{className:"opacity-70",children:"(optional)"})]}),e.jsx("input",{value:y.productFeed.feedLabel||"",onChange:t=>oe("productFeed",{...y.productFeed,feedLabel:t.target.value.toUpperCase().replace(/[^A-Z0-9_-]/g,"").slice(0,20)}),placeholder:"whole feed",className:"w-full px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition placeholder:text-[var(--text-tertiary)] uppercase"})]})]})]})]}),R?.length>0&&e.jsxs("div",{className:"p-2.5 rounded-lg bg-red-500/10 border border-red-500/20 text-xs text-red-400",children:[e.jsx("div",{className:"font-medium mb-1",children:"Validation errors:"}),e.jsx("ul",{className:"list-disc list-inside space-y-0.5",children:R.map((t,x)=>e.jsx("li",{children:t},x))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-2 border-t border-[var(--border-subtle)]",children:[e.jsxs("button",{onClick:vr,disabled:_,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-lg bg-[var(--accent-blue)]/15 text-[var(--accent-blue-bright)] hover:bg-[var(--accent-blue)]/25 border border-[var(--accent-blue)]/25 text-xs font-medium transition disabled:opacity-40",children:[_?e.jsx(Ae,{size:14,className:"animate-spin"}):e.jsx(De,{size:14})," Save Changes"]}),e.jsx("button",{onClick:br,disabled:_,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] text-[var(--text-tertiary)] hover:bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs font-medium transition disabled:opacity-40",children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-3 text-xs pb-2",children:[!je&&n.adGroups?.map((t,x)=>e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)]",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] mb-2",children:["Ad Group",n.adGroups.length>1?` ${x+1}`:"",": ",t.name]}),he&&e.jsxs("div",{className:"mb-1",children:[t._cloneTreeSummary?e.jsxs("span",{className:"text-[11px] text-sky-300/90",children:["Product filter: ",t._cloneTreeSummary]}):Zt(t.listingGroupFilter)?e.jsxs("span",{className:"text-[var(--text-tertiary)]",children:["Filter:"," ",Wt(t.listingGroupFilter)?e.jsx("span",{className:"text-[var(--text-secondary)]",children:rt(t.listingGroupFilter)}):Object.entries(t.listingGroupFilter).map(([u,D],b,g)=>e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[u," = ",Array.isArray(D)?D.join(", "):D,b<g.length-1?" · ":""]},u))]}):e.jsx("span",{className:"text-[var(--text-tertiary)] italic",children:"Catch-all (all products not matched by other ad groups)"}),(t.defaultCpc!=null||t.maxCpcLimit!=null)&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mt-1",children:[t.defaultCpc!=null&&e.jsxs(e.Fragment,{children:["Default CPC: ",e.jsxs("span",{className:"text-[var(--text-secondary)]",children:["€",t.defaultCpc]})]}),t.defaultCpc!=null&&t.maxCpcLimit!=null&&" · ",t.maxCpcLimit!=null&&e.jsxs(e.Fragment,{children:["Max CPC: ",e.jsxs("span",{className:"text-[var(--text-secondary)]",children:["€",t.maxCpcLimit]})]})]})]}),!he&&t.keywords?.length>0&&e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"Keywords: "}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t.keywords.map(u=>`[${u.matchType}] ${u.text}`).join(", ")})]}
10),!he&&e.jsx(ys,{audiences:t.audiences,servingMode:t.audienceServingMode,className:"mb-2"}),!he&&t.ads?.map((u,D)=>e.jsxs("div",{className:"mt-2 pl-3 border-l border-[var(--border-subtle)]",children:[e.jsx("div",{className:"text-[var(--text-tertiary)] mb-1",children:"RSA Ad:"}),u.finalUrl&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mb-1 truncate",children:["URL: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:u.finalUrl})]}),e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Headlines: ",(u.headlines||[]).map(b=>{const g=Tr(u.pinnedHeadlines)[b];return g?`${b} [${Na[g]}]`:b}).join(" | ")]}),e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Descriptions: ",(u.descriptions||[]).map(b=>{const g=Tr(u.pinnedDescriptions)[b];return g?`${b} [${Na[g]}]`:b}).join(" | ")]})]},D))]},x)),n.businessName&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Business: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:n.businessName})]}),n.pmaxAssetGroups?.map((t,x)=>e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)]",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] mb-2",children:["Asset Group",n.pmaxAssetGroups.length>1?` ${x+1}`:"",": ",t.name||""]}),t.finalUrl&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mb-1 truncate",children:["URL: ",e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t.finalUrl})]}),t.headlines?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mb-1",children:["Headlines: ",t.headlines.join(" | ")]}),t.longHeadlines?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mb-1",children:["Long Headlines: ",t.longHeadlines.join(" | ")]}),t.descriptions?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mb-1",children:["Descriptions: ",t.descriptions.join(" | ")]}),t.imageUrls?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mb-1",children:["Images: ",t.imageUrls.length]}),t.videoUrls?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mb-1",children:["Videos: ",t.videoUrls.length]}),t.searchThemes?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Search Themes: ",e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t.searchThemes.join(", ")})]}),z&&(Array.isArray(t.audiences)?t.audiences:n.audiences||[]).length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mt-1",children:["Zielgruppen-Signal: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:(Array.isArray(t.audiences)?t.audiences:n.audiences).map(u=>u.name||u.resource_name).join(", ")})]}),t._cloneTreeSummary&&e.jsxs("div",{className:"text-[11px] text-sky-300/90 mt-1",children:["Product filter: ",t._cloneTreeSummary]}),!t._cloneTreeSummary&&Zt(t.pmaxListingGroupFilters)&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mt-1",children:["Products: ",Wt(t.pmaxListingGroupFilters)?e.jsx("span",{className:"text-[var(--text-secondary)]",children:rt(t.pmaxListingGroupFilters)}):Object.entries(t.pmaxListingGroupFilters).map(([u,D])=>e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[u,": ",Array.isArray(D)?D.join(", "):D]},u))]}),!t._cloneTreeSummary&&t.pmaxListingGroupFilters===null&&e.jsxs("div",{className:"text-[var(--text-tertiary)] mt-1",children:["Products: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:"All products"})]})]},x)),je&&st.map((t,x)=>{const u=[t.ad||{},...Array.isArray(t.additionalAds)?t.additionalAds:[]],D=t.format==="CAROUSEL",b=t.channel_controls?.selected_channels||{},g=ya.filter(I=>b[I.key]).map(I=>I.label),O=(t.optimizedTargetingEnabled??t.optimized_targeting_enabled)!==!1;return e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-2",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] flex items-center gap-1.5 flex-wrap",children:["Ad Group",st.length>1?` ${x+1}`:"",": ",t.name,e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--accent-blue)]/10 text-[var(--accent-blue-bright)] border border-[var(--accent-blue)]/20",children:t.format}),u.length>1&&e.jsxs("span",{className:"text-[10px] text-[var(--text-tertiary)]",children:[u.length," ads"]})]}),e.jsxs("div",{className:"space-y-1",children:[Pr[t.format]&&(()=>{const I=Pr[t.format].filter(k=>t.assetAutomation?.[k.key]===!0).map(k=>k.label);return e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Asset optimization: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.length?I.join(", "):"Off"})]})})(),!we&&e.jsxs(e.Fragment,{children:[t.geoTargets?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Geo: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:t.geoTargets.join(", ")})]}),t.languageTargets?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Language: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:t.languageTargets.join(", ")})]}),t._cloneTreeSummary&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Product filter: ",e.jsx("span",{className:"text-sky-300/90",children:t._cloneTreeSummary})]}),!t._cloneTreeSummary&&(Qe||Zt(t.listingGroupFilter))&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Products: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:Zt(t.listingGroupFilter)?rt(t.listingGroupFilter):"All products"})]}),g.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Channels: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:g.join(", ")})]}
10),!t.channel_controls?.selected_channels&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Channels: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:cl(t.channel_controls?.strategy)})]}),e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Optimized targeting: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:O?"On":"Off"})]}),(()=>{const I=(t.audiences||[]).filter(H=>H&&!H.negative),k=(t.audiences||[]).filter(H=>H&&H.negative);return e.jsxs(e.Fragment,{children:[I.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Audiences: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.map(H=>H.name||H.resource_name||H.enum_value).join(", ")})]}),k.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Exclusions: ",e.jsx("span",{className:"text-red-400",children:k.map(H=>H.name||H.resource_name||H.enum_value).join(", ")})]})]})})()]})]}),e.jsx("div",{className:"space-y-2",children:u.map((I,k)=>{const H=D?I.logo_image_url?1:0:I.logo_image_urls?.length||0;return e.jsxs("div",{className:"p-2.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] space-y-1",children:[e.jsx("div",{className:"text-[11px] font-medium text-[var(--text-secondary)]",children:u.length>1?`Ad ${k+1} of ${u.length}`:"Ad"}),I.name?e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Ad name: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.name})]}):e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Ad name: ",e.jsx("span",{className:"italic",children:"not set — give it one in Edit before deploying; Google can't rename an ad later"})]}),I.business_name&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Business: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.business_name})]}),I.final_url&&e.jsxs("div",{className:"text-[var(--text-tertiary)] truncate",children:["URL: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.final_url})]}),I.headlines?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Headlines: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.headlines.join(" | ")})]}),I.long_headlines?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Long Headlines: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.long_headlines.join(" | ")})]}),I.ad_headline&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Headline: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.ad_headline})]}),I.descriptions?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Descriptions: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.descriptions.join(" | ")})]}),I.ad_description&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Description: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.ad_description})]}),(I.call_to_action||I.ad_call_to_action_text)&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["CTA: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.call_to_action||I.ad_call_to_action_text})]}),I.videos?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Videos:"," ",I.videos.map((ye,ue)=>e.jsxs("span",{children:[ue>0&&", ",e.jsxs("a",{href:`https://youtu.be/${ye}`,target:"_blank",rel:"noopener noreferrer",className:"text-[var(--accent-blue-bright)] hover:underline",children:["youtu.be/",ye]})]},ue))]}),I.cards?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Cards: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:I.cards.length})]}),e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Logo",H===1?"":"s",": ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:H})]})]},k)})})]},x)}),je&&!le&&st.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["View-through optimization: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:n.viewThroughOptimization!==!1?"On":"Off"})]}),je&&!le&&Qe&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Product feed: ",e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[Qe.merchantId||e.jsx("span",{className:"italic",children:"account catalog (auto-resolved at deploy)"}),Qe.feedLabel?` · ${Qe.feedLabel}`:""]})]}),!le&&n.sitelinks?.length>0&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)]",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] mb-2 flex items-center gap-1.5",children:[e.jsx(Lr,{size:12,className:"text-[var(--accent-blue-bright)]"}),"Sitelinks (",n.sitelinks.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:n.sitelinks.map((t,x)=>{const u=!!(t.assetId||t.asset_id);return e.jsx("div",{className:"flex items-start gap-2 pl-2 border-l border-[var(--border-subtle)]",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-[var(--text-secondary)] font-medium",children:t.linkText}),u&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--accent-blue)]/10 text-[var(--accent-blue-bright)] border border-[var(--accent-blue)]/20",title:`Reused account asset (asset_id: ${t.assetId||t.asset_id})`,children:"Already in your account"})]}),t.description1&&e.jsx("div",{className:"text-[var(--text-tertiary)]",children:t.description1}),t.description2&&e.jsx("div",{className:"text-[var(--text-tertiary)]",children:t.description2}),e.jsx("div",{className:"text-[var(--text-tertiary)] truncate",children:t.finalUrl})]})},x)})})]}),!le&&n.callouts?.length>0&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)]",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] mb-2 flex items-center gap-1.5",children:[e.jsx(wa,{size:12,className:"text-[var(--accent-blue-bright)]"}),"Callouts (",n.callouts.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.callouts.map((t,x)=>e.jsx("span",{className:"px-2 py-0.5 rounded bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-[var(--text-secondary)]",children:t},x))}),n.callouts.length===1&&e.jsx("div",{className:"text-[11px] text-amber-400/90 mt-2",children:"Google needs at least 2 callouts to 
10show them."})]}),pr&&Ct&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)]",children:[e.jsxs("div",{className:"font-medium text-[var(--text-secondary)] mb-2 flex items-center gap-1.5",children:[e.jsx(xt,{size:12,className:"text-[var(--accent-blue-bright)]"}),"Product Filter"]}),e.jsx("div",{className:"text-[var(--text-tertiary)] text-[11px] mb-2",children:Wt(ke)?e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-[var(--bg-overlay)] border border-[var(--border-subtle)]",children:e.jsx("span",{className:"text-[var(--text-secondary)]",children:rt(ke)})}):Object.entries(ke).map(([t,x])=>e.jsxs("span",{className:"inline-flex items-center gap-1 mr-2 px-2 py-0.5 rounded bg-[var(--bg-overlay)] border border-[var(--border-subtle)]",children:[e.jsxs("span",{className:"text-[var(--text-tertiary)]",children:[t,":"]})," ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:Array.isArray(x)?x.join(", "):x})]},t))}),e.jsxs("button",{onClick:()=>Q(!ce),className:"text-[11px] text-[var(--accent-blue-bright)] hover:text-[var(--accent-blue-bright)]/80 flex items-center gap-1 transition",children:[e.jsx(ja,{size:11}),j?"Loading products...":P?`${P.total||P.products?.length||0} matching products`:"Show matching products",e.jsx(cs,{size:10,className:`transition-transform ${ce?"rotate-90":""}`})]}),e.jsx(Je,{children:ce&&P&&e.jsxs(xe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:[P.message&&!P.products?.length&&e.jsx("div",{className:"text-[var(--text-tertiary)] text-[11px] mt-2",children:P.message}),P.products?.length>0&&e.jsxs("div",{className:"mt-2 max-h-[300px] overflow-y-auto space-y-1 pr-1 custom-scrollbar",children:[P.products.map((t,x)=>e.jsxs("div",{className:"flex items-center gap-2 p-1.5 rounded-lg bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay)] border border-[var(--border-subtle)] transition group",children:[t.imageLink?e.jsx("img",{src:t.imageLink.replace(/^http:\/\//i,"https://"),alt:"",className:"w-8 h-8 rounded object-cover bg-[var(--bg-overlay)] shrink-0",referrerPolicy:"no-referrer",crossOrigin:"anonymous",onError:u=>{u.target.onerror=null,u.target.src="",u.target.className="w-8 h-8 rounded bg-[var(--bg-overlay)] shrink-0"}}):e.jsx("div",{className:"w-8 h-8 rounded bg-[var(--bg-overlay)] flex items-center justify-center shrink-0",children:e.jsx(ja,{size:12,className:"text-[var(--text-tertiary)]"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[var(--text-secondary)] text-[11px] truncate leading-tight",children:t.title}),e.jsxs("div",{className:"text-[var(--text-tertiary)] text-[10px] flex items-center gap-2",children:[e.jsx("span",{children:t.offerId}),t.brand&&e.jsxs("span",{children:["· ",t.brand]}),t.price&&e.jsxs("span",{children:["· ",t.price]})]})]}),e.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded shrink-0 ${t.availability==="in_stock"||t.availability==="in stock"?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20":"bg-amber-500/10 text-amber-400 border border-amber-500/20"}`,children:t.availability==="in_stock"||t.availability==="in stock"?"In stock":t.availability||"—"})]},t.id||x)),P.truncated&&e.jsxs("div",{className:"text-[var(--text-tertiary)] text-[10px] text-center py-1",children:["Showing 200 of ",P.total," products"]})]})]})})]}),ae&&!Ct&&e.jsxs("div",{className:"text-[var(--text-tertiary)] text-[11px] flex items-center gap-1.5",children:[e.jsx(xt,{size:11}),"All products from the feed will be included"]}),le&&n.targetCampaignName&&e.jsxs("div",{className:"text-[var(--text-tertiary)] text-[11px]",children:["Target campaign: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:n.targetCampaignName})," ",e.jsxs("span",{className:"text-[var(--text-tertiary)]",children:["(ID: ",n.targetCampaignId,")"]})]}),!le&&n.biddingStrategy&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Bidding: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:be&&n._clone?.biddingLabel?n._clone.biddingLabel:e.jsxs(e.Fragment,{children:[n.biddingStrategy,n.biddingTarget?` (target: ${n.biddingStrategy==="TARGET_ROAS"?`${ns(n.biddingTarget)}%`:n.biddingTarget})`:"",n.enhancedCpc?" (eCPC)":"",n.maxCpcLimit?` (max CPC: €${n.maxCpcLimit})`:""]})})]}),be&&n._clone.pendingReplacement&&(n._clone.pendingReplacement.failed===!0?e.jsxs("div",{className:"text-[11px] text-amber-400 bg-amber-500/10 border border-amber-500/20 rounded-lg px-2 py-1.5",children:["Creative import #",n._clone.pendingReplacement.importId," failed: ",n._clone.pendingReplacement.failedReason," — re-import the creative and clone again."]}):e.jsxs("div",{className:"text-[11px] text-amber-400 bg-amber-500/10 border border-amber-500/20 rounded-lg px-2 py-1.5",children:["Creative import #",n._clone.pendingReplacement.importId," is still running — the imported images/videos replace the source's the next time this draft is opened. Group-level edits you make before it finishes are replaced by the imported creative."]})),be&&n._clone.alsoCopied?.length>0&&e.jsxs("div",{className:"text-[11px]",children:[e.jsx("div",{className:"text-[var(--text-tertiary)] font-medium uppercase tracking-wide text-[10px] mb-0.5",children:"Also copied 1:1 (not editable here)"}),e.jsx("ul",{className:"space-y-0.5 text-[var(--text-secondary)]",children:n._clone.alsoCopied.map((t,x)=>e.jsxs("li",{className:"flex gap-1.5",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-sky-4
1000/60 shrink-0 mt-[6px]"}),e.jsx("span",{children:t})]},x))})]}),be&&n._clone.notCopied?.length>0&&e.jsxs("div",{className:"text-[11px]",children:[e.jsx("div",{className:"text-[var(--text-tertiary)] font-medium uppercase tracking-wide text-[10px] mb-0.5",children:"Not copied"}),e.jsx("ul",{className:"space-y-0.5 text-amber-400/90",children:n._clone.notCopied.map((t,x)=>e.jsxs("li",{className:"flex gap-1.5",children:[e.jsx("span",{className:"shrink-0",children:"⚠"}),e.jsx("span",{children:t})]},x))})]}),!le&&(()=>{const t=Array.isArray(n.conversionGoalCategories)?n.conversionGoalCategories:null;if(t&&t.length>0){const b=new Map;for(const O of a.availableConversionActions||[])!O?.category||!O.isPrimary||b.set(O.category,(b.get(O.category)||0)+1);const g=t.map(O=>`${ba(O)} (${b.get(O)||0} primary)`).join(", ");return e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Conversion goals: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:g})]})}if(!n.conversionActionId)return e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Conversion goal: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:"Account defaults"})]});const x=a.availableConversionActions?.find(b=>String(b.id)===String(n.conversionActionId)),u=x?.name||n.conversionActionName,D=x?.category||n.conversionActionCategory;return u?e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Conversion goal: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:D?`${ba(D)} — ${u}`:u})]}):null})(),he&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Default CPC: ",e.jsxs("span",{className:"text-[var(--text-secondary)]",children:["€",n.defaultCpc??1]})," · Priority: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:["Low","Medium","High"][n.campaignPriority]||(n.campaignPriority??"Low")})]}),Fr&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Feed Label: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:n.feedLabel||e.jsx("span",{className:"italic",children:"auto (from first geo)"})})]}),!le&&n.geoTargets?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)] flex items-center gap-1",children:[e.jsx(ds,{size:12}),"Locations: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:n.geoTargets.join(", ")})]}),!le&&n.languageTargets?.length>0&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Languages: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:n.languageTargets.join(", ")})]}),!le&&!z&&!je&&e.jsx(ys,{audiences:n.audiences,servingMode:n.audienceServingMode}),!le&&n.positiveGeoTargetType&&n.positiveGeoTargetType!=="PRESENCE"&&e.jsxs("div",{className:"text-[var(--text-tertiary)]",children:["Location matching: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:"Presence or Interest"})]}),!le&&(n.networkSettings?.searchNetwork===!0||n.networkSettings?.displayNetwork===!0)&&e.jsxs("div",{className:"text-[var(--text-tertiary)] flex items-center gap-1",children:[e.jsx(Mr,{size:12}),"Network: ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:[n.networkSettings?.searchNetwork?"Search Partners":null,n.networkSettings?.displayNetwork?"Display Network":null].filter(Boolean).join(" + ")})]})]})})}),!T&&a.warnings?.length>0&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-lg bg-amber-400/5 border border-amber-400/10 mb-3 text-xs",children:[e.jsx(qt,{size:14,className:"text-amber-400 shrink-0 mt-0.5"}),e.jsx("div",{className:"text-amber-400/80",children:a.warnings.join("; ")})]}),!T&&$.length>0&&e.jsx("div",{className:"p-2 rounded-lg bg-red-500/5 border border-red-500/20 mb-3 text-xs",children:e.jsxs("div",{className:"flex items-start gap-2 text-red-400",children:[e.jsx(qt,{size:14,className:"shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium mb-1",children:"Objections recorded — approved as asked, read before deploying"}),e.jsx("ul",{className:"space-y-0.5 text-red-400/90",children:$.map((t,x)=>e.jsxs("li",{children:[t.text?`"${t.text}" — `:"",t.evidence||t.reason||t.rule]},x))})]})]})}),!T&&a.status==="failed"&&a.deployError&&e.jsxs("div",{className:"flex items-start gap-2 p-2.5 rounded-lg bg-red-500/5 border border-red-500/20 mb-3 text-xs",children:[e.jsx(_r,{size:14,className:"text-red-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Deployment rejected"}),a.deployErrorGuidance&&e.jsxs("div",{className:"mb-2 pb-2 border-b border-red-500/10",children:[e.jsx("div",{className:"text-red-300 leading-snug mb-1",children:a.deployErrorGuidance.headline}),Array.isArray(a.deployErrorGuidance.whatToCheck)&&a.deployErrorGuidance.whatToCheck.length>0&&e.jsx("ul",{className:"list-disc list-inside space-y-0.5 text-red-400/75 text-[11px] leading-snug",children:a.deployErrorGuidance.whatToCheck.map((t,x)=>e.jsx("li",{children:t},x))}),e.jsxs("div",{className:"text-red-400/60 text-[11px] mt-1 italic",children:[a.deployErrorGuidance.retryLikelyHelps===!0&&"Worth trying again once you've checked the above.",a.deployErrorGuidance.retryLikelyHelps===!1&&"Deploying again will produce the same error until this is fixed.",a.deployErrorGuidance.retryLikelyHelps==="unknown"&&"Not clear yet whether retrying will help — check the details above first."]})]}),a.deployError.split(/;\s+(?=\S)/).map((t,x)=>e.jsx("div",{className:"text-red-400/85 leading-snug break-words font-mono text-[11px]",children:t.trim()},x))]})]}),!T&&a.status==="failed"&&jr,!T&&["draft","modified","approved","failed"].includes(a.status)&&e.jsx("div",{className:"pt-2 border-t border-[var(--border-subtle)] mb-2",children:e.jsxs("p",{className:"text-[11px] text-[var(--text-tertiary)]",children:[n.campaignType==="SEARCH"&&!Re&&e.jsxs(e.Fragment,{children:["1 Search campaign · ",(n.adGroups||[]).length," ad group",(n.adGroups||[]).length!==1?"s":""," · ",(n.adGroups||[]).reduce((t,x)=>t+(x.keywords||[]).length,0)," keywords"]}),n.campaignType==="SEARCH"&&Re&&e.jsxs(e.Fragment,{children:["Ad group → ",n.targetCampaignName||"existing campaign"," · ",(n.adGroups||[]).reduce((t,x)=>t+(x.keywords||[]).length,0)," keywords"]}),n.campaignType==="PERFORMANCE_MAX"&&!le&&e.jsxs(e.Fragment,{children:["1 PMax campaign · ",Math.max((n.pmaxAssetGroups||[]).length,1)," asset group",Math.max((n.pmaxAssetGroups||[]).length,1)!==1?"s":"",ae&&P?.total!=null&&e.jsxs(e.Fragment,{children:[" · ",P.total," product",P.total!==1?"s":""]})]}),he&&e.jsxs(e.Fragment,{children:["1 Shopping campaign · ",Math.max((n.adGroups||[]).length,1)," ad group",Math.max((n.adGroups||[]).length,1)!==1?"s":"",P?.total!=null&&e.jsxs(e.Fragment,{children:[" · ",P.total," product",P.total!==1?"s":""]})]}),Ue&&e.jsxs(e.Fragment,{children:["Asset group → ",n.targetCampaignName||"existing campaign"," · ",n.campaignSubType?.replace("_"," ")]}),(n.sitelinks||[]).length>0&&e.jsxs(e.Fragment,{children:[" · ",(n.sitelinks||[]).length," sitelink",(n.sitelinks||[]).length!==1?"s":""]}),(n.callouts||[]).length>0&&e.jsxs(e.Fragment,{children:[" · ",(n.callouts||[]).length," callout",(n.callouts||[]).length!==1?"s":""]}),!le&&n.dailyBudget!=null&&e.jsxs(e.Fragment,{children:[" · €",Number(n.dailyBudget).toFixed(2),"/day"]})]})}),!T&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-2 border-t border-[var(--border-subtle)]",children:[["draft","modified","failed"].includes(a.status)&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:It,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[var(--accent-blue)]/10 text-[var(--accent-blue-bright)] hover:bg-[var(--accent-blue)]/20 border border-[var(--accent-blue)]/20 text-xs font-medium transition",children:[e.jsx(Ts,{size:14})," Edit"]}),e.jsxs("button",{onClick:()=>i(a.id),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20 border border-emerald-500/20 text-xs font-medium transition",children:[e.jsx(De,{size:14})," Approve"]}),e.jsxs("button",{onClick:()=>m(a.id),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20 text-xs font-medium transition",children:[e.jsx(_r,{size:14})," Reject"]})]}),a.status==="approved"&&e.jsxs("button",{onClick:()=>h(a.id,q?"PAUSED":"ENABLED"),disabled:Pe,title:Pe?Lt:void 0,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[var(--accent-blue)]/10 text-[var(--accent-blue-bright)] hover:bg-[var(--accent-blue)]/20 border border-[var(--accent-blue)]/20 text-xs font-medium transition disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(St,{size:14})," ",Ie?"Deploy RSA":we?"Deploy Ad":Re?"Deploy Ad Group":Ue?"Deploy Asset Group":q?"Deploy Paused":"Deploy & Launch"]}
10),["approved","failed"].includes(a.status)&&!le&&e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-[var(--text-tertiary)] cursor-pointer select-none",title:"Create the campaign paused so you can review it in Google Ads first. Ask the advisor to enable it when you're ready.",children:[e.jsx("input",{type:"checkbox",checked:q,onChange:t=>F(t.target.checked),className:"accent-[var(--accent-blue)] cursor-pointer"}),be?"Deploy paused (recommended for a copy — the source keeps running)":"Deploy paused"]}),a.status==="failed"&&e.jsxs("button",{onClick:()=>h(a.id,q?"PAUSED":"ENABLED"),disabled:Pe,title:Pe?Lt:void 0,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-amber-500/10 text-amber-400 hover:bg-amber-500/20 border border-amber-500/20 text-xs font-medium transition disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(St,{size:14})," Retry Deploy"]}),["approved","failed"].includes(a.status)&&Pe&&e.jsx("span",{className:"text-[11px] text-amber-400/90",children:Lt}),a.status==="deployed"&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-emerald-400",children:[e.jsx(De,{size:14})," ",(()=>{const t=a.deployStatus||a.structure?._deployed?._deployStatus;return t==="PAUSED"?"Deployed (Paused)":t==="ENABLED"?"Deployed (Live)":"Deployed"})()]}),(()=>{const t=a.biddingFallback||a.structure?._deployed?._biddingFallback;return t?.to?e.jsxs("div",{className:"text-[11px] text-amber-400/90",children:["Bidding changed: ",t.from?`${t.from} → `:"now running ",t.to," — this account is not eligible for the approved strategy. Switch it back once it qualifies."]}):null})(),jr,(a.deployedCampaignId||a.structure?.campaignName)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[a.structure?.campaignName&&e.jsx("span",{className:"text-[var(--text-secondary)]",children:a.structure.campaignName}),a.deployedCampaignId&&e.jsxs("a",{href:`https://ads.google.com/aw/campaigns?campaignId=${a.deployedCampaignId}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[var(--accent-blue-bright)] hover:underline",children:[e.jsx(Lr,{size:12})," Open in Google Ads"]})]})]})]})]})})}function ml({fullText:a,onComplete:i,onProgress:m}){const h=o.useMemo(()=>{const w=[];let T=a;for(;T.length>0;){const v=T.match(/^(\|[^\n]*\n?)+/);if(v){w.push(v[0]),T=T.slice(v[0].length),T.startsWith(`
11`)&&(T=T.slice(1));continue}const U=T.indexOf(`
12
13`);if(U===-1){w.push(T);break}w.push(T.slice(0,U)),T=T.slice(U+2)}return w},[a]),[p,A]=o.useState(0),f=o.useRef(!1);o.useEffect(()=>{A(0),f.current=!1},[a]),o.useEffect(()=>{if(f.current)return;if(p>=h.length){f.current=!0,i?.();return}const w=h[p],T=w.trimStart().startsWith("|"),v=p===0?0:T?200:Math.min(60+w.length*.3,180),U=setTimeout(()=>{A(_=>_+1),m?.()},v);return()=>clearTimeout(U)},[p,h,i,m]);const n=h.slice(0,p).join(`
14
15`),M=p<h.length;return e.jsxs("div",{className:"relative",children:[e.jsx(Qt,{remarkPlugins:[$t],components:or,children:Xt(cr(n))}),M&&e.jsx("span",{className:"inline-block w-[3px] h-[14px] bg-[var(--accent-blue)] rounded-full ml-0.5 animate-pulse align-middle"})]})}function Ns({text:a,label:i="Copy"}){const[m,h]=o.useState(!1),p=A=>{A.stopPropagation(),!(typeof a!="string"||!a)&&(navigator.clipboard.writeText(a),h(!0),setTimeout(()=>h(!1),1600))};return e.jsxs("button",{onClick:p,className:`inline-flex items-center gap-1 px-2 py-1 rounded text-[10px] border transition shrink-0 ${m?"bg-emerald-500/15 text-emerald-300 border-emerald-500/25":"bg-[var(--bg-overlay-heavy)] text-[var(--text-secondary)] border-[var(--border-subtle)] hover:bg-[var(--bg-overlay)]"}`,children:[m?e.jsx(De,{size:11}):e.jsx(Ea,{size:11}),m?"Copied":i]})}function Ps({script:a}){const[i,m]=o.useState(!1),h=()=>{navigator.clipboard.writeText(a),m(!0),setTimeout(()=>m(!1),2e3)};return e.jsxs(xe.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"mt-3 flex items-center gap-3 p-3 rounded-xl bg-amber-500/[0.08] border border-amber-500/20",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-amber-500/15 flex items-center justify-center shrink-0",children:e.jsx(Ta,{size:16,className:"text-amber-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:"Branded Shopping exclusion script"}),e.jsx("div",{className:"text-[11px] text-[var(--text-tertiary)]",children:"Paste into Google Ads > Tools > Scripts"})]}),e.jsxs("button",{onClick:h,className:`px-3 py-1.5 text-xs font-medium rounded-lg transition-all duration-200 flex items-center gap-1.5 shrink-0 ${i?"bg-emerald-500/20 text-emerald-300 border border-emerald-500/30":"bg-amber-500/15 text-amber-300 border border-amber-500/25 hover:bg-amber-500/25"}`,children:[i?e.jsx(De,{size:13}):e.jsx(Ea,{size:13}),i?"Copied!":"Copy Script"]})]})}function pl(a){if(!a)return{verdict:"",analysis:""};const i=a.split(`
16`);for(let h=0;h<i.length;h++)if(i[h].match(/^##\s+/))return{verdict:i.slice(0,h).join(`
17`).trim(),analysis:i.slice(h).join(`
18`).trim()};let m=!1;for(let h=0;h<i.length;h++){const p=i[h].trim();if(p.startsWith("|")&&p.includes("Metric")&&(m=!0),!(p.startsWith("|")&&m)&&m&&!p.startsWith("|")){if(p.startsWith("⚠")||p==="")continue;return{verdict:i.slice(0,h).join(`
19`).trim(),analysis:i.slice(h).join(`
20`).trim()}}}return{verdict:a,analysis:""}}function As({draft:a}){return e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-[var(--text-tertiary)]",children:[e.jsx(fa,{size:13}),e.jsxs("span",{children:[a.title?`"${a.title}" was updated further down`:"This draft was updated further down"," — the current version is below."]})]})}const gl=o.memo(function({msg:i,isStreaming:m,onStreamComplete:h,onStreamProgress:p,onApprove:A,onReject:f,onDeploy:n,onSave:M,onPickLogo:w,onApproveAction:T,onRejectAction:v,onExecuteAction:U,onSavePdf:_,onTileClick:ne,googleAdsAccountId:y,supersededDrafts:B=""}){const q=i.role==="user",F=o.useMemo(()=>new Set(B?B.split(","):[]),[B]),R=Q=>!!Q&&Q.id!=null&&F.has(String(Q.id)),[J,$]=o.useState(!1),P=!q&&!m&&!i._streaming&&i.content,G=i.actionProposal&&!m,{verdict:j,analysis:K}=o.useMemo(()=>G?pl(i.content):{verdict:i.content,analysis:""},[i.content,G]),ce=async()=>{await On(i.content)&&($(!0),setTimeout(()=>$(!1),2e3))};return e.jsx(xe.div,{initial:{opacity:0,y:8}
20,animate:{opacity:1,y:0},transition:{duration:.2},className:q?"flex justify-end":"",children:e.jsxs("div",{className:q?"max-w-[85%] sm:max-w-[70%]":"",children:[e.jsx("div",{className:`text-sm leading-relaxed ${q?"rounded-2xl rounded-tr-md px-4 py-3 bg-[var(--accent-blue)]/[0.10] text-[var(--text-primary)] whitespace-pre-wrap":"py-2 text-[var(--text-primary)] advisor-markdown"}`,children:q?i.tileLabel?e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(xr,{size:14,className:"text-[var(--accent-blue-bright)] shrink-0"}),e.jsx("span",{className:"font-medium",children:i.tileLabel}),i.tileParams&&Object.entries(i.tileParams).map(([Q,pe])=>e.jsx("span",{className:"text-[11px] text-[var(--text-tertiary)] bg-[var(--bg-overlay)] rounded-full px-2 py-0.5 shrink-0 max-w-[16rem] truncate",children:Q==="timeframe"?`${pe}d`:String(pe)},Q))]}):i.content:i._streaming?e.jsxs("div",{className:"relative",children:[e.jsx(Qt,{remarkPlugins:[$t],components:or,children:Xt(cr(i.content))}),e.jsx("span",{className:"inline-block w-[3px] h-[14px] bg-[var(--accent-blue)] rounded-full ml-0.5 animate-pulse align-middle"})]}):m?e.jsx(ml,{fullText:i.content,onComplete:h,onProgress:p}):G?e.jsx(Qt,{remarkPlugins:[$t],components:or,children:Xt(cr(j))}):e.jsx(Qt,{remarkPlugins:[$t],components:or,children:Xt(cr(i.content))})}),i._tileChoices?.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:i._tileChoices.map(Q=>e.jsxs("button",{onClick:()=>ne?.(Q.id),className:"px-4 py-2.5 rounded-xl text-left bg-[var(--accent-blue)]/[0.10] border border-[var(--accent-blue)]/30 hover:bg-[var(--accent-blue)]/[0.20] hover:border-[var(--accent-blue)]/50 transition-all duration-200 max-w-[240px]",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:Q.label}),Q.description&&e.jsx("div",{className:"text-[11px] text-[var(--text-tertiary)] mt-0.5 leading-tight",children:Q.description})]},Q.id))}),G&&K&&e.jsxs("div",{"data-tour":"advisor-analysis-card",className:"mt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 px-5 py-4 rounded-2xl bg-[var(--accent-blue)]/[0.06] border border-[var(--accent-blue)]/20",children:[e.jsx(Sa,{size:22,className:"text-[var(--accent-blue)] shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-lg font-bold text-[var(--text-primary)] block",children:"Campaign Analysis"}),e.jsx("span",{className:"text-sm text-[var(--text-tertiary)]",children:"Detailed per-campaign findings with data"})]})]}),e.jsx("div",{className:"text-sm leading-[1.7] py-5 px-5 mt-3 text-[var(--text-secondary)] advisor-markdown rounded-2xl bg-[var(--bg-overlay)] border border-[var(--border-subtle)]",children:e.jsx(Qt,{remarkPlugins:[$t],components:or,children:Xt(cr(K))})})]}),G&&e.jsx(xe.div,{"data-tour":"advisor-recommendations",initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"mt-6",children:e.jsx(al,{children:e.jsx(Sn,{proposal:i.actionProposal,onApproveAction:T,onRejectAction:v,onExecuteAction:U,googleAdsAccountId:y},i.actionProposal.id)})}),Array.isArray(i.dataTables)&&i.dataTables.length>0&&!m&&e.jsx(oi,{tables:i.dataTables}),i.campaignDraft&&!m&&R(i.campaignDraft)&&e.jsx(As,{draft:i.campaignDraft}),i.campaignDraft&&!m&&!R(i.campaignDraft)&&e.jsx(xe.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"mt-3",children:e.jsx(js,{draft:i.campaignDraft,onApprove:A,onReject:f,onDeploy:n,onSave:M,onPickLogo:w,googleAdsAccountId:y})}),Array.isArray(i.campaignDrafts)&&i.campaignDrafts.length>0&&!m&&i.campaignDrafts.map(Q=>R(Q)?e.jsx(As,{draft:Q},Q.id):e.jsx(xe.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"mt-3",children:e.jsx(js,{draft:Q,onApprove:A,onReject:f,onDeploy:n,onSave:M,onPickLogo:w,googleAdsAccountId:y})},Q.id)),i.googleAdsScript&&!m&&e.jsx(Ps,{script:i.googleAdsScript}),i.campaignErrors?.length>0&&e.jsxs("div",{className:"mt-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-xs text-red-400",children:[e.jsx("div",{className:"font-medium mb-1",children:"Campaign validation errors:"}),e.jsx("ul",{className:"list-disc list-inside space-y-0.5",children:i.campaignErrors.map((Q,pe)=>e.jsx("li",{children:Q},pe))})]}),i.campaignDraftErrors?.length>0&&e.jsxs("div",{className:"mt-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-xs text-red-400",children:[e.jsx("div",{className:"font-medium mb-1",children:"Some campaign drafts failed validation:"}),i.campaignDraftErrors.map((Q,pe)=>e.jsxs("div",{className:"mb-1 last:mb-0",children:[e.jsx("div",{className:"font-medium",children:Q.title}),e.jsx("ul",{className:"list-disc list-inside space-y-0.5",children:(Q.errors||[]).map((fe,ze)=>e.jsx("li",{children:fe},ze))})]},pe))]}),i.stopped&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-[var(--text-tertiary)]",children:[e.jsx(Ca,{size:10,fill:"currentColor"}),e.jsx("span",{children:"Stopped"})]}),e.jsxs("div",{className:`flex items-center gap-2 mt-1 ${q?"justify-end":""}`,children:[e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)]",children:i.timestamp?new Date(i.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}),P&&e.jsxs("button",{onClick:ce,className:`flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] transition-all duration-200 ${J?"bg-emerald-500/15 text-emerald-400":"text-[var(--text-tertiary)] hover:text-[var(--text-tertiary)] hover:bg-[var(--bg-overlay)]"}`,children:[J?e.jsx(De,{size:11}):e.jsx(Ea,{size:11}),J?"Copied!":"Copy"]}),P&&e.jsxs("button",{onClick:()=>_?.(i.content),className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] text-[var(--text-tertiary)] hover:text-[var(--text-tertiary)] hover:bg-[var(--bg-overlay)] transition-all duration-200",children:[e.jsx(Zn,{size:11}),"Save as PDF"]})]})]})})},(a,i)=>a.msg===i.msg&&a.isStreaming===i.isStreaming&&a.googleAdsAccountId===i.googleAdsAccountId);function hl({conversationId:a,googleAdsAccountId:i,onScraped:m}
20){const[h,p]=o.useState(""),[A,f]=o.useState(!1),[n,M]=o.useState(null),[w,T]=o.useState(null),v=async()=>{if(h.trim()){f(!0),T(null);try{const U=await te.scrapeUrl({url:h.trim(),conversationId:a,googleAdsAccountId:i});M(U),m&&m(U)}catch(U){T(U.message)}finally{f(!1)}}};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Mr,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"url",value:h,onChange:U=>p(U.target.value),onKeyDown:U=>U.key==="Enter"&&v(),placeholder:"Enter URL to scrape for campaign content...",className:"w-full pl-10 pr-4 py-2 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-sm text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:border-[var(--accent-blue)]/40 transition"})]}),e.jsx("button",{onClick:v,disabled:A||!h.trim(),className:"px-4 py-2 rounded-lg bg-[var(--accent-blue)]/10 text-[var(--accent-blue-bright)] hover:bg-[var(--accent-blue)]/20 border border-[var(--accent-blue)]/20 text-sm font-medium transition disabled:opacity-40",children:A?e.jsx(Ae,{size:16,className:"animate-spin"}):e.jsx(Vn,{size:16})})]}),w&&e.jsx("div",{className:"text-xs text-red-400 px-1",children:w}),n&&e.jsxs(xe.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-emerald-500/10 border border-emerald-500/20 text-xs",children:[e.jsx(De,{size:14,className:"text-emerald-400 shrink-0"}),e.jsxs("div",{className:"text-emerald-400/80 truncate flex-1",children:[e.jsx("span",{className:"font-medium",children:n.title||"Page scraped"}),e.jsxs("span",{className:"text-emerald-400/50 ml-2",children:[n.headingsCount," headings, ",n.imagesCount," images"]})]}),e.jsx("button",{onClick:()=>{M(null),p("")},className:"text-emerald-400/40 hover:text-emerald-400 transition",children:e.jsx(Ee,{size:14})})]})]})}function ws({conv:a,isActive:i,onClick:m,onDelete:h}){return e.jsxs("button",{onClick:m,className:`w-full group flex items-center gap-2 px-2.5 py-2 rounded-lg text-left text-[13px] transition
21        ${i?"bg-[var(--bg-overlay)] text-[var(--text-primary)]":"text-[var(--text-tertiary)] hover:bg-[var(--bg-overlay)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(wa,{size:13,className:"shrink-0 text-[var(--text-tertiary)]"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"truncate",children:a.title||"New Conversation"}),e.jsx("div",{className:"text-[10px] mt-0.5 text-[var(--text-tertiary)]",children:new Date(a.updatedAt||a.createdAt).toLocaleDateString([],{month:"short",day:"numeric"})})]}),e.jsx("button",{onClick:p=>{p.stopPropagation(),h(a.id)},className:"opacity-0 group-hover:opacity-100 max-md:opacity-100 p-1 rounded hover:bg-[var(--bg-overlay-heavy)] text-[var(--text-tertiary)] hover:text-red-400 transition",children:e.jsx(Es,{size:12})})]})}function Jt(a){const i=a.width,m=a.height;if(!i||!m)return"other";if(i<100||m<100)return"tiny";const h=i/m;return h>=1.7&&h<=2.1&&i>=600&&m>=314?"landscape":h>=.9&&h<=1.1&&i>=300&&m>=300?"square":h>=.9&&h<=1.1&&i>=128?"logo":"other"}function fo(){const{theme:a}=ks(),i=a==="light",{user:m,aiCredits:h,refreshAiCredits:p}=yn(),[A,f]=o.useState([]),[n,M]=o.useState(!0),[w,T]=o.useState(!1);o.useEffect(()=>{let r=!1;return M(!0),na("/api/accounts").then(s=>{r||(f(s.accounts||[]),M(!1),T(!0))}).catch(()=>{r||(M(!1),T(!0))}),()=>{r=!0}},[]);const[v,U]=o.useState(()=>{try{const r=localStorage.getItem("selected_google_ads_account_id"),s=r?parseInt(r,10):null;return s&&!Number.isNaN(s)?s:null}catch{return null}}),_=fn();o.useEffect(()=>{const r=localStorage.getItem("selected_google_ads_account_id"),s=r?parseInt(r,10):null;s&&!Number.isNaN(s)&&s!==v&&U(s)},[_.pathname]);const[ne,y]=o.useState(!1),[B,q]=o.useState(!1),[F,R]=o.useState(!1),[J,$]=o.useState(!1),[P,G]=o.useState(null),[j,K]=o.useState(!1),[ce,Q]=o.useState(!1),pe=o.useCallback(()=>v?(K(!0),Q(!1),te.getInit(v).then(r=>{G(r),K(!1)}).catch(()=>{Q(!0),K(!1)})):Promise.resolve(),[v]);o.useEffect(()=>{if(!v){G(null);return}let r=!1;return K(!0),Q(!1),te.getInit(v).then(s=>{r||(G(s),K(!1))}).catch(()=>{r||(Q(!0),K(!1))}),()=>{r=!0}},[v]);const fe=P?.conversations||[],ze=P?.thirdPartyConnected===!0,{goalsComplete:Oe,csConfigured:L,configured:E,required:re}=An(P,{loading:j,error:ce}),ie=o.useCallback(r=>{G(s=>s&&{...s,...typeof r=="function"?r(s):r})},[]),[ae,he]=o.useState(null),Ue=o.useRef(null),Re=o.useRef(null),Ie=o.useCallback(r=>{Ue.current=r,r||(Re.current=null),he(r)}
21,[]),we=o.useCallback((r,s)=>{r&&s?localStorage.setItem(`advisor_conv_${r}`,s):r&&localStorage.removeItem(`advisor_conv_${r}`)},[]),[le,z]=o.useState([]),je=o.useMemo(()=>Si(le),[le]),[be,mr]=o.useState(()=>localStorage.getItem("advisor_language")||"de"),st=vs[be]||vs.en,Qe=!1,[pr,Fr]=o.useState(!1),[ke,Ct]=o.useState([]),[gr,Et]=o.useState(!1),[nt,Tt]=o.useState(!1);o.useEffect(()=>{if(!v)return;let r=!1;return Et(!0),Tt(!1),te.getSmartPrompts(v,be).then(s=>{r||(Ct(s.prompts||[]),Et(!1),Tt(!0))}).catch(()=>{r||(Et(!1),Tt(!0))}),()=>{r=!0}},[v,be]);const[Pe,Lt]=o.useState("popular"),[hr,Be]=o.useState(null),[Ur,Dt]=o.useState([]),[gt,it]=o.useState(null),[Br,It]=o.useState(!1);o.useEffect(()=>{let r=!1;return te.getCustomPrompts().then(s=>{r||Dt(s.prompts||[])}).catch(()=>{}),()=>{r=!0}},[]);const[br,vr]=o.useState(!1),[oe,ht]=o.useState(null);o.useEffect(()=>{ht(null),vr(!1)},[v]),o.useEffect(()=>{if(!v||!br||oe)return;let r=!1;return te.getMentionEntities(v).then(s=>{r||ht(s)}).catch(()=>{}),()=>{r=!0}},[v,br,oe]);const Hr=oe?.campaigns||[],Vr=oe?.adGroups||[],[yr,bt]=o.useState(!1),[fr,He]=o.useState(""),[vt,yt]=o.useState(-1),[We,Me]=o.useState(""),[Ge,Se]=o.useState(!1),[Pt,$e]=o.useState(null),Gt=o.useRef(null),qe=o.useCallback(r=>{Gt.current=r},[]),lt=o.useRef(null),Ve=o.useRef(!1),[ot,Ot]=o.useState(0),[jr,t]=o.useState(null),[x,u]=o.useState(""),[D,b]=o.useState([]),[g,O]=o.useState(!1),I=o.useRef(""),k=o.useRef(null),H=o.useRef(null),ye=o.useRef(null),[ue,X]=o.useState(!1),[Te,Fe]=o.useState(!1),[ge,ft]=o.useState([]),[Yr,er]=o.useState(!1),[Rt,La]=o.useState(!1),Da=o.useRef(null),[Ze,tr]=o.useState(new Set),[Ce,Mt]=o.useState(null),[_t,zt]=o.useState([]),[rr,Nr]=o.useState(!1),[Ia,Ft]=o.useState(null),[et,jt]=o.useState(null),[Ut,Kr]=o.useState(!1),[Ar,Bt]=o.useState(!1),Wr=o.useRef(null),Pa=o.useRef(null);o.useEffect(()=>{if(!Ar)return;const r=l=>{Wr.current&&!Wr.current.contains(l.target)&&Bt(!1)},s=l=>{l.key==="Escape"&&Bt(!1)};return document.addEventListener("mousedown",r),document.addEventListener("keydown",s),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",s)}},[Ar]);const[Ga,wr]=o.useState([]),[Zr,Jr]=o.useState(null);o.useEffect(()=>{let r=!1;if(Jr(null),!!v)return En.getStatus().then(s=>{r||Jr(s?.enabled&&s.connectionsByAccount?.[v]||null)}).catch(()=>{r||Jr(null)}),()=>{r=!0}},[v]);const[Oa,qr]=o.useState([]),Xr=o.useRef(null),[ct,Qr]=o.useState(null),[Gs,Ra]=o.useState("pmax"),[$r,Ma]=o.useState(!1),[ea,Os]=o.useState({}),_a=o.useRef(!1),za=o.useRef(!1),Ye=A.find(r=>r.id===v),Fa=o.useRef(null),Ua=o.useRef(null),tt=o.useRef(null),Ba=o.useRef(null),[Rs,Ms]=o.useState(""),Ha=Nn({contentRef:Ba,documentTitle:Ye?.descriptiveName||Ye?.customerId||"Advisor",pageStyle:"@page { size: A4; margin: 0 } html, body { background: #ffffff !important } body { -webkit-print-color-adjust: exact; print-color-adjust: exact }"}),_s=o.useCallback(r=>{Ms(r||""),setTimeout(()=>Ha(),100)},[Ha]),Va=o.useRef(!1);o.useEffect(()=>{if(Va.current||!w||(Va.current=!0,v&&A.find(l=>l.id===v)))return;const r=localStorage.getItem("selected_google_ads_account_id"),s=r?parseInt(r,10):null;s&&A.find(l=>l.id===s)?U(s):A.length>0&&U(A[0].id)},[w,A,v]),o.useEffect(()=>{v&&localStorage.setItem("selected_google_ads_account_id",String(v))},[v]),o.useEffect(()=>{!Ye||Ye.aiAdvisorEnabled||(async()=>{try{await na("/api/accounts/ai-advisor-toggle",{method:"POST",body:JSON.stringify({googleAdsAccountId:Ye.id,enabled:!0})}),f(r=>r.map(s=>s.id===Ye.id?{...s,aiAdvisorEnabled:!0}:s))}catch(r){console.error("Failed to auto-enable AI Advisor:",r)}})()},[Ye]),o.useEffect(()=>{localStorage.setItem("advisor_language",be)},[be]);const ta=o.useRef(null);o.useEffect(()=>{if(!v||!P||ta.current===v)return;ta.current=v;const r=localStorage.getItem(`advisor_conv_${v}`);if(!r||!fe.some(l=>String(l.id)===r))return;let s=!1;return te.getConversation(r).then(l=>{s||l?.conversation?.hasLiveStream&&ar(r)}).catch(()=>{}),()=>{s=!0}},[v,P,fe]);const Ya=o.useRef(null);o.useEffect(()=>{v&&nt&&Ya.current!==v&&(Ya.current=v,ke.length>0&&Lt("popular"))},[v,nt,ke.length]);const Ka=o.useCallback(()=>{const r=Ua.current;return r?r.scrollHeight-r.scrollTop-r.clientHeight<150:!0},[]),ra=o.useCallback(()=>{Fa.current?.scrollIntoView({behavior:"smooth"})},[]),Ht=o.useCallback(()=>{Ka()&&ra()},[Ka,ra]),aa=o.useCallback(async r=>{Se(!0),u("Reconnecting..."),b([]),Ve.current=!1;const s=new AbortController;lt.current=s,qe(r),$e(Re.current==="legacy"?null:"stoppable");let l=!1;const c=S=>{l?(I.current+=S,k.current||(k.current=requestAnimationFrame(()=>{const W=I.current;z(ee=>{const se=[...ee],C=se[se.length-1];return C?.role==="assistant"&&C._streaming&&(se[se.length-1]={...C,content:W}),se}),Ht(),k.current=null}))):(l=!0,u(""),b([]),I.current=S,z(W=>[...W,{role:"assistant",content:S,timestamp:new Date().toISOString(),_streaming:!0}]))},d=S=>u(S),N=S=>{S?.id&&(b(W=>{const ee=W.findIndex(se=>se.id===S.id);if(ee>=0){const se=[...W];return se[ee]={...se[ee],status:S.status},se}return[...W,{id:S.id,label:S.label,status:S.status}]}),S.action==="drive_picker"&&Ft(S.label||"The agent needs image creatives — pick them from Google Drive."),S.action==="creative_import"&&S.importId!=null&&Xr.current?.({importId:S.importId,total:S.total,videosAwaitingTitle:S.videosAwaitingTitle}),Ht())};try{for(let S=0;S<4;S++){l=!1,I.current="",z(se=>se.filter(C=>!C._streaming));const W=await te.subscribeToStream(r,{onToken:c,onStatus:d,onStep:N,signal:s.signal});if(k.current&&(cancelAnimationFrame(k.current),k.current=null),Ve.current)return;if(W.noStream){await H.current?.(r);return}if(W.incomplete){if((await te.getConversation(r).catch(()=>null))?.conversation?.hasLiveStream){u("Reconnecting..."),await new Promise(C=>
21setTimeout(C,1500*Math.pow(2,S)));continue}await H.current?.(r);return}const ee=typeof W.message=="string"?{role:"assistant",content:W.message,timestamp:new Date().toISOString()}:W.message;z(ee?se=>{const C=[...se],Z=C.length-1;return C[Z]?.role==="assistant"&&C[Z]._streaming?C[Z]=ee:C.push(ee),C}:se=>se.filter(C=>!C._streaming));return}await H.current?.(r)}catch(S){if(Ve.current||S?.name==="AbortError")return;console.error("resume failed:",S),String(S?.message).includes("stream_expired")?await H.current?.(r):z(W=>[...W.filter(ee=>!ee._streaming),{role:"assistant",content:`Sorry, something went wrong: ${S.message}. Please try again.`,timestamp:new Date().toISOString()}])}finally{k.current&&(cancelAnimationFrame(k.current),k.current=null),Se(!1),u(""),$e(null),qe(null),lt.current=null,Ve.current=!1}},[Ht,qe]),ar=o.useCallback(async r=>{if($e(null),qe(null),!r){z([]),Ie(null),t(null);return}try{const s=await te.getConversation(r);t(null);const l=Ci(s.conversation.messages||[],s.conversation.campaignDrafts);z(l),Re.current=s.conversation.engine||null,Ie(r),we(v,r),s.conversation.hasLiveStream&&aa(r)}catch(s){console.error("Failed to load conversation:",s)}},[aa,v,we,qe]);H.current=ar;const zs=o.useCallback(async()=>{const r=Gt.current;$e("requested");let s,l;try{({stopped:s,reason:l}=await te.stopChat(r))}catch(d){console.error("[stop] request failed",d.response?.status,d.response?.data,d),$e("stoppable");return}s||console.warn(`[stop] server aborted nothing (reason=${l}) for ${r?`conversation ${r}`:"latest active stream"} — finalizing locally`),Ve.current=!0,lt.current?.abort();const c=I.current;k.current&&(cancelAnimationFrame(k.current),k.current=null),z(d=>{const N=d.filter(S=>!S._streaming);return c&&N.push({role:"assistant",content:c,stopped:!0,timestamp:new Date().toISOString()}),N})},[]),Nt=async(r,s,l)=>{if(h?.exhausted)return;const c=(r??We).trim(),d=_t.length>0;if(!c&&!d||!v||Ge)return;const N=d?`[USER SELECTED IMAGES FROM ACCOUNT LIBRARY — use them directly, do NOT ask for them again]
22${[..._t.filter(V=>!V.isLogo).map(V=>{const Le=V.width&&V.height?` (${V.width}×${V.height})`:"",Y=V.label?` [${V.label}]`:"";return`• ${V.url}${Le}${Y}`}),..._t.filter(V=>V.isLogo).map(V=>{const Le=V.width&&V.height?` (${V.width}×${V.height})`:"";return`Logo: ${V.url}${Le} — use as logo_url, NOT as a marketing image`})].join(`
23`)}`:"",S=c?N?`${N}
24
25${c}`:c:N;Me(""),zt([]),Ft(null),$a(null),Se(!0),qe(Ue.current);const W=!!Ue.current&&Re.current==="legacy";$e(W?null:"stoppable"),u("Preparing..."),b([]),I.current="";const ee=s?ke.find(V=>V.id===s):null,se={role:"user",content:S,timestamp:new Date().toISOString(),...ee&&{smartPromptId:s,tileLabel:ee.label},...ee&&l&&{tileParams:l}};z(V=>[...V,se]),setTimeout(()=>ra(),50);let C=!1;Ve.current=!1;const Z=new AbortController;lt.current=Z;try{const V=await te.sendMessageUnified({googleAdsAccountId:v,conversationId:Ue.current,message:S,language:be,...s&&{smartPromptId:s},...ee&&{tileLabel:ee.label},...l&&{tileParams:l},...Qa&&{campaignScope:Qa}},Y=>{C?(I.current+=Y,k.current||(k.current=requestAnimationFrame(()=>{const de=I.current;z(ve=>{const me=[...ve],_e=me[me.length-1];return _e?.role==="assistant"&&_e._streaming&&(me[me.length-1]={..._e,content:de}),me}),Ht(),k.current=null}))):(C=!0,u(""),b([]),I.current=Y,z(de=>[...de,{role:"assistant",content:Y,timestamp:new Date().toISOString(),_streaming:!0}]))},Y=>{u(Y)},Y=>{Y?.id&&(b(de=>{const ve=de.findIndex(me=>me.id===Y.id);if(ve>=0){const me=[...de];return me[ve]={...me[ve],status:Y.status},me}return[...de,{id:Y.id,label:Y.label,status:Y.status}]}),Y.action==="drive_picker"&&Ft(Y.label||"The agent needs image creatives — pick them from Google Drive."),Y.action==="creative_import"&&Y.importId!=null&&Xr.current?.({importId:Y.importId,total:Y.total,videosAwaitingTitle:Y.videosAwaitingTitle}),Ht())},Y=>{Y&&qe(Y)},Z.signal);if(k.current&&(cancelAnimationFrame(k.current),k.current=null),Ve.current){V?.conversationId&&(Ie(V.conversationId),we(v,V.conversationId));return}if(V.incomplete){k.current&&(cancelAnimationFrame(k.current),k.current=null);
25const Y=V.conversationId;Y&&(Ie(Y),we(v,Y));const de=()=>{z(ve=>[...ve.filter(me=>!me._streaming),{role:"assistant",content:"The connection dropped before I could finish — your request wasn't completed. Please try again.",_connectionError:!0,timestamp:new Date().toISOString()}])};try{if(!Y){de();return}const ve=async()=>(await te.getConversation(Y)).conversation||{};let me=await ve(),_e=ss({hasLiveStream:me.hasLiveStream,messages:me.messages});_e==="failed"&&(await new Promise(Ne=>setTimeout(Ne,1e3)),me=await ve(),_e=ss({hasLiveStream:me.hasLiveStream,messages:me.messages})),_e==="resume"?(z(me.messages||[]),await aa(Y)):_e==="show"?z(me.messages||[]):de()}catch{de()}return}if(Ie(V.conversationId),V.stopped&&!V.message)z(Y=>Y.filter(de=>!de._streaming));else{const Y=typeof V.message=="string"?{role:"assistant",content:V.message,timestamp:new Date().toISOString()}:V.message||{role:"assistant",content:"",timestamp:new Date().toISOString()};if(V.tileChoices?.length>0){const de=V.tileChoices.map(ve=>ke.find(me=>me.id===ve)).filter(Boolean);de.length>0&&(Y._tileChoices=de)}z(de=>{const ve=[...de],me=ve.length-1;ve[me]?.role==="assistant"&&ve[me]._streaming?ve[me]=Y:ve.push(Y);const _e=Array.isArray(Y.supersededProposals)?Y.supersededProposals:[];if(_e.length===0)return ve;const Ne=new Map(_e.map(Xe=>[Xe.id,Xe]));return ve.map(Xe=>{const Cr=Xe?.actionProposal&&Ne.get(Xe.actionProposal.id);return Cr?{...Xe,actionProposal:{...Xe.actionProposal,status:Cr.status,operations:Cr.operations,results:Cr.results}}:Xe})})}const Le=await te.getConversations(v);ie({conversations:Le.conversations||[]}),p(),V.tileRedirect&&!V.tileChoices?.length&&setTimeout(()=>{Ie(null),z([]),sr(V.tileRedirect)},800)}catch(V){if(k.current&&(cancelAnimationFrame(k.current),k.current=null),Ve.current||V.name==="AbortError"){const Le=Gt.current;Le&&(Ie(Le),we(v,Le)),p();return}if(V.response?.status===403&&V.response?.data?.error==="ai_credits_exhausted"){p();return}z(Le=>{const Y=[...Le],de=Y.length-1;return Y[de]?.role==="assistant"&&Y[de]._streaming?Y[de]={role:"assistant",content:`Sorry, something went wrong: ${V.message}. Please try again.`,timestamp:new Date().toISOString()}:Y.push({role:"assistant",content:`Sorry, something went wrong: ${V.message}. Please try again.`,timestamp:new Date().toISOString()}),Y})}finally{Se(!1),Ot(0),u(""),$e(null),qe(null),lt.current=null,Ve.current=!1,tt.current?.focus()}};o.useEffect(()=>{if(_a.current||!_.state?.autoAudit||!v||!ke.length||Ge)return;const r=ke.find(l=>l.id==="first_account_review")||ke.find(l=>l.id==="full_account_audit");if(!r)return;_a.current=!0,window.history.replaceState({},""),ta.current=v,Vt();const s=(r.message||"").replace(/\{\{timeframe\}\}/g,"30");setTimeout(()=>Nt(s,r.id,{timeframe:"30"}),300)},[_.state,v,ke,Ge]);const Wa=o.useRef(!1);o.useEffect(()=>{if(Wa.current||!_.state?.openGoals&&!_.state?.openConversation||!v||!P)return;Wa.current=!0;const{openGoals:r,openConversation:s}=_.state;window.history.replaceState({},""),r?y(!0):s&&ar(String(s))},[_.state,v,P]),o.useEffect(()=>{if(za.current)return;const r=_.state?.prefillMessage;!r||typeof r!="string"||!v||Ge||(za.current=!0,window.history.replaceState({},""),setTimeout(()=>Nt(r),300))},[_.state,v,Ge]);const dt=o.useRef({accountId:null,images:null}),Za=async()=>{if(!v)return;Fe(!0),tr(new Set),Mt(null);const r=s=>{const l=(s||[]).find(c=>c.isCurrentLogo);l&&(tr(new Set([l.url])),Mt(l.url))};if(dt.current.accountId===v&&dt.current.images){ft(dt.current.images),er(!1),r(dt.current.images);return}er(!0);try{const l=(await te.getAccountImages(v)).images||[];ft(l),dt.current={accountId:v,images:l},r(l)}catch(s){z(l=>[...l,{role:"assistant",content:`Could not load account image library: ${s.message}.`,timestamp:new Date().toISOString()}]),Fe(!1),Qr(null)}finally{er(!1)}},Fs=async()=>{try{const s=(await te.getAccountImages(v)).images||[];ft(s),dt.current={accountId:v,images:s}}catch{}},Us=8*1024*1024,Bs=["image/jpeg","image/png","image/webp","image/gif"],Ja=async r=>{if(!r||r.length===0)return;const s=[],l=[];for(const c of r)Bs.includes(c.type)?c.size>Us?s.push(`“${c.name}” exceeds the 8 MB limit`):l.push(c):s.push(`“${c.name}” is not a supported image (JPEG, PNG, WebP or GIF)`);if(s.length>0&&z(c=>[...c,{role:"assistant",content:`Skipped ${s.length===1?"a file":"some files"}: ${s.join("; ")}.`,timestamp:new Date().toISOString()}]),l.length!==0){La(!0);try{const c=await te.uploadImagesToLibrary(l,v);dt.current={accountId:null,images:null},await Fs();const d=c.images||[];d.length>0&&zt(C=>
25[...C,...d.map(Z=>({url:Z.url,width:Z.width,height:Z.height,label:Z.width&&Z.height?`${Z.width}×${Z.height}`:"Upload"}))]);const N=(c.skipped||[]).length>0?`
26
27Skipped: ${c.skipped.map(C=>`${C.name} (${C.reason})`).join(", ")}`:"",S=c.library?.uploaded??0,W=c.library?.error,ee=W&&/invalid_grant|expired or revoked/i.test(W)?"the Google Ads connection for this account has expired — reconnect the ad account in Account Settings, then upload again.":W,se=S===0&&ee?`The images could not be added to your Google Ads asset library: ${ee}${d.length>0?" They're attached below, but a campaign cannot use them until they are in the library.":""}${N}`:`${S} image${S===1?"":"s"} from your computer added to your Google Ads asset library.${d.length>0?" They're attached below — send a message to use them in a campaign, or just send to hand them to the agent.":""}${N}`;z(C=>[...C,{role:"assistant",content:se,timestamp:new Date().toISOString()}])}catch(c){z(d=>[...d,{role:"assistant",content:`Image upload failed: ${c.response?.data?.error||c.message}`,timestamp:new Date().toISOString()}])}finally{La(!1)}}},Hs=async r=>{const s=Array.from(r.target.files||[]);r.target.value="",await Ja(s)},Vs=(r,s)=>{const l=new Set(Ze);let c=Ce;if(l.has(r))l.delete(r),c===r&&(c=null);else if(l.add(r),s==="logo"){if(c&&c!==r){const d=ge.find(N=>N.url===c);d&&Jt(d)==="logo"&&l.delete(c)}c=r}tr(l),c!==Ce&&Mt(c)},Ys=r=>{if(Ce&&Ce!==r){const s=ge.find(l=>l.url===Ce);s&&Jt(s)==="logo"&&tr(l=>{const c=new Set(l);return c.delete(s.url),c})}Mt(r)},kr=()=>{Fe(!1),Qr(null),Ra("pmax")},Ks=(r,s="pmax")=>{Qr(r),Ra(s==="dg"?"dg":"pmax"),Za()},Ws=async r=>{if(!(!ct||$r)){Ma(!0);try{await ts(ct,Gs==="dg"?{dgLogoUrl:r}:{logoUrl:r}),kr()}catch(s){z(l=>[...l,{role:"assistant",content:`Logo konnte nicht gesetzt werden: ${s.message||"Unbekannter Fehler"}`,timestamp:new Date().toISOString()}])}finally{Ma(!1)}}},Zs=r=>{const s=ea[r.url],l=s?.w||r.width,c=s?.h||r.height;if(!l||!c)return{ok:!1,reason:"wird geprüft…",pending:!0};if(l<128||c<128)return{ok:!1,reason:"zu klein"};const d=l/c;return d<.95||d>1.05?{ok:!1,reason:"nicht quadratisch"}:{ok:!0}},Js=()=>{if(Ze.size===0&&!Ce)return;const r=Array.from(Ze).map(s=>{const l=ge.find(S=>S.url===s),c=l?.width,d=l?.height;let N="";if(c&&d){const S=c/d;S>=1.7&&S<=2.1&&c>=600&&d>=314?N=`Landscape ${c}×${d}`:S>=.9&&S<=1.1&&c>=300&&d>=300?N=`Square ${c}×${d}`:N=`${c}×${d}`}return{url:s,label:N,width:c,height:d,isLogo:s===Ce}});if(Ce&&!Ze.has(Ce)){const s=ge.find(l=>l.url===Ce);r.push({url:Ce,label:s?.width&&s?.height?`Logo ${s.width}×${s.height}`:"Logo",width:s?.width,height:s?.height,isLogo:!0})}zt(s=>[...r.some(d=>d.isLogo)?s.map(d=>d.isLogo?{...d,isLogo:!1}:d):s,...r]),Fe(!1),tr(new Set),Mt(null)},qs=async r=>{const s=r.target.files?.[0];if(!(!s||!v)){r.target.value="",O(!0);try{const{landscapeUrl:l,squareUrl:c}=await te.generateCampaignImages(s);zt(d=>[...d,{url:l,label:"Landscape (1.91:1)"},{url:c,label:"Square (1:1)"}])}catch(l){z(c=>[...c,{role:"assistant",content:`Image generation failed: ${l.message}. You can upload images or paste URLs instead.`,timestamp:new Date().toISOString()}])}finally{O(!1)}}},Xs=r=>{zt(s=>s.filter((l,c)=>c!==r))},Qs=async({imageFileIds:r,folderIds:s})=>{if(!(r.length===0&&s.length===0))try{const l=await te.importDriveCreatives({googleAdsAccountId:v,fileIds:r,folderIds:s}),c=l.images||[];c.length>0&&(zt(N=>[...N,...c.map(S=>({url:S.url,width:S.width,height:S.height,label:S.width&&S.height?`${S.width}×${S.height}`:"Drive"}))]),dt.current={accountId:null,images:null});const d=(l.skipped||[]).length>0?`
28
29Skipped: ${l.skipped.map(N=>`${N.name} (${N.reason})`).join(", ")}`:"";if(c.length>0){const N=l.library?.uploaded??0,S=l.library?.error,W=S&&/invalid_grant|expired or revoked/i.test(S)?"the Google Ads connection for this account has expired — reconnect the ad account in Account Settings, then import again.":S;z(ee=>[...ee,{role:"assistant",content:N===0&&W?`The images were imported from Google Drive but could not be added to your Google Ads asset library: ${W} They're attached below, but a campaign cannot use them until they are in the library.${d}`:`${N} image${N===1?"":"s"} from Google Drive added to your Google Ads asset library. They're attached below — send a message to use them in a campaign, or just send to hand them to the agent.${d}`,timestamp:new Date().toISOString()}])}else r.length>0&&z(N=>[...N,{role:"assistant",content:`No images could be imported from Google Drive.${d}`,timestamp:new Date().toISOString()}])}catch(l){z(c=>[...c,{role:"assistant",content:`Drive image import failed: ${l.message}`,timestamp:new Date().toISOString()}])}},qa=async()=>
29{if(!(!v||rr)){Nr(!0);try{const{accessToken:r,apiKey:s,appId:l}=await te.getDriveAccessToken();await wn({accessToken:r,apiKey:s,appId:l,onCancel:()=>Nr(!1),onPicked:async c=>{try{const{imageFileIds:d,videoFiles:N,folderIds:S}=kn(c);if(d.length===0&&N.length===0&&S.length===0){Ft(null);return}Ft(null),await Qs({imageFileIds:d,folderIds:S});const W=[...N];if(S.length>0)try{const{videos:ee=[],skipped:se=[]}=await te.listFolderVideos(S),C=new Set(W.map(Z=>Z.id));for(const Z of ee)C.has(Z.id)||(C.add(Z.id),W.push(Z));se.length&&ee.length&&z(Z=>[...Z,{role:"assistant",content:`Some folders' videos couldn't be listed: ${se.map(V=>`${V.name} (${V.reason})`).join(", ")}`,timestamp:new Date().toISOString()}])}catch{}W.length>0&&jt({videos:W.map(ee=>{const se=String(ee.name||"Video").replace(/\.[a-z0-9]+$/i,"").trim().slice(0,100);return{driveFileId:ee.id,fileName:ee.name||"Video",title:se||"Video",description:""}})})}catch(d){z(N=>[...N,{role:"assistant",content:`Drive import failed: ${d.message}`,timestamp:new Date().toISOString()}])}finally{Nr(!1)}}})}catch(r){if(Nr(!1),r.response?.status===409||r.response?.data?.needsReconnect===!0)try{const{authUrl:l}=await na("/api/oauth/merchant-auth-url");z(c=>[...c,{role:"assistant",content:"Your Google connection is missing Drive access. A Google consent window has been opened — approve it, and if the page that opens asks you to select Merchant Center accounts, connect the ones you use. Then come back here and try the Drive button again.",timestamp:new Date().toISOString()}]),window.open(l,"_blank","noopener")}catch{z(l=>[...l,{role:"assistant",content:"Your Google connection is missing Drive access. Reconnect Google in Settings → Integrations, then try again.",timestamp:new Date().toISOString()}])}else z(l=>[...l,{role:"assistant",content:`Google Drive picker failed: ${r.message}`,timestamp:new Date().toISOString()}])}}},$s=({importId:r,total:s,videosAwaitingTitle:l})=>{r!=null&&(qr(c=>c.some(d=>d.id===r)?c:[...c,{id:r,total:s||0,done:0,failed:0,skipped:0,awaiting:0,status:"running",error:null}]),en(r),Array.isArray(l)&&l.length>0&&jt({importId:r,videos:l.map(c=>{const d=String(c.name||"Video").replace(/\.[a-z0-9]+$/i,"").trim().slice(0,100);return{importItemId:c.itemId,fileName:c.name||"Video",title:d||"Video",description:""}})}))};Xr.current=$s;const en=async r=>{let s=2e3;const l=async()=>{let c;try{c=await te.getCreativeImportStatus(r)}catch{setTimeout(l,s);return}const d=c.counts?.images||{total:0,done:0,failed:0},N=c.counts?.videos||{total:0},S=N.awaitingTitle||0,W=N.skipped||0,ee=c.videos||[],se=ee.filter(Y=>Y.status==="done").length,C=ee.filter(Y=>Y.status==="failed"),Z=ee.filter(Y=>Y.status&&!["done","failed","skipped","awaiting_title"].includes(Y.status)).length;qr(Y=>Y.map(de=>de.id===r?{...de,status:c.status,done:d.done+se,failed:d.failed+C.length,skipped:W,awaiting:S,uploading:Z,total:d.total+N.total,error:c.error}:de));const V=Z>0;if((c.status==="done"||c.status==="failed")&&S===0&&!V){const Y=[];d.done>0&&Y.push(`${d.done} Bild${d.done===1?"":"er"} in der Asset-Bibliothek`);const de=ee.filter(Ne=>Ne.status==="done");de.length>0&&Y.push(`${de.length} Video${de.length===1?"":"s"} auf YouTube (unlisted)`);const ve=d.failed+C.length,me=de.filter(Ne=>Ne.videoUrl).map(Ne=>`
30- ${Ne.title||Ne.name}: ${Ne.videoUrl}`).join(""),_e=C.map(Ne=>`
31- ${Ne.title||Ne.name}: ${Ne.error||"unbekannter Fehler"}`).join("");z(Ne=>[...Ne,{role:"assistant",content:c.status==="failed"?`Der Import ist fehlgeschlagen: ${c.error||"unbekannter Fehler"}`:`Import fertig: ${Y.join(" und ")||"nichts importiert"}${ve>0?` (${ve} fehlgeschlagen)`:""}${W>0?` (${W} Video${W===1?"":"s"} ohne Titel übersprungen)`:""}. ${de.length>0||d.done>0?"Die Creatives sind bereit — sag einfach Bescheid, was du daraus bauen willst.":""}${me}${_e?`
32
33Fehlgeschlagen:${_e}`:""}`,timestamp:new Date().toISOString()}]),setTimeout(()=>qr(Ne=>Ne.filter(Xe=>Xe.id!==r)),8e3);return}s=Math.min(s+1e3,5e3),setTimeout(l,s)};setTimeout(l,s)},tn=async r=>{let s=2e3;const l=async()=>{let c;try{c=await te.getVideoStatus(r)}catch{setTimeout(l,s);return}if(wr(d=>d.map(N=>N.id===r?{...N,status:c.status,progress:c.progress,error:c.error}:N)),c.status==="done"){const d=c.videoId?`https://youtu.be/${c.videoId}`:null,N=c.destination==="channel",S=N?`to your YouTube channel “${c.channelTitle}” as ${c.privacyStatus==="public"?"a public":"an unlisted"} video`:"to YouTube as an unlisted video";let W="";N&&c.commentsPreference==="off"&&(c.commentsEnabled===!0?W=`
34
35Comments are ON on this video — turn them off in Studio: ${c.studioEditUrl}`:c.commentsEnabled===!1&&(W=`
36
37Comments are off.`)),z(ee=>[...ee,{role:"assistant",content:`“${c.title}” uploaded ${S} and added to your Google Ads asset library. It's ready to use in a Demand Gen campaign — just ask.${d?`
38
39Watch: ${d}`:""}${W}`,timestamp:new Date().toISOString()}]),setTimeout(()=>wr(ee=>ee.filter(se=>se.id!==r)),6e3);return}if(c.status==="failed"){const d=c.errorReason==="youtube_reconnect_required";z(N=>[...N,{role:"assistant",content:`Video upload failed: ${c.error||"unknown error"}${d?`
40
41Open Connectors → YouTube channel → Reconnect, then upload again.`:""}`,timestamp:new Date().toISOString()}]),setTimeout(()=>wr(N=>N.filter(S=>S.id!==r)),8e3);return}s=Math.min(s+1500,5e3),setTimeout(l,s)};setTimeout(l,s)},rn=1024*1024*1024,an=r=>{if(!r||r.length===0)return;const s=[],l=[];for(const c of r)(c.type||"").startsWith("video/")?c.size>rn?s.push(`“${c.name}” exceeds the 1 GB upload limit`):l.push(c):s.push(`“${c.name}” is not a video file`);s.length>0&&z(c=>[...c,{role:"assistant",content:`Skipped ${s.length===1?"a file":"some files"}: ${s.join("; ")}.`,timestamp:new Date().toISOString()}]),l.length>0&&jt({videos:l.map(c=>{const d=String(c.name||"Video").replace(/\.[a-z0-9]+$/i,"").trim().slice(0,100);return{localFile:c,fileName:c.name||"Video",title:d||"Video",description:""}})})},sn=async r=>{const s=Array.from(r.target.files||[]);if(r.target.value="",s.length===0)return;const l=[],c=[],d=[];for(const N of s){const S=N.type||"";S.startsWith("video/")?c.push(N):S.startsWith("image/")?l.push(N):d.push(`“${N.name}” is not a supported file (images or videos only)`)}d.length>0&&z(N=>[...N,{role:"assistant",content:`Skipped ${d.length===1?"a file":"some files"}: ${d.join("; ")}.`,timestamp:new Date().toISOString()}]),await Ja(l),an(c)},sa=()=>
41{if(Ut)return;const r=et;if(jt(null),r?.importId!=null){const s=(r.videos||[]).map(l=>l.importItemId).filter(Number.isInteger);s.length>0&&te.releaseCreativeImportVideos(r.importId,{skip:s}).catch(()=>{})}},Xa=async()=>{if(!et||Ut)return;const r=(et.videos||[]).filter(s=>(s.title||"").trim());if(r.length!==0){if(Kr(!0),et.importId!=null){try{await te.releaseCreativeImportVideos(et.importId,{videos:r.map(s=>({itemId:s.importItemId,title:s.title.trim(),description:(s.description||"").trim()})),skip:(et.videos||[]).filter(s=>!(s.title||"").trim()).map(s=>s.importItemId).filter(Number.isInteger)})}catch(s){z(l=>[...l,{role:"assistant",content:`Could not start the upload: ${s.response?.data?.error||s.message}`,timestamp:new Date().toISOString()}])}Kr(!1),jt(null);return}for(const s of r){const l=s.title.trim();try{const{uploadId:c}=s.localFile?await te.uploadLocalVideo(s.localFile,{googleAdsAccountId:v,title:l,description:(s.description||"").trim()}):await te.importDriveVideo({googleAdsAccountId:v,driveFileId:s.driveFileId,title:l,description:(s.description||"").trim()});wr(d=>[...d,{id:c,title:l,status:"queued",progress:0,error:null}]),tn(c)}catch(c){const d=c.response?.status===409||c.response?.data?.needsReconnect===!0;if(z(N=>[...N,{role:"assistant",content:d?s.localFile?"The Google Ads connection for this account expired. Reconnect the ad account in Account Settings, then try again.":"Your Google connection is missing Drive access. Reconnect Google in Settings → Integrations, then try again.":`Could not start the upload for “${l}”: ${c.response?.data?.error||c.message}`,timestamp:new Date().toISOString()}]),d)break}}Kr(!1),jt(null)}},sr=r=>{const s=typeof r=="string"?ke.find(l=>l.id===r):r;s&&(s.params?.length>0?Be(s):Nt(s.message||s.label,s.id))},nn=(r,s,l)=>{Be(null),Nt(r,s,l)},ln=r=>{Me(r.prompt),tt.current?.focus()},on=async({title:r,prompt:s})=>{It(!0);try{const l=gt?.prompt;if(l){const c=await te.updateCustomPrompt(l.id,{title:r,prompt:s});Dt(d=>d.map(N=>N.id===l.id?c.prompt:N))}else{const c=await te.createCustomPrompt({title:r,prompt:s});Dt(d=>[c.prompt,...d])}it(null)}finally{It(!1)}},cn=async()=>{const r=gt?.prompt;if(r){It(!0);try{await te.deleteCustomPrompt(r.id),Dt(s=>s.filter(l=>l.id!==r.id)),it(null)}finally{It(!1)}}},[Qa,$a]=o.useState(null),dn=r=>{const s=We.substring(0,vt),l=We.substring(vt+1+fr.length);let c;r._entityType==="adgroup"?c=`@adgroup:${r.name} (in ${r.campaignName})`:(c=`@campaign:${r.name}`,$a(r.name));const d=`${s}${c} ${l}`;Me(d),bt(!1),He(""),yt(-1),tt.current?.focus()},Vt=()=>{Ie(null),z([]),t(null),X(!1),requestAnimationFrame(()=>tt.current?.focus())},es=async r=>{try{await te.deleteConversation(r),ie(s=>({conversations:(s.conversations||[]).filter(l=>l.id!==r)})),ae===r&&Vt()}catch(s){console.error("Failed to delete conversation:",s)}},un=async r=>{try{await te.approveCampaignDraft(r),z(s=>s.map(l=>l.campaignDraft?.id===r?{...l,campaignDraft:{...l.campaignDraft,status:"approved"}}:Array.isArray(l.campaignDrafts)&&l.campaignDrafts.some(c=>c?.id===r)?{...l,campaignDrafts:l.campaignDrafts.map(c=>c?.id===r?{...c,status:"approved"}:c)}:l))}catch(s){console.error("Failed to approve draft:",s)}},xn=async r=>{try{await te.rejectCampaignDraft(r),z(s=>s.map(l=>l.campaignDraft?.id===r?{...l,campaignDraft:{...l.campaignDraft,status:"rejected"}}:Array.isArray(l.campaignDrafts)&&l.campaignDrafts.some(c=>c?.id===r)?{...l,campaignDrafts:l.campaignDrafts.map(c=>c?.id===r?{...c,status:"rejected"}:c)}:l))}catch(s){console.error("Failed to reject draft:",s)}},Yt=(r,s)=>{const l=c=>typeof s=="function"?s(c):s;z(c=>c.map(d=>d.campaignDraft?.id===r?{...d,campaignDraft:{...d.campaignDraft,...l(d.campaignDraft)}}:Array.isArray(d.campaignDrafts)&&d.campaignDrafts.some(N=>N?.id===r)?{...d,campaignDrafts:d.campaignDrafts.map(N=>N?.id===r?{...N,...l(N)}:N)}:d))},mn=async(r,{intervalMs:s=3e3,maxMs:l=600*1e3}={})=>{const c=Date.now()+l;let d=null;for(;;){try{const N=await te.getCampaignDraft(r);d=N?.draft||N||null}catch{}if(d&&d.status!=="deploying"||Date.now()>=c)return d;await new Promise(N=>setTimeout(N,s))}},pn=async(r,s)=>{Yt(r,{status:"deploying"});try{const l=await te.deployCampaignDraft(r,s);Yt(r,{status:"deployed",deployedCampaignId:l.campaignId,...l.status&&{deployStatus:l.status}
41,...l.campaignName&&{campaignName:l.campaignName},...l.biddingFallback&&{biddingFallback:l.biddingFallback}}),l.cloneOutcome&&Yt(r,d=>({structure:{...d?.structure||{},_deployed:{...(d?.structure||{})._deployed||{},_cloneDeploy:l.cloneOutcome}}})),(l.biddingFallback||(l.droppedSearchThemes||[]).length>0||(l.deployNotes||[]).length>0)&&l.message&&z(d=>[...d,{role:"assistant",content:l.message,timestamp:new Date().toISOString()}])}catch(l){const c=l?.response?.data||{},d=await mn(r);if(d?.status==="deployed"){Yt(r,{status:"deployed",deployedCampaignId:d.deployedCampaignId,...d.structure?._deployed?._deployStatus&&{deployStatus:d.structure._deployed._deployStatus}});return}if(d&&d.status!=="failed"&&d.status!=="deploying"){Yt(r,{status:d.status,deployError:c.error||l?.message||null,deployErrorGuidance:c.guidance||null});return}const N=d?.status==="failed"?d.deployError||c.error||l?.message||"Deployment failed":d?.status==="deploying"?"Deployment is still running on the server after 10 minutes — reload this page to see its final status.":c.error||l?.message||"Could not reach the server to confirm the deployment — reload this page to check.";Yt(r,{status:"failed",deployError:N,deployErrorGuidance:d?.status==="failed"&&(d.deployErrorGuidance||c.guidance)||null}),z(S=>[...S,{role:"assistant",content:`Deployment failed: ${N}`,timestamp:new Date().toISOString()}])}},ts=async(r,s)=>{try{const l=await te.updateCampaignDraft(r,s);return l.draft?(z(c=>c.map(d=>d.campaignDraft?.id===r?{...d,campaignDraft:{...d.campaignDraft,...l.draft}}:Array.isArray(d.campaignDrafts)&&d.campaignDrafts.some(N=>N?.id===r)?{...d,campaignDrafts:d.campaignDrafts.map(N=>N?.id===r?{...N,...l.draft}:N)}:d)),!0):!1}catch(l){throw console.error("Failed to save draft:",l),l}},gn=async(r,s=null,l={})=>{try{const c=await te.approveActionProposal(r,s,l),d=c.proposal?.operations||s||c.operations;return z(N=>N.map(S=>S.actionProposal?.id===r?{...S,actionProposal:{...S.actionProposal,status:"approved",...d&&{operations:d}}}:S)),{success:!0}}catch(c){return console.error("Failed to approve action:",c),{success:!1}}},hn=async r=>{try{await te.rejectActionProposal(r),z(s=>s.map(l=>l.actionProposal?.id===r?{...l,actionProposal:{...l.actionProposal,status:"rejected"}}:l))}catch(s){console.error("Failed to reject action:",s)}},bn=async(r,s={})=>{try{z(c=>c.map(d=>d.actionProposal?.id===r?{...d,actionProposal:{...d.actionProposal,status:"executing"}}:d));const l=await te.executeActionProposal(r,s);return z(c=>c.map(d=>d.actionProposal?.id===r?{...d,actionProposal:{...d.actionProposal,status:"executed",results:l.results}}:d)),{status:"executed",results:l.results}}catch(l){const c=l?.response?.data?.results||null;return z(d=>d.map(N=>N.actionProposal?.id===r?{...N,actionProposal:{...N.actionProposal,status:"failed",results:c}}:N)),{status:"failed",results:c}}};if(n)return e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(Ae,{size:24,className:"animate-spin text-[var(--accent-blue)]"})});const Sr=le.length>0,rs=e.jsx("div",{className:"w-full","data-tour":"advisor-input",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-3",children:[e.jsx(Je,{children:ue&&e.jsx(xe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:e.jsx(hl,{conversationId:ae,googleAdsAccountId:v,onScraped:()=>{}})})}),Ia&&e.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-xl bg-sky-500/5 border border-sky-500/20",children:[e.jsx(da,{size:16,className:"text-sky-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] flex-1",children:Ia}),e.jsx("button",{onClick:qa,disabled:rr,className:"px-3 py-1.5 rounded-lg bg-[var(--accent-blue)] text-[var(--text-primary)] text-xs font-medium hover:bg-[var(--accent-blue-bright)] transition disabled:opacity-40",children:rr?"Opening…":"Pick from Google Drive"}),e.jsx("button",{onClick:()=>Ft(null),className:"p-1 rounded text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition","aria-label":"Dismiss",children:e.jsx(Ee,{size:14})})]}),Oa.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Oa.map(r=>{const s=r.status==="failed",l=!s&&(r.awaiting||0)>0,c=!s&&!l&&(r.uploading||0)>0,d=r.status==="done"&&!l&&!c,N=s?"Fehlgeschlagen":l?`Titel fehlt · ${r.done}/${r.total}`:c?`${r.done}/${r.total} · Video wird zu YouTube hochgeladen`:d?`Fertig · ${r.done}/${r.total}`:`${r.done}/${r.total}`;return e.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-xl border text-xs ${s?"bg-red-500/5 border-red-500/20 text-red-300":d?"bg-emerald-500/5 border-emerald-500/20 text-emerald-300":"bg-rose-500/5 border-rose-500/20 text-[var(--text-secondary)]"}`,children:[d?e.jsx(De,{size:14,className:"text-emerald-400"}):s?e.jsx(_r,{size:14,className:"text-red-400"}):l?e.jsx(ua,{size:14,className:"text-rose-400"}):e.jsx(Ae,{size:14,className:"animate-spin text-rose-400"}),e.jsx("span",{children:"Creatives importieren"}),e.jsxs("span",{className:"opacity-70",children:["· ",N]}),r.failed+(r.skipped||0)>0&&!s&&e.jsxs("span",{className:"opacity-70",children:["· ",r.failed+(r.skipped||0)," übersprungen"]})]},`imp-${r.id}`)})}),Ga.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Ga.map(r=>{const s=r.status==="uploading"?`Uploading… ${Math.round((r.progress||0)*100)}%`:r.status==="processing"?"YouTube processing…":r.status==="done"?"Done":r.status==="failed"?"Failed":"Queued…",l=r.status==="failed",c=r.status==="done";return e.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-xl border text-xs ${l?"bg-red-500/5 border-red-500/20 text-red-300":c?"bg-emerald-500/5 border-emerald-500/20 text-emerald-300":"bg-rose-500/5 border-rose-500/20 text-[var(--text-secondary)]"}`,children:[c?e.jsx(De,{size:14,className:"text-emerald-400"}):l?e.jsx(_r,{size:14,className:"text-red-400"}):e.jsx(Ae,{size:14,className:"animate-spin text-rose-400"}),e.jsx("span",{className:"truncate max-w-[160px]",title:r.title,children:r.title}),e.jsxs("span",{className:"opacity-70",children:["· ",s]})]},r.id)})}),_t.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 p-2 rounded-xl bg-[var(--bg-overlay)] border border-[var(--border-subtle)]",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)] mr-1",children:"Images to send:"}),_t.map((r,s)=>e.jsxs("div",{className:"relative group flex items-center gap-1.5 rounded-lg border border-[var(--border-medium)] bg-[var(--bg-overlay)] overflow-hidden",children:[e.jsx("img",{src:r.url,alt:"",className:"w-12 h-12 object-cover"}),e.jsxs("div",{className:"pr-8 py-1",children:[(r.isLogo||r.label)&&e.jsxs("span",{className:"flex items-center gap-1",children:[r.isLogo&&e.jsx("span",{className:"text-[9px] font-semibold px-1 py-px rounded bg-purple-500/90 text-white",children:"Logo"}),r.label&&e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)]",children:r.label})]}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] truncate max-w-[120px] block",title:r.url,children:r.url.
41split("/").pop()||"Image"})]}),e.jsx("button",{type:"button",onClick:()=>Xs(s),className:"absolute top-1 right-1 p-1 rounded bg-[var(--bg-backdrop)] text-[var(--text-secondary)] hover:text-[var(--hover-text)] hover:bg-red-500/80 transition","aria-label":"Remove",children:e.jsx(Ee,{size:14})})]},`${r.url}-${s}`))]}),h?.exhausted&&e.jsx("div",{className:"mb-3 p-4 rounded-xl border border-red-500/20 bg-red-500/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(xr,{size:18,className:"text-red-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)] mb-1",children:"AI credits exhausted"}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-3",children:"You've used all your AI credits for this billing cycle. Your dashboard, feed management, and other features still work normally."}),e.jsx(ia,{to:"/app/settings",className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-[var(--accent-blue)] text-white text-xs font-medium rounded-lg hover:bg-[var(--accent-blue-bright)] transition",children:"Upgrade Plan"})]})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(Rr,{visible:yr,campaigns:Hr,adGroups:Vr,filter:fr,onSelect:dn,onClose:()=>bt(!1),direction:Sr?"up":"down"}),e.jsx("input",{ref:ye,type:"file",accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:qs}),e.jsxs("div",{className:"rounded-3xl bg-[var(--bg-elevated)] border border-[var(--border-subtle)] shadow-lg transition focus-within:border-[var(--accent-blue)]/40 focus-within:ring-1 focus-within:ring-[var(--accent-blue)]/30",children:[e.jsx("textarea",{ref:tt,value:We,onChange:r=>{const s=r.target.value;Me(s);const l=r.target.selectionStart,c=s.substring(0,l),d=c.lastIndexOf("@");if(d>=0&&(d===0||c[d-1]===" "||c[d-1]===`
42`)){const N=c.substring(d+1);!N.includes(" ")||N.length<30?(bt(!0),He(N),yt(d),vr(!0)):bt(!1)}else bt(!1)},onKeyDown:r=>{yr&&Rr.handleKeyDown&&Rr.handleKeyDown(r)||r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),Nt())},placeholder:Sr?"Continue the conversation...":be==="de"?"Frag alles über dein Google Ads Konto...":"Ask anything about your Google Ads account...",rows:1,className:"w-full px-4 pt-3 pb-1 bg-transparent border-0 text-sm text-[var(--text-primary)] placeholder-[var(--text-tertiary)] resize-none focus:outline-none",style:{minHeight:"64px",maxHeight:"200px"},disabled:h?.exhausted,onInput:r=>{r.target.style.height="auto",r.target.style.height=Math.min(r.target.scrollHeight,200)+"px"}}),e.jsxs("div",{className:"flex items-center justify-between px-2 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("div",{className:"relative",ref:Wr,children:[e.jsx("button",{onClick:()=>Bt(r=>!r),disabled:!v||Ge,className:`p-1.5 rounded-lg transition disabled:opacity-40 disabled:cursor-not-allowed ${Ar?"text-[var(--text-primary)] bg-[var(--bg-overlay)]":"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-overlay)]"}`,title:"Attach: Google Ads Library, Google Drive, or upload from your computer",children:e.jsx(Ke,{size:18})}),Ar&&e.jsx("div",{className:"absolute bottom-full mb-2 left-0 w-60 bg-[var(--dropdown-bg)] border border-[var(--border-medium)] rounded-xl shadow-2xl overflow-hidden z-50",children:e.jsxs("div",{className:"py-1",children:[e.jsxs("button",{onClick:()=>{Bt(!1),Za()},disabled:Rt||g,className:"w-full flex items-center gap-2.5 px-3 py-2.5 text-left text-sm text-[var(--text-primary)] hover:bg-[var(--bg-overlay)] transition disabled:opacity-40",children:[e.jsx(Dr,{size:16,className:"text-purple-400 flex-shrink-0"}),e.jsx("span",{children:"Google Ads Library"})]}),e.jsxs("button",{onClick:()=>{Bt(!1),qa()},disabled:rr,className:"w-full flex items-center gap-2.5 px-3 py-2.5 text-left text-sm text-[var(--text-primary)] hover:bg-[var(--bg-overlay)] transition disabled:opacity-40",children:[rr?e.jsx(Ae,{size:16,className:"animate-spin text-sky-400 flex-shrink-0"}):e.jsx(da,{size:16,className:"text-sky-400 flex-shrink-0"}),e.jsx("span",{children:"Google Drive"})]}),e.jsxs("button",{onClick:()=>{Bt(!1),Pa.current?.click()},disabled:Rt,className:"w-full flex items-center gap-2.5 px-3 py-2.5 text-left text-sm text-[var(--text-primary)] hover:bg-[var(--bg-overlay)] transition disabled:opacity-40",children:[Rt?e.jsx(Ae,{size:16,className:"animate-spin text-sky-400 flex-shrink-0"}):e.jsx(ca,{size:16,className:"text-sky-400 flex-shrink-0"}),e.jsx("span",{children:"Upload from computer"})]})]})})]}),e.jsx("input",{ref:Pa,type:"file",accept:"image/jpeg,image/png,image/webp,image/gif,video/*",multiple:!0,className:"hidden",onChange:sn}),e.jsx("button",{onClick:()=>X(!ue),className:`p-1.5 rounded-lg transition ${ue?"text-[var(--accent-blue-bright)] bg-[var(--accent-blue)]/10":"text-emerald-400 hover:text-emerald-300 hover:bg-emerald-500/10"}`,title:"Scrape a URL for campaign content",children:e.jsx(Mr,{size:16})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(fi,{disabled:!v||Ge||h?.exhausted,onTranscript:r=>{Me(s=>(s&&s.trim()?s.replace(/\s+$/,"")+" ":"")+r),requestAnimationFrame(()=>{if(tt.current){tt.current.focus();const s=tt.current.value.length;tt.current.setSelectionRange(s,s)}})}}),Ge&&Pt?e.jsx("button",{onClick:zs,disabled:Pt==="requested",className:"p-2 rounded-xl bg-[var(--accent-blue)] hover:bg-[var(--accent-blue-bright)] text-[var(--text-primary)] transition disabled:opacity-30 disabled:cursor-not-allowed",title:"Stop generating",children:Pt==="requested"?e.jsx(Ae,{size:18,className:"animate-spin"}):e.jsx(Ca,{size:16,fill:"currentColor"})}):e.jsx("button",{onClick:()=>Nt(),disabled:!We.trim()&&!_t.length||Ge||!v||h?.exhausted,className:"p-2 rounded-xl bg-[var(--accent-blue)] hover:bg-[var(--accent-blue-bright)] text-[var(--text-primary)] transition disabled:opacity-30 disabled:cursor-not-allowed",children:Ge?e.jsx(Ae,{size:18,className:"animate-spin"}):e.jsx(Fn,{size:18})})]})]})]})]}),(()=>{const r=[...le||[]].reverse().find(l=>l.role==="assistant");return r?.campaignDraft&&["draft","modified"].includes(r.campaignDraft.status)||Array.isArray(r?.campaignDrafts)&&r.campaignDrafts.some(l=>["draft","modified"].includes(l?.status))?e.jsx("div",{className:"text-center text-[11px] text-[var(--text-tertiary)] mt-1.5",children:'Tip: Refine the draft in chat — e.g. "Add 5 headlines", "Set budget to 20", "Add Bavaria to locations"'}):null})(),e.jsx("div",{className:"text-center text-[10px] text-[var(--text-tertiary)] mt-1",children:be==="de"?"AdSpector Agent nutzt deine echten Kontodaten. Nichts wird ohne deine Freigabe ausgeführt.":"AdS
42pector Agent uses your real account data. Nothing runs without your approval."})]})});return e.jsxs("div",{className:"flex h-[calc(100dvh-4rem)] overflow-hidden",children:[e.jsx("div",{className:"w-52 shrink-0 flex flex-col hidden md:flex overflow-hidden",style:{background:"var(--bg-primary)",borderRight:"1px solid var(--border-subtle)"},children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"p-3",children:e.jsxs("button",{onClick:Vt,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-xl bg-[var(--bg-overlay)] border border-[var(--border-medium)] text-[var(--text-primary)] text-sm font-medium transition hover:bg-[var(--bg-overlay-heavy)]",children:[e.jsx(Ke,{size:15}),"New Chat"]})}),e.jsx("div",{className:"px-3 pb-2",children:e.jsx("div",{className:"text-[10px] uppercase tracking-[0.15em] text-[var(--text-tertiary)] font-medium",children:"Chat History"})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-1.5 pb-2 space-y-0.5",children:fe.length===0?e.jsx("div",{className:"text-center text-[var(--text-tertiary)] text-xs py-8",children:"No conversations yet"}):fe.map(r=>e.jsx(ws,{conv:r,isActive:r.id===ae,onClick:()=>ar(r.id),onDelete:es},r.id))})]})}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"shrink-0 flex items-center justify-between gap-2 px-3 sm:px-4 py-3 border-b border-[var(--border-subtle)] relative z-10 bg-[var(--bg-primary)]/90 backdrop-blur-md",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lr,{size:16,className:"text-[var(--accent-blue)] shrink-0"}),e.jsx("span",{className:"font-semibold text-[var(--text-primary)] hidden sm:inline",children:"AdSpector Agent"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 min-w-0",children:[A.length>0&&e.jsx(Tn,{accounts:A,selectedAccount:Ye,onChange:r=>{U(r),Vt()},showWhenSingle:!0,compact:!0}),e.jsxs("div",{className:"hidden md:flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("button",{onClick:()=>mr(r=>r==="de"?"en":"de"),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay-heavy)] border border-[var(--border-subtle)] transition text-sm",title:`Ad copy language: ${be==="de"?"German":"English"}. Click to switch.`,children:[e.jsx(os,{size:14,className:"text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-[var(--text-primary)] font-medium uppercase",children:be})]}),e.jsxs(ia,{to:"/app/brand",className:"relative flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay-heavy)] border border-[var(--border-subtle)] transition text-sm",title:st.info,children:[e.jsx(as,{size:14,className:"text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-[var(--text-primary)] font-medium",children:st.button}),!j&&P&&e.jsxs("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-full ${E===re?"bg-emerald-500/15 text-emerald-400":"bg-[var(--bg-overlay-heavy)] text-[var(--text-tertiary)]"}`,children:[E,"/",re]})]}),m?.role==="admin"&&e.jsx("button",{disabled:!ae,onClick:()=>q(!0),className:"relative flex items-center gap-1 px-2 py-1.5 rounded-lg bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay-heavy)] border border-[var(--border-subtle)] transition text-xs font-medium text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-[var(--bg-overlay)]",title:"Save to client file",children:e.jsx(fa,{size:12})})]}),e.jsxs("div",{className:"relative md:hidden",children:[e.jsxs("button",{onClick:()=>$(r=>!r),className:"relative p-2 rounded-lg bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay-heavy)] border border-[var(--border-subtle)] text-[var(--text-tertiary)] transition",title:"More options","aria-label":"More options",children:[e.jsx(Un,{size:16}),(Oe||L||ze)&&e.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-emerald-400"})]}),e.jsx(Je,{children:J&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>$(!1)}),e.jsxs(xe.div,{initial:{opacity:0,y:-8,scale:.96}
42,animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.96},transition:{duration:.15},className:"absolute right-0 top-full mt-2 w-56 max-w-[calc(100vw-1.5rem)] rounded-xl bg-[var(--dropdown-bg)] border border-[var(--border-subtle)] shadow-2xl overflow-hidden z-50 py-1",children:[e.jsxs("button",{onClick:()=>mr(r=>r==="de"?"en":"de"),className:"w-full flex items-center justify-between gap-2 px-3 py-2.5 text-left hover:bg-[var(--bg-overlay)] transition",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[e.jsx(os,{size:15,className:"text-[var(--text-tertiary)]"}),"Ad copy language"]}),e.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-primary)]",children:be})]}),e.jsxs(ia,{to:"/app/brand",onClick:()=>$(!1),className:"w-full flex items-center justify-between gap-2 px-3 py-2.5 text-left hover:bg-[var(--bg-overlay)] transition border-t border-[var(--border-subtle)] mt-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[e.jsx(as,{size:15,className:"text-[var(--text-tertiary)]"}),st.button]}),e.jsxs("span",{className:"text-[10px] font-semibold text-[var(--text-tertiary)]",children:[E,"/",re]})]}),m?.role==="admin"&&e.jsx("button",{disabled:!ae,onClick:()=>{q(!0),$(!1)},className:"w-full flex items-center justify-between gap-2 px-3 py-2.5 text-left hover:bg-[var(--bg-overlay)] transition disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:e.jsxs("span",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[e.jsx(fa,{size:15,className:"text-[var(--text-tertiary)]"}),"Save to client file"]})})]})]})})]}),e.jsx("button",{onClick:()=>R(!0),className:"md:hidden p-2 rounded-lg bg-[var(--bg-overlay)] hover:bg-[var(--bg-overlay-heavy)] border border-[var(--border-subtle)] text-[var(--text-tertiary)] transition",title:"Chat history","aria-label":"Chat history",children:e.jsx(Bn,{size:16})}),e.jsx("button",{onClick:Vt,className:"md:hidden p-2 rounded-lg hover:bg-[var(--bg-overlay)] text-[var(--text-tertiary)] transition",children:e.jsx(Ke,{size:18})})]})]}),e.jsx("div",{ref:Ua,className:"flex-1 overflow-y-auto",children:Sr?e.jsxs("div",{className:"p-4 space-y-4 max-w-4xl mx-auto",children:[le.map((r,s)=>e.jsx(gl,{msg:r,supersededDrafts:je[s],isStreaming:s===jr,onStreamComplete:()=>t(null),onStreamProgress:Ht,onApprove:un,onReject:xn,onDeploy:pn,onSave:ts,onPickLogo:Ks,onApproveAction:gn,onRejectAction:hn,onExecuteAction:bn,onSavePdf:_s,onTileClick:l=>{Ie(null),z([]),sr(l)},googleAdsAccountId:v},s)),e.jsx("div",{style:{position:"fixed",left:"-9999px",top:0,width:"210mm",opacity:0,pointerEvents:"none"},"aria-hidden":"true",children:e.jsx(wi,{ref:Ba,content:Rs,accountName:Ye?.descriptiveName||Ye?.customerId,date:new Date().toLocaleDateString()})}),Ge&&D.length>0&&e.jsx(xe.div,{initial:{opacity:0}
42,animate:{opacity:1},className:"py-2",children:e.jsx("div",{className:"space-y-1.5 mb-2",children:D.map(r=>e.jsxs("div",{className:"flex items-center gap-2",children:[r.status==="done"?e.jsx(De,{size:14,className:"text-emerald-400 shrink-0"}):e.jsx(Ae,{size:14,className:"text-[var(--accent-blue-bright)] animate-spin shrink-0"}),e.jsx("span",{className:`text-xs ${r.status==="done"?"text-[var(--text-tertiary)]":"text-[var(--text-secondary)]"}`,children:r.label})]},r.id))})}),Ge&&!le[le.length-1]?._streaming&&D.length===0&&e.jsx(xe.div,{"data-tour":"advisor-progress",initial:{opacity:0},animate:{opacity:1},className:"py-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[var(--bg-overlay-heavy)] animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[var(--bg-overlay-heavy)] animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[var(--bg-overlay-heavy)] animate-bounce",style:{animationDelay:"300ms"}})]}),x&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:x})]})}),e.jsx("div",{ref:Fa})]}):e.jsxs("div",{className:"flex flex-col items-center h-full p-4 sm:p-6 overflow-y-auto",children:[e.jsx(xe.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-center mt-6 sm:mt-14 mb-6 sm:mb-8",children:e.jsx("h1",{className:"font-display text-3xl sm:text-[2.75rem] leading-tight tracking-tight text-[var(--text-primary)]",children:be==="de"?e.jsxs(e.Fragment,{children:["Jeder verschwendete Euro — ",e.jsx("span",{className:"text-[var(--accent-ink)]",children:"gefunden."})]}):e.jsxs(e.Fragment,{children:["Every wasted euro — ",e.jsx("span",{className:"text-[var(--accent-ink)]",children:"found."})]})})}),e.jsx("div",{className:"w-full max-w-2xl mx-auto mb-8 sm:mb-10",children:rs}),gr?e.jsx(Ae,{size:20,className:"animate-spin text-[var(--accent-blue)]"}):ke.length>0?e.jsx(xe.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.15,duration:.3},className:"w-full max-w-4xl",children:(()=>{const r=[{key:"popular",label:"Popular",labelDe:"Beliebt",Icon:Ls,color:"fuchsia"},{key:"analyse",label:"Analyse",labelDe:"Analyse",Icon:Sa,color:"blue"},{key:"scale",label:"Scale",labelDe:"Scale",Icon:Cs,color:"green"},{key:"reports",label:"Reports",labelDe:"Reports",Icon:Ta,color:"violet"},{key:"build",label:"Campaign Builder",labelDe:"Campaign Builder",Icon:St,color:"amber",groups:["search","pmax","shopping","demand_gen"]},{key:"custom",label:"Custom",labelDe:"Custom",Icon:Dr,color:"cyan"}],s=[{group:"search",label:"Search",Icon:zr,color:"emerald"},{group:"pmax",label:"PMax",Icon:St,color:"amber"},{group:"shopping",label:"Shopping",Icon:xt,color:"rose"},{group:"demand_gen",label:"Demand Gen",Icon:mt,color:"violet"}],l={active:"bg-[var(--accent-soft)] border-[color-mix(in_srgb,var(--accent-ink)_35%,transparent)] text-[var(--accent-ink)]",inactive:"border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:border-[var(--border-medium)] hover:text-[var(--text-secondary)]"},c=ke.filter(C=>!C.hidden),d=c.filter(C=>!Ir.includes(C.id)),N=c.some(C=>Ir.includes(C.id)),S=C=>C.groups||[C.key],W=r.filter(C=>C.key==="popular"?N:C.key==="custom"?!0:d.some(Z=>S(C).includes(Z.group))),ee=r.find(C=>C.key===Pe),se=Pe==="popular"?Ir.map(C=>c.find(Z=>Z.id===C)).filter(Boolean):ee?d.filter(C=>S(ee).includes(C.group)):d.filter(C=>C.group===Pe);return e.jsxs(e.Fragment,{children:[e.jsx("div",{"data-tour":"advisor-categories",className:"flex flex-wrap justify-center gap-2 sm:gap-2.5 mb-4 sm:mb-5",children:W.map(C=>{const Z=Pe===C.key,V=C.key==="popular"?Ir.filter(Le=>c.some(Y=>Y.id===Le)).length:C.key==="custom"?Ur.length:d.filter(Le=>S(C).includes(Le.group)).length;return e.jsxs("button",{...C.key==="analyse"?{"data-tour":"advisor-analyse-pill"}:{},onClick:()=>Lt(Z?null:C.key),className:`flex items-center gap-2 px-3.5 py-2 sm:px-4 sm:py-2.5 rounded-full border text-sm font-medium transition-all ${Z?l.active:l.inactive}`,children:[e.jsx(C.Icon,{size:15}),e.jsx("span",{children:be==="de"?C.labelDe:C.label}),e.jsx("span",{className:`text-[11px] ${Z?"opacity-70":"opacity-40"}`,children:V})]},C.key)})}),e.jsx(Je,{mode:"wait",children:Pe==="custom"?e.jsxs(xe.div,{initial:{opacity:0,y:8}
42,animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2},className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[Ur.map(C=>{const Z=(i?il:nl).cyan;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>ln(C),className:`group w-full flex items-start gap-3 p-3.5 pr-10 rounded-xl border ${Z.border} ${Z.glow} hover:bg-[var(--bg-overlay)] transition-all text-left`,children:[e.jsx("div",{className:`p-2 rounded-lg bg-[var(--bg-overlay)] ${Z.icon} transition shrink-0`,children:e.jsx(Dr,{size:16})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] font-medium text-[var(--text-primary)] mb-0.5",children:C.title}),e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] leading-relaxed line-clamp-2",children:C.prompt})]})]}),e.jsx("button",{onClick:()=>it({prompt:C}),title:be==="de"?"Bearbeiten":"Edit",className:"absolute top-2 right-2 p-1.5 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-overlay)] transition",children:e.jsx(Ts,{size:13})})]},C.id)}),e.jsxs("button",{onClick:()=>it({prompt:null}),className:"flex items-center justify-center gap-2 p-3.5 rounded-xl border border-dashed border-cyan-500/30 hover:border-cyan-500/50 text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-overlay)] transition-all min-h-[64px]",children:[e.jsx(Ke,{size:15}),e.jsx("span",{className:"text-[13px] font-medium",children:be==="de"?"Neuer Prompt":"New prompt"})]})]},"custom"):Pe==="build"&&se.length>0?e.jsx(xe.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2},className:"space-y-4",children:s.map(C=>{const Z=d.filter(V=>V.group===C.group);return Z.length?e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1 text-[11px] font-semibold uppercase tracking-wider text-[var(--text-tertiary)]",children:[e.jsx(C.Icon,{size:12}),e.jsx("span",{children:C.label})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:Z.map(V=>e.jsx(xa,{prompt:V,art:ha[V.id]||null,Icon:va[V.icon]||lr,onClick:sr},V.id))})]},C.group):null})},"build"):Pe==="popular"&&se.length>0?e.jsx(xe.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2},className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:se.map(C=>e.jsx(xa,{prompt:C,art:ha[C.id]||null,Icon:va[C.icon]||lr,onClick:sr,dataTour:C.id==="performance_review"?"advisor-perf-review":void 0},C.id))},"popular"):Pe&&se.length>0?e.jsx(xe.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2},className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:se.map(C=>e.jsx(xa,{prompt:C,art:ha[C.id]||null,Icon:va[C.icon]||lr,onClick:sr},C.id))},Pe):null})]})})()}):null,Qe]})}),Sr?e.jsx("div",{className:"shrink-0 border-t border-[var(--border-subtle)] px-3 pt-3 sm:px-4 sm:pt-4 relative z-10 bg-[var(--bg-primary)]/90 backdrop-blur-md",style:{paddingBottom:"calc(env(safe-area-inset-bottom, 0px) + 0.75rem)"},children:rs}):null]}),e.jsx(Je,{children:F&&e.jsxs("div",{className:"fixed inset-0 z-50 md:hidden",children:[e.jsx(xe.div,{initial:{opacity:0}
42,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"absolute inset-0 bg-[var(--bg-backdrop)]",onClick:()=>R(!1)}),e.jsxs(xe.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.25,ease:"easeOut"},className:"absolute right-0 top-0 h-full w-full max-w-xs flex flex-col",style:{background:"var(--bg-primary)",borderLeft:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-b border-[var(--border-subtle)]",children:[e.jsx("span",{className:"text-sm font-semibold text-[var(--text-primary)]",children:"Chat History"}),e.jsx("button",{onClick:()=>R(!1),className:"p-1.5 rounded-lg hover:bg-[var(--bg-overlay)] text-[var(--text-tertiary)] transition","aria-label":"Close chat history",children:e.jsx(Ee,{size:18})})]}),e.jsx("div",{className:"p-3",children:e.jsxs("button",{onClick:()=>{Vt(),R(!1)},className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-xl bg-[var(--bg-overlay)] border border-[var(--border-medium)] text-[var(--text-primary)] text-sm font-medium transition hover:bg-[var(--bg-overlay-heavy)]",children:[e.jsx(Ke,{size:15}),"New Chat"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-1.5 pb-[calc(env(safe-area-inset-bottom,0px)+0.5rem)] space-y-0.5",children:fe.length===0?e.jsx("div",{className:"text-center text-[var(--text-tertiary)] text-xs py-8",children:"No conversations yet"}):fe.map(r=>e.jsx(ws,{conv:r,isActive:r.id===ae,onClick:()=>{ar(r.id),R(!1)},onDelete:es},r.id))})]})]})}),e.jsxs(Je,{children:[et&&(()=>{const r=et.videos||[],s=(d,N)=>jt(S=>({...S,videos:S.videos.map((W,ee)=>ee===d?{...W,...N}:W)})),l=r.length>0&&r.every(d=>(d.title||"").trim()),c=r.length>1;return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-[var(--bg-backdrop)] backdrop-blur-sm",onClick:sa,children:e.jsxs("div",{className:"rounded-2xl border border-[var(--border-subtle)] bg-[var(--bg-elevated)] shadow-2xl max-w-md w-full flex flex-col max-h-[85vh]",onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-subtle)]",children:[e.jsxs("h3",{className:"text-base font-medium text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(ua,{size:18,className:"text-rose-400"}),c?`Upload ${r.length} videos to YouTube`:"Upload video to YouTube"]}),e.jsx("button",{onClick:sa,className:"p-1 rounded text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition","aria-label":"Close",children:e.jsx(Ee,{size:18})})]}),e.jsx("div",{className:"p-4 space-y-4 overflow-y-auto",children:r.map((d,N)=>e.jsxs("div",{className:c?"pb-4 border-b border-[var(--border-subtle)] last:border-0 last:pb-0":"",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)] flex items-center gap-1.5 mb-2",children:[d.localFile?e.jsx(ca,{size:13,className:"flex-shrink-0"}):e.jsx(da,{size:13,className:"flex-shrink-0"})," ",e.jsx("span",{className:"truncate",title:d.fileName,children:d.fileName}),e.jsx("span",{className:"opacity-60 flex-shrink-0",children:Zr?`· to ${Zr.channelTitle} · ${Zr.uploadDefaults?.privacyStatus||"unlisted"}`:"· unlisted"})]}),e.jsxs("label",{className:"block text-xs font-medium text-[var(--text-secondary)] mb-1",children:["Title ",e.jsx("span",{className:"text-rose-400",children:"*"})]}),e.jsx("input",{type:"text",autoFocus:N===0,maxLength:100,value:d.title,onChange:S=>s(N,{title:S.target.value}),onKeyDown:S=>{S.key==="Enter"&&!c&&l&&Xa()},placeholder:"Video title",className:"w-full px-3 py-2 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-medium)] text-sm text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)]"}),e.jsxs("span",{className:"text-[10px] text-[var(--text-tertiary)] mt-1 block",children:[(d.title||"").length,"/100"]}),e.jsxs("label",{className:"block text-xs font-medium text-[var(--text-secondary)] mb-1 mt-2",children:["Description ",e.jsx("span",{className:"text-[var(--text-tertiary)] font-normal",children:"(optional — defaults to the title)"})]}),e.jsx("textarea",{rows:2,maxLength:5e3,value:d.description,onChange:S=>s(N,{description:S.target.value}),placeholder:"Leave empty to reuse the title",className:"w-full px-3 py-2 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-medium)] text-sm text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-blue)] resize-none"})]},d.importItemId||d.driveFileId||d.fileName))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4 border-t border-[var(--border-subtle)]",children:[e.jsx("button",{onClick:sa,disabled:Ut,className:"px-3 py-2 rounded-lg text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition disabled:opacity-40",children:et.importId!=null?"Skip upload":"Cancel"}),e.jsxs("button",{onClick:Xa,disabled:Ut||!l,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-rose-500 hover:bg-rose-400 text-white text-sm font-medium transition disabled:opacity-40 disabled:cursor-not-allowed",children:[Ut?e.jsx(Ae,{size:16,className:"animate-spin"}):e.jsx(ua,{size:16}),Ut?"Starting…":c?`Upload ${r.length} to YouTube`:"Upload to YouTube"]})]})]})})})(),Te&&e.jsx(xe.div,{initial:{opacity:0}
42,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-[var(--bg-backdrop)] backdrop-blur-sm",onClick:kr,children:e.jsxs(xe.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"rounded-2xl border border-[var(--border-subtle)] bg-[var(--bg-elevated)] shadow-2xl max-w-2xl w-full max-h-[80vh] flex flex-col",onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-subtle)]",children:[e.jsxs("h3",{className:"text-lg font-medium text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(Dr,{size:20,className:"text-[var(--accent-blue-bright)]"}),ct?"Logo wählen":"Google Ads Library"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Da.current?.click(),disabled:Rt||!v,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-purple-400 hover:text-purple-300 bg-purple-500/10 hover:bg-purple-500/20 border border-purple-500/20 text-xs font-medium transition disabled:opacity-40 disabled:cursor-not-allowed",title:"Upload images from your computer into this account's asset library (JPEG, PNG, WebP or GIF, max 8 MB each)",children:[Rt?e.jsx(Ae,{size:14,className:"animate-spin"}):e.jsx(ca,{size:14}),Rt?"Uploading…":"Upload from computer"]}),e.jsx("input",{ref:Da,type:"file",accept:"image/jpeg,image/png,image/webp,image/gif",multiple:!0,className:"hidden",onChange:Hs}),e.jsx("button",{onClick:kr,className:"p-1.5 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-overlay)] transition",children:e.jsx(Ee,{size:20})})]})]}),e.jsx("div",{className:"p-4 overflow-auto flex-1 min-h-0",children:Yr?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ae,{size:28,className:"animate-spin text-[var(--accent-blue)]"})}):ge.length===0?e.jsxs("div",{className:"text-[var(--text-tertiary)] text-center py-8 space-y-1",children:[e.jsx("p",{children:"No images in this account's asset library."}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:"If the library didn't load, check the chat for an error. You can also upload images or use Generate with AI."})]}):ct?e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4 p-2.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-tertiary)] leading-relaxed",children:["Das Logo muss ",e.jsx("span",{className:"text-emerald-400 font-medium",children:"quadratisch (1:1)"})," und mindestens ",e.jsx("span",{className:"text-emerald-400 font-medium",children:"128×128 px"})," groß sein. Geeignete Bilder sind grün markiert — ein Klick übernimmt das Bild als Logo."]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2 sm:gap-3",children:ge.map(r=>{const s=Zs(r),l=ea[r.url]?.w||r.width,c=ea[r.url]?.h||r.height;return e.jsxs("button",{type:"button",disabled:!s.ok||$r,onClick:()=>s.ok&&Ws(r.url),title:s.ok?"Als Logo übernehmen":s.reason,className:`relative rounded-lg border-2 overflow-hidden bg-[var(--bg-overlay)] aspect-square transition ${s.ok?"border-emerald-500/40 hover:border-emerald-400 hover:ring-2 hover:ring-emerald-400/30":"border-[var(--border-subtle)] opacity-40 grayscale cursor-not-allowed"}`,children:[e.jsx("img",{src:r.url,alt:r.name||"",loading:"lazy",className:"w-full h-full object-contain",onLoad:d=>{const N=d.target.naturalWidth,S=d.target.naturalHeight;N&&S&&Os(W=>W[r.url]?W:{...W,[r.url]:{w:N,h:S}})}}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 flex items-center justify-between gap-1 bg-[var(--bg-backdrop)] px-1.5 py-0.5",children:[s.ok?e.jsx("span",{className:"text-[9px] font-semibold text-[var(--text-primary)] px-1.5 py-0.5 rounded bg-emerald-500/80",children:"Als Logo geeignet"}):e.jsx("span",{className:"text-[9px] text-[var(--text-tertiary)]",children:s.reason}),e.jsxs("span",{className:"text-[10px] text-[var(--text-secondary)] ml-auto",children:[l||"?","×",c||"?"]})]})]},r.id)})})]}):(()=>{const r=ge.filter(W=>Jt(W)==="landscape"),s=ge.filter(W=>Jt(W)==="square"),l=ge.filter(W=>Jt(W)==="logo"),c=ge.filter(W=>Jt(W)==="other"),d={landscape:"bg-sky-500/80",square:"bg-emerald-500/80",logo:"bg-purple-500/80",other:"bg-[var(--bg-overlay-heavy)]"},N={landscape:"Landscape",square:"Square",logo:"Logo",other:""},S=(W,ee,se,C)=>se.length===0?null:e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${d[C]}`}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:W}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:ee}),e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:["(",se.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2 sm:gap-3",children:se.map(Z=>e.jsxs("button",{type:"button",onClick:()=>Vs(Z.url,C),className:`relative rounded-lg border-2 overflow-hidden bg-[var(--bg-overlay)] transition ${C==="landscape"?"aspect-[1.91/1]":"aspect-square"} ${Ze.has(Z.url)?"border-[var(--accent-blue)] ring-2 ring-[var(--accent-blue)]/30":"border-[var(--border-subtle)] hover:border-[var(--border-medium)]"}`,children:[e.jsx("img",{src:Z.url,alt:Z.name||"",className:"w-full h-full object-cover",loading:"lazy"}),Ze.has(Z.url)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[var(--accent-blue)]/20",children:e.jsx(De,{size:28,className:"text-[var(--text-primary)] drop-shadow",strokeWidth:3})}),C==="square"&&(Ce===Z.url?e.jsxs("span",{role:"button",tabIndex:0,title:"Logo-Markierung entfernen",onClick:V=>{V.stopPropagation(),Mt(null)}
42,className:"absolute top-1.5 left-1.5 z-10 inline-flex items-center gap-1 text-[10px] font-semibold px-2 py-1 rounded-md bg-purple-600 text-white shadow-md ring-1 ring-purple-300/70 cursor-pointer hover:bg-purple-500 transition",children:[e.jsx(De,{size:11,strokeWidth:3})," ",Z.isCurrentLogo?"Aktuelles Logo":"Logo ✓"]}):e.jsxs("span",{role:"button",tabIndex:0,title:"Dieses Bild als Logo verwenden",onClick:V=>{V.stopPropagation(),Ys(Z.url)},className:"absolute top-1.5 left-1.5 z-10 inline-flex items-center gap-1 text-[10px] font-semibold px-2 py-1 rounded-md bg-black/65 text-white backdrop-blur-sm shadow-md ring-1 ring-white/25 cursor-pointer hover:bg-purple-600 hover:ring-purple-300 transition",children:[e.jsx(mt,{size:11})," Als Logo"]})),C==="logo"&&Ce===Z.url&&e.jsxs("span",{className:"absolute top-1.5 left-1.5 z-10 inline-flex items-center gap-1 text-[10px] font-semibold px-2 py-1 rounded-md bg-purple-600 text-white shadow-md ring-1 ring-purple-300/70",children:[e.jsx(De,{size:11,strokeWidth:3})," ",Z.isCurrentLogo?"Aktuelles Logo":"Logo"]}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 flex items-center justify-between bg-[var(--bg-backdrop)] px-1.5 py-0.5",children:[N[C]&&e.jsx("span",{className:`text-[9px] font-semibold text-[var(--text-primary)] px-1.5 py-0.5 rounded ${d[C]}`,children:N[C]}),e.jsxs("span",{className:"text-[10px] text-[var(--text-secondary)] ml-auto",children:[Z.width,"×",Z.height]})]})]},Z.id))})]});return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4 p-2.5 rounded-lg bg-[var(--bg-overlay)] border border-[var(--border-subtle)] text-xs text-[var(--text-tertiary)] leading-relaxed",children:["PMax needs: ",e.jsx("span",{className:"text-sky-400 font-medium",children:"1 Landscape"})," (1.91:1, min 600×314) + ",e.jsx("span",{className:"text-emerald-400 font-medium",children:"1 Square"})," (1:1, min 300×300). Max ",e.jsx("span",{className:"font-medium text-[var(--text-secondary)]",children:"20 images per PMax asset group"}),"."," ",Ce?e.jsx("span",{className:"text-emerald-400 font-medium",children:"Logo ausgewählt ✓"}):e.jsxs(e.Fragment,{children:["Optionally pick a ",e.jsx("span",{className:"text-purple-400 font-medium",children:"Logo"})," (1:1, min 128×128)."]})]}),S("Landscape","1.91:1 · min 600×314",r,"landscape"),S("Square","1:1 · min 300×300",s,"square"),S("Logo-size","1:1 · 128–299px",l,"logo"),S("Other sizes","",c,"other")]})})()}),!Yr&&ge.length>0&&e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4 border-t border-[var(--border-subtle)]",children:[ct&&$r&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mr-auto",children:[e.jsx(Ae,{size:14,className:"animate-spin"})," Logo wird gesetzt…"]}),e.jsx("button",{onClick:kr,className:"px-4 py-2 rounded-lg text-[var(--text-secondary)] hover:bg-[var(--bg-overlay)] transition",children:ct?"Abbrechen":"Cancel"}),!ct&&Ze.size-(Ce&&Ze.has(Ce)?1:0)>20&&e.jsx("span",{className:"text-xs text-amber-400 mr-2 max-w-[20rem] leading-snug",children:"PMax asset groups take max 20 images — extras will be trimmed unless the AI splits them across multiple asset groups (Demand Gen allows more)."}),!ct&&(()=>{const r=Ce&&!Ze.has(Ce)?1:0,s=Ze.size+r;return e.jsx("button",{onClick:Js,disabled:s===0,className:"px-4 py-2 rounded-lg bg-[var(--accent-blue)] text-[var(--text-primary)] hover:bg-[var(--accent-blue-bright)] transition disabled:opacity-40 disabled:cursor-not-allowed",children:Ze.size===0&&r?"Logo verwenden":`Use selected (${s})`})})()]})]})})]}),hr&&e.jsx(ci,{tile:hr,language:be,onSend:nn,onClose:()=>Be(null)}),gt&&e.jsx(di,{prompt:gt.prompt,language:be,saving:Br,onSave:on,onDelete:cn,onClose:()=>it(null)}),ne&&Ye&&e.jsx(ui,{account:Ye,onClose:r=>{if(y(!1),ie(s=>({onboardingGoals:{...s.onboardingGoals||{},completedAt:new Date().toISOString()}})),pe(),r?.autoAudit){const s=ke.find(l=>l.id==="full_account_audit");if(s){const l=(s.message||"").replace(/\{\{timeframe\}\}/g,"30");setTimeout(()=>Nt(l,s.id),300)}}}}),B&&ae&&e.jsx(xi,{accountId:v,conversationId:ae,onClose:()=>q(!1)})]})}export{fo 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.