"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[5793],{846485(e,t,n){var s;n.d(t,{b:()=>s}),function(e){e.MASTER="MASTER",e.BACKUP="BACKUP",e.MEMBER="MEMBER"}(s||(s={}))},640225(e,t,n){n.d(t,{J6:()=>s,_y:()=>o}),n(846485);const s=(e,t)=>e.filter(e=>{if(!e.stacking_group_id)return!0;const n=t.find(t=>t._id===e.stacking_group_id);if(!n)return!0;const s=n.units.find(e=>1===e.index);return s?.mac===e.mac}),o=(e,t,n)=>{if(!t||!n)return e;const s=n.find(e=>e._id===t);return s?.name||e}},27103(e,t,n){n.d(t,{A:()=>m});var s=n(274934),o=n(602086),i=n(599110),r=n(309130),a=n(927728),l=n(753959),c=n(100978),_=n(602097),d=n(470070);const m=({list:e,messageId:t})=>{const[n,m]=(0,o.useState)(!1),A=n?e.length:3;return(0,s.jsx)(_.A,{in:!0,children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(c.A,{flexDirection:"column",gap:r.YC,alignItems:"flex-start",children:[(0,s.jsx)(d.sA,{id:t,values:{count:e.length}}),(0,s.jsx)(a.A,{children:e.slice(0,A).map((e,t)=>(0,s.jsx)("li",{children:e},`${e} + ${t+1}`))}),e.length>3?(0,s.jsx)(i.A,{type:"button",onClick:()=>m(e=>!e),variant:"inline",children:(0,s.jsx)(d.sA,n?{id:"COMMON_SHOW_LESS"}:{id:"COMMON_SHOW_X_MORE",values:{value:e.length-3}})}):null]})})})}},901389(e,t,n){n.d(t,{A:()=>l});var s=n(274934),o=n(814557),i=n(600191),r=n(263705),a=n(612389);const l=({children:e,...t})=>{const{themeName:n}=(0,r.u)();return(0,s.jsx)(a.A,{icon:(0,s.jsx)(i.A,{variant:"fill",size:"original",color:o.Ay[`desktop-color-orange-06-${n}`]}),description:e,...t})}},602097(e,t,n){n.d(t,{A:()=>c});var s=n(274934),o=n(602086),i=n(786200),r=n(409844),a=n(309130);const l=(e,t)=>r.AH`
  &-appear,
  &-enter {
    opacity: 0;
    display: flex !important;
    transform: translateY(-${a.xO});
  }
  &-appear-active,
  &-enter-active {
    display: flex !important;
    ${e&&`flex-direction: ${e};`}
    ${t&&`padding: ${t};`}
    opacity: 1;
    transform: translateY(0px);
    transition:
      opacity 150ms ease-in-out,
      transform 300ms cubic-bezier(0.25, 0.1, 0.25, 1);
  }
  &-appear-done,
  &-enter-done {
    display: flex !important;
    ${e&&`flex-direction: ${e};`}
    ${t&&`padding: ${t};`}
    opacity: 1;
  }
  &-exit {
    display: flex !important;
    opacity: 0;
    height: 0;
    box-sizing: border-box;
    margin: ${a.xO} 0 0 !important;
    & > * {
      display: none;
    }
  }
  &-exit-active {
    display: flex !important;
    margin: 0 !important;
    transition: margin 300ms cubic-bezier(0.25, 0.1, 0.25, 1);
  }
  &-exit-done {
    display: none;
  }
`,c=(0,o.memo)(({timeout:e=300,in:t=!1,flexDirection:n,padding:r=`0 0 ${a.fS}`,wrap:c=!1,children:_,...d})=>{const m=(0,o.useRef)(null);return c?(0,s.jsx)(i.A,{nodeRef:m,appear:t,in:t,timeout:e,classNames:l(n,r),mountOnEnter:!0,...d,children:(0,s.jsx)("div",{children:_})}):(0,s.jsx)(s.Fragment,{children:o.Children.map(_,o=>(0,s.jsx)(i.A,{nodeRef:m,appear:t,in:t,timeout:e,classNames:l(n,void 0),mountOnEnter:!0,...d,children:null===o?(0,s.jsx)("div",{}):o}))})})},305793(e,t,n){n.d(t,{A:()=>Je});var s,o,i,r=n(274934),a=n(241792),l=n(977872),c=n(42220),_=n(602086),d=n(159469),m=n(464920),A=n(762542),p=n(292027),E=n(635891),I=n(877840),C=n(436417),u=n(449339),T=n(309130),N=n(901389),O=n(753959),S=n(756782),x=n(793442),M=n(100978),f=n(205521),L=n(700444),R=n(470070),j=n(197571),h=n(897166),g=n(754924),y=n(34118),P=n(797230),v=n(998281),D=n(111356),b=n(590979),k=n(969288),V=n(726831),U=n(352210),G=n(115114);!function(e){e.ANY="any",e.DEVICE="device",e.MAC="mac",e.NETWORK="network",e.IP="ip"}(s||(s={})),function(e){e.ANY="any",e.SPECIFIC="specific"}(o||(o={})),function(e){e.ALL="all",e.SPECIFIC="specific"}(i||(i={}));var w=n(810024),F=n(765282),Y=n(635187),K=n(260334);const W=/^\d+$/,H=e=>{if(!W.test(e))return!1;const t=Number.parseInt(e,10);return!Number.isNaN(t)&&Number.isInteger(t)&&t>=1&&t<=65535},$=a.Yj().superRefine((e,t)=>{const n=e.split(Y.KE).map(e=>e.trim()).filter(Boolean),s=new Set(n);n.every(H)||t.addIssue({code:F.eq.custom,message:(0,K.rn)("SETTINGS_COMMON_SINGLE_PORT_VALIDATION_REQUIRED")}),s.size!==n.length&&t.addIssue({code:F.eq.custom,message:(0,K.rn)("SETTINGS_COMMON_DUPLICATE_PORTS_VALIDATION")})});var B=n(833886),z=n(627625),Q=n(847849),X=n(149450);const Z=(0,z.S)([X.B,Q.K],{message:(0,K.rn)("SETTINGS_ACL_RULES_IPV4_SUBNET_VALIDATION")});var q=n(423564),J=n(508659),ee=n(586566);const te=(e,t)=>{switch(e?.type){case s.IP:return e.ips?e.ips.map(e=>(0,w.Wn)(e)):[];case s.NETWORK:return t.filter(({_id:t})=>e.network_ids?.includes(t)).map(e=>(0,q.mC)(e)).filter(Boolean);default:return[]}},ne=(e,t)=>{const[n,s]=(0,J.A)(t.filter(t=>!t.specific_enforcers?.length||t.specific_enforcers.includes(e.mac)),e=>e.type===P.xC.MAC);return{mac:(e.switch_caps?.max_custom_mac_acls||0)-n.length,ip:(e.switch_caps?.max_custom_ip_acls||0)-s.length}},se=(e,t,n)=>!t.length||t.every(t=>{if(!(0,ee._E)(e,t))return!0;const s=ne(t,n);return e===P.xC.MAC&&s.mac>0||e===P.xC.IPV4&&s.ip>0}),oe=(e,t,n)=>{const s=(0,w.Wn)(e);return!t.some(e=>!!(0,w.MD)(s,e)||!(1!==(0,w.ut)(s)||1!==(0,w.ut)(e)||!n.some(t=>t.ip_subnet&&(0,w.xX)(t.ip_subnet,(0,w.a7)(e))&&(0,w.xX)(t.ip_subnet,(0,w.a7)(s)))))},ie=Z,re=a.Ik({type:a.eu(s.ANY)}),ae=a.Ik({type:a.eu(s.MAC),mac:B.V,mac_mask:a.KC([a.Ik({enabled:a.eu(!0),mask:a.Yj()}),a.Ik({enabled:a.eu(!1).optional()})]).optional().transform(e=>e||{enabled:!1})}),le=a.Ik({type:a.eu(s.DEVICE),macs:a.YO(B.V,{message:(0,K.rn)("SETTINGS_COMMON_DEVICE_REQUIRED")}).min(1,{message:(0,K.rn)("SETTINGS_COMMON_DEVICE_REQUIRED")})}),ce=a.Ik({type:a.eu(s.NETWORK),network_ids:a.YO(a.Yj(),{message:(0,K.rn)("SETTINGS_COMMON_NETWORK_REQUIRED")}).min(1,{message:(0,K.rn)("SETTINGS_COMMON_NETWORK_REQUIRED")})}),_e=a.Ik({type:a.eu(s.IP),ips:a.YO(ie,{message:(0,K.rn)("SETTINGS_SECURITY_MIN_ONE_ENTRY")}).min(1,{message:(0,K.rn)("SETTINGS_SECURITY_MIN_ONE_ENTRY")})}),de=(a.KC([ae,le,ce,_e,re]),a.KC([a.Ik({type:a.eu(o.ANY)}),a.Ik({type:a.eu(o.SPECIFIC),port:$.refine(e=>e.split(Y.KE).filter(Boolean).map(Number).length<=10,{message:(0,K.rn)("SETTINGS_ACL_RULES_PORTS_MEMBERS_MAX_VALIDATION",{count:10})})})]));var me=n(370115),Ae=n(689941),pe=n(243436);const Ee=function({form:e,name:t,getIsNetworkVisible:n,getDisabledReason:s,additionalInfo:o="subnet",...i}){const a=(0,l.d4)(j.Ct),d=(0,c.FH)({control:e.control,name:t}),m=(0,_.useMemo)(()=>a.filter(e=>d===e._id||n(e)).map(e=>{const t=d!==e._id?s?.(e):void 0,n=(0,pe.A1)(e);return{label:n?`${e.name} (${n})`:e.name,value:e._id,tooltipDescription:t,disabled:!!t,additionalInfo:"subnet"===o?(0,q.mC)(e):"vlan"===o?(0,pe.mM)(e.vlan,(0,q.nz)(e))?.toString():void 0}}),[a,d,n,s,o]);return(0,r.jsx)(Ae.A,{control:e.control,name:t,options:m,renderOption:me.Ku,...i})};var Ie=n(164487),Ce=n(597750),ue=n(636658);const Te=({form:e})=>{const t=(0,l.d4)(g.m9),n=(0,l.d4)(g.ID);return(0,r.jsxs)(Ce.A,{children:[(0,r.jsx)(Ie.A,{htmlFor:"network_id",tooltip:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_NETWORK_TOOLTIP",values:{link:(0,r.jsx)(x.A,{href:V.A.aclRules,id:"COMMON_LEARN_MORE",noWrap:!0})}}),tooltipProps:{isInteractive:!0},children:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_VLAN_NETWORKS"})}),(0,r.jsx)(Ee,{form:e,name:"network_id",additionalInfo:"subnet",getIsNetworkVisible:e=>(0,ue.d)(e,t),getDisabledReason:e=>n.some(t=>t.mgmt_network_id===e._id||e.ip_subnet&&(0,w.xX)(e.ip_subnet,t.ip))?(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_NETWORK_DISABLED_TOOLTIP"}):void 0})]})};var Ne=n(482609),Oe=n(787481);const Se=({form:e,existingRecord:t})=>{const n=(0,l.d4)(g.b2),o=(0,l.d4)(v.yT),a=(0,_.useCallback)(s=>{const r=o.filter(e=>e._id!==t?._id);e.getValues("devices.type")!==i.ALL||se(s,n,r)||e.setValue("devices.type",i.SPECIFIC),e.getValues("devices.type")===i.SPECIFIC&&e.setValue("devices.macs",e.getValues("devices.macs")?.filter(e=>n.some(t=>t.mac===e&&(0,ee._E)(s,t)&&ne(t,r)[s===P.xC.MAC?"mac":"ip"]>0)))},[o,n,t?._id,e]);return(0,r.jsxs)(Oe.A,{children:[(0,r.jsx)(Ne.A,{control:e.control,name:"type",value:P.xC.MAC,onCheck:()=>{e.setValue("source.type",s.ANY),e.setValue("destination.type",s.ANY),a(P.xC.MAC)},children:(0,r.jsx)(R.sA,{id:"COMMON_MAC"})}),(0,r.jsx)(Ne.A,{control:e.control,name:"type",value:P.xC.IPV4,onCheck:()=>{e.setValue("source.type",s.ANY),e.setValue("destination.type",s.ANY),a(P.xC.IPV4)},children:(0,r.jsx)(R.sA,{id:"COMMON_IPV4"})})]})};var xe=n(347625),Me=n(749445),fe=n(846294),Le=n(974390),Re=n(27103),je=n(640225),he=n(160286);const ge=({form:e,existingRecord:t})=>{const n=(0,l.d4)(g.b2),s=(0,l.d4)(v.yT),o=(0,l.d4)(he.D5),a=(0,c.FH)({control:e.control,name:"type"}),d=(0,c.FH)({control:e.control,name:"devices"}),m=(0,_.useMemo)(()=>s.filter(e=>e._id!==t?._id),[s,t?._id]),A=(0,_.useMemo)(()=>(0,je.J6)(n,o).map(e=>{const t=ne(e,m),n=(0,ee._E)(a,e)?(a===P.xC.MAC?t.mac:t.ip)<=0?(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_SWITCH_LIMIT_REACHED_TOOLTIP"}):null:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_SWITCH_INCOMPATIBLE_TOOLTIP"});return{label:(0,je._y)((0,xe.Q)(e),e.stacking_group_id,o),value:e.mac,image:(0,r.jsx)(Le.A,{model:e.model}),disabled:!!n,tooltipDescription:n,tooltipPortal:!!n,tooltipPosition:"left",tooltipOffset:20}}),[n,a,m,o]),p=(0,_.useMemo)(()=>n.filter(e=>(!a||!(0,ee._E)(a,e))&&(d?.type===i.ALL||d?.type===i.SPECIFIC&&d.macs?.includes(e.mac))),[n,d,a]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(Ce.A,{children:[(0,r.jsx)(Ie.A,{htmlFor:"devices.type",tooltip:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_SWITCH_TOOLTIP"}),children:(0,r.jsx)(R.sA,{id:"COMMON_SWITCH"})}),(0,r.jsxs)(Oe.A,{children:[(0,r.jsx)(fe.A,{reason:d?.type===i.ALL||se(a,n,m)?null:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_SWITCH_LIMIT_REACHED_TOOLTIP_SOME"}),children:(0,r.jsx)(Ne.A,{name:"devices.type",control:e.control,value:i.ALL,children:(0,r.jsx)(R.sA,{id:"COMMON_ALL"})})}),(0,r.jsx)(Ne.A,{name:"devices.type",control:e.control,value:i.SPECIFIC,children:(0,r.jsx)(R.sA,{id:"COMMON_SPECIFIC"})})]})]}),d?.type===i.SPECIFIC?(0,r.jsx)(Me.A,{control:e.control,name:"devices.macs",options:A,triggerButtonText:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_SWITCH_TRIGGER"})}):null,p.length?(0,r.jsx)(Re.A,{list:p.map(e=>(0,xe.Q)(e)),messageId:"SETTINGS_ACL_RULES_SWITCH_INCOMPATIBLE_ALERT"}):null]})};var ye=n(209546),Pe=n(729484);const ve=({form:e,name:t})=>{const n=(0,c.FH)({control:e.control,name:`${t}.type`}),s=(0,c.FH)({control:e.control,name:"protocol"}),{formatMessage:i}=(0,R.tz)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(Ce.A,{children:[(0,r.jsx)(Ie.A,{htmlFor:`${t}.type`,children:(0,r.jsx)(R.sA,{id:"COMMON_PORT"})}),(0,r.jsxs)(Oe.A,{children:[(0,r.jsx)(Ne.A,{control:e.control,name:`${t}.type`,value:o.ANY,children:(0,r.jsx)(R.sA,{id:"COMMON_ANY"})}),(0,r.jsx)(fe.A,{reason:s===P.w$.ALL?(0,r.jsx)(R.sA,{id:"SETTINGS_ROUTING_NAT_PORT_DISABLED_TOOLTIP"}):null,children:(0,r.jsx)(Ne.A,{control:e.control,name:`${t}.type`,value:o.SPECIFIC,children:(0,r.jsx)(R.sA,{id:"COMMON_SPECIFIC"})})})]})]}),n===o.SPECIFIC?(0,r.jsx)(E.A,{control:e.control,name:`${t}.port`,placeholder:i({id:"COMMON_PLACEHOLDER_EG"},{value:"11,12"})}):null]})};var De=n(477909),be=n(625133),ke=n(489714);const Ve=function({form:e,name:t,...n}){const{formatMessage:s}=(0,R.tz)();return(0,r.jsx)(E.A,{control:e.control,name:t,onChange:({target:{value:e}},t)=>{t.onChange((0,ke.Z)(e))},placeholder:s({id:"COMMON_PLACEHOLDER_EG"},{value:"ab:cd:ef:12:34:56"}),...n})};var Ue=n(796091);const Ge=({form:e,name:t})=>{const n=(0,c.FH)({control:e.control,name:t});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ve,{form:e,name:`${t}.mac`}),(0,r.jsx)(Ue.A,{children:(0,r.jsx)(be.A,{tooltip:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_MAC_MASK_TOOLTIP"}),control:e.control,name:`${t}.mac_mask.enabled`,children:(0,r.jsx)(R.sA,{id:"SETTINGS_NETWORKS_FORM_NETMASK"})})}),n?.type===s.MAC&&n.mac_mask?.enabled?(0,r.jsx)(M.A,{width:92,alignItems:"flex-start",children:(0,r.jsx)(Ae.A,{control:e.control,name:`${t}.mac_mask.mask`,options:(0,De.A)(9,49).map(e=>{return{value:(t=e,(2**48-1-(2**(48-t)-1)).toString(16).padStart(12,"0").match(/(.{2})/g).join(":")),label:e.toString()};var t})})}):null]})},we=({form:e,name:t})=>{const n=(0,c.FH)({control:e.control,name:"type"});return(0,r.jsxs)(Oe.A,{children:[(0,r.jsx)(Ne.A,{control:e.control,name:`${t}.type`,value:s.ANY,children:(0,r.jsx)(R.sA,{id:"COMMON_ANY"})}),n===P.xC.MAC?(0,r.jsx)(Ne.A,{control:e.control,name:`${t}.type`,value:s.DEVICE,children:(0,r.jsx)(R.sA,{id:"COMMON_DEVICE"})}):null,n===P.xC.MAC?(0,r.jsx)(Ne.A,{control:e.control,name:`${t}.type`,value:s.MAC,children:(0,r.jsx)(R.sA,{id:"COMMON_MAC_ADDRESS"})}):null,n===P.xC.IPV4?(0,r.jsx)(Ne.A,{control:e.control,name:`${t}.type`,value:s.NETWORK,children:(0,r.jsx)(R.sA,{id:"COMMON_NETWORK"})}):null,n===P.xC.IPV4?(0,r.jsx)(Ne.A,{control:e.control,name:`${t}.type`,value:s.IP,children:(0,r.jsx)(R.sA,{id:"COMMON_IP"})}):null]})};var Fe=n(186070);const Ye=function({form:e,name:t,excludeUnifiDevices:n}){const{formatMessage:s}=(0,R.tz)(),o=(0,c.FH)({control:e.control,name:"network_id"}),i=(0,_.useCallback)(e=>e.network_id===o?"vlan":"other",[o]),a=(0,_.useMemo)(()=>({vlan:{label:s({id:"SETTINGS_VLAN_DEVICES"}),order:0},other:{label:s({id:"SETTINGS_FIREWALL_RULE_OTHER_DEVICES"}),order:1}}),[s]);return(0,r.jsx)(Fe.A,{form:e,name:t,groups:a,getGroup:i,excludeUnifiDevices:n})},Ke=({form:e})=>{const t=(0,l.d4)(g.m9),n=(0,l.d4)(j.Ct),{formatMessage:o}=(0,R.tz)(),i=(0,c.FH)({control:e.control,name:"type"}),a=(0,c.FH)({control:e.control,name:"destination"}),d=(0,c.FH)({control:e.control,name:"source"}),m=(0,_.useMemo)(()=>te(a,n),[a,n]),A=(0,_.useMemo)(()=>n.filter(e=>!(0,q.$q)(e)),[n]),p=(0,_.useMemo)(()=>ie.refine(e=>oe(e,m,A),{message:(0,K.rn)("SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP")}),[m,A]);return(0,r.jsxs)(S.A,{...b.A.addDataTestId(b.A.TestId.ACL_POLICY_FORM_SOURCE),title:(0,r.jsx)(R.sA,{id:"COMMON_SOURCE"}),children:[(0,r.jsx)(we,{form:e,name:"source"}),d?.type===s.NETWORK?(0,r.jsx)(ye.A,{form:e,name:"source.network_ids",additionalInfo:"subnet",getIsNetworkVisible:e=>(0,ue.d)(e,t),getDisabledReason:({_id:e,ip_subnet:t})=>a?.type===s.NETWORK&&a.network_ids?.includes(e)?(0,r.jsx)(R.sA,{id:"SETTINGS_SECURITY_NETWORK_OPTION_DISABLED_REASON"}):m.some(e=>t&&(0,w.MD)(t,e))?(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP"}):void 0}):null,d?.type===s.IP?(0,r.jsx)(Pe.A,{form:e,name:"source.ips",schema:p,placeholder:o({id:"COMMON_IPV4_ADDRESS_OR_SUBNET"})}):null,d?.type===s.MAC?(0,r.jsx)(Ge,{form:e,name:"source"}):null,d?.type===s.DEVICE?(0,r.jsx)(Ye,{form:e,name:"source.macs"}):null,i===P.xC.IPV4?(0,r.jsx)(ve,{form:e,name:"source_port"}):null]})},We=({form:e})=>(0,r.jsxs)(Ce.A,{children:[(0,r.jsx)(Ie.A,{htmlFor:"protocol",children:(0,r.jsx)(R.sA,{id:"COMMON_PROTOCOL"})}),(0,r.jsxs)(Oe.A,{children:[(0,r.jsx)(Ne.A,{control:e.control,name:"protocol",value:P.w$.ALL,onCheck:()=>{e.setValue("source_port.type",o.ANY),e.setValue("destination_port.type",o.ANY)},children:(0,r.jsx)(R.sA,{id:"COMMON_ALL"})}),(0,r.jsx)(Ne.A,{control:e.control,name:"protocol",value:P.w$.TCP_AND_UDP,children:(0,r.jsx)(R.sA,{id:"COMMON_TCP_AND_UDP"})}),(0,r.jsx)(Ne.A,{control:e.control,name:"protocol",value:P.w$.TCP,children:(0,r.jsx)(R.sA,{id:"COMMON_TCP"})}),(0,r.jsx)(Ne.A,{control:e.control,name:"protocol",value:P.w$.UDP,children:(0,r.jsx)(R.sA,{id:"COMMON_UDP"})})]})]}),He=({form:e})=>{const t=(0,l.d4)(g.m9),n=(0,l.d4)(j.Ct),{formatMessage:o}=(0,R.tz)(),i=(0,c.FH)({control:e.control,name:"type"}),a=(0,c.FH)({control:e.control,name:"destination"}),d=(0,c.FH)({control:e.control,name:"source"}),m=(0,_.useMemo)(()=>te(d,n),[d,n]),A=(0,_.useMemo)(()=>n.filter(e=>!(0,q.$q)(e)),[n]),p=(0,_.useMemo)(()=>ie.refine(e=>oe(e,m,A),{message:(0,K.rn)("SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP")}),[m,A]);return(0,r.jsxs)(S.A,{...b.A.addDataTestId(b.A.TestId.ACL_POLICY_FORM_DESTINATION),title:(0,r.jsx)(R.sA,{id:"COMMON_DESTINATION"}),children:[(0,r.jsx)(we,{form:e,name:"destination"}),a?.type===s.NETWORK?(0,r.jsx)(ye.A,{form:e,name:"destination.network_ids",additionalInfo:"subnet",getIsNetworkVisible:e=>(0,ue.d)(e,t),getDisabledReason:({_id:e,ip_subnet:t})=>d?.type===s.NETWORK&&d.network_ids?.includes(e)?(0,r.jsx)(R.sA,{id:"SETTINGS_SECURITY_NETWORK_OPTION_DISABLED_REASON"}):m.some(e=>t&&(0,w.MD)(t,e))?(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP"}):void 0}):null,a?.type===s.IP?(0,r.jsx)(Pe.A,{form:e,name:"destination.ips",schema:p,placeholder:o({id:"COMMON_IPV4_ADDRESS_OR_SUBNET"})}):null,a?.type===s.MAC?(0,r.jsx)(Ge,{form:e,name:"destination"}):null,a?.type===s.DEVICE?(0,r.jsx)(Ye,{form:e,name:"destination.macs",excludeUnifiDevices:!0}):null,i===P.xC.IPV4?(0,r.jsx)(ve,{form:e,name:"destination_port"}):null]})},$e=({form:e})=>(0,r.jsxs)(Oe.A,{children:[(0,r.jsx)(Ne.A,{control:e.control,name:"action",value:P.tZ.BLOCK,children:(0,r.jsx)(R.sA,{id:"COMMON_ACTION_BLOCK"})}),(0,r.jsx)(Ne.A,{control:e.control,name:"action",value:P.tZ.ALLOW,children:(0,r.jsx)(R.sA,{id:"COMMON_ALLOW"})})]});var Be=n(420174);const ze=(e,t)=>e?.type===P.lP.CLIENT_MAC?e.specific_mac_addresses?.length?1!==e.specific_mac_addresses?.length||!e.mac_mask&&t.some(t=>"mac"in t&&t.mac===e.specific_mac_addresses?.[0])?{type:s.DEVICE,macs:e.specific_mac_addresses||[]}:{type:s.MAC,mac:e.specific_mac_addresses?.[0],mac_mask:e.mac_mask?{enabled:!0,mask:e.mac_mask}:{enabled:!1}}:{type:s.ANY}:e?.type===P.lP.NETWORK?0===e.network_ids?.length?{type:s.ANY}:{type:s.NETWORK,network_ids:e.network_ids}:e?.type===P.lP.IP_OR_SUBNET?0===e.ips_or_subnets?.length?{type:s.ANY}:{type:s.IP,ips:e.ips_or_subnets}:{type:s.ANY},Qe=(e,t,n,s,r,a)=>{const l=e?.type||n||P.xC.MAC;return{name:e?.name||a,type:l,action:e?.action||P.tZ.BLOCK,devices:e?e.specific_enforcers?.length?{type:i.SPECIFIC,macs:e.specific_enforcers}:{type:i.ALL}:se(l,s,r)?{type:i.ALL}:{type:i.SPECIFIC,macs:[]},network_id:e?.mac_acl_network_id,protocol:e?.ip_acl_protocol||P.w$.ALL,source:ze(e?.traffic_source,t),source_port:e?.traffic_source.ports?.length?{type:o.SPECIFIC,port:String(e.traffic_source.ports.join(Y.KE))}:{type:o.ANY},destination:ze(e?.traffic_destination,t),destination_port:e?.traffic_destination.ports?.length?{type:o.SPECIFIC,port:String(e.traffic_destination.ports.join(Y.KE))}:{type:o.ANY}}},Xe=(e,t,n)=>{const i=n?.type===o.SPECIFIC?n.port.split(Y.KE).filter(Boolean).map(Number):[];return t?t.type===s.NETWORK?{type:P.lP.NETWORK,network_ids:t.network_ids,ports:i}:t.type===s.IP?{type:P.lP.IP_OR_SUBNET,ips_or_subnets:t.ips,ports:i}:t.type===s.ANY?e===P.xC.MAC?{type:P.lP.CLIENT_MAC,specific_mac_addresses:[]}:{type:P.lP.NETWORK,network_ids:[],ports:i}:t.type===s.DEVICE?{type:P.lP.CLIENT_MAC,specific_mac_addresses:t.macs||[],mac_mask:void 0}:t.type===s.MAC?{type:P.lP.CLIENT_MAC,specific_mac_addresses:[t.mac],mac_mask:t.mac_mask?.enabled?t.mac_mask.mask:void 0}:{}:{type:P.lP.IP_OR_SUBNET,ips_or_subnets:[],ports:i}},Ze=e=>`acl-policy-form-${e}`,qe=a.fc(P.xC).optional().catch(()=>{}),Je=({activeItem:e,typeSelector:t})=>{const{sharedName:n,setSharedName:o}=(0,Be.H5)(),F=!e?._id||e._id?.startsWith(k.R6)?void 0:e,Y=(0,l.wA)(),W=(0,l.d4)(h.EL),H=(0,l.d4)(y.GB),$=(0,l.d4)(j.Ct),B=(0,l.d4)(h.vc),z=(0,l.d4)(v.Us),Q=(0,l.d4)(g.b2),X=(0,l.d4)(v.yT),Z=(0,_.useMemo)(()=>X.filter(e=>e._id!==F?._id),[X,F?._id]),J=(0,_.useMemo)(()=>((e,t)=>a.E$(a.Ik({name:a.Yj({message:(0,K.rn)("COMMON_VALIDATION_NAME_REQUIRED")}).min(1,{message:(0,K.rn)("COMMON_VALIDATION_NAME_REQUIRED")}).max(32,{message:(0,K.rn)("SETTINGS_COMMON_FIELD_SHOULD_NOT_EXCEED_MAX_LENGTH",{name:(0,K.rn)("COMMON_NAME"),limit:32})}),action:a.fc(P.tZ),devices:a.KC([a.Ik({type:a.eu(i.ALL)}),a.Ik({type:a.eu(i.SPECIFIC),macs:a.YO(a.Yj(),{message:(0,K.rn)("SETTINGS_ACL_RULES_SWITCH_REQUIRED")}).min(1,{message:(0,K.rn)("SETTINGS_ACL_RULES_SWITCH_REQUIRED")})})])}),a.KC([a.Ik({type:a.eu(P.xC.MAC),network_id:a.Yj({message:(0,K.rn)("SETTINGS_VALIDATION_SELECT_A_NETWORK")}),source:a.KC([ae,le,re]),destination:a.KC([ae,le,re])}),a.Ik({type:a.eu(P.xC.IPV4),protocol:a.KC([a.eu(P.w$.ALL),a.eu(P.w$.TCP_AND_UDP),a.eu(P.w$.TCP),a.eu(P.w$.UDP)]),source:a.KC([ce,_e,re]),source_port:de,destination:a.KC([ce,_e,re]),destination_port:de}).refine(t=>{if(t.destination?.type!==s.NETWORK)return!0;const n=t.destination.network_ids||[],o=te(t.source,e),i=e.filter(({_id:e})=>n.includes(e)).map(e=>(0,q.mC)(e)).filter(Boolean);return!o.some(e=>i.some(t=>(0,w.MD)(e,t)))},{path:["destination","network_ids"],message:(0,K.rn)("SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP")}).refine(t=>{if(t.destination?.type!==s.IP)return!0;const n=t.destination.ips||[];return!te(t.source,e).some(e=>n.some(t=>(0,w.MD)(e,(0,w.Wn)(t))))},{path:["destination","ips"],message:(0,K.rn)("SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP")}),a.Ik({type:a.eu(P.xC.IPV6)})])).refine(e=>e.type!==P.xC.MAC||e.action!==P.tZ.BLOCK||!(e.source.type===s.MAC&&e.source.mac===t),{path:["data","source","mac"],message:(0,K.rn)("SETTINGS_ACL_RULES_MAC_VALIDATION_GATEWAY")}).refine(e=>e.type!==P.xC.MAC||e.action!==P.tZ.BLOCK||!(e.destination.type===s.MAC&&e.destination.mac===t),{path:["data","destination","mac"],message:(0,K.rn)("SETTINGS_ACL_RULES_MAC_VALIDATION_GATEWAY")}))($,B),[$,B]),ee=(0,C.m)({schema:J,defaultValues:Qe(F,H,qe.parse(e._id.split(":")[1]),Q,Z,n)});(0,A.y)(ee);const ne=(0,c.FH)({control:ee.control,name:"type"}),se=(0,c.FH)({control:ee.control,name:"action"}),oe=(0,c.FH)({control:ee.control,name:"source.type"}),ie=(0,c.FH)({control:ee.control,name:"destination.type"}),me=ee.handleSubmit(async e=>Y((0,D.OL)(((e,t,n)=>({enabled:!0,acl_index:n,...e,predefined:!!e?.predefined,name:t.name,type:t.type,action:t.action,specific_enforcers:t.devices.type===i.ALL?[]:t.devices.macs,mac_acl_network_id:t.type===P.xC.MAC?t.network_id:void 0,ip_acl_protocol:t.type===P.xC.IPV4?t.protocol:void 0,traffic_source:Xe(t.type,"source"in t?t.source:void 0,"source_port"in t?t.source_port:void 0),traffic_destination:Xe(t.type,"destination"in t?t.destination:void 0,"destination_port"in t?t.destination_port:void 0)}))(F,e,z))).then(e=>{Y((0,f.SQ)(!1)),Y((0,f.XP)({type:u.H.ACL_POLICY,id:e._id}))}).then(()=>{ee.reset()}).catch(e=>{const t=(0,m.F)(e)?e:void 0,n=t?.apiData?.details?.enforcer_mac;Y((0,L.ox)(t?.apiData?.code===U.ApiString.apiErrCustomAclCapacityExceeded&&n?{icon:d.C.danger,message:"SETTINGS_ACL_RULES_ERROR_SAVE",errorMessage:"SETTINGS_ACL_RULES_EXCEEDED_ERROR",errorValues:{device:Q.find(({mac:e})=>e===n)?.name||n}}:{icon:d.C.danger,message:"SETTINGS_ACL_RULES_ERROR_SAVE",errorMessage:t?.msg||"SETTINGS_ACL_RULES_GENERIC_ERROR",errorValues:t}))}));return(0,r.jsx)("form",{onSubmit:me,id:Ze(e._id),children:(0,r.jsxs)(I.A,{isDisabled:W,children:[(0,r.jsxs)(M.A,{gap:T.Ln,flexDirection:"column",width:"100%",children:[(0,r.jsxs)(S.A,{children:[t,(0,r.jsx)(E.A,{control:ee.control,name:"name",label:(0,r.jsx)(R.sA,{id:"COMMON_NAME"}),onChange:(e,t)=>{t.onChange(e),o(e.target.value)}})]}),(0,r.jsxs)(S.A,{...b.A.addDataTestId(b.A.TestId.ACL_POLICY_FORM_TYPE),title:(0,r.jsx)(R.sA,{id:"COMMON_TYPE"}),tooltip:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_TYPE_TOOLTIP",values:{link:(0,r.jsx)(x.A,{id:"COMMON_LEARN_MORE",href:V.A.aclRules})}}),tooltipProps:{isInteractive:!0},children:[(0,r.jsx)(Se,{form:ee,existingRecord:F}),ne===P.xC.MAC?(0,r.jsx)(O.A,{children:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_BANNER_MAC",values:{link:(0,r.jsx)(x.A,{href:V.A.aclRules,id:"COMMON_LEARN_MORE",noWrap:!0})}})}):null,ne===P.xC.IPV4||ne===P.xC.IPV6?(0,r.jsx)(O.A,{children:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_BANNER_IP",values:{link:(0,r.jsx)(x.A,{href:V.A.aclRules,id:"COMMON_LEARN_MORE",noWrap:!0})}})}):null,(0,r.jsx)(ge,{form:ee,existingRecord:F}),ne===P.xC.IPV4?(0,r.jsx)(We,{form:ee}):null,ne===P.xC.MAC?(0,r.jsx)(Te,{form:ee}):null]}),(0,r.jsx)(Ke,{form:ee}),(0,r.jsxs)(S.A,{...b.A.addDataTestId(b.A.TestId.ACL_POLICY_FORM_ACTION),title:(0,r.jsx)(R.sA,{id:"COMMON_ACTION"}),children:[(0,r.jsx)($e,{form:ee}),se===P.tZ.BLOCK&&oe===s.ANY&&ie===s.ANY?(0,r.jsx)(N.A,{children:(0,r.jsx)(R.sA,{id:"SETTINGS_ACL_RULES_ANY_ANY_WARNING_MESSAGE",values:{link:(0,r.jsx)(x.A,{href:V.A.aclRules,noWrap:!0,id:"COMMON_LEARN_MORE"})}})}):null]}),(0,r.jsx)(He,{form:ee}),F?(0,r.jsx)(p.A,{enabled:F.enabled,name:F.name||"",onPause:async()=>{await Y((0,D.RJ)([{_id:F._id,enabled:!1}])),await Y((0,D.U9)())},onResume:async()=>{await Y((0,D.RJ)([{_id:F._id,enabled:!0}])),await Y((0,D.U9)())},onRemove:()=>Y((0,D.DH)([F._id]))}):null]}),(0,r.jsx)(G.A,{onFormCancel:()=>ee.reset(),isDirty:ee.formState.isDirty||!F,hideCancelButton:!ee.formState.isDirty,submitButtonText:F?void 0:"COMMON_ACTION_ADD",form:Ze(e._id),isSubmitting:ee.formState.isSubmitting})]})})}},186070(e,t,n){n.d(t,{A:()=>T});var s=n(274934),o=n(602086),i=n(977872),r=n(42220),a=n(117948),l=n(314191),c=n(938984),_=n(749445),d=n(833466),m=n(100978),A=n(650632),p=n(470070),E=n(831433),I=n(34118);const C={threshold:.1},u=({children:e})=>(0,s.jsx)(m.A,{alignItems:"center",height:d.b,children:(0,s.jsx)(c.A,{size:"inherit",color:"inherit",children:e})}),T=function({form:e,name:t,additionalInfo:n="mac",excludeUnifiDevices:c,getGroup:d,groups:T,...N}){const{formatMessage:O}=(0,p.tz)(),S=(0,r.FH)({control:e.control,name:t}),x=(0,i.d4)(I.GB),M=(0,o.useMemo)(()=>{const e=x.filter(e=>!(c&&"unifi_device"in e&&e.unifi_device)),t=(S||[]).filter(t=>!e.some(e=>"mac"in e&&e.mac===t)).map(e=>({mac:e,name:e})),o=[...e,...t].flatMap(e=>"mac"in e?[e]:[]);return(T&&d?(0,a.A)(Object.entries((0,l.A)(o,d)),([e])=>T[e]?.order??0).map(([e,t])=>({id:e,label:T[e]?.label,options:t})).filter(e=>e.options.length>0):[{id:void 0,label:void 0,options:o}]).flatMap(({options:e,label:t,id:o})=>[...t&&o?[{label:(0,s.jsx)(u,{children:t}),value:o,group:o,groupTitle:!0}]:[],...e.map(e=>({label:(0,E.tn)(e),value:e.mac,group:o,image:(0,s.jsx)(m.A,{maxWidth:24,maxHeight:24,children:(0,s.jsx)(A.A,{client:e})}),additionalInfo:"mac"===n?e.mac:void 0}))])},[n,x.length,S,c]);return(0,s.jsx)(_.A,{control:e.control,name:t,options:M,truncateLabels:!0,isWindowed:!0,triggerButtonText:O({id:"COMMON_SELECT"}),searchOptions:C,...N})}},729484(e,t,n){n.d(t,{A:()=>r});var s=n(274934),o=n(470070),i=n(858098);const r=function({form:e,name:t,schema:n,placeholder:r,max:a,label:l="SETTINGS_IP_ADDRESS_SUBNET",disableMultiEdit:c=!1}){const{formatMessage:_}=(0,o.tz)();return(0,s.jsx)(i.A,{form:e,name:t,fieldLabel:l,modalTitle:(0,s.jsx)(o.sA,{id:"SETTINGS_ADD_MULTIPLE_IPS"}),modalFieldPlaceholder:_({id:"SETTINGS_ADD_MULTIPLE_IPS_PLACEHOLDER"}),getDuplicationMessage:()=>_({id:"SETTINGS_DUPLICATE_IP_VALIDATION"}),itemSchema:n,placeholder:r??_({id:"COMMON_ENTER_IP_ADDRESS"}),disableMultiEdit:c,max:a})}},209546(e,t,n){n.d(t,{A:()=>m});var s=n(274934),o=n(602086),i=n(977872),r=n(42220),a=n(749445),l=n(243436),c=n(470070),_=n(423564),d=n(197571);const m=function({form:e,name:t,getIsNetworkVisible:n,getDisabledReason:m,additionalInfo:A,getOptionLabel:p,...E}){const{formatMessage:I}=(0,c.tz)(),C=(0,i.d4)(d.Ct),u=(0,r.FH)({control:e.control,name:t}),T=(0,o.useMemo)(()=>C.filter(e=>n(e)||u?.includes(e._id)).map(e=>{const t=u?.includes(e._id)?void 0:m?.(e);return{label:p?.(e)||e.name,value:e._id,disabled:!!t,tooltipDescription:t,tooltipPosition:"left",tooltipPortal:!0,additionalInfo:"subnet"===A?(0,_.mC)(e):"vlan"===A?(0,l.mM)(e.vlan,(0,_.nz)(e))?.toString():void 0}}),[C,n,u,m,p,A]);return(0,s.jsx)(a.A,{control:e.control,name:t,options:T,truncateLabels:!0,...E,triggerButtonText:I({id:"COMMON_SELECT"})})}},833886(e,t,n){n.d(t,{V:()=>r});var s=n(241792),o=n(570866),i=n(260334);const r=s.Yj({message:(0,i.rn)("SETTINGS_ACL_RULES_MAC_VALIDATION_GENERIC")}).refine(e=>o.b8.test(e),{message:(0,i.rn)("SETTINGS_ACL_RULES_MAC_VALIDATION_GENERIC")})}}]);