import{D as v,r as o,b2 as h,a as s,W as x,j as r,X as y,Y as b,Z as d,aM as I,bj as P,al as S}from"./index-BMKwTcAk.js";const c=a=>a?JSON.parse(a).VendorName||"(vendor?)":"",C=v(a=>S({root:{padding:"2px 4px",display:"flex",alignItems:"center",width:400},input:{marginLeft:a.spacing(1),flex:1},iconButton:{padding:10},divider:{height:28,margin:4},formControl:{margin:a.spacing(1),minWidth:300},modal:{backgroundColor:"#fff"}})),j=({value:a,onChange:l,componentTypeId:p=null,error:t=""})=>{const u=C(),[n,m]=o.useState(null);return o.useEffect(()=>{(async()=>{const e=await h.getParts({componentTypeId:p});e.ok&&m(e.data)})()},[]),s(x,{className:u.formControl,variant:"outlined",children:[r(y,{children:"Part"}),s(b,{label:"Part",error:!!t,value:a??null,onChange:l,renderValue:e=>{if(e.length===0)return r("div",{});const i=n?.find(g=>g.partId===e),f=`${i?.partName} - ${c(i?.vendor||"{}")}`;return r("div",{style:{display:"flex",flexWrap:"wrap"},children:r(I,{label:f})})},children:[r(d,{disabled:!0,value:"",children:r("div",{})}),n&&n.filter(e=>e.isActive).map(e=>s(d,{value:e.partId,children:[e.partName," - ",c(e.vendor)]},`part-${e.partId}`))]}),r(P,{error:!!t,children:t})]})};export{j as P};
//# sourceMappingURL=part.form-field-wT-Urm33.js.map
