"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[7569],{734264:(e,t,a)=>{a.d(t,{R:()=>l});var i=a(887831),n=a(691189),s=a(717905),o=a(93710),r=a(935822);const l=({searchText:e,sortByField:t,sortDirection:a,pageSize:l=o.md,pageNumber:c},d={},u={})=>(0,n.sU)(o.A2,o.gI,{data:{searchText:e,sortByField:t,sortDirection:a,pageSize:l,pageNumber:c},...d},{method:i.A.POST,idField:o.RR,fetchConfig:{getAllPostResponse:!0},additionalPayloadSelector:[s.ar.PAGE_NUMBER,s.ar.TOTAL_PAGE_COUNT,s.ar.TOTAL_ELEMENT_COUNT],compareFunction:r.G,...u})},93710:(e,t,a)=>{a.d(t,{A2:()=>i,RR:()=>s,UE:()=>r,gI:()=>n,iP:()=>l,md:()=>o});const i="sites",n="/v2/api/sites/overview",s="id",o=20;var r;!function(e){e.ASCENDING="ASCENDING",e.DESCENDING="DESCENDING"}(r||(r={}));const l={searchText:"",sortByField:void 0,sortDirection:void 0,pageSize:1e4,pageNumber:0}},935822:(e,t,a)=>{a.d(t,{G:()=>i});const i=({data:e},{data:t})=>e.searchText===t.searchText&&e.sortByField===t.sortByField&&e.sortDirection===t.sortDirection},27307:(e,t,a)=>{a.d(t,{A:()=>r});var i=a(296540),n=a(725508),s=a(313615),o=a(734707);const r=({name:e,className:t,children:a=null,id:r,iconWidth:l,iconHeight:c,size:d="small",variant:u="link",iconSize:E="medium",Icon:C=n.A,omitIconSvgMargin:_=!1,disabled:T=!1,...m})=>{const A=(0,i.useCallback)(e=>e.currentTarget.parentNode.parentNode.childNodes[0].click(),[]);return i.createElement(s.A,{id:r||e,...m},i.createElement(o.Ay,{name:e,size:d,type:"button",variant:u,wrapClassName:t,onClick:A,Icon:C,iconProps:{omitSvgMargin:_,isActive:!0,...l&&{width:l},...c&&{height:c},disabled:T},iconSize:E,disabled:T},a))}},457569:(e,t,a)=>{a.r(t),a.d(t,{default:()=>f});var i=a(296540),n=a(155791),s=a(469733),o=a(418562),r=a(71479),l=a(132196),c=a(980648),d=a(271856),u=a(927099),E=a(459449),C=a(721778),_=a(441652),T=a(323572),m=a(126457),A=a(294303),I=a(675359),N=a(977178),O=a(742920),S=a(566723),p=a(734264),g=a(93710),M=a(367370),h=a(705426),D=a(27307);const v="upload-site-file",b=(0,r.A)("div")`
  max-width: ${336}px;
  overflow: hidden;
  text-overflow: ellipsis;
`,f=({onClose:e})=>{const{formatMessage:t}=(0,E.tz)(),a=(0,s.useDispatch)(),r=(0,i.useRef)(null),{updateNotification:f}=(0,s.useSelector)(N.o),[R,k]=(0,i.useState)(""),[P,w]=(0,i.useState)(""),[y,L]=(0,i.useState)(null),[U,x]=(0,i.useState)(!1),[z,F]=(0,i.useState)(!1),G=(0,i.useCallback)(()=>{y&&(a((0,_.ho)(y.backup_id)),L(null)),a((0,m.AS)()),e?.()},[e,a,y]),H=(0,i.useCallback)(()=>{r.current&&(r.current.value="")},[]),W=(0,i.useCallback)(({target:{value:e}})=>{k(e)},[k]),B=(0,i.useCallback)((e,i)=>{"current"in i&&(r.current=i.current);const n=r.current?.files[0];if(!n)return;F(!0);const s=n.name||"network_site_file",l=(0,o.A)();a((0,I.ox)({id:l,renderTitle:()=>t({id:"COMMON_UPLOADING_FILES"}),downloads:[{id:v,filename:s,progress:0,status:t({id:"COMMON_FILE_UPLOADING"}),onCancel:()=>{a((0,I.uU)(l)),F(!1),H()}}],duration:0,notificationType:"DownloadsToast"})),a((0,_.kI)(n)).then(e=>{f({id:l,title:t({id:"COMMON_UPLOADED_FILES"}),downloads:[{id:v,files:[{filename:s,progress:100,status:t({id:"COMMON_FILE_UPLOADED"})}],onCancel:()=>{}}],duration:2e3,notificationType:"DownloadsToast"});const i=e?.data?.[0]||{};i.purpose===C.L.APPLICATION_BACKUP?(a((0,I.ox)({icon:O.C.warning,message:"COMMON_SITE_SWITCHER_IMPORT_SITE_BACKUP_UPLOADED"})),y&&a((0,_.ho)(i.backup_id))):(L(i),w(n?.name))}).catch(e=>{a((0,I.uU)(l)),H(),a((0,I.ox)({errorMessage:e.msg,errorValues:{...e,fileName:P},icon:O.C.danger,message:"COMMON_SITE_SWITCHED_IMPORT_SITE_ERROR"}))}).finally(()=>{F(!1)})},[a,P,t,H,f,y]),K=(0,i.useCallback)(()=>{x(!0),a(y?(0,T.rA)({newSiteName:R,importedSiteId:y?.backup_id}):(0,T.TG)(R)).then(()=>{a((0,p.R)(g.iP)),a((0,M.N)())}).catch(()=>{a((0,I.ox)({type:O.C.danger,message:"COMMON_SITE_SWITCHER_ADD_SITE_ERROR",values:{name:R}}))}).finally(()=>{G(),x(!1)})},[a,G,y,R]),$=(0,i.useCallback)(()=>{U||G()},[U,G]);return i.createElement(h.A,{title:i.createElement(E.sA,{id:"COMMON_SITE_SWITCHER_ADD_NEW_SITE"}),onRequestClose:$,size:"small",actions:[{type:"button",text:i.createElement(E.sA,{id:"COMMON_ACTION_CANCEL"}),onClick:G,disabled:U},{type:"button",text:i.createElement(E.sA,{id:"COMMON_ACTION_ADD"}),onClick:K,variant:"primary",disabled:!R||U,loader:U?"loading":void 0}],headerClassName:l.AH`
        svg {
          pointer-events: ${U?"none":"cursor"};
        }
      `},i.createElement(c.A,{full:!0,variant:"secondary",label:t({id:"COMMON_SITE_SWITCHER_SITE_NAME"}),onChange:W,value:R,disabled:U}),i.createElement(A.A,{marginTop:S.xO},i.createElement(d.A,{width:220,description:i.createElement(u.A,{centered:!0},i.createElement(E.sA,{id:"COMMON_SITE_SWITCHER_IMPORT_SITE_TOOLTIP"})),portal:!0},i.createElement(D.A,{name:"import-site",size:"large",variant:"inline",iconSize:"original",Icon:n.A,onChange:B,disabled:z||U},i.createElement(b,null,P.length>0?P:i.createElement(E.sA,{id:"COMMON_SITE_SWITCHER_IMPORT_SITE"}))))))}}}]);