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