import{__assign as e,__spreadArray as t}from'./../../../ext-esm/tslib/tslib.es6.js';import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useEffect as a}from"react";import{isEmpty as i,take as o}from"lodash";import c from"classnames";import{makeStyles as l,Typography as p}from"@material-ui/core";var s=l((function(e){var t=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:t.primary.text6,fontSize:"12px",padding:"16px 0 8px 16px"},recentSearchesIcon:{width:"16px",height:"16px",color:t.primary.text6,marginRight:"16px"}}})),m=function(e,t,r){e.setItem(t,JSON.stringify(r))},d=function(l){var d=l.className,u=l.title,f=l.Icon,h=l.onInputChange,x=l.inputValue,g=l.isHidden,v=l.maxCount,S=l.dataStorageKey,N=l.dataStorage,b=l.clearable,I=function(e,t){return JSON.parse(e.getItem(t))||[]}(N,S),w=s();if(a((function(){(null==x?void 0:x.trim())&&!I.includes(x)&&m(N,S,o(t([x],I,!0),v))}),[x]),i(I)||g)return null;var y=null==I?void 0:I.map((function(t){return r("div",e({className:w.option,"data-testid":"".concat("RecentSearches","_").concat(t),onClick:function(){!function(e){m(N,S,b?I:I.filter((function(t){return t!==e}))),h(e)}(t)}},{children:[f&&n(f,{className:w.recentSearchesIcon}),n("div",e({className:w.label},{children:t}))]}),t)}));return r("div",e({className:c(w.recentSearchesWrapper,d)},{children:[u&&n(p,e({className:w.caption},{children:u})),y]}))};export{d as default};
