PageSourceSearch

https://nexuspolitics.org/assets/ai-usage-BS0RLvJy.js

js nexuspolitics.org collected 2026-10-06 18:03:55 UTC 35,872 bytes, 1 lines download raw bytes

1import{j as e,q as Q,T as X,x as ee,y as L,z as x,A as se,D as g,dC as we,dD as Se,dE as Ae,at as B,K as D,aa as te,aA as ue,dF as me,B as j,aB as he,aC as xe,aD as ge,aE as pe,a5 as ae,aF as fe,Z as v,dG as De,dH as Ie,aO as Ce,aP as ze,aQ as Pe,aR as Le,aS as Be,bR as _e,dI as Ee,dJ as Ke,dK as $e,dL as Ue,dM as Me,E as Fe,O as Ge}from"./main-CRoKG4v1.js";import{aD as Re,ai as be,aG as K,r as u,aH as Oe,m as He,aI as Ze,z as Ve,ad as We,a6 as Ye,aJ as qe,aK as Je,aL as Qe}from"./icons-XSZ3OYVz.js";const Xe=["chat_issue","chat_issue_iframe","chat_dashboard","chat_cluster","summarize_issue","profile_summary","pressekit","live_issues","moderation","embeddings","voice_synthesis","voice_transcription","unattributed"];function es(s){return Xe.includes(s)}const E={chat:{label:"Anliegen-Chat",short:"Chat"},assistant:{label:"Dashboard-KI",short:"Dashboard"},content:{label:"Profile & Inhalte",short:"Inhalte"},system:{label:"Plattform",short:"System"}},V={enabled:!0,perUserDailyTokens:null,perIpDailyTokens:null,globalDailyTokens:null},je={chat_issue:{label:"Anliegen-Chat",description:"KI-Chat beim Einreichen eines Anliegens — auch für nicht angemeldete Besucher erreichbar.",group:"chat",system:!1,defaults:{enabled:!0,perUserDailyTokens:5e5,perIpDailyTokens:25e4,globalDailyTokens:1e7}},chat_issue_iframe:{label:"Anliegen-Chat (Einbettung)",description:"Derselbe Chat, eingebettet auf Webseiten von Politikern und Kommunen.",group:"chat",system:!1,defaults:{enabled:!0,perUserDailyTokens:5e5,perIpDailyTokens:25e4,globalDailyTokens:5e6}},chat_dashboard:{label:"Dashboard-Assistent",description:"KI-Assistent im Dashboard. Jede Anfrage enthält den gefilterten Problem-Kontext und ist daher token-intensiv.",group:"assistant",system:!1,defaults:{enabled:!0,perUserDailyTokens:1e6,perIpDailyTokens:2e5,globalDailyTokens:1e7}},chat_cluster:{label:"Cluster-Chat",description:"Chat zu einem Anliegen-Cluster (ab Basic-Tarif).",group:"assistant",system:!1,defaults:{enabled:!0,perUserDailyTokens:5e5,perIpDailyTokens:2e5,globalDailyTokens:5e6}},summarize_issue:{label:"Zusammenfassung Anliegen",description:"KI-Analyse der gefilterten Anliegen im Dashboard.",group:"assistant",system:!1,defaults:{enabled:!0,perUserDailyTokens:6e5,perIpDailyTokens:2e5,globalDailyTokens:5e6}},profile_summary:{label:"Profil-Zusammenfassung",description:"KI-generierte Zusammenfassung für Politiker- und Bürgerprofile.",group:"content",system:!1,defaults:{enabled:!0,perUserDailyTokens:1e5,perIpDailyTokens:5e4,globalDailyTokens:2e6}},pressekit:{label:"Pressekit",description:"Textgenerierung für das Pressekit-PDF.",group:"content",system:!1,defaults:{enabled:!0,perUserDailyTokens:1e5,perIpDailyTokens:5e4,globalDailyTokens:1e6}},live_issues:{label:"Live-Anliegen",description:"Kurzfassungen der neuesten Anliegen; öffentlich, ein Modellaufruf je Anliegen.",group:"content",system:!1,defaults:{enabled:!0,perUserDailyTokens:15e4,perIpDailyTokens:15e4,globalDailyTokens:2e6}},moderation:{label:"Inhaltsprüfung",description:"Automatische Prüfung neuer Inhalte auf Verstöße. Läuft im Namen der Plattform.",group:"system",system:!0,defaults:V},embeddings:{label:"Embeddings",description:"Vektorisierung von Inhalten für Ähnlichkeitssuche und Empfehlungen.",group:"system",system:!0,defaults:V},voice_synthesis:{label:"Sprachausgabe (Polly)",description:"KI-Antworten im Anliegen-Chat vorlesen. Zählt Zeichen statt Tokens.",group:"chat",system:!1,defaults:{enabled:!0,perUserDailyTokens:2e5,perIpDailyTokens:1e5,globalDailyTokens:5e6}},voice_transcription:{label:"Spracheingabe (Transcribe)",description:"Mikrofon-Diktat im Anliegen-Chat transkribieren. Zählt Audiosekunden statt Tokens.",group:"chat",system:!1,defaults:{enabled:!0,perUserDailyTokens:3600,perIpDailyTokens:1800,globalDailyTokens:1e5}},unattributed:{label:"Nicht zugeordnet",description:"Modellaufrufe ohne Feature-Zuordnung. Tauchen hier Werte auf, fehlt an einer Aufrufstelle die Zuordnung.",group:"system",system:!0,defaults:V}},ss=7,m=new Intl.NumberFormat("de-DE"),ke=new Intl.NumberFormat("de-DE",{notation:"compact",maximumFractionDigits:1});function y(s){return s>=1e5?ke.format(s):m.format(s)}function ts(s){return s>=1e3?ke.format(s):String(s)}function W(s){const[,t,r]=s.split("-");return`${r}.${t}.`}
1function O(s){return new Date(s).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}function z(s){const t=s.replace(/[.\s_]/g,"");return t===""?null:/^\d+$/.test(t)?Number(t):void 0}function G(s){return s===null?"∞":y(s)}function $(s){return s instanceof Error?s.message:"Aktion fehlgeschlagen."}const as={blocked:"Gesperrt",feature_disabled:"Bereich aus",rate_limit:"Ratenlimit",user_limit:"Kontolimit",ip_limit:"IP-Limit",global_limit:"Gesamtlimit"};function I({title:s,description:t,action:r,children:n,className:i}){return e.jsxs("section",{className:Q("min-w-0",i),children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-end justify-between gap-x-4 gap-y-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:s}),t&&e.jsx("p",{className:"text-muted-foreground mt-0.5 max-w-prose text-pretty text-sm",children:t})]}),r]}),n]})}function w({children:s,className:t}){return e.jsx("div",{className:Q("border-border min-w-0 rounded-xl border bg-white shadow-sm",t),children:s})}function H({text:s}){return e.jsxs(w,{className:"flex items-center gap-3 p-6",children:[e.jsx(Re,{className:"text-muted-foreground h-5 w-5 shrink-0"}),e.jsx("p",{className:"text-muted-foreground text-pretty text-sm",children:s})]})}const le=96,Y=32,U=5;function ns({values:s,label:t}){if(s.length<2)return null;const r=Math.max(...s,1),n=(le-U*2)/(s.length-1),i=s.map((a,l)=>({x:U+l*n,y:Y-U-a/r*(Y-U*2)})),d=i[i.length-1];return e.jsxs("svg",{role:"img","aria-label":t,viewBox:`0 0 ${le} ${Y}`,className:"h-8 w-24 shrink-0",children:[e.jsx("polyline",{fill:"none",stroke:"#c3c2b7",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",points:i.map(a=>`${a.x},${a.y}`).join(" ")}),e.jsx("circle",{cx:d.x,cy:d.y,r:4,className:"fill-primary",stroke:"#ffffff",strokeWidth:2})]})}function M({label:s,value:t,sub:r,icon:n,trend:i,trendLabel:d}){return e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-muted-foreground min-w-0 truncate text-sm",children:s}),e.jsx(n,{className:"text-muted-foreground h-4 w-4 shrink-0"})]}),e.jsxs("div",{className:"mt-3 flex items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-3xl font-semibold leading-none tracking-tight",children:t}),r&&e.jsx("div",{className:"text-muted-foreground mt-1.5 truncate text-xs",children:r})]}),i&&e.jsx(ns,{values:i,label:d??"Verlauf"})]})]})}const ls={ok:"bg-primary",warning:"bg-amber-500",critical:"bg-destructive"};function rs({used:s,limit:t,label:r}){if(t===null)return e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-medium tabular-nums",children:[y(s),e.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","Tokens heute"]})]}),e.jsx("div",{className:"bg-muted mt-2 h-2 rounded-full"}),e.jsx("div",{className:"text-muted-foreground mt-1.5 text-xs",children:"Kein Gesamtlimit gesetzt"})]});const n=t===0?1:s/t,i=n>=1?"critical":n>=.8?"warning":"ok";return e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-medium tabular-nums",children:[y(s),e.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","von ",y(t)," Tokens"]})]}),e.jsx("div",{role:"meter","aria-label":r,"aria-valuemin":0,"aria-valuemax":t,"aria-valuenow":Math.min(s,t),className:"bg-muted mt-2 h-2 overflow-hidden rounded-full",children:e.jsx("div",{className:Q("h-full rounded-full",ls[i]),style:{width:`${Math.min(n,1)*100}%`}})}),e.jsxs("div",{className:"text-muted-foreground mt-1.5 flex items-center gap-1 text-xs",children:[i==="warning"&&e.jsx(be,{className:"h-3 w-3"}),i==="critical"&&e.jsx(K,{className:"h-3 w-3"}),Math.round(n*100)," %",i==="warning"&&" · nahe am Limit",i==="critical"&&" · Limit erreicht"]})]})}const _=["chat","assistant","content","system"],R={chat:"#2a78d6",assistant:"#eb6834",content:"#1baf7a",system:"#c3c2b7"},re="#898781",ie="#d03b3b",is="#e1e0d9",de=200;function Ne(s){if(s<=0)return 1;const t=10**Math.floor(Math.log10(s)),r=s/t;return(r<=1?1:r<=2?2:r<=5?5:10)*t}function ye({columns:s,max:t,ticks:r,ariaLabel:n,emptyText:i,isEmpty:d}){const a=d?[0]:r;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"relative w-11 shrink-0",style:{height:de}
1,"aria-hidden":!0,children:a.map(l=>e.jsx("span",{className:"text-muted-foreground absolute right-0 translate-y-1/2 text-[11px] tabular-nums leading-none",style:{bottom:`${l/t*100}%`},children:ts(l)},l))}),e.jsxs("div",{role:"img","aria-label":n,className:"relative min-w-0 flex-1",style:{height:de},children:[a.map(l=>e.jsx("div",{className:"absolute inset-x-0 border-t",style:{bottom:`${l/t*100}%`,borderColor:is}},l)),e.jsx("div",{className:"absolute inset-0 flex items-stretch gap-1",children:s.map(l=>{const h=l.segments.filter(o=>o.value>0);return e.jsxs(we,{children:[e.jsx(Se,{asChild:!0,children:e.jsx("div",{className:"hover:bg-muted/60 flex min-w-0 flex-1 flex-col-reverse items-center rounded-t-md",children:h.map((o,p)=>e.jsx("div",{className:"w-full max-w-6 "+(p>0?"border-t-2 border-white":"")+(p===h.length-1?"rounded-t-[4px]":""),style:{height:`${o.value/t*100}%`,minHeight:3,backgroundColor:o.color}},o.color))})}),e.jsx(Ae,{children:l.tooltip})]},l.key)})}),d&&e.jsx("div",{className:"text-muted-foreground pointer-events-none absolute inset-0 flex items-center justify-center text-pretty px-4 text-center text-sm",children:i})]})]}),e.jsxs("div",{className:"mt-2 flex gap-2","aria-hidden":!0,children:[e.jsx("div",{className:"w-11 shrink-0"}),e.jsx("div",{className:"flex min-w-0 flex-1 gap-1",children:s.map(l=>e.jsx("div",{className:"min-w-0 flex-1 whitespace-nowrap text-center text-[11px] leading-none "+(l.emphasizeLabel?"text-foreground font-medium":"text-muted-foreground"),children:l.xLabel},l.key))})]})]})}function J({color:s,label:t,value:r,icon:n}){return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5 text-sm",children:[e.jsx("span",{className:"h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:s},"aria-hidden":!0}),n,e.jsx("span",{className:"truncate",children:t}),r&&e.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:r})]})}function ds({history:s}){const t=s.map(a=>{const l={chat:0,assistant:0,content:0,system:0};for(const[h,o]of Object.entries(a.byFeature))es(h)&&(l[je[h].group]+=o);return{...a,byGroup:l}}),r=Ne(Math.max(...t.map(a=>a.tokens),1)),n=_.map(a=>({group:a,total:t.reduce((l,h)=>l+h.byGroup[a],0)})),i=n.reduce((a,l)=>a+l.total,0),d=t.map((a,l)=>{const h=l===t.length-1;return{key:a.day,segments:_.map(o=>({value:a.byGroup[o],color:R[o]})),xLabel:(t.length-1-l)%2===0?W(a.day):null,emphasizeLabel:h,tooltip:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"font-medium",children:[W(a.day),h&&" (bisher)"]}),_.map(o=>e.jsxs("div",{className:"flex items-center gap-2 tabular-nums",children:[e.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:R[o]}}),e.jsx("span",{className:"flex-1",children:E[o].label}),e.jsx("span",{children:m.format(a.byGroup[o])})]},o)),e.jsxs("div",{className:"border-t border-white/30 pt-1 tabular-nums",children:["Gesamt ",m.format(a.tokens)," Tokens ·"," ",m.format(a.denied)," abgelehnt"]})]})}});return e.jsxs(w,{className:"flex-1 p-4",children:[e.jsx("ul",{className:"mb-4 flex flex-wrap gap-x-5 gap-y-1.5",children:n.map(({group:a,total:l})=>e.jsx(J,{color:R[a],label:E[a].label,value:y(l)},a))}),e.jsx(ye,{columns:d,max:r,ticks:[0,r/2,r],ariaLabel:`Tokenverbrauch der letzten ${t.length} Tage nach Bereichsgruppe, insgesamt ${y(i)}. Die Tabelle darunter enthält dieselben Werte.`,emptyText:`Noch keine KI-Nutzung in den letzten ${t.length} Tagen.`,isEmpty:i===0}),e.jsxs("details",{className:"mt-4 text-sm",children:[e.jsx("summary",{className:"text-muted-foreground hover:text-foreground cursor-pointer",children:"Als Tabelle anzeigen"}),e.jsxs(X,{className:"mt-2 text-xs",children:[e.jsx(ee,{children:e.jsxs(L,{children:[e.jsx(x,{className:"px-1.5",children:"Tag"}),_.map(a=>e.jsx(x,{className:"px-1.5 text-right",title:E[a].label,children:E[a].short},a)),e.jsx(x,{className:"px-1.5 text-right",children:"Gesamt"}),e.jsx(x,{className:"px-1.5 text-right",title:"Abgelehnt",children:"Abgel."})]})}),e.jsx(se,{children:[...t].reverse().map(a=>e.jsxs(L,{children:[e.jsx(g,{className:"px-1.5",children:W(a.day)}),_.map(l=>e.jsx(g,{className:"px-1.5 text-right tabular-nums",title:m.format(a.byGroup[l]),children:y(a.byGroup[l])},l)),e.jsx(g,{className:"px-1.5 text-right font-medium tabular-nums",title:m.format(a.tokens),children:y(a.tokens)}),e.jsx(g,{className:"px-1.5 text-right tabular-nums",children:m.format(a.denied)})]},a.day))})]})]})]})}function oe(s){return`${s}–${s+1} Uhr`}function os({hourly:s}){const t=Ne(Math.max(...s.map(a=>a.ok+a.denied),1)),r=s.reduce((a,l)=>a+l.ok,0),n=s.reduce((a,l)=>a+l.denied,0),i=s.reduce((a,l)=>l.ok+l.denied>a.ok+a.denied?l:a,s[0]??{hour:0,ok:0,denied:0}),d=s.map(a=>({key:String(a.hour),segments:[{value:a.ok,color:re},{value:a.denied,color:ie}],xLabel:a.hour%3===0?String(a.hour):null,tooltip:e.jsxs("div",{className:"space-y-1 tabular-nums",children:[e.jsx("div",{className:"font-medium",children:oe(a.hour)}),e.jsxs("div",{children:[m.format(a.ok+a.denied)," Aufrufe"]}),e.jsxs("div",{children:[m.format(a.denied)," abgelehnt"]})]})}));return e.jsxs(w,{className:"flex-1 p-4",children:[e.jsxs("ul",{className:"mb-1 flex flex-wrap gap-x-5 gap-y-1.5",children:[e.jsx(J,{color:re,label:"Erfolgreich",value:m.format(r)}),e.jsx(J,{color:ie,label:"Abgelehnt",value:m.format(n),icon:e.jsx(K,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0})})]}),e.jsx("p",{className:"text-muted-foreground mb-4 text-xs",children:r+n===0?"Aufrufe der letzten 7 Tage nach Uhrzeit (deutsche Zeit).":`Aufrufe der letzten 7 Tage nach Uhrzeit (deutsche Zeit). Am meisten los: ${oe(i.hour)}.`}),e.jsx(ye,{columns:d,max:t,ticks:[0,t],ariaLabel:`Aufrufe der letzten 7 Tage nach Tageszeit, ${m.format(r+n)} insgesamt, davon ${m.format(n)} abgelehnt.`,emptyText:"Noch keine Aufrufe im Anfrage-Protokoll.",isEmpty:r+n===0})]})}function cs({features:s,canEdit:t,onChanged:r}){return e.jsx(I,{title:"Verbrauch je Bereich",description:"Heutiger 
1Verbrauch gegen das Gesamtlimit des Bereichs. Die Einzellimits gelten je angemeldetem Konto bzw. je IP-Adresse (nicht angemeldet).",children:e.jsx("div",{className:"@2xl:grid-cols-2 @5xl:grid-cols-3 grid gap-4",children:s.map(n=>e.jsx(us,{feature:n,canEdit:t,onChanged:r},n.feature))})})}function F({label:s,value:t}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("dt",{className:"text-muted-foreground truncate text-xs",children:s}),e.jsx("dd",{className:"truncate text-sm font-medium tabular-nums",children:t})]})}function q({label:s,value:t}){return e.jsxs("span",{className:"bg-muted text-muted-foreground inline-flex items-center gap-1 whitespace-nowrap rounded-md px-2 py-0.5 text-xs",children:[s,e.jsx("span",{className:"text-foreground font-medium tabular-nums",children:G(t)})]})}function us({feature:s,canEdit:t,onChanged:r}){const n=je[s.feature].group,i=s.todayInputTokens+s.todayOutputTokens;return e.jsxs(w,{className:"flex flex-col gap-4 p-4"+(s.limits.enabled?"":" bg-muted/40"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:R[n]},title:E[n].label,"aria-hidden":!0}),e.jsx("h3",{className:"break-words font-semibold",children:s.label}),!s.limits.enabled&&e.jsx(B,{variant:"destructive",children:"Deaktiviert"}),s.customized&&e.jsx(B,{variant:"outline",children:"Angepasst"})]}),e.jsx("p",{className:"text-muted-foreground mt-1 line-clamp-3 min-h-[3.75rem] break-words text-sm",title:s.description,children:s.description})]}),e.jsx(ms,{feature:s,canEdit:t,onSaved:r})]}),e.jsx(rs,{used:i,limit:s.limits.globalDailyTokens,label:`${s.label}: Tagesverbrauch gegen Gesamtlimit`}),e.jsxs("dl",{className:"border-border grid grid-cols-2 gap-x-3 gap-y-2 border-t pt-3 sm:grid-cols-4",children:[e.jsx(F,{label:"Aufrufe",value:m.format(s.todayCalls)}),e.jsx(F,{label:"Abgelehnt",value:m.format(s.todayDenied)}),e.jsx(F,{label:"Konten / IPs",value:`${s.distinctUsers} / ${s.distinctIps}`}),e.jsx(F,{label:"7 Tage",value:y(s.weekTokens)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-muted-foreground mr-1 text-xs",children:"Limits"}),!s.system&&e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Konto",value:s.limits.perUserDailyTokens}),e.jsx(q,{label:"IP",value:s.limits.perIpDailyTokens})]}),e.jsx(q,{label:"Gesamt",value:s.limits.globalDailyTokens})]})]})}function ms({feature:s,canEdit:t,onSaved:r}){const[n,i]=u.useState(!1),[d,a]=u.useState(s.limits.enabled),[l,h]=u.useState(""),[o,p]=u.useState(""),[T,c]=u.useState(""),[f,A]=u.useState(!1),b=N=>{a(N.enabled),h(N.perUserDailyTokens?.toString()??""),p(N.perIpDailyTokens?.toString()??""),c(N.globalDailyTokens?.toString()??"")},C=N=>{N&&b(s.limits),i(N)},k=async(N,S)=>{A(!0);try{await N(),v.success(S),i(!1),r()}catch(Te){v.error($(Te))}finally{A(!1)}},Z=N=>{N.preventDefault();const S={perUserDailyTokens:z(l),perIpDailyTokens:z(o),globalDailyTokens:z(T)};if(S.perUserDailyTokens===void 0||S.perIpDailyTokens===void 0||S.globalDailyTokens===void 0){v.error("Limits müssen ganze Zahlen sein (leer = kein Limit).");return}k(()=>De({data:{feature:s.feature,enabled:d,perUserDailyTokens:S.perUserDailyTokens??null,perIpDailyTokens:S.perIpDailyTokens??null,globalDailyTokens:S.globalDailyTokens??null}}),"Limits gespeichert")};return e.jsxs(ue,{open:n,onOpenChange:C,children:[e.jsx(me,{asChild:!0,children:e.jsx(j,{variant:"ghost",size:"icon",className:"shrink-0","aria-label":`${s.label} bearbeiten`,children:e.jsx(Oe,{className:"h-4 w-4"})})}),e.jsxs(he,{children:[e.jsxs(xe,{children:[e.jsx(ge,{children:s.label}),e.jsx(pe,{children:"Tageslimits in Tokens (Ein- und Ausgabe zusammen). Leer lassen für „kein Limit“. Die Änderung gilt nach spätestens 15 Sekunden."})]}),e.jsxs("form",{onSubmit:Z,className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(D,{htmlFor:`enabled-${s.feature}`,children:"Bereich aktiv"}),e.jsx(ae,{id:`enabled-${s.feature}`,checked:d,onCheckedChange:a,disabled:!t})]}),!s.system&&e.jsxs(e.Fragment,{children:[e.jsx(P,{id:`user-${s.feature}
1`,label:"Pro angemeldetem Konto",value:l,onChange:h,placeholder:G(s.defaults.perUserDailyTokens),disabled:!t}),e.jsx(P,{id:`ip-${s.feature}`,label:"Pro IP-Adresse (nicht angemeldet)",value:o,onChange:p,placeholder:G(s.defaults.perIpDailyTokens),disabled:!t})]}),e.jsx(P,{id:`global-${s.feature}`,label:"Gesamt pro Tag (Notbremse für alle zusammen)",value:T,onChange:c,placeholder:G(s.defaults.globalDailyTokens),disabled:!t}),!t&&e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nur Admins können Limits ändern."}),e.jsxs(fe,{className:"gap-2 sm:justify-between",children:[s.customized&&t?e.jsx(j,{type:"button",variant:"ghost",disabled:f,onClick:()=>{k(()=>Ie({data:{feature:s.feature}}),"Auf Standardwerte zurückgesetzt")},children:"Auf Standard zurücksetzen"}):e.jsx("span",{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Abbrechen"}),e.jsx(j,{type:"submit",disabled:f||!t,children:f?"Wird gespeichert...":"Speichern"})]})]})]})]})]})}function P({id:s,label:t,value:r,onChange:n,placeholder:i,disabled:d}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:s,children:t}),e.jsx(te,{id:s,inputMode:"numeric",value:r,onChange:a=>n(a.target.value),placeholder:`Standard: ${i}`,disabled:d})]})}function ne({label:s,detail:t,className:r="max-w-[10rem] @xl:max-w-[16rem]"}){return e.jsxs("div",{className:`min-w-0 ${r}`,children:[e.jsx("div",{className:"truncate font-medium",title:s,children:s}),t&&e.jsx("div",{className:"text-muted-foreground truncate text-xs",title:t,children:t})]})}function hs({subjects:s,onChanged:t}){const r=Math.max(...s.map(n=>n.tokens),1);return e.jsx(I,{title:"Größte Verbraucher heute",description:"Konten und IP-Adressen mit dem höchsten Verbrauch, über alle Bereiche. Die Zähler kennen IP-Adressen nur als Pseudonym; die tatsächliche Adresse steht im Anfrage-Protokoll darunter.",children:s.length===0?e.jsx(H,{text:"Heute wurde noch keine KI genutzt."}):e.jsx(w,{className:"overflow-hidden",children:e.jsxs(X,{children:[e.jsx(ee,{children:e.jsxs(L,{children:[e.jsx(x,{children:"Verursacher"}),e.jsx(x,{className:"@4xl:table-cell hidden",children:"Bereiche"}),e.jsx(x,{children:"Tokens"}),e.jsx(x,{className:"@3xl:table-cell hidden text-right",children:"Aufrufe"}),e.jsx(x,{className:"@xl:table-cell hidden text-right",children:"Abgelehnt"}),e.jsx(x,{className:"w-px"})]})}),e.jsx(se,{children:s.map(n=>e.jsxs(L,{children:[e.jsx(g,{children:e.jsx(ne,{label:n.label,detail:n.detail})}),e.jsx(g,{className:"@4xl:table-cell hidden max-w-[14rem]",children:e.jsx("div",{className:"text-muted-foreground truncate text-sm",title:n.features.join(", "),children:n.features.join(", ")})}),e.jsx(g,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-muted @3xl:block hidden h-1.5 w-20 shrink-0 overflow-hidden rounded-full","aria-hidden":!0,children:e.jsx("div",{className:"bg-primary h-full rounded-full",style:{width:`${n.tokens/r*100}%`}})}),e.jsx("span",{className:"tabular-nums",children:m.format(n.tokens)})]})}),e.jsx(g,{className:"@3xl:table-cell hidden text-right tabular-nums",children:m.format(n.calls)}),e.jsx(g,{className:"@xl:table-cell hidden text-right tabular-nums",children:m.format(n.denied)}),e.jsx(g,{className:"text-right",children:n.blocked?e.jsx(B,{variant:"destructive",children:"Gesperrt"}):e.jsx(ve,{subject:n,onBlocked:t,trigger:e.jsxs(j,{variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(K,{className:"h-3.5 w-3.5"}),"Sperren"]})})})]},`${n.subjectType}:${n.subjectKey}`))})]})})})}function xs({blocks:s,onChanged:t}){return e.jsx(I,{title:"Sperren",description:"Gesperrte Konten und IP-Adressen können keine KI-Funktion nutzen. Die Inhaltsprüfung ist ausgenommen, damit gesperrte Nutzer keine ungeprüften Inhalte einstellen können. Sperren wirken nach spätestens 15 Sekunden.",action:e.jsx(ve,{subject:null,onBlocked:t,trigger:e.jsxs(j,{className:"gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),"Sperre hinzufügen"]})}),children:s.length===0?e.jsx(H,{text:"Keine aktiven Sperren."}):e.jsx(w,{children:e.jsx("ul",{className:"divide-border divide-y",children:s.map(r=>e.jsx(gs,{block:r,onRemoved:t},r.id))})})})}function gs({block:s,onRemoved:t}){const[r,n]=u.useState(!1),i=async()=>{n(!0);try{await Ke({data:{id:s.id}}),v.success("Sperre aufgehoben"),t()}catch(d){v.error($(d))}finally{n(!1)}};return e.jsxs("li",{className:"flex flex-wrap items-start justify-between gap-x-6 gap-y-3 p-4",children:[e.jsxs("div",{className:"min-w-0 flex-1 basis-56",children:[e.jsx(ne,{label:s.label,detail
1:s.detail,className:"max-w-full"}),e.jsxs("div",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[e.jsx(B,{variant:s.source==="auto"?"secondary":"outline",children:s.source==="auto"?"Automatisch":"Manuell"}),s.createdByName&&e.jsxs("span",{className:"text-muted-foreground min-w-0 truncate",title:s.createdByName,children:["von ",s.createdByName]})]})]}),e.jsx("p",{className:"min-w-0 flex-[2] basis-64 text-pretty break-words text-sm",title:s.reason??void 0,children:e.jsx("span",{className:"line-clamp-3",children:s.reason??"—"})}),e.jsxs("dl",{className:"text-muted-foreground whitespace-nowrap text-xs tabular-nums",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("dt",{children:"Seit"}),e.jsx("dd",{children:O(s.createdAt)})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("dt",{children:"Bis"}),e.jsx("dd",{children:s.expiresAt?O(s.expiresAt):"unbefristet"})]})]}),e.jsxs(j,{variant:"ghost",size:"sm",className:"gap-1",onClick:i,disabled:r,children:[e.jsx(Ze,{className:"h-4 w-4"}),"Aufheben"]})]})}const ps=[{value:"1",label:"1 Stunde"},{value:"24",label:"24 Stunden"},{value:"168",label:"7 Tage"},{value:"720",label:"30 Tage"},{value:"forever",label:"Unbefristet"}];function ve({subject:s,onBlocked:t,trigger:r}){const[n,i]=u.useState(!1),[d,a]=u.useState(""),[l,h]=u.useState("24"),[o,p]=u.useState(""),[T,c]=u.useState(!1),f=s!==null||d.trim()!=="",A=async b=>{if(b.preventDefault(),!f)return;c(!0);const C={reason:o.trim()||void 0,hours:l==="forever"?null:Number(l)};try{await Ee({data:s?{subjectType:s.subjectType,subjectKey:s.subjectKey,...C}:{identifier:d.trim(),...C}}),v.success("Gesperrt"),i(!1),a(""),p(""),t()}catch(k){v.error($(k))}finally{c(!1)}};return e.jsxs(ue,{open:n,onOpenChange:i,children:[e.jsx(me,{asChild:!0,children:r}),e.jsxs(he,{children:[e.jsxs(xe,{children:[e.jsx(ge,{className:"break-words",children:s?`${s.label} sperren`:"Sperre hinzufügen"}),e.jsx(pe,{children:"Ab sofort keine KI-Funktion mehr nutzbar (außer der automatischen Inhaltsprüfung)."})]}),e.jsxs("form",{onSubmit:A,className:"space-y-4",children:[!s&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"block-identifier",children:"E-Mail-Adresse oder IP-Adresse *"}),e.jsx(te,{id:"block-identifier",value:d,onChange:b=>a(b.target.value),placeholder:"z. B. [email protected] oder 203.0.113.7",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"block-duration",children:"Dauer"}),e.jsxs(Ce,{value:l,onValueChange:h,children:[e.jsx(ze,{id:"block-duration",children:e.jsx(Pe,{})}),e.jsx(Le,{children:ps.map(b=>e.jsx(Be,{value:b.value,children:b.label},b.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"block-reason",children:"Grund (optional)"}),e.jsx(_e,{id:"block-reason",value:o,onChange:b=>p(b.target.value),placeholder:"Warum wird gesperrt?",rows:3,maxLength:500})]}),e.jsxs(fe,{children:[e.jsx(j,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Abbrechen"}),e.jsx(j,{type:"submit",disabled:T||!f,children:T?"Wird gespeichert...":"Sperren"})]})]})]})]})}const fs=s=>$e({data:s});function bs({loadLog:s=fs}){const[t,r]=u.useState(!1),[n,i]=u.useState(""),[d,a]=u.useState(""),[l,h]=u.useState(null),[o,p]=u.useState(!0);u.useEffect(()=>{let c=!1;return p(!0),s({onlyDenied:t,search:d||void 0}).then(f=>{c||h(f)}).catch(f=>{c||v.error($(f))}).finally(()=>{c||p(!1)}),()=>{c=!0}},[t,d,s]);const T=c=>{c.preventDefault(),a(n.trim())};return e.jsxs(I,{title:"Anfrage-Protokoll",description:`Jeder KI-Aufruf mit IP-Adresse, Konto und Ergebnis, auch abgelehnte und gesperrte. Einträge werden nach ${ss} Tagen automatisch gelöscht. IPv4 steht vollständig, IPv6 als /64-Präfix im Protokoll.`,children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-x-4 gap-y-3",children:[e.jsxs("form",{onSubmit:T,className:"flex min-w-0 flex-wrap gap-2",children:[e.jsx(te,{"aria-label":"E-Mail- oder IP-Adresse suchen",className:"w-full min-w-0 sm:w-72",value:n,onChange:c=>i(c.target.value),placeholder:"E-Mail- oder IP-Adresse"}),e.jsxs(j,{type:"submit",variant:"outline",className:"gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),"Suchen"]}),d&&e.jsx(j,{type:"button",variant:"ghost",onClick:()=>{i(""),a("")},children:"Zurücksetzen"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{id:"log-only-denied",checked:t,onCheckedChange:r}),e.jsx(D,{htmlFor:"log-only-denied",children:"Nur abgelehnte"})]})]}),o&&!l?e.jsx(H,{text:"Wird geladen..."}):!l||l.entries.length===0?e.jsx(H,{text:l&&!l.resolved?"Dazu wurde kein Konto und keine gültige IP-Adresse gefunden.":"Keine Einträge."}):e.jsx(w,{className:"overflow-hidden",children:e.jsxs(X,{children:[e.jsx(ee,{children:e.jsxs(L,{children:[e.jsx(x,{className:"@md:table-cell hidden",children:"Zeit"}),e.jsx(x,{className:"@xl:table-cell hidden",children:"Bereich"}),e.jsx(x,{children:"Konto / IP"}),e.jsx(x,{children:"Ergebnis"}),e.jsx(x,{className:"@3xl:table-cell hidden text-right",children:"Tokens"}),e.jsx(x,{className:"@5xl:table-cell hidden",children:"Browser"})]})}),e.jsx(se,{children:l.entries.map(c=>e.jsxs(L,{children:[e.jsx(g,{className:"text-muted-foreground @md:table-cell hidden whitespace-nowrap",children:O(c.createdAt)}),e.jsx(g,{className:"@xl:table-cell @3xl:max-w-[12rem] hidden max-w-[9rem]",children:e.jsx("div",{className:"truncate",title:c.feature,children:c.feature})}),e.jsxs(g,{children:[c.userLabel&&e.jsx(ne,{label:c.userLabel,detail
1:c.userDetail}),e.jsx("div",{className:c.userLabel?"text-muted-foreground break-all font-mono text-xs":"break-all font-mono text-sm",children:c.ip??e.jsx("span",{title:"Zu diesem Aufruf kam keine IP-Adresse an, etwa bei direktem Zugriff ohne Proxy.",children:"IP unbekannt"})}),e.jsxs("div",{className:"text-muted-foreground @md:hidden mt-0.5 text-xs",children:[O(c.createdAt)," · ",c.feature]})]}),e.jsx(g,{children:c.status==="ok"?e.jsx(B,{variant:"outline",children:"OK"}):e.jsxs(B,{variant:"destructive",className:"gap-1",children:[e.jsx(K,{}),as[c.denyReason??""]??"Abgelehnt"]})}),e.jsx(g,{className:"@3xl:table-cell hidden text-right tabular-nums",children:m.format(c.tokens)}),e.jsx(g,{className:"@5xl:table-cell hidden max-w-[14rem]",children:e.jsx("div",{className:"text-muted-foreground truncate text-xs",title:c.userAgent??void 0,children:c.userAgent??"—"})})]},c.id))})]})})]})}function ce({id:s,label:t,description:r,checked:n,onCheckedChange:i,disabled:d}){return e.jsxs("div",{className:"flex items-start justify-between gap-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(D,{htmlFor:s,children:t}),e.jsx("p",{className:"text-muted-foreground mt-1 text-pretty text-sm",children:r})]}),e.jsx(ae,{id:s,checked:n,onCheckedChange:i,disabled:d,className:"mt-0.5 shrink-0"})]})}function js({settings:s,canEdit:t,onChanged:r}){const[n,i]=u.useState(s.enforce),[d,a]=u.useState(s.autoBlockEnabled),[l,h]=u.useState(s.autoBlockAfterDenials.toString()),[o,p]=u.useState(s.autoBlockHours.toString()),[T,c]=u.useState(s.maxCallsPerMinute.toString()),[f,A]=u.useState(!1),b=async C=>{C.preventDefault();const k={autoBlockAfterDenials:z(l),autoBlockHours:z(o),maxCallsPerMinute:z(T)};if(!k.autoBlockAfterDenials||!k.autoBlockHours||!k.maxCallsPerMinute){v.error("Bitte ganze Zahlen ab 1 eintragen.");return}A(!0);try{await Ue({data:{enforce:n,autoBlockEnabled:d,autoBlockAfterDenials:k.autoBlockAfterDenials,autoBlockHours:k.autoBlockHours,maxCallsPerMinute:k.maxCallsPerMinute}}),v.success("Einstellungen gespeichert"),r()}catch(Z){v.error($(Z))}finally{A(!1)}};return e.jsx(I,{title:"Einstellungen",description:"Gelten für alle Bereiche. Änderungen wirken nach spätestens 15 Sekunden.",children:e.jsx(w,{className:"max-w-3xl p-5",children:e.jsxs("form",{onSubmit:b,className:"space-y-6",children:[e.jsx(ce,{id:"setting-enforce",label:"Limits durchsetzen",description:"Aus = Beobachtungsmodus: Es wird nur gezählt, was abgelehnt worden wäre. Sinnvoll, um neue Limits erst einzumessen.",checked:n,onCheckedChange:i,disabled:!t}),e.jsx(ce,{id:"setting-autoblock",label:"Automatisch sperren",description:"Wer wiederholt am Limit abgelehnt wird, hämmert gegen den Endpunkt und wird für alle KI-Bereiche gesperrt.",checked:d,onCheckedChange:a,disabled:!t}),e.jsxs("div",{className:"border-border grid items-end gap-4 border-t pt-5 sm:grid-cols-3",children:[e.jsx(P,{id:"setting-denials",label:"Sperre nach … Ablehnungen pro Tag",value:l,onChange:h,placeholder:"25",disabled:!t||!d}),e.jsx(P,{id:"setting-hours",label:"Sperrdauer (Stunden)",value:o,onChange:p,placeholder:"24",disabled:!t||!d}),e.jsx(P,{id:"setting-calls",label:"Max. Modellaufrufe pro Minute",value:T,onChange:c,placeholder:"60",disabled:!t})]}),t?e.jsx(j,{type:"submit",disabled:f,children:f?"Wird gespeichert...":"Speichern"}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nur Admins können die Einstellungen ändern."})]})})})}function ks({overview:s,canEdit:t,onChanged:r,loadLog:n}){const{history:i,settings:d}=s,a=i[i.length-1],l=i[i.length-2],h=s.blocks.filter(o=>o.source==="auto").length;return e.jsxs("div",{className:"@container mx-auto w-full min-w-0 max-w-7xl space-y-8 p-4 sm:p-6",children:[e.jsxs("header",{className:"flex flex-wrap items-start justify-between gap-x-6 gap-y-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"KI-Nutzung"}),e.jsx("p",{className:"text-muted-foreground mt-1 max-w-2xl text-pretty",children:"Tokenverbrauch der KI-Funktionen, Tageslimits und Sperren. Die Tageszähler setzen um Mitternacht deutscher Zeit zurück."})]}),d.enforce?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1 text-sm font-medium text-emerald-900",children:[e.jsx(We,{className:"h-4 w-4"}),"Limits aktiv"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-amber-300 bg-amber-50 px-3 py-1 text-sm font-medium text-amber-950",children:[e.jsx(Ye,{className:"h-4 w-4"}),"Beobachtungsmodus"]})]}),!d.enforce&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-amber-300 bg-amber-50 p-4 text-amber-950",children:[e.jsx(be,{className:"mt-0.5 h-5 w-5 shrink-0"}),e.jsxs("p",{className:"text-pretty text-sm",children:[e.jsx("strong",{children:"Beobachtungsmodus:"})," Token- und Ratenlimits werden nur mitgezählt, aber nicht durchgesetzt. „Abgelehnt“ zeigt, was abgelehnt worden wäre. Manuelle Sperren und deaktivierte Bereiche gelten weiterhin."]})]}),e.jsxs("section",{"aria-label":"Kennzahlen",className:"@md:grid-cols-2 @5xl:grid-cols-4 grid grid-cols-1 gap-4",children:[e.jsx(M,{label:"Tokens heute",icon:qe,value:y(a?.tokens??0),sub:`Gestern: ${y(l?.tokens??0)}`,trend:i.map(o=>o.tokens),trendLabel:"Tokens der letzten 14 Tage, der letzte Punkt ist heute"}),e.jsx(M,{label:"Modellaufrufe heute",icon:Je,value:m.format(a?.calls??0),sub:`Gestern: ${m.format(l?.calls??0)}`,trend:i.map(o=>o.calls),trendLabel:"Modellaufrufe der letzten 14 Tage, der letzte Punkt ist heute"}),e.jsx(M,{label:d.enforce?"Abgelehnt heute":"Würden abgelehnt heute",icon:Qe,value:m.format(a?.denied??0),sub:`Gestern: ${m.format(l?.denied??0)}`,trend:i.map(o=>o.denied),trendLabel:"Abgelehnte Anfragen der letzten 14 Tage, der letzte Punkt ist heute"}),e.jsx(M,{label:"Aktive Sperren",icon:K,value:m.format(s.blocks.length),sub:s.blocks.length===0?"Keine Sperren aktiv":`${h} automatisch, ${s.blocks.length-h} manuell`})]}),e.jsxs("div",{className:"@3xl:grid-cols-2 grid gap-x-4 gap-y-8",children:[e.jsx(I,{className:"flex flex-col",title:"Verlauf der letzten 14 Tage",description:"Tokens pro Tag, nach Bereichsgruppe.",children:e.jsx(ds,{history:i})}),e.jsx(I,{className:"flex flex-col",title:"Aktivität nach Tageszeit",description:"Wann die KI genutzt wird und wann Anfragen abgelehnt werden.",children:e.jsx(os,{hourly:s.hourly})})]}),e.jsx(cs,{features:s.features,canEdit:t,onChanged:r}),e.jsx(hs,{subjects:s.topSubjects,onChanged:r}),e.jsx(bs,{loadLog:n}),e.jsx(xs,{blocks:s.blocks,onChanged:r}),e.jsx(js,{settings:d,canEdit:t,onChanged:r})]})}function vs(){const s=Me.useLoaderData(),t=Fe(),{data:r}=Ge.useSession();return e.jsx(ks,{overview:s,canEdit:r?.user?.userType==="admin",onChanged:()=>
1t.invalidate()})}export{vs as component};

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.