PageSourceSearch

https://delivr.to/assets/CampaignResults-BLJQQnj0.js

js delivr.to collected 2026-09-25 19:12:20 UTC 265,024 bytes, 11 lines download raw bytes

1import{u as st,a as Ht,b as vt,k as ci,j as n}from"./query-DmstuUoN.js";import{d as K,g as _r,a as E,b as Da,h as Ta,i as di,l as Ra,L as ar,c as Ma}from"./vendor-CHI41uxr.js";import{c as be,a4 as it,B as G,b as _e,m as se,n as ie,o as ae,t as wt,v as bt,w as jt,x as xe,I as Nr,X as ui,H as W,T as kr,a5 as Sr,k as wn,D as $e,d as ze,e as Le,f as Be,g as qe,O as or,L as Oa,y as ue,E as he,z as Ce,A as Ae,l as Jt,a2 as Ia,h as Cr,_ as Pa,u as Fa,F as $a,a6 as ts,a3 as hi,s as za,J as La,U as Ba}from"./index-CT7kTiav.js";import{B as De}from"./badge-CIRiQWe_.js";import{L as fi,S as qa}from"./switch-Toae-IaB.js";import{L as Ar,T as Ha,a as Ua,b as ns,c as rs}from"./tabs-CLdUJLBs.js";import{C as bn}from"./checkbox-CcaDavml.js";import{S as at}from"./ServiceIcon-CrwT3mpk.js";import{S as Er,a as Dr,b as Va,c as Tr,d as Rr}from"./select-rx-Gp2-j.js";import{A as Wa,a as Ga,b as Ka,c as Ja,d as Ya,e as Xa,f as Za,g as Qa}from"./alert-dialog-DQgxaHUn.js";import{P as Mr}from"./PayloadDetailModal-d_rZHTmv.js";import{C as lr}from"./clock-c878Mt3R.js";import{S as Ve}from"./shield-CsgJ5rrZ.js";import{M as cr}from"./mouse-pointer-BjUa1v8Z.js";import{M as mi}from"./more-horizontal-C_pwGMBH.js";import{C as _t,T as Nt,a as sn,b as we,c as oe,d as kt,e as ee}from"./table-B-i1Qc_g.js";import{i as mt,f as pe,r as pi,b as eo,c as xi,d as to,e as Ue,g as Or,p as Xe,h as Pe,j as gi,k as Ir,l as yi,m as no,C as ro,n as Ot,o as Tt,S as so,q as io,s as ao,t as ss,u as oo,v as Se,w as lo,x as co,y as uo,z as mn,B as ho,E as vi,F as fo,H as ln,I as jn,J as mo,K as po,M as xo,N as go,O as yo,P as wi,Q as bi,U as ji,V as _i,W as Ni,Z as en,X as Rn,Y as Mn,_ as vo,$ as wo,D as de,R as On,T as In,L as Pn,A as bo,a as Jn,a0 as is,a1 as jo,a2 as as,a3 as _o,G as dr}from"./AreaChart-BbjuXgQC.js";import{M as Fn}from"./mail-D42Ko5db.js";import{P as ki,M as Pr,a as Fr,p as Yn}from"./QuickSendModal-fc8TmXFK.js";import{h as Oe,a as No,b as ko,C as Si,I as Ci,W as Ai,d as Ei,e as Di,f as Ti}from"./IntegrationIcons-Cy2UT7kj.js";import{A as Ri}from"./alert-circle-Bk1rTHL-.js";import{E as $n}from"./external-link-toS3VXTH.js";import{T as Mi}from"./textarea-Dsn3FwXX.js";import{b as So,c as Co}from"./usePayloads-Bkjkf-Fq.js";import{downloadChartAsPng as ur,getDateString as os}from"./download-Cy4RHPTg.js";import{L as hr}from"./loader-2-DBtHWqj4.js";import{I as _n}from"./info-Bh9sgHOw.js";import{P as Ao}from"./plus-D-Rv8PQG.js";import{M as Eo}from"./FileTypeIcon-C0ONCHbU.js";import{u as Do}from"./useDocumentTitle-BOGfSQQj.js";import{C as To}from"./check-circle-CiD2n8E-.js";import"./ui-WgsiDFN4.js";import"./trending-up-BJitD4Ir.js";import"./trash-2-e27I1N9K.js";const ls=be("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const Ro=be("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);const Mo=be("Focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);const Oo=be("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const Io=be("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);const Po=be("MapPin",[["path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z",key:"2oe9fu"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);const Oi=be("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Fo=be("MousePointerClick",[["path",{d:"m9 9 5 12 1.8-5.2L21 14Z",key:"1b76lo"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}]]);const $o=be("PieChart",[["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}],["path",{d:"M22 12A10 10 0 0 0 12 2v10z",key:"1rfc4y"}]]);const zo=be("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const Lo=be("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const Ii=be("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);const Pi=be("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);const Bo=be("Triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);const qo=be("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);const Ho=be("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function Uo(e,t){return st({queryKey:["campaign",e,"details"],queryFn:()=>Oe.get(e),enabled:!!e,refetchInterval:t?.autoRefresh?1e4:!1,placeholderData:ci})}function Vo(e,t){return st({queryKey:["campaign",e,"related"],queryFn:()=>Oe.getRelated(e),enabled:!!e,refetchInterval:t?.autoRefresh?1e4:!1,placeholderData:ci})}function Wo(e){return st({queryKey:["campaign",e?.campaign_id,"insights"],queryFn:()=>Oe.getInsights(e),enabled:!!e,staleTime:3e4})}function Go(e){return st({queryKey:["campaign",e?.campaign_id,"recommendations"],queryFn:()=>Oe.getRecommendations(e),enabled:!!e,staleTime:3e4})}function Ko(e){const t=Ht();return vt({mutationFn:({emailId:r,status:s})=>Oe.updateEmailStatus(e,r,s),onSuccess:()=>{t.invalidateQueries({queryKey:["campaign",e,"details"]}
1),t.invalidateQueries({queryKey:["campaign",e,"related"]})}})}function Jo(e){const t=Ht();return vt({mutationFn:r=>Oe.bulkUpdateEmailStatus(e,r),onSuccess:()=>{t.invalidateQueries({queryKey:["campaign",e,"details"]}),t.invalidateQueries({queryKey:["campaign",e,"related"]})}})}function Yo(e,t,r=!1){return st({queryKey:["campaign",e,"email",t,"eml"],queryFn:()=>Oe.getEml(e,t),enabled:r&&!!e&&!!t})}function Xo(e){const t=Ht();return vt({mutationFn:()=>Oe.rerunIntegrations(e),onSuccess:()=>{t.invalidateQueries({queryKey:["campaign",e,"details"]})}})}function Zo(e){return vt({mutationFn:async t=>{const{blob:r,filename:s}=await Oe.downloadReport(e,t),i=URL.createObjectURL(r),a=document.createElement("a");return a.href=i,a.download=s,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),s}})}function Qo(e){const t=Ht();return vt({mutationFn:()=>Oe.completeCampaign(e),onSuccess:()=>{t.invalidateQueries({queryKey:["campaign",e,"details"]}),t.invalidateQueries({queryKey:["campaigns"]})}})}function el(e){const t=Ht();return vt({mutationFn:r=>Oe.extendCampaign(e,r),onSuccess:()=>{t.invalidateQueries({queryKey:["campaign",e,"details"]}),t.invalidateQueries({queryKey:["campaigns"]})}})}function tl(e){const t=Ht();return vt({mutationFn:({linkId:r,status:s})=>Oe.reportLinkStatus(r,s),onSuccess:()=>{t.invalidateQueries({queryKey:["campaign",e,"details"]})}})}var cs=180/Math.PI,fr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fi(e,t,r,s,i,a){var o,l,u;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(u=e*r+t*s)&&(r-=e*u,s-=t*u),(l=Math.sqrt(r*r+s*s))&&(r/=l,s/=l,u/=l),e*s<t*r&&(e=-e,t=-t,u=-u,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*cs,skewX:Math.atan(u)*cs,scaleX:o,scaleY:l}}var cn;function nl(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?fr:Fi(t.a,t.b,t.c,t.d,t.e,t.f)}function rl(e){return e==null||(cn||(cn=document.createElementNS("http://www.w3.org/2000/svg","g")),cn.setAttribute("transform",e),!(e=cn.transform.baseVal.consolidate()))?fr:(e=e.matrix,Fi(e.a,e.b,e.c,e.d,e.e,e.f))}function $i(e,t,r,s){function i(c){return c.length?c.pop()+" ":""}function a(c,h,w,y,v,S){if(c!==w||h!==y){var j=v.push("translate(",null,t,null,r);S.push({i:j-4,x:mt(c,w)},{i:j-2,x:mt(h,y)})}else(w||y)&&v.push("translate("+w+t+y+r)}function o(c,h,w,y){c!==h?(c-h>180?h+=360:h-c>180&&(c+=360),y.push({i:w.push(i(w)+"rotate(",null,s)-2,x:mt(c,h)})):h&&w.push(i(w)+"rotate("+h+s)}function l(c,h,w,y){c!==h?y.push({i:w.push(i(w)+"skewX(",null,s)-2,x:mt(c,h)}):h&&w.push(i(w)+"skewX("+h+s)}function u(c,h,w,y,v,S){if(c!==w||h!==y){var j=v.push(i(v)+"scale(",null,",",null,")");S.push({i:j-4,x:mt(c,w)},{i:j-2,x:mt(h,y)})}else(w!==1||y!==1)&&v.push(i(v)+"scale("+w+","+y+")")}return function(c,h){var w=[],y=[];return c=e(c),h=e(h),a(c.translateX,c.translateY,h.translateX,h.translateY,w,y),o(c.rotate,h.rotate,w,y),l(c.skewX,h.skewX,w,y),u(c.scaleX,c.scaleY,h.scaleX,h.scaleY,w,y),c=h=null,function(v){for(var S=-1,j=y.length,b;++S<j;)w[(b=y[S]).i]=b.x(v);return w.join("")}}}var sl=$i(nl,"px, ","px)","deg)"),il=$i(rl,", ",")",")"),al=1e-12;function ds(e){return((e=Math.exp(e))+1/e)/2}function ol(e){return((e=Math.exp(e))-1/e)/2}function ll(e){return((e=Math.exp(2*e))-1)/(e+1)}const cl=(function e(t,r,s){function i(a,o){var l=a[0],u=a[1],c=a[2],h=o[0],w=o[1],y=o[2],v=h-l,S=w-u,j=v*v+S*S,b,p;if(j<al)p=Math.log(y/c)/t,b=function(M){return[l+M*v,u+M*S,c*Math.exp(t*M*p)]};else{var m=Math.sqrt(j),f=(y*y-c*c+s*j)/(2*c*r*m),d=(y*y-c*c-s*j)/(2*y*r*m),x=Math.log(Math.sqrt(f*f+1)-f),g=Math.log(Math.sqrt(d*d+1)-d);p=(g-x)/t,b=function(M){var P=M*p,q=ds(x),k=c/(r*m)*(q*ll(t*P+x)-ol(x));return[l+k*v,u+k*S,c*q/ds(t*P+x)]}}return b.duration=p*1e3*t/Math.SQRT2,b}return i.rho=function(a){var o=Math.max(.001,+a),l=o*o,u=l*l;return e(o,l,u)},i})(Math.SQRT2,2,4);var dl=["points","className","baseLinePoints","connectNulls"];function Rt(){return Rt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];
vendor: 24,387 bytes, lines 1-2
1for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Rt.apply(this,arguments)}function ul(e,t){if(e==null)return{};var r=hl(e,t),s,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)s=a[i],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function hl(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function us(e){return xl(e)||pl(e)||ml(e)||fl()}function fl(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ml(e,t){if(e){if(typeof e=="string")return mr(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return mr(e,t)}}function pl(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function xl(e){if(Array.isArray(e))return mr(e)}function mr(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}var hs=function(t){return t&&t.x===+t.x&&t.y===+t.y},gl=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return t.forEach(function(s){hs(s)?r[r.length-1].push(s):r[r.length-1].length>0&&r.push([])}),hs(t[0])&&r[r.length-1].push(t[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},Zt=function(t,r){var s=gl(t);r&&(s=[s.reduce(function(a,o){return[].concat(us(a),us(o))},[])]);var i=s.map(function(a){return a.reduce(function(o,l,u){return"".concat(o).concat(u===0?"M":"L").concat(l.x,",").concat(l.y)},"")}).join("");return s.length===1?"".concat(i,"Z"):i},yl=function(t,r,s){var i=Zt(t,s);return"".concat(i.slice(-1)==="Z"?i.slice(0,-1):i,"L").concat(Zt(r.reverse(),s).slice(1))},vl=function(t){var r=t.points,s=t.className,i=t.baseLinePoints,a=t.connectNulls,o=ul(t,dl);if(!r||!r.length)return null;var l=it("recharts-polygon",s);if(i&&i.length){var u=o.stroke&&o.stroke!=="none",c=yl(r,i,a);return K.createElement("g",{className:l},K.createElement("path",Rt({},pe(o,!0),{fill:c.slice(-1)==="Z"?o.fill:"none",stroke:"none",d:c})),u?K.createElement("path",Rt({},pe(o,!0),{fill:"none",d:Zt(r,a)})):null,u?K.createElement("path",Rt({},pe(o,!0),{fill:"none",d:Zt(i,a)})):null)}var h=Zt(r,a);return K.createElement("path",Rt({},pe(o,!0),{fill:h.slice(-1)==="Z"?o.fill:"none",className:l,d:h}))},Xn,fs;function wl(){if(fs)return Xn;fs=1;var e=pi(),t=eo(),r=xi();function s(i,a){return i&&i.length?e(i,r(a,2),t):void 0}return Xn=s,Xn}var bl=wl();const jl=_r(bl);var Zn,ms;function _l(){if(ms)return Zn;ms=1;var e=pi(),t=xi(),r=to();function s(i,a){return i&&i.length?e(i,t(a,2),r):void 0}return Zn=s,Zn}var Nl=_l();const kl=_r(Nl);var Sl=["cx","cy","angle","ticks","axisLine"],Cl=["ticks","tick","angle","tickFormatter","stroke"];function Ft(e){"@babel/helpers - typeof";return Ft=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ft(e)}function Qt(){return Qt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Qt.apply(this,arguments)}function ps(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,s)}return r}function ut(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ps(Object(r),!0).forEach(function(s){zn(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ps(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function xs(e,t){if(e==null)return{};var r=Al(e,t),s,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)s=a[i],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function Al(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function El(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function gs(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,Li(s.key),s)}}function Dl(e,t,r){return t&&gs(e.prototype,t),r&&gs(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Tl(e,t,r){return t=Nn(t),Rl(e,zi()?Reflect.construct(t,r||[],Nn(e).constructor):t.apply(e,r))}function Rl(e,t){if(t&&(Ft(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ml(e)}function Ml(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function zi(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(zi=function(){return!!e})()}function Nn(e){return Nn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Nn(e)}function Ol(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&pr(e,t)}function pr(e,t){return pr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,i){return s.__proto__=i,s},pr(e,t)}function zn(e,t,r){return t=Li(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Li(e){var t=Il(e,"string");return Ft(t)=="symbol"?t:t+""}function Il(e,t){if(Ft(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t);if(Ft(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Ln=(function(e){function t(){return El(this,t),Tl(this,t,arguments)}return Ol(t,e),Dl(t,[{key:"getTickValueCoord",value:function(s){var i=s.coordinate,a=this.props,o=a.angle,l=a.cx,u=a.cy;return Xe(l,u,i,o)}},{key:"getTickTextAnchor",value:function(){var s=this.props.orientation,i;switch(s){case"left":i="end";break;case"right":i="start";break;default:i="middle";break}return i}},{key:"getViewBox",value:function(){var s=this.props,i=s.cx,a=s.cy,o=s.angle,l=s.ticks,u=jl(l,function(h){return h.coordinate||0}),c=kl(l,function(h){return h.coordinate||0});return{cx:i,cy:a,startAngle:o,endAngle:o,innerRadius:c.coordinate||0,outerRadius:u.coordinate||0}}},{key:"renderAxisLine",value:function(){var s=this.props,i=s.cx,a=s.cy,o=s.angle,l=s.ticks,u=s.axisLine,c=xs(s,Sl),h=l.reduce(function(S,j){return[Math.min(S[0],j.coordinate),Math.max(S[1],j.coordinate)]},[1/0,-1/0]),w=Xe(i,a,h[0],o),y=Xe(i,a,h[1],o),v=ut(ut(ut({},pe(c,!1)),{},{fill:"none"},pe(u,!1)),{},{x1:w.x,y1:w.y,x2:y.x,y2:y.y});return K.createElement("line",Qt({className:"recharts-polar-radius-axis-line"},v))}},{key:"renderTicks",value:function(){var s=this,i=this.props,a=i.ticks,o=i.tick,l=i.angle,u=i.tickFormatter,c=i.stroke,h=xs(i,Cl),w=this.getTickTextAnchor(),y=pe(h,!1),v=pe(o,!1),S=a.map(function(j,b){var p=s.getTickValueCoord(j),m=ut(ut(ut(ut({textAnchor:w,transform:"rotate(".concat(90-l,", ").concat(p.x,", ").concat(p.y,")")},y),{},{stroke:"none",fill:c},v),{},{index:b},p),{},{payload:j});return K.createElement(Pe,Qt({className:it("recharts-polar-radius-axis-tick",gi(o)),key:"tick-".concat(j.coordinate)},Ir(s.props,j,b)),t.renderTickItem(o,m,u?u(j.value,b):j.value))});return K.createElement(Pe,{className:"recharts-polar-radius-axis-ticks"},S)}},{key:"render",value:function(){var s=this.props,i=s.ticks,a=s.axisLine,o=s.tick;return!i||!i.length?null:K.createElement(Pe,{className:it("recharts-polar-radius-axis",this.props.className)},a&&this.renderAxisLine(),o&&this.renderTicks(),yi.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(s,i,a){var o;return K.isValidElement(s)?o=K.cloneElement(s,i):Ue(s)?o=s(i):o=K.createElement(Or,Qt({},i,{className:"recharts-polar-radius-axis-tick-value"}),a),o}}])})(E.PureComponent);zn(Ln,"displayName","PolarRadiusAxis");zn(Ln,"axisType","radiusAxis");zn(Ln,"defaultProps",{type:"number",radiusAxisId:0,cx:0,cy:0,angle:0,orientation:"right",stroke:"#ccc",axisLine:!0,tick:!0,tickCount:5,allowDataOverflow:!1,scale:"auto",allowDuplicatedCategory:!0});function $t(e){"@babel/helpers - typeof";return $t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$t(e)}function pt(){return pt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},pt.apply(this,arguments)}function ys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,s)}return r}function ht(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ys(Object(r),!0).forEach(function(s){Bn(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ys(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function Pl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function vs(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,qi(s.key),s)}}function Fl(e,t,r){return t&&vs(e.prototype,t),r&&vs(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function $l(e,t,r){return t=kn(t),zl(e,Bi()?Reflect.construct(t,r||[],kn(e).constructor):t.apply(e,r))}function zl(e,t){if(t&&($t(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ll(e)}function Ll(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Bi(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Bi=function(){return!!e})()}function kn(e){return kn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},kn(e)}function Bl(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&xr(e,t)}function xr(e,t){return xr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,i){return s.__proto__=i,s},xr(e,t)}function Bn(e,t,r){return t=qi(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qi(e){var t=ql(e,"string");return $t(t)=="symbol"?t:t+""}function ql(e,t){if($t(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t);if($t(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Hl=Math.PI/180,ws=1e-5,qn=(function(e){function t(){return Pl(this,t),$l(this,t,arguments)}return Bl(t,e),Fl(t,[{key:"getTickLineCoord",value:function(s){var i=this.props,a=i.cx,o=i.cy,l=i.radius,u=i.orientation,c=i.tickSize,h=c||8,w=Xe(a,o,l,s.coordinate),y=Xe(a,o,l+(u==="inner"?-1:1)*h,s.coordinate);return{x1:w.x,y1:w.y,x2:y.x,y2:y.y}}},{key:"getTickTextAnchor",value:function(s){var i=this.props.orientation,a=Math.cos(-s.coordinate*Hl),o;return a>ws?o=i==="outer"?"start":"end":a<-ws?o=i==="outer"?"end":"start":o="middle",o}},{key:"renderAxisLine",value:function(){var s=this.props,i=s.cx,a=s.cy,o=s.radius,l=s.axisLine,u=s.axisLineType,c=ht(ht({},pe(this.props,!1)),{},{fill:"none"},pe(l,!1));if(u==="circle")return K.createElement(no,pt({className:"recharts-polar-angle-axis-line"},c,{cx:i,cy:a,r:o}));var h=this.props.ticks,w=h.map(function(y){return Xe(i,a,o,y.coordinate)});return K.createElement(vl,pt({className:"recharts-polar-angle-axis-line"},c,{points:w}))}},{key:"renderTicks",value:function(){var s=this,i=this.props,a=i.ticks,o=i.tick,l=i.tickLine,u=i.tickFormatter,c=i.stroke,h=pe(this.props,!1),w=pe(o,!1),y=ht(ht({},h),{},{fill:"none"},pe(l,!1)),v=a.map(function(S,j){var b=s.getTickLineCoord(S),p=s.getTickTextAnchor(S),m=ht(ht(ht({textAnchor:p},h),{},{stroke:"none",fill:c},w),{},{index:j,payload:S,x:b.x2,y:b.y2});return K.createElement(Pe,pt({className:it("recharts-polar-angle-axis-tick",gi(o)),key:"tick-".concat(S.coordinate)},Ir(s.props,S,j)),l&&K.createElement("line",pt({className:"recharts-polar-angle-axis-tick-line"},y,b)),o&&t.renderTickItem(o,m,u?u(S.value,j):S.value))});return K.createElement(Pe,{className:"recharts-polar-angle-axis-ticks"},v)}},{key:"render",value:function(){var s=this.props,i=s.ticks,a=s.radius,o=s.axisLine;return a<=0||!i||!i.length?null:K.createElement(Pe,{className:it("recharts-polar-angle-axis",this.props.className)},o&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(s,i,a){var o;return K.isValidElement(s)?o=K.cloneElement(s,i):Ue(s)?o=s(i):o=K.createElement(Or,pt({},i,{className:"recharts-polar-angle-axis-tick-value"}),a),o}}])})(E.PureComponent);Bn(qn,"displayName","PolarAngleAxis");Bn(qn,"axisType","angleAxis");Bn(qn,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var pn;function zt(e){"@babel/helpers - typeof";return zt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zt(e)}function Mt(){return Mt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Mt.apply(this,arguments)}function bs(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,s)}return r}function re(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?bs(Object(r),!0).forEach(function(s){Me(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bs(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function Ul(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function js(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,Ui(s.key),s)}}function Vl(e,t,r){return t&&js(e.prototype,t),r&&js(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Wl(e,t,r){return t=Sn(t),Gl(e,Hi()?Reflect.construct(t,r||[],Sn(e).constructor):t.apply(e,r))}function Gl(e,t){if(t&&(zt(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Kl(e)}function Kl(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Hi(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Hi=function(){return!!e})()}function Sn(e){return Sn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Sn(e)}function Jl(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&gr(e,t)}function gr(e,t){return gr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,i){return s.__proto__=i,s},gr(e,t)}function Me(e,t,r){return t=Ui(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ui(e){var t=Yl(e,"string");return zt(t)=="symbol"?t:t+""}function Yl(e,t){if(zt(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t);if(zt(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Qe=(function(e){function t(r){var s;return Ul(this,t),s=Wl(this,t,[r]),Me(s,"pieRef",null),Me(s,"sectorRefs",[]),Me(s,"id",co("recharts-pie-")),Me(s,"handleAnimationEnd",function(){var i=s.props.onAnimationEnd;s.setState({isAnimationFinished:!0}),Ue(i)&&i()}),Me(s,"handleAnimationStart",function(){var i=s.props.onAnimationStart;s.setState({isAnimationFinished:!1}),Ue(i)&&i()}),s.state={isAnimationFinished:!r.isAnimationActive,prevIsAnimationActive:r.isAnimationActive,prevAnimationId:r.animationId,sectorToFocus:0},s}return Jl(t,e),Vl(t,[{key:"isActiveIndex",value:function(s){var i=this.props.activeIndex;return Array.isArray(i)?i.indexOf(s)!==-1:s===i}},{key:"hasActiveIndex",value:function(){var s=this.props.activeIndex;return Array.isArray(s)?s.length!==0:s||s===0}},{key:"renderLabels",value:function(s){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var a=this.props,o=a.label,l=a.labelLine,u=a.dataKey,c=a.valueKey,h=pe(this.props,!1),w=pe(o,!1),y=pe(l,!1),v=o&&o.offsetRadius||20,S=s.map(function(j,b){var p=(j.startAngle+j.endAngle)/2,m=Xe(j.cx,j.cy,j.outerRadius+v,p),f=re(re(re(re({},h),j),{},{stroke:"none"},w),{},{index:b,textAnchor:t.getTextAnchor(m.x,j.cx)},m),d=re(re(re(re({},h),j),{},{fill:"none",stroke:j.fill},y),{},{index:b,points:[Xe(j.cx,j.cy,j.outerRadius,p),m]}),x=u;return Ot(u)&&Ot(c)?x="value":Ot(u)&&(x=c),K.createElement(Pe,{key:"label-".concat(j.startAngle,"-").concat(j.endAngle,"-").concat(j.midAngle,"-").concat(b)},l&&t.renderLabelLineItem(l,d,"line"),t.renderLabelItem(o,f,Tt(j,x)))});return K.createElement(Pe,{className:"recharts-pie-labels"},S)}},{key:"renderSectorsStatically",value:function(s){var i=this,a=this.props,o=a.activeShape,l=a.blendStroke,u=a.inactiveShape;return s.map(function(c,h){if(c?.startAngle===0&&c?.endAngle===0&&s.length!==1)return null;var w=i.isActiveIndex(h),y=u&&i.hasActiveIndex()?u:null,v=w?o:y,S=re(re({},c),{},{stroke:l?c.fill:c.stroke,tabIndex:-1});return K.createElement(Pe,Mt({ref:function(b){b&&!i.sectorRefs.includes(b)&&i.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},Ir(i.props,c,h),{key:"sector-".concat(c?.startAngle,"-").concat(c?.endAngle,"-").concat(c.midAngle,"-").concat(h)}),K.createElement(so,Mt({option:v,isActive:w,shapeType:"sector"},S)))})}},{key:"renderSectorsWithAnimation",value:function(){var s=this,i=this.props,a=i.sectors,o=i.isAnimationActive,l=i.animationBegin,u=i.animationDuration,c=i.animationEasing,h=i.animationId,w=this.state,y=w.prevSectors,v=w.prevIsAnimationActive;return K.createElement(io,{begin:l,duration:u,isActive:o,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(h,"-").concat(v),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(S){var j=S.t,b=[],p=a&&a[0],m=p.startAngle;return a.forEach(function(f,d){var x=y&&y[d],g=d>0?ao(f,"paddingAngle",0):0;if(x){var M=ss(x.endAngle-x.startAngle,f.endAngle-f.startAngle),P=re(re({},f),{},{startAngle:m+g,endAngle:m+M(j)+g});b.push(P),m=P.endAngle}else{var q=f.endAngle,k=f.startAngle,N=ss(0,q-k),O=N(j),I=re(re({},f),{},{startAngle:m+g,endAngle:m+O+g});b.push(I),m=I.endAngle}}),K.createElement(Pe,null,s.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(s){var i=this;s.onkeydown=function(a){if(!a.altKey)switch(a.key){case"ArrowLeft":{var o=++i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[o].focus(),i.setState({sectorToFocus:o});break}case"ArrowRight":{var l=--i.state.sectorToFocus<0?i.sectorRefs.length-1:i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[l].focus(),i.setState({sectorToFocus:l});break}case"Escape":{i.sectorRefs[i.state.sectorToFocus].blur(),i.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var s=this.props,i=s.sectors,a=s.isAnimationActive,o=this.state.prevSectors;return a&&i&&i.length&&(!o||!oo(o,i))?this.renderSectorsWithAnimation():this.renderSectorsStatically(i)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var s=this,i=this.props,a=i.hide,o=i.sectors,l=i.className,u=i.label,c=i.cx,h=i.cy,w=i.innerRadius,y=i.outerRadius,v=i.isAnimationActive,S=this.state.isAnimationFinished;if(a||!o||!o.length||!Se(c)||!Se(h)||!Se(w)||!Se(y))return null;var j=it("recharts-pie",l);return K.createElement(Pe,{tabIndex:this.props.rootTabIndex,className:j,ref:function(p){s.pieRef=p}},this.renderSectors(),u&&this.renderLabels(o),yi.renderCallByParent(this.props,null,!1),(!v||S)&&lo.renderCallByParent(this.props,o,!1))}}],[{key:"getDerivedStateFromProps",value:function(s,i){return i.prevIsAnimationActive!==s.isAnimationActive?{prevIsAnimationActive:s.isAnimationActive,prevAnimationId:s.animationId,curSectors:s.sectors,prevSectors:[],isAnimationFinished:!0}:s.isAnimationActive&&s.animationId!==i.prevAnimationId?{prevAnimationId:s.animationId,curSectors:s.sectors,prevSectors:i.curSectors,isAnimationFinished:!0}:s.sectors!==i.curSectors?{curSectors:s.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(s,i){return s>i?"start":s<i?"end":"middle"}},{key:"renderLabelLineItem",value:function(s,i,a){if(K.isValidElement(s))return K.cloneElement(s,i);if(Ue(s))return s(i);var o=it("recharts-pie-label-line",typeof s!="boolean"?s.className:"");return K.createElement(ro,Mt({},i,{key:a,type:"linear",className:o}))}},{key:"renderLabelItem",value:function(s,i,a){if(K.isValidElement(s))return K.cloneElement(s,i);var o=a;if(Ue(s)&&(o=s(i),K.isValidElement(o)))return o;var l=it("recharts-pie-label-text",typeof s!="boolean"&&!Ue(s)?s.className:"");return K.createElement(Or,Mt({},i,{alignmentBaseline:"middle",className:l}),o)}}])})(E.PureComponent);pn=Qe;Me(Qe,"displayName","Pie");Me(Qe,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!uo.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});Me(Qe,"parseDeltaAngle",function(e,t){var r=mn(t-e),s=Math.min(Math.abs(t-e),360);return r*s});Me(Qe,"getRealPieData",function(e){var t=e.data,r=e.children,s=pe(e,!1),i=ho(r,vi);return t&&t.length?t.map(function(a,o){return re(re(re({payload:a},s),a),i&&i[o]&&i[o].props)}):i&&i.length?i.map(function(a){return re(re({},s),a.props)}):[]});Me(Qe,"parseCoordinateOfPie",function(e,t){var r=t.top,s=t.left,i=t.width,a=t.height,o=fo(i,a),l=s+ln(e.cx,i,i/2),u=r+ln(e.cy,a,a/2),c=ln(e.innerRadius,o,0),h=ln(e.outerRadius,o,o*.8),w=e.maxRadius||Math.sqrt(i*i+a*a)/2;return{cx:l,cy:u,innerRadius:c,outerRadius:h,maxRadius:w}});Me(Qe,"getComposedData",function(e){var t=e.item,r=e.offset,s=t.type.defaultProps!==void 0?re(re({},t.type.defaultProps),t.props):t.props,i=pn.getRealPieData(s);if(!i||!i.length)return null;var a=s.cornerRadius,o=s.startAngle,l=s.endAngle,u=s.paddingAngle,c=s.dataKey,h=s.nameKey,w=s.valueKey,y=s.tooltipType,v=Math.abs(s.minAngle),S=pn.parseCoordinateOfPie(s,r),j=pn.parseDeltaAngle(o,l),b=Math.abs(j),p=c;Ot(c)&&Ot(w)?(jn(!1,`Use "dataKey" to specify the value of pie,
3      the props "valueKey" will be deprecated in 1.1.0`),p="value"):Ot(c)&&(jn(!1,`Use "dataKey" to specify the value of pie,
4      the props "valueKey" will be deprecated in 1.1.0`),p=w);var m=i.filter(function(P){return Tt(P,p,0)!==0}).length,f=(b>=360?m:m-1)*u,d=b-m*v-f,x=i.reduce(function(P,q){var k=Tt(q,p,0);return P+(Se(k)?k:0)},0),g;if(x>0){var M;g=i.map(function(P,q){var k=Tt(P,p,0),N=Tt(P,h,q),O=(Se(k)?k:0)/x,I;q?I=M.endAngle+mn(j)*u*(k!==0?1:0):I=o;var _=I+mn(j)*((k!==0?v:0)+O*d),T=(I+_)/2,C=(S.innerRadius+S.outerRadius)/2,R=[{name:N,value:k,payload:P,dataKey:p,type:y}],D=Xe(S.cx,S.cy,C,T);return M=re(re(re({percent:O,cornerRadius:a,name:N,tooltipPayload:R,midAngle:T,middleRadius:C,tooltipPosition:D},P),S),{},{value:Tt(P,p),startAngle:I,endAngle:_,payload:P,paddingAngle:mn(j)*u}),M})}return re(re({},S),{},{sectors:g,data:i})});var Xl=["x1","y1","x2","y2","key"],Zl=["offset"];function gt(e){"@babel/helpers - typeof";return gt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gt(e)}function _s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,s)}return r}function ve(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_s(Object(r),!0).forEach(function(s){Ql(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_s(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function Ql(e,t,r){return t=ec(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ec(e){var t=tc(e,"string");return gt(t)=="symbol"?t:t+""}function tc(e,t){if(gt(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t);if(gt(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function xt(){return xt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];
vendor: 4,496 bytes, line 4
4for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},xt.apply(this,arguments)}function Ns(e,t){if(e==null)return{};var r=nc(e,t),s,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)s=a[i],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function nc(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var rc=function(t){var r=t.fill;if(!r||r==="none")return null;var s=t.fillOpacity,i=t.x,a=t.y,o=t.width,l=t.height,u=t.ry;return K.createElement("rect",{x:i,y:a,ry:u,width:o,height:l,stroke:"none",fill:r,fillOpacity:s,className:"recharts-cartesian-grid-bg"})};function Vi(e,t){var r;if(K.isValidElement(e))r=K.cloneElement(e,t);else if(Ue(e))r=e(t);else{var s=t.x1,i=t.y1,a=t.x2,o=t.y2,l=t.key,u=Ns(t,Xl),c=pe(u,!1);c.offset;var h=Ns(c,Zl);r=K.createElement("line",xt({},h,{x1:s,y1:i,x2:a,y2:o,fill:"none",key:l}))}return r}function sc(e){var t=e.x,r=e.width,s=e.horizontal,i=s===void 0?!0:s,a=e.horizontalPoints;if(!i||!a||!a.length)return null;var o=a.map(function(l,u){var c=ve(ve({},e),{},{x1:t,y1:l,x2:t+r,y2:l,key:"line-".concat(u),index:u});return Vi(i,c)});return K.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function ic(e){var t=e.y,r=e.height,s=e.vertical,i=s===void 0?!0:s,a=e.verticalPoints;if(!i||!a||!a.length)return null;var o=a.map(function(l,u){var c=ve(ve({},e),{},{x1:l,y1:t,x2:l,y2:t+r,key:"line-".concat(u),index:u});return Vi(i,c)});return K.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function ac(e){var t=e.horizontalFill,r=e.fillOpacity,s=e.x,i=e.y,a=e.width,o=e.height,l=e.horizontalPoints,u=e.horizontal,c=u===void 0?!0:u;if(!c||!t||!t.length)return null;var h=l.map(function(y){return Math.round(y+i-i)}).sort(function(y,v){return y-v});i!==h[0]&&h.unshift(0);var w=h.map(function(y,v){var S=!h[v+1],j=S?i+o-y:h[v+1]-y;if(j<=0)return null;var b=v%t.length;return K.createElement("rect",{key:"react-".concat(v),y,x:s,height:j,width:a,stroke:"none",fill:t[b],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return K.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},w)}function oc(e){var t=e.vertical,r=t===void 0?!0:t,s=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,l=e.width,u=e.height,c=e.verticalPoints;if(!r||!s||!s.length)return null;var h=c.map(function(y){return Math.round(y+a-a)}).sort(function(y,v){return y-v});a!==h[0]&&h.unshift(0);var w=h.map(function(y,v){var S=!h[v+1],j=S?a+l-y:h[v+1]-y;if(j<=0)return null;var b=v%s.length;return K.createElement("rect",{key:"react-".concat(v),x:y,y:o,width:j,height:u,stroke:"none",fill:s[b],fillOpacity:i,className:"recharts-cartesian-grid-bg"})});return K.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},w)}var lc=function(t,r){var s=t.xAxis,i=t.width,a=t.height,o=t.offset;return wi(bi(ve(ve(ve({},_i.defaultProps),s),{},{ticks:ji(s,!0),viewBox:{x:0,y:0,width:i,height:a}})),o.left,o.left+o.width,r)},cc=function(t,r){var s=t.yAxis,i=t.width,a=t.height,o=t.offset;return wi(bi(ve(ve(ve({},_i.defaultProps),s),{},{ticks:ji(s,!0),viewBox:{x:0,y:0,width:i,height:a}})),o.top,o.top+o.height,r)},At={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Wi(e){var t,r,s,i,a,o,l=mo(),u=po(),c=xo(),h=ve(ve({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:At.stroke,fill:(r=e.fill)!==null&&r!==void 0?r:At.fill,horizontal:(s=e.horizontal)!==null&&s!==void 0?s:At.horizontal,horizontalFill:(i=e.horizontalFill)!==null&&i!==void 0?i:At.horizontalFill,vertical:(a=e.vertical)!==null&&a!==void 0?a:At.vertical,verticalFill:(o=e.verticalFill)!==null&&o!==void 0?o:At.verticalFill,x:Se(e.x)?e.x:c.left,y:Se(e.y)?e.y:c.top,width:Se(e.width)?e.width:c.width,height:Se(e.height)?e.height:c.height}),w=h.x,y=h.y,v=h.width,S=h.height,j=h.syncWithTicks,b=h.horizontalValues,p=h.verticalValues,m=go(),f=yo();if(!Se(v)||v<=0||!Se(S)||S<=0||!Se(w)||w!==+w||!Se(y)||y!==+y)return null;var d=h.verticalCoordinatesGenerator||lc,x=h.horizontalCoordinatesGenerator||cc,g=h.horizontalPoints,M=h.verticalPoints;if((!g||!g.length)&&Ue(x)){var P=b&&b.length,q=x({yAxis:f?ve(ve({},f),{},{ticks:P?b:f.ticks}):void 0,width:l,height:u,offset:c},P?!0:j);jn(Array.isArray(q),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(gt(q),"]")),Array.isArray(q)&&(g=q)}
4if((!M||!M.length)&&Ue(d)){var k=p&&p.length,N=d({xAxis:m?ve(ve({},m),{},{ticks:k?p:m.ticks}):void 0,width:l,height:u,offset:c},k?!0:j);jn(Array.isArray(N),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(gt(N),"]")),Array.isArray(N)&&(M=N)}return K.createElement("g",{className:"recharts-cartesian-grid"},K.createElement(rc,{fill:h.fill,fillOpacity:h.fillOpacity,x:h.x,y:h.y,width:h.width,height:h.height,ry:h.ry}),K.createElement(sc,xt({},h,{offset:c,horizontalPoints:g,xAxis:m,yAxis:f})),K.createElement(ic,xt({},h,{offset:c,verticalPoints:M,xAxis:m,yAxis:f})),K.createElement(ac,xt({},h,{horizontalPoints:g})),K.createElement(oc,xt({},h,{verticalPoints:M})))}Wi.displayName="CartesianGrid";var Gi=Ni({chartName:"BarChart",GraphicalChild:en,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Rn},{axisType:"yAxis",AxisComp:Mn}],formatAxisMap:vo}),dc=Ni({chartName:"PieChart",GraphicalChild:Qe,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:qn},{axisType:"radiusAxis",AxisComp:Ln}],formatAxisMap:wo,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});function Et(e,t,r){let s=r.initialDeps??[],i,a=!0;function o(){var l,u,c;let h;r.key&&((l=r.debug)!=null&&l.call(r))&&(h=Date.now());const w=e();if(!(w.length!==s.length||w.some((S,j)=>s[j]!==S)))return i;s=w;let v;if(r.key&&((u=r.debug)!=null&&u.call(r))&&(v=Date.now()),i=t(...w),r.key&&((c=r.debug)!=null&&c.call(r))){const S=Math.round((Date.now()-h)*100)/100,j=Math.round((Date.now()-v)*100)/100,b=j/16,p=(m,f)=>{for(m=String(m);m.length<f;)m=" "+m;return m};console.info(`%c⏱ ${p(j,5)} /${p(S,5)} ms`,`
5            font-size: .6rem;
6            font-weight: bold;
7            color: hsl(${Math.max(0,Math.min(120-120*b,120))}deg 100% 31%);`,r?.key)}return r?.onChange&&!(a&&r.skipInitialOnChange)&&r.onChange(i),a=!1,i}return o.updateDeps=l=>{s=l},o}
vendor: 4,368 bytes, line 7
7function ks(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const uc=(e,t)=>Math.abs(e-t)<1.01,hc=(e,t,r)=>{let s;return function(...i){e.clearTimeout(s),s=e.setTimeout(()=>t.apply(this,i),r)}},Ss=e=>{const{offsetWidth:t,offsetHeight:r}=e;return{width:t,height:r}},fc=e=>e,mc=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1),s=[];for(let i=t;i<=r;i++)s.push(i);return s},pc=(e,t)=>{const r=e.scrollElement;if(!r)return;const s=e.targetWindow;if(!s)return;const i=o=>{const{width:l,height:u}=o;t({width:Math.round(l),height:Math.round(u)})};if(i(Ss(r)),!s.ResizeObserver)return()=>{};const a=new s.ResizeObserver(o=>{const l=()=>{const u=o[0];if(u?.borderBoxSize){const c=u.borderBoxSize[0];if(c){i({width:c.inlineSize,height:c.blockSize});return}}i(Ss(r))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return a.observe(r,{box:"border-box"}),()=>{a.unobserve(r)}},Cs={passive:!0},As=typeof window>"u"?!0:"onscrollend"in window,xc=(e,t)=>{const r=e.scrollElement;if(!r)return;const s=e.targetWindow;if(!s)return;let i=0;const a=e.options.useScrollendEvent&&As?()=>{}:hc(s,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=h=>()=>{const{horizontal:w,isRtl:y}=e.options;i=w?r.scrollLeft*(y&&-1||1):r.scrollTop,a(),t(i,h)},l=o(!0),u=o(!1);r.addEventListener("scroll",l,Cs);const c=e.options.useScrollendEvent&&As;return c&&r.addEventListener("scrollend",u,Cs),()=>{r.removeEventListener("scroll",l),c&&r.removeEventListener("scrollend",u)}},gc=(e,t,r)=>{if(t?.borderBoxSize){const s=t.borderBoxSize[0];if(s)return Math.round(s[r.options.horizontal?"inlineSize":"blockSize"])}return e[r.options.horizontal?"offsetWidth":"offsetHeight"]},yc=(e,{adjustments:t=0,behavior:r},s)=>{var i,a;const o=e+t;(a=(i=s.scrollElement)==null?void 0:i.scrollTo)==null||a.call(i,{[s.options.horizontal?"left":"top"]:o,behavior:r})};class vc{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let r=null;const s=()=>r||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:r=new this.targetWindow.ResizeObserver(i=>{i.forEach(a=>{const o=()=>{this._measureElement(a.target,a)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var i;(i=s())==null||i.disconnect(),r=null},observe:i=>{var a;return(a=s())==null?void 0:a.observe(i,{box:"border-box"})},unobserve:i=>{var a;return(a=s())==null?void 0:a.unobserve(i)}}})(),this.range=null,this.setOptions=r=>{Object.entries(r).forEach(([s,i])=>{typeof i>"u"&&delete r[s]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:fc,rangeExtractor:mc,onChange:()=>{},measureElement:gc,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...r}},this.notify=r=>{var s,i;(i=(s=this.options).onChange)==null||i.call(s,this,r)},this.maybeNotify=Et(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),r=>{this.notify(r)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(r=>r()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var r;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((r=this.scrollElement)==null?void 0:r.window)??null,this.elementsCache.forEach(i=>
7{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,a)=>{this.scrollAdjustments=0,this.scrollDirection=a?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=a,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(r,s)=>{const i=new Map,a=new Map;for(let o=s-1;o>=0;o--){const l=r[o];if(i.has(l.lane))continue;const u=a.get(l.lane);if(u==null||l.end>u.end?a.set(l.lane,l):l.end<u.end&&i.set(l.lane,!0),i.size===this.options.lanes)break}return a.size===this.options.lanes?Array.from(a.values()).sort((o,l)=>o.end===l.end?o.index-l.index:o.end-l.end)[0]:void 0},this.getMeasurementOptions=Et(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(r,s,i,a,o,l)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMeasuredCacheIndexes=[],{count:r,paddingStart:s,scrollMargin:i,getItemKey:a,enabled:o,lanes:l}),{key:!1}),this.getMeasurements=Et(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:r,paddingStart:s,scrollMargin:i,getItemKey:a,enabled:o,lanes:l},u)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>r)for(const y of this.laneAssignments.keys())y>=r&&this.laneAssignments.delete(y);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(y=>{this.itemSizeCache.set(y.key,y.size)}));const c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===r&&(this.lanesSettling=!1);const h=this.measurementsCache.slice(0,c),w=new Array(l).fill(void 0);for(let y=0;y<c;y++){const v=h[y];v&&(w[v.lane]=y)}for(let y=c;y<r;y++){const v=a(y),S=this.laneAssignments.get(y);let j,b;if(S!==void 0&&this.options.lanes>1){j=S;const d=w[j],x=d!==void 0?h[d]:void 0;b=x?x.end+this.options.gap:s+i}else{const d=this.options.lanes===1?h[y-1]:this.getFurthestMeasurement(h,y);b=d?d.end+this.options.gap:s+i,j=d?d.lane:y%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(y,j)}const p=u.get(v),m=typeof p=="number"?p:this.options.estimateSize(y),f=b+m;h[y]={index:y,start:b,size:m,end:f,key:v,lane:j},w[j]=y}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Et(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(r,s,i,a)=>this.range=r.length>0&&s>0?wc({measurements:r,outerSize:s,scrollOffset:i,lanes:a}):null,{key:!1,debug:()=>this.options.debug}
vendor: 1,605 bytes, line 7
7),this.getVirtualIndexes=Et(()=>{let r=null,s=null;const i=this.calculateRange();return i&&(r=i.startIndex,s=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,r,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,r,s]},(r,s,i,a,o)=>a===null||o===null?[]:r({startIndex:a,endIndex:o,overscan:s,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=r=>{const s=this.options.indexAttribute,i=r.getAttribute(s);return i?parseInt(i,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this._measureElement=(r,s)=>{const i=this.indexFromElement(r),a=this.measurementsCache[i];if(!a)return;const o=a.key,l=this.elementsCache.get(o);l!==r&&(l&&this.observer.unobserve(l),this.observer.observe(r),this.elementsCache.set(o,r)),r.isConnected&&this.resizeItem(i,this.options.measureElement(r,s,this))},this.resizeItem=(r,s)=>{const i=this.measurementsCache[r];if(!i)return;const a=this.itemSizeCache.get(i.key)??i.size,o=s-a;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,o,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,s)),this.notify(!1))},this.measureElement=r=>{if(!r){this.elementsCache.forEach((s,i)=>{s.isConnected||(this.observer.unobserve(s),this.elementsCache.delete(i))});return}this._measureElement(r,void 0)},this.getVirtualItems=Et(()=>
7[this.getVirtualIndexes(),this.getMeasurements()],(r,s)=>{const i=[];for(let a=0,o=r.length;a<o;a++){const l=r[a],u=s[l];i.push(u)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=r=>{const s=this.getMeasurements();if(s.length!==0)return ks(s[Ki(0,s.length-1,i=>ks(s[i]).start,r)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const r=this.scrollElement.document.documentElement;return this.options.horizontal?r.scrollWidth-this.scrollElement.innerWidth:r.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(r,s,i=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),o=this.getScrollOffset();s==="auto"&&(s=r>=o+a?"end":"start"),s==="center"?r+=(i-a)/2:s==="end"&&(r-=a);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,r),0)},this.getOffsetForIndex=(r,s="auto")=>{r=Math.max(0,Math.min(r,this.options.count-1));const i=this.measurementsCache[r];if(!i)return;const a=this.getSize(),o=this.getScrollOffset();if(s==="auto")if(i.end>=o+a-this.options.scrollPaddingEnd)s="end";else if(i.start<=o+this.options.scrollPaddingStart)s="start";else return[o,s];if(s==="end"&&r===this.options.count-1)return[this.getMaxScrollOffset(),s];const l=s==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,s,i.size),s]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(r,{align:s="start",behavior:i}={})=>{i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(r,s),{adjustments:void 0,behavior:i})},this.scrollToIndex=(r,{align:s="auto",behavior:i}={})=>{i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),r=Math.max(0,Math.min(r,this.options.count-1)),this.currentScrollToIndex=r;let a=0;const o=10,l=c=>{if(!this.targetWindow)return;const h=this.getOffsetForIndex(r,c);if(!h){console.warn("Failed to get offset for index:",r);return}const[w,y]=h;this._scrollToOffset(w,{adjustments:void 0,behavior:i}),this.targetWindow.requestAnimationFrame(()=>{const v=()=>{if(this.currentScrollToIndex!==r)return;const S=this.getScrollOffset(),j=this.getOffsetForIndex(r,y);if(!j){console.warn("Failed to get offset for index:",r);return}uc(j[0],S)||u(y)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(v):v()})},u=c=>{this.targetWindow&&this.currentScrollToIndex===r&&(a++,a<o?this.targetWindow.requestAnimationFrame(()=>l(c)):console.warn(`Failed to scroll to index ${r} after ${o} attempts.`))};l(s)},this.scrollBy=(r,{behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+r,{adjustments:void 0,behavior:s})},this.getTotalSize=()=>{var r;const s=this.getMeasurements();let i;if(s.length===0)i=this.options.paddingStart;else if(this.options.lanes===1)i=((r=s[s.length-1])==null?void 0:r.end)??0;else{const a=Array(this.options.lanes).fill(null);let o=s.length-1;for(;o>=0&&a.some(l=>l===null);){const l=s[o];a[l.lane]===null&&(a[l.lane]=l.end),o--}i=Math.max(...a.filter(l=>l!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(r,{adjustments:s,behavior:i})=>{this.options.scrollToFn(r,{behavior:i,adjustments:s},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}}const Ki=(e,t,r,s)=>{for(;e<=t;){const i=(e+t)/2|0,a=r(i);if(a<s)e=i+1;else if(a>s)t=i-1;else return i}return e>0?e-1:0};function wc({measurements:e,outerSize:t,scrollOffset:r,lanes:s}){const i=e.length-1,a=u=>e[u].start;if(e.length<=s)return{startIndex:0,endIndex:i};let o=Ki(0,i,a,r),l=o;if(s===1)for(;l<i&&e[l].end<r+t;)l++;else if(s>1){const u=Array(s).fill(0);for(;l<i&&u.some(h=>h<r+t);){const h=e[l];u[h.lane]=h.end,l++}const c=Array(s).fill(r+t);for(;o>=0&&c.some(h=>h>=r);){const h=e[o];c[h.lane]=h.start,o--}o=Math.max(0,o-o%s),l=Math.min(i,l+(s-1-l%s))}return{startIndex:o,endIndex:l}}const Es=typeof document<"u"?E.useLayoutEffect:E.useEffect;function bc({useFlushSync:e=!0,...t}){const r=E.useReducer(()=>({}),{})[1],s={...t,onChange:(a,o)=>{var l;
7e&&o?Da.flushSync(r):r(),(l=t.onChange)==null||l.call(t,a,o)}},[i]=E.useState(()=>new vc(s));return i.setOptions(s),Es(()=>i._didMount(),[]),Es(()=>i._willUpdate()),i}function Cn(e){return bc({observeElementRect:pc,observeElementOffset:xc,scrollToFn:yc,...e})}const jc={Delivered:"bg-green-500/5 hover:bg-green-500/10",Rewritten:"bg-green-500/5 hover:bg-green-500/10","Junk (Delivered)":"bg-green-500/5 hover:bg-green-500/10","Junk (Rewritten)":"bg-green-500/5 hover:bg-green-500/10",Stripped:"bg-orange-500/5 hover:bg-orange-500/10",Held:"bg-orange-500/5 hover:bg-orange-500/10","Junk (Stripped)":"bg-orange-500/5 hover:bg-orange-500/10","Junk (Held)":"bg-orange-500/5 hover:bg-orange-500/10","Blocked (Dropped)":"bg-orange-500/5 hover:bg-orange-500/10","Blocked (Bounced)":"bg-orange-500/5 hover:bg-orange-500/10","Blocked (Trashed)":"bg-orange-500/5 hover:bg-orange-500/10",Failed:"bg-red-500/5 hover:bg-red-500/10",Error:"bg-red-500/5 hover:bg-red-500/10"},It={Pending:{bg:"hsl(var(--muted))",text:"hsl(var(--muted-foreground))",darkText:"hsl(var(--muted-foreground))"},Sent:{bg:"#3FCBFF",text:"#ffffff",darkText:"#0c4a5e"},Delivered:{bg:"#4CDBC4",text:"#ffffff",darkText:"#134e45"},Rewritten:{bg:"#4CDBC4",text:"#ffffff",darkText:"#134e45"},"Junk (Delivered)":{bg:"#4CDBC4",text:"#ffffff",darkText:"#134e45"},"Junk (Rewritten)":{bg:"#4CDBC4",text:"#ffffff",darkText:"#134e45"},Stripped:{bg:"#FFD15D",text:"#ffffff",darkText:"#713f12"},Held:{bg:"#FFD15D",text:"#ffffff",darkText:"#713f12"},"Junk (Stripped)":{bg:"#FFD15D",text:"#ffffff",darkText:"#713f12"},"Junk (Held)":{bg:"#FFD15D",text:"#ffffff",darkText:"#713f12"},Failed:{bg:"#FE7058",text:"#ffffff",darkText:"#7f1d1d"},Error:{bg:"#FE7058",text:"#ffffff",darkText:"#7f1d1d"},"Blocked (Dropped)":{bg:"#FFAE5D",text:"#ffffff",darkText:"#7c2d12"},"Blocked (Bounced)":{bg:"#FFAE5D",text:"#ffffff",darkText:"#7c2d12"},"Blocked (Trashed)":{bg:"#FFAE5D",text:"#ffffff",darkText:"#7c2d12"}},$r=["Sent","Delivered","Rewritten","Junk (Delivered)","Junk (Rewritten)","Held","Junk (Held)","Stripped","Junk (Stripped)","Blocked (Dropped)","Blocked (Bounced)","Blocked (Trashed)"],_c=$r.filter(e=>!e.includes("Rewritten")),Nc=$r.filter(e=>!e.includes("Stripped"));function Ji(e){return new Date(e*1e3).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}function kc(e){return e==="as_link"?Nc:_c}function Yi({status:e}){const t=It[e]||It.Pending;return n.jsx(De,{style:{backgroundColor:t.bg,"--status-text":t.text,"--status-text-dark":t.darkText},className:"font-normal text-[--status-text] dark:text-[--status-text-dark]",children:e})}function Xi({mailType:e}){return e==="as_link"?n.jsx("span",{title:"Link delivery",children:n.jsx(fi,{className:"h-4 w-4 text-muted-foreground"})}):e==="as_body"?n.jsx("span",{title:"Body delivery",children:n.jsx(Nr,{className:"h-4 w-4 text-muted-foreground"})}):n.jsx("span",{title:"Attachment delivery",children:n.jsx(ki,{className:"h-4 w-4 text-muted-foreground"})})}function Zi({extension:e}){return n.jsx("img",{src:`/images/${e.toLowerCase()}.png`,alt:e,title:e,className:"h-6 w-auto max-w-6",onError:t=>{t.target.src="/images/blank.png"}})}function Qi({email:e,onStatusChange:t,disabled:r}){const s=kc(e.mail_type),i=It[e.status]||It.Pending;return e.status==="Failed"||e.status==="Error"?n.jsx(Yi,{status:e.status}):n.jsxs(Er,{value:e.status,onValueChange:a=>t(e.email_id,a),disabled:r,children:[n.jsx(Dr,{className:"h-7 w-[150px] border-0 px-2 text-[--status-text] dark:text-[--status-text-dark]",style:{backgroundColor:i.bg,"--status-text":i.text,"--status-text-dark":i.darkText},children:n.jsx("span",{children:e.status})}),n.jsx(Tr,{children:s.map(a=>{const o=It[a];return n.jsx(Rr,{value:a,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:o.bg}}),a]})},a)})})]})}function Sc({data:e,onClick:t,showColumn:r}){if(!r)return null;if(!e||Object.keys(e).length===0)return n.jsx("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 opacity-30",children:n.jsx("img",{src:"/images/defender.png",alt:"Defender",className:"h-5 w-auto max-w-5"})});const s=e.org_level_action==="Block"||e.user_level_action==="Block",i=e.detection_methods?Object.keys(e.detection_methods).length:0;return n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsxs("button",{onClick:t,className:"flex items-center gap-0.5 hover:opacity-80 transition-opacity px-1.5 py-0.5 rounded bg-muted/50 hover:bg-muted",children:[n.jsx("img",{src:"/images/defender.png",alt:"Defender",className:"h-5 w-auto max-w-5"}),s?n.jsx(ui,{className:"h-3 w-3 text-destructive"}):i>0?n.jsx("span",{className:"text-xs text-muted-foreground ml-0.5",children:i}):null]})}),n.jsx(ae,{children:s?"Blocked by policy. Click to view Defender data":i>0?`${i} detection method(s). Click to view Defender data`:"View Defender data"})]})}function Cc({data:e,onClick:t,showColumn:r}){if(!r)return null;if(!e||Object.keys(e).length===0)return n.jsx("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 opacity-30",children:n.jsx(at,{service:"sublime",size:20})});const s=e.flagged_rules?.length||0;return n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsxs("button",{onClick:t,className:"flex items-center gap-0.5 hover:opacity-80 transition-opacity px-1.5 py-0.5 rounded bg-muted/50 hover:bg-muted",children:[n.jsx(at,{service:"sublime",size:20}),s>0&&n.jsx("span",{className:"text-xs text-muted-foreground ml-0.5",children:s})]})}),n.jsx(ae,{children:s>0?`${s} flagged rule(s). Click to view Sublime data`:"View Sublime data"})]})}function Ac({email:e,isSelected:t,isSelectable:r,onSelect:s,onStatusChange:i,onViewPayload:a,onDownloadPayload:o,onViewEml:l,onViewGatewayResponse:u,isUpdating:c}){const h=()=>{navigator.clipboard.writeText(e.email_id),W.success("Email ID copied")};return n.jsx("div",{className:"rounded-lg border p-3 pr-2",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"pt-0.5",children:n.jsx(bn,{checked:t,onCheckedChange:w=>s(w===!0),disabled:!r})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(Xi,{mailType:e.mail_type}),n.jsx(Zi,{extension:e.extension}),n.jsx("button",{className:"text-primary hover:underline text-left truncate font-medium",onClick:a,children:e.payload_name})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[e.status==="Failed"||e.status==="Error"?n.jsx(Yi,{status:e.status}):n.jsx(Qi,{email:e,onStatusChange:i,disabled:c}),n.jsx("span",{className:"text-xs text-muted-foreground",children:Ji(e.sent)})]})]}),n.jsxs(wt,{children:[n.jsx(bt,{asChild:!0,children:n.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",children:n.jsx(mi,{className:"h-4 w-4"})})}),n.jsxs(jt,{align:"end",children:[n.jsxs(xe,{onClick:h,children:[n.jsx(_t,{className:"mr-2 h-4 w-4"}),"Copy Email ID"]}),n.jsxs(xe,{onClick:o,children:[n.jsx(de,{className:"mr-2 h-4 w-4"}),"Download Payload"]}),n.jsxs(xe,{onClick:l,disabled:!e.has_eml,children:[n.jsx(Fn,{className:"mr-2 h-4 w-4"}),"View EML"]}),e.sendgrid_reason&&n.jsxs(xe,{onClick:u,children:[n.jsx(Nr,{className:"mr-2 h-4 w-4"}),"View Gateway Response"]})]})]})]})})}function Ec({emails:e,onStatusChange:t,onBulkStatusChange:r,onViewDefender:s,onViewSublime:i,onViewEml:a,onViewGatewayResponse:o,onViewClicks:l,onDownloadPayload:u,isUpdating:c=!1,hasDefenderIntegration:h=!1,hasSublimeIntegration:w=!1,renderBulkActions:y}){const[v,S]=E.useState(new Set),[j,b]=E.useState(null),[p,m]=E.useState(!1),[f,d]=E.useState(null),[x,g]=E.useState(null),[M,P]=E.useState("asc"),q=E.useRef(null),k=E.useRef(null),N=E.useMemo(()=>x?[...e].sort((H,F)=>{let Q=0;return x==="payload"?Q=H.payload_name.localeCompare(F.payload_name):x==="status"&&(Q=H.status.localeCompare(F.status)),M==="asc"?Q:-Q}):e,[e,x,M]),O=48,I=Cn({count:N.length,getScrollElement:()=>q.current,estimateSize:()=>O,overscan:5}),_=100,T=Cn({count:N.length,getScrollElement:()=>k.current,estimateSize:()=>_,overscan:3}),C=H=>{x===H?P(M==="asc"?"desc":"asc"):(g(H),P("asc"))},R=E.useMemo(()=>e.some(H=>H.mail_type==="as_link"),[e]),D=E.useMemo(()=>e.some(H=>H.mail_control_information?.Defender&&Object.keys(H.mail_control_information.Defender).length>0),[e]),A=E.useMemo(()=>e.some(H=>H.mail_control_information?.Sublime&&Object.keys(H.mail_control_information.Sublime).length>0),[e]),$=h||D,J=w||A,B=E.useMemo(()=>e.some(H=>H.status==="Sent"),[e]),Z=H=>{if(H){const F=e.filter(Q=>Q.status!=="Failed"&&Q.status!=="Error").map(Q=>Q.email_id);S(new Set(F))}else S(new Set)},X=(H,F)=>{const Q=new Set(v);F?Q.add(H):Q.delete(H),S(Q)},Y=()=>{const H=e.filter(F=>F.status==="Sent");r(H.map(F=>({email_id:F.email_id,status:"Blocked (Dropped)"})))},te=()=>{if(!f||v.size===0)return;const H=Array.from(v).map(F=>({email_id:F,status:f}));r(H),m(!1),d(null),S(new Set)},V=H=>{navigator.clipboard.writeText(H),W.success("Email ID copied to clipboard")};return n.jsxs("div",{children:[!y&&n.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[B&&n.jsx(G,{variant:"outline",size:"sm",onClick:Y,disabled:c,
7children:"Set Remaining Blocked"}),v.size>0&&n.jsxs(G,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:c,children:["Set Selected Status (",v.size,")"]})]}),y?.({hasSentEmails:B,selectedCount:v.size,onSetRemainingBlocked:Y,onOpenBulkStatusDialog:()=>m(!0),isUpdating:c}),n.jsx("div",{ref:k,className:"md:hidden max-h-[800px] overflow-y-auto",children:e.length===0?n.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No emails in this campaign"}):n.jsx("div",{style:{height:`${T.getTotalSize()}px`,width:"100%",position:"relative"},children:T.getVirtualItems().map(H=>{const F=N[H.index],Q=F.status!=="Failed"&&F.status!=="Error";return n.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${H.size}px`,transform:`translateY(${H.start}px)`},className:"pb-3",children:n.jsx(Ac,{email:F,isSelected:v.has(F.email_id),isSelectable:Q,onSelect:lt=>X(F.email_id,lt),onStatusChange:t,onViewPayload:()=>b(F.recipe_uuid),onDownloadPayload:()=>u?.(F.payload_uuid),onViewEml:()=>a?.(F),onViewGatewayResponse:()=>o?.(F),isUpdating:c})},F.email_id)})})}),n.jsx("div",{ref:q,className:"hidden md:block rounded-md border overflow-auto max-h-[800px]",children:n.jsxs("div",{className:"min-w-[700px]",children:[n.jsxs("div",{className:"sticky top-0 bg-background z-10 border-b grid items-center h-12 text-sm font-medium text-muted-foreground",style:{gridTemplateColumns:`44px 40px 36px 36px 1fr 170px ${R?"80px ":""}${$?"50px ":""}${J?"50px ":""}40px`},children:[n.jsx("div",{className:"px-3",children:n.jsx(bn,{checked:v.size>0&&v.size===e.filter(H=>H.status!=="Failed"&&H.status!=="Error").length,onCheckedChange:Z})}),n.jsx("div",{className:"pl-4 pr-2",children:n.jsx("span",{title:"Sent Time",children:n.jsx(lr,{className:"h-4 w-4"})})}),n.jsx("div",{className:"px-2"}),n.jsx("div",{className:"px-2"}),n.jsx("div",{className:"cursor-pointer hover:bg-muted/50 px-2 h-full flex items-center",onClick:()=>C("payload"),children:n.jsxs("div",{className:"flex items-center gap-1",children:["Payload",x==="payload"&&n.jsx("span",{className:"text-xs",children:M==="asc"?"â
7†‘":"↓"})]})}),n.jsx("div",{className:"cursor-pointer hover:bg-muted/50 px-2 h-full flex items-center",onClick:()=>C("status"),children:n.jsxs("div",{className:"flex items-center gap-1",children:["Status",x==="status"&&n.jsx("span",{className:"text-xs",children:M==="asc"?"↑":"↓"})]})}),R&&n.jsx("div",{className:"px-2",children:"Clicks"}),$&&n.jsx("div",{className:"px-2",children:n.jsx("span",{title:"Microsoft Defender",children:n.jsx(Ve,{className:"h-4 w-4"})})}),J&&n.jsx("div",{className:"px-2",children:n.jsx(at,{service:"sublime",size:16})}),n.jsx("div",{})]}),n.jsx("div",{style:{height:e.length>0?`${I.getTotalSize()}px`:"auto",position:"relative"},children:e.length===0?n.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No emails in this campaign"}):I.getVirtualItems().map(H=>{const F=N[H.index],Q=F.status!=="Failed"&&F.status!=="Error",lt=F.mail_control_information?.Defender&&Object.keys(F.mail_control_information.Defender).length>0,L=F.mail_control_information?.Sublime&&Object.keys(F.mail_control_information.Sublime).length>0;return n.jsxs("div",{className:_e("grid items-center border-b text-sm",jc[F.status]||"hover:bg-muted/50"),style:{gridTemplateColumns:`44px 40px 36px 36px 1fr 170px ${R?"80px ":""}${$?"50px ":""}${J?"50px ":""}40px`,position:"absolute",top:0,left:0,width:"100%",height:`${H.size}px`,transform:`translateY(${H.start}px)`},children:[n.jsx("div",{className:"px-3",children:n.jsx(bn,{checked:v.has(F.email_id),onCheckedChange:z=>X(F.email_id,z===!0),disabled:!Q})}),n.jsx("div",{className:"pl-4 pr-2",children:n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx("button",{className:"text-muted-foreground hover:text-foreground",children:n.jsx(lr,{className:"h-4 w-4"})})}),n.jsx(ae,{children:Ji(F.sent)})]})}),n.jsx("div",{className:"px-2",children:n.jsx(Xi,{mailType:F.mail_type})}),n.jsx("div",{className:"px-2",children:n.jsx(Zi,{extension:F.extension})}),n.jsx("div",{className:"px-2 truncate",children:n.jsx("button",{className:"text-primary hover:underline text-left truncate max-w-full",onClick:()=>b(F.recipe_uuid),children:F.payload_name})}),n.jsx("div",{className:"px-2",children:n.jsx(Qi,{email:F,onStatusChange:t,disabled:c})}),R&&n.jsx("div",{className:"px-2",children:F.mail_type==="as_link"&&n.jsxs("button",{type:"button",className:`flex items-center gap-1 ${F.clicks&&F.clicks.length>0?"cursor-pointer hover:text-primary":"opacity-50"}`,onClick:()=>F.clicks&&F.clicks.length>0&&l?.(F),disabled:!F.clicks||F.clicks.length===0,children:[n.jsx(cr,{className:"h-3 w-3"}),n.jsx("span",{children:F.clicks?.length||0})]})}),$&&n.jsx("div",{className:"px-2",children:n.jsx(Sc,{data:F.mail_control_information?.Defender,showColumn:$,onClick:lt?()=>s?.(F):void 0})}),J&&n.jsx("div",{className:"px-2",children:n.jsx(Cc,{data:F.mail_control_information?.Sublime,showColumn:J,onClick:L?()=>i?.(F):void 0})}),n.jsx("div",{className:"px-1",children:n.jsxs(wt,{children:[n.jsx(bt,{asChild:!0,children:n.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",children:n.jsx(mi,{className:"h-4 w-4"})})}),n.jsxs(jt,{align:"end",children:[n.jsxs(xe,{onClick:()=>V(F.email_id),children:[n.jsx(_t,{className:"mr-2 h-4 w-4"}),"Copy Email ID"]}),n.jsxs(xe,{onClick:()=>u?.(F.payload_uuid),children:[n.jsx(de,{className:"mr-2 h-4 w-4"}),"Download Payload"]}),n.jsxs(xe,{onClick:()=>a?.(F),disabled:!F.has_eml,children:[n.jsx(Fn,{className:"mr-2 h-4 w-4"}),"View EML"]}),F.sendgrid_reason&&n.jsxs(xe,{onClick:()=>o?.(F),children:[n.jsx(Nr,{className:"mr-2 h-4 w-4"}),"View Gateway Response"]})]})]})})]},F.email_id)})})]})}),n.jsx(Wa,{open:p,onOpenChange:m,children:n.jsxs(Ga,{children:[n.jsxs(Ka,{children:[n.jsx(Ja,{children:"Set Email Status"}),n.jsxs(Ya,{children:["Set the status for ",v.size," selected email(s)."]})]}),n.jsx("div",{className:"py-4",children:n.jsxs(Er,{value:f||void 0,onValueChange:H=>d(H),children:[n.jsx(Dr,{children:n.jsx(Va,{placeholder:"Select a status"})}),n.jsx(Tr,{children:$r.map(H=>{const F=It[H];return n.jsx(Rr,{value:H,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:F.bg}}),H]})},H)})})]})}),n.jsxs(Xa,{children:[n.jsx(Za,{children:"Cancel"}),n.jsx(Qa,{onClick:te,disabled:!f,children:"Set Status"})]})]})}),n.jsx(Mr,{payloadId:j,open:!!j,onOpenChange:H=>{H||b(null)}})]})}const Dc={Pending:"#EDEDED",Sent:"#3FCBFF",Delivered:"#4CDBC4",Blocked:"#FFAE5D",Failed:"#FE7058"};function Tc(e){switch(e){case"Pending":return"Pending";case"Sent":return"Sent";case"Delivered":case"Rewritten":case"Junk (Delivered)":case"Junk (Rewritten)":return"Delivered";case"Stripped":case"Held":case"Junk (Stripped)":case"Junk (Held)":case"Blocked (Dropped)":case"Blocked (Bounced)":case"Blocked (Trashed)":return"Blocked";case"Failed":case"Error":return"Failed";default:return"Pending"}}function Ds({emails:e,data:t,emptyMessage:r="No data available"}){const s=E.useMemo(()=>
7{if(t)return t;const i={Pending:0,Sent:0,Delivered:0,Blocked:0,Failed:0};for(const o of e??[]){const l=Tc(o.status);i[l]++}return Object.entries(i).filter(([o,l])=>l>0).map(([o,l])=>({name:o,value:l,color:Dc[o]}))},[e,t]);return s.length===0?n.jsx("div",{className:"flex items-center justify-center h-[200px] text-muted-foreground",children:r}):n.jsx("div",{className:"h-[300px]",children:n.jsx(On,{width:"100%",height:"100%",children:n.jsxs(dc,{children:[n.jsx(Qe,{data:s,cx:"50%",cy:"45%",innerRadius:50,outerRadius:80,paddingAngle:2,dataKey:"value",label:({name:i,value:a})=>`${i}: ${a}`,labelLine:!1,fontSize:12,children:s.map((i,a)=>n.jsx(vi,{fill:i.color},`cell-${a}`))}),n.jsx(In,{formatter:(i,a)=>[i,a],contentStyle:{backgroundColor:"hsl(var(--secondary))",border:"1px solid hsl(var(--border))",borderRadius:"8px",color:"hsl(var(--secondary-foreground))"},itemStyle:{color:"hsl(var(--secondary-foreground))"},labelStyle:{color:"hsl(var(--secondary-foreground))"}}),n.jsx(Pn,{verticalAlign:"bottom",height:36,formatter:i=>n.jsx("span",{className:"text-sm text-foreground",children:i})})]})})})}function Rc({campaign:e,isSelected:t,onSelect:r,onDelete:s,onResend:i,onStopRepeating:a,isPremium:o,isRepeatingActive:l}){const u=!e.parent_campaign_id,c=(e.status==="Failed"||e.status==="Cancelled")&&e.error_message;return n.jsx("div",{className:_e("rounded-lg border p-3 pr-2 cursor-pointer transition-colors hover:bg-muted/50",t&&"bg-accent border-accent"),onClick:()=>r(e.campaign_id),children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[u&&n.jsx(Ii,{className:"h-4 w-4 text-amber-500 fill-amber-500 shrink-0"}),n.jsx("span",{className:"font-medium truncate",children:e.campaign_name}),n.jsx(Si,{campaignType:e.campaign_type})]}),n.jsx("div",{className:"flex items-center gap-3",children:e.campaign_type==="web"?n.jsx(Ai,{results:e.campaign_results}):n.jsxs(n.Fragment,{children:[n.jsx(Ei,{results:e.campaign_results}),n.jsx(Ci,{integrations:e.integrations})]})})]}),n.jsxs("div",{className:"flex flex-col items-end gap-1",onClick:h=>h.stopPropagation(),children:[n.jsx(Ti,{campaign:e,onDelete:s,onResend:i,onStopRepeating:a,isPremium:o,isRepeatingActive:l}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(Di,{status:e.status}),c&&n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx(Ri,{className:"h-4 w-4 text-destructive"})}),n.jsx(ae,{className:"max-w-xs",children:e.error_message})]})]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:Sr(e.requested_start_time)})]})]})})}function Ts({campaigns:e,selectedCampaignId:t,onSelectCampaign:r,autoRefresh:s,isPremium:i}){const a=Ta(),[o]=di(),l=e.every(m=>m.campaign_type==="web"),u=No(),c=ko(),h=[...e].sort((m,f)=>{const d=parseInt(m.requested_start_time,10)||0,x=parseInt(f.requested_start_time,10)||0;return d-x}),w=h[h.length-1],v=(parseInt(String(w?.repeat_for),10)||0)>0,S=m=>{r(m);const f=new URLSearchParams(o);f.set("campaign",m),s&&f.set("auto_refresh","true"),a(`/app/campaign-results?${f.toString()}`,{replace:!0})},j=m=>{u.mutate([m],{onSuccess:()=>{if(W.success("Campaign deleted successfully"),m===t){const f=e.find(d=>d.campaign_id===m);f?.parent_campaign_id?a(`/app/campaign-results?campaign=${f.parent_campaign_id}`):a("/app/campaigns")}},onError:()=>{W.error("Failed to delete campaign")}})},b=m=>{const d=e.find(x=>x.campaign_id===m)?.campaign_type==="web";c.mutate(m,{onSuccess:x=>{W.success(d?"Campaign relaunched successfully":"Campaign resent successfully"),a(`/app/campaign-results?campaign=${x.campaign_id}`)},onError:()=>{W.error(d?"Failed to relaunch campaign":"Failed to resend campaign")}})},p=m=>{W.info(`Stop repeating: ${m}`)};return h.length===0?n.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No related campaigns found"}):n.jsxs(kr,{children:[n.jsx("div",{className:"md:hidden flex flex-col gap-3",children:h.map(m=>n.jsx(Rc,{campaign:m,isSelected:m.campaign_id===t,onSelect:S,onDelete:j,onResend:b,onStopRepeating:p,isPremium:i,isRepeatingActive:v},m.campaign_id))}),n.jsx("div",{className:"hidden md:block rounded-md border",children:n.jsxs(Nt,{children:[n.jsx(sn,{children:n.jsxs(we,{children:[n.jsx(oe,{className:"w-[40px]"}),n.jsx(oe,{children:"Date"}),n.jsx(oe,{children:"Name"}),n.jsx(oe,{className:"w-[40px]",children:"Type"}),!l&&n.jsx(oe,{children:"Integrations"}),n.jsx(oe,{children:"Summary"}),n.jsx(oe,{children:"Status"}),n.jsx(oe,{className:"w-[50px]"})]})}),n.jsx(kt,{children:h.map(m=>{const f=m.campaign_id===t,d=!m.parent_campaign_id,x=(m.status==="Failed"||m.status==="Cancelled")&&m.error_message;return n.jsxs(we,{className:_e("cursor-pointer transition-colors",f&&"bg-accent"),onClick:()=>S(m.campaign_id),children:[n.jsx(ee,{className:"text-center",children:d&&n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx(Ii,{className:"h-4 w-4 text-amber-500 fill-amber-500 mx-auto"})}),n.jsx(ae,{children:"Parent Campaign"})]})}),n.jsx(ee,{className:"whitespace-nowrap",children:Sr(m.requested_start_time)}),n.jsx(ee,{className:"max-w-[200px] truncate font-medium",children:m.campaign_name}),n.jsx(ee,{children:n.jsx(Si,{campaignType:m.campaign_type})}),!l&&n.jsx(ee,{children:m.campaign_type!=="web"&&n.jsx(Ci,{integrations:m.integrations})}),n.jsx(ee,{children:m.campaign_type==="web"?n.jsx(Ai,{results:m.campaign_results}):n.jsx(Ei,{results:m.campaign_results})}),n.jsx(ee,{children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Di,{status:m.status}),x&&n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx(Ri,{className:"h-4 w-4 text-destructive"})}),n.jsx(ae,{className:"max-w-xs",children:m.error_message})]})]})}),n.jsx(ee,{onClick:g=>g.stopPropagation(),children:n.jsx(Ti,{campaign:m,onDelete:j,onResend:b,onStopRepeating:p,isPremium:i,isRepeatingActive:v})})]},m.campaign_id)})})]})})]})}function Mc({campaigns:e}){const t=E.useMemo(()=>[...e].sort((i,a)=>{const o=parseInt(i.requested_start_time,10)||0,l=parseInt(a.requested_start_time,10)||0;return o-l}).filter(i=>i.status==="Completed"&&i.campaign_results&&Array.isArray(i.campaign_results)&&i.campaign_results.length===3).map(i=>{const[a,o,l]=i.campaign_results;return{name:Sr(i.requested_start_time),sent:a,delivered:o,blocked:l}}),[e]);if(t.length===0)return n.jsx("div",{className:"flex items-center justify-center h-[200px] text-muted-foreground",children:"No completed campaigns to display"});const r=t.length===1?[{name:"",sent:0,delivered:0,blocked:0},...t]:t;return n.jsx(On,{width:"100%",height:200,children:n.jsxs(bo,{data:r,margin:{top:10,right:30,left:0,bottom:0},children:[n.jsx(Wi,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Rn,{dataKey:"name",tick:{fontSize:12},className:"text-xs fill-muted-foreground"}),n.jsx(Mn,{tick:{fontSize:12},className:"text-xs fill-muted-foreground",allowDecimals:!1}),n.jsx(In,{contentStyle:{backgroundColor:"hsl(var(--card))",borderColor:"hsl(var(--border))",borderRadius:"var(--radius)"},labelStyle:{color:"hsl(var(--foreground))",fontWeight:"bold"}}),n.jsx(Pn,{}),n.jsx(Jn,{type:"monotone",dataKey:"sent",name:"Sent",stackId:"1",stroke:"rgba(63, 203, 255, 1)",fill:"rgba(63, 203, 255, 0.8)"}),n.jsx(Jn,{type:"monotone",dataKey:"delivered",name:"Delivered",stackId:"1",stroke:"rgba(76, 219, 196, 1)",fill:"rgba(76, 219, 196, 0.8)"}),n.jsx(Jn,{type:"monotone",dataKey:"blocked",name:"Blocked",stackId:"1",stroke:"rgba(255, 174, 93, 1)",fill:"rgba(255, 174, 93, 0.8)"})]})})}const Oc="7687fafb-7b8f-4452-a47a-96cec312aff6";function Rs({outcome:e,severity:t}){return t==="info"?n.jsx("div",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-[#3FCBFF]",title:"Informational",children:n.jsx(_n,{className:"h-3 w-3 text-white"})}):e==="positive"?n.jsx("div",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-[#4CDBC4]",title:"Effective Security",children:n.jsx(Ao,{className:"h-3 w-3 text-white"})}):e==="negative"?n.jsx("div",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-[#FE7058]",title:"Improvement Opportunity",children:n.jsx(Oi,{className:"h-3 w-3 text-white"})}):null}function Ic(e){if(e.includes(":")){const[t,...r]=e.split(":");return n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"font-semibold",children:[t,":"]}),r.join(":")]})}return n.jsx(n.Fragment,{children:e})}function Pc({result:e}){let t=null;return Array.isArray(e)?t=e.length:typeof e=="number"&&(t=e),t===null?null:n.jsx(De,{variant:"secondary",className:"text-xs flex-shrink-0",children:t})}function Fc({extension:e}){return n.jsx("img",{src:`/images/${e}.png`,alt:e,title:e,className:"h-4 w-4",onError:t=>{t.target.src="/images/blank.png"}})}function $c({result:e,insightId:t}){if(typeof e=="boolean")return null;if(typeof e=="number")return n.jsxs("div",{className:"mt-2 pt-2 border-t",children:[n.jsx("span",{className:"font-medium text-sm",children:"Result: "}),n.jsx("span",{className:"text-sm text-muted-foreground",children:e})]});if(typeof e=="string")return n.jsxs("div",{className:"mt-2 pt-2 border-t",children:[n.jsx("span",{className:"font-medium text-sm",children:"Result: "}),n.jsx("span",{className:"text-sm text-muted-foreground",children:e})]});if(Array.isArray(e)&&e.length>0){const r=t===Oc;if(typeof e[0]=="object"&&e[0]!==null){const s=[...e].sort((i,a)=>{const o=Object.values(i)[0]||0;return(Object.values(a)[0]||0)-o});return n.jsxs("div",{className:"mt-2 pt-2 border-t",children:[n.jsx("span",{className:"font-medium text-sm",children:"Result:"}),n.jsxs("table",{className:"w-full mt-1 text-sm",children:[r&&n.jsx("thead",{children:n.jsxs("tr",{className:"text-left text-muted-foreground",children:[n.jsx("th",{className:"pr-4 w-6"}),n.jsx("th",{className:"pr-4 font-medium",children:"Extension"}),n.jsx("th",{className:"pr-4 font-medium",children:"Count"})]})}),n.jsx("tbody",{children:s.map((i,a)=>Object.entries(i).map(([l,u])=>n.jsxs("tr",{children:[r&&n.jsx("td",{className:"pr-2 py-0.5",children:n.jsx(Fc,{extension:l})}),n.jsx("td",{className:"pr-4 py-0.5 text-muted-foreground",children:l}),n.jsx("td",{className:"py-0.5 text-muted-foreground",children:String(u)})]},`${a}-${l}`)))})]})]})}return e.every(s=>typeof s=="string")?n.jsxs("div",{className:"mt-2 pt-2 border-t",children:[n.jsx("span",{className:"font-medium text-sm",children:"Result:"}),n.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:e.map((s,i)=>n.jsx("div",{children:s},i))})]}):n.jsxs("div",{className:"mt-2 pt-2 border-t",children:[n.jsx("span",{className:"font-medium text-sm",children:"Result: "}),n.jsxs("span",{className:"text-sm text-muted-foreground",children:[e.length," item(s)"]})]})}return Array.isArray(e)&&e.length===0?n.jsxs("div",{className:"mt-2 pt-2 border-t",children:[n.jsx("span",{className:"font-medium text-sm",children:"Result: "}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"None"})]}):null}function zc({insights:e,isPremium:t,onUpgradeClick:r}){if(!e||e.length===0)return n.jsx("div",{className:"text-center py-4 text-muted-foreground text-sm",children:"No insights available for this campaign"});const s=[...e].sort((i,a)=>{const o={high:3,medium:2,low:1,info:0},l={negative:3,positive:2,info:1},u=o[a.severity]-o[i.severity];return u!==0?u:l[a.outcome]-l[i.outcome]});return n.jsx(kr,{children:n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"rounded-md border",children:n.jsx(Nt,{children:n.jsx(kt,{children:s.map(i=>n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsxs(we,{className:"cursor-help",children:[n.jsx(ee,{className:"w-[40px] p-2",children:n.jsx(Rs,{outcome:i.outcome,severity:i.severity})}),n.jsx(ee,{className:"py-2",children:n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-sm",children:Ic(i.name)}),n.jsx(Pc,{result:i.result})]})})]})}),n.jsx(ae,{side:"left",className:"max-w-md p-4",sideOffset:10,children:n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Rs,{outcome:i.outcome,severity:i.severity}),n.jsx("span",{className:"font-semibold",children:i.name})]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:i.description}),n.jsx($c,{result:i.result,insightId:i.id})]})})]},i.id))})})}),!t&&n.jsxs("div",{className:"rounded-md border overflow-hidden relative isolate",children:[n.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[n.jsx("div",{className:"absolute top-1/2 right-1/4 -translate-y-1/2 w-32 h-32 bg-primary/20 rounded-full blur-2xl"}),n.jsx("div",{className:"absolute top-1/2 left-1/4 -translate-y-1/2 w-28 h-28 bg-chart-purple/20 rounded-full blur-2xl"}),n.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-48 h-16 bg-primary/15 rounded-full blur-3xl"})]}),n.jsxs("button",{onClick:r,className:"flex items-center gap-3 py-3 px-4 relative z-10 w-full hover:bg-muted/50 transition-colors cursor-pointer text-left",children:[n.jsx(wn,{className:"h-6 w-6 text-primary shrink-0"}),n.jsxs("span",{className:"text-sm text-muted-foreground",children:["See all the insights available to Premium & Enterprise users"," ",n.jsx("a",{href:"https://docs.delivr.to/docs/campaigns/insights",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-primary hover:underline",onClick:i=>i.stopPropagation(),children:"here"}),"."]})]})]})]})})}const tn={Hosted:{bg:"#3FCBFF",text:"#ffffff",darkText:"#0c4a5e"}
7,Accessed:{bg:"#3FCBFF",text:"#ffffff",darkText:"#0c4a5e"},Delivered:{bg:"#4CDBC4",text:"#ffffff",darkText:"#134e45"},Deleted:{bg:"#FFAE5D",text:"#ffffff",darkText:"#7c2d12"},Blocked:{bg:"#FFAE5D",text:"#ffffff",darkText:"#7c2d12"},"No Download":{bg:"#FFAE5D",text:"#ffffff",darkText:"#7c2d12"}};function zr(e,t){if(t)switch(t.status){case"verified":return"Delivered";case"deleted":return"Deleted";case"hash_mismatch":return"Blocked";case"no_download":return"No Download";case"downloading":return"Accessed"}const r=e.client_reports?.length?e.client_reports[e.client_reports.length-1]:void 0;if(r)switch(r.status){case"verified":return"Delivered";case"deleted":return"Deleted";case"hash_mismatch":return"Blocked";case"timeout":return"Accessed";case"no_download":return"No Download";case"not_accessed":return"Hosted"}return e.accesses?.some(i=>i.status==="downloaded")||e.click_count>0?"Accessed":"Hosted"}const Lc=["Delivered","Deleted","Blocked","No Download","Accessed","Hosted"];function Bc(e,t){const r=new Map;for(const s of e){const i=t?.get(s.link_id),a=zr(s,i);r.set(a,(r.get(a)??0)+1)}return Lc.filter(s=>(r.get(s)??0)>0).map(s=>({name:s,value:r.get(s),color:tn[s].bg}))}function ea({impact:e}){if(e==="info")return n.jsx("div",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-[#3FCBFF]",title:"Informational",children:n.jsx(_n,{className:"h-3 w-3 text-white"})});const t={high:"#FE7058",medium:"#FFAE5D",low:"#4CDBC4"};return n.jsx("div",{className:"flex h-5 w-5 items-center justify-center rounded-full",style:{backgroundColor:t[e]},title:`Impact to Security Posture: ${e.charAt(0).toUpperCase()+e.slice(1)}`,children:n.jsx(Oi,{className:"h-3 w-3 text-white"})})}function ta({effort:e}){const t={low:"#3FCBFF",medium:"#FFAE5D",high:"#E74C3C"};return n.jsx("span",{title:`Expected implementation effort: ${e.charAt(0).toUpperCase()+e.slice(1)}`,children:n.jsx(Bo,{className:"h-4 w-4",style:{fill:t[e],color:t[e]}})})}function qc({recommendation:e,relatedEmails:t,relatedPayloadLinks:r,open:s,onOpenChange:i}){const[a,o]=E.useState(null),[l,u]=E.useState(!1);if(!e)return null;const c=w=>{o(w.recipe_uuid),u(!0)},h=w=>{w.recipe_id&&(o(w.recipe_id),u(!0))};return n.jsxs(n.Fragment,{children:[n.jsx($e,{open:s,onOpenChange:i,children:n.jsx(ze,{className:"max-w-[800px] max-h-[80vh] overflow-y-auto sm:max-w-[90vw] md:max-w-[800px]",children:n.jsxs("div",{className:"w-full overflow-hidden",children:[n.jsxs(Le,{className:"pr-6",children:[n.jsx(Be,{asChild:!0,children:n.jsxs("div",{className:"flex items-start gap-2 text-lg font-semibold",children:[n.jsx("span",{className:"shrink-0 mt-0.5",children:n.jsx(ea,{impact:e.impact_posture})}),n.jsx("span",{className:"break-words hyphens-auto",children:e.name})]})}),n.jsxs(qe,{className:"flex items-center gap-4 pt-2 flex-wrap",children:[n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Impact:"}),n.jsx(De,{variant:"outline",className:"capitalize",children:e.impact_posture})]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Effort:"}),n.jsx(ta,{effort:e.effort}),n.jsx("span",{className:"capitalize text-sm",children:e.effort})]})]})]}),n.jsx("div",{className:"mt-4 prose dark:prose-invert prose-sm max-w-full break-words hyphens-auto prose-pre:overflow-x-auto prose-pre:max-w-full prose-pre:whitespace-pre-wrap prose-pre:break-all prose-code:break-all",children:n.jsx(Eo,{children:e.description})}),t.length>0&&n.jsxs("div",{className:"mt-6 pt-4 border-t",children:[n.jsxs("h4",{className:"text-sm font-medium mb-3",children:["Related Emails (",t.length,")"]}),n.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:t.map(w=>{const y=oi[w.status]||oi.Pending;return n.jsxs("button",{type:"button",onClick:()=>c(w),className:"flex items-center justify-between gap-2 p-2 rounded-md bg-muted/50 text-sm w-full text-left hover:bg-muted transition-colors cursor-pointer",children:[n.jsx("span",{className:"truncate flex-1 text-primary hover:underline",title:w.payload_name,children:w.payload_name}),n.jsx(De,{style:{backgroundColor:y.bg,"--status-text":y.text,"--status-text-dark":y.darkText},className:"font-normal text-xs shrink-0 text-[--status-text] dark:text-[--status-text-dark]",children:w.status})]},w.email_id)})})]}),r.length>0&&n.jsxs("div",{className:"mt-6 pt-4 border-t",children:[n.jsxs("h4",{className:"text-sm font-medium mb-3",children:["Related Payloads (",r.length,")"]}),n.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:r.map(w=>{const y=zr(w),v=tn[y];return n.jsxs("button",{type:"button",onClick:()=>h(w),disabled:!w.recipe_id,className:"flex items-center justify-between gap-2 p-2 rounded-md bg-muted/50 text-sm w-full text-left hover:bg-muted transition-colors cursor-pointer disabled:cursor-default disabled:hover:bg-muted/50",children:[n.jsx("span",{className:w.recipe_id?"truncate flex-1 text-primary hover:underline":"truncate flex-1 text-muted-foreground",title:w.payload_name,children:w.payload_name}),n.jsx(De,{style:{backgroundColor:v.bg,"--status-text":v.text,"--status-text-dark":v.darkText},className:"font-normal text-xs shrink-0 text-[--status-text] dark:text-[--status-text-dark]",children:y})]},w.link_id)})})]})]})})}),n.jsx(Mr,{payloadId:a,open:l,onOpenChange:u})]})}function Hc({recommendations:e,emails:t=[],payloadLinks:r=[],isPremium:s}){const[i,a]=E.useState(null),[o,l]=E.useState(!1),u=y=>t.filter(v=>v.recommendations?.includes(y)),c=y=>r.filter(v=>v.recommendations?.includes(y));if(!e||e.length===0)return n.jsx("div",{className:"text-center py-4 text-muted-foreground text-sm",children:"No recommendations available for this campaign"});const h=[...e].sort((y,v)=>{const S={high:4,medium:3,low:2,info:1},j={low:1,medium:2,high:3},b=S[v.impact_posture]-S[y.impact_posture];return b!==0?b:j[y.effort]-j[v.effort]}),w=y=>{a(y),l(!0)};return n.jsxs(kr,{children:[n.jsx("div",{className:"rounded-md border",children:n.jsx(Nt,{children:n.jsxs(kt,{children:[h.map(y=>n.jsxs(we,{className:"cursor-pointer hover:bg-accent",onClick:()=>w(y),children:[n.jsx(ee,{className:"w-[40px] p-2",children:n.jsx(ea,{impact:y.impact_posture})}),n.jsx(ee,{className:"py-2",children:n.jsx("span",{className:"text-sm text-primary hover:underline",children:y.name})}),n.jsx(ee,{className:"w-[40px] p-2",children:n.jsxs(se,{children:[n.jsx(ie,{children:n.jsx(ta,{effort:y.effort})}),n.jsxs(ae,{children:["Effort:"," ",y.effort.charAt(0).toUpperCase()+y.effort.slice(1)]})]})})]},y.id)),!s&&n.jsxs(n.Fragment,{children:[n.jsx(we,{children:n.jsx(ee,{colSpan:3,className:"p-0 h-px"})}),n.jsx(we,{children:n.jsxs(ee,{colSpan:3,className:"text-center py-3 text-sm text-muted-foreground opacity-50",children:["See all the recommendations available to Premium & Enterprise users"," ",n.jsx("a",{href:"https://docs.delivr.to/docs/campaigns/recommendations",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-primary hover:underline",children:"here"}),"."]})})]})]})})}),n.jsx(qc,{recommendation:i,relatedEmails:i?u(i.id):[],relatedPayloadLinks:i?c(i.id
7):[],open:o,onOpenChange:l})]})}function Uc({open:e,onOpenChange:t,defenderData:r,recipient:s,sentTime:i}){if(!r)return null;const a=[];r.detection_methods&&Object.entries(r.detection_methods).forEach(([u,c])=>{Array.isArray(c)&&c.forEach(h=>{a.push({type:u,name:String(h)})})});const l=(()=>{if(!r.id||!s||!i)return null;const u=new Date(i*1e3).toISOString();return`https://security.microsoft.com/emailentity?f=v2&startTime=${u}&endTime=${u}&id=${r.id}&recipient=${s}`})();return n.jsx($e,{open:e,onOpenChange:t,children:n.jsxs(ze,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[n.jsxs(Le,{children:[n.jsxs(Be,{className:"flex items-center gap-2",children:[n.jsx("img",{src:"/images/defender.png",alt:"Defender",className:"h-8 w-8"}),"Microsoft Defender 365"]}),n.jsx(qe,{children:"Security detection information for this email"})]}),n.jsxs("div",{className:"space-y-4 mt-4",children:[r.org_level_policy&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"font-semibold text-sm",children:"Org-level Policy:"}),n.jsxs("span",{className:"text-sm",children:[r.org_level_policy,r.org_level_action&&n.jsx("code",{className:"ml-2 px-1 bg-destructive/10 text-destructive rounded",children:r.org_level_action})]})]}),r.user_level_policy&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"font-semibold text-sm",children:"User-level Policy:"}),n.jsxs("span",{className:"text-sm",children:[r.user_level_policy,r.user_level_action&&n.jsx("code",{className:"ml-2 px-1 bg-destructive/10 text-destructive rounded",children:r.user_level_action})]})]}),n.jsxs("div",{className:"space-y-2 p-3 rounded-md bg-muted",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"font-semibold text-sm",children:"Threat Name(s):"}),n.jsx("span",{className:"text-sm",children:r.threat_names||"None"})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"font-semibold text-sm",children:"Threat Types:"}),n.jsx("span",{className:"text-sm",children:r.threat_types||"None"})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"font-semibold text-sm",children:"State:"}),n.jsx("code",{className:"px-1 bg-destructive/10 text-destructive rounded text-sm",children:r.state})]})]}),n.jsxs("div",{children:[n.jsx("h4",{className:"font-semibold mb-2",children:"Detection Methods"}),n.jsx("div",{className:"rounded-md border",children:n.jsxs(Nt,{children:[n.jsx(sn,{children:n.jsxs(we,{children:[n.jsx(oe,{children:"Detection"}),n.jsx(oe,{children:"Type"})]})}),n.jsx(kt,{children:a.length>0?a.map((u,c)=>n.jsxs(we,{children:[n.jsx(ee,{children:u.name}),n.jsx(ee,{children:u.type})]},c)):n.jsx(we,{children:n.jsx(ee,{colSpan:2,className:"text-center text-muted-foreground",children:"No detections found."})})})]})})]}),l&&n.jsx(G,{asChild:!0,variant:"outline",className:"w-full",children:n.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:[n.jsx($n,{className:"h-4 w-4 mr-2"}),"View Email in Defender 365"]})})]})]})})}function Vc({open:e,onOpenChange:t,sublimeData:r,integrations:s,recipient:i}){const[a,o]=E.useState(null);if(!r)return null;const u=(()=>{if(!s||!i)return null;const h=s.find(y=>y.integration_type.toLowerCase()==="sublime"&&y.email.toLowerCase()===i.toLowerCase());if(!h?.api_url)return null;let w=h.api_url;return w.endsWith("/")||(w+="/"),w.includes("api.platform.sublimesecurity.com")&&(w=w.replace("api.","")),`${w}messages/${r.id}/`})(),c=h=>{navigator.clipboard.writeText(h),o(h),W.success("Sublime Rule ID copied to clipboard"),setTimeout(()=>o(null),2e3)};return n.jsx($e,{open:e,onOpenChange:t,children:n.jsxs(ze,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[n.jsxs(Le,{children:[n.jsxs(Be,{className:"flex items-center gap-2",children:[n.jsx(at,{service:"sublime",size:32}),"Sublime Rules"]}),n.jsx(qe,{children:"Sublime Security detection results for this email"})]}),n.jsxs("div",{className:"space-y-4 mt-4",children:[n.jsx("div",{className:"p-3 rounded-md bg-muted",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"font-semibold text-sm",children:"State:"}),n.jsx("code",{className:"px-1 bg-destructive/10 text-destructive rounded text-sm",children:r.state})]})}),n.jsx("div",{className:"rounded-md border",children:n.jsxs(Nt,{children:[n.jsx(sn,{children:n.jsxs(we,{children:[n.jsx(oe,{className:"w-[50px]",children:"ID"}),n.jsx(oe,{children:"Rule"}),n.jsx(oe,{children:"Tags"})]})}),n.jsx(kt,{children:r.flagged_rules&&r.flagged_rules.length>0?r.flagged_rules.map((h,w)=>n.jsxs(we,{children:[n.jsx(ee,{className:"p-2",children:h.id&&n.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>c(h.id),title:h.id,children:n.jsx(_t,{className:`h-3 w-3 ${a===h.id?"text-green-500":""}`})})}),n.jsx(ee,{children:h.name}),n.jsx(ee,{children:h.tags&&h.tags.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1",children:h.tags.map((y,v)=>n.jsx(De,{variant:"secondary",className:"text-xs",children:y},v))})})]},w)):n.jsx(we,{children:n.jsx(ee,{colSpan:3,className:"text-center text-muted-foreground",children:"No flagged rules."})})})]})}),u&&n.jsx(G,{asChild:!0,variant:"outline",className:"w-full",children:n.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[n.jsx($n,{className:"h-4 w-4 mr-2"}),"View Email in Sublime"]})})]})]})})}const Wc={BLOCKED:"bg-destructive/10 text-destructive",EMPLOYEE_IGNORED_WARNING:"bg-warning/10 text-warning",EMPLOYEE_WARNED:"bg-warning/10 text-warning",NOT_BLOCKED:"bg-success/10 text-success"},Gc={CRITICAL:"bg-destructive text-white",HIGH:"bg-destructive/80 text-white",MEDIUM:"bg-warning text-white",LOW:"bg-muted text-muted-foreground"};function Kc(e){return e.split("_").map(t=>t.charAt(0)+t.slice(1).toLowerCase()).join(" ")}
7function Jc({open:e,onOpenChange:t,pushSecurityData:r,payloadName:s}){if(!r)return null;const{detections:i}=r;return n.jsx($e,{open:e,onOpenChange:t,children:n.jsxs(ze,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[n.jsxs(Le,{children:[n.jsxs(Be,{className:"flex items-center gap-2",children:[n.jsx(at,{service:"push_security",size:32}),"Push Security Detections"]}),n.jsxs(qe,{children:["Browser security detections for ",s||"this link"]})]}),n.jsxs("div",{className:"space-y-4 mt-4",children:[i.length===0?n.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No detections recorded."}):n.jsx("div",{className:"rounded-md border",children:n.jsxs(Nt,{children:[n.jsx(sn,{children:n.jsxs(we,{children:[n.jsx(oe,{children:"Type"}),n.jsx(oe,{children:"Severity"}),n.jsx(oe,{children:"Response"}),n.jsx(oe,{children:"Employee"}),n.jsx(oe,{children:"Time"})]})}),n.jsx(kt,{children:i.map((a,o)=>n.jsxs(we,{children:[n.jsx(ee,{className:"text-sm",children:a.detection_type.split("_").map(l=>l.charAt(0)+l.slice(1).toLowerCase()).join(" ")}),n.jsx(ee,{children:n.jsx(De,{className:Gc[a.severity]||"",children:a.severity})}),n.jsx(ee,{children:n.jsx("code",{className:`px-1.5 py-0.5 rounded text-xs ${Wc[a.response]||""}`,children:Kc(a.response)})}),n.jsx(ee,{className:"text-sm text-muted-foreground",children:a.employee_email||"N/A"}),n.jsx(ee,{className:"text-sm text-muted-foreground whitespace-nowrap",children:new Date(a.timestamp*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})})]},o))})]})}),i.length>0&&n.jsx("div",{className:"space-y-3",children:i.map((a,o)=>n.jsxs("div",{className:"p-3 rounded-md bg-muted space-y-1.5 text-sm",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"font-semibold",children:"Event URL:"}),n.jsx("code",{className:"text-xs break-all",children:a.event_url})]}),a.referrer_url&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"font-semibold",children:"Referrer:"}),n.jsx("code",{className:"text-xs break-all",children:a.referrer_url})]}),a.phishing_tool_indicator&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"font-semibold",children:"Phishing Tool:"}),n.jsx("code",{className:"text-xs",children:a.phishing_tool_indicator})]})]},o))})]})]})})}function Yc({open:e,onOpenChange:t,emlContent:r,emailId:s,isLoading:i}){const a=()=>{r&&(navigator.clipboard.writeText(r),W.success("EML copied to clipboard"))},o=()=>{if(!r)return;const l=new Blob([r],{type:"text/plain"}),u=URL.createObjectURL(l),c=document.createElement("a");c.href=u,c.download=`${s||"email"}.eml`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(u),W.success("EML file downloaded")};return n.jsx($e,{open:e,onOpenChange:t,children:n.jsxs(ze,{className:"max-w-4xl max-h-[90vh] flex flex-col",children:[n.jsxs(Le,{children:[n.jsxs(Be,{className:"flex items-center gap-2",children:[n.jsx(Fn,{className:"h-5 w-5 text-primary"}),"View EML"]}),n.jsx(qe,{children:"Raw email content in EML format"})]}),n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:i?n.jsx("div",{className:"flex items-center justify-center h-64",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsx(Mi,{value:r||"",readOnly:!0,className:"h-[60vh] font-mono text-xs resize-none",placeholder:"No EML content available"})}),n.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[n.jsxs(G,{variant:"outline",onClick:a,disabled:!r||i,children:[n.jsx(_t,{className:"h-4 w-4 mr-2"}),"Copy to Clipboard"]}),n.jsxs(G,{variant:"outline",onClick:o,disabled:!r||i,children:[n.jsx(de,{className:"h-4 w-4 mr-2"}),"Download EML"]})]})]})})}function Xc({open:e,onOpenChange:t,gatewayResponse:r}){const[s,i]=E.useState(!1),a=()=>{r&&(navigator.clipboard.writeText(r),i(!0),W.success("Gateway response copied to clipboard"),setTimeout(()=>i(!1),2e3))};return n.jsx($e,{open:e,onOpenChange:t,children:n.jsxs(ze,{className:"max-w-2xl",children:[n.jsxs(Le,{children:[n.jsxs(Be,{className:"flex items-center gap-2",children:[n.jsx(Lo,{className:"h-5 w-5 text-primary"}),"Gateway Response"]}),n.jsx(qe,{children:"Response from the mail gateway for this email"})]}),n.jsx("div",{className:"mt-4",children:n.jsx(Mi,{value:r||"",readOnly:!0,className:"h-32 font-mono text-xs resize-none",placeholder:"No gateway response available"})}),n.jsx("div",{className:"flex justify-end mt-4",children:n.jsxs(G,{variant:"outline",onClick:a,disabled:!r,children:[n.jsx(_t,{className:`h-4 w-4 mr-2 ${s?"text-green-500":""}`}),"Copy to Clipboard"]})})]})})}function Zc(e,t){return t&&t.length>0?t.map(r=>({http_method:r.http_method,user_agent:r.user_agent,timestamp:typeof r.timestamp=="str
7ing"?parseInt(r.timestamp,10):r.timestamp,source_ip:r.source_ip,geo_city:r.geo_city,geo_country:r.geo_country,blocked_by:r.blocked_by})):e&&e.length>0?e.map(r=>({http_method:r.http_method,user_agent:r.user_agent,timestamp:parseInt(r.timestamp,10),source_ip:r.source_ip})):[]}function Qc(e){return isNaN(e)?"":new Date(e*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Ms(e){const t=e.geo_city&&e.geo_city!=="unknown"?e.geo_city:null,r=e.geo_country&&e.geo_country!=="unknown"?e.geo_country:null;return t&&r?`${t}, ${r}`:r||null}function na({open:e,onOpenChange:t,clicks:r,accesses:s,recipient:i}){const o=[...Zc(r,s)].sort((c,h)=>h.timestamp-c.timestamp),l=o.some(c=>Ms(c)!==null),u=o.some(c=>c.status);return n.jsx($e,{open:e,onOpenChange:t,children:n.jsxs(ze,{className:"max-w-4xl max-h-[80vh] flex flex-col",children:[n.jsxs(Le,{children:[n.jsxs(Be,{className:"flex items-center gap-2",children:[n.jsx(Fo,{className:"h-5 w-5 text-primary"}),"Click Details"]}),i&&n.jsxs(qe,{children:["Click tracking data for ",i]})]}),n.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:o.length===0?n.jsx("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:"No click data available"}):n.jsxs(Nt,{children:[n.jsx(sn,{children:n.jsxs(we,{children:[n.jsx(oe,{className:"w-[80px]",children:"Method"}),l&&n.jsx(oe,{className:"w-[160px]",children:"Location"}),n.jsx(oe,{children:"User Agent"}),n.jsx(oe,{className:"w-[160px]",children:"Time"}),n.jsx(oe,{className:"w-[140px]",children:"Source IP"}),u&&n.jsx(oe,{className:"w-[100px]",children:"Status"})]})}),n.jsx(kt,{children:o.map((c,h)=>{const w=Ms(c);return n.jsxs(we,{children:[n.jsx(ee,{children:n.jsx("span",{className:`font-mono text-xs px-2 py-1 rounded ${c.http_method==="GET"?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":c.http_method==="POST"?"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200":"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}`,children:c.http_method})}),l&&n.jsx(ee,{className:"text-xs",children:w?n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx(Po,{className:"h-3 w-3 text-muted-foreground"}),w]}):n.jsx("span",{className:"text-muted-foreground",children:"Unknown"})}),n.jsx(ee,{className:"max-w-[400px] truncate text-xs",title:c.user_agent,children:c.user_agent}),n.jsx(ee,{className:"text-xs",children:Qc(c.timestamp)}),n.jsx(ee,{className:"font-mono text-xs",children:c.source_ip}),u&&n.jsx(ee,{children:c.status&&n.jsx(De,{variant:c.status==="downloaded"?"default":"destructive",className:"text-xs",children:c.status})})]},h)})})]})}),o.length>0&&n.jsxs("div",{className:"text-xs text-muted-foreground pt-2 border-t",children:[o.length," click",o.length!==1?"s":""," recorded"]})]})})}function ed({campaignId:e,campaignStatus:t,isPremium:r}){const s=Zo(e),[i,a]=E.useState(!1),o=t!=="Completed",l=async u=>{if(!r){a(!0);return}if(t!=="Completed"){W.error("Reports can only be downloaded for completed campaigns");return}W.loading("Generating report...",{id:"download-report"});try{await s.mutateAsync(u),W.success("Report downloaded successfully",{id:"download-report"})}catch{W.error("Error downloading report. Please try again.",{id:"download-report"})}};return n.jsxs(n.Fragment,{children:[n.jsxs(wt,{children:[n.jsx(bt,{asChild:!0,children:n.jsxs(G,{variant:"outline",size:"sm",disabled:o||s.isPending,children:[s.isPending?n.jsx("div",{className:"animate-spin h-4 w-4 mr-2 border-2 border-current border-t-transparent rounded-full"}):n.jsx(de,{className:"h-4 w-4 mr-2"}),"Download Report",!r&&n.jsx(wn,{className:"ml-2 h-3 w-3 text-primary"})]})}),n.jsxs(jt,{align:"end",children:[n.jsx(xe,{onClick:()=>l("html"),children:"HTML Report"}),n.jsx(xe,{onClick:()=>l("markdown"),children:"Markdown Report"}),n.jsx(xe,{onClick:()=>l("json"),children:"JSON Report"})]})]}),n.jsx(or,{open:i,onOpenChange:a,feature:"campaign reports"})]})}function Lt(e){const t=new Date(e*1e3),r=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${r}-${s}-${i} ${a}:${o}`}function ra(e){const t=e.client_reports?.length?e.client_reports[e.client_reports.length-1]:void 0;if(t)switch(t.status){case"verified":return"Delivered";case"deleted":return"Deleted";case"hash_mismatch":return"Blocked";case"timeout":return"Accessed";case"no_download":return"No Download"}return e.accesses?.some(s=>s.status==="downloaded")||e.click_count>0?"Accessed":"Hosted"}function td(e){const t=["Sent","Email ID","Delivery Type","Extension","Payload","Payload Description","Payload References","Payload Tags","Status","Click Data","Gateway Response"],r=e.map(i=>[Lt(i.sent),i.email_id,i.mail_type==="as_link"?"Link":"Attachment",i.extension,i.payload_name,i.payload_description||"",JSON.stringify(i.payload_references||[]),JSON.stringify(i.payload_tags||[]),i.status,JSON.stringify(i.clicks||[]),i.sendgrid_reason||""]);return[t.map(i=>`"${i}"`).join(","),...r.map(i=>i.map(a=>`"${String(a).replace(/"/g,'""')}"`).join(","))].join(`
8`)}
8function nd(e){const t=e.map(r=>({sent:Lt(r.sent),email_id:r.email_id,delivery_type:r.mail_type==="as_link"?"Link":"Attachment",extension:r.extension,payload:r.payload_name,payload_description:r.payload_description||"",payload_references:r.payload_references||[],payload_tags:r.payload_tags||[],status:r.status,click_data:r.clicks||[],gateway_response:r.sendgrid_reason||""}));return JSON.stringify(t,null,2)}function rd(e){const t=["Generated","Link ID","Payload ID","Recipe ID","Extension","Payload","Status","Clicks","Click Data","Expiry"],r=e.map(i=>[Lt(i.generation_epoch),i.link_id,i.payload_id,i.recipe_id||"",i.extension||"",i.payload_name,ra(i),String(i.click_count),JSON.stringify(i.accesses||[]),Lt(i.expiry_epoch)]);return[t.map(i=>`"${i}"`).join(","),...r.map(i=>i.map(a=>`"${String(a).replace(/"/g,'""')}"`).join(","))].join(`
9`)}function sd(e){const t=e.map(r=>({generated:Lt(r.generation_epoch),link_id:r.link_id,payload_id:r.payload_id,recipe_id:r.recipe_id||"",extension:r.extension||"",payload:r.payload_name,status:ra(r),clicks:r.click_count,click_data:r.accesses||[],expiry:Lt(r.expiry_epoch)}));return JSON.stringify(t,null,2)}function Os(e,t,r){const s=new Blob([e],{type:r}),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function Is({emails:e,payloadLinks:t,campaignName:r="campaign"}){const s=!!t,i=s?t?.length??0:e?.length??0,a=o=>{if(i===0){W.error("No results to export");return}const l=new Date().toISOString().split("T")[0],u=r.replace(/[^a-z0-9]/gi,"_").toLowerCase();if(o==="csv"){const c=s?rd(t):td(e);Os(c,`${u}_results_${l}.csv`,"text/csv")}else{const c=s?sd(t):nd(e);Os(c,`${u}_results_${l}.json`,"application/json")}W.success(`Exported ${i} results to ${o.toUpperCase()}`)};return n.jsxs(wt,{children:[n.jsx(bt,{asChild:!0,children:n.jsxs(G,{variant:"outline",size:"sm",children:[n.jsx(de,{className:"h-4 w-4 mr-2"}),"Export Results"]})}),n.jsxs(jt,{align:"end",children:[n.jsx(xe,{onClick:()=>a("csv"),children:"Export as CSV"}),n.jsx(xe,{onClick:()=>a("json"),children:"Export as JSON"})]})]})}function Ps(e,t,r){const s=new Blob([e],{type:r}),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function id(e){const t=["Insight ID","Name","Description","Outcome","Severity","Result"],r=e.map(i=>[i.id,i.name,i.description,i.outcome,i.severity,typeof i.result=="boolean"?i.result.toString():JSON.stringify(i.result)]);return[t.map(i=>`"${i}"`).join(","),...r.map(i=>i.map(a=>`"${String(a).replace(/"/g,'""')}"`).join(","))].join(`
10`)}function ad(e){const t=e.map(r=>({insight_id:r.id,name:r.name,description:r.description,outcome:r.outcome,severity:r.severity,result:r.result}));return JSON.stringify(t,null,2)}function od({insights:e,campaignName:t="campaign"}){const r=s=>{if(!e||e.length===0){W.error("No insights to export");return}const i=new Date().toISOString().split("T")[0],a=t.replace(/[^a-z0-9]/gi,"_").toLowerCase();if(s==="csv"){const o=id(e);Ps(o,`${a}_insights_${i}.csv`,"text/csv"),W.success(`Exported ${e.length} insights to CSV`)}else{const o=ad(e);Ps(o,`${a}_insights_${i}.json`,"application/json"),W.success(`Exported ${e.length} insights to JSON`)}};return n.jsxs(wt,{children:[n.jsx(bt,{asChild:!0,children:n.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:[n.jsx(de,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Export Insights"})]})}),n.jsxs(jt,{align:"end",children:[n.jsx(xe,{onClick:()=>r("csv"),children:"Export as CSV"}),n.jsx(xe,{onClick:()=>r("json"),children:"Export as JSON"})]})]})}function Fs(e,t,r){const s=new Blob([e],{type:r}),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function ld(e){const t=["Recommendation ID","Impact on Security Posture","Recommendation Name","Recommendation Content","Effort to Implement"],r=e.map(i=>[i.id,i.impact_posture,i.name,i.description,i.effort]);return[t.map(i=>`"${i}"`).join(","),...r.map(i=>i.map(a=>`"${String(a).replace(/"/g,'""')}"`).join(","))].join(`
11`)}function cd(e){const t=e.map(r=>({recommendation_id:r.id,impact_on_security_posture:r.impact_posture,recommendation_name:r.name,recommendation_content:r.description,effort_to_implement:r.effort}));return JSON.stringify(t,null,2)}function dd({recommendations:e,campaignName:t="campaign"}){const r=s=>{if(!e||e.length===0){W.error("No recommendations to export");return}const i=new Date().toISOString().split("T")[0],a=t.replace(/[^a-z0-9]/gi,"_").toLowerCase();if(s==="csv"){const o=ld(e);Fs(o,`${a}_recommendations_${i}.csv`,"text/csv"),W.success(`Exported ${e.length} recommendations to CSV`)}else{const o=cd(e);Fs(o,`${a}_recommendations_${i}.json`,"application/json"),W.success(`Exported ${e.length} recommendations to JSON`)}};return n.jsxs(wt,{children:[n.jsx(bt,{asChild:!0,children:n.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:[n.jsx(de,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Export Recommendations"})]})}),n.jsxs(jt,{align:"end",children:[n.jsx(xe,{onClick:()=>r("csv"),children:"Export as CSV"}),n.jsx(xe,{onClick:()=>r("json"),children:"Export as JSON"})]})]})}var ud={value:()=>{}};function an(){for(var e=0,t=arguments.length,r={},s;e<t;++e){if(!(s=arguments[e]+"")||s in r||/[\s.]/.test(s))throw new Error("illegal type: "+s);r[s]=[]}return new xn(r)}function xn(e){this._=e}function hd(e,t){return e.trim().split(/^|\s+/).map(function(r){var s="",i=r.indexOf(".");if(i>=0&&(s=r.slice(i+1),r=r.slice(0,i)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:s}})}xn.prototype=an.prototype={constructor:xn,on:function(e,t){var r=this._,s=hd(e+"",r),i,a=-1,o=s.length;if(arguments.length<2){for(;++a<o;
vendor: 12,790 bytes, line 11
11)if((i=(e=s[a]).type)&&(i=fd(r[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<o;)if(i=(e=s[a]).type)r[i]=$s(r[i],e.name,t);else if(t==null)for(i in r)r[i]=$s(r[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var r in t)e[r]=t[r].slice();return new xn(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var r=new Array(i),s=0,i,a;s<i;++s)r[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],s=0,i=a.length;s<i;++s)a[s].value.apply(t,r)},apply:function(e,t,r){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],i=0,a=s.length;i<a;++i)s[i].value.apply(t,r)}};function fd(e,t){for(var r=0,s=e.length,i;r<s;++r)if((i=e[r]).name===t)return i.value}function $s(e,t,r){for(var s=0,i=e.length;s<i;++s)if(e[s].name===t){e[s]=ud,e=e.slice(0,s).concat(e.slice(s+1));break}return r!=null&&e.push({name:t,value:r}),e}var yr="http://www.w3.org/1999/xhtml";const zs={svg:"http://www.w3.org/2000/svg",xhtml:yr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Hn(e){var t=e+="",r=t.indexOf(":");return r>=0&&(t=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),zs.hasOwnProperty(t)?{space:zs[t],local:e}:e}function md(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===yr&&t.documentElement.namespaceURI===yr?t.createElement(e):t.createElementNS(r,e)}}function pd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function sa(e){var t=Hn(e);return(t.local?pd:md)(t)}function xd(){}function Lr(e){return e==null?xd:function(){return this.querySelector(e)}}function gd(e){typeof e!="function"&&(e=Lr(e));for(var t=this._groups,r=t.length,s=new Array(r),i=0;i<r;++i)for(var a=t[i],o=a.length,l=s[i]=new Array(o),u,c,h=0;h<o;++h)(u=a[h])&&(c=e.call(u,u.__data__,h,a))&&("__data__"in u&&(c.__data__=u.__data__),l[h]=c);return new Te(s,this._parents)}function yd(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function vd(){return[]}function ia(e){return e==null?vd:function(){return this.querySelectorAll(e)}}function wd(e){return function(){return yd(e.apply(this,arguments))}}function bd(e){typeof e=="function"?e=wd(e):e=ia(e);for(var t=this._groups,r=t.length,s=[],i=[],a=0;a<r;++a)for(var o=t[a],l=o.length,u,c=0;c<l;++c)(u=o[c])&&(s.push(e.call(u,u.__data__,c,o)),i.push(u));return new Te(s,i)}function aa(e){return function(){return this.matches(e)}}function oa(e){return function(t){return t.matches(e)}}var jd=Array.prototype.find;function _d(e){return function(){return jd.call(this.children,e)}}function Nd(){return this.firstElementChild}function kd(e){return this.select(e==null?Nd:_d(typeof e=="function"?e:oa(e)))}var Sd=Array.prototype.filter;function Cd(){return Array.from(this.children)}function Ad(e){return function(){return Sd.call(this.children,e)}}function Ed(e){return this.selectAll(e==null?Cd:Ad(typeof e=="function"?e:oa(e)))}function Dd(e){typeof e!="function"&&(e=aa(e));for(var t=this._groups,r=t.length,s=new Array(r),i=0;i<r;++i)for(var a=t[i],o=a.length,l=s[i]=[],u,c=0;c<o;++c)(u=a[c])&&e.call(u,u.__data__,c,a)&&l.push(u);return new Te(s,this._parents)}function la(e){return new Array(e.length)}function Td(){return new Te(this._enter||this._groups.map(la),this._parents)}function An(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}An.prototype={constructor:An,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Rd(e){return function(){return e}}function Md(e,t,r,s,i,a){for(var o=0,l,u=t.length,c=a.length;o<c;++o)(l=t[o])?(l.__data__=a[o],s[o]=l):r[o]=new An(e,a[o]);for(;o<u;++o)(l=t[o])&&(i[o]=l)}function Od(e,t,r,s,i,a,o){var l,u,c=new Map,h=t.length,w=a.length,y=new Array(h),v;for(l=0;l<h;++l)(u=t[l])&&(y[l]=v=o.call(u,u.__data__,l,t)+"",c.has(v)?i[l]=u:c.set(v,u));for(l=0;l<w;++l)v=o.call(e,a[l],l,a)+"",(u=c.get(v))?(s[l]=u,u.__data__=a[l],c.delete(v)):r[l]=new An(e,a[l]);for(l=0;l<h;++l)(u=t[l])&&c.get(y[l])===u&&(i[l]=u)}function Id(e){return e.__data__}function Pd(e,t){if(!arguments.length)return Array.from(this,Id);var r=t?Od:Md,s=this._parents,i=this._groups;typeof e!="function"&&(e=Rd(e));for(var a=i.length,o=new Array(a),l=new Array(a),u=new Array(a),c=0;c<a;++c){var h=s[c],w=i[c],y=w.length,v=Fd(e.call(h,h&&h.__data__,c,s)),S=v.length,j=l[c]=new Array(S),b=o[c]=new Array(S),p=u[c]=new Array(y);r(h,w,j,b,p,v,t);for(var m=0,f=0,d,x;m<S;++m)if(d=j[m]){for(m>=f&&(f=m+1);!(x=b[f])&&++f<S;);d._next=x||null}}return o=new Te(o,s),o._enter=l,o._exit=u,o}function Fd(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function $d(){return new Te(this._exit||this._groups.map(la),this._parents)}function zd(e,t,r){var s=this.enter(),i=this,a=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),r==null?a.remove():r(a),s&&i?s.merge(i).order():i}function Ld(e){for(var t=e.selection?e.selection():e,r=this._groups,s=t._groups,i=r.length,a=s.length,o=Math.min(i,a),l=new Array(i),u=0;u<o;++u)for(var c=r[u],h=s[u],w=c.length,y=l[u]=new Array(w),v,S=0;S<w;++S)(v=c[S]||h[S])&&(y[S]=v);for(;u<i;++u)l[u]=r[u];return new Te(l,this._parents)}function Bd(){for(var e=this._groups,t=-1,r=e.length;++t<r;)for(var s=e[t],i=s.length-1,a=s[i],o;--i>=0;)(o=s[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function qd(e){e||(e=Hd);function t(w,y){return w&&y?e(w.__data__,y.__data__):!w-!y}for(var r=this._groups,s=r.length,i=new Array(s),a=0;a<s;++a){for(var o=r[a],l=o.length,u=i[a]=new Array(l),c,h=0;h<l;++h)(c=o[h])&&(u[h]=c);u.sort(t)}return new Te(i,this._parents).order()}function Hd(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ud(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Vd(){return Array.from(this)}function Wd(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var s=e[t],i=0,a=s.length;i<a;++i){var o=s[i];if(o)return o}return null}function Gd(){let e=0;for(const t of this)++e;return e}function Kd(){return!this.node()}function Jd(e){for(var t=this._groups,r=0,s=t.length;r<s;++r)for(var i=t[r],a=0,o=i.length,l;a<o;++a)(l=i[a])&&e.call(l,l.__data__,a,i);return this}function Yd(e){return function(){this.removeAttribute(e)}}function Xd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zd(e,t){return function(){this.setAttribute(e,t)}}function Qd(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function eu(e,t){return function(){var r=t.apply(this,arguments);r==null?this.removeAttribute(e):this.setAttribute(e,r)}}function tu(e,t){return function(){var r=t.apply(this,arguments);r==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,r)}}function nu(e,t){var r=Hn(e);if(arguments.length<2){var s=this.node();return r.local?s.getAttributeNS(r.space,r.local):s.getAttribute(r)}return this.each((t==null?r.local?Xd:Yd:typeof t=="function"?r.local?tu:eu:r.local?Qd:Zd)(r,t))}function ca(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ru(e){return function(){this.style.removeProperty(e)}}function su(e,t,r){return function(){this.style.setProperty(e,t,r)}}function iu(e,t,r){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,r)}}function au(e,t,r){return arguments.length>1?this.each((t==null?ru:typeof t=="function"?iu:su)(e,t,r??"")):Bt(this.node(),e)}function Bt(e,t){return e.style.getPropertyValue(t)||ca(e).getComputedStyle(e,null).getPropertyValue(t)}function ou(e){return function(){delete this[e]}}function lu(e,t){return function(){this[e]=t}}function cu(e,t){return function(){var r=t.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function du(e,t){return arguments.length>1?this.each((t==null?ou:typeof t=="function"?cu:lu)(e,t)):this.node()[e]}function da(e){return e.trim().split(/^|\s+/)}function Br(e){return e.classList||new ua(e)}function ua(e){this._node=e,this._names=da(e.getAttribute("class")||"")}ua.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ha(e,t){for(var r=Br(e),s=-1,i=t.length;++s<i;)r.add(t[s])}function fa(e,t){for(var r=Br(e),s=-1,i=t.length;++s<i;)r.remove(t[s])}function uu(e){return function(){ha(this,e)}}function hu(e){return function(){fa(this,e)}}function fu(e,t){return function(){(t.apply(this,arguments)?ha:fa)(this,e)}}function mu(e,t){var r=da(e+"");if(arguments.length<2){for(var s=Br(this.node()),i=-1,a=r.length;++i<a;)if(!s.contains(r[i]))return!1;return!0}return this.each((typeof t=="function"?fu:t?uu:hu)(r,t))}function pu(){this.textContent=""}function xu(e){return function(){this.textContent=e}}function gu(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function yu(e){return arguments.length?this.each(e==null?pu:(typeof e=="function"?gu:xu)(e)):this.node().textContent}function vu(){this.innerHTML=""}function wu(e){return function(){this.innerHTML=e}}function bu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ju(e){return arguments.length?this.each(e==null?vu:(typeof e=="function"?bu:wu)(e)):this.node().innerHTML}function _u(){this.nextSibling&&this.parentNode.appendChild(this)}function Nu(){return this.each(_u)}function ku(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Su(){return this.each(ku)}function Cu(e){var t=typeof e=="function"?e:sa(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Au(){return null}function Eu(e,t){var r=typeof e=="function"?e:sa(e),s=t==null?Au:typeof t=="function"?t:Lr(t);return this.select(function(){return this.insertBefore(r.apply(this,arguments),s.apply(this,arguments)||null)})}function Du(){var e=this.parentNode;e&&e.removeChild(this)}function Tu(){return this.each(Du)}function Ru(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Mu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ou(e){return this.select(e?Mu:Ru)}function Iu(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Pu(e){return function(t){e.call(this,t,this.__data__)}}function Fu(e){return e.trim().split(/^|\s+/).map(function(t){var r="",s=t.indexOf(".");return s>=0&&(r=t.slice(s+1),t=t.slice(0,s)),{type:t,name:r}})}function $u(e){return function(){var t=this.__on;if(t){for(var r=0,s=-1,i=t.length,a;r<i;++r)a=t[r],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++s]=a;++s?t.length=s:delete this.__on}}}function zu(e,t,r){return function(){var s=this.__on,i,a=Pu(t);if(s){for(var o=0,l=s.length;o<l;++o)if((i=s[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=r),i.value=t;return}}this.addEventListener(e.type,a,r),i={type:e.type,name:e.name,value:t,listener:a,options:r},s?s.push(i):this.__on=[i]}}function Lu(e,t,r){var s=Fu(e+""),i,a=s.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var u=0,c=l.length,h;u<c;++u)for(i=0,h=l[u];i<a;++i)if((o=s[i]).type===h.type&&o.name===h.name)return h.value}return}for(l=t?zu:$u,i=0;i<a;++i)this.each(l(s[i],t,r));return this}function ma(e,t,r){var s=ca(e),i=s.CustomEvent;typeof i=="function"?i=new i(t,r):(i=s.document.createEvent("Event"),r?(i.initEvent(t,r.bubbles,r.cancelable),i.detail=r.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function Bu(e,t){return function(){return ma(this,e,t)}}function qu(e,t){return function(){return ma(this,e,t.apply(this,arguments))}}function Hu(e,t){return this.each((typeof t=="function"?qu:Bu)(e,t))}function*Uu(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var s=e[t],i=0,a=s.length,o;i<a;++i)(o=s[i])&&(yield o)}var pa=[null];function Te(e,t){this._groups=e,this._parents=t}function on(){return new Te([[document.documentElement]],pa)}function Vu(){return this}Te.prototype=on.prototype={constructor:Te,select:gd,selectAll:bd,selectChild:kd,selectChildren:Ed,filter:Dd,data:Pd,enter
vendor: 7,230 bytes, line 11
11:Td,exit:$d,join:zd,merge:Ld,selection:Vu,order:Bd,sort:qd,call:Ud,nodes:Vd,node:Wd,size:Gd,empty:Kd,each:Jd,attr:nu,style:au,property:du,classed:mu,text:yu,html:ju,raise:Nu,lower:Su,append:Cu,insert:Eu,remove:Tu,clone:Ou,datum:Iu,on:Lu,dispatch:Hu,[Symbol.iterator]:Uu};function Fe(e){return typeof e=="string"?new Te([[document.querySelector(e)]],[document.documentElement]):new Te([[e]],pa)}function Wu(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Je(e,t){if(e=Wu(e),t===void 0&&(t=e.currentTarget),t){var r=t.ownerSVGElement||t;if(r.createSVGPoint){var s=r.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const Gu={passive:!1},nn={capture:!0,passive:!1};function Qn(e){e.stopImmediatePropagation()}function Pt(e){e.preventDefault(),e.stopImmediatePropagation()}function xa(e){var t=e.document.documentElement,r=Fe(e).on("dragstart.drag",Pt,nn);"onselectstart"in t?r.on("selectstart.drag",Pt,nn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function ga(e,t){var r=e.document.documentElement,s=Fe(e).on("dragstart.drag",null);t&&(s.on("click.drag",Pt,nn),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in r?s.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}const dn=e=>()=>e;function vr(e,{sourceEvent:t,subject:r,target:s,identifier:i,active:a,x:o,y:l,dx:u,dy:c,dispatch:h}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:h}})}vr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Ku(e){return!e.ctrlKey&&!e.button}function Ju(){return this.parentNode}function Yu(e,t){return t??{x:e.x,y:e.y}}function Xu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Zu(){var e=Ku,t=Ju,r=Yu,s=Xu,i={},a=an("start","drag","end"),o=0,l,u,c,h,w=0;function y(d){d.on("mousedown.drag",v).filter(s).on("touchstart.drag",b).on("touchmove.drag",p,Gu).on("touchend.drag touchcancel.drag",m).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(d,x){if(!(h||!e.call(this,d,x))){var g=f(this,t.call(this,d,x),d,x,"mouse");g&&(Fe(d.view).on("mousemove.drag",S,nn).on("mouseup.drag",j,nn),xa(d.view),Qn(d),c=!1,l=d.clientX,u=d.clientY,g("start",d))}}function S(d){if(Pt(d),!c){var x=d.clientX-l,g=d.clientY-u;c=x*x+g*g>w}i.mouse("drag",d)}function j(d){Fe(d.view).on("mousemove.drag mouseup.drag",null),ga(d.view,c),Pt(d),i.mouse("end",d)}function b(d,x){if(e.call(this,d,x)){var g=d.changedTouches,M=t.call(this,d,x),P=g.length,q,k;for(q=0;q<P;++q)(k=f(this,M,d,x,g[q].identifier,g[q]))&&(Qn(d),k("start",d,g[q]))}}function p(d){var x=d.changedTouches,g=x.length,M,P;for(M=0;M<g;++M)(P=i[x[M].identifier])&&(Pt(d),P("drag",d,x[M]))}function m(d){var x=d.changedTouches,g=x.length,M,P;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),M=0;M<g;++M)(P=i[x[M].identifier])&&(Qn(d),P("end",d,x[M]))}function f(d,x,g,M,P,q){var k=a.copy(),N=Je(q||g,x),O,I,_;if((_=r.call(d,new vr("beforestart",{sourceEvent:g,target:y,identifier:P,active:o,x:N[0],y:N[1],dx:0,dy:0,dispatch:k}),M))!=null)return O=_.x-N[0]||0,I=_.y-N[1]||0,function T(C,R,D){var A=N,$;switch(C){case"start":i[P]=T,$=o++;break;case"end":delete i[P],--o;case"drag":N=Je(D||R,x),$=o;break}k.call(C,d,new vr(C,{sourceEvent:R,subject:_,target:y,identifier:P,active:$,x:N[0]+O,y:N[1]+I,dx:N[0]-A[0],dy:N[1]-A[1],dispatch:k}),M)}}return y.filter=function(d){return arguments.length?(e=typeof d=="function"?d:dn(!!d),y):e},y.container=function(d){return arguments.length?(t=typeof d=="function"?d:dn(d),y):t},y.subject=function(d){return arguments.length?(r=typeof d=="function"?d:dn(d),y):r},y.touchable=function(d){return arguments.length?(s=typeof d=="function"?d:dn(!!d),y):s},y.on=function(){var d=a.on.apply(a,arguments);return d===a?y:d},y.clickDistance=function(d){return arguments.length?(w=(d=+d)*d,y):Math.sqrt(w)},y}var qt=0,Yt=0,Gt=0,ya=1e3,En,Xt,Dn=0,yt=0,Un=0,rn=typeof performance=="object"&&performance.now?performance:Date,va=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qr(){return yt||(va(Qu),yt=rn.now()+Un)}function Qu(){yt=0}function Tn(){this._call=this._time=this._next=null}Tn.prototype=Hr.prototype={constructor:Tn,restart:function(e,t,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?qr():+r)+(t==null?0:+t),!this._next&&Xt!==this&&(Xt?Xt._next=this:En=this,Xt=this),this._call=e,this._time=r,wr()},stop:function(){this._call&&(this._call=null,this._time=1/0,wr())}};function Hr(e,t,r){var s=new Tn;return s.restart(e,t,r),s}function eh(){qr(),++qt;for(var e=En,t;e;)(t=yt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--qt}function Ls(){yt=(Dn=rn.now())+Un,qt=Yt=0;try{eh()}finally{qt=0,nh(),yt=0}}function th(){var e=rn.now(),t=e-Dn;t>ya&&(Un-=t,Dn=e)}function nh(){for(var e,t=En,r,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:En=r);Xt=e,wr(s)}function wr(e){if(!qt){Yt&&(Yt=clearTimeout(Yt));var t=e-yt;t>24?(e<1/0&&(Yt=setTimeout(Ls,e-rn.now()-Un)),Gt&&(Gt=clearInterval(Gt))):(Gt||(Dn=rn.now(),Gt=setInterval(th,ya)),qt=1,va(Ls))}}function Bs(e,t,r){var s=new Tn;return t=t==null?0:+t,s.restart(i=>{s.stop(),e(i+t)},t,r),s}var rh=an("start","end","cancel","interrupt"),sh=[],wa=0,qs=1,br=2,gn=3,Hs=4,jr=5,yn=6;function Vn(e,t,r,s,i,a){var o=e.__transition;if(!o)e.__transition={};else if(r in o)return;ih(e,r,{name:t,index:s,group:i,on:rh,tween:sh,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:wa})}function Ur(e,t){var r=He(e,t);if(r.state>wa)throw new Error("too late; already scheduled");return r}function We(e,t){var r=He(e,t);if(r.state>gn)throw new Error("too late; already running");return r}function He(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw new Error("transition not found");return r}function ih(e,t,r){var s=e.__transition,i;s[t]=r,r.timer=Hr(a,0,r.time);function a(c){r.state=qs,r.timer.restart(o,r.delay,r.time),r.delay<=c&&o(c-r.delay)}function o(c){var h,w,y,v;if(r.state!==qs)return u();for(h in s)if(v=s[h],v.name===r.name){if(v.state===gn)return Bs(o);v.state===Hs?(v.state=yn,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete s[h]):+h<t&&(v.state=yn,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete s[h])}if(Bs(function(){r.state===gn&&(r.state=Hs,r.timer.restart(l,r.delay,r.time),l(c))}),r.state=br,r.on.call("start",e,e.__data__,r.index,r.group),r.state===br){for(r.state=gn,i=new Array(y=r.tween.length),h=0,w=-1;h<y;
vendor: 8,011 bytes, line 11
11++h)(v=r.tween[h].value.call(e,e.__data__,r.index,r.group))&&(i[++w]=v);i.length=w+1}}function l(c){for(var h=c<r.duration?r.ease.call(null,c/r.duration):(r.timer.restart(u),r.state=jr,1),w=-1,y=i.length;++w<y;)i[w].call(e,h);r.state===jr&&(r.on.call("end",e,e.__data__,r.index,r.group),u())}function u(){r.state=yn,r.timer.stop(),delete s[t];for(var c in s)return;delete e.__transition}}function vn(e,t){var r=e.__transition,s,i,a=!0,o;if(r){t=t==null?null:t+"";for(o in r){if((s=r[o]).name!==t){a=!1;continue}i=s.state>br&&s.state<jr,s.state=yn,s.timer.stop(),s.on.call(i?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete r[o]}a&&delete e.__transition}}function ah(e){return this.each(function(){vn(this,e)})}function oh(e,t){var r,s;return function(){var i=We(this,e),a=i.tween;if(a!==r){s=r=a;for(var o=0,l=s.length;o<l;++o)if(s[o].name===t){s=s.slice(),s.splice(o,1);break}}i.tween=s}}function lh(e,t,r){var s,i;if(typeof r!="function")throw new Error;return function(){var a=We(this,e),o=a.tween;if(o!==s){i=(s=o).slice();for(var l={name:t,value:r},u=0,c=i.length;u<c;++u)if(i[u].name===t){i[u]=l;break}u===c&&i.push(l)}a.tween=i}}function ch(e,t){var r=this._id;if(e+="",arguments.length<2){for(var s=He(this.node(),r).tween,i=0,a=s.length,o;i<a;++i)if((o=s[i]).name===e)return o.value;return null}return this.each((t==null?oh:lh)(r,e,t))}function Vr(e,t,r){var s=e._id;return e.each(function(){var i=We(this,s);(i.value||(i.value={}))[t]=r.apply(this,arguments)}),function(i){return He(i,s).value[t]}}function ba(e,t){var r;return(typeof t=="number"?mt:t instanceof as?is:(r=as(t))?(t=r,is):jo)(e,t)}function dh(e){return function(){this.removeAttribute(e)}}function uh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hh(e,t,r){var s,i=r+"",a;return function(){var o=this.getAttribute(e);return o===i?null:o===s?a:a=t(s=o,r)}}function fh(e,t,r){var s,i=r+"",a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===s?a:a=t(s=o,r)}}function mh(e,t,r){var s,i,a;return function(){var o,l=r(this),u;return l==null?void this.removeAttribute(e):(o=this.getAttribute(e),u=l+"",o===u?null:o===s&&u===i?a:(i=u,a=t(s=o,l)))}}function ph(e,t,r){var s,i,a;return function(){var o,l=r(this),u;return l==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),u=l+"",o===u?null:o===s&&u===i?a:(i=u,a=t(s=o,l)))}}function xh(e,t){var r=Hn(e),s=r==="transform"?il:ba;return this.attrTween(e,typeof t=="function"?(r.local?ph:mh)(r,s,Vr(this,"attr."+e,t)):t==null?(r.local?uh:dh)(r):(r.local?fh:hh)(r,s,t))}function gh(e,t){return function(r){this.setAttribute(e,t.call(this,r))}}function yh(e,t){return function(r){this.setAttributeNS(e.space,e.local,t.call(this,r))}}function vh(e,t){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&yh(e,a)),r}return i._value=t,i}function wh(e,t){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&gh(e,a)),r}return i._value=t,i}function bh(e,t){var r="attr."+e;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;var s=Hn(e);return this.tween(r,(s.local?vh:wh)(s,t))}function jh(e,t){return function(){Ur(this,e).delay=+t.apply(this,arguments)}}function _h(e,t){return t=+t,function(){Ur(this,e).delay=t}}function Nh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?jh:_h)(t,e)):He(this.node(),t).delay}function kh(e,t){return function(){We(this,e).duration=+t.apply(this,arguments)}}function Sh(e,t){return t=+t,function(){We(this,e).duration=t}}function Ch(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?kh:Sh)(t,e)):He(this.node(),t).duration}function Ah(e,t){if(typeof t!="function")throw new Error;return function(){We(this,e).ease=t}}function Eh(e){var t=this._id;return arguments.length?this.each(Ah(t,e)):He(this.node(),t).ease}function Dh(e,t){return function(){var r=t.apply(this,arguments);if(typeof r!="function")throw new Error;We(this,e).ease=r}}function Th(e){if(typeof e!="function")throw new Error;return this.each(Dh(this._id,e))}function Rh(e){typeof e!="function"&&(e=aa(e));for(var t=this._groups,r=t.length,s=new Array(r),i=0;i<r;++i)for(var a=t[i],o=a.length,l=s[i]=[],u,c=0;c<o;++c)(u=a[c])&&e.call(u,u.__data__,c,a)&&l.push(u);return new Ze(s,this._parents,this._name,this._id)}function Mh(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,r=e._groups,s=t.length,i=r.length,a=Math.min(s,i),o=new Array(s),l=0;l<a;++l)for(var u=t[l],c=r[l],h=u.length,w=o[l]=new Array(h),y,v=0;v<h;++v)(y=u[v]||c[v])&&(w[v]=y);for(;l<s;++l)o[l]=t[l];return new Ze(o,this._parents,this._name,this._id)}function Oh(e){return(e+"").trim().split(/^|\s+/).every(function(t){var r=t.indexOf(".");return r>=0&&(t=t.slice(0,r)),!t||t==="start"})}function Ih(e,t,r){var s,i,a=Oh(t)?Ur:We;return function(){var o=a(this,e),l=o.on;l!==s&&(i=(s=l).copy()).on(t,r),o.on=i}}function Ph(e,t){var r=this._id;return arguments.length<2?He(this.node(),r).on.on(e):this.each(Ih(r,e,t))}function Fh(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;t&&t.removeChild(this)}}function $h(){return this.on("end.remove",Fh(this._id))}function zh(e){var t=this._name,r=this._id;typeof e!="function"&&(e=Lr(e));for(var s=this._groups,i=s.length,a=new Array(i),o=0;o<i;++o)for(var l=s[o],u=l.length,c=a[o]=new Array(u),h,w,y=0;y<u;++y)(h=l[y])&&(w=e.call(h,h.__data__,y,l))&&("__data__"in h&&(w.__data__=h.__data__),c[y]=w,Vn(c[y],t,r,y,c,He(h,r)));return new Ze(a,this._parents,t,r)}function Lh(e){var t=this._name,r=this._id;typeof e!="function"&&(e=ia(e));for(var s=this._groups,i=s.length,a=[],o=[],l=0;l<i;++l)for(var u=s[l],c=u.length,h,w=0;w<c;++w)if(h=u[w]){for(var y=e.call(h,h.__data__,w,u),v,S=He(h,r),j=0,b=y.length;j<b;++j)(v=y[j])&&Vn(v,t,r,j,y,S);a.push(y),o.push(h)}return new Ze(a,o,t,r)}var Bh=on.prototype.constructor;function qh(){return new Bh(this._groups,this._parents)}function Hh(e,t){var r,s,i;return function(){var a=Bt(this,e),o=(this.style.removeProperty(e),Bt(this,e));return a===o?null:a===r&&o===s?i:i=t(r=a,s=o)}}function ja(e){return function(){this.style.removeProperty(e)}}function Uh(e,t,r){var s,i=r+"",a;return function(){var o=Bt(this,e);return o===i?null:o===s?a:a=t(s=o,r)}}function Vh(e,t,r){var s,i,a;return function(){var o=Bt(this,e),l=r(this),u=l+"";return l==null&&(u=l=(this.style.removeProperty(e),Bt(this,e))),o===u?null:o===s&&u===i?a:(i=u,a=t(s=o,l))}}function Wh(e,t){var r,s,i,a="style."+t,o="end."+a,l;return function(){var u=We(this,e),c=u.on,h=u.value[a]==null?l||(l=ja(t)):void 0;(c!==r||i!==h)&&(s=(r=c).copy()).on(o,i=h),u.on=s}}function Gh(e,t,r){var s=(e+="")=="transform"?sl:ba;return t==null?this.styleTween(e,Hh(e,s)).on("end.style."+e,ja(e)):typeof t=="function"?this.styleTween(e,Vh(e,s,Vr(this,"style."+e,t))).each(Wh(this._id,e)):this.styleTween(e,Uh(e,s,t),r).on("end.style."+e,null)}function Kh(e,t,r){return function(s){this.style.setProperty(e,t.call(this,s),r)}}function Jh(e,t,r){var s,i;function a(){var o=t.apply(this,arguments);return o!==i&&(s=(i=o)&&Kh(e,o,r)),s}return a._value=t,a}function Yh(e,t,r){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,Jh(e,t,r??""))}function Xh(e){return function(){this.textContent=e}}function Zh(e){return function(){var t=e(this);this.textContent=t??""}}function Qh(e){return this.tween("text",typeof e=="function"?Zh(Vr(this,"text",e)):Xh(e==null?"":e+""))}function ef(e){return function(t){this.textContent=e.call(this,t)}}function tf(e){var t,r;function s(){var i=e.apply(this,arguments);return i!==r&&(t=(r=i)&&ef(i)),t}return s._value=e,s}function nf(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,tf(e))}
11function rf(){for(var e=this._name,t=this._id,r=_a(),s=this._groups,i=s.length,a=0;a<i;++a)for(var o=s[a],l=o.length,u,c=0;c<l;++c)if(u=o[c]){var h=He(u,t);Vn(u,e,r,c,o,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new Ze(s,this._parents,e,r)}function sf(){var e,t,r=this,s=r._id,i=r.size();return new Promise(function(a,o){var l={value:o},u={value:function(){--i===0&&a()}};r.each(function(){var c=We(this,s),h=c.on;h!==e&&(t=(e=h).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(u)),c.on=t}),i===0&&a()})}var af=0;function Ze(e,t,r,s){this._groups=e,this._parents=t,this._name=r,this._id=s}function _a(){return++af}var Ke=on.prototype;Ze.prototype={constructor:Ze,select:zh,selectAll:Lh,selectChild:Ke.selectChild,selectChildren:Ke.selectChildren,filter:Rh,merge:Mh,selection:qh,transition:rf,call:Ke.call,nodes:Ke.nodes,node:Ke.node,size:Ke.size,empty:Ke.empty,each:Ke.each,on:Ph,attr:xh,attrTween:bh,style:Gh,styleTween:Yh,text:Qh,textTween:nf,remove:$h,tween:ch,delay:Nh,duration:Ch,ease:Eh,easeVarying:Th,end:sf,[Symbol.iterator]:Ke[Symbol.iterator]};function of(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var lf={time:null,delay:0,duration:250,ease:of};function cf(e,t){for(var r;!(r=e.__transition)||!(r=r[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return r}function df(e){var t,r;e instanceof Ze?(t=e._id,e=e._name):(t=_a(),(r=lf).time=qr(),e=e==null?null:e+"");for(var s=this._groups,i=s.length,a=0;a<i;++a)for(var o=s[a],l=o.length,u,c=0;c<l;++c)(u=o[c])&&Vn(u,e,t,c,o,r||cf(u,t));return new Ze(s,this._parents,e,t)}on.prototype.interrupt=ah;on.prototype.transition=df;function uf(e,t){var r,s=1;e==null&&(e=0),t==null&&(t=0);function i(){var a,o=r.length,l,u=0,c=0;for(a=0;a<o;++a)l=r[a],u+=l.x,c+=l.y;for(u=(u/o-e)*s,c=(c/o-t)*s,a=0;a<o;++a)l=r[a],l.x-=u,l.y-=c}return i.initialize=function(a){r=a},i.x=function(a){return arguments.length?(e=+a,i):e},i.y=function(a){return arguments.length?(t=+a,i):t},i.strength=function(a){return arguments.length?(s=+a,i):s},i}function hf(e){const t=+this._x.call(null,e),r=+this._y.call(null,e);return Na(this.cover(t,r),t,r,e)}function Na(e,t,r,s){if(isNaN(t)||isNaN(r))return e;var i,a=e._root,o={data:s},l=e._x0,u=e._y0,c=e._x1,h=e._y1,w,y,v,S,j,b,p,m;if(!a)return e._root=o,e;for(;a.length;)if((j=t>=(w=(l+c)/2))?l=w:c=w,(b=r>=(y=(u+h)/2))?u=y:h=y,i=a,!(a=a[p=b<<1|j]))return i[p]=o,e;if(v=+e._x.call(null,a.data),S=+e._y.call(null,a.data),t===v&&r===S)return o.next=a,i?i[p]=o:e._root=o,e;do i=i?i[p]=new Array(4):e._root=new Array(4),(j=t>=(w=(l+c)/2))?l=w:c=w,(b=r>=(y=(u+h)/2))?u=y:h=y;while((p=b<<1|j)===(m=(S>=y)<<1|v>=w));return i[m]=a,i[p]=o,e}function ff(e){var t,r,s=e.length,i,a,o=new Array(s),l=new Array(s),u=1/0,c=1/0,h=-1/0,w=-1/0;for(r=0;r<s;++r)isNaN(i=+this._x.call(null,t=e[r]))||isNaN(a=+this._y.call(null,t))||(o[r]=i,l[r]=a,i<u&&(u=i),i>h&&(h=i),a<c&&(c=a),a>w&&(w=a));if(u>h||c>w)return this;for(this.cover(u,c).cover(h,w),r=0;r<s;++r)Na(this,o[r],l[r],e[r]);return this}function mf(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var r=this._x0,s=this._y0,i=this._x1,a=this._y1;if(isNaN(r))i=(r=Math.floor(e))+1,a=(s=Math.floor(t))+1;else{for(var o=i-r||1,l=this._root,u,c;r>e||e>=i||s>t||t>=a;)switch(c=(t<s)<<1|e<r,u=new Array(4),u[c]=l,l=u,o*=2,c){case 0:i=r+o,a=s+o;break;case 1:r=i-o,a=s+o;break;case 2:i=r+o,s=a-o;break;case 3:r=i-o,s=a-o;break}this._root&&this._root.length&&(this._root=l)}return this._x0=r,this._y0=s,this._x1=i,this._y1=a,this}function pf(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function xf(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function je(e,t,r,s,i){this.node=e,this.x0=t,this.y0=r,this.x1=s,this.y1=i}function gf(e,t,r){var s,i=this._x0,a=this._y0,o,l,u,c,h=this._x1,w=this._y1,y=[],v=this._root,S,j;for(v&&y.push(new je(v,i,a,h,w)),r==null?r=1/0:(i=e-r,a=t-r,h=e+r,w=t+r,r*=r);S=y.pop();)if(!(!(v=S.node)||(o=S.x0)>h||(l=S.y0)>w||(u=S.x1)<i||(c=S.y1)<a))if(v.length){var b=(o+u)/2,p=(l+c)/2;y.push(new je(v[3],b,p,u,c),new je(v[2],o,p,b,c),new je(v[1],b,l,u,p),new je(v[0],o,l,b,p)),(j=(t>=p)<<1|e>=b)&&(S=y[y.length-1],y[y.length-1]=y[y.length-1-j],y[y.length-1-j]=S)}else{var m=e-+this._x.call(null,v.data),f=t-+this._y.call(null,v.data),d=m*m+f*f;if(d<r){var x=Math.sqrt(r=d);i=e-x,a=t-x,h=e+x,w=t+x,s=v.data}}return s}function yf(e){if(isNaN(h=+this._x.call(null,e))||isNaN(w=+this._y.call(null,e)))return this;var t,r=this._root,s,i,a,o=this._x0,l=this._y0,u=this._x1,c=this._y1,h,w,y,v,S,j,b,p;if(!r)return this;if(r.length)for(;;){if((S=h>=(y=(o+u)/2))?o=y:u=y,(j=w>=(v=(l+c)/2))?l=v:c=v,t=r,!(r=r[b=j<<1|S]))return this;if(!r.length)break;(t[b+1&3]||t[b+2&3]||t[b+3&3])&&(s=t,p=b)}for(;r.data!==e;)if(i=r,!(r=r.next))return this;return(a=r.next)&&delete r.next,i?(a?i.next=a:delete i.next,this):t?(a?t[b]=a:delete t[b],(r=t[0]||t[1]||t[2]||t[3])&&r===(t[3]||t[2]||t[1]||t[0])&&!r.length&&(s?s[p]=r:this._root=r),this):(this._root=a,this)}function vf(e){for(var t=0,r=e.length;t<r;++t)this.remove(e[t]);return this}function wf(){return this._root}function bf(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function jf(e){var t=[],r,s=this._root,i,a,o,l,u;for(s&&t.push(new je(s,this._x0,this._y0,this._x1,this._y1));r=t.pop();)if(!e(s=r.node,a=r.x0,o=r.y0,l=r.x1,u=r.y1)&&s.length){var c=(a+l)/2,h=(o+u)/2;(i=s[3])&&t.push(new je(i,c,h,l,u)),(i=s[2])&&t.push(new je(i,a,h,c,u)),(i=s[1])&&t.pu
vendor: 9,862 bytes, line 11
11sh(new je(i,c,o,l,h)),(i=s[0])&&t.push(new je(i,a,o,c,h))}return this}function _f(e){var t=[],r=[],s;for(this._root&&t.push(new je(this._root,this._x0,this._y0,this._x1,this._y1));s=t.pop();){var i=s.node;if(i.length){var a,o=s.x0,l=s.y0,u=s.x1,c=s.y1,h=(o+u)/2,w=(l+c)/2;(a=i[0])&&t.push(new je(a,o,l,h,w)),(a=i[1])&&t.push(new je(a,h,l,u,w)),(a=i[2])&&t.push(new je(a,o,w,h,c)),(a=i[3])&&t.push(new je(a,h,w,u,c))}r.push(s)}for(;s=r.pop();)e(s.node,s.x0,s.y0,s.x1,s.y1);return this}function Nf(e){return e[0]}function kf(e){return arguments.length?(this._x=e,this):this._x}function Sf(e){return e[1]}function Cf(e){return arguments.length?(this._y=e,this):this._y}function Wr(e,t,r){var s=new Gr(t??Nf,r??Sf,NaN,NaN,NaN,NaN);return e==null?s:s.addAll(e)}function Gr(e,t,r,s,i,a){this._x=e,this._y=t,this._x0=r,this._y0=s,this._x1=i,this._y1=a,this._root=void 0}function Us(e){for(var t={data:e.data},r=t;e=e.next;)r=r.next={data:e.data};return t}var ke=Wr.prototype=Gr.prototype;ke.copy=function(){var e=new Gr(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,r,s;if(!t)return e;if(!t.length)return e._root=Us(t),e;for(r=[{source:t,target:e._root=new Array(4)}];t=r.pop();)for(var i=0;i<4;++i)(s=t.source[i])&&(s.length?r.push({source:s,target:t.target[i]=new Array(4)}):t.target[i]=Us(s));return e};ke.add=hf;ke.addAll=ff;ke.cover=mf;ke.data=pf;ke.extent=xf;ke.find=gf;ke.remove=yf;ke.removeAll=vf;ke.root=wf;ke.size=bf;ke.visit=jf;ke.visitAfter=_f;ke.x=kf;ke.y=Cf;function Ne(e){return function(){return e}}function rt(e){return(e()-.5)*1e-6}function Af(e){return e.x+e.vx}function Ef(e){return e.y+e.vy}function Df(e){var t,r,s,i=1,a=1;typeof e!="function"&&(e=Ne(e==null?1:+e));function o(){for(var c,h=t.length,w,y,v,S,j,b,p=0;p<a;++p)for(w=Wr(t,Af,Ef).visitAfter(l),c=0;c<h;++c)y=t[c],j=r[y.index],b=j*j,v=y.x+y.vx,S=y.y+y.vy,w.visit(m);function m(f,d,x,g,M){var P=f.data,q=f.r,k=j+q;if(P){if(P.index>y.index){var N=v-P.x-P.vx,O=S-P.y-P.vy,I=N*N+O*O;I<k*k&&(N===0&&(N=rt(s),I+=N*N),O===0&&(O=rt(s),I+=O*O),I=(k-(I=Math.sqrt(I)))/I*i,y.vx+=(N*=I)*(k=(q*=q)/(b+q)),y.vy+=(O*=I)*k,P.vx-=N*(k=1-k),P.vy-=O*k)}return}return d>v+k||g<v-k||x>S+k||M<S-k}}function l(c){if(c.data)return c.r=r[c.data.index];for(var h=c.r=0;h<4;++h)c[h]&&c[h].r>c.r&&(c.r=c[h].r)}function u(){if(t){var c,h=t.length,w;for(r=new Array(h),c=0;c<h;++c)w=t[c],r[w.index]=+e(w,c,t)}}return o.initialize=function(c,h){t=c,s=h,u()},o.iterations=function(c){return arguments.length?(a=+c,o):a},o.strength=function(c){return arguments.length?(i=+c,o):i},o.radius=function(c){return arguments.length?(e=typeof c=="function"?c:Ne(+c),u(),o):e},o}function Tf(e){return e.index}function Vs(e,t){var r=e.get(t);if(!r)throw new Error("node not found: "+t);return r}function Rf(e){var t=Tf,r=w,s,i=Ne(30),a,o,l,u,c,h=1;e==null&&(e=[]);function w(b){return 1/Math.min(l[b.source.index],l[b.target.index])}function y(b){for(var p=0,m=e.length;p<h;++p)for(var f=0,d,x,g,M,P,q,k;f<m;++f)d=e[f],x=d.source,g=d.target,M=g.x+g.vx-x.x-x.vx||rt(c),P=g.y+g.vy-x.y-x.vy||rt(c),q=Math.sqrt(M*M+P*P),q=(q-a[f])/q*b*s[f],M*=q,P*=q,g.vx-=M*(k=u[f]),g.vy-=P*k,x.vx+=M*(k=1-k),x.vy+=P*k}function v(){if(o){var b,p=o.length,m=e.length,f=new Map(o.map((x,g)=>[t(x,g,o),x])),d;for(b=0,l=new Array(p);b<m;++b)d=e[b],d.index=b,typeof d.source!="object"&&(d.source=Vs(f,d.source)),typeof d.target!="object"&&(d.target=Vs(f,d.target)),l[d.source.index]=(l[d.source.index]||0)+1,l[d.target.index]=(l[d.target.index]||0)+1;for(b=0,u=new Array(m);b<m;++b)d=e[b],u[b]=l[d.source.index]/(l[d.source.index]+l[d.target.index]);s=new Array(m),S(),a=new Array(m),j()}}function S(){if(o)for(var b=0,p=e.length;b<p;++b)s[b]=+r(e[b],b,e)}function j(){if(o)for(var b=0,p=e.length;b<p;++b)a[b]=+i(e[b],b,e)}return y.initialize=function(b,p){o=b,c=p,v()},y.links=function(b){return arguments.length?(e=b,v(),y):e},y.id=function(b){return arguments.length?(t=b,y):t},y.iterations=function(b){return arguments.length?(h=+b,y):h},y.strength=function(b){return arguments.length?(r=typeof b=="function"?b:Ne(+b),S(),y):r},y.distance=function(b){return arguments.length?(i=typeof b=="function"?b:Ne(+b),j(),y):i},y}const Mf=1664525,Of=1013904223,Ws=4294967296;function If(){let e=1;return()=>(e=(Mf*e+Of)%Ws)/Ws}function Pf(e){return e.x}function Ff(e){return e.y}var $f=10,zf=Math.PI*(3-Math.sqrt(5));function Lf(e){var t,r=1,s=.001,i=1-Math.pow(s,1/300),a=0,o=.6,l=new Map,u=Hr(w),c=an("tick","end"),h=If();e==null&&(e=[]);function w(){y(),c.call("tick",t),r<s&&(u.stop(),c.call("end",t))}function y(j){var b,p=e.length,m;j===void 0&&(j=1);for(var f=0;f<j;++f)for(r+=(a-r)*i,l.forEach(function(d){d(r)}),b=0;b<p;++b)m=e[b],m.fx==null?m.x+=m.vx*=o:(m.x=m.fx,m.vx=0),m.fy==null?m.y+=m.vy*=o:(m.y=m.fy,m.vy=0);return t}function v(){for(var j=0,b=e.length,p;j<b;++j){if(p=e[j],p.index=j,p.fx!=null&&(p.x=p.fx),p.fy!=null&&(p.y=p.fy),isNaN(p.x)||isNaN(p.y)){var m=$f*Math.sqrt(.5+j),f=j*zf;p.x=m*Math.cos(f),p.y=m*Math.sin(f)}(isNaN(p.vx)||isNaN(p.vy))&&(p.vx=p.vy=0)}}function S(j){return j.initialize&&j.initialize(e,h),j}return v(),t={tick:y,restart:function(){return u.restart(w),t},stop:function(){return u.stop(),t},nodes:function(j){return arguments.length?(e=j,v(),l.forEach(S),t):e},alpha:function(j){return arguments.length?(r=+j,t):r},alphaMin:function(j){return arguments.length?(s=+j,t):s},alphaDecay:function(j){return arguments.length?(i=+j,t):+i},alphaTarget:function(j){return arguments.length?(a=+j,t):a},velocityDecay:function(j){return arguments.length?(o=1-j,t):1-o},randomSource:function(j){return arguments.length?(h=j,l.forEach(S),t):h},force:function(j,b){return arguments.length>1?(b==null?l.delete(j):l.set(j,S(b)),t):l.get(j)},find:function(j,b,p){var m=0,f=e.length,d,x,g,M,P;for(p==null?p=1/0:p*=p,m=0;m<f;++m)M=e[m],d=j-M.x,x=b-M.y,g=d*d+x*x,g<p&&(P=M,p=g);return P},on:function(j,b){return arguments.length>1?(c.on(j,b),t):c.on(j)}}}function Bf(){var e,t,r,s,i=Ne(-30),a,o=1,l=1/0,u=.81;function c(v){var S,j=e.length,b=Wr(e,Pf,Ff).visitAfter(w);for(s=v,S=0;S<j;++S)t=e[S],b.visit(y)}function h(){if(e){var v,S=e.length,j;for(a=new Array(S),v=0;v<S;++v)j=e[v],a[j.index]=+i(j,v,e)}}function w(v){var S=0,j,b,p=0,m,f,d;if(v.length){for(m=f=d=0;d<4;++d)(j=v[d])&&(b=Math.abs(j.value))&&(S+=j.value,p+=b,m+=b*j.x,f+=b*j.y);v.x=m/p,v.y=f/p}else{j=v,j.x=j.data.x,j.y=j.data.y;do S+=a[j.data.index];while(j=j.next)}v.value=S}function y(v,S,j,b){if(!v.value)return!0;var p=v.x-t.x,m=v.y-t.y,f=b-S,d=p*p+m*m;if(f*f/u<d)return d<l&&(p===0&&(p=rt(r),d+=p*p),m===0&&(m=rt(r),d+=m*m),d<o&&(d=Math.sqrt(o*d)),t.vx+=p*v.value*s/d,t.vy+=m*v.value*s/d),!0;if(v.length||d>=l)return;(v.data!==t||v.next)&&(p===0&&(p=rt(r),d+=p*p),m===0&&(m=rt(r),d+=m*m),d<o&&(d=Math.sqrt(o*d)));do v.data!==t&&(f=a[v.data.index]*s/d,t.vx+=p*f,t.vy+=m*f);while(v=v.next)}return c.initialize=function(v,S){e=v,r=S,h()},c.strength=function(v){return arguments.length?(i=typeof v=="function"?v:Ne(+v),h(),c):i},c.distanceMin=function(v){return arguments.length?(o=v*v,c):Math.sqrt(o)},c.distanceMax=function(v){return arguments.length?(l=v*v,c):Math.sqrt(l)},c.theta=function(v){return arguments.length?(u=v*v,c):Math.sqrt(u)},c}function qf(e){var t=Ne(.1),r,s,i;typeof e!="function"&&(e=Ne(e==null?0:+e));function a(l){for(var u=0,c=r.length,h;u<c;++u)h=r[u],h.vx+=(i[u]-h.x)*s[u]*l}function o(){if(r){var l,u=r.length;for(s=new Array(u),i=new Array(u),l=0;l<u;++l)s[l]=isNaN(i[l]=+e(r[l],l,r))?0:+t(r[l],l,r)}}return a.initialize=function(l){r=l,o()},a.strength=function(l){return arguments.length?(t=typeof l=="function"?l:Ne(+l),o(),a):t},a.x=function(l){return arguments.length?(e=typeof l=="function"?l:Ne(+l),o(),a):e},a}function Hf(e){var t=Ne(.1),r,s,i;typeof e!="function"&&(e=Ne(e==null?0:+e));function a(l){for(var u=0,c=r.length,h;u<c;++u)h=r[u],h.vy+=(i[u]-h.y)*s[u]*l}function o(){if(r){var l,u=r.length;for(s=new Array(u),i=new Array(u),l=0;l<u;++l)s[l]=isNaN(i[l]=+e(r[l],l,r))?0:+t(r[l],l,r)}}return a.initialize=function(l){r=l,o()},a.strength=function(l){return arguments.length?(t=typeof l=="function"?l:Ne(+l),o(),a):t},a.y=function(l){return arguments.length?(e=typeof l=="function"?l:Ne(+l),o(),a):e},a}const un=e=>()=>e;function Uf(e,{sourceEvent:t,target:r,transform:s,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:i}})}function Ye(e,t,r){this.k=e,this.x=t,this.y=r}Ye.prototype={constructor:Ye,scale:function(e){return e===1?this:new Ye(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ye(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Kr=new Ye(1,0,0);Ye.prototype;function er(e){e.stopImmediatePropagation()}function Kt(e){e.preventDefault(),e.stopImmediatePropagation()}function Vf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Wf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Gs(){return this.__zoom||Kr}function Gf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?
vendor: 4,412 bytes, line 11
111:.002)*(e.ctrlKey?10:1)}function Kf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Jf(e,t,r){var s=e.invertX(t[0][0])-r[0][0],i=e.invertX(t[1][0])-r[1][0],a=e.invertY(t[0][1])-r[0][1],o=e.invertY(t[1][1])-r[1][1];return e.translate(i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function Yf(){var e=Vf,t=Wf,r=Jf,s=Gf,i=Kf,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,u=cl,c=an("start","zoom","end"),h,w,y,v=500,S=150,j=0,b=10;function p(_){_.property("__zoom",Gs).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",k).filter(i).on("touchstart.zoom",N).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",I).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}p.transform=function(_,T,C,R){var D=_.selection?_.selection():_;D.property("__zoom",Gs),_!==D?x(_,T,C,R):D.interrupt().each(function(){g(this,arguments).event(R).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},p.scaleBy=function(_,T,C,R){p.scaleTo(_,function(){var D=this.__zoom.k,A=typeof T=="function"?T.apply(this,arguments):T;return D*A},C,R)},p.scaleTo=function(_,T,C,R){p.transform(_,function(){var D=t.apply(this,arguments),A=this.__zoom,$=C==null?d(D):typeof C=="function"?C.apply(this,arguments):C,J=A.invert($),B=typeof T=="function"?T.apply(this,arguments):T;return r(f(m(A,B),$,J),D,o)},C,R)},p.translateBy=function(_,T,C,R){p.transform(_,function(){return r(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),o)},null,R)},p.translateTo=function(_,T,C,R,D){p.transform(_,function(){var A=t.apply(this,arguments),$=this.__zoom,J=R==null?d(A):typeof R=="function"?R.apply(this,arguments):R;return r(Kr.translate(J[0],J[1]).scale($.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof C=="function"?-C.apply(this,arguments):-C),A,o)},R,D)};function m(_,T){return T=Math.max(a[0],Math.min(a[1],T)),T===_.k?_:new Ye(T,_.x,_.y)}function f(_,T,C){var R=T[0]-C[0]*_.k,D=T[1]-C[1]*_.k;return R===_.x&&D===_.y?_:new Ye(_.k,R,D)}function d(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function x(_,T,C,R){_.on("start.zoom",function(){g(this,arguments).event(R).start()}).on("interrupt.zoom end.zoom",function(){g(this,arguments).event(R).end()}).tween("zoom",function(){var D=this,A=arguments,$=g(D,A).event(R),J=t.apply(D,A),B=C==null?d(J):typeof C=="function"?C.apply(D,A):C,Z=Math.max(J[1][0]-J[0][0],J[1][1]-J[0][1]),X=D.__zoom,Y=typeof T=="function"?T.apply(D,A):T,te=u(X.invert(B).concat(Z/X.k),Y.invert(B).concat(Z/Y.k));return function(V){if(V===1)V=Y;else{var H=te(V),F=Z/H[2];V=new Ye(F,B[0]-H[0]*F,B[1]-H[1]*F)}$.zoom(null,V)}})}function g(_,T,C){return!C&&_.__zooming||new M(_,T)}function M(_,T){this.that=_,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,T),this.taps=0}M.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,T){return this.mouse&&_!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var T=Fe(this.that).datum();c.call(_,this.that,new Uf(_,{sourceEvent:this.sourceEvent,target:p,transform:this.that.__zoom,dispatch:c}),T)}};function P(_,...T){if(!e.apply(this,arguments))return;var C=g(this,T).event(_),R=this.__zoom,D=Math.max(a[0],Math.min(a[1],R.k*Math.pow(2,s.apply(this,arguments)))),A=Je(_);if(C.wheel)(C.mouse[0][0]!==A[0]||C.mouse[0][1]!==A[1])&&(C.mouse[1]=R.invert(C.mouse[0]=A)),clearTimeout(C.wheel);else{if(R.k===D)return;C.mouse=[A,R.invert(A)],vn(this),C.start()}Kt(_),C.wheel=setTimeout($,S),C.zoom("mouse",r(f(m(R,D),C.mouse[0],C.mouse[1]),C.extent,o));function $(){C.wheel=null,C.end()}}function q(_,...T){if(y||!e.apply(this,arguments))return;var C=_.currentTarget,R=g(this,T,!0).event(_),D=Fe(_.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",Z,!0),A=Je(_,C),$=_.clientX,J=_.clientY;xa(_.view),er(_),R.mouse=[A,this.__zoom.invert(A)],vn(this),R.start();function B(X){if(Kt(X),!R.moved){var Y=X.clientX-$,te=X.clientY-J;R.moved=Y*Y+te*te>j}
11R.event(X).zoom("mouse",r(f(R.that.__zoom,R.mouse[0]=Je(X,C),R.mouse[1]),R.extent,o))}function Z(X){D.on("mousemove.zoom mouseup.zoom",null),ga(X.view,R.moved),Kt(X),R.event(X).end()}}function k(_,...T){if(e.apply(this,arguments)){var C=this.__zoom,R=Je(_.changedTouches?_.changedTouches[0]:_,this),D=C.invert(R),A=C.k*(_.shiftKey?.5:2),$=r(f(m(C,A),R,D),t.apply(this,T),o);Kt(_),l>0?Fe(this).transition().duration(l).call(x,$,R,_):Fe(this).call(p.transform,$,R,_)}}function N(_,...T){if(e.apply(this,arguments)){var C=_.touches,R=C.length,D=g(this,T,_.changedTouches.length===R).event(_),A,$,J,B;for(er(_),$=0;$<R;++$)J=C[$],B=Je(J,this),B=[B,this.__zoom.invert(B),J.identifier],D.touch0?!D.touch1&&D.touch0[2]!==B[2]&&(D.touch1=B,D.taps=0):(D.touch0=B,A=!0,D.taps=1+!!h);h&&(h=clearTimeout(h)),A&&(D.taps<2&&(w=B[0],h=setTimeout(function(){h=null},v)),vn(this),D.start())}}function O(_,...T){if(this.__zooming){var C=g(this,T).event(_),R=_.changedTouches,D=R.length,A,$,J,B;for(Kt(_),A=0;A<D;++A)$=R[A],J=Je($,this),C.touch0&&C.touch0[2]===$.identifier?C.touch0[0]=J:C.touch1&&C.touch1[2]===$.identifier&&(C.touch1[0]=J);if($=C.that.__zoom,C.touch1){var Z=C.touch0[0],X=C.touch0[1],Y=C.touch1[0],te=C.touch1[1],V=(V=Y[0]-Z[0])*V+(V=Y[1]-Z[1])*V,H=(H=te[0]-X[0])*H+(H=te[1]-X[1])*H;$=m($,Math.sqrt(V/H)),J=[(Z[0]+Y[0])/2,(Z[1]+Y[1])/2],B=[(X[0]+te[0])/2,(X[1]+te[1])/2]}else if(C.touch0)J=C.touch0[0],B=C.touch0[1];else return;C.zoom("touch",r(f($,J,B),C.extent,o))}}function I(_,...T){if(this.__zooming){var C=g(this,T).event(_),R=_.changedTouches,D=R.length,A,$;for(er(_),y&&clearTimeout(y),y=setTimeout(function(){y=null},v),A=0;A<D;++A)$=R[A],C.touch0&&C.touch0[2]===$.identifier?delete C.touch0:C.touch1&&C.touch1[2]===$.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&($=Je($,this),Math.hypot(w[0]-$[0],w[1]-$[1])<b)){var J=Fe(this).on("dblclick.zoom");J&&J.apply(this,arguments)}}}return p.wheelDelta=function(_){return arguments.length?(s=typeof _=="function"?_:un(+_),p):s},p.filter=function(_){return arguments.length?(e=typeof _=="function"?_:un(!!_),p):e},p.touchable=function(_){return arguments.length?(i=typeof _=="function"?_:un(!!_),p):i},p.extent=function(_){return arguments.length?(t=typeof _=="function"?_:un([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),p):t},p.scaleExtent=function(_){return arguments.length?(a[0]=+_[0],a[1]=+_[1],p):[a[0],a[1]]},p.translateExtent=function(_){return arguments.length?(o[0][0]=+_[0][0],o[1][0]=+_[1][0],o[0][1]=+_[0][1],o[1][1]=+_[1][1],p):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},p.constrain=function(_){return arguments.length?(r=_,p):r},p.duration=function(_){return arguments.length?(l=+_,p):l},p.interpolate=function(_){return arguments.length?(u=_,p):u},p.on=function(){var _=c.on.apply(c,arguments);return _===c?p:_},p.clickDistance=function(_){return arguments.length?(j=(_=+_)*_,p):Math.sqrt(j)},p.tapDistance=function(_){return arguments.length?(b=+_,p):b},p}const Xf={Delivered:["Delivered","Rewritten","Junk (Delivered)","Junk (Rewritten)"],Blocked:["Blocked (Dropped)","Blocked (Bounced)","Blocked (Trashed)","Stripped","Held","Junk (Stripped)","Junk (Held)"],Pending:["Sent","Pending"],Failed:["Failed","Error"]};function Dt(e){for(const[t,r]of Object.entries(Xf))if(r.includes(e))return t;return"Other"}const hn={payload:"#3FCBFF",technique:"#6366f1",group:"#FE7058",software:"#FFAE5D",filetype:"#4CDBC4"},Zf={technique:"Attack Techniques",group:"Threat Groups",software:"Software",filetype:"File Types"};function Ks({nodes:e,links:t,chartRef:r,isFullscreen:s=!1,onToggleFullscreen:i,visibleTypes:a,onToggleType:o,focusDelivered:l,onToggleFocusDelivered:u}){const c=E.useRef(null),h=E.useRef(null),[w,y]=E.useState(1),v=E.useRef(null),S=E.useRef(null),[j,b]=E.useState(null),p=E.useMemo(()=>{let g=e.filter(q=>a.has(q.type));l&&(g=g.filter(q=>q.delivered>0));const M=new Set(g.map(q=>q.id)),P=t.filter(q=>M.has(q.source)&&M.has(q.target));return{nodes:g,links:P}},[e,t,a,l]),m=E.useCallback(()=>{v.current&&S.current&&S.current.transition().duration(300).call(v.current.scaleBy,1.5)},[]),f=E.useCallback(()=>{v.current&&S.current&&S.current.transition().duration(300).call(v.current.scaleBy,.67)},[]),d=E.useCallback(()=>{v.current&&S.current&&(S.current.transition().duration(300).call(v.current.transform,Kr),y(1))},[]);return E.useEffect(()=>{if(!c.current||p.nodes.length===0)return;const g=h.current,M=s?g?.clientWidth||window.innerWidth-100:600,P=s?window.innerHeight-200:400;Fe(c.current).selectAll("*").remove();const q=Fe(c.current).attr("viewBox",`0 0 ${M}
11 ${P}`).attr("width","100%").attr("height",P);S.current=q;const k=Yf().scaleExtent([.2,5]).on("zoom",A=>{N.attr("transform",A.transform),y(A.transform.k)});v.current=k,q.call(k);const N=q.append("g"),O=Math.max(...p.nodes.map(A=>A.count),1),I=_o().domain([1,O]).range([8,30]),_=p.nodes.map(A=>({...A})),T=p.links.map(A=>({...A})),C=Lf(_).force("link",Rf(T).id(A=>A.id).distance(120)).force("charge",Bf().strength(-350)).force("center",uf(M/2,P/2)).force("x",qf(M/2).strength(.1)).force("y",Hf(P/2).strength(.1)).force("collision",Df().radius(A=>I(A.count)+10)),R=N.append("g").attr("stroke","#999").attr("stroke-opacity",.4).selectAll("line").data(T).join("line").attr("stroke-width",A=>Math.sqrt(A.value)),D=N.append("g").selectAll("g").data(_).join("g").call(Zu().on("start",(A,$)=>{A.active||C.alphaTarget(.3).restart(),$.fx=$.x,$.fy=$.y}).on("drag",(A,$)=>{$.fx=A.x,$.fy=A.y}).on("end",A=>{A.active||C.alphaTarget(0)})).on("dblclick",(A,$)=>{$.fx=null,$.fy=null,C.alphaTarget(.3).restart(),setTimeout(()=>C.alphaTarget(0),500)}).on("click",(A,$)=>{b($)});return D.append("circle").attr("r",A=>I(A.count)).attr("fill",A=>hn[A.type]||"#999").attr("stroke","#fff").attr("stroke-width",1.5).attr("opacity",A=>.4+A.delivered/(A.count||1)*.6).attr("cursor","pointer"),D.append("text").text(A=>A.label.length>12?A.label.slice(0,12)+"...":A.label).attr("x",0).attr("y",A=>I(A.count)+12).attr("text-anchor","middle").attr("font-size","10px").attr("fill","currentColor").attr("class","text-foreground").attr("pointer-events","none"),C.on("tick",()=>{R.attr("x1",A=>A.source.x).attr("y1",A=>A.source.y).attr("x2",A=>A.target.x).attr("y2",A=>A.target.y),D.attr("transform",A=>`translate(${A.x},${A.y})`)}),()=>{C.stop()}},[p,s,l]),p.nodes.length===0?n.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No relationship data available with current filters"}):n.jsxs("div",{ref:h,className:s?"h-full":"",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 mb-4",children:[n.jsx("div",{className:"flex flex-wrap items-center gap-4",children:Object.entries(Zf).map(([g,M])=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(bn,{id:`filter-${g}`,checked:a.has(g),onCheckedChange:()=>o(g)}),n.jsxs(Ar,{htmlFor:`filter-${g}`,className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[n.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:hn[g]}}),M]})]},g))}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(G,{variant:l?"default":"outline",size:"sm",onClick:u,title:"Show only delivered",children:n.jsx(Mo,{className:"h-4 w-4"})}),n.jsx(G,{variant:"outline",size:"sm",onClick:f,title:"Zoom out",children:n.jsx(Ho,{className:"h-4 w-4"})}),n.jsxs("span",{className:"text-xs text-muted-foreground w-12 text-center",children:[Math.round(w*100),"%"]}),n.jsx(G,{variant:"outline",size:"sm",onClick:m,title:"Zoom in",children:n.jsx(qo,{className:"h-4 w-4"})}),n.jsx(G,{variant:"outline",size:"sm",onClick:d,title:"Reset zoom",children:n.jsx(zo,{className:"h-4 w-4"})}),i&&n.jsx(G,{variant:"outline",size:"sm",onClick:i,title:s?"Exit fullscreen":"Fullscreen",children:s?n.jsx(Pr,{className:"h-4 w-4"}):n.jsx(Fr,{className:"h-4 w-4"})})]})]}),n.jsxs("div",{className:"flex gap-4",children:[n.jsx("div",{ref:r,className:"flex-1",children:n.jsx("svg",{ref:c,className:"border border-border rounded-lg bg-card"})}),j&&n.jsxs("div",{className:"w-64 border border-border rounded-lg bg-card p-4 space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h4",{className:"font-semibold text-sm",children:"Node Details"}),n.jsx(G,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>b(null),children:n.jsx(ui,{className:"h-4 w-4"})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"Name"}),n.jsx("p",{className:"text-sm font-medium",children:j.label})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"Type"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:hn[j.type]}}),n.jsx("p",{className:"text-sm capitalize",children:j.type})]})]}),n.jsxs("div",{className:"border-t border-border pt-2",children:[n.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Metrics"}),n.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-lg font-bold",children:j.count}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Total"})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-lg font-bold text-success",children:j.delivered}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Delivered"})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-lg font-bold text-status-blocked",children:j.blocked}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Blocked"})]})]})]}),n.jsxs("div",{className:"border-t border-border pt-2",children:[n.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Delivery Rate"}),n.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:n.jsx("div",{className:"bg-success h-2 rounded-full",style:{width:`${j.delivered/(j.count||1)*100}%`}})}),n.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[Math.round(j.delivered/(j.count||1)*100),"% delivered"]})]})]})]})]}),n.jsxs("div",{className:"flex flex-wrap gap-4 mt-4 justify-center text-sm",children:[Object.entries(hn).filter(([g])=>a.has(g)).map(([g,M])=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:M}}),n.jsx("span",{className:"capitalize",children:g})]},g)),n.jsx("span",{className:"text-muted-foreground",children:"• Click node to view details"})]})]})}function Qf({data:e,chartRef:t}){if(e.length===0)return n.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No file type data available"});const i=Math.max(200,e.length*40);return n.jsx("div",{ref:t,children:n.jsx(On,{width:"100%",height:i,children:n.jsxs(Gi,{data:e,layout:"vertical",margin:{top:5,right:30,left:10,bottom:5},children:[n.jsx(Rn,{type:"number"}),n.jsx(Mn,{dataKey:"name",type:"category",width:70,tick:{fontSize:12},interval:0}),n.jsx(In,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"6px"},content:({active:a,payload:o,label:l})=>
11{if(!a||!o?.length)return null;const u=e.find(c=>c.name===l);return n.jsxs("div",{className:"bg-card border border-border rounded-md p-2 shadow-md",children:[n.jsx("p",{className:"font-medium text-foreground",children:l}),n.jsxs("p",{className:"text-sm text-success",children:["Delivered: ",u?.delivered||0]}),n.jsxs("p",{className:"text-sm text-status-blocked",children:["Blocked: ",u?.blocked||0]}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Total: ",u?.total||0]})]})}}),n.jsx(Pn,{}),n.jsx(en,{dataKey:"delivered",fill:"#4CDBC4",name:"Delivered",stackId:"a"}),n.jsx(en,{dataKey:"blocked",fill:"#FFAE5D",name:"Blocked",stackId:"a"})]})})})}function tr({data:e,chartRef:t}){if(e.length===0)return n.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No data available"});const i=Math.max(200,e.length*40);return n.jsx("div",{ref:t,children:n.jsx(On,{width:"100%",height:i,children:n.jsxs(Gi,{data:e,layout:"vertical",margin:{top:5,right:30,left:10,bottom:5},children:[n.jsx(Rn,{type:"number"}),n.jsx(Mn,{dataKey:"name",type:"category",width:120,tick:{fontSize:11},interval:0}),n.jsx(In,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"6px"},content:({active:a,payload:o,label:l})=>
11{if(!a||!o?.length)return null;const u=e.find(c=>c.name===l);return n.jsxs("div",{className:"bg-card border border-border rounded-md p-2 shadow-md",children:[n.jsx("p",{className:"font-medium text-foreground",children:u?.fullName||l}),n.jsxs("p",{className:"text-sm text-success",children:["Delivered: ",u?.delivered||0]}),n.jsxs("p",{className:"text-sm text-status-blocked",children:["Blocked: ",u?.blocked||0]}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Total: ",u?.total||0]})]})}}),n.jsx(Pn,{}),n.jsx(en,{dataKey:"delivered",fill:"#4CDBC4",name:"Delivered",stackId:"a"}),n.jsx(en,{dataKey:"blocked",fill:"#FFAE5D",name:"Blocked",stackId:"a"})]})})})}function em({emails:e,campaignName:t}){const r=E.useRef(null),s=E.useRef(null),i=E.useRef(null),a=E.useRef(null),o=E.useRef(null),[l,u]=E.useState(!1),[c,h]=E.useState(new Set(["technique","group","software","filetype"])),[w,y]=E.useState(!0),v=E.useCallback(D=>{h(A=>{const $=new Set(A);return $.has(D)?$.delete(D):$.add(D),$})},[]),S=E.useCallback(()=>{y(D=>!D)},[]),j=E.useMemo(()=>{const D=new Set;return e.forEach(A=>{A.recipe_uuid&&D.add(A.recipe_uuid)}),D},[e]),{data:b=[],isLoading:p}=So(),{data:m}=st({queryKey:["intel","techniques"],queryFn:()=>Yn.getTechniques(),staleTime:1800*1e3}),{data:f}=st({queryKey:["intel","groups"],queryFn:()=>Yn.getGroups(),staleTime:1800*1e3}),{data:d}=st({queryKey:["intel","software"],queryFn:()=>Yn.getSoftware(),staleTime:1800*1e3}),x=E.useMemo(()=>{const D=new Map;return m?.forEach(A=>D.set(A.id,A.name)),D},[m]),g=E.useMemo(()=>{const D=new Map;return f?.forEach(A=>D.set(A.id,A.name)),D},[f]),M=E.useMemo(()=>{const D=new Map;return d?.forEach(A=>D.set(A.id,A.name)),D},[d]),P=p,q=E.useMemo(()=>{const D=new Map;for(const A of b){const $=A.recipe_id||A.id;j.has($)&&D.set($,A)}return D},[b,j]),k=E.useMemo(()=>e.map(D=>({...D,details:q.get(D.recipe_uuid)})),[e,q]),N=E.useMemo(()=>{const D={},A={},$={},J={};for(const B of k){const Z=Dt(B.status)==="Delivered",X=Dt(B.status)==="Blocked",Y=B.details,te=B.extension.toUpperCase();if(D[te]||(D[te]={delivered:0,blocked:0,total:0}),D[te].total++,Z&&D[te].delivered++,X&&D[te].blocked++,Y){for(const V of Y.techniques||[]){const H=x.get(V)||V;A[V]||(A[V]={delivered:0,blocked:0,total:0,name:H}),A[V].total++,Z&&A[V].delivered++,X&&A[V].blocked++}for(const V of Y.groups||[]){const H=g.get(V)||V;$[V]||($[V]={delivered:0,blocked:0,total:0,name:H}),$[V].total++,Z&&$[V].delivered++,X&&$[V].blocked++}for(const V of Y.software||[]){const H=M.get(V)||V;J[V]||(J[V]={delivered:0,blocked:0,total:0,name:H}),J[V].total++,Z&&J[V].delivered++,X&&J[V].blocked++}}}return{fileTypes:Object.entries(D).map(([B,Z])=>({name:B,...Z})).sort((B,Z)=>Z.total-B.total).slice(0,10),techniques:Object.entries(A).map(([,B])=>({name:B.name.length>25?B.name.slice(0,25)+"...":B.name,fullName:B.name,delivered:B.delivered,blocked:B.blocked,total:B.total})).sort((B,Z)=>Z.total-B.total).slice(0,10),groups:Object.entries($).map(([,B])=>({name:B.name.length>25?B.name.slice(0,25)+"...":B.name,fullName:B.name,delivered:B.delivered,blocked:B.blocked,total:B.total})).sort((B,Z)=>Z.total-B.total).slice(0,10),software:Object.entries(J).map(([,B])=>({name:B.name.length>25?B.name.slice(0,25)+"...":B.name,fullName:B.name,delivered:B.delivered,blocked:B.blocked,total:B.total})).sort((B,Z)=>Z.total-B.total).slice(0,10)}},[k,x,g,M]),O=E.useMemo(()=>{const D=new Map,A=(B,Z,X,Y,te)=>{let V=D.get(B);V||(V={id:B,label:Z,type:X,count:0,delivered:0,blocked:0},D.set(B,V)),V.count++,Y&&V.delivered++,te&&V.blocked++},$=new Map,J=(B,Z)=>{const X=[B,Z].sort().join("-");let Y=$.get(X);Y||(Y={source:B,target:Z,value:0},$.set(X,Y)),Y.value++};for(const B of k){const Z=Dt(B.status)==="Delivered",X=Dt(B.status)==="Blocked",Y=B.details,te=`ft-${B.extension.toLowerCase()}`;if(A(te,B.extension.toUpperCase(),"filetype",Z,X),Y){for(const V of Y.techniques||[]){const H=x.get(V)||V,F=`tech-${V}`;A(F,H,"technique",Z,X),J(te,F)}for(const V of Y.groups||[]){const H=g.get(V)||V,F=`group-${V}`;A(F,H,"group",Z,X),J(te,F);for(const Q of Y.techniques||[])J(F,`tech-${Q}`)}for(const V of Y.software||[]){const H=M.get(V)||V,F=`sw-${V}`;A(F,H,"software",Z,X),J(te,F);for(const Q of Y.techniques||[])J(F,`tech-${Q}`)}}}return{nodes:Array.from(D.values()),links:Array.from($.values()).filter(
11B=>B.value>0)}},[k,x,g,M]),I=async(D,A)=>{const $=`${t.replace(/[^a-z0-9]/gi,"_")}_${A}.png`;await ur(D,$)},_=N.groups.length>0,T=N.software.length>0,C=N.techniques.length>0,R=O.nodes.length>1;return P?n.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[n.jsx(Oa,{size:48}),n.jsx("span",{className:"text-muted-foreground",children:"Processing payload data..."})]}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[n.jsx(ue,{children:n.jsxs(he,{className:"pt-6",children:[n.jsx("div",{className:"text-2xl font-bold",children:e.length}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Payloads"})]})}),n.jsx(ue,{children:n.jsxs(he,{className:"pt-6",children:[n.jsx("div",{className:"text-2xl font-bold text-success",children:e.filter(D=>Dt(D.status)==="Delivered").length}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Delivered"})]})}),n.jsx(ue,{children:n.jsxs(he,{className:"pt-6",children:[n.jsx("div",{className:"text-2xl font-bold text-status-blocked",children:e.filter(D=>Dt(D.status)==="Blocked").length}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Blocked"})]})}),n.jsx(ue,{children:n.jsxs(he,{className:"pt-6",children:[n.jsx("div",{className:"text-2xl font-bold",children:new Set(e.map(D=>D.extension.toLowerCase())).size}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"File Types"})]})})]}),R&&n.jsxs(n.Fragment,{children:[n.jsxs(ue,{children:[n.jsxs(Ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(Ae,{children:"Threat Intelligence Relationships"}),n.jsx(G,{variant:"ghost",size:"sm",onClick:()=>I(o,"network_graph"),children:n.jsx(de,{className:"h-4 w-4"})})]}),n.jsxs(he,{children:[n.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Node size indicates frequency. Connections show shared attributes between payloads.",w?" Highlighting delivered payloads.":" Opacity reflects delivery success rate."]}),n.jsx(Ks,{nodes:O.nodes,links:O.links,chartRef:o,isFullscreen:!1,onToggleFullscreen:()=>u(!0),visibleTypes:c,onToggleType:v,focusDelivered:w,onToggleFocusDelivered:S})]})]}),l&&n.jsxs("div",{className:"fixed inset-0 z-[100] bg-background flex flex-col !mt-0",children:[n.jsxs("div",{className:"flex items-center justify-between h-16 px-6 border-b border-border",children:[n.jsx("h2",{className:"text-xl font-semibold",children:"Threat Intelligence Relationships"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>I(o,"network_graph"),children:[n.jsx(de,{className:"h-4 w-4 mr-2"}),"Export"]}),n.jsxs(G,{variant:"outline",size:"sm",onClick:()=>u(!1),children:[n.jsx(Pr,{className:"h-4 w-4 mr-2"}),"Exit Fullscreen"]})]})]}),n.jsx("div",{className:"flex-1 min-h-0 p-6",children:n.jsx(Ks,{nodes:O.nodes,links:O.links,chartRef:o,isFullscreen:!0,onToggleFullscreen:()=>u(!1),visibleTypes:c,onToggleType:v,focusDelivered:w,onToggleFocusDelivered:S})})]})]}),n.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[n.jsxs(ue,{children:[n.jsxs(Ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(Ae,{children:"Deliverability by File Type"}),n.jsx(G,{variant:"ghost",size:"sm",onClick:()=>I(r,"file_types"),children:n.jsx(de,{className:"h-4 w-4"})})]}),n.jsx(he,{children:n.jsx(Qf,{data:N.fileTypes,chartRef:r})})]}),C&&n.jsxs(ue,{children:[n.jsxs(Ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(Ae,{children:"Deliverability by Attack Technique"}),n.jsx(G,{variant:"ghost",size:"sm",onClick:()=>I(a,"techniques"),children:n.jsx(de,{className:"h-4 w-4"})})]}),n.jsx(he,{children:n.jsx(tr,{data:N.techniques,chartRef:a})})]}),_&&n.jsxs(ue,{children:[n.jsxs(Ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(Ae,{children:"Deliverability by Threat Group"}),n.jsx(G,{variant:"ghost",size:"sm",onClick:()=>I(s,"threat_groups"),children:n.jsx(de,{className:"h-4 w-4"})})]}),n.jsx(he,{children:n.jsx(tr,{data:N.groups,chartRef:s})})]}),T&&n.jsxs(ue,{children:[n.jsxs(Ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(Ae,{children:"Deliverability by Software"}),n.jsx(G,{variant:"ghost",size:"sm",onClick:()=>I(i,"software"),children:n.jsx(de,{className:"h-4 w-4"})})]}),n.jsx(he,{children:n.jsx(tr,{data:N.software,chartRef:i})})]})]}),!_&&!T&&!C&&n.jsx(ue,{children:n.jsx(he,{className:"py-8",children:n.jsxs("p",{className:"text-center text-muted-foreground",children:["No threat intelligence metadata available for the payloads in this campaign.",n.jsx("br",{}),n.jsx("span",{className:"text-sm",children:"Threat group, software, and attack technique breakdowns will appear when payloads have associated threat intelligence data."})]})})})]})}const Js={Delivered:"bg-green-500/5 hover:bg-green-500/10",Deleted:"bg-orange-500/5 hover:bg-orange-500/10",Blocked:"bg-orange-500/5 hover:bg-orange-500/10","No Download":"bg-orange-500/5 hover:bg-orange-500/10"},tm=["Hosted","Accessed","Delivered","Deleted","Blocked","No Download"],nm={Hosted:"not_accessed",Accessed:"timeout",Delivered:"verified",Deleted:"deleted",Blocked:"hash_mismatch","No Download":"no_download"},rm={antivirus_quarantine:"Blocked by Antivirus / EDR",safe_browsing_block:"Blocked by Safe Browsing",user_deleted:"Deleted by user",unknown:"Unknown reason"};function Ys(e){return e?rm[e]||e.replace(/_/g," "):null}function sm(e){const t=typeof e=="string"?parseInt(e,10):e;return new Date(t*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Xs(e){const t=Math.floor(Date.now()/1e3),r=e-t;if(r<=0)return{isExpired:!0,label:"Expired",variant:"destructive"};const s=Math.floor(r/60),i=Math.floor(s/60);return i>0?{isExpired:!1,label:`${i}h ${s%60}m`,variant:"secondary"}:s>0?{isExpired:!1,label:`${s}m`,variant:s<10?"outline":"secondary"}:{isExpired:!1,label:"<1m",variant:"outline"}}function im({link:e,onBeforeAction:t,disabled:r=!1}){const[s,i]=E.useState(!1),a=async()=>
11{if(!r&&!(t&&!t()))try{await navigator.clipboard.writeText(e),i(!0),W.success("Link copied to clipboard"),setTimeout(()=>i(!1),2e3)}catch{W.error("Failed to copy link")}};return n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,disabled:r,children:s?n.jsx(Jt,{className:"h-3.5 w-3.5 text-green-500"}):n.jsx(_t,{className:"h-3.5 w-3.5"})})})}),n.jsx(ae,{children:r?"Link expired":s?"Copied!":"Copy link"})]})}function Zs({status:e}){const t=tn[e];return n.jsx(De,{style:{backgroundColor:t.bg,"--status-text":t.text,"--status-text-dark":t.darkText},className:"font-normal text-[--status-text] dark:text-[--status-text-dark]",children:e})}function Qs({linkId:e,status:t,onStatusChange:r,disabled:s}){const i=tn[t];return n.jsxs(Er,{value:t,onValueChange:a=>{const o=nm[a];o&&r(e,o)},disabled:s,children:[n.jsx(Dr,{className:"h-7 w-[130px] border-0 px-2 text-[--status-text] dark:text-[--status-text-dark]",style:{backgroundColor:i.bg,"--status-text":i.text,"--status-text-dark":i.darkText},children:n.jsx("span",{children:t})}),n.jsx(Tr,{children:tm.map(a=>{const o=tn[a];return n.jsx(Rr,{value:a,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:o.bg}}),a]})},a)})})]})}function am({open:e,onOpenChange:t,onEnableMonitoring:r,onProceedWithoutMonitoring:s,actionType:i}){const a={copy:"copying the link",open:"opening the link",download:"downloading all links"}[i];return n.jsx($e,{open:e,onOpenChange:t,children:n.jsxs(ze,{className:"sm:max-w-md",children:[n.jsxs(Le,{children:[n.jsxs(Be,{className:"flex items-center gap-2",children:[n.jsx(Ve,{className:"h-5 w-5 text-muted-foreground"}),"Enable Download Monitoring?"]}),n.jsx(qe,{className:"pt-2",children:"Verify downloads and detect antivirus blocks in real-time."})]}),n.jsxs("div",{className:"py-2 text-sm text-muted-foreground",children:["Would you like to enable monitoring before ",a,"?"]}),n.jsxs(Cr,{className:"flex-col sm:flex-row gap-2",children:[n.jsx(G,{variant:"outline",onClick:s,children:"Skip for now"}),n.jsx(G,{onClick:r,children:"Enable Monitoring"})]})]})})}function ei({open:e,onOpenChange:t}){return n.jsx($e,{open:e,onOpenChange:t,children:n.jsxs(ze,{className:"sm:max-w-lg",children:[n.jsxs(Le,{children:[n.jsxs(Be,{className:"flex items-center gap-2",children:[n.jsx(Ve,{className:"h-5 w-5 text-muted-foreground"}),"Download Monitoring"]}),n.jsx(qe,{children:"Automatically verify payload delivery and detect security control blocks."})]}),n.jsxs("div",{className:"space-y-4 text-sm",children:[n.jsxs("div",{children:[n.jsx("p",{className:"font-medium mb-1",children:"How it works"}),n.jsx("p",{className:"text-muted-foreground",children:"Every payload download is verified in two stages. First, the downloaded content is hash-checked in your browser to confirm it passed through your web proxy intact (Globe column). This works on all browsers. On Chromium browsers with Download Monitoring enabled, payloads are saved to a selected folder and watched for deletion by antivirus or endpoint protection (Shield column)."})]}),n.jsxs("div",{children:[n.jsx("p",{className:"font-medium mb-1",children:"Which folder to select"}),n.jsx("p",{className:"text-muted-foreground",children:"Select your browser's default downloads directory, or create a subfolder within it for testing. Payloads will be saved to whichever folder you choose, so there's no need to configure your browser's download location separately."})]}),n.jsxs("div",{children:[n.jsx("p",{className:"font-medium mb-1",children:"Privacy"}),n.jsx("p",{className:"text-muted-foreground",children:"Only file names and MD5 hashes are read from the selected directory. File contents are not uploaded or transmitted. Access is scoped to the single folder you choose."})]}),n.jsxs("div",{children:[n.jsx("p",{className:"font-medium mb-1",children:"Browser support"}),n.jsx("p",{className:"text-muted-foreground",children:"Proxy verification works on all browsers. Endpoint detection (file write monitoring) requires a Chromium-based browser (Chrome, Edge) with File System Access API support."})]})]})]})})}function ka({status:e,observerSupported:t,isSupported:r,verifiedCount:s,blockedCount:i,totalLinks:a,directoryName:o,onEnable:l,onStop:u,onChangeDirectory:c}){const[h,w]=E.useState(!1);if(!r)return n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-lg border bg-muted/30 border-border",children:[n.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-muted text-muted-foreground",children:n.jsx(Ve,{className:"h-4 w-4"})}),n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm font-medium",children:"Download Monitoring"}),n.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors",onClick:()=>w(!0),children:n.jsx(_n,{className:"h-3.5 w-3.5"})})]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Proxy verification is active on all browsers. Enable Download Monitoring on Chrome or Edge for endpoint detection."})]}),n.jsx(ei,{open:h,onOpenChange:w})]});const y=e==="monitoring",v=e==="requesting";return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:_e("flex items-center justify-between px-4 py-2.5 rounded-lg border transition-all duration-300",y?"bg-green-500/5 border-green-500/20 dark:bg-green-500/10":"bg-muted/30 border-border"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:_e("flex items-center justify-center w-8 h-8 rounded-full transition-colors",y?"bg-green-500/10 text-green-500":"bg-muted text-muted-foreground"),children:y?n.jsx(Ia,{className:"h-4 w-4"}):n.jsx(Ve,{className:"h-4 w-4"})}),n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm font-medium",children:y?"Monitoring Active":"Download Monitoring"}),n.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors",onClick:()=>w(!0),children:n.jsx(_n,{className:"h-3.5 w-3.5"})}),y&&n.jsx(De,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-green-500/30 text-green-600 dark:text-green-400",children:t?"Real-time":"Polling"})]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:y?n.jsxs(n.Fragment,{children:["Watching ",a," link",a!==1?"s":"",o&&n.jsxs("span",{className:"ml-1",children:["in"," ",n.jsx("span",{className:"font-medium text-foreground
11/70",children:o}),c&&n.jsx("button",{className:"ml-1 text-primary hover:underline",onClick:S=>{S.stopPropagation(),c()},children:"(change)"})]}),(s>0||i>0)&&n.jsxs("span",{className:"ml-1",children:["·"," ",s>0&&n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:[s," verified"]}),s>0&&i>0&&", ",i>0&&n.jsxs("span",{className:"text-red-600 dark:text-red-400",children:[i," blocked"]})]})]}):"Verify downloads & detect AV blocks"})]})]}),y?n.jsxs(G,{variant:"ghost",size:"sm",onClick:u,className:"text-muted-foreground hover:text-foreground",children:[n.jsx(Ro,{className:"h-4 w-4 mr-1.5"}),"Stop"]}):n.jsx(G,{variant:v?"ghost":"default",size:"sm",onClick:l,disabled:v,className:_e(!v&&"bg-gradient-to-r from-green-500 to-emerald-500 hover:from-green-600 hover:to-emerald-600 text-white border-0"),children:v?n.jsxs(n.Fragment,{children:[n.jsx(hr,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Requesting..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Oo,{className:"h-4 w-4 mr-1.5"}),"Enable"]})})]}),n.jsx(ei,{open:h,onOpenChange:w})]})}function om({monitoringStatus:e,monitoredDownloads:t,isMonitoringSupported:r,observerSupported:s,onRequestMonitoring:i,onStopMonitoring:a,onChangeDirectory:o,directoryName:l,totalLinks:u}){let c=0,h=0;for(const[,w]of t)w.status==="verified"?c++:(w.status==="deleted"||w.status==="hash_mismatch")&&h++;return n.jsx(ka,{status:e,observerSupported:s,isSupported:r,verifiedCount:c,blockedCount:h,totalLinks:u,directoryName:l,onEnable:i,onStop:a,onChangeDirectory:o})}function lm({payloadLinks:e,monitoringStatus:t,monitoredDownloads:r,isMonitoringSupported:s,observerSupported:i,onRequestMonitoring:a,onStopMonitoring:o,onChangeDirectory:l,directoryName:u,onStatusChange:c,saveToDirectory:h,verifyBlobInline:w,hasPushSecurityIntegration:y,onPushSecurityClick:v,showMonitoringBar:S=!0}){const[j,b]=E.useState(null),[p,m]=E.useState(null),[f,d]=E.useState({open:!1,actionType:"copy",pendingAction:null}),[x,g]=E.useState(new Set),[M,P]=E.useState(null),[q,k]=E.useState("asc"),N=L=>{M===L?k(q==="asc"?"desc":"asc"):(P(L),k("asc"))},O=new Map;for(const L of e)O.set(L.link_id,zr(L,r.get(L.link_id)));const I=e.some(L=>L.client_reports?.some(z=>z.possible_reason==="download_complete")||r.has(L.link_id)),_=e.some(L=>L.client_reports?.some(z=>z.possible_reason==="file_verified"||z.possible_reason==="antivirus_quarantine"||z.possible_reason==="safe_browsing_block")||r.has(L.link_id)&&(r.get(L.link_id)?.status==="verified"||r.get(L.link_id)?.status==="deleted")),T=E.useMemo(()=>M?[...e].sort((L,z)=>{let le=0;if(M==="payload")le=L.payload_name.localeCompare(z.payload_name);else if(M==="status"){const ge=O.get(L.link_id)??"Hosted",Re=O.get(z.link_id)??"Hosted";le=ge.localeCompare(Re)}return q==="asc"?le:-le}):e,[e,M,q,O]),[C,R]=E.useState(typeof window<"u"&&window.innerWidth>=1024);E.useEffect(()=>{const L=window.matchMedia("(min-width: 1024px)"),z=le=>R(le.matches);return L.addEventListener("change",z),()=>L.removeEventListener("change",z)},[]);const D=C?"140px":"80px",A=E.useRef(null),$=E.useRef(null),J=48,B=120,Z=Cn({count:T.length,getScrollElement:()=>A.current,estimateSize:()=>J,overscan:10}),X=Cn({count:T.length,getScrollElement:()=>$.current,estimateSize:()=>B,overscan:5}),Y=async L=>{g(z=>new Set(z).add(L.link_id));try{const z=await fetch(L.link_url);if(!z.ok){(z.headers.get("content-type")||"").includes("application/json")?(await z.json()).message==="Link expired."?W.error("Link expired"):W.error("Failed to download payload"):W.error(`Download failed (${z.status})`);return}if((z.headers.get("content-type")||"").includes("application/json")){const me=z.clone();try{if((await me.json()).message==="Link expired."){W.error("Link expired");return}}catch{}}const ge=await z.blob();if(te&&h&&await h(ge,L.payload_name)){W.success(`Saved ${L.payload_name} to monitored folder`);return}w&&await w(ge,L.payload_name);const Re=URL.createObjectURL(ge),ce=document.createElement("a");ce.href=Re,ce.download=L.payload_name,document.body.appendChild(ce),ce.click(),document.body.removeChild(ce),URL.revokeObjectURL(Re),W.success(`Downloaded ${L.payload_name}`)}catch{W.error(`Failed to download ${L.payload_name}`)}finally{g(z=>{const le=new Set(z);return le.delete(L.link_id),le})}},te=t==="monitoring";let V=0,H=0;for(const[,L]of r)L.status==="verified"?V++:(L.status==="deleted"||L.status==="hash_mismatch")&&H++;const F=(L,z)=>te||!s?!0:(d({open:!0,actionType:L,pendingAction:z}),!1),Q=async()=>{await a()&&f.pendingAction&&f.pendingAction(),d({open:!1,actionType:"copy",pendingAction:null})},lt=()=>{f.pendingAction&&f.pendingAction(),d({open:!1,actionType:"copy",pendingAction:null})};return e.length===0?n.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No payload links generated"}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:S?"space-y-4":void 0,children:[S&&n.jsx(ka,{status:t,observerSupported:i,isSupported:s,verifiedCount:V,blockedCount:H,totalLinks:e.length,directoryName:u,onEnable:a,onStop:o,onChangeDirectory:l}),n.jsx("div",{ref:$,className:"min-[900px]:hidden overflow-y-auto max-h-[600px] space-y-2",children:T.length===0?n.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No payload links generated"}):n.jsx("div",{style:{height:`${X.getTotalSize()}px`,width:"100%",position:"relative"},children:X.getVirtualItems().map(L=>{const z=T[L.index],le=Xs(z.expiry_epoch),ge=z.payload_name.split(".").pop()?.toLowerCase()||"",Re=le.isExpired,ce=O.get(z.link_id)??"Hosted",me=r.get(z.link_id),fe=Ys(me?.possibleReason||z.client_reports?.[z.client_reports.length-1]?.possible_reason),et=(me?!0:z.client_reports?.some(Ie=>Ie.possible_reason==="download_complete")??!1)?me?me.status==="verified"||me.status==="deleted"||me.status==="hash_mismatch":!0:null;return n.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${L.size}px`,transform:`translateY(${L.start}px)`},className:"pb-2",children:n.jsxs("div",{className:_e("rounded-lg border p-3",Js[ce]||""),children:[n.jsxs("div",{className:"flex items-center gap-2.5 mb-2",children:[n.jsxs("div",{className:"relative shrink-0",children:[n.jsx("img",{src:`/images/${ge}.png`,alt:ge,className:"h-7 w-7",onError:Ie=>{Ie.target.src="/images/blank.png"}}),ce==="Delivered"&&n.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 bg-green-500 rounded-full flex items-center justify-center",children:n.jsx(Jt,{className:"h-2 w-2 text-white"})})]}),n.jsx("button",{className:"flex-1 min-w-0 text-sm font-medium text-primary hover:underline text-left truncate",onClick:()=>m({payloadId:z.recipe_id??z.payload_id,recipeId:null}),children:z.payload_name}),n.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[n.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:Re||x.has(z.link_id),onClick:()=>{F("download",()=>Y(z))&&Y(z)},children:x.has(z.link_id)?n.jsx(hr,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(de,{className:"h-3.5 w-3.5"})}),n.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:Re,onClick:()=>{navigator.clipboard.writeText(z.link_url),W.success("Link copied")},children:n.jsx(_t,{className:"h-3.5 w-3.5"})})]})]}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c?n.jsx(Qs,{linkId:z.link_id,status:ce,onStatusChange:c}):n.jsx(Zs,{status:ce}),n.jsx("span",{className:_e("text-[11px]",le.isExpired?"text-destructive":"text-muted-foreground"),children:le.isExpired?"Expired":le.label}),z.click_count>0&&n.jsxs("button",{className:"text-[11px] text-muted-foreground hover:text-foreground flex items-center gap-0.5",onClick:()=>b({payloadName:z.payload_name,accesses:z.accesses}),children:[n.jsx(cr,{className:"h-3 w-3"}),z.click_count]}),et!=null&&n.jsx(dr,{className:_e("h-3 w-3",et?"text-success":"text-status-blocked")}),fe&&n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx(Ve,{className:"h-3 w-3 text-status-blocked cursor-help"})}),n.jsx(ae,{children:fe})]})]})]})}
11,z.link_id)})})}),n.jsx("div",{ref:A,className:"hidden min-[900px]:block rounded-lg border overflow-y-auto overflow-x-hidden max-h-[800px]",children:n.jsxs("div",{children:[n.jsxs("div",{className:"sticky top-0 bg-background z-10 border-b grid items-center h-12 text-sm font-medium text-muted-foreground",style:{gridTemplateColumns:`1fr ${D} 80px 56px ${I?"40px ":""}${_?"40px ":""}${y?"40px ":""}150px`},children:[n.jsx("div",{className:"px-3 cursor-pointer hover:bg-muted/50 h-full flex items-center",onClick:()=>N("payload"),children:n.jsxs("div",{className:"flex items-center gap-1",children:["Payload",M==="payload"&&n.jsx("span",{className:"text-xs",children:q==="asc"?"↑":"↓"})]})}),n.jsx("div",{className:"px-3",children:"Link"}),n.jsx("div",{className:"px-3 text-center",children:"Expires"}),y&&n.jsx("div",{className:"px-1 text-center",children:n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx("span",{className:"cursor-help inline-flex justify-center",children:n.jsx(at,{service:"push_security",size:16})})}),n.jsx(ae,{children:"Push Security"})]})}),n.jsx("div",{className:"px-3 text-center",children:n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx("span",{className:"cursor-help",children:"Clicks"})}),n.jsx(ae,{children:"Server-side click count"})]})}),I&&n.jsx("div",{className:"px-1 text-center",children:n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx("span",{className:"cursor-help",children:n.jsx(dr,{className:"h-3.5 w-3.5 mx-auto"})})}),n.jsx(ae,{children:"Proxy / download result"})]})}),_&&n.jsx("div",{className:"px-1 text-center",children:n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx("span",{className:"cursor-help",children:n.jsx(Ve,{className:"h-3.5 w-3.5 mx-auto"})})}),n.jsx(ae,{children:"Endpoint / AV result"})]})}),n.jsx("div",{className:"px-3 text-center cursor-pointer hover:bg-muted/50 h-full flex items-center justify-center",onClick:()=>N("status"),children:n.jsxs("div",{className:"flex items-center gap-1",children:["Status",M==="status"&&n.jsx("span",{className:"text-xs",children:q==="asc"?"↑":"↓"})]})})]}),n.jsx("div",{style:{height:T.length>0?`${Z.getTotalSize()}px`:"auto",position:"relative"},children:T.length===0?n.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No payload links generated"}):Z.getVirtualItems().map(L=>{const z=T[L.index],le=Xs(z.expiry_epoch),ge=z.payload_name.split(".").pop()?.toLowerCase()||"",Re=ge==="html"||ge==="htm",ce=le.isExpired,me=O.get(z.link_id)??"Hosted",fe=r.get(z.link_id),Ut=Ys(fe?.possibleReason||z.client_reports?.[z.client_reports.length-1]?.possible_reason),Ie=(fe?!0:z.client_reports?.some(Ge=>Ge.possible_reason==="download_complete")??!1)?fe?fe.status==="verified"||fe.status==="deleted"||fe.status==="hash_mismatch":!0:null;let tt=null;if(fe)tt=fe.status==="verified"?"passed":fe.status==="deleted"||fe.status==="hash_mismatch"?"blocked":null;else if(z.client_reports?.length){const Ge=["file_verified","antivirus_quarantine","safe_browsing_block"],St=[...z.client_reports].filter(ct=>ct.possible_reason&&Ge.includes(ct.possible_reason)).sort((ct,Wn)=>Number(Wn.timestamp)-Number(ct.timestamp))[0];St&&(tt=St.possible_reason==="file_verified"?"passed":"blocked")}return n.jsxs("div",{className:_e("grid items-center border-b text-sm group transition-colors",Js[me]||"hover:bg-muted/50"),style:{gridTemplateColumns:`1fr ${D} 80px 56px ${I?"40px ":""}${_?"40px ":""}${y?"40px ":""}150px`,position:"absolute",top:0,left:0,width:"100%",height:`${L.size}px`,transform:`translateY(${L.start}px)`},children:[n.jsx("div",{className:"px-3 truncate min-w-[200px]",children:n.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[n.jsxs("div",{className:"relative flex-shrink-0",children:[n.jsx("img",{src:`/images/${ge}.png`,alt:ge,className:"h-6 w-6 shrink-0",onError:Ge=>{Ge.target.src="/images/blank.png"}}),me==="Delivered"&&n.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 bg-green-500 rounded-full flex items-center justify-center",children:n.jsx(Jt,{className:"h-2 w-2 text-white"})})]}),n.jsx("button",{className:"font-medium truncate text-left text-primary hover:underline",onClick:()=>m({payloadId:z.recipe_id??z.payload_id,recipeId:null}),children:z.payload_name})]})}),n.jsx("div",{className:"px-1",children:n.jsxs("div",{className:"flex items-center gap-0",children:[n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx("code",{className:"text-[10px] bg-muted/50 px-1.5 py-0.5 rounded font-mono text-muted-foreground cursor-help hidden lg:inline",children:z.link_id.slice(-8)})}),n.jsx(ae,{children:z.link_url})]}),n.jsx(im,{link:z.link_url,disabled:ce,onBeforeAction:()=>F("copy",()=>{navigator.clipboard.writeText(z.link_url),W.success("Link copied to clipboard")})}),n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:ce||x.has(z.link_id),onClick:()=>
11{if(ce)return;F("download",()=>Y(z))&&Y(z)},children:x.has(z.link_id)?n.jsx(hr,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(de,{className:"h-3.5 w-3.5"})})})}),n.jsx(ae,{children:ce?"Link expired":x.has(z.link_id)?"Downloading...":"Download"})]}),Re&&n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:ce,onClick:()=>{ce||window.open(z.link_url,"_blank")},children:n.jsx($n,{className:"h-3.5 w-3.5"})})}),n.jsx(ae,{children:"Open in browser"})]})]})}),n.jsx("div",{className:"px-3 text-center",children:n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx(De,{variant:le.variant,className:"text-xs",children:le.label})}),n.jsx(ae,{children:le.isExpired?"Expired":`Expires: ${sm(z.expiry_epoch)}`})]})}),y&&n.jsx("div",{className:"px-1 text-center",children:z.browser_security_information?.PushSecurity?.detections?.length?n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v?.(z),children:n.jsx(at,{service:"push_security",size:16})})}),n.jsxs(ae,{children:[z.browser_security_information.PushSecurity.detections.length," detection",z.browser_security_information.PushSecurity.detections.length!==1?"s":""]})]}):n.jsx("span",{className:"text-muted-foreground text-xs",children:"-"})}),n.jsx("div",{className:"px-3 text-center",children:z.click_count>0?n.jsxs(G,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>b({payloadName:z.payload_name,accesses:z.accesses}),children:[n.jsx(cr,{className:"h-3.5 w-3.5 mr-1"}),z.click_count]}):n.jsx("span",{className:"text-muted-foreground text-xs",children:"0"})}),I&&n.jsx("div",{className:"px-1 text-center",children:Ie!=null&&n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:Ie?n.jsx(Jt,{className:"h-3.5 w-3.5 text-success mx-auto cursor-help"}):n.jsx(Ve,{className:"h-3.5 w-3.5 text-status-blocked mx-auto cursor-help"})}),n.jsx(ae,{children:Ie?"Downloaded successfully":"Download blocked by proxy"})]})}),_&&n.jsx("div",{className:"px-1 text-center",children:tt&&n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:tt==="passed"?n.jsx(Jt,{className:"h-3.5 w-3.5 text-success mx-auto cursor-help"}):n.jsx(Ve,{className:"h-3.5 w-3.5 text-status-blocked mx-auto cursor-help"})}),n.jsx(ae,{children:tt==="passed"?"File verified on disk":Ut||"Blocked by endpoint protection"})]})}),n.jsx("div",{className:"px-3 text-center",children:c?n.jsx(Qs,{linkId:z.link_id,status:me,onStatusChange:c}):n.jsx(Zs,{status:me})})]},z.link_id)})})]})})]}),n.jsx(na,{open:!!j,onOpenChange:L=>!L&&b(null),accesses:j?.accesses,recipient:j?.payloadName}),n.jsx(Mr,{payloadId:p?.payloadId??null,recipeId:p?.recipeId??null,open:!!p,onOpenChange:L=>!L&&m(null)}),n.jsx(am,{open:f.open,onOpenChange:L=>!L&&d({open:!1,actionType:"copy",pendingAction:null}),onEnableMonitoring:Q,onProceedWithoutMonitoring:lt,actionType:f.actionType})]})}const ti="campaign_insights_panel";function cm(){const[e,t]=E.useState(()=>{try{return localStorage.getItem(ti)==="collapsed"}catch{return!1}});return{collapsed:e,updateCollapsed:s=>{t(s);try{localStorage.setItem(ti,s?"collapsed":"expanded")}catch{}}}}function ni({collapsed:e,onCollapsedChange:t}){return n.jsx(G,{variant:"ghost",size:"icon",onClick:()=>t(!e),"aria-controls":"campaign-insights-sidebar","aria-expanded":!e,"aria-label":e?"Expand insights panel":"Collapse insights panel",title:e?"Expand insights panel":"Collapse insights panel",className:"hidden h-8 w-8 text-muted-foreground hover:bg-transparent hover:text-primary lg:inline-flex",children:e?n.jsx(Fr,{className:"h-4 w-4"}):n.jsx(Pr,{className:"h-4 w-4"})})}function ri({collapsed:e,onCollapsedChange:t,children:r}){const[s,i]=E.useState(!e);return E.useEffect(()=>{if(e){i(!1);return}const a=setTimeout(()=>i(!0),320);return()=>clearTimeout(a)},[e]),n.jsxs("aside",{id:"campaign-insights-sidebar",className:_e("w-full min-w-0 lg:shrink-0 lg:transition-[width] lg:duration-300 lg:ease-in-out",e?"lg:w-10":"lg:w-[380px]"),children:[n.jsxs("div",{className:_e("hidden h-full w-10 flex-col items-center rounded-lg border bg-card p-1 text-card-foreground shadow-sm",e&&"lg:flex"),children:[n.jsx(G,{variant:"ghost",size:"icon",onClick:()=>t(!1),title:"Expand insights panel","aria-label":"Expand insights panel","aria-controls":"campaign-insights-sidebar","aria-expanded":!1,className:"h-8 w-8 shrink-0 text-muted-foreground hover:bg-transparent hover:text-primary",children:n.jsx(Fr,{className:"h-4 w-4"})}),n.jsxs("div",{className:"mt-2 flex flex-col items-center gap-3","aria-hidden":"true",children:[n.jsx(Io,{className:"h-4 w-4 text-muted-foreground"}),n.jsx($o,{className:"h-4 w-4 text-muted-foreground"})]})]}),n.jsx("div",{className:_e((e||!s)&&"lg:hidden"),children:r})]})}function si({sidebarToggle:e,campaignName:t,insights:r,recommendationsData:s,isPremium:i,relatedCampaignsList:a,emails:o,webDistribution:l,onInsightsUpgradeClick:u,onRecommendationsUpgradeClick:c}){const h=E.useRef(null),w=E.useRef(null),y=l!==void 0;return n.jsxs("div",{className:"space-y-6 min-w-0",children:[n.jsxs(ue,{className:"relative overflow-hidden",children:[e&&n.jsx("div",{className:"absolute right-1 top-1 z-10",children:e}),n.jsxs(Ce,{className:"flex flex-row flex-wrap items-center justify-between gap-2 pb-2",children:[n.jsx(Ae,{children:"Insights"}),r&&r.length>0&&i&&n.jsx(od,{insights:r,campaignName:t})]}),n.jsx(he,{className:"overflow-x-auto",children:r&&r.length>0?n.jsx(zc,{insights:r,isPremium:i,onUpgradeClick:u}):i?n.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No insights available for this campaign"}):n.jsx("div",{className:"border rounded-md overflow-hidden",children:n.jsxs("button",{onClick:u,className:"relative flex items-center justify-center gap-2 py-4 w-full hover:bg-muted/50 transition-colors cursor-pointer",children:[n.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[n.jsx("div",{className:"absolute top-0 right-1/4 w-24 h-24 bg-primary/10 rounded-full blur-2xl"}),n.jsx("div",{className:"absolute bottom-0 left-1/4 w-20 h-20 bg-chart-purple/10 rounded-full blur-2xl"})]}),n.jsx(wn,{className:"h-6 w-6 text-primary relative z-10"}),n.jsx("p",{className:"text-sm text-muted-foreground relative z-10",children:"Insights are available with Premium & Enterprise subscriptions."})]})})})]}),n.jsxs(ue,{className:"overflow-hidden",children:[n.jsxs(Ce,{className:"flex flex-row flex-wrap items-center justify-between gap-2 pb-2",children:[n.jsx(Ae,{children:"Recommendations"}),s?.recommendations&&s.recommendations.length>0&&i&&n.jsx(dd,{recommendations:s.recommendations,campaignName:t})]}),n.jsx(he,{className:"overflow-x-auto",children:s?.recommendations&&s.recommendations.length>0?n.jsx(Hc,{recommendations:s.recommendations,emails:s.emails,payloadLinks:s.payload_links,isPremium:i}):i?n.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No recommendations available for this campaign"}):n.jsx("div",{className:"border rounded-md overflow-hidden",children:n.jsxs("button",{onClick:c,className:"relative flex items-center gap-3 py-4 px-4 w-full hover:bg-muted/50 transition-colors cursor-pointer isolate",children:[n.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[n.jsx("div",{className:"absolute top-1/2 right-1/4 -translate-y-1/2 w-32 h-32 bg-primary/20 rounded-full blur-2xl"}),n.jsx("div",{className:"absolute top-1/2 left-1/4 -translate-y-1/2 w-28 h-28 bg-chart-purple/20 rounded-full blur-2xl"}),n.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-48 h-16 bg-primary/15 rounded-full blur-3xl"})]}),n.jsx(wn,{className:"h-6 w-6 text-primary relative z-10 shrink-0"}),n.jsx("p",{className:"text-sm text-muted-foreground relative z-10",children:"Recommendations are available with Premium & Enterprise subscriptions."})]})})})]}),n.jsxs(ue,{className:"overflow-hidden",children:[n.jsxs(Ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(Ae,{children:"Results Distribution"}),n.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:async()=>{await ur(h,`results-distribution-${t}-${os()}.png`)?W.success("Chart downloaded"):W.error("Failed to download chart")},title:"Download as PNG",children:n.jsx(de,{className:"h-4 w-4"})})]}),n.jsx(he,{children:n.jsx("div",{ref:h,children:y?n.jsx(Ds,{data:l,emptyMessage:"No link activity yet"}):n.jsx(Ds,{emails:o??[],emptyMessage:"No email data"})})})]}),a&&a.length>1&&n.jsxs(ue,{className:"overflow-hidden",children:[n.jsxs(Ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(Ae,{children:"Historical View"}),n.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:async()=>{await ur(w,`historical-view-${t}-${os()}.png`)?W.success("Chart downloaded"):W.error("Failed to download chart")},title:"Download as PNG",children:n.jsx(de,{className:"h-4 w-4"})})]}),n.jsx(he,{children:n.jsx("div",{ref:w,children:n.jsx(Mc,{campaigns:a})})})]})]})}var nr={exports:{}},ii;function dm(){return ii||(ii=1,(function(e,t){(function(r){e.exports=r()})(function(r){var s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function i(p,m){var f=p[0],d=p[1],x=p[2],g=p[3];f+=(d&x|~d&g)+m[0]-680876936|0,f=(f<<7|f>>>25)+d|0,g+=(f&d|~f&x)+m[1]-389564586|0,g=(g<<12|g>>>20)+f|0,x+=(g&f|~g&d)+m[2]+606105819|0,x=(x<<17|x>>>15)+g|0,d+=(x&g|~x&f)+m[3]-1044525330|0,d=(d<<22|d>>>10)+x|0,f+=(d&x|~d&g)+m[4]-176418897|0,f=(f<<7|f>>>25)+d|0,g+=(f&d|~f&x)+m[5]+1200080426|0,g=(g<<12|g>>>20)+f|0,x+=(g&f|~g&d)+m[6]-1473231341|0,x=(x<<17|x>>>15)+g|0,d+=(x&g|~x&f)+m[7]-45705983|0,d=(d<<22|d>>>10)+x|0,f+=(d&x|~d&g)+m[8]+1770035416|0,f=(f<<7|f>>>25)+d|0,g+=(f&d|~f&x)+m[9]-1958414417|0,g=(g<<12|g>>>20)+f|0,x+=(g&f|~g&d)+m[10]-42063|0,x=(x<<17|x>>>15)+g|0,d+=(x&g|~x&f)+m[11]-1990404162|0,d=(d<<22|d>>>10)+x|0,f+=(d&x|~d&g)+m[12]+1804603682|0,f=(f<<7|f>>>25)+d|0,g+=(f&d|~f&x)+m[13]-40341101|0,g=(g<<12|g>>>20)+f|0,x+=(g&f|~g&d)+m[14]-1502002290|0,x=(x<<17|x>>>15)+g|0,d+=(x&g|~x&f)+m[15]+1236535329|0,d=(d<<22|d>>>10)+x|0,f+=(d&g|x&~g)+m[1]-165796510|0,f=(f<<5|f>>>27)+d|0,g+=(f&x|d&~x)+m[6]-1069501632|0,g=(g<<9|g>>>23)+f|0,x+=(g&d|f&~d)+m[11]+643717713|0,x=(x<<14|x>>>18)+g|0,d+=(x&f|g&~f)+m[0]-373897302|0,d=(d<<20|d>>>12)+x|0,f+=(d&g|x&~g)+m[5]-701558691|0,f=(f<<5|f>>>27)+d|0,g+=(f&x|d&~x)+m[10]+38016083|0,g=(g<<9|g>>>23)+f|0,x+=(g&d|f&~d)+m[15]-660478335|0,x=(x<<14|x>>>18)+g|0,d+=(x&f|g&~f)+m[4]-405537848|0,d=(d<<20|d>>>12)+x|0,f+=(d&g|x&~g)+m[9]+568446438|0,f=(f<<5|f>>>27)+d|0,g+=(f&x|d&~x)+m[14]-1019803690|0,g=(g<<9|g>>>23)+f|0,x+=(g&d|f&~d)+m[3]-187363961|0,x=(x<<14|x>>>18)+g|0,d+=(x&f|g&~f)+m[8]+1163531501|0,d=(d<<20|d>>>12)+x|0,f+=(d&g|x&~g)+m[13]-1444681467|0,f=(f<<5|f>>>27)+d|0,g+=(f&x|d&~x)+m[2]-51403784|0,g=(g<<9|g>>>23)+f|0,x+=(g&d|f&~d)+m[7]+1735328473|0,x=(x<<14|x>>>18)+g|0,d+=(x&f|g&~f)+m[12]-1926607734|0,d=(d<<20|d>>>12)+x|0,f+=(d^x^g)+m[5]-378558|0,f=(f<<4|f>>>28)+d|0,g+=(f^d^x)+m[8]-2022574463|0,g=(g<<11|g>>>21)+f|0,x+=(g^f^d)+m[11]+1839030562|0,x=(x<<16|x>>>16)+g|0,d+=(x^g^f)+m[14]-35309556|0,d=(d<<23|d>>>9)+x|0,f+=(d^x^g)+m[1]-1530992060|0,f=(f<<4|f>>>28)+d|0,g+=(f^d^x)+m[4]+1272893353|0,g=(g<<11|g>>>21)+f|0,x+=(g^f^d)+m[7]-155497632|0,x=(x<<16|x>>>16)+g|0,d+=(x^g^f)+m[10]-1094730640|0,d=(d<<23|d>>>9)+x|0,f+=(d^x^g)+m[13]+681279174|0,f=(f<<4|f>>>28)+d|0,g+=(f^d^x)+m[0]-358537222|0,g=(g<<11|g>>>21)+f|0,x+=(g^f^d)+m[3]-722521979|0,x=(x<<16|x>>>16)+g|0,d+=(x^g^f)+m[6]+76029189|0,d=(d<<23|d>>>9)+x|0,f+=(d^x^g)+m[9]-640364487|0,f=(f<<4|f>>>28)+d|0,g+=(f^d^x)+m[12]-421815835|0,g=(g<<11|g>>>21)+f|0,x+=(g^f^d)+m[15]+530742520|0,x=(x<<16|x>>>16)+g|0,d+=(x^g^f)+m[2]-995338651|0,d=(d<<23|d>>>
119)+x|0,f+=(x^(d|~g))+m[0]-198630844|0,f=(f<<6|f>>>26)+d|0,g+=(d^(f|~x))+m[7]+1126891415|0,g=(g<<10|g>>>22)+f|0,x+=(f^(g|~d))+m[14]-1416354905|0,x=(x<<15|x>>>17)+g|0,d+=(g^(x|~f))+m[5]-57434055|0,d=(d<<21|d>>>11)+x|0,f+=(x^(d|~g))+m[12]+1700485571|0,f=(f<<6|f>>>26)+d|0,g+=(d^(f|~x))+m[3]-1894986606|0,g=(g<<10|g>>>22)+f|0,x+=(f^(g|~d))+m[10]-1051523|0,x=(x<<15|x>>>17)+g|0,d+=(g^(x|~f))+m[1]-2054922799|0,d=(d<<21|d>>>11)+x|0,f+=(x^(d|~g))+m[8]+1873313359|0,f=(f<<6|f>>>26)+d|0,g+=(d^(f|~x))+m[15]-30611744|0,g=(g<<10|g>>>22)+f|0,x+=(f^(g|~d))+m[6]-1560198380|0,x=(x<<15|x>>>17)+g|0,d+=(g^(x|~f))+m[13]+1309151649|0,d=(d<<21|d>>>11)+x|0,f+=(x^(d|~g))+m[4]-145523070|0,f=(f<<6|f>>>26)+d|0,g+=(d^(f|~x))+m[11]-1120210379|0,g=(g<<10|g>>>22)+f|0,x+=(f^(g|~d))+m[2]+718787259|0,x=(x<<15|x>>>17)+g|0,d+=(g^(x|~f))+m[9]-343485551|0,d=(d<<21|d>>>11)+x|0,p[0]=f+p[0]|0,p[1]=d+p[1]|0,p[2]=x+p[2]|0,p[3]=g+p[3]|0}function a(p){var m=[],f;for(f=0;f<64;f+=4)m[f>>2]=p.charCodeAt(f)+(p.charCodeAt(f+1)<<8)+(p.charCodeAt(f+2)<<16)+(p.charCodeAt(f+3)<<24);return m}function o(p){var m=[],f;for(f=0;f<64;f+=4)m[f>>2]=p[f]+(p[f+1]<<8)+(p[f+2]<<16)+(p[f+3]<<24);return m}function l(p){var m=p.length,f=[1732584193,-271733879,-1732584194,271733878],d,x,g,M,P,q;for(d=64;d<=m;d+=64)i(f,a(p.substring(d-64,d)));for(p=p.substring(d-64),x=p.length,g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d=0;d<x;d+=1)g[d>>2]|=p.charCodeAt(d)<<(d%4<<3);if(g[d>>2]|=128<<(d%4<<3),d>55)for(i(f,g),d=0;d<16;d+=1)g[d]=0;return M=m*8,M=M.toString(16).match(/(.*?)(.{0,8})$/),P=parseInt(M[2],16),q=parseInt(M[1],16)||0,g[14]=P,g[15]=q,i(f,g),f}function u(p){var m=p.length,f=[1732584193,-271733879,-1732584194,271733878],d,x,g,M,P,q;for(d=64;d<=m;d+=64)i(f,o(p.subarray(d-64,d)));for(p=d-64<m?p.subarray(d-64):new Uint8Array(0),x=p.length,g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d=0;d<x;d+=1)g[d>>2]|=p[d]<<(d%4<<3);if(g[d>>2]|=128<<(d%4<<3),d>55)for(i(f,g),d=0;d<16;d+=1)g[d]=0;return M=m*8,M=M.toString(16).match(/(.*?)(.{0,8})$/),P=parseInt(M[2],16),q=parseInt(M[1],16)||0,g[14]=P,g[15]=q,i(f,g),f}function c(p){var m="",f;for(f=0;f<4;f+=1)m+=s[p>>f*8+4&15]+s[p>>f*8&15];return m}function h(p){var m;for(m=0;m<p.length;m+=1)p[m]=c(p[m]);return p.join("")}h(l("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function p(m,f){return m=m|0||0,m<0?Math.max(m+f,0):Math.min(m,f)}ArrayBuffer.prototype.slice=function(m,f){var d=this.byteLength,x=p(m,d),g=d,M,P,q,k;return f!==r&&(g=p(f,d)),x>g?new ArrayBuffer(0):(M=g-x,P=new ArrayBuffer(M),q=new Uint8Array(P),k=new Uint8Array(this,x,M),q.set(k),P)}})();function w(p){return/[\u0080-\uFFFF]/.test(p)&&(p=unescape(encodeURIComponent(p))),p}function y(p,m){var f=p.length,d=new ArrayBuffer(f),x=new Uint8Array(d),g;for(g=0;g<f;g+=1)x[g]=p.charCodeAt(g);return m?x:d}function v(p){return String.fromCharCode.apply(null,new Uint8Array(p))}function S(p,m,f){var d=new Uint8Array(p.byteLength+m.byteLength);return d.set(new Uint8Array(p)),d.set(new Uint8Array(m),p.byteLength),d}function j(p){var m=[],f=p.length,d;for(d=0;d<f-1;d+=2)m.push(parseInt(p.substr(d,2),16));return String.fromCharCode.apply(String,m)}function b(){this.reset()}return b.prototype.append=function(p){return this.appendBinary(w(p)),this},b.prototype.appendBinary=function(p){this._buff+=p,this._length+=p.length;var m=this._buff.length,f;for(f=64;f<=m;f+=64)i(this._hash,a(this._buff.substring(f-64,f)));return this._buff=this._buff.substring(f-64),this},b.prototype.end=function(p){var m=this._buff,f=m.length,d,x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],g;for(d=0;d<f;d+=1)x[d>>2]|=m.charCodeAt(d)<<(d%4<<3);return this._finish(x,f),g=h(this._hash),p&&(g=j(g)),this.reset(),g},b.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},b.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},b.prototype.setState=function(p){return this._buff=p.buff,this._length=p.length,this._hash=p.hash,this},b.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},b.prototype._finish=function(p,m){var f=m,d,x,g;if(p[f>>2]|=128<<(f%4<<3),f>55)for(i(this._hash,p),f=0;f<16;f+=1)p[f]=0;d=this._length*8,d=d.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(d[2],16),g=parseInt(d[1],16)||0,p[14]=x,p[15]=g,i(this._hash,p)},b.hash=function(p,m){return b.hashBinary(w(p),m)},b.hashBinary=function(p,m){var f=l(p),d=h(f);return m?j(d):d},b.ArrayBuffer=function(){this.reset()},b.ArrayBuffer.prototype.append=function(p){var m=S(this._buff.buffer,p),f=m.length,d;for(this._length+=p.byteLength,d=64;d<=f;d+=64)i(this._hash,o(m.subarray(d-64,d)));return this._buff=d-64<f?new Uint8Array(m.buffer.slice(d-64)):new Uint8Array(0),this},b.ArrayBuffer.prototype.end=function(p){var m=this._buff,f=m.length,d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],x,g;for(x=0;x<f;x+=1)d[x>>
112]|=m[x]<<(x%4<<3);return this._finish(d,f),g=h(this._hash),p&&(g=j(g)),this.reset(),g},b.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},b.ArrayBuffer.prototype.getState=function(){var p=b.prototype.getState.call(this);return p.buff=v(p.buff),p},b.ArrayBuffer.prototype.setState=function(p){return p.buff=y(p.buff,!0),b.prototype.setState.call(this,p)},b.ArrayBuffer.prototype.destroy=b.prototype.destroy,b.ArrayBuffer.prototype._finish=b.prototype._finish,b.ArrayBuffer.hash=function(p,m){var f=u(new Uint8Array(p)),d=h(f);return m?j(d):d},b})})(nr)),nr.exports}var um=dm();const hm=_r(um);async function rr(e){return new Promise((t,r)=>{const i=new hm.ArrayBuffer,a=new FileReader,o=Math.ceil(e.size/2097152);let l=0;a.onload=c=>{c.target?.result&&i.append(c.target.result),l++,l<o?u():t(i.end())},a.onerror=()=>{r(new Error("Error reading file for MD5 hash"))};function u(){const c=l*2097152,h=Math.min(c+2097152,e.size),w=e.slice(c,h);a.readAsArrayBuffer(w)}u()})}const sr=()=>typeof window<"u"&&"showDirectoryPicker"in window,ir=()=>typeof window<"u"&&"FileSystemObserver"in window,fm="delivrto-download-monitor",mm=1,ot="handles",Jr="downloads-directory";async function Yr(){return new Promise((e,t)=>{const r=indexedDB.open(fm,mm);r.onerror=()=>t(r.error),r.onsuccess=()=>e(r.result),r.onupgradeneeded=s=>{const i=s.target.result;i.objectStoreNames.contains(ot)||i.createObjectStore(ot)}})}async function pm(e){try{const t=await Yr(),r=t.transaction(ot,"readwrite");r.objectStore(ot).put(e,Jr),await new Promise((i,a)=>{r.oncomplete=()=>i(),r.onerror=()=>a(r.error)}),t.close()}catch(t){console.error("[DownloadMonitor] Failed to store handle:",t)}}async function ai(){try{const e=await Yr(),s=e.transaction(ot,"readonly").objectStore(ot).get(Jr);return new Promise(i=>{s.onsuccess=()=>{e.close(),i(s.result||null)},s.onerror=()=>{e.close(),i(null)}})}catch(e){return console.error("[DownloadMonitor] Failed to retrieve handle:",e),null}}async function fn(){try{const e=await Yr(),t=e.transaction(ot,"readwrite");t.objectStore(ot).delete(Jr),await new Promise((s,i)=>{t.oncomplete=()=>s(),t.onerror=()=>i(t.error)}),e.close()}catch(e){console.error("[DownloadMonitor] Failed to clear handle:",e)}}async function ft(e,t,r,s){if(!s?.aborted)try{console.log(`[DownloadMonitor] Reporting ${t} for ${e}`),await Pa.post(`/links/${e}/status`,{status:t,filename:r.filename,hash:r.hash,timestamp:r.timestamp,possibleReason:r.possibleReason},{signal:s})}catch(i){if(s?.aborted)return;console.error("Failed to report download status:",i)}}function xm(e){const[t,r]=E.useState({status:"idle",directoryHandle:null,monitoredDownloads:new Map,observerSupported:ir()}),s=E.useRef(e),i=E.useRef(null),a=E.useRef(null),o=E.useRef(new Set),l=E.useRef(!1),u=E.useRef(null);E.useEffect(()=>{s.current=e},[e]);const c=E.useRef(new Map),h=E.useRef(new Set),w=E.useRef(new Map);E.useEffect(()=>{if(l.current||!sr())return;l.current=!0,(async()=>{const N=await ai();if(N)try{await N.queryPermission({mode:"readwrite"})==="granted"?(console.log("[DownloadMonitor] Auto-restored monitoring from stored handle"),r(I=>({...I,status:"monitoring",directoryHandle:N}))):console.log("[DownloadMonitor] Stored handle exists but permission not granted")}catch(O){console.log("[DownloadMonitor] Stored handle no longer valid:",O),await fn()}})()},[]);const y=E.useCallback(k=>{r(N=>({...N,status:"monitoring",directoryHandle:k}))},[]),v=E.useCallback(async()=>{if(!sr())return r(k=>({...k,status:"unsupported"})),!1;r(k=>({...k,status:"requesting"}));try{const k=await ai();if(k)try{if(await k.queryPermission({mode:"readwrite"})==="granted")return console.log("[DownloadMonitor] Restored permission from stored handle"),y(k),!0;if(await k.requestPermission({mode:"readwrite"})==="granted")return console.log("[DownloadMonitor] Re-granted permission for stored handle"),y(k),!0}catch(O){console.log("[DownloadMonitor] Stored handle no longer valid:",O),await fn()}const N=await window.showDirectoryPicker({id:"delivrto-download-monitor",mode:"readwrite",startIn:"downloads"});return await pm(N),console.log("[DownloadMonitor] Stored new directory handle"),y(N),!0}catch(k){return k.name==="AbortError"?r(O=>({...O,status:"denied"})):(console.error("Error requesting directory access:",k),r(O=>({...O,status:"idle"}))),!1}},[y]),S=k=>{const N=k.toLowerCase();return N.endsWith(".tmp")||N.endsWith(".crdownload")||N.endsWith(".partial")||N.endsWith(".download")||N.startsWith(".com.google.")||N.startsWith(".")},j=async(k,N,O=1e4,I=500)=>{let _=-1,T=0;const C=Date.now();for(;Date.now()-C<O&&!N.aborted;)try{const R=await k.getFile();if(R.size===_&&R.size>0){if(T++,T>=3)return R}else T=0,_=R.size;await new Promise(D=>setTimeout(D,I))}catch{return null}if(N.aborted)return null;try{return await k.getFile()}catch{return null}},b=E.useCallback(async(k,N)=>{if(N.aborted)return;const O=c.current.get(k.name);if(!(O&&!O.aborted)){c.current.set(k.name,N);try{if(N.aborted)return;if(S(k.name)){console.log(`[DownloadMonitor] Temporary file detected: ${k.name}`);return}console.log(`[DownloadMonitor] New file detected: ${k.name}`);const I=w.current;if(I.size>0){for(const[R,D]of I)clearTimeout(D.timeoutId),console.log(`[DownloadMonitor] Correlating ${k.name} with temp file ${R}`);I.clear()}if(h.current.has(k.name)){h.current.delete(k.name);return}console.log(`[DownloadMonitor] Waiting for download to complete: ${k.name}`);const _=await j(k,N);if(N.aborted)return;if(!_){const R=s.current.find(D=>D.filename.toLowerCase()===k.name.toLowerCase());R?(console.log(`[DownloadMonitor] File deleted before verification (AV): ${k.name} → matched expected payload ${R.filename}`),r(D=>{if(N.aborted)return D;const A=new Map(D.monitoredDownloads);
11return A.set(R.linkId,{linkId:R.linkId,payloadId:R.payloadId,expectedHash:R.hash,expectedFilename:R.filename,status:"deleted",detectedFilename:k.name,detectedAt:Date.now(),deletedAt:Date.now(),possibleReason:"antivirus_quarantine"}),{...D,monitoredDownloads:A}}),await ft(R.linkId,"deleted",{filename:k.name,timestamp:Date.now(),possibleReason:"antivirus_quarantine"},N)):console.log(`[DownloadMonitor] File was deleted before processing: ${k.name}`);return}if(_.size>500*1024*1024){console.warn(`[DownloadMonitor] Skipping large file: ${_.name} (${_.size} bytes)`);return}if(_.size<1024&&_.type==="application/json")try{const R=await _.text();if(JSON.parse(R).message==="Link expired."){console.log(`[DownloadMonitor] Failed payload: ${_.name} - Link expired`);return}}catch{}if(N.aborted)return;const T=await rr(_);if(N.aborted)return;console.log(`[DownloadMonitor] File detected: ${_.name}, hash: ${T}`);const C=s.current.find(R=>R.hash.toLowerCase()===T.toLowerCase());C?(console.log(`[DownloadMonitor] Verified download: ${_.name} matches ${C.filename}`),r(R=>{if(N.aborted)return R;const D=new Map(R.monitoredDownloads);return D.set(C.linkId,{linkId:C.linkId,payloadId:C.payloadId,expectedHash:C.hash,expectedFilename:C.filename,status:"verified",detectedFilename:_.name,detectedHash:T,detectedAt:Date.now(),verifiedAt:Date.now()}),{...R,monitoredDownloads:D}}),await ft(C.linkId,"verified",{filename:_.name,hash:T,timestamp:Date.now()},N)):console.log(`[DownloadMonitor] No match found for ${_.name} (hash: ${T})`)}catch(I){if(N.aborted)return;console.error("[DownloadMonitor] Error processing file:",I)}finally{c.current.get(k.name)===N&&c.current.delete(k.name)}}},[]),p=E.useCallback(async(k,N,O)=>{if(!N.aborted){if(S(k)){console.log(`[DownloadMonitor] Temporary file disappeared: ${k} - waiting for rename...`);const I=window.setTimeout(()=>{if(w.current.get(k)?.signal===N){if(w.current.delete(k),N.aborted)return;console.log(`[DownloadMonitor] Temp file ${k} was not renamed - possible AV block during download`)}},5e3);w.current.set(k,{disappearedAt:Date.now(),size:O||0,timeoutId:I,signal:N});return}r(I=>{if(N.aborted)return I;const _=new Map(I.monitoredDownloads);let T=!1;for(const[C,R]of _)R.detectedFilename===k&&R.status==="verified"&&(console.log(`[DownloadMonitor] File deleted (possible AV): ${k}`),_.set(C,{...R,status:"deleted",deletedAt:Date.now(),possibleReason:"antivirus_quarantine"}),T=!0,ft(C,"deleted",{filename:k,timestamp:Date.now(),possibleReason:"antivirus_quarantine"},N));return T?{...I,monitoredDownloads:_}:I})}},[]),m=E.useCallback(async(k,N)=>{if(N.aborted||!ir()||!window.FileSystemObserver)return!1;let O=null;try{return O=new window.FileSystemObserver(async I=>{if(N.aborted)return;console.log(`[DownloadMonitor] Observer received ${I.length} record(s)`);const _=I.map(async T=>{if(N.aborted)return;if(T.type==="disappeared"){const D=T.relativePathComponents?.length?T.relativePathComponents[T.relativePathComponents.length-1]:T.changedHandle?.name;if(!D)return;console.log(`[DownloadMonitor] Event: disappeared, file: ${D}`),await p(D,N);return}if(!T.changedHandle||T.changedHandle.kind!=="file")return;const C=T.changedHandle.name,R=S(C);T.type==="appeared"&&(R?console.log(`[DownloadMonitor] Temporary file detected: ${C}`):await b(T.changedHandle,N)),T.type==="moved"&&(R||(console.log(`[DownloadMonitor] File renamed to final name: ${C}`),await b(T.changedHandle,N))),T.type==="modified"&&(R||await b(T.changedHandle,N))});await Promise.allSettled(_)}),i.current=O,await O.observe(k,{recursive:!1}),N.aborted?(O.disconnect(),i.current===O&&(i.current=null),!1):(console.log("[DownloadMonitor] Started FileSystemObserver"),!0)}catch(I){return O?.disconnect(),i.current===O&&(i.current=null),N.aborted||console.error("[DownloadMonitor] Failed to start observer:",I),!1}},[b,p]),f=E.useCallback(async(k,N)=>{if(N.aborted)return;o.current.clear();try{for await(const I of k.values()){if(N.aborted)return;I.kind==="file"&&o.current.add(I.name)}}catch(I){if(N.aborted)return;console.error("[DownloadMonitor] Error during initial scan:",I)}const O=async()=>
11{if(!N.aborted)try{const I=new Set,_=[];for await(const C of k.values()){if(N.aborted)return;C.kind==="file"&&(I.add(C.name),o.current.has(C.name)||_.push(C))}if(_.length>0&&await Promise.allSettled(_.map(C=>b(C,N))),N.aborted)return;const T=[...o.current].filter(C=>!I.has(C));if(T.length>0&&await Promise.allSettled(T.map(C=>p(C,N))),N.aborted)return;o.current=I}catch(I){if(N.aborted)return;console.error("[DownloadMonitor] Polling error:",I)}};N.aborted||(a.current=window.setInterval(O,2e3),console.log("[DownloadMonitor] Started polling fallback"))},[b,p]);E.useEffect(()=>{if(t.status!=="monitoring"||!t.directoryHandle)return;const k=new AbortController;u.current?.abort(),u.current=k;const N=t.directoryHandle;return(async()=>ir()?!await m(N,k.signal)&&!k.signal.aborted&&await f(N,k.signal):await f(N,k.signal))(),()=>{k.abort(),u.current===k&&(u.current=null),i.current?.disconnect(),i.current=null,a.current&&(clearInterval(a.current),a.current=null)}},[t.status,t.directoryHandle,m,f]);const d=E.useCallback(()=>{u.current?.abort(),u.current=null,i.current?.disconnect(),i.current=null,a.current&&(clearInterval(a.current),a.current=null);for(const k of w.current.values())clearTimeout(k.timeoutId);w.current.clear(),o.current.clear(),c.current.clear(),h.current.clear(),fn(),r(k=>({...k,status:"idle",directoryHandle:null})),console.log("[DownloadMonitor] Stopped monitoring")},[]),x=E.useCallback(async()=>(u.current?.abort(),u.current=null,i.current?.disconnect(),i.current=null,a.current&&(clearInterval(a.current),a.current=null),o.current.clear(),await fn(),r(k=>({...k,status:"idle",directoryHandle:null})),v()),[v]),g=E.useCallback(k=>{r(N=>{const O=new Map(N.monitoredDownloads);return O.delete(k),{...N,monitoredDownloads:O}})},[]),M=E.useCallback(async(k,N)=>{const O=s.current.find(I=>I.filename.toLowerCase()===k.toLowerCase());O&&await ft(O.linkId,"verified",{filename:k,timestamp:Date.now(),possibleReason:"download_complete"},N)},[]),P=E.useCallback(async(k,N)=>{const O=s.current.find(I=>I.filename.toLowerCase()===N.toLowerCase());if(O)try{const I=new File([k],N),_=await rr(I);_.toLowerCase()===O.hash.toLowerCase()?(console.log(`[DownloadMonitor] Download verified (cross-browser): ${N}`),await ft(O.linkId,"verified",{filename:N,hash:_,timestamp:Date.now(),possibleReason:"download_complete"})):console.log(`[DownloadMonitor] Inline hash mismatch (cross-browser): ${N} (expected: ${O.hash}, got: ${_})`)}catch(I){console.error(`[DownloadMonitor] Inline blob hash failed for ${N}:`,I)}},[]),q=E.useCallback(async(k,N)=>{const O=u.current?.signal;if(!t.directoryHandle||!O||O.aborted)return!1;try{const _=await(await t.directoryHandle.getFileHandle(N,{create:!0})).createWritable();if(await _.write(k),await _.close(),O.aborted||(h.current.add(N),console.log(`[DownloadMonitor] Saved ${N} to monitored directory`),await M(N,O),O.aborted))return!0;try{const T=new File([k],N),C=await rr(T);if(O.aborted)return!0;const R=s.current.find(D=>D.hash.toLowerCase()===C.toLowerCase());R?(console.log(`[DownloadMonitor] Inline verified: ${N} matches ${R.filename}`),r(D=>{if(O.aborted)return D;const A=new Map(D.monitoredDownloads);return A.set(R.linkId,{linkId:R.linkId,payloadId:R.payloadId,expectedHash:R.hash,expectedFilename:R.filename,status:"verified",detectedFilename:N,detectedHash:C,detectedAt:Date.now(),verifiedAt:Date.now()}),{...D,monitoredDownloads:A}}),await ft(R.linkId,"verified",{filename:N,hash:C,timestamp:Date.now(),possibleReason:"file_verified"},O)):console.log(`[DownloadMonitor] Inline hash mismatch for ${N} (hash: ${C})`)}catch(T){console.error(`[DownloadMonitor] Inline hash failed for ${N}:`,T)}return!0}catch(I){if(O.aborted)return!0;const _=I;if(_.name==="AbortError"&&_.message?.includes("Safe Browsing")||_.name==="TypeError"&&_.message?.includes("Name is not allowed")){console.log(`[DownloadMonitor] Blocked by Safe Browsing: ${N}`);const C=s.current.find(R=>R.filename.toLowerCase()===N.toLowerCase());if(C){if(await M(N,O),O.aborted)return!0;r(R=>{if(O.aborted)return R;const D=new Map(R.monitoredDownloads);return D.set(C.linkId,{linkId:C.linkId,payloadId:C.payloadId,expectedHash:C.hash,expectedFilename:C.filename,status:"hash_mismatch",detectedFilename:N,detectedAt:Date.now(),possibleReason:"safe_browsing_block"}),{...R,monitoredDownloads:D}}),await ft(C.linkId,"hash_mismatch",{filename:N,timestamp:Date.now(),possibleReason:"safe_browsing_block"},O)}return!0}return console.error(`[DownloadMonitor] Failed to save ${N} to directory:`,I),!1}}
11,[t.directoryHandle,M]);return{...t,requestPermission:v,stopMonitoring:d,changeDirectory:x,clearDownload:g,saveToDirectory:q,reportDownloadComplete:M,verifyBlobInline:P,isSupported:sr()}}const oi={Pending:{bg:"#EDEDED",text:"#374151",darkText:"#374151"},Sent:{bg:"#3FCBFF",text:"#ffffff",darkText:"#0c4a5e"},Delivered:{bg:"#4CDBC4",text:"#ffffff",darkText:"#134e45"},Rewritten:{bg:"#4CDBC4",text:"#ffffff",darkText:"#134e45"},"Junk (Delivered)":{bg:"#4CDBC4",text:"#ffffff",darkText:"#134e45"},"Junk (Rewritten)":{bg:"#4CDBC4",text:"#ffffff",darkText:"#134e45"},Stripped:{bg:"#FFD15D",text:"#ffffff",darkText:"#713f12"},Held:{bg:"#FFD15D",text:"#ffffff",darkText:"#713f12"},"Junk (Stripped)":{bg:"#FFD15D",text:"#ffffff",darkText:"#713f12"},"Junk (Held)":{bg:"#FFD15D",text:"#ffffff",darkText:"#713f12"},Failed:{bg:"#FE7058",text:"#ffffff",darkText:"#7f1d1d"},Error:{bg:"#FE7058",text:"#ffffff",darkText:"#7f1d1d"},"Blocked (Dropped)":{bg:"#FFAE5D",text:"#ffffff",darkText:"#7c2d12"},"Blocked (Bounced)":{bg:"#FFAE5D",text:"#ffffff",darkText:"#7c2d12"},"Blocked (Trashed)":{bg:"#FFAE5D",text:"#ffffff",darkText:"#7c2d12"}},li={Pending:{label:"Pending",className:"bg-muted text-muted-foreground hover:bg-muted/80"},Scheduled:{label:"Scheduled",className:"bg-[#EDEDED] text-gray-700 hover:bg-[#DCDCDC] dark:bg-gray-700 dark:text-gray-200 dark:hover:bg-gray-600"},Running:{label:"Running",className:"bg-[#EDEDED] text-gray-700 hover:bg-[#DCDCDC] dark:bg-gray-700 dark:text-gray-200 dark:hover:bg-gray-600"},Sending:{label:"Sending",className:"bg-[#EDEDED] text-gray-700 hover:bg-[#DCDCDC] dark:bg-gray-700 dark:text-gray-200 dark:hover:bg-gray-600"},Active:{label:"Active",className:"bg-[#3FCBFF] text-white hover:bg-[#2BB8EC] dark:text-[#0c4a5e]"},Completed:{label:"Completed",className:"bg-[#4CDBC4] text-white hover:bg-[#3BC5B5] dark:text-[#134e45]"},Failed:{label:"Failed",className:"bg-[#FE7058] text-white hover:bg-[#E5614A] dark:text-[#7f1d1d]"},Error:{label:"Error",className:"bg-[#FE7058] text-[#7f1d1d] hover:bg-[#E5614A]"},Cancelled:{label:"Cancelled",className:"bg-gray-300 text-gray-700 hover:bg-gray-400 dark:bg-gray-600 dark:text-gray-200 dark:hover:bg-gray-500"}};function gm(e){const t=typeof e=="string"?parseInt(e,10):e;return new Date(t*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"})}function ym(e){let t=0,r=0,s=0;for(const i of e){const a=i.status;a==="Delivered"||a==="Rewritten"||a==="Junk (Delivered)"||a==="Junk (Rewritten)"?r++:a==="Blocked (Dropped)"||a==="Blocked (Bounced)"||a==="Blocked (Trashed)"||a==="Stripped"||a==="Held"||a==="Junk (Stripped)"||a==="Junk (Held)"?s++:(a==="Sent"||a==="Pending")&&t++}return{sent:t,delivered:r,blocked:s}}function vm({status:e}){const{label:t,className:r}=li[e]||li.Pending;return n.jsx(De,{className:r,children:t})}function wm({ownership:e}){return e==="user"?n.jsx("span",{title:"Owned by You",children:n.jsx(La,{className:"h-4 w-4 text-muted-foreground/50"})}):n.jsx("span",{title:"Team Owned",children:n.jsx(Ba,{className:"h-4 w-4 text-muted-foreground/50"})})}function bm({integrations:e}){if(!e)return null;const t=[...e.senders||[],...e.mailboxes||[],...e.mail_controls||[]];return t.length===0?null:n.jsx("div",{className:"flex items-center gap-1",children:t.map((r,s)=>{const i=r.integration_status==="complete";return n.jsx("div",{className:i?"":"opacity-30 grayscale",title:`${r.integration_type}${i?"":" (pending)"}`,children:n.jsx(at,{service:r.integration_type,size:20})},s)})})}function jm({emails:e}){const t=e.some(s=>s.mail_type==="as_link"),r=e.some(s=>s.mail_type==="as_attachment");return n.jsxs("div",{className:"flex items-center gap-1",children:[t&&n.jsx("span",{title:"Link delivery",children:n.jsx(fi,{className:"h-4 w-4 text-muted-foreground"})}),r&&n.jsx("span",{title:"Attachment delivery",children:n.jsx(ki,{className:"h-4 w-4 text-muted-foreground"})})]})}function _m({campaign:e,relatedCampaigns:t}){const{repeat_days:r,repeat_for:s}=e;if(!r||r<=0)return null;let i;if(t&&t.length>0){const h=[...t].sort((y,v)=>{const S=parseInt(y.requested_start_time,10)||0;return(parseInt(v.requested_start_time,10)||0)-S})[0];i=(parseInt(String(h.repeat_for),10)||0)>0}else i=(s??0)>0;
11const a=s??0,o=a===-1,l=r%7===0?`${r/7}w`:`${r}d`,u=i?`Active Automated Campaign - Every ${r} day${r>1?"s":""}${o?" (indefinitely)":` (${a} remaining)`}`:`Completed Automated Campaign - Ran every ${r} day${r>1?"s":""}`;return n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsxs("span",{className:_e("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",i?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:[n.jsx(hi,{className:_e("h-3 w-3",!i&&"opacity-50")}),n.jsx("span",{children:l})]})}),n.jsx(ae,{children:n.jsx("p",{children:u})})]})}function Nm({sent:e,delivered:t,blocked:r}){return n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"h-3 w-3 rounded-full bg-primary"}),e]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"h-3 w-3 rounded-full bg-success"}),t]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"h-3 w-3 rounded-full bg-status-blocked"}),r]})]})}function km({campaign:e,relatedCampaigns:t,autoRefresh:r,onAutoRefreshChange:s,isPremium:i,onRerunIntegrations:a,isRerunningIntegrations:o,onCompleteCampaign:l,isCompletingCampaign:u,onExtendCampaign:c,isExtendingCampaign:h,onDownloadAll:w,onDownloadRemaining:y,remainingCount:v,isDownloadingAll:S,monitoredDownloads:j}){const b=e.campaign_type==="web",[p,m]=E.useState({open:!1,mode:"all"}),f=E.useMemo(()=>ym(e.emails||[]),[e.emails]),d=e.integrations_running??!1,x=!!(e.integrations?.senders?.length||e.integrations?.mailboxes?.length||e.integrations?.mail_controls?.length||e.integrations?.browser_security?.length),g=!d&&x&&i&&(e.status==="Completed"||b&&e.status==="Active"),M=E.useMemo(()=>{if(!b||!e.payload_links)return null;const k=e.payload_links,N=k.length,O=k.filter(_=>{if(_.click_count>0)return!0;const T=j?.get(_.link_id);return T&&(T.status==="verified"||T.status==="deleted")}).length,I=k.reduce((_,T)=>_+T.click_count,0);return{totalLinks:N,accessedLinks:O,totalAccesses:I}},[b,e.payload_links,j]),P=E.useMemo(()=>{if(!b||!e.payload_links)return[];const k=Math.floor(Date.now()/1e3);return e.payload_links.filter(N=>{const O=N.payload_name.split(".").pop()?.toLowerCase()||"",I=O==="html"||O==="htm",_=N.expiry_epoch>k;return I&&_})},[b,e.payload_links]),q=()=>{if(P.length===0)return;let k=0,N=0;for(const O of P)window.open(O.link_url,"_blank","noopener,noreferrer")?k+=1:N+=1;N>0?W.warning(`Opened ${k} of ${P.length} link${P.length!==1?"s":""}. Allow pop-ups for this site to open the rest.`):k>0&&W.success(`Opened ${k} HTML link${k!==1?"s":""} in new tabs`)};return n.jsxs(ue,{children:[n.jsx(Ce,{className:"pb-3",children:n.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[n.jsxs("div",{className:"space-y-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(wm,{ownership:e.ownership}),b&&n.jsx(dr,{className:"h-5 w-5 text-primary"}),n.jsx(Ae,{className:"text-xl sm:text-2xl break-words",children:e.campaign_name}),b&&n.jsx(De,{variant:"outline",className:"text-xs",children:"Web Test"}),!b&&n.jsx(_m,{campaign:e,relatedCampaigns:t})]}),n.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-4 text-sm text-muted-foreground",children:[!b&&n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(Fn,{className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate",children:e.recipient})]}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(lr,{className:"h-4 w-4 shrink-0"}),n.jsx("span",{children:gm(e.requested_start_time)})]})]})]}),n.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 shrink-0",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(qa,{id:"auto-refresh",checked:r,onCheckedChange:s}),n.jsx(Ar,{htmlFor:"auto-refresh",className:"text-sm text-muted-foreground",children:"Auto-refresh"})]}),n.jsx(vm,{status:e.status})]})]})}),n.jsx(he,{children:n.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:flex-wrap sm:items-center sm:gap-6",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Template:"}),n.jsx(ar,{to:`/app/templates?template=${e.template_id}`,className:"text-sm text-primary hover:underline",children:e.template_name}),!b&&n.jsx(jm,{emails:e.emails||[]})]}),b&&M&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Links:"}),n.jsxs("span",{className:"text-sm",children:[M.accessedLinks,"/",M.totalLinks," accessed",M.totalAccesses>0&&n.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",M.totalAccesses," total downloads)"]})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Integrations:"}),x?n.jsxs(n.Fragment,{children:[n.jsx(bm,{integrations:e.integrations}),d?n.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[n.jsx(ts,{className:"h-4 w-4 animate-spin"}),n.jsx("span",{children:"Collecting..."})]}):g?n.jsxs(G,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:a,disabled:o,children:[o?n.jsx(ts,{className:"h-3.5 w-3.5 animate-spin mr-1"}):n.jsx(hi,{className:"h-3.5 w-3.5 mr-1"}),b?"Collect Results":"Rerun Integrations"]}):null]}
11):n.jsx("span",{className:"text-sm text-muted-foreground/60",children:"None"})]}),!b&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Results:"}),n.jsx(Nm,{...f})]}),b&&(e.status==="Active"||e.status==="Completed")&&n.jsxs("div",{className:"flex items-center gap-2",children:[c&&n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsxs(G,{variant:"outline",size:"sm",onClick:c,disabled:h,children:[n.jsx(Pi,{className:"h-4 w-4 mr-2"}),h?"Resetting...":"Reset Link Expiry"]})}),n.jsx(ae,{children:"Set a new expiry time for all download links in this campaign"})]}),e.status==="Active"&&l&&n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsxs(G,{variant:"outline",size:"sm",onClick:l,disabled:u,children:[n.jsx(To,{className:"h-4 w-4 mr-2"}),u?"Completing...":"Mark Complete"]})}),n.jsx(ae,{children:"End this campaign and expire all remaining download links"})]}),P.length>0&&n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsxs(G,{variant:"outline",size:"sm",onClick:q,children:[n.jsx($n,{className:"h-4 w-4 mr-2"}),"Open All (",P.length,")"]})}),n.jsxs(ae,{children:["Open all ",P.length," HTML link",P.length!==1?"s":""," in new tabs"]})]}),w&&n.jsxs("div",{className:"flex items-center",children:[n.jsxs(se,{children:[n.jsx(ie,{asChild:!0,children:n.jsxs(G,{size:"sm",className:v!==void 0&&v>0&&v<(e.payload_links?.length??0)?"rounded-r-none":"",onClick:()=>{const k=v!==void 0&&v>0&&v<(e.payload_links?.length??0);m({open:!0,mode:k?"remaining":"all"})},disabled:S||e.status==="Completed",children:[n.jsx(de,{className:"h-4 w-4 mr-2"}),S?"Downloading...":v!==void 0&&v>0&&v<(e.payload_links?.length??0)?`Download Remaining (${v})`:"Download All"]})}),n.jsx(ae,{children:v!==void 0&&v>0&&v<(e.payload_links?.length??0)?`Download ${v} payload${v!==1?"s":""} not yet fetched`:"Download all payloads in this campaign"})]}),v!==void 0&&v>0&&v<(e.payload_links?.length??0)&&n.jsxs(wt,{children:[n.jsx(bt,{asChild:!0,children:n.jsx(G,{size:"sm",className:"rounded-l-none border-l border-primary-foreground/20 px-2",disabled:S||e.status==="Completed",children:n.jsx(za,{className:"h-3.5 w-3.5"})})}),n.jsx(jt,{align:"end",children:n.jsxs(xe,{onClick:()=>m({open:!0,mode:"all"}),children:[n.jsx(de,{className:"h-4 w-4 mr-2"}),"Download All (",e.payload_links?.length??0,")"]})})]})]})]})]})}),n.jsx($e,{open:p.open,onOpenChange:k=>m(N=>({...N,open:k})),children:n.jsxs(ze,{className:"sm:max-w-md",children:[n.jsxs(Le,{children:[n.jsxs(Be,{className:"flex items-center gap-2",children:[n.jsx(de,{className:"h-5 w-5"}),p.mode==="remaining"?"Download Remaining Payloads?":"Download All Payloads?"]}),n.jsx(qe,{children:p.mode==="remaining"?`This will download ${v} payload${v!==1?"s":""} that have not yet been fetched.`:`This will download ${e.payload_links?.length??0} payload${(e.payload_links?.length??0)!==1?"s":""} to test your web security controls.`})]}),b&&n.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border bg-muted/50 px-3 py-2.5",children:[n.jsx(Ve,{className:"h-4 w-4 text-muted-foreground mt-0.5 shrink-0"}),n.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Ensure Download Monitoring is configured and enabled before continuing, for automated results collection."})]}),n.jsxs(Cr,{className:"gap-2 sm:gap-0",children:[n.jsx(G,{variant:"outline",onClick:()=>m({open:!1,mode:"all"}),children:"Cancel"}),n.jsxs(G,{onClick:()=>{m({open:!1,mode:"all"}),p.mode==="remaining"?y?.():w?.()},children:[n.jsx(de,{className:"h-4 w-4 mr-2"}),p.mode==="remaining"?`Download ${v}`:"Download All"]})]})]})})]})}function op(){const{campaignId:e}=Ra(),[t,r]=di(),{data:s}=Fa(),i=t.get("campaign"),a=e||i||"";Do("Campaign Results");const[o,l]=E.useState(a),[u,c]=E.useState(t.get("auto_refresh")==="true"),[h,w]=E.useState(!1),[y,v]=E.useState(!1),[S,j]=E.useState("payloads"),{collapsed:b,updateCollapsed:p}=cm();E.useMemo(()=>
11{l(a)},[a]);const{data:m,isLoading:f,error:d}=Uo(o,{autoRefresh:u}),{data:x,refetch:g}=Vo(a,{autoRefresh:u}),M=E.useRef(void 0);E.useEffect(()=>{const U=m?.integrations_running??!1,ne=M.current;if(ne!==void 0){if(ne===!1&&U===!0){if(!u){c(!0);const Ee=new URLSearchParams(t);Ee.set("auto_refresh","true"),r(Ee,{replace:!0})}}else if(ne===!0&&U===!1&&u){c(!1);const Ee=new URLSearchParams(t);Ee.set("auto_refresh","false"),r(Ee,{replace:!0})}}M.current=U},[m?.integrations_running]);const{data:P}=Wo(m),{data:q}=Go(m),k=Ko(o),N=Jo(o),O=Xo(o),I=Qo(o),_=el(o),T=tl(o),C=Co(),R=(U,ne)=>{T.mutate({linkId:U,status:ne},{onSuccess:()=>{W.success("Link status updated")},onError:()=>{W.error("Failed to update link status")}})},D=(U,ne)=>{k.mutate({emailId:U,status:ne},{onSuccess:()=>{W.success("Status updated")},onError:()=>{W.error("Failed to update status")}})},A=U=>{N.mutate(U,{onSuccess:()=>{W.success(`Updated ${U.length} email${U.length>1?"s":""}`)},onError:()=>{W.error("Failed to update statuses")}})},$=U=>{c(U);const ne=new URLSearchParams(t);ne.set("auto_refresh",U.toString()),r(ne,{replace:!0})},J=()=>{O.mutate(void 0,{onSuccess:()=>{W.success("Integrations collection started"),u||$(!0)},onError:U=>{U.response?.status===409?W.error("Integrations are already running"):U.response?.status===400?W.error("Campaign must be completed or active before collecting results"):W.error("Failed to start integrations collection")}})},B=()=>{I.mutate(void 0,{onSuccess:()=>{W.success("Campaign marked as complete"),L.status==="monitoring"&&L.stopMonitoring(),g()},onError:()=>{W.error("Failed to complete campaign")}})},[Z,X]=E.useState(!1),[Y,te]=E.useState(60),V=()=>{_.mutate(Y,{onSuccess:U=>{X(!1);const ne=U.reactivated?`Campaign reactivated — ${U.links_updated} link${U.links_updated!==1?"s":""} set to expire in ${U.new_expiry_minutes} minutes`:`${U.links_updated} link${U.links_updated!==1?"s":""} set to expire in ${U.new_expiry_minutes} minutes`;W.success(ne)},onError:()=>{W.error("Failed to reset link expiry")}})},H=s?.subscription_status==="Premium"||s?.subscription_status==="Enterprise",F=m?.campaign_type==="web",Q=m,lt=E.useMemo(()=>!F||!Q?.payload_links?[]:Q.payload_links.filter(U=>U.expected_hash).map(U=>({linkId:U.link_id,payloadId:U.payload_id,hash:U.expected_hash,filename:U.payload_name})),[F,Q?.payload_links]),L=xm(lt);E.useEffect(()=>{m?.status==="Completed"&&L.status==="monitoring"&&L.stopMonitoring()},[m?.status,L.status]);const z=E.useMemo(()=>Bc(Q?.payload_links||[],L.monitoredDownloads),[Q?.payload_links,L.monitoredDownloads]),[le,ge]=E.useState(!1),Re=async(U=!1)=>{const ne=Q?.payload_links;if(!ne||ne.length===0||m?.status==="Completed")return;const Ee=U?ne.filter(ye=>(ye.client_reports?.length?ye.client_reports[ye.client_reports.length-1]:null)?.status==="not_accessed"?!0:ye.click_count===0&&(!ye.client_reports||ye.client_reports.length===0)):ne;if(Ee.length===0){W.info("All payloads have already been downloaded");return}ge(!0);try{let ye=0;const Vt=Math.floor(Date.now()/1e3);for(let nt=0;nt<Ee.length;nt++){const dt=Ee[nt];if(!(dt.expiry_epoch&&dt.expiry_epoch<Vt)){try{const Ct=await fetch(dt.link_url);if(!Ct.ok)continue;if((Ct.headers.get("content-type")||"").includes("application/json")){const Qr=Ct.clone();try{if((await Qr.json()).message==="Link expired.")continue}catch{}}const Kn=await Ct.blob();if(L.status==="monitoring"&&L.saveToDirectory&&await L.saveToDirectory(Kn,dt.payload_name)){ye++,nt<Ee.length-1&&await new Promise(es=>setTimeout(es,1e3));continue}await L.verifyBlobInline(Kn,dt.payload_name);const Zr=URL.createObjectURL(Kn),Wt=document.createElement("a");Wt.href=Zr,Wt.download=dt.payload_name,document.body.appendChild(Wt),Wt.click(),document.body.removeChild(Wt),URL.revokeObjectURL(Zr)}catch{console.error(`Failed to download ${dt.payload_name}`)}ye++,nt<Ee.length-1&&await new Promise(Ct=>setTimeout(Ct,1e3))}}ye>0&&W.success("Downloads initiated",{description:`Started downloading ${ye} payload${ye!==1?"s":""}`})}catch(ye){console.error("Error downloading links:",ye),W.error("Download failed",{description:"An error occurred while downloading files"})}finally{ge(!1)}},[ce,me]=E.useState(null),[fe,Ut]=E.useState(null),[et,Ie]=E.useState(null),[tt,Ge]=E.useState(null),[St,ct]=E.useState(null),{data:Wn,isLoading:Sa}=Yo(a||"",et?.email_id||"",!!et),Ca=E.useMemo(()=>m?.integrations?.mail_controls?.some(U=>U.integration_type.toLowerCase()==="defender"),[m]),Aa=E.useMemo(()=>m?.integrations?.mail_controls?.some(U=>U.integration_type.toLowerCase()==="sublime"),[m]),Ea=E.useMemo(()=>m?.integrations?.browser_security?.some(U=>U.integration_type.toLowerCase()==="push_security"&&U.integration_status==="complete"),[m]),[Gn,Xr]=E.useState(null);return f?n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx($a,{className:"h-12 w-12"})}):d||!m?n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center gap-4",children:n.jsx(ar,{to:"/app/campaigns",children:n.jsxs(G,{variant:"outline",size:"sm",children:[n.jsx(ls,{className:"mr-2 h-4 w-4"}),"Back to Campaigns"]})})}),n.jsx(ue,{children:n.jsx(he,{className:"py-8 text-center",children:n.jsx("p",{className:"text-muted-foreground",children:d?"Failed to load campaign. Please try again.":"Campaign not found."})})})]}):n.jsxs("div",{className:"space-y-6 min-w-0 overflow-hidden",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx(ar,{to:"/app/campaigns",children:n.jsxs(G,{variant:"outline",size:"sm",children:[n.jsx(ls,{className:"h-4 w-4 sm:mr-2"}),n.jsx("span",{className:"hidden sm:inline",children:"Back to Campaigns"})]})}),n.jsx("div",{className:"flex items-center gap-2",children:F?n.jsx(Is,{payloadLinks:Q?.payload_links||[],campaignName:m.campaign_name}):n.jsxs(n.Fragment,{children:[n.jsx(Is,{emails:m.emails||[],campaignName:m.campaign_name}),n.jsx(ed,{campaignId:m.campaign_id,campaignStatus:m.status,isPremium:H})]})})]}),n.jsx(km,{campaign:m,relatedCampaigns:x?.campaigns,autoRefresh:u,onAutoRefreshChange:$,isPremium:H,onRerunIntegrations:J,isRerunningIntegrations:O.isPending,onCompleteCampaign:B,isCompletingCampaign:I.isPending,onExtendCampaign:F?()=>X(!0):void 0,isExtendingCampaign:_.isPending,onDownloadAll:F?()=>Re(!1):void 0,onDownloadRemaining:F?()=>Re(!0):void 0,remainingCount:F?Q?.payload_links?.filter(U=>(U.client_reports?.length?U.client_reports[U.client_reports.length-1]:null)?.status==="not_accessed"?!0:U.click_count===0&&(!U.client_reports||U.client_reports.length===0)).length:void 0,isDownloadingAll:le,monitoredDownloads:F?L.monitoredDownloads:void 0}),F?n.jsxs("div",{className:"space-y-6",children:[n.jsx(om,{monitoringStatus:L.status,monitoredDownloads:L.monitoredDownloads,isMonitoringSupported:L.isSupported,observerSupported:L.observerSupported,onRequestMonitoring:L.requestPermission,onStopMonitoring:L.stopM
11onitoring,onChangeDirectory:L.changeDirectory,directoryName:L.directoryHandle?.name,totalLinks:(Q.payload_links||[]).length}),n.jsxs("div",{className:"flex flex-col gap-6 min-w-0 lg:flex-row",children:[n.jsxs("div",{className:"flex-1 space-y-6 min-w-0",children:[n.jsxs(ue,{className:"overflow-hidden",children:[n.jsx(Ce,{className:"flex flex-row flex-wrap items-center justify-between gap-2 pb-2",children:n.jsx(Ae,{children:"Campaign Results"})}),n.jsx(he,{className:"overflow-x-auto",children:n.jsx(lm,{payloadLinks:Q.payload_links||[],monitoringStatus:L.status,monitoredDownloads:L.monitoredDownloads,isMonitoringSupported:L.isSupported,observerSupported:L.observerSupported,onRequestMonitoring:L.requestPermission,onStopMonitoring:L.stopMonitoring,onChangeDirectory:L.changeDirectory,directoryName:L.directoryHandle?.name,onStatusChange:R,saveToDirectory:L.saveToDirectory,verifyBlobInline:L.verifyBlobInline,hasPushSecurityIntegration:Ea,onPushSecurityClick:U=>Xr(U),showMonitoringBar:!1})})]}),x&&x.campaigns.length>0&&n.jsxs(ue,{className:"overflow-hidden",children:[n.jsx(Ce,{children:n.jsx(Ae,{children:"Related Campaigns"})}),n.jsx(he,{className:"overflow-x-auto",children:n.jsx(Ts,{campaigns:x.campaigns,selectedCampaignId:o,onSelectCampaign:l,autoRefresh:u,isPremium:H})})]})]}),n.jsx(ri,{collapsed:b,onCollapsedChange:p,children:n.jsx(si,{sidebarToggle:n.jsx(ni,{collapsed:b,onCollapsedChange:p}),campaignName:m.campaign_name,insights:P,recommendationsData:q,isPremium:H,relatedCampaignsList:x?.campaigns,webDistribution:z,onInsightsUpgradeClick:()=>w(!0),onRecommendationsUpgradeClick:()=>v(!0)})})]})]}):n.jsxs(Ha,{value:S,onValueChange:j,className:"w-full",children:[n.jsxs(Ua,{className:"mb-4",children:[n.jsx(ns,{value:"payloads",children:"Payloads"}),n.jsx(ns,{value:"analytics",children:"Analytics"})]}),n.jsx(rs,{value:"payloads",children:n.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row min-w-0",children:[n.jsxs("div",{className:"flex-1 space-y-6 min-w-0",children:[n.jsxs(ue,{className:"overflow-hidden",children:[n.jsxs(Ce,{className:"flex flex-row flex-wrap items-center justify-between gap-2 pb-2",children:[n.jsx(Ae,{children:"Campaign Results"}),n.jsx("div",{className:"flex items-center gap-2",children:n.jsx("div",{id:"bulk-actions-container",className:"flex items-center gap-2 min-h-[36px] flex-wrap"})})]}),n.jsx(he,{className:"overflow-x-auto",children:n.jsx(Ec,{emails:m.emails||[],onStatusChange:D,onBulkStatusChange:A,isUpdating:k.isPending||N.isPending,hasDefenderIntegration:Ca,hasSublimeIntegration:Aa,onViewDefender:U=>{me(U)},onViewSublime:U=>{Ut(U)},onViewEml:U=>{Ie(U)},onViewGatewayResponse:U=>{Ge(U)},onViewClicks:U=>{ct(U)},onDownloadPayload:U=>{C.mutate(U,{onSuccess:ne=>{W.success(`Downloaded ${ne}`)},onError:()=>{W.error("Error downloading payload. Please try again.")}})},renderBulkActions:({hasSentEmails:U,selectedCount:ne,onSetRemainingBlocked:Ee,onOpenBulkStatusDialog:ye,isUpdating:Vt})=>{const nt=document.getElementById("bulk-actions-container");return nt?Ma.createPortal(n.jsxs(n.Fragment,{children:[U&&n.jsx(G,{variant:"outline",size:"sm",onClick:Ee,disabled:Vt,children:"Set Remaining Blocked"}),ne>0&&n.jsxs(G,{variant:"outline",size:"sm",onClick:ye,disabled:Vt,children:["Set Selected Status (",ne,")"]})]}),nt):null}})})]}),x&&x.campaigns.length>0&&n.jsxs(ue,{className:"overflow-hidden",children:[n.jsx(Ce,{children:n.jsx(Ae,{children:"Related Campaigns"})}),n.jsx(he,{className:"overflow-x-auto",children:n.jsx(Ts,{campaigns:x.campaigns,selectedCampaignId:o,onSelectCampaign:l,autoRefresh:u,isPremium:H})})]})]}),n.jsx(ri,{collapsed:b,onCollapsedChange:p,children:n.jsx(si,{sidebarToggle:n.jsx(ni,{collapsed:b,onCollapsedChange:p}),campaignName:m.campaign_name,insights:P,recommendationsData:q,isPremium:H,relatedCampaignsList:x?.campaigns,emails:m.emails||[],onInsightsUpgradeClick:()=>w(!0),onRecommendationsUpgradeClick:()=>v(!0)})})]})}),n.jsx(rs,{value:"analytics",children:n.jsx(em,{emails:m.emails||[],campaignName:m.campaign_name})})]}),n.jsx(Uc,{open:!!ce,onOpenChange:U=>!U&&me(null),defenderData:ce?.mail_control_information?.Defender||null,recipient:ce?.recipient,sentTime:ce?.sent}),n.jsx(Vc,{open:!!fe,onOpenChange:U=>!U&&Ut(null),sublimeData:fe?.mail_control_information?.Sublime||null,recipient:fe?.recipient}),n.jsx(Jc,{open:!!Gn,onOpenChange:U=>!U&&Xr(null),pushSecurityData:Gn?.browser_security_information?.PushSecurity||null,payloadName:Gn?.payload_name}),n.jsx(Yc,{open:!!et,onOpenChange:U=>!U&&Ie(null),emlContent:Wn||null,emailId:et?.email_id,isLoading:Sa}),n.jsx(Xc,{open:!!tt,onOpenChange:U=>!U&&Ge(null),gatewayResponse:tt?.sendgrid_reason||null}),n.jsx(na,{open:!!St,onOpenChange:U=>!U&&ct(null),clicks:St?.clicks||null,recipient:St?.recipient}),n.jsx(or,{open:h,onOpenChange:w,feature:"Campaign Insights",requiredTier:"premium"}),n.jsx(or,{open:y,onOpenChange:v,feature:"Campaign Recommendations",requiredTier:"premium"}),n.jsx($e,{open:Z,onOpenChange:X,children:n.jsxs(ze,{className:"sm:max-w-md",children:[n.jsxs(Le,{children:[n.jsx(Be,{children:"Reset Link Expiry"}),n.jsxs(qe,{children:["Set a new expiry time for all links in this campaign. This replaces the current expiry — it is not additive.",m?.status==="Completed"&&n.jsx("span",{className:"block mt-2 font-medium text-foreground",children:"This will also reactivate the campaign from C
11ompleted to Active."})]})]}),n.jsxs("div",{className:"flex items-center gap-2 py-4",children:[n.jsx(Ar,{htmlFor:"extend-minutes",className:"whitespace-nowrap",children:"Expire in:"}),n.jsx("input",{id:"extend-minutes",type:"number",min:1,max:1440,value:Y,onChange:U=>{const ne=parseInt(U.target.value,10);isNaN(ne)||te(Math.min(1440,Math.max(1,ne)))},className:"flex h-9 w-24 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),n.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",Y>=60?`${Math.floor(Y/60)}h${Y%60>0?` ${Y%60}m`:""}`:`${Y}m`,")"]})]}),n.jsxs(Cr,{children:[n.jsx(G,{variant:"outline",onClick:()=>X(!1),children:"Cancel"}),n.jsxs(G,{onClick:V,disabled:_.isPending,children:[n.jsx(Pi,{className:"h-4 w-4 mr-2"}),_.isPending?"Applying...":"Apply"]})]})]})})]})}export{op as CampaignResults,oi as EMAIL_STATUS_COLORS};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.