"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[6785],{879275:(e,t,n)=>{n.d(t,{A:()=>i});var r=n(296540),a=n(691294),l=n(703447),o=n(395812);const i=({client:e})=>{switch(e.type){case a.sK.VPN:return r.createElement(o.A,{type:"vpn"});case a.sK.TELEPORT:return r.createElement(o.A,{type:"teleport"});case a.sK.WIRED:case a.sK.WIRELESS:default:return r.createElement(l.A,{client:e,alt:e.name})}}},319551:(e,t,n)=>{n.d(t,{A:()=>E,I:()=>m});var r=n(296540),a=n(259902),l=n(71479),o=n(118818),i=n(888170),c=n(691294);const s=(0,l.A)(o.A,{shouldForwardProp:e=>!["marginLeft","marginRight"].includes(e)})`
  width: 6px;
  height: 6px;
  ${({marginLeft:e})=>e&&`margin-left: ${e}px;`}
  ${({marginRight:e})=>e&&`margin-right: ${e}px;`}
`,_=(0,l.A)(a.A,{shouldForwardProp:e=>!["marginLeft","marginRight"].includes(e)})`
  width: 13px;
  height: 13px;
  color: ${i.Ay["white-6"]};
  ${({marginLeft:e})=>e&&`margin-left: ${e}px;`}
  ${({marginRight:e})=>e&&`margin-right: ${e}px;`}
`,m=(e,t,n)=>t===c.S2.ONLINE?"success":e!==c.sK.VPN&&e!==c.sK.TELEPORT&&n?"danger":"neutral",E=(0,r.memo)(({status:e,marginLeft:t=5,marginRight:n=12})=>"blocked"===e?r.createElement(_,{marginLeft:t-3,marginRight:n-3}):r.createElement(s,{variant:e,marginLeft:t,marginRight:n}))},396785:(e,t,n)=>{n.d(t,{A:()=>Pt});var r=n(296540),a=n(469733),l=n(641777),o=n(570868),i=n(959341),c=n(602021),s=n(294303),_=n(566723),m=n(48925),E=n(895424),d=n(459449),u=n(845030),p=n(398300),A=n(110456),I=n(532419),O=n(152408),R=n(897502),T=n(821580),N=n(366188),f=n(984652),S=n(934474),C=n(592510),g=n(414783),P=n(276759),M=n(743663),D=n(90086),L=n(47801),G=n(853801),y=n(711748),h=n(91589),v=n(414523),w=n(407814),F=n(215616),W=n(263963),b=n(242299),k=n(143985),U=n(737410),x=n(387521),V=n(348466),Y=n(760370),$=n(470310),H=n(306190);const B=(e,t)=>(0,h.Y)((e=>({dst_port:e.interface_port,proto:e.protocol,destination_ip:(0,H.xs)(e.interface)?void 0:e.interface_ips[e.interface],destination_ips:(0,H.xs)(e.interface)?Object.entries(e.interface_ips).map(([e,t])=>({interface:e,destination_ip:t})):void 0,pfwd_interface:e.interface,src_limiting_enabled:e.source.type!==$.I.ANY,src:e.source.type===$.I.LIMITED&&e.source.value.type===$.y.SPECIFIC?e.source.value.ip:void 0,src_firewall_group_id:e.source.type===$.I.LIMITED&&e.source.value.type===$.y.LIST?e.source.value.object_id:void 0,src_limiting_type:e.source.type!==$.I.ANY?e.source.value.type===$.y.SPECIFIC?U.sp.IP:U.sp.FIREWALL_GROUP:void 0}))(e),t),K=w.KC([w.Ik({type:w.eu($.I.ANY)}),w.Ik({type:w.eu($.I.LIMITED),value:w.KC([w.Ik({type:w.eu($.y.SPECIFIC),ip:b.q}),w.Ik({type:w.eu($.y.LIST),object_id:w.Yj({message:(0,W.rn)("SETTINGS_COMMON_LIST_REQUIRED")})})])})]),j=e=>e.includes(V.KE)||e.includes(V.jr),z=(e,t)=>(0,H.xs)(t?.pfwd_interface)?t?.destination_ips?.find(t=>t.interface===e)?.destination_ip||Y.U:t?.pfwd_interface===e&&t?.destination_ip||Y.U,X=(e,t)=>({name:e?.name||t,interface:e?(0,H.xs)(e.pfwd_interface)?U.ep.ALL:e.pfwd_interface||U.ep.ALL:U.ep.WAN,interface_ips:Object.fromEntries(Object.values(U.ep).map(t=>[t,z(t,e)])),interface_port:e?.dst_port||"",source:e?.src_limiting_enabled?e?.src_limiting_type===U.sp.FIREWALL_GROUP?{type:$.I.LIMITED,value:{type:$.y.LIST,object_id:e?.src_firewall_group_id}}:e?.src_limiting_type===U.sp.IP?{type:$.I.LIMITED,value:{type:$.y.SPECIFIC,ip:e?.src}}:{type:$.I.ANY,value:{type:$.y.SPECIFIC}}:{type:$.I.ANY,value:{type:$.y.SPECIFIC}},forward_ip:e?.fwd||"",forward_port:e?.fwd_port||"",protocol:e?.proto||U.do.TCP_UDP,logging_enabled:!!e?.log});var q=n(828647);var Q=n(349665),J=n(188738),Z=n(317672),ee=n(553432),te=n(610356),ne=n(792072),re=n(504779),ae=n(801081),le=n(339879),oe=n(519680),ie=n(594827);const ce=({form:e})=>{const{formatMessage:t}=(0,d.tz)(),n=(0,a.useSelector)((e=>(0,ae.Mz)(le.ht,t=>t.flatMap(t=>{const n=(0,oe.eC)(t.configuration.wan_networkgroup),r=t.configuration.wan_networkgroup&&(0,ie.si)(t.configuration.wan_networkgroup);return[{label:t.configuration.name,value:1===(0,ie.si)(n)?U.ep.WAN:n,additionalInfo:e({id:"COMMON_NETWORK_PURPOSE_WANX"},{number:r})}]})))(t)),l=(0,a.useSelector)(ne.S1),o=(0,a.useSelector)(N.qp),i=n.length>3,c=e.formState.defaultValues?.interface,s=(0,r.useMemo)(()=>[...n,...l&&o&&(o.enabled||o._id===c)?[{value:U.ep.WAN_MAGIC,label:t({id:"COMMON_WAN_MAGIC"}),additionalInfo:t({id:"COMMON_WAN_MAGIC"}),tooltipDescription:t({id:"SETTINGS_WAN_MAGIC_INTERFACE_DISABLED_TOOLTIP"}),disabled:!0}]:[],...n.length>=2?[{value:U.ep.ALL,label:t({id:"COMMON_ALL_WANS"}),additionalInfo:i?void 0:t({id:"COMMON_ALL_WANS"})}]:[]],[t,i,l,n,o]),_=r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_WAN_INTERFACE"});return n.length<2?null:i?r.createElement(J.A,{control:e.control,name:"interface",label:_,options:s}):r.createElement(Q.A,null,r.createElement(Z.A,{htmlFor:"interface"},_),r.createElement(ee.A,null,s.map(({additionalInfo:t,value:n,tooltipDescription:a})=>r.createElement(re.A,{reasons:a?[a]:[]},r.createElement(te.A,{key:n,control:e.control,name:"interface",value:n},t)))))};var se=n(349785),_e=n(758649),me=n(349107),Ee=n(765562),de=n(284428);const ue="1-10,11,12",pe=({form:e})=>{const{formatMessage:t}=(0,d.tz)(),n=(0,de.mQ)(),a=(0,se.FH)({control:e.control,name:"interface_port"}),l=(0,se.FH)({control:e.control,name:"forward_port"});return r.createElement(s.A,{flexDirection:"column",gap:_.YC,width:"100%"},r.createElement(E.A,{control:e.control,name:"interface_port",placeholder:t({id:"COMMON_PLACEHOLDER_EG"},{value:ue}),label:r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_WAN_PORT"}),tooltip:r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_WAN_PORT_TOOLTIP",values:{link:r.createElement(me.A,{id:"COMMON_LEARN_MORE",href:Ee.A.portForwardingGuide})}}),tooltipProps:{portal:!0,isInteractive:!0}}),r.createElement(s.A,null,r.createElement(_e.A,{type:"button",variant:"inline",size:"medium",disabled:n||!a||a===l,onClick:()=>e.setValue("forward_port",a,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})},r.createElement(d.sA,{id:"SETTINGS_INTERNET_GENERAL_ADV_GW_PORT_FORWARD_UPDATE_FORWARD_PORT"}))))};var Ae=n(631293),Ie=n(867955),Oe=n(242366);const Re=({form:e})=>{const{formatMessage:t}=(0,d.tz)(),n=(0,se.FH)({control:e.control,name:"source"});return r.createElement(Oe.A,null,r.createElement(Q.A,null,r.createElement(Z.A,{htmlFor:"source.type",tooltip:r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_LIMIT_ACCESS_TO_SOURCE_TOOLTIP",values:{link:r.createElement(me.A,{id:"COMMON_LEARN_MORE",href:Ee.A.portForwardingGuide})}}),tooltipProps:{isInteractive:!0,portal:!0}},r.createElement(d.sA,{id:"COMMON_FROM"})),r.createElement(ee.A,null,r.createElement(te.A,{control:e.control,name:"source.type",value:$.I.ANY,onCheck:()=>e.trigger("interface_port")},r.createElement(d.sA,{id:"SETTINGS_INTERNET_GENERAL_ADV_GW_PORT_FORWARD_FROM_VALUES_ANY"})),r.createElement(te.A,{control:e.control,name:"source.type",value:$.I.LIMITED,onCheck:()=>e.trigger("interface_port")},r.createElement(d.sA,{id:"SETTINGS_INTERNET_GENERAL_ADV_GW_PORT_FORWARD_FROM_VALUES_LIMITED"})))),n?.type===$.I.LIMITED?r.createElement(r.Fragment,null,r.createElement(ee.A,null,r.createElement(te.A,{control:e.control,name:"source.value.type",value:$.y.SPECIFIC,onCheck:()=>e.trigger("interface_port")},r.createElement(d.sA,{id:"COMMON_SPECIFIC"})),r.createElement(te.A,{control:e.control,name:"source.value.type",value:$.y.LIST,onCheck:()=>e.trigger("interface_port")},r.createElement(d.sA,{id:"SETTINGS_LIST"}))),n.value?.type===$.y.SPECIFIC?r.createElement(E.A,{control:e.control,name:"source.value.ip",placeholder:t({id:"SETTINGS_ROUTING_PORT_FORWARDING_LIMITED_IP_ADDRESS_PLACEHOLDER"}),onAfterChange:()=>e.trigger("interface_port")}):null,n.value?.type===$.y.LIST?r.createElement(Ae.A,{form:e,name:"source.value.object_id",types:[Ie.B.ADDRESS_GROUP]}):null):null)};var Te=n(271856),Ne=n(620637),fe=n(149133),Se=n(823084),Ce=n(363370),ge=n(784830),Pe=n(691294),Me=n(189601),De=n(239417),Le=n(855019),Ge=n(837612);const ye=(0,Me.WY)()((0,ae.Mz)(De.A8,De.fq,De.xD,(e,t,n)=>e.concat(n?.length>0?n:t||[]).reduce((e,t)=>{if(![Pe.sK.WIRED,Pe.sK.WIRELESS].includes(t.type))return e;const n=t;return n.use_fixedip?(e.push({id:`${n.fixed_ip||n.ip}-${n.mac}`,name:n.display_name||n.name,ip:n.fixed_ip||n.ip,mac:n.mac,client:{status:n.status,type:n.type,oui:n.oui,fingerprint:n.fingerprint,blocked:n.blocked,icon_filename:n?.unifi_device_info?.icon_filename,icon_resolutions:n?.unifi_device_info?.icon_resolutions}}),e):e},[])),e=>e),he=(0,Me.WY)()((0,ae.Mz)(I.ID,e=>e.filter(e=>e.config_network?.type===Le.NL.STATIC).map(e=>{const t=(0,Ge.S9)(e);return{id:`${e.config_network.ip}-${e.mac}`,name:e.name,mac:e.mac,ip:e.config_network.ip||e.ip,device:{deviceState:t,status:(0,Ge.Nf)(e),statusPulse:(0,Ge.s1)(e.deviceState),model:e.model}}})),e=>e),ve=(0,ae.Mz)(ye,he,(e,t)=>e.concat(t));var we,Fe=n(985370),We=n(892145),be=n(617147),ke=n(71479),Ue=n(582724),xe=n(413357),Ve=n(834959),Ye=n(963070),$e=n(785330),He=n(269889),Be=n(396660),Ke=n(775699),je=n(249304),ze=n(596441),Xe=n(860765),qe=n(905410),Qe=n(559478),Je=n(6176),Ze=n(602197),et=n(319551),tt=n(879275),nt=n(200826);!function(e){e.ID="id",e.NAME="name",e.IP="ip",e.MAC="mac"}(we||(we={}));const rt=[{value:10,default:!0}],at=e=>e.client?.status===Pe.S2.OFFLINE||e.device?.deviceState===Ze.g.DISCONNECTED,lt=[{id:we.NAME,sortable:!0,minWidth:260,label:r.createElement(d.sA,{id:"COMMON_NAME"}),renderCell:e=>r.createElement(s.A,{minWidth:0,width:"100%",gap:_.YC},r.createElement(s.A,{paddingLeft:_.YC,alignItems:"center"},e.client?r.createElement(et.A,{marginLeft:0,marginRight:0,status:(0,et.I)(e.client.type,e.client.status,e.client.blocked)}):r.createElement(Qe.A,{status:e.device?.status,pulsating:e.device?.statusPulse}),r.createElement(s.A,{marginLeft:_.xO,height:30,minWidth:30,maxWidth:30,justifyContent:"center",alignItems:"center"},e.device?.model?r.createElement(Je.A,{model:e.device.model}):r.createElement(tt.A,{client:e.client}))),r.createElement(s.A,{flex:1,alignItems:"center",minWidth:0},r.createElement(He.A,{enabled:!at(e),truncate:!0},e.name||r.createElement(d.sA,{id:"COMMON_FALLBACK"})))),compare:(0,Be.l0)(({name:e})=>e)},{id:we.IP,minWidth:120,sortable:!0,label:r.createElement(d.sA,{id:"COMMON_IP_ADDRESS"}),renderCell:e=>r.createElement(He.A,{enabled:!at(e)},e.ip),compare:(e,t,n,r)=>(0,$e.j5)((0,fe.GQ)(n.ip),(0,fe.GQ)(r.ip))},{id:we.MAC,minWidth:120,sortable:!0,label:r.createElement(d.sA,{id:"COMMON_MAC_ADDRESS"}),renderCell:e=>r.createElement(He.A,{enabled:!at(e)},e.mac),compare:(0,Be.l0)(({mac:e})=>e)}],ot=(0,r.memo)(({searchText:e,onItemClick:t})=>{const n=(0,a.useDispatch)(),[l,o]=(0,r.useState)(Xe.B),i=(0,a.useSelector)(ve),c=(0,r.useCallback)(({id:e},t)=>{n((0,Ke.yT)(je.l.FIXED_IPS,{sortBy:e,isAscending:t}))},[n]),{isAscending:s,sortBy:_}=(0,nt.A)(je.l.FIXED_IPS),m=(0,r.useMemo)(()=>{const t=e.toLowerCase().trim();return t?i.filter(({name:e,mac:n,ip:r})=>[e,n,r].some(e=>e?.toLowerCase?.().indexOf(t)>=0)):i},[e,i]),E=(0,r.useCallback)(({from:e,rowsPerPage:n})=>r.createElement(Ye.A,{items:m,rowLimit:n,rowOffset:e,columns:lt,onSort:c,initialSortBy:_,initiallySortAscending:s,onRowClick:t,rowHeight:ze.I.ROW_HEIGHT,disableColumnFilters:!0,truncateHeaderCells:!0}),[s,m,t,c,_]);return r.createElement(qe.A,{section:"COMMON_CLIENTS",wrapperFlexProps:{padding:"0",height:394},itemCount:m.length,tableType:je.l.FIXED_IPS,rowOptions:rt,onRenderTable:E,onPageChanged:o,pageNumber:l})}),it=(0,ke.A)(be.A)`
  width: 808px;

  height: 515px;
  & > div {
    overflow-x: hidden !important;
  }
`,ct=({setShowModal:e,onItemSelect:t})=>{const[n,a]=(0,r.useState)(""),l=(0,r.useRef)(null),o=(0,r.useCallback)((e,t)=>{a(String(t))},[]),i=(0,r.useCallback)(()=>{a("")},[]);return(0,Ue.A)([(0,xe.Zi)(Ve.B.SETTINGS)],r.createElement(it,{isOpen:!0,onRequestClose:()=>{e(!1)},onAfterOpen:()=>{l.current?.focus()},flushContent:!0,title:r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_FIXED_IPS"})},r.createElement(s.A,{flexDirection:"column",gap:_.Ln,padding:`${_.Ln} ${_.Er} 0 ${_.Er}`},r.createElement(s.A,{justifyContent:"start"},r.createElement(We.A,{ref:l,iconBefore:r.createElement(Fe.A,{size:"small"}),onChange:o,onClear:i,value:n,variant:"secondary"})),r.createElement(ot,{searchText:n,onItemClick:t}))))},st=({form:e})=>{const{formatMessage:t}=(0,d.tz)(),n=(0,de.mQ)(),l=(0,se.FH)({control:e.control,name:"forward_ip"}),o=(0,a.useSelector)(N.RR),c=(0,a.useSelector)(ne.JP),[m,u]=(0,r.useState)(!1),p=(0,a.useSelector)(ve),A=(0,r.useMemo)(()=>c&&(0,Ne.isValidIpv4)(l)&&!o.some(({ip_subnet:e})=>e&&(0,fe.xX)(e,l)),[l,c,o]);return r.createElement(Oe.A,null,r.createElement(s.A,{flexDirection:"column",gap:_.YC,width:"100%"},r.createElement(E.A,{control:e.control,name:"forward_ip",placeholder:t({id:"COMMON_IPV4_ADDRESS"}),label:r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_FORWARD_IP_ADDRESS"}),tooltip:r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_FORWARD_IP_ADDRESS_TOOLTIP"}),tooltipProps:{portal:!0}}),r.createElement(s.A,null,r.createElement(Te.A,{description:0===p.length?r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_SELECT_DEVICE_DISABLED_TOOLTIP"}):null,portal:!0,style:{width:"fit-content"}},r.createElement(_e.A,{type:"button",variant:"inline",size:"medium",disabled:n||!p.length,onClick:()=>{u(!0)}},r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_FORWARD_IP_ADDRESS_SELECT_DEVICE_BUTTON"}))))),A?r.createElement(Se.A,null,r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_FORWARD_WARNING",values:{firewallPolicyLink:r.createElement(Ce.A,{to:`${i.g_}?${ge.o5}`},r.createElement(d.sA,{id:"COMMON_FIREWALL_POLICY"})),learnMoreLink:r.createElement(me.A,{id:"COMMON_LEARN_MORE",noWrap:!0,href:Ee.A.portForwardingGuide})}})):null,m?r.createElement(ct,{setShowModal:u,onItemSelect:({ip:t})=>{e.setValue("forward_ip",t,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0}),u(!1)}}):null)},_t=({form:e})=>r.createElement(E.A,{control:e.control,name:"forward_port",placeholder:(0,d.tz)().formatMessage({id:"COMMON_PLACEHOLDER_EG"},{value:ue}),label:r.createElement(d.sA,{id:"COMMON_FORWARD_PORT"}),tooltip:r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_FORWARD_PORT_TOOLTIP"}),tooltipProps:{portal:!0}}),mt=[U.do.TCP_UDP,U.do.TCP,U.do.UDP],Et={[U.do.TCP_UDP]:"COMMON_TCP_AND_UDP",[U.do.TCP]:"COMMON_TCP",[U.do.UDP]:"COMMON_UDP"},dt=({form:e})=>r.createElement(Q.A,null,r.createElement(Z.A,{htmlFor:"protocol"},r.createElement(d.sA,{id:"COMMON_PROTOCOL"})),r.createElement(ee.A,null,mt.map(t=>r.createElement(te.A,{key:t,control:e.control,name:"protocol",value:t},r.createElement(d.sA,{id:Et[t]})))));var ut=n(311785),pt=n(438628),At=n(177651),It=n(547868),Ot=n(128736),Rt=n(546391),Tt=n(517940),Nt=n(592563);const ft=({label:e,network:t,form:n})=>{const{formatMessage:l}=(0,d.tz)(),o=(0,a.useDispatch)(),i=(0,a.useSelector)(At.E),c=(0,a.useSelector)(le.uM),m=(0,se.FH)({control:n.control,name:"interface_port"}),E=(0,se.FH)({control:n.control,name:`interface_ips.${(0,H.RJ)(t.wan_networkgroup)}`}),A=c.find(e=>e._id===t._id),I=E===Y.U?A?.ip:E||A?.ip,O=i.some(e=>e.interface===(0,It.d)(t.wan_networkgroup)),R=((e,t,n,a,l,o)=>{if(!e)return null;const i=r.createElement(d.sA,{id:"COMMON_NETWORK_PURPOSE_WANX",values:{number:(0,ie.si)(a)}});return(0,fe.J6)(e)?r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_INTERFACE_IPS_CGNAT_WARNING",values:{name:i,link:r.createElement(me.A,{href:Ee.A.portForwardingGuide,id:"COMMON_LEARN_MORE",noWrap:!0}),multiplePorts:l}}):(0,fe.C0)(e)?r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_INTERFACE_PRIVATE_IP_WARNING",values:{name:i,link:r.createElement(me.A,{href:Ee.A.portForwardingGuide,id:"COMMON_LEARN_MORE",noWrap:!0}),multiplePorts:l}}):!n&&[Tt.mR.DHCP,Tt.mR.PPPOE,Tt.mR.DS_LITE].includes(t)?r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_INTERFACE_IPS_DHCP_PPPOE_WARNING",values:{name:i,link:r.createElement(me.A,{href:Ee.A.vpnDynamicDnsConfigGuide,id:"COMMON_LEARN_MORE",noWrap:!0}),dynamicDnsLink:r.createElement(Nt.A,{onClick:o},r.createElement(d.sA,{id:"COMMON_DYNAMIC_DNS"})),multiplePorts:l}}):null})(I,t.wan_type||Tt.mR.STATIC,O,t.wan_networkgroup,m?.includes(V.KE)||m?.includes(V.jr),()=>o((0,u.XP)({type:p.H.WAN,id:t._id}))),T=r.createElement(s.A,{gap:_.YC},r.createElement(Z.A,{htmlFor:"interface_ip",tooltip:r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_WAN_IP_TOOLTIP"})},e??r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_WAN_X_IP",values:{name:(0,ie.qY)(t.wan_networkgroup,l)}})),R?r.createElement(Te.A,{description:R,portal:!0,isInteractive:!0,style:{display:"flex",alignItems:"center"}},r.createElement(Ot.A,{variant:"fill",size:"medium"})):null),N=(e=>[Tt.mR.STATIC,Tt.mR.PPPOE].includes(e.wan_type)?(e.wan_ip_aliases||[]).map(e=>e?.replace(Rt.M9,"")).filter(Boolean):[])(t);if(N.length){const e=[{label:l({id:"SETTINGS_NETWORKS_FORM_FIELDS_INTERNET_SOURCE_IP_VALUE_MAIN"}),value:Y.U,additionalInfo:t?.wan_ip||void 0},...N.map(e=>({label:`${e}`,value:e}))];return r.createElement(J.A,{control:n.control,name:`interface_ips.${(0,H.RJ)(t.wan_networkgroup)}`,options:e,key:t._id,label:T})}const f=A?.ip||(t.wan_type===Tt.mR.STATIC?t.wan_ip:I)||l({id:t.wan_type===Tt.mR.DHCP?"COMMON_DHCP":"COMMON_IPV4_CONNECTION_TYPE_PPPOE"});return r.createElement(Q.A,null,T,r.createElement(pt.A,{type:"text",value:f,disabled:!0,variant:"secondary",width:"100%",style:{marginTop:2}}))},St=(0,ke.A)("div",(0,ut.A)("numColumns"))`
  display: grid;
  grid-template-columns: repeat(${({numColumns:e})=>e}, 1fr);
  gap: ${_.kc};
`,Ct=({form:e})=>{const t=(0,se.FH)({control:e.control,name:"interface"}),n=(0,a.useSelector)(N.Ct),l=(0,r.useMemo)(()=>n.filter(e=>(0,H.EG)(e,t)),[n,t]);return l.length?r.createElement(St,{numColumns:Math.min(2,l.length)},l.map(t=>r.createElement(ft,{key:t._id,network:t,form:e,label:1===l.length?r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_WAN_IP"}):null}))):null};var gt=n(624461);const Pt=({activeItem:e,typeSelector:t})=>{const{sharedName:n,setSharedName:b}=(0,gt.H5)(),V=e?._id?.startsWith(i.R6)?void 0:e,z=(0,a.useDispatch)(),Q=(0,a.useSelector)(N.Ct),J=(0,a.useSelector)(c.EL),Z=(0,a.useSelector)(I.Lt),ee=(0,a.useSelector)(I.jY),te=(0,a.useSelector)(D._),ne=(0,a.useSelector)(I.fq),re=(0,a.useSelector)(y.O9),ae=(0,r.useMemo)(()=>V?._id?(0,L.Tg)(te,{type:M.y.PORT_FORWARDING,id:V._id}):te,[V?._id,te]),le=(0,r.useMemo)(()=>{const e=(V?(0,h.Y)(V,ne):[]).find(e=>(0,L.GP)(ae,e,re));return e?(0,L.GP)(ae,e,re):null},[ae,V,re,ne]),oe=(0,r.useMemo)(()=>((e,t,n)=>w.Ik({name:w.Yj({message:(0,W.rn)("COMMON_VALIDATION_NAME_REQUIRED")}).min(1,{message:(0,W.rn)("COMMON_VALIDATION_NAME_REQUIRED")}).max(64),interface_port:x.C,source:K,forward_ip:k.B,forward_port:x.C,protocol:w.fc(U.do),logging_enabled:w.zM().optional().transform(e=>e??!1),interface:w.fc(U.ep).optional().transform(e=>e||U.ep.ALL),interface_ips:w.g1(w.fc(U.ep),w.KC([k.B,w.eu(Y.U)]).optional())}).refine(e=>!(j(e.forward_port)||j(e.interface_port))||e.forward_port.trim()===e.interface_port.trim(),{path:["forward_port"],message:(0,W.rn)("SETTINGS_INTERNET_GENERAL_ADV_GW_PORT_FORWARD_VALIDATION_INCORRECT_MULTIPORT_FWD_PORT")}).superRefine((r,a)=>{const l=B(r,t).flatMap(t=>{const r=(0,L.GP)(e,t,n);return r?{ownPort:t,conflict:r}:[]})[0];if(l){const e=(0,L.gG)(l.conflict.range),t=(0,L.gG)(l.ownPort.range);a.addIssue({code:F.eq.custom,message:(0,W.rn)(e===t?"SETTINGS_PORT_CONFLICT_VALIDATION_SAME_PORT":"SETTINGS_PORT_CONFLICT_VALIDATION",{otherPorts:e,otherName:l.conflict.usedBy.name,ownPorts:t}),path:["interface_port"]})}}))(ae,ne,re),[ae,re,ne]),ie=(0,o.m)({schema:oe,defaultValues:X(V,n)});(0,G.y)(ie);const se=ie.handleSubmit(e=>z((0,A.oU)(((e,t,n)=>({enabled:!0,...e,name:t.name,pfwd_interface:t.interface,destination_ip:(0,H.xs)(t.interface)?void 0:t.interface_ips[t.interface||U.ep.WAN]||Y.U,destination_ips:(0,H.xs)(t.interface)?n.flatMap(e=>{const n=(0,q.qV)(e.wan_networkgroup);return(0,H._4)(e)&&e.wan_networkgroup&&n?[{interface:n,destination_ip:t.interface_ips[n]||Y.U}]:[]}):[],dst_port:t.interface_port,fwd:t.forward_ip,fwd_port:t.forward_port,proto:t.protocol,src:t.source.type===$.I.LIMITED&&t.source.value.type===$.y.SPECIFIC?t.source.value.ip:void 0,src_firewall_group_id:t.source.type===$.I.LIMITED&&t.source.value.type===$.y.LIST?t.source.value.object_id:void 0,src_limiting_enabled:t.source.type!==$.I.ANY,src_limiting_type:t.source.type===$.I.LIMITED&&t.source.value.type===$.y.LIST?U.sp.FIREWALL_GROUP:t.source.type===$.I.LIMITED&&t.source.value.type===$.y.SPECIFIC?U.sp.IP:void 0,log:t.logging_enabled}))(V,e,Q))).then(async e=>(await z((0,A.Go)(void 0,{resolveWithExisting:!1})),z((0,g.fn)(void 0,{resolveWithExisting:!1})),e)).then(e=>{z((0,u.SQ)(!1)),z((0,u.XP)({type:p.H.PORT_FORWARDING_POLICY,id:e?._id??e?.data?.[0]?._id}))}).then(()=>ie.reset()));(0,r.useEffect)(()=>{z((0,f.Ic)(void 0,{crudCacheStrategy:{type:C.e.CACHE}})),z((0,f.$3)(void 0,{crudCacheStrategy:{type:C.e.CACHE}})),z((0,S.$O)(void 0,{crudCacheStrategy:{type:C.e.CACHE}}))},[z]);const _e=`port-forward-form-${V?._id||"new"}`;return r.createElement("form",{onSubmit:se,id:_e},r.createElement(l.A,{isDisabled:J},r.createElement(s.A,{gap:_.Ln,flexDirection:"column",width:"100%"},r.createElement(m.A,null,t,Z?r.createElement(O.A,{feature:"COMMON_PORT_FORWARDING"}):null,r.createElement(E.A,{control:ie.control,name:"name",label:r.createElement(d.sA,{id:"COMMON_NAME"}),onChange:(e,t)=>{t.onChange(e),b(e.target.value)}})),r.createElement(m.A,null,ee?r.createElement(ce,{form:ie}):null,ee?r.createElement(Ct,{form:ie}):null,r.createElement(pe,{form:ie}),r.createElement(Re,{form:ie}),r.createElement(st,{form:ie}),r.createElement(_t,{form:ie}),r.createElement(dt,{form:ie})),r.createElement(m.A,null,r.createElement(T.A,null,r.createElement(R.A,{control:ie.control,name:"logging_enabled",tooltip:r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_SYSLOG_LOGGING_TOOLTIP"})},r.createElement(d.sA,{id:"COMMON_SYSLOG_LOGGING"})))),V?r.createElement(P.A,{enabled:V.enabled,name:V.name,onPause:async()=>{await z((0,A.oU)({...V,enabled:!1})),await z((0,A.Go)())},onResume:async()=>{await z((0,A.oU)({...V,enabled:!0})),await z((0,A.Go)())},resumeDisabledReason:le?r.createElement(d.sA,{id:"SETTINGS_ROUTING_PORT_FORWARDING_RESUME_DISABLED_TOOLTIP",values:{name:le?.usedBy.name}}):void 0,onRemove:()=>z((0,A.Bc)(V))}):null),r.createElement(v.A,{onFormCancel:()=>ie.reset(),isDirty:ie.formState.isDirty||!V,hideCancelButton:!ie.formState.isDirty,submitButtonText:V?void 0:"COMMON_ACTION_ADD",form:_e,isSubmitting:ie.formState.isSubmitting})))}}}]);