1import{G as b,u as f,j as t,ac as j,ae as v,w as x,x as p,ab as k,r as l,ia as P}from"./index-DCYDlreI-ms8gbr5h.js";import{o as C}from"./noc-detail-window-uU39-Yjg.js";import{NocTriggerSparkline as E}from"./Noc2dSpecialCharts-DdOkgNcZ.js";import{P as I}from"./plus-Cg7ahvLS.js";import"./use-chart-theme-BuXsx_-B.js";import"./linesGL-qSIj7KZu.js";const w=b("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);const m=b("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),N="noc-pinned-triggers",u=8;function d(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(N);if(!e)return[];const s=JSON.parse(e);return Array.isArray(s)?s.filter(i=>typeof i=="string"):[]}catch{return[]}}function g(e){typeof window>"u"||(window.localStorage.setItem(N,JSON.stringify(e)),window.dispatchEvent(new CustomEvent("noc-pins-changed")))}function y(){const[e,s]=l.useState(()=>d());l.useEffect(()=>{const n=()=>s(d());return window.addEventListener("noc-pins-changed",n),window.addEventListener("storage",n),()=>{window.removeEventListener("noc-pins-changed",n),window.removeEventListener("storage",n)}},[]);const i=l.useCallback(n=>{const r=d();r.includes(n)||r.length>=u||g([...r,n])},[]),o=l.useCallback(n=>{g(d().filter(r=>r!==n))},[]),c=l.useCallback(n=>{const r=d();r.includes(n)?g(r.filter(h=>h!==n)):r.length<u&&g([...r,n])},[]),a=l.useCallback(n=>e.includes(n),[e]);return{pins:e,pin:i,unpin:o,toggle:c,isPinned:a,isFull:e.length>=u}}const A={aws:"#FF9900",azure:"#0078D4",gcp:"#4285F4",oci:"#C74634",oracle:"#C74634",mongodb:"#00ED64",platform:"#94A3B8"},O={aws:"text-orange-400",azure:"text-sky-400",gcp:"text-blue-400",oci:"text-red-400",oracle:"text-red-400",mongodb:"text-emerald-400",platform:"text-slate-400"};function D(e){if(typeof e=="number")return e;if(typeof e=="string"&&Number.isFinite(Number(e)))return Number(e)}function L({status:e}){return e==="failed"?t.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500 inline-block"}):e==="ok"||e==="succeeded"?t.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500 inline-block"}):t.jsx("span",{className:"h-2 w-2 rounded-full bg-slate-500 inline-block"})}function S({item:e,onUnpin:s}){const{t:i}=f("pages"),o=A[e.provider]??"#94a3b8",c=O[e.provider]??"text-slate-400",a=D(e.threshold),n=e.history[e.history.length-1]?.value??null,r=e.lastExecutedAt?new Date(e.lastExecutedAt).toLocaleTimeString():"â";return t.jsx(x,{className:"rounded-2xl bg-background border-2 cursor-pointer transition-all duration-150 hover:scale-[1.02] hover:shadow-lg",style:{borderColor:`${o}66`},onClick:()=>{C({type:"triggers",triggerId:e.triggerId})},"data-testid":`watchlist-${e.triggerId}`,children:t.jsxs(p,{className:"p-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:`text-sm font-semibold truncate ${c}`,children:e.name}),t.jsxs("div",{className:"text-[10px] text-muted-foreground truncate",children:[e.provider," · ",e.type,e.severity?` · ${e.severity}`:""]})]}),t.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),s()},title:i("noc.watchlist.unpin","Despinar"),className:"text-muted-foreground hover:text-foreground transition shrink-0","data-testid":`watchlist-unpin-${e.triggerId}`,children:t.jsx(w,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{className:"h-12",children:e.history.length>0?t.jsx(E,{history:e.history,threshold:a,height:48,color:o}):t.jsx("div",{className:"h-full rounded bg-muted/20 flex items-center justify-center text-[10px] text-muted-foreground",children:i("noc.watchlist.no_executions","sem execuções")})}),t.jsxs("div",{className:"flex items-center justify-between mt-2 text-[10px] text-muted-foreground",children:[t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(L,{status:e.lastExecutionStatus}),r]}),n!==null&&t.jsxs("span",{className:"tabular-nums",children:[t.jsx("b",{className:"text-foreground",children:n}),a!==void 0?` / ${a}`:""]})]})]})})}function $({enabled:e=!0}){const{t:s}=f("pages"),{token:i}=j(),{pins:o,unpin:c}=y(),a=v({queryKey:["noc","watchlist",o],queryFn:()=>P(i,o,30),enabled:e&&!!i&&o.length>0,refetchInterval:2e4});if(o.length===0)return t.jsx(x,{className:"rounded-2xl bg-background border-dashed border-border/60",children:t.jsxs(p,{className:"p-3 text-center text-xs text-muted-foreground flex items-center justify-center gap-2",children:[t.jsx(m,{className:"h-3.5 w-3.5"}),s("noc.watchlist.empty.intro","Nenhum gatilho pinado. Abra os detalhes de um trigger e clique em"),t.jsx(I,{className:"h-3.5 w-3.5 inline"}),s("noc.watchlist.empty.action","Pinar pra acompanhar aqui.")]})});const n=a.data?.items??[];return t.jsx(x,{className:"rounded-2xl bg-background",children:t.jsxs(p,{className:"p-3",children:[t.jsx("div",{className:"flex items-center justify-between mb-2",children:t.jsxs("div",{className:"text-xs uppercase tracking-wider text-muted-foreground font-semibold flex items-center gap-2",children:[t.jsx(m,{className:"h-3.5 w-3.5"}),s("noc.watchlist.title","Watchlist de gatilhos"),t.jsxs(k,{variant:"outline",className:"text-[10px]",children:[o.length,"/",u]})]})}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2",children:[n.map(r=>
1t.jsx(S,{item:r,onUnpin:()=>c(r.triggerId)},r.triggerId)),n.length===0&&a.isLoading&&t.jsx("div",{className:"col-span-full text-center text-xs text-muted-foreground py-6",children:s("noc.loading")})]})]})})}function z({triggerId:e}){const{t:s}=f("pages"),{isPinned:i,toggle:o,isFull:c}=y(),a=i(e),n=!a&&c;return t.jsxs("button",{type:"button",onClick:()=>o(e),disabled:n,title:a?s("noc.watchlist.unpin_aria","Remover do watchlist do NOC"):c?s("noc.watchlist.pin_full",{limit:u,defaultValue:"Watchlist cheio ({{limit}}). Despine algum primeiro."}):s("noc.watchlist.pin_aria","Pinar no watchlist do NOC"),className:`inline-flex items-center gap-1 rounded-lg border px-2 py-1 text-xs transition ${a?"border-cyan-500/50 bg-cyan-500/10 text-cyan-400":n?"border-border bg-background/30 text-muted-foreground/40 cursor-not-allowed":"border-border bg-background/30 text-muted-foreground hover:bg-foreground/5"}`,"data-testid":"trigger-pin-button",children:[a?t.jsx(w,{className:"h-3.5 w-3.5"}):t.jsx(m,{className:"h-3.5 w-3.5"}),a?s("noc.watchlist.pinned","Pinado"):s("noc.watchlist.pin_action","Pinar no NOC")]})}export{u as PIN_LIMIT,z as TriggerPinButton,$ as TriggerWatchlist,y as usePinnedTriggers};
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.