import{r as a,U as S,j as m,X as g}from"./vendor.e6eaca24.js";import{c as y,e as P}from"./index.c6944236.js";import{o as x}from"./onEnterPress.b56e5f51.js";const b="_search_1u6p9_1";var v={search:b};const C=s=>{const[n,i]=a.exports.useState(""),[d,h]=a.exports.useState([]),[c,r]=a.exports.useState(!1),l=a.exports.useRef(""),f=S(async e=>{if(e=e.trim(),r(!0),l.current=e,!e){r(!1);return}const t=await s.onSearch(e);l.current===e&&(h(t||[]),u(!1),r(!1))},500),[o,u]=a.exports.useState(!0);y().subscribe(e=>e.type==="ready"&&!o&&u(!0));const R=P(0,768);return m(g,{className:v.search+(s.className?" "+s.className:""),placeholder:s.placeholder,value:n,noResultsMessage:s.noResultsMessage,onSearchChange:(e,{value:t})=>{i(t),r(!0),f(t)},input:{iconPosition:"left",fluid:R},results:o?[]:d.map(e=>({key:s.onGetResultKey(e),title:"",data:e})),loading:c,showNoResults:!c&&!o,resultRenderer:e=>s.onRenderResult(e.data),onResultSelect:(e,{result:t})=>s.onResultSelect(t.data),onKeyPress:x(()=>n&&s.onEnterPress&&s.onEnterPress(n))})};export{C as P};
