import{c as v,d as D,e as B,f as w}from"./chunk-HKJPMV7R.js";import{B as k,i as g}from"./chunk-A32B57A4.js";import{H as f,I as S,J as C}from"./chunk-4EQLHXW7.js";import{Eb as o,Gd as h,Ia as a,Ob as r,Sa as s,ec as l,qc as m,rc as b,tc as d,uc as p,zb as u,zc as c}from"./chunk-JSJB5BKT.js";import{e as y}from"./chunk-SZAW6ZBW.js";var q,L=y(()=>{h();D();C();h();k();w();C();q=(()=>{class e{constructor(t,i){this.isNew=!0,this.disabled=!1,this.type="button",this.onSubmit=new s,this.onClick=new s,this.isSubmitDisabled=!0,this.submitButtonDisabled=!1,t&&(this.parent=t),this.loadingService=i,this.isLoading=!1}ngAfterViewInit(){this.loadingSubscription=this.loadingService.isWorking().subscribe(t=>{t.mode===v.Local&&(this.isLoading=t.isLoading,this.toggleSubmitButton())}),this.parent.form.valueChanges.subscribe(()=>{this.toggleSubmitButton()})}ngAfterContentChecked(){this.isSubmitDisabled=this.submitButtonDisabled}ngOnChanges(t){this.toggleSubmitButton()}submit(){this.type==="button"&&(this.onSubmit.emit(),this.onClick.emit())}ngOnDestroy(){this.loadingSubscription&&this.loadingSubscription.unsubscribe()}toggleSubmitButton(){this.submitButtonDisabled=this.isLoading||!this.isNew&&this.parent.pristine||this.disabled||this.parent.form.invalid}static{this.\u0275fac=function(i){return new(i||e)(o(g,9),o(B))}}static{this.\u0275cmp=r({type:e,selectors:[["sd-submit-button"]],inputs:{isNew:"isNew",disabled:"disabled",parent:"parent",type:"type",label:"label"},outputs:{onSubmit:"onSubmit",onClick:"onClick"},features:[a],decls:2,vars:2,consts:[["styleClass","button-default-footer","type","button",3,"onClick","label","disabled"]],template:function(i,n){i&1&&(d(0),m(1,"p-button",0),c("onClick",function(){return n.submit()}),b(),p()),i&2&&(u(),l("label",n.label)("disabled",n.isSubmitDisabled))},dependencies:[S,f],encapsulation:2})}}return e})()});export{q as a,L as b};
