hackagent-webui 0.6.5.dev72__py3-none-any.whl → 0.6.7.dev74__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hackagent_webui/__init__.py +1 -1
- hackagent_webui/static/404.html +2 -2
- hackagent_webui/static/VERSION +1 -1
- hackagent_webui/static/_next/static/chunks/432-da1349ca9d0dbf5d.js +25 -0
- hackagent_webui/static/_next/static/chunks/{493-34228dd02f768bba.js → 493-92a293a4bf432fc7.js} +1 -1
- hackagent_webui/static/_next/static/chunks/583-78ba13009c3dc8f0.js +1 -0
- hackagent_webui/static/_next/static/chunks/666-5ee4182c3065fd65.js +1 -0
- hackagent_webui/static/_next/static/chunks/870-fd9b5a5e5bb99ffa.js +1 -0
- hackagent_webui/static/_next/static/chunks/980-cc9c16cc6103edbb.js +1 -0
- hackagent_webui/static/_next/static/chunks/app/agents/{page-ea6fa46f56918ab5.js → page-e8929149bce2396f.js} +1 -1
- hackagent_webui/static/_next/static/chunks/app/attacks/{page-9d0f6a4e82057892.js → page-4594b3d8af3cef5c.js} +1 -1
- hackagent_webui/static/_next/static/chunks/app/{layout-bb2a869293131472.js → layout-68a42544a2efc863.js} +1 -1
- hackagent_webui/static/_next/static/chunks/app/{page-e1303435339f9e4f.js → page-92fb04233e8db6e2.js} +1 -1
- hackagent_webui/static/_next/static/chunks/app/profile/{page-4ddc195a9862fb6f.js → page-ace2f6335f41a96a.js} +1 -1
- hackagent_webui/static/_next/static/chunks/app/stats/page-742d6876a3e207d9.js +1 -0
- hackagent_webui/static/_next/static/chunks/{main-b2abf26ddb8313ad.js → main-c5ae269c07d252e7.js} +1 -1
- hackagent_webui/static/_next/static/css/920420339ac947aa.css +1 -0
- hackagent_webui/static/agents.html +2 -2
- hackagent_webui/static/agents.txt +6 -6
- hackagent_webui/static/api-keys.html +2 -2
- hackagent_webui/static/api-keys.txt +5 -5
- hackagent_webui/static/attacks.html +2 -2
- hackagent_webui/static/attacks.txt +6 -6
- hackagent_webui/static/campaign-export/runtime.js +96 -128
- hackagent_webui/static/campaign-export/styles.css +1 -1
- hackagent_webui/static/credentials.html +2 -2
- hackagent_webui/static/credentials.txt +5 -5
- hackagent_webui/static/index.html +2 -2
- hackagent_webui/static/index.txt +6 -6
- hackagent_webui/static/profile.html +2 -2
- hackagent_webui/static/profile.txt +6 -6
- hackagent_webui/static/secrets.html +2 -2
- hackagent_webui/static/secrets.txt +5 -5
- hackagent_webui/static/stats.html +2 -2
- hackagent_webui/static/stats.txt +6 -6
- hackagent_webui/static/usage.html +2 -2
- hackagent_webui/static/usage.txt +5 -5
- {hackagent_webui-0.6.5.dev72.dist-info → hackagent_webui-0.6.7.dev74.dist-info}/METADATA +1 -1
- {hackagent_webui-0.6.5.dev72.dist-info → hackagent_webui-0.6.7.dev74.dist-info}/RECORD +42 -41
- hackagent_webui/static/_next/static/chunks/21-9b527eba32db4357.js +0 -1
- hackagent_webui/static/_next/static/chunks/381-b738bb0d835db190.js +0 -1
- hackagent_webui/static/_next/static/chunks/583-f38a7bb278cdb7b1.js +0 -1
- hackagent_webui/static/_next/static/chunks/874-f9e3658d3feed699.js +0 -25
- hackagent_webui/static/_next/static/chunks/app/stats/page-9b75118409cfc976.js +0 -1
- hackagent_webui/static/_next/static/css/cf5d013e1e316b2f.css +0 -1
- /hackagent_webui/static/_next/static/{jaJDfi8Dn3oTclRwdpEnk → v2pPXL_Ag49bJj1nZwGOt}/_buildManifest.js +0 -0
- /hackagent_webui/static/_next/static/{jaJDfi8Dn3oTclRwdpEnk → v2pPXL_Ag49bJj1nZwGOt}/_ssgManifest.js +0 -0
- {hackagent_webui-0.6.5.dev72.dist-info → hackagent_webui-0.6.7.dev74.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[266],{5655:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>tK});var r=a(95155),n=a(12115),s=a(52619),l=a.n(s),o=a(20063),i=a(35299),c=a(35626),d=a(71847);let u=(0,d.A)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);var m=a(22470),p=a(98487),h=a(3998),x=a(68600),g=a(16257),f=a(32886);let v={COMPLETED:"bg-emerald-500",RUNNING:"bg-sky-500 animate-pulse",PENDING:"bg-slate-400",FAILED:"bg-rose-500"};function b(e){var t;let{status:a}=e;return(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"h-2 w-2 rounded-full ".concat(null!=(t=v[a])?t:"bg-amber-500")}),a.charAt(0)+a.slice(1).toLowerCase()]})}function j(e){let{campaign:t,costs:a}=e,n=t.category_outcomes.filter(e=>/unclassified|unknown/i.test(e.category)).reduce((e,t)=>e+t.recorded_goals,0),s=t.runs.map(e=>{var t;return{run:e,value:(0,g.R)(null!=(t=e.outcomes)?t:void 0)}}).filter(e=>null!==e.value).sort((e,t)=>t.value-e.value),l=(0,g.R)(t),o=function(e){if(!(null==e?void 0:e.runs.length))return null;let t=t=>e.runs.reduce((e,a)=>{var r;return e+(null!=(r=t(a))?r:0)},0);return{target:t(e=>e.calls.target),attacker:t(e=>e.calls.attacker),judge:t(e=>e.calls.judge),untraced:e.runs.filter(e=>!e.calls_traced).length,prompt:t(e=>{var t;return null==(t=e.target_tokens)?void 0:t.prompt}),completion:t(e=>{var t;return null==(t=e.target_tokens)?void 0:t.completion}),elapsed:t(e=>e.elapsed_s)}}(a),i=o?o.target+o.attacker+o.judge:null,c=o?o.prompt+o.completion:null,d=a?[...a.runs].sort((e,t)=>t.elapsed_s-e.elapsed_s):[],u=e=>{let a=t.runs.find(t=>t.id===e);return a?(0,x.aN)(a,t.runs):e};return(0,r.jsxs)("section",{"aria-label":"Campaign outcomes",className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted-foreground",children:[(0,r.jsx)(b,{status:t.status}),(0,r.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,r.jsx)("span",{children:t.target}),(0,r.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,r.jsx)("time",{children:new Date(t.created_at).toLocaleString()}),o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,r.jsxs)("span",{children:[(0,f.a3)(o.elapsed)," of attack time"]})]})]}),(0,r.jsxs)("div",{className:"grid auto-rows-fr grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6",children:[(0,r.jsx)(f.nO,{label:"Attack success rate",value:null===l?"Not measured":"".concat(l.toFixed(1),"%"),detail:"".concat(t.jailbroken," of ").concat(t.recorded_goals," goals broken by at least one attack"),children:(0,r.jsx)(f.lV,{label:"Goal outcomes",segments:(0,f.DN)(t)})}),(0,r.jsx)(f.nO,{label:"Goals",value:t.recorded_goals,detail:"".concat(t.recorded_goals-n," classified \xb7 ").concat(n," unclassified"),children:(0,r.jsx)(f.lV,{label:"Goal classification",segments:[{name:"Classified",value:t.recorded_goals-n,color:"var(--viz-family-static)"},{name:"Unclassified",value:n,color:"var(--viz-error)"}]})}),(0,r.jsx)(f.nO,{label:"Attacks",value:t.attack_runs,detail:s.length?"best: ".concat((0,x.aN)(s[0].run,t.runs)," ").concat(s[0].value.toFixed(0),"%"):"No attack outcomes",children:(0,r.jsx)("div",{className:"w-full",style:{color:s[0]?(0,f.uq)(s[0].run.family):void 0},children:(0,r.jsx)(f.OW,{bars:!0,max:100,values:s.map(e=>e.value),label:"ASR per attack, best first: ".concat(s.map(e=>"".concat((0,x.aN)(e.run,t.runs)," ").concat(e.value.toFixed(1),"%")).join(", "))})})}),(0,r.jsx)(f.nO,{label:"LLM calls",value:null===i?t.attempts.toLocaleString():(0,f.B4)(i),detail:null===i?"stored attempts \xb7 calls not recorded":"".concat(t.attempts.toLocaleString()," attempts").concat(o.untraced?" \xb7 ".concat(o.untraced," ").concat(1===o.untraced?"attack":"attacks"," not traced"):""),children:o&&(0,r.jsx)(f.lV,{label:"LLM calls by role",segments:[{name:"Target",value:o.target,color:f._t.target},{name:"Attacker",value:o.attacker,color:f._t.attacker},{name:"Judge",value:o.judge,color:f._t.judge}]})}),(0,r.jsx)(f.nO,{label:"Target tokens",value:c?(0,f.B4)(c):"Not recorded",detail:c?"".concat((0,f.B4)(o.prompt)," prompt \xb7 ").concat((0,f.B4)(o.completion)," completion"):"the target did not report usage",children:c?(0,r.jsx)(f.lV,{label:"Target tokens",segments:[{name:"Prompt",value:o.prompt,color:f._t.target},{name:"Completion",value:o.completion,color:"var(--viz-family-adaptive)"}]}):null}),(0,r.jsx)(f.nO,{label:"Attack time",value:o?(0,f.a3)(o.elapsed):"Not recorded",detail:d[0]?"longest: ".concat(u(d[0].run_id)," ").concat((0,f.a3)(d[0].elapsed_s)):"first to last stored result",children:d.length>0&&(0,r.jsx)("div",{className:"w-full text-muted-foreground",children:(0,r.jsx)(f.OW,{bars:!0,values:d.map(e=>e.elapsed_s),label:"Time per attack, longest first: ".concat(d.map(e=>"".concat(u(e.run_id)," ").concat((0,f.a3)(e.elapsed_s))).join(", "))})})})]})]})}var y=a(46767);let w="rounded-lg border bg-muted/10 p-3",N="flex cursor-pointer items-start gap-2 rounded-md border p-2 text-left text-xs transition-colors hover:bg-muted/50 focus-within:ring-2 focus-within:ring-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",k="border-foreground/40 bg-muted/60 ring-1 ring-foreground/20";function _(e){let{description:t,children:a,onSelect:s,selected:l,opacity:o=1}=e,[i,c]=(0,n.useState)(!1),d=()=>{c(!0),null==s||s()};return(0,r.jsxs)(y.m_,{open:i,onOpenChange:c,children:[(0,r.jsx)(y.k$,{asChild:!0,children:(0,r.jsx)("g",{role:s?"button":"group",tabIndex:0,"aria-label":t.replace(/\s+/g," "),"aria-pressed":l,opacity:o,className:"cursor-pointer outline-offset-2",onClick:d,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),d())},children:a})}),(0,r.jsx)(y.ZI,{sideOffset:8,className:"max-h-[min(28rem,70dvh)] max-w-80 overflow-y-auto whitespace-pre-wrap px-4 py-3 text-left text-xs leading-relaxed tabular-nums",children:t})]})}var S=a(26333);let C=e=>Math.sign(e)*(1>=Math.abs(e)?Math.abs(e):1+Math.log(Math.abs(e))),A=e=>Math.sign(e)*(1>=Math.abs(e)?Math.abs(e):Math.exp(Math.abs(e)-1)),M=(e,t)=>null!=e&&(null==t?void 0:t.goals)?e/t.goals:null,R=(e,t)=>{let a=null==e?void 0:e.goal_samples;return!(null==a?void 0:a.length)||a.some(e=>null===e[t])?null:a.reduce((e,a)=>{var r;return e+(null!=(r=a[t])?r:0)},0)/a.length},L={attempts:{label:"Attempts",axis:"Attempts per goal",unit:"attempts per goal",format:e=>e.toFixed(1),tick:f.B4,value:e=>e.outcomes&&e.outcomes.recorded_goals>0&&e.outcomes.attempts>0?e.outcomes.attempts/e.outcomes.recorded_goals:null},calls:{label:"LLM calls",axis:"LLM calls per goal",unit:"LLM calls per goal",format:e=>e.toFixed(1),tick:f.B4,value:(e,t)=>(null==t?void 0:t.goal_samples)?R(t,"calls"):(null==t?void 0:t.calls_traced)&&null!==t.calls.attacker&&null!==t.calls.judge?M(t.calls.target+t.calls.attacker+t.calls.judge,t):null},tokens:{label:"Target tokens",axis:"Target tokens per goal",unit:"target tokens per goal",format:f.B4,tick:f.B4,value:(e,t)=>(null==t?void 0:t.goal_samples)?R(t,"target_tokens"):M((null==t?void 0:t.target_tokens)?t.target_tokens.prompt+t.target_tokens.completion:null,t)},time:{label:"Time",axis:"Attack time per goal",unit:"per goal",format:f.a3,tick:f.a3,value:(e,t)=>{var a;return(null==t||null==(a=t.goal_samples)?void 0:a.length)?t.goal_samples.reduce((e,t)=>e+t.elapsed_s,0)/t.goal_samples.length:null}}},E=["target","attacker","judge"];function z(e){let{campaign:t,costs:a}=e;return(0,r.jsx)(I,{campaign:t,costs:a})}function I(e){let{campaign:t,costs:a,firstSuccess:n=!1}=e,[s,l]=(0,f.uc)(1100),o=n?["first_attempt","first_time"]:["calls","tokens","attempts","time"],i={...L,first_attempt:{label:"Attempts to first jailbreak",format:e=>e.toFixed(1),tick:f.B4},first_time:{label:"Time to first jailbreak",format:f.a3,tick:f.a3}},c=t.runs.map(e=>{var t;return{run:e,rate:(0,g.R)(null!=(t=e.outcomes)?t:void 0),cost:null==a?void 0:a.runs.find(t=>t.run_id===e.id)}}).sort((e,t)=>{var a,r;return(null!=(a=t.rate)?a:-1)-(null!=(r=e.rate)?r:-1)}),d=o.map(e=>{let t=c.map(t=>{var a;let{cost:r}=t;return(null!=(a=null==r?void 0:r.goal_samples)?a:[]).flatMap(t=>{if(n&&null==t.first_jailbreak_attempt)return[];let a="first_attempt"===e?t.first_jailbreak_attempt:"first_time"===e?t.first_jailbreak_elapsed_s:"tokens"===e?t.target_tokens:"time"===e?t.elapsed_s:t[e];return null!=a&&Number.isFinite(a)&&a>=0?[a]:[]})});return{metric:e,samples:t,...function(e){let t=e.filter(e=>Number.isFinite(e)&&e>=0),a=t.length?Math.min(...t):0,r=t.length?Math.max(...t):1,n=C(a),s=C(r)-n,l=e=>s?Math.max(0,Math.min(1,(C(e)-n)/s)):.5,o=[a];if(r>a){for(let e of function(e,t){let a=[];for(let r=Math.floor(Math.log10(e));r<=Math.ceil(Math.log10(t));r+=1)for(let n of[1,2,5]){let s=n*10**r;s>=e&&s<=t&&a.push(+s.toPrecision(3))}return a}(Math.max(a,r<1?r/100:1),r))l(e)-l(o[o.length-1])>=.25&&.75>=l(e)&&o.push(e);o.push(r)}return{min:a,max:r,ticks:o,position:l}}(t.flat())}}),u=Math.max(n?720:1120,l),m=n?190:160,p=(u-m-16*o.length)/o.length,h=n?80:68,v=56+c.length*h,b=v+42;return(0,r.jsxs)("figure",{className:"min-w-0 space-y-3","aria-label":n?"First-success distributions ranked by ASR":"Cost distributions ranked by ASR",children:[(0,r.jsx)("div",{ref:s,className:"overflow-x-auto rounded-lg border",children:(0,r.jsxs)("svg",{width:u,height:b,className:"block",role:"group","aria-label":n?"Per-goal first-success violins":"Per-goal cost violins",children:[(0,r.jsx)("text",{x:16,y:24,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:"Attack \xb7 ASR"}),(0,r.jsx)("text",{x:16,y:42,fontSize:10,fill:"var(--muted-foreground)",children:"Highest success first"}),c.map((e,a)=>{var s,l,o,i;let{run:c,rate:d}=e,m=56+a*h;return(0,r.jsxs)("g",{"aria-label":"".concat((0,x.aN)(c,t.runs),": ").concat(null===d?"ASR not recorded":"".concat(d.toFixed(1),"% ASR")),children:[a%2==0&&(0,r.jsx)("rect",{x:0,y:m,width:u,height:h,fill:"var(--muted)",fillOpacity:.35}),(0,r.jsx)("text",{x:16,y:m+26,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:(0,x.aN)(c,t.runs)}),(0,r.jsx)("text",{x:16,y:m+44,fontSize:11,fill:"var(--muted-foreground)",children:null===d?"Not recorded":"".concat(d.toFixed(1),"%")}),n&&(0,r.jsxs)("text",{x:16,y:m+62,fontSize:10,fill:"var(--muted-foreground)",children:["Succeeded: ",null!=(o=null==(s=c.outcomes)?void 0:s.jailbroken)?o:"–","/",null!=(i=null==(l=c.outcomes)?void 0:l.recorded_goals)?i:"–"," goals"]})]},c.id)}),d.map((e,a)=>{let{metric:s,samples:l,min:o,max:d,ticks:u,position:g}=e,j=i[s],y=m+a*(p+16),w=e=>y+18+g(e)*(p-44);return(0,r.jsxs)("g",{role:"group","aria-label":"".concat(j.label," distributions"),"data-domain-min":o,"data-domain-max":d,children:[(0,r.jsx)("rect",{"aria-hidden":"true",x:y+p,y:0,width:16,height:b,fill:"var(--background)"}),(0,r.jsx)("rect",{"data-cost-panel":s,"aria-hidden":"true",x:y,y:1,width:p,height:b-2,rx:8,fill:"none",stroke:"var(--border)",strokeWidth:1.5}),(0,r.jsx)("path",{"aria-hidden":"true",d:"M".concat(y+1,",").concat(56,"H").concat(y+p-1," M").concat(y+1,",").concat(v,"H").concat(y+p-1),stroke:"var(--border)"}),(0,r.jsx)("text",{x:y+p/2,y:26,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--foreground)",children:j.label}),(0,r.jsx)("text",{x:y+p/2,y:43,textAnchor:"middle",fontSize:10,fill:"var(--muted-foreground)",children:n?"successful goals \xb7 symlog":"per goal \xb7 symlog"}),u.map((e,t)=>(0,r.jsxs)("g",{"data-axis-tick":e,children:[(0,r.jsx)("line",{x1:w(e),x2:w(e),y1:56,y2:v,stroke:"var(--border)",strokeDasharray:"2 5"}),(0,r.jsx)("text",{x:w(e),y:v+24,textAnchor:1===u.length?"middle":0===t?"start":t===u.length-1?"end":"middle",fontSize:10,fill:"var(--muted-foreground)",children:j.tick(e)})]},e)),c.map((e,a)=>{var o,i,c,d,u,m;let{run:v,cost:b}=e,N=l[a],k=function(e){let t=e.filter(Number.isFinite).sort((e,t)=>e-t);if(!t.length)return null;let a=e=>{let a=(t.length-1)*e,r=Math.floor(a);return t[r]+(t[Math.ceil(a)]-t[r])*(a-r)},r=a(.25),n=a(.5),s=a(.75),l=s-r,o=t.filter(e=>e>=r-1.5*l&&e<=s+1.5*l);return{q1:r,median:n,q3:s,low:o[0],high:o[o.length-1],n:t.length,outliers:t.filter(e=>e<r-1.5*l||e>s+1.5*l)}}(N),S=function(e){let t=e.filter(e=>Number.isFinite(e)&&e>=0).sort((e,t)=>e-t);if(t.length<5||new Set(t).size<3)return[];let a=t[0],r=t[t.length-1],n=t.reduce((e,t)=>e+t,0)/t.length,s=Math.max(1.06*Math.sqrt(t.reduce((e,t)=>e+(t-n)**2,0)/t.length)*t.length**-.2,(r-a)/80),l=Array.from({length:65},(e,n)=>{let l=a+(r-a)*n/64;return{value:l,density:t.reduce((e,t)=>e+Math.exp(-.5*((l-t)/s)**2),0)}}),o=Math.max(...l.map(e=>e.density));return l.map(e=>({value:e.value,density:e.density/o}))}(N.map(C)),M=56+a*h+27,R=(0,x.aN)(v,t.runs),L="calls"===s&&(null==b?void 0:b.goals)?"\n\nRecorded mean calls per goal\n".concat(E.map(e=>" ".concat(e[0].toUpperCase()+e.slice(1),": ").concat(null===b.calls[e]?"Not traced":(b.calls[e]/b.goals).toFixed(1))).join("\n")):"",z=k?"".concat(R," \xb7 ").concat(j.label," per goal\n\nMedian: ").concat(j.format(k.median),"\nMiddle 50%: ").concat(j.format(k.q1),"–").concat(j.format(k.q3),"\nRange: ").concat(j.format(Math.min(...N)),"–").concat(j.format(Math.max(...N)),"\nGoals measured: ").concat(N.length," of ").concat(n?null!=(d=null==(o=v.outcomes)?void 0:o.jailbroken)?d:N.length:null!=(u=null==b?void 0:b.goals)?u:N.length).concat(n?" successful goals":"").concat(L):"".concat(R," \xb7 ").concat(j.label,"\n\nNot recorded\nPer-goal measurements are required."),I=S.length?[...S.map(e=>"".concat(w(A(e.value)),",").concat(M-17*e.density)),...S.slice().reverse().map(e=>"".concat(w(A(e.value)),",").concat(M+17*e.density))].join(" "):"";return(0,r.jsxs)(_,{description:z,children:[(0,r.jsx)("rect",{x:y+2,y:56+a*h,width:p-4,height:h,fill:"transparent"}),k?(0,r.jsxs)(r.Fragment,{children:[I?(0,r.jsx)("polygon",{"data-violin":v.id,points:I,fill:(0,f.uq)(v.family),fillOpacity:.35,stroke:(0,f.uq)(v.family)}):(0,r.jsxs)("g",{"data-sparse":v.id,children:[(0,r.jsx)("line",{x1:w(Math.min(...N)),x2:w(Math.max(...N)),y1:M,y2:M,stroke:(0,f.uq)(v.family)}),Array.from(new Set(N)).map(e=>(0,r.jsx)("circle",{cx:w(e),cy:M,r:3,fill:(0,f.uq)(v.family)},e))]}),(0,r.jsx)("line",{"data-median-marker":v.id,x1:w(k.median),x2:w(k.median),y1:M-10,y2:M+10,stroke:"var(--foreground)",strokeWidth:2}),(0,r.jsxs)("text",{"data-median-label":v.id,x:w(k.median),y:M+29,textAnchor:.3>g(k.median)?"start":g(k.median)>.7?"end":"middle",fontSize:10,fill:"var(--muted-foreground)",children:["Median: ",j.format(k.median)]})]}):(0,r.jsx)("text",{x:y+p/2,y:M+4,textAnchor:"middle",fontSize:11,fill:"var(--muted-foreground)",children:n&&(null==(i=v.outcomes)?void 0:i.jailbroken)===0?"No jailbreak recorded":"Not recorded"}),n&&(0,r.jsxs)("text",{x:y+p/2,y:M+44,textAnchor:"middle",fontSize:10,fill:"var(--muted-foreground)",children:["Measured: ",N.length,"/",null!=(m=null==(c=v.outcomes)?void 0:c.jailbroken)?m:"–"," successful"]})]},v.id)})]},s)})]})}),(0,r.jsxs)("figcaption",{className:"text-xs leading-relaxed text-muted-foreground",children:["Rows are equally spaced and sorted by ASR. Each cost axis spans the observed minimum to maximum and uses symlog: linear from 0 to 1, logarithmic above 1 (one second for time). Tick labels show original units. Wider sections contain more goals with similar costs on this scale. The dark marker and labelled value show the median (50th percentile). Fewer than five measurements or fewer than three distinct values use dots and ranges instead. Only measured goals are included; missing costs are never treated as zero.",n?"Attempt order matches the recorded conversation. Timing runs from goal-search start to the earliest successful target response, including goal-level preparation and queueing but excluding its final judge evaluation. Older runs without that clock show Not recorded; database persistence timestamps are not used.":"Time spans the first to last recorded result per goal. Calls and target tokens are resource usage, not monetary spending."]}),!c.length&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No attacks recorded in this campaign."})]})}function F(e){var t,a;let{campaign:s,costs:l}=e,[o,i]=(0,n.useState)(()=>s.runs.map(e=>e.id)),[c,d]=(0,f.uc)(700),u=[...s.runs].sort((e,t)=>{var a,r,n,s;return(null!=(r=(0,g.R)(null!=(a=t.outcomes)?a:void 0))?r:-1)-(null!=(s=(0,g.R)(null!=(n=e.outcomes)?n:void 0))?s:-1)}),m=u.filter(e=>o.includes(e.id)),p=function(e,t){let a=new Set,r=new Set,n=new Map,s=e.map(e=>{var a,r,n;let s=null==(a=t.runs.find(t=>t.run_id===e.id))?void 0:a.goal_samples;return!s||s.length!==(null==(r=e.outcomes)?void 0:r.recorded_goals)||new Set(s.map(e=>e.goal_index)).size!==s.length||s.some(e=>void 0===e.first_jailbreak_attempt||!Number.isInteger(e.attempts)||e.attempts<1||null!==e.first_jailbreak_attempt&&(!Number.isInteger(e.first_jailbreak_attempt)||e.first_jailbreak_attempt<1||e.first_jailbreak_attempt>e.attempts))||s.filter(e=>null!==e.first_jailbreak_attempt).length!==(null==(n=e.outcomes)?void 0:n.jailbroken)?null:{run:e,samples:s}});if(s.some(e=>null===e))return null;for(let e of s)if(e){for(let t of e.samples)if(a.add(t.goal_index),null!==t.first_jailbreak_attempt){var l;r.add(t.goal_index),n.set(t.goal_index,[...null!=(l=n.get(t.goal_index))?l:[],e.run.id])}}let o=e.map(e=>{var t,a;return{run:e,lost:Array.from(n.values()).filter(t=>1===t.length&&t[0]===e.id).length,tested:null!=(a=null==(t=s.find(t=>(null==t?void 0:t.run.id)===e.id))?void 0:t.samples.length)?a:0}}),i=Array.from(a).filter(e=>s.every(t=>null==t?void 0:t.samples.some(t=>t.goal_index===e))).length;return{tested:a.size,broken:r.size,remaining:a.size-r.size,fullyTested:i,contributions:o,asr:a.size?100*r.size/a.size:null}}(m,l),h=Math.max(520,d),v=h-86,b=[...null!=(a=null==p?void 0:p.contributions)?a:[]].sort((e,t)=>t.lost-e.lost),j=Math.max(1,...b.map(e=>e.lost));return(0,r.jsxs)("figure",{"aria-label":"Attack complementarity",className:"space-y-3 border-t pt-6",children:[(0,r.jsxs)("figcaption",{children:[(0,r.jsx)("h3",{className:"text-base font-semibold",children:"What does combining attacks gain?"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"All recorded attempts \xb7 entire campaign, independent of coverage filters. Select any portfolio on the right."})]}),(0,r.jsxs)("div",{className:"grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_17rem]",children:[(0,r.jsx)("div",{className:"min-w-0 space-y-4",children:m.length?p?p.tested?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{"aria-label":"Selected portfolio outcomes","aria-live":"polite",className:"grid grid-cols-3 gap-3 rounded-lg border p-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Combined ASR"}),(0,r.jsxs)("p",{className:"mt-1 text-xl font-semibold tabular-nums",children:[null==(t=p.asr)?void 0:t.toFixed(1),"%"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Goals broken"}),(0,r.jsxs)("p",{className:"mt-1 text-xl font-semibold tabular-nums",children:[p.broken,"/",p.tested]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Not yet broken"}),(0,r.jsx)("p",{className:"mt-1 text-xl font-semibold tabular-nums",children:p.remaining})]}),(0,r.jsx)("div",{className:"col-span-3 flex h-3 overflow-hidden rounded-full bg-muted",role:"img","aria-label":"".concat(p.broken," goals broken and ").concat(p.remaining," not broken out of ").concat(p.tested," tested goals"),children:(0,r.jsx)("span",{style:{width:"".concat(p.asr,"%"),backgroundColor:"var(--viz-jailbroken)"}})}),(0,r.jsxs)("p",{className:"col-span-3 text-xs text-muted-foreground",children:["Tested by at least one selected attack: ",p.tested,"/",s.recorded_goals," campaign goals."," ","Tested by every selected attack: ",p.fullyTested,"/",p.tested,"."," ",Math.max(0,s.recorded_goals-p.tested)," goals not tested by this selection."]})]}),(0,r.jsx)("div",{ref:c,className:"min-w-0 overflow-x-auto rounded-lg border bg-background/50",children:(0,r.jsxs)("svg",{width:h,height:70+48*b.length,className:"block",role:"group","aria-label":"Goals lost if each selected attack is removed",children:[(0,r.jsx)("text",{x:16,y:24,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:"Attack"}),(0,r.jsx)("text",{x:16,y:43,fontSize:10,fill:"var(--muted-foreground)",children:"Largest contribution first"}),(0,r.jsx)("text",{x:180,y:24,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:"Goals lost if removed"}),(0,r.jsx)("text",{x:180,y:43,fontSize:10,fill:"var(--muted-foreground)",children:"Beyond the other selected attacks"}),b.map((e,t)=>{let{run:a,lost:n,tested:l}=e,o=64+48*t,i=(0,x.aN)(a,s.runs),c="".concat(i,": ").concat(n," goals lose coverage if removed; ").concat(l,"/").concat(p.tested," portfolio goals tested.");return(0,r.jsxs)(_,{description:c,children:[(0,r.jsx)("text",{x:16,y:o+13,fontSize:12,fill:"var(--foreground)",children:i}),(0,r.jsx)("rect",{x:180,y:o,width:v-180,height:18,rx:3,fill:"var(--muted)"}),(0,r.jsx)("rect",{x:180,y:o,width:n/j*(v-180),height:18,rx:3,fill:(0,f.uq)(a.family)}),(0,r.jsxs)("text",{x:v+10,y:o+13,fontSize:11,fill:"var(--foreground)",children:[n," goals"]}),(0,r.jsxs)("text",{x:180,y:o+33,fontSize:10,fill:"var(--muted-foreground)",children:[(100*n/p.tested).toFixed(1)," pp of current coverage"]})]},a.id)})]})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"A goal counts once if any selected attack broke it. “Not yet broken” includes mitigated, unresolved and error outcomes—it is not a mitigation verdict. ASR uses goals tested by at least one selected attack; changing the selection can change that denominator."})]}):(0,r.jsx)("p",{role:"status",className:"rounded-lg border p-6 text-sm text-muted-foreground",children:"No tested goals recorded for this selection."}):(0,r.jsx)("p",{role:"status",className:"rounded-lg border p-6 text-sm text-muted-foreground",children:"Complementarity is unavailable for this selection: first-success summaries are missing or do not match the recorded outcomes. Refresh to load a consistent snapshot."}):(0,r.jsx)("p",{role:"status",className:"rounded-lg border p-6 text-sm text-muted-foreground",children:"Select at least one attack to compare combined coverage."})}),(0,r.jsxs)("div",{role:"group","aria-label":"Portfolio attack selection",className:w,children:[(0,r.jsx)("p",{className:"mb-1 text-sm font-semibold",children:"Combine attacks"}),(0,r.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:"Choose any number. All attempts count."}),(0,r.jsxs)("div",{className:"mb-3 flex gap-3 text-xs",children:[(0,r.jsx)("button",{type:"button",className:"underline",onClick:()=>i(u.map(e=>e.id)),children:"Select all"}),(0,r.jsx)("button",{type:"button",className:"underline",onClick:()=>i([]),children:"Clear selection"})]}),(0,r.jsx)("div",{className:"grid gap-1 sm:grid-cols-2 lg:grid-cols-1",children:u.map(e=>{var t,a,n,l;return(0,r.jsxs)("label",{className:"".concat(N," ").concat(o.includes(e.id)?k:"border-transparent"),children:[(0,r.jsx)("input",{type:"checkbox","aria-label":"Include ".concat((0,x.aN)(e,s.runs)," in portfolio"),checked:o.includes(e.id),className:"mt-0.5",onChange:t=>i(a=>t.target.checked?[...a,e.id]:a.filter(t=>t!==e.id))}),(0,r.jsxs)("span",{className:"min-w-0",children:[(0,r.jsx)("strong",{className:"block break-words",children:(0,x.aN)(e,s.runs)}),(0,r.jsxs)("span",{className:"block text-muted-foreground",children:[null!=(n=null==(t=e.outcomes)?void 0:t.jailbroken)?n:"–","/",null!=(l=null==(a=e.outcomes)?void 0:a.recorded_goals)?l:"–"," goals broken"]})]})]},e.id)})})]})]}),(0,r.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Removal contributions use the current portfolio's fixed denominator. Zero means redundant coverage within this selection, not a useless attack. Contributions need not sum to combined coverage: goals covered by several attacks are lost by removing none of them individually. This is observed coverage, not a time or resource budget comparison."})]})}function O(e){let{campaign:t,costs:a}=e,[s,l]=(0,f.uc)(800),[o,i]=(0,n.useState)(null),c=e=>i(t=>t===e?null:e),d=new Map(a.runs.map(e=>[e.run_id,e])),u=t.runs.filter(e=>{var t;let a=null==(t=d.get(e.id))?void 0:t.goal_samples;return(null==a?void 0:a.length)?a.some(e=>e.attempts>1):!!e.outcomes&&e.outcomes.attempts>e.outcomes.recorded_goals}).sort((e,t)=>{var a,r,n,s;return(null!=(r=(0,g.R)(null!=(a=t.outcomes)?a:void 0))?r:-1)-(null!=(s=(0,g.R)(null!=(n=e.outcomes)?n:void 0))?s:-1)}).map((e,t)=>({run:e,progression:function(e,t){let a=e.outcomes,r=null==t?void 0:t.goal_samples;if(!(null==a?void 0:a.recorded_goals))return{available:!1,reason:"No tested goals recorded."};if(!(null==r?void 0:r.length)||r.some(e=>void 0===e.first_jailbreak_attempt))return{available:!1,reason:"First-success summaries were not recorded for this attack."};let n=r.filter(e=>null!==e.first_jailbreak_attempt);if(r.length!==a.recorded_goals||n.length!==a.jailbroken||new Set(r.map(e=>e.goal_index)).size!==r.length||r.some(e=>!Number.isInteger(e.attempts)||e.attempts<1||null!==e.first_jailbreak_attempt&&(!Number.isInteger(e.first_jailbreak_attempt)||e.first_jailbreak_attempt<1||e.first_jailbreak_attempt>e.attempts)))return{available:!1,reason:"Progression summaries do not match the recorded outcomes. Refresh to load a consistent snapshot."};let s=Math.max(...r.map(e=>e.attempts)),l=new Map;n.forEach(e=>{var t;let a=e.first_jailbreak_attempt;l.set(a,(null!=(t=l.get(a))?t:0)+1)});let o=0,i=[{attempt:0,percent:0},...Array.from(l).sort((e,t)=>{let[a]=e,[r]=t;return a-r}).map(e=>{let[t,r]=e;return{attempt:t,percent:100*(o+=r)/a.recorded_goals}})];return i[i.length-1].attempt!==s&&i.push({attempt:s,percent:100*o/a.recorded_goals}),{available:!0,denominator:a.recorded_goals,successes:o,maxAttempt:s,points:i}}(e,d.get(e.id)),color:"hsl(".concat((137.5*t+210)%360,", 65%, 45%)"),dash:["","7 3","2 3","9 3 2 3"][t%4]})),m=u.filter(e=>e.progression.available),p=Math.max(1,...u.map(e=>e.progression.available?e.progression.maxAttempt:0)),h=Math.max(640,l),v=h-35,b=e=>62+e/p*(v-62),j=e=>280-e/100*258,y=Array.from(new Set([0,1,...[.25,.5,.75,1].map(e=>Math.round(p*e))])).sort((e,t)=>e-t);return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(I,{campaign:t,costs:a,firstSuccess:!0}),(0,r.jsxs)("figure",{"aria-label":"Cumulative success by recorded attempt",className:"space-y-3",children:[(0,r.jsxs)("figcaption",{children:[(0,r.jsx)("h3",{className:"text-base font-semibold",children:"What does continuing the search gain?"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Attacks with multiple recorded attempts for at least one goal, including static attacks. Each goal enters once, at its first recorded jailbreak. Every endpoint equals that attack's ASR."})]}),(0,r.jsxs)("div",{className:"grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_17rem]",children:[m.length>0&&(0,r.jsx)("div",{ref:s,className:"min-w-0 overflow-x-auto rounded-lg border bg-background/50",children:(0,r.jsxs)("svg",{width:h,height:330,className:"block",role:"group","aria-label":"Cumulative success step curves",children:[[0,25,50,75,100].map(e=>(0,r.jsxs)("g",{children:[(0,r.jsx)("line",{x1:62,x2:v,y1:j(e),y2:j(e),stroke:"var(--border)",strokeDasharray:"3 4"}),(0,r.jsxs)("text",{x:52,y:j(e)+4,textAnchor:"end",fontSize:11,fill:"var(--muted-foreground)",children:[e,"%"]})]},e)),y.map(e=>(0,r.jsxs)("g",{children:[(0,r.jsx)("line",{x1:b(e),x2:b(e),y1:280,y2:285,stroke:"var(--border)"}),(0,r.jsx)("text",{x:b(e),y:300,textAnchor:"middle",fontSize:11,fill:"var(--muted-foreground)",children:e})]},e)),(0,r.jsx)("text",{x:16,y:151,transform:"rotate(-90 16 ".concat(151,")"),textAnchor:"middle",fontSize:11,fill:"var(--muted-foreground)",children:"Tested goals jailbroken"}),(0,r.jsx)("text",{x:(62+v)/2,y:321,textAnchor:"middle",fontSize:11,fill:"var(--muted-foreground)",children:"Recorded attempt number"}),[...u].sort((e,t)=>Number(e.run.id===o)-Number(t.run.id===o)).map(e=>{let{run:a,progression:n,color:s,dash:l}=e;if(!n.available)return null;let i=(0,x.aN)(a,t.runs),d=n.points[n.points.length-1],u="M ".concat(b(0)," ").concat(j(0));n.points.slice(1).forEach(e=>{u+=" H ".concat(b(e.attempt)," V ").concat(j(e.percent))});let m=function(e,t){let a=t.points[t.points.length-1];return"".concat(e," \xb7 cumulative success\n\nSucceeded: ").concat(t.successes," of ").concat(t.denominator," tested goals\nFinal ASR: ").concat(a.percent.toFixed(1),"%\nLast recorded attempt: ").concat(t.maxAttempt,"\n\n").concat(t.points.filter(e=>e.attempt>0).map(e=>"By attempt ".concat(e.attempt,": ").concat(e.percent.toFixed(1),"%")).join("\n"))}(i,n);return(0,r.jsxs)(_,{description:m,onSelect:()=>c(a.id),selected:o===a.id,opacity:o&&o!==a.id?.25:1,children:[(0,r.jsx)("path",{d:u,fill:"none",stroke:s,strokeWidth:o===a.id?3:2,strokeDasharray:l}),(0,r.jsx)("path",{d:u,fill:"none",stroke:"transparent",strokeWidth:14}),(0,r.jsx)("circle",{cx:b(d.attempt),cy:j(d.percent),r:4,fill:s,"data-progression-run":a.id,"data-endpoint-asr":d.percent,"data-endpoint-attempt":d.attempt})]},a.id)})]})}),(0,r.jsxs)("div",{role:"group","aria-label":"Cumulative success legend",className:w,children:[(0,r.jsx)("p",{className:"mb-1 text-sm font-semibold",children:"Attacks"}),(0,r.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:"Select one to highlight its curve."}),(0,r.jsx)("div",{className:"grid gap-1 sm:grid-cols-2 lg:grid-cols-1",children:u.map(e=>{let{run:a,progression:n,color:s,dash:l}=e,i=(0,x.aN)(a,t.runs),d=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("svg",{"aria-hidden":"true",width:24,height:14,className:"shrink-0",children:(0,r.jsx)("line",{x1:0,x2:24,y1:7,y2:7,stroke:s,strokeWidth:3,strokeDasharray:l})}),(0,r.jsxs)("span",{className:"min-w-0",children:[(0,r.jsx)("strong",{className:"block break-words",children:i}),n.available?(0,r.jsxs)("span",{className:"block text-muted-foreground",children:[(100*n.successes/n.denominator).toFixed(1),"% \xb7 ",n.successes,"/",n.denominator," goals"]}):(0,r.jsx)("span",{className:"block text-muted-foreground",children:n.reason})]})]});return n.available?(0,r.jsx)("button",{type:"button","aria-label":"Highlight ".concat(i," curve"),"aria-pressed":o===a.id,onClick:()=>c(a.id),className:"".concat(N," ").concat(o===a.id?k:"border-transparent"),children:d},a.id):(0,r.jsx)("div",{className:"flex items-start gap-2 p-2 text-xs",children:d},a.id)})}),(0,r.jsx)("button",{type:"button",disabled:!o,className:"mt-3 text-xs underline disabled:no-underline disabled:opacity-50",onClick:()=>i(null),children:"Show all curves equally"})]})]}),!u.length&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No attacks with multiple recorded attempts for a goal in this campaign."}),(0,r.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"The denominator stays fixed at all tested goals, including unsuccessful goals. Curves plateau through the last recorded attempt for each attack. Attempts follow recorded conversation order, not necessarily completion order; static or batched requests may run in parallel. These curves describe observed attempt progression, not repeated-response ASR@k or a guarantee of success from a larger budget."})]}),(0,r.jsx)(F,{campaign:t,costs:a})]})}let T={nuanced:"eval_nj",jailbreakbench:"eval_jb",harmbench:"eval_hb",harmbench_variant:"eval_hbv",strongreject:"eval_sj_binary",on_topic:"eval_on_topic",scorer:"eval_scorer",rag_outcome:"eval_rag"},D=RegExp("[^\\p{L}\\p{N}_]","gu");function P(e){let t=e.trim().toLowerCase().replaceAll(" ","_");return t in T?T[t]:t.startsWith("eval_")?t:"eval_".concat(t.replace(D,"_")||"judge")}let H=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);function J(e){let t=null==e?void 0:e.evaluation,a=H(t)&&Array.isArray(t.judges)?t.judges.filter(H).flatMap(e=>"string"==typeof e.name&&H(e.scoring)&&"string"==typeof e.scoring.type?[{name:e.name,kind:e.scoring.type}]:[]):[];return a.map((e,t)=>{let r=a.filter(t=>t.kind===e.kind).length>1;return{recorded:r?"".concat(e.kind,":").concat(e.name,"#").concat(t+1):e.kind,label:"".concat(e.kind,":").concat(e.name).concat(r?"#".concat(t+1):"")}})}function W(e){return J(e).map(e=>P(e.recorded))}let U={eval_nj:"Nuanced",eval_jb:"JailbreakBench",eval_hb:"HarmBench",eval_hbv:"HarmBench variant",eval_sj_binary:"StrongReject",eval_on_topic:"On-topic",eval_scorer:"Scorer",eval_rag:"RAG outcome"};function G(e){var t;let a=new Map([["panel","Panel"]]);for(let t of J(e.configuration))a.set(t.recorded,t.label),a.set(P(t.recorded),t.label);return null==(t=e.audit)||t.judges.forEach(e=>{a.has(P(e.judge))||a.set(P(e.judge),e.judge)}),e=>{var t,r;return null!=(r=null!=(t=a.get(e))?t:U[e])?r:e.replace(/^eval_/,"")}}let $=e=>"".concat((100*e).toFixed(1),"%"),q=e=>e.toFixed(3),B=e=>"panel"===e?"Panel":e,K={prepend_append:"Adds harmless text before and after the same answer.",refusal_prefix:"Adds a refusal sentence before the same answer.",educational_framing:"Presents the same answer as educational or defensive material.",fictional_story:"Presents the same answer as fictional dialogue."},V=e=>void 0!==e&&Number.isFinite(e)&&e>=0&&e<=1?e:null;function Z(e){let{rows:t,plots:a,label:n,rowHeading:s,identify:l,name:o,detail:i,renderName:c,compact:d=!1}=e,[u,m]=(0,f.uc)(1e3),p=d?190:250,h=Math.max(d?68:88,...t.map(e=>16*Math.ceil(o(e).length/(d?22:28))+36)),x=Math.max(p+a.length*((d?180:225)+16),m),g=(x-p-16*a.length)/a.length,v=t.findIndex(e=>"panel"===l(e)),b=v>0,j=40*!!b,y=e=>56+e*h+(b&&e>=v?j:0),w=56+t.length*h+j,N=b?[{start:56,end:56+v*h},{start:y(v),end:w}]:[{start:56,end:w}];return(0,r.jsx)("div",{ref:u,className:"min-w-0 overflow-x-auto",children:(0,r.jsxs)("svg",{width:x,height:w+42,className:"block",role:"group","aria-label":n,children:[(0,r.jsx)("text",{x:16,y:24,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:s}),b&&(0,r.jsx)("text",{x:16,y:y(v)-12,fontSize:11,fontWeight:600,fill:"var(--muted-foreground)",children:"Combined panel"}),t.map((e,t)=>(0,r.jsxs)("g",{"data-audit-row":l(e),children:[(t%2==0||"panel"===l(e))&&(0,r.jsx)("rect",{x:0,y:y(t),width:x,height:h,fill:"var(--muted)",fillOpacity:.35}),(0,r.jsx)("foreignObject",{x:16,y:y(t)+8,width:p-32,height:h-12,children:(0,r.jsxs)("div",{className:"flex h-full flex-col justify-center text-xs",children:[(0,r.jsx)("span",{className:"break-all font-semibold leading-4",title:o(e),children:c?c(e):o(e)}),(0,r.jsx)("span",{className:"mt-1 text-[10px] text-muted-foreground",children:i(e)})]})})]},l(e))),a.map((e,a)=>{let n=p+a*(g+16),s=t=>(t-e.min)/(e.max-e.min),o=e=>n+18+s(e)*(g-44);return(0,r.jsxs)("g",{role:"group","aria-label":"".concat(e.label," audit panel"),"data-audit-panel":e.id,"data-domain-min":e.min,"data-domain-max":e.max,children:[N.map((e,t)=>(0,r.jsx)("rect",{"data-score-block":0===t?"judges":"panel",x:n,y:0===t?1:e.start,width:g,height:0===t?e.end-1:e.end-e.start,rx:8,fill:"none",stroke:"var(--border)",strokeWidth:1.5},t)),(0,r.jsx)("path",{d:"M".concat(n+1,",").concat(56,"H").concat(n+g-1),stroke:"var(--border)"}),(0,r.jsx)("text",{x:n+g/2,y:26,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--foreground)",children:e.label}),(0,r.jsx)("text",{x:n+g/2,y:43,textAnchor:"middle",fontSize:10,fill:"var(--muted-foreground)",children:e.hint}),e.ticks.map((t,a)=>(0,r.jsxs)("g",{children:[N.map(a=>(0,r.jsx)("line",{x1:o(t),x2:o(t),y1:a.start,y2:a.end,stroke:e.min<0&&0===t?"var(--muted-foreground)":"var(--border)",strokeDasharray:"2 5"},a.start)),(0,r.jsx)("text",{x:o(t),y:w+24,textAnchor:0===a?"start":a===e.ticks.length-1?"end":"middle",fontSize:10,fill:"var(--muted-foreground)",children:e.format(t)})]},t)),t.map((t,a)=>{let{value:i,description:c,limit:u,color:m="var(--viz-family-static)"}=e.measure(t),p=y(a)+27;return(0,r.jsxs)(_,{description:c,children:[(0,r.jsx)("rect",{x:n+2,y:y(a),width:g-4,height:h,fill:"transparent"}),null!==i?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("line",{x1:o(0),x2:o(i),y1:p,y2:p,stroke:m,strokeWidth:2,strokeOpacity:.4}),(0,r.jsx)("circle",{"data-audit-marker":l(t),"data-value":i,cx:o(i),cy:p,r:4,fill:m}),(0,r.jsx)("text",{x:o(i),y:p+(d?22:29),textAnchor:.3>s(i)?"start":s(i)>.7?"end":"middle",fontSize:10,fill:"var(--muted-foreground)",children:e.format(i)})]}):(0,r.jsx)("text",{x:n+g/2,y:p+4,textAnchor:"middle",fontSize:11,fill:"var(--muted-foreground)",children:"Not recorded"}),void 0!==u&&(0,r.jsx)("line",{"data-audit-limit":l(t),x1:o(u),x2:o(u),y1:p-10,y2:p+10,stroke:"var(--foreground)",strokeWidth:2})]},l(t))})]},e.id)})]})})}function Y(e){var t;let{campaign:a}=e,n=a.audit,s=[...null!=(t=null==n?void 0:n.judges)?t:[]].sort((e,t)=>Number("panel"===e.judge)-Number("panel"===t.judge)),l=function(e){let t=Array.from(new Set(e.flatMap(e=>{var t,a;return null!=(a=null==(t=e.robustness)?void 0:t.wrappers.map(e=>e.wrapper))?a:[]}))),a=Math.min(1,Math.max(.1,Math.ceil(10*Math.max(0,...e.flatMap(e=>e.robustness?[e.robustness.max_flip_rate,...e.robustness.wrappers.map(e=>e.flip_rate)]:[]).filter(e=>null!==V(e))))/10));return t.map(e=>({id:e,label:e.replace(/_/g," "),hint:"Verdicts changed \xb7 lower is better",min:0,max:a,ticks:[0,a/2,a],format:$,measure(t){var a,r,n,s,l,o;let i=null==(a=t.robustness)?void 0:a.wrappers.find(t=>t.wrapper===e),c=V(null==i?void 0:i.flip_rate),d=V(null==(r=t.robustness)?void 0:r.max_flip_rate),u=!0===t.passed?"Within configured limit":!1===t.passed?"Over configured limit":"Not graded";return{value:c,limit:i&&null!==d?d:void 0,description:"".concat(B(t.judge)," \xb7 ").concat(e.replace(/_/g," "),"\n\n").concat(null!=(n=K[e])?n:"Recorded content-preserving wrapper.","\nThe answer and its correct label stay unchanged.\n\nVerdicts changed: ").concat(null===c?"Not recorded":$(c)).concat((null==i?void 0:i.flips)===void 0?"":" (".concat(i.flips,")"),"\nCorrect harmful detections hidden: ").concat(null!=(s=null==i?void 0:i.true_positive_evasions)?s:"Not recorded","\nShare of original correct harmful detections hidden: ").concat((null==i?void 0:i.true_positive_evasion_rate)===void 0?"Not recorded":$(i.true_positive_evasion_rate),"\nHarmful verdict → safe: ").concat(null!=(l=null==i?void 0:i.detected_to_missed)?l:"Not recorded","\nSafe verdict → harmful: ").concat(null!=(o=null==i?void 0:i.missed_to_detected)?o:"Not recorded","\nWrapped accuracy: ").concat((null==i?void 0:i.accuracy)===void 0?"Not recorded":$(i.accuracy),"\nAccuracy change: ").concat((null==i?void 0:i.accuracy_delta)===void 0?"Not recorded":"".concat((100*i.accuracy_delta).toFixed(1)," pp"),"\n\nChanged by any wrapper: ").concat(t.robustness?$(t.robustness.any_wrapper_flip_rate):"Not recorded","\nConfigured maximum: ").concat(null===d?"Not recorded":$(d),"\nOverall check: ").concat(t.robustness?u:"Not recorded","\nThe overall check uses the union across wrappers, counting each sample once—not this wrapper alone.")}}}))}(s),o=G(a),i={rows:s,rowHeading:"Judge / panel",identify:e=>e.judge,name:e=>o(e.judge),detail:e=>"".concat(e.metrics.samples," samples").concat("panel"===e.judge?" \xb7 combined verdict":"")};return(0,r.jsxs)("section",{id:"campaign-audit",tabIndex:-1,className:"investigation-panel min-w-0 scroll-mt-[calc(var(--campaign-navigation-height,0px)+1rem)] space-y-6 p-5 sm:p-6","aria-label":"Campaign audit",children:[(0,r.jsxs)("header",{children:[(0,r.jsx)("p",{className:"section-eyebrow",children:"05 / Judge audit"}),(0,r.jsx)("h2",{className:"mt-2 text-xl font-semibold",children:"Can we trust the verdicts?"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Compare each judge, then the panel, on labelled examples and content-preserving wrappers."})]}),n?s.length?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("figure",{"aria-label":"Judge calibration plots",className:"space-y-3",children:[(0,r.jsxs)("figcaption",{children:[(0,r.jsx)("h3",{className:"text-base font-semibold",children:"Can judges distinguish harmful from safe?"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Youden’s J is the primary comparison: −1 reversed, 0 no discrimination, +1 perfect separation. “Falsely accused” means safe examples incorrectly flagged harmful."})]}),(0,r.jsx)(Z,{...i,plots:[{id:"j",label:"Youden’s J",hint:"Higher is better \xb7 −1 to +1",min:-1,max:1,ticks:[-1,-.5,0,.5,1],format:q},{id:"detected",label:"Harmful detected",hint:"Higher is better \xb7 sensitivity",min:0,max:1,ticks:[0,.25,.5,.75,1],format:$},{id:"accused",label:"Falsely accused",hint:"Lower is better \xb7 false positives",min:0,max:1,ticks:[0,.25,.5,.75,1],format:$}].map(e=>({...e,measure(t){var a,r,n,s,l;let o=function(e){var t;let{tp:a,fp:r,tn:n,fn:s}=e,l=[a,r,n,s].every(e=>void 0!==e&&Number.isInteger(e)&&e>=0)&&void 0!==a&&void 0!==r&&void 0!==n&&void 0!==s&&a+r+n+s===e.samples,o=e.samples>0,i=l&&a+s>0?a/(a+s):null,c=l&&n+r>0?n/(n+r):null,d=null!==i&&null!==c,u=l?Math.sqrt((a+r)*(a+s)*(n+r)*(n+s)):0;return{precision:l?a+r>0?a/(a+r):null:o?e.precision:null,recall:l?i:o?e.recall:null,accuracy:l&&o?(a+n)/e.samples:o?e.accuracy:null,f1:l?2*a+r+s>0?2*a/(2*a+r+s):null:o&&null!=(t=e.f1)?t:null,specificity:c,balancedAccuracy:d?(i+c)/2:null,youdensJ:d?i+c-1:null,mcc:l&&u>0?(a*n-r*s)/u:null,falsePositiveRate:null===c?null:1-c,falseNegativeRate:null===i?null:1-i,negativePredictiveValue:l&&n+s>0?n/(n+s):null,validCounts:l}}(t.metrics),i="j"===e.id?o.youdensJ:"detected"===e.id?o.recall:o.falsePositiveRate,c=t.metrics,d="j"===e.id?"J = sensitivity + specificity − 1.\n−1: completely reversed; 0: no discrimination; +1: perfect separation.":"detected"===e.id?"Share of labelled harmful examples the judge detected.":"Share of labelled safe examples incorrectly flagged harmful.";return{value:i,description:"".concat(B(t.judge)," \xb7 ").concat(e.label,"\n\nValue: ").concat(null===i?"Not measured":e.format(i),"\n").concat(d,"\n\nSamples: ").concat(c.samples,"\nHarmful detected (TP): ").concat(null!=(a=c.tp)?a:"Not recorded","\nHarmful missed (FN): ").concat(null!=(r=c.fn)?r:"Not recorded","\nSafe falsely flagged (FP): ").concat(null!=(n=c.fp)?n:"Not recorded","\nSafe correctly passed (TN): ").concat(null!=(s=c.tn)?s:"Not recorded","\nAbstentions: ").concat(null!=(l=c.abstentions)?l:"Not recorded").concat(null===i?"\n\nValid counts and a nonzero class denominator are required for this statistic.":"")}}})),label:"Aligned judge calibration scores"}),(0,r.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"J = sensitivity + specificity − 1. The panel is measured on its own combined verdicts, not the mean of judges’ scores. These are single measured scores, not distributions or quality grades. Hover, focus or tap for exact counts. Missing class denominators remain unmeasured."})]}),(0,r.jsxs)("figure",{"aria-label":"Judge robustness plots",className:"space-y-3 border-t pt-6",children:[(0,r.jsxs)("figcaption",{children:[(0,r.jsx)("h3",{className:"text-base font-semibold",children:"Does wrapping the same answer change the verdict?"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Each panel is one wrapper. The answer and its correct label stay the same; markers show the percentage of original verdicts that changed. Lower is better; ideally 0%."})]}),l.length?(0,r.jsx)(Z,{...i,plots:l,label:"Aligned wrapper verdict-change rates"}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No wrapper robustness measurements recorded."}),(0,r.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"All wrappers share a linear percentage scale. Black ticks show each judge’s configured maximum. The overall check uses samples changed by any wrapper, counting each sample once—not each wrapper independently. Hover, focus or tap for wrapper descriptions, hidden correct detections and the overall result. A changed verdict may correct an original error or introduce one."})]})]}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No judge metrics recorded."}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No audit recorded for this execution."})]})}var Q=a(27937),X=a(24033);let ee="For the same row and column: micro > macro means the agreement group or vote pattern tends to be more frequent in goals with more attempts; micro < macro means it tends to be more frequent in goals with fewer attempts. This association alone does not establish a cause or measure ASR@goal.",et=["unanimous","mixed","incomplete"];function ea(e){return e.includes("?")?"incomplete":e.includes("0")&&e.includes("1")?"mixed":"unanimous"}function er(e){return"mixed"===e?"Mixed verdict":"incomplete"===e?"Incomplete":"Unanimous"}function en(e){let{description:t,share:a}=e,[s,l]=(0,n.useState)(!1);return(0,r.jsxs)(y.m_,{open:s,onOpenChange:l,children:[(0,r.jsx)(y.k$,{asChild:!0,children:(0,r.jsx)("button",{type:"button","aria-label":t,onClick:()=>l(!0),className:"block w-full rounded-sm px-2 py-2 text-[10px] tabular-nums focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring",style:{backgroundColor:null===a||0===a?"var(--muted)":"color-mix(in srgb, var(--viz-family-static) ".concat(Math.round(8+72*a),"%, var(--card))")},children:null===a?"—":"".concat((100*a).toFixed(1),"%")})}),(0,r.jsx)(y.ZI,{className:"max-w-80 text-xs",children:t})]})}function es(e,t){if(!e.outcome_patterns)return;let a=new Set;if(e.outcome_patterns.some(e=>{let r="".concat(e.outcome,":").concat(e.pattern),n=!["jailbreak","mitigated","unresolved"].includes(e.outcome)||e.pattern.length!==t||!/^[01?]+$/.test(e.pattern)||!Number.isInteger(e.attempts)||e.attempts<0||a.has(r);return a.add(r),n})||e.outcome_patterns.reduce((e,t)=>e+t.attempts,0)!==e.attempts)throw Error("Recorded outcome patterns do not match the recorded attempts. Refresh to load a consistent snapshot.");let r=e.goal_weighted;if(r){let t=new Set,a=new Set(e.outcome_patterns.map(e=>"".concat(e.outcome,":").concat(e.pattern)));if(!Number.isInteger(r.goals)||r.goals<0||r.outcome_patterns.some(e=>{let r="".concat(e.outcome,":").concat(e.pattern),n=!a.has(r)||t.has(r)||!Number.isFinite(e.weight)||e.weight<0;return t.add(r),n})||Math.abs(r.outcome_patterns.reduce((e,t)=>e+t.weight,0)-r.goals)>1e-8*Math.max(1,r.goals))throw Error("Goal-weighted patterns do not match the recorded goals. Refresh to load a consistent snapshot.")}}function el(e){let{campaign:t}=e,[a,s]=(0,n.useState)("attempts"),l="goals"===a,[o,i]=(0,n.useState)(new Set),c=t.judge_agreement,d=G(t),u=null;try{es(c,c.judges.length)}catch(e){u=e instanceof Error?e.message:String(e)}let m=t.runs.map(e=>{let a=c.runs.find(t=>t.run_id===e.id),r=null;try{a&&es(a,c.judges.length)}catch(e){r=e instanceof Error?e.message:String(e)}return{id:e.id,label:(0,x.aN)(e,t.runs),counts:a,error:r}}).sort((e,t)=>e.label.localeCompare(t.label)),p=[{id:"all-attempts",label:"All attempts",counts:c,error:u},...m],g=e=>e.split("").filter(e=>"1"===e).length,v=et.flatMap(e=>{var t;let a=new Set;(null!=(t=c.outcome_patterns)?t:[]).forEach(t=>{t.attempts>0&&ea(t.pattern)===e&&a.add(t.pattern)});let r=[];return a.forEach(e=>r.push(e)),r.sort((e,t)=>g(e)-g(t)||e.localeCompare(t)),r.length?[{group:e,pattern:null},...o.has(e)?[]:r.map(t=>({group:e,pattern:t}))]:[]});return(0,r.jsxs)("figure",{className:"min-w-0 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,r.jsx)("figcaption",{className:"text-base font-semibold",children:"Exact judge patterns"}),(0,r.jsxs)("div",{role:"group","aria-label":"Judge frequency weighting",className:"flex gap-1",children:[(0,r.jsxs)(y.m_,{children:[(0,r.jsx)(y.k$,{asChild:!0,children:(0,r.jsx)(h.$,{size:"sm",variant:l?"outline":"secondary","aria-pressed":!l,onClick:()=>s("attempts"),children:"Micro \xb7 Attempts"})}),(0,r.jsxs)(y.ZI,{className:"max-w-80 space-y-2 text-xs",children:[(0,r.jsx)("p",{children:"Average over all attempts directly. Every response counts equally, so goals with more attempts contribute more."}),(0,r.jsx)("p",{children:ee})]})]}),(0,r.jsxs)(y.m_,{children:[(0,r.jsx)(y.k$,{asChild:!0,children:(0,r.jsx)(h.$,{size:"sm",variant:l?"secondary":"outline","aria-pressed":l,onClick:()=>s("goals"),children:"Macro \xb7 Goals"})}),(0,r.jsxs)(y.ZI,{className:"max-w-80 space-y-2 text-xs",children:[(0,r.jsx)("p",{children:"First average over attempts within each goal, then average equally over goals. Every goal counts equally, regardless of its number of attempts. This is not ASR@goal."}),(0,r.jsx)("p",{children:ee})]})]})]})]}),(0,r.jsx)("ul",{"aria-label":"Judge pattern key",className:"flex flex-wrap gap-4 text-xs text-muted-foreground",title:"Unknown judge votes include abstaining, missing or invalid votes.",children:[["1","Jailbreak",f.Md.jailbroken],["0","Mitigation",f.Md.mitigated],["?","Unknown",f.Md.unresolved]].map(e=>{let[t,a,n]=e;return(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"block h-3.5 w-3.5 rounded-[1px]",style:{backgroundColor:n}}),t," \xb7 ",a]},t)})}),u?(0,r.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:u}):c.outcome_patterns?c.attempts?l&&!c.goal_weighted?(0,r.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Goal weighting is unavailable in this snapshot. The updated backend must regenerate goal-level weights from recorded goal identities; attempt totals cannot reconstruct them."}):(0,r.jsxs)("section",{"aria-label":"Judge patterns by attack",className:"min-w-0 space-y-2",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Cell intensity = frequency under the selected averaging mode, from 0% (empty) to 100% (dark). All attempts pools the campaign. Hover, focus or tap for counts."}),m.filter(e=>e.error).map(e=>(0,r.jsxs)("p",{role:"alert",className:"text-xs text-destructive",children:[e.label,": ",e.error]},e.id)),(0,r.jsx)("div",{role:"region","aria-label":"Scrollable attack comparison",tabIndex:0,className:"max-w-full overflow-x-auto rounded-md border",children:(0,r.jsxs)("table",{className:"w-full border-separate border-spacing-0 text-xs",children:[(0,r.jsxs)("caption",{className:"sr-only",children:["Judge pattern frequency across the campaign and within each attack. ",l?"Each column weights its recorded goals equally.":"Each column uses its own attempt count."]}),(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"bg-card",children:[(0,r.jsx)("th",{scope:"col",className:"sticky left-0 z-10 min-w-40 whitespace-nowrap border-b bg-card p-3 text-left align-bottom",children:"Agreement / judge votes"}),p.map((e,t)=>(0,r.jsxs)("th",{scope:"col",className:"min-w-24 border-b p-2 align-bottom font-medium ".concat(0===t?"bg-muted/20":""),children:[(0,r.jsx)("span",{className:"block whitespace-nowrap",title:e.label,children:e.label}),(0,r.jsx)("span",{className:"mt-1 block whitespace-nowrap text-[10px] font-normal text-muted-foreground",children:e.counts?"".concat(e.counts.goal_weighted?"".concat(e.counts.goal_weighted.goals.toLocaleString()," goals \xb7 "):"").concat(e.counts.attempts.toLocaleString()," attempts"):"Not recorded"})]},e.id))]})}),(0,r.jsx)("tbody",{children:v.map(e=>{let t;return(0,r.jsxs)("tr",{className:null===e.pattern?"bg-muted/40 font-semibold":"even:bg-muted/20",children:[(0,r.jsx)("th",{scope:"row","aria-label":null===e.pattern?er(e.group):"".concat(er(e.group)," \xb7 Judge votes ").concat(e.pattern),className:"sticky left-0 z-10 border-b bg-card py-3 pr-3 text-left ".concat(null===e.pattern?"pl-3":"pl-10"),children:null===e.pattern?(0,r.jsxs)("button",{type:"button","aria-expanded":!o.has(e.group),"aria-label":"Toggle ".concat(er(e.group)),onClick:()=>{let t;return t=e.group,i(e=>{let a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a})},className:"flex w-full items-center gap-1 rounded-sm text-left focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring",children:[o.has(e.group)?(0,r.jsx)(Q.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}):(0,r.jsx)(X.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}),er(e.group)]}):(t=e.pattern,(0,r.jsx)("span",{className:"flex flex-wrap gap-3",children:c.judges.map((e,a)=>{let n=t[a],s="1"===n?"Jailbreak":"0"===n?"Mitigation":"Unknown",l="1"===n?f.Md.jailbroken:"0"===n?f.Md.mitigated:f.Md.unresolved;return(0,r.jsx)("span",{role:"img","aria-label":"J".concat(a+1," \xb7 ").concat(d(e.id),": ").concat(s),title:"".concat(d(e.id),": ").concat(s),className:"inline-block h-3.5 w-3.5 rounded-[1px]",style:{backgroundColor:l}},e.id)})}))}),p.map((t,a)=>{var n,s,o,i,c,d,u,m,p;let h=null!=(u=null==(n=t.counts)?void 0:n.attempts)?u:0,x=!t.error&&(null==(s=t.counts)?void 0:s.outcome_patterns)!==void 0&&h>0,g=null!=(m=null==(i=t.counts)||null==(o=i.outcome_patterns)?void 0:o.filter(t=>ea(t.pattern)===e.group&&(null===e.pattern||t.pattern===e.pattern)).reduce((e,t)=>e+t.attempts,0))?m:0,f=null==(c=t.counts)?void 0:c.goal_weighted,v=null!=(p=null==f?void 0:f.outcome_patterns.filter(t=>ea(t.pattern)===e.group&&(null===e.pattern||t.pattern===e.pattern)).reduce((e,t)=>e+t.weight,0))?p:0,b=x?l?f&&f.goals>0?v/f.goals:null:g/h:null,j="".concat(t.label," \xb7 ").concat(er(e.group)).concat(null===e.pattern?"":" \xb7 ".concat(e.pattern),": ").concat(null===b?t.error?"Invalid pattern data":(null==(d=t.counts)?void 0:d.attempts)===0?"No attempts recorded":l&&!f?"Goal weights unavailable":"Patterns not recorded":l?"".concat((100*b).toFixed(1),"% macro average; ").concat(g," of ").concat(h," raw attempts"):"".concat(g," / ").concat(h," attempts (").concat((100*b).toFixed(1),"%)"));return(0,r.jsx)("td",{className:"border-b p-1.5 text-center ".concat(0===a?"bg-muted/20":""),children:(0,r.jsx)(en,{description:j,share:b})},t.id)})]},"".concat(e.group,":").concat(e.pattern))})})]})})]}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No attempts recorded."}):(0,r.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Judge patterns are preparing. The updated backend must regenerate this snapshot."}),(0,r.jsx)("ul",{className:"flex flex-wrap gap-x-5 gap-y-1 text-xs text-muted-foreground","aria-label":"Judge order",children:c.judges.map((e,t)=>(0,r.jsxs)("li",{className:"break-all",children:["J",t+1," \xb7 ",d(e.id)]},e.id))})]})}function eo(e){let{campaign:t}=e,a=t.judge_agreement;return a&&a.judges.length?(0,r.jsx)(el,{campaign:t}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Per-judge votes were not recorded. Agreement cannot be measured."})}var ei=a(5917),ec=a(75426),ed=a(42710);function eu(e){let{text:t,label:a}=e,[s,l]=(0,n.useState)(!1);return(0,r.jsxs)(h.$,{variant:"ghost",size:"sm","aria-label":a,onClick:()=>{var e;null==(e=navigator.clipboard)||e.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!1),1500)})},children:[s?(0,r.jsx)(ei.A,{className:"mr-2 h-4 w-4"}):(0,r.jsx)(ec.A,{className:"mr-2 h-4 w-4"}),s?"Copied":"Copy"]})}function em(e){let{text:t,label:a}=e;return(0,r.jsxs)("div",{className:"relative rounded-md border bg-muted/40",children:[(0,r.jsx)("div",{className:"absolute right-1 top-1",children:(0,r.jsx)(eu,{text:t,label:"Copy ".concat(a)})}),(0,r.jsx)("pre",{"aria-label":a,className:"overflow-x-auto p-4 pr-24 font-mono text-xs leading-relaxed",children:t})]})}function ep(e){var t;let{campaign:a}=e;return a.configuration&&Object.keys(a.configuration).length?(0,r.jsxs)("details",{className:"investigation-panel p-4",children:[(0,r.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:"Campaign configuration (YAML)"}),(0,r.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["The campaign file as executed. Credentials are replaced with [REDACTED]. ","Endpoints are the addresses used during this execution and may differ from the file you launched."]}),(0,r.jsx)("div",{className:"mt-3",children:(0,r.jsx)(em,{text:(t=a.configuration,(0,ed.As)(t,{lineWidth:0})),label:"Campaign configuration"})})]}):null}function eh(e){let{id:t,eyebrow:a,title:n,description:s,label:l,children:o}=e;return(0,r.jsxs)("section",{id:t,tabIndex:-1,"aria-label":l,className:"investigation-panel min-w-0 scroll-mt-[calc(var(--campaign-navigation-height,0px)+1rem)] space-y-5 p-5 sm:p-6",children:[(0,r.jsxs)("header",{children:[(0,r.jsx)("p",{className:"section-eyebrow",children:a}),(0,r.jsx)("h2",{className:"mt-2 text-xl font-semibold",children:n}),(0,r.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:s})]}),o]})}let ex=[{id:"campaign-coverage",label:"Coverage"},{id:"campaign-success",label:"Success progression"},{id:"campaign-cost",label:"Cost"},{id:"campaign-agreement",label:"Judge agreement"},{id:"campaign-audit",label:"Judge audit"}];function eg(){let e=(0,n.useRef)(null),[t,a]=(0,n.useState)(ex[0].id);return(0,n.useEffect)(()=>{let t=e.current,r=null==t?void 0:t.parentElement;if(!t||!r)return;let n=()=>{let e=t.getBoundingClientRect().bottom+17,n=ex[0].id;for(let t of ex){let a=r.querySelector("#".concat(t.id));a&&a.getBoundingClientRect().top<=e&&(n=t.id)}a(n)},s=()=>{r.style.setProperty("--campaign-navigation-height","".concat(t.getBoundingClientRect().height,"px")),n()};s();let l=new ResizeObserver(s);return l.observe(t),l.observe(r),document.addEventListener("scroll",n,!0),window.addEventListener("resize",s),()=>{l.disconnect(),document.removeEventListener("scroll",n,!0),window.removeEventListener("resize",s),r.style.removeProperty("--campaign-navigation-height")}},[]),(0,r.jsx)("nav",{ref:e,"aria-label":"Campaign sections",className:"sticky top-0 z-40 overflow-x-auto border-b bg-background shadow-sm",children:(0,r.jsx)("div",{className:"flex min-w-max items-center gap-5 px-1",children:ex.map(e=>(0,r.jsx)("a",{href:"#".concat(e.id),"aria-current":t===e.id?"location":void 0,className:"border-b-2 py-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ".concat(t===e.id?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),onClick:t=>{if(0!==t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;t.preventDefault();let r=document.getElementById(e.id);r&&(r.scrollIntoView({block:"start"}),r.focus({preventScroll:!0}),a(e.id))},children:e.label},e.id))})})}function ef(e){let{campaign:t,costs:a,costStatus:n,coverage:s,conversationsAvailable:l=!0}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(j,{campaign:t,costs:a}),(0,r.jsx)(eg,{}),(0,r.jsx)(eh,{id:"campaign-coverage",eyebrow:"01 / Goal coverage",title:"Which goals held?",label:"Goal by attack outcomes",description:"All goals summarizes each attack's overall success rate; columns are ranked by ASR. Expand categories and subcategories for details".concat(l?", or select a goal's outcome marker to open its conversation.":". Conversations are not included in this offline snapshot."),children:s}),(0,r.jsx)(eh,{id:"campaign-success",eyebrow:"02 / Success progression",title:"How soon do attacks succeed?",label:"Success progression",description:"Compare first-jailbreak distributions among successful goals, then see cumulative success across recorded attempts. Attacks are ranked by ASR; successful/tested counts keep failures visible.",children:a?(0,r.jsx)(O,{campaign:t,costs:a}):n}),(0,r.jsx)(eh,{id:"campaign-cost",eyebrow:"03 / Cost",title:"How much does each attack use?",label:"Attack efficiency",description:"Compare per-goal cost distributions across attacks, ranked by success rate. Symlog cost axes preserve zeros and compress large values; lower costs sit further left.",children:a?(0,r.jsx)(z,{campaign:t,costs:a}):n}),(0,r.jsx)(eh,{id:"campaign-agreement",eyebrow:"04 / Judge agreement",title:"How often do judges disagree?",label:"Judge agreement",description:"Which judges agree on the same response? Exact attempt-level patterns preserve judge identity; unresolved votes stay separate.",children:(0,r.jsx)(eo,{campaign:t})}),(0,r.jsx)(Y,{campaign:t}),(0,r.jsx)(ep,{campaign:t}),t.notes&&(0,r.jsxs)("details",{className:"investigation-panel p-4",children:[(0,r.jsx)("summary",{className:"cursor-pointer text-sm",children:"Campaign notes"}),(0,r.jsx)("p",{className:"mt-3 whitespace-pre-wrap text-sm",children:t.notes})]})]})}var ev=a(65229);let eb=["Categories","Subcategories","Goals"],ej=[{value:"unreviewed",label:"Not reviewed"},{value:"reviewed",label:"Reviewed"},{value:"differs",label:"Review differs from panel"},{value:"inconclusive",label:"Reviewed inconclusive"}];function ey(e){var t;let a=t=>Array.from(new Set(e.getAll(t).filter(Boolean)));return{search:null!=(t=e.get("search"))?t:"",category:a("category"),subcategory:a("subcategory"),outcome:a("outcome"),attack:a("attack"),review:a("review").filter(e=>ej.some(t=>t.value===e))}}function ew(e){var t;return null!=(t=eb.find(t=>t===e.get("granularity")))?t:null}function eN(e,t){var a,r,n;return t?null!=(n=null==(r=e.attack_outcomes)||null==(a=r.find(e=>e.run_id===t))?void 0:a.verdict)?n:"untested":e.verdict}function ek(e,t){if(!t.length)return e.verdict;let a=t.map(t=>eN(e,t)).filter(e=>"untested"!==e);return a.length?a.includes("jailbroken")?"jailbroken":a.every(e=>"mitigated"===e)?"mitigated":a.every(e=>"error"===e)?"error":"unresolved":"untested"}function e_(e){let{filters:t,attacks:a,onChange:n}=e,s=[{key:"category",label:"Category"},{key:"subcategory",label:"Subcategory"},{key:"attack",label:"Attack"},{key:"outcome",label:"Outcome"},{key:"review",label:"Review"}];if(!t.search&&!s.some(e=>t[e.key].length))return null;let l=(e,t)=>{var r,n,s,l;return"attack"===e?null!=(s=null==(r=a.find(e=>e.value===t))?void 0:r.label)?s:"Unknown attack (".concat(t,")"):"review"===e?null!=(l=null==(n=ej.find(e=>e.value===t))?void 0:n.label)?l:t:"untested"===t?"Not tested":t};return(0,r.jsxs)("div",{"aria-label":"Active goal filters",className:"flex flex-wrap gap-2",children:[t.search&&(0,r.jsxs)(h.$,{size:"sm",variant:"secondary","aria-label":"Remove search filter: ".concat(t.search),onClick:()=>n({search:""}),children:["Search: ",t.search,(0,r.jsx)(ev.A,{"aria-hidden":"true",className:"h-3 w-3"})]}),s.flatMap(e=>t[e.key].map(a=>(0,r.jsxs)(h.$,{size:"sm",variant:"secondary",className:"h-auto max-w-full whitespace-normal text-left text-xs","aria-label":"Remove ".concat(e.label.toLowerCase()," filter: ").concat(l(e.key,a)),onClick:()=>n({[e.key]:t[e.key].filter(e=>e!==a)}),children:[e.label,": ",l(e.key,a),(0,r.jsx)(ev.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"})]},"".concat(e.key,":").concat(a))))]})}var eS=a(65142);function eC(e){let{label:t,options:a,selected:n,onChange:s}=e;return(0,r.jsxs)("fieldset",{className:"min-w-0 space-y-2",children:[(0,r.jsxs)("legend",{className:"text-sm font-semibold",children:[t," (",n.length,")"]}),(0,r.jsx)("div",{className:"max-h-60 space-y-1 overflow-y-auto",children:a.map(e=>(0,r.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 rounded p-1.5 text-sm hover:bg-muted",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-0.5 shrink-0",checked:n.includes(e.value),onChange:t=>s(t.target.checked?[...n,e.value]:n.filter(t=>t!==e.value))}),(0,r.jsx)("span",{className:"min-w-0 break-words",children:e.label})]},e.value))})]})}function eA(e){let{filters:t,attacks:a,categories:n,subcategories:s,detailLevel:l,canExpand:o,filtering:i,radioId:c,searchInput:d,onChange:u,onDetail:m,onClear:p,reviews:x=!1}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eS.p,{ref:d,"aria-label":"Search goals",placeholder:"Search goals...",value:t.search,className:"h-10 w-full min-w-0",onChange:e=>u({search:e.target.value})}),(0,r.jsxs)("div",{"aria-label":"Coverage toolbar",className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)(S.AM,{children:[(0,r.jsx)(S.Wv,{asChild:!0,children:(0,r.jsxs)(h.$,{variant:"outline",children:["Attacks",t.attack.length?" (".concat(t.attack.length,")"):"",(0,r.jsx)(X.A,{"aria-hidden":"true",className:"h-4 w-4"})]})}),(0,r.jsxs)(S.hl,{align:"start","aria-label":"Attack filters",children:[(0,r.jsx)(eC,{label:"Attacks",selected:t.attack,options:a,onChange:e=>u({attack:e})}),(0,r.jsx)("p",{className:"mt-3 text-xs text-muted-foreground",children:"No selection includes every attack. Combined outcome is jailbroken if any selected attack succeeded."})]})]}),(0,r.jsxs)(S.AM,{children:[(0,r.jsx)(S.Wv,{asChild:!0,children:(0,r.jsxs)(h.$,{variant:"outline",children:["Topics",t.category.length+t.subcategory.length?" (".concat(t.category.length+t.subcategory.length,")"):"",(0,r.jsx)(X.A,{"aria-hidden":"true",className:"h-4 w-4"})]})}),(0,r.jsxs)(S.hl,{align:"start","aria-label":"Topic filters",className:"max-h-[80dvh] w-[min(32rem,calc(100vw-2rem))] space-y-3 overflow-y-auto",children:[(0,r.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,r.jsx)(eC,{label:"Categories",selected:t.category,options:n.map(e=>({value:e,label:e})),onChange:e=>u({category:e})}),(0,r.jsxs)("div",{className:"min-w-0 space-y-3",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold",children:["Subcategories (",t.subcategory.length,")"]}),!t.category.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Select a category first."}),s.map(e=>(0,r.jsx)(eC,{label:e.category,selected:t.subcategory.filter(t=>e.names.includes(t)),options:e.names.map(e=>({value:e,label:e})),onChange:a=>u({subcategory:[...t.subcategory.filter(t=>!e.names.includes(t)),...a]})},e.category))]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Match any selection within each group. No selection includes all."})]})]}),(0,r.jsxs)(S.AM,{children:[(0,r.jsx)(S.Wv,{asChild:!0,children:(0,r.jsxs)(h.$,{variant:"outline",children:["Outcomes",t.outcome.length?" (".concat(t.outcome.length,")"):"",(0,r.jsx)(X.A,{"aria-hidden":"true",className:"h-4 w-4"})]})}),(0,r.jsxs)(S.hl,{align:"start","aria-label":"Outcome filters",children:[(0,r.jsx)(eC,{label:"Outcomes",selected:t.outcome,options:["jailbroken","mitigated","unresolved","error","untested"].map(e=>({value:e,label:"untested"===e?"Not tested":e[0].toUpperCase()+e.slice(1)})),onChange:e=>u({outcome:e})}),(0,r.jsx)("p",{className:"mt-3 text-xs text-muted-foreground",children:"Match any selected outcome, combining selected attacks. No selection includes all outcomes."})]})]}),x&&(0,r.jsxs)(S.AM,{children:[(0,r.jsx)(S.Wv,{asChild:!0,children:(0,r.jsxs)(h.$,{variant:"outline",children:["Reviews",t.review.length?" (".concat(t.review.length,")"):"",(0,r.jsx)(X.A,{"aria-hidden":"true",className:"h-4 w-4"})]})}),(0,r.jsxs)(S.hl,{align:"start","aria-label":"Review filters",children:[(0,r.jsx)(eC,{label:"Reviews",selected:t.review,options:ej.map(e=>({value:e.value,label:e.label})),onChange:e=>u({review:e})}),(0,r.jsx)("p",{className:"mt-3 text-xs text-muted-foreground",children:"A goal matches when any of its attempts for the selected attacks does. Not reviewed shows the reviews still to do."})]})]}),(0,r.jsxs)(S.AM,{children:[(0,r.jsx)(S.Wv,{asChild:!0,children:(0,r.jsxs)(h.$,{variant:"outline",children:["Detail: ",null!=l?l:"Custom",(0,r.jsx)(X.A,{"aria-hidden":"true",className:"h-4 w-4"})]})}),(0,r.jsx)(S.hl,{align:"start","aria-label":"Coverage detail",children:(0,r.jsxs)("fieldset",{className:"space-y-2",children:[(0,r.jsx)("legend",{className:"text-sm font-semibold",children:"Detail level"}),eb.map(e=>(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 rounded p-1.5 text-sm hover:bg-muted",children:[(0,r.jsx)("input",{type:"radio",name:"granularity-".concat(c),disabled:!o,checked:l===e,onChange:()=>m(e)}),e]},e)),null===l&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Custom: rows expanded individually."})]})})]}),(0,r.jsx)(h.$,{size:"sm",variant:"ghost",className:"ml-auto",disabled:!i&&"Categories"===l,onClick:p,children:"Clear all"})]})]})}let eM={jailbroken:f.Md.jailbroken,mitigated:"color-mix(in srgb, var(--viz-mitigated) 38%, var(--card))",unresolved:f.Md.unresolved,error:f.Md.error,untested:"var(--muted)"};function eR(e){let{children:t,header:a}=e,s=(0,n.useRef)(null),l=(0,n.useRef)(null),[o,i]=(0,n.useState)({category:"",subcategory:""});return(0,n.useEffect)(()=>{let e=()=>{if(!s.current||!l.current)return;let e=l.current.getBoundingClientRect().bottom,t="",a="";for(let l of Array.from(s.current.querySelectorAll("tr[data-category]"))){var r,n;if(l.getBoundingClientRect().top>e)break;void 0===l.dataset.subcategory?(t=null!=(r=l.dataset.category)?r:"",a=""):(t=null!=(n=l.dataset.category)?n:"",a=l.dataset.subcategory)}i(e=>e.category===t&&e.subcategory===a?e:{category:t,subcategory:a})};return e(),document.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{document.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[t]),(0,r.jsxs)("div",{ref:s,children:[(0,r.jsxs)("div",{ref:l,"aria-label":"Current coverage group",className:"sticky top-[var(--campaign-navigation-height,0px)] z-30 bg-card text-xs shadow-sm",children:[a,(0,r.jsxs)("div",{className:"flex items-baseline gap-1.5 truncate border-b px-3 py-1 leading-tight",children:[(0,r.jsx)("span",{className:"shrink-0 font-semibold",children:o.category||"Goal coverage"}),o.subcategory&&(0,r.jsxs)("span",{className:"truncate text-muted-foreground",children:["\xb7 ",o.subcategory]})]})]}),t]})}function eL(e){let{goals:t,runId:a,label:n,attacks:s}=e,l=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r={recorded_goals:0,jailbroken:0,mitigated:0,unresolved:0};for(let n of e){let e=t?eN(n,t):ek(n,a);"untested"!==e&&(r.recorded_goals++,"jailbroken"===e?r.jailbroken++:"mitigated"===e?r.mitigated++:r.unresolved++)}return r}(t,a,s),o=(0,g.R)(l),i=null===o?"Not tested":"".concat(o.toFixed(1),"%"),c="".concat(l.jailbroken,"/").concat(l.recorded_goals," goals jailbroken \xb7 ").concat(l.unresolved," unresolved");return(0,r.jsxs)("span",{"aria-label":"".concat(n,": ").concat(i),tabIndex:0,title:null===o?"".concat(n,"\n\nNot tested\nNo recorded attempts"):"".concat(n,"\n\nASR: ").concat(i,"\nJailbroken goals: ").concat(l.jailbroken," of ").concat(l.recorded_goals,"\nUnresolved goals: ").concat(l.unresolved),style:null===o?void 0:{backgroundColor:"color-mix(in srgb, var(--viz-jailbroken) ".concat(Math.round(4+.2*o),"%, var(--card))")},className:"block rounded-sm py-1 text-center text-[10px] font-semibold tabular-nums sm:text-xs ".concat(null===o?"text-muted-foreground":""),children:[null===o?"–":i,(0,r.jsxs)("span",{className:"sr-only",children:[" \xb7 ",null===o?"No recorded attempts":c]})]})}let eE=()=>{};function ez(e){let{campaign:t,recordedGoals:a,query:s="",onSelectionChange:l=eE,onOpenGoal:o,status:i}=e,c=void 0!==o,d=function(e,t,a){let[r,s]=(0,n.useState)(()=>ey(new URLSearchParams(t))),[l,o]=(0,n.useState)(()=>ew(new URLSearchParams(t))),[i,c]=(0,n.useState)(()=>new Set),d=(0,n.useRef)(!1),u=(0,n.useRef)(!1),m=(0,n.useMemo)(()=>[...e].sort((e,t)=>e.index-t.index),[e]),p=Object.values(r).some(e=>Array.isArray(e)?e.length>0:!!e),h=(0,n.useMemo)(()=>m.filter(e=>(!r.search||e.goal.toLocaleLowerCase().includes(r.search.toLocaleLowerCase()))&&(!r.category.length||r.category.includes(e.category))&&(!r.subcategory.length||r.subcategory.includes(e.subcategory||"Unspecified Subcategory"))&&(!r.outcome.length||r.outcome.includes(ek(e,r.attack)))&&(!r.review.length||r.review.some(t=>(function(e,t,a){var r;let n=(null!=(r=e.attack_outcomes)?r:[]).filter(e=>!t.length||t.includes(e.run_id)).reduce((e,t)=>{var a,r,n;return{attempts:e.attempts+t.attempts,reviewed:e.reviewed+(null!=(a=t.reviewed_attempts)?a:0),inconclusive:e.inconclusive+(null!=(r=t.inconclusive_attempts)?r:0),differs:e.differs+(null!=(n=t.overridden_attempts)?n:0)}},{attempts:0,reviewed:0,inconclusive:0,differs:0});return"unreviewed"===a?n.reviewed<n.attempts:"reviewed"===a?n.reviewed>0:"differs"===a?n.differs>0:n.inconclusive>0})(e,r.attack,t)))),[m,r]),x=(0,n.useMemo)(()=>{let e=new Map;for(let t of h){e.has(t.category)||e.set(t.category,new Map);let a=e.get(t.category),r=t.subcategory||"Unspecified Subcategory";a.has(r)||a.set(r,[]),a.get(r).push(t)}return Array.from(e).sort((e,t)=>{let[a]=e,[r]=t;return a.localeCompare(r,void 0,{numeric:!0})}).map(e=>{let[t,a]=e;return{category:t,subcategories:Array.from(a).sort((e,t)=>{let[a]=e,[r]=t;return a.localeCompare(r,void 0,{numeric:!0})})}})},[h]),g=(0,n.useMemo)(()=>Array.from(new Set(m.map(e=>e.category))).sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0})),[m]),f=(0,n.useMemo)(()=>r.category.map(e=>({category:e,names:Array.from(new Set(m.filter(t=>t.category===e).map(e=>e.subcategory||"Unspecified Subcategory"))).sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0}))})),[m,r.category]);(0,n.useEffect)(()=>{let e=ey(new URLSearchParams(t));s(t=>JSON.stringify(t)===JSON.stringify(e)?t:e),o(ew(new URLSearchParams(t)))},[t]),(0,n.useEffect)(()=>{if(d.current){d.current=!1;return}l?c(new Set(x.flatMap(e=>"Categories"===l?[]:[JSON.stringify([e.category]),..."Goals"===l?e.subcategories.map(t=>{let[a]=t;return JSON.stringify([e.category,a])}):[]]))):p?c(new Set(x.flatMap(e=>[JSON.stringify([e.category]),...e.subcategories.map(t=>{let[a]=t;return JSON.stringify([e.category,a])})]))):u.current&&c(new Set),u.current=p},[x,p,l]);let v=x.map(e=>JSON.stringify([e.category])),b=x.flatMap(e=>e.subcategories.map(t=>{let[a]=t;return JSON.stringify([e.category,a])})),j=v.length>0&&v.every(e=>i.has(e)),y=j&&b.length>0&&b.every(e=>i.has(e))?"Goals":j&&!b.some(e=>i.has(e))?"Subcategories":v.some(e=>i.has(e))?null:"Categories";function w(e){let t={...r,...e};if(e.category){let e=new Set(m.filter(e=>t.category.includes(e.category)).map(e=>e.subcategory||"Unspecified Subcategory"));t.subcategory=t.subcategory.filter(t=>e.has(t))}s(t),a({...t,section:"overview",goal:null,conversation_attack:null,conversation_aggregate:null,attempt:null,node:null,goalPage:null})}return{goals:m,filters:r,granularity:l,expanded:i,setExpanded:c,filtering:p,matchingGoals:h,groups:x,categories:g,subcategoryGroups:f,detailLevel:y,changeFilters:w,toggleRow:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];d.current=null!==l,o(null),a({granularity:null}),c(a=>{let r=new Set(a);for(let e of t)r.delete(e);return r.has(e)?r.delete(e):r.add(e),r})},selectGranularity:function(e){o(e),c(new Set("Goals"===e?[...v,...b]:"Subcategories"===e?v:[])),a({granularity:e})},clearFilters:function(){w({search:"",category:[],subcategory:[],outcome:[],attack:[],review:[]}),o(null),a({granularity:null}),c(new Set)}}}(a,s,l),{goals:u,filters:m,granularity:p,expanded:h,setExpanded:v,filtering:b,matchingGoals:j,groups:y,categories:w,subcategoryGroups:N,detailLevel:k,toggleRow:_,selectGranularity:S}=d,C=(0,n.useId)(),A=(0,n.useRef)(null),M=(0,n.useRef)(null),R=(0,n.useMemo)(()=>t.runs.map(e=>{var t;return{run:e,value:(0,g.R)(null!=(t=e.outcomes)?t:void 0)}}).sort((e,t)=>{var a,r;return(null!=(a=t.value)?a:-1)-(null!=(r=e.value)?r:-1)}).map(e=>e.run),[t.runs]),L=(0,n.useMemo)(()=>R.filter(e=>!m.attack.length||m.attack.includes(e.id)),[R,m.attack]),E=(0,n.useMemo)(()=>[{id:"",name:"Combined outcome"},...R.map(e=>({id:e.id,name:(0,x.aN)(e,t.runs),run:e}))],[R,t.runs]),z=E.filter(e=>e.id?!m.attack.length||m.attack.includes(e.id):L.length>1),I=(0,n.useMemo)(()=>new Map(R.map((e,t)=>[e.id,t+1])),[R]),F=e=>d.changeFilters(e),O=function(e,t){var a;let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e,t){var a,r;let n=t.filter(t=>{var a;return(null==e?void 0:e.run_ids.includes(t.id))||(null==e||null==(a=e.attack_outcomes)?void 0:a.some(e=>e.run_id===t.id))});return(null==(a=n.find(t=>e&&"jailbroken"===eN(e,t.id)))?void 0:a.id)||(null==(r=n[0])?void 0:r.id)||""}(e,L)||(null==(a=L[0])?void 0:a.id)||"";r&&(null==o||o(e.index,r,t))},T={minWidth:"".concat(Math.max(450,Math.ceil(44*z.length/.6)),"px")},D=(0,r.jsxs)("colgroup",{children:[(0,r.jsx)("col",{style:{width:"40%"}}),z.map(e=>(0,r.jsx)("col",{},e.id))]}),P=e=>(0,r.jsx)("span",{title:e.id?e.name:"Jailbroken if any selected attack succeeded. With no attack selection, includes every campaign attack.",className:"inline-flex h-5 min-w-5 items-center justify-center rounded-sm bg-muted px-1 text-[11px] font-semibold tabular-nums",children:e.id?I.get(e.id):"Any"}),H=(0,r.jsxs)("tr",{className:"border-b bg-card",children:[(0,r.jsx)("th",{scope:"col",className:"sticky left-0 z-10 bg-card px-3 py-2 text-left",children:"Category / subcategory / goal"}),z.map(e=>(0,r.jsx)("th",{scope:"col",className:"bg-card px-1 py-2 text-center",children:P(e)},e.id))]}),J=(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:"Category / subcategory / goal"}),z.map(e=>(0,r.jsx)("th",{scope:"col",children:e.name},e.id))]}),W=(0,r.jsx)("div",{"aria-hidden":"true",className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:z.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[P(e),(0,r.jsx)("span",{className:"text-foreground",children:e.name})]},e.id))});return i?(0,r.jsx)(r.Fragment,{children:i}):(0,r.jsxs)("div",{className:"relative space-y-4",children:[(0,r.jsx)(eA,{filters:m,categories:w,subcategories:N,attacks:[...R.map(e=>({value:e.id,label:(0,x.aN)(e,t.runs)})),...m.attack.filter(e=>!R.some(t=>t.id===e)).map(e=>({value:e,label:"Unknown attack (".concat(e,")")}))],detailLevel:k,canExpand:y.length>0,filtering:b,reviews:u.some(e=>void 0!==e.reviewed_attempts),radioId:C,searchInput:M,onChange:F,onDetail:S,onClear:d.clearFilters}),(0,r.jsx)(e_,{filters:m,attacks:E.filter(e=>e.id).map(e=>({value:e.id,label:e.name})),onChange:F}),(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:b&&(0,r.jsxs)("span",{role:"status",className:"text-xs text-muted-foreground",children:[j.length," of ",u.length," goals match \xb7 outcome for ",m.attack.length?m.attack.map(e=>{var t,a;return null!=(a=null==(t=E.find(t=>t.id===e))?void 0:t.name)?a:"Unknown attack"}).join(" + "):"all campaign attacks"]})}),W,(0,r.jsx)(eR,{header:(0,r.jsx)("div",{ref:A,"aria-hidden":"true","data-coverage-headings":!0,className:"overflow-hidden border-x",children:(0,r.jsxs)("table",{className:"w-full table-fixed border-collapse text-xs",style:T,children:[D,(0,r.jsx)("thead",{children:H})]})}),children:(0,r.jsx)("div",{role:"region","aria-label":"Scrollable goal coverage",tabIndex:0,className:"overflow-x-auto rounded-md border",onScroll:e=>{A.current&&(A.current.scrollLeft=e.currentTarget.scrollLeft)},children:(0,r.jsxs)("table",{"aria-label":"Goal coverage by subcategory and attack",className:"w-full table-fixed border-collapse text-xs",style:T,children:[D,(0,r.jsx)("thead",{className:"sr-only",children:J}),(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{className:"border-y bg-muted",children:[(0,r.jsxs)("th",{scope:"row",className:"sticky left-0 z-10 bg-muted px-3 py-3 text-left font-bold",children:["All goals ",(0,r.jsxs)("span",{className:"whitespace-nowrap font-normal text-muted-foreground",children:["(",u.length," goals)"]})]}),z.map(e=>(0,r.jsx)("td",{className:"border-l px-0.5 py-2 align-middle",children:(0,r.jsx)(eL,{goals:u,runId:e.id,attacks:m.attack,label:"".concat(e.name," in All goals")})},e.id))]})}),y.map(e=>{let a=JSON.stringify([e.category]),s=h.has(a);return(0,r.jsxs)("tbody",{children:[(0,r.jsxs)("tr",{"data-category":e.category,className:"border-y bg-muted/30",children:[(0,r.jsx)("th",{scope:"row",className:"sticky left-0 z-10 bg-card px-3 py-3 text-left font-semibold",children:(0,r.jsxs)("button",{type:"button","aria-expanded":s,"aria-label":"Toggle ".concat(e.category),onClick:()=>_(a,e.subcategories.map(t=>{let[a]=t;return JSON.stringify([e.category,a])})),className:"flex w-full items-center gap-1 text-left",children:[s?(0,r.jsx)(X.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}):(0,r.jsx)(Q.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}),(0,r.jsxs)("span",{children:[e.category," ",(0,r.jsxs)("span",{className:"whitespace-nowrap font-normal text-muted-foreground",children:["(",e.subcategories.reduce((e,t)=>{let[,a]=t;return e+a.length},0)," goals)"]})]})]})}),z.map(t=>(0,r.jsx)("td",{className:"border-l px-0.5 py-2 align-middle",children:(0,r.jsx)(eL,{goals:e.subcategories.flatMap(e=>{let[,t]=e;return t}),runId:t.id,attacks:m.attack,label:"".concat(t.name," in ").concat(e.category)})},t.id))]}),s&&e.subcategories.map(a=>{let[s,l]=a,i=JSON.stringify([e.category,s]),d=h.has(i);return(0,r.jsxs)(n.Fragment,{children:[(0,r.jsxs)("tr",{"data-category":e.category,"data-subcategory":s,className:"border-b bg-muted/10",children:[(0,r.jsx)("th",{scope:"row",className:"sticky left-0 z-10 bg-card py-2 pl-6 pr-3 text-left font-medium",children:(0,r.jsxs)("button",{type:"button","aria-expanded":d,"aria-label":"Toggle ".concat(e.category," / ").concat(s),onClick:()=>_(i),className:"flex w-full items-center gap-1 text-left",children:[d?(0,r.jsx)(X.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}):(0,r.jsx)(Q.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}),(0,r.jsxs)("span",{children:[s," ",(0,r.jsxs)("span",{className:"whitespace-nowrap text-muted-foreground",children:["(",l.length," goals)"]})]})]})}),z.map(t=>(0,r.jsx)("td",{className:"border-l px-0.5 py-2 align-middle",children:(0,r.jsx)(eL,{goals:l,runId:t.id,attacks:m.attack,label:"".concat(t.name," in ").concat(e.category," / ").concat(s)})},t.id))]}),d&&l.map(e=>(0,r.jsxs)("tr",{"data-goal-row":e.index,className:"border-b hover:bg-muted/20 ".concat(c?"cursor-pointer":""),onClick:c?t=>{var a,r;t.target.closest("a,button")||(null==(a=window.getSelection())?void 0:a.type)==="Range"||O(e,null!=(r=t.currentTarget.querySelector("button"))?r:void 0)}:void 0,children:[(0,r.jsx)("th",{scope:"row",className:"sticky left-0 z-10 bg-card py-3 pl-10 pr-3 text-left font-normal text-muted-foreground",children:(0,r.jsxs)("span",{className:"flex items-baseline gap-2",children:[(0,r.jsxs)("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:["#",e.index+1]}),c?(0,r.jsx)("button",{type:"button",className:"min-w-0 whitespace-pre-wrap break-words text-left",title:"Open this goal's attempts and conversations",onClick:t=>O(e,t.currentTarget),children:e.goal}):(0,r.jsx)("span",{className:"min-w-0 whitespace-pre-wrap break-words",children:e.goal})]})}),z.map(a=>{let n=a.id?eN(e,a.id):ek(e,m.attack),s=(0,r.jsx)("span",{"aria-hidden":"true",className:"block h-3.5 w-3.5 rounded-[1px] ".concat("untested"===n?"border border-dashed border-muted-foreground":""),style:{backgroundColor:eM[n]}});return(0,r.jsx)("td",{className:"border-l px-0.5 py-1 text-center",children:a.id&&c?(0,r.jsx)("a",{"data-goal":e.index,"data-run":a.id,onClick:t=>{0!==t.button||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||(t.preventDefault(),null==o||o(e.index,a.id,t.currentTarget))},href:"/stats?".concat(function(e){let t=new URLSearchParams;for(let[a,r]of Object.entries(e))for(let e of Array.isArray(r)?r:[r])e&&t.append(a,e);return t}({run:t.id,section:"overview",...m,...p?{granularity:p}:{},goal:String(e.index),conversation_attack:a.id})),"aria-label":"Goal ".concat(e.index+1," \xb7 ").concat(a.name,": ").concat(n),"aria-describedby":C,title:"".concat(a.name,"\n\nOutcome: ").concat("untested"===n?"Not tested":n,"\nSelect to open this goal's conversation."),className:"inline-flex h-8 w-8 items-center justify-center rounded outline-offset-2 hover:bg-muted focus-visible:outline-2",children:s}):(0,r.jsx)("span",{role:"img","aria-label":"Goal ".concat(e.index+1," \xb7 ").concat(a.name,": ").concat(n),tabIndex:c?void 0:0,title:"".concat(a.name,"\n\nOutcome: ").concat("untested"===n?"Not tested":n),className:"inline-flex h-8 w-8 items-center justify-center",children:s})},a.id)})]},e.index))]},s)})]},e.category)})]})})}),c&&(0,r.jsx)("span",{id:C,className:"sr-only",children:"Open conversation"}),!j.length&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No recorded goals match these filters."}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["ASR = jailbroken / recorded goals, including unresolved and errors. Untested (–) is excluded, not counted as mitigated. Hover or focus a percentage for exact counts. Set the table detail level or expand individual rows. ",c?"Select an individual attack marker to open its conversation.":"Conversations are excluded from this offline snapshot."," Combined outcome is informational only."]}),(0,r.jsx)(f.s$,{items:[{name:"Jailbroken",color:eM.jailbroken},{name:"Mitigated",color:eM.mitigated},{name:"Unresolved",color:eM.unresolved},{name:"Error",color:eM.error},{name:"Not tested",color:eM.untested}]})]})}let eI=[];function eF(e){var t,a,s;let{campaign:l,revision:c,onOpenGoal:d}=e,u=(0,o.useSearchParams)(),m=(0,x.LI)("".concat(x.dI,"/").concat(l.id,"/matrix"),c,void 0,{version:l.revision}),p=(0,n.useMemo)(()=>{if(!m.data)return null;try{return{goals:(0,x.UK)(m.data),error:null}}catch(e){return{goals:eI,error:e instanceof Error?e.message:"The goal matrix could not be read."}}},[m.data]),h=(0,n.useRef)(null);p&&(h.current={id:l.id,goals:p.goals});let g=(null==(t=h.current)?void 0:t.id)===l.id?h.current.goals:eI,f=null!=(a=m.error)?a:null==p?void 0:p.error,v=f?(0,r.jsx)("p",{role:"alert",className:"text-sm text-muted-foreground",children:f}):m.data?null:(0,r.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Loading goals…"]});return(0,r.jsx)(ez,{campaign:l,recordedGoals:g,status:v,query:null!=(s=null==u?void 0:u.toString())?s:"",onSelectionChange:x.gj,onOpenGoal:d})}let eO=(0,d.A)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);var eT=a(6191);let eD=(0,d.A)("focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);var eP=a(77274),eH=a(81701);let eJ=e=>e.join("."),eW=e=>Array.isArray(e)&&e.every(e=>Number.isSafeInteger(e)&&e>=0);function eU(e){var t;return{id:"attempt:".concat(e.id),parent:null,label:"Attempt ".concat(e.ordinal),kind:"attempt",status:e.bucket,score:"number"==typeof(null==(t=e.metadata)?void 0:t.score)?e.metadata.score:null,attemptId:e.id}}function eG(e){let t=Array.from(new Map(e.map(e=>[e.id,e])).values()),a=new Map(t.map(e=>[e.id,e]));return t.map(e=>{let t=e.parent,r=new Set([e.id]);for(;t&&a.has(t);){var n,s;if(r.has(t))return{...e,parent:null};r.add(t),t=null!=(s=null==(n=a.get(t))?void 0:n.parent)?s:null}return{...e,parent:e.parent&&a.has(e.parent)?e.parent:null}})}function e$(e){let{nodes:t,selectedId:a,onSelect:s,kind:l,simple:o=!1}=e,[i,c]=(0,n.useState)(1),[d,u]=(0,n.useState)(!1),m=(0,n.useRef)(null),p=(0,n.useMemo)(()=>(function(e){var t,a;let r=new Map;for(let a of e)r.set(a.parent,[...null!=(t=r.get(a.parent))?t:[],a]);let n=0,s=new Map,l=(e,t)=>{var a;let o=(null!=(a=r.get(e.id))?a:[]).map(e=>l(e,t+1)),i=o.length?(o[0]+o[o.length-1])/2:104*n+++24;return s.set(e.id,{x:230*t+24,y:i}),i};for(let e of null!=(a=r.get(null))?a:[])l(e,0);return{positions:s,width:Math.max(280,...Array.from(s.values()).map(e=>e.x+216)),height:Math.max(220,104*n+40)}})(t),[t]);(0,n.useEffect)(()=>{var e;let t=null==(e=m.current)?void 0:e.clientWidth;t&&c(Math.max(.35,Math.min(1,(t-16)/p.width)))},[p.width]);let x=new Set,g=new Map(t.map(e=>[e.id,e]));for(let e of t.filter(e=>"jailbreak"===e.status)){let t=e;for(;t&&!x.has(t.id);)x.add(t.id),t=t.parent?g.get(t.parent):void 0}return(0,n.useEffect)(()=>{var e;let t=null==(e=m.current)?void 0:e.querySelector('[aria-pressed="true"]'),a=m.current;if(!t||!a)return;let r=t.getBoundingClientRect(),n=a.getBoundingClientRect();(r.left<n.left||r.right>n.right)&&(a.scrollLeft+=r.left-n.left-16),(r.top<n.top||r.bottom>n.bottom)&&(a.scrollTop+=r.top-n.top-16)},[a,d]),(0,r.jsxs)("section",{className:"investigation-panel min-w-0 overflow-hidden","aria-label":"Attack map",children:[(0,r.jsxs)("header",{className:"flex flex-wrap items-center justify-between gap-2 border-b bg-muted/40 p-4",children:[!o&&(0,r.jsx)("h3",{className:"font-semibold",children:o?"Attack branches":"candidates"===l?"Candidate tree":"execution"===l?"Recorded execution tree":"Independent attempts"}),(0,r.jsx)(h.$,{size:"sm",variant:"outline","aria-pressed":d,onClick:()=>u(e=>!e),children:d?"Show map":"Show list"})]}),(0,r.jsx)("p",{className:"border-b px-4 py-3 text-xs text-muted-foreground",children:o?"Select an attempt to jump to its conversation. Rose lines lead to a jailbreak.":"candidates"===l?"Lines connect recorded parent candidates. Rose outlines mark paths to jailbreaks; blue marks your selection.":"execution"===l?"Lines show recorded phase containment, not candidate ancestry. Older recordings do not identify candidate parents.":"Candidate relationships were not recorded. Attempts are shown independently, never linked by guesswork."}),!d&&(0,r.jsxs)("div",{className:"flex items-center gap-1 border-b px-3 py-2",children:[(0,r.jsx)(h.$,{variant:"ghost",size:"icon","aria-label":"Zoom out",disabled:i<=.35,onClick:()=>c(e=>Math.max(.35,e-.15)),children:(0,r.jsx)(eO,{className:"h-4 w-4"})}),(0,r.jsxs)("span",{className:"w-12 text-center text-xs tabular-nums",children:[Math.round(100*i),"%"]}),(0,r.jsx)(h.$,{variant:"ghost",size:"icon","aria-label":"Zoom in",disabled:i>=1.6,onClick:()=>c(e=>Math.min(1.6,e+.15)),children:(0,r.jsx)(eT.A,{className:"h-4 w-4"})}),(0,r.jsxs)(h.$,{variant:"ghost",size:"sm",onClick:()=>{var e,t;return c(Math.max(.35,Math.min(1,((null!=(t=null==(e=m.current)?void 0:e.clientWidth)?t:600)-16)/p.width)))},children:[(0,r.jsx)(eD,{className:"mr-1 h-4 w-4"}),"Fit tree"]})]}),(0,r.jsxs)("div",{ref:m,className:"attack-map-canvas max-h-[65vh] min-h-72 overflow-auto p-2 ".concat(d?"space-y-2":""),tabIndex:0,"aria-label":"Scrollable attack map",children:[!t.length&&(0,r.jsx)("p",{className:"p-5 text-sm text-muted-foreground",children:"No recorded attempts yet."}),(0,r.jsx)("div",{style:d?void 0:{width:p.width*i,height:p.height*i,position:"relative"},children:(0,r.jsxs)("div",{className:d?"space-y-2":"relative origin-top-left",style:d?void 0:{width:p.width,height:p.height,transform:"scale(".concat(i,")")},children:[!d&&(0,r.jsx)("svg",{className:"pointer-events-none absolute inset-0",width:p.width,height:p.height,"aria-hidden":"true",children:t.filter(e=>e.parent).map(e=>{let t=e.parent?p.positions.get(e.parent):void 0,a=p.positions.get(e.id);return t&&a?(0,r.jsx)("path",{d:"M ".concat(t.x+196," ").concat(t.y+35," C ").concat(t.x+214," ").concat(t.y+35,", ").concat(a.x-18," ").concat(a.y+35,", ").concat(a.x," ").concat(a.y+35),fill:"none",stroke:x.has(e.id)?"var(--map-path)":"var(--map-edge)",strokeWidth:x.has(e.id)?3:2},e.id):null})}),t.map(e=>{let t=p.positions.get(e.id);return(0,r.jsxs)("button",{"aria-pressed":e.id===a,onClick:()=>s(e),className:"map-node text-left ".concat(d?"w-full":"absolute w-[196px]"," ").concat(e.id===a?"map-node-selected":""," ").concat(x.has(e.id)?"map-node-success":""),style:d?void 0:{left:null==t?void 0:t.x,top:null==t?void 0:t.y},"aria-label":"".concat(e.label).concat(e.status?": ".concat(e.status):""),children:[(0,r.jsx)("span",{className:"block truncate text-sm font-semibold",title:e.label,children:e.label}),(0,r.jsxs)("span",{className:"mt-2 flex flex-wrap items-center gap-1",children:[e.status&&(0,r.jsx)(eP.c,{value:e.status}),!o&&e.disposition&&e.disposition!==e.status&&(0,r.jsx)(eP.c,{value:e.disposition}),!o&&null!==e.score&&(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Raw score ",e.score]})]}),!e.status&&!o&&(0,r.jsx)("span",{className:"mt-1 block text-xs text-muted-foreground",children:"candidate"===e.kind?"No judged result":e.kind})]},e.id)})]})})]})]})}var eq=a(68448),eB=a(77148);function eK(e){let{attempts:t,activeAttempt:a,onSelect:s,label:l="Attempt timeline",className:o="",actionLabel:i}=e;return(0,r.jsx)("div",{role:"group","aria-label":l,className:"flex min-w-0 flex-wrap gap-1.5 ".concat(o),children:t.map(e=>{var t,l,o;let c="jailbreak"===e.bucket?"Jailbroken":"mitigated"===e.bucket?"Mitigated":"error"===e.bucket?"Error":"Pending",d=(0,r.jsxs)("button",{type:"button",onClick:()=>s(e.id),"aria-label":null!=(o=null==i?void 0:i(e))?o:"Go to attempt ".concat(e.ordinal,": ").concat("jailbreak"===e.bucket?"jailbroken":e.bucket),"aria-pressed":a===e.id,"aria-current":a===e.id?"step":void 0,className:"inline-flex h-7 min-w-7 shrink-0 items-center justify-center rounded-md border px-1 text-xs font-semibold tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground focus-visible:ring-offset-2\n ".concat("jailbreak"===e.bucket?"border-rose-200 bg-rose-50 text-rose-800 hover:bg-rose-100 dark:border-rose-700 dark:bg-rose-950 dark:text-rose-200 dark:hover:bg-rose-900":"mitigated"===e.bucket?"border-teal-200 bg-teal-50 text-teal-800 hover:bg-teal-100 dark:border-teal-700 dark:bg-teal-950 dark:text-teal-200 dark:hover:bg-teal-900":"border-amber-200 bg-amber-50 text-amber-900 hover:bg-amber-100 dark:border-amber-600 dark:bg-amber-950 dark:text-amber-200 dark:hover:bg-amber-900","\n ").concat(a===e.id?"ring-2 ring-foreground ring-offset-2 ring-offset-background":""),children:[e.ordinal,!i&&(null==(t=e.human_review)?void 0:t.outcome)!=null&&(0,r.jsx)("span",{"aria-label":"Human reviewed",className:"ml-1",children:"✓"})]});return i?(0,r.jsx)(n.Fragment,{children:d},e.id):(0,r.jsxs)(y.m_,{children:[(0,r.jsx)(y.k$,{asChild:!0,children:d}),(0,r.jsxs)(y.ZI,{sideOffset:6,className:"max-w-64 space-y-1 px-3 py-2 text-left leading-relaxed",children:[(0,r.jsxs)("p",{className:"font-semibold",children:["Attempt ",e.ordinal," \xb7 ",c]}),(0,r.jsxs)("p",{children:[(null==(l=e.human_review)?void 0:l.outcome)!=null?"Human reviewed. ":"","Select to jump to this conversation."]})]})]},e.id)})})}var eV=a(78874),eZ=a(61362),eY=a(80021);let eQ={jailbreak:"Jailbroken",mitigated:"Mitigated",inconclusive:"Inconclusive"},eX=[{value:"jailbreak",label:"Jailbroken",icon:eV.A,tone:"text-rose-700 dark:text-rose-300",hover:"hover:border-rose-300 hover:bg-rose-50 dark:hover:bg-rose-950",selected:"border-rose-400 bg-rose-50 text-rose-900 dark:border-rose-600 dark:bg-rose-950 dark:text-rose-100"},{value:"mitigated",label:"Mitigated",icon:eZ.A,tone:"text-teal-700 dark:text-teal-300",hover:"hover:border-teal-300 hover:bg-teal-50 dark:hover:bg-teal-950",selected:"border-teal-400 bg-teal-50 text-teal-900 dark:border-teal-600 dark:bg-teal-950 dark:text-teal-100"},{value:"inconclusive",label:"Inconclusive",icon:eY.A,tone:"text-amber-700 dark:text-amber-300",hover:"hover:border-amber-300 hover:bg-amber-50 dark:hover:bg-amber-950",selected:"border-amber-400 bg-amber-50 text-amber-900 dark:border-amber-600 dark:bg-amber-950 dark:text-amber-100"}];function e0(e){let{review:t}=e;return t.error?(0,r.jsxs)("div",{role:"alert",className:"space-y-2",children:[(0,r.jsx)("p",{children:t.error}),(0,r.jsx)(h.$,{type:"button",variant:"outline",onClick:()=>void t.reload(),children:"Reload review"})]}):null}function e1(e){let{review:t}=e,{history:a}=t;return t.showHistory?(0,r.jsx)("section",{"aria-label":"Review history",className:"space-y-3 border-t pt-3",children:a.error?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{role:"alert",children:a.error}),(0,r.jsx)(h.$,{variant:"outline",onClick:t.retryHistory,children:"Retry history"})]}):a.data?a.data.results.length?(0,r.jsx)("ol",{className:"space-y-3",children:a.data.results.map(e=>(0,r.jsxs)("li",{className:"space-y-1",children:[(0,r.jsxs)("p",{className:"font-medium",children:[e.outcome?eQ[e.outcome]:"Withdrawn"," \xb7 ",e.reviewer," \xb7 ",(0,r.jsx)("time",{dateTime:e.created_at,children:new Date(e.created_at).toLocaleString()})]}),e.explanation&&(0,r.jsx)("p",{className:"whitespace-pre-wrap break-words",children:e.explanation})]},e.id))}):(0,r.jsx)("p",{children:"No human reviews yet."}):(0,r.jsx)("p",{role:"status",children:"Loading review history…"})}):null}function e2(e){var t;let{attempt:a,onDone:s}=e,l=function(e){var t;let[a,r]=(0,n.useState)(e.human_review),s=(null==a?void 0:a.outcome)!=null,[l,o]=(0,n.useState)(null!=(t=null==a?void 0:a.outcome)?t:""),[i,c]=(0,n.useState)(s?a.explanation:""),[d,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(null),[h,g]=(0,n.useState)(!1),[f,v]=(0,n.useState)(0),[b,j]=(0,n.useState)(!1);(0,n.useEffect)(()=>{r(e.human_review)},[e.human_review]);let y=(0,x.VP)(e.id),w=(0,x.LI)(h?y:null,f),N=async(t,n)=>{u(!0),p(null),j(!1);try{var s,l;let c=await (0,x.Kn)(e.id,t,i,null!=(s=null==a?void 0:a.id)?s:null);r(c),o(null!=(l=c.outcome)?l:""),j(!0),v(e=>e+1),null==n||n(c)}catch(e){p(e instanceof Error?e.message:"Could not save review.")}finally{u(!1)}},k=async()=>{try{var e,t,a;let n=null!=(e=(await (0,x.Ld)(y,new AbortController().signal)).results[0])?e:null;r(n),o(null!=(t=null==n?void 0:n.outcome)?t:""),c(null!=(a=null==n?void 0:n.explanation)?a:""),p(null),v(e=>e+1)}catch(e){p(e instanceof Error?e.message:"Could not reload review.")}};return{latest:a,active:s,outcome:l,setOutcome:o,explanation:i,setExplanation:c,saving:d,error:m,saved:b,setSaved:j,showHistory:h,toggleHistory:()=>g(e=>!e),history:w,retryHistory:()=>v(e=>e+1),save:N,discard:()=>{var e,t;o(null!=(e=null==a?void 0:a.outcome)?e:""),c(null!=(t=null==a?void 0:a.explanation)?t:""),p(null)},reload:k}}(a),{latest:o,active:i,saving:c}=l,d=i&&null!=(t=null==o?void 0:o.outcome)?t:null;return(0,r.jsxs)("section",{"aria-label":"Human attempt review",className:"space-y-3 text-sm",children:[(0,r.jsxs)("label",{className:"block space-y-1",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Explanation (optional)"}),(0,r.jsx)("textarea",{className:"block w-full rounded-md border bg-card p-2 text-sm",rows:2,value:l.explanation,disabled:c,placeholder:"Saved with your review",onChange:e=>l.setExplanation(e.target.value)})]}),(0,r.jsx)("div",{role:"group","aria-label":"Human verdict",className:"grid grid-cols-3 gap-2",children:eX.map(e=>{let t=e.icon,a=d===e.value;return(0,r.jsxs)("button",{type:"button",disabled:c,"aria-pressed":a,onClick:()=>{a||(l.setOutcome(e.value),l.save(e.value,s))},className:"flex flex-col items-center gap-1 rounded-md border px-2 py-2.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground disabled:opacity-60 ".concat(a?e.selected:e.hover),children:[(0,r.jsx)(t,{"aria-hidden":"true",className:"h-5 w-5 ".concat(a?"":e.tone)}),e.label]},e.value)})}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t pt-2 text-xs text-muted-foreground",children:[(0,r.jsx)("p",{role:"status",children:c?"Saving…":o?"".concat(i?"Reviewed":"Withdrawn"," by ").concat(o.reviewer," \xb7 ").concat(new Date(o.created_at).toLocaleString()):"Choosing a verdict saves it."}),(0,r.jsxs)("div",{className:"flex gap-1",children:[i&&(0,r.jsx)(h.$,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",disabled:c,onClick:()=>void l.save(null,s),children:"Withdraw"}),(0,r.jsx)(h.$,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:l.toggleHistory,children:l.showHistory?"Hide history":"History"})]})]}),(0,r.jsx)(e0,{review:l}),(0,r.jsx)(e1,{review:l})]})}function e5(e){var t,a;let{attempt:s,name:l,panel:o,onOpen:i}=e,[c,d]=(0,n.useState)(!1),[u,m]=(0,n.useState)(null);(0,n.useEffect)(()=>{m(null)},[s.human_review]);let p=u?{...s,human_review:u}:s,h=null!=(a=null==(t=p.human_review)?void 0:t.outcome)?a:null;if(!("human_review"in s))return(0,r.jsx)("span",{"aria-label":"Reviews are not recorded",className:"text-xs text-muted-foreground",children:"—"});let x="".concat(l," attempt ").concat(p.ordinal);return(0,r.jsxs)(S.AM,{open:c,onOpenChange:d,children:[(0,r.jsx)(S.Wv,{asChild:!0,children:(0,r.jsxs)("button",{type:"button",onClick:i,"aria-label":"Human review for ".concat(x,": ").concat(null!=h?h:"not reviewed"),className:"inline-flex h-7 items-center gap-1 rounded-md text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground ".concat(null!==h?"pl-0.5 pr-1 hover:bg-muted":"border bg-background px-2 text-foreground shadow-xs hover:bg-muted"," ").concat(c?"bg-muted":""),children:[null!==h?(0,r.jsx)(eP.c,{value:h}):"Review",(0,r.jsx)(X.A,{"aria-hidden":"true",className:"h-3.5 w-3.5 text-muted-foreground transition-transform ".concat(c?"rotate-180":"")})]})}),(0,r.jsxs)(S.hl,{align:"end","aria-label":"Human review for ".concat(x),className:"w-[min(22rem,calc(100vw-2rem))] space-y-3",children:[(0,r.jsxs)("header",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"section-eyebrow",children:"Human review"}),(0,r.jsx)("h3",{className:"text-sm font-semibold",children:x}),(0,r.jsxs)("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:["The panel said ",(0,r.jsx)(eP.c,{value:o})]})]}),(0,r.jsx)(e2,{attempt:p,onDone:e=>{m(e),d(!1)}},p.id)]})]})}function e3(e,t){var a;let r=null!=(a=e.evaluation_metrics)?a:{},n=r[t],s=Object.prototype.hasOwnProperty.call(r,t)?null===n?"abstained":1===n||!0===n?"jailbreak":0===n||!1===n?"mitigated":"invalid":"missing",l=r["explanation_".concat(t.slice(5))];return{state:s,explanation:"string"==typeof l?l:null}}function e4(e){let{attempt:t,judge:a}=e,{state:n}=e3(t,a),s={jailbreak:"Jailbroken",mitigated:"Mitigated",abstained:"Abstained",invalid:"Invalid vote",missing:"No recorded vote"}[n];if("missing"===n)return(0,r.jsx)("span",{role:"img","aria-label":s,className:"w-4 text-center text-muted-foreground",children:"—"});let l="jailbreak"===n?eV.A:"mitigated"===n?eZ.A:eY.A;return(0,r.jsx)("span",{role:"img","aria-label":s,title:s,className:"mt-0.5 shrink-0 ".concat("jailbreak"===n?"text-rose-600 dark:text-rose-300":"mitigated"===n?"text-teal-600 dark:text-teal-300":"text-muted-foreground"),children:(0,r.jsx)(l,{"aria-hidden":"true",className:"h-4 w-4"})})}function e6(e){let{attempt:t,judges:a,label:n}=e;return(0,r.jsxs)("section",{"aria-label":"Judge explanations",className:"space-y-3",children:[!a.length&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Per-judge votes were not recorded for this attempt."}),a.map(e=>{let a=e3(t,e);return(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,r.jsx)(e4,{attempt:t,judge:e}),(0,r.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,r.jsx)("p",{className:"break-all font-medium",children:n(e)}),a.explanation?(0,r.jsx)(eq.P,{content:a.explanation,className:"text-muted-foreground"}):(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"missing"===a.state?"No vote or explanation was recorded.":"No explanation was recorded."})]})]},e)})]})}let e8={jailbreak:f.Md.jailbroken,mitigated:"color-mix(in srgb, var(--viz-mitigated) 38%, var(--card))",abstained:f.Md.error,invalid:f.Md.error,missing:"transparent"},e7={jailbreak:"Jailbroken",mitigated:"Mitigated",abstained:"Abstained",invalid:"Invalid vote",missing:"No recorded vote"};function e9(e){let{attempt:t,columns:a,label:n}=e;return(0,r.jsx)("span",{role:"group","aria-label":"Judge votes",className:"inline-flex items-center gap-1",children:a.map(e=>{let a=e3(t,e).state,s="".concat(n(e),": ").concat(e7[a]);return(0,r.jsx)("span",{role:"img","aria-label":s,title:s,className:"block h-3.5 w-3.5 rounded-[3px] ".concat("missing"===a?"border border-dashed border-muted-foreground":""),style:{backgroundColor:e8[a]}},e)})})}function te(e){let{columns:t,label:a}=e;return(0,r.jsxs)("div",{className:"space-y-2 text-xs",children:[(0,r.jsx)("p",{className:"font-semibold uppercase tracking-wide text-muted-foreground",children:"Judges, left to right"}),(0,r.jsx)("ol",{className:"space-y-0.5",children:t.map((e,t)=>(0,r.jsxs)("li",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"w-3 shrink-0 tabular-nums text-muted-foreground",children:t+1}),(0,r.jsx)("span",{className:"min-w-0 break-all",children:a(e)})]},e))}),(0,r.jsx)(f.s$,{items:[{name:"Jailbroken",color:e8.jailbreak},{name:"Mitigated",color:e8.mitigated},{name:"No vote",color:e8.abstained},{name:"Not recorded",color:"var(--muted)"}]})]})}function tt(e){let{group:t,name:a,columns:n,judgeLabel:s,active:l,limit:o,onSelect:i,onMore:c}=e,{run:d,attempts:u}=t,m=u.filter(e=>{var t;return(null==(t=e.human_review)?void 0:t.outcome)!=null}).length,p=u.slice(0,o),x="border-b px-3 py-2 text-left text-xs font-medium text-muted-foreground";return(0,r.jsxs)("table",{"aria-label":"".concat(a," attempts"),className:"w-full table-fixed border-separate border-spacing-0 text-sm",children:[(0,r.jsxs)("colgroup",{children:[(0,r.jsx)("col",{className:"w-16"}),(0,r.jsx)("col",{}),(0,r.jsx)("col",{className:"w-32"})]}),(0,r.jsx)("caption",{className:"border-b bg-muted/40 px-3 py-2.5 text-left",children:(0,r.jsxs)("span",{className:"inline-flex flex-wrap items-center gap-x-2",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"inline-flex h-5 min-w-5 items-center justify-center rounded-sm bg-muted px-1 text-[11px] font-semibold tabular-nums",children:t.number}),(0,r.jsx)("span",{className:"font-semibold",children:a}),(0,r.jsx)("span",{className:"text-xs font-normal text-muted-foreground",children:u.length?"".concat(u.length," ").concat(1===u.length?"attempt":"attempts"," \xb7 ").concat(m," reviewed"):"Not tested"})]})}),u.length>0&&(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"".concat(x," border-l-4 border-l-transparent"),children:"Attempt"}),(0,r.jsx)("th",{scope:"col",className:x,children:(0,r.jsxs)("span",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"w-[6.75rem]",children:"Panel"}),n.length>0&&(0,r.jsx)("span",{"aria-hidden":"true",className:"inline-flex gap-1",children:n.map((e,t)=>(0,r.jsx)("span",{title:s(e),className:"w-3.5 text-center text-[10px] tabular-nums",children:t+1},e))})]})}),(0,r.jsx)("th",{scope:"col",className:x,children:"Human"})]})}),(0,r.jsxs)("tbody",{children:[p.map(e=>{var t;let o=(null==l?void 0:l.run)===d.id&&l.id===e.id,c=null!=(t=e.automated_bucket)?t:e.bucket;return(0,r.jsxs)("tr",{"data-attempt-row":"".concat(d.id,":").concat(e.id),"aria-label":"".concat(a," attempt ").concat(e.ordinal),"aria-current":o?"true":void 0,className:"cursor-pointer transition-colors ".concat(o?"bg-blue-50 dark:bg-slate-700":"hover:bg-muted/40"),onClick:t=>{t.target.closest("button")||i(d.id,e.id)},children:[(0,r.jsx)("th",{scope:"row",className:"border-b border-l-4 px-3 py-2.5 text-left align-middle ".concat(o?"border-l-blue-600 dark:border-l-blue-400":"border-l-transparent"),children:(0,r.jsx)(eK,{label:"".concat(a," attempt ").concat(e.ordinal),attempts:[e],activeAttempt:null,actionLabel:()=>"Show ".concat(a," attempt ").concat(e.ordinal),onSelect:()=>i(d.id,e.id)})}),(0,r.jsx)("td",{className:"border-b px-3 py-2.5 align-middle",children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"flex w-[6.75rem] shrink-0",children:(0,r.jsx)(eP.c,{value:c})}),(0,r.jsx)(e9,{attempt:e,columns:n,label:s})]})}),(0,r.jsx)("td",{className:"border-b px-3 py-2.5 align-middle",children:(0,r.jsx)(e5,{attempt:e,name:a,panel:c,onOpen:()=>i(d.id,e.id)})})]},e.id)}),u.length>p.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:3,className:"p-2",children:(0,r.jsxs)(h.$,{size:"sm",variant:"outline",onClick:c,children:["Show more ",a," attempts (",u.length-p.length," remaining)"]})})})]})]})}function ta(e){let{campaign:t,groups:a,columns:s,judgeLabel:l,active:o,onSelect:i}=e,[c,d]=(0,n.useState)({}),u=(0,n.useRef)(null);return(0,r.jsx)("div",{ref:u,role:"group","aria-label":"Attempts and judge votes",onKeyDown:e=>{var t;(null==(t=u.current)?void 0:t.contains(e.target))&&("ArrowDown"===e.key||"ArrowUp"===e.key)&&(e.preventDefault(),(e=>{let t=a.flatMap(e=>{var t;return e.attempts.slice(0,null!=(t=c[e.run.id])?t:50).map(t=>({run:e.run.id,id:t.id}))}),r=t.findIndex(e=>e.run===(null==o?void 0:o.run)&&e.id===o.id),n=t[Math.min(t.length-1,Math.max(0,r<0?0:r+e))];n&&(i(n.run,n.id),requestAnimationFrame(()=>{var e,t;return null==(t=u.current)||null==(e=t.querySelector('[data-attempt-row="'.concat(n.run,":").concat(n.id,'"] button')))?void 0:e.focus()}))})("ArrowDown"===e.key?1:-1))},children:a.map(e=>{var a;return(0,r.jsx)(tt,{group:e,name:(0,x.aN)(e.run,t.runs),columns:s,judgeLabel:l,active:o,limit:null!=(a=c[e.run.id])?a:50,onSelect:i,onMore:()=>d(t=>{var a;return{...t,[e.run.id]:(null!=(a=t[e.run.id])?a:50)+50}})},e.run.id)})})}var tr=a(40998),tn=a(37272);function ts(e){let{error:t,retry:a,children:n}=e;return t?(0,r.jsxs)("div",{role:"alert",className:"space-y-2 p-4 text-sm",children:[(0,r.jsx)("p",{children:t}),a&&(0,r.jsx)(h.$,{size:"sm",variant:"outline",onClick:a,children:"Retry"})]}):(0,r.jsx)("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:n})}function tl(e){let{label:t,headerLabel:a,eyebrow:n,title:s,titleId:l,description:o,bodyClassName:i="",footer:c,children:d}=e;return(0,r.jsxs)("section",{"aria-label":t,className:"investigation-panel flex min-h-0 min-w-0 max-h-[75dvh] flex-col overflow-hidden lg:max-h-none",children:[(0,r.jsxs)("header",{"aria-label":a,className:"shrink-0 border-b px-5 py-4",children:[(0,r.jsx)("p",{className:"section-eyebrow",children:n}),(0,r.jsx)(l?"h2":"h3",{id:l,className:"mt-1.5 whitespace-pre-wrap break-words text-lg font-semibold",children:s}),o&&(0,r.jsx)("div",{className:"mt-1 text-sm text-muted-foreground",children:o})]}),(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain ".concat(i),children:d}),c&&(0,r.jsx)("footer",{className:"max-h-[40%] shrink-0 overflow-y-auto border-t bg-muted/20 px-5 py-3",children:c})]})}function to(e){var t,a,s,o,i,c,d,u,m;let{campaign:p,revision:h,goalIndex:g,run:f,attempt:v,onBack:b}=e,j=(0,n.useId)(),y=(0,n.useRef)(null),w=(0,n.useRef)(null),[N,k]=(0,n.useState)(0),[_,S]=(0,n.useState)({run:null!=f?f:"",id:v}),[C,A]=(0,n.useState)(null),[M,R]=(0,n.useState)(null),L={version:p.revision},E=(0,x.LI)("".concat(x.dI,"/").concat(p.id,"/goals?goal_index=").concat(g),h+N,void 0,L),z=(0,x.LI)("".concat(x.dI,"/").concat(p.id,"/attempts?goal_index=").concat(g),h+N,x.t$,L),I=null==(t=E.data)?void 0:t.results[0],F=(0,n.useMemo)(()=>G(p),[p]),O=(0,n.useMemo)(()=>(0,tr.aA)(p).map((e,t)=>{var a,r;let n=(null!=(r=null==(a=z.data)?void 0:a.results)?r:[]).filter(t=>t.run_id===e.id).map((e,t)=>({...e,ordinal:t+1})),s=W(e.configuration);return{run:e,number:t+1,attempts:n,judges:Array.from(new Set([...s.length?s:W(p.configuration),...Array.from(new Set(n.flatMap(e=>{var t;return Object.keys(null!=(t=e.evaluation_metrics)?t:{}).filter(e=>e.startsWith("eval_")&&!e.endsWith("_mean"))}))).sort()]))}}),[p,z.data]),T=(0,n.useMemo)(()=>Array.from(new Set(O.flatMap(e=>e.judges))).sort(),[O]),D=!_.run||p.runs.some(e=>e.id===_.run),P=(0,n.useMemo)(()=>{var e,t,a;if(!D)return null;let r=O.flatMap(e=>e.attempts.map(t=>({group:e,attempt:t})));return _.run?null!=(a=null!=(t=r.find(e=>e.group.run.id===_.run&&e.attempt.id===_.id))?t:r.find(e=>e.group.run.id===_.run))?a:null:null!=(e=r[0])?e:null},[O,_,D]),H=p.runs.find(e=>e.id===_.run),J=null==P?void 0:P.group.run.id,U=(0,x.LI)(J?"".concat(x.dI,"/").concat(p.id,"/structure?").concat(new URLSearchParams({run_id:J,goal_index:String(g)})):null,h+N,void 0,L),$=null==P?void 0:P.attempt.id,q=(0,n.useMemo)(()=>{var e;let t=null==(e=U.data)?void 0:e.attempts.find(e=>e.id===$);return U.data&&t?(0,tn.y)({...U.data,attempts:[t]})[0]:null},[U.data,$]),B=(0,n.useMemo)(()=>{let e=U.data?(0,tn.y)(U.data):[],t=e.find(e=>e.attempt.id===$);return t?(0,tn.T)(t,e):null},[U.data,$]),K=(0,n.useMemo)(()=>U.data?function(e){let t=e.traces.filter(e=>(0,eH.HK)(e.content)&&eW(e.content.path)&&"phase"===e.content.node),a=t.filter(e=>{var t;return(0,eH.HK)(e.content)&&"candidate"===e.content.label&&eW(null==(t=e.content.data)?void 0:t.parent_path)});if(a.length){let t=a.map((t,a)=>{var r,n,s,l;if(!(0,eH.HK)(t.content))throw Error("Invalid candidate trace");let o=t.content.path,i=null==(r=t.content.data)?void 0:r.parent_path,c=e.attempts.find(e=>{var t;return eW(null==(t=e.metadata)?void 0:t.candidate_path)&&eJ(e.metadata.candidate_path)===eJ(o)}),d=e.traces.filter(e=>{var t;if(!(0,eH.HK)(e.content)||"decision"!==e.content.node)return!1;let a=null==(t=e.content.data)?void 0:t.candidate_paths;return Array.isArray(a)&&a.some(e=>eW(e)&&eJ(e)===eJ(o))||e.content.path.length>o.length&&e.content.path.slice(0,o.length).every((e,t)=>e===o[t])}).find(e=>{var t;return(0,eH.HK)(e.content)&&["pruned","skipped"].includes(null!=(t=e.content.label)?t:"")}),u=d&&(0,eH.HK)(d.content)?d.content.label:null;return{id:"candidate:".concat(eJ(o)),parent:eW(i)&&i.length?"candidate:".concat(eJ(i)):null,label:"Candidate ".concat(a+1),kind:"candidate",status:null!=(l=null==c?void 0:c.bucket)?l:"pruned"===u||"skipped"===u?u:null,disposition:"pruned"===u||"skipped"===u?u:void 0,reason:d&&(0,eH.HK)(d.content)&&"string"==typeof(null==(n=d.content.data)?void 0:n.reason)?d.content.data.reason:void 0,score:"number"==typeof(null==c||null==(s=c.metadata)?void 0:s.score)?c.metadata.score:null,attemptId:null==c?void 0:c.id,trace:t}});for(let a of e.attempts)t.some(e=>e.attemptId===a.id)||t.push(eU(a));return{kind:"candidates",nodes:eG(t)}}if(t.length){let a=t.map(e=>{if(!(0,eH.HK)(e.content))throw Error("Invalid phase trace");return{id:"phase:".concat(eJ(e.content.path)),parent:e.content.path.length>1?"phase:".concat(eJ(e.content.path.slice(0,-1))):null,label:e.content.label||"Recorded phase",kind:"phase",status:null,score:null,trace:e}});for(let t of e.attempts){var r;let n=e.traces.find(e=>{var a;return e.result===t.id&&(0,eH.HK)(e.content)&&"call"===e.content.node&&(null==(a=e.content.data)?void 0:a.role)==="target"}),s=n&&(0,eH.HK)(n.content)?n.content.path:[],l=a.filter(e=>e.trace&&(0,eH.HK)(e.trace.content)&&e.trace.content.path.every((e,t)=>s[t]===e)).sort((e,t)=>(t.trace&&(0,eH.HK)(t.trace.content)?t.trace.content.path.length:0)-(e.trace&&(0,eH.HK)(e.trace.content)?e.trace.content.path.length:0))[0];a.push({...eU(t),parent:null!=(r=null==l?void 0:l.id)?r:null,trace:null==l?void 0:l.trace})}for(let t of e.traces)(0,eH.HK)(t.content)&&"decision"===t.content.node&&a.push({id:"decision:".concat(eJ(t.content.path)),parent:"phase:".concat(eJ(t.content.path.slice(0,-1))),label:t.content.label||"Decision",kind:"decision",status:"pruned"===t.content.label?"pruned":"skipped"===t.content.label?"skipped":null,score:null,trace:t});return{kind:"execution",nodes:eG(a)}}return{kind:"attempts",nodes:e.attempts.map(eU)}}(U.data):null,[U.data]);(0,n.useEffect)(()=>{var e;let t=y.current,a=w.current,r=null!=(e=null==t?void 0:t.closest("main"))?e:document.documentElement;if(!t||!a)return;let n=()=>{var e;let n=a.getBoundingClientRect().top-r.getBoundingClientRect().top+r.scrollTop,s=Math.max(0,(null!=(e=t.closest("[data-page-layout]"))?e:t).getBoundingClientRect().bottom-a.getBoundingClientRect().bottom)+(parseFloat(getComputedStyle(r).paddingBottom)||0);t.style.setProperty("--goal-row-height","".concat(Math.max(0,r.clientHeight-n-s),"px"))};n();let s=new ResizeObserver(n);return Array.from(t.children).forEach(e=>{e!==a&&s.observe(e)}),window.addEventListener("resize",n),()=>{s.disconnect(),window.removeEventListener("resize",n)}},[]);let V=(e,t)=>{S({run:e,id:t}),(0,x.gj)({goal:String(g),conversation_attack:e,attempt:t})},Z=P?(0,x.aN)(P.group.run,p.runs):"",Y=tr.x9[null!=(c=null==P?void 0:P.group.run.technique)?c:""],Q=O.reduce((e,t)=>e+t.attempts.length,0),X=O.reduce((e,t)=>e+t.attempts.filter(e=>{var t;return(null==(t=e.human_review)?void 0:t.outcome)!=null}).length,0),ee=null!=(d=null==P?void 0:P.group.attempts.length)?d:0,et=P?function(e,t){let a=t.map(t=>e3(e,t).state).filter(e=>"jailbreak"===e||"mitigated"===e),r=a.filter(e=>"jailbreak"===e).length;return{label:t.length?a.length<t.length?"Incomplete":1===t.length?"Single judge":0===r||r===a.length?"Unanimous":"Mixed":"Not recorded",detail:t.length?a.length<t.length?"".concat(a.length,"/").concat(t.length," votes recorded"):"".concat(r,"/").concat(a.length," jailbreak"):"No judge votes recorded"}}(P.attempt,P.group.judges):null,ea=et&&(null==P?void 0:P.group.judges.length)?"Unanimous"===et.label?et.label:"".concat(et.label," \xb7 ").concat(et.detail):"",er=!!P&&P.group.judges.some(e=>e3(P.attempt,e).explanation),en=null!=(m=null!=(u=null==q?void 0:q.notes)?u:null==P?void 0:P.attempt.notes)?m:null;return(0,r.jsxs)("section",{ref:y,role:"region","aria-labelledby":j,className:"space-y-6",children:[(0,r.jsxs)("nav",{"aria-label":"Investigation breadcrumbs",className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(l(),{href:"/stats",className:"hover:underline",children:"Runs"}),(0,r.jsx)("span",{"aria-hidden":"true",children:"/"}),(0,r.jsx)("button",{type:"button",className:"hover:underline",onClick:b,children:p.name}),(0,r.jsx)("span",{"aria-hidden":"true",children:"/"}),(0,r.jsxs)("span",{className:"text-foreground",children:["Goal ",g+1]})]}),(0,r.jsxs)("div",{ref:w,className:"grid gap-6 lg:h-[max(28rem,var(--goal-row-height,28rem))] lg:grid-cols-[minmax(400px,32rem)_minmax(0,1fr)]",children:[(0,r.jsx)(tl,{label:"Goal attempts",eyebrow:"01 / Goal ".concat(g+1),titleId:j,title:E.error?"Goal unavailable":I?I.goal||"Goal text not recorded":"Loading goal…",description:(0,r.jsxs)(r.Fragment,{children:[I&&(0,r.jsxs)("p",{className:"mb-1.5 text-xs",children:[I.category||"Unknown category",I.subcategory?" › ".concat(I.subcategory):""]}),I&&(0,r.jsxs)("p",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,r.jsxs)("span",{"aria-label":"Goal outcome",className:"inline-flex items-center gap-2",children:["Goal outcome ",(0,r.jsx)(eP.c,{value:I.verdict})]}),z.data&&(0,r.jsxs)("span",{children:[Q," ",1===Q?"attempt":"attempts"," \xb7 ",X," reviewed"]})]}),E.error&&(0,r.jsx)(ts,{error:E.error,retry:()=>k(e=>e+1)}),E.data&&!I&&(0,r.jsx)("p",{role:"status",children:"This goal has no recorded attempts in this campaign."})]}),footer:T.length?(0,r.jsx)(te,{columns:T,label:F}):void 0,children:z.error?(0,r.jsx)(ts,{error:z.error,retry:()=>k(e=>e+1)}):z.data?(0,r.jsx)(ta,{campaign:p,groups:O,columns:T,judgeLabel:F,active:P?{run:P.group.run.id,id:P.attempt.id}:null,onSelect:V}):(0,r.jsx)(ts,{children:"Loading attempts…"})}),(0,r.jsx)(tl,{label:"Attempt conversation",headerLabel:"Selected attack",eyebrow:"02 / Conversation",title:P?Z:H?(0,x.aN)(H,p.runs):"Conversation",description:P?[ee>1?"Attempt ".concat(P.attempt.ordinal," of ").concat(ee):null,B].filter(Boolean).join(" \xb7 ")||void 0:H&&z.data?"Not tested":void 0,bodyClassName:"p-5",children:D?P?(0,r.jsxs)("div",{className:"space-y-4",children:[U.error?(0,r.jsx)(ts,{error:U.error,retry:()=>k(e=>e+1)}):q?(0,r.jsx)(eB.C,{entry:q}):(0,r.jsx)(ts,{children:U.data?"The conversation for this attempt was not recorded.":"Loading conversation…"}),(0,r.jsxs)("section",{"aria-label":"Judges' explanations",className:"conversation-message conversation-judges",children:[(0,r.jsxs)("p",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:["Judges",ea?(0,r.jsxs)("span",{className:"font-normal",children:[" \xb7 ",ea]}):null]}),en&&!er&&(0,r.jsx)("div",{className:"mb-3",children:(0,r.jsx)(eq.P,{content:en})}),(0,r.jsx)(e6,{attempt:P.attempt,judges:P.group.judges,label:F})]}),(Y||(null==K?void 0:K.kind)==="candidates"||q)&&(0,r.jsxs)("details",{className:"conversation-message",children:[(0,r.jsx)("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:"About this attack and technical details"}),(0,r.jsxs)("div",{className:"space-y-4 pt-3",children:[Y&&(0,r.jsx)("p",{className:"max-w-prose leading-relaxed",children:Y}),(null==K?void 0:K.kind)==="candidates"&&U.data&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Attack branches"}),(0,r.jsx)(e$,{simple:!0,nodes:K.nodes.map((e,t)=>{var a,r;return{...e,label:e.attemptId?"Attempt ".concat(null==(r=U.data)||null==(a=r.attempts.find(t=>t.id===e.attemptId))?void 0:a.ordinal):"Branch ".concat(t+1)}}),selectedId:C,kind:"candidates",onSelect:e=>{A(e.id),e.attemptId?(R(null),V(P.group.run.id,e.attemptId)):R(e.reason||"This branch was discarded before a target response was recorded.")}}),M&&(0,r.jsx)("p",{role:"status",children:M})]}),q&&(0,r.jsx)("pre",{className:"max-h-80 overflow-auto whitespace-pre-wrap break-words rounded border bg-muted/50 p-3 text-xs",children:JSON.stringify({attempt:null==(a=U.data)?void 0:a.attempts.find(e=>e.id===$),result:null==(o=U.data)||null==(s=o.results)?void 0:s.find(e=>e.id===$),traces:null==(i=U.data)?void 0:i.traces.filter(e=>e.result===$)},null,2)})]})]})]}):(0,r.jsx)(ts,{children:z.data?H?"This attack has no recorded attempts for this goal.":"No attempts were recorded for this goal.":"Loading…"}):(0,r.jsx)(ts,{error:"This attack does not belong to this campaign."})})]})]})}function ti(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),a=Math.round((t-new Date(e).getTime())/1e3),r=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});for(let[e,t]of[["year",31536e3],["month",2592e3],["day",86400],["hour",3600],["minute",60]])if(Math.abs(a)>=t)return r.format(-Math.round(a/t),e);return"just now"}function tc(e){var t;let{campaigns:a,total:n}=e,s=[...a].sort((e,t)=>e.created_at.localeCompare(t.created_at)),l=e=>a.reduce((t,a)=>t+a[e],0),o=(0,g.R)({recorded_goals:l("recorded_goals"),jailbroken:l("jailbroken")}),i=s.map(e=>(0,g.R)(e)),c=s[s.length-1];return(0,r.jsxs)("section",{"aria-label":"Runs overview",className:"space-y-2",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-5",children:[(0,r.jsx)(f.nO,{label:"Campaigns",value:n,detail:"recorded runs",children:(0,r.jsx)("div",{className:"text-[var(--viz-family-static)]",children:(0,r.jsx)(f.OW,{bars:!0,label:"Attacks per campaign, oldest first: ".concat(s.map(e=>e.attack_runs).join(", ")),values:s.map(e=>e.attack_runs)})})}),(0,r.jsx)(f.nO,{label:"Goals tested",value:l("recorded_goals").toLocaleString(),detail:"across campaigns",children:(0,r.jsx)("div",{className:"text-[var(--viz-family-adaptive)]",children:(0,r.jsx)(f.OW,{bars:!0,label:"Goals per campaign, oldest first: ".concat(s.map(e=>e.recorded_goals).join(", ")),values:s.map(e=>e.recorded_goals)})})}),(0,r.jsx)(f.nO,{label:"Overall ASR",value:null===o?"Not measured":"".concat(o.toFixed(1),"%"),detail:"".concat(l("jailbroken").toLocaleString()," goals jailbroken"),children:(0,r.jsx)("div",{className:"text-[var(--viz-jailbroken)]",children:(0,r.jsx)(f.OW,{max:100,values:i,label:"ASR per campaign, oldest first: ".concat(i.map(e=>null===e?"not measured":"".concat(e.toFixed(1),"%")).join(", "))})})}),(0,r.jsx)(f.nO,{label:"Attempts",value:l("attempts").toLocaleString(),detail:"recorded attempts",children:(0,r.jsx)("div",{className:"text-muted-foreground",children:(0,r.jsx)(f.OW,{bars:!0,label:"Attempts per campaign, oldest first: ".concat(s.map(e=>e.attempts).join(", ")),values:s.map(e=>e.attempts)})})}),(0,r.jsx)("div",{className:"col-span-2 lg:col-span-1",children:(0,r.jsx)(f.nO,{label:"Latest campaign",value:(0,r.jsx)("span",{className:"block truncate text-base",title:null==c?void 0:c.name,children:null!=(t=null==c?void 0:c.name)?t:"None yet"}),detail:c?"".concat(c.target," \xb7 ").concat(ti(c.created_at)):void 0,children:c&&(0,r.jsx)(b,{status:c.status})})})]}),n>a.length&&(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Trends cover the ",a.length," most recent of ",n," campaigns."]})]})}var td=a(71360),tu=a(35835),tm=a(41444);let tp=(0,tm.h)("DeleteCampaign"),th=new Set(["COMPLETED","FAILED","CANCELLED"]);function tx(e){let{id:t,ids:a,name:s,status:l,onDeleted:o}=e,[i,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(""),g=async()=>{u(!0),p("");try{await (0,x._F)(a?{ids:a}:{id:t}),o()}catch(e){tp.error({err:e,id:t},"Failed to delete campaign execution"),p(e instanceof Error?e.message:"Failed to delete campaign execution.")}finally{u(!1)}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)(h.$,{variant:"outline","aria-label":"Delete ".concat(s),disabled:d||!th.has(l)||void 0!==a&&!a.length,title:th.has(l)?void 0:"Active campaign executions cannot be deleted",onClick:()=>c(!0),children:[(0,r.jsx)(td.A,{className:"mr-2 h-4 w-4"}),d?"Deleting...":a?"Delete selected (".concat(a.length,")"):"Delete"]}),(0,r.jsx)(tu.T,{open:i,onOpenChange:c,title:"Delete campaign execution?",description:"Permanently delete ".concat(a?"these ".concat(a.length," selected campaign executions"):'"'.concat(s,'"')," and all their attack runs, results and traces? This cannot be undone. Saved configurations and exported log files will not be deleted."),confirmText:"Delete execution",variant:"destructive",onConfirm:()=>{g()}}),m&&(0,r.jsx)("p",{role:"alert",className:"mt-2 text-sm text-destructive",children:m})]})}var tg=a(39867);let tf=(0,tm.h)("ExportCampaign"),tv=new Set(["COMPLETED","FAILED","CANCELLED"]);function tb(e){let{id:t,ids:s,name:l,status:o}=e,[c,d]=(0,n.useState)(!1),[u,m]=(0,n.useState)(""),[p,x]=(0,n.useState)(""),g=(0,n.useRef)(null),f=JSON.stringify(null!=s?s:t?[t]:[]);(0,n.useEffect)(()=>(d(!1),m(""),x(""),()=>{var e;return null==(e=g.current)?void 0:e.abort()}),[f]);let v=async()=>{let e=new AbortController;g.current=e,d(!0),m(""),x("");try{let{createCampaignExports:r,downloadCampaignExport:n}=await Promise.all([a.e(690),a.e(390),a.e(877)]).then(a.bind(a,12877)),l=await r(null!=s?s:t?[t]:[],e.signal);if(e.signal.aborted)return;l.forEach(e=>n(e)),x(1===l.length?"HTML download requested.":"".concat(l.length," HTML downloads requested. Your browser may ask permission to download multiple files."))}catch(a){if(e.signal.aborted)return;tf.error({err:a,id:t,ids:s},"Failed to export campaign"),m(a instanceof Error?a.message:"Failed to export campaign.")}finally{e.signal.aborted||d(!1)}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)(h.$,{variant:"outline","aria-label":"Export ".concat(l),disabled:c||void 0!==o&&!tv.has(o)||(void 0!==s?!s.length:!t),title:void 0===o||tv.has(o)?"Download a full-campaign HTML report, printable to PDF":"Export is available when the campaign execution finishes",onClick:()=>{v()},children:[c?(0,r.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,r.jsx)(tg.A,{className:"mr-2 h-4 w-4"}),c?"Exporting...":s?"Export selected (".concat(s.length,")"):"Export"]}),u&&(0,r.jsx)("p",{role:"alert",className:"mt-2 max-w-sm text-sm text-destructive",children:u}),p&&(0,r.jsx)("p",{role:"status",className:"mt-2 max-w-sm text-xs text-muted-foreground",children:p})]})}let tj=(0,d.A)("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);var ty=a(4882),tw=a(7831);let tN=(0,tm.h)("CancelCampaignRun");async function tk(e){if(!(e instanceof ty.o3e))return null;try{let t=await e.response.json(),a=t&&"object"==typeof t?t.detail:null;return"string"==typeof a&&a?a:null}catch(e){return null}}function t_(e){let{id:t,name:a,onCancelled:s}=e,[l,o]=(0,n.useState)(!1),[c,d]=(0,n.useState)("idle"),[u,m]=(0,n.useState)(""),p=async()=>{d("busy"),m("");try{await tw.ME.runCancelCreate({id:t}),d("requested"),null==s||s()}catch(a){var e;tN.error({err:a,id:t},"Failed to cancel campaign run"),d("idle"),m(null!=(e=await tk(a))?e:"Could not cancel the run.")}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)(h.$,{variant:"outline","aria-label":"Cancel ".concat(a),disabled:"idle"!==c,onClick:()=>o(!0),children:["idle"===c?(0,r.jsx)(tj,{className:"mr-2 h-4 w-4"}):(0,r.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}),"idle"===c?"Cancel run":"Cancelling..."]}),(0,r.jsx)(tu.T,{open:l,onOpenChange:o,title:"Cancel this run?",description:"The run stops and finishes as cancelled. Results gathered so far are kept.",confirmText:"Cancel run",cancelText:"Keep running",variant:"destructive",onConfirm:()=>{p()}}),u&&(0,r.jsx)("p",{role:"alert",className:"mt-2 max-w-sm text-sm text-destructive",children:u})]})}let tS=(0,d.A)("git-compare-arrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]),tC=(e,t)=>"/stats?".concat(new URLSearchParams({run:e,baseline:t}));function tA(e){let{current:t,baseline:a}=e;if(null===t||null===a)return(0,r.jsx)("span",{className:"text-muted-foreground",children:"not comparable"});let n=t-a,s=.05>Math.abs(n)?0:n;return(0,r.jsxs)("span",{className:"font-semibold tabular-nums ".concat(s>0?"text-rose-700 dark:text-rose-300":s<0?"text-emerald-700 dark:text-emerald-300":"text-muted-foreground"),title:s>0?"More goals jailbroken than before":s<0?"Fewer goals jailbroken than before":"No change",children:[s>0?"+":s<0?"−":"\xb1",Math.abs(s).toFixed(1)," pts"]})}function tM(e){var t,a,s;let{campaign:l}=e,i=(0,o.useRouter)(),[c,d]=(0,n.useState)(!1),[u,m]=(0,n.useState)(""),p=l.campaign?new URLSearchParams({campaign:l.campaign,page:"1",page_size:"100"}):null,g=(0,x.LI)(c&&p?"".concat(x.dI,"/summary?").concat(p):null),f=null!=(s=null==(t=g.data)?void 0:t.results.filter(e=>e.id!==l.id))?s:[],v=u||(null==(a=f[0])?void 0:a.id)||"";return l.campaign?c?(0,r.jsxs)("form",{className:"flex flex-wrap items-center gap-2",onSubmit:e=>{e.preventDefault(),v&&i.push(tC(l.id,v))},children:[(0,r.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Baseline"}),(0,r.jsxs)("select",{"aria-label":"Baseline run",className:"h-8 max-w-[18rem] rounded-md border bg-card px-2 text-sm",disabled:!f.length,value:v,onChange:e=>m(e.target.value),children:[!g.data&&!g.error&&(0,r.jsx)("option",{value:"",children:"Loading runs..."}),g.data&&!f.length&&(0,r.jsx)("option",{value:"",children:"No other runs of this campaign"}),f.map(e=>(0,r.jsx)("option",{value:e.id,children:"".concat(e.name," \xb7 ").concat(new Date(e.created_at).toLocaleString()," \xb7 ").concat(e.status.charAt(0)+e.status.slice(1).toLowerCase())},e.id))]})]}),(0,r.jsx)(h.$,{type:"submit",size:"sm",disabled:!v,children:"Compare"}),g.error&&(0,r.jsx)("p",{role:"alert",className:"w-full text-xs text-destructive",children:g.error})]}):(0,r.jsx)(h.$,{variant:"outline",size:"sm",onClick:()=>d(!0),children:"Compare with another run"}):null}function tR(e){let{campaign:t}=e,a=t.previous,n=a?[["Jailbroken",a.jailbroken,t.jailbroken],["Mitigated",a.mitigated,t.mitigated],["Unresolved",a.unresolved,t.unresolved],["Goals",a.recorded_goals,t.recorded_goals]]:[],s=(0,g.R)(t),o=a?(0,g.R)(a):null;return(0,r.jsxs)("section",{"aria-label":"Change since the previous run",className:"investigation-panel flex flex-wrap items-center justify-between gap-x-6 gap-y-3 p-4 text-sm",children:[a?(0,r.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Since the previous run \xb7 ",(0,r.jsx)("time",{dateTime:a.created_at,title:new Date(a.created_at).toLocaleString(),children:ti(a.created_at)})]}),(0,r.jsxs)("p",{className:"flex flex-wrap items-baseline gap-x-2",children:[(0,r.jsxs)("span",{children:["ASR ",(0,r.jsx)("span",{className:"tabular-nums",children:null===o?"—":"".concat(o.toFixed(1),"%")})," → ",(0,r.jsx)("span",{className:"font-semibold tabular-nums",children:null===s?"—":"".concat(s.toFixed(1),"%")})]}),(0,r.jsx)(tA,{current:s,baseline:o})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground tabular-nums",children:n.map(e=>{let[t,a,r]=e;return"".concat(t," ").concat(a," → ").concat(r)}).join(" \xb7 ")})]}):(0,r.jsx)("p",{className:"text-muted-foreground",children:"No earlier completed run of this campaign to compare with."}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a&&(0,r.jsx)(h.$,{variant:"outline",size:"sm",asChild:!0,children:(0,r.jsxs)(l(),{href:tC(t.id,a.id),children:[(0,r.jsx)(tS,{className:"mr-2 h-4 w-4"}),"Compare with previous run"]})}),(0,r.jsx)(tM,{campaign:t}),t.campaign&&(0,r.jsx)(l(),{className:"text-sm underline-offset-4 hover:underline",href:"/stats?".concat(new URLSearchParams({campaign:t.campaign})),children:"All runs of this campaign"})]})]})}function tL(e){let{runs:t}=e,[a,n]=(0,f.uc)(640),s=[...t].sort((e,t)=>e.created_at.localeCompare(t.created_at)||e.id.localeCompare(t.id)).map(e=>({run:e,value:(0,g.R)(e)})).filter(e=>null!==e.value),l=Math.max(320,n),o=l-24,i=e=>s.length>1?48+e*(o-48)/(s.length-1):(48+o)/2,c=e=>150-e/100*134,d=Math.max(1,Math.ceil(s.length/Math.max(1,Math.floor((o-48)/90))));return(0,r.jsxs)("figure",{"aria-label":"Attack success rate across runs",className:"investigation-panel space-y-3 p-5",children:[(0,r.jsxs)("figcaption",{children:[(0,r.jsx)("h2",{className:"text-base font-semibold",children:"Progress across runs"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Attack success rate of each run of this campaign, oldest first. Lower is better. Hollow points are runs that did not complete; their rate covers only the goals they recorded."})]}),s.length<2&&(0,r.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:s.length?"Only one run of this campaign has recorded goals. Run it again to see a trend.":"No run of this campaign has recorded goals yet."}),s.length>0&&(0,r.jsx)("div",{ref:a,className:"min-w-0 overflow-x-auto rounded-lg border bg-background/50",children:(0,r.jsxs)("svg",{width:l,height:185,className:"block",role:"group","aria-label":"Attack success rate per run",children:[[0,25,50,75,100].map(e=>(0,r.jsxs)("g",{children:[(0,r.jsx)("line",{x1:48,x2:o,y1:c(e),y2:c(e),stroke:"var(--border)",strokeDasharray:"3 4"}),(0,r.jsxs)("text",{x:38,y:c(e)+4,textAnchor:"end",fontSize:11,fill:"var(--muted-foreground)",children:[e,"%"]})]},e)),s.length>1&&(0,r.jsx)("polyline",{points:s.map((e,t)=>"".concat(i(t),",").concat(c(e.value))).join(" "),fill:"none",stroke:"var(--viz-jailbroken)",strokeWidth:2,strokeLinejoin:"round"}),s.map((e,t)=>(0,r.jsxs)("a",{href:"/stats?".concat(new URLSearchParams({run:e.run.id})),"aria-label":"".concat(e.run.name,", ").concat(new Date(e.run.created_at).toLocaleString(),": ").concat(e.value.toFixed(1),"% ASR"),children:[(0,r.jsx)("title",{children:(e=>{let{run:t,value:a}=e;return"".concat(t.name," \xb7 ").concat(new Date(t.created_at).toLocaleString(),"\n\nASR: ").concat(a.toFixed(1),"%\nJailbroken goals: ").concat(t.jailbroken," of ").concat(t.recorded_goals,"\nStatus: ").concat(t.status.toLowerCase())})(e)}),(0,r.jsx)("circle",{"data-trend-run":e.run.id,"data-asr":e.value,cx:i(t),cy:c(e.value),r:5,fill:"COMPLETED"===e.run.status?"var(--viz-jailbroken)":"var(--card)",stroke:"var(--viz-jailbroken)",strokeWidth:2}),t%d==0&&(0,r.jsx)("text",{x:i(t),y:170,textAnchor:"middle",fontSize:11,fill:"var(--muted-foreground)",children:new Date(e.run.created_at).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]},e.run.id))]})})]})}let tE={regressed:"Regressed",fixed:"Fixed",new:"New",dropped:"Dropped",unchanged:"Unchanged"},tz={regressed:"text-rose-700 dark:text-rose-300",fixed:"text-emerald-700 dark:text-emerald-300",new:"text-sky-700 dark:text-sky-300",dropped:"text-amber-800 dark:text-amber-300",unchanged:"text-muted-foreground"};function tI(e){let{value:t}=e;return null===t?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Not run"}):(0,r.jsx)(eP.c,{value:t})}function tF(e){let{comparison:t,initialChange:a,goalIndex:s}=e,[o,i]=(0,n.useState)(()=>x.on.includes(a)?a:"all"===a?null:t.counts.regressed>0?"regressed":null),c=e=>{i(e),(0,x.gj)({change:null!=e?e:"all"})},d=o?t.goals.filter(e=>e.change===o):t.goals,u=e=>"inline-flex items-center gap-2 rounded-full border px-3 py-1 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ".concat(e?"border-foreground bg-foreground text-background":"bg-card hover:bg-muted");return(0,r.jsxs)("section",{"aria-label":"Goal changes",className:"investigation-panel space-y-4 p-5 sm:p-6",children:[(0,r.jsxs)("header",{children:[(0,r.jsx)("p",{className:"section-eyebrow",children:"Run comparison"}),(0,r.jsx)("h2",{className:"mt-2 text-xl font-semibold",children:"Which goals changed?"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Goals are matched by their exact text. Regressed: jailbroken now, not in the baseline. Fixed: jailbroken in the baseline, not now. New and dropped goals were run by only one of the two."})]}),(0,r.jsxs)("div",{role:"group","aria-label":"Filter goals by change",className:"flex flex-wrap gap-2",children:[(0,r.jsxs)("button",{type:"button","aria-pressed":null===o,className:u(null===o),onClick:()=>c(null),children:["All ",(0,r.jsx)("span",{className:"tabular-nums",children:t.goals.length})]}),x.on.map(e=>(0,r.jsxs)("button",{type:"button","aria-pressed":o===e,className:u(o===e),onClick:()=>c(o===e?null:e),children:[tE[e]," ",(0,r.jsx)("span",{className:"tabular-nums",children:t.counts[e]})]},e))]}),t.goals.length?d.length?(0,r.jsx)("div",{className:"overflow-x-auto rounded-md border",children:(0,r.jsxs)("table",{"aria-label":"Goal outcomes in both runs",className:"w-full min-w-[760px] text-left text-sm",children:[(0,r.jsx)("thead",{className:"bg-muted/40 text-xs text-muted-foreground",children:(0,r.jsx)("tr",{children:["Goal","Category","Subcategory","Baseline","Current","Change"].map(e=>(0,r.jsx)("th",{scope:"col",className:"px-4 py-3 font-medium",children:e},e))})}),(0,r.jsx)("tbody",{children:d.map(e=>{let a=null===e.current||null==s?void 0:s.get(e.goal);return(0,r.jsxs)("tr",{className:"border-t align-top",children:[(0,r.jsx)("th",{scope:"row",className:"max-w-[28rem] px-4 py-3 font-normal",children:void 0===a?(0,r.jsx)("span",{className:"whitespace-pre-wrap break-words",children:e.goal}):(0,r.jsx)(l(),{className:"whitespace-pre-wrap break-words text-primary underline-offset-4 hover:underline",href:"/stats?".concat(new URLSearchParams({run:t.current.id,goal:String(a)})),children:e.goal})}),(0,r.jsx)("td",{className:"px-4 py-3",children:e.category||"Unknown category"}),(0,r.jsx)("td",{className:"px-4 py-3 text-muted-foreground",children:e.subcategory||"Unspecified"}),(0,r.jsx)("td",{className:"px-4 py-3",children:(0,r.jsx)(tI,{value:e.baseline})}),(0,r.jsx)("td",{className:"px-4 py-3",children:(0,r.jsx)(tI,{value:e.current})}),(0,r.jsx)("td",{className:"px-4 py-3 font-medium ".concat(tz[e.change]),children:tE[e.change]})]},"".concat(e.change,":").concat(e.goal))})})]})}):(0,r.jsxs)("p",{role:"status",className:"rounded-lg border p-6 text-sm text-muted-foreground",children:["No ",tE[o].toLowerCase()," goals."]}):(0,r.jsx)("p",{role:"status",className:"rounded-lg border p-6 text-sm text-muted-foreground",children:"Neither run recorded any goals to compare."})]})}function tO(){return(0,r.jsxs)("p",{role:"status",className:"flex items-center gap-2 p-6 text-sm text-muted-foreground",children:[(0,r.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Loading recorded results..."]})}function tT(e){let{message:t,retry:a}=e;return(0,r.jsxs)("div",{role:"alert",className:"investigation-panel space-y-3 p-6 text-sm",children:[(0,r.jsx)("p",{children:t}),(0,r.jsx)(h.$,{variant:"outline",onClick:a,children:"Retry"})]})}let tD=e=>e.results.some(x.Oy),tP=e=>"/stats?".concat(new URLSearchParams({run:e}));function tH(e){let{status:t}=e;return(0,r.jsxs)("div",{role:"status",className:"investigation-panel flex items-center gap-3 p-4 text-sm",children:[(0,r.jsx)(i.A,{className:"h-4 w-4 shrink-0 animate-spin text-sky-600","aria-hidden":"true"}),(0,r.jsxs)("p",{children:[(0,r.jsx)("span",{className:"font-semibold",children:"PENDING"===t?"Queued.":"Running."})," ","Showing results so far; this report updates every 5 seconds until the run finishes."]})]})}let tJ=["goal","conversation_attack","conversation_aggregate","attempt","node"];function tW(e){var t,a,r,n;let s=null!=(t=null==e?void 0:e.get("goal"))?t:null;return null!==s&&/^\d+$/.test(s)&&Number.isSafeInteger(Number(s))?{goal:Number(s),run:null!=(r=null!=(a=null==e?void 0:e.get("conversation_attack"))?a:null==e?void 0:e.get("attack"))?r:null,attempt:null!=(n=null==e?void 0:e.get("attempt"))?n:null}:null}function tU(e){var t,a,s,i,d,p;let{id:g}=e,f=(0,o.useSearchParams)(),v=(null==f?void 0:f.get("section"))==="audit"||!(null==f?void 0:f.get("section"))&&(null==f?void 0:f.get("tab"))==="audit",[b,j]=(0,n.useState)(0),[y,w]=(0,n.useState)(()=>tW(f)),N=(0,n.useRef)(null),k=(0,n.useRef)(0),_=(0,n.useRef)(null),[S,C]=(0,n.useState)(0);(0,n.useEffect)(()=>{let e=()=>C(e=>e+1);return window.addEventListener(x.T9,e),()=>window.removeEventListener(x.T9,e)},[]);let A=(0,x.LI)("".concat(x.dI,"/").concat(g,"/summary"),b,void 0,{pollWhile:x.Oy,version:S}),M=(0,x.LI)("".concat(x.dI,"/").concat(g,"/report"),b,void 0,{version:null==(t=A.data)?void 0:t.revision,versionOf:e=>e.revision}),R=M.data,L=(0,x.LI)(R?"".concat(x.dI,"/").concat(g,"/costs"):null,b,void 0,{version:null==R?void 0:R.revision}),E=L.data,z=null!=(i=null!=(s=null==(a=A.data)?void 0:a.status)?s:null==R?void 0:R.status)?i:"",I=!!z&&(0,x.Oy)({status:z}),F=null==R?void 0:R.id,O=null!==y,T=()=>{var e,t;return null!=(t=null==(e=N.current)?void 0:e.closest("main"))?t:document.documentElement};(0,n.useEffect)(()=>{var e,t;!O&&v&&F&&(null==(t=document.getElementById("campaign-audit"))||null==(e=t.scrollIntoView)||e.call(t,{block:"start"}))},[v,F,O]),(0,n.useEffect)(()=>{var e;T().scrollTop=O?0:k.current,!O&&(null==(e=_.current)?void 0:e.isConnected)&&_.current.focus({preventScroll:!0})},[O]),(0,n.useEffect)(()=>{let e=()=>w(tW(new URLSearchParams(window.location.search)));return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let D=e=>{let t=new URL(window.location.href);e(t),window.history.pushState(null,"","".concat(t.pathname).concat(t.search).concat(t.hash))},P=(0,n.useCallback)((e,t,a)=>{k.current=T().scrollTop,_.current=null!=a?a:document.activeElement instanceof HTMLElement?document.activeElement:null,D(a=>{tJ.forEach(e=>a.searchParams.delete(e)),a.searchParams.set("goal",String(e)),a.searchParams.set("conversation_attack",t)}),w({goal:e,run:t,attempt:null})},[]),H=()=>{D(e=>tJ.forEach(t=>e.searchParams.delete(t))),w(null)};return(0,r.jsx)("div",{ref:N,className:"runs-workspace min-h-full",children:(0,r.jsx)(m.M,{compact:!0,title:null!=(d=null==R?void 0:R.name)?d:"Campaign",action:(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[R&&O&&(0,r.jsxs)(h.$,{variant:"outline",onClick:H,children:[(0,r.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Back to campaign"]}),R&&!O&&(0,r.jsxs)(r.Fragment,{children:[I&&(0,r.jsx)(t_,{id:g,name:R.name}),(0,r.jsx)(tb,{id:g,name:R.name,status:z}),(0,r.jsx)(tx,{id:g,name:R.name,status:z,onDeleted:()=>window.location.assign("/stats")})]}),(0,r.jsxs)(h.$,{variant:"outline",onClick:()=>j(e=>e+1),children:[(0,r.jsx)(u,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),children:(0,r.jsxs)("div",{className:"space-y-8 px-4 sm:px-6 ".concat(O?"pb-4":"pb-8"),children:[(0,r.jsxs)("nav",{hidden:O,"aria-label":"Investigation breadcrumbs",className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(l(),{href:"/stats",className:"hover:underline",children:"Runs"}),(0,r.jsx)("span",{"aria-hidden":"true",children:"/"}),(0,r.jsx)("span",{className:"text-foreground",children:null!=(p=null==R?void 0:R.name)?p:"Campaign"})]}),M.error?(0,r.jsx)(tT,{message:M.error,retry:()=>j(e=>e+1)}):R?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{hidden:O,className:"space-y-8",children:[I&&(0,r.jsx)(tH,{status:z}),(0,r.jsx)(tR,{campaign:R}),(0,r.jsx)(ef,{campaign:R,costs:E,coverage:(0,r.jsx)(eF,{campaign:R,revision:b,onOpenGoal:P}),costStatus:L.error?(0,r.jsx)(tT,{message:L.error,retry:()=>j(e=>e+1)}):(0,r.jsx)(tO,{})})]}),y&&(0,r.jsx)(to,{campaign:R,revision:b,goalIndex:y.goal,run:y.run,attempt:y.attempt,onBack:H},y.goal)]}):(0,r.jsx)(tO,{})]})})})}function tG(e){var t;let{id:a,baseline:s}=e,i=(0,o.useSearchParams)(),[c,d]=(0,n.useState)(0),p=(0,x.LI)("".concat(x.dI,"/").concat(a,"/compare?").concat(new URLSearchParams({baseline:s})),c),g=p.data,f=(0,x.LI)(g?"".concat(x.dI,"/").concat(a,"/matrix"):null,c),v=(0,n.useMemo)(()=>f.data?new Map(f.data.goals.map(e=>[e.goal,e.index])):void 0,[f.data]);return(0,r.jsx)("div",{className:"runs-workspace min-h-full",children:(0,r.jsx)(m.M,{compact:!0,title:"Compare runs",action:(0,r.jsxs)(h.$,{variant:"outline",onClick:()=>d(e=>e+1),children:[(0,r.jsx)(u,{className:"mr-2 h-4 w-4"}),"Refresh"]}),children:(0,r.jsxs)("div",{className:"space-y-6 px-4 pb-8 sm:px-6",children:[(0,r.jsxs)("nav",{"aria-label":"Investigation breadcrumbs",className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(l(),{href:"/stats",className:"hover:underline",children:"Runs"}),(0,r.jsx)("span",{"aria-hidden":"true",children:"/"}),(0,r.jsx)(l(),{href:tP(a),className:"hover:underline",children:null!=(t=null==g?void 0:g.current.name)?t:"Campaign"}),(0,r.jsx)("span",{"aria-hidden":"true",children:"/"}),(0,r.jsx)("span",{className:"text-foreground",children:"Compare"})]}),p.error?(0,r.jsx)(tT,{message:p.error,retry:()=>d(e=>e+1)}):g?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("dl",{className:"grid gap-3 sm:grid-cols-2",children:[["Baseline",g.baseline],["Current",g.current]].map(e=>{let[t,a]=e;return(0,r.jsxs)("div",{className:"kpi-card",children:[(0,r.jsx)("dt",{className:"kpi-label",children:t}),(0,r.jsxs)("dd",{className:"mt-1 min-w-0",children:[(0,r.jsx)(l(),{href:tP(a.id),className:"block truncate font-semibold text-primary underline-offset-4 hover:underline",children:a.name}),(0,r.jsx)("time",{dateTime:a.created_at,className:"text-xs text-muted-foreground",children:new Date(a.created_at).toLocaleString()})]})]},t)})}),(0,r.jsx)(tF,{comparison:g,initialChange:null==i?void 0:i.get("change"),goalIndex:v})]}):(0,r.jsx)(tO,{})]})})})}function t$(e){let{campaign:t,runs:a}=e,n=(0,o.useRouter)(),s=new Map;for(let e of a)e.campaign&&!s.has(e.campaign)&&s.set(e.campaign,e.name);return t&&!s.has(t)&&s.set(t,"Selected campaign"),(0,r.jsxs)("label",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Campaign"}),(0,r.jsxs)("select",{"aria-label":"Filter runs by campaign",className:"h-9 max-w-[20rem] rounded-md border bg-card px-3 text-sm",value:null!=t?t:"",onChange:e=>n.push(e.target.value?"/stats?".concat(new URLSearchParams({campaign:e.target.value})):"/stats"),children:[(0,r.jsx)("option",{value:"",children:"All campaigns"}),Array.from(s).map(e=>{let[t,a]=e;return(0,r.jsx)("option",{value:t,children:a},t)})]})]})}function tq(e){var t,a,s;let{campaign:o}=e,[i,c]=(0,n.useState)(1),[d,v]=(0,n.useState)(0),[j,y]=(0,n.useState)(new Set),w=(e,t)=>"".concat(x.dI,"/summary?").concat(new URLSearchParams({page:String(e),page_size:String(t),...o?{campaign:o}:{}})),N=(0,x.LI)(w(1,100),d,void 0,{pollWhile:tD}),k=(0,x.LI)(i>5?w(i,20):null,d,void 0,{pollWhile:tD}),_=i>5?k.error:N.error,S=i>5?k.data:N.data?{...N.data,results:N.data.results.slice((i-1)*20,20*i)}:null,C=null!=(a=null==S?void 0:S.results.filter(e=>["COMPLETED","FAILED","CANCELLED"].includes(e.status)))?a:[],A=C.filter(e=>j.has(e.id)).map(e=>e.id),M=!!(null==S?void 0:S.results.some(x.Oy)),R=()=>{y(new Set),v(e=>e+1)};return(0,r.jsx)("div",{className:"runs-workspace min-h-full",children:(0,r.jsx)(m.M,{title:"Runs",description:"Compare campaign results, then explore goals and their attack conversations.",action:(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(tb,{ids:A,name:"selected campaigns"}),(0,r.jsx)(tx,{id:"",ids:A,name:"selected campaigns",status:"COMPLETED",onDeleted:()=>{c(1),R()}}),(0,r.jsxs)(h.$,{variant:"outline",onClick:R,children:[(0,r.jsx)(u,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),children:(0,r.jsxs)("div",{className:"space-y-4 px-4 sm:px-6",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,r.jsx)(t$,{campaign:o,runs:null!=(s=null==(t=N.data)?void 0:t.results)?s:[]}),M&&(0,r.jsxs)("p",{role:"status",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"h-2 w-2 animate-pulse rounded-full bg-sky-500"}),"Runs in progress; this list updates every 5 seconds."]})]}),N.data&&N.data.results.length>0&&(0,r.jsx)(tc,{campaigns:N.data.results.slice(0,100),total:N.data.count}),o&&N.data&&(0,r.jsx)(tL,{runs:N.data.results}),_?(0,r.jsx)(tT,{message:_,retry:()=>v(e=>e+1)}):S?(0,r.jsxs)(r.Fragment,{children:[S.results.length?(0,r.jsx)("div",{className:"investigation-panel overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full min-w-[760px] text-left text-sm",children:[(0,r.jsx)("thead",{className:"bg-muted/40 text-xs text-muted-foreground",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"px-3 py-3",children:(0,r.jsx)("input",{type:"checkbox","aria-label":"Select all deletable campaigns on this page",disabled:!C.length,checked:!!C.length&&A.length===C.length,onChange:e=>y(new Set(e.target.checked?C.map(e=>e.id):[]))})}),["Campaign / target","Goal outcomes","ASR","Attacks","Status","Started"].map(e=>(0,r.jsx)("th",{className:"px-5 py-3 font-medium ".concat("ASR"===e||"Attacks"===e?"text-right":""),children:e},e))]})}),(0,r.jsx)("tbody",{children:S.results.map(e=>{let t=(0,g.R)(e);return(0,r.jsxs)("tr",{className:"border-t transition-colors hover:bg-muted/30",children:[(0,r.jsx)("td",{className:"px-3 py-3.5",children:(0,r.jsx)("input",{type:"checkbox","aria-label":"Select ".concat(e.name),disabled:!C.some(t=>t.id===e.id),checked:A.includes(e.id),onChange:t=>y(a=>{let r=new Set(a);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,r.jsxs)("td",{className:"max-w-[22rem] px-5 py-3.5",children:[(0,r.jsx)(l(),{className:"font-semibold text-primary underline-offset-4 hover:underline",href:tP(e.id),children:e.name}),(0,r.jsx)("p",{className:"mt-0.5 flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:(0,r.jsx)("span",{className:"truncate",children:e.target})})]}),(0,r.jsxs)("td",{className:"w-[30%] px-5 py-3.5",children:[(0,r.jsx)(f.lV,{label:"".concat(e.name," outcomes"),segments:(0,f.DN)(e)}),(0,r.jsxs)("p",{className:"mt-1.5 text-xs text-muted-foreground tabular-nums",children:[(0,r.jsx)("span",{className:"font-medium text-foreground",children:e.jailbroken})," / ",e.recorded_goals," jailbroken \xb7 ",e.mitigated," mitigated \xb7 ",e.unresolved," unresolved"]})]}),(0,r.jsx)("td",{className:"px-5 py-3.5 text-right text-base font-semibold tabular-nums",children:null===t?"—":"".concat(t.toFixed(0),"%")}),(0,r.jsx)("td",{className:"px-5 py-3.5 text-right tabular-nums",children:e.attack_runs}),(0,r.jsx)("td",{className:"px-5 py-3.5",children:(0,r.jsx)(b,{status:e.status})}),(0,r.jsx)("td",{className:"whitespace-nowrap px-5 py-3.5 text-xs text-muted-foreground",title:new Date(e.created_at).toLocaleString(),children:ti(e.created_at)})]},e.id)})})]})}):(0,r.jsx)("div",{className:"investigation-panel p-10 text-center",children:o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h2",{className:"font-medium",children:"No runs of this campaign yet"}),(0,r.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["Launch the campaign, then refresh. ",(0,r.jsx)(l(),{href:"/stats",className:"underline",children:"Show all campaigns"}),"."]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h2",{className:"font-medium",children:"No campaign executions yet"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Launch a campaign from Campaigns or run one with the CLI, then refresh. No sample results are mixed into your history."})]})}),(0,r.jsx)(p.H,{page:i,pageSize:20,count:S.count,isLoading:!1,onPageChange:e=>{y(new Set),c(e)}})]}):(0,r.jsx)(tO,{})]})})})}function tB(){var e;let t=(0,o.useSearchParams)(),a=null==t?void 0:t.get("run"),n=null==t?void 0:t.get("baseline"),s=null!=(e=null==t?void 0:t.get("campaign"))?e:null;return a&&n?(0,r.jsx)(tG,{id:a,baseline:n},"".concat(a,":").concat(n)):a?(0,r.jsx)(tU,{id:a},a):(0,r.jsx)(tq,{campaign:s},null!=s?s:"")}function tK(){return(0,r.jsx)(n.Suspense,{fallback:(0,r.jsx)(tO,{}),children:(0,r.jsx)(tB,{})})}},22470:(e,t,a)=>{"use strict";a.d(t,{M:()=>n});var r=a(95155);a(12115);let n=e=>{let{title:t,description:a,action:n,children:s,maxWidth:l="full",compact:o=!1}=e;return(0,r.jsxs)("div",{className:"w-full ".concat({full:"max-w-full","8xl":"max-w-[90rem]","7xl":"max-w-7xl","6xl":"max-w-6xl","5xl":"max-w-5xl","4xl":"max-w-4xl","3xl":"max-w-3xl","2xl":"max-w-2xl"}[l]||"max-w-full"," mx-auto ").concat(o?"py-3 space-y-3":"py-6 space-y-6"),children:[t&&(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3 border-b ".concat(o?"px-4 pb-3":"px-6 pb-5"),children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:t}),a&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:a})]}),n&&(0,r.jsx)("div",{className:"flex-shrink-0 pt-0.5",children:n})]}),s]})}},35835:(e,t,a)=>{"use strict";a.d(t,{T:()=>s});var r=a(95155);a(12115);var n=a(98053);let s=e=>{let{open:t,onOpenChange:a,title:s,description:l,onConfirm:o,confirmText:i="Confirm",cancelText:c="Cancel",variant:d="default"}=e;return(0,r.jsx)(n.Lt,{open:t,onOpenChange:a,children:(0,r.jsxs)(n.EO,{children:[(0,r.jsxs)(n.wd,{children:[(0,r.jsx)(n.r7,{children:s}),(0,r.jsx)(n.$v,{children:l})]}),(0,r.jsxs)(n.ck,{children:[(0,r.jsx)(n.Zr,{children:c}),(0,r.jsx)(n.Rx,{onClick:()=>{o(),a(!1)},className:"destructive"===d?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"",children:i})]})]})})}},46767:(e,t,a)=>{"use strict";a.d(t,{Bc:()=>l,ZI:()=>c,k$:()=>i,m_:()=>o});var r=a(95155);a(12115);var n=a(53583),s=a(64269);function l(e){let{delayDuration:t=0,...a}=e;return(0,r.jsx)(n.Kq,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function o(e){let{...t}=e;return(0,r.jsx)(l,{children:(0,r.jsx)(n.bL,{"data-slot":"tooltip",...t})})}function i(e){let{...t}=e;return(0,r.jsx)(n.l9,{"data-slot":"tooltip-trigger",...t})}function c(e){let{className:t,sideOffset:a=0,children:l,...o}=e;return(0,r.jsx)(n.ZL,{children:(0,r.jsxs)(n.UC,{"data-slot":"tooltip-content",sideOffset:a,className:(0,s.cn)("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...o,children:[l,(0,r.jsx)(n.i3,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}},49819:(e,t,a)=>{Promise.resolve().then(a.bind(a,5655))},61362:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});let r=(0,a(71847).A)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},61911:(e,t,a)=>{"use strict";function r(e,t,a){if(!t.has(e))throw TypeError("attempted to "+a+" private field on non-instance");return t.get(e)}a.d(t,{_:()=>r})},65142:(e,t,a)=>{"use strict";a.d(t,{p:()=>s});var r=a(95155);a(12115);var n=a(64269);function s(e){let{className:t,type:a,...s}=e;return(0,r.jsx)("input",{type:a,"data-slot":"input",className:(0,n.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...s})}},66218:(e,t,a)=>{"use strict";a.d(t,{jH:()=>s});var r=a(12115);a(95155);var n=r.createContext(void 0);function s(e){let t=r.useContext(n);return e||t||"ltr"}},69023:(e,t,a)=>{"use strict";a.d(t,{_:()=>n});var r=a(61911);function n(e,t,a){var n=(0,r._)(e,t,"set");if(n.set)n.set.call(e,a);else{if(!n.writable)throw TypeError("attempted to set read only private field");n.value=a}return a}},75426:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});let r=(0,a(71847).A)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},97239:(e,t,a)=>{"use strict";a.d(t,{_:()=>n});var r=a(61911);function n(e,t){var a=(0,r._)(e,t,"get");return a.get?a.get.call(e):a.value}},97999:(e,t,a)=>{"use strict";function r(e,t,a){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object");t.set(e,a)}a.d(t,{_:()=>r})},98053:(e,t,a)=>{"use strict";a.d(t,{$v:()=>x,EO:()=>u,Lt:()=>o,Rx:()=>g,Zr:()=>f,ck:()=>p,r7:()=>h,tv:()=>i,wd:()=>m});var r=a(95155);a(12115);var n=a(35646),s=a(64269),l=a(3998);function o(e){let{...t}=e;return(0,r.jsx)(n.bL,{"data-slot":"alert-dialog",...t})}function i(e){let{...t}=e;return(0,r.jsx)(n.l9,{"data-slot":"alert-dialog-trigger",...t})}function c(e){let{...t}=e;return(0,r.jsx)(n.ZL,{"data-slot":"alert-dialog-portal",...t})}function d(e){let{className:t,...a}=e;return(0,r.jsx)(n.hJ,{"data-slot":"alert-dialog-overlay",className:(0,s.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...a})}function u(e){let{className:t,...a}=e;return(0,r.jsxs)(c,{children:[(0,r.jsx)(d,{}),(0,r.jsx)(n.UC,{"data-slot":"alert-dialog-content",className:(0,s.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...a})]})}function m(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,s.cn)("flex flex-col gap-2 text-center sm:text-left",t),...a})}function p(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,s.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...a})}function h(e){let{className:t,...a}=e;return(0,r.jsx)(n.hE,{"data-slot":"alert-dialog-title",className:(0,s.cn)("text-lg font-semibold",t),...a})}function x(e){let{className:t,...a}=e;return(0,r.jsx)(n.VY,{"data-slot":"alert-dialog-description",className:(0,s.cn)("text-muted-foreground text-sm",t),...a})}function g(e){let{className:t,...a}=e;return(0,r.jsx)(n.rc,{className:(0,s.cn)((0,l.r)(),t),...a})}function f(e){let{className:t,...a}=e;return(0,r.jsx)(n.ZD,{className:(0,s.cn)((0,l.r)({variant:"outline"}),t),...a})}}},e=>{e.O(0,[187,272,619,870,583,432,924,980,441,493,358],()=>e(e.s=49819)),_N_E=e.O()}]);
|