import{d as N,a as r,o,I as L,e,E as d,b as p,_ as U,Y as A,f as h,G as q,L as B,p as z,u as F,j as T,i as D,k as E,t as i,g as f,h as V,w as M,F as G,r as Y}from"./JQJBiNWj.js";import H from"./3oa0FK2h.js";import{_ as J}from"./BtEXx3og.js";const K={class:"text-2xl"},Q={class:"grow pt-0.5"},R={key:0},W=N({__name:"Message",props:{severity:{default:"info"},closable:{type:Boolean,default:!1}},emits:["close"],setup(n,{emit:b}){const c=b;function y(){c("close")}return(a,g)=>{const s=U;return o(),r("div",{class:"w-full flex p-5 gap-4",style:L({backgroundColor:a.severity==="danger"?"#fde0db":a.severity==="info"?"#d4e5ff":a.severity==="success"?"#d6fbd5":"#fff5c2"})},[e("div",K,[a.severity==="info"?(o(),p(s,{key:0,name:"material-symbols:info",class:"text-blue-500"})):d("",!0),a.severity==="warning"?(o(),p(s,{key:1,name:"material-symbols:warning",class:"text-black"})):d("",!0),a.severity==="danger"?(o(),p(s,{key:2,name:"material-symbols:cancel",class:"text-red-500"})):d("",!0),a.severity==="success"?(o(),p(s,{key:3,name:"material-symbols:check-circle",class:"text-green-500"})):d("",!0)]),e("div",Q,[A(a.$slots,"default")]),a.closable?(o(),r("div",R,[e("button",{class:"text-xl",type:"button","aria-label":"Fechar a messagem alerta",onClick:y},[h(s,{name:"material-symbols:close-rounded",class:q(a.severity==="danger"?"text-red-500":a.severity==="info"?"text-blue-500":a.severity==="success"?"text-green-500":"text-black")},null,8,["class"])])])):d("",!0)],4)}}}),X=Object.assign(W,{__name:"UiMessage"}),Z={class:"flex flex-col gap-5"},ee={class:"base-grid grid-cols-2 max-md:grid-cols-1"},se={class:"flex flex-col"},te={class:"flex flex-col"},ae={class:"flex flex-col"},oe={class:"flex flex-col"},le={key:0,"data-status":""},re={key:1,"data-status":""},ne={key:0},ie={class:"w-full rounded-t border border-b-0 px-2 py-1"},de={"data-errors-count":""},ce={class:"flex p-2 border-b text-sm space-x-2 items-center hover:bg-gray-100 justify-between"},ue={class:"flex"},me={class:"list-disc"},fe=N({__name:"ImportProgress",props:B({jobId:{},toastPending:{default:()=>{}},fileName:{default:()=>{}},planilha:{default:()=>{}}},{pending:{type:Boolean,default:!0},pendingModifiers:{}}),emits:B(["success"],["update:pending"]),setup(n,{emit:b}){const c=z(),y=b,a=F(n,"pending"),g=T(!1),s=D.core.getImportProgress(n.jobId),O=l=>l?Object.entries(l).map(([t,u])=>({line:t,errors:u})):[];return E(()=>s==null?void 0:s.readyState,l=>{var u;if(s.error)return;if(g.value=!1,l!=="Closed"){a.value=!0;return}a.value=!1;const t=!!Object.keys(((u=s==null?void 0:s.data)==null?void 0:u.errors)??{}).length;if(n.toastPending&&c.remove(n.toastPending),c.add(t?{severity:"error",life:1e4,summary:"Erro",detail:"A planilha foi processada, porém erros foram encontrados. Verifique linhas com erros."}:{severity:"success",life:5e3,summary:"Sucesso",detail:"A planilha foi processada com sucesso."}),g.value=!t,t){const m={...s.data};y("success",m)}else{const m={...s.data};y("success",m)}}),E(()=>s==null?void 0:s.error,l=>{l&&(a.value=!1,n.toastPending&&c.remove(n.toastPending),c.add({severity:"error",summary:"Erro",detail:"Ocorreu um erro na importação da planilha. Verifique a planilha e tente novamente.",life:1e4}))}),(l,t)=>{var x,k,P,w,S,j,I,C;const u=H,m=X;return o(),r("div",Z,[e("div",ee,[e("div",se,[t[0]||(t[0]=e("label",{class:"p-label"},"Arquivo:",-1)),e("span",null,i(l.fileName),1)]),e("div",te,[t[1]||(t[1]=e("label",{class:"p-label"},"Planilha Selecionada:",-1)),e("span",null,i(l.planilha),1)]),e("div",ae,[t[2]||(t[2]=e("label",{class:"p-label"},"Linhas Processadas:",-1)),e("span",null,i((k=(x=f(s))==null?void 0:x.data)==null?void 0:k.processed)+" / "+i((w=(P=f(s))==null?void 0:P.data)==null?void 0:w.total),1)]),e("div",oe,[t[4]||(t[4]=e("label",{class:"p-label"},"Status:",-1)),a.value?(o(),r("span",le,[h(J,{class:"!w-[1em] !h-[1em]"}),t[3]||(t[3]=V(" Processando... "))])):d("",!0),a.value?d("",!0):(o(),r("span",re,"Planilha processada"))])]),f(g)?(o(),p(m,{key:1,severity:"success"},{default:M(()=>t[7]||(t[7]=[V(" A importação foi concluída com sucesso! ")])),_:1})):(o(),r("div",ne,[e("div",ie,[t[5]||(t[5]=e("label",{class:"p-label mr-1"},"Erros:",-1)),e("span",de,i(Object.values(((j=(S=f(s))==null?void 0:S.data)==null?void 0:j.errors)??{}).reduce((v,_)=>v+_.length,0)),1)]),h(u,{items:O((C=(I=f(s))==null?void 0:I.data)==null?void 0:C.errors),style:{width:"100%",height:"400px"},"item-size":38,class:"border rounded-t-none rounded"},{item:M(({item:v})=>[e("div",ce,[e("div",ue,[t[6]||(t[6]=e("i",{class:"pi pi-exclamation-circle text-danger mr-6"},null,-1)),e("ul",me,[(o(!0),r(G,null,Y(v.errors,(_,$)=>(o(),r("li",{key:$},i(_),1))),128))])]),e("span",null,"Linha: "+i(v.line),1)])]),_:1},8,["items"])]))])}}}),ve=Object.assign(fe,{__name:"UtilsImportProgress"});export{ve as U};
