"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[5835],{620627(e,t,n){n.d(t,{A:()=>m});var i=n(274934),r=n(938984),o=n(247816),s=n(309130),a=n(100978),c=n(535322);const l=(0,o.A)("div")`
  margin-right: ${s.kc};
`,d=(0,o.A)("div")`
  margin-left: ${s.kc};
`,m=({icon:e,closeIcon:t,nested:n,children:o,...s})=>(0,i.jsx)(c.A,{nested:n,...s,children:(0,i.jsxs)(a.A,{children:[(0,i.jsx)(l,{children:e}),(0,i.jsx)(r.A,{size:"medium",children:o}),t?(0,i.jsx)(d,{children:t}):null]})})},535322(e,t,n){n.d(t,{A:()=>A,I:()=>i});var i,r=n(274934),o=n(814557),s=n(158885),a=n(247816),c=n(565527),l=n(309130),d=n(100978),m=n(291508);!function(e){e.ACCORDION="accordion",e.BUTTON_LIST="buttonList"}(i||(i={}));const u=(0,a.A)(d.A,(0,m.A)("marginBottom","isButtonList","margin","flex","width","padding","nested","background"))`
  background-color: ${({background:e,nested:t,theme:{themeName:n}})=>e||o.Ay[n===c.S.DARK?`desktop-color-neutral-${t?"00":"01"}-${c.S.DARK}`:`desktop-color-neutral-${t?"01":"00"}-${c.S.LIGHT}`]};
  padding: ${({isButtonList:e,padding:t})=>t||(e?`0 ${l.Ln}`:l.Ln)};
  margin-bottom: ${({marginBottom:e})=>e||l.Ln};
  ${({margin:e})=>e?`margin: ${e};`:""}
  border-radius: 8px;
  flex-direction: column;
  width: ${({width:e="100%"})=>e};
  flex: ${({flex:e=0})=>e};
  > :last-child {
    margin-bottom: 0;
  }
  thead {
    tr {
      height: 32px !important;
    }
    th {
      text-transform: none;
    }
  }
  ${({isButtonList:e})=>e?`\n    > div {\n      display: flex;\n      height: 48px;\n      border-bottom: ${({theme:{themeName:e}})=>o.Ay[`desktop-border-divider-${e}`]};\n      &:last-child {\n        border-bottom: none;\n      }\n    }\n  `:""}
`,_=(0,a.A)(s.A,(0,m.A)("marginBottom","margin","flex","padding","nested","background"))`
  background-color: ${({background:e,nested:t,theme:{themeName:n}})=>e||o.Ay[n===c.S.DARK?`desktop-color-neutral-${t?"00":"01"}-${c.S.DARK}`:`desktop-color-neutral-${t?"01":"00"}-${c.S.LIGHT}`]};
  margin-bottom: ${({theme:e,marginBottom:t})=>t||e.spacing["spacing-l"]};
  ${({margin:e})=>e?`margin: ${e};`:""}
  ${({padding:e})=>e?`padding: ${e};`:""}
  border-radius: 8px;
  flex-direction: column;
  flex: ${({flex:e=0})=>e};
  > :last-child {
    margin-bottom: 0;
  }
  thead {
    tr {
      height: 32px !important;
    }
    th {
      text-transform: none;
    }
  }
  > li {
    > div:first-child {
      background: ${({background:e,theme:{themeName:t}})=>e||o.Ay[t===c.S.DARK?`desktop-color-neutral-01-${c.S.DARK}`:`desktop-color-neutral-00-${c.S.LIGHT}`]};
      height: 48px;
      padding: 0 ${l.Ln};
    }
    > div:nth-child(2) {
      margin-bottom: 0;
      padding: 0;
      > div {
        padding: 0 ${l.Ln} ${l.Ln};
      }
    }
  }
`,A=({type:e,marginBottom:t,margin:n,padding:o,flex:s,width:a,nested:c,...l})=>"items"in l?(0,r.jsx)(_,{marginBottom:t,margin:n,padding:o,flex:s,nested:c,...l}):(0,r.jsx)(u,{nested:c,width:a,marginBottom:t,margin:n,padding:o,flex:s,isButtonList:e===i.BUTTON_LIST,...l,children:l.children})},89469(e,t,n){n.d(t,{A:()=>a});var i=n(274934),r=n(602086),o=n(309130),s=n(100978);const a=(0,r.forwardRef)((e,t)=>(0,i.jsx)(s.A,{ref:t,flexDirection:"column",gap:o.kc,width:"100%",...e}))},756782(e,t,n){n.d(t,{A:()=>O});var i=n(274934),r=n(814557),o=n(602086),s=n(938984),a=n(247816),c=n(309130),l=n(590979),d=n(147045),m=n(291508),u=n(304151),_=n(100978),A=n(535322),h=n(89469);const g=(0,a.A)(A.A,(0,m.A)("isOutlined"))`
  border: ${({theme:{themeName:e},isOutlined:t})=>`1px solid ${t?r.Ay[`desktop-color-ublue-06-${e}`]:"transparent"}`};
`,O=({children:e,title:t,tooltip:n,tooltipProps:r,[d.L]:a,titleAction:m,isOutlined:A})=>{const O=(e=>o.Children.toArray(e).length>0)(e);return(0,i.jsx)(g,{marginBottom:"none",...l.A.addDataTestId(a??""),isOutlined:A,children:(0,i.jsxs)(_.A,{flexDirection:"column",...O&&{gap:c.Ln},width:"100%",children:[t?(0,i.jsxs)(_.A,{alignItems:"center",gap:c.YC,justifyContent:"space-between",width:"100%",children:[(0,i.jsxs)(_.A,{gap:c.YC,alignItems:"center",children:[(0,i.jsx)(s.A,{variant:"heading-medium",children:t}),n?(0,i.jsx)(u.A,{description:n,portal:!0,...r}):null]}),m?(0,i.jsx)(_.A,{children:m}):null]}):null,O?(0,i.jsx)(h.A,{children:e}):null]})})}},594492(e,t,n){n.d(t,{A:()=>m});var i=n(274934),r=n(602086),o=n(599110),s=n(247816),a=n(309130),c=n(470070),l=n(291508);const d=(0,s.A)("footer",(0,l.A)("hasFormResetButton"))`
  display: flex;
  justify-content: ${({hasFormResetButton:e})=>e?"space-between":"flex-end"};
  padding: ${a.S2} ${a.fS};
  gap: ${a.kc};
`,m=({allowCancel:e,isDirty:t,isInvalid:n,isSubmitting:s,onFormSubmit:a,onFormReset:l,onFormCancel:m,className:u,submitButtonText:_,customButton:A,applyButton:h,applyButtonFirst:g,hideCancelButton:O,form:C})=>{const I=(0,r.useMemo)(()=>h||(0,i.jsx)(o.A,{name:"submit",variant:"primary",type:"submit",onClick:a,disabled:!t||n||s,form:C,children:(0,i.jsx)(c.sA,{id:_||"COMMON_ACTION_APPLY_CHANGES"})}),[h,C,t,n,s,a,_]);return(0,i.jsxs)(d,{className:u,hasFormResetButton:!!l,children:[g?I:A,O?null:(0,i.jsx)(o.A,{name:"cancel",variant:"default",type:"button",onClick:m,disabled:!e&&!t,children:(0,i.jsx)(c.sA,{id:"COMMON_ACTION_CANCEL"})}),l?(0,i.jsx)(o.A,{name:"reset",variant:"default",type:"button",onClick:l,disabled:!t,children:(0,i.jsx)(c.sA,{id:"COMMON_ACTION_RESET_TO_DEFAULT"})}):null,g?A:I]})}},115114(e,t,n){n.d(t,{A:()=>d});var i=n(274934),r=n(232932),o=n(247816),s=n(409844),a=n(594492);const c=(0,o.A)("div")`
  height: 66px;
`,l=s.AH`
  padding: 0px !important;
`,d=({isDirty:e,onFormSubmit:t,onFormCancel:n,isInvalid:o,...s})=>e?(0,i.jsx)(r.A,{children:(0,i.jsx)(a.A,{isDirty:e,onFormCancel:n,onFormSubmit:t,isInvalid:o,className:l,...s})}):(0,i.jsx)(c,{})},205835(e,t,n){n.r(t),n.d(t,{default:()=>z});var i,r=n(274934),o=n(977872),s=n(602086),a=n(42220),c=n(241792),l=n(853777),d=n(159469),m=n(436417),u=n(309130),_=n(620627),A=n(756782),h=n(100978),g=n(205521),O=n(700444),C=n(470070),I=n(352210),p=n(192967),x=n(795206),N=n(115114),E=n(409844),R=n(247816),f=n(938984),D=n(814557),b=n(421314),M=n(656705);!function(e){e.PORT="port",e.NAME="name",e.CONNECTED_DEVICE="connectedDevice"}(i||(i={}));const j={[i.PORT]:"COMMON_PORT",[i.NAME]:"COMMON_NAME",[i.CONNECTED_DEVICE]:"COMMON_CONNECTED_DEVICE"};var v=n(347625),S=n(974390),w=n(650632),k=n(831433);const T=20,L=({connectedClient:e,connectedUnifiDevice:t})=>t?(0,r.jsxs)(h.A,{alignItems:"center",gap:u.kc,children:[(0,r.jsx)(S.A,{model:t.model,width:T,height:T}),(0,r.jsx)(b.A,{size:"medium",color:"text-2",children:(0,v.Q)(t)})]}):e?(0,r.jsxs)(h.A,{alignItems:"center",gap:u.kc,children:[(0,r.jsx)(h.A,{width:T,height:T,minWidth:T,maxWidth:T,justifyContent:"center",alignItems:"center",children:(0,r.jsx)(w.A,{client:e})}),(0,r.jsx)(b.A,{size:"medium",color:"text-2",children:(0,k.tn)(e)})]}):null,B=E.AH`
  background: transparent !important;
`,P=({header:{id:e}})=>(0,r.jsx)(b.A,{children:(0,r.jsx)(C.sA,{id:j[e]})}),$=R.A.div`
  flex: 0 0 ${20}px;
  width: ${20}px;
  height: ${20}px;
  border-radius: 2px;
  background: ${({isUp:e,theme:{themeName:t}})=>e?D.Ay[`desktop-color-green-06-${t}`]:D.Ay[`desktop-color-neutral-03-${t}`]};
`,W=[{id:i.PORT,accessorFn:e=>e,size:50,enableResizing:!1,enableSorting:!1,header:P,cell:({row:{original:e}})=>(0,r.jsxs)(h.A,{alignItems:"center",gap:u.kc,children:[(0,r.jsx)($,{isUp:e.up}),(0,r.jsx)(f.A,{size:"medium",color:"text-2",children:e.port_idx})]})},{id:i.NAME,accessorFn:e=>e,size:77,enableResizing:!1,enableSorting:!1,header:P,cell:({row:{original:e}})=>(0,r.jsx)(b.A,{size:"medium",color:"text-2",children:e.name})},{id:i.CONNECTED_DEVICE,accessorFn:e=>e,enableResizing:!1,enableSorting:!1,header:P,cell:({row:{original:e}})=>(0,r.jsx)(L,{connectedClient:e.connectedClient,connectedUnifiDevice:e.connectedUnifiDevice})}],y=e=>String(e.port_idx),U=({deviceMac:e,rows:t,selectedPortIdxs:n,onChangeSelectedPortIdxs:i})=>{const o=(0,s.useMemo)(()=>n.map(String),[n]),a=(0,s.useCallback)(t=>{i(e,t.map(e=>Number(e)).filter(e=>Number.isFinite(e)))},[e,i]);return t.length?(0,r.jsx)(M.A,{data:t,columns:W,getRowId:y,multiSelectMode:!0,selection:o,onChangeSelection:a,selectAllBehavior:"noOverride",rowSelectedClassName:B}):null},F=({device:e})=>(0,r.jsxs)(h.A,{alignItems:"center",gap:u.YC,children:[(0,r.jsx)(h.A,{flexShorthand:"0 0 22px",width:22,height:22,children:(0,r.jsx)(S.A,{model:e.model,width:22,height:22})}),(0,r.jsx)(f.A,{variant:"heading-small",isTruncated:!0,children:(0,v.Q)(e)})]});var Y=n(163360);const K=e=>{const t=new Map;e.wiredClients.forEach(e=>{t.has(e.sw_port)||t.set(e.sw_port,e)});const n=new Map;return e.wiredUnifiDevices.forEach(e=>{n.has(e.mac)||n.set(e.mac,e)}),(e.port_table||[]).flatMap(e=>{if(!(0,Y.vm)(e))return[];const i=e.port_idx?t.get(e.port_idx):void 0,r=e.last_connection?.mac?n.get(e.last_connection.mac):void 0;return i||r?[{...e,connectedClient:i,connectedUnifiDevice:r}]:[]})},X="selectedPortIdxsByMac",G=c.Ik({[X]:c.g1(c.Yj(),c.YO(c.ai()))}),V={},z=()=>{const e=(0,o.wA)(),t=(0,o.d4)(p.qy),n=(0,s.useMemo)(()=>Object.fromEntries(t.map(e=>[e.mac,K(e)])),[t]),i=(0,s.useMemo)(()=>({[X]:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t.map(e=>e.port_idx)]))}),[n]),c=(0,m.m)({schema:G,defaultValues:i}),E=(0,a.FH)({control:c.control,name:X})??V,R=(0,s.useCallback)((e,t)=>{const n=c.getValues(X)??{};c.setValue(X,{...n,[e]:t},{shouldDirty:!0})},[c]),f=(0,s.useMemo)(()=>Object.values(E).some(e=>e.length>0),[E]),D=c.handleSubmit(({[X]:t})=>{const n=Object.entries(t).filter(([,e])=>e.length>0).map(([e,t])=>({mac:e,port_idxs:t}));n.length?e((0,x.Qr)({devices:n})).then(()=>{e((0,x.Uc)()),e((0,g.K5)())}).catch(t=>{e((0,O.ox)({icon:d.C.danger,message:I.API_STRING_TRANSLATION[t?.apiMsg]||"COMMON_NOTICE_REQUEST_ERROR"}))}):e((0,g.K5)())});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(h.A,{width:"100%",gap:u.xO,flexDirection:"column",children:[(0,r.jsx)(_.A,{padding:u.kc,icon:(0,r.jsx)(l.A,{size:"original",variant:"fill",isActive:!0}),marginBottom:"0",children:(0,r.jsx)(C.sA,{id:"COMMON_REVIEW_PORTS_DESCRIPTION"})}),(0,r.jsx)(h.A,{flexDirection:"column",gap:u.kc,children:t.map(e=>(0,r.jsx)(A.A,{children:(0,r.jsxs)(h.A,{flexDirection:"column",gap:u.kc,children:[(0,r.jsx)(F,{device:e}),(0,r.jsx)(U,{deviceMac:e.mac,rows:n[e.mac]??[],selectedPortIdxs:E[e.mac]||[],onChangeSelectedPortIdxs:R})]})},e.mac))})]}),(0,r.jsx)(N.A,{onFormCancel:()=>{e((0,g.K5)())},onFormSubmit:D,isDirty:!0,hideCancelButton:!1,isInvalid:!f,isSubmitting:c.formState.isSubmitting,submitButtonText:"COMMON_DEVICE_SET_EDGE",form:"edge-port-review"})]})}},521376(e,t,n){var i;n.d(t,{U:()=>i}),function(e){e.ARROW_LEFT="ArrowLeft",e.ARROW_RIGHT="ArrowRight",e.ARROW_DOWN="ArrowDown",e.ARROW_UP="ArrowUp",e.ENTER="Enter",e.ESCAPE="Escape",e.BACKSPACE="Backspace",e.DELETE="Delete",e.TAB="Tab"}(i||(i={}))},436417(e,t,n){n.d(t,{m:()=>a});var i=n(602086),r=n(42220),o=n(369289),s=n(721533);function a({schema:e,defaultValues:t,presets:n}){const a=(0,i.useMemo)(()=>n?(0,o.A)(n,e=>e.defaultValues):{},[n]),c=(0,i.useMemo)(()=>({...t,...a}),[a,t]),l=(0,r.mN)({resolver:(0,s.u)(e),shouldFocusError:!0,defaultValues:c,shouldUseNativeValidation:!1,mode:"onTouched"}),d=(0,i.useRef)(c);d.current=c;const m=(0,i.useCallback)((...e)=>{const[t,...n]=e;return l.reset(t?{...t,...a}:d.current,...n)},[a,l]);return{...l,reset:m,formState:{...l.formState,isDirty:!!Object.keys(l.formState.dirtyFields).length,isSubmitting:l.formState.isSubmitting},handleSubmit:(...e)=>l.handleSubmit(e[0],(t,...n)=>{const i=Object.keys(t)[0];if(i)try{const e=document.getElementsByName(i)?.[0];e?.scrollIntoView?.({behavior:"smooth",block:"center"}),e?.focus?.({preventScroll:!0})}catch{}e[1]?.(t,...n)})}}},656705(e,t,n){n.d(t,{A:()=>O});var i,r,o,s,a,c=n(274934),l=n(602086);!function(e){e.TABLE="table"}(i||(i={})),function(e){e.ROW_ID_MAP_BY_INDEX="rowIdMapByIndex",e.INDEX_MAP_BY_ROW_ID="indexMapByRowId"}(r||(r={})),function(e){e.ON_KEY_DOWN="onKeyDown",e.INCOMING_ROW_PROPS="incomingRowProps",e.HAS_ON_ROW_CLICK="hasOnRowClick"}(o||(o={})),function(e){e.INCOMING_ON_ROW_CLICK="incomingOnRowClick",e.LOCAL_CURRENT_INDEX="localCurrentIndex"}(s||(s={})),function(e){e.DATA_MAP_REFERENCE="dataMapReference",e.ROW_ID_MAP_BY_INDEX="rowIdMapByIndex",e.INDEX_MAP_BY_ROW_ID="indexMapByRowId",e.INCOMING_ON_ROW_CLICK="incomingOnRowClick",e.LOCAL_CURRENT_INDEX="localCurrentIndex",e.MULTI_SELECT_MODE="multiSelectMode"}(a||(a={}));const d="data-row-id";var m=n(202730),u=n(147045);var _=n(521376);const A=e=>e?.children?.[1]?.children;var h=n(587389);const g=(0,n(247816).A)(h.A)`
  tr {
    outline: none;
  }
`,O=({data:e=[],rowProps:t,onRowClick:n,...h})=>{const O=(0,l.useRef)(null),C=(0,l.useRef)(null),{[r.ROW_ID_MAP_BY_INDEX]:I,[r.INDEX_MAP_BY_ROW_ID]:p}=(({[i.TABLE]:e})=>{const[t,n]=(0,l.useState)(()=>e?A(e):void 0);(0,l.useEffect)(()=>{e&&n(A(e))},[e]);const{[r.ROW_ID_MAP_BY_INDEX]:o,[r.INDEX_MAP_BY_ROW_ID]:s}=(0,l.useMemo)(()=>{const e=new Map,n=new Map,i=t?.length;if(t&&i)for(let r=0;r<i;r+=1){const i=t[r].getAttribute(d);i&&(e.set(i,r),n.set(r,i))}return{[r.ROW_ID_MAP_BY_INDEX]:e,[r.INDEX_MAP_BY_ROW_ID]:n}},[t]);return{[r.ROW_ID_MAP_BY_INDEX]:o,[r.INDEX_MAP_BY_ROW_ID]:s}})({[i.TABLE]:O.current}),x=(e=>{const t=(0,l.useRef)(new Map),n=(0,l.useRef)(void 0);if(n.current!==e){n.current=e,t.current.clear();const i=e.length;for(let n=0;n<i;n+=1)t.current.set(e[n].id,e[n])}return t})(e),N=(({[a.DATA_MAP_REFERENCE]:e,[a.ROW_ID_MAP_BY_INDEX]:t,[a.INDEX_MAP_BY_ROW_ID]:n,[a.INCOMING_ON_ROW_CLICK]:i,[a.LOCAL_CURRENT_INDEX]:r,[a.MULTI_SELECT_MODE]:o})=>{const s=(0,l.useCallback)(e=>{e.preventDefault()},[]),c=(0,l.useCallback)(()=>{const t=e.current.get(n.get(r.current+1));t&&(i?.(t),r.current+=1)},[n,r,i,e]),d=(0,l.useCallback)(()=>{const t=e.current.get(n.get(r.current-1));t&&(i?.(t),r.current-=1)},[n,r,i,e]);return(0,l.useCallback)((e,{id:n})=>e=>{if(!o&&i){const i=t.get(n);if(Number.isFinite(i))switch(null===r.current&&(r.current=i),e.key){case _.U.ARROW_DOWN:s(e),c();break;case _.U.ARROW_UP:s(e),d()}}},[i,r,o,s,t,c,d])})({[a.DATA_MAP_REFERENCE]:x,[a.ROW_ID_MAP_BY_INDEX]:I,[a.INDEX_MAP_BY_ROW_ID]:p,[a.INCOMING_ON_ROW_CLICK]:n,[a.LOCAL_CURRENT_INDEX]:C,[a.MULTI_SELECT_MODE]:h.multiSelectMode}),E=(({[o.INCOMING_ROW_PROPS]:e,[o.ON_KEY_DOWN]:t,[o.HAS_ON_ROW_CLICK]:n})=>(0,l.useCallback)((i,r)=>({...n?{[u.L]:m.b.SIDE_PANEL_TRIGGER}:{},...e?.(i,r),[d]:i.id,tabIndex:0,onKeyDown:t(i,r)}),[e,t,n]))({[o.INCOMING_ROW_PROPS]:t,[o.ON_KEY_DOWN]:N,[o.HAS_ON_ROW_CLICK]:Boolean(n)}),R=(({[s.INCOMING_ON_ROW_CLICK]:e,[s.LOCAL_CURRENT_INDEX]:t})=>{const n=(0,l.useCallback)(n=>{t.current=null,e?.(n)},[e,t]);return e?n:void 0})({[s.INCOMING_ON_ROW_CLICK]:n,[s.LOCAL_CURRENT_INDEX]:C});return(0,c.jsx)(g,{ref:O,data:e,rowProps:E,onRowClick:R,tableHeight:e.length?"100%":void 0,virtualize:!0,virtualizeColumn:!0,overscan:6,overscanColumn:1,stickyHeader:!0,...h})}}}]);