import{r as e,j as t}from"./react-B_SyE9nW.js";import{s,o as i,q as o,aU as a,t as r,az as n,L as l,m as p}from"./index-BQSZGmOF.js";import{S as c,h as d,a as h,b as x,c as m}from"./SearchTabs-CfZM2Hmz.js";import{P as u}from"./RatingReview-0G4iFlXG.js";import{I as j,c as f,P as g,T as v}from"./index-B6oO2W5I.js";import{S as b}from"./SearchIco-CaF9GOIM.js";import{H as w}from"./HomeContext-BawbBkhW.js";import{s as y}from"./BaseList-BxI_TkR_.js";import{P as I}from"./Autocomplete-Btbhghlh.js";import{T}from"./styles-CzleH-tD.js";import{S as E}from"./Stack-B1rHPIE2.js";const C=[{src:d,srcTiny:h},{src:x,srcTiny:m}];let S=!1,k=0;const B=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(B,{"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,{})},z=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; } `,H=()=>{k=0,setTimeout((()=>{S||n((()=>{y.open=S})),S=!1}),l.isDesktop?300:0)},R=()=>{var e;S=!0,++k>=2&&(k=0,null==(e=document.getElementById("enj-home-search"))||e.focus())},D=()=>{y.open&&(S=!0),n((()=>{y.anchorEl||(y.anchorEl=document.getElementById("enj-home-search")||null),y.open=!0}))},A=i((()=>t.jsx(z,{open:y.open,id:"enj-popper-home-search",anchorEl:y.anchorEl,onBlur:H,children:t.jsx(g,{elevation:1,sx:{borderRadius:"18px",minHeight:"20px",p:"15px 10px 10px"},onClick:R,children:t.jsx(c,{})})}))),F={"& fieldset":{inset:0},"&":{"@media(min-width:768px)":{maxWidth:"352px",m:0,"& .MuiSvgIcon-root":{mr:"8px"}}}},L=i((()=>{const{onSearch:s,clear:i}=e.useContext(w),o=e.useMemo((()=>a(s,300)),[]);e.useEffect((()=>()=>{o.cancel(),y.reset(),k=0,i()}),[]);return t.jsx(T,{autoComplete:"off",id:"enj-home-search","aria-describedby":"enj-popper-home-search",InputProps:P,onFocus:D,onBlur:H,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})})),O={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)"}},q=()=>Math.floor(2*Math.random()+1)-1;const U={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=q(),t=q();return{title:["welcome","theBests"][e],...C[t]}}();return t.jsxs(E,{sx:O,"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(L,{})}),t.jsx(A,{}),t.jsx(p,{sx:U,children:t.jsx(u,{src:s,srcTiny:i,dataTest:"enj-header-image"})})]})}));export{W as H,B as I};