"use strict";var e=require("@babel/runtime/helpers/defineProperty"),r=require("react"),t=require("lodash"),n=require("@material-ui/core"),a=require("react/jsx-runtime");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e);function u(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function c(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?u(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):u(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var p=n.makeStyles((function(e){return{content:{width:"342px",maxHeight:"166px",borderRadius:"4px",marginLeft:"50px",marginTop:"-16px",overflowY:"auto",background:e.palette.background.b9,boxShadow:"0px 5px 5px -3px rgb(0 0 0 / 20%), 0px 8px 10px 1px rgb(0 0 0 / 14%), 0px 3px 14px 2px rgb(0 0 0 / 12%)","&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-corner":{background:"rgba(0, 0, 0, 0)"},"&::-webkit-scrollbar-thumb":{backgroundColor:"rgba(164, 164, 167, 0.7)",borderRadius:"10px",border:"5px solid rgba(0, 0, 0, 0.01)",backgroundClip:"padding-box"},zIndex:999},label:{background:e.palette.background.b9},labelWrapper:{height:"24px",padding:"0 4px",background:e.palette.background.b9},itemWrapper:{display:"flex",alignItems:"center"},unit:{color:e.palette.primary.text7,marginLeft:"4px"}}}));module.exports=function(e){var i=e.suggestions,o=e.keyStr,u=e.onAddSuggestion,l=e.onChangeHeight,s=p(),b=r.useRef(),d=r.useMemo((function(){var e=i.filter((function(e){return e.label.toUpperCase().includes(o.toUpperCase())})),r=t.uniq(e.map((function(e){return e.type}))).reduce((function(r,t){var n=e.filter((function(e){return e.type===t}));return r.concat([{value:t,label:t,isSubHeader:!0}]).concat(n.map((function(e){return c(c({},e),{},{value:e.key})})))}),[]);return r.length?r:[{value:"noOptions",label:"No Options",isSubHeader:!0}]}),[i,o]);r.useEffect((function(){b.current&&l(b.current.clientHeight)}),[i,o,b.current]);var f=function(e){var r=e.label,t=e.isSubHeader,n=e.unit;return t?a.jsx("div",{className:s.labelWrapper,children:a.jsx("span",{children:r})}):a.jsxs("div",{className:s.itemWrapper,children:[a.jsx("span",{children:r}),!!n&&a.jsx("span",{className:s.unit,children:n})]})};return a.jsx("div",{className:s.content,ref:b,children:d.map((function(e){return a.jsx(n.MenuItem,{selected:!1,disabled:e.isSubHeader,onClick:function(){return u(e.value)},children:f(e)},e.value)}))})};
