"use strict";(self.webpackChunkwebpackYWCASBlocksJsonp=self.webpackChunkwebpackYWCASBlocksJsonp||[]).push([[153],{817:(e,t,n)=>{n.r(t),n.d(t,{default:()=>k});var l=n(609),s=n(368),c=n.n(s),r=n(87),o=n(939),a=n(723);const u=window.CustomEvent||null;var i=n(560),d=n(212),p=n(106),m=n(315);const k=({children:e,className:t})=>{if(!m.YWCAS_HAS_AUTOCOMPLETE)return null;const{query:n,inputFocused:s,setInputFocused:k}=(0,p.$A)(),{getResults:f}=(0,i.$)(),b=f(n);(0,r.useEffect)(()=>{const e=e=>{const t=document.getElementsByClassName("wp-block-yith-filled-block");e.target.parentNode.parentNode&&e.target.parentNode.parentNode.classList.contains("ywcas-input-field-wrapper")||t[0]&&!t[0].contains(e.target)&&k(null)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[k]),(0,r.useEffect)(()=>{((e,{bubbles:t=!1,cancelable:n=!1,element:l,detail:s={}})=>{if(!u)return;l||(l=document.body);const c=new u(e,{bubbles:t,cancelable:n,detail:s});l.dispatchEvent(c)})("ywcas-blocks_render_blocks_frontend",{element:document.body.querySelector(".wp-block-yith-search-block")})},[]);const E=c()("ywcas-popover-results",0===b.results.totalResults?"no-results":"");return""===n||n.length<m.YWCAS_MIN_CHARS?null:s?(0,l.createElement)(l.Fragment,null,(0,l.createElement)(d.z6,{className:E,anchorRef:s,verticalMargin:5,forceMinWidth:!0,forceInView:!1,fixed:!0,sx:{"&.no-results hr.wp-block-separator":{display:"none"},"& hr.wp-block-separator":{marginLeft:"0",marginRight:"0"}}},(0,l.createElement)(o.Stack,{direction:"column",spacing:4,className:"wp-block-yith-filled-block"},b.results.fuzzyToken&&b.results.fuzzyToken.length>0&&(0,l.createElement)(o.Box,{sx:{lineHeight:"2.5em"}},(0,a.sprintf)(m.YWCAS_PLURAL_RESULTS_LABEL,0,n)),(0,l.createElement)(o.Box,{className:t},b.results.fuzzyToken&&b.results.fuzzyToken.length>0&&(0,l.createElement)(o.Box,{sx:{marginBottom:"15px"}},(0,l.createElement)("strong",null,(0,a.sprintf)(m.YWCAS_FUZZY_RESULTS,b.results.fuzzyToken))),e)))):null}}}]);