var __extends=this&&this.__extends||function(){var n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),AutoSuggest;(function(n){var t;(function(t){function oi(n,t){var r=[],u,f;if(t)if(n)r=t.slice();else{u=function(n){var i=t.find(function(t){return t.verb&&t.verb.toLocaleLowerCase()==n.toLocaleLowerCase()});i&&r.push(i)};for(f in i)u(f)}return r}function si(n){return n?n.filter(function(n){return!n.verb||n.verb.toLowerCase()!="open"}):[]}function e(n,i,r,u,f,e){e()&&(n=n.slice(),i.getExtraVerbsAsync?t.Promise.safeChain("getExtraVerbsAsync",function(){return i.getExtraVerbsAsync(u)},function(t){return s(k(n,t,!0),i,u,f,e)},function(){return s(n,i,u,f,e)},null,r):s(n,i,u,f,e))}function s(n,t,i,r,u){if(u()){var f=t.getExtraVerbs?k(n,t.getExtraVerbs(i),!1):n;f[0]==a&&f.shift();r(f)}}function lt(n,r,u,f){return n.map(function(n){var e,o,s,h;if(n.verb){switch(n.verb.toLocaleLowerCase()){case ht:e="PinnedToStart";break;case p:e="PinnedToTaskbar";break;case ct:e="UnpinnedFromStart";break;case w:e="UnpinnedFromTaskbar";break;case st:o="UninstallConfirmation";e="UninstallationInProgress"}return s=function(t){t();e?u.showTemporaryMessage(f.getLocString(e,HitHighlightingParser.removeMarkers(r.text)),{content:"",type:2}):u.hideTemporaryMessage();n.verb.toLocaleLowerCase()==p&&f.addItemToPinnedToTaskbar(r.deviceItem.id);n.verb.toLocaleLowerCase()==w&&f.removeItemFromPinnedToTaskbar(r.deviceItem.id)},h=n.icon||i[n.verb.toLocaleLowerCase()],new t.DeviceItemVerbWrapper(n,h,function(i){o&&t.DialogBox?t.DialogBox.show(f.getLocString(o),[{id:null,text:n.displayName,action:function(){return s(i)},selected:!1},{id:null,text:f.getLocString("Cancel"),selected:!0}]):s(i)})}return n})}function b(n,i,r,u,f,o){if(t.isJumpListSuggestion(i))return t.Promise.safeChain("jumpListItem.getVerbsAsync",function(){return i.jumpListItem.getVerbsAsync()},function(n){return e(si(n),i,h,u,f,o)},function(){return e([],i,h,u,f,o)},null,n+" "+i.type),!0;var h=n+" "+i.type,c=t.getItemWithFileMetadata(i);return c&&c.canHaveContextMenu?(t.Promise.safeChain("getVerbsAsync",function(){return c.getVerbsAsync()},function(n){return e(oi(r,n),i,h,u,f,o)},function(){return e([],i,h,u,f,o)},null,h),!0):i.getExtraVerbsAsync?(e([],i,h,u,f,o),!0):i.getExtraVerbs?(s([],i,u,f,o),!0):(u&&f([]),!1)}function o(n,i,r){if(i==t.GroupType.EdgeHistory&&!r)return!1;var u=HitHighlightingParser.removeMarkers(n.text),f=u?u.length:0;return n.additionalInfoText&&!r&&(f+=n.additionalInfoText.length),f>(r?fi:ei)}function at(n){for(var i,r={topResults:n.topResults.slice(0),groups:[]},t=0,u=n.groups;t0&&t.length>0){var r=i?n.concat(a):n;return r.concat(t)}return n.length>0?n:t.length>0?i?[a].concat(t):t:[]}function r(n,i){return n.find(function(n){return t.sameGroup(n.typeWithSource,i)})}function yt(n,i){return n.find(function(n){return t.sameGroup(n.group.typeWithSource,i)})}function pt(n,t){return n.queryToFetch.substring(0,t.queryToFetch.lastIndexOf("\\"))}function wt(n,i,r,u,f){var s,o,e,h,c;if(r==t.GroupType.PathCompletion)return s=pt(n,n)+"\\"+String.fromCharCode(8206),{title:s,narratorText:s};if(u&&(o=u.groupDisplayName,o))return{title:o,narratorText:f?i.getLocString("AddingScopeNarratorText",o):o};switch(r){case t.GroupType.Command:e=i.getLocString("CommandGroup");break;case t.GroupType.Cortana:e=i.getLocString("CortanaGroup");break;case t.GroupType.Store:e=i.getLocString("StoreGroup");break;case t.GroupType.PowerBi:e="Power BI";break;case t.GroupType.EdgeHistory:e=i.getLocString("EdgeHistoryGroup");break;case t.GroupType.LocalPlaces:e=i.getLocString("LocalPlacesGroup");break;case t.GroupType.Related:e=i.getLocString("RelatedSuggestionsGroup");break;case t.GroupType.SearchSuggestions:e=t.getWebSuggestionsGroupHeader(i);break;case t.GroupType.Websites:e=t.getWebsitesGroupHeader(i);break;case t.GroupType.Contact:e=i.getLocString("ContactGroup")}if(!e){if(h=t.getScope(r),h==t.Scope.All)throw new Error("Unknown group type: "+r);c=t.ScopeConfig[h];e=t.getScopeDisplayName(c,i)}return{title:e,narratorText:f?i.getLocString("AddingScopeNarratorText",e.toLocaleLowerCase()):e}}var d=4,g=6,h=8,u=12,nt=1,f=20,c=16,kt=f+2*h,tt=16+2*h,dt=tt,it=60,gt=f+2*u,ni=f+c+d+2*u,ti=f+2*(c+d)+2*u,ii=80+2*u,ri=h,rt=f,ui=48,l=1,ut=t.IconSize_GridLayout+2*(g+nt),ft=t.IconSize_GridLayout_Medium+2*(g+nt),et=3,ot=4,fi=39,ei=42,a={},v="runas",y="tabletmode_opennewwindow",st="tile.uninstall",ht="startpin",p="taskbarpin",ct="startunpin",w="taskbarunpin",i={},bt;i[v]={content:"",type:1};i.runasuser={content:"",type:1};i.openinbrowser={content:"",type:1};i.openfilelocation={content:"",type:2};i.opencontaining={content:"",type:2};i[y]={content:"",type:2};i.pintostartscreen={content:"",type:2};i[ct]={content:"",type:1};i[w]={content:"",type:1};i[ht]={content:"",type:2};i[p]={content:"",type:2};i.settings={content:"",type:2};i.manage={content:"",type:1};i.review={content:"",type:2};i.share={content:"",type:1};i.connectnetworkdrive={content:"",type:1};i.disconnectnetworkdrive={content:"",type:1};i.uninstall={content:"",type:2};i[st]={content:"",type:2};i.itemproperties={content:"",type:2};t.extendVerbs=lt;t.getVerbsAsync=b;t.wrapsToTwoLines=o;t.joinVerbs=k;t.getGroupTitleAndNarratorText=wt;bt=function(i){function u(r,u,f,e,o,s,h,c,l){var a=i.call(this,r,f,e,s)||this,v;return a._host=r,a._autoComplete=u,a._navigationHelper=o,a._headerFooterViewModel=h,a._previewPane=c,a._contextMenu=l,a._pendingSubmitSequenceNumber=-1,a._pendingSubmitModifierKeys=null,a._pendingSubmitTimeStamp=null,a._resultsCounter={topResults:[],groups:[]},a._pendingSuggestionsInExistingGroups=[],a._pendingSuggestionsInMissingGroups=[],s.setSuggestionClickHandler(a.doubleClickGuardedHandler(function(t,i){n.safeExecute(function(){return a.click(n.getCurrentTime(),t,n.getInputType(i),null)},"suggestionClickHandler")})),s.setContextMenuHandler(function(t,i){n.safeExecute(function(){return a.showContextMenu(t,i.pageX,i.pageY)},"contextMenuHandler")}),s.setOpenPreviewPaneClickHandler(function(t,i){n.safeExecute(function(){return a.openPreviewPane(t,i)},"openPreviewPaneClickHandler")}),s.setExpanderClickInstrumentation(function(n,t,i,r){var u="Expander"+(r?"Opened":"Closed"),f={si:t,st:i,K:n.instItem.getLayoutKValue()};a._instrumentationHelper.logClientInstEvent("Select",u,null,f)}),a._previewPane&&(a._previewPane.init(a),a._previewPane.bindBeforeItemLaunch(function(n,t,i,r,u){return a._instrumentationHelper.instrumentItemClick(n,t.instItem,t.sequenceNumber,t.instrumentPingBack,i,null,null,r,u)}),a._previewPane.bindAfterItemLaunch(function(n,t,i){return a.onSuggestionLaunch(n,t,i)})),r.bindKeyUp(function(n,t,i){return a.onKeyUp(n,t,i)}),r.bindShown(function(){!t.isMobileCache&&SearchAppWrapper.CortanaApp.queryFormulationView.deviceSearch.getSearchServiceStatusAsync&&t.Promise.safeChain("getSearchServiceStatusAsync",function(){return SearchAppWrapper.CortanaApp.queryFormulationView.deviceSearch.getSearchServiceStatusAsync()},function(n){a._instrumentationHelper.setSearchServiceStatus(li(n));n!=0&&n!=4&&n!=3&&n!=7&&a.showIndexingMessage(!1)})}),r.bindKeyDown(function(i){i=t.getRtlAdjustedKey(i);var r=n.getCurrentActiveElement();t.isScopeTile(r)?((i==39||i==37)&&a._headerFooterViewModel.focusNextScopeTile(r,i==39),t.config.allowUpForScopes&&a._selectedItem&&a.select(a._headerFooterViewModel.getSelectableItems()[0],!1)):t.isOptInBtn(r)&&(i==39||i==37)&&a._headerFooterViewModel.handleOptInOutNavigation(r,i==39)}),r.bindDismissed(function(){a._pendingSuggestionsInExistingGroups=[];a._pendingSuggestionsInMissingGroups=[];a.removeProgressBar();a._contextMenu.dismiss();a._previewPane&&t.previewPaneAvailable&&a._previewPane.dismiss();a._page.hideTemporaryMessage();a.hideIndexingMessage();t.DialogBox&&t.DialogBox.hide();a._headerFooterViewModel.render(null,!1,!1,!1,!0);t.config.glyphInSearchBox&&a._host.setSearchBoxGlyphIcon()}),s.bindOnNarratorLaunch(function(t){for(var i,f=n.getCurrentTime(),e=a.getSelectableItems(),r=0,u=e;r0&&!a._headerFooterViewModel.isScopesL2Visible()&&a._headerFooterViewModel.isScopeElement(a._selectedItem)?a.select(a.topResults[0],a.topResults[0].sequenceNumber==a._sequenceNumberReader.getSequenceNumber()):a.renderSelectedSuggestionState(!1)}),r.bindSearchBoxLostFocus(function(){var i=t.isScopeTile(n.getCurrentActiveElement());i?sb_st(function(){a._host.searchBoxHasFocus()||a._headerFooterViewModel.isScopeElement(a._selectedItem)||a.renderSelectedSuggestionState(!0)},75):a.renderSelectedSuggestionState(!0)})):(v=SearchAppWrapper.CortanaApp.searchBox,v.addEventListener("keydown",function(n){n.keyCode==9&&a._selectedItem&&a.renderSelectedSuggestionState(!0)})),sj_evt.bind("CortanaPaneWidthSet",function(n){return a.onPaneWidthSet(n[1])}),sj_be(_ge("qfContainer"),"scroll",function(){return a._contextMenu.dismiss()}),a}return __extends(u,i),u.prototype.onPaneWidthSet=function(n){ot=Math.floor((n-2*l)/ft);et=Math.floor((n-2*l)/ut)},u.prototype.setSelectedStyleSuspended=function(n,i){n.selectedStyleSuspended=t.qfMode!=3&&i},u.prototype.renderSelectedSuggestionState=function(n){this._selectedItem&&t.qfMode!=3&&(this.setSelectedStyleSuspended(this._selectedItem,n),this.renderSelection(this._selectedItem))},u.prototype.removeProgressBar=function(){t.config.dataSourcesWithProgressBar.length>0&&(this._progressTimer&&(sb_ct(this._progressTimer),this._progressTimer=null),this._page.setProgressIndicatorVisibility(!1))},u.prototype.resetPendingSubmitSequenceNumber=function(){this._pendingSubmitSequenceNumber=null;this._pendingSubmitModifierKeys=null;this._pendingSubmitTimeStamp=null},u.prototype.onAfterKeyDown=function(i,r,u){var f,e;if(this._partialQuery&&(i!=13&&(this._page.hideTemporaryMessage(),this.resetPendingSubmitSequenceNumber()),(!t.DialogBox||!t.DialogBox.isVisible())&&!this._headerFooterViewModel.isScopesL2Visible())){if(!u&&n.isContextMenuKey(i,r.shiftKey,!1)&&!this._headerFooterViewModel.isScopesL2Visible()){this.tryShowContextMenuOnSelectedSuggestion();return}if(this._contextMenu.isContextMenuVisible()){n.isUpOrDownKey(i)||i==13||this._contextMenu.dismiss();return}if(this._previewPane&&t.previewPaneAvailable&&this._selectedItem&&this.isSuggestion(this._selectedItem)){this._previewPane.onAfterKeyDownWhenSuggestionSelected(i,this._partialQuery,this._selectedItem);if(this._previewPane.hasFocus())return}n.isUpOrDownKey(i)&&this._selectedItem&&(this._selectedItem==this.topResults[0]?this._page.scrollToTop():this._page.scrollTo(this._selectedItem),this._headerFooterViewModel.isScopeElement(this._selectedItem)?(_ge(this._selectedItem.id).focus(),this._host.searchBoxHasFocus()&&SearchAppWrapper.CortanaApp.focusWebView()):this._host.setFocusInSearchBox("onAfterKeydown"));t.config.forceTypedQueryOnTopSupported&&i==46&&this._partialQuery&&this._selectedItem&&this._selectedItem===this.topResults[0]&&this.topResults[0].query.toLocaleLowerCase()!=this._partialQuery.queryToFetch.toLocaleLowerCase()&&(f=this._host.getQuery(),f.originalQuery==this._partialQuery.originalQuery&&(e=f.originalCursorPosition==f.originalQuery.length,e&&this._host.reformulate(this._partialQuery.originalQuery,null,1)))}},u.prototype.onKeyUp=function(i,r,u){if(i==9&&this._selectedItem&&!t.config.searchBoxFocusEvents){var f=n.getCurrentActiveElement();this.renderSelectedSuggestionState(!t.isBodyOrSuggestion(f));return}if(!u&&n.isContextMenuKey(i,r.shiftKey,!0)&&!this._headerFooterViewModel.isScopesL2Visible()){this.tryShowContextMenuOnSelectedSuggestion();return}},u.prototype.tryShowContextMenuOnSelectedSuggestion=function(){var n=this._selectedItem&&this.isSuggestion(this._selectedItem)?this._selectedItem:null,t;n&&(t=_ge(n.id),this.showContextMenu(n,120,t.offsetTop+this._page.getScrollTop()+24))},u.prototype.onQueryChanged=function(r,u){var c=this,l,e,p,w,b,o,s,a,v,h,y,f;if(t.DialogBox&&t.DialogBox.hide(),this._contextMenu.dismiss(),!this._partialQuery||!this._partialQuery.equals(r)){if(this._page.hideTemporaryMessage(),t.config.dataSourcesWithProgressBar.length>0&&(this._progressTimer&&(sb_ct(this._progressTimer),this._progressTimer=null),r.showProgressBar?this._progressTimer=sb_st(function(){return n.safeExecute(function(){c._progressTimer&&(c._page.setProgressIndicatorVisibility(!0),c._progressTimer=null)},"showProgress")},250):this._page.setProgressIndicatorVisibility(!1)),this._partialQuery&&this._partialQuery.scope!=r.scope&&(this._turnOnIndexingInstItem||this.hideIndexingMessage()),l=this._partialQuery?this._partialQuery.queryToFetch:"",e=r.queryToFetch,this._previewPane&&t.previewPaneAvailable)this._previewPane.onQueryChanged(r);for(p=this._partialQuery?this._partialQuery.scope:t.Scope.All,i.prototype.onQueryChanged.call(this,r,u),w=t.qfMode!=3&&t.config.glyphInSearchBox==1,w&&r.scope!=p&&(b=t.ScopeConfig[r.scope],r.scope==t.Scope.All?this._host.setSearchBoxGlyphIcon():this._host.setSearchBoxGlyphIcon(b.icon)),o=!1,s=0,a=this.topResults;sl.length&&e.startsWith(l)&&f.query.toLowerCase().includes(r.queryToFetch.toLowerCase())&&(v=f.text.indexOf(HitHighlightingParser.endMarker),v>=0&&v0&&this._partialQuery.fullPartialQuery&&this.showDisableEnterMessage()},u.prototype.doubleClickGuardedHandler=function(t){var i;return function(r,u){i&&n.getCurrentDate().getTime()-i<=250||(i=n.getCurrentDate().getTime(),t(r,u))}},u.prototype.click=function(n,i,r,u){this._page.hideTemporaryMessage();var f=this.isGroup(i)?null:i;if(!i.instItem||f&&f.isReformulation||this._instrumentationHelper.instrumentItemClick(n,i.instItem,i.sequenceNumber,f?f.instrumentPingBack:null,r,u),!f){i.click(n);return}u=u||this._host.getModifierKeyState();u.ctrlKey&&u.shiftKey?this.launchVerb(f,v,n):u.shiftKey?this.launchVerb(f,y,n):f.click(n);t.qfMode!=3||f.isReformulation||this._host.updateQueryWithoutRefetching("");this.onSuggestionLaunch(f,this._partialQuery)},u.prototype.onSuggestionLaunch=function(n,r,u){t.isChildSuggestion(n)&&(n=n.parent);i.prototype.onSuggestionLaunch.call(this,n,r,u)},u.prototype.launchVerb=function(i,r,u){var f=b("launchVerb",i,t.config.rawVerbs,!1,function(f){for(var h,c,o=!1,l=function(i){if(i.verb&&i.verb.toLocaleLowerCase()==r.toLocaleLowerCase())return i.executeSync?n.safeExecute(function(){return i.executeSync()},"verb.executeSync",null,r):t.Promise.safeChain("verb.executeAsync",function(){return i.executeAsync()},null,null,null,r),o=!0,"break"},e=0,s=f;eo)return h.groups.splice(r,0,n),u=!0,"break"},h=this,r=0;r0||n.length>0)&&this.showDisableEnterMessage();else{var t=this.topResults[0];return this._instrumentationHelper.instrumentItemClick(this._pendingSubmitTimeStamp,t.instItem,t.sequenceNumber,t.instrumentPingBack,1,this._pendingSubmitModifierKeys),this._pendingSubmitModifierKeys&&this._pendingSubmitModifierKeys.ctrlKey&&this._pendingSubmitModifierKeys.shiftKey?this.launchVerb(t,v,this._pendingSubmitTimeStamp):this._pendingSubmitModifierKeys&&this._pendingSubmitModifierKeys.shiftKey?this.launchVerb(t,y,this._pendingSubmitTimeStamp):t.click(this._pendingSubmitTimeStamp),0}}finally{this.resetPendingSubmitSequenceNumber()}return 1},u.prototype.showDisableEnterMessage=function(){this._page.showTemporaryMessage(this._host.getLocString("EnterOnAmbiguousTopHitMessageText"),{content:"",type:2})},u.prototype.showIndexingMessage=function(i){var r=this,u;t.isMobileCache||(t.config.showEnableIndexerLink&&!i?(this._turnOnIndexingInstItem=n.InstrumentedItem.getNonSuggestionInstrumentedItem("IMIO",t.SyntheticQSCodesMaps.KValues),u={text:this._host.getLocString("WindowsIndexingDisabledAction"),instItem:this._turnOnIndexingInstItem,click:function(i){var f=n.getCurrentTime(),u=r._sequenceNumberReader.getSequenceNumber();u>r._lastUpdatedSequenceNumber&&r._instrumentationHelper.instrumentSyntheticInstrumentedItem(u,"IMIO",r._turnOnIndexingInstItem);r._instrumentationHelper.instrumentItemClick(f,r._turnOnIndexingInstItem,u,null,n.getInputType(i));t.LocalDataProvider.launchIndexingOptions(r._host,!1)}}):this._turnOnIndexingInstItem=null,this._page.showIndexingMessage(i,u))},u.prototype.hideIndexingMessage=function(){t.isMobileCache||(this._turnOnIndexingInstItem=null,this._page.hideIndexingMessage())},u.prototype.getAvailableSpace=function(n){var r=this,i;return t.isL2(this._partialQuery)&&this._partialQuery.queryToFetch?Number.MAX_VALUE:(i=this._page.getSuggestionsContainerHeight(),t.config.extraTopPadding&&!t.searchBoxOnTop&&(i-=t.config.extraTopPadding),t.scopesAvailable&&(i-=ui),n.topResults.length==0||t.shouldRenderFlatListWithoutGroups(this._partialQuery)||(i-=dt),n.topResults.forEach(function(n){return i-=vt(n,t.isL2(r._partialQuery))}),n.groups.forEach(function(n){return i-=ci(r._partialQuery,n)}),n.groups.some(function(n){return n.typeWithSource&&t.isTopHitChildGroup(n.typeWithSource)})&&n.groups.some(function(n){return n.typeWithSource&&!t.isTopHitChildGroup(n.typeWithSource)})&&(i-=ri),i)},u.prototype.canFitSuggestion=function(t,i,u){if(u.suppressed)return!0;var e=at(this._resultsCounter),f;return t?(f={typeWithSource:i,suggestions:[]},e.groups.push(f)):f=r(e.groups,i),f.suggestions.push({mainTextWrapsToTwoLines:u&&o(u,i.type,!1),isSuppressed:u&&u.suppressed,hasTwoLines:u&&n.contains(u.classNames,"forceNoWrapOutsideTopResult")}),this.getAvailableSpace(e)>=0},u.prototype.getMaxNumberOfGroupsToFitMinSuggestionsPerGroup=function(){var i,r,u,n,f;if(t.isL2(this._partialQuery)&&this._partialQuery.queryToFetch)return Number.MAX_VALUE;for(i=at(this._resultsCounter),r=0,u=i.groups;r0){for(n={suggestions:[]},f=0;f0&&(u.cssClasses+=t.isL2(this._partialQuery)?" gridLayout":" gridLayout gridLayoutMedium")},u.prototype.onGroupsCleared=function(){this._pendingSuggestionsInExistingGroups=[];this._pendingSuggestionsInMissingGroups=[];this._resultsCounter.groups=[];this._turnOnIndexingInstItem&&this._instrumentationHelper.instrumentSyntheticInstrumentedItem(this._lastUpdatedSequenceNumber,"IMIO",this._turnOnIndexingInstItem)},u.prototype.launchSearch=function(n,t){var i=n.queryToFetch;this._host.launchSearch(i,this._navigationHelper.getSearchUrl(n.fullPartialQuery,i,t),!1)},u.prototype.setRemoveIconHistorySuggestions=function(i){var r=this,u=i.getExtraVerbs&&i.getExtraVerbs(!1).some(function(n){return n.verb=="RemoveFromDeviceHistory"}),e=i.type=="HS"&&t.config.removeSuggUrl,o=t.config.th&&ClientTestHooks.isTesthookParamSet("forceRemoveIcon"),f;(o||u||e)&&(f=u?"RemoveFromDeviceHistory":"RemoveFromWebHistory",i.removeIcon={icon:{content:"",type:2},title:this._host.getLocString(u?"RemoveFromDeviceHistory":"RemoveFromWebHistory"),click:function(t){var u=n.getCurrentTime();t.stopPropagation();r._page.hideTemporaryMessage();r._instrumentationHelper.instrumentItemClick(u,i.instItem,i.sequenceNumber,i.instrumentPingBack,n.getInputType(t),null,f);r.launchVerb(i,f,u);r._host.setFocusInSearchBox("remove")}})},u.prototype.updateNarratorWithPreviewMessage=function(n){var r=t.alwaysWide?"PreviewPaneButtonNarratorMessageWidePane":"PreviewPaneButtonNarratorMessage",i=this._host.getLocString(r);n.narratorText&&t.supportsPreview(n)!=0&&n.narratorText.indexOf(i)==-1&&(n.narratorText+=", "+i)},u.prototype.onBeforeRenderTopResults=function(i,r,u,f){var e=this,s,c,h;this.topResults.forEach(function(n){e.setRemoveIconHistorySuggestions(n);e.updateNarratorWithPreviewMessage(n)});s=1;this.topResults.length!=1||this.topResults[0].hasChildSuggestionsDisplayed||r.some(function(n){return t.isChildSuggestion(n)})&&(this.topResults[0].hasChildSuggestionsDisplayed=!0,s=0);c=this.getSelectableItems();this._selectedItem&&n.contains(c,this._selectedItem)&&!this._headerFooterViewModel.isScopeElement(this._selectedItem)&&(this._selectedItem!=i[0]||this.topResults[0]==i[0])||(h=this._partialQuery.queryToFetch&&this.topResults.length>0?this.topResults[0]:null,this._previewPane&&t.previewPaneAvailable&&n.safeExecute(function(){return e._previewPane.onTopHitUpdated(e._partialQuery,e._selectedItem&&e.isSuggestion(e._selectedItem)?e._selectedItem:null,h,e.getSuggestions(!1))},"ppOnTopHitUpdated 1"),this.select(h,!1),this._page.scrollToTop());var l=this.topResults.length>0,o=function(n){return!n.suppressed&&(!t.config.recourseOnlyInGroups||!t.isRecourse(n))},a=l||r.some(o)||this.groups.some(function(n){return n.suggestions.some(o)})||this._pendingSuggestionsInMissingGroups.some(function(n){return n.suggestions.some(o)})||this._pendingSuggestionsInExistingGroups.some(function(n){return n.suggestions.some(o)});return this._headerFooterViewModel.render(this._partialQuery,l,a,u,f),s},u.prototype.isRankable=function(n){return n.typeWithSource.type!=t.GroupType.SearchSuggestions&&n.typeWithSource.type!=t.GroupType.Websites&&n.typeWithSource.type!=t.GroupType.LocalPlaces&&!n.suggestions.some(t.enforceOriginalOrder)},u.prototype.isNotRankableWithRecourse=function(n){return n.typeWithSource.type==t.GroupType.Emails},u.prototype.openPreviewPane=function(n,t){t.stopPropagation();this._previewPane.showPreview(this._partialQuery,n);this.select(n,!0);this._host.setFocusInSearchBox("openPreviewPane")},u.prototype.mayNeedFlush=function(){return!t.shouldRenderFlatListWithoutGroups(this._partialQuery)},u.prototype.shouldRenderGroup=function(i){return t.previewPaneAvailable&&t.config.suppressedGroups&&n.contains(t.config.suppressedGroups,i)?!1:!0},u.prototype.update=function(i,r,u,f,e,s,h,c,l,a){var v=this,k=this.topResults,w,d,y,it;i&&(this._contentQuery=this._partialQuery);var tt=this.updateTopResults(i,r,u,f,e,l),ft=tt[0],et=tt[1];for(et(),this._resultsCounter.topResults=[],w=0,d=this.topResults;w0&&this._selectedItem==this.topResults[0]&&this._autoComplete.apply(this.topResults[0]),this.handlePendingSubmit(e)==0)return this.removeProgressBar(),0;var b=!1,g=0,rt=function(){b&&g==0&&(v._instrumentationHelper.instrumentRenderFinished(f,h),b=!1)},nt=function(n,t){var r=!1,i;if(v.isRankable(t)&&v._partialQuery&&v._partialQuery.queryToFetch)for(i=0;it.suggestions[i].rankingScore){t.suggestions.splice(i,0,n);r=!0;break}r||t.suggestions.push(n);g+=1;v.setupIcon(f,n,!1,function(){g-=1;rt()});v.onSuggestionAddedToGroup(n,t)},p=this.getMaxNumberOfGroupsToFitMinSuggestionsPerGroup()-this.groups.length,ut=function(){var i,r,n,e;if(p!=0&&u||v.flush(nt,f,c),v._partialQuery&&v._partialQuery.queryToFetch)for(v.groups.sort(function(n,i){return c.findIndex(function(i){return t.sameGroup(i,n.typeWithSource)})-c.findIndex(function(n){return t.sameGroup(n,i.typeWithSource)})}),i=0,r=v.groups;i0||s.length>0?(this.renderGroupsAfter(function(){for(var et,h,l,g,y,tt,w,it,r,b,rt,o=0,d=s;o0&&v.canFitSuggestion(!1,u,n)?nt(n,r):v.queueSuggestionInExistingGroup(n,r)):p>0&&v.canFitSuggestion(!0,u,n)?(r=v.addGroup(u,n,f,c,a),v.shouldTrackGroupCount(r)&&(r.count=1),nt(n,r),p-=1):v.queueSuggestionInMissingGroup(n,u,a))},l=0,g=k;l0})||this._pendingSuggestionsInExistingGroups.some(function(n){return n.suggestions.length>0}))&&(this.renderGroupsAfter(function(){return ut()}),b=!0),t.alwaysWide&&this.topResults.length==0&&this.groups.length>0&&this.autoSelectTopResultWhenNoTopHit(),rt(),l&&this.removeProgressBar(),1},u.prototype.autoSelectTopResultWhenNoTopHit=function(){var f=this,t=this.groups,i,r,u,o,s,e;if(t.length!=0&&!t[0].suggestions[0].selected){for(u=0;u=0){r=u;break}r>=0?(r>0&&(o=t[r],t.splice(r,1),t.unshift(o)),i>0&&(s=t[0].suggestions[i],t[0].suggestions.splice(i,1),t[0].suggestions.unshift(s))):(e=t[0].suggestions[0],n.safeExecute(function(){return f._previewPane.onTopHitUpdated(f._partialQuery,undefined,e,f.getSuggestions(!1))},"ppOnTopHitUpdated 2"),this.select(e,!1))}},u.prototype.populateGroupHeaderFlags=function(n){if(t.canGoToL2(n)){var i=n.suggestions.every(function(n){return n.suppressed});n.showCountInHeader=i}},u.prototype.shouldTrackGroupCount=function(n){return t.canGoToL2(n)},u.prototype.getGroupData=function(n){var i={type:t.getGroupType(n),source:n.sourceForGroup};return[i,r(this.groups,i)]},u.prototype.removePendingSuggestionFromExistingGroup=function(n,t){for(var r,u,i=0;i0&&i.length>0){var u=i[0];this.canFitSuggestion(!1,t.typeWithSource,u)&&r(u,t);i.splice(0,1);n-=1}},u.prototype.flush=function(n,i,r){for(var e,s,u,c,l=this,a=function(u){var o=u.suggestions[0],e;o&&f.canFitSuggestion(!0,u.typeWithSource,o)&&(e=f.addGroup(u.typeWithSource,o,i,r,u.extraSignalsMap),f.shouldTrackGroupCount(e)&&(e.count=u.suggestions.length),f.partialFlush(t.config.minSuggestionsPerGroup,e,u.suggestions,n),u.suggestions.forEach(function(n){return l.queueSuggestionInExistingGroup(n,e)}),u.suggestions=[])},f=this,o=0,h=this._pendingSuggestionsInMissingGroups;o0}))for(e=0,s=this._pendingSuggestionsInExistingGroups;e