import{r as A,j as a,v as C}from"./vendor-ClLR6ncd.js";import{A as j,c as E}from"./Autocomplete-Cjt7Q9VV.js";import{C as F}from"./Chip-DoCs8Smb.js";const L=E();function y({label:c,setter:o,values:n,disabled:m,required:d=!0,fullWidth:p=!1,predefinedOptions:r=[],error:f,helperText:x}){const i=!n,[v,V]=A.useState([]),u=i?v:n,h=e=>{const t=e.map(l=>l.inputValue!==void 0?l.inputValue:l);i&&V(t),o(t)};return a.jsx(j,{disabled:m,fullWidth:p,freeSolo:!0,selectOnFocus:!0,autoSelect:!0,clearIcon:null,multiple:!0,size:"small",options:Array.from(new Set(u.concat(r))),value:u,onChange:(e,t)=>{h(t)},filterOptions:(e,t)=>{const l=L(e,t),{inputValue:s}=t,S=e.some(g=>s===g);return s!==""&&!S&&l.push({inputValue:s,title:`Click to add "${s}"`}),l},getOptionLabel:e=>e.inputValue?e.inputValue:e,renderOption:(e,t)=>a.jsx("li",{...e,children:r.includes(t)&&!u.includes(t)?t:t.title!==void 0?t.title:`Click to remove "${t}"`}),renderTags:(e,t)=>e.map((l,s)=>a.jsx(F,{variant:"outlined",label:l.inputValue!==void 0?l.inputValue:l,size:"small",...t({index:s})},s)),renderInput:e=>a.jsx(C,{...e,label:c,variant:"standard",required:d,sx:{...e.sx,mb:"12px"},error:f,helperText:x})})}export{y as A};
