import e from"@babel/runtime/helpers/slicedToArray";import{useState as t,useRef as o}from"react";import r from"prop-types";import{withRouter as i}from"react-router";import n from"lodash/get";import{withStyles as a,Tooltip as l,makeStyles as c,Chip as p,Input as s}from"@material-ui/core";import u from"@material-ui/icons/Close";import d from"./AssetTypesSection.js";import m from"./AssetResultSection.js";import{useAssetsData as f}from"./effects/useAssetsData.js";import{SEARCH_CATEGORIES as h,CATEGORY_KEY_VALUES as x}from"./constants.js";import{jsxs as g,jsx as y}from"react/jsx-runtime";var C=a((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),b=c((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"}}})),v=function(r){var i=r.onClickAsset,a=r.company,l=t(null),c=e(l,2),v=c[0],I=c[1],w=t(null),A=e(w,2),D=A[0],S=A[1],j=t(1),k=e(j,2),R=k[0],N=k[1],T=b(),W=o(),z=f(D,v,R,a),B=e(z,2),q=B[0],K=B[1];return g("div",{className:T.wrapper,children:[y("div",{className:T.inputWrapper,children:g("div",{className:T.searchInput,children:[v&&y(p,{"data-not-migrated-muichip":!0,classes:{root:T.selectedChip,deleteIcon:T.selectedChipDeleteIcon},label:n(h,[v,"labelPlural"],"Assets"),deleteIcon:y(u,{}),onDelete:function(){I(null),N(1)}}),y(s,{"data-testid":"".concat("AutoCompleteAssetSearch","_searchInput"),inputRef:W,autoFocus:!0,disableUnderline:!0,fullWidth:!0,value:D||"",placeholder:"Search ".concat(n(h,[v,"labelPlural"],"assets"),"..."),onChange:function(e){var t=e.target.value;S(t),N(1)},onKeyUp:function(t){var o=t.target.value,r=t.keyCode,i=x.find((function(t){var r=e(t,2);return r[0],r[1].autoCategorizedKey===o.trim().toLowerCase()}));if(i&&(13===r||32===r))return S(""),I(i[0]),void N(1);""===o&&8===r&&(I(null),N(1))}}),y(C,{title:"Clear",children:y(u,{className:v||D?T.selectedChipDeleteIcon:T.disabledIcon,onClick:function(){W.current.focus(),S(""),I(null),N(1)}})})]})}),!v&&!D&&y(d,{onClickAssetType:function(e){W.current.focus(),I(e),N(1)}}),(v||D)&&y(m,{loading:q,page:R,groupedAssets:K,onClickAsset:i,onScrollReached:function(e){"top"===e&&R>1&&N((function(e){return e-1})),"bottom"===e&&N((function(e){return e+1}))}})]})};v.propTypes={company:r.number.isRequired,onClickAsset:r.func.isRequired};var I=i(v);export{I as default};
