"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[9213],{13524:(e,t,a)=>{a.d(t,{A:()=>I});var n=a(296540),E=a(86571),l=a(689965),r=a(469733),c=a(927099),i=a(777916),o=a(758649),s=a(137298),m=a(398300),A=a(294303),u=a(845030),d=a(699784),C=a(927806),_=a(532419),p=a(360113),M=a(258117);const N=({activeItem:e})=>{const{speed:t,rx_packets:a,rx_bytes:E,tx_packets:l,tx_bytes:N}=(0,C.q$)(e)||{},I=(0,r.useSelector)((0,n.useMemo)(()=>(0,_.I4)(e.mac),[e.mac])),{poe_power:T=null,port_poe:R=!1}=(0,C.$Y)({device:e,uplink:I})||{},v=(0,r.useDispatch)(),{formatMessage:S}=(0,d.tz)(),D=(0,n.useCallback)(()=>{v((0,u.XP)({type:m.H.DEVICE,id:I?.mac}))},[v,I?.mac]);return n.createElement(A.A,{height:"100%",flexDirection:"column"},I?.mac?n.createElement(p.A,null,n.createElement(c.A,{size:"body"},n.createElement(d.sA,{id:"COMMON_DEVICE"})),n.createElement(o.A,{type:"button",variant:"inline",onClick:D},n.createElement(c.A,{color:"inherit",size:"body",truncate:!0},(0,C.Jz)(e,I,S)))):null,n.createElement(M.A,{portSpeed:t}),R&&Number(T)>0?n.createElement(p.A,null,n.createElement(c.A,{size:"body"},n.createElement(d.sA,{id:"DEVICE_PROPERTY_UPLINK_POWER"})),n.createElement(c.A,{size:"body",color:"tertiary"},n.createElement(d.sA,{id:"COMMON_UNIT_WATTS_SHORT",values:{value:T}}))):null,a&&E?n.createElement(p.A,null,n.createElement(c.A,{size:"body"},n.createElement(d.sA,{id:"COMMON_DOWN_PKTS_BYTES"})),n.createElement(c.A,{size:"body",color:"tertiary"},n.createElement(i.A,{type:"number",input:a,size:"body",color:"tertiary"})," / ",(0,s.z3)(E))):null,l&&N?n.createElement(p.A,null,n.createElement(c.A,{size:"body"},n.createElement(d.sA,{id:"COMMON_UP_PKTS_BYTES"})),n.createElement(c.A,{size:"body",color:"tertiary"},n.createElement(i.A,{type:"number",input:l,size:"body",color:"tertiary"})," / ",(0,s.z3)(N))):null)},I=({activeItem:e})=>n.createElement(l.A,{type:l.I.ACCORDION,items:[{id:"uplink",openByDefault:!0,label:n.createElement(E.A,{id:"COMMON_PARENT_DEVICE"}),renderContent:()=>n.createElement(N,{activeItem:e})}]})},71265:(e,t,a)=>{a.d(t,{R:()=>m,k:()=>A});var n=a(280258),E=a(190497),l=a(953048),r=a(175522),c=a(936621),i=a(305988);const o=[...new Set([n.H,r.Q.join(r.A),l.Zt,c.F,E.nc,i.Vr])],s={numeric:!0,sensitivity:"base"},m=(e,t)=>{const a=[];for(let n=e;n<=t;n+=1)a.push({value:n,label:String(n)});return a},A=e=>({value:t,label:a},{value:n,label:E})=>o.includes(t?.toString())||o.includes(n?.toString())?1/0:a?.toString().localeCompare(E?.toString(),e,s)??-1},175522:(e,t,a)=>{a.d(t,{A:()=>E,Q:()=>l});var n=a(416348);const E="_",l=[n.ZM,n.Je]},211908:(e,t,a)=>{a.d(t,{A:()=>B});var n=a(469733),E=a(296540),l=a(353899),r=a(758649),c=a(742920),i=a(421130),o=a(675359),s=a(699784),m=a(801081),A=a(25553),u=a(87485),d=a(264963);const C=e=>(0,m.Mz)((e=>(0,A.uh)((0,d.lX)({queryParams:{mac:e}})))(e),e=>(0,u.i6)(e)?.devices||[]);var _,p,M=a(768195),N=a(546391);!function(e){e.EXISTING="existing",e.NEW="new"}(_||(_={})),function(e){e.MAC="mac",e.TYPE="type",e.MODEL="model"}(p||(p={}));var I,T=a(238761),R=a(271856),v=a(438628),S=a(162420),D=a(400261),O=a(874807);!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"}(I||(I={}));const P={[I.DEVICE_REPLACEMENT_MODE]:void 0,[I.SET_DEVICE_REPLACEMENT_MODE]:O.P1,[I.NEW_MAC]:void 0,[I.SET_NEW_MAC]:O.P1,[I.EXISTING_MAC]:void 0,[I.SET_EXISTING_MAC]:O.P1,[I.REPLACEMENT_CANDIDATES]:[],[I.ERROR]:void 0,[I.RESET_ERROR]:O.P1},b=(0,E.createContext)(P);const y=a(132196).AH`
  height: 54px;
`;var g=a(71479),L=a(566723),h=a(294303);const V=(0,g.A)(h.A)`
  align-items: center;
  gap: ${L.YC};
`,f=(0,E.memo)(()=>{const{newMac:e,setNewMac:t,error:a,resetError:n}=(0,E.useContext)(b),l=(0,E.useCallback)(({target:{value:e}})=>{t((0,D.Z)(e)),n()},[t,n]);return E.createElement(v.A,{className:y,value:e,onChange:l,onFocus:n,variant:"secondary",label:E.createElement(V,null,E.createElement(s.sA,{id:"COMMON_MAC_ADDRESS"}),E.createElement(R.A,{portal:!0,width:"100%",maxWidth:248,description:E.createElement(s.sA,{id:"DEVICE_REPLACEMENT_MAC_LOCATION"})},E.createElement(S.A,{isActive:!0}))),width:"100%",invalid:a})});var k=a(362412),w=a(6176);const x=(0,E.memo)(()=>{const{replacementCandidates:e,existingMac:t,setExistingMac:a,error:n,resetError:l}=(0,E.useContext)(b),r=(0,E.useMemo)(()=>e.map(({mac:e,model:t,name:a})=>({label:a,value:e,image:E.createElement(w.A,{model:t}),additionalInfo:e})),[e]),c=(0,E.useCallback)(({value:e})=>{a(String(e)),l()},[a,l]);return E.createElement(k.A.Sorted,{value:t,label:E.createElement(s.sA,{id:"COMMON_DEVICE"}),width:"100%",searchable:!0,onChange:c,onFocus:l,maxHeight:228,options:r,invalid:n})}),W=(0,g.A)(h.A)`
  flex-direction: column;
  gap: ${L.kc};
`,z=(0,E.memo)(()=>{const{replacementCandidates:e,deviceReplacementMode:t,setDeviceReplacementMode:a,resetError:n}=(0,E.useContext)(b),l=(0,E.useMemo)(()=>e.length?[{id:_.EXISTING,children:E.createElement(s.sA,{id:"COMMON_EXISTING"}),onChange:()=>{a(_.EXISTING),n()},checked:t===_.EXISTING},{id:_.NEW,children:E.createElement(s.sA,{id:"COMMON_NEW"}),onChange:()=>{a(_.NEW),n()},checked:t===_.NEW}]:[],[e.length,t,a,n]);return E.createElement(W,null,E.createElement(T.A,{direction:"row",items:l}),t===_.EXISTING?E.createElement(x,null):null,t===_.NEW?E.createElement(f,null):null)}),G=(0,g.A)(h.A)`
  align-items: center;
  gap: ${L.YC};
  width: fit-content;
`;var X=a(252093);const Y={[M.gQ.INCOMPATIBLE_REPLACEMENT]:"DEVICE_REPLACEMENT_DEVICE_INCOMPATIBLE_REPLACEMENT_ERROR",[M.gQ.REPLACEMENT_ALREADY_ASSIGNED]:"DEVICE_REPLACEMENT_DEVICE_REPLACEMENT_ALREADY_ASSIGNED_ERROR"},q=({mac:e,hideTooltip:t=!1})=>{const{formatMessage:a}=(0,s.tz)(),i=(0,n.useDispatch)(),[m,A]=(0,E.useState)(!1),[u,p]=(0,E.useState)(!1),[T,R]=(0,E.useState)(_.NEW),[v,S]=(0,E.useState)(""),[D,O]=(0,E.useState)(""),[P,y]=(0,E.useState)(void 0),g=(0,n.useSelector)((0,E.useMemo)(()=>C(e),[e])),L=(0,E.useCallback)(()=>{A(!0)},[]),h=(0,E.useCallback)(()=>{A(!1),S(""),O(""),p(!1),R(_.NEW),y(void 0)},[]),V=(0,E.useCallback)(()=>{switch(T){case _.EXISTING:return D;case _.NEW:return v;default:return}},[T,D,v]),f=(0,E.useCallback)(()=>{i((0,o.ox)({icon:c.C.success,message:"DEVICE_REPLACEMENT_DEVICE_SET",duration:3e3})),h()},[i,h]),k=(0,E.useCallback)(e=>{switch(e.apiData?.replacement_state){case M.gQ.INCOMPATIBLE_REPLACEMENT:case M.gQ.REPLACEMENT_ALREADY_ASSIGNED:y(a({id:Y[e.apiData.replacement_state]}));break;case M.gQ.CANNOT_REPLACE:default:i((0,o.ox)({icon:c.C.danger,message:"DEVICE_FAILED_TO_SET_REPLACEMENT_DEVICE",duration:3e3}))}},[i,a]),w=(0,E.useCallback)(()=>{p(!1)},[]),x=(0,E.useCallback)(()=>{p(!0),i((0,d.uC)(e,V())).then(f).catch(k).finally(w)},[i,f,k,e,V,w]),W=(0,E.useMemo)(()=>Boolean(V().match(N.b8)),[V]),q=(0,E.useMemo)(()=>[{text:E.createElement(s.sA,{id:"COMMON_ACTION_CANCEL"}),variant:"tertiary",onClick:h},{text:E.createElement(s.sA,{id:"COMMON_ACTION_APPLY"}),variant:"primary",onClick:x,disabled:!W||u,loader:u?"spinner":void 0}],[h,x,W,u]),B=(0,E.useCallback)(()=>{y(void 0)},[y]),$=(0,E.useMemo)(()=>({[I.DEVICE_REPLACEMENT_MODE]:T,[I.SET_DEVICE_REPLACEMENT_MODE]:R,[I.NEW_MAC]:v,[I.SET_NEW_MAC]:S,[I.EXISTING_MAC]:D,[I.SET_EXISTING_MAC]:O,[I.REPLACEMENT_CANDIDATES]:g,[I.ERROR]:P,[I.RESET_ERROR]:B}),[T,v,D,g,P,B]);return(0,E.useEffect)(()=>{i((0,d.lX)({queryParams:{mac:e}}))},[i,e]),E.createElement(b.Provider,{value:$},E.createElement(l.A,{allowOverflow:!0,title:E.createElement(s.sA,{id:"DEVICE_SET_REPLACEMENT_DEVICE"}),body:E.createElement(z,null),position:"top",portal:!0,actions:q,isOpen:m,onRequestClose:h},E.createElement(G,null,E.createElement(r.A,{type:"button",variant:"inline",size:"medium",onClick:L},E.createElement(s.sA,{id:"DEVICE_SET_REPLACEMENT_DEVICE"})),t?null:E.createElement(X.A,{messageId:"DEVICE_SET_REPLACEMENT_DEVICE_DESCRIPTION",variant:"outline"}))))},B=(0,E.memo)(({model:e,type:t,...a})=>(0,i.G)({type:t,model:e})?E.createElement(q,{type:t,model:e,...a}):null)},252093:(e,t,a)=>{a.d(t,{A:()=>c});var n=a(296540),E=a(271856),l=a(162420),r=a(699784);const c=({messageId:e,tooltipClassName:t,values:a,isInteractive:c,portal:i,variant:o="twoTone",size:s="medium"})=>n.createElement(E.A,{description:n.createElement(r.sA,{id:e,values:a}),width:210,isInteractive:c,portal:i,tooltipClassName:t},n.createElement(l.A,{isActive:!0,omitSvgMargin:!0,variant:o,size:s}))},264963:(e,t,a)=>{a.d(t,{X2:()=>u,lX:()=>m,uC:()=>A});var n=a(516693),E=a(691189),l=a(742920),r=a(887831);const c="/v2/api/site/{site}/device/:mac:",i=`${c}/replacement-candidates`,o=`${c}/replace?replacementDeviceMac=:replacement-mac:`,s=`${c}/replace`,m=(e={},t={})=>(0,E.Kd)("replacementCandidates",`${i.replace(":mac:",e.queryParams?.mac)}`,e.queryParams?.mac,e,{...t,idField:"mac"}),A=(e,t)=>a=>a((0,E.vB)(n.aC,null,null,r.A.POST,o.replace(":mac:",e).replace(":replacement-mac:",t),{},null,{})),u=e=>t=>t((0,E.vB)(n.aC,null,null,r.A.DELETE,s.replace(":mac:",e),{},null,{failureToast:()=>({icon:l.C.danger,message:"COMMON_UNKNOWN_ERROR"})}))},284428:(e,t,a)=>{a.d(t,{Im:()=>i,iL:()=>o,mQ:()=>r,pv:()=>l,q:()=>c});var n=a(296540),E=a(451449);function l(){return(0,n.useContext)(E.I)}function r(){return l().fields}function c(){return l().tooltipPopovers}function i(){return l().tooltipIcons}function o(){return l().labels}},362412:(e,t,a)=>{a.d(t,{A:()=>m});var n=a(469733),E=a(296540),l=a(436331),r=a(805837),c=a(282556),i=a(71265);const o=e=>E.createElement(l.A,{renderOption:r.q,...e}),s=e=>E.createElement(o,{...e});s.Sorted=e=>{const t=(0,n.useSelector)(c.zi),a=(0,E.useMemo)(()=>(0,i.k)(t),[t]);return E.createElement(o,{...e,sortBy:a})};const m=s},400242:(e,t,a)=>{a.d(t,{A:()=>c});var n=a(296540),E=a(927099),l=a(699784),r=a(360113);const c=({ip:e,lan_ip:t,wan:a=!1,lan:c=!1,compact:i=!1})=>t||e?n.createElement(r.A,{compact:i},n.createElement(E.A,{color:"secondary",size:"body"},n.createElement(l.sA,{id:a?"DEVICE_PROPERTY_OVERVIEW_WAN_IP_ADDRESS":c?"DEVICE_PROPERTY_OVERVIEW_LAN_IP_ADDRESS":"COMMON_IP_ADDRESS"})),n.createElement(E.A,{color:"tertiary",size:"body"},t||e)):null},400261:(e,t,a)=>{a.d(t,{Z:()=>E});var n=a(546391);const E=e=>e?e.replace(n.SD,"").replace(n.fA,"$&:").substring(0,17).toLowerCase():e},421130:(e,t,a)=>{a.d(t,{G:()=>c});var n=a(780811),E=a(768195);const l=[E.bq.USW,E.bq.UAP],r=[E.W4.UDBA69F],c=({type:e,model:t})=>(l.includes(e)||r.includes(t))&&!(0,n.tNJ)({model:t})},451449:(e,t,a)=>{a.d(t,{I:()=>n});const n=(0,a(296540).createContext)({fields:!1,labels:!1,tooltipPopovers:!1,tooltipIcons:!1})},766624:(e,t,a)=>{a.d(t,{A:()=>i});var n=a(296540),E=a(271856),l=a(709690),r=a(284428),c=a(566723);const i=({description:e,isInteractive:t,portal:a=!0,cursorType:i,title:o,position:s,width:m,iconProps:A,disabled:u=!1})=>{const d=(0,r.Im)()||u,C=(0,r.q)();return n.createElement(E.A,{description:e,portal:a,isInteractive:t,style:{display:"flex",alignItems:"center"},cursorType:i,title:o,position:s,width:m,disableHover:C},n.createElement(l.A,{isActive:!0,size:"original",opacity:d?c.xN:void 0,...A}))}}}]);