import{aj as I,j as e,ak as R,r as c,B as f,v as P,I as $,T as b,A as w,g as k}from"./index-B1H8BCL7.js";import{d as M}from"./RestartAltOutlined-CeoSsncl.js";import{S as u}from"./Stack-BIAbaqpj.js";var p={},G=R;Object.defineProperty(p,"__esModule",{value:!0});var _=p.default=void 0,T=G(I()),B=e,F=(0,T.default)((0,B.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95C8.08 7.14 9.94 6 12 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11c1.56.1 2.78 1.41 2.78 2.96 0 1.65-1.35 3-3 3zM8 13h2.55v3h2.9v-3H16l-4-4z"}),"CloudUploadOutlined");_=p.default=F;var x={},H=R;Object.defineProperty(x,"__esModule",{value:!0});var y=x.default=void 0,L=H(I()),U=e,q=(0,L.default)((0,U.jsx)("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4.86 8.86-3 3.87L9 13.14 6 17h12l-3.86-5.14z"}),"ImageOutlined");y=x.default=q;function W({value:a,onChange:o,label:g="lab logo",maxSizeKB:n=2048,size:l=220}){const m=c.useRef(null),[h,i]=c.useState(!1),[j,s]=c.useState(null),d=()=>{var r;return(r=m.current)==null?void 0:r.click()},v=r=>{if(s(null),!r)return;if(!r.type.startsWith("image/")){s("Only image files are accepted (PNG, JPG, SVG, etc.).");return}if(r.size>n*1024){s(`Image is ${(r.size/1024).toFixed(0)} KB — please keep it under ${n} KB.`);return}const t=new FileReader;t.onload=O=>o==null?void 0:o(O.target.result),t.onerror=()=>s("Could not read the file. Please try a different image."),t.readAsDataURL(r)},C=r=>{var t;return v((t=r.target.files)==null?void 0:t[0])},D=r=>{var t;r.preventDefault(),i(!1),v((t=r.dataTransfer.files)==null?void 0:t[0])},S=r=>{r.preventDefault(),i(!0)},z=()=>i(!1);return e.jsxs(u,{spacing:1,alignItems:"flex-start",children:[e.jsxs(f,{onClick:d,onDrop:D,onDragOver:S,onDragLeave:z,role:"button",tabIndex:0,sx:{width:l,height:l,position:"relative",cursor:"pointer",borderRadius:3,border:"2px dashed",borderColor:h?"#1d4ed8":a?"transparent":"#cbd5e1",backgroundColor:h?"#eff6ff":a?"#fff":"#f8fafc",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.15s ease","&:hover":{borderColor:"#1d4ed8",backgroundColor:"#eff6ff"}},children:[a?e.jsxs(e.Fragment,{children:[e.jsx(f,{component:"img",src:a,alt:g,sx:{maxWidth:"85%",maxHeight:"85%",objectFit:"contain"}}),e.jsx(P,{title:"Replace image",arrow:!0,children:e.jsx($,{size:"small",onClick:r=>{r.stopPropagation(),d()},sx:{position:"absolute",top:8,right:8,backgroundColor:"rgba(255,255,255,0.95)","&:hover":{backgroundColor:"#fff"}},children:e.jsx(M,{fontSize:"small"})})})]}):e.jsxs(u,{alignItems:"center",spacing:1,children:[e.jsx(f,{sx:{width:48,height:48,borderRadius:"50%",background:"linear-gradient(135deg, #1d4ed8 0%, #8b5cf6 100%)",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff"},children:e.jsx(_,{})}),e.jsxs(b,{sx:{fontSize:"0.78rem",fontWeight:600,color:"#0f172a"},children:["Upload ",g]}),e.jsxs(b,{sx:{fontSize:"0.7rem",color:"#64748b",textAlign:"center",px:1},children:["Drag & drop or click",e.jsx("br",{}),"PNG / JPG / SVG · up to ",(n/1024).toFixed(1)," MB"]})]}),e.jsx("input",{ref:m,type:"file",accept:"image/*",hidden:!0,onChange:C})]}),j&&e.jsx(w,{severity:"error",sx:{width:l,py:.5},onClose:()=>s(null),children:j}),a&&e.jsxs(u,{direction:"row",spacing:1,children:[e.jsx(k,{size:"small",startIcon:e.jsx(y,{}),onClick:d,sx:{textTransform:"none"},children:"Replace"}),e.jsx(k,{size:"small",color:"error",onClick:()=>o==null?void 0:o(null),sx:{textTransform:"none"},children:"Remove"})]})]})}export{W as L};
