"use strict";var e=require('./../../../ext-esm/tslib/tslib.es6.js'),r=require("react/jsx-runtime"),t=require("react"),a=require("lodash"),n=require("classnames"),i=require("@material-ui/core");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(n),o=i.makeStyles((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"}}})),l=function(e,r,t){e.setItem(r,JSON.stringify(t))};module.exports=function(n){var s=n.className,u=n.title,p=n.Icon,d=n.onInputChange,f=n.inputValue,m=n.isHidden,x=n.maxCount,g=n.dataStorageKey,h=n.dataStorage,v=n.clearable,S=function(e,r){return JSON.parse(e.getItem(r))||[]}(h,g),_=o();if(t.useEffect((function(){var r;(null==f?void 0:f.trim())&&!S.includes(f)&&(r=f,l(h,g,a.take(e.__spreadArray([r],S,!0),x)))}),[f]),a.isEmpty(S)||m)return null;var y=null==S?void 0:S.map((function(t){return r.jsxs("div",e.__assign({className:_.option,"data-testid":"".concat("RecentSearches","_").concat(t),onClick:function(){!function(e){l(h,g,v?S:S.filter((function(r){return r!==e}))),d(e)}(t)}},{children:[p&&r.jsx(p,{className:_.recentSearchesIcon}),r.jsx("div",e.__assign({className:_.label},{children:t}))]}),t)}));return r.jsxs("div",e.__assign({className:c.default(_.recentSearchesWrapper,s)},{children:[u&&r.jsx(i.Typography,e.__assign({className:_.caption},{children:u})),y]}))};
