import e from"@babel/runtime/helpers/slicedToArray";import t from"prop-types";import{useState as o,useCallback as s}from"react";import{debounce as r}from"lodash";import{makeStyles as n,Chip as a}from"@material-ui/core";import{Search as i}from"../../Search/Search.js";import"../../Search/components/Listbox.js";import"../../Search/components/Paper.js";import"../../Search/components/RecentSearches.js";import p from"../../Search/components/InputAdornmentLeft.js";import l from"../../Search/components/Groups.js";import"../../Search/components/SelectAllListItem.js";import{usePrimaryAssetSelectData as u}from"../effects/index.js";import{ACTIVE_STATUS as c}from"../constants.js";import{getSearchPlaceholder as d}from"../utils/index.js";import m from"./SelectItem.js";import{jsx as h}from"react/jsx-runtime";var f=n({paper:{boxShadow:"0px 3px 10px 0px #00000066"},listbox:{maxHeight:210,"& .MuiAutocomplete-option":{padding:"0px 0px 0px 16px"}},option:{padding:"6px 0","&:hover":{backgroundColor:"initial"}},groupChip:{height:32,padding:0},activeChip:{fontWeight:500,backgroundColor:"#75DB29",color:"#212121",fontSize:10,cursor:"pointer",height:12,textTransform:"uppercase",marginRight:12,letterSpacing:1}}),g=function(t){var n=t["data-testid"],g=t.appKey,A=t.assetFields,b=t.assetType,C=t.company,x=t.currentOption,S=t.currentValue,I=t.defaultValue,v=t.disableClearable,y=t.disabled,j=t.groups,R=t.isNullable,G=t.isRequiredAssetId,P=t.isSecondaryAssetPresent,O=t.label,T=t.multiple,F=t.onActiveAssetIdChange,N=t.onChange,L=t.onGroupChange,V=t.onGroupReset,k=t.onInputReset,q=t.placeholder,H=t.selectedGroup,K=t.setCurrentOption,M=o(""),_=e(M,2),w=_[0],z=_[1],B=d(b,P),D=f(),E=u({appKey:g,assetType:b,company:C,groups:j,isRequiredAssetId:G,assetFields:A,selectedGroup:H,currentValue:S,setCurrentOption:K,onActiveAssetIdChange:F}),W=E.assets,J=E.loading,Q=s(r((function(e){z(e)}),200),[]);return h(i,{classes:{paper:D.paper,listbox:D.listbox,groupChip:D.groupChip},defaultValue:I,disableClearable:v,disabled:y,isNullable:R,loading:J,onGroupChange:L,onGroupReset:V,placeholder:q||B,selectedGroup:H,onChange:function(e,t){N(t)},"data-testid":n,multiple:T,onInputChange:Q,onInputReset:function(){k(),K(null)},TextFieldProps:{label:O,value:w,endAdornment:(null==x?void 0:x.status)===c&&h(a,{"data-not-migrated-muichip":!0,className:D.activeChip,label:"Active"})},isHiddenAllOption:!0,value:x,options:W,renderCustomOption:function(e,t){var o=e.status,s=e.name,r=e.id,a=t.selected;return h(m,{className:D.option,assetName:s,multiple:T,selected:a,value:r,status:o&&c,"data-testid":"".concat(n,"_option_").concat(s,"MenuItem")},r)},getOptionLabel:function(e){return e.name||""},GroupsComponent:l,groups:j,InputProps:{startAdornment:h(p,{})}})};g.propTypes={assetFields:t.array,isSecondaryAssetPresent:t.bool,"data-testid":t.string,onInputReset:t.func,onActiveAssetIdChange:t.func,placeholder:t.string},g.defaultProps={assetFields:[],isSecondaryAssetPresent:!0,"data-testid":"PrimaryAssetEditorAutocomplete",onInputReset:function(){},onActiveAssetIdChange:function(){},placeholder:null};export{g as default};
//# sourceMappingURL=PrimaryAssetSelect.js.map
