1import{dY as ot,a as t,eH as dt,j as h,b4 as ut,l as O,b6 as ht,b3 as ft,z as mt,cF as pt,cG as gt,cH as bt,ad as R,eI as yt,eJ as xt,eK as $,eL as ve,eM as J,ee as vt,eN as E,D as U,eO as ce,aI as oe,eP as At,cQ as he,cK as fe,eQ as St,aO as me,eR as kt,w as L,eS as _e,eT as wt,eU as Nt,eV as Tt,cD as Ct,eW as It,e8 as Pe,t as Et,eX as De,aA as Fe,eY as ee,eZ as se,e_ as Ae,aG as Me,aW as Oe,e$ as Lt,f0 as Rt,cd as q,at as _t,ae as z,an as Pt,U as Q,dd as Dt,cT as Se,f1 as je,f2 as Be,f3 as $e,f4 as Ve,db as Ue,f5 as ze,f6 as pe,T as Z,ed as ge,f7 as K,a4 as H,f8 as Ft,f9 as Mt,eC as Ot,cS as qe,aT as I,fa as W,fb as jt,fc as Bt,bY as Y,fd as $t,fe as Vt,ff as Ut,fg as zt,fh as qt,af as Ge,b0 as te,fi as Gt,fj as Qe,bI as de,fk as Qt,fl as ue,e3 as He,fm as Ht,aL as Kt,fn as Wt,d_ as Ke,W as Yt,m as We,fo as Zt,Z as Xt,B as Jt,e4 as es,cP as ts,cW as ss,dc as ns,a5 as as,fp as rs,fq as is,fr as ls,fs as cs,ft as os,fu as ke,a2 as ds,ag as us,ca as hs,fv as fs,eF as ms,fw as ps,ef as gs,x as bs,fx as we,bE as ys,cN as xs,fy as ne,dX as vs,dV as ae,eo as As}from"./index-BFa3nKuT.js";import{r as Ss,g as ks,a as y,S as ws}from"./datepicker-CN3oO0F6.js";import"./visx-o561FtCw.js";import{g as Ns}from"./pagination-D7CFms1s.js";import{N as be}from"./apollo-B9xYJgZj.js";import{A as Ts}from"./executionDisplayLabel-DDOCh7EL.js";import{u as Cs,c as Is,F as Es}from"./forms-BE_8TKCw.js";import{S as Ls,k as Ne,j as Rs,l as _s,ao as Ps}from"./charts-BEfaN6Tb.js";import"./framerMotion-KnKeNhwd.js";import"./shiki-DSW_v8w1.js";import"./betterAuth-wecmey9t.js";import"./tanstack-82Oensom.js";import"./virtuoso-_8EeKo1c.js";import"./sentry-BM1d0HPc.js";import"./amplitude-rTYtQKJT.js";import"./amplify-FijOe782.js";import"./qrcode-CMNUHY9J.js";import"./dnd-BjCurfON.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"01e610d75577dcaf5e5c9af84e79c9458f58a767"},e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=(function(n){for(var a=1;a<arguments.length;a++){var r=arguments[a];if(r!=null)for(var l in r)r.hasOwnProperty(l)&&(n[l]=r[l])}return n})({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:currents-dashboard":!0});var s=new e.Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="363c6587-f697-45b3-8663-e64f707a3b7d",e._sentryDebugIdIdentifier="sentry-dbid-363c6587-f697-45b3-8663-e64f707a3b7d")}catch{}})();var Ds=Math.min;function Fs(e,s,n){for(var a=Rs,r=e[0].length,l=e.length,i=l,c=Array(l),o=1/0,m=[];i--;){var g=e[i];o=Ds(g.length,o),c[i]=r>=120&&g.length>=120?new Ls(i&&g):void 0}g=e[0];var p=-1,f=c[0];e:for(;++p<r&&m.length<o;){var d=g[p],u=d;if(d=d!==0?d:0,!(f?Ne(f,u):a(m,u))){for(i=l;--i;){var v=c[i];if(!(v?Ne(v,u):a(e[i],u)))continue e}f&&f.push(u),m.push(d)}}return m}function Ms(e){return ot(e)?e:[]}var Os=_s(function(e){var s=Ps(e,Ms);return s.length&&s[0]===e[0]?Fs(s):[]});function Ye({values:e,options:s,maxBadges:n=3}){return t("div",{className:"flex items-center",children:dt(e,n).map((a,r)=>{const l=s.find(c=>c.value===a),i=(l==null?void 0:l.label)??a;return h(ft,{delayDuration:300,children:[t(ut,{asChild:!0,children:t("span",{"aria-label":i,className:O("inline-flex items-center justify-center w-5 h-5 text-[10px] font-medium rounded-full relative",l==null?void 0:l.color),style:{marginLeft:r>0?"-6px":0,zIndex:e.length-r},children:i.charAt(0).toUpperCase()})}),t(ht,{children:i})]},`${a}-${r}`)})})}const js=mt("div",{target:"e119ql8i0"})({name:"w6gyyi",styles:"transition:scale 0.2s;&:hover{scale:1.02;}"});function Bs(){return t("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-ui-v2-border-opaque","aria-hidden":!0})}function $s({items:e,stem:s=!0,renderItem:n,renderMarker:a,renderWrapper:r,className:l}){const i=s&&e.length>1;return t("div",{className:O("relative flex flex-col gap-2 overflow-visible",l),children:e.map((c,o)=>{const m=o===0,g=o===e.length-1,p=i&&o>0,f={index:o,showStem:p},d=h("div",{className:"relative z-10 grid grid-cols-[24px_1fr] items-start justify-center w-full",children:[h("div",{className:"flex h-full shrink-0 items-center justify-center",children:[(a==null?void 0:a(f,c))??t(Bs,{}
1),i?t("div",{"aria-hidden":!0,className:O("pointer-events-none absolute z-0 border-l border-solid border-ui-v2-border-opaque",m?"top-1/2":"top-[-16px]",g?"bottom-1/2":"bottom-[-16px]")}):null]}),t("div",{className:"min-w-0",children:n(c,f)})]});return t("div",{className:"relative overflow-visible animate-in fade-in-0",children:r?r(d,c,f):d},c.id)})})}var re={},Te;function Vs(){return Te||(Te=1,(function(e){var s=pt();Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=s(gt()),a=s(bt()),r=s(Ss()),l=function(o){var m=o.color,g=m===void 0?"currentColor":m,p=o.size,f=p===void 0?24:p,d=(0,a.default)(o,["color","size"]);return r.default.createElement("svg",(0,n.default)({fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",shapeRendering:"geometricPrecision",viewBox:"0 0 24 24"},d,{height:f,width:f,style:{color:g}}),r.default.createElement("path",{d:"M8 10.854h3.798M8 21c2.578 0 3.798-1.494 3.798-4.19v-5.956m0 0h3.75m-3.75 0V7.476c0-2.906 1.379-4.898 4.202-4.4"}))},i=l;e.default=i})(re)),re}var Us=Vs();const zs=ks(Us),Ze="border-b-0 p-0 shrink-0";function X({label:e,options:s,value:n,onValueChange:a}){return h($,{value:n,onValueChange:a,options:s,children:[t($.Trigger,{asChild:!0,children:t(R,{type:"primary",chevron:t(xt,{"aria-hidden":!0}),children:h("span",{className:"flex items-center gap-1.5",children:[e,n.length>0&&t(yt,{children:n.length})]})})}),h($.Content,{children:[s.map(r=>t($.Item,{value:r.value,children:r.label},r.value)),h($.Footer,{children:[t($.SelectAll,{}),t($.ClearAll,{})]})]})]})}const qs=({totalCount:e,rangeStart:s,rangeEnd:n})=>{const a=e===0?"0 affected tests":`${s}â${n} of ${e} affected test${e!==1?"s":""}`;return e===0?null:h("div",{className:"flex flex-wrap items-center justify-between gap-x-2 gap-y-1 p-2",children:[t("span",{className:"text-sm text-theme-secondary",children:a}),t("span",{className:"text-sm text-theme-secondary",children:"Last seen first"})]})},Gs=({rule:e})=>e.archivedAt||e.disabledAt||ve(e.expiresAfter)?h("div",{className:"flex gap-1",children:[e.archivedAt&&t(M,{status:"warning",children:"Archived"}),e.disabledAt&&t(M,{status:"neutral",children:"Disabled"}),ve(e.expiresAfter)&&t(M,{status:"error",children:"Expired"})]}):t(M,{status:"success",children:"Active"}),M=({children:e,status:s="neutral"})=>t(vt,{appearance:"filled",status:s,className:"shrink-0",children:e}),Qs=({actions:e})=>t(Ye,{values:e.map(s=>s.op),options:J}),Hs=({types:e})=>t(Ye,{values:e,options:J}),Ks=({status:e})=>{switch(e){case E.Expired:return t(M,{status:"error",children:"Expired"});case E.Disabled:return t(M,{status:"neutral",children:"Disabled"});case E.Active:return t(M,{status:"success",children:"Active"});case E.Archived:return t(M,{status:"warning",children:"Archived"});default:return e}},Ws=new Set(Object.values(E)),Ys=new Set(Object.values(St)),Zs=[7,14,30],ie=14,Xs=new Set(Object.values(fe)),ye=()=>{const[e,s]=U("status",ce),[n,a]=U("at_s",oe),[r,l]=U("actionTypes",ce),[i,c]=At({key:"at",defaultLookback:ie}),[o,m]=U("at_dir",oe),[,g]=he(),p=()=>{if(!e||e.length===0)return[E.Active];const b=e.filter(Boolean).filter(_=>Ws.has(_));return b.length>0?b:[E.Active]},f=o&&Xs.has(o)?o:fe.Desc,d=i&&Zs.includes(i)?i:ie,u=()=>g(1),v=b=>{s(b.length>0?b:void 0),u()},x=()=>!r||r.length===0?[]:r.filter(Boolean).filter(b=>Ys.has(b)),P=b=>{a(b||void 0),u()},D=b=>{l(b.length>0?b:void 0),u()},C=b=>{c(String(b)),u()},N=b=>{m(b),u()},w=()=>{s(void 0),a(void 0),l(void 0),c(void 0),m(void 0),u()},k=()=>{const b=p();return!(b.length===1&&b[0]===E.Active)||!!n||x().length>0||d!==ie};return{statuses:p(),setStatuses:v,search:n??"",setSearch:P,actionTypes:x(),setActionTypes:D,lookback:d,setLookback:C,sortDirection:f,setSortDirection:N,resetFilters:w,hasCustomFilters:k}},Ce=25,Js=(e,s,n,a=null)=>{const r=ye(),[l,i]=me({key:"at",defaultLookback:r.lookback}),c=y.useMemo(()=>n!=null&&n.trim()?n.trim():null,[n]),o=!c&&!a,{data:m,loading:g,error:p,fetchMore:f,networkStatus:d}=kt({variables:{input:{orgId:e,projectId:s,signature:c,dateStart:L(l),dateEnd:L(i),limit:Ce,actionId:a,search:r.search||null,startingAfter:null,endingBefore:null}},skip:o,fetchPolicy:"cache-and-network",notifyOnNetworkStatusChange:!0}),u=m==null?void 0:m.actionsAffectedTestExecutions,v=y.useMemo(()=>u!=null&&u.executions?u.executions:[],[u==null?void 0:u.executions]),x=(u==null?void 0:u.hasMore)??!1,P=d===be.fetchMore,D=y.useCallback(async()=>{var w;const C=(w=u==null?void 0:u.executions)==null?void 0:w[u.executions.length-1],N=C==null?void 0:C.cursor;!c&&!a||!N||!(u!=null&&u.hasMore)||await f({variables:{input:{orgId:e,projectId:s,signature:c,dateStart:L(l),dateEnd:L(i),limit:Ce,actionId:a,search:r.search||null,startingAfter:N,endingBefore:null}},updateQuery:(k,{fetchMoreResult:b})=>{if(!(b!=null&&b.actionsAffectedTestExecutions))return k;const _=b.actionsAffectedTestExecutions,T=k.actionsAffectedTestExecutions,V=new Set(((T==null?void 0:T.executions)??[]).map(F=>F.cursor).filter(F=>!!F)),j=_.executions.filter(F=>F.cursor&&!V.has(F.cursor));return{...k,actionsAffectedTestExecutions:{..._,executions:[...(T==null?void 0:T.executions)??[],...j]}}}})},[a,i,l,f,r.search,e,u==null?void 0:u.executions,u==null?void 0:u.hasMore,s,c]);return{executions:v,loading:g,error:p,hasMore:x,loadMore:D,loadingMore:P,lookback:r.lookback,setLookback:r.setLookback}},Xe=(e,s,n,a)=>Js(e,s,n,a);function en({href:e,className:s,children:n}){return t(Pe,{to:e,className:s,children:n})}function Je({executions:e,error:s,emptyLabel:n="No executions foun
1d"}){if(s)return t("div",{className:"pl-6 pb-2",children:t("span",{className:"text-theme-error text-sm",children:"Failed to load executions"})});if(e.length===0)return t("div",{className:"pl-6 pb-2",children:t("span",{className:"text-theme-secondary text-sm",children:n})});const a=e.map(r=>{var l;return{id:`${r.runId}:${r.instanceId}:${r.executedAt}`,status:Ct(r.state),flaky:r.isFlaky??void 0,href:Tt(r.instanceId,r.testId).href,group:(l=r.groupId)!=null&&l.trim()?t(Nt,{label:wt(r.groupId,48),tooltip:r.groupId}):void 0,primary:t(Ts,{prTitle:r.prTitle,commitMessage:r.commitMessage,prId:r.prId,commitSha:r.commitSha}),branch:r.branch??void 0,time:t(_e,{date:new Date(r.executedAt),label:"Executed at"})}});return t(It,{items:a,revealOnMount:!0,linkComponent:en})}function tn(e){const s=new Map;for(const a of e){const r=s.get(a.id);r?r.push(a):s.set(a.id,[a])}const n=Array.from(s.entries()).map(([a,r])=>{const l=new Set;let i=r[0].lastSeen,c=0;for(const o of r){for(const m of o.types)l.add(m);o.lastSeen>i&&(i=o.lastSeen),c+=o.recordingCount}return{name:r[0].name,id:a,actions:r,types:Array.from(l),status:r[0].status,lastSeen:i,recordingCount:c}});return Fe(n,"lastSeen","desc")}function sn({orgId:e,projectId:s,testSignature:n,groupId:a}){const{executions:r,loading:l,error:i,hasMore:c,loadMore:o,loadingMore:m}=Xe(e,s,n,a),g=y.useCallback(async p=>{p.stopPropagation(),await o()},[o]);return l&&r.length===0?t("div",{className:"pl-6 py-2",children:t(q,{})}):h("div",{className:"flex flex-col gap-2",children:[t(Je,{executions:r,error:i==null?void 0:i.message}),c?t("div",{children:t(R,{type:"secondary",disabled:m,className:"border border-ui-v2-border-main",onClick:g,children:m?"Loadingâ¦":"Load more"})}):null]})}const nn=({group:e,orgId:s,projectId:n,testSignature:a})=>{const r=ee(n,e.id),[l,i]=y.useState(!1);return h("div",{children:[h(se,{onClick:()=>i(c=>!c),"aria-expanded":l,children:[t(Ae,{"aria-hidden":!0,className:O("shrink-0 text-ui-v2-content-secondary-idle transition-transform",l&&"rotate-90")}),t(Ks,{status:e.status}),t(Hs,{types:e.types}),t(se.Text,{className:"ty-text truncate max-w-[400px]",children:e.name}),h("span",{className:"ty-text flex-shrink-0",children:["Applied ",e.recordingCount," ",Me("time",e.recordingCount)]}),t(se.Actions,{className:"ml-auto",children:t(Oe,{href:r,color:!1,underline:!1,className:O(Rt({type:"secondary",size:"default"}),Lt,"border border-ui-v2-border-main"),children:h("span",{className:"inline-flex items-center",children:[t("span",{className:"pr-ui-v2-1",children:"Action Details"}),t(Ae,{size:"default","aria-hidden":!0})]})})})]}),l&&t("div",{className:"mt-2 ml-ui-v2-2.5 max-h-[400px] overflow-y-auto",children:t(sn,{orgId:s,projectId:n,testSignature:a,groupId:e.id})})]})},an=({actions:e,visibleRows:s=2,orgId:n,testSignature:a})=>{const[r]=Et(),[l,i]=y.useState(!1),c=tn(e);if(c.length===0)return null;const o=c.length>s,m=l?c:c.slice(0,s),g=c.length-s;return h("div",{className:"flex flex-col gap-1",children:[m.map(p=>t(nn,{group:p,orgId:n,projectId:r,testSignature:a},p.id)),o&&t(De,{variant:"ghost",size:"xs",onClick:p=>{p.stopPropagation(),i(f=>!f)},className:"text-left w-fit",children:l?"show less":`and ${g} more`})]})},rn=({item:e,orgId:s,projectId:n})=>t("div",{className:"min-w-0 border-b border-theme-border/50 last:border-b-0",children:h("div",{className:"flex flex-col gap-2 min-w-0 p-2 rounded-sm",children:[t("div",{className:"flex items-start justify-between gap-ui-v2-4 min-w-0",children:h("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[t("span",{className:"block min-w-0 truncate text-sm font-medium text-theme-foreground",children:e.title}),t("span",{className:"block min-w-0 truncate text-sm text-theme-secondary",children:e.specFile})]})}),t(an,{actions:e.actions,orgId:s,testSignature:e.signature})]})}),ln=()=>t(z,{padding:"16px",justifyContent:"center",children:t(q,{})}),cn=()=>t(z,{padding:"32px",justifyContent:"center",alignItems:"center",children:t(Pt,{font:Q.font.small,span:!0,type:"secondary",children:"No affected tests found"})}),on=({page:e,pagesCount:s,onPageChange:n})=>s>1?t(z,{justifyContent:"center",padding:"12px",children:t(Dt,{page:e,count:s,onChange:n})}):null,dn=({orgId:e,projectId:s,actionsAffectedTests:n,isLoading:a=!1,isUpdating:r=!1,pageSize:l})=>{const[i,c]=he(),o=(n==null?void 0:n.results)??[],m=(n==null?void 0:n.total)??0,{rangeStart:g,rangeEnd:p,pagesCount:f}=Ns({count:m,limit:l,page:i}),d=o.length===0&&!a;return h("div",{className:"max-h-full overflow-y-auto",children:[t(qs,{totalCount:m,rangeStart:g,rangeEnd:p}),a&&o.length===0&&t(ln,{}),!a&&d&&t(cn,{}),!a&&!d&&t(_t,{loading:r,children:t("div",{className:"flex flex-col gap-2",children:o.map(u=>t(rn,{item:u,orgId:e,projectId:s},u.signature))})}),t(on,{page:i,pagesCount:f,onPageChange:c})]})},un=[{label:"7d",value:7},{label:"14d",value:14},{label:"30d",value:30}
1],et=({value:e,onChange:s})=>t(Se,{className:O("h-[24px]","[&_[role=radio]]:box-border [&_[role=radio]]:h-[24px] [&_[role=radio]]:py-0"),value:String(e),onValueChange:n=>s(Number(n)),"aria-label":"Lookback period",children:un.map(n=>t(Se.Item,{value:String(n.value),children:n.label},n.value))}),Ie=25,hn=(e,s)=>{const n=ye(),[a]=he(),[r,l]=me({key:"at",defaultLookback:n.lookback}),{data:i,loading:c,previousData:o}=je({variables:{input:{orgId:e,projectId:s,dateStart:L(r),dateEnd:L(l),search:n.search||null,actionTypes:n.actionTypes.length>0?n.actionTypes:null,actionId:null,page:a-1,limit:Ie,dir:n.sortDirection,status:n.statuses.length>0?n.statuses:null}},fetchPolicy:"cache-and-network"}),m=c?o:i;return{actionsAffectedTests:m==null?void 0:m.actionsAffectedTests,loading:!!(c&&!o),updating:!!(c&&o),pageSize:Ie,filters:n}},fn=({orgId:e,projectId:s})=>{const{actionsAffectedTests:n,loading:a,updating:r,pageSize:l,filters:i}=hn(e,s);return h("div",{className:"flex flex-col gap-2",children:[h(Be,{className:Ze,children:[h($e,{children:[t(X,{label:"Action Status",options:Ve,value:i.statuses,onValueChange:c=>i.setStatuses([...c])}),t(X,{label:"Action Type",options:J,value:i.actionTypes,onValueChange:c=>i.setActionTypes([...c])}),t(Ue,{className:"min-w-48 w-80 max-w-full",placeholder:"Search by test title, spec file or action name",onChange:i.setSearch,initialValue:i.search})]}),t(ze,{children:t(et,{value:i.lookback,onChange:i.setLookback})})]}),t(dn,{orgId:e,projectId:s,actionsAffectedTests:n,isLoading:a,isUpdating:r,pageSize:l})]})},le=25;function mn(e,s,n){var P;const a=ye(),[r,l]=me({key:"at",defaultLookback:a.lookback}),{data:i,loading:c,error:o,fetchMore:m,networkStatus:g,previousData:p}=je({variables:{input:{orgId:e,projectId:s,dateStart:L(r),dateEnd:L(l),search:a.search||null,actionTypes:a.actionTypes.length>0?a.actionTypes:null,actionId:n,page:0,limit:le,dir:a.sortDirection,status:a.statuses.length>0?a.statuses:null}},skip:!n,fetchPolicy:"cache-and-network",notifyOnNetworkStatusChange:!0}),f=c?p:i,d=f==null?void 0:f.actionsAffectedTests,u=(d==null?void 0:d.nextPage)!=null,v=g===be.fetchMore,x=y.useCallback(async()=>{var C;const D=(C=i==null?void 0:i.actionsAffectedTests)==null?void 0:C.nextPage;D!=null&&await m({variables:{input:{orgId:e,projectId:s,dateStart:L(r),dateEnd:L(l),search:a.search||null,actionTypes:a.actionTypes.length>0?a.actionTypes:null,actionId:n,page:D,limit:le,dir:a.sortDirection,status:a.statuses.length>0?a.statuses:null}},updateQuery:(N,{fetchMoreResult:w})=>{var V;if(!(w!=null&&w.actionsAffectedTests))return N;const k=w.actionsAffectedTests,b=N.actionsAffectedTests;if(!b)return w;const _=new Set((b.results??[]).map(j=>j.signature)),T=(k.results??[]).filter(j=>!_.has(j.signature));return{...N,actionsAffectedTests:{...k,results:[...b.results??[],...T],total:k.total,count:(((V=b.results)==null?void 0:V.length)??0)+T.length,nextPage:k.nextPage}}}})},[n,(P=i==null?void 0:i.actionsAffectedTests)==null?void 0:P.nextPage,l,r,m,a.actionTypes,a.search,a.sortDirection,a.statuses,e,s]);return{actionsAffectedTests:d,loading:!!(c&&!p),updating:!!(c&&p),error:o,pageSize:le,hasMoreSignatures:u,loadMoreSignatures:x,loadingMoreSignatures:v,lookback:a.lookback,setLookback:a.setLookback}}const pn=({date:e,createdBy:s})=>{const[n]=pe(e);return t("span",{className:"inline-flex items-center",children:t(Z,{text:t(ge,{date:e}),children:h("span",{className:"text-theme-secondary text-xs truncate",children:["Created ",n," by ",s]})})})},gn=({date:e})=>{const[s]=pe(e);return t("span",{className:"inline-flex items-center",children:t(Z,{text:t(ge,{date:e}),children:h("span",{className:"text-theme-secondary text-xs truncate",children:[e<new Date?"Expired":"Expires"," ",s]})})})},Ee=30,tt=({date:e})=>{const[s]=pe(e??new Date);if(!e)return t("span",{className:"inline-flex items-center",children:t(Z,{text:"No applications recorded within the data-retention window",children:t("span",{className:"text-theme-secondary text-xs truncate",children:"Never fired"})})});const a=ws(new Date,e)>Ee?`Fired >${Ee}d ago`:`Fired ${s}`;return t("span",{className:"inline-flex items-center",children:t(Z,{text:t(ge,{date:e}),children:t("span",{className:"text-theme-secondary text-xs truncate",children:a})})})};function bn({isEditing:e,isSaving:s,onStartEdit:n,onCancelEdit:a}){const r=K();return h("div",{className:"flex justify-end gap-ui-v2-2",children:[e&&h(H,{children:[t(R,{type:"accent",htmlType:"submit",form:"rule-form",loading:s,children:"Save"}),t(R,{type:"secondary",onClick:a,disabled:s,children:"Cancel"})]}),!e&&t(R,{type:"secondary",disabled:!r,onClick:n,children:"Edit"})]})}const yn=({rule:e})=>{const s=K(),[n,{loading:a}]=Ft(),[r,{loading:l}]=Mt(),[i,c]=y.useState(null),o=a||l,m=!e.disabledAt,g=i??m;y.useEffect(()=>{c(null)},[e.disabledAt]);const p=async f=>{if(!(!s||o)&&f!==m){c(f);try{f?await r({variables:{ruleId:e._id}}):await n({variables:{ruleId:e._id}})}catch{c(null)}}};return h("div",{className:"flex items-center gap-2",children:[t(Ot,{"aria-label":g?"Disable rule":"Enable rule",checked:g,disabled:!s||o,onChange:f=>p(f.target.checked),id:"rule-disable-toggle"}),t(qe,{htmlFor:"rule-disable-toggle",className:"text-theme-secondary",children:"Enabled"})]})};function xn({rule:e}){const s=y.useMemo(()=>[{id:"created",date:I(e.createdAt),label:`Created by ${e.createdBy}`},e.disabledAt?{id:"disabled",date:I(e.disabledAt),label:`Disabled by ${e.disabledBy}`}
1:null,e.archivedAt?{id:"archived",date:I(e.archivedAt),label:`Archived by ${e.archivedBy}`}:null,e.expiresAfter?{id:"expires",date:I(e.expiresAfter),label:I(e.expiresAfter)>new Date?"Expiration scheduled":"Expired"}:null,e.lastApplied?{id:"last-applied",date:I(e.lastApplied),label:"Last fired"}:null].filter(n=>n!==null).sort((n,a)=>n.date.getTime()-a.date.getTime()),[e]);return t($s,{items:s,renderItem:n=>h("div",{className:"flex min-w-0 items-center justify-between gap-4",children:[t("span",{className:"text-theme-secondary ty-text truncate",children:n.label}),t("span",{className:"text-theme-secondary ty-text tabular-nums",children:t(_e,{date:n.date})})]})})}const vn=({rule:e,orgId:s,projectId:n,onSaveSuccess:a,onSaveError:r})=>{var v;const[l,i]=y.useState(!1),c=Cs({reValidateMode:"onChange",defaultValues:W(e)});y.useEffect(()=>{l||c.reset(W(e))},[e,c]);const{upsertRule:o,loading:m}=jt({orgId:s,projectId:n,onSuccess:()=>{i(!1),a()},onError:r}),g=Is({control:c.control}),p=y.useMemo(()=>Bt(g??e),[g,e]),f=()=>{c.reset(W(e)),i(!0)},d=()=>{c.reset(W(e)),i(!1)},u=async x=>{await o({ruleId:x._id,rule:{name:x.name,description:x.description,action:x.action,expiresAfter:x.expiresAfter,matcher:x.matcher}})};return t(Es,{...c,children:h("div",{className:"max-h-full overflow-y-auto flex flex-col",children:[t("div",{className:"flex gap-ui-v2-4 items-center py-8",children:h("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[t("span",{className:"text-theme-foreground font-medium leading-tight truncate",children:e.name}),t("span",{className:"text-theme-secondary text-sm truncate",children:(v=e.description)!=null&&v.trim()?e.description:null}),t(tt,{date:e.lastApplied?I(e.lastApplied):null})]})}),h("form",{id:"rule-form",className:"flex flex-col gap-ui-v2-4",onSubmit:c.handleSubmit(u),children:[h("div",{className:"flex items-center gap-2 justify-between",children:[t(yn,{rule:e}),t(bn,{isEditing:l,isSaving:m||c.formState.isSubmitting,onStartEdit:f,onCancelEdit:d})]}),l?h(H,{children:[t(Y,{level:1,children:t($t,{})}),t(Y,{level:1,children:t(Vt,{})})]}):null,t(Y,{level:1,children:t(Ut,{readOnly:!l})}),t(Y,{level:1,children:t(zt,{readOnly:!l})}),p.length>0&&t(qt,{requiredVersions:p})]}),h("div",{className:"p-ui-v2-4 py-8 flex flex-col gap-ui-v2-4",children:[t("div",{className:"",children:t(Ge,{className:"text-theme-foreground",children:"History"})}),t(xn,{rule:e})]})]})})};function An({orgId:e,projectId:s,actionId:n,signature:a}){const{executions:r,loading:l,error:i,hasMore:c,loadMore:o,loadingMore:m}=Xe(e,s,a,n),g=y.useCallback(async p=>{p.stopPropagation(),await o()},[o]);return l&&r.length===0?t("div",{className:"pl-6 py-2",children:t(q,{})}):h("div",{className:"flex flex-col gap-2",children:[t(Je,{executions:r,error:i==null?void 0:i.message}),c?t(R,{type:"secondary",disabled:m,className:"self-start border border-ui-v2-border-main",onClick:g,children:m?"Loadingâ¦":"Load more"}):null]})}function Sn({row:e,orgId:s,projectId:n,actionId:a}){const[r,l]=y.useState(!1);return t(Ht,{label:h("span",{className:"flex min-w-0 items-center justify-between gap-2 w-full",children:[t("span",{className:O("truncate text-ui-v2-13 font-medium",r&&"text-ui-v2-content-primary-idle"),children:e.title||"â"}),t("span",{className:"ty-text truncate",children:e.specFile})]}),expanded:r,onToggle:()=>l(i=>!i),children:t("div",{className:"max-h-[400px] overflow-y-auto",children:t(An,{orgId:s,projectId:n,actionId:a,signature:e.signature})})})}function kn({orgId:e,projectId:s,actionId:n}){const{actionsAffectedTests:a,loading:r,error:l,hasMoreSignatures:i,loadMoreSignatures:c,loadingMoreSignatures:o,lookback:m,setLookback:g}=mn(e,s,n),p=(a==null?void 0:a.results)??[],f=y.useCallback(async d=>{d.preventDefault(),await c()},[c]);return h("div",{className:"pt-2 flex flex-col gap-ui-v2-4 pl-ui-v2-4",children:[h("div",{className:"flex items-center justify-between gap-ui-v2-4",children:[t(Ge,{className:"text-theme-foreground",children:"Affected tests"}),t(et,{value:m,onChange:g})]}),r&&p.length===0?t("div",{className:"py-ui-v2-4 flex justify-center",children:t(q,{})}):l?t("div",{className:"mx-auto pt-6",children:t("span",{className:"text-theme-error text-xs",children:"Failed to load affected tests"})}):p.length===0?t("div",{className:"mx-auto pt-6",children:t("span",{className:"text-theme-secondary text-xs",children:"No affected tests in this period"})}):h("div",{className:"flex flex-col gap-2 pr-2",children:[p.map(d=>t(Sn,{row:d,orgId:e,projectId:s,actionId:n},d.signature)),i?t(R,{type:"secondary",disabled:o,className:"self-start border border-ui-v2-border-main",onClick:f,children:o?"Loadingâ¦":"Load more tests"}):null]})]})}const wn=te(({project:e})=>{const{ruleId:s}=Gt(),{toast:n}=He(),{data:a,loading:r,error:l}=Qe({variables:{input:{orgId:e.orgId,projectId:e.projectId,ruleId:s}},skip:!s,fetchPolicy:"cache-and-network"}),i=a==null?void 0:a.projectRule,c=()=>{n.success({title:"Action updated successfully"})},o=m=>{n.error({title:m.message||"Something went wrong. Please try again."})};return r&&!i?t("div",{className:"flex items-center justify-center gap-ui-v2-4 py-8",children:t(q,{})}):l||!i?h("div",{className:"flex flex-col items-center justify-center gap-ui-v2-4 py-8",children:[t(de,{children:t("title",{children:l?`Error Loading Action · ${e.name}`:`Action Not Found · ${e.name}`})}),t("span",{className:"text-theme-secondary text-sm",children:l?"Error loading action":"Action not found"}),t(Oe,{href:ue(e.projectId),children:h(De,{variant:"secondary",size:"sm",children:[t(Qt,{size:14,className:"mr-1"}),"Back to Actions"]})})]}):h(H,{children:[t(de,{children:h("title",{children:[i.name," · Actions · ",e.name]})}),t(vn,{rule:i,orgId:e.orgId,projectId:e.projectId,onSaveSuccess:c,onSaveError:o}),t(kn,{orgId:e.orgId,projectId:e.projectId,actionId:i._id})]})}),Nn=({onChange:e,onUpdate:s,selectedRules:n,project:a,allRulesLength:r})=>{const l=Kt(),i=K(),[c,{loading:o}]=Wt(),m=r>0&&n.length===r,g=async({enabled:d})=>{c({variables:{input:{rulesId:n.map(u=>u._id),enabled:d,orgId:a.orgId,projectId:a.projectId,expiry:null}},onCompleted:()=>{s()}}).catch(()=>{})},p=n.some(d=>!d.disabledAt),f=n.some(d=>!!d.disabledAt);return h("div",{className:"border-b border-theme-border p-2 flex items-center gap-ui-v2-4 h-[40px]",children:[t(Ke,{id:"rule-bulk-bar-checkbox",checked:m,onChange:d=>{e(d.target.checked)}}),h("div",{className:"flex justify-between items-center flex-grow gap-1",children:[t(qe,{htmlFor:"rule-bulk-bar-checkbox",children:t(Yt,{margin:0,font:Q.font.small,children:n.length>0?`Select all (${n.length} ${Me("item",n.length)} selected)`:"Select all"})}),h(z,{gap:l.layout.gapQuarter,children:[p&&t(R,{type:"secondary",disabled:!i,loading:o,onClick:()=>g({enabled:!1}),children:"Disable"}),f&&t(R,{type:"secondary",disabled:!i,loading:o,onClick:()=>g({enabled:!0}),children:"Enable"})]})]})]})},Tn=({rule:e})=>{var s;return h("div",{className:"flex flex-col min-w-0 gap-1",children:[h("div",{className:"flex justify-between items-center gap-2 min-w-0",children:[t("span",{className:"text-theme-foreground text-sm font-medium min-w-0 flex-1 truncate",title:e.name,children:e.name}),t("div",{className:"flex-shrink-0 flex flex-col items-end",children:t(Gs,{rule:e})})]}),h("div",{className:"flex justify-between gap-2 min-w-0",children:[h("div",{className:"flex min-w-0 flex-1 gap-ui-v2-4 items-baseline",children:[t("span",{className:"shrink-0",children:t(pn,{date:I(e.createdAt),createdBy:e.createdBy})}),t("span",{className:"shrink-0",children:t(tt,{date:e.lastApplied?I(e.lastApplied):null})}),e.expiresAfter&&t("span",{className:"shrink-0",children:t(gn,{date:I(e.expiresAfter)})}),((s=e.description)==null?void 0:s.trim())&&t("span",{className:"min-w-0 flex-1 truncate text-theme-secondary text-xs",title:e.description??"",children:e.description})]}),t("div",{className:"flex items-center gap-2 flex-shrink-0",children:t(Qs,{actions:e.action})})]})]})},Cn=({project:e,rule:s,isSelected:n=!1,onSelect:a})=>t("div",{className:"flex flex-col",children:h("div",{className:"flex items-baseline gap-ui-v2-4 hover:bg-theme-accent-2 p-2 pr-ui-v2-4 rounded-sm group",children:[t(Ke,{className:O("invisible group-hover:visible",{visible:n}),checked:n,onChange:r=>a(s,r.target.checked)}),t(Pe,{to:`${ee(e.projectId,s._id)}${window.location.search}`,className:"flex-grow-1 min-w-0 overflow-hidden",children:t(Tn,{rule:s})},s._id)]})});function In({projectId:e}){const n=We()(Zt(e));return t(Jt,{type:"secondary","aria-label":"Action settings",icon:t(Xt,{}),onClick:n})}const st=()=>{const[e,s]=es(),[n,a]=U("s",oe),[r,l]=U("actionTypes",ce),i=()=>e.length===0?[E.Active]:e,c=()=>!r||r.length===0?[]:r;return{getStatuses:i,getActionTypes:c,hasCustomFilters:()=>!(i().includes(E.Active)&&i().length===1)||!!n||!!r&&r.length>0,resetFilters:()=>{s([]),a(null),l(null)},isStatusActive:d=>i().some(u=>u===d),isActionTypeActive:d=>c().some(u=>u===d),handleStatusFilter:(d,u)=>{if(u){s([...i(),d]);return}s(i().filter(v=>v!==d))},search:n,setSearch:a,setStatuses:s,setActionTypes:l}},En=[{label:"Creation Time",value:"createdAt"},{label:"Last Application",value:"lastApplied"}],Ln="createdAt";function Rn(e){return e==="createdAt"||e==="lastApplied"}const nt=()=>{const[e,s]=ts(),[n,,a]=ss(),r=Rn(e)?e:Ln,l=y.useCallback(i=>{s(i)},[s]);return{sortBy:r,setSortBy:l,sortOrder:n,toggleSortOrder:a}},_n=({children:e,projectId:s,orgId:n})=>{const{getStatuses:a,setStatuses:r,search:l,setSearch:i,getActionTypes:c,setActionTypes:o}
1=st(),m=K(n),{sortBy:g,setSortBy:p}=nt(),f=a(),d=c();return h(Be,{className:Ze,children:[h($e,{children:[t(X,{label:"Action Status",options:Ve,value:f,onValueChange:x=>{r([...x])}}),t(X,{label:"Action Type",options:J,value:d,onValueChange:x=>{o(x.length>0?[...x]:null)}}),t(Ue,{className:"min-w-48 w-80 max-w-full",placeholder:"Search by action name",onChange:i,initialValue:l}),t(ns,{value:g,onChange:p,options:En,buttonType:"primary"})]}),h(ze,{children:[m&&t(In,{projectId:s,orgId:n}),e]})]})},Pn=te(({project:e,children:s})=>t(_n,{projectId:e.projectId,orgId:e.orgId,children:s})),Dn=()=>{const[e,s]=y.useState([]),n=y.useCallback(c=>{s(c)},[]),a=y.useCallback(c=>{s(o=>o.includes(c)?o:[...o,c])},[]),r=y.useCallback(c=>{s(o=>o.filter(m=>m!==c))},[]),l=y.useCallback(()=>{s([])},[]),i=y.useCallback(c=>e.includes(c),[e]);return{selectedRuleIds:e,selectVisibleRuleIds:n,addSelectedRuleId:a,removeSelectedRuleId:r,resetSelectedRules:l,isChecked:i}};function Le(e){if(e==null)return null;const n=(e instanceof Date?e:new Date(e)).getTime();return Number.isFinite(n)?n:null}function Re(e,s){return Le(s==="lastApplied"?e.lastApplied:e.createdAt)}function Fn(e,s,n){const a=n===fe.Asc?1:-1;return[...e].sort((r,l)=>{const i=Re(r,s)??-1/0,c=Re(l,s)??-1/0;return i===c?0:a*(i-c)})}const Mn=te(({project:e})=>{const s=as(),n=K(),[a,r]=y.useState(),{toast:l}=He(),{selectedRuleIds:i,selectVisibleRuleIds:c,addSelectedRuleId:o,removeSelectedRuleId:m,resetSelectedRules:g,isChecked:p}=Dn(),{getStatuses:f,getActionTypes:d,hasCustomFilters:u,search:v}=st(),{sortBy:x,sortOrder:P}=nt(),{isOpen:D,openModal:C,closeModal:N}=rs(),w=We(),{data:k,loading:b,refetch:_,networkStatus:T}=is({variables:{input:{orgId:e.orgId,projectId:e.projectId,status:f(),search:v??null,actionTypes:d().length>0?d():null}},fetchPolicy:"cache-and-network",onCompleted:()=>{g()}}),V=()=>{r(void 0),C()},j=A=>{l.success({title:`Action ${a?"updated":"created"} successfully`}),N(),a||w(ee(e.projectId,A),{keepOriginalQueryParams:!0})()},F=A=>{l.error({title:A.message||"Something went wrong. Please try again."})},at=(A,G)=>{if(G)return o(A._id);m(A._id)},B=k==null?void 0:k.projectRules,xe=B==null?void 0:B.filter(A=>Os(ls(A),f()).length>0),S=xe?Fn(xe,x,P):void 0,rt=y.useMemo(()=>{if(!(S!=null&&S.length)||i.length===0)return[];const A=new Set(i);return S.filter(G=>A.has(G._id))},[S,i]),it=B&&!B.length&&!b&&T!==be.refetch,lt=A=>{if(A&&(S!=null&&S.length))return c(S.map(G=>G._id));g()},ct=!B||B.length===0;return h(H,{children:[t(cs,{isOpen:D,onUpsert:j,onError:F,onClose:N,initialValues:a,orgId:e.orgId,projectId:e.projectId},a?`${a._id}`:"new"),h("div",{className:"flex flex-col gap-2",children:[t(Pn,{children:t(R,{type:"accent",leftIcon:t(os,{}),onClick:V,disabled:!n,children:"New"})}),!ct&&t(Nn,{allRulesLength:(S==null?void 0:S.length)??0,project:e,onChange:lt,selectedRules:rt,onUpdate:_}),S==null?void 0:S.map(A=>t(Cn,{project:e,rule:A,isSelected:p(A._id),onSelect:at},A._id)),b&&t(z,{padding:s.layout.gapHalf,justifyContent:"center",children:t(q,{})}),it&&h(z,{pt:s.layout.gapHalf,alignItems:"center",justifyContent:"center",flexDirection:"column",children:[u()&&t(ke,{type:"secondary",font:Q.font.small,span:!0,children:"No results for selected filters"}),!u()&&h(H,{children:[t(ke,{type:"secondary",font:Q.font.small,span:!0,children:"No active items"}),t(ds,{h:2}),t(js,{children:t(us,{href:"https://docs.currents.dev/guides/automation-rules",target:"_blank",rel:"noopener noreferrer",font:Q.font.small,children:t("img",{width:450,src:"/actions-banner.png",title:"Automate your workflows using Currents Actions",alt:"Automate your workflows using Currents Actions"})})})]})]})]})]})});function On(e){return e.length>8?`â¦${e.slice(-6)}`:e}function jn({project:e}){var p;const{path:s}=hs(),{pathname:n}=fs(),a=ms(),r=y.useMemo(()=>{const f=ps(n,{path:`${s}/:ruleId`,exact:!0}),d=f==null?void 0:f.params.ruleId;if(!(!d||d==="affected-tests"))return d},[n,s]),{data:l}=Qe({variables:{input:{orgId:e.orgId,projectId:e.projectId,ruleId:r}},skip:!r,fetchPolicy:"cache-first"});gs({currentProject:e,sideNavActiveSubItem:"actions"});const i=n.includes("/affected-tests"),c=y.useMemo(()=>{var d,u;const f=[{label:`${e.name??"Project"}`,link:bs(e.projectId),type:"project"},{label:"Actions",link:ue(e.projectId)}];if(r){const v=(u=(d=l==null?void 0:l.projectRule)==null?void 0:d.name)==null?void 0:u.trim();return[...f,{label:v||On(r),link:ee(e.projectId,r)}]}return i?[...f,{label:"Affected Tests",link:we(e.projectId)}]:f},[e.name,e.projectId,r,(p=l==null?void 0:l.projectRule)==null?void 0:p.name,i]);ys(c);const o=[{id:"actions",order:1,label:"Actions",icon:t(xs,{className:"size-3"}),path:ue(e.projectId)},{id:"affected-tests",order:2,label:"Affected Tests",icon:t(zs,{className:"size-3"}),path:we(e.projectId)}],g=n.includes("/affected-tests")?"affected-tests":"actions";return h(As,{children:[t(de,{children:h("title",{children:[e.name," Actions"]})}),t(ne,{className:"mb-8",value:g,onValueChange:f=>{const d=o.find(u=>u.id===f);d&&a.push(d.path)},children:t(ne.List,{children:Fe(o,"order").map(f=>
1t(ne.Trigger,{value:f.id,iconStart:f.icon,children:f.label},f.id))})}),h(vs,{children:[t(ae,{exact:!0,path:`${s}`,children:t(Mn,{})}),t(ae,{path:`${s}/affected-tests`,children:t(fn,{orgId:e.orgId,projectId:e.projectId})}),t(ae,{path:`${s}/:ruleId`,children:t(wn,{})})]})]})}const na=te(jn);export{na as ActionsRouter,na as default}; 2//# sourceMappingURL=actionsRouter-B3spFSJp.js.map
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.