1import{u as k,r as a,j as e}from"./index-CiU28txl.js";import{u as y}from"./useImpersonation-Bci6Rvke.js";const C={en:{title:"Tracking",placement:"Placement",impressions:"Impressions",viewable:"Viewable",clicks:"Clicks",ctr:"CTR",viewability:"Viewability",noData:"No tracking data available for this period.",loadError:"Could not load tracking data."},de:{title:"Tracking",placement:"Placement",impressions:"Impressionen",viewable:"Sichtbar",clicks:"Klicks",ctr:"CTR",viewability:"Sichtbarkeit",noData:"Keine Tracking-Daten für diesen Zeitraum vorhanden.",loadError:"Tracking-Daten konnten nicht geladen werden."}};function E(){const{apiFetch:i}=y(),{locale:r}=k(),t=C[r],[n,b]=a.useState(null),[p,m]=a.useState(!0),[x,h]=a.useState(null),[c,j]=a.useState("7d"),[,f]=a.useTransition(),u=a.useCallback(async()=>{m(!0),h(null);try{const s=await i(`/api/publisher/events?range=${c}`);if(!s.ok)throw new Error("Failed");const w=await s.json();b(w)}catch{h(t.loadError)}finally{m(!1)}},[i,c,t.loadError]);a.useEffect(()=>{f(()=>{u()})},[u]);const d=s=>s.toLocaleString(r==="de"?"de-CH":"en-US");if(p)return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-text-primary mb-6",children:t.title}),e.jsx("div",{className:"rounded-2xl border border-border-subtle/50 bg-surface-raised/50 p-6",children:e.jsx("div",{className:"space-y-3",children:[1,2,3].map(s=>e.jsx("div",{className:"h-4 w-full animate-pulse rounded bg-surface-sunken"},s))})})]});if(x)return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-text-primary mb-6",children:t.title}),e.jsx("div",{className:"rounded-2xl border border-red-800/30 bg-red-900/10 p-6",children:e.jsx("p",{className:"text-sm text-red-400",children:x})})]});const l=n?.placements??[],v=Math.max(...l.map(s=>s.impressions),1),N=Math.max(...l.map(s=>s.clicks),1),g=Math.max(...l.map(s=>s.viewable),1);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-text-primary",children:t.title}),e.jsx("div",{className:"flex rounded-lg border border-border-subtle overflow-hidden",children:["7d","30d","90d"].map(s=>e.jsx("button",{onClick:()=>j(s),className:`px-3 py-1.5 text-xs font-medium transition-colors ${c===s?"bg-nexbid-600 text-white":"bg-surface-raised text-text-muted hover:text-text-primary"}`,children:s},s))})]}),e.jsx("div",{className:"rounded-2xl border border-border-subtle/50 bg-surface-raised/50 p-6",children:l.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:t.noData}):e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border-subtle/50 text-xs text-text-muted uppercase tracking-wide",children:[e.jsx("th",{className:"pb-3 pr-4",children:t.placement}),e.jsx("th",{className:"pb-3 pr-4",children:t.impressions}),e.jsx("th",{className:"pb-3 pr-4",children:t.viewable}),e.jsx("th",{className:"pb-3 pr-4",children:t.clicks}),e.jsx("th",{className:"pb-3 pr-4",children:t.ctr}),e.jsx("th",{className:"pb-3",children:t.viewability})]})}),e.jsx("tbody",{className:"divide-y divide-border-subtle/50",children:l.map(s=>e.jsxs("tr",{className:"text-text-muted",children:[e.jsx("td",{className:"py-3 pr-4 font-medium text-text-primary",children:s.placement_name}),e.jsx("td",{className:"py-3 pr-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-16 text-right tabular-nums",children:d(s.impressions)}),e.jsx(o,{value:s.impressions,max:v,color:"bg-nexbid-500"})]})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-16 text-right tabular-nums",children:d(s.viewable)}),e.jsx(o,{value:s.viewable,max:g,color:"bg-blue-500"})]})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-16 text-right tabular-nums",children:d(s.clicks)}),e.jsx(o,{value:s.clicks,max:N,color:"bg-amber-500"})]})}),e.jsxs("td",{className:"py-3 pr-4 tabular-nums",children:[s.ctr.toFixed(2),"%"]}),e.jsxs("td",{className:"py-3 tabular-nums",children:[s.viewability_rate.toFixed(1),"%"]})]},s.placement_id))})]})})]})}function o({value:i,max:r,color:t}){const n=r>0?i/r*100:0;return e.jsx("div",{className:"h-2 w-20 rounded-full bg-surface-sunken overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${t} transition-all`,style:{width:`${Math.max(n,2)}%`}})})}const D=E;export{D as Component,E 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.