import{a as i}from"./chunk-AH4KWRYY.js";import{a as r,b as y,e as s,f as c}from"./chunk-VFX53AYF.js";import{l as p,m as F,v as _,w as b}from"./chunk-ZVQ5RRLK.js";import{b as W,e as z}from"./chunk-5LZMOUCI.js";import{B as k,D as x,Ia as G,Ja as U,Oa as $,Qa as j,q as M,r as A,u as S,w as B,z as O}from"./chunk-2N3356TH.js";import{a as V,b as D}from"./chunk-EK6YV2TW.js";import{ua as I}from"./chunk-NZ765PUK.js";import{Bb as P,Eb as R,bc as d,cc as v,dc as w,ec as g,ed as C,fd as T,jb as h,ub as n,yd as E}from"./chunk-DYUFV4HF.js";import{d as N,n as q}from"./chunk-INB5GR2I.js";q();var e,L=(e=class{constructor(t,a,o,l,m){this.data=t,this._dialogRef=a,this._fb=o,this._cdr=l,this._localizationService=m,this.form=this._fb.group({changeTo:this._fb.control(null,r()),fieldForEdit:this._fb.control(null,r())})}ngOnInit(){this._dialogRef.submitData$$.next(this.form),this._dialogRef.instance?.submitted.pipe(D(this)).subscribe(()=>this._cdr.markForCheck()),this._validateChangeToField()}_validateChangeToField(){this.form.controls.fieldForEdit.valueChanges.pipe(D(this)).subscribe(t=>{this.form.controls.changeTo.clearValidators(),this.form.controls.changeTo.updateValueAndValidity(),t===i.PurchasePrice&&this.form.controls.changeTo.setValidators([r(),s(p.max),c(p.min)]),t===i.Quantity&&(this.data.isOnlyWeight?this.form.controls.changeTo.setValidators([r(),s(_.max),c(_.min)]):this.form.controls.changeTo.setValidators([r(),s(b.max),c(b.min)])),t===i.Markup&&this.form.controls.changeTo.setValidators([r(),s(F.max),c(F.min)]),t===i.NewPrice&&this.form.controls.changeTo.setValidators([r(),s(p.max),c(0)]),!this.data.isOnlyWeight&&t!==i.PurchasePrice&&t!==i.NewPrice&&t!==i.Markup&&this.form.controls.changeTo.addValidators(y(/^\d+$/,this._localizationService.getSync("\u0412\u044B\u0431\u0440\u0430\u043D\u044B \u0448\u0442\u0443\u0447\u043D\u044B\u0435 \u0442\u043E\u0432\u0430\u0440\u044B"))),(t==i.PurchasePrice||t==i.NewPrice||t==i.Markup)&&this.form.controls.changeTo.addValidators(y(/^\d+(\.\d{1,2})?$/,this._localizationService.getSync("\u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u0430 \u0446\u0435\u043D\u0430 \u0442\u043E\u043B\u044C\u043A\u043E \u0441 \u0434\u0432\u0443\u043C\u044F \u0437\u043D\u0430\u043A\u0430\u043C\u0438 \u043F\u043E\u0441\u043B\u0435 \u0442\u043E\u0447\u043A\u0438"))),this.form.controls.changeTo.updateValueAndValidity(),this._cdr.detectChanges()})}},e.\u0275fac=function(a){return new(a||e)(n(U),n(G),n(k),n(E),n(z))},e.\u0275cmp=P({type:e,selectors:[["tis-mass-editing-dialog"]],decls:5,vars:13,consts:[[3,"formGroup"],["formControlName","fieldForEdit",3,"requiredForLabel","options","showClearButton","label"],["formControlName","changeTo","token","changeTo",3,"showControlButtons","precision","isWeight","label"]],template:function(a,o){a&1&&(v(0,"form",0),g(1,"wk-dropdown",1),C(2,"translate"),g(3,"wk-number-input",2),C(4,"translate"),w()),a&2&&(d("formGroup",o.form),h(),d("requiredForLabel",!0)("options",o.data.options)("showClearButton",!1)("label",T(2,9,"\u041F\u043E\u043B\u0435 \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F")),h(2),d("showControlButtons",!1)("precision",3)("isWeight",o.data.isOnlyWeight)("label",T(4,11,"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u043D\u0430")))},dependencies:[I,x,S,M,A,B,O,$,j,W],encapsulation:2,changeDetection:0}),e);L=N([V()],L);var st=(()=>{let t=class t{transform(o,l=3){let m=typeof o=="string"?parseFloat(o):o;if(isNaN(m))return"";let f=m.toFixed(l);return f=f.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),f}};t.\u0275fac=function(l){return new(l||t)},t.\u0275pipe=R({name:"customNumber",type:t,pure:!0});let u=t;return u})();export{L as a,st as b};
//# sourceMappingURL=chunk-WH7T22JN.js.map
