import{b as k}from"./chunk-ITBEQ7BR.js";import{A,C as B,V as O,g as D,p as u,s as F,y as _}from"./chunk-VGBLHTO7.js";import{h as x,x as j}from"./chunk-6IEN3EM2.js";import"./chunk-62B4KVUQ.js";import"./chunk-HCYBOTNG.js";import{g as b}from"./chunk-3UGHNNA7.js";import{c as I}from"./chunk-HPZNSLDN.js";import{E as T,F as L,c as w,e as y,f as S}from"./chunk-DBX6XJWC.js";import"./chunk-H2CU6EEU.js";import"./chunk-GK2ZGAUD.js";import"./chunk-4TDNJBFX.js";import"./chunk-NUAVJ2U7.js";import"./chunk-KOATU5RH.js";import"./chunk-XWHKIKFV.js";import"./chunk-PBM4LEG7.js";import"./chunk-QVLAHW2O.js";import"./chunk-TI6NUUOB.js";import"./chunk-LYCHGZAM.js";import{$b as i,Bd as h,Kb as g,Md as C,Qb as p,Sd as M,dd as v,hc as r,ic as a,jc as l,la as E,nd as G,sc as m,t as f,xb as o,yb as c}from"./chunk-PGS4AHIT.js";M();j();S();E();B();G();L();S();M();function R(n,P){if(n&1&&(r(0,"div",3),l(1,"paw-input-field",4),a()),n&2){let e=m(2);o(),i("field",e.inputFields.warningBefore)("model",e.actionModel)("form",e.formGroup)}}function U(n,P){if(n&1&&(r(0,"div",1)(1,"div",2)(2,"div",3),l(3,"paw-input-field",4),a(),r(4,"div",3),l(5,"paw-input-field",4),a(),r(6,"div",3),l(7,"paw-input-field",4),a(),r(8,"div",3),l(9,"paw-input-field",4),a(),p(10,R,2,3,"div",5),a(),r(11,"div",6),l(12,"paw-action",7)(13,"paw-action",7),a()()),n&2){let e=m();o(3),i("field",e.inputFields.description)("model",e.actionModel)("form",e.formGroup),o(2),i("field",e.inputFields.assignedTo)("model",e.actionModel)("form",e.formGroup),o(2),i("field",e.inputFields.deadline)("model",e.actionModel)("form",e.formGroup),o(2),i("field",e.inputFields.warning)("model",e.actionModel)("form",e.formGroup),o(),i("ngIf",e.actionModel.warning),o(2),i("action",e.cancelAction),o(),i("action",e.saveAction)}}var oe=(()=>{class n{constructor(e,t,d,s){this.eventsCalendarService=e,this.authService=t,this.cdr=d,this.translate=s,this.destroy$=new f,this.currentCase=null,this.documentResult=null,this.acLFTask="",this.acUsedTime=0,this.formGroup=new x({}),this.actionModel=this.getDefaultModel(),this.inputFields={}}ngOnInit(){this.initializeModel(),this.setupInputFields()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}getDefaultModel(){return{description:"",assignedTo:[],deadline:new Date,warning:!1,warningBefore:0}}initializeModel(){let e=new Date;e.setDate(e.getDate()+7);let t=this.authService.authUser,d=t?[t.id]:[];this.actionModel={description:"",assignedTo:d,deadline:e,warning:!1,warningBefore:0}}setupInputFields(){let e=!this.acLFTask||this.acLFTask==="";this.inputFields={description:{id:"description",label:"Description",component:u,required:!0},assignedTo:{id:"assignedTo",label:"TaskResponsiblePerson",component:F,searchable:!0,required:!0,multiselect:e,lazyLoad:!0,options:[],apiRequest:t=>this.eventsCalendarService.getOrganizersLookup(t||""),labelMapper:t=>t?.fullname||"",valueMapper:t=>t?.userId,modelToOptionMapper:(t,d)=>t?Array.isArray(t)?t.map(s=>({userId:s,fullname:"",worker:""})):{userId:t,fullname:"",worker:""}:null},deadline:{id:"deadline",label:"To",component:_,required:!0},warning:{id:"warning",label:"Warning",component:A},warningBefore:{id:"warningBefore",label:"NotifyBefore",component:u}},this.cdr.detectChanges()}get saveAction(){return{id:"save",icon:"fas fa-save",label:"Save",title:"Save",type:"mat-raised-button",color:"primary",onSelected:()=>this.handleSave()}}get cancelAction(){return{id:"cancel",icon:"fas fa-times",label:"Cancel",title:"Cancel",type:"mat-button",onSelected:()=>this.handleCancel()}}handleSave(){this.actionModel.description&&this.actionModel.deadline&&this.onSave&&this.onSave(this.actionModel)}handleCancel(){this.onCancel&&this.onCancel()}static{this.\u0275fac=function(t){return new(t||n)(c(k),c(T),c(v),c(w))}}static{this.\u0275cmp=g({type:n,selectors:[["paw-document-action-modal"]],inputs:{currentCase:"currentCase",documentResult:"documentResult",acLFTask:"acLFTask",acUsedTime:"acUsedTime",onSave:"onSave",onCancel:"onCancel"},decls:1,vars:1,consts:[["class","action-modal-content",4,"ngIf"],[1,"action-modal-content"],[1,"form-fields"],[1,"field-row"],[1,"paw-label-width-l",3,"field","model","form"],["class","field-row",4,"ngIf"],[1,"action-buttons"],[3,"action"]],template:function(t,d){t&1&&p(0,U,14,15,"div",0),t&2&&i("ngIf",d.actionModel)},dependencies:[C,h,y,O,D,b,I],styles:[".action-modal-content[_ngcontent-%COMP%]{padding:var(--paw-padding-l);min-height:300px;display:flex;flex-direction:column}.action-modal-content[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]{flex:1}.action-modal-content[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .field-row[_ngcontent-%COMP%]{margin-bottom:var(--paw-margin-l)}.action-modal-content[_ngcontent-%COMP%]   .action-buttons[_ngcontent-%COMP%]{display:flex;justify-content:flex-end;gap:var(--paw-gap-s);padding-top:var(--paw-padding-l);border-top:1px solid var(--paw-color-divider);margin-top:var(--paw-margin-l)}"],changeDetection:0})}}return n})();export{oe as DocumentActionModalComponent};
