File manager - Edit - /home/web/vm-3fadc827.na4u.ru/www/bitrix/modules/catalog/install/js/catalog/product-form/dist/product-form.bundle.min.js
Back
this.BX=this.BX||{};(function(t,e,s,i,o,a,n,r,l,c,d,u,p,h,m,g,I,b,f,T,E,O,C,v,P,_,R,A){"use strict";class y{}y.TOP="TOP";y.BOTTOM="BOTTOM";class k extends d.VuexBuilderModel{getName(){return"productList"}getState(){return{currency:"",taxIncluded:"N",basket:[],total:{sum:0,discount:0,taxSum:0,result:0}}}static getBaseProduct(){const t=h.Text.getRandom();return{offerId:null,selectorId:t,fields:{innerId:t,productId:null,skuId:null,code:null,module:null,sort:0,price:null,basePrice:null,priceExclusive:null,quantity:1,name:"",discount:0,discountRate:0,discountInfos:[],discountType:A.DiscountType.PERCENTAGE,tax:0,taxSum:0,taxIncluded:"N",measureCode:0,measureName:"",measureRatio:1,isCustomPrice:"N",additionalFields:[],properties:[],brands:[]},calculatedFields:[],catalogFields:{},showDiscount:"N",showTax:"N",skuTree:[],image:null,sum:0,catalogPrice:null,discountSum:0,detailUrl:"",encodedFields:null,errors:[]}}getActions(){return{resetBasket({commit:t}){t("clearBasket");t("addItem",{})},removeItem({dispatch:t,commit:e,state:s},i){e("deleteItem",i);if(s.basket.length===0){e("addItem",{})}else{s.basket.forEach(((t,s)=>{e("updateItem",{index:s,fields:{sort:s}})}))}t("calculateTotal")},changeItem:({dispatch:t,commit:e},s)=>{e("updateItem",s);t("calculateTotal")},setCurrency:({commit:t},e)=>{const s=e||"";t("setCurrency",s)},addItem:({dispatch:t,commit:e},s)=>{const i=s.item||{fields:{}};e("addItem",{item:i,position:s.position||y.TOP});t("calculateTotal")},calculateTotal:({commit:t,state:e})=>{const s={sum:0,taxSum:0,discount:0,result:0};e.basket.forEach((t=>{const e=h.Text.toNumber(t.fields.basePrice||0);const i=h.Text.toNumber(t.fields.quantity||0);const o=h.Text.toNumber(t.fields.discount||0);const a=h.Text.toNumber(t.fields.taxSum||0);s.sum+=e*i;s.result+=h.Text.toNumber(t.sum);s.discount+=o*i;s.taxSum+=a*i}));s.discount=s.discount>s.sum?s.sum:s.discount;t("setTotal",s)}}}getGetters(){return{getBasket:t=>()=>t.basket,getBaseProduct:()=>()=>k.getBaseProduct()}}getMutations(){return{addItem:(t,e)=>{let s=k.getBaseProduct();s=Object.assign(s,e.item);if(e.position===y.BOTTOM){t.basket.push(s)}else{t.basket.unshift(s)}t.basket.forEach(((t,e)=>{t.fields.sort=e}))},updateItem:(t,e)=>{if(h.Type.isNil(t.basket[e.index])){u.Vue.set(t.basket,e.index,k.getBaseProduct())}t.basket[e.index]=Object.assign(t.basket[e.index],e.product)},clearBasket:t=>{t.basket=[]},deleteItem:(t,e)=>{t.basket.splice(e.index,1);t.basket.forEach(((t,e)=>{t.fields.sort=e}))},setErrors:(t,e)=>{t.errors=e},clearErrors:t=>{t.errors=[]},setCurrency:(t,e)=>{t.currency=e},setTotal:(t,e)=>{const s=e;if(h.Type.isStringFilled(t.currency)){for(const i in e){if(e.hasOwnProperty(i)){s[i]=R.CurrencyCore.currencyFormat(e[i],t.currency)}}}t.total=Object.assign(t.total,s)}}}}const S=Object.freeze({databaseConfig:{name:"catalog.product-form"},templateName:"bx-form",templatePanelButtons:"bx-panel-buttons",templatePanelCompilation:"bx-panel-compilation",templateRowName:"bx-form-row",templateFieldInlineSelector:"bx-field-inline-selector",templateFieldPrice:"bx-field-price",templateFieldResultSum:"bx-field-result-sum",templateFieldQuantity:"bx-field-quantity",templateFieldDiscount:"bx-field-discount",templateFieldTax:"bx-field-tax",templateFieldBrand:"bx-field-brand",moduleId:"catalog"});class L{}L.PRODUCT_SELECTOR="product-selector";L.IMAGE_EDITOR="image-editor";L.QUANTITY="quantity";L.PRICE="price";L.RESULT="result";L.DISCOUNT="discount";L.TAX="tax";L.BRAND="brand";L.MEASURE="measure";class M{}M.EMPTY_PRODUCT_SELECTOR=0;M.EMPTY_IMAGE=1;M.EMPTY_QUANTITY=2;M.EMPTY_PRICE=3;M.EMPTY_BRAND=4;M.IS_NULLABLE_PRICE=5;class B{}B.REGULAR="REGULAR";B.READ_ONLY="READ_ONLY";B.COMPILATION="COMPILATION";u.Vue.component(S.templateFieldQuantity,{props:{measureCode:Number,measureRatio:Number,measureName:String,quantity:Number,editable:Boolean,saveableMeasure:Boolean,hasError:Boolean,options:Object},created(){this.onInputQuantityHandler=h.Runtime.debounce(this.onInputQuantity,500,this)},methods:{onInputQuantity(t){if(!this.editable){return}t.target.value=t.target.value.replace(/[^.\d]/g,".");const e=h.Text.toNumber(t.target.value);const s=t.target.value.substr(-1);if(s==="."){return}this.changeQuantity(e)},calculateCorrectionFactor(t,e){let s=t;let i=e;let o=1;while(!(Number.isInteger(s)&&Number.isInteger(i))){o*=10;s=t*o;i=e*o}return o},incrementValue(){if(!this.editable){return}const t=this.calculateCorrectionFactor(this.quantity,this.measureRatio);const e=(this.quantity*t+this.measureRatio*t)/t;this.changeQuantity(e)},decrementValue(){if(this.quantity>this.measureRatio&&this.editable){const t=this.calculateCorrectionFactor(this.quantity,this.measureRatio);const e=(this.quantity*t-this.measureRatio*t)/t;this.changeQuantity(e)}},changeQuantity(t){this.$emit("onChangeQuantity",t)},showPopupMenu(t){if(!this.editable||!h.Type.isArray(this.options.measures)){return}const e=[];this.options.measures.forEach((t=>{e.push({text:t.SYMBOL,item:t,onclick:this.selectMeasure})}));if(e.length>0){this.popupMenu=new p.Menu({bindElement:t,items:e});this.popupMenu.show()}},selectMeasure(t,e){var s,i;this.$emit("onSelectMeasure",{code:(s=e.options)==null?void 0:s.item.CODE,name:(i=e.options)==null?void 0:i.item.SYMBOL});if(this.popupMenu){this.popupMenu.close()}}},template:`\n\t\t<div class="catalog-pf-product-input-wrapper" v-bind:class="{ 'ui-ctl-danger': hasError }">\n\t\t\t<input \t\n\t\t\t\ttype="text" class="catalog-pf-product-input"\n\t\t\t\tv-bind:class="{ 'catalog-pf-product-input--disabled': !editable }"\n\t\t\t\t:value="quantity"\n\t\t\t\t@input="onInputQuantityHandler"\n\t\t\t\t:disabled="!editable"\n\t\t\t>\n\t\t\t<div \n\t\t\t\tclass="catalog-pf-product-input-info catalog-pf-product-input-info--action" \n\t\t\t\t@click="showPopupMenu($event.target)"\n\t\t\t>\n\t\t\t\t<span>{{ measureName }}</span>\n\t\t\t</div>\n\t\t</div>\n\t`});u.Vue.component(S.templateFieldPrice,{props:{selectorId:String,price:Number,editable:Boolean,hasError:Boolean,options:Object},created(){this.onInputPriceHandler=h.Runtime.debounce(this.onInputPrice,500,this)},methods:{onInputPrice(t){if(!this.editable){return}t.target.value=t.target.value.replace(/[^.,\d]/g,"");if(t.target.value===""){t.target.value=0}const e=t.target.value.substr(-1);if(e===","){t.target.value=t.target.value.replace(",",".")}let s=h.Text.toNumber(t.target.value);if(e==="."||e===","){return}if(s<0){s*=-1}this.$emit("onChangePrice",s)}},computed:{localize(){return u.Vue.getFilteredPhrases("CATALOG_")},currencySymbol(){return this.options.currencySymbol||""}},template:`\n\t\t<div class="catalog-pf-product-input-wrapper" v-bind:class="{ 'ui-ctl-danger': hasError }">\n\t\t\t<input \ttype="text" class="catalog-pf-product-input catalog-pf-product-input--align-right"\n\t\t\t\t\tv-bind:class="{ 'catalog-pf-product-input--disabled': !editable }"\n\t\t\t\t\tv-model.lazy="price"\n\t\t\t\t\t@input="onInputPriceHandler"\n\t\t\t\t\t:disabled="!editable"\n\t\t\t>\n\t\t\t<div class="catalog-pf-product-input-info" v-html="currencySymbol"></div>\n\t\t</div>\n\t`});u.Vue.component(S.templateFieldDiscount,{props:{editable:Boolean,options:Object,discount:Number,discountType:Number,discountRate:Number},created(){this.onInputDiscount=h.Runtime.debounce(this.onChangeDiscount,500,this);this.currencySymbol=this.options.currencySymbol},methods:{onChangeType(t,e){var s;if(!this.editable){return}const i=h.Text.toNumber(e==null?void 0:(s=e.options)==null?void 0:s.type)===A.DiscountType.MONETARY?A.DiscountType.MONETARY:A.DiscountType.PERCENTAGE;this.$emit("changeDiscountType",i);if(this.popupMenu){this.popupMenu.close()}},onChangeDiscount(t){const e=h.Text.toNumber(t.target.value)||0;if(e===h.Text.toNumber(this.discount)||!this.editable){return}this.$emit("changeDiscount",e)},showPopupMenu(t){if(!this.editable||!h.Type.isArray(this.options.allowedDiscountTypes)){return}const e=[];if(this.options.allowedDiscountTypes.includes(A.DiscountType.PERCENTAGE)){e.push({text:"%",onclick:this.onChangeType,type:A.DiscountType.PERCENTAGE})}if(this.options.allowedDiscountTypes.includes(A.DiscountType.MONETARY)){e.push({text:this.currencySymbol,onclick:this.onChangeType,type:A.DiscountType.MONETARY})}if(e.length>0){this.popupMenu=new p.Menu({bindElement:t,items:e});this.popupMenu.show()}}},computed:{getDiscountInputValue(){if(h.Text.toNumber(this.discountType)===A.DiscountType.PERCENTAGE){return h.Text.toNumber(this.discountRate)}return h.Text.toNumber(this.discount)},getDiscountSymbol(){return h.Text.toNumber(this.discountType)===A.DiscountType.PERCENTAGE?"%":this.currencySymbol}},template:`\n\t\t<div class="catalog-pf-product-input-wrapper catalog-pf-product-input-wrapper--left">\n\t\t\t<input class="catalog-pf-product-input catalog-pf-product-input--align-right catalog-pf-product-input--right"\n\t\t\t\t\tv-bind:class="{ 'catalog-pf-product-input--disabled': !editable }"\n\t\t\t\t\tref="discountInput" \n\t\t\t\t\t:value="getDiscountInputValue"\n\t\t\t\t\t:v-model="discountRate"\n\t\t\t\t\t@input="onInputDiscount"\n\t\t\t\t\tplaceholder="0"\n\t\t\t\t\t:disabled="!editable">\n\t\t\t<div class="catalog-pf-product-input-info catalog-pf-product-input-info--action" \n\t\t\t\t@click="showPopupMenu">\n\t\t\t\t<span v-html="getDiscountSymbol"></span>\n\t\t\t</div>\n\t\t</div>\n\t`});u.Vue.component(S.templateFieldTax,{props:{taxId:Number,editable:Boolean,options:Object},data(){return{taxValue:this.getTaxList()[this.taxId]||0}},methods:{onChangeValue(t,e){var s,i;const o=h.Text.toNumber(e==null?void 0:(s=e.options)==null?void 0:s.item);if(o===h.Text.toNumber(this.taxValue)||!this.editable){return}this.$emit("changeTax",{taxValue:o,taxId:e==null?void 0:(i=e.options)==null?void 0:i.id});if(this.popupMenu){this.popupMenu.close()}},getTaxList(){return h.Type.isArray(this.options.taxList)?this.options.taxList:[]},showPopupMenu(t){if(!this.editable||!h.Type.isArray(this.options.taxList)){return}const e=[];this.options.taxList.forEach(((t,s)=>{e.push({id:s,text:t+"%",item:t,onclick:this.onChangeValue})}));if(e.length>0){this.popupMenu=new p.Menu({bindElement:t,items:e});this.popupMenu.show()}}},template:`\n\t\t<div class="catalog-pf-product-input-wrapper catalog-pf-product-input-wrapper--right" @click="showPopupMenu">\n\t\t\t<div class="catalog-pf-product-input">{{this.taxValue}}%</div>\n\t\t\t<div class="catalog-pf-product-input-info catalog-pf-product-input-info--dropdown"></div>\n\t\t</div>\n\t`});u.Vue.component(S.templateFieldInlineSelector,{props:{editable:Boolean,basketLength:Number,options:Object,basketItem:Object,model:Object},data(){return{currencySymbol:null,productSelector:null,imageControlId:null,selectorId:this.basketItem.selectorId}},created(){_.EventEmitter.subscribe("BX.Catalog.ProductSelector:onProductSelect",this.onProductSelect.bind(this));_.EventEmitter.subscribe("BX.Catalog.ProductSelector:onChange",this.onProductChange.bind(this));_.EventEmitter.subscribe("BX.Catalog.ProductSelector:onClear",this.onProductClear.bind(this))},mounted(){this.productSelector=new r.ProductSelector(this.selectorId,this.prepareSelectorParams());this.productSelector.renderTo(this.$refs.selectorWrapper)},methods:{prepareSelectorParams(){const t={NAME:this.getField("name")||""};if(!h.Type.isNil(this.getField("basePrice"))){t.PRICE=this.getField("basePrice");t.CURRENCY=this.options.currency}const e={iblockId:this.options.iblockId,basePriceId:this.options.basePriceId,currency:this.options.currency,skuTree:this.getDefaultSkuTree(),fileInputId:"",morePhotoValues:[],fileInput:"",model:this.model,config:{DETAIL_PATH:this.basketItem.detailUrl||"",ENABLE_SEARCH:true,ENABLE_INPUT_DETAIL_LINK:true,ENABLE_IMAGE_CHANGE_SAVING:true,ENABLE_EMPTY_PRODUCT_ERROR:this.options.enableEmptyProductError||this.isRequiredField(L.PRODUCT_SELECTOR),ENABLE_EMPTY_IMAGES_ERROR:this.isRequiredField(L.IMAGE_EDITOR),ROW_ID:this.selectorId,ENABLE_SKU_SELECTION:this.editable,HIDE_UNSELECTED_ITEMS:this.options.hideUnselectedProperties,URL_BUILDER_CONTEXT:this.options.urlBuilderContext},mode:this.editable?r.ProductSelector.MODE_EDIT:r.ProductSelector.MODE_VIEW,fields:t};const s=this.basketItem.image;if(h.Type.isObject(s)){e.fileView=s.preview;e.fileInput=s.input;e.fileInputId=s.id;e.morePhotoValues=s.values}return e},isEnabledSaving(){return this.options.enableCatalogSaving&&this.basketItem.hasEditRights},isRequiredField(t){return h.Type.isArray(this.options.requiredFields)&&this.options.requiredFields.includes(t)},getDefaultSkuTree(){let t=this.basketItem.skuTree||{};if(h.Type.isStringFilled(t)){t=JSON.parse(t)}return t},getField(t,e=null){return this.basketItem.fields[t]||e},onProductSelect(t){const e=t.getData();if(h.Type.isStringFilled(e.selectorId)&&e.selectorId===this.productSelector.getId()){this.$emit("onProductSelect")}},onProductChange(t){const e=t.getData();if(h.Type.isStringFilled(e.selectorId)&&e.selectorId===this.productSelector.getId()){const t=e.fields.BASE_PRICE;const s={BASE_PRICE:t,MODULE:"catalog",NAME:e.fields.NAME,ID:e.fields.ID,PRODUCT_ID:e.fields.PRODUCT_ID,SKU_ID:e.fields.SKU_ID,PROPERTIES:e.fields.PROPERTIES,URL_BUILDER_CONTEXT:this.options.urlBuilderContext,CUSTOMIZED:h.Type.isNil(e.fields.PRICE)||e.fields.CUSTOMIZED==="Y"?"Y":"N",MEASURE_CODE:e.fields.MEASURE_CODE,MEASURE_NAME:e.fields.MEASURE_NAME,IS_NEW:e.isNew};this.$emit("onProductChange",s)}},onProductClear(t){const e=t.getData();if(h.Type.isStringFilled(e.selectorId)&&e.selectorId===this.productSelector.getId()){this.$emit("onProductClear")}}},template:`\n\t\t<div class="catalog-pf-product-item-section" :id="selectorId" ref="selectorWrapper"></div>\n\t`});let N=t=>t,x,D;u.Vue.component(S.templateFieldBrand,{props:{brands:[Array,String],options:Object,editable:Boolean,hasError:Boolean,selectorId:String},data(){return{cache:new h.Cache.MemoryCache}},created(){this.selector=new l.TagSelector({id:this.selectorId,dialogOptions:{id:this.selectorId,context:"CATALOG_BRANDS",preselectedItems:this.getPreselectedBrands(),events:{"Item:onSelect":this.onBrandChange.bind(this),"Item:onDeselect":this.onBrandChange.bind(this),"Search:onItemCreateAsync":this.createBrand.bind(this)},searchTabOptions:{stub:true,stubOptions:{title:h.Tag.message(x||(x=N`${0}`),"CATALOG_FORM_BRAND_SELECTOR_IS_EMPTY_TITLE"),subtitle:h.Tag.message(D||(D=N`${0}`),"CATALOG_FORM_BRAND_SELECTOR_IS_EMPTY_SUBTITLE"),arrow:true}},searchOptions:{allowCreateItem:true},entities:[{id:"brand",options:{iblockId:this.options.iblockId},dynamicSearch:true,dynamicLoad:true}]}})},mounted(){this.selector.renderTo(this.$refs.brandSelectorWrapper)},methods:{getPreselectedBrands(){if(!h.Type.isArray(this.brands)||this.brands.length===0){return[]}return this.brands.map((t=>["brand",t]))},onBrandChange(t){const e=t.getTarget().getSelectedItems();const s=[];if(h.Type.isArray(e)){e.forEach((t=>{s.push(t.getId())}))}this.$emit("changeBrand",s)},createBrand(t){const{searchQuery:e}=t.getData();const s=this.options.iblockId;return new Promise(((i,o)=>{const a=t.getTarget();const n={name:e.getQuery(),iblockId:s};a.showLoader();h.ajax.runAction("catalog.productForm.createBrand",{data:{fields:n}}).then((t=>{a.hideLoader();const s=a.addItem({id:t.data.id,entityId:"brand",title:e.getQuery(),tabs:a.getRecentTab().getId()});if(s){s.select()}a.hide();i()})).catch((()=>o()))}))}},computed:{localize(){return u.Vue.getFilteredPhrases("CATALOG_")}},template:`\n\t\t<div class="catalog-pf-product-control ui-ctl-w100" v-bind:class="{ 'ui-ctl-danger': hasError }">\n\t\t\t<div class="catalog-pf-product-input-wrapper" ref="brandSelectorWrapper" :id="selectorId"></div>\n\t\t</div>\n\t`});u.Vue.component(S.templateFieldResultSum,{props:{sum:Number,editable:Boolean,options:Object},created(){this.onInputSumHandler=h.Runtime.debounce(this.onInputSum,500,this)},methods:{onInputSum(t){if(!this.editable){return}t.target.value=t.target.value.replace(/[^.,\d]/g,"");if(t.target.value===""){t.target.value=0}let e=t.target.value.substr(-1);if(e===","){t.target.value=t.target.value.replace(",",".")}let s=h.Text.toNumber(t.target.value);if(e==="."||e===","){return}if(s<0){s*=-1}this.$emit("onChangeSum",s)}},computed:{localize(){return u.Vue.getFilteredPhrases("CATALOG_")},currencySymbol(){return this.options.currencySymbol||""}},template:`\n\t\t<div class="catalog-pf-product-input-wrapper">\n\t\t\t<input \ttype="text" \n\t\t\t\t\tclass="catalog-pf-product-input catalog-pf-product-input--align-right"\n\t\t\t\t\t:class="{ 'catalog-pf-product-input--disabled': !editable }"\n\t\t\t\t\t:value="sum"\n\t\t\t\t\t@input="onInputSumHandler"\n\t\t\t\t\t:disabled="!editable"\n\t\t\t>\n\t\t\t<div class="catalog-pf-product-input-info"\n\t\t\t\t :class="{ 'catalog-pf-product-input--disabled': !editable }"\n\t\t\t\t v-html="currencySymbol"\n\t\t\t></div>\n\t\t</div>\n\t`});u.Vue.component(S.templateRowName,{props:{basketItem:Object,basketItemIndex:Number,basketLength:Number,countItems:Number,options:Object,mode:String},data(){return{model:null,currencySymbol:null,productSelector:null,imageControlId:null,selectorId:this.basketItem.selectorId,defaultMeasure:{name:"",id:null},blocks:{productSelector:L.PRODUCT_SELECTOR,quantity:L.QUANTITY,price:L.PRICE,result:L.RESULT,discount:L.DISCOUNT,tax:L.TAX,brand:L.BRAND,measure:L.MEASURE},errorCodes:{emptyProductSelector:M.EMPTY_PRODUCT_SELECTOR,emptyImage:M.EMPTY_IMAGE,emptyQuantity:M.EMPTY_QUANTITY,emptyPrice:M.EMPTY_PRICE,emptyBrand:M.EMPTY_BRAND}}},created(){this.currencySymbol=this.options.currencySymbol;this.model=this.initModel();if(h.Type.isArray(this.options.measures)){this.options.measures.map((t=>{if(t["IS_DEFAULT"]==="Y"){this.defaultMeasure.name=t.SYMBOL;this.defaultMeasure.code=t.CODE;if(!this.basketItem.fields.measureName&&!this.basketItem.fields.measureCode){this.changeProductFields({measureCode:this.defaultMeasure.code,measureName:this.defaultMeasure.name})}}}))}},methods:{prepareModelFields(){var t,e,s,i,o,a,n,r;const l=this.basketItem.fields;const c=h.Text.toNumber(l.price);let d=l.basePrice?l.basePrice:l.price;if(!h.Type.isNil(d)){d=h.Text.toNumber(d)}return{NAME:((t=this.basketItem.fields)==null?void 0:t.name)||"",MODULE:((e=this.basketItem.fields)==null?void 0:e.module)||"",PROPERTIES:((s=this.basketItem.fields)==null?void 0:s.properties)||{},BRAND:((i=this.basketItem.fields)==null?void 0:i.brand)||{},PRODUCT_ID:(o=this.basketItem.fields)==null?void 0:o.productId,ID:((a=this.basketItem.fields)==null?void 0:a.skuId)||((n=this.basketItem.fields)==null?void 0:n.productId),SKU_ID:(r=this.basketItem.fields)==null?void 0:r.skuId,QUANTITY:h.Text.toNumber(l.quantity),BASE_PRICE:d,PRICE:c,PRICE_NETTO:d,PRICE_BRUTTO:c,PRICE_EXCLUSIVE:this.basketItem.fields.priceExclusive||c,DISCOUNT_TYPE_ID:h.Text.toNumber(l.discountType)||A.DiscountType.PERCENTAGE,DISCOUNT_RATE:h.Text.toNumber(l.discountRate),DISCOUNT_SUM:h.Text.toNumber(l.discount),TAX_INCLUDED:l.taxIncluded||this.options.taxIncluded,TAX_RATE:l.tax||0,CUSTOMIZED:l.isCustomPrice||"N",MEASURE_CODE:l.measureCode||this.defaultMeasure.code,MEASURE_NAME:l.measureName||this.defaultMeasure.name}},initModel(){var t,e,s;const i=h.Text.toNumber((t=this.basketItem.fields)==null?void 0:t.productId);const o=h.Text.toNumber((e=this.basketItem.fields)==null?void 0:e.skuId);const a=new c.ProductModel({iblockId:h.Text.toNumber(this.options.iblockId),basePriceId:h.Text.toNumber(this.options.basePriceId),currency:this.options.currency,isSimpleModel:h.Type.isStringFilled((s=this.basketItem.fields)==null?void 0:s.name)&&i<=0&&o<=0,fields:this.prepareModelFields()});_.EventEmitter.subscribe(a,"onErrorsChange",this.onErrorsChange);return a},onErrorsChange(){const t=Object.values(this.model.getErrorCollection().getErrors());this.changeRowData({errors:t});this.$emit("emitErrorsChange",{index:this.basketItemIndex,errors:t})},setCalculatedFields(t){this.model.getCalculator().setFields(t);const e={calculatedFields:t};if(h.Text.toNumber(t.SUM)>=0){e.sum=h.Text.toNumber(t.SUM)}if(!h.Type.isNil(t.ID)){e.offerId=h.Text.toNumber(t.ID)}this.changeRowData(e)},getProductFieldsFromModel(){const t=this.model.getFields();return{productId:t.PRODUCT_ID,skuId:t.SKU_ID,name:t.NAME,module:t.MODULE,basePrice:t.BASE_PRICE,price:t.PRICE,priceExclusive:t.PRICE_EXCLUSIVE,quantity:t.QUANTITY,discountRate:t.DISCOUNT_RATE,discount:t.DISCOUNT_SUM,discountType:t.DISCOUNT_TYPE_ID,isCustomPrice:t.CUSTOMIZED||"N",measureCode:t.MEASURE_CODE||"",measureName:t.MEASURE_NAME||"",properties:t.PROPERTIES||{},brands:t.BRANDS||{},taxId:t.TAX_ID}},changeRowData(t){this.$emit("changeRowData",{index:this.basketItemIndex,product:t})},changeProductFields(t){t=Object.assign(this.basketItem.fields,t);this.$emit("changeProduct",{index:this.basketItemIndex,product:{fields:t},skipFieldChecking:this.model.isSimple()&&this.basketLength===1})},saveCatalogField(t){return this.model.save(t)},onProductChange(t){t=Object.assign(this.model.getCalculator().calculateBasePrice(t.BASE_PRICE),t);this.changeRowData({catalogPrice:t.BASE_PRICE});this.processFields(t);this.setCalculatedFields(t)},onProductSelect(){this.changeProductFields({additionalFields:{originBasketId:"",originProductId:""}})},onProductClear(){const t=this.model.getCalculator().calculatePrice(0);t.BASE_PRICE=0;t.NAME="";t.ID=0;t.PRODUCT_ID=0;t.SKU_ID=0;t.MODULE="";this.setCalculatedFields(t)},onChangeSum(t){const e=t/h.Text.toNumber(this.basketItem.fields.quantity)+h.Text.toNumber(this.basketItem.fields.discount);this.onChangePrice(e)},onChangePrice(t){if(!this.options.isCatalogPriceSaveEnabled){this.changeBasePrice(t);return}this.model.showSaveNotifier("priceChanger_"+this.selectorId,{title:h.Loc.getMessage("CATALOG_PRODUCT_MODEL_SAVING_NOTIFICATION_PRICE_CHANGED_QUERY"),events:{onCancel:()=>{const e=this.changePrice(t);if(e.DISCOUNT_SUM>0){this.toggleDiscount("Y");this.$root.$app.changeFormOption("showDiscountBlock","Y")}},onSave:()=>{this.changeBasePrice(t);this.saveCatalogField(["BASE_PRICE"]).then((()=>{this.changeRowData({catalogPrice:t})}))}}})},onSelectMeasure(t){this.changeMeasure(t);this.model.showSaveNotifier("measureChanger_"+this.selectorId,{title:h.Loc.getMessage("CATALOG_PRODUCT_MODEL_SAVING_NOTIFICATION_MEASURE_CHANGED_QUERY"),events:{onSave:()=>{this.saveCatalogField(["MEASURE_CODE","MEASURE_NAME"])}}})},toggleDiscount(t){if(this.isReadOnly){return}this.changeRowData({showDiscount:t});if(t==="Y"){setTimeout((()=>{var t,e,s,i;return(t=this.$refs)==null?void 0:(e=t.discountWrapper)==null?void 0:(s=e.$refs)==null?void 0:(i=s.discountInput)==null?void 0:i.focus()}))}},toggleTax(t){this.changeRowData({showTax:t})},processFields(t){this.model.getCalculator().setFields(t);this.model.setFields(t);this.changeProductFields({...this.basketItem.fields,...this.getProductFieldsFromModel()});if(!h.Type.isNil(t.SUM)){this.changeRowData({sum:t.SUM})}},changeBrand(t){const e=h.Type.isArray(t)?t:[];this.processFields({BRANDS:e})},onChangeQuantity(t){this.model.getCalculator().setFields();this.processFields(this.model.getCalculator().calculateQuantity(t))},changeMeasure(t){const e=this.basketItem.fields;e["measureCode"]=t.code;e["measureName"]=t.name;this.processFields({MEASURE_CODE:t.code,MEASURE_NAME:t.name})},changeBasePrice(t){this.model.setField("BASE_PRICE",t);this.processFields(this.model.getCalculator().calculateBasePrice(t))},changePrice(t){this.model.getCalculator().setFields(this.model.getCalculator().calculateBasePrice(this.basketItem.catalogPrice));const e=this.model.getCalculator().calculatePrice(t);this.processFields(e);return e},changeDiscountType(t){const e=h.Text.toNumber(t)===A.DiscountType.MONETARY?A.DiscountType.MONETARY:A.DiscountType.PERCENTAGE;const s=this.model.getCalculator().calculateDiscountType(e);this.processFields(s);return s},changeDiscount(t){const e=this.model.getCalculator().calculateDiscount(t);this.processFields(e);return e},changeTax(t){const e=this.model.getCalculator().calculateTax(t.taxValue);e.TAX_ID=t.taxId;this.processFields(e);return e},changeTaxIncluded(t){if(t===this.basketItem.taxIncluded||!this.isEditableField(this.blocks.tax)){return}const e=this.model.getCalculator().calculateTaxIncluded(t);this.processFields(e);return e},removeItem(){this.$emit("removeItem",{index:this.basketItemIndex})},isRequiredField(t){return h.Type.isArray(this.options.requiredFields)&&this.options.requiredFields.includes(t)},isVisibleBlock(t){return h.Type.isArray(this.options.visibleBlocks)&&this.options.visibleBlocks.includes(t)},hasError(t){if(this.basketItem.errors.length===0||this.model.isEmpty()&&!this.model.isChanged()){return false}const e=this.basketItem.errors.filter((e=>e.code===t));return e.length>0},isEditablePrice(){var t,e;return((t=this.options)==null?void 0:t.editableFields.includes(L.PRICE))&&(this.model.isNew()||!this.model.isCatalogExisted()||((e=this.options)==null?void 0:e.isCatalogPriceEditEnabled))},isEditableField(t){var e,s;if(t===L.PRICE&&!((e=this.options)!=null&&e.isCatalogPriceEditEnabled)){return this.isEditablePrice()}return(s=this.options)==null?void 0:s.editableFields.includes(t)},getHint(t){var e;return(e=this.options)==null?void 0:e.fieldHints[t]},hasHint(t){var e;if(t===L.PRICE&&!((e=this.options)!=null&&e.isCatalogPriceEditEnabled)){return!this.isEditablePrice()}return false},showPriceNotify(){const t=this.getHint(this.blocks.price);if(h.Text.toNumber(t==null?void 0:t.ARTICLE_CODE)>0){top.BX.Helper.show("redirect=detail&code="+h.Text.toNumber(t==null?void 0:t.ARTICLE_CODE))}}},watch:{taxIncluded(t,e){if(t!==e){this.changeTaxIncluded(t)}}},computed:{localize(){return u.Vue.getFilteredPhrases("CATALOG_FORM_")},showDiscount(){return this.showDiscountBlock&&this.basketItem.showDiscount==="Y"},getBrandsSelectorId(){return this.basketItem.selectorId+"_brands"},getPriceExclusive(){return this.basketItem.fields.priceExclusive||this.basketItem.fields.price},showDiscountBlock(){return this.options.showDiscountBlock==="Y"&&this.isVisibleBlock(this.blocks.discount)&&!this.isReadOnly},showTaxBlock(){return this.options.showTaxBlock==="Y"&&this.getTaxList.length>0&&this.isVisibleBlock(this.blocks.tax)&&!this.isReadOnly},showRemoveIcon(){if(this.isReadOnly){return false}if(this.countItems>1){return true}return!h.Type.isNil(this.basketItem.offerId)},showTaxSelector(){return this.basketItem.showTax==="Y"},showBasePrice(){return this.basketItem.fields.discount>0||h.Text.toNumber(this.basketItem.fields.price)!==h.Text.toNumber(this.basketItem.fields.basePrice)},getMeasureName(){return this.basketItem.fields.measureName||this.defaultMeasure.name},getMeasureCode(){return this.basketItem.fields.measureCode||this.defaultMeasure.code},getTaxList(){return h.Type.isArray(this.options.taxList)?this.options.taxList:[]},taxIncluded(){return this.basketItem.fields.taxIncluded},isTaxIncluded(){return this.taxIncluded==="Y"},isReadOnly(){return this.mode===B.READ_ONLY}},template:`\n\t\t<div class="catalog-pf-product-item" v-bind:class="{ 'catalog-pf-product-item--borderless': !isReadOnly && basketItemIndex === 0 }">\n\t\t\t<div class="catalog-pf-product-item--remove" @click="removeItem" v-if="showRemoveIcon"></div>\n\t\t\t<div class="catalog-pf-product-item--num">\n\t\t\t\t<div class="catalog-pf-product-index">{{basketItemIndex + 1}}</div>\n\t\t\t</div>\n\t\t\t<div class="catalog-pf-product-item--left">\n\t\t\t\t<div v-if="isVisibleBlock(blocks.productSelector)">\n\t\t\t\t\t<div class="catalog-pf-product-item-section">\n\t\t\t\t\t\t<div class="catalog-pf-product-label">{{localize.CATALOG_FORM_NAME}}</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<${S.templateFieldInlineSelector}\n\t\t\t\t\t\t:basketItem="basketItem"\n\t\t\t\t\t\t:basketLength="basketLength"\n\t\t\t\t\t\t:options="options"\n\t\t\t\t\t\t:model="model"\n\t\t\t\t\t\t:editable="isEditableField(blocks.productSelector)"\n\t\t\t\t\t\t@onProductSelect="onProductSelect"\n\t\t\t\t\t\t@onProductChange="onProductChange"\n\t\t\t\t\t\t@saveCatalogField="saveCatalogField"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div v-if="isVisibleBlock(blocks.brand)" class="catalog-pf-product-input-brand-wrapper">\n\t\t\t\t\t<div class="catalog-pf-product-item-section">\n\t\t\t\t\t\t<div class="catalog-pf-product-label">{{localize.CATALOG_FORM_BRAND_TITLE}}</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<${S.templateFieldBrand}\n\t\t\t\t\t\t:brands="basketItem.fields.brands"\n\t\t\t\t\t\t:selectorId="getBrandsSelectorId"\n\t\t\t\t\t\t:hasError="hasError(errorCodes.emptyBrand)"\n\t\t\t\t\t\t:options="options"\n\t\t\t\t\t\t:editable="isEditableField(blocks.brand)"\n\t\t\t\t\t\t@changeBrand="changeBrand"\n\t\t\t\t\t\t@saveCatalogField="saveCatalogField"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t</div>\n\t\t\t<div class="catalog-pf-product-item--right">\n\t\t\t\t<div class="catalog-pf-product-item-section">\n\t\t\t\t\t<div v-if="isVisibleBlock(blocks.price)" class="catalog-pf-product-label" style="width: 94px">\n\t\t\t\t\t\t{{localize.CATALOG_FORM_PRICE}}\n\t\t\t\t\t\t<span v-if="hasHint(blocks.price)" class="ui-hint-icon" @click="showPriceNotify"></span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div v-if="isVisibleBlock(blocks.quantity)" class="catalog-pf-product-label" style="width: 72px">\n\t\t\t\t\t\t{{localize.CATALOG_FORM_QUANTITY}}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div v-if="isVisibleBlock(blocks.result)" class="catalog-pf-product-label" style="width: 94px">\n\t\t\t\t\t\t{{localize.CATALOG_FORM_RESULT}}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class="catalog-pf-product-item-section">\n\n\t\t\t\t\t<div v-if="isVisibleBlock(blocks.price)" class="catalog-pf-product-control" style="width: 94px">\n\t\t\t\t\t\t<${S.templateFieldPrice}\n\t\t\t\t\t\t\t:selectorId="basketItem.selectorId"\n\t\t\t\t\t\t\t:price="basketItem.fields.basePrice"\n\t\t\t\t\t\t\t:options="options"\n\t\t\t\t\t\t\t:editable="isEditableField(blocks.price)"\n\t\t\t\t\t\t\t:hasError="hasError(errorCodes.emptyPrice)"\n\t\t\t\t\t\t\t@onChangePrice="onChangePrice"\n\t\t\t\t\t\t\t@saveCatalogField="saveCatalogField"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div v-if="isVisibleBlock(blocks.quantity)" class="catalog-pf-product-control" style="width: 72px">\n\t\t\t\t\t\t<${S.templateFieldQuantity}\n\t\t\t\t\t\t\t:quantity="basketItem.fields.quantity"\n\t\t\t\t\t\t\t:measureCode="getMeasureCode"\n\t\t\t\t\t\t\t:measureRatio="basketItem.fields.measureRatio"\n\t\t\t\t\t\t\t:measureName="getMeasureName"\n\t\t\t\t\t\t\t:hasError="hasError(errorCodes.emptyQuantity)"\n\t\t\t\t\t\t\t:options="options"\n\t\t\t\t\t\t\t:editable="isEditableField(blocks.quantity)"\n\t\t\t\t\t\t\t@onChangeQuantity="onChangeQuantity"\n\t\t\t\t\t\t\t@onSelectMeasure="onSelectMeasure"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div v-if="isVisibleBlock(blocks.result)" class="catalog-pf-product-control" style="width: 94px">\n\t\t\t\t\t\t<${S.templateFieldResultSum}\n\t\t\t\t\t\t\t\t:sum="basketItem.sum"\n\t\t\t\t\t\t\t\t:options="options"\n\t\t\t\t\t\t\t\t:editable="isEditableField(blocks.result)"\n\t\t\t\t\t\t\t\t@onChangeSum="onChangeSum"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div v-if="hasError(errorCodes.emptyQuantity)" class="catalog-pf-product-item-section">\n\t\t\t\t\t<div class="catalog-product-error">{{localize.CATALOG_FORM_ERROR_EMPTY_QUANTITY}}</div>\n\t\t\t\t</div>\n\t\t\t\t<div v-if="hasError(errorCodes.emptyPrice)" class="catalog-pf-product-item-section">\n\t\t\t\t\t<div class="catalog-product-error">{{localize.CATALOG_FORM_ERROR_EMPTY_PRICE}}</div>\n\t\t\t\t</div>\n\t\t\t\t<div v-if="showDiscountBlock" class="catalog-pf-product-item-section">\n\t\t\t\t\t<div v-if="showDiscount" class="catalog-pf-product-link-toggler catalog-pf-product-link-toggler--hide" @click="toggleDiscount('N')">{{localize.CATALOG_FORM_DISCOUNT_TITLE}}</div>\n\t\t\t\t\t<div v-else class="catalog-pf-product-link-toggler catalog-pf-product-link-toggler--show" @click="toggleDiscount('Y')">{{localize.CATALOG_FORM_DISCOUNT_TITLE}}</div>\n\t\t\t\t</div>\n\n\t\t\t\t<div v-if="showDiscount" class="catalog-pf-product-item-section">\n\t\t\t\t\t<${S.templateFieldDiscount}\n\t\t\t\t\t\t:discount="basketItem.fields.discount"\n\t\t\t\t\t\t:discountType="basketItem.fields.discountType"\n\t\t\t\t\t\t:discountRate="basketItem.fields.discountRate"\n\t\t\t\t\t\t:options="options"\n\t\t\t\t\t\t:editable="isEditableField(blocks.discount)"\n\t\t\t\t\t\tref="discountWrapper"\n\t\t\t\t\t\t@changeDiscount="changeDiscount"\n\t\t\t\t\t\t@changeDiscountType="changeDiscountType"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t\t<div v-if="showTaxBlock" class="catalog-pf-product-item-section catalog-pf-product-item-section--dashed">\n\t\t\t\t\t<div v-if="showTaxSelector" class="catalog-pf-product-link-toggler catalog-pf-product-link-toggler--hide" @click="toggleTax('N')">{{localize.CATALOG_FORM_TAX_TITLE}}</div>\n\t\t\t\t\t<div v-else class="catalog-pf-product-link-toggler catalog-pf-product-link-toggler--show" @click="toggleTax('Y')">{{localize.CATALOG_FORM_TAX_TITLE}}</div>\n\t\t\t\t</div>\n\t\t\t\t<div v-if="showTaxSelector && showTaxBlock" class="catalog-pf-product-item-section">\n\t\t\t\t\t<${S.templateFieldTax}\n\t\t\t\t\t\t:taxId="basketItem.fields.taxId"\n\t\t\t\t\t\t:options="options"\n\t\t\t\t\t\t:editable="isEditableField(blocks.tax)"\n\t\t\t\t\t\t@changeProduct="changeProduct"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class="catalog-pf-product-item-section catalog-pf-product-item-section--dashed"></div>\n\t\t\t</div>\n\t\t</div>\n\t`});class F{}F.REGULAR="REGULAR";F.FACEBOOK="FACEBOOK";class w{}w.COMPILATION_FACEBOOK=13856526;w.COMMON_COMPILATION=13841876;let U=t=>t,G,$,Y,X,H,V,q,j,z,Q;u.Vue.component(S.templatePanelCompilation,{props:{compilationOptions:Object,mode:String},created(){_.EventEmitter.subscribe("BX.Catalog.ProductSelector:onChange",this.destroyPopup.bind(this));_.EventEmitter.subscribe("BX.Catalog.ProductSelector:onClear",this.destroyPopup.bind(this));this.newLabel=new g.Label({text:this.localize.CATALOG_FORM_COMPILATION_PRODUCT_NEW_LABEL,color:g.LabelColor.PRIMARY,fill:true});const t=h.Tag.render(G||(G=U` <a class="ui-btn ui-btn-primary">${0}</a> `),this.localize.CATALOG_FORM_COMPILATION_INFO_BUTTON_MORE);h.Event.bind(t,"click",this.openHelpDesk);let e="";let s="";if(this.isFacebookForm()){e=this.localize.CATALOG_FORM_COMPILATION_INFO_MESSAGE_TITLE_FACEBOOK;s=h.Tag.render($||($=U` <p>${0}</p> <p>${0}</p> `),this.localize.CATALOG_FORM_COMPILATION_INFO_MESSAGE_BODY_FACEBOOK_FIRST_BLOCK,this.localize.CATALOG_FORM_COMPILATION_INFO_MESSAGE_BODY_FACEBOOK_SECOND_BLOCK)}else{e=this.localize.CATALOG_FORM_COMPILATION_INFO_MESSAGE_TITLE;s=this.localize.CATALOG_FORM_COMPILATION_INFO_MESSAGE_BODY_MARKETING}this.message=new I.MessageCard({id:"compilationInfo",header:e,description:s,angle:false,hidden:true,actionElements:[t]});_.EventEmitter.subscribe(this.message,"onClose",this.hideMessage)},mounted(){this.$refs.label.appendChild(this.newLabel.render());this.$refs.message.appendChild(this.message.getLayout());if(!this.compilationOptions.hiddenInfoMessage){this.showMessage()}},data(){return{compilationLink:null}},methods:{isFacebookForm(){return this.compilationOptions.type===F.FACEBOOK},openHelpDesk(){this.helpdeskCode=this.isFacebookForm()?w.COMPILATION_FACEBOOK:w.COMMON_COMPILATION;top.BX.Helper.show("redirect=detail&code="+this.helpdeskCode)},showPopup(t){if(this.compilationOptions.disabledSwitcher){return}if(this.isFacebookForm()){this.openHelpDesk();return}if(this.popup instanceof p.Popup){this.popup.setBindElement(this.$refs.qrLink);this.popup.show();return}const e=this.$store.getters["productList/getBasket"]();const s=e.map((t=>{var e;return t==null?void 0:(e=t.fields)==null?void 0:e.skuId}));return new Promise(((e,i)=>{h.ajax.runAction("salescenter.api.store.getLinkToProductCollection",{json:{productIds:s}}).then((s=>{this.compilationLink=s.data.link;this.popup=new p.Popup({bindElement:t.target,content:this.getQRPopupContent(),width:375,closeIcon:{top:"5px",right:"5px"},padding:0,closeByEsc:true,autoHide:true,cacheable:true,animation:"fading-slide",angle:{offset:30}});this.popup.show();e()})).catch((()=>i()))}))},destroyPopup(){if(this.popup instanceof p.Popup){this.popup.destroy();this.popup=null}},getQRPopupContent(){if(!this.compilationLink){return""}const t=h.Tag.render(Y||(Y=U` <div class="catalog-pf-product-qr-popup-copy">${0}</div> `),this.localize.CATALOG_FORM_COMPILATION_QR_COPY);h.Event.bind(t,"click",(()=>{BX.clipboard.copy(this.compilationLink);BX.UI.Notification.Center.notify({content:this.localize.CATALOG_FORM_COMPILATION_QR_COPY_NOTIFY_MESSAGE,autoHideDelay:2e3})}));const e=h.Tag.render(X||(X=U`<div class="catalog-pf-product-qr-popup-image"></div>`));const s=h.Tag.render(H||(H=U` <div class="catalog-pf-product-qr-popup"> <div class="catalog-pf-product-qr-popup-content"> <div class="catalog-pf-product-qr-popup-text">${0}</div> ${0} <div class="catalog-pf-product-qr-popup-buttons"> <a href="${0}" target="_blank" class="ui-btn ui-btn-light-border ui-btn-round">${0}</a> </div> </div> <div class="catalog-pf-product-qr-popup-bottom"> <a href="${0}" target="_blank" class="catalog-pf-product-qr-popup--url">${0}</a> ${0} </div> </div> `),this.localize.CATALOG_FORM_COMPILATION_QR_POPUP_TITLE,e,this.compilationLink,this.localize.CATALOG_FORM_COMPILATION_QR_POPUP_INPUT_TITLE,this.compilationLink,this.compilationLink,t);new QRCode(e,{text:this.compilationLink,width:250,height:250});return s},setSetting(t){const e=t.target.checked?"Y":"N";if(!this.compilationOptions.hasStore){this.compilationOptions.disabledSwitcher=true;const s=new p.Popup({bindElement:t.target,className:"catalog-product-form-popup--creating-shop",content:this.getOnBeforeCreationStorePopupContent(),width:310,overlay:true,padding:17,animation:"fading-slide",angle:false});s.show();h.ajax.runAction("salescenter.api.store.getStoreInfo",{json:{}}).then((t=>{var i,o;if(h.Type.isStringFilled((i=t.data)==null?void 0:(o=i.deactivatedStore)==null?void 0:o.TITLE)){var a,n;const e=h.Loc.getMessage("CATALOG_FORM_COMPILATION_UNPUBLISHED_STORE",{"#STORE_TITLE#":h.Tag.safe(V||(V=U`${0}`),(a=t.data)==null?void 0:(n=a.deactivatedStore)==null?void 0:n.TITLE)});BX.UI.Notification.Center.notify({content:h.Tag.render(q||(q=U` <div> <span>${0}</span> <a href="/shop/stores/" target="_blank"> ${0} </a> </div> `),e,h.Loc.getMessage("CATALOG_FORM_COMPILATION_UNPUBLISHED_STORE_LINK"))})}s.setContent(this.getOnAfterCreationStorePopupContent());s.setClosingByEsc(true);s.setAutoHide(true);s.show();this.$root.$app.changeFormOption("isCompilationMode",e);this.compilationOptions.disabledSwitcher=this.compilationOptions.isLimitedStore;this.compilationOptions.hasStore=true}))}else{this.$root.$app.changeFormOption("isCompilationMode",e)}},getOnBeforeCreationStorePopupContent(){const t=h.Tag.render(j||(j=U` <div class="catalog-product-form-popup--loader-block"></div> `));const e=h.Tag.render(z||(z=U` <div class="catalog-product-form-popup--container"> <div class="catalog-product-form-popup--title">${0}</div> ${0} <div class="catalog-product-form-popup--text">${0}</div> </div> `),h.Loc.getMessage("CATALOG_FORM_POPUP_BEFORE_MARKET_CREATING"),t,h.Loc.getMessage("CATALOG_FORM_POPUP_BEFORE_MARKET_CREATING_INFO"));const s=new m.Loader({color:"#2fc6f6",target:t,size:40});s.show();return e},getOnAfterCreationStorePopupContent(){return h.Tag.render(Q||(Q=U` <div class="catalog-product-form-popup--container"> <div class="catalog-product-form-popup--title">${0}</div> <div class="catalog-product-form-popup--loader-block catalog-product-form-popup--done"></div> <div class="catalog-product-form-popup--text">${0}</div> </div> `),h.Loc.getMessage("CATALOG_FORM_POPUP_AFTER_MARKET_CREATING"),h.Loc.getMessage("CATALOG_FORM_POPUP_AFTER_MARKET_CREATING_INFO"))},onLabelClick(){if(this.compilationOptions.isLimitedStore){BX.UI.InfoHelper.show("limit_sites_number")}},onClickHint(t){t.preventDefault();t.stopImmediatePropagation();if(!this.message){return}if(this.message.isShown()){this.hideMessage()}else{this.showMessage()}},showMessage(){if(this.message){h.Dom.addClass(this.$refs.hintIcon,"catalog-pf-product-panel-message-arrow-target");this.message.show()}},hideMessage(){if(this.message){h.Dom.removeClass(this.$refs.hintIcon,"catalog-pf-product-panel-message-arrow-target")}this.message.hide();this.$root.$app.changeFormOption("hiddenCompilationInfoMessage","Y")}},computed:{localize(){return u.Vue.getFilteredPhrases("CATALOG_")},showQrLink(){return this.mode===B.COMPILATION},...d.Vuex.mapState({productList:t=>t.productList})},template:`\n\t\t<div>\n\t\t\t<div class="catalog-pf-product-panel-compilation">\n\t\t\t\t<div class="catalog-pf-product-panel-compilation-wrapper">\n\t\t\t\t\t<label class="ui-ctl ui-ctl-checkbox" @click="onLabelClick">\n\t\t\t\t\t\t<input \n\t\t\t\t\t\t\ttype="checkbox" \n\t\t\t\t\t\t\t:disabled="compilationOptions.disabledSwitcher"\n\t\t\t\t\t\t\tclass="ui-ctl-element" \n\t\t\t\t\t\t\t@change="setSetting" \n\t\t\t\t\t\t\tdata-setting-id="isCompilationMode"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t<div class="ui-ctl-label-text">{{localize.CATALOG_FORM_COMPILATION_PRODUCT_SWITCHER}}</div>\n\t\t\t\t\t\t<div ref="hintIcon">\n\t\t\t\t\t\t\t<div data-hint-init="vue" class="ui-hint" @click="onClickHint">\n\t\t\t\t\t\t\t\t<span class="ui-hint-icon"></span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div ref="label"></div>\n\t\t\t\t\t\t<div class="tariff-lock" v-if="compilationOptions.isLimitedStore"></div>\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t\t<div \t\t\t\t\n\t\t\t\t\tv-if="showQrLink"\n\t\t\t\t\tclass="catalog-pf-product-panel-compilation-link --icon-qr"\n\t\t\t\t\t@click="showPopup"\n\t\t\t\t\tref="qrLink"\n\t\t\t\t>\n\t\t\t\t\t{{localize.CATALOG_FORM_COMPILATION_QR_LINK}}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class="catalog-pf-product-panel-compilation-message" ref="message"></div>\n\t\t</div>\n\t`});let K=t=>t,W,Z,J,tt;u.Vue.component(S.templatePanelButtons,{props:{options:Object,mode:String},data(){return{settings:[]}},methods:{refreshBasket(){this.$emit("refreshBasket")},changeBasketItem(t){this.$emit("changeRowData",t)},addBasketItemForm(){this.$emit("addItem")},getInternalIndexByProductId(t){const e=this.$store.getters["productList/getBasket"]();return Object.keys(e).findIndex((s=>parseInt(e[s].skuId)===parseInt(t)))},handleAddItem(t,e){const s=4;if(h.Text.toNumber(e.type)===s){h.ajax.runAction("catalog.productSelector.getSelectedSku",{json:{variationId:t,options:{priceId:this.options.basePriceId,urlBuilder:this.options.urlBuilder,currency:this.options.currency,resetSku:true}}}).then((t=>this.processResponse(t,e.isAddAnyway)))}else{h.ajax.runAction("catalog.productSelector.getProduct",{json:{productId:t,options:{priceId:this.options.basePriceId,urlBuilder:this.options.urlBuilder,currency:this.options.currency}}}).then((t=>this.processResponse(t,e.isAddAnyway)))}},processResponse(t,e){const s=e?-1:this.getInternalIndexByProductId(t.data.skuId);if(s<0){const e=t.data;const s=h.Text.toNumber(e.fields.BASE_PRICE);e.fields=e.fields||{};let i=this.$store.getters["productList/getBaseProduct"]();i.fields=Object.assign(i.fields,{price:s,priceExclusive:s,basePrice:s,name:e.fields.NAME||"",productId:e.productId,skuId:e.skuId,measureCode:e.fields.MEASURE_CODE,measureName:e.fields.MEASURE_NAME,measureRatio:e.fields.MEASURE_RATIO,properties:e.fields.PROPERTIES,offerId:e.skuId>0?e.skuId:e.productId,module:"catalog",isCustomPrice:h.Type.isNil(e.fields.PRICE)?"Y":"N",discountType:this.options.defaultDiscountType});delete e.fields;i=Object.assign(i,e);i.sum=s;this.$root.$app.addProduct(i)}},onUpdateBasketItem(t,e){this.$store.dispatch("productList/changeRowData",{index:t,fields:e});this.$store.dispatch("productList/changeProduct",{index:t,fields:e.fields})},removeEmptyItems(){const t=this.$store.getters["productList/getBasket"]();t.forEach(((e,s)=>{if(t[s].name===""&&t[s].price<1e-10){this.$store.commit("productList/deleteItem",{index:s})}}))},modifyBasketItem(t){const e=parseInt(t.id);if(e>0){const s=this.getInternalIndexByProductId(e);if(s>=0){this.showDialogProductExists(t)}else{this.removeEmptyItems();this.handleAddItem(e,t)}}},showDialogProductExists(t){this.popup=new p.Popup(null,null,{events:{onPopupClose:()=>{this.popup.destroy()}},zIndex:4e3,autoHide:true,closeByEsc:true,closeIcon:true,titleBar:h.Loc.getMessage("CATALOG_FORM_BLOCK_PROD_EXIST_DLG_TITLE"),draggable:true,resizable:false,lightShadow:true,cacheable:false,overlay:true,content:h.Loc.getMessage("CATALOG_FORM_BLOCK_PROD_EXIST_DLG_TEXT_FOR_DOUBLE").replace("#NAME#",t.name),buttons:this.getButtons(t)});this.popup.show()},getButtons(t){const e=[];const s=t;e.push(new BX.UI.SaveButton({text:h.Loc.getMessage("CATALOG_FORM_BLOCK_PROD_EXIST_DLG_OK"),onclick:()=>{const t=parseInt(s.id);const e=this.getInternalIndexByProductId(t);if(e>=0){this.handleAddItem(t,{...s,isAddAnyway:true})}this.popup.destroy()}}));e.push(new BX.UI.CancelButton({text:h.Loc.getMessage("CATALOG_FORM_BLOCK_PROD_EXIST_DLG_NO"),onclick:()=>{this.popup.destroy()}}));return e},showDialogProductSearch(){const t="addBasketItemFromDialogProductSearch";window[t]=t=>this.modifyBasketItem(t);const e=new BX.CDialog({content_url:"/bitrix/tools/sale/product_search_dialog.php?"+"&caller=order_edit"+"&func_name="+t+"&STORE_FROM_ID=0"+"&public_mode=Y",height:Math.max(500,window.innerHeight-400),width:Math.max(800,window.innerWidth-400),draggable:true,resizable:true,min_height:500,min_width:800,zIndex:3100});e.Show()},setSetting(t){if(t.target.dataset.settingId==="taxIncludedOption"){const e=t.target.checked?"Y":"N";this.$root.$app.changeFormOption("taxIncluded",e)}else if(t.target.dataset.settingId==="showDiscountInputOption"){const e=t.target.checked?"Y":"N";this.$root.$app.changeFormOption("showDiscountBlock",e)}else if(t.target.dataset.settingId==="showTaxInputOption"){const e=t.target.checked?"Y":"N";this.$root.$app.changeFormOption("showTaxBlock",e)}else if(t.target.dataset.settingId==="warehouseOption"){const e=t.target.checked?"Y":"N";if(e==="Y"){this.popupMenu.close();(new v.Slider).open("/bitrix/components/bitrix/catalog.warehouse.master.clear/slider.php",{}).then((()=>{h.ajax.runAction("catalog.config.isUsedInventoryManagement",{}).then((e=>{const s=this.getSettingItems().findIndex((e=>e.id===t.target.dataset.settingId));this.options.warehouseOption=e.data===true;this.settings=this.getSettingItems()}))}))}}},getSettingItem(t){var e;const s=h.Tag.render(W||(W=K` <input type="checkbox" class="ui-ctl-element"> `));s.checked=t.checked;s.disabled=(e=t.disabled)!=null?e:false;s.dataset.settingId=t.id;const i=h.Type.isStringFilled(t.hint)?h.Tag.render(Z||(Z=K`<span class="catalog-product-form-setting-hint" data-hint="${0}"></span>`),t.hint):"";const o=h.Tag.render(J||(J=K` <label class="ui-ctl ui-ctl-checkbox ui-ctl-w100"> ${0} <div class="ui-ctl-label-text ${0}">${0}${0}</div> </label> `),s,t.disabled?"catalog-product-form-disabled-setting":"",t.title,i);BX.UI.Hint.init(o);h.Event.bind(o,"change",this.setSetting.bind(this));return o},getSettingItems(){return[{id:"showDiscountInputOption",checked:this.options.showDiscountBlock!=="N",title:this.localize.CATALOG_FORM_ADD_SHOW_DISCOUNTS_OPTION},{id:"warehouseOption",checked:this.options.warehouseOption,disabled:this.options.warehouseOption,title:this.localize.CATALOG_FORM_ADD_SHOW_WAREHOUSE_OPTION,hint:this.options.warehouseOption?this.localize.CATALOG_FORM_ADD_SHOW_WAREHOUSE_HINT:""}]},prepareSettingsContent(){const t=h.Tag.render(tt||(tt=K` <div class='catalog-pf-product-config-popup'></div> `));this.settings.forEach((e=>{t.append(this.getSettingItem(e))}));return t},showConfigPopup(t){this.popupMenu=new p.Popup(null,t.target,{autoHide:true,draggable:false,offsetLeft:0,offsetTop:0,noAllPaddings:true,bindOptions:{forceBindPosition:true},closeByEsc:true,content:this.prepareSettingsContent()});this.popupMenu.show()},openSlider(t,e){if(!h.Type.isPlainObject(e)){e={}}e={...{cacheable:false,allowChangeHistory:false,events:{}},...e};return new Promise((s=>{if(h.Type.isString(t)&&t.length>1){e.events.onClose=function(t){s(t.getSlider())};BX.SidePanel.Instance.open(t,e)}else{s()}}))}},computed:{localize(){return u.Vue.getFilteredPhrases("CATALOG_")},countItems(){return this.order.basket.length},...d.Vuex.mapState({productList:t=>t.productList})},mounted(){this.settings=this.getSettingItems()},template:`\n\t\t<div>\n\t\t\t<div class="catalog-pf-product-add">\n\t\t\t\t<div class="catalog-pf-product-add-wrapper">\n\t\t\t\t\t<span class="catalog-pf-product-add-link" @click="addBasketItemForm">{{localize.CATALOG_FORM_ADD_PRODUCT}}</span>\n\t\t\t\t\t<span class="catalog-pf-product-add-link catalog-pf-product-add-link--gray" @click="showDialogProductSearch">{{localize.CATALOG_FORM_ADD_PRODUCT_FROM_CATALOG}}</span>\n\t\t\t\t</div>\n\t\t\t\t<div class="catalog-pf-product-configure-link" @click="showConfigPopup">{{localize.CATALOG_FORM_DISCOUNT_EDIT_PAGE_URL_TITLE}}</div>\n\t\t\t</div>\n\t\t</div>\n\t`});u.Vue.component(S.templateName,{props:{options:Object,mode:String},created(){BX.ajax.runAction("catalog.productSelector.getFileInput",{json:{iblockId:this.options.iblockId}})},methods:{refreshBasket(){this.$store.dispatch("productList/refreshBasket")},changeProduct(t){this.$root.$app.changeProduct(t)},emitErrorsChange(){this.$root.$app.emitErrorsChange()},changeRowData(t){delete t.product.fields;this.$store.commit("productList/updateItem",t)},removeItem(t){this.$root.$app.removeProduct(t)},addItem(){this.$root.$app.addProduct()}},computed:{localize(){return u.Vue.getFilteredPhrases("CATALOG_")},showTaxResult(){return this.options.showTaxBlock!=="N"},showResults(){return this.options.showResults!==false},showButtonsTop(){return this.options.singleProductMode!==true&&this.mode!==B.READ_ONLY&&this.options.buttonsPosition!==y.BOTTOM},showButtonsBottom(){return this.options.singleProductMode!==true&&this.mode!==B.READ_ONLY&&this.options.buttonsPosition===y.BOTTOM},showResultBlock(){return this.showResults||this.enableAddButtons},countItems(){return this.productList.basket.length},totalResultLabel(){return this.options.hasOwnProperty("totalResultLabel")&&this.options.totalResultLabel?this.options.totalResultLabel:this.localize.CATALOG_FORM_TOTAL_RESULT},...d.Vuex.mapState({productList:t=>t.productList})},template:`\n\t<div class="catalog-product-form-container">\n\t\t<${S.templatePanelButtons}\n\t\t\t:options="options"\n\t\t\t:mode="mode"\n\t\t\t@refreshBasket="refreshBasket"\n\t\t\t@addItem="addItem"\n\t\t\t@changeRowData="changeRowData"\n\t\t\t@changeProduct="changeProduct"\n\t\t\tv-if="showButtonsTop"\n\t\t/>\n\t\t<div v-for="(item, index) in productList.basket" :key="item.selectorId">\n\t\t\t<${S.templateRowName}\n\t\t\t\t:basketItem="item"\n\t\t\t\t:basketItemIndex="index"\n\t\t\t\t:basketLength="productList.basket.length"\n\t\t\t\t:countItems="countItems"\n\t\t\t\t:options="options"\n\t\t\t\t:mode="mode"\n\t\t\t\t@changeProduct="changeProduct"\n\t\t\t\t@changeRowData="changeRowData"\n\t\t\t\t@removeItem="removeItem"\n\t\t\t\t@refreshBasket="refreshBasket"\n\t\t\t\t@emitErrorsChange="emitErrorsChange"\n\t\t\t/>\n\t\t</div>\n\t\t<${S.templatePanelButtons}\n\t\t\t:options="options"\n\t\t\t:mode="mode"\n\t\t\t@refreshBasket="refreshBasket"\n\t\t\t@addItem="addItem"\n\t\t\t@changeRowData="changeRowData"\n\t\t\t@changeProduct="changeProduct"\n\t\t\tv-if="showButtonsBottom"\n\t\t/>\n\t\t<${S.templatePanelCompilation}\n\t\t\tv-if="options.showCompilationModeSwitcher"\n\t\t\t:compilationOptions="options.compilationFormOption"\n\t\t\t:mode="mode"\n\t\t/>\n\t\t<div class="catalog-pf-result-line"></div>\n\t\t<div class="catalog-pf-result-wrapper" v-if="showResultBlock">\n\t\t\t<table class="catalog-pf-result" v-if="showResultBlock">\n\t\t\t\t<tr v-if="showResults">\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<span class="catalog-pf-text">{{localize.CATALOG_FORM_PRODUCTS_PRICE}}:</span>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<span v-html="productList.total.sum"\n\t\t\t\t\t\t\t:class="productList.total.result !== productList.total.sum ? 'catalog-pf-text catalog-pf-text--line-through' : 'catalog-pf-text'"\n\t\t\t\t\t\t></span>\n\t\t\t\t\t\t<span class="catalog-pf-symbol" v-html="options.currencySymbol"></span>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr v-if="showResults">\n\t\t\t\t\t<td class="catalog-pf-result-padding-bottom">\n\t\t\t\t\t\t<span class="catalog-pf-text catalog-pf-text--discount">{{localize.CATALOG_FORM_TOTAL_DISCOUNT}}:</span>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class="catalog-pf-result-padding-bottom">\n\t\t\t\t\t\t<span class="catalog-pf-text catalog-pf-text--discount" v-html="productList.total.discount"></span>\n\t\t\t\t\t\t<span class="catalog-pf-symbol" v-html="options.currencySymbol"></span>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr v-if="showResults && showTaxResult">\n\t\t\t\t\t<td class="catalog-pf-tax">\n\t\t\t\t\t\t<span class="catalog-pf-text catalog-pf-text--tax">{{localize.CATALOG_FORM_TAX_TITLE}}:</span>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class="catalog-pf-tax">\n\t\t\t\t\t\t<span class="catalog-pf-text catalog-pf-text--tax" v-html="productList.total.taxSum"></span>\n\t\t\t\t\t\t<span class="catalog-pf-symbol" v-html="options.currencySymbol"></span>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr v-if="showResults">\n\t\t\t\t\t<td class="catalog-pf-result-padding">\n\t\t\t\t\t\t<span class="catalog-pf-text catalog-pf-text--total catalog-pf-text--border">{{totalResultLabel}}:</span>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class="catalog-pf-result-padding">\n\t\t\t\t\t\t<span class="catalog-pf-text catalog-pf-text--total" v-html="productList.total.result"></span>\n\t\t\t\t\t\t<span class="catalog-pf-symbol catalog-pf-symbol--total" v-html="options.currencySymbol"></span>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</div>\n\t</div>\n`});let et=t=>t,st;var it=babelHelpers.classPrivateFieldLooseKey("onBasketChange");var ot=babelHelpers.classPrivateFieldLooseKey("checkRequiredFields");var at=babelHelpers.classPrivateFieldLooseKey("changeCompilationModeSetting");var nt=babelHelpers.classPrivateFieldLooseKey("setMode");class rt{constructor(t={}){Object.defineProperty(this,nt,{value:ut});Object.defineProperty(this,at,{value:dt});Object.defineProperty(this,ot,{value:ct});Object.defineProperty(this,it,{value:lt});this.options=this.prepareOptions(t);this.defaultOptions=Object.assign({},this.options);this.editable=true;babelHelpers.classPrivateFieldLooseBase(this,nt)[nt](B.REGULAR);this.wrapper=h.Tag.render(st||(st=et`<div class=""></div>`));if(h.Text.toNumber(t.iblockId)<=0){return}rt.initStore().then((t=>this.initTemplate(t))).catch((t=>rt.showError(t)))}static initStore(){const t=new d.VuexBuilder;return t.addModel(k.create()).build()}prepareOptions(t={}){const e=h.Extension.getSettings("catalog.product-form");const s={basket:[],measures:[],iblockId:null,basePriceId:e.get("basePriceId"),taxList:[],singleProductMode:false,showResults:true,showCompilationModeSwitcher:false,enableEmptyProductError:true,pricePrecision:2,currency:e.get("currency"),currencySymbol:e.get("currencySymbol"),taxIncluded:e.get("taxIncluded"),warehouseOption:e.get("warehouseOption"),showDiscountBlock:e.get("showDiscountBlock"),showTaxBlock:e.get("showTaxBlock"),allowedDiscountTypes:[A.DiscountType.PERCENTAGE,A.DiscountType.MONETARY],visibleBlocks:[L.PRODUCT_SELECTOR,L.PRICE,L.QUANTITY,L.RESULT,L.DISCOUNT],requiredFields:[],editableFields:[],newItemPosition:y.TOP,buttonsPosition:y.TOP,urlBuilderContext:"SHOP",hideUnselectedProperties:false,isCatalogPriceEditEnabled:e.get("isCatalogPriceEditEnabled"),isCatalogPriceSaveEnabled:e.get("isCatalogPriceSaveEnabled"),fieldHints:e.get("fieldHints"),compilationFormType:F.REGULAR,compilationFormOption:{}};if(t.visibleBlocks&&!h.Type.isArray(t.visibleBlocks)){delete t.visibleBlocks}if(t.requiredFields&&!h.Type.isArray(t.requiredFields)){delete t.requiredFields}t={...s,...t};t.showTaxBlock="N";if(e.get("isEnabledLanding")){t.compilationFormOption={type:t.compilationFormType,hasStore:e.get("hasLandingStore"),isLimitedStore:e.get("isLimitedLandingStore"),disabledSwitcher:e.get("isLimitedLandingStore"),hiddenInfoMessage:e.get("hiddenCompilationInfoMessage")}}else{t.showCompilationModeSwitcher=false}t.defaultDiscountType="";if(h.Type.isArray(t.allowedDiscountTypes)){if(t.allowedDiscountTypes.includes(A.DiscountType.PERCENTAGE)){t.defaultDiscountType=A.DiscountType.PERCENTAGE}else if(t.allowedDiscountTypes.includes(A.DiscountType.MONETARY)){t.defaultDiscountType=A.DiscountType.MONETARY}}return t}layout(){return this.wrapper}initTemplate(t){return new Promise((e=>{const s=this;this.store=t.store;this.templateEngine=u.BitrixVue.createApp({el:this.wrapper,store:this.store,data:{options:this.options,mode:this.mode},created(){this.$app=s},mounted(){e()},template:`<${S.templateName} :options="options" :mode="mode"/>`});if(h.Type.isStringFilled(this.options.currency)){this.setData({currency:this.options.currency});R.CurrencyCore.loadCurrencyFormat(this.options.currency)}if(this.options.basket.length>0){this.setData({basket:this.options.basket},{newItemPosition:y.BOTTOM});if(h.Type.isObject(this.options.totals)){this.store.commit("productList/setTotal",this.options.totals)}else{this.store.dispatch("productList/calculateTotal")}}else{const t=this.store.getters["productList/getBaseProduct"]();t.fields.discountType=this.options.defaultDiscountType;this.addProduct(t)}_.EventEmitter.emit(this,"onAfterInit")}))}addProduct(t={}){this.store.dispatch("productList/addItem",{item:t,position:this.options.newItemPosition}).then((()=>{babelHelpers.classPrivateFieldLooseBase(this,it)[it]()}))}emitErrorsChange(){_.EventEmitter.emit(this,"ProductForm:onErrorsChange")}changeProduct(t){const e=t.product;e.errors=[];if(t.skipFieldChecking!==true){const t=babelHelpers.classPrivateFieldLooseBase(this,ot)[ot](e.fields);e.errors=(t==null?void 0:t.errors)||[]}this.store.dispatch("productList/changeItem",{index:t.index,product:e}).then((()=>{babelHelpers.classPrivateFieldLooseBase(this,it)[it]()}))}removeProduct(t){this.store.dispatch("productList/removeItem",{index:t.index}).then((()=>{babelHelpers.classPrivateFieldLooseBase(this,it)[it]()}))}setData(t,e={}){if(h.Type.isObject(t.basket)){const s=this.store.getters["productList/getBasket"]();t.basket.forEach((t=>{if(!h.Type.isObject(t)){return}const i=e.newItemPosition||this.options.newItemPosition;const o=t.selectorId;if(h.Type.isNil(o)){this.store.dispatch("productList/addItem",{item:t,position:i});return}const a=s.findIndex((t=>t.selectorId===o));if(a===-1){this.store.dispatch("productList/addItem",{item:t,position:i})}else{this.store.dispatch("productList/changeItem",{basketIndex:a,fields:t})}}))}if(h.Type.isStringFilled(t.currency)){this.store.dispatch("productList/setCurrency",t.currency)}if(h.Type.isObject(t.total)){this.store.commit("productList/setTotal",{sum:t.total.sum,taxSum:t.total.taxSum,discount:t.total.discount,result:t.total.result})}if(h.Type.isObject(t.errors)){this.store.commit("productList/setErrors",t.errors)}}changeFormOption(t,e){e=e==="Y"?"Y":"N";if(t==="isCompilationMode"){if(!this.options.showCompilationModeSwitcher){return}const t=e==="Y"?B.COMPILATION:B.REGULAR;babelHelpers.classPrivateFieldLooseBase(this,at)[at](t);return}this.options[t]=e;if(t!=="hiddenCompilationInfoMessage"){const s=this.store.getters["productList/getBasket"]();s.forEach(((s,i)=>{if(t==="showDiscountBlock"){s.showDiscountBlock=e}else if(t==="showTaxBlock"){s.showTaxBlock=e}else if(t==="taxIncluded"){s.fields.taxIncluded=e}this.store.dispatch("productList/changeItem",{index:i,fields:s})}))}h.ajax.runAction("catalog.productForm.setConfig",{data:{configName:t,value:e}})}getTotal(){this.store.dispatch("productList/getTotal")}setEditable(t){this.editable=t;if(!t){babelHelpers.classPrivateFieldLooseBase(this,nt)[nt](B.READ_ONLY)}else{babelHelpers.classPrivateFieldLooseBase(this,nt)[nt](B.REGULAR)}}hasErrors(){if(!this.store){return false}const t=this.store.getters["productList/getBasket"]();const e=t.filter((t=>t.errors.length>0));return e.length>0}static showError(t){console.error(t)}}function lt(){_.EventEmitter.emit(this,"ProductForm:onBasketChange",{basket:this.store.getters["productList/getBasket"]()})}function ct(t){const e={};if(!h.Type.isArray(this.options.requiredFields)||this.options.requiredFields.length===0){return e}e.errors=[];this.options.requiredFields.forEach((s=>{switch(s){case L.PRICE:if(t.price<=0){e.errors.push({code:M.EMPTY_PRICE,message:h.Loc.getMessage("CATALOG_FORM_ERROR_EMPTY_PRICE")})}break;case L.QUANTITY:if(t.quantity<=0){e.errors.push({code:M.EMPTY_QUANTITY,message:h.Loc.getMessage("CATALOG_FORM_ERROR_EMPTY_QUANTITY")})}break;case L.BRAND:if(!h.Type.isArray(t.brands)||t.brands.length===0){e.errors.push({code:M.EMPTY_BRAND,message:h.Loc.getMessage("CATALOG_FORM_ERROR_EMPTY_BRAND")})}break}}));return e}function dt(t){this.options.requiredFields=[];if(t===B.COMPILATION){const t=[L.PRODUCT_SELECTOR,L.PRICE,L.BRAND];this.options.requiredFields=this.options.visibleBlocks.filter((e=>t.includes(e)))}babelHelpers.classPrivateFieldLooseBase(this,nt)[nt](t);const e=this.store.getters["productList/getBasket"]();e.forEach(((t,s)=>this.changeProduct({index:s,product:t,skipFieldChecking:e.length===1&&s===0&&t.offerId===null})))}function ut(t){this.mode=t;if(t===B.READ_ONLY){this.options.editableFields=[]}else if(t===B.COMPILATION){this.options.editableFields=[L.PRODUCT_SELECTOR,L.PRICE,L.BRAND];this.options.visibleBlocks=this.defaultOptions.visibleBlocks;if(this.options.compilationFormType===F.FACEBOOK){this.options.visibleBlocks.push(L.BRAND)}this.options.showResults=false}else{t=B.REGULAR;this.options.visibleBlocks=this.defaultOptions.visibleBlocks;this.options.showResults=this.defaultOptions.showResults;this.options.editableFields=this.defaultOptions.visibleBlocks}if(this.templateEngine){this.templateEngine.mode=t}_.EventEmitter.emit(this,"ProductForm:onModeChange",{mode:t})}t.ProductForm=rt})(this.BX.Catalog=this.BX.Catalog||{},BX,BX.UI,BX,BX.UI,BX,BX.UI,BX.Catalog,BX.UI.EntitySelector,BX.Catalog,BX,BX,BX.Main,BX,BX,BX.UI,BX.UI,window,BX,BX,BX,BX,BX,BX.Catalog.StoreUse,BX,BX.Event,BX.Currency,BX.Catalog); //# sourceMappingURL=product-form.bundle.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.27 |
proxy
|
phpinfo
|
Settings