You are on page 1of 3

var FailedPromise=function(){function n(){this.isActive=!

0;this.operation=null}return n.prototype.then=function(n,t){return
this.handleError(t),this},n.prototype.done=function(n,t)
{this.handleError(t)},n.prototype.handleError=function(n)
{this.isActive&&n&&_w.setImmediate(function(){return
n(null)})},n.prototype.cancel=function(){this.isActive=!1},n}
(),ThresholdUtilitiesM2=function(){function
n(){this.regExes={};this.guidCleaner=/[-{}]/g;this.isFirstPageStart=!
0;this.startTime=_w.performance?
_w.performance.timing.navigationStart:si_ST;this.apiSequenceNumber=0;this.headersAs
yncPromise=null;this.headersCallComplete=!
1;this.cortanaHeaders=null;this.themeColor=null;this.isDarkTheme=null;this.headersC
allTimeout=3e3;this.headersCallbacks=[];this.rtlLangs=["ar","dv","fa","he","ku-
arab","pa-arab","prs","ps","sd-arab","syr","ug","ur","qps-
plocm"];sj_evt.bind("ajax.threshold.authChanged",sj_dm(this,this.clearLocalCache),1
);sj_evt.bind("ajax.threshold.pageStart",sj_dm(this,this.onPageStart),1)}return
n.prototype.getUrlParameter=function(n,t){for(var
r=null,f=this.getParameterRegex(t),u,i;u=f.exec(n);)i=u;return i&&i.length>=2?
r=i[1]:t==="mock"&&(r=this.getMockParameter(n)),r},n.prototype.setUrlParameter=func
tion(n,t,i){var r=n,u=this.getParameterRegex(t).exec(n),f="&",e,o,s;return u?
(f=u[0].substring(0,1),e=u.index,o=u.index+u[0].length,r=n.substring(0,e),i&&(r+=f+
t+"="+i),r+=n.substring(o)):i&&(s=this.getRegex("devicecontent"),s.test(n)?
n.indexOf("#")<0&&(f="#"):n.indexOf("?")<0&&(f="?"),r=n+f+t+"="+i),r},n.prototype.g
etDecodedQuery=function(n){var i=n,t;return i||
(i=_w.location.href),t=this.getUrlParameter(i,"q"),t&&(t=decodeURIComponent(t.repla
ce(this.getRegex("\\+")," ")).trim()),t},n.prototype.getUrlReadyQuery=function(n)
{return
encodeURIComponent(n).replace(this.getRegex("%20"),"+")},n.prototype.recordApiTimeD
etail=function(n,t,i){var u=new Date,f,r,e,o;if(n&&(_G.ApiTimes=_G.ApiTimes||
{},_G.ApiTimes[n]=u.getTime()-this.startTime),i){f={};for(r in
i)i.hasOwnProperty(r)&&(f[r]=i[r]);i=f;i.time=u}else i={time:u,label:n||
t,sequence:this.apiSequenceNumber++};return
e=_w.msWriteProfilerMark,o=i.sequence+","+(n||
i.label),e&&e(o),_w.performance&&performance.mark&&performance.mark(o),i},n.prototy
pe.recordApiTime=function(n){return
this.recordApiTimeDetail(n),null},n.prototype.uploadApiTimes=function(n){var
t=_G.ApiTimes;this.recordApiTime(n);t&&typeof Log2!
="undefined"&&Log2&&(Log2.LogEvent("CPT2",
{wt:t},null,null,null,null,null,null),_G.ApiTimes={})},n.prototype.wrapSynchronousA
piCall=function(n,t,i,r){for(var e,o,s,h=this,f=[],u=4;u<arguments.length;u++)f[u-
4]=arguments[u];e=this.recordApiTimeDetail(i?i+"S":null,t);s=function(n,u){var
o=h.recordApiTimeDetail(i?i+n:null,t,e),s=u?" exception:
"+u.stack:"";h.recordApiString("ApiEnd "+n+' \t"'+(r?r:"")+'"\t'+t+"("+f.join(", ")
+")\t"+(o.time.getTime()-e.time.getTime())+"ms
elapsed"+s)};try{o=n[t].apply(n,f);s("C")}catch(c)
{s("E",c);SharedLogHelper.LogError("Exception","Failed while calling
overrideMethod: "+t,c);o=null}return o},n.prototype.wrapApiCall=function(){for(var
i,n=[],t=4;t<arguments.length;t++)n[t-
4]=arguments[t];for(n=[],i=0;i<arguments.length;i++)n.push(arguments[i]);return
n.splice(4,0,0,null),this.wrapApiCallWithTimeout.apply(this,n)},n.prototype.wrapApi
CallWithTimeout=function(n,t,i,r,u,f){for(var y,s=[],h=6;h<arguments.length;h+
+)s[h-6]=arguments[h];if(_w.SearchAppWrapperLogging)return n[t].apply(n,s);var
l=this,a=this.recordApiTimeDetail(i?i+"S":null,t),e,o,c=function(n,u){var
e="stack",o=l.recordApiTimeDetail(i?i+n:null,t,a),f=u&&u[e]?" exception:
"+u[e]:"";u&&f===""&&(f=" Windows error: "+u.message);l.recordApiString("ApiEnd
"+n+' \t"'+(r?r:"")+'"\t'+t+"("+s.join(", ")+")\t"+(o.time.getTime()-
a.time.getTime())+"ms
elapsed"+f)};try{o=n[t].apply(n,s);this.recordApiTimeDetail(i?
i+"P":null,t);u&&u>0&&(e=sb_st(function()
{o&&o.cancel&&o.cancel();c("T");f&&f(null)},u));o.then(function(n){return
e&&sb_ct(e),c("C"),n},function(n)
{e&&sb_ct(e);c("E",n);SharedLogHelper.LogError("Exception","Failed in
overrideMethod callback: "+t,n);f&&f(null)})}catch(v)
{e&&sb_ct(e);c("E",v);SharedLogHelper.LogError("Exception","Failed while calling
overrideMethod: "+t,v);y=new FailedPromise;o=y.then(null,f)}return
o},n.prototype.cleanGuid=function(n){var t=n;return
t&&(t=t.replace(this.guidCleaner,"")),t},n.prototype.parseJSON=function(n){var
t,i=null;if(n)try{t=JSON.parse(n)}catch(r){i=r}return t||console.log("Unable to
parse JSON input: "+n+(i?". Exception:
"+i:"")),t},n.prototype.getCortanaHeaders=function(n){var
f=this,t=this;if(this.headersCallComplete)
{n(this.cortanaHeaders);return}if(this.headersCallbacks.push(n),!
this.headersAsyncPromise){var i=null,e=!1,u=function()
{i&&(sb_ct(i),i=null);t.headersCallComplete=!0},r=function(){var i,r,n;if(!
e)for(t.cortanaHeaders||(t.cortanaHeadersTimedOut?
SharedLogHelper.LogWarning("getCortanaHeaders",null,"Timeout"):SharedLogHelper.LogE
rror("getCortanaHeaders",null,t.cortanaHeadersError||new Error("Missing
headers"))),i=t.headersCallbacks,r=i.length,n=0;n<r;n++)i[n]
(t.cortanaHeaders)},s=function(n){u();var
i={};try{Object.keys(n).forEach(function(t){n[t]&&(i[t]=n[t].toString())})}catch(e)
{SharedLogHelper.LogError("getCortanaHeaders","copy headers failed.
".concat(e))}f.headerOverrides(i);t.cortanaHeaders=i;t.cortanaHeadersError=null;t.c
ortanaHeadersTimedOut=!1;r()},h=function(n)
{try{u();f.headerOverrides(n);t.cortanaHeaders=n;t.cortanaHeadersError=null;t.corta
naHeadersTimedOut=!1;r()}catch(i)
{SharedLogHelper.LogError("getCortanaHeaders","getQueryHeadersJsonStringAsync
response not valid ".concat(i))}},o=function(n)
{u();t.cortanaHeaders=null;t.cortanaHeadersError=n;t.cortanaHeadersTimedOut=!
1;r()};i=sb_st(function()
{t.cortanaHeaders=null;t.cortanaHeadersError=null;t.cortanaHeadersTimedOut=!
0;r();e=!0},this.headersCallTimeout);this.headersAsyncPromise=_w.WSB&&!!
WSB.config&&WSB.config.wsbWebView2&&SearchAppWrapper.CortanaApp.webRequestHelper?
this.wrapApiCall(SearchAppWrapper.CortanaApp.webRequestHelper,"getQueryHeadersJsonS
tringAsync","GQH_","getQueryHeadersJsonString").then(function(n){return
h(JSON.parse(n))},o):this.wrapApiCall(SearchAppWrapper.CortanaApp,"getQueryHeadersA
sync","GQH_","getQueryHeaders").then(s,o)}},n.prototype.headerOverrides=function(n)
{var
t=SearchAppWrapper.CortanaApp.width,i=SearchAppWrapper.CortanaApp.height,r;t&&i&&(n
["X-BM-
DeviceDimensionsLogical"]=t+"x"+i,r=SearchAppWrapper.CortanaApp.deviceScale,r!
=100&&(t=t*r/100,i=i*r/100),n["X-BM-DeviceDimensions"]=t+"x"+i);_w.WSB&&!!
WSB.config&&(delete n["X-Search-RPSToken"],delete
n.Authorization)},n.prototype.getThemeColor=function(n){function u(n){var
t,r;i.themeColor===null&&n&&(t=n.split(";"),t.length==2&&(i.isDarkTheme=t[0]=="0000
00",r=t[1],r&&(i.themeColor="#"+r)))}var t=this,i=this,r;this.themeColor===null?
(r=SearchAppWrapper.CortanaApp.theme,typeof r!="undefined"?
(u(r),n(this.themeColor,this.isDarkTheme)):this.getCortanaHeaders(function(i)
{t.themeColor===null&&i&&(u(i["X-BM-
Theme"]),n(t.themeColor,t.isDarkTheme))})):n(this.themeColor,this.isDarkTheme)},n.p
rototype.getOsSKU=function(n){var t="X-Device-
OSSKU";this.getCortanaHeaders(function(i){i&&i[t]?
n(i[t]):n("unknown")})},n.prototype.isRightToLeftLanguage=function(n){return
this.rtlLangs.some(function(t){return n=n.toLocaleLowerCase(),n==t||
n.indexOf(t+"-")==0})},n.prototype.setBodyLangAttributes=function(n)
{_d.body.setAttribute("dir",this.isRightToLeftLanguage(n)?"rtl":"ltr");_d.body.setA
ttribute("lang",n)},n.prototype.recordApiString=function(n)
{ThresholdDiagnostics.recordApiString(n)},n.prototype.pushOntoArray=function(n,t)
{if(n&&t)for(var i in t)n.push(t[i])},n.prototype.navigateTo=function(n,t){var
i=sj_ce("a","b_hide");i.href=n;i.setAttribute("data-
h",t.GetNamespacedKValue());_d.body.appendChild(i);i.click()},n.prototype.createPro
mise=function(n){return Promise.promise?Promise.promise(n):new
Promise(n)},n.prototype.getParameterRegex=function(n){return this.getRegex("[?
&#]"+n.toLowerCase()+"=([^&#]*)")},n.prototype.getRegex=function(n,t,i){var
r=this.regExes[n];return r||(r=new RegExp(n,(i?"":"g")+
(t?"":"i")),this.regExes[n]=r),r.lastIndex=0,r},n.prototype.getMockParameter=functi
on(n){var r=null,t=n.indexOf("#"),u,i;return t>0&&t<n.length-
1&&(u=n.substr(t+1).split("&"),i=u.filter(this.unlabeledParameterFilter),i.length>0
&&(r=i[0])),r},n.prototype.unlabeledParameterFilter=function(n){return
n.indexOf("=")<0},n.prototype.clearLocalCache=function()
{this.cortanaHeaders=null;this.cortanaHeadersError=null;this.cortanaHeadersTimedOut
=!1;this.themeColor=null;this.headersAsyncPromise=null;this.headersCallComplete=!
1;this.headersCallbacks=[]},n.prototype.onPageStart=function(n){!
this.isFirstPageStart&&n[1]&&(this.startTime=n[1],this.clearLocalCache());this.isFi
rstPageStart=!1;sj_evt.fire("ajax.postload")},n}();_w.ThresholdUtilities=new
ThresholdUtilitiesM2;sj_evt.bind("threshold.pageUnload",function()
{sj_evt.fire("unload")},0)

You might also like