| Current Path : /var/www/homesaver/www/bitrix/js/catalog/product-selector/dist/ |
| Current File : /var/www/homesaver/www/bitrix/js/catalog/product-selector/dist/product-selector.bundle.min.js |
this.BX=this.BX||{};(function(e,t,s,i,o,a,r,l,n,c,d,h,u,g,p,E,b,m,I,C){"use strict";let T=e=>e,v,P,L,_,f,S,O,A;var N=babelHelpers.classPrivateFieldLooseKey("loader");var y=babelHelpers.classPrivateFieldLooseKey("getSaveContainer");var D=babelHelpers.classPrivateFieldLooseKey("getLoader");var F=babelHelpers.classPrivateFieldLooseKey("showLoader");var R=babelHelpers.classPrivateFieldLooseKey("hideLoader");var H=babelHelpers.classPrivateFieldLooseKey("getLabelContainer");var M=babelHelpers.classPrivateFieldLooseKey("getHintContainer");var B=babelHelpers.classPrivateFieldLooseKey("onClickSaveChanges");var w=babelHelpers.classPrivateFieldLooseKey("createItem");var k=babelHelpers.classPrivateFieldLooseKey("handleClick");var U=babelHelpers.classPrivateFieldLooseKey("getErrorAdminHint");class x extends u.DefaultFooter{constructor(e,t){super(e,t);Object.defineProperty(this,U,{value:Y});Object.defineProperty(this,k,{value:W});Object.defineProperty(this,w,{value:q});Object.defineProperty(this,B,{value:Q});Object.defineProperty(this,M,{value:X});Object.defineProperty(this,H,{value:K});Object.defineProperty(this,R,{value:$});Object.defineProperty(this,F,{value:j});Object.defineProperty(this,D,{value:V});Object.defineProperty(this,y,{value:G});Object.defineProperty(this,N,{writable:true,value:null});this.getDialog().subscribe("onSearch",this.handleOnSearch.bind(this))}getContent(){let e="";const t=this.options.allowCreateItem===true||this.options.allowEditItem===false;if(this.isViewEditButton()&&t){e=b.Tag.render(v||(v=T`
<div>${0}</div>
`),b.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_1"));const t=e.querySelector("create-button");b.Dom.replace(t,babelHelpers.classPrivateFieldLooseBase(this,H)[H]());const s=e.querySelector("change-button");b.Dom.replace(s,babelHelpers.classPrivateFieldLooseBase(this,y)[y]())}else if(this.isViewEditButton()){e=babelHelpers.classPrivateFieldLooseBase(this,y)[y]()}else{e=babelHelpers.classPrivateFieldLooseBase(this,H)[H]()}return b.Tag.render(P||(P=T`
<div class="ui-selector-search-footer-box">
${0}
${0}
${0}
</div>
`),e,babelHelpers.classPrivateFieldLooseBase(this,M)[M](),this.getLoaderContainer())}handleOnSearch(e){const{query:t}=e.getData();if(this.options.currentValue===t||t===""){this.hide()}else{this.show()}this.getQueryContainer().textContent=` ${t}`}isViewEditButton(){return this.options.allowEditItem===true}getQueryContainer(){return this.cache.remember("name-container",(()=>b.Tag.render(L||(L=T`
<span class="ui-selector-search-footer-query"></span>
`))))}getLoaderContainer(){return this.cache.remember("loader",(()=>b.Tag.render(_||(_=T`
<div class="ui-selector-search-footer-loader"></div>
`))))}}function G(){return this.cache.remember("save-container",(()=>{const e="ui-selector-footer-link";const t=this.options.inputName===m.ProductSelector.INPUT_FIELD_BARCODE?"CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_BARCODE_CHANGE":"CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CHANGE";return b.Tag.render(f||(f=T`
<span class="${0}" onclick="${0}">
${0}
</span>
`),e,babelHelpers.classPrivateFieldLooseBase(this,B)[B].bind(this),b.Loc.getMessage(t))}))}function V(){if(b.Type.isNil(babelHelpers.classPrivateFieldLooseBase(this,N)[N])){babelHelpers.classPrivateFieldLooseBase(this,N)[N]=new a.Loader({target:this.getLoaderContainer(),size:17,color:"rgba(82, 92, 105, 0.9)"})}return babelHelpers.classPrivateFieldLooseBase(this,N)[N]}function j(){void babelHelpers.classPrivateFieldLooseBase(this,D)[D]().show()}function $(){void babelHelpers.classPrivateFieldLooseBase(this,D)[D]().hide()}function K(){return this.cache.remember("label",(()=>b.Tag.render(S||(S=T`
<span>
<span
onclick="${0}"
class="ui-selector-footer-link ui-selector-footer-link-add"
>
${0}
</span>
${0}
</span>
`),babelHelpers.classPrivateFieldLooseBase(this,k)[k].bind(this),this.getOption("creationLabel",b.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE")),this.getQueryContainer())))}function X(){return this.cache.remember("hint",(()=>{let e=null;if(!this.options.allowEditItem&&!this.options.allowCreateItem){e=b.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_DISABLED_FOOTER_ALL_HINT",{"#ADMIN_HINT#":babelHelpers.classPrivateFieldLooseBase(this,U)[U]()})}else if(!this.options.allowEditItem){e=b.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_DISABLED_FOOTER_EDIT_HINT",{"#ADMIN_HINT#":babelHelpers.classPrivateFieldLooseBase(this,U)[U]()})}else if(!this.options.allowCreateItem){e=b.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_DISABLED_FOOTER_ADD_HINT",{"#ADMIN_HINT#":babelHelpers.classPrivateFieldLooseBase(this,U)[U]()})}if(!e){return null}const t=b.Tag.render(O||(O=T`<span class="ui-btn ui-btn-icon-lock ui-btn-link"></span>`));t.dataset.hint=e;t.dataset.hintNoIcon=true;BX.UI.Hint.initNode(t);return b.Tag.render(A||(A=T`<div class="product-search-selector-disabled-footer-hint">${0}</div>`),t)}))}function Q(){if(!this.options.allowEditItem){return}const e=this.getDialog();e.emit("ChangeItem:onClick",{query:e.getSearchTab().getLastSearchQuery().query});e.clearSearch();e.hide()}function q(e){if(!this.options.allowCreateItem){return}const t=this.getDialog().getTagSelector();if(t&&t.isLocked()){return}const s=()=>{babelHelpers.classPrivateFieldLooseBase(this,R)[R]();if(this.getDialog().getTagSelector()){this.getDialog().getTagSelector().unlock();this.getDialog().focusSearch()}};e.preventDefault();babelHelpers.classPrivateFieldLooseBase(this,F)[F]();if(t){t.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()}s()})).catch((()=>{s()}))}function W(e){babelHelpers.classPrivateFieldLooseBase(this,w)[w](e)}function Y(){return this.options.errorAdminHint||""}let z=e=>e,J,Z,ee;class te extends u.DefaultFooter{getContent(){const e=b.Tag.render(J||(J=z`
<div>${0}</div>
`),b.Loc.getMessage("CATALOG_SELECTOR_LIMITED_PRODUCT_CREATION"));const t=b.Tag.render(Z||(Z=z`
<a class="ui-btn ui-btn-sm ui-btn-primary ui-btn-hover ui-btn-round">
${0}
</a>
`),b.Loc.getMessage("CATALOG_SELECTOR_LICENSE_EXPLODE"));b.Event.bind(t,"click",(()=>{BX.UI.InfoHelper.show("limit_shop_products")}));return b.Tag.render(ee||(ee=z`
<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 se{}se.SEARCHING="SEARCHING";se.SHOW_PRODUCT_ITEM="SHOW_PRODUCT_ITEM";se.SHOW_RECENT="SHOW_RECENT";class ie{static getCodes(){return[ie.NOT_SELECTED_PRODUCT,ie.FAILED_PRODUCT]}}ie.NOT_SELECTED_PRODUCT="NOT_SELECTED_PRODUCT";ie.FAILED_PRODUCT="FAILED_PRODUCT";let oe=e=>e,ae,re,le,ne,ce,de,he,ue;var ge=babelHelpers.classPrivateFieldLooseKey("handleIconsSwitchingOnNameInput");var pe=babelHelpers.classPrivateFieldLooseKey("initHasDialogItems");var Ee=babelHelpers.classPrivateFieldLooseKey("hideFooter");var be=babelHelpers.classPrivateFieldLooseKey("handleNameInputChange");var me=babelHelpers.classPrivateFieldLooseKey("clearInputCache");var Ie=babelHelpers.classPrivateFieldLooseKey("showSelectedItem");var Ce=babelHelpers.classPrivateFieldLooseKey("handleNameInputHiddenChange");var Te=babelHelpers.classPrivateFieldLooseKey("handleSearchIconClick");var ve=babelHelpers.classPrivateFieldLooseKey("handleNameInputBlur");var Pe=babelHelpers.classPrivateFieldLooseKey("getHiddenNameInput");var Le=babelHelpers.classPrivateFieldLooseKey("getArrowIcon");var _e=babelHelpers.classPrivateFieldLooseKey("getSearchIcon");class fe{constructor(e,t={}){Object.defineProperty(this,_e,{value:we});Object.defineProperty(this,Le,{value:Be});Object.defineProperty(this,Pe,{value:Me});Object.defineProperty(this,ve,{value:He});Object.defineProperty(this,Te,{value:Re});Object.defineProperty(this,Ce,{value:Fe});Object.defineProperty(this,Ie,{value:De});Object.defineProperty(this,me,{value:ye});Object.defineProperty(this,be,{value:Ne});Object.defineProperty(this,Ee,{value:Ae});Object.defineProperty(this,pe,{value:Oe});Object.defineProperty(this,ge,{value:Se});this.cache=new b.Cache.MemoryCache;this.options=t;this.id=e||b.Text.getRandom();this.selector=t.selector;if(!(this.selector instanceof m.ProductSelector)){throw new TypeError("Product selector instance not found.")}this.model=t.model||{};this.isEnabledDetailLink=t.isEnabledDetailLink;this.inputName=t.inputName||m.ProductSelector.INPUT_FIELD_NAME;this.loadedSelectedItem=null;this.handleSearchInput=b.Runtime.debounce(this.searchInDialog,500,this)}layout(){babelHelpers.classPrivateFieldLooseBase(this,me)[me]();const e=b.Tag.render(ae||(ae=oe`<div class="ui-ctl ui-ctl-w100 ui-ctl-after-icon"></div>`));this.toggleIcon(this.getClearIcon(),"none");b.Dom.append(this.getClearIcon(),e);if(this.isSearchEnabled()){if(this.selector.isProductSearchEnabled()){babelHelpers.classPrivateFieldLooseBase(this,pe)[pe]()}this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,_e)[_e](),b.Type.isStringFilled(this.getFilledValue())?"none":"block");b.Dom.append(babelHelpers.classPrivateFieldLooseBase(this,_e)[_e](),e);b.Event.bind(this.getNameInput(),"click",this.handleClickNameInput.bind(this));b.Event.bind(this.getNameInput(),"input",this.handleSearchInput);b.Event.bind(this.getNameInput(),"blur",babelHelpers.classPrivateFieldLooseBase(this,ve)[ve].bind(this));b.Event.bind(this.getNameInput(),"keydown",this.handleNameInputKeyDown.bind(this));this.dialogMode=this.model.isCatalogExisted()?se.SHOW_PRODUCT_ITEM:se.SHOW_RECENT}if(this.showDetailLink()&&b.Type.isStringFilled(this.getValue())){this.toggleIcon(this.getClearIcon(),"none");this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,_e)[_e](),"none");this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,Le)[Le](),"block");b.Dom.append(babelHelpers.classPrivateFieldLooseBase(this,Le)[Le](),e)}b.Event.bind(this.getNameInput(),"click",babelHelpers.classPrivateFieldLooseBase(this,ge)[ge].bind(this));b.Event.bind(this.getNameInput(),"input",babelHelpers.classPrivateFieldLooseBase(this,ge)[ge].bind(this));b.Event.bind(this.getNameInput(),"change",babelHelpers.classPrivateFieldLooseBase(this,be)[be].bind(this));b.Dom.append(this.getNameBlock(),e);return e}getId(){return this.id}getField(e){return this.model.getField(e)}getValue(){return this.getField(this.inputName)}getFilledValue(){return this.getNameInput().value||""}getSearchQuery(){return this.getFilledValue().trim()}isSearchQueryEmpty(){return this.getSearchQuery()===""}isSearchEnabled(){return Boolean(this.options.isSearchEnabled)}toggleIcon(e,t){if(b.Type.isDomNode(e)){b.Dom.style(e,"display",t)}}getNameBlock(){return this.cache.remember("nameBlock",(()=>b.Tag.render(re||(re=oe`
<div class="ui-ctl ui-ctl-textbox ui-ctl-w100">
${0}
${0}
${0}
</div>
`),this.getNameTag(),this.getNameInput(),babelHelpers.classPrivateFieldLooseBase(this,Pe)[Pe]())))}getNameTag(){return null}getNameInput(){return this.cache.remember("nameInput",(()=>{const e=b.Tag.render(le||(le=oe`
<input type="text"
class="ui-ctl-element ui-ctl-textbox"
autocomplete="off"
data-name="${0}"
value="${0}"
placeholder="${0}"
title="${0}"
onchange="${0}"
>
`),b.Text.encode(this.inputName),b.Text.encode(this.getValue()),b.Text.encode(this.getPlaceholder()),b.Text.encode(this.getValue()),babelHelpers.classPrivateFieldLooseBase(this,Ce)[Ce].bind(this));if(this.selector.getConfig("SELECTOR_INPUT_DISABLED",false)){b.Dom.addClass(e,"ui-ctl-disabled");e.setAttribute("disabled",true)}return e}))}getClearIcon(){return this.cache.remember("closeIcon",(()=>b.Tag.render(ne||(ne=oe`
<button
class="ui-ctl-after ui-ctl-icon-clear"
onclick="${0}"
></button>
`),this.handleClearIconClick.bind(this))))}showDetailLink(){return this.isEnabledDetailLink}handleNameInputKeyDown(e){}clearErrors(){const e=this.model.getErrorCollection().getErrors();for(const t in e){if(m.ProductSelector.ErrorCodes.getCodes().includes(t)){this.model.getErrorCollection().removeError(t)}}}focusName(){requestAnimationFrame((()=>this.getNameInput().focus()))}removeSpotlight(){}removeQrAuth(){}destroy(){}showItems(){if(this.getFilledValue()===""){this.showPreselectedItems();return}if(!this.model.isCatalogExisted()||this.dialogMode!==se.SHOW_PRODUCT_ITEM){this.searchInDialog();return}babelHelpers.classPrivateFieldLooseBase(this,Ie)[Ie]()}showPreselectedItems(){if(!this.selector.isProductSearchEnabled()){return}this.dialogMode=se.SHOW_RECENT;const e=this.getDialog();this.loadPreselectedItems();e.selectFirstTab();e.show();babelHelpers.classPrivateFieldLooseBase(this,Ee)[Ee]()}isFooterHidable(){return true}searchInDialog(){throw new Error('Method "searchInDialog" should be overridden')}handleClickNameInput(){throw new Error('Method "handleClickNameInput" should be overridden')}getPlaceholder(){throw new Error('Method "getPlaceholder" should be overridden')}getDialog(){return this.cache.remember("dialog",(()=>new u.Dialog(this.getDialogParams())))}getDialogParams(){var e;const t={id:"product",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(!b.Type.isNil(s)){t.options.restrictedProductTypes=s}return{id:`${this.id}_product`,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,recentTabOptions:{stub:true,stubOptions:{title:b.Tag.message(ce||(ce=oe`${0}`),"CATALOG_SELECTOR_RECENT_TAB_STUB_TITLE")}},entities:[t],events:{"Item:onSelect":this.onProductSelect.bind(this),onShow:this.onDialogShow.bind(this)}}}onDialogShow(e){}getOnProductSelectConfig(e){throw new Error('Method "getOnProductSelectConfig" should be overridden')}onProductSelect(e){const t=e.getData().item;t.getDialog().getTargetNode().value=t.getTitle();this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,_e)[_e](),"none");this.clearErrors();if(this.selector){this.selector.onProductSelect(t.getId(),this.getOnProductSelectConfig(t));this.selector.clearLayout();this.selector.layout()}this.dialogMode=se.SHOW_PRODUCT_ITEM;this.loadedSelectedItem=t;this.cache.delete("dialog")}onChangeValue(e){this.getNameInput().title=e;this.getNameInput().value=e}handleClearIconClick(e){this.clear();e.stopPropagation();e.preventDefault()}clear(){this.selector.emit("onBeforeClear",{selectorId:this.selector.getId(),rowId:this.selector.getRowId()});this.loadedSelectedItem=null;if(this.selector.isProductSearchEnabled()&&!this.model.isEmpty()){this.selector.clearState();this.selector.clearLayout();this.selector.layout()}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()})}loadPreselectedItems(){const e=this.getDialog();if(e.isLoading()){return}e.removeItems();e.loadState="UNSENT";this.loadedSelectedItem=null;e.load()}}function Se(e){this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,Le)[Le](),"none");if(b.Type.isStringFilled(e.target.value)){this.toggleIcon(this.getClearIcon(),"block");this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,_e)[_e](),"none")}else{this.toggleIcon(this.getClearIcon(),"none");if(this.isSearchEnabled()){this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,_e)[_e](),"block")}}}function Oe(){if(!b.Type.isNil(this.selector.getConfig("EXIST_DIALOG_ITEMS"))){return}if(!this.selector.getModel().isEmpty()){this.selector.setConfig("EXIST_DIALOG_ITEMS",true);return}this.selector.setConfig("EXIST_DIALOG_ITEMS",false);const e=this.getDialog();if(e.hasDynamicLoad()){this.loadPreselectedItems();e.subscribeOnce("onLoad",(()=>{if(e.getPreselectedItems().length>1){this.selector.setConfig("EXIST_DIALOG_ITEMS",true)}}))}else{this.selector.setConfig("EXIST_DIALOG_ITEMS",true)}}function Ae(){if(this.isFooterHidable()){var e;(e=this.getDialog().getFooter())==null?void 0:e.hide()}}function Ne(e){const t=e.target.value;this.onChangeValue(t)}function ye(){this.cache.delete("dialog");this.cache.delete("nameBlock");this.cache.delete("nameInput");this.cache.delete("hiddenNameInput")}function De(){const e=this.getDialog();e.removeItems();new Promise(((t,s)=>{if(!b.Type.isNil(this.loadedSelectedItem)){t();return}e.showLoader();b.ajax.runAction("catalog.productSelector.getSkuSelectorItem",{json:{id:this.selector.getModel().getSkuId(),options:{iblockId:this.model.getIblockId(),basePriceId:this.model.getBasePriceId(),currency:this.model.getCurrency()}}}).then((s=>{e.hideLoader();this.loadedSelectedItem=null;if(b.Type.isObject(s.data)&&!e.isLoading()){this.loadedSelectedItem=e.addItem(s.data)}t()})).catch((e=>s(e)))})).then((()=>{if(b.Type.isNil(this.loadedSelectedItem)){this.searchInDialog()}else{e.setPreselectedItems([this.selector.getModel().getSkuId()]);e.getRecentTab().getRootNode().addItem(this.loadedSelectedItem);e.selectFirstTab();babelHelpers.classPrivateFieldLooseBase(this,Ee)[Ee]()}})).catch((e=>console.error(e)));e.getPopup().show();babelHelpers.classPrivateFieldLooseBase(this,Ee)[Ee]()}function Fe(e){babelHelpers.classPrivateFieldLooseBase(this,Pe)[Pe]().value=e.target.value}function Re(e){this.searchInDialog();this.focusName();e.stopPropagation();e.preventDefault()}function He(e){setTimeout((()=>{this.toggleIcon(this.getClearIcon(),"none");if(this.showDetailLink()&&b.Type.isStringFilled(this.getValue())){if(this.isSearchEnabled()){this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,_e)[_e](),"none")}this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,Le)[Le](),"block")}else{this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,Le)[Le](),"none");if(this.isSearchEnabled()){this.toggleIcon(babelHelpers.classPrivateFieldLooseBase(this,_e)[_e](),b.Type.isStringFilled(this.getFilledValue())?"none":"block")}}}),200);if(this.isSearchEnabled()&&this.selector.isEnabledEmptyProductError()){setTimeout((()=>{if(!this.selector.inProcess()&&(this.model.isEmpty()||!b.Type.isStringFilled(this.getFilledValue()))){this.model.getErrorCollection().setError(ie.NOT_SELECTED_PRODUCT,this.selector.getEmptySelectErrorMessage());this.selector.layoutErrors()}}),200)}}function Me(){return this.cache.remember("hiddenNameInput",(()=>b.Tag.render(de||(de=oe`
<input
type="hidden"
name="${0}"
value="${0}"
>
`),b.Text.encode(this.inputName),b.Text.encode(this.getValue()))))}function Be(){return this.cache.remember("arrowIcon",(()=>b.Tag.render(he||(he=oe`
<a
href="${0}"
target="_blank"
class="ui-ctl-after ui-ctl-icon-forward"
>
`),b.Text.encode(this.model.getDetailPath()))))}function we(){return this.cache.remember("searchIcon",(()=>b.Tag.render(ue||(ue=oe`
<button
class="ui-ctl-after ui-ctl-icon-search"
onclick="${0}"
></button>
`),babelHelpers.classPrivateFieldLooseBase(this,Te)[Te].bind(this))))}let ke=e=>e,Ue,xe,Ge,Ve,je,$e;var Ke=babelHelpers.classPrivateFieldLooseKey("searchItem");class Xe extends fe{constructor(e,t={}){super(e,t);Object.defineProperty(this,Ke,{value:Qe});this.immutableFieldNames=[m.ProductSelector.INPUT_FIELD_BARCODE,m.ProductSelector.INPUT_FIELD_NAME];if(!this.immutableFieldNames.includes(this.inputName)){this.immutableFieldNames.push(this.inputName)}this.ajaxInProcess=false}getNameTag(){if(!this.model.isNew()){return""}return b.Tag.render(Ue||(Ue=ke`
<div class="ui-ctl-tag">${0}</div>
`),b.Loc.getMessage("CATALOG_SELECTOR_NEW_TAG_TITLE"))}getDialogParams(){const e={...super.getDialogParams(),searchTabOptions:{stub:true,stubOptions:{title:b.Tag.message(xe||(xe=ke`${0}`),"CATALOG_SELECTOR_IS_EMPTY_TITLE"),subtitle:this.isAllowedCreateProduct()?b.Tag.message(Ge||(Ge=ke`${0}`),"CATALOG_SELECTOR_IS_EMPTY_SUBTITLE"):"",arrow:true}}};const t=b.Extension.getSettings("catalog.product-selector");if(b.Type.isObject(t.get("limitInfo"))){e.footer=te}else if(this.model&&this.model.isCatalogExisted()){e.footer=x;e.footerOptions={inputName:this.inputName,allowEditItem:this.isAllowedEditProduct(),allowCreateItem:this.isAllowedCreateProduct(),errorAdminHint:t.get("errorAdminHint"),creationLabel:b.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE"),currentValue:this.getValue()}}else{e.searchOptions={allowCreateItem:this.isAllowedCreateProduct()}}e.events["Search:onItemCreateAsync"]=this.createProduct.bind(this);e.events["ChangeItem:onClick"]=this.showChangeNotification.bind(this);return e}isAllowedCreateProduct(){return this.selector.getConfig("IS_ALLOWED_CREATION_PRODUCT",true)&&this.selector.checkProductAddRights()}isAllowedEditProduct(){return this.selector.checkProductEditRights()}handleNameInputKeyDown(e){const t=this.getDialog();if(e.key==="Enter"&&t.getActiveTab()===t.getSearchTab()){e.stopPropagation();e.preventDefault();if(b.Browser.isMac()&&e.metaKey||e.ctrlKey){t.getSearchTab().getFooter().createItem()}}}onChangeValue(e){super.onChangeValue(e);const t={};t[this.inputName]=e;h.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:b.Tag.render(Ve||(Ve=ke`<div>${0}</div>`),b.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_NAME")),autoHide:true})})).catch((e=>console.error(e)))}searchInDialog(){if(this.isSearchQueryEmpty()){if(this.isHasDialogItems===false){this.getDialog().hide();return}this.loadedSelectedItem=null;this.showPreselectedItems();return}this.dialogMode=se.SEARCHING;babelHelpers.classPrivateFieldLooseBase(this,Ke)[Ke](this.getSearchQuery())}handleClickNameInput(){const e=this.getDialog();if(e.isOpen()||this.getFilledValue()===""&&this.isHasDialogItems===false){e.hide();return}this.showItems()}getImmutableFieldNames(){return this.immutableFieldNames}getOnProductSelectConfig(e){const t=e.getCustomData().get("isNew");const s=[];this.getImmutableFieldNames().forEach((t=>{if(!b.Type.isNil(e.getCustomData().get(t))){this.model.setField(t,e.getCustomData().get(t));s.push(t)}}));return{isNew:t,immutableFields:s}}createProductModelFromSearchQuery(e){const t={...this.selector.getModel().getFields()};t[this.inputName]=e;return new I.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 null}this.ajaxInProcess=true;const t=e.getTarget();const{searchQuery:s}=e.getData();const i=this.createProductModelFromSearchQuery(s.getQuery());h.EventEmitter.emit(this.selector,"onBeforeCreate",{model:i});return new Promise(((e,o)=>{if(!this.checkCreationModel(i)){this.ajaxInProcess=false;t.hide();o();return}t.showLoader();i.save().then((o=>{t.hideLoader();const a=b.Text.toInteger(o.data.id);const r=t.addItem({id:a,entityId:"product",title:s.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,i.getField(e));this.selector.getModel().setOption(e,i.getField(e))}));if(r){r.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:b.Tag.render(je||(je=ke`<div>${0}</div>`),e.message),autoHide:true})}));this.ajaxInProcess=false;o()}))}))}checkCreationModel(e){return true}showChangeNotification(e){const{query:t}=e.getData();const s={title:b.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:b.Tag.render($e||($e=ke`<div>${0}</div>`),e.message),autoHide:true})}))}))}}}};if(this.selector.getConfig("ROLLBACK_INPUT_AFTER_CANCEL",false)){s.declineCancelTitle=b.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_CANCEL_TITLE");s.events.onCancel=()=>{this.selector.clearLayout();this.selector.layout()}}this.selector.getModel().showSaveNotifier(`nameChanger_${this.selector.getId()}`,s)}getPlaceholder(){return this.isSearchEnabled()&&this.model.isEmpty()?b.Loc.getMessage("CATALOG_SELECTOR_BEFORE_SEARCH_TITLE"):b.Loc.getMessage("CATALOG_SELECTOR_VIEW_NAME_TITLE")}}function Qe(e=""){if(!this.selector.isProductSearchEnabled()){return}const t=this.getDialog();t.getPopup().show();t.search(e)}let qe=e=>e,We,Ye,ze,Je,Ze;var et=babelHelpers.classPrivateFieldLooseKey("barcodeContent");var tt=babelHelpers.classPrivateFieldLooseKey("scannerContent");var st=babelHelpers.classPrivateFieldLooseKey("getScannerContent");var it=babelHelpers.classPrivateFieldLooseKey("getScannerLabelContainer");var ot=babelHelpers.classPrivateFieldLooseKey("getScannerQueryContainer");class at extends x{constructor(e,t={}){super(e,t);Object.defineProperty(this,ot,{value:nt});Object.defineProperty(this,it,{value:lt});Object.defineProperty(this,st,{value:rt});Object.defineProperty(this,et,{writable:true,value:null});Object.defineProperty(this,tt,{writable:true,value:null});this.getDialog().subscribe("SearchTab:onLoad",this.handleOnSearchLoad.bind(this))}getContent(){babelHelpers.classPrivateFieldLooseBase(this,et)[et]=super.getContent();babelHelpers.classPrivateFieldLooseBase(this,tt)[tt]=babelHelpers.classPrivateFieldLooseBase(this,st)[st]();b.Dom.style(babelHelpers.classPrivateFieldLooseBase(this,et)[et],"display","none");return b.Tag.render(We||(We=qe`
<div class="catalog-footers-container">
${0}
${0}
</div>
`),babelHelpers.classPrivateFieldLooseBase(this,et)[et],babelHelpers.classPrivateFieldLooseBase(this,tt)[tt])}isViewEditButton(){return!this.options.isEmptyBarcode&&super.isViewEditButton()}handleOnSearch(e){const{query:t}=e.getData();if(!b.Type.isStringFilled(t)){this.show();b.Dom.style(babelHelpers.classPrivateFieldLooseBase(this,tt)[tt],"display","");b.Dom.style(babelHelpers.classPrivateFieldLooseBase(this,et)[et],"display","none")}else if(this.options.currentValue===t){this.hide()}else{this.show();b.Dom.style(babelHelpers.classPrivateFieldLooseBase(this,et)[et],"display","");b.Dom.style(babelHelpers.classPrivateFieldLooseBase(this,tt)[tt],"display","none")}this.getQueryContainer().textContent=` ${t}`;babelHelpers.classPrivateFieldLooseBase(this,ot)[ot]().textContent=` ${t}`}handleOnSearchLoad(e){const{searchTab:t}=e.getData();this.getDialog().getItems().forEach((e=>{if(e.getCustomData().get("BARCODE")===t.getLastSearchQuery().getQuery()){this.hide()}}))}}function rt(){const e=b.Tag.render(Ye||(Ye=qe`
<div>${0}</div>
`),b.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_BARCODE"));const t=e.querySelector("create-button");b.Dom.replace(t,babelHelpers.classPrivateFieldLooseBase(this,it)[it]());return b.Tag.render(ze||(ze=qe`
<div class="ui-selector-search-footer-box">
${0}
${0}
</div>
`),e,this.getLoaderContainer())}function lt(){return this.cache.remember("scannerLabel",(()=>b.Tag.render(Je||(Je=qe`
<span onclick="${0}">
<span class="ui-selector-footer-link ui-selector-footer-link-add footer-link--warehouse-barcode-icon">
${0}
</span>
${0}
</span>
`),this.options.onScannerClick,b.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_BARCODE_START_SCAN_LABEL"),babelHelpers.classPrivateFieldLooseBase(this,ot)[ot]())))}function nt(){return this.cache.remember("scanner_name-container",(()=>b.Tag.render(Ze||(Ze=qe`
<span class="ui-selector-search-footer-query"></span>
`))))}let ct=e=>e,dt,ht,ut,gt,pt,Et,bt,mt,It;var Ct=babelHelpers.classPrivateFieldLooseKey("searchByBarcode");var Tt=babelHelpers.classPrivateFieldLooseKey("startMobileScanner");var vt=babelHelpers.classPrivateFieldLooseKey("sendMobilePush");var Pt=babelHelpers.classPrivateFieldLooseKey("getProductIdByBarcode");var Lt=babelHelpers.classPrivateFieldLooseKey("selectScannedBarcodeProduct");var _t=babelHelpers.classPrivateFieldLooseKey("getBarcodeIcon");var ft=babelHelpers.classPrivateFieldLooseKey("layoutMobileQrPopup");var St=babelHelpers.classPrivateFieldLooseKey("closeMobilePopup");class Ot extends Xe{constructor(e,t={}){super(e,t);Object.defineProperty(this,St,{value:Mt});Object.defineProperty(this,ft,{value:Ht});Object.defineProperty(this,_t,{value:Rt});Object.defineProperty(this,Lt,{value:Ft});Object.defineProperty(this,Pt,{value:Dt});Object.defineProperty(this,vt,{value:yt});Object.defineProperty(this,Tt,{value:Nt});Object.defineProperty(this,Ct,{value:At});this.onFocusHandler=this.handleFocusEvent.bind(this);this.onBlurHandler=this.handleBlurEvent.bind(this);this.focused=false;this.settingsCollection=b.Extension.getSettings("catalog.product-selector");this.isInstalledMobileApp=this.selector.getConfig("IS_INSTALLED_MOBILE_APP")||this.settingsCollection.get("isInstallMobileApp");if(!this.settingsCollection.get("isEnabledQrAuth")&&this.selector.getConfig("ENABLE_BARCODE_QR_AUTH",true)){this.qrAuth=new n.QrAuthorization;this.qrAuth.createQrCodeImage()}}layout(){const e=super.layout();b.Dom.append(babelHelpers.classPrivateFieldLooseBase(this,_t)[_t](),e);this.getNameInput().className+=" catalog-product-field-input-barcode";b.Event.bind(this.getNameInput(),"focus",this.onFocusHandler);b.Event.bind(this.getNameInput(),"blur",this.onBlurHandler);return e}getDialogParams(){var e;const t={id:"barcode",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 s=this.selector.getConfig("RESTRICTED_PRODUCT_TYPES",null);if(!b.Type.isNil(s)){t.options.restrictedProductTypes=s}const i={id:`${this.id}_barcode`,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:b.Tag.message(dt||(dt=ct`${0}`),"CATALOG_SELECTOR_IS_EMPTY_TITLE"),subtitle:this.isAllowedCreateProduct()?b.Tag.message(ht||(ht=ct`${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()&&!b.Type.isStringFilled(this.model.getField(this.inputName))){i.preselectedItems=[["barcode",this.model.getSkuId()]]}if(b.Type.isObject(this.settingsCollection.get("limitInfo"))){i.footer=te}else{i.footer=at;i.footerOptions={onScannerClick:babelHelpers.classPrivateFieldLooseBase(this,Tt)[Tt].bind(this),isEmptyBarcode:!this.model||!this.model.isCatalogExisted(),inputName:this.inputName,errorAdminHint:this.settingsCollection.get("errorAdminHint"),allowEditItem:this.isAllowedEditProduct(),allowCreateItem:this.isAllowedCreateProduct(),creationLabel:b.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE_WITH_BARCODE"),currentValue:this.getValue(),searchOptions:{allowCreateItem:this.isAllowedCreateProduct(),footerOptions:{label:b.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE_WITH_BARCODE")}}}}return i}handleFocusEvent(){this.focused=true}handleBlurEvent(){this.focused=false}isSearchEnabled(){return true}showDetailLink(){return false}getNameTag(){return null}handleClickNameInput(e){if(this.qrAuth&&this.getDialog().getContainer()){if(!b.Dom.hasClass(this.getDialog().getContainer(),"qr-barcode-info")){b.Dom.addClass(this.getDialog().getContainer(),"qr-barcode-info")}if(this.getDialog().getContainer()){b.Dom.append(babelHelpers.classPrivateFieldLooseBase(this,ft)[ft](),this.getDialog().getContainer())}}super.handleClickNameInput(e)}showItems(){this.searchInDialog()}onChangeValue(e){const t={};this.getNameInput().title=e;this.getNameInput().value=e;t[this.inputName]=e;h.EventEmitter.emit("ProductSelector::onBarcodeChange",{rowId:this.selector.getRowId(),fields:t});this.selector.emit("onBarcodeChange",{value:e});if(this.selector.isEnabledAutosave()){this.selector.getModel().setField(this.inputName,e);this.selector.getModel().showSaveNotifier(`barcodeChanger_${this.selector.getId()}`,{title:b.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_BARCODE"),disableCancel:true,events:{onSave:()=>{if(this.selector){this.selector.getModel().save([this.inputName])}}}})}}searchInDialog(){babelHelpers.classPrivateFieldLooseBase(this,Ct)[Ct](this.getSearchQuery())}createProductModelFromSearchQuery(e){const t=super.createProductModelFromSearchQuery(e);t.setField(m.ProductSelector.INPUT_FIELD_NAME,b.Loc.getMessage("CATALOG_SELECTOR_NEW_BARCODE_PRODUCT_NAME"));t.setField(this.inputName,e);return t}checkCreationModel(e){if(!b.Type.isStringFilled(e.getField(m.ProductSelector.INPUT_FIELD_NAME))){this.model.getErrorCollection().setError(ie.NOT_SELECTED_PRODUCT,b.Loc.getMessage("CATALOG_SELECTOR_EMPTY_TITLE"));return false}return true}getPlaceholder(){return this.isSearchEnabled()&&this.model.isEmpty()?b.Loc.getMessage("CATALOG_SELECTOR_BEFORE_SEARCH_BARCODE_TITLE"):b.Loc.getMessage("CATALOG_SELECTOR_VIEW_BARCODE_TITLE")}handleClearIconClick(e){this.toggleIcon(this.getClearIcon(),"none");this.onChangeValue("");this.selector.focusName();e.stopPropagation();e.preventDefault()}applyScannerData(e){babelHelpers.classPrivateFieldLooseBase(this,Pt)[Pt](e).then((t=>{const s=t==null?void 0:t.data;if(s){babelHelpers.classPrivateFieldLooseBase(this,Lt)[Lt](s)}else{babelHelpers.classPrivateFieldLooseBase(this,Ct)[Ct](e)}this.getNameInput().value=b.Text.encode(e)})).catch((e=>console.error(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){b.Dom.remove(t);if(b.Dom.hasClass(this.getDialog().getContainer(),"qr-barcode-info")){b.Dom.removeClass(this.getDialog().getContainer(),"qr-barcode-info")}}this.qrAuth=null}destroy(){b.Event.unbind(this.getNameInput(),"focus",this.onFocusHandler);b.Event.unbind(this.getNameInput(),"blur",this.onBlurHandler)}}function At(e=""){if(!this.selector.isProductSearchEnabled()){return}const t=this.getDialog();if(!t){return}t.removeItems();if(!b.Type.isStringFilled(e)&&this.model&&this.model.isCatalogExisted()){t.setPreselectedItems([["barcode",this.model.getSkuId()]]);t.loadState="UNSENT";t.load()}t.show();t.search(e)}function Nt(e){if(this.isInstalledMobileApp){babelHelpers.classPrivateFieldLooseBase(this,vt)[vt](e);return}if(!this.qrAuth){this.qrAuth=new n.QrAuthorization;this.qrAuth.createQrCodeImage()}if(this.getDialog().isOpen()){this.getDialog().hide();this.getDialog().subscribeOnce("onHide",this.handleClickNameInput.bind(this))}else{this.handleClickNameInput(e)}}function yt(e){e==null?void 0:e.preventDefault();this.getDialog().hide();this.getNameInput().focus();if(!this.selector.isEnabledMobileScanning()){return}const t=this.selector.getMobileScannerToken();l.BarcodeScanner.open(t);const s=b.Tag.render(ut||(ut=ct`<span class='ui-notification-balloon-action'>${0}</span>`),b.Loc.getMessage("CATALOG_SELECTOR_SEND_PUSH_ON_SCANNER_NOTIFICATION_REPEAT"));b.Event.bind(s,"click",babelHelpers.classPrivateFieldLooseBase(this,vt)[vt].bind(this));const i=b.Tag.render(gt||(gt=ct`
<div>
<span>${0}</span>
${0}
</div>
`),b.Loc.getMessage("CATALOG_SELECTOR_SEND_PUSH_ON_SCANNER_NOTIFICATION"),s);BX.UI.Notification.Center.notify({content:i,category:"sending_push_barcode_scanner_notification",autoHideDelay:5e3})}function Dt(e){return b.ajax.runAction("catalog.ProductSelector.#getProductIdByBarcode",{json:{barcode:e}})}function Ft(e){this.toggleIcon(this.getSearchIcon(),"none");this.clearErrors();if(this.selector){this.selector.onProductSelect(e,{isNew:false,immutableFields:[]});this.selector.clearLayout();this.selector.layout()}this.cache.delete("dialog")}function Rt(){return this.cache.remember("barcodeIcon",(()=>{const e=b.Tag.render(pt||(pt=ct`
<button class="ui-ctl-before warehouse-barcode-icon" title="${0}"></button>
`),b.Loc.getMessage("CATALOG_SELECTOR_BARCODE_ICON_TITLE"));if(!this.settingsCollection.get("isShowedBarcodeSpotlightInfo")&&this.settingsCollection.get("isAllowedShowBarcodeSpotlightInfo")&&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();h.EventEmitter.subscribe(this.spotlight,"BX.SpotLight:onTargetEnter",(()=>{const t=new c.Guide({steps:[{target:e,title:b.Loc.getMessage("CATALOG_SELECTOR_BARCODE_SCANNER_FIRST_TIME_HINT_TITLE"),text:b.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",{})}))}b.Event.bind(e,"click",(e=>{e.preventDefault();if(this.qrAuth){this.handleClickNameInput(e)}else{babelHelpers.classPrivateFieldLooseBase(this,Tt)[Tt](e)}}));return e}))}function Ht(){return this.cache.remember("qrMobilePopup",(()=>{const e=b.Tag.render(Et||(Et=ct`<span class="popup-window-close-icon"></span>`));b.Event.bind(e,"click",babelHelpers.classPrivateFieldLooseBase(this,St)[St].bind(this));let t="";let s="";if(top.BX.Helper){s=b.Tag.render(bt||(bt=ct`
<a class="product-selector-mobile-popup-link ui-btn ui-btn-light-border ui-btn-round">
${0}
</a>
`),b.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_HELP_BUTTON"));b.Event.bind(s,"click",(()=>{top.BX.Helper.show("redirect=detail&code=14956818")}));t=b.Tag.render(mt||(mt=ct`
<a class="product-selector-mobile-popup-link ui-btn ui-btn-link">
${0}
</a>
`),b.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_SEND_PUSH_BUTTON"));b.Event.bind(t,"click",(()=>{top.BX.Helper.show("redirect=detail&code=15042444")}))}return b.Tag.render(It||(It=ct`
<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>
`),b.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_TITLE"),b.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_INSTRUCTION"),this.qrAuth.getQrNode(),s,t,e)}))}function Mt(){this.removeQrAuth();b.ajax.runAction("catalog.ProductSelector.isInstalledMobileApp",{json:{}}).then((e=>{this.selector.emit("onBarcodeQrClose",{});if(e.data===true){this.selector.emit("onBarcodeScannerInstallChecked",{});this.isInstalledMobileApp=true}})).catch((e=>console.error(e)));b.userOptions.save("product-selector","barcodeQrAuth","showed","Y")}let Bt=e=>e,wt,kt;class Ut extends u.BaseFooter{render(){const e=b.Tag.render(wt||(wt=Bt`<div>${0}</div>`),this.getContent());b.Dom.addClass(e,this.getContainerClassName());return e}getHelpLink(){const e=b.Tag.render(kt||(kt=Bt`
<div class="product-selector-placement__help-link">
${0}
</div>
`),b.Loc.getMessage("CATALOG_SELECTOR_1C_HELP_LINK"));b.Event.bind(e,"click",(()=>{if(top.BX&&top.BX.Helper){top.BX.Helper.show("redirect=detail&code=20233654")}}));return e}getContent(){throw new Error('Method "getContent" should be overridden')}getContainerClassName(){throw new Error('Method "getContainerClassName" should be overridden')}}let xt=e=>e,Gt,Vt;class jt extends Ut{getContent(){const e=b.Tag.render(Gt||(Gt=xt`
<div class="product-selector-placement__status">
${0}
</div>
`),this.getOption("text")||"");b.Event.bind(e,"click",(()=>{p.OneCPlanRestrictionSlider.show()}));return b.Tag.render(Vt||(Vt=xt`
<div class="product-selector-placement__container --lock">
<div class="product-selector-placement__icon-1C">
<div class="ui-icon-set --1c"></div>
</div>
${0}
${0}
</div>
`),e,this.getHelpLink())}getContainerClassName(){return"product-selector-placement__footer-failure"}}let $t=e=>e,Kt;class Xt extends Ut{getContent(){return b.Tag.render(Kt||(Kt=$t`
<div class="product-selector-placement__container --default">
<div class="product-selector-placement__icon-1C">
<div class="ui-icon-set --1c"></div>
</div>
<div class="ui-icon-set --warning product-selector-placement__icon-error"></div>
<div class="product-selector-placement__status">
${0}
</div>
${0}
</div>
`),this.getOption("text")||"",this.getHelpLink())}getContainerClassName(){return"product-selector-placement__footer-failure"}}let Qt=e=>e,qt;class Wt extends Ut{getContent(){return b.Tag.render(qt||(qt=Qt`
<div class="product-selector-placement__container">
<div class="product-selector-placement__loader-icon">
<div class="ui-icon-set --1c"></div>
<div class="product-selector-placement__loader">
<div class="product-selector-placement__loader-subtract"></div>
</div>
</div>
<div class="product-selector-placement__status">
${0}
</div>
${0}
</div>
`),b.Loc.getMessage("CATALOG_SELECTOR_1C_CONNECTING"),this.getHelpLink())}getContainerClassName(){return"product-selector-placement__footer-loading"}}let Yt=e=>e,zt;class Jt extends Ut{getContent(){return b.Tag.render(zt||(zt=Yt`
<div class="product-selector-placement__container">
<div class="product-selector-placement__icon-1C">
<div class="ui-icon-set --1c"></div>
</div>
<div class="product-selector-placement__status">
${0}
</div>
${0}
</div>
`),b.Loc.getMessage("CATALOG_SELECTOR_1C_CONNECTED"),this.getHelpLink())}getContainerClassName(){return"product-selector-placement__footer-success"}}var Zt=babelHelpers.classPrivateFieldLooseKey("searchTimer");var es=babelHelpers.classPrivateFieldLooseKey("productCreateTimer");var ts=babelHelpers.classPrivateFieldLooseKey("settingsCollection");var ss=babelHelpers.classPrivateFieldLooseKey("onExternalCatalogProductSelect");var is=babelHelpers.classPrivateFieldLooseKey("onProductsFound");var os=babelHelpers.classPrivateFieldLooseKey("clearSearchTimer");var as=babelHelpers.classPrivateFieldLooseKey("onProductCreated");var rs=babelHelpers.classPrivateFieldLooseKey("showSearchLoader");var ls=babelHelpers.classPrivateFieldLooseKey("hideSearchLoader");var ns=babelHelpers.classPrivateFieldLooseKey("toggleEmptyResult");var cs=babelHelpers.classPrivateFieldLooseKey("searchInExternalCatalog");var ds=babelHelpers.classPrivateFieldLooseKey("getDialogParamsFooter");var hs=babelHelpers.classPrivateFieldLooseKey("initializePlacement");var us=babelHelpers.classPrivateFieldLooseKey("renderStub");class gs extends fe{constructor(e,t={}){super(e,t);Object.defineProperty(this,us,{value:_s});Object.defineProperty(this,hs,{value:Ls});Object.defineProperty(this,ds,{value:Ps});Object.defineProperty(this,cs,{value:vs});Object.defineProperty(this,ns,{value:Ts});Object.defineProperty(this,ls,{value:Cs});Object.defineProperty(this,rs,{value:Is});Object.defineProperty(this,as,{value:ms});Object.defineProperty(this,os,{value:bs});Object.defineProperty(this,is,{value:Es});Object.defineProperty(this,ss,{value:ps});Object.defineProperty(this,Zt,{writable:true,value:null});Object.defineProperty(this,es,{writable:true,value:null});Object.defineProperty(this,ts,{writable:true,value:{}});babelHelpers.classPrivateFieldLooseBase(this,ts)[ts]=b.Extension.getSettings("catalog.product-selector");h.EventEmitter.subscribe("Catalog:ProductSelectorPlacement:onProductCreated",babelHelpers.classPrivateFieldLooseBase(this,as)[as].bind(this));h.EventEmitter.subscribe("Catalog:ProductSelectorPlacement:onProductsFound",babelHelpers.classPrivateFieldLooseBase(this,is)[is].bind(this));babelHelpers.classPrivateFieldLooseBase(this,hs)[hs]().catch((()=>{}))}isSearchEnabled(){return true}onDialogShow(e){babelHelpers.classPrivateFieldLooseBase(this,hs)[hs]().catch((()=>{}))}getDialogParams(){return{...super.getDialogParams(),...babelHelpers.classPrivateFieldLooseBase(this,ds)[ds](),searchOptions:{allowCreateItem:false},searchTabOptions:{stub:true,stubOptions:{title:b.Loc.getMessage("CATALOG_SELECTOR_IS_EMPTY_TITLE"),subtitle:"",arrow:false}},recentTabOptions:{stub:true,stubOptions:{title:b.Loc.getMessage("CATALOG_SELECTOR_1C_RECENT_TAB_SEARCH_TITLE"),subtitle:b.Loc.getMessage("CATALOG_SELECTOR_1C_RECENT_TAB_SEARCH_SUBTITLE")}}}}searchInDialog(){this.getDialog().getPopup().show();babelHelpers.classPrivateFieldLooseBase(this,hs)[hs]().then((()=>this.searchInDialogActual())).catch((()=>{}))}searchInDialogActual(){const e=this.getDialog();e.getPopup().show();if(this.isSearchQueryEmpty()){this.clear();e.selectTab(this.getDialog().getRecentTab().getId());this.showItems()}else{this.dialogMode=se.SEARCHING;e.selectTab(e.getSearchTab().getId());e.getSearchTab().getStub().hide();babelHelpers.classPrivateFieldLooseBase(this,hs)[hs]().then((()=>babelHelpers.classPrivateFieldLooseBase(this,cs)[cs]())).catch((()=>{}))}}handleClickNameInput(){if(babelHelpers.classPrivateFieldLooseBase(this,ts)[ts].is1cPlanRestricted){p.OneCPlanRestrictionSlider.show();return}this.getDialog().getPopup().show();babelHelpers.classPrivateFieldLooseBase(this,hs)[hs]().then((()=>this.showItems())).catch((()=>{}))}getPlaceholder(){return b.Loc.getMessage("CATALOG_SELECTOR_1C_INPUT_PLACEHOLDER")}getOnProductSelectConfig(e){return{needExternalUpdate:e.getCustomData().get("needExternalUpdate")}}onProductSelect(e){const t=e.getData().item;if(e.getTarget()===this.getDialog()&&t.getCustomData().has("appSid")){this.selector.emitOnProductSelectEvents();babelHelpers.classPrivateFieldLooseBase(this,ss)[ss](t);return}super.onProductSelect(e)}isFooterHidable(){return false}loadPreselectedItems(){this.selector.placement.initialize().then((()=>super.loadPreselectedItems())).catch((()=>{}))}}function ps(e){if(babelHelpers.classPrivateFieldLooseBase(this,es)[es]){return}const t={rowId:this.selector.getRowId()};h.EventEmitter.emit("Catalog:ProductSelectorPlacement:onNeedProductCreate",{appSid:e.getCustomData().get("appSid"),productId:e.id,returnEventData:t});babelHelpers.classPrivateFieldLooseBase(this,es)[es]=setTimeout((()=>{BX.UI.Notification.Center.notify({content:b.Loc.getMessage("CATALOG_SELECTOR_1C_NOT_RESPONDING_ERROR"),autoHide:true,autoHideDelay:4e3});babelHelpers.classPrivateFieldLooseBase(this,as)[as](new h.BaseEvent({data:{...t,createdProduct:null}}))}),C.ExternalCatalogPlacement.RESPONSE_TIMEOUT)}function Es(e){const{rowId:t,searchResults:s,searchQuery:i}=e.getData();if(t!==this.selector.getRowId()){return}babelHelpers.classPrivateFieldLooseBase(this,os)[os]();if(i!==this.getSearchQuery()){return}const o=this.getDialog();o.selectTab(o.getSearchTab().getId());if(s.length===0){babelHelpers.classPrivateFieldLooseBase(this,us)[us](this.getDialog().getSearchTab(),{title:b.Loc.getMessage("CATALOG_SELECTOR_IS_EMPTY_TITLE"),subtitle:"",arrow:false})}for(const e of s){o.addItem({id:e.id,title:e.name,avatar:"/bitrix/js/catalog/product-selector/images/icon1C.png",entityId:"product",tabs:o.getSearchTab().getId(),customData:{appSid:this.selector.placement.getAppSidId()}})}babelHelpers.classPrivateFieldLooseBase(this,ls)[ls]();babelHelpers.classPrivateFieldLooseBase(this,ns)[ns]();this.getDialog().setFooter(Jt)}function bs(){clearTimeout(babelHelpers.classPrivateFieldLooseBase(this,Zt)[Zt]);babelHelpers.classPrivateFieldLooseBase(this,Zt)[Zt]=null}function ms(e){if(babelHelpers.classPrivateFieldLooseBase(this,es)[es]===null){return}const{rowId:t,createdProduct:s}=e.getData();if(t!==this.selector.getRowId()){return}const i=this.getDialog();const o=b.Text.toNumber(s==null?void 0:s.id);const a=new u.Item({id:o||0,entityId:"product",title:(s==null?void 0:s.title)||"",customData:{needExternalUpdate:false}});a.setDialog(i);if(o>0){i.saveRecentItem(a)}this.onProductSelect(new h.BaseEvent({data:{item:a}}));i.removeItems();i.hide();clearTimeout(babelHelpers.classPrivateFieldLooseBase(this,es)[es]);babelHelpers.classPrivateFieldLooseBase(this,es)[es]=null}function Is(){const e=this.getDialog().getSearchTab().getSearchLoader();e.show();e.getTextContainer().textContent=b.Loc.getMessage("CATALOG_SELECTOR_1C_SEARCH")}function Cs(){this.getDialog().getSearchTab().getSearchLoader().hide()}function Ts(){this.getDialog().getSearchTab().toggleEmptyResult()}function vs(){babelHelpers.classPrivateFieldLooseBase(this,os)[os]();babelHelpers.classPrivateFieldLooseBase(this,rs)[rs]();this.getDialog().removeItems();h.EventEmitter.emit("Catalog:ProductSelectorPlacement:onNeedSearchProducts",{appSid:this.selector.placement.getAppSidId(),searchQuery:this.getSearchQuery(),returnEventData:{rowId:this.selector.getRowId(),searchQuery:this.getSearchQuery()}});babelHelpers.classPrivateFieldLooseBase(this,Zt)[Zt]=setTimeout((()=>{babelHelpers.classPrivateFieldLooseBase(this,os)[os]();babelHelpers.classPrivateFieldLooseBase(this,ls)[ls]();babelHelpers.classPrivateFieldLooseBase(this,ns)[ns]();this.getDialog().setFooter(Xt,{text:b.Loc.getMessage("CATALOG_SELECTOR_1C_NOT_RESPONDING")});babelHelpers.classPrivateFieldLooseBase(this,us)[us](this.getDialog().getSearchTab(),{title:b.Loc.getMessage("CATALOG_SELECTOR_1C_RECENT_TAB_NO_RESPONSE_TITLE"),subtitle:b.Loc.getMessage("CATALOG_SELECTOR_1C_RECENT_TAB_NO_RESPONSE_SUBTITLE").replace("[break]","<br>"),arrow:true});BX.UI.Notification.Center.notify({content:b.Loc.getMessage("CATALOG_SELECTOR_1C_NOT_RESPONDING_ERROR"),autoHide:true,autoHideDelay:4e3})}),C.ExternalCatalogPlacement.RESPONSE_TIMEOUT)}function Ps(){let e=Wt;let t={};if(this.selector.placement.isInitialized()){e=this.selector.placement.isInitializedSuccessfully()?Jt:Xt;if(this.selector.placement.isInitializedSuccessfully()){e=Jt}else{e=Xt;t={text:b.Loc.getMessage("CATALOG_SELECTOR_1C_NOT_CONNECTED")}}}return{footer:e,footerOptions:t}}function Ls(){return new Promise(((e,t)=>{this.selector.placement.initialize().then((()=>{this.getDialog().setFooter(Jt);e()})).catch((e=>{babelHelpers.classPrivateFieldLooseBase(this,us)[us](this.getDialog().getRecentTab(),{title:b.Loc.getMessage("CATALOG_SELECTOR_1C_RECENT_TAB_INIT_FAILURE_TITLE"),subtitle:b.Loc.getMessage("CATALOG_SELECTOR_1C_RECENT_TAB_INIT_FAILURE_SUBTITLE").replace("[break]","<br>"),arrow:true});if((e==null?void 0:e.reason)==="tariff"){this.getDialog().setFooter(jt,{text:b.Loc.getMessage("CATALOG_SELECTOR_1C_NOT_CONNECTED")})}else{this.getDialog().setFooter(Xt,{text:b.Loc.getMessage("CATALOG_SELECTOR_1C_NOT_CONNECTED")})}t()}))}))}function _s(e,t){this.getDialog().removeItems();e.getStub().hide();e.setStub(true,t);e.getStub().show()}let fs=e=>e,Ss;class Os{constructor(e,t={}){var s;this.id=e||b.Text.getRandom();this.selector=t.selector||null;if(!(this.selector instanceof m.ProductSelector)){throw new Error("Product selector instance not found.")}this.config=t.config||{};if(!b.Type.isStringFilled((s=this.selector.getModel())==null?void 0:s.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,t;const s=`\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\t\t`;(e=this.selector.getModel())==null?void 0:e.getImageCollection().setEditInput(s);(t=this.selector.getModel())==null?void 0:t.getImageCollection().setPreview(s)}isViewMode(){return this.selector&&(this.selector.isViewMode()||!this.selector.model.isSaveable())}isEnabledLiveSaving(){return this.enableSaving}layout(){var e,t,s,i;const o=b.Tag.render(Ss||(Ss=fs`<div></div>`));const a=this.isViewMode()?(e=this.selector.getModel())==null?void 0:(t=e.getImageCollection())==null?void 0:t.getPreview():(s=this.selector.getModel())==null?void 0:(i=s.getImageCollection())==null?void 0:i.getEditInput();b.Runtime.html(o,a);return o}}let As=e=>e,Ns,ys,Ds,Fs,Rs,Hs,Ms,Bs;const ws=new Map;const ks=new Map;var Us=babelHelpers.classPrivateFieldLooseKey("inAjaxProcess");var xs=babelHelpers.classPrivateFieldLooseKey("createSearchInput");class Gs extends h.EventEmitter{static getById(e){return ws.get(e)||null}constructor(e,t={}){super();Object.defineProperty(this,xs,{value:Vs});Object.defineProperty(this,Us,{writable:true,value:false});this.mode=Gs.MODE_EDIT;this.cache=new b.Cache.MemoryCache;this.type=Gs.INPUT_FIELD_NAME;this.mobileScannerToken=null;this.variationChangeHandler=this.handleVariationChange.bind(this);this.onSaveImageHandler=this.onSaveImage.bind(this);this.onChangeFieldsHandler=b.Runtime.debounce(this.onChangeFields,500,this);this.onUploaderIsInitedHandler=this.onUploaderIsInited.bind(this);this.onNameChangeFieldHandler=b.Runtime.debounce(this.onNameChange,500,this);this.placementOnProductUpdatedHandler=this.placementOnProductUpdated.bind(this);this.setEventNamespace("BX.Catalog.ProductSelector");this.id=e||b.Text.getRandom();t.inputFieldName=t.inputFieldName||Gs.INPUT_FIELD_NAME;this.options=t||{};this.settings=b.Extension.getSettings("catalog.product-selector");this.type=this.options.type||Gs.INPUT_FIELD_NAME;this.setMode(t.mode);this.isExternalCatalog=this.settings.get("isExternalCatalog",false);if(this.isExternalCatalog){this.placement=C.ExternalCatalogPlacement.create();this.placement.initialize()}if(t.model&&t.model instanceof I.ProductModel){this.model=t.model}else{this.model=I.ProductModel.getById(this.id)}if(!(this.model instanceof I.ProductModel)){this.model=new I.ProductModel({currency:t.currency,iblockId:b.Text.toNumber(t.iblockId),basePriceId:b.Text.toNumber(t.basePriceId),fields:t.fields,skuTree:t.skuTree,storeMap:t.storeMap})}this.model.getImageCollection().setMorePhotoValues(t.morePhotoValues);if(!b.Type.isNil(this.getConfig("DETAIL_PATH"))){this.model.setDetailPath(this.getConfig("DETAIL_PATH"))}if(t.failedProduct){this.model.getErrorCollection().setError(ie.FAILED_PRODUCT,"")}if(this.isShowableEmptyProductError()){this.model.getErrorCollection().setError(ie.NOT_SELECTED_PRODUCT,this.getEmptySelectErrorMessage())}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)}this.subscribeEvents();ws.set(this.id,this)}setModel(e){this.model=e}getModel(){return this.model}setMode(e){if(!b.Type.isNil(e)){this.mode=e===Gs.MODE_VIEW?Gs.MODE_VIEW:Gs.MODE_EDIT}}isViewMode(){return this.mode===Gs.MODE_VIEW}isShortViewFormat(){return this.getConfig("VIEW_FORMAT",Gs.FULL_VIEW_FORMAT)===Gs.SHORT_VIEW_FORMAT}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)}getEmptySelectErrorMessage(){return!this.isExternalCatalog&&this.checkProductAddRights()?b.Loc.getMessage("CATALOG_SELECTOR_SELECTED_PRODUCT_TITLE"):b.Loc.getMessage("CATALOG_SELECTOR_SELECT_PRODUCT_TITLE")}getMobileScannerToken(){return this.mobileScannerToken||b.Text.getRandom(16)}checkProductViewRights(){var e;return(e=this.model.checkAccess(I.RightActionDictionary.ACTION_PRODUCT_VIEW))!=null?e:true}checkProductEditRights(){var e;return(e=this.model.checkAccess(I.RightActionDictionary.ACTION_PRODUCT_EDIT))!=null?e:false}checkProductAddRights(){var e;return(e=this.model.checkAccess(I.RightActionDictionary.ACTION_PRODUCT_ADD))!=null?e:false}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 Os(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&&this.checkProductViewRights()}isSkuTreeEnabled(){return this.getConfig("ENABLE_SKU_TREE",true)!==false}isImageFieldEnabled(){return this.getConfig("ENABLE_IMAGE_INPUT",true)!==false}isShowableEmptyProductError(){const e=this.model.isEmpty()&&this.model.isChanged();return this.isEnabledEmptyProductError()&&(e||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)&&b.Type.isStringFilled(this.model.getDetailPath())&&this.checkProductViewRights()}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=b.Tag.render(Ns||(Ns=As`<div class="catalog-product-field-inner"></div>`));b.Dom.append(this.layoutNameBlock(),t);if(this.getSkuTreeInstance()){b.Dom.append(this.getSkuTreeInstance().layout(),t)}b.Dom.append(this.getErrorContainer(),t);if(!this.isViewMode()){b.Dom.append(t,e)}if(this.isImageFieldEnabled()){if(b.Reflection.getClass("BX.UI.ImageInput")){this.layoutImage()}if(Gs.UIInputRequest instanceof Promise){Gs.UIInputRequest.then((()=>{this.layoutImage()}))}else{Gs.UIInputRequest=new Promise((e=>{b.ajax.runAction("catalog.productSelector.getFileInput",{json:{iblockId:this.getModel().getIblockId()}}).then((()=>{this.layoutImage();Gs.UIInputRequest=null;e()}))}))}b.Dom.append(this.getImageContainer(),e)}if(this.isViewMode()){b.Dom.append(t,e)}if(this.isViewMode()){b.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",(()=>b.Tag.render(ys||(ys=As`<div class="catalog-product-img"></div>`))))}getErrorContainer(){return this.cache.remember("errorContainer",(()=>b.Tag.render(Ds||(Ds=As`<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(!Gs.ErrorCodes.getCodes().includes(t)){continue}if(t==="EMPTY_IMAGE"){this.setImageErrorBorder()}else{b.Dom.append(b.Tag.render(Fs||(Fs=As`<div class="catalog-product-error-item">${0}</div>`),e[t].text),this.getErrorContainer());if(this.searchInput){b.Dom.addClass(this.searchInput.getNameBlock(),"ui-ctl-danger")}}}}setImageErrorBorder(){b.Dom.addClass(this.getImageContainer().querySelector(".adm-fileinput-area"),"adm-fileinput-drag-area-error")}clearImageErrorBorder(){b.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="";b.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(){this.unsubscribeToVariationChange();const e=this.getWrapper();if(e){e.innerHTML=""}}subscribeEvents(){h.EventEmitter.incrementMaxListeners("ProductList::onChangeFields",1);h.EventEmitter.incrementMaxListeners("ProductSelector::onNameChange",1);h.EventEmitter.incrementMaxListeners("Catalog.ImageInput::save",1);h.EventEmitter.incrementMaxListeners("onUploaderIsInited",1);h.EventEmitter.incrementMaxListeners("Catalog:ProductSelectorPlacement:onProductUpdated",1);h.EventEmitter.subscribe("ProductList::onChangeFields",this.onChangeFieldsHandler);h.EventEmitter.subscribe("ProductSelector::onNameChange",this.onNameChangeFieldHandler);h.EventEmitter.subscribe("Catalog.ImageInput::save",this.onSaveImageHandler);h.EventEmitter.subscribe("onUploaderIsInited",this.onUploaderIsInitedHandler);h.EventEmitter.subscribe("Catalog:ProductSelectorPlacement:onProductUpdated",this.placementOnProductUpdatedHandler)}unsubscribeEvents(){this.unsubscribeToVariationChange();h.EventEmitter.unsubscribe("Catalog.ImageInput::save",this.onSaveImageHandler);h.EventEmitter.unsubscribe("ProductList::onChangeFields",this.onChangeFieldsHandler);h.EventEmitter.unsubscribe("onUploaderIsInited",this.onUploaderIsInitedHandler);h.EventEmitter.unsubscribe("onUploaderIsInited",this.onUploaderIsInitedHandler);h.EventEmitter.unsubscribe("ProductSelector::onNameChange",this.onNameChangeFieldHandler);h.EventEmitter.unsubscribe("Catalog:ProductSelectorPlacement:onProductUpdated",this.placementOnProductUpdatedHandler)}defineWrapperClass(e){if(this.isViewMode()){b.Dom.addClass(e,"catalog-product-view");b.Dom.removeClass(e,"catalog-product-edit");if(this.isShortViewFormat()){b.Dom.addClass(e,"--short-format")}}else{b.Dom.addClass(e,"catalog-product-edit");b.Dom.removeClass(e,"catalog-product-view")}if(this.isImageFieldEnabled()){b.Dom.addClass(e,"--with-images")}}getNameBlockView(){const e=b.Text.encode(this.model.getField("NAME"));const t=b.Loc.getMessage("CATALOG_SELECTOR_VIEW_NAME_TITLE");if(this.getModel().getDetailPath()){return b.Tag.render(Rs||(Rs=As`
<a href="${0}" title="${0}">${0}</a>
`),this.getModel().getDetailPath(),t,e)}return b.Tag.render(Hs||(Hs=As`<span title="${0}">${0}</span>`),t,e)}getNameInputFilledValue(){if(this.searchInput){return this.searchInput.getFilledValue()}return""}layoutNameBlock(){const e=b.Tag.render(Ms||(Ms=As`<div class="catalog-product-field-input"></div>`));if(this.isViewMode()){b.Dom.append(this.getNameBlockView(),e)}else{this.searchInput=babelHelpers.classPrivateFieldLooseBase(this,xs)[xs]();b.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(ks.has(this.getModel().getIblockId())){e(ks.get(this.getModel().getIblockId()))}else{b.ajax.runAction("catalog.productSelector.getSkuTreeProperties",{json:{iblockId:this.getModel().getIblockId()}}).then((t=>{ks.set(this.getModel().getIblockId(),t);e(t)}))}}))}getSkuTreeInstance(){var e;if(this.isSkuTreeEnabled()&&(e=this.getModel())!=null&&e.getSkuTree()&&!this.skuTreeInstance){this.skuTreeInstance=new o.SkuTree({skuTree:this.getModel().getSkuTree(),selectable:this.getConfig("ENABLE_SKU_SELECTION",true),hideUnselected:this.getConfig("HIDE_UNSELECTED_ITEMS",false),isShortView:this.isViewMode()&&this.isShortViewFormat()})}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 s=b.Text.toNumber(t.PARENT_PRODUCT_ID);const i=b.Text.toNumber(t.ID);if(s<=0||i<=0){return}this.emit("onBeforeChange",{selectorId:this.getId(),rowId:this.getRowId()});babelHelpers.classPrivateFieldLooseBase(this,Us)[Us]=true;if(this.placement){this.placement.initialize().then((()=>{this.placementEmitOnCatalogProductNeedToUpdate({productId:i,returnEventData:{rowId:this.getRowId(),scenario:"variationChange",payload:[i]}})})).catch((()=>{this.handleVariationChangeAjaxAction(i);BX.UI.Notification.Center.notify({content:b.Loc.getMessage("CATALOG_SELECTOR_1C_NOT_RESPONDING_ERROR"),autoHide:true,autoHideDelay:4e3})}));return}this.handleVariationChangeAjaxAction(i)}handleVariationChangeAjaxAction(e){b.ajax.runAction("catalog.productSelector.getSelectedSku",{json:{variationId:e,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 s=t.fields;this.getModel().setFields(s)}reloadFileInput(){var e;b.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()}}))}onNameChange(e){const t=e.getData();if(t.rowId!==this.getRowId()||!this.isEnabledAutosave()){return}const s=t.fields;this.getModel().setFields(s);this.getModel().save().then((()=>{BX.UI.Notification.Center.notify({id:"saving_field_notify_name",closeButton:false,content:b.Tag.render(Bs||(Bs=As`<div>${0}</div>`),b.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_NAME_CHANGED")),autoHide:true})}))}onSaveImage(e){const[,t,s]=e.getData();if(t!==this.getFileInput().getId()){return}this.getFileInput().setId(s.data.id);this.getFileInput().setInputHtml(s.data.input);this.getFileInput().setView(s.data.preview);this.getModel().getImageCollection().setMorePhotoValues(s.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,Us)[Us]}onProductSelect(e,t){this.emitOnProductSelectEvents();this.productSelectRequest(e,t)}emitOnProductSelectEvents(){this.emit("onProductSelect",{selectorId:this.getId(),rowId:this.getRowId()});this.emit("onBeforeChange",{selectorId:this.getId(),rowId:this.getRowId()})}productSelectRequest(e,t={isNew:false,needExternalUpdate:true,immutableFields:[]}){babelHelpers.classPrivateFieldLooseBase(this,Us)[Us]=true;if(this.placement&&t.needExternalUpdate!==false){this.placement.initialize().then((()=>{this.placementEmitOnCatalogProductNeedToUpdate({productId:e,returnEventData:{rowId:this.getRowId(),scenario:"productSelect",payload:[e,t]}})})).catch((()=>{this.productSelectAjaxAction(e,t);BX.UI.Notification.Center.notify({content:b.Loc.getMessage("CATALOG_SELECTOR_1C_NOT_RESPONDING_ERROR"),autoHide:true,autoHideDelay:4e3})}));return}this.productSelectAjaxAction(e,t)}productSelectAjaxAction(e,t={isNew:false,immutableFields:[]}){b.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)))}placementEmitOnCatalogProductNeedToUpdate(e){h.EventEmitter.emit("Catalog:ProductSelectorPlacement:onNeedProductUpdate",{appSid:this.placement.getAppSidId(),...e});this.placementProductUpdateTimer=setTimeout((()=>{BX.UI.Notification.Center.notify({content:b.Loc.getMessage("CATALOG_SELECTOR_1C_NOT_RESPONDING_ERROR"),autoHide:true,autoHideDelay:4e3});this.placementOnProductUpdated(new h.BaseEvent({data:{...e.returnEventData}}))}),C.ExternalCatalogPlacement.RESPONSE_TIMEOUT)}placementOnProductUpdated(e){if(this.placementProductUpdateTimer===null){return}const{rowId:t,scenario:s,payload:i}=e.getData();if(t!==this.getRowId()){return}if(s==="productSelect"){this.productSelectAjaxAction(...i)}else if(s==="variationChange"){this.handleVariationChangeAjaxAction(...i)}clearTimeout(this.placementProductUpdateTimer);this.placementProductUpdateTimer=null}processResponse(e,t={},s=false){const i=(e==null?void 0:e.data)||null;babelHelpers.classPrivateFieldLooseBase(this,Us)[Us]=false;const o=(i==null?void 0:i.fields)||[];if(b.Type.isArray(t.immutableFields)){t.immutableFields.forEach((e=>{o[e]=this.getModel().getField(e)}));if(i){i.fields=o}}if(s){this.clearState()}if(i){this.changeSelectedElement(i,t)}else if(!s){this.productSelectRequest(this.getModel().getProductId())}this.unsubscribeToVariationChange();if(this.isEnabledChangesRendering()){this.clearLayout();this.layout()}this.emit("onChange",{selectorId:this.id,rowId:this.getRowId(),isNew:t.isNew||false,fields:o,morePhoto:this.getModel().getImageCollection().getMorePhotoValues()})}changeSelectedElement(e,t){const s=b.Text.toInteger(e.productId);const i=this.getModel().getProductId()!==s;if(i){this.getModel().setOption("productId",s);this.getModel().setOption("skuId",b.Text.toInteger(e.skuId));this.getModel().setOption("isSimpleModel",false);this.getModel().setOption("isNew",t.isNew)}this.getModel().initFields(e.fields);const o={id:"",input:"",preview:"",values:[]};if(b.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(b.Type.isObject(e.skuTree)){this.updateSkuTree(e.skuTree)}}checkEmptyImageError(){if(!b.Type.isArrayFilled(this.getModel().getImageCollection().getMorePhotoValues())&&this.isEnabledEmptyImagesError()){this.getModel().getErrorCollection().setError("EMPTY_IMAGE",b.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)}}function Vs(){if(this.placement){return new gs(this.id,{selector:this,model:this.getModel(),inputName:this.options.inputFieldName,isSearchEnabled:this.isProductSearchEnabled(),isEnabledEmptyProductError:this.isEnabledEmptyProductError(),isEnabledDetailLink:this.isInputDetailLinkEnabled()})}if(this.getType()===Gs.INPUT_FIELD_BARCODE){if(!this.searchInput){return new Ot(this.id,{selector:this,model:this.getModel(),inputName:this.options.inputFieldName})}return this.searchInput}return new Xe(this.id,{selector:this,model:this.getModel(),inputName:this.options.inputFieldName,isSearchEnabled:this.isProductSearchEnabled(),isEnabledEmptyProductError:this.isEnabledEmptyProductError(),isEnabledDetailLink:this.isInputDetailLinkEnabled()})}Gs.MODE_VIEW="view";Gs.MODE_EDIT="edit";Gs.SHORT_VIEW_FORMAT="short";Gs.FULL_VIEW_FORMAT="full";Gs.INPUT_FIELD_NAME="NAME";Gs.INPUT_FIELD_BARCODE="BARCODE";Gs.ErrorCodes=ie;Gs.UIInputRequest=null;e.ProductSelector=Gs})(this.BX.Catalog=this.BX.Catalog||{},BX,BX,BX,BX.Catalog.SkuTree,BX,BX.UI,BX.Catalog,BX.UI,BX.UI.Tour,BX,BX.Event,BX.UI.EntitySelector,BX,BX.Catalog,BX,BX,BX.Catalog,BX.Catalog,BX.Catalog);
//# sourceMappingURL=product-selector.bundle.map.js