import{r as i,P as $,I as J,c as R,S as O,j as e,a as V}from"./app-BZJf8lgN.js";import{L as X}from"./layout-DZ5xjWdd.js";import{P as D,F as I}from"./fileupload.esm-CWt4e-Qk.js";import{T as Y}from"./toast.esm-CYGIlaDH.js";import{C as G,u as Q,B as v}from"./button.esm-D_cwsnQR.js";import{u as W}from"./hooks.esm-UVLztt_0.js";import"./CSSTransition-DBuKQJwM.js";import"./index.esm-Ckth6fI3.js";import"./index.esm-hRnQzR_k.js";import"./csstransition.esm-BNRxTMOa.js";import"./index.esm-CygY3Qsw.js";import"./index.esm-B5zYYMSp.js";function d(s){"@babel/helpers - typeof";return d=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},d(s)}function Z(s,r){if(d(s)!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,r);if(d(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(s)}function ee(s){var r=Z(s,"string");return d(r)=="symbol"?r:r+""}function E(s,r,t){return(r=ee(r))in s?Object.defineProperty(s,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[r]=t,s}var se={value:"p-tag-value",icon:"p-tag-icon",root:function(r){var t=r.props;return R("p-tag p-component",E(E({},"p-tag-".concat(t.severity),t.severity!==null),"p-tag-rounded",t.rounded))}},re=`
@layer primereact {
    .p-tag {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .p-tag-icon,
    .p-tag-value,
    .p-tag-icon.pi {
        line-height: 1.5;
    }
    
    .p-tag.p-tag-rounded {
        border-radius: 10rem;
    }
}
`,f=G.extend({defaultProps:{__TYPE:"Tag",value:null,severity:null,rounded:!1,icon:null,style:null,className:null,children:void 0},css:{classes:se,styles:re}});function T(s,r){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);r&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),t.push.apply(t,n)}return t}function te(s){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?T(Object(t),!0).forEach(function(n){E(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):T(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}var F=i.forwardRef(function(s,r){var t=W(),n=i.useContext($),o=f.getProps(s,n),c=f.setMetaData({props:o}),m=c.ptm,u=c.cx,x=c.isUnstyled;Q(f.css.styles,x,{name:"tag"});var g=i.useRef(null),y=t({className:u("icon")},m("icon")),h=J.getJSXIcon(o.icon,te({},y),{props:o});i.useImperativeHandle(r,function(){return{props:o,getElement:function(){return g.current}}});var b=t({ref:g,className:R(o.className,u("root")),style:o.style},f.getOtherProps(o),m("root")),p=t({className:u("value")},m("value"));return i.createElement("span",b,h,i.createElement("span",p,o.value),i.createElement("span",null,o.children))});F.displayName="Tag";const ae={icon:"pi pi-fw pi-images",iconOnly:!0,className:"p-button-rounded p-button-outlined"},ne={className:"p-button-success p-button-rounded p-button-outlined"},C={icon:"pi pi-fw pi-times",iconOnly:!0,className:"p-button-danger p-button-rounded p-button-outlined"};function be(){const s=i.useRef(null),r=i.useRef(null),t=i.useRef(null),[n,o]=i.useState(0),{data:c,setData:m,post:u,errors:x,processing:g,reset:y}=O({excelFile:null}),h=a=>{m("excelFile",a.files[0])},b=a=>{if(a.preventDefault(),!c.excelFile){s.current.show({severity:"error",summary:"Error",detail:"Selecciona un archivo Excel",life:3e3});return}u(route("excel.update"),{onSuccess:()=>{s.current.show({severity:"success",summary:"¡Listo!",detail:"Excel subido",life:3e3}),y(),r.current.clear()},onError:l=>{s.current.show({severity:"error",summary:"Error",detail:"No se pudo subir el Excel",life:3e3}),console.error("Error Excel:",l)}})},{data:p,setData:N,post:B,errors:S,processing:U,reset:z}=O({images:[]}),L=a=>{N("images",a.files);let l=n;a.files.forEach(j=>l+=j.size),o(l)},P=()=>{if(!p.images.length){s.current.show({severity:"warn",summary:"Atención",detail:"No hay imágenes para subir",life:3e3});return}B(route("images.upload"),{onSuccess:a=>{s.current.show({severity:"success",summary:"¡Listo!",detail:`${p.images.length} imagen(es) subidas`,life:3e3}),console.log("Imágenes subidas:",p.images),console.log("Respuesta servidor:",a),z(),t.current.clear(),o(0)},onError:a=>{s.current.show({severity:"error",summary:"Error",detail:"Falló la subida de imágenes",life:3e3}),console.error("Error imágenes:",a)}})},M=a=>{var l;s.current.show({severity:"error",summary:"Error",detail:"Formato o tamaño no válido",life:3e3}),console.error("PrimeReact upload error:",(l=a.xhr)==null?void 0:l.response)},_=a=>{var w;const{className:l,chooseButton:j,uploadButton:oe,cancelButton:q}=a,A=n/5e5,K=((w=t.current)==null?void 0:w.formatSize(n))??"0 B";return e.jsxs("div",{className:l,style:{display:"flex",alignItems:"center",background:"transparent"},children:[j,e.jsx(v,{icon:"pi pi-upload",onClick:P,className:ne.className,tooltip:"Subir imágenes"}),q,e.jsxs("div",{className:"ml-auto flex align-items-center gap-3",children:[e.jsxs("span",{children:[K," / 50 MB"]}),e.jsx(D,{value:A,showValue:!1,style:{width:"10rem",height:"12px"}})]})]})},k=(a,l)=>e.jsxs("div",{className:"flex align-items-center flex-wrap gap-3 py-2",children:[e.jsxs("div",{className:"flex align-items-center",style:{width:"40%"},children:[e.jsx("img",{alt:a.name,src:a.objectURL,width:100}),e.jsxs("div",{className:"ml-3 flex flex-column",children:[e.jsx("span",{children:a.name}),e.jsx("small",{children:new Date().toLocaleDateString()})]})]}),e.jsx(F,{value:l.formatSize,className:"px-3 py-2"}),e.jsx(v,{icon:"pi pi-times",className:C.className,onClick:()=>l.onRemove(a)})]}),H=()=>e.jsxs("div",{className:"flex flex-column align-items-center p-5",children:[e.jsx("i",{className:"pi pi-image mb-3",style:{fontSize:"4rem",color:"#bbb"}}),e.jsx("span",{children:"Arrastrá imágenes aquí"})]});return e.jsxs(X,{children:[(g||U)&&e.jsx(D,{mode:"indeterminate",style:{height:"6px"}}),e.jsx(V,{title:"Cargar Excel e Imágenes"}),e.jsx(Y,{ref:s}),e.jsxs("section",{className:"card p-4 mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Columnas requeridas en el Excel"}),e.jsx("p",{children:"El archivo Excel debe tener las siguientes columnas (las marcadas con * son obligatorias):"}),e.jsxs("ul",{className:"list-disc list-inside mt-2",children:[e.jsx("li",{children:"Codigo origen *"}),e.jsx("li",{children:"Codigo equivalente"}),e.jsx("li",{children:"Descripcion *"}),e.jsx("li",{children:"Categoria *"}),e.jsx("li",{children:"Espesor"}),e.jsx("li",{children:"Muesca"}),e.jsx("li",{children:"Combustible"}),e.jsx("li",{children:"Temperatura"}),e.jsx("li",{children:"Material"}),e.jsx("li",{children:"Tamaño"}),e.jsx("li",{children:"Potencia"}),e.jsx("li",{children:"Marca/Modelo *"}),e.jsx("li",{children:"Precio *"}),e.jsx("li",{children:"Imagen"})]}),e.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Nota: La columna 'Cantidad' será ignorada."})]}),e.jsxs("section",{className:"card p-4 mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"1. Cargar Excel"}),e.jsxs("form",{onSubmit:b,children:[e.jsx(I,{ref:r,mode:"basic",name:"excelFile",chooseLabel:"Seleccionar Excel",accept:".xlsx",maxFileSize:2e7,auto:!1,customUpload:!0,uploadHandler:()=>{},onSelect:h}),x.excelFile&&e.jsx("p",{className:"text-red-600 mt-2",children:x.excelFile}),e.jsx(v,{type:"submit",label:"Subir Excel",className:"mt-4"})]})]}),e.jsxs("section",{className:"card p-4",children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"2. Subir Imágenes (Drag & Drop)"}),e.jsx(I,{ref:t,name:"images",multiple:!0,accept:"image/*",maxFileSize:2e6,customUpload:!0,uploadHandler:P,onSelect:L,onError:M,headerTemplate:_,itemTemplate:k,emptyTemplate:H,chooseOptions:ae,cancelOptions:C}),S.images&&e.jsx("p",{className:"text-red-600 mt-2",children:S.images})]})]})}export{be as default};
//# sourceMappingURL=Excel-C0ShPLXY.js.map
