1import{a as ee}from"./chunk-S5N3GRVN.js";import{a as $}from"./chunk-62SF4JCA.js";import"./chunk-SEX2LCJO.js";import{a as Z}from"./chunk-JB2BA5YO.js";import{a as J}from"./chunk-L42JBMHJ.js";import"./chunk-MCW2XNIN.js";import{B as Q,C as U,F as X,G as Y,x as K}from"./chunk-4FQZK2NZ.js";import{a as G}from"./chunk-T6IJJEFG.js";import"./chunk-7WL3BACO.js";import"./chunk-7ZQPNQNT.js";import{a as k}from"./chunk-JZ4VMR3W.js";import{b as D,e as O,f as P,g as B,h as L,i as W,j as N,p as R,q,t as j,v as z}from"./chunk-2Z6S4T4X.js";import"./chunk-5AZYVR57.js";import{b as I,d as H}from"./chunk-RDF3JGCK.js";import"./chunk-7TOIXNST.js";import"./chunk-HNCLXARL.js";import{Db as A,Eb as a,Fb as o,Fc as w,Lb as F,Pb as u,Rb as f,Xa as r,Yc as T,Zc as V,cc as S,db as g,dc as d,ec as p,ga as C,ha as v,ic as h,jb as M,jc as y,kc as _,qc as m,rc as s,ta as b,xb as x,yb as E}from"./chunk-QUDZOOIP.js";function ie(c,l){if(c&1){let e=F();a(0,"mat-form-field",3)(1,"mat-label"),d(2),m(3,"translate"),o(),a(4,"input",14),_("ngModelChange",function(i){C(e);let n=f();return y(n.titleFr,i)||(n.titleFr=i),v(i)}),o()(),a(5,"mat-form-field",3)(6,"mat-label"),d(7),m(8,"translate"),o(),a(9,"textarea",15),_("ngModelChange",function(i){C(e);let n=f();return y(n.contentFr,i)||(n.contentFr=i),v(i)}),o()()}if(c&2){let e=f();r(2),p(s(3,4,"AdminHelpArticles.FieldTitle")),r(2),h("ngModel",e.titleFr),r(3),p(s(8,6,"AdminHelpArticles.FieldContent")),r(2),h("ngModel",e.contentFr)}}function ne(c,l){if(c&1){let e=F();a(0,"mat-form-field",3)(1,"mat-label"),d(2),m(3,"translate"),o(),a(4,"input",16),_("ngModelChange",function(i){C(e);let n=f();return y(n.titleEn,i)||(n.titleEn=i),v(i)}),o()(),a(5,"mat-form-field",3)(6,"mat-label"),d(7),m(8,"translate"),o(),a(9,"textarea",17),_("ngModelChange",function(i){C(e);let n=f();return y(n.contentEn,i)||(n.contentEn=i),v(i)}),o()()}if(c&2){let e=f();r(2),p(s(3,4,"AdminHelpArticles.FieldTitle")),r(2),h("ngModel",e.titleEn),r(3),p(s(8,6,"AdminHelpArticles.FieldContent")),r(2),h("ngModel",e.contentEn)}}var te=class c{constructor(l,e,t,i,n,re,ae){this.snackbar=l;this.route=e;this.router=t;this.helpArticlesService=i;this.confirmDialog=n;this.translate=re;this.cdr=ae}snackbar;route;router;helpArticlesService;confirmDialog;translate;cdr;editingId=null;loading=b(!1);busy=b(!1);activeLang=b("fr");category="";titleFr="";titleEn="";contentFr="";contentEn="";isVisible=!0;displayOrder=1;isPlatformAdminOnly=!1;ngOnInit(){let l=this.route.snapshot.paramMap.get("id");l&&(this.editingId=l,this.loading.set(!0),this.helpArticlesService.getById(l).subscribe({next:e=>{this.loading.set(!1),e&&(this.category=e.category,this.titleFr=e.titleFr,this.titleEn=e.titleEn,this.contentFr=e.contentFr,this.contentEn=e.contentEn,this.isVisible=e.isVisible,this.displayOrder=e.displayOrder,this.isPlatformAdminOnly=e.isPlatformAdminOnly,this.cdr.detectChanges())},error:()=>this.loading.set(!1)}))}hasRequiredContent(){return!!(this.category.trim()&&this.titleFr.trim()&&this.titleEn.trim()&&this.contentFr.trim()&&this.contentEn.trim())}save(){if(this.busy())return;if(!this.hasRequiredContent()){this.snackbar.error(this.translate.instant("AdminHelpArticles.MissingFields"));return}this.busy.set(!0);let l={category:this.category.trim(),titleFr:this.titleFr.trim(),titleEn:this.titleEn.trim(),contentFr:this.contentFr.trim(),contentEn:this.contentEn.trim(),isVisible:this.isVisible,displayOrder:this.displayOrder,isPlatformAdminOnly:this.isPlatformAdminOnly};(this.editingId?this.helpArticlesService.update(this.editingId,l):this.helpArticlesService.create(l)).subscribe({next:()=>this.router.navigate(["/admin/help/manage"]),error:t=>{this.busy.set(!1),this.snackbar.error(t?.error?.error??this.translate.instant("AdminHelpArticles.SaveFailed"))}})}async delete(){!this.editingId||this.busy()||!await this.confirmDialog.confirm({title:this.translate.instant("Common.ConfirmDeleteTitle"),message:this.translate.instant("AdminHelpArticles.ConfirmDelete"),confirmLabel:this.translate.instant("Common.Delete"),variant:"danger"})||(this.busy.set(!0),this.helpArticlesService.delete(this.editingId).subscribe({next:()=>this.router.navigate(["/admin/help/manage"]),error:e=>{this.busy.set(!1),this.snackbar.error(e?.error?.error??this.translate.instant("AdminHelpArticles.DeleteFailed"))}}))}static \u0275fac=function(e){return new(e||c)(g(G),g(I),g(H),g(ee),g(k),g(T),g(w))};static \u0275cmp=M({type:c,selectors:[["app-admin-help-article-form"]],decls:35,vars:31,consts:[[1,"mx-auto","w-full","max-w-[1180px]","px-3","py-4","sm:px-6","sm:py-6"],["backLink","/admin/help/manage",3,"title"],[1,"grid","gap-5",3,"ngSubmit"],["appearance","outline","subscriptSizing","dynamic",1,"w-full"],["matInput","","name","category","maxlength","100","required","",3,"ngModelChange","ngModel","placeholder"],[1,"flex","gap-2","border-b","border-line"],["type","button",1,"border-b-2","px-3","pb-2.5","text-[0.9rem]","font-bold","transition-colors",3,"click"],[1,"flex","flex-wrap","items-end","gap-6"],["appearance","outline","subscriptSizing","dynamic",1,"w-full","sm:w-40"],["matInput","","name","displayOrder","type","number","min","1",3,"ngModelChange","ngModel"],[1,"flex","items-center","gap-3","py-1"],[3,"checkedChange","checked"],[1,"text-[13px]","font-medium","text-gray-700"],["cancelLink","/admin/help/manage",3,"remove","saving","canDelete"],["matInput","","name","titleFr","maxlength","300","required","",3,"ngModelChange","ngModel"],["matInput","","name","contentFr","rows","10","required","",3,"ngModelChange","ngModel"],["matInput","","name","titleEn","maxlength","300","required","",3,"ngModelChange","ngModel"],["matInput","","name","contentEn","rows","10","required","",3,"ngModelChange","ngModel"]],template:function(e,t){e&1&&(a(0,"main",0)(1,"app-form-page",1),m(2,"translate"),m(3,"translate"),a(4,"form",2),u("ngSubmit",function(){return t.save()}),a(5,"mat-form-field",3)(6,"mat-label"),d(7),m(8,"translate"),o(),a(9,"input",4),m(10,"translate"),_("ngModelChange",function(n){return y(t.category,n)||(t.category=n),n}),o()(),a(11,"div",5)(12,"button",6),u("click",function(){return t.activeLang.set("fr")}),d(13,"Fran\xE7ais"),o(),a(14,"button",6),u("click",function(){return t.activeLang.set("en")}),d(15,"English"),o()(),x(16,ie,10,8)(17,ne,10,8),a(18,"div",7)(19,"mat-form-field",8)(20,"mat-label"),d(21),m(22,"translate"),o(),a(23,"input",9),_("ngModelChange",function(n){return y(t.displayOrder,n)||(t.displayOrder=n),n}),o()(),a(24,"div",10)(25,"app-toggle",11),u("checkedChange",function(n){return t.isVisible=n}),o(),a(26,"span",12),d(27),m(28,"translate"),o()(),a(29,"div",10)(30,"app-toggle",11),u("checkedChange",function(n){return t.isPlatformAdminOnly=n}),o(),a(31,"span",12),d(32),m(33,"translate"),o()()(),a(34,"app-form-actions",13),u("remove",function(){return t.delete()}),o()()()()),e&2&&(r(),A("title",t.editingId?s(2,17,"AdminHelpArticles.EditTitle"):s(3,19,"AdminHelpArticles.NewTitle")),r(6),p(s(8,21,"AdminHelpArticles.FieldCategory")),r(2),h("ngModel",t.category),A("placeholder",s(10,23,"AdminHelpArticles.CategoryPlaceholder")),r(3),S(t.activeLang()==="fr"?"border-primary text-primary":"border-transparent text-muted"),r(2),S(t.activeLang()==="en"?"border-primary text-primary":"border-transparent text-muted"),r(2),E(t.activeLang()==="fr"?16:17),r(5),p(s(22,25,"AdminContacts.FieldDisplayOrder")),r(2),h("ngModel",t.displayOrder),r(2),A("checked",t.isVisible),r(2),p(s(28,27,"AdminContacts.FieldVisible")),r(3),A("checked",t.isPlatformAdminOnly),r(2),p(s(33,29,"AdminHelpArticles.FieldPlatformAdminOnly")),r(2),A("saving",t.busy())("canDelete",!!t.editingId))},dependencies:[z,W,D,N,O,P,q,j,R,L,B,Z,$,J,U,Q,K,Y,X,V],encapsulation:2})};export{te as AdminHelpArticleFormComponent};
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.