1!function(){"use strict";BX.namespace("BX.Sale.BasketFilter"),BX.Sale.BasketFilter=function(t){this.component=t,this.activeFilterMode=!1,this.filterTimer=null,this.mouseOverClearFilter=!1,this.realShownItems=[],this.realSortedItems=[],this.realScrollTop=0,this.lastShownItemsHash="",this.currentFilter={query:"",similarHash:"",warning:!1,notAvailable:!1,delayed:!1},this.component.useItemsFilter&&this.bindEvents()},BX.Sale.BasketFilter.prototype.bindEvents=function(){var t,e=this.component.getEntity(this.component.getCacheNode(this.component.ids.itemListWrapper),"basket-filter");t=this.component.getEntity(e,"basket-filter-input"),BX.type.isDomNode(t)&&(BX.bind(t,"focus",(function(){})),BX.bind(t,"blur",BX.delegate((function(){this.mouseOverClearFilter||(e.style.flex="")}),this)),BX.bind(t,"keyup",BX.proxy(this.onFilterInput,this)),BX.bind(t,"cut",BX.proxy(this.onFilterInput,this)),BX.bind(t,"paste",BX.proxy(this.onFilterInput,this))),t=this.component.getEntity(e,"basket-filter-clear-btn"),BX.type.isDomNode(t)&&(BX.bind(t,"mouseenter",BX.delegate((function(){this.mouseOverClearFilter=!0}),this)),BX.bind(t,"mouseout",BX.delegate((function(){this.mouseOverClearFilter=!1}),this)),BX.bind(t,"click",BX.delegate((function(){this.filterInputEmpty()||(this.clearFilterInput(),this.onFilterChange()),e.style.flex=""}),this)))},BX.Sale.BasketFilter.prototype.isActive=function(){return this.activeFilterMode},BX.Sale.BasketFilter.prototype.showFilterByName=function(t){if(t)switch(t){case"not-available":this.showNotAvailableItemsFilter(),this.showAllItemsFilter();break;case"delayed":this.showDelayItemsFilter(),this.showAllItemsFilter();break;case"warning":this.showWarningItemsFilter(),this.showAllItemsFilter();break;case"similar":this.showSimilarItemsFilter(),this.showAllItemsFilter();break;default:this.clearAllFiltersExcept([]),this.onFilterChange()}},BX.Sale.BasketFilter.prototype.showAllItemsFilter=function(){this.component.getEntity(this.component.getCacheNode(this.component.ids.itemListWrapper),"basket-items-count",'[data-filter="all"]').style.display=""},BX.Sale.BasketFilter.prototype.onFilterInput=function(){var t=BX.type.isDomNode(BX.proxy_context)?BX.util.trim(BX.proxy_context.value).toLowerCase():"";BX.proxy_context.parentElement.querySelector(".basket-clear-input-btn").style.display=t?"":"none",this.currentFilter.query!==t&&(this.currentFilter.query=t,this.onFilterChange())},BX.Sale.BasketFilter.prototype.clearAllFiltersExcept=function(t){t&&BX.type.isArray(t)&&(!BX.util.in_array("input",t)&&this.clearFilterInput(),!BX.util.in_array("warning",t)&&this.clearWarningItemsFilter(),!BX.util.in_array("delayed",t)&&this.clearDelayItemsFilter(),!BX.util.in_array("not-available",t)&&this.clearNotAvailableItemsFilter(),BX.util.in_array("similar",t)||(this.clearSimilarItemsFilter(),this.component.showSimilarCount(!1)))},BX.Sale.BasketFilter.prototype.filterInputEmpty=function(){return 0===this.currentFilter.query.length},BX.Sale.BasketFilter.prototype.clearFilterInput=function(){this.currentFilter.query="";var t=this.component.getEntity(this.component.getCacheNode(this.component.ids.itemListWrapper),"basket-filter-input");BX.type.isDomNode(t)&&(t.value=""),t.parentElement.querySelector(".basket-clear-input-btn").style.display="none"},BX.Sale.BasketFilter.prototype.addWarningItemsFilter=function(){this.currentFilter.warning=!0},BX.Sale.BasketFilter.prototype.clearWarningItemsFilter=function(){this.currentFilter.warning=!1},BX.Sale.BasketFilter.prototype.showWarningItemsFilter=function(){this.currentFilter.warning||(this.clearAllFiltersExcept(["warning"]),this.addWarningItemsFilter(),this.onFilterChange())},BX.Sale.BasketFilter.prototype.addDelayItemsFilter=function(){this.currentFilter.delayed=!0},BX.Sale.BasketFilter.prototype.clearDelayItemsFilter=function(){this.currentFilter.delayed=!1},BX.Sale.BasketFilter.prototype.showDelayItemsFilter=function(){this.currentFilter.delayed||(this.clearAllFiltersExcept(["delayed"]),this.addDelayItemsFilter(),this.onFilterChange())},BX.Sale.BasketFilter.prototype.addNotAvailableItemsFilter=function(){this.currentFilter.notAvailable=!0},BX.Sale.BasketFilter.prototype.clearNotAvailableItemsFilter=function(){this.currentFilter.notAvailable=!1},BX.Sale.BasketFilter.prototype.showNotAvailableItemsFilter=function(){this.currentFilter.notAvailable||(this.clearAllFiltersExcept(["not-available"]),this.addNotAvailableItemsFilter(),this.onFilterChange())},BX.Sale.BasketFilter.prototype.addSimilarItemsFilter=function(t){this.currentFilter.similarHash=t.HASH},BX.Sale.BasketFilter.prototype.clearSimilarItemsFilter=function(){this.currentFilter.similarHash=""},BX.Sale.BasketFilter.prototype.showSimilarItemsFilter=function(){var t=this.component.getItemDataByTarget(BX.proxy_context);this.currentFilter.similarHash!==t.HASH&&(this.clearAllFiltersExcept(["similar"]),this.addSimilarItemsFilter(t),this.onFilterChange())},BX.Sale.BasketFilter.prototype.getTimeoutDuration=function(){return this.component.duration.filterTimer},BX.Sale.BasketFilter.prototype.onFilterChange=function(){this.component.showItemsOverlay(),this.currentFilter.query.length||this.currentFilter.similarHash.length||this.currentFilter.warning||this.currentFilter.notAvailable||this.currentFilter.delayed?(clearTimeout(this.filterTimer),this.filterTimer=setTimeout(BX.proxy(this.enableFilterMode,this),this.getTimeoutDuration())):this.disableFilterMode()},BX.Sale.BasketFilter.prototype.enableFilterMode=function(){var t;this.activeFilterMode||(this.activeFilterMode=!0,this.realShownItems=BX.util.array_values(this.component.shownItems),this.realSortedItems=BX.util.array_values(this.component.sortedItems),this.realScrollTop=this.component.getDocumentScrollTop()),this.component.scrollToFirstItem(),this.component.sortedItems=this.searchItems(),t=JSON.stringify(this.component.sortedItems),this.lastShownItemsHash!==t?(this.lastShownItemsHash=t,this.component.deleteBasketItems(BX.util.array_values(this.component.shownItems),!1),this.component.sortedItems.length?(this.component.initializeBasketItems(),this.hideEmptyFilterResult()):this.showEmptyFilterResult(),this.currentFilter.similarHash.length&&this.component.showSimilarCount(!0)):this.highlightFoundItems(),this.component.hideItemsOverlay()},BX.Sale.BasketFilter.prototype.disableFilterMode=function(){clearTimeout(this.filterTimer),this.lastShownItemsHash="",this.activeFilterMode&&(this.activeFilterMode=!1,this.component.sortedItems=BX.util.array_values(this.realSortedItems),this.component.deleteBasketItems(BX.util.array_values(this.component.shownItems),!1),this.hideEmptyFilterResult(),this.component.editBasketItems(BX.util.array_values(this.realShownItems)),window.scrollTo(0,this.realScrollTop)),this.component.hideItemsOverlay()},BX.Sale.BasketFilter.prototype.searchItems=function(){for(var t=[],e=0;e<this.realSortedItems.length;e++){var i=this.component.items[this.realSortedItems[e]];i&&this.searchItemMatch(i)&&t.push(i.ID)}return t},BX.Sale.BasketFilter.prototype.highlightFoundItems=function(){if(this.activeFilterMode)for(var t in this.component.shownItems)this.component.shownItems.hasOwnProperty(t)&&this.highlightSearchMatch(this.component.items[this.component.shownItems[t]])},BX.Sale.BasketFilter.prototype.searchItemMatch=function(t){var e=!1,i=!1;if(this.currentFilter.notAvailable){if(!(i=!!t.NOT_AVAILABLE))return e}else if(this.currentFilter.delayed){if(!(i=!!t.DELAYED))return e}else if(this.currentFilter.warning){if(!(i=BX.util.in_array(t.ID,this.component.warningItems)))return e}else if(BX.type.isNotEmptyString(this.currentFilter.similarHash)&&!(i=this.currentFilter.similarHash===t.HASH))return e;if(BX.type.isNotEmptyString(this.currentFilter.query)){if(-1!==t.NAME.toLowerCase().indexOf(this.currentFilter.query)&&(e="NAME"),!e){var r=parseFloat(this.currentFilter.query);isNaN(r)||(parseFloat(t.PRICE)===r?e="PRICE":parseFloat(t.SUM_PRICE)===r&&(e="SUM_PRICE"))}var s,l;if(!e&&this.currentFilter.query.length>=3&&(-1!==t.PRICE_FORMATED.toLowerCase().indexOf(this.currentFilter.query)?e="PRICE":-1!==t.SUM_PRICE_FORMATED.toLowerCase().indexOf(this.currentFilter.query)&&(e="SUM_PRICE")),!e&&t.PROPS.length)for(s in t.PROPS)if(t.PROP
1S.hasOwnProperty(s)&&BX.type.isNotEmptyString(t.PROPS[s].VALUE)&&((l=t.PROPS[s].VALUE.toLowerCase())===this.currentFilter.query||this.currentFilter.query.length>=3&&-1!==l.indexOf(this.currentFilter.query))){e="PROPS";break}if(!e&&t.COLUMN_LIST.length)for(s in t.COLUMN_LIST)if(t.COLUMN_LIST.hasOwnProperty(s)&&BX.type.isNotEmptyString(t.COLUMN_LIST[s].VALUE)&&((l=t.COLUMN_LIST[s].VALUE.toLowerCase())===this.currentFilter.query||this.currentFilter.query.length>=3&&-1!==l.indexOf(this.currentFilter.query))){e="COLUMNS";break}}else i&&(e=!0);return e},BX.Sale.BasketFilter.prototype.highlightSearchMatch=function(t){var e,i,r,s,l=this.searchItemMatch(t);if(l)switch(l){case"NAME":e=this.component.getEntity(BX(this.component.ids.item+t.ID),"basket-item-name"),BX.type.isDomNode(e)&&(e.innerHTML=t.NAME.replace(new RegExp("(.*)("+this.currentFilter.query.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+")(.*)","gi"),(function(t,e,i,r){return BX.util.htmlspecialchars(e)+'<span class="basket-item-highlighted">'+BX.util.htmlspecialchars(i)+"</span>"+BX.util.htmlspecialchars(r)})));break;case"PRICE":e=BX(this.component.ids.price+t.ID),BX.addClass(e,"basket-item-highlighted");break;case"SUM_PRICE":e=BX(this.component.ids.sumPrice+t.ID),BX.addClass(e,"basket-item-highlighted");break;case"PROPS":for(e=this.component.getEntities(BX(this.component.ids.item+t.ID),"basket-item-property-value"),i=0;i<e.length;i++)for(r in s=e[i].getAttribute("data-property-code"),t.PROPS)t.PROPS.hasOwnProperty(r)&&t.PROPS[r].CODE===s&&(e[i].innerHTML=t.PROPS[r].VALUE.replace(new RegExp("("+this.currentFilter.query+")","gi"),'<span class="basket-item-highlighted">$1</span>'));break;case"COLUMNS":for(e=this.component.getEntities(BX(this.component.ids.item+t.ID),"basket-item-property-column-value"),i=0;i<e.length;i++)for(r in s=e[i].getAttribute("data-column-property-code"),t.COLUMN_LIST)t.COLUMN_LIST.hasOwnProperty(r)&&t.COLUMN_LIST[r].CODE===s&&(e[i].innerHTML=t.COLUMN_LIST[r].VALUE.replace(new RegExp("("+this.currentFilter.query+")","gi"),'<span class="basket-item-highlighted">$1</span>'))}},BX.Sale.BasketFilter.prototype.showEmptyFilterResult=function(){var t=this.component.getCacheNode(this.component.ids.itemList);if(BX.type.isDomNode(t)){var e=this.component.getCacheNode(this.component.ids.itemListEmptyResult);BX.type.isDomNode(e)&&(e.style.display="")}},BX.Sale.BasketFilter.prototype.hideEmptyFilterResult=function(){var t=this.component.getCacheNode(this.component.ids.itemListEmptyResult);BX.type.isDomNode(t)&&(t.style.display="none")}}(); 2//# sourceMappingURL=filter.min.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.