"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[26657],{358935(e,a,E){E.d(a,{X2:()=>A,lX:()=>d,uC:()=>C});var s=E(571766),t=E(29472),i=E(159469),n=E(774366);const l=`${E(290454).w}/device/:mac:`,c=`${l}/replacement-candidates`,r=`${l}/replace?replacementDeviceMac=:replacement-mac:`,o=`${l}/replace`,d=(e={},a={})=>(0,t.Kd)("replacementCandidates",`${c.replace(":mac:",e.queryParams?.mac)}`,e.queryParams?.mac,e,{...a,idField:"mac"}),C=(e,a)=>E=>E((0,t.vB)(s.aC,null,null,n.A.POST,r.replace(":mac:",e).replace(":replacement-mac:",a),{},null,{})),A=e=>a=>a((0,t.vB)(s.aC,null,null,n.A.DELETE,o.replace(":mac:",e),{},null,{failureToast:()=>({icon:i.C.danger,message:"COMMON_UNKNOWN_ERROR"})}))},428792(e,a,E){E.d(a,{F:()=>c,T:()=>o});var s=E(222102),t=E(656466),i=E(401042),n=E(549059);const l=(0,t.uh)((0,n.P)()),c=(0,s.Mz)(l,i.kh),r=(0,t.uh)((0,n.L)()),o=(0,s.Mz)(r,i.kh)},721398(e,a,E){E.d(a,{A:()=>l});var s=E(274934),t=E(125799),i=E(853777),n=E(470070);const l=({messageId:e,tooltipClassName:a,values:E,isInteractive:l,portal:c,variant:r="twoTone",size:o="medium"})=>(0,s.jsx)(t.A,{description:(0,s.jsx)(n.sA,{id:e,values:E}),width:210,isInteractive:l,portal:c,tooltipClassName:a,children:(0,s.jsx)(i.A,{isActive:!0,omitSvgMargin:!0,variant:r,size:o})})},999837(e,a,E){E.d(a,{A:()=>$});var s=E(274934),t=E(977872),i=E(602086),n=E(696264),l=E(599110),c=E(159469),r=E(706925),o=E(700444),d=E(470070),C=E(222102),A=E(656466),_=E(401042),u=E(358935);var M,m,N=E(857780),I=E(570866);!function(e){e.EXISTING="existing",e.NEW="new"}(M||(M={})),function(e){e.MAC="mac",e.TYPE="type",e.MODEL="model"}(m||(m={}));var T,R=E(990330),p=E(125799),v=E(843615),S=E(853777),D=E(489714),x=E(947414);!function(e){e.DEVICE_REPLACEMENT_MODE="deviceReplacementMode",e.SET_DEVICE_REPLACEMENT_MODE="setDeviceReplacementMode",e.NEW_MAC="newMac",e.SET_NEW_MAC="setNewMac",e.EXISTING_MAC="existingMac",e.SET_EXISTING_MAC="setExistingMac",e.REPLACEMENT_CANDIDATES="replacementCandidates",e.ERROR="error",e.RESET_ERROR="resetError"}(T||(T={}));const g=(0,i.createContext)({[T.DEVICE_REPLACEMENT_MODE]:void 0,[T.SET_DEVICE_REPLACEMENT_MODE]:x.P1,[T.NEW_MAC]:void 0,[T.SET_NEW_MAC]:x.P1,[T.EXISTING_MAC]:void 0,[T.SET_EXISTING_MAC]:x.P1,[T.REPLACEMENT_CANDIDATES]:[],[T.ERROR]:void 0,[T.RESET_ERROR]:x.P1}),h=E(409844).AH`
  height: 54px;
`;var O=E(247816),P=E(309130),L=E(100978);const b=(0,O.A)(L.A)`
  align-items: center;
  gap: ${P.YC};
`,j=(0,i.memo)(()=>{const{newMac:e,setNewMac:a,error:E,resetError:t}=(0,i.useContext)(g),n=(0,i.useCallback)(({target:{value:e}})=>{a((0,D.Z)(e)),t()},[a,t]);return(0,s.jsx)(v.A,{className:h,value:e,onChange:n,onFocus:t,variant:"secondary",label:(0,s.jsxs)(b,{children:[(0,s.jsx)(d.sA,{id:"COMMON_MAC_ADDRESS"}),(0,s.jsx)(p.A,{portal:!0,width:"100%",maxWidth:248,description:(0,s.jsx)(d.sA,{id:"DEVICE_REPLACEMENT_MAC_LOCATION"}),children:(0,s.jsx)(S.A,{isActive:!0})})]}),width:"100%",invalid:E})});var f=E(237887),k=E(974390);const w=(0,i.memo)(()=>{const{replacementCandidates:e,existingMac:a,setExistingMac:E,error:t,resetError:n}=(0,i.useContext)(g),l=(0,i.useMemo)(()=>e.map(({mac:e,model:a,name:E})=>({label:E,value:e,image:(0,s.jsx)(k.A,{model:a}),additionalInfo:e})),[e]),c=(0,i.useCallback)(({value:e})=>{E(String(e)),n()},[E,n]);return(0,s.jsx)(f.A.Sorted,{value:a,label:(0,s.jsx)(d.sA,{id:"COMMON_DEVICE"}),width:"100%",searchable:!0,onChange:c,onFocus:n,maxHeight:228,options:l,invalid:t})}),V=(0,O.A)(L.A)`
  flex-direction: column;
  gap: ${P.kc};
`,G=(0,i.memo)(()=>{const{replacementCandidates:e,deviceReplacementMode:a,setDeviceReplacementMode:E,resetError:t}=(0,i.useContext)(g),n=(0,i.useMemo)(()=>e.length?[{id:M.EXISTING,children:(0,s.jsx)(d.sA,{id:"COMMON_EXISTING"}),onChange:()=>{E(M.EXISTING),t()},checked:a===M.EXISTING},{id:M.NEW,children:(0,s.jsx)(d.sA,{id:"COMMON_NEW"}),onChange:()=>{E(M.NEW),t()},checked:a===M.NEW}]:[],[e.length,a,E,t]);return(0,s.jsxs)(V,{children:[(0,s.jsx)(R.A,{direction:"row",items:n}),a===M.EXISTING?(0,s.jsx)(w,{}):null,a===M.NEW?(0,s.jsx)(j,{}):null]})}),W=(0,O.A)(L.A)`
  align-items: center;
  gap: ${P.YC};
  width: fit-content;
`;var X=E(721398);const y={[N.gQ.INCOMPATIBLE_REPLACEMENT]:"DEVICE_REPLACEMENT_DEVICE_INCOMPATIBLE_REPLACEMENT_ERROR",[N.gQ.REPLACEMENT_ALREADY_ASSIGNED]:"DEVICE_REPLACEMENT_DEVICE_REPLACEMENT_ALREADY_ASSIGNED_ERROR"},z=({mac:e,hideTooltip:a=!1})=>{const{formatMessage:E}=(0,d.tz)(),r=(0,t.wA)(),[m,R]=(0,i.useState)(!1),[p,v]=(0,i.useState)(!1),[S,D]=(0,i.useState)(M.NEW),[x,h]=(0,i.useState)(""),[O,P]=(0,i.useState)(""),[L,b]=(0,i.useState)(void 0),j=(0,t.d4)((0,i.useMemo)(()=>(e=>(0,C.Mz)((e=>(0,A.uh)((0,u.lX)({queryParams:{mac:e}})))(e),e=>(0,_.i6)(e)?.devices||[]))(e),[e])),f=(0,i.useCallback)(()=>{R(!0)},[]),k=(0,i.useCallback)(()=>{R(!1),h(""),P(""),v(!1),D(M.NEW),b(void 0)},[]),w=(0,i.useCallback)(()=>{switch(S){case M.EXISTING:return O;case M.NEW:return x;default:return}},[S,O,x]),V=(0,i.useCallback)(()=>{r((0,o.ox)({icon:c.C.success,message:"DEVICE_REPLACEMENT_DEVICE_SET",duration:3e3})),k()},[r,k]),z=(0,i.useCallback)(e=>{switch(e.apiData?.replacement_state){case N.gQ.INCOMPATIBLE_REPLACEMENT:case N.gQ.REPLACEMENT_ALREADY_ASSIGNED:b(E({id:y[e.apiData.replacement_state]}));break;default:r((0,o.ox)({icon:c.C.danger,message:"DEVICE_FAILED_TO_SET_REPLACEMENT_DEVICE",duration:3e3}))}},[r,E]),$=(0,i.useCallback)(()=>{v(!1)},[]),q=(0,i.useCallback)(()=>{v(!0),r((0,u.uC)(e,w())).then(V).catch(z).finally($)},[r,V,z,e,w,$]),F=(0,i.useMemo)(()=>Boolean(w().match(I.b8)),[w]),Y=(0,i.useMemo)(()=>[{text:(0,s.jsx)(d.sA,{id:"COMMON_ACTION_CANCEL"}),variant:"tertiary",onClick:k},{text:(0,s.jsx)(d.sA,{id:"COMMON_ACTION_APPLY"}),variant:"primary",onClick:q,disabled:!F||p,loader:p?"spinner":void 0}],[k,q,F,p]),B=(0,i.useCallback)(()=>{b(void 0)},[b]),U=(0,i.useMemo)(()=>({[T.DEVICE_REPLACEMENT_MODE]:S,[T.SET_DEVICE_REPLACEMENT_MODE]:D,[T.NEW_MAC]:x,[T.SET_NEW_MAC]:h,[T.EXISTING_MAC]:O,[T.SET_EXISTING_MAC]:P,[T.REPLACEMENT_CANDIDATES]:j,[T.ERROR]:L,[T.RESET_ERROR]:B}),[S,x,O,j,L,B]);return(0,i.useEffect)(()=>{r((0,u.lX)({queryParams:{mac:e}}))},[r,e]),(0,s.jsx)(g.Provider,{value:U,children:(0,s.jsx)(n.A,{allowOverflow:!0,title:(0,s.jsx)(d.sA,{id:"DEVICE_SET_REPLACEMENT_DEVICE"}),body:(0,s.jsx)(G,{}),position:"top",portal:!0,actions:Y,isOpen:m,onRequestClose:k,children:(0,s.jsxs)(W,{children:[(0,s.jsx)(l.A,{type:"button",variant:"inline",size:"medium",onClick:f,children:(0,s.jsx)(d.sA,{id:"DEVICE_SET_REPLACEMENT_DEVICE"})}),a?null:(0,s.jsx)(X.A,{messageId:"DEVICE_SET_REPLACEMENT_DEVICE_DESCRIPTION",variant:"outline"})]})})})},$=(0,i.memo)(({model:e,type:a,...E})=>(0,r.G)({type:a,model:e})?(0,s.jsx)(z,{type:a,model:e,...E}):null)},577141(e,a,E){E.d(a,{FH:()=>d,YG:()=>A,ad:()=>o,dA:()=>C});var s=E(222102),t=E(254585),i=E(428792),n=E(904614),l=E(910577),c=E(754924),r=E(544691);const o=(0,s.Mz)(r.K8,l.Ag,t.gm,(e,a,E)=>e.filter(({device_macs:e})=>e.includes(E)).reduce((e,{_id:E})=>[...e,...a.filter(({ap_group_ids:e})=>(e||[]).includes(E))],[])),d=(0,s.Mz)(o,e=>e.every(({enabled:e})=>!1===e)),C=(0,s.Mz)(o,e=>e.some(({enabled:e,wlan_bands:a})=>e&&(a||[]).includes(n._$.AX))),A=(0,s.Mz)(t.gm,c.vh,i.F,r.K8,(e,a,E,s)=>{if(!a.includes(e))return null;const t=s.filter(({device_macs:a})=>a.includes(e));return E.filter(({configuration:{ap_group_ids:e}})=>t.some(({_id:a})=>e?.includes(a))).some(({configuration:{wlan_bands:e}})=>e.includes(n._$.AX))})},706925(e,a,E){E.d(a,{G:()=>l});var s=E(956978),t=E(857780);const i=[t.bq.USW,t.bq.UAP,t.bq.USP],n=[t.W4.UDBA69F],l=({type:e,model:a})=>(i.includes(e)||n.includes(a))&&!(0,s.tNJ)({model:a})},489714(e,a,E){E.d(a,{Z:()=>t});var s=E(570866);const t=e=>e?e.replace(s.SD,"").replace(s.fA,"$&:").substring(0,17).toLowerCase():e}}]);