import{i as e}from"./chunk-aKtaBQYM.js";import{Vt as t,t as n,wt as r}from"./mui-B6lh3XSP.js";import{n as i,t as a}from"./Autocomplete-BugREI_2.js";import{t as o}from"./TextField-DOdnjCrL.js";import{pt as s,w as c}from"./index-KVuxnkWj.js";var l=e(t(),1),u=r(),d=n()(()=>({autocompleteMultiple:{"& .MuiAutocomplete-inputRoot":{flexWrap:`nowrap`,overflow:`hidden`},"& .MuiAutocomplete-input":{minWidth:`1px !important`},"& .MuiAutocomplete-tag .MuiChip-label":{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}}})),f=({label:e,fullWidth:t,multiple:n,value:r=null,emptyValue:f=null,emptyTitle:p=``,onChange:m,endpoint:h,data:g,keyGetter:_=e=>e.id,titleGetter:v=e=>e.name,helperText:y,placeholder:b,singleLine:x,allValue:S})=>{let{classes:C}=d(),[w,T]=(0,l.useState)(),E=e=>typeof e==`object`?e:w.find(t=>_(t)===e),D=e=>(e=E(e),e?v(e):p);if((0,l.useEffect)(()=>T(g),[g]),s(async({signal:e})=>{h&&T(await(await c(h,{signal:e})).json())},[h]),w){let s=n?(r||[]).map(e=>E(e)).filter(e=>e!=null):E(r)||null;return(0,u.jsx)(a,{size:x?`small`:`medium`,multiple:n,className:n&&x?C.autocompleteMultiple:void 0,options:w,getOptionLabel:D,renderOption:({key:e,...t},n)=>(0,u.jsx)(`li`,{...t,children:v(n)},_(n)||e),isOptionEqualToValue:(e,t)=>_(e)===_(t),value:s,onChange:(e,t)=>{if(n){let e=t.map(e=>_(e));if(S&&e.length>1){let t=(r||[]).includes(S);e.includes(S)&&(e=t?e.filter(e=>e!==S):[S])}m({target:{value:e}})}else m({target:{value:t?_(t):f}})},renderValue:n&&x?(e,t)=>e.length?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(i,{...t({index:0}),label:v(e[0]),size:`small`,sx:{minWidth:0}},_(e[0])),e.length>1&&(0,u.jsx)(i,{label:`${e.length-1}`,size:`small`,sx:{flexShrink:0}})]}):null:void 0,fullWidth:t,disableCloseOnSelect:n,renderInput:t=>(0,u.jsx)(o,{...t,label:e,helperText:y,placeholder:n&&!s.length?b:void 0,slotProps:{...t.slotProps,inputLabel:{...t.slotProps?.inputLabel,shrink:n&&!s.length&&!!b||t.slotProps?.inputLabel?.shrink}}})})}return null};export{f as t};