import{a as j,b as z,c as G}from"./chunk-7WI7JLGR.js";import{a as V}from"./chunk-POEUDRE2.js";import{a as L}from"./chunk-CVDKI2WT.js";import{a as $}from"./chunk-3NMADI5P.js";import"./chunk-POWTZQEB.js";import"./chunk-AZNUVYH2.js";import"./chunk-4SQIPONB.js";import{a as N}from"./chunk-OMYRNWA7.js";import"./chunk-DQZNL7BK.js";import{a as U}from"./chunk-BAEZMG5T.js";import{a as A}from"./chunk-C72E7DYO.js";import"./chunk-WIPHIZE3.js";import{b as R}from"./chunk-LXYD2H4H.js";import"./chunk-IEDTWYT7.js";import"./chunk-TMA5MVRB.js";import"./chunk-VRBUVT76.js";import"./chunk-VUFRXBL5.js";import"./chunk-AG5UR6GS.js";import"./chunk-XXT62TCF.js";import"./chunk-YUC4NXDM.js";import"./chunk-6P3ZDNP3.js";import"./chunk-VP22RGQG.js";import"./chunk-3FDFNYAA.js";import"./chunk-3HDMTDNY.js";import"./chunk-YR6PJKN6.js";import"./chunk-HVO2LBIZ.js";import"./chunk-JU53QNJX.js";import"./chunk-EMJJQSXR.js";import"./chunk-2G4GCCRX.js";import"./chunk-KAJE4RE3.js";import"./chunk-H6QVTBMZ.js";import"./chunk-XNR6WIGX.js";import"./chunk-5KOP4ULD.js";import"./chunk-F2X3VGZZ.js";import"./chunk-RYV2RH4B.js";import"./chunk-CV2ZWZQE.js";import"./chunk-R2UR7BVM.js";import{b as w,j as T,q as k,t as I}from"./chunk-HKLJ6VPZ.js";import"./chunk-MQ46LYK7.js";import{b as E,c as B}from"./chunk-PQ5Q7HJL.js";import"./chunk-72CHOCZD.js";import{Ab as v,Cb as P,Db as C,Eb as o,Fb as r,G as h,Gb as u,Kb as M,O as F,Pb as D,Qb as l,Ua as a,_a as f,ac as c,cc as m,ea as b,f as x,fa as y,gb as S,mb as _,mc as O,tb as p,vc as s,wc as d,zb as g}from"./chunk-56X5LYJH.js";import"./chunk-TSRGIXR5.js";var K=i=>[i];function Q(i,t){if(i&1&&(u(0,"app-error-card",2),s(1,"translate")),i&2){let e=l();p("message",d(1,1,e.errorMessage))}}function W(i,t){i&1&&u(0,"app-empty-card",3)}function X(i,t){if(i&1){let e=M();o(0,"div",6)(1,"span",8),c(2),s(3,"translate"),r(),o(4,"span",9),c(5),s(6,"translate"),r(),o(7,"app-form-modal",10),D("resValue",function(H){b(e);let J=l(3);return y(J.updateStatus(H))}),r()()}if(i&2){let e=l().$implicit,n=l(2);a(2),m("",d(3,5,e.label),":"),a(2),p("ngClass",n.period==null?null:n.period.status),a(),m(" ",e.value||d(6,7,"financialPeriods.no_note")," "),a(2),p("fields",n.changeStatusFields)("apiUrl",n.changeStatusUrl)}}function Y(i,t){if(i&1&&(o(0,"div",7)(1,"span",8),c(2),s(3,"translate"),r(),o(4,"span",11),c(5),s(6,"translate"),r()()),i&2){let e=l().$implicit;a(2),m("",d(3,2,e.label),":"),a(3),m(" ",e.value||d(6,4,"financialPeriods.no_note")," ")}}function Z(i,t){if(i&1&&_(0,X,8,9,"div",6)(1,Y,7,6,"div",7),i&2){let e=t.$implicit;g(e.label==="financialPeriods.status"?0:1)}}function ee(i,t){if(i&1&&(o(0,"div",5),u(1,"i",12),o(2,"a",13),c(3),s(4,"translate"),r()()),i&2){let e=t.$implicit,n=l(2);a(2),p("routerLink",O(5,K,e.route))("relativeTo",n.route),a(),m(" ",d(4,3,e.name),`
`)}}function ie(i,t){if(i&1&&(o(0,"div",4),P(1,Z,2,1,null,null,v),P(3,ee,5,7,"div",5,v),r()),i&2){let e=l();a(),C(e.periodFields),a(2),C(e.actions)}}var q=class i{constructor(t,e){this.route=t;this.apiService=e}period;periodFields=[];actions=[{name:"financialPeriods.activity_log",route:"activity-log"},{name:"financialPeriods.review_report",route:"review-report"},{name:"financialPeriods.unlock_log",route:"unlock-log"}];loading=!0;errorMessage=null;destroy$=new x;periodEndPoint="financial-periods";FinancialPeriodStatus=j;changeStatusFields=[];ngOnInit(){this.loadPeriodFromRoute()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}loadPeriodFromRoute(){let t=this.route.snapshot.paramMap.get("id"),e=Number(t);if(!t||isNaN(e)){console.error("Invalid or missing period id in route");return}this.loadDetail(e)}buildModalField(t){this.changeStatusFields=G(t)}loadDetail(t){this.loading=!1,this.apiService.GetById(this.periodEndPoint,t).pipe(F(this.destroy$),h(()=>this.loading=!0)).subscribe({next:e=>{e.status&&e.data?(this.period=e.data,this.buildPeriodFields(),this.buildModalField(e.data.status)):(this.period=void 0,this.errorMessage=e.message||"periodEndPoint.no_data")},error:e=>{this.period=void 0,this.errorMessage="financialPeriods.api_error",console.error("API error:",e)}})}statusOptions=z;get changeStatusUrl(){return`financial-periods/changeStatus/${this.period.id}`}buildPeriodFields(){this.period&&(this.periodFields=[{label:"financialPeriods.name",value:this.period.name},{label:"financialPeriods.from",value:this.period.from},{label:"financialPeriods.to",value:this.period.to},{label:"financialPeriods.status",value:this.period.status},{label:"financialPeriods.description",value:this.period.description},{label:"financialPeriods.facility",value:this.period.facility},{label:"financialPeriods.created_by",value:this.period.created_by},{label:"financialPeriods.modified_by",value:this.period.modified_by}])}updateStatus(t){this.period=t,this.buildPeriodFields()}static \u0275fac=function(e){return new(e||i)(f(k),f(A))};static \u0275cmp=S({type:i,selectors:[["app-financial-periods-details"]],decls:5,vars:2,consts:[["title","details_title","imageSrc","assets/images/addNewPeriod.png","Translationprefix","financialPeriods"],["appShowLoaderUntilPageLoaded","",1,"pt-2",3,"isReady"],[3,"message"],["message","financialPeriods.no_data"],[1,"financial-period-card"],[1,"cell","justify-content-start"],[1,"cell","status-cell"],[1,"cell"],[1,"label"],[1,"value","status-icon",3,"ngClass"],["titleOfButton","send","icon","fa-pen-to-square fa-solid","titleOfbutton","changeStatus","headerOfModal","CHANGE_REASON","translationPrefix","financialPeriods",3,"resValue","fields","apiUrl"],[1,"value"],[1,"pi","pi-file-edit"],[1,"activity",3,"routerLink","relativeTo"]],template:function(e,n){e&1&&(u(0,"app-page-title",0),o(1,"div",1),_(2,Q,2,3,"app-error-card",2)(3,W,1,0,"app-empty-card",3)(4,ie,5,0,"div",4),r()),e&2&&(a(),p("isReady",n.loading),a(),g(n.errorMessage?2:n.period?4:3))},dependencies:[B,E,I,R,T,w,N,U,V,L,$],styles:[".label[_ngcontent-%COMP%]{color:var(--dark);font-weight:500;font-size:20px}.value[_ngcontent-%COMP%]{color:var(--light);font-weight:400;font-size:20px}.cell[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px}.financial-period-card[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(auto-fill,minmax(400px,1fr));gap:24px 140px}.status-icon[_ngcontent-%COMP%]{padding:0 50px;border-radius:20px}.status-icon.open[_ngcontent-%COMP%]{color:var(--success);background-color:#4caf5026}.status-icon.draft[_ngcontent-%COMP%]{color:var(--Normal);background-color:#fbbc052e}.status-icon.restricted[_ngcontent-%COMP%]{color:var(--update);background-color:#ff98002e}.status-icon.closed[_ngcontent-%COMP%]{color:var(--error);background-color:#f443362e}.status-icon.hard_locked[_ngcontent-%COMP%]{color:var(--primary);background-color:#9c27b02e}.activity[_ngcontent-%COMP%]{font-weight:500;font-size:20px;text-decoration:underline;color:var(--dark);text-transform:capitalize}"]})};export{q as FinancialPeriodsDetailsComponent};
