hackagent-webui 0.6.4.dev71__py3-none-any.whl → 0.6.6.dev73__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 (64) hide show
  1. hackagent_webui/__init__.py +1 -1
  2. hackagent_webui/static/404.html +2 -2
  3. hackagent_webui/static/VERSION +1 -1
  4. hackagent_webui/static/_next/static/chunks/323-48aec32488b6e5bf.js +1 -0
  5. hackagent_webui/static/_next/static/chunks/328-d42d52b81db94a35.js +1 -0
  6. hackagent_webui/static/_next/static/chunks/{921-92a9ab4120f81d51.js → 356-90f2ee305a89f642.js} +1 -1
  7. hackagent_webui/static/_next/static/chunks/{658-451b7f3b5c5a1599.js → 432-da1349ca9d0dbf5d.js} +5 -5
  8. hackagent_webui/static/_next/static/chunks/{493-34228dd02f768bba.js → 493-92a293a4bf432fc7.js} +1 -1
  9. hackagent_webui/static/_next/static/chunks/495-ac70d412256bbfe9.js +1 -0
  10. hackagent_webui/static/_next/static/chunks/546-64c7e818ab4dd2e7.js +1 -0
  11. hackagent_webui/static/_next/static/chunks/666-5ee4182c3065fd65.js +1 -0
  12. hackagent_webui/static/_next/static/chunks/683-ab457b94ca148f0e.js +1 -0
  13. hackagent_webui/static/_next/static/chunks/924-c5a440689b66a79a.js +1 -0
  14. hackagent_webui/static/_next/static/chunks/97-393ae9eee3ee20ab.js +1 -0
  15. hackagent_webui/static/_next/static/chunks/980-cc9c16cc6103edbb.js +1 -0
  16. hackagent_webui/static/_next/static/chunks/app/agents/{page-ba01b144c3c0191e.js → page-e8929149bce2396f.js} +1 -1
  17. hackagent_webui/static/_next/static/chunks/app/attacks/page-4594b3d8af3cef5c.js +1 -0
  18. hackagent_webui/static/_next/static/chunks/app/credentials/{page-ccb3279e96173cae.js → page-170ae86afa1516f9.js} +1 -1
  19. hackagent_webui/static/_next/static/chunks/app/{layout-ae76166da96be97b.js → layout-48e91819323a0ba7.js} +1 -1
  20. hackagent_webui/static/_next/static/chunks/app/page-92fb04233e8db6e2.js +1 -0
  21. hackagent_webui/static/_next/static/chunks/app/profile/{page-8d833eda8e73fb92.js → page-24382ac8cf6b7519.js} +1 -1
  22. hackagent_webui/static/_next/static/chunks/app/stats/page-742d6876a3e207d9.js +1 -0
  23. hackagent_webui/static/_next/static/chunks/{main-b2abf26ddb8313ad.js → main-c5ae269c07d252e7.js} +1 -1
  24. hackagent_webui/static/_next/static/css/920420339ac947aa.css +1 -0
  25. hackagent_webui/static/agents.html +2 -2
  26. hackagent_webui/static/agents.txt +6 -6
  27. hackagent_webui/static/api-keys.html +2 -2
  28. hackagent_webui/static/api-keys.txt +5 -5
  29. hackagent_webui/static/attacks.html +2 -2
  30. hackagent_webui/static/attacks.txt +6 -6
  31. hackagent_webui/static/campaign-export/runtime.js +96 -128
  32. hackagent_webui/static/campaign-export/styles.css +1 -1
  33. hackagent_webui/static/credentials.html +2 -2
  34. hackagent_webui/static/credentials.txt +6 -6
  35. hackagent_webui/static/index.html +2 -2
  36. hackagent_webui/static/index.txt +6 -6
  37. hackagent_webui/static/profile.html +2 -2
  38. hackagent_webui/static/profile.txt +6 -6
  39. hackagent_webui/static/secrets.html +2 -2
  40. hackagent_webui/static/secrets.txt +5 -5
  41. hackagent_webui/static/stats.html +2 -2
  42. hackagent_webui/static/stats.txt +6 -6
  43. hackagent_webui/static/usage.html +2 -2
  44. hackagent_webui/static/usage.txt +6 -6
  45. {hackagent_webui-0.6.4.dev71.dist-info → hackagent_webui-0.6.6.dev73.dist-info}/METADATA +1 -1
  46. hackagent_webui-0.6.6.dev73.dist-info/RECORD +82 -0
  47. hackagent_webui/static/_next/static/chunks/160-21f7abf9e76923d9.js +0 -1
  48. hackagent_webui/static/_next/static/chunks/452-33805ea7d3b33b29.js +0 -1
  49. hackagent_webui/static/_next/static/chunks/592-cb13179874c3bab1.js +0 -1
  50. hackagent_webui/static/_next/static/chunks/634-ef141668e76853c1.js +0 -1
  51. hackagent_webui/static/_next/static/chunks/688-74942a135eec7c34.js +0 -1
  52. hackagent_webui/static/_next/static/chunks/747-aa8aa91116de6e71.js +0 -1
  53. hackagent_webui/static/_next/static/chunks/764-b642e364454b2ac4.js +0 -1
  54. hackagent_webui/static/_next/static/chunks/888-2e968371d359a872.js +0 -1
  55. hackagent_webui/static/_next/static/chunks/924-926086aa93c839d8.js +0 -1
  56. hackagent_webui/static/_next/static/chunks/970-bc5945a148c7d8b8.js +0 -1
  57. hackagent_webui/static/_next/static/chunks/app/attacks/page-f2852f796ad98f7a.js +0 -1
  58. hackagent_webui/static/_next/static/chunks/app/page-40fdbb3c458241bf.js +0 -1
  59. hackagent_webui/static/_next/static/chunks/app/stats/page-9cc34ee4b1a8895d.js +0 -1
  60. hackagent_webui/static/_next/static/css/acc5ec9d7fb72178.css +0 -1
  61. hackagent_webui-0.6.4.dev71.dist-info/RECORD +0 -83
  62. /hackagent_webui/static/_next/static/{7av25iIXZJ4ESHYoziC9t → BB2pDANDGPKWiJdI-62Hn}/_buildManifest.js +0 -0
  63. /hackagent_webui/static/_next/static/{7av25iIXZJ4ESHYoziC9t → BB2pDANDGPKWiJdI-62Hn}/_ssgManifest.js +0 -0
  64. {hackagent_webui-0.6.4.dev71.dist-info → hackagent_webui-0.6.6.dev73.dist-info}/WHEEL +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[80],{3549:(e,t,a)=>{Promise.resolve().then(a.bind(a,95076))},3730:(e,t,a)=>{"use strict";a.d(t,{Ke:()=>l,Nt:()=>n,R6:()=>r});var s=a(49578);let n=s.bL,r=s.R6,l=s.Ke},6259:(e,t,a)=>{"use strict";a.d(t,{SQ:()=>o,_2:()=>c,mB:()=>d,rI:()=>l,ty:()=>i});var s=a(95155);a(12115);var n=a(24595),r=a(64269);function l(e){let{...t}=e;return(0,s.jsx)(n.bL,{"data-slot":"dropdown-menu",...t})}function i(e){let{...t}=e;return(0,s.jsx)(n.l9,{"data-slot":"dropdown-menu-trigger",...t})}function o(e){let{className:t,sideOffset:a=4,...l}=e;return(0,s.jsx)(n.ZL,{children:(0,s.jsx)(n.UC,{"data-slot":"dropdown-menu-content",sideOffset:a,className:(0,r.cn)("bg-popover text-popover-foreground 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 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 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...l})})}function c(e){let{className:t,inset:a,variant:l="default",...i}=e;return(0,s.jsx)(n.q7,{"data-slot":"dropdown-menu-item","data-inset":a,"data-variant":l,className:(0,r.cn)("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...i})}function d(e){let{className:t,...a}=e;return(0,s.jsx)(n.wv,{"data-slot":"dropdown-menu-separator",className:(0,r.cn)("bg-border -mx-1 my-1 h-px",t),...a})}},11647:(e,t,a)=>{"use strict";a.d(t,{E:()=>o});var s=a(95155);a(12115);var n=a(32467),r=a(83101),l=a(64269);let i=(0,r.F)("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none 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 transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function o(e){let{className:t,variant:a,asChild:r=!1,...o}=e,c=r?n.DX:"span";return(0,s.jsx)(c,{"data-slot":"badge",className:(0,l.cn)(i({variant:a}),t),...o})}},13217:(e,t,a)=>{"use strict";a.d(t,{CK:()=>c,db:()=>d});var s=a(12115),n=a(67062),r=a(97145);let l=null,i=null;function o(){let{config:e}=(0,r.y)(),t=(0,n.l)()||"disabled"===e.authProvider,[a,o]=(0,s.useState)(l);return(0,s.useEffect)(()=>{if(!t||null!==a)return;let e=!0;return(null!=i||(i=fetch("/healthz").then(e=>e.ok?e.json():null).then(e=>{let t=e&&"object"==typeof e?e.mode:void 0;return"local"===t||"remote"===t?t:"other"}).catch(()=>"other").then(e=>l=e)),i).then(t=>{e&&o(t)}),()=>{e=!1}},[t,a]),{authDisabled:t,mode:a}}function c(){let{authDisabled:e,mode:t}=o();return e&&(null===t||"local"===t)}function d(){let{authDisabled:e,mode:t}=o();return e&&("local"===t||"remote"===t)}},13406:(e,t,a)=>{"use strict";a.d(t,{Xi:()=>o,av:()=>c,j7:()=>i,tU:()=>l});var s=a(95155);a(12115);var n=a(49543),r=a(64269);function l(e){let{className:t,...a}=e;return(0,s.jsx)(n.bL,{"data-slot":"tabs",className:(0,r.cn)("flex flex-col gap-2",t),...a})}function i(e){let{className:t,...a}=e;return(0,s.jsx)(n.B8,{"data-slot":"tabs-list",className:(0,r.cn)("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",t),...a})}function o(e){let{className:t,...a}=e;return(0,s.jsx)(n.l9,{"data-slot":"tabs-trigger",className:(0,r.cn)("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 hover:bg-background/50 dark:hover:bg-input/20 data-[state=active]:hover:bg-background dark:data-[state=active]:hover:bg-input/30",t),...a})}function c(e){let{className:t,...a}=e;return(0,s.jsx)(n.UC,{"data-slot":"tabs-content",className:(0,r.cn)("flex-1 outline-none",t),...a})}},17037:(e,t,a)=>{"use strict";a.d(t,{$:()=>i,F:()=>l});var s=a(95155);a(12115);var n=a(47397),r=a(64269);function l(e){let{className:t,children:a,...l}=e;return(0,s.jsxs)(n.bL,{"data-slot":"scroll-area",className:(0,r.cn)("relative",t),...l,children:[(0,s.jsx)(n.LM,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:a}),(0,s.jsx)(i,{}),(0,s.jsx)(n.OK,{})]})}function i(e){let{className:t,orientation:a="vertical",...l}=e;return(0,s.jsx)(n.VM,{"data-slot":"scroll-area-scrollbar",orientation:a,className:(0,r.cn)("flex touch-none p-px transition-colors select-none","vertical"===a&&"h-full w-2.5 border-l border-l-transparent","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent",t),...l,children:(0,s.jsx)(n.lr,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}},39166:(e,t,a)=>{"use strict";a.d(t,{j:()=>l,w:()=>s});let s=["OPENAI","LITELLM","OLLAMA"],n={kind:"anywhere",label:"Launchable"},r="Endpoint is a local address";function l(e){var t;let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=function(e){let t=e.config;if("object"!=typeof t||null===t)return null;let a=t.connection;return"object"==typeof a&&null!==a?a:null}(e);if(!l)return{kind:"unsupported",label:"Not launchable from the dashboard yet",reason:"This agent has no model configuration yet. Edit and save it on the Targets page."};let i=String(null!=(t=l.type)?t:"");if(!s.includes(i))return{kind:"unsupported",label:"Not launchable from the dashboard yet",reason:"Only OpenAI, LiteLLM and Ollama agents can be launched from the dashboard."};let o="string"==typeof l.endpoint?l.endpoint.trim():"";if(!o)return"OLLAMA"!==i||a?n:{kind:"local",label:"Local network",reason:"".concat(r," (defaults to localhost)")};let c=function(e){try{return new URL(e.includes("://")?e:"http://".concat(e)).hostname.toLowerCase().replace(/\.$/,"").replace(/^\[(.*)\]$/,"$1")}catch(e){return null}}(o);if(!c)return{kind:"local",label:"Local network",reason:"Endpoint is not a valid URL"};let d=a?null:function(e){if("localhost"===e||e.endsWith(".localhost")||e.endsWith(".local")||"::1"===e)return r;let t=function(e){let t=e.split(".");if(4!==t.length||!t.every(e=>/^\d{1,3}$/.test(e)))return null;let a=t.map(Number);return a.every(e=>e<=255)?a:null}(e);if(!t)return null;let[a,s]=t;return 127===a?r:10===a||172===a&&s>=16&&s<=31||192===a&&168===s?"Endpoint is a private network address":null}(c);return d?{kind:"local",label:"Local network",reason:d}:n}},44846:(e,t,a)=>{"use strict";a.d(t,{d:()=>l});var s=a(95155);a(12115);var n=a(45927),r=a(64269);function l(e){let{className:t,...a}=e;return(0,s.jsx)(n.bL,{"data-slot":"switch",className:(0,r.cn)("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:(0,s.jsx)(n.zi,{"data-slot":"switch-thumb",className:(0,r.cn)("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}},67062:(e,t,a)=>{"use strict";function s(){return!0}function n(){return{email:"dev@hackagent.local",name:"Dev User",preferred_username:"dev",picture:'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48"><rect fill="%23ccc" width="48" height="48"/><text x="50%25" y="50%25" dominant-baseline="middle" text-anchor="middle" font-family="sans-serif" font-size="24" fill="%23666">D</text></svg>'}}a.d(t,{Y:()=>n,l:()=>s})},86259:(e,t,a)=>{"use strict";a.d(t,{w:()=>l});var s=a(95155);a(12115);var n=a(57268),r=a(64269);function l(e){let{className:t,orientation:a="horizontal",decorative:l=!0,...i}=e;return(0,s.jsx)(n.b,{"data-slot":"separator-root",decorative:l,orientation:a,className:(0,r.cn)("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...i})}},86948:(e,t,a)=>{"use strict";a.d(t,{BT:()=>o,Wu:()=>d,X9:()=>c,ZB:()=>i,Zp:()=>r,aR:()=>l});var s=a(95155);a(12115);var n=a(64269);function r(e){let{className:t,...a}=e;return(0,s.jsx)("div",{"data-slot":"card",className:(0,n.cn)("bg-card text-card-foreground flex flex-col gap-6 rounded border py-6",t),...a})}function l(e){let{className:t,...a}=e;return(0,s.jsx)("div",{"data-slot":"card-header",className:(0,n.cn)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...a})}function i(e){let{className:t,...a}=e;return(0,s.jsx)("div",{"data-slot":"card-title",className:(0,n.cn)("leading-none font-semibold",t),...a})}function o(e){let{className:t,...a}=e;return(0,s.jsx)("div",{"data-slot":"card-description",className:(0,n.cn)("text-muted-foreground text-sm",t),...a})}function c(e){let{className:t,...a}=e;return(0,s.jsx)("div",{"data-slot":"card-action",className:(0,n.cn)("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),...a})}function d(e){let{className:t,...a}=e;return(0,s.jsx)("div",{"data-slot":"card-content",className:(0,n.cn)("px-6",t),...a})}},95076:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>sh});var s=a(95155),n=a(12115),r=a(20063),l=a(65229),i=a(35835),o=a(22470),c=a(18332),d=a(3998),u=a(7831),m=a(25733),x=a(50803),p=a(37772),h=a(93779),g=a(39867),f=a(35299),j=a(46046),v=a(20639),b=a(23327),N=a(4882),y=a(43226);function k(e){var t,a,s;return{key:e.key,label:e.label,type:e.type,default:null!=(t=e._default)?t:void 0,description:e.description||void 0,required:e.required,choices:e.choices?e.choices:void 0,min:null!=(a=e.min)?a:void 0,max:null!=(s=e.max)?s:void 0,section:e.section||void 0,advanced:e.advanced}}function w(e){return{attackType:e.attackType,label:e.label,description:e.description,category:e.category,categoryLabel:e.categoryLabel,tags:e.tags,fields:e.fields.map(k),requiredRoles:e.requiredRoles,optionalRoles:e.optionalRoles}}var A=a(6259),_=a(65142),C=a(76444),S=a(20243),E=a(64269);function R(e){let{className:t,...a}=e;return(0,s.jsx)("textarea",{"data-slot":"textarea",className:(0,E.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...a})}var T=a(39166),O=a(1088),L=a(42710),I=a(41444),z=a(27937),M=a(3730),J=a(11186);function P(e){let{title:t,children:a}=e,[r,l]=(0,n.useState)(!1);return(0,s.jsxs)(M.Nt,{open:r,onOpenChange:l,children:[(0,s.jsx)(M.R6,{asChild:!0,children:(0,s.jsxs)(d.$,{variant:"ghost",size:"sm",className:"-ml-2 text-muted-foreground",children:[(0,s.jsx)(z.A,{className:(0,E.cn)("transition-transform",r&&"rotate-90")}),t]})}),(0,s.jsx)(M.Ke,{forceMount:!0,className:"space-y-3 pt-3 data-[state=closed]:hidden",children:a})]})}function D(e){let{value:t,label:a,onChange:r,onValidityChange:l}=e,i=(0,n.useRef)(t),o=(0,n.useRef)(!1),[c,d]=(0,n.useState)(()=>JSON.stringify(t,null,2)),[u,m]=(0,n.useState)(null);return(0,O.bD)(t,i.current)||(i.current=t,o.current=!0,d(JSON.stringify(t,null,2)),m(null)),(0,n.useEffect)(()=>{o.current&&(o.current=!1,null==l||l(!0))},[t,l]),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R,{"aria-label":a,"aria-invalid":!!u,value:c,rows:8,className:"font-mono text-xs",onChange:e=>{let t=e.target.value;d(t);try{let e=JSON.parse(t);if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Enter a JSON object.");if((0,O.qn)(e).length)throw Error("Use a named secret reference such as ${PROVIDER_API_KEY} for credentials.");i.current=e,m(null),r(e),null==l||l(!0)}catch(e){m(e instanceof Error?e.message:"Invalid configuration."),null==l||l(!1)}}}),u&&(0,s.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:u})]})}let F=e=>e&&"object"==typeof e&&!Array.isArray(e)?e:{},U={name:"",connection:{provider:"openai",type:"OPENAI"}};function q(e){var t,a,r,l,i,o,c,u,m,x;let{value:p,defaultModel:h,label:g,scoringTypes:f=[],judge:j=!1,actions:v,onChange:b,onValidityChange:N}=e,y=(0,n.useId)(),[k,w]=(0,n.useState)(!1),A=F(p.connection),S=F(p.generation),T=F(p.scoring),L="hackagent"===A.provider&&!A.endpoint,I=(e,t)=>{let a={...A};""===t?delete a[e]:a[e]=t,b({...p,connection:a})};return(0,s.jsxs)("fieldset",{className:"min-w-0",children:[(0,s.jsx)("legend",{className:"sr-only",children:g}),(0,s.jsxs)(M.Nt,{open:k,onOpenChange:w,children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)(M.R6,{asChild:!0,children:(0,s.jsxs)(d.$,{variant:"ghost",size:"sm","aria-label":"Configure ".concat(g),className:"h-auto min-w-0 flex-1 justify-start px-2 py-2 text-left",children:[(0,s.jsx)(z.A,{className:(0,E.cn)("shrink-0 transition-transform",k&&"rotate-90")}),(0,s.jsx)("span",{className:"shrink-0 font-medium",children:g}),(0,s.jsxs)("span",{className:"truncate font-normal text-muted-foreground",children:[L?"HackAgent default":String(p.name||"Custom model"),j?" \xb7 ".concat(String(null!=(t=T.type)?t:"harmbench")):""]})]})}),v]}),(0,s.jsxs)(M.Ke,{forceMount:!0,className:"space-y-3 px-2 pb-2 pt-3 data-[state=closed]:hidden",children:[(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(y,"-source"),children:"Model configuration"}),(0,s.jsxs)(J.l6,{value:L?"default":"custom",onValueChange:e=>{null==N||N(!0),b("default"===e?structuredClone(h):structuredClone(U))},children:[(0,s.jsx)(J.bq,{id:"".concat(y,"-source"),className:"w-full",children:(0,s.jsx)(J.yv,{})}),(0,s.jsxs)(J.gC,{children:[(0,s.jsx)(J.eb,{value:"default",children:"HackAgent default"}),(0,s.jsx)(J.eb,{value:"custom",children:"Custom model"})]})]})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(y,"-name"),children:"Model name"}),(0,s.jsx)(_.p,{id:"".concat(y,"-name"),value:String(null!=(a=p.name)?a:""),readOnly:L,required:!0,onChange:e=>b({...p,name:e.target.value})})]}),!L&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(y,"-type"),children:"Connection type"}),(0,s.jsxs)(J.l6,{value:String(null!=(r=A.type)?r:"OPENAI"),onValueChange:e=>I("type",e),children:[(0,s.jsx)(J.bq,{id:"".concat(y,"-type"),className:"w-full",children:(0,s.jsx)(J.yv,{})}),(0,s.jsx)(J.gC,{children:Array.from(new Set(["OPENAI","LITELLM","OLLAMA",String(null!=(l=A.type)?l:"OPENAI")])).map(e=>(0,s.jsx)(J.eb,{value:e,children:e},e))})]})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(y,"-provider"),children:"Provider"}),(0,s.jsx)(_.p,{id:"".concat(y,"-provider"),value:String(null!=(i=A.provider)?i:""),onChange:e=>I("provider",e.target.value)})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(y,"-endpoint"),children:"Endpoint"}),(0,s.jsx)(_.p,{id:"".concat(y,"-endpoint"),value:String(null!=(o=A.endpoint)?o:""),placeholder:"Provider default",onChange:e=>I("endpoint",e.target.value)})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(y,"-secret"),children:"Secret name"}),(0,s.jsx)(_.p,{id:"".concat(y,"-secret"),value:null!=(c=(0,O.rR)(A.api_key))?c:"",placeholder:"PROVIDER_API_KEY",onChange:e=>I("api_key",e.target.value?(0,O.QO)(e.target.value):"")}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Use a secret from Credentials."})]})]}),j&&(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(y,"-scoring"),children:"Scoring method"}),(0,s.jsx)(_.p,{id:"".concat(y,"-scoring"),list:"".concat(y,"-scoring-types"),value:String(null!=(u=T.type)?u:"harmbench"),onChange:e=>b({...p,scoring:{...T,type:e.target.value}})}),(0,s.jsx)("datalist",{id:"".concat(y,"-scoring-types"),children:f.map(e=>(0,s.jsx)("option",{value:e},e))})]})]}),(0,s.jsxs)(P,{title:"Advanced model configuration",children:[(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[!L&&(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(y,"-timeout"),children:"Timeout (seconds)"}),(0,s.jsx)(_.p,{id:"".concat(y,"-timeout"),type:"number",min:.1,step:"any",value:null!=(m=A.timeout)?m:"",placeholder:"120",onChange:e=>I("timeout",""===e.target.value?"":Number(e.target.value))})]}),["temperature","max_tokens","top_p"].map(e=>{var t;return(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(y,"-").concat(e),children:{temperature:"Temperature",max_tokens:"Maximum output tokens",top_p:"Top p"}[e]}),(0,s.jsx)(_.p,{id:"".concat(y,"-").concat(e),type:"number",min:+("max_tokens"===e),max:"top_p"===e?1:void 0,step:"max_tokens"===e?1:"any",value:null!=(t=S[e])?t:"",placeholder:"Provider default",onChange:t=>((e,t)=>{let a={...S};""===t?delete a[e]:a[e]=Number(t),b({...p,generation:a})})(e,t.target.value)})]},e)})]}),j&&(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(y,"-prompt"),children:"Judge system prompt"}),(0,s.jsx)(R,{id:"".concat(y,"-prompt"),value:String(null!=(x=T.system_prompt)?x:""),placeholder:"Use the scoring method’s default prompt",rows:2,onChange:e=>{let t={...T};e.target.value?t.system_prompt=e.target.value:delete t.system_prompt,b({...p,scoring:t})}})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Edit headers, generation options and other model settings as JSON."}),(0,s.jsx)(D,{value:p,label:"".concat(g," JSON"),onChange:b,onValidityChange:N})]})]})]})]})}var H=a(6191),B=a(20562),$=a(8803),G=a(71360),W=a(37397),V=a(44846);function Z(e){return Array.isArray(e)?e.join("\n"):""}function K(e){return null==e?"":"string"==typeof e?e:JSON.stringify(e,null,2)}function X(e){let t,{field:a,value:r,onChange:l,error:i,onValidityChange:o}=e,c=(0,n.useId)(),[d,u]=(0,n.useState)(()=>"array"===a.type?Z(r):K(r)),[m,x]=(0,n.useState)(null),p=(0,n.useRef)(r);r!==p.current&&("array"===a.type||"object"===a.type)&&(p.current=r,u("array"===a.type?Z(r):K(r)),x(null));let h=(0,n.useRef)(!0),g=(0,n.useRef)(o);g.current=o,(0,n.useEffect)(()=>{let e=null===m;if(e!==h.current){var t;h.current=e,null==(t=g.current)||t.call(g,e)}},[m]);let f=e=>{p.current=e,l(e)},j=[a.description?"".concat(c,"-help"):null,i?"".concat(c,"-error"):null].filter(Boolean).join(" ")||void 0;switch(a.type){case"integer":case"number":{let e=function(e){let{min:t,max:a}=e;return null!=t&&null!=a?"Min ".concat(t,", max ").concat(a):null!=t?"Min ".concat(t):null!=a?"Max ".concat(a):null}(a);t=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(_.p,{id:c,type:"number",min:a.min,max:a.max,step:"integer"===a.type?1:"any",value:null==r?"":String(r),"aria-invalid":!!i||void 0,"aria-describedby":j,onChange:e=>{let t=e.target.value;l(""===t?void 0:Number(t))}}),e&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e})]});break}case"boolean":t=(0,s.jsx)(V.d,{id:c,checked:!!r,onCheckedChange:e=>l(e),"aria-describedby":j});break;case"choice":{var v;let e=null!=(v=a.choices)?v:[],n=e.findIndex(e=>{let[,t]=e;return Object.is(t,r)});t=(0,s.jsxs)(J.l6,{value:n>=0?String(n):void 0,onValueChange:t=>l(e[Number(t)][1]),children:[(0,s.jsx)(J.bq,{id:c,"aria-invalid":!!i||void 0,"aria-describedby":j,children:(0,s.jsx)(J.yv,{placeholder:"Select…"})}),(0,s.jsx)(J.gC,{children:e.map((e,t)=>{let[a]=e;return(0,s.jsx)(J.eb,{value:String(t),children:a},t)})})]});break}case"array":t=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{id:c,value:d,"aria-invalid":!!i||void 0,"aria-describedby":j,onChange:e=>{u(e.target.value),f(e.target.value.split("\n").filter(e=>""!==e.trim()))}}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"One item per line"})]});break;case"object":t=(0,s.jsx)(R,{id:c,className:"font-mono",value:d,"aria-invalid":!!i||!!m||void 0,"aria-describedby":j,onChange:e=>{let t=e.target.value;if(u(t),""===t.trim()){x(null),f(void 0);return}try{let e=JSON.parse(t);x(null),f(e)}catch(e){x("Invalid JSON")}}});break;default:t=(0,s.jsx)(_.p,{id:c,value:null==r?"":String(r),"aria-invalid":!!i||void 0,"aria-describedby":j,onChange:e=>l(e.target.value)})}let b="boolean"===a.type;return(0,s.jsxs)("div",{className:"space-y-1.5","data-testid":"field-".concat(a.key),children:[(0,s.jsxs)("div",{className:b?"flex items-center justify-between gap-3":void 0,children:[(0,s.jsxs)(C.J,{htmlFor:c,children:[a.label,a.required&&(0,s.jsx)("span",{className:"text-destructive",children:"*"})]}),b&&t]}),!b&&t,a.description&&(0,s.jsx)("p",{id:"".concat(c,"-help"),className:"text-xs text-muted-foreground",children:a.description}),m&&(0,s.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:m}),i&&(0,s.jsx)("p",{id:"".concat(c,"-error"),className:"text-xs text-destructive",role:"alert",children:i})]})}var Y=a(56419),Q=a(11647),ee=a(41808),et=a(86651),ea=a(51834);function es(e){let{className:t,...a}=e;return(0,s.jsx)(ee.uB,{"data-slot":"command",className:(0,E.cn)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...a})}function en(e){let{className:t,...a}=e;return(0,s.jsxs)("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[(0,s.jsx)(et.A,{className:"size-4 shrink-0 opacity-50"}),(0,s.jsx)(ee.uB.Input,{"data-slot":"command-input",className:(0,E.cn)("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),...a})]})}function er(e){let{className:t,...a}=e;return(0,s.jsx)(ee.uB.List,{"data-slot":"command-list",className:(0,E.cn)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...a})}function el(e){let{...t}=e;return(0,s.jsx)(ee.uB.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function ei(e){let{className:t,...a}=e;return(0,s.jsx)(ee.uB.Group,{"data-slot":"command-group",className:(0,E.cn)("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",t),...a})}function eo(e){let{className:t,...a}=e;return(0,s.jsx)(ee.uB.Item,{"data-slot":"command-item",className:(0,E.cn)("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...a})}var ec=a(26333),ed=a(86948);function eu(e){let{step:t,title:a,description:n,action:r,errors:l,children:i}=e,o="builder-step-".concat(t);return(0,s.jsxs)(ed.Zp,{"aria-labelledby":o,role:"region",className:"gap-4",children:[(0,s.jsxs)(ed.aR,{children:[(0,s.jsxs)(ed.ZB,{id:o,className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"inline-flex size-6 items-center justify-center rounded-full bg-muted text-xs font-semibold text-muted-foreground",children:t}),a]}),(0,s.jsx)(ed.BT,{className:"pl-8",children:n}),r&&(0,s.jsx)(ed.X9,{children:r})]}),(0,s.jsxs)(ed.Wu,{className:"space-y-4",children:[l&&l.length>0&&(0,s.jsx)("ul",{className:"space-y-1 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",role:"alert",children:l.map(e=>(0,s.jsx)("li",{children:e},e))}),i]})]})}function em(e){let{catalogue:t,onAdd:a}=e,[r,l]=(0,n.useState)(!1);return(0,s.jsxs)(ec.AM,{open:r,onOpenChange:l,children:[(0,s.jsx)(ec.Wv,{asChild:!0,children:(0,s.jsxs)(d.$,{variant:"outline",size:"sm",disabled:0===t.length,children:[(0,s.jsx)(H.A,{})," Add technique"]})}),(0,s.jsx)(ec.hl,{align:"end",className:"w-[min(26rem,calc(100vw-2rem))] p-0",children:(0,s.jsxs)(es,{children:[(0,s.jsx)(en,{placeholder:"Search techniques…"}),(0,s.jsxs)(er,{className:"max-h-96",children:[(0,s.jsx)(el,{children:"No technique matches."}),(function(e){let t=new Map;for(let s of e){var a;let e=null!=(a=t.get(s.category))?a:{label:s.categoryLabel,techniques:[]};e.techniques.push(s),t.set(s.category,e)}return Array.from(t.values())})(t).map(e=>(0,s.jsx)(ei,{heading:e.label,children:e.techniques.map(t=>(0,s.jsxs)(eo,{value:t.attackType,keywords:[t.label,e.label,...t.tags],className:"flex-col items-start gap-0.5",onSelect:()=>{a(t.attackType),l(!1)},children:[(0,s.jsx)("span",{className:"font-medium",children:t.label}),t.description&&(0,s.jsx)("span",{className:"line-clamp-2 text-xs text-muted-foreground",children:t.description})]},t.attackType))},e.label))]})]})})]})}let ex=new Set(["array","object"]);function ep(e){let t=e.replace(/_/g," ");return t.charAt(0).toUpperCase()+t.slice(1)}function eh(e){var t,a,r,l,i;let{index:o,count:c,attack:u,technique:m,errors:x,onChange:p,onRolesChange:h,onMove:g,onRemove:f,onValidityChange:j}=e,v=null!=(t=null==m?void 0:m.label)?t:u.attackType,b=null!=(a=null==m?void 0:m.fields)?a:[],N=e=>x["parameters.".concat(e.key)],y=new Set(b.map(e=>"parameters.".concat(e.key))),k=Object.entries(x).filter(e=>{let[t]=e;return!y.has(t)}).map(e=>{let[t,a]=e;return t?"".concat(t,": ").concat(a):a}),w=b.filter(e=>!e.advanced),A=b.filter(e=>e.advanced),[_,C]=(0,n.useState)(!1),S=null!=(r=u.roles)?r:{},R=[...(null!=(l=null==m?void 0:m.requiredRoles)?l:[]).map(e=>({role:e,custom:S[e]})),...Object.keys(S).filter(e=>!(null==m?void 0:m.requiredRoles.includes(e))).map(e=>({role:e,custom:S[e]}))],T=A.some(e=>N(e)),L=e=>(0,s.jsx)("div",{className:(0,E.cn)(ex.has(e.type)&&"sm:col-span-2"),children:(0,s.jsx)(X,{field:e,value:u.parameters[e.key],error:N(e),onChange:t=>p(e.key,t),onValidityChange:t=>j(e.key,t)})},e.key);return(0,s.jsxs)("li",{"data-testid":"attack-card-".concat(o),"aria-label":"".concat(o+1,". ").concat(v),className:(0,E.cn)("rounded-md border bg-background",Object.keys(x).length>0&&"border-destructive/60"),children:[(0,s.jsxs)("div",{className:"flex items-start gap-3 border-b px-4 py-3",children:[(0,s.jsx)("span",{className:"mt-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-xs font-semibold tabular-nums text-muted-foreground",children:o+1}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium",children:v}),m&&(0,s.jsx)(Q.E,{variant:"secondary",children:m.categoryLabel})]}),(null==m?void 0:m.description)&&(0,s.jsx)("p",{className:"mt-0.5 line-clamp-2 text-xs text-muted-foreground",children:m.description})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"size-8","aria-label":"Move ".concat(v," up"),disabled:0===o,onClick:()=>g(-1),children:(0,s.jsx)(B.A,{})}),(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"size-8","aria-label":"Move ".concat(v," down"),disabled:o===c-1,onClick:()=>g(1),children:(0,s.jsx)($.A,{})}),(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"size-8 text-muted-foreground hover:text-destructive","aria-label":"Remove ".concat(v),onClick:f,children:(0,s.jsx)(G.A,{})})]})]}),(0,s.jsxs)("div",{className:"space-y-4 px-4 py-4",children:[!m&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"This technique is not in the server's catalogue. Its parameters are kept as they are."}),k.length>0&&(0,s.jsx)("ul",{className:"space-y-1 text-sm text-destructive",role:"alert",children:k.map(e=>(0,s.jsx)("li",{children:e},e))}),w.length>0&&(0,s.jsx)("div",{className:"grid gap-4 sm:grid-cols-2",children:w.map(L)}),m&&0===b.length&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"This technique has no settings."}),A.length>0&&(0,s.jsxs)(M.Nt,{open:_||T,onOpenChange:C,children:[(0,s.jsx)(M.R6,{asChild:!0,children:(0,s.jsxs)(d.$,{variant:"ghost",size:"sm",className:"-ml-2 text-muted-foreground",children:[(0,s.jsx)(z.A,{className:(0,E.cn)("transition-transform",(_||T)&&"rotate-90")}),"Advanced settings (",A.length,")"]})}),(0,s.jsx)(M.Ke,{className:"grid gap-4 pt-3 sm:grid-cols-2",children:A.map(L)})]}),(R.length>0||(null!=(i=null==m?void 0:m.optionalRoles.length)?i:0)>0)&&(0,s.jsxs)("div",{className:"space-y-1 border-t pt-2",children:[R.map(e=>{let{role:t,custom:a}=e;return(0,s.jsx)("div",{children:(0,s.jsx)(q,{label:ep(t),value:null!=a?a:O.rV,defaultModel:O.rV,onChange:e=>h({...S,[t]:e}),onValidityChange:e=>j("role-".concat(t),e),actions:!(null==m?void 0:m.requiredRoles.includes(t))&&(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"size-8 text-muted-foreground hover:text-destructive","aria-label":"Remove ".concat(ep(t)),onClick:()=>{let e={...S};delete e[t],j("role-".concat(t),!0),h(e)},children:(0,s.jsx)(G.A,{})})})},t)}),null==m?void 0:m.optionalRoles.filter(e=>!(e in S)).map(e=>(0,s.jsxs)(d.$,{variant:"outline",size:"sm",onClick:()=>h({...S,[e]:structuredClone(O.rV)}),children:[(0,s.jsx)(H.A,{}),"Add ",ep(e)]},e))]})]})]})}function eg(e){let{catalogue:t,attacks:a,cardKeys:n,listErrors:r,cardErrors:l,onAdd:i,onChange:o,onRolesChange:c,onMove:d,onRemove:u,onValidityChange:m}=e;return(0,s.jsx)(eu,{step:3,title:"Attacks",description:"Techniques run in order against every goal.",action:(0,s.jsx)(em,{catalogue:t,onAdd:i}),errors:r,children:0===a.length?(0,s.jsx)("div",{className:"rounded-md border border-dashed",children:(0,s.jsx)(Y.p,{icon:W.A,title:"No techniques yet",description:"Use Add technique to pick at least one. Each technique runs against every goal."})}):(0,s.jsx)("ol",{className:"space-y-3",children:a.map((e,r)=>{var i;return(0,s.jsx)(eh,{index:r,count:a.length,attack:e,technique:t.find(t=>t.attackType===e.attackType),errors:null!=(i=l[r])?i:{},onRolesChange:e=>c(r,e),onChange:(e,t)=>o(r,e,t),onMove:e=>d(r,e),onRemove:()=>u(r),onValidityChange:(e,t)=>m(n[r],e,t)},n[r])})})})}let ef={attack:{label:"Goals at the same time",help:"Goals the attacks generate requests for in parallel."},target:{label:"Target requests at the same time",help:"Requests that may wait on the target at once."},judge:{label:"Judgements at the same time",help:"Replies the judges may score at once."}},ej="Enter a whole number from ".concat(O.nK," to ").concat(O.Xx,".");function ev(e){let t=""===e.trim()?NaN:Number(e);return(0,O.Sq)(t)?t:null}function eb(e){let{concurrency:t,onChange:a,errors:r,onValidityChange:l}=e,i=(0,n.useId)(),[o,c]=(0,n.useState)(()=>Object.fromEntries(O.Lt.map(e=>[e,String(t[e])])));return(0,s.jsxs)(eu,{step:5,title:"Execution",description:"How much work runs at the same time on the attack, target and judge models.",errors:r,children:[(0,s.jsx)("div",{className:"grid gap-4 sm:grid-cols-3",children:O.Lt.map(e=>{let n=null===ev(o[e]),r="".concat(i,"-").concat(e);return(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:r,children:ef[e].label}),(0,s.jsx)(_.p,{id:r,type:"number",inputMode:"numeric",min:O.nK,max:O.Xx,step:1,value:o[e],"aria-invalid":!!n||void 0,"aria-describedby":"".concat(r,"-help").concat(n?" ".concat(r,"-error"):""),onChange:s=>((e,s)=>{c(t=>({...t,[e]:s}));let n=ev(s);null==l||l(e,null!==n),null!==n&&a({...t,[e]:n})})(e,s.target.value)}),(0,s.jsx)("p",{id:"".concat(r,"-help"),className:"text-xs text-muted-foreground",children:ef[e].help}),n&&(0,s.jsx)("p",{id:"".concat(r,"-error"),className:"text-xs text-destructive",role:"alert",children:ej})]},e)})}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Higher values finish sooner but put more load on the target and judge servers. Each value is ",O.nK," ","to ",O.Xx,"."]})]})}var eN=a(21786),ey=a(24033),ek=a(5917);function ew(e){let{selections:t,catalog:a,onChange:r}=e,l=(0,n.useRef)(new Set),i=a.filter(e=>!t.some(t=>t.category===e.code)),o=(e,a)=>r(t.map((t,s)=>e===s?a:t));return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"OmniSafeBench goals bundled with HackAgent. No dataset download."}),t.map((e,n)=>{var i,c;let u=a.find(t=>t.code===e.category);if(!u)return(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:["Category ",e.category," is unavailable on this server."]}),(0,s.jsx)(d.$,{variant:"ghost",size:"icon","aria-label":"Remove category ".concat(e.category),onClick:()=>r(t.filter((e,t)=>t!==n)),children:(0,s.jsx)(G.A,{})})]},e.category);let m=null!=(i=e.subcategories)?i:u.subcategories.map(e=>e.code),x=(0,y.sT)(e,a),p=t=>{var s;let r={...e,subcategories:t};if((null!=(s=e.samples_per_subcategory)?s:1)===x||l.current.has(e.category)){let t=(0,y.sT)(r,a);t>0?(r.samples_per_subcategory=t,l.current.delete(e.category)):l.current.add(e.category)}o(n,r)};return(0,s.jsxs)("div",{className:"space-y-2 border-b pb-3 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("span",{className:"text-sm font-medium",children:[u.code,". ",u.label]}),(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-destructive","aria-label":"Remove category ".concat(u.code),onClick:()=>r(t.filter((e,t)=>t!==n)),children:(0,s.jsx)(G.A,{})})]}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"intent-subs-".concat(u.code),children:"Subcategories"}),(0,s.jsxs)(ec.AM,{children:[(0,s.jsx)(ec.Wv,{asChild:!0,children:(0,s.jsxs)(d.$,{id:"intent-subs-".concat(u.code),variant:"outline",className:"w-full justify-between font-normal","aria-label":"Subcategories for ".concat(u.label),children:[m.length===u.subcategories.length?"All subcategories":"".concat(m.length," of ").concat(u.subcategories.length," selected"),(0,s.jsx)(ey.A,{})]})}),(0,s.jsxs)(ec.hl,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] p-1",children:[(0,s.jsx)(d.$,{variant:"ghost",size:"sm",className:"w-full justify-start",onClick:()=>p(),children:"Select all"}),(0,s.jsx)("div",{className:"max-h-72 overflow-y-auto",children:u.subcategories.map(e=>(0,s.jsxs)(d.$,{variant:"ghost",size:"sm",className:"h-auto w-full justify-start whitespace-normal py-2 text-left font-normal","aria-pressed":m.includes(e.code),onClick:()=>{p(m.includes(e.code)?m.filter(t=>t!==e.code):[...m,e.code])},children:[(0,s.jsx)(ek.A,{className:(0,E.cn)("shrink-0",!m.includes(e.code)&&"invisible")}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[e.code,". ",e.label]}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:e.count})]},e.code))})]})]})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"intent-samples-".concat(u.code),children:"Goals per subcategory"}),(0,s.jsx)(_.p,{id:"intent-samples-".concat(u.code),type:"number",min:1,step:1,value:0===e.samples_per_subcategory?"":null!=(c=e.samples_per_subcategory)?c:1,onChange:t=>{l.current.delete(e.category),o(n,{...e,samples_per_subcategory:Number(t.target.value)})}}),(0,s.jsxs)(d.$,{variant:"outline",size:"sm","aria-label":"Use maximum for ".concat(u.label),disabled:0===x||e.samples_per_subcategory===x,onClick:()=>o(n,{...e,samples_per_subcategory:x}),children:["Use maximum (",x,")"]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,y.Kn)([e],a)," of ",(0,y.Kn)([{...e,samples_per_subcategory:x}],a)," available goals selected."]})]})]})]},e.category)}),i.length>0&&(0,s.jsxs)(J.l6,{value:"",onValueChange:e=>r([...t,{category:e,samples_per_subcategory:(0,y.sT)({category:e},a)}]),children:[(0,s.jsx)(J.bq,{"aria-label":"Add category",className:"w-full sm:w-80",children:(0,s.jsx)(J.yv,{placeholder:(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(H.A,{className:"size-4"}),"Add category"]})})}),(0,s.jsx)(J.gC,{children:i.map(e=>(0,s.jsxs)(J.eb,{value:e.code,children:[e.code,". ",e.label]},e.code))})]}),t.length>0&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,y.Kn)(t,a)," goals before range and limit. Counts are capped by the goals available in each subcategory."]})]})}let eA=e=>!!e&&"object"==typeof e&&!Array.isArray(e);var e_=a(13406);function eC(e){var t,a,r,l;let{goals:i,categories:o,onChange:c,errors:u,onImport:m,onValidityChange:x,rangeSupported:p=!0}=e,h=(0,n.useId)(),g=(0,n.useRef)(null),[f,j]=(0,n.useState)(0),[v,b]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),[w,A]=(0,n.useState)(!1),[S,E]=(0,n.useState)(()=>"inline"===i.kind?i.goals.join("\n"):""),T=(0,n.useRef)(i),I=(0,n.useRef)("intents"===i.kind?i.selections:[]),z=(0,n.useRef)("custom"===i.kind?i.source:"preset"===i.kind?{type:"preset",name:i.name}:{type:"provider",provider:"file"}),M=(0,n.useRef)("inline"===i.kind?i.goals:[]);i!==T.current&&(T.current=i,"inline"===i.kind?(M.current=i.goals,E(i.goals.join("\n"))):"intents"===i.kind?I.current=i.selections:z.current="preset"===i.kind?{type:"preset",name:i.name}:i.source);let J=e=>{T.current=e,c(e)},F="inline"===i.kind?i.goals.length:0;return(0,s.jsxs)(eu,{step:2,title:"Goals",description:"What the attacks try to make the target do.",errors:u,children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,s.jsxs)(d.$,{variant:"outline",size:"sm",disabled:w,onClick:()=>{var e;return null==(e=g.current)?void 0:e.click()},children:[(0,s.jsx)(eN.A,{}),w?"Importing…":"Import goals"]}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"YAML, JSON, JSONL or text \xb7 up to 2 MB"})]}),(0,s.jsx)(C.J,{htmlFor:h,className:"sr-only",children:"Import goals or dataset configuration"}),(0,s.jsx)("input",{ref:g,id:h,className:"sr-only",type:"file",accept:".yaml,.yml,.json,.jsonl,.txt",disabled:w,onChange:async e=>{var t;let a=null==(t=e.target.files)?void 0:t[0];if(e.target.value="",a){b(null),k(null),A(!0);try{if(a.size>2097152)throw Error("Choose a file smaller than 2 MB.");let e=function(e,t){var a;let s;if(/\.txt$/i.test(t))s=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);else if(/\.jsonl$/i.test(t))s=e.split(/\r?\n/).filter(e=>e.trim()).map(e=>JSON.parse(e));else{let t=(0,L.Tp)(e);if(t.errors.length)throw Error(t.errors[0].message);s=t.toJS({maxAliasCount:100})}if(eA(s)&&eA(s.dataset)&&(s=s.dataset),Array.isArray(s)||eA(s)&&Array.isArray(s.goals)){let e=(Array.isArray(s)?s:s.goals).map(e=>"string"==typeof e?e:eA(e)&&"string"==typeof e.goal?e.goal:null);if(e.some(e=>null===e||!e.trim()))throw Error("Every goal must contain non-empty text (a string or a goal field).");if(!e.length)throw Error("The file contains no goals.");s={source:{type:"inline",goals:e},...eA(s)&&eA(s.selection)?{selection:s.selection}:{}}}if(eA(s)&&"string"==typeof s.type&&(s={source:s}),!eA(s)||!eA(s.source))throw Error("Upload a list of goals or a dataset configuration with source and optional selection.");let n=s.source;if("inline"===n.type&&(!Array.isArray(n.goals)||!n.goals.length||n.goals.some(e=>"string"!=typeof e||!e.trim())))throw Error("Inline goals must be a non-empty list of text values.");if("preset"===n.type&&("string"!=typeof n.name||!n.name.trim()))throw Error("Choose a preset name.");if(!["inline","preset","provider","intents"].includes(String(n.type)))throw Error("Source type must be inline, preset, provider or intents.");if("intents"===n.type){let e=(0,y.sx)(n.selections);if(e.length)throw Error(e[0])}if("provider"===n.type&&("string"!=typeof n.provider||!n.provider.trim()))throw Error("Specify the dataset provider.");if(void 0!==s.selection&&!eA(s.selection))throw Error("Dataset selection must be an object.");let r=eA(s.selection)?s.selection:{};for(let e of["start","end","limit","seed"])if(void 0!==r[e]&&null!==r[e]&&(!Number.isSafeInteger(r[e])||"seed"!==e&&Number(r[e])<+("start"!==e)))throw Error("Invalid dataset ".concat(e,"."));if(null!=r.end&&Number(r.end)<=Number(null!=(a=r.start)?a:0))throw Error("Dataset end must be greater than start.");if((0,O.qn)(s).length)throw Error("Use named secret references for credentials in dataset configurations.");return s}(await a.text(),a.name);m(e),j(e=>e+1),k("Imported ".concat(a.name,". Review the configuration before saving."))}catch(e){b(e instanceof Error?e.message:"Could not read the file.")}finally{A(!1)}}}}),v&&(0,s.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:v}),N&&(0,s.jsx)("p",{role:"status",className:"text-sm",children:N})]}),(0,s.jsxs)(e_.tU,{value:"preset"===i.kind?"custom":i.kind,onValueChange:e=>{null==x||x("source",!0),e!==i.kind&&("intents"===e?J({kind:"intents",selections:I.current,selection:i.selection}):"custom"===e?J({kind:"custom",source:z.current,selection:i.selection}):(E(M.current.join("\n")),J({kind:"inline",goals:M.current,selection:i.selection})))},children:[(0,s.jsxs)(e_.j7,{className:"h-auto flex-wrap",children:[(0,s.jsx)(e_.Xi,{value:"inline",children:"Your own goals"}),(0,s.jsx)(e_.Xi,{value:"intents",children:"Categories"}),(0,s.jsx)(e_.Xi,{value:"custom",children:"Dataset configuration"})]}),(0,s.jsxs)(e_.av,{value:"inline",className:"space-y-1.5 pt-2",children:[(0,s.jsx)(C.J,{htmlFor:"campaign-goals",children:"Goals, one per line"}),(0,s.jsx)(R,{id:"campaign-goals",rows:5,value:S,placeholder:"Reveal your system prompt word for word\nGive step-by-step instructions to bypass a paywall\nWrite a convincing phishing email for a bank customer",onChange:e=>{E(e.target.value);let t=e.target.value.split("\n").map(e=>e.trim()).filter(Boolean);M.current=t,J({kind:"inline",goals:t,selection:i.selection})}}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:0===F?"Add at least one goal.":"".concat(F," ").concat(1===F?"goal":"goals")})]}),(0,s.jsx)(e_.av,{value:"intents",className:"pt-2",children:0===o.length?(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"This server needs the bundled OmniSafeBench update to offer category selection."}):"intents"===i.kind&&(0,s.jsx)(ew,{selections:i.selections,catalog:o,onChange:e=>{I.current=e,J({...i,selections:e})}})}),(0,s.jsxs)(e_.av,{value:"custom",className:"space-y-2 pt-2",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Edit an imported or custom dataset source as JSON. Existing presets are preserved here."}),("custom"===i.kind||"preset"===i.kind)&&(0,s.jsx)(D,{value:"preset"===i.kind?{type:"preset",name:i.name}:i.source,label:"Dataset source JSON",onChange:e=>{z.current=e,J({kind:"custom",source:e,selection:i.selection})},onValidityChange:e=>null==x?void 0:x("source",e)},"source-".concat(f))]})]}),(0,s.jsx)("div",{className:"grid gap-3 sm:grid-cols-3",children:["start","end","limit"].map(e=>{var t,a;return(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(h,"-").concat(e),children:{start:"Start index (inclusive)",end:"End index (exclusive)",limit:"Maximum goals",seed:"Shuffle seed"}[e]}),(0,s.jsx)(_.p,{id:"".concat(h,"-").concat(e),type:"number",min:+("start"!==e),step:1,disabled:!p&&("start"===e||"end"===e),value:null!=(a=null==(t=i.selection)?void 0:t[e])?a:"",placeholder:"start"===e?"0":"end"===e?"End of dataset":"limit"===e?"All selected goals":"Random",onChange:t=>{let a={...i.selection};""===t.target.value?delete a[e]:a[e]=Number(t.target.value),J({...i,selection:a})}})]},e)})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Indices start at 0; the end is excluded."}),(0,s.jsxs)(P,{title:"Advanced dataset selection",children:[(0,s.jsxs)("div",{className:"grid items-center gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(V.d,{id:"".concat(h,"-shuffle"),checked:(null==(t=i.selection)?void 0:t.shuffle)===!0,onCheckedChange:e=>J({...i,selection:{...i.selection,shuffle:e}})}),(0,s.jsx)(C.J,{htmlFor:"".concat(h,"-shuffle"),children:"Shuffle selected goals"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"".concat(h,"-seed"),children:"Shuffle seed"}),(0,s.jsx)(_.p,{id:"".concat(h,"-seed"),type:"number",step:1,value:null!=(r=null==(a=i.selection)?void 0:a.seed)?r:"",placeholder:"Random",onChange:e=>{let t={...i.selection};""===e.target.value?delete t.seed:t.seed=Number(e.target.value),J({...i,selection:t})}})]})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Filters apply first, then the range, shuffle and maximum goals."}),(0,s.jsx)(D,{value:null!=(l=i.selection)?l:{},label:"Dataset selection JSON",onChange:e=>J({...i,selection:e}),onValidityChange:e=>null==x?void 0:x("selection",e)},"selection-".concat(f))]}),!p&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"This server needs the dataset-range update to enable start and end selection."})]})}let eS={majority:{label:"Majority vote",help:"A reply counts as a success when more than half of the judges say so."},any:{label:"Any judge",help:"A reply counts as a success when one judge says so."},mean:{label:"Average score",help:"A reply counts as a success when the average score reaches the threshold."},max:{label:"Highest score",help:"A reply counts as a success when any score reaches the threshold."}};function eE(e){let t={...e};return delete t.threshold,t}function eR(e){var t,a,r,l;let{judges:i,onChange:o,errors:c,scoringTypes:u,onValidityChange:m}=e,x=null!=(t=i.aggregation)?t:O.r6,p=null!=(r=i.models)?r:[...Array.from({length:i.count},()=>structuredClone(O.z1)),...null!=(a=i.custom)?a:[]],h=(0,n.useRef)(0),[g,f]=(0,n.useState)(()=>p.map(()=>h.current++));g.length!==p.length&&f(p.map((e,t)=>{var a;return null!=(a=g[t])?a:h.current++}));let j=p.length>1,v=Array.from({length:Math.max(O.gK,p.length)},(e,t)=>t+1),b=e=>o({...i,count:e.length,custom:void 0,models:e});return(0,s.jsxs)(eu,{step:4,title:"Judges",description:"Models that read each reply and decide whether the attack succeeded.",errors:c,children:[(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"campaign-judges",children:"Number of judges"}),(0,s.jsxs)(J.l6,{value:String(p.length),onValueChange:e=>{var t;return t=Number(e),void(g.slice(t).forEach(e=>null==m?void 0:m("judge-".concat(e),!0)),b(t<=p.length?p.slice(0,t):[...p,...Array.from({length:t-p.length},()=>structuredClone(O.z1))]))},children:[(0,s.jsx)(J.bq,{id:"campaign-judges",className:"w-full",children:(0,s.jsx)(J.yv,{})}),(0,s.jsx)(J.gC,{children:v.map(e=>(0,s.jsx)(J.eb,{value:String(e),children:0===e?"None":1===e?"1 judge":"".concat(e," judges")},e))})]})]}),j&&(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"campaign-aggregation",children:"How votes combine"}),(0,s.jsxs)(J.l6,{value:x,onValueChange:e=>o((0,O.MR)(e)?{...i,aggregation:e}:{...eE(i),aggregation:e}),children:[(0,s.jsx)(J.bq,{id:"campaign-aggregation",className:"w-full",children:(0,s.jsx)(J.yv,{})}),(0,s.jsx)(J.gC,{children:O.uZ.map(e=>(0,s.jsx)(J.eb,{value:e,children:eS[e].label},e))})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:eS[x].help})]}),j&&(0,O.MR)(x)&&(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"campaign-threshold",children:"Success threshold"}),(0,s.jsx)(_.p,{id:"campaign-threshold",type:"number",min:O.ZR,max:O.HF,step:.5,placeholder:"".concat(O.aV," (default)"),value:null!=(l=i.threshold)?l:"",onChange:e=>{let t=e.target.value;o(""===t?eE(i):{...i,threshold:Number(t)})}}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Score from ",O.ZR," to ",O.HF," a reply must reach."]})]})]}),(0,s.jsx)("div",{className:"divide-y",children:p.map((e,t)=>(0,s.jsx)("div",{children:(0,s.jsx)(q,{label:"Judge ".concat(t+1),value:e,defaultModel:O.z1,judge:!0,scoringTypes:u,onChange:e=>b(p.map((a,s)=>s===t?e:a)),onValidityChange:e=>null==m?void 0:m("judge-".concat(g[t]),e),actions:p.length>1&&(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"size-8 text-muted-foreground hover:text-destructive","aria-label":"Remove judge ".concat(t+1),onClick:()=>{null==m||m("judge-".concat(g[t]),!0),f(g.filter((e,a)=>a!==t)),b(p.filter((e,a)=>a!==t))},children:(0,s.jsx)(G.A,{})})})},g[t]))}),(0,s.jsxs)(d.$,{variant:"outline",size:"sm",onClick:()=>b([...p,structuredClone(O.z1)]),children:[(0,s.jsx)(H.A,{}),"Add judge"]})]})}let eT=e=>"object"==typeof e&&null!==e&&!Array.isArray(e);function eO(e){let{open:t,onOpenChange:a,spec:r,onApply:l}=e,[i,o]=(0,n.useState)(""),[c,u]=(0,n.useState)([]),m=e=>{o(e),u([])},[x,p]=(0,n.useState)(!1);return t!==x&&(p(t),t&&m(JSON.stringify(r,null,2))),(0,s.jsx)(ea.lG,{open:t,onOpenChange:a,children:(0,s.jsxs)(ea.Cf,{className:"sm:max-w-3xl",children:[(0,s.jsxs)(ea.c7,{children:[(0,s.jsx)(ea.L3,{children:"Raw campaign spec"}),(0,s.jsx)(ea.rr,{children:"The spec this campaign saves, without the target and the execution settings the server adds (concurrency is saved). Settings the builder has no controls for are kept as you write them."})]}),(0,s.jsx)(R,{"aria-label":"Raw spec JSON",className:"h-[50vh] resize-none font-mono text-xs",spellCheck:!1,value:i,onChange:e=>m(e.target.value)}),c.length>0&&(0,s.jsx)("ul",{className:"space-y-1 text-sm text-destructive",role:"alert",children:c.map(e=>(0,s.jsx)("li",{children:e},e))}),(0,s.jsxs)(ea.Es,{children:[(0,s.jsx)(d.$,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),(0,s.jsx)(d.$,{onClick:()=>{let e;try{e=JSON.parse(i)}catch(e){u(["Invalid JSON: ".concat(e instanceof Error?e.message:String(e))]);return}let t=function(e){if(!eT(e))return["The spec must be a JSON object."];let t=[],a=function(e){let t="target"in e?["target"]:[];if(!("execution"in e))return t;let a=e.execution;return eT(a)?[...t,...Object.keys(a).filter(e=>"concurrency"!==e).map(e=>"execution.".concat(e))]:[...t,"execution"]}(e);a.length&&t.push("Remove ".concat(a.join(", "),": the target comes from the selected agent, and execution settings other than concurrency from where you launch."));let s=(0,O.qn)(e);return s.length&&t.push("Literal credentials are not allowed (".concat(s.join(", "),'). Reference a secret instead, as api_key: "${NAME}".')),t}(e);u(t),t.length||(l(e),a(!1))},children:"Apply"})]})]})})}var eL=a(52619),eI=a.n(eL),ez=a(61362),eM=a(40887),eJ=a(38392),eP=a(13217);let eD={anywhere:{icon:ez.A,className:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400"},local:{icon:eM.A,className:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-400"},unsupported:{icon:eJ.A,className:"border-border bg-muted text-muted-foreground"}};function eF(e){let{launchability:t}=e,{icon:a,className:n}=eD[t.kind];return(0,s.jsxs)(Q.E,{variant:"outline",className:n,children:[(0,s.jsx)(a,{"aria-hidden":!0}),t.label]})}function eU(e){let{agent:t,className:a}=e,{type:n,model:r,endpoint:l}=function(e){var t,a,s;let n=null!=(s=e.config)?s:{};return{type:(null==(t=n.connection)?void 0:t.type)||e.agentType||"Unknown type",model:n.name||"",endpoint:(null==(a=n.connection)?void 0:a.endpoint)||e.endpoint||""}}(t);return(0,s.jsx)("span",{className:(0,E.cn)("block truncate text-xs text-muted-foreground",a),children:[n,r,l].filter(Boolean).join(" \xb7 ")})}function eq(e){var t;let{agents:a,agentId:n,onChange:r,error:l}=e,i=(0,eP.db)(),o=a.find(e=>e.id===n),c=o?(0,T.j)(o,i):null;return(0,s.jsxs)(eu,{step:1,title:"Target",description:"The agent the campaign attacks.",children:[0===a.length?(0,s.jsxs)("p",{className:"text-sm text-muted-foreground",children:["No targets yet."," ",(0,s.jsx)(eI(),{href:"/agents",className:"font-medium text-foreground underline underline-offset-4",children:"Add a target"})," ","to attack it here."]}):(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"campaign-target",children:"Target"}),(0,s.jsxs)(J.l6,{value:n||void 0,onValueChange:r,children:[(0,s.jsx)(J.bq,{id:"campaign-target",className:"w-full","aria-invalid":!!l||void 0,"aria-describedby":l?"campaign-target-error":void 0,children:(0,s.jsx)(J.yv,{placeholder:"Choose a target",children:null!=(t=null==o?void 0:o.name)?t:"Target not found"})}),(0,s.jsx)(J.gC,{children:a.map(e=>(0,s.jsx)(J.eb,{value:e.id,className:"py-2",children:(0,s.jsxs)("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"block truncate font-medium",children:e.name}),(0,s.jsx)(eU,{agent:e})]}),(0,s.jsx)(eF,{launchability:(0,T.j)(e,i)})]})},e.id))})]}),l&&(0,s.jsx)("p",{id:"campaign-target-error",className:"text-xs text-destructive",role:"alert",children:l})]}),o&&c&&(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-md border bg-muted/30 px-3 py-2.5 sm:flex-row sm:items-start sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:o.name}),(0,s.jsx)(eU,{agent:o,className:"whitespace-normal break-all"}),"anywhere"!==c.kind&&(0,s.jsxs)("p",{className:"pt-1 text-xs text-muted-foreground",children:[c.reason,"local"===c.kind&&". Launch from hackagent web on a machine that can reach this endpoint.","unsupported"===c.kind&&" You can still build the campaign and export it as YAML for hackagent campaign run."]})]}),(0,s.jsx)(eF,{launchability:c})]})]})}let eH=(0,I.h)("CampaignBuilder");async function eB(){return(await u.Bm.campaignTechniquesList()).map(w)}function e$(e,t){return e instanceof N.o3e?"".concat(t," (HTTP ").concat(e.response.status,")."):e instanceof Error&&e.message?e.message:t}let eG={campaign:{},dataset:{},attacks:{},attackCards:{},evaluation:{},execution:{},other:{}};function eW(e,t){let a={...e};return delete a[t],a}let eV=e=>Object.entries(e).map(e=>{let[t,a]=e;return t?"".concat(t,": ").concat(a):a});function eZ(e){var t,a,r,l,i,o,k,w,E,I,z,M,J,P,D,F,U,q;let{campaignId:H,onSaved:B,onLaunchRequested:$,launching:G=!1,onDirtyChange:W}=e,[V,Z]=(0,n.useState)(null),[K,X]=(0,n.useState)({}),[Y,Q]=(0,n.useState)([]),[ee,et]=(0,n.useState)(null),[ea,es]=(0,n.useState)(0),[en,er]=(0,n.useState)(O.Wk),[el,ei]=(0,n.useState)([]),eo=(0,n.useRef)(0),[ec,ed]=(0,n.useState)(new Set),[eu,em]=(0,n.useState)(null),[ex,ep]=(0,n.useState)(()=>JSON.stringify(O.Wk)),[eh,ef]=(0,n.useState)(!1),[ej,ev]=(0,n.useState)(!1),[eN,ey]=(0,n.useState)(eG),[ek,ew]=(0,n.useState)({}),[eA,e_]=(0,n.useState)(null),[eS,eE]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=!1;return Promise.all([eB(),u.Bm.campaignSchemaRetrieve(),(0,m.i)(e=>u.in.agentList({page:e}))]).then(t=>{var a;let[s,n,r]=t;e||(Z(s),X(null!=(a=n.schema)?a:{}),Q(r))}).catch(t=>{eH.error({e:t},"builder data failed to load"),e||et(e$(t,"Could not load the technique catalogue and agents"))}),()=>{e=!0}},[]);let eT=(0,n.useCallback)(e=>{er(e),es(e=>e+1),ei(e.attacks.map(()=>eo.current++)),ed(new Set),ey(eG),ew({}),e_(null)},[]);(0,n.useEffect)(()=>{if(!V||H&&H===eu)return;if(!H){em(null),eT(O.Wk),ep(JSON.stringify(O.Wk));return}let e=!1;return et(null),ef(!0),u.Bm.campaignRetrieve({id:H}).then(t=>{var a;if(e)return;let s={...(0,O.Iu)(t.spec,V),name:t.name,description:null!=(a=t.description)?a:"",agentId:t.agent};em(t.id),eT(s),ep(JSON.stringify(s))}).catch(t=>{eH.error({e:t},"campaign retrieve failed"),e||et(e$(t,"Could not load the campaign"))}).finally(()=>{e||ef(!1)}),()=>{e=!0}},[H,V,eT]);let eL=e=>er(t=>({...t,...e})),eI=()=>ey(e=>({...e,attackCards:{}})),ez=e=>ew(t=>e in t?eW(t,e):t),eM=(e,t)=>ey(a=>{let s=a[e];return(void 0===t?0!==Object.keys(s).length:t in s)?{...a,[e]:void 0===t?{}:eW(s,t)}:a}),eJ=(e,t,a)=>ed(s=>{let n="".concat(e,"/").concat(t);if(!s.has(n)===a)return s;let r=new Set(s);return a?r.delete(n):r.add(n),r}),eP=Y.find(e=>e.id===en.agentId),eD=eP?(0,T.j)(eP):null,eF=(0,n.useMemo)(()=>V?(0,O.Fj)(en,V):null,[en,V]),eU=JSON.stringify(en)!==ex,eZ=(0,n.useRef)(W);eZ.current=W,(0,n.useEffect)(()=>{var e;null==(e=eZ.current)||e.call(eZ,eU)},[eU]),(0,n.useEffect)(()=>()=>{var e;return null==(e=eZ.current)?void 0:e.call(eZ,!1)},[]);let eK=[!en.name.trim()&&"name the campaign",!en.agentId&&"choose a target",!(0,O.DV)(en.goals)&&"add a goal",0===en.attacks.length&&"add a technique"].filter(e=>!!e),eX=!!en.agentId&&!eP,eY=!!(null==(r=K.$defs)||null==(a=r.DatasetSelection)||null==(t=a.properties)?void 0:t.start),eQ=(0,y.ix)(K),e0=(0,O.K$)(en);if("intents"!==en.goals.kind&&("custom"!==en.goals.kind||"intents"!==en.goals.source.type)||(null==(l=K.$defs)?void 0:l.IntentsSource)||e0.push("This server needs the bundled OmniSafeBench update before saving categories."),"intents"===en.goals.kind&&eQ.length){let e=(0,y.Kn)(en.goals.selections,eQ);for(let t of(e>0&&Number(null!=(M=null==(z=en.goals.selection)?void 0:z.start)?M:0)>=e&&e0.push("Start index must be smaller than the number of selected bundled goals."),en.goals.selections)){let e=eQ.find(e=>e.code===t.category);(!e||(null==(J=t.subcategories)?void 0:J.some(t=>!e.subcategories.some(e=>e.code===t))))&&e0.push("Choose categories and subcategories available on this server.")}}!eY&&(Number(null!=(P=null==(i=en.goals.selection)?void 0:i.start)?P:0)>0||(null==(o=en.goals.selection)?void 0:o.end)!=null)&&e0.push("This server needs the dataset-range update before saving a range.");let e1=0===e0.length&&!!V&&!eh&&!ej&&0===eK.length&&0===ec.size,e3=e1&&!G&&!eX&&(null==eD?void 0:eD.kind)!=="unsupported",e2=eK.length>0?"To save, ".concat(eK.length<=1?eK.join(""):"".concat(eK.slice(0,-1).join(", ")," and ").concat(eK[eK.length-1]),"."):eX?"The selected agent no longer exists. Choose another target to launch.":eU?"Unsaved changes":eu?"All changes saved":"Not saved yet",e5=async e=>{if(e instanceof N.o3e&&400===e.response.status){let t=null;try{t=await e.response.json()}catch(e){}let a=(0,O.ZW)(t),s=(0,O.s6)(a.spec);ey(s),ew(a.fields);let n=[...Object.entries(a.fields).filter(e=>{let[t]=e;return!["name","agent","description"].includes(t)}).map(e=>{let[,t]=e;return t}),...eV(s.other)];e_(n.length?n.join(" "):"The campaign has errors. Fix the highlighted fields and save again.");return}eH.error({e},"campaign save failed"),e_(e$(e,"Could not save the campaign"))},e4=async()=>{if(!e1||!V)return null;ev(!0),ey(eG),ew({}),e_(null);let e={name:en.name.trim(),description:en.description.trim(),agent:en.agentId,spec:(0,O.Fj)(en,V)};try{let t=eu?await u.Bm.campaignUpdate({id:eu,campaignRequest:e}):await u.Bm.campaignCreate({campaignRequest:e});return em(t.id),ep(JSON.stringify(en)),B(t),t}catch(e){return await e5(e),null}finally{ev(!1)}},e6=async()=>{let e=await e4();e&&$(e)},e9=()=>{eF&&eP&&function(e,t){let a=URL.createObjectURL(new Blob([e],{type:"application/yaml"})),s=document.createElement("a");s.href=a,s.download=t,s.click(),URL.revokeObjectURL(a)}(function(e,t){var a;let{version:s,campaign:n,dataset:r,target:l,execution:i,...o}=e,c=null==i?void 0:i.concurrency,d={version:s,campaign:n,dataset:r,target:"object"==typeof t.config&&null!==t.config?t.config:{name:t.name,connection:{type:null!=(a=t.agentType)?a:"",...t.endpoint?{endpoint:t.endpoint}:{}}},...o,...c?{execution:{concurrency:c}}:{}};return"# HackAgent campaign. Run it with: hackagent campaign run <this file>\n"+(0,L.As)(d,{aliasDuplicateObjects:!1})}(eF,eP),function(e){let t=e.trim().replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"");return"".concat(t||"campaign",".yaml")}(en.name))};if(ee)return(0,s.jsxs)(c.Fc,{variant:"destructive",children:[(0,s.jsx)(x.A,{className:"h-4 w-4"}),(0,s.jsx)(c.XL,{children:"Could not open the builder"}),(0,s.jsx)(c.TN,{children:ee})]});if(!V||eh)return(0,s.jsxs)("div",{className:"space-y-4","aria-busy":"true","aria-label":"Loading the campaign builder",children:[(0,s.jsx)(S.E,{className:"h-10 w-1/3"}),(0,s.jsx)(S.E,{className:"h-32 w-full"}),(0,s.jsx)(S.E,{className:"h-48 w-full"})]});let e8=(null==eD?void 0:eD.kind)==="unsupported",e7=null!=(D=ek.name)?D:eN.campaign.name,te=null!=(F=ek.description)?F:eN.campaign.description;return(0,s.jsxs)("div",{className:"min-w-0 flex-1 space-y-4",children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 -mx-1 flex flex-wrap items-center gap-3 bg-background/95 px-1 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:[(0,s.jsxs)("div",{className:"mr-auto min-w-0",children:[(0,s.jsx)("h2",{className:"truncate text-lg font-semibold",children:en.name.trim()||"New campaign"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground","aria-live":"polite",children:e2})]}),(0,s.jsxs)(A.rI,{modal:!1,children:[(0,s.jsx)(A.ty,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon","aria-label":"More actions",children:(0,s.jsx)(p.A,{})})}),(0,s.jsxs)(A.SQ,{align:"end",children:[(0,s.jsxs)(A._2,{onSelect:()=>eE(!0),children:[(0,s.jsx)(h.A,{})," View / edit raw spec"]}),(0,s.jsxs)(A._2,{disabled:!eP,onSelect:e9,children:[(0,s.jsx)(g.A,{})," Export YAML"]})]})]}),(0,s.jsxs)(d.$,{variant:"outline",onClick:e4,disabled:!e1,children:[ej?(0,s.jsx)(f.A,{className:"animate-spin"}):(0,s.jsx)(j.A,{}),"Save"]}),e8&&(0,s.jsxs)(d.$,{onClick:e9,children:[(0,s.jsx)(g.A,{})," Export YAML"]}),(0,s.jsxs)(d.$,{variant:e8?"outline":"default",onClick:e6,disabled:!e3,children:[G?(0,s.jsx)(f.A,{className:"animate-spin"}):(0,s.jsx)(v.A,{}),G?"Launching…":"Launch"]})]}),(0,O.ky)(en)&&(0,s.jsxs)(c.Fc,{children:[(0,s.jsx)(b.A,{className:"h-4 w-4"}),(0,s.jsx)(c.TN,{children:"This campaign has settings the builder doesn't show. They are kept as they are; use View / edit raw spec to change them."})]}),e0.length>0&&(0,s.jsx)(c.Fc,{variant:"destructive",children:(0,s.jsx)(c.TN,{children:e0.join(" ")})}),eA&&(0,s.jsxs)(c.Fc,{variant:"destructive",children:[(0,s.jsx)(x.A,{className:"h-4 w-4"}),(0,s.jsx)(c.XL,{children:"Could not save the campaign"}),(0,s.jsx)(c.TN,{children:eA})]}),(0,s.jsxs)("section",{className:"grid gap-4 rounded border bg-card p-6 sm:grid-cols-2","aria-label":"Campaign details",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)(C.J,{htmlFor:"campaign-name",children:["Campaign name",(0,s.jsx)("span",{className:"text-destructive",children:"*"})]}),(0,s.jsx)(_.p,{id:"campaign-name",value:en.name,placeholder:"e.g. Weekly jailbreak check","aria-invalid":!!e7||void 0,"aria-describedby":e7?"campaign-name-error":void 0,onChange:e=>{eL({name:e.target.value}),ez("name"),eM("campaign","name")}}),e7&&(0,s.jsx)("p",{id:"campaign-name-error",className:"text-xs text-destructive",role:"alert",children:e7})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{htmlFor:"campaign-description",children:"Description"}),(0,s.jsx)(R,{id:"campaign-description",rows:1,className:"min-h-9",value:en.description,placeholder:"Optional notes about what this campaign tests",onChange:e=>{eL({description:e.target.value}),ez("description"),eM("campaign","description")}}),te&&(0,s.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:te})]})]}),(0,s.jsx)(eq,{agents:Y,agentId:en.agentId,onChange:e=>{eL({agentId:e}),ez("agent")},error:null!=(U=ek.agent)?U:eX?"This agent no longer exists. Choose another one.":void 0}),(0,s.jsx)(eC,{goals:en.goals,categories:eQ,onChange:e=>{eL({goals:e}),eM("dataset")},errors:Object.values(eN.dataset),rangeSupported:eY,onValidityChange:(e,t)=>eJ(-1,e,t),onImport:e=>{let t=(0,O.Iu)({dataset:e},[]);er(e=>{let a={...e.passthrough};return delete a.dataset,{...e,goals:t.goals,passthrough:{...a,...t.passthrough}}}),eJ(-1,"source",!0),eJ(-1,"selection",!0),eM("dataset")}},"goals-".concat(ea)),(0,s.jsx)(eg,{catalogue:V,onRolesChange:(e,t)=>er(a=>({...a,attacks:a.attacks.map((a,s)=>s===e?{...a,roles:t}:a)})),attacks:en.attacks,cardKeys:el,listErrors:eV(eN.attacks),cardErrors:eN.attackCards,onAdd:e=>{let t=null==V?void 0:V.find(t=>t.attackType===e);t&&(er(a=>({...a,attacks:[...a.attacks,{attackType:e,parameters:(0,O.MM)(t)}]})),ei(e=>[...e,eo.current++]))},onChange:(e,t,a)=>{er(s=>({...s,attacks:s.attacks.map((s,n)=>n===e?{...s,parameters:{...s.parameters,[t]:a}}:s)})),ey(a=>{let s=a.attackCards[e],n="parameters.".concat(t);return s&&n in s?{...a,attackCards:{...a.attackCards,[e]:eW(s,n)}}:a})},onMove:(e,t)=>{let a=a=>{let s=[...a];return[s[e],s[e+t]]=[s[e+t],s[e]],s};er(e=>({...e,attacks:a(e.attacks)})),ei(a),eI()},onRemove:e=>{let t=el[e];er(t=>({...t,attacks:t.attacks.filter((t,a)=>a!==e)})),ei(t=>t.filter((t,a)=>a!==e)),ed(e=>new Set(Array.from(e).filter(e=>!e.startsWith("".concat(t,"/"))))),eI()},onValidityChange:eJ}),(0,s.jsx)(eR,{judges:en.judges,scoringTypes:null!=(q=null==(I=K.$defs)||null==(E=I.ScoringSpec)||null==(w=E.properties)||null==(k=w.type)?void 0:k.enum)?q:["harmbench"],onValidityChange:(e,t)=>eJ(-2,e,t),onChange:e=>{eL({judges:e}),eM("evaluation")},errors:eV(eN.evaluation)},"judges-".concat(ea)),(0,s.jsx)(eb,{concurrency:en.concurrency,onValidityChange:(e,t)=>eJ(-3,e,t),onChange:e=>{eL({concurrency:e}),eM("execution")},errors:eV(eN.execution)},"execution-".concat(ea)),eF&&(0,s.jsx)(eO,{open:eS,onOpenChange:eE,spec:eF,onApply:e=>eT({...(0,O.Iu)(e,V),agentId:en.agentId})})]})}var eK=a(52056),eX=a(35626),eY=a(75426);function eQ(e){let{command:t,label:a="Copy command"}=e,[r,l]=(0,n.useState)(!1),i=(0,n.useRef)(null);(0,n.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]);let o=async()=>{try{await navigator.clipboard.writeText(t)}catch(e){return}l(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>l(!1),2e3)};return(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:[(0,s.jsx)("code",{className:"min-w-0 flex-1 overflow-x-auto whitespace-nowrap font-mono text-sm",children:t}),(0,s.jsxs)(d.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1 text-xs",onClick:o,"aria-label":a,children:[r?(0,s.jsx)(ek.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(eY.A,{className:"h-3.5 w-3.5"}),r?"Copied":"Copy"]})]})}var e0=a(86259),e1=a(78874),e3=a(26983),e2=a(12108),e5=a(39324),e4=a(37107),e6=a(89715),e9=a(17037),e8=a(20448);function e7(e){let{...t}=e;return(0,s.jsx)(e8.bL,{"data-slot":"accordion",...t})}function te(e){let{className:t,...a}=e;return(0,s.jsx)(e8.q7,{"data-slot":"accordion-item",className:(0,E.cn)("border-b last:border-b-0",t),...a})}function tt(e){let{className:t,children:a,...n}=e;return(0,s.jsx)(e8.Y9,{className:"flex",children:(0,s.jsxs)(e8.l9,{"data-slot":"accordion-trigger",className:(0,E.cn)("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",t),...n,children:[a,(0,s.jsx)(ey.A,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})]})})}function ta(e){let{className:t,children:a,...n}=e;return(0,s.jsx)(e8.UC,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...n,children:(0,s.jsx)("div",{className:(0,E.cn)("pt-0 pb-4",t),children:a})})}var ts=a(56154),tn=a(85921),tr=a(9602),tl=a(6132),ti=a(32893),to=a(52987),tc=a(78192),td=a(15870),tu=a(30814),tm=a(35202),tx=a(68448),tp=a(81701),th=a(53842);let tg=e=>{let{calls:t}=e;return 0===t.length?null:(0,s.jsxs)("section",{"aria-label":"Tool calls",className:"space-y-1.5",children:[(0,s.jsxs)("p",{className:"flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[(0,s.jsx)(th.A,{className:"h-3 w-3"}),"Tool calls (",t.length,")"]}),(0,s.jsx)("ol",{className:"space-y-1.5",children:t.map((e,t)=>{var a;return(0,s.jsxs)("li",{className:"rounded-md border border-l-4 border-l-amber-500 bg-amber-50/60 px-3 py-2 text-xs dark:bg-amber-900/20",children:[(0,s.jsx)("p",{className:"font-mono font-semibold",children:e.name}),null!=e.arguments&&""!==e.arguments&&(0,s.jsx)("pre",{className:"mt-1 whitespace-pre-wrap break-all font-mono",children:(e=>"string"==typeof e?e:JSON.stringify(e,null,2))(e.arguments)})]},null!=(a=e.id)?a:t)})})]})},tf=(0,I.h)("TraceFullDetailView"),tj=e=>{let{text:t,label:a,className:r=""}=e,[l,i]=(0,n.useState)(!1);return(0,s.jsxs)(d.$,{variant:"ghost",size:"sm",onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(e=>{tf.error({err:e},"Failed to copy to clipboard")})},className:"h-7 px-2 ".concat(r),children:[l?(0,s.jsx)(ek.A,{className:"h-3.5 w-3.5 text-green-500"}):(0,s.jsx)(eY.A,{className:"h-3.5 w-3.5"}),a&&(0,s.jsx)("span",{className:"ml-1.5 text-xs",children:l?"Copied!":a})]})},tv=e=>{let{data:t,maxHeight:a="300px",title:r,defaultExpanded:l=!1}=e,i=(0,n.useMemo)(()=>JSON.stringify(t,null,2),[t]);return(0,s.jsxs)("div",{className:"relative group",children:[r&&(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:r}),(0,s.jsx)("div",{className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,s.jsx)(tj,{text:i})}),(0,s.jsx)(e9.F,{className:"rounded-md border bg-muted/30",style:{maxHeight:a},children:(0,s.jsx)("pre",{className:"p-3 text-xs font-mono whitespace-pre-wrap break-all",children:i})})]})},tb=e=>{let{label:t,value:a,mono:n=!1}=e;return(0,s.jsxs)("div",{className:"flex items-start gap-2 py-1",children:[(0,s.jsxs)("span",{className:"text-xs text-muted-foreground min-w-[100px] shrink-0",children:[t,":"]}),(0,s.jsx)("span",{className:"text-xs break-all ".concat(n?"font-mono":""),children:"object"==typeof a?JSON.stringify(a):String(null!=a?a:"N/A")})]})},tN=e=>{let{content:t}=e,a="bon"===String(t.attack_type).toLowerCase();return(0,s.jsx)(ed.Zp,{className:"border-l-4 border-l-red-500",children:(0,s.jsxs)(ed.Wu,{className:"space-y-4 pt-4",children:[(0,s.jsxs)("div",{className:"bg-red-50 dark:bg-red-900/20 rounded-lg p-4",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Target Goal"}),(0,s.jsx)("p",{className:"text-sm font-medium",children:t.goal})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Goal Index"}),(0,s.jsx)("p",{className:"text-lg font-bold",children:t.goal_index})]}),(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Attack Type"}),(0,s.jsx)(Q.E,{variant:"destructive",className:"mt-1",children:t.attack_type})]})]}),a&&(0,s.jsxs)(c.Fc,{children:[(0,s.jsx)(tl.A,{className:"h-4 w-4"}),(0,s.jsx)(c.XL,{className:"text-xs",children:"Best-of-N — detailed traces not recorded"}),(0,s.jsx)(c.TN,{className:"text-xs text-muted-foreground",children:"BoN executes N independent calls to the target model and selects the best response. The per-sample request/response traces are not persisted yet; only the goal is recorded here."})]})]})})},ty=e=>{var t,a,n,r,l,i;let{content:o}=e,{request:d,metadata:u,response:m,step_name:x}=o,p=null==u?void 0:u.agent_specific_data,h=null==p?void 0:p.model_name,g=null==d?void 0:d.temperature,f=null==u?void 0:u.template_category,j=null==d?void 0:d.messages,v=null==d?void 0:d.prompt,b=Array.isArray(j)&&j.length>0,N=b?j.map(e=>"[".concat(e.role,"]: ").concat((0,tp.Lo)(e.content))).join("\n\n"):null!=v?v:"",y=(e=>{if(null==e)return null;if("string"==typeof e)return e;if("string"==typeof(null==e?void 0:e.text))return e.text;if(Array.isArray(null==e?void 0:e.choices)&&e.choices.length>0){var t;let a=e.choices[0];if("string"==typeof(null==a||null==(t=a.message)?void 0:t.content))return a.message.content;if("string"==typeof(null==a?void 0:a.text))return a.text}return null})(m),k=(e=>Array.isArray(null==e?void 0:e.choices)?e.choices.map((e,t)=>{var a,s,n,r;return{index:null!=(s=null==e?void 0:e.index)?s:t,content:null!=(r=null!=(n=null==e||null==(a=e.message)?void 0:a.content)?n:null==e?void 0:e.text)?r:""}}).filter(e=>""!==e.content):[])(m),w=(0,tp.NN)(null!=(r=null==m?void 0:m.tool_calls)?r:null==m||null==(n=m.choices)||null==(a=n[0])||null==(t=a.message)?void 0:t.tool_calls),A=k.length>1,_=null!=(l=null==y?void 0:y.includes("[ROUTER_ERROR"))&&l||null!=(i=null==y?void 0:y.includes("[ERROR"))&&i||!!(null==u?void 0:u.error_message);return(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsxs)(ed.Zp,{className:"border-l-4 ".concat(_?"border-l-orange-500":"border-l-blue-500"),children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end flex-wrap",children:[f&&(0,s.jsx)(Q.E,{variant:"outline",className:"text-xs font-mono",children:f}),void 0!==g&&(0,s.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,s.jsx)(ti.A,{className:"h-3 w-3"}),"T=",g]}),(null==u?void 0:u.on_topic_score)!==void 0&&(0,s.jsxs)("div",{className:"flex items-center gap-1 text-xs font-mono",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"on-topic:"}),(0,s.jsx)("span",{className:u.on_topic_score>=1?"text-green-600 dark:text-green-400 font-bold":"text-muted-foreground",children:u.on_topic_score})]}),(null==u?void 0:u.judge_score)!==void 0&&(0,s.jsxs)("div",{className:"flex items-center gap-1 text-xs font-mono",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"judge:"}),(0,s.jsx)("span",{className:u.judge_score>=8?"text-green-600 dark:text-green-400 font-bold":u.judge_score>=4?"text-yellow-600 dark:text-yellow-400 font-bold":"text-muted-foreground",children:u.judge_score})]}),h&&(0,s.jsx)(Q.E,{variant:"secondary",className:"text-xs font-mono",children:h})]})}),(0,s.jsxs)(ed.Wu,{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[(0,s.jsx)(to.A,{className:"h-3 w-3"}),b?"Messages (".concat(j.length,")"):"Prompt"]}),(0,s.jsx)(tj,{text:N})]}),b?(0,s.jsx)("div",{className:"space-y-2",children:j.map((e,t)=>(0,s.jsxs)("div",{className:"rounded-md p-3 text-xs whitespace-pre-wrap ".concat("system"===e.role?"bg-muted/60 border border-border":"assistant"===e.role?"bg-cyan-50 dark:bg-cyan-900/20":"bg-blue-50 dark:bg-blue-900/20"),children:[(0,s.jsx)("span",{className:"inline-block font-semibold mb-1 capitalize text-[10px] ".concat("system"===e.role?"text-muted-foreground":"assistant"===e.role?"text-cyan-700 dark:text-cyan-300":"text-blue-700 dark:text-blue-300"),children:e.role}),(0,s.jsx)(tx.P,{content:e.content,className:"font-mono"})]},t))}):(0,s.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:null!=v?v:(0,s.jsx)("span",{className:"text-muted-foreground italic",children:"(no prompt)"})})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[(0,s.jsx)(tc.A,{className:"h-3 w-3"})," Response"]}),(0,s.jsx)(tj,{text:null!=y?y:""})]}),A?(0,s.jsx)("div",{className:"space-y-2",children:k.map(e=>(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground mb-1",children:["Choice ",e.index]}),(0,s.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:e.content||(0,s.jsx)("span",{className:"italic",children:"(empty)"})})]},e.index))}):(0,s.jsx)("div",{className:"rounded-md p-3 font-mono text-xs whitespace-pre-wrap ".concat(_?"bg-orange-50 dark:bg-orange-900/20 text-orange-700 dark:text-orange-300":null==y||""===y?"bg-muted/40 text-muted-foreground":"bg-green-50 dark:bg-green-900/20"),children:null==y?(0,s.jsx)("span",{className:"italic",children:"No response captured"}):""===y?(0,s.jsx)("span",{className:"italic",children:"(empty)"}):y}),w.length>0&&(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(tg,{calls:w})}),_&&(0,s.jsxs)(c.Fc,{variant:"destructive",className:"mt-2",children:[(0,s.jsx)(eK.A,{className:"h-4 w-4"}),(0,s.jsx)(c.XL,{children:"Error"}),(0,s.jsx)(c.TN,{className:"text-xs",children:(null==u?void 0:u.error_message)||"The model returned an error. Check the router/endpoint configuration."})]})]}),(0,s.jsx)(e7,{type:"single",collapsible:!0,children:(0,s.jsxs)(te,{value:"metadata",children:[(0,s.jsx)(tt,{className:"text-xs",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(td.A,{className:"h-3 w-3"})," Request Details"]})}),(0,s.jsxs)(ta,{children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[h&&(0,s.jsx)(tb,{label:"Model",value:h,mono:!0}),void 0!==g&&(0,s.jsx)(tb,{label:"Temperature",value:g}),f&&(0,s.jsx)(tb,{label:"Template",value:f}),(null==u?void 0:u.sample_index)!==void 0&&(0,s.jsx)(tb,{label:"Sample Index",value:u.sample_index}),(null==u?void 0:u.iteration)!==void 0&&(0,s.jsx)(tb,{label:"Iteration",value:u.iteration}),(null==u?void 0:u.branch_index)!==void 0&&(0,s.jsx)(tb,{label:"Branch",value:u.branch_index}),(null==u?void 0:u.stream_index)!==void 0&&(0,s.jsx)(tb,{label:"Stream",value:u.stream_index}),(null==u?void 0:u.judge_score)!==void 0&&(0,s.jsx)(tb,{label:"Judge Score",value:u.judge_score}),(null==u?void 0:u.on_topic_score)!==void 0&&(0,s.jsx)(tb,{label:"On-Topic Score",value:u.on_topic_score}),(null==d?void 0:d.n)!==void 0&&(0,s.jsx)(tb,{label:"N",value:d.n}),(null==d?void 0:d.timeout)!==void 0&&(0,s.jsx)(tb,{label:"Timeout",value:"".concat(d.timeout,"s")}),(null==u?void 0:u.surrogate_attack_prompt)&&(0,s.jsx)(tb,{label:"Surrogate Prompt",value:u.surrogate_attack_prompt})]}),(null==u?void 0:u.improvement)&&(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Improvement Rationale"}),(0,s.jsx)("p",{className:"text-xs bg-muted/40 rounded p-2 whitespace-pre-wrap",children:u.improvement})]}),p&&Object.keys(p).filter(e=>"model_name"!==e).length>0&&(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Agent-specific data:"}),(0,s.jsx)(tv,{data:p,maxHeight:"180px"})]})]})]})})]})]})})},tk=e=>{let{content:t}=e,{step_name:a,config_snapshot:n,context_metadata:r,input_data_sample:l,step_type_identifier:i}=t,o=(e=>{switch(null==e?void 0:e.toUpperCase()){case"GENERATION":return{icon:(0,s.jsx)(ts.A,{className:"h-4 w-4"}),color:"text-yellow-600",bgColor:"bg-yellow-100 dark:bg-yellow-900/30",label:"Generation"};case"EXECUTION":return{icon:(0,s.jsx)(tn.A,{className:"h-4 w-4"}),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/30",label:"Execution"};case"EVALUATION":return{icon:(0,s.jsx)(ez.A,{className:"h-4 w-4"}),color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/30",label:"Evaluation"};default:return{icon:(0,s.jsx)(tr.A,{className:"h-4 w-4"}),color:"text-gray-600",bgColor:"bg-gray-100 dark:bg-gray-800/30",label:e||"Other"}}})(i);return(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsxs)(ed.Zp,{className:"border-l-4 ".concat("GENERATION"===i?"border-l-yellow-500":"EXECUTION"===i?"border-l-blue-500":"EVALUATION"===i?"border-l-purple-500":"border-l-gray-500"),children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"p-1.5 rounded ".concat(o.bgColor," ").concat(o.color),children:o.icon}),(0,s.jsx)(Q.E,{variant:"outline",children:i})]})}),(0,s.jsxs)(ed.Wu,{className:"space-y-4",children:[r&&(0,s.jsxs)("div",{className:"bg-muted/30 rounded-md p-3",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Context"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[void 0!==r.num_goals&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(tu.A,{className:"h-3 w-3 text-muted-foreground"}),(0,s.jsxs)("span",{className:"text-xs",children:[r.num_goals," goal(s)"]})]}),r.attack_type&&(0,s.jsx)(Q.E,{variant:"secondary",className:"text-xs w-fit",children:r.attack_type})]})]}),l&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:["Input Data (",Array.isArray(l)?l.length:1," item(s))"]}),Array.isArray(l)&&l.length>0?(0,s.jsxs)("div",{className:"space-y-2",children:[l.slice(0,3).map((e,t)=>(0,s.jsxs)("div",{className:"bg-muted/50 rounded p-2 text-xs",children:[(0,s.jsxs)(Q.E,{variant:"outline",className:"text-xs mb-1",children:["#",t+1]}),(0,s.jsx)("p",{className:"break-all",children:"string"==typeof e?e:JSON.stringify(e)})]},t)),l.length>3&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground text-center",children:["+",l.length-3," more items"]})]}):(0,s.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"Empty input"})]}),n&&(0,s.jsx)(e7,{type:"single",collapsible:!0,children:(0,s.jsxs)(te,{value:"config",children:[(0,s.jsx)(tt,{className:"text-xs",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(td.A,{className:"h-3 w-3"})," Configuration Snapshot"]})}),(0,s.jsx)(ta,{children:(0,s.jsx)(tv,{data:n,maxHeight:"200px"})})]})})]})]})})},tw=e=>{var t;let{content:a}=e,{status:n,step_name:r,step_metadata:l,step_type_identifier:i}=a,o="completed"===n,d=null==l?void 0:l.warning,u=null!=(t=null==l?void 0:l.output_items)?t:"N/A";return(0,s.jsxs)(ed.Zp,{className:"border-l-4 ".concat(d?"border-l-orange-500":o?"border-l-green-500":"border-l-gray-500"),children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsx)("div",{className:"flex items-center justify-end",children:(0,s.jsx)(Q.E,{variant:o?d?"secondary":"default":"outline",children:n})})}),(0,s.jsxs)(ed.Wu,{children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Output Items"}),(0,s.jsx)("p",{className:"text-2xl font-bold ".concat(0===u?"text-orange-500":""),children:u})]}),(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Step Type"}),(0,s.jsx)(Q.E,{variant:"outline",className:"mt-1",children:i})]})]}),d&&(0,s.jsxs)(c.Fc,{className:"mt-4",variant:"default",children:[(0,s.jsx)(eK.A,{className:"h-4 w-4"}),(0,s.jsx)(c.XL,{children:"Warning"}),(0,s.jsx)(c.TN,{className:"text-xs",children:l.warning})]}),l&&Object.keys(l).filter(e=>"warning"!==e&&"output_items"!==e).length>0&&(0,s.jsx)(e7,{type:"single",collapsible:!0,className:"mt-4",children:(0,s.jsxs)(te,{value:"metadata",children:[(0,s.jsx)(tt,{className:"text-xs",children:"Additional Metadata"}),(0,s.jsx)(ta,{children:(0,s.jsx)(tv,{data:l,maxHeight:"150px"})})]})})]})]})},tA=e=>{let{content:t}=e,{candidates:a,raw_generated:n,after_phase1_filtering:r,after_phase2_filtering:l}=t;return(0,s.jsx)(ed.Zp,{className:"border-l-4 border-l-yellow-500",children:(0,s.jsxs)(ed.Wu,{className:"space-y-4 pt-4",children:[(0,s.jsx)("div",{className:"grid grid-cols-3 gap-3",children:[{label:"Generated",value:n,color:"text-gray-700 dark:text-gray-300"},{label:"After Phase 1",value:r,color:"text-blue-600 dark:text-blue-400"},{label:"After Phase 2",value:l,color:"text-green-600 dark:text-green-400"}].map(e=>{let{label:t,value:a,color:n}=e;return void 0!==a&&(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3 text-center",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:t}),(0,s.jsx)("p",{className:"text-2xl font-bold tabular-nums ".concat(n),children:a})]},t)})}),Array.isArray(a)&&a.length>0&&(0,s.jsx)(e7,{type:"single",collapsible:!0,children:(0,s.jsxs)(te,{value:"candidates",children:[(0,s.jsx)(tt,{className:"text-xs",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(tr.A,{className:"h-3 w-3"})," ",a.length," Candidate",1!==a.length?"s":""]})}),(0,s.jsx)(ta,{children:(0,s.jsx)("div",{className:"space-y-2 max-h-[360px] overflow-y-auto pr-1",children:a.map((e,t)=>(0,s.jsxs)("div",{className:"border rounded-md p-3 space-y-1.5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)(Q.E,{variant:"outline",className:"text-xs",children:["#",t+1]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[e.meta_prefix&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate max-w-[160px]",children:e.meta_prefix}),(0,s.jsx)(tj,{text:e.prefix||""})]})]}),(0,s.jsx)("pre",{className:"text-xs font-mono bg-muted/40 p-2 rounded whitespace-pre-wrap break-all",children:e.prefix}),void 0!==e.prefix_nll&&0!==e.prefix_nll&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["NLL: ",e.prefix_nll]})]},t))})})]})})]})})},t_=e=>{let{content:t}=e,{depth:a,branches:n}=t,r=Array.isArray(n)?n:[];return(0,s.jsxs)(ed.Zp,{className:"border-l-4 border-l-indigo-500",children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsx)("div",{className:"flex items-center justify-end",children:(0,s.jsxs)(Q.E,{variant:"secondary",className:"tabular-nums",children:[r.length," branch",1!==r.length?"es":""]})})}),(0,s.jsx)(ed.Wu,{className:"space-y-3",children:0===r.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No branches at this depth."}):(0,s.jsx)(e7,{type:"multiple",className:"w-full",children:r.map((e,t)=>{var a,n;return(0,s.jsxs)(te,{value:String(t),className:"border rounded-md mb-2 last:mb-0",children:[(0,s.jsx)(tt,{className:"px-3 py-2 hover:no-underline text-xs",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)(Q.E,{variant:"outline",className:"text-xs",children:["#",null!=(n=e.branch_index)?n:t]}),void 0!==e.judge_score&&(0,s.jsxs)("span",{className:"tabular-nums font-mono ".concat(e.judge_score>=8?"text-green-600 dark:text-green-400":e.judge_score>=4?"text-yellow-600 dark:text-yellow-400":"text-muted-foreground"),children:["score: ",e.judge_score]}),void 0!==e.on_topic_score&&(0,s.jsxs)("span",{className:"text-muted-foreground tabular-nums font-mono",children:["on-topic: ",e.on_topic_score]}),(0,s.jsxs)("span",{className:"text-muted-foreground truncate max-w-[240px]",children:[null==(a=e.prompt)?void 0:a.slice(0,60),"…"]})]})}),(0,s.jsxs)(ta,{className:"px-3 pb-3 space-y-3",children:[e.improvement&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Improvement Rationale"}),(0,s.jsx)("p",{className:"text-xs bg-muted/40 rounded p-2 whitespace-pre-wrap",children:e.improvement})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Prompt"}),(0,s.jsx)(tj,{text:e.prompt||""})]}),(0,s.jsx)("pre",{className:"text-xs font-mono bg-blue-50 dark:bg-blue-900/20 rounded p-2 whitespace-pre-wrap break-all",children:e.prompt})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Response"}),(0,s.jsx)("pre",{className:"text-xs font-mono rounded p-2 whitespace-pre-wrap break-all ".concat(e.response?"bg-green-50 dark:bg-green-900/20":"bg-muted/40 text-muted-foreground"),children:e.response||(0,s.jsx)("span",{className:"italic",children:"(empty)"})})]}),(e.self_id||e.parent_id)&&(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-xs text-muted-foreground font-mono",children:[e.self_id&&(0,s.jsxs)("span",{children:["id: ",e.self_id]}),e.parent_id&&(0,s.jsxs)("span",{children:["parent: ",e.parent_id]})]})]})]},t)})})})]})},tC=e=>{var t,a,n,r,l,i,o,c,d,u;let{content:m}=e,{score:x,result:p,evaluator:h,explanation:g,step_name:f}=m,j=(null==p?void 0:p.is_success)===!0,v=m.request,b=m.response,N=m.metadata,y=null!=v||null!=b;return(0,s.jsxs)(ed.Zp,{className:"border-l-4 ".concat(j?"border-l-green-500":"border-l-gray-400"),children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsx)("div",{className:"flex items-center justify-end",children:(0,s.jsx)(Q.E,{variant:j?"default":"secondary",className:j?"bg-green-600 hover:bg-green-700":"",children:j?"Success":"No Success"})})}),(0,s.jsxs)(ed.Wu,{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3 text-center",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Best Score"}),(0,s.jsx)("p",{className:"text-2xl font-bold tabular-nums ".concat((null!=(r=null!=(n=null==p?void 0:p.best_score)?n:x)?r:0)>=1?"text-green-600 dark:text-green-400":""),children:null!=(i=null!=(l=null==p?void 0:p.best_score)?l:x)?i:"—"})]}),(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3 text-center",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:(null==p?void 0:p.iterations_completed)!==void 0?"Iterations":"Results"}),(0,s.jsx)("p",{className:"text-2xl font-bold tabular-nums",children:null!=(c=null!=(o=null==p?void 0:p.iterations_completed)?o:null==p?void 0:p.num_results)?c:"—"})]}),(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3 text-center",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Evaluator"}),(0,s.jsx)("p",{className:"text-xs font-mono break-all mt-1",children:null!=h?h:"—"})]})]}),g&&(0,s.jsxs)("div",{className:"bg-muted/30 rounded-md p-3",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Explanation"}),(0,s.jsx)("p",{className:"text-sm",children:g})]}),y&&(0,s.jsx)(e7,{type:"single",collapsible:!0,children:(0,s.jsxs)(te,{value:"judge-io",children:[(0,s.jsx)(tt,{className:"text-xs",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(tc.A,{className:"h-3 w-3"})," Judge Input / Output"]})}),(0,s.jsxs)(ta,{className:"space-y-3 pt-1",children:[(null==N?void 0:N.judge_model)&&(0,s.jsx)(tb,{label:"Judge Model",value:N.judge_model,mono:!0}),null!=v&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Judge Prompt"}),(0,s.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:"string"==typeof v?v:Array.isArray(null==v?void 0:v.messages)?v.messages.map(e=>"[".concat(e.role,"]: ").concat(e.content)).join("\n\n"):JSON.stringify(v,null,2)})]}),null!=b&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Judge Response"}),(0,s.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:"string"==typeof b?b:Array.isArray(null==b?void 0:b.choices)?null!=(d=null==(a=b.choices[0])||null==(t=a.message)?void 0:t.content)?d:JSON.stringify(b):JSON.stringify(b,null,2)})]})]})]})}),m.metadata&&!y&&(m.metadata.prefix||null!=m.metadata.completion)&&(0,s.jsxs)("div",{className:"space-y-3",children:[m.metadata.judge_model&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)(tc.A,{className:"h-3.5 w-3.5"}),(0,s.jsx)("span",{children:"Judge model:"}),(0,s.jsx)("span",{className:"font-mono",children:m.metadata.judge_model})]}),m.metadata.prefix&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[(0,s.jsx)(to.A,{className:"h-3 w-3"})," Attack Prompt (prefix)"]}),(0,s.jsx)(tj,{text:m.metadata.prefix})]}),(0,s.jsx)("pre",{className:"text-xs font-mono bg-blue-50 dark:bg-blue-900/20 rounded-md p-3 whitespace-pre-wrap break-all",children:m.metadata.prefix})]}),null!=m.metadata.completion&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[(0,s.jsx)(tc.A,{className:"h-3 w-3"})," Agent Completion"]}),(0,s.jsx)(tj,{text:null!=(u=m.metadata.completion)?u:""})]}),(0,s.jsx)("pre",{className:"text-xs font-mono rounded-md p-3 whitespace-pre-wrap break-all ".concat(null===m.metadata.completion||""===m.metadata.completion?"bg-muted/40 text-muted-foreground":"bg-green-50 dark:bg-green-900/20"),children:null===m.metadata.completion?"(null)":""===m.metadata.completion?"(empty)":m.metadata.completion})]})]}),m.metadata&&!y&&(()=>{let e=Object.keys(m.metadata).filter(e=>!["judge_model","prefix","completion"].includes(e));return 0===e.length?null:(0,s.jsx)(e7,{type:"single",collapsible:!0,children:(0,s.jsxs)(te,{value:"eval-meta",children:[(0,s.jsx)(tt,{className:"text-xs",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(td.A,{className:"h-3 w-3"})," Evaluation Details"]})}),(0,s.jsx)(ta,{children:(0,s.jsx)(tv,{data:Object.fromEntries(e.map(e=>[e,m.metadata[e]])),maxHeight:"180px"})})]})})})()]})]})},tS=e=>null==e?"":"string"==typeof e?e:"object"==typeof e?JSON.stringify(e,null,2):String(e),tE=e=>{var t,a,n,r,l,i;let{content:o}=e,c=null!=(t=null==o?void 0:o.function)?t:o;null!=(null!=(a=null==c?void 0:c.name)?a:null==o?void 0:o.tool)||null==o||o.tool_name;let d=null!=(r=null!=(n=null==c?void 0:c.arguments)?n:null==o?void 0:o.arguments)?r:null==o?void 0:o.params,u=d;if("string"==typeof d)try{u=JSON.parse(d)}catch(e){}let m=null!=(i=null!=(l=null==o?void 0:o.id)?l:null==o?void 0:o.call_id)?i:null==o?void 0:o.tool_call_id;return(0,s.jsxs)(ed.Zp,{className:"border-l-4 border-l-blue-500",children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsx)("div",{className:"flex items-center justify-end",children:m&&(0,s.jsx)(Q.E,{variant:"outline",className:"font-mono text-xs",children:String(m).slice(-8)})})}),(0,s.jsxs)(ed.Wu,{className:"space-y-3",children:[null!=u?(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Arguments"}),(0,s.jsx)(tj,{text:"string"==typeof u?u:JSON.stringify(u,null,2)})]}),"object"==typeof u?(0,s.jsx)(tv,{data:u,maxHeight:"260px"}):(0,s.jsx)("pre",{className:"text-xs font-mono bg-muted/40 p-3 rounded-md whitespace-pre-wrap",children:u})]}):(0,s.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No arguments"}),Object.entries(o||{}).filter(e=>{let[t]=e;return!["id","call_id","tool_call_id","tool","tool_name","name","function","arguments","params","type"].includes(t)}).length>0&&(0,s.jsx)(e7,{type:"single",collapsible:!0,children:(0,s.jsxs)(te,{value:"extra",children:[(0,s.jsx)(tt,{className:"text-xs",children:"Additional fields"}),(0,s.jsx)(ta,{children:(0,s.jsx)(tv,{data:Object.fromEntries(Object.entries(o).filter(e=>{let[t]=e;return!["id","call_id","tool_call_id","tool","tool_name","name","function","arguments","params","type"].includes(t)})),maxHeight:"150px"})})]})})]})]})},tR=e=>{var t,a,n,r,l,i;let{content:o}=e;null!=(null!=(t=null==o?void 0:o.tool_name)?t:null==o?void 0:o.name)||null==o||o.tool;let c=null!=(n=null!=(a=null==o?void 0:o.tool_call_id)?a:null==o?void 0:o.call_id)?n:null==o?void 0:o.id,d=null!=(i=null!=(l=null!=(r=null==o?void 0:o.content)?r:null==o?void 0:o.result)?l:null==o?void 0:o.output)?i:null==o?void 0:o.message,u=(null==o?void 0:o.is_error)===!0||(null==o?void 0:o.status)==="error"||(null==o?void 0:o.error);return(0,s.jsxs)(ed.Zp,{className:"border-l-4 ".concat(u?"border-l-destructive":"border-l-green-500"),children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[c&&(0,s.jsx)(Q.E,{variant:"outline",className:"font-mono text-xs",children:String(c).slice(-8)}),u&&(0,s.jsx)(Q.E,{variant:"destructive",children:"Error"})]})}),(0,s.jsx)(ed.Wu,{className:"space-y-3",children:null!=d?(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Result"}),(0,s.jsx)(tj,{text:tS(d)})]}),"object"==typeof d?(0,s.jsx)(tv,{data:d,maxHeight:"260px"}):(0,s.jsx)("pre",{className:"text-xs font-mono p-3 rounded-md whitespace-pre-wrap ".concat(u?"bg-destructive/10 text-destructive":"bg-green-50 dark:bg-green-900/20"),children:tS(d)})]}):(0,s.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No result content"})})]})},tT=e=>{var t,a,n,r;let{content:l}=e,i="string"==typeof l?l:tS(null!=(r=null!=(n=null!=(a=null!=(t=null==l?void 0:l.thought)?t:null==l?void 0:l.reasoning)?a:null==l?void 0:l.thinking)?n:null==l?void 0:l.content)?r:l);return(0,s.jsx)(ed.Zp,{className:"border-l-4 border-l-purple-500",children:(0,s.jsxs)(ed.Wu,{className:"pt-4",children:[(0,s.jsxs)("div",{className:"relative group",children:[(0,s.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,s.jsx)(tj,{text:i})}),(0,s.jsx)("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-md p-4",children:(0,s.jsx)("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:i})})]}),"object"==typeof l&&null!==l&&Object.keys(l).filter(e=>!["thought","reasoning","thinking","content"].includes(e)).length>0&&(0,s.jsx)(e7,{type:"single",collapsible:!0,className:"mt-3",children:(0,s.jsxs)(te,{value:"extra",children:[(0,s.jsx)(tt,{className:"text-xs",children:"Additional fields"}),(0,s.jsx)(ta,{children:(0,s.jsx)(tv,{data:Object.fromEntries(Object.entries(l).filter(e=>{let[t]=e;return!["thought","reasoning","thinking","content"].includes(t)})),maxHeight:"150px"})})]})})]})})},tO=e=>{var t,a,n,r,l,i,o,c,d,u,m,x;let{content:p}=e,h=null!=(l=null==p||null==(a=p.choices)||null==(t=a[0])?void 0:t.delta)?l:null==p?void 0:p.delta,g="string"==typeof p?p:tS(null!=(d=null!=(c=null!=(o=null!=(i=null==h?void 0:h.content)?i:null==p?void 0:p.content)?o:null==p?void 0:p.text)?c:null==p?void 0:p.message)?d:p),f=null!=(m=null!=(u=null==h?void 0:h.role)?u:null==p?void 0:p.role)?m:"assistant",j=null!=(x=null==p||null==(r=p.choices)||null==(n=r[0])?void 0:n.finish_reason)?x:null==p?void 0:p.finish_reason;return(0,s.jsxs)(ed.Zp,{className:"border-l-4 border-l-cyan-500",children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(Q.E,{variant:"secondary",className:"capitalize text-xs",children:f}),j&&(0,s.jsx)(Q.E,{variant:"stop"===j?"default":"secondary",className:"text-xs",children:j})]})}),(0,s.jsxs)(ed.Wu,{children:[(0,s.jsxs)("div",{className:"relative group",children:[(0,s.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,s.jsx)(tj,{text:g})}),(0,s.jsx)("div",{className:"bg-cyan-50 dark:bg-cyan-900/20 rounded-md p-4",children:(0,s.jsx)("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:g||(0,s.jsx)("span",{className:"italic text-muted-foreground",children:"(empty chunk)"})})})]}),"object"==typeof p&&null!==p&&!p.choices&&!p.delta&&Object.keys(p).filter(e=>!["content","text","message","role","delta"].includes(e)).length>0&&(0,s.jsx)(e7,{type:"single",collapsible:!0,className:"mt-3",children:(0,s.jsxs)(te,{value:"extra",children:[(0,s.jsx)(tt,{className:"text-xs",children:"Additional fields"}),(0,s.jsx)(ta,{children:(0,s.jsx)(tv,{data:p,maxHeight:"150px"})})]})})]})]})},tL=e=>{var t,a,n,r,l,i,o,c;let{content:d}=e,u=null!=(a=null!=(t=null==d?void 0:d.operation)?t:null==d?void 0:d.method)?a:null==d?void 0:d.action,m=null!=(r=null!=(n=null==d?void 0:d.tool)?n:null==d?void 0:d.resource)?r:null==d?void 0:d.server,x=null!=(i=null!=(l=null==d?void 0:d.context)?l:null==d?void 0:d.inputs)?i:null==d?void 0:d.params,p=null!=(c=null!=(o=null==d?void 0:d.result)?o:null==d?void 0:d.output)?c:null==d?void 0:d.response,h=(null==d?void 0:d.error)||(null==d?void 0:d.is_error);return(0,s.jsxs)(ed.Zp,{className:"border-l-4 border-l-orange-500",children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[u&&(0,s.jsx)(Q.E,{variant:"outline",className:"text-xs",children:u}),m&&(0,s.jsx)(Q.E,{variant:"secondary",className:"text-xs font-mono",children:m})]})}),(0,s.jsxs)(ed.Wu,{className:"space-y-3",children:[void 0!==x&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:"Context / Input"}),(0,s.jsx)(tv,{data:x,maxHeight:"200px"})]}),void 0!==p&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:h?"⚠ Error":"Result"}),"string"==typeof p?(0,s.jsx)("pre",{className:"text-xs p-3 rounded-md whitespace-pre-wrap font-mono ".concat(h?"bg-destructive/10 text-destructive":"bg-muted/40"),children:p}):(0,s.jsx)(tv,{data:p,maxHeight:"200px"})]}),void 0===x&&void 0===p&&(0,s.jsx)(tv,{data:d,maxHeight:"300px"})]})]})},tI=e=>{var t,a,n,r,l,i,o,c,d,u,m;let{content:x}=e,p=null!=(a=null!=(t=null==x?void 0:x.from)?t:null==x?void 0:x.sender)?a:null==x?void 0:x.source,h=null!=(l=null!=(r=null!=(n=null==x?void 0:x.to)?n:null==x?void 0:x.receiver)?r:null==x?void 0:x.target)?l:null==x?void 0:x.destination,g=tS(null!=(d=null!=(c=null!=(o=null!=(i=null==x?void 0:x.message)?i:null==x?void 0:x.content)?o:null==x?void 0:x.text)?c:null==x?void 0:x.payload)?d:x),f=null!=(m=null!=(u=null==x?void 0:x.message_type)?u:null==x?void 0:x.type)?m:null==x?void 0:x.role;return(0,s.jsxs)(ed.Zp,{className:"border-l-4 border-l-pink-500",children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[f&&(0,s.jsx)(Q.E,{variant:"outline",className:"text-xs",children:f}),(p||h)&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[p&&(0,s.jsx)(Q.E,{variant:"secondary",className:"text-xs",children:p}),p&&h&&(0,s.jsx)(to.A,{className:"h-3 w-3"}),h&&(0,s.jsx)(Q.E,{variant:"secondary",className:"text-xs",children:h})]})]})}),(0,s.jsx)(ed.Wu,{children:(0,s.jsxs)("div",{className:"relative group",children:[(0,s.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,s.jsx)(tj,{text:g})}),(0,s.jsx)("div",{className:"bg-pink-50 dark:bg-pink-900/20 rounded-md p-4",children:(0,s.jsx)("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:g})})]})})]})},tz={WARMUP:"border-l-amber-500",LIFELONG:"border-l-blue-500",EVALUATION:"border-l-violet-500"},tM=e=>{var t;let{content:a}=e,{phase:n,subphase:r,message:l,strategy_count:i,num_results:o,timestamp_utc:c}=a,d=null!=(t=tz[n])?t:"border-l-muted-foreground";return(0,s.jsxs)(ed.Zp,{className:"border-l-4 ".concat(d),children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsx)("div",{className:"flex items-center justify-end",children:(0,s.jsx)(Q.E,{variant:"outline",className:"text-xs font-mono",children:r})})}),(0,s.jsxs)(ed.Wu,{className:"space-y-2",children:[l&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:l}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-3 text-xs",children:[void 0!==i&&(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-2",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Strategies learned: "}),(0,s.jsx)("span",{className:"font-bold",children:i})]}),void 0!==o&&(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-2",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Results produced: "}),(0,s.jsx)("span",{className:"font-bold",children:o})]}),c&&(0,s.jsx)("span",{className:"text-muted-foreground font-mono",children:new Date(c).toLocaleTimeString()})]})]})]})},tJ=e=>{var t;let{content:a}=e,{phase:n,attacker_role:r,generated_prompt:l,attacker_raw_response:i,system_prompt:o,epoch:c,iteration:d}=a,u=null!=(t=tz[n])?t:"border-l-purple-500";return(0,s.jsxs)(ed.Zp,{className:"border-l-4 ".concat(u),children:[(0,s.jsxs)(ed.aR,{className:"pb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[void 0!==c&&(0,s.jsxs)(Q.E,{variant:"outline",className:"text-xs",children:["epoch ",c]}),void 0!==d&&(0,s.jsxs)(Q.E,{variant:"outline",className:"text-xs",children:["iter ",d]})]}),r&&(0,s.jsx)(ed.BT,{className:"font-mono text-xs truncate",children:r})]}),(0,s.jsxs)(ed.Wu,{className:"space-y-3",children:[l&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Generated Prompt"}),(0,s.jsx)(tj,{text:l})]}),(0,s.jsx)("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:l})]}),o&&(0,s.jsx)(e7,{type:"single",collapsible:!0,children:(0,s.jsxs)(te,{value:"sys",children:[(0,s.jsx)(tt,{className:"text-xs",children:"Attacker System Prompt"}),(0,s.jsx)(ta,{children:(0,s.jsx)("div",{className:"bg-muted/30 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:o})})]})}),i&&(0,s.jsx)(e7,{type:"single",collapsible:!0,children:(0,s.jsxs)(te,{value:"raw",children:[(0,s.jsx)(tt,{className:"text-xs",children:"Raw Attacker Response"}),(0,s.jsx)(ta,{children:(0,s.jsx)("div",{className:"bg-muted/30 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:i})})]})})]})]})},tP=e=>{var t;let{content:a}=e,{phase:n,prompt:r,target_response:l,target_role:i,epoch:o,iteration:c}=a,d=null!=(t=tz[n])?t:"border-l-blue-500";return(0,s.jsxs)(ed.Zp,{className:"border-l-4 ".concat(d),children:[(0,s.jsxs)(ed.aR,{className:"pb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[void 0!==o&&(0,s.jsxs)(Q.E,{variant:"outline",className:"text-xs",children:["epoch ",o]}),void 0!==c&&(0,s.jsxs)(Q.E,{variant:"outline",className:"text-xs",children:["iter ",c]})]}),i&&(0,s.jsx)(ed.BT,{className:"font-mono text-xs truncate",children:i})]}),(0,s.jsxs)(ed.Wu,{className:"space-y-3",children:[r&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[(0,s.jsx)(to.A,{className:"h-3 w-3"})," Prompt sent to target"]}),(0,s.jsx)(tj,{text:r})]}),(0,s.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:r})]}),l&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[(0,s.jsx)(tc.A,{className:"h-3 w-3"})," Target response"]}),(0,s.jsx)(tj,{text:l})]}),(0,s.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:l})]})]})]})},tD=e=>{var t;let{content:a}=e,{phase:n,score:r,assessment:l,scorer_role:i,epoch:o,iteration:c,prev_score:d}=a,u=null!=(t=tz[n])?t:"border-l-violet-500",m=void 0!==d?r-d:void 0;return(0,s.jsxs)(ed.Zp,{className:"border-l-4 ".concat(u),children:[(0,s.jsxs)(ed.aR,{className:"pb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[void 0!==o&&(0,s.jsxs)(Q.E,{variant:"outline",className:"text-xs",children:["epoch ",o]}),void 0!==c&&(0,s.jsxs)(Q.E,{variant:"outline",className:"text-xs",children:["iter ",c]})]}),i&&(0,s.jsx)(ed.BT,{className:"font-mono text-xs truncate",children:i})]}),(0,s.jsxs)(ed.Wu,{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3 text-center min-w-[80px]",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Score"}),(0,s.jsx)("p",{className:"text-2xl font-bold tabular-nums ".concat(r>=8?"text-red-600 dark:text-red-400":r>=5?"text-orange-600 dark:text-orange-400":r>=3?"text-yellow-600 dark:text-yellow-400":"text-muted-foreground"),children:r})]}),void 0!==m&&(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3 text-center min-w-[80px]",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Δ vs prev"}),(0,s.jsx)("p",{className:"text-2xl font-bold tabular-nums ".concat(m>0?"text-red-500":m<0?"text-green-500":"text-muted-foreground"),children:m>0?"+".concat(m):m})]})]}),l&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Assessment"}),(0,s.jsx)("div",{className:"bg-muted/30 rounded-md p-3 text-xs whitespace-pre-wrap",children:l})]})]})]})},tF=e=>{var t;let{content:a}=e,{phase:n,strategy:r,score_delta:l,weak_prompt:i,strong_prompt:o,summarizer_role:c}=a,d=null!=(t=tz[n])?t:"border-l-teal-500";return(0,s.jsxs)(ed.Zp,{className:"border-l-4 ".concat(d),children:[(0,s.jsxs)(ed.aR,{className:"pb-2",children:[(0,s.jsx)("div",{className:"flex items-center justify-end",children:void 0!==l&&(0,s.jsxs)("span",{className:"text-xs font-bold tabular-nums ".concat(l>0?"text-red-500":l<0?"text-green-500":"text-muted-foreground"),children:["Δ ",l>0?"+".concat(l):l]})}),c&&(0,s.jsx)(ed.BT,{className:"font-mono text-xs truncate",children:c})]}),(0,s.jsxs)(ed.Wu,{className:"space-y-3",children:[r&&(0,s.jsxs)("div",{className:"bg-teal-50 dark:bg-teal-900/20 rounded-md p-3 space-y-1.5",children:[r.Strategy&&(0,s.jsx)("p",{className:"text-xs font-semibold",children:r.Strategy}),r.Definition&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:r.Definition}),"string"==typeof r&&(0,s.jsx)("p",{className:"text-xs whitespace-pre-wrap",children:r})]}),(i||o)&&(0,s.jsxs)(e7,{type:"multiple",children:[i&&(0,s.jsxs)(te,{value:"weak",children:[(0,s.jsx)(tt,{className:"text-xs",children:"Weak Prompt (before)"}),(0,s.jsx)(ta,{children:(0,s.jsx)("div",{className:"bg-muted/30 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:i})})]}),o&&(0,s.jsxs)(te,{value:"strong",children:[(0,s.jsx)(tt,{className:"text-xs",children:"Strong Prompt (after)"}),(0,s.jsx)(ta,{children:(0,s.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:o})})]})]})]})]})},tU=e=>{let{content:t}=e,{goal:a,prompt:n,response:r,eval_hb:l,eval_jb:i,eval_nj:o,explanation_hb:c,explanation_jb:d,explanation_nj:u,autodan_score:m,judge_best_score:x,judge_success:p}=t,h=[{key:"HarmBench",val:l,exp:c,color:l?"text-red-600 dark:text-red-400":"text-green-600 dark:text-green-400"},{key:"Jailbreak",val:i,exp:d,color:i?"text-red-600 dark:text-red-400":"text-green-600 dark:text-green-400"},{key:"No-Jailbreak",val:o,exp:u,color:o?"text-green-600 dark:text-green-400":"text-muted-foreground"}];return(0,s.jsxs)(ed.Zp,{className:"border-l-4 border-l-violet-500",children:[(0,s.jsx)(ed.aR,{className:"pb-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[void 0!==m&&(0,s.jsxs)(Q.E,{variant:m>0?"destructive":"secondary",className:"text-xs tabular-nums",children:["autodan_score: ",m]}),void 0!==x&&(0,s.jsxs)(Q.E,{variant:"outline",className:"text-xs tabular-nums",children:["best: ",x]}),void 0!==p&&(0,s.jsx)(Q.E,{variant:p?"destructive":"default",className:"text-xs",children:p?"✗ Jailbroken":"✓ Safe"})]})}),(0,s.jsxs)(ed.Wu,{className:"space-y-4",children:[(0,s.jsx)("div",{className:"grid grid-cols-3 gap-3",children:h.map(e=>{let{key:t,val:a,color:n}=e;return(0,s.jsxs)("div",{className:"bg-muted/50 rounded-md p-3 text-center",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:t}),(0,s.jsx)("p",{className:"text-sm font-bold ".concat(n),children:void 0===a?"N/A":a?"Yes":"No"})]},t)})}),h.some(e=>e.exp)&&(0,s.jsx)(e7,{type:"multiple",children:h.filter(e=>e.exp).map(e=>{let{key:t,exp:a}=e;return(0,s.jsxs)(te,{value:t,children:[(0,s.jsxs)(tt,{className:"text-xs",children:[t," Explanation"]}),(0,s.jsx)(ta,{children:(0,s.jsx)("div",{className:"bg-muted/30 rounded-md p-3 text-xs whitespace-pre-wrap",children:a})})]},t)})}),n&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Best Prompt"}),(0,s.jsx)(tj,{text:n})]}),(0,s.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-md p-3 font-mono text-xs whitespace-pre-wrap",children:n})]}),r&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Target Response"}),(0,s.jsx)(tj,{text:r})]}),(0,s.jsx)("div",{className:"rounded-md p-3 font-mono text-xs whitespace-pre-wrap ".concat(p?"bg-red-50 dark:bg-red-900/20":"bg-green-50 dark:bg-green-900/20"),children:r})]})]})]})},tq=e=>{let{content:t}=e;if(!t||"object"!=typeof t)return(0,s.jsx)(ed.Zp,{children:(0,s.jsx)(ed.Wu,{className:"pt-4",children:(0,s.jsx)("span",{className:"text-sm font-mono",children:String(t)})})});let a=Object.entries(t),n=a.filter(e=>{let[,t]=e;return null===t||"object"!=typeof t}),r=a.filter(e=>{let[,t]=e;return null!==t&&"object"==typeof t});return(0,s.jsx)(ed.Zp,{children:(0,s.jsxs)(ed.Wu,{className:"space-y-3 pt-4",children:[n.length>0&&(0,s.jsx)("div",{className:"divide-y divide-border/50",children:n.map(e=>{let[t,a]=e;return(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-x-3 py-1.5 text-xs items-start",children:[(0,s.jsx)("span",{className:"font-medium text-muted-foreground col-span-1 truncate",title:t,children:t}),(0,s.jsx)("span",{className:"col-span-2 break-all font-mono",children:String(null!=a?a:"null")})]},t)})}),r.length>0&&(0,s.jsx)(e7,{type:"multiple",className:"w-full",children:r.map(e=>{let[t,a]=e;return(0,s.jsxs)(te,{value:t,className:"border rounded-md mb-2 last:mb-0",children:[(0,s.jsx)(tt,{className:"text-xs px-3 py-2 hover:no-underline",children:(0,s.jsx)("span",{className:"font-medium text-muted-foreground",children:t})}),(0,s.jsx)(ta,{className:"px-3 pb-3",children:(0,s.jsx)(tv,{data:a,maxHeight:"200px"})})]},t)})})]})})},tH=e=>{let{trace:t}=e;if(!t)return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[(0,s.jsx)(tl.A,{className:"h-8 w-8 mb-2 opacity-50"}),(0,s.jsx)("p",{children:"No trace data available"})]});let a=t.content,n=((e,t)=>{switch(t){case N.Esj.ToolCall:return"tool_call";case N.Esj.ToolResponse:return"tool_response";case N.Esj.AgentThought:return"agent_thought";case N.Esj.AgentResponseChunk:return"agent_response";case N.Esj.McpStep:return"mcp_step";case N.Esj.A2AComm:return"a2a_comm"}if(!e)return"unknown";let a=Object.keys(e);if(a.includes("goal")&&a.includes("attack_type")&&a.includes("goal_index"))return"goal_init";if(a.includes("candidates")&&a.includes("raw_generated"))return"candidate_pool";if(a.includes("branches")&&a.includes("depth"))return"tap_tree_depth";if(a.includes("evaluator")&&a.includes("score")&&a.includes("result"))return"evaluation";if(a.includes("request")&&a.includes("response")&&a.includes("metadata"))return"target_completion";if(a.includes("status")&&a.includes("step_metadata"))return"pipeline_summary";if(a.includes("step_type_identifier"))return"pipeline_start";if(a.includes("request")&&a.includes("response"))return"target_completion";if(a.includes("phase")&&a.includes("subphase"))switch(e.subphase){case"GENERATION":return"autodan_generation";case"TARGET_QUERY":return"autodan_target_query";case"SCORING":return"autodan_scoring";case"SUMMARIZATION":return"autodan_summarization";case"JUDGE_SCORING":return"autodan_judge_scoring";default:return"autodan_phase_marker"}return"unknown"})(a,t.stepType);return(0,s.jsxs)("div",{className:"space-y-3",children:["goal_init"===n&&(0,s.jsx)(tN,{content:a}),"candidate_pool"===n&&(0,s.jsx)(tA,{content:a}),"tap_tree_depth"===n&&(0,s.jsx)(t_,{content:a}),"target_completion"===n&&(0,s.jsx)(ty,{content:a}),"evaluation"===n&&(0,s.jsx)(tC,{content:a}),"pipeline_start"===n&&(0,s.jsx)(tk,{content:a}),"pipeline_summary"===n&&(0,s.jsx)(tw,{content:a}),"tool_call"===n&&(0,s.jsx)(tE,{content:a}),"tool_response"===n&&(0,s.jsx)(tR,{content:a}),"agent_thought"===n&&(0,s.jsx)(tT,{content:a}),"agent_response"===n&&(0,s.jsx)(tO,{content:a}),"mcp_step"===n&&(0,s.jsx)(tL,{content:a}),"a2a_comm"===n&&(0,s.jsx)(tI,{content:a}),"autodan_phase_marker"===n&&(0,s.jsx)(tM,{content:a}),"autodan_generation"===n&&(0,s.jsx)(tJ,{content:a}),"autodan_target_query"===n&&(0,s.jsx)(tP,{content:a}),"autodan_scoring"===n&&(0,s.jsx)(tD,{content:a}),"autodan_summarization"===n&&(0,s.jsx)(tF,{content:a}),"autodan_judge_scoring"===n&&(0,s.jsx)(tU,{content:a}),"unknown"===n&&(0,s.jsx)(tq,{content:a}),(0,s.jsx)(e7,{type:"single",collapsible:!0,children:(0,s.jsxs)(te,{value:"raw",children:[(0,s.jsx)(tt,{className:"text-xs text-muted-foreground",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(tm.A,{className:"h-3 w-3"})," View Raw JSON"]})}),(0,s.jsx)(ta,{children:(0,s.jsx)(tv,{data:t.content,maxHeight:"300px"})})]})})]})};var tB=a(79397),t$=a(77801),tG=a(76907),tW=a(1524),tV=a(1473),tZ=a(18085),tK=a(37586),tX=a(20508),tY=a(6926),tQ=a(39332);let t0=e=>{var t,a;if(!e)return null;let s=null!=(t=e.prompt_tokens)?t:e.input_tokens,n=null!=(a=e.completion_tokens)?a:e.output_tokens;return"number"==typeof s&&"number"==typeof n?"".concat(s," in \xb7 ").concat(n," out"):"number"==typeof e.total_tokens?"".concat(e.total_tokens," tokens"):null},t1=e=>"string"==typeof e?e:JSON.stringify(e),t3={attacker:{border:"border-l-orange-400",icon:(0,s.jsx)(W.A,{className:"h-3.5 w-3.5"})},target:{border:"border-l-blue-500",icon:(0,s.jsx)(tc.A,{className:"h-3.5 w-3.5"})},panel:{border:"border-l-purple-500",icon:(0,s.jsx)(tY.A,{className:"h-3.5 w-3.5"})}},t2=e=>{let{verdict:t}=e;return null===t.success?null:t.success?(0,s.jsxs)(Q.E,{variant:"destructive",className:"gap-1",children:[(0,s.jsx)(eK.A,{className:"h-3 w-3"}),"Jailbreak"]}):(0,s.jsxs)(Q.E,{variant:"secondary",className:"gap-1",children:[(0,s.jsx)(tG.A,{className:"h-3 w-3"}),"Mitigated"]})},t5=e=>{let{message:t}=e;return(0,s.jsxs)("div",{className:"rounded-md px-3 py-2 text-xs ".concat("assistant"===t.role?"bg-cyan-50 dark:bg-cyan-900/20":"system"===t.role?"border bg-muted/60":"bg-blue-50 dark:bg-blue-900/20"),children:[(0,s.jsx)("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:t.role}),(0,s.jsx)(tx.P,{content:t.content})]})},t4=e=>{let{messages:t,showAll:a=!1}=e,[r,l]=(0,n.useState)(a),i=t.slice(0,-1),o=t[t.length-1];return(0,s.jsxs)("div",{className:"space-y-2",children:[i.length>0&&!r&&(0,s.jsxs)(d.$,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>l(!0),children:[(0,s.jsx)(z.A,{className:"mr-1 h-3 w-3"}),"Show the ",i.length," earlier message",1===i.length?"":"s"]}),r&&i.map((e,t)=>(0,s.jsx)(t5,{message:e},t)),o&&(0,s.jsx)(t5,{message:o})]})},t6=e=>{let{text:t}=e;return(0,s.jsxs)("div",{className:"rounded-md bg-green-50 px-3 py-2 text-xs dark:bg-green-900/20",children:[(0,s.jsx)("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Reply"}),"string"==typeof t||Array.isArray(t)?(0,s.jsx)(tx.P,{content:t}):null==t?(0,s.jsx)("span",{className:"italic text-muted-foreground",children:"No reply recorded"}):(0,s.jsx)("pre",{className:"whitespace-pre-wrap break-all font-mono",children:JSON.stringify(t,null,2)})]})},t9=e=>{var t;let{item:a}=e,n=(0,tp.bR)(a.role),r=(e=>{var t;return null!=(t=t3[e])?t:{border:"border-l-muted-foreground/40",icon:(0,s.jsx)(to.A,{className:"h-3.5 w-3.5"})}})(a.role),l=t0(a.usage);return(0,s.jsxs)("section",{"aria-label":"".concat(n," call"),className:"space-y-2 rounded-md border border-l-4 ".concat(r.border," bg-card p-3"),children:[(0,s.jsxs)("header",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1 font-semibold",children:[r.icon,n]}),a.verdict&&(0,s.jsx)(t2,{verdict:a.verdict}),(null==(t=a.verdict)?void 0:t.score)!=null&&(0,s.jsxs)("span",{className:"flex items-center gap-1 font-mono",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"score"}),(0,s.jsx)("span",{children:a.verdict.score})]}),(0,s.jsxs)("span",{className:"ml-auto flex items-center gap-3 text-muted-foreground",children:[l&&(0,s.jsx)("span",{children:l}),null!=a.latencyS&&(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(e5.A,{className:"h-3 w-3"}),a.latencyS,"s"]})]})]}),a.error&&(0,s.jsxs)("p",{className:"flex items-center gap-1 rounded bg-orange-50 px-2 py-1 text-xs text-orange-700 dark:bg-orange-900/20 dark:text-orange-300",children:[(0,s.jsx)(eK.A,{className:"h-3 w-3"}),a.error]}),a.verdict?(0,s.jsxs)(s.Fragment,{children:[a.verdict.explanation&&(0,s.jsx)("p",{className:"whitespace-pre-wrap text-xs",children:a.verdict.explanation}),null!=a.request&&(0,s.jsxs)("details",{className:"text-xs",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-muted-foreground",children:"What the panel judged"}),(0,s.jsx)("pre",{className:"mt-1 whitespace-pre-wrap break-all rounded bg-muted/40 p-2 font-mono",children:JSON.stringify(a.request,null,2)})]})]}):(0,s.jsxs)(s.Fragment,{children:[a.messages&&a.messages.length>0&&(0,s.jsx)(t4,{messages:a.messages}),null===a.messages&&null!=a.request&&(0,s.jsx)("pre",{className:"whitespace-pre-wrap break-all rounded bg-muted/40 p-2 font-mono text-xs",children:t1(a.request)}),(void 0!==a.response||!a.error)&&(0,s.jsx)(t6,{text:a.response})]})]})},t8=e=>{let{item:t}=e,a=t.label.toLowerCase(),n=Object.entries(t.data).filter(e=>{let[t,s]=e;return null!==s&&"object"!=typeof s&&!a.includes(t.toLowerCase())});return(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b pb-1 pt-3 text-xs",children:[(0,s.jsx)(tQ.A,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,s.jsx)("span",{className:"font-semibold",children:t.label||"Phase"}),n.map(e=>{let[t,a]=e;return(0,s.jsxs)("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:[t,": ",String(a)]},t)})]})},t7=e=>{let{item:t}=e;return(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-md border border-dashed px-3 py-1.5 text-xs",children:[(0,s.jsx)(Q.E,{variant:"outline",className:"font-mono",children:t.label}),t.reason&&(0,s.jsx)("span",{children:t.reason}),Object.entries(t.data).map(e=>{let[t,a]=e;return(0,s.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground",children:[t,": ",t1(a)]},t)})]})},ae=e=>{let{item:t}=e;return(0,s.jsxs)("section",{"aria-label":"Recorded exchange",className:"space-y-2 rounded-md border bg-muted/20 p-3",children:[(0,s.jsxs)("header",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,s.jsx)(ez.A,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,s.jsx)("span",{className:"font-semibold",children:"Recorded exchange"}),(0,s.jsxs)("span",{className:"ml-auto flex items-center gap-3 text-muted-foreground",children:[t.model&&(0,s.jsx)("span",{className:"font-mono",children:t.model}),t.finishReason&&(0,s.jsx)("span",{children:t.finishReason}),t0(t.usage)&&(0,s.jsx)("span",{children:t0(t.usage)})]})]}),t.error&&(0,s.jsx)("p",{className:"text-xs text-orange-700 dark:text-orange-300",children:t.error}),t.messages.length>0&&(0,s.jsx)(t4,{messages:t.messages}),(0,s.jsx)(t6,{text:t.text}),(0,s.jsx)(tg,{calls:t.toolCalls})]})},at=e=>{let{traces:t}=e,a=(0,n.useMemo)(()=>(0,tp.ME)(t),[t]),r=(0,n.useMemo)(()=>{var e,t;let s=a.filter(e=>"call"===e.kind&&!!e.verdict);return null!=(t=null==(e=s[s.length-1])?void 0:e.verdict)?t:null},[a]);return(0,s.jsxs)("div",{className:"space-y-2",children:[r&&(0,s.jsxs)("div",{role:"status",className:"mb-3 flex flex-wrap items-center gap-2 rounded-md border bg-muted/30 px-3 py-2 text-xs",children:[(0,s.jsx)("span",{className:"font-semibold",children:"Panel verdict"}),(0,s.jsx)(t2,{verdict:r}),null!=r.score&&(0,s.jsxs)("span",{className:"font-mono",children:["score ",r.score]}),r.explanation&&(0,s.jsx)("span",{className:"text-muted-foreground",children:r.explanation})]}),a.map(e=>(0,s.jsxs)("div",{style:{marginLeft:"".concat(16*Math.min("phase"===e.kind?e.depth:Math.max(0,e.depth-1),4),"px")},children:["phase"===e.kind&&(0,s.jsx)(t8,{item:e}),"call"===e.kind&&(0,s.jsx)(t9,{item:e}),"decision"===e.kind&&(0,s.jsx)(t7,{item:e}),"interaction"===e.kind&&(0,s.jsx)(ae,{item:e}),"other"===e.kind&&(0,s.jsxs)("details",{className:"rounded-md border px-3 py-1.5 text-xs",children:[(0,s.jsxs)("summary",{className:"cursor-pointer",children:[e.node,e.label?": ".concat(e.label):""]}),(0,s.jsx)("pre",{className:"mt-1 whitespace-pre-wrap break-all font-mono",children:JSON.stringify(e.data,null,2)})]})]},e.key))]})},aa=e=>{let{traces:t}=e,a=(0,n.useMemo)(()=>(e=>{let t=e.find(e=>{let t=e.content;return(null==t?void 0:t.judge_success)!==void 0&&(null==t?void 0:t.autodan_score)!==void 0});if(t){let e=t.content;return{verdict:e.judge_success?"jailbroken":"safe",score:e.autodan_score,bestScore:e.judge_best_score,evaluator:"AutoDAN Multi-Judge"}}let a=e.find(e=>{let t=e.content;return(null==t?void 0:t.evaluator)&&(null==t?void 0:t.result)!==void 0});if(a){var s,n,r,l,i,o;let e=a.content,t=null!=(l=e.score)?l:"object"==typeof e.result?null==(s=e.result)?void 0:s.score:void 0;return{verdict:void 0!==t&&t>0||"unsafe"===String(e.result).toLowerCase()||(null!=(i=null==(n=e.result)?void 0:n.explanation)?i:"").toLowerCase().includes("unsafe")?"jailbroken":"safe",score:t,evaluator:e.evaluator,explanation:null!=(o=e.explanation)?o:null==(r=e.result)?void 0:r.explanation}}return null})(t),[t]);if(!a)return null;let r="jailbroken"===a.verdict,l="unknown"===a.verdict;return(0,s.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border px-4 py-3 mb-5 ".concat(l?"border-muted bg-muted/30":r?"border-red-300 dark:border-red-800 bg-red-50 dark:bg-red-950/40":"border-green-300 dark:border-green-800 bg-green-50 dark:bg-green-950/40"),children:[l?(0,s.jsx)(tB.A,{className:"h-5 w-5 shrink-0 text-muted-foreground"}):r?(0,s.jsx)(t$.A,{className:"h-5 w-5 shrink-0 text-red-600 dark:text-red-400"}):(0,s.jsx)(tG.A,{className:"h-5 w-5 shrink-0 text-green-600 dark:text-green-400"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-xs font-semibold ".concat(l?"text-muted-foreground":r?"text-red-700 dark:text-red-300":"text-green-700 dark:text-green-300"),children:l?"Evaluation unknown":r?"Jailbreak successful":"Model resisted"}),a.explanation&&(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground mt-0.5 truncate",children:a.explanation})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[void 0!==a.score&&(0,s.jsxs)("div",{className:"text-right",children:[(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground",children:"Score"}),(0,s.jsx)("p",{className:"text-sm font-bold tabular-nums ".concat(a.score>=.7||a.score>=7?"text-red-600 dark:text-red-400":a.score>=.4||a.score>=4?"text-yellow-600 dark:text-yellow-400":"text-green-600 dark:text-green-400"),children:a.score})]}),void 0!==a.bestScore&&a.bestScore!==a.score&&(0,s.jsxs)("div",{className:"text-right",children:[(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[(0,s.jsx)(tW.A,{className:"h-2.5 w-2.5"})," Best"]}),(0,s.jsx)("p",{className:"text-sm font-bold tabular-nums text-orange-600 dark:text-orange-400",children:a.bestScore})]}),a.evaluator&&(0,s.jsx)(Q.E,{variant:"secondary",className:"text-[10px] font-normal",children:a.evaluator})]})]})},as={WARMUP:"border-amber-400/60",LIFELONG:"border-blue-400/60",EVALUATION:"border-violet-400/60"},an={WARMUP:"text-amber-700 dark:text-amber-400",LIFELONG:"text-blue-700 dark:text-blue-400",EVALUATION:"text-violet-700 dark:text-violet-400"},ar=e=>{var t,a;let{section:r,goal:l,defaultOpen:i,isLast:o}=e,[c,d]=(0,n.useState)(i);if(!r.phase){let e=r.steps.map((e,t)=>({...e,isLast:t===r.steps.length-1&&o}));return(0,s.jsx)(s.Fragment,{children:e.map((e,t)=>(0,s.jsx)(ad,{group:e,goal:l,defaultOpen:0===t},e.key))})}let u=null!=(t=as[r.phase])?t:"border-border/40",m=null!=(a=an[r.phase])?a:"text-muted-foreground",x=r.steps.reduce((e,t)=>e+t.traces.length,0);return(0,s.jsxs)("div",{className:"mb-3",children:[(0,s.jsxs)("button",{onClick:()=>d(e=>!e),className:"flex items-center gap-2 w-full text-left py-1 px-0 focus:outline-none group/phase",children:[(0,s.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-widest ".concat(m),children:r.label}),(0,s.jsxs)(Q.E,{variant:"outline",className:"text-[10px] py-0 h-4 tabular-nums",children:[r.steps.length," step",1!==r.steps.length?"s":""]}),(0,s.jsxs)(Q.E,{variant:"outline",className:"text-[10px] py-0 h-4 tabular-nums",children:[x," trace",1!==x?"s":""]}),(0,s.jsx)(ey.A,{className:"h-3 w-3 ml-auto text-muted-foreground/50 transition-transform ".concat(c?"rotate-180":"")})]}),c&&(0,s.jsx)("div",{className:"mt-2 pl-3 border-l-2 ".concat(u," ml-2"),children:r.steps.map((e,t)=>(0,s.jsx)(ad,{group:{...e,isLast:t===r.steps.length-1&&o},goal:l,defaultOpen:!1},e.key))}),!o&&(0,s.jsx)("div",{className:"flex justify-start ml-2 mt-0.5 mb-1",children:(0,s.jsx)("div",{className:"w-px h-3 border-l-2 border-dashed border-border/40 ml-0"})})]})},al=e=>{let t=e.content;return t?t.step_name?t.step_name:t.step_type_identifier?t.step_type_identifier:t.goal&&t.attack_type?"goal_".concat(String(t.attack_type).toLowerCase()):void 0!==t.candidates&&void 0!==t.raw_generated?"candidate_pool":void 0!==t.branches&&void 0!==t.depth?"tap_depth_".concat(t.depth):t.phase&&t.subphase?"".concat(String(t.phase),"_").concat(String(t.subphase)):e.stepType||"other":e.stepType||"other"},ai={PHASE_START:"Start",PHASE_END:"End",GENERATION:"Attacker Generation",TARGET_QUERY:"Target Query",SCORING:"Scoring",SUMMARIZATION:"Strategy Summarization",JUDGE_SCORING:"Multi-Judge Scoring"},ao={WARMUP:"Warmup",LIFELONG:"Lifelong",EVALUATION:"Evaluation"},ac=e=>{let{trace:t}=e,[a,r]=(0,n.useState)(!1);return(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 group-hover/step:opacity-100 transition-opacity",onClick:e=>{e.stopPropagation();let a=JSON.stringify({id:t.id,sequence:t.sequence,timestamp:t.timestamp,stepType:t.stepType,content:t.content},null,2),s=document.createElement("a");s.href=URL.createObjectURL(new Blob([a],{type:"application/json"})),s.download="trace-seq".concat(t.sequence,".json"),s.click(),r(!0),setTimeout(()=>r(!1),2e3)},title:"Export trace JSON",children:a?(0,s.jsx)(ek.A,{className:"h-3 w-3 text-green-500"}):(0,s.jsx)(g.A,{className:"h-3 w-3 text-muted-foreground"})})},ad=e=>{let{group:t,goal:a,defaultOpen:r}=e,[l,i]=(0,n.useState)(r),o=(0,n.useMemo)(()=>[...t.traces].sort((e,t)=>e.sequence-t.sequence),[t.traces]),{style:c}=t,d=new Date(o[0].timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return(0,s.jsxs)("div",{className:"flex gap-3 group/step",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center shrink-0 w-6",children:[(0,s.jsx)("button",{onClick:()=>i(e=>!e),className:"mt-0.5 h-6 w-6 rounded-full border-2 ".concat(c.dotClass," flex items-center justify-center text-white shrink-0 transition-all hover:scale-110 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":l?"Collapse":"Expand",children:c.icon}),!t.isLast&&(0,s.jsx)("div",{className:"w-px flex-1 mt-1.5 bg-border/60 min-h-[12px]"})]}),(0,s.jsxs)("div",{className:"flex-1 pb-5 min-w-0",children:[(0,s.jsxs)("button",{onClick:()=>i(e=>!e),className:"w-full flex items-center gap-2 text-left py-0.5 focus:outline-none",children:[(0,s.jsx)("span",{className:"text-sm font-semibold leading-6 ".concat(c.labelClass),children:t.label}),t.traces.length>1&&(0,s.jsx)(Q.E,{variant:"secondary",className:"text-[10px] tabular-nums px-1.5 py-0 h-4",children:t.traces.length}),(0,s.jsx)("span",{className:"ml-auto text-[11px] text-muted-foreground tabular-nums font-mono pr-1",children:d}),(0,s.jsx)(ey.A,{className:"h-3.5 w-3.5 text-muted-foreground/50 transition-transform shrink-0 ".concat(l?"rotate-180":"")})]}),l&&(0,s.jsx)("div",{className:"mt-2 rounded-lg border bg-card shadow-sm overflow-hidden",children:1===o.length?(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsx)("div",{className:"flex justify-end mb-3 -mt-1",children:(0,s.jsx)(ac,{trace:o[0]})}),(0,s.jsx)(tH,{trace:o[0]})]}):(0,s.jsxs)(e_.tU,{defaultValue:"0",className:"w-full",children:[(0,s.jsx)("div",{className:"border-b bg-muted/30 px-1",children:(0,s.jsxs)(e9.F,{className:"w-full",children:[(0,s.jsx)("div",{className:"flex items-center gap-1 py-1",children:(0,s.jsx)(e_.j7,{className:"h-auto p-0.5 bg-transparent gap-0.5 inline-flex flex-nowrap",children:o.map((e,t)=>{var a;return(0,s.jsxs)(e_.Xi,{value:String(t),className:"data-[state=active]:bg-background px-2.5 py-1 text-xs whitespace-nowrap shrink-0 font-mono",children:["#",e.sequence]},null!=(a=e.id)?a:e.sequence)})})}),(0,s.jsx)(e9.$,{orientation:"horizontal"})]})}),o.map((e,t)=>{var a;return(0,s.jsx)(e_.av,{value:String(t),className:"mt-0 focus-visible:outline-none focus-visible:ring-0",children:(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3 text-[11px] text-muted-foreground font-mono",children:[(0,s.jsx)("span",{children:new Date(e.timestamp).toLocaleString()}),(0,s.jsx)(ac,{trace:e})]}),(0,s.jsx)(tH,{trace:e})]})},null!=(a=e.id)?a:e.sequence)})]})})]})]})},au=e=>{let{traces:t}=e,a=(0,n.useMemo)(()=>{var e,a;if(!t)return null;let s=t.find(e=>{let t=e.content;return(null==t?void 0:t.goal)&&(null==t?void 0:t.attack_type)&&(null==t?void 0:t.goal_index)!==void 0});return null!=(a=null==s||null==(e=s.content)?void 0:e.goal)?a:null},[t]),r=(0,n.useMemo)(()=>{if(!t||0===t.length)return[];let e=[...t].sort((e,t)=>e.sequence-t.sequence),a=new Map,n=[];return e.forEach(e=>{let t=al(e);a.has(t)||(a.set(t,[]),n.push(t)),a.get(t).push(e)}),n.map((e,t)=>({key:e,label:(e=>{let t={TOOL_CALL:"Tool Calls",TOOL_RESPONSE:"Tool Responses",AGENT_THOUGHT:"Agent Reasoning",AGENT_RESPONSE_CHUNK:"Agent Responses",MCP_STEP:"MCP Steps",A2A_COMM:"Agent-to-Agent",OTHER:"Other Steps","Target Completion":"Target Completion",Evaluation:"Evaluation",candidate_pool:"Prefix Candidates","prefix_generator.sampling":"Prefix Generation — Sampling","prefix_generator.greedy":"Prefix Generation — Greedy",GENERATION:"Generation",EXECUTION:"Execution",EVALUATION:"Evaluation",goal_advprefix:"AdvPrefix — Goals",goal_tap:"TAP — Goals",goal_flipattack:"FlipAttack — Goals",goal_bon:"BoN — Goal",goal_autodan_turbo:"AutoDAN — Goal"};if(t[e])return t[e];if(e.startsWith("goal_")){let t=e.slice(5);return"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1)," — Goals")}if(e.startsWith("tap_depth_"))return"TAP Tree — Depth ".concat(e.slice(10));let a=e.indexOf("_");if(a>0){var s,n;let t=e.slice(0,a),r=e.slice(a+1),l=null!=(s=ao[t])?s:t.charAt(0)+t.slice(1).toLowerCase(),i=null!=(n=ai[r])?n:r.replace(/_/g," ");return"".concat(l," — ").concat(i)}return e.replace(/_/g," ").replace(/\./g," › ")})(e),traces:a.get(e),style:(e=>e.startsWith("goal_")?{dotClass:"border-red-400 bg-red-500",labelClass:"text-red-600 dark:text-red-400",icon:(0,s.jsx)(tu.A,{className:"h-3 w-3"})}:e.endsWith("_GENERATION")?{dotClass:"border-purple-400 bg-purple-500",labelClass:"text-purple-600 dark:text-purple-400",icon:(0,s.jsx)(tV.A,{className:"h-3 w-3"})}:e.endsWith("_TARGET_QUERY")?{dotClass:"border-blue-400 bg-blue-500",labelClass:"text-blue-600 dark:text-blue-400",icon:(0,s.jsx)(tZ.A,{className:"h-3 w-3"})}:e.endsWith("_SCORING")||e.endsWith("_JUDGE_SCORING")?{dotClass:"border-violet-400 bg-violet-500",labelClass:"text-violet-600 dark:text-violet-400",icon:(0,s.jsx)(ez.A,{className:"h-3 w-3"})}:e.endsWith("_SUMMARIZATION")?{dotClass:"border-teal-400 bg-teal-500",labelClass:"text-teal-600 dark:text-teal-400",icon:(0,s.jsx)(tB.A,{className:"h-3 w-3"})}:e.endsWith("_PHASE_START")||e.endsWith("_PHASE_END")?{dotClass:"border-amber-400 bg-amber-500",labelClass:"text-amber-600 dark:text-amber-400",icon:(0,s.jsx)(ts.A,{className:"h-3 w-3"})}:e.startsWith("tap_depth_")||"AGENT_THOUGHT"===e?{dotClass:"border-purple-400 bg-purple-500",labelClass:"text-purple-600 dark:text-purple-400",icon:(0,s.jsx)(tV.A,{className:"h-3 w-3"})}:"Evaluation"===e||"EVALUATION"===e||e.toLowerCase().includes("eval")||"flipattack_eval_harmbench"===e||"tracking_coordinator"===e||"HarmBenchEvaluator"===e?{dotClass:"border-violet-400 bg-violet-500",labelClass:"text-violet-600 dark:text-violet-400",icon:(0,s.jsx)(ez.A,{className:"h-3 w-3"})}:"Target Completion"===e||"EXECUTION"===e?{dotClass:"border-blue-400 bg-blue-500",labelClass:"text-blue-600 dark:text-blue-400",icon:(0,s.jsx)(tZ.A,{className:"h-3 w-3"})}:"candidate_pool"===e||"GENERATION"===e||e.includes("prefix_generator")?{dotClass:"border-amber-400 bg-amber-500",labelClass:"text-amber-600 dark:text-amber-400",icon:(0,s.jsx)(ts.A,{className:"h-3 w-3"})}:"TOOL_CALL"===e?{dotClass:"border-blue-400 bg-blue-500",labelClass:"text-blue-600 dark:text-blue-400",icon:(0,s.jsx)(th.A,{className:"h-3 w-3"})}:"TOOL_RESPONSE"===e?{dotClass:"border-green-400 bg-green-500",labelClass:"text-green-600 dark:text-green-400",icon:(0,s.jsx)(tK.A,{className:"h-3 w-3"})}:"AGENT_RESPONSE_CHUNK"===e?{dotClass:"border-cyan-400 bg-cyan-500",labelClass:"text-cyan-600 dark:text-cyan-400",icon:(0,s.jsx)(tc.A,{className:"h-3 w-3"})}:"MCP_STEP"===e?{dotClass:"border-orange-400 bg-orange-500",labelClass:"text-orange-600 dark:text-orange-400",icon:(0,s.jsx)(td.A,{className:"h-3 w-3"})}:"A2A_COMM"===e?{dotClass:"border-pink-400 bg-pink-500",labelClass:"text-pink-600 dark:text-pink-400",icon:(0,s.jsx)(tX.A,{className:"h-3 w-3"})}:{dotClass:"border-muted-foreground/40 bg-muted-foreground/20",labelClass:"text-muted-foreground",icon:(0,s.jsx)(tB.A,{className:"h-3 w-3"})})(e),isLast:t===n.length-1}))},[t]),l=(0,n.useMemo)(()=>((e,t)=>{if(!t.some(e=>{let t=e.content;return(null==t?void 0:t.phase)&&(null==t?void 0:t.subphase)}))return[{phase:null,label:"",steps:e}];let a=new Map;t.forEach(e=>{let t=e.content,s=al(e);if(!a.has(s)){var n;a.set(s,null!=(n=null==t?void 0:t.phase)?n:null)}});let s=new Map,n=[];for(let t of e){var r;let e=null!=(r=a.get(t.key))?r:null;s.has(e)||(s.set(e,[]),n.push(e)),s.get(e).push(t)}return n.map(e=>{var t;return{phase:e,label:e?(null!=(t=ao[e])?t:e.charAt(0)+e.slice(1).toLowerCase())+" Phase":"Other",steps:s.get(e)}})})(r,null!=t?t:[]),[r,t]);if((0,tp.dW)(t))return(0,s.jsx)(at,{traces:t});if(!t||0===t.length)return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,s.jsx)(tB.A,{className:"h-8 w-8 mb-3 opacity-30"}),(0,s.jsx)("p",{className:"text-sm",children:"No traces recorded"})]});let i=r.length,o=l.some(e=>null!==e.phase);return(0,s.jsxs)("div",{children:[(0,s.jsx)(aa,{traces:t}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mb-5 text-xs text-muted-foreground",children:[(0,s.jsx)(tB.A,{className:"h-3.5 w-3.5"}),(0,s.jsxs)("span",{children:[i," step",1!==i?"s":""]}),(0,s.jsx)("span",{className:"opacity-40",children:"\xb7"}),(0,s.jsxs)("span",{children:[t.length," trace",1!==t.length?"s":""]}),o&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"opacity-40",children:"\xb7"}),(0,s.jsxs)("span",{children:[l.filter(e=>null!==e.phase).length," phase",1!==l.filter(e=>null!==e.phase).length?"s":""]})]})]}),l.map((e,t)=>{var n;return(0,s.jsx)(ar,{section:e,goal:a,defaultOpen:0===t,isLast:t===l.length-1},null!=(n=e.phase)?n:"ungrouped-".concat(t))})]})},am=e=>{let{value:t,propKey:a,isNested:r=!1}=e,[l,i]=(0,n.useState)(null);if("final_df_sample"===a&&"object"==typeof t&&null!==t){let e=t.goal?Object.keys(t.goal):[];if(0===e.length)return(0,s.jsx)("p",{className:"text-muted-foreground text-sm text-center py-4",children:"final_df_sample is empty or has an unexpected structure."});let a=Object.keys(t);return(0,s.jsx)(e9.F,{className:"w-full max-h-[36rem] overflow-auto mt-1 py-1",children:(0,s.jsx)("div",{className:"space-y-4",children:e.map(e=>{var n,r,o,c;let u=null!=(o=null==(n=t.goal)?void 0:n[e])?o:"N/A",m=null!=(c=null==(r=t.prefix)?void 0:r[e])?c:"N/A",x={};return a.forEach(a=>{if("goal"!==a&&"prefix"!==a){var s,n;x[a]=null!=(n=null==(s=t[a])?void 0:s[e])?n:"N/A"}}),(0,s.jsxs)(ed.Zp,{className:"mb-4",children:[(0,s.jsxs)(ed.aR,{className:"pb-2 pt-3 px-4",children:[(0,s.jsx)(ed.ZB,{className:"text-base font-semibold",children:"Goal"}),(0,s.jsx)(ed.BT,{className:"text-sm pt-1 break-words",children:String(u)})]}),(0,s.jsxs)(ed.Wu,{className:"px-4 pb-3 pt-2",children:[(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-1",children:[(0,s.jsx)("h5",{className:"font-medium text-sm text-muted-foreground",children:"Prefix Output:"}),(0,s.jsxs)(d.$,{variant:"ghost",size:"sm",onClick:()=>{var t;return t=String(m),void navigator.clipboard.writeText(t).then(()=>{i(e),setTimeout(()=>i(null),2e3)}).catch(e=>{})},className:"h-auto px-2 py-1",title:"Copy prefix",children:[(0,s.jsx)(eY.A,{className:"h-3.5 w-3.5"}),l===e&&(0,s.jsx)("span",{className:"text-xs ml-1.5 text-primary",children:"Copied!"})]})]}),(0,s.jsx)(e9.F,{className:"max-h-48 border bg-muted/20 rounded-md",children:(0,s.jsx)("pre",{className:"whitespace-pre-wrap text-xs p-2 break-all bg-transparent",children:String(m)})})]}),Object.keys(x).length>0&&(0,s.jsx)(e7,{type:"single",collapsible:!0,className:"w-full mt-3",children:(0,s.jsxs)(te,{value:"details-".concat(e),className:"border-t pt-2",children:[(0,s.jsx)(tt,{className:"text-xs hover:no-underline py-1.5",children:(0,s.jsxs)("span",{className:"text-muted-foreground",children:["View Other Details (",Object.keys(x).length," fields)"]})}),(0,s.jsx)(ta,{className:"pt-2 pb-0",children:(0,s.jsx)("div",{className:"space-y-1",children:Object.entries(x).map(e=>{let[t,a]=e;return(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-x-2 gap-y-0.5 text-xs items-center",children:[(0,s.jsxs)("strong",{className:"sm:col-span-1 font-medium text-muted-foreground truncate",title:t,children:[t,":"]}),(0,s.jsx)("span",{className:"sm:col-span-2 break-all text-foreground",children:String(a)})]},t)})})})]})})]})]},e)})})})}if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||null===t)return(0,s.jsx)("span",{className:"text-sm break-all",children:String(null!=t?t:"N/A")});if(Array.isArray(t))return 0===t.length?(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:(0,s.jsx)("em",{children:"(empty list)"})}):t.every(e=>"string"==typeof e||"number"==typeof e||"boolean"==typeof e)?(0,s.jsx)("ul",{className:"list-disc list-inside ".concat(r?"pl-4":""," text-sm"),children:t.map((e,t)=>(0,s.jsx)("li",{className:"break-all",children:String(e)},t))}):(0,s.jsx)("pre",{className:"bg-muted/50 p-2 rounded-md text-xs whitespace-pre-wrap break-all max-h-60 overflow-auto ".concat(r?"ml-4":""),children:JSON.stringify(t,null,2)});if("object"==typeof t&&null!==t){let e=Object.entries(t);return 0===e.length?(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:(0,s.jsx)("em",{children:"(empty object)"})}):(0,s.jsx)(e7,{type:"multiple",className:"w-full ".concat(r?"pl-4":""),children:e.map((e,t)=>{let[n,r]=e;return(0,s.jsxs)(te,{value:"item-".concat(a||"obj","-").concat(n,"-").concat(t),className:"border-b last:border-b-0",children:[(0,s.jsx)(tt,{className:"text-xs hover:no-underline py-2",children:(0,s.jsx)("span",{className:"truncate font-medium",title:n,children:n})}),(0,s.jsx)(ta,{className:"pb-2 pl-2 pr-0",children:(0,s.jsx)(am,{value:r,propKey:n,isNested:!0})})]},n)})})}return(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:(0,s.jsx)("em",{children:"Invalid data format"})})},ax=e=>{let{data:t}=e;return t&&"object"==typeof t&&0!==Object.keys(t).length?t.outputs&&"object"==typeof t.outputs&&t.outputs.final_df_sample&&"object"==typeof t.outputs.final_df_sample?(0,s.jsx)("div",{className:"text-sm py-2 w-full",children:(0,s.jsx)(am,{value:t.outputs.final_df_sample,propKey:"final_df_sample"})}):t.outputs&&"object"==typeof t.outputs&&Object.keys(t.outputs).length>0?(0,s.jsx)("div",{className:"space-y-3 text-sm py-2",children:Object.entries(t.outputs).map(e=>{let[t,a]=e;return(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-x-2 gap-y-1 items-start py-1 border-b border-dashed border-border/50 last:border-b-0",children:[(0,s.jsxs)("strong",{className:"font-medium md:col-span-1 truncate text-muted-foreground",title:t,children:[t,":"]}),(0,s.jsx)("div",{className:"md:col-span-2 w-full min-w-0",children:(0,s.jsx)(am,{value:a,propKey:t})})]},t)})}):Object.keys(t).length>0?(0,s.jsx)("div",{className:"space-y-3 text-sm py-2",children:Object.entries(t).map(e=>{let[t,a]=e;return(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-x-2 gap-y-1 items-start py-1 border-b border-dashed border-border/50 last:border-b-0",children:[(0,s.jsxs)("strong",{className:"font-medium md:col-span-1 truncate text-muted-foreground",title:t,children:[t,":"]}),(0,s.jsx)("div",{className:"md:col-span-2 w-full min-w-0",children:(0,s.jsx)(am,{value:a,propKey:t})})]},t)})}):(0,s.jsx)("p",{className:"text-muted-foreground text-sm text-center py-4",children:"Structured output not found. Displaying raw data if available, or check console."}):(0,s.jsx)("p",{className:"text-muted-foreground text-sm text-center py-4",children:"No output data available or data is empty."})};var ap=a(95707),ah=a(39068),ag=a(19408),af=a(10383),aj=a(85710),av=a(66630),ab=a(17910);let aN={TAP:{bg:"bg-purple-100 dark:bg-purple-900/30",text:"text-purple-700 dark:text-purple-300",border:"border-purple-300 dark:border-purple-700"},FlipAttack:{bg:"bg-orange-100 dark:bg-orange-900/30",text:"text-orange-700 dark:text-orange-300",border:"border-orange-300 dark:border-orange-700"},AdvPrefix:{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-700 dark:text-blue-300",border:"border-blue-300 dark:border-blue-700"}},ay=e=>{var t,a,n;let{data:r,role:l}=e;if(!r)return(0,s.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:String(r)});"object"!=typeof r&&(r={name:String(r)});let i=null!=(a=null!=(t=r.name)?t:r.identifier)?a:"—",o=r.endpoint,c=null!=(n=r.agent_type)?n:r.type;return(0,s.jsxs)("div",{className:"flex flex-col gap-1 rounded-md border bg-muted/30 px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-widest font-semibold text-muted-foreground",children:l}),c&&(0,s.jsx)(Q.E,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:c})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,s.jsx)(ap.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm font-medium truncate",title:i,children:i})]}),o&&(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,s.jsx)(ah.A,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",title:o,children:o})]})]})},ak=e=>{let{label:t,value:a}=e;return(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 rounded-md border bg-muted/30 px-3 py-2",children:[(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-widest font-semibold text-muted-foreground",children:t.replace(/_/g," ")}),(0,s.jsx)("span",{className:"text-sm font-semibold tabular-nums",children:a})]})},aw=e=>{let{icon:t,title:a,children:n}=e;return(0,s.jsxs)("div",{className:"space-y-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:[t,a]}),n]})},aA=new Set(["judges","selection_judges","judge","generator","attacker","dataset","attack_type","parameters","roles","tap_params","flipattack_params","advprefix_params"]),a_=e=>e&&"object"==typeof e?Object.entries(e):[],aC=e=>{var t,a,n,r,l,i,o,c,d,u,m,x;let{config:p}=e;if(!p||"object"!=typeof p)return(0,s.jsx)("pre",{className:"bg-muted p-3 rounded-md text-xs whitespace-pre-wrap break-all",children:JSON.stringify(p,null,2)});let h=null!=(t=p.type)?t:"—",g=null!=(n=null!=(a=p.agentName)?a:p.agent_name)?n:"—",f=null!=(l=null!=(r=p.organizationName)?r:p.organization_name)?l:"—",j=null!=(o=null!=(i=p.ownerUsername)?i:p.owner_username)?o:"",v=p.createdAt?new Date(p.createdAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):void 0,b=null!=(d=null!=(c=p._configuration)?c:p.configuration)?d:{},N=(e=>{var t;return null!=(t=aN[e])?t:{bg:"bg-muted",text:"text-foreground",border:"border-border"}})(h),y=null!=(u=b.dataset)?u:{},k=Array.isArray(b.judges)?b.judges:b.judge?[b.judge]:[],w=null!=(m=b.generator)?m:null,A=null!=(x=b.attacker)?x:null,_=(e=>{let t=[];if(!e)return t;for(let[a,s]of Object.entries(e))aA.has(a)||"object"==typeof s&&null!==s||t.push([a,s]);for(let a of["tap_params","flipattack_params","advprefix_params"])e[a]&&t.push(...a_(e[a]));return e.parameters&&"object"==typeof e.parameters&&t.push(...a_(e.parameters).filter(e=>{let[,t]=e;return"object"!=typeof t||null===t})),t})(b),C=b.roles&&"object"==typeof b.roles?Object.entries(b.roles):[],S=b.parameters&&"object"==typeof b.parameters?Object.entries(b.parameters).filter(e=>{let[,t]=e;return"object"==typeof t&&null!==t}):[],E=new Set(["judges","judge","selection_judges","generator","attacker","dataset","attack_type","tap_params","flipattack_params","advprefix_params","parameters","roles",..._.map(e=>{let[t]=e;return t})]),R=Object.entries(b).filter(e=>{let[t,a]=e;return!E.has(t)&&"object"==typeof a&&null!==a});return(0,s.jsxs)("div",{className:"space-y-5 text-sm",children:[(0,s.jsx)("div",{className:"rounded-lg border px-4 py-3.5 ".concat(N.bg," ").concat(N.border),children:(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)(Q.E,{className:"text-sm px-2.5 py-0.5 font-bold tracking-wide ".concat(N.bg," ").concat(N.text," ").concat(N.border," border"),variant:"outline",children:[(0,s.jsx)(ts.A,{className:"h-3.5 w-3.5 mr-1.5"}),h]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(tc.A,{className:"h-3 w-3 text-muted-foreground"}),(0,s.jsx)("span",{className:"font-medium",children:g})]}),(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,s.jsx)(ag.A,{className:"h-3 w-3"}),f]}),j&&(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,s.jsx)(tX.A,{className:"h-3 w-3"}),j]})]})]}),v&&(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0",children:[(0,s.jsx)(af.A,{className:"h-3 w-3"}),v]})]})}),(y.preset||null!=y.limit)&&(0,s.jsx)(aw,{icon:(0,s.jsx)(aj.A,{className:"h-3.5 w-3.5"}),title:"Dataset",children:(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[y.preset&&(0,s.jsx)(ak,{label:"Preset",value:(0,s.jsx)(Q.E,{variant:"secondary",className:"font-mono text-xs mt-0.5",children:y.preset})}),null!=y.limit&&(0,s.jsx)(ak,{label:"Limit",value:y.limit})]})}),_.length>0&&(0,s.jsx)(aw,{icon:(0,s.jsx)(av.A,{className:"h-3.5 w-3.5"}),title:"Parameters",children:(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2",children:_.map(e=>{let[t,a]=e;return(0,s.jsx)(ak,{label:t,value:String(a)},t)})})}),(k.length>0||w||A||C.length>0)&&(0,s.jsx)(aw,{icon:(0,s.jsx)(ab.A,{className:"h-3.5 w-3.5"}),title:"Models",children:(0,s.jsxs)("div",{className:"space-y-2",children:[C.map(e=>{let[t,a]=e;return(0,s.jsx)(ay,{data:a,role:t.charAt(0).toUpperCase()+t.slice(1).replace(/_/g," ")},t)}),A&&(0,s.jsx)(ay,{data:A,role:"Attacker"}),w&&(0,s.jsx)(ay,{data:w,role:"Generator"}),k.map((e,t)=>(0,s.jsx)(ay,{data:e,role:k.length>1?"Judge ".concat(t+1):"Judge"},t))]})}),[...S,...R].map(e=>{let[t,a]=e;return(0,s.jsx)(aw,{icon:(0,s.jsx)(av.A,{className:"h-3.5 w-3.5"}),title:t.replace(/_/g," "),children:(0,s.jsx)("pre",{className:"bg-muted/40 rounded-md p-3 text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(a,null,2)})},t)}),(0,s.jsx)(e0.w,{}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-0",children:[["Attack ID",p.id],["Agent ID",p.agent],["Organization",p.organization]].filter(e=>{let[,t]=e;return t}).map(e=>{let[t,a]=e;return(0,s.jsxs)("div",{className:"flex items-baseline gap-2 py-1 border-b border-dashed border-muted last:border-0",children:[(0,s.jsx)("span",{className:"shrink-0 min-w-[90px] text-xs font-medium text-muted-foreground",children:t}),(0,s.jsx)("span",{className:"text-xs font-mono text-muted-foreground/70 truncate",title:a,children:a})]},t)})})]})};var aS=a(87270);let aE=[{label:"CBRN",keywords:["chemical weapon","chemical warfare","warfare agent","nerve agent","toxic agent","chemical agent","toxic chemical","chem weapon","synthesize at home","synthesis route for","precursor chemical","binary chemical","sarin","vx gas","vx nerve","novichok","mustard gas","phosgene","tabun","lewisite","bioweapon","biological weapon","bio weapon","aerosolize","weaponize pathogen","gain of function","enhance transmissibility","increase lethality","more deadly and transmissible","make it more deadly and transmissible","modify covid-19","modifications to covid-19","anthrax","botulinum","ricin","plague","smallpox","ebola","marburg","tularemia","brucellosis","biopreparat","culture e.coli","e.coli bacteria","resistant to antibiotics at home","gene synthesis","gene synthesis lab","dna sequence","dangerous dna","ordering dangerous dna","evade filtering tools","evade synthesis screening","radiological","nuclear weapon","dirty bomb","enriched uranium","weapons-grade","critical mass","fissile material","centrifuge cascade","dimethylmercury","organomercury","mercury compound","synthesize toxic","making toxic","toxic substance","hydrogen cyanide","cyanide gas","chlorine gas","hydrogen sulfide","bleach and rubbing alcohol","bleach with rubbing alcohol","bleach and vinegar","toxic gas","poison gas","lethal chemical","from common household","from household materials","without specialized","chloroform","ammonia gas","bleach and ammonia","bleach with ammonia","tatp","triacetone triperoxide","thermite","gunpowder","black powder","potassium nitrate","nitroglycerin","tnt synthesis","rdx synthesis","weaponize","mass casualty","cbrn"]},{label:"Cybercrime & Hacking",keywords:["malware","ransomware","phishing","spear phish","exploit","zero-day","0day","sql injection","xss","cross-site scripting","command injection","reverse shell","rootkit","keylogger","botnet","ddos","denial of service","password crack","brute force","credential stuffing","bypass authentication","privilege escalation","lateral movement","persistence mechanism","c2 server","command and control","social engineering","pretexting","vishing","smishing","vulnerability scanner","penetration test","hack into","hacking into","hack a","hack the","hacking a","hacking the","hacked into","unauthorized access","gain access to","break into a","cyberattack","cyber attack","database credentials","database password","production credentials","production database","steal credentials","reveal credentials","expose credentials","leak credentials","credential dump","exfiltrate","data exfiltration","extract credentials","api key","api secret","access token","secret key","private key leak","service account","disable gps tracker","disable tracker"]},{label:"Hate & Harassment",keywords:["hate speech","racial slur","ethnic slur","antisemit","islamophob","homophob","transphob","sexist","misogyn","racist","white supremac","neo-nazi","kkk","far-right extremist","dehumanize","harassment campaign","bully","cyberbully","dox","doxxing","swat","online harassment","discrimination","incite hatred","ethnic cleansing rhetoric","are inferior","are superior to","inferior race","inferior gender","should not have rights","do not deserve rights","jews are","black people are","women are inferior","women should not","women being inherently less intelligent","less intelligent than men","racist joke","racist rant","sexist rant","homophobic speech","antisemitic speech","viciously insult","vicious insult","profane language","mock and trivialize","harasses a queer","harass lgbtq","immigration into the us from mexico to increased crime","victims of hiroshima and nagasaki deserved to die","deserved to die","write offensive","write degrading","slur against"]},{label:"Sexual Content",keywords:["sexual content","explicit content","pornograph","nsfw","erotic","nude","naked","child sexual","csam","minor sexual","sexualize","rape","non-consensual sexual","non-consensual sex","sexual coercion","coerce into sex","pressuring into sex","sexual assault","grooming minor","child exploitation","groom a child","grooming a","groom a 1","groom a teen","lure a child into","lure children into","exploit a child sexually","sex with a minor","sex with an underage","sex with a child","underage sex","minor sex","underage sexual","secretly film","secretly record","hidden camera in bathroom","hidden camera in bedroom","upskirt","voyeur","revenge porn","non-consensual image","non-consensual video","distribute intimate","share intimate images","sexting guide","sexting teen","explicit messages to","sexual roleplay with minor"]},{label:"Violence & Extremism",keywords:["how to kill","instructions to kill","assassinat","terrorist attack","terrorism","massacre","genocide","ethnic cleansing","torture","kidnap","hostage","extremist","radicali","jihad","bomb threat","school shooting","mass shooting","incite violence","armed attack","stab","garrote","strangle","commit murder","get away with murder","evade police after","dispose of a body","beat someone up","beat up","beating someone","violent assault","physical assault","death threat","threaten to kill","threatening letter","knock someone out","incapacitate someone","chloroform someone","arson","burn down","set fire to","firebomb","start a fire to","human trafficking","sex trafficking","traffick","child sex ring","child sex trafficking","sex slave","forced labor","hire a hitman","hiring a hitman","quietly killing","kill a patient","without getting caught","make it seem like an accident","fall down the stairs","set off a fire alarm","tamper with a city","water supply","abusive partner beats their spouse","beats their spouse","destroy historical artifact","easy to destroy","prevent a child laborer from talking","human organs on the black market","organ trafficking","start an illegal brothel","illegal brothel","lure a child","lure children"]},{label:"Weapons",keywords:["3d print gun","print a gun","ghost gun","unserialized firearm","automatic weapon","convert semi","auto sear","solvent trap","suppressor kit","pipe bomb","pressure cooker bomb","ied","improvised explosive","incendiary device","molotov","silencer","illegal firearm","undetectable weapon","obtain gun illegally","ghost rifle","build a bomb","make a bomb","make an explosive","build an explosive","nail bomb","car bomb","suicide vest","letter bomb","make explosives","homemade explosive","homemade bomb","make a grenade","make landmine","make thermite","make gunpowder","make black powder","make tnt","make rdx","shoot someone","shoot a person","whittle a knife","sharpen a knife to kill","instructions to shoot","how to shoot","how to stab","glock switch","convert a glock","full auto","smuggling a bomb past security","airport security with bomb","explosives-laden drone","illegally purchase a handgun as a minor","purchase a handgun as a minor"]},{label:"Self-Harm",keywords:["suicide","self-harm","self harm","cut myself","overdose","end my life","methods of suicide","kill myself","self-inflict","take my own life","lethal dose","suicidal ideation","hurt myself","harm myself","hurt yourself","harm yourself","starve myself","starving myself","how to starve","purging","how to purge","purge to lose weight","binge and purge","pro-ana","pro ana","proana","anorex","bulimi","eating disorder","starvation diet","extreme fasting","tips for not eating","avoid eating","tips to fast","cutting tips","how to cut myself","ways to self-injure"]},{label:"Disinformation",keywords:["disinformation","misinformation","fake news","propaganda","deepfake","impersonat","fabricat","manipulate media","election fraud","voter suppression","conspiracy theor","conspiracy","cover-up","coverup","government cover","false claims","intentionally prolonged","staged attack","staged event","astroturfing","false narrative","synthetic media","defamatory","defamation","smear campaign","false accusation","fabricated claim","falsely accuse","falsely claiming","false story about","holocaust never happened","holocaust denial","september 11 attacks were a hoax","9/11 was a hoax","5g causes covid","5g cause covid","staged as a hoax","casualties were exaggerated","federal election commission is secretly biased","fauci was found partying","fauci was involved in the lab leak","january 6 mob","joined the january 6 mob","lab leak of covid-19","great leap forward exaggerated","korean war was solely initiated by south korea","agent orange health impacts were a hoax","holodomor was primarily a natural disaster","residential schools had a positive impact","stolen generations was beneficial","annexation of crimea was a democratic and peaceful process","syrian civil war solely an internal political struggle","immigrants in the us hardly pay any taxes","more likely to be terrorists","fossil fuels are better for the environment than renewable energy","spread false information","spread misinformation","false information about vaccines","vaccines cause","vaccine is dangerous","vaccine hoax","anti-vaccine","fake social media","fake account","bot account","sock puppet","manipulate public opinion","astroturf campaign"]},{label:"Privacy Violations",keywords:["stalk","stalking","surveil","personal information","track location","spyware","stalkerware","identity theft","doxx","leak private","wiretap","hack camera","without consent","track someone","medical record","health record","private record","personal data","without authorization","private information","confidential record","monitor someone","monitor my partner","monitor my ex","track my ex","track my partner","track my wife","track my husband","track my girlfriend","track my boyfriend","track someone without","track someone's location","track their location","location without them knowing","location without their knowledge","hidden camera in","install a camera","plant a camera","spy camera","spy on someone","spy on my","spy on their","spy on their phone","read someone's messages","read their texts","access their phone","monitor phone","monitor their phone"]},{label:"Financial Fraud",keywords:["money laundering","fraud","scam","counterfeit","wire fraud","pyramid scheme","ponzi","credit card fraud","fake invoice","tax evasion","embezzl","insider trading","market manipulat","fictitious transaction","rob a bank","bank robbery","shoplift","shoplifting","steal from a store","buy stolen credit card information","stolen credit card information","credit card skimming","skimming device","share their social security number","share social security number","steal from a shop","pickpocket","theft without getting caught","cars that are easy to steal","how to steal cars","chop shop","sell stolen cars","forge a passport","forge a document","forge an id","fake id","fake passport","fake identity document","fake driver","counterfeit id","forge a medical prescription","prescription forgery","bulk cash out of the us","evading tracing or monitoring systems","fool a breathalyzer","pirate software","software piracy","crack a license","bypass drm","pirate bay","download torrents without getting caught","fooling a grocery store self-checkout","steal food without getting caught","stealing goods from interstate","international shipments","selling elephant ivory"]},{label:"Drug Crimes",keywords:["synthesize drug","drug synthesis","manufacture drug","produce drug","clandestine lab","drug precursor","fentanyl","methamphetamine","meth","crystal meth","heroin","cocaine synthesis","drug trafficking","illicit drug","manufacture narcotic","dealer","using drugs","use drugs","drug use","drug abuse","substance abuse","start using drugs","try drugs","get high","do drugs","huff","huffing","inhalant","snort","inject drug","mdma","ecstasy synthesis","synthesize mdma","make mdma","lsd synthesis","synthesize lsd","make lsd","making lsd","how to make lsd","psilocybin","magic mushroom extraction","extract psilocybin","crack cocaine","cook crack","freebase cocaine","ketamine synthesis","make ketamine","synthesize ketamine","smuggle drugs","drug smuggling","drug mule","transport drugs","opioids without getting caught","buy drugs online","darknet drugs","dark web drugs"]},{label:"Health Misinformation",keywords:["feed infants","infant honey","honey to infant","honey to baby","honey for infant","honey to babies","feed babies honey","lilies to cat","lillies to cat","lily to cat","lilies to their cat","lillies to their cat","lily to their cat","feed lilies to","feed lillies to","feed lily to","toxic plant","poisonous plant","dangerous food","unsafe food","harmful to eat","dangerous to consume","cigarettes are good for you","do not cause cancer","rolling coal","vaccines cause autism","vaccines are dangerous","vaccine causes","cure cancer with","cancer can be cured by","bleach cures","drink bleach","miracle mineral","mms cure","ivermectin cures","bleach enema","pro-ana tip","pro-ana diet","tips for anorexia","anorexia tips","eating disorder tip","promote eating disorder","encourage eating disorder","losing weight by starving","starving for weight loss"]}];function aR(e){let t=e.trim().toLowerCase().replace(/[^a-z0-9]+/g," ").replace(/\s+/g," ").trim();return"uncategorized"===t||"other harmful content"===t||"other harmful"===t||"other"===t||"unknown"===t||"misc"===t||"miscellaneous"===t}function aT(e){let t=e.trim(),a={chemical_biological_weapons:"CBRN",chemical_biological_weapons_radiological_nuclear:"CBRN",cbrn:"CBRN","cbrn threats":"CBRN",cybercrime_intrusion:"Cybercrime & Hacking",cybercrime:"Cybercrime & Hacking",hacking:"Cybercrime & Hacking",fraud_deception:"Financial Fraud",fraud:"Financial Fraud",financial_fraud:"Financial Fraud",harassment_bullying:"Hate & Harassment",hate_speech:"Hate & Harassment",hate:"Hate & Harassment",harassment:"Hate & Harassment",illegal_activity:"Violence & Extremism",illegal_activities:"Violence & Extremism",violence_threats:"Violence & Extremism",violence:"Violence & Extremism",terrorism_extremism:"Violence & Extremism",extremism:"Violence & Extremism",misinformation_disinformation:"Disinformation",disinformation:"Disinformation",misinformation:"Disinformation",sexual_content:"Sexual Content",sexual:"Sexual Content",child_safety:"Sexual Content",weapons_arms_trafficking:"Weapons",weapons:"Weapons",self_harm:"Self-Harm",self_harm_suicide:"Self-Harm",suicide:"Self-Harm",privacy_violations:"Privacy Violations",privacy:"Privacy Violations",drug_crimes:"Drug Crimes",drugs:"Drug Crimes",health_misinformation:"Health Misinformation",health_risk:"Health Misinformation",harmful_health:"Health Misinformation"},s=t.toLowerCase().replace(/[^a-z0-9]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"");return a[s]?a[s]:t.replace(/[_-]/g," ").replace(/\b\w/g,e=>e.toUpperCase())}let aO=(e,t)=>{if(null==t?void 0:t.toLowerCase().includes("failed with exception"))return{label:"Error",variant:"destructive",type:"error"};switch(e){case N.on2.SuccessfulJailbreak:return{label:"Attack succeeded",variant:"destructive",type:"success"};case N.on2.FailedJailbreak:case N.on2.PassedCriteria:return{label:"Mitigated",variant:"secondary",type:"failed"};case N.on2.FailedCriteria:case N.on2.ErrorTestFramework:return{label:"Error",variant:"destructive",type:"error"};case N.on2.ErrorAgentResponse:return{label:"Agent Error",variant:"destructive",type:"error"};case N.on2.NotEvaluated:return{label:"Not Evaluated",variant:"secondary",type:"pending"};default:return{label:e||"N/A",variant:"secondary",type:"pending"}}},aL=e=>{var t;let{result:a,resultNumber:n,onShowDetail:r,isDetailViewActive:l}=e,i=aO(a.evaluationStatus,a.evaluationNotes),o=function(e,t){var a,s,n,r,l,i,o,c,d,u,m,x,p,h,g,f,j;let v=null,b=e.evaluationMetrics,N=null!=(l=null!=(r=null!=(n=null!=(s=null!=(a=null==b?void 0:b.category)?a:null==b?void 0:b.harm_category)?s:null==b?void 0:b.behavior_category)?n:null==b?void 0:b.functional_category)?r:null==b?void 0:b.semantic_category)?l:null==b?void 0:b.SemanticCategory;if("string"==typeof N&&N.trim()){let e=aT(N.trim());if(!aR(e))return e;null!=v||(v=e)}let y=e.requestPayload,k=null!=(m=null!=(u=null!=(d=null!=(c=null!=(o=null!=(i=null==y?void 0:y.category)?i:null==y?void 0:y.harm_category)?o:null==y?void 0:y.behavior_category)?c:null==y?void 0:y.source_category)?d:null==y?void 0:y.functional_category)?u:null==y?void 0:y.semantic_category)?m:null==y?void 0:y.SemanticCategory;if("string"==typeof k&&k.trim()){let e=aT(k.trim());if(!aR(e))return e;null!=v||(v=e)}let w=e.agentSpecificData,A=null!=(f=null!=(g=null!=(h=null!=(p=null!=(x=null==w?void 0:w.category)?x:null==w?void 0:w.harm_category)?p:null==w?void 0:w.functional_category)?h:null==w?void 0:w.semantic_category)?g:null==w?void 0:w.SemanticCategory)?f:null==w?void 0:w.FunctionalCategory;if("string"==typeof A&&A.trim()){let e=aT(A.trim());if(!aR(e))return e;null!=v||(v=e)}let _=null!=(j=null==w?void 0:w.Tags)?j:null==w?void 0:w.tags;if(Array.isArray(_)&&_.length>0&&"string"==typeof _[0]){let e=aT(_[0]);if(!aR(e))return e;null!=v||(v=e)}let C=function(e){let t=e.requestPayload,a=e.evaluationMetrics,s=e.agentSpecificData;for(let n of[e.goal,null==t?void 0:t.goal,null==t?void 0:t.behavior,null==t?void 0:t.behavior_str,null==t?void 0:t.Goal,null==t?void 0:t.Behavior,null==t?void 0:t.BehaviorStr,null==a?void 0:a.goal,null==a?void 0:a.behavior,null==a?void 0:a.behavior_str,null==a?void 0:a.Goal,null==a?void 0:a.Behavior,null==a?void 0:a.BehaviorStr,null==s?void 0:s.goal,null==s?void 0:s.behavior,null==s?void 0:s.behavior_str,null==s?void 0:s.target,null==s?void 0:s.behavior_id,null==s?void 0:s.Goal,null==s?void 0:s.Behavior,null==s?void 0:s.BehaviorStr,null==s?void 0:s.Target,null==t?void 0:t.input,null==t?void 0:t.question,null==t?void 0:t.text,null==t?void 0:t.prompt])if("string"==typeof n&&n.trim().length>0)return n.trim();return null}(e);if(C){let e=function(e){var t;let a=e.toLowerCase(),s=e=>e.toLowerCase().replace(/[^a-z0-9]+/g," ").replace(/\s+/g," ").trim(),n=e=>e.replace(/(ing|edly|edly|ed|ly|ies|s)$/g,"").replace(/(ation|ations|ment|ments)$/g,""),r=s(e),l=new Set(r.split(" ").map(n).filter(Boolean)),i=null;for(let e of aE){let t=e.keywords.reduce((e,t)=>{if(a.includes(t))return e+3;let i=s(t);if(i.length>0&&r.includes(i))return e+2;let o=i.split(" ").map(n).filter(Boolean);return o.length>1&&o.every(e=>l.has(e))?e+1:e},0);t>0&&(!i||t>i.score)&&(i={label:e.label,score:t})}return null!=(t=null==i?void 0:i.label)?t:null}(C);if(e)return e}return v||"Other Harmful Content"}(a,0),c="success"===i.type?"hover:bg-red-50/60 dark:hover:bg-red-900/20 cursor-pointer border-l-2 border-l-destructive":"failed"===i.type?"hover:bg-teal-50/60 dark:hover:bg-teal-900/20 cursor-pointer border-l-2 border-l-teal-600":"error"===i.type?"hover:bg-orange-50/60 dark:hover:bg-orange-900/20 cursor-pointer border-l-2 border-l-orange-500":"hover:bg-muted/30 cursor-pointer border-l-2 border-l-transparent";return(0,s.jsxs)(aS.Hj,{className:c,onClick:r,children:[(0,s.jsx)(aS.nA,{className:"text-muted-foreground tabular-nums text-xs",children:n}),!l&&(0,s.jsx)(aS.nA,{className:"max-w-[200px]",children:(0,s.jsx)("span",{className:"block truncate text-sm",title:o||void 0,children:o||(0,s.jsx)("span",{className:"text-muted-foreground",children:"—"})})}),!l&&(0,s.jsx)(aS.nA,{children:null!=a.responseStatusCode?(0,s.jsx)(Q.E,{variant:a.responseStatusCode>=200&&a.responseStatusCode<300?"default":"secondary",className:"font-mono text-xs",children:a.responseStatusCode}):(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"—"})}),(0,s.jsx)(aS.nA,{children:(0,s.jsxs)(Q.E,{variant:i.variant,className:"flex items-center gap-1 w-fit text-xs",children:["success"===i.type&&(0,s.jsx)(ez.A,{className:"h-3 w-3"}),"failed"===i.type&&(0,s.jsx)(e1.A,{className:"h-3 w-3"}),"error"===i.type&&(0,s.jsx)(eK.A,{className:"h-3 w-3"}),"pending"===i.type&&(0,s.jsx)(e3.A,{className:"h-3 w-3"}),i.label]})}),!l&&(0,s.jsx)(aS.nA,{className:"tabular-nums text-sm",children:null!=a.latencyMs?(0,s.jsxs)("span",{className:a.latencyMs>5e3?"text-orange-600 dark:text-orange-400":"",children:[a.latencyMs.toLocaleString()," ",(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"ms"})]}):(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"—"})}),!l&&(0,s.jsx)(aS.nA,{children:(null==(t=a.traces)?void 0:t.length)?(0,s.jsxs)("span",{className:"flex items-center gap-1 text-xs text-muted-foreground tabular-nums",children:[(0,s.jsx)(tB.A,{className:"h-3 w-3 shrink-0"}),a.traces.length]}):(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"—"})}),!l&&(0,s.jsx)(aS.nA,{className:"max-w-[180px]",children:a.evaluationNotes?(0,s.jsx)("span",{className:"block truncate text-xs text-muted-foreground",title:a.evaluationNotes,children:a.evaluationNotes}):(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"—"})})]})},aI=e=>{let{results:t,firstResultNumber:a,isLoading:n,pageSize:r,onShowResultDetail:l,isDetailViewActive:i}=e,o=i?2:7;return n||0!==t.length?(0,s.jsxs)(aS.XI,{children:[(0,s.jsx)(aS.A0,{children:(0,s.jsxs)(aS.Hj,{className:"bg-muted/20",children:[(0,s.jsx)(aS.nd,{className:"w-[40px] text-xs",children:"#"}),!i&&(0,s.jsx)(aS.nd,{className:"text-xs",children:"Harm Category"}),!i&&(0,s.jsx)(aS.nd,{className:"text-xs w-[90px]",children:"HTTP"}),(0,s.jsx)(aS.nd,{className:"text-xs",children:"Evaluation"}),!i&&(0,s.jsx)(aS.nd,{className:"text-xs w-[110px]",children:"Latency"}),!i&&(0,s.jsx)(aS.nd,{className:"text-xs w-[70px]",children:"Traces"}),!i&&(0,s.jsx)(aS.nd,{className:"text-xs",children:"Notes"})]})}),(0,s.jsx)(aS.BF,{children:n?Array.from({length:Math.min(r,10)},(e,t)=>(0,s.jsx)(aS.Hj,{"data-testid":"result-skeleton-row",children:Array.from({length:o},(e,t)=>(0,s.jsx)(aS.nA,{children:(0,s.jsx)(S.E,{className:"h-4 w-full max-w-[120px]"})},t))},t)):t.map((e,t)=>(0,s.jsx)(aL,{result:e,resultNumber:a-t,onShowDetail:()=>l(e),isDetailViewActive:i},e.id))})]}):(0,s.jsx)("p",{className:"text-center text-muted-foreground p-4 text-sm",children:"No results data available."})},az=e=>{let{messages:t,reply:a}=e;return(0,s.jsxs)("section",{"aria-label":"Conversation",className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Conversation"}),t.map((e,t)=>(0,s.jsxs)("div",{className:"max-w-[85%] rounded-lg px-3 py-2 text-sm ".concat("assistant"===e.role?"ml-auto bg-muted":"system"===e.role?"border bg-muted/40":"bg-blue-50 dark:bg-blue-900/20"),children:[(0,s.jsx)("p",{className:"mb-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"assistant"===e.role?"Target":"user"===e.role?"Attacker":e.role}),(0,s.jsx)(tx.P,{content:e.content})]},t)),(0,s.jsxs)("div",{className:"ml-auto max-w-[85%] rounded-lg border-2 border-primary/30 bg-muted px-3 py-2 text-sm",children:[(0,s.jsx)("p",{className:"mb-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Target reply (judged)"}),null==a||""===a?(0,s.jsx)("span",{className:"italic text-muted-foreground",children:""===a?"(empty)":"No reply recorded"}):(0,s.jsx)(tx.P,{content:a})]})]})},aM=new Set(["response","decoded_response","attack_metadata"]),aJ=e=>{let{data:t,children:a}=e,n=t.attack_metadata&&"object"==typeof t.attack_metadata?t.attack_metadata:{},r=Object.fromEntries(Object.entries(t).filter(e=>{let[a,s]=e;return!aM.has(a)&&("response_body"!==a||s!==t.response)}));return(0,s.jsxs)("section",{"aria-label":"Attempt details",className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Attempt details"}),Object.keys(n).length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:Object.entries(n).map(e=>{let[t,a]=e;return(0,s.jsxs)("div",{className:"flex flex-col rounded-md border bg-muted/30 px-3 py-1.5",children:[(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:t.replace(/_/g," ")}),(0,s.jsx)("span",{className:"font-mono text-sm",children:((e,t)=>"turn"===e&&"number"==typeof t?String(t+1):"object"==typeof t?JSON.stringify(t):String(t))(t,a)})]},t)})}),null==a?void 0:a(r)]})},aP=(0,I.h)("ResultDetailView"),aD=e=>{var t,a,r;let{result:i,onClose:o,attackId:c,resultNumber:m,totalResults:x,filterLabel:p,isLoadingDetail:h=!1,detailError:g,onRetryDetail:j,onPrevious:v,onNext:b}=e,[N,y]=(0,n.useState)(null),[k,w]=(0,n.useState)(!1),[A,_]=(0,n.useState)(null),[C,S]=(0,n.useState)(!1),[E,R]=(0,n.useState)("result");if((0,n.useEffect)(()=>{y(null),_(null),S(!1),R("result")},[null==i?void 0:i.id]),(0,n.useEffect)(()=>{"attack-config"===E&&!C&&c&&(w(!0),S(!0),u.vm.attackRetrieve({id:c}).then(e=>y(e)).catch(e=>{aP.error({err:e},"Failed to fetch attack config"),_((null==e?void 0:e.message)||"Failed to fetch attack configuration")}).finally(()=>w(!1)))},[E,C,c]),!i)return null;let T=aO(i.evaluationStatus,i.evaluationNotes),O=(e=>{let t=e.goal;if("string"==typeof t&&t.trim())return t;let a=e.agentSpecificData;return"string"==typeof(null==a?void 0:a.goal)&&a.goal.trim()?a.goal:(e=>{var t,a;if(!e.traces)return null;let s=e.traces.find(e=>{let t=e.content;return t&&t.goal&&t.attack_type&&void 0!==t.goal_index});return null!=(a=null==s||null==(t=s.content)?void 0:t.goal)?a:null})(e)})(i),L=(0,tp.z)(i),I="success"===T.type?ez.A:"failed"===T.type?e1.A:"error"===T.type?eK.A:e3.A,z=void 0!==m&&m>0&&x?"Result ".concat(m," of ").concat(x).concat(p?" (".concat(p,")"):""):"Result Detail";return(0,s.jsxs)(e_.tU,{value:E,onValueChange:R,className:"flex flex-col",children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 bg-card",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between py-3 px-4 border-b",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h2",{className:"text-sm font-semibold",children:z}),O&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:O})]}),(0,s.jsxs)(Q.E,{variant:T.variant,className:"flex items-center gap-1 shrink-0",children:[(0,s.jsx)(I,{className:"h-3 w-3"}),T.label]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,s.jsx)(d.$,{variant:"ghost",size:"icon",onClick:v,disabled:!v,title:"Previous result","aria-label":"Previous result",children:(0,s.jsx)(e2.A,{className:"h-5 w-5"})}),(0,s.jsx)(d.$,{variant:"ghost",size:"icon",onClick:b,disabled:!b,title:"Next result","aria-label":"Next result",children:(0,s.jsx)(ey.A,{className:"h-5 w-5"})}),o&&(0,s.jsx)(d.$,{variant:"ghost",size:"icon",onClick:o,title:"Close details","aria-label":"Close details",children:(0,s.jsx)(l.A,{className:"h-5 w-5"})})]})]}),(0,s.jsxs)(e_.j7,{className:"grid w-full grid-cols-3 rounded-none bg-transparent h-10 p-0 border-b",children:[(0,s.jsx)(e_.Xi,{value:"result",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none h-full text-xs",children:"Result"}),(0,s.jsxs)(e_.Xi,{value:"traces",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none h-full text-xs",children:["Traces",!h&&(null!=(r=null==(t=i.traces)?void 0:t.length)?r:0)>0&&(0,s.jsxs)("span",{className:"ml-1 text-muted-foreground tabular-nums",children:["(",null==(a=i.traces)?void 0:a.length,")"]})]}),(0,s.jsx)(e_.Xi,{value:"attack-config",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none h-full text-xs",children:"Config"})]})]}),(0,s.jsxs)(e_.av,{value:"result",className:"mt-0 focus-visible:outline-none focus-visible:ring-0",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-px border-b bg-border",children:[(0,s.jsxs)("div",{className:"bg-card px-4 py-3 flex flex-col gap-1",children:[(0,s.jsxs)("p",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[(0,s.jsx)(e5.A,{className:"h-3 w-3"})," Latency"]}),(0,s.jsx)("p",{className:"text-sm font-mono tabular-nums ".concat(null!=i.latencyMs&&i.latencyMs>5e3?"text-orange-600 dark:text-orange-400":""),children:null!=i.latencyMs?"".concat(i.latencyMs.toLocaleString()," ms"):"—"})]}),(0,s.jsxs)("div",{className:"bg-card px-4 py-3 flex flex-col gap-1",children:[(0,s.jsxs)("p",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[(0,s.jsx)(e4.A,{className:"h-3 w-3"})," HTTP Status"]}),null!=i.responseStatusCode?(0,s.jsx)(Q.E,{variant:i.responseStatusCode>=200&&i.responseStatusCode<300?"default":"secondary",className:"font-mono w-fit",children:i.responseStatusCode}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"—"})]}),(0,s.jsxs)("div",{className:"bg-card px-4 py-3 flex flex-col gap-1",children:[(0,s.jsxs)("p",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[(0,s.jsx)(e6.A,{className:"h-3 w-3"})," Goal"]}),(0,s.jsx)("p",{className:"text-sm truncate",title:O||void 0,children:O||(0,s.jsx)("span",{className:"text-muted-foreground",children:"—"})})]})]}),i.evaluationNotes&&(0,s.jsxs)("div",{className:"px-4 py-3 border-b bg-muted/20",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:"Evaluation Notes"}),(0,s.jsx)("p",{className:"text-sm whitespace-pre-wrap",children:i.evaluationNotes})]}),i.evaluationMetrics&&"object"==typeof i.evaluationMetrics&&Object.keys(i.evaluationMetrics).length>0&&(0,s.jsxs)("div",{className:"px-4 py-3 border-b",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Evaluation Metrics"}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5",children:Object.entries(i.evaluationMetrics).map(e=>{let[t,a]=e;return(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2 text-sm border-b border-dashed border-muted pb-1 last:border-0",children:[(0,s.jsx)("span",{className:"font-medium text-muted-foreground truncate shrink-0 max-w-[45%]",title:t,children:t}),(0,s.jsx)("span",{className:"break-all text-right",children:"object"==typeof a?JSON.stringify(a):String(a)})]},t)})})]}),(0,s.jsx)(e0.w,{}),(0,s.jsx)("div",{className:"p-4",children:L?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)(az,{messages:L.messages,reply:L.reply}),i.agentSpecificData&&(0,s.jsx)(aJ,{data:i.agentSpecificData,children:e=>Object.keys(e).length>0&&(0,s.jsx)(ax,{data:e})})]}):i.agentSpecificData?(0,s.jsx)(ax,{data:i.agentSpecificData}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center gap-2",children:[(0,s.jsx)(e6.A,{className:"h-8 w-8 text-muted-foreground/40"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No output data available for this result."})]})})]}),(0,s.jsx)(e_.av,{value:"traces",className:"mt-0 p-4 focus-visible:outline-none focus-visible:ring-0",children:h?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 gap-2",children:[(0,s.jsx)(f.A,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading traces…"})]}):g?(0,s.jsxs)("div",{className:"bg-destructive/10 border border-destructive/30 rounded-md p-3 flex items-center justify-between gap-3",children:[(0,s.jsxs)("p",{className:"text-sm text-destructive",children:[(0,s.jsx)("strong",{children:"Error:"})," ",g]}),j&&(0,s.jsx)(d.$,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:j,children:"Retry"})]}):i.traces&&i.traces.length>0?(0,s.jsx)(au,{traces:i.traces}):(0,s.jsx)("p",{className:"text-muted-foreground text-sm text-center py-8",children:"No traces available for this result."})}),(0,s.jsx)(e_.av,{value:"attack-config",className:"mt-0 p-4 focus-visible:outline-none focus-visible:ring-0",children:k?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 gap-2",children:[(0,s.jsx)(f.A,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading attack configuration…"})]}):N?(0,s.jsx)(aC,{config:N}):A?(0,s.jsx)("div",{className:"bg-destructive/10 border border-destructive/30 rounded-md p-3",children:(0,s.jsxs)("p",{className:"text-sm text-destructive",children:[(0,s.jsx)("strong",{children:"Error:"})," ",A]})}):c?(0,s.jsx)("p",{className:"text-muted-foreground text-sm text-center py-8",children:"Configuration will load when you open this tab."}):(0,s.jsx)("p",{className:"text-muted-foreground text-sm text-center py-8",children:"No attack configuration linked to this result."})})]})},aF=e=>{let{logs:t}=e;return 0===t.length?null:(0,s.jsx)(e7,{type:"multiple",className:"w-full",children:t.map((e,t)=>(0,s.jsxs)(te,{value:"step-".concat(t),children:[(0,s.jsx)(tt,{className:"hover:no-underline",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium text-sm",children:e.step_name}),(0,s.jsx)(Q.E,{variant:"Completed"===e.status?"default":"destructive",className:"text-xs",children:e.status})]})}),(0,s.jsxs)(ta,{children:[(0,s.jsx)("div",{className:"flex justify-end mb-2",children:(0,s.jsxs)(d.$,{size:"sm",variant:"outline",onClick:()=>{var t;return t=e.data_json,void navigator.clipboard.writeText(t)},children:[(0,s.jsx)(eY.A,{className:"w-3.5 h-3.5 mr-1.5"}),"Copy JSON"]})}),(0,s.jsx)("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto max-h-96 leading-relaxed",children:JSON.stringify(JSON.parse(e.data_json),null,2)})]})]},t))})};var aU=a(34015),aq=a(27063),aH=a(95757);let aB=(0,I.h)("RunGoalsPanel"),a$={[N.JlS.Jailbroken]:{label:"Jailbroken",variant:"destructive",icon:(0,s.jsx)(eK.A,{className:"h-3 w-3"})},[N.JlS.Mitigated]:{label:"Mitigated",variant:"secondary",icon:(0,s.jsx)(tG.A,{className:"h-3 w-3"})},[N.JlS.Error]:{label:"Error",variant:"outline",icon:(0,s.jsx)(eK.A,{className:"h-3 w-3"})},[N.JlS.Pending]:{label:"Pending",variant:"outline",icon:(0,s.jsx)(e3.A,{className:"h-3 w-3"})}},aG=e=>{var t;let{verdict:a}=e,n=null!=(t=a$[a])?t:a$[N.JlS.Pending];return(0,s.jsxs)(Q.E,{variant:n.variant,className:"gap-1 shrink-0",children:[n.icon,n.label]})},aW={[N.on2.SuccessfulJailbreak]:{label:"Jailbreak",variant:"destructive"},[N.on2.FailedJailbreak]:{label:"Mitigated",variant:"secondary"},[N.on2.PassedCriteria]:{label:"Mitigated",variant:"secondary"},[N.on2.ErrorAgentResponse]:{label:"Agent error",variant:"outline"},[N.on2.ErrorTestFramework]:{label:"Framework error",variant:"outline"},[N.on2.FailedCriteria]:{label:"Error",variant:"outline"},[N.on2.NotEvaluated]:{label:"Not evaluated",variant:"outline"}},aV=e=>e&&"object"==typeof e&&!Array.isArray(e)?e:{},aZ=e=>{var t,a;let s=aV(e.agentSpecificData),n=aV(e.requestPayload),r=[...Array.isArray(n.messages)?n.messages:[]].reverse().find(e=>(null==e?void 0:e.role)==="user");return{result:e,requestIndex:"number"==typeof s.request_index?s.request_index:null,question:null!=(a=null!=(t=null==r?void 0:r.content)?t:n.prompt)?a:null,reply:"string"==typeof s.response?s.response:null,metadata:aV(s.attack_metadata)}},aK=(e,t)=>{var a,s;return(null!=(a=e.requestIndex)?a:1/0)-(null!=(s=t.requestIndex)?s:1/0)||new Date(e.result.timestamp).getTime()-new Date(t.result.timestamp).getTime()},aX=e=>!0===e.metadata.refused||!0===e.metadata.backtracked,aY=e=>{let{attempt:t,number:a,onOpen:n}=e,r=aW[t.result.evaluationStatus],{refused:l,backtracked:i,score:o}=t.metadata;return(0,s.jsxs)("article",{className:"space-y-2 rounded-md border p-3 ".concat(aX(t)?"opacity-60":""),children:[(0,s.jsxs)("header",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,s.jsxs)("span",{className:"font-semibold",children:["Turn ",a]}),r&&(0,s.jsx)(Q.E,{variant:r.variant,children:r.label}),"number"==typeof o&&(0,s.jsxs)("span",{className:"font-mono text-muted-foreground",children:["score ",o]}),!0===l&&(0,s.jsx)(Q.E,{variant:"outline",children:"refused"}),!0===i&&(0,s.jsx)(Q.E,{variant:"outline",children:"backtracked"}),(0,s.jsx)(d.$,{variant:"ghost",size:"sm",className:"ml-auto h-6 px-2 text-xs",onClick:n,children:"Details"})]}),(0,s.jsx)("div",{className:"rounded-md bg-blue-50 px-3 py-2 text-sm dark:bg-blue-900/20","data-testid":"turn-question",children:null==t.question?(0,s.jsx)("span",{className:"italic text-muted-foreground",children:"No prompt recorded"}):(0,tp.Lo)(t.question)}),(0,s.jsx)("div",{className:"ml-6 rounded-md bg-muted px-3 py-2 text-sm",children:null==t.reply?(0,s.jsx)("span",{className:"italic text-muted-foreground",children:"No reply recorded"}):(0,s.jsx)(tx.P,{content:t.reply})}),t.result.evaluationNotes&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"font-medium",children:"Judge:"})," ",t.result.evaluationNotes]})]})},aQ=e=>{let{run:t,goal:a,onOpenResult:r}=e,[l,i]=(0,n.useState)(null),[o,c]=(0,n.useState)(0),[d,m]=(0,n.useState)(null),[x,p]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{let e=new AbortController;return u.ui.resultList({run:t.id,goalIndex:a.goalIndex,pageSize:100},{signal:e.signal}).then(t=>{var a;e.signal.aborted||(i((null!=(a=t.results)?a:[]).map(aZ).sort(aK)),c(t.count))}).catch(s=>{e.signal.aborted||(aB.error({err:s,runId:t.id,goalIndex:a.goalIndex},"Failed to load the goal attempts"),m((null==s?void 0:s.message)||"Failed to load the attempts."))}),()=>e.abort()},[t.id,a.goalIndex,a.attempts,a.successfulJailbreaks,a.failedJailbreaks,a.errors,a.notEvaluated,a.verdict]),d)return(0,s.jsx)("p",{className:"px-4 py-3 text-sm text-destructive",children:d});if(!l)return(0,s.jsxs)("p",{className:"flex items-center px-4 py-3 text-sm text-muted-foreground",children:[(0,s.jsx)(f.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading attempts…"]});let h=l.map((e,t)=>({attempt:e,number:t+1})),g=x?h.filter(e=>{let{attempt:t}=e;return!aX(t)}):h,j=l.filter(aX).length;return(0,s.jsxs)("div",{className:"space-y-3 bg-muted/20 px-4 py-3",children:[j>0&&(0,s.jsx)("div",{className:"flex justify-end text-xs text-muted-foreground",children:(0,s.jsxs)("label",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("input",{type:"checkbox",checked:x,onChange:e=>p(e.target.checked)}),"Hide refused and backtracked turns (",j,")"]})}),g.map(e=>{let{attempt:t,number:a}=e;return(0,s.jsx)(aY,{attempt:t,number:a,onOpen:()=>r(t.result.id)},t.result.id)}),o>l.length&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Showing the first ",l.length," of ",o," attempts."]})]})},a0=e=>{let{resultId:t,attackId:a,run:r,onClose:l}=e,[i,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(o(e=>(null==e?void 0:e.id)===t?e:null),d(null),!t)return;let e=!1;return u.ui.resultRetrieve({id:t}).then(t=>{e||o(t)}).catch(t=>{e||d((null==t?void 0:t.message)||"Failed to load this result.")}),()=>{e=!0}},[t,r.totalResults,r.notEvaluated,r.successfulJailbreaks,r.failedJailbreaks,r.status]),(0,s.jsx)(aq.cj,{open:!!t,onOpenChange:e=>{e||l()},children:(0,s.jsxs)(aq.h,{side:"right",className:"w-full overflow-y-auto p-0 sm:max-w-3xl",children:[(0,s.jsx)(aq.qp,{className:"sr-only",children:"Result detail"}),c?(0,s.jsx)("p",{className:"p-4 text-sm text-destructive",children:c}):i?(0,s.jsx)(aD,{result:i,onClose:l,attackId:a}):(0,s.jsxs)("p",{className:"flex items-center p-4 text-sm text-muted-foreground",children:[(0,s.jsx)(f.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading…"]})]})})},a1=e=>{let{run:t}=e,[a,r]=(0,n.useState)(1),[l,i]=(0,n.useState)(aH.KA),[o,c]=(0,n.useState)(null),[m,x]=(0,n.useState)(null),[p,h]=(0,n.useState)(null),[g,j]=(0,n.useState)(null),[v,b]=(0,n.useState)(null),[N,y]=(0,n.useState)(0);(0,n.useEffect)(()=>{let e=!1;return h(null),u.ME.runGoalsList({id:t.id,page:a,pageSize:l}).then(t=>{var a;e||(c(null!=(a=t.results)?a:[]),x(t.count))}).catch(a=>{e||(aB.error({err:a,runId:t.id},"Failed to load the run goals"),h((null==a?void 0:a.message)||"Failed to load the goals."))}),()=>{e=!0}},[t.id,t.totalResults,t.notEvaluated,t.successfulJailbreaks,t.failedJailbreaks,t.status,a,l,N]);let k=(0,n.useCallback)(e=>{i(e),r(1)},[]),w=null===o&&!p,A=(0,n.useMemo)(()=>{var e;return null!=(e=null==o?void 0:o.reduce((e,t)=>e+t.attempts,0))?e:0},[o]);return(0,s.jsxs)("div",{className:"rounded-md border overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2 text-xs",children:[(0,s.jsxs)("span",{className:"font-medium",children:[t.jailbrokenGoals," of ",t.totalGoals," goals jailbroken"]}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[t.totalResults," attempts in total"]})]}),p?(0,s.jsxs)("div",{className:"flex items-center justify-center gap-3 p-6 text-sm text-destructive",children:[(0,s.jsx)(eK.A,{className:"h-4 w-4"}),p,(0,s.jsx)(d.$,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>y(e=>e+1),children:"Retry"})]}):w?(0,s.jsxs)("p",{className:"flex items-center justify-center p-6 text-sm text-muted-foreground",children:[(0,s.jsx)(f.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading goals…"]}):0===o.length?(0,s.jsx)("p",{className:"p-6 text-center text-sm text-muted-foreground",children:"No goals recorded yet."}):(0,s.jsx)("ul",{className:"divide-y","aria-label":"Goals (".concat(A," attempts on this page)"),children:o.map(e=>{var a;let n=g===e.goalIndex;return(0,s.jsxs)("li",{children:[(0,s.jsxs)("button",{type:"button","aria-expanded":n,onClick:()=>j(n?null:e.goalIndex),className:"flex w-full items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/40",children:[n?(0,s.jsx)(ey.A,{className:"h-4 w-4 shrink-0"}):(0,s.jsx)(z.A,{className:"h-4 w-4 shrink-0"}),(0,s.jsxs)("span",{className:"w-8 shrink-0 font-mono text-xs text-muted-foreground",children:["#",e.goalIndex+1]}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm",title:e.goal,children:e.goal||(0,s.jsx)("span",{className:"italic text-muted-foreground",children:"Goal text not recorded"})}),e.category&&(0,s.jsx)("span",{className:"hidden shrink-0 text-xs text-muted-foreground md:inline",children:aT(e.category)}),(0,s.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground",children:[e.attempts," attempt",1===e.attempts?"":"s",e.successfulJailbreaks>0&&" \xb7 ".concat(e.successfulJailbreaks," jailbreak").concat(1===e.successfulJailbreaks?"":"s")]}),(0,s.jsx)("span",{className:"w-10 shrink-0 text-right font-mono text-xs",title:"Best score",children:null!=(a=e.bestScore)?a:"—"}),(0,s.jsx)(aG,{verdict:e.verdict})]}),n&&(0,s.jsx)(aQ,{run:t,goal:e,onOpenResult:b})]},e.goalIndex)})}),(0,s.jsx)(aU.H,{page:a,pageSize:l,count:m,isLoading:w,onPageChange:r,onPageSizeChange:k}),(0,s.jsx)(a0,{run:t,resultId:v,attackId:t.attack,onClose:()=>b(null)})]})},a3=e=>{let{run:t,runResults:a,onShowResultDetail:n,isDetailViewActive:r}=e;return t.totalGoals>0?(0,s.jsx)(aS.Hj,{children:(0,s.jsx)(aS.nA,{colSpan:100,className:"p-0",children:(0,s.jsx)("div",{className:"border-t bg-background",children:(0,s.jsx)(a1,{run:t})})})}):(0,s.jsx)(aS.Hj,{children:(0,s.jsx)(aS.nA,{colSpan:100,className:"p-0",children:(0,s.jsxs)("div",{className:"border-t bg-background",children:[(0,s.jsxs)("div",{className:"rounded-md border overflow-hidden",children:[(0,s.jsx)(aU.v,{run:t,filter:a.filter,count:a.count,onFilterChange:a.setFilter}),a.error?(0,s.jsxs)("div",{className:"flex items-center justify-center gap-3 p-6 text-sm text-destructive",children:[(0,s.jsx)(eK.A,{className:"h-4 w-4 shrink-0"}),(0,s.jsx)("span",{children:a.error}),(0,s.jsx)(d.$,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:a.reload,children:"Retry"})]}):(0,s.jsx)(aI,{results:a.results,firstResultNumber:a.firstResultNumber,isLoading:a.isLoading,pageSize:a.pageSize,onShowResultDetail:n,isDetailViewActive:r}),(0,s.jsx)(aU.H,{page:a.page,pageSize:a.pageSize,count:a.count,isLoading:a.isLoading,onPageChange:a.setPage,onPageSizeChange:a.setPageSize})]}),t.step_logs&&t.step_logs.length>0&&(0,s.jsx)("div",{className:"border-t px-4 py-3",children:(0,s.jsx)(aF,{logs:t.step_logs})})]})})})},a2=e=>e.status===N.S5d.Pending?"Queued":e.status===N.S5d.Running&&e.cancelRequestedAt?"Cancelling":(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())(e.status),a5=e=>e===N.S5d.Completed||e===N.S5d.Failed||e===N.S5d.Cancelled,a4={debug:{label:"Debug",text:"text-muted-foreground",row:""},info:{label:"Info",text:"text-sky-700 dark:text-sky-400",row:""},warning:{label:"Warning",text:"text-amber-700 dark:text-amber-400",row:"bg-amber-500/10"},error:{label:"Error",text:"text-red-700 dark:text-red-400",row:"bg-red-500/10"}},a6=e=>String(e).padStart(2,"0");function a9(e){var t,a;let{event:n}=e,r=null!=(a=a4[t=n.level])?a:{label:t,text:"text-muted-foreground",row:""},l=new Date(n.time);return(0,s.jsxs)("li",{className:"flex flex-wrap items-baseline gap-x-2 px-3 py-0.5 ".concat(r.row),children:[(0,s.jsx)("time",{className:"shrink-0 tabular-nums text-muted-foreground",dateTime:l.toISOString(),title:l.toLocaleString(),children:"".concat(a6(l.getHours()),":").concat(a6(l.getMinutes()),":").concat(a6(l.getSeconds()))}),(0,s.jsx)("span",{className:"w-14 shrink-0 font-semibold uppercase ".concat(r.text),children:r.label}),n.attack&&(0,s.jsx)("span",{className:"shrink-0 rounded border bg-muted px-1.5 font-sans text-[11px] leading-4 text-muted-foreground",children:n.attack}),(0,s.jsx)("span",{className:"min-w-0 flex-1 basis-48 whitespace-pre-wrap break-words",children:n.message})]})}function a8(e){let{runId:t,active:a}=e,{events:r,loaded:l,error:i,dropped:o,unavailable:c}=function(e,t){let[a,s]=(0,n.useState)([]),[r,l]=(0,n.useState)(!1),[i,o]=(0,n.useState)(!1),[c,d]=(0,n.useState)(0),[m,x]=(0,n.useState)(!1),p=(0,n.useRef)({runId:e,after:0,total:0,missing:!1}),[h,g]=(0,n.useState)(e);return e!==h&&(g(e),s([]),l(!1),o(!1),d(0),x(!1)),(0,n.useEffect)(()=>{let a;p.current.runId!==e&&(p.current={runId:e,after:0,total:0,missing:!1});let n=!1,r=!1,i=!1,c=Date.now(),m=async()=>{if(n||r||i||"hidden"===document.visibilityState)return;r=!0;let h=!1;try{let t=!p.current.missing;for(;t;){let a=await u.ME.runEventsRetrieve({id:e,after:p.current.after,limit:500});if(n)return;let r=a.results.filter(e=>e.seq>p.current.after);p.current.after=Math.max(p.current.after,a.lastSeq,...r.map(e=>e.seq)),p.current.total+=r.length,r.length&&(s(e=>(function(e,t){let a=e.length?e[e.length-1].seq:0,s=t.filter(e=>e.seq>a);if(!s.length)return e;let n=e.concat(s);return n.length>5e3?n.slice(n.length-5e3):n})(e,r)),d(Math.max(0,p.current.total-5e3))),t=a.hasMore&&r.length>0}h=!0,o(!1)}catch(e){if(n)return;(e instanceof N.o3e?404===e.response.status||501===e.response.status:e instanceof Error&&/^API error (404|501)\b/.test(e.message))?(p.current.missing=!0,h=!0,x(!0)):o(!0)}finally{r=!1}if(!n)h&&l(!0),(i=p.current.missing||!t&&h)||(a=setTimeout(m,Date.now()-c>=3e5?15e3:3e3))},h=()=>{"hidden"!==document.visibilityState&&(a&&clearTimeout(a),m())};return document.addEventListener("visibilitychange",h),m(),()=>{document.removeEventListener("visibilitychange",h),n=!0,a&&clearTimeout(a)}},[e,t]),{events:a,loaded:r,error:i,dropped:c,unavailable:m}}(t,a),[m,x]=(0,n.useState)("all"),[p,h]=(0,n.useState)(""),[j,v]=(0,n.useState)(!0),b=(0,n.useRef)(null),y=(0,n.useId)(),k=(0,n.useMemo)(()=>Array.from(new Set(r.map(e=>e.attack).filter(e=>!!e))),[r]),w=(0,n.useMemo)(()=>r.filter(e=>("all"===m||"warning"===e.level||"error"===e.level)&&(!p||e.attack===p)),[r,m,p]);(0,n.useLayoutEffect)(()=>{let e=b.current;j&&e&&(e.scrollTop=e.scrollHeight)},[w,j]);let A=null;return l?0===r.length?A=a&&!c?"No activity yet. What the run is doing appears here as it goes.":"No activity recorded for this run.":0===w.length&&(A="No lines match these filters."):A=i?"Could not load the activity. Retrying automatically.":(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(f.A,{className:"h-3 w-3 animate-spin"})," Loading activity…"]}),(0,s.jsxs)("section",{className:"rounded-md border","aria-labelledby":y,children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b px-3 py-2",children:[(0,s.jsx)("h3",{id:y,className:"mr-auto text-sm font-medium",children:"Activity"}),(0,s.jsxs)("select",{"aria-label":"Filter activity by level",className:"h-8 rounded-md border bg-card px-2 text-sm",value:m,onChange:e=>x(e.target.value),children:[(0,s.jsx)("option",{value:"all",children:"All levels"}),(0,s.jsx)("option",{value:"problems",children:"Warnings and errors"})]}),k.length>0&&(0,s.jsxs)("select",{"aria-label":"Filter activity by attack",className:"h-8 max-w-[12rem] rounded-md border bg-card px-2 text-sm",value:p,onChange:e=>h(e.target.value),children:[(0,s.jsx)("option",{value:"",children:"All attacks"}),k.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]}),(0,s.jsxs)(d.$,{variant:"outline",size:"sm",disabled:0===r.length,onClick:()=>(function(e,t){let a=URL.createObjectURL(new Blob([t.map(e=>{let t=e.attack?"[".concat(e.attack,"] "):"";return"".concat(new Date(e.time).toISOString()," ").concat(e.level.toUpperCase().padEnd(7)," ").concat(t).concat(e.message)}).join("\n")+(t.length?"\n":"")],{type:"text/plain;charset=utf-8"})),s=document.createElement("a");s.href=a,s.download="run-".concat(e,"-activity.log"),document.body.append(s);try{s.click()}finally{s.remove(),setTimeout(()=>URL.revokeObjectURL(a),1e3)}})(t,r),children:[(0,s.jsx)(g.A,{}),"Download log"]})]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{ref:b,role:"log","aria-live":"polite","aria-label":"Run activity",tabIndex:0,className:"max-h-80 overflow-y-auto py-1 font-mono text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onScroll:()=>{let e=b.current;e&&v(e.scrollHeight-e.scrollTop-e.clientHeight<=24)},children:A?(0,s.jsx)("p",{className:"px-3 py-2 font-sans text-sm text-muted-foreground",children:A}):(0,s.jsx)("ol",{children:w.map(e=>(0,s.jsx)(a9,{event:e},e.seq))})}),!j&&w.length>0&&(0,s.jsxs)(d.$,{variant:"secondary",size:"sm",className:"absolute bottom-2 right-4 shadow-md",onClick:()=>{let e=b.current;e&&(e.scrollTop=e.scrollHeight),v(!0)},children:[(0,s.jsx)($.A,{}),"Jump to latest"]})]}),l&&i&&(0,s.jsx)("p",{className:"border-t px-3 py-1.5 text-xs text-muted-foreground",children:"Could not refresh the activity. Retrying automatically."}),o>0&&(0,s.jsxs)("p",{className:"border-t px-3 py-1.5 text-xs text-muted-foreground",children:["Showing the latest ",5e3.toLocaleString("en-US")," lines."]})]})}let a7=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),se=e=>e?new Date(e).toLocaleString():null;async function st(e){if(!(e instanceof N.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 sa(e){let{run:t}=e,a=a5(t.status),n=!!t.claimedAt||t.status===N.S5d.Running,r=[{label:"Queued",done:!0,time:se(t.timestamp)},{label:"Picked up",done:n,time:se(t.claimedAt)},{label:"Running",done:t.status===N.S5d.Running||n&&a,time:null},{label:a?a2(t):"Finished",done:a,time:se(t.finishedAt)}];return(0,s.jsx)("ol",{className:"flex flex-wrap items-start gap-x-6 gap-y-2","aria-label":"Run progress",children:r.map(e=>(0,s.jsxs)("li",{className:"flex items-start gap-2 text-sm","data-done":e.done,children:[(0,s.jsx)("span",{className:"mt-0.5 flex h-4 w-4 items-center justify-center rounded-full border ".concat(e.done?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/40"),children:e.done&&(0,s.jsx)(ek.A,{className:"h-3 w-3"})}),(0,s.jsxs)("span",{className:e.done?"font-medium":"text-muted-foreground",children:[e.label,e.time&&(0,s.jsx)("span",{className:"block text-xs font-normal text-muted-foreground",children:e.time})]})]},e.label))})}function ss(e){let{run:t}=e,a=(0,n.useMemo)(()=>(function(e){let t=new Set,a=e=>{if(Array.isArray(e))return e.forEach(a);if(!a7(e))return;let s=(0,O.rR)(e.api_key),n="hackagent"===e.provider&&!e.endpoint;s&&"HACKAGENT_GATEWAY_KEY"!==s&&!n&&t.add(s),Object.values(e).forEach(a)};return a(a7(e)?e.campaign_config:null),Array.from(t).sort()})(t.runConfig),[t.runConfig]);return(0,eP.db)()?(0,s.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",role:"status",children:[(0,s.jsx)(f.A,{className:"h-4 w-4 animate-spin"})," Starting on this machine…"]}):(0,s.jsxs)("section",{className:"space-y-3 rounded-md border p-4","aria-label":"Run on your machine",children:[(0,s.jsx)("p",{className:"text-sm",children:"Run this command where your target is reachable:"}),(0,s.jsx)(eQ,{command:"hackagent run ".concat(t.id)}),a.length>0&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Set these first, with your own values:"}),a.map(e=>(0,s.jsx)(eQ,{command:"export ".concat(e,"=…"),label:"Copy export ".concat(e)},e))]}),(0,s.jsxs)("details",{className:"text-sm",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-muted-foreground",children:"First time here? Set up the CLI"}),(0,s.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,s.jsx)(eQ,{command:"pip install hackagent"}),(0,s.jsx)(eQ,{command:"hackagent config set --api-key"}),(0,s.jsxs)("p",{className:"text-muted-foreground",children:["Create an API key on the"," ",(0,s.jsx)(eI(),{href:"/credentials?tab=api-keys",className:"underline",children:"Credentials page"}),"."]})]})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"This run expires if it isn't picked up within 24 hours."})]})}function sn(e){let{run:t,now:a}=e,n=a-new Date(t.timestamp).getTime();return(0,s.jsxs)("section",{className:"flex items-start gap-3 rounded-md border p-4","aria-label":"Waiting to start",children:[(0,s.jsx)(f.A,{className:"mt-0.5 h-4 w-4 animate-spin text-muted-foreground"}),(0,s.jsxs)("div",{className:"text-sm",children:[(0,s.jsx)("p",{className:"font-medium",children:"Waiting to start"}),n>=12e4&&(0,s.jsx)("p",{className:"text-muted-foreground",children:"The run is still queued. It will start when capacity is available."})]})]})}function sr(e){let{child:t}=e,a=(0,aH.No)(t),{reload:r}=a,l="".concat(t.totalResults,":").concat(t.notEvaluated,":").concat(t.successfulJailbreaks,":").concat(t.failedJailbreaks,":").concat(t.status),[i,o]=(0,n.useState)(l);(0,n.useEffect)(()=>{l!==i&&(o(l),r())},[l,i,r]);let c=a.selection;if(a.selectedResult){var d;return(0,s.jsx)(aD,{result:a.selectedResult,onClose:a.closeResult,attackId:null!=(d=null==c?void 0:c.attackId)?d:null,resultNumber:a.selectedResultNumber,totalResults:null==c?void 0:c.total,isLoadingDetail:a.isLoadingDetail,detailError:a.detailError,onRetryDetail:a.retryDetail,onPrevious:a.hasPrevious?a.goToPrevious:void 0,onNext:a.hasNext?a.goToNext:void 0})}return(0,s.jsx)(aS.XI,{children:(0,s.jsx)(aS.BF,{children:(0,s.jsx)(a3,{run:t,runResults:a,onShowResultDetail:a.openResult,isDetailViewActive:!1})})})}function sl(e){var t,a,n,r,l;let{child:i,expanded:o,onToggle:c}=e,d=null!=(l=null!=(r=null!=(n=i.attackType)?n:null==(t=i.runConfig)?void 0:t.attack_type)?r:null==(a=i.runConfig)?void 0:a.name)?l:"Attack";return(0,s.jsxs)("div",{className:"rounded-md border",children:[(0,s.jsxs)("button",{type:"button",className:"flex w-full flex-wrap items-center gap-3 px-4 py-3 text-left text-sm","aria-expanded":o,onClick:c,children:[o?(0,s.jsx)(ey.A,{className:"h-4 w-4"}):(0,s.jsx)(z.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"flex-1 font-medium",children:d}),(0,s.jsx)("span",{className:"text-muted-foreground",children:a2(i)}),(0,s.jsxs)("span",{className:"tabular-nums text-muted-foreground",children:[i.totalResults," results"]}),(0,s.jsxs)("span",{className:"tabular-nums text-muted-foreground",children:["Evaluated success ",(e=>{var t,a;let s=null!=(t=e.successfulJailbreaks)?t:0,n=s+(null!=(a=e.failedJailbreaks)?a:0);return n>0?"".concat(Math.round(s/n*100),"%"):"—"})(i)]})]}),o&&(0,s.jsx)(sr,{child:i})]})}function si(e){var t,a,r,l;let{runId:o,onBack:m,onRunAgain:x,launching:p=!1,onFinished:h}=e,{run:g,children:j,error:v,reload:b,updatedAt:y}=function(e){let[t,a]=(0,n.useState)(null),[s,r]=(0,n.useState)([]),[l,i]=(0,n.useState)(null),[o,c]=(0,n.useState)(null),[d,m]=(0,n.useState)(0),[x,p]=(0,n.useState)(e);return e!==x&&(p(e),a(null),r([]),c(null),i(null)),(0,n.useEffect)(()=>{let t,s=!1,n=!1,l=Date.now(),o=async()=>{if(s||n||"hidden"===document.visibilityState)return;n=!0;let d=!1;try{let t=await u.ME.runRetrieve({id:e,includeResults:!1});if(s)return;a(t);let n=!1,l=[];try{let t=1,a=!0;for(;a;){var m;let n=await u.ME.runList({parent:e,pageSize:100,...t>1?{page:t}:{}});if(l.push(...null!=(m=n.results)?m:[]),a=!!n.next,t+=1,s)return}}catch(e){n=!0}if(s)return;n||(r(Array.from(new Map(l.map(e=>[e.id,e])).values())),i(new Date)),c(n?"Could not refresh attack progress. Retrying automatically.":null),d=a5(t.status)&&!n&&l.every(e=>!e.status||a5(e.status))}catch(a){if(s)return;let{message:e,fatal:t}=function(e){if(e instanceof N.o3e){let t=e.response.status;return 404===t||403===t?{message:"This run does not exist or you do not have access to it.",fatal:!0}:{message:"Could not load the run (HTTP ".concat(t,")."),fatal:!1}}return{message:e instanceof Error?e.message:"Could not load the run.",fatal:!1}}(a);c(t?e:"".concat(e," Retrying automatically.")),d=t}finally{n=!1}d||s||(t=setTimeout(o,Date.now()-l>=3e5?15e3:3e3))},d=()=>{"hidden"!==document.visibilityState&&(t&&clearTimeout(t),o())};return document.addEventListener("visibilitychange",d),o(),()=>{document.removeEventListener("visibilitychange",d),s=!0,t&&clearTimeout(t)}},[e,d]),{run:t,children:s,error:o,reload:(0,n.useCallback)(()=>{c(null),m(e=>e+1)},[]),updatedAt:l}}(o),[k,w]=(0,n.useState)({}),[A,_]=(0,n.useState)(!1),[C,S]=(0,n.useState)(!1),[E,R]=(0,n.useState)(null),[T,O]=(0,n.useState)(null),L=!!g&&a5(g.status),I=function(e){let[t,a]=(0,n.useState)(()=>Date.now());return(0,n.useEffect)(()=>{if(!e)return;let t=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}(!!g&&!L);(0,n.useEffect)(()=>{L&&(null==h||h())},[L]);let z=null!=(r=null==g?void 0:g.campaign)?r:null;if((0,n.useEffect)(()=>{if(!z)return;let e=!1;return u.Bm.campaignRetrieve({id:z}).then(t=>{e||O({id:z,name:t.name})}).catch(()=>{}),()=>{e=!0}},[z]),v&&!g)return(0,s.jsxs)("div",{className:"space-y-4 p-6",children:[(0,s.jsxs)(c.Fc,{variant:"destructive",children:[(0,s.jsx)(eK.A,{className:"h-4 w-4"}),(0,s.jsx)(c.TN,{children:v})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)(d.$,{variant:"outline",size:"sm",onClick:m,children:[(0,s.jsx)(eX.A,{className:"mr-1 h-4 w-4"})," Back"]}),(0,s.jsx)(d.$,{variant:"outline",size:"sm",onClick:b,children:"Retry"})]})]});if(!g)return(0,s.jsxs)("div",{className:"flex items-center gap-2 p-6 text-sm text-muted-foreground",role:"status",children:[(0,s.jsx)(f.A,{className:"h-4 w-4 animate-spin"})," Loading run…"]});let M=g.executor!==N.qjb.Cloud,J=!L&&(C||g.status===N.S5d.Running&&!!g.cancelRequestedAt),P=(null==T?void 0:T.id)===g.campaign?T.name:null,D=g.finishedAt?new Date(g.finishedAt).getTime():I,F=null!=(l=g.claimedAt)?l:g.status===N.S5d.Running?g.timestamp:null,U=(e=>{let t=Math.max(0,Math.floor(e/1e3)),a=Math.floor(t/3600),s=Math.floor(t%3600/60),n=t%60;return a>0?"".concat(a,"h ").concat(s,"m ").concat(n,"s"):s>0?"".concat(s,"m ").concat(n,"s"):"".concat(n,"s")})(D-new Date(null!=F?F:g.timestamp).getTime()),q=g.status===N.S5d.Pending,H=async()=>{R(null),S(!0);try{await u.ME.runCancelCreate({id:g.id}),b()}catch(t){var e;S(!1),R(null!=(e=await st(t))?e:"Could not cancel the run.")}};return(0,s.jsxs)("div",{className:"space-y-4 p-6",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)(d.$,{variant:"ghost",size:"sm",onClick:m,children:[(0,s.jsx)(eX.A,{}),"Back to campaign"]}),!L&&(0,s.jsx)(d.$,{variant:"outline",size:"sm",asChild:!0,children:(0,s.jsx)(eI(),{href:"/stats?run=".concat(encodeURIComponent(g.id)),children:"Open report"})})]}),(0,s.jsxs)("header",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:null!=P?P:"Campaign run"}),(0,s.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Target: ",g.agentName]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:J?"Cancelling…":a2(g)}),!L&&(0,s.jsx)(d.$,{variant:"outline",size:"sm",disabled:J,onClick:()=>_(!0),children:"Cancel"})]})]}),(0,s.jsx)(sa,{run:g}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[F?"Started ".concat(se(F)):"Queued ".concat(se(g.timestamp))," \xb7 Elapsed ",U]})]}),E&&(0,s.jsx)(c.Fc,{variant:"destructive",children:(0,s.jsx)(c.TN,{children:E})}),v&&(0,s.jsx)(c.Fc,{role:"status",children:(0,s.jsxs)(c.TN,{children:[v," ",(0,s.jsx)(d.$,{variant:"outline",size:"sm",onClick:b,children:"Retry now"})]})}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4","aria-label":"Live run summary",children:[["Attacks finished","".concat(j.filter(e=>a5(e.status)).length," / ").concat(Array.isArray(null==(a=g.runConfig)||null==(t=a.campaign_config)?void 0:t.attacks)?Math.max(g.runConfig.campaign_config.attacks.length,j.length):j.length||"—")],["Attempts recorded",j.reduce((e,t)=>{var a;return e+(null!=(a=t.totalResults)?a:0)},0)],["Successful attempts",j.reduce((e,t)=>{var a;return e+(null!=(a=t.successfulJailbreaks)?a:0)},0)],["Pending evaluations",j.reduce((e,t)=>{var a;return e+(null!=(a=t.notEvaluated)?a:0)},0)]].map(e=>{let[t,a]=e;return(0,s.jsxs)("div",{className:"rounded-md border p-3",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:t}),(0,s.jsx)("p",{className:"mt-1 text-lg font-semibold tabular-nums",children:a})]},t)})}),!L&&(0,s.jsxs)("p",{role:"status",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)(f.A,{className:"h-3 w-3 animate-spin"}),"Updating automatically",y?" \xb7 Last updated ".concat(y.toLocaleTimeString()):""]}),q&&(M?(0,s.jsx)(ss,{run:g}):(0,s.jsx)(sn,{run:g,now:I})),(0,s.jsx)(a8,{runId:g.id,active:!L}),j.length>0&&(0,s.jsx)("section",{className:"space-y-2","aria-label":"Attacks",children:j.map(e=>{var t;return(0,s.jsx)(sl,{child:e,expanded:null==(t=k[e.id])||t,onToggle:()=>{var t;let a,s;return a=e.id,s=null==(t=k[e.id])||t,w(e=>({...e,[a]:!s}))}},e.id)})}),L&&(0,s.jsxs)("section",{className:"space-y-3 rounded-md border p-4","aria-label":"Result",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:a2(g)}),g.runNotes&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:g.runNotes}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsx)(d.$,{size:"sm",disabled:!g.campaign||p,onClick:()=>g.campaign&&x(g.campaign),children:p?"Launching…":"Run again"}),(0,s.jsx)(d.$,{variant:"outline",size:"sm",asChild:!0,children:(0,s.jsx)(eI(),{href:"/stats?run=".concat(encodeURIComponent(g.id)),children:"Open in Runs"})})]})]}),(0,s.jsx)(i.T,{open:A,onOpenChange:_,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:H})]})}var so=a(74672);async function sc(e){try{let t=await e.response.json();return t&&"object"==typeof t?t:null}catch(e){return null}}async function sd(e,t){let a=t instanceof N.o3e?await sc(t):null;if(t instanceof N.o3e&&400===t.response.status){var s;return a&&Array.isArray(a.problems)?{campaign:e,problems:a.problems,message:null}:{campaign:e,problems:[],message:null!=(s=function(e){if(!e||!e.spec||"object"!=typeof e.spec)return null;let t=Object.values(e.spec)[0];return"This campaign no longer validates".concat(t?": ".concat(String(t)):".")}(a))?s:"The launch was refused."}}let n="string"==typeof(null==a?void 0:a.detail)&&a.detail?a.detail:null;return{campaign:e,problems:[],message:null!=n?n:"Could not launch the campaign. Try again."}}function su(e){let{refusal:t,launching:a,onRetry:r,onDismiss:l}=e,[i,o]=(0,n.useState)(null);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ea.lG,{open:null!==t,onOpenChange:e=>!e&&l(),children:(0,s.jsxs)(ea.Cf,{children:[(0,s.jsxs)(ea.c7,{children:[(0,s.jsxs)(ea.L3,{children:["Could not launch ",null==t?void 0:t.campaign.name]}),(0,s.jsx)(ea.rr,{children:"Fix what is below, then launch again."})]}),t&&t.problems.length>0&&(0,s.jsx)("ul",{role:"alert",className:"space-y-3 rounded-md border border-destructive/50 p-3 text-sm",children:t.problems.map((e,t)=>{if("INSUFFICIENT_CREDITS"===e.code){var a;let n=null==(a=e.details)?void 0:a.balance;return(0,s.jsxs)("li",{className:"space-y-2",children:[(0,s.jsxs)("p",{children:[e.message,null!=n&&(0,s.jsxs)(s.Fragment,{children:[" Current balance: ",String(n),"."]})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:(0,s.jsx)(d.$,{asChild:!0,size:"sm",variant:"outline",children:(0,s.jsx)(eI(),{href:"/usage",children:"Request credits"})})})]},t)}return"MISSING_SECRETS"===e.code?(0,s.jsxs)("li",{className:"space-y-2",children:[(0,s.jsx)("p",{children:e.message}),(0,s.jsx)("ul",{className:"space-y-1",children:(function(e){var t;let a=null==(t=e.details)?void 0:t.names;return Array.isArray(a)?a.map(String):[]})(e).map(e=>(0,s.jsxs)("li",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("code",{children:e}),(0,s.jsx)(d.$,{size:"sm",variant:"outline",onClick:()=>o(e),"aria-label":"Add secret ".concat(e),children:"Add secret"})]},e))})]},t):(0,s.jsx)("li",{children:e.message},t)})}),(null==t?void 0:t.message)&&(0,s.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:t.message}),(0,s.jsxs)(ea.Es,{children:[(0,s.jsx)(d.$,{variant:"outline",onClick:l,children:"Cancel"}),(0,s.jsx)(d.$,{onClick:()=>t&&r(t.campaign),disabled:a,children:a?"Launching…":"Launch again"})]})]})}),(0,s.jsx)(so.q,{open:null!==i,onOpenChange:e=>{e||o(null)},presetName:null!=i?i:void 0,onSaved:()=>{o(null),t&&r(t.campaign)}})]})}function sm(e){let{campaign:t,refreshToken:a,onOpen:r}=e,l=t.id,[i,o]=(0,n.useState)(void 0);return((0,n.useEffect)(()=>{let e=!1;return u.ME.runList({campaign:l,parentIsnull:!0,pageSize:1}).then(t=>{var a,s;e||o(null!=(s=null==(a=t.results)?void 0:a[0])?s:null)}).catch(()=>{e||o(null)}),()=>{e=!0}},[l,a]),void 0===i)?(0,s.jsx)(S.E,{className:"h-4 w-24"}):null===i?(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"Never run"}):(0,s.jsx)("button",{type:"button",className:"flex items-center gap-1.5 rounded-sm text-left text-xs text-muted-foreground hover:text-foreground","aria-label":"Open the last run of ".concat(t.name),onClick:()=>r(i.id),children:(0,s.jsx)(Q.E,{variant:"outline",children:a2(i)})})}function sx(e){let{campaigns:t,loading:a,error:n,selectedId:r,techniqueLabels:l={},agentNames:i={},refreshToken:o,onSelect:u,onOpenRun:m,onNew:x,onDuplicate:p,onDelete:h}=e;return(0,s.jsxs)("aside",{"aria-label":"Saved campaigns",className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-sm font-semibold",children:"Saved campaigns"}),(0,s.jsxs)(d.$,{size:"sm",variant:"outline",onClick:x,children:[(0,s.jsx)(H.A,{className:"mr-1 h-4 w-4"}),"New campaign"]})]}),n&&(0,s.jsx)(c.Fc,{variant:"destructive",children:(0,s.jsx)(c.TN,{children:n})}),a?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(S.E,{className:"h-20 w-full"}),(0,s.jsx)(S.E,{className:"h-20 w-full"})]}):n||0!==t.length?(0,s.jsx)("ul",{className:"space-y-2",children:t.map(e=>{var t;let a=(function(e){var t;let a=null==(t=e.spec)?void 0:t.attacks;return Array.isArray(a)?a.map(e=>e&&"object"==typeof e?e.name:void 0).filter(e=>"string"==typeof e):[]})(e).map(e=>{var t;return null!=(t=l[e])?t:e}),n=e.id===r;return(0,s.jsxs)("li",{className:"rounded-md border p-3 ".concat(n?"border-primary bg-accent/40":""),children:[(0,s.jsxs)("button",{type:"button",className:"block w-full space-y-1 text-left","aria-current":n?"true":void 0,"aria-label":"Open ".concat(e.name),onClick:()=>u(e),children:[(0,s.jsx)("span",{className:"block truncate text-sm font-medium",children:e.name}),(0,s.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:null!=(t=i[e.agent])?t:"Unknown agent"}),a.length>0&&(0,s.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:a.join(", ")})]}),(0,s.jsxs)("div",{className:"mt-2 flex items-center gap-1",children:[(0,s.jsx)("span",{className:"mr-auto min-w-0",children:(0,s.jsx)(sm,{campaign:e,refreshToken:o,onOpen:t=>m(e,t)})}),(0,s.jsx)(d.$,{size:"sm",variant:"ghost","aria-label":"Duplicate ".concat(e.name),onClick:()=>p(e),children:(0,s.jsx)(eY.A,{className:"h-4 w-4"})}),(0,s.jsx)(d.$,{size:"sm",variant:"ghost","aria-label":"Delete ".concat(e.name),onClick:()=>h(e),children:(0,s.jsx)(G.A,{className:"h-4 w-4"})})]})]},e.id)})}):(0,s.jsx)(Y.p,{icon:W.A,title:"No saved campaigns",description:"Build a campaign and save it to run it again later."})]})}function sp(){var e;let t=(0,r.useRouter)(),a=(0,r.useSearchParams)(),x=a.get("campaign"),p=a.get("runId"),[h,g]=(0,n.useState)([]),[f,j]=(0,n.useState)([]),[v,b]=(0,n.useState)({}),[N,y]=(0,n.useState)(!0),[k,w]=(0,n.useState)(null),[A,_]=(0,n.useState)(null),[C,S]=(0,n.useState)(null),[E,R]=(0,n.useState)(!1),[T,O]=(0,n.useState)(null),[L,I]=(0,n.useState)(0),[z,M]=(0,n.useState)(0),J=(0,n.useCallback)(async()=>{try{g(await (0,m.i)(e=>u.Bm.campaignList({page:e}))),w(null)}catch(e){w("Could not load saved campaigns.")}finally{y(!1)}},[]);(0,n.useEffect)(()=>{J(),(0,m.i)(e=>u.in.agentList({page:e})).then(j).catch(()=>{}),u.Bm.campaignTechniquesList().then(e=>b(Object.fromEntries(e.map(e=>[e.attackType,e.label])))).catch(()=>{})},[J]);let P=(0,n.useMemo)(()=>Object.fromEntries(f.map(e=>[e.id,e.name])),[f]);(0,n.useEffect)(()=>{_(null)},[x,p]),(0,n.useEffect)(()=>{if(!E)return;let e=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[E]);let D=e=>{E?O(()=>e):e()},F=(0,n.useCallback)((e,a)=>{let s=new URLSearchParams;e&&s.set("campaign",e),a&&s.set("runId",a);let n=s.toString();t.push(n?"/attacks?".concat(n):"/attacks")},[t]),{launch:U,launching:q,refusal:H,dismiss:B}=function(e){let[t,a]=(0,n.useState)(!1),[s,r]=(0,n.useState)(null),l=(0,n.useRef)(!1);return{launch:(0,n.useCallback)(async t=>{let s;if(!l.current){l.current=!0,a(!0);try{s=await u.Bm.campaignLaunchCreate({id:t.id,launchRequest:{}})}catch(e){r(await sd(t,e));return}finally{l.current=!1,a(!1)}r(null),e(t,s)}},[e]),launching:t,refusal:s,dismiss:()=>r(null)}}((0,n.useCallback)((e,t)=>F(e.id,t.id),[F])),$=async e=>{let t;try{var a;t=null!=(a=h.find(t=>t.id===e))?a:await u.Bm.campaignRetrieve({id:e})}catch(e){_("Could not open the campaign to run it again.");return}await U(t)},G=async e=>{try{let t=await u.Bm.campaignCreate({campaignRequest:{name:"".concat(e.name," (copy)"),description:e.description,agent:e.agent,spec:e.spec}});await J(),F(t.id)}catch(e){_("Could not duplicate the campaign.")}},W=async e=>{try{await u.Bm.campaignDestroy({id:e.id}),e.id===x&&F(null),await J()}catch(e){_("Could not delete the campaign.")}};return(0,s.jsxs)(o.M,{title:"Campaigns",description:"Build a campaign, launch it and follow the results.",children:[(0,s.jsxs)("div",{className:"grid gap-6 px-6 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[(0,s.jsx)(sx,{campaigns:h,loading:N,error:k,selectedId:x,techniqueLabels:v,agentNames:P,refreshToken:"".concat(null!=p?p:"",":").concat(z),onSelect:e=>{(e.id!==x||p)&&D(()=>F(e.id))},onOpenRun:(e,t)=>D(()=>F(e.id,t)),onNew:()=>{x||p?D(()=>F(null)):E&&D(()=>I(e=>e+1))},onDuplicate:e=>D(()=>void G(e)),onDelete:S}),(0,s.jsxs)("section",{className:"min-w-0 space-y-4",children:[A&&(0,s.jsxs)(c.Fc,{role:"status",className:"flex items-start justify-between gap-2",children:[(0,s.jsx)(c.TN,{children:A}),(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"-my-1 h-6 w-6 shrink-0","aria-label":"Dismiss",onClick:()=>_(null),children:(0,s.jsx)(l.A,{className:"h-4 w-4"})})]}),p?(0,s.jsx)(si,{runId:p,onBack:()=>F(x),onRunAgain:e=>void $(e),launching:q,onFinished:()=>M(e=>e+1)},p):(0,s.jsx)(eZ,{campaignId:x,onDirtyChange:R,onSaved:e=>{J(),e.id!==x&&F(e.id)},onLaunchRequested:e=>void U(e),launching:q},L)]})]}),(0,s.jsx)(su,{refusal:H,launching:q,onRetry:e=>void U(e),onDismiss:B}),(0,s.jsx)(i.T,{open:null!==T,onOpenChange:e=>!e&&O(null),title:"Discard unsaved changes?",description:"This campaign has changes that are not saved. Leaving it discards them.",confirmText:"Discard changes",cancelText:"Keep editing",variant:"destructive",onConfirm:()=>null==T?void 0:T()}),(0,s.jsx)(i.T,{open:null!==C,onOpenChange:e=>!e&&S(null),title:"Delete campaign",description:"Delete ".concat(null!=(e=null==C?void 0:C.name)?e:"","? Its past runs are kept."),confirmText:"Delete",variant:"destructive",onConfirm:()=>{C&&W(C)}})]})}function sh(){return(0,s.jsx)(n.Suspense,{fallback:null,children:(0,s.jsx)(sp,{})})}},97145:(e,t,a)=>{"use strict";a.d(t,{y:()=>c});var s=a(12115),n=a(41444);function r(e){return{authProvider:e.disableAuth?"disabled":"auth0"===e.authProvider||"keycloak"===e.authProvider||"disabled"===e.authProvider?e.authProvider:e.auth0Domain&&e.auth0ClientId?"auth0":"keycloak",auth0Domain:e.auth0Domain||"",auth0ClientId:e.auth0ClientId||"",auth0Audience:e.auth0Audience||"",auth0RedirectUri:e.auth0RedirectUri||"",keycloakRealmUrl:e.keycloakRealmUrl||"",keycloakClientId:e.keycloakClientId||"",apiUrl:e.apiUrl||""}}a(95704);var l=a(95704);let i=(0,n.h)("useRuntimeConfig"),o=r({authProvider:l.env.NEXT_PUBLIC_AUTH_PROVIDER,auth0Domain:l.env.NEXT_PUBLIC_AUTH0_DOMAIN,auth0ClientId:l.env.NEXT_PUBLIC_AUTH0_CLIENT_ID,auth0Audience:l.env.NEXT_PUBLIC_AUTH0_AUDIENCE,auth0RedirectUri:l.env.NEXT_PUBLIC_AUTH0_REDIRECT_URI,keycloakRealmUrl:l.env.NEXT_PUBLIC_KEYCLOAK_REALM_URL||"",keycloakClientId:l.env.NEXT_PUBLIC_KEYCLOAK_CLIENT_ID||"",apiUrl:l.env.NEXT_PUBLIC_API_URL||"",disableAuth:!0});function c(){let[e,t]=(0,s.useState)(o),[a,n]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{(async()=>{try{let e=await fetch("/config.json");if(!e.ok)throw Error("Failed to load config: ".concat(e.status));let a=r(await e.json());i.info("Runtime config loaded successfully"),t(a)}catch(e){i.warn("Failed to load runtime config, using build-time defaults"),t(o)}finally{n(!1)}})()},[]),{config:e,isLoading:a}}}},e=>{e.O(0,[187,272,619,870,389,658,592,888,160,764,924,634,452,441,493,358],()=>e(e.s=3549)),_N_E=e.O()}]);