@zydon/common 2.4.97 → 2.4.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -24,6 +24,6 @@ import { styled, alpha } from '@mui/material/styles';
|
|
|
24
24
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
25
25
|
import { GridToolbarFilterButton, GridToolbarColumnsButton } from '@mui/x-data-grid-premium';
|
|
26
26
|
|
|
27
|
-
var P="datagrid-actions";var $=styled(a,{shouldForwardProp:o=>o!=="breakpoint"})(({theme:o,breakpoint:r})=>({position:"relative",borderRadius:12,padding:0,gap:0,overflow:"hidden",[o.breakpoints.down(r)]:{borderColor:alpha(o.palette.grey[500],.2)}})),U=styled(d,{shouldForwardProp:o=>o!=="breakpoint"})(({theme:o,breakpoint:r})=>({flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:"24px 24px 0",gap:24,[o.breakpoints.down(r)]:{padding:"16px 16px 0"}})),Q=styled(d,{shouldForwardProp:o=>o!=="breakpoint"})(({theme:o,breakpoint:r})=>({flexDirection:"row",alignItems:"center",gap:12,color:o.palette.text.secondary,[o.breakpoints.down(r)]:{"& button, & a":{textIndent:"-9999em",fontSize:0,minWidth:36,maxWidth:36,height:36,width:36,overflow:"hidden","& .MuiButton-icon":{margin:0}}}})),q=styled(j)({borderStyle:"dashed",height:16,margin:"auto"}),b=styled(j)({borderStyle:"dashed",height:12,marginTop:"auto",marginBottom:"auto"}),J=styled(d,{shouldForwardProp:o=>o!=="breakpoint"})(({theme:o,breakpoint:r})=>({position:"relative",padding:16,flexDirection:"row",alignItems:"center",color:o.palette.text.secondary,[o.breakpoints.down(r)]:{padding:"12px 16px",borderBottom:`1px solid ${o.palette.divider}`,minHeight:60,[o.breakpoints.down(r)]:{"& button":{textIndent:"-9999em",fontSize:0,minWidth:36,maxWidth:36,height:36,width:36,overflow:"hidden","& .MuiButton-icon":{margin:0}}}}})),K=styled(d,{shouldForwardProp:o=>o!=="breakpoint"})(({theme:o,breakpoint:r})=>({width:320,alignItems:"center",justifyContent:"center",[o.breakpoints.down(r)]:{
|
|
27
|
+
var P="datagrid-actions";var $=styled(a,{shouldForwardProp:o=>o!=="breakpoint"})(({theme:o,breakpoint:r})=>({position:"relative",borderRadius:12,padding:0,gap:0,overflow:"hidden",[o.breakpoints.down(r)]:{borderColor:alpha(o.palette.grey[500],.2)}})),U=styled(d,{shouldForwardProp:o=>o!=="breakpoint"})(({theme:o,breakpoint:r})=>({flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:"24px 24px 0",gap:24,[o.breakpoints.down(r)]:{padding:"16px 16px 0"}})),Q=styled(d,{shouldForwardProp:o=>o!=="breakpoint"})(({theme:o,breakpoint:r})=>({flexDirection:"row",alignItems:"center",gap:12,color:o.palette.text.secondary,[o.breakpoints.down(r)]:{"& button, & a":{textIndent:"-9999em",fontSize:0,minWidth:36,maxWidth:36,height:36,width:36,overflow:"hidden","& .MuiButton-icon":{margin:0}}}})),q=styled(j)({borderStyle:"dashed",height:16,margin:"auto"}),b=styled(j)({borderStyle:"dashed",height:12,marginTop:"auto",marginBottom:"auto"}),J=styled(d,{shouldForwardProp:o=>o!=="breakpoint"})(({theme:o,breakpoint:r})=>({position:"relative",padding:16,flexDirection:"row",alignItems:"center",color:o.palette.text.secondary,[o.breakpoints.down(r)]:{padding:"12px 16px",borderBottom:`1px solid ${o.palette.divider}`,minHeight:60,[o.breakpoints.down(r)]:{"& button":{textIndent:"-9999em",fontSize:0,minWidth:36,maxWidth:36,height:36,width:36,overflow:"hidden","& .MuiButton-icon":{margin:0}}}}})),K=styled(d,{shouldForwardProp:o=>o!=="breakpoint"})(({theme:o,breakpoint:r})=>({width:320,alignItems:"center",justifyContent:"center",[o.breakpoints.down(r)]:{position:"absolute",left:0,width:"100%",padding:"0 12px",zIndex:1,"& fieldset, & input":{display:"flex"},"& .MuiInputAdornment-root":{marginLeft:0}}})),X=styled(d)(({theme:o})=>({"& .MuiToolbar-root":{height:24,minHeight:24,overflow:"hidden",[o.breakpoints.down("sm")]:{height:"auto",flexWrap:"wrap",justifyContent:"center"}}})),Y=styled(d)(({theme:o})=>({minHeight:60,alignItems:"flex-end",justifyContent:"center",borderTop:`1px solid ${o.palette.divider}`})),Z=styled(d)(({theme:o})=>({flexDirection:"row",height:60,alignItems:"center",justifyContent:"space-between",borderTop:`1px solid ${o.palette.divider}`,gap:16,padding:16}));var Po=({count:o,page:r,rowsPerPage:l,onPageChange:m,onRowsPerPageChange:w})=>jsx(X,{children:jsx(ho,{color:"primary",component:"div",size:"small",count:o,page:r,rowsPerPage:l,onPageChange:(c,n)=>m(n),onRowsPerPageChange:c=>w(Number(c.target.value))})}),y=Po;var wo=forwardRef(({children:o,...r},l)=>jsx(ro,{...r,ref:l,color:"inherit",startIcon:jsx(a$1,{icon:"COLUMNS"}),children:o??"Colunas"}));wo.displayName="ColumnsButton";var Co=forwardRef(({children:o,...r},l)=>jsx(ro,{...r,ref:l,color:"inherit",startIcon:jsx(a$1,{icon:"FILTER_VERTICAL"}),children:o??"Filtros"}));Co.displayName="FilterButton";var vo=({setFilterButtonEl:o})=>jsxs(a$9,{container:P,children:[jsx(GridToolbarFilterButton,{ref:o,slotProps:{button:{color:"inherit",startIcon:jsx(a$1,{icon:"FILTER_VERTICAL"}),children:"Filtros"}}}),jsx(b,{orientation:"vertical",flexItem:!0}),jsx(GridToolbarColumnsButton,{slotProps:{button:{color:"inherit",startIcon:jsx(a$1,{icon:"COLUMNS"}),children:"Colunas"}}})]}),eo=vo;var So=({title:o,breakpoint:r="md",columns:l,rows:m=[],mobileRender:w,rowCount:c=0,paginationModel:n={page:0,pageSize:25},onPaginationChange:g,actions:T,moreActions:D,onAdd:S,onSearch:B,searchValue:ao,onSearchChange:po,slots:C,slotProps:so,loading:u,fetching:k,containerProps:lo={height:562,maxHeight:562},...mo})=>{let f=a$2(),h=b$1("down",r),[co,uo]=useState(null),A=!!B,v=!!S,R=!!T,go=R||v,F=!!D,E=F||A||!h;return jsxs($,{breakpoint:r,...lo,flex:u?1:void 0,minHeight:!u&&m.length===0?562:void 0,children:[jsxs(U,{breakpoint:r,children:[jsx(x,{variant:"overline",color:"text.secondary",noWrap:!0,children:o}),go&&jsxs(Q,{breakpoint:r,children:[R&&jsxs(Fragment,{children:[T,v&&jsx(q,{orientation:"vertical",flexItem:!0})]}),v&&jsx(ro,{startIcon:jsx(a$1,{icon:"SIMPLE_ADD"}),variant:"contained",onClick:S,children:"Adicionar"})]})]}),E&&jsxs(J,{breakpoint:r,children:[jsx(d,{flex:1,direction:"row",alignItems:"center",id:P,gap:.5,children:F&&jsxs(Fragment,{children:[jsx(ro,{color:"inherit",startIcon:jsx(a$1,{icon:"MORE_BOLD"}),size:"small",onClick:f.onOpen,children:"Mais"}),!h&&jsx(b,{orientation:"vertical",flexItem:!0}),jsx(a$3,{open:f.open,anchorEl:f.open,onClose:f.onClose,sx:{minWidth:160},disabledArrow:h,children:D})]})}),A&&jsx(K,{breakpoint:r,children:jsx(a$4,{value:ao,placeholder:"Buscar",onSearch:B,onChange:e=>po?.(e.target.value),size:"small",fullWidth:!0,iconPosition:"start"})})]}),!E&&jsx(j,{sx:{mt:2}}),h?jsxs(a$5,{isFetching:k,fetching:jsx(a$6,{}),isLoading:u,loading:jsx(To,{sx:{m:"160px auto"}}),isEmpty:m.length===0,empty:jsx(d,{flex:1,alignItems:"center",justifyContent:"center",children:C?.noRowsOverlay?jsx(C.noRowsOverlay,{}):jsx(x,{variant:"body2",color:"text.secondary",children:"Nenhum registro encontrado"})}),children:[jsx(a$7,{fillContent:!0,children:m.map(e=>w(e))}),jsx(Y,{children:jsx(y,{count:c,page:n.page,rowsPerPage:n.pageSize,onPageChange:e=>g(e,n.pageSize),onRowsPerPageChange:e=>g(n.page,e)})})]}):jsx(a$8,{columns:l,rows:m,slots:{toolbar:eo,footer:()=>jsxs(Z,{children:[jsxs(d,{direction:"row",alignItems:"center",gap:.5,children:[jsx(x,{variant:"body2",color:"text.disabled",children:"Total de itens:"}),jsx(x,{variant:"body2",children:c})]}),jsx(y,{count:c,page:n.page,rowsPerPage:n.pageSize,onPageChange:e=>g(e,n.pageSize),onRowsPerPageChange:e=>g(n.page,e)})]}),...C},slotProps:{panel:{anchorEl:co},toolbar:{setFilterButtonEl:uo,showQuickFilter:!0},...so},columnHeaderHeight:48,getRowHeight:()=>68,loading:u,fetching:k,...mo})]},u?"loading":"data")},ut=So;
|
|
28
28
|
|
|
29
29
|
export { ut as default };
|
|
@@ -16,7 +16,7 @@ import '../../chunk-ILHUUK4X.js';
|
|
|
16
16
|
import { a as a$1 } from '../../chunk-S7QQBC4I.js';
|
|
17
17
|
import { a as a$8 } from '../../chunk-ONZBWH3C.js';
|
|
18
18
|
import { memo, forwardRef, useMemo, useLayoutEffect, useCallback, useRef, useState, useEffect } from 'react';
|
|
19
|
-
import
|
|
19
|
+
import So from '@mui/material/FormHelperText';
|
|
20
20
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
21
21
|
import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
22
22
|
import { restrictToHorizontalAxis, restrictToParentElement, restrictToWindowEdges } from '@dnd-kit/modifiers';
|
|
@@ -32,6 +32,6 @@ import Mo from '@mui/material/Badge';
|
|
|
32
32
|
import { useDropzone } from 'react-dropzone';
|
|
33
33
|
import at from '@mui/material/CircularProgress';
|
|
34
34
|
|
|
35
|
-
var So=({helperText:e,disabled:o,isError:r})=>e?jsx(Ro,{error:r,sx:i=>({mx:"14px",color:o?i.palette.grey[500]:void 0}),children:e}):null,G=memo(So);var Re=styled(le)({position:"relative",width:"100%",borderRadius:8,overflow:"hidden","&:hover .actions":{display:"flex"}}),Se=styled(le)({position:"absolute",top:4,right:4,gap:.5,"& svg":{width:16,height:16}}),Xe=styled(Pe,{shouldForwardProp:e=>!["isDragActive","isError","disabled"].includes(e)})(({theme:e,isDragActive:o,isError:r,disabled:i})=>({outline:"none",cursor:"pointer",overflow:"hidden",position:"relative",padding:e.spacing(5),borderRadius:e.shape.borderRadius,transition:e.transitions.create("padding"),backgroundColor:e.palette.background.neutral,border:`1px dashed ${alpha(e.palette.grey[500],.32)}`,...o&&{opacity:.72},...r&&{color:e.palette.error.main,backgroundColor:e.palette.error.lighter,borderColor:e.palette.error.light},...i&&{opacity:.48,pointerEvents:"none"},"&:hover":{opacity:.72}}));styled(le)(({theme:e})=>({display:"none",position:"absolute",alignItems:"center",justifyContent:"center",flexDirection:"row",gap:12,width:"100%",height:"100%",backgroundColor:alpha(e.palette.primary.main,.9),zIndex:999,button:{"&, &:hover, &:focus":{backgroundColor:"#fff"}}}));var qe=styled(yo)(({theme:e})=>({position:"relative",zIndex:999,pointerEvents:"auto",color:e.palette.grey[700],backgroundColor:e.palette.grey[100],"&:hover":{color:e.palette.grey[900],backgroundColor:e.palette.grey[300]}})),Me=styled("div")({position:"relative",zIndex:1,"&:hover":{zIndex:2}}),Ve=styled(le,{shouldForwardProp:e=>!["isDragging"].includes(e)})(({theme:e,width:o,isDragging:r})=>({width:o,height:100,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2,1,2,1),gap:e.spacing(1),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),Ke=styled(m.div)(({theme:e,width:o,isDragging:r})=>({width:o,height:60,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),Je=styled(a)(({theme:e})=>({top:16,right:16,zIndex:9,position:"absolute",color:e.palette.common.white,backgroundColor:alpha(e.palette.grey[900],.72),"&:hover":{backgroundColor:alpha(e.palette.grey[900],.48)}})),Qe=styled(Pe,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="disabled"&&e!=="hasError"})(({theme:e,isDragActive:o,disabled:r,hasError:i})=>({width:64,height:64,flexShrink:0,display:"flex",borderRadius:1,cursor:"pointer",alignItems:"center",color:e.palette.text.disabled,justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),border:`dashed 1px ${alpha(e.palette.grey[500],.16)}`,...o&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...i&&{color:e.palette.error.main,borderColor:e.palette.error.main,backgroundColor:alpha(e.palette.error.main,.08)},"&:hover":{opacity:.72}})),Ye=styled(Pe)(({theme:e})=>({padding:e.spacing(1),top:0,left:0,width:"100%",height:"100%",position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",transition:"all 0.3s ease-in-out",filter:"blur(0)","&:hover":{filter:"blur(3px)"}})),eo=styled("img",{shouldForwardProp:e=>e!=="aspectRatio"&&e!=="isLoading"&&e!=="isUploading"&&e!=="maxWidth"&&e!=="maxHeight"&&e!=="cropSize"})(({theme:e,aspectRatio:o,maxWidth:r,maxHeight:i,isLoading:t,isUploading:d})=>({borderRadius:e.shape.borderRadius,objectFit:"cover",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) scale(1)",filter:"blur(0)",zIndex:1,maxWidth:r,maxHeight:i,backgroundColor:e.palette.background.paper,width:o>1?"calc(100% - 16px)":void 0,height:o>1?void 0:"calc(100% - 16px)",aspectRatio:o,transition:"all 0.5s ease-in-out",...t||d?{opacity:0,filter:"blur(1.5rem)",transform:"translate(-50%, -50%) scale(0.7)"}:{},"&:hover":{transition:"all 0.2s ease-in-out"}})),oo=styled("img",{shouldForwardProp:e=>e!=="isLoading"&&e!=="isUploading"})(({isLoading:e,isUploading:o})=>({width:"100%",height:"100%",objectFit:"cover",top:0,left:0,filter:"blur(1.5rem)",transform:"scale(1.1)",position:"absolute",zIndex:0,transition:"opacity 0.3s ease-in-out",...e&&{opacity:0},...o&&{opacity:.7,filter:"blur(2rem)"}})),ro=styled(le)({width:"100%",height:"100%",position:"relative",overflow:"hidden",borderRadius:"50%",justifyContent:"center",alignItems:"center"});styled(Oo)(({theme:e})=>({py:1,px:2,mt:3,textAlign:"left",borderStyle:"dashed",borderColor:"error.main",backgroundColor:alpha(e.palette.error.main,.08)}));var Te=styled(Pe,{shouldForwardProp:e=>e!=="isError"&&e!=="hasFile"})(({theme:e,isError:o,hasFile:r})=>({top:0,gap:e.spacing(1),left:0,width:"100%",height:"100%",zIndex:9,display:"flex",borderRadius:"50%",position:"absolute",alignItems:"center",color:e.palette.text.disabled,flexDirection:"column",justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),transition:e.transitions.create(["opacity"],{duration:e.transitions.duration.shorter}),"&:hover":{opacity:.92},...o&&{color:e.palette.error.main},...r&&{zIndex:9,opacity:0,color:e.palette.common.white,backgroundColor:alpha(e.palette.common.black,.54)}})),to=styled(le)({top:0,left:0,right:0,bottom:0,position:"absolute",zIndex:10,alignItems:"center",justifyContent:"center"});styled(le)(({theme:e})=>({padding:20,justifyContent:"center",alignItems:"center",gap:4,alignSelf:"stretch",borderRadius:12,background:e.palette.grey[200],color:e.palette.text.disabled,height:160}));var io=styled(Pe,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="isError"&&e!=="hasFile"})(({theme:e,isDragActive:o,disabled:r,isError:i,hasFile:t})=>({padding:e.spacing(1),margin:"auto",width:144,height:144,cursor:"pointer",overflow:"hidden",borderRadius:"50%",border:`1px dashed ${alpha(e.palette.grey[500],.2)}`,...o&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...i&&{borderColor:"error.main"},...t&&{...i&&{bgcolor:alpha(e.palette.error.main,.08)},"&:hover .upload-placeholder":{opacity:1},"& img":{filter:"blur(0)"},"&:hover img":{filter:"blur(3px)"}}})),ao=styled("img")({width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover",transition:"all 0.3s ease-in-out"}),no=styled(a)(({theme:e})=>({backgroundColor:alpha(e.palette.grey[900],.72),color:e.palette.common.white,"&:hover":{backgroundColor:alpha(e.palette.grey[600],.64),color:e.palette.common.white},"& svg":{width:14,height:14}}));var To=({onRemove:e,sx:o,file:r,disableDrag:i,attributes:t,listeners:d,innerWidth:s,isDragging:l})=>{let p=r?.id||r?.url;return p?jsx(Mo,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Ke,{width:s,isDragging:l,"data-testid":`preview-multi-img-${p}`,...j().inUp,sx:o,children:[jsx(a$2,{disableDrag:i,...t,...d}),jsx(f,{tooltip:!0,imageView:!0,file:r}),jsx(Se,{sx:{position:"absolute",right:3,top:3,zIndex:1},children:e&&jsx(no,{size:"small",label:"Remover arquivo",onClick:()=>e(r),icon:"DELETE_MARK_BUTTON_02"})})]})},`badge-${p}`):null},so=memo(To);var Bo=({file:e$1,thumbnail:o,onRemove:r,sx:i,disableDrag:t=!1})=>{let d=e$1?.size||0,s=e$1?.name||e$1?.url||e$1?.id,l=e$1?.id||e$1?.url||"",p=typeof e$1=="string",n=t?70:80,{attributes:g,listeners:x$1,setNodeRef:E,transform:u,transition:b,isDragging:y}=useSortable({id:l,disabled:t}),P={transform:x.Transform.toString(u),transition:b,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${n+8}px`,height:"68px"};return o&&e$1?jsx(Me,{ref:E,style:P,children:jsx(so,{innerWidth:n,isDragging:y,sx:i,file:e$1,disableDrag:t,attributes:g,listeners:x$1,onRemove:r})}):jsx(Me,{ref:E,style:{...P,height:"80px",width:`${n+38}px`},children:jsxs(Ve,{width:n+30,isDragging:y,"data-testid":`preview-multi-img-${l}`,...j().inUp,sx:i,children:[jsx(a$2,{disableDrag:t,...g,...x$1}),e$1&&jsx(f,{file:e$1}),jsxs(le,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$3,{title:s,children:jsx(ke,{variant:"subtitle2",noWrap:!0,children:s})}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:p?"":e(d)})]}),jsx(Se,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},mo=memo(Bo);var or=({thumbnail:e,files:o,onRemove:r,onReorder:i,sx:t})=>{let d=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),s=useCallback(p=>{let{active:n,over:g}=p;if(!(!n||!g||n.id===g.id)&&i){let x=o.findIndex(({id:u})=>u===n.id),E=o.findIndex(({id:u})=>u===g.id);x!==-1&&E!==-1&&i(x,E,o);}},[o,i]),l=jsx(AnimatePresence,{initial:!1,children:o.map(p=>jsx(mo,{sx:t,id:`preview-file-${p.id}`,file:p,onRemove:r,thumbnail:e,disableDrag:!i},`preview-file-${p.id}`))});return i?jsx(DndContext,{sensors:d,collisionDetection:closestCenter,onDragEnd:s,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:o.map(p=>p.id),strategy:horizontalListSortingStrategy,children:l})}):l},Ie=memo(or);var go=forwardRef(({onLoading:e,aspectRatio:o,cropSize:r,...i},t)=>{let{maxWidth:d,maxHeight:s}=useMemo(()=>r&&typeof r=="object"?{maxWidth:r.width,maxHeight:r.height}:r&&typeof r=="number"?{maxWidth:r,maxHeight:r}:{maxWidth:"100%",maxHeight:"100%"},[r]);a$1(()=>{e?.(!0);}),useLayoutEffect(()=>{typeof t=="object"&&t?.current?e?.(!t.current.complete):e?.(!1);},[t,e]);function l(){e?.(!1);}return jsx(eo,{...i,maxWidth:d,maxHeight:s,ref:t,aspectRatio:o,onLoad:l,onError:l})});go.displayName="LoadingPreviewImage";var uo=go;var lr=({file:e,aspectRatio:o=1,isUploading:r,isLoading:i,onLoading:t,cropSize:d,maxWidth:s,maxHeight:l})=>{let p=useRef(null),n=e?.id||e?.url||e?.name,g=e?.name||e?.url||e?.id,x=URL.createObjectURL(e)||e?.url;return n?jsxs(Ye,{className:"single-file-preview-box",children:[jsx(uo,{className:"single-file-preview-img",aspectRatio:o,cropSize:d,isLoading:i,isUploading:r,alt:g,src:x,ref:p,loading:"lazy",onLoading:t,onLoad:()=>t?.(!1),onError:()=>t?.(!1),maxWidth:s,maxHeight:l},`image-preview-${n}`),jsx(oo,{className:"single-file-preview-bg",alt:g,src:x,isLoading:i,isUploading:r})]}):null},Ce=memo(lr);var hi=e=>e.startsWith("image/"),xo=(e,o=.8)=>new Promise((r,i)=>{let t=document.createElement("canvas"),d=t.getContext("2d"),s=new Image;s.onload=()=>{t.width=s.width,t.height=s.height,d?(d.drawImage(s,0,0),t.toBlob(l=>{if(l){let p=new File([l],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(p);}else i(new Error("Falha ao converter para WebP"));},"image/webp",o)):i(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},s.onerror=()=>i(new Error("Falha ao carregar imagem")),s.src=URL.createObjectURL(e);});var gr=({onFilesSelect:e$1,onFileSelect:o,onReorder:r,onRemove:i,filesPreview:t,dropzoneOptions:d,enableCrop:s=!1,customAspectRatio:l,convertToWebp:p=!0,cropSize:n,maxFiles:g})=>{let{showErrorMessage:x}=a$8(),E=useMemo(()=>l||(n&&typeof n!="number"?n.width/n.height:1),[l,n]),[u,b]=useState([]),[y,P]=useState(!1),[h,S]=useState(null),[f,F]=useState(null),[m,D]=useState(""),[A,R]=useState(!1),[I,M]=useState([]),[T,Z]=useState(0),[X,q]=useState(0),Y=c=>{if(c.length<1)return;let v=c[0];S(v),Z(_=>_+1);let O=new FileReader;O.onload=()=>{D(O.result),P(!0);},O.readAsDataURL(v);},ie=(c,v)=>{F(v);},ae=async()=>!h||!f?null:new Promise(c=>{let v=document.createElement("canvas"),O=v.getContext("2d"),_=new Image;_.onload=async()=>{let{width:U,height:he,x:Ao,y:wo}=f,ve=U,Ee=he;n&&(typeof n=="number"?(ve=n,Ee=n/E):(ve=n.width,Ee=n.height)),v.width=ve,v.height=Ee,O?(O.drawImage(_,Ao,wo,U,he,0,0,ve,Ee),v.toBlob(async je=>{if(je){let Ue=new File([je],h.name,{type:h.type,lastModified:Date.now()});if(p)try{Ue=await xo(Ue);}catch(Do){x(Do,"Erro ao converter para WebP");}c(Ue);}else c(null);},"image/png")):c(null);},_.src=m;}),ne=async()=>{if(!(!h||!f)){R(!0);try{let c=await ae();c&&e$1?e$1([c],b):c&&o&&o(c,b),P(!1),R(!1),D(""),S(null);let v=I.slice(1);M(v),Y(v);}catch(c){x(c,"Erro ao processar imagem");}}},C=()=>{P(!1),R(!1),D(""),S(null),M([]),Z(0),q(0);},H=c=>{if(c.length===0)return;let v=Object.keys(d?.accept||{}).some(_=>_.includes("image/")),O=u.length+c.length;if(g&&O>g){x(new Error(`M\xE1ximo de ${g} arquivos`),"Erro ao fazer upload");return}if(v&&s){let _=c.filter(U=>U.type.startsWith("image/"));q(_.length),Z(0),M(_),Y(_);}else if(e$1)e$1(c,b);else if(o){let _=c[0];o(_,b);}},z=c=>{if(!c.length)return;let v=c[0]?.errors[0]?.code,O=d?.maxSize||3145728;I.length,v==="file-too-large"?x(new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(O)}`),"Erro ao fazer upload"):v==="file-invalid-type"?x(new Error("Formato de arquivo n\xE3o suportado"),"Erro ao fainternalFiles.length > 0zer upload"):x(c[0]?.errors[0]||new Error("Erro ao enviar arquivo"),"Erro ao fazer upload");},{getRootProps:N,getInputProps:V,isDragActive:ee,isDragReject:k,fileRejections:B}=useDropzone({onDrop:H,onDropRejected:z,...d}),K=c=>{if(!c){b([]),i?.(void 0);return}if(e$1){let v=u.filter(O=>O.id!==c.id);b(v),i?.(c);}else b([]),i?.(c);},a=(c,v,O)=>{b(_=>{let U=[..._],[he]=U.splice(c,1);return U.splice(v,0,he),r?.(c,v,O),U});};return useEffect(()=>{let c=t||[];b(v=>{let O=JSON.stringify(v?.map(U=>U.id||U.name)),_=JSON.stringify(c?.map(U=>U.id||U.name));return O===_?v:c});},[t]),{file:u?.[0],files:u,aspectRatio:E,dropzoneProps:{getRootProps:N,getInputProps:V,isDragActive:ee,isDragReject:k,fileRejections:B},cropState:{cropModalOpen:y,imagePreview:m,cropLoading:A,setCropModalOpen:P,onCropInitialized:ie,handleCropSave:ne,handleCropCancel:C,currentImageIndex:T,totalPendingImages:X},setInitialFiles:b,handleRemove:K,handleReorder:a}},W=gr;var ze=(a=>(a.APPLICATION_OCTET_STREAM="application/octet-stream",a.IMAGE_JPEG="image/jpeg",a.IMAGE_JPG="image/jpg",a.IMAGE_PNG="image/png",a.IMAGE_GIF="image/gif",a.IMAGE_WEBP="image/webp",a.IMAGE_SVG="image/svg+xml",a.IMAGE_BMP="image/bmp",a.IMAGE_TIFF="image/tiff",a.IMAGE_ICO="image/x-icon",a.IMAGE_AVIF="image/avif",a.APPLICATION_PDF="application/pdf",a.TEXT_PLAIN="text/plain",a.TEXT_CSV="text/csv",a.APPLICATION_RTF="application/rtf",a.APPLICATION_MSWORD="application/msword",a.APPLICATION_DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",a.APPLICATION_MSEXCEL="application/vnd.ms-excel",a.APPLICATION_XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",a.APPLICATION_MSPOWERPOINT="application/vnd.ms-powerpoint",a.APPLICATION_PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",a.APPLICATION_ODT="application/vnd.oasis.opendocument.text",a.APPLICATION_ODS="application/vnd.oasis.opendocument.spreadsheet",a.APPLICATION_ODP="application/vnd.oasis.opendocument.presentation",a.APPLICATION_XML="application/xml",a.TEXT_XML="text/xml",a.TEXT_HTML="text/html",a.TEXT_CSS="text/css",a.APPLICATION_JSON="application/json",a.TEXT_JAVASCRIPT="text/javascript",a.APPLICATION_ZIP="application/zip",a.APPLICATION_GZIP="application/gzip",a.APPLICATION_RAR="application/vnd.rar",a.APPLICATION_7Z="application/x-7z-compressed",a.AUDIO_MPEG="audio/mpeg",a.AUDIO_WAV="audio/wav",a.AUDIO_OGG="audio/ogg",a.AUDIO_WEBM="audio/webm",a.AUDIO_AAC="audio/aac",a.VIDEO_MP4="video/mp4",a.VIDEO_MPEG="video/mpeg",a.VIDEO_OGG="video/ogg",a.VIDEO_WEBM="video/webm",a.VIDEO_QUICKTIME="video/quicktime",a))(ze||{}),ye=(e=>(e["application/octet-stream"]="APPLICATION_OCTET_STREAM",e["image/jpeg"]="IMAGE_JPEG",e["image/jpg"]="IMAGE_JPG",e["image/png"]="IMAGE_PNG",e["image/gif"]="IMAGE_GIF",e["image/webp"]="IMAGE_WEBP",e["image/svg+xml"]="IMAGE_SVG",e["image/bmp"]="IMAGE_BMP",e["image/tiff"]="IMAGE_TIFF",e["image/x-icon"]="IMAGE_ICO",e["image/avif"]="IMAGE_AVIF",e["application/pdf"]="APPLICATION_PDF",e["text/plain"]="TEXT_PLAIN",e["text/csv"]="TEXT_CSV",e["application/rtf"]="APPLICATION_RTF",e["application/msword"]="APPLICATION_MSWORD",e["application/vnd.openxmlformats-officedocument.wordprocessingml.document"]="APPLICATION_DOCX",e["application/vnd.ms-excel"]="APPLICATION_MSEXCEL",e["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]="APPLICATION_XLSX",e["application/vnd.ms-powerpoint"]="APPLICATION_MSPOWERPOINT",e["application/vnd.openxmlformats-officedocument.presentationml.presentation"]="APPLICATION_PPTX",e["application/vnd.oasis.opendocument.text"]="APPLICATION_ODT",e["application/vnd.oasis.opendocument.spreadsheet"]="APPLICATION_ODS",e["application/vnd.oasis.opendocument.presentation"]="APPLICATION_ODP",e["application/xml"]="APPLICATION_XML",e["text/xml"]="TEXT_XML",e["text/html"]="TEXT_HTML",e["text/css"]="TEXT_CSS",e["application/json"]="APPLICATION_JSON",e["text/javascript"]="TEXT_JAVASCRIPT",e["application/zip"]="APPLICATION_ZIP",e["application/gzip"]="APPLICATION_GZIP",e["application/vnd.rar"]="APPLICATION_RAR",e["application/x-7z-compressed"]="APPLICATION_7Z",e["audio/mpeg"]="AUDIO_MPEG",e["audio/wav"]="AUDIO_WAV",e["audio/ogg"]="AUDIO_OGG",e["audio/webm"]="AUDIO_WEBM",e["audio/aac"]="AUDIO_AAC",e["video/mp4"]="VIDEO_MP4",e["video/mpeg"]="VIDEO_MPEG",e["video/ogg"]="VIDEO_OGG",e["video/webm"]="VIDEO_WEBM",e["video/quicktime"]="VIDEO_QUICKTIME",e))(ye||{});var br=({createFilesMutation:e,filesUrl:o})=>{let{showErrorMessage:r}=a$8(),[i,t]=useState(!1),[d,s]=useState(!1),[l,p]=useState(null),[n,g]=useState(),x=useMemo(()=>n?.[0],[n]),E=d||i,u=useCallback(async P=>{if(!P?.length){g(void 0),s(!1);return}s(!0);try{let S=(await Promise.all(P.map(async(f,F)=>{try{if(!o[F])return null;let m=await fetch(o[F]);if(!m.ok)throw new Error(m.statusText);let D=await m.blob(),A=new File([D],f,{type:D.type});return A.id=f,A.url=URL.createObjectURL(A),A.index=F,A}catch{return null}}))).filter(f=>f!==null);g(S);}catch(h){r(h,"Erro ao carregar preview dos arquivos"),g(void 0);}finally{s(!1);}},[o,r]),b=useRef("");return useEffect(()=>{let P=JSON.stringify(o||[]);if(P===b.current)return;b.current=P;let h=!1;return (async()=>{if(o.length){let f=o.filter(Boolean);if(await u(f),h)return}else g(void 0),s(!1);})(),()=>{h=!0;}},[o,u]),{filesPreview:n,filePreview:x,uploadFiles:async(P,h)=>{if(P.filter(f=>f instanceof File)?.length){t(!0);try{let f=P[0].type||"application/octet-stream",F=ye[f];if(!F)throw new Error(`Tipo de arquivo n\xE3o suportado: ${f}`);let m=await e({files:P.map(I=>({content_type:F,name:I.name}))}).unwrap(),D=m.files.map(I=>I.id),A=[];return (await Promise.all(m.files.map((I,M)=>{let T=P[M];return T.id=I.id,T.url=URL.createObjectURL(T),A.push(T),fetch(I.url,{method:"PUT",headers:{"Content-Type":f},body:T})}))).forEach(I=>{if(!I.ok)throw new Error(`Erro no upload: ${I.statusText}`)}),h?.(A),D}catch(f){throw p(f),r(f,"Erro no upload"),f}finally{t(!1);}}},setFilesPreview:g,isUploadingFiles:i,isLoadingPreview:d,isUploadOrLoadingFiles:E,uploadFilesError:l}},Ir=br;var vr=({sx:e,id:o,name:r,tabIndex:i,uploading:t,getRootProps:d,getInputProps:s,isDragActive:l,isError:p,disabled:n,dropZoneSxProps:g,dropZoneContent:x,children:E,...u})=>jsxs(Re,{children:[t&&jsx(a$7,{"data-testid":"uploading-progress-bar",sx:{zIndex:1}}),jsxs(Pe,{sx:{width:1,position:"relative",...e},children:[jsxs(Xe,{...d(),"data-testid":"drop-zone-styled-area",isError:p,isDragActive:l,disabled:!!n,sx:g,...u,children:[jsx("input",{...s(),id:o,tabIndex:i,name:r}),x]}),E]})]}),oe=vr;var wr=({header:e,description:o,sx:r,...i})=>jsxs(le,{spacing:5,alignItems:"center",justifyContent:"center",direction:{xs:"column",md:"row"},sx:{width:1,textAlign:{xs:"center",md:"left"},...r},...i,children:[jsx(a$4,{sx:{width:220}}),jsxs("div",{children:[jsx(ke,{gutterBottom:!0,variant:"h5",children:e||"Soltar ou selecionar arquivos"}),jsx(ke,{variant:"body2",sx:{color:"text.secondary"},children:o||jsxs(Fragment,{children:["Solte os arquivos aqui ou clique",jsx(ke,{variant:"body2",component:"span",sx:{mx:.5,color:"primary.main",textDecoration:"underline"},children:"procurar"}),"na sua m\xE1quina"]})})]})]}),re=memo(wr);var _r=({onRemove:e,onReorder:o,onFilesSelect:r,id:i,disabled:t,error:d,helperText:s,files:l,thumbnail:p,dropZoneSxProps:n,uploading:g,tabIndex:x,maxFiles:E,placeholderAlt:u,placeholderProps:b,...y})=>{let{files:P,dropzoneProps:h,handleRemove:S,handleReorder:f}=W({onFilesSelect:r,onReorder:o,onRemove:e,filesPreview:l,dropzoneOptions:{multiple:!0,disabled:t,...y},maxFiles:E}),{getRootProps:F,getInputProps:m,isDragActive:D,isDragReject:A}=h,R=!!P?.filter(M=>!!M.id).length,I=A||!!d;return jsxs(oe,{id:i,uploading:g,disabled:t,dropZoneSxProps:n,tabIndex:x,getRootProps:F,getInputProps:m,isDragActive:D,isError:I,dropZoneContent:jsx(Fragment,{children:u?jsx(le,{children:u}):jsx(re,{header:b?.header,description:b?.description})}),children:[jsx(G,{disabled:t,helperText:s,isError:I}),R&&jsx(Pe,{sx:{my:3},children:jsx(Ie,{files:P,thumbnail:!!p,onRemove:e?S:void 0,onReorder:o?f:void 0})})]})},yr=memo(_r);var zr=({onFilesSelect:e,onRemove:o,onReorder:r,id:i,disabled:t,error:d,helperText:s,files:l,dropZoneSxProps:p,placeholderProps:n,placeholderAlt:g,uploading:x,tabIndex:E,maxFiles:u,aspectRatio:b,enableCrop:y=!0,convertToWebp:P=!0,cropSize:h,name:S,label:f,...F})=>{let{files:m,dropzoneProps:D,cropState:A,aspectRatio:R,handleRemove:I,handleReorder:M}=W({onFilesSelect:e,onReorder:r,onRemove:o,filesPreview:l,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:t,...F},enableCrop:y,customAspectRatio:b,convertToWebp:P,maxFiles:u,cropSize:h,uploading:x}),{getRootProps:T,getInputProps:Z,isDragActive:X,isDragReject:q}=D,{cropModalOpen:Y,imagePreview:ie,cropLoading:ae,onCropInitialized:ne,handleCropSave:C,handleCropCancel:H,currentImageIndex:z,totalPendingImages:N}=A,V=!!m?.filter(B=>!!B.id).length,ee=q||!!d,k=useMemo(()=>{let B=f??"Ajustar Imagem",K=N>1||z>1?` (${z} de ${N})`:"";return `${B}${K}`},[f,N,z]);return jsxs(oe,{id:i,name:S,uploading:x,disabled:t,dropZoneSxProps:p,tabIndex:E,getRootProps:T,getInputProps:Z,isDragActive:X,isError:ee,dropZoneContent:jsx(Fragment,{children:g?jsx(le,{children:g}):jsx(re,{header:n?.header,description:n?.description})}),children:[jsx(G,{disabled:t,helperText:s,isError:ee}),V&&jsx(Pe,{sx:{my:3,ml:.5},children:jsx(Ie,{files:m,thumbnail:!0,onRemove:I,onReorder:r?M:void 0})}),jsx(a$5,{open:Y,onClose:H,label:k,imageSrc:ie,aspectRatio:R,onInitialized:ne,onSave:C,loading:ae,cropSize:h})]})},Nr=memo(zr);var Zr=({onFileSelect:e$1,onRemove:o,file:r,id:i,disabled:t,error:d,helperText:s,sx:l,dropZoneSxProps:p,uploading:n,tabIndex:g,...x})=>{let E=r?[r]:[],{file:u,dropzoneProps:b,handleRemove:y}=W({onFileSelect:e$1,onRemove:o,filesPreview:E,dropzoneOptions:{multiple:!1,disabled:t,...x}}),{getRootProps:P,getInputProps:h,isDragActive:S,isDragReject:f$1}=b,F=useCallback(R=>{R.stopPropagation(),y(u||void 0);},[u,y]),m$1=!!u,D=typeof u=="string",A=f$1||!!d;return jsx(oe,{id:i,uploading:n,disabled:t,dropZoneSxProps:p,tabIndex:g,getRootProps:P,getInputProps:h,isDragActive:S,isError:A,dropZoneContent:jsxs(Fragment,{children:[!m$1&&jsx(re,{}),m$1&&jsxs(le,{component:m.div,...j().inUp,spacing:2,direction:"row",alignItems:"center",sx:{my:1,px:1,py:.75,borderRadius:.75,border:R=>`solid 1px ${R.palette.divider}`,...l},children:[jsx(f,{file:u}),jsxs(le,{flexGrow:1,sx:{minWidth:0},children:[jsx(ke,{variant:"subtitle2",noWrap:!0,children:D?u:u.name}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:D?"":e(u.size)})]}),o&&jsx(a$3,{title:"Remover arquivo",children:jsx(qe,{edge:"end",size:"small",disabled:t,"aria-label":"Remover arquivo",onClick:F,children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(G,{disabled:t,helperText:s,isError:A})})},Hr=memo(Zr);var Qr=({onRemove:e,onFileSelect:o,file:r,id:i,disabled:t,error:d,helperText:s,dropZoneSxProps:l,placeholderProps:p,placeholderAlt:n,uploading:g,tabIndex:x,aspectRatio:E,enableCrop:u=!0,convertToWebp:b=!0,name:y,label:P,cropSize:h,sx:S,maxWidth:f,maxHeight:F,...m})=>{let D=r?[r]:[],[A,R]=useState(!1),{file:I,dropzoneProps:M,cropState:T,handleRemove:Z,aspectRatio:X}=W({onFileSelect:o,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:t,...m},filesPreview:D,enableCrop:u,customAspectRatio:E,convertToWebp:b,cropSize:h}),{getRootProps:q,getInputProps:Y,isDragActive:ie,isDragReject:ae}=M,{cropModalOpen:ne,imagePreview:C,cropLoading:H,onCropInitialized:z,handleCropSave:N,handleCropCancel:V}=T,ee=useCallback(()=>{Z(I||void 0);},[I,Z]),k=!!I,B=ae||!!d,K=k?{opacity:0}:{opacity:1},a=l?.width;return useEffect(()=>{k||R(!1);},[k]),jsxs(Re,{sx:{...S,...a&&{width:a}},children:[(g||A)&&jsx(a$7,{}),jsxs(oe,{id:i,uploading:g,disabled:t,dropZoneSxProps:l,tabIndex:x,getRootProps:q,getInputProps:Y,isDragActive:ie,isError:B,name:y,dropZoneContent:jsxs(Fragment,{children:[n?jsx(le,{sx:K,children:n}):jsx(re,{sx:K,header:p?.title,description:p?.description}),k&&jsx(Ce,{file:I,cropSize:h,isLoading:A,isUploading:g,onLoading:R,aspectRatio:X,maxWidth:f,maxHeight:F})]}),children:[jsx(G,{disabled:t,helperText:s,isError:B}),k&&e&&jsx(Je,{size:"small",onClick:ee,disabled:t,label:"Remover arquivo",children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$5,{open:ne,onClose:V,label:P??"Ajustar Imagem",imageSrc:C,aspectRatio:X,onInitialized:z,onSave:N,loading:H,cropSize:h})]})]})},Yr=memo(Qr);var nt=({onFileSelect:e,onRemove:o,file:r,disabled:i,label:t,id:d,tabIndex:s,error:l,helperText:p,sx:n,name:g,maxSize:x,uploading:E,aspectRatio:u=1,enableCrop:b=!0,convertToWebp:y=!0,cropSize:P,...h})=>{let[S,f]=useState(!1),F=r?[r]:[],{file:m,dropzoneProps:D,cropState:A,handleRemove:R}=W({filesPreview:F,onFileSelect:e,onRemove:o,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,maxSize:x,...h},enableCrop:b,customAspectRatio:u,convertToWebp:y,cropSize:P}),{getRootProps:I,getInputProps:M,isDragActive:T,isDragReject:Z}=D,{cropModalOpen:X,imagePreview:q,cropLoading:Y,onCropInitialized:ie,handleCropSave:ae,handleCropCancel:ne}=A,C=Z||!!l,H=S||E,z=!!o,N=useRef(""),V=useRef();useEffect(()=>{if(!m){N.current="",V.current=void 0;return}let B=m.id??`${m.name}-${m.size}-${m.lastModified}`;if(V.current===B)return;V.current=B,f(!0);let K=URL.createObjectURL(m);return N.current=K,()=>{URL.revokeObjectURL(K);}},[m]);let ee=()=>{f(!1);},k=useCallback(()=>z&&m?()=>R(m):I().onClick,[z,m,I,R]);return jsxs(Fragment,{children:[jsxs(le,{sx:{alignItems:"center"},children:[jsxs(io,{sx:n,isError:C,isDragActive:T,hasFile:!!m,...I(),onClick:k(),children:[jsxs(ro,{children:[m&&jsx(ao,{alt:"Avatar Preview",src:N.current,onLoad:ee,...H&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),H&&jsx(to,{children:jsx(at,{size:135,thickness:1,color:"primary"})}),!m&&!H&&jsxs(Te,{isError:C,hasFile:!1,children:[jsx(a$6,{icon:"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"text.disabled"},children:"Adicionar foto"})]}),m&&!H&&jsxs(Te,{isError:C,hasFile:!0,children:[jsx(a$6,{icon:z?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"common.white"},children:z?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:g,id:d,tabIndex:s,...M()})]}),jsx(le,{sx:{alignItems:"center",mt:-.5},children:jsx(G,{helperText:p,disabled:i,isError:C})})]}),X&&q&&jsx(a$5,{open:X,onClose:ne,label:t??"Ajustar Imagem",imageSrc:q,aspectRatio:u,onInitialized:ie,onSave:ae,loading:Y,cropSize:P,cropShape:"round"})]})},st=memo(nt);var mt=({error:e,name:o,disabled:r,sx:i,...t})=>{let{getRootProps:d,getInputProps:s,isDragActive:l,isDragReject:p}=useDropzone({disabled:r,...t}),n=p||e;return jsxs(Qe,{...d(),isDragActive:l,hasError:!!n,disabled:!!r,sx:i,"data-testid":"upload-box",children:[jsx("input",{name:o,...s()}),"Selecionar arquivo"]})},ct=memo(mt);
|
|
35
|
+
var Ro=({helperText:e,disabled:o,isError:r})=>e?jsx(So,{error:r,sx:i=>({mx:"14px",color:o?i.palette.grey[500]:void 0}),children:e}):null,G=memo(Ro);var Se=styled(le)({position:"relative",width:"100%",borderRadius:8,overflow:"hidden","&:hover .actions":{display:"flex"}}),Re=styled(le)({position:"absolute",top:4,right:4,gap:.5,"& svg":{width:16,height:16}}),Xe=styled(Pe,{shouldForwardProp:e=>!["isDragActive","isError","disabled"].includes(e)})(({theme:e,isDragActive:o,isError:r,disabled:i})=>({outline:"none",cursor:"pointer",overflow:"hidden",position:"relative",padding:e.spacing(5),borderRadius:e.shape.borderRadius,transition:e.transitions.create("padding"),backgroundColor:e.palette.background.neutral,border:`1px dashed ${alpha(e.palette.grey[500],.32)}`,...o&&{opacity:.72},...r&&{color:e.palette.error.main,backgroundColor:e.palette.error.lighter,borderColor:e.palette.error.light},...i&&{opacity:.48,pointerEvents:"none"},"&:hover":{opacity:.72}}));styled(le)(({theme:e})=>({display:"none",position:"absolute",alignItems:"center",justifyContent:"center",flexDirection:"row",gap:12,width:"100%",height:"100%",backgroundColor:alpha(e.palette.primary.main,.9),zIndex:999,button:{"&, &:hover, &:focus":{backgroundColor:"#fff"}}}));var qe=styled(yo)(({theme:e})=>({position:"relative",zIndex:999,pointerEvents:"auto",color:e.palette.grey[700],backgroundColor:e.palette.grey[100],"&:hover":{color:e.palette.grey[900],backgroundColor:e.palette.grey[300]}})),Me=styled("div")({position:"relative",zIndex:1,"&:hover":{zIndex:2}}),Ve=styled(le,{shouldForwardProp:e=>!["isDragging"].includes(e)})(({theme:e,width:o,isDragging:r})=>({width:o,height:100,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2,1,2,1),gap:e.spacing(1),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),Ke=styled(m.div)(({theme:e,width:o,isDragging:r})=>({width:o,height:60,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),Je=styled(a)(({theme:e})=>({top:16,right:16,zIndex:9,position:"absolute",color:e.palette.common.white,backgroundColor:alpha(e.palette.grey[900],.72),"&:hover":{backgroundColor:alpha(e.palette.grey[900],.48)}})),Qe=styled(Pe,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="disabled"&&e!=="hasError"})(({theme:e,isDragActive:o,disabled:r,hasError:i})=>({width:64,height:64,flexShrink:0,display:"flex",borderRadius:1,cursor:"pointer",alignItems:"center",color:e.palette.text.disabled,justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),border:`dashed 1px ${alpha(e.palette.grey[500],.16)}`,...o&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...i&&{color:e.palette.error.main,borderColor:e.palette.error.main,backgroundColor:alpha(e.palette.error.main,.08)},"&:hover":{opacity:.72}})),Ye=styled(Pe)(({theme:e})=>({padding:e.spacing(1),top:0,left:0,width:"100%",height:"100%",position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",transition:"all 0.3s ease-in-out",filter:"blur(0)","&:hover":{filter:"blur(3px)"}})),eo=styled("img",{shouldForwardProp:e=>e!=="aspectRatio"&&e!=="isLoading"&&e!=="isUploading"&&e!=="maxWidth"&&e!=="maxHeight"&&e!=="cropSize"})(({theme:e,aspectRatio:o,maxWidth:r,maxHeight:i,isLoading:t,isUploading:m})=>({borderRadius:e.shape.borderRadius,objectFit:"cover",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) scale(1)",filter:"blur(0)",zIndex:1,maxWidth:r,maxHeight:i,backgroundColor:e.palette.background.paper,width:o>1?"calc(100% - 16px)":void 0,height:o>1?void 0:"calc(100% - 16px)",aspectRatio:o,transition:"all 0.5s ease-in-out",...t||m?{opacity:0,filter:"blur(1.5rem)",transform:"translate(-50%, -50%) scale(0.7)"}:{},"&:hover":{transition:"all 0.2s ease-in-out"}})),oo=styled("img",{shouldForwardProp:e=>e!=="isLoading"&&e!=="isUploading"})(({isLoading:e,isUploading:o})=>({width:"100%",height:"100%",objectFit:"cover",top:0,left:0,filter:"blur(1.5rem)",transform:"scale(1.1)",position:"absolute",zIndex:0,transition:"opacity 0.3s ease-in-out",...e&&{opacity:0},...o&&{opacity:.7,filter:"blur(2rem)"}})),ro=styled(le)({width:"100%",height:"100%",position:"relative",overflow:"hidden",borderRadius:"50%",justifyContent:"center",alignItems:"center"});styled(Oo)(({theme:e})=>({py:1,px:2,mt:3,textAlign:"left",borderStyle:"dashed",borderColor:"error.main",backgroundColor:alpha(e.palette.error.main,.08)}));var Te=styled(Pe,{shouldForwardProp:e=>e!=="isError"&&e!=="hasFile"})(({theme:e,isError:o,hasFile:r})=>({top:0,gap:e.spacing(1),left:0,width:"100%",height:"100%",zIndex:9,display:"flex",borderRadius:"50%",position:"absolute",alignItems:"center",color:e.palette.text.disabled,flexDirection:"column",justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),transition:e.transitions.create(["opacity"],{duration:e.transitions.duration.shorter}),"&:hover":{opacity:.92},...o&&{color:e.palette.error.main},...r&&{zIndex:9,opacity:0,color:e.palette.common.white,backgroundColor:alpha(e.palette.common.black,.54)}})),to=styled(le)({top:0,left:0,right:0,bottom:0,position:"absolute",zIndex:10,alignItems:"center",justifyContent:"center",opacity:.8});styled(le)(({theme:e})=>({padding:20,justifyContent:"center",alignItems:"center",gap:4,alignSelf:"stretch",borderRadius:12,background:e.palette.grey[200],color:e.palette.text.disabled,height:160}));var io=styled(Pe,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="isError"&&e!=="hasFile"})(({theme:e,isDragActive:o,disabled:r,isError:i,hasFile:t})=>({padding:e.spacing(1),margin:"auto",width:144,height:144,cursor:"pointer",overflow:"hidden",borderRadius:"50%",border:`1px dashed ${alpha(e.palette.grey[500],.2)}`,...o&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...i&&{borderColor:"error.main"},...t&&{...i&&{bgcolor:alpha(e.palette.error.main,.08)},"&:hover .upload-placeholder":{opacity:1},"& img":{filter:"blur(0)"},"&:hover img":{filter:"blur(3px)"}}})),ao=styled("img")({width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover",transition:"all 0.3s ease-in-out"}),no=styled(a)(({theme:e})=>({backgroundColor:alpha(e.palette.grey[900],.72),color:e.palette.common.white,"&:hover":{backgroundColor:alpha(e.palette.grey[600],.64),color:e.palette.common.white},"& svg":{width:14,height:14}}));var To=({onRemove:e,sx:o,file:r,disableDrag:i,attributes:t,listeners:m,innerWidth:s,isDragging:p})=>{let d=r?.id||r?.url;return d?jsx(Mo,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Ke,{width:s,isDragging:p,"data-testid":`preview-multi-img-${d}`,...j().inUp,sx:o,children:[jsx(a$2,{disableDrag:i,...t,...m}),jsx(f,{tooltip:!0,imageView:!0,file:r}),jsx(Re,{sx:{position:"absolute",right:3,top:3,zIndex:1},children:e&&jsx(no,{size:"small",label:"Remover arquivo",onClick:()=>e(r),icon:"DELETE_MARK_BUTTON_02"})})]})},`badge-${d}`):null},so=memo(To);var Bo=({file:e$1,thumbnail:o,onRemove:r,sx:i,disableDrag:t=!1})=>{let m=e$1?.size||0,s=e$1?.name||e$1?.id||e$1?.url,p=e$1?.id||e$1?.url||e$1?.name||e$1?.index?.toString()||"",d=typeof e$1=="string",n=t?70:80,{attributes:g,listeners:x$1,setNodeRef:E,transform:u,transition:I,isDragging:y}=useSortable({id:p,disabled:t}),P={transform:x.Transform.toString(u),transition:I,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${n+8}px`,height:"68px"};return o&&e$1?jsx(Me,{ref:E,style:P,children:jsx(so,{innerWidth:n,isDragging:y,sx:i,file:e$1,disableDrag:t,attributes:g,listeners:x$1,onRemove:r})}):jsx(Me,{ref:E,style:{...P,height:"80px",width:`${n+38}px`},children:jsxs(Ve,{width:n+30,isDragging:y,"data-testid":`preview-multi-img-${p}`,...j().inUp,sx:i,children:[jsx(a$2,{disableDrag:t,...g,...x$1}),e$1&&jsx(f,{file:e$1}),jsxs(le,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$3,{title:s,children:jsx(ke,{variant:"subtitle2",noWrap:!0,children:s})}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:d?"":e(m)})]}),jsx(Re,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},mo=memo(Bo);var or=({thumbnail:e,files:o,onRemove:r,onReorder:i,sx:t})=>{let m=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),s=useCallback(d=>{let{active:n,over:g}=d;if(!(!n||!g||n.id===g.id)&&i){let x=o.findIndex(({id:u})=>u===n.id),E=o.findIndex(({id:u})=>u===g.id);x!==-1&&E!==-1&&i(x,E,o);}},[o,i]),p=jsx(AnimatePresence,{initial:!1,children:o.map(d=>jsx(mo,{sx:t,id:`preview-file-${d.id}`,file:d,onRemove:r,thumbnail:e,disableDrag:!i},`preview-file-${d.id}`))});return i?jsx(DndContext,{sensors:m,collisionDetection:closestCenter,onDragEnd:s,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:o.map(d=>d.id),strategy:horizontalListSortingStrategy,children:p})}):p},Ie=memo(or);var go=forwardRef(({onLoading:e,aspectRatio:o,cropSize:r,...i},t)=>{let{maxWidth:m,maxHeight:s}=useMemo(()=>r&&typeof r=="object"?{maxWidth:r.width,maxHeight:r.height}:r&&typeof r=="number"?{maxWidth:r,maxHeight:r}:{maxWidth:"100%",maxHeight:"100%"},[r]);a$1(()=>{e?.(!0);}),useLayoutEffect(()=>{typeof t=="object"&&t?.current?e?.(!t.current.complete):e?.(!1);},[t,e]);function p(){e?.(!1);}return jsx(eo,{...i,maxWidth:m,maxHeight:s,ref:t,aspectRatio:o,onLoad:p,onError:p})});go.displayName="LoadingPreviewImage";var uo=go;var lr=({file:e,aspectRatio:o=1,isUploading:r,isLoading:i,onLoading:t,cropSize:m,maxWidth:s,maxHeight:p})=>{let d=useRef(null),n=e?.id||e?.url||e?.name,g=e?.name||e?.url||e?.id,x=URL.createObjectURL(e)||e?.url;return n?jsxs(Ye,{className:"single-file-preview-box",children:[jsx(uo,{className:"single-file-preview-img",aspectRatio:o,cropSize:m,isLoading:i,isUploading:r,alt:g,src:x,ref:d,loading:"lazy",onLoading:t,onLoad:()=>t?.(!1),onError:()=>t?.(!1),maxWidth:s,maxHeight:p},`image-preview-${n}`),jsx(oo,{className:"single-file-preview-bg",alt:g,src:x,isLoading:i,isUploading:r})]}):null},Ce=memo(lr);var hi=e=>e.startsWith("image/"),xo=(e,o=.8)=>new Promise((r,i)=>{let t=document.createElement("canvas"),m=t.getContext("2d"),s=new Image;s.onload=()=>{t.width=s.width,t.height=s.height,m?(m.drawImage(s,0,0),t.toBlob(p=>{if(p){let d=new File([p],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(d);}else i(new Error("Falha ao converter para WebP"));},"image/webp",o)):i(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},s.onerror=()=>i(new Error("Falha ao carregar imagem")),s.src=URL.createObjectURL(e);});var gr=({onFilesSelect:e$1,onFileSelect:o,onReorder:r,onRemove:i,filesPreview:t,dropzoneOptions:m,enableCrop:s=!1,customAspectRatio:p,convertToWebp:d=!0,cropSize:n,maxFiles:g})=>{let{showErrorMessage:x}=a$8(),E=useMemo(()=>p||(n&&typeof n!="number"?n.width/n.height:1),[p,n]),[u,I]=useState([]),[y,P]=useState(!1),[h,R]=useState(null),[b,D]=useState(null),[l,F]=useState(""),[S,w]=useState(!1),[f,M]=useState([]),[T,Z]=useState(0),[X,q]=useState(0),Y=c=>{if(c.length<1)return;let v=c[0];R(v),Z(_=>_+1);let O=new FileReader;O.onload=()=>{F(O.result),P(!0);},O.readAsDataURL(v);},ie=(c,v)=>{D(v);},ae=async()=>!h||!b?null:new Promise(c=>{let v=document.createElement("canvas"),O=v.getContext("2d"),_=new Image;_.onload=async()=>{let{width:U,height:he,x:Ao,y:wo}=b,ve=U,Ee=he;n&&(typeof n=="number"?(ve=n,Ee=n/E):(ve=n.width,Ee=n.height)),v.width=ve,v.height=Ee,O?(O.drawImage(_,Ao,wo,U,he,0,0,ve,Ee),v.toBlob(async je=>{if(je){let Ue=new File([je],h.name,{type:h.type,lastModified:Date.now()});if(d)try{Ue=await xo(Ue);}catch(Do){x(Do,"Erro ao converter para WebP");}c(Ue);}else c(null);},"image/png")):c(null);},_.src=l;}),ne=async()=>{if(!(!h||!b)){w(!0);try{let c=await ae();c&&e$1?e$1([c],I):c&&o&&o(c,I),P(!1),w(!1),F(""),R(null);let v=f.slice(1);M(v),Y(v);}catch(c){x(c,"Erro ao processar imagem");}}},C=()=>{P(!1),w(!1),F(""),R(null),M([]),Z(0),q(0);},H=c=>{if(c.length===0)return;let v=Object.keys(m?.accept||{}).some(_=>_.includes("image/")),O=u.length+c.length;if(g&&O>g){x(new Error(`M\xE1ximo de ${g} arquivos`),"Erro ao fazer upload");return}if(v&&s){let _=c.filter(U=>U.type.startsWith("image/"));q(_.length),Z(0),M(_),Y(_);}else if(e$1)e$1(c,I);else if(o){let _=c[0];o(_,I);}},z=c=>{if(!c.length)return;let v=c[0]?.errors[0]?.code,O=m?.maxSize||3145728;f.length,v==="file-too-large"?x(new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(O)}`),"Erro ao fazer upload"):v==="file-invalid-type"?x(new Error("Formato de arquivo n\xE3o suportado"),"Erro ao fainternalFiles.length > 0zer upload"):x(c[0]?.errors[0]||new Error("Erro ao enviar arquivo"),"Erro ao fazer upload");},{getRootProps:N,getInputProps:V,isDragActive:ee,isDragReject:k,fileRejections:B}=useDropzone({onDrop:H,onDropRejected:z,...m}),K=c=>{if(!c){I([]),i?.(void 0);return}if(e$1){let v=u.filter(O=>O.id!==c.id);I(v),i?.(c);}else I([]),i?.(c);},a=(c,v,O)=>{I(_=>{let U=[..._],[he]=U.splice(c,1);return U.splice(v,0,he),r?.(c,v,O),U});};return useEffect(()=>{let c=t||[];I(v=>{let O=JSON.stringify(v?.map(U=>U.id||U.name)),_=JSON.stringify(c?.map(U=>U.id||U.name));return O===_?v:c});},[t]),{file:u?.[0],files:u,aspectRatio:E,dropzoneProps:{getRootProps:N,getInputProps:V,isDragActive:ee,isDragReject:k,fileRejections:B},cropState:{cropModalOpen:y,imagePreview:l,cropLoading:S,setCropModalOpen:P,onCropInitialized:ie,handleCropSave:ne,handleCropCancel:C,currentImageIndex:T,totalPendingImages:X},setInitialFiles:I,handleRemove:K,handleReorder:a}},W=gr;var ze=(a=>(a.APPLICATION_OCTET_STREAM="application/octet-stream",a.IMAGE_JPEG="image/jpeg",a.IMAGE_JPG="image/jpg",a.IMAGE_PNG="image/png",a.IMAGE_GIF="image/gif",a.IMAGE_WEBP="image/webp",a.IMAGE_SVG="image/svg+xml",a.IMAGE_BMP="image/bmp",a.IMAGE_TIFF="image/tiff",a.IMAGE_ICO="image/x-icon",a.IMAGE_AVIF="image/avif",a.APPLICATION_PDF="application/pdf",a.TEXT_PLAIN="text/plain",a.TEXT_CSV="text/csv",a.APPLICATION_RTF="application/rtf",a.APPLICATION_MSWORD="application/msword",a.APPLICATION_DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",a.APPLICATION_MSEXCEL="application/vnd.ms-excel",a.APPLICATION_XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",a.APPLICATION_MSPOWERPOINT="application/vnd.ms-powerpoint",a.APPLICATION_PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",a.APPLICATION_ODT="application/vnd.oasis.opendocument.text",a.APPLICATION_ODS="application/vnd.oasis.opendocument.spreadsheet",a.APPLICATION_ODP="application/vnd.oasis.opendocument.presentation",a.APPLICATION_XML="application/xml",a.TEXT_XML="text/xml",a.TEXT_HTML="text/html",a.TEXT_CSS="text/css",a.APPLICATION_JSON="application/json",a.TEXT_JAVASCRIPT="text/javascript",a.APPLICATION_ZIP="application/zip",a.APPLICATION_GZIP="application/gzip",a.APPLICATION_RAR="application/vnd.rar",a.APPLICATION_7Z="application/x-7z-compressed",a.AUDIO_MPEG="audio/mpeg",a.AUDIO_WAV="audio/wav",a.AUDIO_OGG="audio/ogg",a.AUDIO_WEBM="audio/webm",a.AUDIO_AAC="audio/aac",a.VIDEO_MP4="video/mp4",a.VIDEO_MPEG="video/mpeg",a.VIDEO_OGG="video/ogg",a.VIDEO_WEBM="video/webm",a.VIDEO_QUICKTIME="video/quicktime",a))(ze||{}),ye=(e=>(e["application/octet-stream"]="APPLICATION_OCTET_STREAM",e["image/jpeg"]="IMAGE_JPEG",e["image/jpg"]="IMAGE_JPG",e["image/png"]="IMAGE_PNG",e["image/gif"]="IMAGE_GIF",e["image/webp"]="IMAGE_WEBP",e["image/svg+xml"]="IMAGE_SVG",e["image/bmp"]="IMAGE_BMP",e["image/tiff"]="IMAGE_TIFF",e["image/x-icon"]="IMAGE_ICO",e["image/avif"]="IMAGE_AVIF",e["application/pdf"]="APPLICATION_PDF",e["text/plain"]="TEXT_PLAIN",e["text/csv"]="TEXT_CSV",e["application/rtf"]="APPLICATION_RTF",e["application/msword"]="APPLICATION_MSWORD",e["application/vnd.openxmlformats-officedocument.wordprocessingml.document"]="APPLICATION_DOCX",e["application/vnd.ms-excel"]="APPLICATION_MSEXCEL",e["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]="APPLICATION_XLSX",e["application/vnd.ms-powerpoint"]="APPLICATION_MSPOWERPOINT",e["application/vnd.openxmlformats-officedocument.presentationml.presentation"]="APPLICATION_PPTX",e["application/vnd.oasis.opendocument.text"]="APPLICATION_ODT",e["application/vnd.oasis.opendocument.spreadsheet"]="APPLICATION_ODS",e["application/vnd.oasis.opendocument.presentation"]="APPLICATION_ODP",e["application/xml"]="APPLICATION_XML",e["text/xml"]="TEXT_XML",e["text/html"]="TEXT_HTML",e["text/css"]="TEXT_CSS",e["application/json"]="APPLICATION_JSON",e["text/javascript"]="TEXT_JAVASCRIPT",e["application/zip"]="APPLICATION_ZIP",e["application/gzip"]="APPLICATION_GZIP",e["application/vnd.rar"]="APPLICATION_RAR",e["application/x-7z-compressed"]="APPLICATION_7Z",e["audio/mpeg"]="AUDIO_MPEG",e["audio/wav"]="AUDIO_WAV",e["audio/ogg"]="AUDIO_OGG",e["audio/webm"]="AUDIO_WEBM",e["audio/aac"]="AUDIO_AAC",e["video/mp4"]="VIDEO_MP4",e["video/mpeg"]="VIDEO_MPEG",e["video/ogg"]="VIDEO_OGG",e["video/webm"]="VIDEO_WEBM",e["video/quicktime"]="VIDEO_QUICKTIME",e))(ye||{});var br=({createFilesMutation:e,filesUrl:o})=>{let{showErrorMessage:r}=a$8(),[i,t]=useState(!1),[m,s]=useState(!1),[p,d]=useState(null),[n,g]=useState(),x=useMemo(()=>n?.[0],[n]),E=m||i,u=useCallback(async P=>{if(!P?.length){g(void 0),s(!1);return}s(!0);try{let R=(await Promise.all(P.map(async(b,D)=>{try{if(!o[D])return null;let l=await fetch(o[D]);if(!l.ok)throw new Error(l.statusText);let F=await l.blob(),S=l.headers.get("etag"),w=l.headers.get("x-file-name")||S,f=new File([F],w,{type:F.type});return f.id=S,f.url=o[D],f.index=D,f}catch{return null}}))).filter(b=>b!==null);g(R);}catch(h){r(h,"Erro ao carregar preview dos arquivos"),g(void 0);}finally{s(!1);}},[o,r]),I=useRef("");return useEffect(()=>{let P=JSON.stringify(o||[]);if(P===I.current)return;I.current=P;let h=!1;return (async()=>{if(o.length){let b=o.filter(Boolean);if(await u(b),h)return}else g(void 0),s(!1);})(),()=>{h=!0;}},[o,u]),{filesPreview:n,filePreview:x,uploadFiles:async(P,h)=>{if(P.filter(b=>b instanceof File)?.length){t(!0);try{let b=P[0].type||"application/octet-stream",D=ye[b];if(!D)throw new Error(`Tipo de arquivo n\xE3o suportado: ${b}`);let l=await e({files:P.map(f=>({content_type:D,name:f.name}))}).unwrap(),F=l.files.map(f=>f.id),S=[];return (await Promise.all(l.files.map((f,M)=>{let T=P[M];return T.id=f.id,T.url=URL.createObjectURL(T),S.push(T),fetch(f.url,{method:"PUT",headers:{"Content-Type":b},body:T})}))).forEach(f=>{if(!f.ok)throw new Error(`Erro no upload: ${f.statusText}`)}),h?.(S),F}catch(b){throw d(b),r(b,"Erro no upload"),b}finally{t(!1);}}},setFilesPreview:g,isUploadingFiles:i,isLoadingPreview:m,isUploadOrLoadingFiles:E,uploadFilesError:p}},Ir=br;var vr=({sx:e,id:o,name:r,tabIndex:i,uploading:t,getRootProps:m,getInputProps:s,isDragActive:p,isError:d,disabled:n,dropZoneSxProps:g,dropZoneContent:x,children:E,...u})=>jsxs(Se,{children:[t&&jsx(a$7,{"data-testid":"uploading-progress-bar",sx:{zIndex:1}}),jsxs(Pe,{sx:{width:1,position:"relative",...e},children:[jsxs(Xe,{...m(),"data-testid":"drop-zone-styled-area",isError:d,isDragActive:p,disabled:!!n,sx:g,...u,children:[jsx("input",{...s(),id:o,tabIndex:i,name:r}),x]}),E]})]}),oe=vr;var wr=({header:e,description:o,sx:r,...i})=>jsxs(le,{spacing:5,alignItems:"center",justifyContent:"center",direction:{xs:"column",md:"row"},sx:{width:1,textAlign:{xs:"center",md:"left"},...r},...i,children:[jsx(a$4,{sx:{width:220}}),jsxs("div",{children:[jsx(ke,{gutterBottom:!0,variant:"h5",children:e||"Soltar ou selecionar arquivos"}),jsx(ke,{variant:"body2",sx:{color:"text.secondary"},children:o||jsxs(Fragment,{children:["Solte os arquivos aqui ou clique",jsx(ke,{variant:"body2",component:"span",sx:{mx:.5,color:"primary.main",textDecoration:"underline"},children:"procurar"}),"na sua m\xE1quina"]})})]})]}),re=memo(wr);var _r=({onRemove:e,onReorder:o,onFilesSelect:r,id:i,disabled:t,error:m,helperText:s,files:p,thumbnail:d,dropZoneSxProps:n,uploading:g,tabIndex:x,maxFiles:E,placeholderAlt:u,placeholderProps:I,...y})=>{let{files:P,dropzoneProps:h,handleRemove:R,handleReorder:b}=W({onFilesSelect:r,onReorder:o,onRemove:e,filesPreview:p,dropzoneOptions:{multiple:!0,disabled:t,...y},maxFiles:E}),{getRootProps:D,getInputProps:l,isDragActive:F,isDragReject:S}=h,w=!!P?.filter(M=>!!M.id).length,f=S||!!m;return jsxs(oe,{id:i,uploading:g,disabled:t,dropZoneSxProps:n,tabIndex:x,getRootProps:D,getInputProps:l,isDragActive:F,isError:f,dropZoneContent:jsx(Fragment,{children:u?jsx(le,{children:u}):jsx(re,{header:I?.header,description:I?.description})}),children:[jsx(G,{disabled:t,helperText:s,isError:f}),w&&jsx(Pe,{sx:{my:3},children:jsx(Ie,{files:P,thumbnail:!!d,onRemove:e?R:void 0,onReorder:o?b:void 0})})]})},yr=memo(_r);var zr=({onFilesSelect:e,onRemove:o,onReorder:r,id:i,disabled:t,error:m,helperText:s,files:p,dropZoneSxProps:d,placeholderProps:n,placeholderAlt:g,uploading:x,tabIndex:E,maxFiles:u,aspectRatio:I,enableCrop:y=!0,convertToWebp:P=!0,cropSize:h,name:R,label:b,...D})=>{let{files:l,dropzoneProps:F,cropState:S,aspectRatio:w,handleRemove:f,handleReorder:M}=W({onFilesSelect:e,onReorder:r,onRemove:o,filesPreview:p,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:t,...D},enableCrop:y,customAspectRatio:I,convertToWebp:P,maxFiles:u,cropSize:h,uploading:x}),{getRootProps:T,getInputProps:Z,isDragActive:X,isDragReject:q}=F,{cropModalOpen:Y,imagePreview:ie,cropLoading:ae,onCropInitialized:ne,handleCropSave:C,handleCropCancel:H,currentImageIndex:z,totalPendingImages:N}=S,V=!!l?.filter(B=>!!B.id).length,ee=q||!!m,k=useMemo(()=>{let B=b??"Ajustar Imagem",K=N>1||z>1?` (${z} de ${N})`:"";return `${B}${K}`},[b,N,z]);return jsxs(oe,{id:i,name:R,uploading:x,disabled:t,dropZoneSxProps:d,tabIndex:E,getRootProps:T,getInputProps:Z,isDragActive:X,isError:ee,dropZoneContent:jsx(Fragment,{children:g?jsx(le,{children:g}):jsx(re,{header:n?.header,description:n?.description})}),children:[jsx(G,{disabled:t,helperText:s,isError:ee}),V&&jsx(Pe,{sx:{my:3,ml:.5},children:jsx(Ie,{files:l,thumbnail:!0,onRemove:f,onReorder:r?M:void 0})}),jsx(a$5,{open:Y,onClose:H,label:k,imageSrc:ie,aspectRatio:w,onInitialized:ne,onSave:C,loading:ae,cropSize:h})]})},Nr=memo(zr);var Zr=({onFileSelect:e$1,onRemove:o,file:r,id:i,disabled:t,error:m$1,helperText:s,sx:p,dropZoneSxProps:d,uploading:n,tabIndex:g,...x})=>{let E=r?[r]:[],{file:u,dropzoneProps:I,handleRemove:y}=W({onFileSelect:e$1,onRemove:o,filesPreview:E,dropzoneOptions:{multiple:!1,disabled:t,...x}}),{getRootProps:P,getInputProps:h,isDragActive:R,isDragReject:b}=I,D=useCallback(w=>{w.stopPropagation(),y(u||void 0);},[u,y]),l=!!u,F=typeof u=="string",S=b||!!m$1;return jsx(oe,{id:i,uploading:n,disabled:t,dropZoneSxProps:d,tabIndex:g,getRootProps:P,getInputProps:h,isDragActive:R,isError:S,dropZoneContent:jsxs(Fragment,{children:[!l&&jsx(re,{}),l&&jsxs(le,{component:m.div,...j().inUp,spacing:2,direction:"row",alignItems:"center",sx:{my:1,px:1,py:.75,borderRadius:.75,border:w=>`solid 1px ${w.palette.divider}`,...p},children:[jsx(f,{file:u}),jsxs(le,{flexGrow:1,sx:{minWidth:0},children:[jsx(ke,{variant:"subtitle2",noWrap:!0,children:F?u:u.name}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:F?"":e(u.size)})]}),o&&jsx(a$3,{title:"Remover arquivo",children:jsx(qe,{edge:"end",size:"small",disabled:t,"aria-label":"Remover arquivo",onClick:D,children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(G,{disabled:t,helperText:s,isError:S})})},Hr=memo(Zr);var Qr=({onRemove:e,onFileSelect:o,file:r,id:i,disabled:t,error:m,helperText:s,dropZoneSxProps:p,placeholderProps:d,placeholderAlt:n,uploading:g,tabIndex:x,aspectRatio:E,enableCrop:u=!0,convertToWebp:I=!0,name:y,label:P,cropSize:h,sx:R,maxWidth:b,maxHeight:D,...l})=>{let F=r?[r]:[],[S,w]=useState(!1),{file:f,dropzoneProps:M,cropState:T,handleRemove:Z,aspectRatio:X}=W({onFileSelect:o,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:t,...l},filesPreview:F,enableCrop:u,customAspectRatio:E,convertToWebp:I,cropSize:h}),{getRootProps:q,getInputProps:Y,isDragActive:ie,isDragReject:ae}=M,{cropModalOpen:ne,imagePreview:C,cropLoading:H,onCropInitialized:z,handleCropSave:N,handleCropCancel:V}=T,ee=useCallback(()=>{Z(f||void 0);},[f,Z]),k=!!f,B=ae||!!m,K=k?{opacity:0}:{opacity:1},a=p?.width;return useEffect(()=>{k||w(!1);},[k]),jsxs(Se,{sx:{...R,...a&&{width:a}},children:[(g||S)&&jsx(a$7,{}),jsxs(oe,{id:i,uploading:g,disabled:t,dropZoneSxProps:p,tabIndex:x,getRootProps:q,getInputProps:Y,isDragActive:ie,isError:B,name:y,dropZoneContent:jsxs(Fragment,{children:[n?jsx(le,{sx:K,children:n}):jsx(re,{sx:K,header:d?.title,description:d?.description}),k&&jsx(Ce,{file:f,cropSize:h,isLoading:S,isUploading:g,onLoading:w,aspectRatio:X,maxWidth:b,maxHeight:D})]}),children:[jsx(G,{disabled:t,helperText:s,isError:B}),k&&e&&jsx(Je,{size:"small",onClick:ee,disabled:t,label:"Remover arquivo",children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$5,{open:ne,onClose:V,label:P??"Ajustar Imagem",imageSrc:C,aspectRatio:X,onInitialized:z,onSave:N,loading:H,cropSize:h})]})]})},Yr=memo(Qr);var nt=({onFileSelect:e,onRemove:o,file:r,disabled:i,label:t,id:m,tabIndex:s,error:p,helperText:d,sx:n,name:g,maxSize:x,uploading:E,aspectRatio:u=1,enableCrop:I=!0,convertToWebp:y=!0,cropSize:P,...h})=>{let[R,b]=useState(!1),D=r?[r]:[],{file:l,dropzoneProps:F,cropState:S,handleRemove:w}=W({filesPreview:D,onFileSelect:e,onRemove:o,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,maxSize:x,...h},enableCrop:I,customAspectRatio:u,convertToWebp:y,cropSize:P}),{getRootProps:f,getInputProps:M,isDragActive:T,isDragReject:Z}=F,{cropModalOpen:X,imagePreview:q,cropLoading:Y,onCropInitialized:ie,handleCropSave:ae,handleCropCancel:ne}=S,C=Z||!!p,H=R||E,z=!!o,N=useRef(""),V=useRef();useEffect(()=>{if(!l){N.current="",V.current=void 0;return}let B=l.id??`${l.name}-${l.size}-${l.lastModified}`;if(V.current===B)return;V.current=B,b(!0);let K=URL.createObjectURL(l);return N.current=K,()=>{URL.revokeObjectURL(K);}},[l]);let ee=()=>{b(!1);},k=useCallback(()=>z&&l?()=>w(l):f().onClick,[z,l,f,w]);return jsxs(Fragment,{children:[jsxs(le,{sx:{alignItems:"center"},children:[jsxs(io,{sx:n,isError:C,isDragActive:T,hasFile:!!l,...f(),onClick:k(),children:[jsxs(ro,{children:[H&&jsx(to,{children:jsx(at,{size:135,thickness:2,color:"primary"})}),l&&jsx(ao,{alt:"Avatar Preview",src:N.current,onLoad:ee,...H&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),!l&&!H&&jsxs(Te,{isError:C,hasFile:!1,children:[jsx(a$6,{icon:"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"text.disabled"},children:"Adicionar foto"})]}),l&&!H&&jsxs(Te,{isError:C,hasFile:!0,children:[jsx(a$6,{icon:z?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"common.white"},children:z?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:g,id:m,tabIndex:s,...M()})]}),jsx(le,{sx:{alignItems:"center",mt:-.5},children:jsx(G,{helperText:d,disabled:i,isError:C})})]}),X&&q&&jsx(a$5,{open:X,onClose:ne,label:t??"Ajustar Imagem",imageSrc:q,aspectRatio:u,onInitialized:ie,onSave:ae,loading:Y,cropSize:P,cropShape:"round"})]})},st=memo(nt);var mt=({error:e,name:o,disabled:r,sx:i,...t})=>{let{getRootProps:m,getInputProps:s,isDragActive:p,isDragReject:d}=useDropzone({disabled:r,...t}),n=d||e;return jsxs(Qe,{...m(),isDragActive:p,hasError:!!n,disabled:!!r,sx:i,"data-testid":"upload-box",children:[jsx("input",{name:o,...s()}),"Selecionar arquivo"]})},ct=memo(mt);
|
|
36
36
|
|
|
37
37
|
export { ze as ContentType, ye as FileContentType, G as HelperText, Ie as MultiFilePreview, yr as MultipleFileUpload, Nr as MultipleImageUpload, Ce as SingleFilePreview, Hr as SingleFileUpload, Yr as SingleImageUpload, st as UploadAvatar, ct as UploadSimpleBox, xo as convertToWebP, hi as isImageFile, W as useDropzoneUploader, Ir as useFileUploadService };
|