1import{a as yt}from"./chunk-J56CX3TI.js";import{f as _t}from"./chunk-F5GF4DFP.js";import"./chunk-KOQIKQ66.js";import"./chunk-VGHX6RVZ.js";import"./chunk-XOFR5VDT.js";import"./chunk-D6GIXJHU.js";import"./chunk-V6JIWBIY.js";import"./chunk-TVKUJHCJ.js";import"./chunk-AZV6ART2.js";import{a as vt}from"./chunk-X3TBMCDT.js";import{b as gt}from"./chunk-7VCEAD4J.js";import"./chunk-ZXBSDFP3.js";import"./chunk-I6W6JKOL.js";import{ca as St}from"./chunk-5FOTDUDB.js";import"./chunk-FRFVJ72T.js";import"./chunk-5CSIGGSU.js";import{f as ht}from"./chunk-MGZLJECP.js";import"./chunk-LYSGAG4P.js";import"./chunk-VJSMSKCS.js";import"./chunk-6URCNC7N.js";import{a as at}from"./chunk-O4EO7MHO.js";import{a as pt,b as ft,c as Ct}from"./chunk-WUO4YCLL.js";import"./chunk-RAWUH2QX.js";import{i as rt,k as ot,l as st,q as lt,r as ct,t as mt,u as dt,v as ut}from"./chunk-DBTMC7UN.js";import"./chunk-NRQPG2H7.js";import"./chunk-OGGGMJSN.js";import{Kc as pe,ba as it,kc as ce}from"./chunk-5P3AN2OS.js";import{P as nt}from"./chunk-KUZG56OI.js";import"./chunk-HGZSA7RT.js";import"./chunk-RS3SWHRI.js";import"./chunk-CBCKS6VK.js";import{e as le}from"./chunk-645XG2RC.js";import{C as se,k as oe,l as tt}from"./chunk-VOTWYUYF.js";import{$a as a,$d as X,Ae as Z,Bf as $e,Cd as Ne,Cm as We,Eb as c,Ec as o,Ei as He,Ek as he,Em as Ke,F as De,Fa as y,Fb as s,Fc as l,Fm as Xe,Ga as _,Gb as r,Gc as x,Ge as ee,Gf as je,Gi as qe,Gm as Ye,Hb as v,He as Me,Ji as ae,Jm as Ze,Ld as w,Lf as Le,N as Ie,Ob as A,Od as J,Of as Re,Pa as we,Pd as W,Qe as U,Rb as N,Rf as Ge,Sm as re,Tb as V,Um as et,Vi as Qe,Wd as Ve,Wf as O,Xb as G,Xf as ne,Yb as z,Yd as K,Yf as ze,Zb as H,Zi as Je,ab as ge,ae as Be,af as te,bc as Ee,bf as ie,c as B,dc as Fe,ef as Ue,fa as P,fc as p,gc as D,gd as M,ge as Y,hb as d,hc as f,he as Ae,ie as Pe,lb as k,ma as E,mb as R,md as Q,pe as ke,rb as b,s as _e,sc as I,se as ve,t as be,td as Te,wa as xe,wc as q,xa as L,xb as F,xc as C,xf as Oe,za as fe,zb as T}from"./chunk-23S5SJ2M.js";import"./chunk-MVDMSBX6.js";import"./chunk-JVX7FMTT.js";import"./chunk-WNQ4N7RJ.js";import"./chunk-SLBGBKZ3.js";import"./chunk-W6K676FX.js";import"./chunk-QUJFQN2Y.js";import"./chunk-GSCG32S7.js";import"./chunk-KKHWLRGY.js";import"./chunk-KX4FLUXE.js";import"./chunk-TTZSLDD6.js";import"./chunk-HD5YA6ZE.js";import"./chunk-LZE6NVX3.js";import"./chunk-KZJFW7VO.js";import"./chunk-T42X4GN6.js";import"./chunk-6CZJXZPX.js";import"./chunk-6OKCMVIT.js";import"./chunk-VT4XPAGN.js";import"./chunk-T2BITMNJ.js";import"./chunk-JVYOHDHX.js";import"./chunk-MTHZ7MWU.js";import"./chunk-WI5MSH4N.js";import"./chunk-TG547T4L.js";import"./chunk-CKP3SGE2.js";import"./chunk-MUSA4S5V.js";import{k as g}from"./chunk-3FU4ZZZM.js";var bt=(()=>{class e{constructor(t,n){this.alertController=t,this.translateService=n}canDeactivate(t,n,i,m){return g(this,null,function*(){if(t.isDirty&&!t.isValid){let h=yield this.alertController.create({message:this.translateService.instant("modal.cancel.confirm"),buttons:[{text:this.translateService.instant("no"),role:"cancel",cssClass:"secondary"},{text:this.translateService.instant("yes"),role:"delete"}]});yield h.present();let S=yield h.onDidDismiss();return S.role==="delete"&&t.rePatchClientData(),S.role==="delete"}return t.save()})}static{this.\u0275fac=function(n){return new(n||e)(fe(Le),fe(O))}}static{this.\u0275prov=xe({token:e,factory:e.\u0275fac,providedIn:"root"})}}return e})();var At=["clientName"],Pt=e=>({field:e,maxLength:255}),kt=e=>({field:e});function Mt(e,u){e&1&&(s(0,"ion-item",11),p(1),o(2,"translate"),r()),e&2&&(a(),f(" ",l(2,1,"clientNameUpdate.noNetwork")," "))}function Ut(e,u){e&1&&(s(0,"ion-item",12),p(1),o(2,"translate"),r()),e&2&&(a(),f(" ",l(2,1,"errorNetwork")," "))}function Ot(e,u){e&1&&(s(0,"span",6),p(1),o(2,"translate"),o(3,"translate"),r()),e&2&&(a(),f(" ",x(3,3,"formValidation.fieldTooLong",C(6,Pt,l(2,1,"clientDataSettings.name")))," "))}function $t(e,u){e&1&&(s(0,"span",6),p(1),o(2,"translate"),o(3,"translate"),r()),e&2&&(a(),f(" ",x(3,3,"formValidation.emptyField",C(6,kt,l(2,1,"clientDataSettings.name")))," "))}function jt(e,u){e&1&&(s(0,"span",6),p(1),o(2,"translate"),r()),e&2&&(a(),f(" ",l(2,1,"clientNameUpdate.errorClientNameExists")," "))}
1function Lt(e,u){e&1&&v(0,"ion-spinner",15)}function Rt(e,u){if(e&1){let t=A();s(0,"ion-button",13),N("click",function(){y(t);let i=V();return _(i.save())}),b(1,Lt,1,0,"ion-spinner",14),s(2,"span"),p(3),o(4,"translate"),r()()}if(e&2){let t=V();c("disabled",t.saving||!t.savePossibleAndNecessary()),a(),c("ngIf",t.saving),a(2),D(l(4,3,"button.save"))}}var It=(()=>{class e{constructor(t,n,i,m,h,S,$){this.fb=t,this.translateService=n,this.clientDataService=i,this.clientService=m,this.syncService=h,this.networkStatusService=S,this.toastService=$,this.destroy$=new B,this.saving=!1,this.clientForm=this.fb.group({name:["",[w.required,w.maxLength(255)]]})}ngOnInit(){this.clientDataService.getOwnClient().pipe(E(this.destroy$)).subscribe(t=>{this.client=t,this.clientForm.reset({name:t.name})}),this.networkStatusService.onlineOrUnknown$.pipe(E(this.destroy$)).subscribe(t=>this.networkConnected=t),setTimeout(()=>g(this,null,function*(){yield this.clientName.setFocus()}),500)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}save(){return g(this,null,function*(){if(this.savePossibleAndNecessary())try{this.saving=!0,this.abortController=new AbortController;let t=this.abortController.signal;if(yield this.clientService.updateClientName(this.client,this.clientForm.controls.name.value,t),t.aborted||(yield this.syncService.startSync(re.CURRENT_PROJECT_AND_PROJECT_WITH_CHANGES),t.aborted))return;yield this.toastService.info("saving_success"),yield this.modal.dismiss({role:"save"})}catch(t){if(t instanceof Ne&&t.status===400){if(t.error.errorCode==="NAME_EXISTS"){this.clientForm.controls.name.setErrors({clientNameExists:!0});return}}else if(t instanceof He||t instanceof qe||t?.name==="TimeoutError"){this.clientForm.controls.name.setErrors({networkError:!0});return}yield this.toastService.error("clientNameUpdate.error",{message:ae(t)})}finally{this.saving=!1,this.abortController=void 0}})}cancel(){return g(this,null,function*(){this.abortController?.abort(),yield this.modal.dismiss({role:"cancel"})})}savePossibleAndNecessary(){return this.clientForm.valid&&this.clientForm.dirty&&this.clientForm.controls.name.value!==this.client?.name&&this.networkConnected!==!1}static{this.\u0275fac=function(n){return new(n||e)(d(Y),d(O),d(oe),d(tt),d(pe),d(ce),d(le))}}static{this.\u0275cmp=k({type:e,selectors:[["app-client-name-update"]],viewQuery:function(n,i){if(n&1&&G(At,5),n&2){let m;z(m=H())&&(i.clientName=m.first)}},standalone:!1,decls:21,vars:18,consts:[["clientName",""],[1,"with-padding"],["action","#",1,"omg-form",3,"formGroup"],["lines","none","class","warning",4,"ngIf"],["lines","none","class","error-message",4,"ngIf"],["labelPlacement","floating","formControlName","name","type","text","required","",1,"omg-required",3,"label"],[1,"error-message"],["class","error-message",4,"ngIf"],["slot","end"],[1,"omg-btn-text",3,"click"],["class","omg-btn-primary",3,"disabled","click",4,"appFeatureEnabled","appFeatureEnabledForAdmin"],["lines","none",1,"warning"],["lines","none",1,"error-message"],[1,"omg-btn-primary",3,"click","disabled"],["slot","start","class","spinner-center-button",4,"ngIf"],["slot","start",1,"spinner-center-button"]],template:function(n,i){if(n&1){let m=A();s(0,"app-modal-header")(1,"ion-title"),p(2),o(3,"translate"),r()(),s(4,"ion-content",1)(5,"form",2),b(6,Mt,3,3,"ion-item",3)(7,Ut,3,3,"ion-item",4),s(8,"ion-item"),v(9,"ion-input",5,0),o(11,"translate"),r(),F(12,Ot,4,8,"span",6),b(13,$t,4,8,"span",7)(14,jt,3,3,"span",7),r()(),s(15,"app-modal-footer")(16,"ion-buttons",8)(17,"ion-button",9),N("click",function(){return y(m),_(i.cancel())}),p(18),o(19,"translate"),r(),b(20,Rt,5,5,"ion-button",10),r()()}n&2&&(a(2),D(l(3,12,"clientNameUpdate.title")),a(3),c("formGroup",i.clientForm),a(),c("ngIf",i.networkConnected===!1),a(),c("ngIf",i.clientForm.controls.name.errors==null?null:i.clientForm.controls.name.errors.networkError),a(2),c("label",I(l(11,14,"clientDataSettings.name"))),a(3),T(i.clientForm.controls.name.errors!=null&&i.clientForm.controls.name.errors.maxlength?12:-1),a(),c("ngIf",(i.clientForm.controls.name.errors==null?null:i.clientForm.controls.name.errors.required)&&i.clientForm.controls.name.dirty),a(),c("ngIf",(i.clientForm.controls.name.errors==null?null:i.clientForm.controls.name.errors.clientNameExists)&&i.clientForm.controls.name.dirty),a(4),D(l(19,16,"cancel")),a(2),c("appFeatureEnabled",!0)("appFeatureEnabledForAdmin",!0))},dependencies:[M,Ve,J,W,Be,K,X,ee,Me,U,te,ie,Oe,$e,Z,gt,Xe,Ye,ne],encapsulation:2})}}return e})();var zt=()=>["fal","user-alt"],Ht=()=>["fal","info-circle"],qt=e=>["/company",e],Qt=()=>["fal","arrow-right"],Jt=e=>({field:e}),Wt=e=>({field:e,maxLength:32}),ye=e=>({field:e,maxLength:255}),Kt=e=>({field:e,maxLength:10});function Xt(e,u){if(e&1&&(s(0,"ion-button",7),o(1,"async"),v(2,"fa-icon",4),s(3,"span"),p(4),o(5,"translate"),r()()),e&2){let t,n=V();c("routerLink",C(7,qt,(t=l(1,3,n.ownCompany$))==null?null:t.id)),a(2),c("icon",q(9,Qt)),a(2),D(l(5,5,"clientDataSettings.seeCompanyDetails"))}}function Yt(e,u){e&1&&(s(0,"span",21),p(1),o(2,"translate"),o(3,"translate"),r()),e&2&&(a(),f(" ",x(3,3,"formValidation.emptyField",C(6,Jt,l(2,1,"clientDataSettings.name")))," "))}function Zt(e,u){e&1&&(s(0,"span",21),p(1),o(2,"translate"),o(3,"translate"),r()),e&2&&(a(),f(" ",x(3,3,"formValidation.fieldTooLong",C(6,Wt,l(2,1,"clientDataSettings.vatNumber")))," "))}function ei(e,u){e&1&&(s(0,"span",21),p(1),o(2,"translate"),o(3,"translate"),r()),e&2&&(a(),f(" ",x(3,3,"formValidation.fieldTooLong",C(6,ye,l(2,1,"clientDataSettings.street1")))," "))}function ti(e,u){e&1&&(s(0,"span",21),p(1),o(2,"translate"),o(3,"translate"),r()),e&2&&(a(),f(" ",x(3,3,"formValidation.fieldTooLong",C(6,ye,l(2,1,"clientDataSettings.street2")))," "))}function ii(e,u){e&1&&(s(0,"span",21),p(1),o(2,"translate"),o(3,"translate"),r()),e&2&&(a(),f(" ",x(3,3,"formValidation.fieldTooLong",C(6,Kt,l(2,1,"clientDataSettings.zipCode")))," "))}function ni(e,u){e&1&&(s(0,"span",21),p(1),o(2,"translate"),o(3,"translate"),r()),e&2&&(a(),f(" ",x(3,3,"formValidation.fieldTooLong",C(6,ye,l(2,1,"clientDataSettings.city")))," "))}function ai(e,u){if(e&1&&v(0,"app-selectable-item-icon",33),e&2){let t=u.isItemSelected;c("selected",t)}}function ri(e,u){if(e&1&&v(0,"app-selectable-value",34),e&2){let t=u.value;c("value",t)}}function oi(e,u){e&1&&v(0,"app-selectable-header")}function si(e,u){e&1&&v(0,"app-selectable-footer")}var me=(()=>{class e{get address(){return this.clientForm.controls.address}constructor(t,n,i,m,h,S){this.fb=t,this.addressDataService=n,this.countryDataService=i,this.modalController=m,this.selectableUtilService=h,this.companyService=S,this.clientDataChange=new ge,this.isValidChange=new ge,this.clientForm=this.fb.group({name:["",w.required],uid:["",w.maxLength(32)],address:this.fb.group({street1:["",w.maxLength(255)],street2:["",w.maxLength(255)],zipCode:["",w.maxLength(10)],city:["",w.maxLength(255)]}),country:[null]}),this.destroy$=new B,this.getGroupText=($,de,ue)=>this.countryDataService.getGroupText($,de,ue),this.countries$=this.countryDataService.dataSorted$,this.ownCompany$=this.companyService.getOwnCompany$()}ngOnChanges(t){this.client&&this.patchClientData()}ngOnInit(){this.clientForm.statusChanges.pipe(E(this.destroy$),P(1)).subscribe(()=>{this.clientForm.status==="VALID"?this.isValidChange.emit(!0):this.clientForm.status==="INVALID"&&this.isValidChange.emit(!1)}),this.clientForm.valueChanges.pipe(E(this.destroy$),P(1)).subscribe(t=>{this.clientDataChange.emit(t)})}patchClientData(){this.clientForm.patchValue(this.client,{emitEvent:!1});let t=this.addressDataService.getByIdForOwnClient(this.client.addressId);be([this.countries$,t]).pipe(E(this.destroy$),P(1)).subscribe(([n,i])=>{this.clientForm.controls.address.patchValue(i,{emitEvent:!1}),this.clientForm.get("country").setValue(n.find(m=>m.id===this.client.countryId),{emitEvent:!1})})}markAsPristine(){this.clientForm.markAsPristine()}changeClientName(){return g(this,null,function*(){return yield(yield this.modalController.create({component:It,componentProps:{client:this.client}})).present()})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}onOpen(t){return g(this,null,function*(){this.resizeModeBeforeOpen=yield this.selectableUtilService.setKeyboardResizeModeOnOpe
1n()})}onClose(t){return g(this,null,function*(){yield this.selectableUtilService.setKeyboardResizeModeOnClose(t,this.resizeModeBeforeOpen)})}static{this.\u0275fac=function(n){return new(n||e)(d(Y),d(se),d(it),d(Re),d(at),d(yt))}}static{this.\u0275cmp=k({type:e,selectors:[["app-client-data-settings"]],inputs:{client:"client"},outputs:{clientDataChange:"clientDataChange",isValidChange:"isValidChange"},standalone:!1,features:[we],decls:89,vars:84,consts:[["protocolTypeSelectable","","fs","appSelectableCommon"],[3,"formGroup"],[1,"omg-section","omg-just-header"],[1,"omg-section-h1"],["slot","start",3,"icon"],[1,"omg-section","omg-header-info"],[1,"d-flex","flex-column","gap-2"],[1,"omg-btn-secondary",3,"routerLink"],[1,"omg-section"],[1,"omg-section-h2"],[1,"omg-gap-regular"],[1,"d-flex","gap-2"],[1,"grid"],[1,"cursor-pointer",3,"click"],["label-placement","floating","readonly","","formControlName","name",1,"cursor-pointer","username-input"],["slot","label"],["class","error-message",4,"ngIf"],[1,"d-flex","flex-column"],[1,"d-flex","gap-2","ion-align-items-center"],["labelPlacement","floating","type","text","formControlName","uid",1,"text-primary",3,"label"],["size","lg","appInfoPopoverClick","",3,"icon","infoTitle","infoText"],[1,"error-message"],[1,"omg-section",3,"formGroup"],["labelPlacement","floating","type","text","formControlName","street1",1,"text-primary",3,"label"],["labelPlacement","floating","type","text","formControlName","street2",1,"text-primary",3,"label"],["labelPlacement","floating","type","text","formControlName","zipCode",1,"text-primary",3,"label"],["labelPlacement","floating","type","text","formControlName","city",1,"text-primary",3,"label"],["position","floating",1,"text-primary"],["item-content","","formControlName","country","itemValueField","id","itemTextField","name","appSelectableCommon","","virtualScrollApproxItemHeight","48px",1,"text-primary",3,"onOpen","onClose","items","searchPlaceholder","searchFailText","canSearch","className","shouldFocusSearchbar","hasVirtualScroll","virtualScrollHeaderFn"],["ionicSelectableItemIconTemplate",""],["ionicSelectableValueTemplate",""],["ionicSelectableHeaderTemplate",""],["ionicSelectableFooterTemplate",""],[3,"selected"],[3,"value"]],template:function(n,i){if(n&1){let m=A();s(0,"ion-content",1)(1,"div",2)(2,"div",3),v(3,"fa-icon",4),s(4,"span"),p(5),o(6,"translate"),r()()(),s(7,"div",5)(8,"div",6)(9,"span"),p(10),o(11,"translate"),r(),s(12,"span"),p(13),o(14,"translate"),r()(),F(15,Xt,6,10,"ion-button",7),o(16,"async"),r(),s(17,"div",8)(18,"div",9),p(19),o(20,"translate"),r(),s(21,"div",10)(22,"div",11)(23,"span"),p(24),o(25,"translate"),r(),s(26,"span"),p(27),r()()()(),s(28,"div",8)(29,"div",9),p(30),o(31,"translate"),r(),s(32,"div",10)(33,"div",12)(34,"div")(35,"ion-item",13),N("click",function(){return y(m),_(i.changeClientName())}),s(36,"ion-input",14)(37,"div",15),p(38),o(39,"translate"),r()()(),b(40,Yt,4,8,"span",16),r(),s(41,"div",17)(42,"div",18)(43,"ion-item"),v(44,"ion-input",19),o(45,"translate"),r(),v(46,"fa-icon",20),r(),F(47,Zt,4,8,"span",21),r()()()(),s(48,"div",22)(49,"div",9),p(50),o(51,"translate"),r(),s(52,"div",10)(53,"div",12)(54,"div")(55,"ion-item"),v(56,"ion-input",23),o(57,"translate"),r(),F(58,ei,4,8,"span",21),r(),s(59,"div")(60,"ion-item"),v(61,"ion-input",24),o(62,"translate"),r(),F(63,ti,4,8,"span",21),r(),s(64,"div")(65,"ion-item"),v(66,"ion-input",25),o(67,"translate"),r(),F(68,ii,4,8,"span",21),r(),s(69,"div")(70,"ion-item"),v(71,"ion-input",26),o(72,"translate"),r(),F(73,ni,4,8,"span",21),r(),s(74,"div",1)(75,"ion-item")(76,"ion-label",27),p(77),o(78,"translate"),r(),s(79,"ionic-selectable",28,0),o(82,"translate"),o(83,"translate"),o(84,"async"),N("onOpen",function(S){return y(m),_(i.onOpen(S))})("onClose",function(S){return y(m),_(i.onClose(S))}),b(85,ai,1,1,"ng-template",29)(86,ri,1,1,"ng-template",30)(87,oi,1,0,"ng-template",31)(88,si,1,0,"ng-template",32),r()()()()()()()}if(n&2){let m=Ee(81);c("formGroup",i.clientForm),a(3),c("icon",q(82,zt)),a(2),D(l(6,46,"clientDataSettings.title")),a(5),D(l(11,48,"clientDataSettings.info1")),a(3),D(l(14,50,"clientDataSettings.info2")),a(2),T(l(16,52,i.ownCompany$)?15:-1),a(4),f(" ",l(20,54,"clientDataSettings.accountSection")," "),a(5),f(" ",l(25,56,"clientDataSettings.customerNumber")," "),a(3),f(" ",i.client.customerNumber," "),a(3),f(" ",l(31,58,"clientDataSettings.billingSection")," "),a(5),Fe("ion-invalid",i.clientForm.controls.name.errors),a(3),f(" ",l(39,60,"clientDataSettings.name")," "),a(2),c("ngIf",i.clientForm.controls.name.errors&&i.clientForm.controls.name.dirty),a(4),c("label",I(l(45,62,"clientDataSettings.vatNumber"))),a(2),c("icon",q(83,Ht))("infoTitle","clientDataSettings.vatNumber")("infoText","buyingWorkflow.vatInfo"),a(),T(i.clientForm.controls.uid.errors!=null&&i.clientForm.controls.uid.errors.maxlength?47:-1),a(),c("formGroup",i.address),a(2),f(" ",l(51,64,"clientDataSettings.addressSection")," "),a(6),c("label",I(l(57,66,"clientDataSettings.street1"))),a(2),T(i.address.controls.street1.errors!=null&&i.address.controls.street1.errors.maxlength?58:-1),a(3),c("label",I(l(62,68,"clientDataSettings.street2"))),a(2),T(i.address.controls.street2.errors!=null&&i.address.controls.street2.errors.maxlength?63:-1),a(3),c("label",I(l(67,70,"clientDataSettings.zipCode"))),a(2),T(i.address.controls.zipCode.errors!=null&&i.address.controls.zipCode.errors.maxlength?68:-1),a(3),c("label",I(l(72,72,"clientDataSettings.city"))),a(2),T(i.address.controls.city.errors!=null&&i.address.controls.city.errors.maxlength?73:-1),a(),c("formGroup",i.clientForm),a(3),D(l(78,74,"clientDataSettings.country")),a(2),c("searchPlaceholder",I(l(82,76,"search")))("searchFailText",I(l(83,78,"noItemsFound")))("items",l(84,80,i.countries$))("canSearch",!0)("className","protocol-type-selector")("shouldFocusSearchbar",m.isDesktop)("hasVirtualScroll",!0)("virtualScrollHeaderFn",i.getGroupText)}},dependencies:[M,J,W,K,X,ee,U,te,ie,Ue,Z,je,ke,We,pt,ct,ot,rt,lt,st,mt,dt,ut,ft,ht,Q,ne],styles:[".input-label-placement-floating.sc-ion-input-md-h[_ngcontent-%COMP%], .input-label-placement-stacked.sc-ion-input-md-h[_ngcontent-%COMP%]{min-height:55px}.grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:50% 50%;gap:8px}@media(max-width:575px){.grid[_ngcontent-%COMP%]{grid-template-columns:100%}}"]})}}return e})();function ci(e,u){if(e&1){let t=A();s(0,"app-client-data-settings",1),N("clientDataChange",function(i){y(t);let m=V();return _(m.clientDataChanged(i))})("isValidChange",function(i){y(t);let m=V();return _(m.validityChanged(i))}),r()}if(e&2){let t=u.ngIf;c("client",t)}}var xt="AdminSettingsClientDataPage",wt=(()=>{class e{constructor(t,n,i,m,h,S,$,de){this.clientDataService=t,this.toastService=n,this.translateService=i,this.addressDataService=m,this.syncService=h,this.networkStatusService=S,this.loggingService=$,this.systemEventService=de,this.isValid=!1,this.isDirty=!1,this.isUpdating=!1,this.update$=new B,this.destroy$=new B,this.client$=this.clientDataService.getOwnClient().pipe(_e(ue=>ue),P(1))}ngOnInit(){this.update$.pipe(E(this.destroy$),Ie(Je),De(()=>this.isValid&&this.isDirty)).subscribe(()=>g(this,null,function*(){yield this.save()}))}clientDataChanged(t){this.isDirty=!0,this.clientDataInForm=t,this.update$.next()}validityChanged(t){this.isValid=t}save(){return g(this,null,function*(){if(!this.isDirty)return!0;
1if(this.isUpdating)return!1;this.isUpdating=!0;try{let t=yield he(this.client$);if(this.formComponent?.markAsPristine(),t.addressId)yield this.updateClientAddress(t,this.clientDataInForm);else{if(this.networkStatusService.offline)throw new Error("Cannot insert a new clientAddress when there is no network connection because we need to run a sync afterwards.");let n=yield this.insertClientAddress(t,this.clientDataInForm);yield this.syncService.dataSync(re.PROJECTS_WITH_CHANGES),t.addressId=n.id}return yield this.updateClientData(t,this.clientDataInForm),this.isDirty=!1,yield this.toastService.savingSuccess(),!0}catch(t){return yield this.toastService.savingError(),this.loggingService.error(xt,`save - ${ae(t)}`),this.systemEventService.logErrorEvent(xt+" save",t),!1}finally{this.isUpdating=!1}})}updateClientData(t,n){return g(this,null,function*(){t.name=n.name,t.uid=n.uid,t.countryId=n.country?.id,yield this.clientDataService.update(t)})}insertClientAddress(t,n){return g(this,null,function*(){let i={id:Ze(),street1:n.address.street1,zipCode:n.address.zipCode,city:n.address.city,clientId:t.id,changedAt:new Date().toISOString()};return yield this.addressDataService.insert(i,t.id),i})}updateClientAddress(t,n){return g(this,null,function*(){let i=yield he(this.addressDataService.getByIdForOwnClient(t.addressId));if(!i)throw new Error(`Unable to find the address with id ${t.addressId} of the client ${t.id}.`);i.street1=n.address.street1,i.street2=n.address.street2,i.zipCode=n.address.zipCode,i.city=n.address.city,yield this.addressDataService.update(i,i.clientId)})}rePatchClientData(){this.formComponent?.patchClientData(),this.isDirty=!1,this.isValid=!1}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),this.update$.complete()}static{this.\u0275fac=function(n){return new(n||e)(d(oe),d(le),d(O),d(se),d(pe),d(ce),d(Qe),d(et))}}static{this.\u0275cmp=k({type:e,selectors:[["app-admin-settings-client-data"]],viewQuery:function(n,i){if(n&1&&G(me,5),n&2){let m;z(m=H())&&(i.formComponent=m.first)}},standalone:!1,decls:3,vars:3,consts:[[3,"client","clientDataChange","isValidChange",4,"ngIf"],[3,"clientDataChange","isValidChange","client"]],template:function(n,i){n&1&&(s(0,"ion-content"),b(1,ci,1,1,"app-client-data-settings",0),o(2,"async"),r()),n&2&&(a(),c("ngIf",l(2,1,i.client$)))},dependencies:[M,U,me,Q],encapsulation:2})}}return e})();var pi=[{path:"",component:wt,canDeactivate:[bt]}],Et=(()=>{class e{static{this.\u0275fac=function(n){return new(n||e)}}static{this.\u0275mod=R({type:e})}static{this.\u0275inj=L({imports:[ve.forChild(pi),ve]})}}return e})();var la=(()=>{class e{static{this.\u0275fac=function(n){return new(n||e)}}static{this.\u0275mod=R({type:e})}static{this.\u0275inj=L({imports:[Te,Ae,Pe,Ge,Et,ze,Ke,_t,Ct,St,vt,nt]})}}return e})();export{la as AdminSettingsClientDataPageModule};
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.