"use strict";(self.webpackChunkwebpackYWCASBlocksJsonp=self.webpackChunkwebpackYWCASBlocksJsonp||[]).push([[179],{797(e,t,o){o.r(t),o.d(t,{default:()=>f});var r=o(956),s=o(609),c=o(87),l=o(939),a=o(212),n=o(106),u=o(572),d=o(315);var i=o(723);const p={placeholder:{type:"string",default:(0,i.__)("Search products...","yith-woocommerce-ajax-search")},placeholderTextColor:{type:"string",default:"#000"},iconType:{type:"string",default:"icon-right"},inputTextColor:{type:"string",default:"#000"},inputBgColor:{type:"string",default:"#fff"},inputBgFocusColor:{type:"string",default:"#fff"},inputBorderColor:{type:"string",default:"#7C7C7C"},inputBorderFocusColor:{type:"string",default:"#5B5B5B"},inputBorderSize:{type:"object",default:{topLeft:"1px",topRight:"1px",bottomLeft:"1px",bottomRight:"1px"}},inputBorderRadius:{type:"object",default:{topLeft:"20px",topRight:"20px",bottomLeft:"20px",bottomRight:"20px"}},submitContentColor:{type:"string",default:"#000"},submitContentHoverColor:{type:"string",default:"#000"},submitBorderColor:{type:"string",default:"#fff"},submitBorderHoverColor:{type:"string",default:"#fff"},submitBgColor:{type:"string",default:"#fff"},submitBgHoverColor:{type:"string",default:"#fff"},submitStyle:{type:"string",default:"icon"},className:{type:"string",default:"ywcas-input-block"},buttonLabel:{type:"string",default:(0,i.__)("Search","yith-woocommerce-ajax-search-premium")},buttonBorderRadius:{type:"object",default:{topLeft:"10px",topRight:"10px",bottomLeft:"10px",bottomRight:"10px"}},lock:{type:"object",default:{remove:!1,move:!1}}},f=(0,r.n)(p)(e=>{const{placeholder:t=""}=e,{query:o,setQuery:r,inputFocused:i,setInputFocused:p,size:f}=(0,n.$A)(),m=(0,c.useRef)(null),y=(0,u.Ub)(`(max-width: ${d.YWCAS_MOBILE_BREAKPOINT})`),[b,h]=(0,c.useState)(!1),[g,w]=(0,c.useState)(o);(0,c.useEffect)(()=>{w(o)},[o]),(0,c.useEffect)(()=>{const e=setTimeout(()=>{r(g)},1e3);return()=>clearTimeout(e)},[g]),(0,c.useEffect)(()=>{i&&(y?!b&&v():C())},[y,i]);const v=()=>{const e=document.querySelector("#wpadminbar"),t=document.querySelector("#ywtenv-banner");let o=document.querySelector(".ywcas-search-mobile");if(!o){o=document.createElement("div"),o.classList.add("ywcas-search-mobile"),(e||t)&&o.classList.add("with-wp-admin-toolbar");const r=i.closest(".wp-block-yith-search-block"),s=Array.prototype.indexOf.call(r.parentNode.childNodes,r);r.parentNode.classList.add("ywcas-block-mounted"),r.parentNode.dataset.ywcasTarget=s,o.append(r),document.body.append(o),document.body.classList.add("ywcas-disable-overflow"),document.documentElement.style.overflow="hidden",h(!0)}},C=()=>{const e=document.querySelector(".ywcas-search-mobile");if(e){const t=e.querySelector(".wp-block-yith-search-block"),o=document.querySelector(".ywcas-block-mounted"),r=o.dataset.ywcasTarget;r<o.childNodes.length-1?o.insertBefore(t,o.childNodes[r]):o.append(t),e.remove(),o.classList.remove("ywcas-block-mounted"),document.body.classList.remove("ywcas-disable-overflow"),document.documentElement.style.overflow=""}h(!1)};return(0,s.createElement)(l.Box,{ref:m},(0,s.createElement)(a.Lw,{placeholder:t,setSearchQuery:(e,t)=>{e?(e.stopPropagation(),i||p(null==m?void 0:m.current),g!==e.target.value&&w(e.target.value)):w(t)},queryString:g,onFocus:()=>{p(null==m?void 0:m.current)},onCloseMobile:()=>{C(),w(""),p(null);const e=new CustomEvent("ywcas-close-mobile",{detail:{},bubbles:!0,cancelable:!0,composed:!1});document.dispatchEvent(e)},size:f,isSmallDevice:y,...e}))})},956(e,t,o){o.d(t,{n:()=>c});var r=o(609),s=o(486);const c=e=>t=>o=>{const c=(0,s.N)(e,o);return(0,r.createElement)(t,{...o,...c})}}}]);