import{r as e,_ as t,j as i,h as o,O as a}from"./react-B_SyE9nW.js";import{a as r,g as s,s as n,f as l,b as c,aC as d,aD as h,e as p,S as m,B as u,j as g,G as x,k as f,M as b,o as v,n as w,N as C,l as j,m as k,w as y}from"./index-Flm6m8Wj.js";import{I,h as M,M as S,a as R}from"./index-C6Ujt1Uk.js";import{B as $,F as z,P as L}from"./BackIco-CDsoigLi.js";import{B as O}from"./Stack-CZ7Wid7r.js";import{G as A}from"./Grid-DM22V-x0.js";import{_ as B}from"./history-CBi_mSPs.js";import{S as H}from"./SwitchBase-3Y_6lBhY.js";import{c as T}from"./index-BQVK4Wpw.js";import{E as N}from"./ErrorIco-CI_jFgDF.js";function E(e){return s("MuiSwitch",e)}const V=r("MuiSwitch",["root","edgeStart","edgeEnd","switchBase","colorPrimary","colorSecondary","sizeSmall","sizeMedium","checked","disabled","input","thumb","track"]),D=["className","color","edge","size","sx"],F=T(),P=n("span",{name:"MuiSwitch",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:i}=e;return[t.root,i.edge&&t[`edge${l(i.edge)}`],t[`size${l(i.size)}`]]}})({display:"inline-flex",width:58,height:38,overflow:"hidden",padding:12,boxSizing:"border-box",position:"relative",flexShrink:0,zIndex:0,verticalAlign:"middle","@media print":{colorAdjust:"exact"},variants:[{props:{edge:"start"},style:{marginLeft:-8}},{props:{edge:"end"},style:{marginRight:-8}},{props:{size:"small"},style:{width:40,height:24,padding:7,[`& .${V.thumb}`]:{width:16,height:16},[`& .${V.switchBase}`]:{padding:4,[`&.${V.checked}`]:{transform:"translateX(16px)"}}}}]}),Z=n(H,{name:"MuiSwitch",slot:"SwitchBase",overridesResolver:(e,t)=>{const{ownerState:i}=e;return[t.switchBase,{[`& .${V.input}`]:t.input},"default"!==i.color&&t[`color${l(i.color)}`]]}})((({theme:e})=>({position:"absolute",top:0,left:0,zIndex:1,color:e.vars?e.vars.palette.Switch.defaultColor:`${"light"===e.palette.mode?e.palette.common.white:e.palette.grey[300]}`,transition:e.transitions.create(["left","transform"],{duration:e.transitions.duration.shortest}),[`&.${V.checked}`]:{transform:"translateX(20px)"},[`&.${V.disabled}`]:{color:e.vars?e.vars.palette.Switch.defaultDisabledColor:`${"light"===e.palette.mode?e.palette.grey[100]:e.palette.grey[600]}`},[`&.${V.checked} + .${V.track}`]:{opacity:.5},[`&.${V.disabled} + .${V.track}`]:{opacity:e.vars?e.vars.opacity.switchTrackDisabled:""+("light"===e.palette.mode?.12:.2)},[`& .${V.input}`]:{left:"-100%",width:"300%"}})),(({theme:e})=>({"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.activeChannel} / ${e.vars.palette.action.hoverOpacity})`:c(e.palette.action.active,e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},variants:[...Object.entries(e.palette).filter((([,e])=>e.main&&e.light)).map((([t])=>({props:{color:t},style:{[`&.${V.checked}`]:{color:(e.vars||e).palette[t].main,"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette[t].mainChannel} / ${e.vars.palette.action.hoverOpacity})`:c(e.palette[t].main,e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${V.disabled}`]:{color:e.vars?e.vars.palette.Switch[`${t}DisabledColor`]:`${"light"===e.palette.mode?d(e.palette[t].main,.62):h(e.palette[t].main,.55)}`}},[`&.${V.checked} + .${V.track}`]:{backgroundColor:(e.vars||e).palette[t].main}}})))]}))),W=n("span",{name:"MuiSwitch",slot:"Track",overridesResolver:(e,t)=>t.track})((({theme:e})=>({height:"100%",width:"100%",borderRadius:7,zIndex:-1,transition:e.transitions.create(["opacity","background-color"],{duration:e.transitions.duration.shortest}),backgroundColor:e.vars?e.vars.palette.common.onBackground:`${"light"===e.palette.mode?e.palette.common.black:e.palette.common.white}`,opacity:e.vars?e.vars.opacity.switchTrack:""+("light"===e.palette.mode?.38:.3)}))),_=n("span",{name:"MuiSwitch",slot:"Thumb",overridesResolver:(e,t)=>t.thumb})((({theme:e})=>({boxShadow:(e.vars||e).shadows[1],backgroundColor:"currentColor",width:20,height:20,borderRadius:"50%"}))),G=e.forwardRef((function(e,a){const r=F({props:e,name:"MuiSwitch"}),{className:s,color:n="primary",edge:c=!1,size:d="medium",sx:h}=r,m=t(r,D),u=B({},r,{color:n,edge:c,size:d}),g=(e=>{const{classes:t,edge:i,size:o,color:a,checked:r,disabled:s}=e,n={root:["root",i&&`edge${l(i)}`,`size${l(o)}`],switchBase:["switchBase",`color${l(a)}`,r&&"checked",s&&"disabled"],thumb:["thumb"],track:["track"],input:["input"]},c=p(n,E,t);return B({},t,c)})(u),x=i.jsx(_,{className:g.thumb,ownerState:u});return i.jsxs(P,{className:o(g.root,s),sx:h,ownerState:u,children:[i.jsx(Z,B({type:"checkbox",icon:x,checkedIcon:x,ref:a,ownerState:u},m,{classes:B({},g,{root:g.switchBase})})),i.jsx(W,{className:g.track,ownerState:u})]})})),U={VERTICAL:"VERTICAL",HORIZONTAL:"HORIZONTAL",NORMAL:"NORMAL"};function X(e){return i.jsx(m,{...e,children:i.jsx("path",{d:"M20.8 20.3H3.2C2 20.3 1 19.3 1 18V5.9c0-1.2 1-2.2 2.2-2.2h17.6c1.2 0 2.2 1 2.2 2.2V18c0 1.3-1 2.3-2.2 2.3zM3.2 4.8c-.6 0-1.1.5-1.1 1.1V18c0 .6.5 1.1 1.1 1.1h17.6c.6 0 1.1-.5 1.1-1.1V5.9c0-.6-.5-1.1-1.1-1.1H3.2z"})})}function J(e){return i.jsx(m,{...e,children:i.jsx("path",{d:"M20.3 3.2v17.6c0 1.2-1 2.2-2.2 2.2H5.9c-1.2 0-2.2-1-2.2-2.2V3.2C3.8 2 4.7 1 5.9 1H18c1.3 0 2.3 1 2.3 2.2zM4.8 20.8c0 .6.5 1.1 1.1 1.1H18c.6 0 1.1-.5 1.1-1.1V3.2c0-.6-.5-1.1-1.1-1.1H5.9c-.6 0-1.1.5-1.1 1.1v17.6z"})})}function Q(e){return i.jsx(m,{...e,children:i.jsx("path",{d:"M14.59 8L12 10.59 9.41 8 8 9.41 10.59 12 8 14.59 9.41 16 12 13.41 14.59 16 16 14.59 13.41 12 16 9.41 14.59 8zM12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"})})}function Y({onClick:e,selected:t}){return i.jsx(u,{onClick:e,sx:{height:"4px",width:"4px",backgroundColor:g.red,opacity:t?1:.8,borderRadius:"50%",mx:1,mb:2,transition:"transform 0.3s",transform:t?"scale(2)":"scale(1)"}})}function q(e){return i.jsxs(m,{height:14,width:14,...e,children:[i.jsx("rect",{width:"16",height:"16",rx:"2",fill:"#D64300"}),i.jsx("mask",{id:"mask0_528_23597",maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"16",height:"16",children:i.jsx("rect",{width:"16",height:"16",fill:"#D9D9D9"})}),i.jsx("g",{mask:"url(#mask0_528_23597)",children:i.jsx("path",{d:"M3.33333 14C2.96667 14 2.65278 13.8694 2.39167 13.6083C2.13056 13.3472 2 13.0333 2 12.6667V3.33333C2 2.96667 2.13056 2.65278 2.39167 2.39167C2.65278 2.13056 2.96667 2 3.33333 2H12.6667C13.0333 2 13.3472 2.13056 13.6083 2.39167C13.8694 2.65278 14 2.96667 14 3.33333V12.6667C14 13.0333 13.8694 13.3472 13.6083 13.6083C13.3472 13.8694 13.0333 14 12.6667 14H3.33333ZM3.33333 12.6667H12.6667V3.33333H3.33333V12.6667ZM4 11.3333H12L9.5 8L7.5 10.6667L6 8.66667L4 11.3333ZM5.66667 6.66667C5.94444 6.66667 6.18056 6.56944 6.375 6.375C6.56944 6.18056 6.66667 5.94444 6.66667 5.66667C6.66667 5.38889 6.56944 5.15278 6.375 4.95833C6.18056 4.76389 5.94444 4.66667 5.66667 4.66667C5.38889 4.66667 5.15278 4.76389 4.95833 4.95833C4.76389 5.15278 4.66667 5.38889 4.66667 5.66667C4.66667 5.94444 4.76389 6.18056 4.95833 6.375C5.15278 6.56944 5.38889 6.66667 5.66667 6.66667Z",fill:"white"})})]})}const K={width:x.isMobile?"285px":"100%",display:"grid",gridAutoFlow:"column",gridAutoColumns:"auto",gap:"5px",maxWidth:"fit-content",overflow:"auto",scrollBehavior:"smooth",WebkitOverflowScrolling:"touch",padding:"0 5px","&::-webkit-scrollbar":{display:"none"}},ee={width:"100%",overflow:"hidden",display:"flex",justifyContent:"center",mb:2},te=b`
  animation: ${f`
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
  }
`} 2s infinite;
`,ie=n("div")`
  position: relative;
  height: 95px;
  width: 95px;
  padding: 1px;
  border-radius: 10px;
  flex: 1;
  border: 2px solid ${({isSelected:e,mainImage:t})=>e&&t?g.red:e?"#B7B7B7":"white"};
  background-color: ${({isSelected:e,mainImage:t})=>e&&t?"#FFECC6":e?`${g.gray33}`:"white"};
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  & {
    & {
      img {
        object-fit: cover;
        height: 75px;
        width: 75px;
        border-radius: 6px;
        box-shadow: rgba(0, 0, 0, 0.2) 0 2px 1px -1px, rgba(0, 0, 0, 0.14) 0 1px 1px 0, rgba(0, 0, 0, 0.12) 0 1px 3px 0;
        ${({error:e})=>e?`box-shadow:0px 0px 4px 2px ${g.red};opacity:0.7;border:1px solid ${g.red}`:""};
      }

    .MuiButtonBase-root {
      position: absolute;
      right: -3px;
      top: -3px;
      z-index: 1;

      .MuiSvgIcon-root {
        color: ${g.white};
        background-color: ${({error:e})=>g[e?"red":"gray50"]};
        border-radius: 50%;
        transform: scale(1);
        ${({error:e})=>e?te:""};

      }
  }

  .second-icon-button {
    position: absolute;
    bottom: -50px;
    right: 50px;
    z-index: 1;
    padding: 10px;
 }

`,oe={display:"flex",alignItems:"center",justifyContent:"center",width:"40px"},ae=n("div")`
  display: flex;
  align-items: center;
  flex-direction: column;
`,re=n(I)`
  border: 1px solid;
`,se=n(O)((()=>({width:"auto",my:"5px"})));const ne=v((function({onClickAccept:t,onDelete:o,images:a,imageToEdit:r,onChange:s,limit:n=1,forProfile:l,forOneImage:c}){var d;const[h,p]=e.useState(!1),[m,f]=e.useState(!1),[b,v]=e.useState(1),C=e.useRef(null),[j,k]=e.useState(1);e.useEffect((()=>{if(C.current){const e=C.current;return e.addEventListener("scroll",y),()=>{e.removeEventListener("scroll",y)}}}),[j]);const y=()=>{if(C.current){const e=C.current;p(e.scrollLeft>0),f(e.scrollLeft+e.offsetWidth<e.scrollWidth),setTimeout((()=>{if(e.scrollLeft+e.offsetWidth>=e.scrollWidth)v(j);else{const t=Math.ceil(e.scrollLeft/285);v(t||1)}}),500)}},M=e=>{C.current&&C.current.scrollBy(e,0)};return e.useEffect((()=>{y()}),[null==(d=C.current)?void 0:d.clientWidth]),e.useEffect((()=>{k(Math.ceil(a.length/3))}),[a.length]),i.jsxs(i.Fragment,{children:[l?i.jsx(u,{sx:ee,children:i.jsx(A,{container:!0,justifyContent:"center",alignItems:"center",sx:{width:"163px",height:"163px","& .img-preview":{width:"163px",height:"163px"}},children:i.jsx("div",{className:"img-preview",style:{borderRadius:"50%",border:`1px solid ${g.whiteBorder}`,overflow:"hidden"}})})}):i.jsxs(ae,{children:[i.jsxs(u,{sx:ee,children:[!x.isMobile&&i.jsx(u,{sx:oe,children:h&&i.jsx(re,{onClick:()=>M(-380),size:"small",children:i.jsx($,{fontSize:"inherit"})})}),i.jsx(u,{sx:K,ref:C,children:a.map(((e,t)=>{var a,l;return i.jsxs(ie,{isSelected:(l=null==e?void 0:e.id,l===r),error:t>=n,mainImage:e.mainImage&&!c,children:[i.jsx("img",{onClick:()=>null==s?void 0:s(e.id),src:e.croppedImage??(null==(a=e.image)?void 0:a.toString()),alt:"image item"}),i.jsx(I,{onClick:()=>null==o?void 0:o(null==e?void 0:e.id),children:i.jsx(Q,{})}),e.mainImage&&!c?i.jsx(u,{sx:{position:"absolute",left:"12px",bottom:"12px",zIndex:1,height:"16px",width:"16px",backgroundColor:g.red,borderRadius:"4px"},children:i.jsx(q,{})}):i.jsx(i.Fragment,{})]},`image-${t}`)}))}),!x.isMobile&&i.jsx(u,{sx:oe,children:m&&i.jsx(re,{onClick:()=>M(380),size:"small",children:i.jsx(z,{fontSize:"inherit"})})})]}),x.isMobile&&j>1&&i.jsx(L,{count:j,onChange:(e,t)=>{var i;i=286*(t-1),C.current&&C.current.scrollTo(i,0),v(t)},hideNextButton:!0,hidePrevButton:!0,page:b,renderItem:({selected:e,onClick:t})=>i.jsx(Y,{onClick:t,selected:e})})]}),i.jsx(se,{onClick:t,children:w("accept")})]})})),le=n((({label:e,value:t,onChangeMainImage:o,disabled:a,...r})=>i.jsxs("div",{style:{position:"relative",height:"25px",cursor:"pointer"},...a?{}:{onClick:o},children:[i.jsx(G,{checked:t,focusVisibleClassName:".Mui-focusVisible",disableRipple:!0,disabled:a,...r,sx:{width:"100%"}}),i.jsx(M,{sx:{position:"absolute",color:"white",top:"20%",left:t?"7%":"22%",zIndex:0,fontSize:"10px"},variant:"body1",className:"MuiSwitch-label",children:e})]})))((({theme:e,value:t,disabled:i})=>({width:105,height:22,padding:0,position:"relative","& .MuiSwitch-switchBase":{width:t?"145px":"none",padding:0,margin:2,transitionDuration:"300ms"},"& .MuiSwitch-thumb":{top:"1%",boxSizing:"border-box",backgroundColor:"white",width:18,height:18},"& .MuiSwitch-track":{borderRadius:25,backgroundColor:"#BFBFBF",opacity:i?"0.4!important":"1!important",transition:e.transitions.create([g.red],{duration:500})},"& .MuiTypography-root.MuiSwitch-label":{position:"absolute",width:"100%",top:"50%",left:"150%",transform:"translate(-50%, -50%)",color:g.red,zIndex:1}})));const ce=v((function({label:e,value:t,onChangeMainImage:o,disabled:a}){return i.jsx(le,{label:e,value:t??!1,disabled:a,onChangeMainImage:o})})),de=n("div")`
  height: 100%;
  & {
    .cropper-modal {
      background-color: #bababa;
      opacity: 0.8;
    }
  }
`,he={NORMAL:1,VERTICAL:3/4,HORIZONTAL:4/3};const pe=v((function({onCropImage:t,src:o,images:r,changeAspectRatioAction:s=!0,onClickAccept:n,onChange:l,onClose:c,imageToEdit:d,forProfile:h,forOneImage:p,uploaded:m,limit:f,actionJustification:b="space-between",...v}){const[k,y]=e.useState(),[M,S]=e.useState((null==o?void 0:o.aspect)??"NORMAL"),R=e.useRef(null);e.useEffect((()=>()=>{$()}),[k,o]);const $=()=>{if(k&&o){const e=null==k?void 0:k.getCroppedCanvas({maxWidth:1024,maxHeight:1024,fillColor:g.whiteBorder,imageSmoothingQuality:"high",imageSmoothingEnabled:!0}),{height:i,width:a}=e,r=e.toDataURL("image/jpeg"),s=Object.keys(he).find((e=>((e,t,i=1e-4)=>Math.abs(e-t)<i)(he[e],a/i,.1))),n=k.getData(!0);null==t||t({...o,croppedImage:r,croppedData:n,aspect:s??"HORIZONTAL"},!0)}},z=e=>{const t=e?U.VERTICAL:U.HORIZONTAL,i=he[t];S(t),null==k||k.setAspectRatio(i)};e.useLayoutEffect((()=>{setTimeout((()=>{if(o)if("NORMAL"===o.aspect&&R.current){const{width:e,height:t}=R.current;h||z(t>e)}else{S(o.aspect);const e=he[h?U.NORMAL:(null==o?void 0:o.aspect)??"HORIZONTAL"];null==k||k.setAspectRatio(e),o.croppedData&&(null==k||k.setData(o.croppedData))}}),100)}),[o,k,R.current]);const{width:L,height:O,preview:A}=e.useMemo((()=>{const e=x.isMobile?285:430;return{width:e,height:e*(3/4),preview:.38*e+"px"}}),[x.device]);return i.jsxs(de,{children:[i.jsxs(u,{sx:{width:"100%",position:"relative",py:1},children:[i.jsx(C,{color:"gray",size:"medium",children:w("preview")}),i.jsx(a,{ref:R,style:{height:O,width:L,margin:"12px auto auto auto"},zoomTo:0,initialAspectRatio:he[h?U.NORMAL:(null==o?void 0:o.aspect)??"HORIZONTAL"],aspectRatio:he[h?U.NORMAL:M],src:null==o?void 0:o.image,viewMode:1,guides:!0,center:!0,minCropBoxHeight:10,minCropBoxWidth:10,movable:!0,autoCrop:!0,responsive:!0,autoCropArea:1,checkOrientation:!1,modal:!0,onInitialized:y,background:!1,preview:".img-preview"})]}),i.jsx("div",{dir:"column",style:{display:"flex",flexDirection:"column",alignItems:"center"},children:i.jsxs(u,{sx:{display:"flex",width:x.isDesktop?"80%":"100%",justifyContent:b,p:2,pt:0,alignItems:"center"},children:[!p&&i.jsx(ce,{label:w("mainPicture"),value:!m&&(null==o?void 0:o.mainImage),onChangeMainImage:()=>{const e=r.find((e=>e.id===(null==o?void 0:o.id)));e&&(e.mainImage=!e.mainImage,r.forEach((e=>{e.id!==(null==o?void 0:o.id)&&(e.mainImage=!1)})))},disabled:Boolean(m)||1===f||1===r.length}),i.jsx(u,{children:s&&i.jsxs(I,{onClick:()=>z(M===U.HORIZONTAL),children:[i.jsx(J,{sx:{color:M===U.VERTICAL?void 0:g.grayLighter}}),i.jsx(X,{sx:{color:M===U.HORIZONTAL?void 0:g.grayLighter}})]})})]})}),i.jsx(ne,{...{onClickAccept:()=>{var e;r.sort(((e,t)=>e.mainImage===t.mainImage?0:e.mainImage?-1:1)),$(),null==n||n(),c(),null==(e=j)||e()},onChange:l,imageToEdit:d??(null==o?void 0:o.id),preview:A,forProfile:h,forOneImage:p,images:m?r.map((e=>({...e,mainImage:!1}))):r,limit:f,...v}})]})})),me=n(N)`
  &.MuiSvgIcon-root {
    width: 170px;
    height: auto;
    margin-bottom: 15px;
  }
`;const ue=v((function({limit:e,onClose:t}){return i.jsxs(S,{open:k.isImageLimitError,onClose:()=>{y(k.getPrevious.pop()),t()},children:[i.jsx(me,{}),i.jsx(R,{size:"micro",color:"lightGray",margin:"20px 0 10px",text:w("errImageLimit",{limit:e})})]})})),ge={display:"flex",justifyContent:"center",".MuiDialog-container":{width:"620px",".MuiPaper-root":{maxWidth:"620px",width:"100%",m:"32px 0",".MuiDialogContent-root":{overflowY:"hidden"}},"@media(max-width:791px)":{width:"90%",m:"auto",".MuiPaper-root":{width:"100%",maxWidth:"unset"}}}};const xe=v((function({onClose:t,images:o,imageToEdit:a,src:r,limit:s,uploaded:n,open:l,...c}){const d=e.useMemo((()=>o.find((({id:e})=>e===a))),[o,a]);return e.useEffect((()=>{var e;(0===o.length&&k.isCropPicture||0===o.length&&l)&&(t(),null==(e=j)||e())}),[o]),i.jsxs(i.Fragment,{children:[i.jsx(ue,{limit:s-(n??0),onClose:t}),Boolean(o.length)&&i.jsx(S,{open:l||k.isCropPicture,onClose:()=>t(),sx:ge,children:i.jsx(pe,{...{onClose:t,images:o,imageToEdit:a,src:r??d,limit:s-(n??0),uploaded:n,...c}})})]})}));const fe=v((function({children:e,onChange:t,id:o="enj-btn-img-upload",disabled:a,multiple:r=!1}){return i.jsxs("label",{htmlFor:o,children:[a?i.jsx(i.Fragment,{}):i.jsx(u,{component:"input",accept:"image/jpeg, image/png",type:"file",onChange:t,id:o,multiple:r,sx:{display:"none"},onClick:e=>e.stopPropagation()}),e]})}));function be(e){return i.jsx(m,{...e,children:i.jsx("path",{d:"M3 4.8V2.1h1.8v2.7h2.7v1.8H4.8v2.7H3V6.6H.3V4.8H3zm2.7 5.4V7.5h2.7V4.8h6.3l1.6 1.8h2.8c1 0 1.8.8 1.8 1.8v10.8c0 1-.8 1.8-1.8 1.8H4.8c-1 0-1.8-.8-1.8-1.8v-9h2.7zm6.3 8.1c2.5 0 4.5-2 4.5-4.5s-2-4.5-4.5-4.5-4.5 2-4.5 4.5 2 4.5 4.5 4.5zm-2.9-4.5a2.9 2.9 0 105.8 0 2.9 2.9 0 00-5.8 0z"})})}export{xe as C,fe as F,ue as I,be as P,G as S,U as a,pe as b,Q as c};