import{bD as Z,bE as k,bF as H,bG as T,bH as V,bI as $,aj as L,bJ as J,c as K,a as Q,b as i,bK as W,b2 as q,b1 as X,bL as Y,bM as U,bN as ee,b3 as te,bO as se,bP as ae,bQ as ne,bR as oe,r as F,bx as ce,u as ie,bS as le,bT as re,bU as de,bV as ue,j as g,a2 as B,bj as O,bW as ve,V as be}from"./index-BSsexBJO.js";const pe=async({setSaveType:e,currentEvent:t,dispatch:s,calendarsGroup:c,loadMaterials:d,id:u,date:a,setIsLoaderData:p,navigate:m,user:l})=>{if(Number(u)===Z)return;e(t.resource.saveType||k.Save);const v=await s(H({id:Number(u),calendarsGroup:c,startDate:new Date(a),isAllDay:!1,isUtc:!0})),{payload:n}=v;if(!n){m("/");return}const{AccessType:b}=n||{};((n==null?void 0:n.OrganizerId)===(l==null?void 0:l.ContactId)||b!==T.FreeBusy&&b!==T.Read)&&(n!=null&&n.HasMaterials)&&await d(),p(!1)},fe=async({event:e,currentUser:t,dispatch:s,id:c})=>{const{accessType:d,ownerId:u,organizerId:a}=e.resource,p=u===(t==null?void 0:t.Id)||a===(t==null?void 0:t.ContactId);if(!((d===T.FreeBusy||d===T.Read)&&!p&&(u!==void 0||a!==void 0)))try{const{payload:l}=await s(V(Number(c)));if(e.resource.ownerId!==(t==null?void 0:t.Id))return;const v=$(l,t);if(L.isEmpty(v))return;const n=v.map(({id:b})=>b);await s(J(n))}catch{}},Ee=()=>{const e=K.c(41),t=Q(),s=i(W),c=i(q),d=i(X),u=i(Y),a=i(U),p=i(ee),m=i(te),l=i(se),v=i(ae),n=i(ne),b=i(oe),[h,N]=F.useState(k.Save),[I,_]=F.useState(!0),E=ce(),{isMobile:z}=ie(),{id:o,date:f}=le(),w=o!==void 0;let S;e[0]!==t||e[1]!==E?(S=()=>{t(re()),t(de()),E("/")},e[0]=t,e[1]=E,e[2]=S):S=e[2];const j=S;let D;e[3]!==s||e[4]!==a||e[5]!==t||e[6]!==o?(D=()=>{fe({event:s,currentUser:a,dispatch:t,id:Number(o)})},e[3]=s,e[4]=a,e[5]=t,e[6]=o,e[7]=D):D=e[7];const C=D;let x;e[8]!==c||e[9]!==s||e[10]!==a||e[11]!==f||e[12]!==t||e[13]!==o||e[14]!==C||e[15]!==E?(x=()=>{if(!(!o&&f)){const{pathname:P,search:G}=window.location;if(P==="/event/new_event"){t(ue({search:G,calendarsGroup:c}));return}pe({setSaveType:N,currentEvent:s,dispatch:t,calendarsGroup:c,loadMaterials:C,id:Number(o),date:f,setIsLoaderData:_,navigate:E,user:a})}},e[8]=c,e[9]=s,e[10]=a,e[11]=f,e[12]=t,e[13]=o,e[14]=C,e[15]=E,e[16]=x):x=e[16];let A;if(e[17]!==f||e[18]!==o?(A=[o,f],e[17]=f,e[18]=o,e[19]=A):A=e[19],F.useEffect(x,A),L.isEmpty(d)){let r;return e[20]===Symbol.for("react.memo_cache_sentinel")?(r=g.jsx(B,{w:"100%",h:"100vh",align:"center",justify:"center",children:g.jsx(O,{})}),e[20]=r):r=e[20],r}if(w&&o!==(s==null?void 0:s.id)){let r;return e[21]===Symbol.for("react.memo_cache_sentinel")?(r=g.jsx(B,{w:"100%",h:"100vh",align:"center",justify:"center",children:g.jsx(O,{})}),e[21]=r):r=e[21],r}const R=z?10:20;let y;e[22]!==n||e[23]!==d||e[24]!==c||e[25]!==u||e[26]!==s||e[27]!==p||e[28]!==a||e[29]!==j||e[30]!==w||e[31]!==I||e[32]!==b||e[33]!==h||e[34]!==v||e[35]!==l||e[36]!==m?(y=g.jsx(ve,{edit:w,handleCloseCreateEventModal:j,calendarList:d,currentEvent:s,calendarsGroup:c,currentAddConfigStatus:u,currentUser:a,saveType:h,setSaveType:N,isLoaderData:I,currentEventStatus:p,timeZones:m,timeZone:l,submitEvent:v,calendarDisplayedDatesRange:n,openedDeletedRecurringActionModal:b}),e[22]=n,e[23]=d,e[24]=c,e[25]=u,e[26]=s,e[27]=p,e[28]=a,e[29]=j,e[30]=w,e[31]=I,e[32]=b,e[33]=h,e[34]=v,e[35]=l,e[36]=m,e[37]=y):y=e[37];let M;return e[38]!==R||e[39]!==y?(M=g.jsx(be,{w:"100%",px:R,children:y}),e[38]=R,e[39]=y,e[40]=M):M=e[40],M};export{Ee as default};
