import{a as e}from"./chunk-BNv3lrIs.js";import{n as t,t as n}from"./jsx-runtime-pmtNMKr4.js";import{n as r}from"./toast-hrvP3G3Q.js";import{t as i}from"./Button-_yTP2B6J.js";import{t as a}from"./useMediaQuery-C_7KdS3g.js";import{t as o}from"./load-HIf6x4Qy.js";import{A as s,Hr as c,Mn as l,bi as u,li as d}from"./index-CBXvBSuP.js";import{t as f}from"./PageHeader-C3X_ZaAc.js";import{t as p}from"./DataTable-BuE1Zp8A.js";import{t as m}from"./useTheme-D5mB3Mad.js";import{t as h}from"./exportCSV-BTwfFV3A.js";import{r as g}from"./movimientosAlmacenPL-BEyVO_3l.js";var _=e(t(),1),v=n();function y({props:e}){let[t,n]=(0,_.useState)(!0);(0,_.useEffect)(()=>{setTimeout(()=>{n(!1)},500)},[]);let[y,x]=(0,_.useState)(!0),[S,C]=(0,_.useState)([]),w=()=>{let e=setTimeout(()=>{C(z),x(!1)},0);return()=>clearTimeout(e)};(0,_.useEffect)(()=>{w()},[]);let T=[{name:`ID`,selector:e=>e.id,omit:!0},{name:`ID DEL ARTICULO`,selector:e=>e.idArticuloAPL,omit:!0},{name:`PRODUCTO`,selector:e=>e.producto,sortable:!0},{name:`TIPO`,selector:e=>e.tipo,sortable:!0},{name:`CANTIDAD MOVIMIENTO`,selector:e=>e.cantidadMovimiento,sortable:!0},{name:`UNIDAD DE MEDIDA`,selector:e=>e.unidadMedida,sortable:!0},{name:`DEPARTAMENTO`,selector:e=>e.departamento,sortable:!0}];a(m().breakpoints.down(`sm`));let[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(null),M=()=>{let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`},[N,P]=(0,_.useState)(M()),[F,I]=(0,_.useState)(M()),L=e=>{P(e.target.value)},R=e=>{I(e.target.value)},[z,B]=(0,_.useState)([]),V=()=>{try{g(N,F).then(e=>{let{data:t}=e;B(b(t))}).catch(e=>{})}catch{}};return(0,_.useEffect)(()=>{V()},[N,F]),(0,v.jsxs)(v.Fragment,{children:[t&&(0,v.jsx)(o,{}),(0,v.jsx)(f,{title:`Movimientos insumos`,icon:c,buttons:[(0,v.jsxs)(`div`,{className:`d-flex align-items-center flex-wrap gap-3 me-2`,children:[(0,v.jsxs)(u.Group,{className:`d-flex align-items-center gap-2 mb-0`,children:[(0,v.jsx)(u.Label,{className:`mb-0 text-nowrap text-secondary fw-semibold`,children:`Fecha Inicio:`}),(0,v.jsx)(u.Control,{type:`date`,name:`fechaInicio`,value:N,onChange:L,className:`glass-input`,style:{width:`auto`}})]}),(0,v.jsxs)(u.Group,{className:`d-flex align-items-center gap-2 mb-0`,children:[(0,v.jsx)(u.Label,{className:`mb-0 text-nowrap text-secondary fw-semibold`,children:`Fecha Fin:`}),(0,v.jsx)(u.Control,{type:`date`,name:`fechaFin`,value:F,onChange:R,className:`glass-input`,style:{width:`auto`}})]})]},`date-filters`),(0,v.jsxs)(i,{variant:`primary`,onClick:()=>{try{r.info(`Estamos empaquetando tu respaldo, espere por favor ....`);let e=setTimeout(()=>{h(z,`MOVIMIENTOS_APL_`+N+`-`+F)},5600);return()=>clearTimeout(e)}catch(e){console.log(e)}},className:`btn-premium d-flex align-items-center`,children:[(0,v.jsx)(d,{icon:l,className:`me-2`}),`CSV periodo`]},`btn-csv`)]}),(0,v.jsx)(`div`,{className:`divTabla`,children:(0,v.jsx)(p,{title:`Lista de movimientos del almacen`,datos:z,columnas:T})}),(0,v.jsxs)(s,{show:E,onClose:()=>D(!1),maxWidth:`xl`,children:[(0,v.jsx)(s.Header,{closeButton:!0,onClose:()=>D(!1),children:A}),(0,v.jsx)(s.Body,{children:O})]})]})}function b(e){let t=[];return e.forEach(e=>{t.push({id:e._id,idArticuloAPL:e.idArticuloAPL,tipo:e.tipo,producto:e.producto,cantidadMovimiento:e.cantidadMovimiento,unidadMedida:e.unidadMedida,departamento:e.departamento,fecha:e.createdAt})}),t}export{y as default};