import{j as l}from"./chunk-JBNKEIUX.js";import"./chunk-5SW267PH.js";import"./chunk-PU7DBJLZ.js";import"./chunk-3DDBG3AR.js";import"./chunk-5MLUVH77.js";import"./chunk-SMMBZMNL.js";import"./chunk-S5GA3KRV.js";import"./chunk-EFONMPAR.js";import"./chunk-YQXLYYOT.js";import"./chunk-6RITFGP2.js";import"./chunk-HGXDKXJP.js";import"./chunk-WQUXAKOL.js";import"./chunk-LYNKRDJC.js";import"./chunk-SKY4LXUD.js";import"./chunk-BZT47AWD.js";import"./chunk-5WQBRAHK.js";import"./chunk-4FTRQKHH.js";import"./chunk-TTWRMELT.js";import"./chunk-EMJ4QQUL.js";import"./chunk-QPCAJSKO.js";import"./chunk-QV67LFVX.js";import"./chunk-4O3FVBGX.js";import{b as O}from"./chunk-TGWIHQDX.js";import{d as s}from"./chunk-Q5KZV54I.js";import{a as F}from"./chunk-YHVRQUSB.js";import"./chunk-3Z7PXZF3.js";import{a as M}from"./chunk-43BLBOSI.js";import"./chunk-IWSLIKCG.js";import"./chunk-2DXJE6G7.js";import"./chunk-7RP244JU.js";import"./chunk-LHGSJXTX.js";import"./chunk-ZKNPBXGB.js";import{b}from"./chunk-S3ADKFO2.js";import{E as C}from"./chunk-I5MYHHJE.js";import{$b as S,Fb as n,Ib as y,S as u,Wa as f,Xc as w,Zb as g,_b as v,f as m,gb as r,lb as h}from"./chunk-CKLXM6EG.js";import{a as d,b as p}from"./chunk-TSRGIXR5.js";var _=class c{constructor(i,e,t,a,o){this.apiService=i;this.route=e;this.translate=t;this.cdr=a;this.toast=o}title;urlApi;translationPrefix="categories";fullWidthFields=["select","input","date","table","radio","textarea","multi-select"];values;categories;isEdit=!1;isShowMode=!1;fields;destroy$=new m;titleOfButton;mainFormComponent;ngOnInit(){this.route.paramMap.subscribe(i=>{let e=i.get("id");this.isShowMode=this.route.snapshot.routeConfig?.path?.includes("show")??!1,this.fields=[{type:"input",title:"name_ar",inputType:"text",class:"col-6",controlName:"name_ar",validators:[s.required,s.maxLength(50)],readOnly:this.isShowMode},{type:"input",title:"name_en",inputType:"text",class:"col-6",controlName:"name_en",validators:[s.required,s.maxLength(50)],readOnly:this.isShowMode},{type:"multi-select",title:"relatedCategory",options:[],class:"col-6",optionsUrl:"procurement/public/category/show-categories-child",controlName:"parent_categories",readOnly:this.isShowMode,nestedName:"category"},{type:"radio",title:"active",controlName:"active",class:"col-6",options:[{name:this.translate.instant("yes"),id:1},{name:this.translate.instant("no"),id:0}],validators:[s.required],readOnly:this.isShowMode,RadioDefaultValue:1}],e?(this.getDetails(e),this.isShowMode?(this.title="show-category",this.urlApi=`procurement/category/show-category/${e}`):(this.isEdit=!0,this.titleOfButton="edit",this.title="edit-category",this.urlApi=`procurement/category/update/${e}`)):(this.isEdit=!1,this.titleOfButton="add",this.title="add-category",this.urlApi="procurement/category/store")}),this.isShowMode}getDetails(i){this.apiService.Get(`procurement/category/show-category/${i}`).pipe(u(this.destroy$)).subscribe(e=>{let t=e.data.parent_categories,a=this.fields.find(o=>o.controlName==="parent_categories");a&&(a.options=t.map(o=>({id:o.id,name:o.name})),this.values=p(d({},e.data.category),{parent_categories:t.map(o=>o.id)}),this.isShowMode&&(a.readOnly=!0),this.isShowMode&&this.fields.push({type:"input",title:"created_at",class:"col-6",controlName:"created_at",readOnly:!0,value:e.data.category.created_at},{type:"input",title:"updated_at",class:"col-6",controlName:"updated_at",readOnly:!0,value:e.data.category.updated_at}),this.cdr.detectChanges())})}static \u0275fac=function(e){return new(e||c)(r(F),r(C),r(b),r(w),r(O))};static \u0275cmp=h({type:c,selectors:[["app-category-actions"]],viewQuery:function(e,t){if(e&1&&g(l,5),e&2){let a;v(a=S())&&(t.mainFormComponent=a.first)}},decls:2,vars:10,consts:[[3,"title","Translationprefix","showTitle","showBreadcrumb"],["routeAfterSuccess","/settings/categories","titleOfButton2","cancel",3,"fields","url","formValues","fullWidthFields","readOnly","titleOfButton"]],template:function(e,t){e&1&&y(0,"app-page-title",0)(1,"app-main-form",1),e&2&&(n("title",t.title)("Translationprefix",t.translationPrefix)("showTitle",!0)("showBreadcrumb",!0),f(),n("fields",t.fields)("url",t.urlApi)("formValues",t.values)("fullWidthFields",t.fullWidthFields)("readOnly",t.isShowMode)("titleOfButton",t.titleOfButton))},dependencies:[M,l],styles:["[_nghost-%COMP%]     .p-multiselect{border-radius:8px!important;background:#e8e8e8b3!important;display:flex;padding:24px!important;border:none!important}"]})};export{_ as CategoryActions};
