1import{a as d}from"./chunk-MV5KNM6A.js";import"./chunk-WJY6HROL.js";import"./chunk-2GHFED2S.js";import"./chunk-WCL72VCC.js";import"./chunk-BYXBJQAS.js";import"./chunk-7AAUCWQR.js";import{f as B}from"./chunk-FBTFUOPC.js";import"./chunk-LNP67U4I.js";import"./chunk-GX4UVFWP.js";import"./chunk-ZOXOJ2SW.js";import"./chunk-75FPLXLX.js";import"./chunk-AQBRTEMP.js";import"./chunk-GCZ3C3HM.js";import"./chunk-QGUVMJOM.js";import"./chunk-UWTSORKH.js";import"./chunk-XMQL2ZPB.js";import"./chunk-2NWUFIXC.js";import"./chunk-KADQP2XK.js";import"./chunk-ECMF7CC2.js";import"./chunk-C4XHNRNH.js";import"./chunk-Z36TISWV.js";import"./chunk-XM23J7BA.js";import"./chunk-WH6ILIPS.js";import"./chunk-LKIIPTIG.js";import"./chunk-INMDLS22.js";import"./chunk-AJZMXFMA.js";import{e as V,f as _,r as L,s as U,z as H}from"./chunk-YE7HTOLI.js";import"./chunk-NZ4I6U2Z.js";import{b as O}from"./chunk-23N7CA4O.js";import"./chunk-NGAT3XSV.js";import"./chunk-6DMACB4X.js";import"./chunk-C5J3HTKX.js";import"./chunk-W4BNGQYG.js";import"./chunk-OSVOK6WL.js";import"./chunk-WXXKR7LF.js";import"./chunk-R2NO6V5K.js";import"./chunk-FV2Q4OA6.js";import"./chunk-QPZCEWML.js";import"./chunk-L44SDTPC.js";import"./chunk-CLQP3QCS.js";import"./chunk-TWVMK4TV.js";import"./chunk-EGNI2XJ3.js";import"./chunk-A3N634GV.js";import"./chunk-F457L6VT.js";import"./chunk-6BC3ZOBR.js";import"./chunk-4U4PLY73.js";import"./chunk-RQ4F2COW.js";import"./chunk-7RWCIHFI.js";import"./chunk-GP7G4HVV.js";import"./chunk-X5ROTD3U.js";import{a as I}from"./chunk-V4NS6LW3.js";import"./chunk-VFTYDXHH.js";import"./chunk-LJSWAOQY.js";import"./chunk-RFPVTC6I.js";import{b as F}from"./chunk-SPFBMSSO.js";import"./chunk-TZOYHBJT.js";import"./chunk-34KEMFZC.js";import"./chunk-4BUGZAA4.js";import"./chunk-3TCRHIAB.js";import"./chunk-76JNFTGE.js";import{g as n,l as E}from"./chunk-C7VFP4N4.js";import"./chunk-CYMQMRSQ.js";import{B as P,j as k}from"./chunk-SAPP7HDL.js";import"./chunk-YJOTM47P.js";import"./chunk-2PJAPLDY.js";import"./chunk-UQ5LDOFJ.js";import"./chunk-C2CO7BOS.js";import"./chunk-UVTXHEDZ.js";import"./chunk-3APTCJCW.js";import"./chunk-KDTKTPR2.js";import{a as M,c as D}from"./chunk-TPWGF6XO.js";import{$a as a,A as u,Ic as v,Kd as w,Lb as f,Qa as p,S as h,Tb as C,Uc as T,Vc as R,Xa as S,Ya as l,ha as g,lc as y,xa as s,xc as A,yc as b}from"./chunk-MH4BPXDL.js";import{l as o}from"./chunk-CU44V7JF.js";var ne=(()=>{let r=class r{constructor(){this.generalSettingsFormService=s(B),this.calendarSettingsService=s(H),this.calendarSettingsFactoryService=s(U),this.vdsToastService=s(O),this.translation=s(I),this.destroyRef=s(p),this.trackingErrorCore=s(F),this.collaborator=l.required(),this.isMobileScreen=l(!1),this.hideHeader=l(!0),this.showCopySettingsButton=l(!1),this.copySettingsClicked=S(),this.generalPanel=f(d),this.form=this.generalSettingsFormService.buildForm(),this.selectedDays=D(this.form.controls.selectableDaysForAppointments.valueChanges.pipe(g(this.form.controls.selectableDaysForAppointments.value),u(e=>e??[])),{initialValue:[]}),this.loading=a(!0),this.calendarSettings=a(void 0),this.appointmentTimeRange=a(void 0),this.weeklyAppointmentTimes=a(void 0),this.customScheduleTypes=a(void 0),this.defaultCalendarSettings=a(void 0),this.customAddressLocations=a(void 0),this.initialAgendaViewSelectorSettings=a(""),this.automaticReminderMessageCalendar=a(void 0),this.canShowSuccessSubmitMessage=a(!1),this.componentLoaded=a(!1),this.automaticReminderParameters=a([]),this.isAutomaticReminderCalendarEnabled=a(!0),this.currentCollaboratorOccupation=a(""),this.currentCollaboratorRegister=a(""),this.collaboratorSubtitle=w(()=>{let e=[],i=this.currentCollaboratorOccupation(),t=this.currentCollaboratorRegister();return i&&e.push(i),t&&e.push(`(${t})`),e.join(" ")})}ngOnInit(){return o(this,null,function*(){yield this.translation.loaded(),this.initializeAutomaticReminderParameters(),yield this.load()})}load(){return o(this,null,function*(){this.loading.set(!0);try{yield this.loadCollaboratorInfo(),yield this.loadCalendarSettingsAndPopulate(),this.componentLoaded.set(!0),this.listen()}finally{setTimeout(()=>{this.canShowSuccessSubmitMessage.set(!0),this.loading.set(!1)},2e3)}})}
1listen(){this.form.valueChanges.pipe(h(400),M(this.destroyRef)).subscribe(()=>{this.componentLoaded()&&this.submit()})}loadCollaboratorInfo(){return o(this,null,function*(){let e=this.collaborator();this.currentCollaboratorOccupation.set(e.occupations?.length?yield E(this.translation,e.occupations[0]):""),this.currentCollaboratorRegister.set(e.register?.value??"")})}loadCalendarSettingsAndPopulate(){return o(this,null,function*(){let e=this.collaborator(),i=yield this.calendarSettingsService.get({userVediusKey:e.key});if(this.calendarSettings.set(i),!i){let m=new Error("Calendar settings not found");this.trackingErrorCore.onCaptureException(m),this.vdsToastService.error(this.translation.get(n.ToastDefaultErrorTitle));return}let t=this.generalSettingsFormService.populateForm(this.form,i);this.initialAgendaViewSelectorSettings.set(t.initialAgendaViewSelectorSettings),this.appointmentTimeRange.set(t.appointmentTimeRange),this.weeklyAppointmentTimes.set(t.weeklyAppointmentTimes),this.customScheduleTypes.set(t.customScheduleTypes),this.customAddressLocations.set(t.customAddressLocations),this.automaticReminderMessageCalendar.set(t.automaticReminderMessageCalendar),this.defaultCalendarSettings.set(this.calendarSettingsFactoryService.createDefault(e))})}submit(){if(this.loading())return;if(this.generalPanel()?.customLocalAddressPartialForm()?.formHasErrors()){this.vdsToastService.error(this.translation.get(n.ToastDefaultUpdateAutomaticallyTitleError),this.translation.get(n.ToastDefaultUpdateAutomaticallyDescriptionError));return}if(!this.form.valid){this.hasInvalidInteractedControl(this.form)&&this.vdsToastService.error(this.translation.get(n.ToastDefaultUpdateAutomaticallyTitleError),this.translation.get(n.ToastDefaultUpdateAutomaticallyDescriptionError));return}let{calendarSettings:e,automaticReminderMessageCalendar:i}=this.generalSettingsFormService.buildCalendarSettings({form:this.form,user:this.collaborator(),generalPanel:this.generalPanel(),reminderMessagePartialForm:void 0,loadedCalendarSettings:this.calendarSettings(),isAutomaticReminderCalendarEnabled:this.isAutomaticReminderCalendarEnabled(),automaticReminderParameters:this.automaticReminderParameters(),automaticReminderMessageCalendar:this.ensureAutomaticReminderCalendar()});this.automaticReminderMessageCalendar.set(i),this.calendarSettingsService.saveSync({calendarSettings:e}),this.canShowSuccessSubmitMessage()&&this.showSaveToastMessage()}showSaveToastMessage(){this.vdsToastService.success(this.translation.get(n.AgendaSettingsSavedMessage))}initializeAutomaticReminderParameters(){this.automaticReminderParameters.set(V.map(e=>{let i=this.translation.get(`${n.AgendaReminderMessages}.${e}`);return new _(e,i)}))}hasInvalidInteractedControl(e){if(e.invalid&&(e.touched||e.dirty))return!0;if(e instanceof k)for(let i of Object.keys(e.controls)){let t=e.get(i);if(t&&this.hasInvalidInteractedControl(t))return!0}else if(e instanceof P){for(let i of e.controls)if(this.hasInvalidInteractedControl(i))return!0}return!1}ensureAutomaticReminderCalendar(){let e=this.automaticReminderMessageCalendar();return e||(e=L.createDefault(),this.automaticReminderMessageCalendar.set(e)),e}};r.\u0275fac=function(i){return new(i||r)},r.\u0275cmp=C({type:r,selectors:[["app-agenda-general-settings-container"]],viewQuery:function(i,t){i&1&&T(t.generalPanel,d,5),i&2&&R()},inputs:{collaborator:[1,"collaborator"],isMobileScreen:[1,"isMobileScreen"],hideHeader:[1,"hideHeader"],showCopySettingsButton:[1,"showCopySettingsButton"]},outputs:{copySettingsClicked:"copySettingsClicked"},decls:1,vars:14,consts:[[3,"copySettingsClicked","form","loading","isMobileScreen","hideHeader","currentUserVedius","collaboratorSubtitle","showCopySettingsButton","appointmentTimeRange","weeklyAppointmentTimes","selectedDays","customScheduleTypes","defaultCalendarSettings","customAddressLocations","initialAgendaViewSelectorSettings"]],template:function(i,t){i&1&&(A(0,"app-agenda-general-settings-panel",0),v("copySettingsClicked",function(){return t.copySettingsClicked.emit()}),b()),i&2&&y("form",t.form)("loading",t.loading())("isMobileScreen",t.isMobileScreen())("hideHeader",t.hideHeader())("currentUserVedius",t.collaborator())("collaboratorSubtitle",t.collaboratorSubtitle())("showCopySettingsButton",t.showCopySettingsButton())("appointmentTimeRange",t.appointmentTimeRange())("weeklyAppointmentTimes",t.weeklyAppointmentTimes())("selectedDays",t.selectedDays())("customScheduleTypes",t.customScheduleTypes())("defaultCalendarSettings",t.defaultCalendarSettings())("customAddressLocations",t.customAddressLocations())("initialAgendaViewSelectorSettings",t.initialAgendaViewSelectorSettings())},dependencies:[d],styles:[`:host{display:block} 2`],encapsulation:2,changeDetection:0});let c=r;return c})();export{ne as AgendaGeneralSettingsContainerComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.