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