"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[61709],{152480:(e,t,a)=>{a.d(t,{A:()=>E});var l=a(296540),n=a(709690),i=a(457856),s=a(222588),o=a(722860),c=a(394756),r=a(325898),m=a(772776);const d=(0,o.c)(s.A),h=e=>{const{className:t,forwardedRef:a,motif:n,style:i,...s}=(0,c.b)(e),{motif:o}=(0,r.A)(n),h=(0,m.p)(e);return l.createElement("span",{className:d.concat(t)("settingsGridBadge",`settingsGridBadge-${o}`),ref:a,style:{...i,...h},...s})};var g=l.forwardRef((e,t)=>l.createElement(h,{forwardedRef:t,...e})),u=a(14463),p=a(927099),b=a(271856);const A=(0,o.c)(s.A),T=e=>{const{alignWith:t,badge:a,badgeClassName:s,children:o,className:d,disableHover:h=!1,forwardedRef:T,highlight:E=!1,highlightDelay:f,highlightNoAutoScroll:C,highlightOutlineClassName:_,highlightOutlineColor:w,highlightOutlineOffset:N,highlightType:S="none",htmlFor:v,icon:y,iconClassName:I,label:O,labelClassName:M,labelSize:R="body",labelWeight:L="normal",motif:k,style:x,textWrapperClassName:D,unlimitedWidth:G=!1,tooltip:B,tooltipWidth:W,tooltipProps:Y,...z}=(0,c.b)(e),{motif:H}=(0,r.A)(k),F=(0,m.p)(e),P=(0,l.useRef)(null),V=(0,l.useRef)(null);(0,i.iz)(!C&&E,f,P,S,T||V);const $=(0,i.gH)(E,f,S,v,T||V);return l.createElement(l.Fragment,null,("auto"===S||"outline"===S)&&l.createElement(u.A,{className:_,color:w,offset:N,ref:P,show:!!E&&("auto"===S&&!1===$||"outline"===S)}),l.createElement("div",{className:A.concat(d)("settingsGridLabelContainer",`settingsGridLabelContainer-${H}`,"spotlight"===S&&E&&"settingsGridLabelContainer-selected",!G&&"settingsGridLabelContainer-limitedWidth","withLabel"===t&&"settingsGridLabelContainer-withLabel"),style:{..."number"==typeof t&&{paddingTop:t},...x,...F}},o||l.createElement(l.Fragment,null,"function"==typeof y?l.createElement(y,{className:A.concat(I)("labelIcon",`labelIcon-${H}`)}):y,l.createElement("label",{className:A.concat(D)("label",!h&&"label-hover"),htmlFor:v,ref:T||V,...z},l.createElement(p.A,{color:"secondary",className:A.concat(M)("labelText",`labelText-${H}`,y&&"labelText-alignWithIcon","spotlight"===S&&E&&"label-spotlightHighlight","spotlight"===S&&E&&`label-spotlightHighlight-${H}`),size:R,weight:L,motif:H},O,a&&l.createElement(g,{className:s},a)))),B&&l.createElement(b.A,{...Y,description:B,className:A("labelTooltip"),width:W,motif:H,onClick:e=>e.stopPropagation(),portal:!0},l.createElement(n.A,{isActive:!0,size:"original",className:A("labelTooltipSvg"),motif:H,onClick:e=>e.preventDefault()}))))},E=l.forwardRef((e,t)=>l.createElement(T,{forwardedRef:t,...e}));E.displayName="SettingsGridLabel"},161709:(e,t,a)=>{a.r(t),a.d(t,{default:()=>x});var l=a(469733),n=a(296540),i=a(951272),s=a(742920),o=a(675359),c=a(126457),r=a(463486),m=a(780811),d=a(532419),h=a(171073),g=a(776309),u=a(927099),p=a(847883),b=a(81126),A=a(842151),T=a(71479),E=a(6510),f=a(480695),C=a(566723),_=a(252093),w=a(143811),N=a(294303),S=a(598274),v=a(699784),y=a(705426);const I=(0,T.A)(y.A)`
  width: 415px;
  .contentClassName {
    > div span {
      line-height: 24px;
    }
  }
`,O=(0,T.A)(u.A)`
  margin: ${C.Ln} 0;
`,M=(0,T.A)(N.A)`
  gap: 6px;
`,R=(0,T.A)(b.A)`
  flex: 1;
`,L=({onChange:e,onClose:t,withTest:a})=>{const{values:{batteryMac:s,targetMac:o},handleSubmit:c}=(0,i.j7)(),r=(0,l.useSelector)(d.qD),m=(0,l.useSelector)(d.ID).find(({mac:e})=>e===s),h=r.map(({name:e,model:t,mac:a})=>({value:a,label:(0,E.Q)({name:e,model:t,mac:a})}));return n.createElement(I,{allowOverflow:!0,title:n.createElement(u.A,{weight:"bold",size:"header-xs"},n.createElement(v.sA,{id:"ASSIGN_BATTERY_MODAL_TITLE"})),size:"small",contentClassName:"contentClassName",actions:[{variant:"tertiary",text:n.createElement(v.sA,{id:"COMMON_ACTION_CANCEL"}),onClick:t,type:"button"},{variant:"primary",text:n.createElement(v.sA,{id:a?"ASSIGN_AND_TEST_BATTERY_ACTION":"ASSIGN_BATTERY_ACTION"}),onClick:()=>c(),type:"button",disabled:!o}],onRequestClose:t},n.createElement(O,{size:"body"},n.createElement(v.sA,{id:"ASSIGN_BATTERY_MODAL_CONTENT"})),n.createElement(M,{alignItems:"center"},n.createElement(S.A,{device:m,labelId:"DEVICE_ACTIONS_LOCATE_BATTERY"}),n.createElement(_.A,{messageId:"DEVICE_ACTIONS_LOCATE_DEVICE_DESCRIPTION",tooltipClassName:"tooltip-position-fixer"})),n.createElement(A.A,{padding:"none"},n.createElement(p.A,null,n.createElement(f.A,{style:{flex:1},type:"input",label:n.createElement(v.sA,{id:"ASSIGN_BATTERY_ITEM",values:{id:(0,E.Q)(m)}})}),n.createElement(R,{column:!0,width:"50%"},n.createElement(w.A,{name:"targetMac",type:"dropdown",variant:"secondary",translateLabel:!0,label:"COMMON_ASSIGN_TO",options:h,onChange:e,width:"100%"})))))},k=(e,t,a,l)=>{const n=new Set([...l||[],...t.connected_battery_overrides||[]].map(({mac:e})=>e));a&&n.add(a);const i=[...n].map(e=>({mac:e}));return e((0,h.ex)({connected_battery_overrides:i},t._id,t.mac,{extend:!0})),i},x=({activeMacs:e,selectedHost:t})=>{const a=(0,l.useSelector)((0,d.nH)(e)).filter(m.OFJ),u=(0,l.useDispatch)(),p=(0,l.useSelector)(d.ID),b=(0,l.useSelector)(d.qD),A=t?[t]:b,[T,E]=(0,n.useState)({withTest:1===a.length,hostMac:void 0}),[f,C]=(0,n.useState)(void 0),[_,w]=(0,n.useState)(a.map(({mac:e})=>e)),N=(0,n.useCallback)(()=>{u((0,c.AS)())},[]);(0,n.useEffect)(()=>{if(!A.length)return u((0,c.AS)()),void u((0,o.ox)({icon:s.C.warning,message:"ASSIGN_BATTERY_MODAL_NO_HOSTS_WARNING"}));const e={withTest:1===a.length,hostMac:A[0].mac};a.forEach(e=>{!e.adopted&&u((0,h.Hk)(e))});const t=a.filter(e=>!(0,r.rs)(e.mac,p)).map(({mac:e})=>({mac:e}));if(t.length){const l=k(u,A[0],void 0,t);e.withTest=e.withTest&&1===l.length,1===A.length?(u((0,c.AS)()),e.withTest&&u((0,c.to)({modalType:g.A.TEST_SMART_BATTERY,modalProps:{batteryMac:a[0].mac,hostMac:e.hostMac}}))):E(e)}},[]);const S={batteryMac:_[0],targetMac:f||(0,r.rs)(_[0],p)?.mac||A[0].mac};return A.length?n.createElement(i.l1,{enableReinitialize:!0,initialValues:S,onSubmit:({batteryMac:e,targetMac:t})=>{const l=(0,r.rs)(e,p),n={withTest:T.withTest,hostMac:t};if(l?.mac!==t){l&&(0,r.jq)(e,l,u);const a=p.find(({mac:e})=>e===t),i=k(u,a,e);n.withTest=n.withTest&&1===i.length}else n.withTest=n.withTest&&1===l.connected_battery_overrides.length;E(n),C(void 0),_.shift(),0===_.length?(u((0,c.AS)()),n.withTest&&u((0,c.to)({modalType:g.A.TEST_SMART_BATTERY,modalProps:{batteryMac:a[0].mac,hostMac:n.hostMac}}))):w(_)}},n.createElement(L,{onClose:N,onChange:e=>{const t=p.find(({mac:t})=>t===e.value);E({...T,withTest:1===a.length&&0===(t.connected_battery_overrides||[]).filter(({mac:e})=>e!==_[0]).length}),C(e.value)},withTest:T.withTest})):null}},231347:(e,t,a)=>{a.d(t,{Y:()=>i});var l=a(956347),n=a(296540);function i(e){const t=(0,l.zy)(),a=(0,l.W6)(),i=(0,n.useMemo)(()=>new URLSearchParams(t.search),[t.search]),s=i.get(e),o=(0,n.useCallback)(l=>{const n=new URLSearchParams(i.toString());return l?n.set(e,l):n.delete(e),a.replace({...t,search:n.toString()})},[a,e,t,i]);return(0,n.useMemo)(()=>[s,o],[s,o])}},252093:(e,t,a)=>{a.d(t,{A:()=>o});var l=a(296540),n=a(271856),i=a(162420),s=a(699784);const o=({messageId:e,tooltipClassName:t,values:a,isInteractive:o,portal:c,variant:r="twoTone",size:m="medium"})=>l.createElement(n.A,{description:l.createElement(s.sA,{id:e,values:a}),width:210,isInteractive:o,portal:c,tooltipClassName:t},l.createElement(i.A,{isActive:!0,omitSvgMargin:!0,variant:r,size:m}))},269333:(e,t,a)=>{a.d(t,{A:()=>s});var l=a(296540),n=a(152480),i=a(353942);const s=({htmlFor:e,searchHtmlFor:t,searchIgnore:a,searchIsApplicable:s,searchTags:o,searchText:c,...r})=>{const m=(0,i.A)(),d=(0,l.useRef)(null),h=m===e||m===t;return(0,l.useEffect)(()=>{if(h&&d.current){const{y:e}=d.current.getBoundingClientRect?.()||{y:0};(e<150||e+200>window.innerHeight)&&setTimeout(()=>{d.current?.scrollIntoView?.({behavior:"smooth",block:"center"})},50)}},[h]),l.createElement(n.A,{highlight:h,highlightType:"spotlight",htmlFor:t||e,forwardedRef:d,highlightNoAutoScroll:!0,...r})}},353942:(e,t,a)=>{a.d(t,{A:()=>i});var l=a(231347),n=a(583286);const i=()=>(0,l.Y)(n.mv)[0]||null},480695:(e,t,a)=>{a.d(t,{A:()=>c});var l=a(296540),n=a(284428),i=a(566723),s=a(269333);const o=e=>{if(e)switch(e){case"picklist":case"realCheckbox":case"radio":case"input":case"dropdown":case"tabs":case"button":case"link":case"table":case"label":case"text":default:return;case"dropdownWithLabel":case"inputWithLabel":return"withLabel"}},c=({type:e,...t})=>{const a=(0,n.iL)();return l.createElement(s.A,{alignWith:o(e),style:a?{opacity:i.xN,pointerEvents:"none",userSelect:"none"}:void 0,...t})}},598274:(e,t,a)=>{a.d(t,{A:()=>g});var l=a(469733),n=a(296540),i=a(71479),s=a(699784),o=a(780811),c=a(837612),r=a(602197),m=a(171073),d=a(734707);const h=(0,i.A)(d.Ay)`
  padding: 0;
  white-space: nowrap;
`,g=({device:e,labelId:t,disabled:a})=>{const i=(0,l.useDispatch)(),d=(0,c.S9)(e),g=(0,n.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),(0,o.YdF)({type:e.type})&&Boolean(e.peer_ubb?.mac)&&i((0,m.VO)({locating:e.peer_ubb.locating,mac:e.peer_ubb.mac,name:e.peer_ubb.name,model:e.peer_ubb.model})),i((0,m.VO)({locating:e.locating,mac:e.mac,name:e.name,model:e.model}))},[i,e.type,e.mac,e.name,e.model,e.locating,e.peer_ubb?.mac,e.peer_ubb?.name,e.peer_ubb?.model,e.peer_ubb?.locating]);return n.createElement(h,{variant:"link",onClick:g,disabled:a||d!==r.g.CONNECTED},n.createElement(s.sA,{id:e.locating?"DEVICE_ACTIONS_LOCATE_STOP":t||"DEVICE_ACTIONS_LOCATE"}))}}}]);