"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[5468],{432680:(e,t,i)=>{i.d(t,{XR:()=>o,jq:()=>r,ll:()=>c,rt:()=>l});var n=i(691189),a=i(800126);const l=(e={},t={})=>(0,n.t9)(a.A2,a.VD,e,{...t,idField:"id"}),r=e=>(0,n.vL)(a.A2,e.id,`${a.gI}/${e.id}`,e,void 0,{idField:"id"}),c=e=>e.id?r(e):(e=>(0,n.eC)(a.A2,a.gI,e,void 0,{idField:"id",fetchConfig:{getAllPostData:!0}}))(e),o=e=>(0,n.LK)(a.A2,e,`${a.gI}/${e}`,void 0,{idField:"id"})},800126:(e,t,i)=>{i.d(t,{$j:()=>r,A2:()=>n,VD:()=>l,gI:()=>a});const n="object",a="/v2/api/site/{site}/object-oriented-network-config",l=`${a}s`,r=999},945468:(e,t,i)=>{i.r(t),i.d(t,{default:()=>F});var n=i(296540),a=i(469733),l=i(183970),r=i(570868),c=i(48925),o=i(641777),m=i(602021),s=i(294303),d=i(566723),u=i(459449),E=i(845030),A=i(398300),O=i(38671),f=i(675359),h=i(742920),C=i(895424),v=i(642597),p=i(959341),_=i(689965),b=i(853801),M=i(133183),g=i(861509),N=i(705483),S=i(414523),I=i(592563),y=i(900956),D=i(117982),T=i(732881),k=i(217439),R=i(74750),w=i(432680);const x=({existingRecord:e})=>{const t=(0,a.useDispatch)();return n.createElement("div",null,n.createElement(y.A,null,n.createElement(D.A,null,n.createElement(I.A,{fontSize:"medium",variant:"destructive"},n.createElement(u.sA,{id:"COMMON_ACTION_DELETE"}))),n.createElement(T.A,{actionButtons:n.createElement(R.A,{variant:"destructive",onPress:async()=>{await t((0,v.aX)(e.id)),await t((0,w.rt)())}},n.createElement(u.sA,{id:"COMMON_ACTION_DELETE"})),title:n.createElement(u.sA,{id:"COMMON_ARE_YOU_SURE"})},n.createElement(k.A,{variant:"inherit",size:"medium"},n.createElement(u.sA,{id:"COMMON_CLIENT_GROUP_DELETE_CONFIRMATION",values:{name:e?.name}})))))},L="network-members-group-form",V=({activeItem:e})=>{const t=e&&e.id!==p.R6?e:void 0,i=(0,a.useDispatch)(),I=(0,a.useSelector)(m.EL),y=(0,a.useSelector)(g.y),D=(0,n.useMemo)(()=>y.filter(e=>e.id!==t?.id),[t?.id,y]),T=(0,n.useMemo)(()=>(0,N.c)(D),[D]),k=(0,r.m)({schema:T,defaultValues:{name:t?.name||"",member_macs:t?.members||[]}});(0,b.y)(k);const R=k.handleSubmit(e=>i((0,v.YH)({id:t?.id,name:e.name,members:e.member_macs,type:t?.type||l.k.CLIENTS})).then(async e=>(await i((0,v.O$)(void 0,{resolveWithExisting:!1})),e)).then(e=>{i((0,E.SQ)(!1)),i((0,E.XP)({type:A.H.NETWORK_MEMBERS_GROUP,id:e.id}))}).then(()=>k.reset()).catch(e=>{const t=(0,O.F)(e)?e:void 0;i((0,f.ox)({icon:h.C.danger,message:"COMMON_CLIENT_GROUP_FAILED_SAVE",errorMessage:t?.msg,errorValues:t?.details}))}));return n.createElement("form",{onSubmit:R,id:L},n.createElement(o.A,{isDisabled:I},n.createElement(s.A,{gap:d.kc,flexDirection:"column",width:"100%"},n.createElement(c.A,null,n.createElement(C.A,{control:k.control,name:"name",label:n.createElement(u.sA,{id:"COMMON_NAME"})}),n.createElement(M.A,{form:k,name:"member_macs"})),t?n.createElement(_.A,null,n.createElement(x,{existingRecord:t})):null),n.createElement(S.A,{onFormCancel:()=>k.reset(),isDirty:k.formState.isDirty||!t,hideCancelButton:!k.formState.isDirty,form:L,isSubmitting:k.formState.isSubmitting,submitButtonText:t?"COMMON_ACTION_SAVE":"COMMON_ACTION_CREATE"})))},F=({activeItem:e})=>n.createElement(V,{key:e.id,activeItem:e})},133183:(e,t,i)=>{i.d(t,{A:()=>E});var n=i(296540),a=i(376618),l=i(784045),r=i(469733),c=i(349785),o=i(239417),m=i(951106),s=i(294303),d=i(703447),u=i(92828);const E=function({form:e,name:t,additionalInfo:i="mac",excludeUnifiDevices:E,getGroup:A,groups:O,...f}){const h=(0,c.FH)({control:e.control,name:t}),C=(0,r.useSelector)(o.GB),v=(0,n.useMemo)(()=>{const e=C.filter(e=>!(E&&"unifi_device"in e&&e.unifi_device)),t=(h||[]).filter(t=>!e.some(e=>"mac"in e&&e.mac===t)).map(e=>({mac:e,name:e})),i=[...e,...t].flatMap(e=>"mac"in e?[e]:[]);return(O&&A?(0,l.A)(Object.entries((0,a.A)(i,A)),([e])=>O[e]?.order??0).map(([e,t])=>({id:e,label:O[e]?.label,options:t})).filter(e=>e.options.length>0):[{id:void 0,label:void 0,options:i}]).flatMap(({options:e,label:t,id:i})=>[...t&&i?[{type:"SECTION",title:t,id:i,children:[]}]:[],...e.map(e=>({type:"CHECKBOX",title:(0,m.tn)(e),id:e.mac,checkboxProps:{symbol:n.createElement(s.A,{maxWidth:24,maxHeight:24},n.createElement(d.A,{client:e}))},children:[]}))])},[i,C.length,h,E]),p=(0,n.useCallback)(()=>{e.setValue(t,v.map(e=>e.id),{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})},[v,e,t]),_=(0,n.useCallback)(()=>{const i=new Set(e.getValues(t));return v.length>0&&v.every(e=>i.has(e.id))},[v,e,t]);return n.createElement(u.A,{control:e.control,name:t,options:v,isVirtualized:!0,onSelectAll:p,isAllSelected:_,...f})}}}]);