hackagent-webui 0.5.26.dev65__py3-none-any.whl → 0.6.0.dev67__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.
Files changed (78) hide show
  1. hackagent_webui/__init__.py +1 -1
  2. hackagent_webui/static/404.html +13 -1
  3. hackagent_webui/static/VERSION +1 -1
  4. hackagent_webui/static/_next/static/LQR5ZJKBJglYlSbR2x_0w/_buildManifest.js +1 -0
  5. hackagent_webui/static/_next/static/chunks/103-7d6c873540c82114.js +1 -0
  6. hackagent_webui/static/_next/static/chunks/160-21f7abf9e76923d9.js +1 -0
  7. hackagent_webui/static/_next/static/chunks/187-849543277a4f9394.js +1 -0
  8. hackagent_webui/static/_next/static/chunks/272-3caece2aead52578.js +1 -0
  9. hackagent_webui/static/_next/static/chunks/389-5c1851e19b276a7a.js +1 -0
  10. hackagent_webui/static/_next/static/chunks/520-47765c33e252fada.js +1 -0
  11. hackagent_webui/static/_next/static/chunks/{352-9d98107ec1d2a19b.js → 604-42876ab36dfd0b3b.js} +2 -2
  12. hackagent_webui/static/_next/static/chunks/{634-67a19c764fc7a25a.js → 634-af3c4a776b062843.js} +1 -1
  13. hackagent_webui/static/_next/static/chunks/688-74942a135eec7c34.js +1 -0
  14. hackagent_webui/static/_next/static/chunks/747-aa8aa91116de6e71.js +1 -0
  15. hackagent_webui/static/_next/static/chunks/749-aa275fbe25b32d24.js +1 -0
  16. hackagent_webui/static/_next/static/chunks/8-a96ecba12d5b2a4a.js +1 -0
  17. hackagent_webui/static/_next/static/chunks/877.05f7f1bfa707d114.js +1 -0
  18. hackagent_webui/static/_next/static/chunks/888-2e968371d359a872.js +1 -0
  19. hackagent_webui/static/_next/static/chunks/970-bc5945a148c7d8b8.js +1 -0
  20. hackagent_webui/static/_next/static/chunks/app/_not-found/page-5e0f704047919d17.js +1 -0
  21. hackagent_webui/static/_next/static/chunks/app/agents/page-3c5aa0f73ce025a1.js +1 -0
  22. hackagent_webui/static/_next/static/chunks/app/api-keys/page-5e0f704047919d17.js +1 -0
  23. hackagent_webui/static/_next/static/chunks/app/attacks/page-374744a9cfcae586.js +1 -0
  24. hackagent_webui/static/_next/static/chunks/app/credentials/page-e8ee2f975dfadf78.js +1 -0
  25. hackagent_webui/static/_next/static/chunks/app/layout-2d3da5de7ab446be.js +1 -0
  26. hackagent_webui/static/_next/static/chunks/app/page-40fdbb3c458241bf.js +1 -0
  27. hackagent_webui/static/_next/static/chunks/app/profile/page-e346d35f93464904.js +1 -0
  28. hackagent_webui/static/_next/static/chunks/app/secrets/page-5e0f704047919d17.js +1 -0
  29. hackagent_webui/static/_next/static/chunks/app/stats/page-608e2fa66387c864.js +1 -0
  30. hackagent_webui/static/_next/static/chunks/app/usage/page-05dc3bd9fe72c9d6.js +1 -0
  31. hackagent_webui/static/_next/static/chunks/{webpack-5f5c255a944acccf.js → webpack-a6495b10aecf8893.js} +1 -1
  32. hackagent_webui/static/_next/static/css/d4f67f6fdc8fb850.css +1 -0
  33. hackagent_webui/static/agents.html +13 -1
  34. hackagent_webui/static/agents.txt +23 -22
  35. hackagent_webui/static/api-keys.html +13 -1
  36. hackagent_webui/static/api-keys.txt +20 -22
  37. hackagent_webui/static/attacks.html +13 -1
  38. hackagent_webui/static/attacks.txt +23 -22
  39. hackagent_webui/static/campaign-export/styles.css +1 -1
  40. hackagent_webui/static/credentials.html +13 -0
  41. hackagent_webui/static/credentials.txt +24 -0
  42. hackagent_webui/static/index.html +13 -1
  43. hackagent_webui/static/index.txt +23 -22
  44. hackagent_webui/static/profile.html +13 -1
  45. hackagent_webui/static/profile.txt +23 -22
  46. hackagent_webui/static/secrets.html +13 -1
  47. hackagent_webui/static/secrets.txt +20 -22
  48. hackagent_webui/static/stats.html +13 -1
  49. hackagent_webui/static/stats.txt +23 -22
  50. hackagent_webui/static/usage.html +13 -0
  51. hackagent_webui/static/usage.txt +24 -0
  52. {hackagent_webui-0.5.26.dev65.dist-info → hackagent_webui-0.6.0.dev67.dist-info}/METADATA +1 -1
  53. hackagent_webui-0.6.0.dev67.dist-info/RECORD +83 -0
  54. hackagent_webui/static/_next/static/U7s5LqEUH8gEO4-nmwKZH/_buildManifest.js +0 -1
  55. hackagent_webui/static/_next/static/chunks/109-654aaa36bb44ad55.js +0 -1
  56. hackagent_webui/static/_next/static/chunks/133-3d48df8e6274f1e3.js +0 -1
  57. hackagent_webui/static/_next/static/chunks/168-a33d1f7eac818103.js +0 -1
  58. hackagent_webui/static/_next/static/chunks/210-86c6a66776f43b4f.js +0 -1
  59. hackagent_webui/static/_next/static/chunks/267-68673a68da8dc0ed.js +0 -1
  60. hackagent_webui/static/_next/static/chunks/574-0cc0eddd7440f9e6.js +0 -1
  61. hackagent_webui/static/_next/static/chunks/630-d567a2d5c62c90f0.js +0 -1
  62. hackagent_webui/static/_next/static/chunks/704-e457c79de3cc7514.js +0 -1
  63. hackagent_webui/static/_next/static/chunks/756-0acdfe10693b8afc.js +0 -1
  64. hackagent_webui/static/_next/static/chunks/877.8e1543796718ce2b.js +0 -1
  65. hackagent_webui/static/_next/static/chunks/918-f236042f5a6cc47e.js +0 -1
  66. hackagent_webui/static/_next/static/chunks/app/_not-found/page-72f9264520fc0b6a.js +0 -1
  67. hackagent_webui/static/_next/static/chunks/app/agents/page-2ede712c1f31dd76.js +0 -1
  68. hackagent_webui/static/_next/static/chunks/app/api-keys/page-1c219ac9dd1bcdd4.js +0 -1
  69. hackagent_webui/static/_next/static/chunks/app/attacks/page-247041304bc4853c.js +0 -1
  70. hackagent_webui/static/_next/static/chunks/app/layout-88b65f1463c58138.js +0 -1
  71. hackagent_webui/static/_next/static/chunks/app/page-67fe8c280f18e8a6.js +0 -1
  72. hackagent_webui/static/_next/static/chunks/app/profile/page-96240b9461a515e9.js +0 -1
  73. hackagent_webui/static/_next/static/chunks/app/secrets/page-62bf5dba3522de29.js +0 -1
  74. hackagent_webui/static/_next/static/chunks/app/stats/page-457e2fc0286253b9.js +0 -1
  75. hackagent_webui/static/_next/static/css/99e7387e28657839.css +0 -1
  76. hackagent_webui-0.5.26.dev65.dist-info/RECORD +0 -75
  77. /hackagent_webui/static/_next/static/{U7s5LqEUH8gEO4-nmwKZH → LQR5ZJKBJglYlSbR2x_0w}/_ssgManifest.js +0 -0
  78. {hackagent_webui-0.5.26.dev65.dist-info → hackagent_webui-0.6.0.dev67.dist-info}/WHEEL +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[266],{22470:(e,t,a)=>{"use strict";a.d(t,{M:()=>r});var n=a(95155);a(12115);let r=e=>{let{title:t,description:a,action:r,children:l,maxWidth:s="full",compact:o=!1}=e;return(0,n.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"}[s]||"max-w-full"," mx-auto ").concat(o?"py-3 space-y-3":"py-6 space-y-6"),children:[t&&(0,n.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,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:t}),a&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:a})]}),r&&(0,n.jsx)("div",{className:"flex-shrink-0 pt-0.5",children:r})]}),l]})}},35835:(e,t,a)=>{"use strict";a.d(t,{T:()=>l});var n=a(95155);a(12115);var r=a(98053);let l=e=>{let{open:t,onOpenChange:a,title:l,description:s,onConfirm:o,confirmText:i="Confirm",cancelText:c="Cancel",variant:d="default"}=e;return(0,n.jsx)(r.Lt,{open:t,onOpenChange:a,children:(0,n.jsxs)(r.EO,{children:[(0,n.jsxs)(r.wd,{children:[(0,n.jsx)(r.r7,{children:l}),(0,n.jsx)(r.$v,{children:s})]}),(0,n.jsxs)(r.ck,{children:[(0,n.jsx)(r.Zr,{children:c}),(0,n.jsx)(r.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:()=>s,ZI:()=>c,k$:()=>i,m_:()=>o});var n=a(95155);a(12115);var r=a(53583),l=a(64269);function s(e){let{delayDuration:t=0,...a}=e;return(0,n.jsx)(r.Kq,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function o(e){let{...t}=e;return(0,n.jsx)(s,{children:(0,n.jsx)(r.bL,{"data-slot":"tooltip",...t})})}function i(e){let{...t}=e;return(0,n.jsx)(r.l9,{"data-slot":"tooltip-trigger",...t})}function c(e){let{className:t,sideOffset:a=0,children:s,...o}=e;return(0,n.jsx)(r.ZL,{children:(0,n.jsxs)(r.UC,{"data-slot":"tooltip-content",sideOffset:a,className:(0,l.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:[s,(0,n.jsx)(r.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,86868))},51834:(e,t,a)=>{"use strict";a.d(t,{Cf:()=>u,Es:()=>x,HM:()=>c,L3:()=>p,c7:()=>m,lG:()=>o,rr:()=>g});var n=a(95155);a(12115);var r=a(88292),l=a(65229),s=a(64269);function o(e){let{...t}=e;return(0,n.jsx)(r.bL,{"data-slot":"dialog",...t})}function i(e){let{...t}=e;return(0,n.jsx)(r.ZL,{"data-slot":"dialog-portal",...t})}function c(e){let{...t}=e;return(0,n.jsx)(r.bm,{"data-slot":"dialog-close",...t})}function d(e){let{className:t,...a}=e;return(0,n.jsx)(r.hJ,{"data-slot":"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,children:a,...o}=e;return(0,n.jsxs)(i,{"data-slot":"dialog-portal",children:[(0,n.jsx)(d,{}),(0,n.jsxs)(r.UC,{"data-slot":"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),...o,children:[a,(0,n.jsxs)(r.bm,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,n.jsx)(l.A,{}),(0,n.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function m(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"dialog-header",className:(0,s.cn)("flex flex-col gap-2 text-center sm:text-left",t),...a})}function x(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"dialog-footer",className:(0,s.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...a})}function p(e){let{className:t,...a}=e;return(0,n.jsx)(r.hE,{"data-slot":"dialog-title",className:(0,s.cn)("text-lg leading-none font-semibold",t),...a})}function g(e){let{className:t,...a}=e;return(0,n.jsx)(r.VY,{"data-slot":"dialog-description",className:(0,s.cn)("text-muted-foreground text-sm",t),...a})}},65142:(e,t,a)=>{"use strict";a.d(t,{p:()=>l});var n=a(95155);a(12115);var r=a(64269);function l(e){let{className:t,type:a,...l}=e;return(0,n.jsx)("input",{type:a,"data-slot":"input",className:(0,r.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),...l})}},68600:(e,t,a)=>{"use strict";a.d(t,{LI:()=>v,Ld:()=>g,Oy:()=>o,UK:()=>d,_F:()=>h,aN:()=>i,dI:()=>m,gj:()=>b,on:()=>u});var n=a(12115),r=a(72903),l=a(41444);let s=new Set(["PENDING","RUNNING"]),o=e=>s.has(e.status);function i(e,t){return(function(e,t){let a=t.filter(t=>t.technique===e.technique).sort((e,t)=>e.created_at.localeCompare(t.created_at)||e.id.localeCompare(t.id));return"".concat(e.technique.toUpperCase()).concat(a.length>1?" (".concat(a.findIndex(t=>t.id===e.id)+1,")"):"")})(e,t).replace("STATIC_TEMPLATE","Static template").replace("BASELINE","Baseline").replace("FLIPATTACK","FlipAttack").replace("CIPHERCHAT","CipherChat").replace("CRESCENDO","Crescendo").replace("ADVPREFIX","AdvPrefix")}let c=["unresolved","mitigated","error","jailbroken"];function d(e){return e.goals.map((t,a)=>{let n=[];return e.runs.forEach((t,r)=>{var l,s,o;let i=null==(l=e.cells[a])?void 0:l[r];if(null==i)return;let d=c[i];if(!d)throw Error("Unknown outcome code ".concat(i," in the goal matrix."));n.push({run_id:t,verdict:d,attempts:null!=(o=null==(s=e.attempts[a])?void 0:s[r])?o:0})}),{...t,run_ids:n.map(e=>e.run_id),attack_outcomes:n}})}let u=["regressed","fixed","new","dropped","unchanged"],m="/api/proxy/run";async function x(e,t){let a=null;try{let t=await e.json();a=t&&"object"==typeof t&&"detail"in t?t.detail:null}catch(e){}return Error("".concat(t," (HTTP ").concat(e.status,")").concat("string"==typeof a&&a?": ".concat(a):"."))}async function p(e,t,a){let n=await fetch(e,{...t,headers:{...(0,r.b)(),...t.headers}});if(!n.ok)throw await x(n,a);return n}async function g(e,t){var a;let n=await p(e,{signal:t},"Could not load campaign runs");if(!(null==(a=n.headers.get("content-type"))?void 0:a.includes("application/json")))throw Error("The server returned campaign run data in an unexpected format.");return n.json()}async function h(e){await ("ids"in e?p("".concat(m,"/delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:e.ids})},"Deletion failed"):p("".concat(m,"/").concat(e.id),{method:"DELETE"},"Deletion failed"))}let f=(0,l.h)("CampaignRuns");function v(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:g,{pollWhile:r,version:l,versionOf:s}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},[o,i]=(0,n.useState)({url:null,data:null,error:null,version:void 0}),c=o.url===e&&null!==o.data,d=c&&!!(null==r?void 0:r(o.data)),u=(0,n.useRef)({poll:d,version:l,versionOf:s}),m=(0,n.useRef)(void 0),x=(0,n.useRef)(null);return(0,n.useEffect)(()=>{u.current={poll:d,version:l,versionOf:s}}),(0,n.useEffect)(()=>{let t;if(!e)return;let n=new AbortController,r=!1,l=!1,s=()=>{clearTimeout(t),t=void 0,!r&&u.current.poll&&"hidden"!==document.visibilityState&&(t=setTimeout(()=>o(!1),5e3))},o=c=>{clearTimeout(t),t=void 0,r=!0;let d=u.current.version;m.current=d,a(e,n.signal).then(t=>{var a,r,l;n.signal.aborted||i({url:e,data:t,error:null,version:null!=(l=null==(a=(r=u.current).versionOf)?void 0:a.call(r,t))?l:d})}).catch(t=>{!n.signal.aborted&&(f.error({err:t,url:e},"Failed to load campaign run data"),c&&i({url:e,data:null,error:t instanceof Error?t.message:"Failed to load campaign runs.",version:void 0}))}).finally(()=>{r=!1,n.signal.aborted||(l?(l=!1,o(!1)):s())})},c=()=>{"hidden"===document.visibilityState?(clearTimeout(t),t=void 0):!u.current.poll||r||t||o(!1)};return x.current={refresh:()=>{r?l=!0:o(!1)},schedule:s},i({url:e,data:null,error:null,version:void 0}),o(!0),document.addEventListener("visibilitychange",c),()=>{n.abort(),clearTimeout(t),document.removeEventListener("visibilitychange",c),x.current=null}},[e,t,a]),(0,n.useEffect)(()=>{var e;null==(e=x.current)||e.schedule()},[d]),(0,n.useEffect)(()=>{var e;c&&void 0!==l&&l!==o.version&&l!==m.current&&(null==(e=x.current)||e.refresh())},[c,l,o.version]),o.url===e?o:{url:e,data:null,error:null,version:void 0}}function b(e){let t=new URL(window.location.href);for(let[a,n]of Object.entries(e))if(Array.isArray(n))for(let e of(t.searchParams.delete(a),n))t.searchParams.append(a,e);else null===n||""===n?t.searchParams.delete(a):t.searchParams.set(a,n);window.history.replaceState(null,"","".concat(t.pathname).concat(t.search))}},86868:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>tF});var n=a(95155),r=a(12115),l=a(52619),s=a.n(l),o=a(20063),i=a(35299),c=a(71847);let d=(0,c.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 u=a(22470),m=a(34015),x=a(3998),p=a(68600);function g(e){let t=r.useRef(null),[a,n]=r.useState(e);return r.useEffect(()=>{let e=t.current;if(!e||"undefined"==typeof ResizeObserver)return;let a=()=>{e.clientWidth>0&&n(e.clientWidth)};a();let r=new ResizeObserver(a);return r.observe(e),()=>r.disconnect()},[]),[t,a]}let h={jailbroken:"var(--viz-jailbroken)",mitigated:"var(--viz-mitigated)",unresolved:"var(--viz-unresolved)",error:"var(--viz-error)"},f={static:"Static",adaptive:"Adaptive",multi_turn:"Multi-turn",indirect:"Indirect"},v=e=>"var(--viz-family-".concat(e&&f[e]?e:"other",")"),b=e=>[{name:"Jailbroken",value:e.jailbroken,color:h.jailbroken},{name:"Mitigated",value:e.mitigated,color:h.mitigated},{name:"Unresolved",value:e.unresolved,color:h.unresolved}];function j(e){let{label:t,values:a,max:r,color:l="currentColor",bars:s=!1}=e,o=null!=r?r:Math.max(1,...a.map(e=>null!=e?e:0)),i=e=>+(3+(1-e/o)*24).toFixed(2),c=a.flatMap((e,t)=>null===e?[]:["".concat(a.length>1?+(100*t/(a.length-1)).toFixed(2):50,",").concat(i(e))]);return(0,n.jsx)("svg",{role:"img","aria-label":t,viewBox:"0 0 100 30",preserveAspectRatio:"none",className:"h-8 w-full overflow-visible",style:{color:l},children:s?a.map((e,t)=>null===e?null:(0,n.jsx)("rect",{x:100*t/a.length+.6,width:Math.max(.8,100/a.length-1.2),y:i(e),height:27-i(e),fill:"currentColor",opacity:"0.75"},t)):(0,n.jsxs)(n.Fragment,{children:[c.length>1&&(0,n.jsx)("polygon",{points:"".concat(c[0].split(",")[0],",27 ").concat(c.join(" ")," ").concat(c[c.length-1].split(",")[0],",27"),fill:"currentColor",opacity:"0.12"}),(0,n.jsx)("polyline",{points:c.join(" "),fill:"none",stroke:"currentColor",strokeWidth:"1.75",vectorEffect:"non-scaling-stroke",strokeLinejoin:"round"})]})})}function y(e){let{label:t,segments:a,className:r="h-2"}=e,l=a.reduce((e,t)=>e+t.value,0);return(0,n.jsx)("div",{role:"img","aria-label":"".concat(t,": ").concat(a.map(e=>"".concat(e.name," ").concat(e.value)).join(", ")),className:"flex w-full overflow-hidden rounded-full bg-muted ".concat(r),children:l>0&&a.map(e=>(0,n.jsx)("span",{title:"".concat(e.name,": ").concat(e.value),className:"h-full",style:{width:"".concat(+(100*e.value/l).toFixed(2),"%"),backgroundColor:e.color}},e.name))})}function k(e){let{label:t,value:a,detail:r,children:l}=e;return(0,n.jsxs)("div",{className:"kpi-card",children:[(0,n.jsx)("p",{className:"kpi-label truncate",children:t}),(0,n.jsx)("p",{className:"kpi-value truncate",children:a}),(0,n.jsx)("p",{className:"min-h-8 text-xs leading-4 text-muted-foreground line-clamp-2",children:r}),(0,n.jsx)("div",{className:"flex h-8 items-end",children:l})]})}let N=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#d4a373","#2a9d8f","#e76f51"],w=/unclassified|unknown/i;function S(e){let{info:t,className:a=""}=e;return t?(0,n.jsx)("span",{"aria-hidden":"true",title:t.name,className:"inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded px-1 text-[10px] font-semibold leading-none text-white ".concat(a),style:{backgroundColor:t.color},children:t.code}):null}function C(e){if(null==e||!Number.isFinite(e))return"—";let t=Math.abs(e);return t>=1e6?"".concat((e/1e6).toFixed(t>=1e7?0:1),"M"):t>=1e4?"".concat((e/1e3).toFixed(0),"k"):t>=1e3?"".concat((e/1e3).toFixed(1),"k"):t>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function _(e){if(null==e||!Number.isFinite(e))return"—";if(e<1)return"".concat(Math.round(1e3*e)," ms");if(e<60)return"".concat(e.toFixed(+(e<10))," s");let t=Math.round(e/60);if(t<60)return"".concat(t," min");let a=Math.floor(t/60);return"".concat(a," h ").concat(t%60," min")}let A={target:"var(--viz-role-target)",attacker:"var(--viz-role-attacker)",judge:"var(--viz-role-judge)"};function M(e){let{items:t}=e;return(0,n.jsx)("ul",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground","aria-label":"Legend",children:t.map(e=>(0,n.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-2.5 w-2.5 rounded-sm",style:{backgroundColor:e.color}}),e.name]},e.name))})}let L=e=>e&&e.recorded_goals>0?100*e.jailbroken/e.recorded_goals:null,R={cloud:{label:"Cloud",title:"Executed on HackAgent cloud"},local:{label:"Local",title:"Executed on a local machine, launched from the dashboard"},cli:{label:"CLI",title:"Executed from the command line"}};function z(e){var t;let{executor:a}=e,r=null!=(t=R[a])?t:{label:a,title:"Executed by ".concat(a)};return(0,n.jsx)("span",{title:r.title,"aria-label":"Executor: ".concat(r.label),className:"inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-[11px] font-medium leading-none text-muted-foreground",children:r.label})}let E={COMPLETED:"bg-emerald-500",RUNNING:"bg-sky-500 animate-pulse",PENDING:"bg-slate-400",FAILED:"bg-rose-500"};function F(e){var t;let{status:a}=e;return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-2 w-2 rounded-full ".concat(null!=(t=E[a])?t:"bg-amber-500")}),a.charAt(0)+a.slice(1).toLowerCase()]})}function I(e){let{campaign:t,costs:a}=e,r=t.category_outcomes.filter(e=>/unclassified|unknown/i.test(e.category)).reduce((e,t)=>e+t.recorded_goals,0),l=t.runs.map(e=>{var t;return{run:e,value:L(null!=(t=e.outcomes)?t:void 0)}}).filter(e=>null!==e.value).sort((e,t)=>t.value-e.value),s=L(t),o=function(e){if(!(null==e?void 0:e.runs.length))return null;let t=t=>e.runs.reduce((e,a)=>{var n;return e+(null!=(n=t(a))?n: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,p.aN)(a,t.runs):e};return(0,n.jsxs)("section",{"aria-label":"Campaign outcomes",className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted-foreground",children:[(0,n.jsx)(F,{status:t.status}),(0,n.jsx)(z,{executor:t.executor}),(0,n.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,n.jsx)("span",{children:t.target}),(0,n.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,n.jsx)("time",{children:new Date(t.created_at).toLocaleString()}),o&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,n.jsxs)("span",{children:[_(o.elapsed)," of attack time"]})]})]}),(0,n.jsxs)("div",{className:"grid auto-rows-fr grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6",children:[(0,n.jsx)(k,{label:"Attack success rate",value:null===s?"Not measured":"".concat(s.toFixed(1),"%"),detail:"".concat(t.jailbroken," of ").concat(t.recorded_goals," goals broken by at least one attack"),children:(0,n.jsx)(y,{label:"Goal outcomes",segments:b(t)})}),(0,n.jsx)(k,{label:"Goals",value:t.recorded_goals,detail:"".concat(t.recorded_goals-r," classified \xb7 ").concat(r," unclassified"),children:(0,n.jsx)(y,{label:"Goal classification",segments:[{name:"Classified",value:t.recorded_goals-r,color:"var(--viz-family-static)"},{name:"Unclassified",value:r,color:"var(--viz-error)"}]})}),(0,n.jsx)(k,{label:"Attacks",value:t.attack_runs,detail:l.length?"best: ".concat((0,p.aN)(l[0].run,t.runs)," ").concat(l[0].value.toFixed(0),"%"):"No attack outcomes",children:(0,n.jsx)("div",{className:"w-full",style:{color:l[0]?v(l[0].run.family):void 0},children:(0,n.jsx)(j,{bars:!0,max:100,values:l.map(e=>e.value),label:"ASR per attack, best first: ".concat(l.map(e=>"".concat((0,p.aN)(e.run,t.runs)," ").concat(e.value.toFixed(1),"%")).join(", "))})})}),(0,n.jsx)(k,{label:"LLM calls",value:null===i?t.attempts.toLocaleString():C(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,n.jsx)(y,{label:"LLM calls by role",segments:[{name:"Target",value:o.target,color:A.target},{name:"Attacker",value:o.attacker,color:A.attacker},{name:"Judge",value:o.judge,color:A.judge}]})}),(0,n.jsx)(k,{label:"Target tokens",value:c?C(c):"Not recorded",detail:c?"".concat(C(o.prompt)," prompt \xb7 ").concat(C(o.completion)," completion"):"the target did not report usage",children:c?(0,n.jsx)(y,{label:"Target tokens",segments:[{name:"Prompt",value:o.prompt,color:A.target},{name:"Completion",value:o.completion,color:"var(--viz-family-adaptive)"}]}):null}),(0,n.jsx)(k,{label:"Attack time",value:o?_(o.elapsed):"Not recorded",detail:d[0]?"longest: ".concat(u(d[0].run_id)," ").concat(_(d[0].elapsed_s)):"first to last stored result",children:d.length>0&&(0,n.jsx)("div",{className:"w-full text-muted-foreground",children:(0,n.jsx)(j,{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(_(e.elapsed_s))).join(", "))})})})]})]})}var T=a(46767);let O="rounded-lg border bg-muted/10 p-3",P="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",D="border-foreground/40 bg-muted/60 ring-1 ring-foreground/20";function U(e){let{description:t,children:a,onSelect:l,selected:s,opacity:o=1}=e,[i,c]=(0,r.useState)(!1),d=()=>{c(!0),null==l||l()};return(0,n.jsxs)(T.m_,{open:i,onOpenChange:c,children:[(0,n.jsx)(T.k$,{asChild:!0,children:(0,n.jsx)("g",{role:l?"button":"group",tabIndex:0,"aria-label":t.replace(/\s+/g," "),"aria-pressed":s,opacity:o,className:"cursor-pointer outline-offset-2",onClick:d,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),d())},children:a})}),(0,n.jsx)(T.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 H=a(26333);let W=e=>Math.sign(e)*(1>=Math.abs(e)?Math.abs(e):1+Math.log(Math.abs(e))),G=e=>Math.sign(e)*(1>=Math.abs(e)?Math.abs(e):Math.exp(Math.abs(e)-1)),q=(e,t)=>null!=e&&(null==t?void 0:t.goals)?e/t.goals:null,J=(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 n;return e+(null!=(n=a[t])?n:0)},0)/a.length},K={attempts:{label:"Attempts",axis:"Attempts per goal",unit:"attempts per goal",format:e=>e.toFixed(1),tick:C,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:C,value:(e,t)=>(null==t?void 0:t.goal_samples)?J(t,"calls"):(null==t?void 0:t.calls_traced)&&null!==t.calls.attacker&&null!==t.calls.judge?q(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:C,tick:C,value:(e,t)=>(null==t?void 0:t.goal_samples)?J(t,"target_tokens"):q((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:_,tick:_,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}}},B=["target","attacker","judge"];function $(e){let{campaign:t,costs:a}=e;return(0,n.jsx)(V,{campaign:t,costs:a})}function V(e){let{campaign:t,costs:a,firstSuccess:r=!1}=e,[l,s]=g(1100),o=r?["first_attempt","first_time"]:["calls","tokens","attempts","time"],i={...K,first_attempt:{label:"Attempts to first jailbreak",format:e=>e.toFixed(1),tick:C},first_time:{label:"Time to first jailbreak",format:_,tick:_}},c=t.runs.map(e=>{var t;return{run:e,rate:L(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,n;return(null!=(a=t.rate)?a:-1)-(null!=(n=e.rate)?n:-1)}),d=o.map(e=>{let t=c.map(t=>{var a;let{cost:n}=t;return(null!=(a=null==n?void 0:n.goal_samples)?a:[]).flatMap(t=>{if(r&&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,n=t.length?Math.max(...t):1,r=W(a),l=W(n)-r,s=e=>l?Math.max(0,Math.min(1,(W(e)-r)/l)):.5,o=[a];if(n>a){for(let e of function(e,t){let a=[];for(let n=Math.floor(Math.log10(e));n<=Math.ceil(Math.log10(t));n+=1)for(let r of[1,2,5]){let l=r*10**n;l>=e&&l<=t&&a.push(+l.toPrecision(3))}return a}(Math.max(a,n<1?n/100:1),n))s(e)-s(o[o.length-1])>=.25&&.75>=s(e)&&o.push(e);o.push(n)}return{min:a,max:n,ticks:o,position:s}}(t.flat())}}),u=Math.max(r?720:1120,s),m=r?190:160,x=(u-m-16*o.length)/o.length,h=r?80:68,f=56+c.length*h,b=f+42;return(0,n.jsxs)("figure",{className:"min-w-0 space-y-3","aria-label":r?"First-success distributions ranked by ASR":"Cost distributions ranked by ASR",children:[(0,n.jsx)("div",{ref:l,className:"overflow-x-auto rounded-lg border",children:(0,n.jsxs)("svg",{width:u,height:b,className:"block",role:"group","aria-label":r?"Per-goal first-success violins":"Per-goal cost violins",children:[(0,n.jsx)("text",{x:16,y:24,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:"Attack \xb7 ASR"}),(0,n.jsx)("text",{x:16,y:42,fontSize:10,fill:"var(--muted-foreground)",children:"Highest success first"}),c.map((e,a)=>{var l,s,o,i;let{run:c,rate:d}=e,m=56+a*h;return(0,n.jsxs)("g",{"aria-label":"".concat((0,p.aN)(c,t.runs),": ").concat(null===d?"ASR not recorded":"".concat(d.toFixed(1),"% ASR")),children:[a%2==0&&(0,n.jsx)("rect",{x:0,y:m,width:u,height:h,fill:"var(--muted)",fillOpacity:.35}),(0,n.jsx)("text",{x:16,y:m+26,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:(0,p.aN)(c,t.runs)}),(0,n.jsx)("text",{x:16,y:m+44,fontSize:11,fill:"var(--muted-foreground)",children:null===d?"Not recorded":"".concat(d.toFixed(1),"%")}),r&&(0,n.jsxs)("text",{x:16,y:m+62,fontSize:10,fill:"var(--muted-foreground)",children:["Succeeded: ",null!=(o=null==(l=c.outcomes)?void 0:l.jailbroken)?o:"–","/",null!=(i=null==(s=c.outcomes)?void 0:s.recorded_goals)?i:"–"," goals"]})]},c.id)}),d.map((e,a)=>{let{metric:l,samples:s,min:o,max:d,ticks:u,position:g}=e,j=i[l],y=m+a*(x+16),k=e=>y+18+g(e)*(x-44);return(0,n.jsxs)("g",{role:"group","aria-label":"".concat(j.label," distributions"),"data-domain-min":o,"data-domain-max":d,children:[(0,n.jsx)("rect",{"aria-hidden":"true",x:y+x,y:0,width:16,height:b,fill:"var(--background)"}),(0,n.jsx)("rect",{"data-cost-panel":l,"aria-hidden":"true",x:y,y:1,width:x,height:b-2,rx:8,fill:"none",stroke:"var(--border)",strokeWidth:1.5}),(0,n.jsx)("path",{"aria-hidden":"true",d:"M".concat(y+1,",").concat(56,"H").concat(y+x-1," M").concat(y+1,",").concat(f,"H").concat(y+x-1),stroke:"var(--border)"}),(0,n.jsx)("text",{x:y+x/2,y:26,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--foreground)",children:j.label}),(0,n.jsx)("text",{x:y+x/2,y:43,textAnchor:"middle",fontSize:10,fill:"var(--muted-foreground)",children:r?"successful goals \xb7 symlog":"per goal \xb7 symlog"}),u.map((e,t)=>(0,n.jsxs)("g",{"data-axis-tick":e,children:[(0,n.jsx)("line",{x1:k(e),x2:k(e),y1:56,y2:f,stroke:"var(--border)",strokeDasharray:"2 5"}),(0,n.jsx)("text",{x:k(e),y:f+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:f,cost:b}=e,N=s[a],w=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,n=Math.floor(a);return t[n]+(t[Math.ceil(a)]-t[n])*(a-n)},n=a(.25),r=a(.5),l=a(.75),s=l-n,o=t.filter(e=>e>=n-1.5*s&&e<=l+1.5*s);return{q1:n,median:r,q3:l,low:o[0],high:o[o.length-1],n:t.length,outliers:t.filter(e=>e<n-1.5*s||e>l+1.5*s)}}(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],n=t[t.length-1],r=t.reduce((e,t)=>e+t,0)/t.length,l=Math.max(1.06*Math.sqrt(t.reduce((e,t)=>e+(t-r)**2,0)/t.length)*t.length**-.2,(n-a)/80),s=Array.from({length:65},(e,r)=>{let s=a+(n-a)*r/64;return{value:s,density:t.reduce((e,t)=>e+Math.exp(-.5*((s-t)/l)**2),0)}}),o=Math.max(...s.map(e=>e.density));return s.map(e=>({value:e.value,density:e.density/o}))}(N.map(W)),C=56+a*h+27,_=(0,p.aN)(f,t.runs),A="calls"===l&&(null==b?void 0:b.goals)?"\n\nRecorded mean calls per goal\n".concat(B.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")):"",M=w?"".concat(_," \xb7 ").concat(j.label," per goal\n\nMedian: ").concat(j.format(w.median),"\nMiddle 50%: ").concat(j.format(w.q1),"–").concat(j.format(w.q3),"\nRange: ").concat(j.format(Math.min(...N)),"–").concat(j.format(Math.max(...N)),"\nGoals measured: ").concat(N.length," of ").concat(r?null!=(d=null==(o=f.outcomes)?void 0:o.jailbroken)?d:N.length:null!=(u=null==b?void 0:b.goals)?u:N.length).concat(r?" successful goals":"").concat(A):"".concat(_," \xb7 ").concat(j.label,"\n\nNot recorded\nPer-goal measurements are required."),L=S.length?[...S.map(e=>"".concat(k(G(e.value)),",").concat(C-17*e.density)),...S.slice().reverse().map(e=>"".concat(k(G(e.value)),",").concat(C+17*e.density))].join(" "):"";return(0,n.jsxs)(U,{description:M,children:[(0,n.jsx)("rect",{x:y+2,y:56+a*h,width:x-4,height:h,fill:"transparent"}),w?(0,n.jsxs)(n.Fragment,{children:[L?(0,n.jsx)("polygon",{"data-violin":f.id,points:L,fill:v(f.family),fillOpacity:.35,stroke:v(f.family)}):(0,n.jsxs)("g",{"data-sparse":f.id,children:[(0,n.jsx)("line",{x1:k(Math.min(...N)),x2:k(Math.max(...N)),y1:C,y2:C,stroke:v(f.family)}),Array.from(new Set(N)).map(e=>(0,n.jsx)("circle",{cx:k(e),cy:C,r:3,fill:v(f.family)},e))]}),(0,n.jsx)("line",{"data-median-marker":f.id,x1:k(w.median),x2:k(w.median),y1:C-10,y2:C+10,stroke:"var(--foreground)",strokeWidth:2}),(0,n.jsxs)("text",{"data-median-label":f.id,x:k(w.median),y:C+29,textAnchor:.3>g(w.median)?"start":g(w.median)>.7?"end":"middle",fontSize:10,fill:"var(--muted-foreground)",children:["Median: ",j.format(w.median)]})]}):(0,n.jsx)("text",{x:y+x/2,y:C+4,textAnchor:"middle",fontSize:11,fill:"var(--muted-foreground)",children:r&&(null==(i=f.outcomes)?void 0:i.jailbroken)===0?"No jailbreak recorded":"Not recorded"}),r&&(0,n.jsxs)("text",{x:y+x/2,y:C+44,textAnchor:"middle",fontSize:10,fill:"var(--muted-foreground)",children:["Measured: ",N.length,"/",null!=(m=null==(c=f.outcomes)?void 0:c.jailbroken)?m:"–"," successful"]})]},f.id)})]},l)})]})}),(0,n.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.",r?"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,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"No attacks recorded in this campaign."})]})}function Z(e){var t,a;let{campaign:l,costs:s}=e,[o,i]=(0,r.useState)(()=>l.runs.map(e=>e.id)),[c,d]=g(700),u=[...l.runs].sort((e,t)=>{var a,n,r,l;return(null!=(n=L(null!=(a=t.outcomes)?a:void 0))?n:-1)-(null!=(l=L(null!=(r=e.outcomes)?r:void 0))?l:-1)}),m=u.filter(e=>o.includes(e.id)),x=function(e,t){let a=new Set,n=new Set,r=new Map,l=e.map(e=>{var a,n,r;let l=null==(a=t.runs.find(t=>t.run_id===e.id))?void 0:a.goal_samples;return!l||l.length!==(null==(n=e.outcomes)?void 0:n.recorded_goals)||new Set(l.map(e=>e.goal_index)).size!==l.length||l.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))||l.filter(e=>null!==e.first_jailbreak_attempt).length!==(null==(r=e.outcomes)?void 0:r.jailbroken)?null:{run:e,samples:l}});if(l.some(e=>null===e))return null;for(let e of l)if(e){for(let t of e.samples)if(a.add(t.goal_index),null!==t.first_jailbreak_attempt){var s;n.add(t.goal_index),r.set(t.goal_index,[...null!=(s=r.get(t.goal_index))?s:[],e.run.id])}}let o=e.map(e=>{var t,a;return{run:e,lost:Array.from(r.values()).filter(t=>1===t.length&&t[0]===e.id).length,tested:null!=(a=null==(t=l.find(t=>(null==t?void 0:t.run.id)===e.id))?void 0:t.samples.length)?a:0}}),i=Array.from(a).filter(e=>l.every(t=>null==t?void 0:t.samples.some(t=>t.goal_index===e))).length;return{tested:a.size,broken:n.size,remaining:a.size-n.size,fullyTested:i,contributions:o,asr:a.size?100*n.size/a.size:null}}(m,s),h=Math.max(520,d),f=h-86,b=[...null!=(a=null==x?void 0:x.contributions)?a:[]].sort((e,t)=>t.lost-e.lost),j=Math.max(1,...b.map(e=>e.lost));return(0,n.jsxs)("figure",{"aria-label":"Attack complementarity",className:"space-y-3 border-t pt-6",children:[(0,n.jsxs)("figcaption",{children:[(0,n.jsx)("h3",{className:"text-base font-semibold",children:"What does combining attacks gain?"}),(0,n.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,n.jsxs)("div",{className:"grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_17rem]",children:[(0,n.jsx)("div",{className:"min-w-0 space-y-4",children:m.length?x?x.tested?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{"aria-label":"Selected portfolio outcomes","aria-live":"polite",className:"grid grid-cols-3 gap-3 rounded-lg border p-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Combined ASR"}),(0,n.jsxs)("p",{className:"mt-1 text-xl font-semibold tabular-nums",children:[null==(t=x.asr)?void 0:t.toFixed(1),"%"]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Goals broken"}),(0,n.jsxs)("p",{className:"mt-1 text-xl font-semibold tabular-nums",children:[x.broken,"/",x.tested]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Not yet broken"}),(0,n.jsx)("p",{className:"mt-1 text-xl font-semibold tabular-nums",children:x.remaining})]}),(0,n.jsx)("div",{className:"col-span-3 flex h-3 overflow-hidden rounded-full bg-muted",role:"img","aria-label":"".concat(x.broken," goals broken and ").concat(x.remaining," not broken out of ").concat(x.tested," tested goals"),children:(0,n.jsx)("span",{style:{width:"".concat(x.asr,"%"),backgroundColor:"var(--viz-jailbroken)"}})}),(0,n.jsxs)("p",{className:"col-span-3 text-xs text-muted-foreground",children:["Tested by at least one selected attack: ",x.tested,"/",l.recorded_goals," campaign goals."," ","Tested by every selected attack: ",x.fullyTested,"/",x.tested,"."," ",Math.max(0,l.recorded_goals-x.tested)," goals not tested by this selection."]})]}),(0,n.jsx)("div",{ref:c,className:"min-w-0 overflow-x-auto rounded-lg border bg-background/50",children:(0,n.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,n.jsx)("text",{x:16,y:24,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:"Attack"}),(0,n.jsx)("text",{x:16,y:43,fontSize:10,fill:"var(--muted-foreground)",children:"Largest contribution first"}),(0,n.jsx)("text",{x:180,y:24,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:"Goals lost if removed"}),(0,n.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:r,tested:s}=e,o=64+48*t,i=(0,p.aN)(a,l.runs),c="".concat(i,": ").concat(r," goals lose coverage if removed; ").concat(s,"/").concat(x.tested," portfolio goals tested.");return(0,n.jsxs)(U,{description:c,children:[(0,n.jsx)("text",{x:16,y:o+13,fontSize:12,fill:"var(--foreground)",children:i}),(0,n.jsx)("rect",{x:180,y:o,width:f-180,height:18,rx:3,fill:"var(--muted)"}),(0,n.jsx)("rect",{x:180,y:o,width:r/j*(f-180),height:18,rx:3,fill:v(a.family)}),(0,n.jsxs)("text",{x:f+10,y:o+13,fontSize:11,fill:"var(--foreground)",children:[r," goals"]}),(0,n.jsxs)("text",{x:180,y:o+33,fontSize:10,fill:"var(--muted-foreground)",children:[(100*r/x.tested).toFixed(1)," pp of current coverage"]})]},a.id)})]})}),(0,n.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,n.jsx)("p",{role:"status",className:"rounded-lg border p-6 text-sm text-muted-foreground",children:"No tested goals recorded for this selection."}):(0,n.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,n.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,n.jsxs)("div",{role:"group","aria-label":"Portfolio attack selection",className:O,children:[(0,n.jsx)("p",{className:"mb-1 text-sm font-semibold",children:"Combine attacks"}),(0,n.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:"Choose any number. All attempts count."}),(0,n.jsxs)("div",{className:"mb-3 flex gap-3 text-xs",children:[(0,n.jsx)("button",{type:"button",className:"underline",onClick:()=>i(u.map(e=>e.id)),children:"Select all"}),(0,n.jsx)("button",{type:"button",className:"underline",onClick:()=>i([]),children:"Clear selection"})]}),(0,n.jsx)("div",{className:"grid gap-1 sm:grid-cols-2 lg:grid-cols-1",children:u.map(e=>{var t,a,r,s;return(0,n.jsxs)("label",{className:"".concat(P," ").concat(o.includes(e.id)?D:"border-transparent"),children:[(0,n.jsx)("input",{type:"checkbox","aria-label":"Include ".concat((0,p.aN)(e,l.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,n.jsxs)("span",{className:"min-w-0",children:[(0,n.jsx)("strong",{className:"block break-words",children:(0,p.aN)(e,l.runs)}),(0,n.jsxs)("span",{className:"block text-muted-foreground",children:[null!=(r=null==(t=e.outcomes)?void 0:t.jailbroken)?r:"–","/",null!=(s=null==(a=e.outcomes)?void 0:a.recorded_goals)?s:"–"," goals broken"]})]})]},e.id)})})]})]}),(0,n.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 Y(e){let{campaign:t,costs:a}=e,[l,s]=g(800),[o,i]=(0,r.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,n,r,l;return(null!=(n=L(null!=(a=t.outcomes)?a:void 0))?n:-1)-(null!=(l=L(null!=(r=e.outcomes)?r:void 0))?l:-1)}).map((e,t)=>({run:e,progression:function(e,t){let a=e.outcomes,n=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==n?void 0:n.length)||n.some(e=>void 0===e.first_jailbreak_attempt))return{available:!1,reason:"First-success summaries were not recorded for this attack."};let r=n.filter(e=>null!==e.first_jailbreak_attempt);if(n.length!==a.recorded_goals||r.length!==a.jailbroken||new Set(n.map(e=>e.goal_index)).size!==n.length||n.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 l=Math.max(...n.map(e=>e.attempts)),s=new Map;r.forEach(e=>{var t;let a=e.first_jailbreak_attempt;s.set(a,(null!=(t=s.get(a))?t:0)+1)});let o=0,i=[{attempt:0,percent:0},...Array.from(s).sort((e,t)=>{let[a]=e,[n]=t;return a-n}).map(e=>{let[t,n]=e;return{attempt:t,percent:100*(o+=n)/a.recorded_goals}})];return i[i.length-1].attempt!==l&&i.push({attempt:l,percent:100*o/a.recorded_goals}),{available:!0,denominator:a.recorded_goals,successes:o,maxAttempt:l,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),x=Math.max(1,...u.map(e=>e.progression.available?e.progression.maxAttempt:0)),h=Math.max(640,s),f=h-35,v=e=>62+e/x*(f-62),b=e=>280-e/100*258,j=Array.from(new Set([0,1,...[.25,.5,.75,1].map(e=>Math.round(x*e))])).sort((e,t)=>e-t);return(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsx)(V,{campaign:t,costs:a,firstSuccess:!0}),(0,n.jsxs)("figure",{"aria-label":"Cumulative success by recorded attempt",className:"space-y-3",children:[(0,n.jsxs)("figcaption",{children:[(0,n.jsx)("h3",{className:"text-base font-semibold",children:"What does continuing the search gain?"}),(0,n.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,n.jsxs)("div",{className:"grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_17rem]",children:[m.length>0&&(0,n.jsx)("div",{ref:l,className:"min-w-0 overflow-x-auto rounded-lg border bg-background/50",children:(0,n.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,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:62,x2:f,y1:b(e),y2:b(e),stroke:"var(--border)",strokeDasharray:"3 4"}),(0,n.jsxs)("text",{x:52,y:b(e)+4,textAnchor:"end",fontSize:11,fill:"var(--muted-foreground)",children:[e,"%"]})]},e)),j.map(e=>(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:v(e),x2:v(e),y1:280,y2:285,stroke:"var(--border)"}),(0,n.jsx)("text",{x:v(e),y:300,textAnchor:"middle",fontSize:11,fill:"var(--muted-foreground)",children:e})]},e)),(0,n.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,n.jsx)("text",{x:(62+f)/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:r,color:l,dash:s}=e;if(!r.available)return null;let i=(0,p.aN)(a,t.runs),d=r.points[r.points.length-1],u="M ".concat(v(0)," ").concat(b(0));r.points.slice(1).forEach(e=>{u+=" H ".concat(v(e.attempt)," V ").concat(b(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,r);return(0,n.jsxs)(U,{description:m,onSelect:()=>c(a.id),selected:o===a.id,opacity:o&&o!==a.id?.25:1,children:[(0,n.jsx)("path",{d:u,fill:"none",stroke:l,strokeWidth:o===a.id?3:2,strokeDasharray:s}),(0,n.jsx)("path",{d:u,fill:"none",stroke:"transparent",strokeWidth:14}),(0,n.jsx)("circle",{cx:v(d.attempt),cy:b(d.percent),r:4,fill:l,"data-progression-run":a.id,"data-endpoint-asr":d.percent,"data-endpoint-attempt":d.attempt})]},a.id)})]})}),(0,n.jsxs)("div",{role:"group","aria-label":"Cumulative success legend",className:O,children:[(0,n.jsx)("p",{className:"mb-1 text-sm font-semibold",children:"Attacks"}),(0,n.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:"Select one to highlight its curve."}),(0,n.jsx)("div",{className:"grid gap-1 sm:grid-cols-2 lg:grid-cols-1",children:u.map(e=>{let{run:a,progression:r,color:l,dash:s}=e,i=(0,p.aN)(a,t.runs),d=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("svg",{"aria-hidden":"true",width:24,height:14,className:"shrink-0",children:(0,n.jsx)("line",{x1:0,x2:24,y1:7,y2:7,stroke:l,strokeWidth:3,strokeDasharray:s})}),(0,n.jsxs)("span",{className:"min-w-0",children:[(0,n.jsx)("strong",{className:"block break-words",children:i}),r.available?(0,n.jsxs)("span",{className:"block text-muted-foreground",children:[(100*r.successes/r.denominator).toFixed(1),"% \xb7 ",r.successes,"/",r.denominator," goals"]}):(0,n.jsx)("span",{className:"block text-muted-foreground",children:r.reason})]})]});return r.available?(0,n.jsx)("button",{type:"button","aria-label":"Highlight ".concat(i," curve"),"aria-pressed":o===a.id,onClick:()=>c(a.id),className:"".concat(P," ").concat(o===a.id?D:"border-transparent"),children:d},a.id):(0,n.jsx)("div",{className:"flex items-start gap-2 p-2 text-xs",children:d},a.id)})}),(0,n.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,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"No attacks with multiple recorded attempts for a goal in this campaign."}),(0,n.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,n.jsx)(Z,{campaign:t,costs:a})]})}let Q=e=>"".concat((100*e).toFixed(1),"%"),X=e=>e.toFixed(3),ee=e=>"panel"===e?"Panel":e,et={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."},ea=e=>void 0!==e&&Number.isFinite(e)&&e>=0&&e<=1?e:null;function en(e){let{judges:t,plots:a,label:r}=e,[l,s]=g(1e3),o=Math.max(170+241*a.length,s),i=(o-170-16*a.length)/a.length,c=56+68*t.length,d=c+42;return(0,n.jsx)("div",{ref:l,className:"min-w-0 overflow-x-auto rounded-lg border",children:(0,n.jsxs)("svg",{width:o,height:d,className:"block",role:"group","aria-label":r,children:[(0,n.jsx)("text",{x:16,y:24,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:"Judge / panel"}),(0,n.jsx)("text",{x:16,y:42,fontSize:10,fill:"var(--muted-foreground)",children:"Individual judges, then panel"}),t.map((e,t)=>(0,n.jsxs)("g",{"data-audit-row":e.judge,children:[(t%2==0||"panel"===e.judge)&&(0,n.jsx)("rect",{x:0,y:56+68*t,width:o,height:68,fill:"var(--muted)",fillOpacity:.35}),(0,n.jsx)("text",{x:16,y:56+68*t+27,fontSize:12,fontWeight:600,fill:"var(--foreground)",children:ee(e.judge)}),(0,n.jsxs)("text",{x:16,y:56+68*t+45,fontSize:10,fill:"var(--muted-foreground)",children:[e.metrics.samples," samples","panel"===e.judge?" \xb7 combined verdict":""]})]},e.judge)),a.map((e,a)=>{let r=170+a*(i+16),l=t=>(t-e.min)/(e.max-e.min),s=e=>r+18+l(e)*(i-44);return(0,n.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:[(0,n.jsx)("rect",{x:r,y:1,width:i,height:d-2,rx:8,fill:"none",stroke:"var(--border)",strokeWidth:1.5}),(0,n.jsx)("path",{d:"M".concat(r+1,",").concat(56,"H").concat(r+i-1," M").concat(r+1,",").concat(c,"H").concat(r+i-1),stroke:"var(--border)"}),(0,n.jsx)("text",{x:r+i/2,y:26,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--foreground)",children:e.label}),(0,n.jsx)("text",{x:r+i/2,y:43,textAnchor:"middle",fontSize:10,fill:"var(--muted-foreground)",children:e.hint}),e.ticks.map((t,a)=>(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:s(t),x2:s(t),y1:56,y2:c,stroke:e.min<0&&0===t?"var(--muted-foreground)":"var(--border)",strokeDasharray:"2 5"}),(0,n.jsx)("text",{x:s(t),y:c+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:o,description:c,limit:d}=e.measure(t),u=56+68*a+27;return(0,n.jsxs)(U,{description:c,children:[(0,n.jsx)("rect",{x:r+2,y:56+68*a,width:i-4,height:68,fill:"transparent"}),null!==o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("line",{x1:s(0),x2:s(o),y1:u,y2:u,stroke:"var(--viz-family-static)",strokeWidth:2,strokeOpacity:.4}),(0,n.jsx)("circle",{"data-audit-marker":t.judge,"data-value":o,cx:s(o),cy:u,r:4,fill:"var(--viz-family-static)"}),(0,n.jsx)("text",{x:s(o),y:u+29,textAnchor:.3>l(o)?"start":l(o)>.7?"end":"middle",fontSize:10,fill:"var(--muted-foreground)",children:e.format(o)})]}):(0,n.jsx)("text",{x:r+i/2,y:u+4,textAnchor:"middle",fontSize:11,fill:"var(--muted-foreground)",children:"Not recorded"}),void 0!==d&&(0,n.jsx)("line",{"data-audit-limit":t.judge,x1:s(d),x2:s(d),y1:u-10,y2:u+10,stroke:"var(--foreground)",strokeWidth:2})]},t.judge)})]},e.id)})]})})}function er(e){var t;let{campaign:a}=e,r=a.audit,l=[...null!=(t=null==r?void 0:r.judges)?t:[]].sort((e,t)=>Number("panel"===e.judge)-Number("panel"===t.judge)),s=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!==ea(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:Q,measure(t){var a,n,r,l,s,o;let i=null==(a=t.robustness)?void 0:a.wrappers.find(t=>t.wrapper===e),c=ea(null==i?void 0:i.flip_rate),d=ea(null==(n=t.robustness)?void 0:n.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(ee(t.judge)," \xb7 ").concat(e.replace(/_/g," "),"\n\n").concat(null!=(r=et[e])?r:"Recorded content-preserving wrapper.","\nThe answer and its correct label stay unchanged.\n\nVerdicts changed: ").concat(null===c?"Not recorded":Q(c)).concat((null==i?void 0:i.flips)===void 0?"":" (".concat(i.flips,")"),"\nCorrect harmful detections hidden: ").concat(null!=(l=null==i?void 0:i.true_positive_evasions)?l:"Not recorded","\nShare of original correct harmful detections hidden: ").concat((null==i?void 0:i.true_positive_evasion_rate)===void 0?"Not recorded":Q(i.true_positive_evasion_rate),"\nHarmful verdict → safe: ").concat(null!=(s=null==i?void 0:i.detected_to_missed)?s:"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":Q(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?Q(t.robustness.any_wrapper_flip_rate):"Not recorded","\nConfigured maximum: ").concat(null===d?"Not recorded":Q(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.")}}}))}(l);return(0,n.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,n.jsxs)("header",{children:[(0,n.jsx)("p",{className:"section-eyebrow",children:"04 / Judge audit"}),(0,n.jsx)("h2",{className:"mt-2 text-xl font-semibold",children:"Can we trust the verdicts?"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Compare each judge, then the panel, on labelled examples and content-preserving wrappers."})]}),r?l.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("figure",{"aria-label":"Judge calibration plots",className:"space-y-3",children:[(0,n.jsxs)("figcaption",{children:[(0,n.jsx)("h3",{className:"text-base font-semibold",children:"Can judges distinguish harmful from safe?"}),(0,n.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,n.jsx)(en,{judges:l,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:X},{id:"detected",label:"Harmful detected",hint:"Higher is better \xb7 sensitivity",min:0,max:1,ticks:[0,.25,.5,.75,1],format:Q},{id:"accused",label:"Falsely accused",hint:"Lower is better \xb7 false positives",min:0,max:1,ticks:[0,.25,.5,.75,1],format:Q}].map(e=>({...e,measure(t){var a,n,r,l,s;let o=function(e){var t;let{tp:a,fp:n,tn:r,fn:l}=e,s=[a,n,r,l].every(e=>void 0!==e&&Number.isInteger(e)&&e>=0)&&void 0!==a&&void 0!==n&&void 0!==r&&void 0!==l&&a+n+r+l===e.samples,o=e.samples>0,i=s&&a+l>0?a/(a+l):null,c=s&&r+n>0?r/(r+n):null,d=null!==i&&null!==c,u=s?Math.sqrt((a+n)*(a+l)*(r+n)*(r+l)):0;return{precision:s?a+n>0?a/(a+n):null:o?e.precision:null,recall:s?i:o?e.recall:null,accuracy:s&&o?(a+r)/e.samples:o?e.accuracy:null,f1:s?2*a+n+l>0?2*a/(2*a+n+l):null:o&&null!=(t=e.f1)?t:null,specificity:c,balancedAccuracy:d?(i+c)/2:null,youdensJ:d?i+c-1:null,mcc:s&&u>0?(a*r-n*l)/u:null,falsePositiveRate:null===c?null:1-c,falseNegativeRate:null===i?null:1-i,negativePredictiveValue:s&&r+l>0?r/(r+l):null,validCounts:s}}(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(ee(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!=(n=c.fn)?n:"Not recorded","\nSafe falsely flagged (FP): ").concat(null!=(r=c.fp)?r:"Not recorded","\nSafe correctly passed (TN): ").concat(null!=(l=c.tn)?l:"Not recorded","\nAbstentions: ").concat(null!=(s=c.abstentions)?s:"Not recorded").concat(null===i?"\n\nValid counts and a nonzero class denominator are required for this statistic.":"")}}})),label:"Aligned judge calibration scores"}),(0,n.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,n.jsxs)("figure",{"aria-label":"Judge robustness plots",className:"space-y-3 border-t pt-6",children:[(0,n.jsxs)("figcaption",{children:[(0,n.jsx)("h3",{className:"text-base font-semibold",children:"Does wrapping the same answer change the verdict?"}),(0,n.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%."})]}),s.length?(0,n.jsx)(en,{judges:l,plots:s,label:"Aligned wrapper verdict-change rates"}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"No wrapper robustness measurements recorded."}),(0,n.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,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"No judge metrics recorded."}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"No audit recorded for this execution."})]})}var el=a(5917),es=a(75426);a(27063);var eo=a(81408);function ei(e){let{text:t,label:a}=e,[l,s]=(0,r.useState)(!1);return(0,n.jsxs)(x.$,{variant:"ghost",size:"sm","aria-label":a,onClick:()=>{var e;null==(e=navigator.clipboard)||e.writeText(t).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})},children:[l?(0,n.jsx)(el.A,{className:"mr-2 h-4 w-4"}):(0,n.jsx)(es.A,{className:"mr-2 h-4 w-4"}),l?"Copied":"Copy"]})}function ec(e){let{text:t,label:a}=e;return(0,n.jsxs)("div",{className:"relative rounded-md border bg-muted/40",children:[(0,n.jsx)("div",{className:"absolute right-1 top-1",children:(0,n.jsx)(ei,{text:t,label:"Copy ".concat(a)})}),(0,n.jsx)("pre",{"aria-label":a,className:"overflow-x-auto p-4 pr-24 font-mono text-xs leading-relaxed",children:t})]})}function ed(e){var t;let{campaign:a}=e;return a.configuration&&Object.keys(a.configuration).length?(0,n.jsxs)("details",{className:"investigation-panel p-4",children:[(0,n.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:"Campaign configuration (YAML)"}),(0,n.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,n.jsx)("div",{className:"mt-3",children:(0,n.jsx)(ec,{text:(t=a.configuration,(0,eo.As)(t,{lineWidth:0})),label:"Campaign configuration"})})]}):null}function eu(e){let{id:t,eyebrow:a,title:r,description:l,label:s,children:o}=e;return(0,n.jsxs)("section",{id:t,tabIndex:-1,"aria-label":s,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,n.jsxs)("header",{children:[(0,n.jsx)("p",{className:"section-eyebrow",children:a}),(0,n.jsx)("h2",{className:"mt-2 text-xl font-semibold",children:r}),(0,n.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:l})]}),o]})}let em=[{id:"campaign-coverage",label:"Coverage"},{id:"campaign-success",label:"Success progression"},{id:"campaign-cost",label:"Cost"},{id:"campaign-audit",label:"Judge audit"}];function ex(){let e=(0,r.useRef)(null),[t,a]=(0,r.useState)(em[0].id);return(0,r.useEffect)(()=>{let t=e.current,n=null==t?void 0:t.parentElement;if(!t||!n)return;let r=()=>{let e=t.getBoundingClientRect().bottom+17,r=em[0].id;for(let t of em){let a=n.querySelector("#".concat(t.id));a&&a.getBoundingClientRect().top<=e&&(r=t.id)}a(r)},l=()=>{n.style.setProperty("--campaign-navigation-height","".concat(t.getBoundingClientRect().height,"px")),r()};l();let s=new ResizeObserver(l);return s.observe(t),s.observe(n),document.addEventListener("scroll",r,!0),window.addEventListener("resize",l),()=>{s.disconnect(),document.removeEventListener("scroll",r,!0),window.removeEventListener("resize",l),n.style.removeProperty("--campaign-navigation-height")}},[]),(0,n.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,n.jsx)("div",{className:"flex min-w-max items-center gap-5 px-1",children:em.map(e=>(0,n.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 n=document.getElementById(e.id);n&&(n.scrollIntoView({block:"start"}),n.focus({preventScroll:!0}),a(e.id))},children:e.label},e.id))})})}function ep(e){let{campaign:t,costs:a,costStatus:r,coverage:l,conversationsAvailable:s=!0}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(I,{campaign:t,costs:a}),(0,n.jsx)(ex,{}),(0,n.jsx)(eu,{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(s?", or select a goal's outcome marker to open its conversation.":". Conversations are not included in this offline snapshot."),children:l}),(0,n.jsx)(eu,{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,n.jsx)(Y,{campaign:t,costs:a}):r}),(0,n.jsx)(eu,{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,n.jsx)($,{campaign:t,costs:a}):r}),(0,n.jsx)(er,{campaign:t}),(0,n.jsx)(ed,{campaign:t}),t.notes&&(0,n.jsxs)("details",{className:"investigation-panel p-4",children:[(0,n.jsx)("summary",{className:"cursor-pointer text-sm",children:"Campaign notes"}),(0,n.jsx)("p",{className:"mt-3 whitespace-pre-wrap text-sm",children:t.notes})]})]})}var eg=a(65229),eh=a(24033),ef=a(27937),ev=a(51834),eb=a(78874),ej=a(61362);let ey=(0,c.A)("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);var ek=a(52056);let eN=(0,c.A)("circle-help",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function ew(e){let{value:t}=e,a="jailbroken"===t||"jailbreak"===t,r="mitigated"===t,l="pruned"===t||"skipped"===t,s="error"===t,o=a?eb.A:r?ej.A:l?ey:s?ek.A:eN,i=a?"Jailbroken":r?"Mitigated":l?"pruned"===t?"Pruned":"Skipped":s?"Error":"pending"===t?"Pending":"Unresolved";return(0,n.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium ".concat(a?"border-rose-200 bg-rose-50 text-rose-800 dark:border-rose-700 dark:bg-rose-950 dark:text-rose-200":r?"border-teal-200 bg-teal-50 text-teal-800 dark:border-teal-700 dark:bg-teal-950 dark:text-teal-200":l?"border-slate-300 bg-slate-100 text-slate-700 dark:border-slate-500 dark:bg-slate-700 dark:text-slate-100":"border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-600 dark:bg-amber-950 dark:text-amber-200"),children:[(0,n.jsx)(o,{className:"h-3 w-3","aria-hidden":"true"}),i]})}var eS=a(65142);let eC=["Categories","Subcategories","Goals"];function e_(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")}}function eA(e){var t;return null!=(t=eC.find(t=>t===e.get("granularity")))?t:null}function eM(e,t){var a,n,r;return t?null!=(r=null==(n=e.attack_outcomes)||null==(a=n.find(e=>e.run_id===t))?void 0:a.verdict)?r:"untested":e.verdict}function eL(e,t){if(!t.length)return e.verdict;let a=t.map(t=>eM(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 eR(e){let{label:t,options:a,selected:r,onChange:l}=e;return(0,n.jsxs)("fieldset",{className:"min-w-0 space-y-2",children:[(0,n.jsxs)("legend",{className:"text-sm font-semibold",children:[t," (",r.length,")"]}),(0,n.jsx)("div",{className:"max-h-60 space-y-1 overflow-y-auto",children:a.map(e=>(0,n.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 rounded p-1.5 text-sm hover:bg-muted",children:[(0,n.jsx)("input",{type:"checkbox",className:"mt-0.5 shrink-0",checked:r.includes(e.value),onChange:t=>l(t.target.checked?[...r,e.value]:r.filter(t=>t!==e.value))}),(0,n.jsx)("span",{className:"min-w-0 break-words",children:e.label})]},e.value))})]})}function ez(e){let{filters:t,attacks:a,categories:r,subcategories:l,detailLevel:s,canExpand:o,filtering:i,radioId:c,searchInput:d,onChange:u,onDetail:m,onClear:p}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.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,n.jsxs)("div",{"aria-label":"Coverage toolbar",className:"flex flex-wrap items-center gap-2",children:[(0,n.jsxs)(H.AM,{children:[(0,n.jsx)(H.Wv,{asChild:!0,children:(0,n.jsxs)(x.$,{variant:"outline",children:["Attacks",t.attack.length?" (".concat(t.attack.length,")"):"",(0,n.jsx)(eh.A,{"aria-hidden":"true",className:"h-4 w-4"})]})}),(0,n.jsxs)(H.hl,{align:"start","aria-label":"Attack filters",children:[(0,n.jsx)(eR,{label:"Attacks",selected:t.attack,options:a,onChange:e=>u({attack:e})}),(0,n.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,n.jsxs)(H.AM,{children:[(0,n.jsx)(H.Wv,{asChild:!0,children:(0,n.jsxs)(x.$,{variant:"outline",children:["Topics",t.category.length+t.subcategory.length?" (".concat(t.category.length+t.subcategory.length,")"):"",(0,n.jsx)(eh.A,{"aria-hidden":"true",className:"h-4 w-4"})]})}),(0,n.jsxs)(H.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,n.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,n.jsx)(eR,{label:"Categories",selected:t.category,options:r.map(e=>({value:e,label:e})),onChange:e=>u({category:e})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-3",children:[(0,n.jsxs)("h3",{className:"text-sm font-semibold",children:["Subcategories (",t.subcategory.length,")"]}),!t.category.length&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Select a category first."}),l.map(e=>(0,n.jsx)(eR,{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,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Match any selection within each group. No selection includes all."})]})]}),(0,n.jsxs)(H.AM,{children:[(0,n.jsx)(H.Wv,{asChild:!0,children:(0,n.jsxs)(x.$,{variant:"outline",children:["Outcomes",t.outcome.length?" (".concat(t.outcome.length,")"):"",(0,n.jsx)(eh.A,{"aria-hidden":"true",className:"h-4 w-4"})]})}),(0,n.jsxs)(H.hl,{align:"start","aria-label":"Outcome filters",children:[(0,n.jsx)(eR,{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,n.jsx)("p",{className:"mt-3 text-xs text-muted-foreground",children:"Match any selected outcome, combining selected attacks. No selection includes all outcomes."})]})]}),(0,n.jsxs)(H.AM,{children:[(0,n.jsx)(H.Wv,{asChild:!0,children:(0,n.jsxs)(x.$,{variant:"outline",children:["Detail: ",null!=s?s:"Custom",(0,n.jsx)(eh.A,{"aria-hidden":"true",className:"h-4 w-4"})]})}),(0,n.jsx)(H.hl,{align:"start","aria-label":"Coverage detail",children:(0,n.jsxs)("fieldset",{className:"space-y-2",children:[(0,n.jsx)("legend",{className:"text-sm font-semibold",children:"Detail level"}),eC.map(e=>(0,n.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 rounded p-1.5 text-sm hover:bg-muted",children:[(0,n.jsx)("input",{type:"radio",name:"granularity-".concat(c),disabled:!o,checked:s===e,onChange:()=>m(e)}),e]},e)),null===s&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Custom: rows expanded individually."})]})})]}),(0,n.jsx)(x.$,{size:"sm",variant:"ghost",className:"ml-auto",disabled:!i&&"Categories"===s,onClick:p,children:"Clear all"})]})]})}let eE={jailbroken:h.jailbroken,mitigated:"color-mix(in srgb, var(--viz-mitigated) 38%, var(--card))",unresolved:h.unresolved,error:h.error,untested:"var(--muted)"};function eF(e){let{children:t,header:a}=e,l=(0,r.useRef)(null),s=(0,r.useRef)(null),[o,i]=(0,r.useState)({category:"",subcategory:""});return(0,r.useEffect)(()=>{let e=()=>{if(!l.current||!s.current)return;let e=s.current.getBoundingClientRect().bottom,t="",a="";for(let s of Array.from(l.current.querySelectorAll("tr[data-category]"))){var n,r;if(s.getBoundingClientRect().top>e)break;void 0===s.dataset.subcategory?(t=null!=(n=s.dataset.category)?n:"",a=""):(t=null!=(r=s.dataset.category)?r:"",a=s.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,n.jsxs)("div",{ref:l,children:[(0,n.jsxs)("div",{ref:s,"aria-label":"Current coverage group",className:"sticky top-[var(--campaign-navigation-height,0px)] z-30 bg-card text-xs shadow-sm",children:[a,(0,n.jsxs)("div",{className:"border-b px-3 py-2",children:[(0,n.jsx)("div",{className:"font-semibold",children:o.category||"Goal coverage"}),(0,n.jsx)("div",{className:"pl-3 text-muted-foreground",children:o.subcategory||"\xa0"})]})]}),t]})}function eI(e){let{goals:t,runId:a,label:r,attacks:l}=e,s=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n={recorded_goals:0,jailbroken:0,mitigated:0,unresolved:0};for(let r of e){let e=t?eM(r,t):eL(r,a);"untested"!==e&&(n.recorded_goals++,"jailbroken"===e?n.jailbroken++:"mitigated"===e?n.mitigated++:n.unresolved++)}return n}(t,a,l),o=L(s),i=null===o?"Not tested":"".concat(o.toFixed(1),"%"),c="".concat(s.jailbroken,"/").concat(s.recorded_goals," goals jailbroken \xb7 ").concat(s.unresolved," unresolved");return(0,n.jsxs)("span",{"aria-label":"".concat(r,": ").concat(i),tabIndex:0,title:null===o?"".concat(r,"\n\nNot tested\nNo recorded attempts"):"".concat(r,"\n\nASR: ").concat(i,"\nJailbroken goals: ").concat(s.jailbroken," of ").concat(s.recorded_goals,"\nUnresolved goals: ").concat(s.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,n.jsxs)("span",{className:"sr-only",children:[" \xb7 ",null===o?"No recorded attempts":c]})]})}let eT=()=>{};function eO(e){var t,a,l,s;let{campaign:o,recordedGoals:i,query:c="",onSelectionChange:d=eT,renderEvidence:u,status:m}=e,g=void 0!==u,h=function(e,t,a){let[n,l]=(0,r.useState)(()=>e_(new URLSearchParams(t))),[s,o]=(0,r.useState)(()=>eA(new URLSearchParams(t))),[i,c]=(0,r.useState)(()=>new Set),d=(0,r.useRef)(!1),u=(0,r.useRef)(!1),m=(0,r.useMemo)(()=>[...e].sort((e,t)=>e.index-t.index),[e]),x=Object.values(n).some(e=>Array.isArray(e)?e.length>0:!!e),p=(0,r.useMemo)(()=>m.filter(e=>(!n.search||e.goal.toLocaleLowerCase().includes(n.search.toLocaleLowerCase()))&&(!n.category.length||n.category.includes(e.category))&&(!n.subcategory.length||n.subcategory.includes(e.subcategory||"Unspecified Subcategory"))&&(!n.outcome.length||n.outcome.includes(eL(e,n.attack)))),[m,n]),g=(0,r.useMemo)(()=>{let e=new Map;for(let t of p){e.has(t.category)||e.set(t.category,new Map);let a=e.get(t.category),n=t.subcategory||"Unspecified Subcategory";a.has(n)||a.set(n,[]),a.get(n).push(t)}return Array.from(e).sort((e,t)=>{let[a]=e,[n]=t;return a.localeCompare(n,void 0,{numeric:!0})}).map(e=>{let[t,a]=e;return{category:t,subcategories:Array.from(a).sort((e,t)=>{let[a]=e,[n]=t;return a.localeCompare(n,void 0,{numeric:!0})})}})},[p]),h=(0,r.useMemo)(()=>Array.from(new Set(m.map(e=>e.category))).sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0})),[m]),f=(0,r.useMemo)(()=>n.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,n.category]);(0,r.useEffect)(()=>{let e=e_(new URLSearchParams(t));l(t=>JSON.stringify(t)===JSON.stringify(e)?t:e),o(eA(new URLSearchParams(t)))},[t]),(0,r.useEffect)(()=>{if(d.current){d.current=!1;return}s?c(new Set(g.flatMap(e=>"Categories"===s?[]:[JSON.stringify([e.category]),..."Goals"===s?e.subcategories.map(t=>{let[a]=t;return JSON.stringify([e.category,a])}):[]]))):x?c(new Set(g.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=x},[g,x,s]);let v=g.map(e=>JSON.stringify([e.category])),b=g.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 k(e){let t={...n,...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))}l(t),a({...t,section:"overview",goal:null,conversation_attack:null,conversation_aggregate:null,attempt:null,node:null,goalPage:null})}return{goals:m,filters:n,granularity:s,expanded:i,setExpanded:c,filtering:x,matchingGoals:p,groups:g,categories:h,subcategoryGroups:f,detailLevel:y,changeFilters:k,toggleRow:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];d.current=null!==s,o(null),a({granularity:null}),c(a=>{let n=new Set(a);for(let e of t)n.delete(e);return n.has(e)?n.delete(e):n.add(e),n})},selectGranularity:function(e){o(e),c(new Set("Goals"===e?[...v,...b]:"Subcategories"===e?v:[])),a({granularity:e})},clearFilters:function(){k({search:"",category:[],subcategory:[],outcome:[],attack:[]}),o(null),a({granularity:null}),c(new Set)}}}(i,c,d),{goals:f,filters:v,granularity:b,expanded:j,setExpanded:y,filtering:k,matchingGoals:N,groups:w,categories:S,subcategoryGroups:C,detailLevel:_,toggleRow:A,selectGranularity:R}=h,z=(0,r.useId)(),E=(0,r.useRef)(null),[F,I]=(0,r.useState)(null),T=(0,r.useRef)(null),O=(0,r.useRef)(null),P=(0,r.useMemo)(()=>o.runs.map(e=>{var t;return{run:e,value:L(null!=(t=e.outcomes)?t:void 0)}}).sort((e,t)=>{var a,n;return(null!=(a=t.value)?a:-1)-(null!=(n=e.value)?n:-1)}).map(e=>e.run),[o.runs]),D=(0,r.useMemo)(()=>P.filter(e=>!v.attack.length||v.attack.includes(e.id)),[P,v.attack]),U=(0,r.useMemo)(()=>[{id:"",name:"Combined outcome"},...P.map(e=>({id:e.id,name:(0,p.aN)(e,o.runs),run:e}))],[P,o.runs]),H=U.filter(e=>e.id?!v.attack.length||v.attack.includes(e.id):D.length>1);(0,r.useEffect)(()=>{var e,t,a;let n=new URLSearchParams(c),r=n.get("goal");if(null===r||!/^\d+$/.test(r)||!Number.isSafeInteger(Number(r)))return void I(null);if(!g)return;let l=null!=(a=null!=(t=n.get("conversation_attack"))?t:n.get("attack"))?a:"",s=f.find(e=>e.index===Number(r));s&&y(e=>new Set([...Array.from(e),JSON.stringify([s.category]),JSON.stringify([s.category,s.subcategory||"Unspecified Subcategory"])])),I({goal:Number(r),run:l||function(e,t){var a,n;let r=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=r.find(t=>e&&"jailbroken"===eM(e,t.id)))?void 0:a.id)||(null==(n=r[0])?void 0:n.id)||""}(s,D)||(null==(e=D[0])?void 0:e.id)||"",aggregate:!l||"1"===n.get("conversation_aggregate")})},[c,g,f,D,y]);let W=e=>{h.changeFilters(e),I(null)},G=[...v.category.map(e=>({key:"category",label:"Category",value:e})),...v.subcategory.map(e=>({key:"subcategory",label:"Subcategory",value:e})),...v.attack.map(e=>{var t,a;return{key:"attack",label:"Attack",value:e,display:null!=(a=null==(t=U.find(t=>t.id===e))?void 0:t.name)?a:"Unknown attack (".concat(e,")")}}),...v.outcome.map(e=>({key:"outcome",label:"Outcome",value:e,display:"untested"===e?"Not tested":e}))].filter(e=>e.value),q=f.find(e=>e.index===(null==F?void 0:F.goal)),J=P.find(e=>e.id===(null==F?void 0:F.run)),K={minWidth:"".concat(Math.max(450,Math.ceil(44*H.length/.6)),"px")},B=(0,n.jsxs)("colgroup",{children:[(0,n.jsx)("col",{style:{width:"40%"}}),H.map(e=>(0,n.jsx)("col",{},e.id))]}),$=(0,n.jsxs)("tr",{className:"border-b bg-card",children:[(0,n.jsx)("th",{scope:"col",className:"sticky left-0 z-10 bg-card p-3 text-left",children:"Category / subcategory / goal"}),H.map(e=>(0,n.jsx)("th",{scope:"col",className:"bg-card px-1 py-3 align-bottom text-center",children:(0,n.jsx)("span",{title:e.id?e.name:"Jailbroken if any selected attack succeeded. With no attack selection, includes every campaign attack.",className:"inline-flex rotate-180 items-center gap-2 whitespace-nowrap [writing-mode:vertical-rl]",children:e.name})},e.id))]});return m?(0,n.jsx)(n.Fragment,{children:m}):(0,n.jsxs)("div",{className:"relative space-y-4",children:[(0,n.jsx)(ez,{filters:v,categories:S,subcategories:C,attacks:[...P.map(e=>({value:e.id,label:(0,p.aN)(e,o.runs)})),...v.attack.filter(e=>!P.some(t=>t.id===e)).map(e=>({value:e,label:"Unknown attack (".concat(e,")")}))],detailLevel:_,canExpand:w.length>0,filtering:k,radioId:z,searchInput:O,onChange:W,onDetail:R,onClear:()=>{h.clearFilters(),I(null)}}),(G.length>0||v.search)&&(0,n.jsxs)("div",{"aria-label":"Active goal filters",className:"flex flex-wrap gap-2",children:[v.search&&(0,n.jsxs)(x.$,{size:"sm",variant:"secondary","aria-label":"Remove search filter: ".concat(v.search),onClick:()=>W({search:""}),children:["Search: ",v.search,(0,n.jsx)(eg.A,{"aria-hidden":"true",className:"h-3 w-3"})]}),G.map(e=>(0,n.jsxs)(x.$,{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("display"in e?e.display:e.value),onClick:()=>W({[e.key]:v[e.key].filter(t=>t!==e.value)}),children:[e.label,": ","display"in e?e.display:e.value,(0,n.jsx)(eg.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"})]},"".concat(e.key,":").concat(e.value)))]}),(0,n.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:k&&(0,n.jsxs)("span",{role:"status",className:"text-xs text-muted-foreground",children:[N.length," of ",f.length," goals match \xb7 outcome for ",v.attack.length?v.attack.map(e=>{var t,a;return null!=(a=null==(t=U.find(t=>t.id===e))?void 0:t.name)?a:"Unknown attack"}).join(" + "):"all campaign attacks"]})}),(0,n.jsx)(eF,{header:(0,n.jsx)("div",{ref:E,"aria-hidden":"true","data-coverage-headings":!0,className:"overflow-hidden border-x",children:(0,n.jsxs)("table",{className:"w-full table-fixed border-collapse text-xs",style:K,children:[B,(0,n.jsx)("thead",{children:$})]})}),children:(0,n.jsx)("div",{role:"region","aria-label":"Scrollable goal coverage",tabIndex:0,className:"overflow-x-auto rounded-md border",onScroll:e=>{E.current&&(E.current.scrollLeft=e.currentTarget.scrollLeft)},children:(0,n.jsxs)("table",{"aria-label":"Goal coverage by subcategory and attack",className:"w-full table-fixed border-collapse text-xs",style:K,children:[B,(0,n.jsx)("thead",{className:"sr-only",children:$}),(0,n.jsx)("tbody",{children:(0,n.jsxs)("tr",{className:"border-y bg-muted",children:[(0,n.jsxs)("th",{scope:"row",className:"sticky left-0 z-10 bg-muted px-3 py-3 text-left font-bold",children:["All goals ",(0,n.jsxs)("span",{className:"whitespace-nowrap font-normal text-muted-foreground",children:["(",f.length," goals)"]})]}),H.map(e=>(0,n.jsx)("td",{className:"border-l px-0.5 py-2 align-middle",children:(0,n.jsx)(eI,{goals:f,runId:e.id,attacks:v.attack,label:"".concat(e.name," in All goals")})},e.id))]})}),w.map(e=>{let t=JSON.stringify([e.category]),a=j.has(t);return(0,n.jsxs)("tbody",{children:[(0,n.jsxs)("tr",{"data-category":e.category,className:"border-y bg-muted/30",children:[(0,n.jsx)("th",{scope:"row",className:"sticky left-0 z-10 bg-card px-3 py-3 text-left font-semibold",children:(0,n.jsxs)("button",{type:"button","aria-expanded":a,"aria-label":"Toggle ".concat(e.category),onClick:()=>A(t,e.subcategories.map(t=>{let[a]=t;return JSON.stringify([e.category,a])})),className:"flex w-full items-center gap-1 text-left",children:[a?(0,n.jsx)(eh.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}):(0,n.jsx)(ef.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}),(0,n.jsxs)("span",{children:[e.category," ",(0,n.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)"]})]})]})}),H.map(t=>(0,n.jsx)("td",{className:"border-l px-0.5 py-2 align-middle",children:(0,n.jsx)(eI,{goals:e.subcategories.flatMap(e=>{let[,t]=e;return t}),runId:t.id,attacks:v.attack,label:"".concat(t.name," in ").concat(e.category)})},t.id))]}),a&&e.subcategories.map(t=>{let[a,l]=t,s=JSON.stringify([e.category,a]),i=j.has(s);return(0,n.jsxs)(r.Fragment,{children:[(0,n.jsxs)("tr",{"data-category":e.category,"data-subcategory":a,className:"border-b bg-muted/10",children:[(0,n.jsx)("th",{scope:"row",className:"sticky left-0 z-10 bg-card py-2 pl-6 pr-3 text-left font-medium",children:(0,n.jsxs)("button",{type:"button","aria-expanded":i,"aria-label":"Toggle ".concat(e.category," / ").concat(a),onClick:()=>A(s),className:"flex w-full items-center gap-1 text-left",children:[i?(0,n.jsx)(eh.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}):(0,n.jsx)(ef.A,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}),(0,n.jsxs)("span",{children:[a," ",(0,n.jsxs)("span",{className:"whitespace-nowrap text-muted-foreground",children:["(",l.length," goals)"]})]})]})}),H.map(t=>(0,n.jsx)("td",{className:"border-l px-0.5 py-2 align-middle",children:(0,n.jsx)(eI,{goals:l,runId:t.id,attacks:v.attack,label:"".concat(t.name," in ").concat(e.category," / ").concat(a)})},t.id))]}),i&&l.map(e=>(0,n.jsxs)("tr",{className:"border-b hover:bg-muted/20",children:[(0,n.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,n.jsxs)("span",{className:"flex items-baseline gap-2",children:[(0,n.jsxs)("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:["#",e.index+1]}),(0,n.jsx)("span",{className:"min-w-0 whitespace-pre-wrap break-words",children:e.goal})]})}),H.map(t=>{let a=t.id?eM(e,t.id):eL(e,v.attack),r=(0,n.jsx)("span",{"aria-hidden":"true",className:"block h-3.5 w-3.5 rounded-[1px] ".concat("untested"===a?"border border-dashed border-muted-foreground":""),style:{backgroundColor:eE[a]}});return(0,n.jsx)("td",{className:"border-l px-0.5 py-1 text-center",children:t.id&&g?(0,n.jsx)("a",{"data-goal":e.index,"data-run":t.id,onClick:a=>{if(0!==a.button||a.ctrlKey||a.metaKey||a.shiftKey||a.altKey)return;a.preventDefault(),T.current=a.currentTarget;let n=t.id;I({goal:e.index,run:n,aggregate:!1}),d({section:"overview",goal:String(e.index),conversation_attack:n,conversation_aggregate:null,attempt:null,node:null})},href:"/stats?".concat(function(e){let t=new URLSearchParams;for(let[a,n]of Object.entries(e))for(let e of Array.isArray(n)?n:[n])e&&t.append(a,e);return t}({run:o.id,section:"overview",...v,...b?{granularity:b}:{},goal:String(e.index),conversation_attack:t.id})),"aria-label":"Goal ".concat(e.index+1," \xb7 ").concat(t.name,": ").concat(a),"aria-describedby":z,title:"".concat(t.name,"\n\nOutcome: ").concat("untested"===a?"Not tested":a,"\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:r}):(0,n.jsx)("span",{role:"img","aria-label":"Goal ".concat(e.index+1," \xb7 ").concat(t.name,": ").concat(a),tabIndex:g?void 0:0,title:"".concat(t.name,"\n\nOutcome: ").concat("untested"===a?"Not tested":a),className:"inline-flex h-8 w-8 items-center justify-center",children:r})},t.id)})]},e.index))]},a)})]},e.category)})]})})}),g&&(0,n.jsx)("span",{id:z,className:"sr-only",children:"Open conversation"}),!N.length&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"No recorded goals match these filters."}),(0,n.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. ",g?"Select an individual attack marker to open its conversation.":"Conversations are excluded from this offline snapshot."," Combined outcome is informational only."]}),(0,n.jsx)(M,{items:[{name:"Jailbroken",color:eE.jailbroken},{name:"Mitigated",color:eE.mitigated},{name:"Unresolved",color:eE.unresolved},{name:"Error",color:eE.error},{name:"Not tested",color:eE.untested}]}),g&&(0,n.jsx)(ev.lG,{open:null!==F,onOpenChange:e=>{e||(I(null),d({goal:null,conversation_attack:null,conversation_aggregate:null,attempt:null,node:null}))},children:(0,n.jsxs)(ev.Cf,{className:"flex h-[90dvh] flex-col overflow-hidden sm:max-w-5xl",onCloseAutoFocus:e=>{var t,a;e.preventDefault(),null==(t=(null==(a=T.current)?void 0:a.isConnected)?T.current:O.current)||t.focus()},children:[(0,n.jsxs)(ev.c7,{className:"shrink-0 pr-6",children:[(0,n.jsx)(ev.L3,{className:"whitespace-pre-wrap break-words text-xl",children:(null==(t=f.find(e=>e.index===(null==F?void 0:F.goal)))?void 0:t.goal)||"Goal text not recorded"}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(null==(a=f.find(e=>e.index===(null==F?void 0:F.goal)))?void 0:a.category)||"Unknown category",(null==(l=f.find(e=>e.index===(null==F?void 0:F.goal)))?void 0:l.subcategory)?" / ".concat(null==(s=f.find(e=>e.index===(null==F?void 0:F.goal)))?void 0:s.subcategory):""]}),q&&F&&(0,n.jsxs)("div",{"aria-label":"Goal outcome for selected attack",className:"flex items-center gap-2 text-xs text-muted-foreground",children:["Goal outcome \xb7 ",J?(0,p.aN)(J,o.runs):"Unknown attack","untested"===eM(q,F.run)?(0,n.jsx)("span",{children:"Not tested"}):(0,n.jsx)(ew,{value:eM(q,F.run)})]}),(0,n.jsxs)(ev.rr,{className:"sr-only",children:[(null==F?void 0:F.aggregate)?"Combined outcome: showing the highest-ranked successful selected attack, or the highest-ranked tested selected attack if none succeeded. With no attack selection, all campaign attacks are included. ":"","Close to return to the same place in goal coverage."]})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:F&&(F.run&&!P.some(e=>e.id===F.run)?(0,n.jsx)("p",{role:"alert",className:"p-5 text-sm",children:"This attack does not belong to this campaign."}):F.run?null==u?void 0:u(F):(0,n.jsx)("p",{className:"p-5 text-sm text-muted-foreground",children:"No recorded attack conversation for this goal."}))})]})})]})}var eP=a(68448);let eD=(0,c.A)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);var eU=a(6191);let eH=(0,c.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 eW=a(81701);let eG=e=>e.join("."),eq=e=>Array.isArray(e)&&e.every(e=>Number.isSafeInteger(e)&&e>=0);function eJ(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 eK(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,n=new Set([e.id]);for(;t&&a.has(t);){var r,l;if(n.has(t))return{...e,parent:null};n.add(t),t=null!=(l=null==(r=a.get(t))?void 0:r.parent)?l:null}return{...e,parent:e.parent&&a.has(e.parent)?e.parent:null}})}function eB(e){let{nodes:t,selectedId:a,onSelect:l,kind:s,simple:o=!1}=e,[i,c]=(0,r.useState)(1),[d,u]=(0,r.useState)(!1),m=(0,r.useRef)(null),p=(0,r.useMemo)(()=>(function(e){var t,a;let n=new Map;for(let a of e)n.set(a.parent,[...null!=(t=n.get(a.parent))?t:[],a]);let r=0,l=new Map,s=(e,t)=>{var a;let o=(null!=(a=n.get(e.id))?a:[]).map(e=>s(e,t+1)),i=o.length?(o[0]+o[o.length-1])/2:104*r+++24;return l.set(e.id,{x:230*t+24,y:i}),i};for(let e of null!=(a=n.get(null))?a:[])s(e,0);return{positions:l,width:Math.max(280,...Array.from(l.values()).map(e=>e.x+216)),height:Math.max(220,104*r+40)}})(t),[t]);(0,r.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 g=new Set,h=new Map(t.map(e=>[e.id,e]));for(let e of t.filter(e=>"jailbreak"===e.status)){let t=e;for(;t&&!g.has(t.id);)g.add(t.id),t=t.parent?h.get(t.parent):void 0}return(0,r.useEffect)(()=>{var e;let t=null==(e=m.current)?void 0:e.querySelector('[aria-pressed="true"]'),a=m.current;if(!t||!a)return;let n=t.getBoundingClientRect(),r=a.getBoundingClientRect();(n.left<r.left||n.right>r.right)&&(a.scrollLeft+=n.left-r.left-16),(n.top<r.top||n.bottom>r.bottom)&&(a.scrollTop+=n.top-r.top-16)},[a,d]),(0,n.jsxs)("section",{className:"investigation-panel min-w-0 overflow-hidden","aria-label":"Attack map",children:[(0,n.jsxs)("header",{className:"flex flex-wrap items-center justify-between gap-2 border-b bg-muted/40 p-4",children:[!o&&(0,n.jsx)("h3",{className:"font-semibold",children:o?"Attack branches":"candidates"===s?"Candidate tree":"execution"===s?"Recorded execution tree":"Independent attempts"}),(0,n.jsx)(x.$,{size:"sm",variant:"outline","aria-pressed":d,onClick:()=>u(e=>!e),children:d?"Show map":"Show list"})]}),(0,n.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"===s?"Lines connect recorded parent candidates. Rose outlines mark paths to jailbreaks; blue marks your selection.":"execution"===s?"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,n.jsxs)("div",{className:"flex items-center gap-1 border-b px-3 py-2",children:[(0,n.jsx)(x.$,{variant:"ghost",size:"icon","aria-label":"Zoom out",disabled:i<=.35,onClick:()=>c(e=>Math.max(.35,e-.15)),children:(0,n.jsx)(eD,{className:"h-4 w-4"})}),(0,n.jsxs)("span",{className:"w-12 text-center text-xs tabular-nums",children:[Math.round(100*i),"%"]}),(0,n.jsx)(x.$,{variant:"ghost",size:"icon","aria-label":"Zoom in",disabled:i>=1.6,onClick:()=>c(e=>Math.min(1.6,e+.15)),children:(0,n.jsx)(eU.A,{className:"h-4 w-4"})}),(0,n.jsxs)(x.$,{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,n.jsx)(eH,{className:"mr-1 h-4 w-4"}),"Fit tree"]})]}),(0,n.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,n.jsx)("p",{className:"p-5 text-sm text-muted-foreground",children:"No recorded attempts yet."}),(0,n.jsx)("div",{style:d?void 0:{width:p.width*i,height:p.height*i,position:"relative"},children:(0,n.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,n.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,n.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:g.has(e.id)?"var(--map-path)":"var(--map-edge)",strokeWidth:g.has(e.id)?3:2},e.id):null})}),t.map(e=>{let t=p.positions.get(e.id);return(0,n.jsxs)("button",{"aria-pressed":e.id===a,onClick:()=>l(e),className:"map-node text-left ".concat(d?"w-full":"absolute w-[196px]"," ").concat(e.id===a?"map-node-selected":""," ").concat(g.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,n.jsx)("span",{className:"block truncate text-sm font-semibold",title:e.label,children:e.label}),(0,n.jsxs)("span",{className:"mt-2 flex flex-wrap items-center gap-1",children:[e.status&&(0,n.jsx)(ew,{value:e.status}),!o&&e.disposition&&e.disposition!==e.status&&(0,n.jsx)(ew,{value:e.disposition}),!o&&null!==e.score&&(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Raw score ",e.score]})]}),!e.status&&!o&&(0,n.jsx)("span",{className:"mt-1 block text-xs text-muted-foreground",children:"candidate"===e.kind?"No judged result":e.kind})]},e.id)})]})})]})]})}function e$(e){return Array.isArray(e)?e.filter(e=>"object"==typeof e&&null!==e&&"string"==typeof e.role&&"content"in e):[]}function eV(e){return"object"!=typeof e||null===e||Array.isArray(e)?null:e}let eZ=e=>JSON.stringify(e);function eY(e){let{error:t,retry:a}=e;return t?(0,n.jsxs)("div",{role:"alert",className:"space-y-3 p-5 text-sm",children:[(0,n.jsx)("p",{children:t}),(0,n.jsx)(x.$,{variant:"outline",onClick:a,children:"Retry"})]}):(0,n.jsxs)("p",{role:"status",className:"flex items-center gap-2 p-5 text-sm text-muted-foreground",children:[(0,n.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Loading conversation..."]})}function eQ(e){let{role:t,content:a,label:r}=e;return(0,n.jsxs)("div",{className:"conversation-message ".concat("assistant"===t?"conversation-response":"system"===t?"conversation-context":"conversation-prompt"),children:[(0,n.jsx)("p",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:null!=r?r:"assistant"===t?"Target response":"user"===t?"Attack prompt":"system"===t?"System context":t}),(0,n.jsx)(eP.P,{content:a})]})}function eX(e){let{label:t,ordinal:a}=e;return(0,n.jsxs)("p",{className:"conversation-repeat",children:[t," ",(0,n.jsxs)("span",{className:"text-muted-foreground",children:["— same as attempt ",a]})]})}h.jailbroken,h.jailbroken,h.mitigated,h.unresolved,h.unresolved,h.error;let e0={advprefix:"AdvPrefix writes the opening of a compliant answer and makes the target continue it. Each opening is sampled several times; only the text the target added is shown as its response.",crescendo:"Crescendo starts with a harmless question and escalates over several turns, building on the target’s own answers. Refused turns are rephrased from the last accepted turn."};function e1(e){var t;let{entry:a,entries:r,highlight:l}=e,s=function(e,t){var a;let n=null!=(a=e.attempt.metadata)?a:{};if("number"==typeof n.turn)return["Turn ".concat(n.turn+1),!0===n.refused?"target refused":null,!0===n.backtracked?"will be rephrased":null].filter(Boolean).join(" \xb7 ");if("number"==typeof n.prefix_index){let a=t.filter(e=>{var t;return(null==(t=e.attempt.metadata)?void 0:t.prefix_index)===n.prefix_index}),r=new Set(t.map(e=>{var t;return null==(t=e.attempt.metadata)?void 0:t.prefix_index})).size;return"Opening ".concat(n.prefix_index+1," of ").concat(r," \xb7 sample ").concat(a.indexOf(e)+1," of ").concat(a.length)}return null}(a,r),o=null==(t=r[r.indexOf(a)-1])?void 0:t.attempt.ordinal;return(0,n.jsxs)("article",{id:"attempt-".concat(a.attempt.id),tabIndex:-1,"aria-label":"Attempt ".concat(a.attempt.ordinal),className:"conversation-attempt scroll-mt-[calc(var(--conversation-navigation-height,0px)+1rem)] space-y-4 ".concat(l?"conversation-highlight":""),children:[(0,n.jsxs)("header",{className:"flex flex-wrap items-center justify-between gap-2 border-b pb-3",children:[(0,n.jsxs)("h3",{className:"text-sm font-semibold",children:["Attempt ",a.attempt.ordinal,s&&(0,n.jsx)("span",{className:"ml-2 font-normal text-muted-foreground",children:s})]}),(0,n.jsx)(ew,{value:a.attempt.bucket})]}),null!==a.continuesFrom&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:a.continuesFrom===o?"Continuing the conversation above.":"Continues the conversation from attempt ".concat(a.continuesFrom,".")}),a.messages.length?a.messages.map((e,t)=>void 0!==e.repeatOf?(0,n.jsx)(eX,{label:"Attack prompt",ordinal:e.repeatOf},t):(0,n.jsx)(eQ,{role:e.role,content:e.content},t)):!a.continues&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"The prompt was not recorded."}),null!==a.prefill&&(null!==a.prefillRepeatOf?(0,n.jsx)(eX,{label:"Prefilled opening",ordinal:a.prefillRepeatOf}):(0,n.jsxs)("div",{className:"conversation-message conversation-prefill",children:[(0,n.jsxs)("p",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:["Prefilled opening ",(0,n.jsx)("span",{className:"font-normal",children:"\xb7 written by the attacker, presented as the target's own words"})]}),(0,n.jsx)(eP.P,{content:a.prefill})]})),null===a.reply?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"No target response was recorded."}):null!==a.replyRepeatOf?(0,n.jsx)(eX,{label:null!==a.prefill?"Target continuation":"Target response",ordinal:a.replyRepeatOf}):null!==a.prefill?(0,n.jsx)(eQ,{role:"assistant",label:"Target continuation",content:a.reply}):(0,n.jsx)(eQ,{role:"assistant",content:a.reply}),a.notes&&(0,n.jsxs)("div",{className:"border-l-2 border-slate-400 pl-4 text-sm",children:[(0,n.jsx)("p",{className:"mb-1 text-xs font-semibold text-muted-foreground",children:"error"===a.attempt.bucket?"What went wrong":"Why this outcome"}),(0,n.jsx)(eP.P,{content:a.notes})]})]})}function e2(e){var t,a,l,s;let{campaign:i,goal:c,runId:d,revision:u,attackHeader:m}=e,x=(0,o.useSearchParams)(),[g,h]=(0,r.useState)(0),[f,v]=(0,r.useState)(null!=(a=null==x?void 0:x.get("attempt"))?a:null),[b,j]=(0,r.useState)(null!=(l=null==x?void 0:x.get("attempt"))?l:null),[y,k]=(0,r.useState)(null),[N,w]=(0,r.useState)(null),S=(0,r.useRef)(null),C=(0,r.useRef)(null),_=new URLSearchParams({run_id:d,goal_index:String(c.index)}),A=(0,p.LI)("".concat(p.dI,"/").concat(i.id,"/structure?").concat(_),u+g),M=(0,r.useMemo)(()=>A.data?function(e){var t;let a=new Map((null!=(t=e.results)?t:[]).map(e=>[e.id,e])),n=[],r=new Map,l=new Map,s=new Map;return e.attempts.map(t=>{var o,i,c,d,u,m,x,p,g,h,f,v,b,j;let y=a.get(t.id),k=e.traces.filter(e=>e.result===t.id).sort((e,t)=>e.sequence-t.sequence),N=k.find(e=>{var t;return(0,eW.HK)(e.content)&&"call"===e.content.node&&(null==(t=e.content.data)?void 0:t.role)==="target"}),w=N&&(0,eW.HK)(N.content)?N.content.data:void 0,S=k.find(e=>{let t=eV(e.content);return t&&!("v"in t)&&eV(t.request)&&eV(t.response)}),C=eV(null==S?void 0:S.content),_=eV(null==C?void 0:C.request),A=eV(null==C?void 0:C.response),M=e$(null==y||null==(o=y.request_payload)?void 0:o.messages),L=e$(null==w?void 0:w.request),R=null==y||null==(i=y.request_payload)?void 0:i.prompt,z=M.length?M:"string"==typeof R?[{role:"user",content:R}]:L.length?L:e$(null==_?void 0:_.messages),E=null!=(p=null!=(x=null!=(m=null!=(u=null==y||null==(c=y.agent_specific_data)?void 0:c.response)?u:null==y||null==(d=y.agent_specific_data)?void 0:d.decoded_response)?m:null==w?void 0:w.response)?x:null==A?void 0:A.text)?p:null,F=z.at(-1),I=(null==F?void 0:F.role)==="assistant"&&"string"==typeof F.content&&z.length>1?F.content:null,T=null===I?z:z.slice(0,-1),O=null!==I&&"string"==typeof E&&E.startsWith(I)?E.slice(I.length):E,P=n.filter(e=>{var t;return(t=e.messages).length>0&&t.length<=T.length&&t.every((e,t)=>{let a;return a=T[t],e.role===a.role&&eZ(e.content)===eZ(a.content)})}).reduce((e,t)=>!e||t.messages.length>=e.messages.length?t:e,null),D=T.slice(null!=(g=null==P?void 0:P.messages.length)?g:0).map(e=>{if("user"!==e.role)return e;let a=r.get(eZ(e.content));return void 0===a&&r.set(eZ(e.content),t.ordinal),void 0===a?e:{...e,repeatOf:a}}),U=null===I?null:null!=(h=l.get(I))?h:null;null!==I&&null===U&&l.set(I,t.ordinal);let H=eZ([I,O]),W=null===O||""===O?null:null!=(f=s.get(H))?f:null;return null!==O&&null===W&&s.set(H,t.ordinal),n.push({ordinal:t.ordinal,messages:[...z.slice(0,null===I?void 0:-1),...null!==E?[{role:"assistant",content:E}]:[]]}),{attempt:t,messages:D,prefill:I,prefillRepeatOf:U,reply:O,replyRepeatOf:W,notes:null!=(b=null!=(v=t.notes)?v:null==y?void 0:y.evaluation_notes)?b:null,continues:null!==P,continuesFrom:null!=(j=null==P?void 0:P.ordinal)?j:null}})}(A.data):[],[A.data]),L=(0,r.useMemo)(()=>A.data?function(e){let t=e.traces.filter(e=>(0,eW.HK)(e.content)&&eq(e.content.path)&&"phase"===e.content.node),a=t.filter(e=>{var t;return(0,eW.HK)(e.content)&&"candidate"===e.content.label&&eq(null==(t=e.content.data)?void 0:t.parent_path)});if(a.length){let t=a.map((t,a)=>{var n,r,l,s;if(!(0,eW.HK)(t.content))throw Error("Invalid candidate trace");let o=t.content.path,i=null==(n=t.content.data)?void 0:n.parent_path,c=e.attempts.find(e=>{var t;return eq(null==(t=e.metadata)?void 0:t.candidate_path)&&eG(e.metadata.candidate_path)===eG(o)}),d=e.traces.filter(e=>{var t;if(!(0,eW.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=>eq(e)&&eG(e)===eG(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,eW.HK)(e.content)&&["pruned","skipped"].includes(null!=(t=e.content.label)?t:"")}),u=d&&(0,eW.HK)(d.content)?d.content.label:null;return{id:"candidate:".concat(eG(o)),parent:eq(i)&&i.length?"candidate:".concat(eG(i)):null,label:"Candidate ".concat(a+1),kind:"candidate",status:null!=(s=null==c?void 0:c.bucket)?s:"pruned"===u||"skipped"===u?u:null,disposition:"pruned"===u||"skipped"===u?u:void 0,reason:d&&(0,eW.HK)(d.content)&&"string"==typeof(null==(r=d.content.data)?void 0:r.reason)?d.content.data.reason:void 0,score:"number"==typeof(null==c||null==(l=c.metadata)?void 0:l.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(eJ(a));return{kind:"candidates",nodes:eK(t)}}if(t.length){let a=t.map(e=>{if(!(0,eW.HK)(e.content))throw Error("Invalid phase trace");return{id:"phase:".concat(eG(e.content.path)),parent:e.content.path.length>1?"phase:".concat(eG(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 n;let r=e.traces.find(e=>{var a;return e.result===t.id&&(0,eW.HK)(e.content)&&"call"===e.content.node&&(null==(a=e.content.data)?void 0:a.role)==="target"}),l=r&&(0,eW.HK)(r.content)?r.content.path:[],s=a.filter(e=>e.trace&&(0,eW.HK)(e.trace.content)&&e.trace.content.path.every((e,t)=>l[t]===e)).sort((e,t)=>(t.trace&&(0,eW.HK)(t.trace.content)?t.trace.content.path.length:0)-(e.trace&&(0,eW.HK)(e.trace.content)?e.trace.content.path.length:0))[0];a.push({...eJ(t),parent:null!=(n=null==s?void 0:s.id)?n:null,trace:null==s?void 0:s.trace})}for(let t of e.traces)(0,eW.HK)(t.content)&&"decision"===t.content.node&&a.push({id:"decision:".concat(eG(t.content.path)),parent:"phase:".concat(eG(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:eK(a)}}return{kind:"attempts",nodes:e.attempts.map(eJ)}}(A.data):null,[A.data]);(0,r.useEffect)(()=>{let e=C.current,t=S.current;if(!e||!t)return;let a=()=>t.style.setProperty("--conversation-navigation-height","".concat(e.getBoundingClientRect().height,"px"));a();let n=new ResizeObserver(a);return n.observe(e),()=>n.disconnect()},[M]),(0,r.useEffect)(()=>{if(f&&M.length){var e,t;let a=document.getElementById("attempt-".concat(f));a&&(null==(e=S.current)?void 0:e.contains(a))&&(null==a||null==(t=a.scrollIntoView)||t.call(a,{block:"start",behavior:"instant"}),null==a||a.focus({preventScroll:!0}))}},[f,M]),(0,r.useEffect)(()=>{let e=S.current,t=C.current;if(!e||!t||!M.length)return;let a=()=>{let a=Array.from(e.querySelectorAll(".conversation-attempt")).filter(e=>e.getBoundingClientRect().height>0);if(!a.length)return;let n=t.getBoundingClientRect().bottom+16,r=a[0];for(let e of a){if(e.getBoundingClientRect().top>n)break;r=e}j(r.id.slice(8))};a(),document.addEventListener("scroll",a,!0),window.addEventListener("resize",a);let n=new ResizeObserver(a);return n.observe(e),n.observe(t),()=>{document.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a),n.disconnect()}},[M]);let R=e=>{var t,a;v(e),j(e),(0,p.gj)({goal:String(c.index),...(null==x?void 0:x.has("conversation_attack"))?{conversation_attack:d}:{attack:d},attempt:e});let n=document.getElementById("attempt-".concat(e));n&&(null==(t=S.current)?void 0:t.contains(n))&&(null==(a=n.scrollIntoView)||a.call(n,{block:"start",behavior:"smooth"}))};if(A.error||!A.data)return(0,n.jsxs)("div",{className:"space-y-4",children:[m(),(0,n.jsx)(eY,{error:A.error,retry:()=>h(e=>e+1)})]});let z=e0[null!=(s=null==(t=i.runs.find(e=>e.id===d))?void 0:t.technique)?s:""];return(0,n.jsxs)("div",{ref:S,className:"min-w-0 space-y-6",children:[(0,n.jsx)("div",{ref:C,"aria-label":"Conversation controls",className:"sticky top-0 z-10 space-y-3 border-b bg-background py-3",children:M.length<=1?m():(0,n.jsxs)("div",{"aria-label":"Attempt navigation",className:"flex items-start gap-4",children:[m(),(0,n.jsx)("div",{role:"group","aria-label":"Attempt timeline",className:"ml-auto flex min-w-0 flex-1 flex-wrap justify-end gap-1.5",children:M.map(e=>{let t="jailbreak"===e.attempt.bucket?"Jailbroken":"mitigated"===e.attempt.bucket?"Mitigated":"error"===e.attempt.bucket?"Error":"Pending";return(0,n.jsxs)(T.m_,{children:[(0,n.jsx)(T.k$,{asChild:!0,children:(0,n.jsx)("button",{onClick:()=>R(e.attempt.id),"aria-label":"Go to attempt ".concat(e.attempt.ordinal,": ").concat("jailbreak"===e.attempt.bucket?"jailbroken":e.attempt.bucket),"aria-pressed":b===e.attempt.id,"aria-current":b===e.attempt.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.attempt.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.attempt.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(b===e.attempt.id?"ring-2 ring-foreground ring-offset-2 ring-offset-background":""),children:e.attempt.ordinal})}),(0,n.jsxs)(T.ZI,{sideOffset:6,className:"max-w-64 space-y-1 px-3 py-2 text-left leading-relaxed",children:[(0,n.jsxs)("p",{className:"font-semibold",children:["Attempt ",e.attempt.ordinal," \xb7 ",t]}),(0,n.jsx)("p",{children:"Select to jump to this conversation."})]})]},e.attempt.id)})})]})}),z&&(0,n.jsx)("p",{className:"max-w-prose text-sm leading-relaxed",children:z}),(null==L?void 0:L.kind)==="candidates"&&(0,n.jsxs)("details",{className:"investigation-panel overflow-hidden",children:[(0,n.jsxs)("summary",{className:"cursor-pointer p-4 text-sm font-medium",children:["Attack branches ",(0,n.jsx)("span",{className:"ml-1 font-normal text-muted-foreground",children:"(optional)"})]}),(0,n.jsx)(eB,{simple:!0,nodes:L.nodes.map((e,t)=>{var a,n;return{...e,label:e.attemptId?"Attempt ".concat(null==(n=A.data)||null==(a=n.attempts.find(t=>t.id===e.attemptId))?void 0:a.ordinal):"Branch ".concat(t+1)}}),selectedId:y,kind:"candidates",onSelect:e=>{k(e.id),e.attemptId?(w(null),R(e.attemptId)):w(e.reason||"This branch was discarded before a target response was recorded.")}}),N&&(0,n.jsx)("p",{role:"status",className:"p-4 text-sm",children:N})]}),(0,n.jsxs)("section",{"aria-label":"Attack conversation",className:"space-y-8",children:[M.map(e=>(0,n.jsx)(e1,{entry:e,entries:M,highlight:f===e.attempt.id},e.attempt.id)),!M.length&&(0,n.jsx)("p",{className:"investigation-panel p-6 text-sm",children:"This attack has no recorded attempts for this goal."})]}),(0,n.jsxs)("details",{className:"border-t pt-4",children:[(0,n.jsx)("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:"Technical details"}),(0,n.jsx)("pre",{className:"mt-3 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/50 p-4 text-xs",children:JSON.stringify(A.data,null,2)})]})]})}function e5(e){var t,a;let{campaign:l,revision:s,goalIndex:o,attack:i,catalog:c,showGoalHeader:d=!0}=e,[u,m]=(0,r.useState)(0),x=(0,p.LI)("".concat(p.dI,"/").concat(l.id,"/goals?goal_index=").concat(o),s+u),g=null==(t=x.data)?void 0:t.results[0];if(x.error||!x.data)return(0,n.jsx)(eY,{error:x.error,retry:()=>m(e=>e+1)});if(!g)return(0,n.jsx)("p",{className:"investigation-panel p-6 text-sm",children:"This goal has no recorded attempts in this campaign."});let h=null==(a=g.attack_outcomes)?void 0:a.find(e=>e.run_id===i),f=h||g.run_ids.includes(i),v=l.runs.find(e=>e.id===i),b=()=>(0,n.jsxs)("header",{"aria-label":"Selected attack",className:"flex min-h-7 shrink-0 flex-wrap items-center gap-2",children:[(0,n.jsx)("h3",{className:"text-base font-semibold",children:v?(0,p.aN)(v,l.runs):"Unknown attack"}),!f&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"Not tested"}),!f&&(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"0 attempts"})]});return(0,n.jsxs)("div",{className:"min-w-0 space-y-5",children:[d&&(0,n.jsxs)("header",{"aria-label":"Goal details",className:"space-y-2 border-b pb-5",children:[(0,n.jsx)("h2",{className:"w-full whitespace-pre-wrap break-words text-xl font-semibold",children:g.goal||"Goal text not recorded"}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)(S,{info:c.get(g.category)}),(0,n.jsxs)("p",{className:"min-w-0 flex-1 text-xs font-semibold text-muted-foreground",children:["Goal ",g.index+1," \xb7 ",g.category||"Unknown",g.subcategory?" / ".concat(g.subcategory):""]}),(0,n.jsxs)("span",{"aria-label":"Goal outcome for selected attack",className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:["Goal outcome ",h?(0,n.jsx)(ew,{value:h.verdict}):(0,n.jsx)("span",{children:f?"Outcome not recorded":"Not tested"})]})]})]}),f?(0,n.jsx)(e2,{campaign:l,goal:g,runId:i,revision:s,attackHeader:b},"".concat(g.index,":").concat(i)):(0,n.jsxs)(n.Fragment,{children:[b(),(0,n.jsx)("p",{className:"py-5 text-sm text-muted-foreground",children:"This attack has no recorded attempts for this goal."})]})]})}let e3=[];function e4(e){var t,a,l;let{campaign:s,revision:c}=e,d=(0,o.useSearchParams)(),u=(0,p.LI)("".concat(p.dI,"/").concat(s.id,"/matrix"),c,void 0,{version:s.revision}),m=(0,r.useMemo)(()=>{if(!u.data)return null;try{return{goals:(0,p.UK)(u.data),error:null}}catch(e){return{goals:e3,error:e instanceof Error?e.message:"The goal matrix could not be read."}}},[u.data]),x=(0,r.useMemo)(()=>(function(e){let t=Array.from(new Set(e)).sort((e,t)=>e.localeCompare(t)),a=0;return new Map(t.map((e,t)=>{let n=/^([A-Z][0-9]*)\.\s*/.exec(e),r=w.test(e)?"var(--viz-error)":N[a++%N.length];return[e,{name:e,code:n?n[1]:String(t+1),short:n?e.slice(n[0].length):e,color:r}]}))})(s.category_outcomes.map(e=>e.category)),[s.category_outcomes]),g=(0,r.useRef)(null);m&&(g.current={id:s.id,goals:m.goals});let h=(null==(t=g.current)?void 0:t.id)===s.id?g.current.goals:e3,f=null!=(a=u.error)?a:null==m?void 0:m.error,v=f?(0,n.jsx)("p",{role:"alert",className:"text-sm text-muted-foreground",children:f}):u.data?null:(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Loading goals…"]});return(0,n.jsx)(eO,{campaign:s,recordedGoals:h,status:v,query:null!=(l=null==d?void 0:d.toString())?l:"",onSelectionChange:p.gj,renderEvidence:e=>(0,n.jsx)(e5,{campaign:s,revision:c,goalIndex:e.goal,attack:e.run,catalog:x,showGoalHeader:!1},"".concat(e.goal,":").concat(e.run))})}function e6(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),a=Math.round((t-new Date(e).getTime())/1e3),n=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 n.format(-Math.round(a/t),e);return"just now"}function e8(e){var t;let{campaigns:a,total:r}=e,l=[...a].sort((e,t)=>e.created_at.localeCompare(t.created_at)),s=e=>a.reduce((t,a)=>t+a[e],0),o=L({recorded_goals:s("recorded_goals"),jailbroken:s("jailbroken")}),i=l.map(e=>L(e)),c=l[l.length-1];return(0,n.jsxs)("section",{"aria-label":"Runs overview",className:"space-y-2",children:[(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-5",children:[(0,n.jsx)(k,{label:"Campaigns",value:r,detail:"recorded runs",children:(0,n.jsx)("div",{className:"text-[var(--viz-family-static)]",children:(0,n.jsx)(j,{bars:!0,label:"Attacks per campaign, oldest first: ".concat(l.map(e=>e.attack_runs).join(", ")),values:l.map(e=>e.attack_runs)})})}),(0,n.jsx)(k,{label:"Goals tested",value:s("recorded_goals").toLocaleString(),detail:"across campaigns",children:(0,n.jsx)("div",{className:"text-[var(--viz-family-adaptive)]",children:(0,n.jsx)(j,{bars:!0,label:"Goals per campaign, oldest first: ".concat(l.map(e=>e.recorded_goals).join(", ")),values:l.map(e=>e.recorded_goals)})})}),(0,n.jsx)(k,{label:"Overall ASR",value:null===o?"Not measured":"".concat(o.toFixed(1),"%"),detail:"".concat(s("jailbroken").toLocaleString()," goals jailbroken"),children:(0,n.jsx)("div",{className:"text-[var(--viz-jailbroken)]",children:(0,n.jsx)(j,{max:100,values:i,label:"ASR per campaign, oldest first: ".concat(i.map(e=>null===e?"not measured":"".concat(e.toFixed(1),"%")).join(", "))})})}),(0,n.jsx)(k,{label:"Attempts",value:s("attempts").toLocaleString(),detail:"recorded attempts",children:(0,n.jsx)("div",{className:"text-muted-foreground",children:(0,n.jsx)(j,{bars:!0,label:"Attempts per campaign, oldest first: ".concat(l.map(e=>e.attempts).join(", ")),values:l.map(e=>e.attempts)})})}),(0,n.jsx)("div",{className:"col-span-2 lg:col-span-1",children:(0,n.jsx)(k,{label:"Latest campaign",value:(0,n.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(e6(c.created_at)):void 0,children:c&&(0,n.jsx)(F,{status:c.status})})})]}),r>a.length&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Trends cover the ",a.length," most recent of ",r," campaigns."]})]})}var e7=a(71360),e9=a(35835),te=a(41444);let tt=(0,te.h)("DeleteCampaign"),ta=new Set(["COMPLETED","FAILED","CANCELLED"]);function tn(e){let{id:t,ids:a,name:l,status:s,onDeleted:o}=e,[i,c]=(0,r.useState)(!1),[d,u]=(0,r.useState)(!1),[m,g]=(0,r.useState)(""),h=async()=>{u(!0),g("");try{await (0,p._F)(a?{ids:a}:{id:t}),o()}catch(e){tt.error({err:e,id:t},"Failed to delete campaign execution"),g(e instanceof Error?e.message:"Failed to delete campaign execution.")}finally{u(!1)}};return(0,n.jsxs)("div",{children:[(0,n.jsxs)(x.$,{variant:"outline","aria-label":"Delete ".concat(l),disabled:d||!ta.has(s)||void 0!==a&&!a.length,title:ta.has(s)?void 0:"Active campaign executions cannot be deleted",onClick:()=>c(!0),children:[(0,n.jsx)(e7.A,{className:"mr-2 h-4 w-4"}),d?"Deleting...":a?"Delete selected (".concat(a.length,")"):"Delete"]}),(0,n.jsx)(e9.T,{open:i,onOpenChange:c,title:"Delete campaign execution?",description:"Permanently delete ".concat(a?"these ".concat(a.length," selected campaign executions"):'"'.concat(l,'"')," 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:()=>{h()}}),m&&(0,n.jsx)("p",{role:"alert",className:"mt-2 text-sm text-destructive",children:m})]})}var tr=a(39867);let tl=(0,te.h)("ExportCampaign"),ts=new Set(["COMPLETED","FAILED","CANCELLED"]);function to(e){let{id:t,ids:l,name:s,status:o}=e,[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)(""),[p,g]=(0,r.useState)(""),h=(0,r.useRef)(null),f=JSON.stringify(null!=l?l:t?[t]:[]);(0,r.useEffect)(()=>(d(!1),m(""),g(""),()=>{var e;return null==(e=h.current)?void 0:e.abort()}),[f]);let v=async()=>{let e=new AbortController;h.current=e,d(!0),m(""),g("");try{let{createCampaignExports:n,downloadCampaignExport:r}=await Promise.all([a.e(690),a.e(390),a.e(877)]).then(a.bind(a,12877)),s=await n(null!=l?l:t?[t]:[],e.signal);if(e.signal.aborted)return;s.forEach(e=>r(e)),g(1===s.length?"HTML download requested.":"".concat(s.length," HTML downloads requested. Your browser may ask permission to download multiple files."))}catch(a){if(e.signal.aborted)return;tl.error({err:a,id:t,ids:l},"Failed to export campaign"),m(a instanceof Error?a.message:"Failed to export campaign.")}finally{e.signal.aborted||d(!1)}};return(0,n.jsxs)("div",{children:[(0,n.jsxs)(x.$,{variant:"outline","aria-label":"Export ".concat(s),disabled:c||void 0!==o&&!ts.has(o)||(void 0!==l?!l.length:!t),title:void 0===o||ts.has(o)?"Download a full-campaign HTML report, printable to PDF":"Export is available when the campaign execution finishes",onClick:()=>{v()},children:[c?(0,n.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,n.jsx)(tr.A,{className:"mr-2 h-4 w-4"}),c?"Exporting...":l?"Export selected (".concat(l.length,")"):"Export"]}),u&&(0,n.jsx)("p",{role:"alert",className:"mt-2 max-w-sm text-sm text-destructive",children:u}),p&&(0,n.jsx)("p",{role:"status",className:"mt-2 max-w-sm text-xs text-muted-foreground",children:p})]})}let ti=(0,c.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 tc=a(38775),td=a(7831);let tu=(0,te.h)("CancelCampaignRun");async function tm(e){if(!(e instanceof tc.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 tx(e){let{id:t,name:a,onCancelled:l}=e,[s,o]=(0,r.useState)(!1),[c,d]=(0,r.useState)("idle"),[u,m]=(0,r.useState)(""),p=async()=>{d("busy"),m("");try{await td.ME.runCancelCreate({id:t}),d("requested"),null==l||l()}catch(a){var e;tu.error({err:a,id:t},"Failed to cancel campaign run"),d("idle"),m(null!=(e=await tm(a))?e:"Could not cancel the run.")}};return(0,n.jsxs)("div",{children:[(0,n.jsxs)(x.$,{variant:"outline","aria-label":"Cancel ".concat(a),disabled:"idle"!==c,onClick:()=>o(!0),children:["idle"===c?(0,n.jsx)(ti,{className:"mr-2 h-4 w-4"}):(0,n.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}),"idle"===c?"Cancel run":"Cancelling..."]}),(0,n.jsx)(e9.T,{open:s,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,n.jsx)("p",{role:"alert",className:"mt-2 max-w-sm text-sm text-destructive",children:u})]})}let tp=(0,c.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"}]]),tg=(e,t)=>"/stats?".concat(new URLSearchParams({run:e,baseline:t}));function th(e){let{current:t,baseline:a}=e;if(null===t||null===a)return(0,n.jsx)("span",{className:"text-muted-foreground",children:"not comparable"});let r=t-a,l=.05>Math.abs(r)?0:r;return(0,n.jsxs)("span",{className:"font-semibold tabular-nums ".concat(l>0?"text-rose-700 dark:text-rose-300":l<0?"text-emerald-700 dark:text-emerald-300":"text-muted-foreground"),title:l>0?"More goals jailbroken than before":l<0?"Fewer goals jailbroken than before":"No change",children:[l>0?"+":l<0?"−":"\xb1",Math.abs(l).toFixed(1)," pts"]})}function tf(e){var t,a,l;let{campaign:s}=e,i=(0,o.useRouter)(),[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)(""),g=s.campaign?new URLSearchParams({campaign:s.campaign,page:"1",page_size:"100"}):null,h=(0,p.LI)(c&&g?"".concat(p.dI,"/summary?").concat(g):null),f=null!=(l=null==(t=h.data)?void 0:t.results.filter(e=>e.id!==s.id))?l:[],v=u||(null==(a=f[0])?void 0:a.id)||"";return s.campaign?c?(0,n.jsxs)("form",{className:"flex flex-wrap items-center gap-2",onSubmit:e=>{e.preventDefault(),v&&i.push(tg(s.id,v))},children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:"Baseline"}),(0,n.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:[!h.data&&!h.error&&(0,n.jsx)("option",{value:"",children:"Loading runs..."}),h.data&&!f.length&&(0,n.jsx)("option",{value:"",children:"No other runs of this campaign"}),f.map(e=>(0,n.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,n.jsx)(x.$,{type:"submit",size:"sm",disabled:!v,children:"Compare"}),h.error&&(0,n.jsx)("p",{role:"alert",className:"w-full text-xs text-destructive",children:h.error})]}):(0,n.jsx)(x.$,{variant:"outline",size:"sm",onClick:()=>d(!0),children:"Compare with another run"}):null}function tv(e){let{campaign:t}=e,a=t.previous,r=a?[["Jailbroken",a.jailbroken,t.jailbroken],["Mitigated",a.mitigated,t.mitigated],["Unresolved",a.unresolved,t.unresolved],["Goals",a.recorded_goals,t.recorded_goals]]:[],l=L(t),o=a?L(a):null;return(0,n.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,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Since the previous run \xb7 ",(0,n.jsx)("time",{dateTime:a.created_at,title:new Date(a.created_at).toLocaleString(),children:e6(a.created_at)})]}),(0,n.jsxs)("p",{className:"flex flex-wrap items-baseline gap-x-2",children:[(0,n.jsxs)("span",{children:["ASR ",(0,n.jsx)("span",{className:"tabular-nums",children:null===o?"—":"".concat(o.toFixed(1),"%")})," → ",(0,n.jsx)("span",{className:"font-semibold tabular-nums",children:null===l?"—":"".concat(l.toFixed(1),"%")})]}),(0,n.jsx)(th,{current:l,baseline:o})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground tabular-nums",children:r.map(e=>{let[t,a,n]=e;return"".concat(t," ").concat(a," → ").concat(n)}).join(" \xb7 ")})]}):(0,n.jsx)("p",{className:"text-muted-foreground",children:"No earlier completed run of this campaign to compare with."}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a&&(0,n.jsx)(x.$,{variant:"outline",size:"sm",asChild:!0,children:(0,n.jsxs)(s(),{href:tg(t.id,a.id),children:[(0,n.jsx)(tp,{className:"mr-2 h-4 w-4"}),"Compare with previous run"]})}),(0,n.jsx)(tf,{campaign:t}),t.campaign&&(0,n.jsx)(s(),{className:"text-sm underline-offset-4 hover:underline",href:"/stats?".concat(new URLSearchParams({campaign:t.campaign})),children:"All runs of this campaign"})]})]})}function tb(e){let{runs:t}=e,[a,r]=g(640),l=[...t].sort((e,t)=>e.created_at.localeCompare(t.created_at)||e.id.localeCompare(t.id)).map(e=>({run:e,value:L(e)})).filter(e=>null!==e.value),s=Math.max(320,r),o=s-24,i=e=>l.length>1?48+e*(o-48)/(l.length-1):(48+o)/2,c=e=>150-e/100*134,d=Math.max(1,Math.ceil(l.length/Math.max(1,Math.floor((o-48)/90))));return(0,n.jsxs)("figure",{"aria-label":"Attack success rate across runs",className:"investigation-panel space-y-3 p-5",children:[(0,n.jsxs)("figcaption",{children:[(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Progress across runs"}),(0,n.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."})]}),l.length<2&&(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:l.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."}),l.length>0&&(0,n.jsx)("div",{ref:a,className:"min-w-0 overflow-x-auto rounded-lg border bg-background/50",children:(0,n.jsxs)("svg",{width:s,height:185,className:"block",role:"group","aria-label":"Attack success rate per run",children:[[0,25,50,75,100].map(e=>(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:48,x2:o,y1:c(e),y2:c(e),stroke:"var(--border)",strokeDasharray:"3 4"}),(0,n.jsxs)("text",{x:38,y:c(e)+4,textAnchor:"end",fontSize:11,fill:"var(--muted-foreground)",children:[e,"%"]})]},e)),l.length>1&&(0,n.jsx)("polyline",{points:l.map((e,t)=>"".concat(i(t),",").concat(c(e.value))).join(" "),fill:"none",stroke:"var(--viz-jailbroken)",strokeWidth:2,strokeLinejoin:"round"}),l.map((e,t)=>(0,n.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,n.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,n.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,n.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 tj={regressed:"Regressed",fixed:"Fixed",new:"New",dropped:"Dropped",unchanged:"Unchanged"},ty={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 tk(e){let{value:t}=e;return null===t?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"Not run"}):(0,n.jsx)(ew,{value:t})}function tN(e){let{comparison:t,initialChange:a,goalIndex:l}=e,[o,i]=(0,r.useState)(()=>p.on.includes(a)?a:"all"===a?null:t.counts.regressed>0?"regressed":null),c=e=>{i(e),(0,p.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,n.jsxs)("section",{"aria-label":"Goal changes",className:"investigation-panel space-y-4 p-5 sm:p-6",children:[(0,n.jsxs)("header",{children:[(0,n.jsx)("p",{className:"section-eyebrow",children:"Run comparison"}),(0,n.jsx)("h2",{className:"mt-2 text-xl font-semibold",children:"Which goals changed?"}),(0,n.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,n.jsxs)("div",{role:"group","aria-label":"Filter goals by change",className:"flex flex-wrap gap-2",children:[(0,n.jsxs)("button",{type:"button","aria-pressed":null===o,className:u(null===o),onClick:()=>c(null),children:["All ",(0,n.jsx)("span",{className:"tabular-nums",children:t.goals.length})]}),p.on.map(e=>(0,n.jsxs)("button",{type:"button","aria-pressed":o===e,className:u(o===e),onClick:()=>c(o===e?null:e),children:[tj[e]," ",(0,n.jsx)("span",{className:"tabular-nums",children:t.counts[e]})]},e))]}),t.goals.length?d.length?(0,n.jsx)("div",{className:"overflow-x-auto rounded-md border",children:(0,n.jsxs)("table",{"aria-label":"Goal outcomes in both runs",className:"w-full min-w-[760px] text-left text-sm",children:[(0,n.jsx)("thead",{className:"bg-muted/40 text-xs text-muted-foreground",children:(0,n.jsx)("tr",{children:["Goal","Category","Subcategory","Baseline","Current","Change"].map(e=>(0,n.jsx)("th",{scope:"col",className:"px-4 py-3 font-medium",children:e},e))})}),(0,n.jsx)("tbody",{children:d.map(e=>{let a=null===e.current||null==l?void 0:l.get(e.goal);return(0,n.jsxs)("tr",{className:"border-t align-top",children:[(0,n.jsx)("th",{scope:"row",className:"max-w-[28rem] px-4 py-3 font-normal",children:void 0===a?(0,n.jsx)("span",{className:"whitespace-pre-wrap break-words",children:e.goal}):(0,n.jsx)(s(),{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,n.jsx)("td",{className:"px-4 py-3",children:e.category||"Unknown category"}),(0,n.jsx)("td",{className:"px-4 py-3 text-muted-foreground",children:e.subcategory||"Unspecified"}),(0,n.jsx)("td",{className:"px-4 py-3",children:(0,n.jsx)(tk,{value:e.baseline})}),(0,n.jsx)("td",{className:"px-4 py-3",children:(0,n.jsx)(tk,{value:e.current})}),(0,n.jsx)("td",{className:"px-4 py-3 font-medium ".concat(ty[e.change]),children:tj[e.change]})]},"".concat(e.change,":").concat(e.goal))})})]})}):(0,n.jsxs)("p",{role:"status",className:"rounded-lg border p-6 text-sm text-muted-foreground",children:["No ",tj[o].toLowerCase()," goals."]}):(0,n.jsx)("p",{role:"status",className:"rounded-lg border p-6 text-sm text-muted-foreground",children:"Neither run recorded any goals to compare."})]})}function tw(){return(0,n.jsxs)("p",{role:"status",className:"flex items-center gap-2 p-6 text-sm text-muted-foreground",children:[(0,n.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Loading recorded results..."]})}function tS(e){let{message:t,retry:a}=e;return(0,n.jsxs)("div",{role:"alert",className:"investigation-panel space-y-3 p-6 text-sm",children:[(0,n.jsx)("p",{children:t}),(0,n.jsx)(x.$,{variant:"outline",onClick:a,children:"Retry"})]})}let tC=e=>e.results.some(p.Oy),t_=e=>"/stats?".concat(new URLSearchParams({run:e}));function tA(e){let{status:t}=e;return(0,n.jsxs)("div",{role:"status",className:"investigation-panel flex items-center gap-3 p-4 text-sm",children:[(0,n.jsx)(i.A,{className:"h-4 w-4 shrink-0 animate-spin text-sky-600","aria-hidden":"true"}),(0,n.jsxs)("p",{children:[(0,n.jsx)("span",{className:"font-semibold",children:"PENDING"===t?"Queued.":"Running."})," ","Showing results so far; this report updates every 5 seconds until the run finishes."]})]})}function tM(e){var t,a,l,i,c,m;let{id:g}=e,h=(0,o.useSearchParams)(),f=(null==h?void 0:h.get("section"))==="audit"||!(null==h?void 0:h.get("section"))&&(null==h?void 0:h.get("tab"))==="audit",[v,b]=(0,r.useState)(0),j=(0,p.LI)("".concat(p.dI,"/").concat(g,"/summary"),v,void 0,{pollWhile:p.Oy}),y=(0,p.LI)("".concat(p.dI,"/").concat(g,"/report"),v,void 0,{version:null==(t=j.data)?void 0:t.revision,versionOf:e=>e.revision}),k=y.data,N=(0,p.LI)(k?"".concat(p.dI,"/").concat(g,"/costs"):null,v,void 0,{version:null==k?void 0:k.revision}),w=N.data,S=null!=(i=null!=(l=null==(a=j.data)?void 0:a.status)?l:null==k?void 0:k.status)?i:"",C=!!S&&(0,p.Oy)({status:S}),_=null==k?void 0:k.id;return(0,r.useEffect)(()=>{var e,t;f&&_&&(null==(t=document.getElementById("campaign-audit"))||null==(e=t.scrollIntoView)||e.call(t,{block:"start"}))},[f,_]),(0,n.jsx)("div",{className:"runs-workspace min-h-full",children:(0,n.jsx)(u.M,{compact:!0,title:null!=(c=null==k?void 0:k.name)?c:"Campaign",action:(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[k&&(0,n.jsxs)(n.Fragment,{children:[C&&(0,n.jsx)(tx,{id:g,name:k.name}),(0,n.jsx)(to,{id:g,name:k.name,status:S}),(0,n.jsx)(tn,{id:g,name:k.name,status:S,onDeleted:()=>window.location.assign("/stats")})]}),(0,n.jsxs)(x.$,{variant:"outline",onClick:()=>b(e=>e+1),children:[(0,n.jsx)(d,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),children:(0,n.jsxs)("div",{className:"space-y-8 px-4 pb-8 sm:px-6",children:[(0,n.jsxs)("nav",{"aria-label":"Investigation breadcrumbs",className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(s(),{href:"/stats",className:"hover:underline",children:"Runs"}),(0,n.jsx)("span",{"aria-hidden":"true",children:"/"}),(0,n.jsx)("span",{className:"text-foreground",children:null!=(m=null==k?void 0:k.name)?m:"Campaign"})]}),y.error?(0,n.jsx)(tS,{message:y.error,retry:()=>b(e=>e+1)}):k?(0,n.jsxs)(n.Fragment,{children:[C&&(0,n.jsx)(tA,{status:S}),(0,n.jsx)(tv,{campaign:k}),(0,n.jsx)(ep,{campaign:k,costs:w,coverage:(0,n.jsx)(e4,{campaign:k,revision:v}),costStatus:N.error?(0,n.jsx)(tS,{message:N.error,retry:()=>b(e=>e+1)}):(0,n.jsx)(tw,{})})]}):(0,n.jsx)(tw,{})]})})})}function tL(e){var t;let{id:a,baseline:l}=e,i=(0,o.useSearchParams)(),[c,m]=(0,r.useState)(0),g=(0,p.LI)("".concat(p.dI,"/").concat(a,"/compare?").concat(new URLSearchParams({baseline:l})),c),h=g.data,f=(0,p.LI)(h?"".concat(p.dI,"/").concat(a,"/matrix"):null,c),v=(0,r.useMemo)(()=>f.data?new Map(f.data.goals.map(e=>[e.goal,e.index])):void 0,[f.data]);return(0,n.jsx)("div",{className:"runs-workspace min-h-full",children:(0,n.jsx)(u.M,{compact:!0,title:"Compare runs",action:(0,n.jsxs)(x.$,{variant:"outline",onClick:()=>m(e=>e+1),children:[(0,n.jsx)(d,{className:"mr-2 h-4 w-4"}),"Refresh"]}),children:(0,n.jsxs)("div",{className:"space-y-6 px-4 pb-8 sm:px-6",children:[(0,n.jsxs)("nav",{"aria-label":"Investigation breadcrumbs",className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(s(),{href:"/stats",className:"hover:underline",children:"Runs"}),(0,n.jsx)("span",{"aria-hidden":"true",children:"/"}),(0,n.jsx)(s(),{href:t_(a),className:"hover:underline",children:null!=(t=null==h?void 0:h.current.name)?t:"Campaign"}),(0,n.jsx)("span",{"aria-hidden":"true",children:"/"}),(0,n.jsx)("span",{className:"text-foreground",children:"Compare"})]}),g.error?(0,n.jsx)(tS,{message:g.error,retry:()=>m(e=>e+1)}):h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dl",{className:"grid gap-3 sm:grid-cols-2",children:[["Baseline",h.baseline],["Current",h.current]].map(e=>{let[t,a]=e;return(0,n.jsxs)("div",{className:"kpi-card",children:[(0,n.jsx)("dt",{className:"kpi-label",children:t}),(0,n.jsxs)("dd",{className:"mt-1 min-w-0",children:[(0,n.jsx)(s(),{href:t_(a.id),className:"block truncate font-semibold text-primary underline-offset-4 hover:underline",children:a.name}),(0,n.jsx)("time",{dateTime:a.created_at,className:"text-xs text-muted-foreground",children:new Date(a.created_at).toLocaleString()})]})]},t)})}),(0,n.jsx)(tN,{comparison:h,initialChange:null==i?void 0:i.get("change"),goalIndex:v})]}):(0,n.jsx)(tw,{})]})})})}function tR(e){let{campaign:t,runs:a}=e,r=(0,o.useRouter)(),l=new Map;for(let e of a)e.campaign&&!l.has(e.campaign)&&l.set(e.campaign,e.name);return t&&!l.has(t)&&l.set(t,"Selected campaign"),(0,n.jsxs)("label",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:"Campaign"}),(0,n.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=>r.push(e.target.value?"/stats?".concat(new URLSearchParams({campaign:e.target.value})):"/stats"),children:[(0,n.jsx)("option",{value:"",children:"All campaigns"}),Array.from(l).map(e=>{let[t,a]=e;return(0,n.jsx)("option",{value:t,children:a},t)})]})]})}function tz(e){var t,a,l;let{campaign:o}=e,[i,c]=(0,r.useState)(1),[g,h]=(0,r.useState)(0),[f,v]=(0,r.useState)(new Set),j=(e,t)=>"".concat(p.dI,"/summary?").concat(new URLSearchParams({page:String(e),page_size:String(t),...o?{campaign:o}:{}})),k=(0,p.LI)(j(1,100),g,void 0,{pollWhile:tC}),N=(0,p.LI)(i>5?j(i,20):null,g,void 0,{pollWhile:tC}),w=i>5?N.error:k.error,S=i>5?N.data:k.data?{...k.data,results:k.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:[],_=C.filter(e=>f.has(e.id)).map(e=>e.id),A=!!(null==S?void 0:S.results.some(p.Oy)),M=()=>{v(new Set),h(e=>e+1)};return(0,n.jsx)("div",{className:"runs-workspace min-h-full",children:(0,n.jsx)(u.M,{title:"Runs",description:"Compare campaign results, then explore goals and their attack conversations.",action:(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsx)(to,{ids:_,name:"selected campaigns"}),(0,n.jsx)(tn,{id:"",ids:_,name:"selected campaigns",status:"COMPLETED",onDeleted:()=>{c(1),M()}}),(0,n.jsxs)(x.$,{variant:"outline",onClick:M,children:[(0,n.jsx)(d,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),children:(0,n.jsxs)("div",{className:"space-y-4 px-4 sm:px-6",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,n.jsx)(tR,{campaign:o,runs:null!=(l=null==(t=k.data)?void 0:t.results)?l:[]}),A&&(0,n.jsxs)("p",{role:"status",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.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."]})]}),k.data&&k.data.results.length>0&&(0,n.jsx)(e8,{campaigns:k.data.results.slice(0,100),total:k.data.count}),o&&k.data&&(0,n.jsx)(tb,{runs:k.data.results}),w?(0,n.jsx)(tS,{message:w,retry:()=>h(e=>e+1)}):S?(0,n.jsxs)(n.Fragment,{children:[S.results.length?(0,n.jsx)("div",{className:"investigation-panel overflow-x-auto",children:(0,n.jsxs)("table",{className:"w-full min-w-[760px] text-left text-sm",children:[(0,n.jsx)("thead",{className:"bg-muted/40 text-xs text-muted-foreground",children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"px-3 py-3",children:(0,n.jsx)("input",{type:"checkbox","aria-label":"Select all deletable campaigns on this page",disabled:!C.length,checked:!!C.length&&_.length===C.length,onChange:e=>v(new Set(e.target.checked?C.map(e=>e.id):[]))})}),["Campaign / target","Goal outcomes","ASR","Attacks","Status","Started"].map(e=>(0,n.jsx)("th",{className:"px-5 py-3 font-medium ".concat("ASR"===e||"Attacks"===e?"text-right":""),children:e},e))]})}),(0,n.jsx)("tbody",{children:S.results.map(e=>{let t=L(e);return(0,n.jsxs)("tr",{className:"border-t transition-colors hover:bg-muted/30",children:[(0,n.jsx)("td",{className:"px-3 py-3.5",children:(0,n.jsx)("input",{type:"checkbox","aria-label":"Select ".concat(e.name),disabled:!C.some(t=>t.id===e.id),checked:_.includes(e.id),onChange:t=>v(a=>{let n=new Set(a);return t.target.checked?n.add(e.id):n.delete(e.id),n})})}),(0,n.jsxs)("td",{className:"max-w-[22rem] px-5 py-3.5",children:[(0,n.jsx)(s(),{className:"font-semibold text-primary underline-offset-4 hover:underline",href:t_(e.id),children:e.name}),(0,n.jsxs)("p",{className:"mt-0.5 flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"truncate",children:e.target}),(0,n.jsx)(z,{executor:e.executor})]})]}),(0,n.jsxs)("td",{className:"w-[30%] px-5 py-3.5",children:[(0,n.jsx)(y,{label:"".concat(e.name," outcomes"),segments:b(e)}),(0,n.jsxs)("p",{className:"mt-1.5 text-xs text-muted-foreground tabular-nums",children:[(0,n.jsx)("span",{className:"font-medium text-foreground",children:e.jailbroken})," / ",e.recorded_goals," jailbroken \xb7 ",e.mitigated," mitigated \xb7 ",e.unresolved," unresolved"]})]}),(0,n.jsx)("td",{className:"px-5 py-3.5 text-right text-base font-semibold tabular-nums",children:null===t?"—":"".concat(t.toFixed(0),"%")}),(0,n.jsx)("td",{className:"px-5 py-3.5 text-right tabular-nums",children:e.attack_runs}),(0,n.jsx)("td",{className:"px-5 py-3.5",children:(0,n.jsx)(F,{status:e.status})}),(0,n.jsx)("td",{className:"whitespace-nowrap px-5 py-3.5 text-xs text-muted-foreground",title:new Date(e.created_at).toLocaleString(),children:e6(e.created_at)})]},e.id)})})]})}):(0,n.jsx)("div",{className:"investigation-panel p-10 text-center",children:o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{className:"font-medium",children:"No runs of this campaign yet"}),(0,n.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["Launch the campaign, then refresh. ",(0,n.jsx)(s(),{href:"/stats",className:"underline",children:"Show all campaigns"}),"."]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{className:"font-medium",children:"No campaign executions yet"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Launch a campaign from Attacks or run one with the CLI, then refresh. No sample results are mixed into your history."})]})}),(0,n.jsx)(m.H,{page:i,pageSize:20,count:S.count,isLoading:!1,onPageChange:e=>{v(new Set),c(e)}})]}):(0,n.jsx)(tw,{})]})})})}function tE(){var e;let t=(0,o.useSearchParams)(),a=null==t?void 0:t.get("run"),r=null==t?void 0:t.get("baseline"),l=null!=(e=null==t?void 0:t.get("campaign"))?e:null;return a&&r?(0,n.jsx)(tL,{id:a,baseline:r},"".concat(a,":").concat(r)):a?(0,n.jsx)(tM,{id:a},a):(0,n.jsx)(tz,{campaign:l},null!=l?l:"")}function tF(){return(0,n.jsx)(r.Suspense,{fallback:(0,n.jsx)(tw,{}),children:(0,n.jsx)(tE,{})})}},98053:(e,t,a)=>{"use strict";a.d(t,{$v:()=>g,EO:()=>u,Lt:()=>o,Rx:()=>h,Zr:()=>f,ck:()=>x,r7:()=>p,tv:()=>i,wd:()=>m});var n=a(95155);a(12115);var r=a(35646),l=a(64269),s=a(3998);function o(e){let{...t}=e;return(0,n.jsx)(r.bL,{"data-slot":"alert-dialog",...t})}function i(e){let{...t}=e;return(0,n.jsx)(r.l9,{"data-slot":"alert-dialog-trigger",...t})}function c(e){let{...t}=e;return(0,n.jsx)(r.ZL,{"data-slot":"alert-dialog-portal",...t})}function d(e){let{className:t,...a}=e;return(0,n.jsx)(r.hJ,{"data-slot":"alert-dialog-overlay",className:(0,l.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,n.jsxs)(c,{children:[(0,n.jsx)(d,{}),(0,n.jsx)(r.UC,{"data-slot":"alert-dialog-content",className:(0,l.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,n.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,l.cn)("flex flex-col gap-2 text-center sm:text-left",t),...a})}function x(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,l.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...a})}function p(e){let{className:t,...a}=e;return(0,n.jsx)(r.hE,{"data-slot":"alert-dialog-title",className:(0,l.cn)("text-lg font-semibold",t),...a})}function g(e){let{className:t,...a}=e;return(0,n.jsx)(r.VY,{"data-slot":"alert-dialog-description",className:(0,l.cn)("text-muted-foreground text-sm",t),...a})}function h(e){let{className:t,...a}=e;return(0,n.jsx)(r.rc,{className:(0,l.cn)((0,s.r)(),t),...a})}function f(e){let{className:t,...a}=e;return(0,n.jsx)(r.ZD,{className:(0,l.cn)((0,s.r)({variant:"outline"}),t),...a})}}},e=>{e.O(0,[133,574,619,870,583,352,924,452,441,493,358],()=>e(e.s=49819)),_N_E=e.O()}]);