import{a as t}from"./chunk-XX6HBKFT.js";import{a as o,b as g,e as n,f as s}from"./chunk-5T6TZLDM.js";import{l as d,m as _,v as S,w as C}from"./chunk-ZVQ5RRLK.js";import{b as k,e as G}from"./chunk-RCWJCOBH.js";import{B as V,D as w,Ga as M,Ha as A,Ma as B,Oa as O,q as P,r as N,u as R,w as E,z as I}from"./chunk-NKXT7PF4.js";import{a as F,b as p}from"./chunk-IGFM5CCE.js";import{ua as z}from"./chunk-TDUJNOEU.js";import{Db as T,dc as c,ec as b,fc as y,fd as u,gc as h,gd as f,lb as m,wb as r,zd as D}from"./chunk-I3FGJX2C.js";import{d as v,n as W}from"./chunk-INB5GR2I.js";W();var e,U=(e=class{constructor(i,a,l,j,x){this.data=i,this._dialogRef=a,this._fb=l,this._cdr=j,this._localizationService=x,this.form=this._fb.group({changeTo:this._fb.control(null,o(!1,this._localizationService.getSync.bind(this._localizationService))),fieldForEdit:this._fb.control(null,o(!1,this._localizationService.getSync.bind(this._localizationService)))})}ngOnInit(){this._dialogRef.submitData$$.next(this.form),this._dialogRef.instance?.submitted.pipe(p(this)).subscribe(()=>this._cdr.markForCheck()),this._validateChangeToField()}_validateChangeToField(){this.form.controls.fieldForEdit.valueChanges.pipe(p(this)).subscribe(i=>{this.form.controls.changeTo.clearValidators(),this.form.controls.changeTo.updateValueAndValidity(),i===t.PurchasePrice&&this.form.controls.changeTo.setValidators([o(!1,this._localizationService.getSync.bind(this._localizationService)),n(d.max),s(d.min)]),i===t.Quantity&&(this.data.isOnlyWeight?this.form.controls.changeTo.setValidators([o(!1,this._localizationService.getSync.bind(this._localizationService)),n(S.max),s(S.min)]):this.form.controls.changeTo.setValidators([o(!1,this._localizationService.getSync.bind(this._localizationService)),n(C.max),s(C.min)])),i===t.Markup&&this.form.controls.changeTo.setValidators([o(!1,this._localizationService.getSync.bind(this._localizationService)),n(_.max),s(_.min)]),i===t.NewPrice&&this.form.controls.changeTo.setValidators([o(!1,this._localizationService.getSync.bind(this._localizationService)),n(d.max),s(0)]),!this.data.isOnlyWeight&&i!==t.PurchasePrice&&i!==t.NewPrice&&i!==t.Markup&&this.form.controls.changeTo.addValidators(g(/^\d+$/,this._localizationService.getSync("\u0412\u044B\u0431\u0440\u0430\u043D\u044B \u0448\u0442\u0443\u0447\u043D\u044B\u0435 \u0442\u043E\u0432\u0430\u0440\u044B"))),(i==t.PurchasePrice||i==t.NewPrice||i==t.Markup)&&this.form.controls.changeTo.addValidators(g(/^\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)(r(A),r(M),r(V),r(D),r(G))},e.\u0275cmp=T({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,l){a&1&&(b(0,"form",0),h(1,"wk-dropdown",1),u(2,"translate"),h(3,"wk-number-input",2),u(4,"translate"),y()),a&2&&(c("formGroup",l.form),m(),c("requiredForLabel",!0)("options",l.data.options)("showClearButton",!1)("label",f(2,9,"\u041F\u043E\u043B\u0435 \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F")),m(2),c("showControlButtons",!1)("precision",3)("isWeight",l.data.isOnlyWeight)("label",f(4,11,"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u043D\u0430")))},dependencies:[z,w,R,P,N,E,I,B,O,k],encapsulation:2,changeDetection:0}),e);U=v([F()],U);export{U as a};
//# sourceMappingURL=chunk-REOZGE7J.js.map
