You are on page 1of 4

var WSB;(function(n){const i="QSCH";class r extends n.

JsonDataProvider{getName()
{return"QuickSearchSuggestionsDataProvider"}constructor()
{super("QSCH");this._lastTypedQuery=new u;(n.TestHookUrlParameters===null||
n.TestHookUrlParameters===void 0?void
0:n.TestHookUrlParameters.mockLastQuery)&&this._lastTypedQuery.setQuery(n.TestHookU
rlParameters.mockLastQuery);n.Host.bindDismissed(n=>{n&&n.queryToFetch&&this._lastT
ypedQuery.setQuery(n.fullPartialQuery)})}fetch(n,t){if(n.enabledDataSources[i]){let
u={};u=r.getQuickSearchResponse(u);t(i,u,undefined)}}static
getQuickSearchResponse(t){let
i=n.ScopeConfig[n.Scope.Web]&&n.ScopeConfig[n.Scope.Web].prefixes?
n.ScopeConfig[n.Scope.Web].prefixes[0]:null,r=n.Host.getLanguage().toLowerCase();if
(n.shouldEnableQuickSearches(r)){let
u=[];t.quickAnswers=n.getQuickAnswersTranslatedSuggestions(r);t.quickAnswers.forEac
h(n=>{i?u.push(i.toLowerCase()+": "+n.query):u.push(n.query)})}return
t}}n.QuickSearchSuggestionsDataProvider=r;class u{constructor()
{this.LastTypedQueryTTLms=6e5}getQuery(){const t=n.getCurrentTime();return
this._lastTypedQueryTimeStamp&&t-
this._lastTypedQueryTimeStamp<this.LastTypedQueryTTLms?this._lastTypedQuery:
(this._lastTypedQuery=null,this._lastTypedQueryTimeStamp=null,null)}setQuery(t)
{this._lastTypedQuery=t;this._lastTypedQueryTimeStamp=n.getCurrentTime()}}class
t{constructor(n)
{this._navigationHelper=n;t.navigationHelper=this._navigationHelper}parse(n,i,r,u,f
,e){let o=[];t.parseQuickSearchSuggestions(n,i,r,u,o);e(r,o,undefined)}static
parseQuickSearchSuggestions(i,r,u,f,e){let
o=n.ScopeConfig[n.Scope.Web]&&n.ScopeConfig[n.Scope.Web].prefixes?
n.ScopeConfig[n.Scope.Web].prefixes[0]:null;if(f&&f.resumeSearchQuery){let
o="RSSG",t=n.createSuggestion(i,n.Host.getLocString("RedoLastSearch"),null,
{type:2,content:"&#xE81C"},o,f.resumeSearchQuery,n.InstrumentedItem.createInstrumen
tedItemForReformulation(r,o),998,r,n.localDataSourceMayContainPII(u)),s={verb:"Remo
veFromDeviceHistory",displayName:n.Host.getLocString("RemoveFromDeviceHistory"),exe
cuteSync:f.resumeSearchRemoveAction,icon:
{content:"&#xE711",type:2}};t.tooltip=n.Host.getLocString("RedoYourLastSearchToolti
p",f.resumeSearchQuery);n.setExtraVerbs(t,()=>[s],!
1);t.click=()=>{n.Host.reformulate(f.resumeSearchQuery),n.Host.setFocusInSearchBox(
null,`$
{o}.click`)};t.reactKey=o+f.resumeSearchQuery;e.push(t)}if(f&&f.quickAnswers){let
s="QSSG";for(let h of f.quickAnswers){let
c=n.config.quickSearchToMsnMarkets[n.getCurrentLanguage()]&&h.msnUrl,l=(h.type===2|
|h.type===1)&&n.config.enableShopSH1,a=n.config.quickSearchToEdge||c||
l,f=n.createSuggestion(i,h.text?h.text:h.query,null,n.config.quickAnswerWeb?
{type:2,content:"&#xE721"}:h.icon,s,h.query,a?
n.InstrumentedItem.createInstrumentedItem(r,s):n.InstrumentedItem.createInstrumente
dItemForReformulation(r,s),a?c?20:l?
15:0:998,r,n.localDataSourceMayContainPII(u));f.tooltip=c?
h.msnTooltip:h.tooltip;f.click=()=>{var
u,r;if(c)n.Host.launchUriAsync(h.msnUrl);else if(l&&f.handoffType===15){r="";const
i=n.Host.getLanguage().toLowerCase(),o="entrypoint=wsb&setmkt="+i,e=(u=f.query)===n
ull||u===void 0?void 0:u.toLowerCase(),s=n.encodeQueryParameter(e);r=(i=="en-au"||
i=="en-ca"||i=="en-gb"||i=="en-us")&&e==="valentine's day gifts"?"/shop/valentines-
day?":e==="geschenke zum valentinstag"?"/shop/valentins-tag?":e==="cadeaux pour la
saint-valentin"?"/shop/saintvalentin?":"/shop?
q="+s;r+="&"+o;n.Host.launchSearchAsync(h.query,t.navigationHelper.getSearchUrl(h.q
uery,h.query,"SW",r,15,n.mapOSFormCode("WNSGPH")),f.useRaf)}else
if(a)n.Host.launchSearchAsync(h.query,t.navigationHelper.getSearchUrl(h.query,h.que
ry,"SW",null,0),f.useRaf);else{let t=h.query;o&&(t=o.toLowerCase()+":
"+t);n.Host.reformulateOnSuggestionClick(t,i.isSearchHomeZI,s,h.serpURLParams);n.Ho
st.setFocusInSearchBox(null,`$
{s}.click`)}};f.reactKey=s+h.query;e.push(f)}}}}n.QuickSearchSuggestionsParser=t})
(WSB||(WSB={})),function(n){class t extends
n.JsonDataProvider{constructor(n="DFLS"){super(n);this.dataSourceType=n}getName()
{return
this.dataSourceType=="DFLS"?"CuratedSuggestionsDataProvider":"CuratedSettingsDataPr
ovider"}fetch(t,i,r,u)
{t.enabledDataSources[this.dataSourceType]&&(this.dataSourceType=="DFLS"?
n.Async.safeChain("CuratedSuggestionsFetch",
()=>SearchAppWrapper.CortanaApp.queryFormulationView.deviceSearch.getAllAppsAsync()
,n=>i(this.dataSourceType,n,undefined),null,u):this.dataSourceType=="CUSE"&&i(this.
dataSourceType,null,undefined))}}n.CuratedSuggestionsDataProvider=t;class
i{constructor(n){this.dataSourceType=n!==null&&n!==void 0?
n:"DFLS"}parse(n,t,i,r,u,f){let e=[];this.dataSourceType=="DFLS"?
this.parseCuratedSuggestions(n,t,i,r,e):this.dataSourceType=="CUSE"&&this.parseCura
tedSettings(n,t,i,r,e);f(i,e,undefined)}addSettingSuggestion(t,i,r,u,f,e,o){let
h="DFLS",s=n.createSuggestion(f,r,null,{type:u==="&#xE771"?
1:2,content:u},h,f.fullPartialQuery,n.InstrumentedItem.createInstrumentedItem(e,h),
2,e,n.localDataSourceMayContainPII(this.dataSourceType));s.click=()=>n.Host.launchU
riAsync(i,!
0);s.tooltip=s.text;s.reactKey=h+s.text;s.query=s.text;s.staticGroupType=o;t.push(s
);s.narratorText=s.text}addAppSuggestion(t,i,r,u,f){if(i){let o=i[r];if(o){let
s=n.getIcon(o,o.id+"_"+o.filePath+"_"+o.displayName,"curatedSuggestion",!0,!
1,null,o.isImmersive&&o.logoBackgroundColor,0),e=n.createSuggestion(u,o.displayName
,s,null,"DFLS",u.fullPartialQuery,n.InstrumentedItem.createInstrumentedItem(f,"PP")
,2,f,n.localDataSourceMayContainPII(this.dataSourceType));e.deviceItem=o;e.click=()
=>n.Host.launchAppItemAsync(o,this.dataSourceType);e.tooltip=e.text;e.reactKey="PP"
+e.text;e.query=e.text;e.staticGroupType=n.GroupType.CuratedSuggestions;e.narratorT
ext=e.text;t.push(e)}}}parseCuratedSettings(t,i,r,u,f)
{this.addSettingSuggestion(f,"ms-
settings:quiethours",n.Host.getLocString("FocusSettingSuggestion"),null,t,i,n.Group
Type.CuratedSettings);this.addSettingSuggestion(f,"ms-
settings:sound",n.Host.getLocString("SoundSettingsSuggestion"),null,t,i,n.GroupType
.CuratedSettings);this.addSettingSuggestion(f,"ms-
settings:bluetooth",n.Host.getLocString("BluetoothSettingsSuggestion"),null,t,i,n.G
roupType.CuratedSettings);this.addSettingSuggestion(f,"ms-
settings:display",n.Host.getLocString("DisplaySettingsSuggestion"),null,t,i,n.Group
Type.CuratedSettings);this.addSettingSuggestion(f,"ms-
settings:colors",n.Host.getLocString("ColorSettingsSuggestion"),null,t,i,n.GroupTyp
e.CuratedSettings);this.addSettingSuggestion(f,"ms-settings:search-
permissions",n.Host.getLocString("SearchSettings"),null,t,i,n.GroupType.CuratedSett
ings)}parseCuratedSuggestions(t,i,r,u,f){n.config.useCobaltCSS?
(this.addAppSuggestion(f,u,"MicrosoftWindows.Client.CBS_cw5n1h2txyewy!
WebExperienceHost",t,i),this.addAppSuggestion(f,u,"MSEdge",t,i),this.addAppSuggesti
on(f,u,"Microsoft.Getstarted_8wekyb3d8bbwe!
App",t,i),this.addSettingSuggestion(f,"ms-
settings:emailandaccounts",n.Host.getLocString("EmailSettingSuggestion"),"&#xE715",
t,i,n.GroupType.CuratedSuggestions),this.addAppSuggestion(f,u,"Microsoft.ScreenSket
ch_8wekyb3d8bbwe!App",t,i),this.addSettingSuggestion(f,"ms-
settings:windowsupdate",n.Host.getLocString("UpdateSettingSuggestion"),"&#xE895",t,
i,n.GroupType.CuratedSuggestions),this.addAppSuggestion(f,u,"Microsoft.Paint_8wekyb
3d8bbwe!App",t,i),this.addSettingSuggestion(f,"ms-
settings:themes",n.Host.getLocString("ThemeSettingSuggestion"),"&#xE771",t,i,n.Grou
pType.CuratedSuggestions),this.addAppSuggestion(f,u,"Microsoft.SkyDrive.Desktop",t,
i),this.addAppSuggestion(f,u,"Microsoft.WindowsCalculator_8wekyb3d8bbwe!
App",t,i),this.addSettingSuggestion(f,"ms-
settings:bluetooth",n.Host.getLocString("BluetoothSettingSuggestion"),"&#xE772",t,i
,n.GroupType.CuratedSuggestions),this.addAppSuggestion(f,u,"microsoft.windowscommun
icationsapps_8wekyb3d8bbwe!
microsoft.windowslive.mail",t,i),this.addAppSuggestion(f,u,"Microsoft.Windows.Explo
rer",t,i)):
(this.addAppSuggestion(f,u,"MSEdge",t,i),this.addAppSuggestion(f,u,"Microsoft.Getst
arted_8wekyb3d8bbwe!App",t,i),this.addSettingSuggestion(f,"ms-
settings:emailandaccounts",n.Host.getLocString("EmailSettingSuggestion"),"&#xE715",
t,i,n.GroupType.CuratedSuggestions),this.addAppSuggestion(f,u,"{1AC14E77-02E7-4E5D-
B744-2EB1AE5198B7}\\SnippingTool.exe",t,i),this.addSettingSuggestion(f,"ms-
settings:windowsupdate",n.Host.getLocString("UpdateSettingSuggestion"),"&#xE895",t,
i,n.GroupType.CuratedSuggestions),this.addAppSuggestion(f,u,"Microsoft.Windows.Comp
uter",t,i),this.addAppSuggestion(f,u,"{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\
mspaint.exe",t,i),this.addSettingSuggestion(f,"ms-
settings:themes",n.Host.getLocString("ThemeSettingSuggestion"),"&#xE771",t,i,n.Grou
pType.CuratedSuggestions),this.addAppSuggestion(f,u,"Microsoft.SkyDrive.Desktop",t,
i),this.addAppSuggestion(f,u,"{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\
notepad.exe",t,i),this.addAppSuggestion(f,u,"Microsoft.Windows.Explorer",t,i),this.
addAppSuggestion(f,u,"Microsoft.GetHelp_8wekyb3d8bbwe!
App",t,i),this.addAppSuggestion(f,u,"microsoft.windowscommunicationsapps_8wekyb3d8b
bwe!
microsoft.windowslive.mail",t,i),this.addAppSuggestion(f,u,"windows.immersivecontro
lpanel_cw5n1h2txyewy!
microsoft.windows.immersivecontrolpanel",t,i))}}n.CuratedSuggestionsParser=i}(WSB||
(WSB={})),function(n){const
t="TS",i=n.config.trendingSearchUpdateMillis,r=500,u="/dsb/scenario?
name=EditorialTrendingSearch",f="/dsb/scenario?name=TrendingSearchWithCache";class
e{getName(){return"TrendingSearchDataProvider"}constructor()
{this.WSBTSCacheStorageKey="WSBTrendingSearchCache";n.Host.bindShown(()=>{n.isTSFal
lbackToANA=!1})}fetch(n,i)
{n.enabledDataSources[t]&&i(t,this.generateTSDataResponse(),null)}generateTSDataRes
ponse(){let t=[];if(n.MockUrlParameters&&typeof
n.MockedTSData=="object")return{suggestions:n.MockedTSData.suggestions};const
r=this.loadTSContentFromWSBCache();if(n.isTSFallbackToANA=!1,r)
{const{cacheTime:u,trendingSearchSuggestions:f}=r;t=[...f];(u===0||
u+i<n.getCurrentTime())&&this.fetchTSUrlWithTimeout().then(t=>{t&&n.Host.refreshCur
rentPane()})}else{const
i=this.loadTSContentFromDSBCache();i?t=[...i.trendingSearchSuggestions]:
(n.isTSFallbackToANA=!
0,n.Host.refreshCurrentPane());this.fetchTSUrl()}return{suggestions:t}}async
fetchTSUrlWithTimeout(){let i=!1,t=n.safeSetTimeout(()=>{i=!
0},r,"fetchTSContentTimer");const u=async()=>{const n=await
this.fetchTSUrl();return n?i?
(SharedLogHelper.LogWarning("fetchTrendingSearchContentDone","Fetch trending search
content succeed but timeout, will render on next shown"),!1):
(t&&(sb_ct(t),t=null),!0):!1};return await u()}async fetchTSUrl(){const
o=n.isBrowserOnline(),r=n.Host.getLanguage().toLowerCase(),i=n.Host.getRegion().toL
owerCase(),e=n.revIpRegionCache.toLowerCase();let s;s=e=="cn"||i=="cn"||
i=="hk"&&r.startsWith("zh")?u:f;let t=`${location.origin}$
{s}`;t=ThresholdUtilities.setUrlParameter(t,"cc",i);t=ThresholdUtilities.setUrlPara
meter(t,"setlang",r);try{let f=await fetch(t),u=await
f.json(),s={ImpressionGuid:u.impressionGuid};if(f.status==200)
{if(this.isValidTSContent(u))return
this.setTSContentToCache({cacheTime:n.getCurrentTime(),trendingSearchSuggestions:u.
scenarios[0].items}),n.isTSFallbackToANA=!
1,n.InstrumentationHelper.instrumentDSBEvent(s),!
0;n.InstrumentationHelper.instrumentDSBEvent(s);throw new Error(`Invalid trending
search content. Online status ${o}. Response data ${u?
JSON.stringify(u):"undefined"}.`);}else if(f.status==203){const t=e=="cn"?`and
revip $
{e}`:null;n.InstrumentationHelper.instrumentDSBEvent(s);SharedLogHelper.LogWarning(
"fetchTrendingSearchUrl",`Trending Search is not supporting this region ${i} and
language ${r} ${t}`)}else throw new Error(`http status:${f.status}. Online status $
{o}`);}catch(h){}return n.isTSFallbackToANA=!0,n.Host.refreshCurrentPane(),!
1}isValidTSContent(n){var t;return(n===null||n===void 0?void
0:n.scenarios)&&(n===null||n===void 0?void
0:n.scenarios.length)>0&&((t=n.scenarios[0])===null||t===void 0?void
0:t.items)&&n.scenarios[0].items.length>0}setTSContentToCache(t)
{n.LightweightStorage.setItem(this.WSBTSCacheStorageKey,JSON.stringify(t))}loadTSCo
ntentFromWSBCache(){const
t=n.LightweightStorage.getItem(this.WSBTSCacheStorageKey);return t?
JSON.parse(t):null}loadTSContentFromDSBCache(){var t,i,r,u,f;const
e=n.LightweightStorage.getItem(n.config.dsbCacheKey);if(e){const
o=JSON.parse(e),n=(r=(i=(t=o.response)===null||t===void 0?void
0:t.ContentCollection[0])===null||i===void 0?void 0:i.Data)===null||r===void 0?void
0:r.filter(n=>{var t;return((t=n===null||n===void 0?void 0:n.Cards[0])===null||
t===void 0?void 0:t.Scenario)=="TrendingSearch"});if(n&&(n===null||n===void 0?void
0:n.length)==1){const t=(f=(u=n[0].Cards[0].FieldsStore)===null||u===void 0?void
0:u.Items)===null||f===void 0?void 0:f.map(n=>{var
t,i,r,u;return{Query:n.Title,Thumbnail:{ThumbnailUrl:(t=n.Thumbnail)===null||
t===void 0?void 0:t.ThumbnailUrl,ThumbnailId:(i=n.Thumbnail)===null||i===void 0?
void 0:i.ThumbnailId,ThumbnailHeight:(r=n.Thumbnail)===null||r===void 0?void
0:r.ThumbnailHeight,ThumbnailWidth:(u=n.Thumbnail)===null||u===void 0?void
0:u.ThumbnailWidth}}});return{cacheTime:o.cacheTime,trendingSearchSuggestions:t?
t:null}}}return null}}n.TrendingSearchDataProvider=e;class o{constructor(n)
{this._navigationHelper=n}parse(t,i,r,u,f,e){let o=[];for(let e of
u.suggestions)n.safeExecute(()=>this.parseTrendingSearchDataSuggestion(t,e,r,i,f,o)
,"parseTrendingSearchDataSuggestion
"+r);e(r,o,null)}parseTrendingSearchDataSuggestion(t,i,r,u,f,e){var o;const
s="TS",c=n.InstrumentedItem.createInstrumentedItem(u,s),h=i.Query;if(f()){let
r=n.createSuggestion(t,h,null,null,s,h,c,0,u,!1);if(n.isThumbnailForTSEnabled())
{const t=(o=i.Thumbnail)===null||o===void 0?void 0:o.ThumbnailId;if(t){const
i=24,u=24,f=n.config.imageHostName+`${t}${i?`&w=${i}`:""}${u?`&h=$
{u}`:""}&c=1&rs=1&p=0`;r.icon={type:0,content:f}}}r.reactKey=`${s} $
{h}`;r.click=n.config.enableMoreEdgeProtocol?
()=>{n.Host.launchSearchAsync(r.query,this._navigationHelper.getSearchUrl(t.fullPar
tialQuery,r.query,r.type,null,r.handoffType,n.mapOSFormCode("SSHTRD")),r.useRaf,n.m
apOSFormCode("SSHTRD"))}:
()=>{n.Host.launchSearchAsync(r.query,this._navigationHelper.getSearchUrl(t.fullPar
tialQuery,r.query,r.type,null,r.handoffType,n.mapOSFormCode("SSHTRD")),r.useRaf)};e
.push(r)}}}n.TrendingSearchDataParser=o}(WSB||(WSB={}))

You might also like