import{R as i,bu as b,bv as l,bw as S,bs as y,f as w,aS as q,bx as L,g as P,j as d,a2 as x,Q as E,by as O}from"./app-BgLa5dit.js";function k(e,a=[]){function n(){e()}i.useEffect(()=>(window.addEventListener("scroll",n),()=>window.removeEventListener("scroll",n)),[...a])}function C(e){const{query:a,indices:n,analyticsOptions:r,onLog:u,shouldLog:g=!0}=e,f=b(a,5e3),[m,t]=i.useState({[a]:!1});function c(s,h){if(g){if(!s){t({"":!0});return}m[s]||(t({[s]:!0}),l.logUserAction({query:s,indices:n},l.mergeOptions(r,[{actionType:y.Search,workflowPhase:S.Complete},h])),typeof u=="function"&&u())}}function o(s,h){const v=s.name;m[v]||(t({[v]:!0}),l.logUserAction(s,l.mergeOptions(r,[{actionType:y.Search,workflowPhase:S.Complete},h])))}return i.useEffect(()=>c(f),[f]),k(()=>c(a),[a,m]),{log:c,logTrendingTopic:o}}const A="_searchSvg_1f2uy_1",I="_searchInput_1f2uy_7",N={searchSvg:A,searchInput:I};T.defaultProps={debounceTime:300,queryParamName:"query"};function T(e){const a=w.getCurrentRoute().appLink.params,[n,r]=i.useState((a==null?void 0:a[e.queryParamName])??"");i.useEffect(()=>{var t,c;if(a){if(a[e.queryParamName]){r(((t=a[e.queryParamName])==null?void 0:t.trim())??"");return}n.length&&!((c=a[e.queryParamName])!=null&&c.length)&&r("")}},[e.id]),i.useEffect(()=>{a!=null&&a[e.queryParamName]&&(a==null?void 0:a[e.queryParamName])!==n&&r(a==null?void 0:a[e.queryParamName])},[a==null?void 0:a[e.queryParamName]]);const u=b(n,e.debounceTime);i.useEffect(()=>{f(u)},[u]);function g(t){r(t.target.value)}function f(t=""){if(t===a[e.queryParamName]||!t&&!a[e.queryParamName])return;const c=q.omit(a,[e.queryParamName,"cursor"]),o={[e.queryParamName]:t.trim()?t.trimLeft():"",...c};o[e.queryParamName]||(delete o[e.queryParamName],delete o.cursor),L.preventScrollTop(),e.analyticsOptions&&l.logUserAction({query:t,indices:e.searchIndices},l.mergeOptions(e.analyticsOptions,{actionType:y.InstantSearch,workflowPhase:S.Complete})),P.trigger({...e.searchAppLink,params:o})}const{log:m}=C({query:n,indices:e.searchIndices,analyticsOptions:e.analyticsOptions,shouldLog:!!e.analyticsOptions});return d.jsxs("div",{className:"position-relative w-100",children:[d.jsx("input",{name:e.name,type:"text",className:x(`form-control pe-2 w-100 border-dark ${N.searchInput}`,e.size==="lg"&&"form-control-lg",e.className),id:e.id,autoComplete:"off",placeholder:e.placeholder,"aria-label":"Search",onChange:g,onBlur:t=>m(t.target.value??""),value:n}),d.jsx(E,{svg:O,className:`${N.searchSvg} svg-container cursor-pointer text-dark`})]})}export{T as S};
//# sourceMappingURL=1Of0XWgF.chunk.js.map
