import{R as u,i as h,h as _,a2 as f,k as e,v as x,q as g,B as E}from"./entry_page.js";import{d as y,E as C,a as v}from"./Dashboard.EnterpriseViewOnlyPreset.hOZR46Qg.js";import{w as a,g as R}from"./Dashboard.utils.0p-tEVNs.js";import{F as S}from"./Dashboard.consts.BpCQqH5Z.js";import"./Search.BNBTqs0I.js";import"./ErrorBoundary.xJor3Ppq.js";import"./ArrowBroadUnderbarDown.wq6id2ca.js";const A="Open in Search",w=g(E)`
    max-width: fit-content;
    font-size: ${x.fontSize};
    align-content: flex-end;
    place-self: end;
    grid-column: 2;
    grid-row: 4;
    bottom: 8px;
`,k=({dashboardDefinition:t})=>{const r=u.useRef(),n=h(),d=u.useCallback(i=>{r.current=i},[]);return _.useEffect(()=>{a('[data-input-id="errors_tab_input"][data-input-type="input.timerange"]',"#errors_tab_description_viz"),a('[data-input-id="errors_type_input"][data-input-type="input.multiselect"]',"#errors_tab_errors_list_viz"),a("#open_search_error_events_tab_with_types","#errors_tab_errors_list_viz")},[]),_.useEffect(()=>{if(!r?.current)return()=>{};const m=f.create({search:`index=_internal source=*${n.meta.restRoot}* log_level=ERROR | dedup exc_l | table exc_l`,earliest_time:"0",latest_time:"now"},{cache:!0,cancelOnUnload:!0}).getResults().subscribe(c=>{if(c?.results?.length){const o=JSON.parse(JSON.stringify(t));o.inputs.errors_type_input.options.items=[{label:"All",value:"*"}],c.results.sort((s,b)=>{const p=s.exc_l.toUpperCase(),l=b.exc_l.toUpperCase();return p<l?-1:p>l?1:0}).forEach(s=>o.inputs.errors_type_input.options.items.push({label:s.exc_l,value:`"${s.exc_l}"`})),r.current?.updateDefinition(o)}});return()=>{m.unsubscribe()}},[t,n.meta.restRoot,r]),t?e.jsx(y.DashboardContextProvider,{preset:C,initialDefinition:t,featureFlags:S,children:e.jsxs(e.Fragment,{children:[e.jsx(w,{id:"open_search_error_events_tab_with_types",label:A,openInNewContext:!0,onClick:()=>document.querySelector('#errors_tab_errors_list_viz [data-test="open-search-button"]')?.click()}),e.jsx(v.DashboardCore,{width:"100%",height:"auto",actionMenus:R("error"),dashboardCoreApiRef:d})]})}):null};export{k as ErrorDashboard,k as default};
