import{a as E}from"./chunk-722T4EPN.js";import{a as M,b as O}from"./chunk-B4BXIPDQ.js";import{a as k}from"./chunk-CKDUQWQK.js";import{c as p}from"./chunk-CGP3C5E7.js";import{k as m,l as d,u as l,v as h}from"./chunk-CZO7TLJA.js";import{H as t,J as b,K as R,O as V,Q as w,T as I,W as x,Y as A}from"./chunk-KT4MWGDC.js";import{a as N,b as u}from"./chunk-3KIQTF23.js";import{ya as y}from"./chunk-ONNJVTQI.js";import{Ab as C,Tb as s,cc as T,dc as D,ec as _,gd as P,mb as c,rb as a}from"./chunk-A4WWLITB.js";import{b as g,i as U}from"./chunk-QOJKCMZT.js";var i=function(e){return e[e.PurchasePrice=0]="PurchasePrice",e[e.Quantity=1]="Quantity",e[e.Markup=2]="Markup",e[e.NewPrice=3]="NewPrice",e}(i||{});U();var F=class f{constructor(o,r,n,G){this.data=o,this._dialogRef=r,this._fb=n,this._cdr=G,this.form=this._fb.group({changeTo:this._fb.control(null,t.required),fieldForEdit:this._fb.control(null,t.required)})}ngOnInit(){this._dialogRef.submitData$$.next(this.form),this._dialogRef.instance?.submitted.pipe(u(this)).subscribe(()=>this._cdr.markForCheck()),this._validateChangeToField()}_validateChangeToField(){this.form.controls.fieldForEdit.valueChanges.pipe(u(this)).subscribe(o=>{this.form.controls.changeTo.clearValidators(),this.form.controls.changeTo.updateValueAndValidity(),o===i.PurchasePrice&&this.form.controls.changeTo.setValidators([t.required,t.max(m.max),t.min(m.min)]),o===i.Quantity&&(this.data.isOnlyWeight?this.form.controls.changeTo.setValidators([t.required,t.max(l.max),t.min(l.min)]):this.form.controls.changeTo.setValidators([t.required,t.max(h.max),t.min(h.min)])),o===i.Markup&&this.form.controls.changeTo.setValidators([t.required,t.max(d.max),t.min(d.min)]),o===i.NewPrice&&this.form.controls.changeTo.setValidators([t.required,t.max(m.max),t.min(0)]),!this.data.isOnlyWeight&&o!==i.PurchasePrice&&o!==i.NewPrice&&o!==i.Markup&&this.form.controls.changeTo.addValidators(p(t.pattern(/^\d+$/),"\u0412\u044B\u0431\u0440\u0430\u043D\u044B \u0448\u0442\u0443\u0447\u043D\u044B\u0435 \u0442\u043E\u0432\u0430\u0440\u044B")),(o==i.PurchasePrice||o==i.NewPrice||o==i.Markup)&&this.form.controls.changeTo.addValidators(p(t.pattern(/^\d+(\.\d{1,2})?$/),"\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()})}static{this.\u0275fac=function(r){return new(r||f)(a(O),a(M),a(x),a(P))}}static{this.\u0275cmp=C({type:f,selectors:[["tis-mass-editing-dialog"]],decls:3,vars:6,consts:[[3,"formGroup"],["formControlName","fieldForEdit","label","\u041F\u043E\u043B\u0435 \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F",3,"options","showClearButton"],["formControlName","changeTo","token","changeTo","label","\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u043D\u0430",3,"showControlButtons","precision","isWeight"]],template:function(r,n){r&1&&(T(0,"form",0),_(1,"tis-dropdown",1)(2,"tis-number-input",2),D()),r&2&&(s("formGroup",n.form),c(),s("options",n.data.options)("showClearButton",!1),c(),s("showControlButtons",!1)("precision",3)("isWeight",n.data.isOnlyWeight))},dependencies:[y,A,V,b,R,w,I,k,E],encapsulation:2,changeDetection:0})}};F=g([N()],F);export{i as a,F as b};
