import{d as V,a as m,o,I as $,e,E as d,b as p,_ as U,a2 as A,f as _,G as q,N as C,p as z,u as L,j as T,i as D,k as E,t as i,g as f,h as M,w as N}from"./dVzHJMF1.js";import F from"./r1Y5hC84.js";import{_ as G}from"./Cn3xUAbr.js";const H={class:"text-2xl"},J={class:"grow pt-0.5"},K={key:0},Q=V({__name:"Message",props:{severity:{default:"info"},closable:{type:Boolean,default:!1}},emits:["close"],setup(r,{emit:b}){const c=b;function y(){c("close")}return(a,v)=>{const s=U;return o(),m("div",{class:"w-full flex p-5 gap-4",style:$({backgroundColor:a.severity==="danger"?"#fde0db":a.severity==="info"?"#d4e5ff":a.severity==="success"?"#d6fbd5":"#fff5c2"})},[e("div",H,[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",J,[A(a.$slots,"default")]),a.closable?(o(),m("div",K,[e("button",{class:"text-xl",type:"button","aria-label":"Fechar a messagem alerta",onClick:y},[_(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)}}}),R=Object.assign(Q,{__name:"UiMessage"}),W={class:"flex flex-col gap-5"},X={class:"base-grid grid-cols-2 max-md:grid-cols-1"},Y={class:"flex flex-col"},Z={class:"flex flex-col"},ee={class:"flex flex-col"},se={class:"flex flex-col"},te={key:0,"data-status":""},ae={key:1,"data-status":""},oe={key:0},le={class:"w-full rounded-t border border-b-0 px-2 py-1"},re={"data-errors-count":""},ne={class:"flex p-2 border-b text-sm items-center hover:bg-gray-100 justify-between my-1",style:{height:"38px"}},ie={class:"flex items-center"},de={class:"text-nowrap ml-2"},ce=V({__name:"ImportProgress",props:C({jobId:{},toastPending:{default:()=>{}},fileName:{default:()=>{}},planilha:{default:()=>{}}},{pending:{type:Boolean,default:!0},pendingModifiers:{}}),emits:C(["success"],["update:pending"]),setup(r,{emit:b}){const c=z(),y=b,a=L(r,"pending"),v=T(!1),s=D.core.getImportProgress(r.jobId),B=l=>l?Object.entries(l).flatMap(([t,u])=>u.map(n=>({line:t,error:n}))):[];return E(()=>s==null?void 0:s.readyState,l=>{var u;if(s.error)return;if(v.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(r.toastPending&&c.remove(r.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."}),v.value=!t,t){const n={...s.data};y("success",n)}else{const n={...s.data};y("success",n)}}),E(()=>s==null?void 0:s.error,l=>{l&&(a.value=!1,r.toastPending&&c.remove(r.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 h,x,k,P,w,S,j,I;const u=F,n=R;return o(),m("div",W,[e("div",X,[e("div",Y,[t[0]||(t[0]=e("label",{class:"p-label"},"Arquivo:",-1)),e("span",null,i(l.fileName),1)]),e("div",Z,[t[1]||(t[1]=e("label",{class:"p-label"},"Planilha Selecionada:",-1)),e("span",null,i(l.planilha),1)]),e("div",ee,[t[2]||(t[2]=e("label",{class:"p-label"},"Linhas Processadas:",-1)),e("span",null,i((x=(h=f(s))==null?void 0:h.data)==null?void 0:x.processed)+" / "+i((P=(k=f(s))==null?void 0:k.data)==null?void 0:P.total),1)]),e("div",se,[t[4]||(t[4]=e("label",{class:"p-label"},"Status:",-1)),a.value?(o(),m("span",te,[_(G,{class:"!w-[1em] !h-[1em]"}),t[3]||(t[3]=M(" Processando... "))])):d("",!0),a.value?d("",!0):(o(),m("span",ae,"Planilha processada"))])]),f(v)?(o(),p(n,{key:1,severity:"success"},{default:N(()=>t[7]||(t[7]=[M(" A importação foi concluída com sucesso! ")])),_:1})):(o(),m("div",oe,[e("div",le,[t[5]||(t[5]=e("label",{class:"p-label mr-1"},"Erros:",-1)),e("span",re,i(Object.values(((S=(w=f(s))==null?void 0:w.data)==null?void 0:S.errors)??{}).reduce((g,O)=>g+O.length,0)),1)]),_(u,{items:B((I=(j=f(s))==null?void 0:j.data)==null?void 0:I.errors),style:{width:"100%",height:"400px"},"item-size":38,class:"border rounded-t-none rounded"},{item:N(({item:g})=>[e("div",ne,[e("div",ie,[t[6]||(t[6]=e("i",{class:"pi pi-exclamation-circle text-danger mr-6"},null,-1)),e("span",null,i(g.error),1)]),e("span",de,"Linha: "+i(g.line),1)])]),_:1},8,["items"])]))])}}}),pe=Object.assign(ce,{__name:"UtilsImportProgress"});export{pe as U};
