(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[69029],{879077(e,t,l){"use strict";l.d(t,{A:()=>_});var s=l(296540),n=l(469733),r=l(961630),a=l(548950),u=l(778851),o=l(451919),c=l(510497),i=l(366702),d=l(916537),m=l(187483),h=l(572112),f=l(639775),R=l(59308),E=l(382915),T=l(822336),g=l(968154),b=l(779185),S=l(883057),y=l(71479);const A=(0,y.A)("div")`
  // Raise above tabs in wifi scanner and wifi speed-test
  z-index: 1;
`,C=(0,y.A)(S.J)`
  &[aria-selected='true'] {
    background: ${({theme:{themeName:e}})=>T.Ay[`desktop-color-neutral-02-${e}`]};
  }
  &.hideSearchResultCount {
    > span:last-child {
      display: none;
    }
  }
`,L=({hideSearchResultCount:e=!1,...t})=>s.createElement(C,{...t,...e&&{className:"hideSearchResultCount"}}),M=(0,y.A)(b.F)`
  &[aria-selected='true'] {
    background: ${({theme:{themeName:e}})=>T.Ay[`desktop-color-neutral-02-${e}`]};
  }
`;function v(){return s.createElement(g.m,null,s.createElement("style",null,"\n        .multi-search-fix {\n          z-index: 25;\n        }\n    "))}var p=l(458973);const _=({lsKey:e,getInitialSuggestions:t,searchModelName:l,searchIndex:T,enabledColumns:g,records:b,recordIdKey:S,omitAllResults:y=!1,resultsLimit:C=1e4,onFocus:_,onBlur:w,onAddTag:N,onReset:O,onRemoveTag:$,initialTags:k,placeholder:I,hideSearchResultCount:U=!1,enableMinifiedView:x=!1})=>{const{formatMessage:Q}=(0,d.tz)(),F=(0,i.Ay)().width<h.A.M.TO,V=(0,s.useMemo)(()=>({width:x&&F?E.q1:E.Em,expandedWidth:x&&F?E.Em:void 0}),[x,F]),z=(0,s.useMemo)(()=>new Set(b),[b]),H=(0,s.useMemo)(()=>z.size||C,[z.size,C]),P=(0,n.useDispatch)(),q=(0,n.useSelector)(m.W1),B=(0,n.useSelector)(m.YL),W=(0,n.useSelector)(m.TP),D=(0,s.useMemo)(()=>(0,u.ns)(q,B,W),[W,B,q]),{usedPlaceholder:J,overflowTitleLabel:j,overflowTranslations:K,removeTagLabel:G,recentTermsLabel:Y,recentTermsTitle:Z,resetButton:X,searchResultsLabel:ee}=(0,s.useMemo)(()=>({usedPlaceholder:I||Q({id:"COMMON_SEARCH"}),overflowTitleLabel:Q({id:"MULTI_SEARCH_OVERFLOW_LABEL"}),overflowTranslations:{singular:`{0} ${Q({id:"MULTI_SEARCH_OVERFLOW_SINGULAR"})}`,plural:`{0} ${Q({id:"MULTI_SEARCH_OVERFLOW_PLURAL"})}`},removeTagLabel:Q({id:"MULTI_SEARCH_REMOVE_TERM"}),recentTermsLabel:Q({id:"MULTI_SEARCH_RECENT_TERMS_LABEL"}),recentTermsTitle:Q({id:"MULTI_SEARCH_RECENT_TERMS_TITLE"}),resetButton:Q({id:"COMMON_ACTION_RESET"}),searchResultsLabel:Q({id:"MULTI_SEARCH_RESULTS"})}),[I,Q]),te=(0,s.useMemo)(()=>`${o.TA.PERSIST}:${o.TA.NETWORK}.${D}.${e}`,[D,e]),le=(0,s.useMemo)(()=>{try{const e=JSON.parse(c.D.getItem(te));return e.length?e:null}catch{return null}},[te]),se=(0,n.useSelector)((0,s.useMemo)(()=>(0,R.f)(l),[l])),ne=(0,s.useMemo)(()=>le||(t instanceof Function?t():t)||[],[t,le]),[re,ae]=(0,s.useState)(()=>ne),[ue,oe]=(0,s.useState)({value:"",searchResults:[]}),ce=(0,s.useRef)(new Set(b.map(e=>e[S]))),ie=(0,s.useCallback)(e=>{const{id:t,tag:l}=e,s=[{id:t,label:l},...re.filter(e=>e.id!==t)].slice(0,E.om);ae(s),c.D.setItem(te,JSON.stringify(s))},[te,re]),de=(0,s.useCallback)(e=>{const t=re.filter(({id:t})=>t!==e);ae(t),c.D.setItem(te,JSON.stringify(t))},[te,re]);(0,s.useEffect)(()=>{const e=new Set,t=Array.from(z),l=t.length;for(let s=0;s<l;s+=1){const l=t[s];T.addAsync(l,void 0),e.add(l[S])}const s=Array.from(ce.current),n=s.length;for(let t=0;t<n;t+=1){const l=s[t];e.has(l)||T.removeAsync(l)}ce.current=e},[S,z,T]);const me=(0,s.useCallback)(()=>{oe(e=>({...e,value:""}))},[]),he=(0,s.useCallback)(()=>{oe({searchResults:[],value:""}),P((0,p.sV)(l)),O?.()},[P,O,l]),fe=(0,s.useCallback)(async e=>{N?.();const t=ue.searchResults?.find(({id:t})=>t===e);if(ue.searchResults.length>0&&t&&(P((0,p.tn)({modelName:l,id:t.id,fsQuery:t.fsQuery,result:t.result,label:t.tag})),ie(t),oe(e=>({...e,searchResults:[]}))),0===ue.searchResults.length&&e){const[t,s]=e.split("::"),n="all"===t?g:[t],r=await T.searchAsync({query:s,index:n,limit:H});P((0,p.tn)({modelName:l,id:e,fsQuery:(0,f.pR)(r,s,n),result:(0,f.UV)(r),label:s})),ie({id:e,tag:s})}},[ie,P,g,H,N,T,l,ue.searchResults]),Re=(0,s.useCallback)(e=>{P((0,p.W1)(l,e)),$?.(e)},[P,$,l]);(0,s.useEffect)(()=>{const e=se.length;if(e)for(let t=0;t<e;t+=1){const e=se[t],s=(0,f.UV)(T.search(e.fsQuery.query,H,{index:g,enrich:!0,limit:H}));(0,a._)(e.result,s)||P((0,p.P8)({...e,result:s,label:`${e.fsQuery.query}`,modelName:l}))}},[P,b]),(0,s.useEffect)(()=>{if(k){he();const e=k.length;for(let t=0;t<e;t+=1)fe(`${E.G_}${k[t]}`)}},[k]);const Ee=(0,s.useCallback)(e=>t=>{t.stopPropagation(),de(e)},[de]),Te=(0,s.useMemo)(()=>re.map(({id:e,label:t})=>({id:e,label:s.createElement(M,{label:t,onRemove:Ee(e)})})),[Ee,re]);return s.createElement(A,null,s.createElement(v,null),s.createElement(r.A,{dropdownPortalClassName:"multi-search-fix",placeholder:se.length?null:J,selectOnEnter:!0,onFocus:_,onBlur:w,onAddTag:fe,onChange:(e,t)=>{const n=T.search(t,H,{index:g,enrich:!0,limit:H}),r=(0,f.UV)(n),u=(0,f.Qp)(se),o=(0,f.lN)(n),c=1===o.length?o[0].field:E.Mv,i=[],d=(0,f.A1)(n,u,S),m=[],h=new Set,R=Object.keys(d),b=R.length;for(let e=0;e<b;e+=1){const l=R[e],s=Array.from(d[l]).slice(0,E.rw),n=s.length;for(let e=0;e<n;e+=1){const n=s[e],r=Array.isArray(n)?n:[n];for(let e=0;e<r.length;e+=1){const s=r[e],n={query:s,index:[l],limit:H},{result:o}=T.search(n)[0];if(1===r.length||(0,f.V9)(s,t)){const e=`${l}::${s}`;h.has(e)||(h.add(e),m.push({id:e,fsQuery:n,query:s,count:(0,a.y)(...Object.values({...u,[l]:new Set([...u[l]||[],...o])})).size,result:new Set(o)}))}}}}m.sort((e,t)=>t.count-e.count);const A=m.slice(0,E.NZ).length;for(let e=0;e<A;e+=1){const{query:t,count:n,id:r,result:a,fsQuery:u}=m[e];i.push({id:r,label:s.createElement(L,{label:s.createElement(s.Fragment,null,t),count:n,hideSearchResultCount:U}),fsQuery:u,tag:`${t}`,result:new Set(a),modelName:l})}const C=(0,a.y)(...Object.values({...u,[c]:new Set([...u[c]||[],...r])})),M={id:`${c}::${t}::inputString`,label:s.createElement(L,{label:s.createElement(s.Fragment,null,t),count:C.size,hideSearchResultCount:U}),fsQuery:(0,f.pR)(o,t),tag:`${t}`,result:r,modelName:l};if(0===C.size&&i.length>0){const{count:e,id:l,result:n,fsQuery:r}=m[0],[a]=l.split("::");M.id=`${a}::${t}`,M.result=n,M.fsQuery.index=[...r.index],M.label=s.createElement(L,{label:s.createElement(s.Fragment,null,t),count:e,hideSearchResultCount:U})}y||i.unshift(M),oe(""===t?{value:"",searchResults:[]}:{value:t,searchResults:i})},onClear:me,onReset:he,onRemoveTag:Re,overflowTitleLabel:j,overflowTranslations:K,removeTagLabel:G,recentTerms:Te,recentTermsLabel:Y,recentTermsTitle:Z,resetButton:X,searchResults:ue.searchResults,searchResultsLabel:ee,tags:se,value:ue.value,...V}))}},17809(){}}]);