"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[61343],{435689(e,i,s){s.d(i,{A:()=>n});var t=s(602086),l=s(141992);const n=(0,s(272338).w)(e=>(0,t.createElement)("svg",(0,l.d)({viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em"},e),(0,t.createElement)("path",{d:"M16 5H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1Z",fill:"currentColor",className:e.twotonedclassname}),(0,t.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m10.367 13.887 2.12-2.121a.5.5 0 1 0-.706-.708l-1.267 1.268V3.5a.5.5 0 0 0-1 0v8.827l-1.268-1.269a.5.5 0 0 0-.707.708l2.12 2.121a.502.502 0 0 0 .708 0ZM17 6a1 1 0 0 0-1-1h-3v1h3v10H4V6h3V5H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6Z",fill:"currentColor",className:e.baseclassname}),(0,t.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.038 3a.75.75 0 0 1 .75.75v7.683l.479-.479a.747.747 0 0 1 1.06 0 .75.75 0 0 1 0 1.061l-1.767 1.768a.737.737 0 0 1-.53.22L9.958 14a.737.737 0 0 1-.47-.217L7.72 12.015a.752.752 0 0 1-.001-1.061.751.751 0 0 1 1.062 0l.507.507V3.75a.75.75 0 0 1 .75-.75ZM17 6.004a1 1 0 0 0-1-1h-3v1.5h2.5v9h-11v-9H7v-1.5H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-10Z",fill:"currentColor",className:e.fillclassname})))},861343(e,i,s){s.r(i),s.d(i,{default:()=>Ee});var t=s(274934),l=s(602086),n=s(977872),a=s(843871),r=s(108628),d=s(807811),o=s(938984),c=s(95032),m=s(347625),A=s(950804),E=s(309130),I=s(100978),T=s(974390),_=s(470070),h=s(911917),x=s(45978),u=s(521853),C=s(570866);const N=[{id:"status",label:null,renderCell:({status:e,statusPulse:i})=>(0,t.jsx)(h.A,{status:e,pulsating:i,marginLeft:E.YC,marginRight:E.xO}),growthFactor:1,minWidth:30},{id:"name",label:(0,t.jsx)(_.sA,{id:"COMMON_NAME"}),renderCell:({name:e,model:i})=>(0,t.jsxs)(I.A,{width:"100%",children:[(0,t.jsx)(T.A,{model:i,width:"18px",height:"18px"}),(0,t.jsx)(c.A,{size:"medium",isTruncated:!0,color:"inherit",style:{marginLeft:12},children:e})]}),minWidth:60},{id:"state",label:(0,t.jsx)(_.sA,{id:"COMMON_STATUS"}),renderCell:({state:e})=>{let i="notice";return i=e===x.g.CONNECTED?"positive":e===x.g.DISCONNECTED?"text-2":"notice",(0,t.jsx)(o.A,{color:i,size:"medium",children:(0,t.jsx)(_.sA,{id:u.A[e]})})},minWidth:50},{id:"model",label:(0,t.jsx)(_.sA,{id:"COMMON_MODEL"}),renderCell:({model:e})=>(0,t.jsx)(c.A,{isTruncated:!0,color:"inherit",size:"medium",children:(0,m.Lm)(e)}),minWidth:60},{id:"fw_version",label:(0,t.jsx)(_.sA,{id:"COMMON_VERSION"}),renderCell:({fw_version:e})=>(0,t.jsx)(c.A,{isTruncated:!0,color:"inherit",size:"medium",children:e?.length>0?e:(0,t.jsx)(_.sA,{id:"COMMON_FALLBACK"})}),minWidth:60}],O=A.A.object().shape({inform_ip:A.A.string().label("COMMON_LABEL_HOSTNAME_IP").matches(C.vz,{message:(0,t.jsx)(_.sA,{id:"COMMON_VALIDATION_VALID_IP"})}).required(),inform_port:A.A.number().label("COMMON_PORT").required()});var S,j=s(247816),M=s(869332),R=s(754924);!function(e){e.EXPORT_SITE="export-site",e.MIGRATE_SITE="migrate-site",e.MIGRATE_DEVICES="migrate-devices"}(S||(S={}));const p={inform_ip:"",inform_port:8080,macs:[]};var g=s(792929),v=s(853777),f=s(61322),b=s(814557);const G=(0,j.A)(I.A)`
  width: 100%;
  padding: 14px 16px;
  background: ${({theme:{themeName:e}})=>b.Ay[`desktop-color-neutral-02-${e}`]};
  border-radius: ${b.Ay["desktop-radius-base"]};

  > svg {
    margin-right: 12px !important;
  }
`,V=({children:e})=>(0,t.jsx)(G,{children:e}),w=(0,j.A)("div")`
  margin: 32px 0 20px;
`,L=({removeTableItems:e})=>(0,t.jsxs)(I.A,{flexDirection:"column",children:[(0,t.jsx)(w,{children:(0,t.jsx)(g.A,{idField:"mac",columns:N,items:e,headerHeight:32,rowHeight:f.I.ROW_HEIGHT,disableColumnFilters:!0,truncateHeaderCells:!0})}),(0,t.jsxs)(V,{children:[(0,t.jsx)(v.A,{size:"original",isActive:!0,variant:"fill"}),(0,t.jsx)(o.A,{size:"medium",children:(0,t.jsx)(_.sA,{id:"SETTINGS_SITE_CONFIGURATION_REMOVE_MIGRATED_DEVICES",values:{b:_.b,br:_.br}})})]})]});var U=s(599110),F=s(159469),D=s(700444),P=s(393629),z=s(561500),k=s(795206),H=s(384783);const y=({handleRemoveModalClose:e,handleExportModalClose:i})=>{const{values:s}=(0,a.j7)(),r=(0,n.wA)(),d=(0,l.useCallback)(()=>{r((0,z.Yl)(s.macs)).then(()=>{s.macs.forEach(e=>{r((0,P.W)(e)),r((0,k.XL)(e))}),e(),i()}).catch(()=>{r((0,D.ox)({icon:F.C.danger,message:"API_ERROR_DEVICE_REMOVE"}))})},[r,i,e,s.macs]);return(0,t.jsx)(H.A,{title:(0,t.jsx)(_.sA,{id:"DEVICE_ACTIONS_REMOVE_LABEL_PLURAL"}),onRequestClose:e,actions:[{type:"button",text:(0,t.jsx)(_.sA,{id:"COMMON_ACTION_CANCEL"}),onClick:e},{type:"button",text:(0,t.jsx)(_.sA,{id:"COMMON_ACTION_REMOVE"}),onClick:d,variant:"danger"}],size:"small",children:(0,t.jsx)(o.A,{size:"medium",color:"text-2",children:(0,t.jsx)(_.sA,{id:"DEVICE_ACTIONS_REMOVE_CONFIRM_MESSAGE_PLURAL"})})})},$=(0,j.A)("footer")`
  padding: ${E.S2} ${E.fS};
`,W=(0,j.A)("div")`
  margin-left: ${E.Ln};
`,B=({handleCancel:e,hasMigrationStarted:i,isMigrateActionEnabled:s})=>{const{handleSubmit:n}=(0,a.j7)(),[r,d]=(0,l.useState)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)($,{children:(0,t.jsxs)(I.A,{alignItems:"center",justifyContent:"flex-end",children:[(0,t.jsx)(U.A,{type:"button",size:"medium",onClick:e,children:(0,t.jsx)(_.sA,{id:"COMMON_ACTION_SKIP"})}),(0,t.jsx)(W,{children:(0,t.jsx)(U.A,{type:"button",variant:i?"danger":"primary",onClick:i?()=>{d(!0)}:()=>{n()},disabled:!i&&!s,children:(0,t.jsx)(_.sA,{id:i?"DEVICE_ACTIONS_REMOVE_LABEL_PLURAL":"SETTINGS_SITE_CONFIGURATION_MIGRATE_DEVICES"})})})]})}),r?(0,t.jsx)(y,{handleRemoveModalClose:()=>d(!1),handleExportModalClose:e}):null]})},X=(0,j.A)("div")`
  margin-left: 16px;
`,Z=(0,j.A)("footer")`
  padding: 24px 32px;
`,Y=({handleNextStep:e,handleCancel:i})=>(0,t.jsx)(Z,{children:(0,t.jsxs)(I.A,{alignItems:"center",justifyContent:"flex-end",children:[(0,t.jsx)(U.A,{type:"button",size:"medium",onClick:i,children:(0,t.jsx)(_.sA,{id:"COMMON_ACTION_CANCEL"})}),(0,t.jsx)(X,{children:(0,t.jsx)(U.A,{type:"button",size:"medium",variant:"primary",onClick:e,children:(0,t.jsx)(_.sA,{id:"COMMON_ACTION_CONTINUE"})})})]})}),q=(0,j.A)(o.A)`
  margin: 32px 0 20px;
`,K=function(){return(0,t.jsx)(I.A,{children:(0,t.jsx)(q,{size:"medium",children:(0,t.jsx)(_.sA,{id:"SETTINGS_SITE_CONFIGURATION_MIGRATE_SITE_INSTRUCTION"})})})};var J=s(120197);const Q=(0,j.A)("div")`
  margin: ${E.fS} 0 ${E.Er};
`,ee=(0,j.A)(o.A)`
  margin: ${E.fS} 0 ${E.Er};
`,ie=(0,j.A)(o.A)`
  margin: 0 ${E.kc};
`,se=(0,j.A)("div")`
  width: 50%;
`,te=[],le=({migrateTableItems:e})=>{const{setFieldValue:i}=(0,a.j7)();return(0,t.jsxs)(I.A,{flexDirection:"column",children:[(0,t.jsx)(ee,{size:"medium",children:(0,t.jsx)(_.sA,{id:"SETTINGS_SITE_CONFIGURATION_MIGRATE_DEVICES_INSTRUCTION"})}),(0,t.jsxs)(I.A,{alignItems:"baseline",children:[(0,t.jsx)(ie,{size:"medium",color:"text-3",children:"http://"}),(0,t.jsx)(J.A,{name:"inform_ip",variant:"secondary",label:"COMMON_LABEL_HOSTNAME_IP",helperMessage:"SETTINGS_SITE_CONFIGURATION_MIGRATE_DEVICES_INPUT_HELPER",full:!0}),(0,t.jsx)(ie,{size:"medium",color:"text-3",children:":"}),(0,t.jsx)(se,{children:(0,t.jsx)(J.A,{name:"inform_port",variant:"secondary",label:"COMMON_PORT",full:!0})}),(0,t.jsx)(ie,{size:"medium",color:"text-3",children:"/inform"})]}),(0,t.jsx)(Q,{children:e.length>0?(0,t.jsx)(g.A,{idField:"mac",columns:N,items:e,initialSelectedIds:te,onChangeSelection:e=>{i("macs",e)},headerHeight:32,rowHeight:f.I.ROW_HEIGHT,multiSelectMode:!0,truncateHeaderCells:!0,disableColumnFilters:!0}):(0,t.jsxs)(V,{children:[(0,t.jsx)(v.A,{size:"original",isActive:!0,variant:"fill"}),(0,t.jsx)(o.A,{size:"medium",children:(0,t.jsx)(_.sA,{id:"SETTINGS_SITE_CONFIGURATION_MIGRATE_NO_DEVICES"})})]})})]})};var ne=s(425040),ae=s(435689),re=s(897166),de=s(759997);const oe=(0,j.A)(o.A)`
  margin: 32px 0 20px;
`,ce=()=>{const{formatMessage:e}=(0,_.tz)(),i=(0,n.wA)(),s=(0,n.d4)(re.Gd),[a,r]=(0,l.useState)(!1),d=s?.desc||"",o=(0,l.useCallback)(()=>{r(!0);const s=(0,ne.A)();i((0,D.ox)({id:s,downloads:[{id:`file-${s}`,filename:e({id:"SETTINGS_SYSTEM_MAINTENANCE_SUPPORT_INFORMATION_PREPARING"}),status:e({id:"SETTINGS_SYSTEM_MAINTENANCE_SUPPORT_INFORMATION_FETCHING"}),progress:0,onCancel:()=>{i((0,D.uU)(s)),r(!1)}}],duration:0,notificationType:"DownloadsToast"})),i((0,z.p5)()).then(({data:e})=>{i((0,de.LV)(e?.[0]?.url,s,()=>r(!1)))}).catch(()=>{r(!1),(0,D.uU)(s),i((0,D.ox)({icon:F.C.danger,message:"SETTINGS_SITE_CONFIGURATION_EXPORT_SITE_ERROR",values:{siteName:d}}))})},[d,i,e]);return(0,t.jsxs)(I.A,{flexDirection:"column",children:[(0,t.jsx)(oe,{size:"medium",children:(0,t.jsx)(_.sA,{id:"SETTINGS_SITE_CONFIGURATION_EXPORT_SITE_INSTRUCTION"})}),(0,t.jsx)(I.A,{children:(0,t.jsx)(U.A,{name:"download-current-site",type:"button",variant:"inline",size:"medium",Icon:ae.A,iconProps:{size:"original",isActive:!a},onClick:o,disabled:a,children:(0,t.jsx)(_.sA,{id:"SETTINGS_SITE_CONFIGURATION_EXPORT_SITE_DOWNLOAD_BUTTON"})})})]})},me=(0,j.A)(H.A)`
  width: 600px !important;
`,Ae=({hasMigrationStarted:e})=>{const i=(0,n.wA)(),{values:{inform_ip:s,inform_port:r,macs:d}}=(0,a.j7)(),[o,c]=(0,l.useState)(S.EXPORT_SITE),m=(0,n.d4)((0,l.useMemo)(()=>(0,R.lj)(e),[e])),A=(0,l.useMemo)(()=>m.filter(({mac:e})=>d.includes(e)),[m,d]),E=s&&r&&d.length>0,I=(0,l.useCallback)(()=>{i((0,M.AS)())},[i]),T=(0,l.useCallback)(()=>{switch(o){case S.MIGRATE_DEVICES:return{modalTitle:"SETTINGS_SITE_CONFIGURATION_MIGRATE_DEVICES",modalFooter:(0,t.jsx)(B,{handleCancel:I,hasMigrationStarted:e,isMigrateActionEnabled:E}),modalViewContent:e?(0,t.jsx)(L,{removeTableItems:A}):(0,t.jsx)(le,{migrateTableItems:m})};case S.MIGRATE_SITE:return{modalTitle:"SETTINGS_SITE_CONFIGURATION_MIGRATE_SITE",modalFooter:(0,t.jsx)(Y,{handleNextStep:()=>{c(S.MIGRATE_DEVICES)},handleCancel:I}),modalViewContent:(0,t.jsx)(K,{})};default:return{modalTitle:"SETTINGS_SITE_CONFIGURATION_EXPORT_SITE",modalFooter:(0,t.jsx)(Y,{handleNextStep:()=>{c(S.MIGRATE_SITE)},handleCancel:I}),modalViewContent:(0,t.jsx)(ce,{})}}},[I,e,E,m,o,A]),{modalTitle:h,modalFooter:x,modalViewContent:u}=T();return(0,t.jsx)(me,{title:(0,t.jsx)(_.sA,{id:h}),footer:x,size:"medium",children:u})},Ee=()=>{const e=(0,n.wA)(),[i,s]=(0,l.useState)(!1),o=(0,l.useCallback)(i=>{const t={deviceMacs:i.macs,informUrl:`${d.DU}${i.inform_ip}:${i.inform_port}/inform`};s(!0),e((0,r.du)(t)).catch(()=>{s(!1)})},[e]);return(0,t.jsx)(a.l1,{initialValues:p,onSubmit:o,validationSchema:O,children:(0,t.jsx)(Ae,{hasMigrationStarted:i})})}}}]);