import{j as s,ap as T,e as x,Q as k,af as N,R as o,J as F,k as R,aq as D,E as Q,ar as B,as as M,a9 as S,p as m,h as f,g as y,i as j}from"./app-BgLa5dit.js";import{S as q}from"./nO4MXtNL.chunk.js";import{P as O}from"./yL1Poddl.chunk.js";import{g as V,u as W}from"./Brw8lpR5.chunk.js";import{D as z}from"./C8tTfnnp.chunk.js";import{D as G}from"./DPl9_NPk.chunk.js";import"./HrByhRZi.chunk.js";import"./CY0zrGLk.chunk.js";import"./0GREfvNX.chunk.js";const $="_row_1cgbq_1",J="_cell_1cgbq_4",_={row:$,cell:J},K={table:"w-100",header:"fw-semibold py-1",headerCell:"py-1 px-2",row:_.row,cell:`d-flex align-items-center border-end border-light px-2 ${_.cell}`};function U(t){return[{Header:"Type",id:"type",accessor:e=>e,Cell:({value:e})=>{if(e._index==="video")return e.masterType==="Clip"?s.jsx("div",{children:"Clip"}):s.jsx("div",{children:"Video"});if(e._index==="topic")return s.jsx("div",{children:"Topic"});if(e._index==="dashboard")return s.jsx("div",{children:"Curated Topic"})},width:10},{Header:"ID",id:"ID",accessor:e=>e.id,Cell:({value:e})=>s.jsx("div",{className:"text-truncate",children:e}),width:10},{Header:"Name",id:"name",accessor:e=>e.name,Cell:({value:e})=>s.jsx("div",{children:e}),width:30},{Header:"Stage",id:"stage",accessor:e=>e.stage,Cell:({value:e})=>s.jsx("div",{children:x.formatStageName(e)}),width:10},{Header:"Action",id:"action",accessor:e=>e,Cell:({value:e})=>s.jsx("div",{children:s.jsx("button",{className:"btn btn-link p-0",onClick:()=>t(e),children:s.jsx(k,{svg:N})})}),width:5}]}function Y(t){return s.jsx(T,{data:t.results,columns:U(t.onClickOpen),theme:K})}const X="_presentationFilter_1fev9_1",Z={presentationFilter:X},u=10;function ce(t){const[e,I]=o.useState([]),[r,v]=o.useState(""),[c,p]=o.useState(!1),[d,C]=o.useState(F.get(V(t.pipelineId))),{selectedPresentation:i,presentations:g,setPresentation:L,isLoading:b}=W({presentationId:d},"dashboard","curated_topic",t.pipelineId),h=R();async function A(a){const[n,H,P]=await Promise.all([h(m.getVideos({searchQuery:a,filters:[],limit:u})),h(m.getClassifications({searchQuery:a,presentationId:i==null?void 0:i.id,filters:[],limit:u,pipelineId:t.pipelineId})),h(m.getDashboards({searchQuery:a,presentationId:i==null?void 0:i.id,filters:[],limit:u}))]);I([...n.data.map(l=>({...l,_index:"video"})),...P.data.map(l=>({...l,_index:"dashboard"})),...H.data.map(l=>({...l,_index:"topic"}))]),p(!1)}function w(a){L(d);const n=t.pipelineId==="clickview"?{application:j.ASSEMBLY_LINE,action:x.mapStageToAction(a.stage),params:{presentationId:d}}:{application:j.STREAMABLE_PIPELINE,action:x.mapStageToAction(a.stage),params:{presentationId:d}};if(a._index!=="dashboard"&&[f.AssemblyLine.REVIEW_TOPICS,f.AssemblyLine.PUBLISHED_TOPICS].includes(n.action)){y.trigger(n),t.closePopup();return}n.params.query=a.id.toString(),y.trigger(n),t.closePopup()}const E=o.useCallback(D.debounce(a=>A(a),300),[i==null?void 0:i.id]);return o.useEffect(()=>{if(r){p(!0),E(r);return}p(!1)},[r,i==null?void 0:i.id]),s.jsxs(Q,{title:"Search",closePopup:t.closePopup,size:"xl",showLoadingSpinner:b,backdrop:"static",children:[!b&&g.length>1&&s.jsx("div",{className:`mb-2 ${Z.presentationFilter}`,children:s.jsx(O,{stage:"curated_topic",presentations:g,setPresentation:C,selectedPresentation:i,objectType:"dashboard"})}),s.jsx(q,{name:"global-assembly-line-search",placeholder:"Search for a video or topic",setQuery:v,query:r,autoFocus:!0}),s.jsxs("div",{className:"my-2",children:[c&&s.jsx("div",{className:"text-center p-5 mt-5",children:s.jsx(B,{as:"div",animation:"border",role:"status"})}),!c&&r&&!e.length&&s.jsx("div",{className:"pb-5",children:s.jsx(G,{})}),!c&&!r&&!e.length&&s.jsx("div",{className:"pb-5",children:s.jsx(z,{})}),!c&&!!e.length&&s.jsx(M.Scrollbars,{autoHeight:!0,autoHeightMin:500,autoHeightMax:500,children:s.jsx(Y,{results:e,onClickOpen:w})})]}),s.jsx(S,{children:s.jsx(S.Submit,{variant:"dark",text:"Done",onClick:t.closePopup,disabled:!1})})]})}export{ce as AssemblyLineGlobalSearchView};
//# sourceMappingURL=Dz25-NBs.chunk.js.map
