1import{r as b,j as e,i as oe,L as de}from"./react-vendor-xjz46aeH.js";import{u as m,p as x,b as re}from"./index-DctxNkkm.js";import{z as B,K as Ne,m as we,E as ke}from"./index-DB-GErVi.js";import{P as Se}from"./PageHeader-BdDybfPf.js";import{P as Ae}from"./Pagination-CrLnsmAm.js";import{E as ae}from"./ErrorState-DlvwccLP.js";import{S as D}from"./StatCard-B91o18fs.js";import{S as Ce}from"./StatCardSkeleton-BW2z5c_5.js";import{T as Te}from"./TableSkeleton-C9Pu8LvF.js";import{D as De}from"./DateRangePicker-Ce2Wjv8W.js";import{a as Me}from"./dateRange-BnwWrnqN.js";import{u as Re}from"./useRecommendationFilterFields-DIo3HyeZ.js";import{d as Y,k as q}from"./tanstack-vendor-CK-H18W-.js";import{s as Ee}from"./recSections-ywQCVcei.js";import{r as _e,g as K,a as W}from"./recBadges-DKOkRq-w.js";import{R as Ie,C as $e,E as Oe,X as Le,Y as Pe,T as Ve,F as ze}from"./recharts-vendor-gU3RjD-X.js";import{I as Fe}from"./InfoTooltip-I_YM7wGk.js";import{G as Ue}from"./GroupedAccountDropdown-Bh-4E3aH.js";import{G as He}from"./GroupedTypeDropdown-DixluBFy.js";import"./sentry-vendor-B7Zxq--p.js";import"./CostInfoBanner-DabANHFh.js";import"./actionFailure-B9bV-6re.js";import"./date-vendor-CF6zyQJ7.js";import"./dateUtils-BLHMZBe5.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"53c0c37b9d0458a05694e8ed0430da9c4ec6eaca"};var s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="8dd1f033-4dfd-4e6d-9538-1ae628c91ef1",t._sentryDebugIdIdentifier="sentry-dbid-8dd1f033-4dfd-4e6d-9538-1ae628c91ef1")}catch{}})();const Ge={from:"date_from",to:"date_to",provider:"provider",cloudAccountId:"cloud_account_id",resourceType:"resource_type",category:"category",status:"status",verified:"verified",applied:"applied",viewed:"viewed",kind:"kind"};function J(t,{paged:s=!0}={}){const a={};for(const[r,o]of Object.entries(Ge))t[r]&&(a[o]=t[r]);return s&&(t.page&&(a.page=t.page),t.size&&(a.size=t.size)),a}const z=["raised","applied","dismissed","verifiedResolved"];function Ke(t,s){if(!Array.isArray(t))return[];if(s==="accumulated"){const r=Object.fromEntries(z.map(o=>[o,0]));return t.map(o=>{const c={date:o.date};for(const d of z)r[d]+=o[d]??0,c[d]=r[d];return c})}const a=[];for(let r=0;r<t.length;r+=7){const o=t.slice(r,r+7),c={date:o[0].date,end:o.at(-1).date};for(const d of z)c[d]=o.reduce((i,u)=>i+(u[d]??0),0);a.push(c)}return a}const We=new Set(["verified_adopted","verified_diverged","verified_gone"]);function Be(t){const s={tone:"done",word:"raised",date:t.raisedAt};let a={tone:"empty",word:"",date:null};t.actedAt&&(t.actedKind==="dismissed"?a={tone:"stop",word:t.dismissedUntil?"snoozed":"dismissed",date:t.actedAt}:a={tone:"done",word:t.actedKind==="auto_applied"?"auto":"applied",date:t.actedAt});let r={tone:"empty",word:"",date:null};return t.verifiedAt&&We.has(t.resolutionState)?r={tone:"verified",word:"resolved",date:t.verifiedAt}:t.verifiedAt&&t.resolutionState==="verified_reverted"?r={tone:"bad",word:"undone",date:t.verifiedAt}:t.verifiedAt&&t.resolutionState==="verified_unchanged"?r={tone:"bad",word:"checked",date:t.verifiedAt}:t.actedAt&&t.actedKind!=="dismissed"&&(r={tone:"pending",word:"checking",date:null}),[s,a,r]}const $={verified_adopted:{text:"Change confirmed",tone:"resolved"},verified_diverged:{text:"Changed differently",tone:"resolved"},verified_gone:{text:"Resource removed",tone:"removed"},verified_unchanged:{text:"Nothing changed",tone:"bad"},verified_reverted:{text:"Change undone",tone:"bad"}};function Ye(t){return $[t.resolutionState]?$[t.resolutionState]:t.status==="applied"?{text:"Awaiting a check",tone:"pending"}:{text:"Not checked yet",tone:"pending"}}const qe=new Set(["system.v1-engine","system.unknown","system.reconciler","verification-probe"]);function F(t){return t&&!qe.has(t)?` by ${t}`:""}function Je(t){switch(t.kind){case"created":return"Raised";case"applied":return`Applied${F(t.actor)}`;case"auto_applied":return"Applied automatically";case"dismissed":return`Dismissed${F(t.actor)}`;case"reopened":return"Reopened";case"closed":return"Closed";case"optimised":return"Resolved on its own";case"drifted":return"Came back after being resolved";case"status_changed":return`Status changed${F(t.actor)}`;case"reevaluated":{const s=$[t.details?.state];return s?`Verified: ${s.text.charAt(0).toLowerCase()}${s.text.slice(1)}`:"Re-checked"}default:return"Updated"}}const Qe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Xe(t){if(t<1e3)return String(t);const s=t/1e3;return`${s<100?String(Math.round(s*10)/10):String(Math.round(s))}k`}function E(t){if(!t)return"â";const s=new Date(t);return Number.isNaN(s.getTime())?"â":`${Qe[s.getUTCMonth()]} ${s.getUTCDate()}`}function ce(t,s){const a=t.recId??t.id,r=s?`/orgs/${s}`:"",o=new URLSearchParams;return t.status&&o.set("status",t.status),t.resourceUid?o.set("resource",t.resourceUid):t.resourceName&&o.set("search",t.resourceName),o.set("rec",a),`${r}/recommendations/${Ee(_e(t))}?${o.toString().replace(/\+/g,"%20")}`}function Ze(t){return t.kind==="created"?"raise":t.kind==="applied"||t.kind==="auto_applied"?"apply":t.kind==="reevaluated"?$[t.details?.state]?.tone==="bad"?"bad":"verify":t.kind==="reopened"||t.kind==="drifted"?"raise":"neutral"}function et(t){const s=new Date(t);return Number.isNaN(s.getTime())?String(t).slice(0,10):s.toISOString().slice(0,10)}function tt(t){const s=new Date(t);return Number.isNaN(s.getTime())?"":`${String(s.getUTCHours()).padStart(2,"0")}
1:${String(s.getUTCMinutes()).padStart(2,"0")}`}function st(t){const s=[];for(const a of t??[]){const r=et(a.at),o=s.at(-1);o&&o.day===r?o.events.push(a):s.push({day:r,events:[a]})}return s}function rt(t,{enabled:s=!0}={}){const a=J(t);return Y({queryKey:["recommendations","history","list",a],queryFn:()=>B.get("/recommendations/history",a),placeholderData:q,enabled:s})}function at(t){const s=J(t,{paged:!1});return Y({queryKey:["recommendations","history","summary",s],queryFn:()=>B.get("/recommendations/history/summary",s),placeholderData:q})}function nt(t,{enabled:s=!0}={}){const a=J(t);return Y({queryKey:["recommendations","history","events",a],queryFn:()=>B.get("/recommendations/activity",a),placeholderData:q,enabled:s})}const it="#3b82f6",ot="#10b981",dt="#94a3b8",ct="#22d3ee",U=[{key:"raised",name:"Raised",color:it},{key:"applied",name:"Applied",color:ot},{key:"dismissed",name:"Dismissed",color:dt},{key:"verifiedResolved",name:"Verified resolved",color:ct}],lt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function I(t){const[,s,a]=String(t).split("-");return`${lt[Number(s)-1]} ${Number(a)}`}function ut({active:t,payload:s,label:a,mode:r}){if(!t||!s?.length)return null;const o=s[0]?.payload?.end;return e.jsxs("div",{className:"bg-surface-elevated border border-border rounded-xl px-3.5 py-3 shadow-lg text-text-primary",children:[e.jsx("p",{className:"text-xs text-text-muted mb-1.5",children:r==="accumulated"?`By ${I(a)}`:`${I(a)} â ${I(o??a)}`}),s.map(c=>e.jsxs("p",{className:"text-[13px] mb-0.5",children:[e.jsx("span",{style:{color:c.color},className:"text-text-secondary",children:c.name}),": ",e.jsx("span",{className:"font-semibold text-text-primary tabular-nums",children:c.value})]},c.dataKey))]})}function mt(t){const s=t>50?20:t>10?5:1;return Math.max(s,Math.ceil(t*1.1/s)*s)}const pt=[{value:"accumulated",label:"Accumulated"},{value:"weekly",label:"Weekly"}];function xt({series:t,totals:s,subtitle:a}){const[r,o]=b.useState("accumulated"),c=b.useMemo(()=>Ke(t,r),[t,r]),d=r==="weekly";return e.jsxs("div",{className:"bg-surface border border-border-strong/60 rounded-xl shadow-card p-4 sm:p-5 mb-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-text-primary",children:"Recommendations over time"}),e.jsx("p",{className:"text-sm text-text-muted",children:a})]}),e.jsx("div",{className:"flex p-0.5 bg-surface-tertiary rounded-lg self-start shrink-0",role:"group","aria-label":"Chart mode",children:pt.map(i=>e.jsx("button",{type:"button","aria-pressed":r===i.value,onClick:()=>o(i.value),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-all ${r===i.value?"bg-surface shadow-sm text-text-primary font-bold":"text-text-muted hover:text-text-primary"}`,children:i.label},i.value))})]}),e.jsx("div",{className:"h-[220px]","data-testid":"history-chart",children:e.jsx(Ie,{width:"100%",height:"100%",children:e.jsxs($e,{data:c,margin:{top:10,right:24,left:0,bottom:0},accessibilityLayer:!1,children:[e.jsx("defs",{children:U.map(i=>e.jsxs("linearGradient",{id:`hist-${i.key}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:i.color,stopOpacity:.15}),e.jsx("stop",{offset:"95%",stopColor:i.color,stopOpacity:0})]},i.key))}),e.jsx(Oe,{strokeDasharray:"3 3",stroke:d?"rgba(148,163,184,0.18)":"rgba(148,163,184,0.1)"}),e.jsx(Le,{dataKey:"date",tickFormatter:I,tick:{fontSize:11,fill:"var(--color-text-muted, #6b7280)",fontWeight:500},tickLine:!1,axisLine:!1,interval:d?0:"equidistantPreserveStart",minTickGap:d?4:40,dy:8}),e.jsx(Pe,{allowDecimals:!1,tick:{fontSize:11,fill:"var(--color-text-muted, #6b7280)",fontWeight:500},tickLine:!1,axisLine:!1,width:44,dx:-4,tickFormatter:Xe,domain:[0,mt]}),e.jsx(Ve,{content:e.jsx(ut,{mode:r}),cursor:{stroke:"rgba(148,163,184,0.2)",strokeWidth:1}}),U.map(i=>e.jsx(ze,{type:"monotone",dataKey:i.key,name:i.name,stroke:i.color,fill:`url(#hist-${i.key})`,strokeWidth:2,dot:d?{r:3,fill:i.color,stroke:i.color,strokeWidth:1}:!1,activeDot:{r:4,fill:i.color,stroke:"#fff",strokeWidth:1.5}},i.key))]})})}),e.jsx("div",{className:"flex flex-wrap gap-x-5 gap-y-1 mt-3 text-xs text-text-secondary",children:U.map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"w-3.5 h-0.5 rounded-sm",style:{background:i.color}}),i.name,e.jsx("span",{className:"font-semibold text-text-primary tabular-nums",children:s?.[i.key]??0})]},i.key))})]})}const ht="The three steps each recommendation goes through. Raised: we found it. Acted: someone applied, dismissed or snoozed it. Verified: we checked your cloud account. Resolved means the issue is gone, Checked means nothing changed, Undone means the change was reversed, and Checking means the check has not run yet.",ft={done:"bg-success-600",stop:"bg-text-muted",verified:"bg-primary-600",bad:"bg-danger-500",pending:"border-2 border-dashed border-border-strong bg-transparent",empty:"bg-border-strong"};function gt({row:t}){const s=Be(t);return e.jsx("div",{className:"flex items-start w-fit mx-auto","aria-label":"Raised, acted, verified",children:s.map((a,r)=>
1e.jsxs("div",{className:"contents",children:[r>0&&e.jsx("span",{"data-connector":!0,className:`h-0.5 w-6 shrink-0 mt-1 ${a.tone==="empty"||a.tone==="pending"?"bg-border-strong":"bg-success-600"}`}),e.jsxs("span",{className:"grid justify-items-center gap-1 w-[72px]",children:[e.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${ft[a.tone]}`}),e.jsx("span",{className:"text-[10px] leading-none uppercase tracking-wider text-text-muted",children:a.word||" "}),e.jsx("span",{className:`text-xs leading-none tabular-nums ${a.date?"text-text-secondary":"text-text-muted"}`,children:E(a.date)})]})]},r))})}const ne={open:"bg-warning-600/10 text-warning-600",applied:"bg-success-600/10 text-success-600",dismissed:"bg-surface-tertiary text-text-muted",optimised:"bg-surface-tertiary text-text-secondary"},yt={resolved:"bg-primary-600/10 text-primary-600",removed:"bg-surface-tertiary text-text-secondary",bad:"bg-danger-500/10 text-danger-500",pending:"border border-dashed border-border-strong text-text-muted"},bt={resolved:"â ",removed:"â "};function vt({row:t}){const a=t.status==="dismissed"&&t.dismissedUntil?`Snoozed to ${E(t.dismissedUntil)}`:W(t.status);return e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded-md text-xs font-semibold whitespace-nowrap ${ne[t.status]??ne.dismissed}`,children:a})}function jt({rows:t,fmtCurrency:s}){const{orgID:a}=oe();return e.jsx("div",{className:"overflow-x-auto border border-border-strong/60 rounded-xl bg-surface",children:e.jsxs("table",{className:"w-full min-w-[820px] text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-tertiary/60 text-left text-[11px] uppercase tracking-wider text-text-muted",children:[e.jsx("th",{className:"px-3 py-2.5 font-semibold",children:"Recommendation"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold text-center",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:["Progress",e.jsx(Fe,{text:ht})]})}),e.jsx("th",{className:"px-3 py-2.5 font-semibold",children:"Status"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold",children:"Verification"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold text-right",children:"Savings"})]})}),e.jsx("tbody",{children:t.map(r=>{const o=Ye(r),c=r.resolutionState==="verified_gone";return e.jsxs("tr",{className:"border-t border-border align-middle hover:bg-primary-600/5",children:[e.jsxs("td",{className:"px-3 py-3",children:[e.jsx(de,{to:ce(r,a),className:"font-medium text-text-primary hover:text-primary-600",children:r.title}),e.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:[r.resourceName||r.resourceUid,r.resourceType,r.cloudAccountId,K(r.category)].filter(Boolean).join(" · ")})]}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(gt,{row:r})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(vt,{row:r})}),e.jsx("td",{className:"px-3 py-3",children:e.jsxs("span",{className:`inline-flex px-2 py-0.5 rounded-md text-xs font-semibold whitespace-nowrap ${yt[o.tone]}`,children:[bt[o.tone]??"",o.text]})}),e.jsx("td",{className:"px-3 py-3 text-right tabular-nums font-semibold whitespace-nowrap",children:e.jsxs("span",{className:c||r.status==="dismissed"?"text-text-secondary":"text-success-600",children:[c?"was ":"",s(r.savingsUsd),"/mo"]})})]},r.id)})})]})})}const Nt={raise:{cls:"bg-warning-600/10 text-warning-600",icon:"+"},apply:{cls:"bg-success-600/10 text-success-600",icon:"â"},verify:{cls:"bg-primary-600/10 text-primary-600",icon:"â"},bad:{cls:"bg-danger-500/10 text-danger-500",icon:"!"},neutral:{cls:"bg-surface-tertiary text-text-muted",icon:"·"}};function wt({events:t,fmtCurrency:s}){const{orgID:a}=oe(),r=st(t);return e.jsx("div",{className:"border border-border-strong/60 rounded-xl bg-surface",children:r.map((o,c)=>e.jsxs("section",{children:[e.jsxs("h3",{className:"px-4 pt-3 pb-1 text-[11px] uppercase tracking-wider font-semibold text-text-muted",children:[E(`${o.day}T12:00:00Z`),c===0&&e.jsx("span",{className:"ml-2 normal-case tracking-normal font-normal",children:"· times in UTC"})]}),e.jsx("ul",{children:o.events.map(d=>{const i=Nt[Ze(d)];return e.jsx("li",{className:"border-t border-border",children:e.jsxs(de,{to:ce(d,a),className:"group grid grid-cols-[52px_28px_minmax(0,1fr)_auto] gap-2.5 items-start px-4 py-2.5 hover:bg-primary-600/5 focus-visible:outline-none focus-visible:bg-primary-600/5",children:[e.jsx("time",{className:"text-xs text-text-muted tabular-nums pt-1",children:tt(d.at)}),e.jsx("span",{className:`w-6 h-6 rounded-full grid place-items-center text-xs font-bold ${i.cls}`,"aria-hidden":"true",children:i.icon}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm text-text-primary",children:[Je(d)," · ",e.jsx("span",{className:"font-medium group-hover:text-primary-600",children:d.title})]}),e.jsx("p",{className:"text-xs text-text-muted truncate",children:[d.resourceName,d.resourceType,d.cloudAccountId].filter(
1Boolean).join(" · ")})]}),e.jsxs("span",{className:"text-sm font-semibold tabular-nums text-text-secondary whitespace-nowrap",children:[s(d.savingsUsd),"/mo"]})]})},d.id)})})]},o.day))})}const M=t=>t?t.split(",").filter(Boolean):[];function y({children:t,className:s="h-3.5 w-3.5 shrink-0"}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:s,"aria-hidden":"true",children:t})}const k={category:e.jsxs(y,{children:[e.jsx("path",{d:"M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8z"}),e.jsx("circle",{cx:"7.5",cy:"7.5",r:"1.5"})]}),cloud:e.jsxs(y,{children:[e.jsx("path",{d:"M17.5 19a4.5 4.5 0 1 0-1.4-8.78A6 6 0 1 0 6 18.3"}),e.jsx("path",{d:"M6 19h11.5"})]}),account:e.jsxs(y,{children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"}),e.jsx("path",{d:"M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3"})]}),type:e.jsxs(y,{children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"})]}),status:e.jsxs(y,{children:[e.jsx("circle",{cx:"6",cy:"5",r:"2"}),e.jsx("circle",{cx:"18",cy:"5",r:"2"}),e.jsx("circle",{cx:"12",cy:"20",r:"2"}),e.jsx("path",{d:"M12 18v-5M12 13c0-3-6-3-6-6M12 13c0-3 6-3 6-6"})]}),progress:e.jsxs(y,{children:[e.jsx("circle",{cx:"6",cy:"19",r:"2"}),e.jsx("circle",{cx:"18",cy:"5",r:"2"}),e.jsx("path",{d:"M8 19h6.5a3.5 3.5 0 0 0 0-7h-5a3.5 3.5 0 0 1 0-7H16"})]})},kt={idle:e.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"}),rightsizing:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M15 3h6v6M9 21H3v-6"}),e.jsx("path",{d:"M21 3l-7 7M3 21l7-7"})]}),orphan:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 0 1 4 8"}),e.jsx("path",{d:"M8 12h4M3 3l18 18"})]}),schedule:e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 7v5l3 2"})]}),discount:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M19 5 5 19"}),e.jsx("circle",{cx:"6.5",cy:"6.5",r:"2.5"}),e.jsx("circle",{cx:"17.5",cy:"17.5",r:"2.5"})]}),compliance:e.jsx("path",{d:"M12 3l7 3v5c0 4.5-3 8.5-7 10-4-1.5-7-5.5-7-10V6l7-3z"}),governance:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M3 21h18M5 21V10M19 21V10M9 21V10M15 21V10"}),e.jsx("path",{d:"M12 3 3 8h18z"})]})};function St(t){const s=kt[t]??k.category.props.children;return e.jsx(y,{className:"h-3.5 w-3.5 shrink-0 text-text-muted",children:s})}const ie={aws:"AWS",gcp:"Google Cloud",azure:"Azure"},H=[{key:"viewed",title:"Seen",options:[{value:"",label:"Any"},{value:"yes",label:"Seen by someone"},{value:"no",label:"Not seen yet"}]},{key:"applied",title:"Acted on",options:[{value:"",label:"Any"},{value:"yes",label:"Applied"},{value:"no",label:"Not applied"}]},{key:"verified",title:"Verified",options:[{value:"",label:"Any"},{value:"yes",label:"Verified resolved"},{value:"no",label:"Not verified yet"}]}];function G({options:t,selected:s,onToggle:a}){return e.jsxs("div",{className:"py-1",children:[t.map(r=>e.jsxs("button",{type:"button",onClick:()=>a(r.value),className:"w-full text-left px-3 py-1.5 text-xs transition-colors flex items-center gap-2 text-text-primary hover:bg-surface",children:[e.jsx("input",{type:"checkbox",checked:s.includes(r.value),readOnly:!0,className:"h-3.5 w-3.5 rounded border-border-strong accent-primary-600 pointer-events-none"}),r.icon,e.jsx("span",{className:"truncate",children:r.label})]},r.value)),t.length===0&&e.jsx("p",{className:"px-3 py-2 text-xs text-text-muted",children:"No values yet"})]})}function A({label:t,icon:s,summary:a,count:r=0,onClear:o,width:c="w-64",children:d}){const i=r>0,[u,g]=b.useState(!1),h=b.useRef(null);return b.useEffect(()=>{if(!u)return;const v=N=>{h.current&&!h.current.contains(N.target)&&g(!1)},S=N=>N.key==="Escape"&&g(!1);return document.addEventListener("mousedown",v),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",S)}},[u]),e.jsxs("div",{ref:h,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":u,title:i?`${t}: ${a}`:void 0,onClick:()=>g(v=>!v),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border transition-colors ${i||u?"border-primary-600/40 bg-primary-600/10 text-primary-600":"border-border-strong bg-surface-tertiary text-text-secondary hover:border-primary-600/40 hover:text-text-primary"}`,children:[s,e.jsx("span",{className:"whitespace-nowrap",children:t}),e.jsx("span",{"aria-hidden":!i,className:`inline-flex items-center justify-center min-w-[1.25rem] h-4 px-1 rounded-full text-[10px] font-semibold tabular-nums ${i?"bg-primary-600 text-white":"invisible"}`,children:i?r:0}),e.jsx("svg",{className:`w-3 h-3 shrink-0 transition-transform ${u?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})]}),u&&e.jsxs("div",{role:"dialog","aria-label":t,className:`absolute left-0 z-50 mt-2 ${c} max-w-[calc(100vw-2rem)] rounded-xl border border-border-strong bg-surface-elevated shadow-xl overflow-hidden`,children:[e.jsx("div",{className:"max-h-80 overflow-y-auto",children:d}),i&&e.jsxs("div",{className:"border-t border-border-strong px-3 py-2 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted tabular-nums",children:[r," selected"]}),e.jsxs("button",{type:"button",onClick:o,className:"inline-flex items-center gap-1 text-xs font-medium text-primary-500 hover:text-primary-600 transition-colors",children:[e.jsx(y,{className:"h-3 w-3 shrink-0",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})}),"Clear"]})]})]})]})}function R(t,s){return t.map(s).join(", ")}function At({values:t,set:s,fields:a}){const r=M(t.category),o=M(t.provider),c=M(t.cloudAccountId),d=M(t.resourceType),i=M(t.status),u=(n,l,C)=>s(n,(l.includes(C)?l.filter(L=>L!==C):[...l,C]).join(",")),g=H.filter(n=>t[n.key]).map(n=>({...n,chosen:n.options.find(l=>l.value===t[n.key])?.label})),h=b.useMemo(()=>a?.cloudAccounts??[],[a]),v=b.useMemo(()=>Object.fromEntries(h.map(n=>[n.id,n.name||n.id])),[h]),S=b.useMemo(()=>{const n={};for(const l of h)n[l.provider]||(n[l.provider]=[]),n[l.provider].push(l);return{providers:a?.providers??[],byProvider:n}},[h,a]),N=r.length+o.length+c.length+d.length+i.length>0||g.length>0,O=()=>{for(const n of["category","provider","cloudAccountId","resourceType","status","verified","applied","viewed"])s(n,"")};return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-5",children:[e.jsx(A,{label:"Category",icon:k.category,count:r.length,summary:R(r,K),onClear:()=>s("category",""),children:e.jsx(G,{options:(a?.categories??[]).map(n=>({value:n,label:K(n),icon:St(n)})),selected:r,onToggle:n=>u("category",r,n)})}),e.jsx(A,{label:"Cloud",icon:k.cloud,count:o.length,summary:R(o,n=>ie[n]??n.toUpperCase()),onClear:()=>s("provider",""),width:"w-56",children:e.jsx(G,{options:(a?.providers??[]).map(n=>({value:n,label:ie[n]??n.toUpperCase(),icon:e.jsx(Ne,{provider:n,className:"w-4 h-4 shrink-0"})})),selected:o,onToggle:n=>u("provider",o,n)})}),e.jsx(A,{label:"Account",icon:k.account,count:c.length,summary:R(c,n=>v[n]??n),onClear:()=>s("cloudAccountId",""),width:"w-72",children:e.jsx(Ue,{inline:!0,selectedIds:new Set(c),groupedData:S,onChange:n=>s("cloudAccountId",[...n].join(","))})}),e.jsx(A,{label:"Type",icon:k.type,count:d.length,summary:R(d,n=>n),onClear:()=>s("resourceType",""),width:"w-72",children:e.jsx(He,{inline:!0,selectedTypes:new Set(d),availableTypes:a?.resourceTypes??[],onChange:n=>s("resourceType",[...n].join(","))})}),e.jsx(A,{label:"Status",icon:k.status,count:i.length,summary:R(i,W),onClear:()=>s("status",""),width:"w-56",children:e.jsx(G,{options:(a?.statuses??[]).map(n=>({value:n,label:W(n)})),selected:i,onToggle:n=>u("status",i,n)})}),e.jsx(A,{label:"Progress",icon:k.progress,count:g.length,summary:g.map(n=>n.chosen).join(" · "),onClear:()=>
1H.forEach(n=>s(n.key,"")),width:"w-80",children:e.jsxs("div",{className:"py-1",children:[H.map(n=>e.jsxs("fieldset",{className:"px-3 py-2",children:[e.jsx("legend",{className:"text-[10px] font-semibold uppercase tracking-wider text-text-muted mb-1",children:n.title}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.options.map(l=>e.jsx("button",{type:"button","aria-pressed":(t[n.key]||"")===l.value,onClick:()=>s(n.key,l.value),className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${(t[n.key]||"")===l.value?"border-primary-600/40 bg-primary-600/10 text-primary-600 font-medium":"border-border-strong text-text-secondary hover:text-text-primary"}`,children:l.label},l.value))})]},n.key)),e.jsx("p",{className:"px-3 pt-1 pb-1 text-[11px] leading-snug text-text-muted",children:"Verified resolved: we confirmed on your cloud account that the change is in place, the resource changed another way, or it no longer exists."})]})}),N&&e.jsxs("button",{type:"button",onClick:O,className:"inline-flex items-center gap-1.5 px-1 py-1.5 text-xs font-medium text-primary-500 hover:text-primary-600 transition-colors ml-1",children:[e.jsxs(y,{children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),"Reset filters"]})]})}const Ct=[{value:"table",label:"Table"},{value:"timeline",label:"Timeline"}];function Tt({view:t,onChange:s}){return e.jsx("div",{className:"flex items-center bg-surface-tertiary rounded-full p-0.5",role:"group","aria-label":"List view",children:Ct.map(a=>e.jsx("button",{type:"button","aria-pressed":t===a.value,onClick:()=>s(a.value),className:`min-w-[4.5rem] px-3 py-1.5 text-xs font-medium rounded-full text-center transition-all ${t===a.value?"bg-surface text-primary-600 shadow-sm":"text-text-muted hover:text-text-primary"}`,children:a.label},a.value))})}const Dt=90,Mt=366;function ts(){const{fmtCurrency:t,fmtCurrencyCompact:s}=we(),a=b.useMemo(()=>Me(Dt),[]),[r,o]=m("from",x.withDefault(a.from)),[c,d]=m("to",x.withDefault(a.to)),[i,u]=m("provider",x.withDefault("")),[g,h]=m("account",x.withDefault("")),[v,S]=m("type",x.withDefault("")),[N,O]=m("category",x.withDefault("")),[n,l]=m("status",x.withDefault("")),[C,L]=m("verified",x.withDefault("")),[le,ue]=m("applied",x.withDefault("")),[me,pe]=m("viewed",x.withDefault("")),[Q,xe]=m("view",x.withDefault("table")),[X,T]=m("page",re.withDefault(1)),[Z,he]=m("size",re.withDefault(20)),ee={provider:i,cloudAccountId:g,resourceType:v,category:N,status:n,verified:C,applied:le,viewed:me},te={from:r,to:c,...ee},se={...te,page:X,size:Z},j=Q==="timeline",fe={provider:u,cloudAccountId:h,resourceType:S,category:O,status:l,verified:L,applied:ue,viewed:pe},ge=(w,V)=>{fe[w](V||null),T(1)},_=at(te),ye=rt(se,{enabled:!j}),be=nt(se,{enabled:j}),{data:ve}=Re(),f=j?be:ye,P=j?f.data?.events:f.data?.items,p=_.data,je=`Raised, applied, dismissed and verified resolved, ${E(`${r}T12:00:00Z`)} â ${E(`${c}T12:00:00Z`)}`;return e.jsxs("div",{children:[e.jsx(Se,{title:"Recommendations Overview",subtitle:"Everything raised, applied, dismissed and verified across your organisation.",action:e.jsx(De,{from:r,to:c,onChange:(w,V)=>{o(w),d(V),T(1)},clearable:!1,maxDays:Mt,size:"sm"})}),e.jsx(At,{values:ee,set:ge,fields:ve}),_.isError?e.jsx(ae,{title:"Failed to load the lifecycle summary",error:_.error,onRetry:_.refetch}):p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4 mb-6","data-testid":"history-cards",children:[e.jsx(D,{label:"Raised",value:String(p.raised),sub:"new in the period"}),e.jsx(D,{label:"Applied",value:String(p.applied),sub:`${s(p.appliedSavingsUsd)}/mo estimated`}),e.jsx(D,{label:"Dismissed",value:String(p.dismissed),sub:`${p.snoozed} snoozed`}),e.jsx(D,{label:"Verified resolved",value:String(p.verifiedResolved),sub:"confirmed on your cloud account",info:"Recommendations we checked on your cloud account and confirmed are no longer an open issue: the change we recommended is in place, the resource was changed another way, or it no longer exists. This page counts every recommendation, including ones below the minimum-savings threshold, so it can be higher than the Verified resolved card on the Savings page.",infoPlacement:"left"}),e.jsx(D,{label:"Savings confirmed",value:s(p.confirmedSavingsUsd),title:t(p.confirmedSavingsUsd),sub:"per month"})]}),e.jsx(xt,{series:p.series,totals:p,subtitle:je})]}):e.jsx(Ce,{count:5,className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 ga
1p-4 mb-6"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-primary",children:j?"Events":"Recommendations"}),e.jsx(Tt,{view:Q,onChange:w=>{xe(w),T(1)}}),f.data&&e.jsxs("span",{className:"ml-auto text-xs text-text-muted tabular-nums",children:[f.data.total," ",j?"events":"recommendations"]})]}),f.isError?e.jsx(ae,{title:"Failed to load the recommendation lifecycle",error:f.error,onRetry:f.refetch}):f.data?P?.length?e.jsxs(e.Fragment,{children:[j?e.jsx(wt,{events:P,fmtCurrency:t}):e.jsx(jt,{rows:P,fmtCurrency:t}),e.jsx(Ae,{page:X,hasMore:f.data.hasMore,total:f.data.total,label:j?"events":"recommendations",onPageChange:T,pageSize:Z,onPageSizeChange:w=>{he(w),T(1)}})]}):e.jsx(ke,{message:"Nothing happened to a recommendation in this period with these filters."}):e.jsx(Te,{rows:6})]})}export{ts as default};
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.