import e from"@babel/runtime/helpers/toConsumableArray";import{useEffect as r}from"react";import{isEmpty as t,take as n}from"lodash";import a from"classnames";import{makeStyles as i,Typography as o}from"@material-ui/core";import{jsxs as c,jsx as l}from"react/jsx-runtime";var p=i((function(e){var r=e.palette;return{recentSearchesWrapper:{paddingBottom:"8px"},option:{display:"flex",alignItems:"center",padding:"0 16px","&:hover":{cursor:"pointer",backgroundColor:"rgba(255, 255, 255, 0.16)"}},label:{lineHeight:"36px",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},caption:{color:r.primary.text6,fontSize:"12px",padding:"16px 0 8px 16px"},recentSearchesIcon:{width:"16px",height:"16px",color:r.primary.text6,marginRight:"16px"}}})),s=function(e,r,t){e.setItem(r,JSON.stringify(t))},m=function(i){var m=i.className,u=i.title,d=i.Icon,f=i.onInputChange,h=i.inputValue,x=i.isHidden,g=i.maxCount,v=i.dataStorageKey,S=i.dataStorage,b=i.clearable,N=function(e,r){return JSON.parse(e.getItem(r))||[]}(S,v),I=p();if(r((function(){null!=h&&h.trim()&&!N.includes(h)&&s(S,v,n([h].concat(e(N)),g))}),[h]),t(N)||x)return null;var y=null==N?void 0:N.map((function(e){return c("div",{className:I.option,"data-testid":"".concat("RecentSearches","_").concat(e),onClick:function(){!function(e){s(S,v,b?N:N.filter((function(r){return r!==e}))),f(e)}(e)},children:[d&&l(d,{className:I.recentSearchesIcon}),l("div",{className:I.label,children:e})]},e)}));return c("div",{className:a(I.recentSearchesWrapper,m),children:[u&&l(o,{className:I.caption,children:u}),y]})};export{m as default};
