"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),r=require("prop-types"),a=require("lodash/get"),l=require("@material-ui/core"),i=require("@material-ui/icons/Close"),n=require("./AssetTypesSection.js"),o=require("./AssetResultSection.js"),s=require("./effects/useAssetsData.js"),u=require("./constants.js"),c=require("react/jsx-runtime");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=p(e),f=p(r),x=p(a),h=p(i),m=l.withStyles((function(){return{tooltip:{backgroundColor:"#414141",color:"#ffffff",fontSize:"11px",lineHeight:"16px",borderRadius:"4px",boxShadow:"0px 4px 4px rgba(0, 0, 0, 0.12)",padding:"4px"}}}))(l.Tooltip),C=l.makeStyles((function(e){return{wrapper:{width:"472px",display:"flex",flexDirection:"column",padding:16},inputWrapper:{display:"flex",width:"auto",margin:"0 8px 8px",alignItems:"center",flexWrap:"nowrap",justifyContent:"space-between"},selectedChip:{height:"24px",margin:"4px"},selectedChipDeleteIcon:{width:"16px",height:"16px",color:e.palette.primary.text6,"&:hover":{color:e.palette.primary.text1}},disabledIcon:{width:"16px",height:"16px",color:e.palette.primary.text6,opacity:.4},closeIconButton:{padding:0,"&:hover $closeIcon":{color:e.palette.primary.text1}},searchInput:{width:"100%",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",borderBottom:"2px solid #03BCD4"},closeIcon:{color:e.palette.primary.text6,fontSize:"18px"}}})),y=function(e){var r=e.onClickAsset,a=e.company,i=t.useState(null),p=d.default(i,2),f=p[0],y=p[1],g=t.useState(null),A=d.default(g,2),b=A[0],j=A[1],I=t.useState(1),S=d.default(I,2),v=S[0],w=S[1],q=C(),R=t.useRef(),D=s.useAssetsData(b,f,v,a),E=d.default(D,2),k=E[0],T=E[1];return c.jsxs("div",{className:q.wrapper,children:[c.jsx("div",{className:q.inputWrapper,children:c.jsxs("div",{className:q.searchInput,children:[f&&c.jsx(l.Chip,{"data-not-migrated-muichip":!0,classes:{root:q.selectedChip,deleteIcon:q.selectedChipDeleteIcon},label:x.default(u.SEARCH_CATEGORIES,[f,"labelPlural"],"Assets"),deleteIcon:c.jsx(h.default,{}),onDelete:function(){y(null),w(1)}}),c.jsx(l.Input,{"data-testid":"".concat("AutoCompleteAssetSearch","_searchInput"),inputRef:R,autoFocus:!0,disableUnderline:!0,fullWidth:!0,value:b||"",placeholder:"Search ".concat(x.default(u.SEARCH_CATEGORIES,[f,"labelPlural"],"assets"),"..."),onChange:function(e){var t=e.target.value;j(t),w(1)},onKeyUp:function(e){var t=e.target.value,r=e.keyCode,a=u.CATEGORY_KEY_VALUES.find((function(e){var r=d.default(e,2);return r[0],r[1].autoCategorizedKey===t.trim().toLowerCase()}));if(a&&(13===r||32===r))return j(""),y(a[0]),void w(1);""===t&&8===r&&(y(null),w(1))}}),c.jsx(m,{title:"Clear",children:c.jsx(h.default,{className:f||b?q.selectedChipDeleteIcon:q.disabledIcon,onClick:function(){R.current.focus(),j(""),y(null),w(1)}})})]})}),!f&&!b&&c.jsx(n,{onClickAssetType:function(e){R.current.focus(),y(e),w(1)}}),(f||b)&&c.jsx(o,{loading:k,page:v,groupedAssets:T,onClickAsset:r,onScrollReached:function(e){"top"===e&&v>1&&w((function(e){return e-1})),"bottom"===e&&w((function(e){return e+1}))}})]})};y.propTypes={company:f.default.number.isRequired,onClickAsset:f.default.func.isRequired},module.exports=y;
//# sourceMappingURL=AutoCompleteAssetSearch.js.map
