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 f(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?pt:wt)}function a(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 v(n){if(n.isAnswer)return ct;var t=n.hasAdditionalInfoText?ht:st;return n.wrapsToTwoLines&&(t+=b),t}function rt(n){if(n.isSuppressed)return 0;var t=et;return n.wrapsToTwoLines&&(t+=b),t}function i(n){return n.scope==0&&!n.taskFrame}function ut(n,r,u){var f=w,e,o;return r.type&&t.useGridLayout(u,n,r.type)?(e=Math.ceil(r.suggestions.length/(i(n)?nt:g)),o=i(n)?d:k,f+=o*e,f+=2*l):r.type&&(r.type===19||r.type===9)?r.suggestions.forEach(function(n){return f+=v({wrapsToTwoLines:!1,hasAdditionalInfoText:!0,isAnswer:!1,isSuppressed:n.isSuppressed})}):r.suggestions.forEach(function(n){return f+=rt(n)}),f}function ft(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 o(n,t){return n.length>0&&t.length>0?n.concat(bt).concat(t):n.length>0?n:t.length>0?t:[]}var y=6,s=8,e=12,p=3,r=1,u=20,h=16,et=u+2*s,w=h+2*s,ot=w,st=u+h+p+2*e,ht=u+2*(h+p)+2*e,ct=80+2*e,c=u+2*e+r,lt=40,at=s+r,b=u,vt=48,yt=r,l=1,k=t.IconSize_GridLayout+2*(y+r),d=t.IconSize_GridLayout_Medium+2*(y+r),g=3,nt=4,pt=39,wt=42,bt={verb:null,displayName:null,executeAsync:null},tt="Classic_{87d66a43-7b11-4a28-9811-c86ee395acf7}",kt=function(){function n(){}return n.PersistentDisambig="WNSMYS",n}(),it;t.joinVerbsWithSeparator=o;it=function(r){function u(i,u,f,e,o,s,h,c){var a=this,v,y;r.call(this,i,u,e,o,h);this._host=u;this._autoComplete=f;this._navigationHelper=s;this._scopesViewModel=c;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&&(nt=Math.floor((i-2*l)/d),g=Math.floor((i-2*l)/k),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(ft(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))},u.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(i.queryToFetch.toLowerCase())){var t=n.text.indexOf(HitHighlightingParser.endMarker);t>=0&&te&&f.width>e&&t.updateRatio(r,f);u()};t.getIconDimensions(r.icon,f)}else u()},u.prototype.getImageSize=function(n,r,u){return u?0:t.useGridLayout(this._config,n,r.type)?i(n)?3:2:1},u.prototype.allowUnselectedState=function(){return this.topResults.length==0},u.prototype.isGroup=function(n){return!!n.suggestions},u.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()},u.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)}},u.prototype.remove=function(n){this._instrumentationHelper.instrumentItemClick(n.sequenceNumber);this.launchVerb(n,t.Verbs.RemoveFromDeviceHistory);n.suppressed=!0;this._host.setFocusInSearchBox("remove")},u.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()},u.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")})})},u.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},u.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(o(n,t),i,u)},function(){return f.handleExtraVerbs(n,i,u)},null,r):this.handleExtraVerbs(n,i,u)},u.prototype.handleExtraVerbs=function(n,t,i){t.getExtraVerbs?i(o(n,t.getExtraVerbs())):i(n)},u.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]},u.prototype.getFolderPathForPathCompletion=function(n){return n.queryToFetch.substring(0,this._partialQuery.queryToFetch.lastIndexOf("\\"))},u.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}},u.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},u.prototype.onAfterRenderTopResults=function(i,r){var e=this,u;if(this._resultsCounter.topResults=[],this.topResults.forEach(function(n){e._resultsCounter.topResults.push({wrapsToTwoLines:f(n,!0,e._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},u.prototype.showDisableEnterMessage=function(){this._page.showTemporaryMessage(this._host.getLocString("EnterOnAmbiguousTopHitMessageText"),{content:t.CortanaFontIcons.Info,type:2})},u.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([tt])},function(n){var t=n[tt];t&&r._host.launchDeviceItem(t,"showIndexingMessage")})}:null),i&&this.resetSuggestionsContainerHeight())},u.prototype.hideIndexingMessage=function(){t.isMobileCache||this._page.hideIndexingMessage()&&this.resetSuggestionsContainerHeight()},u.prototype.allowedInGroups=function(n){return n.handoffType==6?!n.miniAnswerOnly&&n.type!=t.OnlineSuggestionTypes.GenericTp2Answer:!0},u.prototype.resetSuggestionsContainerHeight=function(){this._suggestionsContainerHeight=0},u.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;c!=n&&(_ge("container").style.height=t-n+"px",c=n)},"getting permanent disambig height"),this._suggestionsContainerHeight=t-c):this._suggestionsContainerHeight=t},u.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-=lt)),f=this._config.scopesOrder.length>0&&(this._config.scopeBarAtBottom||this._host.getFeatureEnabled(t.SearchBoxOnTopFeatureName).featureEnabled),f&&(i-=yt),this._config.scopesOrder.length>0&&(i-=vt),n.topResults.length!=0&&(i-=ot),(this._partialQuery.scope!=0||this._partialQuery.taskFrame)&&this._partialQuery.queryToFetch&&(i*=2),n.topResults.forEach(function(n){return i-=v(n)}),n.groups.forEach(function(n){return i-=ut(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-=at),i},u.prototype.canFitSuggestion=function(n,t,i){if(!this._partialQuery.fullPartialQuery)return!0;var u=a(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&&f(i,!1,this._host),isSuppressed:i&&i.suppressed}),this.getAvailableSpace(u)>=0},u.prototype.getMaxNumberOfGroupsToFitMinSuggestionsPerGroup=function(){var r=this,n=a(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},u.prototype.renderPermanentDisambig=function(){this._page.updatePermanentDisambigView(this.permanentDisambig)},u.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)):r.prototype.renderTopResults.call(this)},u.prototype.renderGroups=function(){n.isDataSourceEnabled(t.DataSources.Proactive,this._partialQuery,this._config)&&!this._partialQuery.fullPartialQuery?this._page.updateZeroInputGroupsView(this.groups):r.prototype.renderGroups.call(this)},u.prototype.onSuggestionLaunch=function(n){this._partialQuery.useOemDataSources&&t.isFileOrFolder(n.type)||r.prototype.onSuggestionLaunch.call(this,n)},u.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]})},u}(n.BaseRootViewModel);t.RootViewModel=it})(t=n.Windows||(n.Windows={}))})(AutoSuggest||(AutoSuggest={}))