var __extends=this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);r.prototype=t.prototype;n.prototype=new r},AutoSuggest;(function(n){var t;(function(t){function e(n,t){var i=n.query?n.query:HitHighlightingParser.removeMarkers(n.text),r=i?i.length:0;return n.additionalInfoText&&!t&&(r+=n.additionalInfoText.length),r>(t?at:vt)}function nt(n){var t={topResults:n.topResults.slice(0),groups:[]};return n.groups.forEach(function(n){t.groups.push({type:n.type,suggestions:n.suggestions.slice(0)})}),t}function tt(n){if(n.isAnswer)return ot;var t=n.hasAdditionalInfoText?et:ft;return n.wrapsToTwoLines&&(t+=p),t}function pt(n){if(n.isSuppressed)return 0;var t=rt;return n.wrapsToTwoLines&&(t+=p),t}function u(n){return n.scope==0&&!n.taskFrame}function wt(n,i,r){var f=y,e,o;return i.type&&t.useGridLayout(r,n,i.type)?(e=Math.ceil(i.suggestions.length/(u(n)?d:k)),o=u(n)?b:w,f+=o*e,f+=2*c):i.type&&(i.type===19||i.type===9)?i.suggestions.forEach(function(n){return f+=tt({wrapsToTwoLines:!1,hasAdditionalInfoText:!0,isAnswer:!1,isSuppressed:n.isSuppressed})}):i.suggestions.forEach(function(n){return f+=pt(n)}),f}function bt(n){switch(n){case 0:return t.SearchServiceStatus.ContinuePending;case 7:return t.SearchServiceStatus.Disabled;case 1:return t.SearchServiceStatus.PausePending;case 2:return t.SearchServiceStatus.Paused;case 4:return t.SearchServiceStatus.StartPending;case 5:return t.SearchServiceStatus.StopPending;case 6:return t.SearchServiceStatus.Stopped}return undefined}function l(n,t){return n.length>0&&t.length>0?n.concat(yt).concat(t):n.length>0?n:t.length>0?t:[]}var a=6,o=8,f=12,v=3,i=1,r=20,s=16,rt=r+2*o,y=s+2*o,ut=y,ft=r+s+v+2*f,et=r+2*(s+v)+2*f,ot=80+2*f,h=r+2*f+i,st=40,ht=o+i,p=r,ct=48,lt=i,c=1,w=t.IconSize_GridLayout+2*(a+i),b=t.IconSize_GridLayout_Medium+2*(a+i),k=3,d=4,at=39,vt=42,yt={verb:null,displayName:null,executeAsync:null},g="Classic_{87d66a43-7b11-4a28-9811-c86ee395acf7}",kt=function(){function n(){}return n.PersistentDisambig="WNSMYS",n}(),it;t.joinVerbsWithSeparator=l;it=function(i){function r(r,u,f,e,o,s,h,l){var a=this,v,y;i.call(this,r,u,e,o,h);this._host=u;this._autoComplete=f;this._navigationHelper=s;this._scopesViewModel=l;this.permanentDisambig=[];this._pendingSubmitSequenceNumber=-1;this._pendingSubmitModifierKeys=null;this._resultsCounter={topResults:[],groups:[]};this._suggestionsContainerHeight=0;this._initialized=!1;this._animateProactiveCards=!0;this._container=_ge("qfContainer");h.setContextMenuHandler(function(n,t){return a.showContextMenu(n,t.pageX,t.pageY)});h.setSuggestionClickHandler(function(n){return a.click(n)});h.setRemoveSuggestionClickHandler(function(n){return a.remove(n)});u.bindKeyDown(function(n,t){return a.onKeyDown(n,t)});u.bindKeyUp(function(n){return a.onKeyUp(n)});v=SearchAppWrapper.CortanaApp.searchBox.isMock;u.bindAppVisible(function(){ThresholdUtilities.getCortanaHeaders(function(n){var u,r,f,i;n&&(u=n["X-BM-DeviceDimensionsLogical"],u&&(r=u.split("x"),r.length==2&&((t.isMobileCache||v)&&(f=_ge("root"),f.style.height=r[1]+"px"),i=parseInt(r[0]),i&&(d=Math.floor((i-2*c)/b),k=Math.floor((i-2*c)/w),v&&(f.style.width=i+"px")))))});a.resetSuggestionsContainerHeight()});u.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(bt(n));n!=0&&n!=4&&n!=3&&n!=7&&a.showIndexingMessage(!1)})});u.bindDismissed(function(){a.removeProgressBar();t.ContextMenus.dismiss();a._page.hideTemporaryMessage();a.hideIndexingMessage();a._initialized=!1;a._animateProactiveCards=!0;a.permanentDisambig=[];a._config.showMyStuffLinks&&a.renderPermanentDisambig();a._scopesViewModel.render(null,!1,!0,!1,!0)});h.bindOnNarratorLaunch(function(n){for(var i=a.getSelectableItems(),t=0;t0&&tu&&this.scrollToSuggestion(r,_d.body,u))},r.prototype.scrollToSuggestion=function(n,t,i){var u=t.scrollTop,r=n.offsetTop,f=r+n.offsetHeight;f>u+i?t.scrollTop=f-i:ro.length&&f.startsWith(o)&&n.query&&n.query.toLowerCase().includes(r.queryToFetch.toLowerCase())){var t=n.text.indexOf(HitHighlightingParser.endMarker);t>=0&&te&&f.width>e&&t.updateRatio(i,f);r()};t.getIconDimensions(i.icon,f)}else r()},r.prototype.getImageSize=function(n,i,r){return r?0:t.useGridLayout(this._config,n,i.type)?u(n)?3:2:1},r.prototype.allowUnselectedState=function(){return this.topResults.length==0},r.prototype.isGroup=function(n){return!!n.suggestions},r.prototype.submit=function(i,r,u,f){var e=t.ContextMenus.getSelectedItem(),o=f?2:0;if(e){e.click(o,u);r();return}var s=n.getCurrentActiveElement(),h=!t.isBodyOrSuggestion(s),c=this._host.isRequestFocusAvailable();if(h){c||(s.click(),r());return}if(this._lastUpdatedSequenceNumber!=i&&(!this._selectedItem||this._selectedItem==this.topResults[0])){this._pendingSubmitSequenceNumber=i;this._pendingSubmitModifierKeys=u;this._stopFurtherProcessing=r;return}this._selectedItem?(this._selectedItem.instItem&&this._instrumentationHelper.instrumentCustomGping(o,this._selectedItem.instItem.getHValue(),null,u),this.click(this._selectedItem,u),r()):this.groups.length>0&&this._partialQuery.fullPartialQuery&&this.showDisableEnterMessage()},r.prototype.click=function(n,i){if(n.instItem&&this._instrumentationHelper.instrumentItemClick(n.sequenceNumber,n.sequenceNumber>this._lastUpdatedSequenceNumber),this.isGroup(n)){n.click();return}var r=n;if(!r.suppressed){i=i||this._host.getModifierKeyState();i.ctrlKey&&i.shiftKey?this.launchVerb(r,t.Verbs.LaunchAsAdmin):i.shiftKey?this.launchVerb(r,t.Verbs.OpenInNewWindow):r.click();this.onSuggestionLaunch(r)}},r.prototype.remove=function(n){this._instrumentationHelper.instrumentItemClick(n.sequenceNumber);this.launchVerb(n,t.Verbs.RemoveFromDeviceHistory);n.suppressed=!0;this._host.setFocusInSearchBox("remove")},r.prototype.launchVerb=function(n,i){this.getDeviceItemVerbsAsync("launchVerb",n,function(r){var u=!1;r.forEach(function(n){n.verb==i&&(t.Promise.safeChain(i+".executeAsync",function(){return n.executeAsync()}),u=!0)});u||n.click()})||n.click()},r.prototype.showContextMenu=function(n,i,r){var u=this;this.getDeviceItemVerbsAsync("showContextMenu",n,function(f){return t.ContextMenus.showContextMenu(f,i,r,function(t,i,r){u._instrumentationHelper.instrumentItemClick(n.sequenceNumber);u._instrumentationHelper.instrumentCustomGping(i,n.instItem.getHValue(),t,r)},u._page,function(){return u._host.setFocusInSearchBox("contextMenuClick")})})},r.prototype.getDeviceItemVerbsAsync=function(n,i,r){var f=this,o=t.asJumpListSuggestion(i),u,e;return o?(t.Promise.safeChain("jumpListItem.getVerbsAsync",function(){return o.jumpListItem.getVerbsAsync()},function(n){return f.handleExtraVerbsAsync(n.slice(0),i,u,r)},function(){return f.handleExtraVerbsAsync([],i,u,r)},null,n+" "+i.type),!0):(u=n+" "+i.type,e=t.getItemWithFileMetadata(i),e&&e.canHaveContextMenu)?(t.Promise.safeChain("getVerbsAsync",function(){return e.getVerbsAsync()},function(n){return f.handleExtraVerbsAsync(n.slice(0),i,u,r)},function(){return f.handleExtraVerbsAsync([],i,u,r)},null,u),!0):i.getExtraVerbsAsync?(this.handleExtraVerbsAsync([],i,u,r),!0):i.getExtraVerbs?(this.handleExtraVerbs([],i,r),!0):!1},r.prototype.handleExtraVerbsAsync=function(n,i,r,u){var f=this;i.getExtraVerbsAsync?t.Promise.safeChain("getExtraVerbsAsync",function(){return i.getExtraVerbsAsync()},function(t){return f.handleExtraVerbs(l(n,t),i,u)},function(){return f.handleExtraVerbs(n,i,u)},null,r):this.handleExtraVerbs(n,i,u)},r.prototype.handleExtraVerbs=function(n,t,i){t.getExtraVerbs?i(l(n,t.getExtraVerbs())):i(n)},r.prototype.getGroupHeaderClickAction=function(i,r,u){var f=this,o,e,s;if(!t.isMobileCache&&(o=t.getScope(r),o!=0))return o==i.scope?[null,null]:[function(){return f._scopesViewModel.clickHandler(o,"groupHeader")},null];switch(r){case 10:e=function(){return f._host.launchStoreSearch(i.queryToFetch)};break;case 11:e=function(){return f.launchSearch(i,u)};break;case 12:e=function(){return f._host.launchFolder(f.getFolderPathForPathCompletion(i))}}if(e){if(!u)throw"No QS code for: "+n.GroupType[r];return s=n.InstrumentedItem.getNonSuggestionInstrumentedItem(u,t.SyntheticQSCodes.KValues),[e,s]}return[null,null]},r.prototype.getFolderPathForPathCompletion=function(n){return n.queryToFetch.substring(0,this._partialQuery.queryToFetch.lastIndexOf("\\"))},r.prototype.getGroupTitleAndNarratorText=function(i,r,u,f){var e,o,s,h;if(r==12)return e=this.getFolderPathForPathCompletion(i)+"\\"+String.fromCharCode(8206),{title:e,narratorText:e};if(t.isJumpListGroup(r))return e=t.asJumpListSuggestion(u).groupDisplayName,{title:e,narratorText:e};switch(r){case 3:e=this._host.getLocString("CommandGroup");break;case 2:e=this._host.getLocString("CortanaGroup");break;case 10:e=this._host.getLocString("StoreGroup");break;case 13:e=this._host.getLocString("PowerBIGroup");break;case 21:e=this._host.getLocString("EdgeHistoryGroup")}if(o=this._host.getLocString("AddingScopeNarratorText"),e)return{title:e,narratorText:f?n.formatString(o,[e]):e};if(s=t.getScope(r),s==0)throw new Error("Unknown group type: "+r);return h=t.ScopeConfig[s],e=t.getScopeDisplayName(h,this._host),{title:e,narratorText:f?n.formatString(o,[e]):e}},r.prototype.createGroup=function(i,r,u){var e=t.GroupHeaderQSCodes[i],o=this.getGroupHeaderClickAction(this._partialQuery,i,e),s=o[0],f=o[1],h=this.getGroupTitleAndNarratorText(this._partialQuery,i,r,s),c="",l;return t.isJumpListGroup(i)&&(c+=" jumpList"),l={type:i,id:"gr"+i,title:h.title,narratorText:h.narratorText,click:s,suggestions:[],instRegionName:n.GroupType[i],instItem:f,selected:!1,cssClasses:c,sequenceNumber:u},f&&this._instrumentationHelper.instrumentSyntheticInstrumentedItem(u,e,f),this._resultsCounter.groups.push({type:i,suggestions:[]}),l},r.prototype.onAfterRenderTopResults=function(i,r){var f=this,u;if(this._resultsCounter.topResults=[],this.topResults.forEach(function(n){f._resultsCounter.topResults.push({wrapsToTwoLines:e(n,!0,f._host),hasAdditionalInfoText:!!n.additionalInfoTextForTopResult||!!n.stars,isAnswer:!!n.answerHtml,isSuppressed:!1})}),this._autoComplete&&this.topResults.length>0&&this._selectedItem==this.topResults[0]&&this._autoComplete.apply(this.topResults[0]),this._pendingSubmitSequenceNumber==this._lastUpdatedSequenceNumber)try{if(this.topResults.length==0)(this.groups.length>0||r.length>0)&&this.showDisableEnterMessage();else return this._instrumentationHelper.instrumentCustomGping(0,this.topResults[0].instItem.getHValue(),null,this._pendingSubmitModifierKeys),this._pendingSubmitModifierKeys&&this._pendingSubmitModifierKeys.ctrlKey&&this._pendingSubmitModifierKeys.shiftKey?this.launchVerb(this.topResults[0],t.Verbs.LaunchAsAdmin):this._pendingSubmitModifierKeys&&this._pendingSubmitModifierKeys.shiftKey?this.launchVerb(this.topResults[0],t.Verbs.OpenInNewWindow):this.topResults[0].click(),this._stopFurtherProcessing(),0}finally{this.resetPendingSubmitSequenceNumber()}return n.isDataSourceEnabled(t.DataSources.Proactive,this._partialQuery,this._config)&&!this._partialQuery.fullPartialQuery&&this.topResults.length>0&&(n.Ajax.onAfterRender(),u=_ge("b_results"),this._animateProactiveCards?(this._animateProactiveCards=!1,Animation.cascadeList(u)):u.classList.remove("b_slideListHide")),1},r.prototype.showDisableEnterMessage=function(){this._page.showTemporaryMessage(this._host.getLocString("EnterOnAmbiguousTopHitMessageText"),{content:t.CortanaFontIcons.Info,type:2})},r.prototype.showIndexingMessage=function(n){var r=this,i;t.isMobileCache||(i=this._page.showIndexingMessage(n,this._config.showEnableIndexerLink&&!n?function(){return t.Promise.safeChain("showIndexingMessage_findSettingsAsync",function(){return SearchAppWrapper.CortanaApp.queryFormulationView.deviceSearch.findSettingsAsync([g])},function(n){var t=n[g];t&&r._host.launchDeviceItem(t,"showIndexingMessage")})}:null),i&&this.resetSuggestionsContainerHeight())},r.prototype.hideIndexingMessage=function(){t.isMobileCache||this._page.hideIndexingMessage()&&this.resetSuggestionsContainerHeight()},r.prototype.allowedInGroups=function(n){return n.handoffType==6?!n.miniAnswerOnly&&n.type!=t.OnlineSuggestionTypes.GenericTp2Answer:!0},r.prototype.resetSuggestionsContainerHeight=function(){this._suggestionsContainerHeight=0},r.prototype.calculateSuggestionsContainerHeight=function(){var t=_ge("root").clientHeight,i=_ge("indexingMessage");t-=i.offsetHeight;this._config.showMyStuffLinks?(n.safeExecute(function(){var n=_ge("permanentDisambig").firstChild.offsetHeight;h!=n&&(_ge("container").style.height=t-n+"px",h=n)},"getting permanent disambig height"),this._suggestionsContainerHeight=t-h):this._suggestionsContainerHeight=t},r.prototype.getAvailableSpace=function(n){var r=this,i,u,f;return this._suggestionsContainerHeight||this.calculateSuggestionsContainerHeight(),i=this._suggestionsContainerHeight,this._config.extraPadding&&!this._host.getFeatureEnabled(t.SearchBoxOnTopFeatureName).featureEnabled&&(i-=this._config.extraPadding),t.isOemEnabled()&&(u=t.ScopeConfig[this._partialQuery.scope],u.canUseOemDataSources&&(i-=st)),f=this._config.scopesOrder.length>0&&(this._config.scopeBarAtBottom||this._host.getFeatureEnabled(t.SearchBoxOnTopFeatureName).featureEnabled),f&&(i-=lt),this._config.scopesOrder.length>0&&(i-=ct),n.topResults.length!=0&&(i-=ut),(this._partialQuery.scope!=0||this._partialQuery.taskFrame)&&this._partialQuery.queryToFetch&&(i*=2),n.topResults.forEach(function(n){return i-=tt(n)}),n.groups.forEach(function(n){return i-=wt(r._partialQuery,n,r._config)}),n.groups.some(function(n){return n.type&&t.isJumpListGroup(n.type)})&&n.groups.some(function(n){return n.type&&!t.isJumpListGroup(n.type)})&&(i-=ht),i},r.prototype.canFitSuggestion=function(n,t,i){if(!this._partialQuery.fullPartialQuery)return!0;var u=nt(this._resultsCounter),r;return n?(r={type:t,suggestions:[]},u.groups.push(r)):r=u.groups.filter(function(n){return n.type==t})[0],r.suggestions.push({wrapsToTwoLines:i&&e(i,!1,this._host),isSuppressed:i&&i.suppressed}),this.getAvailableSpace(u)>=0},r.prototype.getMaxNumberOfGroupsToFitMinSuggestionsPerGroup=function(){var r=this,n=nt(this._resultsCounter),t,i;for(n.groups.forEach(function(n){while(n.suggestions.length0;){for(t={type:undefined,suggestions:[]},i=0;i0?this.topResults[0]:null,!1),this.scrollToTop()),s=this.topResults.length>0,c=!s&&this.groups.length==0&&!r.some(function(n){return h.canFitSuggestion(!0,t.getGroupType(n),n)}),this._scopesViewModel.render(this._partialQuery,s,c,u,f),e},r.prototype.renderPermanentDisambig=function(){this._page.updatePermanentDisambigView(this.permanentDisambig)},r.prototype.renderTopResults=function(){n.isDataSourceEnabled(t.DataSources.Proactive,this._partialQuery,this._config)&&!this._partialQuery.fullPartialQuery?(this.topResults.length>0&&n.Ajax.onBeforeRender(),this._page.updateProactiveCardsView(this.topResults)):i.prototype.renderTopResults.call(this)},r.prototype.renderGroups=function(){n.isDataSourceEnabled(t.DataSources.Proactive,this._partialQuery,this._config)&&!this._partialQuery.fullPartialQuery?this._page.updateZeroInputGroupsView(this.groups):i.prototype.renderGroups.call(this)},r.prototype.onSuggestionLaunch=function(n){this._partialQuery.useOemDataSources&&t.isFileOrFolder(n.type)||i.prototype.onSuggestionLaunch.call(this,n)},r.prototype.isRankable=function(n){var t=this;return n.type!=11&&n.type!=2&&!n.suggestions.some(function(n){return t._config.enforceOriginalOrderForTypes[n.type]})},r}(n.BaseRootViewModel);t.RootViewModel=it})(t=n.Windows||(n.Windows={}))})(AutoSuggest||(AutoSuggest={}))