a?1:0};a.tagsList.push(e),t===i.Ascending?a.tagsList.sort(o):t===i.Descending&&(a.tagsList.sort(o),a.tagsList.reverse())},o.prototype._removeTooltip=function(e){var t=this.properties.toolTipsTags[e];t&&(t.dispose(),delete this.properties.toolTipsTags[e])},o.prototype._enableTypeAhead=function(){var t=this.properties,i=t.options;if(i.typeahead){var a=i.typeahead||null;if(null!==a)if(t.typeahead)t.tagsTreeViewVisible||t.typeahead.enable();else{var o=t.extendedTypeaheadOptions=e.jQuery.extend(!0,{},e.UI.Controls.Typeahead.DEFAULTOPTIONS,a),r=this._getTypeaheadEmptyTemplate();o.templates.empty={template:r,fadeOutDelay:3e3},o.isSelected=function(e){var i=!1;return t.tagsList&&t.tagsList.forEach(function(t){t.id===e.id&&(i=!0)}),i},t.typeahead=new e.UI.Controls.Typeahead(t.$input.get(0),o),t.typeahead.addEventListener(\"suggestionselected\",this.getDelegate(this._onSuggestionSelected)),t.typeahead.addEventListener(\"loading\",this.getDelegate(this._onTypeahaedLoading)),t.typeahead.addEventListener(\"loaded\",this.getDelegate(this._onTypeahaedLoaded))}}},o.prototype._enableTagsTreeView=function(){var t=this.properties,i=t.options;if(i.tagsTreeView){var a=e.jQuery(\"\").addClass(\"sdl-labelmanager-assist-icon\"),o={iconClass:{light:\"\",dark:\"\"},style:e.UI.Controls.ButtonStyle.DEFAULT,state:e.UI.Controls.ButtonToggleState.OFF,purpose:e.UI.Controls.ButtonPurpose.TOGGLE,disabled:!1};t.assistButton=new e.UI.Controls.Button(a.get(0),o),t.tagsTreeViewVisible=!1,t.assistButton.addEventListener(\"propertychange\",this.getDelegate(this._onAssistButttonPropertyChange)),a.insertAfter(t.$container)}},o.prototype._onSuggestionSelected=function(e){var t=e.data;t&&t.length>0&&(this.add(t[0]),this._clearInput(),this.focus())},o.prototype._onTopNodeReached=function(){this.focus()},o.prototype._onNodeSelected=function(e){var t=e.data;if(t&&!this._nodeIsSelected(t)){var i={label:t.name,id:t.id,description:t.description,isInvalid:!1};this.add(i)}},o.prototype._hideTreeView=function(){var e=this,t=this.properties;t.tagsTreeView&&(t.tagsTreeView.hide(),t.tagsTreeViewCallout.hide()),t.tagsTreeViewVisible=!1,this._enableTypeAhead(),t.assistButton&&t.assistButton.toggleOff(),setTimeout(function(){e.fireEvent(\"tagstreeviewcallouthidden\")},0)},o.prototype._focusTreeView=function(){var t=this.properties,i=t.tagsTreeView.getRootNodes();i&&i.length>0&&(e.jQuery(t.tagsTreeView.getElement()).focus(),event.preventDefault())},o.prototype._containerOnKeyDown=function(t){var i,a,o=this.properties,r=this._findInputWrapper(),s=t.target===o.$input.get(0),n=e.UI.Core.Event.Constants.Keys;switch(t.which){case n.BACKSPACE:if(0===o.$input.val().trim().length){var l=r.prev();l&&(o.$selectedTag?(i=o.$selectedTag.data(\"item\"),this._moveCursorLeft(),this.remove(i)):s&&(a=e.jQuery(\".tag\",l),this.selectTag(a))),t.preventDefault()}break;case n.DELETE:if(0===o.$input.val().trim().length){var p=r.next();p&&(o.$selectedTag?(i=o.$selectedTag.data(\"item\"),this._moveCursorRight(),this.remove(i)):s&&(a=e.jQuery(\".tag\",p),this.selectTag(a))),t.preventDefault()}break;case n.LEFT:s&&this._moveCursorLeft();break;case n.RIGHT:s&&this._moveCursorRight();break;case n.ESCAPE:var d=o.typeahead;d||o.tagsTreeViewVisible?o.tagsTreeViewVisible&&(this._hideTreeView(),this.focus()):this._clearInput(),t.preventDefault();break;case n.TAB:o.tagsTreeViewVisible&&(t.shiftKey||this._focusTreeView());break;case n.DOWN:o.tagsTreeViewVisible&&this._focusTreeView()}o.$input&&o.$input.attr(\"size\",Math.max(o.inputSize,o.$input.val().length))},o.prototype._treeViewOnKeyDown=function(t){var i=this.properties,a=e.UI.Core.Event.Constants.Keys;switch(t.which){case a.ESCAPE:i.tagsTreeViewVisible&&(this._hideTreeView(),this.focus());break;case a.TAB:i.tagsTreeViewVisible&&(t.shiftKey?(this.focus(),t.preventDefault()):(e.jQuery(i.assistButton.getElement()).focus(),t.preventDefault()))}},o.prototype._positionFilteredTreeView=function(t){void 0===t&&(t=!0);var i=this.properties;i.tagsTreeViewCalloutPosition||(i.tagsTreeViewCalloutPosition=e.UI.Controls.PositionedControlPosition.BELOW);var a={preferredPosition:null,allowedPositions:[],targetElement:i.$container.get(0),horizontalAlign:e.UI.Controls.PositionedControlHorizontalAlignement.LEFT_TO_LEFT,verticalAlign:e.UI.Controls.PositionedControlVerticalAlignement.TOP_TO_TOP,resizeToFit:!1,targetBox:{xLeft:null,xRight:null,yAbove:-3,yBelow:i.$container.outerHeight()+3}};if(i.tagsTreeView&&!i.tagsTreeViewCallout&&(i.tagsTreeViewCallout=new e.UI.Controls.PositionedControl(i.$tagsTreeViewCallout.get(0),a)),i.tagsTreeView&&i.tagsTreeViewVisible){var o=this._setTagsTreeViewSize(t);o.hide?this._hideTreeView():(a.preferredPosition=o.position,a.allowedPositions.push(o.position),i.tagsTreeViewCalloutPosition=o.position,i.tagsTreeViewCallout.update(a),this._updateTagsTreeViewScrollableArea())}},o.prototype._onAssistButttonPropertyChange=function(i){var a=this,o=this.properties,r=o.options,s=o.$input.val(),n=r.tagsTreeView||null,l={load:n.load,sortOrder:n.sortOrder,forceReload:n.forceReload,activeNodeIdPath:\"\",renderDataIdAttribute:!1,canDeselect:!1,isSelected:function(e){return a._nodeIsSelected(e)}},p=this;if(\"state\"===i.data.property)if(i.data.value!==e.UI.Controls.ButtonToggleState.ON||o.tagsTreeViewVisible)o.tagsTreeViewVisible&&this._hideTreeView();else{if(this.focus(),\"function\"==typeof l.forceReload&&(l.forceReload=r.tagsTreeView.forceReload()),o.tagsTreeView)l.query!==s&&(l.query=s,o.tagsTreeView.update(l)),o.tagsTreeView.show();else{var d=o.$tagsTreeViewCallout=e.jQuery(\"\").addClass(\"sdl-labelmanager sdl-labelmanager-tree\");e.UI.Core.Utils.Version.addVersionCssClass(d[0]),d.appendTo(document.body);var u=e.jQuery(\"\").prependTo(d);\"function\"==typeof n.getSelectableNodesCount&&(o.$tagsTreeViewTopBarElement=e.jQuery('').prependTo(d)),l.query=s,o.tagsTreeView=new t.TagsTreeView(u.get(0),l);var g=o.tagsTreeView.isLoading();g||this._onTagsTreeViewLoaded(),this._setTopbarMessage(s,g),d.on(\"keydown.labelmanager\",function(e){p._treeViewOnKeyDown(e)}),o.tagsTreeView.addEventListener(\"topnodereached\",this.getDelegate(this._onTopNodeReached)),o.tagsTreeView.addEventListener(\"nodeselected\",this.getDelegate(this._onNodeSelected)),o.tagsTreeView.addEventListener(\"loading\",this.getDelegate(this._onTagsTreeViewLoading)),o.tagsTreeView.addEventListener(\"loaded\",this.getDelegate(this._onTagsTreeViewLoaded))}o.typeahead.disable(),o.tagsTreeViewVisible=!0,this._positionFilteredTreeView(),o.tagsTreeViewCallout.show(),o.keyUpHandler&&o.$input.off(\"keyup.labelmanager\",o.keyUpHandler),o.keyUpHandler=function(e){o.tagsTreeView&&o.tagsTreeViewVisible&&(l.query=o.$input.val(),o.tagsTreeView.update(l))},o.$input.on(\"keyup.labelmanager\",o.keyUpHandler),this.fireEvent(\"tagstreeviewcalloutshown\")}},o.prototype._clearInput=function(){var e=this.properties;e.typeahead.disable(),e.$input.val(\"\"),e.typeahead.enable()},o.prototype._setTagsTreeViewSize=function(i){void 0===i&&(i=!0);var a=t.PositionedControlPosition.BELOW,o=!1,r=this.properties,s=10,n=e.jQuery(window).height(),l=e.jQuery(window).width(),p=r.$container.outerHeight(),d=r.$container.offset(),u=d.top,g=d.left;r.options.scrollContainer===document.body&&(u-=e.jQuery(window).scrollTop(),g-=e.jQuery(window).scrollLeft());var c,h,T=n-(u+p),v=u;c=l-g-s,T>v&&i||!i&&r.tagsTreeViewCalloutPosition===t.PositionedControlPosition.BELOW?(h=T-s,a=t.PositionedControlPosition.BELOW):(h=v-s,a=t.PositionedControlPosition.ABOVE);var y=r.$tagsTreeViewCallout.css(\"max-width\");if(y.indexOf(\"%\")===-1){var f=parseInt(y,10);\"undefined\"!=typeof f&&fc&&(o=!0)}var C=r.$tagsTreeViewCallout.css(\"min-height\");if(C.indexOf(\"%\")===-1){var _=parseInt(C,10);\"number\"==typeof _&&_>h&&(o=!0)}return T>=h&&i&&(a=t.PositionedControlPosition.BELOW),r.$tagsTreeViewCallout.height(h).width(c),{position:a,hide:o}},o.prototype._handleFocusOut=function(t){var i=t.data,a=this.properties;if(i.reason===e.UI.Core.Controls.FocusOutReason.Scroll||i.reason===e.UI.Core.Controls.FocusOutReason.Resize)a.tagsTreeViewVisible&&this._hideTreeView();else if(a.tagsTreeView&&a.tagsTreeViewVisible){var o=i.toElement,r=e.jQuery(a.tagsTreeView.getElement()),s=r.find(o);0!==s.length||r.is(e.jQuery(o))||this._hideTreeView()}},o.prototype._updateTagsTreeViewScrollableArea=function(){for(var t=this.properties,i=t.$tagsTreeViewCallout.outerHeight(),a=0,o=t.$tagsTreeViewCallout.children(),r=0,s=o.length;r
\").text(i).addClass(\"sdl-typeahead-empty\");return a[0].outerHTML},o.prototype._nodeIsSelected=function(e){var t=!1;return this.properties.tagsList.forEach(function(i){i.id===e.id&&(t=!0)}),t},o.prototype._onTagsTreeViewLoading=function(e){this._setTopbarMessage(this.properties.$input.val(),!0)},o.prototype._onTagsTreeViewLoaded=function(e){this._setTopbarMessage(this.properties.$input.val(),!1),this.fireEvent(\"tagstreeviewloaded\")},o.prototype._onTypeahaedLoading=function(t){var i=this.properties.typeahead,a=i.getDropdownElement(),o=this.properties,r=o.$container.outerWidth();if(o.assistButton){var s=o.$containerWrapper.outerWidth();r===s&&(r-=e.jQuery(o.assistButton.getElement()).outerWidth(!0))}var n=o.$input.parent().position().left,l=r-n;l<100&&(l=100),a.css({\"max-width\":l,width:l}).data(\"sdl-labelmanager-width\",l)},o.prototype._onTypeahaedLoaded=function(e){var t=this.properties.typeahead,i=t.getDropdownElement(),a=i.data(\"sdl-labelmanager-width\");i.css({\"max-width\":a,width:a})},o.prototype._getTagElements=function(){return e.jQuery(\".tag\",this.properties.$container)},o._keyCombinationInList=function(e,t){for(var i=!1,a=0,o=t;ae?this.scrollHeight=e:this.scrollHeight=this.virtualScrollHeight,this.maxScrollTop=this.scrollHeight-this.element.clientHeight,this.virtualScrollTopMultiplier=this.maxVirtualScrollTop/this.maxScrollTop,this.virtualScrollTop=0,this.previousScrollTop=0,this.element.innerHTML='',this.visibleCellCount=Math.min(Math.ceil(this.element.clientHeight/this.cellHeight)+1,this.items.length),this.createCells(),this._addEventListeners(),this.onScroll()}},e.prototype.update=function(e){this.dispose(),this.contentRenderer=e.contentRenderer,this.items=e.items,this.init()},e.prototype._addEventListeners=function(){this.eventCoordinator=new t(this),this.eventCoordinator.register(this.element,\"scroll\",this.onScroll),this.eventCoordinator.register(window,\"resize\",function(){this.dispose(),this.init()}),this.rowSelectionEnabled&&(this.eventCoordinator.register(this.element,\"keydown\",this.keyHandler),this.eventCoordinator.register(this.element,\"click\",this.itemClickHandler.bind(this)))},e.prototype._removeEventListeners=function(){this.eventCoordinator&&this.eventCoordinator.dispose()},e.prototype.dispose=function(){this._removeEventListeners(),this.element.removeAttribute(\"style\"),this.element.classList.remove(\"sdl-virtual-list\"),SDL.UI.Core.Utils.Version.removeVersionCssClass(this.element),this.element.innerHTML=\"\"},e.prototype.getDisposed=function(){return this._isDisposed},e.prototype.getTypeName=function(){return\"SDL.UI.Controls.VirtualList\"},e.prototype.render=function(e){\"function\"==typeof e&&e()},e.prototype.getVisibleCellCount=function(){return Math.ceil(this.element.clientHeight/this.items.length)},e.prototype.onScroll=function(){this.virtualScrollTop=Math.round(this.element.scrollTop*this.virtualScrollTopMultiplier),this.renderVisibleCells()},e.prototype.renderVisibleCells=function(){var e,t=Math.floor(this.virtualScrollTop/this.cellHeight);e=this.virtualScrollTop===this.maxVirtualScrollTop&&1!==this.virtualScrollTopMultiplier?this.maxScrollTop-this.cellHeight*(this.visibleCellCount-1)+this.element.clientHeight:Math.round(t*this.cellHeight/this.virtualScrollTopMultiplier);for(var i=0;i-1&&s0?(i.hasFocus=!1,this.items[t-1].hasFocus=!0,s=this.scrollIntoView(this.items[t-1])):(i&&(i.hasFocus=!1),this.items[this.items.length-1].hasFocus=!0,s=this.scrollIntoView(this.items[this.items.length-1]));break;case 40:t>=0&&t-1){var i=t*this.cellHeight-this.element.getBoundingClientRect().height+this.cellHeight+2,s=t*this.cellHeight;if(this.element.scrollTops)return this.element.scrollTop=s,!0}return!1},e.prototype.itemClickHandler=function(e){for(var t=e.target;!t.classList.contains(\"cell\")&&t!==this.element;)t=t.parentNode;if(t!==this.element){var i=t.virtualListItem,s=this.items.filter(function(e){return e.selected})[0];s&&(s.selected=!1),i.selected=!0,this.renderVisibleCells(),this.onSelectionCallback&&this.onSelectionCallback(e,i)}};var t=function(e){this.context=e,this.registeredEventListeners=[]};t.prototype.register=function(e,t,i,s){var l={element:e,type:t,listener:i.bind(this.context),useCapture:s};this.registeredEventListeners.push(l),l.element.addEventListener(l.type,l.listener,l.useCapture)},t.prototype.dispose=function(){for(var e;this.registeredEventListeners.length>0;)e=this.registeredEventListeners.pop(),e.element.removeEventListener(e.type,e.listener,e.useCapture)},SDL=SDL||{},SDL.UI=SDL.UI||{},SDL.UI.Controls=SDL.UI.Controls||{},SDL.UI.Controls.VirtualList=e}();var SDL;!function(){var t=function(t,i){i=i||{},this._isDisposed=!1;var s=0;if(window.requestAnimationFrame||(window.requestAnimationFrame=function(t){var e=(new Date).getTime(),i=Math.max(0,16-(e-s)),r=window.setTimeout(function(){t(e+i)},i);return s=e+i,r}),!i.resources)throw new Error(\"LibraryPanel: no resources object provided via the control options.\");this.resourcesOptions={culture:i.resources.culture,getTranslation:i.resources.getTranslation},this.resources={},this._setResources(),this.eventCoordinator=new e(this),this.element=t,this.previousData=[],this.previouslySelectedItems=[],this.onSelectionCallback=i.onSelectionCallback,this.rawData=[],this.rootName=i.rootName||\"\",this.onCloseCallback=i.onClose,this.isClosable=i.isClosable,this.panelWidth=this.element.offsetWidth||parseInt(window.getComputedStyle(this.element).width),t.classList.add(\"sdl-library-selector\"),SDL.UI.Core.Utils.Version.addVersionCssClass(t),this._createHeaderHTML(t,i.title),this.mainListContainer=this._createBodyHTML(t,i.subTitle||this.resources.selectItem),this.virtualList=new SDL.UI.Controls.VirtualList(this.mainListContainer,{contentRenderer:this.renderListItem.bind(this),items:[],cellHeight:this.CELL_HEIGHT,enableRowSelection:!0,onSelectionCallback:this._virtualListSelection.bind(this)});var r=this.mainContainer.parentElement.querySelector(\"header .search-button\");if(this.eventCoordinator.register(r,\"click\",this.toggleSearchBar),this.searchButton=new SDL.UI.Controls.Button(r,{iconClass:{light:\"small search mono-bright\",dark:\"small search mono-dark\"},purpose:\"general\",style:\"icon\"}),this.isClosable){var n=this.mainContainer.parentElement.querySelector(\"header .close-button\");this.eventCoordinator.register(n,\"click\",this._closeButtonHandler),this.closeButton=new SDL.UI.Controls.Button(n,{iconClass:{light:\"small close mono-bright\",dark:\"small close mono-dark\"},purpose:\"general\",style:\"icon\"})}var a=this.mainContainer.querySelector(\".back-button\");this.eventCoordinator.register(a,\"click\",this._backClickHandler),this.backButton=new SDL.UI.Controls.Button(a,{iconClass:{light:\"small back mono-bright\",dark:\"small back mono-dark\"},purpose:\"general\"});var o=this.mainContainer.querySelector(\".heirarchy-button\");this.eventCoordinator.register(o,\"click\",this._toggleHeirarchyMenu),this.eventCoordinator.register(o,\"blur\",function(t){this.heirarchyList.offsetParent&&t.relatedTarget&&this._toggleHeirarchyMenu()}),this.heirarchyButton=new SDL.UI.Controls.Button(o,{iconClass:{light:\"heirarchy-button\",dark:\"heirarchy-button\"},purpose:\"general\",style:\"icon\"});var l=this.mainContainer.querySelector(\"button.confirmation\");this.eventCoordinator.register(l,\"click\",this._itemSelectConfirmation),this.confirmationButton=new SDL.UI.Controls.Button(l,{purpose:\"confirm\",disabled:!0}),this.eventCoordinator.register(t,\"keydown\",this._keyHandler),this.eventCoordinator.register(t,\"click\",this._closeOpenedMenu),this.eventCoordinator.register(this.heirarchyList,\"click\",this._heirarchyListClickHandler),this.update(i)};t.prototype.getTypeName=function(){return\"SDL.UI.Controls.LibraryPanel\"},t.prototype.render=function(t){\"function\"==typeof t&&t()},t.prototype.update=function(t){t.resources&&t.resources.culture!==this.resourcesOptions.culture&&(this.resourcesOptions={culture:t.resources.culture,getTranslation:t.resources.getTranslation},this._setResources()),this.selectedItemId=t.data.selectedItemId,this.rootName=t.rootName,this._findSelectedItemLevelData(t.data),this.currentData&&this.virtualList.update({contentRenderer:this.renderListItem.bind(this),items:this.currentData,cellHeight:this.CELL_HEIGHT})};var e=function(t){this.context=t,this.registeredEventListeners=[]};e.prototype.register=function(t,e,i,s){var r={element:t,type:e,listener:i.bind(this.context),useCapture:s};this.registeredEventListeners.push(r),r.element.addEventListener(r.type,r.listener,r.useCapture)},e.prototype.dispose=function(){for(var t;this.registeredEventListeners.length>0;)t=this.registeredEventListeners.pop(),t.element.removeEventListener(t.type,t.listener,t.useCapture)},t.prototype.dispose=function(){this.eventCoordinator.dispose(),this.closeButton&&this.closeButton.dispose(),this.searchButton.dispose(),this.searchActionButton.dispose(),this.backButton.dispose(),this.heirarchyButton.dispose(),this.confirmationButton.dispose(),this.element.classList.remove(\"sdl-library-selector\"),SDL.UI.Core.Utils.Version.removeVersionCssClass(this.element);for(var t=0;length=this.element.children.length;t++)this.element.removeChild(this.element.children[0]);this._isDisposed=!0},t.prototype.getDisposed=function(){return this._isDisposed},t.prototype._findSelectedItemLevelData=function(t){this.previousData.length=0,this.heirarchyList.querySelector(\"ul\").innerHTML=\"\",this._getLevelItems(t,this.rootName),0===this.previousData.length&&(this.backButton.disable(),this.heirarchyButton.disable(),this.mainContainer.querySelector(\".current-level\").innerHTML=this.rootName)},t.prototype._getLevelItems=function(t,e){var i=[],s=!1,r=!0;this.mainContainer.querySelector(\".current-level\").innerHTML=e;for(var n=0;n0&&(this._addToHeirarchy({name:e}),this.mainContainer.querySelector(\".button-ribbon > i\").setAttribute(\"data-type\",t[n].dataType||\"\"),this.backButton.enable(),r=!1,this.previousData.push(i),this._getLevelItems(t[n].children,t[n].name)),t[n].isSelected&&(s=!0);(s||r)&&(this.currentData=i)},t.prototype._createHeaderHTML=function(t,e){var i=document.createElement(\"header\"),s=\"\"+e+'';this.isClosable&&(s+=''),s+=\"
\",i.innerHTML=s,t.appendChild(i)},t.prototype._createBodyHTML=function(t,e){this.mainContainer=document.createElement(\"div\"),this.mainContainer.classList.add(\"main-container\"),this.mainContainer.innerHTML=''+e+'
',this.searchBar=this.mainContainer.querySelector(\".search-row\"),this.searchActionButton=this.searchBar.querySelector(\"button\"),this.eventCoordinator.register(this.searchActionButton,\"click\",this._executeSearch),this.searchActionButton=new SDL.UI.Controls.Button(this.searchActionButton,{purpose:\"general\",style:\"default\"});var i=document.createElement(\"div\");return i.setAttribute(\"tabIndex\",0),i.innerHTML=\"\",i.classList.add(\"main-list\"),this.mainContainer.appendChild(i),this.previousListContainer=document.createElement(\"div\"),this.previousListContainer.innerHTML=\"\",this.previousListContainer.classList.add(\"previous-list\"),this.previousListContainer.style.left=-this.panelWidth+\"px\",this.mainContainer.appendChild(this.previousListContainer),this.heirarchyList=document.createElement(\"div\"),this.heirarchyList.style.display=\"none\",this.heirarchyList.classList.add(\"heirarchy-list\"),this.heirarchyList.innerHTML='',this.mainContainer.appendChild(this.heirarchyList),t.appendChild(this.mainContainer),i},t.prototype._renderList=function(t,e){for(var i=e.querySelector(\"ul\"),s=\"\",r=0;r'+t[r].name+\"\",t[r].isSelectable&&(s+=''),s+=\"
\",t[r].isSelectable?t[r].isDrillable&&(s+=''):s+='',s+=\"\";i.innerHTML=s},t.prototype.renderListItem=function(t){var e=''+t.name+\"\",t.isSelectable&&(e+=''),e+=\"
\",t.isSelectable?t.isDrillable&&(e+='
'):e+='
',e+=\"
\"},t.prototype.selectItemById=function(t,e){var i=this.mainListContainer.querySelector('[data-id=\"'+t+'\"]');i&&this._selectItemById(i,t,e)},t.prototype._selectItemById=function(t,e,i){for(var s=null,r=0;r0?e._addToHeirarchy(e.previouslySelectedItems[e.previouslySelectedItems.length-1]):e._addToHeirarchy({name:e.rootName}),e.previouslySelectedItems.push(t)})},1))},t.prototype._addToHeirarchy=function(t){var e=document.createElement(\"li\");e.innerHTML=''+t.name+\"\",this.heirarchyList.querySelector(\"ul\").appendChild(e)},t.prototype._backClickHandler=function(){var t=this;if(\"none\"!==this.searchBar.style.display)return this.searchBar.querySelector(\"input\").value=\"\",this._executeSearch(),void this.toggleSearchBar();if(this.previousData.length>0){this.currentData=this.previousData.pop(),this._renderList(this.currentData,this.previousListContainer),window.requestAnimationFrame(function(){t.previousListContainer.classList.add(\"transit-back\"),t.previousListContainer.style.left=0,t.mainListContainer.classList.add(\"transit-back\"),t.mainListContainer.style.left=t.panelWidth+\"px\"}),this.confirmationButton.disable();var e=this.heirarchyList.querySelector(\"ul\"),i=function(){t.virtualList.update({contentRenderer:t.renderListItem.bind(t),items:t.currentData,cellHeight:t.CELL_HEIGHT}),t.mainListContainer.classList.remove(\"transit-back\"),t.mainListContainer.style.left=0,t.previousListContainer.classList.remove(\"transit-back\"),t.previousListContainer.style.left=-t.panelWidth+\"px\",e.children.length>0?(t.previouslySelectedItems.pop(),t.mainContainer.querySelector(\".current-level\").innerHTML=e.lastChild.querySelector(\"span\").innerHTML,t.mainContainer.querySelector(\".button-ribbon > i\").setAttribute(\"data-type\",e.lastChild.querySelector(\"i\").getAttribute(\"data-type\")),e.removeChild(e.lastChild)):(t.mainContainer.querySelector(\".current-level\").innerHTML=t.rootName,t.mainContainer.querySelector(\".button-ribbon > i\").setAttribute(\"data-type\",\"\")),0===e.children.length&&(t.backButton.disable(),t.heirarchyButton.disable()),t.mainListContainer.removeEventListener(\"transitionend\",i)};this.mainListContainer.addEventListener(\"transitionend\",i)}},t.prototype._toggleHeirarchyMenu=function(){if(null===this.heirarchyList.offsetParent&&this.heirarchyList.querySelector(\"ul\").children.length>0)this.heirarchyList.style.display=\"block\";else{var t=this.heirarchyList.querySelector(\"li.focused\");t&&t.classList.remove(\"focused\"),this.heirarchyList.style.display=\"none\"}},t.prototype._heirarchyListClickHandler=function(t){for(var e=t.target;\"LI\"!==e.tagName;)e=e.parentElement;for(var i=Array.prototype.indexOf.call(e.parentElement.childNodes,e),s=this.heirarchyList.querySelector(\"ul\"),r=this.previousData.length;r>i;r--)this.currentData=this.previousData.pop(),s.children.length>0&&(s.removeChild(s.lastChild),this.previouslySelectedItems.pop());this.confirmationButton.disable(),this._renderList(this.currentData,this.previousListContainer);var n=this,a=function(){n.virtualList.update({contentRenderer:n.renderListItem.bind(n),items:n.currentData,cellHeight:n.CELL_HEIGHT}),n.mainListContainer.classList.remove(\"transit-back\"),n.mainListContainer.style.left=0,n.previousListContainer.classList.remove(\"transit-back\"),n.previousListContainer.style.left=-n.panelWidth+\"px\";var t=s.lastChild;t?(n.mainContainer.querySelector(\".current-level\").innerHTML=t.querySelector(\"span\").innerHTML,n.mainContainer.querySelector(\".button-ribbon > i\").setAttribute(\"data-type\",t.querySelector(\"i\").getAttribute(\"data-type\"))):(n.mainContainer.querySelector(\".current-level\").innerHTML=n.rootName,n.mainContainer.querySelector(\".button-ribbon > i\").setAttribute(\"data-type\",\"\")),n.mainListContainer.removeEventListener(\"transitionend\",a),0===s.children.length&&(n.backButton.disable(),n.heirarchyButton.disable())};this.previousListContainer.classList.add(\"transit-back\"),this.previousListContainer.style.left=0,this.mainListContainer.classList.add(\"transit-back\"),this.mainListContainer.style.left=this.panelWidth+\"px\",this.mainListContainer.addEventListener(\"transitionend\",a)},t.prototype._itemSelectConfirmation=function(){this.onSelectionCallback(this.selectedItem)},t.prototype._closeButtonHandler=function(){this.onCloseCallback&&this.onCloseCallback()},t.prototype.toggleSearchBar=function(){\"none\"===this.searchBar.style.display?(this.searchBar.style.display=\"block\",this.backButton.enable(),this.mainListContainer.classList.add(\"search-open\")):(this.searchBar.style.display=\"none\",this.mainListContainer.classList.remove(\"search-open\"),this.previousData.length<=0&&this.backButton.disable()),this.previousListContainer.style.top=this.mainListContainer.offsetTop+\"px\"},t.prototype._executeSearch=function(){for(var t=this.searchBar.querySelector(\"input\").value.toLowerCase(),e=[],i=0;i-1&&e.push(this.currentData[i]);this.virtualList.update({contentRenderer:this.renderListItem.bind(this),items:e,cellHeight:this.CELL_HEIGHT})},t.prototype._closeOpenedMenu=function(t){var e=t.target,i=this.mainContainer.querySelector(\".heirarchy-button\");i.contains(e)||e===i||(this.heirarchyList.style.display=\"none\")},t.prototype._keyHandler=function(t){var e,i,s=t.keyCode;switch(s){case 36:var r={target:this.heirarchyList.querySelector(\"ul\").firstChild};this._heirarchyListClickHandler(r);break;case 37:t.target!==this.searchBar.querySelector(\"input\")&&this._backClickHandler();break;case 38:this.heirarchyList.offsetParent&&(e=this.heirarchyList.querySelector(\"li.focused\"),e&&e.previousSibling?(e.previousSibling.classList.add(\"focused\"),e.classList.remove(\"focused\")):(this.heirarchyList.querySelector(\"ul\").lastChild.classList.add(\"focused\"),e&&e.classList.remove(\"focused\")));break;case 40:this.heirarchyList.offsetParent&&(e=this.heirarchyList.querySelector(\"li.focused\"),e&&e.nextSibling?(e.nextSibling.classList.add(\"focused\"),e.classList.remove(\"focused\")):(this.heirarchyList.querySelector(\"ul\").firstChild.classList.add(\"focused\"),e&&e.classList.remove(\"focused\")));break;case 13:this.heirarchyList.offsetParent?(e=this.heirarchyList.querySelector(\"li.focused\"),this._heirarchyListClickHandler({target:e}),this._toggleHeirarchyMenu(),t.preventDefault()):t.target===this.searchBar.querySelector(\"input\")&&this._executeSearch();break;case 39:var n=this.mainListContainer.querySelector(\".focused\");n&&t.target!==this.searchBar.querySelector(\"input\")&&(i=parseInt(n.firstElementChild.getAttribute(\"data-id\"),10),this._selectItemById(n,i,!0));break;case 27:var a=this.searchBar.querySelector(\"input\");t.target===a?(a.value=\"\",this._executeSearch(),this.toggleSearchBar()):this._closeButtonHandler()}},t.prototype._virtualListSelection=function(t,e){var i=!1;t.target.classList.contains(\"drill-button\")&&(i=!0);var s=this.mainContainer.querySelector('[data-id=\"'+e.id+'\"]');this._selectItemById(s.firstElementChild,e.id,i),this.mainContainer.querySelector(\".select-row > button\").focus()},t.prototype._setSelectedItemFullPath=function(t){for(var e=\"\",i=0;i\").prependTo(s).text(t.options.title)),t.options.type&&s.addClass(\"sdl-message-\"+t.options.type),s.addClass(\"sdl-message\")},s.prototype.update=function(s){var i=this.properties,o=i.options;s=e.jQuery.extend({},s),t.prototype.update.call(this,s),i.options.title!=o.title&&(i.options.title?(this.$title||(this.$title=e.jQuery(\"\").prependTo(this.$element)),this.$title.text(i.options.title)):this.$title&&(this.$title.remove(),this.$title=null)),i.options.type!=o.type&&(o.type&&this.$element.removeClass(\"sdl-message-\"+o.type),i.options.type&&this.$element.addClass(\"sdl-message-\"+i.options.type))},s.prototype._dispose=function(){this.$element.removeClass(\"sdl-message sdl-message-info sdl-message-question sdl-message-warning sdl-message-error sdl-message-progress sdl-message-goal\"),this.$title&&(this.$title.remove(),this.$title=null),this.$element=null,t.prototype._dispose.call(this)},s}(e.UI.Core.Controls.ControlBase));t.Message=s}(s=t.Controls||(t.Controls={}))}(t=e.UI||(e.UI={}))}(SDL||(SDL={}));var __extends=this&&this.__extends||function(t,o){function i(){this.constructor=t}for(var e in o)o.hasOwnProperty(e)&&(t[e]=o[e]);t.prototype=null===o?Object.create(o):(i.prototype=o.prototype,new i)},SDL;!function(t){var o;!function(o){var i;!function(o){var i=function(o){function i(t){o.call(this,t),this._initialize()}return __extends(i,o),i.prototype.getTypeName=function(){return\"SDL.UI.Controls.RadioButton\"},i.prototype._initialize=function(){var o=this._$elem=t.jQuery(this.properties.element),i=this._input=t.jQuery(\"input[type='radio']\",o).get(0);if(!i)throw new Error('RadioButton control has to contain a child element of type \"input[radio]\".');o.addClass(\"sdl-radiobutton\"),this._$img=t.jQuery(\"\").insertAfter(i)},i.prototype.getInputElement=function(){return this._input},i.prototype._dispose=function(){t.jQuery(this._$elem).removeClass(\"sdl-radiobutton\"),this._$img&&this._$img.remove(),this._$elem=void 0,this._$img=void 0,this._input=void 0,o.prototype._dispose.call(this)},i}(t.UI.Core.Controls.ControlBase);o.RadioButton=i}(i=o.Controls||(o.Controls={}))}(o=t.UI||(t.UI={}))}(SDL||(SDL={}));var __extends=this&&this.__extends||function(e,t){function i(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)},SDL;!function(e){var t;!function(t){var i;!function(t){var i=function(t){function i(e,i){t.call(this,e,i),this._initialize()}return __extends(i,t),i.prototype.getTypeName=function(){return\"SDL.UI.Controls.ResizeTrigger\"},i.prototype._initialize=function(){var t=this.properties.element;e.jQuery(t).addClass(\"sdl-resizetrigger\"),this.scrollTriggers=e.jQuery(\"\").appendTo(t)[0],this.prevWidth=t.offsetWidth,this.prevHeight=t.offsetHeight,this.resetTriggers(),this.executeAfterDelay=(window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(e){return window.setTimeout(e,20)}).bind(window),this.cancelExecuteAfterDelay=(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.clearTimeout).bind(window),this.scrollTriggers.addEventListener(\"scroll\",this.getDelegate(this.onScroll),!0)},i.prototype.resetTriggers=function(){if(!this.resettingTriggers){this.resettingTriggers=!0;var e=this.scrollTriggers.firstElementChild,t=e.firstElementChild;t.style.width=e.offsetWidth+1+\"px\",t.style.height=e.offsetHeight+1+\"px\",e.scrollLeft=e.scrollWidth,e.scrollTop=e.scrollHeight;var i=this.scrollTriggers.lastElementChild;i.scrollLeft=i.scrollWidth,i.scrollTop=i.scrollHeight,this.resettingTriggers=!1}},i.prototype.onScroll=function(e){this.resettingTriggers||(this.afterScrollExecuteRequest&&this.cancelExecuteAfterDelay(this.afterScrollExecuteRequest),this.afterScrollExecuteRequest=this.executeAfterDelay(this.getDelegate(this.onAfterScroll)))},i.prototype.onAfterScroll=function(){this.afterScrollExecuteRequest=null,this.resetTriggers(),this.isSizeChanged()&&(this.prevWidth=this.properties.element.offsetWidth,this.prevHeight=this.properties.element.offsetHeight,this.fireEvent(\"resize\"))},i.prototype.isSizeChanged=function(){return this.properties.element.offsetWidth!=this.prevWidth||this.properties.element.offsetHeight!=this.prevHeight},i.prototype._dispose=function(){e.jQuery(this.properties.element).removeClass(\"sdl-resizetrigger\"),this.scrollTriggers&&(this.scrollTriggers.removeEventListener(\"scroll\",this.removeDelegate(this.onScroll),!0),this.afterScrollExecuteRequest&&this.cancelExecuteAfterDelay(this.afterScrollExecuteRequest),e.jQuery(this.scrollTriggers).remove(),this.scrollTriggers=null),t.prototype._dispose.call(this)},i}(e.UI.Core.Controls.ControlBase);t.ResizeTrigger=i}(i=t.Controls||(t.Controls={}))}(t=e.UI||(e.UI={}))}(SDL||(SDL={}));var __extends=this&&this.__extends||function(t,i){function e(){this.constructor=t}for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n]);t.prototype=null===i?Object.create(i):(e.prototype=i.prototype,new e)},SDL;!function(t){var i;!function(i){var e;!function(i){var e=function(i){function e(t,e){i.call(this,t,e),this._initialize()}return __extends(e,i),e.prototype.getTypeName=function(){return\"SDL.UI.Controls.TextInput\"},e.prototype._initialize=function(){var i=this.properties,e=this._$elem=t.jQuery(i.element),n=i.options=t.jQuery.extend({},i.options),o=e.prop(\"type\");if(\"text\"!=o&&\"email\"!=o&&\"url\"!=o&&\"password\"!=o)throw new Error('TextInput control has to be an element of type \"input[text]\", \"input[email]\", \"input[url]\" or \"input[password]\".');e.addClass(\"sdl-textinput\"),n.invalid=void 0!=n.invalid&&\"true\"==n.invalid.toString(),this._updateInvalidState()},e.prototype.setInvalid=function(t){var i=this.properties.options.invalid;this.properties.options.invalid=t=void 0!=t&&\"true\"==t.toString(),i!=t&&(this._updateInvalidState(),this.fireEvent(\"propertychange\",{property:\"invalid\",value:t}))},e.prototype.isInvalid=function(){return this.properties.options.invalid},e.prototype.update=function(e){if(e){var n=this.properties,o=t.jQuery.extend({},n.options);i.prototype.update.call(this,e),void 0!=e.invalid&&(e.invalid=\"true\"==e.invalid.toString(),o.invalid!==e.invalid&&(this._updateInvalidState(),this.fireEvent(\"propertychange\",{property:\"invalid\",value:e.invalid})))}},e.prototype._updateInvalidState=function(){this.properties.options.invalid?this._$elem.addClass(\"invalid\"):this._$elem.removeClass(\"invalid\")},e.prototype._dispose=function(){this._$elem.removeClass(\"sdl-textinput invalid\"),this._$elem=void 0,i.prototype._dispose.call(this)},e}(t.UI.Core.Controls.ControlBase);i.TextInput=e}(e=i.Controls||(i.Controls={}))}(i=t.UI||(t.UI={}))}(SDL||(SDL={}));{\"controls.search.clearSearchResults\":\"Clear search results\"}var __extends=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},SDL;!function(t){var e;!function(e){var o;!function(o){!function(t){t[t.Implicit=\"Implicit\"]=\"Implicit\",t[t.Explicit=\"Explicit\"]=\"Explicit\"}(o.SearchMode||(o.SearchMode={}));var i=o.SearchMode,r=function(r){function s(t,e){r.call(this,t,e||{}),this._previousQuery=\"\",this._initialize()}return __extends(s,r),s.prototype._initialize=function(){var e=this.properties,o=e.$element=t.jQuery(e.element);e.options=t.jQuery.extend(!0,{searchMode:i.Explicit,placeholder:\"\",debounce:300,showTooltip:!0},e.options),e.searchMode=e.options.searchMode,e.showTooltip=this._boolStringUnionToBool(e.options.showTooltip),e.initialTabIndex=o.attr(\"tabIndex\"),e.tabIndex=e.initialTabIndex||\"0\",e.controls={searchInput:null,searchButton:null,clearButton:null,searchInputTooltip:null,searchButtonTooltip:null,clearButtonTooltip:null},e.options.disabled=null==e.options.disabled?this.isDisabled():\"true\"===e.options.disabled.toString(),o.addClass(\"sdl-search\"),e.$searchInput=this._initSearchInput().appendTo(o),e.$clearButton=this._initClearButton().appendTo(o),e.$searchButton=this._initSearchButton().appendTo(o),this._updateDisabledState(),this._updateFireSearchEventFunction()},s.prototype._boolStringUnionToBool=function(t){return\"string\"==typeof t?\"true\"==t.toString():t},s.prototype.update=function(e){var o=this,i=this.properties,s=t.jQuery.extend({},i.options,{disabled:this.isDisabled()});r.prototype.update.call(this,e),e=i.options=t.jQuery.extend(!0,{},s,i.options);var n=[];if(null!=e.disabled){e.disabled=\"true\"===e.disabled.toString();var a=null==s.disabled||s.disabled!==e.disabled;a&&(this._updateDisabledState(),n.push(\"disabled\"))}var p=i.showTooltip=this._boolStringUnionToBool(i.options.showTooltip),l=s.showTooltip!==p;l&&(this._updateTooltips(i.showTooltip),n.push(\"showTooltip\"));var c=s.placeholder!==e.placeholder;c&&(i.$searchInput.attr(\"placeholder\",e.placeholder),this._updateTooltipMessage(e.placeholder),n.push(\"placeholder\"));var h=s.searchMode!==e.searchMode;h&&(this._changeMode(e.searchMode),n.push(\"searchMode\"));var u=s.debounce!==e.debounce;u&&(i.options.debounce=e.debounce,this._updateFireSearchEventFunction(),n.push(\"debounce\")),n.forEach(function(t){o.fireEvent(\"propertychange\",{property:t,value:e[t]})})},s.prototype._initSearchInput=function(){var e=this.properties,o=e.options.placeholder,i=t.jQuery(\"\");return i[0].setAttribute(\"placeholder\",o),e.controls.searchInput=new t.UI.Controls.TextInput(i[0]),i.on(\"keyup\",this.getDelegate(this._onSearchQueryKeyUp)),i.on(\"input\",this.getDelegate(this._onSearchQueryInput)),o&&this._initTooltip(i,\"searchInputTooltip\",o),i},s.prototype._initClearButton=function(){var e=this.properties,o=t.jQuery(\"\");return e.searchMode===i.Implicit&&o.addClass(\"sdl-clear-button-implicit\"),o.on(\"click\",this.getDelegate(this._onClearButtonClick)),o.on(\"focus\",this.getDelegate(this._onClearButtonFocus)),o.on(\"blur\",this.getDelegate(this._onClearButtonBlur)),this._showButton(o,!1),this._initTooltip(o,\"clearButtonTooltip\",e.options.resources.getTranslation(\"controls.search.clearSearchResults\")),o},s.prototype._initSearchButton=function(){var t=this.properties,e=t.searchMode===i.Explicit?this._initExplicitSearchButton():this._initImplicitSearchButton();return e.addClass(\"sdl-search-button\"),e},s.prototype._initExplicitSearchButton=function(){var e=this.properties,i=t.jQuery(\"\"),r={iconClass:{dark:\"icon-search-16-mono-dark\",light:\"\"},purpose:o.ButtonPurpose.GENERAL,style:o.ButtonStyle.ICON,state:o.ButtonToggleState.OFF,disabled:!1},s=e.controls.searchButton;s&&s.dispose(),e.controls.searchButton=new t.UI.Controls.Button(i[0],r),i.on(\"click\",this.getDelegate(this._onSearchButtonClick));var n=e.controls.searchButtonTooltip;return n&&(n.dispose(),e.controls.searchButtonTooltip=null),e.options.placeholder&&this._initTooltip(i,\"searchButtonTooltip\",e.options.placeholder),i},s.prototype._initImplicitSearchButton=function(){return t.jQuery(\"\")},s.prototype._changeMode=function(t){var e=this.properties;e.searchMode=t,t===i.Implicit?(e.$searchInput.addClass(\"sdl-search-field-implicit\"),e.$clearButton.addClass(\"sdl-clear-button-implicit\")):(e.$searchInput.removeClass(\"sdl-search-field-implicit\"),e.$clearButton.removeClass(\"sdl-clear-button-implicit\"));var o=this._initSearchButton();e.$searchButton.replaceWith(o),e.$searchButton=o;var r=!e.$searchInput.val();this._showSearchButton(r),this._updateDisabledState(),this._updateFireSearchEventFunction()},s.prototype._initTooltips=function(){var t=this.properties;t.showTooltip&&(t.options.placeholder&&(this._initTooltip(t.$searchInput,\"searchInputTooltip\",t.options.placeholder),this._initTooltip(t.$searchButton,\"searchButtonTooltip\",t.options.placeholder)),this._initTooltip(t.$clearButton,\"clearButtonTooltip\",t.options.resources.getTranslation(\"controls.search.clearSearchResults\")))},s.prototype._disposeTooltips=function(){var t=this.properties.controls;t.searchInputTooltip.dispose(),t.searchButtonTooltip.dispose(),t.clearButtonTooltip.dispose()},s.prototype._initTooltip=function(e,i,r){var s=this.properties;if(s.showTooltip){var n={relativeTo:o.TooltipRelativeTo.Mouse,position:o.TooltipPosition.Bottom,showIfNoOverflow:!0,offsetX:0,offsetY:0,delay:500,content:r};s.controls[i]=new t.UI.Controls.Tooltip(e[0],n)}},s.prototype._updateTooltips=function(t){t?this._initTooltips():this._disposeTooltips()},s.prototype._updateTooltipMessage=function(t){var e=this.properties;e.showTooltip&&(this._updateTooltipMessageOnControl(e.$searchInput,\"searchInputTooltip\",t),this._updateTooltipMessageOnControl(e.$searchButton,\"searchButtonTooltip\",t))},s.prototype._updateTooltipMessageOnControl=function(t,e,o){var i=this.properties.controls[e];o?!i||i.getDisposed()?this._initTooltip(t,e,o):i.update({content:o}):i&&i.dispose()},s.prototype._onSearchButtonClick=function(){var t=this.properties;t.searchQuery=t.$searchInput.val(),this._fireSearchEventWithDebounce(t.searchQuery),t.searchQuery&&this._setAppliedState(!0)},s.prototype._onSearchQueryKeyUp=function(t){t.which===e.Core.Event.Constants.Keys.ESCAPE&&this._clearSearch(),t.which===e.Core.Event.Constants.Keys.ENTER&&this._onSearchQueryChanged(!0)},s.prototype._onSearchQueryInput=function(){this._onSearchQueryChanged(!1)},s.prototype._onSearchQueryChanged=function(t){var e=this.properties;e.searchQuery=e.$searchInput.val();var o=!Boolean(e.searchQuery);e.searchMode===i.Implicit||t?(this._fireSearchEventWithDebounce(e.searchQuery),this._setAppliedState(!o)):this._setAppliedState(!1),this._showClearButton(!o),this._showSearchButton(o)},s.prototype._onClearButtonFocus=function(){this.properties.$searchInput.addClass(\"sdl-search-field-focused\")},s.prototype._onClearButtonBlur=function(){this.properties.$searchInput.removeClass(\"sdl-search-field-focused\")},s.prototype._onClearButtonClick=function(){this._clearSearch(),this.properties.$searchInput.focus()},s.prototype._clearSearch=function(){this._clearInput(),this._showClearButton(!1),this._showSearchButton(!0),this._setAppliedState(!1),this._previousQuery=\"\",this._fireClearEvent()},s.prototype._clearInput=function(){this.properties.$searchInput.val(\"\")},s.prototype._showClearButton=function(t){this._showButton(this.properties.$clearButton,t)},s.prototype._showSearchButton=function(t){var e=this.properties;e.searchMode===i.Implicit&&this._showButton(e.$searchButton,t)},s.prototype._showButton=function(t,e){e?t.css(\"visibility\",\"visible\"):t.css(\"visibility\",\"hidden\")},s.prototype._setAppliedState=function(t){var e=this.properties.$searchInput;t?e.addClass(\"sdl-search-field-applied\"):e.removeClass(\"sdl-search-field-applied\")},s.prototype._fireSearchEvent=function(t){this._previousQuery!==t&&(this.fireEvent(\"search\",{searchQuery:t}),this._previousQuery=t)},s.prototype._fireClearEvent=function(){this.fireEvent(\"clear\")},s.prototype.disable=function(){this.isDisabled()||this._changeDisableState(!0)},s.prototype.enable=function(){this.isDisabled()&&this._changeDisableState(!1)},s.prototype.isDisabled=function(){return!!this.properties.$element.attr(\"disabled\")},s.prototype._changeDisableState=function(t){this.properties.options.disabled=t,this._updateDisabledState(),this.fireEvent(\"propertychange\",{property:\"disabled\",value:t})},s.prototype._updateDisabledState=function(){var t=this.properties;if(t.options.disabled)t.tabIndex=t.$element.attr(\"tabIndex\")||\"0\",t.$element.attr(\"disabled\",\"true\"),t.$searchInput.attr(\"disabled\",\"true\").removeAttr(\"tabIndex\"),t.$clearButton.attr(\"disabled\",\"true\").removeAttr(\"tabIndex\"),t.$searchButton.attr(\"disabled\",\"true\").removeAttr(\"tabIndex\"),t.searchMode===i.Explicit&&t.controls.searchButton.disable();else{var e=Number(t.tabIndex);t.$element.removeAttr(\"disabled\"),t.$searchInput.removeAttr(\"disabled\").attr(\"tabIndex\",e),t.$clearButton.removeAttr(\"disabled\").attr(\"tabIndex\",e),t.$searchButton.removeAttr(\"disabled\").attr(\"tabIndex\",e),t.$searchButton.attr(\"tabIndex\",e),t.searchMode===i.Explicit&&t.controls.searchButton.enable()}},s.prototype._updateFireSearchEventFunction=function(){var e=this.properties,o=e.options.debounce,r=e.options.searchMode;r==i.Implicit&&o>0?this._fireSearchEventWithDebounce=t.Client.Types.Function.debounce(this._fireSearchEvent,o):this._fireSearchEventWithDebounce=t.Client.Types.Function.debounce(this._fireSearchEvent,o,!0)},s.prototype.getTypeName=function(){return\"SDL.UI.Controls.Search\"},s.prototype._dispose=function(){var t=this.properties;t.timeout&&clearTimeout(t.timeout),t.$clearButton.off(\"click\",this._onClearButtonClick),t.$clearButton.off(\"focus\",this._onClearButtonFocus),t.$clearButton.off(\"blur\",this._onClearButtonBlur),t.$searchInput.off(\"keyup\",this._onSearchQueryKeyUp),t.$searchInput.off(\"input\",this._onSearchQueryInput),t.$searchButton.off(\"click\",this._onSearchButtonClick);var e=t.controls;for(var o in e)e.hasOwnProperty(o)&&e[o]&&e[o].dispose();t.$element.removeClass(\"sdl-search\"),t.$searchInput.remove(),t.$searchButton.remove(),t.$clearButton.remove(),t.$element=null,r.prototype._dispose.call(this)},s}(t.UI.Core.Controls.ControlBase);o.Search=r}(o=e.Controls||(e.Controls={}))}(e=t.UI||(t.UI={}))}(SDL||(SDL={}));var __extends=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},SDL;!function(t){var e;!function(e){var o;!function(e){!function(t){t[t.MESSAGES=\"messages\"]=\"MESSAGES\",t[t.WORKFLOWS=\"workflows\"]=\"WORKFLOWS\",t[t.NOTIFICATIONS=\"notifications\"]=\"NOTIFICATIONS\",t[t.USER=\"user\"]=\"USER\",t[t.SEARCH=\"search\"]=\"SEARCH\",t[t.HELP=\"help\"]=\"HELP\",t[t.ACTIVITIES=\"activities\"]=\"ACTIVITIES\",t[t.CLOSE=\"close\"]=\"CLOSE\"}(e.TopBarButton||(e.TopBarButton={}));var o=e.TopBarButton,n=[[o.SEARCH,o.HELP],[o.MESSAGES,o.WORKFLOWS,o.NOTIFICATIONS,o.USER],[o.ACTIVITIES],[o.CLOSE]],s={messages:\"controls.topbar.messages\",workflows:\"controls.topbar.workflows\",notifications:\"controls.topbar.notifications\",search:\"controls.topbar.search\",help:\"controls.topbar.help\",close:\"controls.topbar.close\",logIn:\"controls.topbar.logIn\",activities:\"controls.topbar.activities\"},i=function(i){function r(t,e){i.call(this,t,e),this._initialize()}return __extends(r,i),r.prototype.getTypeName=function(){return\"SDL.UI.Controls.TopBar\"},r.prototype._initialize=function(){var o=this.properties,n=o.$element=t.jQuery(o.element),s=o.options=t.jQuery.extend(!0,{ribbonTabs:[],buttons:{}},o.options);this._setResources(),s.experimental=s.experimental&&\"true\"==s.experimental.toString()||!1,s.hostMode=s.hostMode&&\"true\"==s.hostMode.toString()||!1,s.showBackButton=s.showBackButton&&\"true\"==s.showBackButton.toString()||!1,s.ribbonTabs&&s.ribbonTabs.length?this._hasRibbonTabId(s.selectedRibbonTabId)||(s.selectedRibbonTabId=s.ribbonTabs[0].id):(s.ribbonTabs=[],null==s.selectedRibbonTabId||this._hasRibbonTabId(s.selectedRibbonTabId)||(s.selectedRibbonTabId=null)),s.buttons||(s.buttons={}),s.hostMode||t.jQuery(document.documentElement).addClass(\"sdl-topbar sdl-topbar-page\"),null!=s.paddingLeft&&(o.element.style.paddingLeft=s.paddingLeft+\"px\"),(s.title||s.showBackButton)&&(o.$title=t.jQuery(\"\").appendTo(n).append(t.jQuery(\"\").text(s.title||\"\")),s.showBackButton&&this._addBackButton()),n.addClass(\"sdl-topbar sdl-topbar-control\"),s.experimental&&n.addClass(\"sdl-topbar-experimental\"),o.$ribbonTabsContainer=t.jQuery(\"\").appendTo(n).click(this.getDelegate(this._onRibbonTabClick)),o.$buttonsContainer=t.jQuery(\"\").appendTo(n).click(this.getDelegate(this._onButtonClick)),this._populateButtons(),o.$resizeTrigger=o.$ribbonTabsContainer.children(\".sdl-topbar-resize-trigger\"),o.resizeTriggerControl=new e.ResizeTrigger(o.$resizeTrigger.get(0)),o.$tabsOverflowButton=o.$ribbonTabsContainer.children(\".sdl-topbar-ribbon-overflown-button\"),this._updateButtons(),this._populateRibbonTabs(),this._calculateRibbonTabs(),o.resizeTriggerControl.addEventListener(\"resize\",this.getDelegate(this._onRibbonTabsResize)),s.ribbonTabsFlyoutMenuShown&&o.$ribbonTabsContainer.hasClass(\"sdl-topbar-ribbon-overflown\")&&this._showFlyoutMenu()},r.prototype.update=function(e){var o=this;if(e){var s=this.properties,r=s.options;i.prototype.update.call(this,e),e=s.options=t.jQuery.extend(!0,{},s.options),e.resources?e.resources.culture!==r.resources.culture&&this._setResources():e.resources=r.resources,e.hostMode=e.hostMode&&\"true\"==e.hostMode.toString()||!1,e.showBackButton=e.showBackButton&&\"true\"==e.showBackButton.toString()||!1;var a=[];if(e.hostMode!=r.hostMode&&(e.hostMode?t.jQuery(document.documentElement).removeClass(\"sdl-topbar-page\"):t.jQuery(document.documentElement).addClass(\"sdl-topbar-page\"),a.push(\"hostMode\")),e.paddingLeft!=r.paddingLeft&&(null!=e.paddingLeft?s.element.style.paddingLeft=e.paddingLeft+\"px\":s.element.style.paddingLeft=\"\"),e.title!=r.title||e.showBackButton!=r.showBackButton)if(e.title||e.showBackButton)s.$title?s.$title.children().last().text(e.title||\"\"):s.$title=t.jQuery(\"\").append(t.jQuery(\"\").text(e.title||\"\")).insertBefore(s.element.firstElementChild),s.$backButton?e.showBackButton||(s.$backButton.off(\"click\",this.removeDelegate(this._onNavigateBackClick)).remove(),s.$backButton=null,this.fireEvent(\"propertychange\",{property:\"showBackButton\",value:!1}),this.fireEvent(\"hidebackbutton\")):e.showBackButton&&(this._addBackButton(),this.fireEvent(\"propertychange\",{property:\"showBackButton\",value:!0}),this.fireEvent(\"showbackbutton\"));else{var b=s.$backButton;b&&(s.$backButton.off(\"click\",this.removeDelegate(this._onNavigateBackClick)).remove(),s.$backButton=null),s.$title.remove(),s.$title=null,b&&(this.fireEvent(\"propertychange\",{property:\"showBackButton\",value:!1}),this.fireEvent(\"hidebackbutton\"))}e.ribbonTabs||(e.ribbonTabs=r.ribbonTabs),e.buttons||(e.buttons=r.buttons),e.ribbonTabs.length?this._hasRibbonTabId(e.selectedRibbonTabId)||(e.selectedRibbonTabId=e.ribbonTabs[0].id):null==e.selectedRibbonTabId||this._hasRibbonTabId(e.selectedRibbonTabId)||(e.selectedRibbonTabId=null),e.selectedRibbonTabId!=r.selectedRibbonTabId&&a.push(\"selectedRibbonTabId\"),this._updateButtons(),this._populateRibbonTabs(),this._calculateRibbonTabs(),null!=e.ribbonTabsFlyoutMenuShown&&(e.ribbonTabsFlyoutMenuShown=e.ribbonTabsFlyoutMenuShown&&\"true\"==e.ribbonTabsFlyoutMenuShown.toString()||!1,e.ribbonTabsFlyoutMenuShown?s.$ribbonTabsContainer.hasClass(\"sdl-topbar-ribbon-overflown\")&&this._showFlyoutMenu():this._hideFlyoutMenu());for(var l=0,u=a.length;l \").insertBefore(e.$title.children().first()).click(this.getDelegate(this._onNavigateBackClick))},r.prototype._hasRibbonTabId=function(t){var e=this.properties.options,o=!1;return null!=e.selectedRibbonTabId&&(o=e.ribbonTabs.some(function(t){return t.id===e.selectedRibbonTabId})),o},r.prototype._populateRibbonTabs=function(){var e,o=this.properties,n=this._getRibbonTabs(),s=o.options.ribbonTabs,i=o.options.selectedRibbonTabId,r=s.length;for(e=0;ee?n.eq(e):t.jQuery(\"\").insertBefore(o.$tabsOverflowButton),a.data(\"tab-id\",b.id).text(b.label||\"_\").toggleClass(\"sdl-topbar-ribbon-tab-hidden\",l).toggleClass(\"sdl-topbar-ribbon-tab-selected\",b.id==i)}n.length>r&&n.slice(r).remove(),this._updateFlyoutMenuList()},r.prototype._populateButtons=function(){var e=this;n.forEach(function(n,s){var i=t.jQuery(\"\").appendTo(e.properties.$buttonsContainer);n.forEach(function(e,n){var s=t.jQuery(\"\").addClass(\"sdl-topbar-button-\"+e).appendTo(i);switch(e){case o.MESSAGES:case o.WORKFLOWS:case o.NOTIFICATIONS:s.append(\"\")}})})},r.prototype._updateButtons=function(){var t=this.properties,e=t.options.buttons;n.forEach(function(n,s){var i=!0,r=t.$buttonsContainer.children().eq(s);n.forEach(function(n,s){var a=e[n],b=!a||\"false\"==a.toString()||a.hidden&&\"true\"==a.hidden.toString()||!1,l=a&&a.selected&&\"true\"==a.selected.toString()||!1,u=r.children(\".sdl-topbar-button-\"+n).toggleClass(\"sdl-topbar-button-hidden\",b).toggleClass(\"sdl-topbar-button-selected\",l);if(!b)switch(n){case o.MESSAGES:case o.WORKFLOWS:case o.NOTIFICATIONS:var p=(a.value||0)+\"\",d=p>99?\"99+\":(0|p)==p?p.replace(/^0+/,\"\")||0:p;u.attr(\"title\",t.resources[n]).children(\":last-child\").text(d).toggleClass(\"sdl-topbar-bubble-empty\",\"0\"==d);break;case o.USER:var c=a,h=c.isLoggedIn&&\"true\"==c.isLoggedIn.toString()||!1,f=c.isPicture&&\"true\"==c.isPicture.toString()||!1,v=!!c.pictureUrl;u.attr(\"title\",h?c.userName||null:t.resources.logIn).toggleClass(\"sdl-topbar-button-userloggedin\",!f&&h).toggleClass(\"sdl-topbar-button-userpicture\",f&&v).toggleClass(\"sdl-topbar-button-userdefaultpicture\",f&&!v).children(\":first-child\").css(\"background-image\",f&&v?'url(\"'+encodeURI(c.pictureUrl)+'\")':\"\");break;default:u.attr(\"title\",t.resources[n])}!b&&i&&(i=!1)}),r.toggleClass(\"sdl-topbar-buttongroup-empty\",i)}),t.$element.css(\"paddingRight\",t.$buttonsContainer[0].offsetWidth+30)},r.prototype._onRibbonTabsResize=function(){this._calculateRibbonTabs()},r.prototype._calculateRibbonTabs=function(){var t=this.properties,e=t.$ribbonTabsContainer[0].offsetWidth;if(e<10)this._hideFlyoutMenu();else{var o=t.$ribbonTabsContainer[0].offsetWidth,n=this._getRibbonTabs(),s=n.get().some(function(t){return!o||(o-=t.offsetWidth)<0});if(s){e-=31;var i=this._getSelectedRibbonTab(),r=!1;i.hasClass(\"sdl-topbar-ribbon-overflown-tab\")&&(r=!0,i.removeClass(\"sdl-topbar-ribbon-overflown-tab\")),o=e-i[0].offsetWidth;for(var a=i.prev(),b=!1;a.length&&!a.is(t.$resizeTrigger)&&(r||!a.hasClass(\"sdl-topbar-ribbon-overflown-tab\"));){if(b)a.addClass(\"sdl-topbar-ribbon-overflown-tab\");else{var l=a[0].offsetWidth;l&&(l+=.5),o>=l?(o-=l,a.removeClass(\"sdl-topbar-ribbon-overflown-tab\")):(b=!0,a.addClass(\"sdl-topbar-ribbon-overflown-tab\"))}a=a.prev()}var u=i.next();for(b=!1;u.length&&!u.is(t.$tabsOverflowButton);){if(b)u.addClass(\"sdl-topbar-ribbon-overflown-tab\");else{var l=u[0].offsetWidth;l&&(l+=.5),o>=l?(o-=l,u.removeClass(\"sdl-topbar-ribbon-overflown-tab\")):(b=!0,u.addClass(\"sdl-topbar-ribbon-overflown-tab\"))}u=u.next()}if(o>=0)for(b=!1;a.length&&!a.is(t.$resizeTrigger);){if(b)a.addClass(\"sdl-topbar-ribbon-overflown-tab\");else{var l=a[0].offsetWidth;l&&(l+=.5),o>=l?(o-=l,a.removeClass(\"sdl-topbar-ribbon-overflown-tab\")):(b=!0,a.addClass(\"sdl-topbar-ribbon-overflown-tab\"))}a=a.prev()}t.$ribbonTabsContainer.addClass(\"sdl-topbar-ribbon-overflown\")}else n.removeClass(\"sdl-topbar-ribbon-overflown-tab\"),t.$ribbonTabsContainer.removeClass(\"sdl-topbar-ribbon-overflown\"),this._hideFlyoutMenu()}},r.prototype._onRibbonTabClick=function(e){var o=this.properties;e.target==o.$tabsOverflowButton[0]?o.$tabsOverflowButton.hasClass(\"sdl-topbar-ribbon-overflown-button-pressed\")?this._hideFlyoutMenu():this._showFlyoutMenu():this.selectRibbonTabId(t.jQuery(e.target).data(\"tab-id\"))},r.prototype._onButtonClick=function(e){var s=this.properties;if(s.$buttonsContainer[0].contains(e.target)){var i=t.jQuery(e.target);i[0].className.indexOf(\"sdl-topbar-button\")==-1&&(i=i.parent());for(var r=0,a=n.length;r