File manager - Edit - /home/web/vm-3fadc827.na4u.ru/www/bitrix/modules/catalog/install/js/catalog/product-selector/dist/product-selector.bundle.min.js
Back
this.BX=this.BX||{};(function(e,t,i,s,o,r,n,a,l,c,h,d,g,u,I,E){"use strict";let m=e=>e,p,C,T,b,S,f;class _ extends n.DefaultFooter{constructor(e,t){super(e,t);this.loader=null;this.getDialog().subscribe("onSearch",this.handleOnSearch.bind(this))}getContent(){let e="";if(this.options.allowCreateItem===false){e=this.getSaveContainer()}else{e=d.Tag.render(p||(p=m` <div>${0}</div> `),d.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER"));const t=e.querySelector("create-button");d.Dom.replace(t,this.getLabelContainer());const i=e.querySelector("change-button");d.Dom.replace(i,this.getSaveContainer())}return d.Tag.render(C||(C=m` <div class="ui-selector-search-footer-box"> ${0} ${0} </div> `),e,this.getLoaderContainer())}getLoader(){if(d.Type.isNil(this.loader)){this.loader=new o.Loader({target:this.getLoaderContainer(),size:17,color:"rgba(82, 92, 105, 0.9)"})}return this.loader}showLoader(){void this.getLoader().show()}hideLoader(){void this.getLoader().hide()}setLabel(e){if(d.Type.isString(e)){this.getLabelContainer().textContent=e}}getLabelContainer(){return this.cache.remember("label",(()=>d.Tag.render(T||(T=m` <span> <span onclick="${0}" class="ui-selector-footer-link ui-selector-footer-link-add"> ${0} </span> ${0} </span> `),this.handleClick.bind(this),this.getOption("creationLabel",d.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE")),this.getQueryContainer())))}getQueryContainer(){return this.cache.remember("name-container",(()=>d.Tag.render(b||(b=m` <span class="ui-selector-search-footer-query"></span> `))))}getSaveContainer(){return this.cache.remember("save-container",(()=>{const e=`ui-selector-footer-link`;const t=this.options.inputName===l.ProductSelector.INPUT_FIELD_BARCODE?"CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_BARCODE_CHANGE":"CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CHANGE";return d.Tag.render(S||(S=m` <span class="${0}" onclick="${0}"> ${0} </span> `),e,this.onClickSaveChanges.bind(this),d.Loc.getMessage(t))}))}getLoaderContainer(){return this.cache.remember("loader",(()=>d.Tag.render(f||(f=m` <div class="ui-selector-search-footer-loader"></div> `))))}onClickSaveChanges(){const e=this.getDialog().getActiveTab().getLastSearchQuery();this.getDialog().emit("ChangeItem:onClick",{query:e.query});this.getDialog().clearSearch();this.getDialog().hide()}createItem(){const e=this.getDialog().getTagSelector();if(e&&e.isLocked()){return}const t=()=>{this.hideLoader();if(this.getDialog().getTagSelector()){this.getDialog().getTagSelector().unlock();this.getDialog().focusSearch()}};event.preventDefault();this.showLoader();if(e){e.lock()}this.getDialog().emitAsync("Search:onItemCreateAsync",{searchQuery:this.getDialog().getActiveTab().getLastSearchQuery()}).then((()=>{this.getTab().clearResults();this.getDialog().clearSearch();if(this.getDialog().getActiveTab()===this.getTab()){this.getDialog().selectFirstTab()}t()})).catch((()=>{t()}))}handleClick(){this.createItem()}handleOnSearch(e){const{query:t}=e.getData();if(this.options.currentValue===t||t===""){this.hide()}else{this.show()}if(this.options.allowCreateItem!==false){this.getQueryContainer().textContent=t}}}let A=e=>e,L,N,v;class P extends n.DefaultFooter{getContent(){const e=d.Tag.render(L||(L=A` <div>${0}</div> `),d.Loc.getMessage("CATALOG_SELECTOR_LIMITED_PRODUCT_CREATION"));const t=d.Tag.render(N||(N=A` <a class="ui-btn ui-btn-sm ui-btn-primary ui-btn-hover ui-btn-round"> ${0} </a> `),d.Loc.getMessage("CATALOG_SELECTOR_LICENSE_EXPLODE"));d.Event.bind(t,"click",(()=>{BX.UI.InfoHelper.show("limit_shop_products")}));return d.Tag.render(v||(v=A` <div class="ui-selector-search-footer-box"> <div class="ui-selector-search-footer-box"> <div class="tariff-lock"></div> ${0} </div> <div> ${0} </div> </div> `),e,t)}}class D{}D.NOT_SELECTED_PRODUCT="NOT_SELECTED_PRODUCT";D.FAILED_PRODUCT="FAILED_PRODUCT";let O=e=>e,M,y,R,w,k,F,B,H,U,V,x,G,$;class X{constructor(e,t={}){this.cache=new d.Cache.MemoryCache;this.id=e||d.Text.getRandom();this.selector=t.selector;if(!(this.selector instanceof l.ProductSelector)){throw new Error("Product selector instance not found.")}this.model=t.model||{};this.isEnabledSearch=t.isSearchEnabled;this.isEnabledDetailLink=t.isEnabledDetailLink;this.inputName=t.inputName||l.ProductSelector.INPUT_FIELD_NAME;this.immutableFieldNames=[l.ProductSelector.INPUT_FIELD_BARCODE,l.ProductSelector.INPUT_FIELD_NAME];if(!this.immutableFieldNames.includes(this.inputName)){this.immutableFieldNames.push(this.inputName)}this.ajaxInProcess=false}destroy(){}getId(){return this.id}getSelectorType(){return l.ProductSelector.INPUT_FIELD_NAME}getField(e){return this.model.getField(e)}getValue(){return this.getField(this.inputName)}getFilledValue(){return this.getNameInput().value||""}isSearchEnabled(){return this.isEnabledSearch}toggleIcon(e,t){if(d.Type.isDomNode(e)){d.Dom.style(e,"display",t)}}getNameBlock(){return this.cache.remember("nameBlock",(()=>d.Tag.render(M||(M=O` <div class="ui-ctl ui-ctl-textbox ui-ctl-w100"> ${0} ${0} ${0} </div> `),this.getNameTag(),this.getNameInput(),this.getHiddenNameInput())))}getNameTag(){if(!this.model.isNew()){return""}return d.Tag.render(y||(y=O` <div class="ui-ctl-tag">${0}</div> `),d.Loc.getMessage("CATALOG_SELECTOR_NEW_TAG_TITLE"))}getNameInput(){return this.cache.remember("nameInput",(()=>d.Tag.render(R||(R=O` <input type="text" class="ui-ctl-element ui-ctl-textbox" autocomplete="off" data-name="${0}" value="${0}" placeholder="${0}" title="${0}" onchange="${0}" > `),d.Text.encode(this.inputName),d.Text.encode(this.getValue()),d.Text.encode(this.getPlaceholder()),d.Text.encode(this.getValue()),this.handleNameInputHiddenChange.bind(this))))}getHiddenNameInput(){return this.cache.remember("hiddenNameInput",(()=>d.Tag.render(w||(w=O` <input type="hidden" name="${0}" value="${0}" > `),d.Text.encode(this.inputName),d.Text.encode(this.getValue()))))}handleNameInputHiddenChange(e){this.getHiddenNameInput().value=e.target.value}getClearIcon(){return this.cache.remember("closeIcon",(()=>d.Tag.render(k||(k=O` <button class="ui-ctl-after ui-ctl-icon-clear" onclick="${0}" ></button> `),this.handleClearIconClick.bind(this))))}getArrowIcon(){return this.cache.remember("arrowIcon",(()=>d.Tag.render(F||(F=O` <a href="${0}" target="_blank" class="ui-ctl-after ui-ctl-icon-forward" > `),d.Text.encode(this.model.getDetailPath()))))}getSearchIcon(){return this.cache.remember("searchIcon",(()=>d.Tag.render(B||(B=O` <button class="ui-ctl-after ui-ctl-icon-search" onclick="${0}" ></button> `),this.handleSearchIconClick.bind(this))))}layout(){this.clearInputCache();const e=d.Tag.render(H||(H=O`<div class="ui-ctl ui-ctl-w100 ui-ctl-after-icon"></div>`));this.toggleIcon(this.getClearIcon(),"none");d.Dom.append(this.getClearIcon(),e);if(this.isSearchEnabled()){if(this.selector.isProductSearchEnabled()){this.initHasDialogItems()}this.toggleIcon(this.getSearchIcon(),d.Type.isStringFilled(this.getFilledValue())?"none":"block");d.Dom.append(this.getSearchIcon(),e);d.Event.bind(this.getNameInput(),"click",this.handleShowSearchDialog.bind(this));d.Event.bind(this.getNameInput(),"input",this.handleShowSearchDialog.bind(this));d.Event.bind(this.getNameInput(),"blur",this.handleNameInputBlur.bind(this));d.Event.bind(this.getNameInput(),"keydown",this.handleNameInputKeyDown.bind(this))}if(this.showDetailLink()&&d.Type.isStringFilled(this.getValue())){this.toggleIcon(this.getClearIcon(),"none");this.toggleIcon(this.getSearchIcon(),"none");this.toggleIcon(this.getArrowIcon(),"block");d.Dom.append(this.getArrowIcon(),e)}d.Event.bind(this.getNameInput(),"click",this.handleIconsSwitchingOnNameInput.bind(this));d.Event.bind(this.getNameInput(),"input",this.handleIconsSwitchingOnNameInput.bind(this));d.Event.bind(this.getNameInput(),"change",this.handleNameInputChange.bind(this));d.Dom.append(this.getNameBlock(),e);return e}showDetailLink(){return this.isEnabledDetailLink}getDialog(){return this.cache.remember("dialog",(()=>{var e;const t=X.SEARCH_TYPE_ID;const i={id:t,options:{iblockId:this.model.getIblockId(),basePriceId:this.model.getBasePriceId(),currency:this.model.getCurrency()},dynamicLoad:true,dynamicSearch:true};const s=this.selector.getConfig("RESTRICTED_PRODUCT_TYPES",null);if(!d.Type.isNil(s)){i.options.restrictedProductTypes=s}const o={id:this.id+"_"+t,height:300,width:Math.max((e=this.getNameInput())==null?void 0:e.offsetWidth,565),context:"catalog-products",targetNode:this.getNameInput(),enableSearch:false,multiple:false,dropdownMode:true,searchTabOptions:{stub:true,stubOptions:{title:d.Tag.message(U||(U=O`${0}`),"CATALOG_SELECTOR_IS_EMPTY_TITLE"),subtitle:this.isAllowedCreateProduct()?d.Tag.message(V||(V=O`${0}`),"CATALOG_SELECTOR_IS_EMPTY_SUBTITLE"):"",arrow:true}},events:{"Item:onSelect":this.onProductSelect.bind(this),"Search:onItemCreateAsync":this.createProduct.bind(this),"ChangeItem:onClick":this.showChangeNotification.bind(this)},entities:[i]};const r=d.Extension.getSettings("catalog.product-selector");if(d.Type.isObject(r.get("limitInfo"))){o.footer=P}else if(this.model&&this.model.isSaveable()&&this.model.isCatalogExisted()){o.footer=_;o.footerOptions={inputName:this.inputName,allowCreateItem:this.isAllowedCreateProduct(),creationLabel:d.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE"),currentValue:this.getValue()}}else{o.searchOptions={allowCreateItem:this.isAllowedCreateProduct()}}return new n.Dialog(o)}))}initHasDialogItems(){if(!d.Type.isNil(this.isHasDialogItems)){return}if(!this.selector.getModel().isEmpty()){this.isHasDialogItems=true;return}this.isHasDialogItems=false;const e=this.getDialog();if(e.hasDynamicLoad()){e.hasRecentItems().then((e=>{if(e===true){this.isHasDialogItems=true}}))}else{this.isHasDialogItems=true}}isAllowedCreateProduct(){return this.selector.getConfig("IS_ALLOWED_CREATION_PRODUCT",true)}handleNameInputKeyDown(e){const t=this.getDialog();if(e.key==="Enter"&&t.getActiveTab()===t.getSearchTab()){e.stopPropagation();e.preventDefault();if(d.Browser.isMac()&&e.metaKey||e.ctrlKey){t.getSearchTab().getFooter().createItem()}}}handleIconsSwitchingOnNameInput(e){this.toggleIcon(this.getArrowIcon(),"none");if(d.Type.isStringFilled(e.target.value)){this.toggleIcon(this.getClearIcon(),"block");this.toggleIcon(this.getSearchIcon(),"none")}else{this.toggleIcon(this.getClearIcon(),"none");if(this.isSearchEnabled()){this.toggleIcon(this.getSearchIcon(),"block")}}}clearInputCache(){this.cache.delete("dialog");this.cache.delete("nameBlock");this.cache.delete("nameInput");this.cache.delete("hiddenNameInput")}handleClearIconClick(e){if(this.selector.isProductSearchEnabled()&&!this.model.isEmpty()){this.selector.clearState();this.selector.clearLayout();this.selector.layout();this.selector.searchInDialog()}else{const e="";this.toggleIcon(this.getClearIcon(),"none");this.onChangeValue(e)}this.selector.focusName();this.selector.emit("onClear",{selectorId:this.selector.getId(),rowId:this.selector.getRowId()});e.stopPropagation();e.preventDefault()}handleNameInputChange(e){const t=e.target.value;this.onChangeValue(t)}onChangeValue(e){const t={};this.getNameInput().title=e;this.getNameInput().value=e;t[this.inputName]=e;g.EventEmitter.emit("ProductSelector::onNameChange",{rowId:this.selector.getRowId(),fields:t});if(!this.selector.isEnabledAutosave()){return}this.selector.getModel().setFields(t);this.selector.getModel().save().then((()=>{BX.UI.Notification.Center.notify({id:"saving_field_notify_name",closeButton:false,content:d.Tag.render(x||(x=O`<div>${0}</div>`),d.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_NAME")),autoHide:true})}))}focusName(){requestAnimationFrame((()=>this.getNameInput().focus()))}searchInDialog(e=""){if(!this.selector.isProductSearchEnabled()){return}const t=this.getDialog();if(t){t.removeItems();e=e.trim();if(e===""){if(this.isHasDialogItems===false){t.hide();return}t.loadState="UNSENT";t.load()}t.show();t.search(e)}}handleShowSearchDialog(e){this.searchInDialog(this.getNameInput().value)}handleNameInputBlur(e){setTimeout((()=>{this.toggleIcon(this.getClearIcon(),"none");if(this.showDetailLink()&&d.Type.isStringFilled(this.getValue())){if(this.isSearchEnabled()){this.toggleIcon(this.getSearchIcon(),"none")}this.toggleIcon(this.getArrowIcon(),"block")}else{this.toggleIcon(this.getArrowIcon(),"none");if(this.isSearchEnabled()){this.toggleIcon(this.getSearchIcon(),d.Type.isStringFilled(this.getFilledValue())?"none":"block")}}}),200);if(this.isSearchEnabled()&&this.selector.isEnabledEmptyProductError()){setTimeout((()=>{if(!this.selector.inProcess()&&(this.model.isEmpty()||!d.Type.isStringFilled(this.getNameInput().value))){this.model.getErrorCollection().setError(D.NOT_SELECTED_PRODUCT,d.Loc.getMessage("CATALOG_SELECTOR_SELECTED_PRODUCT_TITLE"));this.selector.layoutErrors()}}),200)}}handleSearchIconClick(e){this.searchInDialog();this.focusName();e.stopPropagation();e.preventDefault()}getImmutableFieldNames(){return this.immutableFieldNames}setInputValueOnProductSelect(e){e.getDialog().getTargetNode().value=e.getTitle()}onProductSelect(e){const t=e.getData().item;this.setInputValueOnProductSelect(t);this.toggleIcon(this.getSearchIcon(),"none");this.model.getErrorCollection().clearErrors();if(this.selector){const e=t.getCustomData().get("isNew");const i=[];this.getImmutableFieldNames().forEach((e=>{if(!d.Type.isNil(t.getCustomData().get(e))){this.model.setField(e,t.getCustomData().get(e));i.push(e)}}));this.selector.onProductSelect(t.getId(),{isNew:e,immutableFields:i});this.selector.clearLayout();this.selector.layout()}this.cache.delete("dialog")}createProductModelFromSearchQuery(e){const t={...this.selector.getModel().getFields()};t[this.inputName]=e;return new a.ProductModel({isSimpleModel:true,isNew:true,currency:this.selector.options.currency,iblockId:this.selector.getModel().getIblockId(),basePriceId:this.selector.getModel().getBasePriceId(),fields:t})}createProduct(e){if(this.ajaxInProcess){return}this.ajaxInProcess=true;const t=e.getTarget();const{searchQuery:i}=e.getData();const s=this.createProductModelFromSearchQuery(i.getQuery());g.EventEmitter.emit(this.selector,"onBeforeCreate",{model:s});return new Promise(((e,o)=>{if(!this.checkCreationModel(s)){this.ajaxInProcess=false;t.hide();o();return}t.showLoader();s.save().then((o=>{t.hideLoader();const r=d.Text.toInteger(o.data.id);const n=t.addItem({id:r,entityId:X.SEARCH_TYPE_ID,title:i.getQuery(),tabs:t.getRecentTab().getId(),customData:{isNew:true}});this.selector.getModel().setOption("isSimpleModel",false);this.selector.getModel().setOption("isNew",true);this.getImmutableFieldNames().forEach((e=>{this.selector.getModel().setField(e,s.getField(e));this.selector.getModel().setOption(e,s.getField(e))}));if(n){n.select()}t.hide();this.cache.delete("dialog");this.ajaxInProcess=false;this.isHasDialogItems=true;e()})).catch((e=>{t.hideLoader();e.errors.forEach((e=>{BX.UI.Notification.Center.notify({closeButton:true,content:d.Tag.render(G||(G=O`<div>${0}</div>`),e.message),autoHide:true})}));this.ajaxInProcess=false;o()}))}))}checkCreationModel(e){return true}showChangeNotification(e){const{query:t}=e.getData();const i={title:d.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_"+this.selector.getType()),events:{onSave:()=>{if(this.selector){this.selector.getModel().setField(this.inputName,t);this.selector.getModel().save([this.inputName]).catch((e=>{e.errors.forEach((e=>{BX.UI.Notification.Center.notify({closeButton:true,content:d.Tag.render($||($=O`<div>${0}</div>`),e.message),autoHide:true})}))}))}}}};if(this.selector.getConfig("ROLLBACK_INPUT_AFTER_CANCEL",false)){i.declineCancelTitle=d.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_CANCEL_TITLE");i.events.onCancel=()=>{this.selector.clearLayout();this.selector.layout()}}this.selector.getModel().showSaveNotifier("nameChanger_"+this.selector.getId(),i)}getPlaceholder(){return this.isSearchEnabled()&&this.model.isEmpty()?d.Loc.getMessage("CATALOG_SELECTOR_BEFORE_SEARCH_TITLE"):d.Loc.getMessage("CATALOG_SELECTOR_VIEW_NAME_TITLE")}removeSpotlight(){}removeQrAuth(){}}X.SEARCH_TYPE_ID="product";let Q=e=>e,j;class q{constructor(e,t={}){var i;this.id=e||d.Text.getRandom();this.selector=t.selector||null;if(!(this.selector instanceof l.ProductSelector)){throw new Error("Product selector instance not found.")}this.config=t.config||{};if(!d.Type.isStringFilled((i=this.selector.getModel())==null?void 0:i.getImageCollection().getEditInput())){this.restoreDefaultInputHtml()}this.enableSaving=t.enableSaving;this.uploaderFieldMap={}}getId(){return this.id}setId(e){this.id=e}setView(e){var t;(t=this.selector.getModel())==null?void 0:t.getImageCollection().setPreview(e)}setInputHtml(e){var t;(t=this.selector.getModel())==null?void 0:t.getImageCollection().setEditInput(e)}restoreDefaultInputHtml(){var e;const t=`\n\t\t\t<div class='ui-image-input-container ui-image-input-img--disabled'>\n\t\t\t\t<div class='adm-fileinput-wrapper '>\n\t\t\t\t\t<div class='adm-fileinput-area mode-pict adm-fileinput-drag-area'></div>\n\t\t\t\t</div>\n\t\t\t</div>\n`;(e=this.selector.getModel())==null?void 0:e.getImageCollection().setEditInput(t)}isViewMode(){return this.selector&&this.selector.isViewMode()}isEnabledLiveSaving(){return this.enableSaving}layout(){var e,t,i,s;const o=d.Tag.render(j||(j=Q`<div></div>`));const r=this.isViewMode()?(e=this.selector.getModel())==null?void 0:(t=e.getImageCollection())==null?void 0:t.getPreview():(i=this.selector.getModel())==null?void 0:(s=i.getImageCollection())==null?void 0:s.getEditInput();d.Runtime.html(o,r);return o}}let Y=e=>e,W,K,z,J,Z;class ee extends _{constructor(e,t={}){super(e,t);this.isEmptyBarcode=t.isEmptyBarcode}getContent(){this.barcodeContent=super.getContent();this.scannerContent=this.getScannerContent();d.Dom.style(this.barcodeContent,"display","none");d.Dom.style(this.scannerContent,"display","none");return d.Tag.render(W||(W=Y` <div class="catalog-footers-container"> ${0} ${0} </div> `),this.barcodeContent,this.scannerContent)}getScannerContent(){const e=d.Tag.render(K||(K=Y` <div>${0}</div> `),d.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_BARCODE"));const t=e.querySelector("create-button");d.Dom.replace(t,this.getScannerLabelContainer());return d.Tag.render(z||(z=Y` <div class="ui-selector-search-footer-box"> ${0} ${0} </div> `),e,this.getLoaderContainer())}getScannerLabelContainer(){return this.cache.remember("scannerLabel",(()=>d.Tag.render(J||(J=Y` <span onclick="${0}"> <span class="ui-selector-footer-link ui-selector-footer-link-add footer-link--warehouse-barcode-icon"> ${0} </span> ${0} </span> `),this.handleScannerClick.bind(this),d.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_BARCODE_START_SCAN_LABEL"),this.getScannerQueryContainer())))}getScannerQueryContainer(){return this.cache.remember("scanner_name-container",(()=>d.Tag.render(Z||(Z=Y` <span class="ui-selector-search-footer-query"></span> `))))}handleScannerClick(){var e;const t=(e=this.options)==null?void 0:e.inputEntity;if(t){t.startMobileScanner()}}handleOnSearch(e){const{query:t}=e.getData();if(this.isEmptyBarcode){if(t===""){this.show();d.Dom.style(this.scannerContent,"display","")}else{this.hide()}}else{if(t===""){this.show();d.Dom.style(this.barcodeContent,"display","none");d.Dom.style(this.scannerContent,"display","")}else if(this.options.currentValue===t){this.hide()}else{this.show();d.Dom.style(this.barcodeContent,"display","");d.Dom.style(this.scannerContent,"display","none")}}if(this.options.allowCreateItem!==false){this.getQueryContainer().textContent=t;this.getScannerQueryContainer().textContent=t}}}let te=e=>e,ie,se,oe,re,ne,ae,le,ce,he,de;class ge extends X{constructor(e,t={}){super(e,t);this.onFocusHandler=this.handleFocusEvent.bind(this);this.onBlurHandler=this.handleBlurEvent.bind(this);this.focused=false;this.settingsCollection=d.Extension.getSettings("catalog.product-selector");if(!this.settingsCollection.get("isEnabledQrAuth")&&this.selector.getConfig("ENABLE_BARCODE_QR_AUTH",true)){this.qrAuth=new u.QrAuthorization;this.qrAuth.createQrCodeImage()}}destroy(){d.Event.unbind(this.getNameInput(),"focus",this.onFocusHandler);d.Event.unbind(this.getNameInput(),"blur",this.onBlurHandler)}handleFocusEvent(){this.focused=true}handleBlurEvent(){this.focused=false}isSearchEnabled(){return true}showDetailLink(){return false}getNameBlock(){return this.cache.remember("nameBlock",(()=>d.Tag.render(ie||(ie=te` <div class="ui-ctl ui-ctl-textbox ui-ctl-w100"> ${0} ${0} </div> `),this.getNameInput(),this.getHiddenNameInput())))}getDialog(){return this.cache.remember("dialog",(()=>{var e;const t={id:ge.SEARCH_TYPE_ID,options:{iblockId:this.model.getIblockId(),basePriceId:this.model.getBasePriceId(),currency:this.model.getCurrency()},dynamicLoad:true,dynamicSearch:true,searchFields:[{name:"title",type:"string",system:true,searchable:false}]};const i=this.selector.getConfig("RESTRICTED_PRODUCT_TYPES",null);if(!d.Type.isNil(i)){t.options.restrictedProductTypes=i}const s={id:this.id+"_"+ge.SEARCH_TYPE_ID,height:300,width:Math.max((e=this.getNameInput())==null?void 0:e.offsetWidth,565),context:null,targetNode:this.getNameInput(),enableSearch:false,multiple:false,dropdownMode:true,searchTabOptions:{stub:true,stubOptions:{title:d.Tag.message(se||(se=te`${0}`),"CATALOG_SELECTOR_IS_EMPTY_TITLE"),subtitle:this.isAllowedCreateProduct()?d.Tag.message(oe||(oe=te`${0}`),"CATALOG_SELECTOR_IS_EMPTY_SUBTITLE"):"",arrow:true}},events:{"Item:onSelect":this.onProductSelect.bind(this),"Search:onItemCreateAsync":this.createProduct.bind(this),"ChangeItem:onClick":this.showChangeNotification.bind(this)},entities:[t]};if(this.model.getSkuId()&&!d.Type.isStringFilled(this.model.getField(this.inputName))){s.preselectedItems=[[ge.SEARCH_TYPE_ID,this.model.getSkuId()]]}if(d.Type.isObject(this.settingsCollection.get("limitInfo"))){s.footer=P}else if(this.model&&this.model.isSaveable()&&this.model.isCatalogExisted()){s.footer=ee;s.footerOptions={inputEntity:this,isEmptyBarcode:false,inputName:this.inputName,allowCreateItem:this.isAllowedCreateProduct(),creationLabel:d.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE_WITH_BARCODE"),currentValue:this.getValue()}}else{s.footer=ee;s.footerOptions={inputEntity:this,isEmptyBarcode:true,inputName:this.inputName,allowCreateItem:this.isAllowedCreateProduct(),creationLabel:d.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE_WITH_BARCODE"),currentValue:this.getValue()};s.searchOptions={allowCreateItem:this.isAllowedCreateProduct(),footerOptions:{label:d.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE_WITH_BARCODE")}}}return new n.Dialog(s)}))}layoutMobileQrPopup(){return this.cache.remember("qrMobilePopup",(()=>{const e=d.Tag.render(re||(re=te`<span class="popup-window-close-icon"></span>`));d.Event.bind(e,"click",this.closeMobilePopup.bind(this));let t="";let i="";if(top.BX.Helper){i=d.Tag.render(ne||(ne=te` <a class="product-selector-mobile-popup-link ui-btn ui-btn-light-border ui-btn-round"> ${0} </a> `),d.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_HELP_BUTTON"));d.Event.bind(i,"click",(()=>{top.BX.Helper.show("redirect=detail&code=14956818")}));t=d.Tag.render(ae||(ae=te` <a class="product-selector-mobile-popup-link ui-btn ui-btn-link"> ${0} </a> `),d.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_SEND_PUSH_BUTTON"));d.Event.bind(t,"click",(()=>{top.BX.Helper.show("redirect=detail&code=15042444")}))}return d.Tag.render(le||(le=te` <div data-role="mobile-popup"> <div class="product-selector-mobile-popup-overlay"></div> <div class="product-selector-mobile-popup-content"> <div class="product-selector-mobile-popup-title">${0}</div> <div class="product-selector-mobile-popup-text">${0}</div> <div class="product-selector-mobile-popup-qr"> ${0} </div> <div class="product-selector-mobile-popup-link-container"> ${0} ${0} </div> ${0} </div> </div> `),d.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_TITLE"),d.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_INSTRUCTION"),this.qrAuth.getQrNode(),i,t,e)}))}closeMobilePopup(){this.removeQrAuth();d.ajax.runAction("catalog.ProductSelector.isInstalledMobileApp",{json:{}}).then((e=>{if(e.data===true){this.selector.emit("onBarcodeQrClose",{})}}));d.userOptions.save("product-selector","barcodeQrAuth","showed","Y")}handleShowSearchDialog(e){if(this.qrAuth&&this.getDialog().getContainer()){if(!d.Dom.hasClass(this.getDialog().getContainer(),"qr-barcode-info")){d.Dom.addClass(this.getDialog().getContainer(),"qr-barcode-info")}if(this.getDialog().getContainer()){d.Dom.append(this.layoutMobileQrPopup(),this.getDialog().getContainer())}}super.handleShowSearchDialog(e)}onChangeValue(e){const t={};this.getNameInput().title=e;this.getNameInput().value=e;t[this.inputName]=e;g.EventEmitter.emit("ProductSelector::onBarcodeChange",{rowId:this.selector.getRowId(),fields:t});if(this.selector.isEnabledAutosave()){this.selector.getModel().setField(this.inputName,e);this.selector.getModel().showSaveNotifier("barcodeChanger_"+this.selector.getId(),{title:d.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_BARCODE"),disableCancel:true,events:{onSave:()=>{if(this.selector){this.selector.getModel().save([this.inputName])}}}})}}searchInDialog(e=""){if(!this.selector.isProductSearchEnabled()){return}const t=this.getDialog();t.removeItems();if(t){if(e===""){t.setPreselectedItems([[ge.SEARCH_TYPE_ID,this.model.getSkuId()]]);t.loadState="UNSENT";t.load()}t.show();t.search(e)}}handleNameInputBlur(e){setTimeout((()=>{this.toggleIcon(this.getClearIcon(),"none");if(this.showDetailLink()&&d.Type.isStringFilled(this.getValue())){this.toggleIcon(this.getSearchIcon(),"none");this.toggleIcon(this.getArrowIcon(),"block")}else{this.toggleIcon(this.getArrowIcon(),"none");this.toggleIcon(this.getSearchIcon(),d.Type.isStringFilled(this.getFilledValue())?"none":"block")}}),200)}setInputValueOnProductSelect(e){e.getDialog().getTargetNode().value=e.getSubtitle()}getCreationProduct(e){const t={...this.selector.getModel().getFields()};t[l.ProductSelector.INPUT_FIELD_NAME]=e;return new a.ProductModel({isSimpleModel:true,isNew:true,currency:this.selector.options.currency,iblockId:this.selector.getModel().getIblockId(),basePriceId:this.selector.getModel().getBasePriceId(),fields:t})}createProductModelFromSearchQuery(e){const t=super.createProductModelFromSearchQuery(e);t.setField(l.ProductSelector.INPUT_FIELD_NAME,d.Loc.getMessage("CATALOG_SELECTOR_NEW_BARCODE_PRODUCT_NAME"));t.setField(this.inputName,e);return t}checkCreationModel(e){if(!d.Type.isStringFilled(e.getField(l.ProductSelector.INPUT_FIELD_NAME))){this.model.getErrorCollection().setError(D.NOT_SELECTED_PRODUCT,d.Loc.getMessage("CATALOG_SELECTOR_EMPTY_TITLE"));return false}return true}getPlaceholder(){return this.isSearchEnabled()&&this.model.isEmpty()?d.Loc.getMessage("CATALOG_SELECTOR_BEFORE_SEARCH_BARCODE_TITLE"):d.Loc.getMessage("CATALOG_SELECTOR_VIEW_BARCODE_TITLE")}handleClearIconClick(e){this.toggleIcon(this.getClearIcon(),"none");this.onChangeValue("");this.selector.focusName();e.stopPropagation();e.preventDefault()}startMobileScanner(e){if(!this.settingsCollection.get("isInstallMobileApp")&&this.selector.getConfig("ENABLE_BARCODE_QR_AUTH",true)){this.qrAuth=new u.QrAuthorization;this.qrAuth.createQrCodeImage();this.handleShowSearchDialog(e);return}this.sendMobilePush(e)}sendMobilePush(e){e==null?void 0:e.preventDefault();this.getDialog().hide();this.getNameInput().focus();if(!this.selector.isEnabledMobileScanning()){return}const t=this.selector.getMobileScannerToken();c.BarcodeScanner.open(t);const i=d.Tag.render(ce||(ce=te`<span class='ui-notification-balloon-action'>${0}</span>`),d.Loc.getMessage("CATALOG_SELECTOR_SEND_PUSH_ON_SCANNER_NOTIFICATION_REPEAT"));d.Event.bind(i,"click",this.sendMobilePush.bind(this));const s=d.Tag.render(he||(he=te` <div> <span>${0}</span> ${0} </div> `),d.Loc.getMessage("CATALOG_SELECTOR_SEND_PUSH_ON_SCANNER_NOTIFICATION"),i);BX.UI.Notification.Center.notify({content:s,category:"sending_push_barcode_scanner_notification",autoHideDelay:5e3})}getProductIdByBarcode(e){return d.ajax.runAction("catalog.ProductSelector.getProductIdByBarcode",{json:{barcode:e}})}applyScannerData(e){this.getProductIdByBarcode(e).then((t=>{const i=t==null?void 0:t.data;if(i){this.selectScannedBarcodeProduct(i)}else{this.searchInDialog(e)}this.getNameInput().value=d.Text.encode(e)}))}selectScannedBarcodeProduct(e){this.toggleIcon(this.getSearchIcon(),"none");this.model.getErrorCollection().clearErrors();if(this.selector){this.selector.onProductSelect(e,{isNew:false,immutableFields:[]});this.selector.clearLayout();this.selector.layout()}this.cache.delete("dialog")}getBarcodeIcon(){return this.cache.remember("barcodeIcon",(()=>{const e=d.Tag.render(de||(de=te` <button class="ui-ctl-before warehouse-barcode-icon" title="${0}"></button> `),d.Loc.getMessage("CATALOG_SELECTOR_BARCODE_ICON_TITLE"));if(!this.settingsCollection.get("isShowedBarcodeSpotlightInfo")&&this.selector.getConfig("ENABLE_INFO_SPOTLIGHT",true)){this.spotlight=new BX.SpotLight({id:"selector_barcode_scanner_info",targetElement:e,autoSave:true,targetVertex:"middle-center",zIndex:200});this.spotlight.show();g.EventEmitter.subscribe(this.spotlight,"BX.SpotLight:onTargetEnter",(()=>{const t=new E.Guide({steps:[{target:e,title:d.Loc.getMessage("CATALOG_SELECTOR_BARCODE_SCANNER_FIRST_TIME_HINT_TITLE"),text:d.Loc.getMessage("CATALOG_SELECTOR_BARCODE_SCANNER_FIRST_TIME_HINT_TEXT")}],onEvents:true});t.getPopup().setAutoHide(true);t.showNextStep();this.selector.setConfig("ENABLE_INFO_SPOTLIGHT",false);this.selector.emit("onSpotlightClose",{})}))}d.Event.bind(e,"click",(e=>{e.preventDefault();if(this.qrAuth){this.handleShowSearchDialog(e)}else{this.startMobileScanner(e)}}));return e}))}layout(){const e=super.layout();d.Dom.append(this.getBarcodeIcon(),e);this.getNameInput().className+=" catalog-product-field-input-barcode";d.Event.bind(this.getNameInput(),"focus",this.onFocusHandler);d.Event.bind(this.getNameInput(),"blur",this.onBlurHandler);return e}removeSpotlight(){if(this.spotlight){this.spotlight.close()}}removeQrAuth(){var e;const t=(e=this.getDialog().getContainer())==null?void 0:e.querySelector('[data-role="mobile-popup"]');if(t){d.Dom.remove(t);if(d.Dom.hasClass(this.getDialog().getContainer(),"qr-barcode-info")){d.Dom.removeClass(this.getDialog().getContainer(),"qr-barcode-info")}}this.qrAuth=null}}ge.SEARCH_TYPE_ID="barcode";let ue=e=>e,Ie,Ee,me,pe,Ce,Te,be;const Se=new Map;const fe=new Map;var _e=babelHelpers.classPrivateFieldLooseKey("inAjaxProcess");class Ae extends g.EventEmitter{static getById(e){return Se.get(e)||null}constructor(e,t={}){super();Object.defineProperty(this,_e,{writable:true,value:false});this.mode=Ae.MODE_EDIT;this.cache=new d.Cache.MemoryCache;this.type=Ae.INPUT_FIELD_NAME;this.mobileScannerToken=null;this.variationChangeHandler=this.handleVariationChange.bind(this);this.onSaveImageHandler=this.onSaveImage.bind(this);this.onChangeFieldsHandler=d.Runtime.debounce(this.onChangeFields,500,this);this.onUploaderIsInitedHandler=this.onUploaderIsInited.bind(this);this.setEventNamespace("BX.Catalog.ProductSelector");this.id=e||d.Text.getRandom();t.inputFieldName=t.inputFieldName||Ae.INPUT_FIELD_NAME;this.options=t||{};this.type=this.options.type||Ae.INPUT_FIELD_NAME;this.setMode(t.mode);if(t.model&&t.model instanceof a.ProductModel){this.model=t.model}else{this.model=a.ProductModel.getById(this.id)}if(!(this.model instanceof a.ProductModel)){this.model=new a.ProductModel({currency:t.currency,iblockId:d.Text.toNumber(t.iblockId),basePriceId:d.Text.toNumber(t.basePriceId),fields:t.fields,skuTree:t.skuTree,storeMap:t.storeMap})}this.model.getImageCollection().setMorePhotoValues(t.morePhotoValues);if(!d.Type.isNil(this.getConfig("DETAIL_PATH"))){this.model.setDetailPath(this.getConfig("DETAIL_PATH"))}if(t.failedProduct){this.model.getErrorCollection().setError(D.FAILED_PRODUCT,"")}if(this.isShowableEmptyProductError()){this.model.getErrorCollection().setError(D.NOT_SELECTED_PRODUCT,d.Loc.getMessage("CATALOG_SELECTOR_SELECTED_PRODUCT_TITLE"))}if(t.fileView){this.model.getImageCollection().setPreview(t.fileView)}if(t.fileInput){this.model.getImageCollection().setEditInput(t.fileInput)}this.layout();if(t.skuTree){this.updateSkuTree(t.skuTree)}if(t.scannerToken){this.setMobileScannerToken(t.scannerToken)}g.EventEmitter.subscribe("ProductList::onChangeFields",this.onChangeFieldsHandler);g.EventEmitter.subscribe("Catalog.ImageInput::save",this.onSaveImageHandler);g.EventEmitter.subscribe("onUploaderIsInited",this.onUploaderIsInitedHandler);Se.set(this.id,this)}setModel(e){this.model=e}getModel(){return this.model}setMode(e){if(!d.Type.isNil(e)){this.mode=e===Ae.MODE_VIEW?Ae.MODE_VIEW:Ae.MODE_EDIT}}isViewMode(){return this.mode===Ae.MODE_VIEW}isSaveable(){return!this.isViewMode()&&this.model.isSaveable()}isEnabledAutosave(){return this.isSaveable()&&this.getConfig("ENABLE_AUTO_SAVE",false)}isEnabledMobileScanning(){return!this.isViewMode()&&this.getConfig("ENABLE_MOBILE_SCANNING",true)}getMobileScannerToken(){return this.mobileScannerToken||d.Text.getRandom(16)}setMobileScannerToken(e){this.mobileScannerToken=e}removeMobileScannerToken(){this.mobileScannerToken=null}getId(){return this.id}getType(){return this.type}getConfig(e,t){return BX.prop.get(this.options.config,e,t)}setConfig(e,t){this.options.config[e]=t;return this}getRowId(){return this.getConfig("ROW_ID")}getFileInput(){if(!this.fileInput){this.fileInput=new q(this.options.fileInputId,{selector:this,enableSaving:this.getConfig("ENABLE_IMAGE_CHANGE_SAVING",false)})}return this.fileInput}isProductSearchEnabled(){return this.getConfig("ENABLE_SEARCH",false)&&this.model.getIblockId()>0}isSkuTreeEnabled(){return this.getConfig("ENABLE_SKU_TREE",true)!==false}isImageFieldEnabled(){return this.getConfig("ENABLE_IMAGE_INPUT",true)!==false}isShowableEmptyProductError(){return this.isEnabledEmptyProductError()&&(this.model.isEmpty()&&this.model.isChanged()||this.model.isSimple())}isShowableErrors(){return this.isEnabledEmptyProductError()||this.isEnabledEmptyImagesError()}isEnabledEmptyProductError(){return this.getConfig("ENABLE_EMPTY_PRODUCT_ERROR",false)}isEnabledEmptyImagesError(){return this.getConfig("ENABLE_EMPTY_IMAGES_ERROR",false)}isEnabledChangesRendering(){return this.getConfig("ENABLE_CHANGES_RENDERING",true)}isInputDetailLinkEnabled(){return this.getConfig("ENABLE_INPUT_DETAIL_LINK",false)&&d.Type.isStringFilled(this.model.getDetailPath())}getWrapper(){if(!this.wrapper){this.wrapper=document.getElementById(this.id)}return this.wrapper}renderTo(e){this.clearLayout();this.wrapper=e;this.layout()}layout(){const e=this.getWrapper();if(!e){return}this.defineWrapperClass(e);e.innerHTML="";const t=d.Tag.render(Ie||(Ie=ue`<div class="catalog-product-field-inner"></div>`));d.Dom.append(this.layoutNameBlock(),t);if(this.getSkuTreeInstance()){d.Dom.append(this.getSkuTreeInstance().layout(),t)}d.Dom.append(this.getErrorContainer(),t);if(!this.isViewMode()){d.Dom.append(t,e)}if(this.isImageFieldEnabled()){if(!d.Reflection.getClass("BX.UI.ImageInput")){d.ajax.runAction("catalog.productSelector.getFileInput",{json:{iblockId:this.getModel().getIblockId()}}).then((()=>{this.layoutImage()}))}else{this.layoutImage()}d.Dom.append(this.getImageContainer(),e)}else{d.Dom.addClass(e,"catalog-product-field-no-image")}if(this.isViewMode()){d.Dom.append(t,e)}if(this.isShowableErrors){this.layoutErrors()}this.subscribeToVariationChange()}focusName(){if(this.searchInput){this.searchInput.focusName()}return this}getImageContainer(){return this.cache.remember("imageContainer",(()=>d.Tag.render(Ee||(Ee=ue`<div class="catalog-product-img"></div>`))))}getErrorContainer(){return this.cache.remember("errorContainer",(()=>d.Tag.render(me||(me=ue`<div class="catalog-product-error"></div>`))))}layoutErrors(){this.getErrorContainer().innerHTML="";this.clearImageErrorBorder();if(!this.model.getErrorCollection().hasErrors()){return}const e=this.model.getErrorCollection().getErrors();for(const t in e){if(t==="EMPTY_IMAGE"){this.setImageErrorBorder()}else{d.Dom.append(d.Tag.render(pe||(pe=ue`<div class="catalog-product-error-item">${0}</div>`),e[t].text),this.getErrorContainer());if(this.searchInput){d.Dom.addClass(this.searchInput.getNameBlock(),"ui-ctl-danger")}}}}setImageErrorBorder(){d.Dom.addClass(this.getImageContainer().querySelector(".adm-fileinput-area"),"adm-fileinput-drag-area-error")}clearImageErrorBorder(){d.Dom.removeClass(this.getImageContainer().querySelector(".adm-fileinput-area"),"adm-fileinput-drag-area-error")}onUploaderIsInited(){if(this.isEnabledEmptyImagesError()){requestAnimationFrame(this.layoutErrors.bind(this))}}layoutImage(){this.getImageContainer().innerHTML="";d.Dom.append(this.getFileInput().layout(),this.getImageContainer());this.refreshImageSelectorId=null}clearState(){this.getModel().initFields({ID:"",NAME:"",BARCODE:"",PRODUCT_ID:null,SKU_ID:null}).setOption("isNew",false);this.getFileInput().restoreDefaultInputHtml();this.getModel().clearSkuTree();this.skuTreeInstance=null;this.getModel().getStoreCollection().clear()}clearLayout(){const e=this.getWrapper();if(e){e.innerHTML=""}this.unsubscribeToVariationChange()}unsubscribeEvents(){this.unsubscribeToVariationChange();g.EventEmitter.unsubscribe("Catalog.ImageInput::save",this.onSaveImageHandler);g.EventEmitter.unsubscribe("ProductList::onChangeFields",this.onChangeFieldsHandler);g.EventEmitter.unsubscribe("onUploaderIsInited",this.onUploaderIsInitedHandler)}defineWrapperClass(e){if(this.isViewMode()){d.Dom.addClass(e,"catalog-product-view");d.Dom.removeClass(e,"catalog-product-edit")}else{d.Dom.addClass(e,"catalog-product-edit");d.Dom.removeClass(e,"catalog-product-view")}}getNameBlockView(){const e=d.Text.encode(this.model.getField("NAME"));const t=d.Loc.getMessage("CATALOG_SELECTOR_VIEW_NAME_TITLE");if(this.getModel().getDetailPath()){return d.Tag.render(Ce||(Ce=ue` <a href="${0}" title="${0}">${0}</a> `),this.getModel().getDetailPath(),t,e)}return d.Tag.render(Te||(Te=ue`<span title="${0}">${0}</span>`),t,e)}getNameInputFilledValue(){if(this.searchInput){return this.searchInput.getFilledValue()}return""}layoutNameBlock(){const e=d.Tag.render(be||(be=ue`<div class="catalog-product-field-input"></div>`));if(this.isViewMode()){d.Dom.append(this.getNameBlockView(),e)}else{if(this.getType()===Ae.INPUT_FIELD_BARCODE){if(!this.searchInput){this.searchInput=new ge(this.id,{selector:this,model:this.getModel(),inputName:this.options.inputFieldName})}}else{this.searchInput=new X(this.id,{selector:this,model:this.getModel(),inputName:this.options.inputFieldName,isSearchEnabled:this.isProductSearchEnabled(),isEnabledEmptyProductError:this.isEnabledEmptyProductError(),isEnabledDetailLink:this.isInputDetailLinkEnabled()})}d.Dom.append(this.searchInput.layout(),e)}return e}searchInDialog(){this.searchInput.searchInDialog();return this}updateSkuTree(e){this.getModel().setSkuTree(e);this.skuTreeInstance=null;return this}getIblockSkuTreeProperties(){return new Promise((e=>{if(fe.has(this.getModel().getIblockId())){e(fe.get(this.getModel().getIblockId()))}else{d.ajax.runAction("catalog.productSelector.getSkuTreeProperties",{json:{iblockId:this.getModel().getIblockId()}}).then((t=>{fe.set(this.getModel().getIblockId(),t);e(t)}))}}))}getSkuTreeInstance(){var e;if(this.isSkuTreeEnabled()&&(e=this.getModel())!=null&&e.getSkuTree()&&!this.skuTreeInstance){this.skuTreeInstance=new s.SkuTree({skuTree:this.getModel().getSkuTree(),selectable:this.getConfig("ENABLE_SKU_SELECTION",true),hideUnselected:this.getConfig("HIDE_UNSELECTED_ITEMS",false)})}return this.skuTreeInstance}subscribeToVariationChange(){const e=this.getSkuTreeInstance();if(e){this.unsubscribeToVariationChange();e.subscribe("SkuProperty::onChange",this.variationChangeHandler)}}unsubscribeToVariationChange(){const e=this.getSkuTreeInstance();if(e){e.unsubscribe("SkuProperty::onChange",this.variationChangeHandler)}}handleVariationChange(e){const[t]=e.getData();const i=d.Text.toNumber(t.PARENT_PRODUCT_ID);const s=d.Text.toNumber(t.ID);if(i<=0||s<=0){return}this.emit("onBeforeChange",{selectorId:this.getId(),rowId:this.getRowId()});babelHelpers.classPrivateFieldLooseBase(this,_e)[_e]=true;d.ajax.runAction("catalog.productSelector.getSelectedSku",{json:{variationId:s,options:{priceId:this.basePriceId,currency:this.model.getCurrency(),urlBuilder:this.getConfig("URL_BUILDER_CONTEXT")}}}).then((e=>this.processResponse(e,{...this.options.config})))}onChangeFields(e){const t=e.getData();if(t.rowId!==this.getRowId()){return}const i=t.fields;this.getModel().setFields(i)}reloadFileInput(){var e;d.ajax.runAction("catalog.productSelector.getFileInput",{json:{iblockId:this.getModel().getIblockId(),skuId:(e=this.getModel())==null?void 0:e.getSkuId()}}).then((e=>{this.getModel().getImageCollection().setEditInput(e.data.html);if(this.isImageFieldEnabled()){this.layoutImage()}}))}onSaveImage(e){const[,t,i]=e.getData();if(t!==this.getFileInput().getId()){return}this.getFileInput().setId(i.data.id);this.getFileInput().setInputHtml(i.data.input);this.getFileInput().setView(i.data.preview);this.getModel().getImageCollection().setMorePhotoValues(i.data.values);if(this.isImageFieldEnabled()){this.layoutImage()}this.emit("onChange",{selectorId:this.id,rowId:this.getRowId(),fields:this.getModel().getFields(),morePhoto:this.getModel().getImageCollection().getMorePhotoValues()})}inProcess(){return babelHelpers.classPrivateFieldLooseBase(this,_e)[_e]}onProductSelect(e,t){this.emit("onProductSelect",{selectorId:this.getId(),rowId:this.getRowId()});this.emit("onBeforeChange",{selectorId:this.getId(),rowId:this.getRowId()});this.productSelectAjaxAction(e,t)}productSelectAjaxAction(e,t={isNew:false,immutableFields:[]}){babelHelpers.classPrivateFieldLooseBase(this,_e)[_e]=true;d.ajax.runAction("catalog.productSelector.getProduct",{json:{productId:e,options:{priceId:this.basePriceId,currency:this.model.getCurrency(),urlBuilder:this.getConfig("URL_BUILDER_CONTEXT")}}}).then((e=>this.processResponse(e,{...this.options.config,...t},true)))}processResponse(e,t={},i=false){const s=(e==null?void 0:e.data)||null;babelHelpers.classPrivateFieldLooseBase(this,_e)[_e]=false;if(s){this.changeSelectedElement(s,t)}else if(i){this.clearState()}else{this.productSelectAjaxAction(this.getModel().getProductId())}this.unsubscribeToVariationChange();if(this.isEnabledChangesRendering()){this.clearLayout();this.layout()}const o=(s==null?void 0:s.fields)||null;if(d.Type.isArray(t.immutableFields)){t.immutableFields.forEach((e=>{o[e]=this.getModel().getField(e)}))}this.emit("onChange",{selectorId:this.id,rowId:this.getRowId(),isNew:t.isNew||false,fields:o})}changeSelectedElement(e,t){const i=d.Text.toInteger(e.productId);const s=this.getModel().getProductId()!==i;if(s){this.getModel().setOption("productId",i);this.getModel().setOption("skuId",d.Text.toInteger(e.skuId));this.getModel().setOption("isSimpleModel",false);this.getModel().setOption("isNew",t.isNew)}if(d.Type.isArray(this.options.immutableFields)){this.options.immutableFields.forEach((t=>{e.fields[t]=this.getModel().getField(t)}))}if(d.Type.isArray(t.immutableFields)){t.immutableFields.forEach((t=>{e.fields[t]=this.getModel().getField(t)}))}this.getModel().initFields(e.fields);const o={id:"",input:"",preview:"",values:[]};if(d.Type.isObject(e.image)){o.id=e.image.id;o.input=e.image.input;o.preview=e.image.preview;o.values=e.image.values}this.getFileInput().setId(o.id);this.getFileInput().setInputHtml(o.input);this.getFileInput().setView(o.preview);this.getModel().getImageCollection().setMorePhotoValues(o.values);this.checkEmptyImageError();if(e.detailUrl){this.getModel().setDetailPath(e.detailUrl)}if(d.Type.isObject(e.skuTree)){this.updateSkuTree(e.skuTree)}}checkEmptyImageError(){if(!d.Type.isArrayFilled(this.getModel().getImageCollection().getMorePhotoValues())&&this.isEnabledEmptyImagesError()){this.getModel().getErrorCollection().setError("EMPTY_IMAGE",d.Loc.getMessage("CATALOG_SELECTOR_EMPTY_IMAGE_ERROR"))}else{this.getModel().getErrorCollection().removeError("EMPTY_IMAGE")}}removeSpotlight(){var e;(e=this.searchInput)==null?void 0:e.removeSpotlight();this.setConfig("ENABLE_INFO_SPOTLIGHT",false)}removeQrAuth(){var e;(e=this.searchInput)==null?void 0:e.removeQrAuth();this.setConfig("ENABLE_BARCODE_QR_AUTH",false)}}Ae.MODE_VIEW="view";Ae.MODE_EDIT="edit";Ae.INPUT_FIELD_NAME="NAME";Ae.INPUT_FIELD_BARCODE="BARCODE";Ae.ErrorCodes=D;e.ProductSelector=Ae})(this.BX.Catalog=this.BX.Catalog||{},BX,BX,BX.Catalog.SkuTree,BX,BX,BX.UI.EntitySelector,BX.Catalog,BX.Catalog,BX.Catalog,BX,BX,BX.Event,BX.UI,BX,BX.UI.Tour); //# sourceMappingURL=product-selector.bundle.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.26 |
proxy
|
phpinfo
|
Settings