import{r as e,j as t}from"./react-B_SyE9nW.js";import{s,o as i,j as o,aN as a,n as r,au as n,G as l,B as p}from"./index-Flm6m8Wj.js";import{S as c,h as d,a as h,b as x,c as m}from"./SearchTabs-CtLPWyU-.js";import{P as u}from"./RatingReview-B-1D8CT5.js";import{I as j,f,P as g,T as v}from"./index-C6Ujt1Uk.js";import{S as b}from"./SearchIco-DT1PnKLK.js";import{H as w}from"./HomeContext-BSc59jT5.js";import{s as y}from"./BaseList-DujuL-Ej.js";import{P as I}from"./Autocomplete-BQWOUXOt.js";import{T}from"./styles-BKX5ijFq.js";import{S as E}from"./Stack-CZ7Wid7r.js";const C=[{src:d,srcTiny:h},{src:x,srcTiny:m}];let B=!1,S=0;const k=s(j)`
  --visible: 'hidden';
  position: absolute;
  right: 0;

  & {
    visibility: var(--visible);
    padding: 6px 8px;
  }
`,M=i((()=>{const{clear:s}=e.useContext(w);return t.jsx(k,{"aria-label":"clear",onClick:()=>{var e;n((()=>{y.value=""})),s(),null==(e=document.getElementById("enj-home-search"))||e.focus()},style:{"--visible":y.value?"visible":"hidden"},children:t.jsx(f,{})})})),P={startAdornment:t.jsx(b,{}),endAdornment:t.jsx(M,{})},H=s(I)`
  position: relative;
  z-index: 1;
  left: -15px !important;
  max-width: calc(100% - 30px);
  width: calc(100% - 30px);
  @media (min-width: 768px) {
    max-width: 352px;
  }
`,R=()=>{S=0,setTimeout((()=>{B||n((()=>{y.open=B})),B=!1}),l.isDesktop?300:0)},z=()=>{var e;B=!0,++S>=2&&(S=0,null==(e=document.getElementById("enj-home-search"))||e.focus())},D=()=>{y.open&&(B=!0),n((()=>{y.anchorEl||(y.anchorEl=document.getElementById("enj-home-search")||null),y.open=!0}))},A=i((()=>t.jsx(H,{open:y.open,id:"enj-popper-home-search",anchorEl:y.anchorEl,onBlur:R,children:t.jsx(g,{elevation:1,sx:{borderRadius:"18px",minHeight:"20px",p:"15px 10px 10px"},onClick:z,children:t.jsx(c,{})})}))),F={"& fieldset":{inset:0},"&":{"@media(min-width:768px)":{maxWidth:"352px",m:0,"& .MuiSvgIcon-root":{mr:"8px"}}}},O=i((()=>{const{onSearch:s,clear:i}=e.useContext(w),o=e.useMemo((()=>a(s,300)),[]);e.useEffect((()=>()=>{o.cancel(),y.reset(),S=0,i()}),[]);return t.jsx(T,{autoComplete:"off",id:"enj-home-search","aria-describedby":"enj-popper-home-search",InputProps:P,onFocus:D,onBlur:R,value:y.value,onChange:e=>{n((()=>{y.anchorEl=e.currentTarget;const t=e.target.value;y.value=t,y.open=!!t,o(t)}))},placeholder:r("searchHomePlaceholder"),sx:F})})),G={p:"0 15px 12px",width:"100%",height:"90px",bgcolor:o.grayMap,borderRadius:"0 0 28px 28px",position:"sticky",top:0,zIndex:1,justifyContent:"flex-end",overflow:"hidden","& fieldset.MuiOutlinedInput-notchedOutline":{inset:0},"@media(min-width:768px)":{height:"200px",pb:"25px"},"@media(min-width:1366px)":{height:"210px",pb:"49px",borderRadius:"0",position:"relative"},"& > p":{filter:"drop-shadow(0px 0px 8px #000)"}},L=()=>Math.floor(2*Math.random()+1)-1;const N={width:"100%",height:"100%",position:"absolute",left:0,top:0,overflow:"hidden",zIndex:-1,filter:"brightness(0.5)","& picture, & picture > img":{height:"100%",width:"100%"}};const W=i((function(){const{title:e,src:s,srcTiny:i}=function(){const e=L(),t=L();return{title:["welcome","theBests"][e],...C[t]}}();return t.jsxs(E,{sx:G,"data-test":"enj-header",children:[l.isMobile?t.jsx(t.Fragment,{}):t.jsx(v,{dataTest:"enj-header-title",text:r(e),color:"white",weight:"normal",size:l.isDesktop?"xxlargex":"xlargem",margin:`auto auto ${l.isDesktop?26:20}px`,variant:"h1"}),t.jsx(p,{sx:{display:"flex",alignItems:"center",width:"100%",justifyContent:"center"},children:t.jsx(O,{})}),t.jsx(A,{}),t.jsx(p,{sx:N,children:t.jsx(u,{src:s,srcTiny:i,dataTest:"enj-header-image"})})]})}));export{W as H,k as I};