import{j as e,P as S,Q as I,S as O,R as c,K as x,bm as T,T as i,br as z,eQ as W,fh as B,bk as C,o as s}from"./index-Y-QvttbJ.js";function M({fullWidth:m=!1,multiple:a=!1,required:o=!1,label:p="",placeholder:j="",options:t=[],helperText:b="",error:v=!1,margin:u="",size:f,slotProps:y={},...h}){const g=t.find(l=>l.value===h.value)?.title;return e.jsxs(S,{margin:u,fullWidth:m,error:v,children:[e.jsx(I,{size:f,children:`${p}${o?"*":""}`}),e.jsxs(O,{multiple:a,sx:{"& .MuiInputBase-input":{width:"calc(100% - 46px)","& > .MuiBox-root:first-of-type":{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},input:e.jsx(B,{defaultValue:g,sx:{flex:1},required:o,label:p,inputProps:{margin:u},size:f}),renderValue:l=>{if(a)return e.jsx(x,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:l.map(n=>{const d=t.find(w=>w.value===n);return d&&d.title&&e.jsx(W,{size:"small",label:d.title},n)})});const r=t.find(n=>n.value===l);return r&&r.title&&e.jsxs(x,{children:[e.jsx(i,{component:"span",children:r.title}),e.jsx(i,{component:"span",variant:"body2",sx:{marginLeft:1,color:"text.secondary"},children:r.description})]})},IconComponent:l=>e.jsx(z,{...l,width:20,height:20}),...h,children:[e.jsx(c,{disabled:!0,children:e.jsx("em",{children:j})}),!o&&!a&&e.jsx(c,{value:"",children:"None"}),t.map(l=>l&&l.value&&e.jsx(c,{value:l.value,disabled:l.disabled||!1,children:e.jsxs(x,{sx:T({display:"flex",flexDirection:"column"},y?.optionItem?.sx),children:[e.jsx(i,{component:"span",children:l.title}),l.description&&e.jsx(i,{component:"span",variant:"body2",sx:{maxWidth:510,fontSize:12,whiteSpace:"normal",color:"text.secondary"},children:l.description})]})},l.value))]}),e.jsx(C,{children:b})]})}M.propTypes={error:s.bool,required:s.bool,multiple:s.bool,fullWidth:s.bool,label:s.string,placeholder:s.string,options:s.array,helperText:s.string,margin:s.string,size:s.string,textDirection:s.oneOf(["row","column"]),slotProps:s.object};export{M as S};
